Skip to content

Commit 7b90f5a

Browse files
robhancockseddavem330
authored andcommitted
net: macb: fix PTP TX timestamp failure due to packet padding
PTP TX timestamp handling was observed to be broken with this driver when using the raw Layer 2 PTP encapsulation. ptp4l was not receiving the expected TX timestamp after transmitting a packet, causing it to enter a failure state. The problem appears to be due to the way that the driver pads packets which are smaller than the Ethernet minimum of 60 bytes. If headroom space was available in the SKB, this caused the driver to move the data back to utilize it. However, this appears to cause other data references in the SKB to become inconsistent. In particular, this caused the ptp_one_step_sync function to later (in the TX completion path) falsely detect the packet as a one-step SYNC packet, even when it was not, which caused the TX timestamp to not be processed when it should be. Using the headroom for this purpose seems like an unnecessary complexity as this is not a hot path in the driver, and in most cases it appears that there is sufficient tailroom to not require using the headroom anyway. Remove this usage of headroom to prevent this inconsistency from occurring and causing other problems. Fixes: 653e92a ("net: macb: add support for padding and fcs computation") Signed-off-by: Robert Hancock <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Tested-by: Claudiu Beznea <[email protected]> # on SAMA7G5 Reviewed-by: Claudiu Beznea <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3e13469 commit 7b90f5a

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,7 +2187,6 @@ static int macb_pad_and_fcs(struct sk_buff **skb, struct net_device *ndev)
21872187
bool cloned = skb_cloned(*skb) || skb_header_cloned(*skb) ||
21882188
skb_is_nonlinear(*skb);
21892189
int padlen = ETH_ZLEN - (*skb)->len;
2190-
int headroom = skb_headroom(*skb);
21912190
int tailroom = skb_tailroom(*skb);
21922191
struct sk_buff *nskb;
21932192
u32 fcs;
@@ -2201,9 +2200,6 @@ static int macb_pad_and_fcs(struct sk_buff **skb, struct net_device *ndev)
22012200
/* FCS could be appeded to tailroom. */
22022201
if (tailroom >= ETH_FCS_LEN)
22032202
goto add_fcs;
2204-
/* FCS could be appeded by moving data to headroom. */
2205-
else if (!cloned && headroom + tailroom >= ETH_FCS_LEN)
2206-
padlen = 0;
22072203
/* No room for FCS, need to reallocate skb. */
22082204
else
22092205
padlen = ETH_FCS_LEN;
@@ -2212,10 +2208,7 @@ static int macb_pad_and_fcs(struct sk_buff **skb, struct net_device *ndev)
22122208
padlen += ETH_FCS_LEN;
22132209
}
22142210

2215-
if (!cloned && headroom + tailroom >= padlen) {
2216-
(*skb)->data = memmove((*skb)->head, (*skb)->data, (*skb)->len);
2217-
skb_set_tail_pointer(*skb, (*skb)->len);
2218-
} else {
2211+
if (cloned || tailroom < padlen) {
22192212
nskb = skb_copy_expand(*skb, 0, padlen, GFP_ATOMIC);
22202213
if (!nskb)
22212214
return -ENOMEM;

0 commit comments

Comments
 (0)