This patch implements dev->tx_descriptor_status function for net_qdma PMD.
Signed-off-by: Aman Kumar <aman.ku...@vvdntech.in> --- drivers/net/qdma/qdma_devops.c | 1 + drivers/net/qdma/qdma_rxtx.c | 47 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/drivers/net/qdma/qdma_devops.c b/drivers/net/qdma/qdma_devops.c index 12391790f0..dfa41a9aa7 100644 --- a/drivers/net/qdma/qdma_devops.c +++ b/drivers/net/qdma/qdma_devops.c @@ -1759,4 +1759,5 @@ void qdma_dev_ops_init(struct rte_eth_dev *dev) dev->tx_pkt_burst = &qdma_xmit_pkts; dev->rx_queue_count = &qdma_dev_rx_queue_count; dev->rx_descriptor_status = &qdma_dev_rx_descriptor_status; + dev->tx_descriptor_status = &qdma_dev_tx_descriptor_status; } diff --git a/drivers/net/qdma/qdma_rxtx.c b/drivers/net/qdma/qdma_rxtx.c index 6842203ada..3abc72717f 100644 --- a/drivers/net/qdma/qdma_rxtx.c +++ b/drivers/net/qdma/qdma_rxtx.c @@ -559,6 +559,53 @@ qdma_dev_tx_done_cleanup(void *tx_queue, uint32_t free_cnt) return reclaim_tx_mbuf(txq, txq->wb_status->cidx, free_cnt); } +/** + * DPDK callback to check the status of a Tx descriptor in the queue. + * + * @param tx_queue + * Pointer to Tx queue specific data structure. + * @param offset + * The offset of the descriptor starting from tail (0 is the place where + * the next packet will be send). + * + * @return + * - (RTE_ETH_TX_DESC_FULL) Descriptor is being processed by the hw, i.e. + * in the transmit queue. + * - (RTE_ETH_TX_DESC_DONE) Hardware is done with this descriptor, it can + * be reused by the driver. + * - (RTE_ETH_TX_DESC_UNAVAIL): Descriptor is unavailable, reserved by the + * driver or the hardware. + * - (-EINVAL) bad descriptor offset. + */ +int +qdma_dev_tx_descriptor_status(void *tx_queue, uint16_t offset) +{ + struct qdma_tx_queue *txq = tx_queue; + uint16_t id; + int avail, in_use; + uint16_t cidx = 0; + + if (unlikely(offset >= (txq->nb_tx_desc - 1))) + return -EINVAL; + + /* One descriptor is reserved so that pidx is not same as old pidx */ + if (offset == (txq->nb_tx_desc - 2)) + return RTE_ETH_TX_DESC_UNAVAIL; + + id = txq->q_pidx_info.pidx; + cidx = txq->wb_status->cidx; + + in_use = (int)id - cidx; + if (in_use < 0) + in_use += (txq->nb_tx_desc - 1); + avail = txq->nb_tx_desc - 2 - in_use; + + if (offset < avail) + return RTE_ETH_TX_DESC_DONE; + + return RTE_ETH_TX_DESC_FULL; +} + /* Transmit API for Streaming mode */ uint16_t qdma_xmit_pkts_st(struct qdma_tx_queue *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) -- 2.36.1