DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Cc: Jasvinder Singh <jasvinder.singh@intel.com>,
	Hongjun Ni <hongjun.ni@intel.com>
Subject: [dpdk-dev] [PATCH 01/12] examples/ip_pipeline: add rule list per table
Date: Fri,  2 Nov 2018 11:36:52 +0000	[thread overview]
Message-ID: <1541158623-29742-1-git-send-email-cristian.dumitrescu@intel.com> (raw)

For each pipeline table, have the master thread maintain the list of
rules that are currently stored in the table. This list allows the
master thread to handle table queries with minimal impact for the
data plane threads: requests to read the current set of table rules
are fully handled by the master thread with no involvement from
data plane threads, requests to read the per table rule moving data
(such as stats counters or timestamp associated with specific
actions) are handled by the data plane threads through plain memory
reads rather than key lookup.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
---
 examples/ip_pipeline/pipeline.c | 88 +++++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h | 36 +++++++++++++++++
 2 files changed, 124 insertions(+)

diff --git a/examples/ip_pipeline/pipeline.c b/examples/ip_pipeline/pipeline.c
index b23d6c0..78d590d 100644
--- a/examples/ip_pipeline/pipeline.c
+++ b/examples/ip_pipeline/pipeline.c
@@ -1041,7 +1041,95 @@ pipeline_table_create(const char *pipeline_name,
 	memcpy(&table->params, params, sizeof(*params));
 	table->ap = ap;
 	table->a = action;
+	TAILQ_INIT(&table->rules);
+	table->rule_default = NULL;
+
 	pipeline->n_tables++;
 
 	return 0;
 }
+
+struct table_rule *
+table_rule_find(struct table *table,
+    struct table_rule_match *match)
+{
+	struct table_rule *rule;
+
+	TAILQ_FOREACH(rule, &table->rules, node)
+		if (memcmp(&rule->match, match, sizeof(*match)) == 0)
+			return rule;
+
+	return NULL;
+}
+
+void
+table_rule_add(struct table *table,
+    struct table_rule *new_rule)
+{
+	struct table_rule *existing_rule;
+
+	existing_rule = table_rule_find(table, &new_rule->match);
+	if (existing_rule == NULL)
+		TAILQ_INSERT_TAIL(&table->rules, new_rule, node);
+	else {
+		TAILQ_INSERT_AFTER(&table->rules, existing_rule, new_rule, node);
+		TAILQ_REMOVE(&table->rules, existing_rule, node);
+		free(existing_rule);
+	}
+}
+
+void
+table_rule_add_bulk(struct table *table,
+    struct table_rule_list *list,
+    uint32_t n_rules)
+{
+	uint32_t i;
+
+	for (i = 0; i < n_rules; i++) {
+		struct table_rule *existing_rule, *new_rule;
+
+		new_rule = TAILQ_FIRST(list);
+		if (new_rule == NULL)
+			break;
+
+		TAILQ_REMOVE(list, new_rule, node);
+
+		existing_rule = table_rule_find(table, &new_rule->match);
+		if (existing_rule == NULL)
+			TAILQ_INSERT_TAIL(&table->rules, new_rule, node);
+		else {
+			TAILQ_INSERT_AFTER(&table->rules, existing_rule, new_rule, node);
+			TAILQ_REMOVE(&table->rules, existing_rule, node);
+			free(existing_rule);
+		}
+	}
+}
+
+void
+table_rule_delete(struct table *table,
+    struct table_rule_match *match)
+{
+	struct table_rule *rule;
+
+	rule = table_rule_find(table, match);
+	if (rule == NULL)
+		return;
+
+	TAILQ_REMOVE(&table->rules, rule, node);
+	free(rule);
+}
+
+void
+table_rule_default_add(struct table *table,
+	struct table_rule *rule)
+{
+	free(table->rule_default);
+	table->rule_default = rule;
+}
+
+void
+table_rule_default_delete(struct table *table)
+{
+	free(table->rule_default);
+	table->rule_default = NULL;
+}
diff --git a/examples/ip_pipeline/pipeline.h b/examples/ip_pipeline/pipeline.h
index e5b1d5d..2034504 100644
--- a/examples/ip_pipeline/pipeline.h
+++ b/examples/ip_pipeline/pipeline.h
@@ -143,6 +143,10 @@ struct table_params {
 	const char *action_profile_name;
 };
 
