!240 [sync] PR-238: sig-dpdk: sync some patches for PMD/LIB/APP

From: @openeuler-sync-bot 
Reviewed-by: @li-huisong 
Signed-off-by: @li-huisong
This commit is contained in:
openeuler-ci-bot 2022-10-26 02:41:59 +00:00 committed by Gitee
commit 45458322fd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
66 changed files with 16617 additions and 1 deletions

View File

@ -0,0 +1,52 @@
From fe5e02e38e96e0b6ac33fd56a0f0b8cbad30b66f Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:01 +0800
Subject: [PATCH 125/189] net/hns3: fix link status capability query from VF
Currently, the VF LSC capability is obtained from PF driver in
the interrupt mailbox interrupt thread, it is asynchronous.
The VF driver waits for 500ms to get this capability in probe
process.
The primary process will receive a message and do probe in the
interrupt thread context when attach a device in the secondary
process. At this case, VF driver never obtains this capability
from PF.
The root cause is that 'vf->pf_push_lsc_cap' is not updated by
the handling mailbox thread until finishing probe. The reason
this update wouldn't be done is that the handling mailbox interrupt
thread and the probe alarm thread are both in epool thread, and
the probe alarm thread is before the mailbox interrupt thread.
Fixes: 9bc2289fe5ea ("net/hns3: refactor VF LSC event report")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_ethdev_vf.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 7323e47f15..b85f68cb1d 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -778,6 +778,14 @@ hns3vf_get_push_lsc_cap(struct hns3_hw *hw)
while (remain_ms > 0) {
rte_delay_ms(HNS3_POLL_RESPONE_MS);
+ /*
+ * The probe process may perform in interrupt thread context.
+ * For example, users attach a device in the secondary process.
+ * At the moment, the handling mailbox task will be blocked. So
+ * driver has to actively handle the HNS3_MBX_LINK_STAT_CHANGE
+ * mailbox from PF driver to get this capability.
+ */
+ hns3_dev_handle_mbx_msg(hw);
if (__atomic_load_n(&vf->pf_push_lsc_cap, __ATOMIC_ACQUIRE) !=
HNS3_PF_PUSH_LSC_CAP_UNKNOWN)
break;
--
2.23.0

View File

@ -0,0 +1,131 @@
From 0e4f6eceec1c0cd0cae67504b90eb6a4f0451307 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:02 +0800
Subject: [PATCH 126/189] net/hns3: support backplane media type
The 802.11 physical PMA sub-layer defines three media: copper, fiber and
backplane. For PMD, the backplane is similar to the fiber, the main
differences are that backplane doesn't have optical module.
Because the interface of firmware fiber is also applicable to the
backplane, this patch supports the backplane only through simple
extension.
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 54 +++++++++++++++++++---------------
1 file changed, 30 insertions(+), 24 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 8a8f3f1950..5632b82078 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -2788,11 +2788,8 @@ hns3_check_media_type(struct hns3_hw *hw, uint8_t media_type)
}
break;
case HNS3_MEDIA_TYPE_FIBER:
- ret = 0;
- break;
case HNS3_MEDIA_TYPE_BACKPLANE:
- PMD_INIT_LOG(ERR, "Media type is Backplane, not supported.");
- ret = -EOPNOTSUPP;
+ ret = 0;
break;
default:
PMD_INIT_LOG(ERR, "Unknown media type = %u!", media_type);
@@ -4245,14 +4242,11 @@ hns3_update_link_info(struct rte_eth_dev *eth_dev)
{
struct hns3_adapter *hns = eth_dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
- int ret = 0;
if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER)
- ret = hns3_update_copper_link_info(hw);
- else if (hw->mac.media_type == HNS3_MEDIA_TYPE_FIBER)
- ret = hns3_update_fiber_link_info(hw);
+ return hns3_update_copper_link_info(hw);
- return ret;
+ return hns3_update_fiber_link_info(hw);
}
static int
@@ -4545,11 +4539,13 @@ hns3_get_port_supported_speed(struct rte_eth_dev *eth_dev)
if (ret)
return ret;
- if (mac->media_type == HNS3_MEDIA_TYPE_FIBER) {
+ if (mac->media_type == HNS3_MEDIA_TYPE_FIBER ||
+ mac->media_type == HNS3_MEDIA_TYPE_BACKPLANE) {
/*
* Some firmware does not support the report of supported_speed,
- * and only report the effective speed of SFP. In this case, it
- * is necessary to use the SFP's speed as the supported_speed.
+ * and only report the effective speed of SFP/backplane. In this
+ * case, it is necessary to use the SFP/backplane's speed as the
+ * supported_speed.
*/
if (mac->supported_speed == 0)
mac->supported_speed =
@@ -4811,7 +4807,7 @@ hns3_check_port_speed(struct hns3_hw *hw, uint32_t link_speeds)
if (mac->media_type == HNS3_MEDIA_TYPE_COPPER)
speed_bit = hns3_convert_link_speeds2bitmap_copper(link_speeds);
- else if (mac->media_type == HNS3_MEDIA_TYPE_FIBER)
+ else
speed_bit = hns3_convert_link_speeds2bitmap_fiber(link_speeds);
if (!(speed_bit & supported_speed)) {
@@ -4955,6 +4951,19 @@ hns3_set_fiber_port_link_speed(struct hns3_hw *hw,
return hns3_cfg_mac_speed_dup(hw, cfg->speed, cfg->duplex);
}
+static const char *
+hns3_get_media_type_name(uint8_t media_type)
+{
+ if (media_type == HNS3_MEDIA_TYPE_FIBER)
+ return "fiber";
+ else if (media_type == HNS3_MEDIA_TYPE_COPPER)
+ return "copper";
+ else if (media_type == HNS3_MEDIA_TYPE_BACKPLANE)
+ return "backplane";
+ else
+ return "unknown";
+}
+
static int
hns3_set_port_link_speed(struct hns3_hw *hw,
struct hns3_set_link_speed_cfg *cfg)
@@ -4969,18 +4978,15 @@ hns3_set_port_link_speed(struct hns3_hw *hw,
#endif
ret = hns3_set_copper_port_link_speed(hw, cfg);
- if (ret) {
- hns3_err(hw, "failed to set copper port link speed,"
- "ret = %d.", ret);
- return ret;
- }
- } else if (hw->mac.media_type == HNS3_MEDIA_TYPE_FIBER) {
+ } else {
ret = hns3_set_fiber_port_link_speed(hw, cfg);
- if (ret) {
- hns3_err(hw, "failed to set fiber port link speed,"
- "ret = %d.", ret);
- return ret;
- }
+ }
+
+ if (ret) {
+ hns3_err(hw, "failed to set %s port link speed, ret = %d.",
+ hns3_get_media_type_name(hw->mac.media_type),
+ ret);
+ return ret;
}
return 0;
--
2.23.0

View File

@ -0,0 +1,46 @@
From 9a640a6c9cfbf7b5dea307209dc6f20cbfc871c0 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:03 +0800
Subject: [PATCH 127/189] net/hns3: cancel heartbeat alarm when VF reset
The purpose of the heartbeat alarm is to keep alive for VF. The mailbox
channel is disabled when VF is reset, and the heartbeat mailbox message
will fail to send. If the reset is not complete, the error information
about the heartbeat sending failure will be printed continuously.
In fact, VF does set alive when VF restore its configuration. So the
heartbeat alarm can be canceled to prepare to start reset and start the
alarm when start service.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_ethdev_vf.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index b85f68cb1d..0dea63e8be 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1977,6 +1977,8 @@ hns3vf_stop_service(struct hns3_adapter *hns)
} else
hw->reset.mbuf_deferred_free = false;
+ rte_eal_alarm_cancel(hns3vf_keep_alive_handler, eth_dev);
+
/*
* It is cumbersome for hardware to pick-and-choose entries for deletion
* from table space. Hence, for function reset software intervention is
@@ -1998,6 +2000,10 @@ hns3vf_start_service(struct hns3_adapter *hns)
eth_dev = &rte_eth_devices[hw->data->port_id];
hns3_set_rxtx_function(eth_dev);
hns3_mp_req_start_rxtx(eth_dev);
+
+ rte_eal_alarm_set(HNS3VF_KEEP_ALIVE_INTERVAL, hns3vf_keep_alive_handler,
+ eth_dev);
+
if (hw->adapter_state == HNS3_NIC_STARTED) {
hns3vf_start_poll_job(eth_dev);
--
2.23.0

View File

@ -0,0 +1,35 @@
From f4039f8c809b290e1031023c6dc680af7e8dbe11 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:04 +0800
Subject: [PATCH 128/189] net/hns3: fix PTP interrupt logging
PMD driver will receive a PTP interrupt when receive a PTP packet.
But driver doesn't distinguish it. As a result, many unknown events
are printed when many PTP packets are received on the link. The PTP
interrupt is normal, so this patch doesn't log and ignores it.
Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 5632b82078..7c9938b96e 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -318,7 +318,7 @@ hns3_interrupt_handler(void *param)
hns3_schedule_reset(hns);
} else if (event_cause == HNS3_VECTOR0_EVENT_MBX) {
hns3_dev_handle_mbx_msg(hw);
- } else {
+ } else if (event_cause != HNS3_VECTOR0_EVENT_PTP) {
hns3_warn(hw, "received unknown event: vector0_int_stat:0x%x "
"ras_int_stat:0x%x cmdq_int_stat:0x%x",
vector0_int, ras_int, cmdq_int);
--
2.23.0

View File

@ -0,0 +1,132 @@
From 8626a054e516796e942019ce4a1e22d6d8fcd3ee Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:05 +0800
Subject: [PATCH 129/189] net/hns3: fix statistics locking
The stats_lock is used to protect statistics update in stats APIs and
periodic task, but current code only protect queue related statistics.
Fixes: a65342d9d5d2 ("net/hns3: fix MAC and queues HW statistics overflow")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_stats.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c
index bf8af4531f..d56d3ec174 100644
--- a/drivers/net/hns3/hns3_stats.c
+++ b/drivers/net/hns3/hns3_stats.c
@@ -629,6 +629,7 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats)
uint16_t i;
int ret;
+ rte_spinlock_lock(&hw->stats_lock);
/* Update imissed stats */
ret = hns3_update_imissed_stats(hw, false);
if (ret) {
@@ -644,10 +645,7 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats)
if (rxq == NULL)
continue;
- rte_spinlock_lock(&hw->stats_lock);
hns3_rcb_rx_ring_stats_get(rxq, stats);
- rte_spinlock_unlock(&hw->stats_lock);
-
rte_stats->ierrors += rxq->err_stats.l2_errors +
rxq->err_stats.pkt_len_errors;
rte_stats->ibytes += rxq->basic_stats.bytes;
@@ -659,9 +657,7 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats)
if (txq == NULL)
continue;
- rte_spinlock_lock(&hw->stats_lock);
hns3_rcb_tx_ring_stats_get(txq, stats);
- rte_spinlock_unlock(&hw->stats_lock);
rte_stats->obytes += txq->basic_stats.bytes;
}
@@ -683,7 +679,10 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats)
rte_stats->opackets = stats->rcb_tx_ring_pktnum_rcd -
rte_stats->oerrors;
rte_stats->rx_nombuf = eth_dev->data->rx_mbuf_alloc_failed;
+
out:
+ rte_spinlock_unlock(&hw->stats_lock);
+
return ret;
}
@@ -697,6 +696,7 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev)
uint16_t i;
int ret;
+ rte_spinlock_lock(&hw->stats_lock);
/*
* Note: Reading hardware statistics of imissed registers will
* clear them.
@@ -732,7 +732,6 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev)
if (rxq == NULL)
continue;
- rte_spinlock_lock(&hw->stats_lock);
memset(&rxq->basic_stats, 0,
sizeof(struct hns3_rx_basic_stats));
@@ -740,7 +739,6 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev)
(void)hns3_read_dev(rxq, HNS3_RING_RX_PKTNUM_RECORD_REG);
rxq->err_stats.pkt_len_errors = 0;
rxq->err_stats.l2_errors = 0;
- rte_spinlock_unlock(&hw->stats_lock);
}
/* Clear all the stats of a txq in a loop to keep them synchronized */
@@ -749,19 +747,18 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev)
if (txq == NULL)
continue;
- rte_spinlock_lock(&hw->stats_lock);
memset(&txq->basic_stats, 0,
sizeof(struct hns3_tx_basic_stats));
/* This register is read-clear */
(void)hns3_read_dev(txq, HNS3_RING_TX_PKTNUM_RECORD_REG);
- rte_spinlock_unlock(&hw->stats_lock);
}
- rte_spinlock_lock(&hw->stats_lock);
hns3_tqp_stats_clear(hw);
- rte_spinlock_unlock(&hw->stats_lock);
+
out:
+ rte_spinlock_unlock(&hw->stats_lock);
+
return ret;
}
@@ -1082,11 +1079,11 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
count++;
}
}
- rte_spinlock_unlock(&hw->stats_lock);
ret = hns3_update_imissed_stats(hw, false);
if (ret) {
hns3_err(hw, "update imissed stats failed, ret = %d", ret);
+ rte_spinlock_unlock(&hw->stats_lock);
return ret;
}
@@ -1115,7 +1112,6 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
}
}
- rte_spinlock_lock(&hw->stats_lock);
hns3_tqp_dfx_stats_get(dev, xstats, &count);
hns3_queue_stats_get(dev, xstats, &count);
rte_spinlock_unlock(&hw->stats_lock);
--
2.23.0

View File

@ -0,0 +1,34 @@
From 07210d18c368b27539218d9c3a907f30447c2a1e Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:06 +0800
Subject: [PATCH 130/189] net/hns3: fix descriptors check with SVE
The SVE algorithm and NEON algorithm have the same requirements for
nb-desc, but the nb-desc is verified only when using NEON.
Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_rxtx.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 0dc1d8cb60..b7fe2352a1 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -1759,7 +1759,8 @@ hns3_rxq_conf_runtime_check(struct hns3_hw *hw, uint16_t buf_size,
return -EINVAL;
}
- if (pkt_burst == hns3_recv_pkts_vec) {
+ if (pkt_burst == hns3_recv_pkts_vec ||
+ pkt_burst == hns3_recv_pkts_vec_sve) {
min_vec_bds = HNS3_DEFAULT_RXQ_REARM_THRESH +
HNS3_DEFAULT_RX_BURST;
if (nb_desc < min_vec_bds ||
--
2.23.0

View File

@ -0,0 +1,50 @@
From 3a1871f1dfbba831c9c6a65081d22e6021d78ffe Mon Sep 17 00:00:00 2001
From: Dongdong Liu <liudongdong3@huawei.com>
Date: Fri, 21 Oct 2022 15:36:07 +0800
Subject: [PATCH 131/189] net/hns3: clean some functions
Delete unnecessary code and adjust code to make code more clean.
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_rxtx.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index b7fe2352a1..840ca384ce 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -1909,8 +1909,6 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc,
rxq->pvid_sw_discard_en = false;
rxq->ptype_en = hns3_dev_get_support(hw, RXD_ADV_LAYOUT) ? true : false;
rxq->configured = true;
- rxq->io_base = (void *)((char *)hw->io_base + HNS3_TQP_REG_OFFSET +
- idx * HNS3_TQP_REG_SIZE);
rxq->io_base = (void *)((char *)hw->io_base +
hns3_get_tqp_reg_offset(idx));
rxq->io_head_reg = (volatile void *)((char *)rxq->io_base +
@@ -2442,10 +2440,8 @@ hns3_recv_pkts_simple(void *rx_queue,
nmb = hns3_rx_alloc_buffer(rxq);
if (unlikely(nmb == NULL)) {
- uint16_t port_id;
-
- port_id = rxq->port_id;
- rte_eth_devices[port_id].data->rx_mbuf_alloc_failed++;
+ rte_eth_devices[rxq->port_id].data->
+ rx_mbuf_alloc_failed++;
break;
}
@@ -3870,7 +3866,7 @@ hns3_prep_pkt_proc(struct hns3_tx_queue *tx_queue, struct rte_mbuf *m)
#endif
if (hns3_pkt_is_tso(m)) {
if (hns3_pkt_need_linearized(m, m->nb_segs,
- tx_queue->max_non_tso_bd_num) ||
+ tx_queue->max_non_tso_bd_num) ||
hns3_check_tso_pkt_valid(m)) {
rte_errno = EINVAL;
return -EINVAL;
--
2.23.0

View File

@ -0,0 +1,88 @@
From a8c847f28e885f7ef07b3fd3fc415e2ce4113ee8 Mon Sep 17 00:00:00 2001
From: Dongdong Liu <liudongdong3@huawei.com>
Date: Fri, 21 Oct 2022 15:36:08 +0800
Subject: [PATCH 132/189] net/hns3: delete unused code
The RTE_HNS3_ONLY_1630_FPGA macro is not in use, so delete the code.
Fixes: 2192c428f9a6 ("net/hns3: fix firmware compatibility configuration")
Fixes: bdaf190f8235 ("net/hns3: support link speed autoneg for PF")
Cc: stable@dpdk.org
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_cmd.c | 33 ---------------------------------
drivers/net/hns3/hns3_ethdev.c | 11 ++---------
2 files changed, 2 insertions(+), 42 deletions(-)
diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c
index e3d096d9cb..50cb3eabb1 100644
--- a/drivers/net/hns3/hns3_cmd.c
+++ b/drivers/net/hns3/hns3_cmd.c
@@ -631,39 +631,6 @@ hns3_firmware_compat_config(struct hns3_hw *hw, bool is_init)
struct hns3_cmd_desc desc;
uint32_t compat = 0;
-#if defined(RTE_HNS3_ONLY_1630_FPGA)
- /* If resv reg enabled phy driver of imp is not configured, driver
- * will use temporary phy driver.
- */
- struct rte_pci_device *pci_dev;
- struct rte_eth_dev *eth_dev;
- uint8_t revision;
- int ret;
-
- eth_dev = &rte_eth_devices[hw->data->port_id];
- pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
- /* Get PCI revision id */
- ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN,
- HNS3_PCI_REVISION_ID);
- if (ret != HNS3_PCI_REVISION_ID_LEN) {
- PMD_INIT_LOG(ERR, "failed to read pci revision id, ret = %d",
- ret);
- return -EIO;
- }
- if (revision == PCI_REVISION_ID_HIP09_A) {
- struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw);
- if (hns3_dev_get_support(hw, COPPER) == 0 || pf->is_tmp_phy) {
- PMD_INIT_LOG(ERR, "***use temp phy driver in dpdk***");
- pf->is_tmp_phy = true;
- hns3_set_bit(hw->capability,
- HNS3_DEV_SUPPORT_COPPER_B, 1);
- return 0;
- }
-
- PMD_INIT_LOG(ERR, "***use phy driver in imp***");
- }
-#endif
-
hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_FIRMWARE_COMPAT_CFG, false);
req = (struct hns3_firmware_compat_cmd *)desc.data;
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 7c9938b96e..401736f5a6 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -4970,17 +4970,10 @@ hns3_set_port_link_speed(struct hns3_hw *hw,
{
int ret;
- if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER) {
-#if defined(RTE_HNS3_ONLY_1630_FPGA)
- struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw);
- if (pf->is_tmp_phy)
- return 0;
-#endif
-
+ if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER)
ret = hns3_set_copper_port_link_speed(hw, cfg);
- } else {
+ else
ret = hns3_set_fiber_port_link_speed(hw, cfg);
- }
if (ret) {
hns3_err(hw, "failed to set %s port link speed, ret = %d.",
--
2.23.0

View File

@ -0,0 +1,62 @@
From ab50c70fe965fb931156eddfbde0ead68323849a Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:09 +0800
Subject: [PATCH 133/189] examples/dma: support dequeue when no packet received
Currently the example using DMA in asynchronous mode, which are:
nb_rx = rte_eth_rx_burst();
if (nb_rx == 0)
continue;
...
dma_enqueue(); // enqueue the received packets copy request
nb_cpl = dma_dequeue(); // get copy completed packets
...
There are no waiting inside dma_dequeue(), and this is why it's called
asynchronus. If there are no packet received, it won't call
dma_dequeue(), but some packets may still in the DMA queue which
enqueued in last cycle. As a result, when the traffic is stopped, the
sent packets and received packets are unbalanced from the perspective
of the traffic generator.
The patch supports DMA dequeue when no packet received, it helps to
judge the test result by comparing the sent packets with the received
packets on traffic generator sides.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Kevin Laatz <kevin.laatz@intel.com>
---
examples/dma/dmafwd.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c
index 9b17b40dbf..b06042e5fe 100644
--- a/examples/dma/dmafwd.c
+++ b/examples/dma/dmafwd.c
@@ -408,8 +408,13 @@ dma_rx_port(struct rxtx_port_config *rx_config)
nb_rx = rte_eth_rx_burst(rx_config->rxtx_port, i,
pkts_burst, MAX_PKT_BURST);
- if (nb_rx == 0)
+ if (nb_rx == 0) {
+ if (copy_mode == COPY_MODE_DMA_NUM &&
+ (nb_rx = dma_dequeue(pkts_burst, pkts_burst_copy,
+ MAX_PKT_BURST, rx_config->dmadev_ids[i])) > 0)
+ goto handle_tx;
continue;
+ }
port_statistics.rx[rx_config->rxtx_port] += nb_rx;
@@ -450,6 +455,7 @@ dma_rx_port(struct rxtx_port_config *rx_config)
pkts_burst_copy[j]);
}
+handle_tx:
rte_mempool_put_bulk(dma_pktmbuf_pool,
(void *)pkts_burst, nb_rx);
--
2.23.0

View File

@ -0,0 +1,31 @@
From 29cb11b1bfafa7a4cefaffbbd5b05afab32957ba Mon Sep 17 00:00:00 2001
From: Jie Hai <haijie1@huawei.com>
Date: Fri, 21 Oct 2022 15:36:10 +0800
Subject: [PATCH 134/189] net/hns3: add dump of VF VLAN filter modify
capability
Show whether support modifying VF VLAN filter or not.
Sample output changes:
+ -- support VF VLAN FILTER MOD: Yes
Signed-off-by: Jie Hai <haijie1@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_dump.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c
index ef3e5c0fb4..646e93d8e6 100644
--- a/drivers/net/hns3/hns3_dump.c
+++ b/drivers/net/hns3/hns3_dump.c
@@ -98,6 +98,7 @@ hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw)
{HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, "OUTER UDP CKSUM"},
{HNS3_DEV_SUPPORT_RAS_IMP_B, "RAS IMP"},
{HNS3_DEV_SUPPORT_TM_B, "TM"},
+ {HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B, "VF VLAN FILTER MOD"},
};
uint32_t i;
--
2.23.0

View File

@ -0,0 +1,89 @@
From 9fd76879f458693e1cf368aeeb08238c579c8ff3 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:11 +0800
Subject: [PATCH 135/189] net/hns3: fix Rx with PTP
The Rx and Tx vector algorithm of hns3 PMD don't support PTP
function. Currently, hns3 driver uses 'pf->ptp_enable' to check
whether PTP is enabled so as to not select Rx and Tx vector
algorithm. And the variable is set when call rte_eth_timesync_enable().
Namely, it may not be set before selecting Rx/Tx function, let's say
the case: set PTP offload in dev_configure(), do dev_start() and then
call rte_eth_timesync_enable(). In this case, all PTP packets can not
be received to application. So this patch fixes the check based on the
RTE_ETH_RX_OFFLOAD_TIMESTAMP flag.
Fixes: 3ca3dcd65101 ("net/hns3: fix vector Rx/Tx when PTP enabled")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_ptp.c | 1 -
drivers/net/hns3/hns3_rxtx_vec.c | 20 +++++++++-----------
2 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c
index 0b0061bba5..6bbd85ba23 100644
--- a/drivers/net/hns3/hns3_ptp.c
+++ b/drivers/net/hns3/hns3_ptp.c
@@ -125,7 +125,6 @@ hns3_timesync_enable(struct rte_eth_dev *dev)
if (pf->ptp_enable)
return 0;
- hns3_warn(hw, "note: please ensure Rx/Tx burst mode is simple or common when enabling PTP!");
rte_spinlock_lock(&hw->lock);
ret = hns3_timesync_configure(hns, true);
diff --git a/drivers/net/hns3/hns3_rxtx_vec.c b/drivers/net/hns3/hns3_rxtx_vec.c
index 73f0ab6bc8..153866cf03 100644
--- a/drivers/net/hns3/hns3_rxtx_vec.c
+++ b/drivers/net/hns3/hns3_rxtx_vec.c
@@ -17,15 +17,18 @@ int
hns3_tx_check_vec_support(struct rte_eth_dev *dev)
{
struct rte_eth_txmode *txmode = &dev->data->dev_conf.txmode;
- struct hns3_adapter *hns = dev->data->dev_private;
- struct hns3_pf *pf = &hns->pf;
+ struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
/* Only support RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE */
if (txmode->offloads != RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)
return -ENOTSUP;
- /* Vec is not supported when PTP enabled */
- if (pf->ptp_enable)
+ /*
+ * PTP function requires the cooperation of Rx and Tx.
+ * Tx vector isn't supported if RTE_ETH_RX_OFFLOAD_TIMESTAMP is set
+ * in Rx offloads.
+ */
+ if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
return -ENOTSUP;
return 0;
@@ -233,9 +236,8 @@ hns3_rx_check_vec_support(struct rte_eth_dev *dev)
struct rte_eth_fdir_conf *fconf = &dev->data->dev_conf.fdir_conf;
struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
uint64_t offloads_mask = RTE_ETH_RX_OFFLOAD_TCP_LRO |
- RTE_ETH_RX_OFFLOAD_VLAN;
- struct hns3_adapter *hns = dev->data->dev_private;
- struct hns3_pf *pf = &hns->pf;
+ RTE_ETH_RX_OFFLOAD_VLAN |
+ RTE_ETH_RX_OFFLOAD_TIMESTAMP;
if (dev->data->scattered_rx)
return -ENOTSUP;
@@ -249,9 +251,5 @@ hns3_rx_check_vec_support(struct rte_eth_dev *dev)
if (hns3_rxq_iterate(dev, hns3_rxq_vec_check, NULL) != 0)
return -ENOTSUP;
- /* Vec is not supported when PTP enabled */
- if (pf->ptp_enable)
- return -ENOTSUP;
-
return 0;
}
--
2.23.0

View File

@ -0,0 +1,44 @@
From eaab0561c2effa2f60f27c10d27c099d819fdd1f Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:12 +0800
Subject: [PATCH 136/189] net/hns3: fix crash in SVE Tx
Currently, the number of Tx send bytes is obtained by accumulating the
length of the batch 'mbuf' packets of the current loop cycle.
Unfortunately, it uses svcntd (which means all lane, regardless of
whether the corresponding lane is valid) which may lead to overflow,
and thus refers to an invalid mbuf.
Because the SVE xmit algorithm applies only to a single mbuf, the
mbuf's data_len is equal pkt_len, so this patch fixes it by using
svaddv_u64(svbool_t pg, svuint64_t data_len) which only adds valid
lanes.
Fixes: fdcd6a3e0246 ("net/hns3: add bytes stats")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_rxtx_vec_sve.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c
index be1fdbcdf0..b0dfb052bb 100644
--- a/drivers/net/hns3/hns3_rxtx_vec_sve.c
+++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c
@@ -435,9 +435,8 @@ hns3_tx_fill_hw_ring_sve(struct hns3_tx_queue *txq,
offsets, svdup_n_u64(valid_bit));
/* Increment bytes counter */
- uint32_t idx;
- for (idx = 0; idx < svcntd(); idx++)
- txq->basic_stats.bytes += pkts[idx]->pkt_len;
+ txq->basic_stats.bytes +=
+ (svaddv_u64(pg, data_len) >> HNS3_UINT16_BIT);
/* update index for next loop */
i += svcntd();
--
2.23.0

View File

