sync patches for 22.03

Signed-off-by: speech_white <humin29@huawei.com>
(cherry picked from commit 39c2c5154122fef74060ffd6dbbe8cd4fdd9d21b)
This commit is contained in:
speech_white 2022-05-17 19:55:36 +08:00 committed by openeuler-sync-bot
parent 8c61f7172a
commit 62a20ce454
41 changed files with 4827 additions and 1 deletions

View File

@ -0,0 +1,129 @@
From 42a26d7136b259ee7ff1b39325e19ef5ef9fe0e3 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Fri, 11 Feb 2022 12:49:22 +0800
Subject: [PATCH 01/13] ethdev: introduce dump API
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Added the ethdev dump API which provides querying private info from device.
There exists many private properties in different PMD drivers, such as
adapter state, Rx/Tx func algorithm in hns3 PMD. The information of these
properties is important for debug. As the information is private, the new
API is introduced.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Ray Kinsella <mdr@ashroe.eu>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
lib/ethdev/ethdev_driver.h | 23 +++++++++++++++++++++++
lib/ethdev/rte_ethdev.c | 17 +++++++++++++++++
lib/ethdev/rte_ethdev.h | 21 +++++++++++++++++++++
3 files changed, 61 insertions(+)
diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h
index d95605a355..e24ff7064c 100644
--- a/lib/ethdev/ethdev_driver.h
+++ b/lib/ethdev/ethdev_driver.h
@@ -990,6 +990,26 @@ typedef int (*eth_representor_info_get_t)(struct rte_eth_dev *dev,
typedef int (*eth_rx_metadata_negotiate_t)(struct rte_eth_dev *dev,
uint64_t *features);
+/**
+
+ * @internal
+ * Dump private info from device to a file.
+ *
+ * @param dev
+ * Port (ethdev) handle.
+ * @param file
+ * A pointer to a file for output.
+ *
+ * @return
+ * Negative value on error, 0 on success.
+ *
+ * @retval 0
+ * Success
+ * @retval -EINVAL
+ * Invalid file
+ */
+typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file);
+
/**
* @internal A structure containing the functions exported by an Ethernet driver.
*/
@@ -1186,6 +1206,9 @@ struct eth_dev_ops {
* kinds of metadata to the PMD
*/
eth_rx_metadata_negotiate_t rx_metadata_negotiate;
+
+ /** Dump private info from device */
+ eth_dev_priv_dump_t eth_dev_priv_dump;
};
/**
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index a1d475a292..b9a452107f 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -6472,6 +6472,23 @@ rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features)
(*dev->dev_ops->rx_metadata_negotiate)(dev, features));
}
+int
+rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)
+{
+ struct rte_eth_dev *dev;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+ dev = &rte_eth_devices[port_id];
+
+ if (file == NULL) {
+ RTE_ETHDEV_LOG(ERR, "Invalid file (NULL)\n");
+ return -EINVAL;
+ }
+
+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->eth_dev_priv_dump, -ENOTSUP);
+ return eth_err(port_id, (*dev->dev_ops->eth_dev_priv_dump)(dev, 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 fa299c8ad7..b8f135ba3f 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -5188,6 +5188,27 @@ int rte_eth_representor_info_get(uint16_t port_id,
__rte_experimental
int rte_eth_rx_metadata_negotiate(uint16_t port_id, uint64_t *features);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Dump private info from device to a file. Provided data and the order depends
+ * on the PMD.
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ * @param file
+ * A pointer to a file for output.
+ * @return
+ * - (0) on success.
+ * - (-ENODEV) if *port_id* is invalid.
+ * - (-EINVAL) if null file.
+ * - (-ENOTSUP) if the device does not support this function.
+ * - (-EIO) if device is removed.
+ */
+__rte_experimental
+int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file);
+
#include <rte_ethdev_core.h>
/**
--
2.30.0

View File

@ -0,0 +1,90 @@
From a91c0f253dd9b31cbe30bf5470a818aa0a909e26 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Sat, 19 Feb 2022 09:37:46 +0800
Subject: [PATCH 02/13] app/procinfo: add device private info dump
This patch adds support for dump the device private info from a running
application. It can help developers locate the problem.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
app/proc-info/main.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index ce140aaf84..fbc1715ce9 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -84,6 +84,8 @@ static char bdr_str[MAX_STRING_LEN];
/**< Enable show port. */
static uint32_t enable_shw_port;
+/**< Enable show port private info. */
+static uint32_t enable_shw_port_priv;
/**< Enable show tm. */
static uint32_t enable_shw_tm;
/**< Enable show crypto. */
@@ -123,6 +125,7 @@ proc_info_usage(const char *prgname)
" --collectd-format: to print statistics to STDOUT in expected by collectd format\n"
" --host-id STRING: host id used to identify the system process is running on\n"
" --show-port: to display ports information\n"
+ " --show-port-private: to display ports private information\n"
" --show-tm: to display traffic manager information for ports\n"
" --show-crypto: to display crypto information\n"
" --show-ring[=name]: to display ring information\n"
@@ -232,6 +235,7 @@ proc_info_parse_args(int argc, char **argv)
{"xstats-ids", 1, NULL, 1},
{"host-id", 0, NULL, 0},
{"show-port", 0, NULL, 0},
+ {"show-port-private", 0, NULL, 0},
{"show-tm", 0, NULL, 0},
{"show-crypto", 0, NULL, 0},
{"show-ring", optional_argument, NULL, 0},
@@ -284,6 +288,9 @@ proc_info_parse_args(int argc, char **argv)
else if (!strncmp(long_option[option_index].name,
"show-port", MAX_LONG_OPT_SZ))
enable_shw_port = 1;
+ else if (!strncmp(long_option[option_index].name,
+ "show-port-private", MAX_LONG_OPT_SZ))
+ enable_shw_port_priv = 1;
else if (!strncmp(long_option[option_index].name,
"show-tm", MAX_LONG_OPT_SZ))
enable_shw_tm = 1;
@@ -887,6 +894,25 @@ show_port(void)
}
}
+static void
+show_port_private_info(void)
+{
+ int i;
+
+ snprintf(bdr_str, MAX_STRING_LEN, " show - Port PMD Private ");
+ STATS_BDR_STR(10, bdr_str);
+
+ RTE_ETH_FOREACH_DEV(i) {
+ /* Skip if port is not in mask */
+ if ((enabled_port_mask & (1ul << i)) == 0)
+ continue;
+
+ snprintf(bdr_str, MAX_STRING_LEN, " Port %u ", i);
+ STATS_BDR_STR(5, bdr_str);
+ rte_eth_dev_priv_dump(i, stdout);
+ }
+}
+
static void
display_nodecap_info(int is_leaf, struct rte_tm_node_capabilities *cap)
{
@@ -1549,6 +1575,8 @@ main(int argc, char **argv)
/* show information for PMD */
if (enable_shw_port)
show_port();
+ if (enable_shw_port_priv)
+ show_port_private_info();
if (enable_shw_tm)
show_tm();
if (enable_shw_crypto)
--
2.30.0

View File

@ -0,0 +1,174 @@
From c79d78f63ba993a7fb45b7c842cfcfefb38ba5b6 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Fri, 11 Feb 2022 10:42:46 +0800
Subject: [PATCH 03/13] net/hns3: dump device basic info
This patch dumps device basic info such as device name, adapter state
for debug.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 1 +
drivers/net/hns3/hns3_ethdev.h | 1 +
drivers/net/hns3/hns3_ethdev_dump.c | 99 +++++++++++++++++++++++++++++
drivers/net/hns3/hns3_ethdev_vf.c | 1 +
drivers/net/hns3/meson.build | 1 +
5 files changed, 103 insertions(+)
create mode 100644 drivers/net/hns3/hns3_ethdev_dump.c
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 13ebcde002..a9394eeeff 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -6568,6 +6568,7 @@ static const struct eth_dev_ops hns3_eth_dev_ops = {
.timesync_adjust_time = hns3_timesync_adjust_time,
.timesync_read_time = hns3_timesync_read_time,
.timesync_write_time = hns3_timesync_write_time,
+ .eth_dev_priv_dump = hns3_eth_dev_priv_dump,
};
static const struct hns3_reset_ops hns3_reset_ops = {
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index d62884cd9b..412626c053 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -1055,6 +1055,7 @@ int hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts);
int hns3_timesync_write_time(struct rte_eth_dev *dev,
const struct timespec *ts);
int hns3_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
+int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file);
static inline bool
is_reset_pending(struct hns3_adapter *hns)
diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c
new file mode 100644
index 0000000000..bd95184b02
--- /dev/null
+++ b/drivers/net/hns3/hns3_ethdev_dump.c
@@ -0,0 +1,99 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2022 HiSilicon Limited
+ */
+
+#include <rte_kvargs.h>
+#include <rte_bus_pci.h>
+#include <ethdev_pci.h>
+#include <rte_pci.h>
+
+#include "hns3_common.h"
+#include "hns3_logs.h"
+#include "hns3_regs.h"
+#include "hns3_rxtx.h"
+
+static const char *
+hns3_get_adapter_state_name(uint32_t state)
+{
+ static const char * const state_name[] = {
+ "UNINITIALIZED",
+ "INITIALIZED",
+ "CONFIGURING",
+ "CONFIGURED",
+ "STARTING",
+ "STARTED",
+ "STOPPING",
+ "CLOSING",
+ "CLOSED",
+ "REMOVED",
+ "NSTATES"
+ };
+
+ if (state < RTE_DIM(state_name))
+ return state_name[state];
+ else
+ return "unknown";
+}
+
+static const char *
+hns3_get_io_func_hint_name(uint32_t hint)
+{
+ switch (hint) {
+ case HNS3_IO_FUNC_HINT_NONE:
+ return "none";
+ case HNS3_IO_FUNC_HINT_VEC:
+ return "vec";
+ case HNS3_IO_FUNC_HINT_SVE:
+ return "sve";
+ case HNS3_IO_FUNC_HINT_SIMPLE:
+ return "simple";
+ case HNS3_IO_FUNC_HINT_COMMON:
+ return "common";
+ default:
+ return "unknown";
+ }
+}
+
+static void
+hns3_get_device_basic_info(FILE *file, struct rte_eth_dev *dev)
+{
+ struct hns3_adapter *hns = dev->data->dev_private;
+ struct hns3_hw *hw = &hns->hw;
+
+ fprintf(file,
+ " - Device Base Info:\n"
+ "\t -- name: %s\n"
+ "\t -- adapter_state=%s\n"
+ "\t -- nb_rx_queues=%u nb_tx_queues=%u\n"
+ "\t -- total_tqps_num=%u tqps_num=%u intr_tqps_num=%u\n"
+ "\t -- rss_size_max=%u alloc_rss_size=%u tx_qnum_per_tc=%u\n"
+ "\t -- min_tx_pkt_len=%u intr_mapping_mode=%u vlan_mode=%u\n"
+ "\t -- tso_mode=%u max_non_tso_bd_num=%u\n"
+ "\t -- max_tm_rate=%u Mbps\n"
+ "\t -- set link down: %s\n"
+ "\t -- rx_func_hint=%s tx_func_hint=%s\n"
+ "\t -- dev_flags: lsc=%d\n"
+ "\t -- intr_conf: lsc=%u rxq=%u\n",
+ dev->data->name,
+ hns3_get_adapter_state_name(hw->adapter_state),
+ dev->data->nb_rx_queues, dev->data->nb_tx_queues,
+ hw->total_tqps_num, hw->tqps_num, hw->intr_tqps_num,
+ hw->rss_size_max, hw->alloc_rss_size, hw->tx_qnum_per_tc,
+ hw->min_tx_pkt_len, hw->intr.mapping_mode, hw->vlan_mode,
+ hw->tso_mode, hw->max_non_tso_bd_num,
+ hw->max_tm_rate,
+ hw->set_link_down ? "Yes" : "No",
+ hns3_get_io_func_hint_name(hns->rx_func_hint),
+ hns3_get_io_func_hint_name(hns->tx_func_hint),
+ !!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC),
+ dev->data->dev_conf.intr_conf.lsc,
+ dev->data->dev_conf.intr_conf.rxq);
+}
+
+int
+hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
+{
+ hns3_get_device_basic_info(file, dev);
+
+ return 0;
+}
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 5f905c515c..aee0c36360 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -2290,6 +2290,7 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = {
.get_reg = hns3_get_regs,
.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,
};
static const struct hns3_reset_ops hns3vf_reset_ops = {
diff --git a/drivers/net/hns3/meson.build b/drivers/net/hns3/meson.build
index 8a4c7cc100..665b2afedf 100644
--- a/drivers/net/hns3/meson.build
+++ b/drivers/net/hns3/meson.build
@@ -30,6 +30,7 @@ sources = files(
'hns3_tm.c',
'hns3_ptp.c',
'hns3_common.c',
+ 'hns3_ethdev_dump.c',
)
deps += ['hash']
--
2.30.0

View File

@ -0,0 +1,63 @@
From 9bbea26d3c903f5741447a1b1a943d02b275af56 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Fri, 11 Feb 2022 10:52:06 +0800
Subject: [PATCH 04/13] net/hns3: dump device feature capability
Kunpeng 920 and Kunpeng 930 support different feature capability.
This patch dumps feature capability Current device supports.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_ethdev_dump.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c
index bd95184b02..a0fa0a3584 100644
--- a/drivers/net/hns3/hns3_ethdev_dump.c
+++ b/drivers/net/hns3/hns3_ethdev_dump.c
@@ -55,6 +55,30 @@ hns3_get_io_func_hint_name(uint32_t hint)
}
static void
+hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw)
+{
+ const char * const caps_name[] = {
+ "DCB",
+ "COPPER",
+ "FD QUEUE REGION",
+ "PTP",
+ "TX PUSH",
+ "INDEP TXRX",
+ "STASH",
+ "SIMPLE BD",
+ "RXD Advanced Layout",
+ "OUTER UDP CKSUM",
+ "RAS IMP",
+ "TM",
+ };
+ uint32_t i;
+
+ fprintf(file, " - Dev Capability:\n");
+ for (i = 0; i < RTE_DIM(caps_name); i++)
+ fprintf(file, "\t -- support %s: %s\n", caps_name[i],
+ hw->capability & BIT(i) ? "yes" : "no");
+}
+
hns3_get_device_basic_info(FILE *file, struct rte_eth_dev *dev)
{
struct hns3_adapter *hns = dev->data->dev_private;
@@ -93,7 +117,11 @@ hns3_get_device_basic_info(FILE *file, struct rte_eth_dev *dev)
int
hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
{
+ struct hns3_adapter *hns = dev->data->dev_private;
+ struct hns3_hw *hw = &hns->hw;
+
hns3_get_device_basic_info(file, dev);
+ hns3_get_dev_feature_capability(file, hw);
return 0;
}
--
2.30.0

View File

@ -0,0 +1,63 @@
From 7041258cda77065d991d6ee8913edf110bd12531 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Fri, 11 Feb 2022 10:56:54 +0800
Subject: [PATCH 05/13] net/hns3: dump device MAC info
This patch dumps device MAC info which hns3 PMD private info offers.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_ethdev_dump.c | 31 +++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c
index a0fa0a3584..83601d9bda 100644
--- a/drivers/net/hns3/hns3_ethdev_dump.c
+++ b/drivers/net/hns3/hns3_ethdev_dump.c
@@ -54,6 +54,28 @@ hns3_get_io_func_hint_name(uint32_t hint)
}
}
+static void
+hns3_get_dev_mac_info(FILE *file, struct hns3_adapter *hns)
+{
+ struct hns3_hw *hw = &hns->hw;
+ struct hns3_pf *pf = &hns->pf;
+
+ fprintf(file, " - MAC Info:\n");
+ fprintf(file,
+ "\t -- query_type=%u\n"
+ "\t -- supported_speed=0x%x\n"
+ "\t -- advertising=0x%x\n"
+ "\t -- lp_advertising=0x%x\n"
+ "\t -- support_autoneg=%s\n"
+ "\t -- support_fc_autoneg=%s\n",
+ hw->mac.query_type,
+ hw->mac.supported_speed,
+ hw->mac.advertising,
+ hw->mac.lp_advertising,
+ hw->mac.support_autoneg != 0 ? "Yes" : "No",
+ pf->support_fc_autoneg ? "Yes" : "No");
+}
+
static void
hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw)
{
@@ -123,5 +145,14 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
hns3_get_device_basic_info(file, dev);
hns3_get_dev_feature_capability(file, hw);
+ /*
+ * VF only supports dumping basic info, feaure capability and queue
+ * info.
+ */
+ if (hns->is_vf)
+ return 0;
+
+ hns3_get_dev_mac_info(file, hns);
+
return 0;
}
--
2.30.0

View File

