DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/4] pipeline: add table action for packet tag
@ 2018-10-09 15:47 Cristian Dumitrescu
  2018-10-09 15:47 ` [dpdk-dev] [PATCH 2/4] examples/ip_pipeline: add support for packet tag table action Cristian Dumitrescu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Cristian Dumitrescu @ 2018-10-09 15:47 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 | 10 +++++
 2 files changed, 88 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..d700ebf 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,13 @@ struct rte_table_action_sym_crypto_params {
 };
 
 /**
+ * RTE_TABLE_ACTION_TAG
+ */
+struct rte_table_action_tag_params {
+	uint32_t tag;
+};
+
+/**
  * Table action profile.
  */
 struct rte_table_action_profile;
-- 
2.7.4

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

* [dpdk-dev] [PATCH 2/4] examples/ip_pipeline: add support for packet tag table action
  2018-10-09 15:47 [dpdk-dev] [PATCH 1/4] pipeline: add table action for packet tag Cristian Dumitrescu
@ 2018-10-09 15:47 ` Cristian Dumitrescu
  2018-10-09 15:47 ` [dpdk-dev] [PATCH 3/4] net/softnic: " Cristian Dumitrescu
  2018-10-09 15:47 ` [dpdk-dev] [PATCH 4/4] net/softnic: add support for flow api mark action Cristian Dumitrescu
  2 siblings, 0 replies; 4+ messages in thread
From: Cristian Dumitrescu @ 2018-10-09 15:47 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	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH 3/4] net/softnic: add support for packet tag table action
  2018-10-09 15:47 [dpdk-dev] [PATCH 1/4] pipeline: add table action for packet tag Cristian Dumitrescu
  2018-10-09 15:47 ` [dpdk-dev] [PATCH 2/4] examples/ip_pipeline: add support for packet tag table action Cristian Dumitrescu
@ 2018-10-09 15:47 ` Cristian Dumitrescu
  2018-10-09 15:47 ` [dpdk-dev] [PATCH 4/4] net/softnic: add support for flow api mark action Cristian Dumitrescu
  2 siblings, 0 replies; 4+ messages in thread
From: Cristian Dumitrescu @ 2018-10-09 15:47 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..2bb48da 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]
  *
  * 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 < 1 ||
+		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	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH 4/4] net/softnic: add support for flow api mark action
  2018-10-09 15:47 [dpdk-dev] [PATCH 1/4] pipeline: add table action for packet tag Cristian Dumitrescu
  2018-10-09 15:47 ` [dpdk-dev] [PATCH 2/4] examples/ip_pipeline: add support for packet tag table action Cristian Dumitrescu
  2018-10-09 15:47 ` [dpdk-dev] [PATCH 3/4] net/softnic: " Cristian Dumitrescu
@ 2018-10-09 15:47 ` Cristian Dumitrescu
  2 siblings, 0 replies; 4+ messages in thread
From: Cristian Dumitrescu @ 2018-10-09 15:47 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..b7b0b6d 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_STATS */
+			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	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-09 15:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-09 15:47 [dpdk-dev] [PATCH 1/4] pipeline: add table action for packet tag Cristian Dumitrescu
2018-10-09 15:47 ` [dpdk-dev] [PATCH 2/4] examples/ip_pipeline: add support for packet tag table action Cristian Dumitrescu
2018-10-09 15:47 ` [dpdk-dev] [PATCH 3/4] net/softnic: " Cristian Dumitrescu
2018-10-09 15:47 ` [dpdk-dev] [PATCH 4/4] net/softnic: add support for flow api mark action Cristian Dumitrescu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).