* [dpdk-dev] [PATCH] pipeline: increase immediate operand size
@ 2020-10-29 18:08 Cristian Dumitrescu
2020-11-02 20:38 ` David Marchand
0 siblings, 1 reply; 2+ messages in thread
From: Cristian Dumitrescu @ 2020-10-29 18:08 UTC (permalink / raw)
To: dev; +Cc: david.marchand, Venkata Suresh Kumar P
From: Venkata Suresh Kumar P <venkata.suresh.kumar.p@intel.com>
This patch increases the immediate operand size from 32 to 64 bits.
Signed-off-by: Venkata Suresh Kumar P <venkata.suresh.kumar.p@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
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 <string.h>
#include <stdio.h>
#include <errno.h>
+#include <inttypes.h>
#include <sys/queue.h>
#include <arpa/inet.h>
@@ -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 {
*<pre>+-----+---------------------------+------------------+-----+-----+</pre>
*<pre>| T | Table action data field | t.header.field | NO | YES |</pre>
*<pre>+-----+---------------------------+------------------+-----+-----+</pre>
- *<pre>| I | Immediate value (32-bit) | h.header.field | NO | YES |</pre>
+ *<pre>| I | Immediate value (64-bit) | h.header.field | NO | YES |</pre>
*<pre>+-----+---------------------------+------------------+-----+-----+</pre>
*
* Instruction set:
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [PATCH] pipeline: increase immediate operand size
2020-10-29 18:08 [dpdk-dev] [PATCH] pipeline: increase immediate operand size Cristian Dumitrescu
@ 2020-11-02 20:38 ` David Marchand
0 siblings, 0 replies; 2+ messages in thread
From: David Marchand @ 2020-11-02 20:38 UTC (permalink / raw)
To: Cristian Dumitrescu, Venkata Suresh Kumar P; +Cc: dev
On Thu, Oct 29, 2020 at 7:08 PM Cristian Dumitrescu
<cristian.dumitrescu@intel.com> wrote:
>
> From: Venkata Suresh Kumar P <venkata.suresh.kumar.p@intel.com>
>
> This patch increases the immediate operand size from 32 to 64 bits.
>
> Signed-off-by: Venkata Suresh Kumar P <venkata.suresh.kumar.p@intel.com>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Applied, thanks.
--
David Marchand
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-02 20:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 18:08 [dpdk-dev] [PATCH] pipeline: increase immediate operand size Cristian Dumitrescu
2020-11-02 20:38 ` David Marchand
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.