/* table TABLE */
INSTR_TABLE,
+ INSTR_TABLE_AF,
INSTR_SELECTOR,
INSTR_LEARNER,
+ INSTR_LEARNER_AF,
- /* learn LEARNER ACTION_NAME */
+ /* learn LEARNER ACTION_NAME [ m.action_first_arg ] */
INSTR_LEARNER_LEARN,
/* forget */
* Return from action
*/
INSTR_RETURN,
+
+ /* Start of custom instructions. */
+ INSTR_CUSTOM_0,
};
struct instr_operand {
struct instr_learn {
uint8_t action_id;
+ uint8_t mf_offset;
};
struct instr_extern_obj {
int invalid;
};
+typedef void (*instr_exec_t)(struct rte_swx_pipeline *);
+
/*
* Action.
*/
+typedef void
+(*action_func_t)(struct rte_swx_pipeline *p);
+
struct action {
TAILQ_ENTRY(action) node;
char name[RTE_SWX_NAME_SIZE];
uint32_t n_actions;
int default_action_is_const;
uint32_t action_data_size_max;
+ int *action_is_for_table_entries;
+ int *action_is_for_default_entry;
uint32_t size;
uint32_t id;
/* Action. */
struct action **actions;
- struct field **action_arg;
struct action *default_action;
uint8_t *default_action_data;
uint32_t n_actions;
int default_action_is_const;
uint32_t action_data_size_max;
+ int *action_is_for_table_entries;
+ int *action_is_for_default_entry;
uint32_t size;
uint32_t timeout;
struct learner_runtime {
void *mailbox;
uint8_t **key;
- uint8_t **action_data;
};
struct learner_statistics {
#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 port_in_runtime *in;
struct port_out_runtime *out;
struct instruction **action_instructions;
+ action_func_t *action_funcs;
struct rte_swx_table_state *table_state;
struct table_statistics *table_stats;
struct selector_statistics *selector_stats;
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];
+ void *lib;
uint32_t n_structs;
uint32_t n_ports_in;
const struct instruction *ip)
{
uint64_t action_id = ip->learn.action_id;
+ uint32_t mf_offset = ip->learn.mf_offset;
uint32_t learner_id = t->learner_id;
struct rte_swx_table_state *ts = &t->table_state[p->n_tables +
p->n_selectors + learner_id];
l->mailbox,
t->time,
action_id,
- l->action_data[action_id]);
+ &t->metadata[mf_offset]);
TRACE("[Thread %2u] learner %u learn %s\n",
p->thread_id,