Skip to contentSkip to conversation

net/hns3: support getting Tx and Rx queue information

PATCH Superseded Wei Hu (Xavier) 2 participants 14 messages Aug 18, 2020 – Aug 25, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/hns3: support getting Tx and Rx queue information

From: Huisong Li <[email protected]>

This patch adds support for querying Rx/Tx queue information.

Currently, if there are not available Rx buffer descriptors in recieving direction based on hns3 network engine, incoming packets will always be dropped by hardware. This patch reports the '.rx_drop_en' information to DPDK framework in the '.dev_infos_get', '.rxq_info_get' and '.rx_queue_setup' ops implementation function.

---
 drivers/net/hns3/hns3_ethdev.c    | 11 +++++++
 drivers/net/hns3/hns3_ethdev_vf.c | 11 +++++++
 drivers/net/hns3/hns3_rxtx.c      | 51 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_rxtx.h      |  5 ++-
 4 files changed, 77 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_ethdev.c +11 -0
index 81e773046..fab1914c3 100644
@@ -2495,6 +2495,15 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)
 		.nb_mtu_seg_max = HNS3_MAX_NON_TSO_BD_PER_PKT,
 	};
 
+	info->default_rxconf = (struct rte_eth_rxconf) {
+		/*
+		 * If there are no available Rx buffer descriptors, incoming
+		 * packets are always dropped by hardware based on hns3 network
+		 * engine.
+		 */
+		.rx_drop_en = 1,
+	};
+
 	info->vmdq_queue_num = 0;
 
 	info->reta_size = HNS3_RSS_IND_TBL_SIZE;
@@ -5413,6 +5422,8 @@ static const struct eth_dev_ops hns3_eth_dev_ops = {
 	.tx_queue_release       = hns3_dev_tx_queue_release,
 	.rx_queue_intr_enable   = hns3_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable  = hns3_dev_rx_queue_intr_disable,
+	.rxq_info_get           = hns3_rxq_info_get,
+	.txq_info_get           = hns3_txq_info_get,
 	.dev_configure          = hns3_dev_configure,
 	.flow_ctrl_get          = hns3_flow_ctrl_get,
 	.flow_ctrl_set          = hns3_flow_ctrl_set,
drivers/net/hns3/hns3_ethdev_vf.c +11 -0
index 1d2941f0e..60b576b02 100644
@@ -947,6 +947,15 @@ hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)
 		.nb_mtu_seg_max = HNS3_MAX_NON_TSO_BD_PER_PKT,
 	};
 
+	info->default_rxconf = (struct rte_eth_rxconf) {
+		/*
+		 * If there are no available Rx buffer descriptors, incoming
+		 * packets are always dropped by hardware based on hns3 network
+		 * engine.
+		 */
+		.rx_drop_en = 1,
+	};
+
 	info->vmdq_queue_num = 0;
 
 	info->reta_size = HNS3_RSS_IND_TBL_SIZE;
@@ -2473,6 +2482,8 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = {
 	.tx_queue_release   = hns3_dev_tx_queue_release,
 	.rx_queue_intr_enable   = hns3_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable  = hns3_dev_rx_queue_intr_disable,
+	.rxq_info_get       = hns3_rxq_info_get,
+	.txq_info_get       = hns3_txq_info_get,
 	.dev_configure      = hns3vf_dev_configure,
 	.mac_addr_add       = hns3vf_add_mac_addr,
 	.mac_addr_remove    = hns3vf_remove_mac_addr,
drivers/net/hns3/hns3_rxtx.c +51 -0

60 lines not on this page · raw message

drivers/net/hns3/hns3_rxtx.h +4 -1
index 0d20a27c8..f1fb3b56a 100644
@@ -402,5 +402,8 @@ int hns3_set_fake_rx_or_tx_queues(struct rte_eth_dev *dev, uint16_t nb_rx_q,
 int hns3_config_gro(struct hns3_hw *hw, bool en);
 int hns3_restore_gro_conf(struct hns3_hw *hw);
 void hns3_update_all_queues_pvid_state(struct hns3_hw *hw);
-
+void hns3_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+		       struct rte_eth_rxq_info *qinfo);
+void hns3_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+		       struct rte_eth_txq_info *qinfo);
 #endif /* _HNS3_RXTX_H_ */