@ -0,0 +1,254 @@
From 698e42cb7ca963e34b2f8c7e1f9be98a7793bed3 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Fri, 11 Feb 2022 11:03:05 +0800
Subject: [PATCH 06/13] net/hns3: dump queue info
This patch dumps Rx/Tx queue info, such as queue numbers, queue enable
state for debug.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_ethdev_dump.c | 220 ++++++++++++++++++++++++++++
1 file changed, 220 insertions(+)
diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c
index 83601d9bda..face41e4a7 100644
--- a/drivers/net/hns3/hns3_ethdev_dump.c
+++ b/drivers/net/hns3/hns3_ethdev_dump.c
@@ -136,6 +136,225 @@ hns3_get_device_basic_info(FILE *file, struct rte_eth_dev *dev)
dev->data->dev_conf.intr_conf.rxq);
}
+/*
+ * Note: caller must make sure queue_id < nb_queues
+ * nb_queues = RTE_MAX(eth_dev->data->nb_rx_queues,
+ * eth_dev->data->nb_tx_queues)
+ */
+static struct hns3_rx_queue *
+hns3_get_rx_queue(struct rte_eth_dev *dev, uint32_t queue_id)
+{
+ struct hns3_adapter *hns = dev->data->dev_private;
+ struct hns3_hw *hw = &hns->hw;
+ uint32_t offset;
+ void **rx_queues;
+
+ if (queue_id < dev->data->nb_rx_queues) {
+ rx_queues = dev->data->rx_queues;
+ offset = queue_id;
+ } else {
+ /*
+ * For kunpeng930, fake queue is not exist. But since the queues
+ * are usually accessd in pairs, this branch may still exist.
+ */
+ if (hns3_dev_get_support(hw, INDEP_TXRX))
+ return NULL;
+
+ rx_queues = hw->fkq_data.rx_queues;
+ offset = queue_id - dev->data->nb_rx_queues;
+ }
+
+ if (rx_queues != NULL && rx_queues[offset] != NULL)
+ return rx_queues[offset];
+
+ hns3_err(hw, "Detect rx_queues is NULL!\n");
+ return NULL;
+}
+
+/*
+ * Note: caller must make sure queue_id < nb_queues
+ * nb_queues = RTE_MAX(eth_dev->data->nb_rx_queues,
+ * eth_dev->data->nb_tx_queues)
+ */
+static struct hns3_tx_queue *
+hns3_get_tx_queue(struct rte_eth_dev *dev, uint32_t queue_id)
+{
+ struct hns3_adapter *hns = dev->data->dev_private;
+ struct hns3_hw *hw = &hns->hw;
+ uint32_t offset;
+ void **tx_queues;
+
+ if (queue_id < dev->data->nb_tx_queues) {
+ tx_queues = dev->data->tx_queues;
+ offset = queue_id;
+ } else {
+ /*
+ * For kunpeng930, fake queue is not exist. But since the queues
+ * are usually accessd in pairs, this branch may still exist.
+ */
+ if (hns3_dev_get_support(hw, INDEP_TXRX))
+ return NULL;
+ tx_queues = hw->fkq_data.tx_queues;
+ offset = queue_id - dev->data->nb_tx_queues;
+ }
+
+ if (tx_queues != NULL && tx_queues[offset] != NULL)
+ return tx_queues[offset];
+
+ hns3_err(hw, "Detect tx_queues is NULL!\n");
+ return NULL;
+}
+
+static void
+hns3_get_rxtx_fake_queue_info(FILE *file, struct rte_eth_dev *dev)
+{
+ struct hns3_adapter *hns = dev->data->dev_private;
+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns);
+ struct hns3_rx_queue *rxq;
+ struct hns3_tx_queue *txq;
+ uint32_t queue_id;
+
+ if (dev->data->nb_rx_queues != dev->data->nb_tx_queues &&
+ !hns3_dev_get_support(hw, INDEP_TXRX)) {
+ queue_id = RTE_MIN(dev->data->nb_rx_queues,
+ dev->data->nb_tx_queues);
+ rxq = hns3_get_rx_queue(dev, queue_id);
+ if (rxq == NULL)
+ return;
+ txq = hns3_get_tx_queue(dev, queue_id);
+ if (txq == NULL)
+ return;
+ fprintf(file,
+ "\t -- first fake_queue rxtx info:\n"
+ "\t Rx: port=%u nb_desc=%u free_thresh=%u\n"
+ "\t Tx: port=%u nb_desc=%u\n",
+ rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh,
+ txq->port_id, txq->nb_tx_desc);
+ }
+}
+
+static void
+hns3_get_queue_enable_state(struct hns3_hw *hw, uint32_t *queue_state,
+ uint32_t nb_queues, bool is_rxq)
+{
+#define STATE_SIZE (sizeof(*queue_state) * CHAR_BIT)
+ uint32_t queue_en_reg;
+ uint32_t reg_offset;
+ uint32_t state;
+ uint32_t i;
+
+ queue_en_reg = is_rxq ? HNS3_RING_RX_EN_REG : HNS3_RING_TX_EN_REG;
+ for (i = 0; i < nb_queues; i++) {
+ reg_offset = hns3_get_tqp_reg_offset(i);
+ state = hns3_read_dev(hw, reg_offset + HNS3_RING_EN_REG);
+ if (hns3_dev_get_support(hw, INDEP_TXRX))
+ state = state && hns3_read_dev(hw, reg_offset +
+ queue_en_reg);
+ hns3_set_bit(queue_state[i / STATE_SIZE],
+ i % STATE_SIZE, state);
+ }
+}
+
+static void
+hns3_print_queue_state_perline(FILE *file, const uint32_t *queue_state,
+ uint32_t nb_queues, uint32_t line_num)
+{
+#define NUM_QUEUE_PER_LINE (sizeof(*queue_state) * CHAR_BIT)
+ uint32_t qid = line_num * NUM_QUEUE_PER_LINE;
+ uint32_t j;
+
+ for (j = 0; j < NUM_QUEUE_PER_LINE; j++) {
+ fprintf(file, "%1lx", hns3_get_bit(queue_state[line_num], j));
+
+ if (qid % CHAR_BIT == CHAR_BIT - 1) {
+ fprintf(file, "%s",
+ j == NUM_QUEUE_PER_LINE - 1 ? "\n" : ":");
+ }
+ qid++;
+ if (qid >= nb_queues) {
+ fprintf(file, "\n");
+ break;
+ }
+ }
+}
+
+static void
+hns3_display_queue_enable_state(FILE *file, const uint32_t *queue_state,
+ uint32_t nb_queues, bool is_rxq)
+{
+#define NUM_QUEUE_PER_LINE (sizeof(*queue_state) * CHAR_BIT)
+ uint32_t i;
+
+ if (nb_queues == 0) {
+ fprintf(file, "\t %s queue number is 0\n",
+ is_rxq ? "Rx" : "Tx");
+ return;
+ }
+
+ fprintf(file, "\t %s queue id | enable state bitMap\n",
+ is_rxq ? "Rx" : "Tx");
+
+ for (i = 0; i < (nb_queues - 1) / NUM_QUEUE_PER_LINE + 1; i++) {
+ uint32_t line_end = (i + 1) * NUM_QUEUE_PER_LINE - 1;
+ uint32_t line_start = i * NUM_QUEUE_PER_LINE;
+ fprintf(file, "\t %04u - %04u | ", line_start,
+ nb_queues - 1 > line_end ? line_end : nb_queues - 1);
+
+ hns3_print_queue_state_perline(file, queue_state, nb_queues, i);
+ }
+}
+
+static void
+hns3_get_rxtx_queue_enable_state(FILE *file, struct rte_eth_dev *dev)
+{
+#define MAX_TQP_NUM 1280
+#define QUEUE_BITMAP_SIZE (MAX_TQP_NUM / 32)
+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ uint32_t rx_queue_state[QUEUE_BITMAP_SIZE] = {0};
+ uint32_t tx_queue_state[QUEUE_BITMAP_SIZE] = {0};
+ uint32_t nb_rx_queues;
+ uint32_t nb_tx_queues;
+
+ nb_rx_queues = dev->data->nb_rx_queues;
+ nb_tx_queues = dev->data->nb_tx_queues;
+
+ 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,
+ true);
+
+ hns3_get_queue_enable_state(hw, tx_queue_state, nb_tx_queues, false);
+ hns3_display_queue_enable_state(file, tx_queue_state, nb_tx_queues,
+ false);
+}
+
+static void
+hns3_get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev)
+{
+ struct hns3_rx_queue *rxq;
+ struct hns3_tx_queue *txq;
+ uint32_t queue_id = 0;
+
+ rxq = hns3_get_rx_queue(dev, queue_id);
+ if (rxq == NULL)
+ return;
+ txq = hns3_get_tx_queue(dev, queue_id);
+ if (txq == NULL)
+ return;
+ fprintf(file, " - Rx/Tx Queue Info:\n");
+ fprintf(file,
+ "\t -- first queue rxtx info:\n"
+ "\t Rx: port=%u nb_desc=%u free_thresh=%u\n"
+ "\t Tx: port=%u nb_desc=%u\n"
+ "\t -- tx push: %s\n",
+ rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh,
+ txq->port_id, txq->nb_tx_desc,
+ txq->tx_push_enable ? "enabled" : "disabled");
+
+ hns3_get_rxtx_fake_queue_info(file, dev);
+ hns3_get_rxtx_queue_enable_state(file, dev);
+}
+
int
hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
{
@@ -144,6 +363,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
hns3_get_device_basic_info(file, dev);
hns3_get_dev_feature_capability(file, hw);
+ hns3_get_rxtx_queue_info(file, dev);
/*
* VF only supports dumping basic info, feaure capability and queue
--
2.30.0

View File

@ -0,0 +1,180 @@
From 05e415e929a404187f6b595a0b0f1ea958c1ca12 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Fri, 11 Feb 2022 11:06:55 +0800
Subject: [PATCH 07/13] net/hns3: dump VLAN configuration info
This patch dump VLAN filter, strip related info and Pvid info for debug.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_ethdev_dump.c | 147 ++++++++++++++++++++++++++++
1 file changed, 147 insertions(+)
diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c
index face41e4a7..d017e66e69 100644
--- a/drivers/net/hns3/hns3_ethdev_dump.c
+++ b/drivers/net/hns3/hns3_ethdev_dump.c
@@ -355,6 +355,152 @@ 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_rx_offload_cfg(FILE *file, struct hns3_hw *hw)
+{
+ struct hns3_vport_vtag_rx_cfg_cmd *req;
+ struct hns3_cmd_desc desc;
+ uint16_t vport_id;
+ uint8_t bitmap;
+ int ret;
+
+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_PORT_RX_CFG, true);
+ req = (struct hns3_vport_vtag_rx_cfg_cmd *)desc.data;
+ vport_id = HNS3_PF_FUNC_ID;
+ req->vf_offset = vport_id / HNS3_VF_NUM_PER_CMD;
+ bitmap = 1 << (vport_id % HNS3_VF_NUM_PER_BYTE);
+ req->vf_bitmap[req->vf_offset] = bitmap;
+
+ /*
+ * current version VF is not supported when PF is driven by DPDK driver,
+ * just need to configure rx parameters for PF vport.
+ */
+ 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 -- RX VLAN configuration\n"
+ "\t vlan1_strip_en :%s\n"
+ "\t vlan2_strip_en :%s\n"
+ "\t vlan1_vlan_prionly :%s\n"
+ "\t vlan2_vlan_prionly :%s\n"
+ "\t vlan1_strip_discard :%s\n"
+ "\t vlan2_strip_discard :%s\n",
+ hns3_get_bit(req->vport_vlan_cfg,
+ HNS3_REM_TAG1_EN_B) ? "Enable" : "Disable",
+ hns3_get_bit(req->vport_vlan_cfg,
+ HNS3_REM_TAG2_EN_B) ? "Enable" : "Disable",
+ hns3_get_bit(req->vport_vlan_cfg,
+ HNS3_SHOW_TAG1_EN_B) ? "Enable" : "Disable",
+ hns3_get_bit(req->vport_vlan_cfg,
+ HNS3_SHOW_TAG2_EN_B) ? "Enable" : "Disable",
+ hns3_get_bit(req->vport_vlan_cfg,
+ HNS3_DISCARD_TAG1_EN_B) ? "Enable" : "Disable",
+ hns3_get_bit(req->vport_vlan_cfg,
+ HNS3_DISCARD_TAG2_EN_B) ? "Enable" : "Disable");
+
+ return 0;
+}
+
+static void
+hns3_parse_tx_vlan_cfg(FILE *file, struct hns3_vport_vtag_tx_cfg_cmd *req)
+{
+#define VLAN_VID_MASK 0x0fff
+#define VLAN_PRIO_SHIFT 13
+
+ fprintf(file,
+ "\t -- TX VLAN configuration\n"
+ "\t accept_tag1 :%s\n"
+ "\t accept_untag1 :%s\n"
+ "\t insert_tag1_en :%s\n"
+ "\t default_vlan_tag1 = %d, qos = %d\n"
+ "\t accept_tag2 :%s\n"
+ "\t accept_untag2 :%s\n"
+ "\t insert_tag2_en :%s\n"
+ "\t default_vlan_tag2 = %d, qos = %d\n"
+ "\t vlan_shift_mode :%s\n",
+ hns3_get_bit(req->vport_vlan_cfg,
+ HNS3_ACCEPT_TAG1_B) ? "Enable" : "Disable",
+ hns3_get_bit(req->vport_vlan_cfg,
+ HNS3_ACCEPT_UNTAG1_B) ? "Enable" : "Disable",
+ hns3_get_bit(req->vport_vlan_cfg,
+ HNS3_PORT_INS_TAG1_EN_B) ? "Enable" : "Disable",
+ req->def_vlan_tag1 & VLAN_VID_MASK,
+ req->def_vlan_tag1 >> VLAN_PRIO_SHIFT,
+ hns3_get_bit(req->vport_vlan_cfg,
+ HNS3_ACCEPT_TAG2_B) ? "Enable" : "Disable",
+ hns3_get_bit(req->vport_vlan_cfg,
+ HNS3_ACCEPT_UNTAG2_B) ? "Enable" : "Disable",
+ hns3_get_bit(req->vport_vlan_cfg,
+ HNS3_PORT_INS_TAG2_EN_B) ? "Enable" : "Disable",
+ req->def_vlan_tag2 & VLAN_VID_MASK,
+ req->def_vlan_tag2 >> VLAN_PRIO_SHIFT,
+ hns3_get_bit(req->vport_vlan_cfg,
+ HNS3_TAG_SHIFT_MODE_EN_B) ? "Enable" :
+ "Disable");
+}
+
+static int
+hns3_get_vlan_tx_offload_cfg(FILE *file, struct hns3_hw *hw)
+{
+ struct hns3_vport_vtag_tx_cfg_cmd *req;
+ struct hns3_cmd_desc desc;
+ uint16_t vport_id;
+ uint8_t bitmap;
+ int ret;
+
+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_PORT_TX_CFG, true);
+ req = (struct hns3_vport_vtag_tx_cfg_cmd *)desc.data;
+ vport_id = HNS3_PF_FUNC_ID;
+ req->vf_offset = vport_id / HNS3_VF_NUM_PER_CMD;
+ bitmap = 1 << (vport_id % HNS3_VF_NUM_PER_BYTE);
+ req->vf_bitmap[req->vf_offset] = bitmap;
+ /*
+ * current version VF is not supported when PF is driven by DPDK driver,
+ * just need to configure tx parameters for PF vport.
+ */
+ 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;
+ }
+
+ hns3_parse_tx_vlan_cfg(file, req);
+
+ return 0;
+}
+
+static void
+hns3_get_port_pvid_info(FILE *file, struct hns3_hw *hw)
+{
+ fprintf(file, "\t -- pvid status: %s\n",
+ hw->port_base_vlan_cfg.state ? "on" : "off");
+}
+
+static void
+hns3_get_vlan_config_info(FILE *file, struct hns3_hw *hw)
+{
+ int ret;
+
+ fprintf(file, " - VLAN Config Info:\n");
+ ret = hns3_get_vlan_rx_offload_cfg(file, hw);
+ if (ret < 0)
+ return;
+
+ ret = hns3_get_vlan_tx_offload_cfg(file, hw);
+ if (ret < 0)
+ return;
+
+ hns3_get_port_pvid_info(file, hw);
+}
+
int
hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
{
@@ -373,6 +519,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
return 0;
hns3_get_dev_mac_info(file, hns);
+ hns3_get_vlan_config_info(file, hw);
return 0;
}
--
2.30.0

View File

@ -0,0 +1,119 @@
From ca1080fde102a1b9de5781e0919a5342b6151bd3 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Fri, 11 Feb 2022 11:10:28 +0800
Subject: [PATCH 08/13] net/hns3: dump flow director basic info
This patch dumps flow director basic info such rule numbers, hit counts
for debug.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_ethdev_dump.c | 85 +++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c
index d017e66e69..792ef99b81 100644
--- a/drivers/net/hns3/hns3_ethdev_dump.c
+++ b/drivers/net/hns3/hns3_ethdev_dump.c
@@ -101,6 +101,90 @@ hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw)
hw->capability & BIT(i) ? "yes" : "no");
}
+static const char *
+hns3_get_fdir_tuple_name(uint32_t index)
+{
+ static const char * const tuple_name[] = {
+ "outer_dst_mac",
+ "outer_src_mac",
+ "outer_vlan_1st_tag",
+ "outer_vlan_2nd_tag",
+ "outer_eth_type",
+ "outer_l2_rsv",
+ "outer_ip_tos",
+ "outer_ip_proto",
+ "outer_src_ip",
+ "outer_dst_ip",
+ "outer_l3_rsv",
+ "outer_src_port",
+ "outer_dst_port",
+ "outer_l4_rsv",
+ "outer_tun_vni",
+ "outer_tun_flow_id",
+ "inner_dst_mac",
+ "inner_src_mac",
+ "inner_vlan_tag1",
+ "inner_vlan_tag2",
+ "inner_eth_type",
+ "inner_l2_rsv",
+ "inner_ip_tos",
+ "inner_ip_proto",
+ "inner_src_ip",
+ "inner_dst_ip",
+ "inner_l3_rsv",
+ "inner_src_port",
+ "inner_dst_port",
+ "inner_sctp_tag",
+ };
+ if (index < RTE_DIM(tuple_name))
+ return tuple_name[index];
+ else
+ return "unknown";
+}
+
+static void
+hns3_get_fdir_basic_info(FILE *file, struct hns3_pf *pf)
+{
+#define TMPBUF_SIZE 2048
+#define PERLINE_TUPLE_NAMES 4
+ struct hns3_fd_cfg *fdcfg = &pf->fdir.fd_cfg;
+ char tmpbuf[TMPBUF_SIZE] = {0};
+ uint32_t i, count = 0;
+
+ fprintf(file, " - Fdir Info:\n");
+ fprintf(file,
+ "\t -- mode=%u max_key_len=%u rule_num:%u cnt_num:%u\n"
+ "\t -- key_sel=%u tuple_active=0x%x meta_data_active=0x%x\n"
+ "\t -- ipv6_word_en: in_s=%u in_d=%u out_s=%u out_d=%u\n"
+ "\t -- active_tuples:\n",
+ fdcfg->fd_mode, fdcfg->max_key_length,
+ fdcfg->rule_num[HNS3_FD_STAGE_1],
+ fdcfg->cnt_num[HNS3_FD_STAGE_1],
+ fdcfg->key_cfg[HNS3_FD_STAGE_1].key_sel,
+ fdcfg->key_cfg[HNS3_FD_STAGE_1].tuple_active,
+ fdcfg->key_cfg[HNS3_FD_STAGE_1].meta_data_active,
+ fdcfg->key_cfg[HNS3_FD_STAGE_1].inner_sipv6_word_en,
+ fdcfg->key_cfg[HNS3_FD_STAGE_1].inner_dipv6_word_en,
+ fdcfg->key_cfg[HNS3_FD_STAGE_1].outer_sipv6_word_en,
+ fdcfg->key_cfg[HNS3_FD_STAGE_1].outer_dipv6_word_en);
+
+ for (i = 0; i < MAX_TUPLE; i++) {
+ if (!(fdcfg->key_cfg[HNS3_FD_STAGE_1].tuple_active & BIT(i)))
+ continue;
+ if (count % PERLINE_TUPLE_NAMES == 0)
+ fprintf(file, "\t ");
+ fprintf(file, " %s", hns3_get_fdir_tuple_name(i));
+ count++;
+ if (count % PERLINE_TUPLE_NAMES == 0)
+ fprintf(file, "\n");
+ }
+ if (count % PERLINE_TUPLE_NAMES)
+ fprintf(file, "\n");
+
+ fprintf(file, "%s", tmpbuf);
+}
+
+static void
hns3_get_device_basic_info(FILE *file, struct rte_eth_dev *dev)
{
struct hns3_adapter *hns = dev->data->dev_private;
@@ -520,6 +604,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
hns3_get_dev_mac_info(file, hns);
hns3_get_vlan_config_info(file, hw);
+ hns3_get_fdir_basic_info(file, &hns->pf);
return 0;
}
--
2.30.0

View File

@ -0,0 +1,188 @@
From f612c76b724c499f870026ec3deda07f0de13543 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Fri, 11 Feb 2022 11:22:23 +0800
Subject: [PATCH 09/13] net/hns3: dump TM configuration info
This patch dumps TM configuration info about shaper, port node, TC node,
queue node related info.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_ethdev_dump.c | 154 ++++++++++++++++++++++++++++
1 file changed, 154 insertions(+)
diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c
index 792ef99b81..c0fc55b290 100644
--- a/drivers/net/hns3/hns3_ethdev_dump.c
+++ b/drivers/net/hns3/hns3_ethdev_dump.c
@@ -585,6 +585,159 @@ hns3_get_vlan_config_info(FILE *file, struct hns3_hw *hw)
hns3_get_port_pvid_info(file, hw);
}
+static void
+hns3_get_tm_conf_shaper_info(FILE *file, struct hns3_tm_conf *conf)
+{
+ struct hns3_shaper_profile_list *shaper_profile_list =
+ &conf->shaper_profile_list;
+ struct hns3_tm_shaper_profile *shaper_profile;
+
+ if (!conf->nb_shaper_profile)
+ return;
+
+ fprintf(file, " shaper_profile:\n");
+ TAILQ_FOREACH(shaper_profile, shaper_profile_list, node) {
+ fprintf(file,
+ " id=%u reference_count=%u peak_rate=%" PRIu64 "Bps\n",
+ shaper_profile->shaper_profile_id,
+ shaper_profile->reference_count,
+ shaper_profile->profile.peak.rate);
+ }
+}
+
+static void
+hns3_get_tm_conf_port_node_info(FILE *file, struct hns3_tm_conf *conf)
+{
+ if (!conf->root)
+ return;
+
+ fprintf(file,
+ " 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 ?
+ (int)conf->root->shaper_profile->shaper_profile_id : -1);
+}
+
+static void
+hns3_get_tm_conf_tc_node_info(FILE *file, struct hns3_tm_conf *conf)
+{
+ struct hns3_tm_node_list *tc_list = &conf->tc_list;
+ struct hns3_tm_node *tc_node[HNS3_MAX_TC_NUM];
+ struct hns3_tm_node *tm_node;
+ uint32_t tidx;
+
+ if (!conf->nb_tc_node)
+ return;
+
+ 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);
+ if (tidx < HNS3_MAX_TC_NUM)
+ tc_node[tidx] = tm_node;
+ }
+
+ for (tidx = 0; tidx < HNS3_MAX_TC_NUM; tidx++) {
+ tm_node = tc_node[tidx];
+ if (tm_node == NULL)
+ continue;
+ fprintf(file,
+ " id=%u TC%u reference_count=%u parent_id=%d "
+ "shaper_profile_id=%d\n",
+ tm_node->id, hns3_tm_calc_node_tc_no(conf, tm_node->id),
+ tm_node->reference_count,
+ tm_node->parent ? (int)tm_node->parent->id : -1,
+ tm_node->shaper_profile ?
+ (int)tm_node->shaper_profile->shaper_profile_id : -1);
+ }
+}
+
+static void
+hns3_get_tm_conf_queue_format_info(FILE *file, struct hns3_tm_node **queue_node,
+ uint32_t *queue_node_tc,
+ uint32_t nb_tx_queues)
+{
+#define PERLINE_QUEUES 32
+#define PERLINE_STRIDE 8
+#define LINE_BUF_SIZE 1024
+ uint32_t i, j, line_num, start_queue, end_queue;
+ char tmpbuf[LINE_BUF_SIZE] = {0};
+
+ line_num = (nb_tx_queues + PERLINE_QUEUES - 1) / PERLINE_QUEUES;
+ for (i = 0; i < line_num; i++) {
+ start_queue = i * PERLINE_QUEUES;
+ end_queue = (i + 1) * PERLINE_QUEUES - 1;
+ if (end_queue > nb_tx_queues - 1)
+ end_queue = nb_tx_queues - 1;
+ fprintf(file, " %04u - %04u | ", start_queue, end_queue);
+ for (j = start_queue; j < nb_tx_queues; j++) {
+ if (j >= end_queue + 1)
+ break;
+ if (j > start_queue && j % PERLINE_STRIDE == 0)
+ fprintf(file, ":");
+ fprintf(file, "%u",
+ queue_node[j] ? queue_node_tc[j] :
+ HNS3_MAX_TC_NUM);
+ }
+ fprintf(file, "%s\n", tmpbuf);
+ }
+}
+
+static void
+hns3_get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf,
+ uint32_t nb_tx_queues)
+{
+ struct hns3_tm_node_list *queue_list = &conf->queue_list;
+ uint32_t nb_queue_node = conf->nb_leaf_nodes_max + 1;
+ struct hns3_tm_node *queue_node[nb_queue_node];
+ uint32_t queue_node_tc[nb_queue_node];
+ struct hns3_tm_node *tm_node;
+
+ if (!conf->nb_queue_node)
+ return;
+
+ fprintf(file,
+ " queue_node: \n"
+ " tx queue id | mapped tc (8 mean node not exist)\n");
+
+ memset(queue_node, 0, sizeof(queue_node));
+ memset(queue_node_tc, 0, sizeof(queue_node_tc));
+ nb_tx_queues = RTE_MIN(nb_tx_queues, nb_queue_node);
+ TAILQ_FOREACH(tm_node, queue_list, node) {
+ if (tm_node->id >= nb_queue_node)
+ continue;
+ queue_node[tm_node->id] = tm_node;
+ queue_node_tc[tm_node->id] = tm_node->parent ?
+ hns3_tm_calc_node_tc_no(conf, tm_node->parent->id) : 0;
+ nb_tx_queues = RTE_MAX(nb_tx_queues, tm_node->id + 1);
+ }
+
+ hns3_get_tm_conf_queue_format_info(file, queue_node, queue_node_tc,
+ nb_tx_queues);
+}
+
+static void
+hns3_get_tm_conf_info(FILE *file, struct rte_eth_dev *dev)
+{
+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+ struct hns3_tm_conf *conf = &pf->tm_conf;
+
+ fprintf(file, " - TM config info:\n");
+ fprintf(file,
+ "\t -- nb_leaf_nodes_max=%u nb_nodes_max=%u\n"
+ "\t -- nb_shaper_profile=%u nb_tc_node=%u nb_queue_node=%u\n"
+ "\t -- committed=%u\n",
+ conf->nb_leaf_nodes_max, conf->nb_nodes_max,
+ conf->nb_shaper_profile, conf->nb_tc_node, conf->nb_queue_node,
+ conf->committed);
+
+ hns3_get_tm_conf_shaper_info(file, conf);
+ hns3_get_tm_conf_port_node_info(file, conf);
+ hns3_get_tm_conf_tc_node_info(file, conf);
+ hns3_get_tm_conf_queue_node_info(file, conf, dev->data->nb_tx_queues);
+}
+
int
hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
{
@@ -605,6 +758,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
hns3_get_dev_mac_info(file, hns);
hns3_get_vlan_config_info(file, hw);
hns3_get_fdir_basic_info(file, &hns->pf);
+ hns3_get_tm_conf_info(file, dev);
return 0;
}
--
2.30.0

