Skip to content

Commit

Permalink
pipeline: fix instruction translation
Browse files Browse the repository at this point in the history
[ upstream commit d366a48 ]

The SWX pipeline instructions work with operands of different types:
header fields (h.header.field), packet meta-data (m.field), extern
object mailbox field (e.obj.field), extern function (f.field), action
data read from table entries (t.field), or immediate values; hence the
HMEFTI acronym.

For some pipeline instructions (add/sub, srl/shr, jmplt/jmpgt), only
the H, M and I cases were handled, while the E, F and T cases were
disregarded. This is what we fix here.

Fixes: baf7999 ("pipeline: introduce SWX add instruction")
Fixes: c88c629 ("pipeline: introduce SWX subtract instruction")
Fixes: b09ba6d ("pipeline: introduce SWX SHL instruction")
Fixes: e0f5163 ("pipeline: introduce SWX SHR instruction")
Fixes: b3947e2 ("pipeline: introduce SWX jump and return instructions")

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
  • Loading branch information
cristian-dumitrescu authored and steevenlee committed May 8, 2021
1 parent a8c9a82 commit 7c0c441
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/librte_pipeline/rte_swx_pipeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -3475,9 +3475,9 @@ instr_alu_add_translate(struct rte_swx_pipeline *p,
fsrc = struct_field_parse(p, action, src, &src_struct_id);
if (fsrc) {
instr->type = INSTR_ALU_ADD;
if (dst[0] == 'h' && src[0] == 'm')
if (dst[0] == 'h' && src[0] != 'h')
instr->type = INSTR_ALU_ADD_HM;
if (dst[0] == 'm' && src[0] == 'h')
if (dst[0] != 'h' && src[0] == 'h')
instr->type = INSTR_ALU_ADD_MH;
if (dst[0] == 'h' && src[0] == 'h')
instr->type = INSTR_ALU_ADD_HH;
Expand Down Expand Up @@ -3528,9 +3528,9 @@ instr_alu_sub_translate(struct rte_swx_pipeline *p,
fsrc = struct_field_parse(p, action, src, &src_struct_id);
if (fsrc) {
instr->type = INSTR_ALU_SUB;
if (dst[0] == 'h' && src[0] == 'm')
if (dst[0] == 'h' && src[0] != 'h')
instr->type = INSTR_ALU_SUB_HM;
if (dst[0] == 'm' && src[0] == 'h')
if (dst[0] != 'h' && src[0] == 'h')
instr->type = INSTR_ALU_SUB_MH;
if (dst[0] == 'h' && src[0] == 'h')
instr->type = INSTR_ALU_SUB_HH;
Expand Down Expand Up @@ -3658,9 +3658,9 @@ instr_alu_shl_translate(struct rte_swx_pipeline *p,
fsrc = struct_field_parse(p, action, src, &src_struct_id);
if (fsrc) {
instr->type = INSTR_ALU_SHL;
if (dst[0] == 'h' && src[0] == 'm')
if (dst[0] == 'h' && src[0] != 'h')
instr->type = INSTR_ALU_SHL_HM;
if (dst[0] == 'm' && src[0] == 'h')
if (dst[0] != 'h' && src[0] == 'h')
instr->type = INSTR_ALU_SHL_MH;
if (dst[0] == 'h' && src[0] == 'h')
instr->type = INSTR_ALU_SHL_HH;
Expand Down Expand Up @@ -3711,9 +3711,9 @@ instr_alu_shr_translate(struct rte_swx_pipeline *p,
fsrc = struct_field_parse(p, action, src, &src_struct_id);
if (fsrc) {
instr->type = INSTR_ALU_SHR;
if (dst[0] == 'h' && src[0] == 'm')
if (dst[0] == 'h' && src[0] != 'h')
instr->type = INSTR_ALU_SHR_HM;
if (dst[0] == 'm' && src[0] == 'h')
if (dst[0] != 'h' && src[0] == 'h')
instr->type = INSTR_ALU_SHR_MH;
if (dst[0] == 'h' && src[0] == 'h')
instr->type = INSTR_ALU_SHR_HH;
Expand Down Expand Up @@ -4906,9 +4906,9 @@ instr_jmp_lt_translate(struct rte_swx_pipeline *p,
fb = struct_field_parse(p, action, b, &b_struct_id);
if (fb) {
instr->type = INSTR_JMP_LT;
if (a[0] == 'h' && b[0] == 'm')
if (a[0] == 'h' && b[0] != 'h')
instr->type = INSTR_JMP_LT_HM;
if (a[0] == 'm' && b[0] == 'h')
if (a[0] != 'h' && b[0] == 'h')
instr->type = INSTR_JMP_LT_MH;
if (a[0] == 'h' && b[0] == 'h')
instr->type = INSTR_JMP_LT_HH;
Expand Down Expand Up @@ -4963,9 +4963,9 @@ instr_jmp_gt_translate(struct rte_swx_pipeline *p,
fb = struct_field_parse(p, action, b, &b_struct_id);
if (fb) {
instr->type = INSTR_JMP_GT;
if (a[0] == 'h' && b[0] == 'm')
if (a[0] == 'h' && b[0] != 'h')
instr->type = INSTR_JMP_GT_HM;
if (a[0] == 'm' && b[0] == 'h')
if (a[0] != 'h' && b[0] == 'h')
instr->type = INSTR_JMP_GT_MH;
if (a[0] == 'h' && b[0] == 'h')
instr->type = INSTR_JMP_GT_HH;
Expand Down

0 comments on commit 7c0c441

Please sign in to comment.