Signature · 1 line
2.27.0
#1 lore raw

PATCH v2 1/1 net/hns3: support getting Tx and Rx queue information

From: Huisong Li <[email protected]>

This patch adds support for querying Rx/Tx queue information.

Currently, if there are not available Rx buffer descriptors in receiving direction based on hns3 network engine, incoming packets will always be dropped by hardware. This patch reports the '.rx_drop_en' information to DPDK framework in the '.dev_infos_get', '.rxq_info_get' and '.rx_queue_setup' ops implementation function.

---
v1 -> v2: fix the typo in the commit log.

---
 drivers/net/hns3/hns3_ethdev.c    | 11 +++++++
 drivers/net/hns3/hns3_ethdev_vf.c | 11 +++++++
 drivers/net/hns3/hns3_rxtx.c      | 51 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_rxtx.h      |  5 ++-
 4 files changed, 77 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_ethdev.c +11 -0
index 81e773046..fab1914c3 100644
@@ -2495,6 +2495,15 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)
 		.nb_mtu_seg_max = HNS3_MAX_NON_TSO_BD_PER_PKT,
 	};
 
+	info->default_rxconf = (struct rte_eth_rxconf) {
+		/*
+		 * If there are no available Rx buffer descriptors, incoming
+		 * packets are always dropped by hardware based on hns3 network
+		 * engine.
+		 */
+		.rx_drop_en = 1,
+	};
+
 	info->vmdq_queue_num = 0;
 
 	info->reta_size = HNS3_RSS_IND_TBL_SIZE;
@@ -5413,6 +5422,8 @@ static const struct eth_dev_ops hns3_eth_dev_ops = {
 	.tx_queue_release       = hns3_dev_tx_queue_release,
 	.rx_queue_intr_enable   = hns3_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable  = hns3_dev_rx_queue_intr_disable,
+	.rxq_info_get           = hns3_rxq_info_get,
+	.txq_info_get           = hns3_txq_info_get,
 	.dev_configure          = hns3_dev_configure,
 	.flow_ctrl_get          = hns3_flow_ctrl_get,
 	.flow_ctrl_set          = hns3_flow_ctrl_set,
drivers/net/hns3/hns3_ethdev_vf.c +11 -0
index 1d2941f0e..60b576b02 100644
@@ -947,6 +947,15 @@ hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)
 		.nb_mtu_seg_max = HNS3_MAX_NON_TSO_BD_PER_PKT,
 	};
 
+	info->default_rxconf = (struct rte_eth_rxconf) {
+		/*
+		 * If there are no available Rx buffer descriptors, incoming
+		 * packets are always dropped by hardware based on hns3 network
+		 * engine.
+		 */
+		.rx_drop_en = 1,
+	};
+
 	info->vmdq_queue_num = 0;
 
 	info->reta_size = HNS3_RSS_IND_TBL_SIZE;
@@ -2473,6 +2482,8 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = {
 	.tx_queue_release   = hns3_dev_tx_queue_release,
 	.rx_queue_intr_enable   = hns3_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable  = hns3_dev_rx_queue_intr_disable,
+	.rxq_info_get       = hns3_rxq_info_get,
+	.txq_info_get       = hns3_txq_info_get,
 	.dev_configure      = hns3vf_dev_configure,
 	.mac_addr_add       = hns3vf_add_mac_addr,
 	.mac_addr_remove    = hns3vf_remove_mac_addr,
drivers/net/hns3/hns3_rxtx.c +51 -0

60 lines not on this page · raw message

drivers/net/hns3/hns3_rxtx.h +4 -1
index 0d20a27c8..f1fb3b56a 100644
@@ -402,5 +402,8 @@ int hns3_set_fake_rx_or_tx_queues(struct rte_eth_dev *dev, uint16_t nb_rx_q,
 int hns3_config_gro(struct hns3_hw *hw, bool en);
 int hns3_restore_gro_conf(struct hns3_hw *hw);
 void hns3_update_all_queues_pvid_state(struct hns3_hw *hw);
-
+void hns3_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+		       struct rte_eth_rxq_info *qinfo);
+void hns3_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+		       struct rte_eth_txq_info *qinfo);
 #endif /* _HNS3_RXTX_H_ */
Signature · 1 line
2.27.0
#2 lore raw
Quoted 12 lines · Wei Hu (Xavier)

