From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 1/4] pipeline: add table action for packet tag
Date: Tue, 9 Oct 2018 16:47:21 +0100 [thread overview]
Message-ID: <1539100044-224533-1-git-send-email-cristian.dumitrescu@intel.com> (raw)
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
next reply other threads:[~2018-10-09 15:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-09 15:47 Cristian Dumitrescu [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1539100044-224533-1-git-send-email-cristian.dumitrescu@intel.com \
--to=cristian.dumitrescu@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).