DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 1/4] pipeline: improve the drop instruction
@ 2021-11-26 23:51 Cristian Dumitrescu
  2021-11-26 23:51 ` [PATCH 2/4] pipeline: move port type registration to library Cristian Dumitrescu
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Cristian Dumitrescu @ 2021-11-26 23:51 UTC (permalink / raw)
  To: dev; +Cc: yogesh.jangra

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/4] pipeline: move port type registration to library
  2021-11-26 23:51 [PATCH 1/4] pipeline: improve the drop instruction Cristian Dumitrescu
@ 2021-11-26 23:51 ` Cristian Dumitrescu
  2021-11-26 23:51 ` [PATCH 3/4] pipeline: move table " Cristian Dumitrescu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Cristian Dumitrescu @ 2021-11-26 23:51 UTC (permalink / raw)
  To: dev; +Cc: yogesh.jangra

Move the port type registration for the well known port types from the
application to the pipeline library.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Yogesh Jangra <yogesh.jangra@intel.com>
---
 examples/pipeline/obj.c         |  54 -----------
 lib/pipeline/rte_swx_pipeline.c | 159 ++++++++++++++++++++++++--------
 2 files changed, 123 insertions(+), 90 deletions(-)

diff --git a/examples/pipeline/obj.c b/examples/pipeline/obj.c
index 569207a79d..4b2db66c46 100644
--- a/examples/pipeline/obj.c
+++ b/examples/pipeline/obj.c
@@ -16,10 +16,6 @@
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
-#include <rte_swx_port_ethdev.h>
-#include <rte_swx_port_fd.h>
-#include <rte_swx_port_ring.h>
-#include <rte_swx_port_source_sink.h>
 #include <rte_swx_table_em.h>
 #include <rte_swx_table_wm.h>
 #include <rte_swx_pipeline.h>
@@ -543,56 +539,6 @@ pipeline_create(struct obj *obj, const char *name, int numa_node)
 	if (status)
 		goto error;
 
-	status = rte_swx_pipeline_port_in_type_register(p,
-		"ethdev",
-		&rte_swx_port_ethdev_reader_ops);
-	if (status)
-		goto error;
-
-	status = rte_swx_pipeline_port_out_type_register(p,
-		"ethdev",
-		&rte_swx_port_ethdev_writer_ops);
-	if (status)
-		goto error;
-
-	status = rte_swx_pipeline_port_in_type_register(p,
-		"ring",
-		&rte_swx_port_ring_reader_ops);
-	if (status)
-		goto error;
-
-	status = rte_swx_pipeline_port_out_type_register(p,
-		"ring",
-		&rte_swx_port_ring_writer_ops);
-	if (status)
-		goto error;
-
-#ifdef RTE_PORT_PCAP
-	status = rte_swx_pipeline_port_in_type_register(p,
-		"source",
-		&rte_swx_port_source_ops);
-	if (status)
-		goto error;
-#endif
-
-	status = rte_swx_pipeline_port_out_type_register(p,
-		"sink",
-		&rte_swx_port_sink_ops);
-	if (status)
-		goto error;
-
-	status = rte_swx_pipeline_port_in_type_register(p,
-		"fd",
-		&rte_swx_port_fd_reader_ops);
-	if (status)
-		goto error;
-
-	status = rte_swx_pipeline_port_out_type_register(p,
-		"fd",
-		&rte_swx_port_fd_writer_ops);
-	if (status)
-		goto error;
-
 	status = rte_swx_pipeline_table_type_register(p,
 		"exact",
 		RTE_SWX_TABLE_MATCH_EXACT,
diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index ff2fe964a5..bebad98e99 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -7,6 +7,11 @@
 #include <arpa/inet.h>
 #include <dlfcn.h>
 
+#include <rte_swx_port_ethdev.h>
+#include <rte_swx_port_fd.h>
+#include <rte_swx_port_ring.h>
+#include "rte_swx_port_source_sink.h"
+
 #include "rte_swx_pipeline_internal.h"
 
 #define CHECK(condition, err_code)                                             \
@@ -8982,17 +8987,122 @@ metarray_free(struct rte_swx_pipeline *p)
 /*
  * Pipeline.
  */
+void
+rte_swx_pipeline_free(struct rte_swx_pipeline *p)
+{
+	void *lib;
+
+	if (!p)
+		return;
+
+	lib = p->lib;
+
+	free(p->instruction_data);
+	free(p->instructions);
+
+	metarray_free(p);
+	regarray_free(p);
+	table_state_free(p);
+	learner_free(p);
+	selector_free(p);
+	table_free(p);
+	action_free(p);
+	instruction_table_free(p);
+	metadata_free(p);
+	header_free(p);
+	extern_func_free(p);
+	extern_obj_free(p);
+	port_out_free(p);
+	port_in_free(p);
+	struct_free(p);
+
+	free(p);
+
+	if (lib)
+		dlclose(lib);
+}
+
+static int
+port_in_types_register(struct rte_swx_pipeline *p)
+{
+	int status;
+
+	status = rte_swx_pipeline_port_in_type_register(p,
+		"ethdev",
+		&rte_swx_port_ethdev_reader_ops);
+	if (status)
+		return status;
+
+	status = rte_swx_pipeline_port_in_type_register(p,
+		"ring",
+		&rte_swx_port_ring_reader_ops);
+	if (status)
+		return status;
+
+#ifdef RTE_PORT_PCAP
+	status = rte_swx_pipeline_port_in_type_register(p,
+		"source",
+		&rte_swx_port_source_ops);
+	if (status)
+		return status;
+#endif
+
+	status = rte_swx_pipeline_port_in_type_register(p,
+		"fd",
+		&rte_swx_port_fd_reader_ops);
+	if (status)
+		return status;
+
+	return 0;
+}
+
+static int
+port_out_types_register(struct rte_swx_pipeline *p)
+{
+	int status;
+
+	status = rte_swx_pipeline_port_out_type_register(p,
+		"ethdev",
+		&rte_swx_port_ethdev_writer_ops);
+	if (status)
+		return status;
+
+	status = rte_swx_pipeline_port_out_type_register(p,
+		"ring",
+		&rte_swx_port_ring_writer_ops);
+	if (status)
+		return status;
+
+	status = rte_swx_pipeline_port_out_type_register(p,
+		"sink",
+		&rte_swx_port_sink_ops);
+	if (status)
+		return status;
+
+	status = rte_swx_pipeline_port_out_type_register(p,
+		"fd",
+		&rte_swx_port_fd_writer_ops);
+	if (status)
+		return status;
+
+	return 0;
+}
+
 int
 rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node)
 {
-	struct rte_swx_pipeline *pipeline;
+	struct rte_swx_pipeline *pipeline = NULL;
+	int status = 0;
 
 	/* Check input parameters. */
 	CHECK(p, EINVAL);
 
 	/* Memory allocation. */
 	pipeline = calloc(1, sizeof(struct rte_swx_pipeline));
-	CHECK(pipeline, ENOMEM);
+	if (!pipeline) {
+		status = -ENOMEM;
+		goto error;
+	}
 
 	/* Initialization. */
 	TAILQ_INIT(&pipeline->struct_types);
@@ -9016,43 +9126,20 @@ rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node)
 	pipeline->n_structs = 1; /* Struct 0 is reserved for action_data. */
 	pipeline->numa_node = numa_node;
 
-	*p = pipeline;
-	return 0;
-}
-
-void
-rte_swx_pipeline_free(struct rte_swx_pipeline *p)
-{
-	void *lib;
-
-	if (!p)
-		return;
-
-	lib = p->lib;
-
-	free(p->instruction_data);
-	free(p->instructions);
+	status = port_in_types_register(pipeline);
+	if (status)
+		goto error;
 
-	metarray_free(p);
-	regarray_free(p);
-	table_state_free(p);
-	learner_free(p);
-	selector_free(p);
-	table_free(p);
-	action_free(p);
-	instruction_table_free(p);
-	metadata_free(p);
-	header_free(p);
-	extern_func_free(p);
-	extern_obj_free(p);
-	port_out_free(p);
-	port_in_free(p);
-	struct_free(p);
+	status = port_out_types_register(pipeline);
+	if (status)
+		goto error;
 
-	free(p);
+	*p = pipeline;
+	return 0;
 
-	if (lib)
-		dlclose(lib);
+error:
+	rte_swx_pipeline_free(pipeline);
+	return status;
 }
 
 int
-- 
2.17.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/4] pipeline: move table type registration to library
  2021-11-26 23:51 [PATCH 1/4] pipeline: improve the drop instruction Cristian Dumitrescu
  2021-11-26 23:51 ` [PATCH 2/4] pipeline: move port type registration to library Cristian Dumitrescu