From: Huisong Li <[email protected]>

This patch adds support for querying Rx/Tx queue information.

Currently, if there are not available Rx buffer descriptors in receiving direction based on hns3 network engine, incoming packets will always be dropped by hardware. This patch reports the '.rx_drop_en' information to DPDK framework in the '.dev_infos_get', '.rxq_info_get' and '.rx_queue_setup' ops implementation function.

<...>

drivers/net/hns3/hns3_ethdev.c hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) · line 2505

Quoted 12 lines
drivers/net/hns3/hns3_ethdev.c +8 -0
@@ -2495,6 +2495,15 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)
 		.nb_mtu_seg_max = HNS3_MAX_NON_TSO_BD_PER_PKT,
 	};
 
+	info->default_rxconf = (struct rte_eth_rxconf) {
+		/*
+		 * If there are no available Rx buffer descriptors, incoming
+		 * packets are always dropped by hardware based on hns3 network
+		 * engine.
+		 */
+		.rx_drop_en = 1,
+	};

Can you please separate this into two patches, first one for 'rx_drop_en' related changes to existing code, second one to add queue info get functions?

And you may prefer to request backporting the 'rx_drop_en' patch.

<...>

drivers/net/hns3/hns3_rxtx.c void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) · line 2835

Quoted 12 lines
drivers/net/hns3/hns3_rxtx.c +12 -0
+void
+hns3_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+		  struct rte_eth_rxq_info *qinfo)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_rx_queue *rxq = dev->data->rx_queues[queue_id];
+
+	if (rxq == NULL) {
+		hns3_err(hw, "queue pointer of rx queue_id (%u) is NULL.",
+			 queue_id);
+		return;
+	}

'rxq' should not be 'NULL' at this stage, because of the "queue_id >= dev->data->nb_rx_queues" check in 'rte_eth_rx_queue_info_get()'. Can you please check if it can be 'NULL' and if it can be, better to check it in the ethdev API, instead of doing in each PMD, both for 'rxq' & 'txq'.

#3 lore raw

Hi, Ferruh Yigit

Quoted 30 lines · Ferruh Yigit
Quoted 12 lines · Wei Hu (Xavier)

From: Huisong Li <[email protected]>

This patch adds support for querying Rx/Tx queue information.

Currently, if there are not available Rx buffer descriptors in receiving direction based on hns3 network engine, incoming packets will always be dropped by hardware. This patch reports the '.rx_drop_en' information to DPDK framework in the '.dev_infos_get', '.rxq_info_get' and '.rx_queue_setup' ops implementation function.

<...>

drivers/net/hns3/hns3_ethdev.c hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) · line 2505

Quoted 12 lines
drivers/net/hns3/hns3_ethdev.c +8 -0
@@ -2495,6 +2495,15 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)
  		.nb_mtu_seg_max = HNS3_MAX_NON_TSO_BD_PER_PKT,
  	};
 
+	info->default_rxconf = (struct rte_eth_rxconf) {
+		/*
+		 * If there are no available Rx buffer descriptors, incoming
+		 * packets are always dropped by hardware based on hns3 network
+		 * engine.
+		 */
+		.rx_drop_en = 1,
+	};

Can you please separate this into two patches, first one for 'rx_drop_en' related changes to existing code, second one to add queue info get functions?

Quoted 1 line

And you may prefer to request backporting the 'rx_drop_en' patch.

Thanks for you suggestion.

I will update them in V3.

Quoted 18 lines

<...>

drivers/net/hns3/hns3_rxtx.c void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) · line 2835

Quoted 12 lines
drivers/net/hns3/hns3_rxtx.c +12 -0
+void
+hns3_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+		  struct rte_eth_rxq_info *qinfo)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_rx_queue *rxq = dev->data->rx_queues[queue_id];
+
+	if (rxq == NULL) {
+		hns3_err(hw, "queue pointer of rx queue_id (%u) is NULL.",
+			 queue_id);
+		return;
+	}

'rxq' should not be 'NULL' at this stage, because of the "queue_id >= dev->data->nb_rx_queues" check in 'rte_eth_rx_queue_info_get()'. Can you please check if it can be 'NULL' and if it can be, better to check it in the ethdev API, instead of doing in each PMD, both for 'rxq' & 'txq'.

