thread_ip_inc(p);
}
+/*
+ * recirculate.
+ */
+static int
+instr_recirculate_translate(struct rte_swx_pipeline *p __rte_unused,
+ struct action *action __rte_unused,
+ char **tokens __rte_unused,
+ int n_tokens,
+ struct instruction *instr,
+ struct instruction_data *data __rte_unused)
+{
+ CHECK(n_tokens == 1, EINVAL);
+
+ instr->type = INSTR_RECIRCULATE;
+ return 0;
+}
+
+static int
+instr_recircid_translate(struct rte_swx_pipeline *p,
+ struct action *action __rte_unused,
+ char **tokens,
+ int n_tokens,
+ struct instruction *instr,
+ struct instruction_data *data __rte_unused)
+{
+ struct field *f;
+
+ CHECK(n_tokens == 2, EINVAL);
+
+ f = metadata_field_parse(p, tokens[1]);
+ CHECK(f, EINVAL);
+
+ instr->type = INSTR_RECIRCID;
+ instr->io.io.offset = f->offset / 8;
+ instr->io.io.n_bits = f->n_bits;
+ return 0;
+}
+
+static inline void
+instr_recirculate_exec(struct rte_swx_pipeline *p)
+{
+ struct thread *t = &p->threads[p->thread_id];
+ struct instruction *ip = t->ip;
+
+ __instr_recirculate_exec(p, t, ip);
+
+ /* Thread. */
+ thread_ip_inc(p);
+}
+
+static inline void
+instr_recircid_exec(struct rte_swx_pipeline *p)
+{
+ struct thread *t = &p->threads[p->thread_id];
+ struct instruction *ip = t->ip;
+
+ __instr_recircid_exec(p, t, ip);
+
+ /* Thread. */
+ thread_ip_inc(p);
+}
+
/*
* extract.
*/
instr,
data);
+ if (!strcmp(tokens[tpos], "recirculate"))
+ return instr_recirculate_translate(p,
+ action,
+ &tokens[tpos],
+ n_tokens - tpos,
+ instr,
+ data);
+
+ if (!strcmp(tokens[tpos], "recircid"))
+ return instr_recircid_translate(p,
+ action,
+ &tokens[tpos],
+ n_tokens - tpos,
+ instr,
+ data);
+
if (!strcmp(tokens[tpos], "extract"))
return instr_hdr_extract_translate(p,
action,
[INSTR_TX_I] = instr_tx_i_exec,
[INSTR_DROP] = instr_drop_exec,
[INSTR_MIRROR] = instr_mirror_exec,
+ [INSTR_RECIRCULATE] = instr_recirculate_exec,
+ [INSTR_RECIRCID] = instr_recircid_exec,
[INSTR_HDR_EXTRACT] = instr_hdr_extract_exec,
[INSTR_HDR_EXTRACT2] = instr_hdr_extract2_exec,
case INSTR_TX_I: return "INSTR_TX_I";
case INSTR_DROP: return "INSTR_DROP";
case INSTR_MIRROR: return "INSTR_MIRROR";
+ case INSTR_RECIRCULATE: return "INSTR_RECIRCULATE";
+ case INSTR_RECIRCID: return "INSTR_RECIRCID";
case INSTR_HDR_EXTRACT: return "INSTR_HDR_EXTRACT";
case INSTR_HDR_EXTRACT2: return "INSTR_HDR_EXTRACT2";
instr->mirror.src.offset);
}
+static void
+instr_recirculate_export(struct instruction *instr, FILE *f)
+{
+ fprintf(f,
+ "\t{\n"
+ "\t\t.type = %s,\n"
+ "\t},\n",
+ instr_type_to_name(instr));
+}
+
+static void
+instr_recircid_export(struct instruction *instr, FILE *f)
+{
+ fprintf(f,
+ "\t{\n"
+ "\t\t.type = %s,\n"
+ "\t\t.io = {\n"
+ "\t\t\t.offset = %u,\n"
+ "\t\t\t.n_bits = %u,\n"
+ "\t\t},\n"
+ "\t},\n",
+ instr_type_to_name(instr),
+ instr->io.io.offset,
+ instr->io.io.n_bits);
+}
+
static void
instr_hdr_validate_export(struct instruction *instr, FILE *f)
{
[INSTR_TX_I] = instr_io_export,
[INSTR_DROP] = instr_io_export,
[INSTR_MIRROR] = instr_mirror_export,
+ [INSTR_RECIRCULATE] = instr_recirculate_export,
+ [INSTR_RECIRCID] = instr_recircid_export,
[INSTR_HDR_EXTRACT] = instr_io_export,
[INSTR_HDR_EXTRACT2] = instr_io_export,
case INSTR_TX_I: return "__instr_tx_i_exec";
case INSTR_DROP: return "__instr_drop_exec";
case INSTR_MIRROR: return "__instr_mirror_exec";
+ case INSTR_RECIRCULATE: return "__instr_recirculate_exec";
+ case INSTR_RECIRCID: return "__instr_recircid_exec";
case INSTR_HDR_EXTRACT: return "__instr_hdr_extract_exec";
case INSTR_HDR_EXTRACT2: return "__instr_hdr_extract2_exec";
*/
INSTR_MIRROR,
+ /* recirculate
+ */
+ INSTR_RECIRCULATE,
+
+ /* recircid m.recirc_pass_id
+ * Read the internal recirculation pass ID into the specified meta-data field.
+ */
+ INSTR_RECIRCID,
+
/* extract h.header */
INSTR_HDR_EXTRACT,
INSTR_HDR_EXTRACT2,
uint8_t *ptr;
uint32_t *mirroring_slots;
uint64_t mirroring_slots_mask;
+ int recirculate;
+ uint32_t recirc_pass_id;
/* Structures. */
uint8_t **structs;
struct rte_swx_pkt *pkt = &t->pkt;
int pkt_received;
+ /* Recirculation: keep the current packet. */
+ if (t->recirculate) {
+ TRACE("[Thread %2u] rx - recirculate (pass %u)\n",
+ p->thread_id,
+ t->recirc_pass_id + 1);
+
+ /* Packet. */
+ t->ptr = &pkt->pkt[pkt->offset];
+ t->mirroring_slots_mask = 0;
+ t->recirculate = 0;
+ t->recirc_pass_id++;
+
+ /* Headers. */
+ t->valid_headers = 0;
+ t->n_headers_out = 0;
+
+ /* Tables. */
+ t->table_state = p->table_state;
+
+ return 1;
+ }
+
/* Packet. */
pkt_received = port->pkt_rx(port->obj, pkt);
t->ptr = &pkt->pkt[pkt->offset];
p->port_id);
t->mirroring_slots_mask = 0;
+ t->recirc_pass_id = 0;
/* Headers. */
t->valid_headers = 0;
struct port_out_runtime *port = &p->out[port_id];
struct rte_swx_pkt *pkt = &t->pkt;
+ /* Recirculation: keep the current packet. */
+ if (t->recirculate) {
+ TRACE("[Thread %2u]: tx 1 pkt - recirculate\n",
+ p->thread_id);
+
+ /* Headers. */
+ emit_handler(t);
+
+ /* Packet. */
+ mirroring_handler(p, t, pkt);
+
+ return;
+ }
+
TRACE("[Thread %2u]: tx 1 pkt to port %u\n",
p->thread_id,
(uint32_t)port_id);
struct port_out_runtime *port = &p->out[port_id];
struct rte_swx_pkt *pkt = &t->pkt;
+ /* Recirculation: keep the current packet. */
+ if (t->recirculate) {
+ TRACE("[Thread %2u]: tx (i) 1 pkt - recirculate\n",
+ p->thread_id);
+
+ /* Headers. */
+ emit_handler(t);
+
+ /* Packet. */
+ mirroring_handler(p, t, pkt);
+
+ return;
+ }
+
TRACE("[Thread %2u]: tx (i) 1 pkt to port %u\n",
p->thread_id,
(uint32_t)port_id);
t->mirroring_slots_mask |= 1LLU << slot_id;
}
+static inline void
+__instr_recirculate_exec(struct rte_swx_pipeline *p __rte_unused,
+ struct thread *t,
+ const struct instruction *ip __rte_unused)
+{
+ TRACE("[Thread %2u]: recirculate\n",
+ p->thread_id);
+
+ t->recirculate = 1;
+}
+
+static inline void
+__instr_recircid_exec(struct rte_swx_pipeline *p __rte_unused,
+ struct thread *t,
+ const struct instruction *ip)
+{
+ TRACE("[Thread %2u]: recircid (pass %u)\n",
+ p->thread_id,
+ t->recirc_pass_id);
+
+ /* Meta-data. */
+ METADATA_WRITE(t, ip->io.io.offset, ip->io.io.n_bits, t->recirc_pass_id);
+}
+
/*
* extract.
*/