[dpdk-dev,5/8] net/bnxt: add support for tx_descriptor_status

Message ID 20170824162956.62761-7-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 tx_descriptor_status dev_op
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
  

Comments

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

<...>

> +static int
> +bnxt_tx_descriptor_status_op(void *tx_queue, uint16_t offset)
> +{
> +	struct bnxt_tx_queue *txq = (struct bnxt_tx_queue *)tx_queue;
> +	struct bnxt_cp_ring_info *cpr;
> +	struct tx_pkt_cmpl *txcmp;
> +	uint32_t cons;
> +
> +	if (!txq)
> +		return -EINVAL;
> +
> +	cpr = txq->cp_ring;
> +
> +	if (offset >= txq->nb_tx_desc)
> +		return -EINVAL;
> +
> +	cons = RING_CMP(cpr->cp_ring_struct, offset);
> +	txcmp = (struct tx_pkt_cmpl *)&cpr->cp_desc_ring[cons];
> +
> +	if (CMP_VALID(txcmp, offset, cpr->cp_ring_struct))
> +		return RTE_ETH_TX_DESC_DONE;
> +
> +	return RTE_ETH_TX_DESC_FULL;

Same comment with Rx one, a check may be required to distinguish between
status FULL and UNAVAIL.

> +}
<...>
  

Patch

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 1b8e4a9..088cf6a 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1586,6 +1586,31 @@  bnxt_rx_descriptor_done_op(void *rx_queue, uint16_t offset)
 	return !!(CMP_VALID(rxcmp, offset, cpr->cp_ring_struct));
 }
 
+static int
+bnxt_tx_descriptor_status_op(void *tx_queue, uint16_t offset)
+{
+	struct bnxt_tx_queue *txq = (struct bnxt_tx_queue *)tx_queue;
+	struct bnxt_cp_ring_info *cpr;
+	struct tx_pkt_cmpl *txcmp;
+	uint32_t cons;
+
+	if (!txq)
+		return -EINVAL;
+
+	cpr = txq->cp_ring;
+
+	if (offset >= txq->nb_tx_desc)
+		return -EINVAL;
+
+	cons = RING_CMP(cpr->cp_ring_struct, offset);
+	txcmp = (struct tx_pkt_cmpl *)&cpr->cp_desc_ring[cons];
+
+	if (CMP_VALID(txcmp, offset, cpr->cp_ring_struct))
+		return RTE_ETH_TX_DESC_DONE;
+
+	return RTE_ETH_TX_DESC_FULL;
+}
+
 /*
  * Initialization
  */
@@ -1638,6 +1663,7 @@  static const struct eth_dev_ops bnxt_dev_ops = {
 	.rx_queue_count = bnxt_rx_queue_count_op,
 	.rx_descriptor_status = bnxt_rx_descriptor_status_op,
 	.rx_descriptor_done   = bnxt_rx_descriptor_done_op,
+	.tx_descriptor_status = bnxt_tx_descriptor_status_op,
 };
 
 static bool bnxt_vf_pciid(uint16_t id)