@ -0,0 +1,46 @@
From e95f25b7cda1108b4e0579dd70f1bf90516b7e2c Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:13 +0800
Subject: [PATCH 137/189] net/hns3: fix next-to-use overflow in SVE Tx
If txq's next-to-use plus nb_pkts equal txq's nb_tx_desc when using
SVE xmit algorithm, the txq's next-to-use will equal nb_tx_desc after
the xmit, this does not cause Tx exceptions, but may affect other ops
that depend on this field, such as tx_descriptor_status.
Fixes: f0c243a6cb6f ("net/hns3: support SVE Tx")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_rxtx_vec_sve.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c
index b0dfb052bb..f09a81dbd5 100644
--- a/drivers/net/hns3/hns3_rxtx_vec_sve.c
+++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c
@@ -464,14 +464,16 @@ hns3_xmit_fixed_burst_vec_sve(void *__restrict tx_queue,
return 0;
}
- if (txq->next_to_use + nb_pkts > txq->nb_tx_desc) {
+ if (txq->next_to_use + nb_pkts >= txq->nb_tx_desc) {
nb_tx = txq->nb_tx_desc - txq->next_to_use;
hns3_tx_fill_hw_ring_sve(txq, tx_pkts, nb_tx);
txq->next_to_use = 0;
}
- hns3_tx_fill_hw_ring_sve(txq, tx_pkts + nb_tx, nb_pkts - nb_tx);
- txq->next_to_use += nb_pkts - nb_tx;
+ if (nb_pkts > nb_tx) {
+ hns3_tx_fill_hw_ring_sve(txq, tx_pkts + nb_tx, nb_pkts - nb_tx);
+ txq->next_to_use += nb_pkts - nb_tx;
+ }
txq->tx_bd_ready -= nb_pkts;
hns3_write_txq_tail_reg(txq, nb_pkts);
--
2.23.0

View File

@ -0,0 +1,46 @@
From 982c9eabe68c6d5a0e8328df8dc11c5f315eddf0 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:14 +0800
Subject: [PATCH 138/189] net/hns3: fix next-to-use overflow in simple Tx
If txq's next-to-use plus nb_pkts equal txq's nb_tx_desc when using
simple xmit algorithm, the txq's next-to-use will equal nb_tx_desc
fter the xmit, this does not cause Tx exceptions, but may affect other
ops that depend on this field, such as tx_descriptor_status.
Fixes: 7ef933908f04 ("net/hns3: add simple Tx path")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_rxtx.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 840ca384ce..93cc70477d 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4129,14 +4129,16 @@ hns3_xmit_pkts_simple(void *tx_queue,
}
txq->tx_bd_ready -= nb_pkts;
- if (txq->next_to_use + nb_pkts > txq->nb_tx_desc) {
+ if (txq->next_to_use + nb_pkts >= txq->nb_tx_desc) {
nb_tx = txq->nb_tx_desc - txq->next_to_use;
hns3_tx_fill_hw_ring(txq, tx_pkts, nb_tx);
txq->next_to_use = 0;
}
- hns3_tx_fill_hw_ring(txq, tx_pkts + nb_tx, nb_pkts - nb_tx);
- txq->next_to_use += nb_pkts - nb_tx;
+ if (nb_pkts > nb_tx) {
+ hns3_tx_fill_hw_ring(txq, tx_pkts + nb_tx, nb_pkts - nb_tx);
+ txq->next_to_use += nb_pkts - nb_tx;
+ }
hns3_write_txq_tail_reg(txq, nb_pkts);
--
2.23.0

View File

@ -0,0 +1,56 @@
From c4f3e4cf9404434d8062c523c8b6bc55df136140 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:15 +0800
Subject: [PATCH 139/189] net/hns3: optimize SVE Tx performance
Optimize SVE xmit algorithm performance, will get about 1%+
performance gain under 64B macfwd.
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/hns3/hns3_rxtx_vec_sve.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c
index f09a81dbd5..6f23ba674d 100644
--- a/drivers/net/hns3/hns3_rxtx_vec_sve.c
+++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c
@@ -389,10 +389,12 @@ hns3_tx_fill_hw_ring_sve(struct hns3_tx_queue *txq,
HNS3_UINT32_BIT;
svuint64_t base_addr, buf_iova, data_off, data_len, addr;
svuint64_t offsets = svindex_u64(0, BD_SIZE);
- uint32_t i = 0;
- svbool_t pg = svwhilelt_b64_u32(i, nb_pkts);
+ uint32_t cnt = svcntd();
+ svbool_t pg;
+ uint32_t i;
- do {
+ for (i = 0; i < nb_pkts; /* i is updated in the inner loop */) {
+ pg = svwhilelt_b64_u32(i, nb_pkts);
base_addr = svld1_u64(pg, (uint64_t *)pkts);
/* calc mbuf's field buf_iova address */
buf_iova = svadd_n_u64_z(pg, base_addr,
@@ -439,12 +441,11 @@ hns3_tx_fill_hw_ring_sve(struct hns3_tx_queue *txq,
(svaddv_u64(pg, data_len) >> HNS3_UINT16_BIT);
/* update index for next loop */
- i += svcntd();
- pkts += svcntd();
- txdp += svcntd();
- tx_entry += svcntd();
- pg = svwhilelt_b64_u32(i, nb_pkts);
- } while (svptest_any(svptrue_b64(), pg));
+ i += cnt;
+ pkts += cnt;
+ txdp += cnt;
+ tx_entry += cnt;
+ }
}
static uint16_t
--
2.23.0

View File

@ -0,0 +1,75 @@
From aa31e13f290fb82b43dac134f6b2b0332b3ffd45 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:16 +0800
Subject: [PATCH 140/189] net/hns3: fix crash when secondary process access FW
Currently, to prevent missing reporting of reset interrupts and quickly
identify reset interrupts, the following logic is designed in the
FW (firmware) command interface hns3_cmd_send: if an unprocessed
interrupt exist (by checking reset registers), related reset task is
scheduled.
The secondary process may invoke the hns3_cmd_send interface (e.g. using
proc-info query some stats). Unfortunately, the secondary process
does not support reset processing, and a segment fault may occur if it
schedules reset task.
Fix it by limit the checking and scheduling of reset under only primary
process.
Fixes: 2790c6464725 ("net/hns3: support device reset")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 10 +++++++++-
drivers/net/hns3/hns3_ethdev_vf.c | 11 +++++++++--
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 401736f5a6..24ee9df332 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -5602,7 +5602,15 @@ hns3_is_reset_pending(struct hns3_adapter *hns)
struct hns3_hw *hw = &hns->hw;
enum hns3_reset_level reset;
- hns3_check_event_cause(hns, NULL);
+ /*
+ * Check the registers to confirm whether there is reset pending.
+ * Note: This check may lead to schedule reset task, but only primary
+ * process can process the reset event. Therefore, limit the
+ * checking under only primary process.
+ */
+ if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+ hns3_check_event_cause(hns, NULL);
+
reset = hns3_get_reset_level(hns, &hw->reset.pending);
if (reset != HNS3_NONE_RESET && hw->reset.level != HNS3_NONE_RESET &&
hw->reset.level < reset) {
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 0dea63e8be..db2f15abe2 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1864,8 +1864,15 @@ hns3vf_is_reset_pending(struct hns3_adapter *hns)
if (hw->reset.level == HNS3_VF_FULL_RESET)
return false;
- /* Check the registers to confirm whether there is reset pending */
- hns3vf_check_event_cause(hns, NULL);
+ /*
+ * Check the registers to confirm whether there is reset pending.
+ * Note: This check may lead to schedule reset task, but only primary
+ * process can process the reset event. Therefore, limit the
+ * checking under only primary process.
+ */
+ if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+ hns3vf_check_event_cause(hns, NULL);
+
reset = hns3vf_get_reset_level(hw, &hw->reset.pending);
if (hw->reset.level != HNS3_NONE_RESET && reset != HNS3_NONE_RESET &&
hw->reset.level < reset) {
--
2.23.0

View File

@ -0,0 +1,81 @@
From a3cc39e81492da62dc98146c33f8f5dbb632e746 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:17 +0800
Subject: [PATCH 141/189] net/hns3: delete unused markup
The '__rte_unused' tag in the input parameter of 'hns3_mac_stats_reset'
is redundant. This patch remove this tag. In addition, this function is
aimed to clear MAC statics. So using 'struct hns3_hw' as input parameter
is better than 'struct rte_eth_dev', and it also facilitates the call of
this function.
Fixes: 8839c5e202f3 ("net/hns3: support device stats")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_stats.c | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c
index d56d3ec174..c2af3bd231 100644
--- a/drivers/net/hns3/hns3_stats.c
+++ b/drivers/net/hns3/hns3_stats.c
@@ -406,15 +406,6 @@ hns3_query_mac_stats_reg_num(struct hns3_hw *hw)
return 0;
}
-static int
-hns3_query_update_mac_stats(struct rte_eth_dev *dev)
-{
- struct hns3_adapter *hns = dev->data->dev_private;
- struct hns3_hw *hw = &hns->hw;
-
- return hns3_update_mac_stats(hw);
-}
-
static int
hns3_update_port_rpu_drop_stats(struct hns3_hw *hw)
{
@@ -763,14 +754,13 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev)
}
static int
-hns3_mac_stats_reset(__rte_unused struct rte_eth_dev *dev)
+hns3_mac_stats_reset(struct hns3_hw *hw)
{
- struct hns3_adapter *hns = dev->data->dev_private;
- struct hns3_hw *hw = &hns->hw;
struct hns3_mac_stats *mac_stats = &hw->mac_stats;
int ret;
- ret = hns3_query_update_mac_stats(dev);
+ /* Clear hardware MAC statistics by reading it. */
+ ret = hns3_update_mac_stats(hw);
if (ret) {
hns3_err(hw, "Clear Mac stats fail : %d", ret);
return ret;
@@ -1063,8 +1053,7 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
hns3_tqp_basic_stats_get(dev, xstats, &count);
if (!hns->is_vf) {
- /* Update Mac stats */
- ret = hns3_query_update_mac_stats(dev);
+ ret = hns3_update_mac_stats(hw);
if (ret < 0) {
hns3_err(hw, "Update Mac stats fail : %d", ret);
rte_spinlock_unlock(&hw->stats_lock);
@@ -1482,8 +1471,7 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev)
if (hns->is_vf)
goto out;
- /* HW registers are cleared on read */
- ret = hns3_mac_stats_reset(dev);
+ ret = hns3_mac_stats_reset(hw);
out:
rte_spinlock_unlock(&hw->stats_lock);
--
2.23.0

View File

@ -0,0 +1,44 @@
From 70cecb90da490a7f0d484ab9cd8bd481c17f20a3 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:18 +0800
Subject: [PATCH 142/189] net/hns3: fix clearing hardware MAC statistics
In the situation that the driver hns3 exits abnormally during packets
sending and receiving, the hardware statistics are not cleared when the
driver hns3 is reloaded. It need to be cleared during driver hns3
initialization that hardware MAC statistics.
Fixes: 8839c5e202f3 ("net/hns3: support device stats")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_stats.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c
index c2af3bd231..552ae9d30c 100644
--- a/drivers/net/hns3/hns3_stats.c
+++ b/drivers/net/hns3/hns3_stats.c
@@ -1528,6 +1528,7 @@ hns3_tqp_stats_clear(struct hns3_hw *hw)
int
hns3_stats_init(struct hns3_hw *hw)
{
+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
int ret;
rte_spinlock_init(&hw->stats_lock);
@@ -1538,6 +1539,9 @@ hns3_stats_init(struct hns3_hw *hw)
return ret;
}
+ if (!hns->is_vf)
+ hns3_mac_stats_reset(hw);
+
return hns3_tqp_stats_init(hw);
}
--
2.23.0

View File

@ -0,0 +1,185 @@
From 39caf6f8ce22bb3d8af12ab16b1182fe1679698d Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:19 +0800
Subject: [PATCH 143/189] net/hns3: revert Tx performance optimization
The Tx performance deteriorates in the case of larger packets size and
larger burst. It may take a long time to optimize in these scenarios,
so this commit reverts
commit 0b77e8f3d364 ("net/hns3: optimize Tx performance")
Fixes: 0b77e8f3d364 ("net/hns3: optimize Tx performance")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_rxtx.c | 115 ++++++++++++++++++-----------------
1 file changed, 60 insertions(+), 55 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 93cc70477d..21c3ef72b1 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -3075,51 +3075,40 @@ hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc,
return 0;
}
-static int
+static void
hns3_tx_free_useless_buffer(struct hns3_tx_queue *txq)
{
uint16_t tx_next_clean = txq->next_to_clean;
- uint16_t tx_next_use = txq->next_to_use;
- struct hns3_entry *tx_entry = &txq->sw_ring[tx_next_clean];
+ uint16_t tx_next_use = txq->next_to_use;
+ uint16_t tx_bd_ready = txq->tx_bd_ready;
+ uint16_t tx_bd_max = txq->nb_tx_desc;
+ struct hns3_entry *tx_bak_pkt = &txq->sw_ring[tx_next_clean];
struct hns3_desc *desc = &txq->tx_ring[tx_next_clean];
- uint16_t i;
-
- if (tx_next_use >= tx_next_clean &&
- tx_next_use < tx_next_clean + txq->tx_rs_thresh)
- return -1;
+ struct rte_mbuf *mbuf;
- /*
- * All mbufs can be released only when the VLD bits of all
- * descriptors in a batch are cleared.
- */
- for (i = 0; i < txq->tx_rs_thresh; i++) {
- if (desc[i].tx.tp_fe_sc_vld_ra_ri &
- rte_le_to_cpu_16(BIT(HNS3_TXD_VLD_B)))
- return -1;
- }
+ while ((!(desc->tx.tp_fe_sc_vld_ra_ri &
+ rte_cpu_to_le_16(BIT(HNS3_TXD_VLD_B)))) &&
+ tx_next_use != tx_next_clean) {
+ mbuf = tx_bak_pkt->mbuf;
+ if (mbuf) {
+ rte_pktmbuf_free_seg(mbuf);
+ tx_bak_pkt->mbuf = NULL;
+ }
- for (i = 0; i < txq->tx_rs_thresh; i++) {
- rte_pktmbuf_free_seg(tx_entry[i].mbuf);
- tx_entry[i].mbuf = NULL;
+ desc++;
+ tx_bak_pkt++;
+ tx_next_clean++;
+ tx_bd_ready++;
+
+ if (tx_next_clean >= tx_bd_max) {
+ tx_next_clean = 0;
+ desc = txq->tx_ring;
+ tx_bak_pkt = txq->sw_ring;
+ }
}
- /* Update numbers of available descriptor due to buffer freed */
- txq->tx_bd_ready += txq->tx_rs_thresh;
- txq->next_to_clean += txq->tx_rs_thresh;
- if (txq->next_to_clean >= txq->nb_tx_desc)
- txq->next_to_clean = 0;
-
- return 0;
-}
-
-static inline int
-hns3_tx_free_required_buffer(struct hns3_tx_queue *txq, uint16_t required_bds)
-{
- while (required_bds > txq->tx_bd_ready) {
- if (hns3_tx_free_useless_buffer(txq) != 0)
- return -1;
- }
- return 0;
+ txq->next_to_clean = tx_next_clean;
+ txq->tx_bd_ready = tx_bd_ready;
}
int
@@ -4162,8 +4151,7 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
uint16_t nb_tx;
uint16_t i;
- if (txq->tx_bd_ready < txq->tx_free_thresh)
- (void)hns3_tx_free_useless_buffer(txq);
+ hns3_tx_free_useless_buffer(txq);
tx_next_use = txq->next_to_use;
tx_bd_max = txq->nb_tx_desc;
@@ -4178,14 +4166,10 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
nb_buf = tx_pkt->nb_segs;
if (nb_buf > txq->tx_bd_ready) {
- /* Try to release the required MBUF, but avoid releasing
- * all MBUFs, otherwise, the MBUFs will be released for
- * a long time and may cause jitter.
- */
- if (hns3_tx_free_required_buffer(txq, nb_buf) != 0) {
- txq->dfx_stats.queue_full_cnt++;
- goto end_of_tx;
- }
+ txq->dfx_stats.queue_full_cnt++;
+ if (nb_tx == 0)
+ return 0;
+ goto end_of_tx;
}
/*
@@ -4609,22 +4593,43 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
static int
hns3_tx_done_cleanup_full(struct hns3_tx_queue *txq, uint32_t free_cnt)
{
- uint16_t round_cnt;
+ uint16_t next_to_clean = txq->next_to_clean;
+ uint16_t next_to_use = txq->next_to_use;
+ uint16_t tx_bd_ready = txq->tx_bd_ready;
+ struct hns3_entry *tx_pkt = &txq->sw_ring[next_to_clean];
+ struct hns3_desc *desc = &txq->tx_ring[next_to_clean];
uint32_t idx;
if (free_cnt == 0 || free_cnt > txq->nb_tx_desc)
free_cnt = txq->nb_tx_desc;
- if (txq->tx_rs_thresh == 0)
- return 0;
-
- round_cnt = rounddown(free_cnt, txq->tx_rs_thresh);
- for (idx = 0; idx < round_cnt; idx += txq->tx_rs_thresh) {
- if (hns3_tx_free_useless_buffer(txq) != 0)
+ for (idx = 0; idx < free_cnt; idx++) {
+ if (next_to_clean == next_to_use)
+ break;
+ if (desc->tx.tp_fe_sc_vld_ra_ri &
+ rte_cpu_to_le_16(BIT(HNS3_TXD_VLD_B)))
break;
+ if (tx_pkt->mbuf != NULL) {
+ rte_pktmbuf_free_seg(tx_pkt->mbuf);
+ tx_pkt->mbuf = NULL;
+ }
+ next_to_clean++;
+ tx_bd_ready++;
+ tx_pkt++;
+ desc++;
+ if (next_to_clean == txq->nb_tx_desc) {
+ tx_pkt = txq->sw_ring;
+ desc = txq->tx_ring;
+ next_to_clean = 0;
+ }
+ }
+
+ if (idx > 0) {
+ txq->next_to_clean = next_to_clean;
+ txq->tx_bd_ready = tx_bd_ready;
}
- return idx;
+ return (int)idx;
}
int
--
2.23.0

View File

@ -0,0 +1,71 @@
From 85b5d5a0807856f276bb382af7a443e030975cce Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:20 +0800
Subject: [PATCH 144/189] net/hns3: fix RSS rule restore
The 'hns3_restore_rss_filter' function is used to restore RSS rule.
But this function calls the 'hns3_config_rss_filter' which sets the
last to invalid in flow RSS list. This causes the flow RSS list has
no valid rule.
Fixes: ec674cb742e5 ("net/hns3: fix flushing RSS rule")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_flow.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 5e0a9bc93f..8b9bfe4880 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1539,7 +1539,6 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
const struct hns3_rss_conf *conf, bool add)
{
struct hns3_adapter *hns = dev->data->dev_private;
- struct hns3_rss_conf_ele *rss_filter_ptr;
struct hns3_hw *hw = &hns->hw;
struct hns3_rss_conf *rss_info;
uint64_t flow_types;
@@ -1618,13 +1617,6 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
goto rss_config_err;
}
- /*
- * When create a new RSS rule, the old rule will be overlaid and set
- * invalid.
- */
- TAILQ_FOREACH(rss_filter_ptr, &hw->flow_rss_list, entries)
- rss_filter_ptr->filter_info.valid = false;
-
rss_config_err:
rte_spinlock_unlock(&hw->lock);
@@ -1749,6 +1741,7 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev,
{
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
struct hns3_rss_conf_ele *rss_filter_ptr;
+ struct hns3_rss_conf_ele *filter_ptr;
const struct hns3_rss_conf *rss_conf;
int ret;
@@ -1773,6 +1766,14 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev,
hns3_rss_conf_copy(&rss_filter_ptr->filter_info, &rss_conf->conf);
rss_filter_ptr->filter_info.valid = true;
+
+ /*
+ * When create a new RSS rule, the old rule will be overlaid and set
+ * invalid.
+ */
+ TAILQ_FOREACH(filter_ptr, &hw->flow_rss_list, entries)
+ filter_ptr->filter_info.valid = false;
+
TAILQ_INSERT_TAIL(&hw->flow_rss_list, rss_filter_ptr, entries);
flow->rule = rss_filter_ptr;
flow->filter_type = RTE_ETH_FILTER_HASH;
--
2.23.0

View File

@ -0,0 +1,65 @@
From 2e78798fe932e9064677c6f2d1ea14542c503202 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:21 +0800
Subject: [PATCH 145/189] net/hns3: fix RSS filter restore
Currently, driver sets RSS function to 'RTE_ETH_HASH_FUNCTION_MAX'
when user flush all rules in order to judge whether driver needs
to restore RSS rules. In fact, all rules are saved in flow RSS list.
So there is no need to modify RSS function to this macro. And this
list can be used to restore. The modification of RSS function may
introduce new problem.
Fixes: eb158fc756a5 ("net/hns3: fix config when creating RSS rule after flush")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_flow.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 8b9bfe4880..82ead96854 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1587,8 +1587,6 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
rss_info->conf.queue_num = 0;
}
- /* set RSS func invalid after flushed */
- rss_info->conf.func = RTE_ETH_HASH_FUNCTION_MAX;
return 0;
}
@@ -1659,13 +1657,23 @@ int
hns3_restore_rss_filter(struct rte_eth_dev *dev)
{
struct hns3_adapter *hns = dev->data->dev_private;
+ struct hns3_rss_conf_ele *filter;
struct hns3_hw *hw = &hns->hw;
+ int ret = 0;
- /* When user flush all rules, it doesn't need to restore RSS rule */
- if (hw->rss_info.conf.func == RTE_ETH_HASH_FUNCTION_MAX)
- return 0;
+ TAILQ_FOREACH(filter, &hw->flow_rss_list, entries) {
+ if (!filter->filter_info.valid)
+ continue;
- return hns3_config_rss_filter(dev, &hw->rss_info, true);
+ ret = hns3_config_rss_filter(dev, &filter->filter_info, true);
+ if (ret != 0) {
+ hns3_err(hw, "restore RSS filter failed, ret=%d", ret);
+ goto out;
+ }
+ }
+
+out:
+ return ret;
}
static int
--
2.23.0

View File

@ -0,0 +1,74 @@
From baa250c283ba4180f3ac55b42c74f98d85860598 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:22 +0800
Subject: [PATCH 146/189] net/hns3: fix lock protection of RSS flow rule
RSS flow rules are saved in RSS filter linked list. The linked
list is modified by rte_flow API and is used to restore RSS rules
during reset process. So this patch uses 'hw->flows_lock' to protect
the configuration and recovery of RSS rule.
Fixes: c37ca66f2b27 ("net/hns3: support RSS")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_flow.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 82ead96854..301a4a56b3 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1596,27 +1596,20 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
hns3_warn(hw, "Config queue numbers %u are beyond the scope of truncated",
rss_flow_conf.queue_num);
hns3_info(hw, "Max of contiguous %u PF queues are configured", num);
-
- rte_spinlock_lock(&hw->lock);
if (num) {
ret = hns3_update_indir_table(dev, &rss_flow_conf, num);
if (ret)
- goto rss_config_err;
+ return ret;
}
/* Set hash algorithm and flow types by the user's config */
ret = hns3_hw_rss_hash_set(hw, &rss_flow_conf);
if (ret)
- goto rss_config_err;
+ return ret;
ret = hns3_rss_conf_copy(rss_info, &rss_flow_conf);
- if (ret) {
+ if (ret)
hns3_err(hw, "RSS config init fail(%d)", ret);
- goto rss_config_err;
- }
-
-rss_config_err:
- rte_spinlock_unlock(&hw->lock);
return ret;
}
@@ -1661,6 +1654,7 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev)
struct hns3_hw *hw = &hns->hw;
int ret = 0;
+ pthread_mutex_lock(&hw->flows_lock);
TAILQ_FOREACH(filter, &hw->flow_rss_list, entries) {
if (!filter->filter_info.valid)
continue;
@@ -1673,6 +1667,8 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev)
}
out:
+ pthread_mutex_unlock(&hw->flows_lock);
+
return ret;
}
--
2.23.0

View File

@ -0,0 +1,159 @@
From c05520ce0dfe94fd8a676a4d69502f6abc67df08 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:23 +0800
Subject: [PATCH 147/189] net/hns3: fix RSS flow rule restore
After reset process, types of RSS flow rule cannot be restored when
load driver without RTE_ETH_MQ_RX_RSS_FLAG flag. This is because the
restoration for RSS flow rule is done in the 'hns3_config_rss()'. But
this function is also used to configure and restore RSS configuration
from ethdev ops, and doesn't configure RSS types if 'rxmode.mq_mode'
has not the flag. As a result, RSS types configured by rte flow API
can't be restored in this case when encounter reset. Actually, all
RSS rules are saved to a global link list.
Use the linked list to restore RSS flow rule.
Fixes: 920be799dbc3 ("net/hns3: fix RSS indirection table configuration")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 11 ++---------
drivers/net/hns3/hns3_ethdev_vf.c | 11 ++---------
drivers/net/hns3/hns3_flow.c | 8 +++++++-
drivers/net/hns3/hns3_flow.h | 1 +
drivers/net/hns3/hns3_rss.h | 1 -
5 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 24ee9df332..fc3fc76a40 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -5006,6 +5006,7 @@ static int
hns3_do_start(struct hns3_adapter *hns, bool reset_queue)
{
struct hns3_hw *hw = &hns->hw;
+ struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id];
bool link_en;
int ret;
@@ -5042,7 +5043,7 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue)
if (ret)
goto err_set_link_speed;
- return 0;
+ return hns3_restore_filter(dev);
err_set_link_speed:
(void)hns3_cfg_mac_mode(hw, false);
@@ -5059,12 +5060,6 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue)
return ret;
}
-static void
-hns3_restore_filter(struct rte_eth_dev *dev)
-{
- hns3_restore_rss_filter(dev);
-}
-
static int
hns3_dev_start(struct rte_eth_dev *dev)
{
@@ -5121,8 +5116,6 @@ hns3_dev_start(struct rte_eth_dev *dev)
hns3_set_rxtx_function(dev);
hns3_mp_req_start_rxtx(dev);
- hns3_restore_filter(dev);
-
/* Enable interrupt of all rx queues before enabling queues */
hns3_dev_all_rx_queue_intr_enable(hw, true);
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index db2f15abe2..13f1cba0e6 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1727,6 +1727,7 @@ static int
hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue)
{
struct hns3_hw *hw = &hns->hw;
+ struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id];
uint16_t nb_rx_q = hw->data->nb_rx_queues;
uint16_t nb_tx_q = hw->data->nb_tx_queues;
int ret;
@@ -1741,13 +1742,7 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue)
if (ret)
hns3_err(hw, "failed to init queues, ret = %d.", ret);
- return ret;
-}
-
-static void
-hns3vf_restore_filter(struct rte_eth_dev *dev)
-{
- hns3_restore_rss_filter(dev);
+ return hns3_restore_filter(dev);
}
static int
@@ -1799,8 +1794,6 @@ hns3vf_dev_start(struct rte_eth_dev *dev)
hns3_set_rxtx_function(dev);
hns3_mp_req_start_rxtx(dev);
- hns3vf_restore_filter(dev);
-
/* Enable interrupt of all rx queues before enabling queues */
hns3_dev_all_rx_queue_intr_enable(hw, true);
hns3_start_tqps(hw);
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 301a4a56b3..7bd2f0bf7a 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1646,7 +1646,7 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev)
return ret;
}
-int
+static int
hns3_restore_rss_filter(struct rte_eth_dev *dev)
{
struct hns3_adapter *hns = dev->data->dev_private;
@@ -1672,6 +1672,12 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev)
return ret;
}
+int
+hns3_restore_filter(struct rte_eth_dev *dev)
+{
+ return hns3_restore_rss_filter(dev);
+}
+
static int
hns3_flow_parse_rss(struct rte_eth_dev *dev,
const struct hns3_rss_conf *conf, bool add)
diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h
index 1ab3f9f5c6..0f5de129a3 100644
--- a/drivers/net/hns3/hns3_flow.h
+++ b/drivers/net/hns3/hns3_flow.h
@@ -49,5 +49,6 @@ int hns3_dev_flow_ops_get(struct rte_eth_dev *dev,
const struct rte_flow_ops **ops);
void hns3_flow_init(struct rte_eth_dev *dev);
void hns3_flow_uninit(struct rte_eth_dev *dev);
+int hns3_restore_filter(struct rte_eth_dev *dev);
#endif /* _HNS3_FLOW_H_ */
diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h
index 5b90d3a628..78c9eff827 100644
--- a/drivers/net/hns3/hns3_rss.h
+++ b/drivers/net/hns3/hns3_rss.h
@@ -110,6 +110,5 @@ int hns3_config_rss(struct hns3_adapter *hns);
void hns3_rss_uninit(struct hns3_adapter *hns);
int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf);
int hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key);
-int hns3_restore_rss_filter(struct rte_eth_dev *dev);
#endif /* _HNS3_RSS_H_ */
--
2.23.0

View File

