/* extract h.header m.last_field_size */
INSTR_HDR_EXTRACT_M,
+ /* lookahead h.header */
+ INSTR_HDR_LOOKAHEAD,
+
/* emit h.header */
INSTR_HDR_EMIT,
INSTR_HDR_EMIT_TX,
return 0;
}
+static int
+instr_hdr_lookahead_translate(struct rte_swx_pipeline *p,
+ struct action *action,
+ char **tokens,
+ int n_tokens,
+ struct instruction *instr,
+ struct instruction_data *data __rte_unused)
+{
+ struct header *h;
+
+ CHECK(!action, EINVAL);
+ CHECK(n_tokens == 2, EINVAL);
+
+ h = header_parse(p, tokens[1]);
+ CHECK(h, EINVAL);
+ CHECK(!h->st->var_size, EINVAL);
+
+ instr->type = INSTR_HDR_LOOKAHEAD;
+ instr->io.hdr.header_id[0] = h->id;
+ instr->io.hdr.struct_id[0] = h->struct_id;
+ instr->io.hdr.n_bytes[0] = 0; /* Unused. */
+
+ return 0;
+}
+
static inline void
__instr_hdr_extract_exec(struct rte_swx_pipeline *p, uint32_t n_extract);
thread_ip_inc(p);
}
+static inline void
+instr_hdr_lookahead_exec(struct rte_swx_pipeline *p)
+{
+ struct thread *t = &p->threads[p->thread_id];
+ struct instruction *ip = t->ip;
+
+ uint64_t valid_headers = t->valid_headers;
+ uint8_t *ptr = t->ptr;
+
+ uint32_t header_id = ip->io.hdr.header_id[0];
+ uint32_t struct_id = ip->io.hdr.struct_id[0];
+
+ TRACE("[Thread %2u]: lookahead header %u\n",
+ p->thread_id,
+ header_id);
+
+ /* Headers. */
+ t->structs[struct_id] = ptr;
+ t->valid_headers = MASK64_BIT_SET(valid_headers, header_id);
+
+ /* Thread. */
+ thread_ip_inc(p);
+}
+
/*
* emit.
*/
instr,
data);
+ if (!strcmp(tokens[tpos], "lookahead"))
+ return instr_hdr_lookahead_translate(p,
+ action,
+ &tokens[tpos],
+ n_tokens - tpos,
+ instr,
+ data);
+
if (!strcmp(tokens[tpos], "emit"))
return instr_hdr_emit_translate(p,
action,
[INSTR_HDR_EXTRACT7] = instr_hdr_extract7_exec,
[INSTR_HDR_EXTRACT8] = instr_hdr_extract8_exec,
[INSTR_HDR_EXTRACT_M] = instr_hdr_extract_m_exec,
+ [INSTR_HDR_LOOKAHEAD] = instr_hdr_lookahead_exec,
[INSTR_HDR_EMIT] = instr_hdr_emit_exec,
[INSTR_HDR_EMIT_TX] = instr_hdr_emit_tx_exec,