View File

@ -0,0 +1,165 @@
From e5e64a038775d3c7bd8f412fe9d814c8dfe795eb Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Fri, 11 Feb 2022 11:27:04 +0800
Subject: [PATCH 10/13] net/hns3: dump flow control info
This patch dumps flow control info such as flow control mode
for debug.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 2 +-
drivers/net/hns3/hns3_ethdev.h | 2 +
drivers/net/hns3/hns3_ethdev_dump.c | 103 ++++++++++++++++++++++++++++
3 files changed, 106 insertions(+), 1 deletion(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index a9394eeeff..cac6dd7755 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -5350,7 +5350,7 @@ hns3_get_current_fc_mode(struct rte_eth_dev *dev)
return hns3_get_autoneg_fc_mode(hw);
}
-static int
+int
hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
{
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index 412626c053..fd83bb7109 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -1030,6 +1030,8 @@ hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr)
return __atomic_fetch_and(addr, ~mask, __ATOMIC_RELAXED) & mask;
}
+int
+hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf);
uint32_t hns3_get_speed_capa(struct hns3_hw *hw);
int hns3_buffer_alloc(struct hns3_hw *hw);
diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c
index c0fc55b290..d9c1879f74 100644
--- a/drivers/net/hns3/hns3_ethdev_dump.c
+++ b/drivers/net/hns3/hns3_ethdev_dump.c
@@ -738,6 +738,108 @@ hns3_get_tm_conf_info(FILE *file, struct rte_eth_dev *dev)
hns3_get_tm_conf_queue_node_info(file, conf, dev->data->nb_tx_queues);
}
+static void
+hns3_fc_mode_to_rxtx_pause(enum hns3_fc_mode fc_mode, bool *rx_pause,
+ bool *tx_pause)
+{
+ switch (fc_mode) {
+ case HNS3_FC_NONE:
+ *tx_pause = false;
+ *rx_pause = false;
+ break;
+ case HNS3_FC_RX_PAUSE:
+ *rx_pause = true;
+ *tx_pause = false;
+ break;
+ case HNS3_FC_TX_PAUSE:
+ *rx_pause = false;
+ *tx_pause = true;
+ break;
+ case HNS3_FC_FULL:
+ *rx_pause = true;
+ *tx_pause = true;
+ break;
+ default:
+ *rx_pause = false;
+ *tx_pause = false;
+ break;
+ }
+}
+
+static bool
+hns3_is_link_fc_mode(struct hns3_adapter *hns)
+{
+ struct hns3_hw *hw = &hns->hw;
+ struct hns3_pf *pf = &hns->pf;
+
+ if (hw->current_fc_status == HNS3_FC_STATUS_PFC)
+ return false;
+
+ if (hw->num_tc > 1 && !pf->support_multi_tc_pause)
+ return false;
+
+ return true;
+}
+
+static void
+hns3_get_link_fc_info(FILE *file, struct rte_eth_dev *dev)
+{
+ struct hns3_adapter *hns = dev->data->dev_private;
+ struct hns3_hw *hw = &hns->hw;
+ struct rte_eth_fc_conf cur_fc_conf;
+ bool rx_pause1;
+ bool tx_pause1;
+ bool rx_pause2;
+ bool tx_pause2;
+ int ret;
+
+ if (!hns3_is_link_fc_mode(hns))
+ return;
+
+ ret = hns3_flow_ctrl_get(dev, &cur_fc_conf);
+ if (ret) {
+ fprintf(file, "get device flow control info fail!\n");
+ return;
+ }
+
+ hns3_fc_mode_to_rxtx_pause(hw->requested_fc_mode,
+ &rx_pause1, &tx_pause1);
+ hns3_fc_mode_to_rxtx_pause((enum hns3_fc_mode)cur_fc_conf.mode,
+ &rx_pause2, &tx_pause2);
+
+ fprintf(file,
+ "\t -- link_fc_info:\n"
+ "\t Requested fc:\n"
+ "\t Rx: %s\n"
+ "\t Tx: %s\n"
+ "\t Current fc:\n"
+ "\t Rx: %s\n"
+ "\t Tx: %s\n"
+ "\t Autonegotiate: %s\n"
+ "\t Pause time: 0x%x\n",
+ rx_pause1 ? "On" : "Off", tx_pause1 ? "On" : "Off",
+ rx_pause2 ? "On" : "Off", tx_pause2 ? "On" : "Off",
+ cur_fc_conf.autoneg == RTE_ETH_LINK_AUTONEG ? "On" : "Off",
+ cur_fc_conf.pause_time);
+}
+
+static void
+hns3_get_flow_ctrl_info(FILE *file, struct rte_eth_dev *dev)
+{
+ struct hns3_adapter *hns = dev->data->dev_private;
+ struct hns3_hw *hw = &hns->hw;
+
+ fprintf(file, " - Flow Ctrl Info:\n");
+ fprintf(file,
+ "\t -- fc_common_info:\n"
+ "\t current_fc_status=%u\n"
+ "\t requested_fc_mode=%u\n",
+ hw->current_fc_status,
+ hw->requested_fc_mode);
+
+ hns3_get_link_fc_info(file, dev);
+}
+
int
hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
{
@@ -759,6 +861,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
hns3_get_vlan_config_info(file, hw);
hns3_get_fdir_basic_info(file, &hns->pf);
hns3_get_tm_conf_info(file, dev);
+ hns3_get_flow_ctrl_info(file, dev);
return 0;
}
--
2.30.0

View File

@ -0,0 +1,35 @@
From 297a29aa8a27e93b2fa1fdc40a4964f0fbbaa4ec Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Thu, 31 Mar 2022 14:20:42 +0800
Subject: [PATCH 11/13] net/hns3: change dump file name
change dump file name 'hns3_ethdev_dump.c' to 'hns3_dump.c', as it
is more simple.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} | 0
drivers/net/hns3/meson.build | 2 +-
2 files changed, 1 insertion(+), 1 deletion(-)
rename drivers/net/hns3/{hns3_ethdev_dump.c => hns3_dump.c} (100%)
diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_dump.c
similarity index 100%
rename from drivers/net/hns3/hns3_ethdev_dump.c
rename to drivers/net/hns3/hns3_dump.c
diff --git a/drivers/net/hns3/meson.build b/drivers/net/hns3/meson.build
index 665b2afedf..9f30f6b7af 100644
--- a/drivers/net/hns3/meson.build
+++ b/drivers/net/hns3/meson.build
@@ -30,7 +30,7 @@ sources = files(
'hns3_tm.c',
'hns3_ptp.c',
'hns3_common.c',
- 'hns3_ethdev_dump.c',
+ 'hns3_dump.c',
)
deps += ['hash']
--
2.30.0

View File

