DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>
Subject: [dpdk-dev] [PATCH v2 9/9] net/hns3: support query Rx descriptor status
Date: Wed, 10 Mar 2021 14:16:25 +0800	[thread overview]
Message-ID: <1615356985-24722-10-git-send-email-humin29@huawei.com> (raw)
In-Reply-To: <1615356985-24722-1-git-send-email-humin29@huawei.com>

From: Hongbo Zheng <zhenghongbo3@huawei.com>

Add support for query Rx descriptor status in hns3 driver. Check the
descriptor specified and provide the status information of the
corresponding descriptor.

Signed-off-by: Hongbo Zheng <zhenghongbo3@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 doc/guides/nics/features/hns3.ini      |  1 +
 doc/guides/nics/features/hns3_vf.ini   |  1 +
 doc/guides/rel_notes/release_21_05.rst |  1 +
 drivers/net/hns3/hns3_ethdev.c         |  1 +
 drivers/net/hns3/hns3_ethdev_vf.c      |  1 +
 drivers/net/hns3/hns3_rxtx.c           | 36 ++++++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_rxtx.h           |  1 +
 7 files changed, 42 insertions(+)

diff --git a/doc/guides/nics/features/hns3.ini b/doc/guides/nics/features/hns3.ini
index 2c0cb89..3988be4 100644
--- a/doc/guides/nics/features/hns3.ini
+++ b/doc/guides/nics/features/hns3.ini
@@ -35,6 +35,7 @@ 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
 Extended stats       = Y
diff --git a/doc/guides/nics/features/hns3_vf.ini b/doc/guides/nics/features/hns3_vf.ini
index e60b09b..1640669 100644
--- a/doc/guides/nics/features/hns3_vf.ini
+++ b/doc/guides/nics/features/hns3_vf.ini
@@ -33,6 +33,7 @@ Inner L3 checksum    = Y
 Inner L4 checksum    = Y
 Packet type parsing  = Y
 Tx descriptor status = Y
+Rx descriptor status = Y
 Basic stats          = Y
 Extended stats       = Y
 Stats per queue      = Y
diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst
index 619ffd1..5be2bcc 100644
--- a/doc/guides/rel_notes/release_21_05.rst
+++ b/doc/guides/rel_notes/release_21_05.rst
@@ -64,6 +64,7 @@ New Features
   * Added support for Tx push qick doorbell to improve performance.
   * Added support for outer UDP checksum in Kunpeng930.
   * Added support for query Tx descriptor status.
+  * Added support for query Rx descriptor status.
 
 * **Updated NXP DPAA2 driver.**
 
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 997d017..fba715b 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -6774,6 +6774,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev)
 err_mp_init_secondary:
 	eth_dev->dev_ops = NULL;
 	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->rx_descriptor_status = NULL;
 	eth_dev->tx_pkt_burst = NULL;
 	eth_dev->tx_pkt_prepare = NULL;
 	eth_dev->tx_descriptor_status = NULL;
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 28d0e20..b121d7f 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -2917,6 +2917,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev)
 err_mp_init_secondary:
 	eth_dev->dev_ops = NULL;
 	eth_dev->rx_pkt_burst = NULL;
+	eth_dev->rx_descriptor_status = NULL;
 	eth_dev->tx_pkt_burst = NULL;
 	eth_dev->tx_pkt_prepare = NULL;
 	eth_dev->tx_descriptor_status = NULL;
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 4a13613..ba30086 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4123,6 +4123,7 @@ void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev)
 	if (hns->hw.adapter_state == HNS3_NIC_STARTED &&
 	    __atomic_load_n(&hns->hw.reset.resetting, __ATOMIC_RELAXED) == 0) {
 		eth_dev->rx_pkt_burst = hns3_get_rx_function(eth_dev);
+		eth_dev->rx_descriptor_status = hns3_dev_rx_descriptor_status;
 		eth_dev->tx_pkt_burst = hns3_get_tx_function(eth_dev, &prep);
 		eth_dev->tx_pkt_prepare = prep;
 		eth_dev->tx_descriptor_status = hns3_dev_tx_descriptor_status;
@@ -4339,6 +4340,41 @@ hns3_tx_done_cleanup(void *txq, uint32_t free_cnt)
 }
 
 int
