return err;
}
-typedef void (*instr_exec_t)(struct rte_swx_pipeline *);
-
static instr_exec_t instruction_table[] = {
[INSTR_RX] = instr_rx_exec,
[INSTR_TX] = instr_tx_exec,
[INSTR_RETURN] = instr_return_exec,
};
+static int
+instruction_table_build(struct rte_swx_pipeline *p)
+{
+ p->instruction_table = calloc(RTE_SWX_PIPELINE_INSTRUCTION_TABLE_SIZE_MAX,
+ sizeof(struct instr_exec_t *));
+ if (!p->instruction_table)
+ return -EINVAL;
+
+ memcpy(p->instruction_table, instruction_table, sizeof(instruction_table));
+
+ return 0;
+}
+
+static void
+instruction_table_build_free(struct rte_swx_pipeline *p)
+{
+ if (!p->instruction_table)
+ return;
+
+ free(p->instruction_table);
+ p->instruction_table = NULL;
+}
+
+static void
+instruction_table_free(struct rte_swx_pipeline *p)
+{
+ instruction_table_build_free(p);
+}
+
static inline void
instr_exec(struct rte_swx_pipeline *p)
{
struct thread *t = &p->threads[p->thread_id];
struct instruction *ip = t->ip;
- instr_exec_t instr = instruction_table[ip->type];
+ instr_exec_t instr = p->instruction_table[ip->type];
instr(p);
}
selector_free(p);
table_free(p);
action_free(p);
+ instruction_table_free(p);
metadata_free(p);
header_free(p);
extern_func_free(p);
if (status)
goto error;
+ status = instruction_table_build(p);
+ if (status)
+ goto error;
+
status = action_build(p);
if (status)
goto error;
selector_build_free(p);
table_build_free(p);
action_build_free(p);
+ instruction_table_build_free(p);
metadata_build_free(p);
header_build_free(p);
extern_func_build_free(p);
* Return from action
*/
INSTR_RETURN,
+
+ /* Start of custom instructions. */
+ INSTR_CUSTOM_0,
};
struct instr_operand {
int invalid;
};
+typedef void (*instr_exec_t)(struct rte_swx_pipeline *);
+
/*
* Action.
*/
#define RTE_SWX_PIPELINE_THREADS_MAX 16
#endif
+#ifndef RTE_SWX_PIPELINE_INSTRUCTION_TABLE_SIZE_MAX
+#define RTE_SWX_PIPELINE_INSTRUCTION_TABLE_SIZE_MAX 256
+#endif
+
struct rte_swx_pipeline {
struct struct_type_tailq struct_types;
struct port_in_type_tailq port_in_types;
struct metarray_runtime *metarray_runtime;
struct instruction *instructions;
struct instruction_data *instruction_data;
+ instr_exec_t *instruction_table;
struct thread threads[RTE_SWX_PIPELINE_THREADS_MAX];
uint32_t n_structs;