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 C8AEFA04B1; Tue, 8 Sep 2020 22:21:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C1F8D1C1B4; Tue, 8 Sep 2020 22:19:21 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id A60261C112 for ; Tue, 8 Sep 2020 22:19:00 +0200 (CEST) IronPort-SDR: +tAVVqt9Q4k6vKajrCJ0naqUr9P6Aja3KmmzxezU4/2YuIx958mEge3BMroFnYwvLk7rcqzreb xh7r1iHy9PvQ== X-IronPort-AV: E=McAfee;i="6000,8403,9738"; a="145939405" X-IronPort-AV: E=Sophos;i="5.76,407,1592895600"; d="scan'208";a="145939405" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2020 13:18:47 -0700 IronPort-SDR: UimwZnjys1f0/18Cm5OkQDXdo5gMgNbIYSjNijH4qQRVP2hChbxFPzRX/yDbWsBI/xcH/Exj4L DYhD68b7RJGw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,406,1592895600"; d="scan'208";a="504493431" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by fmsmga006.fm.intel.com with ESMTP; 08 Sep 2020 13:18:46 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Date: Tue, 8 Sep 2020 21:18:04 +0100 Message-Id: <20200908201830.74206-16-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200908201830.74206-1-cristian.dumitrescu@intel.com> References: <20200907214032.95052-2-cristian.dumitrescu@intel.com> <20200908201830.74206-1-cristian.dumitrescu@intel.com> Subject: [dpdk-dev] [PATCH v3 15/41] pipeline: introduce SWX sub instruction 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" The sub (i.e. subtract) instruction source can be header field (H), meta-data field (M), extern object (E) or function (F) mailbox field, table entry action data field (T) or immediate value (I). The destination is HMEF. Signed-off-by: Cristian Dumitrescu --- lib/librte_pipeline/rte_swx_pipeline.c | 168 +++++++++++++++++++++++++ 1 file changed, 168 insertions(+) diff --git a/lib/librte_pipeline/rte_swx_pipeline.c b/lib/librte_pipeline/rte_swx_pipeline.c index 6eee52f24..245621dc3 100644 --- a/lib/librte_pipeline/rte_swx_pipeline.c +++ b/lib/librte_pipeline/rte_swx_pipeline.c @@ -278,6 +278,17 @@ enum instruction_type { INSTR_ALU_ADD_HH, /* dst = H, src = H */ INSTR_ALU_ADD_MI, /* dst = MEF, src = I */ INSTR_ALU_ADD_HI, /* dst = H, src = I */ + + /* sub dst src + * dst -= src + * dst = HMEF, src = HMEFTI + */ + INSTR_ALU_SUB, /* dst = MEF, src = MEF */ + INSTR_ALU_SUB_MH, /* dst = MEF, src = H */ + INSTR_ALU_SUB_HM, /* dst = H, src = MEF */ + INSTR_ALU_SUB_HH, /* dst = H, src = H */ + INSTR_ALU_SUB_MI, /* dst = MEF, src = I */ + INSTR_ALU_SUB_HI, /* dst = H, src = I */ }; struct instr_operand { @@ -2916,6 +2927,58 @@ instr_alu_add_translate(struct rte_swx_pipeline *p, return 0; } +static int +instr_alu_sub_translate(struct rte_swx_pipeline *p, + struct action *action, + char **tokens, + int n_tokens, + struct instruction *instr, + struct instruction_data *data __rte_unused) +{ + char *dst = tokens[1], *src = tokens[2]; + struct field *fdst, *fsrc; + uint32_t dst_struct_id, src_struct_id, src_val; + + CHECK(n_tokens == 3, EINVAL); + + fdst = struct_field_parse(p, NULL, dst, &dst_struct_id); + CHECK(fdst, EINVAL); + + /* SUB, SUB_HM, SUB_MH, SUB_HH. */ + fsrc = struct_field_parse(p, action, src, &src_struct_id); + if (fsrc) { + instr->type = INSTR_ALU_SUB; + if (dst[0] == 'h' && src[0] == 'm') + instr->type = INSTR_ALU_SUB_HM; + if (dst[0] == 'm' && src[0] == 'h') + instr->type = INSTR_ALU_SUB_MH; + if (dst[0] == 'h' && src[0] == 'h') + instr->type = INSTR_ALU_SUB_HH; + + instr->alu.dst.struct_id = (uint8_t)dst_struct_id; + instr->alu.dst.n_bits = fdst->n_bits; + instr->alu.dst.offset = fdst->offset / 8; + instr->alu.src.struct_id = (uint8_t)src_struct_id; + instr->alu.src.n_bits = fsrc->n_bits; + instr->alu.src.offset = fsrc->offset / 8; + return 0; + } + + /* SUB_MI, SUB_HI. */ + src_val = strtoul(src, &src, 0); + CHECK(!src[0], EINVAL); + + instr->type = INSTR_ALU_SUB_MI; + if (dst[0] == 'h') + instr->type = INSTR_ALU_SUB_HI; + + instr->alu.dst.struct_id = (uint8_t)dst_struct_id; + instr->alu.dst.n_bits = fdst->n_bits; + instr->alu.dst.offset = fdst->offset / 8; + instr->alu.src_val = (uint32_t)src_val; + return 0; +} + static inline void instr_alu_add_exec(struct rte_swx_pipeline *p) { @@ -3006,6 +3069,96 @@ instr_alu_add_hi_exec(struct rte_swx_pipeline *p) thread_ip_inc(p); } +static inline void +instr_alu_sub_exec(struct rte_swx_pipeline *p) +{ + struct thread *t = &p->threads[p->thread_id]; + struct instruction *ip = t->ip; + + TRACE("[Thread %2u] sub\n", p->thread_id); + + /* Structs. */ + ALU(t, ip, -); + + /* Thread. */ + thread_ip_inc(p); +} + +static inline void +instr_alu_sub_mh_exec(struct rte_swx_pipeline *p) +{ + struct thread *t = &p->threads[p->thread_id]; + struct instruction *ip = t->ip; + + TRACE("[Thread %2u] sub (mh)\n", p->thread_id); + + /* Structs. */ + ALU_MH(t, ip, -); + + /* Thread. */ + thread_ip_inc(p); +} + +static inline void +instr_alu_sub_hm_exec(struct rte_swx_pipeline *p) +{ + struct thread *t = &p->threads[p->thread_id]; + struct instruction *ip = t->ip; + + TRACE("[Thread %2u] sub (hm)\n", p->thread_id); + + /* Structs. */ + ALU_HM(t, ip, -); + + /* Thread. */ + thread_ip_inc(p); +} + +static inline void +instr_alu_sub_hh_exec(struct rte_swx_pipeline *p) +{ + struct thread *t = &p->threads[p->thread_id]; + struct instruction *ip = t->ip; + + TRACE("[Thread %2u] sub (hh)\n", p->thread_id); + + /* Structs. */ + ALU_HH(t, ip, -); + + /* Thread. */ + thread_ip_inc(p); +} + +static inline void +instr_alu_sub_mi_exec(struct rte_swx_pipeline *p) +{ + struct thread *t = &p->threads[p->thread_id]; + struct instruction *ip = t->ip; + + TRACE("[Thread %2u] sub (mi)\n", p->thread_id); + + /* Structs. */ + ALU_MI(t, ip, -); + + /* Thread. */ + thread_ip_inc(p); +} + +static inline void +instr_alu_sub_hi_exec(struct rte_swx_pipeline *p) +{ + struct thread *t = &p->threads[p->thread_id]; + struct instruction *ip = t->ip; + + TRACE("[Thread %2u] sub (hi)\n", p->thread_id); + + /* Structs. */ + ALU_HI(t, ip, -); + + /* Thread. */ + thread_ip_inc(p); +} + #define RTE_SWX_INSTRUCTION_TOKENS_MAX 16 static int @@ -3115,6 +3268,14 @@ instr_translate(struct rte_swx_pipeline *p, instr, data); + if (!strcmp(tokens[tpos], "sub")) + return instr_alu_sub_translate(p, + action, + &tokens[tpos], + n_tokens - tpos, + instr, + data); + CHECK(0, EINVAL); } @@ -3279,6 +3440,13 @@ static instr_exec_t instruction_table[] = { [INSTR_ALU_ADD_HH] = instr_alu_add_hh_exec, [INSTR_ALU_ADD_MI] = instr_alu_add_mi_exec, [INSTR_ALU_ADD_HI] = instr_alu_add_hi_exec, + + [INSTR_ALU_SUB] = instr_alu_sub_exec, + [INSTR_ALU_SUB_MH] = instr_alu_sub_mh_exec, + [INSTR_ALU_SUB_HM] = instr_alu_sub_hm_exec, + [INSTR_ALU_SUB_HH] = instr_alu_sub_hh_exec, + [INSTR_ALU_SUB_MI] = instr_alu_sub_mi_exec, + [INSTR_ALU_SUB_HI] = instr_alu_sub_hi_exec, }; static inline void -- 2.17.1