@ -0,0 +1,71 @@
From d982e1518b7fc217dbf14816b0b929079d742137 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:24 +0800
Subject: [PATCH 148/189] net/hns3: move flow direction rule recovery
The 'hns3_restore_filter' is used to restore flow rules from
rte_flow API during the reset process. This patch moves the
recovery of flow direction rule to this function to improve
code maintainability.
Fixes: fcba820d9b9e ("net/hns3: support flow director")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 4 ----
drivers/net/hns3/hns3_fdir.c | 3 +++
drivers/net/hns3/hns3_flow.c | 7 +++++++
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index fc3fc76a40..01c13f8d70 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -5907,10 +5907,6 @@ hns3_restore_conf(struct hns3_adapter *hns)
if (ret)
goto err_promisc;
- ret = hns3_restore_all_fdir_filter(hns);
- if (ret)
- goto err_promisc;
-
ret = hns3_restore_ptp(hns);
if (ret)
goto err_promisc;
diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c
index 30e5e66772..48a91fb517 100644
--- a/drivers/net/hns3/hns3_fdir.c
+++ b/drivers/net/hns3/hns3_fdir.c
@@ -1068,6 +1068,9 @@ int hns3_restore_all_fdir_filter(struct hns3_adapter *hns)
bool err = false;
int ret;
+ if (hns->is_vf)
+ return 0;
+
/*
* This API is called in the reset recovery process, the parent function
* must hold hw->lock.
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 7bd2f0bf7a..17c4274123 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1675,6 +1675,13 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev)
int
hns3_restore_filter(struct rte_eth_dev *dev)
{
+ struct hns3_adapter *hns = dev->data->dev_private;
+ int ret;
+
+ ret = hns3_restore_all_fdir_filter(hns);
+ if (ret != 0)
+ return ret;
+
return hns3_restore_rss_filter(dev);
}
--
2.23.0

View File

@ -0,0 +1,195 @@
From 470e1b242046d7968ce039428201cc6c9595e114 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:25 +0800
Subject: [PATCH 149/189] net/hns3: fix restore filter function input
This 'hns3_restore_filter' is an internal interface of driver.
Currently, it uses 'struct rte_eth_dev *dev' as input parameter,
This is inconvenient for the function to call in driver because
caller has to obtain its device address by global variable
'rte_eth_devices[]'. Fix the input of this function.
Fixes: 920be799dbc3 ("net/hns3: fix RSS indirection table configuration")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 3 +--
drivers/net/hns3/hns3_ethdev_vf.c | 3 +--
drivers/net/hns3/hns3_flow.c | 30 ++++++++++++------------------
drivers/net/hns3/hns3_flow.h | 2 +-
4 files changed, 15 insertions(+), 23 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 01c13f8d70..c59543ef5b 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -5006,7 +5006,6 @@ static int
hns3_do_start(struct hns3_adapter *hns, bool reset_queue)
{
struct hns3_hw *hw = &hns->hw;
- struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id];
bool link_en;
int ret;
@@ -5043,7 +5042,7 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue)
if (ret)
goto err_set_link_speed;
- return hns3_restore_filter(dev);
+ return hns3_restore_filter(hns);
err_set_link_speed:
(void)hns3_cfg_mac_mode(hw, false);
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 13f1cba0e6..72d60191ab 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1727,7 +1727,6 @@ static int
hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue)
{
struct hns3_hw *hw = &hns->hw;
- struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id];
uint16_t nb_rx_q = hw->data->nb_rx_queues;
uint16_t nb_tx_q = hw->data->nb_tx_queues;
int ret;
@@ -1742,7 +1741,7 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue)
if (ret)
hns3_err(hw, "failed to init queues, ret = %d.", ret);
- return hns3_restore_filter(dev);
+ return hns3_restore_filter(hns);
}
static int
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 17c4274123..2b4286d46d 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1508,11 +1508,9 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config)
}
static int
-hns3_update_indir_table(struct rte_eth_dev *dev,
+hns3_update_indir_table(struct hns3_hw *hw,
const struct rte_flow_action_rss *conf, uint16_t num)
{
- struct hns3_adapter *hns = dev->data->dev_private;
- struct hns3_hw *hw = &hns->hw;
uint16_t indir_tbl[HNS3_RSS_IND_TBL_SIZE_MAX];
uint16_t j;
uint32_t i;
@@ -1535,11 +1533,9 @@ hns3_update_indir_table(struct rte_eth_dev *dev,
}
static int
-hns3_config_rss_filter(struct rte_eth_dev *dev,
+hns3_config_rss_filter(struct hns3_hw *hw,
const struct hns3_rss_conf *conf, bool add)
{
- struct hns3_adapter *hns = dev->data->dev_private;
- struct hns3_hw *hw = &hns->hw;
struct hns3_rss_conf *rss_info;
uint64_t flow_types;
uint16_t num;
@@ -1591,13 +1587,13 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
}
/* Set rx queues to use */
- num = RTE_MIN(dev->data->nb_rx_queues, rss_flow_conf.queue_num);
+ num = RTE_MIN(hw->data->nb_rx_queues, rss_flow_conf.queue_num);
if (rss_flow_conf.queue_num > num)
hns3_warn(hw, "Config queue numbers %u are beyond the scope of truncated",
rss_flow_conf.queue_num);
hns3_info(hw, "Max of contiguous %u PF queues are configured", num);
if (num) {
- ret = hns3_update_indir_table(dev, &rss_flow_conf, num);
+ ret = hns3_update_indir_table(hw, &rss_flow_conf, num);
if (ret)
return ret;
}
@@ -1627,7 +1623,7 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev)
rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list);
while (rss_filter_ptr) {
TAILQ_REMOVE(&hw->flow_rss_list, rss_filter_ptr, entries);
- ret = hns3_config_rss_filter(dev, &rss_filter_ptr->filter_info,
+ ret = hns3_config_rss_filter(hw, &rss_filter_ptr->filter_info,
false);
if (ret)
rss_rule_fail_cnt++;
@@ -1647,11 +1643,9 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev)
}
static int
-hns3_restore_rss_filter(struct rte_eth_dev *dev)
+hns3_restore_rss_filter(struct hns3_hw *hw)
{
- struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_rss_conf_ele *filter;
- struct hns3_hw *hw = &hns->hw;
int ret = 0;
pthread_mutex_lock(&hw->flows_lock);
@@ -1659,7 +1653,7 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev)
if (!filter->filter_info.valid)
continue;
- ret = hns3_config_rss_filter(dev, &filter->filter_info, true);
+ ret = hns3_config_rss_filter(hw, &filter->filter_info, true);
if (ret != 0) {
hns3_err(hw, "restore RSS filter failed, ret=%d", ret);
goto out;
@@ -1673,16 +1667,16 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev)
}
int
-hns3_restore_filter(struct rte_eth_dev *dev)
+hns3_restore_filter(struct hns3_adapter *hns)
{
- struct hns3_adapter *hns = dev->data->dev_private;
+ struct hns3_hw *hw = &hns->hw;
int ret;
ret = hns3_restore_all_fdir_filter(hns);
if (ret != 0)
return ret;
- return hns3_restore_rss_filter(dev);
+ return hns3_restore_rss_filter(hw);
}
static int
@@ -1699,7 +1693,7 @@ hns3_flow_parse_rss(struct rte_eth_dev *dev,
return -EINVAL;
}
- return hns3_config_rss_filter(dev, conf, add);
+ return hns3_config_rss_filter(hw, conf, add);
}
static int
@@ -1960,7 +1954,7 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
break;
case RTE_ETH_FILTER_HASH:
rss_filter_ptr = (struct hns3_rss_conf_ele *)flow->rule;
- ret = hns3_config_rss_filter(dev, &rss_filter_ptr->filter_info,
+ ret = hns3_config_rss_filter(hw, &rss_filter_ptr->filter_info,
false);
if (ret)
return rte_flow_error_set(error, EIO,
diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h
index 0f5de129a3..854fbb7ff0 100644
--- a/drivers/net/hns3/hns3_flow.h
+++ b/drivers/net/hns3/hns3_flow.h
@@ -49,6 +49,6 @@ int hns3_dev_flow_ops_get(struct rte_eth_dev *dev,
const struct rte_flow_ops **ops);
void hns3_flow_init(struct rte_eth_dev *dev);
void hns3_flow_uninit(struct rte_eth_dev *dev);
-int hns3_restore_filter(struct rte_eth_dev *dev);
+int hns3_restore_filter(struct hns3_adapter *hns);
#endif /* _HNS3_FLOW_H_ */
--
2.23.0

View File

@ -0,0 +1,37 @@
From 0acb77e818a7a0e71126667f0624c19c2706f59c Mon Sep 17 00:00:00 2001
From: Dongdong Liu <liudongdong3@huawei.com>
Date: Fri, 21 Oct 2022 15:36:26 +0800
Subject: [PATCH 150/189] net/hns3: fix build with gcov
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
meson build -Db_coverage=true
ninja -C build
../drivers/net/hns3/hns3_ethdev.c:2856:22: warning: cfg.umv_space may be
used uninitialized in this function [-Wmaybe-uninitialized]
2856 | pf->wanted_umv_size = cfg.umv_space;
Fix compiling warnings using gcc 10.3.1.
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index c59543ef5b..45b5d699b4 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -2808,6 +2808,7 @@ hns3_get_board_configuration(struct hns3_hw *hw)
struct hns3_cfg cfg;
int ret;
+ memset(&cfg, 0, sizeof(cfg));
ret = hns3_get_board_cfg(hw, &cfg);
if (ret) {
PMD_INIT_LOG(ERR, "get board config failed %d", ret);
--
2.23.0

View File

@ -0,0 +1,44 @@
From c2fd801565933c744bc6342f9dad56de644d68a3 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:27 +0800
Subject: [PATCH 151/189] net/hns3: fix packet type for GENEVE
Currently, hns3 reports VXLAN tunnel packet type for GENEVE,
which is misleading to user. In fact, hns3 hardware cannot
distinguish between VXLAN and GENEVE packet. So this patch
uses RTE_PTYPE_TUNNEL_GRENAT packet type to report.
Fixes: 7d6df32cf742 ("net/hns3: fix missing outer L4 UDP flag for VXLAN")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_rxtx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 21c3ef72b1..089caccd7f 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -1995,7 +1995,7 @@ hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev)
RTE_PTYPE_INNER_L4_TCP,
RTE_PTYPE_INNER_L4_SCTP,
RTE_PTYPE_INNER_L4_ICMP,
- RTE_PTYPE_TUNNEL_VXLAN,
+ RTE_PTYPE_TUNNEL_GRENAT,
RTE_PTYPE_TUNNEL_NVGRE,
RTE_PTYPE_UNKNOWN
};
@@ -2092,7 +2092,7 @@ hns3_init_tunnel_ptype_tbl(struct hns3_ptype_table *tbl)
tbl->ol3table[5] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT;
tbl->ol4table[0] = RTE_PTYPE_UNKNOWN;
- tbl->ol4table[1] = RTE_PTYPE_L4_UDP | RTE_PTYPE_TUNNEL_VXLAN;
+ tbl->ol4table[1] = RTE_PTYPE_L4_UDP | RTE_PTYPE_TUNNEL_GRENAT;
tbl->ol4table[2] = RTE_PTYPE_TUNNEL_NVGRE;
}
--
2.23.0

View File

@ -0,0 +1,40 @@
From 36416b8c0fd1918ed0f89cca83b8c21e22a529c7 Mon Sep 17 00:00:00 2001
From: Jie Hai <haijie1@huawei.com>
Date: Fri, 21 Oct 2022 15:36:28 +0800
Subject: [PATCH 152/189] net/hns3: remove magic numbers for MAC address
Removing magic numbers with macros.
Signed-off-by: Jie Hai <haijie1@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 45b5d699b4..adc47d815d 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -1713,6 +1713,7 @@ hns3_add_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
uint8_t vf_id;
int ret;
+ int idx;
/* Check if mac addr is valid */
if (!rte_is_multicast_ether_addr(mac_addr)) {
@@ -1730,9 +1731,8 @@ hns3_add_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
HNS3_MC_MAC_VLAN_OPS_DESC_NUM);
if (ret) {
/* This mac addr do not exist, add new entry for it */
- memset(desc[0].data, 0, sizeof(desc[0].data));
- memset(desc[1].data, 0, sizeof(desc[0].data));
- memset(desc[2].data, 0, sizeof(desc[0].data));
+ for (idx = 0; idx < HNS3_MC_MAC_VLAN_OPS_DESC_NUM; idx++)
+ memset(desc[idx].data, 0, sizeof(desc[idx].data));
}
/*
--
2.23.0

View File

@ -0,0 +1,379 @@
From 308a29f8342797bedb8005b7061a9b10be36cc6c Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Fri, 21 Oct 2022 15:36:29 +0800
Subject: [PATCH 153/189] net/hns3: fix code check warnings
Fix code check warnings according to:
- function should have same name with previous declaration;
- local variable should no be referenced in macro referenced;
- macro argument 'adapter' should be enclosed in parentheses.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_common.c | 4 ++--
drivers/net/hns3/hns3_dump.c | 4 ++--
drivers/net/hns3/hns3_ethdev.h | 14 +++++++-------
drivers/net/hns3/hns3_flow.c | 4 ++--
drivers/net/hns3/hns3_intr.c | 27 ++++++++++++---------------
drivers/net/hns3/hns3_intr.h | 4 ++--
drivers/net/hns3/hns3_regs.c | 4 ++--
drivers/net/hns3/hns3_rss.c | 2 +-
drivers/net/hns3/hns3_rss.h | 2 +-
drivers/net/hns3/hns3_rxtx.c | 4 ++--
drivers/net/hns3/hns3_rxtx.h | 14 +++++++++-----
drivers/net/hns3/hns3_stats.h | 5 +++--
12 files changed, 45 insertions(+), 43 deletions(-)
diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c
index 7a65db907e..1a1a016aa6 100644
--- a/drivers/net/hns3/hns3_common.c
+++ b/drivers/net/hns3/hns3_common.c
@@ -493,7 +493,7 @@ hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del)
if (ret) {
hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
addr);
- hns3_err(hw, "failed to %s mac addr(%s) index:%d ret = %d.",
+ hns3_err(hw, "failed to %s mac addr(%s) index:%u ret = %d.",
del ? "remove" : "restore", mac_str, i, ret);
}
}
@@ -680,7 +680,7 @@ hns3_init_ring_with_vector(struct hns3_hw *hw)
ret = hw->ops.bind_ring_with_vector(hw, vec, false,
HNS3_RING_TYPE_TX, i);
if (ret) {
- PMD_INIT_LOG(ERR, "fail to unbind TX ring(%d) with vector: %u, ret=%d",
+ PMD_INIT_LOG(ERR, "fail to unbind TX ring(%u) with vector: %u, ret=%d",
i, vec, ret);
return ret;
}
diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c
index 646e93d8e6..cf5b500be1 100644
--- a/drivers/net/hns3/hns3_dump.c
+++ b/drivers/net/hns3/hns3_dump.c
@@ -342,7 +342,7 @@ static void
hns3_print_queue_state_perline(FILE *file, const uint32_t *queue_state,
uint32_t nb_queues, uint32_t line_num)
{
-#define HNS3_NUM_QUEUE_PER_LINE (sizeof(*queue_state) * HNS3_UINT8_BIT)
+#define HNS3_NUM_QUEUE_PER_LINE (sizeof(uint32_t) * HNS3_UINT8_BIT)
uint32_t id = line_num * HNS3_NUM_QUEUE_PER_LINE;
uint32_t i;
@@ -365,7 +365,7 @@ static void
hns3_display_queue_enable_state(FILE *file, const uint32_t *queue_state,
uint32_t nb_queues, bool is_rxq)
{
-#define HNS3_NUM_QUEUE_PER_LINE (sizeof(*queue_state) * HNS3_UINT8_BIT)
+#define HNS3_NUM_QUEUE_PER_LINE (sizeof(uint32_t) * HNS3_UINT8_BIT)
uint32_t i;
fprintf(file, "\t %s queue id | enable state bitMap\n",
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index eb8ca1e60f..aad779e949 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -898,11 +898,11 @@ enum hns3_dev_cap {
hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_##_name##_B)
#define HNS3_DEV_PRIVATE_TO_HW(adapter) \
- (&((struct hns3_adapter *)adapter)->hw)
+ (&((struct hns3_adapter *)(adapter))->hw)
#define HNS3_DEV_PRIVATE_TO_PF(adapter) \
- (&((struct hns3_adapter *)adapter)->pf)
+ (&((struct hns3_adapter *)(adapter))->pf)
#define HNS3_DEV_PRIVATE_TO_VF(adapter) \
- (&((struct hns3_adapter *)adapter)->vf)
+ (&((struct hns3_adapter *)(adapter))->vf)
#define HNS3_DEV_HW_TO_ADAPTER(hw) \
container_of(hw, struct hns3_adapter, hw)
@@ -999,10 +999,10 @@ static inline uint32_t hns3_read_reg(void *base, uint32_t reg)
#define NEXT_ITEM_OF_ACTION(act, actions, index) \
do { \
- act = (actions) + (index); \
- while (act->type == RTE_FLOW_ACTION_TYPE_VOID) { \
+ (act) = (actions) + (index); \
+ while ((act)->type == RTE_FLOW_ACTION_TYPE_VOID) { \
(index)++; \
- act = actions + index; \
+ (act) = (actions) + (index); \
} \
} while (0)
@@ -1027,7 +1027,7 @@ hns3_atomic_clear_bit(unsigned int nr, volatile uint64_t *addr)
__atomic_fetch_and(addr, ~(1UL << nr), __ATOMIC_RELAXED);
}
-static inline int64_t
+static inline uint64_t
hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr)
{
uint64_t mask = (1UL << nr);
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 2b4286d46d..1aee965e4a 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -66,7 +66,7 @@ static enum rte_flow_item_type tunnel_next_items[] = {
struct items_step_mngr {
enum rte_flow_item_type *items;
- int count;
+ size_t count;
};
static inline void
@@ -1141,7 +1141,7 @@ hns3_validate_item(const struct rte_flow_item *item,
struct items_step_mngr step_mngr,
struct rte_flow_error *error)
{
- int i;
+ uint32_t i;
if (item->last)
return rte_flow_error_set(error, ENOTSUP,
diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c
index 3ca2e1e338..4bdcd6070b 100644
--- a/drivers/net/hns3/hns3_intr.c
+++ b/drivers/net/hns3/hns3_intr.c
@@ -16,12 +16,6 @@
#define SWITCH_CONTEXT_US 10
-#define HNS3_CHECK_MERGE_CNT(val) \
- do { \
- if (val) \
- hw->reset.stats.merge_cnt++; \
- } while (0)
-
static const char *reset_string[HNS3_MAX_RESET] = {
"flr", "vf_func", "vf_pf_func", "vf_full", "vf_global",
"pf_func", "global", "IMP", "none",
@@ -2525,20 +2519,20 @@ static void
hns3_clear_reset_level(struct hns3_hw *hw, uint64_t *levels)
{
uint64_t merge_cnt = hw->reset.stats.merge_cnt;
- int64_t tmp;
+ uint64_t tmp;
switch (hw->reset.level) {
case HNS3_IMP_RESET:
hns3_atomic_clear_bit(HNS3_IMP_RESET, levels);
tmp = hns3_test_and_clear_bit(HNS3_GLOBAL_RESET, levels);
- HNS3_CHECK_MERGE_CNT(tmp);
+ merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt;
tmp = hns3_test_and_clear_bit(HNS3_FUNC_RESET, levels);
- HNS3_CHECK_MERGE_CNT(tmp);
+ merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt;
break;
case HNS3_GLOBAL_RESET:
hns3_atomic_clear_bit(HNS3_GLOBAL_RESET, levels);
tmp = hns3_test_and_clear_bit(HNS3_FUNC_RESET, levels);
- HNS3_CHECK_MERGE_CNT(tmp);
+ merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt;
break;
case HNS3_FUNC_RESET:
hns3_atomic_clear_bit(HNS3_FUNC_RESET, levels);
@@ -2546,19 +2540,19 @@ hns3_clear_reset_level(struct hns3_hw *hw, uint64_t *levels)
case HNS3_VF_RESET:
hns3_atomic_clear_bit(HNS3_VF_RESET, levels);
tmp = hns3_test_and_clear_bit(HNS3_VF_PF_FUNC_RESET, levels);
- HNS3_CHECK_MERGE_CNT(tmp);
+ merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt;
tmp = hns3_test_and_clear_bit(HNS3_VF_FUNC_RESET, levels);
- HNS3_CHECK_MERGE_CNT(tmp);
+ merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt;
break;
case HNS3_VF_FULL_RESET:
hns3_atomic_clear_bit(HNS3_VF_FULL_RESET, levels);
tmp = hns3_test_and_clear_bit(HNS3_VF_FUNC_RESET, levels);
- HNS3_CHECK_MERGE_CNT(tmp);
+ merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt;
break;
case HNS3_VF_PF_FUNC_RESET:
hns3_atomic_clear_bit(HNS3_VF_PF_FUNC_RESET, levels);
tmp = hns3_test_and_clear_bit(HNS3_VF_FUNC_RESET, levels);
- HNS3_CHECK_MERGE_CNT(tmp);
+ merge_cnt = tmp > 0 ? merge_cnt + 1 : merge_cnt;
break;
case HNS3_VF_FUNC_RESET:
hns3_atomic_clear_bit(HNS3_VF_FUNC_RESET, levels);
@@ -2570,13 +2564,16 @@ hns3_clear_reset_level(struct hns3_hw *hw, uint64_t *levels)
default:
return;
};
- if (merge_cnt != hw->reset.stats.merge_cnt)
+
+ if (merge_cnt != hw->reset.stats.merge_cnt) {
hns3_warn(hw,
"No need to do low-level reset after %s reset. "
"merge cnt: %" PRIu64 " total merge cnt: %" PRIu64,
reset_string[hw->reset.level],
hw->reset.stats.merge_cnt - merge_cnt,
hw->reset.stats.merge_cnt);
+ hw->reset.stats.merge_cnt = merge_cnt;
+ }
}
static bool
diff --git a/drivers/net/hns3/hns3_intr.h b/drivers/net/hns3/hns3_intr.h
index 1a0f196614..1490a5e387 100644
--- a/drivers/net/hns3/hns3_intr.h
+++ b/drivers/net/hns3/hns3_intr.h
@@ -170,7 +170,7 @@ struct hns3_hw_error_desc {
const struct hns3_hw_error *hw_err;
};
-int hns3_enable_hw_error_intr(struct hns3_adapter *hns, bool state);
+int hns3_enable_hw_error_intr(struct hns3_adapter *hns, bool en);
void hns3_handle_msix_error(struct hns3_adapter *hns, uint64_t *levels);
void hns3_handle_ras_error(struct hns3_adapter *hns, uint64_t *levels);
void hns3_config_mac_tnl_int(struct hns3_hw *hw, bool en);
@@ -185,7 +185,7 @@ void hns3_schedule_reset(struct hns3_adapter *hns);
void hns3_schedule_delayed_reset(struct hns3_adapter *hns);
int hns3_reset_req_hw_reset(struct hns3_adapter *hns);
int hns3_reset_process(struct hns3_adapter *hns,
- enum hns3_reset_level reset_level);
+ enum hns3_reset_level new_level);
void hns3_reset_abort(struct hns3_adapter *hns);
void hns3_start_report_lse(struct rte_eth_dev *dev);
void hns3_stop_report_lse(struct rte_eth_dev *dev);
diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c
index 6778e4cfc2..33392fd1f0 100644
--- a/drivers/net/hns3/hns3_regs.c
+++ b/drivers/net/hns3/hns3_regs.c
@@ -15,7 +15,7 @@
#define REG_NUM_PER_LINE 4
#define REG_LEN_PER_LINE (REG_NUM_PER_LINE * sizeof(uint32_t))
-static int hns3_get_dfx_reg_line(struct hns3_hw *hw, uint32_t *length);
+static int hns3_get_dfx_reg_line(struct hns3_hw *hw, uint32_t *lines);
static const uint32_t cmdq_reg_addrs[] = {HNS3_CMDQ_TX_ADDR_L_REG,
HNS3_CMDQ_TX_ADDR_H_REG,
@@ -295,7 +295,7 @@ hns3_direct_access_regs(struct hns3_hw *hw, uint32_t *data)
uint32_t *origin_data_ptr = data;
uint32_t reg_offset;
uint16_t i, j;
- int reg_num;
+ size_t reg_num;
/* fetching per-PF registers values from PF PCIe register space */
reg_num = sizeof(cmdq_reg_addrs) / sizeof(uint32_t);
diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 1003daf03e..fc912ed2e8 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -10,7 +10,7 @@
#include "hns3_logs.h"
/* Default hash keys */
-const uint8_t hns3_hash_key[] = {
+const uint8_t hns3_hash_key[HNS3_RSS_KEY_SIZE] = {
0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0,
0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h
index 78c9eff827..a12f8b7034 100644
--- a/drivers/net/hns3/hns3_rss.h
+++ b/drivers/net/hns3/hns3_rss.h
@@ -88,7 +88,7 @@ static inline uint32_t roundup_pow_of_two(uint32_t x)
return 1UL << fls(x - 1);
}
-extern const uint8_t hns3_hash_key[];
+extern const uint8_t hns3_hash_key[HNS3_RSS_KEY_SIZE];
struct hns3_adapter;
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 089caccd7f..f7641b1309 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -2762,7 +2762,7 @@ hns3_rx_check_vec_support(__rte_unused struct rte_eth_dev *dev)
}
uint16_t __rte_weak
-hns3_recv_pkts_vec(__rte_unused void *tx_queue,
+hns3_recv_pkts_vec(__rte_unused void *rx_queue,
__rte_unused struct rte_mbuf **rx_pkts,
__rte_unused uint16_t nb_pkts)
{
@@ -2770,7 +2770,7 @@ hns3_recv_pkts_vec(__rte_unused void *tx_queue,
}
uint16_t __rte_weak
-hns3_recv_pkts_vec_sve(__rte_unused void *tx_queue,
+hns3_recv_pkts_vec_sve(__rte_unused void *rx_queue,
__rte_unused struct rte_mbuf **rx_pkts,
__rte_unused uint16_t nb_pkts)
{
diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h
index 803e805a5b..87c7c115a1 100644
--- a/drivers/net/hns3/hns3_rxtx.h
+++ b/drivers/net/hns3/hns3_rxtx.h
@@ -691,10 +691,12 @@ int hns3_rxq_iterate(struct rte_eth_dev *dev,
int (*callback)(struct hns3_rx_queue *, void *), void *arg);
void hns3_dev_release_mbufs(struct hns3_adapter *hns);
int hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc,
- unsigned int socket, const struct rte_eth_rxconf *conf,
+ unsigned int socket_id,
+ const struct rte_eth_rxconf *conf,
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);
+ unsigned int socket_id,
+ const struct rte_eth_txconf *conf);
uint32_t hns3_rx_queue_count(void *rx_queue);
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);
@@ -704,9 +706,11 @@ uint16_t hns3_recv_pkts_simple(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts);
uint16_t hns3_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts);
-uint16_t hns3_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
+uint16_t hns3_recv_pkts_vec(void *__restrict rx_queue,
+ struct rte_mbuf **__restrict rx_pkts,
uint16_t nb_pkts);
-uint16_t hns3_recv_pkts_vec_sve(void *rx_queue, struct rte_mbuf **rx_pkts,
+uint16_t hns3_recv_pkts_vec_sve(void *__restrict rx_queue,
+ struct rte_mbuf **__restrict rx_pkts,
uint16_t nb_pkts);
int hns3_rx_burst_mode_get(struct rte_eth_dev *dev,
__rte_unused uint16_t queue_id,
@@ -754,7 +758,7 @@ 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);
-uint32_t hns3_get_tqp_reg_offset(uint16_t idx);
+uint32_t hns3_get_tqp_reg_offset(uint16_t queue_id);
int hns3_start_all_txqs(struct rte_eth_dev *dev);
int hns3_start_all_rxqs(struct rte_eth_dev *dev);
void hns3_stop_all_txqs(struct rte_eth_dev *dev);
diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h
index b5cd6188b4..9d84072205 100644
--- a/drivers/net/hns3/hns3_stats.h
+++ b/drivers/net/hns3/hns3_stats.h
@@ -145,7 +145,8 @@ struct hns3_reset_stats;
#define HNS3_IMISSED_STATS_FIELD_OFFSET(f) \
(offsetof(struct hns3_rx_missed_stats, f))
-int hns3_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats);
+int hns3_stats_get(struct rte_eth_dev *eth_dev,
+ struct rte_eth_stats *rte_stats);
int hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
unsigned int n);
int hns3_dev_xstats_reset(struct rte_eth_dev *dev);
@@ -160,7 +161,7 @@ int hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
const uint64_t *ids,
struct rte_eth_xstat_name *xstats_names,
uint32_t size);
-int hns3_stats_reset(struct rte_eth_dev *dev);
+int hns3_stats_reset(struct rte_eth_dev *eth_dev);
int hns3_stats_init(struct hns3_hw *hw);
void hns3_stats_uninit(struct hns3_hw *hw);
int hns3_query_mac_stats_reg_num(struct hns3_hw *hw);
--
2.23.0

View File

