* [PATCH net] net: mvpp2: Extract the correct ethtype from the skb for tx csum offload
@ 2018-10-04 8:03 Maxime Chevallier
2018-10-04 8:08 ` [EXT] " Yan Markman
2018-10-04 9:50 ` Sergei Shtylyov
0 siblings, 2 replies; 4+ messages in thread
From: Maxime Chevallier @ 2018-10-04 8:03 UTC (permalink / raw)
To: davem
Cc: Maxime Chevallier, netdev, linux-kernel, Antoine Tenart,
thomas.petazzoni, gregory.clement, miquel.raynal, nadavh,
stefanc, ymarkman, mw
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>
---
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 38cc01beea79..4bd5b251e3c7 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -1737,7 +1737,7 @@ static u32 mvpp2_txq_desc_csum(int l3_offs, int l3_proto,
command |= (ip_hdr_len << MVPP2_TXD_IP_HLEN_SHIFT);
command |= MVPP2_TXD_IP_CSUM_DISABLE;
- if (l3_proto == htons(ETH_P_IP)) {
+ if (l3_proto == ETH_P_IP) {
command &= ~MVPP2_TXD_IP_CSUM_DISABLE; /* enable IPv4 csum */
command &= ~MVPP2_TXD_L3_IP6; /* enable IPv4 */
} else {
@@ -2600,14 +2600,15 @@ static u32 mvpp2_skb_tx_csum(struct mvpp2_port *port, struct sk_buff *skb)
if (skb->ip_summed == CHECKSUM_PARTIAL) {
int ip_hdr_len = 0;
u8 l4_proto;
+ int l3_proto = ntohs(vlan_get_protocol(skb));
- if (skb->protocol == htons(ETH_P_IP)) {
+ if (l3_proto == ETH_P_IP) {
struct iphdr *ip4h = ip_hdr(skb);
/* Calculate IPv4 checksum and L4 checksum */
ip_hdr_len = ip4h->ihl;
l4_proto = ip4h->protocol;
- } else if (skb->protocol == htons(ETH_P_IPV6)) {
+ } else if (l3_proto == ETH_P_IPV6) {
struct ipv6hdr *ip6h = ipv6_hdr(skb);
/* 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)
}
return mvpp2_txq_desc_csum(skb_network_offset(skb),
- skb->protocol, ip_hdr_len, l4_proto);
+ l3_proto, ip_hdr_len, l4_proto);
}
return MVPP2_TXD_L4_CSUM_NOT | MVPP2_TXD_IP_CSUM_DISABLE;
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [EXT] [PATCH net] net: mvpp2: Extract the correct ethtype from the skb for tx csum offload
2018-10-04 8:03 [PATCH net] net: mvpp2: Extract the correct ethtype from the skb for tx csum offload Maxime Chevallier
@ 2018-10-04 8:08 ` Yan Markman
2018-10-04 9:50 ` Sergei Shtylyov
1 sibling, 0 replies; 4+ messages in thread
From: Yan Markman @ 2018-10-04 8:08 UTC (permalink / raw)
To: Maxime Chevallier, davem
Cc: netdev, linux-kernel, Antoine Tenart, thomas.petazzoni,
gregory.clement, miquel.raynal, Nadav Haklai, Stefan Chulski, mw
I'm not sure that kind of ntohs() using is good for the Performance.
htons(ETH_P_IP) is CONSTANT swapped Big/LittleEndian by COMPILER whilst the
ntohs(vlan_get_protocol(skb)) is run-time short/byte-swap for every packet.
Yan Markman
-----Original Message-----
From: Maxime Chevallier [mailto:maxime.chevallier@bootlin.com]
Sent: Thursday, October 04, 2018 11:03 AM
To: davem@davemloft.net
Cc: Maxime Chevallier <maxime.chevallier@bootlin.com>; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Antoine Tenart <antoine.tenart@bootlin.com>; thomas.petazzoni@bootlin.com; gregory.clement@bootlin.com; miquel.raynal@bootlin.com; Nadav Haklai <nadavh@marvell.com>; Stefan Chulski <stefanc@marvell.com>; Yan Markman <ymarkman@marvell.com>; mw@semihalf.com
Subject: [EXT] [PATCH net] net: mvpp2: Extract the correct ethtype from the skb for tx csum offload
External Email
----------------------------------------------------------------------
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>
---
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 38cc01beea79..4bd5b251e3c7 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -1737,7 +1737,7 @@ static u32 mvpp2_txq_desc_csum(int l3_offs, int l3_proto,
command |= (ip_hdr_len << MVPP2_TXD_IP_HLEN_SHIFT);
command |= MVPP2_TXD_IP_CSUM_DISABLE;
- if (l3_proto == htons(ETH_P_IP)) {
+ if (l3_proto == ETH_P_IP) {
command &= ~MVPP2_TXD_IP_CSUM_DISABLE; /* enable IPv4 csum */
command &= ~MVPP2_TXD_L3_IP6; /* enable IPv4 */
} else {
@@ -2600,14 +2600,15 @@ static u32 mvpp2_skb_tx_csum(struct mvpp2_port *port, struct sk_buff *skb)
if (skb->ip_summed == CHECKSUM_PARTIAL) {
int ip_hdr_len = 0;
u8 l4_proto;
+ int l3_proto = ntohs(vlan_get_protocol(skb));
- if (skb->protocol == htons(ETH_P_IP)) {
+ if (l3_proto == ETH_P_IP) {
struct iphdr *ip4h = ip_hdr(skb);
/* Calculate IPv4 checksum and L4 checksum */
ip_hdr_len = ip4h->ihl;
l4_proto = ip4h->protocol;
- } else if (skb->protocol == htons(ETH_P_IPV6)) {
+ } else if (l3_proto == ETH_P_IPV6) {
struct ipv6hdr *ip6h = ipv6_hdr(skb);
/* 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)
}
return mvpp2_txq_desc_csum(skb_network_offset(skb),
- skb->protocol, ip_hdr_len, l4_proto);
+ l3_proto, ip_hdr_len, l4_proto);
}
return MVPP2_TXD_L4_CSUM_NOT | MVPP2_TXD_IP_CSUM_DISABLE;
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: mvpp2: Extract the correct ethtype from the skb for tx csum offload
2018-10-04 8:03 [PATCH net] net: mvpp2: Extract the correct ethtype from the skb for tx csum offload Maxime Chevallier
2018-10-04 8:08 ` [EXT] " Yan Markman
@ 2018-10-04 9:50 ` Sergei Shtylyov
2018-10-04 13:13 ` Maxime Chevallier
1 sibling, 1 reply; 4+ messages in thread
From: Sergei Shtylyov @ 2018-10-04 9:50 UTC (permalink / raw)
To: Maxime Chevallier, davem
Cc: netdev, linux-kernel, Antoine Tenart, thomas.petazzoni,
gregory.clement, miquel.raynal, nadavh, stefanc, ymarkman, mw
Hello!
On 10/4/2018 11:03 AM, Maxime Chevallier wrote:
> 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.
^ of?
> Fixes: 3f51850 ("ethernet: Add new driver for Marvell Armada 375 network unit")
12 hex digits needed here.
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
[...]
MBR, Sergei
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: mvpp2: Extract the correct ethtype from the skb for tx csum offload
2018-10-04 9:50 ` Sergei Shtylyov
@ 2018-10-04 13:13 ` Maxime Chevallier
0 siblings, 0 replies; 4+ messages in thread
From: Maxime Chevallier @ 2018-10-04 13:13 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: davem, netdev, linux-kernel, Antoine Tenart, thomas.petazzoni,
gregory.clement, miquel.raynal, nadavh, stefanc, ymarkman, mw
Hello Sergei,
On Thu, 4 Oct 2018 12:50:17 +0300
Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> wrote:
>Hello!
>
>On 10/4/2018 11:03 AM, Maxime Chevallier wrote:
>
>> 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.
> ^ of?
>
>> Fixes: 3f51850 ("ethernet: Add new driver for Marvell Armada 375 network unit")
>
> 12 hex digits needed here.
Sorry about that, I'll resend with a proper Fixes tag.
Thanks,
Maxime
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-04 13:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-04 8:03 [PATCH net] net: mvpp2: Extract the correct ethtype from the skb for tx csum offload Maxime Chevallier
2018-10-04 8:08 ` [EXT] " Yan Markman
2018-10-04 9:50 ` Sergei Shtylyov
2018-10-04 13:13 ` Maxime Chevallier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).