@ 2021-11-26 23:51 ` Cristian Dumitrescu
  2021-11-26 23:51 ` [PATCH 4/4] pipeline: add drop port for each pipeline Cristian Dumitrescu
  2021-11-27  0:02 ` [PATCH V2 1/4] pipeline: improve the drop instruction Cristian Dumitrescu
  3 siblings, 0 replies; 9+ messages in thread
From: Cristian Dumitrescu @ 2021-11-26 23:51 UTC (permalink / raw)
  To: dev; +Cc: yogesh.jangra

Move the table type registration for the well known table types from
the application to the pipeline library.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Yogesh Jangra <yogesh.jangra@intel.com>
---
 examples/pipeline/obj.c         | 16 ----------------
 lib/pipeline/rte_swx_pipeline.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/examples/pipeline/obj.c b/examples/pipeline/obj.c
index 4b2db66c46..b79f044ac7 100644
--- a/examples/pipeline/obj.c
+++ b/examples/pipeline/obj.c
@@ -16,8 +16,6 @@
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
-#include <rte_swx_table_em.h>
-#include <rte_swx_table_wm.h>
 #include <rte_swx_pipeline.h>
 #include <rte_swx_ctl.h>
 
@@ -539,20 +537,6 @@ pipeline_create(struct obj *obj, const char *name, int numa_node)
 	if (status)
 		goto error;
 
-	status = rte_swx_pipeline_table_type_register(p,
-		"exact",
-		RTE_SWX_TABLE_MATCH_EXACT,
-		&rte_swx_table_exact_match_ops);
-	if (status)
-		goto error;
-
-	status = rte_swx_pipeline_table_type_register(p,
-		"wildcard",
-		RTE_SWX_TABLE_MATCH_WILDCARD,
-		&rte_swx_table_wildcard_match_ops);
-	if (status)
-		goto error;
-
 	/* Node allocation */
 	pipeline = calloc(1, sizeof(struct pipeline));
 	if (pipeline == NULL)
diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index bebad98e99..a05a4edc7d 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -12,6 +12,9 @@
 #include <rte_swx_port_ring.h>
 #include "rte_swx_port_source_sink.h"
 
+#include <rte_swx_table_em.h>
+#include <rte_swx_table_wm.h>
+ 
 #include "rte_swx_pipeline_internal.h"
 
 #define CHECK(condition, err_code)                                             \
@@ -9088,6 +9091,28 @@ port_out_types_register(struct rte_swx_pipeline *p)
 	return 0;
 }
 
+static int
+table_types_register(struct rte_swx_pipeline *p)
+{
+	int status;
+
+	status = rte_swx_pipeline_table_type_register(p,
+		"exact",
+		RTE_SWX_TABLE_MATCH_EXACT,
+		&rte_swx_table_exact_match_ops);
+	if (status)
+		return status;
+
+	status = rte_swx_pipeline_table_type_register(p,
+		"wildcard",
+		RTE_SWX_TABLE_MATCH_WILDCARD,
+		&rte_swx_table_wildcard_match_ops);
+	if (status)
+		return status;
+
+	return 0;
+}
+
 int
 rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node)
 {
@@ -9134,6 +9159,10 @@ rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node)
 	if (status)
 		goto error;
 
+	status = table_types_register(pipeline);
+	if (status)
+		goto error;
+
 	*p = pipeline;
 	return 0;
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 4/4] pipeline: add drop port for each pipeline
  2021-11-26 23:51 [PATCH 1/4] pipeline: improve the drop instruction 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 ` Cristian Dumitrescu
  2021-11-27  0:02 ` [PATCH V2 1/4] pipeline: improve the drop instruction Cristian Dumitrescu
  3 siblings, 0 replies; 9+ messages in thread
From: Cristian Dumitrescu @ 2021-11-26 23:51 UTC (permalink / raw)
  To: dev; +Cc: yogesh.jangra

An additional output port is now implicitly created for every pipeline
to seve as the packet drop port. Up to now, the drop port had to be
explicitly created for each pipeline.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Yogesh Jangra <yogesh.jangra@intel.com>
---
 examples/pipeline/cli.c                   | 15 +++++++++++----
 examples/pipeline/examples/fib.cli        |  1 -
 examples/pipeline/examples/learner.cli    |  1 -
 examples/pipeline/examples/selector.cli   |  1 -
 examples/pipeline/examples/varbit.cli     |  1 -
 examples/pipeline/examples/vxlan.cli      |  1 -
 examples/pipeline/examples/vxlan_pcap.cli |  1 -
 lib/pipeline/rte_swx_pipeline.c           | 11 +++++++++++
 8 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c
index 83b460caf6..c32349e5f0 100644
--- a/examples/pipeline/cli.c
+++ b/examples/pipeline/cli.c
@@ -2551,10 +2551,17 @@ cmd_pipeline_stats(char **tokens,
 
 		rte_swx_ctl_pipeline_port_out_stats_read(p->p, i, &stats);
 
-		snprintf(out, out_size, "\tPort %u:"
-			" packets %" PRIu64
-			" bytes %" PRIu64 "\n",
-			i, stats.n_pkts, stats.n_bytes);
+		if (i != info.n_ports_out - 1)
+			snprintf(out, out_size, "\tPort %u:"
+				" packets %" PRIu64
+				" bytes %" PRIu64 "\n",
+				i, stats.n_pkts, stats.n_bytes);
+		else
+			snprintf(out, out_size, "\tDROP:"
+				" packets %" PRIu64
+				" bytes %" PRIu64 "\n",
+				stats.n_pkts, stats.n_bytes);
+
 		out_size -= strlen(out);
 		out += strlen(out);
 	}
diff --git a/examples/pipeline/examples/fib.cli b/examples/pipeline/examples/fib.cli
index b20aed3cf6..93ab2b08f8 100644
--- a/examples/pipeline/examples/fib.cli
+++ b/examples/pipeline/examples/fib.cli
@@ -25,7 +25,6 @@ pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32
 pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32
 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32
 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32
-pipeline PIPELINE0 port out 4 sink none
 
 pipeline PIPELINE0 build ./examples/pipeline/examples/fib.spec
 
diff --git a/examples/pipeline/examples/learner.cli b/examples/pipeline/examples/learner.cli
index af7792624f..688ce34f34 100644
--- a/examples/pipeline/examples/learner.cli
+++ b/examples/pipeline/examples/learner.cli
@@ -25,7 +25,6 @@ pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32
 pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32
 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32
 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32
-pipeline PIPELINE0 port out 4 sink none
 
 pipeline PIPELINE0 build ./examples/pipeline/examples/learner.spec
 
diff --git a/examples/pipeline/examples/selector.cli b/examples/pipeline/examples/selector.cli
index 36f3ead541..123782c57b 100644
--- a/examples/pipeline/examples/selector.cli
+++ b/examples/pipeline/examples/selector.cli
@@ -19,7 +19,6 @@ pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32
 pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32
 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32
 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32
-pipeline PIPELINE0 port out 4 sink none
 
 pipeline PIPELINE0 build ./examples/pipeline/examples/selector.spec
 
diff --git a/examples/pipeline/examples/varbit.cli b/examples/pipeline/examples/varbit.cli
index 0589e32c15..9caeb9ca26 100644
--- a/examples/pipeline/examples/varbit.cli
+++ b/examples/pipeline/examples/varbit.cli
@@ -25,7 +25,6 @@ pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32
 pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32
 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32
 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32
-pipeline PIPELINE0 port out 4 sink none
 
 pipeline PIPELINE0 build ./examples/pipeline/examples/varbit.spec
 
diff --git a/examples/pipeline/examples/vxlan.cli b/examples/pipeline/examples/vxlan.cli
index a3bde6a9f9..444f3f7bd8 100644
--- a/examples/pipeline/examples/vxlan.cli
+++ b/examples/pipeline/examples/vxlan.cli
@@ -19,7 +19,6 @@ pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32
 pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32
 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32
 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32
-pipeline PIPELINE0 port out 4 sink none
 
 pipeline PIPELINE0 build ./examples/pipeline/examples/vxlan.spec
 pipeline PIPELINE0 table vxlan_table add ./examples/pipeline/examples/vxlan_table.txt
diff --git a/examples/pipeline/examples/vxlan_pcap.cli b/examples/pipeline/examples/vxlan_pcap.cli
index c03dc9303d..83fca8d0d9 100644
--- a/examples/pipeline/examples/vxlan_pcap.cli
+++ b/examples/pipeline/examples/vxlan_pcap.cli
@@ -14,7 +14,6 @@ pipeline PIPELINE0 port out 0 sink none
 pipeline PIPELINE0 port out 1 sink none
 pipeline PIPELINE0 port out 2 sink none
 pipeline PIPELINE0 port out 3 sink none
-pipeline PIPELINE0 port out 4 sink none
 
 pipeline PIPELINE0 build ./examples/pipeline/examples/vxlan.spec
 pipeline PIPELINE0 table vxlan_table add ./examples/pipeline/examples/vxlan_table.txt
diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index a05a4edc7d..9dfbe9bb7f 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -9199,6 +9199,9 @@ pipeline_compile(struct rte_swx_pipeline *p);
 int
 rte_swx_pipeline_build(struct rte_swx_pipeline *p)
 {
+	struct rte_swx_port_sink_params drop_port_params = {
+		.file_name = NULL,
+	};
 	int status;
 
 	CHECK(p, EINVAL);
@@ -9208,6 +9211,14 @@ rte_swx_pipeline_build(struct rte_swx_pipeline *p)
 	if (status)
 		goto error;
 
+	/* Drop port. */
+	status = rte_swx_pipeline_port_out_config(p,
+						  p->n_ports_out,
+						  "sink",
+						  &drop_port_params);
+	if (status)
+		goto error;
+
 	status = port_out_build(p);
 	if (status)
 		goto error;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH V2 1/4] pipeline: improve the drop instruction
  2021-11-26 23:51 [PATCH 1/4] pipeline: improve the drop instruction Cristian Dumitrescu
                   ` (2 preceding siblings ...)
  2021-11-26 23:51 ` [PATCH 4/4] pipeline: add drop port for each pipeline Cristian Dumitrescu
@ 2021-11-27  0:02 ` Cristian Dumitrescu
  2021-11-27  0:02   ` [PATCH V2 2/4] pipeline: move port type registration to library Cristian Dumitrescu
                     ` (2 more replies)
  3 siblings, 3 replies; 9+ messages in thread