@ -0,0 +1,680 @@
From d2c737bb909c52de76246d9c74944d96c5e7792f Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Thu, 31 Mar 2022 15:59:51 +0800
Subject: [PATCH 12/13] net/hns3: fix code check for dump
This patch fix code check for dump, making it more readable.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_dump.c | 341 +++++++++++++++---------------
drivers/net/hns3/hns3_dump.h | 10 +
drivers/net/hns3/hns3_ethdev.c | 1 +
drivers/net/hns3/hns3_ethdev.h | 3 +-
drivers/net/hns3/hns3_ethdev_vf.c | 1 +
5 files changed, 187 insertions(+), 169 deletions(-)
create mode 100644 drivers/net/hns3/hns3_dump.h
diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c
index d9c1879f74..3a30a585c5 100644
--- a/drivers/net/hns3/hns3_dump.c
+++ b/drivers/net/hns3/hns3_dump.c
@@ -2,37 +2,41 @@
* Copyright(C) 2022 HiSilicon Limited
*/
-#include <rte_kvargs.h>
-#include <rte_bus_pci.h>
-#include <ethdev_pci.h>
-#include <rte_pci.h>
+#include <rte_malloc.h>
+#include "hns3_ethdev.h"
#include "hns3_common.h"
-#include "hns3_logs.h"
-#include "hns3_regs.h"
#include "hns3_rxtx.h"
+#include "hns3_regs.h"
+#include "hns3_logs.h"
+#include "hns3_dump.h"
static const char *
-hns3_get_adapter_state_name(uint32_t state)
+hns3_get_adapter_state_name(enum hns3_adapter_state state)
{
- static const char * const state_name[] = {
- "UNINITIALIZED",
- "INITIALIZED",
- "CONFIGURING",
- "CONFIGURED",
- "STARTING",
- "STARTED",
- "STOPPING",
- "CLOSING",
- "CLOSED",
- "REMOVED",
- "NSTATES"
+ const struct {
+ enum hns3_adapter_state state;
+ const char *name;
+ } adapter_state_name[] = {
+ {HNS3_NIC_UNINITIALIZED, "UNINITIALIZED"},
+ {HNS3_NIC_INITIALIZED, "INITIALIZED"},
+ {HNS3_NIC_CONFIGURING, "CONFIGURING"},
+ {HNS3_NIC_CONFIGURED, "CONFIGURED"},
+ {HNS3_NIC_STARTING, "STARTING"},
+ {HNS3_NIC_STARTED, "STARTED"},
+ {HNS3_NIC_STOPPING, "STOPPING"},
+ {HNS3_NIC_CLOSING, "CLOSING"},
+ {HNS3_NIC_CLOSED, "CLOSED"},
+ {HNS3_NIC_REMOVED, "REMOVED"},
+ {HNS3_NIC_NSTATES, "NSTATES"},
};
+ uint32_t i;
- if (state < RTE_DIM(state_name))
- return state_name[state];
- else
- return "unknown";
+ for (i = 0; i < RTE_DIM(adapter_state_name); i++)
+ if (state == adapter_state_name[i].state)
+ return adapter_state_name[i].name;
+
+ return "Unknown";
}
static const char *
@@ -79,32 +83,36 @@ hns3_get_dev_mac_info(FILE *file, struct hns3_adapter *hns)
static void
hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw)
{
- const char * const caps_name[] = {
- "DCB",
- "COPPER",
- "FD QUEUE REGION",
- "PTP",
- "TX PUSH",
- "INDEP TXRX",
- "STASH",
- "SIMPLE BD",
- "RXD Advanced Layout",
- "OUTER UDP CKSUM",
- "RAS IMP",
- "TM",
+ const struct {
+ enum hns3_dev_cap cap;
+ const char *name;
+ } caps_name[] = {
+ {HNS3_DEV_SUPPORT_DCB_B, "DCB"},
+ {HNS3_DEV_SUPPORT_COPPER_B, "COPPER"},
+ {HNS3_DEV_SUPPORT_FD_QUEUE_REGION_B, "FD QUEUE REGION"},
+ {HNS3_DEV_SUPPORT_PTP_B, "PTP"},
+ {HNS3_DEV_SUPPORT_TX_PUSH_B, "TX PUSH"},
+ {HNS3_DEV_SUPPORT_INDEP_TXRX_B, "INDEP TXRX"},
+ {HNS3_DEV_SUPPORT_STASH_B, "STASH"},
+ {HNS3_DEV_SUPPORT_SIMPLE_BD_B, "SIMPLE BD"},
+ {HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B, "RXD Advanced Layout"},
+ {HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, "OUTER UDP CKSUM"},
+ {HNS3_DEV_SUPPORT_RAS_IMP_B, "RAS IMP"},
+ {HNS3_DEV_SUPPORT_TM_B, "TM"},
};
uint32_t i;
fprintf(file, " - Dev Capability:\n");
for (i = 0; i < RTE_DIM(caps_name); i++)
- fprintf(file, "\t -- support %s: %s\n", caps_name[i],
- hw->capability & BIT(i) ? "yes" : "no");
+ fprintf(file, "\t -- support %s: %s\n", caps_name[i].name,
+ hns3_get_bit(hw->capability, caps_name[i].cap) ? "Yes" :
+ "No");
}
static const char *
hns3_get_fdir_tuple_name(uint32_t index)
{
- static const char * const tuple_name[] = {
+ const char * const tuple_name[] = {
"outer_dst_mac",
"outer_src_mac",
"outer_vlan_1st_tag",
@@ -145,10 +153,8 @@ hns3_get_fdir_tuple_name(uint32_t index)
static void
hns3_get_fdir_basic_info(FILE *file, struct hns3_pf *pf)
{
-#define TMPBUF_SIZE 2048
-#define PERLINE_TUPLE_NAMES 4
+#define HNS3_PERLINE_TUPLE_NAME_LEN 4
struct hns3_fd_cfg *fdcfg = &pf->fdir.fd_cfg;
- char tmpbuf[TMPBUF_SIZE] = {0};
uint32_t i, count = 0;
fprintf(file, " - Fdir Info:\n");
@@ -171,17 +177,15 @@ hns3_get_fdir_basic_info(FILE *file, struct hns3_pf *pf)
for (i = 0; i < MAX_TUPLE; i++) {
if (!(fdcfg->key_cfg[HNS3_FD_STAGE_1].tuple_active & BIT(i)))
continue;
- if (count % PERLINE_TUPLE_NAMES == 0)
+ if (count % HNS3_PERLINE_TUPLE_NAME_LEN == 0)
fprintf(file, "\t ");
fprintf(file, " %s", hns3_get_fdir_tuple_name(i));
count++;
- if (count % PERLINE_TUPLE_NAMES == 0)
+ if (count % HNS3_PERLINE_TUPLE_NAME_LEN == 0)
fprintf(file, "\n");
}
- if (count % PERLINE_TUPLE_NAMES)
+ if (count % HNS3_PERLINE_TUPLE_NAME_LEN)
fprintf(file, "\n");
-
- fprintf(file, "%s", tmpbuf);
}
static void
@@ -220,99 +224,94 @@ hns3_get_device_basic_info(FILE *file, struct rte_eth_dev *dev)
dev->data->dev_conf.intr_conf.rxq);
}
-/*
- * Note: caller must make sure queue_id < nb_queues
- * nb_queues = RTE_MAX(eth_dev->data->nb_rx_queues,
- * eth_dev->data->nb_tx_queues)
- */
static struct hns3_rx_queue *
-hns3_get_rx_queue(struct rte_eth_dev *dev, uint32_t queue_id)
+hns3_get_rx_queue(struct rte_eth_dev *dev)
{
- struct hns3_adapter *hns = dev->data->dev_private;
- struct hns3_hw *hw = &hns->hw;
- uint32_t offset;
+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct hns3_rx_queue *rxq;
+ uint32_t queue_id;
void **rx_queues;
- if (queue_id < dev->data->nb_rx_queues) {
+ for (queue_id = 0; queue_id < dev->data->nb_rx_queues; queue_id++) {
rx_queues = dev->data->rx_queues;
- offset = queue_id;
- } else {
- /*
- * For kunpeng930, fake queue is not exist. But since the queues
- * are usually accessd in pairs, this branch may still exist.
- */
- if (hns3_dev_get_support(hw, INDEP_TXRX))
+ if (rx_queues == NULL || rx_queues[queue_id] == NULL) {
+ hns3_err(hw, "detect rx_queues is NULL!\n");
return NULL;
+ }
- rx_queues = hw->fkq_data.rx_queues;
- offset = queue_id - dev->data->nb_rx_queues;
- }
+ rxq = (struct hns3_rx_queue *)rx_queues[queue_id];
+ if (rxq->rx_deferred_start)
+ continue;
- if (rx_queues != NULL && rx_queues[offset] != NULL)
- return rx_queues[offset];
+ return rx_queues[queue_id];
+ }
- hns3_err(hw, "Detect rx_queues is NULL!\n");
return NULL;
}
-/*
- * Note: caller must make sure queue_id < nb_queues
- * nb_queues = RTE_MAX(eth_dev->data->nb_rx_queues,
- * eth_dev->data->nb_tx_queues)
- */
static struct hns3_tx_queue *
-hns3_get_tx_queue(struct rte_eth_dev *dev, uint32_t queue_id)
+hns3_get_tx_queue(struct rte_eth_dev *dev)
{
- struct hns3_adapter *hns = dev->data->dev_private;
- struct hns3_hw *hw = &hns->hw;
- uint32_t offset;
+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct hns3_tx_queue *txq;
+ uint32_t queue_id;
void **tx_queues;
- if (queue_id < dev->data->nb_tx_queues) {
+ for (queue_id = 0; queue_id < dev->data->nb_tx_queues; queue_id++) {
tx_queues = dev->data->tx_queues;
- offset = queue_id;
- } else {
- /*
- * For kunpeng930, fake queue is not exist. But since the queues
- * are usually accessd in pairs, this branch may still exist.
- */
- if (hns3_dev_get_support(hw, INDEP_TXRX))
+ if (tx_queues == NULL || tx_queues[queue_id] == NULL) {
+ hns3_err(hw, "detect tx_queues is NULL!\n");
return NULL;
- tx_queues = hw->fkq_data.tx_queues;
- offset = queue_id - dev->data->nb_tx_queues;
- }
+ }
- if (tx_queues != NULL && tx_queues[offset] != NULL)
- return tx_queues[offset];
+ txq = (struct hns3_tx_queue *)tx_queues[queue_id];
+ if (txq->tx_deferred_start)
+ continue;
+
+ return tx_queues[queue_id];
+ }
- hns3_err(hw, "Detect tx_queues is NULL!\n");
return NULL;
}
static void
hns3_get_rxtx_fake_queue_info(FILE *file, struct rte_eth_dev *dev)
{
- struct hns3_adapter *hns = dev->data->dev_private;
- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns);
+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
struct hns3_rx_queue *rxq;
struct hns3_tx_queue *txq;
- uint32_t queue_id;
+ uint32_t queue_id = 0;
+ void **rx_queues;
+ void **tx_queues;
- if (dev->data->nb_rx_queues != dev->data->nb_tx_queues &&
- !hns3_dev_get_support(hw, INDEP_TXRX)) {
- queue_id = RTE_MIN(dev->data->nb_rx_queues,
- dev->data->nb_tx_queues);
- rxq = hns3_get_rx_queue(dev, queue_id);
- if (rxq == NULL)
+ if (hns3_dev_get_support(hw, INDEP_TXRX))
+ return;
+
+ if (dev->data->nb_rx_queues < dev->data->nb_tx_queues) {
+ rx_queues = hw->fkq_data.rx_queues;
+ if (rx_queues == NULL || rx_queues[queue_id] == NULL) {
+ hns3_err(hw, "detect rx_queues is NULL!\n");
return;
- txq = hns3_get_tx_queue(dev, queue_id);
- if (txq == NULL)
+ }
+ rxq = (struct hns3_rx_queue *)rx_queues[queue_id];
+
+ fprintf(file,
+ "\t -- first fake_queue info:\n"
+ "\t Rx: port=%u nb_desc=%u free_thresh=%u\n",
+ rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh);
+ } else if (dev->data->nb_rx_queues > dev->data->nb_tx_queues) {
+ tx_queues = hw->fkq_data.tx_queues;
+ queue_id = 0;
+
+ if (tx_queues == NULL || tx_queues[queue_id] == NULL) {
+ hns3_err(hw, "detect tx_queues is NULL!\n");
return;
+ }
+ txq = (struct hns3_tx_queue *)tx_queues[queue_id];
+
fprintf(file,
- "\t -- first fake_queue rxtx info:\n"
- "\t Rx: port=%u nb_desc=%u free_thresh=%u\n"
- "\t Tx: port=%u nb_desc=%u\n",
- rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh,
+ "\t -- first fake_queue info:\n"
+ "\t Tx: port=%u nb_desc=%u\n",
txq->port_id, txq->nb_tx_desc);
}
}
@@ -321,7 +320,7 @@ static void
hns3_get_queue_enable_state(struct hns3_hw *hw, uint32_t *queue_state,
uint32_t nb_queues, bool is_rxq)
{
-#define STATE_SIZE (sizeof(*queue_state) * CHAR_BIT)
+#define HNS3_QUEUE_NUM_PER_STATS (sizeof(*queue_state) * HNS3_UINT8_BIT)
uint32_t queue_en_reg;
uint32_t reg_offset;
uint32_t state;
@@ -334,28 +333,28 @@ hns3_get_queue_enable_state(struct hns3_hw *hw, uint32_t *queue_state,
if (hns3_dev_get_support(hw, INDEP_TXRX))
state = state && hns3_read_dev(hw, reg_offset +
queue_en_reg);
- hns3_set_bit(queue_state[i / STATE_SIZE],
- i % STATE_SIZE, state);
+ hns3_set_bit(queue_state[i / HNS3_QUEUE_NUM_PER_STATS],
+ i % HNS3_QUEUE_NUM_PER_STATS, state);
}
}
static void
hns3_print_queue_state_perline(FILE *file, const uint32_t *queue_state,
- uint32_t nb_queues, uint32_t line_num)
+ uint32_t nb_queues, uint32_t line_num)
{
-#define NUM_QUEUE_PER_LINE (sizeof(*queue_state) * CHAR_BIT)
- uint32_t qid = line_num * NUM_QUEUE_PER_LINE;
- uint32_t j;
+#define HNS3_NUM_QUEUE_PER_LINE (sizeof(*queue_state) * HNS3_UINT8_BIT)
+ uint32_t id = line_num * HNS3_NUM_QUEUE_PER_LINE;
+ uint32_t i;
- for (j = 0; j < NUM_QUEUE_PER_LINE; j++) {
- fprintf(file, "%1lx", hns3_get_bit(queue_state[line_num], j));
+ for (i = 0; i < HNS3_NUM_QUEUE_PER_LINE; i++) {
+ fprintf(file, "%1lx", hns3_get_bit(queue_state[line_num], i));
- if (qid % CHAR_BIT == CHAR_BIT - 1) {
+ if (id % HNS3_UINT8_BIT == HNS3_UINT8_BIT - 1) {
fprintf(file, "%s",
- j == NUM_QUEUE_PER_LINE - 1 ? "\n" : ":");
+ i == HNS3_NUM_QUEUE_PER_LINE - 1 ? "\n" : ":");
}
- qid++;
- if (qid >= nb_queues) {
+ id++;
+ if (id >= nb_queues) {
fprintf(file, "\n");
break;
}
@@ -364,23 +363,17 @@ hns3_print_queue_state_perline(FILE *file, const uint32_t *queue_state,
static void
hns3_display_queue_enable_state(FILE *file, const uint32_t *queue_state,
- uint32_t nb_queues, bool is_rxq)
+ uint32_t nb_queues, bool is_rxq)
{
-#define NUM_QUEUE_PER_LINE (sizeof(*queue_state) * CHAR_BIT)
+#define HNS3_NUM_QUEUE_PER_LINE (sizeof(*queue_state) * HNS3_UINT8_BIT)
uint32_t i;
- if (nb_queues == 0) {
- fprintf(file, "\t %s queue number is 0\n",
- is_rxq ? "Rx" : "Tx");
- return;
- }
-
fprintf(file, "\t %s queue id | enable state bitMap\n",
is_rxq ? "Rx" : "Tx");
- for (i = 0; i < (nb_queues - 1) / NUM_QUEUE_PER_LINE + 1; i++) {
- uint32_t line_end = (i + 1) * NUM_QUEUE_PER_LINE - 1;
- uint32_t line_start = i * NUM_QUEUE_PER_LINE;
+ for (i = 0; i < (nb_queues - 1) / HNS3_NUM_QUEUE_PER_LINE + 1; i++) {
+ uint32_t line_end = (i + 1) * HNS3_NUM_QUEUE_PER_LINE - 1;
+ uint32_t line_start = i * HNS3_NUM_QUEUE_PER_LINE;
fprintf(file, "\t %04u - %04u | ", line_start,
nb_queues - 1 > line_end ? line_end : nb_queues - 1);
@@ -391,16 +384,28 @@ hns3_display_queue_enable_state(FILE *file, const uint32_t *queue_state,
static void
hns3_get_rxtx_queue_enable_state(FILE *file, struct rte_eth_dev *dev)
{
-#define MAX_TQP_NUM 1280
-#define QUEUE_BITMAP_SIZE (MAX_TQP_NUM / 32)
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- uint32_t rx_queue_state[QUEUE_BITMAP_SIZE] = {0};
- uint32_t tx_queue_state[QUEUE_BITMAP_SIZE] = {0};
+ uint32_t *rx_queue_state;
+ uint32_t *tx_queue_state;
uint32_t nb_rx_queues;
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) {
+ fprintf(file, "\t -- Rx queue number is 0\n");
+ return;
+ }
+ if (nb_tx_queues == 0) {
+ fprintf(file, "\t -- Tx queue number is 0\n");
+ return;
+ }
fprintf(file, "\t -- enable state:\n");
hns3_get_queue_enable_state(hw, rx_queue_state, nb_rx_queues, true);
@@ -410,6 +415,8 @@ hns3_get_rxtx_queue_enable_state(FILE *file, struct rte_eth_dev *dev)
hns3_get_queue_enable_state(hw, tx_queue_state, nb_tx_queues, false);
hns3_display_queue_enable_state(file, tx_queue_state, nb_tx_queues,
false);
+ rte_free(rx_queue_state);
+ rte_free(tx_queue_state);
}
static void
@@ -417,12 +424,11 @@ hns3_get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev)
{
struct hns3_rx_queue *rxq;
struct hns3_tx_queue *txq;
- uint32_t queue_id = 0;
- rxq = hns3_get_rx_queue(dev, queue_id);
+ rxq = hns3_get_rx_queue(dev);
if (rxq == NULL)
return;
- txq = hns3_get_tx_queue(dev, queue_id);
+ txq = hns3_get_tx_queue(dev);
if (txq == NULL)
return;
fprintf(file, " - Rx/Tx Queue Info:\n");
@@ -462,8 +468,8 @@ hns3_get_vlan_rx_offload_cfg(FILE *file, struct hns3_hw *hw)
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));
+ "NIC firmware exec ret=%d optcode=0x%x!", ret,
+ rte_le_to_cpu_16(desc.opcode));
return ret;
}
@@ -551,7 +557,7 @@ hns3_get_vlan_tx_offload_cfg(FILE *file, struct hns3_hw *hw)
ret = hns3_cmd_send(hw, &desc, 1);
if (ret != 0) {
hns3_err(hw,
- "NIC IMP exec ret=%d desc_num=%d optcode=0x%x!",
+ "NIC firmware exec ret=%d desc_num=%d optcode=0x%x!",
ret, 1, rte_le_to_cpu_16(desc.opcode));
return ret;
}
@@ -564,8 +570,8 @@ hns3_get_vlan_tx_offload_cfg(FILE *file, struct hns3_hw *hw)
static void
hns3_get_port_pvid_info(FILE *file, struct hns3_hw *hw)
{
- fprintf(file, "\t -- pvid status: %s\n",
- hw->port_base_vlan_cfg.state ? "on" : "off");
+ fprintf(file, " - pvid status: %s\n",
+ hw->port_base_vlan_cfg.state ? "On" : "Off");
}
static void
@@ -581,8 +587,6 @@ hns3_get_vlan_config_info(FILE *file, struct hns3_hw *hw)
ret = hns3_get_vlan_tx_offload_cfg(file, hw);
if (ret < 0)
return;
-
- hns3_get_port_pvid_info(file, hw);
}
static void
@@ -592,7 +596,7 @@ hns3_get_tm_conf_shaper_info(FILE *file, struct hns3_tm_conf *conf)
&conf->shaper_profile_list;
struct hns3_tm_shaper_profile *shaper_profile;
- if (!conf->nb_shaper_profile)
+ if (conf->nb_shaper_profile == 0)
return;
fprintf(file, " shaper_profile:\n");
@@ -608,7 +612,7 @@ hns3_get_tm_conf_shaper_info(FILE *file, struct hns3_tm_conf *conf)
static void
hns3_get_tm_conf_port_node_info(FILE *file, struct hns3_tm_conf *conf)
{
- if (!conf->root)
+ if (conf->root == NULL)
return;
fprintf(file,
@@ -627,7 +631,7 @@ hns3_get_tm_conf_tc_node_info(FILE *file, struct hns3_tm_conf *conf)
struct hns3_tm_node *tm_node;
uint32_t tidx;
- if (!conf->nb_tc_node)
+ if (conf->nb_tc_node == 0)
return;
fprintf(file, " tc_node: \n");
@@ -658,29 +662,28 @@ hns3_get_tm_conf_queue_format_info(FILE *file, struct hns3_tm_node **queue_node,
uint32_t *queue_node_tc,
uint32_t nb_tx_queues)
{
-#define PERLINE_QUEUES 32
-#define PERLINE_STRIDE 8
-#define LINE_BUF_SIZE 1024
- uint32_t i, j, line_num, start_queue, end_queue;
- char tmpbuf[LINE_BUF_SIZE] = {0};
+#define HNS3_PERLINE_QUEUES 32
+#define HNS3_PERLINE_STRIDE 8
+ uint32_t i, j, line_num, start_queue_id, end_queue_id;
- line_num = (nb_tx_queues + PERLINE_QUEUES - 1) / PERLINE_QUEUES;
+ line_num = (nb_tx_queues + HNS3_PERLINE_QUEUES - 1) /
+ HNS3_PERLINE_QUEUES;
for (i = 0; i < line_num; i++) {
- start_queue = i * PERLINE_QUEUES;
- end_queue = (i + 1) * PERLINE_QUEUES - 1;
- if (end_queue > nb_tx_queues - 1)
- end_queue = nb_tx_queues - 1;
- fprintf(file, " %04u - %04u | ", start_queue, end_queue);
- for (j = start_queue; j < nb_tx_queues; j++) {
- if (j >= end_queue + 1)
+ start_queue_id = i * HNS3_PERLINE_QUEUES;
+ end_queue_id = (i + 1) * HNS3_PERLINE_QUEUES - 1;
+ if (end_queue_id > nb_tx_queues - 1)
+ end_queue_id = nb_tx_queues - 1;
+ fprintf(file, " %04u - %04u | ", start_queue_id,
+ end_queue_id);
+ for (j = start_queue_id; j < nb_tx_queues; j++) {
+ if (j >= end_queue_id + 1)
break;
- if (j > start_queue && j % PERLINE_STRIDE == 0)
+ if (j > start_queue_id && j % HNS3_PERLINE_STRIDE == 0)
fprintf(file, ":");
fprintf(file, "%u",
queue_node[j] ? queue_node_tc[j] :
HNS3_MAX_TC_NUM);
}
- fprintf(file, "%s\n", tmpbuf);
}
}
@@ -694,7 +697,7 @@ hns3_get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf,
uint32_t queue_node_tc[nb_queue_node];
struct hns3_tm_node *tm_node;
- if (!conf->nb_queue_node)
+ if (conf->nb_queue_node == 0)
return;
fprintf(file,
@@ -720,9 +723,13 @@ hns3_get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf,
static void
hns3_get_tm_conf_info(FILE *file, struct rte_eth_dev *dev)
{
+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);
struct hns3_tm_conf *conf = &pf->tm_conf;
+ if (!hns3_dev_get_support(hw, TM))
+ return;
+
fprintf(file, " - TM config info:\n");
fprintf(file,
"\t -- nb_leaf_nodes_max=%u nb_nodes_max=%u\n"
@@ -826,8 +833,7 @@ hns3_get_link_fc_info(FILE *file, struct rte_eth_dev *dev)
static void
hns3_get_flow_ctrl_info(FILE *file, struct rte_eth_dev *dev)
{
- struct hns3_adapter *hns = dev->data->dev_private;
- struct hns3_hw *hw = &hns->hw;
+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
fprintf(file, " - Flow Ctrl Info:\n");
fprintf(file,
@@ -849,6 +855,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
hns3_get_device_basic_info(file, dev);
hns3_get_dev_feature_capability(file, hw);
hns3_get_rxtx_queue_info(file, dev);
+ hns3_get_port_pvid_info(file, hw);
/*
* VF only supports dumping basic info, feaure capability and queue
diff --git a/drivers/net/hns3/hns3_dump.h b/drivers/net/hns3/hns3_dump.h
new file mode 100644
index 0000000000..8ba7ee866a
--- /dev/null
+++ b/drivers/net/hns3/hns3_dump.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2022 HiSilicon Limited
+ */
+
+#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_ */
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index cac6dd7755..dfc41d2a05 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -8,6 +8,7 @@
#include "hns3_ethdev.h"
#include "hns3_common.h"
+#include "hns3_dump.h"
#include "hns3_logs.h"
#include "hns3_rxtx.h"
#include "hns3_intr.h"
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index fd83bb7109..d6d82c55f9 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -874,7 +874,7 @@ struct hns3_adapter {
#define HNS3_DEVARG_MBX_TIME_LIMIT_MS "mbx_time_limit_ms"
-enum {
+enum hns3_dev_cap {
HNS3_DEV_SUPPORT_DCB_B,
HNS3_DEV_SUPPORT_COPPER_B,
HNS3_DEV_SUPPORT_FD_QUEUE_REGION_B,
@@ -1057,7 +1057,6 @@ int hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts);
int hns3_timesync_write_time(struct rte_eth_dev *dev,
const struct timespec *ts);
int hns3_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
-int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file);
static inline bool
is_reset_pending(struct hns3_adapter *hns)
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index aee0c36360..92fbdb90cd 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -10,6 +10,7 @@
#include "hns3_ethdev.h"
#include "hns3_common.h"
+#include "hns3_dump.h"
#include "hns3_logs.h"
#include "hns3_rxtx.h"
#include "hns3_regs.h"
--
2.30.0

View File

@ -0,0 +1,31 @@
From fe0c1c3ea1023ecece4bf5f5ef99a014fcb182b8 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Wed, 6 Apr 2022 09:29:30 +0800
Subject: [PATCH 13/13] ethdev: fix ethdev version map
This patch fix ethdev version map as new API introduced.
Fixes: 2d2aea5495d1 ("ethdev: introduce dump API")
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
lib/ethdev/version.map | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map
index c2fb0669a4..f29c60eda4 100644
--- a/lib/ethdev/version.map
+++ b/lib/ethdev/version.map
@@ -256,6 +256,9 @@ EXPERIMENTAL {
rte_flow_flex_item_create;
rte_flow_flex_item_release;
rte_flow_pick_transfer_proxy;
+
+ # added in 22.03
+ rte_eth_dev_priv_dump;
};
INTERNAL {
--
2.30.0

View File

@ -0,0 +1,28 @@
From b757a6bf3bef31517f3799fa5a0426e38da04a71 Mon Sep 17 00:00:00 2001
From: Min Hu <humin29@huawei.com>
Date: Wed, 6 Apr 2022 11:56:06 +0800
Subject: [PATCH] net/hns3: delete simple bd cap
This patch delete simple bd cap for dump as it has not been merged
in community.
Signed-off-by: Min Hu <humin29@huawei.com>
---
drivers/net/hns3/hns3_dump.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/hns3/hns3_dump.c b/drivers/net/hns3/hns3_dump.c
index 3a30a585c5..4b18bb647c 100644
--- a/drivers/net/hns3/hns3_dump.c
+++ b/drivers/net/hns3/hns3_dump.c
@@ -94,7 +94,6 @@ hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw)
{HNS3_DEV_SUPPORT_TX_PUSH_B, "TX PUSH"},
{HNS3_DEV_SUPPORT_INDEP_TXRX_B, "INDEP TXRX"},
{HNS3_DEV_SUPPORT_STASH_B, "STASH"},
- {HNS3_DEV_SUPPORT_SIMPLE_BD_B, "SIMPLE BD"},
{HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B, "RXD Advanced Layout"},
{HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, "OUTER UDP CKSUM"},
{HNS3_DEV_SUPPORT_RAS_IMP_B, "RAS IMP"},
--
2.30.0

View File

@ -0,0 +1,29 @@
From 288da934034f84ab87b9e0d087db7e1e3c88bc8a Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Fri, 8 Apr 2022 11:27:04 +0800
Subject: [PATCH] net/hns3: fix TM info dump
This patch add newline characterat the end of TM info dump.
Fixes: 761dfa44be2f ("net/hns3: dump TM configuration info")
Signed-off-by: Min Hu (Connor) <humin29@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 3a30a585c5..6ec3125b10 100644
--- a/drivers/net/hns3/hns3_dump.c
+++ b/drivers/net/hns3/hns3_dump.c
@@ -684,6 +684,7 @@ hns3_get_tm_conf_queue_format_info(FILE *file, struct hns3_tm_node **queue_node,
queue_node[j] ? queue_node_tc[j] :
HNS3_MAX_TC_NUM);
}
+ fprintf(file, "\n");
}
}
--
2.33.0

View File

@ -0,0 +1,182 @@
From 0ac9cae2d0e1763cf884f0b5d735e4b57b6acb27 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Thu, 17 Feb 2022 10:59:07 +0800
Subject: [PATCH 01/25] dma/hisilicon: support Kunpeng 930
The Kunpeng930 DMA devices have the same PCI device id with Kunpeng920,
but with different PCI revision and register layout. This patch
introduces the basic initialization for Kunpeng930 DMA devices.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
doc/guides/dmadevs/hisilicon.rst | 1 +
drivers/dma/hisilicon/hisi_dmadev.c | 34 ++++++++++++++++++++++++++---
drivers/dma/hisilicon/hisi_dmadev.h | 28 +++++++++++++++++++-----
3 files changed, 54 insertions(+), 9 deletions(-)
diff --git a/doc/guides/dmadevs/hisilicon.rst b/doc/guides/dmadevs/hisilicon.rst
index 191e56f2f7..81bf090311 100644
--- a/doc/guides/dmadevs/hisilicon.rst
+++ b/doc/guides/dmadevs/hisilicon.rst
@@ -13,6 +13,7 @@ Supported Kunpeng SoCs
----------------------
* Kunpeng 920
+* Kunpeng 930
Device Setup
diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c
index 05066b4d0e..d4e08994a8 100644
--- a/drivers/dma/hisilicon/hisi_dmadev.c
+++ b/drivers/dma/hisilicon/hisi_dmadev.c
@@ -39,6 +39,8 @@ hisi_dma_queue_base(struct hisi_dma_dev *hw)
{
if (hw->reg_layout == HISI_DMA_REG_LAYOUT_HIP08)
return HISI_DMA_HIP08_QUEUE_BASE;
+ else if (hw->reg_layout == HISI_DMA_REG_LAYOUT_HIP09)
+ return HISI_DMA_HIP09_QUEUE_BASE;
else
return 0;
}
@@ -174,7 +176,7 @@ hisi_dma_reset_hw(struct hisi_dma_dev *hw)
}
static void
-hisi_dma_init_hw(struct hisi_dma_dev *hw)
+hisi_dma_init_common(struct hisi_dma_dev *hw)
{
hisi_dma_write_queue(hw, HISI_DMA_QUEUE_SQ_BASE_L_REG,
lower_32_bits(hw->sqe_iova));
@@ -192,6 +194,12 @@ hisi_dma_init_hw(struct hisi_dma_dev *hw)
hisi_dma_write_queue(hw, HISI_DMA_QUEUE_ERR_INT_NUM0_REG, 0);
hisi_dma_write_queue(hw, HISI_DMA_QUEUE_ERR_INT_NUM1_REG, 0);
hisi_dma_write_queue(hw, HISI_DMA_QUEUE_ERR_INT_NUM2_REG, 0);
+}
+
+static void
+hisi_dma_init_hw(struct hisi_dma_dev *hw)
+{
+ hisi_dma_init_common(hw);
if (hw->reg_layout == HISI_DMA_REG_LAYOUT_HIP08) {
hisi_dma_write_queue(hw, HISI_DMA_HIP08_QUEUE_ERR_INT_NUM3_REG,
@@ -206,9 +214,27 @@ hisi_dma_init_hw(struct hisi_dma_dev *hw)
HISI_DMA_HIP08_QUEUE_CTRL0_ERR_ABORT_B, false);
hisi_dma_update_queue_mbit(hw, HISI_DMA_QUEUE_INT_STATUS_REG,
HISI_DMA_HIP08_QUEUE_INT_MASK_M, true);
- hisi_dma_update_queue_mbit(hw,
- HISI_DMA_HIP08_QUEUE_INT_MASK_REG,
+ hisi_dma_update_queue_mbit(hw, HISI_DMA_QUEUE_INT_MASK_REG,
HISI_DMA_HIP08_QUEUE_INT_MASK_M, true);
+ } else if (hw->reg_layout == HISI_DMA_REG_LAYOUT_HIP09) {
+ hisi_dma_update_queue_mbit(hw, HISI_DMA_QUEUE_CTRL0_REG,
+ HISI_DMA_HIP09_QUEUE_CTRL0_ERR_ABORT_M, false);
+ hisi_dma_update_queue_mbit(hw, HISI_DMA_QUEUE_INT_STATUS_REG,
+ HISI_DMA_HIP09_QUEUE_INT_MASK_M, true);
+ hisi_dma_update_queue_mbit(hw, HISI_DMA_QUEUE_INT_MASK_REG,
+ HISI_DMA_HIP09_QUEUE_INT_MASK_M, true);
+ hisi_dma_update_queue_mbit(hw,
+ HISI_DMA_HIP09_QUEUE_ERR_INT_STATUS_REG,
+ HISI_DMA_HIP09_QUEUE_ERR_INT_MASK_M, true);
+ hisi_dma_update_queue_mbit(hw,
+ HISI_DMA_HIP09_QUEUE_ERR_INT_MASK_REG,
+ HISI_DMA_HIP09_QUEUE_ERR_INT_MASK_M, true);
+ hisi_dma_update_queue_bit(hw, HISI_DMA_QUEUE_CTRL1_REG,
+ HISI_DMA_HIP09_QUEUE_CTRL1_VA_ENABLE_B, true);
+ hisi_dma_update_bit(hw,
+ HISI_DMA_HIP09_QUEUE_CFG_REG(hw->queue_id),
+ HISI_DMA_HIP09_QUEUE_CFG_LINK_DOWN_MASK_B,
+ true);
}
}
@@ -230,6 +256,8 @@ hisi_dma_reg_layout(uint8_t revision)
{
if (revision == HISI_DMA_REVISION_HIP08B)
return HISI_DMA_REG_LAYOUT_HIP08;
+ else if (revision >= HISI_DMA_REVISION_HIP09A)
+ return HISI_DMA_REG_LAYOUT_HIP09;
else
return HISI_DMA_REG_LAYOUT_INVALID;
}
diff --git a/drivers/dma/hisilicon/hisi_dmadev.h b/drivers/dma/hisilicon/hisi_dmadev.h
index 12e209c86e..591aec0b32 100644
--- a/drivers/dma/hisilicon/hisi_dmadev.h
+++ b/drivers/dma/hisilicon/hisi_dmadev.h
@@ -23,20 +23,22 @@
#define HISI_DMA_DEVICE_ID 0xA122
#define HISI_DMA_PCI_REVISION_ID_REG 0x08
#define HISI_DMA_REVISION_HIP08B 0x21
+#define HISI_DMA_REVISION_HIP09A 0x30
#define HISI_DMA_MAX_HW_QUEUES 4
#define HISI_DMA_MAX_DESC_NUM 8192
#define HISI_DMA_MIN_DESC_NUM 32
/**
- * The HIP08B(HiSilicon IP08) and later Chip(e.g. HiSilicon IP09) are DMA iEPs,
- * they have the same pci device id but with different pci revision.
- * Unfortunately, they have different register layouts, so the layout
+ * The HIP08B(HiSilicon IP08) and HIP09B(HiSilicon IP09) are DMA iEPs, they
+ * have the same pci device id but different pci revision.
+ * Unfortunately, they have different register layouts, so two layout
* enumerations are defined.
*/
enum {
HISI_DMA_REG_LAYOUT_INVALID = 0,
- HISI_DMA_REG_LAYOUT_HIP08
+ HISI_DMA_REG_LAYOUT_HIP08,
+ HISI_DMA_REG_LAYOUT_HIP09
};
/**
@@ -66,7 +68,7 @@ enum {
* calculated by:
* offset = queue-base + (queue-id * queue-region) + reg-offset-in-region.
*
- * The first part of queue region is basically the same for HIP08 and later chip
+ * The first part of queue region is basically the same for HIP08 and HIP09
* register layouts, therefore, HISI_QUEUE_* registers are defined for it.
*/
#define HISI_DMA_QUEUE_SQ_BASE_L_REG 0x0
@@ -85,6 +87,7 @@ enum {
#define HISI_DMA_QUEUE_FSM_REG 0x30
#define HISI_DMA_QUEUE_FSM_STS_M GENMASK(3, 0)
#define HISI_DMA_QUEUE_INT_STATUS_REG 0x40
+#define HISI_DMA_QUEUE_INT_MASK_REG 0x44
#define HISI_DMA_QUEUE_ERR_INT_NUM0_REG 0x84
#define HISI_DMA_QUEUE_ERR_INT_NUM1_REG 0x88
#define HISI_DMA_QUEUE_ERR_INT_NUM2_REG 0x8C
@@ -95,7 +98,6 @@ enum {
*/
#define HISI_DMA_HIP08_QUEUE_BASE 0x0
#define HISI_DMA_HIP08_QUEUE_CTRL0_ERR_ABORT_B 2
-#define HISI_DMA_HIP08_QUEUE_INT_MASK_REG 0x44
#define HISI_DMA_HIP08_QUEUE_INT_MASK_M GENMASK(14, 0)
#define HISI_DMA_HIP08_QUEUE_ERR_INT_NUM3_REG 0x90
#define HISI_DMA_HIP08_QUEUE_ERR_INT_NUM4_REG 0x94
@@ -106,6 +108,20 @@ enum {
#define HISI_DMA_HIP08_DUMP_START_REG 0x2000
#define HISI_DMA_HIP08_DUMP_END_REG 0x2280
+/**
+ * HiSilicon IP09 DMA register and field define:
+ */
+#define HISI_DMA_HIP09_QUEUE_BASE 0x2000
+#define HISI_DMA_HIP09_QUEUE_CTRL0_ERR_ABORT_M GENMASK(31, 28)
+#define HISI_DMA_HIP09_QUEUE_CTRL1_VA_ENABLE_B 2
+#define HISI_DMA_HIP09_QUEUE_INT_MASK_M 0x1
+#define HISI_DMA_HIP09_QUEUE_ERR_INT_STATUS_REG 0x48
+#define HISI_DMA_HIP09_QUEUE_ERR_INT_MASK_REG 0x4C
+#define HISI_DMA_HIP09_QUEUE_ERR_INT_MASK_M GENMASK(18, 1)
+#define HISI_DMA_HIP09_QUEUE_CFG_REG(queue_id) (0x800 + \
+ (queue_id) * 0x20)
+#define HISI_DMA_HIP09_QUEUE_CFG_LINK_DOWN_MASK_B 16
+
/**
* In fact, there are multiple states, but it need to pay attention to
* the following two states for the driver:
--
2.30.0

View File

@ -0,0 +1,35 @@
From 2265601837805a2fc70dd5935ffe3f2ccaec17d1 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Thu, 17 Feb 2022 10:59:08 +0800
Subject: [PATCH] dma/hisilicon: support error handling with Kunpeng 930
The Kunpeng930 DMA supports the capability of handles errors.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/dma/hisilicon/hisi_dmadev.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c
index d4e08994a8..b99a9bce6c 100644
--- a/drivers/dma/hisilicon/hisi_dmadev.c
+++ b/drivers/dma/hisilicon/hisi_dmadev.c
@@ -328,11 +328,14 @@ hisi_dma_info_get(const struct rte_dma_dev *dev,
struct rte_dma_info *dev_info,
uint32_t info_sz)
{
- RTE_SET_USED(dev);
+ struct hisi_dma_dev *hw = dev->data->dev_private;
RTE_SET_USED(info_sz);
dev_info->dev_capa = RTE_DMA_CAPA_MEM_TO_MEM |
RTE_DMA_CAPA_OPS_COPY;
+ if (hw->reg_layout == HISI_DMA_REG_LAYOUT_HIP09)
+ dev_info->dev_capa |= RTE_DMA_CAPA_HANDLES_ERRORS;
+
dev_info->max_vchans = 1;
dev_info->max_desc = HISI_DMA_MAX_DESC_NUM;
dev_info->min_desc = HISI_DMA_MIN_DESC_NUM;
--
2.33.0

View File

@ -0,0 +1,112 @@
From dd69081182fae0a65606e8d8b509aa46795b7cfa Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Thu, 17 Feb 2022 10:59:09 +0800
Subject: [PATCH] dma/hisilicon: support registers dump for Kunpeng 930
This patch supports dump Kunpeng930 DMA registers.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/dma/hisilicon/hisi_dmadev.c | 54 +++++++++++++++++++----------
drivers/dma/hisilicon/hisi_dmadev.h | 8 +++++
2 files changed, 44 insertions(+), 18 deletions(-)
diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c
index b99a9bce6c..3917db38b7 100644
--- a/drivers/dma/hisilicon/hisi_dmadev.c
+++ b/drivers/dma/hisilicon/hisi_dmadev.c
@@ -460,29 +460,13 @@ hisi_dma_stats_reset(struct rte_dma_dev *dev, uint16_t vchan)
}
static void
-hisi_dma_get_dump_range(struct hisi_dma_dev *hw, uint32_t *start, uint32_t *end)
-{
- if (hw->reg_layout == HISI_DMA_REG_LAYOUT_HIP08) {
- *start = HISI_DMA_HIP08_DUMP_START_REG;
- *end = HISI_DMA_HIP08_DUMP_END_REG;
- } else {
- *start = 0;
- *end = 0;
- }
-}
-
-static void
-hisi_dma_dump_common(struct hisi_dma_dev *hw, FILE *f)
+hisi_dma_dump_range(struct hisi_dma_dev *hw, FILE *f, uint32_t start,
+ uint32_t end)
{
#define DUMP_REGNUM_PER_LINE 4
- uint32_t start, end;
uint32_t cnt, i;
- hisi_dma_get_dump_range(hw, &start, &end);
-
- (void)fprintf(f, " common-register:\n");
-
cnt = 0;
for (i = start; i <= end; i += sizeof(uint32_t)) {
if (cnt % DUMP_REGNUM_PER_LINE == 0)
@@ -496,6 +480,40 @@ hisi_dma_dump_common(struct hisi_dma_dev *hw, FILE *f)
(void)fprintf(f, "\n");
}
+static void
+hisi_dma_dump_common(struct hisi_dma_dev *hw, FILE *f)
+{
+ struct {
+ uint8_t reg_layout;
+ uint32_t start;
+ uint32_t end;
+ } reg_info[] = {
+ { HISI_DMA_REG_LAYOUT_HIP08,
+ HISI_DMA_HIP08_DUMP_START_REG,
+ HISI_DMA_HIP08_DUMP_END_REG },
+ { HISI_DMA_REG_LAYOUT_HIP09,
+ HISI_DMA_HIP09_DUMP_REGION_A_START_REG,
+ HISI_DMA_HIP09_DUMP_REGION_A_END_REG },
+ { HISI_DMA_REG_LAYOUT_HIP09,
+ HISI_DMA_HIP09_DUMP_REGION_B_START_REG,
+ HISI_DMA_HIP09_DUMP_REGION_B_END_REG },
+ { HISI_DMA_REG_LAYOUT_HIP09,
+ HISI_DMA_HIP09_DUMP_REGION_C_START_REG,
+ HISI_DMA_HIP09_DUMP_REGION_C_END_REG },
+ { HISI_DMA_REG_LAYOUT_HIP09,
+ HISI_DMA_HIP09_DUMP_REGION_D_START_REG,
+ HISI_DMA_HIP09_DUMP_REGION_D_END_REG },
+ };
+ uint32_t i;
+
+ (void)fprintf(f, " common-register:\n");
+ for (i = 0; i < RTE_DIM(reg_info); i++) {
+ if (hw->reg_layout != reg_info[i].reg_layout)
+ continue;
+ hisi_dma_dump_range(hw, f, reg_info[i].start, reg_info[i].end);
+ }
+}
+
static void
hisi_dma_dump_read_queue(struct hisi_dma_dev *hw, uint32_t qoff,
char *buffer, int max_sz)
diff --git a/drivers/dma/hisilicon/hisi_dmadev.h b/drivers/dma/hisilicon/hisi_dmadev.h
index 591aec0b32..1eaa822db1 100644
--- a/drivers/dma/hisilicon/hisi_dmadev.h
+++ b/drivers/dma/hisilicon/hisi_dmadev.h
@@ -121,6 +121,14 @@ enum {
#define HISI_DMA_HIP09_QUEUE_CFG_REG(queue_id) (0x800 + \
(queue_id) * 0x20)
#define HISI_DMA_HIP09_QUEUE_CFG_LINK_DOWN_MASK_B 16
+#define HISI_DMA_HIP09_DUMP_REGION_A_START_REG 0x0
+#define HISI_DMA_HIP09_DUMP_REGION_A_END_REG 0x368
+#define HISI_DMA_HIP09_DUMP_REGION_B_START_REG 0x800
+#define HISI_DMA_HIP09_DUMP_REGION_B_END_REG 0xA08
+#define HISI_DMA_HIP09_DUMP_REGION_C_START_REG 0x1800
+#define HISI_DMA_HIP09_DUMP_REGION_C_END_REG 0x1A4C
+#define HISI_DMA_HIP09_DUMP_REGION_D_START_REG 0x1C00
+#define HISI_DMA_HIP09_DUMP_REGION_D_END_REG 0x1CC4
/**
* In fact, there are multiple states, but it need to pay attention to
--
2.33.0

View File

@ -0,0 +1,78 @@
From 410c9bc8354b4cccc3ae56608ca5f89f03e53cb3 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Thu, 17 Feb 2022 10:59:10 +0800
Subject: [PATCH] dma/hisilicon: add queue full statistics
This patch adds queue full statistics for HiSilicon DMA PMD.
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/dma/hisilicon/hisi_dmadev.c | 12 ++++++++----
drivers/dma/hisilicon/hisi_dmadev.h | 1 +
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c
index 3917db38b7..c36acf01be 100644
--- a/drivers/dma/hisilicon/hisi_dmadev.c
+++ b/drivers/dma/hisilicon/hisi_dmadev.c
@@ -407,6 +407,7 @@ hisi_dma_start(struct rte_dma_dev *dev)
hw->submitted = 0;
hw->completed = 0;
hw->errors = 0;
+ hw->qfulls = 0;
hisi_dma_update_queue_bit(hw, HISI_DMA_QUEUE_CTRL0_REG,
HISI_DMA_QUEUE_CTRL0_EN_B, true);
@@ -455,6 +456,7 @@ hisi_dma_stats_reset(struct rte_dma_dev *dev, uint16_t vchan)
hw->submitted = 0;
hw->completed = 0;
hw->errors = 0;
+ hw->qfulls = 0;
return 0;
}
@@ -566,14 +568,14 @@ hisi_dma_dump(const struct rte_dma_dev *dev, FILE *f)
" ridx: %u cridx: %u\n"
" sq_head: %u sq_tail: %u cq_sq_head: %u\n"
" cq_head: %u cqs_completed: %u cqe_vld: %u\n"
- " submitted: %" PRIu64 " completed: %" PRIu64 " errors %"
- PRIu64"\n",
+ " submitted: %" PRIu64 " completed: %" PRIu64 " errors: %"
+ PRIu64 " qfulls: %" PRIu64 "\n",
hw->revision, hw->queue_id,
hw->sq_depth_mask > 0 ? hw->sq_depth_mask + 1 : 0,
hw->ridx, hw->cridx,
hw->sq_head, hw->sq_tail, hw->cq_sq_head,
hw->cq_head, hw->cqs_completed, hw->cqe_vld,
- hw->submitted, hw->completed, hw->errors);
+ hw->submitted, hw->completed, hw->errors, hw->qfulls);
hisi_dma_dump_queue(hw, f);
hisi_dma_dump_common(hw, f);
@@ -590,8 +592,10 @@ hisi_dma_copy(void *dev_private, uint16_t vchan,
RTE_SET_USED(vchan);
- if (((hw->sq_tail + 1) & hw->sq_depth_mask) == hw->sq_head)
+ if (((hw->sq_tail + 1) & hw->sq_depth_mask) == hw->sq_head) {
+ hw->qfulls++;
return -ENOSPC;
+ }
sqe->dw0 = rte_cpu_to_le_32(SQE_OPCODE_M2M);
sqe->dw1 = 0;
diff --git a/drivers/dma/hisilicon/hisi_dmadev.h b/drivers/dma/hisilicon/hisi_dmadev.h
index 1eaa822db1..90b85322ca 100644
--- a/drivers/dma/hisilicon/hisi_dmadev.h
+++ b/drivers/dma/hisilicon/hisi_dmadev.h
@@ -241,6 +241,7 @@ struct hisi_dma_dev {
uint64_t submitted;
uint64_t completed;
uint64_t errors;
+ uint64_t qfulls;
/**
* The following fields are not accessed in the I/O path, so they are
--
2.33.0

View File

@ -0,0 +1,79 @@
From 033904450b1d52fd3d09e2bb53e529e3ba0ecf77 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Thu, 17 Feb 2022 10:59:11 +0800
Subject: [PATCH] dma/hisilicon: use common PCI device naming
For DMA device 0000:7d:0.0, the original generated dmadev name starts
with the "7d:0.0", which is not expected.
This patch uses rte_pci_device_name API to generates the dmadev name.
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
doc/guides/dmadevs/hisilicon.rst | 4 ++--
drivers/dma/hisilicon/hisi_dmadev.c | 23 +++++++----------------
2 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/doc/guides/dmadevs/hisilicon.rst b/doc/guides/dmadevs/hisilicon.rst
index 81bf090311..8c1f0f8886 100644
--- a/doc/guides/dmadevs/hisilicon.rst
+++ b/doc/guides/dmadevs/hisilicon.rst
@@ -30,8 +30,8 @@ which can be accessed using API from the ``rte_dmadev`` library.
The name of the ``dmadev`` created is like "B:D.F-chX", e.g. DMA 0000:7b:00.0
will create four ``dmadev``,
-the 1st ``dmadev`` name is "7b:00.0-ch0",
-and the 2nd ``dmadev`` name is "7b:00.0-ch1".
+the 1st ``dmadev`` name is "0000:7b:00.0-ch0",
+and the 2nd ``dmadev`` name is "0000:7b:00.0-ch1".
Device Configuration
~~~~~~~~~~~~~~~~~~~~~
diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c
index c36acf01be..9cef2cbfbe 100644
--- a/drivers/dma/hisilicon/hisi_dmadev.c
+++ b/drivers/dma/hisilicon/hisi_dmadev.c
@@ -784,24 +784,15 @@ hisi_dma_burst_capacity(const void *dev_private, uint16_t vchan)
sq_head - 1 - sq_tail;
}
-static void
-hisi_dma_gen_pci_device_name(const struct rte_pci_device *pci_dev,
- char *name, size_t size)
-{
- memset(name, 0, size);
- (void)snprintf(name, size, "%x:%x.%x",
- pci_dev->addr.bus, pci_dev->addr.devid,
- pci_dev->addr.function);
-}
-
static void
hisi_dma_gen_dev_name(const struct rte_pci_device *pci_dev,
- uint8_t queue_id, char *name, size_t size)
+ uint8_t queue_id, char *dev_name, size_t size)
{
- memset(name, 0, size);
- (void)snprintf(name, size, "%x:%x.%x-ch%u",
- pci_dev->addr.bus, pci_dev->addr.devid,
- pci_dev->addr.function, queue_id);
+ char name[RTE_DEV_NAME_MAX_LEN] = { 0 };
+
+ memset(dev_name, 0, size);
+ rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
+ (void)snprintf(dev_name, size, "%s-ch%u", name, queue_id);
}
/**
@@ -917,7 +908,7 @@ hisi_dma_probe(struct rte_pci_driver *pci_drv __rte_unused,
uint8_t i;
int ret;
- hisi_dma_gen_pci_device_name(pci_dev, name, sizeof(name));
+ rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
if (pci_dev->mem_resource[2].addr == NULL) {
HISI_DMA_LOG(ERR, "%s BAR2 is NULL!\n", name);
--
2.33.0

View File

@ -0,0 +1,38 @@
From d8c079a572f3b76ca22fbfe665fb2e5e578ba881 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Thu, 17 Feb 2022 19:36:55 +0800
Subject: [PATCH] app/testpmd: check starting port is not in bonding
In bond, start or stop slave port should be operated by bonding port.
This patch add port_is_bonding_slave in start_port function.
Fixes: 0e545d3047fe ("app/testpmd: check stopping port is not in bonding")
Cc: stable@dpdk.org
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
app/test-pmd/testpmd.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 6d2e52c790..fe2ce19f99 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2726,6 +2726,13 @@ start_port(portid_t pid)
if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
continue;
+ if (port_is_bonding_slave(pi)) {
+ fprintf(stderr,
+ "Please remove port %d from bonded device.\n",
+ pi);
+ continue;
+ }
+
need_check_link_status = 0;
port = &ports[pi];
if (port->port_status == RTE_PORT_STOPPED)
--
2.33.0

View File

@ -0,0 +1,32 @@
From 73d16d660b866aa209dcdc44a698427dac5f2eb7 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Thu, 17 Feb 2022 11:24:51 +0800
Subject: [PATCH] examples/vhost: remove DMA type option help info
The dma-type parameter was not supported when dmadev was
integrated in vhost, but the help info still exists. This
patch deletes it.
Fixes: 53d3f4778c1d ("vhost: integrate dmadev in asynchronous data-path")
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
---
examples/vhost/main.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 3e784f5c6f..68afd398bb 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -608,7 +608,6 @@ us_vhost_usage(const char *prgname)
" --tx-csum [0|1] disable/enable TX checksum offload.\n"
" --tso [0|1] disable/enable TCP segment offload.\n"
" --client register a vhost-user socket as client mode.\n"
- " --dma-type register dma type for your vhost async driver. For example \"ioat\" for now.\n"
" --dmas register dma channel for specific vhost device.\n",
prgname);
}
--
2.33.0

View File

@ -0,0 +1,169 @@
From d57f2899e29a74fffeb876863e1f570084d6437b Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Wed, 9 Feb 2022 15:35:25 +0800
Subject: [PATCH] kni: fix freeing order in device release
The "kni_dev" is the private data of the "net_device" in kni, and allocated
with the "net_device" by calling "alloc_netdev()". The "net_device" is
freed by calling "free_netdev()" when kni release. The freed memory
includes the "kni_dev". So after "kni_dev" should not be accessed after
"net_device" is released.
Fixes: e77fec694936 ("kni: fix possible mbuf leaks and speed up port release")
Cc: stable@dpdk.org
KASAN trace:
[ 85.263717] ==========================================================
[ 85.264418] BUG: KASAN: use-after-free in kni_net_release_fifo_phy+
0x30/0x84 [rte_kni]
[ 85.265139] Read of size 8 at addr ffff000260668d60 by task kni/341
[ 85.265703]
[ 85.265857] CPU: 0 PID: 341 Comm: kni Tainted: G U O
5.15.0-rc4+ #1
[ 85.266525] Hardware name: linux,dummy-virt (DT)
[ 85.266968] Call trace:
[ 85.267220] dump_backtrace+0x0/0x2d0
[ 85.267591] show_stack+0x24/0x30
[ 85.267924] dump_stack_lvl+0x8c/0xb8
[ 85.268294] print_address_description.constprop.0+0x74/0x2b8
[ 85.268855] kasan_report+0x1e4/0x200
[ 85.269224] __asan_load8+0x98/0xd4
[ 85.269577] kni_net_release_fifo_phy+0x30/0x84 [rte_kni]
[ 85.270116] kni_dev_remove.isra.0+0x50/0x64 [rte_kni]
[ 85.270630] kni_ioctl_release+0x254/0x320 [rte_kni]
[ 85.271136] kni_ioctl+0x64/0xb0 [rte_kni]
[ 85.271553] __arm64_sys_ioctl+0xdc/0x120
[ 85.271955] invoke_syscall+0x68/0x1a0
[ 85.272332] el0_svc_common.constprop.0+0x90/0x200
[ 85.272807] do_el0_svc+0x94/0xa4
[ 85.273144] el0_svc+0x78/0x240
[ 85.273463] el0t_64_sync_handler+0x1a8/0x1b0
[ 85.273895] el0t_64_sync+0x1a0/0x1a4
[ 85.274264]
[ 85.274427] Allocated by task 341:
[ 85.274767] kasan_save_stack+0x2c/0x60
[ 85.275157] __kasan_kmalloc+0x90/0xb4
[ 85.275533] __kmalloc_node+0x230/0x594
[ 85.275917] kvmalloc_node+0x8c/0x190
[ 85.276286] alloc_netdev_mqs+0x70/0x6b0
[ 85.276678] kni_ioctl_create+0x224/0xf40 [rte_kni]
[ 85.277166] kni_ioctl+0x9c/0xb0 [rte_kni]
[ 85.277581] __arm64_sys_ioctl+0xdc/0x120
[ 85.277980] invoke_syscall+0x68/0x1a0
[ 85.278357] el0_svc_common.constprop.0+0x90/0x200
[ 85.278830] do_el0_svc+0x94/0xa4
[ 85.279172] el0_svc+0x78/0x240
[ 85.279491] el0t_64_sync_handler+0x1a8/0x1b0
[ 85.279925] el0t_64_sync+0x1a0/0x1a4
[ 85.280292]
[ 85.280454] Freed by task 341:
[ 85.280763] kasan_save_stack+0x2c/0x60
[ 85.281147] kasan_set_track+0x2c/0x40
[ 85.281522] kasan_set_free_info+0x2c/0x50
[ 85.281930] __kasan_slab_free+0xdc/0x140
[ 85.282331] slab_free_freelist_hook+0x90/0x250
[ 85.282782] kfree+0x128/0x580
[ 85.283099] kvfree+0x48/0x60
[ 85.283402] netdev_freemem+0x34/0x44
[ 85.283770] netdev_release+0x50/0x64
[ 85.284138] device_release+0xa0/0x120
[ 85.284516] kobject_put+0xf8/0x160
[ 85.284867] put_device+0x20/0x30
[ 85.285204] free_netdev+0x22c/0x310
[ 85.285562] kni_dev_remove.isra.0+0x48/0x64 [rte_kni]
[ 85.286076] kni_ioctl_release+0x254/0x320 [rte_kni]
[ 85.286573] kni_ioctl+0x64/0xb0 [rte_kni]
[ 85.286992] __arm64_sys_ioctl+0xdc/0x120
[ 85.287392] invoke_syscall+0x68/0x1a0
[ 85.287769] el0_svc_common.constprop.0+0x90/0x200
[ 85.288243] do_el0_svc+0x94/0xa4
[ 85.288579] el0_svc+0x78/0x240
[ 85.288899] el0t_64_sync_handler+0x1a8/0x1b0
[ 85.289332] el0t_64_sync+0x1a0/0x1a4
[ 85.289699]
[ 85.289862] The buggy address belongs to the object at ffff000260668000
[ 85.289862] which belongs to the cache kmalloc-cg-8k of size 8192
[ 85.291079] The buggy address is located 3424 bytes inside of
[ 85.291079] 8192-byte region [ffff000260668000, ffff00026066a000)
[ 85.292213] The buggy address belongs to the page:
[ 85.292684] page:(____ptrval____) refcount:1 mapcount:0 mapping:
0000000000000000 index:0x0 pfn:0x2a0668
[ 85.293585] head:(____ptrval____) order:3 compound_mapcount:0
compound_pincount:0
[ 85.294305] flags: 0xbfff80000010200(slab|head|node=0|zone=2|
lastcpupid=0x7fff)
[ 85.295020] raw: 0bfff80000010200 0000000000000000 dead000000000122
ffff0000c000d680
[ 85.295767] raw: 0000000000000000 0000000080020002 00000001ffffffff
0000000000000000
[ 85.296512] page dumped because: kasan: bad access detected
[ 85.297054]
[ 85.297217] Memory state around the buggy address:
[ 85.297688] ffff000260668c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb
fb fb
[ 85.298384] ffff000260668c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb
fb fb
[ 85.299088] >ffff000260668d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb
fb fb
[ 85.299781] ^
[ 85.300396] ffff000260668d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb
fb fb
[ 85.301092] ffff000260668e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb
fb fb
[ 85.301787] ===========================================================
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
kernel/linux/kni/kni_misc.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c
index ec70190042..780187d8bf 100644
--- a/kernel/linux/kni/kni_misc.c
+++ b/kernel/linux/kni/kni_misc.c
@@ -182,13 +182,17 @@ kni_dev_remove(struct kni_dev *dev)
if (!dev)
return -ENODEV;
+ /*
+ * The memory of kni device is allocated and released together
+ * with net device. Release mbuf before freeing net device.
+ */
+ kni_net_release_fifo_phy(dev);
+
if (dev->net_dev) {
unregister_netdev(dev->net_dev);
free_netdev(dev->net_dev);
}
- kni_net_release_fifo_phy(dev);
-
return 0;
}
@@ -218,8 +222,8 @@ kni_release(struct inode *inode, struct file *file)
dev->pthread = NULL;
}
- kni_dev_remove(dev);
list_del(&dev->list);
+ kni_dev_remove(dev);
}
up_write(&knet->kni_list_lock);
@@ -468,8 +472,8 @@ kni_ioctl_release(struct net *net, uint32_t ioctl_num,
dev->pthread = NULL;
}
- kni_dev_remove(dev);
list_del(&dev->list);
+ kni_dev_remove(dev);
ret = 0;
break;
}
--
2.33.0

View File

@ -0,0 +1,31 @@
From 0983cdc1870f52a360eadb40eab84b34c20b464d Mon Sep 17 00:00:00 2001
From: Jie Hai <haijie1@huawei.com>
Date: Mon, 28 Feb 2022 11:21:41 +0800
Subject: [PATCH] net/hns3: remove duplicate macro definition
This patch fixes duplicate macro definition of HNS3_RSS_CFG_TBL_SIZE.
Fixes: 737f30e1c3ab ("net/hns3: support command interface with firmware")
Cc: stable@dpdk.org
Signed-off-by: Jie Hai <haijie1@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_cmd.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h
index 81bc9e9d98..f9addc6069 100644
--- a/drivers/net/hns3/hns3_cmd.h
+++ b/drivers/net/hns3/hns3_cmd.h
@@ -603,7 +603,6 @@ struct hns3_cfg_gro_status_cmd {
#define HNS3_RSS_HASH_KEY_OFFSET_B 4
-#define HNS3_RSS_CFG_TBL_SIZE 16
#define HNS3_RSS_HASH_KEY_NUM 16
/* Configure the algorithm mode and Hash Key, opcode:0x0D01 */
struct hns3_rss_generic_config_cmd {
--
2.33.0

View File

@ -0,0 +1,35 @@
From cdb9a7ae5f8f3b59b6de9dc2b52387636245e3a5 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Mon, 28 Feb 2022 11:21:45 +0800
Subject: [PATCH] net/hns3: fix RSS TC mode entry
The driver allocates queues only to valid TCs. But the driver also
configure queues for invalid TCs, which is unreasonable.
Fixes: c37ca66f2b27 ("net/hns3: support RSS")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_rss.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 1782d63883..ebf3c60f07 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -601,8 +601,8 @@ hns3_set_rss_tc_mode(struct hns3_hw *hw)
for (i = 0; i < HNS3_MAX_TC_NUM; i++) {
tc_valid[i] = !!(hw->hw_tc_map & BIT(i));
- tc_size[i] = roundup_size;
- tc_offset[i] = rss_size * i;
+ tc_size[i] = tc_valid[i] ? roundup_size : 0;
+ tc_offset[i] = tc_valid[i] ? rss_size * i : 0;
}
hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_TC_MODE, false);
--
2.33.0

View File

@ -0,0 +1,103 @@
From 87f9628e2c786dff500139baf59720693e46b0bc Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Mon, 28 Feb 2022 11:21:46 +0800
Subject: [PATCH] net/hns3: fix VF RSS TC mode entry
For packets with VLAN priorities destined for the VF, hardware still
assign Rx queue based on the Up-to-TC mapping PF configured. But VF has
only one TC. If other TC don't enable, it causes that the priority
packets that aren't destined for TC0 aren't received by RSS hash but is
destined for queue 0. So driver has to enable the unused TC by using TC0
queue mapping configuration.
Fixes: c37ca66f2b27 ("net/hns3: support RSS")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_rss.c | 56 +++++++++++++++++++++++++++----------
1 file changed, 41 insertions(+), 15 deletions(-)
diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index ebf3c60f07..1493b10f96 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -578,33 +578,59 @@ hns3_dev_rss_reta_query(struct rte_eth_dev *dev,
return 0;
}
-/*
- * Used to configure the tc_size and tc_offset.
- */
+static void
+hns3_set_rss_tc_mode_entry(struct hns3_hw *hw, uint8_t *tc_valid,
+ uint16_t *tc_size, uint16_t *tc_offset,
+ uint8_t tc_num)
+{
+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
+ uint16_t rss_size = hw->alloc_rss_size;
+ uint16_t roundup_size;
+ uint16_t i;
+
+ roundup_size = roundup_pow_of_two(rss_size);
+ roundup_size = ilog2(roundup_size);
+
+ for (i = 0; i < tc_num; i++) {
+ if (hns->is_vf) {
+ /*
+ * For packets with VLAN priorities destined for the VF,
+ * hardware still assign Rx queue based on the Up-to-TC
+ * mapping PF configured. But VF has only one TC. If
+ * other TC don't enable, it causes that the priority
+ * packets that aren't destined for TC0 aren't received
+ * by RSS hash but is destined for queue 0. So driver
+ * has to enable the unused TC by using TC0 queue
+ * mapping configuration.
+ */
+ tc_valid[i] = (hw->hw_tc_map & BIT(i)) ?
+ !!(hw->hw_tc_map & BIT(i)) : 1;
+ tc_size[i] = roundup_size;
+ tc_offset[i] = (hw->hw_tc_map & BIT(i)) ?
+ rss_size * i : 0;
+ } else {
+ tc_valid[i] = !!(hw->hw_tc_map & BIT(i));
+ tc_size[i] = tc_valid[i] ? roundup_size : 0;
+ tc_offset[i] = tc_valid[i] ? rss_size * i : 0;
+ }
+ }
+}
+
static int
hns3_set_rss_tc_mode(struct hns3_hw *hw)
{
- uint16_t rss_size = hw->alloc_rss_size;
struct hns3_rss_tc_mode_cmd *req;
uint16_t tc_offset[HNS3_MAX_TC_NUM];
uint8_t tc_valid[HNS3_MAX_TC_NUM];
uint16_t tc_size[HNS3_MAX_TC_NUM];
struct hns3_cmd_desc desc;
- uint16_t roundup_size;
uint16_t i;
int ret;
- req = (struct hns3_rss_tc_mode_cmd *)desc.data;
-
- roundup_size = roundup_pow_of_two(rss_size);
- roundup_size = ilog2(roundup_size);
-
- for (i = 0; i < HNS3_MAX_TC_NUM; i++) {
- tc_valid[i] = !!(hw->hw_tc_map & BIT(i));
- tc_size[i] = tc_valid[i] ? roundup_size : 0;
- tc_offset[i] = tc_valid[i] ? rss_size * i : 0;
- }
+ hns3_set_rss_tc_mode_entry(hw, tc_valid, tc_size,
+ tc_offset, HNS3_MAX_TC_NUM);
+ req = (struct hns3_rss_tc_mode_cmd *)desc.data;
hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_TC_MODE, false);
for (i = 0; i < HNS3_MAX_TC_NUM; i++) {
uint16_t mode = 0;
--
2.33.0

View File

@ -0,0 +1,51 @@
From d6a9f8fb26b8d6adaac20d6a303faa5c5ba4d5bc Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Wed, 2 Mar 2022 08:35:01 +0800
Subject: [PATCH] net/hns3: increase time waiting for PF reset completion
On the case that PF and VF need to be reset, after the hardware reset is
complete, VF needs wait for 1 second to restore the configuration so
that VF does not fail to recover because PF reset isn't complete. But
the estimated time is not sufficient. This patch fixes it to 5 seconds.
Fixes: 2790c6464725 ("net/hns3: support device reset")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_ethdev_vf.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 06ddf64184..9091706fe5 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1877,6 +1877,7 @@ hns3vf_is_reset_pending(struct hns3_adapter *hns)
static int
hns3vf_wait_hardware_ready(struct hns3_adapter *hns)
{
+#define HNS3_WAIT_PF_RESET_READY_TIME 5
struct hns3_hw *hw = &hns->hw;
struct hns3_wait_data *wait_data = hw->reset.wait_data;
struct timeval tv;
@@ -1897,12 +1898,14 @@ hns3vf_wait_hardware_ready(struct hns3_adapter *hns)
return 0;
wait_data->check_completion = NULL;
- wait_data->interval = 1 * MSEC_PER_SEC * USEC_PER_MSEC;
+ wait_data->interval = HNS3_WAIT_PF_RESET_READY_TIME *
+ MSEC_PER_SEC * USEC_PER_MSEC;
wait_data->count = 1;
wait_data->result = HNS3_WAIT_REQUEST;
rte_eal_alarm_set(wait_data->interval, hns3_wait_callback,
wait_data);
- hns3_warn(hw, "hardware is ready, delay 1 sec for PF reset complete");
+ hns3_warn(hw, "hardware is ready, delay %d sec for PF reset complete",
+ HNS3_WAIT_PF_RESET_READY_TIME);
return -EAGAIN;
} else if (wait_data->result == HNS3_WAIT_TIMEOUT) {
hns3_clock_gettime(&tv);
--
2.33.0

View File

@ -0,0 +1,56 @@
From f5e72e8e8d57b331baf1a86d15eb7fae921f57fb Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Tue, 3 May 2022 18:02:13 +0800
Subject: [PATCH] net/bonding: fix stopping non-active slaves
When stopping a bonded port, all slaves should be stopped. But only
active slaves are stopped.
So fix by stopping all slave ports and later do "deactivate_slave()" for
active slaves.
Fixes: 0911d4ec0183 ("net/bonding: fix crash when stopping mode 4 port")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/bonding/rte_eth_bond_pmd.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 5cbe89031b..605fc2ffb5 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2118,18 +2118,20 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
internals->link_status_polling_enabled = 0;
for (i = 0; i < internals->slave_count; i++) {
uint16_t slave_id = internals->slaves[i].port_id;
+
+ internals->slaves[i].last_link_status = 0;
+ ret = rte_eth_dev_stop(slave_id);
+ if (ret != 0) {
+ RTE_BOND_LOG(ERR, "Failed to stop device on port %u",
+ slave_id);
+ return ret;
+ }
+
+ /* active slaves need to be deactivated. */
if (find_slave_by_id(internals->active_slaves,
internals->active_slave_count, slave_id) !=
- internals->active_slave_count) {
- internals->slaves[i].last_link_status = 0;
- ret = rte_eth_dev_stop(slave_id);
- if (ret != 0) {
- RTE_BOND_LOG(ERR, "Failed to stop device on port %u",
- slave_id);
- return ret;
- }
+ internals->active_slave_count)
deactivate_slave(eth_dev, slave_id);
- }
}
return 0;
--
2.33.0

View File

@ -0,0 +1,37 @@
From 1c5c6cd85f8cab2af92d265b6c7671df0b82e6fb Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Tue, 3 May 2022 18:02:14 +0800
Subject: [PATCH] net/bonding: fix slave stop and remove on port close
All slaves will be stopped and removed when closing a bonded port.
But the while loop can not end if both rte_eth_dev_stop and
rte_eth_bond_slave_remove fails, runs infinitely.
This is because the skipped slave port counted in both function failures
but it should be counted only one.
Fixing by not continue to process in the loop after first failure.
Fixes: fb0379bc5db3 ("net/bonding: check stop call status")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/bonding/rte_eth_bond_pmd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 605fc2ffb5..f0668a636f 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2156,6 +2156,7 @@ bond_ethdev_close(struct rte_eth_dev *dev)
RTE_BOND_LOG(ERR, "Failed to stop device on port %u",
port_id);
skipped++;
+ continue;
}
if (rte_eth_bond_slave_remove(bond_port_id, port_id) != 0) {
--
2.33.0

View File

@ -0,0 +1,186 @@
From 1a1de9879f58b4fd202ecd481c56ae9777207fe9 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Thu, 5 May 2022 20:27:01 +0800
Subject: [PATCH] net/hns3: fix order of clearing imissed register in PF
Clearing imissed registers in PF hardware depends on the
'drop_stats_mode' in struct hns3_hw. The variable is initialized after
the "hns3_get_configuration". But, in current code, the clearing
operation runs before the function.
So this patch fixes this order. In addition, this patch extracts a
public function to initialize and uninitialize statistics to improve the
maintainability of these codes.
Fixes: 3e9f3042d7c8 ("net/hns3: add imissed packet stats")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 13 +++----------
drivers/net/hns3/hns3_ethdev_vf.c | 13 +++----------
drivers/net/hns3/hns3_stats.c | 27 ++++++++++++++++++++++++---
drivers/net/hns3/hns3_stats.h | 5 ++---
4 files changed, 32 insertions(+), 26 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 4e089e682f..5aed7046d8 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -4622,13 +4622,6 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)
goto err_cmd_init;
}
- /* Hardware statistics of imissed registers cleared. */
- ret = hns3_update_imissed_stats(hw, true);
- if (ret) {
- hns3_err(hw, "clear imissed stats failed, ret = %d", ret);
- goto err_cmd_init;
- }
-
hns3_config_all_msix_error(hw, true);
ret = rte_intr_callback_register(pci_dev->intr_handle,
@@ -4654,7 +4647,7 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)
goto err_get_config;
}
- ret = hns3_tqp_stats_init(hw);
+ ret = hns3_stats_init(hw);
if (ret)
goto err_get_config;
@@ -4700,7 +4693,7 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)
err_fdir:
hns3_uninit_umv_space(hw);
err_init_hw:
- hns3_tqp_stats_uninit(hw);
+ hns3_stats_uninit(hw);
err_get_config:
hns3_pf_disable_irq0(hw);
rte_intr_disable(pci_dev->intr_handle);
@@ -4734,7 +4727,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev)
hns3_flow_uninit(eth_dev);
hns3_fdir_filter_uninit(hns);
hns3_uninit_umv_space(hw);
- hns3_tqp_stats_uninit(hw);
+ hns3_stats_uninit(hw);
hns3_config_mac_tnl_int(hw, false);
hns3_pf_disable_irq0(hw);
rte_intr_disable(pci_dev->intr_handle);
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 9091706fe5..9e9fdc4144 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1510,17 +1510,10 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev)
goto err_get_config;
}
- ret = hns3_tqp_stats_init(hw);
+ ret = hns3_stats_init(hw);
if (ret)
goto err_get_config;
- /* Hardware statistics of imissed registers cleared. */
- ret = hns3_update_imissed_stats(hw, true);
- if (ret) {
- hns3_err(hw, "clear imissed stats failed, ret = %d", ret);
- goto err_set_tc_queue;
- }
-
ret = hns3_queue_to_tc_mapping(hw, hw->tqps_num, hw->tqps_num);
if (ret) {
PMD_INIT_LOG(ERR, "failed to set tc info, ret = %d.", ret);
@@ -1548,7 +1541,7 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev)
return 0;
err_set_tc_queue:
- hns3_tqp_stats_uninit(hw);
+ hns3_stats_uninit(hw);
err_get_config:
hns3vf_disable_irq0(hw);
@@ -1579,7 +1572,7 @@ hns3vf_uninit_vf(struct rte_eth_dev *eth_dev)
(void)hns3vf_set_alive(hw, false);
(void)hns3vf_set_promisc_mode(hw, false, false, false);
hns3_flow_uninit(eth_dev);
- hns3_tqp_stats_uninit(hw);
+ hns3_stats_uninit(hw);
hns3vf_disable_irq0(hw);
rte_intr_disable(pci_dev->intr_handle);
hns3_intr_unregister(pci_dev->intr_handle, hns3vf_interrupt_handler,
diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c
index 806720faff..e4a5dcf2f8 100644
--- a/drivers/net/hns3/hns3_stats.c
+++ b/drivers/net/hns3/hns3_stats.c
@@ -540,7 +540,7 @@ hns3_update_port_tx_ssu_drop_stats(struct hns3_hw *hw)
return 0;
}
-int
+static int
hns3_update_imissed_stats(struct hns3_hw *hw, bool is_clear)
{
struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
@@ -1476,7 +1476,7 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev)
return 0;
}
-int
+static int
hns3_tqp_stats_init(struct hns3_hw *hw)
{
struct hns3_tqp_stats *tqp_stats = &hw->tqp_stats;
@@ -1500,7 +1500,7 @@ hns3_tqp_stats_init(struct hns3_hw *hw)
return 0;
}
-void
+static void
hns3_tqp_stats_uninit(struct hns3_hw *hw)
{
struct hns3_tqp_stats *tqp_stats = &hw->tqp_stats;
@@ -1521,3 +1521,24 @@ hns3_tqp_stats_clear(struct hns3_hw *hw)
memset(stats->rcb_rx_ring_pktnum, 0, sizeof(uint64_t) * hw->tqps_num);
memset(stats->rcb_tx_ring_pktnum, 0, sizeof(uint64_t) * hw->tqps_num);
}
+
+int
+hns3_stats_init(struct hns3_hw *hw)
+{
+ int ret;
+
+ /* Hardware statistics of imissed registers cleared. */
+ ret = hns3_update_imissed_stats(hw, true);
+ if (ret) {
+ hns3_err(hw, "clear imissed stats failed, ret = %d", ret);
+ return ret;
+ }
+
+ return hns3_tqp_stats_init(hw);
+}
+
+void
+hns3_stats_uninit(struct hns3_hw *hw)
+{
+ hns3_tqp_stats_uninit(hw);
+}
diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h
index c81d351082..e89dc97632 100644
--- a/drivers/net/hns3/hns3_stats.h
+++ b/drivers/net/hns3/hns3_stats.h
@@ -161,9 +161,8 @@ int hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
struct rte_eth_xstat_name *xstats_names,
uint32_t size);
int hns3_stats_reset(struct rte_eth_dev *dev);
-int hns3_tqp_stats_init(struct hns3_hw *hw);
-void hns3_tqp_stats_uninit(struct hns3_hw *hw);
-int hns3_update_imissed_stats(struct hns3_hw *hw, bool is_clear);
+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);
#endif /* _HNS3_STATS_H_ */
--
2.33.0

