]> git.droids-corp.org - dpdk.git/commitdiff
net/hns3: get number of used descriptors of Rx queue
authorLijun Ou <oulijun@huawei.com>
Thu, 29 Oct 2020 12:51:50 +0000 (20:51 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 3 Nov 2020 22:35:06 +0000 (23:35 +0100)
Implement the available and used rxd number count function.

In Kunpeng series, the NIC hardware supports to read the bd numbers
which wait processed from the hardware FBD (Full Buffer Descriptor),
and the driver maintains the bd number to be written back hardware.
Compare the number of FBDs with the number of BDs to be written back to
the hardware.

The number of used descriptors of a rx queue is computed as follows:
The fbd numbers of reading from FBD register plus the bd numbers to be
written back to hardware maintained by the driver.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
drivers/net/hns3/hns3_ethdev.c
drivers/net/hns3/hns3_ethdev_vf.c
drivers/net/hns3/hns3_rxtx.c
drivers/net/hns3/hns3_rxtx.h

index c34dbea78a7b324aa67b8313ae6741d211b5f614..6342c70ca2b9d1d61c5c2140088211d9e1f36c77 100644 (file)
@@ -6096,6 +6096,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev)
 
        hns3_set_rxtx_function(eth_dev);
        eth_dev->dev_ops = &hns3_eth_dev_ops;
+       eth_dev->rx_queue_count = hns3_rx_queue_count;
        if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
                ret = hns3_mp_init_secondary();
                if (ret) {
index 7d3750d54415a3aca4fcb5e9c50e9e250461c59a..9fb7941eb39cb8da74e02593bb25ad3d4e7f88a7 100644 (file)
@@ -2743,6 +2743,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev)
 
        hns3_set_rxtx_function(eth_dev);
        eth_dev->dev_ops = &hns3vf_eth_dev_ops;
+       eth_dev->rx_queue_count = hns3_rx_queue_count;
        if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
                ret = hns3_mp_init_secondary();
                if (ret) {
index d5119083b19f7e6fb59e1fa5fa093019ebf7df17..55bee176856ed0e5f2ab3a17203310a23b15f7b4 100644 (file)
@@ -3823,3 +3823,28 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 
        return 0;
 }
+
+uint32_t
+hns3_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)
+{
+       /*
+        * Number of BDs that have been processed by the driver
+        * but have not been notified to the hardware.
+        */
+       uint32_t driver_hold_bd_num;
+       struct hns3_rx_queue *rxq;
+       uint32_t fbd_num;
+
+       rxq = dev->data->rx_queues[rx_queue_id];
+       fbd_num = hns3_read_dev(rxq, HNS3_RING_RX_FBDNUM_REG);
+       if (dev->rx_pkt_burst == hns3_recv_pkts_vec ||
+           dev->rx_pkt_burst == hns3_recv_pkts_vec_sve)
+               driver_hold_bd_num = rxq->rx_rearm_nb;
+       else
+               driver_hold_bd_num = rxq->rx_free_hold;
+
+       if (fbd_num <= driver_hold_bd_num)
+               return 0;
+       else
+               return fbd_num - driver_hold_bd_num;
+}
index 4be9c4a4767023b4f282d172350135e78f9ec19f..ae09e946f85129701875c7d189b4a4012892e893 100644 (file)
@@ -620,6 +620,7 @@ int hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc,
                        struct rte_mempool *mp);
 int hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc,
                        unsigned int socket, const struct rte_eth_txconf *conf);
+uint32_t hns3_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int hns3_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);