From: Cristian Dumitrescu @ 2021-11-27  0:02 UTC (permalink / raw)
  To: dev; +Cc: yogesh.jangra

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH V2 2/4] pipeline: move port type registration to library
  2021-11-27  0:02 ` [PATCH V2 1/4] pipeline: improve the drop instruction Cristian Dumitrescu
@ 2021-11-27  0:02   ` 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
  2 siblings, 0 replies; 9+ messages in thread
From: Cristian Dumitrescu @ 2021-11-27  0:02 UTC (permalink / raw)
  To: dev; +Cc: yogesh.jangra

Move the port type registration for the well known port types from the
application to the pipeline library.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Yogesh Jangra <yogesh.jangra@intel.com>
---
 examples/pipeline/obj.c         |  54 -----------
 lib/pipeline/rte_swx_pipeline.c | 159 ++++++++++++++++++++++++--------
 2 files changed, 123 insertions(+), 90 deletions(-)

diff --git a/examples/pipeline/obj.c b/examples/pipeline/obj.c
index 569207a79d..4b2db66c46 100644
--- a/examples/pipeline/obj.c
+++ b/examples/pipeline/obj.c
@@ -16,10 +16,6 @@
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
-#include <rte_swx_port_ethdev.h>
-#include <rte_swx_port_fd.h>
-#include <rte_swx_port_ring.h>
-#include <rte_swx_port_source_sink.h>
 #include <rte_swx_table_em.h>
 #include <rte_swx_table_wm.h>
 #include <rte_swx_pipeline.h>