@ -0,0 +1,285 @@
From 0dcac22b697cc9585a91793d4b632cff11391ec3 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:30 +0800
Subject: [PATCH 154/189] net/hns3: fix header files includes
Header files should be self contained and should not be cyclically
dependent.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_cmd.h | 3 +++
drivers/net/hns3/hns3_common.c | 2 +-
drivers/net/hns3/hns3_dcb.h | 4 ++++
drivers/net/hns3/hns3_ethdev.c | 2 +-
drivers/net/hns3/hns3_fdir.h | 5 +++++
drivers/net/hns3/hns3_flow.h | 3 +++
drivers/net/hns3/hns3_intr.c | 2 +-
drivers/net/hns3/hns3_mbx.h | 4 ++++
drivers/net/hns3/hns3_mp.h | 2 ++
drivers/net/hns3/hns3_regs.h | 3 +++
drivers/net/hns3/hns3_rss.h | 2 ++
drivers/net/hns3/hns3_rxtx.c | 2 +-
drivers/net/hns3/hns3_rxtx.h | 9 +++++++++
drivers/net/hns3/hns3_stats.h | 5 +++++
drivers/net/hns3/hns3_tm.h | 2 ++
15 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h
index 82c999061d..bee96c1e46 100644
--- a/drivers/net/hns3/hns3_cmd.h
+++ b/drivers/net/hns3/hns3_cmd.h
@@ -7,6 +7,9 @@
#include <stdint.h>
+#include <rte_byteorder.h>
+#include <rte_spinlock.h>
+
#define HNS3_CMDQ_TX_TIMEOUT 30000
#define HNS3_CMDQ_CLEAR_WAIT_TIME 200
#define HNS3_CMDQ_RX_INVLD_B 0
diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c
index 1a1a016aa6..716cebbcec 100644
--- a/drivers/net/hns3/hns3_common.c
+++ b/drivers/net/hns3/hns3_common.c
@@ -7,10 +7,10 @@
#include <ethdev_pci.h>
#include <rte_pci.h>
-#include "hns3_common.h"
#include "hns3_logs.h"
#include "hns3_regs.h"
#include "hns3_rxtx.h"
+#include "hns3_common.h"
int
hns3_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version,
diff --git a/drivers/net/hns3/hns3_dcb.h b/drivers/net/hns3/hns3_dcb.h
index e06ec177c8..9d9e7684c1 100644
--- a/drivers/net/hns3/hns3_dcb.h
+++ b/drivers/net/hns3/hns3_dcb.h
@@ -7,7 +7,11 @@
#include <stdint.h>
+#include <ethdev_driver.h>
+#include <rte_ethdev.h>
+
#include "hns3_cmd.h"
+#include "hns3_ethdev.h"
#define HNS3_ETHER_MAX_RATE 100000
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index adc47d815d..7b0e8fc77d 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -6,7 +6,6 @@
#include <rte_bus_pci.h>
#include <ethdev_pci.h>
-#include "hns3_ethdev.h"
#include "hns3_common.h"
#include "hns3_dump.h"
#include "hns3_logs.h"
@@ -16,6 +15,7 @@
#include "hns3_dcb.h"
#include "hns3_mp.h"
#include "hns3_flow.h"
+#include "hns3_ethdev.h"
#define HNS3_SERVICE_INTERVAL 1000000 /* us */
#define HNS3_SERVICE_QUICK_INTERVAL 10
diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h
index 4d18759160..7be1c0a248 100644
--- a/drivers/net/hns3/hns3_fdir.h
+++ b/drivers/net/hns3/hns3_fdir.h
@@ -5,6 +5,10 @@
#ifndef _HNS3_FDIR_H_
#define _HNS3_FDIR_H_
+#include <stdint.h>
+
+#include <rte_flow.h>
+
struct hns3_fd_key_cfg {
uint8_t key_sel;
uint8_t inner_sipv6_word_en;
@@ -177,6 +181,7 @@ struct hns3_fdir_info {
};
struct hns3_adapter;
+struct hns3_hw;
int hns3_init_fd_config(struct hns3_adapter *hns);
int hns3_fdir_filter_init(struct hns3_adapter *hns);
diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h
index 854fbb7ff0..ec94510152 100644
--- a/drivers/net/hns3/hns3_flow.h
+++ b/drivers/net/hns3/hns3_flow.h
@@ -6,6 +6,9 @@
#define _HNS3_FLOW_H_
#include <rte_flow.h>
+#include <ethdev_driver.h>
+
+#include "hns3_rss.h"
struct hns3_flow_counter {
LIST_ENTRY(hns3_flow_counter) next; /* Pointer to the next counter. */
diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c
index 4bdcd6070b..57679254ee 100644
--- a/drivers/net/hns3/hns3_intr.c
+++ b/drivers/net/hns3/hns3_intr.c
@@ -10,9 +10,9 @@
#include "hns3_common.h"
#include "hns3_logs.h"
-#include "hns3_intr.h"
#include "hns3_regs.h"
#include "hns3_rxtx.h"
+#include "hns3_intr.h"
#define SWITCH_CONTEXT_US 10
diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h
index d637bd2b23..b6ccd9ff8c 100644
--- a/drivers/net/hns3/hns3_mbx.h
+++ b/drivers/net/hns3/hns3_mbx.h
@@ -5,6 +5,10 @@
#ifndef _HNS3_MBX_H_
#define _HNS3_MBX_H_
+#include <stdint.h>
+
+#include <rte_spinlock.h>
+
enum HNS3_MBX_OPCODE {
HNS3_MBX_RESET = 0x01, /* (VF -> PF) assert reset */
HNS3_MBX_ASSERTING_RESET, /* (PF -> VF) PF is asserting reset */
diff --git a/drivers/net/hns3/hns3_mp.h b/drivers/net/hns3/hns3_mp.h
index a74221d086..230230bbfe 100644
--- a/drivers/net/hns3/hns3_mp.h
+++ b/drivers/net/hns3/hns3_mp.h
@@ -5,6 +5,8 @@
#ifndef _HNS3_MP_H_
#define _HNS3_MP_H_
+#include <ethdev_driver.h>
+
/* Local data for primary or secondary process. */
struct hns3_process_local_data {
bool init_done; /* Process action register completed flag. */
diff --git a/drivers/net/hns3/hns3_regs.h b/drivers/net/hns3/hns3_regs.h
index 5812eb39db..2636429844 100644
--- a/drivers/net/hns3/hns3_regs.h
+++ b/drivers/net/hns3/hns3_regs.h
@@ -5,6 +5,9 @@
#ifndef _HNS3_REGS_H_
#define _HNS3_REGS_H_
+#include <ethdev_driver.h>
+#include <rte_dev_info.h>
+
/* bar registers for cmdq */
#define HNS3_CMDQ_TX_ADDR_L_REG 0x27000
#define HNS3_CMDQ_TX_ADDR_H_REG 0x27004
diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h
index a12f8b7034..ebb51b4c66 100644
--- a/drivers/net/hns3/hns3_rss.h
+++ b/drivers/net/hns3/hns3_rss.h
@@ -4,6 +4,7 @@
#ifndef _HNS3_RSS_H_
#define _HNS3_RSS_H_
+
#include <rte_ethdev.h>
#include <rte_flow.h>
@@ -91,6 +92,7 @@ static inline uint32_t roundup_pow_of_two(uint32_t x)
extern const uint8_t hns3_hash_key[HNS3_RSS_KEY_SIZE];
struct hns3_adapter;
+struct hns3_hw;
int hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
struct rte_eth_rss_conf *rss_conf);
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index f7641b1309..8ad40a49c7 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -17,10 +17,10 @@
#endif
#include "hns3_common.h"
-#include "hns3_rxtx.h"
#include "hns3_regs.h"
#include "hns3_logs.h"
#include "hns3_mp.h"
+#include "hns3_rxtx.h"
#define HNS3_CFG_DESC_NUM(num) ((num) / 8 - 1)
#define HNS3_RX_RING_PREFETCTH_MASK 3
diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h
index 87c7c115a1..f619d6d466 100644
--- a/drivers/net/hns3/hns3_rxtx.h
+++ b/drivers/net/hns3/hns3_rxtx.h
@@ -6,7 +6,16 @@
#define _HNS3_RXTX_H_
#include <stdint.h>
+
+#include <ethdev_driver.h>
#include <rte_mbuf_core.h>
+#include <rte_ethdev.h>
+#include <rte_ethdev_core.h>
+#include <rte_io.h>
+#include <rte_mempool.h>
+#include <rte_memzone.h>
+
+#include "hns3_ethdev.h"
#define HNS3_MIN_RING_DESC 64
#define HNS3_MAX_RING_DESC 32768
diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h
index 9d84072205..9a360f8870 100644
--- a/drivers/net/hns3/hns3_stats.h
+++ b/drivers/net/hns3/hns3_stats.h
@@ -5,6 +5,9 @@
#ifndef _HNS3_STATS_H_
#define _HNS3_STATS_H_
+#include <ethdev_driver.h>
+#include <rte_ethdev.h>
+
/* TQP stats */
struct hns3_tqp_stats {
uint64_t rcb_tx_ring_pktnum_rcd; /* Total num of transmitted packets */
@@ -145,6 +148,8 @@ struct hns3_reset_stats;
#define HNS3_IMISSED_STATS_FIELD_OFFSET(f) \
(offsetof(struct hns3_rx_missed_stats, f))
+struct hns3_hw;
+
int hns3_stats_get(struct rte_eth_dev *eth_dev,
struct rte_eth_stats *rte_stats);
int hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
diff --git a/drivers/net/hns3/hns3_tm.h b/drivers/net/hns3/hns3_tm.h
index 83e9cc8ba9..47345eeed1 100644
--- a/drivers/net/hns3/hns3_tm.h
+++ b/drivers/net/hns3/hns3_tm.h
@@ -105,6 +105,8 @@ hns3_tm_calc_node_tc_no(struct hns3_tm_conf *conf, uint32_t node_id)
return 0;
}
+struct hns3_hw;
+
void hns3_tm_conf_init(struct rte_eth_dev *dev);
void hns3_tm_conf_uninit(struct rte_eth_dev *dev);
int hns3_tm_ops_get(struct rte_eth_dev *dev __rte_unused, void *arg);
--
2.23.0

View File

@ -0,0 +1,67 @@
From b099debb4a0b3d33ef2c8f5defbaba29c775657b Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:31 +0800
Subject: [PATCH 155/189] net/hns3: remove unused structures
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_cmd.h | 19 -------------------
drivers/net/hns3/hns3_rss.h | 4 ----
2 files changed, 23 deletions(-)
diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h
index bee96c1e46..902638ba99 100644
--- a/drivers/net/hns3/hns3_cmd.h
+++ b/drivers/net/hns3/hns3_cmd.h
@@ -59,11 +59,6 @@ enum hns3_cmd_return_status {
HNS3_CMD_ROH_CHECK_FAIL = 12
};
-struct hns3_misc_vector {
- uint8_t *addr;
- int vector_irq;
-};
-
struct hns3_cmq {
struct hns3_cmq_ring csq;
struct hns3_cmq_ring crq;
@@ -397,20 +392,6 @@ struct hns3_pkt_buf_alloc {
struct hns3_shared_buf s_buf;
};
-#define HNS3_RX_COM_WL_EN_B 15
-struct hns3_rx_com_wl_buf_cmd {
- uint16_t high_wl;
- uint16_t low_wl;
- uint8_t rsv[20];
-};
-
-#define HNS3_RX_PKT_EN_B 15
-struct hns3_rx_pkt_buf_cmd {
- uint16_t high_pkt;
- uint16_t low_pkt;
- uint8_t rsv[20];
-};
-
#define HNS3_PF_STATE_DONE_B 0
#define HNS3_PF_STATE_MAIN_B 1
#define HNS3_PF_STATE_BOND_B 2
diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h
index ebb51b4c66..0d24436cbe 100644
--- a/drivers/net/hns3/hns3_rss.h
+++ b/drivers/net/hns3/hns3_rss.h
@@ -34,10 +34,6 @@
#define HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP 2
#define HNS3_RSS_HASH_ALGO_MASK 0xf
-struct hns3_rss_tuple_cfg {
- uint64_t rss_tuple_fields;
-};
-
#define HNS3_RSS_QUEUES_BUFFER_NUM 64 /* Same as the Max rx/tx queue num */
struct hns3_rss_conf {
/* RSS parameters :algorithm, flow_types, key, queue */
--
2.23.0

View File

@ -0,0 +1,410 @@
From 73da6c3b6da30cc03c4a36f0d71d4ffd220f4026 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:32 +0800
Subject: [PATCH 156/189] net/hns3: rename header guards
Currently, the hns3 driver uses _HNS3_XXX conditional compilation
macros to prevent duplicate header files. But in the C11 standard, all
identifiers starting with an underscore plus an uppercase letter are
always reserved. So this patch fixes it.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_cmd.h | 6 +++---
drivers/net/hns3/hns3_common.h | 6 +++---
drivers/net/hns3/hns3_dcb.h | 6 +++---
drivers/net/hns3/hns3_dump.h | 6 +++---
drivers/net/hns3/hns3_ethdev.h | 6 +++---
drivers/net/hns3/hns3_fdir.h | 6 +++---
drivers/net/hns3/hns3_flow.h | 6 +++---
drivers/net/hns3/hns3_intr.h | 6 +++---
drivers/net/hns3/hns3_logs.h | 6 +++---
drivers/net/hns3/hns3_mbx.h | 6 +++---
drivers/net/hns3/hns3_mp.h | 6 +++---
drivers/net/hns3/hns3_regs.h | 6 +++---
drivers/net/hns3/hns3_rss.h | 6 +++---
drivers/net/hns3/hns3_rxtx.h | 6 +++---
drivers/net/hns3/hns3_rxtx_vec.h | 6 +++---
drivers/net/hns3/hns3_rxtx_vec_neon.h | 6 +++---
drivers/net/hns3/hns3_stats.h | 6 +++---
drivers/net/hns3/hns3_tm.h | 6 +++---
18 files changed, 54 insertions(+), 54 deletions(-)
diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h
index 902638ba99..8ac8b45819 100644
--- a/drivers/net/hns3/hns3_cmd.h
+++ b/drivers/net/hns3/hns3_cmd.h
@@ -2,8 +2,8 @@
* Copyright(c) 2018-2021 HiSilicon Limited.
*/
-#ifndef _HNS3_CMD_H_
-#define _HNS3_CMD_H_
+#ifndef HNS3_CMD_H
+#define HNS3_CMD_H
#include <stdint.h>
@@ -1038,4 +1038,4 @@ int hns3_cmd_init(struct hns3_hw *hw);
void hns3_cmd_destroy_queue(struct hns3_hw *hw);
void hns3_cmd_uninit(struct hns3_hw *hw);
-#endif /* _HNS3_CMD_H_ */
+#endif /* HNS3_CMD_H */
diff --git a/drivers/net/hns3/hns3_common.h b/drivers/net/hns3/hns3_common.h
index 2994e4a269..5aa001f0cc 100644
--- a/drivers/net/hns3/hns3_common.h
+++ b/drivers/net/hns3/hns3_common.h
@@ -2,8 +2,8 @@
* Copyright(C) 2021 HiSilicon Limited
*/
-#ifndef _HNS3_COMMON_H_
-#define _HNS3_COMMON_H_
+#ifndef HNS3_COMMON_H
+#define HNS3_COMMON_H
#include <sys/time.h>
@@ -61,4 +61,4 @@ int hns3_restore_rx_interrupt(struct hns3_hw *hw);
int hns3_get_pci_revision_id(struct hns3_hw *hw, uint8_t *revision_id);
-#endif /* _HNS3_COMMON_H_ */
+#endif /* HNS3_COMMON_H */
diff --git a/drivers/net/hns3/hns3_dcb.h b/drivers/net/hns3/hns3_dcb.h
index 9d9e7684c1..d5bb5edf4d 100644
--- a/drivers/net/hns3/hns3_dcb.h
+++ b/drivers/net/hns3/hns3_dcb.h
@@ -2,8 +2,8 @@
* Copyright(c) 2018-2021 HiSilicon Limited.
*/
-#ifndef _HNS3_DCB_H_
-#define _HNS3_DCB_H_
+#ifndef HNS3_DCB_H
+#define HNS3_DCB_H
#include <stdint.h>
@@ -215,4 +215,4 @@ int hns3_update_queue_map_configure(struct hns3_adapter *hns);
int hns3_port_shaper_update(struct hns3_hw *hw, uint32_t speed);
uint8_t hns3_txq_mapped_tc_get(struct hns3_hw *hw, uint16_t txq_no);
-#endif /* _HNS3_DCB_H_ */
+#endif /* HNS3_DCB_H */
diff --git a/drivers/net/hns3/hns3_dump.h b/drivers/net/hns3/hns3_dump.h
index 8ba7ee866a..616cb70d6e 100644
--- a/drivers/net/hns3/hns3_dump.h
+++ b/drivers/net/hns3/hns3_dump.h
@@ -2,9 +2,9 @@
* Copyright(C) 2022 HiSilicon Limited
*/
-#ifndef _HNS3_DUMP_H_
-#define _HNS3_DUMP_H_
+#ifndef HNS3_DUMP_H
+#define HNS3_DUMP_H
int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file);
-#endif /* _HNS3_DUMP_H_ */
+#endif /* HNS3_DUMP_H */
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index aad779e949..40476bf882 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -2,8 +2,8 @@
* Copyright(c) 2018-2021 HiSilicon Limited.
*/
-#ifndef _HNS3_ETHDEV_H_
-#define _HNS3_ETHDEV_H_
+#ifndef HNS3_ETHDEV_H
+#define HNS3_ETHDEV_H
#include <pthread.h>
#include <ethdev_driver.h>
@@ -1074,4 +1074,4 @@ is_reset_pending(struct hns3_adapter *hns)
return ret;
}
-#endif /* _HNS3_ETHDEV_H_ */
+#endif /* HNS3_ETHDEV_H */
diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h
index 7be1c0a248..de2422e12f 100644
--- a/drivers/net/hns3/hns3_fdir.h
+++ b/drivers/net/hns3/hns3_fdir.h
@@ -2,8 +2,8 @@
* Copyright(c) 2018-2021 HiSilicon Limited.
*/
-#ifndef _HNS3_FDIR_H_
-#define _HNS3_FDIR_H_
+#ifndef HNS3_FDIR_H
+#define HNS3_FDIR_H
#include <stdint.h>
@@ -192,4 +192,4 @@ int hns3_clear_all_fdir_filter(struct hns3_adapter *hns);
int hns3_fd_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value);
int hns3_restore_all_fdir_filter(struct hns3_adapter *hns);
-#endif /* _HNS3_FDIR_H_ */
+#endif /* HNS3_FDIR_H */
diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h
index ec94510152..e4b2fdf2e6 100644
--- a/drivers/net/hns3/hns3_flow.h
+++ b/drivers/net/hns3/hns3_flow.h
@@ -2,8 +2,8 @@
* Copyright(C) 2021 HiSilicon Limited
*/
-#ifndef _HNS3_FLOW_H_
-#define _HNS3_FLOW_H_
+#ifndef HNS3_FLOW_H
+#define HNS3_FLOW_H
#include <rte_flow.h>
#include <ethdev_driver.h>
@@ -54,4 +54,4 @@ void hns3_flow_init(struct rte_eth_dev *dev);
void hns3_flow_uninit(struct rte_eth_dev *dev);
int hns3_restore_filter(struct hns3_adapter *hns);
-#endif /* _HNS3_FLOW_H_ */
+#endif /* HNS3_FLOW_H */
diff --git a/drivers/net/hns3/hns3_intr.h b/drivers/net/hns3/hns3_intr.h
index 1490a5e387..aca1c0722c 100644
--- a/drivers/net/hns3/hns3_intr.h
+++ b/drivers/net/hns3/hns3_intr.h
@@ -2,8 +2,8 @@
* Copyright(c) 2018-2021 HiSilicon Limited.
*/
-#ifndef _HNS3_INTR_H_
-#define _HNS3_INTR_H_
+#ifndef HNS3_INTR_H
+#define HNS3_INTR_H
#include <stdint.h>
@@ -190,4 +190,4 @@ void hns3_reset_abort(struct hns3_adapter *hns);
void hns3_start_report_lse(struct rte_eth_dev *dev);
void hns3_stop_report_lse(struct rte_eth_dev *dev);
-#endif /* _HNS3_INTR_H_ */
+#endif /* HNS3_INTR_H */
diff --git a/drivers/net/hns3/hns3_logs.h b/drivers/net/hns3/hns3_logs.h
index 072a53bd69..c880f752ab 100644
--- a/drivers/net/hns3/hns3_logs.h
+++ b/drivers/net/hns3/hns3_logs.h
@@ -2,8 +2,8 @@
* Copyright(c) 2018-2021 HiSilicon Limited.
*/
-#ifndef _HNS3_LOGS_H_
-#define _HNS3_LOGS_H_
+#ifndef HNS3_LOGS_H
+#define HNS3_LOGS_H
extern int hns3_logtype_init;
#define PMD_INIT_LOG(level, fmt, args...) \
@@ -31,4 +31,4 @@ extern int hns3_logtype_driver;
#define hns3_dbg(hw, fmt, args...) \
PMD_DRV_LOG_RAW(hw, RTE_LOG_DEBUG, fmt "\n", ## args)
-#endif /* _HNS3_LOGS_H_ */
+#endif /* HNS3_LOGS_H */
diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h
index b6ccd9ff8c..c71f43238c 100644
--- a/drivers/net/hns3/hns3_mbx.h
+++ b/drivers/net/hns3/hns3_mbx.h
@@ -2,8 +2,8 @@
* Copyright(c) 2018-2021 HiSilicon Limited.
*/
-#ifndef _HNS3_MBX_H_
-#define _HNS3_MBX_H_
+#ifndef HNS3_MBX_H
+#define HNS3_MBX_H
#include <stdint.h>
@@ -172,4 +172,4 @@ void hns3_dev_handle_mbx_msg(struct hns3_hw *hw);
int hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode,
const uint8_t *msg_data, uint8_t msg_len, bool need_resp,
uint8_t *resp_data, uint16_t resp_len);
-#endif /* _HNS3_MBX_H_ */
+#endif /* HNS3_MBX_H */
diff --git a/drivers/net/hns3/hns3_mp.h b/drivers/net/hns3/hns3_mp.h
index 230230bbfe..5dc32a41d4 100644
--- a/drivers/net/hns3/hns3_mp.h
+++ b/drivers/net/hns3/hns3_mp.h
@@ -2,8 +2,8 @@
* Copyright(c) 2018-2021 HiSilicon Limited.
*/
-#ifndef _HNS3_MP_H_
-#define _HNS3_MP_H_
+#ifndef HNS3_MP_H
+#define HNS3_MP_H
#include <ethdev_driver.h>
@@ -21,4 +21,4 @@ void hns3_mp_req_stop_tx(struct rte_eth_dev *dev);
int hns3_mp_init(struct rte_eth_dev *dev);
void hns3_mp_uninit(struct rte_eth_dev *dev);
-#endif /* _HNS3_MP_H_ */
+#endif /* HNS3_MP_H */
diff --git a/drivers/net/hns3/hns3_regs.h b/drivers/net/hns3/hns3_regs.h
index 2636429844..459bbaf773 100644
--- a/drivers/net/hns3/hns3_regs.h
+++ b/drivers/net/hns3/hns3_regs.h
@@ -2,8 +2,8 @@
* Copyright(c) 2018-2021 HiSilicon Limited.
*/
-#ifndef _HNS3_REGS_H_
-#define _HNS3_REGS_H_
+#ifndef HNS3_REGS_H
+#define HNS3_REGS_H
#include <ethdev_driver.h>
#include <rte_dev_info.h>
@@ -153,4 +153,4 @@
#define HNS3_RL_USEC_TO_REG(rl_usec) ((rl_usec) >> 2)
int hns3_get_regs(struct rte_eth_dev *eth_dev, struct rte_dev_reg_info *regs);
-#endif /* _HNS3_REGS_H_ */
+#endif /* HNS3_REGS_H */
diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h
index 0d24436cbe..5c288c8bb2 100644
--- a/drivers/net/hns3/hns3_rss.h
+++ b/drivers/net/hns3/hns3_rss.h
@@ -2,8 +2,8 @@
* Copyright(c) 2018-2021 HiSilicon Limited.
*/
-#ifndef _HNS3_RSS_H_
-#define _HNS3_RSS_H_
+#ifndef HNS3_RSS_H
+#define HNS3_RSS_H
#include <rte_ethdev.h>
#include <rte_flow.h>
@@ -109,4 +109,4 @@ void hns3_rss_uninit(struct hns3_adapter *hns);
int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf);
int hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key);
-#endif /* _HNS3_RSS_H_ */
+#endif /* HNS3_RSS_H */
diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h
index f619d6d466..ed40621b3a 100644
--- a/drivers/net/hns3/hns3_rxtx.h
+++ b/drivers/net/hns3/hns3_rxtx.h
@@ -2,8 +2,8 @@
* Copyright(c) 2018-2021 HiSilicon Limited.
*/
-#ifndef _HNS3_RXTX_H_
-#define _HNS3_RXTX_H_
+#ifndef HNS3_RXTX_H
+#define HNS3_RXTX_H
#include <stdint.h>
@@ -780,4 +780,4 @@ void hns3_tx_push_init(struct rte_eth_dev *dev);
void hns3_stop_tx_datapath(struct rte_eth_dev *dev);
void hns3_start_tx_datapath(struct rte_eth_dev *dev);
-#endif /* _HNS3_RXTX_H_ */
+#endif /* HNS3_RXTX_H */
diff --git a/drivers/net/hns3/hns3_rxtx_vec.h b/drivers/net/hns3/hns3_rxtx_vec.h
index d13f18627d..2c8a91921e 100644
--- a/drivers/net/hns3/hns3_rxtx_vec.h
+++ b/drivers/net/hns3/hns3_rxtx_vec.h
@@ -2,8 +2,8 @@
* Copyright(c) 2020-2021 HiSilicon Limited.
*/
-#ifndef _HNS3_RXTX_VEC_H_
-#define _HNS3_RXTX_VEC_H_
+#ifndef HNS3_RXTX_VEC_H
+#define HNS3_RXTX_VEC_H
#include "hns3_rxtx.h"
#include "hns3_ethdev.h"
@@ -94,4 +94,4 @@ hns3_rx_reassemble_pkts(struct rte_mbuf **rx_pkts,
return count;
}
-#endif /* _HNS3_RXTX_VEC_H_ */
+#endif /* HNS3_RXTX_VEC_H */
diff --git a/drivers/net/hns3/hns3_rxtx_vec_neon.h b/drivers/net/hns3/hns3_rxtx_vec_neon.h
index 0edd4756f1..55d9bf817d 100644
--- a/drivers/net/hns3/hns3_rxtx_vec_neon.h
+++ b/drivers/net/hns3/hns3_rxtx_vec_neon.h
@@ -2,8 +2,8 @@
* Copyright(c) 2020-2021 HiSilicon Limited.
*/
-#ifndef _HNS3_RXTX_VEC_NEON_H_
-#define _HNS3_RXTX_VEC_NEON_H_
+#ifndef HNS3_RXTX_VEC_NEON_H
+#define HNS3_RXTX_VEC_NEON_H
#include <arm_neon.h>
@@ -299,4 +299,4 @@ hns3_recv_burst_vec(struct hns3_rx_queue *__restrict rxq,
return nb_rx;
}
-#endif /* _HNS3_RXTX_VEC_NEON_H_ */
+#endif /* HNS3_RXTX_VEC_NEON_H */
diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h
index 9a360f8870..74bc4173cc 100644
--- a/drivers/net/hns3/hns3_stats.h
+++ b/drivers/net/hns3/hns3_stats.h
@@ -2,8 +2,8 @@
* Copyright(c) 2018-2021 HiSilicon Limited.
*/
-#ifndef _HNS3_STATS_H_
-#define _HNS3_STATS_H_
+#ifndef HNS3_STATS_H
+#define HNS3_STATS_H
#include <ethdev_driver.h>
#include <rte_ethdev.h>
@@ -172,4 +172,4 @@ void hns3_stats_uninit(struct hns3_hw *hw);
int hns3_query_mac_stats_reg_num(struct hns3_hw *hw);
void hns3_update_hw_stats(struct hns3_hw *hw);
-#endif /* _HNS3_STATS_H_ */
+#endif /* HNS3_STATS_H */
diff --git a/drivers/net/hns3/hns3_tm.h b/drivers/net/hns3/hns3_tm.h
index 47345eeed1..0cac1a5bb2 100644
--- a/drivers/net/hns3/hns3_tm.h
+++ b/drivers/net/hns3/hns3_tm.h
@@ -2,8 +2,8 @@
* Copyright(c) 2020-2021 HiSilicon Limited.
*/
-#ifndef _HNS3_TM_H_
-#define _HNS3_TM_H_
+#ifndef HNS3_TM_H
+#define HNS3_TM_H
#include <stdint.h>
#include <rte_tailq.h>
@@ -114,4 +114,4 @@ void hns3_tm_dev_start_proc(struct hns3_hw *hw);
void hns3_tm_dev_stop_proc(struct hns3_hw *hw);
int hns3_tm_conf_update(struct hns3_hw *hw);
-#endif /* _HNS3_TM_H */
+#endif /* HNS3_TM_H */
--
2.23.0

View File

@ -0,0 +1,87 @@
From e11bff8abbbe9cacc59fa64d3d2046b150c45a6d Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:33 +0800
Subject: [PATCH 157/189] net/hns3: fix IPv4 and IPv6 RSS
Currently, hns3 driver use 'ipv4-other' and 'ipv6-other' as the flag
of IP packets to judge if enable RSS tuple field. But user may use
'RTE_ETH_RSS_IPV4' or 'RTE_ETH_RSS_IPV6' as the flag. So this patch
adds the processing of these macros.
Fixes: 806f1d5ab0e3 ("net/hns3: set RSS hash type input configuration")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_rss.c | 14 ++++++++++++++
drivers/net/hns3/hns3_rss.h | 2 ++
2 files changed, 16 insertions(+)
diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index fc912ed2e8..e7e114727f 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -102,6 +102,10 @@ static const struct {
BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_L4_DST_ONLY,
BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_D) },
+ { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_SRC_ONLY,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) },
+ { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_DST_ONLY,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) },
{ RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_SRC_ONLY,
BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_DST_ONLY,
@@ -134,6 +138,10 @@ static const struct {
BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L4_DST_ONLY,
BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_D) },
+ { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_SRC_ONLY,
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) },
+ { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_DST_ONLY,
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) },
{ RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_SRC_ONLY,
BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_DST_ONLY,
@@ -159,6 +167,9 @@ static const struct {
BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_S) |
BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_D) |
BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_VER) },
+ { RTE_ETH_RSS_IPV4,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) },
{ RTE_ETH_RSS_NONFRAG_IPV4_OTHER,
BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) |
BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) },
@@ -177,6 +188,9 @@ static const struct {
BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_D) |
BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_S) |
BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER) },
+ { RTE_ETH_RSS_IPV6,
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) },
{ RTE_ETH_RSS_NONFRAG_IPV6_OTHER,
BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) |
BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }
diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h
index 5c288c8bb2..9471e7039d 100644
--- a/drivers/net/hns3/hns3_rss.h
+++ b/drivers/net/hns3/hns3_rss.h
@@ -9,11 +9,13 @@
#include <rte_flow.h>
#define HNS3_ETH_RSS_SUPPORT ( \
+ RTE_ETH_RSS_IPV4 | \
RTE_ETH_RSS_FRAG_IPV4 | \
RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
+ RTE_ETH_RSS_IPV6 | \
RTE_ETH_RSS_FRAG_IPV6 | \
RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
--
2.23.0

View File

@ -0,0 +1,57 @@
From 3907f30765bd5ca0d973c0b828de210b3d87713a Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:34 +0800
Subject: [PATCH 158/189] net/hns3: fix types in IPv6 SCTP fields
Fix spelling errors about IPV6-SCTP macro.
Fixes: 1bc633c34008 ("net/hns3: enable RSS for IPv6-SCTP dst/src port fields")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_rss.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index e7e114727f..6d71ee94a9 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -57,8 +57,8 @@ enum hns3_tuple_field {
HNS3_RSS_FIELD_IPV6_UDP_EN_IP_S,
/* IPV6_SCTP ENABLE FIELD */
- HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_D = 48,
- HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_S,
+ HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D = 48,
+ HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S,
HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D,
HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S,
HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER,
@@ -135,9 +135,9 @@ static const struct {
{ RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L3_DST_ONLY,
BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D) },
{ RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L4_SRC_ONLY,
- BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_S) },
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L4_DST_ONLY,
- BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_D) },
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) },
{ RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_SRC_ONLY,
BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) },
{ RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_DST_ONLY,
@@ -185,8 +185,8 @@ static const struct {
BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_D) },
{ RTE_ETH_RSS_NONFRAG_IPV6_SCTP, BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S) |
BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D) |
- BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_D) |
- BIT_ULL(HNS3_RSS_FILED_IPV6_SCTP_EN_SCTP_S) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S) |
BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER) },
{ RTE_ETH_RSS_IPV6,
BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) |
--
2.23.0

View File

