* [PATCH] net/mlx5: support symmetric RSS hash function
@ 2023-06-30 7:37 Xueming Li
2023-06-30 7:54 ` [PATCH v1] " Xueming Li
2023-07-06 11:55 ` [PATCH v2] " Xueming Li
0 siblings, 2 replies; 6+ messages in thread
From: Xueming Li @ 2023-06-30 7:37 UTC (permalink / raw)
To: Matan Azrad, Viacheslav Ovsiienko, Ori Kam, Suanming Mou; +Cc: xuemingl, dev
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1] net/mlx5: support symmetric RSS hash function
2023-06-30 7:37 [PATCH] net/mlx5: support symmetric RSS hash function Xueming Li
@ 2023-06-30 7:54 ` Xueming Li
2023-07-04 8:27 ` Ori Kam
2023-07-06 11:55 ` [PATCH v2] " Xueming Li
1 sibling, 1 reply; 6+ messages in thread
From: Xueming Li @ 2023-06-30 7:54 UTC (permalink / raw)
To: Matan Azrad, Viacheslav Ovsiienko, Ori Kam, Suanming Mou; +Cc: xuemingl, dev
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..6c1703bbed 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.symmetric_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..79d7907ac2 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 symmetric_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..a8dd9920e6 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->symmetric_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->symmetric_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
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH v1] net/mlx5: support symmetric RSS hash function
2023-06-30 7:54 ` [PATCH v1] " Xueming Li
@ 2023-07-04 8:27 ` Ori Kam
0 siblings, 0 replies; 6+ messages in thread
From: Ori Kam @ 2023-07-04 8:27 UTC (permalink / raw)
To: Xueming(Steven) Li, Matan Azrad, Slava Ovsiienko, Suanming Mou; +Cc: dev
Hi Xueming,
> -----Original Message-----
> From: Xueming(Steven) Li <xuemingl@nvidia.com>
> Sent: Friday, June 30, 2023 10:55 AM
> To: Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Suanming Mou
> <suanmingm@nvidia.com>
> Cc: Xueming(Steven) Li <xuemingl@nvidia.com>; dev@dpdk.org
> Subject: [PATCH v1] net/mlx5: support symmetric RSS hash function
>
> 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>
> ---
Best,
Acked-by: Ori Kam <orika@nvidia.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] net/mlx5: support symmetric RSS hash function
2023-06-30 7:37 [PATCH] net/mlx5: support symmetric RSS hash function Xueming Li
2023-06-30 7:54 ` [PATCH v1] " Xueming Li
@ 2023-07-06 11:55 ` Xueming Li
2023-07-06 15:07 ` Matan Azrad
2023-07-06 15:17 ` Raslan Darawsheh
1 sibling, 2 replies; 6+ messages in thread
From: Xueming Li @ 2023-07-06 11:55 UTC (permalink / raw)
To: Matan Azrad, Viacheslav Ovsiienko, Ori Kam, Suanming Mou; +Cc: xuemingl, dev
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>
---
doc/guides/nics/mlx5.rst | 4 ++++
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 +++++---
9 files changed, 53 insertions(+), 10 deletions(-)
diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index b9843edbd9..20420c7feb 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -110,6 +110,7 @@ Features
and source only, destination only or both.
- Several RSS hash keys, one for each flow type.
- Default RSS operation with no hash key specification.
+- Symmetric RSS function.
- Configurable RETA table.
- Link flow control (pause frame).
- Support for multiple MAC addresses.
@@ -708,6 +709,9 @@ Limitations
The flow engine of a process cannot move from active to standby mode
if preceding active application rules are still present and vice versa.
+- The symmetric RSS function is supported by swapping source and desitination
+ addresses and ports
+
Statistics
----------
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 df0f1dfe52..a8c53f227c 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -2164,8 +2164,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,
@@ -5578,6 +5581,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.symmetric_hash_function;
rss_desc_v[i].key_len = MLX5_RSS_HASH_KEY_LEN;
rss_desc_v[i].hash_fields =
dev_flow.hash_fields;
@@ -7275,6 +7280,7 @@ flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,
rss = flow_get_rss_action(dev, p_actions_rx);
if (rss) {
MLX5_ASSERT(rss->queue_num <= RTE_ETH_RSS_RETA_SIZE_512);
+ 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 62789853ab..3d89afb802 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 symmetric_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..a8dd9920e6 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->symmetric_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->symmetric_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 330386df77..0a62add823 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;
}
@@ -1913,6 +1916,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);
@@ -2000,6 +2004,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 b314c0482b..ec713009d7 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH v2] net/mlx5: support symmetric RSS hash function
2023-07-06 11:55 ` [PATCH v2] " Xueming Li
@ 2023-07-06 15:07 ` Matan Azrad
2023-07-06 15:17 ` Raslan Darawsheh
1 sibling, 0 replies; 6+ messages in thread
From: Matan Azrad @ 2023-07-06 15:07 UTC (permalink / raw)
To: Xueming(Steven) Li, Slava Ovsiienko, Ori Kam, Suanming Mou; +Cc: dev
From: Xueming(Steven) Li
> 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>
Acked-by: Matan Azrad <matan@nvidia.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH v2] net/mlx5: support symmetric RSS hash function
2023-07-06 11:55 ` [PATCH v2] " Xueming Li
2023-07-06 15:07 ` Matan Azrad
@ 2023-07-06 15:17 ` Raslan Darawsheh
1 sibling, 0 replies; 6+ messages in thread
From: Raslan Darawsheh @ 2023-07-06 15:17 UTC (permalink / raw)
To: Xueming(Steven) Li, Matan Azrad, Slava Ovsiienko, Ori Kam, Suanming Mou
Cc: Xueming(Steven) Li, dev
[-- Attachment #1: Type: text/plain, Size: 2172 bytes --]
Hi,
> -----Original Message-----
> From: Xueming Li <xuemingl@nvidia.com>
> Sent: Thursday, July 6, 2023 2:56 PM
> To: Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Suanming Mou
> <suanmingm@nvidia.com>
> Cc: Xueming(Steven) Li <xuemingl@nvidia.com>; dev@dpdk.org
> Subject: [PATCH v2] net/mlx5: support symmetric RSS hash function
>
> 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
fixed a typo algorithom -> algorithm
> warning in validation.
>
> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> ---
> doc/guides/nics/mlx5.rst | 4 ++++
> 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 +++++---
> 9 files changed, 53 insertions(+), 10 deletions(-)
>
> diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
> index b9843edbd9..20420c7feb 100644
> --- a/doc/guides/nics/mlx5.rst
> +++ b/doc/guides/nics/mlx5.rst
> @@ -110,6 +110,7 @@ Features
> and source only, destination only or both.
> - Several RSS hash keys, one for each flow type.
> - Default RSS operation with no hash key specification.
> +- Symmetric RSS function.
> - Configurable RETA table.
> - Link flow control (pause frame).
> - Support for multiple MAC addresses.
> @@ -708,6 +709,9 @@ Limitations
> The flow engine of a process cannot move from active to standby mode
> if preceding active application rules are still present and vice versa.
>
> +- The symmetric RSS function is supported by swapping source and
> desitination
Fixed typo desitination -> destination
Patch applied to next -net-mlx,
Kindest regards
Raslan Darawsheh
[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 14545 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-07-06 15:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-30 7:37 [PATCH] net/mlx5: support symmetric RSS hash function Xueming Li
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
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).