[dpdk-dev] [PATCH] rte_metrics: unconditionally export rte_metrics_tel_xxx functions

2021-02-22 Thread Jie
From: Jie Zhou 

This patch allows the same set of rte_metrics_tel_* functions to be
exported no matter JANSSON is available or not, by doing following:
1.  Leverage dpdk_conf to set configuration flag RTE_HAVE_JANSSON
when Jansson dependency is found.
2.  In rte_metrics_telemetry.c, leverage RTE_HAVE_JANSSON to handle the
case when JANSSON is not available by adding stubs for all the instances.
3.  In meson.build, per dpdk\doc\guides\rel_notes\release_20_05.rst,
it is claimed that "Telemetry library is no longer dependent on the
external Jansson library, which allows Telemetry be enabled by default.",
thus make the deps and includes of Telemetry as not conditional anymore.

Signed-off-by: Jie Zhou 
---
 config/meson.build |  5 ++
 lib/librte_metrics/meson.build | 13 +++---
 lib/librte_metrics/rte_metrics_telemetry.c | 53 ++
 lib/librte_metrics/rte_metrics_telemetry.h |  2 +-
 4 files changed, 66 insertions(+), 7 deletions(-)

diff --git a/config/meson.build b/config/meson.build
index 3cf560b8a..892bd9677 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -292,6 +292,11 @@ if is_freebsd
add_project_arguments('-D__BSD_VISIBLE', language: 'c')
 endif
 
+jansson = dependency('jansson', required: false, method: 'pkg-config')
+if jansson.found()
+   dpdk_conf.set('RTE_HAVE_JANSSON', 1)
+endif
+
 if is_windows
# VirtualAlloc2() is available since Windows 10 / Server 2016.
add_project_arguments('-D_WIN32_WINNT=0x0A00', language: 'c')
diff --git a/lib/librte_metrics/meson.build b/lib/librte_metrics/meson.build
index 28a8cc115..b13604c88 100644
--- a/lib/librte_metrics/meson.build
+++ b/lib/librte_metrics/meson.build
@@ -4,11 +4,12 @@
 sources = files('rte_metrics.c')
 headers = files('rte_metrics.h')
 
-jansson = dependency('jansson', required: false, method: 'pkg-config')
-if jansson.found()
+if dpdk_conf.has('RTE_HAVE_JANSSON')
ext_deps += jansson
-   sources += files('rte_metrics_telemetry.c')
-   headers += files('rte_metrics_telemetry.h')
-   deps += ['ethdev', 'telemetry']
-   includes += include_directories('../librte_telemetry')
 endif
+
+sources += files('rte_metrics_telemetry.c')
+headers += files('rte_metrics_telemetry.h')
+
+deps += ['ethdev', 'telemetry']
+includes += include_directories('../librte_telemetry')
diff --git a/lib/librte_metrics/rte_metrics_telemetry.c 
b/lib/librte_metrics/rte_metrics_telemetry.c
index b8ee56ef0..225d9ebce 100644
--- a/lib/librte_metrics/rte_metrics_telemetry.c
+++ b/lib/librte_metrics/rte_metrics_telemetry.c
@@ -2,7 +2,9 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#ifdef RTE_HAVE_JANSSON
 #include 
+#endif
 
 #include 
 #include 
@@ -13,6 +15,7 @@
 #include "rte_metrics.h"
 #include "rte_metrics_telemetry.h"
 
+#ifdef RTE_HAVE_JANSSON
 struct telemetry_metrics_data tel_met_data;
 
 int metrics_log_level;
@@ -70,10 +73,12 @@ rte_metrics_tel_reg_port_ethdev_to_metrics(uint16_t port_id)
free(xstats_names);
return ret;
 }
+#endif
 
 int32_t
 rte_metrics_tel_reg_all_ethdev(int *metrics_register_done, int *reg_index_list)
 {
+#ifdef JANSSON
struct driver_index {
const void *dev_ops;
int reg_index;
@@ -110,8 +115,15 @@ rte_metrics_tel_reg_all_ethdev(int *metrics_register_done, 
int *reg_index_list)
}
*metrics_register_done = 1;
return 0;
+#else
+   RTE_SET_USED(metrics_register_done);
+   RTE_SET_USED(reg_index_list);
+
+   return -ENOTSUP;
+#endif
 }
 
+#ifdef RTE_HAVE_JANSSON
 static int32_t
 rte_metrics_tel_update_metrics_ethdev(uint16_t port_id, int reg_start_index)
 {
@@ -224,11 +236,13 @@ rte_metrics_tel_format_port(uint32_t pid, json_t *ports,
free(names);
return ret;
 }
+#endif
 
 int32_t
 rte_metrics_tel_encode_json_format(struct telemetry_encode_param *ep,
char **json_buffer)
 {
+#ifdef JANSSON
json_t *root, *ports;
int ret, i;
 
@@ -276,12 +290,19 @@ rte_metrics_tel_encode_json_format(struct 
telemetry_encode_param *ep,
*json_buffer = json_dumps(root, JSON_INDENT(2));
json_decref(root);
return 0;
+#else
+   RTE_SET_USED(ep);
+   RTE_SET_USED(json_buffer);
+
+   return -ENOTSUP;
+#endif
 }
 
 int32_t
 rte_metrics_tel_get_ports_stats_json(struct telemetry_encode_param *ep,
int *reg_index, char **json_buffer)
 {
+#ifdef RTE_HAVE_JANSSON
int ret, i;
uint32_t port_id;
 
@@ -306,11 +327,19 @@ rte_metrics_tel_get_ports_stats_json(struct 
telemetry_encode_param *ep,
return ret;
}
return 0;
+#else
+   RTE_SET_USED(ep);
+   RTE_SET_USED(reg_index

Re: [PATCH v2 1/8] lib/ethdev: update Rx and Tx queue status

2023-10-07 Thread Jie Hai

On 2023/9/28 21:15, Ferruh Yigit wrote:

On 9/28/2023 8:42 AM, Jie Hai wrote:

The DPDK framework reports the queue status, which is stored in
'dev->data->tx_queue_state' and 'dev->data->rx_queue_state'.The
state is currently maintained by the drivers. Users may determine
whether a queue participates in packet forwarding based on the
state. However, not all drivers correctly report the queue status.
This may cause forwarding problems.

Since it is difficult to modify the queue status of all drivers,
we consider updating the queue status at the framework level.
Some drivers support queues for hairpin, leaving status updating
for such queues to the drivers. Some drivers support
'deferred_start'. Assume that all drivers that support
'deferred_start' can obtain the configuration through
'rte_eth_tx_queue_info_get' and 'rte_eth_rx_queue_info_get'. So
we can directly update the queue status in 'rte_eth_dev_start'
and 'rte_eth_dev_stop'.

Signed-off-by: Jie Hai 
---
  lib/ethdev/rte_ethdev.c | 40 
  1 file changed, 40 insertions(+)

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 0840d2b5942a..e3aaa71eba9e 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -1641,6 +1641,9 @@ rte_eth_dev_start(uint16_t port_id)
struct rte_eth_dev_info dev_info;
int diag;
int ret, ret_stop;
+   uint16_t i;
+   struct rte_eth_rxq_info rxq_info;
+   struct rte_eth_txq_info txq_info;
  
  	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);

dev = &rte_eth_devices[port_id];
@@ -1697,6 +1700,30 @@ rte_eth_dev_start(uint16_t port_id)
(*dev->dev_ops->link_update)(dev, 0);
}
  
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {

+   if (rte_eth_dev_is_rx_hairpin_queue(dev, i))
+   continue;
+
+   memset(&rxq_info, 0, sizeof(rxq_info));
+   ret = rte_eth_rx_queue_info_get(port_id, i, &rxq_info);
+   if (ret == 0 && rxq_info.conf.rx_deferred_start != 0)
+   dev->data->rx_queue_state[i] = 
RTE_ETH_QUEUE_STATE_STOPPED;
+   else
+   dev->data->rx_queue_state[i] = 
RTE_ETH_QUEUE_STATE_STARTED;
+   }
+
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   if (rte_eth_dev_is_tx_hairpin_queue(dev, i))
+   continue;
+
+   memset(&txq_info, 0, sizeof(txq_info));
+   ret = rte_eth_tx_queue_info_get(port_id, i, &txq_info);
+   if (ret == 0 && txq_info.conf.tx_deferred_start != 0)
+   dev->data->tx_queue_state[i] = 
RTE_ETH_QUEUE_STATE_STOPPED;
+   else
+   dev->data->tx_queue_state[i] = 
RTE_ETH_QUEUE_STATE_STARTED;
+   }
+


Hi Jie,

I am not sure about adding queue_info_get() calls a dependency to
start(), since start() is a mandatory API, I am concerned about possible
side affects.
Like if rte_eth_rx_queue_info_get() fails,Yes, unless we let 
rte_eth_rx|tx_queue_info_get a mandatory API.
Or event though deferred_start is set, can application first call
rx_queue_start(), later start(), like:
  start()
  rx_queue_start()
  stop()
  rx_queue_start()
  start()

   start()  --> deferred_start is confugured, the queue is stopped
   rx_queue_start() --> the queue is started
   stop() --> all queues are stopped
   rx_queue_start() --> not supported, port should starts first
   start()

If we change the order as:
   start()
   rx_queue_start()
   stop()
   start()

The last status of the queue for different drivers may be different.
Most drivers starts all queues except the queue setting deferred_start.
For sfc driver, all queues are started and the status of  the queue
setting deferred_start will be reported as stopped, which is not correct.
That's the point, drivers have their own private processing for 
different sequences of deferred_start, start|stop and queue_start|stop.



Or even applications sets deferred_start, PMD be ignoring without
reflecting that to conf.rx_deferred_start, etc...


Supppose the app sets the deferred_start,
whether the driver verifies the support the configuration or not,
whether the driver issues the configuration to the hardware or not,
whether the driver saves and reports the configuration or not,
Different driver implementations vary.

For the above three cases,  pay attention to the following:

1) Y-Y-Y That's what we need.
2) Y-Y-N That's what we should add.
3) N-N-Y This will lead to wrong information(e.g.ice_rxtx.c mlx5_txq.c 
mlx5_rxq.c)

4) N-N-N That's what we need, too.



Anyway, intention was to move common task, setting queue state, to the
ethdev layer, but because of the deferred_start, in rte_eth_dev_start()
we

Re: [PATCH v7 0/3] add telemetry cmds for ring

2023-10-09 Thread Jie Hai

Hi, Thomas,

Kindly ping for review.

Thanks,
Jie Hai

On 2023/7/4 17:04, Jie Hai wrote:

This patch set supports telemetry cmd to list rings and dump information
of a ring by its name.

v1->v2:
1. Add space after "switch".
2. Fix wrong strlen parameter.

v2->v3:
1. Remove prefix "rte_" for static function.
2. Add Acked-by Konstantin Ananyev for PATCH 1.
3. Introduce functions to return strings instead copy strings.
4. Check pointer to memzone of ring.
5. Remove redundant variable.
6. Hold lock when access ring data.

v3->v4:
1. Update changelog according to reviews of Honnappa Nagarahalli.
2. Add Reviewed-by Honnappa Nagarahalli.
3. Correct grammar in help information.
4. Correct spell warning on "te" reported by checkpatch.pl.
5. Use ring_walk() to query ring info instead of rte_ring_lookup().
6. Fix that type definition the flag field of rte_ring does not match the usage.
7. Use rte_tel_data_add_dict_uint_hex instead of rte_tel_data_add_dict_u64
for mask and flags.

v4->v5:
1. Add Acked-by Konstantin Ananyev and Chengwen Feng.
2. Add ABI change explanation for commit message of patch 1/3.

v5->v6:
1. Add Acked-by Morten Brørup.
2. Fix incorrect reference of commit.

v6->v7:
1. Remove prod/consumer head/tail info.

Jie Hai (3):
   ring: fix unmatched type definition and usage
   ring: add telemetry cmd to list rings
   ring: add telemetry cmd for ring info

  lib/ring/meson.build |   1 +
  lib/ring/rte_ring.c  | 135 +++
  lib/ring/rte_ring_core.h |   2 +-
  3 files changed, 137 insertions(+), 1 deletion(-)



[PATCH v5 00/40] support setting and querying RSS algorithms

2023-10-11 Thread Jie Hai
This patchset is to support setting and querying RSS algorithms.

--
v5:
1. rewrite some comments.
2. check RSS algorithm for drivers supporting RSS.
3. change field "func" of rss_conf to "algorithm".
4. fix commit log for [PATCH v4 4/7].
5. add Acked-by Reshma Pattan.
6. add symmetric_toeplitz_sort for showing.
7. change "hf" to "hash function" for showing.

v4:
1. recomment some definitions related to RSS.
2. allocate static memory for rss_key instead of dynamic.
3. use array of strings to get the name of rss algorithm.
4. add display of rss algorithm with testpmd.

v3:
1. fix commit log for PATCH [1/5].
2. make RSS ABI changes description to start the actual text at the margin.
3. move defnition of enum rte_eth_hash_function to rte_ethdev.h.
4. fix some comment codes.

v2:
1. return error if "func" is invalid.
2. modify the comments of the "func" field.
3. modify commit log of patch [3/5].
4. use malloc instead of rte_malloc.
5. adjust display format of RSS info.
6. remove the string display of rss_hf.

Huisong Li (1):
  net/hns3: support setting and querying RSS hash function

Jie Hai (39):
  ethdev: overwrite some comment related to RSS
  ethdev: support setting and querying RSS algorithm
  net/atlantic: check RSS hash algorithms
  net/axgbe: check RSS hash algorithms
  net/bnx2x: check RSS hash algorithms
  net/bnxt: check RSS hash algorithms
  net/bonding: check RSS hash algorithms
  net/cnxk: check RSS hash algorithms
  net/cpfl: check RSS hash algorithms
  net/cxgbe: check RSS hash algorithms
  net/dpaa: check RSS hash algorithms
  net/dpaa2: check RSS hash algorithms
  net/ena: check RSS hash algorithms
  net/enic: check RSS hash algorithms
  net/fm10k: check RSS hash algorithms
  net/hinic: check RSS hash algorithms
  net/i40e: check RSS hash algorithms
  net/iavf: check RSS hash algorithms
  net/ice: check RSS hash algorithms
  net/idpf: check RSS hash algorithms
  net/igc: check RSS hash algorithms
  net/ionic: check RSS hash algorithms
  net/ixgbe: check RSS hash algorithms
  net/mana: check RSS hash algorithms
  net/mlx5: check RSS hash algorithms
  net/mvpp2: check RSS hash algorithms
  net/netvsc: check RSS hash algorithms
  net/ngbe: : check RSS hash algorithms
  net/nfp: check RSS hash algorithms
  net/null: check RSS hash algorithms
  net/qede: check RSS hash algorithms
  net/sfc: check RSS hash algorithms
  net/tap: check RSS hash algorithms
  net/thunderx: check RSS hash algorithms
  net/txgbe: check RSS hash algorithms
  app/proc-info: fix never show RSS info
  app/proc-info: adjust the display format of RSS info
  app/proc-info: support querying RSS hash algorithm
  app/testpmd: add RSS hash algorithms display

 app/proc-info/main.c   | 32 ++-
 app/test-pmd/cmdline.c | 29 ++---
 app/test-pmd/config.c  | 38 -
 app/test-pmd/testpmd.h |  2 +-
 doc/guides/rel_notes/release_23_11.rst |  2 +
 drivers/net/atlantic/atl_ethdev.c  |  2 +
 drivers/net/axgbe/axgbe_ethdev.c   |  9 +
 drivers/net/bnx2x/bnx2x_ethdev.c   |  4 ++
 drivers/net/bnxt/bnxt_ethdev.c |  6 +++
 drivers/net/bonding/rte_eth_bond_pmd.c |  6 +++
 drivers/net/cnxk/cnxk_ethdev.c |  5 +++
 drivers/net/cnxk/cnxk_ethdev_ops.c |  3 ++
 drivers/net/cpfl/cpfl_ethdev.c |  6 +++
 drivers/net/cxgbe/cxgbe_ethdev.c   |  9 -
 drivers/net/dpaa/dpaa_ethdev.c |  7 
 drivers/net/dpaa2/dpaa2_ethdev.c   |  7 
 drivers/net/ena/ena_rss.c  |  3 ++
 drivers/net/enic/enic_ethdev.c |  1 +
 drivers/net/enic/enic_main.c   |  3 ++
 drivers/net/fm10k/fm10k_ethdev.c   |  9 -
 drivers/net/hinic/hinic_pmd_ethdev.c   |  3 ++
 drivers/net/hinic/hinic_pmd_rx.c   |  3 ++
 drivers/net/hns3/hns3_rss.c| 47 -
 drivers/net/i40e/i40e_ethdev.c |  7 
 drivers/net/iavf/iavf_ethdev.c |  6 +++
 drivers/net/ice/ice_dcf.c  |  3 ++
 drivers/net/ice/ice_dcf_ethdev.c   |  3 ++
 drivers/net/ice/ice_ethdev.c   |  7 
 drivers/net/idpf/idpf_ethdev.c |  6 +++
 drivers/net/igc/igc_ethdev.c   |  4 ++
 drivers/net/igc/igc_txrx.c |  5 +++
 drivers/net/ionic/ionic_ethdev.c   |  6 +++
 drivers/net/ixgbe/ixgbe_ethdev.c   | 12 +-
 drivers/net/ixgbe/ixgbe_rxtx.c |  4 ++
 drivers/net/mana/mana.c| 11 -
 drivers/net/mlx5/mlx5_ethdev.c |  4 ++
 drivers/net/mlx5/mlx5_rss.c|  3 +-
 drivers/net/mvpp2/mrvl_ethdev.c|  3 ++
 drivers/net/netvsc/hn_ethdev.c |  6 +++
 drivers/net/nfp/nfp_common.c   |  9 -
 drivers/net/ngbe/ngbe_ethdev.c |  6 ++-
 drivers/net/ngbe/ngbe_rxtx.c   |  3 ++
 drivers/net/null/rte_eth_null.c|  8 
 drivers/net/qede/qede_ethdev.c |  9 -
 drivers/net/sfc/sfc_ethdev.c   |  3

[PATCH v5 01/40] ethdev: overwrite some comment related to RSS

2023-10-11 Thread Jie Hai
1. overwrite the comments of fields of 'rte_eth_rss_conf'.
2. Add comments for RTE_ETH_HASH_FUNCTION_DEFAULT.

