bnx2x: handle guest vlan for SR-IOV case

Message ID 20200226163635.18252-1-sodey@rbbn.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers
Series bnx2x: handle guest vlan for SR-IOV case |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/iol-testing fail Testing issues
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation fail Compilation issues
ci/travis-robot warning Travis build: failed

Commit Message

Dey, Souvik Feb. 26, 2020, 4:36 p.m. UTC
  In case of bnx2xvf pmd, tx packets can support vland id in 2 ways :
1. setting the mbuf ol_flags=PKT_TX_VLAN_PKT and passing the
vlanid in mbuf->vlan_tci.
2. the tx packet itself has the vlan id included in the packet.
The first case is working as expected but the second case where
the vlan id is included in thetx packets itself was found not
working as expected. To handle that we need to properly set the
start_bd bitfield and the vlan_or_ethertype instead of setting it
to just the ethertype in case of VF.

Signed-off-by: "Dey, Souvik" <sodey@rbbn.com>
---
 drivers/net/bnx2x/bnx2x.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
  

Comments

Rasesh Mody Feb. 26, 2020, 11:05 p.m. UTC | #1
Hi Dey,

The changes look good, however rte/RTE prefix need to be used. The patch doesn’t compile with latest dpdk.
s/ether_type/rte_ether_type/
s/ETHER_TYPE_VLAN/RTE_ETHER_TYPE_VLAN/
s/vlan_hdr/rte_vlan_hdr/

For the subject line, s/bnx2x/net\/bnx2x/ is preferred.

Also, the inclusion footer in the email messages is discouraged for upstream changes.

Thanks!
-Rasesh

On 2/26/20, 8:37 AM, "Dey, Souvik" <sodey@rbbn.com<mailto:sodey@rbbn.com>> wrote:

External Email
  

Patch

diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c
index 0b4030e..f7cca21 100644
--- a/drivers/net/bnx2x/bnx2x.c
+++ b/drivers/net/bnx2x/bnx2x.c
@@ -2216,11 +2216,23 @@  int bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct rte_mbuf *m0)
 			tx_start_bd->vlan_or_ethertype =
 			    rte_cpu_to_le_16(pkt_prod);
 		else {
-			struct rte_ether_hdr *eh =
-			    rte_pktmbuf_mtod(m0, struct rte_ether_hdr *);
-
-			tx_start_bd->vlan_or_ethertype =
-			    rte_cpu_to_le_16(rte_be_to_cpu_16(eh->ether_type));
+			/* when transmitting in a vf, start bd must hold the ethertype
+			 * for fw to enforce it
+			 */
+			struct ether_hdr *eh =
+			    rte_pktmbuf_mtod(m0, struct ether_hdr *);
+			/* Still need to consider inband vlan for enforced */
+			if (eh->ether_type == rte_cpu_to_be_16(ETHER_TYPE_VLAN)) {
+				struct vlan_hdr *vh = (struct vlan_hdr *)(eh + 1);
+				tx_start_bd->bd_flags.as_bitfield |=
+					(X_ETH_INBAND_VLAN <<
+						ETH_TX_BD_FLAGS_VLAN_MODE_SHIFT);
+				tx_start_bd->vlan_or_ethertype =
+					rte_cpu_to_le_16(ntohs(vh->vlan_tci));
+			} else {
+				tx_start_bd->vlan_or_ethertype =
+					rte_cpu_to_le_16(rte_be_to_cpu_16(eh->ether_type));
+			}
 		}
 	}