[v2] net: adjust layer 2 length on soft VLAN insertion

Message ID 1561383962-27064-1-git-send-email-arybchenko@solarflare.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] net: adjust layer 2 length on soft VLAN insertion |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation fail Compilation issues

Commit Message

Andrew Rybchenko June 24, 2019, 1:46 p.m. UTC
  From: Dilshod Urazov <Dilshod.Urazov@oktetlabs.ru>

Layer 2 length must be updated after the prepend to mbuf to keep
the length right to be used by other Tx offloads.

If the packet has tunnel encapsulation, outer_l2_len should be
updated. Otherwise l2_len should be updated.

Fixes: c974021a5949 ("ether: add soft vlan encap/decap")
Cc: stephen@networkplumber.org
Cc: stable@dpdk.org

Signed-off-by: Dilshod Urazov <Dilshod.Urazov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
The fix is required for net/virtio which supports both VLAN
insertion (using the function) and Tx checksum offloads.

 lib/librte_net/rte_ether.h | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Olivier Matz July 5, 2019, 2:51 p.m. UTC | #1
On Mon, Jun 24, 2019 at 02:46:02PM +0100, Andrew Rybchenko wrote:
> From: Dilshod Urazov <Dilshod.Urazov@oktetlabs.ru>
> 
> Layer 2 length must be updated after the prepend to mbuf to keep
> the length right to be used by other Tx offloads.
> 
> If the packet has tunnel encapsulation, outer_l2_len should be
> updated. Otherwise l2_len should be updated.
> 
> Fixes: c974021a5949 ("ether: add soft vlan encap/decap")
> Cc: stephen@networkplumber.org
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dilshod Urazov <Dilshod.Urazov@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>

Acked-by: Olivier Matz <olivier.matz@6wind.com>
  
Ferruh Yigit July 16, 2019, 3:32 p.m. UTC | #2
On 7/5/2019 3:51 PM, Olivier Matz wrote:
> On Mon, Jun 24, 2019 at 02:46:02PM +0100, Andrew Rybchenko wrote:
>> From: Dilshod Urazov <Dilshod.Urazov@oktetlabs.ru>
>>
>> Layer 2 length must be updated after the prepend to mbuf to keep
>> the length right to be used by other Tx offloads.
>>
>> If the packet has tunnel encapsulation, outer_l2_len should be
>> updated. Otherwise l2_len should be updated.
>>
>> Fixes: c974021a5949 ("ether: add soft vlan encap/decap")
>> Cc: stephen@networkplumber.org
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Dilshod Urazov <Dilshod.Urazov@oktetlabs.ru>
>> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>
> 

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h
index 7be9b4890..961ed9361 100644
--- a/lib/librte_net/rte_ether.h
+++ b/lib/librte_net/rte_ether.h
@@ -417,6 +417,11 @@  static inline int rte_vlan_insert(struct rte_mbuf **m)
 
 	(*m)->ol_flags &= ~(PKT_RX_VLAN_STRIPPED | PKT_TX_VLAN);
 
+	if ((*m)->ol_flags & PKT_TX_TUNNEL_MASK)
+		(*m)->outer_l2_len += sizeof(struct rte_vlan_hdr);
+	else
+		(*m)->l2_len += sizeof(struct rte_vlan_hdr);
+
 	return 0;
 }