+hns3_dev_rx_descriptor_status(void *rx_queue, uint16_t offset)
+{
+	volatile struct hns3_desc *rxdp;
+	struct hns3_rx_queue *rxq;
+	struct rte_eth_dev *dev;
+	uint32_t bd_base_info;
+	uint16_t desc_id;
+
+	rxq = (struct hns3_rx_queue *)rx_queue;
+	if (offset >= rxq->nb_rx_desc)
+		return -EINVAL;
+
+	desc_id = (rxq->next_to_use + offset) % rxq->nb_rx_desc;
+	rxdp = &rxq->rx_ring[desc_id];
+	bd_base_info = rte_le_to_cpu_32(rxdp->rx.bd_base_info);
+	dev = &rte_eth_devices[rxq->port_id];
+	if (dev->rx_pkt_burst == hns3_recv_pkts ||
+	    dev->rx_pkt_burst == hns3_recv_scattered_pkts) {
+		if (offset >= rxq->nb_rx_desc - rxq->rx_free_hold)
+			return RTE_ETH_RX_DESC_UNAVAIL;
+	} else if (dev->rx_pkt_burst == hns3_recv_pkts_vec ||
+		   dev->rx_pkt_burst == hns3_recv_pkts_vec_sve){
+		if (offset >= rxq->nb_rx_desc - rxq->rx_rearm_nb)
+			return RTE_ETH_RX_DESC_UNAVAIL;
+	} else {
+		return RTE_ETH_RX_DESC_UNAVAIL;
+	}
+
+	if (!(bd_base_info & BIT(HNS3_RXD_VLD_B)))
+		return RTE_ETH_RX_DESC_AVAIL;
+	else
+		return RTE_ETH_RX_DESC_DONE;
+}
+
+int
 hns3_dev_tx_descriptor_status(void *tx_queue, uint16_t offset)
 {
 	volatile struct hns3_desc *txdp;
diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h
index a824fb2..ab2b05a 100644
--- a/drivers/net/hns3/hns3_rxtx.h
+++ b/drivers/net/hns3/hns3_rxtx.h
@@ -743,6 +743,7 @@ void hns3_stop_all_txqs(struct rte_eth_dev *dev);
 void hns3_restore_tqp_enable_state(struct hns3_hw *hw);
 int hns3_tx_done_cleanup(void *txq, uint32_t free_cnt);
 void hns3_enable_rxd_adv_layout(struct hns3_hw *hw);
+int hns3_dev_rx_descriptor_status(void *rx_queue, uint16_t offset);
 int hns3_dev_tx_descriptor_status(void *tx_queue, uint16_t offset);
 void hns3_tx_push_init(struct rte_eth_dev *dev);
 
-- 
2.7.4


  parent reply	other threads:[~2021-03-10  6:16 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10  6:16 [dpdk-dev] [PATCH v2 0/9] features and bugfixes for hns3 Min Hu (Connor)
2021-03-10  6:16 ` [dpdk-dev] [PATCH v2 1/9] net/hns3: support runtime config to select IO burst func Min Hu (Connor)
2021-03-11 17:31   ` Ferruh Yigit
2021-03-12  0:59     ` Min Hu (Connor)
2021-03-11 17:39   ` Ferruh Yigit
2021-03-12  1:01     ` Min Hu (Connor)
2021-03-10  6:16 ` [dpdk-dev] [PATCH v2 2/9] net/hns3: support Tx push quick doorbell to improve perf Min Hu (Connor)
2021-03-11 18:05   ` Ferruh Yigit
2021-03-12 11:02     ` Min Hu (Connor)
2021-03-10  6:16 ` [dpdk-dev] [PATCH v2 3/9] net/hns3: support for outer UDP cksum Min Hu (Connor)
2021-03-10  6:16 ` [dpdk-dev] [PATCH v2 4/9] net/hns3: adjust the format of RAS related structures Min Hu (Connor)
2021-03-11 18:25   ` Ferruh Yigit
2021-03-12  1:51     ` Min Hu (Connor)
2021-03-12 10:02       ` Ferruh Yigit
2021-03-12 10:51         ` Min Hu (Connor)
2021-03-16 11:32           ` Min Hu (Connor)
2021-03-10  6:16 ` [dpdk-dev] [PATCH v2 5/9] net/hns3: delete redundant xstats RAS statistics Min Hu (Connor)
2021-03-10  6:16 ` [dpdk-dev] [PATCH v2 6/9] net/hns3: support imissed stats for PF/VF Min Hu (Connor)
2021-03-10  6:16 ` [dpdk-dev] [PATCH v2 7/9] net/hns3: support oerrors stats in PF Min Hu (Connor)
2021-03-10  6:16 ` [dpdk-dev] [PATCH v2 8/9] net/hns3: support query Tx descriptor status Min Hu (Connor)
2021-03-10  6:16 ` Min Hu (Connor) [this message]
2021-03-12 11:51 ` [dpdk-dev] [PATCH v3 0/8] features and bugfixes for hns3 Min Hu (Connor)
2021-03-12 11:51   ` [dpdk-dev] [PATCH v3 1/8] net/hns3: support runtime config to select IO burst func Min Hu (Connor)
2021-03-16 12:40     ` Ferruh Yigit
2021-03-17  1:14       ` Min Hu (Connor)
2021-03-17 15:28         ` Ferruh Yigit
2021-03-19  1:08           ` Min Hu (Connor)
2021-03-12 11:51   ` [dpdk-dev] [PATCH v3 2/8] net/hns3: support for outer UDP cksum Min Hu (Connor)
2021-03-12 11:51   ` [dpdk-dev] [PATCH v3 3/8] net/hns3: adjust the format of RAS related structures Min Hu (Connor)
2021-03-12 11:51   ` [dpdk-dev] [PATCH v3 4/8] net/hns3: delete redundant xstats RAS statistics Min Hu (Connor)
2021-03-12 11:51   ` [dpdk-dev] [PATCH v3 5/8] net/hns3: support imissed stats for PF/VF Min Hu (Connor)
2021-03-12 11:51   ` [dpdk-dev] [PATCH v3 6/8] net/hns3: support oerrors stats in PF Min Hu (Connor)
2021-03-12 11:51   ` [dpdk-dev] [PATCH v3 7/8] net/hns3: support query Tx descriptor status Min Hu (Connor)
2021-03-12 11:51   ` [dpdk-dev] [PATCH v3 8/8] net/hns3: support query Rx " Min Hu (Connor)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1615356985-24722-10-git-send-email-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).