Signed-off-by: Jie Hai 
---
 lib/ethdev/rte_ethdev.h | 29 ++---
 lib/ethdev/rte_flow.h   |  3 +++
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index 8542257721c9..b9e4e21189d2 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -448,24 +448,23 @@ struct rte_vlan_filter_conf {
 /**
  * A structure used to configure the Receive Side Scaling (RSS) feature
  * of an Ethernet port.
- * If not NULL, the *rss_key* pointer of the *rss_conf* structure points
- * to an array holding the RSS key to use for hashing specific header
- * fields of received packets. The length of this array should be indicated
- * by *rss_key_len* below. Otherwise, a default random hash key is used by
- * the device driver.
- *
- * The *rss_key_len* field of the *rss_conf* structure indicates the length
- * in bytes of the array pointed by *rss_key*. To be compatible, this length
- * will be checked in i40e only. Others assume 40 bytes to be used as before.
- *
- * The *rss_hf* field of the *rss_conf* structure indicates the different
- * types of IPv4/IPv6 packets to which the RSS hashing must be applied.
- * Supplying an *rss_hf* equal to zero disables the RSS feature.
  */
 struct rte_eth_rss_conf {
-   uint8_t *rss_key;/**< If not NULL, 40-byte hash key. */
+   /**
+* If used to query, the'rss_key_len' indicates the size of rss key of
+* the hardware. And only when rss_key_len is not zero, the 'rss_key'
+* is valid.
+* If used to configure, rss_key_len indicates the length of the
+* 'rss_key' if 'rss_key' is not empty.
+*/
+   uint8_t *rss_key;
uint8_t rss_key_len; /**< hash key length in bytes. */
-   uint64_t rss_hf; /**< Hash functions to apply - see below. */
+   /**
+* Indicating which type of packets and which part of the packets
+* to apply for RSS hash, (see RTE_ETH_RSS_*).
+* Setting *rss_hf* to zero disables the RSS feature.
+*/
+   uint64_t rss_hf;
 };
 
 /*
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index b385741fba6d..5d9e3c68af7b 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -3227,6 +3227,9 @@ struct rte_flow_query_count {
  * Hash function types.
  */
 enum rte_eth_hash_function {
+   /**
+* DEFAULT means driver decides which hash algorithm to pick.
+*/
RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
-- 
2.30.0



[PATCH v5 03/40] net/atlantic: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/atlantic/atl_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/atlantic/atl_ethdev.c 
b/drivers/net/atlantic/atl_ethdev.c
index 3a028f429002..c6e772d47263 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -1857,6 +1857,8 @@ atl_rss_hash_update(struct rte_eth_dev *dev,
};
 
cfg->is_rss = !!rss_conf->rss_hf;
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
if (rss_conf->rss_key) {
memcpy(cfg->aq_rss.hash_secret_key, rss_conf->rss_key,
   rss_conf->rss_key_len);
-- 
2.30.0



[PATCH v5 04/40] net/axgbe: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/axgbe/axgbe_ethdev.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index d08ea4893c37..f67faff2d636 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -339,6 +339,12 @@ static int
 axgbe_dev_configure(struct rte_eth_dev *dev)
 {
struct axgbe_port *pdata =  dev->data->dev_private;
+
+   if (dev->data->dev_conf.rxmode.mq_mode == RTE_ETH_MQ_RX_RSS &&
+   dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
/* Checksum offload to hardware */
pdata->rx_csum_enable = dev->data->dev_conf.rxmode.offloads &
RTE_ETH_RX_OFFLOAD_CHECKSUM;
@@ -582,6 +588,9 @@ axgbe_dev_rss_hash_update(struct rte_eth_dev *dev,
return -EINVAL;
}
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (rss_conf->rss_key != NULL &&
rss_conf->rss_key_len == AXGBE_RSS_HASH_KEY_SIZE) {
rte_memcpy(pdata->rss_key, rss_conf->rss_key,
-- 
2.30.0



[PATCH v5 02/40] ethdev: support setting and querying RSS algorithm

2023-10-11 Thread Jie Hai
Currently, rte_eth_rss_conf supports configuring and querying
RSS hash functions, rss key and it's length, but not RSS hash
algorithm.

The structure ``rte_eth_rss_conf`` is extended by adding a new
field "algorithm". This represents the RSS algorithms to apply.
The following API will be affected:
- rte_eth_dev_configure
- rte_eth_dev_rss_hash_update
- rte_eth_dev_rss_hash_conf_get

If the value of "algorithm" used for configuration is a gibberish
value, report the error and return. Do the same for
rte_eth_dev_rss_hash_update and rte_eth_dev_configure.

To check whether the drivers report valid "algorithm", it is set
to default value before querying.

Signed-off-by: Jie Hai 
Signed-off-by: Dongdong Liu 
---
 doc/guides/rel_notes/release_23_11.rst |  2 ++
 lib/ethdev/rte_ethdev.c| 17 
 lib/ethdev/rte_ethdev.h| 27 +
 lib/ethdev/rte_flow.c  |  1 -
 lib/ethdev/rte_flow.h  | 28 ++
 5 files changed, 48 insertions(+), 27 deletions(-)

diff --git a/doc/guides/rel_notes/release_23_11.rst 
b/doc/guides/rel_notes/release_23_11.rst
index e13d57728071..92a445ab2ed3 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -197,6 +197,8 @@ ABI Changes
   fields, to move ``rxq`` and ``txq`` fields, to change the size of
   ``reserved1`` and ``reserved2`` fields.
 
+* ethdev: Added "algorithm" field to ``rte_eth_rss_conf`` structure for RSS
+  hash algorithm.
 
 Known Issues
 
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 18a4b950b184..2eda1b8072e5 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -1464,6 +1464,14 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t 
nb_rx_q, uint16_t nb_tx_q,
goto rollback;
}
 
+   if (dev_conf->rx_adv_conf.rss_conf.algorithm >= 
RTE_ETH_HASH_FUNCTION_MAX) {
+   RTE_ETHDEV_LOG(ERR,
+   "Ethdev port_id=%u invalid RSS algorithm: 
0x%"PRIx64"\n",
+   port_id, dev_conf->rx_adv_conf.rss_conf.algorithm);
+   ret = -EINVAL;
+   goto rollback;
+   }
+
/* Check if Rx RSS distribution is disabled but RSS hash is enabled. */
if (((dev_conf->rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) == 0) &&
(dev_conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH)) {
@@ -4673,6 +4681,13 @@ rte_eth_dev_rss_hash_update(uint16_t port_id,
return -ENOTSUP;
}
 
+   if (rss_conf->algorithm >= RTE_ETH_HASH_FUNCTION_MAX) {
+   RTE_ETHDEV_LOG(ERR,
+   "Ethdev port_id=%u invalid RSS algorithm: 
0x%"PRIx64"\n",
+   port_id, rss_conf->algorithm);
+   return -EINVAL;
+   }
+
if (*dev->dev_ops->rss_hash_update == NULL)
return -ENOTSUP;
ret = eth_err(port_id, (*dev->dev_ops->rss_hash_update)(dev,
@@ -4700,6 +4715,8 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
return -EINVAL;
}
 
+   rss_conf->algorithm = RTE_ETH_HASH_FUNCTION_DEFAULT;
+
if (*dev->dev_ops->rss_hash_conf_get == NULL)
return -ENOTSUP;
ret = eth_err(port_id, (*dev->dev_ops->rss_hash_conf_get)(dev,
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index b9e4e21189d2..42c4250bd509 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -445,6 +445,32 @@ struct rte_vlan_filter_conf {
uint64_t ids[64];
 };
 
+/**
+ * Hash function types.
+ */
+enum rte_eth_hash_function {
+   /**
+* DEFAULT means driver decides which hash algorithm to pick.
+*/
+   RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
+   RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
+   RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
+   /**
+* Symmetric Toeplitz: src, dst will be replaced by
+* xor(src, dst). For the case with src/dst only,
+* src or dst address will xor with zero pair.
+*/
+   RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
+   /**
+* Symmetric Toeplitz: L3 and L4 fields are sorted prior to
+* the hash function.
+*  If src_ip > dst_ip, swap src_ip and dst_ip.
+*  If src_port > dst_port, swap src_port and dst_port.
+*/
+   RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT,
+   RTE_ETH_HASH_FUNCTION_MAX,
+};
+
 /**
  * A structure used to configure the Receive Side Scaling (RSS) feature
  * of an Ethernet port.
@@ -465,6 +491,7 @@ struct rte_eth_rss_conf {
 * Setting *rss_hf* to zero disables the RSS feature.
 */
uint64_t rss_hf;
+   enum rte_eth_hash_function algorithm;   /**< Hash algorithm. 

[PATCH v5 05/40] net/bnx2x: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/bnx2x/bnx2x_ethdev.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 4448cf2de2d7..078d6db75d1b 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -196,6 +196,10 @@ bnx2x_dev_configure(struct rte_eth_dev *dev)
PMD_DRV_LOG(DEBUG, sc, "num_queues=%d, mtu=%d",
   sc->num_queues, sc->mtu);
 
+   if (dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
/* allocate ilt */
if (bnx2x_alloc_ilt_mem(sc) != 0) {
PMD_DRV_LOG(ERR, sc, "bnx2x_alloc_ilt_mem was failed");
-- 
2.30.0



[PATCH v5 06/40] net/bnxt: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/bnxt/bnxt_ethdev.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index ee1552452a11..92ce05b26dc7 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1166,6 +1166,9 @@ static int bnxt_dev_configure_op(struct rte_eth_dev 
*eth_dev)
rx_offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
eth_dev->data->dev_conf.rxmode.offloads = rx_offloads;
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
/* application provides the hash key to program */
if (rss_conf->rss_key != NULL) {
if (rss_conf->rss_key_len != HW_HASH_KEY_SIZE)
@@ -2168,6 +2171,9 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev 
*eth_dev,
return -EINVAL;
}
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
/* Update the default RSS VNIC(s) */
vnic = bnxt_get_default_vnic(bp);
vnic->hash_type = bnxt_rte_to_hwrm_hash_types(rss_conf->rss_hf);
-- 
2.30.0



[PATCH v5 07/40] net/bonding: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c 
b/drivers/net/bonding/rte_eth_bond_pmd.c
index 122b1187fd9c..75ad0270af03 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -3187,6 +3187,9 @@ bond_ethdev_rss_hash_update(struct rte_eth_dev *dev,
if (bond_rss_conf.rss_hf != 0)
dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf = 
bond_rss_conf.rss_hf;
 
+   if (bond_rss_conf.algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (bond_rss_conf.rss_key) {
if (bond_rss_conf.rss_key_len < internals->rss_key_len)
return -EINVAL;
@@ -3915,6 +3918,9 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
struct rte_eth_rss_conf *rss_conf =
&dev->data->dev_conf.rx_adv_conf.rss_conf;
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (internals->rss_key_len == 0) {
internals->rss_key_len = sizeof(default_rss_key);
}
-- 
2.30.0



[PATCH v5 08/40] net/cnxk: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/cnxk/cnxk_ethdev.c | 5 +
 drivers/net/cnxk/cnxk_ethdev_ops.c | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
index 01b707b6c4ac..dc150de745df 100644
--- a/drivers/net/cnxk/cnxk_ethdev.c
+++ b/drivers/net/cnxk/cnxk_ethdev.c
@@ -976,6 +976,10 @@ nix_rss_default_setup(struct cnxk_eth_dev *dev)
if (rss_hash_level)
rss_hash_level -= 1;
 
+   if (eth_dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
flowkey_cfg = cnxk_rss_ethdev_to_nix(dev, rss_hf, rss_hash_level);
return roc_nix_rss_default_setup(&dev->nix, flowkey_cfg);
 }
@@ -1373,6 +1377,7 @@ cnxk_nix_configure(struct rte_eth_dev *eth_dev)
}
 
/* Configure RSS */
+
rc = nix_rss_default_setup(dev);
if (rc) {
plt_err("Failed to configure rss rc=%d", rc);
diff --git a/drivers/net/cnxk/cnxk_ethdev_ops.c 
b/drivers/net/cnxk/cnxk_ethdev_ops.c
index 3ade8eed3626..b6cba99cbb7f 100644
--- a/drivers/net/cnxk/cnxk_ethdev_ops.c
+++ b/drivers/net/cnxk/cnxk_ethdev_ops.c
@@ -1054,6 +1054,9 @@ cnxk_nix_rss_hash_update(struct rte_eth_dev *eth_dev,
int rc = -EINVAL;
uint8_t alg_idx;
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   goto fail;
+
if (rss_conf->rss_key && rss_conf->rss_key_len != ROC_NIX_RSS_KEY_LEN) {
plt_err("Hash key size mismatch %d vs %d",
rss_conf->rss_key_len, ROC_NIX_RSS_KEY_LEN);
-- 
2.30.0



[PATCH v5 10/40] net/cxgbe: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/cxgbe/cxgbe_ethdev.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 45bbeaef0ceb..8de57bbfe661 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -440,9 +440,13 @@ int cxgbe_dev_configure(struct rte_eth_dev *eth_dev)
 
CXGBE_FUNC_TRACE();
 
-   if (eth_dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+   if (eth_dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
eth_dev->data->dev_conf.rxmode.offloads |=
RTE_ETH_RX_OFFLOAD_RSS_HASH;
+   if (eth_dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+   }
 
if (!(adapter->flags & FW_QUEUE_BOUND)) {
err = cxgbe_setup_sge_fwevtq(adapter);
@@ -1165,6 +1169,9 @@ static int cxgbe_dev_rss_hash_update(struct rte_eth_dev 
*dev,
struct adapter *adapter = pi->adapter;
int err;
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
err = cxgbe_write_rss_conf(pi, rss_conf->rss_hf);
if (err)
return err;
-- 
2.30.0



[PATCH v5 09/40] net/cpfl: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/cpfl/cpfl_ethdev.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index c4ca9343c3e0..6acb6ce9fd22 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -450,6 +450,9 @@ cpfl_init_rss(struct idpf_vport *vport)
rss_conf = &dev_data->dev_conf.rx_adv_conf.rss_conf;
nb_q = dev_data->nb_rx_queues;
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (rss_conf->rss_key == NULL) {
for (i = 0; i < vport->rss_key_size; i++)
vport->rss_key[i] = (uint8_t)rte_rand();
@@ -568,6 +571,9 @@ cpfl_rss_hash_update(struct rte_eth_dev *dev,
return -ENOTSUP;
}
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (!rss_conf->rss_key || rss_conf->rss_key_len == 0) {
PMD_DRV_LOG(DEBUG, "No key to be configured");
goto skip_rss_key;
-- 
2.30.0



[PATCH v5 11/40] net/dpaa: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/dpaa/dpaa_ethdev.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index a6c86113d125..c4d5de9ba21d 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -258,6 +258,10 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
}
 
if (!(default_q || fmc_q)) {
+   if (eth_conf->rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (dpaa_fm_config(dev,
eth_conf->rx_adv_conf.rss_conf.rss_hf)) {
dpaa_write_fm_config_to_file();
@@ -1446,6 +1450,9 @@ dpaa_dev_rss_hash_update(struct rte_eth_dev *dev,
PMD_INIT_FUNC_TRACE();
 
if (!(default_q || fmc_q)) {
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (dpaa_fm_config(dev, rss_conf->rss_hf)) {
DPAA_PMD_ERR("FM port configuration: Failed\n");
return -1;
-- 
2.30.0



[PATCH v5 12/40] net/dpaa2: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/dpaa2/dpaa2_ethdev.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 679f33ae1a08..355c94b6112f 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -583,6 +583,10 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
}
 
if (eth_conf->rxmode.mq_mode == RTE_ETH_MQ_RX_RSS) {
+   if (eth_conf->rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
for (tc_index = 0; tc_index < priv->num_rx_tc; tc_index++) {
ret = dpaa2_setup_flow_dist(dev,
eth_conf->rx_adv_conf.rss_conf.rss_hf,
@@ -2194,6 +2198,9 @@ dpaa2_dev_rss_hash_update(struct rte_eth_dev *dev,
 
PMD_INIT_FUNC_TRACE();
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (rss_conf->rss_hf) {
for (tc_index = 0; tc_index < priv->num_rx_tc; tc_index++) {
ret = dpaa2_setup_flow_dist(dev, rss_conf->rss_hf,
-- 
2.30.0



[PATCH v5 13/40] net/ena: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/ena/ena_rss.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ena/ena_rss.c b/drivers/net/ena/ena_rss.c
index d0ba9d5c0a14..06aff9f3bd49 100644
--- a/drivers/net/ena/ena_rss.c
+++ b/drivers/net/ena/ena_rss.c
@@ -398,6 +398,9 @@ static int ena_rss_hash_set(struct ena_com_dev *ena_dev,
uint8_t *rss_key;
int rc;
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (rss_conf->rss_key != NULL) {
/* Reorder the RSS key bytes for the hardware requirements. */
ena_reorder_rss_hash_key(hw_rss_key, rss_conf->rss_key,
-- 
2.30.0



[PATCH v5 14/40] net/enic: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/enic/enic_ethdev.c | 1 +
 drivers/net/enic/enic_main.c   | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index cdf091559196..164f423a85c8 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -834,6 +834,7 @@ static int enicpmd_dev_rss_hash_conf_get(struct rte_eth_dev 
*dev,
ENICPMD_FUNC_TRACE();
if (rss_conf == NULL)
return -EINVAL;
+
if (rss_conf->rss_key != NULL &&
rss_conf->rss_key_len < ENIC_RSS_HASH_KEY_SIZE) {
dev_err(enic, "rss_hash_conf_get: wrong rss_key_len. given=%u"
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index 19a99a82c501..2eafe7637b3a 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -1428,6 +1428,9 @@ int enic_set_rss_conf(struct enic *enic, struct 
rte_eth_rss_conf *rss_conf)
}
}
 
+   if (rss_enable && rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
ret = enic_set_niccfg(enic, ENIC_RSS_DEFAULT_CPU, rss_hash_type,
  ENIC_RSS_HASH_BITS, ENIC_RSS_BASE_CPU,
  rss_enable);
-- 
2.30.0



[PATCH v5 15/40] net/fm10k: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/fm10k/fm10k_ethdev.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 4d3c4c10cfa4..d8b27e84d836 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -452,8 +452,12 @@ fm10k_dev_configure(struct rte_eth_dev *dev)
 
PMD_INIT_FUNC_TRACE();
 
-   if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+   if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
dev->data->dev_conf.rxmode.offloads |= 
RTE_ETH_RX_OFFLOAD_RSS_HASH;
+   if (dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+   }
 
/* multiple queue mode checking */
ret  = fm10k_check_mq_mode(dev);
@@ -2195,6 +2199,9 @@ fm10k_rss_hash_update(struct rte_eth_dev *dev,
FM10K_RSSRK_ENTRIES_PER_REG))
return -EINVAL;
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (hf == 0)
return -EINVAL;
 
-- 
2.30.0



[PATCH v5 16/40] net/hinic: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/hinic/hinic_pmd_ethdev.c | 3 +++
 drivers/net/hinic/hinic_pmd_rx.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c 
b/drivers/net/hinic/hinic_pmd_ethdev.c
index 7aa5e7d8e929..e818dc939073 100644
--- a/drivers/net/hinic/hinic_pmd_ethdev.c
+++ b/drivers/net/hinic/hinic_pmd_ethdev.c
@@ -1937,6 +1937,9 @@ static int hinic_rss_hash_update(struct rte_eth_dev *dev,
return HINIC_OK;
}
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return HINIC_ERROR;
+
if (rss_conf->rss_key_len > HINIC_RSS_KEY_SIZE) {
PMD_DRV_LOG(ERR, "Invalid rss key, rss_key_len: %d",
rss_conf->rss_key_len);
diff --git a/drivers/net/hinic/hinic_pmd_rx.c b/drivers/net/hinic/hinic_pmd_rx.c
index 7adb6e365993..7736b61c0b0f 100644
--- a/drivers/net/hinic/hinic_pmd_rx.c
+++ b/drivers/net/hinic/hinic_pmd_rx.c
@@ -670,6 +670,9 @@ int hinic_rx_configure(struct rte_eth_dev *dev)
goto rss_config_err;
}
 
+   if (rss_conf.algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   goto rss_config_err;
+
err = hinic_rss_init(nic_dev, NULL, &rss_conf);
if (err) {
PMD_DRV_LOG(ERR, "Init rss failed");
-- 
2.30.0



[PATCH v5 17/40] net/i40e: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/i40e/i40e_ethdev.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 50ba9aac9498..fcd6d4eb0495 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -7749,6 +7749,9 @@ i40e_dev_rss_hash_update(struct rte_eth_dev *dev,
if (rss_hf == 0) /* Disable RSS */
return -EINVAL;
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
return i40e_hw_rss_hash_set(pf, rss_conf);
 }
 
@@ -8986,6 +8989,10 @@ i40e_pf_config_rss(struct i40e_pf *pf)
!(mq_mode & RTE_ETH_MQ_RX_RSS_FLAG))
return 0;
 
+   if (pf->dev_data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
hw = I40E_PF_TO_HW(pf);
hena = i40e_config_hena(pf->adapter, rss_hf);
i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), (uint32_t)hena);
-- 
2.30.0



[PATCH v5 18/40] net/iavf: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/iavf/iavf_ethdev.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index f2fc5a56216d..9d6950d462a6 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -523,6 +523,9 @@ iavf_init_rss(struct iavf_adapter *adapter)
return -ENOTSUP;
}
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
/* configure RSS key */
if (!rss_conf->rss_key) {
/* Calculate the default hash key */
@@ -1588,6 +1591,9 @@ iavf_dev_rss_hash_update(struct rte_eth_dev *dev,
if (!(vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF))
return -ENOTSUP;
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
/* Set hash key. */
ret = iavf_set_rss_key(adapter, rss_conf->rss_key,
   rss_conf->rss_key_len);
-- 
2.30.0



[PATCH v5 19/40] net/ice: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/ice/ice_dcf.c| 3 +++
 drivers/net/ice/ice_dcf_ethdev.c | 3 +++
 drivers/net/ice/ice_ethdev.c | 7 +++
 3 files changed, 13 insertions(+)

diff --git a/drivers/net/ice/ice_dcf.c b/drivers/net/ice/ice_dcf.c
index 7f8f5163acef..bff39cf9d145 100644
--- a/drivers/net/ice/ice_dcf.c
+++ b/drivers/net/ice/ice_dcf.c
@@ -1120,6 +1120,9 @@ ice_dcf_init_rss(struct ice_dcf_hw *hw)
return ice_dcf_configure_rss_lut(hw);
}
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
/* In IAVF, RSS enablement is set by PF driver. It is not supported
 * to set based on rss_conf->rss_hf.
 */
diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c
index 30ad18d8fc20..f0db68c5dee5 100644
--- a/drivers/net/ice/ice_dcf_ethdev.c
+++ b/drivers/net/ice/ice_dcf_ethdev.c
@@ -1405,6 +1405,9 @@ ice_dcf_dev_rss_hash_update(struct rte_eth_dev *dev,
if (!(hw->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF))
return -ENOTSUP;
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
/* HENA setting, it is enabled by default, no change */
if (!rss_conf->rss_key || rss_conf->rss_key_len == 0) {
PMD_DRV_LOG(DEBUG, "No key to be configured");
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 4bad39c2c1c9..0cba6f7d7b6a 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -3383,6 +3383,10 @@ static int ice_init_rss(struct ice_pf *pf)
return -ENOMEM;
}
}
+
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
/* configure RSS key */
if (!rss_conf->rss_key)
ice_get_default_rss_key(vsi->rss_key, vsi->rss_key_size);
@@ -5046,6 +5050,9 @@ ice_rss_hash_update(struct rte_eth_dev *dev,
struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
struct ice_vsi *vsi = pf->main_vsi;
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
/* set hash key */
status = ice_set_rss_key(vsi, rss_conf->rss_key, rss_conf->rss_key_len);
if (status)
-- 
2.30.0



[PATCH v5 20/40] net/idpf: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/idpf/idpf_ethdev.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index 3af7cf0bb7e0..013db04ac8fc 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -426,6 +426,9 @@ idpf_init_rss(struct idpf_vport *vport)
rss_conf = &dev_data->dev_conf.rx_adv_conf.rss_conf;
nb_q = dev_data->nb_rx_queues;
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (rss_conf->rss_key == NULL) {
for (i = 0; i < vport->rss_key_size; i++)
vport->rss_key[i] = (uint8_t)rte_rand();
@@ -541,6 +544,9 @@ idpf_rss_hash_update(struct rte_eth_dev *dev,
return -ENOTSUP;
}
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (!rss_conf->rss_key || rss_conf->rss_key_len == 0) {
PMD_DRV_LOG(DEBUG, "No key to be configured");
goto skip_rss_key;
-- 
2.30.0



[PATCH v5 21/40] net/igc: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/igc/igc_ethdev.c | 4 
 drivers/net/igc/igc_txrx.c   | 5 +
 2 files changed, 9 insertions(+)

diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c
index 58c4f8092772..11c0f5ff231b 100644
--- a/drivers/net/igc/igc_ethdev.c
+++ b/drivers/net/igc/igc_ethdev.c
@@ -2442,6 +2442,10 @@ eth_igc_rss_hash_update(struct rte_eth_dev *dev,
struct rte_eth_rss_conf *rss_conf)
 {
struct igc_hw *hw = IGC_DEV_PRIVATE_HW(dev);
+
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
igc_hw_rss_hash_set(hw, rss_conf);
return 0;
 }
diff --git a/drivers/net/igc/igc_txrx.c b/drivers/net/igc/igc_txrx.c
index 5c60e3e99709..5e62e00d2ad9 100644
--- a/drivers/net/igc/igc_txrx.c
+++ b/drivers/net/igc/igc_txrx.c
@@ -818,6 +818,7 @@ igc_rss_configure(struct rte_eth_dev *dev)
rss_conf = dev->data->dev_conf.rx_adv_conf.rss_conf;
if (rss_conf.rss_key == NULL)
rss_conf.rss_key = default_rss_key;
+
igc_hw_rss_hash_set(hw, &rss_conf);
 }
 
@@ -958,6 +959,10 @@ igc_dev_mq_rx_configure(struct rte_eth_dev *dev)
return -EINVAL;
}
 
+   if (dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
switch (dev->data->dev_conf.rxmode.mq_mode) {
case RTE_ETH_MQ_RX_RSS:
igc_rss_configure(dev);
-- 
2.30.0



[PATCH v5 22/40] net/ionic: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/ionic/ionic_ethdev.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c
index 340fd0cd5923..e2e4d23c069b 100644
--- a/drivers/net/ionic/ionic_ethdev.c
+++ b/drivers/net/ionic/ionic_ethdev.c
@@ -642,6 +642,9 @@ ionic_dev_rss_hash_update(struct rte_eth_dev *eth_dev,
if (rss_conf->rss_key)
key = rss_conf->rss_key;
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if ((rss_conf->rss_hf & IONIC_ETH_RSS_OFFLOAD_ALL) == 0) {
/*
 * Can't disable rss through hash flags,
@@ -826,6 +829,9 @@ ionic_dev_configure(struct rte_eth_dev *eth_dev)
 
IONIC_PRINT_CALL();
 
+   if (eth_dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
ionic_lif_configure(lif);
 
return 0;
-- 
2.30.0



[PATCH v5 23/40] net/ixgbe: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 12 ++--
 drivers/net/ixgbe/ixgbe_rxtx.c   |  4 
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index d6cf00317e77..b92cd746a061 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -2434,8 +2434,12 @@ ixgbe_dev_configure(struct rte_eth_dev *dev)
 
PMD_INIT_FUNC_TRACE();
 
-   if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+   if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
dev->data->dev_conf.rxmode.offloads |= 
RTE_ETH_RX_OFFLOAD_RSS_HASH;
+   if (dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+   }
 
/* multiple queue mode checking */
ret  = ixgbe_check_mq_mode(dev);
@@ -5326,8 +5330,12 @@ ixgbevf_dev_configure(struct rte_eth_dev *dev)
PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
 dev->data->port_id);
 
-   if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+   if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
dev->data->dev_conf.rxmode.offloads |= 
RTE_ETH_RX_OFFLOAD_RSS_HASH;
+   if (dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+   }
 
/*
 * VF has no ability to enable/disable HW CRC
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 90b0a7004f50..150f8065ab60 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -3631,6 +3631,10 @@ ixgbe_dev_rss_hash_update(struct rte_eth_dev *dev,
/* RSS enabled */
if (rss_hf == 0) /* Disable RSS */
return -(EINVAL);
+
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
ixgbe_hw_rss_hash_set(hw, rss_conf);
return 0;
 }
-- 
2.30.0



[PATCH v5 24/40] net/mana: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/mana/mana.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c
index 41c3cf259584..e3055bb545d9 100644
--- a/drivers/net/mana/mana.c
+++ b/drivers/net/mana/mana.c
@@ -80,8 +80,12 @@ mana_dev_configure(struct rte_eth_dev *dev)
struct mana_priv *priv = dev->data->dev_private;
struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
 
-   if (dev_conf->rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
-   dev_conf->rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
+   if (dev_conf->rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
+   dev->data->dev_conf.rxmode.offloads |= 
RTE_ETH_RX_OFFLOAD_RSS_HASH;
+   if (dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+   }
 
if (dev->data->nb_rx_queues != dev->data->nb_tx_queues) {
DRV_LOG(ERR, "Only support equal number of rx/tx queues");
@@ -413,6 +417,9 @@ mana_rss_hash_update(struct rte_eth_dev *dev,
return -ENODEV;
}
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (rss_conf->rss_hf & ~MANA_ETH_RSS_SUPPORT) {
DRV_LOG(ERR, "Port %u invalid RSS HF 0x%" PRIx64,
dev->data->port_id, rss_conf->rss_hf);
-- 
2.30.0



[PATCH v5 26/40] net/mvpp2: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/mvpp2/mrvl_ethdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index 359a5d1df7ab..817153af2ef1 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -440,6 +440,9 @@ mrvl_configure_rss(struct mrvl_priv *priv, struct 
rte_eth_rss_conf *rss_conf)
if (rss_conf->rss_key)
MRVL_LOG(WARNING, "Changing hash key is not supported");
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (rss_conf->rss_hf == 0) {
priv->ppio_params.inqs_params.hash_type = PP2_PPIO_HASH_T_NONE;
} else if (rss_conf->rss_hf & RTE_ETH_RSS_IPV4) {
-- 
2.30.0



[PATCH v5 25/40] net/mlx5: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/mlx5/mlx5_ethdev.c | 4 
 drivers/net/mlx5/mlx5_rss.c| 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 4a85415ff38d..5437fa531738 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -74,6 +74,10 @@ mlx5_dev_configure(struct rte_eth_dev *dev)
!!dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key;
int ret = 0;
 
+   if (dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (use_app_rss_key &&
(dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len !=
 MLX5_RSS_HASH_KEY_LEN)) {
diff --git a/drivers/net/mlx5/mlx5_rss.c b/drivers/net/mlx5/mlx5_rss.c
index e2b478b75ce7..25c410e6010a 100644
--- a/drivers/net/mlx5/mlx5_rss.c
+++ b/drivers/net/mlx5/mlx5_rss.c
@@ -37,7 +37,8 @@ mlx5_rss_hash_update(struct rte_eth_dev *dev,
unsigned int i;
unsigned int idx;
 
-   if (rss_conf->rss_hf & MLX5_RSS_HF_MASK) {
+   if (rss_conf->rss_hf & MLX5_RSS_HF_MASK ||
+   rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT) {
rte_errno = EINVAL;
return -rte_errno;
}
-- 
2.30.0



[PATCH v5 27/40] net/netvsc: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/netvsc/hn_ethdev.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index d0bbc0a4c0c0..9e4205816a6f 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -395,6 +395,9 @@ static int hn_rss_hash_update(struct rte_eth_dev *dev,
return err;
}
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
hn_rss_hash_init(hv, rss_conf);
 
if (rss_conf->rss_hf != 0) {
@@ -756,6 +759,9 @@ static int hn_dev_configure(struct rte_eth_dev *dev)
for (i = 0; i < NDIS_HASH_INDCNT; i++)
hv->rss_ind[i] = i % dev->data->nb_rx_queues;
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
hn_rss_hash_init(hv, rss_conf);
 
subchan = hv->num_queues - 1;
-- 
2.30.0



[PATCH v5 28/40] net/ngbe: : check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/ngbe/ngbe_ethdev.c | 6 +-
 drivers/net/ngbe/ngbe_rxtx.c   | 3 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c
index 478da014b2f8..bb4b8afb0a80 100644
--- a/drivers/net/ngbe/ngbe_ethdev.c
+++ b/drivers/net/ngbe/ngbe_ethdev.c
@@ -921,8 +921,12 @@ ngbe_dev_configure(struct rte_eth_dev *dev)
 
PMD_INIT_FUNC_TRACE();
 
-   if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+   if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
+   if (dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
dev->data->dev_conf.rxmode.offloads |= 
RTE_ETH_RX_OFFLOAD_RSS_HASH;
+   }
 
/* set flag to update link status after init */
intr->flags |= NGBE_FLAG_NEED_LINK_UPDATE;
diff --git a/drivers/net/ngbe/ngbe_rxtx.c b/drivers/net/ngbe/ngbe_rxtx.c
index f31906cc2fe3..0b22d567fcb6 100644
--- a/drivers/net/ngbe/ngbe_rxtx.c
+++ b/drivers/net/ngbe/ngbe_rxtx.c
@@ -2500,6 +2500,9 @@ ngbe_dev_rss_hash_update(struct rte_eth_dev *dev,
return -ENOTSUP;
}
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
hash_key = rss_conf->rss_key;
if (hash_key) {
/* Fill in RSS hash key */
-- 
2.30.0



[PATCH v5 30/40] net/null: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/null/rte_eth_null.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 31081af79752..8427d7484178 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -186,6 +186,11 @@ eth_null_copy_tx(void *q, struct rte_mbuf **bufs, uint16_t 
nb_bufs)
 static int
 eth_dev_configure(struct rte_eth_dev *dev __rte_unused)
 {
+   if ((dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) &&
+dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
return 0;
 }
 
@@ -444,6 +449,9 @@ eth_rss_hash_update(struct rte_eth_dev *dev, struct 
rte_eth_rss_conf *rss_conf)
 
rte_spinlock_lock(&internal->rss_lock);
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if ((rss_conf->rss_hf & internal->flow_type_rss_offloads) != 0)
dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf =
rss_conf->rss_hf & 
internal->flow_type_rss_offloads;
-- 
2.30.0



[PATCH v5 31/40] net/qede: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/qede/qede_ethdev.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index 22cd4706467a..7db69e8f35e0 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -1272,8 +1272,12 @@ static int qede_dev_configure(struct rte_eth_dev 
*eth_dev)
 
PMD_INIT_FUNC_TRACE(edev);
 
-   if (rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+   if (rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
+   if (eth_dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
rxmode->offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
+   }
 
/* We need to have min 1 RX queue.There is no min check in
 * rte_eth_dev_configure(), so we are checking it here.
@@ -2119,6 +2123,9 @@ int qede_rss_hash_update(struct rte_eth_dev *eth_dev,
DP_INFO(edev, "RSS hf = 0x%lx len = %u key = %p\n",
(unsigned long)hf, len, key);
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (hf != 0) {
/* Enabling RSS */
DP_INFO(edev, "Enabling rss\n");
-- 
2.30.0



[PATCH v5 29/40] net/nfp: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/nfp/nfp_common.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 5683afc40a31..780316c764df 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -390,8 +390,12 @@ nfp_net_configure(struct rte_eth_dev *dev)
rxmode = &dev_conf->rxmode;
txmode = &dev_conf->txmode;
 
-   if (rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+   if (rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
rxmode->offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
+   if (dev_conf->rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+   }
 
/* Checking TX mode */
if (txmode->mq_mode) {
@@ -1805,6 +1809,9 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
return 0; /* Nothing to do */
}
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (rss_conf->rss_key_len > NFP_NET_CFG_RSS_KEY_SZ) {
PMD_DRV_LOG(ERR, "hash key too long");
return -EINVAL;
-- 
2.30.0



[PATCH v5 32/40] net/sfc: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/sfc/sfc_ethdev.c | 3 +++
 drivers/net/sfc/sfc_rx.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 1efe64a36a7f..19d7761e2664 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -1728,6 +1728,9 @@ sfc_dev_rss_hash_update(struct rte_eth_dev *dev,
goto fail_scale_mode_set;
}
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (rss_conf->rss_key != NULL) {
if (sa->state == SFC_ETHDEV_STARTED) {
for (key_i = 0; key_i < n_contexts; key_i++) {
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index 1dde2c111001..71c151a07162 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -1519,6 +1519,9 @@ sfc_rx_process_adv_conf_rss(struct sfc_adapter *sa,
return rc;
}
 
+   if (conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (conf->rss_key != NULL) {
if (conf->rss_key_len != sizeof(rss->key)) {
sfc_err(sa, "RSS key size is wrong (should be %zu)",
-- 
2.30.0



[PATCH v5 33/40] net/tap: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/tap/rte_eth_tap.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index b25a52655fa2..5e4813637f0b 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -1038,6 +1038,10 @@ tap_dev_configure(struct rte_eth_dev *dev)
TAP_LOG(INFO, "%s: %s: RX configured queues number: %u",
dev->device->name, pmd->name, dev->data->nb_rx_queues);
 
+   if (dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
return 0;
 }
 
@@ -1894,6 +1898,10 @@ tap_rss_hash_update(struct rte_eth_dev *dev,
rte_errno = EINVAL;
return -rte_errno;
}
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT) {
+   rte_errno = EINVAL;
+   return -rte_errno;
+   }
if (rss_conf->rss_key && rss_conf->rss_key_len) {
/*
 * Currently TAP RSS key is hard coded
-- 
2.30.0



[PATCH v5 34/40] net/thunderx: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/thunderx/nicvf_ethdev.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index ab1e714d9767..2fc54c521c88 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -621,6 +621,9 @@ nicvf_dev_rss_hash_update(struct rte_eth_dev *dev,
struct nicvf *nic = nicvf_pmd_priv(dev);
uint64_t nic_rss;
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
if (rss_conf->rss_key &&
rss_conf->rss_key_len != RSS_HASH_KEY_BYTE_SIZE) {
PMD_DRV_LOG(ERR, "Hash key size mismatch %u",
@@ -1984,8 +1987,13 @@ nicvf_dev_configure(struct rte_eth_dev *dev)
 
PMD_INIT_FUNC_TRACE();
 
-   if (rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+   if (rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
+   if (conf->rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
rxmode->offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
+   }
 
if (!rte_eal_has_hugepages()) {
PMD_INIT_LOG(INFO, "Huge page is not configured");
-- 
2.30.0



[PATCH v5 35/40] net/txgbe: check RSS hash algorithms

2023-10-11 Thread Jie Hai
A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
 drivers/net/txgbe/txgbe_ethdev.c| 7 ++-
 drivers/net/txgbe/txgbe_ethdev_vf.c | 7 ++-
 drivers/net/txgbe/txgbe_rxtx.c  | 3 +++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index 6bc231a13063..b0e6ea6d171b 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -1525,8 +1525,13 @@ txgbe_dev_configure(struct rte_eth_dev *dev)
 
PMD_INIT_FUNC_TRACE();
 
-   if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+   if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
+   if (dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
dev->data->dev_conf.rxmode.offloads |= 
RTE_ETH_RX_OFFLOAD_RSS_HASH;
+   }
 
/* multiple queue mode checking */
ret  = txgbe_check_mq_mode(dev);
diff --git a/drivers/net/txgbe/txgbe_ethdev_vf.c 
b/drivers/net/txgbe/txgbe_ethdev_vf.c
index f1341fbf7e22..b0bc8441ac12 100644
--- a/drivers/net/txgbe/txgbe_ethdev_vf.c
+++ b/drivers/net/txgbe/txgbe_ethdev_vf.c
@@ -579,8 +579,13 @@ txgbevf_dev_configure(struct rte_eth_dev *dev)
PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
 dev->data->port_id);
 
-   if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
+   if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
+   if (dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=
+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
dev->data->dev_conf.rxmode.offloads |= 
RTE_ETH_RX_OFFLOAD_RSS_HASH;
+   }
 
/*
 * VF has no ability to enable/disable HW CRC
diff --git a/drivers/net/txgbe/txgbe_rxtx.c b/drivers/net/txgbe/txgbe_rxtx.c
index f7cd2333abee..3ffc2f4a57a3 100644
--- a/drivers/net/txgbe/txgbe_rxtx.c
+++ b/drivers/net/txgbe/txgbe_rxtx.c
@@ -2894,6 +2894,9 @@ txgbe_dev_rss_hash_update(struct rte_eth_dev *dev,
return -ENOTSUP;
}
 
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
hash_key = rss_conf->rss_key;
if (hash_key) {
/* Fill in RSS hash key */
-- 
2.30.0



[PATCH v5 36/40] net/hns3: support setting and querying RSS hash function

2023-10-11 Thread Jie Hai
From: Huisong Li 

Support setting and querying RSS hash function by ethdev ops.

Signed-off-by: Huisong Li 
Signed-off-by: Dongdong Liu 
---
 drivers/net/hns3/hns3_rss.c | 47 +
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 6126512bd780..010a759f23d9 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -646,14 +646,14 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
if (ret)
goto set_tuple_fail;
 
-   if (key) {
-   ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo,
-   key, hw->rss_key_size);
-   if (ret)
-   goto set_algo_key_fail;
-   /* Update the shadow RSS key with user specified */
+   ret = hns3_update_rss_algo_key(hw, rss_conf->algorithm, key, key_len);
+   if (ret != 0)
+   goto set_algo_key_fail;
+
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   hw->rss_info.hash_algo = 
hns3_hash_func_map[rss_conf->algorithm];
+   if (key != NULL)
memcpy(hw->rss_info.key, key, hw->rss_key_size);
-   }
hw->rss_info.rss_hf = rss_hf;
rte_spinlock_unlock(&hw->lock);
 
@@ -769,7 +769,13 @@ int
 hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
   struct rte_eth_rss_conf *rss_conf)
 {
+   const uint8_t hash_func_map[] = {
+   [HNS3_RSS_HASH_ALGO_TOEPLITZ] = RTE_ETH_HASH_FUNCTION_TOEPLITZ,
+   [HNS3_RSS_HASH_ALGO_SIMPLE] = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR,
+   [HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP] = 
RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
+   };
struct hns3_adapter *hns = dev->data->dev_private;
+   uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0};
struct hns3_hw *hw = &hns->hw;
uint8_t hash_algo;
int ret;
@@ -777,26 +783,27 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
rte_spinlock_lock(&hw->lock);
ret = hns3_rss_hash_get_rss_hf(hw, &rss_conf->rss_hf);
if (ret != 0) {
+   rte_spinlock_unlock(&hw->lock);
hns3_err(hw, "obtain hash tuples failed, ret = %d", ret);
-   goto out;
+   return ret;
+   }
+
+   ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_key, hw->rss_key_size);
+   if (ret != 0) {
+   rte_spinlock_unlock(&hw->lock);
+   hns3_err(hw, "obtain hash algo and key failed, ret = %d", ret);
+   return ret;
}
+   rte_spinlock_unlock(&hw->lock);
 
-   /* Get the RSS Key required by the user */
+   /* Get the RSS Key if user required. */
if (rss_conf->rss_key && rss_conf->rss_key_len >= hw->rss_key_size) {
-   ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_conf->rss_key,
-   hw->rss_key_size);
-   if (ret != 0) {
-   hns3_err(hw, "obtain hash algo and key failed, ret = 
%d",
-ret);
-   goto out;
-   }
+   memcpy(rss_conf->rss_key, rss_key, hw->rss_key_size);
rss_conf->rss_key_len = hw->rss_key_size;
}
+   rss_conf->algorithm = hash_func_map[hash_algo];
 
-out:
-   rte_spinlock_unlock(&hw->lock);
-
-   return ret;
+   return 0;
 }
 
 /*
-- 
2.30.0



[PATCH v5 37/40] app/proc-info: fix never show RSS info

2023-10-11 Thread Jie Hai
Command show-port should show RSS info (rss_key, len and rss_hf),
However, the information is shown only when rss_conf.rss_key is not
NULL. Since no memory is allocated for rss_conf.rss_key, rss_key
will always be NULL and the rss_info will never show. This patch
fixes it.

Fixes: 8a37f37fc243 ("app/procinfo: add --show-port")
Cc: sta...@dpdk.org

Signed-off-by: Jie Hai 
Signed-off-by: Dongdong Liu 
Acked-by: Reshma Pattan 
---
 app/proc-info/main.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index af4c1d8bcbd4..4509b3c16e36 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -152,6 +152,8 @@ struct desc_param {
 static struct desc_param rx_desc_param;
 static struct desc_param tx_desc_param;
 
+#define RSS_HASH_KEY_SIZE 64
+
 /* display usage */
 static void
 proc_info_usage(const char *prgname)
@@ -1013,6 +1015,7 @@ show_port(void)
struct rte_eth_fc_conf fc_conf;
struct rte_ether_addr mac;
struct rte_eth_dev_owner owner;
+   uint8_t rss_key[RSS_HASH_KEY_SIZE];
 
/* Skip if port is not in mask */
if ((enabled_port_mask & (1ul << i)) == 0)
@@ -1171,17 +1174,17 @@ show_port(void)
printf("\n");
}
 
+   rss_conf.rss_key = rss_key;
+   rss_conf.rss_key_len = dev_info.hash_key_size;
ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
if (ret == 0) {
-   if (rss_conf.rss_key) {
-   printf("  - RSS\n");
-   printf("\t  -- RSS len %u key (hex):",
-   rss_conf.rss_key_len);
-   for (k = 0; k < rss_conf.rss_key_len; k++)
-   printf(" %x", rss_conf.rss_key[k]);
-   printf("\t  -- hf 0x%"PRIx64"\n",
-   rss_conf.rss_hf);
-   }
+   printf("  - RSS\n");
+   printf("\t  -- RSS len %u key (hex):",
+   rss_conf.rss_key_len);
+   for (k = 0; k < rss_conf.rss_key_len; k++)
+   printf(" %x", rss_conf.rss_key[k]);
+   printf("\t  -- hf 0x%"PRIx64"\n",
+   rss_conf.rss_hf);
}
 
 #ifdef RTE_LIB_SECURITY
-- 
2.30.0



[PATCH v5 38/40] app/proc-info: adjust the display format of RSS info

2023-10-11 Thread Jie Hai
This patch splits the length and value of RSS key into two parts,
removes spaces between RSS keys, and adds line breaks between RSS
key and RSS hf.

Before the adjustment, RSS info is shown as:
  - RSS
  -- RSS len 40 key (hex): 6d 5a 56 da 25 5b e c2 41 67 \
 25 3d 43 a3 8f b0 d0 ca 2b cb ae 7b 30 b4 77 cb 2d \
 a3 80 30 f2 c 6a 42 b7 3b be ac 1 fa -- hf 0x0
and after:
  - RSS info
  -- key len : 40
  -- key (hex) : 6d5a56da255b0ec24167253d43a38fb0d0c \
a2bcbae7b30b477cb2da38030f20c6a42b73bbeac01fa
  -- hash function : 0x0

Fixes: 8a37f37fc243 ("app/procinfo: add --show-port")
Cc: sta...@dpdk.org

Signed-off-by: Jie Hai 
Signed-off-by: Dongdong Liu 
Acked-by: Reshma Pattan
---
 app/proc-info/main.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 4509b3c16e36..e98352118db1 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -1178,12 +1178,13 @@ show_port(void)
rss_conf.rss_key_len = dev_info.hash_key_size;
ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
if (ret == 0) {
-   printf("  - RSS\n");
-   printf("\t  -- RSS len %u key (hex):",
+   printf("  - RSS info\n");
+   printf("\t  -- key len : %u\n",
rss_conf.rss_key_len);
+   printf("\t  -- key (hex) : ");
for (k = 0; k < rss_conf.rss_key_len; k++)
-   printf(" %x", rss_conf.rss_key[k]);
-   printf("\t  -- hf 0x%"PRIx64"\n",
+   printf("%02x", rss_conf.rss_key[k]);
+   printf("\n\t  -- hash function : 0x%"PRIx64"\n",
rss_conf.rss_hf);
}
 
-- 
2.30.0



[PATCH v5 39/40] app/proc-info: support querying RSS hash algorithm

2023-10-11 Thread Jie Hai
Display RSS hash algorithm with command show-port as below.
  - RSS info
  -- hash algorithm : toeplitz

Signed-off-by: Jie Hai 
Signed-off-by: Dongdong Liu 
Acked-by: Reshma Pattan 
---
 app/proc-info/main.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index e98352118db1..43f264848a6f 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -153,6 +153,14 @@ static struct desc_param rx_desc_param;
 static struct desc_param tx_desc_param;
 
 #define RSS_HASH_KEY_SIZE 64
+static const char * const rss_hash_algos[] = {
+   [RTE_ETH_HASH_FUNCTION_SIMPLE_XOR] = "simple_xor",
+   [RTE_ETH_HASH_FUNCTION_TOEPLITZ] = "toeplitz",
+   [RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ] = "symmetric_toeplitz",
+   [RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT] = 
"symmetric_toeplitz_sort",
+   [RTE_ETH_HASH_FUNCTION_DEFAULT] = "default",
+   [RTE_ETH_HASH_FUNCTION_MAX] = "unknown"
+};
 
 /* display usage */
 static void
@@ -1186,6 +1194,8 @@ show_port(void)
printf("%02x", rss_conf.rss_key[k]);
printf("\n\t  -- hash function : 0x%"PRIx64"\n",
rss_conf.rss_hf);
+   printf("\t  -- hash algorithm : %s\n",
+   rss_hash_algos[rss_conf.algorithm]);
}
 
 #ifdef RTE_LIB_SECURITY
-- 
2.30.0



[PATCH v5 40/40] app/testpmd: add RSS hash algorithms display

2023-10-11 Thread Jie Hai
Add the command "show port X rss-hash algorithm" to display
the RSS hash algorithms of port X. An example is shown:

testpmd> show port 0 rss-hash algorithm
RSS algorithms:
  toeplitz

Signed-off-by: Jie Hai 
---
 app/test-pmd/cmdline.c | 29 -
 app/test-pmd/config.c  | 38 +++---
 app/test-pmd/testpmd.h |  2 +-
 3 files changed, 44 insertions(+), 25 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 679ca47b9401..d0eafd7f1254 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -174,8 +174,8 @@ static void cmd_help_long_parsed(void *parsed_result,
" by masks on port X. size is used to indicate the"
" hardware supported reta size\n\n"
 
-   "show port (port_id) rss-hash [key]\n"
-   "Display the RSS hash functions and RSS hash key of 
port\n\n"
+   "show port (port_id) rss-hash [key | algorithm]\n"
+   "Display the RSS hash functions, RSS hash key and 
RSS hash algorithms of port\n\n"
 
"clear port (info|stats|xstats|fdir) (port_id|all)\n"
"Clear information for port_id, or all.\n\n"
@@ -3026,15 +3026,17 @@ struct cmd_showport_rss_hash {
cmdline_fixed_string_t rss_hash;
cmdline_fixed_string_t rss_type;
cmdline_fixed_string_t key; /* optional argument */
+   cmdline_fixed_string_t algorithm; /* optional argument */
 };
 
 static void cmd_showport_rss_hash_parsed(void *parsed_result,
__rte_unused struct cmdline *cl,
-   void *show_rss_key)
+   __rte_unused void *data)
 {
struct cmd_showport_rss_hash *res = parsed_result;
 
-   port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
+   port_rss_hash_conf_show(res->port_id,
+   !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
 }
 
 static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
@@ -3049,6 +3051,8 @@ static cmdline_parse_token_string_t 
cmd_showport_rss_hash_rss_hash =
 "rss-hash");
 static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
+static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
+   TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, 
"algorithm");
 
 static cmdline_parse_inst_t cmd_showport_rss_hash = {
.f = cmd_showport_rss_hash_parsed,
@@ -3065,7 +3069,7 @@ static cmdline_parse_inst_t cmd_showport_rss_hash = {
 
 static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
.f = cmd_showport_rss_hash_parsed,
-   .data = (void *)1,
+   .data = NULL,
.help_str = "show port  rss-hash key",
.tokens = {
(void *)&cmd_showport_rss_hash_show,
@@ -3077,6 +3081,20 @@ static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
},
 };
 
+static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
+   .f = cmd_showport_rss_hash_parsed,
+   .data = NULL,
+   .help_str = "show port  rss-hash algorithm",
+   .tokens = {
+   (void *)&cmd_showport_rss_hash_show,
+   (void *)&cmd_showport_rss_hash_port,
+   (void *)&cmd_showport_rss_hash_port_id,
+   (void *)&cmd_showport_rss_hash_rss_hash,
+   (void *)&cmd_showport_rss_hash_rss_algo,
+   NULL,
+   },
+};
+
 /* *** Configure DCB *** */
 struct cmd_config_dcb {
cmdline_fixed_string_t port;
@@ -12953,6 +12971,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
+   (cmdline_parse_inst_t *)&cmd_showport_rss_hash_algo,
(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
(cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
(cmdline_parse_inst_t *)&cmd_dump,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 7034fa125bc0..deb9414191b7 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1485,6 +1485,15 @@ rss_types_display(uint64_t rss_types, uint16_t 
char_num_per_line)
printf("\n");
 }
 
+static const char * const rss_hash_algos[] = {
+   [RTE_ETH_HASH_FUNCTION_SIMPLE_XOR] = "simple_xor",
+   [RTE_ETH_HASH_FUNCTION_TOEPLITZ] = "toeplitz",
+   [RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ] = "symmetric_toeplitz",
+   [RTE_ETH_HASH_FUNCTI

Re: [PATCH v5 01/40] ethdev: overwrite some comment related to RSS

2023-10-11 Thread Jie Hai

On 2023/10/12 0:31, Ferruh Yigit wrote:

On 10/11/2023 10:27 AM, Jie Hai wrote:

1. overwrite the comments of fields of 'rte_eth_rss_conf'.
2. Add comments for RTE_ETH_HASH_FUNCTION_DEFAULT.

Signed-off-by: Jie Hai 
---
  lib/ethdev/rte_ethdev.h | 29 ++---
  lib/ethdev/rte_flow.h   |  3 +++
  2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index 8542257721c9..b9e4e21189d2 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -448,24 +448,23 @@ struct rte_vlan_filter_conf {
  /**
   * A structure used to configure the Receive Side Scaling (RSS) feature
   * of an Ethernet port.
- * If not NULL, the *rss_key* pointer of the *rss_conf* structure points
- * to an array holding the RSS key to use for hashing specific header
- * fields of received packets. The length of this array should be indicated
- * by *rss_key_len* below. Otherwise, a default random hash key is used by
- * the device driver.
- *
- * The *rss_key_len* field of the *rss_conf* structure indicates the length
- * in bytes of the array pointed by *rss_key*. To be compatible, this length
- * will be checked in i40e only. Others assume 40 bytes to be used as before.
- *
- * The *rss_hf* field of the *rss_conf* structure indicates the different
- * types of IPv4/IPv6 packets to which the RSS hashing must be applied.
- * Supplying an *rss_hf* equal to zero disables the RSS feature.
   */
  struct rte_eth_rss_conf {
-   uint8_t *rss_key;/**< If not NULL, 40-byte hash key. */
+   /**
+* If used to query, the'rss_key_len' indicates the size of rss key of
+* the hardware. And only when rss_key_len is not zero, the 'rss_key'
+* is valid.
+* If used to configure, rss_key_len indicates the length of the
+* 'rss_key' if 'rss_key' is not empty.



Ahh, different APIs have different expectations :(
Can you please explicitly name the APIs, instead of "to query", "to
configure"?

And there is a note in original comment that *rss_key_len* is only
checked by i40e, rest assume this value as 40 bytes. New comment doesn't
have it.


A new version is show below:
  * In rte_eth_dev_rss_hash_conf_get(), the *rss_key_len* indicates the
  * size of rss key of the hardware. And only when *rss_key_len* is not
  * zero, the *rss_key* is valid.
  *
  * In rte_eth_dev_rss_hash_update() or rte_eth_dev_configure(), the
  * *rss_key_len* indicates the length of the *rss_key* in bytes of
  * the array pointed by *rss_key*. Drivers are free to ignore the
  * *rss_key_len* and assume key length is 40 bytes.

Please check it. Thanks




+*/
+   uint8_t *rss_key;
uint8_t rss_key_len; /**< hash key length in bytes. */
-   uint64_t rss_hf; /**< Hash functions to apply - see below. */
+   /**
+* Indicating which type of packets and which part of the packets
+* to apply for RSS hash, (see RTE_ETH_RSS_*).



There is something doesn't sound right from language perspective,
perhaps someone whose native language is English can help, what about:

"Indicates the type of packets or the specific part of packets to which
RSS hashing is to be applied."



Better, I will change it.

+* Setting *rss_hf* to zero disables the RSS feature.
+*/
+   uint64_t rss_hf;
  };
  
  /*

diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index b385741fba6d..5d9e3c68af7b 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -3227,6 +3227,9 @@ struct rte_flow_query_count {
   * Hash function types.
   */
  enum rte_eth_hash_function {
+   /**
+* DEFAULT means driver decides which hash algorithm to pick.
+*/
RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */


.


Re: [PATCH v5 26/40] net/mvpp2: check RSS hash algorithms

2023-10-11 Thread Jie Hai

On 2023/10/12 2:00, Ferruh Yigit wrote:

On 10/11/2023 10:27 AM, Jie Hai wrote:

A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
  drivers/net/mvpp2/mrvl_ethdev.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index 359a5d1df7ab..817153af2ef1 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -440,6 +440,9 @@ mrvl_configure_rss(struct mrvl_priv *priv, struct 
rte_eth_rss_conf *rss_conf)
if (rss_conf->rss_key)
MRVL_LOG(WARNING, "Changing hash key is not supported");
  
+	if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)

+   return -EINVAL;
+
if (rss_conf->rss_hf == 0) {
priv->ppio_params.inqs_params.hash_type = PP2_PPIO_HASH_T_NONE;
} else if (rss_conf->rss_hf & RTE_ETH_RSS_IPV4) {


what about updating 'mrvl_dev_configure()' ?
.

Hi, Ferruh Yigit,

Both mrvl_dev_configure() and mrvl_rss_hash_update() calls 
mrvl_configure_rss(), I update this for less code.

It may be clearer to verify the two separately.
Will change.

Thanks,
Jie Hai


Re: [PATCH v5 08/40] net/cnxk: check RSS hash algorithms

2023-10-11 Thread Jie Hai

On 2023/10/12 1:04, Ferruh Yigit wrote:

On 10/11/2023 10:27 AM, Jie Hai wrote:

A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
  drivers/net/cnxk/cnxk_ethdev.c | 5 +
  drivers/net/cnxk/cnxk_ethdev_ops.c | 3 +++
  2 files changed, 8 insertions(+)

diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
index 01b707b6c4ac..dc150de745df 100644
--- a/drivers/net/cnxk/cnxk_ethdev.c
+++ b/drivers/net/cnxk/cnxk_ethdev.c
@@ -976,6 +976,10 @@ nix_rss_default_setup(struct cnxk_eth_dev *dev)
if (rss_hash_level)
rss_hash_level -= 1;
  
+	if (eth_dev->data->dev_conf.rx_adv_conf.rss_conf.algorithm !=

+   RTE_ETH_HASH_FUNCTION_DEFAULT)
+   return -EINVAL;
+
flowkey_cfg = cnxk_rss_ethdev_to_nix(dev, rss_hf, rss_hash_level);
return roc_nix_rss_default_setup(&dev->nix, flowkey_cfg);
  }
@@ -1373,6 +1377,7 @@ cnxk_nix_configure(struct rte_eth_dev *eth_dev)
}
  
  	/* Configure RSS */

+



Looks like unintended change.

Will check it before setup in cnxk_nix_configure().



rc = nix_rss_default_setup(dev);
if (rc) {
plt_err("Failed to configure rss rc=%d", rc);
diff --git a/drivers/net/cnxk/cnxk_ethdev_ops.c 
b/drivers/net/cnxk/cnxk_ethdev_ops.c
index 3ade8eed3626..b6cba99cbb7f 100644
--- a/drivers/net/cnxk/cnxk_ethdev_ops.c
+++ b/drivers/net/cnxk/cnxk_ethdev_ops.c
@@ -1054,6 +1054,9 @@ cnxk_nix_rss_hash_update(struct rte_eth_dev *eth_dev,
int rc = -EINVAL;
uint8_t alg_idx;
  
+	if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)

+   goto fail;
+
if (rss_conf->rss_key && rss_conf->rss_key_len != ROC_NIX_RSS_KEY_LEN) {
plt_err("Hash key size mismatch %d vs %d",
rss_conf->rss_key_len, ROC_NIX_RSS_KEY_LEN);


.


Re: [PATCH v5 13/40] net/ena: check RSS hash algorithms

2023-10-11 Thread Jie Hai

On 2023/10/12 1:27, Ferruh Yigit wrote:

On 10/11/2023 10:27 AM, Jie Hai wrote:

A new field 'algorithm' has been added to rss_conf, check it
in case of ignoring unsupported values.

Signed-off-by: Jie Hai 
---
  drivers/net/ena/ena_rss.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/drivers/net/ena/ena_rss.c b/drivers/net/ena/ena_rss.c
index d0ba9d5c0a14..06aff9f3bd49 100644
--- a/drivers/net/ena/ena_rss.c
+++ b/drivers/net/ena/ena_rss.c
@@ -398,6 +398,9 @@ static int ena_rss_hash_set(struct ena_com_dev *ena_dev,
uint8_t *rss_key;
int rc;
  
+	if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)

+   return -EINVAL;
+
if (rss_conf->rss_key != NULL) {
/* Reorder the RSS key bytes for the hardware requirements. */
ena_reorder_rss_hash_key(hw_rss_key, rss_conf->rss_key,


I can see in some drivers configure() ops is not updated, I assume these
are the ones don't have any RSS related config in it, it is not clear
still to add check, but I guess what you are doing is reasonable, I am
OK with this approach.
.


It's true that these drivers support RSS configuration and check it in
their own setup function instead of in dev_configure ops.
Some drivers calls the setup function in dev_configure,
and some in dev_start. It's better to check the configuration in these
setup function for the latter case.


Re: [PATCH v5 36/40] net/hns3: support setting and querying RSS hash function

2023-10-11 Thread Jie Hai

On 2023/10/12 10:23, fengchengwen wrote:

The new algorithm (RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT) should treat 
as Not Support.

With above fix
Acked-by: Chengwen Feng 


Thanks, will check it.

On 2023/10/11 17:28, Jie Hai wrote:

From: Huisong Li 

Support setting and querying RSS hash function by ethdev ops.

Signed-off-by: Huisong Li 
Signed-off-by: Dongdong Liu 
---
  drivers/net/hns3/hns3_rss.c | 47 +
  1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 6126512bd780..010a759f23d9 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -646,14 +646,14 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
if (ret)
goto set_tuple_fail;
  
-	if (key) {

-   ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo,
-   key, hw->rss_key_size);
-   if (ret)
-   goto set_algo_key_fail;
-   /* Update the shadow RSS key with user specified */
+   ret = hns3_update_rss_algo_key(hw, rss_conf->algorithm, key, key_len);
+   if (ret != 0)
+   goto set_algo_key_fail;
+
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   hw->rss_info.hash_algo = 
hns3_hash_func_map[rss_conf->algorithm];
+   if (key != NULL)
memcpy(hw->rss_info.key, key, hw->rss_key_size);
-   }
hw->rss_info.rss_hf = rss_hf;
rte_spinlock_unlock(&hw->lock);
  
@@ -769,7 +769,13 @@ int

  hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
   struct rte_eth_rss_conf *rss_conf)
  {
+   const uint8_t hash_func_map[] = {
+   [HNS3_RSS_HASH_ALGO_TOEPLITZ] = RTE_ETH_HASH_FUNCTION_TOEPLITZ,
+   [HNS3_RSS_HASH_ALGO_SIMPLE] = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR,
+   [HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP] = 
RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
+   };
struct hns3_adapter *hns = dev->data->dev_private;
+   uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0};
struct hns3_hw *hw = &hns->hw;
uint8_t hash_algo;
int ret;
@@ -777,26 +783,27 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
rte_spinlock_lock(&hw->lock);
ret = hns3_rss_hash_get_rss_hf(hw, &rss_conf->rss_hf);
if (ret != 0) {
+   rte_spinlock_unlock(&hw->lock);
hns3_err(hw, "obtain hash tuples failed, ret = %d", ret);
-   goto out;
+   return ret;
+   }
+
+   ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_key, hw->rss_key_size);
+   if (ret != 0) {
+   rte_spinlock_unlock(&hw->lock);
+   hns3_err(hw, "obtain hash algo and key failed, ret = %d", ret);
+   return ret;
}
+   rte_spinlock_unlock(&hw->lock);
  
-	/* Get the RSS Key required by the user */

+   /* Get the RSS Key if user required. */
if (rss_conf->rss_key && rss_conf->rss_key_len >= hw->rss_key_size) {
-   ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_conf->rss_key,
-   hw->rss_key_size);
-   if (ret != 0) {
-   hns3_err(hw, "obtain hash algo and key failed, ret = 
%d",
-ret);
-   goto out;
-   }
+   memcpy(rss_conf->rss_key, rss_key, hw->rss_key_size);
rss_conf->rss_key_len = hw->rss_key_size;
}
+   rss_conf->algorithm = hash_func_map[hash_algo];
  
-out:

-   rte_spinlock_unlock(&hw->lock);
-
-   return ret;
+   return 0;
  }
  
  /*



.


Re: [PATCH v5 36/40] net/hns3: support setting and querying RSS hash function

2023-10-11 Thread Jie Hai

On 2023/10/12 10:23, fengchengwen wrote:

The new algorithm (RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT) should treat 
as Not Support.

With above fix
Acked-by: Chengwen Feng 


Actually, the new algorithm is not supported.
see hns3_update_rss_algo_key().

if (modify_algo && hash_func >= RTE_DIM(hns3_hash_func_map)) {
hns3_err(hw, "hash func (%u) is unsupported.", hash_func);
return -ENOTSUP;
}


On 2023/10/11 17:28, Jie Hai wrote:

From: Huisong Li 

Support setting and querying RSS hash function by ethdev ops.

Signed-off-by: Huisong Li 
Signed-off-by: Dongdong Liu 
---
  drivers/net/hns3/hns3_rss.c | 47 +
  1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 6126512bd780..010a759f23d9 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -646,14 +646,14 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
if (ret)
goto set_tuple_fail;
  
-	if (key) {

-   ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo,
-   key, hw->rss_key_size);
-   if (ret)
-   goto set_algo_key_fail;
-   /* Update the shadow RSS key with user specified */
+   ret = hns3_update_rss_algo_key(hw, rss_conf->algorithm, key, key_len);
+   if (ret != 0)
+   goto set_algo_key_fail;
+
+   if (rss_conf->algorithm != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   hw->rss_info.hash_algo = 
hns3_hash_func_map[rss_conf->algorithm];
+   if (key != NULL)
memcpy(hw->rss_info.key, key, hw->rss_key_size);
-   }
hw->rss_info.rss_hf = rss_hf;
rte_spinlock_unlock(&hw->lock);
  
@@ -769,7 +769,13 @@ int

  hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
   struct rte_eth_rss_conf *rss_conf)
  {
+   const uint8_t hash_func_map[] = {
+   [HNS3_RSS_HASH_ALGO_TOEPLITZ] = RTE_ETH_HASH_FUNCTION_TOEPLITZ,
+   [HNS3_RSS_HASH_ALGO_SIMPLE] = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR,
+   [HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP] = 
RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
+   };
struct hns3_adapter *hns = dev->data->dev_private;
+   uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0};
struct hns3_hw *hw = &hns->hw;
uint8_t hash_algo;
int ret;
@@ -777,26 +783,27 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
rte_spinlock_lock(&hw->lock);
ret = hns3_rss_hash_get_rss_hf(hw, &rss_conf->rss_hf);
if (ret != 0) {
+   rte_spinlock_unlock(&hw->lock);
hns3_err(hw, "obtain hash tuples failed, ret = %d", ret);
-   goto out;
+   return ret;
+   }
+
+   ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_key, hw->rss_key_size);
+   if (ret != 0) {
+   rte_spinlock_unlock(&hw->lock);
+   hns3_err(hw, "obtain hash algo and key failed, ret = %d", ret);
+   return ret;
}
+   rte_spinlock_unlock(&hw->lock);
  
-	/* Get the RSS Key required by the user */

+   /* Get the RSS Key if user required. */
if (rss_conf->rss_key && rss_conf->rss_key_len >= hw->rss_key_size) {
-   ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_conf->rss_key,
-   hw->rss_key_size);
-   if (ret != 0) {
-   hns3_err(hw, "obtain hash algo and key failed, ret = 
%d",
-ret);
-   goto out;
-   }
+   memcpy(rss_conf->rss_key, rss_key, hw->rss_key_size);
rss_conf->rss_key_len = hw->rss_key_size;
}
+   rss_conf->algorithm = hash_func_map[hash_algo];
  
-out:

-   rte_spinlock_unlock(&hw->lock);
-
-   return ret;
+   return 0;
  }
  
  /*



.


Re: [PATCH v5 38/40] app/proc-info: adjust the display format of RSS info

2023-10-11 Thread Jie Hai

On 2023/10/12 10:01, fengchengwen wrote:

Hi HaiJie,

On 2023/10/11 17:28, Jie Hai wrote:

This patch splits the length and value of RSS key into two parts,
removes spaces between RSS keys, and adds line breaks between RSS
key and RSS hf.

Before the adjustment, RSS info is shown as:
   - RSS
  -- RSS len 40 key (hex): 6d 5a 56 da 25 5b e c2 41 67 \
 25 3d 43 a3 8f b0 d0 ca 2b cb ae 7b 30 b4 77 cb 2d \
 a3 80 30 f2 c 6a 42 b7 3b be ac 1 fa -- hf 0x0
and after:
   - RSS info
  -- key len : 40
  -- key (hex) : 6d5a56da255b0ec24167253d43a38fb0d0c \
a2bcbae7b30b477cb2da38030f20c6a42b73bbeac01fa
  -- hash function : 0x0


How about convert to string? e.g. hash function: SIMPLE_XOR


Sorry for the misunderstanding.
"hash function" is for rss_hf, not the RSS hash algorithm.


Fixes: 8a37f37fc243 ("app/procinfo: add --show-port")
Cc: sta...@dpdk.org

Signed-off-by: Jie Hai 
Signed-off-by: Dongdong Liu 
Acked-by: Reshma Pattan
---
  app/proc-info/main.c | 9 +
  1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 4509b3c16e36..e98352118db1 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -1178,12 +1178,13 @@ show_port(void)
rss_conf.rss_key_len = dev_info.hash_key_size;
ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
if (ret == 0) {
-   printf("  - RSS\n");
-   printf("\t  -- RSS len %u key (hex):",
+   printf("  - RSS info\n");
+   printf("\t  -- key len : %u\n",
rss_conf.rss_key_len);
+   printf("\t  -- key (hex) : ");
for (k = 0; k < rss_conf.rss_key_len; k++)
-   printf(" %x", rss_conf.rss_key[k]);
-   printf("\t  -- hf 0x%"PRIx64"\n",
+   printf("%02x", rss_conf.rss_key[k]);
+   printf("\n\t  -- hash function : 0x%"PRIx64"\n",
rss_conf.rss_hf);


Suggest %d other PRIx64

"hash function" is for rss_hf, not the RSS hash algorithm.
And each bit of it is meaningful, so hexadecimal is used.



}
  


.


Re: [PATCH v5 39/40] app/proc-info: support querying RSS hash algorithm

2023-10-11 Thread Jie Hai

On 2023/10/12 10:05, fengchengwen wrote:

Suggest add one new API for get hash_algo_name. e.g. rte_eth_get_rss_algo_name()


Thanks, that's better for reuse, will change it in next version.

On 2023/10/11 17:28, Jie Hai wrote:

Display RSS hash algorithm with command show-port as below.
   - RSS info
  -- hash algorithm : toeplitz

Signed-off-by: Jie Hai 
Signed-off-by: Dongdong Liu 
Acked-by: Reshma Pattan 
---
  app/proc-info/main.c | 10 ++
  1 file changed, 10 insertions(+)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index e98352118db1..43f264848a6f 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -153,6 +153,14 @@ static struct desc_param rx_desc_param;
  static struct desc_param tx_desc_param;
  
  #define RSS_HASH_KEY_SIZE 64

+static const char * const rss_hash_algos[] = {
+   [RTE_ETH_HASH_FUNCTION_SIMPLE_XOR] = "simple_xor",
+   [RTE_ETH_HASH_FUNCTION_TOEPLITZ] = "toeplitz",
+   [RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ] = "symmetric_toeplitz",
+   [RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT] = 
"symmetric_toeplitz_sort",
+   [RTE_ETH_HASH_FUNCTION_DEFAULT] = "default",
+   [RTE_ETH_HASH_FUNCTION_MAX] = "unknown"
+};
  
  /* display usage */

  static void
@@ -1186,6 +1194,8 @@ show_port(void)
printf("%02x", rss_conf.rss_key[k]);
printf("\n\t  -- hash function : 0x%"PRIx64"\n",
rss_conf.rss_hf);
+   printf("\t  -- hash algorithm : %s\n",
+   rss_hash_algos[rss_conf.algorithm]);
}
  
  #ifdef RTE_LIB_SECURITY



.


[PATCH 1/4] net/hns3: fix a typo

2023-10-17 Thread Jie Hai
This patch fixes a typo.

Fixes: c09c7847d892 ("net/hns3: support traffic management")
Cc: sta...@dpdk.org

Signed-off-by: Jie Hai 
---
 drivers/net/hns3/hns3_tm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hns3/hns3_tm.c b/drivers/net/hns3/hns3_tm.c
index 67402a700f46..d9691640140b 100644
--- a/drivers/net/hns3/hns3_tm.c
+++ b/drivers/net/hns3/hns3_tm.c
@@ -739,7 +739,7 @@ hns3_tm_node_type_get(struct rte_eth_dev *dev, uint32_t 
node_id,
 }
 
 static void
-hns3_tm_nonleaf_level_capsbilities_get(struct rte_eth_dev *dev,
+hns3_tm_nonleaf_level_capabilities_get(struct rte_eth_dev *dev,
   uint32_t level_id,
   struct rte_tm_level_capabilities *cap)
 {
@@ -818,7 +818,7 @@ hns3_tm_level_capabilities_get(struct rte_eth_dev *dev,
memset(cap, 0, sizeof(struct rte_tm_level_capabilities));
 
if (level_id != HNS3_TM_NODE_LEVEL_QUEUE)
-   hns3_tm_nonleaf_level_capsbilities_get(dev, level_id, cap);
+   hns3_tm_nonleaf_level_capabilities_get(dev, level_id, cap);
else
hns3_tm_leaf_level_capabilities_get(dev, cap);
 
-- 
2.30.0



[PATCH 0/4] add telemetry commands for TM capabilities

2023-10-17 Thread Jie Hai
This patch adds telemetry commands for TM capabilities and make some
bufix for hns3 driver.

Jie Hai (4):
  net/hns3: fix a typo
  ethdev: add telemetry command for TM capabilities
  ethdev: add telemetry command for TM level capabilities
  ethdev: add telemetry command for TM node capabilities

 drivers/net/hns3/hns3_tm.c|   4 +-
 lib/ethdev/rte_ethdev_telemetry.c | 380 ++
 2 files changed, 382 insertions(+), 2 deletions(-)

-- 
2.30.0



[PATCH 2/4] ethdev: add telemetry command for TM capabilities

2023-10-17 Thread Jie Hai
This patch adds a telemetry command for traffic management
capabilities. An example usage is shown below:

--> /ethdev/tm_capability,0
{
  "/ethdev/tm_capability": {
"n_nodes_max": 265,
"n_levels_max": 3,
"non_leaf_nodes_identical": 1,
"leaf_nodes_identical": 1,
"shaper_n_max": 9,
"shaper_private_n_max": 9,
"shaper_private_dual_rate_n_max": 0,
"shaper_private_rate_min": 0,
"shaper_private_rate_max": 250,
"shaper_private_packet_mode_supported": 0,
"shaper_private_byte_mode_supported": 0,
"shaper_shared_n_max": 0,
"shaper_shared_n_nodes_per_shaper_max": 0,
"shaper_shared_n_shapers_per_node_max": 0,
"shaper_share_dual_rate_n_max": 0,
"shaper_shared_rate_min": 0,
"shaper_shared_rate_max": 0,
"shaper_shared_packet_mode_supported": 0,
"shaper_shared_byte_mode_supported": 0,
"shaper_pkt_length_adjust_min": 20,
"shaper_pkt_length_adjust_max": 24,
"sched_n_children_max": 256,
"sched_sp_n_priorities_max": 1,
"sched_wfq_n_children_per_group_max": 0,
"sched_wfq_n_groups_max": 0,
"sched_wfq_weight_max": 1,
"sched_wfq_packet_mode_supported": 0,
"sched_wfq_byte_mode_supported": 0,
"cman_wred_packet_mode_supported": 0,
"cman_wred_byte_mode_supported": 0,
"cman_head_drop_supported": 0,
"cman_wred_context_n_max": 0,
"cman_wred_context_private_n_max": 0,
"cman_wred_context_shared_n_max": 0,
"cman_wred_context_shared_n_nodes_per_context_max": 0,
"cman_wred_context_shared_n_contexts_per_node_max": 0,
"dynamic_update": "0x0",
"stats_mask": "0x0"
  }
}

Signed-off-by: Jie Hai 
---
 lib/ethdev/rte_ethdev_telemetry.c | 108 ++
 1 file changed, 108 insertions(+)

diff --git a/lib/ethdev/rte_ethdev_telemetry.c 
b/lib/ethdev/rte_ethdev_telemetry.c
index f246a03e2966..02d23486806e 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -11,6 +11,7 @@
 #include "rte_ethdev.h"
 #include "ethdev_driver.h"
 #include "sff_telemetry.h"
+#include "rte_tm.h"
 
 static const struct {
uint32_t capa;
@@ -1021,6 +1022,111 @@ eth_dev_handle_port_vlan(const char *cmd __rte_unused,
return eth_dev_add_vlan_id(port_id, d);
 }
 
+static void
+eth_dev_add_tm_caps(struct rte_tel_data *d, struct rte_tm_capabilities *cap)
+{
+   rte_tel_data_add_dict_uint(d, "n_nodes_max", cap->n_nodes_max);
+   rte_tel_data_add_dict_uint(d, "n_levels_max", cap->n_levels_max);
+   rte_tel_data_add_dict_int(d, "non_leaf_nodes_identical",
+   cap->non_leaf_nodes_identical);
+   rte_tel_data_add_dict_int(d, "leaf_nodes_identical",
+   cap->leaf_nodes_identical);
+   rte_tel_data_add_dict_uint(d, "shaper_n_max", cap->shaper_n_max);
+   rte_tel_data_add_dict_uint(d, "shaper_private_n_max",
+   cap->shaper_private_n_max);
+   rte_tel_data_add_dict_int(d, "shaper_private_dual_rate_n_max",
+   cap->shaper_private_dual_rate_n_max);
+   rte_tel_data_add_dict_uint(d, "shaper_private_rate_min",
+   cap->shaper_private_rate_min);
+   rte_tel_data_add_dict_uint(d, "shaper_private_rate_max",
+   cap->shaper_private_rate_max);
+   rte_tel_data_add_dict_int(d, "shaper_private_packet_mode_supported",
+   cap->shaper_private_packet_mode_supported);
+   rte_tel_data_add_dict_int(d, "shaper_private_byte_mode_supported",
+   cap->shaper_private_byte_mode_supported);
+   rte_tel_data_add_dict_uint(d, "shaper_shared_n_max",
+   cap->shaper_shared_n_max);
+   rte_tel_data_add_dict_uint(d, "shaper_shared_n_nodes_per_shaper_max",
+   cap->shaper_shared_n_nodes_per_shaper_max);
+   rte_tel_data_add_dict_uint(d, "shaper_shared_n_shapers_per_node_max",
+   cap->shaper_shared_n_shapers_per_node_max);
+   rte_tel_data_add_dict_uint(d, "shaper_share_dual_rate_n_max",
+   cap->shaper_shared_dual_rate_n_max);
+   rte_tel_data_add_dict_uint(d, "shaper_shared_rate_min",
+   cap->shaper_shared_rate_min);
+   rte_tel_data_add_dict_uint(d, "shaper_shared_rate_max",
+   cap->shaper_shared_rate_max);
+   rte_tel_data_add_dict_int(d, "shaper_sha

[PATCH 3/4] ethdev: add telemetry command for TM level capabilities

2023-10-17 Thread Jie Hai
This patch adds a telemetry command for traffic management level
capabilities, using (port_id,level_id) as parameters. An
example usage is shown below:

--> /ethdev/tm_level_capability,0,0
{
  "/ethdev/tm_level_capability": {
"n_nodes_max": 1,
"n_nodes_nonleaf_max": 1,
"n_nodes_leaf_max": 0,
"non_leaf_nodes_identical": 1,
"leaf_nodes_identical": 1,
"nonleaf_cap": {
  "shaper_private_supported": 1,
  "shaper_private_dual_rate_supported": 0,
  "shaper_private_rate_min": 0,
  "shaper_private_rate_max": 250,
  "shaper_private_packet_mode_supported": 0,
  "shaper_private_byte_mode_supported": 0,
  "shaper_shared_n_max": 0,
  "shaper_shared_packet_mode_supported": 0,
  "shaper_shared_byte_mode_supported": 0,
  "sched_n_children_max": 8,
  "sched_sp_n_priorities_max": 1,
  "sched_wfq_n_children_per_group_max": 0,
  "sched_wfq_n_groups_max": 0,
  "sched_wfq_weight_max": 1,
  "sched_wfq_packet_mode_supported": 0,
  "sched_wfq_byte_mode_supported": 0,
  "stats_mask": "0x0"
},
"leaf_cap": {
  "shaper_private_supported": 1,
  "shaper_private_dual_rate_supported": 0,
  "shaper_private_rate_min": 0,
  "shaper_private_rate_max": 250,
  "shaper_private_packet_mode_supported": 0,
  "shaper_private_byte_mode_supported": 0,
  "shaper_shared_n_max": 0,
  "shaper_shared_packet_mode_supported": 0,
  "shaper_shared_byte_mode_supported": 0,
  "cman_wred_packet_mode_supported": 8,
  "cman_wred_byte_mode_supported": 1,
  "cman_head_drop_supported": 0,
  "cman_wred_context_private_supported": 0,
  "cman_wred_context_shared_n_max": 1,
  "stats_mask": "0x0"
}
  }
}

Signed-off-by: Jie Hai 
---
 lib/ethdev/rte_ethdev_telemetry.c | 168 ++
 1 file changed, 168 insertions(+)

diff --git a/lib/ethdev/rte_ethdev_telemetry.c 
b/lib/ethdev/rte_ethdev_telemetry.c
index 02d23486806e..4a56685be426 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -1127,6 +1127,172 @@ eth_dev_handle_port_tm_caps(const char *cmd 
__rte_unused,
return 0;
 }
 
+static void
+eth_dev_add_tm_level_basic_caps(struct rte_tel_data *d,
+   struct rte_tm_level_capabilities *cap)
+{
+   rte_tel_data_add_dict_uint(d, "n_nodes_max", cap->n_nodes_max);
+   rte_tel_data_add_dict_uint(d, "n_nodes_nonleaf_max",
+   cap->n_nodes_nonleaf_max);
+   rte_tel_data_add_dict_uint(d, "n_nodes_leaf_max", 
cap->n_nodes_leaf_max);
+   rte_tel_data_add_dict_int(d, "non_leaf_nodes_identical",
+   cap->non_leaf_nodes_identical);
+   rte_tel_data_add_dict_int(d, "leaf_nodes_identical",
+   cap->leaf_nodes_identical);
+}
+
+static void
+eth_dev_add_tm_level_nonleaf_caps(struct rte_tel_data *nonleaf,
+   struct rte_tm_level_capabilities *cap)
+{
+   rte_tel_data_add_dict_int(nonleaf, "shaper_private_supported",
+   cap->nonleaf.shaper_private_supported);
+   rte_tel_data_add_dict_int(nonleaf, "shaper_private_dual_rate_supported",
+   cap->nonleaf.shaper_private_dual_rate_supported);
+   rte_tel_data_add_dict_uint(nonleaf, "shaper_private_rate_min",
+   cap->nonleaf.shaper_private_rate_min);
+   rte_tel_data_add_dict_uint(nonleaf, "shaper_private_rate_max",
+   cap->nonleaf.shaper_private_rate_max);
+   rte_tel_data_add_dict_int(nonleaf, 
"shaper_private_packet_mode_supported",
+   cap->nonleaf.shaper_private_packet_mode_supported);
+   rte_tel_data_add_dict_int(nonleaf, "shaper_private_byte_mode_supported",
+   cap->nonleaf.shaper_private_byte_mode_supported);
+   rte_tel_data_add_dict_uint(nonleaf, "shaper_shared_n_max",
+   cap->nonleaf.shaper_shared_n_max);
+   rte_tel_data_add_dict_int(nonleaf, 
"shaper_shared_packet_mode_supported",
+   cap->nonleaf.shaper_shared_packet_mode_supported);
+   rte_tel_data_add_dict_int(nonleaf, "shaper_shared_byte_mode_supported",
+   cap->nonleaf.shaper_shared_byte_mode_supported);
+   rte_tel_data_add_dict_uint(nonleaf, "sched_n_children_max",
+   cap->nonleaf.sched_n_children_max);
+   rte_tel_data_add_dict_uint(nonleaf, "sched_sp_n_priorities_max&quo

[PATCH 4/4] ethdev: add telemetry command for TM node capabilities

2023-10-17 Thread Jie Hai
This patch adds a telemetry command for traffic management node
capabilities, using (port_id, node_id) as parameters. An example
usage is shown below:

--> /ethdev/tm_node_capability,0,264
{
  "/ethdev/tm_node_capability": {
"shaper_private_supported": 1,
"shaper_private_dual_rate_supported": 0,
"shaper_private_rate_min": 0,
"shaper_private_rate_max": 250,
"shaper_private_packet_mode_supported": 0,
"shaper_private_byte_mode_supported": 0,
"shaper_shared_n_max": 0,
"shaper_shared_packet_mode_supported": 0,
"shaper_shared_byte_mode_supported": 0,
"stats_mask": "0x0",
"node_type": "nonleaf",
"children_max": 8,
"priorities_max": 1,
"sched_wfq_n_children_per_group_max": 0,
"sched_wfq_n_groups_max": 0,
"sched_wfq_weight_max": 1,
"sched_wfq_packet_mode_supported": 0,
"sched_wfq_byte_mode_supported": 0
  }
}

Signed-off-by: Jie Hai 
---
 lib/ethdev/rte_ethdev_telemetry.c | 104 ++
 1 file changed, 104 insertions(+)

diff --git a/lib/ethdev/rte_ethdev_telemetry.c 
b/lib/ethdev/rte_ethdev_telemetry.c
index 4a56685be426..b01028ce9b60 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -1293,6 +1293,108 @@ eth_dev_handle_port_tm_level_caps(const char *cmd 
__rte_unused,
return 0;
 }
 
+static void
+eth_dev_add_tm_node_basic_caps(struct rte_tel_data *node_data,
+   struct rte_tm_node_capabilities *capnode)
+{
+   rte_tel_data_add_dict_int(node_data, "shaper_private_supported",
+   capnode->shaper_private_supported);
+   rte_tel_data_add_dict_int(node_data, 
"shaper_private_dual_rate_supported",
+   capnode->shaper_private_dual_rate_supported);
+   rte_tel_data_add_dict_uint(node_data, "shaper_private_rate_min",
+   capnode->shaper_private_rate_min);
+   rte_tel_data_add_dict_uint(node_data, "shaper_private_rate_max",
+   capnode->shaper_private_rate_max);
+   rte_tel_data_add_dict_int(node_data, 
"shaper_private_packet_mode_supported",
+   capnode->shaper_private_packet_mode_supported);
+   rte_tel_data_add_dict_int(node_data, 
"shaper_private_byte_mode_supported",
+   capnode->shaper_private_byte_mode_supported);
+   rte_tel_data_add_dict_uint(node_data, "shaper_shared_n_max",
+   capnode->shaper_shared_n_max);
+   rte_tel_data_add_dict_int(node_data, 
"shaper_shared_packet_mode_supported",
+   capnode->shaper_shared_packet_mode_supported);
+   rte_tel_data_add_dict_int(node_data, 
"shaper_shared_byte_mode_supported",
+   capnode->shaper_shared_byte_mode_supported);
+   rte_tel_data_add_dict_uint_hex(node_data, "stats_mask",
+   capnode->stats_mask, 0);
+}
+
+static void
+eth_dev_add_tm_type_node_caps(struct rte_tel_data *d, int is_leaf,
+   struct rte_tm_node_capabilities *cap)
+{
+   rte_tel_data_add_dict_string(d, "node_type",
+   is_leaf == 0 ? "nonleaf" : "leaf");
+   if (is_leaf == 0) {
+   rte_tel_data_add_dict_uint(d, "children_max",
+   cap->nonleaf.sched_n_children_max);
+   rte_tel_data_add_dict_uint(d, "priorities_max",
+   cap->nonleaf.sched_sp_n_priorities_max);
+   rte_tel_data_add_dict_uint(d, 
"sched_wfq_n_children_per_group_max",
+   cap->nonleaf.sched_wfq_n_children_per_group_max);
+   rte_tel_data_add_dict_uint(d, "sched_wfq_n_groups_max",
+   cap->nonleaf.sched_wfq_n_groups_max);
+   rte_tel_data_add_dict_uint(d, "sched_wfq_weight_max",
+   cap->nonleaf.sched_wfq_weight_max);
+   rte_tel_data_add_dict_int(d, "sched_wfq_packet_mode_supported",
+   cap->nonleaf.sched_wfq_packet_mode_supported);
+   rte_tel_data_add_dict_int(d, "sched_wfq_byte_mode_supported",
+   cap->nonleaf.sched_wfq_byte_mode_supported);
+   } else {
+   rte_tel_data_add_dict_int(d, "cman_wred_packet_mode_supported",
+   cap->leaf.cman_wred_packet_mode_supported);
+   rte_tel_data_add_dict_int(d, "cman_wred_byte_mode_supported",
+   cap->leaf.cman_wred_byte_mode_supported);
+   rte_tel_data_add_dict_int(d, "cman_head_drop_supported",
+   cap-&g

Re: [PATCH v5 02/40] ethdev: support setting and querying RSS algorithm

2023-10-24 Thread Jie Hai

On 2023/10/12 10:21, fengchengwen wrote:



On 2023/10/12 1:39, Stephen Hemminger wrote:

On Wed, 11 Oct 2023 17:27:27 +0800
Jie Hai  wrote:


Currently, rte_eth_rss_conf supports configuring and querying
RSS hash functions, rss key and it's length, but not RSS hash
algorithm.

The structure ``rte_eth_rss_conf`` is extended by adding a new
field "algorithm". This represents the RSS algorithms to apply.
The following API will be affected:
- rte_eth_dev_configure
- rte_eth_dev_rss_hash_update
- rte_eth_dev_rss_hash_conf_get

If the value of "algorithm" used for configuration is a gibberish
value, report the error and return. Do the same for
rte_eth_dev_rss_hash_update and rte_eth_dev_configure.

To check whether the drivers report valid "algorithm", it is set
to default value before querying.

Signed-off-by: Jie Hai 
Signed-off-by: Dongdong Liu 
---
  doc/guides/rel_notes/release_23_11.rst |  2 ++
  lib/ethdev/rte_ethdev.c| 17 
  lib/ethdev/rte_ethdev.h| 27 +
  lib/ethdev/rte_flow.c  |  1 -
  lib/ethdev/rte_flow.h  | 28 ++
  5 files changed, 48 insertions(+), 27 deletions(-)

diff --git a/doc/guides/rel_notes/release_23_11.rst 
b/doc/guides/rel_notes/release_23_11.rst
index e13d57728071..92a445ab2ed3 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -197,6 +197,8 @@ ABI Changes
fields, to move ``rxq`` and ``txq`` fields, to change the size of
``reserved1`` and ``reserved2`` fields.
  
+* ethdev: Added "algorithm" field to ``rte_eth_rss_conf`` structure for RSS

+  hash algorithm.
  
  Known Issues

  
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 18a4b950b184..2eda1b8072e5 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -1464,6 +1464,14 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t 
nb_rx_q, uint16_t nb_tx_q,
goto rollback;
}
  
+	if (dev_conf->rx_adv_conf.rss_conf.algorithm >= RTE_ETH_HASH_FUNCTION_MAX) {

+   RTE_ETHDEV_LOG(ERR,
+   "Ethdev port_id=%u invalid RSS algorithm: 
0x%"PRIx64"\n",
+   port_id, dev_conf->rx_adv_conf.rss_conf.algorithm);
+   ret = -EINVAL;
+   goto rollback;
+   }
+


Rather than having every driver check the algorithm, why not handle this like
other features in DPDK (which may mean API/ABI changes).

Add a field rss_algo_capa which is bit field of available RSS functions.
Then the check for algorithm can be done in generic code. There a couple
of reserved fields that could be used.


+1 for add a field

But there are two ways to config rss: ethdev-ops, ethdev-rteflow-ops, should 
distinguish them ? or just define for ethdev-ops ?


The rte_flow API does not distinguish RSS rule and FDIR rule,
the actual implementation of rss configuration depends on drivers.
I think if we had this "rss_algo_capa ", it can be just for ethdev-ops 
for ethdev API level use.


It would mean updating all the drivers once with the capa field but
would provide way for application to know what fields are possible.

It has proved to be a problem in later ABI changes if a maximum value
is exposed. I.e don't expose RTE_ETH_HASH_FUNCTION_MAX.


+1



.


.


Re: [PATCH v7 0/3] add telemetry cmds for ring

2023-10-24 Thread Jie Hai



Hi, Thomas,

Kindly ping for review.

Thanks,
Jie Hai
On 2023/7/4 17:04, Jie Hai wrote:

This patch set supports telemetry cmd to list rings and dump information
of a ring by its name.

v1->v2:
1. Add space after "switch".
2. Fix wrong strlen parameter.

v2->v3:
1. Remove prefix "rte_" for static function.
2. Add Acked-by Konstantin Ananyev for PATCH 1.
3. Introduce functions to return strings instead copy strings.
4. Check pointer to memzone of ring.
5. Remove redundant variable.
6. Hold lock when access ring data.

v3->v4:
1. Update changelog according to reviews of Honnappa Nagarahalli.
2. Add Reviewed-by Honnappa Nagarahalli.
3. Correct grammar in help information.
4. Correct spell warning on "te" reported by checkpatch.pl.
5. Use ring_walk() to query ring info instead of rte_ring_lookup().
6. Fix that type definition the flag field of rte_ring does not match the usage.
7. Use rte_tel_data_add_dict_uint_hex instead of rte_tel_data_add_dict_u64
for mask and flags.

v4->v5:
1. Add Acked-by Konstantin Ananyev and Chengwen Feng.
2. Add ABI change explanation for commit message of patch 1/3.

v5->v6:
1. Add Acked-by Morten Brørup.
2. Fix incorrect reference of commit.

v6->v7:
1. Remove prod/consumer head/tail info.

Jie Hai (3):
   ring: fix unmatched type definition and usage
   ring: add telemetry cmd to list rings
   ring: add telemetry cmd for ring info

  lib/ring/meson.build |   1 +
  lib/ring/rte_ring.c  | 135 +++
  lib/ring/rte_ring_core.h |   2 +-
  3 files changed, 137 insertions(+), 1 deletion(-)



Re: [PATCH 0/4] add telemetry commands for TM capabilities

2023-10-24 Thread Jie Hai

Hi, all maintainers,

Kindly ping for review.

Thanks,
Jie Hai

On 2023/10/18 9:39, Jie Hai wrote:

This patch adds telemetry commands for TM capabilities and make some
bufix for hns3 driver.

Jie Hai (4):
   net/hns3: fix a typo
   ethdev: add telemetry command for TM capabilities
   ethdev: add telemetry command for TM level capabilities
   ethdev: add telemetry command for TM node capabilities

  drivers/net/hns3/hns3_tm.c|   4 +-
  lib/ethdev/rte_ethdev_telemetry.c | 380 ++
  2 files changed, 382 insertions(+), 2 deletions(-)



[PATCH] app/testpmd: fix testpmd receive jumbo frame packets

2022-10-24 Thread Jie Wang
For NIC I40E_10G-10G_BASE_T_X722, when testpmd is configured with
link speed, it cannot receive jumbo frame packets.

Because it has changed the link status of the ports if it was
configured with link speed.

When exiting testpmd that it automatically stops packet forwarding
and stops all the ports. But it doesn't update the link status of the
ports. If stop the ports first that it will update the link status.

This patch fix the error that testpmd will update the link status of
the ports when it exits.

Fixes: d3a274ce9dee ("app/testpmd: handle SIGINT and SIGTERM")
Fixes: 284c908cc588 ("app/testpmd: request device removal interrupt")
Cc: sta...@dpdk.org

Signed-off-by: Jie Wang 
---
 app/test-pmd/testpmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 97adafacd0..c348a3f328 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3548,7 +3548,7 @@ pmd_test_exit(void)
}
 #endif
if (ports != NULL) {
-   no_link_check = 1;
+   no_link_check = 0;
RTE_ETH_FOREACH_DEV(pt_id) {
printf("\nStopping port %d...\n", pt_id);
fflush(stdout);
@@ -3675,7 +3675,7 @@ rmv_port_callback(void *arg)
need_to_start = 1;
stop_packet_forwarding();
}
-   no_link_check = 1;
+   no_link_check = 0;
stop_port(port_id);
no_link_check = org_no_link_check;
 
-- 
2.25.1



[PATCH 0/2] add ring telemetry cmds

2023-01-17 Thread Jie Hai
This patch set supports telemetry list rings and dump info of a ring
by its name.

Jie Hai (2):
  ring: add ring list telemetry cmd
  ring: add ring info telemetry cmd

 lib/ring/meson.build |   1 +
 lib/ring/rte_ring.c  | 128 +++
 2 files changed, 129 insertions(+)

-- 
2.33.0



[PATCH 1/2] ring: add ring list telemetry cmd

2023-01-17 Thread Jie Hai
This patch supports the list of rings with telemetry cmd.
An example using this command is shown below:

--> /ring/list
{
  "/ring/list": [
"HT_:7d:00.2",
"MP_mb_pool_0"
  ]
}

Signed-off-by: Jie Hai 
---
 lib/ring/meson.build |  1 +
 lib/ring/rte_ring.c  | 40 
 2 files changed, 41 insertions(+)

diff --git a/lib/ring/meson.build b/lib/ring/meson.build
index c20685c689ac..7fca958ed7fa 100644
--- a/lib/ring/meson.build
+++ b/lib/ring/meson.build
@@ -18,3 +18,4 @@ indirect_headers += files (
 'rte_ring_rts.h',
 'rte_ring_rts_elem_pvt.h',
 )
+deps += ['telemetry']
diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index cddaf6b2876f..bb1dafd4d1ca 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "rte_ring.h"
 #include "rte_ring_elem.h"
@@ -419,3 +420,42 @@ rte_ring_lookup(const char *name)
 
return r;
 }
+
+static void
+rte_ring_walk(void (*func)(struct rte_ring *, void *), void *arg)
+{
+   struct rte_ring_list *ring_list;
+   struct rte_tailq_entry *te;
+
+   ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
+   rte_mcfg_tailq_read_lock();
+
+   TAILQ_FOREACH(te, ring_list, next) {
+   (*func)((struct rte_ring *) te->data, arg);
+   }
+
+   rte_mcfg_tailq_read_unlock();
+}
+
+static void
+ring_list_cb(struct rte_ring *r, void *arg)
+{
+   struct rte_tel_data *d = (struct rte_tel_data *)arg;
+
+   rte_tel_data_add_array_string(d, r->name);
+}
+
+static int
+ring_handle_list(const char *cmd __rte_unused,
+   const char *params __rte_unused, struct rte_tel_data *d)
+{
+   rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+   rte_ring_walk(ring_list_cb, d);
+   return 0;
+}
+
+RTE_INIT(ring_init_telemetry)
+{
+   rte_telemetry_register_cmd("/ring/list", ring_handle_list,
+   "Returns list of available ring. Takes no parameters");
+}
-- 
2.33.0



[PATCH 2/2] ring: add ring info telemetry cmd

2023-01-17 Thread Jie Hai
This patch supports dump of the info of ring by its name.
An example using this command is shown below:

--> /ring/info,MP_mb_pool_0
{
  "/ring/info": {
"name": "MP_mb_pool_0",
"socket": 0,
"flags": 0,
"producer_type": "MP",
"consumer_type": "MC",
"size": 262144,
"mask": 262143,
"capacity": 262143,
"used_count": 147173,
"consumer_tail": 8283,
"consumer_head": 8283,
"producer_tail": 155456,
"producer_head": 155456,
"mz_name": "RG_MP_mb_pool_0",
"mz_len": 2097920,
"mz_hugepage_sz": 1073741824,
"mz_socket_id": 0,
"mz_flags": 0
  }
}

Signed-off-by: Jie Hai 
---
 lib/ring/rte_ring.c | 88 +
 1 file changed, 88 insertions(+)

diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index bb1dafd4d1ca..effdd1fcdba6 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -45,6 +45,9 @@ EAL_REGISTER_TAILQ(rte_ring_tailq)
 /* by default set head/tail distance as 1/8 of ring capacity */
 #define HTD_MAX_DEF8
 
+/* size of name of producer/consumer synchronization modes */
+#define SYNC_MODE_NAME_SZ  16
+
 /* return the size of memory occupied by a ring */
 ssize_t
 rte_ring_get_memsize_elem(unsigned int esize, unsigned int count)
@@ -454,8 +457,93 @@ ring_handle_list(const char *cmd __rte_unused,
return 0;
 }
 
+static void
+ring_get_sync_name_by_type(struct rte_ring *r, char *prod, char *cons)
+{
+   switch(r->prod.sync_type) {
+   case RTE_RING_SYNC_MT:
+   strcpy(prod, "MP");
+   break;
+   case RTE_RING_SYNC_ST:
+   strcpy(prod, "SP");
+   break;
+   case RTE_RING_SYNC_MT_RTS:
+   strcpy(prod, "MP_RTS");
+   break;
+   case RTE_RING_SYNC_MT_HTS:
+   strcpy(prod, "MP_HTS");
+   break;
+   default:
+   strcpy(prod, "Unknown");
+   }
+
+   switch(r->cons.sync_type) {
+   case RTE_RING_SYNC_MT:
+   strcpy(cons, "MC");
+   break;
+   case RTE_RING_SYNC_ST:
+   strcpy(cons, "SC");
+   break;
+   case RTE_RING_SYNC_MT_RTS:
+   strcpy(cons, "MC_RTS");
+   break;
+   case RTE_RING_SYNC_MT_HTS:
+   strcpy(cons, "MC_HTS");
+   break;
+   default:
+   strcpy(cons, "Unknown");
+   }
+}
+
+static int
+ring_handle_info(const char *cmd __rte_unused, const char *params,
+   struct rte_tel_data *d)
+{
+   char prod_type[SYNC_MODE_NAME_SZ];
+   char cons_type[SYNC_MODE_NAME_SZ];
+   const struct rte_memzone *mz;
+   char name[RTE_RING_NAMESIZE];
+   struct rte_ring *r;
+
+   if (params == NULL || strlen(params) == 0 ||
+   strlen(params) >= RTE_MEMZONE_NAMESIZE)
+   return -EINVAL;
+
+   strlcpy(name, params, RTE_MEMZONE_NAMESIZE);
+   r = rte_ring_lookup(name);
+   if (r == NULL)
+   return -EINVAL;
+
+   rte_tel_data_start_dict(d);
+   rte_tel_data_add_dict_string(d, "name", r->name);
+   rte_tel_data_add_dict_int(d, "socket", r->memzone->socket_id);
+   rte_tel_data_add_dict_int(d, "flags", r->flags);
+   ring_get_sync_name_by_type(r, prod_type, cons_type);
+   rte_tel_data_add_dict_string(d, "producer_type", prod_type);
+   rte_tel_data_add_dict_string(d, "consumer_type", cons_type);
+   rte_tel_data_add_dict_u64(d, "size", r->size);
+   rte_tel_data_add_dict_u64(d, "mask", r->mask);
+   rte_tel_data_add_dict_u64(d, "capacity", r->capacity);
+   rte_tel_data_add_dict_u64(d, "used_count", rte_ring_count(r));
+   rte_tel_data_add_dict_u64(d, "consumer_tail", r->cons.tail);
+   rte_tel_data_add_dict_u64(d, "consumer_head", r->cons.head);
+   rte_tel_data_add_dict_u64(d, "producer_tail", r->prod.tail);
+   rte_tel_data_add_dict_u64(d, "producer_head", r->prod.head);
+
+   mz = r->memzone;
+   rte_tel_data_add_dict_string(d, "mz_name", mz->name);
+   rte_tel_data_add_dict_int(d, "mz_len", mz->len);
+   rte_tel_data_add_dict_int(d, "mz_hugepage_sz", mz->hugepage_sz);
+   rte_tel_data_add_dict_int(d, "mz_socket_id", mz->socket_id);
+   rte_tel_data_add_dict_int(d, "mz_flags", mz->flags);
+
+   return 0;
+}
+
 RTE_INIT(ring_init_telemetry)
 {
rte_telemetry_register_cmd("/ring/list", ring_handle_list,
"Returns list of available ring. Takes no parameters");
+   rte_telemetry_register_cmd("/ring/info", ring_handle_info,
+   "Returns ring info. Parameters: ring_name.");
 }
-- 
2.33.0



[PATCH v2 0/2] add ring telemetry cmds

2023-01-17 Thread Jie Hai
This patch set supports telemetry list rings and dump ring info
by its name.

Jie Hai (2):
  ring: add ring list telemetry cmd
  ring: add ring info telemetry cmd

 lib/ring/meson.build |   1 +
 lib/ring/rte_ring.c  | 128 +++
 2 files changed, 129 insertions(+)

-- 
2.33.0



[PATCH v2 1/2] ring: add ring list telemetry cmd

2023-01-17 Thread Jie Hai
This patch supports the list of rings with telemetry cmd.
An example using this command is shown below:

--> /ring/list
{
  "/ring/list": [
"HT_:7d:00.2",
"MP_mb_pool_0"
  ]
}

Signed-off-by: Jie Hai 
---
 lib/ring/meson.build |  1 +
 lib/ring/rte_ring.c  | 40 
 2 files changed, 41 insertions(+)

diff --git a/lib/ring/meson.build b/lib/ring/meson.build
index c20685c689ac..7fca958ed7fa 100644
--- a/lib/ring/meson.build
+++ b/lib/ring/meson.build
@@ -18,3 +18,4 @@ indirect_headers += files (
 'rte_ring_rts.h',
 'rte_ring_rts_elem_pvt.h',
 )
+deps += ['telemetry']
diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index cddaf6b2876f..bb1dafd4d1ca 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "rte_ring.h"
 #include "rte_ring_elem.h"
@@ -419,3 +420,42 @@ rte_ring_lookup(const char *name)
 
return r;
 }
+
+static void
+rte_ring_walk(void (*func)(struct rte_ring *, void *), void *arg)
+{
+   struct rte_ring_list *ring_list;
+   struct rte_tailq_entry *te;
+
+   ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
+   rte_mcfg_tailq_read_lock();
+
+   TAILQ_FOREACH(te, ring_list, next) {
+   (*func)((struct rte_ring *) te->data, arg);
+   }
+
+   rte_mcfg_tailq_read_unlock();
+}
+
+static void
+ring_list_cb(struct rte_ring *r, void *arg)
+{
+   struct rte_tel_data *d = (struct rte_tel_data *)arg;
+
+   rte_tel_data_add_array_string(d, r->name);
+}
+
+static int
+ring_handle_list(const char *cmd __rte_unused,
+   const char *params __rte_unused, struct rte_tel_data *d)
+{
+   rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+   rte_ring_walk(ring_list_cb, d);
+   return 0;
+}
+
+RTE_INIT(ring_init_telemetry)
+{
+   rte_telemetry_register_cmd("/ring/list", ring_handle_list,
+   "Returns list of available ring. Takes no parameters");
+}
-- 
2.33.0



[PATCH v2 2/2] ring: add ring info telemetry cmd

2023-01-17 Thread Jie Hai
This patch supports dump of the info of ring by its name.
An example using this command is shown below:

--> /ring/info,MP_mb_pool_0
{
  "/ring/info": {
"name": "MP_mb_pool_0",
"socket": 0,
"flags": 0,
"producer_type": "MP",
"consumer_type": "MC",
"size": 262144,
"mask": 262143,
"capacity": 262143,
"used_count": 147173,
"consumer_tail": 8283,
"consumer_head": 8283,
"producer_tail": 155456,
"producer_head": 155456,
"mz_name": "RG_MP_mb_pool_0",
"mz_len": 2097920,
"mz_hugepage_sz": 1073741824,
"mz_socket_id": 0,
"mz_flags": 0
  }
}

Signed-off-by: Jie Hai 
---
 lib/ring/rte_ring.c | 88 +
 1 file changed, 88 insertions(+)

diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index bb1dafd4d1ca..82f3d6a6cd60 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -45,6 +45,9 @@ EAL_REGISTER_TAILQ(rte_ring_tailq)
 /* by default set head/tail distance as 1/8 of ring capacity */
 #define HTD_MAX_DEF8
 
+/* size of name of producer/consumer synchronization modes */
+#define SYNC_MODE_NAME_SZ  16
+
 /* return the size of memory occupied by a ring */
 ssize_t
 rte_ring_get_memsize_elem(unsigned int esize, unsigned int count)
@@ -454,8 +457,93 @@ ring_handle_list(const char *cmd __rte_unused,
return 0;
 }
 
+static void
+ring_get_sync_name_by_type(struct rte_ring *r, char *prod, char *cons)
+{
+   switch (r->prod.sync_type) {
+   case RTE_RING_SYNC_MT:
+   strcpy(prod, "MP");
+   break;
+   case RTE_RING_SYNC_ST:
+   strcpy(prod, "SP");
+   break;
+   case RTE_RING_SYNC_MT_RTS:
+   strcpy(prod, "MP_RTS");
+   break;
+   case RTE_RING_SYNC_MT_HTS:
+   strcpy(prod, "MP_HTS");
+   break;
+   default:
+   strcpy(prod, "Unknown");
+   }
+
+   switch (r->cons.sync_type) {
+   case RTE_RING_SYNC_MT:
+   strcpy(cons, "MC");
+   break;
+   case RTE_RING_SYNC_ST:
+   strcpy(cons, "SC");
+   break;
+   case RTE_RING_SYNC_MT_RTS:
+   strcpy(cons, "MC_RTS");
+   break;
+   case RTE_RING_SYNC_MT_HTS:
+   strcpy(cons, "MC_HTS");
+   break;
+   default:
+   strcpy(cons, "Unknown");
+   }
+}
+
+static int
+ring_handle_info(const char *cmd __rte_unused, const char *params,
+   struct rte_tel_data *d)
+{
+   char prod_type[SYNC_MODE_NAME_SZ];
+   char cons_type[SYNC_MODE_NAME_SZ];
+   const struct rte_memzone *mz;
+   char name[RTE_RING_NAMESIZE];
+   struct rte_ring *r;
+
+   if (params == NULL || strlen(params) == 0 ||
+   strlen(params) >= RTE_RING_NAMESIZE)
+   return -EINVAL;
+
+   strlcpy(name, params, RTE_RING_NAMESIZE);
+   r = rte_ring_lookup(name);
+   if (r == NULL)
+   return -EINVAL;
+
+   rte_tel_data_start_dict(d);
+   rte_tel_data_add_dict_string(d, "name", r->name);
+   rte_tel_data_add_dict_int(d, "socket", r->memzone->socket_id);
+   rte_tel_data_add_dict_int(d, "flags", r->flags);
+   ring_get_sync_name_by_type(r, prod_type, cons_type);
+   rte_tel_data_add_dict_string(d, "producer_type", prod_type);
+   rte_tel_data_add_dict_string(d, "consumer_type", cons_type);
+   rte_tel_data_add_dict_u64(d, "size", r->size);
+   rte_tel_data_add_dict_u64(d, "mask", r->mask);
+   rte_tel_data_add_dict_u64(d, "capacity", r->capacity);
+   rte_tel_data_add_dict_u64(d, "used_count", rte_ring_count(r));
+   rte_tel_data_add_dict_u64(d, "consumer_tail", r->cons.tail);
+   rte_tel_data_add_dict_u64(d, "consumer_head", r->cons.head);
+   rte_tel_data_add_dict_u64(d, "producer_tail", r->prod.tail);
+   rte_tel_data_add_dict_u64(d, "producer_head", r->prod.head);
+
+   mz = r->memzone;
+   rte_tel_data_add_dict_string(d, "mz_name", mz->name);
+   rte_tel_data_add_dict_int(d, "mz_len", mz->len);
+   rte_tel_data_add_dict_int(d, "mz_hugepage_sz", mz->hugepage_sz);
+   rte_tel_data_add_dict_int(d, "mz_socket_id", mz->socket_id);
+   rte_tel_data_add_dict_int(d, "mz_flags", mz->flags);
+
+   return 0;
+}
+
 RTE_INIT(ring_init_telemetry)
 {
rte_telemetry_register_cmd("/ring/list", ring_handle_list,
"Returns list of available ring. Takes no parameters");
+   rte_telemetry_register_cmd("/ring/info", ring_handle_info,
+   "Returns ring info. Parameters: ring_name.");
 }
-- 
2.33.0



[PATCH v3 0/2] add ring telemetry cmds

2023-01-30 Thread Jie Hai
This patch set supports telemetry list rings and dump info of a ring
by its name.

v1->v2:
1. Add space after "switch".
2. Fix wrong strlen parameter.

v2->v3:
1. Remove prefix "rte_" for static function.
2. Add Acked-by Konstantin Ananyev for PATCH 1.
3. Introduce functions to return strings instead copy strings.
4. Check pointer to memzone of ring.
5. Remove redundant variable.
6. Hold lock when access ring data.

Jie Hai (2):
  ring: add ring list telemetry cmd
  ring: add ring info telemetry cmd

 lib/ring/meson.build |   1 +
 lib/ring/rte_ring.c  | 123 +++
 2 files changed, 124 insertions(+)

-- 
2.33.0



[PATCH v3 1/2] ring: add ring list telemetry cmd

2023-01-30 Thread Jie Hai
This patch supports the list of rings with telemetry cmd.
An example using this command is shown below:

--> /ring/list
{
  "/ring/list": [
"HT_:7d:00.2",
"MP_mb_pool_0"
  ]
}

Signed-off-by: Jie Hai 
Acked-by: Konstantin Ananyev 
---
 lib/ring/meson.build |  1 +
 lib/ring/rte_ring.c  | 40 
 2 files changed, 41 insertions(+)

diff --git a/lib/ring/meson.build b/lib/ring/meson.build
index c20685c689ac..7fca958ed7fa 100644
--- a/lib/ring/meson.build
+++ b/lib/ring/meson.build
@@ -18,3 +18,4 @@ indirect_headers += files (
 'rte_ring_rts.h',
 'rte_ring_rts_elem_pvt.h',
 )
+deps += ['telemetry']
diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index cddaf6b2876f..e6aac332d88f 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "rte_ring.h"
 #include "rte_ring_elem.h"
@@ -419,3 +420,42 @@ rte_ring_lookup(const char *name)
 
return r;
 }
+
+static void
+ring_walk(void (*func)(struct rte_ring *, void *), void *arg)
+{
+   struct rte_ring_list *ring_list;
+   struct rte_tailq_entry *te;
+
+   ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
+   rte_mcfg_tailq_read_lock();
+
+   TAILQ_FOREACH(te, ring_list, next) {
+   (*func)((struct rte_ring *) te->data, arg);
+   }
+
+   rte_mcfg_tailq_read_unlock();
+}
+
+static void
+ring_list_cb(struct rte_ring *r, void *arg)
+{
+   struct rte_tel_data *d = (struct rte_tel_data *)arg;
+
+   rte_tel_data_add_array_string(d, r->name);
+}
+
+static int
+ring_handle_list(const char *cmd __rte_unused,
+   const char *params __rte_unused, struct rte_tel_data *d)
+{
+   rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+   ring_walk(ring_list_cb, d);
+   return 0;
+}
+
+RTE_INIT(ring_init_telemetry)
+{
+   rte_telemetry_register_cmd("/ring/list", ring_handle_list,
+   "Returns list of available ring. Takes no parameters");
+}
-- 
2.33.0



[PATCH v3 2/2] ring: add ring info telemetry cmd

2023-01-30 Thread Jie Hai
This patch supports dump of the info of ring by its name.
An example using this command is shown below:

--> /ring/info,MP_mb_pool_0
{
  "/ring/info": {
"name": "MP_mb_pool_0",
"socket": 0,
"flags": 0,
"producer_type": "MP",
"consumer_type": "MC",
"size": 262144,
"mask": 262143,
"capacity": 262143,
"used_count": 147173,
"consumer_tail": 8283,
"consumer_head": 8283,
"producer_tail": 155456,
"producer_head": 155456,
"mz_name": "RG_MP_mb_pool_0",
"mz_len": 2097920,
"mz_hugepage_sz": 1073741824,
"mz_socket_id": 0,
"mz_flags": 0
  }
}

Signed-off-by: Jie Hai 
---
 lib/ring/rte_ring.c | 83 +
 1 file changed, 83 insertions(+)

diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index e6aac332d88f..2e57aa653339 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -454,8 +454,91 @@ ring_handle_list(const char *cmd __rte_unused,
return 0;
 }
 
+static const char *
+ring_prod_sync_type_to_name(struct rte_ring *r)
+{
+   switch (r->prod.sync_type) {
+   case RTE_RING_SYNC_MT:
+   return "MP";
+   case RTE_RING_SYNC_ST:
+   return "SP";
+   case RTE_RING_SYNC_MT_RTS:
+   return "MP_RTS";
+   case RTE_RING_SYNC_MT_HTS:
+   return "MP_HTS";
+   default:
+   return "Unknown";
+   }
+}
+
+static const char *
+ring_cons_sync_type_to_name(struct rte_ring *r)
+{
+   switch (r->cons.sync_type) {
+   case RTE_RING_SYNC_MT:
+   return "MC";
+   case RTE_RING_SYNC_ST:
+   return "SC";
+   case RTE_RING_SYNC_MT_RTS:
+   return "MC_RTS";
+   case RTE_RING_SYNC_MT_HTS:
+   return "MC_HTS";
+   default:
+   return "Unknown";
+   }
+}
+
+static int
+ring_handle_info(const char *cmd __rte_unused, const char *params,
+   struct rte_tel_data *d)
+{
+   const struct rte_memzone *mz;
+   struct rte_ring *r;
+
+   if (params == NULL || strlen(params) == 0 ||
+   strlen(params) >= RTE_RING_NAMESIZE)
+   return -EINVAL;
+
+   r = rte_ring_lookup(params);
+   if (r == NULL)
+   return -EINVAL;
+
+   rte_mcfg_tailq_read_lock();
+
+   rte_tel_data_start_dict(d);
+   rte_tel_data_add_dict_string(d, "name", r->name);
+   rte_tel_data_add_dict_int(d, "socket", r->memzone->socket_id);
+   rte_tel_data_add_dict_int(d, "flags", r->flags);
+   rte_tel_data_add_dict_string(d, "producer_type",
+   ring_prod_sync_type_to_name(r));
+   rte_tel_data_add_dict_string(d, "consumer_type",
+   ring_cons_sync_type_to_name(r));
+   rte_tel_data_add_dict_u64(d, "size", r->size);
+   rte_tel_data_add_dict_u64(d, "mask", r->mask);
+   rte_tel_data_add_dict_u64(d, "capacity", r->capacity);
+   rte_tel_data_add_dict_u64(d, "used_count", rte_ring_count(r));
+   rte_tel_data_add_dict_u64(d, "consumer_tail", r->cons.tail);
+   rte_tel_data_add_dict_u64(d, "consumer_head", r->cons.head);
+   rte_tel_data_add_dict_u64(d, "producer_tail", r->prod.tail);
+   rte_tel_data_add_dict_u64(d, "producer_head", r->prod.head);
+
+   mz = r->memzone;
+   if (mz == NULL)
+   return 0;
+   rte_tel_data_add_dict_string(d, "mz_name", mz->name);
+   rte_tel_data_add_dict_int(d, "mz_len", mz->len);
+   rte_tel_data_add_dict_int(d, "mz_hugepage_sz", mz->hugepage_sz);
+   rte_tel_data_add_dict_int(d, "mz_socket_id", mz->socket_id);
+   rte_tel_data_add_dict_int(d, "mz_flags", mz->flags);
+
+   rte_mcfg_tailq_read_unlock();
+   return 0;
+}
+
 RTE_INIT(ring_init_telemetry)
 {
rte_telemetry_register_cmd("/ring/list", ring_handle_list,
"Returns list of available ring. Takes no parameters");
+   rte_telemetry_register_cmd("/ring/info", ring_handle_info,
+   "Returns ring info. Parameters: ring_name.");
 }
-- 
2.33.0



[PATCH] test/mbuf: fix mbuf_autotest retest fail

2023-01-30 Thread Jie Hai
Retest "mbuf_autotest" will fail because the mbuf pool was
not freed after previous test successful done.
This patch fixes it.

Fixes: efc6f9104c80 ("mbuf: fix reset on mbuf free")
Cc: sta...@dpdk.org

Signed-off-by: Jie Hai 
---
 app/test/test_mbuf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c
index 53fe898a384c..6cbb03b0afaa 100644
--- a/app/test/test_mbuf.c
+++ b/app/test/test_mbuf.c
@@ -2764,6 +2764,7 @@ test_nb_segs_and_next_reset(void)
m2->nb_segs != 1 || m2->next != NULL)
GOTO_FAIL("nb_segs or next was not reset properly");
 
+   rte_mempool_free(pool);
return 0;
 
 fail:
-- 
2.30.0



[PATCH] examples/l3fwd-power: support CPPC cpufreq

2023-01-30 Thread Jie Hai
Currently the l3fwd-power only supports ACPI cpufreq and Pstate
cpufreq, This patch adds CPPC cpufreq.

Signed-off-by: Jie Hai 
---
 examples/l3fwd-power/main.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index fd3ade330f82..5090d5598172 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -2453,9 +2453,10 @@ init_power_library(void)
/* we're not supporting the VM channel mode */
env = rte_power_get_env();
if (env != PM_ENV_ACPI_CPUFREQ &&
-   env != PM_ENV_PSTATE_CPUFREQ) {
+   env != PM_ENV_PSTATE_CPUFREQ &&
+   env != PM_ENV_CPPC_CPUFREQ) {
RTE_LOG(ERR, POWER,
-   "Only ACPI and PSTATE mode are supported\n");
+   "Only ACPI, PSTATE and CPPC mode are 
supported\n");
return -1;
}
}
@@ -2639,12 +2640,14 @@ autodetect_mode(void)
/*
 * Empty poll and telemetry modes have to be specifically requested to
 * be enabled, but we can auto-detect between interrupt mode with or
-* without frequency scaling. Both ACPI and pstate can be used.
+* without frequency scaling. Any of ACPI, pstate and CPPC can be used.
 */
if (rte_power_check_env_supported(PM_ENV_ACPI_CPUFREQ))
return APP_MODE_LEGACY;
if (rte_power_check_env_supported(PM_ENV_PSTATE_CPUFREQ))
return APP_MODE_LEGACY;
+   if (rte_power_check_env_supported(PM_ENV_CPPC_CPUFREQ))
+   return APP_MODE_LEGACY;
 
RTE_LOG(NOTICE, L3FWD_POWER, "Frequency scaling not supported, 
selecting interrupt-only mode\n");
 
-- 
2.30.0



Re: [PATCH v2 1/2] ring: add ring list telemetry cmd

2023-01-30 Thread Jie Hai



On 2023/1/23 0:40, Konstantin Ananyev wrote:

Hi Jie,


This patch supports the list of rings with telemetry cmd.
An example using this command is shown below:

--> /ring/list
{
   "/ring/list": [
 "HT_:7d:00.2",
 "MP_mb_pool_0"
   ]
}

Signed-off-by: Jie Hai 
---
  lib/ring/meson.build |  1 +
  lib/ring/rte_ring.c  | 40 
  2 files changed, 41 insertions(+)

diff --git a/lib/ring/meson.build b/lib/ring/meson.build
index c20685c689ac..7fca958ed7fa 100644
--- a/lib/ring/meson.build
+++ b/lib/ring/meson.build
@@ -18,3 +18,4 @@ indirect_headers += files (
  'rte_ring_rts.h',
  'rte_ring_rts_elem_pvt.h',
  )
+deps += ['telemetry']
diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
index cddaf6b2876f..bb1dafd4d1ca 100644
--- a/lib/ring/rte_ring.c
+++ b/lib/ring/rte_ring.c
@@ -22,6 +22,7 @@
  #include 
  #include 
  #include 
+#include 
  #include "rte_ring.h"
  #include "rte_ring_elem.h"
@@ -419,3 +420,42 @@ rte_ring_lookup(const char *name)
  return r;
  }
+
+static void
+rte_ring_walk(void (*func)(struct rte_ring *, void *), void *arg)


As a nit: it is a static function, so I think we can skip 'rte_' prefix 
for it.

Apart from that:
Acked-by: Konstantin Ananyev 


Hi, Konstantin,

Thanks for your review. Accepted and fixed in v3.

Jie Hai

+{
+    struct rte_ring_list *ring_list;
+    struct rte_tailq_entry *te;
+
+    ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
+    rte_mcfg_tailq_read_lock();
+
+    TAILQ_FOREACH(te, ring_list, next) {
+    (*func)((struct rte_ring *) te->data, arg);
+    }
+
+    rte_mcfg_tailq_read_unlock();
+}
+
+static void
+ring_list_cb(struct rte_ring *r, void *arg)
+{
+    struct rte_tel_data *d = (struct rte_tel_data *)arg;
+
+    rte_tel_data_add_array_string(d, r->name);
+}
+
+static int
+ring_handle_list(const char *cmd __rte_unused,
+    const char *params __rte_unused, struct rte_tel_data *d)
+{
+    rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+    rte_ring_walk(ring_list_cb, d);
+    return 0;
+}
+
+RTE_INIT(ring_init_telemetry)
+{
+    rte_telemetry_register_cmd("/ring/list", ring_handle_list,
+    "Returns list of available ring. Takes no parameters");
+}


.


Re: [PATCH v2 2/2] ring: add ring info telemetry cmd

2023-01-30 Thread Jie Hai

Hi, Konstantin,

Thanks for your review. All accepted and fixed in v3.

Jie Hai

On 2023/1/23 1:49, Konstantin Ananyev wrote:



This patch supports dump of the info of ring by its name.
An example using this command is shown below:

--> /ring/info,MP_mb_pool_0
{
   "/ring/info": {
 "name": "MP_mb_pool_0",
 "socket": 0,
 "flags": 0,
 "producer_type": "MP",
 "consumer_type": "MC",
 "size": 262144,
 "mask": 262143,
 "capacity": 262143,
 "used_count": 147173,
 "consumer_tail": 8283,
 "consumer_head": 8283,
 "producer_tail": 155456,
 "producer_head": 155456,
 "mz_name": "RG_MP_mb_pool_0",
 "mz_len": 2097920,
 "mz_hugepage_sz": 1073741824,
 "mz_socket_id": 0,
 "mz_flags": 0
   }
}

Signed-off-by: Jie Hai 


Re: [PATCH v3 2/2] ring: add ring info telemetry cmd

2023-02-02 Thread Jie Hai

On 2023/2/1 0:44, Honnappa Nagarahalli wrote:

Few minor nits. Otherwise,

Reviewed-by: Honnappa Nagarahalli 


Thanks for your review.

-Original Message-
From: Jie Hai 
Sent: Monday, January 30, 2023 8:29 PM
To: Honnappa Nagarahalli ;
konstantin.v.anan...@yandex.ru; dev@dpdk.org
Cc: liudongdo...@huawei.com; haij...@huawei.com
Subject: [PATCH v3 2/2] ring: add ring info telemetry cmd

"ring: add telemetry cmd for ring info"


This patch supports dump of the info of ring by its name.

This patch supports dump of ring information by its name.


Accepted and will change it in v4.

An example using this command is shown below:

--> /ring/info,MP_mb_pool_0
{
   "/ring/info": {
 "name": "MP_mb_pool_0",
 "socket": 0,
 "flags": 0,
 "producer_type": "MP",
 "consumer_type": "MC",
 "size": 262144,
 "mask": 262143,
 "capacity": 262143,
 "used_count": 147173,
 "consumer_tail": 8283,
 "consumer_head": 8283,
 "producer_tail": 155456,
 "producer_head": 155456,

Sometimes it is much easier to understand these numbers if they are in 
hexadecimal. Is it possible to add the hexadecimal format in brackets? 
Something like:
"size": 262144 (0x4)

Huisong Li  makes it possible in 
http://patches.dpdk.org/project/dpdk/patch/20221219070648.33817-7-lihuis...@huawei.com/.
We can change rte_tel_data_add_dict_u64 to 
rte_tel_data_add_dict_uint_hex after his patch accepted.



--
2.33.0


.


Re: [PATCH v3 1/2] ring: add ring list telemetry cmd

2023-02-02 Thread Jie Hai

On 2023/2/1 0:44, Honnappa Nagarahalli wrote:

Few minor comments inline. Otherwise,

Reviewed-by: Honnappa Nagarahalli 


Thanks for your review.

-Original Message-
From: Jie Hai 
Sent: Monday, January 30, 2023 8:29 PM
To: Honnappa Nagarahalli ;
konstantin.v.anan...@yandex.ru; dev@dpdk.org
Cc: liudongdo...@huawei.com; haij...@huawei.com
Subject: [PATCH v3 1/2] ring: add ring list telemetry cmd

How about "ring: add telemetry cmd to list rings"



This patch supports the list of rings with telemetry cmd.

Add a telemetry command to list the rings used in the system.


That sounds easier to understand. Accepted and will change it in v4.

An example using this command is shown below:

--> /ring/list
{
   "/ring/list": [
 "HT_:7d:00.2",
 "MP_mb_pool_0"
   ]
}
+RTE_INIT(ring_init_telemetry)
+{
+   rte_telemetry_register_cmd("/ring/list", ring_handle_list,
+   "Returns list of available ring. Takes no parameters"); }

   
rings
Thank you very much for your comments. I will change it to "Returns list 
of available rings" in v4.

--
2.33.0


.


Re: [PATCH v3 2/2] ring: add ring info telemetry cmd

2023-02-02 Thread Jie Hai

On 2023/2/2 21:07, Konstantin Ananyev wrote:

31/01/2023 02:28, Jie Hai пишет:

This patch supports dump of the info of ring by its name.
An example using this command is shown below:

--> /ring/info,MP_mb_pool_0
{
   "/ring/info": {
 "name": "MP_mb_pool_0",
 "socket": 0,
 "flags": 0,
 "producer_type": "MP",
 "consumer_type": "MC",
 "size": 262144,
 "mask": 262143,
 "capacity": 262143,
 "used_count": 147173,
 "consumer_tail": 8283,
 "consumer_head": 8283,
 "producer_tail": 155456,
 "producer_head": 155456,
 "mz_name": "RG_MP_mb_pool_0",
 "mz_len": 2097920,
 "mz_hugepage_sz": 1073741824,
 "mz_socket_id": 0,
 "mz_flags": 0
   }
}

Signed-off-by: Jie Hai 



+static int
+ring_handle_info(const char *cmd __rte_unused, const char *params,
+    struct rte_tel_data *d)
+{
+    const struct rte_memzone *mz;
+    struct rte_ring *r;
+
+    if (params == NULL || strlen(params) == 0 ||
+    strlen(params) >= RTE_RING_NAMESIZE)
+    return -EINVAL;
+
+    r = rte_ring_lookup(params);
+    if (r == NULL)
+    return -EINVAL;


thanks for the update, but I think there still a potential problem here:
as we release tailq_lock inside ring_lookup() and then grab it after again.
Between these two points we have sort of race condition.
We need a way not to release it in between.
Probably the simplest way - make this function to use ring_walk()
that you introduced in previous patch, instead of ring_lookup().
Similar to what mempool_handle_info() is doing.


Thanks for your comments, and I have learned a lot from it. That will be 
corrected in v4.



.


Re: [PATCH v2 1/5] ethdev: support setting and querying RSS algorithm

2023-08-31 Thread Jie Hai

On 2023/8/31 8:10, Ajit Khaparde wrote:

On Wed, Aug 30, 2023 at 4:46 AM Thomas Monjalon  wrote:


Hello,

Thanks for bringing a new capability.

26/08/2023 09:46, Jie Hai:

Currently, rte_eth_rss_conf supports configuring and querying
rss hash functions, rss key and it's length, but not rss hash
algorithm.

The structure ``rte_eth_rss_conf`` is extended by adding a new
field "func". This represents the RSS algorithms to apply. The
following API is affected:
   - rte_eth_dev_configure
   - rte_eth_dev_rss_hash_update
   - rte_eth_dev_rss_hash_conf_get


So far, the RSS algorithm was used only in flow RSS API.


--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -123,6 +123,8 @@ ABI Changes
 Also, make sure to start the actual text at the margin.
 ===

+   * ethdev: Added "func" field to ``rte_eth_rss_conf`` structure for RSS hash
+ algorithm.


As written above, it should start at the margin.


--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
+#include "rte_flow.h"


It is strange to include rte_flow.h here.
It would be better to move the enum.


+ * The *func* field of the *rss_conf* structure indicates the hash algorithm
+ * applied by the RSS hashing. Passing RTE_ETH_HASH_FUNCTION_DEFAULT allows
+ * the PMD to use its best-effort algorithm rather than a specific one.
   */


I don't like commenting a field on top of the structure.
By the way, the first sentence does not look helpful.
RTE_ETH_HASH_FUNCTION_DEFAULT may be explained in the enum.


  struct rte_eth_rss_conf {
   uint8_t *rss_key;/**< If not NULL, 40-byte hash key. */
   uint8_t rss_key_len; /**< hash key length in bytes. */
   uint64_t rss_hf; /**< Hash functions to apply - see below. */
+ enum rte_eth_hash_function func;/**< Hash algorithm to apply. */


You can drop "to apply" words.

How the algorithms support combinations in rss_hf?

I will spend a little more time on this tomorrow.
Can you update testpmd also to display the info as a part of show rss.


Hi, Ajit Khaparde,

Thanks for your advice. I will update testpmd in next version.

Thanks, Jie Hai





[PATCH v3 0/5] support setting and querying RSS algorithms

2023-09-03 Thread Jie Hai
This patchset is to support setting and querying RSS algorithms.

--
v3:
1. fix commit log for PATCH [1/5].
2. make RSS ABI changes description to start the actual text at the margin.
3. move defnition of enum rte_eth_hash_function to rte_ethdev.h.
4. fix some comment codes.

v2:
1. return error if "func" is invalid.
2. modify the comments of the "func" field.
3. modify commit log of patch [3/5].
4. use malloc instead of rte_malloc.
5. adjust display format of RSS info.
6. remove the string display of rss_hf.
--


Jie Hai (5):
  app/proc-info: fix never show RSS info
  app/proc-info: adjust the display format of RSS info
  app/proc-info: support querying RSS hash algorithm
  app/testpmd: add RSS hash algorithms display
  app/testpmd: add RSS hash algorithms setting

 app/proc-info/main.c   |  45 ---
 app/test-pmd/cmdline.c | 128 ++---
 app/test-pmd/config.c  |  62 +++-
 app/test-pmd/testpmd.h |   5 +-
 4 files changed, 194 insertions(+), 46 deletions(-)

-- 
2.33.0



[PATCH v3 1/5] app/proc-info: fix never show RSS info

2023-09-03 Thread Jie Hai
Command show-port should show RSS info (rss_key, len and rss_hf),
However, the information is showned only when rss_conf.rss_key is not
NULL. Since no memory is allocated for rss_conf.rss_key, rss_key
will always be NULL and the rss_info will never show. This patch
allocates memory for rss_conf.rss_key and makes it possible to show
RSS info.

Fixes: 8a37f37fc243 ("app/procinfo: add --show-port")
Cc: sta...@dpdk.org

Signed-off-by: Jie Hai 
Signed-off-by: Dongdong Liu 
---
 app/proc-info/main.c | 25 -
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 88cee0ca487b..f6b77a705dce 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -1013,6 +1013,7 @@ show_port(void)
struct rte_eth_fc_conf fc_conf;
struct rte_ether_addr mac;
struct rte_eth_dev_owner owner;
+   uint8_t *rss_key;
 
/* Skip if port is not in mask */
if ((enabled_port_mask & (1ul << i)) == 0)
@@ -1171,19 +1172,25 @@ show_port(void)
printf("\n");
}
 
+   rss_key = malloc(dev_info.hash_key_size * sizeof(uint8_t));
+   if (rss_key == NULL)
+   return;
+
+   rss_conf.rss_key = rss_key;
+   rss_conf.rss_key_len = dev_info.hash_key_size;
ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
if (ret == 0) {
-   if (rss_conf.rss_key) {
-   printf("  - RSS\n");
-   printf("\t  -- RSS len %u key (hex):",
-   rss_conf.rss_key_len);
-   for (k = 0; k < rss_conf.rss_key_len; k++)
-   printf(" %x", rss_conf.rss_key[k]);
-   printf("\t  -- hf 0x%"PRIx64"\n",
-   rss_conf.rss_hf);
-   }
+   printf("  - RSS\n");
+   printf("\t  -- RSS len %u key (hex):",
+   rss_conf.rss_key_len);
+   for (k = 0; k < rss_conf.rss_key_len; k++)
+   printf(" %x", rss_conf.rss_key[k]);
+   printf("\t  -- hf 0x%"PRIx64"\n",
+   rss_conf.rss_hf);
}
 
+   free(rss_key);
+
 #ifdef RTE_LIB_SECURITY
show_security_context(i, true);
 #endif
-- 
2.33.0



[PATCH v3 2/5] app/proc-info: adjust the display format of RSS info

2023-09-03 Thread Jie Hai
This patch splits the length and value of RSS key into two parts,
removes spaces between RSS keys, and adds line breaks between RSS
key and RSS hf.

Before the adjustment, RSS info is shown as:
  - RSS
  -- RSS len 40 key (hex): 6d 5a 56 da 25 5b e c2 41 67 \
 25 3d 43 a3 8f b0 d0 ca 2b cb ae 7b 30 b4 77 cb 2d \
 a3 80 30 f2 c 6a 42 b7 3b be ac 1 fa -- hf 0x0
and after:
  - RSS info
  -- key len : 40
  -- key (hex) : 6d5a56da255b0ec24167253d43a38fb0d0c \
a2bcbae7b30b477cb2da38030f20c6a42b73bbeac01fa
  -- hf : 0x0

Fixes: 8a37f37fc243 ("app/procinfo: add --show-port")
Cc: sta...@dpdk.org

Signed-off-by: Jie Hai 
---
 app/proc-info/main.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index f6b77a705dce..6d2d77fea6ba 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -1180,12 +1180,13 @@ show_port(void)
rss_conf.rss_key_len = dev_info.hash_key_size;
ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
if (ret == 0) {
-   printf("  - RSS\n");
-   printf("\t  -- RSS len %u key (hex):",
+   printf("  - RSS info\n");
+   printf("\t  -- key len : %u\n",
rss_conf.rss_key_len);
+   printf("\t  -- key (hex) : ");
for (k = 0; k < rss_conf.rss_key_len; k++)
-   printf(" %x", rss_conf.rss_key[k]);
-   printf("\t  -- hf 0x%"PRIx64"\n",
+   printf("%02x", rss_conf.rss_key[k]);
+   printf("\n\t  -- hf : 0x%"PRIx64"\n",
rss_conf.rss_hf);
}
 
-- 
2.33.0



[PATCH v3 3/5] app/proc-info: support querying RSS hash algorithm

2023-09-03 Thread Jie Hai
Display RSS hash algorithm with command show-port as below.
  - RSS info
  -- hash algorithm : toeplitz

Signed-off-by: Jie Hai 
Signed-off-by: Dongdong Liu 
---
 app/proc-info/main.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 6d2d77fea6ba..02b418a4c661 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -996,6 +996,23 @@ show_offloads(uint64_t offloads,
}
 }
 
+static const char *
+rss_func_to_str(enum rte_eth_hash_function func)
+{
+   switch (func) {
+   case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
+   return "simple_xor";
+   case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
+   return "toeplitz";
+   case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
+   return "symmetric_toeplitz";
+   case RTE_ETH_HASH_FUNCTION_DEFAULT:
+   return "default";
+   default:
+   return "unknown";
+   }
+}
+
 static void
 show_port(void)
 {
@@ -1188,6 +1205,8 @@ show_port(void)
printf("%02x", rss_conf.rss_key[k]);
printf("\n\t  -- hf : 0x%"PRIx64"\n",
rss_conf.rss_hf);
+   printf("\t  -- hash algorithm : %s\n",
+   rss_func_to_str(rss_conf.func));
}
 
free(rss_key);
-- 
2.33.0



[PATCH v3 4/5] app/testpmd: add RSS hash algorithms display

2023-09-03 Thread Jie Hai
1. Add the command "show port X rss-hash func" to display the RSS hash
algorithms of port X.
2. Add the command "show port X rss-hash all" to display the RSS hash
configuration of port X, including RSS hash types, key and algorithms.

Signed-off-by: Jie Hai 
---
 app/test-pmd/cmdline.c | 50 +-
 app/test-pmd/config.c  | 46 +++---
 app/test-pmd/testpmd.h |  2 +-
 3 files changed, 74 insertions(+), 24 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0d0723f6596e..e7888be305da 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -174,8 +174,8 @@ static void cmd_help_long_parsed(void *parsed_result,
" by masks on port X. size is used to indicate the"
" hardware supported reta size\n\n"
 
-   "show port (port_id) rss-hash [key]\n"
-   "Display the RSS hash functions and RSS hash key of 
port\n\n"
+   "show port (port_id) rss-hash [key | func | all]\n"
+   "Display the RSS hash functions, RSS hash key and 
RSS hash algorithms of port\n\n"
 
"clear port (info|stats|xstats|fdir) (port_id|all)\n"
"Clear information for port_id, or all.\n\n"
@@ -3017,15 +3017,21 @@ struct cmd_showport_rss_hash {
cmdline_fixed_string_t rss_hash;
cmdline_fixed_string_t rss_type;
cmdline_fixed_string_t key; /* optional argument */
+   cmdline_fixed_string_t func; /* optional argument */
+   cmdline_fixed_string_t all; /* optional argument */
 };
 
 static void cmd_showport_rss_hash_parsed(void *parsed_result,
__rte_unused struct cmdline *cl,
-   void *show_rss_key)
+   __rte_unused void *data)
 {
struct cmd_showport_rss_hash *res = parsed_result;
 
-   port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
+   if (!strcmp(res->all, "all"))
+   port_rss_hash_conf_show(res->port_id, true, true);
+   else
+   port_rss_hash_conf_show(res->port_id,
+   !strcmp(res->key, "key"), !strcmp(res->func, "func"));
 }
 
 static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
@@ -3040,6 +3046,10 @@ static cmdline_parse_token_string_t 
cmd_showport_rss_hash_rss_hash =
 "rss-hash");
 static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
+static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_func =
+   TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, func, "func");
+static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_all =
+   TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, all, "all");
 
 static cmdline_parse_inst_t cmd_showport_rss_hash = {
.f = cmd_showport_rss_hash_parsed,
@@ -3056,7 +3066,7 @@ static cmdline_parse_inst_t cmd_showport_rss_hash = {
 
 static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
.f = cmd_showport_rss_hash_parsed,
-   .data = (void *)1,
+   .data = NULL,
.help_str = "show port  rss-hash key",
.tokens = {
(void *)&cmd_showport_rss_hash_show,
@@ -3068,6 +3078,34 @@ static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
},
 };
 
+static cmdline_parse_inst_t cmd_showport_rss_hash_func = {
+   .f = cmd_showport_rss_hash_parsed,
+   .data = NULL,
+   .help_str = "show port  rss-hash func",
+   .tokens = {
+   (void *)&cmd_showport_rss_hash_show,
+   (void *)&cmd_showport_rss_hash_port,
+   (void *)&cmd_showport_rss_hash_port_id,
+   (void *)&cmd_showport_rss_hash_rss_hash,
+   (void *)&cmd_showport_rss_hash_rss_func,
+   NULL,
+   },
+};
+
+static cmdline_parse_inst_t cmd_showport_rss_hash_all = {
+   .f = cmd_showport_rss_hash_parsed,
+   .data = NULL,
+   .help_str = "show port  rss-hash all",
+   .tokens = {
+   (void *)&cmd_showport_rss_hash_show,
+   (void *)&cmd_showport_rss_hash_port,
+   (void *)&cmd_showport_rss_hash_port_id,
+   (void *)&cmd_showport_rss_hash_rss_hash,
+   (void *)&cmd_showport_rss_hash_rss_all,
+   NULL,
+   },
+};
+
 /* *** Configure DCB *** */
 struct cmd_config_dcb {
cmdline_fixed_string_t port;
@@ -12905,6 +12943,8 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,

[PATCH v3 5/5] app/testpmd: add RSS hash algorithms setting

2023-09-03 Thread Jie Hai
Add command "port config  rss-hash-func " to set RSS
hash algorithms.

Signed-off-by: Jie Hai 
---
 app/test-pmd/cmdline.c | 78 --
 app/test-pmd/config.c  | 16 -
 app/test-pmd/testpmd.h |  3 +-
 3 files changed, 84 insertions(+), 13 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index e7888be305da..375f16fcee14 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -2136,6 +2136,76 @@ static cmdline_parse_inst_t cmd_config_rss = {
},
 };
 
+/* *** configure rss hash algorithms *** */
+struct cmd_config_rss_hash_func {
+   cmdline_fixed_string_t port;
+   cmdline_fixed_string_t config;
+   portid_t port_id;
+   cmdline_fixed_string_t rss_hash_func;
+   cmdline_fixed_string_t func;
+};
+
+static void
+cmd_config_rss_hash_func_parsed(void *parsed_result,
+  __rte_unused struct cmdline *cl,
+  __rte_unused void *data)
+{
+   struct cmd_config_rss_hash_func *res = parsed_result;
+   struct rte_eth_rss_conf rss_conf = {0};
+   struct {
+   const char *name;
+   enum rte_eth_hash_function func;
+   } hash_func_map[] = {
+   {"default", RTE_ETH_HASH_FUNCTION_DEFAULT},
+   {"toeplitz",RTE_ETH_HASH_FUNCTION_TOEPLITZ},
+   {"simple_xor",  RTE_ETH_HASH_FUNCTION_SIMPLE_XOR},
+   {"symmetric_toeplitz",  
RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ},
+   {NULL,  RTE_ETH_HASH_FUNCTION_MAX},
+   };
+   int i = 0;
+
+   rss_conf.func = RTE_ETH_HASH_FUNCTION_MAX;
+   while (hash_func_map[i].name != NULL) {
+   if (!strcmp(hash_func_map[i].name, res->func)) {
+   rss_conf.func = hash_func_map[i].func;
+   break;
+   }
+   i++;
+   }
+
+   port_rss_hash_key_update(res->port_id, &rss_conf);
+}
+
+static cmdline_parse_token_string_t cmd_config_rss_hash_func_port =
+   TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_func, port, "port");
+static cmdline_parse_token_string_t cmd_config_rss_hash_func_config =
+   TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_func, config,
+"config");
+static cmdline_parse_token_num_t cmd_config_rss_hash_func_port_id =
+   TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_func, port_id,
+RTE_UINT16);
+static cmdline_parse_token_string_t cmd_config_rss_hash_func_rss_hash_func =
+   TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_func,
+rss_hash_func, "rss-hash-func");
+static cmdline_parse_token_string_t cmd_config_rss_hash_func_value =
+   TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_func, func,
+   
"default#toeplitz#simple_xor#symmetric_toeplitz");
+
+static cmdline_parse_inst_t cmd_config_rss_hash_func = {
+   .f = cmd_config_rss_hash_func_parsed,
+   .data = NULL,
+   .help_str = "port config  rss-hash-func"
+   "default|toeplitz|simple_xor|symmetric_toeplitz",
+   .tokens = {
+   (void *)&cmd_config_rss_hash_func_port,
+   (void *)&cmd_config_rss_hash_func_config,
+   (void *)&cmd_config_rss_hash_func_port_id,
+   (void *)&cmd_config_rss_hash_func_rss_hash_func,
+   (void *)&cmd_config_rss_hash_func_value,
+   NULL,
+   },
+};
+
 /* *** configure rss hash key *** */
 struct cmd_config_rss_hash_key {
cmdline_fixed_string_t port;
@@ -2182,6 +2252,7 @@ cmd_config_rss_hash_key_parsed(void *parsed_result,
uint8_t xdgt0;
uint8_t xdgt1;
int i;
+   struct rte_eth_rss_conf rss_conf = {0};
struct rte_eth_dev_info dev_info;
uint8_t hash_key_size;
uint32_t key_len;
@@ -2217,8 +2288,10 @@ cmd_config_rss_hash_key_parsed(void *parsed_result,
return;
hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
}
-   port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
-   hash_key_size);
+   rss_conf.rss_key = hash_key;
+   rss_conf.rss_key_len = hash_key_size;
+   rss_conf.rss_hf = str_to_rsstypes(res->rss_type);
+   port_rss_hash_key_update(res->port_id, &rss_conf);
 }
 
 static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
@@ -12946,6 +13019,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
(cmdline_parse_inst_t *)&cmd_showport_rss_hash_func,
(cmdline_parse_inst_t *)&cmd_showport_rss_hash_all,
(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
+   (cmdline_parse_inst_t *)&cmd_config

Re: [PATCH v2 1/5] ethdev: support setting and querying RSS algorithm

2023-09-03 Thread Jie Hai

On 2023/8/31 8:10, Ajit Khaparde wrote:

On Wed, Aug 30, 2023 at 4:46 AM Thomas Monjalon  wrote:


Hello,

Thanks for bringing a new capability.

26/08/2023 09:46, Jie Hai:

Currently, rte_eth_rss_conf supports configuring and querying
rss hash functions, rss key and it's length, but not rss hash
algorithm.

The structure ``rte_eth_rss_conf`` is extended by adding a new
field "func". This represents the RSS algorithms to apply. The
following API is affected:
   - rte_eth_dev_configure
   - rte_eth_dev_rss_hash_update
   - rte_eth_dev_rss_hash_conf_get


So far, the RSS algorithm was used only in flow RSS API.


--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -123,6 +123,8 @@ ABI Changes
 Also, make sure to start the actual text at the margin.
 ===

+   * ethdev: Added "func" field to ``rte_eth_rss_conf`` structure for RSS hash
+ algorithm.


As written above, it should start at the margin.


--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
+#include "rte_flow.h"


It is strange to include rte_flow.h here.
It would be better to move the enum.


+ * The *func* field of the *rss_conf* structure indicates the hash algorithm
+ * applied by the RSS hashing. Passing RTE_ETH_HASH_FUNCTION_DEFAULT allows
+ * the PMD to use its best-effort algorithm rather than a specific one.
   */


I don't like commenting a field on top of the structure.
By the way, the first sentence does not look helpful.
RTE_ETH_HASH_FUNCTION_DEFAULT may be explained in the enum.


  struct rte_eth_rss_conf {
   uint8_t *rss_key;/**< If not NULL, 40-byte hash key. */
   uint8_t rss_key_len; /**< hash key length in bytes. */
   uint64_t rss_hf; /**< Hash functions to apply - see below. */
+ enum rte_eth_hash_function func;/**< Hash algorithm to apply. */


You can drop "to apply" words.

How the algorithms support combinations in rss_hf?

I will spend a little more time on this tomorrow.
Can you update testpmd also to display the info as a part of show rss.


Hi, Ajit Khaparde,

Displaying RSS hash algorithms with testpmd is in progress.
However, there are some opinions on the implementation,
whether to add commands or display them in existing commands.

way 1: show port 0 rss-hash func
RSS algorithms:
  symmetric_toeplitz

way 2: show port 0 rss-hash
RSS functions:
  ipv4  ipv4-frag  ipv4-other  ipv6  ipv6-frag  ipv6-other
RSS algorithms:
 symmetric_toeplitz

I hope you can give some comments or suggestions.

Thanks,
Jie Hai





Re: [PATCH v2 1/5] ethdev: support setting and querying RSS algorithm

2023-09-04 Thread Jie Hai

Hi, Thomas

Thanks for your review.

On 2023/8/30 19:46, Thomas Monjalon wrote:

Hello,

Thanks for bringing a new capability.

26/08/2023 09:46, Jie Hai:

Currently, rte_eth_rss_conf supports configuring and querying
rss hash functions, rss key and it's length, but not rss hash
algorithm.

The structure ``rte_eth_rss_conf`` is extended by adding a new
field "func". This represents the RSS algorithms to apply. The
following API is affected:
- rte_eth_dev_configure
- rte_eth_dev_rss_hash_update
- rte_eth_dev_rss_hash_conf_get


So far, the RSS algorithm was used only in flow RSS API.


Fixed in V3, these API will be affected.

--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -123,6 +123,8 @@ ABI Changes
 Also, make sure to start the actual text at the margin.
 ===
  
+   * ethdev: Added "func" field to ``rte_eth_rss_conf`` structure for RSS hash

+ algorithm.


As written above, it should start at the margin.


Fixed in V3.

--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
+#include "rte_flow.h"


It is strange to include rte_flow.h here.
It would be better to move the enum.


Fixed in V3, the definations are removed to rte_ethdev.h.

+ * The *func* field of the *rss_conf* structure indicates the hash algorithm
+ * applied by the RSS hashing. Passing RTE_ETH_HASH_FUNCTION_DEFAULT allows
+ * the PMD to use its best-effort algorithm rather than a specific one.
   */


I don't like commenting a field on top of the structure.
By the way, the first sentence does not look helpful.
RTE_ETH_HASH_FUNCTION_DEFAULT may be explained in the enum.


Other fields  above the structure 'rte_eth_rss_conf' have comments.
If the new fields 'func' do not have comments, it may be misleading.
Unless all the comments above are removed. I'm not sure whether to
delete them or not.

  struct rte_eth_rss_conf {
uint8_t *rss_key;/**< If not NULL, 40-byte hash key. */
uint8_t rss_key_len; /**< hash key length in bytes. */
uint64_t rss_hf; /**< Hash functions to apply - see below. */
+   enum rte_eth_hash_function func;/**< Hash algorithm to apply. */


You can drop "to apply" words.

Fixed in V3.


How the algorithms support combinations in rss_hf?


The rss_hf defines the input of the RSS hash algorithms.
For example, rss_hf = RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_IPV4, 
these two kinds of packets can be dispatched to different queues 
according to their tuple field value.
For ipv4-tcp packets, src-ip, dst-ip, src-port, dst-port are used as 
parameters of RSS hash algorithms to compute hash value.

For ipv4 packets src-ip, dst-ip are used.

If rss_hf = RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_L4_SRC_ONLY, for
ipv4-tcp packets, src-port is used as parameters of RSS hash algorithms 
to compute hash value.




.


Thanks,
Jie Hai


[PATCH 3/5] app/proc-info: fix never show RSS info

2023-09-04 Thread Jie Hai
Command show-port should show RSS info (rss_key, len and rss_hf),
However, the information is showned only when rss_conf.rss_key is not
NULL. Since no memory is allocated for rss_conf.rss_key, rss_key
will always be NULL and the rss_info will never show. This patch
allocates memory for rss_conf.rss_key and makes it possible to show
RSS info.

Fixes: 8a37f37fc243 ("app/procinfo: add --show-port")
Cc: sta...@dpdk.org

Signed-off-by: Jie Hai 
Signed-off-by: Dongdong Liu 
---
 app/proc-info/main.c | 25 -
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 88cee0ca487b..f6b77a705dce 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -1013,6 +1013,7 @@ show_port(void)
struct rte_eth_fc_conf fc_conf;
struct rte_ether_addr mac;
struct rte_eth_dev_owner owner;
+   uint8_t *rss_key;
 
/* Skip if port is not in mask */
if ((enabled_port_mask & (1ul << i)) == 0)
@@ -1171,19 +1172,25 @@ show_port(void)
printf("\n");
}
 
+   rss_key = malloc(dev_info.hash_key_size * sizeof(uint8_t));
+   if (rss_key == NULL)
+   return;
+
+   rss_conf.rss_key = rss_key;
+   rss_conf.rss_key_len = dev_info.hash_key_size;
ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
if (ret == 0) {
-   if (rss_conf.rss_key) {
-   printf("  - RSS\n");
-   printf("\t  -- RSS len %u key (hex):",
-   rss_conf.rss_key_len);
-   for (k = 0; k < rss_conf.rss_key_len; k++)
-   printf(" %x", rss_conf.rss_key[k]);
-   printf("\t  -- hf 0x%"PRIx64"\n",
-   rss_conf.rss_hf);
-   }
+   printf("  - RSS\n");
+   printf("\t  -- RSS len %u key (hex):",
+   rss_conf.rss_key_len);
+   for (k = 0; k < rss_conf.rss_key_len; k++)
+   printf(" %x", rss_conf.rss_key[k]);
+   printf("\t  -- hf 0x%"PRIx64"\n",
+   rss_conf.rss_hf);
}
 
+   free(rss_key);
+
 #ifdef RTE_LIB_SECURITY
show_security_context(i, true);
 #endif
-- 
2.33.0



[PATCH 5/5] app/proc-info: support querying RSS hash algorithm

2023-09-04 Thread Jie Hai
Display RSS hash algorithm with command show-port as below.
  - RSS info
  -- hash algorithm : toeplitz

Signed-off-by: Jie Hai 
Signed-off-by: Dongdong Liu 
---
 app/proc-info/main.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 6d2d77fea6ba..02b418a4c661 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -996,6 +996,23 @@ show_offloads(uint64_t offloads,
}
 }
 
+static const char *
+rss_func_to_str(enum rte_eth_hash_function func)
+{
+   switch (func) {
+   case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
+   return "simple_xor";
+   case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
+   return "toeplitz";
+   case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
+   return "symmetric_toeplitz";
+   case RTE_ETH_HASH_FUNCTION_DEFAULT:
+   return "default";
+   default:
+   return "unknown";
+   }
+}
+
 static void
 show_port(void)
 {
@@ -1188,6 +1205,8 @@ show_port(void)
printf("%02x", rss_conf.rss_key[k]);
printf("\n\t  -- hf : 0x%"PRIx64"\n",
rss_conf.rss_hf);
+   printf("\t  -- hash algorithm : %s\n",
+   rss_func_to_str(rss_conf.func));
}
 
free(rss_key);
-- 
2.33.0



[PATCH 2/5] net/hns3: support setting and querying RSS hash function

2023-09-04 Thread Jie Hai
From: Huisong Li 

Support setting and querying RSS hash function by ethdev ops.

Signed-off-by: Huisong Li 
Signed-off-by: Dongdong Liu 
---
 drivers/net/hns3/hns3_rss.c | 47 +
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 6126512bd780..c8346d43d15c 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -646,14 +646,14 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
if (ret)
goto set_tuple_fail;
 
-   if (key) {
-   ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo,
-   key, hw->rss_key_size);
-   if (ret)
-   goto set_algo_key_fail;
-   /* Update the shadow RSS key with user specified */
+   ret = hns3_update_rss_algo_key(hw, rss_conf->func, key, key_len);
+   if (ret != 0)
+   goto set_algo_key_fail;
+
+   if (rss_conf->func != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   hw->rss_info.hash_algo = hns3_hash_func_map[rss_conf->func];
+   if (key != NULL)
memcpy(hw->rss_info.key, key, hw->rss_key_size);
-   }
hw->rss_info.rss_hf = rss_hf;
rte_spinlock_unlock(&hw->lock);
 
@@ -769,7 +769,13 @@ int
 hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
   struct rte_eth_rss_conf *rss_conf)
 {
+   const uint8_t hash_func_map[] = {
+   [HNS3_RSS_HASH_ALGO_TOEPLITZ] = RTE_ETH_HASH_FUNCTION_TOEPLITZ,
+   [HNS3_RSS_HASH_ALGO_SIMPLE] = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR,
+   [HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP] = 
RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
+   };
struct hns3_adapter *hns = dev->data->dev_private;
+   uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0};
struct hns3_hw *hw = &hns->hw;
uint8_t hash_algo;
int ret;
@@ -777,26 +783,27 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
rte_spinlock_lock(&hw->lock);
ret = hns3_rss_hash_get_rss_hf(hw, &rss_conf->rss_hf);
if (ret != 0) {
+   rte_spinlock_unlock(&hw->lock);
hns3_err(hw, "obtain hash tuples failed, ret = %d", ret);
-   goto out;
+   return ret;
+   }
+
+   ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_key, hw->rss_key_size);
+   if (ret != 0) {
+   rte_spinlock_unlock(&hw->lock);
+   hns3_err(hw, "obtain hash algo and key failed, ret = %d", ret);
+   return ret;
}
+   rte_spinlock_unlock(&hw->lock);
 
-   /* Get the RSS Key required by the user */
+   /* Get the RSS Key if user required. */
if (rss_conf->rss_key && rss_conf->rss_key_len >= hw->rss_key_size) {
-   ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_conf->rss_key,
-   hw->rss_key_size);
-   if (ret != 0) {
-   hns3_err(hw, "obtain hash algo and key failed, ret = 
%d",
-ret);
-   goto out;
-   }
+   memcpy(rss_conf->rss_key, rss_key, hw->rss_key_size);
rss_conf->rss_key_len = hw->rss_key_size;
}
+   rss_conf->func = hash_func_map[hash_algo];
 
-out:
-   rte_spinlock_unlock(&hw->lock);
-
-   return ret;
+   return 0;
 }
 
 /*
-- 
2.33.0



[PATCH 4/5] app/proc-info: adjust the display format of RSS info

2023-09-04 Thread Jie Hai
This patch splits the length and value of RSS key into two parts,
removes spaces between RSS keys, and adds line breaks between RSS
key and RSS hf.

Before the adjustment, RSS info is shown as:
  - RSS
  -- RSS len 40 key (hex): 6d 5a 56 da 25 5b e c2 41 67 \
 25 3d 43 a3 8f b0 d0 ca 2b cb ae 7b 30 b4 77 cb 2d \
 a3 80 30 f2 c 6a 42 b7 3b be ac 1 fa -- hf 0x0
and after:
  - RSS info
  -- key len : 40
  -- key (hex) : 6d5a56da255b0ec24167253d43a38fb0d0c \
a2bcbae7b30b477cb2da38030f20c6a42b73bbeac01fa
  -- hf : 0x0

Fixes: 8a37f37fc243 ("app/procinfo: add --show-port")
Cc: sta...@dpdk.org

Signed-off-by: Jie Hai 
---
 app/proc-info/main.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index f6b77a705dce..6d2d77fea6ba 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -1180,12 +1180,13 @@ show_port(void)
rss_conf.rss_key_len = dev_info.hash_key_size;
ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
if (ret == 0) {
-   printf("  - RSS\n");
-   printf("\t  -- RSS len %u key (hex):",
+   printf("  - RSS info\n");
+   printf("\t  -- key len : %u\n",
rss_conf.rss_key_len);
+   printf("\t  -- key (hex) : ");
for (k = 0; k < rss_conf.rss_key_len; k++)
-   printf(" %x", rss_conf.rss_key[k]);
-   printf("\t  -- hf 0x%"PRIx64"\n",
+   printf("%02x", rss_conf.rss_key[k]);
+   printf("\n\t  -- hf : 0x%"PRIx64"\n",
rss_conf.rss_hf);
}
 
-- 
2.33.0



[PATCH 0/5] support setting and querying RSS algorithms

2023-09-04 Thread Jie Hai
This patchset is to support setting and querying RSS algorithms.

--
v3:
1. fix commit log for PATCH [1/5].
2. make RSS ABI changes description to start the actual text at the margin.
3. move defnition of enum rte_eth_hash_function to rte_ethdev.h.
4. fix some comment codes.

v2:
1. return error if "func" is invalid.
2. modify the comments of the "func" field.
3. modify commit log of patch [3/5].
4. use malloc instead of rte_malloc.
5. adjust display format of RSS info.
6. remove the string display of rss_hf.
--

Huisong Li (1):
  net/hns3: support setting and querying RSS hash function

Jie Hai (4):
  ethdev: support setting and querying RSS algorithm
  app/proc-info: fix never show RSS info
  app/proc-info: adjust the display format of RSS info
  app/proc-info: support querying RSS hash algorithm

 app/proc-info/main.c   | 45 +++-
 doc/guides/rel_notes/release_23_11.rst |  2 ++
 drivers/net/hns3/hns3_rss.c| 47 +++---
 lib/ethdev/rte_ethdev.c| 17 ++
 lib/ethdev/rte_ethdev.h| 20 +++
 lib/ethdev/rte_flow.c  |  1 -
 lib/ethdev/rte_flow.h  | 18 ++
 7 files changed, 104 insertions(+), 46 deletions(-)

-- 
2.33.0



[PATCH 1/5] ethdev: support setting and querying RSS algorithm

2023-09-04 Thread Jie Hai
Currently, rte_eth_rss_conf supports configuring and querying
RSS hash functions, rss key and it's length, but not RSS hash
algorithm.

The structure ``rte_eth_rss_conf`` is extended by adding a new
field "func". This represents the RSS algorithms to apply. The
following API will be affected:
- rte_eth_dev_configure
- rte_eth_dev_rss_hash_update
- rte_eth_dev_rss_hash_conf_get

If the value of "func" used for configuration is a gibberish
value, report the error and return. Do the same for
rte_eth_dev_rss_hash_update and rte_eth_dev_configure.

To check whether the drivers report the "func" field, it is set
to default value before querying.

Signed-off-by: Jie Hai 
Signed-off-by: Dongdong Liu 
---
 doc/guides/rel_notes/release_23_11.rst |  2 ++
 lib/ethdev/rte_ethdev.c| 17 +
 lib/ethdev/rte_ethdev.h| 20 
 lib/ethdev/rte_flow.c  |  1 -
 lib/ethdev/rte_flow.h  | 18 ++
 5 files changed, 41 insertions(+), 17 deletions(-)

diff --git a/doc/guides/rel_notes/release_23_11.rst 
b/doc/guides/rel_notes/release_23_11.rst
index 4411bb32c195..94239170139d 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -123,6 +123,8 @@ ABI Changes
Also, make sure to start the actual text at the margin.
===
 
+* ethdev: Added "func" field to ``rte_eth_rss_conf`` structure for RSS hash
+  algorithm.
 
 Known Issues
 
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 0840d2b5942a..4cbcdb344cac 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -1445,6 +1445,14 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t 
nb_rx_q, uint16_t nb_tx_q,
goto rollback;
}
 
+   if (dev_conf->rx_adv_conf.rss_conf.func >= RTE_ETH_HASH_FUNCTION_MAX) {
+   RTE_ETHDEV_LOG(ERR,
+   "Ethdev port_id=%u invalid rss hash function (%u)\n",
+   port_id, dev_conf->rx_adv_conf.rss_conf.func);
+   ret = -EINVAL;
+   goto rollback;
+   }
+
/* Check if Rx RSS distribution is disabled but RSS hash is enabled. */
if (((dev_conf->rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) == 0) &&
(dev_conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH)) {
@@ -4630,6 +4638,13 @@ rte_eth_dev_rss_hash_update(uint16_t port_id,
return -ENOTSUP;
}
 
+   if (rss_conf->func >= RTE_ETH_HASH_FUNCTION_MAX) {
+   RTE_ETHDEV_LOG(ERR,
+   "Ethdev port_id=%u invalid rss hash function (%u)\n",
+   port_id, rss_conf->func);
+   return -EINVAL;
+   }
+
if (*dev->dev_ops->rss_hash_update == NULL)
return -ENOTSUP;
ret = eth_err(port_id, (*dev->dev_ops->rss_hash_update)(dev,
@@ -4657,6 +4672,8 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
return -EINVAL;
}
 
+   rss_conf->func = RTE_ETH_HASH_FUNCTION_DEFAULT;
+
if (*dev->dev_ops->rss_hash_conf_get == NULL)
return -ENOTSUP;
ret = eth_err(port_id, (*dev->dev_ops->rss_hash_conf_get)(dev,
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index 04a2564f222a..1fe3c0a502ac 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -445,6 +445,22 @@ struct rte_vlan_filter_conf {
uint64_t ids[64];
 };
 
+/**
+ * Hash function types.
+ */
+enum rte_eth_hash_function {
+   RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
+   RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
+   RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
+   /**
+* Symmetric Toeplitz: src, dst will be replaced by
+* xor(src, dst). For the case with src/dst only,
+* src or dst address will xor with zero pair.
+*/
+   RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
+   RTE_ETH_HASH_FUNCTION_MAX,
+};
+
 /**
  * A structure used to configure the Receive Side Scaling (RSS) feature
  * of an Ethernet port.
@@ -461,11 +477,15 @@ struct rte_vlan_filter_conf {
  * The *rss_hf* field of the *rss_conf* structure indicates the different
  * types of IPv4/IPv6 packets to which the RSS hashing must be applied.
  * Supplying an *rss_hf* equal to zero disables the RSS feature.
+ *
+ * The *func* field of the *rss_conf* structure indicates the hash algorithm
+ * applied by the RSS hashing.
  */
 struct rte_eth_rss_conf {
uint8_t *rss_key;/**< If not NULL, 40-byte hash key. */
uint8_t rss_key_len; /**< hash key length in bytes. */
uint64_t rss_hf; /**< Hash functions to apply - see below. */
+   enum rte_eth_hash_function func;/**< Hash 

Re: [PATCH v3 0/5] support setting and querying RSS algorithms

2023-09-04 Thread Jie Hai

Hi, ALL

Sorry, please drop this patchset.
Here is V3
https://inbox.dpdk.org/dev/20230904072851.7384-1-haij...@huawei.com/

Thanks,
Jie Hai

On 2023/9/4 14:10, Jie Hai wrote:

This patchset is to support setting and querying RSS algorithms.

--
v3:
1. fix commit log for PATCH [1/5].
2. make RSS ABI changes description to start the actual text at the margin.
3. move defnition of enum rte_eth_hash_function to rte_ethdev.h.
4. fix some comment codes.

v2:
1. return error if "func" is invalid.
2. modify the comments of the "func" field.
3. modify commit log of patch [3/5].
4. use malloc instead of rte_malloc.
5. adjust display format of RSS info.
6. remove the string display of rss_hf.
--


Jie Hai (5):
   app/proc-info: fix never show RSS info
   app/proc-info: adjust the display format of RSS info
   app/proc-info: support querying RSS hash algorithm
   app/testpmd: add RSS hash algorithms display
   app/testpmd: add RSS hash algorithms setting

  app/proc-info/main.c   |  45 ---
  app/test-pmd/cmdline.c | 128 ++---
  app/test-pmd/config.c  |  62 +++-
  app/test-pmd/testpmd.h |   5 +-
  4 files changed, 194 insertions(+), 46 deletions(-)



Re: [PATCH 3/5] app/proc-info: fix never show RSS info

2023-09-08 Thread Jie Hai

Hi, Pattan, Reshma

On 2023/9/6 0:29, Pattan, Reshma wrote:




-Original Message-
+   uint8_t *rss_key;


Instead of pointer can you just take key of type below, so u no need to do 
dynamic memory allocation using malloc and free .
  
Ex: uint8_t hash_key[RSS_HASH_KEY_LENGTH];


And then do below ?
rss_conf.rss_key = hash_key;
.


Thanks for your review, will fix it in next version.

Thanks,
Jie Hai


Re: [PATCH 5/5] app/proc-info: support querying RSS hash algorithm

2023-09-08 Thread Jie Hai

Hi, Pattan, Reshma

On 2023/9/6 1:07, Pattan, Reshma wrote:


Instead of above function you can declare const array of strings as below to 
map hash function names.

static const char * const hf_names[] = {
 [RTE_ETH_HASH_FUNCTION_SIMPLE_XOR] = " simple_xor ",
 [RTE_ETH_HASH_FUNCTION_TOEPLITZ] = " toeplitz ",
 [RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ] = " symmetric_toeplitz ",
 [RTE_ETH_HASH_FUNCTION_DEFAULT] = "default"
};



+   printf("\t  -- hash algorithm : %s\n",
+   rss_func_to_str(rss_conf.func));
}


And then print  as below ?
printf("\t  -- hash algorithm : %s\n", hf_names [rss_conf.func]);
.

Thanks for your review, that sounds better, will fix it.

Thanks,
Jie Hai


[PATCH v4 0/7] support setting and querying RSS algorithms

2023-09-08 Thread Jie Hai
This patchset is to support setting and querying RSS algorithms.

--
v4:
1. recomment some definitions related to RSS.
2. allocate static memory for rss_key instead of dynamic.
3. use array of strings to get the name of rss algorithm.
4. add display of rss algorithm with testpmd.

v3:
1. fix commit log for PATCH [1/5].
2. make RSS ABI changes description to start the actual text at the margin.
3. move defnition of enum rte_eth_hash_function to rte_ethdev.h.
4. fix some comment codes.

v2:
1. return error if "func" is invalid.
2. modify the comments of the "func" field.
3. modify commit log of patch [3/5].
4. use malloc instead of rte_malloc.
5. adjust display format of RSS info.
6. remove the string display of rss_hf.


Huisong Li (1):
  net/hns3: support setting and querying RSS hash function

Jie Hai (6):
  ethdev: recomment some definitions related to RSS
  ethdev: support setting and querying RSS algorithm
  app/proc-info: fix never show RSS info
  app/proc-info: adjust the display format of RSS info
  app/proc-info: support querying RSS hash algorithm
  app/testpmd: add RSS hash algorithms display

 app/proc-info/main.c   | 31 +++-
 app/test-pmd/cmdline.c | 29 ---
 app/test-pmd/config.c  | 36 +--
 app/test-pmd/testpmd.h |  2 +-
 doc/guides/rel_notes/release_23_11.rst |  2 ++
 drivers/net/hns3/hns3_rss.c| 47 +---
 lib/ethdev/rte_ethdev.c| 17 +
 lib/ethdev/rte_ethdev.h| 49 ++
 lib/ethdev/rte_flow.c  |  1 -
 lib/ethdev/rte_flow.h  | 18 ++
 10 files changed, 146 insertions(+), 86 deletions(-)

-- 
2.30.0



[PATCH v4 1/7] ethdev: recomment some definitions related to RSS

2023-09-08 Thread Jie Hai
1. Recomment fields of 'rte_eth_rss_conf'.
2. Add comments for RTE_ETH_HASH_FUNCTION_DEFAULT.

Signed-off-by: Jie Hai 
---
 lib/ethdev/rte_ethdev.h | 28 +---
 lib/ethdev/rte_flow.h   |  4 
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index 04a2564f222a..40cfbb7efddd 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -448,24 +448,22 @@ struct rte_vlan_filter_conf {
 /**
  * A structure used to configure the Receive Side Scaling (RSS) feature
  * of an Ethernet port.
- * If not NULL, the *rss_key* pointer of the *rss_conf* structure points
- * to an array holding the RSS key to use for hashing specific header
- * fields of received packets. The length of this array should be indicated
- * by *rss_key_len* below. Otherwise, a default random hash key is used by
- * the device driver.
- *
- * The *rss_key_len* field of the *rss_conf* structure indicates the length
- * in bytes of the array pointed by *rss_key*. To be compatible, this length
- * will be checked in i40e only. Others assume 40 bytes to be used as before.
- *
- * The *rss_hf* field of the *rss_conf* structure indicates the different
- * types of IPv4/IPv6 packets to which the RSS hashing must be applied.
- * Supplying an *rss_hf* equal to zero disables the RSS feature.
  */
 struct rte_eth_rss_conf {
-   uint8_t *rss_key;/**< If not NULL, 40-byte hash key. */
+   /**
+* If not NULL, 40-byte hash key to use for hashing specific header
+* fields of received packets. The size of rss_key should be indicated
+* by *rss_key_len* below.
+* Otherwise, a default random hash key is used by the device driver.
+*/
+   uint8_t *rss_key;
uint8_t rss_key_len; /**< hash key length in bytes. */
-   uint64_t rss_hf; /**< Hash functions to apply - see below. */
+   /**
+* The different types of packets to which the RSS hashing must be
+* applied, may be combined with SRC/DST_ONLY, see below.
+* Supplying an *rss_hf* equal to zero disables the RSS feature.
+*/
+   uint64_t rss_hf;
 };
 
 /*
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index 2ebb76dbc083..3bd0dc64fbe2 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -3187,6 +3187,10 @@ struct rte_flow_query_count {
  * Hash function types.
  */
 enum rte_eth_hash_function {
+   /**
+* DEFAULT means that conformance to a specific hash algorithm is
+* uncared to the caller. The driver can pick the one it deems optimal.
+*/
RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
-- 
2.30.0



[PATCH v4 2/7] ethdev: support setting and querying RSS algorithm

2023-09-08 Thread Jie Hai
Currently, rte_eth_rss_conf supports configuring and querying
RSS hash functions, rss key and it's length, but not RSS hash
algorithm.

The structure ``rte_eth_rss_conf`` is extended by adding a new
field "func". This represents the RSS algorithms to apply. The
following API will be affected:
- rte_eth_dev_configure
- rte_eth_dev_rss_hash_update
- rte_eth_dev_rss_hash_conf_get

If the value of "func" used for configuration is a gibberish
value, report the error and return. Do the same for
rte_eth_dev_rss_hash_update and rte_eth_dev_configure.

To check whether the drivers report the "func" field, it is set
to default value before querying.

Signed-off-by: Jie Hai 
Signed-off-by: Dongdong Liu 
---
 doc/guides/rel_notes/release_23_11.rst |  2 ++
 lib/ethdev/rte_ethdev.c| 17 +
 lib/ethdev/rte_ethdev.h| 21 +
 lib/ethdev/rte_flow.c  |  1 -
 lib/ethdev/rte_flow.h  | 22 ++
 5 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/doc/guides/rel_notes/release_23_11.rst 
b/doc/guides/rel_notes/release_23_11.rst
index 333e1d95a283..deb019fbe4c1 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -129,6 +129,8 @@ ABI Changes
Also, make sure to start the actual text at the margin.
===
 
+* ethdev: Added "func" field to ``rte_eth_rss_conf`` structure for RSS hash
+  algorithm.
 
 Known Issues
 
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 0840d2b5942a..4cbcdb344cac 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -1445,6 +1445,14 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t 
nb_rx_q, uint16_t nb_tx_q,
goto rollback;
}
 
+   if (dev_conf->rx_adv_conf.rss_conf.func >= RTE_ETH_HASH_FUNCTION_MAX) {
+   RTE_ETHDEV_LOG(ERR,
+   "Ethdev port_id=%u invalid rss hash function (%u)\n",
+   port_id, dev_conf->rx_adv_conf.rss_conf.func);
+   ret = -EINVAL;
+   goto rollback;
+   }
+
/* Check if Rx RSS distribution is disabled but RSS hash is enabled. */
if (((dev_conf->rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) == 0) &&
(dev_conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH)) {
@@ -4630,6 +4638,13 @@ rte_eth_dev_rss_hash_update(uint16_t port_id,
return -ENOTSUP;
}
 
+   if (rss_conf->func >= RTE_ETH_HASH_FUNCTION_MAX) {
+   RTE_ETHDEV_LOG(ERR,
+   "Ethdev port_id=%u invalid rss hash function (%u)\n",
+   port_id, rss_conf->func);
+   return -EINVAL;
+   }
+
if (*dev->dev_ops->rss_hash_update == NULL)
return -ENOTSUP;
ret = eth_err(port_id, (*dev->dev_ops->rss_hash_update)(dev,
@@ -4657,6 +4672,8 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
return -EINVAL;
}
 
+   rss_conf->func = RTE_ETH_HASH_FUNCTION_DEFAULT;
+
if (*dev->dev_ops->rss_hash_conf_get == NULL)
return -ENOTSUP;
ret = eth_err(port_id, (*dev->dev_ops->rss_hash_conf_get)(dev,
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index 40cfbb7efddd..33cec3570f85 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -445,6 +445,26 @@ struct rte_vlan_filter_conf {
uint64_t ids[64];
 };
 
+/**
+ * Hash function types.
+ */
+enum rte_eth_hash_function {
+   /**
+* DEFAULT means that conformance to a specific hash algorithm is
+* uncared to the caller. The driver can pick the one it deems optimal.
+*/
+   RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
+   RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
+   RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
+   /**
+* Symmetric Toeplitz: src, dst will be replaced by
+* xor(src, dst). For the case with src/dst only,
+* src or dst address will xor with zero pair.
+*/
+   RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
+   RTE_ETH_HASH_FUNCTION_MAX,
+};
+
 /**
  * A structure used to configure the Receive Side Scaling (RSS) feature
  * of an Ethernet port.
@@ -464,6 +484,7 @@ struct rte_eth_rss_conf {
 * Supplying an *rss_hf* equal to zero disables the RSS feature.
 */
uint64_t rss_hf;
+   enum rte_eth_hash_function func;/**< Hash algorithm. */
 };
 
 /*
diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index 271d854f7807..d3f2d466d841 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include "rte_ethdev.h"
 #include "rte

[PATCH v4 3/7] net/hns3: support setting and querying RSS hash function

2023-09-08 Thread Jie Hai
From: Huisong Li 

Support setting and querying RSS hash function by ethdev ops.

Signed-off-by: Huisong Li 
Signed-off-by: Dongdong Liu 
---
 drivers/net/hns3/hns3_rss.c | 47 +
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 6126512bd780..c8346d43d15c 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -646,14 +646,14 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
if (ret)
goto set_tuple_fail;
 
-   if (key) {
-   ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo,
-   key, hw->rss_key_size);
-   if (ret)
-   goto set_algo_key_fail;
-   /* Update the shadow RSS key with user specified */
+   ret = hns3_update_rss_algo_key(hw, rss_conf->func, key, key_len);
+   if (ret != 0)
+   goto set_algo_key_fail;
+
+   if (rss_conf->func != RTE_ETH_HASH_FUNCTION_DEFAULT)
+   hw->rss_info.hash_algo = hns3_hash_func_map[rss_conf->func];
+   if (key != NULL)
memcpy(hw->rss_info.key, key, hw->rss_key_size);
-   }
hw->rss_info.rss_hf = rss_hf;
rte_spinlock_unlock(&hw->lock);
 
@@ -769,7 +769,13 @@ int
 hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
   struct rte_eth_rss_conf *rss_conf)
 {
+   const uint8_t hash_func_map[] = {
+   [HNS3_RSS_HASH_ALGO_TOEPLITZ] = RTE_ETH_HASH_FUNCTION_TOEPLITZ,
+   [HNS3_RSS_HASH_ALGO_SIMPLE] = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR,
+   [HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP] = 
RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
+   };
struct hns3_adapter *hns = dev->data->dev_private;
+   uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0};
struct hns3_hw *hw = &hns->hw;
uint8_t hash_algo;
int ret;
@@ -777,26 +783,27 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
rte_spinlock_lock(&hw->lock);
ret = hns3_rss_hash_get_rss_hf(hw, &rss_conf->rss_hf);
if (ret != 0) {
+   rte_spinlock_unlock(&hw->lock);
hns3_err(hw, "obtain hash tuples failed, ret = %d", ret);
-   goto out;
+   return ret;
+   }
+
+   ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_key, hw->rss_key_size);
+   if (ret != 0) {
+   rte_spinlock_unlock(&hw->lock);
+   hns3_err(hw, "obtain hash algo and key failed, ret = %d", ret);
+   return ret;
}
+   rte_spinlock_unlock(&hw->lock);
 
-   /* Get the RSS Key required by the user */
+   /* Get the RSS Key if user required. */
if (rss_conf->rss_key && rss_conf->rss_key_len >= hw->rss_key_size) {
-   ret = hns3_rss_get_algo_key(hw, &hash_algo, rss_conf->rss_key,
-   hw->rss_key_size);
-   if (ret != 0) {
-   hns3_err(hw, "obtain hash algo and key failed, ret = 
%d",
-ret);
-   goto out;
-   }
+   memcpy(rss_conf->rss_key, rss_key, hw->rss_key_size);
rss_conf->rss_key_len = hw->rss_key_size;
}
+   rss_conf->func = hash_func_map[hash_algo];
 
-out:
-   rte_spinlock_unlock(&hw->lock);
-
-   return ret;
+   return 0;
 }
 
 /*
-- 
2.30.0



[PATCH v4 4/7] app/proc-info: fix never show RSS info

2023-09-08 Thread Jie Hai
Command show-port should show RSS info (rss_key, len and rss_hf),
However, the information is shown only when rss_conf.rss_key is not
NULL. Since no memory is allocated for rss_conf.rss_key, rss_key
will always be NULL and the rss_info will never show. This patch
allocates memory for rss_conf.rss_key and makes it possible to show
RSS info.

Fixes: 8a37f37fc243 ("app/procinfo: add --show-port")
Cc: sta...@dpdk.org

Signed-off-by: Jie Hai 
Signed-off-by: Dongdong Liu 
---
 app/proc-info/main.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 88cee0ca487b..95dd4514b3c9 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -152,6 +152,8 @@ struct desc_param {
 static struct desc_param rx_desc_param;
 static struct desc_param tx_desc_param;
 
+#define RSS_HASH_KEY_SIZE 64
+
 /* display usage */
 static void
 proc_info_usage(const char *prgname)
@@ -1013,6 +1015,7 @@ show_port(void)
struct rte_eth_fc_conf fc_conf;
struct rte_ether_addr mac;
struct rte_eth_dev_owner owner;
+   uint8_t rss_key[RSS_HASH_KEY_SIZE];
 
/* Skip if port is not in mask */
if ((enabled_port_mask & (1ul << i)) == 0)
@@ -1171,17 +1174,17 @@ show_port(void)
printf("\n");
}
 
+   rss_conf.rss_key = rss_key;
+   rss_conf.rss_key_len = dev_info.hash_key_size;
ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
if (ret == 0) {
-   if (rss_conf.rss_key) {
-   printf("  - RSS\n");
-   printf("\t  -- RSS len %u key (hex):",
-   rss_conf.rss_key_len);
-   for (k = 0; k < rss_conf.rss_key_len; k++)
-   printf(" %x", rss_conf.rss_key[k]);
-   printf("\t  -- hf 0x%"PRIx64"\n",
-   rss_conf.rss_hf);
-   }
+   printf("  - RSS\n");
+   printf("\t  -- RSS len %u key (hex):",
+   rss_conf.rss_key_len);
+   for (k = 0; k < rss_conf.rss_key_len; k++)
+   printf(" %x", rss_conf.rss_key[k]);
+   printf("\t  -- hf 0x%"PRIx64"\n",
+   rss_conf.rss_hf);
}
 
 #ifdef RTE_LIB_SECURITY
-- 
2.30.0



  1   2   3   4   5   6   7   8   9   10   >