bnx2x: handle guest vlan for SR-IOV case
PATCH 1/1 bnx2x: handle guest vlan for SR-IOV case
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.
--- drivers/net/bnx2x/bnx2x.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/net/bnx2x/bnx2x.c +17 -5
@@ -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)); + } } }
Signature · 9 lines
2.9.3.windows.1 ----------------------------------------------------------------------------------------------------------------------- Notice: This e-mail together with any attachments may contain information of Ribbon Communications Inc. that is confidential and/or proprietary for the sole use of the intended recipient. Any review, disclosure, reliance or distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please notify the sender immediately and then delete all copies, including any attachments. -----------------------------------------------------------------------------------------------------------------------
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" <[email protected]<mailto:[email protected]>> wrote:
External Email
________________________________
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.
---drivers/net/bnx2x/bnx2x.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
drivers/net/bnx2x/bnx2x.c +0 -0
@@ -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));
+ }
}
}
--
2.9.3.windows.1
________________________________
Notice: This e-mail together with any attachments may contain information of Ribbon Communications Inc. that is confidential and/or proprietary for the sole use of the intended recipient. Any review, disclosure, reliance or distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please notify the sender immediately and then delete all copies, including any attachments.
________________________________
PATCH v2 1/1 net/bnx2x: handle guest vlan for SR-IOV case
In reply to Dey, SouvikIn 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.
---
v2:
* Fixed complitaion issues
ether_type to rte_ether_type/ ETHER_TYPE_VLAN to RTE_ETHER_TYPE_VLAN/ vlan_hdr to rte_vlan_hdr/
* Changed the subject line from bnx2x to net/bnx2x.
drivers/net/bnx2x/bnx2x.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/bnx2x/bnx2x.c +5 -4
@@ -2219,11 +2219,11 @@ int bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct rte_mbuf *m0)/* when transmitting in a vf, start bd must hold the ethertype * for fw to enforce it */ -struct ether_hdr *eh = +struct rte_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 ); +if (eh->ether_type ==rte_cpu_to_be_16 (RTE_ETHER_TYPE_VLAN )) { +struct rte_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 );
@@ -2231,7 +2231,8 @@ int bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct rte_mbuf *m0)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)); + (rte_cpu_to_le_16 ( +rte_be_to_cpu_16 (eh->ether_type))); } } }
Signature · 9 lines
2.9.3 ----------------------------------------------------------------------------------------------------------------------- Notice: This e-mail together with any attachments may contain information of Ribbon Communications Inc. that is confidential and/or proprietary for the sole use of the intended recipient. Any review, disclosure, reliance or distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please notify the sender immediately and then delete all copies, including any attachments. -----------------------------------------------------------------------------------------------------------------------
PATCH v2 1/1 bnx2x: handle guest vlan for SR-IOV case
In reply to Dey, SouvikIn 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.
---
v2:
* Fix compilation issues.
ether_type to rte_ether_type/
ETHER_TYPE_VLAN to RTE_ETHER_TYPE_VLAN/
vlan_hdr to rte_vlan_hdr/
* Kept the Subject still same for refernce.
drivers/net/bnx2x/bnx2x.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/net/bnx2x/bnx2x.c +15 -3
@@ -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 { +/* when transmitting in a vf, start bd must hold the ethertype +* for fw to enforce it +*/ 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)); +/* Still need to consider inband vlan for enforced */ +if (eh->ether_type ==rte_cpu_to_be_16 (RTE_ETHER_TYPE_VLAN )) { +struct rte_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)); + } esle { + tx_start_bd->vlan_or_ethertype = (rte_cpu_to_le_16 + (rte_be_to_cpu_16 (eh->ether_type))); + } } }
Signature · 9 lines
2.9.3 ----------------------------------------------------------------------------------------------------------------------- Notice: This e-mail together with any attachments may contain information of Ribbon Communications Inc. that is confidential and/or proprietary for the sole use of the intended recipient. Any review, disclosure, reliance or distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please notify the sender immediately and then delete all copies, including any attachments. -----------------------------------------------------------------------------------------------------------------------
PATCH v3 1/1 net/bnx2x: handle guest VLAN for SR-IOV case
In reply to Dey, SouvikFrom: Souvik Dey <[email protected]>
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.
v3:
* Fixed the checkpatch issue.
* Changed vlan to VLAN in the headline.
v2:
* Fix compilation issues.
* Changed the Subject Line as recommended.
--- drivers/net/bnx2x/bnx2x.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/net/bnx2x/bnx2x.c +18 -2
@@ -2216,11 +2216,27 @@ 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 { +/* when transmitting in a vf, start bd +* must hold the ethertype for fw to enforce it +*/ 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)); +/* Still need to consider inband vlan for enforced */ +if (eh->ether_type == +rte_cpu_to_be_16 (RTE_ETHER_TYPE_VLAN )) { +struct rte_vlan_hdr *vh = + (struct rte_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))); + } } }
Signature · 1 line
2.18.0
Jerin Jacob
AppliedRe: [dpdk-dev] [PATCH v3] net/bnx2x: handle guest VLAN for SR-IOV case
Quoted 17 lines · Rasesh Mody
From: Souvik Dey <[email protected]>
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 inmbuf->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 thestart_bdbitfield and thevlan_or_ethertypeinstead of setting it to just the ethertype in case of VF.v3:
* Fixed the checkpatch issue.
* Changed vlan to VLAN in the headline.
Quoted 6 lines
v2:
* Fix compilation issues.
* Changed the Subject Line as recommended.Signed-off-by Souvik Dey <[email protected]>Acked-by Rasesh Mody <[email protected]>
Applied to dpdk-next-net-mrvl/master. Thanks
Quoted 41 lines
--- drivers/net/bnx2x/bnx2x.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)drivers/net/bnx2x/bnx2x.c +18
-3@@ -2216,11 +2216,27 @@ 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 { +/* when transmitting in a vf, start bd +* must hold the ethertype for fw to enforce it +*/ 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)); +/* Still need to consider inband vlan for enforced */ +if (eh->ether_type == +rte_cpu_to_be_16 (RTE_ETHER_TYPE_VLAN )) { +struct rte_vlan_hdr *vh = + (struct rte_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))); + } } } --2.18.0