@@ -543,56 +539,6 @@ pipeline_create(struct obj *obj, const char *name, int numa_node)
 	if (status)
 		goto error;
 
-	status = rte_swx_pipeline_port_in_type_register(p,
-		"ethdev",
-		&rte_swx_port_ethdev_reader_ops);
-	if (status)
-		goto error;
-
-	status = rte_swx_pipeline_port_out_type_register(p,
-		"ethdev",
-		&rte_swx_port_ethdev_writer_ops);
-	if (status)
-		goto error;
-
-	status = rte_swx_pipeline_port_in_type_register(p,
-		"ring",
-		&rte_swx_port_ring_reader_ops);
-	if (status)
-		goto error;
-
-	status = rte_swx_pipeline_port_out_type_register(p,
-		"ring",
-		&rte_swx_port_ring_writer_ops);
-	if (status)
-		goto error;
-
-#ifdef RTE_PORT_PCAP
-	status = rte_swx_pipeline_port_in_type_register(p,
-		"source",
-		&rte_swx_port_source_ops);
-	if (status)
-		goto error;
-#endif
-
-	status = rte_swx_pipeline_port_out_type_register(p,
-		"sink",
-		&rte_swx_port_sink_ops);
-	if (status)
-		goto error;
-
-	status = rte_swx_pipeline_port_in_type_register(p,
-		"fd",
-		&rte_swx_port_fd_reader_ops);
-	if (status)
-		goto error;
-
-	status = rte_swx_pipeline_port_out_type_register(p,
-		"fd",
-		&rte_swx_port_fd_writer_ops);
-	if (status)
-		goto error;
-
 	status = rte_swx_pipeline_table_type_register(p,
 		"exact",
 		RTE_SWX_TABLE_MATCH_EXACT,
diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index ff2fe964a5..bebad98e99 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -7,6 +7,11 @@
 #include <arpa/inet.h>
 #include <dlfcn.h>
 
+#include <rte_swx_port_ethdev.h>
+#include <rte_swx_port_fd.h>
+#include <rte_swx_port_ring.h>
+#include "rte_swx_port_source_sink.h"
+
 #include "rte_swx_pipeline_internal.h"
 
 #define CHECK(condition, err_code)                                             \
@@ -8982,17 +8987,122 @@ metarray_free(struct rte_swx_pipeline *p)
 /*
  * Pipeline.
  */
+void
+rte_swx_pipeline_free(struct rte_swx_pipeline *p)
+{
+	void *lib;
+
+	if (!p)
+		return;
+
+	lib = p->lib;
+
+	free(p->instruction_data);
+	free(p->instructions);
+
+	metarray_free(p);
+	regarray_free(p);
+	table_state_free(p);
+	learner_free(p);
+	selector_free(p);
+	table_free(p);
+	action_free(p);
+	instruction_table_free(p);
+	metadata_free(p);
+	header_free(p);
+	extern_func_free(p);
+	extern_obj_free(p);
+	port_out_free(p);
+	port_in_free(p);
+	struct_free(p);
+
+	free(p);
+
+	if (lib)
+		dlclose(lib);
+}
+
+static int
+port_in_types_register(struct rte_swx_pipeline *p)
+{
+	int status;
+
+	status = rte_swx_pipeline_port_in_type_register(p,
+		"ethdev",
+		&rte_swx_port_ethdev_reader_ops);
+	if (status)
+		return status;
+
+	status = rte_swx_pipeline_port_in_type_register(p,
+		"ring",
+		&rte_swx_port_ring_reader_ops);
+	if (status)
+		return status;
+
+#ifdef RTE_PORT_PCAP
+	status = rte_swx_pipeline_port_in_type_register(p,
+		"source",
+		&rte_swx_port_source_ops);
+	if (status)
+		return status;
+#endif
+
+	status = rte_swx_pipeline_port_in_type_register(p,
+		"fd",
+		&rte_swx_port_fd_reader_ops);
+	if (status)
+		return status;
+
+	return 0;
+}
+
+static int
+port_out_types_register(struct rte_swx_pipeline *p)
+{
+	int status;
+
+	status = rte_swx_pipeline_port_out_type_register(p,
+		"ethdev",
+		&rte_swx_port_ethdev_writer_ops);
+	if (status)
+		return status;
+
+	status = rte_swx_pipeline_port_out_type_register(p,
+		"ring",
+		&rte_swx_port_ring_writer_ops);
+	if (status)
+		return status;
+
+	status = rte_swx_pipeline_port_out_type_register(p,
+		"sink",
+		&rte_swx_port_sink_ops);
+	if (status)
+		return status;
+
+	status = rte_swx_pipeline_port_out_type_register(p,
+		"fd",
+		&rte_swx_port_fd_writer_ops);
+	if (status)
+		return status;
+
+	return 0;
+}
+
 int
 rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node)
 {
-	struct rte_swx_pipeline *pipeline;
+	struct rte_swx_pipeline *pipeline = NULL;
+	int status = 0;
 
 	/* Check input parameters. */
 	CHECK(p, EINVAL);
 
 	/* Memory allocation. */
 	pipeline = calloc(1, sizeof(struct rte_swx_pipeline));
-	CHECK(pipeline, ENOMEM);
+	if (!pipeline) {
+		status = -ENOMEM;
+		goto error;
+	}
 
 	/* Initialization. */
 	TAILQ_INIT(&pipeline->struct_types);
@@ -9016,43 +9126,20 @@ rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node)
 	pipeline->n_structs = 1; /* Struct 0 is reserved for action_data. */
 	pipeline->numa_node = numa_node;
 
