Skip to content

Commit 35f3625

Browse files
minimaxwelldavem330
authored andcommitted
net: mvpp2: Extract the correct ethtype from the skb for tx csum offload
When offloading the L3 and L4 csum computation on TX, we need to extract the l3_proto from the ethtype, independently of the presence of a vlan tag. The actual driver uses skb->protocol as-is, resulting in packets with the wrong L4 checksum being sent when there's a vlan tag in the packet header and checksum offloading is enabled. This commit makes use of vlan_protocol_get() to get the correct ethtype regardless the presence of a vlan tag. Fixes: 3f51850 ("ethernet: Add new driver for Marvell Armada 375 network unit") Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a688caa commit 35f3625

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,7 +1725,7 @@ static void mvpp2_txq_desc_put(struct mvpp2_tx_queue *txq)
17251725
}
17261726

17271727
/* Set Tx descriptors fields relevant for CSUM calculation */
1728-
static u32 mvpp2_txq_desc_csum(int l3_offs, int l3_proto,
1728+
static u32 mvpp2_txq_desc_csum(int l3_offs, __be16 l3_proto,
17291729
int ip_hdr_len, int l4_proto)
17301730
{
17311731
u32 command;
@@ -2600,14 +2600,15 @@ static u32 mvpp2_skb_tx_csum(struct mvpp2_port *port, struct sk_buff *skb)
26002600
if (skb->ip_summed == CHECKSUM_PARTIAL) {
26012601
int ip_hdr_len = 0;
26022602
u8 l4_proto;
2603+
__be16 l3_proto = vlan_get_protocol(skb);
26032604

2604-
if (skb->protocol == htons(ETH_P_IP)) {
2605+
if (l3_proto == htons(ETH_P_IP)) {
26052606
struct iphdr *ip4h = ip_hdr(skb);
26062607

26072608
/* Calculate IPv4 checksum and L4 checksum */
26082609
ip_hdr_len = ip4h->ihl;
26092610
l4_proto = ip4h->protocol;
2610-
} else if (skb->protocol == htons(ETH_P_IPV6)) {
2611+
} else if (l3_proto == htons(ETH_P_IPV6)) {
26112612
struct ipv6hdr *ip6h = ipv6_hdr(skb);
26122613

26132614
/* Read l4_protocol from one of IPv6 extra headers */
@@ -2619,7 +2620,7 @@ static u32 mvpp2_skb_tx_csum(struct mvpp2_port *port, struct sk_buff *skb)
26192620
}
26202621

26212622
return mvpp2_txq_desc_csum(skb_network_offset(skb),
2622-
skb->protocol, ip_hdr_len, l4_proto);
2623+
l3_proto, ip_hdr_len, l4_proto);
26232624
}
26242625

26252626
return MVPP2_TXD_L4_CSUM_NOT | MVPP2_TXD_IP_CSUM_DISABLE;

0 commit comments

Comments
 (0)