X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Fpipeline%2Frte_swx_pipeline.c;h=8c4670e11172283fdc76b50dbcebf652e7510646;hb=1e1bfd078e581c155cd5a2b5c9191d87714dfc93;hp=dd914fd935f5064be7737414777a9ba14233982a;hpb=f23feb063ddd03490dd993469eb17fd5609889d4;p=dpdk.git diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c index dd914fd935..8c4670e111 100644 --- a/lib/pipeline/rte_swx_pipeline.c +++ b/lib/pipeline/rte_swx_pipeline.c @@ -4,7 +4,6 @@ #include #include #include -#include #include #include @@ -2887,8 +2886,8 @@ instr_alu_ckadd_translate(struct rte_swx_pipeline *p, CHECK(n_tokens == 3, EINVAL); fdst = header_field_parse(p, dst, &hdst); - CHECK(fdst && (fdst->n_bits == 16), EINVAL); - CHECK(!fdst->var_size, EINVAL); + CHECK(fdst, EINVAL); + CHECK(!fdst->var_size && (fdst->n_bits == 16), EINVAL); /* CKADD_FIELD. */ fsrc = header_field_parse(p, src, &hsrc); @@ -2908,17 +2907,16 @@ instr_alu_ckadd_translate(struct rte_swx_pipeline *p, /* CKADD_STRUCT, CKADD_STRUCT20. */ hsrc = header_parse(p, src); CHECK(hsrc, EINVAL); - CHECK(!hsrc->st->var_size, EINVAL); instr->type = INSTR_ALU_CKADD_STRUCT; - if ((hsrc->st->n_bits / 8) == 20) + if (!hsrc->st->var_size && ((hsrc->st->n_bits / 8) == 20)) instr->type = INSTR_ALU_CKADD_STRUCT20; instr->alu.dst.struct_id = (uint8_t)hdst->struct_id; instr->alu.dst.n_bits = fdst->n_bits; instr->alu.dst.offset = fdst->offset / 8; instr->alu.src.struct_id = (uint8_t)hsrc->struct_id; - instr->alu.src.n_bits = hsrc->st->n_bits; + instr->alu.src.n_bits = (uint8_t)hsrc->id; /* The src header ID is stored here. */ instr->alu.src.offset = 0; /* Unused. */ return 0; } @@ -2938,8 +2936,8 @@ instr_alu_cksub_translate(struct rte_swx_pipeline *p, CHECK(n_tokens == 3, EINVAL); fdst = header_field_parse(p, dst, &hdst); - CHECK(fdst && (fdst->n_bits == 16), EINVAL); - CHECK(!fdst->var_size, EINVAL); + CHECK(fdst, EINVAL); + CHECK(!fdst->var_size && (fdst->n_bits == 16), EINVAL); fsrc = header_field_parse(p, src, &hsrc); CHECK(fsrc, EINVAL); @@ -6000,6 +5998,19 @@ instr_label_check(struct instruction_data *instruction_data, CHECK(strcmp(label, instruction_data[j].label), EINVAL); } + /* Check that no jump instruction (either conditional or not) can jump to itself (loop). */ + for (i = 0; i < n_instructions; i++) { + struct instruction_data *data = &instruction_data[i]; + char *label = data->label; + char *jmp_label = data->jmp_label; + + /* Continue if this instruction does not have a label or it is not a jump. */ + if (!label[0] || !jmp_label[0]) + continue; + + CHECK(strcmp(label, jmp_label), EINVAL); + } + /* Get users for each instruction label. */ for (i = 0; i < n_instructions; i++) { struct instruction_data *data = &instruction_data[i]; @@ -8554,7 +8565,7 @@ table_state_build(struct rte_swx_pipeline *p) struct selector *s; struct learner *l; - p->table_state = calloc(p->n_tables + p->n_selectors, + p->table_state = calloc(p->n_tables + p->n_selectors + p->n_learners, sizeof(struct rte_swx_table_state)); CHECK(p->table_state, ENOMEM); @@ -9199,6 +9210,9 @@ pipeline_compile(struct rte_swx_pipeline *p); int rte_swx_pipeline_build(struct rte_swx_pipeline *p) { + struct rte_swx_port_sink_params drop_port_params = { + .file_name = NULL, + }; int status; CHECK(p, EINVAL); @@ -9208,6 +9222,14 @@ rte_swx_pipeline_build(struct rte_swx_pipeline *p) if (status) goto error; + /* Drop port. */ + status = rte_swx_pipeline_port_out_config(p, + p->n_ports_out, + "sink", + &drop_port_params); + if (status) + goto error; + status = port_out_build(p); if (status) goto error;