OK, I will send a email to add check rxq & txq in the rte_eth_rx_queue_info_get

and rte_eth_tx_queue_info_get API function.

Thanks, Xavier.

#4 lore raw

v3 cover minor updates for getting queue info

In reply to Wei Hu (Xavier)

This series include 3 patches.
One patch is a minor update to add checking whether the related Tx or Rx queue has been setuped in the rte_eth_rx_queue_info_get and rte_eth_tx_queue_info_get API function to avoid illegal address access.

And the other two patches for hns3 PMD driver.

Huisong Li (1):
net/hns3: support getting Tx and Rx queue information

Wei Hu (Xavier) (2):
net/hns3: report Rx drop packets enable configuration
ethdev: check if queue setupped when getting queue info

 drivers/net/hns3/hns3_ethdev.c    | 11 +++++++++
 drivers/net/hns3/hns3_ethdev_vf.c | 11 +++++++++
 drivers/net/hns3/hns3_rxtx.c      | 39 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_rxtx.h      |  5 +++-
 lib/librte_ethdev/rte_ethdev.c    | 16 +++++++++++++
 5 files changed, 81 insertions(+), 1 deletion(-)
Signature · 1 line
2.27.0
#5 lore raw

PATCH v3 1/3 net/hns3: report Rx drop packets enable configuration

From: "Wei Hu (Xavier)" <[email protected]>

Currently, if there are not available Rx buffer descriptors in recieving direction based on hns3 network engine, incoming packets will always be dropped by hardware. This patch reports the '.rx_drop_en' information to DPDK framework in the '.dev_infos_get', '.rxq_info_get' and '.rx_queue_setup' ops implementation function.

---
 drivers/net/hns3/hns3_ethdev.c    | 9 +++++++++
 drivers/net/hns3/hns3_ethdev_vf.c | 9 +++++++++
 drivers/net/hns3/hns3_rxtx.c      | 6 ++++++
 3 files changed, 24 insertions(+)
drivers/net/hns3/hns3_ethdev.c +9 -0
index 81e773046..bcbbd7e81 100644
@@ -2495,6 +2495,15 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)
 		.nb_mtu_seg_max = HNS3_MAX_NON_TSO_BD_PER_PKT,
 	};
 
+	info->default_rxconf = (struct rte_eth_rxconf) {
+		/*
+		 * If there are no available Rx buffer descriptors, incoming
+		 * packets are always dropped by hardware based on hns3 network
+		 * engine.
+		 */
+		.rx_drop_en = 1,
+	};
+
 	info->vmdq_queue_num = 0;
 
 	info->reta_size = HNS3_RSS_IND_TBL_SIZE;
drivers/net/hns3/hns3_ethdev_vf.c +9 -0
index 1d2941f0e..3156ed7f5 100644
@@ -947,6 +947,15 @@ hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)
 		.nb_mtu_seg_max = HNS3_MAX_NON_TSO_BD_PER_PKT,
 	};
 
+	info->default_rxconf = (struct rte_eth_rxconf) {
+		/*
+		 * If there are no available Rx buffer descriptors, incoming
+		 * packets are always dropped by hardware based on hns3 network
+		 * engine.
+		 */
+		.rx_drop_en = 1,
+	};
+
 	info->vmdq_queue_num = 0;
 
 	info->reta_size = HNS3_RSS_IND_TBL_SIZE;
drivers/net/hns3/hns3_rxtx.c +6 -0
index c0f798159..3e5e32e38 100644
@@ -1251,6 +1251,12 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc,
 		return -EINVAL;
 	}
 