-	*p = pipeline;
-	return 0;
-}
-
-void
-rte_swx_pipeline_free(struct rte_swx_pipeline *p)
-{
-	void *lib;
-
-	if (!p)
-		return;
-
-	lib = p->lib;
-
-	free(p->instruction_data);
-	free(p->instructions);
+	status = port_in_types_register(pipeline);
+	if (status)
+		goto error;
 
-	metarray_free(p);
-	regarray_free(p);
-	table_state_free(p);
-	learner_free(p);
-	selector_free(p);
-	table_free(p);
-	action_free(p);
-	instruction_table_free(p);
-	metadata_free(p);
-	header_free(p);
-	extern_func_free(p);
-	extern_obj_free(p);
-	port_out_free(p);
-	port_in_free(p);
-	struct_free(p);
+	status = port_out_types_register(pipeline);
+	if (status)
+		goto error;
 
-	free(p);
+	*p = pipeline;
+	return 0;
 
-	if (lib)
-		dlclose(lib);
+error:
+	rte_swx_pipeline_free(pipeline);
+	return status;
 }
 
 int
-- 
2.17.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH V2 3/4] pipeline: move table type registration to library
  2021-11-27  0:02 ` [PATCH V2 1/4] pipeline: improve the drop instruction Cristian Dumitrescu
  2021-11-27  0:02   ` [PATCH V2 2/4] pipeline: move port type registration to library Cristian Dumitrescu
