From: Xueming Li <xuemingl@nvidia.com>
To: Matan Azrad <matan@nvidia.com>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
Ori Kam <orika@nvidia.com>, Suanming Mou <suanmingm@nvidia.com>
Cc: <xuemingl@nvidia.com>, <dev@dpdk.org>
Subject: [PATCH] net/mlx5: support symmetric RSS hash function
Date: Fri, 30 Jun 2023 15:37:44 +0800 [thread overview]
Message-ID: <20230630073744.16247-1-xuemingl@nvidia.com> (raw)
This patch supports symmetric hash function that creating same
hash result for bi-direction traffic which having reverse
source and destination IP and L4 port.
Since the hash algorithom is different than spec(XOR), leave a
warning in validation.
Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
drivers/net/mlx5/mlx5.h | 3 +++
drivers/net/mlx5/mlx5_devx.c | 11 ++++++++---
drivers/net/mlx5/mlx5_flow.c | 10 ++++++++--
drivers/net/mlx5/mlx5_flow.h | 5 +++++
drivers/net/mlx5/mlx5_flow_dv.c | 13 ++++++++++++-
drivers/net/mlx5/mlx5_flow_hw.c | 7 +++++++
drivers/net/mlx5/mlx5_rx.h | 2 +-
drivers/net/mlx5/mlx5_rxq.c | 8 +++++---
8 files changed, 49 insertions(+), 10 deletions(-)
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 2a82348135..b7534933bc 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -1509,6 +1509,7 @@ struct mlx5_mtr_config {
/* RSS description. */
struct mlx5_flow_rss_desc {
+ bool symmetric_hash_function; /**< Symmetric hash function */
uint32_t level;
uint32_t queue_num; /**< Number of entries in @p queue. */
uint64_t types; /**< Specific RSS hash types (see RTE_ETH_RSS_*). */
@@ -1577,6 +1578,7 @@ struct mlx5_hrxq {
#if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
void *action; /* DV QP action pointer. */
#endif
+ bool symmetric_hash_function; /* Symmetric hash function */
uint32_t hws_flags; /* Hw steering flags. */
uint64_t hash_fields; /* Verbs Hash fields. */
uint32_t rss_key_len; /* Hash key length in bytes. */
@@ -1648,6 +1650,7 @@ struct mlx5_obj_ops {
int (*hrxq_modify)(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq,
const uint8_t *rss_key,
uint64_t hash_fields,
+ bool symmetric_hash_function,
const struct mlx5_ind_table_obj *ind_tbl);
void (*hrxq_destroy)(struct mlx5_hrxq *hrxq);
int (*drop_action_create)(struct rte_eth_dev *dev);
diff --git a/drivers/net/mlx5/mlx5_devx.c b/drivers/net/mlx5/mlx5_devx.c
index 4369d2557e..f9d8dc6987 100644
--- a/drivers/net/mlx5/mlx5_devx.c
+++ b/drivers/net/mlx5/mlx5_devx.c
@@ -803,7 +803,8 @@ static void
mlx5_devx_tir_attr_set(struct rte_eth_dev *dev, const uint8_t *rss_key,
uint64_t hash_fields,
const struct mlx5_ind_table_obj *ind_tbl,
- int tunnel, struct mlx5_devx_tir_attr *tir_attr)
+ int tunnel, bool symmetric_hash_function,
+ struct mlx5_devx_tir_attr *tir_attr)
{
struct mlx5_priv *priv = dev->data->dev_private;
bool is_hairpin;
@@ -834,6 +835,7 @@ mlx5_devx_tir_attr_set(struct rte_eth_dev *dev, const uint8_t *rss_key,
tir_attr->disp_type = MLX5_TIRC_DISP_TYPE_INDIRECT;
tir_attr->rx_hash_fn = MLX5_RX_HASH_FN_TOEPLITZ;
tir_attr->tunneled_offload_en = !!tunnel;
+ tir_attr->rx_hash_symmetric = symmetric_hash_function;
/* If needed, translate hash_fields bitmap to PRM format. */
if (hash_fields) {
struct mlx5_rx_hash_field_select *rx_hash_field_select =
@@ -902,7 +904,8 @@ mlx5_devx_hrxq_new(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq,
int err;
mlx5_devx_tir_attr_set(dev, hrxq->rss_key, hrxq->hash_fields,
- hrxq->ind_table, tunnel, &tir_attr);
+ hrxq->ind_table, tunnel, hrxq->symmetric_hash_function,
+ &tir_attr);
hrxq->tir = mlx5_devx_cmd_create_tir(priv->sh->cdev->ctx, &tir_attr);
if (!hrxq->tir) {
DRV_LOG(ERR, "Port %u cannot create DevX TIR.",
@@ -969,13 +972,13 @@ static int
mlx5_devx_hrxq_modify(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq,
const uint8_t *rss_key,
uint64_t hash_fields,
+ bool symmetric_hash_function,
const struct mlx5_ind_table_obj *ind_tbl)
{
struct mlx5_devx_modify_tir_attr modify_tir = {0};
/*
* untested for modification fields:
- * - rx_hash_symmetric not set in hrxq_new(),
* - rx_hash_fn set hard-coded in hrxq_new(),
* - lro_xxx not set after rxq setup
*/
@@ -983,11 +986,13 @@ mlx5_devx_hrxq_modify(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq,
modify_tir.modify_bitmask |=
MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_INDIRECT_TABLE;
if (hash_fields != hrxq->hash_fields ||
+ symmetric_hash_function != hrxq->symmetric_hash_function ||
memcmp(hrxq->rss_key, rss_key, MLX5_RSS_HASH_KEY_LEN))
modify_tir.modify_bitmask |=
MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_HASH;
mlx5_devx_tir_attr_set(dev, rss_key, hash_fields, ind_tbl,
0, /* N/A - tunnel modification unsupported */
+ symmetric_hash_function,
&modify_tir.tir);
modify_tir.tirn = hrxq->tir->id;
if (mlx5_devx_cmd_modify_tir(hrxq->tir, &modify_tir)) {
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index cf83db7b60..8143ac96dc 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -2163,8 +2163,11 @@ mlx5_validate_action_rss(struct rte_eth_dev *dev,
const char *message;
uint32_t queue_idx;
- if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT &&
- rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ)
+ if (rss->func == RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ) {
+ DRV_LOG(WARNING, "port %u symmetric RSS supported with SORT",
+ dev->data->port_id);
+ } else if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT &&
+ rss->func != RTE_ETH_HASH_FUNCTION_TOEPLITZ)
return rte_flow_error_set(error, ENOTSUP,
RTE_FLOW_ERROR_TYPE_ACTION_CONF,
&rss->func,
@@ -5577,6 +5580,8 @@ get_meter_sub_policy(struct rte_eth_dev *dev,
items, rss_actions, error))
goto exit;
rss_desc_v[i] = wks->rss_desc;
+ rss_desc_v[i].symmetric_hash_function =
+ dev_flow.symmetri_hash_function;
rss_desc_v[i].key_len = MLX5_RSS_HASH_KEY_LEN;
rss_desc_v[i].hash_fields =
dev_flow.hash_fields;
@@ -7305,6 +7310,7 @@ flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,
if (rss) {
if (flow_rss_workspace_adjust(wks, rss_desc, rss->queue_num))
return 0;
+ rss_desc->symmetric_hash_function = MLX5_RSS_IS_SYMM(rss->func);
/*
* The following information is required by
* mlx5_flow_hashfields_adjust() in advance.
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 003e7da3a6..1aaacb22bd 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -900,6 +900,7 @@ struct mlx5_flow {
bool external; /**< true if the flow is created external to PMD. */
uint8_t ingress:1; /**< 1 if the flow is ingress. */
uint8_t skip_scale:2;
+ uint8_t symmetri_hash_function:1;
/**
* Each Bit be set to 1 if Skip the scale the flow group with factor.
* If bit0 be set to 1, then skip the scale the original flow group;
@@ -1249,6 +1250,7 @@ struct mlx5_action_construct_data {
uint32_t mask[MLX5_ACT_MAX_MOD_FIELDS];
} modify_header;
struct {
+ bool symmetric_hash_function; /* Symmetric RSS hash */
uint64_t types; /* RSS hash types. */
uint32_t level; /* RSS level. */
uint32_t idx; /* Shared action index. */
@@ -1452,6 +1454,9 @@ struct rte_flow_template_table {
MLX5_RSS_HASH_ESP_SPI)
#define MLX5_RSS_HASH_NONE 0ULL
+#define MLX5_RSS_IS_SYMM(func) \
+ ((func) == RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ)
+
/* extract next protocol type from Ethernet & VLAN headers */
#define MLX5_ETHER_TYPE_FROM_HEADER(_s, _m, _itm, _prt) do { \
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 8290d085ba..375fd9cd9c 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -12006,6 +12006,7 @@ flow_dv_hrxq_prepare(struct rte_eth_dev *dev,
struct mlx5_hrxq *hrxq;
MLX5_ASSERT(rss_desc->queue_num);
+ rss_desc->symmetric_hash_function = dev_flow->symmetri_hash_function;
rss_desc->key_len = MLX5_RSS_HASH_KEY_LEN;
rss_desc->hash_fields = dev_flow->hash_fields;
rss_desc->tunnel = !!(dh->layers & MLX5_FLOW_LAYER_TUNNEL);
@@ -12550,6 +12551,8 @@ flow_dv_translate_action_sample(struct rte_eth_dev *dev,
const uint8_t *rss_key;
rss = sub_actions->conf;
+ rss_desc->symmetric_hash_function =
+ MLX5_RSS_IS_SYMM(rss->func);
memcpy(rss_desc->queue, rss->queue,
rss->queue_num * sizeof(uint16_t));
rss_desc->queue_num = rss->queue_num;
@@ -14478,6 +14481,8 @@ flow_dv_translate(struct rte_eth_dev *dev,
break;
case RTE_FLOW_ACTION_TYPE_RSS:
rss = actions->conf;
+ rss_desc->symmetric_hash_function =
+ MLX5_RSS_IS_SYMM(rss->func);
memcpy(rss_desc->queue, rss->queue,
rss->queue_num * sizeof(uint16_t));
rss_desc->queue_num = rss->queue_num;
@@ -14944,10 +14949,12 @@ flow_dv_translate(struct rte_eth_dev *dev,
error);
if (ret)
return -rte_errno;
- if (action_flags & MLX5_FLOW_ACTION_RSS)
+ if (action_flags & MLX5_FLOW_ACTION_RSS) {
+ dev_flow->symmetri_hash_function = rss_desc->symmetric_hash_function;
flow_dv_hashfields_set(dev_flow->handle->layers,
rss_desc,
&dev_flow->hash_fields);
+ }
/* If has RSS action in the sample action, the Sample/Mirror resource
* should be registered after the hash filed be update.
*/
@@ -16022,6 +16029,8 @@ __flow_dv_action_rss_setup(struct rte_eth_dev *dev,
"cannot setup indirection table");
memcpy(rss_desc.key, shared_rss->origin.key, MLX5_RSS_HASH_KEY_LEN);
rss_desc.key_len = MLX5_RSS_HASH_KEY_LEN;
+ rss_desc.symmetric_hash_function =
+ MLX5_RSS_IS_SYMM(shared_rss->origin.func);
rss_desc.const_q = shared_rss->origin.queue;
rss_desc.queue_num = shared_rss->origin.queue_num;
/* Set non-zero value to indicate a shared RSS. */
@@ -19146,6 +19155,8 @@ flow_dv_mtr_policy_rss_compare(const struct rte_flow_action_rss *r1,
if (!(r1->level <= 1 && r2->level <= 1) &&
!(r1->level > 1 && r2->level > 1))
return 1;
+ if (r1->func != r2->func)
+ return 1;
if (r1->types != r2->types &&
!((r1->types == 0 || r1->types == RTE_ETH_RSS_IP) &&
(r2->types == 0 || r2->types == RTE_ETH_RSS_IP)))
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index b5137a822a..3dc1810bd7 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -405,6 +405,7 @@ flow_hw_tir_action_register(struct rte_eth_dev *dev,
MLX5_RSS_HASH_KEY_LEN);
rss_desc.key_len = MLX5_RSS_HASH_KEY_LEN;
rss_desc.types = !rss->types ? RTE_ETH_RSS_IP : rss->types;
+ rss_desc.symmetric_hash_function = MLX5_RSS_IS_SYMM(rss->func);
flow_hw_hashfields_set(&rss_desc, &rss_desc.hash_fields);
flow_dv_action_rss_l34_hash_adjust(rss->types,
&rss_desc.hash_fields);
@@ -674,6 +675,8 @@ __flow_hw_act_data_shared_rss_append(struct mlx5_priv *priv,
act_data->shared_rss.types = !rss->origin.types ? RTE_ETH_RSS_IP :
rss->origin.types;
act_data->shared_rss.idx = idx;
+ act_data->shared_rss.symmetric_hash_function =
+ MLX5_RSS_IS_SYMM(rss->origin.func);
LIST_INSERT_HEAD(&acts->act_list, act_data, next);
return 0;
}
@@ -1911,6 +1914,7 @@ flow_hw_shared_action_get(struct rte_eth_dev *dev,
case MLX5_RTE_FLOW_ACTION_TYPE_RSS:
rss_desc.level = act_data->shared_rss.level;
rss_desc.types = act_data->shared_rss.types;
+ rss_desc.symmetric_hash_function = act_data->shared_rss.symmetric_hash_function;
flow_dv_hashfields_set(item_flags, &rss_desc, &hash_fields);
hrxq_idx = flow_dv_action_rss_hrxq_lookup
(dev, act_data->shared_rss.idx, hash_fields);
@@ -1998,6 +2002,9 @@ flow_hw_shared_action_construct(struct rte_eth_dev *dev, uint32_t queue,
act_data.shared_rss.types = !shared_rss->origin.types ?
RTE_ETH_RSS_IP :
shared_rss->origin.types;
+ act_data.shared_rss.symmetric_hash_function =
+ MLX5_RSS_IS_SYMM(shared_rss->origin.func);
+
item_flags = table->its[it_idx]->item_flags;
if (flow_hw_shared_action_get
(dev, &act_data, item_flags, rule_act))
diff --git a/drivers/net/mlx5/mlx5_rx.h b/drivers/net/mlx5/mlx5_rx.h
index 3514edd84e..690eb25aae 100644
--- a/drivers/net/mlx5/mlx5_rx.h
+++ b/drivers/net/mlx5/mlx5_rx.h
@@ -284,7 +284,7 @@ uint64_t mlx5_get_rx_queue_offloads(struct rte_eth_dev *dev);
void mlx5_rxq_timestamp_set(struct rte_eth_dev *dev);
int mlx5_hrxq_modify(struct rte_eth_dev *dev, uint32_t hxrq_idx,
const uint8_t *rss_key, uint32_t rss_key_len,
- uint64_t hash_fields,
+ uint64_t hash_fields, bool symmetric_hash_function,
const uint16_t *queues, uint32_t queues_n);
/* mlx5_rx.c */
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index ad8fd13cbe..7d0ecc1126 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -2759,6 +2759,7 @@ mlx5_hrxq_match_cb(void *tool_ctx __rte_unused, struct mlx5_list_entry *entry,
struct mlx5_hrxq *hrxq = container_of(entry, typeof(*hrxq), entry);
return (hrxq->rss_key_len != rss_desc->key_len ||
+ hrxq->symmetric_hash_function != rss_desc->symmetric_hash_function ||
memcmp(hrxq->rss_key, rss_desc->key, rss_desc->key_len) ||
hrxq->hws_flags != rss_desc->hws_flags ||
hrxq->hash_fields != rss_desc->hash_fields ||
@@ -2792,7 +2793,7 @@ mlx5_hrxq_match_cb(void *tool_ctx __rte_unused, struct mlx5_list_entry *entry,
int
mlx5_hrxq_modify(struct rte_eth_dev *dev, uint32_t hrxq_idx,
const uint8_t *rss_key, uint32_t rss_key_len,
- uint64_t hash_fields,
+ uint64_t hash_fields, bool symmetric_hash_function,
const uint16_t *queues, uint32_t queues_n)
{
int err;
@@ -2837,8 +2838,8 @@ mlx5_hrxq_modify(struct rte_eth_dev *dev, uint32_t hrxq_idx,
return -rte_errno;
}
MLX5_ASSERT(priv->obj_ops.hrxq_modify);
- ret = priv->obj_ops.hrxq_modify(dev, hrxq, rss_key,
- hash_fields, ind_tbl);
+ ret = priv->obj_ops.hrxq_modify(dev, hrxq, rss_key, hash_fields,
+ symmetric_hash_function, ind_tbl);
if (ret) {
rte_errno = errno;
goto error;
@@ -2938,6 +2939,7 @@ __mlx5_hrxq_create(struct rte_eth_dev *dev,
hrxq->rss_key_len = rss_key_len;
hrxq->hash_fields = rss_desc->hash_fields;
hrxq->hws_flags = rss_desc->hws_flags;
+ hrxq->symmetric_hash_function = rss_desc->symmetric_hash_function;
memcpy(hrxq->rss_key, rss_key, rss_key_len);
ret = priv->obj_ops.hrxq_new(dev, hrxq, rss_desc->tunnel);
if (ret < 0)
--
2.25.1
next reply other threads:[~2023-06-30 7:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-30 7:37 Xueming Li [this message]
2023-06-30 7:54 ` [PATCH v1] " Xueming Li
2023-07-04 8:27 ` Ori Kam
2023-07-06 11:55 ` [PATCH v2] " Xueming Li
2023-07-06 15:07 ` Matan Azrad
2023-07-06 15:17 ` Raslan Darawsheh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230630073744.16247-1-xuemingl@nvidia.com \
--to=xuemingl@nvidia.com \
--cc=dev@dpdk.org \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=suanmingm@nvidia.com \
--cc=viacheslavo@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).