@ -0,0 +1,380 @@
From c300374b7ef19f05acaa6501093610fbe25bc187 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:35 +0800
Subject: [PATCH 159/189] net/hns3: fix IPv4 RSS
When user only use 'ipv4' to set 'rss_hf', hns3 will enable
all tuple fields for 'ipv4' flow. But if user use 'ipv4-tcp'
, 'ipv4' and 'l4-src-only' to set 'rss_hf', driver does not
enable all tuple fields for 'ipv4' flow.
Fixes: 806f1d5ab0e3 ("net/hns3: set RSS hash type input configuration")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_rss.c | 266 ++++++++++++++++++++++++------------
1 file changed, 176 insertions(+), 90 deletions(-)
diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 6d71ee94a9..ea745c791f 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -70,130 +70,209 @@ enum hns3_tuple_field {
HNS3_RSS_FIELD_IPV6_FRAG_IP_S
};
+enum hns3_rss_tuple_type {
+ HNS3_RSS_IP_TUPLE,
+ HNS3_RSS_IP_L4_TUPLE,
+};
+
static const struct {
uint64_t rss_types;
+ uint16_t tuple_type;
uint64_t rss_field;
} hns3_set_tuple_table[] = {
+ /* IPV4-FRAG */
{ RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_L3_SRC_ONLY,
+ HNS3_RSS_IP_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S) },
{ RTE_ETH_RSS_FRAG_IPV4 | RTE_ETH_RSS_L3_DST_ONLY,
+ HNS3_RSS_IP_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D) },
+ { RTE_ETH_RSS_FRAG_IPV4,
+ HNS3_RSS_IP_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S) |
BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D) },
+
+ /* IPV4 */
+ { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_SRC_ONLY,
+ HNS3_RSS_IP_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) },
+ { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_DST_ONLY,
+ HNS3_RSS_IP_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) },
+ { RTE_ETH_RSS_IPV4,
+ HNS3_RSS_IP_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) },
+
+ /* IPV4-OTHER */
+ { RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_SRC_ONLY,
+ HNS3_RSS_IP_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) },
+ { RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_DST_ONLY,
+ HNS3_RSS_IP_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) },
+ { RTE_ETH_RSS_NONFRAG_IPV4_OTHER,
+ HNS3_RSS_IP_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) },
+
+ /* IPV4-TCP */
{ RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L3_SRC_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L3_DST_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_D) },
{ RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L4_SRC_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L4_DST_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_D) },
+ { RTE_ETH_RSS_NONFRAG_IPV4_TCP,
+ HNS3_RSS_IP_L4_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_S) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_D) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_S) |
BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_D) },
+
+ /* IPV4-UDP */
{ RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_L3_SRC_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_L3_DST_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_D) },
{ RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_L4_SRC_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_L4_DST_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_D) },
+ { RTE_ETH_RSS_NONFRAG_IPV4_UDP,
+ HNS3_RSS_IP_L4_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_S) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_D) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_S) |
BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_D) },
+
+ /* IPV4-SCTP */
{ RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_L3_SRC_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_L3_DST_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_D) },
{ RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_L4_SRC_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_L4_DST_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_D) },
- { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_SRC_ONLY,
- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) },
- { RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_L3_DST_ONLY,
- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) },
- { RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_SRC_ONLY,
- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) },
- { RTE_ETH_RSS_NONFRAG_IPV4_OTHER | RTE_ETH_RSS_L3_DST_ONLY,
- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) },
+ { RTE_ETH_RSS_NONFRAG_IPV4_SCTP,
+ HNS3_RSS_IP_L4_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_S) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_D) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_S) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_D) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_VER) },
+
+ /* IPV6-FRAG */
{ RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_L3_SRC_ONLY,
+ HNS3_RSS_IP_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_S) },
{ RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_L3_DST_ONLY,
+ HNS3_RSS_IP_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_D) },
+ { RTE_ETH_RSS_FRAG_IPV6,
+ HNS3_RSS_IP_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_S) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_D) },
+
+ /* IPV6 */
+ { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_SRC_ONLY,
+ HNS3_RSS_IP_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) },
+ { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_DST_ONLY,
+ HNS3_RSS_IP_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) },
+ { RTE_ETH_RSS_IPV6,
+ HNS3_RSS_IP_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) },
+
+ /* IPV6-OTHER */
+ { RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_SRC_ONLY,
+ HNS3_RSS_IP_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) },
+ { RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_DST_ONLY,
+ HNS3_RSS_IP_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) },
+ { RTE_ETH_RSS_NONFRAG_IPV6_OTHER,
+ HNS3_RSS_IP_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) },
+
+ /* IPV6-TCP */
{ RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L3_SRC_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L3_DST_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_D) },
{ RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L4_SRC_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_L4_DST_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_D) },
+ { RTE_ETH_RSS_NONFRAG_IPV6_TCP,
+ HNS3_RSS_IP_L4_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_S) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_D) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_S) |
BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_D) },
+
+ /* IPV6-UDP */
{ RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_L3_SRC_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_L3_DST_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_D) },
{ RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_L4_SRC_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_L4_DST_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_D) },
+ { RTE_ETH_RSS_NONFRAG_IPV6_UDP,
+ HNS3_RSS_IP_L4_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_S) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_D) |
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_S) |
BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_D) },
+
+ /* IPV6-SCTP */
{ RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L3_SRC_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L3_DST_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D) },
{ RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L4_SRC_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S) },
{ RTE_ETH_RSS_NONFRAG_IPV6_SCTP | RTE_ETH_RSS_L4_DST_ONLY,
+ HNS3_RSS_IP_L4_TUPLE,
BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) },
- { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_SRC_ONLY,
- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) },
- { RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_L3_DST_ONLY,
- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) },
- { RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_SRC_ONLY,
- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) },
- { RTE_ETH_RSS_NONFRAG_IPV6_OTHER | RTE_ETH_RSS_L3_DST_ONLY,
- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) },
-};
-
-static const struct {
- uint64_t rss_types;
- uint64_t rss_field;
-} hns3_set_rss_types[] = {
- { RTE_ETH_RSS_FRAG_IPV4, BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_D) |
- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_FRAG_IP_S) },
- { RTE_ETH_RSS_NONFRAG_IPV4_TCP, BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_S) |
- BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_IP_D) |
- BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_S) |
- BIT_ULL(HNS3_RSS_FIELD_IPV4_TCP_EN_TCP_D) },
- { RTE_ETH_RSS_NONFRAG_IPV4_UDP, BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_S) |
- BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_IP_D) |
- BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_S) |
- BIT_ULL(HNS3_RSS_FIELD_IPV4_UDP_EN_UDP_D) },
- { RTE_ETH_RSS_NONFRAG_IPV4_SCTP, BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_S) |
- BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_IP_D) |
- BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_S) |
- BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_D) |
- BIT_ULL(HNS3_RSS_FIELD_IPV4_SCTP_EN_SCTP_VER) },
- { RTE_ETH_RSS_IPV4,
- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) |
- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) },
- { RTE_ETH_RSS_NONFRAG_IPV4_OTHER,
- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_S) |
- BIT_ULL(HNS3_RSS_FIELD_IPV4_EN_NONFRAG_IP_D) },
- { RTE_ETH_RSS_FRAG_IPV6, BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_S) |
- BIT_ULL(HNS3_RSS_FIELD_IPV6_FRAG_IP_D) },
- { RTE_ETH_RSS_NONFRAG_IPV6_TCP, BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_S) |
- BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_IP_D) |
- BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_S) |
- BIT_ULL(HNS3_RSS_FIELD_IPV6_TCP_EN_TCP_D) },
- { RTE_ETH_RSS_NONFRAG_IPV6_UDP, BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_S) |
- BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_IP_D) |
- BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_S) |
- BIT_ULL(HNS3_RSS_FIELD_IPV6_UDP_EN_UDP_D) },
- { RTE_ETH_RSS_NONFRAG_IPV6_SCTP, BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S) |
+ { RTE_ETH_RSS_NONFRAG_IPV6_SCTP,
+ HNS3_RSS_IP_L4_TUPLE,
+ BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_S) |
BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_IP_D) |
BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_D) |
BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_S) |
BIT_ULL(HNS3_RSS_FIELD_IPV6_SCTP_EN_SCTP_VER) },
- { RTE_ETH_RSS_IPV6,
- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) |
- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) },
- { RTE_ETH_RSS_NONFRAG_IPV6_OTHER,
- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_S) |
- BIT_ULL(HNS3_RSS_FIELD_IPV6_NONFRAG_IP_D) }
};
/*
@@ -321,46 +400,53 @@ hns3_rss_reset_indir_table(struct hns3_hw *hw)
return ret;
}
+static uint64_t
+hns3_rss_calc_tuple_filed(uint64_t rss_hf)
+{
+ uint64_t l3_only_mask = RTE_ETH_RSS_L3_SRC_ONLY |
+ RTE_ETH_RSS_L3_DST_ONLY;
+ uint64_t l4_only_mask = RTE_ETH_RSS_L4_SRC_ONLY |
+ RTE_ETH_RSS_L4_DST_ONLY;
+ uint64_t l3_l4_only_mask = l3_only_mask | l4_only_mask;
+ bool has_l3_l4_only = !!(rss_hf & l3_l4_only_mask);
+ bool has_l3_only = !!(rss_hf & l3_only_mask);
+ uint64_t tuple = 0;
+ uint32_t i;
+
+ for (i = 0; i < RTE_DIM(hns3_set_tuple_table); i++) {
+ if ((rss_hf & hns3_set_tuple_table[i].rss_types) !=
+ hns3_set_tuple_table[i].rss_types)
+ continue;
+
+ if (hns3_set_tuple_table[i].tuple_type == HNS3_RSS_IP_TUPLE) {
+ if (hns3_set_tuple_table[i].rss_types & l3_only_mask ||
+ !has_l3_only)
+ tuple |= hns3_set_tuple_table[i].rss_field;
+ continue;
+ }
+
+ /* For IP types with L4, we need check both L3 and L4 */
+ if (hns3_set_tuple_table[i].rss_types & l3_l4_only_mask ||
+ !has_l3_l4_only)
+ tuple |= hns3_set_tuple_table[i].rss_field;
+ }
+
+ return tuple;
+}
+
int
hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf)
{
struct hns3_rss_input_tuple_cmd *req;
struct hns3_cmd_desc desc;
- uint32_t fields_count = 0; /* count times for setting tuple fields */
- uint32_t i;
+ uint64_t tuple_field;
int ret;
hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_INPUT_TUPLE, false);
-
req = (struct hns3_rss_input_tuple_cmd *)desc.data;
- for (i = 0; i < RTE_DIM(hns3_set_tuple_table); i++) {
- if ((rss_hf & hns3_set_tuple_table[i].rss_types) ==
- hns3_set_tuple_table[i].rss_types) {
- req->tuple_field |=
- rte_cpu_to_le_64(hns3_set_tuple_table[i].rss_field);
- fields_count++;
- }
- }
-
- /*
- * When user does not specify the following types or a combination of
- * the following types, it enables all fields for the supported RSS
- * types. the following types as:
- * - RTE_ETH_RSS_L3_SRC_ONLY
- * - RTE_ETH_RSS_L3_DST_ONLY
- * - RTE_ETH_RSS_L4_SRC_ONLY
- * - RTE_ETH_RSS_L4_DST_ONLY
- */
- if (fields_count == 0) {
- for (i = 0; i < RTE_DIM(hns3_set_rss_types); i++) {
- if ((rss_hf & hns3_set_rss_types[i].rss_types) ==
- hns3_set_rss_types[i].rss_types)
- req->tuple_field |= rte_cpu_to_le_64(
- hns3_set_rss_types[i].rss_field);
- }
- }
-
+ tuple_field = hns3_rss_calc_tuple_filed(rss_hf);
+ req->tuple_field = rte_cpu_to_le_64(tuple_field);
ret = hns3_cmd_send(hw, &desc, 1);
if (ret) {
hns3_err(hw, "Update RSS flow types tuples failed %d", ret);
--
2.23.0

View File

@ -0,0 +1,77 @@
From 3406502c1af41be568561d74b39417dd2a3a771a Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:36 +0800
Subject: [PATCH 160/189] net/hns3: add check for L3 and L4 type
When user set 'L3_SRC/DST_ONLY' or 'L4_SRC/DST_ONLY' to 'rss_hf' and
do not specify the packet type, these types will be not set to hardware.
So this patch adds a check for them.
Fixes: 806f1d5ab0e3 ("net/hns3: set RSS hash type input configuration")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
drivers/net/hns3/hns3_rss.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index ea745c791f..ca5a129234 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -400,8 +400,34 @@ hns3_rss_reset_indir_table(struct hns3_hw *hw)
return ret;
}
+static void
+hns3_rss_check_l3l4_types(struct hns3_hw *hw, uint64_t rss_hf)
+{
+ uint64_t ip_mask = RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_FRAG_IPV4 |
+ RTE_ETH_RSS_NONFRAG_IPV4_OTHER |
+ RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_FRAG_IPV6 |
+ RTE_ETH_RSS_NONFRAG_IPV6_OTHER;
+ uint64_t l4_mask = RTE_ETH_RSS_NONFRAG_IPV4_TCP |
+ RTE_ETH_RSS_NONFRAG_IPV4_UDP |
+ RTE_ETH_RSS_NONFRAG_IPV4_SCTP |
+ RTE_ETH_RSS_NONFRAG_IPV6_TCP |
+ RTE_ETH_RSS_NONFRAG_IPV6_UDP |
+ RTE_ETH_RSS_NONFRAG_IPV6_SCTP;
+ uint64_t l3_src_dst_mask = RTE_ETH_RSS_L3_SRC_ONLY |
+ RTE_ETH_RSS_L3_DST_ONLY;
+ uint64_t l4_src_dst_mask = RTE_ETH_RSS_L4_SRC_ONLY |
+ RTE_ETH_RSS_L4_DST_ONLY;
+
+ if (rss_hf & l3_src_dst_mask &&
+ !(rss_hf & ip_mask || rss_hf & l4_mask))
+ hns3_warn(hw, "packet type isn't specified, L3_SRC/DST_ONLY is ignored.");
+
+ if (rss_hf & l4_src_dst_mask && !(rss_hf & l4_mask))
+ hns3_warn(hw, "packet type isn't specified, L4_SRC/DST_ONLY is ignored.");
+}
+
static uint64_t
-hns3_rss_calc_tuple_filed(uint64_t rss_hf)
+hns3_rss_calc_tuple_filed(struct hns3_hw *hw, uint64_t rss_hf)
{
uint64_t l3_only_mask = RTE_ETH_RSS_L3_SRC_ONLY |
RTE_ETH_RSS_L3_DST_ONLY;
@@ -430,6 +456,7 @@ hns3_rss_calc_tuple_filed(uint64_t rss_hf)
!has_l3_l4_only)
tuple |= hns3_set_tuple_table[i].rss_field;
}
+ hns3_rss_check_l3l4_types(hw, rss_hf);
return tuple;
}
@@ -445,7 +472,7 @@ hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf)
hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_INPUT_TUPLE, false);
req = (struct hns3_rss_input_tuple_cmd *)desc.data;
- tuple_field = hns3_rss_calc_tuple_filed(rss_hf);
+ tuple_field = hns3_rss_calc_tuple_filed(hw, rss_hf);
req->tuple_field = rte_cpu_to_le_64(tuple_field);
ret = hns3_cmd_send(hw, &desc, 1);
if (ret) {
--
2.23.0

View File

@ -0,0 +1,58 @@
From e438ad9ab2897ec33b94ee5f31bd1b2fbfc4e36e Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:37 +0800
Subject: [PATCH 161/189] net/hns3: revert fix mailbox communication with HW
VF's command receive queue was mainly used to receive mailbox messages
from PF. There are two type mailbox messages: request response message
and message pushed by PF.
There are two types of threads that can handle these messages:
1) the interrupt thread of the main process: it could handle both types
of messages.
2) other threads: it could only handle request response messages.
The collaboration mechanism between the two type threads is that other
threads set the opcode of processed messages to zero so that the
interrupt thread of the main process does not process these messages
again. Because other threads can only process part of the messages,
after the processing is complete, the next-to-use pointer of the
command receive queue should not be updated. Otherwise, some messages
(e.g. messages pushed by PF) maybe discarded.
Unfortunately, the patch to be reverted updates next-to-use pointer of
the command receive queue in other threads context, and this will lead
to discard some mailbox message.
So this commit reverts
commit 599ef84add7e ("net/hns3: fix mailbox communication with HW")
Fixes: 599ef84add7e ("net/hns3: fix mailbox communication with HW")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_mbx.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c
index b3563d4694..2de55a6417 100644
--- a/drivers/net/hns3/hns3_mbx.c
+++ b/drivers/net/hns3/hns3_mbx.c
@@ -436,8 +436,10 @@ hns3_handle_mbx_msg_out_intr(struct hns3_hw *hw)
next_to_use = (next_to_use + 1) % hw->cmq.crq.desc_num;
}
- crq->next_to_use = next_to_use;
- hns3_write_dev(hw, HNS3_CMDQ_RX_HEAD_REG, crq->next_to_use);
+ /*
+ * Note: the crq->next_to_use field should not updated, otherwise,
+ * mailbox messages may be discarded.
+ */
}
void
--
2.23.0

View File

@ -0,0 +1,48 @@
From 33814ad89cd618df8c596f7b138150cd4b71a8c3 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:38 +0800
Subject: [PATCH 162/189] net/hns3: fix VF mailbox message handling
VF's command receive queue was mainly used to receive mailbox messages
from PF. There are two type mailbox messages: request response message
and message pushed by PF.
There are two types of threads that can handle these messages:
1) the interrupt thread of the main process: it could handle both types
of messages.
2) other threads: it could only handle request response messages.
The collaboration mechanism between the two type threads is that other
threads set the opcode of processed messages to zero so that the
interrupt thread of the main process does not process these messages
again.
Unfortunately, the other threads mark the message pointed to by the
crq->next-to-use variable which is fixed in the loop, not the message
pointed to by the next-to-use variable.
Fixes: dbbbad23e380 ("net/hns3: fix VF handling LSC event in secondary process")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_mbx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c
index 2de55a6417..9a05f0d1ee 100644
--- a/drivers/net/hns3/hns3_mbx.c
+++ b/drivers/net/hns3/hns3_mbx.c
@@ -429,7 +429,7 @@ hns3_handle_mbx_msg_out_intr(struct hns3_hw *hw)
* Clear opcode to inform intr thread don't process
* again.
*/
- crq->desc[crq->next_to_use].opcode = 0;
+ crq->desc[next_to_use].opcode = 0;
}
scan_next:
--
2.23.0

View File

@ -0,0 +1,123 @@
From ac646ee28e8c9780d02ec685b7581486c13f6961 Mon Sep 17 00:00:00 2001
From: Jie Hai <haijie1@huawei.com>
Date: Fri, 21 Oct 2022 15:36:39 +0800
Subject: [PATCH 163/189] net/hns3: fix minimum Tx frame length
When packet length in Tx is less than length hardware supported,
the minimum frame length in hns3 is used to do padding to avoid
hardware error. Currently, this length is fixed by macro, which
is very unfavorable for subsequent hardware evolution. So fix it
as firmware report.
Fixes: 395b5e08ef8d ("net/hns3: add Tx short frame padding compatibility")
Cc: stable@dpdk.org
Signed-off-by: Jie Hai <haijie1@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_cmd.h | 6 ++++++
drivers/net/hns3/hns3_ethdev.c | 4 +++-
drivers/net/hns3/hns3_ethdev.h | 3 +--
drivers/net/hns3/hns3_ethdev_vf.c | 4 +++-
4 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h
index 8ac8b45819..994dfc48cc 100644
--- a/drivers/net/hns3/hns3_cmd.h
+++ b/drivers/net/hns3/hns3_cmd.h
@@ -967,6 +967,12 @@ struct hns3_dev_specs_0_cmd {
uint32_t max_tm_rate;
};
+struct hns3_dev_specs_1_cmd {
+ uint8_t rsv0[12];
+ uint8_t min_tx_pkt_len;
+ uint8_t rsv1[11];
+};
+
struct hns3_query_rpu_cmd {
uint32_t tc_queue_num;
uint32_t rsv1[2];
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 7b0e8fc77d..7330515535 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -2661,14 +2661,17 @@ static void
hns3_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc)
{
struct hns3_dev_specs_0_cmd *req0;
+ struct hns3_dev_specs_1_cmd *req1;
req0 = (struct hns3_dev_specs_0_cmd *)desc[0].data;
+ req1 = (struct hns3_dev_specs_1_cmd *)desc[1].data;
hw->max_non_tso_bd_num = req0->max_non_tso_bd_num;
hw->rss_ind_tbl_size = rte_le_to_cpu_16(req0->rss_ind_tbl_size);
hw->rss_key_size = rte_le_to_cpu_16(req0->rss_key_size);
hw->max_tm_rate = rte_le_to_cpu_32(req0->max_tm_rate);
hw->intr.int_ql_max = rte_le_to_cpu_16(req0->intr_ql_max);
+ hw->min_tx_pkt_len = req1->min_tx_pkt_len;
}
static int
@@ -2763,7 +2766,6 @@ hns3_get_capability(struct hns3_hw *hw)
hw->tso_mode = HNS3_TSO_HW_CAL_PSEUDO_H_CSUM;
hw->vlan_mode = HNS3_HW_SHIFT_AND_DISCARD_MODE;
hw->drop_stats_mode = HNS3_PKTS_DROP_STATS_MODE2;
- hw->min_tx_pkt_len = HNS3_HIP09_MIN_TX_PKT_LEN;
pf->tqp_config_mode = HNS3_FLEX_MAX_TQP_NUM_MODE;
hw->rss_info.ipv6_sctp_offload_supported = true;
hw->udp_cksum_mode = HNS3_SPECIAL_PORT_HW_CKSUM_MODE;
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index 40476bf882..4406611fe9 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -75,7 +75,6 @@
#define HNS3_DEFAULT_MTU 1500UL
#define HNS3_DEFAULT_FRAME_LEN (HNS3_DEFAULT_MTU + HNS3_ETH_OVERHEAD)
#define HNS3_HIP08_MIN_TX_PKT_LEN 33
-#define HNS3_HIP09_MIN_TX_PKT_LEN 9
#define HNS3_BITS_PER_BYTE 8
@@ -550,7 +549,7 @@ struct hns3_hw {
* The minimum length of the packet supported by hardware in the Tx
* direction.
*/
- uint32_t min_tx_pkt_len;
+ uint8_t min_tx_pkt_len;
struct hns3_queue_intr intr;
/*
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 72d60191ab..6976a9f23d 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -701,13 +701,16 @@ static void
hns3vf_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc)
{
struct hns3_dev_specs_0_cmd *req0;
+ struct hns3_dev_specs_1_cmd *req1;
req0 = (struct hns3_dev_specs_0_cmd *)desc[0].data;
+ req1 = (struct hns3_dev_specs_1_cmd *)desc[1].data;
hw->max_non_tso_bd_num = req0->max_non_tso_bd_num;
hw->rss_ind_tbl_size = rte_le_to_cpu_16(req0->rss_ind_tbl_size);
hw->rss_key_size = rte_le_to_cpu_16(req0->rss_key_size);
hw->intr.int_ql_max = rte_le_to_cpu_16(req0->intr_ql_max);
+ hw->min_tx_pkt_len = req1->min_tx_pkt_len;
}
static int
@@ -846,7 +849,6 @@ hns3vf_get_capability(struct hns3_hw *hw)
hw->intr.gl_unit = HNS3_INTR_COALESCE_GL_UINT_1US;
hw->tso_mode = HNS3_TSO_HW_CAL_PSEUDO_H_CSUM;
hw->drop_stats_mode = HNS3_PKTS_DROP_STATS_MODE2;
- hw->min_tx_pkt_len = HNS3_HIP09_MIN_TX_PKT_LEN;
hw->rss_info.ipv6_sctp_offload_supported = true;
hw->promisc_mode = HNS3_LIMIT_PROMISC_MODE;
--
2.23.0

View File

@ -0,0 +1,238 @@
From e4f2f2e047f123e5aff0a9a5699bf2d4ece4ebb8 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Fri, 21 Oct 2022 15:36:40 +0800
Subject: [PATCH 164/189] ethdev: introduce Rx/Tx descriptor dump API
Added the ethdev Rx/Tx desc dump API which provides functions for query
descriptor from device. HW descriptor info differs in different NICs.
The information demonstrates I/O process which is important for debug.
As the information is different between NICs, the new API is introduced.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
lib/ethdev/ethdev_driver.h | 53 ++++++++++++++++++++++++++++++++++++
lib/ethdev/rte_ethdev.c | 52 +++++++++++++++++++++++++++++++++++
lib/ethdev/rte_ethdev.h | 55 ++++++++++++++++++++++++++++++++++++++
lib/ethdev/version.map | 4 +++
4 files changed, 164 insertions(+)
diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h
index e24ff7064c..41f67f2740 100644
--- a/lib/ethdev/ethdev_driver.h
+++ b/lib/ethdev/ethdev_driver.h
@@ -1010,6 +1010,54 @@ typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev,
*/
typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file);
+/**
+ * @internal
+ * Dump Rx descriptor info to a file.
+ *
+ * It is used for debugging, not a dataplane API.
+ *
+ * @param dev
+ * Port (ethdev) handle.
+ * @param queue_id
+ * A Rx queue identifier on this port.
+ * @param offset
+ * The offset of the descriptor starting from tail. (0 is the next
+ * packet to be received by the driver).
+ * @param num
+ * The number of the descriptors to dump.
+ * @param file
+ * A pointer to a file for output.
+ * @return
+ * Negative errno value on error, zero on success.
+ */
+typedef int (*eth_rx_descriptor_dump_t)(const struct rte_eth_dev *dev,
+ uint16_t queue_id, uint16_t offset,
+ uint16_t num, FILE *file);
+
+/**
+ * @internal
+ * Dump Tx descriptor info to a file.
+ *
+ * This API is used for debugging, not a dataplane API.
+ *
+ * @param dev
+ * Port (ethdev) handle.
+ * @param queue_id
+ * A Tx queue identifier on this port.
+ * @param offset
+ * The offset of the descriptor starting from tail. (0 is the place where
+ * the next packet will be send).
+ * @param num
+ * The number of the descriptors to dump.
+ * @param file
+ * A pointer to a file for output.
+ * @return
+ * Negative errno value on error, zero on success.
+ */
+typedef int (*eth_tx_descriptor_dump_t)(const struct rte_eth_dev *dev,
+ uint16_t queue_id, uint16_t offset,
+ uint16_t num, FILE *file);
+
/**
* @internal A structure containing the functions exported by an Ethernet driver.
*/
@@ -1209,6 +1257,11 @@ struct eth_dev_ops {
/** Dump private info from device */
eth_dev_priv_dump_t eth_dev_priv_dump;
+
+ /** Dump Rx descriptor info */
+ eth_rx_descriptor_dump_t eth_rx_descriptor_dump;
+ /** Dump Tx descriptor info */
+ eth_tx_descriptor_dump_t eth_tx_descriptor_dump;
};
/**
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 25c9f0c123..b95f501b51 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -6509,6 +6509,58 @@ rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)
return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, file));
}
+int
+rte_eth_rx_descriptor_dump(uint16_t port_id, uint16_t queue_id,
+ uint16_t offset, uint16_t num, FILE *file)
+{
+ struct rte_eth_dev *dev;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+ dev = &rte_eth_devices[port_id];
+
+ if (queue_id >= dev->data->nb_rx_queues) {
+ RTE_ETHDEV_LOG(ERR, "Invalid Rx queue_id=%u\n", queue_id);
+ return -EINVAL;
+ }
+
+ if (file == NULL) {
+ RTE_ETHDEV_LOG(ERR, "Invalid file (NULL)\n");
+ return -EINVAL;
+ }
+
+ if (*dev->dev_ops->eth_rx_descriptor_dump == NULL)
+ return -ENOTSUP;
+
+ return eth_err(port_id, (*dev->dev_ops->eth_rx_descriptor_dump)(dev,
+ queue_id, offset, num, file));
+}
+
+int
+rte_eth_tx_descriptor_dump(uint16_t port_id, uint16_t queue_id,
+ uint16_t offset, uint16_t num, FILE *file)
+{
+ struct rte_eth_dev *dev;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+ dev = &rte_eth_devices[port_id];
+
+ if (queue_id >= dev->data->nb_tx_queues) {
+ RTE_ETHDEV_LOG(ERR, "Invalid Tx queue_id=%u\n", queue_id);
+ return -EINVAL;
+ }
+
+ if (file == NULL) {
+ RTE_ETHDEV_LOG(ERR, "Invalid file (NULL)\n");
+ return -EINVAL;
+ }
+
+ if (*dev->dev_ops->eth_tx_descriptor_dump == NULL)
+ return -ENOTSUP;
+
+ return eth_err(port_id, (*dev->dev_ops->eth_tx_descriptor_dump)(dev,
+ queue_id, offset, num, file));
+}
+
RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
RTE_INIT(ethdev_init_telemetry)
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index 082166ed42..8c894e090d 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -5213,6 +5213,61 @@ int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);
__rte_experimental
int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Dump ethdev Rx descriptor info to a file.
+ *
+ * This API is used for debugging, not a dataplane API.
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ * @param queue_id
+ * A Rx queue identifier on this port.
+ * @param offset
+ * The offset of the descriptor starting from tail. (0 is the next
+ * packet to be received by the driver).
+ * @param num
+ * The number of the descriptors to dump.
+ * @param file
+ * A pointer to a file for output.
+ * @return
+ * - On success, zero.
+ * - On failure, a negative value.
+ */
+__rte_experimental
+int rte_eth_rx_descriptor_dump(uint16_t port_id, uint16_t queue_id,
+ uint16_t offset, uint16_t num, FILE *file);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Dump ethdev Tx descriptor info to a file.
+ *
+ * This API is used for debugging, not a dataplane API.
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ * @param queue_id
+ * A Tx queue identifier on this port.
+ * @param offset
+ * The offset of the descriptor starting from tail. (0 is the place where
+ * the next packet will be send).
+ * @param num
+ * The number of the descriptors to dump.
+ * @param file
+ * A pointer to a file for output.
+ * @return
+ * - On success, zero.
+ * - On failure, a negative value.
+ */
+__rte_experimental
+int rte_eth_tx_descriptor_dump(uint16_t port_id, uint16_t queue_id,
+ uint16_t offset, uint16_t num, FILE *file);
+
+
#include <rte_ethdev_core.h>
/**
diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map
index f29c60eda4..09dba86bee 100644
--- a/lib/ethdev/version.map
+++ b/lib/ethdev/version.map
@@ -259,6 +259,10 @@ EXPERIMENTAL {
# added in 22.03
rte_eth_dev_priv_dump;
+
+ # added in 22.11
+ rte_eth_rx_descriptor_dump;
+ rte_eth_tx_descriptor_dump;
};
INTERNAL {
--
2.23.0

View File

@ -0,0 +1,164 @@
From 450591abedaabee32a21d53a50cb5b65440ce971 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Fri, 21 Oct 2022 15:36:41 +0800
Subject: [PATCH 165/189] net/hns3: support Rx/Tx descriptor dump
This patch support query HW descriptor from hns3 device. HW descriptor
is also called BD (buffer description) which is shared memory between
software and hardware.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
Acked-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
drivers/net/hns3/hns3_dump.c | 88 +++++++++++++++++++++++++++++++
drivers/net/hns3/hns3_dump.h | 4 ++
drivers/net/hns3/hns3_ethdev.c | 2 +
drivers/net/hns3/hns3_ethdev_vf.c | 2 +
4 files changed, 96 insertions(+)
diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c
index cf5b500be1..1007b09bd2 100644
--- a/drivers/net/hns3/hns3_dump.c
+++ b/drivers/net/hns3/hns3_dump.c
@@ -11,6 +11,9 @@
#include "hns3_logs.h"
#include "hns3_dump.h"
+#define HNS3_BD_DW_NUM 8
+#define HNS3_BD_ADDRESS_LAST_DW 2
+
static const char *
hns3_get_adapter_state_name(enum hns3_adapter_state state)
{
@@ -873,3 +876,88 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
return 0;
}
+
+int
+hns3_rx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id,
+ uint16_t offset, uint16_t num, FILE *file)
+{
+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct hns3_rx_queue *rxq = dev->data->rx_queues[queue_id];
+ uint32_t *bd_data;
+ uint16_t count = 0;
+ uint16_t desc_id;
+ int i;
+
+ if (offset >= rxq->nb_rx_desc)
+ return -EINVAL;
+
+ if (num > rxq->nb_rx_desc) {
+ hns3_err(hw, "Invalid BD num=%u\n", num);
+ return -EINVAL;
+ }
+
+ while (count < num) {
+ desc_id = (rxq->next_to_use + offset + count) % rxq->nb_rx_desc;
+ bd_data = (uint32_t *)(&rxq->rx_ring[desc_id]);
+ fprintf(file, "Rx queue id:%u BD id:%u\n", queue_id, desc_id);
+ for (i = 0; i < HNS3_BD_DW_NUM; i++) {
+ /*
+ * For the sake of security, first 8 bytes of BD which
+ * stands for physical address of packet should not be
+ * shown.
+ */
+ if (i < HNS3_BD_ADDRESS_LAST_DW) {
+ fprintf(file, "RX BD WORD[%d]:0x%08x\n", i, 0);
+ continue;
+ }
+ fprintf(file, "RX BD WORD[%d]:0x%08x\n", i,
+ *(bd_data + i));
+ }
+ count++;
+ }
+
+ return 0;
+}
+
+int
+hns3_tx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id,
+ uint16_t offset, uint16_t num, FILE *file)
+{
+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct hns3_tx_queue *txq = dev->data->tx_queues[queue_id];
+ uint32_t *bd_data;
+ uint16_t count = 0;
+ uint16_t desc_id;
+ int i;
+
+ if (offset >= txq->nb_tx_desc)
+ return -EINVAL;
+
+ if (num > txq->nb_tx_desc) {
+ hns3_err(hw, "Invalid BD num=%u\n", num);
+ return -EINVAL;
+ }
+
+ while (count < num) {
+ desc_id = (txq->next_to_use + offset + count) % txq->nb_tx_desc;
+ bd_data = (uint32_t *)(&txq->tx_ring[desc_id]);
+ fprintf(file, "Tx queue id:%u BD id:%u\n", queue_id, desc_id);
+ for (i = 0; i < HNS3_BD_DW_NUM; i++) {
+ /*
+ * For the sake of security, first 8 bytes of BD which
+ * stands for physical address of packet should not be
+ * shown.
+ */
+ if (i < HNS3_BD_ADDRESS_LAST_DW) {
+ fprintf(file, "TX BD WORD[%d]:0x%08x\n", i, 0);
+ continue;
+ }
+
+ fprintf(file, "Tx BD WORD[%d]:0x%08x\n", i,
+ *(bd_data + i));
+ }
+ count++;
+ }
+
+ return 0;
+}
diff --git a/drivers/net/hns3/hns3_dump.h b/drivers/net/hns3/hns3_dump.h
index 616cb70d6e..021ce1bbdb 100644
--- a/drivers/net/hns3/hns3_dump.h
+++ b/drivers/net/hns3/hns3_dump.h
@@ -7,4 +7,8 @@
int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file);
+int hns3_rx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id,
+ uint16_t offset, uint16_t num, FILE *file);
+int hns3_tx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id,
+ uint16_t offset, uint16_t num, FILE *file);
#endif /* HNS3_DUMP_H */
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 7330515535..f83cff4d98 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -6558,6 +6558,8 @@ static const struct eth_dev_ops hns3_eth_dev_ops = {
.timesync_read_time = hns3_timesync_read_time,
.timesync_write_time = hns3_timesync_write_time,
.eth_dev_priv_dump = hns3_eth_dev_priv_dump,
+ .eth_rx_descriptor_dump = hns3_rx_descriptor_dump,
+ .eth_tx_descriptor_dump = hns3_tx_descriptor_dump,
};
static const struct hns3_reset_ops hns3_reset_ops = {
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 6976a9f23d..1022b02697 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -2302,6 +2302,8 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = {
.dev_supported_ptypes_get = hns3_dev_supported_ptypes_get,
.tx_done_cleanup = hns3_tx_done_cleanup,
.eth_dev_priv_dump = hns3_eth_dev_priv_dump,
+ .eth_rx_descriptor_dump = hns3_rx_descriptor_dump,
+ .eth_tx_descriptor_dump = hns3_tx_descriptor_dump,
};
static const struct hns3_reset_ops hns3vf_reset_ops = {
--
2.23.0

View File

@ -0,0 +1,50 @@
From ea171dea8f8417fe0715620a3de77e0cf3054916 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Fri, 21 Oct 2022 15:36:42 +0800
Subject: [PATCH 166/189] remove unnecessary null checks
Functions like free, rte_free, and rte_mempool_free
already handle NULL pointer so the checks here are not necessary.
Remove redundant NULL pointer checks before free functions
found by nullfree.cocci
Note: This patch only captures some hns3 modification from the
following patch:
Fixes: 06c047b68061 ("remove unnecessary null checks")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/hns3/hns3_rxtx.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 8ad40a49c7..29caaeafbd 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -86,8 +86,7 @@ hns3_rx_queue_release(void *queue)
hns3_rx_queue_release_mbufs(rxq);
if (rxq->mz)
rte_memzone_free(rxq->mz);
- if (rxq->sw_ring)
- rte_free(rxq->sw_ring);
+ rte_free(rxq->sw_ring);
rte_free(rxq);
}
}
@@ -100,10 +99,8 @@ hns3_tx_queue_release(void *queue)
hns3_tx_queue_release_mbufs(txq);
if (txq->mz)
rte_memzone_free(txq->mz);
- if (txq->sw_ring)
- rte_free(txq->sw_ring);
- if (txq->free)
- rte_free(txq->free);
+ rte_free(txq->sw_ring);
+ rte_free(txq->free);
rte_free(txq);
}
}
--
2.23.0

