From: Venkata Suresh Kumar P Date: Thu, 29 Oct 2020 18:08:10 +0000 (+0000) Subject: pipeline: increase SWX immediate operand size X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2ceb0974ee0981f892cc31dd6bec2187473f7d0e;p=dpdk.git pipeline: increase SWX immediate operand size This patch increases the immediate operand size from 32 to 64 bits. Signed-off-by: Venkata Suresh Kumar P Acked-by: Cristian Dumitrescu --- diff --git a/lib/librte_pipeline/rte_swx_pipeline.c b/lib/librte_pipeline/rte_swx_pipeline.c index 58480788b0..fe8bfc8b3a 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 @@ -490,7 +491,7 @@ struct instr_dst_src { struct instr_operand dst; union { struct instr_operand src; - uint32_t src_val; + uint64_t src_val; }; }; @@ -518,7 +519,7 @@ struct instr_jmp { union { struct instr_operand b; - uint32_t b_val; + uint64_t b_val; }; }; @@ -3199,7 +3200,8 @@ instr_mov_translate(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); @@ -3224,17 +3226,17 @@ instr_mov_translate(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; } @@ -3274,7 +3276,7 @@ instr_mov_i_exec(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); @@ -3461,7 +3463,8 @@ instr_alu_add_translate(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); @@ -3489,7 +3492,7 @@ instr_alu_add_translate(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; @@ -3499,7 +3502,7 @@ instr_alu_add_translate(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; } @@ -3513,7 +3516,8 @@ instr_alu_sub_translate(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); @@ -3541,7 +3545,7 @@ instr_alu_sub_translate(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; @@ -3551,7 +3555,7 @@ instr_alu_sub_translate(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; } @@ -3642,7 +3646,8 @@ instr_alu_shl_translate(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); @@ -3670,7 +3675,7 @@ instr_alu_shl_translate(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; @@ -3680,7 +3685,7 @@ instr_alu_shl_translate(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; } @@ -3694,7 +3699,8 @@ instr_alu_shr_translate(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); @@ -3722,7 +3728,7 @@ instr_alu_shr_translate(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; @@ -3732,7 +3738,7 @@ instr_alu_shr_translate(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; } @@ -3746,7 +3752,8 @@ instr_alu_and_translate(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); @@ -3771,17 +3778,17 @@ instr_alu_and_translate(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; } @@ -3795,7 +3802,8 @@ instr_alu_or_translate(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); @@ -3820,17 +3828,17 @@ instr_alu_or_translate(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; } @@ -3844,7 +3852,8 @@ instr_alu_xor_translate(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); @@ -3869,17 +3878,17 @@ instr_alu_xor_translate(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; } @@ -4775,7 +4784,8 @@ instr_jmp_eq_translate(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); @@ -4803,18 +4813,18 @@ instr_jmp_eq_translate(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; } @@ -4828,7 +4838,8 @@ instr_jmp_neq_translate(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); @@ -4856,18 +4867,18 @@ instr_jmp_neq_translate(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; } @@ -4881,7 +4892,8 @@ instr_jmp_lt_translate(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); @@ -4912,7 +4924,7 @@ instr_jmp_lt_translate(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; @@ -4923,7 +4935,7 @@ instr_jmp_lt_translate(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; } @@ -4937,7 +4949,8 @@ instr_jmp_gt_translate(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); @@ -4968,7 +4981,7 @@ instr_jmp_gt_translate(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; @@ -4979,7 +4992,7 @@ instr_jmp_gt_translate(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 f21a99556e..d0a3439edf 100644 --- a/lib/librte_pipeline/rte_swx_pipeline.h +++ b/lib/librte_pipeline/rte_swx_pipeline.h @@ -382,7 +382,7 @@ rte_swx_pipeline_packet_metadata_register(struct rte_swx_pipeline *p, *
+-----+---------------------------+------------------+-----+-----+
*
| 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: