DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Subject: [PATCH V3 3/7] pipeline: add table entry ID read instruction
Date: Tue, 30 Aug 2022 18:58:07 +0000	[thread overview]
Message-ID: <20220830185811.1843109-4-cristian.dumitrescu@intel.com> (raw)
In-Reply-To: <20220830185811.1843109-1-cristian.dumitrescu@intel.com>

Add the entry ID instruction that reads the entry ID of the latest
table lookup operation from the pipeline into the meta-data. The entry
ID is then used by the register and meter instructions as the index
into the register or meter array.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 lib/pipeline/rte_swx_pipeline.c          | 68 ++++++++++++++++++++++++
 lib/pipeline/rte_swx_pipeline_internal.h | 20 +++++++
 2 files changed, 88 insertions(+)

diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index 80108b8916..ec8268b7f8 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -2834,6 +2834,43 @@ instr_forget_exec(struct rte_swx_pipeline *p)
 	thread_ip_inc(p);
 }
 
+/*
+ * entryid.
+ */
+static int
+instr_entryid_translate(struct rte_swx_pipeline *p,
+			struct action *action __rte_unused,
+			char **tokens,
+			int n_tokens,
+			struct instruction *instr,
+			struct instruction_data *data __rte_unused)
+{
+	struct field *f;
+
+	CHECK(n_tokens == 2, EINVAL);
+
+	f = metadata_field_parse(p, tokens[1]);
+	CHECK(f, EINVAL);
+	CHECK(f->n_bits <= 64, EINVAL);
+
+	instr->type = INSTR_ENTRYID;
+	instr->mov.dst.n_bits = f->n_bits;
+	instr->mov.dst.offset = f->offset / 8;
+	return 0;
+}
+
+static inline void
+instr_entryid_exec(struct rte_swx_pipeline *p)
+{
+	struct thread *t = &p->threads[p->thread_id];
+	struct instruction *ip = t->ip;
+
+	__instr_entryid_exec(p, t, ip);
+
+	/* Thread. */
+	thread_ip_inc(p);
+}
+
 /*
  * extern.
  */
@@ -6336,6 +6373,14 @@ instr_translate(struct rte_swx_pipeline *p,
 					      instr,
 					      data);
 
+	if (!strcmp(tokens[tpos], "entryid"))
+		return instr_entryid_translate(p,
+					       action,
+					       &tokens[tpos],
+					       n_tokens - tpos,
+					       instr,
+					       data);
+
 	if (!strcmp(tokens[tpos], "extern"))
 		return instr_extern_translate(p,
 					      action,
@@ -7321,6 +7366,8 @@ static instr_exec_t instruction_table[] = {
 	[INSTR_LEARNER_REARM] = instr_rearm_exec,
 	[INSTR_LEARNER_REARM_NEW] = instr_rearm_new_exec,
 	[INSTR_LEARNER_FORGET] = instr_forget_exec,
+	[INSTR_ENTRYID] = instr_entryid_exec,
+
 	[INSTR_EXTERN_OBJ] = instr_extern_obj_exec,
 	[INSTR_EXTERN_FUNC] = instr_extern_func_exec,
 	[INSTR_HASH_FUNC] = instr_hash_func_exec,
@@ -11222,6 +11269,7 @@ instr_type_to_name(struct instruction *instr)
 	case INSTR_LEARNER_REARM: return "INSTR_LEARNER_REARM";
 	case INSTR_LEARNER_REARM_NEW: return "INSTR_LEARNER_REARM_NEW";
 	case INSTR_LEARNER_FORGET: return "INSTR_LEARNER_FORGET";
+	case INSTR_ENTRYID: return "INSTR_ENTRYID";
 
 	case INSTR_EXTERN_OBJ: return "INSTR_EXTERN_OBJ";
 	case INSTR_EXTERN_FUNC: return "INSTR_EXTERN_FUNC";
@@ -11922,6 +11970,24 @@ instr_forget_export(struct instruction *instr, FILE *f)
 		instr_type_to_name(instr));
 }
 