View File

@ -0,0 +1,175 @@
From 93df9193174fc6190ec793a0fdfc7bf2ee105669 Mon Sep 17 00:00:00 2001
From: Ferruh Yigit <ferruh.yigit@intel.com>
Date: Fri, 21 Oct 2022 15:36:43 +0800
Subject: [PATCH 167/189] ethdev: introduce generic dummy packet burst function
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Multiple PMDs have dummy/noop Rx/Tx packet burst functions.
These dummy functions are very simple, introduce a common function in
the ethdev and update drivers to use it instead of each driver having
its own functions.
Note:
Note: This patch only captures some hns3 modification from the
following patch:
Fixes: a41f593f1bce ("ethdev: introduce generic dummy packet burst function")
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
---
drivers/net/hns3/hns3_rxtx.c | 18 +++++-------------
drivers/net/hns3/hns3_rxtx.h | 3 ---
lib/ethdev/ethdev_driver.c | 13 +++++++++++++
lib/ethdev/ethdev_driver.h | 17 +++++++++++++++++
lib/ethdev/meson.build | 1 +
lib/ethdev/version.map | 1 +
6 files changed, 37 insertions(+), 16 deletions(-)
create mode 100644 lib/ethdev/ethdev_driver.c
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 29caaeafbd..3c02fd54e1 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4365,14 +4365,6 @@ hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep)
return hns3_xmit_pkts;
}
-uint16_t
-hns3_dummy_rxtx_burst(void *dpdk_txq __rte_unused,
- struct rte_mbuf **pkts __rte_unused,
- uint16_t pkts_n __rte_unused)
-{
- return 0;
-}
-
static void
hns3_trace_rxtx_function(struct rte_eth_dev *dev)
{
@@ -4416,14 +4408,14 @@ hns3_set_rxtx_function(struct rte_eth_dev *eth_dev)
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 = hw->set_link_down ?
- hns3_dummy_rxtx_burst :
+ rte_eth_pkt_burst_dummy :
hns3_get_tx_function(eth_dev, &prep);
eth_dev->tx_pkt_prepare = prep;
eth_dev->tx_descriptor_status = hns3_dev_tx_descriptor_status;
hns3_trace_rxtx_function(eth_dev);
} else {
- eth_dev->rx_pkt_burst = hns3_dummy_rxtx_burst;
- eth_dev->tx_pkt_burst = hns3_dummy_rxtx_burst;
+ eth_dev->rx_pkt_burst = rte_eth_pkt_burst_dummy;
+ eth_dev->tx_pkt_burst = rte_eth_pkt_burst_dummy;
eth_dev->tx_pkt_prepare = NULL;
}
@@ -4637,7 +4629,7 @@ hns3_tx_done_cleanup(void *txq, uint32_t free_cnt)
if (dev->tx_pkt_burst == hns3_xmit_pkts)
return hns3_tx_done_cleanup_full(q, free_cnt);
- else if (dev->tx_pkt_burst == hns3_dummy_rxtx_burst)
+ else if (dev->tx_pkt_burst == rte_eth_pkt_burst_dummy)
return 0;
else
return -ENOTSUP;
@@ -4747,7 +4739,7 @@ hns3_enable_rxd_adv_layout(struct hns3_hw *hw)
void
hns3_stop_tx_datapath(struct rte_eth_dev *dev)
{
- dev->tx_pkt_burst = hns3_dummy_rxtx_burst;
+ dev->tx_pkt_burst = rte_eth_pkt_burst_dummy;
dev->tx_pkt_prepare = NULL;
hns3_eth_dev_fp_ops_config(dev);
diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h
index ed40621b3a..e633b336b1 100644
--- a/drivers/net/hns3/hns3_rxtx.h
+++ b/drivers/net/hns3/hns3_rxtx.h
@@ -742,9 +742,6 @@ void hns3_init_rx_ptype_tble(struct rte_eth_dev *dev);
void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev);
eth_tx_burst_t hns3_get_tx_function(struct rte_eth_dev *dev,
eth_tx_prep_t *prep);
-uint16_t hns3_dummy_rxtx_burst(void *dpdk_txq __rte_unused,
- struct rte_mbuf **pkts __rte_unused,
- uint16_t pkts_n __rte_unused);
uint32_t hns3_get_tqp_intr_reg_offset(uint16_t tqp_intr_id);
void hns3_set_queue_intr_gl(struct hns3_hw *hw, uint16_t queue_id,
diff --git a/lib/ethdev/ethdev_driver.c b/lib/ethdev/ethdev_driver.c
new file mode 100644
index 0000000000..fb7323f4d3
--- /dev/null
+++ b/lib/ethdev/ethdev_driver.c
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2022 Intel Corporation
+ */
+
+#include "ethdev_driver.h"
+
+uint16_t
+rte_eth_pkt_burst_dummy(void *queue __rte_unused,
+ struct rte_mbuf **pkts __rte_unused,
+ uint16_t nb_pkts __rte_unused)
+{
+ return 0;
+}
diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h
index 41f67f2740..d3de203d7a 100644
--- a/lib/ethdev/ethdev_driver.h
+++ b/lib/ethdev/ethdev_driver.h
@@ -1497,6 +1497,23 @@ rte_eth_linkstatus_get(const struct rte_eth_dev *dev,
*dst = __atomic_load_n(src, __ATOMIC_SEQ_CST);
}
+/**
+ * @internal
+ * Dummy DPDK callback for Rx/Tx packet burst.
+ *
+ * @param queue
+ * Pointer to Rx/Tx queue
+ * @param pkts
+ * Packet array
+ * @param nb_pkts
+ * Number of packets in packet array
+ */
+__rte_internal
+uint16_t
+rte_eth_pkt_burst_dummy(void *queue __rte_unused,
+ struct rte_mbuf **pkts __rte_unused,
+ uint16_t nb_pkts __rte_unused);
+
/**
* Allocate an unique switch domain identifier.
*
diff --git a/lib/ethdev/meson.build b/lib/ethdev/meson.build
index 0205c853df..a094585bf7 100644
--- a/lib/ethdev/meson.build
+++ b/lib/ethdev/meson.build
@@ -2,6 +2,7 @@
# Copyright(c) 2017 Intel Corporation
sources = files(
+ 'ethdev_driver.c',
'ethdev_private.c',
'ethdev_profile.c',
'ethdev_trace_points.c',
diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map
index 09dba86bee..590aa5a0a6 100644
--- a/lib/ethdev/version.map
+++ b/lib/ethdev/version.map
@@ -286,6 +286,7 @@ INTERNAL {
rte_eth_hairpin_queue_peer_bind;
rte_eth_hairpin_queue_peer_unbind;
rte_eth_hairpin_queue_peer_update;
+ rte_eth_pkt_burst_dummy;
rte_eth_representor_id_get;
rte_eth_switch_domain_alloc;
rte_eth_switch_domain_free;
--
2.23.0

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,158 @@
From 11186d5e167f1b11c436f0ca550789e855d5292c Mon Sep 17 00:00:00 2001
From: Dongdong Liu <liudongdong3@huawei.com>
Date: Fri, 21 Oct 2022 15:36:45 +0800
Subject: [PATCH 169/189] net/hns3: add VLAN filter query in dump file
Add VLAN filter query in dump file.
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_dump.c | 80 +++++++++++++++++++++++++++++++-----
1 file changed, 69 insertions(+), 11 deletions(-)
diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c
index 1007b09bd2..8268506f6f 100644
--- a/drivers/net/hns3/hns3_dump.c
+++ b/drivers/net/hns3/hns3_dump.c
@@ -4,11 +4,10 @@
#include <rte_malloc.h>
-#include "hns3_ethdev.h"
#include "hns3_common.h"
-#include "hns3_rxtx.h"
-#include "hns3_regs.h"
#include "hns3_logs.h"
+#include "hns3_regs.h"
+#include "hns3_rxtx.h"
#include "hns3_dump.h"
#define HNS3_BD_DW_NUM 8
@@ -394,11 +393,6 @@ hns3_get_rxtx_queue_enable_state(FILE *file, struct rte_eth_dev *dev)
uint32_t nb_tx_queues;
uint32_t bitmap_size;
- bitmap_size = (hw->tqps_num * sizeof(uint32_t) + HNS3_UINT32_BIT) /
- HNS3_UINT32_BIT;
- rx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0);
- tx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0);
-
nb_rx_queues = dev->data->nb_rx_queues;
nb_tx_queues = dev->data->nb_tx_queues;
if (nb_rx_queues == 0) {
@@ -410,6 +404,21 @@ hns3_get_rxtx_queue_enable_state(FILE *file, struct rte_eth_dev *dev)
return;
}
+ bitmap_size = (hw->tqps_num * sizeof(uint32_t) + HNS3_UINT32_BIT) /
+ HNS3_UINT32_BIT;
+ rx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0);
+ if (rx_queue_state == NULL) {
+ hns3_err(hw, "Failed to allocate memory for rx queue state!");
+ return;
+ }
+
+ tx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0);
+ if (tx_queue_state == NULL) {
+ hns3_err(hw, "Failed to allocate memory for tx queue state!");
+ rte_free(rx_queue_state);
+ return;
+ }
+
fprintf(file, "\t -- enable state:\n");
hns3_get_queue_enable_state(hw, rx_queue_state, nb_rx_queues, true);
hns3_display_queue_enable_state(file, rx_queue_state, nb_rx_queues,
@@ -448,6 +457,51 @@ hns3_get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev)
hns3_get_rxtx_queue_enable_state(file, dev);
}
+static int
+hns3_get_vlan_filter_cfg(FILE *file, struct hns3_hw *hw)
+{
+#define HNS3_FILTER_TYPE_VF 0
+#define HNS3_FILTER_TYPE_PORT 1
+#define HNS3_FILTER_FE_NIC_INGRESS_B BIT(0)
+#define HNS3_FILTER_FE_NIC_EGRESS_B BIT(1)
+ struct hns3_vlan_filter_ctrl_cmd *req;
+ struct hns3_cmd_desc desc;
+ uint8_t i;
+ int ret;
+
+ static const uint32_t vlan_filter_type[] = {
+ HNS3_FILTER_TYPE_PORT,
+ HNS3_FILTER_TYPE_VF
+ };
+
+ for (i = 0; i < RTE_DIM(vlan_filter_type); i++) {
+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_FILTER_CTRL,
+ true);
+ req = (struct hns3_vlan_filter_ctrl_cmd *)desc.data;
+ req->vlan_type = vlan_filter_type[i];
+ req->vf_id = HNS3_PF_FUNC_ID;
+ ret = hns3_cmd_send(hw, &desc, 1);
+ if (ret != 0) {
+ hns3_err(hw,
+ "NIC IMP exec ret=%d desc_num=%d optcode=0x%x!",
+ ret, 1, rte_le_to_cpu_16(desc.opcode));
+ return ret;
+ }
+ fprintf(file,
+ "\t -- %s VLAN filter configuration\n"
+ "\t nic_ingress :%s\n"
+ "\t nic_egress :%s\n",
+ req->vlan_type == HNS3_FILTER_TYPE_PORT ?
+ "Port" : "VF",
+ req->vlan_fe & HNS3_FILTER_FE_NIC_INGRESS_B ?
+ "Enable" : "Disable",
+ req->vlan_fe & HNS3_FILTER_FE_NIC_EGRESS_B ?
+ "Enable" : "Disable");
+ }
+
+ return 0;
+}
+
static int
hns3_get_vlan_rx_offload_cfg(FILE *file, struct hns3_hw *hw)
{
@@ -583,6 +637,10 @@ hns3_get_vlan_config_info(FILE *file, struct hns3_hw *hw)
int ret;
fprintf(file, " - VLAN Config Info:\n");
+ ret = hns3_get_vlan_filter_cfg(file, hw);
+ if (ret < 0)
+ return;
+
ret = hns3_get_vlan_rx_offload_cfg(file, hw);
if (ret < 0)
return;
@@ -619,7 +677,7 @@ hns3_get_tm_conf_port_node_info(FILE *file, struct hns3_tm_conf *conf)
return;
fprintf(file,
- " port_node: \n"
+ " port_node:\n"
" node_id=%u reference_count=%u shaper_profile_id=%d\n",
conf->root->id, conf->root->reference_count,
conf->root->shaper_profile ?
@@ -637,7 +695,7 @@ hns3_get_tm_conf_tc_node_info(FILE *file, struct hns3_tm_conf *conf)
if (conf->nb_tc_node == 0)
return;
- fprintf(file, " tc_node: \n");
+ fprintf(file, " tc_node:\n");
memset(tc_node, 0, sizeof(tc_node));
TAILQ_FOREACH(tm_node, tc_list, node) {
tidx = hns3_tm_calc_node_tc_no(conf, tm_node->id);
@@ -705,7 +763,7 @@ hns3_get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf,
return;
fprintf(file,
- " queue_node: \n"
+ " queue_node:\n"
" tx queue id | mapped tc (8 mean node not exist)\n");
memset(queue_node, 0, sizeof(queue_node));
--
2.23.0

View File

@ -0,0 +1,39 @@
From a087560ab1d0e5920f77859f5a06245cc5d7bafe Mon Sep 17 00:00:00 2001
From: Yunjian Wang <wangyunjian@huawei.com>
Date: Fri, 21 Oct 2022 15:36:46 +0800
Subject: [PATCH 170/189] net/bonding: fix array overflow in Rx burst
In bond_ethdev_rx_burst() function, we check the validity of the
'active_slave' as this code:
if (++active_slave == slave_count)
active_slave = 0;
However, the value of 'active_slave' maybe equal to 'slave_count',
when a slave is down. This is wrong and it can cause buffer overflow.
This patch fixes the issue by using '>=' instead of '=='.
Fixes: e1110e977648 ("net/bonding: fix Rx slave fairness")
Cc: stable@dpdk.org
Signed-off-by: Lei Ji <jilei8@huawei.com>
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/bonding/rte_eth_bond_pmd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 09636321cd..828fb5f96d 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -82,7 +82,7 @@ bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
bufs + num_rx_total, nb_pkts);
num_rx_total += num_rx_slave;
nb_pkts -= num_rx_slave;
- if (++active_slave == slave_count)
+ if (++active_slave >= slave_count)
active_slave = 0;
}
--
2.23.0

View File

@ -0,0 +1,60 @@
From 7ec0325f9c2bfe2ea961e66588f8ba9e22bb6483 Mon Sep 17 00:00:00 2001
From: Yunjian Wang <wangyunjian@huawei.com>
Date: Fri, 21 Oct 2022 15:36:47 +0800
Subject: [PATCH 171/189] net/bonding: fix double slave link status query
When link status polling mode is used, the slave link status is
queried twice, which may be inconsistent. To fix this, we can keep
the latest queried link state.
Fixes: a45b288ef21a ("bond: support link status polling")
Cc: stable@dpdk.org
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/bonding/rte_eth_bond_pmd.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 828fb5f96d..3be2b08128 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2400,9 +2400,6 @@ bond_ethdev_slave_link_status_change_monitor(void *cb_arg)
* event callback */
if (slave_ethdev->data->dev_link.link_status !=
internals->slaves[i].last_link_status) {
- internals->slaves[i].last_link_status =
- slave_ethdev->data->dev_link.link_status;
-
bond_ethdev_lsc_event_callback(internals->slaves[i].port_id,
RTE_ETH_EVENT_INTR_LSC,
&bonded_ethdev->data->port_id,
@@ -2901,7 +2898,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
uint8_t lsc_flag = 0;
int valid_slave = 0;
- uint16_t active_pos;
+ uint16_t active_pos, slave_idx;
uint16_t i;
if (type != RTE_ETH_EVENT_INTR_LSC || param == NULL)
@@ -2922,6 +2919,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
for (i = 0; i < internals->slave_count; i++) {
if (internals->slaves[i].port_id == port_id) {
valid_slave = 1;
+ slave_idx = i;
break;
}
}
@@ -3010,6 +3008,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
* slaves
*/
bond_ethdev_link_update(bonded_eth_dev, 0);
+ internals->slaves[slave_idx].last_link_status = link.link_status;
if (lsc_flag) {
/* Cancel any possible outstanding interrupts if delays are enabled */
--
2.23.0

View File

@ -0,0 +1,121 @@
From 4ba54bf73c3f5038f03163d70e60d43e968878d5 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:48 +0800
Subject: [PATCH 172/189] app/testpmd: fix supported RSS offload display
The rte_eth_dev_info.flow_type_rss_offloads is populated in terms of
RTE_ETH_RSS_* bits. If PMD sets RTE_ETH_RSS_L3_SRC_ONLY to
dev_info->flow_type_rss_offloads. testpmd will display "user defined 63"
when run 'show port info 0'. Because testpmd use flowtype_to_str()
to display the supported RSS offload of PMD. In fact, the function is
used to display flow type in FDIR commands for i40e or ixgbe. This patch
uses the RTE_ETH_RSS_* bits to display supported RSS offload of PMD.
Fixes: b12964f621dc ("ethdev: unification of RSS offload types")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
app/test-pmd/config.c | 40 ++++++++++++++++++++++++++--------------
app/test-pmd/testpmd.h | 2 ++
2 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index a7fffc3d1d..2849ee7e7c 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -66,8 +66,6 @@
#define NS_PER_SEC 1E9
-static char *flowtype_to_str(uint16_t flow_type);
-
static const struct {
enum tx_pkt_split split;
const char *name;
@@ -674,6 +672,19 @@ print_dev_capabilities(uint64_t capabilities)
}
}
+const char *
+rsstypes_to_str(uint64_t rss_type)
+{
+ uint16_t i;
+
+ for (i = 0; rss_type_table[i].str != NULL; i++) {
+ if (rss_type_table[i].rss_type == rss_type)
+ return rss_type_table[i].str;
+ }
+
+ return NULL;
+}
+
void
port_infos_display(portid_t port_id)
{
@@ -778,19 +789,20 @@ port_infos_display(portid_t port_id)
if (!dev_info.flow_type_rss_offloads)
printf("No RSS offload flow type is supported.\n");
else {
+ uint64_t rss_offload_types = dev_info.flow_type_rss_offloads;
uint16_t i;
- char *p;
printf("Supported RSS offload flow types:\n");
- for (i = RTE_ETH_FLOW_UNKNOWN + 1;
- i < sizeof(dev_info.flow_type_rss_offloads) * CHAR_BIT; i++) {
- if (!(dev_info.flow_type_rss_offloads & (1ULL << i)))
- continue;
- p = flowtype_to_str(i);
- if (p)
- printf(" %s\n", p);
- else
- printf(" user defined %d\n", i);
+ for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT; i++) {
+ uint64_t rss_offload = RTE_BIT64(i);
+ if ((rss_offload_types & rss_offload) != 0) {
+ const char *p = rsstypes_to_str(rss_offload);
+ if (p)
+ printf(" %s\n", p);
+ else
+ printf(" user defined %u\n",
+ i);
+ }
}
}
@@ -4811,6 +4823,8 @@ set_record_burst_stats(uint8_t on_off)
record_burst_stats = on_off;
}
+#if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
+
static char*
flowtype_to_str(uint16_t flow_type)
{
@@ -4854,8 +4868,6 @@ flowtype_to_str(uint16_t flow_type)
return NULL;
}
-#if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
-
static inline void
print_fdir_mask(struct rte_eth_fdir_masks *mask)
{
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 569b4300cf..d6a775c485 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -1105,6 +1105,8 @@ extern int flow_parse(const char *src, void *result, unsigned int size,
struct rte_flow_item **pattern,
struct rte_flow_action **actions);
+const char *rsstypes_to_str(uint64_t rss_type);
+
/*
* Work-around of a compilation error with ICC on invocations of the
* rte_be_to_cpu_16() function.
--
2.23.0

View File

@ -0,0 +1,71 @@
From d1bfba3efc17445439ba794a63643a57b9b5be5a Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:49 +0800
Subject: [PATCH 173/189] app/testpmd: unify name of L2 payload offload
Currently, the "port config all rss xx" command uses 'ether' name to match
and to set 'RTE_ETH_RSS_L2_PAYLOAD' offload. However, others RSS command,
such as, "port config <port_id> rss-hash-key" and "show port <port_id>
rss-hash key", use 'l2-payload' to represent this offload. So this patch
unifies the name of 'RTE_ETH_RSS_L2_PAYLOAD' offload.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Acked-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
app/test-pmd/cmdline.c | 12 ++++++------
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 26d95e64e0..c5e4c30c9f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -793,8 +793,8 @@ static void cmd_help_long_parsed(void *parsed_result,
"receive buffers available.\n\n"
"port config all rss (all|default|ip|tcp|udp|sctp|"
- "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
- "level-outer|level-inner|<flowtype_id>)\n"
+ "l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|ipv4-chksum|"
+ "none|level-default|level-outer|level-inner|<flowtype_id>)\n"
" Set the RSS mode.\n\n"
"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
@@ -2187,7 +2187,7 @@ cmd_config_rss_parsed(void *parsed_result,
rss_conf.rss_hf = RTE_ETH_RSS_TCP;
else if (!strcmp(res->value, "sctp"))
rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
- else if (!strcmp(res->value, "ether"))
+ else if (!strcmp(res->value, "l2_payload"))
rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
else if (!strcmp(res->value, "port"))
rss_conf.rss_hf = RTE_ETH_RSS_PORT;
@@ -2308,9 +2308,9 @@ cmdline_parse_inst_t cmd_config_rss = {
.f = cmd_config_rss_parsed,
.data = NULL,
.help_str = "port config all rss "
- "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
- "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
- "level-outer|level-inner|ipv4-chksum|<flowtype_id>",
+ "all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|"
+ "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|ipv4-chksum|"
+ "none|level-default|level-outer|level-inner|<flowtype_id>",
.tokens = {
(void *)&cmd_config_rss_port,
(void *)&cmd_config_rss_keyword,
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 94792d88cc..b75adcce55 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -2285,7 +2285,7 @@ port config - RSS
Set the RSS (Receive Side Scaling) mode on or off::
- testpmd> port config all rss (all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none)
+ testpmd> port config all rss (all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none)
RSS is on by default.
--
2.23.0

View File

@ -0,0 +1,251 @@
From 860c15e4347ca38d50f4ce9d3f00e744f090e4e8 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:50 +0800
Subject: [PATCH 174/189] app/testpmd: refactor config all RSS command
The "port config <port_id> rss-hash-key" and "show port <port_id>
rss-hash key" commands both use the 'rss_type_table[]' to get
'rss_types' or the RSS type name. So this patch uses the
'rss_type_table[]' to get the RSS types. In this way, this command
naturally supports more individual types.
Suggested-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Acked-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
app/test-pmd/cmdline.c | 120 ++++++--------------
app/test-pmd/config.c | 20 +++-
app/test-pmd/testpmd.h | 1 +
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 10 +-
4 files changed, 58 insertions(+), 93 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index c5e4c30c9f..6cb095f965 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -792,9 +792,14 @@ static void cmd_help_long_parsed(void *parsed_result,
" Enable or disable packet drop on all RX queues of all ports when no "
"receive buffers available.\n\n"
- "port config all rss (all|default|ip|tcp|udp|sctp|"
- "l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|ipv4-chksum|"
- "none|level-default|level-outer|level-inner|<flowtype_id>)\n"
+ "port config all rss (all|default|level-default|level-outer|level-inner|"
+ "ip|tcp|udp|sctp|tunnel|vlan|none|"
+ "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
+ "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
+ "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
+ "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
+ "l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
+ "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
" Set the RSS mode.\n\n"
"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
@@ -2169,79 +2174,7 @@ cmd_config_rss_parsed(void *parsed_result,
uint16_t i;
int ret;
- if (!strcmp(res->value, "all"))
- rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP |
- RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP |
- RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP |
- RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU |
- RTE_ETH_RSS_ECPRI;
- else if (!strcmp(res->value, "eth"))
- rss_conf.rss_hf = RTE_ETH_RSS_ETH;
- else if (!strcmp(res->value, "vlan"))
- rss_conf.rss_hf = RTE_ETH_RSS_VLAN;
- else if (!strcmp(res->value, "ip"))
- rss_conf.rss_hf = RTE_ETH_RSS_IP;
- else if (!strcmp(res->value, "udp"))
- rss_conf.rss_hf = RTE_ETH_RSS_UDP;
- else if (!strcmp(res->value, "tcp"))
- rss_conf.rss_hf = RTE_ETH_RSS_TCP;
- else if (!strcmp(res->value, "sctp"))
- rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
- else if (!strcmp(res->value, "l2_payload"))
- rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
- else if (!strcmp(res->value, "port"))
- rss_conf.rss_hf = RTE_ETH_RSS_PORT;
- else if (!strcmp(res->value, "vxlan"))
- rss_conf.rss_hf = RTE_ETH_RSS_VXLAN;
- else if (!strcmp(res->value, "geneve"))
- rss_conf.rss_hf = RTE_ETH_RSS_GENEVE;
- else if (!strcmp(res->value, "nvgre"))
- rss_conf.rss_hf = RTE_ETH_RSS_NVGRE;
- else if (!strcmp(res->value, "l3-pre32"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
- else if (!strcmp(res->value, "l3-pre40"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
- else if (!strcmp(res->value, "l3-pre48"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
- else if (!strcmp(res->value, "l3-pre56"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
- else if (!strcmp(res->value, "l3-pre64"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
- else if (!strcmp(res->value, "l3-pre96"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
- else if (!strcmp(res->value, "l3-src-only"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY;
- else if (!strcmp(res->value, "l3-dst-only"))
- rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY;
- else if (!strcmp(res->value, "l4-src-only"))
- rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY;
- else if (!strcmp(res->value, "l4-dst-only"))
- rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY;
- else if (!strcmp(res->value, "l2-src-only"))
- rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY;
- else if (!strcmp(res->value, "l2-dst-only"))
- rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY;
- else if (!strcmp(res->value, "l2tpv3"))
- rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3;
- else if (!strcmp(res->value, "esp"))
- rss_conf.rss_hf = RTE_ETH_RSS_ESP;
- else if (!strcmp(res->value, "ah"))
- rss_conf.rss_hf = RTE_ETH_RSS_AH;
- else if (!strcmp(res->value, "pfcp"))
- rss_conf.rss_hf = RTE_ETH_RSS_PFCP;
- else if (!strcmp(res->value, "pppoe"))
- rss_conf.rss_hf = RTE_ETH_RSS_PPPOE;
- else if (!strcmp(res->value, "gtpu"))
- rss_conf.rss_hf = RTE_ETH_RSS_GTPU;
- else if (!strcmp(res->value, "ecpri"))
- rss_conf.rss_hf = RTE_ETH_RSS_ECPRI;
- else if (!strcmp(res->value, "mpls"))
- rss_conf.rss_hf = RTE_ETH_RSS_MPLS;
- else if (!strcmp(res->value, "ipv4-chksum"))
- rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM;
- else if (!strcmp(res->value, "none"))
- rss_conf.rss_hf = 0;
- else if (!strcmp(res->value, "level-default")) {
+ if (!strcmp(res->value, "level-default")) {
rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
} else if (!strcmp(res->value, "level-outer")) {
@@ -2250,14 +2183,24 @@ cmd_config_rss_parsed(void *parsed_result,
} else if (!strcmp(res->value, "level-inner")) {
rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
- } else if (!strcmp(res->value, "default"))
+ } else if (!strcmp(res->value, "default")) {
use_default = 1;
- else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
- atoi(res->value) < 64)
- rss_conf.rss_hf = 1ULL << atoi(res->value);
- else {
- fprintf(stderr, "Unknown parameter\n");
- return;
+ } else if (isdigit(res->value[0])) {
+ int value = atoi(res->value);
+ if (value > 0 && value < 64)
+ rss_conf.rss_hf = 1ULL << (uint8_t)value;
+ else {
+ fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
+ return;
+ }
+ } else if (!strcmp(res->value, "none")) {
+ rss_conf.rss_hf = 0;
+ } else {
+ rss_conf.rss_hf = str_to_rsstypes(res->value);
+ if (rss_conf.rss_hf == 0) {
+ fprintf(stderr, "Unknown parameter\n");
+ return;
+ }
}
rss_conf.rss_key = NULL;
/* Update global configuration for RSS types. */
@@ -2308,9 +2251,14 @@ cmdline_parse_inst_t cmd_config_rss = {
.f = cmd_config_rss_parsed,
.data = NULL,
.help_str = "port config all rss "
- "all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|"
- "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|ipv4-chksum|"
- "none|level-default|level-outer|level-inner|<flowtype_id>",
+ "all|default|level-default|level-outer|level-inner|"
+ "ip|tcp|udp|sctp|tunnel|vlan|none|"
+ "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
+ "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
+ "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
+ "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
+ "l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
+ "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
.tokens = {
(void *)&cmd_config_rss_port,
(void *)&cmd_config_rss_keyword,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 2849ee7e7c..b08face76d 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -672,6 +672,19 @@ print_dev_capabilities(uint64_t capabilities)
}
}
+uint64_t
+str_to_rsstypes(const char *str)
+{
+ uint16_t i;
+
+ for (i = 0; rss_type_table[i].str != NULL; i++) {
+ if (strcmp(rss_type_table[i].str, str) == 0)
+ return rss_type_table[i].rss_type;
+ }
+
+ return 0;
+}
+
const char *
rsstypes_to_str(uint64_t rss_type)
{
@@ -3063,15 +3076,10 @@ port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key,
{
struct rte_eth_rss_conf rss_conf;
int diag;
- unsigned int i;
rss_conf.rss_key = NULL;
rss_conf.rss_key_len = 0;
- rss_conf.rss_hf = 0;
- for (i = 0; rss_type_table[i].str; i++) {
- if (!strcmp(rss_type_table[i].str, rss_type))
- rss_conf.rss_hf = rss_type_table[i].rss_type;
- }
+ rss_conf.rss_hf = str_to_rsstypes(rss_type);
diag = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf);
if (diag == 0) {
rss_conf.rss_key = hash_key;
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index d6a775c485..e50188778b 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -1105,6 +1105,7 @@ extern int flow_parse(const char *src, void *result, unsigned int size,
struct rte_flow_item **pattern,
struct rte_flow_action **actions);
+uint64_t str_to_rsstypes(const char *str);
const char *rsstypes_to_str(uint64_t rss_type);
/*
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index b75adcce55..e15dc0c4c4 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -2285,7 +2285,15 @@ port config - RSS
Set the RSS (Receive Side Scaling) mode on or off::
- testpmd> port config all rss (all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none)
+ testpmd> port config all rss (all|default|level-default|level-outer|level-inner| \
+ ip|tcp|udp|sctp|tunnel|vlan|none| \
+ ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other| \
+ ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp| \
+ ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex| \
+ l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan| \
+ esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum| \
+ l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32| \
+ l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)
RSS is on by default.
--
2.23.0

View File

@ -0,0 +1,76 @@
From 6515c3f93ea7b5f5ef79f32ca7360b9edfc5e2ab Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:51 +0800
Subject: [PATCH 175/189] app/testpmd: unify RSS types display
The 'rss_type_table[]' maintains the name and value of RSS types. This
patch unifies a common interface to display RSS types.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
app/test-pmd/config.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index b08face76d..7b725fc7a1 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1554,6 +1554,23 @@ port_flow_complain(struct rte_flow_error *error)
return -err;
}
+static void
+rss_types_display(uint64_t rss_types)
+{
+ uint16_t i;
+
+ if (rss_types == 0)
+ return;
+
+ for (i = 0; rss_type_table[i].str; i++) {
+ if (rss_type_table[i].rss_type == 0)
+ continue;
+ if ((rss_types & rss_type_table[i].rss_type) ==
+ rss_type_table[i].rss_type)
+ printf(" %s", rss_type_table[i].str);
+ }
+}
+
static void
rss_config_display(struct rte_flow_action_rss *rss_conf)
{
@@ -1596,13 +1613,7 @@ rss_config_display(struct rte_flow_action_rss *rss_conf)
printf(" none\n");
return;
}
- for (i = 0; rss_type_table[i].str; i++) {
- if ((rss_conf->types &
- rss_type_table[i].rss_type) ==
- rss_type_table[i].rss_type &&
- rss_type_table[i].rss_type != 0)
- printf(" %s\n", rss_type_table[i].str);
- }
+ rss_types_display(rss_conf->types);
}
static struct port_indirect_action *
@@ -3054,13 +3065,8 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key)
printf("RSS disabled\n");
return;
}
- printf("RSS functions:\n ");
- for (i = 0; rss_type_table[i].str; i++) {
- if (rss_type_table[i].rss_type == 0)
- continue;
- if ((rss_hf & rss_type_table[i].rss_type) == rss_type_table[i].rss_type)
- printf("%s ", rss_type_table[i].str);
- }
+ printf("RSS functions:\n");
+ rss_types_display(rss_hf);
printf("\n");
if (!show_rss_key)
return;
--
2.23.0

View File

@ -0,0 +1,165 @@
From ce06141d60c64963a7dc02fbdd9b2229d38a6819 Mon Sep 17 00:00:00 2001
From: Ferruh Yigit <ferruh.yigit@xilinx.com>
Date: Fri, 21 Oct 2022 15:36:52 +0800
Subject: [PATCH 176/189] app/testpmd: compact RSS types output
In port info command output, 'show port info all', supported RSS offload
types printed one type per line, and although this information is not
most important part of the command it takes big part of the command
output.
In port RSS hash and flow RSS command output, 'show port 0 rss-hash',
and 'flow query 0 0 rss', all enabled RSS types are printed on one line.
If there are many types, the print will be very long.
Compacting these RSS offloads and types output by fixing the length of
the character string printed on each line, instead of one per line or
one line.
Output becomes as following:
Supported RSS offload flow types:
ipv4-frag ipv4-tcp ipv4-udp ipv4-sctp ipv4-other
ipv6-frag ipv6-tcp ipv6-udp ipv6-sctp ipv6-other
l4-dst-only l4-src-only l3-dst-only l3-src-only
Signed-off-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
app/test-pmd/config.c | 68 +++++++++++++++++++++++++++++++-----------
app/test-pmd/testpmd.h | 2 ++
2 files changed, 52 insertions(+), 18 deletions(-)
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 7b725fc7a1..873cca6f3e 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -698,6 +698,38 @@ rsstypes_to_str(uint64_t rss_type)
return NULL;
}
+static void
+rss_offload_types_display(uint64_t offload_types, uint16_t char_num_per_line)
+{
+ uint16_t user_defined_str_len;
+ uint16_t total_len = 0;
+ uint16_t str_len = 0;
+ uint64_t rss_offload;
+ uint16_t i;
+
+ for (i = 0; i < sizeof(offload_types) * CHAR_BIT; i++) {
+ rss_offload = RTE_BIT64(i);
+ if ((offload_types & rss_offload) != 0) {
+ const char *p = rsstypes_to_str(rss_offload);
+
+ user_defined_str_len =
+ strlen("user-defined-") + (i / 10 + 1);
+ str_len = p ? strlen(p) : user_defined_str_len;
+ str_len += 2; /* add two spaces */
+ if (total_len + str_len >= char_num_per_line) {
+ total_len = 0;
+ printf("\n");
+ }
+
+ if (p)
+ printf(" %s", p);
+ else
+ printf(" user-defined-%u", i);
+ total_len += str_len;
+ }
+ }
+}
+
void
port_infos_display(portid_t port_id)
{
@@ -802,21 +834,10 @@ port_infos_display(portid_t port_id)
if (!dev_info.flow_type_rss_offloads)
printf("No RSS offload flow type is supported.\n");
else {
- uint64_t rss_offload_types = dev_info.flow_type_rss_offloads;
- uint16_t i;
-
printf("Supported RSS offload flow types:\n");
- for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT; i++) {
- uint64_t rss_offload = RTE_BIT64(i);
- if ((rss_offload_types & rss_offload) != 0) {
- const char *p = rsstypes_to_str(rss_offload);
- if (p)
- printf(" %s\n", p);
- else
- printf(" user defined %u\n",
- i);
- }
- }
+ rss_offload_types_display(dev_info.flow_type_rss_offloads,
+ TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE);
+ printf("\n");
}
printf("Minimum size of RX buffer: %u\n", dev_info.min_rx_bufsize);
@@ -1555,8 +1576,10 @@ port_flow_complain(struct rte_flow_error *error)
}
static void
-rss_types_display(uint64_t rss_types)
+rss_types_display(uint64_t rss_types, uint16_t char_num_per_line)
{
+ uint16_t total_len = 0;
+ uint16_t str_len;
uint16_t i;
if (rss_types == 0)
@@ -1565,9 +1588,18 @@ rss_types_display(uint64_t rss_types)
for (i = 0; rss_type_table[i].str; i++) {
if (rss_type_table[i].rss_type == 0)
continue;
+
if ((rss_types & rss_type_table[i].rss_type) ==
- rss_type_table[i].rss_type)
+ rss_type_table[i].rss_type) {
+ /* Contain two spaces */
+ str_len = strlen(rss_type_table[i].str) + 2;
+ if (total_len + str_len > char_num_per_line) {
+ printf("\n");
+ total_len = 0;
+ }
printf(" %s", rss_type_table[i].str);
+ total_len += str_len;
+ }
}
}
@@ -1613,7 +1645,7 @@ rss_config_display(struct rte_flow_action_rss *rss_conf)
printf(" none\n");
return;
}
- rss_types_display(rss_conf->types);
+ rss_types_display(rss_conf->types, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE);
}
static struct port_indirect_action *
@@ -3066,7 +3098,7 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key)
return;
}
printf("RSS functions:\n");
- rss_types_display(rss_hf);
+ rss_types_display(rss_hf, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE);
printf("\n");
if (!show_rss_key)
return;
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index e50188778b..9c3a5d9bc5 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -105,6 +105,8 @@ struct pkt_burst_stats {
unsigned int pkt_burst_spread[MAX_PKT_BURST + 1];
};
+
+#define TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE 64
/** Information for a given RSS type. */
struct rss_type_info {
const char *str; /**< Type name. */
--
2.23.0

View File

@ -0,0 +1,99 @@
From 00a08212bf6e1c96e491353183d3db9ffbcf3463 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:53 +0800
Subject: [PATCH 177/189] app/testpmd: reorder RSS type table
There are group and individual types in rss_type_table[]. However, group
types are very scattered, and individual types are not arranged based on
the bit number order in 'RTE_ETH_RSS_xxx'. For a clear distribution of
types and better maintenance, this patch reorders this table.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Acked-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
app/test-pmd/config.c | 47 +++++++++++++++++++++++--------------------
1 file changed, 25 insertions(+), 22 deletions(-)
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 873cca6f3e..f8cd135970 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -85,17 +85,20 @@ static const struct {
};
const struct rss_type_info rss_type_table[] = {
+ /* Group types */
{ "all", RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP | RTE_ETH_RSS_TCP |
RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP | RTE_ETH_RSS_L2_PAYLOAD |
RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP | RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP |
RTE_ETH_RSS_GTPU | RTE_ETH_RSS_ECPRI | RTE_ETH_RSS_MPLS},
{ "none", 0 },
- { "eth", RTE_ETH_RSS_ETH },
- { "l2-src-only", RTE_ETH_RSS_L2_SRC_ONLY },
- { "l2-dst-only", RTE_ETH_RSS_L2_DST_ONLY },
+ { "ip", RTE_ETH_RSS_IP },
+ { "udp", RTE_ETH_RSS_UDP },
+ { "tcp", RTE_ETH_RSS_TCP },
+ { "sctp", RTE_ETH_RSS_SCTP },
+ { "tunnel", RTE_ETH_RSS_TUNNEL },
{ "vlan", RTE_ETH_RSS_VLAN },
- { "s-vlan", RTE_ETH_RSS_S_VLAN },
- { "c-vlan", RTE_ETH_RSS_C_VLAN },
+
+ /* Individual type */
{ "ipv4", RTE_ETH_RSS_IPV4 },
{ "ipv4-frag", RTE_ETH_RSS_FRAG_IPV4 },
{ "ipv4-tcp", RTE_ETH_RSS_NONFRAG_IPV4_TCP },
@@ -116,32 +119,32 @@ const struct rss_type_info rss_type_table[] = {
{ "vxlan", RTE_ETH_RSS_VXLAN },
{ "geneve", RTE_ETH_RSS_GENEVE },
{ "nvgre", RTE_ETH_RSS_NVGRE },
- { "ip", RTE_ETH_RSS_IP },
- { "udp", RTE_ETH_RSS_UDP },
- { "tcp", RTE_ETH_RSS_TCP },
- { "sctp", RTE_ETH_RSS_SCTP },
- { "tunnel", RTE_ETH_RSS_TUNNEL },
- { "l3-pre32", RTE_ETH_RSS_L3_PRE32 },
- { "l3-pre40", RTE_ETH_RSS_L3_PRE40 },
- { "l3-pre48", RTE_ETH_RSS_L3_PRE48 },
- { "l3-pre56", RTE_ETH_RSS_L3_PRE56 },
- { "l3-pre64", RTE_ETH_RSS_L3_PRE64 },
- { "l3-pre96", RTE_ETH_RSS_L3_PRE96 },
- { "l3-src-only", RTE_ETH_RSS_L3_SRC_ONLY },
- { "l3-dst-only", RTE_ETH_RSS_L3_DST_ONLY },
- { "l4-src-only", RTE_ETH_RSS_L4_SRC_ONLY },
- { "l4-dst-only", RTE_ETH_RSS_L4_DST_ONLY },
+ { "gtpu", RTE_ETH_RSS_GTPU },
+ { "eth", RTE_ETH_RSS_ETH },
+ { "s-vlan", RTE_ETH_RSS_S_VLAN },
+ { "c-vlan", RTE_ETH_RSS_C_VLAN },
{ "esp", RTE_ETH_RSS_ESP },
{ "ah", RTE_ETH_RSS_AH },
{ "l2tpv3", RTE_ETH_RSS_L2TPV3 },
{ "pfcp", RTE_ETH_RSS_PFCP },
{ "pppoe", RTE_ETH_RSS_PPPOE },
- { "gtpu", RTE_ETH_RSS_GTPU },
{ "ecpri", RTE_ETH_RSS_ECPRI },
{ "mpls", RTE_ETH_RSS_MPLS },
{ "ipv4-chksum", RTE_ETH_RSS_IPV4_CHKSUM },
{ "l4-chksum", RTE_ETH_RSS_L4_CHKSUM },
- { NULL, 0 },
+ { "l3-pre96", RTE_ETH_RSS_L3_PRE96 },
+ { "l3-pre64", RTE_ETH_RSS_L3_PRE64 },
+ { "l3-pre56", RTE_ETH_RSS_L3_PRE56 },
+ { "l3-pre48", RTE_ETH_RSS_L3_PRE48 },
+ { "l3-pre40", RTE_ETH_RSS_L3_PRE40 },
+ { "l3-pre32", RTE_ETH_RSS_L3_PRE32 },
+ { "l2-dst-only", RTE_ETH_RSS_L2_DST_ONLY },
+ { "l2-src-only", RTE_ETH_RSS_L2_SRC_ONLY },
+ { "l4-dst-only", RTE_ETH_RSS_L4_DST_ONLY },
+ { "l4-src-only", RTE_ETH_RSS_L4_SRC_ONLY },
+ { "l3-dst-only", RTE_ETH_RSS_L3_DST_ONLY },
+ { "l3-src-only", RTE_ETH_RSS_L3_SRC_ONLY },
+ { NULL, 0},
};
static const struct {
--
2.23.0

View File

@ -0,0 +1,61 @@
From 34d8e6bf37155488c61029cf392255dd18ed0a87 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Fri, 21 Oct 2022 15:36:54 +0800
Subject: [PATCH 178/189] app/testpmd: fix RSS types display
Now testpmd fails to display types when query RSS rule. The failure is
because the '\n' character is missing at the end of the function
'rss_config_display()'.
Actually, all places calling 'xxx_types_display()' need to '\n'. So this
patch moves '\n' to the inside of these function.
Bugzilla ID: 1048
Fixes: 534988c490f1 ("app/testpmd: unify RSS types display")
Fixes: 44a37f3cffe0 ("app/testpmd: compact RSS types output")
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Tested-by: Weiyuan Li <weiyuanx.li@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
app/test-pmd/config.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index f8cd135970..12386c4d82 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -731,6 +731,7 @@ rss_offload_types_display(uint64_t offload_types, uint16_t char_num_per_line)
total_len += str_len;
}
}
+ printf("\n");
}
void
@@ -840,7 +841,6 @@ port_infos_display(portid_t port_id)
printf("Supported RSS offload flow types:\n");
rss_offload_types_display(dev_info.flow_type_rss_offloads,
TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE);
- printf("\n");
}
printf("Minimum size of RX buffer: %u\n", dev_info.min_rx_bufsize);
@@ -1604,6 +1604,7 @@ rss_types_display(uint64_t rss_types, uint16_t char_num_per_line)
total_len += str_len;
}
}
+ printf("\n");
}
static void
@@ -3102,7 +3103,6 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key)
}
printf("RSS functions:\n");
rss_types_display(rss_hf, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE);
- printf("\n");
if (!show_rss_key)
return;
printf("RSS key:\n");
--
2.23.0

