All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/8] pipeline: add table action for packet tag
@ 2018-10-10 17:53 Cristian Dumitrescu
  2018-10-10 17:53 ` [PATCH v2 2/8] examples/ip_pipeline: add support for packet tag table action Cristian Dumitrescu
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Cristian Dumitrescu @ 2018-10-10 17:53 UTC (permalink / raw)
  To: dev

This patch introduces the packet tag table action which attaches
a 32-bit value (the tag) to the current input packet. The tag is
read from the current table entry. The tag is written into the
mbuf->hash.fdir.hi and the flags PKT_RX_FDIR and PKT_RX_FDIR_ID
are set into mbuf->ol_flags.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 lib/librte_pipeline/rte_table_action.c | 78 ++++++++++++++++++++++++++++++++++
 lib/librte_pipeline/rte_table_action.h | 12 ++++++
 2 files changed, 90 insertions(+)

diff --git a/lib/librte_pipeline/rte_table_action.c b/lib/librte_pipeline/rte_table_action.c
index edb3340..fb7eaf9 100644
--- a/lib/librte_pipeline/rte_table_action.c
+++ b/lib/librte_pipeline/rte_table_action.c
@@ -2012,6 +2012,50 @@ pkt_work_sym_crypto(struct rte_mbuf *mbuf, struct sym_crypto_data *data,
 }
 
 /**
+ * RTE_TABLE_ACTION_TAG
+ */
+struct tag_data {
+	uint32_t tag;
+} __attribute__((__packed__));
+
+static int
+tag_apply(struct tag_data *data,
+	struct rte_table_action_tag_params *p)
+{
+	data->tag = p->tag;
+	return 0;
+}
+
+static __rte_always_inline void
+pkt_work_tag(struct rte_mbuf *mbuf,
+	struct tag_data *data)
+{
+	mbuf->hash.fdir.hi = data->tag;
+	mbuf->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
+}
+
+static __rte_always_inline void
+pkt4_work_tag(struct rte_mbuf *mbuf0,
+	struct rte_mbuf *mbuf1,
+	struct rte_mbuf *mbuf2,
+	struct rte_mbuf *mbuf3,
+	struct tag_data *data0,
+	struct tag_data *data1,
+	struct tag_data *data2,
+	struct tag_data *data3)
+{
+	mbuf0->hash.fdir.hi = data0->tag;
+	mbuf1->hash.fdir.hi = data1->tag;
+	mbuf2->hash.fdir.hi = data2->tag;
+	mbuf3->hash.fdir.hi = data3->tag;
+
+	mbuf0->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
+	mbuf1->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
+	mbuf2->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
+	mbuf3->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
+}
+
+/**
  * Action profile
  */
 static int
@@ -2028,6 +2072,7 @@ action_valid(enum rte_table_action_type action)
 	case RTE_TABLE_ACTION_STATS:
 	case RTE_TABLE_ACTION_TIME:
 	case RTE_TABLE_ACTION_SYM_CRYPTO:
+	case RTE_TABLE_ACTION_TAG:
 		return 1;
 	default:
 		return 0;
@@ -2162,6 +2207,9 @@ action_data_size(enum rte_table_action_type action,
 	case RTE_TABLE_ACTION_SYM_CRYPTO:
 		return (sizeof(struct sym_crypto_data));
 
+	case RTE_TABLE_ACTION_TAG:
+		return sizeof(struct tag_data);
+
 	default:
 		return 0;
 	}
@@ -2419,6 +2467,10 @@ rte_table_action_apply(struct rte_table_action *action,
 				&action->cfg.sym_crypto,
 				action_params);
 
+	case RTE_TABLE_ACTION_TAG:
+		return tag_apply(action_data,
+			action_params);
+
 	default:
 		return -EINVAL;
 	}
@@ -2803,6 +2855,14 @@ pkt_work(struct rte_mbuf *mbuf,
 				ip_offset);
 	}
 
+	if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_TAG)) {
+		void *data = action_data_get(table_entry,
+			action,
+			RTE_TABLE_ACTION_TAG);
+
+		pkt_work_tag(mbuf, data);
+	}
+
 	return drop_mask;
 }
 
@@ -3111,6 +3171,24 @@ pkt4_work(struct rte_mbuf **mbufs,
 				ip_offset);
 	}
 
+	if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_TAG)) {
+		void *data0 = action_data_get(table_entry0,
+			action,
+			RTE_TABLE_ACTION_TAG);
+		void *data1 = action_data_get(table_entry1,
+			action,
+			RTE_TABLE_ACTION_TAG);
+		void *data2 = action_data_get(table_entry2,
+			action,
+			RTE_TABLE_ACTION_TAG);
+		void *data3 = action_data_get(table_entry3,
+			action,
+			RTE_TABLE_ACTION_TAG);
+
+		pkt4_work_tag(mbuf0, mbuf1, mbuf2, mbuf3,
+			data0, data1, data2, data3);
+	}
+
 	return drop_mask0 |
 		(drop_mask1 << 1) |
 		(drop_mask2 << 2) |
diff --git a/lib/librte_pipeline/rte_table_action.h b/lib/librte_pipeline/rte_table_action.h
index e8a7b66..5dbb147 100644
--- a/lib/librte_pipeline/rte_table_action.h
+++ b/lib/librte_pipeline/rte_table_action.h
@@ -96,6 +96,9 @@ enum rte_table_action_type {
 
 	/** Crypto. */
 	RTE_TABLE_ACTION_SYM_CRYPTO,
+
+	/** Tag. */
+	RTE_TABLE_ACTION_TAG,
 };
 
 /** Common action configuration (per table action profile). */
@@ -771,6 +774,15 @@ struct rte_table_action_sym_crypto_params {
 };
 
 /**
+ * RTE_TABLE_ACTION_TAG
+ */
+/** Tag action parameters (per table rule). */
+struct rte_table_action_tag_params {
+	/** Tag to be attached to the input packet. */
+	uint32_t tag;
+};
+
+/**
  * Table action profile.
  */
 struct rte_table_action_profile;
-- 
2.7.4

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

* [PATCH v2 2/8] examples/ip_pipeline: add support for packet tag table action
  2018-10-10 17:53 [PATCH v2 1/8] pipeline: add table action for packet tag Cristian Dumitrescu
@ 2018-10-10 17:53 ` Cristian Dumitrescu
  2018-10-10 17:53 ` [PATCH v2 3/8] net/softnic: " Cristian Dumitrescu
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Cristian Dumitrescu @ 2018-10-10 17:53 UTC (permalink / raw)
  To: dev

Add support for the packet tag table action.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 examples/ip_pipeline/action.c   | 11 +++++++++++
 examples/ip_pipeline/cli.c      | 38 +++++++++++++++++++++++++++++++++++++-
 examples/ip_pipeline/pipeline.h |  1 +
 examples/ip_pipeline/thread.c   | 10 ++++++++++
 4 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/examples/ip_pipeline/action.c b/examples/ip_pipeline/action.c
index a0f97be..3f825a0 100644
--- a/examples/ip_pipeline/action.c
+++ b/examples/ip_pipeline/action.c
@@ -344,6 +344,17 @@ table_action_profile_create(const char *name,
 		}
 	}
 
+	if (params->action_mask & (1LLU << RTE_TABLE_ACTION_TAG)) {
+		status = rte_table_action_profile_action_register(ap,
+			RTE_TABLE_ACTION_TAG,
+			NULL);
+
+		if (status) {
+			rte_table_action_profile_free(ap);
+			return NULL;
+		}
+	}
+
 	status = rte_table_action_profile_freeze(ap);
 	if (status) {
 		rte_table_action_profile_free(ap);
diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index 3ff7caa..a85d04c 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -1032,7 +1032,8 @@ static const char cmd_table_action_profile_help[] =
 "   [time]\n"
 "   [sym_crypto dev <CRYPTODEV_NAME> offset <op_offset> "
 "       mempool_create <mempool_name>\n"
-"       mempool_init <mempool_name>]\n";
+"       mempool_init <mempool_name>]\n"
+"   [tag]\n";
 
 static void
 cmd_table_action_profile(char **tokens,
@@ -1451,6 +1452,11 @@ cmd_table_action_profile(char **tokens,
 		t0 += 9;
 	} /* sym_crypto */
 
+	if ((t0 < n_tokens) && (strcmp(tokens[t0], "tag") == 0)) {
+		p.action_mask |= 1LLU << RTE_TABLE_ACTION_TAG;
+		t0 += 1;
+	} /* tag */
+
 	if (t0 < n_tokens) {
 		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
 		return;
@@ -3107,6 +3113,7 @@ parse_match(char **tokens,
  *          aead_algo <algo> aead_key <key> aead_iv <iv> aead_aad <aad>
  *          digest_size <size>
  *       data_offset <data_offset>]
+ *    [tag <tag>]
  *
  * where:
  *    <pa> ::= g | y | r | drop
@@ -4068,6 +4075,22 @@ parse_table_action_sym_crypto(char **tokens,
 }
 
 static uint32_t
+parse_table_action_tag(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens < 2) ||
+		strcmp(tokens[0], "tag"))
+		return 0;
+
+	if (parser_read_uint32(&a->tag.tag, tokens[1]))
+		return 0;
+
+	a->action_mask |= 1 << RTE_TABLE_ACTION_TAG;
+	return 2;
+}
+
+static uint32_t
 parse_table_action(char **tokens,
 	uint32_t n_tokens,
 	char *out,
@@ -4218,6 +4241,19 @@ parse_table_action(char **tokens,
 		if (n == 0) {
 			snprintf(out, out_size, MSG_ARG_INVALID,
 				"action sym_crypto");
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
+	if (n_tokens && (strcmp(tokens[0], "tag") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_tag(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action tag");
 			return 0;
 		}
 
diff --git a/examples/ip_pipeline/pipeline.h b/examples/ip_pipeline/pipeline.h
index b6b9dc0..73485f6 100644
--- a/examples/ip_pipeline/pipeline.h
+++ b/examples/ip_pipeline/pipeline.h
@@ -282,6 +282,7 @@ struct table_rule_action {
 	struct rte_table_action_stats_params stats;
 	struct rte_table_action_time_params time;
 	struct rte_table_action_sym_crypto_params sym_crypto;
+	struct rte_table_action_tag_params tag;
 };
 
 int
diff --git a/examples/ip_pipeline/thread.c b/examples/ip_pipeline/thread.c
index 3ec44c9..41891f4 100644
--- a/examples/ip_pipeline/thread.c
+++ b/examples/ip_pipeline/thread.c
@@ -2494,6 +2494,16 @@ action_convert(struct rte_table_action *a,
 			return status;
 	}
 
+	if (action->action_mask & (1LLU << RTE_TABLE_ACTION_TAG)) {
+		status = rte_table_action_apply(a,
+			data,
+			RTE_TABLE_ACTION_TAG,
+			&action->tag);
+
+		if (status)
+			return status;
+	}
+
 	return 0;
 }
 
-- 
2.7.4

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

* [PATCH v2 3/8] net/softnic: add support for packet tag table action
  2018-10-10 17:53 [PATCH v2 1/8] pipeline: add table action for packet tag Cristian Dumitrescu
  2018-10-10 17:53 ` [PATCH v2 2/8] examples/ip_pipeline: add support for packet tag table action Cristian Dumitrescu
