[dpdk-dev,2/8] net/bnxt: add support for rx_queue_count

Message ID 20170824162956.62761-4-ajit.khaparde@broadcom.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Ajit Khaparde Aug. 24, 2017, 4:29 p.m. UTC
  add support for rx_queue_count dev_op
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
  

Comments

Ferruh Yigit Aug. 29, 2017, 4:10 p.m. UTC | #1
On 8/24/2017 5:29 PM, Ajit Khaparde wrote:
> add support for rx_queue_count dev_op
> Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>

<...>

> +static uint32_t
> +bnxt_rx_queue_count_op(struct rte_eth_dev *dev, uint16_t rx_queue_id)
> +{
> +	uint32_t desc = 0, raw_cons = 0, cons;
> +	struct bnxt_cp_ring_info *cpr;
> +	struct bnxt_rx_queue *rxq;
> +	struct rx_pkt_cmpl *rxcmp;
> +
> +	rxq = dev->data->rx_queues[rx_queue_id];
> +	cpr = rxq->cp_ring;
> +
> +	while (raw_cons < rxq->nb_rx_desc) {
> +		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))

"raw_cons" increased above, the "raw_cons" here and the one used to get
"cons" are different. Is this an issue for cmp_valid ?

> +			desc++;
> +	}
> +
> +	return desc;
> +}

<...>
  

Patch

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 1302710..316a167 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1517,6 +1517,28 @@  bnxt_dev_led_off_op(struct rte_eth_dev *dev)
 	return bnxt_hwrm_port_led_cfg(bp, false);
 }
 
+static uint32_t
+bnxt_rx_queue_count_op(struct rte_eth_dev *dev, uint16_t rx_queue_id)
+{
+	uint32_t desc = 0, raw_cons = 0, cons;
+	struct bnxt_cp_ring_info *cpr;
+	struct bnxt_rx_queue *rxq;
+	struct rx_pkt_cmpl *rxcmp;
+
+	rxq = dev->data->rx_queues[rx_queue_id];
+	cpr = rxq->cp_ring;
+
+	while (raw_cons < rxq->nb_rx_desc) {
+		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))
+			desc++;
+	}
+
+	return desc;
+}
+
 /*
  * Initialization
  */
@@ -1566,6 +1588,7 @@  static const struct eth_dev_ops bnxt_dev_ops = {
 	.dev_led_off = bnxt_dev_led_off_op,
 	.xstats_get_by_id = bnxt_dev_xstats_get_by_id_op,
 	.xstats_get_names_by_id = bnxt_dev_xstats_get_names_by_id_op,
+	.rx_queue_count = bnxt_rx_queue_count_op,
 };
 
 static bool bnxt_vf_pciid(uint16_t id)