+struct table_rule;
+
+TAILQ_HEAD(table_rule_list, table_rule);
+
 struct port_in {
 	struct port_in_params params;
 	struct port_in_action_profile *ap;
@@ -153,6 +157,8 @@ struct table {
 	struct table_params params;
 	struct table_action_profile *ap;
 	struct rte_table_action *a;
+	struct table_rule_list rules;
+	struct table_rule *rule_default;
 };
 
 struct pipeline {
@@ -286,6 +292,13 @@ struct table_rule_action {
 	struct rte_table_action_decap_params decap;
 };
 
+struct table_rule {
+	TAILQ_ENTRY(table_rule) node;
+	struct table_rule_match match;
+	struct table_rule_action action;
+	void *data;
+};
+
 int
 pipeline_port_in_stats_read(const char *pipeline_name,
 	uint32_t port_id,
@@ -380,5 +393,28 @@ pipeline_table_rule_ttl_read(const char *pipeline_name,
 	void *data,
 	struct rte_table_action_ttl_counters *stats,
 	int clear);
+struct table_rule *
+table_rule_find(struct table *table,
+	struct table_rule_match *match);
+
+void
+table_rule_add(struct table *table,
+	struct table_rule *rule);
+
+void
+table_rule_add_bulk(struct table *table,
+	struct table_rule_list *list,
+	uint32_t n_rules);
+
+void
+table_rule_delete(struct table *table,
+	struct table_rule_match *match);
+
+void
+table_rule_default_add(struct table *table,
+	struct table_rule *rule);
+
+void
+table_rule_default_delete(struct table *table);
 
 #endif /* _INCLUDE_PIPELINE_H_ */
-- 
2.7.4

             reply	other threads:[~2018-11-02 11:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-02 11:36 Cristian Dumitrescu [this message]
2018-11-02 11:36 ` [dpdk-dev] [PATCH 02/12] examples/ip_pipeline: track table rules on add Cristian Dumitrescu
2018-11-02 11:36 ` [dpdk-dev] [PATCH 03/12] examples/ip_pipeline: track table rules on add bulk Cristian Dumitrescu
2018-11-02 11:36 ` [dpdk-dev] [PATCH 04/12] examples/ip_pipeline: track rules on add default Cristian Dumitrescu
2018-11-02 11:36 ` [dpdk-dev] [PATCH 05/12] examples/ip_pipeline: track table rules on delete Cristian Dumitrescu
2018-11-02 11:36 ` [dpdk-dev] [PATCH 06/12] examples/ip_pipeline: track rules on delete default Cristian Dumitrescu
2018-11-02 11:36 ` [dpdk-dev] [PATCH 07/12] examples/ip_pipeline: support rule stats read Cristian Dumitrescu
2018-11-02 11:36 ` [dpdk-dev] [PATCH 08/12] examples/ip_pipeline: support meter " Cristian Dumitrescu
2018-11-02 11:37 ` [dpdk-dev] [PATCH 09/12] examples/ip_pipeline: support rule TTL " Cristian Dumitrescu
2018-11-02 11:37 ` [dpdk-dev] [PATCH 10/12] examples/ip_pipeline: support rule time read Cristian Dumitrescu
2018-11-02 11:37 ` [dpdk-dev] [PATCH 11/12] examples/ip_pipeline: support table rule show Cristian Dumitrescu
2018-11-02 11:37 ` [dpdk-dev] [PATCH 12/12] examples/ip_pipeline: fix port and table stats read Cristian Dumitrescu
2018-11-02 12:39 ` [dpdk-dev] [PATCH 01/12] examples/ip_pipeline: add rule list per table Dumitrescu, Cristian

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=1541158623-29742-1-git-send-email-cristian.dumitrescu@intel.com \
    --to=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=hongjun.ni@intel.com \
    --cc=jasvinder.singh@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).