View File

@ -0,0 +1,91 @@
From 9de9c8f454d4d1d87105700f626568f5f59e6985 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:55 +0800
Subject: [PATCH 179/189] ethdev: support telemetry private dump
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This patch supports telemetry private dump a ethdev port.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
---
lib/ethdev/rte_ethdev.c | 47 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index b95f501b51..df5a627cbe 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -7,6 +7,7 @@
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/queue.h>
@@ -6272,6 +6273,48 @@ eth_dev_handle_port_xstats(const char *cmd __rte_unused,
return 0;
}
+#ifndef RTE_EXEC_ENV_WINDOWS
+static int
+eth_dev_handle_port_dump_priv(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ char *buf, *end_param;
+ int port_id, ret;
+ FILE *f;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -EINVAL;
+
+ port_id = strtoul(params, &end_param, 0);
+ if (*end_param != '\0')
+ RTE_ETHDEV_LOG(NOTICE,
+ "Extra parameters passed to ethdev telemetry command, ignoring");
+ if (!rte_eth_dev_is_valid_port(port_id))
+ return -EINVAL;
+
+ buf = calloc(sizeof(char), RTE_TEL_MAX_SINGLE_STRING_LEN);
+ if (buf == NULL)
+ return -ENOMEM;
+
+ f = fmemopen(buf, RTE_TEL_MAX_SINGLE_STRING_LEN - 1, "w+");
+ if (f == NULL) {
+ free(buf);
+ return -EINVAL;
+ }
+
+ ret = rte_eth_dev_priv_dump(port_id, f);
+ fclose(f);
+ if (ret == 0) {
+ rte_tel_data_start_dict(d);
+ rte_tel_data_string(d, buf);
+ }
+
+ free(buf);
+ return 0;
+}
+#endif /* !RTE_EXEC_ENV_WINDOWS */
+
static int
eth_dev_handle_port_link_status(const char *cmd __rte_unused,
const char *params,
@@ -6571,6 +6614,10 @@ RTE_INIT(ethdev_init_telemetry)
"Returns the common stats for a port. Parameters: int port_id");
rte_telemetry_register_cmd("/ethdev/xstats", eth_dev_handle_port_xstats,
"Returns the extended stats for a port. Parameters: int port_id");
+#ifndef RTE_EXEC_ENV_WINDOWS
+ rte_telemetry_register_cmd("/ethdev/dump_priv", eth_dev_handle_port_dump_priv,
+ "Returns dump private information for a port. Parameters: int port_id");
+#endif
rte_telemetry_register_cmd("/ethdev/link_status",
eth_dev_handle_port_link_status,
"Returns the link status for a port. Parameters: int port_id");
--
2.23.0

View File

@ -0,0 +1,224 @@
From ab11b7f71865aaab19e2a59e877bc70dfbc317b0 Mon Sep 17 00:00:00 2001
From: Sean Morrissey <sean.morrissey@intel.com>
Date: Fri, 21 Oct 2022 15:36:56 +0800
Subject: [PATCH 180/189] dmadev: add telemetry
Telemetry commands are now registered through the dmadev library
for the gathering of DSA stats. The corresponding callback
functions for listing dmadevs and providing info and stats for a
An example usage can be seen below:
Connecting to /var/run/dpdk/rte/dpdk_telemetry.v2
{"version": "DPDK 22.03.0-rc2", "pid": 2956551, "max_output_len": 16384}
Connected to application: "dpdk-dma"
--> /
{"/": ["/", "/dmadev/info", "/dmadev/list", "/dmadev/stats", ...]}
--> /dmadev/list
{"/dmadev/info": {"name": "0000:00:01.0", "nb_vchans": 1, "numa_node": 0,
"max_vchans": 1, "max_desc": 4096, "min_desc": 32, "max_sges": 0,
"capabilities": {"mem2mem": 1, "mem2dev": 0, "dev2mem": 0, ...}}}
--> /dmadev/stats,0,0
{"/dmadev/stats": {"submitted": 0, "completed": 0, "errors": 0}}
Signed-off-by: Sean Morrissey <sean.morrissey@intel.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Conor Walsh <conor.walsh@intel.com>
Tested-by: Sunil Pai G <sunil.pai.g@intel.com>
Tested-by: Kevin Laatz <kevin.laatz@intel.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
doc/guides/prog_guide/dmadev.rst | 24 ++++++
lib/dmadev/meson.build | 2 +
lib/dmadev/rte_dmadev.c | 130 +++++++++++++++++++++++++++++++
3 files changed, 156 insertions(+)
diff --git a/doc/guides/prog_guide/dmadev.rst b/doc/guides/prog_guide/dmadev.rst
index 77863f8028..2aa26d33b8 100644
--- a/doc/guides/prog_guide/dmadev.rst
+++ b/doc/guides/prog_guide/dmadev.rst
@@ -118,3 +118,27 @@ i.e. ``rte_dma_stats_get()``. The statistics returned for each device instance a
* ``submitted``: The number of operations submitted to the device.
* ``completed``: The number of operations which have completed (successful and failed).
* ``errors``: The number of operations that completed with error.
+
+The dmadev library has support for displaying DMA device information
+through the Telemetry interface. Telemetry commands that can be used
+are shown below.
+
+#. Get the list of available DMA devices by ID::
+
+ --> /dmadev/list
+ {"/dmadev/list": [0, 1]}
+
+#. Get general information from a DMA device by passing the device id as a parameter::
+
+ --> /dmadev/info,0
+ {"/dmadev/info": {"name": "0000:00:01.0", "nb_vchans": 1, "numa_node": 0, "max_vchans": 1, "max_desc": 4096,
+ "min_desc": 32, "max_sges": 0, "capabilities": {"mem2mem": 1, "mem2dev": 0, "dev2mem": 0, ...}}}
+
+#. Get the statistics for a particular DMA device and virtual DMA channel by passing the device id and vchan id as parameters
+ (if a DMA device only has one virtual DMA channel you only need to pass the device id)::
+
+ --> /dmadev/stats,0,0
+ {"/dmadev/stats": {"submitted": 0, "completed": 0, "errors": 0}}
+
+For more information on how to use the Telemetry interface, see
+the :doc:`../howto/telemetry`.
diff --git a/lib/dmadev/meson.build b/lib/dmadev/meson.build
index d2fc85e8c7..2f17587b75 100644
--- a/lib/dmadev/meson.build
+++ b/lib/dmadev/meson.build
@@ -5,3 +5,5 @@ sources = files('rte_dmadev.c')
headers = files('rte_dmadev.h')
indirect_headers += files('rte_dmadev_core.h')
driver_sdk_headers += files('rte_dmadev_pmd.h')
+
+deps += ['telemetry']
diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index d4b32b2971..174d4c40ae 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -11,6 +11,7 @@
#include <rte_malloc.h>
#include <rte_memzone.h>
#include <rte_string_fns.h>
+#include <rte_telemetry.h>
#include "rte_dmadev.h"
#include "rte_dmadev_pmd.h"
@@ -864,3 +865,132 @@ dma_fp_object_dummy(struct rte_dma_fp_object *obj)
obj->completed_status = dummy_completed_status;
obj->burst_capacity = dummy_burst_capacity;
}
+
+static int
+dmadev_handle_dev_list(const char *cmd __rte_unused,
+ const char *params __rte_unused,
+ struct rte_tel_data *d)
+{
+ int dev_id;
+
+ rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
+ for (dev_id = 0; dev_id < dma_devices_max; dev_id++)
+ if (rte_dma_is_valid(dev_id))
+ rte_tel_data_add_array_int(d, dev_id);
+
+ return 0;
+}
+
+#define ADD_CAPA(td, dc, c) rte_tel_data_add_dict_int(td, dma_capability_name(c), !!(dc & c))
+
+static int
+dmadev_handle_dev_info(const char *cmd __rte_unused,
+ const char *params, struct rte_tel_data *d)
+{
+ struct rte_dma_info dma_info;
+ struct rte_tel_data *dma_caps;
+ int dev_id, ret;
+ uint64_t dev_capa;
+ char *end_param;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -EINVAL;
+
+ dev_id = strtoul(params, &end_param, 0);
+ if (*end_param != '\0')
+ RTE_DMA_LOG(WARNING, "Extra parameters passed to dmadev telemetry command, ignoring");
+
+ /* Function info_get validates dev_id so we don't need to. */
+ ret = rte_dma_info_get(dev_id, &dma_info);
+ if (ret < 0)
+ return -EINVAL;
+ dev_capa = dma_info.dev_capa;
+
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_string(d, "name", dma_info.dev_name);
+ rte_tel_data_add_dict_int(d, "nb_vchans", dma_info.nb_vchans);
+ rte_tel_data_add_dict_int(d, "numa_node", dma_info.numa_node);
+ rte_tel_data_add_dict_int(d, "max_vchans", dma_info.max_vchans);
+ rte_tel_data_add_dict_int(d, "max_desc", dma_info.max_desc);
+ rte_tel_data_add_dict_int(d, "min_desc", dma_info.min_desc);
+ rte_tel_data_add_dict_int(d, "max_sges", dma_info.max_sges);
+
+ dma_caps = rte_tel_data_alloc();
+ if (!dma_caps)
+ return -ENOMEM;
+
+ rte_tel_data_start_dict(dma_caps);
+ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_MEM_TO_MEM);
+ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_MEM_TO_DEV);
+ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_DEV_TO_MEM);
+ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_DEV_TO_DEV);
+ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_SVA);
+ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_SILENT);
+ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_HANDLES_ERRORS);
+ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_OPS_COPY);
+ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_OPS_COPY_SG);
+ ADD_CAPA(dma_caps, dev_capa, RTE_DMA_CAPA_OPS_FILL);
+ rte_tel_data_add_dict_container(d, "capabilities", dma_caps, 0);
+
+ return 0;
+}
+
+#define ADD_DICT_STAT(s) rte_tel_data_add_dict_u64(d, #s, dma_stats.s)
+
+static int
+dmadev_handle_dev_stats(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ struct rte_dma_info dma_info;
+ struct rte_dma_stats dma_stats;
+ int dev_id, ret, vchan_id;
+ char *end_param;
+ const char *vchan_param;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -EINVAL;
+
+ dev_id = strtoul(params, &end_param, 0);
+
+ /* Function info_get validates dev_id so we don't need to. */
+ ret = rte_dma_info_get(dev_id, &dma_info);
+ if (ret < 0)
+ return -EINVAL;
+
+ /* If the device has one vchan the user does not need to supply the
+ * vchan id and only the device id is needed, no extra parameters.
+ */
+ if (dma_info.nb_vchans == 1 && *end_param == '\0')
+ vchan_id = 0;
+ else {
+ vchan_param = strtok(end_param, ",");
+ if (!vchan_param || strlen(vchan_param) == 0 || !isdigit(*vchan_param))
+ return -EINVAL;
+
+ vchan_id = strtoul(vchan_param, &end_param, 0);
+ }
+ if (*end_param != '\0')
+ RTE_DMA_LOG(WARNING, "Extra parameters passed to dmadev telemetry command, ignoring");
+
+ ret = rte_dma_stats_get(dev_id, vchan_id, &dma_stats);
+ if (ret < 0)
+ return -EINVAL;
+
+ rte_tel_data_start_dict(d);
+ ADD_DICT_STAT(submitted);
+ ADD_DICT_STAT(completed);
+ ADD_DICT_STAT(errors);
+
+ return 0;
+}
+
+RTE_INIT(dmadev_init_telemetry)
+{
+ rte_telemetry_register_cmd("/dmadev/list", dmadev_handle_dev_list,
+ "Returns list of available dmadev devices by IDs. No parameters.");
+ rte_telemetry_register_cmd("/dmadev/info", dmadev_handle_dev_info,
+ "Returns information for a dmadev. Parameters: int dev_id");
+ rte_telemetry_register_cmd("/dmadev/stats", dmadev_handle_dev_stats,
+ "Returns the stats for a dmadev vchannel. Parameters: int dev_id, vchan_id (Optional if only one vchannel)");
+}
--
2.23.0

View File