+static void
+instr_entryid_export(struct instruction *instr, FILE *f)
+{
+	fprintf(f,
+		"\t{\n"
+		"\t\t.type = %s,\n"
+		"\t\t.mov = {\n"
+		"\t\t\t.dst = {\n"
+		"\t\t\t\t.n_bits = %u,\n"
+		"\t\t\t\t.offset = %u,\n"
+		"\t\t\t},\n"
+		"\t\t},\n"
+		"\t},\n",
+		instr_type_to_name(instr),
+		instr->mov.dst.n_bits,
+		instr->mov.dst.offset);
+}
+
 static void
 instr_extern_export(struct instruction *instr, FILE *f)
 {
@@ -12212,6 +12278,7 @@ static instruction_export_t export_table[] = {
 	[INSTR_LEARNER_REARM] = instr_rearm_export,
 	[INSTR_LEARNER_REARM_NEW] = instr_rearm_export,
 	[INSTR_LEARNER_FORGET] = instr_forget_export,
+	[INSTR_ENTRYID] = instr_entryid_export,
 
 	[INSTR_EXTERN_OBJ] = instr_extern_export,
 	[INSTR_EXTERN_FUNC] = instr_extern_export,
@@ -12438,6 +12505,7 @@ instr_type_to_func(struct instruction *instr)
 	case INSTR_LEARNER_REARM: return "__instr_rearm_exec";
 	case INSTR_LEARNER_REARM_NEW: return "__instr_rearm_new_exec";
 	case INSTR_LEARNER_FORGET: return "__instr_forget_exec";
+	case INSTR_ENTRYID: return "__instr_entryid_exec";
 
 	case INSTR_EXTERN_OBJ: return NULL;
 	case INSTR_EXTERN_FUNC: return NULL;
diff --git a/lib/pipeline/rte_swx_pipeline_internal.h b/lib/pipeline/rte_swx_pipeline_internal.h
index 8f96b67d76..335506039b 100644
--- a/lib/pipeline/rte_swx_pipeline_internal.h
+++ b/lib/pipeline/rte_swx_pipeline_internal.h
@@ -504,6 +504,11 @@ enum instruction_type {
 	/* forget */
 	INSTR_LEARNER_FORGET,
 
+	/* entryid m.table_entry_id
+	 * Read the internal table entry ID into the specified meta-data field.
+	 */
+	INSTR_ENTRYID,
+
 	/* extern e.obj.func */
 	INSTR_EXTERN_OBJ,
 
@@ -2377,6 +2382,21 @@ __instr_forget_exec(struct rte_swx_pipeline *p,
 	stats->n_pkts_forget += 1;
 }
 
+/*
+ * entryid.
+ */
+static inline void
+__instr_entryid_exec(struct rte_swx_pipeline *p __rte_unused,
+		       struct thread *t,
+		       const struct instruction *ip)
+{
+	TRACE("[Thread %2u]: entryid\n",
+	      p->thread_id);
+
+	/* Meta-data. */
+	METADATA_WRITE(t, ip->mov.dst.offset, ip->mov.dst.n_bits, t->entry_id);
+}
+
 /*
  * extern.
  */
-- 
2.34.1


  parent reply	other threads:[~2022-08-30 18:58 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-26 10:35 [PATCH 0/7] pipeline: support direct registers and meters Cristian Dumitrescu
2022-08-26 10:35 ` [PATCH 1/7] table: add entry ID for regular tables Cristian Dumitrescu
2022-08-26 10:36 ` [PATCH 2/7] table: add entry ID for learner tables Cristian Dumitrescu
2022-08-26 10:36 ` [PATCH 3/7] pipeline: add table entry ID read instruction Cristian Dumitrescu
2022-08-26 10:36 ` [PATCH 4/7] pipeline: support direct registers on the control path Cristian Dumitrescu
2022-08-26 10:36 ` [PATCH 5/7] pipeline: support direct meters " Cristian Dumitrescu
2022-08-26 10:36 ` [PATCH 6/7] examples/pipeline: add CLI commands for direct registers Cristian Dumitrescu
2022-08-26 10:36 ` [PATCH 7/7] examples/pipeline: add CLI commands for direct meters Cristian Dumitrescu
2022-08-26 11:21 ` [PATCH V2 0/7] pipeline: support direct registers and meters Cristian Dumitrescu
2022-08-26 11:21   ` [PATCH V2 1/7] table: add entry ID for regular tables Cristian Dumitrescu
2022-08-26 11:21   ` [PATCH V2 2/7] table: add entry ID for learner tables Cristian Dumitrescu
2022-08-26 11:21   ` [PATCH V2 3/7] pipeline: add table entry ID read instruction Cristian Dumitrescu
2022-08-26 11:21   ` [PATCH V2 4/7] pipeline: support direct registers on the control path Cristian Dumitrescu
2022-08-26 11:21   ` [PATCH V2 5/7] pipeline: support direct meters " Cristian Dumitrescu
2022-08-26 11:21   ` [PATCH V2 6/7] examples/pipeline: add CLI commands for direct registers Cristian Dumitrescu
2022-08-26 11:21   ` [PATCH V2 7/7] examples/pipeline: add CLI commands for direct meters Cristian Dumitrescu
2022-08-30 18:58 ` [PATCH V3 0/7] pipeline: support direct registers and meters Cristian Dumitrescu
2022-08-30 18:58   ` [PATCH V3 1/7] table: add entry ID for regular tables Cristian Dumitrescu
2022-08-30 18:58   ` [PATCH V3 2/7] table: add entry ID for learner tables Cristian Dumitrescu
2022-09-24  8:25     ` Thomas Monjalon
2022-09-26  9:19       ` Dumitrescu, Cristian
2022-09-26 13:45         ` Thomas Monjalon
2022-08-30 18:58   ` Cristian Dumitrescu [this message]
2022-08-30 18:58   ` [PATCH V3 4/7] pipeline: support direct registers on the control path Cristian Dumitrescu
2022-08-30 18:58   ` [PATCH V3 5/7] pipeline: support direct meters " Cristian Dumitrescu
2022-08-30 18:58   ` [PATCH V3 6/7] examples/pipeline: add CLI commands for direct registers Cristian Dumitrescu
2022-08-30 18:58   ` [PATCH V3 7/7] examples/pipeline: add CLI commands for direct meters Cristian Dumitrescu
2022-09-24  9:34   ` [PATCH V3 0/7] pipeline: support direct registers and meters 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=20220830185811.1843109-4-cristian.dumitrescu@intel.com \
    --to=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    /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).