From: Gregory Etelson <getelson@nvidia.com>
To: <dev@dpdk.org>
Cc: <getelson@nvidia.com>, <mkashani@nvidia.com>,
<rasland@nvidia.com>, "Ori Kam" <orika@nvidia.com>,
Matan Azrad <matan@nvidia.com>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
Suanming Mou <suanmingm@nvidia.com>
Subject: [PATCH 09/13] net/mlx5: add support for calc hash
Date: Sun, 29 Oct 2023 20:22:56 +0200 [thread overview]
Message-ID: <20231029182300.227879-10-getelson@nvidia.com> (raw)
In-Reply-To: <20231029182300.227879-1-getelson@nvidia.com>
From: Ori Kam <orika@nvidia.com>
This commit adds calculate hash function support for mlx5 PMD.
Signed-off-by: Ori Kam <orika@nvidia.com>
---
drivers/net/mlx5/mlx5_flow.c | 32 ++++++++++++++++++++++++++++++++
drivers/net/mlx5/mlx5_flow.h | 8 ++++++++
drivers/net/mlx5/mlx5_flow_hw.c | 31 ++++++++++++++++++++++++++++++-
3 files changed, 70 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index ad9a2f2273..819831cff8 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -1178,6 +1178,13 @@ mlx5_flow_async_action_list_handle_query_update(struct rte_eth_dev *dev,
enum rte_flow_query_update_mode mode,
void *user_data,
struct rte_flow_error *error);
+static int
+mlx5_flow_calc_table_hash(struct rte_eth_dev *dev,
+ const struct rte_flow_template_table *table,
+ const struct rte_flow_item pattern[],
+ uint8_t pattern_template_index,
+ uint32_t *hash, struct rte_flow_error *error);
+
static const struct rte_flow_ops mlx5_flow_ops = {
.validate = mlx5_flow_validate,
.create = mlx5_flow_create,
@@ -1231,6 +1238,7 @@ static const struct rte_flow_ops mlx5_flow_ops = {
mlx5_flow_action_list_handle_query_update,
.async_action_list_handle_query_update =
mlx5_flow_async_action_list_handle_query_update,
+ .flow_calc_table_hash = mlx5_flow_calc_table_hash,
};
/* Tunnel information. */
@@ -11058,6 +11066,30 @@ mlx5_flow_async_action_list_handle_query_update(struct rte_eth_dev *dev,
}
+static int
+mlx5_flow_calc_table_hash(struct rte_eth_dev *dev,
+ const struct rte_flow_template_table *table,
+ const struct rte_flow_item pattern[],
+ uint8_t pattern_template_index,
+ uint32_t *hash, struct rte_flow_error *error)
+{
+ struct rte_flow_attr attr = { .transfer = 0 };
+ enum mlx5_flow_drv_type drv_type = flow_get_drv_type(dev, &attr);
+ const struct mlx5_flow_driver_ops *fops;
+
+ if (drv_type == MLX5_FLOW_TYPE_MIN || drv_type == MLX5_FLOW_TYPE_MAX)
+ return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_ACTION,
+ NULL, "invalid driver type");
+ fops = flow_get_drv_ops(drv_type);
+ if (!fops || !fops->action_query_update)
+ return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_ACTION,
+ NULL, "no query_update handler");
+ return fops->flow_calc_table_hash(dev, table, pattern, pattern_template_index,
+ hash, error);
+}
+
/**
* Destroy all indirect actions (shared RSS).
*
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 81ec8fd7f1..db6f3ba6f5 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -2062,6 +2062,13 @@ typedef int
const void **update, void **query,
enum rte_flow_query_update_mode mode,
void *user_data, struct rte_flow_error *error);
+typedef int
+(*mlx5_flow_calc_table_hash_t)
+ (struct rte_eth_dev *dev,
+ const struct rte_flow_template_table *table,
+ const struct rte_flow_item pattern[],
+ uint8_t pattern_template_index,
+ uint32_t *hash, struct rte_flow_error *error);
struct mlx5_flow_driver_ops {
mlx5_flow_validate_t validate;
@@ -2133,6 +2140,7 @@ struct mlx5_flow_driver_ops {
action_list_handle_query_update;
mlx5_flow_async_action_list_handle_query_update_t
async_action_list_handle_query_update;
+ mlx5_flow_calc_table_hash_t flow_calc_table_hash;
};
/* mlx5_flow.c */
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index cccf7de13f..ea43ebb78b 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -2773,7 +2773,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev,
static const struct rte_flow_item *
flow_hw_get_rule_items(struct rte_eth_dev *dev,
- struct rte_flow_template_table *table,
+ const struct rte_flow_template_table *table,
const struct rte_flow_item items[],
uint8_t pattern_template_index,
struct mlx5_hw_q_job *job)
@@ -10144,6 +10144,34 @@ flow_hw_action_list_handle_query_update(struct rte_eth_dev *dev,
update, query, mode, NULL, error);
}
+static int
+flow_hw_calc_table_hash(struct rte_eth_dev *dev,
+ const struct rte_flow_template_table *table,
+ const struct rte_flow_item pattern[],
+ uint8_t pattern_template_index,
+ uint32_t *hash, struct rte_flow_error *error)
+{
+ const struct rte_flow_item *items;
+ /* Temp job to allow adding missing items */
+ static struct rte_flow_item tmp_items[MLX5_HW_MAX_ITEMS];
+ static struct mlx5_hw_q_job job = {.items = tmp_items};
+ int res;
+
+ items = flow_hw_get_rule_items(dev, table, pattern,
+ pattern_template_index,
+ &job);
+ res = mlx5dr_rule_hash_calculate(table->matcher, items,
+ pattern_template_index,
+ MLX5DR_RULE_HASH_CALC_MODE_RAW,
+ hash);
+ if (res)
+ return rte_flow_error_set(error, res,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL,
+ "hash could not be calculated");
+ return 0;
+}
+
const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = {
.info_get = flow_hw_info_get,
.configure = flow_hw_configure,
@@ -10187,6 +10215,7 @@ const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = {
.get_q_aged_flows = flow_hw_get_q_aged_flows,
.item_create = flow_dv_item_create,
.item_release = flow_dv_item_release,
+ .flow_calc_table_hash = flow_hw_calc_table_hash,
};
/**
--
2.39.2
next prev parent reply other threads:[~2023-10-29 18:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-29 18:22 [PATCH 00/13] net/mlx5: support more REG C registers Gregory Etelson
2023-10-29 18:22 ` [PATCH 01/13] net/mlx5/hws: Definer, add mlx5dr context to definer_conv_data Gregory Etelson
2023-10-29 18:22 ` [PATCH 02/13] net/mlx5: add flow_hw_get_reg_id_from_ctx() Gregory Etelson
2023-10-29 18:22 ` [PATCH 03/13] net/mlx5/hws: Definer, use flow_hw_get_reg_id_from_ctx function call Gregory Etelson
2023-10-29 18:22 ` [PATCH 04/13] net/mlx5: add rte_device parameter to locate HWS registers Gregory Etelson
2023-10-29 18:22 ` [PATCH 05/13] net/mlx5: separate port REG_C registers usage Gregory Etelson
2023-10-29 18:22 ` [PATCH 06/13] net/mlx5: merge REG_C aliases Gregory Etelson
2023-10-29 18:22 ` [PATCH 07/13] net/mlx5: initialize HWS flow tags registers in shared dev context Gregory Etelson
2023-10-29 18:22 ` [PATCH 08/13] net/mlx5/hws: adding method to query rule hash Gregory Etelson
2023-10-30 6:23 ` Ori Kam
2023-10-29 18:22 ` Gregory Etelson [this message]
2023-10-30 8:23 ` [PATCH 09/13] net/mlx5: add support for calc hash Dariusz Sosnowski
2023-10-29 18:22 ` [PATCH 10/13] net/mlx5: fix insert by index Gregory Etelson
2023-10-30 8:25 ` Dariusz Sosnowski
2023-10-29 18:22 ` [PATCH 11/13] net/mlx5: fix query for NIC flow cap Gregory Etelson
2023-10-30 8:26 ` Dariusz Sosnowski
2023-10-29 18:22 ` [PATCH 12/13] net/mlx5: add support for more registers Gregory Etelson
2023-10-30 8:27 ` Dariusz Sosnowski
2023-10-29 18:23 ` [PATCH 13/13] net/mlx5: add validation support for tags Gregory Etelson
2023-10-30 8:28 ` Dariusz Sosnowski
2023-10-30 8:37 ` [PATCH 00/13] net/mlx5: support more REG C registers Suanming Mou
2023-10-30 17:11 ` 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=20231029182300.227879-10-getelson@nvidia.com \
--to=getelson@nvidia.com \
--cc=dev@dpdk.org \
--cc=matan@nvidia.com \
--cc=mkashani@nvidia.com \
--cc=orika@nvidia.com \
--cc=rasland@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).