View File

@ -0,0 +1,432 @@
From dd4cf775f6c2f7dc18c6845983bc84c6351326c4 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Thu, 5 May 2022 20:27:02 +0800
Subject: [PATCH 16/25] net/hns3: fix MAC and queues HW statistics overflow
The MAC and queues statistics are 32-bit registers in hardware. If
hardware statistics are not obtained for a long time, these statistics
will be overflow.
So PF and VF driver have to periodically obtain and save these
statistics. Since the periodical task and the stats API are in different
threads, we introduce a statistics lock to protect the statistics.
Fixes: 8839c5e202f3 ("net/hns3: support device stats")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 6 +-
drivers/net/hns3/hns3_ethdev.h | 6 ++
drivers/net/hns3/hns3_ethdev_vf.c | 6 +-
drivers/net/hns3/hns3_stats.c | 144 +++++++++++++++++++++---------
drivers/net/hns3/hns3_stats.h | 1 +
5 files changed, 116 insertions(+), 47 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index dc37914aea..af317a8c47 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -4365,10 +4365,12 @@ hns3_service_handler(void *param)
struct hns3_adapter *hns = eth_dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
- if (!hns3_is_reset_pending(hns))
+ if (!hns3_is_reset_pending(hns)) {
hns3_update_linkstatus_and_event(hw, true);
- else
+ hns3_update_hw_stats(hw);
+ } else {
hns3_warn(hw, "Cancel the query when reset is pending");
+ }
rte_eal_alarm_set(HNS3_SERVICE_INTERVAL, hns3_service_handler, eth_dev);
}
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index d6d82c55f9..889220237c 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -503,6 +503,12 @@ struct hns3_hw {
uint32_t mac_stats_reg_num;
struct hns3_rx_missed_stats imissed_stats;
uint64_t oerror_stats;
+ /*
+ * The lock is used to protect statistics update in stats APIs and
+ * periodic task.
+ */
+ rte_spinlock_t stats_lock;
+
uint32_t fw_version;
uint16_t pf_vf_if_version; /* version of communication interface */
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index b66047c09f..70b773cfe9 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1338,10 +1338,12 @@ hns3vf_service_handler(void *param)
* Before querying the link status, check whether there is a reset
* pending, and if so, abandon the query.
*/
- if (!hns3vf_is_reset_pending(hns))
+ if (!hns3vf_is_reset_pending(hns)) {
hns3vf_request_link_info(hw);
- else
+ hns3_update_hw_stats(hw);
+ } else {
hns3_warn(hw, "Cancel the query when reset is pending");
+ }
rte_eal_alarm_set(HNS3VF_SERVICE_INTERVAL, hns3vf_service_handler,
eth_dev);
diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c
index 03719cd014..9b7ad067aa 100644
--- a/drivers/net/hns3/hns3_stats.c
+++ b/drivers/net/hns3/hns3_stats.c
@@ -584,6 +584,28 @@ hns3_update_oerror_stats(struct hns3_hw *hw, bool is_clear)
return 0;
}
+static void
+hns3_rcb_rx_ring_stats_get(struct hns3_rx_queue *rxq,
+ struct hns3_tqp_stats *stats)
+{
+ uint32_t cnt;
+
+ cnt = hns3_read_dev(rxq, HNS3_RING_RX_PKTNUM_RECORD_REG);
+ stats->rcb_rx_ring_pktnum_rcd += cnt;
+ stats->rcb_rx_ring_pktnum[rxq->queue_id] += cnt;
+}
+
+static void
+hns3_rcb_tx_ring_stats_get(struct hns3_tx_queue *txq,
+ struct hns3_tqp_stats *stats)
+{
+ uint32_t cnt;
+
+ cnt = hns3_read_dev(txq, HNS3_RING_TX_PKTNUM_RECORD_REG);
+ stats->rcb_tx_ring_pktnum_rcd += cnt;
+ stats->rcb_tx_ring_pktnum[txq->queue_id] += cnt;
+}
+
/*
* Query tqp tx queue statistics ,opcode id: 0x0B03.
* Query tqp rx queue statistics ,opcode id: 0x0B13.
@@ -604,16 +626,14 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats)
struct hns3_tqp_stats *stats = &hw->tqp_stats;
struct hns3_rx_queue *rxq;
struct hns3_tx_queue *txq;
- uint64_t cnt;
uint16_t i;
int ret;
/* Update imissed stats */
ret = hns3_update_imissed_stats(hw, false);
if (ret) {
- hns3_err(hw, "update imissed stats failed, ret = %d",
- ret);
- return ret;
+ hns3_err(hw, "update imissed stats failed, ret = %d", ret);
+ goto out;
}
rte_stats->imissed = imissed_stats->rpu_rx_drop_cnt +
imissed_stats->ssu_rx_drop_cnt;
@@ -624,15 +644,12 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats)
if (rxq == NULL)
continue;
- cnt = hns3_read_dev(rxq, HNS3_RING_RX_PKTNUM_RECORD_REG);
- /*
- * Read hardware and software in adjacent positions to minumize
- * the timing variance.
- */
+ 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;
- stats->rcb_rx_ring_pktnum_rcd += cnt;
- stats->rcb_rx_ring_pktnum[i] += cnt;
rte_stats->ibytes += rxq->basic_stats.bytes;
}
@@ -642,17 +659,16 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats)
if (txq == NULL)
continue;
- cnt = hns3_read_dev(txq, HNS3_RING_TX_PKTNUM_RECORD_REG);
- stats->rcb_tx_ring_pktnum_rcd += cnt;
- stats->rcb_tx_ring_pktnum[i] += cnt;
+ 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;
}
ret = hns3_update_oerror_stats(hw, false);
if (ret) {
- hns3_err(hw, "update oerror stats failed, ret = %d",
- ret);
- return ret;
+ hns3_err(hw, "update oerror stats failed, ret = %d", ret);
+ goto out;
}
rte_stats->oerrors = hw->oerror_stats;
@@ -667,8 +683,8 @@ 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;
-
- return 0;
+out:
+ return ret;
}
int
@@ -688,7 +704,7 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev)
ret = hns3_update_imissed_stats(hw, true);
if (ret) {
hns3_err(hw, "clear imissed stats failed, ret = %d", ret);
- return ret;
+ goto out;
}
/*
@@ -697,9 +713,8 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev)
*/
ret = hns3_update_oerror_stats(hw, true);
if (ret) {
- hns3_err(hw, "clear oerror stats failed, ret = %d",
- ret);
- return ret;
+ hns3_err(hw, "clear oerror stats failed, ret = %d", ret);
+ goto out;
}
for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
@@ -717,6 +732,7 @@ 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));
@@ -724,6 +740,7 @@ 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 */
@@ -732,16 +749,20 @@ 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);
-
- return 0;
+ rte_spinlock_unlock(&hw->stats_lock);
+out:
+ return ret;
}
static int
@@ -908,7 +929,6 @@ hns3_rxq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
struct hns3_rx_basic_stats *rxq_stats;
struct hns3_rx_queue *rxq;
uint16_t i, j;
- uint32_t cnt;
char *val;
for (i = 0; i < dev->data->nb_rx_queues; i++) {
@@ -916,16 +936,10 @@ hns3_rxq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
if (rxq == NULL)
continue;
- cnt = hns3_read_dev(rxq, HNS3_RING_RX_PKTNUM_RECORD_REG);
- /*
- * Read hardware and software in adjacent positions to minimize
- * the time difference.
- */
+ hns3_rcb_rx_ring_stats_get(rxq, stats);
rxq_stats = &rxq->basic_stats;
rxq_stats->errors = rxq->err_stats.l2_errors +
rxq->err_stats.pkt_len_errors;
- stats->rcb_rx_ring_pktnum_rcd += cnt;
- stats->rcb_rx_ring_pktnum[i] += cnt;
/*
* If HW statistics are reset by stats_reset, but a lot of
@@ -955,7 +969,6 @@ hns3_txq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
struct hns3_tx_basic_stats *txq_stats;
struct hns3_tx_queue *txq;
uint16_t i, j;
- uint32_t cnt;
char *val;
for (i = 0; i < dev->data->nb_tx_queues; i++) {
@@ -963,9 +976,7 @@ hns3_txq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
if (txq == NULL)
continue;
- cnt = hns3_read_dev(txq, HNS3_RING_TX_PKTNUM_RECORD_REG);
- stats->rcb_tx_ring_pktnum_rcd += cnt;
- stats->rcb_tx_ring_pktnum[i] += cnt;
+ hns3_rcb_tx_ring_stats_get(txq, stats);
txq_stats = &txq->basic_stats;
txq_stats->packets = stats->rcb_tx_ring_pktnum[i];
@@ -1050,6 +1061,7 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
count = 0;
+ rte_spinlock_lock(&hw->stats_lock);
hns3_tqp_basic_stats_get(dev, xstats, &count);
if (!hns->is_vf) {
@@ -1057,6 +1069,7 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
ret = hns3_query_update_mac_stats(dev);
if (ret < 0) {
hns3_err(hw, "Update Mac stats fail : %d", ret);
+ rte_spinlock_unlock(&hw->stats_lock);
return ret;
}
@@ -1068,11 +1081,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);
+ hns3_err(hw, "update imissed stats failed, ret = %d", ret);
return ret;
}
@@ -1101,8 +1114,10 @@ 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);
return count;
}
@@ -1453,6 +1468,7 @@ int
hns3_dev_xstats_reset(struct rte_eth_dev *dev)
{
struct hns3_adapter *hns = dev->data->dev_private;
+ struct hns3_hw *hw = &hns->hw;
int ret;
/* Clear tqp stats */
@@ -1460,20 +1476,22 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev)
if (ret)
return ret;
+ rte_spinlock_lock(&hw->stats_lock);
hns3_tqp_dfx_stats_clear(dev);
/* Clear reset stats */
memset(&hns->hw.reset.stats, 0, sizeof(struct hns3_reset_stats));
if (hns->is_vf)
- return 0;
+ goto out;
/* HW registers are cleared on read */
ret = hns3_mac_stats_reset(dev);
- if (ret)
- return ret;
- return 0;
+out:
+ rte_spinlock_unlock(&hw->stats_lock);
+
+ return ret;
}
static int
@@ -1527,6 +1545,7 @@ hns3_stats_init(struct hns3_hw *hw)
{
int ret;
+ rte_spinlock_init(&hw->stats_lock);
/* Hardware statistics of imissed registers cleared. */
ret = hns3_update_imissed_stats(hw, true);
if (ret) {
@@ -1542,3 +1561,42 @@ hns3_stats_uninit(struct hns3_hw *hw)
{
hns3_tqp_stats_uninit(hw);
}
+
+static void
+hns3_update_queues_stats(struct hns3_hw *hw)
+{
+ struct rte_eth_dev_data *data = hw->data;
+ struct hns3_rx_queue *rxq;
+ struct hns3_tx_queue *txq;
+ uint16_t i;
+
+ for (i = 0; i < data->nb_rx_queues; i++) {
+ rxq = data->rx_queues[i];
+ if (rxq != NULL)
+ hns3_rcb_rx_ring_stats_get(rxq, &hw->tqp_stats);
+ }
+
+ for (i = 0; i < data->nb_tx_queues; i++) {
+ txq = data->tx_queues[i];
+ if (txq != NULL)
+ hns3_rcb_tx_ring_stats_get(txq, &hw->tqp_stats);
+ }
+}
+
+/*
+ * Some hardware statistics registers are not 64-bit. If hardware statistics are
+ * not obtained for a long time, these statistics may be reversed. This function
+ * is used to update these hardware statistics in periodic task.
+ */
+void
+hns3_update_hw_stats(struct hns3_hw *hw)
+{
+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
+
+ rte_spinlock_lock(&hw->stats_lock);
+ if (!hns->is_vf)
+ hns3_update_mac_stats(hw);
+
+ hns3_update_queues_stats(hw);
+ rte_spinlock_unlock(&hw->stats_lock);
+}
diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h
index e89dc97632..b5cd6188b4 100644
--- a/drivers/net/hns3/hns3_stats.h
+++ b/drivers/net/hns3/hns3_stats.h
@@ -164,5 +164,6 @@ int hns3_stats_reset(struct rte_eth_dev *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);
+void hns3_update_hw_stats(struct hns3_hw *hw);
#endif /* _HNS3_STATS_H_ */
--
2.30.0

View File

@ -0,0 +1,45 @@
From ec0147b5690e6cae2cc4555f78b87defee59c946 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Thu, 5 May 2022 20:27:03 +0800
Subject: [PATCH] net/hns3: fix pseudo-sharing between threads
Some fields in the end of 'struct hns3_rx_queue' and
'struct hns3_tx_queue' are not accessed in the I/O path.
But these fields may be accessed in other threads, which may lead to the
problem of cache pseudo-sharing of IO threads. This patch add a
cacheline alignment to avoid it.
Fixes: 9261fd3caf1f ("net/hns3: improve IO path data cache usage")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_rxtx.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h
index a000318357..62efc854e4 100644
--- a/drivers/net/hns3/hns3_rxtx.h
+++ b/drivers/net/hns3/hns3_rxtx.h
@@ -348,7 +348,7 @@ struct hns3_rx_queue {
* The following fields are not accessed in the I/O path, so they are
* placed at the end.
*/
- void *io_base;
+ void *io_base __rte_cache_aligned;
struct hns3_adapter *hns;
uint64_t rx_ring_phys_addr; /* RX ring DMA address */
const struct rte_memzone *mz;
@@ -521,7 +521,7 @@ struct hns3_tx_queue {
* The following fields are not accessed in the I/O path, so they are
* placed at the end.
*/
- void *io_base;
+ void *io_base __rte_cache_aligned;
struct hns3_adapter *hns;
uint64_t tx_ring_phys_addr; /* TX ring DMA address */
const struct rte_memzone *mz;
--
2.33.0

View File

@ -0,0 +1,50 @@
From 2d287ea3c2301219c201617df15efa161deabf76 Mon Sep 17 00:00:00 2001
From: Chengwen Feng <fengchengwen@huawei.com>
Date: Thu, 5 May 2022 20:27:04 +0800
Subject: [PATCH] net/hns3: fix mbuf free on Tx done cleanup
Currently, the hns3 PMD may free more mbufs than free_cnt parameter,
this is an incorrect implementation. This patch fixes it.
Fixes: 0b77e8f3d364 ("net/hns3: optimize Tx performance")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_rxtx.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index a28de06dfd..0c91e4721e 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4595,7 +4595,7 @@ 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_free_cnt;
+ uint16_t round_cnt;
uint32_t idx;
if (free_cnt == 0 || free_cnt > txq->nb_tx_desc)
@@ -4604,13 +4604,13 @@ hns3_tx_done_cleanup_full(struct hns3_tx_queue *txq, uint32_t free_cnt)
if (txq->tx_rs_thresh == 0)
return 0;
- round_free_cnt = roundup(free_cnt, txq->tx_rs_thresh);
- for (idx = 0; idx < round_free_cnt; idx += txq->tx_rs_thresh) {
+ 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)
break;
}
- return RTE_MIN(idx, free_cnt);
+ return idx;
}
int
--
2.33.0

View File

@ -0,0 +1,214 @@
From 75ccc3f3d7fa06901d5b768448be4dc9f31f550a Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Thu, 5 May 2022 20:27:05 +0800
Subject: [PATCH] net/hns3: fix RSS disable
Currently, hns3 PMD disable RSS by resetting redirection table when user
set rss_hf to 0 so as to all packets go to queue 0. The implementation
may cause following problems:
1) the same type packet may go to different queue on the case of
disabling all tuples and partial tuples. The problem is determined by
hardware design.
2) affect the configuration of redirection table and user experience.
For hns3 hardware, the packets with RSS disabled are always go to the
queue corresponding to first entry of the redirection table. Generally,
disable RSS should be implemented by disabling all tuples, This patch
fix the implementation.
Fixes: c37ca66f2b27 ("net/hns3: support RSS")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 1 -
drivers/net/hns3/hns3_flow.c | 6 +--
drivers/net/hns3/hns3_rss.c | 93 +++++++---------------------------
3 files changed, 18 insertions(+), 82 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 1d9b19d83e..4d5a595aab 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -2015,7 +2015,6 @@ hns3_dev_configure(struct rte_eth_dev *dev)
goto cfg_err;
}
- /* When RSS is not configured, redirect the packet queue 0 */
if ((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
conf->rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
rss_conf = conf->rx_adv_conf.rss_conf;
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index aba07aaa6f..feabac9f41 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1446,13 +1446,9 @@ hns3_disable_rss(struct hns3_hw *hw)
{
int ret;
- /* Redirected the redirection table to queue 0 */
- ret = hns3_rss_reset_indir_table(hw);
+ ret = hns3_set_rss_tuple_by_rss_hf(hw, &hw->rss_info.rss_tuple_sets, 0);
if (ret)
return ret;
-
- /* Disable RSS */
- hw->rss_info.conf.types = 0;
hw->rss_dis_flag = true;
return 0;
diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 1493b10f96..1c703952b9 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -237,31 +237,6 @@ hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key)
return 0;
}
-/*
- * Used to configure the tuple selection for RSS hash input.
- */
-static int
-hns3_rss_set_input_tuple(struct hns3_hw *hw)
-{
- struct hns3_rss_conf *rss_config = &hw->rss_info;
- struct hns3_rss_input_tuple_cmd *req;
- struct hns3_cmd_desc desc_tuple;
- int ret;
-
- hns3_cmd_setup_basic_desc(&desc_tuple, HNS3_OPC_RSS_INPUT_TUPLE, false);
-
- req = (struct hns3_rss_input_tuple_cmd *)desc_tuple.data;
-
- req->tuple_field =
- rte_cpu_to_le_64(rss_config->rss_tuple_sets.rss_tuple_fields);
-
- ret = hns3_cmd_send(hw, &desc_tuple, 1);
- if (ret)
- hns3_err(hw, "Configure RSS input tuple mode failed %d", ret);
-
- return ret;
-}
-
/*
* rss_indirection_table command function, opcode:0x0D07.
* Used to configure the indirection table of rss.
@@ -382,6 +357,8 @@ hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw,
}
tuple->rss_tuple_fields = rte_le_to_cpu_64(req->tuple_field);
+ /* Update supported flow types when set tuple success */
+ hw->rss_info.conf.types = rss_hf;
return 0;
}
@@ -402,7 +379,6 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets;
- struct hns3_rss_conf *rss_cfg = &hw->rss_info;
uint8_t key_len = rss_conf->rss_key_len;
uint64_t rss_hf = rss_conf->rss_hf;
uint8_t *key = rss_conf->rss_key;
@@ -416,22 +392,6 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
if (ret)
goto conf_err;
- if (rss_cfg->conf.types && rss_hf == 0) {
- /* Disable RSS, reset indirection table by local variable */
- ret = hns3_rss_reset_indir_table(hw);
- if (ret)
- goto conf_err;
- } else if (rss_hf && rss_cfg->conf.types == 0) {
- /* Enable RSS, restore indirection table by hw's config */
- ret = hns3_set_rss_indir_table(hw, rss_cfg->rss_indirection_tbl,
- hw->rss_ind_tbl_size);
- if (ret)
- goto conf_err;
- }
-
- /* Update supported flow types when set tuple success */
- rss_cfg->conf.types = rss_hf;
-
if (key) {
if (key_len != HNS3_RSS_KEY_SIZE) {
hns3_err(hw, "The hash key len(%u) is invalid",
@@ -697,7 +657,8 @@ hns3_config_rss(struct hns3_adapter *hns)
struct hns3_hw *hw = &hns->hw;
struct hns3_rss_conf *rss_cfg = &hw->rss_info;
uint8_t *hash_key = rss_cfg->key;
- int ret, ret1;
+ uint64_t rss_hf;
+ int ret;
enum rte_eth_rx_mq_mode mq_mode = hw->data->dev_conf.rxmode.mq_mode;
@@ -713,51 +674,31 @@ hns3_config_rss(struct hns3_adapter *hns)
break;
}
- /* When RSS is off, redirect the packet queue 0 */
- if (((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) == 0)
- hns3_rss_uninit(hns);
-
/* Configure RSS hash algorithm and hash key offset */
ret = hns3_rss_set_algo_key(hw, hash_key);
if (ret)
return ret;
- /* Configure the tuple selection for RSS hash input */
- ret = hns3_rss_set_input_tuple(hw);
+ ret = hns3_set_rss_indir_table(hw, rss_cfg->rss_indirection_tbl,
+ hw->rss_ind_tbl_size);
if (ret)
return ret;
- /*
- * When RSS is off, it doesn't need to configure rss redirection table
- * to hardware.
- */
- if (((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)) {
- ret = hns3_set_rss_indir_table(hw, rss_cfg->rss_indirection_tbl,
- hw->rss_ind_tbl_size);
- if (ret)
- goto rss_tuple_uninit;
- }
-
ret = hns3_set_rss_tc_mode(hw);
if (ret)
- goto rss_indir_table_uninit;
-
- return ret;
-
-rss_indir_table_uninit:
- if (((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)) {
- ret1 = hns3_rss_reset_indir_table(hw);
- if (ret1 != 0)
- return ret;
- }
-
-rss_tuple_uninit:
- hns3_rss_tuple_uninit(hw);
+ return ret;
- /* Disable RSS */
- hw->rss_info.conf.types = 0;
+ /*
+ * When muli-queue RSS mode flag is not set or unsupported tuples are
+ * set, disable all tuples.
+ */
+ rss_hf = hw->rss_info.conf.types;
+ if (!((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) ||
+ !(rss_hf & HNS3_ETH_RSS_SUPPORT))
+ rss_hf = 0;
- return ret;
+ return hns3_set_rss_tuple_by_rss_hf(hw, &hw->rss_info.rss_tuple_sets,
+ rss_hf);
}
/*
--
2.33.0

View File

@ -0,0 +1,75 @@
From 07f64b5f576a779c8c3df4ba45ad70c306dcb562 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Thu, 5 May 2022 20:27:06 +0800
Subject: [PATCH] net/hns3: fix rollback on RSS hash update
The RSS tuple isn't restored when RSS key length is invalid or setting
algo key failed. This patch fixes it.
Fixes: c37ca66f2b27 ("net/hns3: support RSS")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_rss.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 1c703952b9..4b2c24ace4 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -376,9 +376,9 @@ int
hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
struct rte_eth_rss_conf *rss_conf)
{
- struct hns3_adapter *hns = dev->data->dev_private;
- struct hns3_hw *hw = &hns->hw;
+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets;
+ uint64_t rss_hf_bk = hw->rss_info.conf.types;
uint8_t key_len = rss_conf->rss_key_len;
uint64_t rss_hf = rss_conf->rss_hf;
uint8_t *key = rss_conf->rss_key;
@@ -387,27 +387,29 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
if (hw->rss_dis_flag)
return -EINVAL;
+ if (key && key_len != HNS3_RSS_KEY_SIZE) {
+ hns3_err(hw, "the hash key len(%u) is invalid, must be %u",
+ key_len, HNS3_RSS_KEY_SIZE);
+ return -EINVAL;
+ }
+
rte_spinlock_lock(&hw->lock);
ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf);
if (ret)
- goto conf_err;
+ goto set_tuple_fail;
if (key) {
- if (key_len != HNS3_RSS_KEY_SIZE) {
- hns3_err(hw, "The hash key len(%u) is invalid",
- key_len);
- ret = -EINVAL;
- goto conf_err;
- }
ret = hns3_rss_set_algo_key(hw, key);
if (ret)
- goto conf_err;
+ goto set_algo_key_fail;
}
rte_spinlock_unlock(&hw->lock);
return 0;
-conf_err:
+set_algo_key_fail:
+ (void)hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf_bk);
+set_tuple_fail:
rte_spinlock_unlock(&hw->lock);
return ret;
}
--
2.33.0

View File

@ -0,0 +1,136 @@
From 7a036b213b972e2c90e349f1eb90a30b98a740b4 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Thu, 5 May 2022 20:27:07 +0800
Subject: [PATCH 21/25] net/hns3: remove redundant RSS tuple field
The 'rss_tuple_fields' in struct struct hns3_rss_conf::rss_tuple_sets is
redundant. Because the enabled RSS tuple in PMD is already managed by
the 'types' in struct hns3_rss_conf::conf. This patch removes this
redundant variable.
Fixes: c37ca66f2b27 ("net/hns3: support RSS")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_flow.c | 6 ++----
drivers/net/hns3/hns3_rss.c | 12 ++++--------
drivers/net/hns3/hns3_rss.h | 5 +----
3 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index a74b140563..65f8ee3ae1 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1446,7 +1446,7 @@ hns3_disable_rss(struct hns3_hw *hw)
{
int ret;
- ret = hns3_set_rss_tuple_by_rss_hf(hw, &hw->rss_info.rss_tuple_sets, 0);
+ ret = hns3_set_rss_tuple_by_rss_hf(hw, 0);
if (ret)
return ret;
hw->rss_dis_flag = true;
@@ -1496,7 +1496,6 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func,
static int
hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config)
{
- struct hns3_rss_tuple_cfg *tuple;
int ret;
hns3_adjust_rss_key(hw, rss_config);
@@ -1512,8 +1511,7 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config)
hw->rss_info.conf.func = rss_config->func;
- tuple = &hw->rss_info.rss_tuple_sets;
- ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_config->types);
+ ret = hns3_set_rss_tuple_by_rss_hf(hw, rss_config->types);
if (ret)
hns3_err(hw, "Update RSS tuples by rss hf failed %d", ret);
diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 4b2c24ace4..e149c16bfe 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -310,8 +310,7 @@ hns3_rss_reset_indir_table(struct hns3_hw *hw)
}
int
-hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw,
- struct hns3_rss_tuple_cfg *tuple, uint64_t rss_hf)
+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;
@@ -356,7 +355,6 @@ hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw,
return ret;
}
- tuple->rss_tuple_fields = rte_le_to_cpu_64(req->tuple_field);
/* Update supported flow types when set tuple success */
hw->rss_info.conf.types = rss_hf;
@@ -377,7 +375,6 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
struct rte_eth_rss_conf *rss_conf)
{
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets;
uint64_t rss_hf_bk = hw->rss_info.conf.types;
uint8_t key_len = rss_conf->rss_key_len;
uint64_t rss_hf = rss_conf->rss_hf;
@@ -394,7 +391,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
}
rte_spinlock_lock(&hw->lock);
- ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf);
+ ret = hns3_set_rss_tuple_by_rss_hf(hw, rss_hf);
if (ret)
goto set_tuple_fail;
@@ -408,7 +405,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
return 0;
set_algo_key_fail:
- (void)hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf_bk);
+ (void)hns3_set_rss_tuple_by_rss_hf(hw, rss_hf_bk);
set_tuple_fail:
rte_spinlock_unlock(&hw->lock);
return ret;
@@ -699,8 +696,7 @@ hns3_config_rss(struct hns3_adapter *hns)
!(rss_hf & HNS3_ETH_RSS_SUPPORT))
rss_hf = 0;
- return hns3_set_rss_tuple_by_rss_hf(hw, &hw->rss_info.rss_tuple_sets,
- rss_hf);
+ return hns3_set_rss_tuple_by_rss_hf(hw, rss_hf);
}
/*
diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h
index 6f153a1b7b..7789f02a08 100644
--- a/drivers/net/hns3/hns3_rss.h
+++ b/drivers/net/hns3/hns3_rss.h
@@ -43,7 +43,6 @@ struct hns3_rss_conf {
struct rte_flow_action_rss conf;
uint8_t hash_algo; /* hash function type definited by hardware */
uint8_t key[HNS3_RSS_KEY_SIZE]; /* Hash key */
- struct hns3_rss_tuple_cfg rss_tuple_sets;
uint16_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE_MAX];
uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */
bool valid; /* check if RSS rule is valid */
@@ -107,9 +106,7 @@ int hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir,
int hns3_rss_reset_indir_table(struct hns3_hw *hw);
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,
- struct hns3_rss_tuple_cfg *tuple,
- uint64_t rss_hf);
+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);
--
2.30.0

