From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Cc: "Kamalakannan R ." <kamalakannan.r@intel.com>
Subject: [PATCH 6/6] pipeline: configure the hash function for learner tables
Date: Thu, 18 Aug 2022 11:44:49 +0000 [thread overview]
Message-ID: <20220818114449.1408226-7-cristian.dumitrescu@intel.com> (raw)
In-Reply-To: <20220818114449.1408226-1-cristian.dumitrescu@intel.com>
Make the hash function configurable for the learner pipeline tables.
Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Kamalakannan R. <kamalakannan.r@intel.com>
---
lib/pipeline/rte_swx_pipeline.c | 12 ++++++++
lib/pipeline/rte_swx_pipeline.h | 6 ++++
lib/pipeline/rte_swx_pipeline_internal.h | 1 +
lib/pipeline/rte_swx_pipeline_spec.c | 35 +++++++++++++++++++++++-
lib/pipeline/rte_swx_pipeline_spec.h | 1 +
5 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index e1227cbfcc..e9e024029e 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -8893,6 +8893,7 @@ rte_swx_pipeline_learner_config(struct rte_swx_pipeline *p,
struct learner *l = NULL;
struct action *default_action;
struct header *header = NULL;
+ struct hash_func *hf = NULL;
uint32_t action_data_size_max = 0, i;
int status = 0;
@@ -8955,6 +8956,12 @@ rte_swx_pipeline_learner_config(struct rte_swx_pipeline *p,
CHECK((default_action->st && params->default_action_args) || !params->default_action_args,
EINVAL);
+ /* Hash function checks. */
+ if (params->hash_func_name) {
+ hf = hash_func_find(p, params->hash_func_name);
+ CHECK(hf, EINVAL);
+ }
+
/* Any other checks. */
CHECK(size, EINVAL);
CHECK(timeout, EINVAL);
@@ -9043,6 +9050,8 @@ rte_swx_pipeline_learner_config(struct rte_swx_pipeline *p,
l->action_data_size_max = action_data_size_max;
+ l->hf = hf;
+
l->size = size;
for (i = 0; i < n_timeouts; i++)
@@ -9132,6 +9141,9 @@ learner_params_get(struct learner *l)
/* Action data size. */
params->action_data_size = l->action_data_size_max;
+ /* Hash function. */
+ params->hash_func = l->hf ? l->hf->func : NULL;
+
/* Maximum number of keys. */
params->n_keys_max = l->size;
diff --git a/lib/pipeline/rte_swx_pipeline.h b/lib/pipeline/rte_swx_pipeline.h
index 09c75180f8..2c9cc6ee44 100644
--- a/lib/pipeline/rte_swx_pipeline.h
+++ b/lib/pipeline/rte_swx_pipeline.h
@@ -829,6 +829,12 @@ struct rte_swx_pipeline_learner_params {
* list.
*/
int default_action_is_const;
+
+ /** Hash function name. When not set to NULL, it must point to one of
+ * the hash functions that were registered for the current pipeline.
+ * When NULL, the default hash function will be used.
+ */
+ const char *hash_func_name;
};
/**
diff --git a/lib/pipeline/rte_swx_pipeline_internal.h b/lib/pipeline/rte_swx_pipeline_internal.h
index ee579c6656..ef60288dca 100644
--- a/lib/pipeline/rte_swx_pipeline_internal.h
+++ b/lib/pipeline/rte_swx_pipeline_internal.h
@@ -900,6 +900,7 @@ struct learner {
int *action_is_for_table_entries;
int *action_is_for_default_entry;
+ struct hash_func *hf;
uint32_t size;
uint32_t timeout[RTE_SWX_TABLE_LEARNER_N_KEY_TIMEOUTS_MAX];
uint32_t n_timeouts;
diff --git a/lib/pipeline/rte_swx_pipeline_spec.c b/lib/pipeline/rte_swx_pipeline_spec.c
index c0ca7335ff..5a07edd519 100644
--- a/lib/pipeline/rte_swx_pipeline_spec.c
+++ b/lib/pipeline/rte_swx_pipeline_spec.c
@@ -1350,7 +1350,7 @@ selector_block_parse(struct selector_spec *s,
static void
learner_spec_free(struct learner_spec *s)
{
- uintptr_t default_action_name, default_action_args;
+ uintptr_t default_action_name, default_action_args, hash_func_name;
uint32_t i;
if (!s)
@@ -1397,6 +1397,10 @@ learner_spec_free(struct learner_spec *s)
s->params.default_action_is_const = 0;
+ hash_func_name = (uintptr_t)s->params.hash_func_name;
+ free((void *)hash_func_name);
+ s->params.hash_func_name = NULL;
+
s->size = 0;
free(s->timeout);
@@ -1853,6 +1857,35 @@ learner_block_parse(struct learner_spec *s,
err_line,
err_msg);
+ if (!strcmp(tokens[0], "hash")) {
+ if (n_tokens != 2) {
+ if (err_line)
+ *err_line = n_lines;
+ if (err_msg)
+ *err_msg = "Invalid hash statement.";
+ return -EINVAL;
+ }
+
+ if (s->params.hash_func_name) {
+ if (err_line)
+ *err_line = n_lines;
+ if (err_msg)
+ *err_msg = "Duplicate hash statement.";
+ return -EINVAL;
+ }
+
+ s->params.hash_func_name = strdup(tokens[1]);
+ if (!s->params.hash_func_name) {
+ if (err_line)
+ *err_line = n_lines;
+ if (err_msg)
+ *err_msg = "Memory allocation failed.";
+ return -ENOMEM;
+ }
+
+ return 0;
+ }
+
if (!strcmp(tokens[0], "size")) {
char *p = tokens[1];
diff --git a/lib/pipeline/rte_swx_pipeline_spec.h b/lib/pipeline/rte_swx_pipeline_spec.h
index dbe1b40adc..123e175f8b 100644
--- a/lib/pipeline/rte_swx_pipeline_spec.h
+++ b/lib/pipeline/rte_swx_pipeline_spec.h
@@ -134,6 +134,7 @@ struct selector_spec {
* ...
* }
* default_action ACTION_NAME args none | ARG0_NAME ARG0_VALUE ... [ const ]
+ * hash HASH_FUNCTION_NAME
* size SIZE
* timeout {
* TIMEOUT_IN_SECONDS
--
2.34.1
next prev parent reply other threads:[~2022-08-18 11:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-18 11:44 [PATCH 0/6] pipeline: make the hash function configurable per table Cristian Dumitrescu
2022-08-18 11:44 ` [PATCH 1/6] table: add hash function prototype Cristian Dumitrescu
2022-08-18 11:44 ` [PATCH 2/6] table: add key comparison functions Cristian Dumitrescu
2022-08-18 11:44 ` [PATCH 3/6] table: configure the hash function for regular tables Cristian Dumitrescu
2022-08-18 11:44 ` [PATCH 4/6] pipeline: " Cristian Dumitrescu
2022-08-18 11:44 ` [PATCH 5/6] table: configure the hash function for learner tables Cristian Dumitrescu
2022-08-18 11:44 ` Cristian Dumitrescu [this message]
2022-08-19 19:52 ` [PATCH V2 0/6] pipeline: make the hash function configurable per table Cristian Dumitrescu
2022-08-19 19:52 ` [PATCH V2 1/6] table: add hash function prototype Cristian Dumitrescu
2022-08-19 19:52 ` [PATCH V2 2/6] table: add key comparison functions Cristian Dumitrescu
2022-08-19 19:52 ` [PATCH V2 3/6] table: configure the hash function for regular tables Cristian Dumitrescu
2022-08-19 19:52 ` [PATCH V2 4/6] pipeline: " Cristian Dumitrescu
2022-08-19 19:52 ` [PATCH V2 5/6] table: configure the hash function for learner tables Cristian Dumitrescu
2022-08-19 19:52 ` [PATCH V2 6/6] pipeline: " Cristian Dumitrescu
2022-08-31 16:23 ` [PATCH V2 0/6] pipeline: make the hash function configurable per table Stephen Hemminger
2022-09-01 8:11 ` Morten Brørup
2022-09-23 15:58 ` Thomas Monjalon
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=20220818114449.1408226-7-cristian.dumitrescu@intel.com \
--to=cristian.dumitrescu@intel.com \
--cc=dev@dpdk.org \
--cc=kamalakannan.r@intel.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).