@ 2018-10-10 17:53 ` Cristian Dumitrescu
  2018-10-10 17:53 ` [PATCH v2 4/8] net/softnic: add support for flow api mark action Cristian Dumitrescu
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Cristian Dumitrescu @ 2018-10-10 17:53 UTC (permalink / raw)
  To: dev

Add support for packet tag table action.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 drivers/net/softnic/rte_eth_softnic_action.c    | 11 +++++++
 drivers/net/softnic/rte_eth_softnic_cli.c       | 38 +++++++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic_internals.h |  1 +
 drivers/net/softnic/rte_eth_softnic_thread.c    | 10 +++++++
 4 files changed, 60 insertions(+)

diff --git a/drivers/net/softnic/rte_eth_softnic_action.c b/drivers/net/softnic/rte_eth_softnic_action.c
index c542688..133dd06 100644
--- a/drivers/net/softnic/rte_eth_softnic_action.c
+++ b/drivers/net/softnic/rte_eth_softnic_action.c
@@ -364,6 +364,17 @@ softnic_table_action_profile_create(struct pmd_internals *p,
 		}
 	}
 
+	if (params->action_mask & (1LLU << RTE_TABLE_ACTION_TAG)) {
+		status = rte_table_action_profile_action_register(ap,
+			RTE_TABLE_ACTION_TAG,
+			NULL);
+
+		if (status) {
+			rte_table_action_profile_free(ap);
+			return NULL;
+		}
+	}
+
 	status = rte_table_action_profile_freeze(ap);
 	if (status) {
 		rte_table_action_profile_free(ap);
diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c
index dc8ccdc..31c37da 100644
--- a/drivers/net/softnic/rte_eth_softnic_cli.c
+++ b/drivers/net/softnic/rte_eth_softnic_cli.c
@@ -1279,6 +1279,7 @@ cmd_port_in_action_profile(struct pmd_internals *softnic,
  *      stats none | pkts]
  *  [stats pkts | bytes | both]
  *  [time]
+ *  [tag]
  */
 static void
 cmd_table_action_profile(struct pmd_internals *softnic,
@@ -1610,6 +1611,12 @@ cmd_table_action_profile(struct pmd_internals *softnic,
 		t0 += 1;
 	} /* time */
 
+	if (t0 < n_tokens &&
+		(strcmp(tokens[t0], "tag") == 0)) {
+		p.action_mask |= 1LLU << RTE_TABLE_ACTION_TAG;
+		t0 += 1;
+	} /* tag */
+
 	if (t0 < n_tokens) {
 		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
 		return;
@@ -3176,6 +3183,7 @@ parse_match(char **tokens,
  *    [ttl dec | keep]
  *    [stats]
  *    [time]
+ *    [tag <tag>]
  *
  * where:
  *    <pa> ::= g | y | r | drop
@@ -3666,6 +3674,22 @@ parse_table_action_time(char **tokens,
 }
 
 static uint32_t
+parse_table_action_tag(char **tokens,
+	uint32_t n_tokens,
+	struct softnic_table_rule_action *a)
+{
+	if (n_tokens < 2 ||
+		strcmp(tokens[0], "tag"))
+		return 0;
+
+	if (softnic_parser_read_uint32(&a->tag.tag, tokens[1]))
+		return 0;
+
+	a->action_mask |= 1 << RTE_TABLE_ACTION_TAG;
+	return 2;
+}
+
+static uint32_t
 parse_table_action(char **tokens,
 	uint32_t n_tokens,
 	char *out,
@@ -3809,6 +3833,20 @@ parse_table_action(char **tokens,
 		n_tokens -= n;
 	}
 
+	if (n_tokens && (strcmp(tokens[0], "tag") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_tag(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action tag");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
 	if (n_tokens0 - n_tokens == 1) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "action");
 		return 0;
diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h
index 78864e7..1623ff8 100644
--- a/drivers/net/softnic/rte_eth_softnic_internals.h
+++ b/drivers/net/softnic/rte_eth_softnic_internals.h
@@ -897,6 +897,7 @@ struct softnic_table_rule_action {
 	struct rte_table_action_ttl_params ttl;
 	struct rte_table_action_stats_params stats;
 	struct rte_table_action_time_params time;
+	struct rte_table_action_tag_params tag;
 };
 
 struct rte_flow {
diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c
index 87b5592..e1d002e 100644
--- a/drivers/net/softnic/rte_eth_softnic_thread.c
+++ b/drivers/net/softnic/rte_eth_softnic_thread.c
@@ -2478,6 +2478,16 @@ action_convert(struct rte_table_action *a,
 			return status;
 	}
 
+	if (action->action_mask & (1LLU << RTE_TABLE_ACTION_TAG)) {
+		status = rte_table_action_apply(a,
+			data,
+			RTE_TABLE_ACTION_TAG,
+			&action->tag);
+
+		if (status)
+			return status;
+	}
+
 	return 0;
 }
 
-- 
2.7.4

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

* [PATCH v2 4/8] net/softnic: add support for flow api mark action
  2018-10-10 17:53 [PATCH v2 1/8] pipeline: add table action for packet tag Cristian Dumitrescu
  2018-10-10 17:53 ` [PATCH v2 2/8] examples/ip_pipeline: add support for packet tag table action Cristian Dumitrescu
  2018-10-10 17:53 ` [PATCH v2 3/8] net/softnic: " Cristian Dumitrescu
@ 2018-10-10 17:53 ` Cristian Dumitrescu
  2018-10-10 17:53 ` [PATCH v2 5/8] pipeline: add table action for packet decap Cristian Dumitrescu
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Cristian Dumitrescu @ 2018-10-10 17:53 UTC (permalink / raw)
  To: dev

Add support for ethdev flow API mark action.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 drivers/net/softnic/rte_eth_softnic_flow.c | 35 ++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/drivers/net/softnic/rte_eth_softnic_flow.c b/drivers/net/softnic/rte_eth_softnic_flow.c
index 30aa6af..9bb0d56 100644
--- a/drivers/net/softnic/rte_eth_softnic_flow.c
+++ b/drivers/net/softnic/rte_eth_softnic_flow.c
@@ -1168,6 +1168,7 @@ flow_rule_action_get(struct pmd_internals *softnic,
 	struct softnic_table_action_profile_params *params;
 	int n_jump_queue_rss_drop = 0;
 	int n_count = 0;
+	int n_mark = 0;
 
 	profile = softnic_table_action_profile_find(softnic,
 		table->params.action_profile_name);
@@ -1475,6 +1476,40 @@ flow_rule_action_get(struct pmd_internals *softnic,
 			break;
 		} /* RTE_FLOW_ACTION_TYPE_COUNT */
 
+		case RTE_FLOW_ACTION_TYPE_MARK:
+		{
+			const struct rte_flow_action_mark *conf = action->conf;
+
+			if (conf == NULL)
+				return rte_flow_error_set(error,
+					EINVAL,
+					RTE_FLOW_ERROR_TYPE_ACTION,
+					action,
+					"MARK: Null configuration");
+
+			if (n_mark)
+				return rte_flow_error_set(error,
+					ENOTSUP,
+					RTE_FLOW_ERROR_TYPE_ACTION,
+					action,
+					"Only one MARK action per flow");
+
+			if ((params->action_mask &
+				(1LLU << RTE_TABLE_ACTION_TAG)) == 0)
+				return rte_flow_error_set(error,
+					ENOTSUP,
+					RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+					NULL,
+					"MARK action not supported by this table");
+
+			n_mark = 1;
+
+			/* RTE_TABLE_ACTION_TAG */
+			rule_action->tag.tag = conf->id;
+			rule_action->action_mask |= 1 << RTE_TABLE_ACTION_TAG;
+			break;
+		} /* RTE_FLOW_ACTION_TYPE_MARK */
+
 		case RTE_FLOW_ACTION_TYPE_METER:
 		{
 			const struct rte_flow_action_meter *conf = action->conf;
-- 
2.7.4

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

* [PATCH v2 5/8] pipeline: add table action for packet decap
  2018-10-10 17:53 [PATCH v2 1/8] pipeline: add table action for packet tag Cristian Dumitrescu
                   ` (2 preceding siblings ...)
  2018-10-10 17:53 ` [PATCH v2 4/8] net/softnic: add support for flow api mark action Cristian Dumitrescu
@ 2018-10-10 17:53 ` Cristian Dumitrescu
  2018-10-10 17:53 ` [PATCH v2 6/8] examples/ip_pipeline: add support for packet decap table action Cristian Dumitrescu
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Cristian Dumitrescu @ 2018-10-10 17:53 UTC (permalink / raw)
  To: dev

This patch introduces a new table action for packet decapsulation
which removes n bytes from the start of the input packet. The n
is read from the current table entry. The following mbuf fields
are updated by the action: data_off, data_len, pkt_len.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 lib/librte_pipeline/rte_table_action.c | 111 +++++++++++++++++++++++++++++++++
 lib/librte_pipeline/rte_table_action.h |  12 ++++
 2 files changed, 123 insertions(+)

diff --git a/lib/librte_pipeline/rte_table_action.c b/lib/librte_pipeline/rte_table_action.c
index fb7eaf9..6fa31e1 100644
--- a/lib/librte_pipeline/rte_table_action.c
+++ b/lib/librte_pipeline/rte_table_action.c
@@ -2056,6 +2056,83 @@ pkt4_work_tag(struct rte_mbuf *mbuf0,
 }
 
 /**
+ * RTE_TABLE_ACTION_DECAP
+ */
+struct decap_data {
+	uint16_t n;
+} __attribute__((__packed__));
+
+static int
+decap_apply(struct decap_data *data,
+	struct rte_table_action_decap_params *p)
+{
+	data->n = p->n;
+	return 0;
+}
+
+static __rte_always_inline void
+pkt_work_decap(struct rte_mbuf *mbuf,
+	struct decap_data *data)
+{
+	uint16_t data_off = mbuf->data_off;
+	uint16_t data_len = mbuf->data_len;
+	uint32_t pkt_len = mbuf->pkt_len;
+	uint16_t n = data->n;
+
+	mbuf->data_off = data_off + n;
+	mbuf->data_len = data_len - n;
+	mbuf->pkt_len = pkt_len - n;
+}
+
+static __rte_always_inline void
+pkt4_work_decap(struct rte_mbuf *mbuf0,
+	struct rte_mbuf *mbuf1,
+	struct rte_mbuf *mbuf2,
+	struct rte_mbuf *mbuf3,
+	struct decap_data *data0,
+	struct decap_data *data1,
+	struct decap_data *data2,
+	struct decap_data *data3)
+{
+	uint16_t data_off0 = mbuf0->data_off;
+	uint16_t data_len0 = mbuf0->data_len;
+	uint32_t pkt_len0 = mbuf0->pkt_len;
+
+	uint16_t data_off1 = mbuf1->data_off;
+	uint16_t data_len1 = mbuf1->data_len;
+	uint32_t pkt_len1 = mbuf1->pkt_len;
+
+	uint16_t data_off2 = mbuf2->data_off;
+	uint16_t data_len2 = mbuf2->data_len;
+	uint32_t pkt_len2 = mbuf2->pkt_len;
+
+	uint16_t data_off3 = mbuf3->data_off;
+	uint16_t data_len3 = mbuf3->data_len;
+	uint32_t pkt_len3 = mbuf3->pkt_len;
+
+	uint16_t n0 = data0->n;
+	uint16_t n1 = data1->n;
+	uint16_t n2 = data2->n;
+	uint16_t n3 = data3->n;
+
+	mbuf0->data_off = data_off0 + n0;
+	mbuf0->data_len = data_len0 - n0;
+	mbuf0->pkt_len = pkt_len0 - n0;
+
+	mbuf1->data_off = data_off1 + n1;
+	mbuf1->data_len = data_len1 - n1;
+	mbuf1->pkt_len = pkt_len1 - n1;
+
+	mbuf2->data_off = data_off2 + n2;
+	mbuf2->data_len = data_len2 - n2;
+	mbuf2->pkt_len = pkt_len2 - n2;
+
+	mbuf3->data_off = data_off3 + n3;
+	mbuf3->data_len = data_len3 - n3;
+	mbuf3->pkt_len = pkt_len3 - n3;
+}
+
+/**
  * Action profile
  */
 static int
@@ -2073,6 +2150,7 @@ action_valid(enum rte_table_action_type action)
 	case RTE_TABLE_ACTION_TIME:
 	case RTE_TABLE_ACTION_SYM_CRYPTO:
 	case RTE_TABLE_ACTION_TAG:
+	case RTE_TABLE_ACTION_DECAP:
 		return 1;
 	default:
 		return 0;
@@ -2210,6 +2288,9 @@ action_data_size(enum rte_table_action_type action,
 	case RTE_TABLE_ACTION_TAG:
 		return sizeof(struct tag_data);
 
+	case RTE_TABLE_ACTION_DECAP:
+		return sizeof(struct decap_data);
+
 	default:
 		return 0;
 	}
@@ -2471,6 +2552,10 @@ rte_table_action_apply(struct rte_table_action *action,
 		return tag_apply(action_data,
 			action_params);
 
+	case RTE_TABLE_ACTION_DECAP:
+		return decap_apply(action_data,
+			action_params);
+
 	default:
 		return -EINVAL;
 	}
@@ -2863,6 +2948,14 @@ pkt_work(struct rte_mbuf *mbuf,
 		pkt_work_tag(mbuf, data);
 	}
 
+	if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_DECAP)) {
+		void *data = action_data_get(table_entry,
+			action,
+			RTE_TABLE_ACTION_DECAP);
+
+		pkt_work_decap(mbuf, data);
+	}
+
 	return drop_mask;
 }
 
@@ -3189,6 +3282,24 @@ pkt4_work(struct rte_mbuf **mbufs,
 			data0, data1, data2, data3);
 	}
 
+	if (cfg->action_mask & (1LLU << RTE_TABLE_ACTION_DECAP)) {
+		void *data0 = action_data_get(table_entry0,
+			action,
+			RTE_TABLE_ACTION_DECAP);
+		void *data1 = action_data_get(table_entry1,
+			action,
+			RTE_TABLE_ACTION_DECAP);
+		void *data2 = action_data_get(table_entry2,
+			action,
+			RTE_TABLE_ACTION_DECAP);
+		void *data3 = action_data_get(table_entry3,
+			action,
+			RTE_TABLE_ACTION_DECAP);
+
+		pkt4_work_decap(mbuf0, mbuf1, mbuf2, mbuf3,
+			data0, data1, data2, data3);
+	}
+
 	return drop_mask0 |
 		(drop_mask1 << 1) |
 		(drop_mask2 << 2) |
diff --git a/lib/librte_pipeline/rte_table_action.h b/lib/librte_pipeline/rte_table_action.h
index 5dbb147..c960612 100644
--- a/lib/librte_pipeline/rte_table_action.h
+++ b/lib/librte_pipeline/rte_table_action.h
@@ -99,6 +99,9 @@ enum rte_table_action_type {
 
 	/** Tag. */
 	RTE_TABLE_ACTION_TAG,
+
+	/** Packet decapsulations. */
+	RTE_TABLE_ACTION_DECAP,
 };
 
 /** Common action configuration (per table action profile). */
@@ -783,6 +786,15 @@ struct rte_table_action_tag_params {
 };
 
 /**
+ * RTE_TABLE_ACTION_DECAP
+ */
+/** Decap action parameters (per table rule). */
+struct rte_table_action_decap_params {
+	/** Number of bytes to be removed from the start of the packet. */
+	uint16_t n;
+};
+
+/**
  * Table action profile.
  */
 struct rte_table_action_profile;
-- 
2.7.4

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

* [PATCH v2 6/8] examples/ip_pipeline: add support for packet decap table action
  2018-10-10 17:53 [PATCH v2 1/8] pipeline: add table action for packet tag Cristian Dumitrescu
                   ` (3 preceding siblings ...)
  2018-10-10 17:53 ` [PATCH v2 5/8] pipeline: add table action for packet decap Cristian Dumitrescu
@ 2018-10-10 17:53 ` Cristian Dumitrescu
  2018-10-10 17:53 ` [PATCH v2 7/8] net/softnic: " Cristian Dumitrescu
  2018-10-10 17:53 ` [PATCH v2 8/8] net/softnic: add support for flow api vxlan decap action Cristian Dumitrescu
  6 siblings, 0 replies; 8+ messages in thread
From: Cristian Dumitrescu @ 2018-10-10 17:53 UTC (permalink / raw)
  To: dev

Add support for packet decap table action.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 examples/ip_pipeline/action.c   | 11 +++++++++++
 examples/ip_pipeline/cli.c      | 39 ++++++++++++++++++++++++++++++++++++++-
 examples/ip_pipeline/pipeline.h |  1 +
 examples/ip_pipeline/thread.c   | 10 ++++++++++
 4 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/examples/ip_pipeline/action.c b/examples/ip_pipeline/action.c
index 3f825a0..d2104aa 100644
--- a/examples/ip_pipeline/action.c
+++ b/examples/ip_pipeline/action.c
@@ -355,6 +355,17 @@ table_action_profile_create(const char *name,
 		}
 	}
 
+	if (params->action_mask & (1LLU << RTE_TABLE_ACTION_DECAP)) {
+		status = rte_table_action_profile_action_register(ap,
+			RTE_TABLE_ACTION_DECAP,
+			NULL);
+
+		if (status) {
+			rte_table_action_profile_free(ap);
+			return NULL;
+		}
+	}
+
 	status = rte_table_action_profile_freeze(ap);
 	if (status) {
 		rte_table_action_profile_free(ap);
diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index a85d04c..d1e5540 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -1033,7 +1033,8 @@ static const char cmd_table_action_profile_help[] =
 "   [sym_crypto dev <CRYPTODEV_NAME> offset <op_offset> "
 "       mempool_create <mempool_name>\n"
 "       mempool_init <mempool_name>]\n"
-"   [tag]\n";
+"   [tag]\n"
+"   [decap]\n";
 
 static void
 cmd_table_action_profile(char **tokens,
@@ -1457,6 +1458,11 @@ cmd_table_action_profile(char **tokens,
 		t0 += 1;
 	} /* tag */
 
+	if ((t0 < n_tokens) && (strcmp(tokens[t0], "decap") == 0)) {
+		p.action_mask |= 1LLU << RTE_TABLE_ACTION_DECAP;
+		t0 += 1;
+	} /* decap */
+
 	if (t0 < n_tokens) {
 		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
 		return;
@@ -3114,6 +3120,7 @@ parse_match(char **tokens,
  *          digest_size <size>
  *       data_offset <data_offset>]
  *    [tag <tag>]
+ *    [decap <n>]
  *
  * where:
  *    <pa> ::= g | y | r | drop
@@ -4091,6 +4098,22 @@ parse_table_action_tag(char **tokens,
 }
 
 static uint32_t
+parse_table_action_decap(char **tokens,
+	uint32_t n_tokens,
+	struct table_rule_action *a)
+{
+	if ((n_tokens < 2) ||
+		strcmp(tokens[0], "decap"))
+		return 0;
+
+	if (parser_read_uint16(&a->decap.n, tokens[1]))
+		return 0;
+
+	a->action_mask |= 1 << RTE_TABLE_ACTION_DECAP;
+	return 2;
+}
+
+static uint32_t
 parse_table_action(char **tokens,
 	uint32_t n_tokens,
 	char *out,
@@ -4261,6 +4284,20 @@ parse_table_action(char **tokens,
 		n_tokens -= n;
 	}
 
+	if (n_tokens && (strcmp(tokens[0], "decap") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_decap(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action decap");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
 	if (n_tokens0 - n_tokens == 1) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "action");
 		return 0;
diff --git a/examples/ip_pipeline/pipeline.h b/examples/ip_pipeline/pipeline.h
index 73485f6..e5b1d5d 100644
--- a/examples/ip_pipeline/pipeline.h
+++ b/examples/ip_pipeline/pipeline.h
@@ -283,6 +283,7 @@ struct table_rule_action {
 	struct rte_table_action_time_params time;
 	struct rte_table_action_sym_crypto_params sym_crypto;
 	struct rte_table_action_tag_params tag;
+	struct rte_table_action_decap_params decap;
 };
 
 int
diff --git a/examples/ip_pipeline/thread.c b/examples/ip_pipeline/thread.c
index 41891f4..4bd971f 100644
--- a/examples/ip_pipeline/thread.c
+++ b/examples/ip_pipeline/thread.c
@@ -2504,6 +2504,16 @@ action_convert(struct rte_table_action *a,
 			return status;
 	}
 
+	if (action->action_mask & (1LLU << RTE_TABLE_ACTION_DECAP)) {
+		status = rte_table_action_apply(a,
+			data,
+			RTE_TABLE_ACTION_DECAP,
+			&action->decap);
+
+		if (status)
+			return status;
+	}
+
 	return 0;
 }
 
-- 
2.7.4

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

* [PATCH v2 7/8] net/softnic: add support for packet decap table action
  2018-10-10 17:53 [PATCH v2 1/8] pipeline: add table action for packet tag Cristian Dumitrescu
                   ` (4 preceding siblings ...)
  2018-10-10 17:53 ` [PATCH v2 6/8] examples/ip_pipeline: add support for packet decap table action Cristian Dumitrescu
@ 2018-10-10 17:53 ` Cristian Dumitrescu
  2018-10-10 17:53 ` [PATCH v2 8/8] net/softnic: add support for flow api vxlan decap action Cristian Dumitrescu
  6 siblings, 0 replies; 8+ messages in thread
From: Cristian Dumitrescu @ 2018-10-10 17:53 UTC (permalink / raw)
  To: dev

Add support for packet decap table action.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 drivers/net/softnic/rte_eth_softnic_action.c    | 11 +++++++
 drivers/net/softnic/rte_eth_softnic_cli.c       | 38 +++++++++++++++++++++++++
 drivers/net/softnic/rte_eth_softnic_internals.h |  1 +
 drivers/net/softnic/rte_eth_softnic_thread.c    | 10 +++++++
 4 files changed, 60 insertions(+)

diff --git a/drivers/net/softnic/rte_eth_softnic_action.c b/drivers/net/softnic/rte_eth_softnic_action.c
index 133dd06..2b74848 100644
--- a/drivers/net/softnic/rte_eth_softnic_action.c
+++ b/drivers/net/softnic/rte_eth_softnic_action.c
@@ -375,6 +375,17 @@ softnic_table_action_profile_create(struct pmd_internals *p,
 		}
 	}
 
+	if (params->action_mask & (1LLU << RTE_TABLE_ACTION_DECAP)) {
+		status = rte_table_action_profile_action_register(ap,
+			RTE_TABLE_ACTION_DECAP,
+			NULL);
+
+		if (status) {
+			rte_table_action_profile_free(ap);
+			return NULL;
+		}
+	}
+
 	status = rte_table_action_profile_freeze(ap);
 	if (status) {
 		rte_table_action_profile_free(ap);
diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c
index 31c37da..2ddd936 100644
--- a/drivers/net/softnic/rte_eth_softnic_cli.c
+++ b/drivers/net/softnic/rte_eth_softnic_cli.c
@@ -1280,6 +1280,7 @@ cmd_port_in_action_profile(struct pmd_internals *softnic,
  *  [stats pkts | bytes | both]
  *  [time]
  *  [tag]
+ *  [decap]
  */
 static void
 cmd_table_action_profile(struct pmd_internals *softnic,
@@ -1617,6 +1618,12 @@ cmd_table_action_profile(struct pmd_internals *softnic,
 		t0 += 1;
 	} /* tag */
 
+	if (t0 < n_tokens &&
+		(strcmp(tokens[t0], "decap") == 0)) {
+		p.action_mask |= 1LLU << RTE_TABLE_ACTION_DECAP;
+		t0 += 1;
+	} /* decap */
+
 	if (t0 < n_tokens) {
 		snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
 		return;
@@ -3184,6 +3191,7 @@ parse_match(char **tokens,
  *    [stats]
  *    [time]
  *    [tag <tag>]
+ *    [decap <n>]
  *
  * where:
  *    <pa> ::= g | y | r | drop
@@ -3690,6 +3698,22 @@ parse_table_action_tag(char **tokens,
 }
 
 static uint32_t
+parse_table_action_decap(char **tokens,
+	uint32_t n_tokens,
+	struct softnic_table_rule_action *a)
+{
+	if (n_tokens < 2 ||
+		strcmp(tokens[0], "decap"))
+		return 0;
+
+	if (softnic_parser_read_uint16(&a->decap.n, tokens[1]))
+		return 0;
+
+	a->action_mask |= 1 << RTE_TABLE_ACTION_DECAP;
+	return 2;
+}
+
+static uint32_t
 parse_table_action(char **tokens,
 	uint32_t n_tokens,
 	char *out,
@@ -3847,6 +3871,20 @@ parse_table_action(char **tokens,
 		n_tokens -= n;
 	}
 
+	if (n_tokens && (strcmp(tokens[0], "decap") == 0)) {
+		uint32_t n;
+
+		n = parse_table_action_decap(tokens, n_tokens, a);
+		if (n == 0) {
+			snprintf(out, out_size, MSG_ARG_INVALID,
+				"action decap");
+			return 0;
+		}
+
+		tokens += n;
+		n_tokens -= n;
+	}
+
 	if (n_tokens0 - n_tokens == 1) {
 		snprintf(out, out_size, MSG_ARG_INVALID, "action");
 		return 0;
diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h
index 1623ff8..9aa19a9 100644
--- a/drivers/net/softnic/rte_eth_softnic_internals.h
+++ b/drivers/net/softnic/rte_eth_softnic_internals.h
@@ -898,6 +898,7 @@ struct softnic_table_rule_action {
 	struct rte_table_action_stats_params stats;
 	struct rte_table_action_time_params time;
 	struct rte_table_action_tag_params tag;
+	struct rte_table_action_decap_params decap;
 };
 
 struct rte_flow {
diff --git a/drivers/net/softnic/rte_eth_softnic_thread.c b/drivers/net/softnic/rte_eth_softnic_thread.c
index e1d002e..c8a8d23 100644
--- a/drivers/net/softnic/rte_eth_softnic_thread.c
+++ b/drivers/net/softnic/rte_eth_softnic_thread.c
@@ -2488,6 +2488,16 @@ action_convert(struct rte_table_action *a,
 			return status;
 	}
 
+	if (action->action_mask & (1LLU << RTE_TABLE_ACTION_DECAP)) {
+		status = rte_table_action_apply(a,
+			data,
+			RTE_TABLE_ACTION_DECAP,
+			&action->decap);
+
+		if (status)
+			return status;
+	}
+
 	return 0;
 }
 
-- 
2.7.4

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

* [PATCH v2 8/8] net/softnic: add support for flow api vxlan decap action
  2018-10-10 17:53 [PATCH v2 1/8] pipeline: add table action for packet tag Cristian Dumitrescu
                   ` (5 preceding siblings ...)
  2018-10-10 17:53 ` [PATCH v2 7/8] net/softnic: " Cristian Dumitrescu
@ 2018-10-10 17:53 ` Cristian Dumitrescu
  6 siblings, 0 replies; 8+ messages in thread
From: Cristian Dumitrescu @ 2018-10-10 17:53 UTC (permalink / raw)
  To: dev

Add support for ethdev flow API VXLAN decap action.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 drivers/net/softnic/rte_eth_softnic_flow.c | 35 ++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/drivers/net/softnic/rte_eth_softnic_flow.c b/drivers/net/softnic/rte_eth_softnic_flow.c
index 9bb0d56..23ef329 100644
--- a/drivers/net/softnic/rte_eth_softnic_flow.c
+++ b/drivers/net/softnic/rte_eth_softnic_flow.c
@@ -1169,6 +1169,7 @@ flow_rule_action_get(struct pmd_internals *softnic,
 	int n_jump_queue_rss_drop = 0;
 	int n_count = 0;
 	int n_mark = 0;
+	int n_vxlan_decap = 0;
 
 	profile = softnic_table_action_profile_find(softnic,
 		table->params.action_profile_name);
@@ -1510,6 +1511,40 @@ flow_rule_action_get(struct pmd_internals *softnic,
 			break;
 		} /* RTE_FLOW_ACTION_TYPE_MARK */
 
+		case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP:
+		{
+			const struct rte_flow_action_mark *conf = action->conf;
+
+			if (conf)
+				return rte_flow_error_set(error,
+					EINVAL,
+					RTE_FLOW_ERROR_TYPE_ACTION,
+					action,
+					"VXLAN DECAP: Non-null configuration");
+
+			if (n_vxlan_decap)
+				return rte_flow_error_set(error,
+					ENOTSUP,
+					RTE_FLOW_ERROR_TYPE_ACTION,
+					action,
+					"Only one VXLAN DECAP action per flow");
+
+			if ((params->action_mask &
+				(1LLU << RTE_TABLE_ACTION_DECAP)) == 0)
+				return rte_flow_error_set(error,
+					ENOTSUP,
+					RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+					NULL,
+					"VXLAN DECAP action not supported by this table");
+
+			n_vxlan_decap = 1;
+
+			/* RTE_TABLE_ACTION_DECAP */
+			rule_action->decap.n = 50; /* Ether/IPv4/UDP/VXLAN */
+			rule_action->action_mask |= 1 << RTE_TABLE_ACTION_DECAP;
+			break;
+		} /* RTE_FLOW_ACTION_TYPE_VXLAN_DECAP */
+
 		case RTE_FLOW_ACTION_TYPE_METER:
 		{
 			const struct rte_flow_action_meter *conf = action->conf;
-- 
2.7.4

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

end of thread, other threads:[~2018-10-10 17:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-10 17:53 [PATCH v2 1/8] pipeline: add table action for packet tag Cristian Dumitrescu
2018-10-10 17:53 ` [PATCH v2 2/8] examples/ip_pipeline: add support for packet tag table action Cristian Dumitrescu
2018-10-10 17:53 ` [PATCH v2 3/8] net/softnic: " Cristian Dumitrescu
2018-10-10 17:53 ` [PATCH v2 4/8] net/softnic: add support for flow api mark action Cristian Dumitrescu
2018-10-10 17:53 ` [PATCH v2 5/8] pipeline: add table action for packet decap Cristian Dumitrescu
2018-10-10 17:53 ` [PATCH v2 6/8] examples/ip_pipeline: add support for packet decap table action Cristian Dumitrescu
2018-10-10 17:53 ` [PATCH v2 7/8] net/softnic: " Cristian Dumitrescu
2018-10-10 17:53 ` [PATCH v2 8/8] net/softnic: add support for flow api vxlan decap action Cristian Dumitrescu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.