DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Cc: yogesh.jangra@intel.com
Subject: [PATCH V2 1/4] pipeline: improve the drop instruction
Date: Sat, 27 Nov 2021 00:02:51 +0000	[thread overview]
Message-ID: <20211127000254.36148-1-cristian.dumitrescu@intel.com> (raw)
In-Reply-To: <20211126235129.35781-1-cristian.dumitrescu@intel.com>

The output port to be used as the drop port is now determined when the
drop instruction is executed as opposed to being statically determined
at instruction translation time and hardcoded in the opcode.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Yogesh Jangra <yogesh.jangra@intel.com>:
---
 lib/pipeline/rte_swx_pipeline.c          | 38 ++++++++++++++++++------
 lib/pipeline/rte_swx_pipeline_internal.h | 20 +++++++++++++
 2 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index 2145ca0a42..ff2fe964a5 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -1370,6 +1370,7 @@ instruction_is_tx(enum instruction_type type)
 	switch (type) {
 	case INSTR_TX:
 	case INSTR_TX_I:
+	case INSTR_DROP:
 		return 1;
 
 	default:
@@ -1383,6 +1384,7 @@ instruction_does_tx(struct instruction *instr)
 	switch (instr->type) {
 	case INSTR_TX:
 	case INSTR_TX_I:
+	case INSTR_DROP:
 	case INSTR_HDR_EMIT_TX:
 	case INSTR_HDR_EMIT2_TX:
 	case INSTR_HDR_EMIT3_TX:
@@ -1591,7 +1593,7 @@ instr_tx_translate(struct rte_swx_pipeline *p,
 }
 
 static int
-instr_drop_translate(struct rte_swx_pipeline *p,
+instr_drop_translate(struct rte_swx_pipeline *p __rte_unused,
 		     struct action *action __rte_unused,
 		     char **tokens __rte_unused,
 		     int n_tokens,
@@ -1600,9 +1602,8 @@ instr_drop_translate(struct rte_swx_pipeline *p,
 {
 	CHECK(n_tokens == 1, EINVAL);
 
-	/* TX_I. */
-	instr->type = INSTR_TX_I;
-	instr->io.io.val = p->n_ports_out - 1;
+	/* DROP. */
+	instr->type = INSTR_DROP;
 	return 0;
 }
 
@@ -1632,6 +1633,19 @@ instr_tx_i_exec(struct rte_swx_pipeline *p)
 	instr_rx_exec(p);
 }
 
+static inline void
+instr_drop_exec(struct rte_swx_pipeline *p)
+{
+	struct thread *t = &p->threads[p->thread_id];
+	struct instruction *ip = t->ip;
+
+	__instr_drop_exec(p, t, ip);
+
+	/* Thread. */
+	thread_ip_reset(p, t);
+	instr_rx_exec(p);
+}
+
 /*
  * extract.
  */
@@ -6199,7 +6213,7 @@ instr_pattern_emit_many_tx_search(struct instruction *instr,
 	if (!i)
 		return 0;
 
-	if (!instruction_is_tx(instr[i].type))
+	if (instr[i].type != INSTR_TX)
 		return 0;
 
 	if (data[i].n_users)
@@ -6643,6 +6657,7 @@ static instr_exec_t instruction_table[] = {
 	[INSTR_RX] = instr_rx_exec,
 	[INSTR_TX] = instr_tx_exec,
 	[INSTR_TX_I] = instr_tx_i_exec,
+	[INSTR_DROP] = instr_drop_exec,
 
 	[INSTR_HDR_EXTRACT] = instr_hdr_extract_exec,
 	[INSTR_HDR_EXTRACT2] = instr_hdr_extract2_exec,
@@ -9901,6 +9916,7 @@ instr_type_to_name(struct instruction *instr)
 
 	case INSTR_TX: return "INSTR_TX";
 	case INSTR_TX_I: return "INSTR_TX_I";
+	case INSTR_DROP: return "INSTR_DROP";
 
 	case INSTR_HDR_EXTRACT: return "INSTR_HDR_EXTRACT";
 	case INSTR_HDR_EXTRACT2: return "INSTR_HDR_EXTRACT2";
@@ -10126,8 +10142,9 @@ instr_io_export(struct instruction *instr, FILE *f)
 		instr_type_to_name(instr));
 
 	/* instr.io. */
-	fprintf(f,
-		"\t\t.io = {\n");
+	if (n_io || n_io_imm || n_hdrs)
+		fprintf(f,
+			"\t\t.io = {\n");
 
 	/* instr.io.io. */
 	if (n_io)
@@ -10193,8 +10210,9 @@ instr_io_export(struct instruction *instr, FILE *f)
 	}
 
 	/* instr.io - closing curly brace. */
-	fprintf(f,
-		"\t\t},\n");
+	if (n_io || n_io_imm || n_hdrs)
+		fprintf(f,
+			"\t\t},\n");
 
 	/* instr - closing curly brace. */
 	fprintf(f,
@@ -10767,6 +10785,7 @@ static instruction_export_t export_table[] = {
 
 	[INSTR_TX] = instr_io_export,
 	[INSTR_TX_I] = instr_io_export,
+	[INSTR_DROP] = instr_io_export,
 
 	[INSTR_HDR_EXTRACT] = instr_io_export,
 	[INSTR_HDR_EXTRACT2] = instr_io_export,
@@ -10984,6 +11003,7 @@ instr_type_to_func(struct instruction *instr)
 
 	case INSTR_TX: return "__instr_tx_exec";
 	case INSTR_TX_I: return "__instr_tx_i_exec";
+	case INSTR_DROP: return "__instr_drop_exec";
 
 	case INSTR_HDR_EXTRACT: return "__instr_hdr_extract_exec";
 	case INSTR_HDR_EXTRACT2: return "__instr_hdr_extract2_exec";
diff --git a/lib/pipeline/rte_swx_pipeline_internal.h b/lib/pipeline/rte_swx_pipeline_internal.h
index 1921fdcd78..2e86383e45 100644
--- a/lib/pipeline/rte_swx_pipeline_internal.h
+++ b/lib/pipeline/rte_swx_pipeline_internal.h
@@ -225,6 +225,7 @@ enum instruction_type {
 	 */
 	INSTR_TX,   /* port_out = M */
 	INSTR_TX_I, /* port_out = I */
+	INSTR_DROP,
 
 	/* extract h.header */
 	INSTR_HDR_EXTRACT,
@@ -1631,6 +1632,25 @@ __instr_tx_i_exec(struct rte_swx_pipeline *p, struct thread *t, const struct ins
 	port->pkt_tx(port->obj, pkt);
 }
 
+static inline void
+__instr_drop_exec(struct rte_swx_pipeline *p,
+		  struct thread *t,
+		  const struct instruction *ip __rte_unused)
+{
+	uint64_t port_id = p->n_ports_out - 1;
+	struct port_out_runtime *port = &p->out[port_id];
+	struct rte_swx_pkt *pkt = &t->pkt;
+
+	TRACE("[Thread %2u]: drop 1 pkt\n",
+	      p->thread_id);
+
+	/* Headers. */
+	emit_handler(t);
+
+	/* Packet. */
+	port->pkt_tx(port->obj, pkt);
+}
+
 /*
  * extract.
  */
-- 
2.17.1


  parent reply	other threads:[~2021-11-27  0:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-26 23:51 [PATCH " Cristian Dumitrescu
2021-11-26 23:51 ` [PATCH 2/4] pipeline: move port type registration to library Cristian Dumitrescu
2021-11-26 23:51 ` [PATCH 3/4] pipeline: move table " Cristian Dumitrescu
2021-11-26 23:51 ` [PATCH 4/4] pipeline: add drop port for each pipeline Cristian Dumitrescu
2021-11-27  0:02 ` Cristian Dumitrescu [this message]
2021-11-27  0:02   ` [PATCH V2 2/4] pipeline: move port type registration to library Cristian Dumitrescu
2021-11-27  0:02   ` [PATCH V2 3/4] pipeline: move table " Cristian Dumitrescu
2021-11-27  0:02   ` [PATCH V2 4/4] pipeline: add drop port for each pipeline Cristian Dumitrescu
2022-02-13 19:48     ` 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=20211127000254.36148-1-cristian.dumitrescu@intel.com \
    --to=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=yogesh.jangra@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).