From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 20D01A04B1; Wed, 30 Sep 2020 08:38:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F2F401DAFA; Wed, 30 Sep 2020 08:35:24 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 4CCE71DAD4 for ; Wed, 30 Sep 2020 08:34:35 +0200 (CEST) IronPort-SDR: ywY/qr8RYOYK//0lDQ1+G8QkdTo04eSDhf65emzDcNRVHQYLeX1p0xLq8bkLvhqV2oPpL8deGY p+jyqnh5zBPw== X-IronPort-AV: E=McAfee;i="6000,8403,9759"; a="163238691" X-IronPort-AV: E=Sophos;i="5.77,321,1596524400"; d="scan'208";a="163238691" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2020 23:34:32 -0700 IronPort-SDR: GOq+4egcciZTlUSr47VBWy/eXbXJmQKk6rOSXXcnb47TthiSZFYYX9FEOcEj7zcmQrtY1mrM73 xCXDtosU4bMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,321,1596524400"; d="scan'208";a="495881891" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by orsmga005.jf.intel.com with ESMTP; 29 Sep 2020 23:34:32 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: thomas@monjalon.net, david.marchand@redhat.com Date: Wed, 30 Sep 2020 07:33:45 +0100 Message-Id: <20200930063416.68428-12-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200930063416.68428-1-cristian.dumitrescu@intel.com> References: <20200923180645.55852-2-cristian.dumitrescu@intel.com> <20200930063416.68428-1-cristian.dumitrescu@intel.com> Subject: [dpdk-dev] [PATCH v6 11/42] pipeline: add header validate and invalidate SWX instructions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Add instructions to flag a header as valid or invalid. This flag can be tested by the jmpv (jump if header valid) and jmpnv (jump if header not valid) instructions. Signed-off-by: Cristian Dumitrescu --- lib/librte_pipeline/rte_swx_pipeline.c | 108 +++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/lib/librte_pipeline/rte_swx_pipeline.c b/lib/librte_pipeline/rte_swx_pipeline.c index 19bf2761d..8ddd766c2 100644 --- a/lib/librte_pipeline/rte_swx_pipeline.c +++ b/lib/librte_pipeline/rte_swx_pipeline.c @@ -236,6 +236,12 @@ enum instruction_type { INSTR_HDR_EMIT6_TX, INSTR_HDR_EMIT7_TX, INSTR_HDR_EMIT8_TX, + + /* validate h.header */ + INSTR_HDR_VALIDATE, + + /* invalidate h.header */ + INSTR_HDR_INVALIDATE, }; struct instr_io { @@ -252,10 +258,15 @@ struct instr_io { } hdr; }; +struct instr_hdr_validity { + uint8_t header_id; +}; + struct instruction { enum instruction_type type; union { struct instr_io io; + struct instr_hdr_validity valid; }; }; @@ -2098,6 +2109,84 @@ instr_hdr_emit8_tx_exec(struct rte_swx_pipeline *p) instr_tx_exec(p); } +/* + * validate. + */ +static int +instr_hdr_validate_translate(struct rte_swx_pipeline *p, + struct action *action __rte_unused, + char **tokens, + int n_tokens, + struct instruction *instr, + struct instruction_data *data __rte_unused) +{ + struct header *h; + + CHECK(n_tokens == 2, EINVAL); + + h = header_parse(p, tokens[1]); + CHECK(h, EINVAL); + + instr->type = INSTR_HDR_VALIDATE; + instr->valid.header_id = h->id; + return 0; +} + +static inline void +instr_hdr_validate_exec(struct rte_swx_pipeline *p) +{ + struct thread *t = &p->threads[p->thread_id]; + struct instruction *ip = t->ip; + uint32_t header_id = ip->valid.header_id; + + TRACE("[Thread %2u] validate header %u\n", p->thread_id, header_id); + + /* Headers. */ + t->valid_headers = MASK64_BIT_SET(t->valid_headers, header_id); + + /* Thread. */ + thread_ip_inc(p); +} + +/* + * invalidate. + */ +static int +instr_hdr_invalidate_translate(struct rte_swx_pipeline *p, + struct action *action __rte_unused, + char **tokens, + int n_tokens, + struct instruction *instr, + struct instruction_data *data __rte_unused) +{ + struct header *h; + + CHECK(n_tokens == 2, EINVAL); + + h = header_parse(p, tokens[1]); + CHECK(h, EINVAL); + + instr->type = INSTR_HDR_INVALIDATE; + instr->valid.header_id = h->id; + return 0; +} + +static inline void +instr_hdr_invalidate_exec(struct rte_swx_pipeline *p) +{ + struct thread *t = &p->threads[p->thread_id]; + struct instruction *ip = t->ip; + uint32_t header_id = ip->valid.header_id; + + TRACE("[Thread %2u] invalidate header %u\n", p->thread_id, header_id); + + /* Headers. */ + t->valid_headers = MASK64_BIT_CLR(t->valid_headers, header_id); + + /* Thread. */ + thread_ip_inc(p); +} + #define RTE_SWX_INSTRUCTION_TOKENS_MAX 16 static int @@ -2167,6 +2256,22 @@ instr_translate(struct rte_swx_pipeline *p, instr, data); + if (!strcmp(tokens[tpos], "validate")) + return instr_hdr_validate_translate(p, + action, + &tokens[tpos], + n_tokens - tpos, + instr, + data); + + if (!strcmp(tokens[tpos], "invalidate")) + return instr_hdr_invalidate_translate(p, + action, + &tokens[tpos], + n_tokens - tpos, + instr, + data); + CHECK(0, EINVAL); } @@ -2308,6 +2413,9 @@ static instr_exec_t instruction_table[] = { [INSTR_HDR_EMIT6_TX] = instr_hdr_emit6_tx_exec, [INSTR_HDR_EMIT7_TX] = instr_hdr_emit7_tx_exec, [INSTR_HDR_EMIT8_TX] = instr_hdr_emit8_tx_exec, + + [INSTR_HDR_VALIDATE] = instr_hdr_validate_exec, + [INSTR_HDR_INVALIDATE] = instr_hdr_invalidate_exec, }; static inline void -- 2.17.1