@ -0,0 +1,78 @@
From a36114ed036f8c4976dfe3d47f0ee29c9f214fc5 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Fri, 21 Oct 2022 15:36:57 +0800
Subject: [PATCH 181/189] dmadev: support telemetry dump dmadev
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This patch supports telemetry dump dmadev.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
---
lib/dmadev/rte_dmadev.c | 43 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index 174d4c40ae..ea1cb815b4 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -985,6 +985,45 @@ dmadev_handle_dev_stats(const char *cmd __rte_unused,
return 0;
}
+#ifndef RTE_EXEC_ENV_WINDOWS
+static int
+dmadev_handle_dev_dump(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ char *buf, *end_param;
+ int dev_id, ret;
+ FILE *f;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -EINVAL;
+
+ dev_id = strtoul(params, &end_param, 0);
+ if (*end_param != '\0')
+ RTE_DMA_LOG(WARNING, "Extra parameters passed to dmadev telemetry command, ignoring");
+
+ buf = calloc(sizeof(char), RTE_TEL_MAX_SINGLE_STRING_LEN);
+ if (buf == NULL)
+ return -ENOMEM;
+
+ f = fmemopen(buf, RTE_TEL_MAX_SINGLE_STRING_LEN - 1, "w+");
+ if (f == NULL) {
+ free(buf);
+ return -EINVAL;
+ }
+
+ ret = rte_dma_dump(dev_id, f);
+ fclose(f);
+ if (ret == 0) {
+ rte_tel_data_start_dict(d);
+ rte_tel_data_string(d, buf);
+ }
+
+ free(buf);
+ return ret;
+}
+#endif /* !RTE_EXEC_ENV_WINDOWS */
+
RTE_INIT(dmadev_init_telemetry)
{
rte_telemetry_register_cmd("/dmadev/list", dmadev_handle_dev_list,
@@ -993,4 +1032,8 @@ RTE_INIT(dmadev_init_telemetry)
"Returns information for a dmadev. Parameters: int dev_id");
rte_telemetry_register_cmd("/dmadev/stats", dmadev_handle_dev_stats,
"Returns the stats for a dmadev vchannel. Parameters: int dev_id, vchan_id (Optional if only one vchannel)");
+#ifndef RTE_EXEC_ENV_WINDOWS
+ rte_telemetry_register_cmd("/dmadev/dump", dmadev_handle_dev_dump,
+ "Returns dump information for a dmadev. Parameters: int dev_id");
+#endif
}
--
2.23.0

View File

@ -0,0 +1,45 @@
From dcccc81ecd1f1a0a24ba361d474ef81c9691fd14 Mon Sep 17 00:00:00 2001
From: Brian Dooley <brian.dooley@intel.com>
Date: Fri, 21 Oct 2022 15:36:58 +0800
Subject: [PATCH 182/189] telemetry: add missing C++ guards
Some public header files were missing 'extern "C"' C++ guards,
and couldn't be used by C++ applications. Add the missing guards.
Fixes: 8877ac688b52 ("telemetry: introduce infrastructure")
Cc: stable@dpdk.org
Signed-off-by: Brian Dooley <brian.dooley@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
lib/telemetry/rte_telemetry.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h
index 7bca8a9a49..3372b32f38 100644
--- a/lib/telemetry/rte_telemetry.h
+++ b/lib/telemetry/rte_telemetry.h
@@ -9,6 +9,10 @@
#ifndef _RTE_TELEMETRY_H_
#define _RTE_TELEMETRY_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/** Maximum length for string used in object. */
#define RTE_TEL_MAX_STRING_LEN 128
/** Maximum length of string. */
@@ -294,4 +298,8 @@ rte_tel_data_alloc(void);
void
rte_tel_data_free(struct rte_tel_data *data);
+#ifdef __cplusplus
+}
+#endif
+
#endif
--
2.23.0

View File

@ -0,0 +1,146 @@
From 926dc7ff064ee81e6b9732247ddb7785a4ab98b8 Mon Sep 17 00:00:00 2001
From: Bruce Richardson <bruce.richardson@intel.com>
Date: Fri, 21 Oct 2022 15:36:59 +0800
Subject: [PATCH 183/189] telemetry: limit characters allowed in dictionary names
To save issues with encoding the names of values in dicts, we limit the
allowed names to a subset of character values. This list of allowed
characters can be expanded as necessary in future.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
lib/telemetry/rte_telemetry.h | 8 ++++++++
lib/telemetry/telemetry_data.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h
index 3372b32f38..fadea48cb9 100644
--- a/lib/telemetry/rte_telemetry.h
+++ b/lib/telemetry/rte_telemetry.h
@@ -64,6 +64,10 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type);
/**
* Start a dictionary of values for returning from a callback
*
+ * Dictionaries consist of key-values pairs to be returned, where the keys,
+ * or names, are strings and the values can be any of the types supported by telemetry.
+ * Name strings may only contain alphanumeric characters as well as '_' or '/'
+ *
* @param d
* The data structure passed to the callback
* @return
@@ -159,6 +163,7 @@ rte_tel_data_add_array_container(struct rte_tel_data *d,
* The data structure passed to the callback
* @param name
* The name the value is to be stored under in the dict
+ * Must contain only alphanumeric characters or the symbols: '_' or '/'
* @param val
* The string to be stored in the dict
* @return
@@ -177,6 +182,7 @@ rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name,
* The data structure passed to the callback
* @param name
* The name the value is to be stored under in the dict
+ * Must contain only alphanumeric characters or the symbols: '_' or '/'
* @param val
* The number to be stored in the dict
* @return
@@ -193,6 +199,7 @@ rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val);
* The data structure passed to the callback
* @param name
* The name the value is to be stored under in the dict
+ * Must contain only alphanumeric characters or the symbols: '_' or '/'
* @param val
* The number to be stored in the dict
* @return
@@ -212,6 +219,7 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d,
* The data structure passed to the callback
* @param name
* The name the value is to be stored under in the dict.
+ * Must contain only alphanumeric characters or the symbols: '_' or '/'
* @param val
* The pointer to the container to be stored in the dict.
* @param keep
diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c
index e14ae3c4d4..be46054c29 100644
--- a/lib/telemetry/telemetry_data.c
+++ b/lib/telemetry/telemetry_data.c
@@ -3,6 +3,7 @@
*/
#undef RTE_USE_LIBBSD
+#include <stdbool.h>
#include <rte_string_fns.h>
#include "telemetry_data.h"
@@ -92,6 +93,24 @@ rte_tel_data_add_array_container(struct rte_tel_data *d,
return 0;
}
+static bool
+valid_name(const char *name)
+{
+ char allowed[128] = {
+ ['0' ... '9'] = 1,
+ ['A' ... 'Z'] = 1,
+ ['a' ... 'z'] = 1,
+ ['_'] = 1,
+ ['/'] = 1,
+ };
+ while (*name != '\0') {
+ if ((size_t)*name >= RTE_DIM(allowed) || allowed[(int)*name] == 0)
+ return false;
+ name++;
+ }
+ return true;
+}
+
int
rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name,
const char *val)
@@ -104,6 +123,9 @@ rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name,
if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
return -ENOSPC;
+ if (!valid_name(name))
+ return -EINVAL;
+
d->data_len++;
e->type = RTE_TEL_STRING_VAL;
vbytes = strlcpy(e->value.sval, val, RTE_TEL_MAX_STRING_LEN);
@@ -123,6 +145,9 @@ rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val)
if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
return -ENOSPC;
+ if (!valid_name(name))
+ return -EINVAL;
+
d->data_len++;
e->type = RTE_TEL_INT_VAL;
e->value.ival = val;
@@ -140,6 +165,9 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d,
if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
return -ENOSPC;
+ if (!valid_name(name))
+ return -EINVAL;
+
d->data_len++;
e->type = RTE_TEL_U64_VAL;
e->value.u64val = val;
@@ -161,6 +189,9 @@ rte_tel_data_add_dict_container(struct rte_tel_data *d, const char *name,
if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
return -ENOSPC;
+ if (!valid_name(name))
+ return -EINVAL;
+
d->data_len++;
e->type = RTE_TEL_CONTAINER;
e->value.container.data = val;
--
2.23.0

View File

@ -0,0 +1,122 @@
From bdedf8a96e0782e98291e219ed7b74cb7b04fc9c Mon Sep 17 00:00:00 2001
From: Bruce Richardson <bruce.richardson@intel.com>
Date: Fri, 21 Oct 2022 15:37:00 +0800
Subject: [PATCH 184/189] telemetry: fix escaping of invalid json characters
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
For string values returned from telemetry, escape any values that cannot
normally appear in a json string. According to the json spec[1], the
characters than need to be handled are control chars (char value < 0x20)
and '"' and '\' characters.
To handle this, we replace the snprintf call with a separate string
copying and encapsulation routine which checks each character as it
copies it to the final array.
[1] https://www.rfc-editor.org/rfc/rfc8259.txt
Bugzilla ID: 1037
Fixes: 6dd571fd07c3 ("telemetry: introduce new functionality")
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
lib/telemetry/telemetry.c | 11 +++++---
lib/telemetry/telemetry_json.h | 48 +++++++++++++++++++++++++++++++++-
2 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index e5ccfe47f7..d4a7838ded 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -233,9 +233,14 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
MAX_CMD_LEN, cmd ? cmd : "none");
break;
case RTE_TEL_STRING:
- used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":\"%.*s\"}",
- MAX_CMD_LEN, cmd,
- RTE_TEL_MAX_SINGLE_STRING_LEN, d->data.str);
+ prefix_used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":",
+ MAX_CMD_LEN, cmd);
+ cb_data_buf = &out_buf[prefix_used];
+ buf_len = sizeof(out_buf) - prefix_used - 1; /* space for '}' */
+
+ used = rte_tel_json_str(cb_data_buf, buf_len, 0, d->data.str);
+ used += prefix_used;
+ used += strlcat(out_buf + used, "}", sizeof(out_buf) - used);
break;
case RTE_TEL_DICT:
prefix_used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":",
diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
index db70690274..13df5d07e3 100644
--- a/lib/telemetry/telemetry_json.h
+++ b/lib/telemetry/telemetry_json.h
@@ -44,6 +44,52 @@ __json_snprintf(char *buf, const int len, const char *format, ...)
return 0; /* nothing written or modified */
}
+static const char control_chars[0x20] = {
+ ['\n'] = 'n',
+ ['\r'] = 'r',
+ ['\t'] = 't',
+};
+
+/**
+ * @internal
+ * Does the same as __json_snprintf(buf, len, "\"%s\"", str)
+ * except that it does proper escaping as necessary.
+ * Drops any invalid characters we don't support
+ */
+static inline int
+__json_format_str(char *buf, const int len, const char *str)
+{
+ char tmp[len];
+ int tmpidx = 0;
+
+ tmp[tmpidx++] = '"';
+ while (*str != '\0') {
+ if (*str < (int)RTE_DIM(control_chars)) {
+ int idx = *str; /* compilers don't like char type as index */
+ if (control_chars[idx] != 0) {
+ tmp[tmpidx++] = '\\';
+ tmp[tmpidx++] = control_chars[idx];
+ }
+ } else if (*str == '"' || *str == '\\') {
+ tmp[tmpidx++] = '\\';
+ tmp[tmpidx++] = *str;
+ } else
+ tmp[tmpidx++] = *str;
+ /* we always need space for closing quote and null character.
+ * Ensuring at least two free characters also means we can always take an
+ * escaped character like "\n" without overflowing
+ */
+ if (tmpidx > len - 2)
+ return 0;
+ str++;
+ }
+ tmp[tmpidx++] = '"';
+ tmp[tmpidx] = '\0';
+
+ strcpy(buf, tmp);
+ return tmpidx;
+}
+
/* Copies an empty array into the provided buffer. */
static inline int
rte_tel_json_empty_array(char *buf, const int len, const int used)
@@ -62,7 +108,7 @@ rte_tel_json_empty_obj(char *buf, const int len, const int used)
static inline int
rte_tel_json_str(char *buf, const int len, const int used, const char *str)
{
- return used + __json_snprintf(buf + used, len - used, "\"%s\"", str);
+ return used + __json_format_str(buf + used, len - used, str);
}
/* Appends a string into the JSON array in the provided buffer. */
--
2.23.0

View File

@ -0,0 +1,97 @@
From df367f0febc7e5ea999f119f420d30a953268503 Mon Sep 17 00:00:00 2001
From: Bruce Richardson <bruce.richardson@intel.com>
Date: Fri, 21 Oct 2022 15:37:01 +0800
Subject: [PATCH 185/189] telemetry: add escaping of strings in arrays
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When strings are added to an array variable, we need to properly escape
the invalid json characters in the strings.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
lib/telemetry/telemetry_json.h | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
index 13df5d07e3..c4442a0bf0 100644
--- a/lib/telemetry/telemetry_json.h
+++ b/lib/telemetry/telemetry_json.h
@@ -52,17 +52,22 @@ static const char control_chars[0x20] = {
/**
* @internal
- * Does the same as __json_snprintf(buf, len, "\"%s\"", str)
- * except that it does proper escaping as necessary.
+ * This function acts the same as __json_snprintf(buf, len, "%s%s%s", prefix, str, suffix)
+ * except that it does proper escaping of "str" as necessary. Prefix and suffix should be compile-
+ * time constants not needing escaping.
* Drops any invalid characters we don't support
*/
static inline int
-__json_format_str(char *buf, const int len, const char *str)
+__json_format_str(char *buf, const int len, const char *prefix, const char *str, const char *suffix)
{
char tmp[len];
int tmpidx = 0;
- tmp[tmpidx++] = '"';
+ while (*prefix != '\0' && tmpidx < len)
+ tmp[tmpidx++] = *prefix++;
+ if (tmpidx >= len)
+ return 0;
+
while (*str != '\0') {
if (*str < (int)RTE_DIM(control_chars)) {
int idx = *str; /* compilers don't like char type as index */
@@ -75,7 +80,7 @@ __json_format_str(char *buf, const int len, const char *str)
tmp[tmpidx++] = *str;
} else
tmp[tmpidx++] = *str;
- /* we always need space for closing quote and null character.
+ /* we always need space for (at minimum) closing quote and null character.
* Ensuring at least two free characters also means we can always take an
* escaped character like "\n" without overflowing
*/
@@ -83,7 +88,12 @@ __json_format_str(char *buf, const int len, const char *str)
return 0;
str++;
}
- tmp[tmpidx++] = '"';
+
+ while (*suffix != '\0' && tmpidx < len)
+ tmp[tmpidx++] = *suffix++;
+ if (tmpidx >= len)
+ return 0;
+
tmp[tmpidx] = '\0';
strcpy(buf, tmp);
@@ -108,7 +118,7 @@ rte_tel_json_empty_obj(char *buf, const int len, const int used)
static inline int
rte_tel_json_str(char *buf, const int len, const int used, const char *str)
{
- return used + __json_format_str(buf + used, len - used, str);
+ return used + __json_format_str(buf + used, len - used, "\"", str, "\"");
}
/* Appends a string into the JSON array in the provided buffer. */
@@ -118,9 +128,9 @@ rte_tel_json_add_array_string(char *buf, const int len, const int used,
{
int ret, end = used - 1; /* strip off final delimiter */
if (used <= 2) /* assume empty, since minimum is '[]' */
- return __json_snprintf(buf, len, "[\"%s\"]", str);
+ return __json_format_str(buf, len, "[\"", str, "\"]");
- ret = __json_snprintf(buf + end, len - end, ",\"%s\"]", str);
+ ret = __json_format_str(buf + end, len - end, ",\"", str, "\"]");
return ret == 0 ? used : end + ret;
}
--
2.23.0

View File

@ -0,0 +1,55 @@
From c3036c497f29f4acf6423a88f59963781af3eafd Mon Sep 17 00:00:00 2001
From: Bruce Richardson <bruce.richardson@intel.com>
Date: Fri, 21 Oct 2022 15:37:02 +0800
Subject: [PATCH 186/189] telemetry: add escaping of strings in dicts
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When strings are added to an dict variable, we need to properly escape
the invalid json characters in the strings.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
lib/telemetry/telemetry_json.h | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
index c4442a0bf0..e3fae7c30d 100644
--- a/lib/telemetry/telemetry_json.h
+++ b/lib/telemetry/telemetry_json.h
@@ -54,7 +54,7 @@ static const char control_chars[0x20] = {
* @internal
* This function acts the same as __json_snprintf(buf, len, "%s%s%s", prefix, str, suffix)
* except that it does proper escaping of "str" as necessary. Prefix and suffix should be compile-
- * time constants not needing escaping.
+ * time constants, or values not needing escaping.
* Drops any invalid characters we don't support
*/
static inline int
@@ -219,12 +219,16 @@ static inline int
rte_tel_json_add_obj_str(char *buf, const int len, const int used,
const char *name, const char *val)
{
+ char tmp_name[RTE_TEL_MAX_STRING_LEN + 5];
int ret, end = used - 1;
+
+ /* names are limited to certain characters so need no escaping */
+ snprintf(tmp_name, sizeof(tmp_name), "{\"%s\":\"", name);
if (used <= 2) /* assume empty, since minimum is '{}' */
- return __json_snprintf(buf, len, "{\"%s\":\"%s\"}", name, val);
+ return __json_format_str(buf, len, tmp_name, val, "\"}");
- ret = __json_snprintf(buf + end, len - end, ",\"%s\":\"%s\"}",
- name, val);
+ tmp_name[0] = ','; /* replace '{' with ',' at start */
+ ret = __json_format_str(buf + end, len - end, tmp_name, val, "\"}");
return ret == 0 ? used : end + ret;
}
--
2.23.0

View File

@ -0,0 +1,55 @@
From 585eeea3522ce2225a1df94fcc0b8aec2d881b44 Mon Sep 17 00:00:00 2001
From: Bruce Richardson <bruce.richardson@intel.com>
Date: Fri, 21 Oct 2022 15:37:03 +0800
Subject: [PATCH 187/189] telemetry: limit command characters
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Limit the telemetry command characters to the minimum set needed for
current implementations. This prevents issues with invalid json
characters needing to be escaped on replies.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
lib/telemetry/telemetry.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index d4a7838ded..f0be50b2bf 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -3,6 +3,7 @@
*/
#ifndef RTE_EXEC_ENV_WINDOWS
+#include <ctype.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/socket.h>
@@ -71,12 +72,19 @@ int
rte_telemetry_register_cmd(const char *cmd, telemetry_cb fn, const char *help)
{
struct cmd_callback *new_callbacks;
+ const char *cmdp = cmd;
int i = 0;
if (strlen(cmd) >= MAX_CMD_LEN || fn == NULL || cmd[0] != '/'
|| strlen(help) >= RTE_TEL_MAX_STRING_LEN)
return -EINVAL;
+ while (*cmdp != '\0') {
+ if (!isalnum(*cmdp) && *cmdp != '_' && *cmdp != '/')
+ return -EINVAL;
+ cmdp++;
+ }
+
rte_spinlock_lock(&callback_sl);
new_callbacks = realloc(callbacks, sizeof(callbacks[0]) * (num_callbacks + 1));
if (new_callbacks == NULL) {
--
2.23.0

View File

@ -0,0 +1,103 @@
From c89a9af036a9063903537404d615bed04a700e5b Mon Sep 17 00:00:00 2001
From: Bruce Richardson <bruce.richardson@intel.com>
Date: Fri, 21 Oct 2022 15:37:04 +0800
Subject: [PATCH 188/189] telemetry: eliminate duplicate code for json output
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When preparing the json response to a telemetry socket query, the code
for prefixing the command name, and appending the file "}" on the end of
the response was duplicated for multiple reply types. Taking this code
out of the switch statement reduces the duplication and makes the code
more maintainable.
For completeness of testing, add in a test case to validate the "null"
response type - the only leg of the switch statement not already covered
by an existing test case in the telemetry_data tests.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
lib/telemetry/telemetry.c | 35 ++++++++++++-----------------------
1 file changed, 12 insertions(+), 23 deletions(-)
diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index f0be50b2bf..25ab6ed877 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -235,27 +235,22 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
RTE_BUILD_BUG_ON(sizeof(out_buf) < MAX_CMD_LEN +
RTE_TEL_MAX_SINGLE_STRING_LEN + 10);
+
+ prefix_used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":",
+ MAX_CMD_LEN, cmd);
+ cb_data_buf = &out_buf[prefix_used];
+ buf_len = sizeof(out_buf) - prefix_used - 1; /* space for '}' */
+
switch (d->type) {
case RTE_TEL_NULL:
- used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":null}",
- MAX_CMD_LEN, cmd ? cmd : "none");
+ used = strlcpy(cb_data_buf, "null", buf_len);
break;
- case RTE_TEL_STRING:
- prefix_used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":",
- MAX_CMD_LEN, cmd);
- cb_data_buf = &out_buf[prefix_used];
- buf_len = sizeof(out_buf) - prefix_used - 1; /* space for '}' */
+ case RTE_TEL_STRING:
used = rte_tel_json_str(cb_data_buf, buf_len, 0, d->data.str);
- used += prefix_used;
- used += strlcat(out_buf + used, "}", sizeof(out_buf) - used);
break;
- case RTE_TEL_DICT:
- prefix_used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":",
- MAX_CMD_LEN, cmd);
- cb_data_buf = &out_buf[prefix_used];
- buf_len = sizeof(out_buf) - prefix_used - 1; /* space for '}' */
+ case RTE_TEL_DICT:
used = rte_tel_json_empty_obj(cb_data_buf, buf_len, 0);
for (i = 0; i < d->data_len; i++) {
const struct tel_dict_entry *v = &d->data.dict[i];
@@ -291,18 +286,12 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
}
}
}
- used += prefix_used;
- used += strlcat(out_buf + used, "}", sizeof(out_buf) - used);
break;
+
case RTE_TEL_ARRAY_STRING:
case RTE_TEL_ARRAY_INT:
case RTE_TEL_ARRAY_U64:
case RTE_TEL_ARRAY_CONTAINER:
- prefix_used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":",
- MAX_CMD_LEN, cmd);
- cb_data_buf = &out_buf[prefix_used];
- buf_len = sizeof(out_buf) - prefix_used - 1; /* space for '}' */
-
used = rte_tel_json_empty_array(cb_data_buf, buf_len, 0);
for (i = 0; i < d->data_len; i++)
if (d->type == RTE_TEL_ARRAY_STRING)
@@ -330,10 +319,10 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
if (!rec_data->keep)
rte_tel_data_free(rec_data->data);
}
- used += prefix_used;
- used += strlcat(out_buf + used, "}", sizeof(out_buf) - used);
break;
}
+ used += prefix_used;
+ used += strlcat(out_buf + used, "}", sizeof(out_buf) - used);
if (write(s, out_buf, used) < 0)
perror("Error writing to socket");
}
--
2.23.0

View File

@ -0,0 +1,52 @@
From 2674bf9f28b9dd7724d72096a8e54b19400239bd Mon Sep 17 00:00:00 2001
From: Bruce Richardson <bruce.richardson@intel.com>
Date: Fri, 21 Oct 2022 15:37:05 +0800
Subject: [PATCH 189/189] telemetry: make help command more helpful
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The /help telemetry command prints out the help text for the given
command passed in as parameter. However, entering /help without any
parameters does not give any useful information as to the fact that you
need to pass in a command to get help on. Update the command so it
prints its own help text when called without any parameters.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
lib/telemetry/telemetry.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index 25ab6ed877..52048de55c 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -141,15 +141,17 @@ command_help(const char *cmd __rte_unused, const char *params,
struct rte_tel_data *d)
{
int i;
+ /* if no parameters return our own help text */
+ const char *to_lookup = (params == NULL ? cmd : params);
- if (!params)
- return -1;
rte_tel_data_start_dict(d);
rte_spinlock_lock(&callback_sl);
for (i = 0; i < num_callbacks; i++)
- if (strcmp(params, callbacks[i].cmd) == 0) {
- rte_tel_data_add_dict_string(d, params,
- callbacks[i].help);
+ if (strcmp(to_lookup, callbacks[i].cmd) == 0) {
+ if (params == NULL)
+ rte_tel_data_string(d, callbacks[i].help);
+ else
+ rte_tel_data_add_dict_string(d, params, callbacks[i].help);
break;
}
rte_spinlock_unlock(&callback_sl);
--
2.23.0

View File

@ -1,6 +1,6 @@
Name: dpdk
Version: 21.11
Release: 18
Release: 19
Packager: packaging@6wind.com
URL: http://dpdk.org
%global source_version 21.11
@ -137,6 +137,72 @@ Patch6003: backport-0001-CVE-2022-2132.patch
Patch6004: backport-0002-CVE-2022-2132.patch
Patch6005: backport-CVE-2022-28199.patch
Patch9125: 0125-net-hns3-fix-link-status-capability-query-from-VF.patch
Patch9126: 0126-net-hns3-support-backplane-media-type.patch
Patch9127: 0127-net-hns3-cancel-heartbeat-alarm-when-VF-reset.patch
Patch9128: 0128-net-hns3-fix-PTP-interrupt-logging.patch
Patch9129: 0129-net-hns3-fix-statistics-locking.patch
Patch9130: 0130-net-hns3-fix-descriptors-check-with-SVE.patch
Patch9131: 0131-net-hns3-clean-some-functions.patch
Patch9132: 0132-net-hns3-delete-unused-code.patch
Patch9133: 0133-examples-dma-support-dequeue-when-no-packet-received.patch
Patch9134: 0134-net-hns3-add-dump-of-VF-VLAN-filter-modify-capabilit.patch
Patch9135: 0135-net-hns3-fix-Rx-with-PTP.patch
Patch9136: 0136-net-hns3-fix-crash-in-SVE-Tx.patch
Patch9137: 0137-net-hns3-fix-next-to-use-overflow-in-SVE-Tx.patch
Patch9138: 0138-net-hns3-fix-next-to-use-overflow-in-simple-Tx.patch
Patch9139: 0139-net-hns3-optimize-SVE-Tx-performance.patch
Patch9140: 0140-net-hns3-fix-crash-when-secondary-process-access-FW.patch
Patch9141: 0141-net-hns3-delete-unused-markup.patch
Patch9142: 0142-net-hns3-fix-clearing-hardware-MAC-statistics.patch
Patch9143: 0143-net-hns3-revert-Tx-performance-optimization.patch
Patch9144: 0144-net-hns3-fix-RSS-rule-restore.patch
Patch9145: 0145-net-hns3-fix-RSS-filter-restore.patch
Patch9146: 0146-net-hns3-fix-lock-protection-of-RSS-flow-rule.patch
Patch9147: 0147-net-hns3-fix-RSS-flow-rule-restore.patch
Patch9148: 0148-net-hns3-move-flow-direction-rule-recovery.patch
Patch9149: 0149-net-hns3-fix-restore-filter-function-input.patch
Patch9150: 0150-net-hns3-fix-build-with-gcov.patch
Patch9151: 0151-net-hns3-fix-packet-type-for-GENEVE.patch
Patch9152: 0152-net-hns3-remove-magic-numbers-for-MAC-address.patch
Patch9153: 0153-net-hns3-fix-code-check-warnings.patch
Patch9154: 0154-net-hns3-fix-header-files-includes.patch
Patch9155: 0155-net-hns3-remove-unused-structures.patch
Patch9156: 0156-net-hns3-rename-header-guards.patch
Patch9157: 0157-net-hns3-fix-IPv4-and-IPv6-RSS.patch
Patch9158: 0158-net-hns3-fix-types-in-IPv6-SCTP-fields.patch
Patch9159: 0159-net-hns3-fix-IPv4-RSS.patch
Patch9160: 0160-net-hns3-add-check-for-L3-and-L4-type.patch
Patch9161: 0161-net-hns3-revert-fix-mailbox-communication-with-HW.patch
Patch9162: 0162-net-hns3-fix-VF-mailbox-message-handling.patch
Patch9163: 0163-net-hns3-fix-minimum-Tx-frame-length.patch
Patch9164: 0164-ethdev-introduce-Rx-Tx-descriptor-dump-API.patch
Patch9165: 0165-net-hns3-support-Rx-Tx-descriptor-dump.patch
Patch9166: 0166-remove-unnecessary-null-checks.patch
Patch9167: 0167-ethdev-introduce-generic-dummy-packet-burst-function.patch
Patch9168: 0168-fix-spelling-in-comments-and-strings.patch
Patch9169: 0169-net-hns3-add-VLAN-filter-query-in-dump-file.patch
Patch9170: 0170-net-bonding-fix-array-overflow-in-Rx-burst.patch
Patch9171: 0171-net-bonding-fix-double-slave-link-status-query.patch
Patch9172: 0172-app-testpmd-fix-supported-RSS-offload-display.patch
Patch9173: 0173-app-testpmd-unify-name-of-L2-payload-offload.patch
Patch9174: 0174-app-testpmd-refactor-config-all-RSS-command.patch
Patch9175: 0175-app-testpmd-unify-RSS-types-display.patch
Patch9176: 0176-app-testpmd-compact-RSS-types-output.patch
Patch9177: 0177-app-testpmd-reorder-RSS-type-table.patch
Patch9178: 0178-app-testpmd-fix-RSS-types-display.patch
Patch9179: 0179-ethdev-support-telemetry-private-dump.patch
Patch9180: 0180-dmadev-add-telemetry.patch
Patch9181: 0181-dmadev-support-telemetry-dump-dmadev.patch
Patch9182: 0182-telemetry-add-missing-C-guards.patch
Patch9183: 0183-telemetry-limit-characters-allowed-in-dictionary-nam.patch
Patch9184: 0184-telemetry-fix-escaping-of-invalid-json-characters.patch
Patch9185: 0185-telemetry-add-escaping-of-strings-in-arrays.patch
Patch9186: 0186-telemetry-add-escaping-of-strings-in-dicts.patch
Patch9187: 0187-telemetry-limit-command-characters.patch
Patch9188: 0188-telemetry-eliminate-duplicate-code-for-json-output.patch
Patch9189: 0189-telemetry-make-help-command-more-helpful.patch
Summary: Data Plane Development Kit core
Group: System Environment/Libraries
License: BSD and LGPLv2 and GPLv2
@ -264,6 +330,17 @@ strip -g $RPM_BUILD_ROOT/lib/modules/%{kern_devel_ver}/extra/dpdk/igb_uio.ko
/usr/sbin/depmod
%changelog
* Sat Oct 22 2022 Huisong Li <lihuisong@huawei.com> - 21.11-19
Sync some patches for hns3 PMD, telemetry and testpmd. And main
modifications are as follows:
- backport some bugfixes for hns3
- revert Tx performance optimization for hns3
- add Rx/Tx descriptor dump feature for hns3
- refactor some RSS commands for testpmd
- add ethdev telemetry private dump
- add dmadev telemetry
- sync telemetry lib
* Thu Oct 6 2022 wuchangsheng <wuchangsheng2@huawei.com> - 21.11-18
- reinit support return ok