net/bnxt: fix Rx descriptor status
PATCH 1/1 net/bnxt: fix Rx descriptor status
Fix a number of issues in the bnxt receive descriptor status function, including:
- Provide status of receive descriptor instead of completion descriptor.
- Remove invalid comparison of raw ring index with masked ring index.
- Correct misinterpretation of offset parameter as ring index.
- Correct misuse of completion ring index for mbuf ring (the two rings have different sizes).
--- drivers/net/bnxt/bnxt_ethdev.c | 108 ++++++++++++++++++++++++++------- 1 file changed, 86 insertions(+), 22 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +86 -22
@@ -3003,42 +3003,106 @@ bnxt_rx_queue_count_op(struct rte_eth_dev *dev, uint16_t rx_queue_id)static int bnxt_rx_descriptor_status_op (void *rx_queue,uint16_t offset) { -struct bnxt_rx_queue *rxq = (struct bnxt_rx_queue *)rx_queue; -struct bnxt_rx_ring_info *rxr; +struct bnxt_rx_queue *rxq = rx_queue;struct bnxt_cp_ring_info *cpr; -struct rte_mbuf *rx_buf; +struct bnxt_rx_ring_info *rxr; +uint32_t desc, cons, raw_cons; +struct bnxt *bp = rxq->bp;struct rx_pkt_cmpl *rxcmp; -uint32_t cons, cp_cons;int rc; -if (!rxq) -return -EINVAL ; - - rc =is_bnxt_in_error (rxq->bp); + rc =is_bnxt_in_error (bp);if (rc)return rc; - cpr = rxq->cp_ring; - rxr = rxq->rx_ring; -if (offset >= rxq->nb_rx_desc)return -EINVAL ; - cons =RING_CMP (cpr->cp_ring_struct, offset); - cp_cons = cpr->cp_raw_cons; - rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons]; + rxr = rxq->rx_ring; + cpr = rxq->cp_ring; -if (cons > cp_cons) { -if (CMPL_VALID (rxcmp, cpr->valid)) -return RTE_ETH_RX_DESC_DONE ; - }else { -if (CMPL_VALID (rxcmp, !cpr->valid)) +/* +* For the vector receive case, the completion at the requested +* offset can be indexed directly. +*/ +if (bp->flags &BNXT_FLAG_RX_VECTOR_PKT_MODE ) { +struct rx_pkt_cmpl *rxcmp; + +/* Check status of completion descriptor. */ + raw_cons = cpr->cp_raw_cons + + offset *CMP_LEN (CMPL_BASE_TYPE_RX_L2 ); + cons =RING_CMP (cpr->cp_ring_struct, raw_cons); + rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons]; + +if (CMP_VALID (rxcmp, raw_cons, cpr->cp_ring_struct))return RTE_ETH_RX_DESC_DONE ; + +/* Check whether rx desc has an mbuf attached. */ + cons =RING_CMP (rxr->rx_ring_struct, raw_cons /2 ); +if (cons >= rxq->rxrearm_start && + cons < rxq->rxrearm_start + rxq->rxrearm_nb) { +return RTE_ETH_RX_DESC_UNAVAIL ; + } + +return RTE_ETH_RX_DESC_AVAIL ; } - rx_buf = rxr->rx_buf_ring[cons]; -if (rx_buf ==NULL || rx_buf == &rxq->fake_mbuf) -return RTE_ETH_RX_DESC_UNAVAIL ; +/* +* For the non-vector receive case, scan the completion ring to +* locate the completion descriptor for the requested offset. +*/ + raw_cons = cpr->cp_raw_cons; + desc =0 ; +while (1 ) { +uint32_t agg_cnt, cons, cmpl_type; + + cons =RING_CMP (cpr->cp_ring_struct, raw_cons); + rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons]; + +if (!CMP_VALID (rxcmp, raw_cons, cpr->cp_ring_struct)) +break ; + + cmpl_type =CMP_TYPE (rxcmp); + +switch (cmpl_type) { +case CMPL_BASE_TYPE_RX_L2 : +case CMPL_BASE_TYPE_RX_L2_V2 : +if (desc == offset) { + cons = rxcmp->opaque; +if (rxr->rx_buf_ring[cons]) +return RTE_ETH_RX_DESC_DONE ; +else +return RTE_ETH_RX_DESC_UNAVAIL ; + } + agg_cnt =BNXT_RX_L2_AGG_BUFS (rxcmp); + raw_cons = raw_cons +CMP_LEN (cmpl_type) + agg_cnt; + desc++; +break ; + +case CMPL_BASE_TYPE_RX_TPA_END : +if (desc == offset) +return RTE_ETH_RX_DESC_DONE ; + +if (BNXT_CHIP_P5 (rxq->bp)) { +struct rx_tpa_v2_end_cmpl_hi *p5_tpa_end; + + p5_tpa_end = (void *)rxcmp; + agg_cnt =BNXT_TPA_END_AGG_BUFS_TH (p5_tpa_end); + }else { +struct rx_tpa_end_cmpl *tpa_end; + + tpa_end = (void *)rxcmp; + agg_cnt =BNXT_TPA_END_AGG_BUFS (tpa_end); + } + + raw_cons = raw_cons +CMP_LEN (cmpl_type) + agg_cnt; + desc++; +break ; + +default : + raw_cons +=CMP_LEN (cmpl_type); + } + }return RTE_ETH_RX_DESC_AVAIL ; }
Signature · 1 line
2.25.1
Quoted 11 lines · Lance Richardson
Fix a number of issues in the bnxt receive descriptor status function, including:
- Provide status of receive descriptor instead of completion descriptor.
- Remove invalid comparison of raw ring index with masked ring index.
- Correct misinterpretation of offset parameter as ring index.
- Correct misuse of completion ring index for mbuf ring (the two rings have different sizes).
Quoted 6 lines
Fixes 0fe613bb87b2 ("net/bnxt: support Rx descriptor status")Signed-off-by Lance Richardson <[email protected]>Reviewed-by Andy Gospodarek <[email protected]>Reviewed-by Ajit Kumar Khaparde <[email protected]>---
This patch has a dependency on:
http://patchwork.dpdk.org/project/dpdk/list/?series=15289&archive=both&state=*
PATCH v2 1/1 net/bnxt: fix Rx descriptor status
In reply to Lance RichardsonFrom: Lance Richardson <[email protected]>
Fix a number of issues in the bnxt receive descriptor status function, including:
- Provide status of receive descriptor instead of completion descriptor.
- Remove invalid comparison of raw ring index with masked ring index.
- Correct misinterpretation of offset parameter as ring index.
- Correct misuse of completion ring index for mbuf ring (the two rings have different sizes).
---v1->v2: rebase against latest
--- drivers/net/bnxt/bnxt_ethdev.c | 108 ++++++++++++++++++++++++++------- 1 file changed, 86 insertions(+), 22 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +86 -22
@@ -3076,42 +3076,106 @@ bnxt_rx_queue_count_op(struct rte_eth_dev *dev, uint16_t rx_queue_id)static int bnxt_rx_descriptor_status_op (void *rx_queue,uint16_t offset) { -struct bnxt_rx_queue *rxq = (struct bnxt_rx_queue *)rx_queue; -struct bnxt_rx_ring_info *rxr; +struct bnxt_rx_queue *rxq = rx_queue;struct bnxt_cp_ring_info *cpr; -struct rte_mbuf *rx_buf; +struct bnxt_rx_ring_info *rxr; +uint32_t desc, cons, raw_cons; +struct bnxt *bp = rxq->bp;struct rx_pkt_cmpl *rxcmp; -uint32_t cons, cp_cons;int rc; -if (!rxq) -return -EINVAL ; - - rc =is_bnxt_in_error (rxq->bp); + rc =is_bnxt_in_error (bp);if (rc)return rc; - cpr = rxq->cp_ring; - rxr = rxq->rx_ring; -if (offset >= rxq->nb_rx_desc)return -EINVAL ; - cons =RING_CMP (cpr->cp_ring_struct, offset); - cp_cons = cpr->cp_raw_cons; - rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons]; + rxr = rxq->rx_ring; + cpr = rxq->cp_ring; -if (cons > cp_cons) { -if (CMPL_VALID (rxcmp, cpr->valid)) -return RTE_ETH_RX_DESC_DONE ; - }else { -if (CMPL_VALID (rxcmp, !cpr->valid)) +/* +* For the vector receive case, the completion at the requested +* offset can be indexed directly. +*/ +if (bp->flags &BNXT_FLAG_RX_VECTOR_PKT_MODE ) { +struct rx_pkt_cmpl *rxcmp; + +/* Check status of completion descriptor. */ + raw_cons = cpr->cp_raw_cons + + offset *CMP_LEN (CMPL_BASE_TYPE_RX_L2 ); + cons =RING_CMP (cpr->cp_ring_struct, raw_cons); + rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons]; + +if (CMP_VALID (rxcmp, raw_cons, cpr->cp_ring_struct))return RTE_ETH_RX_DESC_DONE ; + +/* Check whether rx desc has an mbuf attached. */ + cons =RING_CMP (rxr->rx_ring_struct, raw_cons /2 ); +if (cons >= rxq->rxrearm_start && + cons < rxq->rxrearm_start + rxq->rxrearm_nb) { +return RTE_ETH_RX_DESC_UNAVAIL ; + } + +return RTE_ETH_RX_DESC_AVAIL ; } - rx_buf = rxr->rx_buf_ring[cons]; -if (rx_buf ==NULL || rx_buf == &rxq->fake_mbuf) -return RTE_ETH_RX_DESC_UNAVAIL ; +/* +* For the non-vector receive case, scan the completion ring to +* locate the completion descriptor for the requested offset. +*/ + raw_cons = cpr->cp_raw_cons; + desc =0 ; +while (1 ) { +uint32_t agg_cnt, cons, cmpl_type; + + cons =RING_CMP (cpr->cp_ring_struct, raw_cons); + rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons]; + +if (!CMP_VALID (rxcmp, raw_cons, cpr->cp_ring_struct)) +break ; + + cmpl_type =CMP_TYPE (rxcmp); + +switch (cmpl_type) { +case CMPL_BASE_TYPE_RX_L2 : +case CMPL_BASE_TYPE_RX_L2_V2 : +if (desc == offset) { + cons = rxcmp->opaque; +if (rxr->rx_buf_ring[cons]) +return RTE_ETH_RX_DESC_DONE ; +else +return RTE_ETH_RX_DESC_UNAVAIL ; + } + agg_cnt =BNXT_RX_L2_AGG_BUFS (rxcmp); + raw_cons = raw_cons +CMP_LEN (cmpl_type) + agg_cnt; + desc++; +break ; + +case CMPL_BASE_TYPE_RX_TPA_END : +if (desc == offset) +return RTE_ETH_RX_DESC_DONE ; + +if (BNXT_CHIP_P5 (rxq->bp)) { +struct rx_tpa_v2_end_cmpl_hi *p5_tpa_end; + + p5_tpa_end = (void *)rxcmp; + agg_cnt =BNXT_TPA_END_AGG_BUFS_TH (p5_tpa_end); + }else { +struct rx_tpa_end_cmpl *tpa_end; + + tpa_end = (void *)rxcmp; + agg_cnt =BNXT_TPA_END_AGG_BUFS (tpa_end); + } + + raw_cons = raw_cons +CMP_LEN (cmpl_type) + agg_cnt; + desc++; +break ; + +default : + raw_cons +=CMP_LEN (cmpl_type); + } + }return RTE_ETH_RX_DESC_AVAIL ; }
Signature · 1 line
2.21.1 (Apple Git-122.3)
PATCH v3 1/1 net/bnxt: fix Rx descriptor status
From: Lance Richardson <[email protected]>
Fix a number of issues in the bnxt receive descriptor status function, including:
- Provide status of receive descriptor instead of completion descriptor.
- Remove invalid comparison of raw ring index with masked ring index.
- Correct misinterpretation of offset parameter as ring index.
- Correct misuse of completion ring index for mbuf ring (the two rings have different sizes).
---v1->v2: rebase against latest tree.v2->v3: fix compilation on PPC. Compile tested only.
--- drivers/net/bnxt/bnxt_ethdev.c | 110 ++++++++++++++++++++++++++------- 1 file changed, 88 insertions(+), 22 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +88 -22
@@ -3076,42 +3076,108 @@ bnxt_rx_queue_count_op(struct rte_eth_dev *dev, uint16_t rx_queue_id)static int bnxt_rx_descriptor_status_op (void *rx_queue,uint16_t offset) { -struct bnxt_rx_queue *rxq = (struct bnxt_rx_queue *)rx_queue; -struct bnxt_rx_ring_info *rxr; +struct bnxt_rx_queue *rxq = rx_queue;struct bnxt_cp_ring_info *cpr; -struct rte_mbuf *rx_buf; +struct bnxt_rx_ring_info *rxr; +uint32_t desc, cons, raw_cons; +struct bnxt *bp = rxq->bp;struct rx_pkt_cmpl *rxcmp; -uint32_t cons, cp_cons;int rc; -if (!rxq) -return -EINVAL ; - - rc =is_bnxt_in_error (rxq->bp); + rc =is_bnxt_in_error (bp);if (rc)return rc; - cpr = rxq->cp_ring; - rxr = rxq->rx_ring; -if (offset >= rxq->nb_rx_desc)return -EINVAL ; - cons =RING_CMP (cpr->cp_ring_struct, offset); - cp_cons = cpr->cp_raw_cons; - rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons]; + rxr = rxq->rx_ring; + cpr = rxq->cp_ring; -if (cons > cp_cons) { -if (CMPL_VALID (rxcmp, cpr->valid)) -return RTE_ETH_RX_DESC_DONE ; - }else { -if (CMPL_VALID (rxcmp, !cpr->valid)) +/* +* For the vector receive case, the completion at the requested +* offset can be indexed directly. +*/ +#if defined(RTE_ARCH_X86 ) || defined(RTE_ARCH_ARM64 ) +if (bp->flags &BNXT_FLAG_RX_VECTOR_PKT_MODE ) { +struct rx_pkt_cmpl *rxcmp; + +/* Check status of completion descriptor. */ + raw_cons = cpr->cp_raw_cons + + offset *CMP_LEN (CMPL_BASE_TYPE_RX_L2 ); + cons =RING_CMP (cpr->cp_ring_struct, raw_cons); + rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons]; + +if (CMP_VALID (rxcmp, raw_cons, cpr->cp_ring_struct))return RTE_ETH_RX_DESC_DONE ; + +/* Check whether rx desc has an mbuf attached. */ + cons =RING_CMP (rxr->rx_ring_struct, raw_cons /2 ); +if (cons >= rxq->rxrearm_start && + cons < rxq->rxrearm_start + rxq->rxrearm_nb) { +return RTE_ETH_RX_DESC_UNAVAIL ; + } + +return RTE_ETH_RX_DESC_AVAIL ; } - rx_buf = rxr->rx_buf_ring[cons]; -if (rx_buf ==NULL || rx_buf == &rxq->fake_mbuf) -return RTE_ETH_RX_DESC_UNAVAIL ; +#endif + +/* +* For the non-vector receive case, scan the completion ring to +* locate the completion descriptor for the requested offset. +*/ + raw_cons = cpr->cp_raw_cons; + desc =0 ; +while (1 ) { +uint32_t agg_cnt, cons, cmpl_type; + + cons =RING_CMP (cpr->cp_ring_struct, raw_cons); + rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons]; +if (!CMP_VALID (rxcmp, raw_cons, cpr->cp_ring_struct)) +break ; + + cmpl_type =CMP_TYPE (rxcmp); + +switch (cmpl_type) { +case CMPL_BASE_TYPE_RX_L2 : +case CMPL_BASE_TYPE_RX_L2_V2 : +if (desc == offset) { + cons = rxcmp->opaque; +if (rxr->rx_buf_ring[cons]) +return RTE_ETH_RX_DESC_DONE ; +else +return RTE_ETH_RX_DESC_UNAVAIL ; + } + agg_cnt =BNXT_RX_L2_AGG_BUFS (rxcmp); + raw_cons = raw_cons +CMP_LEN (cmpl_type) + agg_cnt; + desc++; +break ; + +case CMPL_BASE_TYPE_RX_TPA_END : +if (desc == offset) +return RTE_ETH_RX_DESC_DONE ; + +if (BNXT_CHIP_P5 (rxq->bp)) { +struct rx_tpa_v2_end_cmpl_hi *p5_tpa_end; + + p5_tpa_end = (void *)rxcmp; + agg_cnt =BNXT_TPA_END_AGG_BUFS_TH (p5_tpa_end); + }else { +struct rx_tpa_end_cmpl *tpa_end; + + tpa_end = (void *)rxcmp; + agg_cnt =BNXT_TPA_END_AGG_BUFS (tpa_end); + } + + raw_cons = raw_cons +CMP_LEN (cmpl_type) + agg_cnt; + desc++; +break ; + +default : + raw_cons +=CMP_LEN (cmpl_type); + } + }return RTE_ETH_RX_DESC_AVAIL ; }
Signature · 1 line
2.21.1 (Apple Git-122.3)
Quoted 16 lines · Ajit Khaparde
From: Lance Richardson <[email protected]>
Fix a number of issues in the bnxt receive descriptor status function, including:
- Provide status of receive descriptor instead of completion descriptor.
- Remove invalid comparison of raw ring index with masked ring index.
- Correct misinterpretation of offset parameter as ring index.
- Correct misuse of completion ring index for mbuf ring (the two rings have different sizes).Fixes 0fe613bb87b2 ("net/bnxt: support Rx descriptor status")
Quoted 6 lines
Signed-off-by Lance Richardson <[email protected]>Reviewed-by Andy Gospodarek <[email protected]>Reviewed-by Ajit Khaparde <[email protected]>---
v1->v2: rebase against latest tree.v2->v3: fix compilation on PPC. Compile tested only.
Patch applied to dpdk-next-net-brcm. Thanks
Quoted 142 lines
--- drivers/net/bnxt/bnxt_ethdev.c | 110 ++++++++++++++++++++++++++------- 1 file changed, 88 insertions(+), 22 deletions(-)drivers/net/bnxt/bnxt_ethdev.c +88
-23@@ -3076,42 +3076,108 @@ bnxt_rx_queue_count_op(struct rte_eth_dev *dev, uint16_t rx_queue_id)static int bnxt_rx_descriptor_status_op (void *rx_queue,uint16_t offset) { -struct bnxt_rx_queue *rxq = (struct bnxt_rx_queue *)rx_queue; -struct bnxt_rx_ring_info *rxr; +struct bnxt_rx_queue *rxq = rx_queue;struct bnxt_cp_ring_info *cpr; -struct rte_mbuf *rx_buf; +struct bnxt_rx_ring_info *rxr; +uint32_t desc, cons, raw_cons; +struct bnxt *bp = rxq->bp;struct rx_pkt_cmpl *rxcmp; -uint32_t cons, cp_cons;int rc; -if (!rxq) -return -EINVAL ; - - rc =is_bnxt_in_error (rxq->bp); + rc =is_bnxt_in_error (bp);if (rc)return rc; - cpr = rxq->cp_ring; - rxr = rxq->rx_ring; -if (offset >= rxq->nb_rx_desc)return -EINVAL ; - cons =RING_CMP (cpr->cp_ring_struct, offset); - cp_cons = cpr->cp_raw_cons; - rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons]; + rxr = rxq->rx_ring; + cpr = rxq->cp_ring; -if (cons > cp_cons) { -if (CMPL_VALID (rxcmp, cpr->valid)) -return RTE_ETH_RX_DESC_DONE ; - }else { -if (CMPL_VALID (rxcmp, !cpr->valid)) +/* +* For the vector receive case, the completion at the requested +* offset can be indexed directly. +*/ +#if defined(RTE_ARCH_X86 ) || defined(RTE_ARCH_ARM64 ) +if (bp->flags &BNXT_FLAG_RX_VECTOR_PKT_MODE ) { +struct rx_pkt_cmpl *rxcmp; + +/* Check status of completion descriptor. */ + raw_cons = cpr->cp_raw_cons + + offset *CMP_LEN (CMPL_BASE_TYPE_RX_L2 ); + cons =RING_CMP (cpr->cp_ring_struct, raw_cons); + rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons]; + +if (CMP_VALID (rxcmp, raw_cons, cpr->cp_ring_struct))return RTE_ETH_RX_DESC_DONE ; + +/* Check whether rx desc has an mbuf attached. */ + cons =RING_CMP (rxr->rx_ring_struct, raw_cons /2 ); +if (cons >= rxq->rxrearm_start && + cons < rxq->rxrearm_start + rxq->rxrearm_nb) { +return RTE_ETH_RX_DESC_UNAVAIL ; + } + +return RTE_ETH_RX_DESC_AVAIL ; } - rx_buf = rxr->rx_buf_ring[cons]; -if (rx_buf ==NULL || rx_buf == &rxq->fake_mbuf) -return RTE_ETH_RX_DESC_UNAVAIL ; +#endif + +/* +* For the non-vector receive case, scan the completion ring to +* locate the completion descriptor for the requested offset. +*/ + raw_cons = cpr->cp_raw_cons; + desc =0 ; +while (1 ) { +uint32_t agg_cnt, cons, cmpl_type; + + cons =RING_CMP (cpr->cp_ring_struct, raw_cons); + rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons]; +if (!CMP_VALID (rxcmp, raw_cons, cpr->cp_ring_struct)) +break ; + + cmpl_type =CMP_TYPE (rxcmp); + +switch (cmpl_type) { +case CMPL_BASE_TYPE_RX_L2 : +case CMPL_BASE_TYPE_RX_L2_V2 : +if (desc == offset) { + cons = rxcmp->opaque; +if (rxr->rx_buf_ring[cons]) +return RTE_ETH_RX_DESC_DONE ; +else +return RTE_ETH_RX_DESC_UNAVAIL ; + } + agg_cnt =BNXT_RX_L2_AGG_BUFS (rxcmp); + raw_cons = raw_cons +CMP_LEN (cmpl_type) + agg_cnt; + desc++; +break ; + +case CMPL_BASE_TYPE_RX_TPA_END : +if (desc == offset) +return RTE_ETH_RX_DESC_DONE ; + +if (BNXT_CHIP_P5 (rxq->bp)) { +struct rx_tpa_v2_end_cmpl_hi *p5_tpa_end; + + p5_tpa_end = (void *)rxcmp; + agg_cnt =BNXT_TPA_END_AGG_BUFS_TH (p5_tpa_end); + }else { +struct rx_tpa_end_cmpl *tpa_end; + + tpa_end = (void *)rxcmp; + agg_cnt =BNXT_TPA_END_AGG_BUFS (tpa_end); + } + + raw_cons = raw_cons +CMP_LEN (cmpl_type) + agg_cnt; + desc++; +break ; + +default : + raw_cons +=CMP_LEN (cmpl_type); + } + }return RTE_ETH_RX_DESC_AVAIL ; } --2.21.1 (Apple Git-122.3)