Skip to contentSkip to conversation

ip_pipeline: refactoring

PATCH Superseded Jasvinder Singh 2 participants 181 messages Mar 9, 2018 – Mar 30, 2018 Arm/Amlogic Meson SoC support Page 2 of 3

lore
Share & tools
lore
#83 lore raw

PATCH v3 26/44 ip_pipeline: add pipeline object

In reply to Jasvinder Singh

Add pipeline object implementation to the application.

---
 examples/ip_pipeline/Makefile    |   1 +
 examples/ip_pipeline/cli.c       | 786 +++++++++++++++++++++++++++++++++
 examples/ip_pipeline/cli.h       |   2 -
 examples/ip_pipeline/main.c      |   8 +
 examples/ip_pipeline/meson.build |   1 +
 examples/ip_pipeline/pipeline.c  | 930 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h  | 265 +++++++++++
 7 files changed, 1991 insertions(+), 2 deletions(-)
 create mode 100644 examples/ip_pipeline/pipeline.c
 create mode 100644 examples/ip_pipeline/pipeline.h
examples/ip_pipeline/Makefile +1 -0
index d9c8d86..033319d 100644
@@ -13,6 +13,7 @@ SRCS-y += link.c
 SRCS-y += main.c
 SRCS-y += mempool.c
 SRCS-y += parser.c
+SRCS-y += pipeline.c
 SRCS-y += swq.c
 SRCS-y += tap.c
 SRCS-y += tmgr.c
examples/ip_pipeline/cli.c +786 -0

804 lines not on this page · raw message

examples/ip_pipeline/cli.h +0 -2
index 02564a6..992e4c3 100644
@@ -7,8 +7,6 @@
 
 #include <stddef.h>
 
-#include "action.h"
-
 void
 cli_process(char *in, char *out, size_t out_size);
 
examples/ip_pipeline/main.c +8 -0
index 24b74cf..a7f4486 100644
@@ -15,6 +15,7 @@
 #include "kni.h"
 #include "link.h"
 #include "mempool.h"
+#include "pipeline.h"
 #include "swq.h"
 #include "tap.h"
 #include "tmgr.h"
@@ -215,6 +216,13 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* Pipeline */
+	status = pipeline_init();
+	if (status) {
+		printf("Error: Pipeline initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/meson.build +1 -0
index fb1b61d..2366242 100644
@@ -17,6 +17,7 @@ sources = files(
 	'main.c',
 	'mempool.c',
 	'parser.c',
+	'pipeline.c',
 	'swq.c',
 	'tap.c',
 	'tmgr.c'
examples/ip_pipeline/pipeline.c new file +930 -0

930 lines not on this page · raw message

examples/ip_pipeline/pipeline.h new file +265 -0

265 lines not on this page · raw message

Signature · 1 line
2.9.3
#84 lore raw

PATCH v3 27/44 ip_pipeline: add threads

In reply to Jasvinder Singh

Add threads data structure and initialisation functions to run the pipeline.

---
 examples/ip_pipeline/Makefile    |   2 +-
 examples/ip_pipeline/main.c      |   8 ++
 examples/ip_pipeline/meson.build |   1 +
 examples/ip_pipeline/thread.c    | 159 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/thread.h    |  13 ++++
 5 files changed, 182 insertions(+), 1 deletion(-)
 create mode 100644 examples/ip_pipeline/thread.c
 create mode 100644 examples/ip_pipeline/thread.h
examples/ip_pipeline/Makefile +1 -1
index 033319d..c936d1e 100644
@@ -16,8 +16,8 @@ SRCS-y += parser.c
 SRCS-y += pipeline.c
 SRCS-y += swq.c
 SRCS-y += tap.c
+SRCS-y += thread.c
 SRCS-y += tmgr.c
-#SRCS-y += thread.c
 
 # Build using pkg-config variables if possible
 $(shell pkg-config --exists libdpdk)
examples/ip_pipeline/main.c +8 -0
index a7f4486..d139290 100644
@@ -18,6 +18,7 @@
 #include "pipeline.h"
 #include "swq.h"
 #include "tap.h"
+#include "thread.h"
 #include "tmgr.h"
 
 static const char usage[] =
@@ -223,6 +224,13 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* Thread */
+	status = thread_init();
+	if (status) {
+		printf("Error: Thread initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/meson.build +1 -0
index 2366242..a9f2ea4 100644
@@ -20,5 +20,6 @@ sources = files(
 	'pipeline.c',
 	'swq.c',
 	'tap.c',
+	'thread.c',
 	'tmgr.c'
 )
examples/ip_pipeline/thread.c new file +159 -0

159 lines not on this page · raw message

examples/ip_pipeline/thread.h new file +13 -0
new file mode 100644
index 0000000..39c0d89
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _INCLUDE_THREAD_H_
+#define _INCLUDE_THREAD_H_
+
+#include <stdint.h>
+
+int
+thread_init(void);
+
+#endif /* _INCLUDE_THREAD_H_ */
Signature · 1 line
2.9.3
#85 lore raw

PATCH v3 28/44 ip_pipeline: add thread runtime

In reply to Jasvinder Singh

Add runtime thread functions for the pipeline.

---
 examples/ip_pipeline/main.c   |   6 ++
 examples/ip_pipeline/thread.c | 193 ++++++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/thread.h |   3 +
 3 files changed, 202 insertions(+)
examples/ip_pipeline/main.c +6 -0
index d139290..36da679 100644
@@ -8,6 +8,7 @@
 #include <unistd.h>
 #include <getopt.h>
 
+#include <rte_launch.h>
 #include <rte_eal.h>
 
 #include "cli.h"
@@ -231,6 +232,11 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	rte_eal_mp_remote_launch(
+		thread_main,
+		NULL,
+		SKIP_MASTER);
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/thread.c +193 -0

196 lines not on this page · raw message

examples/ip_pipeline/thread.h +3 -0
index 39c0d89..47db428 100644
@@ -10,4 +10,7 @@
 int
 thread_init(void);
 
+int
+thread_main(void *arg);
+
 #endif /* _INCLUDE_THREAD_H_ */
Signature · 1 line
2.9.3
#86 lore raw

PATCH v3 29/44 ip_pipeline: add cli to enable and disable pipeline

In reply to Jasvinder Singh

Add commands to enable and disable the pipeline on the thread.

---
 examples/ip_pipeline/cli.c    | 102 +++++++++++++++++
 examples/ip_pipeline/thread.c | 260 +++++++++++++++++++++++++++++++++++++++++-
 examples/ip_pipeline/thread.h |   8 ++
 3 files changed, 369 insertions(+), 1 deletion(-)
examples/ip_pipeline/cli.c +102 -0
index c82bbc3..a3642b4 100644
@@ -17,6 +17,7 @@
 #include "pipeline.h"
 #include "swq.h"
 #include "tap.h"
+#include "thread.h"
 #include "tmgr.h"
 
 #ifndef CMD_MAX_TOKENS
@@ -1740,6 +1741,91 @@ cmd_pipeline_port_in_table(char **tokens,
 	}
 }
 
+/**
+ * thread <thread_id> pipeline <pipeline_name> enable
+ */
+static void
+cmd_thread_pipeline_enable(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	char *pipeline_name;
+	uint32_t thread_id;
+	int status;
+
+	if (n_tokens != 5) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	if (parser_read_uint32(&thread_id, tokens[1]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
+		return;
+	}
+
+	if (strcmp(tokens[2], "pipeline") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
+		return;
+	}
+
+	pipeline_name = tokens[3];
+
+	if (strcmp(tokens[4], "enable") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "enable");
+		return;
+	}
+
+	status = thread_pipeline_enable(thread_id, pipeline_name);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, "thread pipeline enable");
+		return;
+	}
+}
+
+/**
+ * thread <thread_id> pipeline <pipeline_name> disable
+ */
+static void
+cmd_thread_pipeline_disable(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	char *pipeline_name;
+	uint32_t thread_id;
+	int status;
+
+	if (n_tokens != 5) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	if (parser_read_uint32(&thread_id, tokens[1]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
+		return;
+	}
+
+	if (strcmp(tokens[2], "pipeline") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
+		return;
+	}
+
+	pipeline_name = tokens[3];
+
+	if (strcmp(tokens[4], "disable") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "disable");
+		return;
+	}
+
+	status = thread_pipeline_disable(thread_id, pipeline_name);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL,
+			"thread pipeline disable");
+		return;
+	}
+}
+
 void
 cli_process(char *in, char *out, size_t out_size)
 {
@@ -1863,6 +1949,22 @@ cli_process(char *in, char *out, size_t out_size)
 		}
 	}
 
+	if (strcmp(tokens[0], "thread") == 0) {
+		if ((n_tokens >= 5) &&
+			(strcmp(tokens[4], "enable") == 0)) {
+			cmd_thread_pipeline_enable(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
+
+		if ((n_tokens >= 5) &&
+			(strcmp(tokens[4], "disable") == 0)) {
+			cmd_thread_pipeline_disable(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
+	}
+
 	snprintf(out, out_size, MSG_CMD_UNKNOWN, tokens[0]);
 }
 
examples/ip_pipeline/thread.c +259 -1

295 lines not on this page · raw message

examples/ip_pipeline/thread.h +8 -0
index 47db428..facdf00 100644
@@ -8,6 +8,14 @@
 #include <stdint.h>
 
 int
+thread_pipeline_enable(uint32_t thread_id,
+	const char *pipeline_name);
+
+int
+thread_pipeline_disable(uint32_t thread_id,
+	const char *pipeline_name);
+
+int
 thread_init(void);
 
 int
Signature · 1 line
2.9.3
#87 lore raw

PATCH v3 30/44 ip_pipeline: add cli to enable and disable pipeline port

In reply to Jasvinder Singh

Add commands to enable and disable the pipeline ports.

---
 examples/ip_pipeline/cli.c      | 112 +++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h |   8 ++
 examples/ip_pipeline/thread.c   | 163 +++++++++++++++++++++++++++++++++++++++-
 3 files changed, 282 insertions(+), 1 deletion(-)
examples/ip_pipeline/cli.c +112 -0
index a3642b4..b9b2138 100644
@@ -1742,6 +1742,100 @@ cmd_pipeline_port_in_table(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> port in <port_id> enable
+ */
+static void
+cmd_pipeline_port_in_enable(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	char *pipeline_name;
+	uint32_t port_id;
+	int status;
+
+	if (n_tokens != 6) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "port") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (strcmp(tokens[3], "in") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
+		return;
+	}
+
+	if (parser_read_uint32(&port_id, tokens[4]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
+		return;
+	}
+
+	if (strcmp(tokens[5], "enable") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "enable");
+		return;
+	}
+
+	status = pipeline_port_in_enable(pipeline_name, port_id);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
+ * pipeline <pipeline_name> port in <port_id> disable
+ */
+static void
+cmd_pipeline_port_in_disable(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	char *pipeline_name;
+	uint32_t port_id;
+	int status;
+
+	if (n_tokens != 6) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "port") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (strcmp(tokens[3], "in") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
+		return;
+	}
+
+	if (parser_read_uint32(&port_id, tokens[4]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
+		return;
+	}
+
+	if (strcmp(tokens[5], "disable") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "disable");
+		return;
+	}
+
+	status = pipeline_port_in_disable(pipeline_name, port_id);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -1947,6 +2041,24 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 6) &&
+			(strcmp(tokens[2], "port") == 0) &&
+			(strcmp(tokens[3], "in") == 0) &&
+			(strcmp(tokens[5], "enable") == 0)) {
+			cmd_pipeline_port_in_enable(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
+
+		if ((n_tokens >= 6) &&
+			(strcmp(tokens[2], "port") == 0) &&
+			(strcmp(tokens[3], "in") == 0) &&
+			(strcmp(tokens[5], "disable") == 0)) {
+			cmd_pipeline_port_in_disable(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +8 -0
index dbc6f77..9b79b67 100644
@@ -262,4 +262,12 @@ struct table_rule_action {
 	struct rte_table_action_time_params time;
 };
 
+int
+pipeline_port_in_enable(const char *pipeline_name,
+	uint32_t port_id);
+
+int
+pipeline_port_in_disable(const char *pipeline_name,
+	uint32_t port_id);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +162 -1

193 lines not on this page · raw message

Signature · 1 line
2.9.3
#88 lore raw

PATCH v3 31/44 ip_pipeline: add cli to read pipeline port and table stats

In reply to Jasvinder Singh

Add commands to read the pipeline port in, port out and table stats.

---
 examples/ip_pipeline/cli.c      | 256 ++++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h |  18 +++
 examples/ip_pipeline/thread.c   | 246 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 520 insertions(+)
examples/ip_pipeline/cli.c +256 -0
index b9b2138..bbf98aa 100644
@@ -1742,6 +1742,83 @@ cmd_pipeline_port_in_table(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> port in <port_id> stats read [clear]
+ */
+
+#define MSG_PIPELINE_PORT_IN_STATS                         \
+	"Pkts in: %" PRIu64 "\n"                           \
+	"Pkts dropped by AH: %" PRIu64 "\n"                \
+	"Pkts dropped by other: %" PRIu64 "\n"
+
+static void
+cmd_pipeline_port_in_stats(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct rte_pipeline_port_in_stats stats;
+	char *pipeline_name;
+	uint32_t port_id;
+	int clear, status;
+
+	if ((n_tokens != 7) && (n_tokens != 8)) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "port") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (strcmp(tokens[3], "in") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
+		return;
+	}
+
+	if (parser_read_uint32(&port_id, tokens[4]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
+		return;
+	}
+
+	if (strcmp(tokens[5], "stats") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
+		return;
+	}
+
+	if (strcmp(tokens[6], "read") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
+		return;
+	}
+
+	clear = 0;
+	if (n_tokens == 8) {
+		if (strcmp(tokens[7], "clear") != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "clear");
+			return;
+		}
+
+		clear = 1;
+	}
+
+	status = pipeline_port_in_stats_read(pipeline_name,
+		port_id,
+		&stats,
+		clear);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+
+	snprintf(out, out_size, MSG_PIPELINE_PORT_IN_STATS,
+		stats.stats.n_pkts_in,
+		stats.n_pkts_dropped_by_ah,
+		stats.stats.n_pkts_drop);
+}
+
+/**
  * pipeline <pipeline_name> port in <port_id> enable
  */
 static void
@@ -1836,6 +1913,159 @@ cmd_pipeline_port_in_disable(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> port out <port_id> stats read [clear]
+ */
+#define MSG_PIPELINE_PORT_OUT_STATS                        \
+	"Pkts in: %" PRIu64 "\n"                           \
+	"Pkts dropped by AH: %" PRIu64 "\n"                \
+	"Pkts dropped by other: %" PRIu64 "\n"
+
+static void
+cmd_pipeline_port_out_stats(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct rte_pipeline_port_out_stats stats;
+	char *pipeline_name;
+	uint32_t port_id;
+	int clear, status;
+
+	if ((n_tokens != 7) && (n_tokens != 8)) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "port") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (strcmp(tokens[3], "out") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "out");
+		return;
+	}
+
+	if (parser_read_uint32(&port_id, tokens[4]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
+		return;
+	}
+
+	if (strcmp(tokens[5], "stats") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
+		return;
+	}
+
+	if (strcmp(tokens[6], "read") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
+		return;
+	}
+
+	clear = 0;
+	if (n_tokens == 8) {
+		if (strcmp(tokens[7], "clear") != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "clear");
+			return;
+		}
+
+		clear = 1;
+	}
+
+	status = pipeline_port_out_stats_read(pipeline_name,
+		port_id,
+		&stats,
+		clear);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+
+	snprintf(out, out_size, MSG_PIPELINE_PORT_OUT_STATS,
+		stats.stats.n_pkts_in,
+		stats.n_pkts_dropped_by_ah,
+		stats.stats.n_pkts_drop);
+}
+
+/**
+ * pipeline <pipeline_name> table <table_id> stats read [clear]
+ */
+#define MSG_PIPELINE_TABLE_STATS                                     \
+	"Pkts in: %" PRIu64 "\n"                                     \
+	"Pkts in with lookup miss: %" PRIu64 "\n"                    \
+	"Pkts in with lookup hit dropped by AH: %" PRIu64 "\n"       \
+	"Pkts in with lookup hit dropped by others: %" PRIu64 "\n"   \
+	"Pkts in with lookup miss dropped by AH: %" PRIu64 "\n"      \
+	"Pkts in with lookup miss dropped by others: %" PRIu64 "\n"
+
+static void
+cmd_pipeline_table_stats(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct rte_pipeline_table_stats stats;
+	char *pipeline_name;
+	uint32_t table_id;
+	int clear, status;
+
+	if ((n_tokens != 6) && (n_tokens != 7)) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "stats") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
+		return;
+	}
+
+	if (strcmp(tokens[5], "read") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
+		return;
+	}
+
+	clear = 0;
+	if (n_tokens == 7) {
+		if (strcmp(tokens[6], "clear") != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "clear");
+			return;
+		}
+
+		clear = 1;
+	}
+
+	status = pipeline_table_stats_read(pipeline_name,
+		table_id,
+		&stats,
+		clear);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+
+	snprintf(out, out_size, MSG_PIPELINE_TABLE_STATS,
+		stats.stats.n_pkts_in,
+		stats.stats.n_pkts_lookup_miss,
+		stats.n_pkts_dropped_by_lkp_hit_ah,
+		stats.n_pkts_dropped_lkp_hit,
+		stats.n_pkts_dropped_by_lkp_miss_ah,
+		stats.n_pkts_dropped_lkp_miss);
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -2045,6 +2275,15 @@ cli_process(char *in, char *out, size_t out_size)
 		if ((n_tokens >= 6) &&
 			(strcmp(tokens[2], "port") == 0) &&
 			(strcmp(tokens[3], "in") == 0) &&
+			(strcmp(tokens[5], "stats") == 0)) {
+			cmd_pipeline_port_in_stats(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
+
+		if ((n_tokens >= 6) &&
+			(strcmp(tokens[2], "port") == 0) &&
+			(strcmp(tokens[3], "in") == 0) &&
 			(strcmp(tokens[5], "enable") == 0)) {
 			cmd_pipeline_port_in_enable(tokens, n_tokens,
 				out, out_size);
@@ -2059,6 +2298,23 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 6) &&
+			(strcmp(tokens[2], "port") == 0) &&
+			(strcmp(tokens[3], "out") == 0) &&
+			(strcmp(tokens[5], "stats") == 0)) {
+			cmd_pipeline_port_out_stats(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
+
+		if ((n_tokens >= 5) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "stats") == 0)) {
+			cmd_pipeline_table_stats(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +18 -0
index 9b79b67..9b2c295 100644
@@ -263,6 +263,12 @@ struct table_rule_action {
 };
 
 int
+pipeline_port_in_stats_read(const char *pipeline_name,
+	uint32_t port_id,
+	struct rte_pipeline_port_in_stats *stats,
+	int clear);
+
+int
 pipeline_port_in_enable(const char *pipeline_name,
 	uint32_t port_id);
 
@@ -270,4 +276,16 @@ int
 pipeline_port_in_disable(const char *pipeline_name,
 	uint32_t port_id);
 
+int
+pipeline_port_out_stats_read(const char *pipeline_name,
+	uint32_t port_id,
+	struct rte_pipeline_port_out_stats *stats,
+	int clear);
+
+int
+pipeline_table_stats_read(const char *pipeline_name,
+	uint32_t table_id,
+	struct rte_pipeline_table_stats *stats,
+	int clear);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +246 -0

301 lines not on this page · raw message

Signature · 1 line
2.9.3
#89 lore raw

PATCH v3 32/44 ip_pipeline: add cli for pipeline table entries

In reply to Jasvinder Singh

Add commands to add pipeline table entries which contains match and action part.

---
 examples/ip_pipeline/cli.c      | 1273 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h |   13 +
 examples/ip_pipeline/thread.c   |  749 +++++++++++++++++++++++
 3 files changed, 2035 insertions(+)
examples/ip_pipeline/cli.c +1273 -0
index bbf98aa..b353b99 100644
@@ -8,6 +8,7 @@
 #include <string.h>
 
 #include <rte_common.h>
+#include <rte_cycles.h>
 
 #include "cli.h"
 #include "kni.h"
@@ -2066,6 +2067,1261 @@ cmd_pipeline_table_stats(char **tokens,
 }
 
 /**
+ * <match> ::=
+ *
+ * match
+ *    acl
+ *       priority <priority>
+ *       ipv4 | ipv6 <sa> <sa_depth> <da> <da_depth>
+ *       <sp0> <sp1> <dp0> <dp1> <proto>
+ *    | array
+ *       pos
+ *    | hash
+ *       raw <key>
+ *       | ipv4_5tuple <sa> <da> <sp> <dp> <proto>
+ *       | ipv6_5tuple <sa> <da> <sp> <dp> <proto>
+ *       | ipv4_addr <addr>
+ *       | ipv6_addr <addr>
+ *       | qinq <svlan> <cvlan>
+ *    | lpm
+ *       ipv4 | ipv6 <addr> <depth>
+ */
+struct pkt_key_qinq {
+	uint16_t ethertype_svlan;
+	uint16_t svlan;
+	uint16_t ethertype_cvlan;
+	uint16_t cvlan;
+} __attribute__((__packed__));
+
+struct pkt_key_ipv4_5tuple {
+	uint8_t time_to_live;
+	uint8_t proto;
+	uint16_t hdr_checksum;
+	uint32_t sa;
+	uint32_t da;
+	uint16_t sp;
+	uint16_t dp;
+} __attribute__((__packed__));
+
+struct pkt_key_ipv6_5tuple {
+	uint16_t payload_length;
+	uint8_t proto;
+	uint8_t hop_limit;
+	uint8_t sa[16];
+	uint8_t da[16];
+	uint16_t sp;
+	uint16_t dp;
+} __attribute__((__packed__));
+
+struct pkt_key_ipv4_addr {
+	uint32_t addr;
+} __attribute__((__packed__));
+
+struct pkt_key_ipv6_addr {
+	uint8_t addr[16];
+} __attribute__((__packed__));
+
+static uint32_t
+parse_match(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size,
+	struct table_rule_match *m)
+{
+	memset(m, 0, sizeof(*m));
+
+	if (n_tokens < 2)
+		return 0;
+
+	if (strcmp(tokens[0], "match") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "match");
+		return 0;
+	}
+
+	if (strcmp(tokens[1], "acl") == 0) {
+		if (n_tokens < 14) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return 0;
+		}
+
+		m->match_type = TABLE_ACL;
+
+		if (strcmp(tokens[2], "priority") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "priority");
+			return 0;
+		}
+
+		if (parser_read_uint32(&m->match.acl.priority,
+			tokens[3]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "priority");
+			return 0;
+		}
+
+		if (strcmp(tokens[4], "ipv4") == 0) {
+			struct in_addr saddr, daddr;
+
+			m->match.acl.ip_version = 1;
+
+			if (parse_ipv4_addr(tokens[5], &saddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "sa");
+				return 0;
+			}
+			m->match.acl.ipv4.sa = rte_be_to_cpu_32(saddr.s_addr);
+
+			if (parse_ipv4_addr(tokens[7], &daddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "da");
+				return 0;
+			}
+			m->match.acl.ipv4.da = rte_be_to_cpu_32(daddr.s_addr);
+		} else if (strcmp(tokens[4], "ipv6") == 0) {
+			struct in6_addr saddr, daddr;
+
+			m->match.acl.ip_version = 0;
+
+			if (parse_ipv6_addr(tokens[5], &saddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "sa");
+				return 0;
+			}
+			memcpy(m->match.acl.ipv6.sa, saddr.s6_addr, 16);
+
+			if (parse_ipv6_addr(tokens[7], &daddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "da");
+				return 0;
+			}
+			memcpy(m->match.acl.ipv6.da, daddr.s6_addr, 16);
+		} else {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND,
+				"ipv4 or ipv6");
+			return 0;
+		}
+
+		if (parser_read_uint32(&m->match.acl.sa_depth,
+			tokens[6]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "sa_depth");
+			return 0;
+		}
+
+		if (parser_read_uint32(&m->match.acl.da_depth,
+			tokens[8]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "da_depth");
+			return 0;
+		}
+
+		if (parser_read_uint16(&m->match.acl.sp0, tokens[9]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "sp0");
+			return 0;
+		}
+
+		if (parser_read_uint16(&m->match.acl.sp1, tokens[10]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "sp1");
+			return 0;
+		}
+
+		if (parser_read_uint16(&m->match.acl.dp0, tokens[11]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "dp0");
+			return 0;
+		}
+
+		if (parser_read_uint16(&m->match.acl.dp1, tokens[12]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "dp1");
+			return 0;
+		}
+
+		if (parser_read_uint8(&m->match.acl.proto, tokens[13]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "proto");
+			return 0;
+		}
+
+		m->match.acl.proto_mask = 0xff;
+
+		return 14;
+	} /* acl */
+
+	if (strcmp(tokens[1], "array") == 0) {
+		if (n_tokens < 3) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return 0;
+		}
+
+		m->match_type = TABLE_ARRAY;
+
+		if (parser_read_uint32(&m->match.array.pos, tokens[2]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "pos");
+			return 0;
+		}
+
+		return 3;
+	} /* array */
+
+	if (strcmp(tokens[1], "hash") == 0) {
+		if (n_tokens < 3) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return 0;
+		}
+
+		m->match_type = TABLE_HASH;
+
+		if (strcmp(tokens[2], "raw") == 0) {
+			uint32_t key_size = TABLE_RULE_MATCH_SIZE_MAX;
+
+			if (n_tokens < 4) {
+				snprintf(out, out_size, MSG_ARG_MISMATCH,
+					tokens[0]);
+				return 0;
+			}
+
+			if (parse_hex_string(tokens[3],
+				m->match.hash.key, &key_size) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "key");
+				return 0;
+			}
+
+			return 4;
+		} /* hash raw */
+
+		if (strcmp(tokens[2], "ipv4_5tuple") == 0) {
+			struct pkt_key_ipv4_5tuple *ipv4 =
+				(struct pkt_key_ipv4_5tuple *) m->match.hash.key;
+			struct in_addr saddr, daddr;
+			uint16_t sp, dp;
+			uint8_t proto;
+
+			if (n_tokens < 8) {
+				snprintf(out, out_size, MSG_ARG_MISMATCH,
+					tokens[0]);
+				return 0;
+			}
+
+			if (parse_ipv4_addr(tokens[3], &saddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "sa");
+				return 0;
+			}
+
+			if (parse_ipv4_addr(tokens[4], &daddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "da");
+				return 0;
+			}
+
+			if (parser_read_uint16(&sp, tokens[5]) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "sp");
+				return 0;
+			}
+
+			if (parser_read_uint16(&dp, tokens[6]) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "dp");
+				return 0;
+			}
+
+			if (parser_read_uint8(&proto, tokens[7]) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"proto");
+				return 0;
+			}
+
+			ipv4->sa = saddr.s_addr;
+			ipv4->da = daddr.s_addr;
+			ipv4->sp = rte_cpu_to_be_16(sp);
+			ipv4->dp = rte_cpu_to_be_16(dp);
+			ipv4->proto = proto;
+
+			return 8;
+		} /* hash ipv4_5tuple */
+
+		if (strcmp(tokens[2], "ipv6_5tuple") == 0) {
+			struct pkt_key_ipv6_5tuple *ipv6 =
+				(struct pkt_key_ipv6_5tuple *) m->match.hash.key;
+			struct in6_addr saddr, daddr;
+			uint16_t sp, dp;
+			uint8_t proto;
+
+			if (n_tokens < 8) {
+				snprintf(out, out_size, MSG_ARG_MISMATCH,
+					tokens[0]);
+				return 0;
+			}
+
+			if (parse_ipv6_addr(tokens[3], &saddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "sa");
+				return 0;
+			}
+
+			if (parse_ipv6_addr(tokens[4], &daddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "da");
+				return 0;
+			}
+
+			if (parser_read_uint16(&sp, tokens[5]) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "sp");
+				return 0;
+			}
+
+			if (parser_read_uint16(&dp, tokens[6]) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "dp");
+				return 0;
+			}
+
+			if (parser_read_uint8(&proto, tokens[7]) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"proto");
+				return 0;
+			}
+
+			memcpy(ipv6->sa, saddr.s6_addr, 16);
+			memcpy(ipv6->da, daddr.s6_addr, 16);
+			ipv6->sp = rte_cpu_to_be_16(sp);
+			ipv6->dp = rte_cpu_to_be_16(dp);
+			ipv6->proto = proto;
+
+			return 8;
+		} /* hash ipv6_5tuple */
+
+		if (strcmp(tokens[2], "ipv4_addr") == 0) {
+			struct pkt_key_ipv4_addr *ipv4_addr =
+				(struct pkt_key_ipv4_addr *) m->match.hash.key;
+			struct in_addr addr;
+
+			if (n_tokens < 4) {
+				snprintf(out, out_size, MSG_ARG_MISMATCH,
+					tokens[0]);
+				return 0;
+			}
+
+			if (parse_ipv4_addr(tokens[3], &addr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"addr");
+				return 0;
+			}
+
+			ipv4_addr->addr = addr.s_addr;
+
+			return 4;
+		} /* hash ipv4_addr */
+
+		if (strcmp(tokens[2], "ipv6_addr") == 0) {
+			struct pkt_key_ipv6_addr *ipv6_addr =
+				(struct pkt_key_ipv6_addr *) m->match.hash.key;
+			struct in6_addr addr;
+
+			if (n_tokens < 4) {
+				snprintf(out, out_size, MSG_ARG_MISMATCH,
+					tokens[0]);
+				return 0;
+			}
+
+			if (parse_ipv6_addr(tokens[3], &addr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"addr");
+				return 0;
+			}
+
+			memcpy(ipv6_addr->addr, addr.s6_addr, 16);
+
+			return 4;
+		} /* hash ipv6_5tuple */
+
+		if (strcmp(tokens[2], "qinq") == 0) {
+			struct pkt_key_qinq *qinq =
+				(struct pkt_key_qinq *) m->match.hash.key;
+			uint16_t svlan, cvlan;
+
+			if (n_tokens < 5) {
+				snprintf(out, out_size, MSG_ARG_MISMATCH,
+					tokens[0]);
+				return 0;
+			}
+
+			if ((parser_read_uint16(&svlan, tokens[3]) != 0) ||
+				(svlan > 0xFFF)) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"svlan");
+				return 0;
+			}
+
+			if ((parser_read_uint16(&cvlan, tokens[4]) != 0) ||
+				(cvlan > 0xFFF)) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"cvlan");
+				return 0;
+			}
+
+			qinq->svlan = rte_cpu_to_be_16(svlan);
+			qinq->cvlan = rte_cpu_to_be_16(cvlan);
+
+			return 5;
+		} /* hash qinq */
+
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return 0;
+	} /* hash */
+
+	if (strcmp(tokens[1], "lpm") == 0) {
+		if (n_tokens < 5) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return 0;
+		}
+
+		m->match_type = TABLE_LPM;
+
+		if (strcmp(tokens[2], "ipv4") == 0) {
+			struct in_addr addr;
+
+			m->match.lpm.ip_version = 1;
+
+			if (parse_ipv4_addr(tokens[3], &addr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"addr");
+				return 0;
+			}
+
+			m->match.lpm.ipv4 = rte_be_to_cpu_32(addr.s_addr);
+		} else if (strcmp(tokens[2], "ipv6") == 0) {
+			struct in6_addr addr;
+
+			m->match.lpm.ip_version = 0;
+
+			if (parse_ipv6_addr(tokens[3], &addr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"addr");
+				return 0;
+			}
+
+			memcpy(m->match.lpm.ipv6, addr.s6_addr, 16);
+		} else {
+			snprintf(out, out_size, MSG_ARG_MISMATCH,
+				"ipv4 or ipv6");
+			return 0;
+		}
+
+		if (parser_read_uint8(&m->match.lpm.depth, tokens[4]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "depth");
+			return 0;
+		}
+
+		return 5;
+	} /* lpm */
+
+	snprintf(out, out_size, MSG_ARG_MISMATCH,
+		"acl or array or hash or lpm");
+	return 0;
+}
+
+/**
+ * table_action ::=
+ *
+ * action
+ *    fwd drop | port <port_id> | table <table_id>
+ *    [meter
+ *       tc0 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
+ *       [tc1 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
+ *        tc2 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
+ *        tc3 meter <meter_profile_id> policer g <pa> y <pa> r <pa>]]
+ *    [tm subport <subport_id> pipe <pipe_id>]
+ *    [encap
+ *       ether <da> <sa>
+ *       | vlan <da> <sa> <pcp> <dei> <vid>
+ *       | qinq <da> <sa> <pcp> <dei> <vid> <pcp> <dei> <vid>
+ *       | mpls unicast | multicast
+ *          <da> <sa>
+ *          label0 <label> <tc> <ttl>
+ *          [label1 <label> <tc> <ttl>
+ *          [label2 <label> <tc> <ttl>
+ *          [label3 <label> <tc> <ttl>]]]
+ *       | pppoe <da> <sa> <session_id>]
+ *    [nat ipv4 | ipv6 <addr> <port>]
+ *    [ttl dec | keep]
+ *    [stats]
+ *    [time]
+ *
+ * where:
+ *    <pa> ::= g | y | r | drop
+ */
+static uint32_t
+parse_table_action_fwd(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens == 0) || (strcmp(tokens[0], "fwd") != 0))
+		return 0;
+
+	tokens++;
+	n_tokens--;
+
+	if (n_tokens && (strcmp(tokens[0], "drop") == 0)) {
+		a->fwd.action = RTE_PIPELINE_ACTION_DROP;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
+		return 1 + 1;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "port") == 0)) {
+		uint32_t id;
+
+		if ((n_tokens < 2) ||
+			parser_read_uint32(&id, tokens[1]))
+			return 0;
+
+		a->fwd.action = RTE_PIPELINE_ACTION_PORT;
+		a->fwd.id = id;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
+		return 1 + 2;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "table") == 0)) {
+		uint32_t id;
+
+		if ((n_tokens < 2) ||
+			parser_read_uint32(&id, tokens[1]))
+			return 0;
+
+		a->fwd.action = RTE_PIPELINE_ACTION_TABLE;
+		a->fwd.id = id;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
+		return 1 + 2;
+	}
+
+	return 0;
+}
+
+static int
+parse_policer_action(char *token, enum rte_table_action_policer *a)
+{
+	if (strcmp(token, "g") == 0) {
+		*a = RTE_TABLE_ACTION_POLICER_COLOR_GREEN;
+		return 0;
+	}
+
+	if (strcmp(token, "y") == 0) {
+		*a = RTE_TABLE_ACTION_POLICER_COLOR_YELLOW;
+		return 0;
+	}
+
+	if (strcmp(token, "r") == 0) {
+		*a = RTE_TABLE_ACTION_POLICER_COLOR_RED;
+		return 0;
+	}
+
+	if (strcmp(token, "drop") == 0) {
+		*a = RTE_TABLE_ACTION_POLICER_DROP;
+		return 0;
+	}
+
+	return -1;
+}
+
+static uint32_t
+parse_table_action_meter_tc(char **tokens,
+	uint32_t n_tokens,
+	struct rte_table_action_mtr_tc_params *mtr)
+{
+	if ((n_tokens < 9) ||
+		strcmp(tokens[0], "meter") ||
+		parser_read_uint32(&mtr->meter_profile_id, tokens[1]) ||
+		strcmp(tokens[2], "policer") ||
+		strcmp(tokens[3], "g") ||
+		parse_policer_action(tokens[4], &mtr->policer[e_RTE_METER_GREEN]) ||
+		strcmp(tokens[5], "y") ||
+		parse_policer_action(tokens[6], &mtr->policer[e_RTE_METER_YELLOW]) ||
+		strcmp(tokens[7], "r") ||
+		parse_policer_action(tokens[8], &mtr->policer[e_RTE_METER_RED]))
+		return 0;
+
+	return 9;
+}
+
+static uint32_t
+parse_table_action_meter(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens == 0) || strcmp(tokens[0], "meter"))
+		return 0;
+
+	tokens++;
+	n_tokens--;
+
+	if ((n_tokens < 10) ||
+		strcmp(tokens[0], "tc0") ||
+		(parse_table_action_meter_tc(tokens + 1,
+			n_tokens - 1,
+			&a->mtr.mtr[0]) == 0))
+		return 0;
+
+	tokens += 10;
+	n_tokens -= 10;
+
+	if ((n_tokens == 0) || strcmp(tokens[0], "tc1")) {
+		a->mtr.tc_mask = 1;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_MTR;
+		return 1 + 10;
+	}
+
+	if ((n_tokens < 30) ||
+		(parse_table_action_meter_tc(tokens + 1,
+			n_tokens - 1, &a->mtr.mtr[1]) == 0) ||
+		strcmp(tokens[10], "tc2") ||
+		(parse_table_action_meter_tc(tokens + 11,
+			n_tokens - 11, &a->mtr.mtr[2]) == 0) ||
+		strcmp(tokens[20], "tc3") ||
+		(parse_table_action_meter_tc(tokens + 21,
+			n_tokens - 21, &a->mtr.mtr[3]) == 0))
+		return 0;
+
+	a->mtr.tc_mask = 0xF;
+	a->action_mask |= 1 << RTE_TABLE_ACTION_MTR;
+	return 1 + 10 + 3 * 10;
+}
+
+static uint32_t
+parse_table_action_tm(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	uint32_t subport_id, pipe_id;
+
+	if ((n_tokens < 5) ||
+		strcmp(tokens[0], "tm") ||
+		strcmp(tokens[1], "subport") ||
+		parser_read_uint32(&subport_id, tokens[2]) ||
+		strcmp(tokens[3], "pipe") ||
+		parser_read_uint32(&pipe_id, tokens[4]))
+		return 0;
+
+	a->tm.subport_id = subport_id;
+	a->tm.pipe_id = pipe_id;
+	a->action_mask |= 1 << RTE_TABLE_ACTION_TM;
+	return 5;
+}
+
+static uint32_t
+parse_table_action_encap(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens == 0) || strcmp(tokens[0], "encap"))
+		return 0;
+
+	tokens++;
+	n_tokens--;
+
+	/* ether */
+	if (n_tokens && (strcmp(tokens[0], "ether") == 0)) {
+		if ((n_tokens < 3) ||
+			parse_mac_addr(tokens[1], &a->encap.ether.ether.da) ||
+			parse_mac_addr(tokens[2], &a->encap.ether.ether.sa))
+			return 0;
+
+		a->encap.type = RTE_TABLE_ACTION_ENCAP_ETHER;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+		return 1 + 3;
+	}
+
+	/* vlan */
+	if (n_tokens && (strcmp(tokens[0], "vlan") == 0)) {
+		uint32_t pcp, dei, vid;
+
+		if ((n_tokens < 6) ||
+			parse_mac_addr(tokens[1], &a->encap.vlan.ether.da) ||
+			parse_mac_addr(tokens[2], &a->encap.vlan.ether.sa) ||
+			parser_read_uint32(&pcp, tokens[3]) ||
+			(pcp > 0x7) ||
+			parser_read_uint32(&dei, tokens[4]) ||
+			(dei > 0x1) ||
+			parser_read_uint32(&vid, tokens[5]) ||
+			(vid > 0xFFF))
+			return 0;
+
+		a->encap.vlan.vlan.pcp = pcp & 0x7;
+		a->encap.vlan.vlan.dei = dei & 0x1;
+		a->encap.vlan.vlan.vid = vid & 0xFFF;
+		a->encap.type = RTE_TABLE_ACTION_ENCAP_VLAN;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+		return 1 + 6;
+	}
+
+	/* qinq */
+	if (n_tokens && (strcmp(tokens[0], "qinq") == 0)) {
+		uint32_t svlan_pcp, svlan_dei, svlan_vid;
+		uint32_t cvlan_pcp, cvlan_dei, cvlan_vid;
+
+		if ((n_tokens < 9) ||
+			parse_mac_addr(tokens[1], &a->encap.qinq.ether.da) ||
+			parse_mac_addr(tokens[2], &a->encap.qinq.ether.sa) ||
+			parser_read_uint32(&svlan_pcp, tokens[3]) ||
+			(svlan_pcp > 0x7) ||
+			parser_read_uint32(&svlan_dei, tokens[4]) ||
+			(svlan_dei > 0x1) ||
+			parser_read_uint32(&svlan_vid, tokens[5]) ||
+			(svlan_vid > 0xFFF) ||
+			parser_read_uint32(&cvlan_pcp, tokens[6]) ||
+			(cvlan_pcp > 0x7) ||
+			parser_read_uint32(&cvlan_dei, tokens[7]) ||
+			(cvlan_dei > 0x1) ||
+			parser_read_uint32(&cvlan_vid, tokens[8]) ||
+			(cvlan_vid > 0xFFF))
+			return 0;
+
+		a->encap.qinq.svlan.pcp = svlan_pcp & 0x7;
+		a->encap.qinq.svlan.dei = svlan_dei & 0x1;
+		a->encap.qinq.svlan.vid = svlan_vid & 0xFFF;
+		a->encap.qinq.cvlan.pcp = cvlan_pcp & 0x7;
+		a->encap.qinq.cvlan.dei = cvlan_dei & 0x1;
+		a->encap.qinq.cvlan.vid = cvlan_vid & 0xFFF;
+		a->encap.type = RTE_TABLE_ACTION_ENCAP_QINQ;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+		return 1 + 9;
+	}
+
+	/* mpls */
+	if (n_tokens && (strcmp(tokens[0], "mpls") == 0)) {
+		uint32_t label, tc, ttl;
+
+		if (n_tokens < 8)
+			return 0;
+
+		if (strcmp(tokens[1], "unicast") == 0)
+			a->encap.mpls.unicast = 1;
+		else if (strcmp(tokens[1], "multicast") == 0)
+			a->encap.mpls.unicast = 0;
+		else
+			return 0;
+
+		if (parse_mac_addr(tokens[2], &a->encap.mpls.ether.da) ||
+			parse_mac_addr(tokens[3], &a->encap.mpls.ether.sa) ||
+			strcmp(tokens[4], "label0") ||
+			parser_read_uint32(&label, tokens[5]) ||
+			(label > 0xFFFFF) ||
+			parser_read_uint32(&tc, tokens[6]) ||
+			(tc > 0x7) ||
+			parser_read_uint32(&ttl, tokens[7]) ||
+			(ttl > 0x3F))
+			return 0;
+
+		a->encap.mpls.mpls[0].label = label;
+		a->encap.mpls.mpls[0].tc = tc;
+		a->encap.mpls.mpls[0].ttl = ttl;
+
+		tokens += 8;
+		n_tokens -= 8;
+
+		if ((n_tokens == 0) || strcmp(tokens[0], "label1")) {
+			a->encap.mpls.mpls_count = 1;
+			a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
+			a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+			return 1 + 8;
+		}
+
+		if ((n_tokens < 4) ||
+			parser_read_uint32(&label, tokens[1]) ||
+			(label > 0xFFFFF) ||
+			parser_read_uint32(&tc, tokens[2]) ||
+			(tc > 0x7) ||
+			parser_read_uint32(&ttl, tokens[3]) ||
+			(ttl > 0x3F))
+			return 0;
+
+		a->encap.mpls.mpls[1].label = label;
+		a->encap.mpls.mpls[1].tc = tc;
+		a->encap.mpls.mpls[1].ttl = ttl;
+
+		tokens += 4;
+		n_tokens -= 4;
+
+		if ((n_tokens == 0) || strcmp(tokens[0], "label2")) {
+			a->encap.mpls.mpls_count = 2;
+			a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
+			a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+			return 1 + 8 + 4;
+		}
+
+		if ((n_tokens < 4) ||
+			parser_read_uint32(&label, tokens[1]) ||
+			(label > 0xFFFFF) ||
+			parser_read_uint32(&tc, tokens[2]) ||
+			(tc > 0x7) ||
+			parser_read_uint32(&ttl, tokens[3]) ||
+			(ttl > 0x3F))
+			return 0;
+
+		a->encap.mpls.mpls[2].label = label;
+		a->encap.mpls.mpls[2].tc = tc;
+		a->encap.mpls.mpls[2].ttl = ttl;
+
+		tokens += 4;
+		n_tokens -= 4;
+
+		if ((n_tokens == 0) || strcmp(tokens[0], "label3")) {
+			a->encap.mpls.mpls_count = 3;
+			a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
+			a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+			return 1 + 8 + 4 + 4;
+		}
+
+		if ((n_tokens < 4) ||
+			parser_read_uint32(&label, tokens[1]) ||
+			(label > 0xFFFFF) ||
+			parser_read_uint32(&tc, tokens[2]) ||
+			(tc > 0x7) ||
+			parser_read_uint32(&ttl, tokens[3]) ||
+			(ttl > 0x3F))
+			return 0;
+
+		a->encap.mpls.mpls[3].label = label;
+		a->encap.mpls.mpls[3].tc = tc;
+		a->encap.mpls.mpls[3].ttl = ttl;
+
+		a->encap.mpls.mpls_count = 4;
+		a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+		return 1 + 8 + 4 + 4 + 4;
+	}
+
+	/* pppoe */
+	if (n_tokens && (strcmp(tokens[0], "pppoe") == 0)) {
+		if ((n_tokens < 4) ||
+			parse_mac_addr(tokens[1], &a->encap.pppoe.ether.da) ||
+			parse_mac_addr(tokens[2], &a->encap.pppoe.ether.sa) ||
+			parser_read_uint16(&a->encap.pppoe.pppoe.session_id,
+				tokens[3]))
+			return 0;
+
+		a->encap.type = RTE_TABLE_ACTION_ENCAP_PPPOE;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+		return 1 + 4;
+	}
+
+	return 0;
+}
+
+static uint32_t
+parse_table_action_nat(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens < 4) ||
+		strcmp(tokens[0], "nat"))
+		return 0;
+
+	if (strcmp(tokens[1], "ipv4") == 0) {
+		struct in_addr addr;
+		uint16_t port;
+
+		if (parse_ipv4_addr(tokens[2], &addr) ||
+			parser_read_uint16(&port, tokens[3]))
+			return 0;
+
+		a->nat.ip_version = 1;
+		a->nat.addr.ipv4 = rte_be_to_cpu_32(addr.s_addr);
+		a->nat.port = port;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_NAT;
+		return 4;
+	}
+
+	if (strcmp(tokens[1], "ipv6") == 0) {
+		struct in6_addr addr;
+		uint16_t port;
+
+		if (parse_ipv6_addr(tokens[2], &addr) ||
+			parser_read_uint16(&port, tokens[3]))
+			return 0;
+
+		a->nat.ip_version = 0;
+		memcpy(a->nat.addr.ipv6, addr.s6_addr, 16);
+		a->nat.port = port;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_NAT;
+		return 4;
+	}
+
+	return 0;
+}
+
+static uint32_t
+parse_table_action_ttl(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens < 2) ||
+		strcmp(tokens[0], "ttl"))
+		return 0;
+
+	if (strcmp(tokens[1], "dec") == 0)
+		a->ttl.decrement = 1;
+	else if (strcmp(tokens[1], "keep") == 0)
+		a->ttl.decrement = 0;
+	else
+		return 0;
+
+	a->action_mask |= 1 << RTE_TABLE_ACTION_TTL;
+	return 2;
+}
+
+static uint32_t
+parse_table_action_stats(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens < 1) ||
+		strcmp(tokens[0], "stats"))
+		return 0;
+
+	a->stats.n_packets = 0;
+	a->stats.n_bytes = 0;
+	a->action_mask |= 1 << RTE_TABLE_ACTION_STATS;
+	return 1;
+}
+
+static uint32_t
+parse_table_action_time(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens < 1) ||
+		strcmp(tokens[0], "time"))
+		return 0;
+
+	a->time.time = rte_rdtsc();
+	a->action_mask |= 1 << RTE_TABLE_ACTION_TIME;
+	return 1;
+}
+
+static uint32_t
+parse_table_action(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size,
+	struct table_rule_action *a)
+{
+	uint32_t n_tokens0 = n_tokens;
+
+	memset(a, 0, sizeof(*a));
+
+	if ((n_tokens < 2) ||
+		strcmp(tokens[0], "action"))
+		return 0;
+
+	tokens++;
+	n_tokens--;
+
+	if (n_tokens && (strcmp(tokens[0], "fwd") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_fwd(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action fwd");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "meter") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_meter(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action meter");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "tm") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_tm(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action tm");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "encap") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_encap(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action encap");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "nat") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_nat(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action nat");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "ttl") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_ttl(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action ttl");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "stats") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_stats(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action stats");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "time") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_time(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action time");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens0 - n_tokens == 1) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "action");
+		return 0;
+	}
+
+	return n_tokens0 - n_tokens;
+}
+
+/**
+ * pipeline <pipeline_name> table <table_id> rule add
+ *    match <match>
+ *    action <table_action>
+ */
+static void
+cmd_pipeline_table_rule_add(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct table_rule_match m;
+	struct table_rule_action a;
+	char *pipeline_name;
+	void *data;
+	uint32_t table_id, t0, n_tokens_parsed;
+	int status;
+
+	if (n_tokens < 8) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "rule") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
+		return;
+	}
+
+	if (strcmp(tokens[5], "add") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
+		return;
+	}
+
+	t0 = 6;
+
+	/* match */
+	n_tokens_parsed = parse_match(tokens + t0,
+		n_tokens - t0,
+		out,
+		out_size,
+		&m);
+	if (n_tokens_parsed == 0)
+		return;
+	t0 += n_tokens_parsed;
+
+	/* action */
+	n_tokens_parsed = parse_table_action(tokens + t0,
+		n_tokens - t0,
+		out,
+		out_size,
+		&a);
+	if (n_tokens_parsed == 0)
+		return;
+	t0 += n_tokens_parsed;
+
+	if (t0 != n_tokens) {
+		snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
+		return;
+	}
+
+	status = pipeline_table_rule_add(pipeline_name, table_id,
+		&m, &a, &data);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
+ * pipeline <pipeline_name> table <table_id> rule add
+ *    match
+ *       default
+ *    action
+ *       fwd drop | port <port_id> | table <table_id>
+ */
+static void
+cmd_pipeline_table_rule_add_default(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct table_rule_action action;
+	void *data;
+	char *pipeline_name;
+	uint32_t table_id;
+	int status;
+
+	if ((n_tokens != 11) && (n_tokens != 12)) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "rule") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
+		return;
+	}
+
+	if (strcmp(tokens[5], "add") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
+		return;
+	}
+
+	if (strcmp(tokens[6], "match") != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "match");
+		return;
+	}
+
+	if (strcmp(tokens[7], "default") != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "default");
+		return;
+	}
+
+	if (strcmp(tokens[8], "action") != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "action");
+		return;
+	}
+
+	if (strcmp(tokens[9], "fwd") != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "fwd");
+		return;
+	}
+
+	action.action_mask = 1 << RTE_TABLE_ACTION_FWD;
+
+	if (strcmp(tokens[10], "drop") == 0) {
+		if (n_tokens != 11) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return;
+		}
+
+		action.fwd.action = RTE_PIPELINE_ACTION_DROP;
+	} else if (strcmp(tokens[10], "port") == 0) {
+		uint32_t id;
+
+		if (n_tokens != 12) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return;
+		}
+
+		if (parser_read_uint32(&id, tokens[11]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
+			return;
+		}
+
+		action.fwd.action = RTE_PIPELINE_ACTION_PORT;
+		action.fwd.id = id;
+	} else if (strcmp(tokens[10], "table") == 0) {
+		uint32_t id;
+
+		if (n_tokens != 12) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return;
+		}
+
+		if (parser_read_uint32(&id, tokens[11]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+			return;
+		}
+
+		action.fwd.action = RTE_PIPELINE_ACTION_TABLE;
+		action.fwd.id = id;
+	} else {
+		snprintf(out, out_size, MSG_ARG_INVALID,
+			"drop or port or table");
+		return;
+	}
+
+	status = pipeline_table_rule_add_default(pipeline_name,
+		table_id,
+		&action,
+		&data);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -2315,6 +3571,23 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 7) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "rule") == 0) &&
+			(strcmp(tokens[5], "add") == 0) &&
+			(strcmp(tokens[6], "match") == 0)) {
+			if ((n_tokens >= 8) &&
+				(strcmp(tokens[7], "default") == 0)) {
+				cmd_pipeline_table_rule_add_default(tokens,
+					n_tokens, out, out_size);
+				return;
+			}
+
+			cmd_pipeline_table_rule_add(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +13 -0
index 9b2c295..9351024 100644
@@ -288,4 +288,17 @@ pipeline_table_stats_read(const char *pipeline_name,
 	struct rte_pipeline_table_stats *stats,
 	int clear);
 
+int
+pipeline_table_rule_add(const char *pipeline_name,
+	uint32_t table_id,
+	struct table_rule_match *match,
+	struct table_rule_action *action,
+	void **data);
+
+int
+pipeline_table_rule_add_default(const char *pipeline_name,
+	uint32_t table_id,
+	struct table_rule_action *action,
+	void **data);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +749 -0

797 lines not on this page · raw message

Signature · 1 line
2.9.3
#90 lore raw

PATCH v3 33/44 ip_pipeline: add cli to delete pipeline table entry

In reply to Jasvinder Singh

Add command to delete the pipeline table entry.

---
 examples/ip_pipeline/cli.c      | 145 ++++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h |   9 +++
 examples/ip_pipeline/thread.c   | 140 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 294 insertions(+)
examples/ip_pipeline/cli.c +145 -0
index b353b99..88df168 100644
@@ -3322,6 +3322,134 @@ cmd_pipeline_table_rule_add_default(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> table <table_id> rule delete
+ *    match <match>
+ */
+static void
+cmd_pipeline_table_rule_delete(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct table_rule_match m;
+	char *pipeline_name;
+	uint32_t table_id, n_tokens_parsed, t0;
+	int status;
+
+	if (n_tokens < 8) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "rule") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
+		return;
+	}
+
+	if (strcmp(tokens[5], "delete") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
+		return;
+	}
+
+	t0 = 6;
+
+	/* match */
+	n_tokens_parsed = parse_match(tokens + t0,
+		n_tokens - t0,
+		out,
+		out_size,
+		&m);
+	if (n_tokens_parsed == 0)
+		return;
+	t0 += n_tokens_parsed;
+
+	if (n_tokens != t0) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	status = pipeline_table_rule_delete(pipeline_name,
+		table_id,
+		&m);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
+ * pipeline <pipeline_name> table <table_id> rule delete
+ *    match
+ *       default
+ */
+static void
+cmd_pipeline_table_rule_delete_default(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	char *pipeline_name;
+	uint32_t table_id;
+	int status;
+
+	if (n_tokens != 8) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "rule") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
+		return;
+	}
+
+	if (strcmp(tokens[5], "delete") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
+		return;
+	}
+
+	if (strcmp(tokens[6], "match") != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "match");
+		return;
+	}
+
+	if (strcmp(tokens[7], "default") != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "default");
+		return;
+	}
+
+	status = pipeline_table_rule_delete_default(pipeline_name,
+		table_id);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -3588,6 +3716,23 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 7) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "rule") == 0) &&
+			(strcmp(tokens[5], "delete") == 0) &&
+			(strcmp(tokens[6], "match") == 0)) {
+			if ((n_tokens >= 8) &&
+				(strcmp(tokens[7], "default") == 0)) {
+				cmd_pipeline_table_rule_delete_default(tokens,
+					n_tokens, out, out_size);
+				return;
+				}
+
+			cmd_pipeline_table_rule_delete(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +9 -0
index 9351024..2bf6360 100644
@@ -301,4 +301,13 @@ pipeline_table_rule_add_default(const char *pipeline_name,
 	struct table_rule_action *action,
 	void **data);
 
+int
+pipeline_table_rule_delete(const char *pipeline_name,
+	uint32_t table_id,
+	struct table_rule_match *match);
+
+int
+pipeline_table_rule_delete_default(const char *pipeline_name,
+	uint32_t table_id);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +140 -0

176 lines not on this page · raw message

Signature · 1 line
2.9.3
#91 lore raw

PATCH v3 34/44 ip_pipeline: add cli to read pipeline table entry stats

In reply to Jasvinder Singh

Add command to read the pipeline table entry stats.

---
 examples/ip_pipeline/cli.c      | 22 +++++++++++
 examples/ip_pipeline/pipeline.h |  7 ++++
 examples/ip_pipeline/thread.c   | 84 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 113 insertions(+)
examples/ip_pipeline/cli.c +22 -0
index 88df168..ee2c78d 100644
@@ -3450,6 +3450,18 @@ cmd_pipeline_table_rule_delete_default(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> table <table_id> rule read stats [clear]
+ */
+static void
+cmd_pipeline_table_rule_stats_read(char **tokens,
+	uint32_t n_tokens __rte_unused,
+	char *out,
+	size_t out_size)
+{
+	snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -3733,6 +3745,16 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 7) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "rule") == 0) &&
+			(strcmp(tokens[5], "read") == 0) &&
+			(strcmp(tokens[6], "stats") == 0)) {
+			cmd_pipeline_table_rule_stats_read(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +7 -0
index 2bf6360..296e4da 100644
@@ -310,4 +310,11 @@ int
 pipeline_table_rule_delete_default(const char *pipeline_name,
 	uint32_t table_id);
 
+int
+pipeline_table_rule_stats_read(const char *pipeline_name,
+	uint32_t table_id,
+	void *data,
+	struct rte_table_action_stats_counters *stats,
+	int clear);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +84 -0

132 lines not on this page · raw message

Signature · 1 line
2.9.3
#92 lore raw

PATCH v3 35/44 ip_pipeline: add cli to configure meter profile

In reply to Jasvinder Singh

Add commands to configure the traffic meter profile.

---
 examples/ip_pipeline/cli.c      | 232 ++++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h |  11 ++
 examples/ip_pipeline/thread.c   | 145 ++++++++++++++++++++++++-
 3 files changed, 387 insertions(+), 1 deletion(-)
examples/ip_pipeline/cli.c +232 -0
index ee2c78d..fabf2db 100644
@@ -3462,6 +3462,218 @@ cmd_pipeline_table_rule_stats_read(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> table <table_id> meter profile <meter_profile_id>
+ *  add srtcm cir <cir> cbs <cbs> ebs <ebs>
+ *  | trtcm cir <cir> pir <pir> cbs <cbs> pbs <pbs>
+ */
+static void
+cmd_pipeline_table_meter_profile_add(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct rte_table_action_meter_profile p;
+	char *pipeline_name;
+	uint32_t table_id, meter_profile_id;
+	int status;
+
+	if (n_tokens < 9) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "meter") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter");
+		return;
+	}
+
+	if (strcmp(tokens[5], "profile") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
+		return;
+	}
+
+	if (parser_read_uint32(&meter_profile_id, tokens[6]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "meter_profile_id");
+		return;
+	}
+
+	if (strcmp(tokens[7], "add") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
+		return;
+	}
+
+	if (strcmp(tokens[8], "srtcm") == 0) {
+		if (n_tokens != 15) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH,
+				tokens[0]);
+			return;
+		}
+
+		p.alg = RTE_TABLE_ACTION_METER_SRTCM;
+
+		if (strcmp(tokens[9], "cir") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cir");
+			return;
+		}
+
+		if (parser_read_uint64(&p.srtcm.cir, tokens[10]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "cir");
+			return;
+		}
+
+		if (strcmp(tokens[11], "cbs") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cbs");
+			return;
+		}
+
+		if (parser_read_uint64(&p.srtcm.cbs, tokens[12]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "cbs");
+			return;
+		}
+
+		if (strcmp(tokens[13], "ebs") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "ebs");
+			return;
+		}
+
+		if (parser_read_uint64(&p.srtcm.ebs, tokens[14]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "ebs");
+			return;
+		}
+	} else if (strcmp(tokens[8], "trtcm") == 0) {
+		if (n_tokens != 17) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return;
+		}
+
+		p.alg = RTE_TABLE_ACTION_METER_TRTCM;
+
+		if (strcmp(tokens[9], "cir") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cir");
+			return;
+		}
+
+		if (parser_read_uint64(&p.trtcm.cir, tokens[10]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "cir");
+			return;
+		}
+
+		if (strcmp(tokens[11], "pir") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pir");
+			return;
+		}
+
+		if (parser_read_uint64(&p.trtcm.pir, tokens[12]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "pir");
+			return;
+		}
+		if (strcmp(tokens[13], "cbs") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cbs");
+			return;
+		}
+
+		if (parser_read_uint64(&p.trtcm.cbs, tokens[14]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "cbs");
+			return;
+		}
+
+		if (strcmp(tokens[15], "pbs") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pbs");
+			return;
+		}
+
+		if (parser_read_uint64(&p.trtcm.pbs, tokens[16]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "pbs");
+			return;
+		}
+	} else {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	status = pipeline_table_mtr_profile_add(pipeline_name,
+		table_id,
+		meter_profile_id,
+		&p);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
+ * pipeline <pipeline_name> table <table_id>
+ *  meter profile <meter_profile_id> delete
+ */
+static void
+cmd_pipeline_table_meter_profile_delete(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	char *pipeline_name;
+	uint32_t table_id, meter_profile_id;
+	int status;
+
+	if (n_tokens != 8) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "meter") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter");
+		return;
+	}
+
+	if (strcmp(tokens[5], "profile") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
+		return;
+	}
+
+	if (parser_read_uint32(&meter_profile_id, tokens[6]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "meter_profile_id");
+		return;
+	}
+
+	if (strcmp(tokens[7], "delete") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
+		return;
+	}
+
+	status = pipeline_table_mtr_profile_delete(pipeline_name,
+		table_id,
+		meter_profile_id);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -3755,6 +3967,26 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 8) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "meter") == 0) &&
+			(strcmp(tokens[5], "profile") == 0) &&
+			(strcmp(tokens[7], "add") == 0)) {
+			cmd_pipeline_table_meter_profile_add(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
+
+		if ((n_tokens >= 8) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "meter") == 0) &&
+			(strcmp(tokens[5], "profile") == 0) &&
+			(strcmp(tokens[7], "delete") == 0)) {
+			cmd_pipeline_table_meter_profile_delete(tokens,
+				n_tokens, out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +11 -0
index 296e4da..d524145 100644
@@ -317,4 +317,15 @@ pipeline_table_rule_stats_read(const char *pipeline_name,
 	struct rte_table_action_stats_counters *stats,
 	int clear);
 
+int
+pipeline_table_mtr_profile_add(const char *pipeline_name,
+	uint32_t table_id,
+	uint32_t meter_profile_id,
+	struct rte_table_action_meter_profile *profile);
+
+int
+pipeline_table_mtr_profile_delete(const char *pipeline_name,
+	uint32_t table_id,
+	uint32_t meter_profile_id);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +144 -1

181 lines not on this page · raw message

Signature · 1 line
2.9.3
#93 lore raw

PATCH v3 36/44 ip_pipeline: add cli to read meter stats

In reply to Jasvinder Singh

Add command to read traffic meter stats.

---
 examples/ip_pipeline/cli.c      | 22 +++++++++++
 examples/ip_pipeline/pipeline.h |  8 ++++
 examples/ip_pipeline/thread.c   | 88 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 118 insertions(+)
examples/ip_pipeline/cli.c +22 -0
index fabf2db..e01806a 100644
@@ -3674,6 +3674,18 @@ cmd_pipeline_table_meter_profile_delete(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> table <table_id> rule read meter [clear]
+ */
+static void
+cmd_pipeline_table_rule_meter_read(char **tokens,
+	uint32_t n_tokens __rte_unused,
+	char *out,
+	size_t out_size)
+{
+	snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -3987,6 +3999,16 @@ cli_process(char *in, char *out, size_t out_size)
 				n_tokens, out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 7) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "rule") == 0) &&
+			(strcmp(tokens[5], "read") == 0) &&
+			(strcmp(tokens[6], "meter") == 0)) {
+			cmd_pipeline_table_rule_meter_read(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +8 -0
index d524145..4978555 100644
@@ -328,4 +328,12 @@ pipeline_table_mtr_profile_delete(const char *pipeline_name,
 	uint32_t table_id,
 	uint32_t meter_profile_id);
 
+int
+pipeline_table_rule_mtr_read(const char *pipeline_name,
+	uint32_t table_id,
+	void *data,
+	uint32_t tc_mask,
+	struct rte_table_action_mtr_counters *stats,
+	int clear);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +88 -0

136 lines not on this page · raw message

Signature · 1 line
2.9.3
#94 lore raw

PATCH v3 37/44 ip_pipeline: add cli to update dscp table

In reply to Jasvinder Singh

Add command to update the dscp table for traffic meter and traffic manager.

---
 examples/ip_pipeline/cli.c      | 154 ++++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h |   6 ++
 examples/ip_pipeline/thread.c   |  77 ++++++++++++++++++++
 3 files changed, 237 insertions(+)
examples/ip_pipeline/cli.c +154 -0
index e01806a..1f51eaf 100644
@@ -3686,6 +3686,152 @@ cmd_pipeline_table_rule_meter_read(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> table <table_id> dscp <file_name>
+ *
+ * File <file_name>:
+ *  - exactly 64 lines
+ *  - line format: <tc_id> <tc_queue_id> <color>, with <color> as: g | y | r
+ */
+static int
+load_dscp_table(struct rte_table_action_dscp_table *dscp_table,
+	const char *file_name,
+	uint32_t *line_number)
+{
+	FILE *f = NULL;
+	uint32_t dscp, l;
+
+	/* Check input arguments */
+	if ((dscp_table == NULL) ||
+		(file_name == NULL) ||
+		(line_number == NULL)) {
+		if (line_number)
+			*line_number = 0;
+		return -EINVAL;
+	}
+
+	/* Open input file */
+	f = fopen(file_name, "r");
+	if (f == NULL) {
+		*line_number = 0;
+		return -EINVAL;
+	}
+
+	/* Read file */
+	for (dscp = 0, l = 1; ; l++) {
+		char line[64];
+		char *tokens[3];
+		enum rte_meter_color color;
+		uint32_t tc_id, tc_queue_id, n_tokens = RTE_DIM(tokens);
+
+		if (fgets(line, sizeof(line), f) == NULL)
+			break;
+
+		if (is_comment(line))
+			continue;
+
+		if (parse_tokenize_string(line, tokens, &n_tokens)) {
+			*line_number = l;
+			return -EINVAL;
+		}
+
+		if (n_tokens == 0)
+			continue;
+
+		if ((dscp >= RTE_DIM(dscp_table->entry)) ||
+			(n_tokens != RTE_DIM(tokens)) ||
+			parser_read_uint32(&tc_id, tokens[0]) ||
+			(tc_id >= RTE_TABLE_ACTION_TC_MAX) ||
+			parser_read_uint32(&tc_queue_id, tokens[1]) ||
+			(tc_queue_id >= RTE_TABLE_ACTION_TC_QUEUE_MAX) ||
+			(strlen(tokens[2]) != 1)) {
+			*line_number = l;
+			return -EINVAL;
+		}
+
+		switch (tokens[2][0]) {
+		case 'g':
+		case 'G':
+			color = e_RTE_METER_GREEN;
+			break;
+
+		case 'y':
+		case 'Y':
+			color = e_RTE_METER_YELLOW;
+			break;
+
+		case 'r':
+		case 'R':
+			color = e_RTE_METER_RED;
+			break;
+
+		default:
+			*line_number = l;
+			return -EINVAL;
+		}
+
+		dscp_table->entry[dscp].tc_id = tc_id;
+		dscp_table->entry[dscp].tc_queue_id = tc_queue_id;
+		dscp_table->entry[dscp].color = color;
+		dscp++;
+	}
+
+	/* Close file */
+	fclose(f);
+	return 0;
+}
+
+static void
+cmd_pipeline_table_dscp(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct rte_table_action_dscp_table dscp_table;
+	char *pipeline_name, *file_name;
+	uint32_t table_id, line_number;
+	int status;
+
+	if (n_tokens != 6) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "dscp") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "dscp");
+		return;
+	}
+
+	file_name = tokens[5];
+
+	status = load_dscp_table(&dscp_table, file_name, &line_number);
+	if (status) {
+		snprintf(out, out_size, MSG_FILE_ERR, file_name, line_number);
+		return;
+	}
+
+	status = pipeline_table_dscp_table_update(pipeline_name,
+		table_id,
+		UINT64_MAX,
+		&dscp_table);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -4009,6 +4155,14 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 5) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "dscp") == 0)) {
+			cmd_pipeline_table_dscp(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +6 -0
index 4978555..598bed0 100644
@@ -336,4 +336,10 @@ pipeline_table_rule_mtr_read(const char *pipeline_name,
 	struct rte_table_action_mtr_counters *stats,
 	int clear);
 
+int
+pipeline_table_dscp_table_update(const char *pipeline_name,
+	uint32_t table_id,
+	uint64_t dscp_mask,
+	struct rte_table_action_dscp_table *dscp_table);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +77 -0

113 lines not on this page · raw message

Signature · 1 line
2.9.3
#95 lore raw

PATCH v3 38/44 ip_pipeline: add cli to read ttl stats

In reply to Jasvinder Singh

Add command to read the ttl stats.

---
 examples/ip_pipeline/cli.c      | 22 +++++++++++
 examples/ip_pipeline/pipeline.h |  7 ++++
 examples/ip_pipeline/thread.c   | 84 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 113 insertions(+)
examples/ip_pipeline/cli.c +22 -0
index 1f51eaf..6757d32 100644
@@ -3832,6 +3832,18 @@ cmd_pipeline_table_dscp(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> table <table_id> rule read ttl [clear]
+ */
+static void
+cmd_pipeline_table_rule_ttl_read(char **tokens,
+	uint32_t n_tokens __rte_unused,
+	char *out,
+	size_t out_size)
+{
+	snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -4163,6 +4175,16 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 7) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "rule") == 0) &&
+			(strcmp(tokens[5], "read") == 0) &&
+			(strcmp(tokens[6], "ttl") == 0)) {
+			cmd_pipeline_table_rule_ttl_read(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +7 -0
index 598bed0..208e407 100644
@@ -342,4 +342,11 @@ pipeline_table_dscp_table_update(const char *pipeline_name,
 	uint64_t dscp_mask,
 	struct rte_table_action_dscp_table *dscp_table);
 
+int
+pipeline_table_rule_ttl_read(const char *pipeline_name,
+	uint32_t table_id,
+	void *data,
+	struct rte_table_action_ttl_counters *stats,
+	int clear);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +84 -0

132 lines not on this page · raw message

Signature · 1 line
2.9.3
#96 lore raw

PATCH v3 39/44 ip_pipeline: add l2fwd example

In reply to Jasvinder Singh

This patch add the configuration file for l2fwd example. It includes commands to build the packet processing stage (pipeline), defining action, add rules to its table, etc.

---
 examples/ip_pipeline/examples/l2fwd.cli | 53 +++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 examples/ip_pipeline/examples/l2fwd.cli
examples/ip_pipeline/examples/l2fwd.cli new file +53 -0
new file mode 100644
index 0000000..5b9d529
@@ -0,0 +1,53 @@
+; SPDX-License-Identifier: BSD-3-Clause
+; Copyright(c) 2010-2018 Intel Corporation
+
+; The pipeline below implements a simple pass-through connection between the
+; input ports to the output ports, as in this diagram:
+;                 ________________
+; LINK0 RXQ0 --->|................|---> LINK1 TXQ0
+;                |                |
+; LINK1 RXQ0 --->|................|---> LINK0 TXQ0
+;                |    PIPELINE0   |
+; LINK2 RXQ0 --->|................|---> LINK3 TXQ0
+;                |                |
+; LINK3 RXQ0 --->|................|---> LINK2 TXQ0
+;                |________________|
+;
+
+mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+
+link LINK0 dev 0000:02:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK1 dev 0000:02:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK2 dev 0000:06:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK3 dev 0000:06:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+
+table action profile AP0 ipv4 offset 270 fwd
+
+pipeline PIPELINE0 period 10 offset_port_id 0 cpu 0
+
+pipeline PIPELINE0 port in bsz 32 link LINK0 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK1 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK2 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK3 rxq 0
+
+pipeline PIPELINE0 port out bsz 32 link LINK0 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK1 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK2 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK3 txq 0
+
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+
+pipeline PIPELINE0 port in 0 table 0
+pipeline PIPELINE0 port in 1 table 1
+pipeline PIPELINE0 port in 2 table 2
+pipeline PIPELINE0 port in 3 table 3
+
+thread 1 pipeline PIPELINE0 enable
+
+pipeline PIPELINE0 table 0 rule add match default action fwd port 1
+pipeline PIPELINE0 table 1 rule add match default action fwd port 0
+pipeline PIPELINE0 table 2 rule add match default action fwd port 3
+pipeline PIPELINE0 table 3 rule add match default action fwd port 2
Signature · 1 line
2.9.3
#97 lore raw

PATCH v3 40/44 ip_pipeline: add KNI port example

In reply to Jasvinder Singh

Add example to illustrate the pipeline functioning with KNI interface.

---
 examples/ip_pipeline/examples/kni.cli | 69 +++++++++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 examples/ip_pipeline/examples/kni.cli
examples/ip_pipeline/examples/kni.cli new file +69 -0
new file mode 100644
index 0000000..1438340
@@ -0,0 +1,69 @@
+; SPDX-License-Identifier: BSD-3-Clause
+; Copyright(c) 2010-2018 Intel Corporation
+
+;                 _______________          ______________________
+;                |               |  KNI0  |                      |
+; LINK0 RXQ0 --->|...............|------->|--+                   |
+;                |               |  KNI1  |  | br0               |
+; LINK1 TXQ0 <---|...............|<-------|<-+                   |
+;                |               |        |     Linux Kernel     |
+;                |   PIPELINE0   |        |     Network Stack    |
+;                |               |  KNI1  |                      |
+; LINK1 RXQ0 --->|...............|------->|--+                   |
+;                |               |  KNI0  |  | br0               |
+; LINK0 TXQ0 <---|...............|<-------|<-+                   |
+;                |_______________|        |______________________|
+;
+; Insert Linux kernel KNI module:
+;    [Linux]$ insmod rte_kni.ko
+;
+; Configure Linux kernel bridge between KNI0 and KNI1 interfaces:
+;    [Linux]$ brctl addbr br0
+;    [Linux]$ brctl addif br0 KNI0
+;    [Linux]$ brctl addif br0 KNI1
+;    [Linux]$ ifconfig br0 up
+;    [Linux]$ ifconfig KNI0 up
+;    [Linux]$ ifconfig KNI1 up
+;
+; Monitor packet forwarding performed by Linux kernel between KNI0 and KNI1:
+;    [Linux]$ tcpdump -i KNI0
+;    [Linux]$ tcpdump -i KNI1
+
+mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+
+link LINK0 dev 0000:02:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK1 dev 0000:02:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+
+kni KNI0 link LINK0 mempool MEMPOOL0
+kni KNI1 link LINK1 mempool MEMPOOL0
+
+table action profile AP0 ipv4 offset 270 fwd
+
+pipeline PIPELINE0 period 10 offset_port_id 0 cpu 0
+
+pipeline PIPELINE0 port in bsz 32 link LINK0 rxq 0
+pipeline PIPELINE0 port in bsz 32 kni KNI1
+pipeline PIPELINE0 port in bsz 32 link LINK1 rxq 0
+pipeline PIPELINE0 port in bsz 32 kni KNI0
+
+pipeline PIPELINE0 port out bsz 32 kni KNI0
+pipeline PIPELINE0 port out bsz 32 link LINK1 txq 0
+pipeline PIPELINE0 port out bsz 32 kni KNI1
+pipeline PIPELINE0 port out bsz 32 link LINK0 txq 0
+
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+
+pipeline PIPELINE0 port in 0 table 0
+pipeline PIPELINE0 port in 1 table 1
+pipeline PIPELINE0 port in 2 table 2
+pipeline PIPELINE0 port in 3 table 3
+
+thread 1 pipeline PIPELINE0 enable
+
+pipeline PIPELINE0 table 0 rule add match default action fwd port 0
+pipeline PIPELINE0 table 1 rule add match default action fwd port 1
+pipeline PIPELINE0 table 2 rule add match default action fwd port 2
+pipeline PIPELINE0 table 3 rule add match default action fwd port 3
Signature · 1 line
2.9.3
#98 lore raw

PATCH v3 41/44 ip_pipeline: add TAP port example

In reply to Jasvinder Singh

Add example to illustrate the pipeline functioning with TAP interface.

---
 examples/ip_pipeline/examples/tap.cli | 66 +++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 examples/ip_pipeline/examples/tap.cli
examples/ip_pipeline/examples/tap.cli new file +66 -0
new file mode 100644
index 0000000..600cea2
@@ -0,0 +1,66 @@
+; SPDX-License-Identifier: BSD-3-Clause
+; Copyright(c) 2010-2018 Intel Corporation
+
+;                 _______________          ______________________
+;                |               |  TAP0  |                      |
+; LINK0 RXQ0 --->|...............|------->|--+                   |
+;                |               |  TAP1  |  | br0               |
+; LINK1 TXQ0 <---|...............|<-------|<-+                   |
+;                |               |        |     Linux Kernel     |
+;                |   PIPELINE0   |        |     Network Stack    |
+;                |               |  TAP1  |                      |
+; LINK1 RXQ0 --->|...............|------->|--+                   |
+;                |               |  TAP0  |  | br0               |
+; LINK0 TXQ0 <---|...............|<-------|<-+                   |
+;                |_______________|        |______________________|
+;
+; Configure Linux kernel bridge between TAP0 and TAP1 interfaces:
+;    [Linux]$ brctl addbr br0
+;    [Linux]$ brctl addif br0 TAP0
+;    [Linux]$ brctl addif br0 TAP1
+;    [Linux]$ ifconfig TAP0 up
+;    [Linux]$ ifconfig TAP1 up
+;    [Linux]$ ifconfig br0 up
+;
+; Monitor packet forwarding performed by Linux kernel between TAP0 and TAP1:
+;    [Linux]$ tcpdump -i TAP0
+;    [Linux]$ tcpdump -i TAP1
+
+mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+
+link LINK0 dev 0000:02:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK1 dev 0000:02:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+
+tap TAP0
+tap TAP1
+
+table action profile AP0 ipv4 offset 270 fwd
+
+pipeline PIPELINE0 period 10 offset_port_id 0 cpu 0
+
+pipeline PIPELINE0 port in bsz 32 link LINK0 rxq 0
+pipeline PIPELINE0 port in bsz 32 tap TAP1 mempool MEMPOOL0 mtu 1500
+pipeline PIPELINE0 port in bsz 32 link LINK1 rxq 0
+pipeline PIPELINE0 port in bsz 32 tap TAP0 mempool MEMPOOL0 mtu 1500
+
+pipeline PIPELINE0 port out bsz 32 tap TAP0
+pipeline PIPELINE0 port out bsz 32 link LINK1 txq 0
+pipeline PIPELINE0 port out bsz 32 tap TAP1
+pipeline PIPELINE0 port out bsz 32 link LINK0 txq 0
+
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+
+pipeline PIPELINE0 port in 0 table 0
+pipeline PIPELINE0 port in 1 table 1
+pipeline PIPELINE0 port in 2 table 2
+pipeline PIPELINE0 port in 3 table 3
+
+thread 1 pipeline PIPELINE0 enable
+
+pipeline PIPELINE0 table 0 rule add match default action fwd port 0
+pipeline PIPELINE0 table 1 rule add match default action fwd port 1
+pipeline PIPELINE0 table 2 rule add match default action fwd port 2
+pipeline PIPELINE0 table 3 rule add match default action fwd port 3
Signature · 1 line
2.9.3
#99 lore raw

PATCH v3 42/44 ip_pipeline: add route example

In reply to Jasvinder Singh

Add example to built pipeline with LPM table to demonstrate layer 3 routing.

---
 examples/ip_pipeline/examples/route.cli | 60 +++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 examples/ip_pipeline/examples/route.cli
examples/ip_pipeline/examples/route.cli new file +60 -0
new file mode 100644
index 0000000..50f0a10
@@ -0,0 +1,60 @@
+; SPDX-License-Identifier: BSD-3-Clause
+; Copyright(c) 2010-2018 Intel Corporation
+
+;                 _______________
+; LINK0 RXQ0 --->|               |---> LINK0 TXQ0
+;                |               |
+; LINK1 RXQ0 --->|               |---> LINK1 TXQ0
+;                |    Routing    |
+; LINK2 RXQ0 --->|               |---> LINK2 TXQ0
+;                |               |
+; LINK3 RXQ0 --->|               |---> LINK3 TXQ0
+;                |_______________|
+;                        |
+;                        +-----------> SINK0 (route miss)
+;
+; Input packet: Ethernet/IPv4
+;
+; Packet buffer layout:
+; #   Field Name       Offset (Bytes)   Size (Bytes)
+; 0   Mbuf             0                128
+; 1   Headroom         128              128
+; 2   Ethernet header  256              14
+; 3   IPv4 header      270              20
+
+mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+
+link LINK0 dev 0000:02:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK1 dev 0000:02:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK2 dev 0000:06:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK3 dev 0000:06:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+
+table action profile AP0 ipv4 offset 270 fwd encap ether
+
+pipeline PIPELINE0 period 10 offset_port_id 0 cpu 0
+
+pipeline PIPELINE0 port in bsz 32 link LINK0 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK1 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK2 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK3 rxq 0
+
+pipeline PIPELINE0 port out bsz 32 link LINK0 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK1 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK2 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK3 txq 0
+pipeline PIPELINE0 port out bsz 32 sink SINK0
+
+pipeline PIPELINE0 table match lpm ipv4 offset 286 size 4K action AP0
+
+pipeline PIPELINE0 port in 0 table 0
+pipeline PIPELINE0 port in 1 table 0
+pipeline PIPELINE0 port in 2 table 0
+pipeline PIPELINE0 port in 3 table 0
+
+thread 1 pipeline PIPELINE0 enable
+
+pipeline PIPELINE0 table 0 rule add match default action fwd port 4
+pipeline PIPELINE0 table 0 rule add match lpm ipv4 100.0.0.0 10 action fwd port 0 encap ether a0:a1:a2:a3:a4:a5 00:01:02:03:04:05
+pipeline PIPELINE0 table 0 rule add match lpm ipv4 100.64.0.0 10 action fwd port 1 encap ether b0:b1:b2:b3:b4:b5 10:11:12:13:14:15
+pipeline PIPELINE0 table 0 rule add match lpm ipv4 100.128.0.0 10 action fwd port 2 encap ether c0:c1:c2:c3:c4:c5 20:21:22:23:24:25
+pipeline PIPELINE0 table 0 rule add match lpm ipv4 100.192.0.0 10 action fwd port 3 encap ether d0:d1:d2:d3:d4:d5 30:31:32:33:34:35
Signature · 1 line
2.9.3
#100 lore raw

PATCH v3 43/44 ip_pipeline: add firewall example

In reply to Jasvinder Singh

Add example to built pipeline with ACL table to demonstrate the firewall operation.

---
 examples/ip_pipeline/examples/firewall.cli | 59 ++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 examples/ip_pipeline/examples/firewall.cli
examples/ip_pipeline/examples/firewall.cli new file +59 -0
new file mode 100644
index 0000000..269256c
@@ -0,0 +1,59 @@
+; SPDX-License-Identifier: BSD-3-Clause
+; Copyright(c) 2010-2018 Intel Corporation
+
+;                 _______________
+; LINK0 RXQ0 --->|               |---> LINK0 TXQ0
+;                |               |
+; LINK1 RXQ0 --->|               |---> LINK1 TXQ0
+;                |   Firewall    |
+; LINK2 RXQ0 --->|               |---> LINK2 TXQ0
+;                |               |
+; LINK3 RXQ0 --->|               |---> LINK3 TXQ0
+;                |_______________|
+;                        |
+;                       -+-
+;
+; Input packet: Ethernet/IPv4
+;
+; Packet buffer layout:
+; #   Field Name            Offset (Bytes)      Size (Bytes)
+; 0   Mbuf                  0                   128
+; 1   Headroom              128                 128
+; 2   Ethernet header       256                 14
+; 3   IPv4 header           270                 20
+
+mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+
+link LINK0 dev 0000:02:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK1 dev 0000:02:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK2 dev 0000:06:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK3 dev 0000:06:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+
+table action profile AP0 ipv4 offset 270 fwd
+
+pipeline PIPELINE0 period 10 offset_port_id 0 cpu 0
+
+pipeline PIPELINE0 port in bsz 32 link LINK0 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK1 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK2 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK3 rxq 0
+
+pipeline PIPELINE0 port out bsz 32 link LINK0 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK1 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK2 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK3 txq 0
+
+pipeline PIPELINE0 table match acl ipv4 offset 270 size 4K action AP0
+
+pipeline PIPELINE0 port in 0 table 0
+pipeline PIPELINE0 port in 1 table 0
+pipeline PIPELINE0 port in 2 table 0
+pipeline PIPELINE0 port in 3 table 0
+
+thread 1 pipeline PIPELINE0 enable
+
+pipeline PIPELINE0 table 0 rule add match default action fwd drop
+pipeline PIPELINE0 table 0 rule add match acl priority 0 ipv4 0.0.0.0 0 100.0.0.0 10 0 65535 0 65535 6 action fwd port 0
+pipeline PIPELINE0 table 0 rule add match acl priority 0 ipv4 0.0.0.0 0 100.64.0.0 10 0 65535 0 65535 6 action fwd port 1
+pipeline PIPELINE0 table 0 rule add match acl priority 0 ipv4 0.0.0.0 0 100.128.0.0 10 0 65535 0 65535 6 action fwd port 2
+pipeline PIPELINE0 table 0 rule add match acl priority 0 ipv4 0.0.0.0 0 100.192.0.0 10 0 65535 0 65535 6 action fwd port 3
Signature · 1 line
2.9.3
#101 lore raw

PATCH v3 44/44 ip_pipeline: add flow classification example

In reply to Jasvinder Singh

Add example to build pipeline with hash table to classify the ingress traffic.

---
 examples/ip_pipeline/examples/flow.cli | 60 ++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 examples/ip_pipeline/examples/flow.cli
examples/ip_pipeline/examples/flow.cli new file +60 -0
new file mode 100644
index 0000000..60b8445
@@ -0,0 +1,60 @@
+; SPDX-License-Identifier: BSD-3-Clause
+; Copyright(c) 2010-2018 Intel Corporation
+
+;                 ________________
+; LINK0 RXQ0 --->|                |---> LINK0 TXQ0
+;                |                |
+; LINK1 RXQ0 --->|                |---> LINK1 TXQ0
+;                |      Flow      |
+; LINK2 RXQ0 --->| Classification |---> LINK2 TXQ0
+;                |                |
+; LINK3 RXQ0 --->|                |---> LINK3 TXQ0
+;                |________________|
+;                        |
+;                        +-----------> SINK0 (flow lookup miss)
+;
+; Input packet: Ethernet/IPv4
+;
+; Packet buffer layout:
+; #   Field Name       Offset (Bytes)   Size (Bytes)
+; 0   Mbuf             0                128
+; 1   Headroom         128              128
+; 2   Ethernet header  256              14
+; 3   IPv4 header      270              20
+
+mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+
+link LINK0 dev 0000:02:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK1 dev 0000:02:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK2 dev 0000:06:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK3 dev 0000:06:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+
+table action profile AP0 ipv4 offset 270 fwd
+
+pipeline PIPELINE0 period 10 offset_port_id 0 cpu 0
+
+pipeline PIPELINE0 port in bsz 32 link LINK0 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK1 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK2 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK3 rxq 0
+
+pipeline PIPELINE0 port out bsz 32 link LINK0 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK1 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK2 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK3 txq 0
+pipeline PIPELINE0 port out bsz 32 sink SINK0
+
+pipeline PIPELINE0 table match hash ext key 16 mask 00FF0000FFFFFFFFFFFFFFFFFFFFFFFF offset 278 buckets 16K size 65K action AP0
+
+pipeline PIPELINE0 port in 0 table 0
+pipeline PIPELINE0 port in 1 table 0
+pipeline PIPELINE0 port in 2 table 0
+pipeline PIPELINE0 port in 3 table 0
+
+thread 1 pipeline PIPELINE0 enable
+
+pipeline PIPELINE0 table 0 rule add match default action fwd port 4
+pipeline PIPELINE0 table 0 rule add match hash ipv4_5tuple 100.0.0.10 200.0.0.10 100 200 6 action fwd port 0
+pipeline PIPELINE0 table 0 rule add match hash ipv4_5tuple 100.0.0.11 200.0.0.11 101 201 6 action fwd port 1
+pipeline PIPELINE0 table 0 rule add match hash ipv4_5tuple 100.0.0.12 200.0.0.12 102 202 6 action fwd port 2
+pipeline PIPELINE0 table 0 rule add match hash ipv4_5tuple 100.0.0.13 200.0.0.13 103 203 6 action fwd port 3
Signature · 1 line
2.9.3
#102 lore raw

PATCH v2 2/44 pipeline: get pipeline table action params

In reply to Jasvinder Singh

Add API to specify action related parameters such as action handler, table entry data size, etc. for the pipeline table.

---
 lib/librte_pipeline/rte_pipeline_version.map |   1 +
 lib/librte_pipeline/rte_table_action.c       | 132 ++++++++++++++++++++++++++-
 lib/librte_pipeline/rte_table_action.h       |  14 +++
 3 files changed, 146 insertions(+), 1 deletion(-)
lib/librte_pipeline/rte_pipeline_version.map +1 -0
index 4bc414c..13337de 100644
@@ -56,5 +56,6 @@ EXPERIMENTAL {
 	rte_table_action_profile_create;
 	rte_table_action_profile_free;
 	rte_table_action_profile_freeze;
+	rte_table_action_table_params_get;
 
 } DPDK_16.04;
lib/librte_pipeline/rte_table_action.c +131 -1

142 lines not on this page · raw message

lib/librte_pipeline/rte_table_action.h +14 -0
index da7f12c..03b77ca 100644
@@ -194,6 +194,20 @@ int __rte_experimental
 rte_table_action_free(struct rte_table_action *action);
 
 /**
+ * Table action table params get.
+ *
+ * @param[in] action
+ *   Handle to table action object (needs to be valid).
+ * @param[inout] params
+ *   Pipeline table parameters (needs to be pre-allocated).
+ * @return
+ *   Zero on success, non-zero error code otherwise.
+ */
+int __rte_experimental
+rte_table_action_table_params_get(struct rte_table_action *action,
+	struct rte_pipeline_table_params *params);
+
+/**
  * Table action apply.
  *
  * @param[in] action
Signature · 1 line
2.9.3
#103 lore raw

PATCH v2 3/44 pipeline: add traffic metering action

In reply to Jasvinder Singh

Add traffic metering action implementation.

---
 lib/librte_pipeline/Makefile                 |   3 +-
 lib/librte_pipeline/meson.build              |   2 +-
 lib/librte_pipeline/rte_pipeline_version.map |   4 +
 lib/librte_pipeline/rte_table_action.c       | 640 ++++++++++++++++++++++++++-
 lib/librte_pipeline/rte_table_action.h       | 248 +++++++++++
 5 files changed, 879 insertions(+), 18 deletions(-)
lib/librte_pipeline/Makefile +2 -1
index e8c43c7..72e4c7c 100644
@@ -8,10 +8,11 @@ include $(RTE_SDK)/mk/rte.vars.mk
 #
 LIB = librte_pipeline.a
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 LDLIBS += -lrte_eal -lrte_mempool -lrte_mbuf -lrte_table
-LDLIBS += -lrte_port
+LDLIBS += -lrte_port -lrte_meter
 
 EXPORT_MAP := rte_pipeline_version.map
 
lib/librte_pipeline/meson.build +1 -1
index 4dda560..71da295 100644
@@ -5,4 +5,4 @@ version = 3
 allow_experimental_apis = true
 sources = files('rte_pipeline.c', 'rte_table_action.c')
 headers = files('rte_pipeline.h', 'rte_table_action.h')
-deps += ['port', 'table']
+deps += ['port', 'table', 'meter']
lib/librte_pipeline/rte_pipeline_version.map +4 -0
index 13337de..c7106dc 100644
@@ -51,7 +51,11 @@ EXPERIMENTAL {
 
 	rte_table_action_apply;
 	rte_table_action_create;
+	rte_table_action_dscp_table_update;
 	rte_table_action_free;
+	rte_table_action_meter_profile_add;
+	rte_table_action_meter_profile_delete;
+	rte_table_action_meter_read;
 	rte_table_action_profile_action_register;
 	rte_table_action_profile_create;
 	rte_table_action_profile_free;
lib/librte_pipeline/rte_table_action.c +624 -16

741 lines not on this page · raw message

lib/librte_pipeline/rte_table_action.h +248 -0

272 lines not on this page · raw message

Signature · 1 line
2.9.3
#104 lore raw

PATCH v2 4/44 pipeline: add traffic manager action

In reply to Jasvinder Singh

Add implementation of traffic manager action.

---
 lib/librte_pipeline/Makefile           |   2 +-
 lib/librte_pipeline/meson.build        |   2 +-
 lib/librte_pipeline/rte_table_action.c | 130 ++++++++++++++++++++++++++++++++-
 lib/librte_pipeline/rte_table_action.h |  24 ++++++
 4 files changed, 155 insertions(+), 3 deletions(-)
lib/librte_pipeline/Makefile +1 -1
index 72e4c7c..c0eaa09 100644
@@ -12,7 +12,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 LDLIBS += -lrte_eal -lrte_mempool -lrte_mbuf -lrte_table
-LDLIBS += -lrte_port -lrte_meter
+LDLIBS += -lrte_port -lrte_meter -lrte_sched
 
 EXPORT_MAP := rte_pipeline_version.map
 
lib/librte_pipeline/meson.build +1 -1
index 71da295..1ee276f 100644
@@ -5,4 +5,4 @@ version = 3
 allow_experimental_apis = true
 sources = files('rte_pipeline.c', 'rte_table_action.c')
 headers = files('rte_pipeline.h', 'rte_table_action.h')
-deps += ['port', 'table', 'meter']
+deps += ['port', 'table', 'meter', 'sched']
lib/librte_pipeline/rte_table_action.c +129 -1

196 lines not on this page · raw message

lib/librte_pipeline/rte_table_action.h +24 -0
index c2f4a55..98babc5 100644
@@ -70,6 +70,9 @@ enum rte_table_action_type {
 
 	/**  Traffic Metering and Policing. */
 	RTE_TABLE_ACTION_MTR,
+
+	/**  Traffic Management. */
+	RTE_TABLE_ACTION_TM,
 };
 
 /** Common action configuration (per table action profile). */
@@ -256,6 +259,27 @@ struct rte_table_action_mtr_counters {
 };
 
 /**
+ * RTE_TABLE_ACTION_TM
+ */
+/** Traffic management action configuration (per table action profile). */
+struct rte_table_action_tm_config {
+	/** Number of subports per port. */
+	uint32_t n_subports_per_port;
+
+	/** Number of pipes per subport. */
+	uint32_t n_pipes_per_subport;
+};
+
+/** Traffic management action parameters (per table rule). */
+struct rte_table_action_tm_params {
+	/** Subport ID. */
+	uint32_t subport_id;
+
+	/** Pipe ID. */
+	uint32_t pipe_id;
+};
+
+/**
  * Table action profile.
  */
 struct rte_table_action_profile;
Signature · 1 line
2.9.3
#105 lore raw

PATCH v2 5/44 pipeline: add packet encapsulation action

In reply to Jasvinder Singh

Add implementation of different type of packet encap such as vlan, qinq, mpls, pppoe, etc.

---
 lib/librte_pipeline/rte_table_action.c | 440 ++++++++++++++++++++++++++++++++-
 lib/librte_pipeline/rte_table_action.h | 129 ++++++++++
 2 files changed, 568 insertions(+), 1 deletion(-)
lib/librte_pipeline/rte_table_action.c +439 -1
index cbf9a29..cd8e7d1 100644
@@ -9,8 +9,12 @@
 #include <rte_byteorder.h>
 #include <rte_cycles.h>
 #include <rte_malloc.h>
+#include <rte_memcpy.h>
+#include <rte_ether.h>
 #include <rte_ip.h>
-
+#include <rte_esp.h>
+#include <rte_tcp.h>
+#include <rte_udp.h>
 
 #include "rte_table_action.h"
 
@@ -366,6 +370,369 @@ pkt_work_tm(struct rte_mbuf *mbuf,
 }
 
 /**
+ * RTE_TABLE_ACTION_ENCAP
+ */
+static int
+encap_valid(enum rte_table_action_encap_type encap)
+{
+	switch (encap) {
+	case RTE_TABLE_ACTION_ENCAP_ETHER:
+	case RTE_TABLE_ACTION_ENCAP_VLAN:
+	case RTE_TABLE_ACTION_ENCAP_QINQ:
+	case RTE_TABLE_ACTION_ENCAP_MPLS:
+	case RTE_TABLE_ACTION_ENCAP_PPPOE:
+		return 1;
+	default:
+		return 0;
+	}
+}
+
+static int
+encap_cfg_check(struct rte_table_action_encap_config *encap)
+{
+	if ((encap->encap_mask == 0) ||
+		(__builtin_popcountll(encap->encap_mask) != 1))
+		return -ENOTSUP;
+
+	return 0;
+}
+
+struct encap_ether_data {
+	struct ether_hdr ether;
+} __attribute__((__packed__));
+
+#define VLAN(pcp, dei, vid)                                \
+	((uint16_t)((((uint64_t)(pcp)) & 0x7LLU) << 13) |  \
+	((((uint64_t)(dei)) & 0x1LLU) << 12) |             \
+	(((uint64_t)(vid)) & 0xFFFLLU))                    \
+
+struct encap_vlan_data {
+	struct ether_hdr ether;
+	struct vlan_hdr vlan;
+} __attribute__((__packed__));
+
+struct encap_qinq_data {
+	struct ether_hdr ether;
+	struct vlan_hdr svlan;
+	struct vlan_hdr cvlan;
+} __attribute__((__packed__));
+
+#define ETHER_TYPE_MPLS_UNICAST                            0x8847
+
+#define ETHER_TYPE_MPLS_MULTICAST                          0x8848
+
+#define MPLS(label, tc, s, ttl)                            \
+	((uint32_t)(((((uint64_t)(label)) & 0xFFFFFLLU) << 12) |\
+	((((uint64_t)(tc)) & 0x7LLU) << 9) |               \
+	((((uint64_t)(s)) & 0x1LLU) << 8) |                \
+	(((uint64_t)(ttl)) & 0xFFLLU)))
+
+struct encap_mpls_data {
+	struct ether_hdr ether;
+	uint32_t mpls[RTE_TABLE_ACTION_MPLS_LABELS_MAX];
+	uint32_t mpls_count;
+} __attribute__((__packed__));
+
+#define ETHER_TYPE_PPPOE_SESSION                           0x8864
+
+#define PPP_PROTOCOL_IP                                    0x0021
+
+struct pppoe_ppp_hdr {
+	uint16_t ver_type_code;
+	uint16_t session_id;
+	uint16_t length;
+	uint16_t protocol;
+} __attribute__((__packed__));
+
+struct encap_pppoe_data {
+	struct ether_hdr ether;
+	struct pppoe_ppp_hdr pppoe_ppp;
+} __attribute__((__packed__));
+
+static size_t
+encap_data_size(struct rte_table_action_encap_config *encap)
+{
+	switch (encap->encap_mask) {
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_ETHER:
+		return sizeof(struct encap_ether_data);
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_VLAN:
+		return sizeof(struct encap_vlan_data);
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_QINQ:
+		return sizeof(struct encap_qinq_data);
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_MPLS:
+		return sizeof(struct encap_mpls_data);
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_PPPOE:
+		return sizeof(struct encap_pppoe_data);
+
+	default:
+		return 0;
+	}
+}
+
+static int
+encap_apply_check(struct rte_table_action_encap_params *p,
+	struct rte_table_action_encap_config *cfg)
+{
+	if ((encap_valid(p->type) == 0) ||
+		((cfg->encap_mask & (1LLU << p->type)) == 0))
+		return -EINVAL;
+
+	switch (p->type) {
+	case RTE_TABLE_ACTION_ENCAP_ETHER:
+		return 0;
+
+	case RTE_TABLE_ACTION_ENCAP_VLAN:
+		return 0;
+
+	case RTE_TABLE_ACTION_ENCAP_QINQ:
+		return 0;
+
+	case RTE_TABLE_ACTION_ENCAP_MPLS:
+		if ((p->mpls.mpls_count == 0) ||
+			(p->mpls.mpls_count > RTE_TABLE_ACTION_MPLS_LABELS_MAX))
+			return -EINVAL;
+
+		return 0;
+
+	case RTE_TABLE_ACTION_ENCAP_PPPOE:
+		return 0;
+
+	default:
+		return -EINVAL;
+	}
+}
+
+static int
+encap_ether_apply(void *data,
+	struct rte_table_action_encap_params *p,
+	struct rte_table_action_common_config *common_cfg)
+{
+	struct encap_ether_data *d = data;
+	uint16_t ethertype = (common_cfg->ip_version) ?
+		ETHER_TYPE_IPv4 :
+		ETHER_TYPE_IPv6;
+
+	/* Ethernet */
+	ether_addr_copy(&p->ether.ether.da, &d->ether.d_addr);
+	ether_addr_copy(&p->ether.ether.sa, &d->ether.s_addr);
+	d->ether.ether_type = rte_htons(ethertype);
+
+	return 0;
+}
+
+static int
+encap_vlan_apply(void *data,
+	struct rte_table_action_encap_params *p,
+	struct rte_table_action_common_config *common_cfg)
+{
+	struct encap_vlan_data *d = data;
+	uint16_t ethertype = (common_cfg->ip_version) ?
+		ETHER_TYPE_IPv4 :
+		ETHER_TYPE_IPv6;
+
+	/* Ethernet */
+	ether_addr_copy(&p->vlan.ether.da, &d->ether.d_addr);
+	ether_addr_copy(&p->vlan.ether.sa, &d->ether.s_addr);
+	d->ether.ether_type = rte_htons(ETHER_TYPE_VLAN);
+
+	/* VLAN */
+	d->vlan.vlan_tci = rte_htons(VLAN(p->vlan.vlan.pcp,
+		p->vlan.vlan.dei,
+		p->vlan.vlan.vid));
+	d->vlan.eth_proto = rte_htons(ethertype);
+
+	return 0;
+}
+
+static int
+encap_qinq_apply(void *data,
+	struct rte_table_action_encap_params *p,
+	struct rte_table_action_common_config *common_cfg)
+{
+	struct encap_qinq_data *d = data;
+	uint16_t ethertype = (common_cfg->ip_version) ?
+		ETHER_TYPE_IPv4 :
+		ETHER_TYPE_IPv6;
+
+	/* Ethernet */
+	ether_addr_copy(&p->qinq.ether.da, &d->ether.d_addr);
+	ether_addr_copy(&p->qinq.ether.sa, &d->ether.s_addr);
+	d->ether.ether_type = rte_htons(ETHER_TYPE_QINQ);
+
+	/* SVLAN */
+	d->svlan.vlan_tci = rte_htons(VLAN(p->qinq.svlan.pcp,
+		p->qinq.svlan.dei,
+		p->qinq.svlan.vid));
+	d->svlan.eth_proto = rte_htons(ETHER_TYPE_VLAN);
+
+	/* CVLAN */
+	d->cvlan.vlan_tci = rte_htons(VLAN(p->qinq.cvlan.pcp,
+		p->qinq.cvlan.dei,
+		p->qinq.cvlan.vid));
+	d->cvlan.eth_proto = rte_htons(ethertype);
+
+	return 0;
+}
+
+static int
+encap_mpls_apply(void *data,
+	struct rte_table_action_encap_params *p)
+{
+	struct encap_mpls_data *d = data;
+	uint16_t ethertype = (p->mpls.unicast) ?
+		ETHER_TYPE_MPLS_UNICAST :
+		ETHER_TYPE_MPLS_MULTICAST;
+	uint32_t i;
+
+	/* Ethernet */
+	ether_addr_copy(&p->mpls.ether.da, &d->ether.d_addr);
+	ether_addr_copy(&p->mpls.ether.sa, &d->ether.s_addr);
+	d->ether.ether_type = rte_htons(ethertype);
+
+	/* MPLS */
+	for (i = 0; i < p->mpls.mpls_count - 1; i++)
+		d->mpls[i] = rte_htonl(MPLS(p->mpls.mpls[i].label,
+			p->mpls.mpls[i].tc,
+			0,
+			p->mpls.mpls[i].ttl));
+
+	d->mpls[i] = rte_htonl(MPLS(p->mpls.mpls[i].label,
+		p->mpls.mpls[i].tc,
+		1,
+		p->mpls.mpls[i].ttl));
+
+	d->mpls_count = p->mpls.mpls_count;
+	return 0;
+}
+
+static int
+encap_pppoe_apply(void *data,
+	struct rte_table_action_encap_params *p)
+{
+	struct encap_pppoe_data *d = data;
+
+	/* Ethernet */
+	ether_addr_copy(&p->pppoe.ether.da, &d->ether.d_addr);
+	ether_addr_copy(&p->pppoe.ether.sa, &d->ether.s_addr);
+	d->ether.ether_type = rte_htons(ETHER_TYPE_PPPOE_SESSION);
+
+	/* PPPoE and PPP*/
+	d->pppoe_ppp.ver_type_code = rte_htons(0x1100);
+	d->pppoe_ppp.session_id = rte_htons(p->pppoe.pppoe.session_id);
+	d->pppoe_ppp.length = 0; /* not pre-computed */
+	d->pppoe_ppp.protocol = rte_htons(PPP_PROTOCOL_IP);
+
+	return 0;
+}
+
+static int
+encap_apply(void *data,
+	struct rte_table_action_encap_params *p,
+	struct rte_table_action_encap_config *cfg,
+	struct rte_table_action_common_config *common_cfg)
+{
+	int status;
+
+	/* Check input arguments */
+	status = encap_apply_check(p, cfg);
+	if (status)
+		return status;
+
+	switch (p->type) {
+	case RTE_TABLE_ACTION_ENCAP_ETHER:
+		return encap_ether_apply(data, p, common_cfg);
+
+	case RTE_TABLE_ACTION_ENCAP_VLAN:
+		return encap_vlan_apply(data, p, common_cfg);
+
+	case RTE_TABLE_ACTION_ENCAP_QINQ:
+		return encap_qinq_apply(data, p, common_cfg);
+
+	case RTE_TABLE_ACTION_ENCAP_MPLS:
+		return encap_mpls_apply(data, p);
+
+	case RTE_TABLE_ACTION_ENCAP_PPPOE:
+		return encap_pppoe_apply(data, p);
+
+	default:
+		return -EINVAL;
+	}
+}
+
+static __rte_always_inline void *
+encap(void *dst, const void *src, size_t n)
+{
+	dst = ((uint8_t *) dst) - n;
+	return rte_memcpy(dst, src, n);
+}
+
+static __rte_always_inline void
+pkt_work_encap(struct rte_mbuf *mbuf,
+	void *data,
+	struct rte_table_action_encap_config *cfg,
+	void *ip,
+	uint16_t total_length,
+	uint32_t ip_offset)
+{
+	switch (cfg->encap_mask) {
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_ETHER:
+		encap(ip, data, sizeof(struct encap_ether_data));
+		mbuf->data_off = ip_offset - (sizeof(struct rte_mbuf) +
+			sizeof(struct encap_ether_data));
+		mbuf->pkt_len = mbuf->data_len = total_length +
+			sizeof(struct encap_ether_data);
+		break;
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_VLAN:
+		encap(ip, data, sizeof(struct encap_vlan_data));
+		mbuf->data_off = ip_offset - (sizeof(struct rte_mbuf) +
+			sizeof(struct encap_vlan_data));
+		mbuf->pkt_len = mbuf->data_len = total_length +
+			sizeof(struct encap_vlan_data);
+		break;
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_QINQ:
+		encap(ip, data, sizeof(struct encap_qinq_data));
+		mbuf->data_off = ip_offset - (sizeof(struct rte_mbuf) +
+			sizeof(struct encap_qinq_data));
+		mbuf->pkt_len = mbuf->data_len = total_length +
+			sizeof(struct encap_qinq_data);
+		break;
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_MPLS:
+	{
+		struct encap_mpls_data *mpls = data;
+		size_t size = sizeof(struct ether_hdr) +
+			mpls->mpls_count * 4;
+
+		encap(ip, data, size);
+		mbuf->data_off = ip_offset - (sizeof(struct rte_mbuf) + size);
+		mbuf->pkt_len = mbuf->data_len = total_length + size;
+		break;
+	}
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_PPPOE:
+	{
+		struct encap_pppoe_data *pppoe =
+			encap(ip, data, sizeof(struct encap_pppoe_data));
+		pppoe->pppoe_ppp.length = rte_htons(total_length + 2);
+		mbuf->data_off = ip_offset - (sizeof(struct rte_mbuf) +
+			sizeof(struct encap_pppoe_data));
+		mbuf->pkt_len = mbuf->data_len = total_length +
+			sizeof(struct encap_pppoe_data);
+		break;
+	}
+
+	default:
+		break;
+	}
+}
+
+/**
  * Action profile
  */
 static int
@@ -375,6 +742,7 @@ action_valid(enum rte_table_action_type action)
 	case RTE_TABLE_ACTION_FWD:
 	case RTE_TABLE_ACTION_MTR:
 	case RTE_TABLE_ACTION_TM:
+	case RTE_TABLE_ACTION_ENCAP:
 		return 1;
 	default:
 		return 0;
@@ -389,6 +757,7 @@ struct ap_config {
 	struct rte_table_action_common_config common;
 	struct rte_table_action_mtr_config mtr;
 	struct rte_table_action_tm_config tm;
+	struct rte_table_action_encap_config encap;
 };
 
 static size_t
@@ -399,6 +768,8 @@ action_cfg_size(enum rte_table_action_type action)
 		return sizeof(struct rte_table_action_mtr_config);
 	case RTE_TABLE_ACTION_TM:
 		return sizeof(struct rte_table_action_tm_config);
+	case RTE_TABLE_ACTION_ENCAP:
+		return sizeof(struct rte_table_action_encap_config);
 	default:
 		return 0;
 	}
@@ -415,6 +786,9 @@ action_cfg_get(struct ap_config *ap_config,
 	case RTE_TABLE_ACTION_TM:
 		return &ap_config->tm;
 
+	case RTE_TABLE_ACTION_ENCAP:
+		return &ap_config->encap;
+
 	default:
 		return NULL;
 	}
@@ -452,6 +826,9 @@ action_data_size(enum rte_table_action_type action,
 	case RTE_TABLE_ACTION_TM:
 		return sizeof(struct tm_data);
 
+	case RTE_TABLE_ACTION_ENCAP:
+		return encap_data_size(&ap_config->encap);
+
 	default:
 		return 0;
 	}
@@ -530,6 +907,10 @@ rte_table_action_profile_action_register(struct rte_table_action_profile *profil
 		status = tm_cfg_check(action_config);
 		break;
 
+	case RTE_TABLE_ACTION_ENCAP:
+		status = encap_cfg_check(action_config);
+		break;
+
 	default:
 		status = 0;
 		break;
@@ -652,6 +1033,12 @@ rte_table_action_apply(struct rte_table_action *action,
 			action_params,
 			&action->cfg.tm);
 
+	case RTE_TABLE_ACTION_ENCAP:
+		return encap_apply(action_data,
+			action_params,
+			&action->cfg.encap,
+			&action->cfg.common);
+
 	default:
 		return -EINVAL;
 	}
@@ -869,6 +1256,18 @@ pkt_work(struct rte_mbuf *mbuf,
 			dscp);
 	}
 
+	if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_ENCAP)) {
+		void *data =
+			action_data_get(table_entry, action, RTE_TABLE_ACTION_ENCAP);
+
+		pkt_work_encap(mbuf,
+			data,
+			&cfg->encap,
+			ip,
+			total_length,
+			ip_offset);
+	}
+
 	return drop_mask;
 }
 
@@ -1013,6 +1412,45 @@ pkt4_work(struct rte_mbuf **mbufs,
 			dscp3);
 	}
 
+	if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_ENCAP)) {
+		void *data0 =
+			action_data_get(table_entry0, action, RTE_TABLE_ACTION_ENCAP);
+		void *data1 =
+			action_data_get(table_entry1, action, RTE_TABLE_ACTION_ENCAP);
+		void *data2 =
+			action_data_get(table_entry2, action, RTE_TABLE_ACTION_ENCAP);
+		void *data3 =
+			action_data_get(table_entry3, action, RTE_TABLE_ACTION_ENCAP);
+
+		pkt_work_encap(mbuf0,
+			data0,
+			&cfg->encap,
+			ip0,
+			total_length0,
+			ip_offset);
+
+		pkt_work_encap(mbuf1,
+			data1,
+			&cfg->encap,
+			ip1,
+			total_length1,
+			ip_offset);
+
+		pkt_work_encap(mbuf2,
+			data2,
+			&cfg->encap,
+			ip2,
+			total_length2,
+			ip_offset);
+
+		pkt_work_encap(mbuf3,
+			data3,
+			&cfg->encap,
+			ip3,
+			total_length3,
+			ip_offset);
+	}
+
 	return drop_mask0 |
 		(drop_mask1 << 1) |
 		(drop_mask2 << 2) |
lib/librte_pipeline/rte_table_action.h +129 -0

147 lines not on this page · raw message

Signature · 1 line
2.9.3
#106 lore raw

PATCH v2 6/44 pipeline: add nat action

In reply to Jasvinder Singh

Add implementation of Network Address Translation(NAT) action.

---
 lib/librte_pipeline/rte_table_action.c | 162 +++++++++++++++++++++++++++++++++
 lib/librte_pipeline/rte_table_action.h |  39 ++++++++
 2 files changed, 201 insertions(+)
lib/librte_pipeline/rte_table_action.c +162 -0
index cd8e7d1..ddffe18 100644
@@ -733,6 +733,115 @@ pkt_work_encap(struct rte_mbuf *mbuf,
 }
 
 /**
+ * RTE_TABLE_ACTION_NAT
+ */
+static int
+nat_cfg_check(struct rte_table_action_nat_config *nat)
+{
+	if ((nat->proto != 0x06) &&
+		(nat->proto != 0x11))
+		return -ENOTSUP;
+
+	return 0;
+}
+
+struct nat_ipv4_data {
+	uint32_t addr;
+	uint16_t port;
+	uint16_t checksum;
+} __attribute__((__packed__));
+
+struct nat_ipv6_data {
+	uint8_t addr[16];
+	uint16_t port;
+	uint16_t checksum;
+} __attribute__((__packed__));
+
+static size_t
+nat_data_size(struct rte_table_action_nat_config *nat __rte_unused,
+	struct rte_table_action_common_config *common)
+{
+	int ip_version = common->ip_version;
+
+	return (ip_version) ?
+		sizeof(struct nat_ipv4_data) :
+		sizeof(struct nat_ipv6_data);
+}
+
+static int
+nat_apply_check(struct rte_table_action_nat_params *p,
+	struct rte_table_action_common_config *cfg)
+{
+	if ((p->ip_version && (cfg->ip_version == 0)) ||
+		((p->ip_version == 0) && cfg->ip_version))
+		return -EINVAL;
+
+	return 0;
+}
+
+static int
+nat_apply(void *data,
+	struct rte_table_action_nat_params *p,
+	struct rte_table_action_common_config *cfg)
+{
+	int status;
+
+	/* Check input arguments */
+	status = nat_apply_check(p, cfg);
+	if (status)
+		return status;
+
+	/* Apply */
+	if (p->ip_version) {
+		struct nat_ipv4_data *d = data;
+
+		d->addr = rte_htonl(p->addr.ipv4);
+		d->port = rte_htons(p->port);
+		d->checksum = 0;
+	} else {
+		struct nat_ipv6_data *d = data;
+
+		memcpy(d->addr, p->addr.ipv6, sizeof(d->addr));
+		d->port = rte_htons(p->port);
+		d->checksum = 0;
+	}
+
+	return 0;
+}
+
+static __rte_always_inline void
+pkt_ipv4_work_nat(struct ipv4_hdr *ip,
+	struct nat_ipv4_data *data,
+	struct rte_table_action_nat_config *cfg)
+{
+	struct tcp_hdr *tcp = (struct tcp_hdr *) &ip[1];
+
+	if (cfg->source_nat) {
+		ip->src_addr = data->addr;
+		tcp->src_port = data->port;
+	} else {
+		ip->dst_addr = data->addr;
+		tcp->dst_port = data->port;
+	}
+}
+
+static __rte_always_inline void
+pkt_ipv6_work_nat(struct ipv6_hdr *ip,
+	struct nat_ipv6_data *data,
+	struct rte_table_action_nat_config *cfg)
+{
+	struct tcp_hdr *tcp = (struct tcp_hdr *) &ip[1];
+
+	if (cfg->source_nat) {
+		rte_memcpy(ip->src_addr, data->addr, 16);
+		tcp->src_port = data->port;
+	} else {
+		rte_memcpy(ip->dst_addr, data->addr, 16);
+		tcp->dst_port = data->port;
+	}
+}
+
+/**
  * Action profile
  */
 static int
@@ -743,6 +852,7 @@ action_valid(enum rte_table_action_type action)
 	case RTE_TABLE_ACTION_MTR:
 	case RTE_TABLE_ACTION_TM:
 	case RTE_TABLE_ACTION_ENCAP:
+	case RTE_TABLE_ACTION_NAT:
 		return 1;
 	default:
 		return 0;
@@ -758,6 +868,7 @@ struct ap_config {
 	struct rte_table_action_mtr_config mtr;
 	struct rte_table_action_tm_config tm;
 	struct rte_table_action_encap_config encap;
+	struct rte_table_action_nat_config nat;
 };
 
 static size_t
@@ -770,6 +881,8 @@ action_cfg_size(enum rte_table_action_type action)
 		return sizeof(struct rte_table_action_tm_config);
 	case RTE_TABLE_ACTION_ENCAP:
 		return sizeof(struct rte_table_action_encap_config);
+	case RTE_TABLE_ACTION_NAT:
+		return sizeof(struct rte_table_action_nat_config);
 	default:
 		return 0;
 	}
@@ -789,6 +902,9 @@ action_cfg_get(struct ap_config *ap_config,
 	case RTE_TABLE_ACTION_ENCAP:
 		return &ap_config->encap;
 
+	case RTE_TABLE_ACTION_NAT:
+		return &ap_config->nat;
+
 	default:
 		return NULL;
 	}
@@ -829,6 +945,10 @@ action_data_size(enum rte_table_action_type action,
 	case RTE_TABLE_ACTION_ENCAP:
 		return encap_data_size(&ap_config->encap);
 
+	case RTE_TABLE_ACTION_NAT:
+		return nat_data_size(&ap_config->nat,
+			&ap_config->common);
+
 	default:
 		return 0;
 	}
@@ -911,6 +1031,10 @@ rte_table_action_profile_action_register(struct rte_table_action_profile *profil
 		status = encap_cfg_check(action_config);
 		break;
 
+	case RTE_TABLE_ACTION_NAT:
+		status = nat_cfg_check(action_config);
+		break;
+
 	default:
 		status = 0;
 		break;
@@ -1039,6 +1163,11 @@ rte_table_action_apply(struct rte_table_action *action,
 			&action->cfg.encap,
 			&action->cfg.common);
 
+	case RTE_TABLE_ACTION_NAT:
+		return nat_apply(action_data,
+			action_params,
+			&action->cfg.common);
+
 	default:
 		return -EINVAL;
 	}
@@ -1268,6 +1397,16 @@ pkt_work(struct rte_mbuf *mbuf,
 			ip_offset);
 	}
 
+	if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_NAT)) {
+		void *data =
+			action_data_get(table_entry, action, RTE_TABLE_ACTION_NAT);
+
+		if (cfg->common.ip_version)
+			pkt_ipv4_work_nat(ip, data, &cfg->nat);
+		else
+			pkt_ipv6_work_nat(ip, data, &cfg->nat);
+	}
+
 	return drop_mask;
 }
 
@@ -1451,6 +1590,29 @@ pkt4_work(struct rte_mbuf **mbufs,
 			ip_offset);
 	}
 
+	if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_NAT)) {
+		void *data0 =
+			action_data_get(table_entry0, action, RTE_TABLE_ACTION_NAT);
+		void *data1 =
+			action_data_get(table_entry1, action, RTE_TABLE_ACTION_NAT);
+		void *data2 =
+			action_data_get(table_entry2, action, RTE_TABLE_ACTION_NAT);
+		void *data3 =
+			action_data_get(table_entry3, action, RTE_TABLE_ACTION_NAT);
+
+		if (cfg->common.ip_version) {
+			pkt_ipv4_work_nat(ip0, data0, &cfg->nat);
+			pkt_ipv4_work_nat(ip1, data1, &cfg->nat);
+			pkt_ipv4_work_nat(ip2, data2, &cfg->nat);
+			pkt_ipv4_work_nat(ip3, data3, &cfg->nat);
+		} else {
+			pkt_ipv6_work_nat(ip0, data0, &cfg->nat);
+			pkt_ipv6_work_nat(ip1, data1, &cfg->nat);
+			pkt_ipv6_work_nat(ip2, data2, &cfg->nat);
+			pkt_ipv6_work_nat(ip3, data3, &cfg->nat);
+		}
+	}
+
 	return drop_mask0 |
 		(drop_mask1 << 1) |
 		(drop_mask2 << 2) |
lib/librte_pipeline/rte_table_action.h +39 -0
index c5c987d..5204511 100644
@@ -77,6 +77,9 @@ enum rte_table_action_type {
 
 	/** Packet encapsulations. */
 	RTE_TABLE_ACTION_ENCAP,
+
+	/** Network Address Translation (NAT). */
+	RTE_TABLE_ACTION_NAT,
 };
 
 /** Common action configuration (per table action profile). */
@@ -409,6 +412,42 @@ struct rte_table_action_encap_params {
 };
 
 /**
+ * RTE_TABLE_ACTION_NAT
+ */
+/** NAT action configuration (per table action profile). */
+struct rte_table_action_nat_config {
+	/** When non-zero, the IP source address and L4 protocol source port are
+	 * translated. When zero, the IP destination address and L4 protocol
+	 * destination port are translated.
+	 */
+	int source_nat;
+
+	/** Layer 4 protocol, for example TCP (0x06) or UDP (0x11). The checksum
+	 * field is computed differently and placed at different header offset
+	 * by each layer 4 protocol.
+	 */
+	uint8_t proto;
+};
+
+/** NAT action parameters (per table rule). */
+struct rte_table_action_nat_params {
+	/** IP version for *addr*: non-zero for IPv4, zero for IPv6. */
+	int ip_version;
+
+	/** IP address. */
+	union {
+		/** IPv4 address; only valid when *ip_version* is non-zero. */
+		uint32_t ipv4;
+
+		/** IPv6 address; only valid when *ip_version* is set to 0. */
+		uint8_t ipv6[16];
+	} addr;
+
+	/** Port. */
+	uint16_t port;
+};
+
+/**
  * Table action profile.
  */
 struct rte_table_action_profile;
Signature · 1 line
2.9.3
#107 lore raw

PATCH v2 7/44 pipeline: add ttl update action

In reply to Jasvinder Singh

Add implementation of ttl update action.

---
 lib/librte_pipeline/rte_pipeline_version.map |   1 +
 lib/librte_pipeline/rte_table_action.c       | 155 +++++++++++++++++++++++++++
 lib/librte_pipeline/rte_table_action.h       |  66 ++++++++++++
 3 files changed, 222 insertions(+)
lib/librte_pipeline/rte_pipeline_version.map +1 -0
index c7106dc..9388585 100644
@@ -61,5 +61,6 @@ EXPERIMENTAL {
 	rte_table_action_profile_free;
 	rte_table_action_profile_freeze;
 	rte_table_action_table_params_get;
+	rte_table_action_ttl_read;
 
 } DPDK_16.04;
lib/librte_pipeline/rte_table_action.c +155 -0

221 lines not on this page · raw message

lib/librte_pipeline/rte_table_action.h +66 -0

84 lines not on this page · raw message

Signature · 1 line
2.9.3
#108 lore raw

PATCH v2 8/44 pipeline: add statistics read action

In reply to Jasvinder Singh

Add implementation of stats read action

---
 lib/librte_pipeline/rte_pipeline_version.map |   1 +
 lib/librte_pipeline/rte_table_action.c       | 112 ++++++++++++++++++++++++++-
 lib/librte_pipeline/rte_table_action.h       |  78 +++++++++++++++++++
 3 files changed, 190 insertions(+), 1 deletion(-)
lib/librte_pipeline/rte_pipeline_version.map +1 -0
index 9388585..8241efc 100644
@@ -61,6 +61,7 @@ EXPERIMENTAL {
 	rte_table_action_profile_free;
 	rte_table_action_profile_freeze;
 	rte_table_action_table_params_get;
+	rte_table_action_stats_read;
 	rte_table_action_ttl_read;
 
 } DPDK_16.04;
lib/librte_pipeline/rte_table_action.c +111 -1

184 lines not on this page · raw message

lib/librte_pipeline/rte_table_action.h +78 -0

96 lines not on this page · raw message

Signature · 1 line
2.9.3
#109 lore raw

PATCH v2 9/44 pipeline: add timestamp action

In reply to Jasvinder Singh

Add implementation of timestamp action.

---
 lib/librte_pipeline/rte_pipeline_version.map |  1 +
 lib/librte_pipeline/rte_table_action.c       | 79 +++++++++++++++++++++++++++-
 lib/librte_pipeline/rte_table_action.h       | 31 +++++++++++
 3 files changed, 110 insertions(+), 1 deletion(-)
lib/librte_pipeline/rte_pipeline_version.map +1 -0
index 8241efc..4e948b8 100644
@@ -62,6 +62,7 @@ EXPERIMENTAL {
 	rte_table_action_profile_freeze;
 	rte_table_action_table_params_get;
 	rte_table_action_stats_read;
+	rte_table_action_time_read;
 	rte_table_action_ttl_read;
 
 } DPDK_16.04;
lib/librte_pipeline/rte_table_action.c +78 -1

127 lines not on this page · raw message

lib/librte_pipeline/rte_table_action.h +31 -0
index 53b9866..e9b30ab 100644
@@ -86,6 +86,9 @@ enum rte_table_action_type {
 
 	/** Statistics. */
 	RTE_TABLE_ACTION_STATS,
+
+	/** Timestamp. */
+	RTE_TABLE_ACTION_TIME,
 };
 
 /** Common action configuration (per table action profile). */
@@ -542,6 +545,15 @@ struct rte_table_action_stats_counters {
 };
 
 /**
+ * RTE_TABLE_ACTION_TIME
+ */
+/** Timestamp action parameters (per table rule). */
+struct rte_table_action_time_params {
+	/** Initial timestamp value. Typically set to current time. */
+	uint64_t time;
+};
+
+/**
  * Table action profile.
  */
 struct rte_table_action_profile;
@@ -815,6 +827,25 @@ rte_table_action_stats_read(struct rte_table_action *action,
 	struct rte_table_action_stats_counters *stats,
 	int clear);
 
+/**
+ * Table action timestamp read.
+ *
+ * @param[in] action
+ *   Handle to table action object (needs to be valid).
+ * @param[in] data
+ *   Data byte array (typically table rule data) with timestamp action
+ *   previously applied on it.
+ * @param[inout] timestamp
+ *   Pre-allocated memory where the timestamp read from *data* is saved (has to
+ *   be non-NULL).
+ * @return
+ *   Zero on success, non-zero error code otherwise.
+ */
+int __rte_experimental
+rte_table_action_time_read(struct rte_table_action *action,
+	void *data,
+	uint64_t *timestamp);
+
 #ifdef __cplusplus
 }
 #endif
Signature · 1 line
2.9.3
#110 lore raw

PATCH v2 10/44 ip_pipeline: remove passthrough pipeline

In reply to Jasvinder Singh

remove passthrough pipeline.

---
 examples/ip_pipeline/Makefile                      |   2 -
 examples/ip_pipeline/init.c                        |   2 -
 examples/ip_pipeline/meson.build                   |   2 -
 .../ip_pipeline/pipeline/pipeline_passthrough.c    |  45 -
 .../ip_pipeline/pipeline/pipeline_passthrough.h    |  12 -
 .../ip_pipeline/pipeline/pipeline_passthrough_be.c | 929 ---------------------
 .../ip_pipeline/pipeline/pipeline_passthrough_be.h |  44 -
 7 files changed, 1036 deletions(-)
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_passthrough.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_passthrough.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_passthrough_be.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_passthrough_be.h
examples/ip_pipeline/Makefile +0 -2
index 85fbbaf..089c269 100644
@@ -19,8 +19,6 @@ SRCS-y += pipeline_common_be.c
 SRCS-y += pipeline_common_fe.c
 SRCS-y += pipeline_master_be.c
 SRCS-y += pipeline_master.c
-SRCS-y += pipeline_passthrough_be.c
-SRCS-y += pipeline_passthrough.c
 SRCS-y += pipeline_firewall_be.c
 SRCS-y += pipeline_firewall.c
 SRCS-y += pipeline_flow_classification_be.c
examples/ip_pipeline/init.c +0 -2
index bb07efa..73b93d7 100644
@@ -26,7 +26,6 @@
 #include "pipeline.h"
 #include "pipeline_common_fe.h"
 #include "pipeline_master.h"
-#include "pipeline_passthrough.h"
 #include "pipeline_firewall.h"
 #include "pipeline_flow_classification.h"
 #include "pipeline_flow_actions.h"
@@ -1822,7 +1821,6 @@ int app_init(struct app_params *app)
 	app_pipeline_common_cmd_push(app);
 	app_pipeline_thread_cmd_push(app);
 	app_pipeline_type_register(app, &pipeline_master);
-	app_pipeline_type_register(app, &pipeline_passthrough);
 	app_pipeline_type_register(app, &pipeline_flow_classification);
 	app_pipeline_type_register(app, &pipeline_flow_actions);
 	app_pipeline_type_register(app, &pipeline_firewall);
examples/ip_pipeline/meson.build +0 -2
index 748c9ae..db80078 100644
@@ -28,8 +28,6 @@ sources = files(
 	'pipeline/pipeline_flow_classification.c',
 	'pipeline/pipeline_master_be.c',
 	'pipeline/pipeline_master.c',
-	'pipeline/pipeline_passthrough_be.c',
-	'pipeline/pipeline_passthrough.c',
 	'pipeline/pipeline_routing_be.c',
 	'pipeline/pipeline_routing.c',
 )
examples/ip_pipeline/pipeline/pipeline_passthrough.c deleted +0 -45

45 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_passthrough.h deleted +0 -12
deleted file mode 100644
index 7a7a2fc..0000000
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_PASSTHROUGH_H__
-#define __INCLUDE_PIPELINE_PASSTHROUGH_H__
-
-#include "pipeline.h"
-
-extern struct pipeline_type pipeline_passthrough;
-
-#endif
examples/ip_pipeline/pipeline/pipeline_passthrough_be.c deleted +0 -929

929 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_passthrough_be.h deleted +0 -44

44 lines not on this page · raw message

Signature · 1 line
2.9.3
#111 lore raw

PATCH v2 11/44 ip_pipeline: remove routing pipeline

In reply to Jasvinder Singh

Remove routing pipeline.

---
 examples/ip_pipeline/Makefile                      |    2 -
 examples/ip_pipeline/init.c                        |    2 -
 examples/ip_pipeline/meson.build                   |    2 -
 examples/ip_pipeline/pipeline/pipeline_routing.c   | 1613 ----------------
 examples/ip_pipeline/pipeline/pipeline_routing.h   |   71 -
 .../ip_pipeline/pipeline/pipeline_routing_be.c     | 1966 --------------------
 .../ip_pipeline/pipeline/pipeline_routing_be.h     |  283 ---
 7 files changed, 3939 deletions(-)
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_routing.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_routing.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_routing_be.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_routing_be.h
examples/ip_pipeline/Makefile +0 -2
index 089c269..f67cfe6 100644
@@ -25,8 +25,6 @@ SRCS-y += pipeline_flow_classification_be.c
 SRCS-y += pipeline_flow_classification.c
 SRCS-y += pipeline_flow_actions_be.c
 SRCS-y += pipeline_flow_actions.c
-SRCS-y += pipeline_routing_be.c
-SRCS-y += pipeline_routing.c
 
 # Build using pkg-config variables if possible
 $(shell pkg-config --exists libdpdk)
examples/ip_pipeline/init.c +0 -2
index 73b93d7..241d80a 100644
@@ -29,7 +29,6 @@
 #include "pipeline_firewall.h"
 #include "pipeline_flow_classification.h"
 #include "pipeline_flow_actions.h"
-#include "pipeline_routing.h"
 #include "thread_fe.h"
 
 #define APP_NAME_SIZE	32
@@ -1824,7 +1823,6 @@ int app_init(struct app_params *app)
 	app_pipeline_type_register(app, &pipeline_flow_classification);
 	app_pipeline_type_register(app, &pipeline_flow_actions);
 	app_pipeline_type_register(app, &pipeline_firewall);
-	app_pipeline_type_register(app, &pipeline_routing);
 
 	app_init_pipelines(app);
 	app_init_threads(app);
examples/ip_pipeline/meson.build +0 -2
index db80078..53d36df 100644
@@ -28,6 +28,4 @@ sources = files(
 	'pipeline/pipeline_flow_classification.c',
 	'pipeline/pipeline_master_be.c',
 	'pipeline/pipeline_master.c',
-	'pipeline/pipeline_routing_be.c',
-	'pipeline/pipeline_routing.c',
 )
examples/ip_pipeline/pipeline/pipeline_routing.c deleted +0 -1613

1,613 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_routing.h deleted +0 -71

71 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_routing_be.c deleted +0 -1966

1,288 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_routing_be.h deleted +0 -283

283 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.9.3

Part of the diff is not shown here. View the raw message.

#112 lore raw

PATCH v2 12/44 ip_pipeline: remove flow classification pipeline

In reply to Jasvinder Singh

Remove flow classification pipeline.

---
 examples/ip_pipeline/Makefile                      |    2 -
 examples/ip_pipeline/init.c                        |    2 -
 examples/ip_pipeline/meson.build                   |    2 -
 .../pipeline/pipeline_flow_classification.c        | 1878 --------------------
 .../pipeline/pipeline_flow_classification.h        |  106 --
 .../pipeline/pipeline_flow_classification_be.c     |  723 --------
 .../pipeline/pipeline_flow_classification_be.h     |  113 --
 7 files changed, 2826 deletions(-)
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_classification.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_classification.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_classification_be.h
examples/ip_pipeline/Makefile +0 -2
index f67cfe6..e43001f 100644
@@ -21,8 +21,6 @@ SRCS-y += pipeline_master_be.c
 SRCS-y += pipeline_master.c
 SRCS-y += pipeline_firewall_be.c
 SRCS-y += pipeline_firewall.c
-SRCS-y += pipeline_flow_classification_be.c
-SRCS-y += pipeline_flow_classification.c
 SRCS-y += pipeline_flow_actions_be.c
 SRCS-y += pipeline_flow_actions.c
 
examples/ip_pipeline/init.c +0 -2
index 241d80a..4780bb1 100644
@@ -27,7 +27,6 @@
 #include "pipeline_common_fe.h"
 #include "pipeline_master.h"
 #include "pipeline_firewall.h"
-#include "pipeline_flow_classification.h"
 #include "pipeline_flow_actions.h"
 #include "thread_fe.h"
 
@@ -1820,7 +1819,6 @@ int app_init(struct app_params *app)
 	app_pipeline_common_cmd_push(app);
 	app_pipeline_thread_cmd_push(app);
 	app_pipeline_type_register(app, &pipeline_master);
-	app_pipeline_type_register(app, &pipeline_flow_classification);
 	app_pipeline_type_register(app, &pipeline_flow_actions);
 	app_pipeline_type_register(app, &pipeline_firewall);
 
examples/ip_pipeline/meson.build +0 -2
index 53d36df..a04e418 100644
@@ -24,8 +24,6 @@ sources = files(
 	'pipeline/pipeline_firewall.c',
 	'pipeline/pipeline_flow_actions_be.c',
 	'pipeline/pipeline_flow_actions.c',
-	'pipeline/pipeline_flow_classification_be.c',
-	'pipeline/pipeline_flow_classification.c',
 	'pipeline/pipeline_master_be.c',
 	'pipeline/pipeline_master.c',
 )
examples/ip_pipeline/pipeline/pipeline_flow_classification.c deleted +0 -1878

1,878 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_flow_classification.h deleted +0 -106

106 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c deleted +0 -723

723 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_flow_classification_be.h deleted +0 -113

113 lines not on this page · raw message

Signature · 1 line
2.9.3
#113 lore raw

PATCH v2 13/44 ip_pipeline: remove flow actions pipeline

In reply to Jasvinder Singh

Remove flow actions pipeline.

---
 examples/ip_pipeline/Makefile                      |    2 -
 examples/ip_pipeline/init.c                        |    2 -
 examples/ip_pipeline/meson.build                   |    2 -
 .../ip_pipeline/pipeline/pipeline_flow_actions.c   | 1286 --------------------
 .../ip_pipeline/pipeline/pipeline_flow_actions.h   |   60 -
 .../pipeline/pipeline_flow_actions_be.c            |  983 ---------------
 .../pipeline/pipeline_flow_actions_be.h            |  139 ---
 7 files changed, 2474 deletions(-)
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_actions.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_actions.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_actions_be.h
examples/ip_pipeline/Makefile +0 -2
index e43001f..0782308 100644
@@ -21,8 +21,6 @@ SRCS-y += pipeline_master_be.c
 SRCS-y += pipeline_master.c
 SRCS-y += pipeline_firewall_be.c
 SRCS-y += pipeline_firewall.c
-SRCS-y += pipeline_flow_actions_be.c
-SRCS-y += pipeline_flow_actions.c
 
 # Build using pkg-config variables if possible
 $(shell pkg-config --exists libdpdk)
examples/ip_pipeline/init.c +0 -2
index 4780bb1..6599b0d 100644
@@ -27,7 +27,6 @@
 #include "pipeline_common_fe.h"
 #include "pipeline_master.h"
 #include "pipeline_firewall.h"
-#include "pipeline_flow_actions.h"
 #include "thread_fe.h"
 
 #define APP_NAME_SIZE	32
@@ -1819,7 +1818,6 @@ int app_init(struct app_params *app)
 	app_pipeline_common_cmd_push(app);
 	app_pipeline_thread_cmd_push(app);
 	app_pipeline_type_register(app, &pipeline_master);
-	app_pipeline_type_register(app, &pipeline_flow_actions);
 	app_pipeline_type_register(app, &pipeline_firewall);
 
 	app_init_pipelines(app);
examples/ip_pipeline/meson.build +0 -2
index a04e418..802c82c 100644
@@ -22,8 +22,6 @@ sources = files(
 	'pipeline/pipeline_common_fe.c',
 	'pipeline/pipeline_firewall_be.c',
 	'pipeline/pipeline_firewall.c',
-	'pipeline/pipeline_flow_actions_be.c',
-	'pipeline/pipeline_flow_actions.c',
 	'pipeline/pipeline_master_be.c',
 	'pipeline/pipeline_master.c',
 )
examples/ip_pipeline/pipeline/pipeline_flow_actions.c deleted +0 -1286

1,286 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_flow_actions.h deleted +0 -60

60 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c deleted +0 -983

983 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_flow_actions_be.h deleted +0 -139

139 lines not on this page · raw message

Signature · 1 line
2.9.3
#114 lore raw

PATCH v2 14/44 ip_pipeline: remove firewall pipeline

In reply to Jasvinder Singh

Remove firewall pipeline.

---
 examples/ip_pipeline/Makefile                      |    2 -
 examples/ip_pipeline/init.c                        |    2 -
 examples/ip_pipeline/meson.build                   |    2 -
 examples/ip_pipeline/pipeline/pipeline_firewall.c  | 1421 --------------------
 examples/ip_pipeline/pipeline/pipeline_firewall.h  |   60 -
 .../ip_pipeline/pipeline/pipeline_firewall_be.c    |  856 ------------
 .../ip_pipeline/pipeline/pipeline_firewall_be.h    |  147 --
 7 files changed, 2490 deletions(-)
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_firewall.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_firewall.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_firewall_be.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_firewall_be.h
examples/ip_pipeline/Makefile +0 -2
index 0782308..ae76edc 100644
@@ -19,8 +19,6 @@ SRCS-y += pipeline_common_be.c
 SRCS-y += pipeline_common_fe.c
 SRCS-y += pipeline_master_be.c
 SRCS-y += pipeline_master.c
-SRCS-y += pipeline_firewall_be.c
-SRCS-y += pipeline_firewall.c
 
 # Build using pkg-config variables if possible
 $(shell pkg-config --exists libdpdk)
examples/ip_pipeline/init.c +0 -2
index 6599b0d..f848310 100644
@@ -26,7 +26,6 @@
 #include "pipeline.h"
 #include "pipeline_common_fe.h"
 #include "pipeline_master.h"
-#include "pipeline_firewall.h"
 #include "thread_fe.h"
 
 #define APP_NAME_SIZE	32
@@ -1818,7 +1817,6 @@ int app_init(struct app_params *app)
 	app_pipeline_common_cmd_push(app);
 	app_pipeline_thread_cmd_push(app);
 	app_pipeline_type_register(app, &pipeline_master);
-	app_pipeline_type_register(app, &pipeline_firewall);
 
 	app_init_pipelines(app);
 	app_init_threads(app);
examples/ip_pipeline/meson.build +0 -2
index 802c82c..7563b39 100644
@@ -20,8 +20,6 @@ sources = files(
 	'thread_fe.c',
 	'pipeline/pipeline_common_be.c',
 	'pipeline/pipeline_common_fe.c',
-	'pipeline/pipeline_firewall_be.c',
-	'pipeline/pipeline_firewall.c',
 	'pipeline/pipeline_master_be.c',
 	'pipeline/pipeline_master.c',
 )
examples/ip_pipeline/pipeline/pipeline_firewall.c deleted +0 -1421

1,421 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_firewall.h deleted +0 -60

60 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_firewall_be.c deleted +0 -856

856 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_firewall_be.h deleted +0 -147

147 lines not on this page · raw message

Signature · 1 line
2.9.3
#115 lore raw

PATCH v2 15/44 ip_pipeline: remove master pipeline

In reply to Jasvinder Singh

remove master pipeline.

---
 examples/ip_pipeline/Makefile                      |    6 -
 examples/ip_pipeline/app.h                         |   12 -
 examples/ip_pipeline/{pipeline => }/hash_func.h    |    3 +-
 .../ip_pipeline/{pipeline => }/hash_func_arm64.h   |    0
 examples/ip_pipeline/init.c                        |  574 --------
 examples/ip_pipeline/meson.build                   |    8 +-
 .../ip_pipeline/pipeline/pipeline_actions_common.h |  202 ---
 examples/ip_pipeline/pipeline/pipeline_common_be.c |  176 ---
 examples/ip_pipeline/pipeline/pipeline_common_be.h |  134 --
 examples/ip_pipeline/pipeline/pipeline_common_fe.c | 1455 --------------------
 examples/ip_pipeline/pipeline/pipeline_common_fe.h |  231 ----
 examples/ip_pipeline/pipeline/pipeline_master.c    |   20 -
 examples/ip_pipeline/pipeline/pipeline_master.h    |   12 -
 examples/ip_pipeline/pipeline/pipeline_master_be.c |  141 --
 examples/ip_pipeline/pipeline/pipeline_master_be.h |   12 -
 examples/ip_pipeline/thread.c                      |   53 -
 examples/ip_pipeline/thread_fe.c                   |  457 ------
 examples/ip_pipeline/thread_fe.h                   |   72 -
 18 files changed, 3 insertions(+), 3565 deletions(-)
 rename examples/ip_pipeline/{pipeline => }/hash_func.h (99%)
 rename examples/ip_pipeline/{pipeline => }/hash_func_arm64.h (100%)
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_actions_common.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_common_be.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_common_be.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_common_fe.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_common_fe.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_master.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_master.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_master_be.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_master_be.h
 delete mode 100644 examples/ip_pipeline/thread_fe.c
 delete mode 100644 examples/ip_pipeline/thread_fe.h
examples/ip_pipeline/Makefile +0 -6
index ae76edc..8ba7887 100644
@@ -12,14 +12,8 @@ SRCS-y += config_parse_tm.c
 SRCS-y += config_check.c
 SRCS-y += init.c
 SRCS-y += thread.c
-SRCS-y += thread_fe.c
 SRCS-y += cpu_core_map.c
 
-SRCS-y += pipeline_common_be.c
-SRCS-y += pipeline_common_fe.c
-SRCS-y += pipeline_master_be.c
-SRCS-y += pipeline_master.c
-
 # Build using pkg-config variables if possible
 $(shell pkg-config --exists libdpdk)
 ifeq ($(.SHELLSTATUS),0)
examples/ip_pipeline/app.h +0 -12
index 907d4e7..dadaf2b 100644
@@ -1359,10 +1359,6 @@ app_core_build_core_mask_string(struct app_params *app, char *mask_buffer)
 	}
 }
 
-void app_pipeline_params_get(struct app_params *app,
-	struct app_pipeline_params *p_in,
-	struct pipeline_params *p_out);
-
 int app_config_init(struct app_params *app);
 
 int app_config_args(struct app_params *app,
@@ -1382,16 +1378,8 @@ int app_config_check(struct app_params *app);
 
 int app_init(struct app_params *app);
 
-int app_post_init(struct app_params *app);
-
 int app_thread(void *arg);
 
-int app_pipeline_type_register(struct app_params *app,
-	struct pipeline_type *ptype);
-
-struct pipeline_type *app_pipeline_type_find(struct app_params *app,
-	char *name);
-
 void app_link_up_internal(struct app_params *app,
 	struct app_link_params *cp);
 
examples/ip_pipeline/hash_func.h renamed from examples/ip_pipeline/pipeline/hash_func.h +2 -1
similarity index 99%
rename from examples/ip_pipeline/pipeline/hash_func.h
rename to examples/ip_pipeline/hash_func.h
index 806ac22..f1b9d94 100644
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
+ * Copyright(c) 2010-2018 Intel Corporation
  */
+
 #ifndef __INCLUDE_HASH_FUNC_H__
 #define __INCLUDE_HASH_FUNC_H__
 
examples/ip_pipeline/hash_func_arm64.h renamed from examples/ip_pipeline/pipeline/hash_func_arm64.h +0 -0
similarity index 100%
rename from examples/ip_pipeline/pipeline/hash_func_arm64.h
rename to examples/ip_pipeline/hash_func_arm64.h
examples/ip_pipeline/init.c +0 -574

591 lines not on this page · raw message

examples/ip_pipeline/meson.build +1 -7
index 7563b39..be3f3e5 100644
@@ -6,8 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
-deps += ['cfgfile', 'pipeline', 'bus_pci']
-includes += include_directories('pipeline')
+deps += ['cfgfile', 'bus_pci']
 sources = files(
 	'config_check.c',
 	'config_parse.c',
@@ -17,9 +16,4 @@ sources = files(
 	'main.c',
 	'parser.c',
 	'thread.c',
-	'thread_fe.c',
-	'pipeline/pipeline_common_be.c',
-	'pipeline/pipeline_common_fe.c',
-	'pipeline/pipeline_master_be.c',
-	'pipeline/pipeline_master.c',
 )
examples/ip_pipeline/pipeline/pipeline_actions_common.h deleted +0 -202

202 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_common_be.c deleted +0 -176

176 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_common_be.h deleted +0 -134

134 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_common_fe.c deleted +0 -1455

1,455 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_common_fe.h deleted +0 -231

231 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_master.c deleted +0 -20
deleted file mode 100644
index b0d730a..0000000
@@ -1,20 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#include "pipeline_master.h"
-#include "pipeline_master_be.h"
-
-static struct pipeline_fe_ops pipeline_master_fe_ops = {
-	.f_init = NULL,
-	.f_post_init = NULL,
-	.f_free = NULL,
-	.f_track = NULL,
-	.cmds = NULL,
-};
-
-struct pipeline_type pipeline_master = {
-	.name = "MASTER",
-	.be_ops = &pipeline_master_be_ops,
-	.fe_ops = &pipeline_master_fe_ops,
-};
examples/ip_pipeline/pipeline/pipeline_master.h deleted +0 -12
deleted file mode 100644
index a5183e3..0000000
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_MASTER_H__
-#define __INCLUDE_PIPELINE_MASTER_H__
-
-#include "pipeline.h"
-
-extern struct pipeline_type pipeline_master;
-
-#endif
examples/ip_pipeline/pipeline/pipeline_master_be.c deleted +0 -141

113 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_master_be.h deleted +0 -12
deleted file mode 100644
index 847c564..0000000

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/thread.c +0 -53

53 lines not on this page · raw message

examples/ip_pipeline/thread_fe.c deleted +0 -457

457 lines not on this page · raw message

examples/ip_pipeline/thread_fe.h deleted +0 -72

72 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.9.3

Part of the diff is not shown here. View the raw message.

#116 lore raw

PATCH v2 16/44 ip_pipeline: remove config

In reply to Jasvinder Singh

Remove application configuration and script files.

---
 examples/ip_pipeline/config/action.cfg             |  68 --
 examples/ip_pipeline/config/action.sh              | 119 ---
 examples/ip_pipeline/config/action.txt             |   8 -
 examples/ip_pipeline/config/diagram-generator.py   | 317 -------
 .../ip_pipeline/config/edge_router_downstream.cfg  |  97 ---
 .../ip_pipeline/config/edge_router_downstream.sh   |  13 -
 .../ip_pipeline/config/edge_router_upstream.cfg    | 124 ---
 .../ip_pipeline/config/edge_router_upstream.sh     |  33 -
 examples/ip_pipeline/config/firewall.cfg           |  68 --
 examples/ip_pipeline/config/firewall.sh            |  13 -
 examples/ip_pipeline/config/firewall.txt           |   9 -
 examples/ip_pipeline/config/flow.cfg               |  72 --
 examples/ip_pipeline/config/flow.sh                |  25 -
 examples/ip_pipeline/config/flow.txt               |  17 -
 examples/ip_pipeline/config/ip_pipeline.cfg        |   9 -
 examples/ip_pipeline/config/ip_pipeline.sh         |   5 -
 examples/ip_pipeline/config/kni.cfg                |  67 --
 examples/ip_pipeline/config/l2fwd.cfg              |  58 --
 examples/ip_pipeline/config/l3fwd.cfg              |  68 --
 examples/ip_pipeline/config/l3fwd.sh               |  33 -
 examples/ip_pipeline/config/l3fwd_arp.cfg          |  70 --
 examples/ip_pipeline/config/l3fwd_arp.sh           |  43 -
 examples/ip_pipeline/config/network_layers.cfg     | 227 ------
 examples/ip_pipeline/config/network_layers.sh      |  79 --
 .../ip_pipeline/config/pipeline-to-core-mapping.py | 906 ---------------------
 examples/ip_pipeline/config/tap.cfg                |  64 --
 examples/ip_pipeline/config/tm_profile.cfg         | 105 ---
 27 files changed, 2717 deletions(-)
 delete mode 100644 examples/ip_pipeline/config/action.cfg
 delete mode 100644 examples/ip_pipeline/config/action.sh
 delete mode 100644 examples/ip_pipeline/config/action.txt
 delete mode 100755 examples/ip_pipeline/config/diagram-generator.py
 delete mode 100644 examples/ip_pipeline/config/edge_router_downstream.cfg
 delete mode 100644 examples/ip_pipeline/config/edge_router_downstream.sh
 delete mode 100644 examples/ip_pipeline/config/edge_router_upstream.cfg
 delete mode 100644 examples/ip_pipeline/config/edge_router_upstream.sh
 delete mode 100644 examples/ip_pipeline/config/firewall.cfg
 delete mode 100644 examples/ip_pipeline/config/firewall.sh
 delete mode 100644 examples/ip_pipeline/config/firewall.txt
 delete mode 100644 examples/ip_pipeline/config/flow.cfg
 delete mode 100644 examples/ip_pipeline/config/flow.sh
 delete mode 100644 examples/ip_pipeline/config/flow.txt
 delete mode 100644 examples/ip_pipeline/config/ip_pipeline.cfg
 delete mode 100644 examples/ip_pipeline/config/ip_pipeline.sh
 delete mode 100644 examples/ip_pipeline/config/kni.cfg
 delete mode 100644 examples/ip_pipeline/config/l2fwd.cfg
 delete mode 100644 examples/ip_pipeline/config/l3fwd.cfg
 delete mode 100644 examples/ip_pipeline/config/l3fwd.sh
 delete mode 100644 examples/ip_pipeline/config/l3fwd_arp.cfg
 delete mode 100644 examples/ip_pipeline/config/l3fwd_arp.sh
 delete mode 100644 examples/ip_pipeline/config/network_layers.cfg
 delete mode 100644 examples/ip_pipeline/config/network_layers.sh
 delete mode 100755 examples/ip_pipeline/config/pipeline-to-core-mapping.py
 delete mode 100644 examples/ip_pipeline/config/tap.cfg
 delete mode 100644 examples/ip_pipeline/config/tm_profile.cfg
examples/ip_pipeline/config/action.cfg deleted +0 -68
deleted file mode 100644
index 994ae94..0000000
@@ -1,68 +0,0 @@
-;   BSD LICENSE
-;
-;   Copyright(c) 2016 Intel Corporation. All rights reserved.
-;   All rights reserved.
-;
-;   Redistribution and use in source and binary forms, with or without
-;   modification, are permitted provided that the following conditions
-;   are met:
-;
-;     * Redistributions of source code must retain the above copyright
-;       notice, this list of conditions and the following disclaimer.
-;     * Redistributions in binary form must reproduce the above copyright
-;       notice, this list of conditions and the following disclaimer in
-;       the documentation and/or other materials provided with the
-;       distribution.
-;     * Neither the name of Intel Corporation nor the names of its
-;       contributors may be used to endorse or promote products derived
-;       from this software without specific prior written permission.
-;
-;   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-;   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-;   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-;   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-;   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-;   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-;   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-;   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-;   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-;   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-;   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-;             ________________
-; RXQ0.0 --->|                |---> TXQ0.0
-;            |                |
-; RXQ1.0 --->|                |---> TXQ1.0
-;            |      Flow      |
-; RXQ2.0 --->|     Actions    |---> TXQ2.0
-;            |                |
-; RXQ3.0 --->|                |---> TXQ3.0
-;            |________________|
-;
-;
-; Input packet: Ethernet/IPv4
-;
-; Packet buffer layout:
-; #	Field Name		Offset (Bytes)	Size (Bytes)
-; 0	Mbuf			0 		128
-; 1	Headroom		128 		128
-; 2	Ethernet header		256 		14
-; 3	IPv4 header		270 		20
-
-[EAL]
-log_level = 0
-
-[PIPELINE0]
-type = MASTER
-core = 0
-
-[PIPELINE1]
-type = FLOW_ACTIONS
-core = 1
-pktq_in = RXQ0.0 RXQ1.0 RXQ2.0 RXQ3.0
-pktq_out = TXQ0.0 TXQ1.0 TXQ2.0 TXQ3.0
-n_flows = 65536
-n_meters_per_flow = 4
-flow_id_offset = 286; ipdaddr
-ip_hdr_offset = 270
-color_offset = 128
examples/ip_pipeline/config/action.sh deleted +0 -119

119 lines not on this page · raw message

examples/ip_pipeline/config/action.txt deleted +0 -8
deleted file mode 100644
index f14207b..0000000
@@ -1,8 +0,0 @@
-#
-# p <pipelineid> action flow bulk ./config/action.txt
-#
-
-flow 0 meter 0 trtcm 1250000000 1250000000 1000000 1000000 policer 0 g G y Y r R meter 1 trtcm 1250000000 1250000000 1000000 1000000 policer 1 g G y Y r R meter 2 trtcm 1250000000 1250000000 1000000 1000000 policer 2 g G y Y r R meter 3 trtcm 1250000000 1250000000 1000000 1000000 policer 3 g G y Y r R port 0
-flow 1 meter 0 trtcm 1250000000 1250000000 1000000 1000000 policer 0 g G y Y r R meter 1 trtcm 1250000000 1250000000 1000000 1000000 policer 1 g G y Y r R meter 2 trtcm 1250000000 1250000000 1000000 1000000 policer 2 g G y Y r R meter 3 trtcm 1250000000 1250000000 1000000 1000000 policer 3 g G y Y r R port 1
-flow 2 meter 0 trtcm 1250000000 1250000000 1000000 1000000 policer 0 g G y Y r R meter 1 trtcm 1250000000 1250000000 1000000 1000000 policer 1 g G y Y r R meter 2 trtcm 1250000000 1250000000 1000000 1000000 policer 2 g G y Y r R meter 3 trtcm 1250000000 1250000000 1000000 1000000 policer 3 g G y Y r R port 2
-flow 3 meter 0 trtcm 1250000000 1250000000 1000000 1000000 policer 0 g G y Y r R meter 1 trtcm 1250000000 1250000000 1000000 1000000 policer 1 g G y Y r R meter 2 trtcm 1250000000 1250000000 1000000 1000000 policer 2 g G y Y r R meter 3 trtcm 1250000000 1250000000 1000000 1000000 policer 3 g G y Y r R port 3
examples/ip_pipeline/config/diagram-generator.py deleted +0 -317

317 lines not on this page · raw message

examples/ip_pipeline/config/edge_router_downstream.cfg deleted +0 -97

97 lines not on this page · raw message

examples/ip_pipeline/config/edge_router_downstream.sh deleted +0 -13
deleted file mode 100644
index 67c3a0d..0000000
@@ -1,13 +0,0 @@
-#
-# run ./config/edge_router_downstream.sh
-#
-
-################################################################################
-# Routing: Ether QinQ, ARP off
-################################################################################
-p 1 route add default 4 #SINK0
-p 1 route add 0.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 qinq 256 257
-p 1 route add 0.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 qinq 258 259
-p 1 route add 0.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 qinq 260 261
-p 1 route add 0.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 qinq 262 263
-#p 1 route ls
examples/ip_pipeline/config/edge_router_upstream.cfg deleted +0 -124

124 lines not on this page · raw message

examples/ip_pipeline/config/edge_router_upstream.sh deleted +0 -33
deleted file mode 100644
index 5d574c1..0000000
@@ -1,33 +0,0 @@
-#
-# run ./config/edge_router_upstream.sh
-#
-
-################################################################################
-# Firewall
-################################################################################
-p 1 firewall add default 4 #SINK0
-p 1 firewall add bulk ./config/edge_router_upstream_firewall.txt
-#p 1 firewall ls
-
-################################################################################
-# Flow Classification
-################################################################################
-p 3 flow add default 4 #SINK1
-p 3 flow add qinq bulk ./config/edge_router_upstream_flow.txt
-#p 3 flow ls
-
-################################################################################
-# Flow Actions - Metering and Policing
-################################################################################
-p 4 action flow bulk ./config/edge_router_upstream_action.txt
-#p 4 action flow ls
-
-################################################################################
-# Routing: Ether MPLS, ARP off
-################################################################################
-p 5 route add default 4 #SINK2
-p 5 route add 0.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 mpls 0:1
-p 5 route add 0.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 mpls 10:11
-p 5 route add 0.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 mpls 20:21
-p 5 route add 0.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 mpls 30:31
-#p 5 route ls
examples/ip_pipeline/config/firewall.cfg deleted +0 -68

68 lines not on this page · raw message

examples/ip_pipeline/config/firewall.sh deleted +0 -13
deleted file mode 100644
index c83857e..0000000
@@ -1,13 +0,0 @@
-#
-# run ./config/firewall.sh
-#
-
-p 1 firewall add default 4 #SINK0
-p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.0.0.0 10 0 65535 0 65535 6 0xF port 0
-p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.64.0.0 10 0 65535 0 65535 6 0xF port 1
-p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.128.0.0 10 0 65535 0 65535 6 0xF port 2
-p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.192.0.0 10 0 65535 0 65535 6 0xF port 3
-
-#p 1 firewall add bulk ./config/firewall.txt
-
-p 1 firewall ls
examples/ip_pipeline/config/firewall.txt deleted +0 -9
deleted file mode 100644
index 54cfffd..0000000
@@ -1,9 +0,0 @@
-#
-# p <pipelineid> firewall add bulk ./config/firewall.txt
-# p <pipelineid> firewall del bulk ./config/firewall.txt
-#
-
-priority 1 ipv4 0.0.0.0 0 100.0.0.0 10 0 65535 0 65535 6 0xF port 0
-priority 1 ipv4 0.0.0.0 0 100.64.0.0 10 0 65535 0 65535 6 0xF port 1
-priority 1 ipv4 0.0.0.0 0 100.128.0.0 10 0 65535 0 65535 6 0xF port 2
-priority 1 ipv4 0.0.0.0 0 100.192.0.0 10 0 65535 0 65535 6 0xF port 3
examples/ip_pipeline/config/flow.cfg deleted +0 -72

72 lines not on this page · raw message

examples/ip_pipeline/config/flow.sh deleted +0 -25
deleted file mode 100644
index 489c707..0000000
@@ -1,25 +0,0 @@
-#
-# run ./config/flow.sh
-#
-
-################################################################################
-# Flow classification (QinQ)
-################################################################################
-#p 1 flow add default 4 #SINK0
-#p 1 flow add qinq 100 200 port 0 id 0
-#p 1 flow add qinq 101 201 port 1 id 1
-#p 1 flow add qinq 102 202 port 2 id 2
-#p 1 flow add qinq 103 203 port 3 id 3
-
-#p 1 flow add qinq bulk ./config/flow.txt
-
-################################################################################
-# Flow classification (IPv4 5-tuple)
-################################################################################
-p 1 flow add default 4 #SINK0
-p 1 flow add ipv4 100.0.0.10 200.0.0.10 100 200 6 port 0 id 0
-p 1 flow add ipv4 100.0.0.11 200.0.0.11 101 201 6 port 1 id 1
-p 1 flow add ipv4 100.0.0.12 200.0.0.12 102 202 6 port 2 id 2
-p 1 flow add ipv4 100.0.0.13 200.0.0.13 103 203 6 port 3 id 3
-
-#p 1 flow add ipv4 bulk ./config/flow.txt
examples/ip_pipeline/config/flow.txt deleted +0 -17
deleted file mode 100644
index c1a141d..0000000
@@ -1,17 +0,0 @@
-#
-# p <pipelineid> flow add qinq bulk ./config/flow.txt
-#
-
-#qinq 100 200 port 0 id 0
-#qinq 101 201 port 1 id 1
-#qinq 102 202 port 2 id 2
-#qinq 103 203 port 3 id 3
-
-#
-# p <pipelineid> flow add ipv4 bulk ./config/flow.txt
-#
-
-ipv4 100.0.0.10 200.0.0.10 100 200 6 port 0 id 0
-ipv4 100.0.0.11 200.0.0.11 101 201 6 port 1 id 1
-ipv4 100.0.0.12 200.0.0.12 102 202 6 port 2 id 2
-ipv4 100.0.0.13 200.0.0.13 103 203 6 port 3 id 3
examples/ip_pipeline/config/ip_pipeline.cfg deleted +0 -9
deleted file mode 100644
index 095ed25..0000000
@@ -1,9 +0,0 @@
-[PIPELINE0]
-type = MASTER
-core = 0
-
-[PIPELINE1]
-type = PASS-THROUGH
-core = 1
-pktq_in = RXQ0.0 RXQ1.0 RXQ2.0 RXQ3.0
-pktq_out = TXQ0.0 TXQ1.0 TXQ2.0 TXQ3.0
examples/ip_pipeline/config/ip_pipeline.sh deleted +0 -5
deleted file mode 100644
index 4fca259..0000000
@@ -1,5 +0,0 @@
-#
-#run config/ip_pipeline.sh
-#
-
-p 1 ping
examples/ip_pipeline/config/kni.cfg deleted +0 -67

67 lines not on this page · raw message

examples/ip_pipeline/config/l2fwd.cfg deleted +0 -58

58 lines not on this page · raw message

examples/ip_pipeline/config/l3fwd.cfg deleted +0 -68

68 lines not on this page · raw message

examples/ip_pipeline/config/l3fwd.sh deleted +0 -33
deleted file mode 100644
index 47406aa..0000000
@@ -1,33 +0,0 @@
-#
-# run ./config/l3fwd.sh
-#
-
-################################################################################
-# Routing: encap = ethernet, arp = off
-################################################################################
-p 1 route add default 4 #SINK0
-p 1 route add 100.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0
-p 1 route add 100.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1
-p 1 route add 100.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2
-p 1 route add 100.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3
-p 1 route ls
-
-################################################################################
-# Routing: encap = ethernet_qinq, arp = off
-################################################################################
-#p 1 route add default 4 #SINK0
-#p 1 route add 100.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 qinq 1000 2000
-#p 1 route add 100.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 qinq 1001 2001
-#p 1 route add 100.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 qinq 1002 2002
-#p 1 route add 100.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 qinq 1003 2003
-#p 1 route ls
-
-################################################################################
-# Routing: encap = ethernet_mpls, arp = off
-################################################################################
-#p 1 route add default 4 #SINK0
-#p 1 route add 100.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 mpls 1000:2000
-#p 1 route add 100.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 mpls 1001:2001
-#p 1 route add 100.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 mpls 1002:2002
-#p 1 route add 100.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 mpls 1003:2003
-#p 1 route ls
examples/ip_pipeline/config/l3fwd_arp.cfg deleted +0 -70

70 lines not on this page · raw message

examples/ip_pipeline/config/l3fwd_arp.sh deleted +0 -43

43 lines not on this page · raw message

examples/ip_pipeline/config/network_layers.cfg deleted +0 -227

227 lines not on this page · raw message

examples/ip_pipeline/config/network_layers.sh deleted +0 -79

79 lines not on this page · raw message

examples/ip_pipeline/config/pipeline-to-core-mapping.py deleted +0 -906

906 lines not on this page · raw message

examples/ip_pipeline/config/tap.cfg deleted +0 -64

64 lines not on this page · raw message

examples/ip_pipeline/config/tm_profile.cfg deleted +0 -105

105 lines not on this page · raw message

Signature · 1 line
2.9.3
#117 lore raw

PATCH v2 17/44 ip_pipeline: rework and improvements

In reply to Jasvinder Singh

All the actions associated with application pipelines tables and ports are now implemented using the new action APIs. Therefore, thousands of lines of code are eliminated from the application. The reduced code size is easier to maintain and extend.

---
 examples/ip_pipeline/Makefile          |   22 +-
 examples/ip_pipeline/app.h             | 1389 -------------
 examples/ip_pipeline/config_check.c    |  488 -----
 examples/ip_pipeline/config_parse.c    | 3395 --------------------------------
 examples/ip_pipeline/config_parse_tm.c |  419 ----
 examples/ip_pipeline/cpu_core_map.c    |  471 -----
 examples/ip_pipeline/cpu_core_map.h    |   40 -
 examples/ip_pipeline/init.c            | 1343 -------------
 examples/ip_pipeline/main.c            |   36 +-
 examples/ip_pipeline/meson.build       |   10 +-
 examples/ip_pipeline/parser.c          |   16 +-
 examples/ip_pipeline/parser.h          |    8 +
 examples/ip_pipeline/pipeline.h        |   73 -
 examples/ip_pipeline/pipeline_be.h     |  322 ---
 examples/ip_pipeline/thread.c          |  240 ---
 examples/ip_pipeline/thread.h          |   69 -
 16 files changed, 37 insertions(+), 8304 deletions(-)
 delete mode 100644 examples/ip_pipeline/app.h
 delete mode 100644 examples/ip_pipeline/config_check.c
 delete mode 100644 examples/ip_pipeline/config_parse.c
 delete mode 100644 examples/ip_pipeline/config_parse_tm.c
 delete mode 100644 examples/ip_pipeline/cpu_core_map.c
 delete mode 100644 examples/ip_pipeline/cpu_core_map.h
 delete mode 100644 examples/ip_pipeline/init.c
 delete mode 100644 examples/ip_pipeline/pipeline.h
 delete mode 100644 examples/ip_pipeline/pipeline_be.h
 delete mode 100644 examples/ip_pipeline/thread.c
 delete mode 100644 examples/ip_pipeline/thread.h
examples/ip_pipeline/Makefile +6 -16
index 8ba7887..981c4f7 100644
@@ -1,18 +1,13 @@
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright(c) 2010-2014 Intel Corporation
+# Copyright(c) 2010-2018 Intel Corporation
 
 # binary name
 APP = ip_pipeline
 
 # all source are stored in SRCS-y
 SRCS-y := main.c
-SRCS-y += config_parse.c
 SRCS-y += parser.c
-SRCS-y += config_parse_tm.c
-SRCS-y += config_check.c
-SRCS-y += init.c
-SRCS-y += thread.c
-SRCS-y += cpu_core_map.c
+#SRCS-y += thread.c
 
 # Build using pkg-config variables if possible
 $(shell pkg-config --exists libdpdk)
@@ -30,9 +25,7 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
-VPATH += pipeline
-CFLAGS += -I. -I./pipeline/
-CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -I.
 
 OBJS := $(patsubst %.c,build/%.o,$(SRCS-y))
 
@@ -59,21 +52,18 @@ ifeq ($(RTE_SDK),)
 $(error "Please define RTE_SDK environment variable")
 endif
 
-VPATH += $(SRCDIR)/pipeline
-
 # Default target, can be overridden by command line or environment
 RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
-INC += $(sort $(wildcard *.h)) $(sort $(wildcard pipeline/*.h))
+INC += $(sort $(wildcard *.h))
 
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) := $(SRCS-y)
 
-CFLAGS += -I$(SRCDIR) -I$(SRCDIR)/pipeline
+CFLAGS += -I$(SRCDIR)
 CFLAGS += -O3
-CFLAGS += $(WERROR_FLAGS) -Wno-error=unused-function -Wno-error=unused-variable
-CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += $(WERROR_FLAGS)
 
 include $(RTE_SDK)/mk/rte.extapp.mk
 
examples/ip_pipeline/app.h deleted +0 -1389

1,389 lines not on this page · raw message

examples/ip_pipeline/config_check.c deleted +0 -488

488 lines not on this page · raw message

examples/ip_pipeline/config_parse.c deleted +0 -3395

1,069 lines not on this page · raw message

examples/ip_pipeline/config_parse_tm.c deleted +0 -419

419 lines not on this page · raw message

examples/ip_pipeline/cpu_core_map.c deleted +0 -471

471 lines not on this page · raw message

examples/ip_pipeline/cpu_core_map.h deleted +0 -40
deleted file mode 100644
index 5e50f6e..0000000

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/init.c deleted +0 -1343

1,343 lines not on this page · raw message

examples/ip_pipeline/main.c +13 -23
index a44cf9a..1696e36 100644

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/meson.build +2 -8
index be3f3e5..063865c 100644

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/parser.c +8 -8
index 0901e9c..0ae3d1d 100644

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/parser.h +8 -0
index 5c421d2..261a8c8 100644

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/pipeline.h deleted +0 -73

73 lines not on this page · raw message

examples/ip_pipeline/pipeline_be.h deleted +0 -322

322 lines not on this page · raw message

examples/ip_pipeline/thread.c deleted +0 -240

240 lines not on this page · raw message

examples/ip_pipeline/thread.h deleted +0 -69

69 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.9.3

Part of the diff is not shown here. View the raw message.

#118 lore raw

PATCH v2 18/44 ip_pipeline: add cli interface

In reply to Jasvinder Singh

CLI interface allowing connectivity with external agent(e.g. telnet, netcat, Python script, etc) is added to the application.

---
 examples/ip_pipeline/Makefile    |   4 +-
 examples/ip_pipeline/cli.c       |  85 ++++++++++
 examples/ip_pipeline/cli.h       |  18 +++
 examples/ip_pipeline/conn.c      | 326 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/conn.h      |  47 ++++++
 examples/ip_pipeline/main.c      | 151 +++++++++++++++++-
 examples/ip_pipeline/meson.build |   2 +
 7 files changed, 631 insertions(+), 2 deletions(-)
 create mode 100644 examples/ip_pipeline/cli.c
 create mode 100644 examples/ip_pipeline/cli.h
 create mode 100644 examples/ip_pipeline/conn.c
 create mode 100644 examples/ip_pipeline/conn.h
examples/ip_pipeline/Makefile +3 -1
index 981c4f7..0c5b6b1 100644
@@ -5,7 +5,9 @@
 APP = ip_pipeline
 
 # all source are stored in SRCS-y
-SRCS-y := main.c
+SRCS-y := cli.c
+SRCS-y += conn.c
+SRCS-y += main.c
 SRCS-y += parser.c
 #SRCS-y += thread.c
 
examples/ip_pipeline/cli.c new file +85 -0

85 lines not on this page · raw message

examples/ip_pipeline/cli.h new file +18 -0
new file mode 100644
index 0000000..992e4c3
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef __INCLUDE_CLI_H__
+#define __INCLUDE_CLI_H__
+
+#include <stddef.h>
+
+void
+cli_process(char *in, char *out, size_t out_size);
+
+int
+cli_script_process(const char *file_name,
+	size_t msg_in_len_max,
+	size_t msg_out_len_max);
+
+#endif
examples/ip_pipeline/conn.c new file +326 -0

326 lines not on this page · raw message

examples/ip_pipeline/conn.h new file +47 -0

47 lines not on this page · raw message

examples/ip_pipeline/main.c +150 -1

170 lines not on this page · raw message

examples/ip_pipeline/meson.build +2 -0
index 063865c..a89cb30 100644
@@ -8,6 +8,8 @@
 
 deps += ['pipeline', 'bus_pci']
 sources = files(
+	'cli.c',
+	'conn.c',
 	'main.c',
 	'parser.c',
 )
Signature · 1 line
2.9.3
#119 lore raw

PATCH v2 19/44 ip_pipeline: add mempool object for pipeline

In reply to Jasvinder Singh

Add mempool object implementation to the application.

---
 examples/ip_pipeline/Makefile    |   1 +
 examples/ip_pipeline/cli.c       | 109 ++++++++++++++++++++++++++++++++++++++-
 examples/ip_pipeline/common.h    |  12 +++++
 examples/ip_pipeline/main.c      |   8 +++
 examples/ip_pipeline/mempool.c   |  81 +++++++++++++++++++++++++++++
 examples/ip_pipeline/mempool.h   |  40 ++++++++++++++
 examples/ip_pipeline/meson.build |   1 +
 7 files changed, 251 insertions(+), 1 deletion(-)
 create mode 100644 examples/ip_pipeline/common.h
 create mode 100644 examples/ip_pipeline/mempool.c
 create mode 100644 examples/ip_pipeline/mempool.h
examples/ip_pipeline/Makefile +1 -0
index 0c5b6b1..fca28c5 100644
@@ -8,6 +8,7 @@ APP = ip_pipeline
 SRCS-y := cli.c
 SRCS-y += conn.c
 SRCS-y += main.c
+SRCS-y += mempool.c
 SRCS-y += parser.c
 #SRCS-y += thread.c
 
examples/ip_pipeline/cli.c +108 -1

126 lines not on this page · raw message

examples/ip_pipeline/common.h new file +12 -0
new file mode 100644
index 0000000..0886dfb
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _INCLUDE_COMMON_H_
+#define _INCLUDE_COMMON_H_
+
+#ifndef NAME_SIZE
+#define NAME_SIZE                                            64
+#endif
+
+#endif /* _INCLUDE_COMMON_H_ */
examples/ip_pipeline/main.c +8 -0
index 60936f4..b53f623 100644
@@ -12,6 +12,7 @@
 
 #include "cli.h"
 #include "conn.h"
+#include "mempool.h"
 
 static const char usage[] =
 	"%s EAL_ARGS -- [-h HOST] [-p PORT] [-s SCRIPT]\n";
@@ -159,6 +160,13 @@ main(int argc, char **argv)
 		return status;
 	};
 
+	/* Mempool */
+	status = mempool_init();
+	if (status) {
+		printf("Error: Mempool initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/mempool.c new file +81 -0

81 lines not on this page · raw message

examples/ip_pipeline/mempool.h new file +40 -0
new file mode 100644
index 0000000..bd46a11
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _INCLUDE_MEMPOOL_H_
+#define _INCLUDE_MEMPOOL_H_
+
+#include <stdint.h>
+#include <sys/queue.h>
+
+#include <rte_mempool.h>
+
+#include "common.h"
+
+struct mempool {
+	TAILQ_ENTRY(mempool) node;
+	char name[NAME_SIZE];
+	struct rte_mempool *m;
+	uint32_t buffer_size;
+};
+
+TAILQ_HEAD(mempool_list, mempool);
+
+int
+mempool_init(void);
+
+struct mempool *
+mempool_find(const char *name);
+
+struct mempool_params {
+	uint32_t buffer_size;
+	uint32_t pool_size;
+	uint32_t cache_size;
+	uint32_t cpu_id;
+};
+
+struct mempool *
+mempool_create(const char *name, struct mempool_params *params);
+
+#endif /* _INCLUDE_MEMPOOL_H_ */
examples/ip_pipeline/meson.build +1 -0
index a89cb30..f8a450f 100644
@@ -11,5 +11,6 @@ sources = files(
 	'cli.c',
 	'conn.c',
 	'main.c',
+	'mempool.c',
 	'parser.c',
 )
Signature · 1 line
2.9.3
#120 lore raw

PATCH v2 20/44 ip_pipeline: add link object

In reply to Jasvinder Singh

Add link object implementation to the application.

---
 examples/ip_pipeline/Makefile    |   1 +
 examples/ip_pipeline/cli.c       | 122 ++++++++++++++++++
 examples/ip_pipeline/link.c      | 268 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/link.h      |  63 +++++++++
 examples/ip_pipeline/main.c      |   8 ++
 examples/ip_pipeline/meson.build |   1 +
 6 files changed, 463 insertions(+)
 create mode 100644 examples/ip_pipeline/link.c
 create mode 100644 examples/ip_pipeline/link.h
examples/ip_pipeline/Makefile +1 -0
index fca28c5..3dab932 100644
@@ -7,6 +7,7 @@ APP = ip_pipeline
 # all source are stored in SRCS-y
 SRCS-y := cli.c
 SRCS-y += conn.c
+SRCS-y += link.c
 SRCS-y += main.c
 SRCS-y += mempool.c
 SRCS-y += parser.c
examples/ip_pipeline/cli.c +122 -0

140 lines not on this page · raw message

examples/ip_pipeline/link.c new file +268 -0

268 lines not on this page · raw message

examples/ip_pipeline/link.h new file +63 -0

63 lines not on this page · raw message

examples/ip_pipeline/main.c +8 -0
index b53f623..edfb523 100644
@@ -12,6 +12,7 @@
 
 #include "cli.h"
 #include "conn.h"
+#include "link.h"
 #include "mempool.h"
 
 static const char usage[] =
@@ -167,6 +168,13 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* Link */
+	status = link_init();
+	if (status) {
+		printf("Error: Link initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/meson.build +1 -0
index f8a450f..a2f9bb6 100644
@@ -10,6 +10,7 @@ deps += ['pipeline', 'bus_pci']
 sources = files(
 	'cli.c',
 	'conn.c',
+	'link.c',
 	'main.c',
 	'mempool.c',
 	'parser.c',
Signature · 1 line
2.9.3
#121 lore raw

PATCH v2 21/44 ip_pipeline: add software queue object

In reply to Jasvinder Singh

Add swq object implementation to the application.

---
 examples/ip_pipeline/Makefile    |  1 +
 examples/ip_pipeline/cli.c       | 55 +++++++++++++++++++++++++++++
 examples/ip_pipeline/main.c      |  8 +++++
 examples/ip_pipeline/meson.build |  1 +
 examples/ip_pipeline/swq.c       | 74 ++++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/swq.h       | 37 ++++++++++++++++++++
 6 files changed, 176 insertions(+)
 create mode 100644 examples/ip_pipeline/swq.c
 create mode 100644 examples/ip_pipeline/swq.h
examples/ip_pipeline/Makefile +1 -0
index 3dab932..0dc8442 100644
@@ -11,6 +11,7 @@ SRCS-y += link.c
 SRCS-y += main.c
 SRCS-y += mempool.c
 SRCS-y += parser.c
+SRCS-y += swq.c
 #SRCS-y += thread.c
 
 # Build using pkg-config variables if possible
examples/ip_pipeline/cli.c +55 -0

73 lines not on this page · raw message

examples/ip_pipeline/main.c +8 -0
index edfb523..456f016 100644
@@ -14,6 +14,7 @@
 #include "conn.h"
 #include "link.h"
 #include "mempool.h"
+#include "swq.h"
 
 static const char usage[] =
 	"%s EAL_ARGS -- [-h HOST] [-p PORT] [-s SCRIPT]\n";
@@ -175,6 +176,13 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* SWQ */
+	status = swq_init();
+	if (status) {
+		printf("Error: SWQ initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/meson.build +1 -0
index a2f9bb6..442f3e3 100644
@@ -14,4 +14,5 @@ sources = files(
 	'main.c',
 	'mempool.c',
 	'parser.c',
+	'swq.c',
 )
examples/ip_pipeline/swq.c new file +74 -0

74 lines not on this page · raw message

examples/ip_pipeline/swq.h new file +37 -0
new file mode 100644
index 0000000..c8440ee
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _INCLUDE_SWQ_H_
+#define _INCLUDE_SWQ_H_
+
+#include <stdint.h>
+#include <sys/queue.h>
+
+#include <rte_ring.h>
+
+#include "common.h"
+
+struct swq {
+	TAILQ_ENTRY(swq) node;
+	char name[NAME_SIZE];
+	struct rte_ring *r;
+};
+
+TAILQ_HEAD(swq_list, swq);
+
+int
+swq_init(void);
+
+struct swq *
+swq_find(const char *name);
+
+struct swq_params {
+	uint32_t size;
+	uint32_t cpu_id;
+};
+
+struct swq *
+swq_create(const char *name, struct swq_params *params);
+
+#endif /* _INCLUDE_SWQ_H_ */
Signature · 1 line
2.9.3
#122 lore raw

PATCH v2 22/44 ip_pipeline: add traffic manager object

In reply to Jasvinder Singh

Add traffic manager object implementation to the application.

---
 examples/ip_pipeline/Makefile    |   1 +
 examples/ip_pipeline/cli.c       | 360 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/main.c      |   8 +
 examples/ip_pipeline/meson.build |   1 +
 examples/ip_pipeline/tmgr.c      | 227 ++++++++++++++++++++++++
 examples/ip_pipeline/tmgr.h      |  70 ++++++++
 6 files changed, 667 insertions(+)
 create mode 100644 examples/ip_pipeline/tmgr.c
 create mode 100644 examples/ip_pipeline/tmgr.h
examples/ip_pipeline/Makefile +1 -0
index 0dc8442..35e4302 100644
@@ -12,6 +12,7 @@ SRCS-y += main.c
 SRCS-y += mempool.c
 SRCS-y += parser.c
 SRCS-y += swq.c
+SRCS-y += tmgr.c
 #SRCS-y += thread.c
 
 # Build using pkg-config variables if possible
examples/ip_pipeline/cli.c +360 -0

378 lines not on this page · raw message

examples/ip_pipeline/main.c +8 -0
index 456f016..490991f 100644
@@ -15,6 +15,7 @@
 #include "link.h"
 #include "mempool.h"
 #include "swq.h"
+#include "tmgr.h"
 
 static const char usage[] =
 	"%s EAL_ARGS -- [-h HOST] [-p PORT] [-s SCRIPT]\n";
@@ -183,6 +184,13 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* Traffic Manager */
+	status = tmgr_init();
+	if (status) {
+		printf("Error: TMGR initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/meson.build +1 -0
index 442f3e3..cb2154c 100644
@@ -15,4 +15,5 @@ sources = files(
 	'mempool.c',
 	'parser.c',
 	'swq.c',
+	'tmgr.c'
 )
examples/ip_pipeline/tmgr.c new file +227 -0

227 lines not on this page · raw message

examples/ip_pipeline/tmgr.h new file +70 -0

70 lines not on this page · raw message

Signature · 1 line
2.9.3
#123 lore raw

PATCH v2 23/44 ip_pipeline: add tap object

In reply to Jasvinder Singh

Add tap object implementation to the application

---
 examples/ip_pipeline/Makefile    |  1 +
 examples/ip_pipeline/cli.c       | 32 +++++++++++++
 examples/ip_pipeline/main.c      |  8 ++++
 examples/ip_pipeline/meson.build |  1 +
 examples/ip_pipeline/tap.c       | 97 ++++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/tap.h       | 29 ++++++++++++
 6 files changed, 168 insertions(+)
 create mode 100644 examples/ip_pipeline/tap.c
 create mode 100644 examples/ip_pipeline/tap.h
examples/ip_pipeline/Makefile +1 -0
index 35e4302..0f6bb78 100644
@@ -12,6 +12,7 @@ SRCS-y += main.c
 SRCS-y += mempool.c
 SRCS-y += parser.c
 SRCS-y += swq.c
+SRCS-y += tap.c
 SRCS-y += tmgr.c
 #SRCS-y += thread.c
 
examples/ip_pipeline/cli.c +32 -0
index c6111e7..b6c5269 100644
@@ -14,6 +14,7 @@
 #include "mempool.h"
 #include "parser.h"
 #include "swq.h"
+#include "tap.h"
 #include "tmgr.h"
 
 #ifndef CMD_MAX_TOKENS
@@ -603,6 +604,32 @@ cmd_tmgr_subport_pipe(char **tokens,
 	}
 }
 
+/**
+ * tap <tap_name>
+ */
+static void
+cmd_tap(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	char *name;
+	struct tap *tap;
+
+	if (n_tokens != 2) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	name = tokens[1];
+
+	tap = tap_create(name);
+	if (tap == NULL) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
 void
 cli_process(char *in, char *out, size_t out_size)
 {
@@ -671,6 +698,11 @@ cli_process(char *in, char *out, size_t out_size)
 		return;
 	}
 
+	if (strcmp(tokens[0], "tap") == 0) {
+		cmd_tap(tokens, n_tokens, out, out_size);
+		return;
+	}
+
 	snprintf(out, out_size, MSG_CMD_UNKNOWN, tokens[0]);
 }
 
examples/ip_pipeline/main.c +8 -0
index 490991f..33c3354 100644
@@ -15,6 +15,7 @@
 #include "link.h"
 #include "mempool.h"
 #include "swq.h"
+#include "tap.h"
 #include "tmgr.h"
 
 static const char usage[] =
@@ -191,6 +192,13 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* TAP */
+	status = tap_init();
+	if (status) {
+		printf("Error: TAP initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/meson.build +1 -0
index cb2154c..e875811 100644
@@ -15,5 +15,6 @@ sources = files(
 	'mempool.c',
 	'parser.c',
 	'swq.c',
+	'tap.c',
 	'tmgr.c'
 )
examples/ip_pipeline/tap.c new file +97 -0

97 lines not on this page · raw message

examples/ip_pipeline/tap.h new file +29 -0
new file mode 100644
index 0000000..0dce72f
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _INCLUDE_TAP_H_
+#define _INCLUDE_TAP_H_
+
+#include <sys/queue.h>
+
+#include "common.h"
+
+struct tap {
+	TAILQ_ENTRY(tap) node;
+	char name[NAME_SIZE];
+	int fd;
+};
+
+TAILQ_HEAD(tap_list, tap);
+
+int
+tap_init(void);
+
+struct tap *
+tap_find(const char *name);
+
+struct tap *
+tap_create(const char *name);
+
+#endif /* _INCLUDE_TAP_H_ */
Signature · 1 line
2.9.3
#124 lore raw

PATCH v2 24/44 ip_pipeline: add kni object

In reply to Jasvinder Singh

Add kni object implementation to the application.

---
 examples/ip_pipeline/Makefile    |   1 +
 examples/ip_pipeline/cli.c       |  65 +++++++++++++++
 examples/ip_pipeline/kni.c       | 167 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/kni.h       |  44 +++++++++++
 examples/ip_pipeline/main.c      |  10 +++
 examples/ip_pipeline/meson.build |   1 +
 6 files changed, 288 insertions(+)
 create mode 100644 examples/ip_pipeline/kni.c
 create mode 100644 examples/ip_pipeline/kni.h
examples/ip_pipeline/Makefile +1 -0
index 0f6bb78..dc56ebf 100644
@@ -7,6 +7,7 @@ APP = ip_pipeline
 # all source are stored in SRCS-y
 SRCS-y := cli.c
 SRCS-y += conn.c
+SRCS-y += kni.c
 SRCS-y += link.c
 SRCS-y += main.c
 SRCS-y += mempool.c
examples/ip_pipeline/cli.c +65 -0

83 lines not on this page · raw message

examples/ip_pipeline/kni.c new file +167 -0

167 lines not on this page · raw message

examples/ip_pipeline/kni.h new file +44 -0

44 lines not on this page · raw message

examples/ip_pipeline/main.c +10 -0
index 33c3354..b65762e 100644
@@ -12,6 +12,7 @@
 
 #include "cli.h"
 #include "conn.h"
+#include "kni.h"
 #include "link.h"
 #include "mempool.h"
 #include "swq.h"
@@ -199,6 +200,13 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* KNI */
+	status = kni_init();
+	if (status) {
+		printf("Error: KNI initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
@@ -210,5 +218,7 @@ main(int argc, char **argv)
 		conn_poll_for_conn(conn);
 
 		conn_poll_for_msg(conn);
+
+		kni_handle_request();
 	}
 }
examples/ip_pipeline/meson.build +1 -0
index e875811..5ad79b2 100644
@@ -10,6 +10,7 @@ deps += ['pipeline', 'bus_pci']
 sources = files(
 	'cli.c',
 	'conn.c',
+	'kni.c',
 	'link.c',
 	'main.c',
 	'mempool.c',
Signature · 1 line
2.9.3
#125 lore raw

PATCH v2 25/44 ip_pipeline: add action profile object

In reply to Jasvinder Singh

Add action profile object implementation to the application.

---
 examples/ip_pipeline/Makefile    |   4 +-
 examples/ip_pipeline/action.c    | 165 +++++++++++++++++++++
 examples/ip_pipeline/action.h    |  44 ++++++
 examples/ip_pipeline/cli.c       | 309 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/cli.h       |   2 +
 examples/ip_pipeline/main.c      |   8 +
 examples/ip_pipeline/meson.build |   2 +
 7 files changed, 533 insertions(+), 1 deletion(-)
 create mode 100644 examples/ip_pipeline/action.c
 create mode 100644 examples/ip_pipeline/action.h
examples/ip_pipeline/Makefile +3 -1
index dc56ebf..d9c8d86 100644
@@ -5,7 +5,8 @@
 APP = ip_pipeline
 
 # all source are stored in SRCS-y
-SRCS-y := cli.c
+SRCS-y := action.c
+SRCS-y += cli.c
 SRCS-y += conn.c
 SRCS-y += kni.c
 SRCS-y += link.c
@@ -69,6 +70,7 @@ INC += $(sort $(wildcard *.h))
 
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) := $(SRCS-y)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -I$(SRCDIR)
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
examples/ip_pipeline/action.c new file +165 -0

165 lines not on this page · raw message

examples/ip_pipeline/action.h new file +44 -0

44 lines not on this page · raw message

examples/ip_pipeline/cli.c +309 -0

321 lines not on this page · raw message

examples/ip_pipeline/cli.h +2 -0
index 992e4c3..02564a6 100644
@@ -7,6 +7,8 @@
 
 #include <stddef.h>
 
+#include "action.h"
+
 void
 cli_process(char *in, char *out, size_t out_size);
 
examples/ip_pipeline/main.c +8 -0
index b65762e..24b74cf 100644
@@ -207,6 +207,14 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* Action profile */
+	status = table_action_profile_init();
+	if (status) {
+		printf("Error: Action profile initialization failed (%d)\n",
+			status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/meson.build +2 -0
index 5ad79b2..fb1b61d 100644
@@ -7,7 +7,9 @@
 # DPDK instance, use 'make'
 
 deps += ['pipeline', 'bus_pci']
+allow_experimental_apis = true
 sources = files(
+	'action.c',
 	'cli.c',
 	'conn.c',
 	'kni.c',
Signature · 1 line
2.9.3
#126 lore raw

PATCH v2 26/44 ip_pipeline: add pipeline object

In reply to Jasvinder Singh

Add pipeline object implementation to the application.

---
 examples/ip_pipeline/Makefile    |   1 +
 examples/ip_pipeline/cli.c       | 786 +++++++++++++++++++++++++++++++++
 examples/ip_pipeline/cli.h       |   2 -
 examples/ip_pipeline/main.c      |   8 +
 examples/ip_pipeline/meson.build |   1 +
 examples/ip_pipeline/pipeline.c  | 930 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h  | 265 +++++++++++
 7 files changed, 1991 insertions(+), 2 deletions(-)
 create mode 100644 examples/ip_pipeline/pipeline.c
 create mode 100644 examples/ip_pipeline/pipeline.h
examples/ip_pipeline/Makefile +1 -0
index d9c8d86..033319d 100644
@@ -13,6 +13,7 @@ SRCS-y += link.c
 SRCS-y += main.c
 SRCS-y += mempool.c
 SRCS-y += parser.c
+SRCS-y += pipeline.c
 SRCS-y += swq.c
 SRCS-y += tap.c
 SRCS-y += tmgr.c
examples/ip_pipeline/cli.c +786 -0

804 lines not on this page · raw message

examples/ip_pipeline/cli.h +0 -2
index 02564a6..992e4c3 100644
@@ -7,8 +7,6 @@
 
 #include <stddef.h>
 
-#include "action.h"
-
 void
 cli_process(char *in, char *out, size_t out_size);
 
examples/ip_pipeline/main.c +8 -0
index 24b74cf..a7f4486 100644
@@ -15,6 +15,7 @@
 #include "kni.h"
 #include "link.h"
 #include "mempool.h"
+#include "pipeline.h"
 #include "swq.h"
 #include "tap.h"
 #include "tmgr.h"
@@ -215,6 +216,13 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* Pipeline */
+	status = pipeline_init();
+	if (status) {
+		printf("Error: Pipeline initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/meson.build +1 -0
index fb1b61d..2366242 100644
@@ -17,6 +17,7 @@ sources = files(
 	'main.c',
 	'mempool.c',
 	'parser.c',
+	'pipeline.c',
 	'swq.c',
 	'tap.c',
 	'tmgr.c'
examples/ip_pipeline/pipeline.c new file +930 -0

930 lines not on this page · raw message

examples/ip_pipeline/pipeline.h new file +265 -0

265 lines not on this page · raw message

Signature · 1 line
2.9.3
#127 lore raw

PATCH v2 27/44 ip_pipeline: add threads

In reply to Jasvinder Singh

Add threads data structure and initialisation functions to run the pipeline.

---
 examples/ip_pipeline/Makefile    |   2 +-
 examples/ip_pipeline/main.c      |   8 ++
 examples/ip_pipeline/meson.build |   1 +
 examples/ip_pipeline/thread.c    | 159 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/thread.h    |  13 ++++
 5 files changed, 182 insertions(+), 1 deletion(-)
 create mode 100644 examples/ip_pipeline/thread.c
 create mode 100644 examples/ip_pipeline/thread.h
examples/ip_pipeline/Makefile +1 -1
index 033319d..c936d1e 100644
@@ -16,8 +16,8 @@ SRCS-y += parser.c
 SRCS-y += pipeline.c
 SRCS-y += swq.c
 SRCS-y += tap.c
+SRCS-y += thread.c
 SRCS-y += tmgr.c
-#SRCS-y += thread.c
 
 # Build using pkg-config variables if possible
 $(shell pkg-config --exists libdpdk)
examples/ip_pipeline/main.c +8 -0
index a7f4486..d139290 100644
@@ -18,6 +18,7 @@
 #include "pipeline.h"
 #include "swq.h"
 #include "tap.h"
+#include "thread.h"
 #include "tmgr.h"
 
 static const char usage[] =
@@ -223,6 +224,13 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* Thread */
+	status = thread_init();
+	if (status) {
+		printf("Error: Thread initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/meson.build +1 -0
index 2366242..a9f2ea4 100644
@@ -20,5 +20,6 @@ sources = files(
 	'pipeline.c',
 	'swq.c',
 	'tap.c',
+	'thread.c',
 	'tmgr.c'
 )
examples/ip_pipeline/thread.c new file +159 -0

159 lines not on this page · raw message

examples/ip_pipeline/thread.h new file +13 -0
new file mode 100644
index 0000000..39c0d89
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _INCLUDE_THREAD_H_
+#define _INCLUDE_THREAD_H_
+
+#include <stdint.h>
+
+int
+thread_init(void);
+
+#endif /* _INCLUDE_THREAD_H_ */
Signature · 1 line
2.9.3
#128 lore raw

PATCH v2 28/44 ip_pipeline: add thread runtime

In reply to Jasvinder Singh

Add runtime thread functions for the pipeline.

---
 examples/ip_pipeline/main.c   |   6 ++
 examples/ip_pipeline/thread.c | 193 ++++++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/thread.h |   3 +
 3 files changed, 202 insertions(+)
examples/ip_pipeline/main.c +6 -0
index d139290..36da679 100644
@@ -8,6 +8,7 @@
 #include <unistd.h>
 #include <getopt.h>
 
+#include <rte_launch.h>
 #include <rte_eal.h>
 
 #include "cli.h"
@@ -231,6 +232,11 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	rte_eal_mp_remote_launch(
+		thread_main,
+		NULL,
+		SKIP_MASTER);
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/thread.c +193 -0

196 lines not on this page · raw message

examples/ip_pipeline/thread.h +3 -0
index 39c0d89..47db428 100644
@@ -10,4 +10,7 @@
 int
 thread_init(void);
 
+int
+thread_main(void *arg);
+
 #endif /* _INCLUDE_THREAD_H_ */
Signature · 1 line
2.9.3
#129 lore raw

PATCH v2 29/44 ip_pipeline: add cli to enable and disable pipeline

In reply to Jasvinder Singh

Add commands to enable and disable the pipeline on the thread.

---
 examples/ip_pipeline/cli.c    | 102 +++++++++++++++++
 examples/ip_pipeline/thread.c | 260 +++++++++++++++++++++++++++++++++++++++++-
 examples/ip_pipeline/thread.h |   8 ++
 3 files changed, 369 insertions(+), 1 deletion(-)
examples/ip_pipeline/cli.c +102 -0
index acf4fe0..c149f2c 100644
@@ -17,6 +17,7 @@
 #include "pipeline.h"
 #include "swq.h"
 #include "tap.h"
+#include "thread.h"
 #include "tmgr.h"
 
 #ifndef CMD_MAX_TOKENS
@@ -1740,6 +1741,91 @@ cmd_pipeline_port_in_table(char **tokens,
 	}
 }
 
+/**
+ * thread <thread_id> pipeline <pipeline_name> enable
+ */
+static void
+cmd_thread_pipeline_enable(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	char *pipeline_name;
+	uint32_t thread_id;
+	int status;
+
+	if (n_tokens != 5) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	if (parser_read_uint32(&thread_id, tokens[1]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
+		return;
+	}
+
+	if (strcmp(tokens[2], "pipeline") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
+		return;
+	}
+
+	pipeline_name = tokens[3];
+
+	if (strcmp(tokens[4], "enable") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "enable");
+		return;
+	}
+
+	status = thread_pipeline_enable(thread_id, pipeline_name);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, "thread pipeline enable");
+		return;
+	}
+}
+
+/**
+ * thread <thread_id> pipeline <pipeline_name> disable
+ */
+static void
+cmd_thread_pipeline_disable(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	char *pipeline_name;
+	uint32_t thread_id;
+	int status;
+
+	if (n_tokens != 5) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	if (parser_read_uint32(&thread_id, tokens[1]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
+		return;
+	}
+
+	if (strcmp(tokens[2], "pipeline") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pipeline");
+		return;
+	}
+
+	pipeline_name = tokens[3];
+
+	if (strcmp(tokens[4], "disable") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "disable");
+		return;
+	}
+
+	status = thread_pipeline_disable(thread_id, pipeline_name);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL,
+			"thread pipeline disable");
+		return;
+	}
+}
+
 void
 cli_process(char *in, char *out, size_t out_size)
 {
@@ -1863,6 +1949,22 @@ cli_process(char *in, char *out, size_t out_size)
 		}
 	}
 
+	if (strcmp(tokens[0], "thread") == 0) {
+		if ((n_tokens >= 5) &&
+			(strcmp(tokens[4], "enable") == 0)) {
+			cmd_thread_pipeline_enable(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
+
+		if ((n_tokens >= 5) &&
+			(strcmp(tokens[4], "disable") == 0)) {
+			cmd_thread_pipeline_disable(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
+	}
+
 	snprintf(out, out_size, MSG_CMD_UNKNOWN, tokens[0]);
 }
 
examples/ip_pipeline/thread.c +259 -1

295 lines not on this page · raw message

examples/ip_pipeline/thread.h +8 -0
index 47db428..facdf00 100644
@@ -8,6 +8,14 @@
 #include <stdint.h>
 
 int
+thread_pipeline_enable(uint32_t thread_id,
+	const char *pipeline_name);
+
+int
+thread_pipeline_disable(uint32_t thread_id,
+	const char *pipeline_name);
+
+int
 thread_init(void);
 
 int
Signature · 1 line
2.9.3
#130 lore raw

PATCH v2 30/44 ip_pipeline: add cli to enable and disable pipeline port

In reply to Jasvinder Singh

Add commands to enable and disable the pipeline ports.

---
 examples/ip_pipeline/cli.c      | 112 +++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h |   8 ++
 examples/ip_pipeline/thread.c   | 163 +++++++++++++++++++++++++++++++++++++++-
 3 files changed, 282 insertions(+), 1 deletion(-)
examples/ip_pipeline/cli.c +112 -0
index c149f2c..84fcd9d 100644
@@ -1742,6 +1742,100 @@ cmd_pipeline_port_in_table(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> port in <port_id> enable
+ */
+static void
+cmd_pipeline_port_in_enable(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	char *pipeline_name;
+	uint32_t port_id;
+	int status;
+
+	if (n_tokens != 6) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "port") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (strcmp(tokens[3], "in") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
+		return;
+	}
+
+	if (parser_read_uint32(&port_id, tokens[4]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
+		return;
+	}
+
+	if (strcmp(tokens[5], "enable") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "enable");
+		return;
+	}
+
+	status = pipeline_port_in_enable(pipeline_name, port_id);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
+ * pipeline <pipeline_name> port in <port_id> disable
+ */
+static void
+cmd_pipeline_port_in_disable(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	char *pipeline_name;
+	uint32_t port_id;
+	int status;
+
+	if (n_tokens != 6) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "port") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (strcmp(tokens[3], "in") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
+		return;
+	}
+
+	if (parser_read_uint32(&port_id, tokens[4]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
+		return;
+	}
+
+	if (strcmp(tokens[5], "disable") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "disable");
+		return;
+	}
+
+	status = pipeline_port_in_disable(pipeline_name, port_id);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -1947,6 +2041,24 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 6) &&
+			(strcmp(tokens[2], "port") == 0) &&
+			(strcmp(tokens[3], "in") == 0) &&
+			(strcmp(tokens[5], "enable") == 0)) {
+			cmd_pipeline_port_in_enable(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
+
+		if ((n_tokens >= 6) &&
+			(strcmp(tokens[2], "port") == 0) &&
+			(strcmp(tokens[3], "in") == 0) &&
+			(strcmp(tokens[5], "disable") == 0)) {
+			cmd_pipeline_port_in_disable(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +8 -0
index dbc6f77..9b79b67 100644
@@ -262,4 +262,12 @@ struct table_rule_action {
 	struct rte_table_action_time_params time;
 };
 
+int
+pipeline_port_in_enable(const char *pipeline_name,
+	uint32_t port_id);
+
+int
+pipeline_port_in_disable(const char *pipeline_name,
+	uint32_t port_id);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +162 -1

193 lines not on this page · raw message

Signature · 1 line
2.9.3
#131 lore raw

PATCH v2 31/44 ip_pipeline: add cli to read pipeline port and table stats

In reply to Jasvinder Singh

Add commands to read the pipeline port in, port out and table stats.

---
 examples/ip_pipeline/cli.c      | 256 ++++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h |  18 +++
 examples/ip_pipeline/thread.c   | 246 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 520 insertions(+)
examples/ip_pipeline/cli.c +256 -0
index 84fcd9d..a5329cd 100644
@@ -1742,6 +1742,83 @@ cmd_pipeline_port_in_table(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> port in <port_id> stats read [clear]
+ */
+
+#define MSG_PIPELINE_PORT_IN_STATS                         \
+	"Pkts in: %" PRIu64 "\n"                           \
+	"Pkts dropped by AH: %" PRIu64 "\n"                \
+	"Pkts dropped by other: %" PRIu64 "\n"
+
+static void
+cmd_pipeline_port_in_stats(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct rte_pipeline_port_in_stats stats;
+	char *pipeline_name;
+	uint32_t port_id;
+	int clear, status;
+
+	if ((n_tokens != 7) && (n_tokens != 8)) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "port") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (strcmp(tokens[3], "in") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "in");
+		return;
+	}
+
+	if (parser_read_uint32(&port_id, tokens[4]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
+		return;
+	}
+
+	if (strcmp(tokens[5], "stats") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
+		return;
+	}
+
+	if (strcmp(tokens[6], "read") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
+		return;
+	}
+
+	clear = 0;
+	if (n_tokens == 8) {
+		if (strcmp(tokens[7], "clear") != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "clear");
+			return;
+		}
+
+		clear = 1;
+	}
+
+	status = pipeline_port_in_stats_read(pipeline_name,
+		port_id,
+		&stats,
+		clear);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+
+	snprintf(out, out_size, MSG_PIPELINE_PORT_IN_STATS,
+		stats.stats.n_pkts_in,
+		stats.n_pkts_dropped_by_ah,
+		stats.stats.n_pkts_drop);
+}
+
+/**
  * pipeline <pipeline_name> port in <port_id> enable
  */
 static void
@@ -1836,6 +1913,159 @@ cmd_pipeline_port_in_disable(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> port out <port_id> stats read [clear]
+ */
+#define MSG_PIPELINE_PORT_OUT_STATS                        \
+	"Pkts in: %" PRIu64 "\n"                           \
+	"Pkts dropped by AH: %" PRIu64 "\n"                \
+	"Pkts dropped by other: %" PRIu64 "\n"
+
+static void
+cmd_pipeline_port_out_stats(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct rte_pipeline_port_out_stats stats;
+	char *pipeline_name;
+	uint32_t port_id;
+	int clear, status;
+
+	if ((n_tokens != 7) && (n_tokens != 8)) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "port") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (strcmp(tokens[3], "out") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "out");
+		return;
+	}
+
+	if (parser_read_uint32(&port_id, tokens[4]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
+		return;
+	}
+
+	if (strcmp(tokens[5], "stats") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
+		return;
+	}
+
+	if (strcmp(tokens[6], "read") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
+		return;
+	}
+
+	clear = 0;
+	if (n_tokens == 8) {
+		if (strcmp(tokens[7], "clear") != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "clear");
+			return;
+		}
+
+		clear = 1;
+	}
+
+	status = pipeline_port_out_stats_read(pipeline_name,
+		port_id,
+		&stats,
+		clear);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+
+	snprintf(out, out_size, MSG_PIPELINE_PORT_OUT_STATS,
+		stats.stats.n_pkts_in,
+		stats.n_pkts_dropped_by_ah,
+		stats.stats.n_pkts_drop);
+}
+
+/**
+ * pipeline <pipeline_name> table <table_id> stats read [clear]
+ */
+#define MSG_PIPELINE_TABLE_STATS                                     \
+	"Pkts in: %" PRIu64 "\n"                                     \
+	"Pkts in with lookup miss: %" PRIu64 "\n"                    \
+	"Pkts in with lookup hit dropped by AH: %" PRIu64 "\n"       \
+	"Pkts in with lookup hit dropped by others: %" PRIu64 "\n"   \
+	"Pkts in with lookup miss dropped by AH: %" PRIu64 "\n"      \
+	"Pkts in with lookup miss dropped by others: %" PRIu64 "\n"
+
+static void
+cmd_pipeline_table_stats(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct rte_pipeline_table_stats stats;
+	char *pipeline_name;
+	uint32_t table_id;
+	int clear, status;
+
+	if ((n_tokens != 6) && (n_tokens != 7)) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "stats") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "stats");
+		return;
+	}
+
+	if (strcmp(tokens[5], "read") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "read");
+		return;
+	}
+
+	clear = 0;
+	if (n_tokens == 7) {
+		if (strcmp(tokens[6], "clear") != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "clear");
+			return;
+		}
+
+		clear = 1;
+	}
+
+	status = pipeline_table_stats_read(pipeline_name,
+		table_id,
+		&stats,
+		clear);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+
+	snprintf(out, out_size, MSG_PIPELINE_TABLE_STATS,
+		stats.stats.n_pkts_in,
+		stats.stats.n_pkts_lookup_miss,
+		stats.n_pkts_dropped_by_lkp_hit_ah,
+		stats.n_pkts_dropped_lkp_hit,
+		stats.n_pkts_dropped_by_lkp_miss_ah,
+		stats.n_pkts_dropped_lkp_miss);
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -2045,6 +2275,15 @@ cli_process(char *in, char *out, size_t out_size)
 		if ((n_tokens >= 6) &&
 			(strcmp(tokens[2], "port") == 0) &&
 			(strcmp(tokens[3], "in") == 0) &&
+			(strcmp(tokens[5], "stats") == 0)) {
+			cmd_pipeline_port_in_stats(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
+
+		if ((n_tokens >= 6) &&
+			(strcmp(tokens[2], "port") == 0) &&
+			(strcmp(tokens[3], "in") == 0) &&
 			(strcmp(tokens[5], "enable") == 0)) {
 			cmd_pipeline_port_in_enable(tokens, n_tokens,
 				out, out_size);
@@ -2059,6 +2298,23 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 6) &&
+			(strcmp(tokens[2], "port") == 0) &&
+			(strcmp(tokens[3], "out") == 0) &&
+			(strcmp(tokens[5], "stats") == 0)) {
+			cmd_pipeline_port_out_stats(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
+
+		if ((n_tokens >= 5) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "stats") == 0)) {
+			cmd_pipeline_table_stats(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +18 -0
index 9b79b67..9b2c295 100644
@@ -263,6 +263,12 @@ struct table_rule_action {
 };
 
 int
+pipeline_port_in_stats_read(const char *pipeline_name,
+	uint32_t port_id,
+	struct rte_pipeline_port_in_stats *stats,
+	int clear);
+
+int
 pipeline_port_in_enable(const char *pipeline_name,
 	uint32_t port_id);
 
@@ -270,4 +276,16 @@ int
 pipeline_port_in_disable(const char *pipeline_name,
 	uint32_t port_id);
 
+int
+pipeline_port_out_stats_read(const char *pipeline_name,
+	uint32_t port_id,
+	struct rte_pipeline_port_out_stats *stats,
+	int clear);
+
+int
+pipeline_table_stats_read(const char *pipeline_name,
+	uint32_t table_id,
+	struct rte_pipeline_table_stats *stats,
+	int clear);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +246 -0

301 lines not on this page · raw message

Signature · 1 line
2.9.3
#132 lore raw

PATCH v2 32/44 ip_pipeline: add cli for pipeline table entries

In reply to Jasvinder Singh

Add commands to add pipeline table entries which contains match and action part.

---
 examples/ip_pipeline/cli.c      | 1273 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h |   13 +
 examples/ip_pipeline/thread.c   |  749 +++++++++++++++++++++++
 3 files changed, 2035 insertions(+)
examples/ip_pipeline/cli.c +1273 -0
index a5329cd..eda04dc 100644
@@ -8,6 +8,7 @@
 #include <string.h>
 
 #include <rte_common.h>
+#include <rte_cycles.h>
 
 #include "cli.h"
 #include "kni.h"
@@ -2066,6 +2067,1261 @@ cmd_pipeline_table_stats(char **tokens,
 }
 
 /**
+ * <match> ::=
+ *
+ * match
+ *    acl
+ *       priority <priority>
+ *       ipv4 | ipv6 <sa> <sa_depth> <da> <da_depth>
+ *       <sp0> <sp1> <dp0> <dp1> <proto>
+ *    | array
+ *       pos
+ *    | hash
+ *       raw <key>
+ *       | ipv4_5tuple <sa> <da> <sp> <dp> <proto>
+ *       | ipv6_5tuple <sa> <da> <sp> <dp> <proto>
+ *       | ipv4_addr <addr>
+ *       | ipv6_addr <addr>
+ *       | qinq <svlan> <cvlan>
+ *    | lpm
+ *       ipv4 | ipv6 <addr> <depth>
+ */
+struct pkt_key_qinq {
+	uint16_t ethertype_svlan;
+	uint16_t svlan;
+	uint16_t ethertype_cvlan;
+	uint16_t cvlan;
+} __attribute__((__packed__));
+
+struct pkt_key_ipv4_5tuple {
+	uint8_t time_to_live;
+	uint8_t proto;
+	uint16_t hdr_checksum;
+	uint32_t sa;
+	uint32_t da;
+	uint16_t sp;
+	uint16_t dp;
+} __attribute__((__packed__));
+
+struct pkt_key_ipv6_5tuple {
+	uint16_t payload_length;
+	uint8_t proto;
+	uint8_t hop_limit;
+	uint8_t sa[16];
+	uint8_t da[16];
+	uint16_t sp;
+	uint16_t dp;
+} __attribute__((__packed__));
+
+struct pkt_key_ipv4_addr {
+	uint32_t addr;
+} __attribute__((__packed__));
+
+struct pkt_key_ipv6_addr {
+	uint8_t addr[16];
+} __attribute__((__packed__));
+
+static uint32_t
+parse_match(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size,
+	struct table_rule_match *m)
+{
+	memset(m, 0, sizeof(*m));
+
+	if (n_tokens < 2)
+		return 0;
+
+	if (strcmp(tokens[0], "match") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "match");
+		return 0;
+	}
+
+	if (strcmp(tokens[1], "acl") == 0) {
+		if (n_tokens < 14) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return 0;
+		}
+
+		m->match_type = TABLE_ACL;
+
+		if (strcmp(tokens[2], "priority") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "priority");
+			return 0;
+		}
+
+		if (parser_read_uint32(&m->match.acl.priority,
+			tokens[3]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "priority");
+			return 0;
+		}
+
+		if (strcmp(tokens[4], "ipv4") == 0) {
+			struct in_addr saddr, daddr;
+
+			m->match.acl.ip_version = 1;
+
+			if (parse_ipv4_addr(tokens[5], &saddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "sa");
+				return 0;
+			}
+			m->match.acl.ipv4.sa = rte_be_to_cpu_32(saddr.s_addr);
+
+			if (parse_ipv4_addr(tokens[7], &daddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "da");
+				return 0;
+			}
+			m->match.acl.ipv4.da = rte_be_to_cpu_32(daddr.s_addr);
+		} else if (strcmp(tokens[4], "ipv6") == 0) {
+			struct in6_addr saddr, daddr;
+
+			m->match.acl.ip_version = 0;
+
+			if (parse_ipv6_addr(tokens[5], &saddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "sa");
+				return 0;
+			}
+			memcpy(m->match.acl.ipv6.sa, saddr.s6_addr, 16);
+
+			if (parse_ipv6_addr(tokens[7], &daddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "da");
+				return 0;
+			}
+			memcpy(m->match.acl.ipv6.da, daddr.s6_addr, 16);
+		} else {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND,
+				"ipv4 or ipv6");
+			return 0;
+		}
+
+		if (parser_read_uint32(&m->match.acl.sa_depth,
+			tokens[6]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "sa_depth");
+			return 0;
+		}
+
+		if (parser_read_uint32(&m->match.acl.da_depth,
+			tokens[8]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "da_depth");
+			return 0;
+		}
+
+		if (parser_read_uint16(&m->match.acl.sp0, tokens[9]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "sp0");
+			return 0;
+		}
+
+		if (parser_read_uint16(&m->match.acl.sp1, tokens[10]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "sp1");
+			return 0;
+		}
+
+		if (parser_read_uint16(&m->match.acl.dp0, tokens[11]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "dp0");
+			return 0;
+		}
+
+		if (parser_read_uint16(&m->match.acl.dp1, tokens[12]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "dp1");
+			return 0;
+		}
+
+		if (parser_read_uint8(&m->match.acl.proto, tokens[13]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "proto");
+			return 0;
+		}
+
+		m->match.acl.proto_mask = 0xff;
+
+		return 14;
+	} /* acl */
+
+	if (strcmp(tokens[1], "array") == 0) {
+		if (n_tokens < 3) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return 0;
+		}
+
+		m->match_type = TABLE_ARRAY;
+
+		if (parser_read_uint32(&m->match.array.pos, tokens[2]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "pos");
+			return 0;
+		}
+
+		return 3;
+	} /* array */
+
+	if (strcmp(tokens[1], "hash") == 0) {
+		if (n_tokens < 3) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return 0;
+		}
+
+		m->match_type = TABLE_HASH;
+
+		if (strcmp(tokens[2], "raw") == 0) {
+			uint32_t key_size = TABLE_RULE_MATCH_SIZE_MAX;
+
+			if (n_tokens < 4) {
+				snprintf(out, out_size, MSG_ARG_MISMATCH,
+					tokens[0]);
+				return 0;
+			}
+
+			if (parse_hex_string(tokens[3],
+				m->match.hash.key, &key_size) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "key");
+				return 0;
+			}
+
+			return 4;
+		} /* hash raw */
+
+		if (strcmp(tokens[2], "ipv4_5tuple") == 0) {
+			struct pkt_key_ipv4_5tuple *ipv4 =
+				(struct pkt_key_ipv4_5tuple *) m->match.hash.key;
+			struct in_addr saddr, daddr;
+			uint16_t sp, dp;
+			uint8_t proto;
+
+			if (n_tokens < 8) {
+				snprintf(out, out_size, MSG_ARG_MISMATCH,
+					tokens[0]);
+				return 0;
+			}
+
+			if (parse_ipv4_addr(tokens[3], &saddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "sa");
+				return 0;
+			}
+
+			if (parse_ipv4_addr(tokens[4], &daddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "da");
+				return 0;
+			}
+
+			if (parser_read_uint16(&sp, tokens[5]) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "sp");
+				return 0;
+			}
+
+			if (parser_read_uint16(&dp, tokens[6]) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "dp");
+				return 0;
+			}
+
+			if (parser_read_uint8(&proto, tokens[7]) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"proto");
+				return 0;
+			}
+
+			ipv4->sa = saddr.s_addr;
+			ipv4->da = daddr.s_addr;
+			ipv4->sp = rte_cpu_to_be_16(sp);
+			ipv4->dp = rte_cpu_to_be_16(dp);
+			ipv4->proto = proto;
+
+			return 8;
+		} /* hash ipv4_5tuple */
+
+		if (strcmp(tokens[2], "ipv6_5tuple") == 0) {
+			struct pkt_key_ipv6_5tuple *ipv6 =
+				(struct pkt_key_ipv6_5tuple *) m->match.hash.key;
+			struct in6_addr saddr, daddr;
+			uint16_t sp, dp;
+			uint8_t proto;
+
+			if (n_tokens < 8) {
+				snprintf(out, out_size, MSG_ARG_MISMATCH,
+					tokens[0]);
+				return 0;
+			}
+
+			if (parse_ipv6_addr(tokens[3], &saddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "sa");
+				return 0;
+			}
+
+			if (parse_ipv6_addr(tokens[4], &daddr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "da");
+				return 0;
+			}
+
+			if (parser_read_uint16(&sp, tokens[5]) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "sp");
+				return 0;
+			}
+
+			if (parser_read_uint16(&dp, tokens[6]) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID, "dp");
+				return 0;
+			}
+
+			if (parser_read_uint8(&proto, tokens[7]) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"proto");
+				return 0;
+			}
+
+			memcpy(ipv6->sa, saddr.s6_addr, 16);
+			memcpy(ipv6->da, daddr.s6_addr, 16);
+			ipv6->sp = rte_cpu_to_be_16(sp);
+			ipv6->dp = rte_cpu_to_be_16(dp);
+			ipv6->proto = proto;
+
+			return 8;
+		} /* hash ipv6_5tuple */
+
+		if (strcmp(tokens[2], "ipv4_addr") == 0) {
+			struct pkt_key_ipv4_addr *ipv4_addr =
+				(struct pkt_key_ipv4_addr *) m->match.hash.key;
+			struct in_addr addr;
+
+			if (n_tokens < 4) {
+				snprintf(out, out_size, MSG_ARG_MISMATCH,
+					tokens[0]);
+				return 0;
+			}
+
+			if (parse_ipv4_addr(tokens[3], &addr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"addr");
+				return 0;
+			}
+
+			ipv4_addr->addr = addr.s_addr;
+
+			return 4;
+		} /* hash ipv4_addr */
+
+		if (strcmp(tokens[2], "ipv6_addr") == 0) {
+			struct pkt_key_ipv6_addr *ipv6_addr =
+				(struct pkt_key_ipv6_addr *) m->match.hash.key;
+			struct in6_addr addr;
+
+			if (n_tokens < 4) {
+				snprintf(out, out_size, MSG_ARG_MISMATCH,
+					tokens[0]);
+				return 0;
+			}
+
+			if (parse_ipv6_addr(tokens[3], &addr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"addr");
+				return 0;
+			}
+
+			memcpy(ipv6_addr->addr, addr.s6_addr, 16);
+
+			return 4;
+		} /* hash ipv6_5tuple */
+
+		if (strcmp(tokens[2], "qinq") == 0) {
+			struct pkt_key_qinq *qinq =
+				(struct pkt_key_qinq *) m->match.hash.key;
+			uint16_t svlan, cvlan;
+
+			if (n_tokens < 5) {
+				snprintf(out, out_size, MSG_ARG_MISMATCH,
+					tokens[0]);
+				return 0;
+			}
+
+			if ((parser_read_uint16(&svlan, tokens[3]) != 0) ||
+				(svlan > 0xFFF)) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"svlan");
+				return 0;
+			}
+
+			if ((parser_read_uint16(&cvlan, tokens[4]) != 0) ||
+				(cvlan > 0xFFF)) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"cvlan");
+				return 0;
+			}
+
+			qinq->svlan = rte_cpu_to_be_16(svlan);
+			qinq->cvlan = rte_cpu_to_be_16(cvlan);
+
+			return 5;
+		} /* hash qinq */
+
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return 0;
+	} /* hash */
+
+	if (strcmp(tokens[1], "lpm") == 0) {
+		if (n_tokens < 5) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return 0;
+		}
+
+		m->match_type = TABLE_LPM;
+
+		if (strcmp(tokens[2], "ipv4") == 0) {
+			struct in_addr addr;
+
+			m->match.lpm.ip_version = 1;
+
+			if (parse_ipv4_addr(tokens[3], &addr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"addr");
+				return 0;
+			}
+
+			m->match.lpm.ipv4 = rte_be_to_cpu_32(addr.s_addr);
+		} else if (strcmp(tokens[2], "ipv6") == 0) {
+			struct in6_addr addr;
+
+			m->match.lpm.ip_version = 0;
+
+			if (parse_ipv6_addr(tokens[3], &addr) != 0) {
+				snprintf(out, out_size, MSG_ARG_INVALID,
+					"addr");
+				return 0;
+			}
+
+			memcpy(m->match.lpm.ipv6, addr.s6_addr, 16);
+		} else {
+			snprintf(out, out_size, MSG_ARG_MISMATCH,
+				"ipv4 or ipv6");
+			return 0;
+		}
+
+		if (parser_read_uint8(&m->match.lpm.depth, tokens[4]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "depth");
+			return 0;
+		}
+
+		return 5;
+	} /* lpm */
+
+	snprintf(out, out_size, MSG_ARG_MISMATCH,
+		"acl or array or hash or lpm");
+	return 0;
+}
+
+/**
+ * table_action ::=
+ *
+ * action
+ *    fwd drop | port <port_id> | table <table_id>
+ *    [meter
+ *       tc0 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
+ *       [tc1 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
+ *        tc2 meter <meter_profile_id> policer g <pa> y <pa> r <pa>
+ *        tc3 meter <meter_profile_id> policer g <pa> y <pa> r <pa>]]
+ *    [tm subport <subport_id> pipe <pipe_id>]
+ *    [encap
+ *       ether <da> <sa>
+ *       | vlan <da> <sa> <pcp> <dei> <vid>
+ *       | qinq <da> <sa> <pcp> <dei> <vid> <pcp> <dei> <vid>
+ *       | mpls unicast | multicast
+ *          <da> <sa>
+ *          label0 <label> <tc> <ttl>
+ *          [label1 <label> <tc> <ttl>
+ *          [label2 <label> <tc> <ttl>
+ *          [label3 <label> <tc> <ttl>]]]
+ *       | pppoe <da> <sa> <session_id>]
+ *    [nat ipv4 | ipv6 <addr> <port>]
+ *    [ttl dec | keep]
+ *    [stats]
+ *    [time]
+ *
+ * where:
+ *    <pa> ::= g | y | r | drop
+ */
+static uint32_t
+parse_table_action_fwd(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens == 0) || (strcmp(tokens[0], "fwd") != 0))
+		return 0;
+
+	tokens++;
+	n_tokens--;
+
+	if (n_tokens && (strcmp(tokens[0], "drop") == 0)) {
+		a->fwd.action = RTE_PIPELINE_ACTION_DROP;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
+		return 1 + 1;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "port") == 0)) {
+		uint32_t id;
+
+		if ((n_tokens < 2) ||
+			parser_read_uint32(&id, tokens[1]))
+			return 0;
+
+		a->fwd.action = RTE_PIPELINE_ACTION_PORT;
+		a->fwd.id = id;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
+		return 1 + 2;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "table") == 0)) {
+		uint32_t id;
+
+		if ((n_tokens < 2) ||
+			parser_read_uint32(&id, tokens[1]))
+			return 0;
+
+		a->fwd.action = RTE_PIPELINE_ACTION_TABLE;
+		a->fwd.id = id;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_FWD;
+		return 1 + 2;
+	}
+
+	return 0;
+}
+
+static int
+parse_policer_action(char *token, enum rte_table_action_policer *a)
+{
+	if (strcmp(token, "g") == 0) {
+		*a = RTE_TABLE_ACTION_POLICER_COLOR_GREEN;
+		return 0;
+	}
+
+	if (strcmp(token, "y") == 0) {
+		*a = RTE_TABLE_ACTION_POLICER_COLOR_YELLOW;
+		return 0;
+	}
+
+	if (strcmp(token, "r") == 0) {
+		*a = RTE_TABLE_ACTION_POLICER_COLOR_RED;
+		return 0;
+	}
+
+	if (strcmp(token, "drop") == 0) {
+		*a = RTE_TABLE_ACTION_POLICER_DROP;
+		return 0;
+	}
+
+	return -1;
+}
+
+static uint32_t
+parse_table_action_meter_tc(char **tokens,
+	uint32_t n_tokens,
+	struct rte_table_action_mtr_tc_params *mtr)
+{
+	if ((n_tokens < 9) ||
+		strcmp(tokens[0], "meter") ||
+		parser_read_uint32(&mtr->meter_profile_id, tokens[1]) ||
+		strcmp(tokens[2], "policer") ||
+		strcmp(tokens[3], "g") ||
+		parse_policer_action(tokens[4], &mtr->policer[e_RTE_METER_GREEN]) ||
+		strcmp(tokens[5], "y") ||
+		parse_policer_action(tokens[6], &mtr->policer[e_RTE_METER_YELLOW]) ||
+		strcmp(tokens[7], "r") ||
+		parse_policer_action(tokens[8], &mtr->policer[e_RTE_METER_RED]))
+		return 0;
+
+	return 9;
+}
+
+static uint32_t
+parse_table_action_meter(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens == 0) || strcmp(tokens[0], "meter"))
+		return 0;
+
+	tokens++;
+	n_tokens--;
+
+	if ((n_tokens < 10) ||
+		strcmp(tokens[0], "tc0") ||
+		(parse_table_action_meter_tc(tokens + 1,
+			n_tokens - 1,
+			&a->mtr.mtr[0]) == 0))
+		return 0;
+
+	tokens += 10;
+	n_tokens -= 10;
+
+	if ((n_tokens == 0) || strcmp(tokens[0], "tc1")) {
+		a->mtr.tc_mask = 1;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_MTR;
+		return 1 + 10;
+	}
+
+	if ((n_tokens < 30) ||
+		(parse_table_action_meter_tc(tokens + 1,
+			n_tokens - 1, &a->mtr.mtr[1]) == 0) ||
+		strcmp(tokens[10], "tc2") ||
+		(parse_table_action_meter_tc(tokens + 11,
+			n_tokens - 11, &a->mtr.mtr[2]) == 0) ||
+		strcmp(tokens[20], "tc3") ||
+		(parse_table_action_meter_tc(tokens + 21,
+			n_tokens - 21, &a->mtr.mtr[3]) == 0))
+		return 0;
+
+	a->mtr.tc_mask = 0xF;
+	a->action_mask |= 1 << RTE_TABLE_ACTION_MTR;
+	return 1 + 10 + 3 * 10;
+}
+
+static uint32_t
+parse_table_action_tm(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	uint32_t subport_id, pipe_id;
+
+	if ((n_tokens < 5) ||
+		strcmp(tokens[0], "tm") ||
+		strcmp(tokens[1], "subport") ||
+		parser_read_uint32(&subport_id, tokens[2]) ||
+		strcmp(tokens[3], "pipe") ||
+		parser_read_uint32(&pipe_id, tokens[4]))
+		return 0;
+
+	a->tm.subport_id = subport_id;
+	a->tm.pipe_id = pipe_id;
+	a->action_mask |= 1 << RTE_TABLE_ACTION_TM;
+	return 5;
+}
+
+static uint32_t
+parse_table_action_encap(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens == 0) || strcmp(tokens[0], "encap"))
+		return 0;
+
+	tokens++;
+	n_tokens--;
+
+	/* ether */
+	if (n_tokens && (strcmp(tokens[0], "ether") == 0)) {
+		if ((n_tokens < 3) ||
+			parse_mac_addr(tokens[1], &a->encap.ether.ether.da) ||
+			parse_mac_addr(tokens[2], &a->encap.ether.ether.sa))
+			return 0;
+
+		a->encap.type = RTE_TABLE_ACTION_ENCAP_ETHER;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+		return 1 + 3;
+	}
+
+	/* vlan */
+	if (n_tokens && (strcmp(tokens[0], "vlan") == 0)) {
+		uint32_t pcp, dei, vid;
+
+		if ((n_tokens < 6) ||
+			parse_mac_addr(tokens[1], &a->encap.vlan.ether.da) ||
+			parse_mac_addr(tokens[2], &a->encap.vlan.ether.sa) ||
+			parser_read_uint32(&pcp, tokens[3]) ||
+			(pcp > 0x7) ||
+			parser_read_uint32(&dei, tokens[4]) ||
+			(dei > 0x1) ||
+			parser_read_uint32(&vid, tokens[5]) ||
+			(vid > 0xFFF))
+			return 0;
+
+		a->encap.vlan.vlan.pcp = pcp & 0x7;
+		a->encap.vlan.vlan.dei = dei & 0x1;
+		a->encap.vlan.vlan.vid = vid & 0xFFF;
+		a->encap.type = RTE_TABLE_ACTION_ENCAP_VLAN;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+		return 1 + 6;
+	}
+
+	/* qinq */
+	if (n_tokens && (strcmp(tokens[0], "qinq") == 0)) {
+		uint32_t svlan_pcp, svlan_dei, svlan_vid;
+		uint32_t cvlan_pcp, cvlan_dei, cvlan_vid;
+
+		if ((n_tokens < 9) ||
+			parse_mac_addr(tokens[1], &a->encap.qinq.ether.da) ||
+			parse_mac_addr(tokens[2], &a->encap.qinq.ether.sa) ||
+			parser_read_uint32(&svlan_pcp, tokens[3]) ||
+			(svlan_pcp > 0x7) ||
+			parser_read_uint32(&svlan_dei, tokens[4]) ||
+			(svlan_dei > 0x1) ||
+			parser_read_uint32(&svlan_vid, tokens[5]) ||
+			(svlan_vid > 0xFFF) ||
+			parser_read_uint32(&cvlan_pcp, tokens[6]) ||
+			(cvlan_pcp > 0x7) ||
+			parser_read_uint32(&cvlan_dei, tokens[7]) ||
+			(cvlan_dei > 0x1) ||
+			parser_read_uint32(&cvlan_vid, tokens[8]) ||
+			(cvlan_vid > 0xFFF))
+			return 0;
+
+		a->encap.qinq.svlan.pcp = svlan_pcp & 0x7;
+		a->encap.qinq.svlan.dei = svlan_dei & 0x1;
+		a->encap.qinq.svlan.vid = svlan_vid & 0xFFF;
+		a->encap.qinq.cvlan.pcp = cvlan_pcp & 0x7;
+		a->encap.qinq.cvlan.dei = cvlan_dei & 0x1;
+		a->encap.qinq.cvlan.vid = cvlan_vid & 0xFFF;
+		a->encap.type = RTE_TABLE_ACTION_ENCAP_QINQ;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+		return 1 + 9;
+	}
+
+	/* mpls */
+	if (n_tokens && (strcmp(tokens[0], "mpls") == 0)) {
+		uint32_t label, tc, ttl;
+
+		if (n_tokens < 8)
+			return 0;
+
+		if (strcmp(tokens[1], "unicast") == 0)
+			a->encap.mpls.unicast = 1;
+		else if (strcmp(tokens[1], "multicast") == 0)
+			a->encap.mpls.unicast = 0;
+		else
+			return 0;
+
+		if (parse_mac_addr(tokens[2], &a->encap.mpls.ether.da) ||
+			parse_mac_addr(tokens[3], &a->encap.mpls.ether.sa) ||
+			strcmp(tokens[4], "label0") ||
+			parser_read_uint32(&label, tokens[5]) ||
+			(label > 0xFFFFF) ||
+			parser_read_uint32(&tc, tokens[6]) ||
+			(tc > 0x7) ||
+			parser_read_uint32(&ttl, tokens[7]) ||
+			(ttl > 0x3F))
+			return 0;
+
+		a->encap.mpls.mpls[0].label = label;
+		a->encap.mpls.mpls[0].tc = tc;
+		a->encap.mpls.mpls[0].ttl = ttl;
+
+		tokens += 8;
+		n_tokens -= 8;
+
+		if ((n_tokens == 0) || strcmp(tokens[0], "label1")) {
+			a->encap.mpls.mpls_count = 1;
+			a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
+			a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+			return 1 + 8;
+		}
+
+		if ((n_tokens < 4) ||
+			parser_read_uint32(&label, tokens[1]) ||
+			(label > 0xFFFFF) ||
+			parser_read_uint32(&tc, tokens[2]) ||
+			(tc > 0x7) ||
+			parser_read_uint32(&ttl, tokens[3]) ||
+			(ttl > 0x3F))
+			return 0;
+
+		a->encap.mpls.mpls[1].label = label;
+		a->encap.mpls.mpls[1].tc = tc;
+		a->encap.mpls.mpls[1].ttl = ttl;
+
+		tokens += 4;
+		n_tokens -= 4;
+
+		if ((n_tokens == 0) || strcmp(tokens[0], "label2")) {
+			a->encap.mpls.mpls_count = 2;
+			a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
+			a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+			return 1 + 8 + 4;
+		}
+
+		if ((n_tokens < 4) ||
+			parser_read_uint32(&label, tokens[1]) ||
+			(label > 0xFFFFF) ||
+			parser_read_uint32(&tc, tokens[2]) ||
+			(tc > 0x7) ||
+			parser_read_uint32(&ttl, tokens[3]) ||
+			(ttl > 0x3F))
+			return 0;
+
+		a->encap.mpls.mpls[2].label = label;
+		a->encap.mpls.mpls[2].tc = tc;
+		a->encap.mpls.mpls[2].ttl = ttl;
+
+		tokens += 4;
+		n_tokens -= 4;
+
+		if ((n_tokens == 0) || strcmp(tokens[0], "label3")) {
+			a->encap.mpls.mpls_count = 3;
+			a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
+			a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+			return 1 + 8 + 4 + 4;
+		}
+
+		if ((n_tokens < 4) ||
+			parser_read_uint32(&label, tokens[1]) ||
+			(label > 0xFFFFF) ||
+			parser_read_uint32(&tc, tokens[2]) ||
+			(tc > 0x7) ||
+			parser_read_uint32(&ttl, tokens[3]) ||
+			(ttl > 0x3F))
+			return 0;
+
+		a->encap.mpls.mpls[3].label = label;
+		a->encap.mpls.mpls[3].tc = tc;
+		a->encap.mpls.mpls[3].ttl = ttl;
+
+		a->encap.mpls.mpls_count = 4;
+		a->encap.type = RTE_TABLE_ACTION_ENCAP_MPLS;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+		return 1 + 8 + 4 + 4 + 4;
+	}
+
+	/* pppoe */
+	if (n_tokens && (strcmp(tokens[0], "pppoe") == 0)) {
+		if ((n_tokens < 4) ||
+			parse_mac_addr(tokens[1], &a->encap.pppoe.ether.da) ||
+			parse_mac_addr(tokens[2], &a->encap.pppoe.ether.sa) ||
+			parser_read_uint16(&a->encap.pppoe.pppoe.session_id,
+				tokens[3]))
+			return 0;
+
+		a->encap.type = RTE_TABLE_ACTION_ENCAP_PPPOE;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
+		return 1 + 4;
+	}
+
+	return 0;
+}
+
+static uint32_t
+parse_table_action_nat(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens < 4) ||
+		strcmp(tokens[0], "nat"))
+		return 0;
+
+	if (strcmp(tokens[1], "ipv4") == 0) {
+		struct in_addr addr;
+		uint16_t port;
+
+		if (parse_ipv4_addr(tokens[2], &addr) ||
+			parser_read_uint16(&port, tokens[3]))
+			return 0;
+
+		a->nat.ip_version = 1;
+		a->nat.addr.ipv4 = rte_be_to_cpu_32(addr.s_addr);
+		a->nat.port = port;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_NAT;
+		return 4;
+	}
+
+	if (strcmp(tokens[1], "ipv6") == 0) {
+		struct in6_addr addr;
+		uint16_t port;
+
+		if (parse_ipv6_addr(tokens[2], &addr) ||
+			parser_read_uint16(&port, tokens[3]))
+			return 0;
+
+		a->nat.ip_version = 0;
+		memcpy(a->nat.addr.ipv6, addr.s6_addr, 16);
+		a->nat.port = port;
+		a->action_mask |= 1 << RTE_TABLE_ACTION_NAT;
+		return 4;
+	}
+
+	return 0;
+}
+
+static uint32_t
+parse_table_action_ttl(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens < 2) ||
+		strcmp(tokens[0], "ttl"))
+		return 0;
+
+	if (strcmp(tokens[1], "dec") == 0)
+		a->ttl.decrement = 1;
+	else if (strcmp(tokens[1], "keep") == 0)
+		a->ttl.decrement = 0;
+	else
+		return 0;
+
+	a->action_mask |= 1 << RTE_TABLE_ACTION_TTL;
+	return 2;
+}
+
+static uint32_t
+parse_table_action_stats(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens < 1) ||
+		strcmp(tokens[0], "stats"))
+		return 0;
+
+	a->stats.n_packets = 0;
+	a->stats.n_bytes = 0;
+	a->action_mask |= 1 << RTE_TABLE_ACTION_STATS;
+	return 1;
+}
+
+static uint32_t
+parse_table_action_time(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens < 1) ||
+		strcmp(tokens[0], "time"))
+		return 0;
+
+	a->time.time = rte_rdtsc();
+	a->action_mask |= 1 << RTE_TABLE_ACTION_TIME;
+	return 1;
+}
+
+static uint32_t
+parse_table_action(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size,
+	struct table_rule_action *a)
+{
+	uint32_t n_tokens0 = n_tokens;
+
+	memset(a, 0, sizeof(*a));
+
+	if ((n_tokens < 2) ||
+		strcmp(tokens[0], "action"))
+		return 0;
+
+	tokens++;
+	n_tokens--;
+
+	if (n_tokens && (strcmp(tokens[0], "fwd") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_fwd(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action fwd");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "meter") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_meter(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action meter");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "tm") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_tm(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action tm");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "encap") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_encap(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action encap");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "nat") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_nat(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action nat");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "ttl") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_ttl(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action ttl");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "stats") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_stats(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action stats");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "time") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_time(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action time");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens0 - n_tokens == 1) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "action");
+		return 0;
+	}
+
+	return n_tokens0 - n_tokens;
+}
+
+/**
+ * pipeline <pipeline_name> table <table_id> rule add
+ *    match <match>
+ *    action <table_action>
+ */
+static void
+cmd_pipeline_table_rule_add(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct table_rule_match m;
+	struct table_rule_action a;
+	char *pipeline_name;
+	void *data;
+	uint32_t table_id, t0, n_tokens_parsed;
+	int status;
+
+	if (n_tokens < 8) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "rule") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
+		return;
+	}
+
+	if (strcmp(tokens[5], "add") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
+		return;
+	}
+
+	t0 = 6;
+
+	/* match */
+	n_tokens_parsed = parse_match(tokens + t0,
+		n_tokens - t0,
+		out,
+		out_size,
+		&m);
+	if (n_tokens_parsed == 0)
+		return;
+	t0 += n_tokens_parsed;
+
+	/* action */
+	n_tokens_parsed = parse_table_action(tokens + t0,
+		n_tokens - t0,
+		out,
+		out_size,
+		&a);
+	if (n_tokens_parsed == 0)
+		return;
+	t0 += n_tokens_parsed;
+
+	if (t0 != n_tokens) {
+		snprintf(out, out_size, MSG_ARG_INVALID, tokens[0]);
+		return;
+	}
+
+	status = pipeline_table_rule_add(pipeline_name, table_id,
+		&m, &a, &data);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
+ * pipeline <pipeline_name> table <table_id> rule add
+ *    match
+ *       default
+ *    action
+ *       fwd drop | port <port_id> | table <table_id>
+ */
+static void
+cmd_pipeline_table_rule_add_default(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct table_rule_action action;
+	void *data;
+	char *pipeline_name;
+	uint32_t table_id;
+	int status;
+
+	if ((n_tokens != 11) && (n_tokens != 12)) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "rule") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
+		return;
+	}
+
+	if (strcmp(tokens[5], "add") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
+		return;
+	}
+
+	if (strcmp(tokens[6], "match") != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "match");
+		return;
+	}
+
+	if (strcmp(tokens[7], "default") != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "default");
+		return;
+	}
+
+	if (strcmp(tokens[8], "action") != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "action");
+		return;
+	}
+
+	if (strcmp(tokens[9], "fwd") != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "fwd");
+		return;
+	}
+
+	action.action_mask = 1 << RTE_TABLE_ACTION_FWD;
+
+	if (strcmp(tokens[10], "drop") == 0) {
+		if (n_tokens != 11) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return;
+		}
+
+		action.fwd.action = RTE_PIPELINE_ACTION_DROP;
+	} else if (strcmp(tokens[10], "port") == 0) {
+		uint32_t id;
+
+		if (n_tokens != 12) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return;
+		}
+
+		if (parser_read_uint32(&id, tokens[11]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "port_id");
+			return;
+		}
+
+		action.fwd.action = RTE_PIPELINE_ACTION_PORT;
+		action.fwd.id = id;
+	} else if (strcmp(tokens[10], "table") == 0) {
+		uint32_t id;
+
+		if (n_tokens != 12) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return;
+		}
+
+		if (parser_read_uint32(&id, tokens[11]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+			return;
+		}
+
+		action.fwd.action = RTE_PIPELINE_ACTION_TABLE;
+		action.fwd.id = id;
+	} else {
+		snprintf(out, out_size, MSG_ARG_INVALID,
+			"drop or port or table");
+		return;
+	}
+
+	status = pipeline_table_rule_add_default(pipeline_name,
+		table_id,
+		&action,
+		&data);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -2315,6 +3571,23 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 7) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "rule") == 0) &&
+			(strcmp(tokens[5], "add") == 0) &&
+			(strcmp(tokens[6], "match") == 0)) {
+			if ((n_tokens >= 8) &&
+				(strcmp(tokens[7], "default") == 0)) {
+				cmd_pipeline_table_rule_add_default(tokens,
+					n_tokens, out, out_size);
+				return;
+			}
+
+			cmd_pipeline_table_rule_add(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +13 -0
index 9b2c295..9351024 100644
@@ -288,4 +288,17 @@ pipeline_table_stats_read(const char *pipeline_name,
 	struct rte_pipeline_table_stats *stats,
 	int clear);
 
+int
+pipeline_table_rule_add(const char *pipeline_name,
+	uint32_t table_id,
+	struct table_rule_match *match,
+	struct table_rule_action *action,
+	void **data);
+
+int
+pipeline_table_rule_add_default(const char *pipeline_name,
+	uint32_t table_id,
+	struct table_rule_action *action,
+	void **data);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +749 -0

797 lines not on this page · raw message

Signature · 1 line
2.9.3
#133 lore raw

PATCH v2 33/44 ip_pipeline: add cli to delete pipeline table entry

In reply to Jasvinder Singh

Add command to delete the pipeline table entry.

---
 examples/ip_pipeline/cli.c      | 145 ++++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h |   9 +++
 examples/ip_pipeline/thread.c   | 140 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 294 insertions(+)
examples/ip_pipeline/cli.c +145 -0
index eda04dc..4938b55 100644
@@ -3322,6 +3322,134 @@ cmd_pipeline_table_rule_add_default(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> table <table_id> rule delete
+ *    match <match>
+ */
+static void
+cmd_pipeline_table_rule_delete(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct table_rule_match m;
+	char *pipeline_name;
+	uint32_t table_id, n_tokens_parsed, t0;
+	int status;
+
+	if (n_tokens < 8) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "table");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "rule") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
+		return;
+	}
+
+	if (strcmp(tokens[5], "delete") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
+		return;
+	}
+
+	t0 = 6;
+
+	/* match */
+	n_tokens_parsed = parse_match(tokens + t0,
+		n_tokens - t0,
+		out,
+		out_size,
+		&m);
+	if (n_tokens_parsed == 0)
+		return;
+	t0 += n_tokens_parsed;
+
+	if (n_tokens != t0) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	status = pipeline_table_rule_delete(pipeline_name,
+		table_id,
+		&m);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
+ * pipeline <pipeline_name> table <table_id> rule delete
+ *    match
+ *       default
+ */
+static void
+cmd_pipeline_table_rule_delete_default(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	char *pipeline_name;
+	uint32_t table_id;
+	int status;
+
+	if (n_tokens != 8) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "rule") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rule");
+		return;
+	}
+
+	if (strcmp(tokens[5], "delete") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
+		return;
+	}
+
+	if (strcmp(tokens[6], "match") != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "match");
+		return;
+	}
+
+	if (strcmp(tokens[7], "default") != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "default");
+		return;
+	}
+
+	status = pipeline_table_rule_delete_default(pipeline_name,
+		table_id);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -3588,6 +3716,23 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 7) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "rule") == 0) &&
+			(strcmp(tokens[5], "delete") == 0) &&
+			(strcmp(tokens[6], "match") == 0)) {
+			if ((n_tokens >= 8) &&
+				(strcmp(tokens[7], "default") == 0)) {
+				cmd_pipeline_table_rule_delete_default(tokens,
+					n_tokens, out, out_size);
+				return;
+				}
+
+			cmd_pipeline_table_rule_delete(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +9 -0
index 9351024..2bf6360 100644
@@ -301,4 +301,13 @@ pipeline_table_rule_add_default(const char *pipeline_name,
 	struct table_rule_action *action,
 	void **data);
 
+int
+pipeline_table_rule_delete(const char *pipeline_name,
+	uint32_t table_id,
+	struct table_rule_match *match);
+
+int
+pipeline_table_rule_delete_default(const char *pipeline_name,
+	uint32_t table_id);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +140 -0

176 lines not on this page · raw message

Signature · 1 line
2.9.3
#134 lore raw

PATCH v2 34/44 ip_pipeline: add cli to read pipeline table entry stats

In reply to Jasvinder Singh

Add command to read the pipeline table entry stats.

---
 examples/ip_pipeline/cli.c      | 22 +++++++++++
 examples/ip_pipeline/pipeline.h |  7 ++++
 examples/ip_pipeline/thread.c   | 84 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 113 insertions(+)
examples/ip_pipeline/cli.c +22 -0
index 4938b55..b810294 100644
@@ -3450,6 +3450,18 @@ cmd_pipeline_table_rule_delete_default(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> table <table_id> rule read stats [clear]
+ */
+static void
+cmd_pipeline_table_rule_stats_read(char **tokens,
+	uint32_t n_tokens __rte_unused,
+	char *out,
+	size_t out_size)
+{
+	snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -3733,6 +3745,16 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 7) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "rule") == 0) &&
+			(strcmp(tokens[5], "read") == 0) &&
+			(strcmp(tokens[6], "stats") == 0)) {
+			cmd_pipeline_table_rule_stats_read(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +7 -0
index 2bf6360..296e4da 100644
@@ -310,4 +310,11 @@ int
 pipeline_table_rule_delete_default(const char *pipeline_name,
 	uint32_t table_id);
 
+int
+pipeline_table_rule_stats_read(const char *pipeline_name,
+	uint32_t table_id,
+	void *data,
+	struct rte_table_action_stats_counters *stats,
+	int clear);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +84 -0

132 lines not on this page · raw message

Signature · 1 line
2.9.3
#135 lore raw

PATCH v2 35/44 ip_pipeline: add cli to configure meter profile

In reply to Jasvinder Singh

Add commands to configure the traffic meter profile.

---
 examples/ip_pipeline/cli.c      | 232 ++++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h |  11 ++
 examples/ip_pipeline/thread.c   | 145 ++++++++++++++++++++++++-
 3 files changed, 387 insertions(+), 1 deletion(-)
examples/ip_pipeline/cli.c +232 -0
index b810294..ddc1dc5 100644
@@ -3462,6 +3462,218 @@ cmd_pipeline_table_rule_stats_read(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> table <table_id> meter profile <meter_profile_id>
+ *  add srtcm cir <cir> cbs <cbs> ebs <ebs>
+ *  | trtcm cir <cir> pir <pir> cbs <cbs> pbs <pbs>
+ */
+static void
+cmd_pipeline_table_meter_profile_add(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct rte_table_action_meter_profile p;
+	char *pipeline_name;
+	uint32_t table_id, meter_profile_id;
+	int status;
+
+	if (n_tokens < 9) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "meter") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter");
+		return;
+	}
+
+	if (strcmp(tokens[5], "profile") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
+		return;
+	}
+
+	if (parser_read_uint32(&meter_profile_id, tokens[6]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "meter_profile_id");
+		return;
+	}
+
+	if (strcmp(tokens[7], "add") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "add");
+		return;
+	}
+
+	if (strcmp(tokens[8], "srtcm") == 0) {
+		if (n_tokens != 15) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH,
+				tokens[0]);
+			return;
+		}
+
+		p.alg = RTE_TABLE_ACTION_METER_SRTCM;
+
+		if (strcmp(tokens[9], "cir") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cir");
+			return;
+		}
+
+		if (parser_read_uint64(&p.srtcm.cir, tokens[10]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "cir");
+			return;
+		}
+
+		if (strcmp(tokens[11], "cbs") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cbs");
+			return;
+		}
+
+		if (parser_read_uint64(&p.srtcm.cbs, tokens[12]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "cbs");
+			return;
+		}
+
+		if (strcmp(tokens[13], "ebs") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "ebs");
+			return;
+		}
+
+		if (parser_read_uint64(&p.srtcm.ebs, tokens[14]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "ebs");
+			return;
+		}
+	} else if (strcmp(tokens[8], "trtcm") == 0) {
+		if (n_tokens != 17) {
+			snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+			return;
+		}
+
+		p.alg = RTE_TABLE_ACTION_METER_TRTCM;
+
+		if (strcmp(tokens[9], "cir") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cir");
+			return;
+		}
+
+		if (parser_read_uint64(&p.trtcm.cir, tokens[10]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "cir");
+			return;
+		}
+
+		if (strcmp(tokens[11], "pir") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pir");
+			return;
+		}
+
+		if (parser_read_uint64(&p.trtcm.pir, tokens[12]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "pir");
+			return;
+		}
+		if (strcmp(tokens[13], "cbs") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cbs");
+			return;
+		}
+
+		if (parser_read_uint64(&p.trtcm.cbs, tokens[14]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "cbs");
+			return;
+		}
+
+		if (strcmp(tokens[15], "pbs") != 0) {
+			snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pbs");
+			return;
+		}
+
+		if (parser_read_uint64(&p.trtcm.pbs, tokens[16]) != 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID, "pbs");
+			return;
+		}
+	} else {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	status = pipeline_table_mtr_profile_add(pipeline_name,
+		table_id,
+		meter_profile_id,
+		&p);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
+ * pipeline <pipeline_name> table <table_id>
+ *  meter profile <meter_profile_id> delete
+ */
+static void
+cmd_pipeline_table_meter_profile_delete(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	char *pipeline_name;
+	uint32_t table_id, meter_profile_id;
+	int status;
+
+	if (n_tokens != 8) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "meter") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meter");
+		return;
+	}
+
+	if (strcmp(tokens[5], "profile") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "profile");
+		return;
+	}
+
+	if (parser_read_uint32(&meter_profile_id, tokens[6]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "meter_profile_id");
+		return;
+	}
+
+	if (strcmp(tokens[7], "delete") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "delete");
+		return;
+	}
+
+	status = pipeline_table_mtr_profile_delete(pipeline_name,
+		table_id,
+		meter_profile_id);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -3755,6 +3967,26 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 8) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "meter") == 0) &&
+			(strcmp(tokens[5], "profile") == 0) &&
+			(strcmp(tokens[7], "add") == 0)) {
+			cmd_pipeline_table_meter_profile_add(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
+
+		if ((n_tokens >= 8) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "meter") == 0) &&
+			(strcmp(tokens[5], "profile") == 0) &&
+			(strcmp(tokens[7], "delete") == 0)) {
+			cmd_pipeline_table_meter_profile_delete(tokens,
+				n_tokens, out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +11 -0
index 296e4da..d524145 100644
@@ -317,4 +317,15 @@ pipeline_table_rule_stats_read(const char *pipeline_name,
 	struct rte_table_action_stats_counters *stats,
 	int clear);
 
+int
+pipeline_table_mtr_profile_add(const char *pipeline_name,
+	uint32_t table_id,
+	uint32_t meter_profile_id,
+	struct rte_table_action_meter_profile *profile);
+
+int
+pipeline_table_mtr_profile_delete(const char *pipeline_name,
+	uint32_t table_id,
+	uint32_t meter_profile_id);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +144 -1

181 lines not on this page · raw message

Signature · 1 line
2.9.3
#136 lore raw

PATCH v2 36/44 ip_pipeline: add cli to read meter stats

In reply to Jasvinder Singh

Add command to read traffic meter stats.

---
 examples/ip_pipeline/cli.c      | 22 +++++++++++
 examples/ip_pipeline/pipeline.h |  8 ++++
 examples/ip_pipeline/thread.c   | 88 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 118 insertions(+)
examples/ip_pipeline/cli.c +22 -0
index ddc1dc5..a5a7c08 100644
@@ -3674,6 +3674,18 @@ cmd_pipeline_table_meter_profile_delete(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> table <table_id> rule read meter [clear]
+ */
+static void
+cmd_pipeline_table_rule_meter_read(char **tokens,
+	uint32_t n_tokens __rte_unused,
+	char *out,
+	size_t out_size)
+{
+	snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -3987,6 +3999,16 @@ cli_process(char *in, char *out, size_t out_size)
 				n_tokens, out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 7) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "rule") == 0) &&
+			(strcmp(tokens[5], "read") == 0) &&
+			(strcmp(tokens[6], "meter") == 0)) {
+			cmd_pipeline_table_rule_meter_read(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +8 -0
index d524145..4978555 100644
@@ -328,4 +328,12 @@ pipeline_table_mtr_profile_delete(const char *pipeline_name,
 	uint32_t table_id,
 	uint32_t meter_profile_id);
 
+int
+pipeline_table_rule_mtr_read(const char *pipeline_name,
+	uint32_t table_id,
+	void *data,
+	uint32_t tc_mask,
+	struct rte_table_action_mtr_counters *stats,
+	int clear);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +88 -0

136 lines not on this page · raw message

Signature · 1 line
2.9.3
#137 lore raw

PATCH v2 37/44 ip_pipeline: add cli to update dscp table

In reply to Jasvinder Singh

Add command to update the dscp table for traffic meter and traffic manager.

---
 examples/ip_pipeline/cli.c      | 154 ++++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/pipeline.h |   6 ++
 examples/ip_pipeline/thread.c   |  77 ++++++++++++++++++++
 3 files changed, 237 insertions(+)
examples/ip_pipeline/cli.c +154 -0
index a5a7c08..3d74ece 100644
@@ -3686,6 +3686,152 @@ cmd_pipeline_table_rule_meter_read(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> table <table_id> dscp <file_name>
+ *
+ * File <file_name>:
+ *  - exactly 64 lines
+ *  - line format: <tc_id> <tc_queue_id> <color>, with <color> as: g | y | r
+ */
+static int
+load_dscp_table(struct rte_table_action_dscp_table *dscp_table,
+	const char *file_name,
+	uint32_t *line_number)
+{
+	FILE *f = NULL;
+	uint32_t dscp, l;
+
+	/* Check input arguments */
+	if ((dscp_table == NULL) ||
+		(file_name == NULL) ||
+		(line_number == NULL)) {
+		if (line_number)
+			*line_number = 0;
+		return -EINVAL;
+	}
+
+	/* Open input file */
+	f = fopen(file_name, "r");
+	if (f == NULL) {
+		*line_number = 0;
+		return -EINVAL;
+	}
+
+	/* Read file */
+	for (dscp = 0, l = 1; ; l++) {
+		char line[64];
+		char *tokens[3];
+		enum rte_meter_color color;
+		uint32_t tc_id, tc_queue_id, n_tokens = RTE_DIM(tokens);
+
+		if (fgets(line, sizeof(line), f) == NULL)
+			break;
+
+		if (is_comment(line))
+			continue;
+
+		if (parse_tokenize_string(line, tokens, &n_tokens)) {
+			*line_number = l;
+			return -EINVAL;
+		}
+
+		if (n_tokens == 0)
+			continue;
+
+		if ((dscp >= RTE_DIM(dscp_table->entry)) ||
+			(n_tokens != RTE_DIM(tokens)) ||
+			parser_read_uint32(&tc_id, tokens[0]) ||
+			(tc_id >= RTE_TABLE_ACTION_TC_MAX) ||
+			parser_read_uint32(&tc_queue_id, tokens[1]) ||
+			(tc_queue_id >= RTE_TABLE_ACTION_TC_QUEUE_MAX) ||
+			(strlen(tokens[2]) != 1)) {
+			*line_number = l;
+			return -EINVAL;
+		}
+
+		switch (tokens[2][0]) {
+		case 'g':
+		case 'G':
+			color = e_RTE_METER_GREEN;
+			break;
+
+		case 'y':
+		case 'Y':
+			color = e_RTE_METER_YELLOW;
+			break;
+
+		case 'r':
+		case 'R':
+			color = e_RTE_METER_RED;
+			break;
+
+		default:
+			*line_number = l;
+			return -EINVAL;
+		}
+
+		dscp_table->entry[dscp].tc_id = tc_id;
+		dscp_table->entry[dscp].tc_queue_id = tc_queue_id;
+		dscp_table->entry[dscp].color = color;
+		dscp++;
+	}
+
+	/* Close file */
+	fclose(f);
+	return 0;
+}
+
+static void
+cmd_pipeline_table_dscp(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	struct rte_table_action_dscp_table dscp_table;
+	char *pipeline_name, *file_name;
+	uint32_t table_id, line_number;
+	int status;
+
+	if (n_tokens != 6) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	pipeline_name = tokens[1];
+
+	if (strcmp(tokens[2], "table") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "port");
+		return;
+	}
+
+	if (parser_read_uint32(&table_id, tokens[3]) != 0) {
+		snprintf(out, out_size, MSG_ARG_INVALID, "table_id");
+		return;
+	}
+
+	if (strcmp(tokens[4], "dscp") != 0) {
+		snprintf(out, out_size, MSG_ARG_NOT_FOUND, "dscp");
+		return;
+	}
+
+	file_name = tokens[5];
+
+	status = load_dscp_table(&dscp_table, file_name, &line_number);
+	if (status) {
+		snprintf(out, out_size, MSG_FILE_ERR, file_name, line_number);
+		return;
+	}
+
+	status = pipeline_table_dscp_table_update(pipeline_name,
+		table_id,
+		UINT64_MAX,
+		&dscp_table);
+	if (status) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -4009,6 +4155,14 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 5) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "dscp") == 0)) {
+			cmd_pipeline_table_dscp(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +6 -0
index 4978555..598bed0 100644
@@ -336,4 +336,10 @@ pipeline_table_rule_mtr_read(const char *pipeline_name,
 	struct rte_table_action_mtr_counters *stats,
 	int clear);
 
+int
+pipeline_table_dscp_table_update(const char *pipeline_name,
+	uint32_t table_id,
+	uint64_t dscp_mask,
+	struct rte_table_action_dscp_table *dscp_table);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +77 -0

113 lines not on this page · raw message

Signature · 1 line
2.9.3
#138 lore raw

PATCH v2 38/44 ip_pipeline: add cli to read ttl stats

In reply to Jasvinder Singh

Add command to read the ttl stats.

---
 examples/ip_pipeline/cli.c      | 22 +++++++++++
 examples/ip_pipeline/pipeline.h |  7 ++++
 examples/ip_pipeline/thread.c   | 84 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 113 insertions(+)
examples/ip_pipeline/cli.c +22 -0
index 3d74ece..a4965a6 100644
@@ -3832,6 +3832,18 @@ cmd_pipeline_table_dscp(char **tokens,
 }
 
 /**
+ * pipeline <pipeline_name> table <table_id> rule read ttl [clear]
+ */
+static void
+cmd_pipeline_table_rule_ttl_read(char **tokens,
+	uint32_t n_tokens __rte_unused,
+	char *out,
+	size_t out_size)
+{
+	snprintf(out, out_size, MSG_CMD_UNIMPLEM, tokens[0]);
+}
+
+/**
  * thread <thread_id> pipeline <pipeline_name> enable
  */
 static void
@@ -4163,6 +4175,16 @@ cli_process(char *in, char *out, size_t out_size)
 				out, out_size);
 			return;
 		}
+
+		if ((n_tokens >= 7) &&
+			(strcmp(tokens[2], "table") == 0) &&
+			(strcmp(tokens[4], "rule") == 0) &&
+			(strcmp(tokens[5], "read") == 0) &&
+			(strcmp(tokens[6], "ttl") == 0)) {
+			cmd_pipeline_table_rule_ttl_read(tokens, n_tokens,
+				out, out_size);
+			return;
+		}
 	}
 
 	if (strcmp(tokens[0], "thread") == 0) {
examples/ip_pipeline/pipeline.h +7 -0
index 598bed0..208e407 100644
@@ -342,4 +342,11 @@ pipeline_table_dscp_table_update(const char *pipeline_name,
 	uint64_t dscp_mask,
 	struct rte_table_action_dscp_table *dscp_table);
 
+int
+pipeline_table_rule_ttl_read(const char *pipeline_name,
+	uint32_t table_id,
+	void *data,
+	struct rte_table_action_ttl_counters *stats,
+	int clear);
+
 #endif /* _INCLUDE_PIPELINE_H_ */
examples/ip_pipeline/thread.c +84 -0

132 lines not on this page · raw message

Signature · 1 line
2.9.3
#139 lore raw

PATCH v2 39/44 ip_pipeline: add l2fwd example

In reply to Jasvinder Singh

This patch add the configuration file for l2fwd example. It includes commands to build the packet processing stage (pipeline), defining action, add rules to its table, etc.

---
 examples/ip_pipeline/examples/l2fwd.cli | 53 +++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 examples/ip_pipeline/examples/l2fwd.cli
examples/ip_pipeline/examples/l2fwd.cli new file +53 -0
new file mode 100644
index 0000000..5b9d529
@@ -0,0 +1,53 @@
+; SPDX-License-Identifier: BSD-3-Clause
+; Copyright(c) 2010-2018 Intel Corporation
+
+; The pipeline below implements a simple pass-through connection between the
+; input ports to the output ports, as in this diagram:
+;                 ________________
+; LINK0 RXQ0 --->|................|---> LINK1 TXQ0
+;                |                |
+; LINK1 RXQ0 --->|................|---> LINK0 TXQ0
+;                |    PIPELINE0   |
+; LINK2 RXQ0 --->|................|---> LINK3 TXQ0
+;                |                |
+; LINK3 RXQ0 --->|................|---> LINK2 TXQ0
+;                |________________|
+;
+
+mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+
+link LINK0 dev 0000:02:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK1 dev 0000:02:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK2 dev 0000:06:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK3 dev 0000:06:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+
+table action profile AP0 ipv4 offset 270 fwd
+
+pipeline PIPELINE0 period 10 offset_port_id 0 cpu 0
+
+pipeline PIPELINE0 port in bsz 32 link LINK0 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK1 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK2 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK3 rxq 0
+
+pipeline PIPELINE0 port out bsz 32 link LINK0 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK1 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK2 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK3 txq 0
+
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+
+pipeline PIPELINE0 port in 0 table 0
+pipeline PIPELINE0 port in 1 table 1
+pipeline PIPELINE0 port in 2 table 2
+pipeline PIPELINE0 port in 3 table 3
+
+thread 1 pipeline PIPELINE0 enable
+
+pipeline PIPELINE0 table 0 rule add match default action fwd port 1
+pipeline PIPELINE0 table 1 rule add match default action fwd port 0
+pipeline PIPELINE0 table 2 rule add match default action fwd port 3
+pipeline PIPELINE0 table 3 rule add match default action fwd port 2
Signature · 1 line
2.9.3
#140 lore raw

PATCH v2 40/44 ip_pipeline: add KNI port example

In reply to Jasvinder Singh

Add example to illustrate the pipeline functioning with KNI interface.

---
 examples/ip_pipeline/examples/kni.cli | 69 +++++++++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 examples/ip_pipeline/examples/kni.cli
examples/ip_pipeline/examples/kni.cli new file +69 -0
new file mode 100644
index 0000000..1438340
@@ -0,0 +1,69 @@
+; SPDX-License-Identifier: BSD-3-Clause
+; Copyright(c) 2010-2018 Intel Corporation
+
+;                 _______________          ______________________
+;                |               |  KNI0  |                      |
+; LINK0 RXQ0 --->|...............|------->|--+                   |
+;                |               |  KNI1  |  | br0               |
+; LINK1 TXQ0 <---|...............|<-------|<-+                   |
+;                |               |        |     Linux Kernel     |
+;                |   PIPELINE0   |        |     Network Stack    |
+;                |               |  KNI1  |                      |
+; LINK1 RXQ0 --->|...............|------->|--+                   |
+;                |               |  KNI0  |  | br0               |
+; LINK0 TXQ0 <---|...............|<-------|<-+                   |
+;                |_______________|        |______________________|
+;
+; Insert Linux kernel KNI module:
+;    [Linux]$ insmod rte_kni.ko
+;
+; Configure Linux kernel bridge between KNI0 and KNI1 interfaces:
+;    [Linux]$ brctl addbr br0
+;    [Linux]$ brctl addif br0 KNI0
+;    [Linux]$ brctl addif br0 KNI1
+;    [Linux]$ ifconfig br0 up
+;    [Linux]$ ifconfig KNI0 up
+;    [Linux]$ ifconfig KNI1 up
+;
+; Monitor packet forwarding performed by Linux kernel between KNI0 and KNI1:
+;    [Linux]$ tcpdump -i KNI0
+;    [Linux]$ tcpdump -i KNI1
+
+mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+
+link LINK0 dev 0000:02:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK1 dev 0000:02:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+
+kni KNI0 link LINK0 mempool MEMPOOL0
+kni KNI1 link LINK1 mempool MEMPOOL0
+
+table action profile AP0 ipv4 offset 270 fwd
+
+pipeline PIPELINE0 period 10 offset_port_id 0 cpu 0
+
+pipeline PIPELINE0 port in bsz 32 link LINK0 rxq 0
+pipeline PIPELINE0 port in bsz 32 kni KNI1
+pipeline PIPELINE0 port in bsz 32 link LINK1 rxq 0
+pipeline PIPELINE0 port in bsz 32 kni KNI0
+
+pipeline PIPELINE0 port out bsz 32 kni KNI0
+pipeline PIPELINE0 port out bsz 32 link LINK1 txq 0
+pipeline PIPELINE0 port out bsz 32 kni KNI1
+pipeline PIPELINE0 port out bsz 32 link LINK0 txq 0
+
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+
+pipeline PIPELINE0 port in 0 table 0
+pipeline PIPELINE0 port in 1 table 1
+pipeline PIPELINE0 port in 2 table 2
+pipeline PIPELINE0 port in 3 table 3
+
+thread 1 pipeline PIPELINE0 enable
+
+pipeline PIPELINE0 table 0 rule add match default action fwd port 0
+pipeline PIPELINE0 table 1 rule add match default action fwd port 1
+pipeline PIPELINE0 table 2 rule add match default action fwd port 2
+pipeline PIPELINE0 table 3 rule add match default action fwd port 3
Signature · 1 line
2.9.3
#141 lore raw

PATCH v2 41/44 ip_pipeline: add TAP port example

In reply to Jasvinder Singh

Add example to illustrate the pipeline functioning with TAP interface.

---
 examples/ip_pipeline/examples/tap.cli | 66 +++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 examples/ip_pipeline/examples/tap.cli
examples/ip_pipeline/examples/tap.cli new file +66 -0
new file mode 100644
index 0000000..600cea2
@@ -0,0 +1,66 @@
+; SPDX-License-Identifier: BSD-3-Clause
+; Copyright(c) 2010-2018 Intel Corporation
+
+;                 _______________          ______________________
+;                |               |  TAP0  |                      |
+; LINK0 RXQ0 --->|...............|------->|--+                   |
+;                |               |  TAP1  |  | br0               |
+; LINK1 TXQ0 <---|...............|<-------|<-+                   |
+;                |               |        |     Linux Kernel     |
+;                |   PIPELINE0   |        |     Network Stack    |
+;                |               |  TAP1  |                      |
+; LINK1 RXQ0 --->|...............|------->|--+                   |
+;                |               |  TAP0  |  | br0               |
+; LINK0 TXQ0 <---|...............|<-------|<-+                   |
+;                |_______________|        |______________________|
+;
+; Configure Linux kernel bridge between TAP0 and TAP1 interfaces:
+;    [Linux]$ brctl addbr br0
+;    [Linux]$ brctl addif br0 TAP0
+;    [Linux]$ brctl addif br0 TAP1
+;    [Linux]$ ifconfig TAP0 up
+;    [Linux]$ ifconfig TAP1 up
+;    [Linux]$ ifconfig br0 up
+;
+; Monitor packet forwarding performed by Linux kernel between TAP0 and TAP1:
+;    [Linux]$ tcpdump -i TAP0
+;    [Linux]$ tcpdump -i TAP1
+
+mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+
+link LINK0 dev 0000:02:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK1 dev 0000:02:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+
+tap TAP0
+tap TAP1
+
+table action profile AP0 ipv4 offset 270 fwd
+
+pipeline PIPELINE0 period 10 offset_port_id 0 cpu 0
+
+pipeline PIPELINE0 port in bsz 32 link LINK0 rxq 0
+pipeline PIPELINE0 port in bsz 32 tap TAP1 mempool MEMPOOL0 mtu 1500
+pipeline PIPELINE0 port in bsz 32 link LINK1 rxq 0
+pipeline PIPELINE0 port in bsz 32 tap TAP0 mempool MEMPOOL0 mtu 1500
+
+pipeline PIPELINE0 port out bsz 32 tap TAP0
+pipeline PIPELINE0 port out bsz 32 link LINK1 txq 0
+pipeline PIPELINE0 port out bsz 32 tap TAP1
+pipeline PIPELINE0 port out bsz 32 link LINK0 txq 0
+
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+pipeline PIPELINE0 table match stub action AP0
+
+pipeline PIPELINE0 port in 0 table 0
+pipeline PIPELINE0 port in 1 table 1
+pipeline PIPELINE0 port in 2 table 2
+pipeline PIPELINE0 port in 3 table 3
+
+thread 1 pipeline PIPELINE0 enable
+
+pipeline PIPELINE0 table 0 rule add match default action fwd port 0
+pipeline PIPELINE0 table 1 rule add match default action fwd port 1
+pipeline PIPELINE0 table 2 rule add match default action fwd port 2
+pipeline PIPELINE0 table 3 rule add match default action fwd port 3
Signature · 1 line
2.9.3
#142 lore raw

PATCH v2 42/44 ip_pipeline: add route example

In reply to Jasvinder Singh

Add example to built pipeline with LPM table to demonstrate layer 3 routing.

---
 examples/ip_pipeline/examples/route.cli | 60 +++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 examples/ip_pipeline/examples/route.cli
examples/ip_pipeline/examples/route.cli new file +60 -0
new file mode 100644
index 0000000..50f0a10
@@ -0,0 +1,60 @@
+; SPDX-License-Identifier: BSD-3-Clause
+; Copyright(c) 2010-2018 Intel Corporation
+
+;                 _______________
+; LINK0 RXQ0 --->|               |---> LINK0 TXQ0
+;                |               |
+; LINK1 RXQ0 --->|               |---> LINK1 TXQ0
+;                |    Routing    |
+; LINK2 RXQ0 --->|               |---> LINK2 TXQ0
+;                |               |
+; LINK3 RXQ0 --->|               |---> LINK3 TXQ0
+;                |_______________|
+;                        |
+;                        +-----------> SINK0 (route miss)
+;
+; Input packet: Ethernet/IPv4
+;
+; Packet buffer layout:
+; #   Field Name       Offset (Bytes)   Size (Bytes)
+; 0   Mbuf             0                128
+; 1   Headroom         128              128
+; 2   Ethernet header  256              14
+; 3   IPv4 header      270              20
+
+mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+
+link LINK0 dev 0000:02:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK1 dev 0000:02:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK2 dev 0000:06:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK3 dev 0000:06:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+
+table action profile AP0 ipv4 offset 270 fwd encap ether
+
+pipeline PIPELINE0 period 10 offset_port_id 0 cpu 0
+
+pipeline PIPELINE0 port in bsz 32 link LINK0 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK1 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK2 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK3 rxq 0
+
+pipeline PIPELINE0 port out bsz 32 link LINK0 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK1 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK2 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK3 txq 0
+pipeline PIPELINE0 port out bsz 32 sink SINK0
+
+pipeline PIPELINE0 table match lpm ipv4 offset 286 size 4K action AP0
+
+pipeline PIPELINE0 port in 0 table 0
+pipeline PIPELINE0 port in 1 table 0
+pipeline PIPELINE0 port in 2 table 0
+pipeline PIPELINE0 port in 3 table 0
+
+thread 1 pipeline PIPELINE0 enable
+
+pipeline PIPELINE0 table 0 rule add match default action fwd port 4
+pipeline PIPELINE0 table 0 rule add match lpm ipv4 100.0.0.0 10 action fwd port 0 encap ether a0:a1:a2:a3:a4:a5 00:01:02:03:04:05
+pipeline PIPELINE0 table 0 rule add match lpm ipv4 100.64.0.0 10 action fwd port 1 encap ether b0:b1:b2:b3:b4:b5 10:11:12:13:14:15
+pipeline PIPELINE0 table 0 rule add match lpm ipv4 100.128.0.0 10 action fwd port 2 encap ether c0:c1:c2:c3:c4:c5 20:21:22:23:24:25
+pipeline PIPELINE0 table 0 rule add match lpm ipv4 100.192.0.0 10 action fwd port 3 encap ether d0:d1:d2:d3:d4:d5 30:31:32:33:34:35
Signature · 1 line
2.9.3
#143 lore raw

PATCH v2 43/44 ip_pipeline: add firewall example

In reply to Jasvinder Singh

Add example to built pipeline with ACL table to demonstrate the firewall operation.

---
 examples/ip_pipeline/examples/firewall.cli | 59 ++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 examples/ip_pipeline/examples/firewall.cli
examples/ip_pipeline/examples/firewall.cli new file +59 -0
new file mode 100644
index 0000000..269256c
@@ -0,0 +1,59 @@
+; SPDX-License-Identifier: BSD-3-Clause
+; Copyright(c) 2010-2018 Intel Corporation
+
+;                 _______________
+; LINK0 RXQ0 --->|               |---> LINK0 TXQ0
+;                |               |
+; LINK1 RXQ0 --->|               |---> LINK1 TXQ0
+;                |   Firewall    |
+; LINK2 RXQ0 --->|               |---> LINK2 TXQ0
+;                |               |
+; LINK3 RXQ0 --->|               |---> LINK3 TXQ0
+;                |_______________|
+;                        |
+;                       -+-
+;
+; Input packet: Ethernet/IPv4
+;
+; Packet buffer layout:
+; #   Field Name            Offset (Bytes)      Size (Bytes)
+; 0   Mbuf                  0                   128
+; 1   Headroom              128                 128
+; 2   Ethernet header       256                 14
+; 3   IPv4 header           270                 20
+
+mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+
+link LINK0 dev 0000:02:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK1 dev 0000:02:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK2 dev 0000:06:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK3 dev 0000:06:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+
+table action profile AP0 ipv4 offset 270 fwd
+
+pipeline PIPELINE0 period 10 offset_port_id 0 cpu 0
+
+pipeline PIPELINE0 port in bsz 32 link LINK0 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK1 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK2 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK3 rxq 0
+
+pipeline PIPELINE0 port out bsz 32 link LINK0 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK1 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK2 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK3 txq 0
+
+pipeline PIPELINE0 table match acl ipv4 offset 270 size 4K action AP0
+
+pipeline PIPELINE0 port in 0 table 0
+pipeline PIPELINE0 port in 1 table 0
+pipeline PIPELINE0 port in 2 table 0
+pipeline PIPELINE0 port in 3 table 0
+
+thread 1 pipeline PIPELINE0 enable
+
+pipeline PIPELINE0 table 0 rule add match default action fwd drop
+pipeline PIPELINE0 table 0 rule add match acl priority 0 ipv4 0.0.0.0 0 100.0.0.0 10 0 65535 0 65535 6 action fwd port 0
+pipeline PIPELINE0 table 0 rule add match acl priority 0 ipv4 0.0.0.0 0 100.64.0.0 10 0 65535 0 65535 6 action fwd port 1
+pipeline PIPELINE0 table 0 rule add match acl priority 0 ipv4 0.0.0.0 0 100.128.0.0 10 0 65535 0 65535 6 action fwd port 2
+pipeline PIPELINE0 table 0 rule add match acl priority 0 ipv4 0.0.0.0 0 100.192.0.0 10 0 65535 0 65535 6 action fwd port 3
Signature · 1 line
2.9.3
#144 lore raw

PATCH v2 44/44 ip_pipeline: add flow classification example

In reply to Jasvinder Singh

Add example to build pipeline with hash table to classify the ingress traffic.

---
 examples/ip_pipeline/examples/flow.cli | 60 ++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 examples/ip_pipeline/examples/flow.cli
examples/ip_pipeline/examples/flow.cli new file +60 -0
new file mode 100644
index 0000000..60b8445
@@ -0,0 +1,60 @@
+; SPDX-License-Identifier: BSD-3-Clause
+; Copyright(c) 2010-2018 Intel Corporation
+
+;                 ________________
+; LINK0 RXQ0 --->|                |---> LINK0 TXQ0
+;                |                |
+; LINK1 RXQ0 --->|                |---> LINK1 TXQ0
+;                |      Flow      |
+; LINK2 RXQ0 --->| Classification |---> LINK2 TXQ0
+;                |                |
+; LINK3 RXQ0 --->|                |---> LINK3 TXQ0
+;                |________________|
+;                        |
+;                        +-----------> SINK0 (flow lookup miss)
+;
+; Input packet: Ethernet/IPv4
+;
+; Packet buffer layout:
+; #   Field Name       Offset (Bytes)   Size (Bytes)
+; 0   Mbuf             0                128
+; 1   Headroom         128              128
+; 2   Ethernet header  256              14
+; 3   IPv4 header      270              20
+
+mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+
+link LINK0 dev 0000:02:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK1 dev 0000:02:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK2 dev 0000:06:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK3 dev 0000:06:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+
+table action profile AP0 ipv4 offset 270 fwd
+
+pipeline PIPELINE0 period 10 offset_port_id 0 cpu 0
+
+pipeline PIPELINE0 port in bsz 32 link LINK0 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK1 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK2 rxq 0
+pipeline PIPELINE0 port in bsz 32 link LINK3 rxq 0
+
+pipeline PIPELINE0 port out bsz 32 link LINK0 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK1 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK2 txq 0
+pipeline PIPELINE0 port out bsz 32 link LINK3 txq 0
+pipeline PIPELINE0 port out bsz 32 sink SINK0
+
+pipeline PIPELINE0 table match hash ext key 16 mask 00FF0000FFFFFFFFFFFFFFFFFFFFFFFF offset 278 buckets 16K size 65K action AP0
+
+pipeline PIPELINE0 port in 0 table 0
+pipeline PIPELINE0 port in 1 table 0
+pipeline PIPELINE0 port in 2 table 0
+pipeline PIPELINE0 port in 3 table 0
+
+thread 1 pipeline PIPELINE0 enable
+
+pipeline PIPELINE0 table 0 rule add match default action fwd port 4
+pipeline PIPELINE0 table 0 rule add match hash ipv4_5tuple 100.0.0.10 200.0.0.10 100 200 6 action fwd port 0
+pipeline PIPELINE0 table 0 rule add match hash ipv4_5tuple 100.0.0.11 200.0.0.11 101 201 6 action fwd port 1
+pipeline PIPELINE0 table 0 rule add match hash ipv4_5tuple 100.0.0.12 200.0.0.12 102 202 6 action fwd port 2
+pipeline PIPELINE0 table 0 rule add match hash ipv4_5tuple 100.0.0.13 200.0.0.13 103 203 6 action fwd port 3
Signature · 1 line
2.9.3
#145 lore raw

PATCH 2/37 pipeline: get pipeline table action params

In reply to Jasvinder Singh

Add API to specify action related parameters such as action handler, table entry data size, etc. for the pipeline table.

---
 lib/librte_pipeline/rte_pipeline_version.map |   1 +
 lib/librte_pipeline/rte_table_action.c       | 132 ++++++++++++++++++++++++++-
 lib/librte_pipeline/rte_table_action.h       |  14 +++
 3 files changed, 146 insertions(+), 1 deletion(-)
lib/librte_pipeline/rte_pipeline_version.map +1 -0
index 4bc414c..13337de 100644
@@ -56,5 +56,6 @@ EXPERIMENTAL {
 	rte_table_action_profile_create;
 	rte_table_action_profile_free;
 	rte_table_action_profile_freeze;
+	rte_table_action_table_params_get;
 
 } DPDK_16.04;
lib/librte_pipeline/rte_table_action.c +131 -1

142 lines not on this page · raw message

lib/librte_pipeline/rte_table_action.h +14 -0
index da7f12c..03b77ca 100644
@@ -194,6 +194,20 @@ int __rte_experimental
 rte_table_action_free(struct rte_table_action *action);
 
 /**
+ * Table action table params get.
+ *
+ * @param[in] action
+ *   Handle to table action object (needs to be valid).
+ * @param[inout] params
+ *   Pipeline table parameters (needs to be pre-allocated).
+ * @return
+ *   Zero on success, non-zero error code otherwise.
+ */
+int __rte_experimental
+rte_table_action_table_params_get(struct rte_table_action *action,
+	struct rte_pipeline_table_params *params);
+
+/**
  * Table action apply.
  *
  * @param[in] action
Signature · 1 line
2.9.3
#146 lore raw

PATCH 3/37 pipeline: add traffic metering action

In reply to Jasvinder Singh

Add traffic metering action implementation.

---
 lib/librte_pipeline/Makefile                 |   3 +-
 lib/librte_pipeline/meson.build              |   2 +-
 lib/librte_pipeline/rte_pipeline_version.map |   4 +
 lib/librte_pipeline/rte_table_action.c       | 638 ++++++++++++++++++++++++++-
 lib/librte_pipeline/rte_table_action.h       | 248 +++++++++++
 5 files changed, 877 insertions(+), 18 deletions(-)
lib/librte_pipeline/Makefile +2 -1
index e8c43c7..72e4c7c 100644
@@ -8,10 +8,11 @@ include $(RTE_SDK)/mk/rte.vars.mk
 #
 LIB = librte_pipeline.a
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 LDLIBS += -lrte_eal -lrte_mempool -lrte_mbuf -lrte_table
-LDLIBS += -lrte_port
+LDLIBS += -lrte_port -lrte_meter
 
 EXPORT_MAP := rte_pipeline_version.map
 
lib/librte_pipeline/meson.build +1 -1
index 4dda560..71da295 100644
@@ -5,4 +5,4 @@ version = 3
 allow_experimental_apis = true
 sources = files('rte_pipeline.c', 'rte_table_action.c')
 headers = files('rte_pipeline.h', 'rte_table_action.h')
-deps += ['port', 'table']
+deps += ['port', 'table', 'meter']
lib/librte_pipeline/rte_pipeline_version.map +4 -0
index 13337de..c7106dc 100644
@@ -51,7 +51,11 @@ EXPERIMENTAL {
 
 	rte_table_action_apply;
 	rte_table_action_create;
+	rte_table_action_dscp_table_update;
 	rte_table_action_free;
+	rte_table_action_meter_profile_add;
+	rte_table_action_meter_profile_delete;
+	rte_table_action_meter_read;
 	rte_table_action_profile_action_register;
 	rte_table_action_profile_create;
 	rte_table_action_profile_free;
lib/librte_pipeline/rte_table_action.c +622 -16

739 lines not on this page · raw message

lib/librte_pipeline/rte_table_action.h +248 -0

272 lines not on this page · raw message

Signature · 1 line
2.9.3
#147 lore raw

PATCH 4/37 pipeline: add traffic manager action

In reply to Jasvinder Singh

Add implementation of traffic manager action.

---
 lib/librte_pipeline/Makefile           |   2 +-
 lib/librte_pipeline/meson.build        |   2 +-
 lib/librte_pipeline/rte_table_action.c | 130 ++++++++++++++++++++++++++++++++-
 lib/librte_pipeline/rte_table_action.h |  24 ++++++
 4 files changed, 155 insertions(+), 3 deletions(-)
lib/librte_pipeline/Makefile +1 -1
index 72e4c7c..c0eaa09 100644
@@ -12,7 +12,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 LDLIBS += -lrte_eal -lrte_mempool -lrte_mbuf -lrte_table
-LDLIBS += -lrte_port -lrte_meter
+LDLIBS += -lrte_port -lrte_meter -lrte_sched
 
 EXPORT_MAP := rte_pipeline_version.map
 
lib/librte_pipeline/meson.build +1 -1
index 71da295..1ee276f 100644
@@ -5,4 +5,4 @@ version = 3
 allow_experimental_apis = true
 sources = files('rte_pipeline.c', 'rte_table_action.c')
 headers = files('rte_pipeline.h', 'rte_table_action.h')
-deps += ['port', 'table', 'meter']
+deps += ['port', 'table', 'meter', 'sched']
lib/librte_pipeline/rte_table_action.c +129 -1

196 lines not on this page · raw message

lib/librte_pipeline/rte_table_action.h +24 -0
index c2f4a55..98babc5 100644
@@ -70,6 +70,9 @@ enum rte_table_action_type {
 
 	/**  Traffic Metering and Policing. */
 	RTE_TABLE_ACTION_MTR,
+
+	/**  Traffic Management. */
+	RTE_TABLE_ACTION_TM,
 };
 
 /** Common action configuration (per table action profile). */
@@ -256,6 +259,27 @@ struct rte_table_action_mtr_counters {
 };
 
 /**
+ * RTE_TABLE_ACTION_TM
+ */
+/** Traffic management action configuration (per table action profile). */
+struct rte_table_action_tm_config {
+	/** Number of subports per port. */
+	uint32_t n_subports_per_port;
+
+	/** Number of pipes per subport. */
+	uint32_t n_pipes_per_subport;
+};
+
+/** Traffic management action parameters (per table rule). */
+struct rte_table_action_tm_params {
+	/** Subport ID. */
+	uint32_t subport_id;
+
+	/** Pipe ID. */
+	uint32_t pipe_id;
+};
+
+/**
  * Table action profile.
  */
 struct rte_table_action_profile;
Signature · 1 line
2.9.3
#148 lore raw

PATCH 5/37 pipeline: add packet encapsulation action

In reply to Jasvinder Singh

Add implementation of different type of packet encap such as vlan, qinq, mpls, pppoe, etc.

---
 lib/librte_pipeline/rte_table_action.c | 440 ++++++++++++++++++++++++++++++++-
 lib/librte_pipeline/rte_table_action.h | 129 ++++++++++
 2 files changed, 568 insertions(+), 1 deletion(-)
lib/librte_pipeline/rte_table_action.c +439 -1
index 09016d1..a3c1546 100644
@@ -9,8 +9,12 @@
 #include <rte_byteorder.h>
 #include <rte_cycles.h>
 #include <rte_malloc.h>
+#include <rte_memcpy.h>
+#include <rte_ether.h>
 #include <rte_ip.h>
-
+#include <rte_esp.h>
+#include <rte_tcp.h>
+#include <rte_udp.h>
 
 #include "rte_table_action.h"
 
@@ -364,6 +368,369 @@ pkt_work_tm(struct rte_mbuf *mbuf,
 }
 
 /**
+ * RTE_TABLE_ACTION_ENCAP
+ */
+static int
+encap_valid(enum rte_table_action_encap_type encap)
+{
+	switch (encap) {
+	case RTE_TABLE_ACTION_ENCAP_ETHER:
+	case RTE_TABLE_ACTION_ENCAP_VLAN:
+	case RTE_TABLE_ACTION_ENCAP_QINQ:
+	case RTE_TABLE_ACTION_ENCAP_MPLS:
+	case RTE_TABLE_ACTION_ENCAP_PPPOE:
+		return 1;
+	default:
+		return 0;
+	}
+}
+
+static int
+encap_cfg_check(struct rte_table_action_encap_config *encap)
+{
+	if ((encap->encap_mask == 0) ||
+		(__builtin_popcountll(encap->encap_mask) != 1))
+		return -ENOTSUP;
+
+	return 0;
+}
+
+struct encap_ether_data {
+	struct ether_hdr ether;
+} __attribute__((__packed__));
+
+#define VLAN(pcp, dei, vid)                                \
+	((uint16_t)((((uint64_t)(pcp)) & 0x7LLU) << 13) |  \
+	((((uint64_t)(dei)) & 0x1LLU) << 12) |             \
+	(((uint64_t)(vid)) & 0xFFFLLU))                    \
+
+struct encap_vlan_data {
+	struct ether_hdr ether;
+	struct vlan_hdr vlan;
+} __attribute__((__packed__));
+
+struct encap_qinq_data {
+	struct ether_hdr ether;
+	struct vlan_hdr svlan;
+	struct vlan_hdr cvlan;
+} __attribute__((__packed__));
+
+#define ETHER_TYPE_MPLS_UNICAST                            0x8847
+
+#define ETHER_TYPE_MPLS_MULTICAST                          0x8848
+
+#define MPLS(label, tc, s, ttl)                            \
+	((uint32_t)(((((uint64_t)(label)) & 0xFFFFFLLU) << 12) |\
+	((((uint64_t)(tc)) & 0x7LLU) << 9) |               \
+	((((uint64_t)(s)) & 0x1LLU) << 8) |                \
+	(((uint64_t)(ttl)) & 0xFFLLU)))
+
+struct encap_mpls_data {
+	struct ether_hdr ether;
+	uint32_t mpls[RTE_TABLE_ACTION_MPLS_LABELS_MAX];
+	uint32_t mpls_count;
+} __attribute__((__packed__));
+
+#define ETHER_TYPE_PPPOE_SESSION                           0x8864
+
+#define PPP_PROTOCOL_IP                                    0x0021
+
+struct pppoe_ppp_hdr {
+	uint16_t ver_type_code;
+	uint16_t session_id;
+	uint16_t length;
+	uint16_t protocol;
+} __attribute__((__packed__));
+
+struct encap_pppoe_data {
+	struct ether_hdr ether;
+	struct pppoe_ppp_hdr pppoe_ppp;
+} __attribute__((__packed__));
+
+static size_t
+encap_data_size(struct rte_table_action_encap_config *encap)
+{
+	switch (encap->encap_mask) {
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_ETHER:
+		return sizeof(struct encap_ether_data);
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_VLAN:
+		return sizeof(struct encap_vlan_data);
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_QINQ:
+		return sizeof(struct encap_qinq_data);
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_MPLS:
+		return sizeof(struct encap_mpls_data);
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_PPPOE:
+		return sizeof(struct encap_pppoe_data);
+
+	default:
+		return 0;
+	}
+}
+
+static int
+encap_apply_check(struct rte_table_action_encap_params *p,
+	struct rte_table_action_encap_config *cfg)
+{
+	if ((encap_valid(p->type) == 0) ||
+		((cfg->encap_mask & (1LLU << p->type)) == 0))
+		return -EINVAL;
+
+	switch (p->type) {
+	case RTE_TABLE_ACTION_ENCAP_ETHER:
+		return 0;
+
+	case RTE_TABLE_ACTION_ENCAP_VLAN:
+		return 0;
+
+	case RTE_TABLE_ACTION_ENCAP_QINQ:
+		return 0;
+
+	case RTE_TABLE_ACTION_ENCAP_MPLS:
+		if ((p->mpls.mpls_count == 0) ||
+			(p->mpls.mpls_count > RTE_TABLE_ACTION_MPLS_LABELS_MAX))
+			return -EINVAL;
+
+		return 0;
+
+	case RTE_TABLE_ACTION_ENCAP_PPPOE:
+		return 0;
+
+	default:
+		return -EINVAL;
+	}
+}
+
+static int
+encap_ether_apply(void *data,
+	struct rte_table_action_encap_params *p,
+	struct rte_table_action_common_config *common_cfg)
+{
+	struct encap_ether_data *d = data;
+	uint16_t ethertype = (common_cfg->ip_version) ?
+		ETHER_TYPE_IPv4 :
+		ETHER_TYPE_IPv6;
+
+	/* Ethernet */
+	ether_addr_copy(&p->ether.ether.da, &d->ether.d_addr);
+	ether_addr_copy(&p->ether.ether.sa, &d->ether.s_addr);
+	d->ether.ether_type = rte_htons(ethertype);
+
+	return 0;
+}
+
+static int
+encap_vlan_apply(void *data,
+	struct rte_table_action_encap_params *p,
+	struct rte_table_action_common_config *common_cfg)
+{
+	struct encap_vlan_data *d = data;
+	uint16_t ethertype = (common_cfg->ip_version) ?
+		ETHER_TYPE_IPv4 :
+		ETHER_TYPE_IPv6;
+
+	/* Ethernet */
+	ether_addr_copy(&p->vlan.ether.da, &d->ether.d_addr);
+	ether_addr_copy(&p->vlan.ether.sa, &d->ether.s_addr);
+	d->ether.ether_type = rte_htons(ETHER_TYPE_VLAN);
+
+	/* VLAN */
+	d->vlan.vlan_tci = rte_htons(VLAN(p->vlan.vlan.pcp,
+		p->vlan.vlan.dei,
+		p->vlan.vlan.vid));
+	d->vlan.eth_proto = rte_htons(ethertype);
+
+	return 0;
+}
+
+static int
+encap_qinq_apply(void *data,
+	struct rte_table_action_encap_params *p,
+	struct rte_table_action_common_config *common_cfg)
+{
+	struct encap_qinq_data *d = data;
+	uint16_t ethertype = (common_cfg->ip_version) ?
+		ETHER_TYPE_IPv4 :
+		ETHER_TYPE_IPv6;
+
+	/* Ethernet */
+	ether_addr_copy(&p->qinq.ether.da, &d->ether.d_addr);
+	ether_addr_copy(&p->qinq.ether.sa, &d->ether.s_addr);
+	d->ether.ether_type = rte_htons(ETHER_TYPE_QINQ);
+
+	/* SVLAN */
+	d->svlan.vlan_tci = rte_htons(VLAN(p->qinq.svlan.pcp,
+		p->qinq.svlan.dei,
+		p->qinq.svlan.vid));
+	d->svlan.eth_proto = rte_htons(ETHER_TYPE_VLAN);
+
+	/* CVLAN */
+	d->cvlan.vlan_tci = rte_htons(VLAN(p->qinq.cvlan.pcp,
+		p->qinq.cvlan.dei,
+		p->qinq.cvlan.vid));
+	d->cvlan.eth_proto = rte_htons(ethertype);
+
+	return 0;
+}
+
+static int
+encap_mpls_apply(void *data,
+	struct rte_table_action_encap_params *p)
+{
+	struct encap_mpls_data *d = data;
+	uint16_t ethertype = (p->mpls.unicast) ?
+		ETHER_TYPE_MPLS_UNICAST :
+		ETHER_TYPE_MPLS_MULTICAST;
+	uint32_t i;
+
+	/* Ethernet */
+	ether_addr_copy(&p->mpls.ether.da, &d->ether.d_addr);
+	ether_addr_copy(&p->mpls.ether.sa, &d->ether.s_addr);
+	d->ether.ether_type = rte_htons(ethertype);
+
+	/* MPLS */
+	for (i = 0; i < p->mpls.mpls_count - 1; i++)
+		d->mpls[i] = rte_htonl(MPLS(p->mpls.mpls[i].label,
+			p->mpls.mpls[i].tc,
+			0,
+			p->mpls.mpls[i].ttl));
+
+	d->mpls[i] = rte_htonl(MPLS(p->mpls.mpls[i].label,
+		p->mpls.mpls[i].tc,
+		1,
+		p->mpls.mpls[i].ttl));
+
+	d->mpls_count = p->mpls.mpls_count;
+	return 0;
+}
+
+static int
+encap_pppoe_apply(void *data,
+	struct rte_table_action_encap_params *p)
+{
+	struct encap_pppoe_data *d = data;
+
+	/* Ethernet */
+	ether_addr_copy(&p->pppoe.ether.da, &d->ether.d_addr);
+	ether_addr_copy(&p->pppoe.ether.sa, &d->ether.s_addr);
+	d->ether.ether_type = rte_htons(ETHER_TYPE_PPPOE_SESSION);
+
+	/* PPPoE and PPP*/
+	d->pppoe_ppp.ver_type_code = rte_htons(0x1100);
+	d->pppoe_ppp.session_id = rte_htons(p->pppoe.pppoe.session_id);
+	d->pppoe_ppp.length = 0; /* not pre-computed */
+	d->pppoe_ppp.protocol = rte_htons(PPP_PROTOCOL_IP);
+
+	return 0;
+}
+
+static int
+encap_apply(void *data,
+	struct rte_table_action_encap_params *p,
+	struct rte_table_action_encap_config *cfg,
+	struct rte_table_action_common_config *common_cfg)
+{
+	int status;
+
+	/* Check input arguments */
+	status = encap_apply_check(p, cfg);
+	if (status)
+		return status;
+
+	switch (p->type) {
+	case RTE_TABLE_ACTION_ENCAP_ETHER:
+		return encap_ether_apply(data, p, common_cfg);
+
+	case RTE_TABLE_ACTION_ENCAP_VLAN:
+		return encap_vlan_apply(data, p, common_cfg);
+
+	case RTE_TABLE_ACTION_ENCAP_QINQ:
+		return encap_qinq_apply(data, p, common_cfg);
+
+	case RTE_TABLE_ACTION_ENCAP_MPLS:
+		return encap_mpls_apply(data, p);
+
+	case RTE_TABLE_ACTION_ENCAP_PPPOE:
+		return encap_pppoe_apply(data, p);
+
+	default:
+		return -EINVAL;
+	}
+}
+
+static __rte_always_inline void *
+encap(void *dst, const void *src, size_t n)
+{
+	dst = ((uint8_t *) dst) - n;
+	return rte_memcpy(dst, src, n);
+}
+
+static __rte_always_inline void
+pkt_work_encap(struct rte_mbuf *mbuf,
+	void *data,
+	struct rte_table_action_encap_config *cfg,
+	void *ip,
+	uint16_t total_length,
+	uint32_t ip_offset)
+{
+	switch (cfg->encap_mask) {
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_ETHER:
+		encap(ip, data, sizeof(struct encap_ether_data));
+		mbuf->data_off = ip_offset - (sizeof(struct rte_mbuf) +
+			sizeof(struct encap_ether_data));
+		mbuf->pkt_len = mbuf->data_len = total_length +
+			sizeof(struct encap_ether_data);
+		break;
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_VLAN:
+		encap(ip, data, sizeof(struct encap_vlan_data));
+		mbuf->data_off = ip_offset - (sizeof(struct rte_mbuf) +
+			sizeof(struct encap_vlan_data));
+		mbuf->pkt_len = mbuf->data_len = total_length +
+			sizeof(struct encap_vlan_data);
+		break;
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_QINQ:
+		encap(ip, data, sizeof(struct encap_qinq_data));
+		mbuf->data_off = ip_offset - (sizeof(struct rte_mbuf) +
+			sizeof(struct encap_qinq_data));
+		mbuf->pkt_len = mbuf->data_len = total_length +
+			sizeof(struct encap_qinq_data);
+		break;
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_MPLS:
+	{
+		struct encap_mpls_data *mpls = data;
+		size_t size = sizeof(struct ether_hdr) +
+			mpls->mpls_count * 4;
+
+		encap(ip, data, size);
+		mbuf->data_off = ip_offset - (sizeof(struct rte_mbuf) + size);
+		mbuf->pkt_len = mbuf->data_len = total_length + size;
+		break;
+	}
+
+	case 1LLU << RTE_TABLE_ACTION_ENCAP_PPPOE:
+	{
+		struct encap_pppoe_data *pppoe =
+			encap(ip, data, sizeof(struct encap_pppoe_data));
+		pppoe->pppoe_ppp.length = rte_htons(total_length + 2);
+		mbuf->data_off = ip_offset - (sizeof(struct rte_mbuf) +
+			sizeof(struct encap_pppoe_data));
+		mbuf->pkt_len = mbuf->data_len = total_length +
+			sizeof(struct encap_pppoe_data);
+		break;
+	}
+
+	default:
+		break;
+	}
+}
+
+/**
  * Action profile
  */
 static int
@@ -373,6 +740,7 @@ action_valid(enum rte_table_action_type action)
 	case RTE_TABLE_ACTION_FWD:
 	case RTE_TABLE_ACTION_MTR:
 	case RTE_TABLE_ACTION_TM:
+	case RTE_TABLE_ACTION_ENCAP:
 		return 1;
 	default:
 		return 0;
@@ -387,6 +755,7 @@ struct ap_config {
 	struct rte_table_action_common_config common;
 	struct rte_table_action_mtr_config mtr;
 	struct rte_table_action_tm_config tm;
+	struct rte_table_action_encap_config encap;
 };
 
 static size_t
@@ -397,6 +766,8 @@ action_cfg_size(enum rte_table_action_type action)
 		return sizeof(struct rte_table_action_mtr_config);
 	case RTE_TABLE_ACTION_TM:
 		return sizeof(struct rte_table_action_tm_config);
+	case RTE_TABLE_ACTION_ENCAP:
+		return sizeof(struct rte_table_action_encap_config);
 	default:
 		return 0;
 	}
@@ -413,6 +784,9 @@ action_cfg_get(struct ap_config *ap_config,
 	case RTE_TABLE_ACTION_TM:
 		return &ap_config->tm;
 
+	case RTE_TABLE_ACTION_ENCAP:
+		return &ap_config->encap;
+
 	default:
 		return NULL;
 	}
@@ -450,6 +824,9 @@ action_data_size(enum rte_table_action_type action,
 	case RTE_TABLE_ACTION_TM:
 		return sizeof(struct tm_data);
 
+	case RTE_TABLE_ACTION_ENCAP:
+		return encap_data_size(&ap_config->encap);
+
 	default:
 		return 0;
 	}
@@ -528,6 +905,10 @@ rte_table_action_profile_action_register(struct rte_table_action_profile *profil
 		status = tm_cfg_check(action_config);
 		break;
 
+	case RTE_TABLE_ACTION_ENCAP:
+		status = encap_cfg_check(action_config);
+		break;
+
 	default:
 		status = 0;
 		break;
@@ -650,6 +1031,12 @@ rte_table_action_apply(struct rte_table_action *action,
 			action_params,
 			&action->cfg.tm);
 
+	case RTE_TABLE_ACTION_ENCAP:
+		return encap_apply(action_data,
+			action_params,
+			&action->cfg.encap,
+			&action->cfg.common);
+
 	default:
 		return -EINVAL;
 	}
@@ -867,6 +1254,18 @@ pkt_work(struct rte_mbuf *mbuf,
 			dscp);
 	}
 
+	if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_ENCAP)) {
+		void *data =
+			action_data_get(table_entry, action, RTE_TABLE_ACTION_ENCAP);
+
+		pkt_work_encap(mbuf,
+			data,
+			&cfg->encap,
+			ip,
+			total_length,
+			ip_offset);
+	}
+
 	return drop_mask;
 }
 
@@ -1011,6 +1410,45 @@ pkt4_work(struct rte_mbuf **mbufs,
 			dscp3);
 	}
 
+	if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_ENCAP)) {
+		void *data0 =
+			action_data_get(table_entry0, action, RTE_TABLE_ACTION_ENCAP);
+		void *data1 =
+			action_data_get(table_entry1, action, RTE_TABLE_ACTION_ENCAP);
+		void *data2 =
+			action_data_get(table_entry2, action, RTE_TABLE_ACTION_ENCAP);
+		void *data3 =
+			action_data_get(table_entry3, action, RTE_TABLE_ACTION_ENCAP);
+
+		pkt_work_encap(mbuf0,
+			data0,
+			&cfg->encap,
+			ip0,
+			total_length0,
+			ip_offset);
+
+		pkt_work_encap(mbuf1,
+			data1,
+			&cfg->encap,
+			ip1,
+			total_length1,
+			ip_offset);
+
+		pkt_work_encap(mbuf2,
+			data2,
+			&cfg->encap,
+			ip2,
+			total_length2,
+			ip_offset);
+
+		pkt_work_encap(mbuf3,
+			data3,
+			&cfg->encap,
+			ip3,
+			total_length3,
+			ip_offset);
+	}
+
 	return drop_mask0 |
 		(drop_mask1 << 1) |
 		(drop_mask2 << 2) |
lib/librte_pipeline/rte_table_action.h +129 -0

147 lines not on this page · raw message

Signature · 1 line
2.9.3
#149 lore raw

PATCH 6/37 pipeline: add nat action

In reply to Jasvinder Singh

Add implementation of Network Address Translation(NAT) action.

---
 lib/librte_pipeline/rte_table_action.c | 162 +++++++++++++++++++++++++++++++++
 lib/librte_pipeline/rte_table_action.h |  39 ++++++++
 2 files changed, 201 insertions(+)
lib/librte_pipeline/rte_table_action.c +162 -0
index a3c1546..fccf577 100644
@@ -731,6 +731,115 @@ pkt_work_encap(struct rte_mbuf *mbuf,
 }
 
 /**
+ * RTE_TABLE_ACTION_NAT
+ */
+static int
+nat_cfg_check(struct rte_table_action_nat_config *nat)
+{
+	if ((nat->proto != 0x06) &&
+		(nat->proto != 0x11))
+		return -ENOTSUP;
+
+	return 0;
+}
+
+struct nat_ipv4_data {
+	uint32_t addr;
+	uint16_t port;
+	uint16_t checksum;
+} __attribute__((__packed__));
+
+struct nat_ipv6_data {
+	uint8_t addr[16];
+	uint16_t port;
+	uint16_t checksum;
+} __attribute__((__packed__));
+
+static size_t
+nat_data_size(struct rte_table_action_nat_config *nat __rte_unused,
+	struct rte_table_action_common_config *common)
+{
+	int ip_version = common->ip_version;
+
+	return (ip_version) ?
+		sizeof(struct nat_ipv4_data) :
+		sizeof(struct nat_ipv6_data);
+}
+
+static int
+nat_apply_check(struct rte_table_action_nat_params *p,
+	struct rte_table_action_common_config *cfg)
+{
+	if ((p->ip_version && (cfg->ip_version == 0)) ||
+		((p->ip_version == 0) && cfg->ip_version))
+		return -EINVAL;
+
+	return 0;
+}
+
+static int
+nat_apply(void *data,
+	struct rte_table_action_nat_params *p,
+	struct rte_table_action_common_config *cfg)
+{
+	int status;
+
+	/* Check input arguments */
+	status = nat_apply_check(p, cfg);
+	if (status)
+		return status;
+
+	/* Apply */
+	if (p->ip_version) {
+		struct nat_ipv4_data *d = data;
+
+		d->addr = rte_htonl(p->addr.ipv4);
+		d->port = rte_htons(p->port);
+		d->checksum = 0;
+	} else {
+		struct nat_ipv6_data *d = data;
+
+		memcpy(d->addr, p->addr.ipv6, sizeof(d->addr));
+		d->port = rte_htons(p->port);
+		d->checksum = 0;
+	}
+
+	return 0;
+}
+
+static __rte_always_inline void
+pkt_ipv4_work_nat(struct ipv4_hdr *ip,
+	struct nat_ipv4_data *data,
+	struct rte_table_action_nat_config *cfg)
+{
+	struct tcp_hdr *tcp = (struct tcp_hdr *) &ip[1];
+
+	if (cfg->source_nat) {
+		ip->src_addr = data->addr;
+		tcp->src_port = data->port;
+	} else {
+		ip->dst_addr = data->addr;
+		tcp->dst_port = data->port;
+	}
+}
+
+static __rte_always_inline void
+pkt_ipv6_work_nat(struct ipv6_hdr *ip,
+	struct nat_ipv6_data *data,
+	struct rte_table_action_nat_config *cfg)
+{
+	struct tcp_hdr *tcp = (struct tcp_hdr *) &ip[1];
+
+	if (cfg->source_nat) {
+		rte_memcpy(ip->src_addr, data->addr, 16);
+		tcp->src_port = data->port;
+	} else {
+		rte_memcpy(ip->dst_addr, data->addr, 16);
+		tcp->dst_port = data->port;
+	}
+}
+
+/**
  * Action profile
  */
 static int
@@ -741,6 +850,7 @@ action_valid(enum rte_table_action_type action)
 	case RTE_TABLE_ACTION_MTR:
 	case RTE_TABLE_ACTION_TM:
 	case RTE_TABLE_ACTION_ENCAP:
+	case RTE_TABLE_ACTION_NAT:
 		return 1;
 	default:
 		return 0;
@@ -756,6 +866,7 @@ struct ap_config {
 	struct rte_table_action_mtr_config mtr;
 	struct rte_table_action_tm_config tm;
 	struct rte_table_action_encap_config encap;
+	struct rte_table_action_nat_config nat;
 };
 
 static size_t
@@ -768,6 +879,8 @@ action_cfg_size(enum rte_table_action_type action)
 		return sizeof(struct rte_table_action_tm_config);
 	case RTE_TABLE_ACTION_ENCAP:
 		return sizeof(struct rte_table_action_encap_config);
+	case RTE_TABLE_ACTION_NAT:
+		return sizeof(struct rte_table_action_nat_config);
 	default:
 		return 0;
 	}
@@ -787,6 +900,9 @@ action_cfg_get(struct ap_config *ap_config,
 	case RTE_TABLE_ACTION_ENCAP:
 		return &ap_config->encap;
 
+	case RTE_TABLE_ACTION_NAT:
+		return &ap_config->nat;
+
 	default:
 		return NULL;
 	}
@@ -827,6 +943,10 @@ action_data_size(enum rte_table_action_type action,
 	case RTE_TABLE_ACTION_ENCAP:
 		return encap_data_size(&ap_config->encap);
 
+	case RTE_TABLE_ACTION_NAT:
+		return nat_data_size(&ap_config->nat,
+			&ap_config->common);
+
 	default:
 		return 0;
 	}
@@ -909,6 +1029,10 @@ rte_table_action_profile_action_register(struct rte_table_action_profile *profil
 		status = encap_cfg_check(action_config);
 		break;
 
+	case RTE_TABLE_ACTION_NAT:
+		status = nat_cfg_check(action_config);
+		break;
+
 	default:
 		status = 0;
 		break;
@@ -1037,6 +1161,11 @@ rte_table_action_apply(struct rte_table_action *action,
 			&action->cfg.encap,
 			&action->cfg.common);
 
+	case RTE_TABLE_ACTION_NAT:
+		return nat_apply(action_data,
+			action_params,
+			&action->cfg.common);
+
 	default:
 		return -EINVAL;
 	}
@@ -1266,6 +1395,16 @@ pkt_work(struct rte_mbuf *mbuf,
 			ip_offset);
 	}
 
+	if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_NAT)) {
+		void *data =
+			action_data_get(table_entry, action, RTE_TABLE_ACTION_NAT);
+
+		if (cfg->common.ip_version)
+			pkt_ipv4_work_nat(ip, data, &cfg->nat);
+		else
+			pkt_ipv6_work_nat(ip, data, &cfg->nat);
+	}
+
 	return drop_mask;
 }
 
@@ -1449,6 +1588,29 @@ pkt4_work(struct rte_mbuf **mbufs,
 			ip_offset);
 	}
 
+	if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_NAT)) {
+		void *data0 =
+			action_data_get(table_entry0, action, RTE_TABLE_ACTION_NAT);
+		void *data1 =
+			action_data_get(table_entry1, action, RTE_TABLE_ACTION_NAT);
+		void *data2 =
+			action_data_get(table_entry2, action, RTE_TABLE_ACTION_NAT);
+		void *data3 =
+			action_data_get(table_entry3, action, RTE_TABLE_ACTION_NAT);
+
+		if (cfg->common.ip_version) {
+			pkt_ipv4_work_nat(ip0, data0, &cfg->nat);
+			pkt_ipv4_work_nat(ip1, data1, &cfg->nat);
+			pkt_ipv4_work_nat(ip2, data2, &cfg->nat);
+			pkt_ipv4_work_nat(ip3, data3, &cfg->nat);
+		} else {
+			pkt_ipv6_work_nat(ip0, data0, &cfg->nat);
+			pkt_ipv6_work_nat(ip1, data1, &cfg->nat);
+			pkt_ipv6_work_nat(ip2, data2, &cfg->nat);
+			pkt_ipv6_work_nat(ip3, data3, &cfg->nat);
+		}
+	}
+
 	return drop_mask0 |
 		(drop_mask1 << 1) |
 		(drop_mask2 << 2) |
lib/librte_pipeline/rte_table_action.h +39 -0
index c5c987d..5204511 100644
@@ -77,6 +77,9 @@ enum rte_table_action_type {
 
 	/** Packet encapsulations. */
 	RTE_TABLE_ACTION_ENCAP,
+
+	/** Network Address Translation (NAT). */
+	RTE_TABLE_ACTION_NAT,
 };
 
 /** Common action configuration (per table action profile). */
@@ -409,6 +412,42 @@ struct rte_table_action_encap_params {
 };
 
 /**
+ * RTE_TABLE_ACTION_NAT
+ */
+/** NAT action configuration (per table action profile). */
+struct rte_table_action_nat_config {
+	/** When non-zero, the IP source address and L4 protocol source port are
+	 * translated. When zero, the IP destination address and L4 protocol
+	 * destination port are translated.
+	 */
+	int source_nat;
+
+	/** Layer 4 protocol, for example TCP (0x06) or UDP (0x11). The checksum
+	 * field is computed differently and placed at different header offset
+	 * by each layer 4 protocol.
+	 */
+	uint8_t proto;
+};
+
+/** NAT action parameters (per table rule). */
+struct rte_table_action_nat_params {
+	/** IP version for *addr*: non-zero for IPv4, zero for IPv6. */
+	int ip_version;
+
+	/** IP address. */
+	union {
+		/** IPv4 address; only valid when *ip_version* is non-zero. */
+		uint32_t ipv4;
+
+		/** IPv6 address; only valid when *ip_version* is set to 0. */
+		uint8_t ipv6[16];
+	} addr;
+
+	/** Port. */
+	uint16_t port;
+};
+
+/**
  * Table action profile.
  */
 struct rte_table_action_profile;
Signature · 1 line
2.9.3
#150 lore raw

PATCH 7/37 pipeline: add ttl update action

In reply to Jasvinder Singh

Add implementation of ttl update action.

---
 lib/librte_pipeline/rte_pipeline_version.map |   1 +
 lib/librte_pipeline/rte_table_action.c       | 155 +++++++++++++++++++++++++++
 lib/librte_pipeline/rte_table_action.h       |  66 ++++++++++++
 3 files changed, 222 insertions(+)
lib/librte_pipeline/rte_pipeline_version.map +1 -0
index c7106dc..9388585 100644
@@ -61,5 +61,6 @@ EXPERIMENTAL {
 	rte_table_action_profile_free;
 	rte_table_action_profile_freeze;
 	rte_table_action_table_params_get;
+	rte_table_action_ttl_read;
 
 } DPDK_16.04;
lib/librte_pipeline/rte_table_action.c +155 -0

221 lines not on this page · raw message

lib/librte_pipeline/rte_table_action.h +66 -0

84 lines not on this page · raw message

Signature · 1 line
2.9.3
#151 lore raw

PATCH 8/37 pipeline: add statistics read action

In reply to Jasvinder Singh

Add implementation of stats read action

---
 lib/librte_pipeline/rte_pipeline_version.map |   1 +
 lib/librte_pipeline/rte_table_action.c       | 112 ++++++++++++++++++++++++++-
 lib/librte_pipeline/rte_table_action.h       |  78 +++++++++++++++++++
 3 files changed, 190 insertions(+), 1 deletion(-)
lib/librte_pipeline/rte_pipeline_version.map +1 -0
index 9388585..8241efc 100644
@@ -61,6 +61,7 @@ EXPERIMENTAL {
 	rte_table_action_profile_free;
 	rte_table_action_profile_freeze;
 	rte_table_action_table_params_get;
+	rte_table_action_stats_read;
 	rte_table_action_ttl_read;
 
 } DPDK_16.04;
lib/librte_pipeline/rte_table_action.c +111 -1

184 lines not on this page · raw message

lib/librte_pipeline/rte_table_action.h +78 -0

96 lines not on this page · raw message

Signature · 1 line
2.9.3
#152 lore raw

PATCH 9/37 pipeline: add timestamp action

In reply to Jasvinder Singh

Add implementation of timestamp action.

---
 lib/librte_pipeline/rte_pipeline_version.map |  1 +
 lib/librte_pipeline/rte_table_action.c       | 79 +++++++++++++++++++++++++++-
 lib/librte_pipeline/rte_table_action.h       | 31 +++++++++++
 3 files changed, 110 insertions(+), 1 deletion(-)
lib/librte_pipeline/rte_pipeline_version.map +1 -0
index 8241efc..4e948b8 100644
@@ -62,6 +62,7 @@ EXPERIMENTAL {
 	rte_table_action_profile_freeze;
 	rte_table_action_table_params_get;
 	rte_table_action_stats_read;
+	rte_table_action_time_read;
 	rte_table_action_ttl_read;
 
 } DPDK_16.04;
lib/librte_pipeline/rte_table_action.c +78 -1

127 lines not on this page · raw message

lib/librte_pipeline/rte_table_action.h +31 -0
index 53b9866..e9b30ab 100644
@@ -86,6 +86,9 @@ enum rte_table_action_type {
 
 	/** Statistics. */
 	RTE_TABLE_ACTION_STATS,
+
+	/** Timestamp. */
+	RTE_TABLE_ACTION_TIME,
 };
 
 /** Common action configuration (per table action profile). */
@@ -542,6 +545,15 @@ struct rte_table_action_stats_counters {
 };
 
 /**
+ * RTE_TABLE_ACTION_TIME
+ */
+/** Timestamp action parameters (per table rule). */
+struct rte_table_action_time_params {
+	/** Initial timestamp value. Typically set to current time. */
+	uint64_t time;
+};
+
+/**
  * Table action profile.
  */
 struct rte_table_action_profile;
@@ -815,6 +827,25 @@ rte_table_action_stats_read(struct rte_table_action *action,
 	struct rte_table_action_stats_counters *stats,
 	int clear);
 
+/**
+ * Table action timestamp read.
+ *
+ * @param[in] action
+ *   Handle to table action object (needs to be valid).
+ * @param[in] data
+ *   Data byte array (typically table rule data) with timestamp action
+ *   previously applied on it.
+ * @param[inout] timestamp
+ *   Pre-allocated memory where the timestamp read from *data* is saved (has to
+ *   be non-NULL).
+ * @return
+ *   Zero on success, non-zero error code otherwise.
+ */
+int __rte_experimental
+rte_table_action_time_read(struct rte_table_action *action,
+	void *data,
+	uint64_t *timestamp);
+
 #ifdef __cplusplus
 }
 #endif
Signature · 1 line
2.9.3
#153 lore raw

PATCH 10/37 ip_pipeline: rework and improvements

In reply to Jasvinder Singh

All the actions associated with application pipelines tables and ports are now implemented using the new action APIs. Therefore, thousands of lines of code are eliminated from the application. The reduced code size is easier to maintain and extend.

---
 examples/ip_pipeline/Makefile                      |   38 +-
 examples/ip_pipeline/app.h                         | 1401 --------
 examples/ip_pipeline/config/action.cfg             |   68 -
 examples/ip_pipeline/config/action.sh              |  119 -
 examples/ip_pipeline/config/action.txt             |    8 -
 examples/ip_pipeline/config/diagram-generator.py   |  317 --
 .../ip_pipeline/config/edge_router_downstream.cfg  |   97 -
 .../ip_pipeline/config/edge_router_downstream.sh   |   13 -
 .../ip_pipeline/config/edge_router_upstream.cfg    |  124 -
 .../ip_pipeline/config/edge_router_upstream.sh     |   33 -
 examples/ip_pipeline/config/firewall.cfg           |   68 -
 examples/ip_pipeline/config/firewall.sh            |   13 -
 examples/ip_pipeline/config/firewall.txt           |    9 -
 examples/ip_pipeline/config/flow.cfg               |   72 -
 examples/ip_pipeline/config/flow.sh                |   25 -
 examples/ip_pipeline/config/flow.txt               |   17 -
 examples/ip_pipeline/config/ip_pipeline.cfg        |    9 -
 examples/ip_pipeline/config/ip_pipeline.sh         |    5 -
 examples/ip_pipeline/config/kni.cfg                |   67 -
 examples/ip_pipeline/config/l2fwd.cfg              |   58 -
 examples/ip_pipeline/config/l3fwd.cfg              |   68 -
 examples/ip_pipeline/config/l3fwd.sh               |   33 -
 examples/ip_pipeline/config/l3fwd_arp.cfg          |   70 -
 examples/ip_pipeline/config/l3fwd_arp.sh           |   43 -
 examples/ip_pipeline/config/network_layers.cfg     |  227 --
 examples/ip_pipeline/config/network_layers.sh      |   79 -
 .../ip_pipeline/config/pipeline-to-core-mapping.py |  906 ------
 examples/ip_pipeline/config/tap.cfg                |   64 -
 examples/ip_pipeline/config/tm_profile.cfg         |  105 -
 examples/ip_pipeline/config_check.c                |  488 ---
 examples/ip_pipeline/config_parse.c                | 3395 --------------------
 examples/ip_pipeline/config_parse_tm.c             |  419 ---
 examples/ip_pipeline/cpu_core_map.c                |  471 ---
 examples/ip_pipeline/cpu_core_map.h                |   40 -
 examples/ip_pipeline/{pipeline => }/hash_func.h    |    3 +-
 .../ip_pipeline/{pipeline => }/hash_func_arm64.h   |    0
 examples/ip_pipeline/init.c                        | 1927 -----------
 examples/ip_pipeline/main.c                        |   36 +-
 examples/ip_pipeline/meson.build                   |   23 +-
 examples/ip_pipeline/parser.c                      |   16 +-
 examples/ip_pipeline/parser.h                      |    8 +
 examples/ip_pipeline/pipeline.h                    |   73 -
 .../ip_pipeline/pipeline/pipeline_actions_common.h |  202 --
 examples/ip_pipeline/pipeline/pipeline_common_be.c |  176 -
 examples/ip_pipeline/pipeline/pipeline_common_be.h |  134 -
 examples/ip_pipeline/pipeline/pipeline_common_fe.c | 1455 ---------
 examples/ip_pipeline/pipeline/pipeline_common_fe.h |  231 --
 examples/ip_pipeline/pipeline/pipeline_firewall.c  | 1421 --------
 examples/ip_pipeline/pipeline/pipeline_firewall.h  |   60 -
 .../ip_pipeline/pipeline/pipeline_firewall_be.c    |  856 -----
 .../ip_pipeline/pipeline/pipeline_firewall_be.h    |  147 -
 .../ip_pipeline/pipeline/pipeline_flow_actions.c   | 1286 --------
 .../ip_pipeline/pipeline/pipeline_flow_actions.h   |   60 -
 .../pipeline/pipeline_flow_actions_be.c            |  983 ------
 .../pipeline/pipeline_flow_actions_be.h            |  139 -
 .../pipeline/pipeline_flow_classification.c        | 1878 -----------
 .../pipeline/pipeline_flow_classification.h        |  106 -
 .../pipeline/pipeline_flow_classification_be.c     |  723 -----
 .../pipeline/pipeline_flow_classification_be.h     |  113 -
 examples/ip_pipeline/pipeline/pipeline_master.c    |   20 -
 examples/ip_pipeline/pipeline/pipeline_master.h    |   12 -
 examples/ip_pipeline/pipeline/pipeline_master_be.c |  141 -
 examples/ip_pipeline/pipeline/pipeline_master_be.h |   12 -
 .../ip_pipeline/pipeline/pipeline_passthrough.c    |   45 -
 .../ip_pipeline/pipeline/pipeline_passthrough.h    |   12 -
 .../ip_pipeline/pipeline/pipeline_passthrough_be.c |  929 ------
 .../ip_pipeline/pipeline/pipeline_passthrough_be.h |   44 -
 examples/ip_pipeline/pipeline/pipeline_routing.c   | 1613 ----------
 examples/ip_pipeline/pipeline/pipeline_routing.h   |   71 -
 .../ip_pipeline/pipeline/pipeline_routing_be.c     | 1966 ------------
 .../ip_pipeline/pipeline/pipeline_routing_be.h     |  283 --
 examples/ip_pipeline/pipeline_be.h                 |  322 --
 examples/ip_pipeline/thread.c                      |  293 --
 examples/ip_pipeline/thread.h                      |   69 -
 examples/ip_pipeline/thread_fe.c                   |  457 ---
 examples/ip_pipeline/thread_fe.h                   |   72 -
 76 files changed, 38 insertions(+), 27348 deletions(-)
 delete mode 100644 examples/ip_pipeline/app.h
 delete mode 100644 examples/ip_pipeline/config/action.cfg
 delete mode 100644 examples/ip_pipeline/config/action.sh
 delete mode 100644 examples/ip_pipeline/config/action.txt
 delete mode 100755 examples/ip_pipeline/config/diagram-generator.py
 delete mode 100644 examples/ip_pipeline/config/edge_router_downstream.cfg
 delete mode 100644 examples/ip_pipeline/config/edge_router_downstream.sh
 delete mode 100644 examples/ip_pipeline/config/edge_router_upstream.cfg
 delete mode 100644 examples/ip_pipeline/config/edge_router_upstream.sh
 delete mode 100644 examples/ip_pipeline/config/firewall.cfg
 delete mode 100644 examples/ip_pipeline/config/firewall.sh
 delete mode 100644 examples/ip_pipeline/config/firewall.txt
 delete mode 100644 examples/ip_pipeline/config/flow.cfg
 delete mode 100644 examples/ip_pipeline/config/flow.sh
 delete mode 100644 examples/ip_pipeline/config/flow.txt
 delete mode 100644 examples/ip_pipeline/config/ip_pipeline.cfg
 delete mode 100644 examples/ip_pipeline/config/ip_pipeline.sh
 delete mode 100644 examples/ip_pipeline/config/kni.cfg
 delete mode 100644 examples/ip_pipeline/config/l2fwd.cfg
 delete mode 100644 examples/ip_pipeline/config/l3fwd.cfg
 delete mode 100644 examples/ip_pipeline/config/l3fwd.sh
 delete mode 100644 examples/ip_pipeline/config/l3fwd_arp.cfg
 delete mode 100644 examples/ip_pipeline/config/l3fwd_arp.sh
 delete mode 100644 examples/ip_pipeline/config/network_layers.cfg
 delete mode 100644 examples/ip_pipeline/config/network_layers.sh
 delete mode 100755 examples/ip_pipeline/config/pipeline-to-core-mapping.py
 delete mode 100644 examples/ip_pipeline/config/tap.cfg
 delete mode 100644 examples/ip_pipeline/config/tm_profile.cfg
 delete mode 100644 examples/ip_pipeline/config_check.c
 delete mode 100644 examples/ip_pipeline/config_parse.c
 delete mode 100644 examples/ip_pipeline/config_parse_tm.c
 delete mode 100644 examples/ip_pipeline/cpu_core_map.c
 delete mode 100644 examples/ip_pipeline/cpu_core_map.h
 rename examples/ip_pipeline/{pipeline => }/hash_func.h (99%)
 rename examples/ip_pipeline/{pipeline => }/hash_func_arm64.h (100%)
 delete mode 100644 examples/ip_pipeline/init.c
 delete mode 100644 examples/ip_pipeline/pipeline.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_actions_common.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_common_be.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_common_be.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_common_fe.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_common_fe.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_firewall.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_firewall.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_firewall_be.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_firewall_be.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_actions.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_actions.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_actions_be.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_classification.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_classification.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_flow_classification_be.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_master.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_master.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_master_be.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_master_be.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_passthrough.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_passthrough.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_passthrough_be.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_passthrough_be.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_routing.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_routing.h
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_routing_be.c
 delete mode 100644 examples/ip_pipeline/pipeline/pipeline_routing_be.h
 delete mode 100644 examples/ip_pipeline/pipeline_be.h
 delete mode 100644 examples/ip_pipeline/thread.c
 delete mode 100644 examples/ip_pipeline/thread.h
 delete mode 100644 examples/ip_pipeline/thread_fe.c
 delete mode 100644 examples/ip_pipeline/thread_fe.h
examples/ip_pipeline/Makefile +6 -32
index 85fbbaf..981c4f7 100644
@@ -1,34 +1,13 @@
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright(c) 2010-2014 Intel Corporation
+# Copyright(c) 2010-2018 Intel Corporation
 
 # binary name
 APP = ip_pipeline
 
 # all source are stored in SRCS-y
 SRCS-y := main.c
-SRCS-y += config_parse.c
 SRCS-y += parser.c
-SRCS-y += config_parse_tm.c
-SRCS-y += config_check.c
-SRCS-y += init.c
-SRCS-y += thread.c
-SRCS-y += thread_fe.c
-SRCS-y += cpu_core_map.c
-
-SRCS-y += pipeline_common_be.c
-SRCS-y += pipeline_common_fe.c
-SRCS-y += pipeline_master_be.c
-SRCS-y += pipeline_master.c
-SRCS-y += pipeline_passthrough_be.c
-SRCS-y += pipeline_passthrough.c
-SRCS-y += pipeline_firewall_be.c
-SRCS-y += pipeline_firewall.c
-SRCS-y += pipeline_flow_classification_be.c
-SRCS-y += pipeline_flow_classification.c
-SRCS-y += pipeline_flow_actions_be.c
-SRCS-y += pipeline_flow_actions.c
-SRCS-y += pipeline_routing_be.c
-SRCS-y += pipeline_routing.c
+#SRCS-y += thread.c
 
 # Build using pkg-config variables if possible
 $(shell pkg-config --exists libdpdk)
@@ -46,9 +25,7 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
-VPATH += pipeline
-CFLAGS += -I. -I./pipeline/
-CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -I.
 
 OBJS := $(patsubst %.c,build/%.o,$(SRCS-y))
 
@@ -75,21 +52,18 @@ ifeq ($(RTE_SDK),)
 $(error "Please define RTE_SDK environment variable")
 endif
 
-VPATH += $(SRCDIR)/pipeline
-
 # Default target, can be overridden by command line or environment
 RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
-INC += $(sort $(wildcard *.h)) $(sort $(wildcard pipeline/*.h))
+INC += $(sort $(wildcard *.h))
 
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) := $(SRCS-y)
 
-CFLAGS += -I$(SRCDIR) -I$(SRCDIR)/pipeline
+CFLAGS += -I$(SRCDIR)
 CFLAGS += -O3
-CFLAGS += $(WERROR_FLAGS) -Wno-error=unused-function -Wno-error=unused-variable
-CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += $(WERROR_FLAGS)
 
 include $(RTE_SDK)/mk/rte.extapp.mk
 
examples/ip_pipeline/app.h deleted +0 -1401

1,401 lines not on this page · raw message

examples/ip_pipeline/config/action.cfg deleted +0 -68

68 lines not on this page · raw message

examples/ip_pipeline/config/action.sh deleted +0 -119

119 lines not on this page · raw message

examples/ip_pipeline/config/action.txt deleted +0 -8
deleted file mode 100644
index f14207b..0000000
@@ -1,8 +0,0 @@
-#
-# p <pipelineid> action flow bulk ./config/action.txt
-#
-
-flow 0 meter 0 trtcm 1250000000 1250000000 1000000 1000000 policer 0 g G y Y r R meter 1 trtcm 1250000000 1250000000 1000000 1000000 policer 1 g G y Y r R meter 2 trtcm 1250000000 1250000000 1000000 1000000 policer 2 g G y Y r R meter 3 trtcm 1250000000 1250000000 1000000 1000000 policer 3 g G y Y r R port 0
-flow 1 meter 0 trtcm 1250000000 1250000000 1000000 1000000 policer 0 g G y Y r R meter 1 trtcm 1250000000 1250000000 1000000 1000000 policer 1 g G y Y r R meter 2 trtcm 1250000000 1250000000 1000000 1000000 policer 2 g G y Y r R meter 3 trtcm 1250000000 1250000000 1000000 1000000 policer 3 g G y Y r R port 1
-flow 2 meter 0 trtcm 1250000000 1250000000 1000000 1000000 policer 0 g G y Y r R meter 1 trtcm 1250000000 1250000000 1000000 1000000 policer 1 g G y Y r R meter 2 trtcm 1250000000 1250000000 1000000 1000000 policer 2 g G y Y r R meter 3 trtcm 1250000000 1250000000 1000000 1000000 policer 3 g G y Y r R port 2
-flow 3 meter 0 trtcm 1250000000 1250000000 1000000 1000000 policer 0 g G y Y r R meter 1 trtcm 1250000000 1250000000 1000000 1000000 policer 1 g G y Y r R meter 2 trtcm 1250000000 1250000000 1000000 1000000 policer 2 g G y Y r R meter 3 trtcm 1250000000 1250000000 1000000 1000000 policer 3 g G y Y r R port 3
examples/ip_pipeline/config/diagram-generator.py deleted +0 -317

317 lines not on this page · raw message

examples/ip_pipeline/config/edge_router_downstream.cfg deleted +0 -97

97 lines not on this page · raw message

examples/ip_pipeline/config/edge_router_downstream.sh deleted +0 -13
deleted file mode 100644
index 67c3a0d..0000000
@@ -1,13 +0,0 @@
-#
-# run ./config/edge_router_downstream.sh
-#
-
-################################################################################
-# Routing: Ether QinQ, ARP off
-################################################################################
-p 1 route add default 4 #SINK0
-p 1 route add 0.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 qinq 256 257
-p 1 route add 0.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 qinq 258 259
-p 1 route add 0.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 qinq 260 261
-p 1 route add 0.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 qinq 262 263
-#p 1 route ls
examples/ip_pipeline/config/edge_router_upstream.cfg deleted +0 -124

124 lines not on this page · raw message

examples/ip_pipeline/config/edge_router_upstream.sh deleted +0 -33
deleted file mode 100644
index 5d574c1..0000000
@@ -1,33 +0,0 @@
-#
-# run ./config/edge_router_upstream.sh
-#
-
-################################################################################
-# Firewall
-################################################################################
-p 1 firewall add default 4 #SINK0
-p 1 firewall add bulk ./config/edge_router_upstream_firewall.txt
-#p 1 firewall ls
-
-################################################################################
-# Flow Classification
-################################################################################
-p 3 flow add default 4 #SINK1
-p 3 flow add qinq bulk ./config/edge_router_upstream_flow.txt
-#p 3 flow ls
-
-################################################################################
-# Flow Actions - Metering and Policing
-################################################################################
-p 4 action flow bulk ./config/edge_router_upstream_action.txt
-#p 4 action flow ls
-
-################################################################################
-# Routing: Ether MPLS, ARP off
-################################################################################
-p 5 route add default 4 #SINK2
-p 5 route add 0.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 mpls 0:1
-p 5 route add 0.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 mpls 10:11
-p 5 route add 0.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 mpls 20:21
-p 5 route add 0.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 mpls 30:31
-#p 5 route ls
examples/ip_pipeline/config/firewall.cfg deleted +0 -68

68 lines not on this page · raw message

examples/ip_pipeline/config/firewall.sh deleted +0 -13
deleted file mode 100644
index c83857e..0000000
@@ -1,13 +0,0 @@
-#
-# run ./config/firewall.sh
-#
-
-p 1 firewall add default 4 #SINK0
-p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.0.0.0 10 0 65535 0 65535 6 0xF port 0
-p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.64.0.0 10 0 65535 0 65535 6 0xF port 1
-p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.128.0.0 10 0 65535 0 65535 6 0xF port 2
-p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.192.0.0 10 0 65535 0 65535 6 0xF port 3
-
-#p 1 firewall add bulk ./config/firewall.txt
-
-p 1 firewall ls
examples/ip_pipeline/config/firewall.txt deleted +0 -9
deleted file mode 100644
index 54cfffd..0000000
@@ -1,9 +0,0 @@
-#
-# p <pipelineid> firewall add bulk ./config/firewall.txt
-# p <pipelineid> firewall del bulk ./config/firewall.txt
-#
-
-priority 1 ipv4 0.0.0.0 0 100.0.0.0 10 0 65535 0 65535 6 0xF port 0
-priority 1 ipv4 0.0.0.0 0 100.64.0.0 10 0 65535 0 65535 6 0xF port 1
-priority 1 ipv4 0.0.0.0 0 100.128.0.0 10 0 65535 0 65535 6 0xF port 2
-priority 1 ipv4 0.0.0.0 0 100.192.0.0 10 0 65535 0 65535 6 0xF port 3
examples/ip_pipeline/config/flow.cfg deleted +0 -72

72 lines not on this page · raw message

examples/ip_pipeline/config/flow.sh deleted +0 -25
deleted file mode 100644
index 489c707..0000000
@@ -1,25 +0,0 @@
-#
-# run ./config/flow.sh
-#
-
-################################################################################
-# Flow classification (QinQ)
-################################################################################
-#p 1 flow add default 4 #SINK0
-#p 1 flow add qinq 100 200 port 0 id 0
-#p 1 flow add qinq 101 201 port 1 id 1
-#p 1 flow add qinq 102 202 port 2 id 2
-#p 1 flow add qinq 103 203 port 3 id 3
-
-#p 1 flow add qinq bulk ./config/flow.txt
-
-################################################################################
-# Flow classification (IPv4 5-tuple)
-################################################################################
-p 1 flow add default 4 #SINK0
-p 1 flow add ipv4 100.0.0.10 200.0.0.10 100 200 6 port 0 id 0
-p 1 flow add ipv4 100.0.0.11 200.0.0.11 101 201 6 port 1 id 1
-p 1 flow add ipv4 100.0.0.12 200.0.0.12 102 202 6 port 2 id 2
-p 1 flow add ipv4 100.0.0.13 200.0.0.13 103 203 6 port 3 id 3
-
-#p 1 flow add ipv4 bulk ./config/flow.txt
examples/ip_pipeline/config/flow.txt deleted +0 -17
deleted file mode 100644
index c1a141d..0000000
@@ -1,17 +0,0 @@
-#
-# p <pipelineid> flow add qinq bulk ./config/flow.txt
-#
-
-#qinq 100 200 port 0 id 0
-#qinq 101 201 port 1 id 1
-#qinq 102 202 port 2 id 2
-#qinq 103 203 port 3 id 3
-
-#
-# p <pipelineid> flow add ipv4 bulk ./config/flow.txt
-#
-
-ipv4 100.0.0.10 200.0.0.10 100 200 6 port 0 id 0
-ipv4 100.0.0.11 200.0.0.11 101 201 6 port 1 id 1
-ipv4 100.0.0.12 200.0.0.12 102 202 6 port 2 id 2
-ipv4 100.0.0.13 200.0.0.13 103 203 6 port 3 id 3
examples/ip_pipeline/config/ip_pipeline.cfg deleted +0 -9
deleted file mode 100644
index 095ed25..0000000
@@ -1,9 +0,0 @@
-[PIPELINE0]
-type = MASTER
-core = 0
-
-[PIPELINE1]
-type = PASS-THROUGH
-core = 1
-pktq_in = RXQ0.0 RXQ1.0 RXQ2.0 RXQ3.0
-pktq_out = TXQ0.0 TXQ1.0 TXQ2.0 TXQ3.0
examples/ip_pipeline/config/ip_pipeline.sh deleted +0 -5
deleted file mode 100644
index 4fca259..0000000
@@ -1,5 +0,0 @@
-#
-#run config/ip_pipeline.sh
-#
-
-p 1 ping
examples/ip_pipeline/config/kni.cfg deleted +0 -67

67 lines not on this page · raw message

examples/ip_pipeline/config/l2fwd.cfg deleted +0 -58

58 lines not on this page · raw message

examples/ip_pipeline/config/l3fwd.cfg deleted +0 -68

68 lines not on this page · raw message

examples/ip_pipeline/config/l3fwd.sh deleted +0 -33
deleted file mode 100644
index 47406aa..0000000
@@ -1,33 +0,0 @@
-#
-# run ./config/l3fwd.sh
-#
-
-################################################################################
-# Routing: encap = ethernet, arp = off
-################################################################################
-p 1 route add default 4 #SINK0
-p 1 route add 100.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0
-p 1 route add 100.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1
-p 1 route add 100.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2
-p 1 route add 100.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3
-p 1 route ls
-
-################################################################################
-# Routing: encap = ethernet_qinq, arp = off
-################################################################################
-#p 1 route add default 4 #SINK0
-#p 1 route add 100.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 qinq 1000 2000
-#p 1 route add 100.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 qinq 1001 2001
-#p 1 route add 100.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 qinq 1002 2002
-#p 1 route add 100.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 qinq 1003 2003
-#p 1 route ls
-
-################################################################################
-# Routing: encap = ethernet_mpls, arp = off
-################################################################################
-#p 1 route add default 4 #SINK0
-#p 1 route add 100.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 mpls 1000:2000
-#p 1 route add 100.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 mpls 1001:2001
-#p 1 route add 100.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 mpls 1002:2002
-#p 1 route add 100.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 mpls 1003:2003
-#p 1 route ls
examples/ip_pipeline/config/l3fwd_arp.cfg deleted +0 -70

70 lines not on this page · raw message

examples/ip_pipeline/config/l3fwd_arp.sh deleted +0 -43

43 lines not on this page · raw message

examples/ip_pipeline/config/network_layers.cfg deleted +0 -227

193 lines not on this page · raw message

examples/ip_pipeline/config/network_layers.sh deleted +0 -79

79 lines not on this page · raw message

examples/ip_pipeline/config/pipeline-to-core-mapping.py deleted +0 -906

906 lines not on this page · raw message

examples/ip_pipeline/config/tap.cfg deleted +0 -64

64 lines not on this page · raw message

examples/ip_pipeline/config/tm_profile.cfg deleted +0 -105

105 lines not on this page · raw message

examples/ip_pipeline/config_check.c deleted +0 -488

488 lines not on this page · raw message

examples/ip_pipeline/config_parse.c deleted +0 -3395

3,395 lines not on this page · raw message

examples/ip_pipeline/config_parse_tm.c deleted +0 -419

419 lines not on this page · raw message

examples/ip_pipeline/cpu_core_map.c deleted +0 -471

471 lines not on this page · raw message

examples/ip_pipeline/cpu_core_map.h deleted +0 -40
deleted file mode 100644
index 5e50f6e..0000000

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/hash_func.h renamed from examples/ip_pipeline/pipeline/hash_func.h +2 -1
similarity index 99%
rename from examples/ip_pipeline/pipeline/hash_func.h
rename to examples/ip_pipeline/hash_func.h
index 806ac22..f1b9d94 100644

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/hash_func_arm64.h renamed from examples/ip_pipeline/pipeline/hash_func_arm64.h +0 -0
similarity index 100%
rename from examples/ip_pipeline/pipeline/hash_func_arm64.h
rename to examples/ip_pipeline/hash_func_arm64.h
examples/ip_pipeline/init.c deleted +0 -1927

1,927 lines not on this page · raw message

examples/ip_pipeline/main.c +13 -23
index a44cf9a..1696e36 100644

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/meson.build +1 -22
index 748c9ae..ea89460 100644

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/parser.c +8 -8
index 0901e9c..0ae3d1d 100644

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/parser.h +8 -0
index 5c421d2..261a8c8 100644

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/pipeline.h deleted +0 -73

73 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_actions_common.h deleted +0 -202

202 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_common_be.c deleted +0 -176

176 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_common_be.h deleted +0 -134

134 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_common_fe.c deleted +0 -1455

1,455 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_common_fe.h deleted +0 -231

231 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_firewall.c deleted +0 -1421

1,421 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_firewall.h deleted +0 -60

60 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_firewall_be.c deleted +0 -856

856 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_firewall_be.h deleted +0 -147

147 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_flow_actions.c deleted +0 -1286

1,286 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_flow_actions.h deleted +0 -60

60 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c deleted +0 -983

983 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_flow_actions_be.h deleted +0 -139

139 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_flow_classification.c deleted +0 -1878

1,878 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_flow_classification.h deleted +0 -106

106 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c deleted +0 -723

723 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_flow_classification_be.h deleted +0 -113

113 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_master.c deleted +0 -20
deleted file mode 100644
index b0d730a..0000000

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/pipeline/pipeline_master.h deleted +0 -12
deleted file mode 100644
index a5183e3..0000000

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/pipeline/pipeline_master_be.c deleted +0 -141

141 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_master_be.h deleted +0 -12
deleted file mode 100644
index 847c564..0000000

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/pipeline/pipeline_passthrough.c deleted +0 -45

45 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_passthrough.h deleted +0 -12
deleted file mode 100644
index 7a7a2fc..0000000

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/pipeline/pipeline_passthrough_be.c deleted +0 -929

929 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_passthrough_be.h deleted +0 -44

44 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_routing.c deleted +0 -1613

1,613 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_routing.h deleted +0 -71

71 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_routing_be.c deleted +0 -1966

1,966 lines not on this page · raw message

examples/ip_pipeline/pipeline/pipeline_routing_be.h deleted +0 -283

283 lines not on this page · raw message

examples/ip_pipeline/pipeline_be.h deleted +0 -322

322 lines not on this page · raw message

examples/ip_pipeline/thread.c deleted +0 -293

293 lines not on this page · raw message

examples/ip_pipeline/thread.h deleted +0 -69

69 lines not on this page · raw message

examples/ip_pipeline/thread_fe.c deleted +0 -457

457 lines not on this page · raw message

examples/ip_pipeline/thread_fe.h deleted +0 -72

72 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.9.3

Part of the diff is not shown here. View the raw message.

#154 lore raw

PATCH 11/37 ip_pipeline: add cli interface

In reply to Jasvinder Singh

CLI interface allowing connectivity with external agent(e.g. telnet, netcat, Python script, etc) is added to the application.

---
 examples/ip_pipeline/Makefile    |   4 +-
 examples/ip_pipeline/cli.c       |  85 ++++++++++
 examples/ip_pipeline/cli.h       |  18 +++
 examples/ip_pipeline/conn.c      | 326 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/conn.h      |  47 ++++++
 examples/ip_pipeline/main.c      | 151 +++++++++++++++++-
 examples/ip_pipeline/meson.build |   5 +-
 7 files changed, 632 insertions(+), 4 deletions(-)
 create mode 100644 examples/ip_pipeline/cli.c
 create mode 100644 examples/ip_pipeline/cli.h
 create mode 100644 examples/ip_pipeline/conn.c
 create mode 100644 examples/ip_pipeline/conn.h
examples/ip_pipeline/Makefile +3 -1
index 981c4f7..0c5b6b1 100644
@@ -5,7 +5,9 @@
 APP = ip_pipeline
 
 # all source are stored in SRCS-y
-SRCS-y := main.c
+SRCS-y := cli.c
+SRCS-y += conn.c
+SRCS-y += main.c
 SRCS-y += parser.c
 #SRCS-y += thread.c
 
examples/ip_pipeline/cli.c new file +85 -0

85 lines not on this page · raw message

examples/ip_pipeline/cli.h new file +18 -0
new file mode 100644
index 0000000..992e4c3
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef __INCLUDE_CLI_H__
+#define __INCLUDE_CLI_H__
+
+#include <stddef.h>
+
+void
+cli_process(char *in, char *out, size_t out_size);
+
+int
+cli_script_process(const char *file_name,
+	size_t msg_in_len_max,
+	size_t msg_out_len_max);
+
+#endif
examples/ip_pipeline/conn.c new file +326 -0

326 lines not on this page · raw message

examples/ip_pipeline/conn.h new file +47 -0

47 lines not on this page · raw message

examples/ip_pipeline/main.c +150 -1

170 lines not on this page · raw message

examples/ip_pipeline/meson.build +3 -2
index ea89460..a89cb30 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright(c) 2017 Intel Corporation
+# Copyright(c) 2017-2018 Intel Corporation
 
 # meson file, for building this example as part of a main DPDK build.
 #
@@ -7,8 +7,9 @@
 # DPDK instance, use 'make'
 
 deps += ['pipeline', 'bus_pci']
-includes += include_directories('pipeline')
 sources = files(
+	'cli.c',
+	'conn.c',
 	'main.c',
 	'parser.c',
 )
Signature · 1 line
2.9.3
#155 lore raw

PATCH 12/37 ip_pipeline: add mempool object for pipeline

In reply to Jasvinder Singh

Add mempool object implementation to the application.

---
 examples/ip_pipeline/Makefile    |   1 +
 examples/ip_pipeline/cli.c       | 109 ++++++++++++++++++++++++++++++++++++++-
 examples/ip_pipeline/common.h    |  12 +++++
 examples/ip_pipeline/main.c      |   8 +++
 examples/ip_pipeline/mempool.c   |  81 +++++++++++++++++++++++++++++
 examples/ip_pipeline/mempool.h   |  40 ++++++++++++++
 examples/ip_pipeline/meson.build |   1 +
 7 files changed, 251 insertions(+), 1 deletion(-)
 create mode 100644 examples/ip_pipeline/common.h
 create mode 100644 examples/ip_pipeline/mempool.c
 create mode 100644 examples/ip_pipeline/mempool.h
examples/ip_pipeline/Makefile +1 -0
index 0c5b6b1..fca28c5 100644
@@ -8,6 +8,7 @@ APP = ip_pipeline
 SRCS-y := cli.c
 SRCS-y += conn.c
 SRCS-y += main.c
+SRCS-y += mempool.c
 SRCS-y += parser.c
 #SRCS-y += thread.c
 
examples/ip_pipeline/cli.c +108 -1

126 lines not on this page · raw message

examples/ip_pipeline/common.h new file +12 -0
new file mode 100644
index 0000000..0886dfb
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _INCLUDE_COMMON_H_
+#define _INCLUDE_COMMON_H_
+
+#ifndef NAME_SIZE
+#define NAME_SIZE                                            64
+#endif
+
+#endif /* _INCLUDE_COMMON_H_ */
examples/ip_pipeline/main.c +8 -0
index 60936f4..b53f623 100644
@@ -12,6 +12,7 @@
 
 #include "cli.h"
 #include "conn.h"
+#include "mempool.h"
 
 static const char usage[] =
 	"%s EAL_ARGS -- [-h HOST] [-p PORT] [-s SCRIPT]\n";
@@ -159,6 +160,13 @@ main(int argc, char **argv)
 		return status;
 	};
 
+	/* Mempool */
+	status = mempool_init();
+	if (status) {
+		printf("Error: Mempool initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/mempool.c new file +81 -0

81 lines not on this page · raw message

examples/ip_pipeline/mempool.h new file +40 -0
new file mode 100644
index 0000000..bd46a11
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _INCLUDE_MEMPOOL_H_
+#define _INCLUDE_MEMPOOL_H_
+
+#include <stdint.h>
+#include <sys/queue.h>
+
+#include <rte_mempool.h>
+
+#include "common.h"
+
+struct mempool {
+	TAILQ_ENTRY(mempool) node;
+	char name[NAME_SIZE];
+	struct rte_mempool *m;
+	uint32_t buffer_size;
+};
+
+TAILQ_HEAD(mempool_list, mempool);
+
+int
+mempool_init(void);
+
+struct mempool *
+mempool_find(const char *name);
+
+struct mempool_params {
+	uint32_t buffer_size;
+	uint32_t pool_size;
+	uint32_t cache_size;
+	uint32_t cpu_id;
+};
+
+struct mempool *
+mempool_create(const char *name, struct mempool_params *params);
+
+#endif /* _INCLUDE_MEMPOOL_H_ */
examples/ip_pipeline/meson.build +1 -0
index a89cb30..f8a450f 100644
@@ -11,5 +11,6 @@ sources = files(
 	'cli.c',
 	'conn.c',
 	'main.c',
+	'mempool.c',
 	'parser.c',
 )
Signature · 1 line
2.9.3
#156 lore raw

PATCH 13/37 ip_pipeline: add link object

In reply to Jasvinder Singh

Add link object implementation to the application.

---
 examples/ip_pipeline/Makefile    |   1 +
 examples/ip_pipeline/cli.c       | 122 ++++++++++++++++++
 examples/ip_pipeline/link.c      | 268 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/link.h      |  63 +++++++++
 examples/ip_pipeline/main.c      |   8 ++
 examples/ip_pipeline/meson.build |   1 +
 6 files changed, 463 insertions(+)
 create mode 100644 examples/ip_pipeline/link.c
 create mode 100644 examples/ip_pipeline/link.h
examples/ip_pipeline/Makefile +1 -0
index fca28c5..3dab932 100644
@@ -7,6 +7,7 @@ APP = ip_pipeline
 # all source are stored in SRCS-y
 SRCS-y := cli.c
 SRCS-y += conn.c
+SRCS-y += link.c
 SRCS-y += main.c
 SRCS-y += mempool.c
 SRCS-y += parser.c
examples/ip_pipeline/cli.c +122 -0

140 lines not on this page · raw message

examples/ip_pipeline/link.c new file +268 -0

268 lines not on this page · raw message

examples/ip_pipeline/link.h new file +63 -0

63 lines not on this page · raw message

examples/ip_pipeline/main.c +8 -0
index b53f623..edfb523 100644
@@ -12,6 +12,7 @@
 
 #include "cli.h"
 #include "conn.h"
+#include "link.h"
 #include "mempool.h"
 
 static const char usage[] =
@@ -167,6 +168,13 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* Link */
+	status = link_init();
+	if (status) {
+		printf("Error: Link initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/meson.build +1 -0
index f8a450f..a2f9bb6 100644
@@ -10,6 +10,7 @@ deps += ['pipeline', 'bus_pci']
 sources = files(
 	'cli.c',
 	'conn.c',
+	'link.c',
 	'main.c',
 	'mempool.c',
 	'parser.c',
Signature · 1 line
2.9.3
#157 lore raw

PATCH 14/37 ip_pipeline: add software queue object

In reply to Jasvinder Singh

Add swq object implementation to the application.

---
 examples/ip_pipeline/Makefile    |  1 +
 examples/ip_pipeline/cli.c       | 55 +++++++++++++++++++++++++++++
 examples/ip_pipeline/main.c      |  8 +++++
 examples/ip_pipeline/meson.build |  1 +
 examples/ip_pipeline/swq.c       | 74 ++++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/swq.h       | 37 ++++++++++++++++++++
 6 files changed, 176 insertions(+)
 create mode 100644 examples/ip_pipeline/swq.c
 create mode 100644 examples/ip_pipeline/swq.h
examples/ip_pipeline/Makefile +1 -0
index 3dab932..0dc8442 100644
@@ -11,6 +11,7 @@ SRCS-y += link.c
 SRCS-y += main.c
 SRCS-y += mempool.c
 SRCS-y += parser.c
+SRCS-y += swq.c
 #SRCS-y += thread.c
 
 # Build using pkg-config variables if possible
examples/ip_pipeline/cli.c +55 -0

73 lines not on this page · raw message

examples/ip_pipeline/main.c +8 -0
index edfb523..456f016 100644
@@ -14,6 +14,7 @@
 #include "conn.h"
 #include "link.h"
 #include "mempool.h"
+#include "swq.h"
 
 static const char usage[] =
 	"%s EAL_ARGS -- [-h HOST] [-p PORT] [-s SCRIPT]\n";
@@ -175,6 +176,13 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* SWQ */
+	status = swq_init();
+	if (status) {
+		printf("Error: SWQ initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/meson.build +1 -0
index a2f9bb6..442f3e3 100644
@@ -14,4 +14,5 @@ sources = files(
 	'main.c',
 	'mempool.c',
 	'parser.c',
+	'swq.c',
 )
examples/ip_pipeline/swq.c new file +74 -0

74 lines not on this page · raw message

examples/ip_pipeline/swq.h new file +37 -0
new file mode 100644
index 0000000..c8440ee
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _INCLUDE_SWQ_H_
+#define _INCLUDE_SWQ_H_
+
+#include <stdint.h>
+#include <sys/queue.h>
+
+#include <rte_ring.h>
+
+#include "common.h"
+
+struct swq {
+	TAILQ_ENTRY(swq) node;
+	char name[NAME_SIZE];
+	struct rte_ring *r;
+};
+
+TAILQ_HEAD(swq_list, swq);
+
+int
+swq_init(void);
+
+struct swq *
+swq_find(const char *name);
+
+struct swq_params {
+	uint32_t size;
+	uint32_t cpu_id;
+};
+
+struct swq *
+swq_create(const char *name, struct swq_params *params);
+
+#endif /* _INCLUDE_SWQ_H_ */
Signature · 1 line
2.9.3
#158 lore raw

PATCH 15/37 ip_pipeline: add traffic manager object

In reply to Jasvinder Singh

Add traffic manager object implementation to the application.

---
 examples/ip_pipeline/Makefile    |   1 +
 examples/ip_pipeline/cli.c       | 360 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/main.c      |   8 +
 examples/ip_pipeline/meson.build |   1 +
 examples/ip_pipeline/tmgr.c      | 227 ++++++++++++++++++++++++
 examples/ip_pipeline/tmgr.h      |  70 ++++++++
 6 files changed, 667 insertions(+)
 create mode 100644 examples/ip_pipeline/tmgr.c
 create mode 100644 examples/ip_pipeline/tmgr.h
examples/ip_pipeline/Makefile +1 -0
index 0dc8442..35e4302 100644
@@ -12,6 +12,7 @@ SRCS-y += main.c
 SRCS-y += mempool.c
 SRCS-y += parser.c
 SRCS-y += swq.c
+SRCS-y += tmgr.c
 #SRCS-y += thread.c
 
 # Build using pkg-config variables if possible
examples/ip_pipeline/cli.c +360 -0

378 lines not on this page · raw message

examples/ip_pipeline/main.c +8 -0
index 456f016..490991f 100644
@@ -15,6 +15,7 @@
 #include "link.h"
 #include "mempool.h"
 #include "swq.h"
+#include "tmgr.h"
 
 static const char usage[] =
 	"%s EAL_ARGS -- [-h HOST] [-p PORT] [-s SCRIPT]\n";
@@ -183,6 +184,13 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* Traffic Manager */
+	status = tmgr_init();
+	if (status) {
+		printf("Error: TMGR initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/meson.build +1 -0
index 442f3e3..cb2154c 100644
@@ -15,4 +15,5 @@ sources = files(
 	'mempool.c',
 	'parser.c',
 	'swq.c',
+	'tmgr.c'
 )
examples/ip_pipeline/tmgr.c new file +227 -0

227 lines not on this page · raw message

examples/ip_pipeline/tmgr.h new file +70 -0

70 lines not on this page · raw message

Signature · 1 line
2.9.3
#159 lore raw

PATCH 16/37 ip_pipeline: add tap object

In reply to Jasvinder Singh

Add tap object implementation to the application

---
 examples/ip_pipeline/Makefile    |  1 +
 examples/ip_pipeline/cli.c       | 32 +++++++++++++
 examples/ip_pipeline/main.c      |  8 ++++
 examples/ip_pipeline/meson.build |  1 +
 examples/ip_pipeline/tap.c       | 97 ++++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/tap.h       | 29 ++++++++++++
 6 files changed, 168 insertions(+)
 create mode 100644 examples/ip_pipeline/tap.c
 create mode 100644 examples/ip_pipeline/tap.h
examples/ip_pipeline/Makefile +1 -0
index 35e4302..0f6bb78 100644
@@ -12,6 +12,7 @@ SRCS-y += main.c
 SRCS-y += mempool.c
 SRCS-y += parser.c
 SRCS-y += swq.c
+SRCS-y += tap.c
 SRCS-y += tmgr.c
 #SRCS-y += thread.c
 
examples/ip_pipeline/cli.c +32 -0
index 99e42c9..5dbd576 100644
@@ -14,6 +14,7 @@
 #include "mempool.h"
 #include "parser.h"
 #include "swq.h"
+#include "tap.h"
 #include "tmgr.h"
 
 #ifndef CMD_MAX_TOKENS
@@ -603,6 +604,32 @@ cmd_tmgr_subport_pipe(char **tokens,
 	}
 }
 
+/**
+ * tap <tap_name>
+ */
+static void
+cmd_tap(char **tokens,
+	uint32_t n_tokens,
+	char *out,
+	size_t out_size)
+{
+	char *name;
+	struct tap *tap;
+
+	if (n_tokens != 2) {
+		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
+		return;
+	}
+
+	name = tokens[1];
+
+	tap = tap_create(name);
+	if (tap == NULL) {
+		snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
+		return;
+	}
+}
+
 void
 cli_process(char *in, char *out, size_t out_size)
 {
@@ -671,6 +698,11 @@ cli_process(char *in, char *out, size_t out_size)
 		return;
 	}
 
+	if (strcmp(tokens[0], "tap") == 0) {
+		cmd_tap(tokens, n_tokens, out, out_size);
+		return;
+	}
+
 	snprintf(out, out_size, MSG_CMD_UNKNOWN, tokens[0]);
 }
 
examples/ip_pipeline/main.c +8 -0
index 490991f..33c3354 100644
@@ -15,6 +15,7 @@
 #include "link.h"
 #include "mempool.h"
 #include "swq.h"
+#include "tap.h"
 #include "tmgr.h"
 
 static const char usage[] =
@@ -191,6 +192,13 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* TAP */
+	status = tap_init();
+	if (status) {
+		printf("Error: TAP initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/meson.build +1 -0
index cb2154c..e875811 100644
@@ -15,5 +15,6 @@ sources = files(
 	'mempool.c',
 	'parser.c',
 	'swq.c',
+	'tap.c',
 	'tmgr.c'
 )
examples/ip_pipeline/tap.c new file +97 -0

97 lines not on this page · raw message

examples/ip_pipeline/tap.h new file +29 -0
new file mode 100644
index 0000000..0dce72f
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _INCLUDE_TAP_H_
+#define _INCLUDE_TAP_H_
+
+#include <sys/queue.h>
+
+#include "common.h"
+
+struct tap {
+	TAILQ_ENTRY(tap) node;
+	char name[NAME_SIZE];
+	int fd;
+};
+
+TAILQ_HEAD(tap_list, tap);
+
+int
+tap_init(void);
+
+struct tap *
+tap_find(const char *name);
+
+struct tap *
+tap_create(const char *name);
+
+#endif /* _INCLUDE_TAP_H_ */
Signature · 1 line
2.9.3
#160 lore raw

PATCH 17/37 ip_pipeline: add kni object

In reply to Jasvinder Singh

Add kni object implementation to the application.

---
 examples/ip_pipeline/Makefile    |   1 +
 examples/ip_pipeline/cli.c       |  65 +++++++++++++++
 examples/ip_pipeline/kni.c       | 165 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/kni.h       |  44 +++++++++++
 examples/ip_pipeline/main.c      |  10 +++
 examples/ip_pipeline/meson.build |   1 +
 6 files changed, 286 insertions(+)
 create mode 100644 examples/ip_pipeline/kni.c
 create mode 100644 examples/ip_pipeline/kni.h
examples/ip_pipeline/Makefile +1 -0
index 0f6bb78..dc56ebf 100644
@@ -7,6 +7,7 @@ APP = ip_pipeline
 # all source are stored in SRCS-y
 SRCS-y := cli.c
 SRCS-y += conn.c
+SRCS-y += kni.c
 SRCS-y += link.c
 SRCS-y += main.c
 SRCS-y += mempool.c
examples/ip_pipeline/cli.c +65 -0

83 lines not on this page · raw message

examples/ip_pipeline/kni.c new file +165 -0

165 lines not on this page · raw message

examples/ip_pipeline/kni.h new file +44 -0

44 lines not on this page · raw message

examples/ip_pipeline/main.c +10 -0
index 33c3354..b65762e 100644
@@ -12,6 +12,7 @@
 
 #include "cli.h"
 #include "conn.h"
+#include "kni.h"
 #include "link.h"
 #include "mempool.h"
 #include "swq.h"
@@ -199,6 +200,13 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* KNI */
+	status = kni_init();
+	if (status) {
+		printf("Error: KNI initialization failed (%d)\n", status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
@@ -210,5 +218,7 @@ main(int argc, char **argv)
 		conn_poll_for_conn(conn);
 
 		conn_poll_for_msg(conn);
+
+		kni_handle_request();
 	}
 }
examples/ip_pipeline/meson.build +1 -0
index e875811..5ad79b2 100644
@@ -10,6 +10,7 @@ deps += ['pipeline', 'bus_pci']
 sources = files(
 	'cli.c',
 	'conn.c',
+	'kni.c',
 	'link.c',
 	'main.c',
 	'mempool.c',
Signature · 1 line
2.9.3
#161 lore raw

PATCH 18/37 ip_pipeline: add action profile object

In reply to Jasvinder Singh

Add action profile object implementation to the application.

---
 examples/ip_pipeline/Makefile    |   3 +-
 examples/ip_pipeline/cli.c       | 309 +++++++++++++++++++++++++++++++++++++++
 examples/ip_pipeline/cli.h       |   2 +
 examples/ip_pipeline/main.c      |   8 +
 examples/ip_pipeline/meson.build |   1 +
 5 files changed, 322 insertions(+), 1 deletion(-)
examples/ip_pipeline/Makefile +2 -1
index dc56ebf..3d7c288 100644
@@ -5,7 +5,8 @@
 APP = ip_pipeline
 
 # all source are stored in SRCS-y
-SRCS-y := cli.c
+SRCS-y := action.c
+SRCS-y += cli.c
 SRCS-y += conn.c
 SRCS-y += kni.c
 SRCS-y += link.c
examples/ip_pipeline/cli.c +309 -0

321 lines not on this page · raw message

examples/ip_pipeline/cli.h +2 -0
index 992e4c3..02564a6 100644
@@ -7,6 +7,8 @@
 
 #include <stddef.h>
 
+#include "action.h"
+
 void
 cli_process(char *in, char *out, size_t out_size);
 
examples/ip_pipeline/main.c +8 -0
index b65762e..24b74cf 100644
@@ -207,6 +207,14 @@ main(int argc, char **argv)
 		return status;
 	}
 
+	/* Action profile */
+	status = table_action_profile_init();
+	if (status) {
+		printf("Error: Action profile initialization failed (%d)\n",
+			status);
+		return status;
+	}
+
 	/* Script */
 	if (app.script_name)
 		cli_script_process(app.script_name,
examples/ip_pipeline/meson.build +1 -0
index 5ad79b2..38a1189 100644
@@ -8,6 +8,7 @@
 
 deps += ['pipeline', 'bus_pci']
 sources = files(
+	'action.c',
 	'cli.c',
 	'conn.c',
 	'kni.c',
Signature · 1 line
2.9.3