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 0FBCDA04B5; Thu, 29 Oct 2020 19:08:18 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 651A1C8CE; Thu, 29 Oct 2020 19:08:16 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 11A44C8CA for ; Thu, 29 Oct 2020 19:08:14 +0100 (CET) IronPort-SDR: 9bJIv4C2258lyPYMtvT/ar97r0DMZW+jv3jGHkx5yuaTZnWXDtTGuluf7NDMWD6zoov25pVzEG 18cWEk5MFHEw== X-IronPort-AV: E=McAfee;i="6000,8403,9789"; a="168579158" X-IronPort-AV: E=Sophos;i="5.77,430,1596524400"; d="scan'208";a="168579158" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2020 11:08:12 -0700 IronPort-SDR: LC41PTYeddsXa9YTEBv/gEJUMkv4LDCmetSCuLNOcPiZD9Z6ot9meWGcfet9Om54Xe4NNJl4mf NNvIfQxIVUBA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,430,1596524400"; d="scan'208";a="536768099" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by orsmga005.jf.intel.com with ESMTP; 29 Oct 2020 11:08:11 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Cc: david.marchand@redhat.com, Venkata Suresh Kumar P Date: Thu, 29 Oct 2020 18:08:10 +0000 Message-Id: <20201029180810.49636-1-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] pipeline: increase immediate operand size 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" From: Venkata Suresh Kumar P This patch increases the immediate operand size from 32 to 64 bits. Signed-off-by: Venkata Suresh Kumar P Acked-by: Cristian Dumitrescu --- lib/librte_pipeline/rte_swx_pipeline.c | 103 +++++++++++++++++++-------------- lib/librte_pipeline/rte_swx_pipeline.h | 2 +- 2 files changed, 59 insertions(+), 46 deletions(-) diff --git a/lib/librte_pipeline/rte_swx_pipeline.c b/lib/librte_pipeline/rte_swx_pipeline.c index 9d64611..7f62425 100644 --- a/lib/librte_pipeline/rte_swx_pipeline.c +++ b/lib/librte_pipeline/rte_swx_pipeline.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -480,7 +481,7 @@ struct instr_dst_src { struct instr_operand dst; union { struct instr_operand src; - uint32_t src_val; + uint64_t src_val; }; }; @@ -508,7 +509,7 @@ struct instr_jmp { union { struct instr_operand b; - uint32_t b_val; + uint64_t b_val; }; }; @@ -3189,7 +3190,8 @@ struct_field_parse(struct rte_swx_pipeline *p, { char *dst = tokens[1], *src = tokens[2]; struct field *fdst, *fsrc; - uint32_t dst_struct_id, src_struct_id, src_val; + uint64_t src_val; + uint32_t dst_struct_id, src_struct_id; CHECK(n_tokens == 3, EINVAL); @@ -3214,17 +3216,17 @@ struct_field_parse(struct rte_swx_pipeline *p, } /* MOV_I. */ - src_val = strtoul(src, &src, 0); + src_val = strtoull(src, &src, 0); CHECK(!src[0], EINVAL); if (dst[0] == 'h') - src_val = htonl(src_val); + src_val = hton64(src_val) >> (64 - fdst->n_bits); instr->type = INSTR_MOV_I; instr->mov.dst.struct_id = (uint8_t)dst_struct_id; instr->mov.dst.n_bits = fdst->n_bits; instr->mov.dst.offset = fdst->offset / 8; - instr->mov.src_val = (uint32_t)src_val; + instr->mov.src_val = src_val; return 0; } @@ -3264,7 +3266,7 @@ struct_field_parse(struct rte_swx_pipeline *p, struct thread *t = &p->threads[p->thread_id]; struct instruction *ip = t->ip; - TRACE("[Thread %2u] mov m.f %x\n", + TRACE("[Thread %2u] mov m.f %" PRIx64 "\n", p->thread_id, ip->mov.src_val); @@ -3451,7 +3453,8 @@ struct_field_parse(struct rte_swx_pipeline *p, { char *dst = tokens[1], *src = tokens[2]; struct field *fdst, *fsrc; - uint32_t dst_struct_id, src_struct_id, src_val; + uint64_t src_val; + uint32_t dst_struct_id, src_struct_id; CHECK(n_tokens == 3, EINVAL); @@ -3479,7 +3482,7 @@ struct_field_parse(struct rte_swx_pipeline *p, } /* ADD_MI, ADD_HI. */ - src_val = strtoul(src, &src, 0); + src_val = strtoull(src, &src, 0); CHECK(!src[0], EINVAL); instr->type = INSTR_ALU_ADD_MI; @@ -3489,7 +3492,7 @@ struct_field_parse(struct rte_swx_pipeline *p, 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; + instr->alu.src_val = src_val; return 0; } @@ -3503,7 +3506,8 @@ struct_field_parse(struct rte_swx_pipeline *p, { char *dst = tokens[1], *src = tokens[2]; struct field *fdst, *fsrc; - uint32_t dst_struct_id, src_struct_id, src_val; + uint64_t src_val; + uint32_t dst_struct_id, src_struct_id; CHECK(n_tokens == 3, EINVAL); @@ -3531,7 +3535,7 @@ struct_field_parse(struct rte_swx_pipeline *p, } /* SUB_MI, SUB_HI. */ - src_val = strtoul(src, &src, 0); + src_val = strtoull(src, &src, 0); CHECK(!src[0], EINVAL); instr->type = INSTR_ALU_SUB_MI; @@ -3541,7 +3545,7 @@ struct_field_parse(struct rte_swx_pipeline *p, 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; + instr->alu.src_val = src_val; return 0; } @@ -3632,7 +3636,8 @@ struct_field_parse(struct rte_swx_pipeline *p, { char *dst = tokens[1], *src = tokens[2]; struct field *fdst, *fsrc; - uint32_t dst_struct_id, src_struct_id, src_val; + uint64_t src_val; + uint32_t dst_struct_id, src_struct_id; CHECK(n_tokens == 3, EINVAL); @@ -3660,7 +3665,7 @@ struct_field_parse(struct rte_swx_pipeline *p, } /* SHL_MI, SHL_HI. */ - src_val = strtoul(src, &src, 0); + src_val = strtoull(src, &src, 0); CHECK(!src[0], EINVAL); instr->type = INSTR_ALU_SHL_MI; @@ -3670,7 +3675,7 @@ struct_field_parse(struct rte_swx_pipeline *p, 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; + instr->alu.src_val = src_val; return 0; } @@ -3684,7 +3689,8 @@ struct_field_parse(struct rte_swx_pipeline *p, { char *dst = tokens[1], *src = tokens[2]; struct field *fdst, *fsrc; - uint32_t dst_struct_id, src_struct_id, src_val; + uint64_t src_val; + uint32_t dst_struct_id, src_struct_id; CHECK(n_tokens == 3, EINVAL); @@ -3712,7 +3718,7 @@ struct_field_parse(struct rte_swx_pipeline *p, } /* SHR_MI, SHR_HI. */ - src_val = strtoul(src, &src, 0); + src_val = strtoull(src, &src, 0); CHECK(!src[0], EINVAL); instr->type = INSTR_ALU_SHR_MI; @@ -3722,7 +3728,7 @@ struct_field_parse(struct rte_swx_pipeline *p, 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; + instr->alu.src_val = src_val; return 0; } @@ -3736,7 +3742,8 @@ struct_field_parse(struct rte_swx_pipeline *p, { char *dst = tokens[1], *src = tokens[2]; struct field *fdst, *fsrc; - uint32_t dst_struct_id, src_struct_id, src_val; + uint64_t src_val; + uint32_t dst_struct_id, src_struct_id; CHECK(n_tokens == 3, EINVAL); @@ -3761,17 +3768,17 @@ struct_field_parse(struct rte_swx_pipeline *p, } /* AND_I. */ - src_val = strtoul(src, &src, 0); + src_val = strtoull(src, &src, 0); CHECK(!src[0], EINVAL); if (dst[0] == 'h') - src_val = htonl(src_val); + src_val = hton64(src_val) >> (64 - fdst->n_bits); instr->type = INSTR_ALU_AND_I; 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; + instr->alu.src_val = src_val; return 0; } @@ -3785,7 +3792,8 @@ struct_field_parse(struct rte_swx_pipeline *p, { char *dst = tokens[1], *src = tokens[2]; struct field *fdst, *fsrc; - uint32_t dst_struct_id, src_struct_id, src_val; + uint64_t src_val; + uint32_t dst_struct_id, src_struct_id; CHECK(n_tokens == 3, EINVAL); @@ -3810,17 +3818,17 @@ struct_field_parse(struct rte_swx_pipeline *p, } /* OR_I. */ - src_val = strtoul(src, &src, 0); + src_val = strtoull(src, &src, 0); CHECK(!src[0], EINVAL); if (dst[0] == 'h') - src_val = htonl(src_val); + src_val = hton64(src_val) >> (64 - fdst->n_bits); instr->type = INSTR_ALU_OR_I; 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; + instr->alu.src_val = src_val; return 0; } @@ -3834,7 +3842,8 @@ struct_field_parse(struct rte_swx_pipeline *p, { char *dst = tokens[1], *src = tokens[2]; struct field *fdst, *fsrc; - uint32_t dst_struct_id, src_struct_id, src_val; + uint64_t src_val; + uint32_t dst_struct_id, src_struct_id; CHECK(n_tokens == 3, EINVAL); @@ -3859,17 +3868,17 @@ struct_field_parse(struct rte_swx_pipeline *p, } /* XOR_I. */ - src_val = strtoul(src, &src, 0); + src_val = strtoull(src, &src, 0); CHECK(!src[0], EINVAL); if (dst[0] == 'h') - src_val = htonl(src_val); + src_val = hton64(src_val) >> (64 - fdst->n_bits); instr->type = INSTR_ALU_XOR_I; 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; + instr->alu.src_val = src_val; return 0; } @@ -4765,7 +4774,8 @@ struct_field_parse(struct rte_swx_pipeline *p, { char *a = tokens[2], *b = tokens[3]; struct field *fa, *fb; - uint32_t a_struct_id, b_struct_id, b_val; + uint64_t b_val; + uint32_t a_struct_id, b_struct_id; CHECK(n_tokens == 4, EINVAL); @@ -4793,18 +4803,18 @@ struct_field_parse(struct rte_swx_pipeline *p, } /* JMP_EQ_I. */ - b_val = strtoul(b, &b, 0); + b_val = strtoull(b, &b, 0); CHECK(!b[0], EINVAL); if (a[0] == 'h') - b_val = htonl(b_val); + b_val = hton64(b_val) >> (64 - fa->n_bits); instr->type = INSTR_JMP_EQ_I; instr->jmp.ip = NULL; /* Resolved later. */ instr->jmp.a.struct_id = (uint8_t)a_struct_id; instr->jmp.a.n_bits = fa->n_bits; instr->jmp.a.offset = fa->offset / 8; - instr->jmp.b_val = (uint32_t)b_val; + instr->jmp.b_val = b_val; return 0; } @@ -4818,7 +4828,8 @@ struct_field_parse(struct rte_swx_pipeline *p, { char *a = tokens[2], *b = tokens[3]; struct field *fa, *fb; - uint32_t a_struct_id, b_struct_id, b_val; + uint64_t b_val; + uint32_t a_struct_id, b_struct_id; CHECK(n_tokens == 4, EINVAL); @@ -4846,18 +4857,18 @@ struct_field_parse(struct rte_swx_pipeline *p, } /* JMP_NEQ_I. */ - b_val = strtoul(b, &b, 0); + b_val = strtoull(b, &b, 0); CHECK(!b[0], EINVAL); if (a[0] == 'h') - b_val = htonl(b_val); + b_val = hton64(b_val) >> (64 - fa->n_bits); instr->type = INSTR_JMP_NEQ_I; instr->jmp.ip = NULL; /* Resolved later. */ instr->jmp.a.struct_id = (uint8_t)a_struct_id; instr->jmp.a.n_bits = fa->n_bits; instr->jmp.a.offset = fa->offset / 8; - instr->jmp.b_val = (uint32_t)b_val; + instr->jmp.b_val = b_val; return 0; } @@ -4871,7 +4882,8 @@ struct_field_parse(struct rte_swx_pipeline *p, { char *a = tokens[2], *b = tokens[3]; struct field *fa, *fb; - uint32_t a_struct_id, b_struct_id, b_val; + uint64_t b_val; + uint32_t a_struct_id, b_struct_id; CHECK(n_tokens == 4, EINVAL); @@ -4902,7 +4914,7 @@ struct_field_parse(struct rte_swx_pipeline *p, } /* JMP_LT_MI, JMP_LT_HI. */ - b_val = strtoul(b, &b, 0); + b_val = strtoull(b, &b, 0); CHECK(!b[0], EINVAL); instr->type = INSTR_JMP_LT_MI; @@ -4913,7 +4925,7 @@ struct_field_parse(struct rte_swx_pipeline *p, instr->jmp.a.struct_id = (uint8_t)a_struct_id; instr->jmp.a.n_bits = fa->n_bits; instr->jmp.a.offset = fa->offset / 8; - instr->jmp.b_val = (uint32_t)b_val; + instr->jmp.b_val = b_val; return 0; } @@ -4927,7 +4939,8 @@ struct_field_parse(struct rte_swx_pipeline *p, { char *a = tokens[2], *b = tokens[3]; struct field *fa, *fb; - uint32_t a_struct_id, b_struct_id, b_val; + uint64_t b_val; + uint32_t a_struct_id, b_struct_id; CHECK(n_tokens == 4, EINVAL); @@ -4958,7 +4971,7 @@ struct_field_parse(struct rte_swx_pipeline *p, } /* JMP_GT_MI, JMP_GT_HI. */ - b_val = strtoul(b, &b, 0); + b_val = strtoull(b, &b, 0); CHECK(!b[0], EINVAL); instr->type = INSTR_JMP_GT_MI; @@ -4969,7 +4982,7 @@ struct_field_parse(struct rte_swx_pipeline *p, instr->jmp.a.struct_id = (uint8_t)a_struct_id; instr->jmp.a.n_bits = fa->n_bits; instr->jmp.a.offset = fa->offset / 8; - instr->jmp.b_val = (uint32_t)b_val; + instr->jmp.b_val = b_val; return 0; } diff --git a/lib/librte_pipeline/rte_swx_pipeline.h b/lib/librte_pipeline/rte_swx_pipeline.h index aed6273..7d59c30 100644 --- a/lib/librte_pipeline/rte_swx_pipeline.h +++ b/lib/librte_pipeline/rte_swx_pipeline.h @@ -371,7 +371,7 @@ struct rte_swx_field_params { *
+-----+---------------------------+------------------+-----+-----+
*
| T   | Table action data field   | t.header.field   | NO  | YES |
*
+-----+---------------------------+------------------+-----+-----+
- *
| I   | Immediate value (32-bit)  | h.header.field   | NO  | YES |
+ *
| I   | Immediate value (64-bit)  | h.header.field   | NO  | YES |
*
+-----+---------------------------+------------------+-----+-----+
* * Instruction set: -- 1.8.3.1