+	if (conf->rx_drop_en == 0)
+		hns3_warn(hw, "if there are no available Rx descriptors,"
+			  "incoming packets are always dropped. input parameter"
+			  " conf->rx_drop_en(%u) is uneffective.",
+			  conf->rx_drop_en);
+
 	if (dev->data->rx_queues[idx]) {
 		hns3_rx_queue_release(dev->data->rx_queues[idx]);
 		dev->data->rx_queues[idx] = NULL;
Signature · 1 line
2.27.0
#6 lore raw

PATCH v3 2/3 net/hns3: support getting Tx and Rx queue information

In reply to Wei Hu (Xavier)

From: Huisong Li <[email protected]>

This patch adds support for querying Rx/Tx queue information.

---
 drivers/net/hns3/hns3_ethdev.c    |  2 ++
 drivers/net/hns3/hns3_ethdev_vf.c |  2 ++
 drivers/net/hns3/hns3_rxtx.c      | 33 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_rxtx.h      |  5 ++++-
 4 files changed, 41 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_ethdev.c +2 -0
index bcbbd7e81..fab1914c3 100644
@@ -5422,6 +5422,8 @@ static const struct eth_dev_ops hns3_eth_dev_ops = {
 	.tx_queue_release       = hns3_dev_tx_queue_release,
 	.rx_queue_intr_enable   = hns3_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable  = hns3_dev_rx_queue_intr_disable,
+	.rxq_info_get           = hns3_rxq_info_get,
+	.txq_info_get           = hns3_txq_info_get,
 	.dev_configure          = hns3_dev_configure,
 	.flow_ctrl_get          = hns3_flow_ctrl_get,
 	.flow_ctrl_set          = hns3_flow_ctrl_set,
drivers/net/hns3/hns3_ethdev_vf.c +2 -0
index 3156ed7f5..60b576b02 100644
@@ -2482,6 +2482,8 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = {
 	.tx_queue_release   = hns3_dev_tx_queue_release,
 	.rx_queue_intr_enable   = hns3_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable  = hns3_dev_rx_queue_intr_disable,
+	.rxq_info_get       = hns3_rxq_info_get,
+	.txq_info_get       = hns3_txq_info_get,
 	.dev_configure      = hns3vf_dev_configure,
 	.mac_addr_add       = hns3vf_add_mac_addr,
 	.mac_addr_remove    = hns3vf_remove_mac_addr,
drivers/net/hns3/hns3_rxtx.c +33 -0
index 3e5e32e38..57dcf0242 100644
@@ -2820,3 +2820,36 @@ void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev)
 		eth_dev->tx_pkt_prepare = hns3_dummy_rxtx_burst;
 	}
 }
+
+void
+hns3_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+		  struct rte_eth_rxq_info *qinfo)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_rx_queue *rxq = dev->data->rx_queues[queue_id];
+
+	qinfo->mp = rxq->mb_pool;
+	qinfo->nb_desc = rxq->nb_rx_desc;
+	qinfo->scattered_rx = dev->data->scattered_rx;
+
+	/*
+	 * If there are no available Rx buffer descriptors, incoming packets
+	 * are always dropped by hardware based on hns3 network engine.
+	 */
+	qinfo->conf.rx_drop_en = 1;
+	qinfo->conf.offloads = dev->data->dev_conf.rxmode.offloads;
+	qinfo->conf.rx_free_thresh = rxq->rx_free_thresh;
+	qinfo->conf.rx_deferred_start = rxq->rx_deferred_start;
+}
+
+void
+hns3_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+		  struct rte_eth_txq_info *qinfo)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_tx_queue *txq = dev->data->tx_queues[queue_id];
+
+	qinfo->nb_desc = txq->nb_tx_desc;
+	qinfo->conf.offloads = dev->data->dev_conf.txmode.offloads;
+	qinfo->conf.tx_deferred_start = txq->tx_deferred_start;
+}
drivers/net/hns3/hns3_rxtx.h +4 -1
index 0d20a27c8..f1fb3b56a 100644
@@ -402,5 +402,8 @@ int hns3_set_fake_rx_or_tx_queues(struct rte_eth_dev *dev, uint16_t nb_rx_q,
 int hns3_config_gro(struct hns3_hw *hw, bool en);
 int hns3_restore_gro_conf(struct hns3_hw *hw);
 void hns3_update_all_queues_pvid_state(struct hns3_hw *hw);
-
+void hns3_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+		       struct rte_eth_rxq_info *qinfo);
+void hns3_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+		       struct rte_eth_txq_info *qinfo);
 #endif /* _HNS3_RXTX_H_ */
Signature · 1 line
2.27.0
#7 lore raw

PATCH v3 3/3 ethdev: check if queue setupped when getting queue info

In reply to Wei Hu (Xavier)

From: "Wei Hu (Xavier)" <[email protected]>

This patch adds checking whether the related Tx or Rx queue has been setuped in the rte_eth_rx_queue_info_get and rte_eth_tx_queue_info_get API function to avoid illegal address access.

---
 lib/librte_ethdev/rte_ethdev.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
