DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] pipeline: validate header on emit
Date: Fri, 26 Mar 2021 20:29:35 +0000	[thread overview]
Message-ID: <20210326202935.15771-1-cristian.dumitrescu@intel.com> (raw)

Enhance the behavior of the emit instruction to ignore invalid
headers, as mandated by the P4 language specification.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 lib/librte_pipeline/rte_swx_pipeline.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pipeline/rte_swx_pipeline.c b/lib/librte_pipeline/rte_swx_pipeline.c
index 4455d9135..6a19b1450 100644
--- a/lib/librte_pipeline/rte_swx_pipeline.c
+++ b/lib/librte_pipeline/rte_swx_pipeline.c
@@ -3024,10 +3024,11 @@ __instr_hdr_emit_exec(struct rte_swx_pipeline *p, uint32_t n_emit)
 {
 	struct thread *t = &p->threads[p->thread_id];
 	struct instruction *ip = t->ip;
+	uint64_t valid_headers = t->valid_headers;
 	uint32_t n_headers_out = t->n_headers_out;
 	struct header_out_runtime *ho = &t->headers_out[n_headers_out - 1];
 	uint8_t *ho_ptr = NULL;
-	uint32_t ho_nbytes = 0, i;
+	uint32_t ho_nbytes = 0, first = 1, i;
 
 	for (i = 0; i < n_emit; i++) {
 		uint32_t header_id = ip->io.hdr.header_id[i];
@@ -3037,12 +3038,17 @@ __instr_hdr_emit_exec(struct rte_swx_pipeline *p, uint32_t n_emit)
 		struct header_runtime *hi = &t->headers[header_id];
 		uint8_t *hi_ptr = t->structs[struct_id];
 
+		if (!MASK64_BIT_GET(valid_headers, header_id))
+			continue;
+
 		TRACE("[Thread %2u]: emit header %u\n",
 		      p->thread_id,
 		      header_id);
 
 		/* Headers. */
-		if (!i) {
+		if (first) {
+			first = 0;
+
 			if (!t->n_headers_out) {
 				ho = &t->headers_out[0];
 
-- 
2.17.1


             reply	other threads:[~2021-03-26 20:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26 20:29 Cristian Dumitrescu [this message]
2021-04-20  0:31 ` Thomas Monjalon

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=20210326202935.15771-1-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).