From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9ADFFA0A02; Fri, 26 Mar 2021 21:29:40 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2CD75140E01; Fri, 26 Mar 2021 21:29:40 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 8CDB440685 for ; Fri, 26 Mar 2021 21:29:38 +0100 (CET) IronPort-SDR: xCjbiCRxrlgQeJ6Uo+nTdX17JgatXBk8Rpv2V/ZBceVyvfzqH8HTTyzLTabc5PPjRKgKrg/+0C 9rLReo7F1D4Q== X-IronPort-AV: E=McAfee;i="6000,8403,9935"; a="191307439" X-IronPort-AV: E=Sophos;i="5.81,281,1610438400"; d="scan'208";a="191307439" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2021 13:29:37 -0700 IronPort-SDR: dDQpObHH2U0xYjzVEG2QM2b2Ja/mZWXFo1JyvJmAF1V1qnwtKv8XycV9xi7VsErHEiggcQYARQ 0TagM/JJ7RYw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,281,1610438400"; d="scan'208";a="608988291" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by fmsmga005.fm.intel.com with ESMTP; 26 Mar 2021 13:29:36 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Date: Fri, 26 Mar 2021 20:29:35 +0000 Message-Id: <20210326202935.15771-1-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] pipeline: validate header on emit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Enhance the behavior of the emit instruction to ignore invalid headers, as mandated by the P4 language specification. Signed-off-by: Cristian Dumitrescu --- 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