]> git.droids-corp.org - dpdk.git/commitdiff
net/cnxk: support getting queue status
authorRahul Bhansali <rbhansali@marvell.com>
Wed, 19 Jan 2022 09:43:27 +0000 (15:13 +0530)
committerJerin Jacob <jerinj@marvell.com>
Thu, 20 Jan 2022 06:38:28 +0000 (07:38 +0100)
Provides ethdev callback support of rx_queue_count,
rx_descriptor_status and tx_descriptor_status.

Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
doc/guides/nics/features/cnxk.ini
doc/guides/nics/features/cnxk_vec.ini
doc/guides/nics/features/cnxk_vf.ini
drivers/net/cnxk/cnxk_ethdev.c
drivers/net/cnxk/cnxk_ethdev.h
drivers/net/cnxk/cnxk_ethdev_ops.c

index 1623a1803e7cfc4854ab1f86e0e0edf416a9935f..0eba334eb438f8b72888f74f95a5650b2746a010 100644 (file)
@@ -37,6 +37,8 @@ Inner L4 checksum    = Y
 Packet type parsing  = Y
 Timesync             = Y
 Timestamp offload    = Y
+Rx descriptor status = Y
+Tx descriptor status = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
index 4b7c2bce4dd6c86d297c54c3cc352e01fbe33d99..df5f358a3eba6754455c93ba75146929ce4fd392 100644 (file)
@@ -33,6 +33,8 @@ L4 checksum offload  = Y
 Inner L3 checksum    = Y
 Inner L4 checksum    = Y
 Packet type parsing  = Y
+Rx descriptor status = Y
+Tx descriptor status = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
index 0523be434d2b6072937bec3b27628dfbedbaf57c..a78fbcada0b10da07441a9ca533bbb2bef7717f4 100644 (file)
@@ -29,6 +29,8 @@ L4 checksum offload  = Y
 Inner L3 checksum    = Y
 Inner L4 checksum    = Y
 Packet type parsing  = Y
+Rx descriptor status = Y
+Tx descriptor status = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
index 74f625553df4de58c074900adf1c52f8169e987c..183fd241d892cdcfb57adabd9f5793e8ecfbda1b 100644 (file)
@@ -1595,6 +1595,9 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev)
        int rc, max_entries;
 
        eth_dev->dev_ops = &cnxk_eth_dev_ops;
+       eth_dev->rx_queue_count = cnxk_nix_rx_queue_count;
+       eth_dev->rx_descriptor_status = cnxk_nix_rx_descriptor_status;
+       eth_dev->tx_descriptor_status = cnxk_nix_tx_descriptor_status;
 
        /* Alloc security context */
        sec_ctx = plt_zmalloc(sizeof(struct rte_security_ctx), 0);
index 5bfda3d81528cf3fb253681e05688599a77f6874..43814a81fc94df64c3105b23f17f010a1ced9c8c 100644 (file)
@@ -559,6 +559,11 @@ void cnxk_nix_rxq_info_get(struct rte_eth_dev *eth_dev, uint16_t qid,
 void cnxk_nix_txq_info_get(struct rte_eth_dev *eth_dev, uint16_t qid,
                           struct rte_eth_txq_info *qinfo);
 
+/* Queue status */
+int cnxk_nix_rx_descriptor_status(void *rxq, uint16_t offset);
+int cnxk_nix_tx_descriptor_status(void *txq, uint16_t offset);
+uint32_t cnxk_nix_rx_queue_count(void *rxq);
+
 /* Lookup configuration */
 const uint32_t *cnxk_nix_supported_ptypes_get(struct rte_eth_dev *eth_dev);
 void *cnxk_nix_fastpath_lookup_mem_get(void);
index 34e480965039779058055626ff80339bc26f2f93..f20f201db263a9fa6e1d1afb5f19f407cc3ca351 100644 (file)
@@ -695,6 +695,66 @@ cnxk_nix_txq_info_get(struct rte_eth_dev *eth_dev, uint16_t qid,
        memcpy(&qinfo->conf, &txq_sp->qconf.conf.tx, sizeof(qinfo->conf));
 }
 
+uint32_t
+cnxk_nix_rx_queue_count(void *rxq)
+{
+       struct cnxk_eth_rxq_sp *rxq_sp = cnxk_eth_rxq_to_sp(rxq);
+       struct roc_nix *nix = &rxq_sp->dev->nix;
+       uint32_t head, tail;
+
+       roc_nix_cq_head_tail_get(nix, rxq_sp->qid, &head, &tail);
+       return (tail - head) % (rxq_sp->qconf.nb_desc);
+}
+
+static inline int
+nix_offset_has_packet(uint32_t head, uint32_t tail, uint16_t offset, bool is_rx)
+{
+       /* Check given offset(queue index) has packet filled/xmit by HW
+        * in case of Rx or Tx.
+        * Also, checks for wrap around case.
+        */
+       return ((tail > head && offset <= tail && offset >= head) ||
+               (head > tail && (offset >= head || offset <= tail))) ?
+                      is_rx :
+                      !is_rx;
+}
+
+int
+cnxk_nix_rx_descriptor_status(void *rxq, uint16_t offset)
+{
+       struct cnxk_eth_rxq_sp *rxq_sp = cnxk_eth_rxq_to_sp(rxq);
+       struct roc_nix *nix = &rxq_sp->dev->nix;
+       uint32_t head, tail;
+
+       if (rxq_sp->qconf.nb_desc <= offset)
+               return -EINVAL;
+
+       roc_nix_cq_head_tail_get(nix, rxq_sp->qid, &head, &tail);
+
+       if (nix_offset_has_packet(head, tail, offset, 1))
+               return RTE_ETH_RX_DESC_DONE;
+       else
+               return RTE_ETH_RX_DESC_AVAIL;
+}
+
+int
+cnxk_nix_tx_descriptor_status(void *txq, uint16_t offset)
+{
+       struct cnxk_eth_txq_sp *txq_sp = cnxk_eth_txq_to_sp(txq);
+       struct roc_nix *nix = &txq_sp->dev->nix;
+       uint32_t head = 0, tail = 0;
+
+       if (txq_sp->qconf.nb_desc <= offset)
+               return -EINVAL;
+
+       roc_nix_sq_head_tail_get(nix, txq_sp->qid, &head, &tail);
+
+       if (nix_offset_has_packet(head, tail, offset, 0))
+               return RTE_ETH_TX_DESC_DONE;
+       else
+               return RTE_ETH_TX_DESC_FULL;
+}
+
 /* It is a NOP for cnxk as HW frees the buffer on xmit */
 int
 cnxk_nix_tx_done_cleanup(void *txq, uint32_t free_cnt)