Skip to contentSkip to conversation

fm10k: fix wrong VLAN value in RX mbuf

PATCH Superseded Shaopeng He 4 participants 11 messages Nov 18, 2015 – Nov 24, 2015 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fm10k: fix wrong VLAN value in RX mbuf

VLAN value should be copied from RX descriptor to mbuf, this patch fixes this issue.

---
 drivers/net/fm10k/fm10k_rxtx.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/fm10k/fm10k_rxtx.c +2 -0
index 1bac28d..eeb635e 100644
@@ -146,6 +146,7 @@ fm10k_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 #endif
 
 		mbuf->hash.rss = desc.d.rss;
+		mbuf->vlan_tci = desc.w.vlan & FM10K_RXD_VLAN_ID_MASK;
 
 		rx_pkts[count] = mbuf;
 		if (++next_dd == q->nb_desc) {
@@ -292,6 +293,7 @@ fm10k_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		rx_desc_to_ol_flags(first_seg, &desc);
 #endif
 		first_seg->hash.rss = desc.d.rss;
+		first_seg->vlan_tci = desc.w.vlan & FM10K_RXD_VLAN_ID_MASK;
 
 		/* Prefetch data of first segment, if configured to do so. */
 		rte_packet_prefetch((char *)first_seg->buf_addr +
Signature · 1 line
1.9.3
#1 lore raw

Hi,

Worth to adding comments that vlan_tci is only valid in case RTE_LIBRTE_FM10K_RX_OLFLAGS_ENABLE is turned on and Flag PKT_RX_VLAN_PKT is set.

Best Regards,
Mark

Quoted 42 lines

-----Original Message-----
From: He, Shaopeng
Sent: Wednesday, November 18, 2015 4:50 PM
To: [email protected]
Cc: Chen, Jing D; Qiu, Michael; He, Shaopeng
Subject: [PATCH] fm10k: fix wrong VLAN value in RX mbuf

VLAN value should be copied from RX descriptor to mbuf, this patch fixes this issue.

---
 drivers/net/fm10k/fm10k_rxtx.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/fm10k/fm10k_rxtx.c +1 -0
index 1bac28d..eeb635e 100644
@@ -146,6 +146,7 @@ fm10k_recv_pkts(void *rx_queue, struct rte_mbuf
 **rx_pkts,
 #endif
 
 		mbuf->hash.rss = desc.d.rss;
+		mbuf->vlan_tci = desc.w.vlan &
 FM10K_RXD_VLAN_ID_MASK;
 
drivers/net/fm10k/fm10k_rxtx.c +1 -0
 		rx_pkts[count] = mbuf;
 		if (++next_dd == q->nb_desc) {
@@ -292,6 +293,7 @@ fm10k_recv_scattered_pkts(void *rx_queue, struct
 rte_mbuf **rx_pkts,
 		rx_desc_to_ol_flags(first_seg, &desc);
 #endif
 		first_seg->hash.rss = desc.d.rss;
+		first_seg->vlan_tci = desc.w.vlan &
 FM10K_RXD_VLAN_ID_MASK;
 
drivers/net/fm10k/fm10k_rxtx.c +0 -1
 		/* Prefetch data of first segment, if configured to do so. */
 		rte_packet_prefetch((char *)first_seg->buf_addr +
--

1.9.3

#2 lore raw

Hi, Mark

Quoted 7 lines

-----Original Message-----
From: Chen, Jing D
Sent: Thursday, November 19, 2015 3:05 PM
To: He, Shaopeng; [email protected]
Cc: Qiu, Michael
Subject: RE: [PATCH] fm10k: fix wrong VLAN value in RX mbuf

Quoted 5 lines

Hi,

Worth to adding comments that vlan_tci is only valid in case RTE_LIBRTE_FM10K_RX_OLFLAGS_ENABLE is turned on and Flag PKT_RX_VLAN_PKT is set.

Good suggestion. But, actually, we have a little different case in fm10k:
fm10k has a switch core inside, which associates a VLAN ID for each packet. For those packets coming in without a VLAN, the port default VLAN ID will be used. So for fm10k, vlan_tci is always valid.
For Flag PKT_RX_VLAN_PKT, currently it will be set when there is inner VLAN in the packet. This is not correct, I will fix it by setting PKT_RX_VLAN_PKT always on in next version.

To verify this, different situations have been tested on current implementation:
1. Ixia sent VLAN 51 packet, DPDK received: vlan_tci=51, PKT_RX_VLAN_PKT=0
2. sent non-VLAN packet, ether port's default VLAN ID is 1

    received: vlan_tci=1, PKT_RX_VLAN_PKT=0
3. sent double-VLAN packet (outer 51, inner 17),
    received: vlan_tci=51, PKT_RX_VLAN_PKT=1

Thanks,
--Shaopeng

Quoted 44 lines

Best Regards,
Mark

Quoted 39 lines

-----Original Message-----
From: He, Shaopeng
Sent: Wednesday, November 18, 2015 4:50 PM
To: [email protected]
Cc: Chen, Jing D; Qiu, Michael; He, Shaopeng
Subject: [PATCH] fm10k: fix wrong VLAN value in RX mbuf

VLAN value should be copied from RX descriptor to mbuf, this patch fixes this issue.

---
 drivers/net/fm10k/fm10k_rxtx.c | 2 ++
 1 file changed, 2 insertions(+)
(quoted diff) +0 -0

b/drivers/net/fm10k/fm10k_rxtx.c index 1bac28d..eeb635e 100644

drivers/net/fm10k/fm10k_rxtx.c +1 -0
@@ -146,6 +146,7 @@ fm10k_recv_pkts(void *rx_queue, struct rte_mbuf
 **rx_pkts,  #endif
 
 		mbuf->hash.rss = desc.d.rss;
+		mbuf->vlan_tci = desc.w.vlan &
 FM10K_RXD_VLAN_ID_MASK;
 
 		rx_pkts[count] = mbuf;
drivers/net/fm10k/fm10k_rxtx.c +1 -0
 		if (++next_dd == q->nb_desc) {
@@ -292,6 +293,7 @@ fm10k_recv_scattered_pkts(void *rx_queue, struct
 rte_mbuf **rx_pkts,
 		rx_desc_to_ol_flags(first_seg, &desc);  #endif
 		first_seg->hash.rss = desc.d.rss;
+		first_seg->vlan_tci = desc.w.vlan &
 FM10K_RXD_VLAN_ID_MASK;
 
 		/* Prefetch data of first segment, if configured to do so. */

rte_packet_prefetch((char *)first_seg->buf_addr +
--
1.9.3

#3 lore raw
In reply to Shaopeng He
Quoted 21 lines · On Wed, 18 Nov 2015 16:50:09 +0800 Shaopeng He <[email protected]> wrote:

VLAN value should be copied from RX descriptor to mbuf, this patch fixes this issue.

---
 drivers/net/fm10k/fm10k_rxtx.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/fm10k/fm10k_rxtx.c +1 -0
index 1bac28d..eeb635e 100644
@@ -146,6 +146,7 @@ fm10k_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 #endif
 
 		mbuf->hash.rss = desc.d.rss;
+		mbuf->vlan_tci = desc.w.vlan & FM10K_RXD_VLAN_ID_MASK;
 
 		rx_pkts[count] = mbuf;
 		if (++next_dd == q->nb_desc) {

drivers/net/fm10k/fm10k_rxtx.c fm10k_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, · line 299

Quoted 7 lines
drivers/net/fm10k/fm10k_rxtx.c +1 -0
@@ -292,6 +293,7 @@ fm10k_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		rx_desc_to_ol_flags(first_seg, &desc);
 #endif
 		first_seg->hash.rss = desc.d.rss;
+		first_seg->vlan_tci = desc.w.vlan & FM10K_RXD_VLAN_ID_MASK;
 
 		/* Prefetch data of first segment, if configured to do so. */
 		rte_packet_prefetch((char *)first_seg->buf_addr +

Good catch, this bug means VLAN's would not work right now. But I think it isn't quite right.

By masking the VLAN you are losing the received priority bits. Other drivers like ixgbe preserve the priority bits.

#4 lore raw

Hi, Stephen

Quoted 38 lines

-----Original Message-----
From: Stephen Hemminger [mailto:[email protected]]
Sent: Friday, November 20, 2015 1:26 AM
To: He, Shaopeng
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH] fm10k: fix wrong VLAN value in RX mbuf

Quoted 13 lines · On Wed, 18 Nov 2015 16:50:09 +0800 Shaopeng He <[email protected]> wrote:

VLAN value should be copied from RX descriptor to mbuf, this patch fixes this issue.

---
 drivers/net/fm10k/fm10k_rxtx.c | 2 ++
 1 file changed, 2 insertions(+)
(quoted diff) +0 -0

b/drivers/net/fm10k/fm10k_rxtx.c index 1bac28d..eeb635e 100644

drivers/net/fm10k/fm10k_rxtx.c fm10k_recv_pkts(void *rx_queue, struct rte_mbuf · line 149

Quoted 4 lines
drivers/net/fm10k/fm10k_rxtx.c +1 -0
@@ -146,6 +146,7 @@ fm10k_recv_pkts(void *rx_queue, struct rte_mbuf
 **rx_pkts,  #endif
 
 		mbuf->hash.rss = desc.d.rss;
+		mbuf->vlan_tci = desc.w.vlan &

FM10K_RXD_VLAN_ID_MASK;

drivers/net/fm10k/fm10k_rxtx.c fm10k_recv_scattered_pkts(void *rx_queue, struct

Quoted 4 lines
drivers/net/fm10k/fm10k_rxtx.c +0 -0
 		rx_pkts[count] = mbuf;
 		if (++next_dd == q->nb_desc) {
@@ -292,6 +293,7 @@ fm10k_recv_scattered_pkts(void *rx_queue, struct

rte_mbuf **rx_pkts,

drivers/net/fm10k/fm10k_rxtx.c fm10k_recv_scattered_pkts(void *rx_queue, struct · line 295

Quoted 3 lines
drivers/net/fm10k/fm10k_rxtx.c +1 -0
 		rx_desc_to_ol_flags(first_seg, &desc);  #endif
 		first_seg->hash.rss = desc.d.rss;
+		first_seg->vlan_tci = desc.w.vlan &

FM10K_RXD_VLAN_ID_MASK;

Quoted 1 line
Quoted 5 lines

drivers/net/fm10k/fm10k_rxtx.c fm10k_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, · line 299

Quoted 2 lines
drivers/net/fm10k/fm10k_rxtx.c +0 -0
 		/* Prefetch data of first segment, if configured to do so. */
 		rte_packet_prefetch((char *)first_seg->buf_addr +

Good catch, this bug means VLAN's would not work right now. But I think it isn't quite right.

Actually, VLAN filter works well, only the vlan_tci in mbuf has wrong value. And because not much places use the vlan_tci, this bug was not found before.

Quoted 3 lines

By masking the VLAN you are losing the received priority bits. Other drivers like ixgbe preserve the priority bits.

Yes, you are right, in next version, I will preserve the priority bits like others.

Thanks,
--Shaopeng

#5 lore raw

PATCH v2 1/1 fm10k: fix wrong VLAN value in RX mbuf

In reply to Shaopeng He

vlan_tci should be copied from RX descriptor to mbuf, and flag PKT_RX_VLAN_PKT should be set for every RX packet, this patch fixes this issue.
fm10k's Ethernet switch core associates a VLAN ID and VLAN PRI for each packet. For those packets coming in without a VLAN, the port default VLAN ID will be used.
So in fm10k, always PKT_RX_VLAN_PKT flag is set and vlan_tci is valid for each RX packet's mbuf.

---
ChangeLog:

v2:
* change flag PKT_RX_VLAN_PKT to always set
* preserve the priority bits in vlan_tci

 drivers/net/fm10k/fm10k_rxtx.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/net/fm10k/fm10k_rxtx.c +12 -2
index 1bac28d..764f4f4 100644
@@ -104,8 +104,14 @@ rx_desc_to_ol_flags(struct rte_mbuf *m, const union fm10k_rx_desc *d)
 		(FM10K_RXD_STATUS_L4CS | FM10K_RXD_STATUS_L4E)))
 		m->ol_flags |= PKT_RX_L4_CKSUM_BAD;
 
-	if (d->d.staterr & FM10K_RXD_STATUS_VEXT)
-		m->ol_flags |= PKT_RX_VLAN_PKT;
+	/**
+	 * fm10k's Ethernet switch core associates a VLAN ID and VLAN PRI
+	 * for each packet. For those packets coming in without a VLAN,
+	 * the port default VLAN ID will be used.
+	 * So in fm10k, always PKT_RX_VLAN_PKT flag is set and vlan_tci
+	 * is valid for each RX packet's mbuf.
+	 */
+	m->ol_flags |= PKT_RX_VLAN_PKT;
 
 	if (unlikely(d->d.staterr & FM10K_RXD_STATUS_HBO))
 		m->ol_flags |= PKT_RX_HBUF_OVERFLOW;
@@ -146,6 +152,8 @@ fm10k_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 #endif
 
 		mbuf->hash.rss = desc.d.rss;
+		/* in fm10k, vlan_tci is always valid for RX packet */
+		mbuf->vlan_tci = desc.w.vlan;
 
 		rx_pkts[count] = mbuf;
 		if (++next_dd == q->nb_desc) {
@@ -292,6 +300,8 @@ fm10k_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		rx_desc_to_ol_flags(first_seg, &desc);
 #endif
 		first_seg->hash.rss = desc.d.rss;
+		/* in fm10k, vlan_tci is always valid for RX packet */
+		first_seg->vlan_tci = desc.w.vlan;
 
 		/* Prefetch data of first segment, if configured to do so. */
 		rte_packet_prefetch((char *)first_seg->buf_addr +
Signature · 1 line
1.9.3
#6 lore raw
Quoted 17 lines

---
ChangeLog:

v2:
* change flag PKT_RX_VLAN_PKT to always set
* preserve the priority bits in vlan_tci

 drivers/net/fm10k/fm10k_rxtx.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/net/fm10k/fm10k_rxtx.c +0 -0
index 1bac28d..764f4f4 100644

drivers/net/fm10k/fm10k_rxtx.c rx_desc_to_ol_flags(struct rte_mbuf *m, const · line 109

Quoted 8 lines
drivers/net/fm10k/fm10k_rxtx.c +2 -2
@@ -104,8 +104,14 @@ rx_desc_to_ol_flags(struct rte_mbuf *m, const
 union fm10k_rx_desc *d)
 		(FM10K_RXD_STATUS_L4CS | FM10K_RXD_STATUS_L4E)))
 		m->ol_flags |= PKT_RX_L4_CKSUM_BAD;
 
-	if (d->d.staterr & FM10K_RXD_STATUS_VEXT)
-		m->ol_flags |= PKT_RX_VLAN_PKT;
+	/**
+	 * fm10k's Ethernet switch core associates a VLAN ID and VLAN PRI

Change to Packets in fm10k device always carries a vlan tag?

drivers/net/fm10k/fm10k_rxtx.c rx_desc_to_ol_flags(struct rte_mbuf *m, const union fm10k_rx_desc *d) · line 114

Quoted 6 lines
drivers/net/fm10k/fm10k_rxtx.c +6 -0
+	 * for each packet. For those packets coming in without a VLAN,
+	 * the port default VLAN ID will be used.
+	 * So in fm10k, always PKT_RX_VLAN_PKT flag is set and vlan_tci
+	 * is valid for each RX packet's mbuf.
+	 */
+	m->ol_flags |= PKT_RX_VLAN_PKT;

Since vlan_tci is always valid, is it better to move above line to below added lines?

Quoted 25 lines
drivers/net/fm10k/fm10k_rxtx.c +2 -0
 	if (unlikely(d->d.staterr & FM10K_RXD_STATUS_HBO))
 		m->ol_flags |= PKT_RX_HBUF_OVERFLOW;
@@ -146,6 +152,8 @@ fm10k_recv_pkts(void *rx_queue, struct rte_mbuf
 **rx_pkts,
 #endif
 
 		mbuf->hash.rss = desc.d.rss;
+		/* in fm10k, vlan_tci is always valid for RX packet */
+		mbuf->vlan_tci = desc.w.vlan;
 
 		rx_pkts[count] = mbuf;
drivers/net/fm10k/fm10k_rxtx.c +2 -0
 		if (++next_dd == q->nb_desc) {
@@ -292,6 +300,8 @@ fm10k_recv_scattered_pkts(void *rx_queue, struct
 rte_mbuf **rx_pkts,
 		rx_desc_to_ol_flags(first_seg, &desc);
 #endif
 		first_seg->hash.rss = desc.d.rss;
+		/* in fm10k, vlan_tci is always valid for RX packet */
+		first_seg->vlan_tci = desc.w.vlan;
 
 		/* Prefetch data of first segment, if configured to do so. */

rte_packet_prefetch((char *)first_seg->buf_addr +
--
1.9.3

#7 lore raw

Hi, Mark

Quoted 34 lines

-----Original Message-----
From: Chen, Jing D
Sent: Friday, November 20, 2015 6:35 PM
To: He, Shaopeng; [email protected]
Cc: Qiu, Michael
Subject: RE: [PATCH v2] fm10k: fix wrong VLAN value in RX mbuf

Quoted 16 lines

---
ChangeLog:

v2:
* change flag PKT_RX_VLAN_PKT to always set
* preserve the priority bits in vlan_tci

 drivers/net/fm10k/fm10k_rxtx.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/fm10k/fm10k_rxtx.c index 1bac28d..764f4f4 100644

drivers/net/fm10k/fm10k_rxtx.c rx_desc_to_ol_flags(struct rte_mbuf *m, const · line 109

Quoted 8 lines
drivers/net/fm10k/fm10k_rxtx.c +2 -2
@@ -104,8 +104,14 @@ rx_desc_to_ol_flags(struct rte_mbuf *m, const
 union fm10k_rx_desc *d)
 		(FM10K_RXD_STATUS_L4CS | FM10K_RXD_STATUS_L4E)))
 		m->ol_flags |= PKT_RX_L4_CKSUM_BAD;
 
-	if (d->d.staterr & FM10K_RXD_STATUS_VEXT)
-		m->ol_flags |= PKT_RX_VLAN_PKT;
+	/**
+	 * fm10k's Ethernet switch core associates a VLAN ID and VLAN PRI

Change to Packets in fm10k device always carries a vlan tag?

Quoted 9 lines

drivers/net/fm10k/fm10k_rxtx.c rx_desc_to_ol_flags(struct rte_mbuf *m, const union fm10k_rx_desc *d) · line 114

Quoted 6 lines
drivers/net/fm10k/fm10k_rxtx.c +6 -0
+	 * for each packet. For those packets coming in without a VLAN,
+	 * the port default VLAN ID will be used.
+	 * So in fm10k, always PKT_RX_VLAN_PKT flag is set and vlan_tci
+	 * is valid for each RX packet's mbuf.
+	 */
+	m->ol_flags |= PKT_RX_VLAN_PKT;

Since vlan_tci is always valid, is it better to move above line to below added lines?

Sure, I will send V3

Thanks,
--Shaopeng

Quoted 25 lines

drivers/net/fm10k/fm10k_rxtx.c rx_desc_to_ol_flags(struct rte_mbuf *m, const · line 117

Quoted 4 lines
drivers/net/fm10k/fm10k_rxtx.c +0 -0
 	if (unlikely(d->d.staterr & FM10K_RXD_STATUS_HBO))
 		m->ol_flags |= PKT_RX_HBUF_OVERFLOW; @@ -146,6

+152,8 @@

Quoted 19 lines

fm10k_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, #endif

drivers/net/fm10k/fm10k_rxtx.c +4 -1
 		mbuf->hash.rss = desc.d.rss;
+		/* in fm10k, vlan_tci is always valid for RX packet */
+		mbuf->vlan_tci = desc.w.vlan;
 
 		rx_pkts[count] = mbuf;
 		if (++next_dd == q->nb_desc) {
@@ -292,6 +300,8 @@ fm10k_recv_scattered_pkts(void *rx_queue, struct
 rte_mbuf **rx_pkts,
 		rx_desc_to_ol_flags(first_seg, &desc);  #endif
 		first_seg->hash.rss = desc.d.rss;
+		/* in fm10k, vlan_tci is always valid for RX packet */
+		first_seg->vlan_tci = desc.w.vlan;
 
 		/* Prefetch data of first segment, if configured to do so. */
 		rte_packet_prefetch((char *)first_seg->buf_addr +
--

1.9.3

#8 lore raw

PATCH v3 1/1 fm10k: fix wrong VLAN value in RX mbuf

In reply to Shaopeng He

vlan_tci should be copied from RX descriptor to mbuf, and flag PKT_RX_VLAN_PKT should be set for every RX packet, this patch fixes this issue.
Packets in fm10k device always carry at least one VLAN tag. For those packets coming in without VLAN tag,
the port default VLAN tag will be used.
So in fm10k, always PKT_RX_VLAN_PKT flag is set and vlan_tci is valid for each RX packet's mbuf.

---
ChangeLog:

v3:
* move flag PKT_RX_VLAN_PKT logic together with vlan_tci
* reword comments

v2:
* change flag PKT_RX_VLAN_PKT to always set
* preserve the priority bits in vlan_tci

 drivers/net/fm10k/fm10k_rxtx.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/net/fm10k/fm10k_rxtx.c +18 -3
index 1bac28d..e958865 100644
@@ -104,9 +104,6 @@ rx_desc_to_ol_flags(struct rte_mbuf *m, const union fm10k_rx_desc *d)
 		(FM10K_RXD_STATUS_L4CS | FM10K_RXD_STATUS_L4E)))
 		m->ol_flags |= PKT_RX_L4_CKSUM_BAD;
 
-	if (d->d.staterr & FM10K_RXD_STATUS_VEXT)
-		m->ol_flags |= PKT_RX_VLAN_PKT;
-
 	if (unlikely(d->d.staterr & FM10K_RXD_STATUS_HBO))
 		m->ol_flags |= PKT_RX_HBUF_OVERFLOW;
 
@@ -146,6 +143,15 @@ fm10k_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 #endif
 
 		mbuf->hash.rss = desc.d.rss;
+		/**
+		 * Packets in fm10k device always carry at least one VLAN tag.
+		 * For those packets coming in without VLAN tag,
+		 * the port default VLAN tag will be used.
+		 * So, always PKT_RX_VLAN_PKT flag is set and vlan_tci
+		 * is valid for each RX packet's mbuf.
+		 */
+		mbuf->ol_flags |= PKT_RX_VLAN_PKT;
+		mbuf->vlan_tci = desc.w.vlan;
 
 		rx_pkts[count] = mbuf;
 		if (++next_dd == q->nb_desc) {
@@ -292,6 +298,15 @@ fm10k_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		rx_desc_to_ol_flags(first_seg, &desc);
 #endif
 		first_seg->hash.rss = desc.d.rss;
+		/**
+		 * Packets in fm10k device always carry at least one VLAN tag.
+		 * For those packets coming in without VLAN tag,
+		 * the port default VLAN tag will be used.
+		 * So, always PKT_RX_VLAN_PKT flag is set and vlan_tci
+		 * is valid for each RX packet's mbuf.
+		 */
+		mbuf->ol_flags |= PKT_RX_VLAN_PKT;
+		first_seg->vlan_tci = desc.w.vlan;
 
 		/* Prefetch data of first segment, if configured to do so. */
 		rte_packet_prefetch((char *)first_seg->buf_addr +
Signature · 1 line
1.9.3
Acked-by on v3 1/1
#9 lore raw
Quoted 60 lines · On Fri, 20 Nov 2015 22:09:47 +0800 Shaopeng He <[email protected]> wrote:

vlan_tci should be copied from RX descriptor to mbuf, and flag PKT_RX_VLAN_PKT should be set for every RX packet, this patch fixes this issue.
Packets in fm10k device always carry at least one VLAN tag. For those packets coming in without VLAN tag,
the port default VLAN tag will be used.
So in fm10k, always PKT_RX_VLAN_PKT flag is set and vlan_tci is valid for each RX packet's mbuf.

---
ChangeLog:

v3:
* move flag PKT_RX_VLAN_PKT logic together with vlan_tci
* reword comments

v2:
* change flag PKT_RX_VLAN_PKT to always set
* preserve the priority bits in vlan_tci

 drivers/net/fm10k/fm10k_rxtx.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/net/fm10k/fm10k_rxtx.c +11 -3
index 1bac28d..e958865 100644
@@ -104,9 +104,6 @@ rx_desc_to_ol_flags(struct rte_mbuf *m, const union fm10k_rx_desc *d)
 		(FM10K_RXD_STATUS_L4CS | FM10K_RXD_STATUS_L4E)))
 		m->ol_flags |= PKT_RX_L4_CKSUM_BAD;
 
-	if (d->d.staterr & FM10K_RXD_STATUS_VEXT)
-		m->ol_flags |= PKT_RX_VLAN_PKT;
-
 	if (unlikely(d->d.staterr & FM10K_RXD_STATUS_HBO))
 		m->ol_flags |= PKT_RX_HBUF_OVERFLOW;
 
@@ -146,6 +143,15 @@ fm10k_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 #endif
 
 		mbuf->hash.rss = desc.d.rss;
+		/**
+		 * Packets in fm10k device always carry at least one VLAN tag.
+		 * For those packets coming in without VLAN tag,
+		 * the port default VLAN tag will be used.
+		 * So, always PKT_RX_VLAN_PKT flag is set and vlan_tci
+		 * is valid for each RX packet's mbuf.
+		 */
+		mbuf->ol_flags |= PKT_RX_VLAN_PKT;
+		mbuf->vlan_tci = desc.w.vlan;
 
 		rx_pkts[count] = mbuf;
 		if (++next_dd == q->nb_desc) {
@@ -292,6 +298,15 @@ fm10k_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		rx_desc_to_ol_flags(first_seg, &desc);
 #endif
 		first_seg->hash.rss = desc.d.rss;
+		/**
+		 * Packets in fm10k device always carry at least one VLAN tag.

drivers/net/fm10k/fm10k_rxtx.c fm10k_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, · line 312

Quoted 10 lines
drivers/net/fm10k/fm10k_rxtx.c +7 -0
+		 * For those packets coming in without VLAN tag,
+		 * the port default VLAN tag will be used.
+		 * So, always PKT_RX_VLAN_PKT flag is set and vlan_tci
+		 * is valid for each RX packet's mbuf.
+		 */
+		mbuf->ol_flags |= PKT_RX_VLAN_PKT;
+		first_seg->vlan_tci = desc.w.vlan;
 
 		/* Prefetch data of first segment, if configured to do so. */
 		rte_packet_prefetch((char *)first_seg->buf_addr +

Looks good thanks.

#10 lore raw
Quoted 9 lines
Quoted 9 lines

vlan_tci should be copied from RX descriptor to mbuf, and flag PKT_RX_VLAN_PKT should be set for every RX packet, this patch fixes this issue.
Packets in fm10k device always carry at least one VLAN tag. For those packets coming in without VLAN tag,
the port default VLAN tag will be used.
So in fm10k, always PKT_RX_VLAN_PKT flag is set and vlan_tci is valid for each RX packet's mbuf.

Quoted 5 lines
Quoted 1 line

Looks good thanks.

Applied, thanks