lib/librte_ethdev/rte_ethdev.c +16 -0
index 7858ad5f1..0503c7929 100644
@@ -4670,6 +4670,14 @@ rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
 		return -EINVAL;
 	}
 
+	if (dev->data->rx_queues[queue_id] == NULL) {
+		RTE_ETHDEV_LOG(ERR,
+			       "Rx queue %"PRIu16" of device with port_id=%"
+			       PRIu16" has not been setuped\n",
+			       queue_id, port_id);
+		return -EINVAL;
+	}
+
 	if (rte_eth_dev_is_rx_hairpin_queue(dev, queue_id)) {
 		RTE_ETHDEV_LOG(INFO,
 			"Can't get hairpin Rx queue %"PRIu16" info of device with port_id=%"PRIu16"\n",
@@ -4701,6 +4709,14 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
 		return -EINVAL;
 	}
 
+	if (dev->data->tx_queues[queue_id] == NULL) {
+		RTE_ETHDEV_LOG(ERR,
+			       "Tx queue %"PRIu16" of device with port_id=%"
+			       PRIu16" has not been setuped\n",
+			       queue_id, port_id);
+		return -EINVAL;
+	}
+
 	if (rte_eth_dev_is_tx_hairpin_queue(dev, queue_id)) {
 		RTE_ETHDEV_LOG(INFO,
 			"Can't get hairpin Tx queue %"PRIu16" info of device with port_id=%"PRIu16"\n",
Signature · 1 line
2.27.0
#8 lore raw

v4 cover minor updates for getting queue info

In reply to Wei Hu (Xavier)

This series include 3 patches.
One patch is a minor update to add checking whether the related Tx or Rx queue has been setuped in the rte_eth_rx_queue_info_get and rte_eth_tx_queue_info_get API function to avoid illegal address access.

And the other two patches for hns3 PMD driver.

Huisong Li (1):
net/hns3: support getting Tx and Rx queue information

Wei Hu (Xavier) (2):
net/hns3: report Rx drop packets enable configuration
ethdev: check if queue setupped when getting queue info

 drivers/net/hns3/hns3_ethdev.c    | 11 +++++++++
 drivers/net/hns3/hns3_ethdev_vf.c | 11 +++++++++
 drivers/net/hns3/hns3_rxtx.c      | 37 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_rxtx.h      |  5 ++++-
 lib/librte_ethdev/rte_ethdev.c    | 16 +++++++++++++
 5 files changed, 79 insertions(+), 1 deletion(-)
Signature · 1 line
2.27.0
#9 lore raw

PATCH v4 1/3 net/hns3: report Rx drop packets enable configuration

From: "Wei Hu (Xavier)" <[email protected]>

Currently, if there are not available Rx buffer descriptors in receiving direction based on hns3 network engine, incoming packets will always be dropped by hardware. This patch reports the '.rx_drop_en' information to DPDK framework in the '.dev_infos_get', '.rxq_info_get' and '.rx_queue_setup' ops implementation function.

---
 drivers/net/hns3/hns3_ethdev.c    | 9 +++++++++
 drivers/net/hns3/hns3_ethdev_vf.c | 9 +++++++++
 drivers/net/hns3/hns3_rxtx.c      | 6 ++++++
 3 files changed, 24 insertions(+)
drivers/net/hns3/hns3_ethdev.c +9 -0
index 81e773046..bcbbd7e81 100644
@@ -2495,6 +2495,15 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)
 		.nb_mtu_seg_max = HNS3_MAX_NON_TSO_BD_PER_PKT,
 	};
 
+	info->default_rxconf = (struct rte_eth_rxconf) {
+		/*
+		 * If there are no available Rx buffer descriptors, incoming
+		 * packets are always dropped by hardware based on hns3 network
+		 * engine.
+		 */
+		.rx_drop_en = 1,
+	};
+
 	info->vmdq_queue_num = 0;
 
 	info->reta_size = HNS3_RSS_IND_TBL_SIZE;
drivers/net/hns3/hns3_ethdev_vf.c +9 -0
index 1d2941f0e..3156ed7f5 100644
@@ -947,6 +947,15 @@ hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)
 		.nb_mtu_seg_max = HNS3_MAX_NON_TSO_BD_PER_PKT,
 	};
 
