net/iavf: fix VLAN insert issue
PATCH 1/1 net/iavf: fix VLAN insert issue
The new VIRTCHNL_VF_OFFLOAD_VLAN_V2 capability allows PF to set the location of TX VLAN insertion.
So VF needs to insert VLAN tag according to the location flags.
--- drivers/net/iavf/iavf_rxtx.c | 45 +++++++++++++++++++++++++++++++----- drivers/net/iavf/iavf_rxtx.h | 3 +++ 2 files changed, 42 insertions(+), 6 deletions(-)
drivers/net/iavf/iavf_rxtx.c +39 -6
@@ -629,6 +629,8 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev, const struct rte_eth_txconf *tx_conf) {struct iavf_hw *hw =IAVF_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct iavf_info *vf = +IAVF_DEV_PRIVATE_TO_VF (dev->data->dev_private);struct iavf_tx_queue *txq;const struct rte_memzone *mz;uint32_t ring_size;
@@ -670,6 +672,24 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,return -ENOMEM ; } +if (vf->vf_res->vf_cap_flags &VIRTCHNL_VF_OFFLOAD_VLAN_V2 ) { +struct virtchnl_vlan_supported_caps *insertion_support = + &vf->vlan_v2_caps.offloads.insertion_support; +uint32_t insertion_cap; + +if (insertion_support->outer) + insertion_cap = insertion_support->outer; +else + insertion_cap = insertion_support->inner; + +if (insertion_cap &VIRTCHNL_VLAN_TAG_LOCATION_L2TAG1 ) + txq->vlan_flag =IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1 ; +else if (insertion_cap &VIRTCHNL_VLAN_TAG_LOCATION_L2TAG2 ) + txq->vlan_flag =IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ; + }else { + txq->vlan_flag =IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1 ; + } + txq->nb_tx_desc = nb_desc; txq->rs_thresh = tx_rs_thresh; txq->free_thresh = tx_free_thresh;
@@ -1968,11 +1988,14 @@ iavf_xmit_cleanup(struct iavf_tx_queue *txq)/* Check if the context descriptor is needed for TX offloading */ static inline uint16_t -iavf_calc_context_desc (uint64_t flags) +iavf_calc_context_desc (uint64_t flags,uint8_t vlan_flag) { -static uint64_t mask =PKT_TX_TCP_SEG ; - -return (flags & mask) ?1 :0 ; +if (flags &PKT_TX_TCP_SEG ) +return 1 ; +if (flags &PKT_TX_VLAN_PKT && + vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) +return 1 ; +return 0 ; } static inline void
@@ -2093,6 +2116,7 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)uint16_t tx_last;uint16_t slen;uint64_t buf_dma_addr; +uint16_t cd_l2tag2 =0 ;union iavf_tx_offload tx_offload = {0 }; txq = tx_queue;
@@ -2119,7 +2143,7 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) tx_offload.l4_len = tx_pkt->l4_len; tx_offload.tso_segsz = tx_pkt->tso_segsz;/* Calculate the number of context descriptors needed. */ - nb_ctx =iavf_calc_context_desc (ol_flags); + nb_ctx =iavf_calc_context_desc (ol_flags, txq->vlan_flag);/* The number of descriptors that must be allocated for * a packet equals to the number of the segments of that
@@ -2154,7 +2178,8 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) }/* Descriptor based VLAN insertion */ -if (ol_flags &PKT_TX_VLAN_PKT ) { +if (ol_flags &PKT_TX_VLAN_PKT && + txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1 ) { td_cmd |=IAVF_TX_DESC_CMD_IL2TAG1 ; td_tag = tx_pkt->vlan_tci; }
@@ -2189,8 +2214,16 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) cd_type_cmd_tso_mss |=iavf_set_tso_ctx (tx_pkt, tx_offload); +if (ol_flags &PKT_TX_VLAN_PKT && + txq->vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) { + cd_type_cmd_tso_mss |=IAVF_TX_CTX_DESC_IL2TAG2 + <<IAVF_TXD_CTX_QW1_CMD_SHIFT ; + cd_l2tag2 = tx_pkt->vlan_tci; + } + ctx_txd->type_cmd_tso_mss =rte_cpu_to_le_64 (cd_type_cmd_tso_mss); + ctx_txd->l2tag2 =rte_cpu_to_le_16 (cd_l2tag2);IAVF_DUMP_TX_DESC (txq, &txr[tx_id], tx_id); txe->last_id = tx_last;
drivers/net/iavf/iavf_rxtx.h +3 -0
@@ -232,6 +232,9 @@ struct iavf_tx_queue {bool q_set;/* if rx queue has been configured */ bool tx_deferred_start;/* don't start this queue in dev start */ const struct iavf_txq_ops *ops; +#define IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1 BIT(0) +#define IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 BIT(1) +uint8_t vlan_flag; };/* Offload features */
Signature · 1 line
2.25.1
Quoted 31 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Thursday, February 4, 2021 11:11 AM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; [email protected]
Cc: Li, Xiaoyun <[email protected]>
Subject: [PATCH] net/iavf: fix VLAN insert issueThe new
VIRTCHNL_VF_OFFLOAD_VLAN_V2capability allows PF to set the location of TX VLAN insertion.So VF needs to insert VLAN tag according to the location flags.
Fixes 1c301e8c3cff ("net/iavf: support new VLAN capabilities")Signed-off-by Xiaoyun Li <[email protected]>--- drivers/net/iavf/iavf_rxtx.c | 45 +++++++++++++++++++++++++++++++----- drivers/net/iavf/iavf_rxtx.h | 3 +++ 2 files changed, 42 insertions(+), 6 deletions(-)drivers/net/iavf/iavf_rxtx.c index renamed from drivers/net/iavf/iavf_rxtx.c +0
-0
3d471d9acc..af5a28d84d100644drivers/net/iavf/iavf_rxtx.c +0
-0/* Check if the context descriptor is needed for TX offloading */ static inline
uint16_t-iavf_calc_context_desc(uint64_t flags)drivers/net/iavf/iavf_rxtx.c +1
-0+iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)
drivers/net/iavf/iavf_rxtx.c iavf_xmit_cleanup(struct iavf_tx_queue *txq) · line 1998
Quoted 10 lines
drivers/net/iavf/iavf_rxtx.c +6
-3{ -static uint64_t mask =PKT_TX_TCP_SEG ; - -return (flags & mask) ?1 :0 ; +if (flags &PKT_TX_TCP_SEG ) +return 1 ; +if (flags &PKT_TX_VLAN_PKT && + vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) +return 1 ; +return 0 ;
How about merging if condition?
if ((flags & PKT_TX_TCP_SEG) ||
(flags & PKT_TX_VLAN_PKT &&
vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2))
return 1;
else
return 0;Quoted 2 lines
}
Quoted 54 lines
-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Thursday, February 4, 2021 14:36
To: Li, Xiaoyun <[email protected]>; Wu, Jingjing <[email protected]>; [email protected]
Subject: RE: [PATCH] net/iavf: fix VLAN insert issueQuoted 30 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Thursday, February 4, 2021 11:11 AM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; [email protected]
Cc: Li, Xiaoyun <[email protected]>
Subject: [PATCH] net/iavf: fix VLAN insert issueThe new
VIRTCHNL_VF_OFFLOAD_VLAN_V2capability allows PF to set the location of TX VLAN insertion.So VF needs to insert VLAN tag according to the location flags.
Fixes 1c301e8c3cff ("net/iavf: support new VLAN capabilities")Signed-off-by Xiaoyun Li <[email protected]>--- drivers/net/iavf/iavf_rxtx.c | 45 +++++++++++++++++++++++++++++++----- drivers/net/iavf/iavf_rxtx.h | 3 +++ 2 files changed, 42 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/drivers/net/iavf/iavf_rxtx.cindex3d471d9acc..af5a28d84d100644drivers/net/iavf/iavf_rxtx.c +0
-0/* Check if the context descriptor is needed for TX offloading */ static inline
uint16_t-iavf_calc_context_desc(uint64_t flags)drivers/net/iavf/iavf_rxtx.c +1
-0+iavf_calc_context_desc(uint64_t flags, uint8_t vlan_flag)drivers/net/iavf/iavf_rxtx.c iavf_xmit_cleanup(struct iavf_tx_queue *txq) · line 1998
Quoted 10 lines
drivers/net/iavf/iavf_rxtx.c +6
-3{ -static uint64_t mask =PKT_TX_TCP_SEG ; - -return (flags & mask) ?1 :0 ; +if (flags &PKT_TX_TCP_SEG ) +return 1 ; +if (flags &PKT_TX_VLAN_PKT && + vlan_flag &IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 ) +return 1 ; +return 0 ;How about merging if condition?
Quoted 7 lines
if ((flags &
PKT_TX_TCP_SEG) ||(flags & PKT_TX_VLAN_PKT && vlan_flag & IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2)) return 1; else return 0;
Both are OK. In case there are new offloads in the future which needs context desc. The previous code looks more clear which offload takes effect?
Quoted 2 lines
Quoted 2 lines
}
Quoted 10 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Thursday, February 4, 2021 11:11 AM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; [email protected]
Cc: Li, Xiaoyun <[email protected]>
Subject: [PATCH] net/iavf: fix VLAN insert issue
Quoted 8 lines
The new
VIRTCHNL_VF_OFFLOAD_VLAN_V2capability allows PF to set the location of TX VLAN insertion.So VF needs to insert VLAN tag according to the location flags.
Fixes 1c301e8c3cff ("net/iavf: support new VLAN capabilities")Signed-off-by Xiaoyun Li <[email protected]>
Zhang, Qi Z
AppliedQuoted 22 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Xing, Beilei
Sent: Thursday, February 4, 2021 2:58 PM
To: Li, Xiaoyun <[email protected]>; Wu, Jingjing <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH] net/iavf: fix VLAN insert issueQuoted 11 lines
-----Original Message-----
From: Li, Xiaoyun <[email protected]>
Sent: Thursday, February 4, 2021 11:11 AM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; [email protected]
Cc: Li, Xiaoyun <[email protected]>
Subject: [PATCH] net/iavf: fix VLAN insert issueThe new
VIRTCHNL_VF_OFFLOAD_VLAN_V2capability allows PF to set the location of TX VLAN insertion.
Quoted 7 lines
Quoted 5 lines
So VF needs to insert VLAN tag according to the location flags.
Fixes 1c301e8c3cff ("net/iavf: support new VLAN capabilities")Signed-off-by Xiaoyun Li <[email protected]>Acked-by Beilei Xing <[email protected]>
Applied to dpdk-next-net-intel.
Thanks
Qi