View File

@ -0,0 +1,70 @@
From 93e1ea6dfa99dea359b8d66123576a395c2c0acd Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Wed, 6 Apr 2022 14:57:00 +0800
Subject: [PATCH] ethdev: fix RSS update when RSS is disabled
The RTE_ETH_MQ_RX_RSS_FLAG flag is a switch to enable RSS. If the flag
is not set in dev_configure, RSS will be not configured and enabled.
However, RSS hash and reta can still be configured by ethdev ops to
enable RSS if the flag isn't set. The behavior is inconsistent.
Fixes: 99a2dd955fba ("lib: remove librte_ prefix from directory names")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
lib/ethdev/rte_ethdev.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 29a3d80466..8520aec561 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -3867,6 +3867,7 @@ rte_eth_dev_rss_reta_update(uint16_t port_id,
struct rte_eth_rss_reta_entry64 *reta_conf,
uint16_t reta_size)
{
+ enum rte_eth_rx_mq_mode mq_mode;
struct rte_eth_dev *dev;
int ret;
@@ -3898,6 +3899,12 @@ rte_eth_dev_rss_reta_update(uint16_t port_id,
if (ret < 0)
return ret;
+ mq_mode = dev->data->dev_conf.rxmode.mq_mode;
+ if (!(mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)) {
+ RTE_ETHDEV_LOG(ERR, "Multi-queue RSS mode isn't enabled.\n");
+ return -ENOTSUP;
+ }
+
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_update, -ENOTSUP);
return eth_err(port_id, (*dev->dev_ops->reta_update)(dev, reta_conf,
reta_size));
@@ -3937,6 +3944,7 @@ rte_eth_dev_rss_hash_update(uint16_t port_id,
{
struct rte_eth_dev *dev;
struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
+ enum rte_eth_rx_mq_mode mq_mode;
int ret;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
@@ -3962,6 +3970,13 @@ rte_eth_dev_rss_hash_update(uint16_t port_id,
dev_info.flow_type_rss_offloads);
return -EINVAL;
}
+
+ mq_mode = dev->data->dev_conf.rxmode.mq_mode;
+ if (!(mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)) {
+ RTE_ETHDEV_LOG(ERR, "Multi-queue RSS mode isn't enabled.\n");
+ return -ENOTSUP;
+ }
+
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_update, -ENOTSUP);
return eth_err(port_id, (*dev->dev_ops->rss_hash_update)(dev,
rss_conf));
--
2.33.0

View File

@ -0,0 +1,103 @@
From ec1691494273ef4f9cb60ed24099196de1ce0cc4 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Wed, 6 Apr 2022 14:57:01 +0800
Subject: [PATCH] net/hns3: remove unnecessary RSS switch
Whether the RSS is enabled depends on RTE_ETH_MQ_RX_RSS_FLAG and packet
tuple are enabled. So the RSS switch is unnecessary.
Fixes: 5e782bc2570c ("net/hns3: fix configuring RSS hash when rules are flushed")
Fixes: fd8196838763 ("net/hns3: fix configuring device with RSS enabled")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 2 --
drivers/net/hns3/hns3_ethdev.h | 1 -
drivers/net/hns3/hns3_ethdev_vf.c | 2 --
drivers/net/hns3/hns3_flow.c | 1 -
drivers/net/hns3/hns3_rss.c | 3 ---
5 files changed, 9 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 4d5a595aab..0b565a5614 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -2018,7 +2018,6 @@ hns3_dev_configure(struct rte_eth_dev *dev)
if ((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
conf->rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
rss_conf = conf->rx_adv_conf.rss_conf;
- hw->rss_dis_flag = false;
ret = hns3_dev_rss_hash_update(dev, &rss_conf);
if (ret)
goto cfg_err;
@@ -2824,7 +2823,6 @@ hns3_get_board_configuration(struct hns3_hw *hw)
hw->mac.media_type = cfg.media_type;
hw->rss_size_max = cfg.rss_size_max;
- hw->rss_dis_flag = false;
memcpy(hw->mac.mac_addr, cfg.mac_addr, RTE_ETHER_ADDR_LEN);
hw->mac.phy_addr = cfg.phy_addr;
hw->dcb_info.num_pg = 1;
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index bb6ddd97ba..5e8a746514 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -526,7 +526,6 @@ struct hns3_hw {
/* The configuration info of RSS */
struct hns3_rss_conf rss_info;
- bool rss_dis_flag; /* disable rss flag. true: disable, false: enable */
uint16_t rss_ind_tbl_size;
uint16_t rss_key_size;
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index f641e0dc36..589de0ab3a 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -495,7 +495,6 @@ hns3vf_dev_configure(struct rte_eth_dev *dev)
/* When RSS is not configured, redirect the packet queue 0 */
if ((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
conf->rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
- hw->rss_dis_flag = false;
rss_conf = conf->rx_adv_conf.rss_conf;
ret = hns3_dev_rss_hash_update(dev, &rss_conf);
if (ret)
@@ -997,7 +996,6 @@ hns3vf_get_configuration(struct hns3_hw *hw)
int ret;
hw->mac.media_type = HNS3_MEDIA_TYPE_NONE;
- hw->rss_dis_flag = false;
/* Get device capability */
ret = hns3vf_get_capability(hw);
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 317f91fc71..86ebbf69b6 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1449,7 +1449,6 @@ hns3_disable_rss(struct hns3_hw *hw)
ret = hns3_set_rss_tuple_by_rss_hf(hw, 0);
if (ret)
return ret;
- hw->rss_dis_flag = true;
return 0;
}
diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index e149c16bfe..d376486a1d 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -381,9 +381,6 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
uint8_t *key = rss_conf->rss_key;
int ret;
- if (hw->rss_dis_flag)
- return -EINVAL;
-
if (key && key_len != HNS3_RSS_KEY_SIZE) {
hns3_err(hw, "the hash key len(%u) is invalid, must be %u",
key_len, HNS3_RSS_KEY_SIZE);
--
2.33.0

View File

@ -0,0 +1,96 @@
From baef6bbfad1b9596c7051f5c1fcc308310296342 Mon Sep 17 00:00:00 2001
From: "Min Hu (Connor)" <humin29@huawei.com>
Date: Wed, 6 Apr 2022 16:45:36 +0800
Subject: [PATCH] app/testpmd: check statistics query before printing
In function 'fwd_stats_display', if function 'rte_eth_stats_get' fails,
'stats' is uncertainty value. The display result will be abnormal.
This patch check the return value of 'rte_eth_stats_get' to avoid
display abnormal stats.
Fixes: 53324971a14e ("app/testpmd: display/clear forwarding stats on demand")
Cc: stable@dpdk.org
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Acked-by: Aman Singh <aman.deep.singh@intel.com>
---
app/test-pmd/config.c | 10 ++++++++--
app/test-pmd/testpmd.c | 16 ++++++++++++++--
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index cc8e7aa138..bd689f9f86 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -249,14 +249,20 @@ nic_stats_display(portid_t port_id)
diff_ns;
uint64_t mpps_rx, mpps_tx, mbps_rx, mbps_tx;
struct rte_eth_stats stats;
-
static const char *nic_stats_border = "########################";
+ int ret;
if (port_id_is_invalid(port_id, ENABLED_WARN)) {
print_valid_ports();
return;
}
- rte_eth_stats_get(port_id, &stats);
+ ret = rte_eth_stats_get(port_id, &stats);
+ if (ret != 0) {
+ fprintf(stderr,
+ "%s: Error: failed to get stats (port %u): %d",
+ __func__, port_id, ret);
+ return;
+ }
printf("\n %s NIC statistics for port %-2d %s\n",
nic_stats_border, port_id, nic_stats_border);
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index fe2ce19f99..79bb23264b 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1982,6 +1982,7 @@ fwd_stats_display(void)
struct rte_port *port;
streamid_t sm_id;
portid_t pt_id;
+ int ret;
int i;
memset(ports_stats, 0, sizeof(ports_stats));
@@ -2013,7 +2014,13 @@ fwd_stats_display(void)
pt_id = fwd_ports_ids[i];
port = &ports[pt_id];
- rte_eth_stats_get(pt_id, &stats);
+ ret = rte_eth_stats_get(pt_id, &stats);
+ if (ret != 0) {
+ fprintf(stderr,
+ "%s: Error: failed to get stats (port %u): %d",
+ __func__, pt_id, ret);
+ continue;
+ }
stats.ipackets -= port->stats.ipackets;
stats.opackets -= port->stats.opackets;
stats.ibytes -= port->stats.ibytes;
@@ -2108,11 +2115,16 @@ fwd_stats_reset(void)
{
streamid_t sm_id;
portid_t pt_id;
+ int ret;
int i;
for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) {
pt_id = fwd_ports_ids[i];
- rte_eth_stats_get(pt_id, &ports[pt_id].stats);
+ ret = rte_eth_stats_get(pt_id, &ports[pt_id].stats);
+ if (ret != 0)
+ fprintf(stderr,
+ "%s: Error: failed to clear stats (port %u):%d",
+ __func__, pt_id, ret);
}
for (sm_id = 0; sm_id < cur_fwd_config.nb_fwd_streams; sm_id++) {
struct fwd_stream *fs = fwd_streams[sm_id];
--
2.33.0

View File

@ -0,0 +1,110 @@
From f0b3966a5072bd0a6c7f7e8652aef793afa4f4d0 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@huawei.com>
Date: Wed, 6 Apr 2022 16:45:37 +0800
Subject: [PATCH] app/testpmd: fix MTU verification
The macro RTE_ETHER_MIN_LEN isn't the minimum value of MTU. But testpmd
used it when execute 'port config mtu 0 xx' cmd. This patch fixes it.
Fixes: 1bb4a528c41f ("ethdev: fix max Rx packet length")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Acked-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
---
app/test-pmd/cmdline.c | 4 ---
app/test-pmd/config.c | 55 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 6ffea8e21a..91e4090582 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -2050,10 +2050,6 @@ cmd_config_mtu_parsed(void *parsed_result,
{
struct cmd_config_mtu_result *res = parsed_result;
- if (res->value < RTE_ETHER_MIN_LEN) {
- fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
- return;
- }
port_mtu_set(res->port_id, res->value);
}
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index bd689f9f86..1b1e738f83 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1254,6 +1254,57 @@ port_reg_set(portid_t port_id, uint32_t reg_off, uint32_t reg_v)
display_port_reg_value(port_id, reg_off, reg_v);
}
+static uint32_t
+eth_dev_get_overhead_len(uint32_t max_rx_pktlen, uint16_t max_mtu)
+{
+ uint32_t overhead_len;
+
+ if (max_mtu != UINT16_MAX && max_rx_pktlen > max_mtu)
+ overhead_len = max_rx_pktlen - max_mtu;
+ else
+ overhead_len = RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
+
+ return overhead_len;
+}
+
+static int
+eth_dev_validate_mtu(uint16_t port_id, uint16_t mtu)
+{
+ struct rte_eth_dev_info dev_info;
+ uint32_t overhead_len;
+ uint32_t frame_size;
+ int ret;
+
+ ret = rte_eth_dev_info_get(port_id, &dev_info);
+ if (ret != 0)
+ return ret;
+
+ if (mtu < dev_info.min_mtu) {
+ fprintf(stderr,
+ "MTU (%u) < device min MTU (%u) for port_id %u\n",
+ mtu, dev_info.min_mtu, port_id);
+ return -EINVAL;
+ }
+ if (mtu > dev_info.max_mtu) {
+ fprintf(stderr,
+ "MTU (%u) > device max MTU (%u) for port_id %u\n",
+ mtu, dev_info.max_mtu, port_id);
+ return -EINVAL;
+ }
+
+ overhead_len = eth_dev_get_overhead_len(dev_info.max_rx_pktlen,
+ dev_info.max_mtu);
+ frame_size = mtu + overhead_len;
+ if (frame_size > dev_info.max_rx_pktlen) {
+ fprintf(stderr,
+ "Frame size (%u) > device max frame size (%u) for port_id %u\n",
+ frame_size, dev_info.max_rx_pktlen, port_id);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
void
port_mtu_set(portid_t port_id, uint16_t mtu)
{
@@ -1263,6 +1314,10 @@ port_mtu_set(portid_t port_id, uint16_t mtu)
if (port_id_is_invalid(port_id, ENABLED_WARN))
return;
+ diag = eth_dev_validate_mtu(port_id, mtu);
+ if (diag != 0)
+ return;
+
if (port->need_reconfig == 0) {
diag = rte_eth_dev_set_mtu(port_id, mtu);
if (diag != 0) {
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: dpdk
Version: 21.11
Release: 9
Release: 10
Packager: packaging@6wind.com
URL: http://dpdk.org
%global source_version 21.11
@ -51,6 +51,46 @@ Patch9042: 0042-net-hns3-delete-duplicated-RSS-type.patch
Patch9043: 0043-net-bonding-fix-promiscuous-and-allmulticast-state.patch
Patch9044: 0044-net-bonding-fix-reference-count-on-mbufs.patch
Patch9045: 0045-app-testpmd-fix-bonding-mode-set.patch
Patch9046: 0046-ethdev-introduce-dump-API.patch
Patch9047: 0047-app-procinfo-add-device-private-info-dump.patch
Patch9048: 0048-net-hns3-dump-device-basic-info.patch
Patch9049: 0049-net-hns3-dump-device-feature-capability.patch
Patch9050: 0050-net-hns3-dump-device-MAC-info.patch
Patch9051: 0051-net-hns3-dump-queue-info.patch
Patch9052: 0052-net-hns3-dump-VLAN-configuration-info.patch
Patch9053: 0053-net-hns3-dump-flow-director-basic-info.patch
Patch9054: 0054-net-hns3-dump-TM-configuration-info.patch
Patch9055: 0055-net-hns3-dump-flow-control-info.patch
Patch9056: 0056-net-hns3-change-dump-file-name.patch
Patch9057: 0057-net-hns3-fix-code-check-for-dump.patch
Patch9058: 0058-ethdev-fix-ethdev-version-map.patch
Patch9059: 0059-net-hns3-delete-simple-bd-cap.patch
Patch9060: 0060-net-hns3-fix-TM-info-dump.patch
Patch9061: 0061-dma-hisilicon-support-Kunpeng-930.patch
Patch9062: 0062-dma-hisilicon-support-error-handling-with-Kunpeng-93.patch
Patch9063: 0063-dma-hisilicon-support-registers-dump-for-Kunpeng-930.patch
Patch9064: 0064-dma-hisilicon-add-queue-full-statistics.patch
Patch9065: 0065-dma-hisilicon-use-common-PCI-device-naming.patch
Patch9066: 0066-app-testpmd-check-starting-port-is-not-in-bonding.patch
Patch9067: 0067-examples-vhost-remove-DMA-type-option-help-info.patch
Patch9068: 0068-kni-fix-freeing-order-in-device-release.patch
Patch9069: 0069-net-hns3-remove-duplicate-macro-definition.patch
Patch9070: 0070-net-hns3-fix-RSS-TC-mode-entry.patch
Patch9071: 0071-net-hns3-fix-VF-RSS-TC-mode-entry.patch
Patch9072: 0072-net-hns3-increase-time-waiting-for-PF-reset-completi.patch
Patch9073: 0073-net-bonding-fix-stopping-non-active-slaves.patch
Patch9074: 0074-net-bonding-fix-slave-stop-and-remove-on-port-close.patch
Patch9075: 0075-net-hns3-fix-order-of-clearing-imissed-register-in-P.patch
Patch9076: 0076-net-hns3-fix-MAC-and-queues-HW-statistics-overflow.patch
Patch9077: 0077-net-hns3-fix-pseudo-sharing-between-threads.patch
Patch9078: 0078-net-hns3-fix-mbuf-free-on-Tx-done-cleanup.patch
Patch9079: 0079-net-hns3-fix-RSS-disable.patch
Patch9080: 0080-net-hns3-fix-rollback-on-RSS-hash-update.patch
Patch9081: 0081-net-hns3-remove-redundant-RSS-tuple-field.patch
Patch9082: 0082-ethdev-fix-RSS-update-when-RSS-is-disabled.patch
Patch9083: 0083-net-hns3-remove-unnecessary-RSS-switch.patch
Patch9084: 0084-app-testpmd-check-statistics-query-before-printing.patch
Patch9085: 0085-app-testpmd-fix-MTU-verification.patch
Summary: Data Plane Development Kit core
Group: System Environment/Libraries
@ -169,6 +209,9 @@ strip -g $RPM_BUILD_ROOT/lib/modules/%{kern_devel_ver}/extra/dpdk/igb_uio.ko
/usr/sbin/depmod
%changelog
* Tue May 17 2022 Min Hu(Connor) <humin29@huawei.com> - 21.11-10
- sync patches from 22.03.
* Wed March 23 2022 Min Hu(Connor) <humin29@huawei.com> - 21.11-9
- fix adding examples app.