+	info->default_rxconf = (struct rte_eth_rxconf) {
+		/*
+		 * If there are no available Rx buffer descriptors, incoming
+		 * packets are always dropped by hardware based on hns3 network
+		 * engine.
+		 */
+		.rx_drop_en = 1,
+	};
+
 	info->vmdq_queue_num = 0;
 
 	info->reta_size = HNS3_RSS_IND_TBL_SIZE;
drivers/net/hns3/hns3_rxtx.c +6 -0
index c0f798159..3e5e32e38 100644
@@ -1251,6 +1251,12 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc,
 		return -EINVAL;
 	}
 
+	if (conf->rx_drop_en == 0)
+		hns3_warn(hw, "if there are no available Rx descriptors,"
+			  "incoming packets are always dropped. input parameter"
+			  " conf->rx_drop_en(%u) is uneffective.",
+			  conf->rx_drop_en);
+
 	if (dev->data->rx_queues[idx]) {
 		hns3_rx_queue_release(dev->data->rx_queues[idx]);
 		dev->data->rx_queues[idx] = NULL;
Signature · 1 line
2.27.0
#10 lore raw

PATCH v4 2/3 net/hns3: support getting Tx and Rx queue information

In reply to Wei Hu (Xavier)

From: Huisong Li <[email protected]>

This patch adds support for querying Rx/Tx queue information.

---
v3 -> v4:
remove unused variable ‘hw’ in hns3_rxq_info_get and hns3_rxq_info_get function.

---
 drivers/net/hns3/hns3_ethdev.c    |  2 ++
 drivers/net/hns3/hns3_ethdev_vf.c |  2 ++
 drivers/net/hns3/hns3_rxtx.c      | 31 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_rxtx.h      |  5 ++++-
 4 files changed, 39 insertions(+), 1 deletion(-)
drivers/net/hns3/hns3_ethdev.c +2 -0
index bcbbd7e81..fab1914c3 100644
@@ -5422,6 +5422,8 @@ static const struct eth_dev_ops hns3_eth_dev_ops = {
 	.tx_queue_release       = hns3_dev_tx_queue_release,
 	.rx_queue_intr_enable   = hns3_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable  = hns3_dev_rx_queue_intr_disable,
+	.rxq_info_get           = hns3_rxq_info_get,
+	.txq_info_get           = hns3_txq_info_get,
 	.dev_configure          = hns3_dev_configure,
 	.flow_ctrl_get          = hns3_flow_ctrl_get,
 	.flow_ctrl_set          = hns3_flow_ctrl_set,
drivers/net/hns3/hns3_ethdev_vf.c +2 -0
index 3156ed7f5..60b576b02 100644
@@ -2482,6 +2482,8 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = {
 	.tx_queue_release   = hns3_dev_tx_queue_release,
 	.rx_queue_intr_enable   = hns3_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable  = hns3_dev_rx_queue_intr_disable,
+	.rxq_info_get       = hns3_rxq_info_get,
+	.txq_info_get       = hns3_txq_info_get,
 	.dev_configure      = hns3vf_dev_configure,
 	.mac_addr_add       = hns3vf_add_mac_addr,
 	.mac_addr_remove    = hns3vf_remove_mac_addr,
drivers/net/hns3/hns3_rxtx.c +31 -0
index 3e5e32e38..fc1a256f3 100644
@@ -2820,3 +2820,34 @@ void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev)
 		eth_dev->tx_pkt_prepare = hns3_dummy_rxtx_burst;
 	}
 }