@ 2021-11-27  0:02   ` Cristian Dumitrescu
  2021-11-27  0:02   ` [PATCH V2 4/4] pipeline: add drop port for each pipeline Cristian Dumitrescu
  2 siblings, 0 replies; 9+ messages in thread
From: Cristian Dumitrescu @ 2021-11-27  0:02 UTC (permalink / raw)
  To: dev; +Cc: yogesh.jangra

Move the table type registration for the well known table types from
the application to the pipeline library.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Yogesh Jangra <yogesh.jangra@intel.com>
---
 examples/pipeline/obj.c         | 16 ----------------
 lib/pipeline/rte_swx_pipeline.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/examples/pipeline/obj.c b/examples/pipeline/obj.c
index 4b2db66c46..b79f044ac7 100644
--- a/examples/pipeline/obj.c
+++ b/examples/pipeline/obj.c
@@ -16,8 +16,6 @@
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
-#include <rte_swx_table_em.h>
-#include <rte_swx_table_wm.h>
 #include <rte_swx_pipeline.h>
 #include <rte_swx_ctl.h>
 
@@ -539,20 +537,6 @@ pipeline_create(struct obj *obj, const char *name, int numa_node)
 	if (status)
 		goto error;
 
-	status = rte_swx_pipeline_table_type_register(p,
-		"exact",
-		RTE_SWX_TABLE_MATCH_EXACT,
-		&rte_swx_table_exact_match_ops);
-	if (status)
-		goto error;
-
-	status = rte_swx_pipeline_table_type_register(p,
-		"wildcard",
-		RTE_SWX_TABLE_MATCH_WILDCARD,
-		&rte_swx_table_wildcard_match_ops);
-	if (status)
-		goto error;
-
 	/* Node allocation */
 	pipeline = calloc(1, sizeof(struct pipeline));
 	if (pipeline == NULL)
diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index bebad98e99..dd914fd935 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -12,6 +12,9 @@
 #include <rte_swx_port_ring.h>
 #include "rte_swx_port_source_sink.h"
 
+#include <rte_swx_table_em.h>
+#include <rte_swx_table_wm.h>
+
 #include "rte_swx_pipeline_internal.h"
 
 #define CHECK(condition, err_code)                                             \
@@ -9088,6 +9091,28 @@ port_out_types_register(struct rte_swx_pipeline *p)
 	return 0;
 }
 
+static int
+table_types_register(struct rte_swx_pipeline *p)
+{
+	int status;
+
+	status = rte_swx_pipeline_table_type_register(p,
+		"exact",
+		RTE_SWX_TABLE_MATCH_EXACT,
+		&rte_swx_table_exact_match_ops);
+	if (status)
+		return status;
+
+	status = rte_swx_pipeline_table_type_register(p,
+		"wildcard",
+		RTE_SWX_TABLE_MATCH_WILDCARD,
+		&rte_swx_table_wildcard_match_ops);
+	if (status)
+		return status;
+
+	return 0;
+}
+
 int
 rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node)
 {
@@ -9134,6 +9159,10 @@ rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node)
 	if (status)
 		goto error;
 
+	status = table_types_register(pipeline);
+	if (status)
+		goto error;
+
 	*p = pipeline;
 	return 0;
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH V2 4/4] pipeline: add drop port for each pipeline
  2021-11-27  0:02 ` [PATCH V2 1/4] pipeline: improve the drop instruction Cristian Dumitrescu
  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   ` Cristian Dumitrescu
  2022-02-13 19:48     ` Thomas Monjalon
  2 siblings, 1 reply; 9+ messages in thread
From: Cristian Dumitrescu @ 2021-11-27  0:02 UTC (permalink / raw)
  To: dev; +Cc: yogesh.jangra

An additional output port is now implicitly created for every pipeline
to serve as the packet drop port. Up to now, the drop port had to be
explicitly created for each pipeline.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Yogesh Jangra <yogesh.jangra@intel.com>
---
 examples/pipeline/cli.c                   | 15 +++++++++++----
 examples/pipeline/examples/fib.cli        |  1 -
 examples/pipeline/examples/learner.cli    |  1 -
 examples/pipeline/examples/selector.cli   |  1 -
 examples/pipeline/examples/varbit.cli     |  1 -
 examples/pipeline/examples/vxlan.cli      |  1 -
 examples/pipeline/examples/vxlan_pcap.cli |  1 -
 lib/pipeline/rte_swx_pipeline.c           | 11 +++++++++++
 8 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c
index 83b460caf6..c32349e5f0 100644
--- a/examples/pipeline/cli.c
+++ b/examples/pipeline/cli.c
@@ -2551,10 +2551,17 @@ cmd_pipeline_stats(char **tokens,
 
 		rte_swx_ctl_pipeline_port_out_stats_read(p->p, i, &stats);
 
-		snprintf(out, out_size, "\tPort %u:"
-			" packets %" PRIu64
-			" bytes %" PRIu64 "\n",
-			i, stats.n_pkts, stats.n_bytes);
+		if (i != info.n_ports_out - 1)
+			snprintf(out, out_size, "\tPort %u:"
+				" packets %" PRIu64
+				" bytes %" PRIu64 "\n",
+				i, stats.n_pkts, stats.n_bytes);
+		else
+			snprintf(out, out_size, "\tDROP:"
+				" packets %" PRIu64
+				" bytes %" PRIu64 "\n",
+				stats.n_pkts, stats.n_bytes);
+
 		out_size -= strlen(out);
 		out += strlen(out);
 	}
diff --git a/examples/pipeline/examples/fib.cli b/examples/pipeline/examples/fib.cli
index b20aed3cf6..93ab2b08f8 100644
--- a/examples/pipeline/examples/fib.cli
+++ b/examples/pipeline/examples/fib.cli
@@ -25,7 +25,6 @@ pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32
 pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32
 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32
 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32
-pipeline PIPELINE0 port out 4 sink none
 
 pipeline PIPELINE0 build ./examples/pipeline/examples/fib.spec
 
diff --git a/examples/pipeline/examples/learner.cli b/examples/pipeline/examples/learner.cli
index af7792624f..688ce34f34 100644
--- a/examples/pipeline/examples/learner.cli
+++ b/examples/pipeline/examples/learner.cli
@@ -25,7 +25,6 @@ pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32
 pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32
 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32
 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32
-pipeline PIPELINE0 port out 4 sink none
 
 pipeline PIPELINE0 build ./examples/pipeline/examples/learner.spec
 
diff --git a/examples/pipeline/examples/selector.cli b/examples/pipeline/examples/selector.cli
index 36f3ead541..123782c57b 100644
--- a/examples/pipeline/examples/selector.cli
+++ b/examples/pipeline/examples/selector.cli
@@ -19,7 +19,6 @@ pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32
 pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32
 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32
 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32
-pipeline PIPELINE0 port out 4 sink none
 
 pipeline PIPELINE0 build ./examples/pipeline/examples/selector.spec
 
diff --git a/examples/pipeline/examples/varbit.cli b/examples/pipeline/examples/varbit.cli
index 0589e32c15..9caeb9ca26 100644
--- a/examples/pipeline/examples/varbit.cli
+++ b/examples/pipeline/examples/varbit.cli
@@ -25,7 +25,6 @@ pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32
 pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32
 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32
 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32
-pipeline PIPELINE0 port out 4 sink none
 
 pipeline PIPELINE0 build ./examples/pipeline/examples/varbit.spec
 
diff --git a/examples/pipeline/examples/vxlan.cli b/examples/pipeline/examples/vxlan.cli
index a3bde6a9f9..444f3f7bd8 100644
--- a/examples/pipeline/examples/vxlan.cli
+++ b/examples/pipeline/examples/vxlan.cli
@@ -19,7 +19,6 @@ pipeline PIPELINE0 port out 0 link LINK0 txq 0 bsz 32
 pipeline PIPELINE0 port out 1 link LINK1 txq 0 bsz 32
 pipeline PIPELINE0 port out 2 link LINK2 txq 0 bsz 32
 pipeline PIPELINE0 port out 3 link LINK3 txq 0 bsz 32
-pipeline PIPELINE0 port out 4 sink none
 
 pipeline PIPELINE0 build ./examples/pipeline/examples/vxlan.spec
 pipeline PIPELINE0 table vxlan_table add ./examples/pipeline/examples/vxlan_table.txt
diff --git a/examples/pipeline/examples/vxlan_pcap.cli b/examples/pipeline/examples/vxlan_pcap.cli
index c03dc9303d..83fca8d0d9 100644
--- a/examples/pipeline/examples/vxlan_pcap.cli
+++ b/examples/pipeline/examples/vxlan_pcap.cli
@@ -14,7 +14,6 @@ pipeline PIPELINE0 port out 0 sink none
 pipeline PIPELINE0 port out 1 sink none
 pipeline PIPELINE0 port out 2 sink none
 pipeline PIPELINE0 port out 3 sink none
-pipeline PIPELINE0 port out 4 sink none
 
 pipeline PIPELINE0 build ./examples/pipeline/examples/vxlan.spec
 pipeline PIPELINE0 table vxlan_table add ./examples/pipeline/examples/vxlan_table.txt
diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index dd914fd935..c332d44bd1 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -9199,6 +9199,9 @@ pipeline_compile(struct rte_swx_pipeline *p);
 int
 rte_swx_pipeline_build(struct rte_swx_pipeline *p)
 {
+	struct rte_swx_port_sink_params drop_port_params = {
+		.file_name = NULL,
+	};
 	int status;
 
 	CHECK(p, EINVAL);
@@ -9208,6 +9211,14 @@ rte_swx_pipeline_build(struct rte_swx_pipeline *p)
 	if (status)
 		goto error;
 
+	/* Drop port. */
+	status = rte_swx_pipeline_port_out_config(p,
+						  p->n_ports_out,
+						  "sink",
+						  &drop_port_params);
+	if (status)
+		goto error;
+
 	status = port_out_build(p);
 	if (status)
 		goto error;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH V2 4/4] pipeline: add drop port for each pipeline
  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
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas Monjalon @ 2022-02-13 19:48 UTC (permalink / raw)
  To: yogesh.jangra, Cristian Dumitrescu; +Cc: dev

27/11/2021 01:02, Cristian Dumitrescu:
> An additional output port is now implicitly created for every pipeline
> to serve as the packet drop port. Up to now, the drop port had to be
> explicitly created for each pipeline.
> 
> Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> Signed-off-by: Yogesh Jangra <yogesh.jangra@intel.com>

Series applied, thanks.




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-02-13 19:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-26 23:51 [PATCH 1/4] pipeline: improve the drop instruction 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 ` [PATCH V2 1/4] pipeline: improve the drop instruction Cristian Dumitrescu
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

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).