a40b537fa5b156172252f47d74b2244fbb379061
[vpp.git] / dpdk / dpdk-16.04_patches / 0017-i40e-Set-PKT_RX_VLAN_PKT-flag-for-VLAN-packets.patch
1 From 2c75df63533e1eaa97c24f41bbd6a5b131ff52ce Mon Sep 17 00:00:00 2001
2 From: Georgi Savov <gsavov@cisco.com>
3 Date: Tue, 10 May 2016 10:59:55 -0400
4 Subject: [PATCH 17/17] i40e Set PKT_RX_VLAN_PKT flag for VLAN packets
5
6 ---
7  drivers/net/i40e/i40e_rxtx.c | 18 +++++++++++++++++-
8  1 file changed, 17 insertions(+), 1 deletion(-)
9
10 diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
11 index 4d35d83..a2bb9a9 100644
12 --- a/drivers/net/i40e/i40e_rxtx.c
13 +++ b/drivers/net/i40e/i40e_rxtx.c
14 @@ -94,7 +94,23 @@ i40e_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union i40e_rx_desc *rxdp)
15                 PMD_RX_LOG(DEBUG, "Descriptor l2tag1: %u",
16                            rte_le_to_cpu_16(rxdp->wb.qword0.lo_dword.l2tag1));
17         } else {
18 -               mb->vlan_tci = 0;
19 +               struct ether_hdr *eth_hdr = rte_pktmbuf_mtod(mb, struct ether_hdr *);
20 +               u16 eth_type = eth_hdr->ether_type;
21 +
22 +               // The i40e firmware does not flag VLAN tagged packets if
23 +               // VLAN stripping is disabled so we need to check the
24 +               // ethernet header to find out if the received packet
25 +               // is a VLAN packet
26 +               if ((eth_type == rte_be_to_cpu_16(ETHER_TYPE_VLAN))      ||
27 +                   (eth_type == rte_be_to_cpu_16(ETHER_TYPE_VLAN_AD))   ||
28 +                   (eth_type == rte_be_to_cpu_16(ETHER_TYPE_VLAN_9100)) ||
29 +                   (eth_type == rte_be_to_cpu_16(ETHER_TYPE_VLAN_9200))) {
30 +                       struct vlan_hdr *vhdr = (struct vlan_hdr *)(eth_hdr+1);
31 +                       mb->ol_flags |= PKT_RX_VLAN_PKT;
32 +                       mb->vlan_tci = rte_be_to_cpu_16(vhdr->vlan_tci);
33 +               } else {
34 +                       mb->vlan_tci = 0;
35 +               }
36         }
37  #ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
38         if (rte_le_to_cpu_16(rxdp->wb.qword2.ext_status) &
39 -- 
40 2.7.4
41