+
+void
+hns3_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+		  struct rte_eth_rxq_info *qinfo)
+{
+	struct hns3_rx_queue *rxq = dev->data->rx_queues[queue_id];
+
+	qinfo->mp = rxq->mb_pool;
+	qinfo->nb_desc = rxq->nb_rx_desc;
+	qinfo->scattered_rx = dev->data->scattered_rx;
+
+	/*
+	 * If there are no available Rx buffer descriptors, incoming packets
+	 * are always dropped by hardware based on hns3 network engine.
+	 */
+	qinfo->conf.rx_drop_en = 1;
+	qinfo->conf.offloads = dev->data->dev_conf.rxmode.offloads;
+	qinfo->conf.rx_free_thresh = rxq->rx_free_thresh;
+	qinfo->conf.rx_deferred_start = rxq->rx_deferred_start;
+}
+
+void
+hns3_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+		  struct rte_eth_txq_info *qinfo)
+{
+	struct hns3_tx_queue *txq = dev->data->tx_queues[queue_id];
+
+	qinfo->nb_desc = txq->nb_tx_desc;
+	qinfo->conf.offloads = dev->data->dev_conf.txmode.offloads;
+	qinfo->conf.tx_deferred_start = txq->tx_deferred_start;
+}
drivers/net/hns3/hns3_rxtx.h +4 -1
index 0d20a27c8..f1fb3b56a 100644
@@ -402,5 +402,8 @@ int hns3_set_fake_rx_or_tx_queues(struct rte_eth_dev *dev, uint16_t nb_rx_q,
 int hns3_config_gro(struct hns3_hw *hw, bool en);
 int hns3_restore_gro_conf(struct hns3_hw *hw);
 void hns3_update_all_queues_pvid_state(struct hns3_hw *hw);
-
+void hns3_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+		       struct rte_eth_rxq_info *qinfo);
+void hns3_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
+		       struct rte_eth_txq_info *qinfo);
 #endif /* _HNS3_RXTX_H_ */
Signature · 1 line
2.27.0
#11 lore raw

PATCH v4 3/3 ethdev: check if queue setupped when getting queue info

In reply to Wei Hu (Xavier)

From: "Wei Hu (Xavier)" <[email protected]>

This patch adds checking whether the related Tx or Rx queue has been setuped in the rte_eth_rx_queue_info_get and rte_eth_tx_queue_info_get API function to avoid illegal address access.

---
 lib/librte_ethdev/rte_ethdev.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
lib/librte_ethdev/rte_ethdev.c +16 -0
index 7858ad5f1..0503c7929 100644
@@ -4670,6 +4670,14 @@ rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
 		return -EINVAL;
 	}
 
+	if (dev->data->rx_queues[queue_id] == NULL) {
+		RTE_ETHDEV_LOG(ERR,
+			       "Rx queue %"PRIu16" of device with port_id=%"
+			       PRIu16" has not been setuped\n",
+			       queue_id, port_id);
+		return -EINVAL;
+	}
+
 	if (rte_eth_dev_is_rx_hairpin_queue(dev, queue_id)) {
 		RTE_ETHDEV_LOG(INFO,
 			"Can't get hairpin Rx queue %"PRIu16" info of device with port_id=%"PRIu16"\n",
@@ -4701,6 +4709,14 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
 		return -EINVAL;
 	}
 
+	if (dev->data->tx_queues[queue_id] == NULL) {
+		RTE_ETHDEV_LOG(ERR,
+			       "Tx queue %"PRIu16" of device with port_id=%"
+			       PRIu16" has not been setuped\n",
+			       queue_id, port_id);
+		return -EINVAL;
+	}
+
 	if (rte_eth_dev_is_tx_hairpin_queue(dev, queue_id)) {
 		RTE_ETHDEV_LOG(INFO,
 			"Can't get hairpin Tx queue %"PRIu16" info of device with port_id=%"PRIu16"\n",
Signature · 1 line
2.27.0
Reviewed-by on v4 3/3
#12 lore raw

Re: [dpdk-dev] [PATCH v4 3/3] ethdev: check if queue setupped when getting queue info

Quoted 7 lines · Wei Hu (Xavier)

From: "Wei Hu (Xavier)" <[email protected]>

This patch adds checking whether the related Tx or Rx queue has been setuped in the rte_eth_rx_queue_info_get and rte_eth_tx_queue_info_get API function to avoid illegal address access.

#13 lore raw

Re: [dpdk-dev] [PATCH v4 0/3] minor updates for getting queue info

In reply to Wei Hu (Xavier)
Quoted 5 lines · Wei Hu (Xavier)

This series include 3 patches.
One patch is a minor update to add checking whether the related Tx or Rx queue has been setuped in the rte_eth_rx_queue_info_get and rte_eth_tx_queue_info_get API function to avoid illegal address access.

Quoted 9 lines

And the other two patches for hns3 PMD driver.

Huisong Li (1):
net/hns3: support getting Tx and Rx queue information

Wei Hu (Xavier) (2):
net/hns3: report Rx drop packets enable configuration
ethdev: check if queue setupped when getting queue info

Series applied to dpdk-next-net/main, thanks.