197b8278aSCristian Dumitrescu /* SPDX-License-Identifier: BSD-3-Clause
297b8278aSCristian Dumitrescu * Copyright(c) 2021 Intel Corporation
397b8278aSCristian Dumitrescu */
497b8278aSCristian Dumitrescu #ifndef __INCLUDE_RTE_SWX_PIPELINE_INTERNAL_H__
597b8278aSCristian Dumitrescu #define __INCLUDE_RTE_SWX_PIPELINE_INTERNAL_H__
697b8278aSCristian Dumitrescu
797b8278aSCristian Dumitrescu #include <inttypes.h>
897b8278aSCristian Dumitrescu #include <string.h>
997b8278aSCristian Dumitrescu #include <sys/queue.h>
1097b8278aSCristian Dumitrescu
117253e3d2STyler Retzlaff #include <rte_bitops.h>
1297b8278aSCristian Dumitrescu #include <rte_byteorder.h>
1397b8278aSCristian Dumitrescu #include <rte_common.h>
1497b8278aSCristian Dumitrescu #include <rte_cycles.h>
1597b8278aSCristian Dumitrescu #include <rte_prefetch.h>
1697b8278aSCristian Dumitrescu #include <rte_meter.h>
1797b8278aSCristian Dumitrescu
1897b8278aSCristian Dumitrescu #include <rte_swx_table_selector.h>
1997b8278aSCristian Dumitrescu #include <rte_swx_table_learner.h>
2097b8278aSCristian Dumitrescu #include <rte_swx_pipeline.h>
2197b8278aSCristian Dumitrescu #include <rte_swx_ctl.h>
2297b8278aSCristian Dumitrescu
2397b8278aSCristian Dumitrescu #ifndef TRACE_LEVEL
2497b8278aSCristian Dumitrescu #define TRACE_LEVEL 0
2597b8278aSCristian Dumitrescu #endif
2697b8278aSCristian Dumitrescu
2797b8278aSCristian Dumitrescu #if TRACE_LEVEL
2897b8278aSCristian Dumitrescu #define TRACE(...) printf(__VA_ARGS__)
2997b8278aSCristian Dumitrescu #else
3097b8278aSCristian Dumitrescu #define TRACE(...)
3197b8278aSCristian Dumitrescu #endif
3297b8278aSCristian Dumitrescu
3397b8278aSCristian Dumitrescu /*
3497b8278aSCristian Dumitrescu * Environment.
3597b8278aSCristian Dumitrescu */
3697b8278aSCristian Dumitrescu #define ntoh64(x) rte_be_to_cpu_64(x)
3797b8278aSCristian Dumitrescu #define hton64(x) rte_cpu_to_be_64(x)
3897b8278aSCristian Dumitrescu
3997b8278aSCristian Dumitrescu /*
4097b8278aSCristian Dumitrescu * Struct.
4197b8278aSCristian Dumitrescu */
4297b8278aSCristian Dumitrescu struct field {
4397b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
4497b8278aSCristian Dumitrescu uint32_t n_bits;
4597b8278aSCristian Dumitrescu uint32_t offset;
4697b8278aSCristian Dumitrescu int var_size;
4797b8278aSCristian Dumitrescu };
4897b8278aSCristian Dumitrescu
4997b8278aSCristian Dumitrescu struct struct_type {
5097b8278aSCristian Dumitrescu TAILQ_ENTRY(struct_type) node;
5197b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
5297b8278aSCristian Dumitrescu struct field *fields;
5397b8278aSCristian Dumitrescu uint32_t n_fields;
5497b8278aSCristian Dumitrescu uint32_t n_bits;
5597b8278aSCristian Dumitrescu uint32_t n_bits_min;
5697b8278aSCristian Dumitrescu int var_size;
5797b8278aSCristian Dumitrescu };
5897b8278aSCristian Dumitrescu
5997b8278aSCristian Dumitrescu TAILQ_HEAD(struct_type_tailq, struct_type);
6097b8278aSCristian Dumitrescu
6197b8278aSCristian Dumitrescu /*
6297b8278aSCristian Dumitrescu * Input port.
6397b8278aSCristian Dumitrescu */
6497b8278aSCristian Dumitrescu struct port_in_type {
6597b8278aSCristian Dumitrescu TAILQ_ENTRY(port_in_type) node;
6697b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
6797b8278aSCristian Dumitrescu struct rte_swx_port_in_ops ops;
6897b8278aSCristian Dumitrescu };
6997b8278aSCristian Dumitrescu
7097b8278aSCristian Dumitrescu TAILQ_HEAD(port_in_type_tailq, port_in_type);
7197b8278aSCristian Dumitrescu
7297b8278aSCristian Dumitrescu struct port_in {
7397b8278aSCristian Dumitrescu TAILQ_ENTRY(port_in) node;
7497b8278aSCristian Dumitrescu struct port_in_type *type;
7597b8278aSCristian Dumitrescu void *obj;
7697b8278aSCristian Dumitrescu uint32_t id;
7797b8278aSCristian Dumitrescu };
7897b8278aSCristian Dumitrescu
7997b8278aSCristian Dumitrescu TAILQ_HEAD(port_in_tailq, port_in);
8097b8278aSCristian Dumitrescu
8197b8278aSCristian Dumitrescu struct port_in_runtime {
8297b8278aSCristian Dumitrescu rte_swx_port_in_pkt_rx_t pkt_rx;
8397b8278aSCristian Dumitrescu void *obj;
8497b8278aSCristian Dumitrescu };
8597b8278aSCristian Dumitrescu
8697b8278aSCristian Dumitrescu /*
8797b8278aSCristian Dumitrescu * Output port.
8897b8278aSCristian Dumitrescu */
8997b8278aSCristian Dumitrescu struct port_out_type {
9097b8278aSCristian Dumitrescu TAILQ_ENTRY(port_out_type) node;
9197b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
9297b8278aSCristian Dumitrescu struct rte_swx_port_out_ops ops;
9397b8278aSCristian Dumitrescu };
9497b8278aSCristian Dumitrescu
9597b8278aSCristian Dumitrescu TAILQ_HEAD(port_out_type_tailq, port_out_type);
9697b8278aSCristian Dumitrescu
9797b8278aSCristian Dumitrescu struct port_out {
9897b8278aSCristian Dumitrescu TAILQ_ENTRY(port_out) node;
9997b8278aSCristian Dumitrescu struct port_out_type *type;
10097b8278aSCristian Dumitrescu void *obj;
10197b8278aSCristian Dumitrescu uint32_t id;
10297b8278aSCristian Dumitrescu };
10397b8278aSCristian Dumitrescu
10497b8278aSCristian Dumitrescu TAILQ_HEAD(port_out_tailq, port_out);
10597b8278aSCristian Dumitrescu
10697b8278aSCristian Dumitrescu struct port_out_runtime {
10797b8278aSCristian Dumitrescu rte_swx_port_out_pkt_tx_t pkt_tx;
108dac0ecd9SCristian Dumitrescu rte_swx_port_out_pkt_fast_clone_tx_t pkt_fast_clone_tx;
109dac0ecd9SCristian Dumitrescu rte_swx_port_out_pkt_clone_tx_t pkt_clone_tx;
11097b8278aSCristian Dumitrescu rte_swx_port_out_flush_t flush;
11197b8278aSCristian Dumitrescu void *obj;
11297b8278aSCristian Dumitrescu };
11397b8278aSCristian Dumitrescu
11497b8278aSCristian Dumitrescu /*
115dac0ecd9SCristian Dumitrescu * Packet mirroring.
116dac0ecd9SCristian Dumitrescu */
117dac0ecd9SCristian Dumitrescu struct mirroring_session {
118dac0ecd9SCristian Dumitrescu uint32_t port_id;
119dac0ecd9SCristian Dumitrescu int fast_clone;
120dac0ecd9SCristian Dumitrescu uint32_t truncation_length;
121dac0ecd9SCristian Dumitrescu };
122dac0ecd9SCristian Dumitrescu
123dac0ecd9SCristian Dumitrescu /*
12497b8278aSCristian Dumitrescu * Extern object.
12597b8278aSCristian Dumitrescu */
12697b8278aSCristian Dumitrescu struct extern_type_member_func {
12797b8278aSCristian Dumitrescu TAILQ_ENTRY(extern_type_member_func) node;
12897b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
12997b8278aSCristian Dumitrescu rte_swx_extern_type_member_func_t func;
13097b8278aSCristian Dumitrescu uint32_t id;
13197b8278aSCristian Dumitrescu };
13297b8278aSCristian Dumitrescu
13397b8278aSCristian Dumitrescu TAILQ_HEAD(extern_type_member_func_tailq, extern_type_member_func);
13497b8278aSCristian Dumitrescu
13597b8278aSCristian Dumitrescu struct extern_type {
13697b8278aSCristian Dumitrescu TAILQ_ENTRY(extern_type) node;
13797b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
13897b8278aSCristian Dumitrescu struct struct_type *mailbox_struct_type;
13997b8278aSCristian Dumitrescu rte_swx_extern_type_constructor_t constructor;
14097b8278aSCristian Dumitrescu rte_swx_extern_type_destructor_t destructor;
14197b8278aSCristian Dumitrescu struct extern_type_member_func_tailq funcs;
14297b8278aSCristian Dumitrescu uint32_t n_funcs;
14397b8278aSCristian Dumitrescu };
14497b8278aSCristian Dumitrescu
14597b8278aSCristian Dumitrescu TAILQ_HEAD(extern_type_tailq, extern_type);
14697b8278aSCristian Dumitrescu
14797b8278aSCristian Dumitrescu struct extern_obj {
14897b8278aSCristian Dumitrescu TAILQ_ENTRY(extern_obj) node;
14997b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
15097b8278aSCristian Dumitrescu struct extern_type *type;
15197b8278aSCristian Dumitrescu void *obj;
15297b8278aSCristian Dumitrescu uint32_t struct_id;
15397b8278aSCristian Dumitrescu uint32_t id;
15497b8278aSCristian Dumitrescu };
15597b8278aSCristian Dumitrescu
15697b8278aSCristian Dumitrescu TAILQ_HEAD(extern_obj_tailq, extern_obj);
15797b8278aSCristian Dumitrescu
15897b8278aSCristian Dumitrescu #ifndef RTE_SWX_EXTERN_TYPE_MEMBER_FUNCS_MAX
15997b8278aSCristian Dumitrescu #define RTE_SWX_EXTERN_TYPE_MEMBER_FUNCS_MAX 8
16097b8278aSCristian Dumitrescu #endif
16197b8278aSCristian Dumitrescu
16297b8278aSCristian Dumitrescu struct extern_obj_runtime {
16397b8278aSCristian Dumitrescu void *obj;
16497b8278aSCristian Dumitrescu uint8_t *mailbox;
16597b8278aSCristian Dumitrescu rte_swx_extern_type_member_func_t funcs[RTE_SWX_EXTERN_TYPE_MEMBER_FUNCS_MAX];
16697b8278aSCristian Dumitrescu };
16797b8278aSCristian Dumitrescu
16897b8278aSCristian Dumitrescu /*
16997b8278aSCristian Dumitrescu * Extern function.
17097b8278aSCristian Dumitrescu */
17197b8278aSCristian Dumitrescu struct extern_func {
17297b8278aSCristian Dumitrescu TAILQ_ENTRY(extern_func) node;
17397b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
17497b8278aSCristian Dumitrescu struct struct_type *mailbox_struct_type;
17597b8278aSCristian Dumitrescu rte_swx_extern_func_t func;
17697b8278aSCristian Dumitrescu uint32_t struct_id;
17797b8278aSCristian Dumitrescu uint32_t id;
17897b8278aSCristian Dumitrescu };
17997b8278aSCristian Dumitrescu
18097b8278aSCristian Dumitrescu TAILQ_HEAD(extern_func_tailq, extern_func);
18197b8278aSCristian Dumitrescu
18297b8278aSCristian Dumitrescu struct extern_func_runtime {
18397b8278aSCristian Dumitrescu uint8_t *mailbox;
18497b8278aSCristian Dumitrescu rte_swx_extern_func_t func;
18597b8278aSCristian Dumitrescu };
18697b8278aSCristian Dumitrescu
18797b8278aSCristian Dumitrescu /*
18892f2944dSCristian Dumitrescu * Hash function.
18992f2944dSCristian Dumitrescu */
19092f2944dSCristian Dumitrescu struct hash_func {
19192f2944dSCristian Dumitrescu TAILQ_ENTRY(hash_func) node;
19292f2944dSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
19392f2944dSCristian Dumitrescu rte_swx_hash_func_t func;
19492f2944dSCristian Dumitrescu uint32_t id;
19592f2944dSCristian Dumitrescu };
19692f2944dSCristian Dumitrescu
19792f2944dSCristian Dumitrescu TAILQ_HEAD(hash_func_tailq, hash_func);
19892f2944dSCristian Dumitrescu
19992f2944dSCristian Dumitrescu struct hash_func_runtime {
20092f2944dSCristian Dumitrescu rte_swx_hash_func_t func;
20192f2944dSCristian Dumitrescu };
20292f2944dSCristian Dumitrescu
20392f2944dSCristian Dumitrescu /*
2048ba342ceSCristian Dumitrescu * RSS.
2058ba342ceSCristian Dumitrescu */
2068ba342ceSCristian Dumitrescu struct rss {
2078ba342ceSCristian Dumitrescu TAILQ_ENTRY(rss) node;
2088ba342ceSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
2098ba342ceSCristian Dumitrescu uint32_t id;
2108ba342ceSCristian Dumitrescu };
2118ba342ceSCristian Dumitrescu
2128ba342ceSCristian Dumitrescu TAILQ_HEAD(rss_tailq, rss);
2138ba342ceSCristian Dumitrescu
2148ba342ceSCristian Dumitrescu struct rss_runtime {
2158ba342ceSCristian Dumitrescu uint32_t key_size; /* key size in bytes. */
2165a9a6ee8SStephen Hemminger uint8_t key[]; /* key. */
2178ba342ceSCristian Dumitrescu };
2188ba342ceSCristian Dumitrescu
2198ba342ceSCristian Dumitrescu /*
22097b8278aSCristian Dumitrescu * Header.
22197b8278aSCristian Dumitrescu */
22297b8278aSCristian Dumitrescu struct header {
22397b8278aSCristian Dumitrescu TAILQ_ENTRY(header) node;
22497b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
22597b8278aSCristian Dumitrescu struct struct_type *st;
22697b8278aSCristian Dumitrescu uint32_t struct_id;
22797b8278aSCristian Dumitrescu uint32_t id;
22897b8278aSCristian Dumitrescu };
22997b8278aSCristian Dumitrescu
23097b8278aSCristian Dumitrescu TAILQ_HEAD(header_tailq, header);
23197b8278aSCristian Dumitrescu
23297b8278aSCristian Dumitrescu struct header_runtime {
23397b8278aSCristian Dumitrescu uint8_t *ptr0;
23497b8278aSCristian Dumitrescu uint32_t n_bytes;
23597b8278aSCristian Dumitrescu };
23697b8278aSCristian Dumitrescu
23797b8278aSCristian Dumitrescu struct header_out_runtime {
23897b8278aSCristian Dumitrescu uint8_t *ptr0;
23997b8278aSCristian Dumitrescu uint8_t *ptr;
24097b8278aSCristian Dumitrescu uint32_t n_bytes;
24197b8278aSCristian Dumitrescu };
24297b8278aSCristian Dumitrescu
24397b8278aSCristian Dumitrescu /*
24497b8278aSCristian Dumitrescu * Instruction.
24597b8278aSCristian Dumitrescu */
24697b8278aSCristian Dumitrescu
2472f8168eaSCristian Dumitrescu /* Operand endianness conventions:
2482f8168eaSCristian Dumitrescu *
2492f8168eaSCristian Dumitrescu * Case 1: Small fields (i.e. fields with size <= 64 bits)
2502f8168eaSCristian Dumitrescu *
2512f8168eaSCristian Dumitrescu * Packet headers are always in Network Byte Order (NBO), i.e. big endian.
25297b8278aSCristian Dumitrescu * Packet meta-data fields are always assumed to be in Host Byte Order (HBO).
25397b8278aSCristian Dumitrescu * Table entry fields can be in either NBO or HBO; they are assumed to be in HBO
25497b8278aSCristian Dumitrescu * when transferred to packet meta-data and in NBO when transferred to packet
25597b8278aSCristian Dumitrescu * headers.
2562f8168eaSCristian Dumitrescu *
2572f8168eaSCristian Dumitrescu * Notation conventions:
25897b8278aSCristian Dumitrescu * -Header field: H = h.header.field (dst/src)
25997b8278aSCristian Dumitrescu * -Meta-data field: M = m.field (dst/src)
26097b8278aSCristian Dumitrescu * -Extern object mailbox field: E = e.field (dst/src)
26197b8278aSCristian Dumitrescu * -Extern function mailbox field: F = f.field (dst/src)
26297b8278aSCristian Dumitrescu * -Table action data field: T = t.field (src only)
26397b8278aSCristian Dumitrescu * -Immediate value: I = 32-bit unsigned value (src only)
2642f8168eaSCristian Dumitrescu *
2652f8168eaSCristian Dumitrescu * Case 2: Big fields (i.e. fields with size > 64 bits)
2662f8168eaSCristian Dumitrescu *
2672f8168eaSCristian Dumitrescu * The big fields are allowed in both headers and meta-data, but they are always
2682f8168eaSCristian Dumitrescu * stored in NBO. This is why the few instructions that accept a big field
2692f8168eaSCristian Dumitrescu * operand require that the other operand, in case it is a small operand, be
2702f8168eaSCristian Dumitrescu * stored in NBO as well, i.e. the small operand must be a header field
2712f8168eaSCristian Dumitrescu * (i.e. meta-data field not allowed in this case).
2722f8168eaSCristian Dumitrescu *
2732f8168eaSCristian Dumitrescu * Notation conventions:
2742f8168eaSCristian Dumitrescu * -Header or meta-data big field: HM-NBO.
27597b8278aSCristian Dumitrescu */
27697b8278aSCristian Dumitrescu
27797b8278aSCristian Dumitrescu enum instruction_type {
27897b8278aSCristian Dumitrescu /* rx m.port_in */
27997b8278aSCristian Dumitrescu INSTR_RX,
28097b8278aSCristian Dumitrescu
28197b8278aSCristian Dumitrescu /* tx port_out
28297b8278aSCristian Dumitrescu * port_out = MI
28397b8278aSCristian Dumitrescu */
28497b8278aSCristian Dumitrescu INSTR_TX, /* port_out = M */
28597b8278aSCristian Dumitrescu INSTR_TX_I, /* port_out = I */
286c07aaa65SCristian Dumitrescu INSTR_DROP,
28797b8278aSCristian Dumitrescu
288dac0ecd9SCristian Dumitrescu /*
289dac0ecd9SCristian Dumitrescu * mirror slot_id session_id
290dac0ecd9SCristian Dumitrescu * slot_id = MEFT
291dac0ecd9SCristian Dumitrescu * session_id = MEFT
292dac0ecd9SCristian Dumitrescu */
293dac0ecd9SCristian Dumitrescu INSTR_MIRROR,
294dac0ecd9SCristian Dumitrescu
2955ec76d29SCristian Dumitrescu /* recirculate
2965ec76d29SCristian Dumitrescu */
2975ec76d29SCristian Dumitrescu INSTR_RECIRCULATE,
2985ec76d29SCristian Dumitrescu
2995ec76d29SCristian Dumitrescu /* recircid m.recirc_pass_id
3005ec76d29SCristian Dumitrescu * Read the internal recirculation pass ID into the specified meta-data field.
3015ec76d29SCristian Dumitrescu */
3025ec76d29SCristian Dumitrescu INSTR_RECIRCID,
3035ec76d29SCristian Dumitrescu
30497b8278aSCristian Dumitrescu /* extract h.header */
30597b8278aSCristian Dumitrescu INSTR_HDR_EXTRACT,
30697b8278aSCristian Dumitrescu INSTR_HDR_EXTRACT2,
30797b8278aSCristian Dumitrescu INSTR_HDR_EXTRACT3,
30897b8278aSCristian Dumitrescu INSTR_HDR_EXTRACT4,
30997b8278aSCristian Dumitrescu INSTR_HDR_EXTRACT5,
31097b8278aSCristian Dumitrescu INSTR_HDR_EXTRACT6,
31197b8278aSCristian Dumitrescu INSTR_HDR_EXTRACT7,
31297b8278aSCristian Dumitrescu INSTR_HDR_EXTRACT8,
31397b8278aSCristian Dumitrescu
31497b8278aSCristian Dumitrescu /* extract h.header m.last_field_size */
31597b8278aSCristian Dumitrescu INSTR_HDR_EXTRACT_M,
31697b8278aSCristian Dumitrescu
31797b8278aSCristian Dumitrescu /* lookahead h.header */
31897b8278aSCristian Dumitrescu INSTR_HDR_LOOKAHEAD,
31997b8278aSCristian Dumitrescu
32097b8278aSCristian Dumitrescu /* emit h.header */
32197b8278aSCristian Dumitrescu INSTR_HDR_EMIT,
32297b8278aSCristian Dumitrescu INSTR_HDR_EMIT_TX,
32397b8278aSCristian Dumitrescu INSTR_HDR_EMIT2_TX,
32497b8278aSCristian Dumitrescu INSTR_HDR_EMIT3_TX,
32597b8278aSCristian Dumitrescu INSTR_HDR_EMIT4_TX,
32697b8278aSCristian Dumitrescu INSTR_HDR_EMIT5_TX,
32797b8278aSCristian Dumitrescu INSTR_HDR_EMIT6_TX,
32897b8278aSCristian Dumitrescu INSTR_HDR_EMIT7_TX,
32997b8278aSCristian Dumitrescu INSTR_HDR_EMIT8_TX,
33097b8278aSCristian Dumitrescu
33197b8278aSCristian Dumitrescu /* validate h.header */
33297b8278aSCristian Dumitrescu INSTR_HDR_VALIDATE,
33397b8278aSCristian Dumitrescu
33497b8278aSCristian Dumitrescu /* invalidate h.header */
33597b8278aSCristian Dumitrescu INSTR_HDR_INVALIDATE,
33697b8278aSCristian Dumitrescu
33797b8278aSCristian Dumitrescu /* mov dst src
33897b8278aSCristian Dumitrescu * dst = src
33997b8278aSCristian Dumitrescu * dst = HMEF, src = HMEFTI
34097b8278aSCristian Dumitrescu */
3419ebff617SCristian Dumitrescu INSTR_MOV, /* dst = MEF, src = MEFT; size(dst) <= 64 bits, size(src) <= 64 bits. */
3429ebff617SCristian Dumitrescu INSTR_MOV_MH, /* dst = MEF, src = H; size(dst) <= 64 bits, size(src) <= 64 bits. */
3439ebff617SCristian Dumitrescu INSTR_MOV_HM, /* dst = H, src = MEFT; size(dst) <= 64 bits, size(src) <= 64 bits. */
3449ebff617SCristian Dumitrescu INSTR_MOV_HH, /* dst = H, src = H; size(dst) <= 64 bits, size(src) <= 64 bits. */
3455b65690eSCristian Dumitrescu INSTR_MOV_DMA, /* dst and src in NBO format. */
3465b65690eSCristian Dumitrescu INSTR_MOV_128, /* dst and src in NBO format, size(dst) = size(src) = 128 bits. */
347*1dd3e5e2SCristian Dumitrescu INSTR_MOV_128_64, /* dst and src in NBO format, size(dst) = 128 bits, size(src) = 64 b. */
348*1dd3e5e2SCristian Dumitrescu INSTR_MOV_64_128, /* dst and src in NBO format, size(dst) = 64 bits, size(src) = 128 b. */
3495b65690eSCristian Dumitrescu INSTR_MOV_128_32, /* dst and src in NBO format, size(dst) = 128 bits, size(src) = 32 b. */
350*1dd3e5e2SCristian Dumitrescu INSTR_MOV_32_128, /* dst and src in NBO format, size(dst) = 32 bits, size(src) = 128 b. */
3519ebff617SCristian Dumitrescu INSTR_MOV_I, /* dst = HMEF, src = I; size(dst) <= 64 bits. */
35297b8278aSCristian Dumitrescu
3532f8168eaSCristian Dumitrescu /* movh dst src
3542f8168eaSCristian Dumitrescu * Read/write the upper half (i.e. bits 127 .. 64) of a 128-bit field into/from a 64-bit
3552f8168eaSCristian Dumitrescu * header field:
3562f8168eaSCristian Dumitrescu *
3572f8168eaSCristian Dumitrescu * dst64 = src128[127:64], where: dst64 = H, src128 = HM-NBO.
3582f8168eaSCristian Dumitrescu * dst128[127:64] = src64, where: dst128 = HM-NBO, src64 = H.
3592f8168eaSCristian Dumitrescu *
3602f8168eaSCristian Dumitrescu * Typically required for operations involving IPv6 addresses.
3612f8168eaSCristian Dumitrescu */
3622f8168eaSCristian Dumitrescu INSTR_MOVH,
3632f8168eaSCristian Dumitrescu
36497b8278aSCristian Dumitrescu /* dma h.header t.field
36597b8278aSCristian Dumitrescu * memcpy(h.header, t.field, sizeof(h.header))
36697b8278aSCristian Dumitrescu */
36797b8278aSCristian Dumitrescu INSTR_DMA_HT,
36897b8278aSCristian Dumitrescu INSTR_DMA_HT2,
36997b8278aSCristian Dumitrescu INSTR_DMA_HT3,
37097b8278aSCristian Dumitrescu INSTR_DMA_HT4,
37197b8278aSCristian Dumitrescu INSTR_DMA_HT5,
37297b8278aSCristian Dumitrescu INSTR_DMA_HT6,
37397b8278aSCristian Dumitrescu INSTR_DMA_HT7,
37497b8278aSCristian Dumitrescu INSTR_DMA_HT8,
37597b8278aSCristian Dumitrescu
37697b8278aSCristian Dumitrescu /* add dst src
37797b8278aSCristian Dumitrescu * dst += src
37897b8278aSCristian Dumitrescu * dst = HMEF, src = HMEFTI
37997b8278aSCristian Dumitrescu */
38097b8278aSCristian Dumitrescu INSTR_ALU_ADD, /* dst = MEF, src = MEF */
38197b8278aSCristian Dumitrescu INSTR_ALU_ADD_MH, /* dst = MEF, src = H */
38297b8278aSCristian Dumitrescu INSTR_ALU_ADD_HM, /* dst = H, src = MEF */
38397b8278aSCristian Dumitrescu INSTR_ALU_ADD_HH, /* dst = H, src = H */
38497b8278aSCristian Dumitrescu INSTR_ALU_ADD_MI, /* dst = MEF, src = I */
38597b8278aSCristian Dumitrescu INSTR_ALU_ADD_HI, /* dst = H, src = I */
38697b8278aSCristian Dumitrescu
38797b8278aSCristian Dumitrescu /* sub dst src
38897b8278aSCristian Dumitrescu * dst -= src
38997b8278aSCristian Dumitrescu * dst = HMEF, src = HMEFTI
39097b8278aSCristian Dumitrescu */
39197b8278aSCristian Dumitrescu INSTR_ALU_SUB, /* dst = MEF, src = MEF */
39297b8278aSCristian Dumitrescu INSTR_ALU_SUB_MH, /* dst = MEF, src = H */
39397b8278aSCristian Dumitrescu INSTR_ALU_SUB_HM, /* dst = H, src = MEF */
39497b8278aSCristian Dumitrescu INSTR_ALU_SUB_HH, /* dst = H, src = H */
39597b8278aSCristian Dumitrescu INSTR_ALU_SUB_MI, /* dst = MEF, src = I */
39697b8278aSCristian Dumitrescu INSTR_ALU_SUB_HI, /* dst = H, src = I */
39797b8278aSCristian Dumitrescu
39897b8278aSCristian Dumitrescu /* ckadd dst src
3992a11b503SCristian Dumitrescu * dst = dst '+ src[0:1] '+ src[2:3] '+ ...
4002a11b503SCristian Dumitrescu * dst = H, src = {H, h.header}, '+ = 1's complement addition operator
40197b8278aSCristian Dumitrescu */
40297b8278aSCristian Dumitrescu INSTR_ALU_CKADD_FIELD, /* src = H */
4032a11b503SCristian Dumitrescu INSTR_ALU_CKADD_STRUCT20, /* src = h.header, with sizeof(header) = 20 bytes. */
4042a11b503SCristian Dumitrescu INSTR_ALU_CKADD_STRUCT, /* src = h.header, with sizeof(header) any 4-byte multiple. */
40597b8278aSCristian Dumitrescu
40697b8278aSCristian Dumitrescu /* cksub dst src
40797b8278aSCristian Dumitrescu * dst = dst '- src
4082a11b503SCristian Dumitrescu * dst = H, src = H, '- = 1's complement subtraction operator
40997b8278aSCristian Dumitrescu */
41097b8278aSCristian Dumitrescu INSTR_ALU_CKSUB_FIELD,
41197b8278aSCristian Dumitrescu
41297b8278aSCristian Dumitrescu /* and dst src
41397b8278aSCristian Dumitrescu * dst &= src
41497b8278aSCristian Dumitrescu * dst = HMEF, src = HMEFTI
41597b8278aSCristian Dumitrescu */
41697b8278aSCristian Dumitrescu INSTR_ALU_AND, /* dst = MEF, src = MEFT */
41797b8278aSCristian Dumitrescu INSTR_ALU_AND_MH, /* dst = MEF, src = H */
41897b8278aSCristian Dumitrescu INSTR_ALU_AND_HM, /* dst = H, src = MEFT */
41997b8278aSCristian Dumitrescu INSTR_ALU_AND_HH, /* dst = H, src = H */
42097b8278aSCristian Dumitrescu INSTR_ALU_AND_I, /* dst = HMEF, src = I */
42197b8278aSCristian Dumitrescu
42297b8278aSCristian Dumitrescu /* or dst src
42397b8278aSCristian Dumitrescu * dst |= src
42497b8278aSCristian Dumitrescu * dst = HMEF, src = HMEFTI
42597b8278aSCristian Dumitrescu */
42697b8278aSCristian Dumitrescu INSTR_ALU_OR, /* dst = MEF, src = MEFT */
42797b8278aSCristian Dumitrescu INSTR_ALU_OR_MH, /* dst = MEF, src = H */
42897b8278aSCristian Dumitrescu INSTR_ALU_OR_HM, /* dst = H, src = MEFT */
42997b8278aSCristian Dumitrescu INSTR_ALU_OR_HH, /* dst = H, src = H */
43097b8278aSCristian Dumitrescu INSTR_ALU_OR_I, /* dst = HMEF, src = I */
43197b8278aSCristian Dumitrescu
43297b8278aSCristian Dumitrescu /* xor dst src
43397b8278aSCristian Dumitrescu * dst ^= src
43497b8278aSCristian Dumitrescu * dst = HMEF, src = HMEFTI
43597b8278aSCristian Dumitrescu */
43697b8278aSCristian Dumitrescu INSTR_ALU_XOR, /* dst = MEF, src = MEFT */
43797b8278aSCristian Dumitrescu INSTR_ALU_XOR_MH, /* dst = MEF, src = H */
43897b8278aSCristian Dumitrescu INSTR_ALU_XOR_HM, /* dst = H, src = MEFT */
43997b8278aSCristian Dumitrescu INSTR_ALU_XOR_HH, /* dst = H, src = H */
44097b8278aSCristian Dumitrescu INSTR_ALU_XOR_I, /* dst = HMEF, src = I */
44197b8278aSCristian Dumitrescu
44297b8278aSCristian Dumitrescu /* shl dst src
44397b8278aSCristian Dumitrescu * dst <<= src
44497b8278aSCristian Dumitrescu * dst = HMEF, src = HMEFTI
44597b8278aSCristian Dumitrescu */
44697b8278aSCristian Dumitrescu INSTR_ALU_SHL, /* dst = MEF, src = MEF */
44797b8278aSCristian Dumitrescu INSTR_ALU_SHL_MH, /* dst = MEF, src = H */
44897b8278aSCristian Dumitrescu INSTR_ALU_SHL_HM, /* dst = H, src = MEF */
44997b8278aSCristian Dumitrescu INSTR_ALU_SHL_HH, /* dst = H, src = H */
45097b8278aSCristian Dumitrescu INSTR_ALU_SHL_MI, /* dst = MEF, src = I */
45197b8278aSCristian Dumitrescu INSTR_ALU_SHL_HI, /* dst = H, src = I */
45297b8278aSCristian Dumitrescu
45397b8278aSCristian Dumitrescu /* shr dst src
45497b8278aSCristian Dumitrescu * dst >>= src
45597b8278aSCristian Dumitrescu * dst = HMEF, src = HMEFTI
45697b8278aSCristian Dumitrescu */
45797b8278aSCristian Dumitrescu INSTR_ALU_SHR, /* dst = MEF, src = MEF */
45897b8278aSCristian Dumitrescu INSTR_ALU_SHR_MH, /* dst = MEF, src = H */
45997b8278aSCristian Dumitrescu INSTR_ALU_SHR_HM, /* dst = H, src = MEF */
46097b8278aSCristian Dumitrescu INSTR_ALU_SHR_HH, /* dst = H, src = H */
46197b8278aSCristian Dumitrescu INSTR_ALU_SHR_MI, /* dst = MEF, src = I */
46297b8278aSCristian Dumitrescu INSTR_ALU_SHR_HI, /* dst = H, src = I */
46397b8278aSCristian Dumitrescu
46497b8278aSCristian Dumitrescu /* regprefetch REGARRAY index
46597b8278aSCristian Dumitrescu * prefetch REGARRAY[index]
46697b8278aSCristian Dumitrescu * index = HMEFTI
46797b8278aSCristian Dumitrescu */
46897b8278aSCristian Dumitrescu INSTR_REGPREFETCH_RH, /* index = H */
46997b8278aSCristian Dumitrescu INSTR_REGPREFETCH_RM, /* index = MEFT */
47097b8278aSCristian Dumitrescu INSTR_REGPREFETCH_RI, /* index = I */
47197b8278aSCristian Dumitrescu
47297b8278aSCristian Dumitrescu /* regrd dst REGARRAY index
47397b8278aSCristian Dumitrescu * dst = REGARRAY[index]
47497b8278aSCristian Dumitrescu * dst = HMEF, index = HMEFTI
47597b8278aSCristian Dumitrescu */
47697b8278aSCristian Dumitrescu INSTR_REGRD_HRH, /* dst = H, index = H */
47797b8278aSCristian Dumitrescu INSTR_REGRD_HRM, /* dst = H, index = MEFT */
47897b8278aSCristian Dumitrescu INSTR_REGRD_HRI, /* dst = H, index = I */
47997b8278aSCristian Dumitrescu INSTR_REGRD_MRH, /* dst = MEF, index = H */
48097b8278aSCristian Dumitrescu INSTR_REGRD_MRM, /* dst = MEF, index = MEFT */
48197b8278aSCristian Dumitrescu INSTR_REGRD_MRI, /* dst = MEF, index = I */
48297b8278aSCristian Dumitrescu
48397b8278aSCristian Dumitrescu /* regwr REGARRAY index src
48497b8278aSCristian Dumitrescu * REGARRAY[index] = src
48597b8278aSCristian Dumitrescu * index = HMEFTI, src = HMEFTI
48697b8278aSCristian Dumitrescu */
48797b8278aSCristian Dumitrescu INSTR_REGWR_RHH, /* index = H, src = H */
48897b8278aSCristian Dumitrescu INSTR_REGWR_RHM, /* index = H, src = MEFT */
48997b8278aSCristian Dumitrescu INSTR_REGWR_RHI, /* index = H, src = I */
49097b8278aSCristian Dumitrescu INSTR_REGWR_RMH, /* index = MEFT, src = H */
49197b8278aSCristian Dumitrescu INSTR_REGWR_RMM, /* index = MEFT, src = MEFT */
49297b8278aSCristian Dumitrescu INSTR_REGWR_RMI, /* index = MEFT, src = I */
49397b8278aSCristian Dumitrescu INSTR_REGWR_RIH, /* index = I, src = H */
49497b8278aSCristian Dumitrescu INSTR_REGWR_RIM, /* index = I, src = MEFT */
49597b8278aSCristian Dumitrescu INSTR_REGWR_RII, /* index = I, src = I */
49697b8278aSCristian Dumitrescu
49797b8278aSCristian Dumitrescu /* regadd REGARRAY index src
49897b8278aSCristian Dumitrescu * REGARRAY[index] += src
49997b8278aSCristian Dumitrescu * index = HMEFTI, src = HMEFTI
50097b8278aSCristian Dumitrescu */
50197b8278aSCristian Dumitrescu INSTR_REGADD_RHH, /* index = H, src = H */
50297b8278aSCristian Dumitrescu INSTR_REGADD_RHM, /* index = H, src = MEFT */
50397b8278aSCristian Dumitrescu INSTR_REGADD_RHI, /* index = H, src = I */
50497b8278aSCristian Dumitrescu INSTR_REGADD_RMH, /* index = MEFT, src = H */
50597b8278aSCristian Dumitrescu INSTR_REGADD_RMM, /* index = MEFT, src = MEFT */
50697b8278aSCristian Dumitrescu INSTR_REGADD_RMI, /* index = MEFT, src = I */
50797b8278aSCristian Dumitrescu INSTR_REGADD_RIH, /* index = I, src = H */
50897b8278aSCristian Dumitrescu INSTR_REGADD_RIM, /* index = I, src = MEFT */
50997b8278aSCristian Dumitrescu INSTR_REGADD_RII, /* index = I, src = I */
51097b8278aSCristian Dumitrescu
51197b8278aSCristian Dumitrescu /* metprefetch METARRAY index
51297b8278aSCristian Dumitrescu * prefetch METARRAY[index]
51397b8278aSCristian Dumitrescu * index = HMEFTI
51497b8278aSCristian Dumitrescu */
51597b8278aSCristian Dumitrescu INSTR_METPREFETCH_H, /* index = H */
51697b8278aSCristian Dumitrescu INSTR_METPREFETCH_M, /* index = MEFT */
51797b8278aSCristian Dumitrescu INSTR_METPREFETCH_I, /* index = I */
51897b8278aSCristian Dumitrescu
51997b8278aSCristian Dumitrescu /* meter METARRAY index length color_in color_out
52097b8278aSCristian Dumitrescu * color_out = meter(METARRAY[index], length, color_in)
52197b8278aSCristian Dumitrescu * index = HMEFTI, length = HMEFT, color_in = MEFTI, color_out = MEF
52297b8278aSCristian Dumitrescu */
52397b8278aSCristian Dumitrescu INSTR_METER_HHM, /* index = H, length = H, color_in = MEFT */
52497b8278aSCristian Dumitrescu INSTR_METER_HHI, /* index = H, length = H, color_in = I */
52597b8278aSCristian Dumitrescu INSTR_METER_HMM, /* index = H, length = MEFT, color_in = MEFT */
52697b8278aSCristian Dumitrescu INSTR_METER_HMI, /* index = H, length = MEFT, color_in = I */
52797b8278aSCristian Dumitrescu INSTR_METER_MHM, /* index = MEFT, length = H, color_in = MEFT */
52897b8278aSCristian Dumitrescu INSTR_METER_MHI, /* index = MEFT, length = H, color_in = I */
52997b8278aSCristian Dumitrescu INSTR_METER_MMM, /* index = MEFT, length = MEFT, color_in = MEFT */
53097b8278aSCristian Dumitrescu INSTR_METER_MMI, /* index = MEFT, length = MEFT, color_in = I */
53197b8278aSCristian Dumitrescu INSTR_METER_IHM, /* index = I, length = H, color_in = MEFT */
53297b8278aSCristian Dumitrescu INSTR_METER_IHI, /* index = I, length = H, color_in = I */
53397b8278aSCristian Dumitrescu INSTR_METER_IMM, /* index = I, length = MEFT, color_in = MEFT */
53497b8278aSCristian Dumitrescu INSTR_METER_IMI, /* index = I, length = MEFT, color_in = I */
53597b8278aSCristian Dumitrescu
53697b8278aSCristian Dumitrescu /* table TABLE */
53797b8278aSCristian Dumitrescu INSTR_TABLE,
5385dc6a5f2SCristian Dumitrescu INSTR_TABLE_AF,
53997b8278aSCristian Dumitrescu INSTR_SELECTOR,
54097b8278aSCristian Dumitrescu INSTR_LEARNER,
5415dc6a5f2SCristian Dumitrescu INSTR_LEARNER_AF,
54297b8278aSCristian Dumitrescu
543e2ecc535SCristian Dumitrescu /* learn ACTION_NAME [ m.action_first_arg ] m.timeout_id */
54497b8278aSCristian Dumitrescu INSTR_LEARNER_LEARN,
54597b8278aSCristian Dumitrescu
546e2ecc535SCristian Dumitrescu /* rearm [ m.timeout_id ] */
547e2ecc535SCristian Dumitrescu INSTR_LEARNER_REARM,
548e2ecc535SCristian Dumitrescu INSTR_LEARNER_REARM_NEW,
549e2ecc535SCristian Dumitrescu
55097b8278aSCristian Dumitrescu /* forget */
55197b8278aSCristian Dumitrescu INSTR_LEARNER_FORGET,
55297b8278aSCristian Dumitrescu
553d4e95281SCristian Dumitrescu /* entryid m.table_entry_id
554d4e95281SCristian Dumitrescu * Read the internal table entry ID into the specified meta-data field.
555d4e95281SCristian Dumitrescu */
556d4e95281SCristian Dumitrescu INSTR_ENTRYID,
557d4e95281SCristian Dumitrescu
55897b8278aSCristian Dumitrescu /* extern e.obj.func */
55997b8278aSCristian Dumitrescu INSTR_EXTERN_OBJ,
56097b8278aSCristian Dumitrescu
56197b8278aSCristian Dumitrescu /* extern f.func */
56297b8278aSCristian Dumitrescu INSTR_EXTERN_FUNC,
56397b8278aSCristian Dumitrescu
56492f2944dSCristian Dumitrescu /* hash HASH_FUNC_NAME dst src_first src_last
56592f2944dSCristian Dumitrescu * Compute hash value over range of struct fields.
56692f2944dSCristian Dumitrescu * dst = M
56792f2944dSCristian Dumitrescu * src_first = HMEFT
56892f2944dSCristian Dumitrescu * src_last = HMEFT
56992f2944dSCristian Dumitrescu * src_first and src_last must be fields within the same struct
57092f2944dSCristian Dumitrescu */
57192f2944dSCristian Dumitrescu INSTR_HASH_FUNC,
57292f2944dSCristian Dumitrescu
5738ba342ceSCristian Dumitrescu /* rss RSS_OBJ_NAME dst src_first src_last
5748ba342ceSCristian Dumitrescu * Compute the RSS hash value over range of struct fields.
5758ba342ceSCristian Dumitrescu * dst = M
5768ba342ceSCristian Dumitrescu * src_first = HMEFT
5778ba342ceSCristian Dumitrescu * src_last = HMEFT
5788ba342ceSCristian Dumitrescu * src_first and src_last must be fields within the same struct
5798ba342ceSCristian Dumitrescu */
5808ba342ceSCristian Dumitrescu INSTR_RSS,
5818ba342ceSCristian Dumitrescu
58297b8278aSCristian Dumitrescu /* jmp LABEL
58397b8278aSCristian Dumitrescu * Unconditional jump
58497b8278aSCristian Dumitrescu */
58597b8278aSCristian Dumitrescu INSTR_JMP,
58697b8278aSCristian Dumitrescu
58797b8278aSCristian Dumitrescu /* jmpv LABEL h.header
58897b8278aSCristian Dumitrescu * Jump if header is valid
58997b8278aSCristian Dumitrescu */
59097b8278aSCristian Dumitrescu INSTR_JMP_VALID,
59197b8278aSCristian Dumitrescu
59297b8278aSCristian Dumitrescu /* jmpnv LABEL h.header
59397b8278aSCristian Dumitrescu * Jump if header is invalid
59497b8278aSCristian Dumitrescu */
59597b8278aSCristian Dumitrescu INSTR_JMP_INVALID,
59697b8278aSCristian Dumitrescu
59797b8278aSCristian Dumitrescu /* jmph LABEL
59897b8278aSCristian Dumitrescu * Jump if table lookup hit
59997b8278aSCristian Dumitrescu */
60097b8278aSCristian Dumitrescu INSTR_JMP_HIT,
60197b8278aSCristian Dumitrescu
60297b8278aSCristian Dumitrescu /* jmpnh LABEL
60397b8278aSCristian Dumitrescu * Jump if table lookup miss
60497b8278aSCristian Dumitrescu */
60597b8278aSCristian Dumitrescu INSTR_JMP_MISS,
60697b8278aSCristian Dumitrescu
60797b8278aSCristian Dumitrescu /* jmpa LABEL ACTION
60897b8278aSCristian Dumitrescu * Jump if action run
60997b8278aSCristian Dumitrescu */
61097b8278aSCristian Dumitrescu INSTR_JMP_ACTION_HIT,
61197b8278aSCristian Dumitrescu
61297b8278aSCristian Dumitrescu /* jmpna LABEL ACTION
61397b8278aSCristian Dumitrescu * Jump if action not run
61497b8278aSCristian Dumitrescu */
61597b8278aSCristian Dumitrescu INSTR_JMP_ACTION_MISS,
61697b8278aSCristian Dumitrescu
61797b8278aSCristian Dumitrescu /* jmpeq LABEL a b
61897b8278aSCristian Dumitrescu * Jump if a is equal to b
61997b8278aSCristian Dumitrescu * a = HMEFT, b = HMEFTI
62097b8278aSCristian Dumitrescu */
62197b8278aSCristian Dumitrescu INSTR_JMP_EQ, /* a = MEFT, b = MEFT */
62297b8278aSCristian Dumitrescu INSTR_JMP_EQ_MH, /* a = MEFT, b = H */
62397b8278aSCristian Dumitrescu INSTR_JMP_EQ_HM, /* a = H, b = MEFT */
62497b8278aSCristian Dumitrescu INSTR_JMP_EQ_HH, /* a = H, b = H */
62597b8278aSCristian Dumitrescu INSTR_JMP_EQ_I, /* (a, b) = (MEFT, I) or (a, b) = (H, I) */
62697b8278aSCristian Dumitrescu
62797b8278aSCristian Dumitrescu /* jmpneq LABEL a b
62897b8278aSCristian Dumitrescu * Jump if a is not equal to b
62997b8278aSCristian Dumitrescu * a = HMEFT, b = HMEFTI
63097b8278aSCristian Dumitrescu */
63197b8278aSCristian Dumitrescu INSTR_JMP_NEQ, /* a = MEFT, b = MEFT */
63297b8278aSCristian Dumitrescu INSTR_JMP_NEQ_MH, /* a = MEFT, b = H */
63397b8278aSCristian Dumitrescu INSTR_JMP_NEQ_HM, /* a = H, b = MEFT */
63497b8278aSCristian Dumitrescu INSTR_JMP_NEQ_HH, /* a = H, b = H */
63597b8278aSCristian Dumitrescu INSTR_JMP_NEQ_I, /* (a, b) = (MEFT, I) or (a, b) = (H, I) */
63697b8278aSCristian Dumitrescu
63797b8278aSCristian Dumitrescu /* jmplt LABEL a b
63897b8278aSCristian Dumitrescu * Jump if a is less than b
63997b8278aSCristian Dumitrescu * a = HMEFT, b = HMEFTI
64097b8278aSCristian Dumitrescu */
64197b8278aSCristian Dumitrescu INSTR_JMP_LT, /* a = MEFT, b = MEFT */
64297b8278aSCristian Dumitrescu INSTR_JMP_LT_MH, /* a = MEFT, b = H */
64397b8278aSCristian Dumitrescu INSTR_JMP_LT_HM, /* a = H, b = MEFT */
64497b8278aSCristian Dumitrescu INSTR_JMP_LT_HH, /* a = H, b = H */
64597b8278aSCristian Dumitrescu INSTR_JMP_LT_MI, /* a = MEFT, b = I */
64697b8278aSCristian Dumitrescu INSTR_JMP_LT_HI, /* a = H, b = I */
64797b8278aSCristian Dumitrescu
64897b8278aSCristian Dumitrescu /* jmpgt LABEL a b
64997b8278aSCristian Dumitrescu * Jump if a is greater than b
65097b8278aSCristian Dumitrescu * a = HMEFT, b = HMEFTI
65197b8278aSCristian Dumitrescu */
65297b8278aSCristian Dumitrescu INSTR_JMP_GT, /* a = MEFT, b = MEFT */
65397b8278aSCristian Dumitrescu INSTR_JMP_GT_MH, /* a = MEFT, b = H */
65497b8278aSCristian Dumitrescu INSTR_JMP_GT_HM, /* a = H, b = MEFT */
65597b8278aSCristian Dumitrescu INSTR_JMP_GT_HH, /* a = H, b = H */
65697b8278aSCristian Dumitrescu INSTR_JMP_GT_MI, /* a = MEFT, b = I */
65797b8278aSCristian Dumitrescu INSTR_JMP_GT_HI, /* a = H, b = I */
65897b8278aSCristian Dumitrescu
65997b8278aSCristian Dumitrescu /* return
66097b8278aSCristian Dumitrescu * Return from action
66197b8278aSCristian Dumitrescu */
66297b8278aSCristian Dumitrescu INSTR_RETURN,
663dfa9491aSCristian Dumitrescu
664dfa9491aSCristian Dumitrescu /* Start of custom instructions. */
665dfa9491aSCristian Dumitrescu INSTR_CUSTOM_0,
66697b8278aSCristian Dumitrescu };
66797b8278aSCristian Dumitrescu
66897b8278aSCristian Dumitrescu struct instr_operand {
66997b8278aSCristian Dumitrescu uint8_t struct_id;
67097b8278aSCristian Dumitrescu uint8_t n_bits;
67197b8278aSCristian Dumitrescu uint8_t offset;
67297b8278aSCristian Dumitrescu uint8_t pad;
67397b8278aSCristian Dumitrescu };
67497b8278aSCristian Dumitrescu
67597b8278aSCristian Dumitrescu struct instr_io {
67697b8278aSCristian Dumitrescu struct {
67797b8278aSCristian Dumitrescu union {
67897b8278aSCristian Dumitrescu struct {
67997b8278aSCristian Dumitrescu uint8_t offset;
68097b8278aSCristian Dumitrescu uint8_t n_bits;
68197b8278aSCristian Dumitrescu uint8_t pad[2];
68297b8278aSCristian Dumitrescu };
68397b8278aSCristian Dumitrescu
68497b8278aSCristian Dumitrescu uint32_t val;
68597b8278aSCristian Dumitrescu };
68697b8278aSCristian Dumitrescu } io;
68797b8278aSCristian Dumitrescu
68897b8278aSCristian Dumitrescu struct {
68997b8278aSCristian Dumitrescu uint8_t header_id[8];
69097b8278aSCristian Dumitrescu uint8_t struct_id[8];
69197b8278aSCristian Dumitrescu uint8_t n_bytes[8];
69297b8278aSCristian Dumitrescu } hdr;
69397b8278aSCristian Dumitrescu };
69497b8278aSCristian Dumitrescu
69597b8278aSCristian Dumitrescu struct instr_hdr_validity {
69697b8278aSCristian Dumitrescu uint8_t header_id;
697a1b2afe4SCristian Dumitrescu uint8_t struct_id;
69897b8278aSCristian Dumitrescu };
69997b8278aSCristian Dumitrescu
70097b8278aSCristian Dumitrescu struct instr_table {
70197b8278aSCristian Dumitrescu uint8_t table_id;
70297b8278aSCristian Dumitrescu };
70397b8278aSCristian Dumitrescu
70497b8278aSCristian Dumitrescu struct instr_learn {
70597b8278aSCristian Dumitrescu uint8_t action_id;
706e2ecc535SCristian Dumitrescu uint8_t mf_first_arg_offset;
707e2ecc535SCristian Dumitrescu uint8_t mf_timeout_id_offset;
708e2ecc535SCristian Dumitrescu uint8_t mf_timeout_id_n_bits;
70997b8278aSCristian Dumitrescu };
71097b8278aSCristian Dumitrescu
71197b8278aSCristian Dumitrescu struct instr_extern_obj {
71297b8278aSCristian Dumitrescu uint8_t ext_obj_id;
71397b8278aSCristian Dumitrescu uint8_t func_id;
71497b8278aSCristian Dumitrescu };
71597b8278aSCristian Dumitrescu
71697b8278aSCristian Dumitrescu struct instr_extern_func {
71797b8278aSCristian Dumitrescu uint8_t ext_func_id;
71897b8278aSCristian Dumitrescu };
71997b8278aSCristian Dumitrescu
72092f2944dSCristian Dumitrescu struct instr_hash_func {
72192f2944dSCristian Dumitrescu uint8_t hash_func_id;
72292f2944dSCristian Dumitrescu
72392f2944dSCristian Dumitrescu struct {
72492f2944dSCristian Dumitrescu uint8_t offset;
72592f2944dSCristian Dumitrescu uint8_t n_bits;
72692f2944dSCristian Dumitrescu } dst;
72792f2944dSCristian Dumitrescu
72892f2944dSCristian Dumitrescu struct {
72992f2944dSCristian Dumitrescu uint8_t struct_id;
73092f2944dSCristian Dumitrescu uint16_t offset;
73192f2944dSCristian Dumitrescu uint16_t n_bytes;
73292f2944dSCristian Dumitrescu } src;
73392f2944dSCristian Dumitrescu };
73492f2944dSCristian Dumitrescu
7358ba342ceSCristian Dumitrescu struct instr_rss {
7368ba342ceSCristian Dumitrescu uint8_t rss_obj_id;
7378ba342ceSCristian Dumitrescu
7388ba342ceSCristian Dumitrescu struct {
7398ba342ceSCristian Dumitrescu uint8_t offset;
7408ba342ceSCristian Dumitrescu uint8_t n_bits;
7418ba342ceSCristian Dumitrescu } dst;
7428ba342ceSCristian Dumitrescu
7438ba342ceSCristian Dumitrescu struct {
7448ba342ceSCristian Dumitrescu uint8_t struct_id;
7458ba342ceSCristian Dumitrescu uint16_t offset;
7468ba342ceSCristian Dumitrescu uint16_t n_bytes;
7478ba342ceSCristian Dumitrescu } src;
7488ba342ceSCristian Dumitrescu };
7498ba342ceSCristian Dumitrescu
75097b8278aSCristian Dumitrescu struct instr_dst_src {
75197b8278aSCristian Dumitrescu struct instr_operand dst;
75297b8278aSCristian Dumitrescu union {
75397b8278aSCristian Dumitrescu struct instr_operand src;
75497b8278aSCristian Dumitrescu uint64_t src_val;
75597b8278aSCristian Dumitrescu };
75697b8278aSCristian Dumitrescu };
75797b8278aSCristian Dumitrescu
75897b8278aSCristian Dumitrescu struct instr_regarray {
75997b8278aSCristian Dumitrescu uint8_t regarray_id;
76097b8278aSCristian Dumitrescu uint8_t pad[3];
76197b8278aSCristian Dumitrescu
76297b8278aSCristian Dumitrescu union {
76397b8278aSCristian Dumitrescu struct instr_operand idx;
76497b8278aSCristian Dumitrescu uint32_t idx_val;
76597b8278aSCristian Dumitrescu };
76697b8278aSCristian Dumitrescu
76797b8278aSCristian Dumitrescu union {
76897b8278aSCristian Dumitrescu struct instr_operand dstsrc;
76997b8278aSCristian Dumitrescu uint64_t dstsrc_val;
77097b8278aSCristian Dumitrescu };
77197b8278aSCristian Dumitrescu };
77297b8278aSCristian Dumitrescu
77397b8278aSCristian Dumitrescu struct instr_meter {
77497b8278aSCristian Dumitrescu uint8_t metarray_id;
77597b8278aSCristian Dumitrescu uint8_t pad[3];
77697b8278aSCristian Dumitrescu
77797b8278aSCristian Dumitrescu union {
77897b8278aSCristian Dumitrescu struct instr_operand idx;
77997b8278aSCristian Dumitrescu uint32_t idx_val;
78097b8278aSCristian Dumitrescu };
78197b8278aSCristian Dumitrescu
78297b8278aSCristian Dumitrescu struct instr_operand length;
78397b8278aSCristian Dumitrescu
78497b8278aSCristian Dumitrescu union {
78597b8278aSCristian Dumitrescu struct instr_operand color_in;
78697b8278aSCristian Dumitrescu uint32_t color_in_val;
78797b8278aSCristian Dumitrescu };
78897b8278aSCristian Dumitrescu
78997b8278aSCristian Dumitrescu struct instr_operand color_out;
79097b8278aSCristian Dumitrescu };
79197b8278aSCristian Dumitrescu
79297b8278aSCristian Dumitrescu struct instr_dma {
79397b8278aSCristian Dumitrescu struct {
79497b8278aSCristian Dumitrescu uint8_t header_id[8];
79597b8278aSCristian Dumitrescu uint8_t struct_id[8];
79697b8278aSCristian Dumitrescu } dst;
79797b8278aSCristian Dumitrescu
79897b8278aSCristian Dumitrescu struct {
79997b8278aSCristian Dumitrescu uint8_t offset[8];
80097b8278aSCristian Dumitrescu } src;
80197b8278aSCristian Dumitrescu
80297b8278aSCristian Dumitrescu uint16_t n_bytes[8];
80397b8278aSCristian Dumitrescu };
80497b8278aSCristian Dumitrescu
80597b8278aSCristian Dumitrescu struct instr_jmp {
80697b8278aSCristian Dumitrescu struct instruction *ip;
80797b8278aSCristian Dumitrescu
80897b8278aSCristian Dumitrescu union {
80997b8278aSCristian Dumitrescu struct instr_operand a;
81097b8278aSCristian Dumitrescu uint8_t header_id;
81197b8278aSCristian Dumitrescu uint8_t action_id;
81297b8278aSCristian Dumitrescu };
81397b8278aSCristian Dumitrescu
81497b8278aSCristian Dumitrescu union {
81597b8278aSCristian Dumitrescu struct instr_operand b;
81697b8278aSCristian Dumitrescu uint64_t b_val;
81797b8278aSCristian Dumitrescu };
81897b8278aSCristian Dumitrescu };
81997b8278aSCristian Dumitrescu
82097b8278aSCristian Dumitrescu struct instruction {
82197b8278aSCristian Dumitrescu enum instruction_type type;
82297b8278aSCristian Dumitrescu union {
82397b8278aSCristian Dumitrescu struct instr_io io;
824dac0ecd9SCristian Dumitrescu struct instr_dst_src mirror;
82597b8278aSCristian Dumitrescu struct instr_hdr_validity valid;
82697b8278aSCristian Dumitrescu struct instr_dst_src mov;
82797b8278aSCristian Dumitrescu struct instr_regarray regarray;
82897b8278aSCristian Dumitrescu struct instr_meter meter;
82997b8278aSCristian Dumitrescu struct instr_dma dma;
83097b8278aSCristian Dumitrescu struct instr_dst_src alu;
83197b8278aSCristian Dumitrescu struct instr_table table;
83297b8278aSCristian Dumitrescu struct instr_learn learn;
83397b8278aSCristian Dumitrescu struct instr_extern_obj ext_obj;
83497b8278aSCristian Dumitrescu struct instr_extern_func ext_func;
83592f2944dSCristian Dumitrescu struct instr_hash_func hash_func;
8368ba342ceSCristian Dumitrescu struct instr_rss rss;
83797b8278aSCristian Dumitrescu struct instr_jmp jmp;
83897b8278aSCristian Dumitrescu };
83997b8278aSCristian Dumitrescu };
84097b8278aSCristian Dumitrescu
84197b8278aSCristian Dumitrescu struct instruction_data {
84297b8278aSCristian Dumitrescu char label[RTE_SWX_NAME_SIZE];
84397b8278aSCristian Dumitrescu char jmp_label[RTE_SWX_NAME_SIZE];
84497b8278aSCristian Dumitrescu uint32_t n_users; /* user = jmp instruction to this instruction. */
84597b8278aSCristian Dumitrescu int invalid;
84697b8278aSCristian Dumitrescu };
84797b8278aSCristian Dumitrescu
848dfa9491aSCristian Dumitrescu typedef void (*instr_exec_t)(struct rte_swx_pipeline *);
849dfa9491aSCristian Dumitrescu
85097b8278aSCristian Dumitrescu /*
85197b8278aSCristian Dumitrescu * Action.
85297b8278aSCristian Dumitrescu */
8535dc6a5f2SCristian Dumitrescu typedef void
8545dc6a5f2SCristian Dumitrescu (*action_func_t)(struct rte_swx_pipeline *p);
8555dc6a5f2SCristian Dumitrescu
85697b8278aSCristian Dumitrescu struct action {
85797b8278aSCristian Dumitrescu TAILQ_ENTRY(action) node;
85897b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
85997b8278aSCristian Dumitrescu struct struct_type *st;
86097b8278aSCristian Dumitrescu int *args_endianness; /* 0 = Host Byte Order (HBO); 1 = Network Byte Order (NBO). */
86197b8278aSCristian Dumitrescu struct instruction *instructions;
8624bd025dcSCristian Dumitrescu struct instruction_data *instruction_data;
86397b8278aSCristian Dumitrescu uint32_t n_instructions;
86497b8278aSCristian Dumitrescu uint32_t id;
86597b8278aSCristian Dumitrescu };
86697b8278aSCristian Dumitrescu
86797b8278aSCristian Dumitrescu TAILQ_HEAD(action_tailq, action);
86897b8278aSCristian Dumitrescu
86997b8278aSCristian Dumitrescu /*
87097b8278aSCristian Dumitrescu * Table.
87197b8278aSCristian Dumitrescu */
87297b8278aSCristian Dumitrescu struct table_type {
87397b8278aSCristian Dumitrescu TAILQ_ENTRY(table_type) node;
87497b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
87597b8278aSCristian Dumitrescu enum rte_swx_table_match_type match_type;
87697b8278aSCristian Dumitrescu struct rte_swx_table_ops ops;
87797b8278aSCristian Dumitrescu };
87897b8278aSCristian Dumitrescu
87997b8278aSCristian Dumitrescu TAILQ_HEAD(table_type_tailq, table_type);
88097b8278aSCristian Dumitrescu
88197b8278aSCristian Dumitrescu struct match_field {
88297b8278aSCristian Dumitrescu enum rte_swx_table_match_type match_type;
88397b8278aSCristian Dumitrescu struct field *field;
88497b8278aSCristian Dumitrescu };
88597b8278aSCristian Dumitrescu
88697b8278aSCristian Dumitrescu struct table {
88797b8278aSCristian Dumitrescu TAILQ_ENTRY(table) node;
88897b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
88997b8278aSCristian Dumitrescu char args[RTE_SWX_NAME_SIZE];
89097b8278aSCristian Dumitrescu struct table_type *type; /* NULL when n_fields == 0. */
89197b8278aSCristian Dumitrescu
89297b8278aSCristian Dumitrescu /* Match. */
89397b8278aSCristian Dumitrescu struct match_field *fields;
89497b8278aSCristian Dumitrescu uint32_t n_fields;
89597b8278aSCristian Dumitrescu struct header *header; /* Only valid when n_fields > 0. */
89697b8278aSCristian Dumitrescu
89797b8278aSCristian Dumitrescu /* Action. */
89897b8278aSCristian Dumitrescu struct action **actions;
89997b8278aSCristian Dumitrescu struct action *default_action;
90097b8278aSCristian Dumitrescu uint8_t *default_action_data;
90197b8278aSCristian Dumitrescu uint32_t n_actions;
90297b8278aSCristian Dumitrescu int default_action_is_const;
90397b8278aSCristian Dumitrescu uint32_t action_data_size_max;
904cd79e020SYogesh Jangra int *action_is_for_table_entries;
905cd79e020SYogesh Jangra int *action_is_for_default_entry;
90697b8278aSCristian Dumitrescu
9079560a329SCristian Dumitrescu struct hash_func *hf;
90897b8278aSCristian Dumitrescu uint32_t size;
90997b8278aSCristian Dumitrescu uint32_t id;
91097b8278aSCristian Dumitrescu };
91197b8278aSCristian Dumitrescu
91297b8278aSCristian Dumitrescu TAILQ_HEAD(table_tailq, table);
91397b8278aSCristian Dumitrescu
91497b8278aSCristian Dumitrescu struct table_runtime {
91597b8278aSCristian Dumitrescu rte_swx_table_lookup_t func;
91697b8278aSCristian Dumitrescu void *mailbox;
91797b8278aSCristian Dumitrescu uint8_t **key;
91897b8278aSCristian Dumitrescu };
91997b8278aSCristian Dumitrescu
92097b8278aSCristian Dumitrescu struct table_statistics {
92197b8278aSCristian Dumitrescu uint64_t n_pkts_hit[2]; /* 0 = Miss, 1 = Hit. */
92297b8278aSCristian Dumitrescu uint64_t *n_pkts_action;
92397b8278aSCristian Dumitrescu };
92497b8278aSCristian Dumitrescu
92597b8278aSCristian Dumitrescu /*
92697b8278aSCristian Dumitrescu * Selector.
92797b8278aSCristian Dumitrescu */
92897b8278aSCristian Dumitrescu struct selector {
92997b8278aSCristian Dumitrescu TAILQ_ENTRY(selector) node;
93097b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
93197b8278aSCristian Dumitrescu
93297b8278aSCristian Dumitrescu struct field *group_id_field;
93397b8278aSCristian Dumitrescu struct field **selector_fields;
93497b8278aSCristian Dumitrescu uint32_t n_selector_fields;
93597b8278aSCristian Dumitrescu struct header *selector_header;
93697b8278aSCristian Dumitrescu struct field *member_id_field;
93797b8278aSCristian Dumitrescu
93897b8278aSCristian Dumitrescu uint32_t n_groups_max;
93997b8278aSCristian Dumitrescu uint32_t n_members_per_group_max;
94097b8278aSCristian Dumitrescu
94197b8278aSCristian Dumitrescu uint32_t id;
94297b8278aSCristian Dumitrescu };
94397b8278aSCristian Dumitrescu
94497b8278aSCristian Dumitrescu TAILQ_HEAD(selector_tailq, selector);
94597b8278aSCristian Dumitrescu
94697b8278aSCristian Dumitrescu struct selector_runtime {
94797b8278aSCristian Dumitrescu void *mailbox;
94897b8278aSCristian Dumitrescu uint8_t **group_id_buffer;
94997b8278aSCristian Dumitrescu uint8_t **selector_buffer;
95097b8278aSCristian Dumitrescu uint8_t **member_id_buffer;
95197b8278aSCristian Dumitrescu };
95297b8278aSCristian Dumitrescu
95397b8278aSCristian Dumitrescu struct selector_statistics {
95497b8278aSCristian Dumitrescu uint64_t n_pkts;
95597b8278aSCristian Dumitrescu };
95697b8278aSCristian Dumitrescu
95797b8278aSCristian Dumitrescu /*
95897b8278aSCristian Dumitrescu * Learner table.
95997b8278aSCristian Dumitrescu */
96097b8278aSCristian Dumitrescu struct learner {
96197b8278aSCristian Dumitrescu TAILQ_ENTRY(learner) node;
96297b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
96397b8278aSCristian Dumitrescu
96497b8278aSCristian Dumitrescu /* Match. */
96597b8278aSCristian Dumitrescu struct field **fields;
96697b8278aSCristian Dumitrescu uint32_t n_fields;
96797b8278aSCristian Dumitrescu struct header *header;
96897b8278aSCristian Dumitrescu
96997b8278aSCristian Dumitrescu /* Action. */
97097b8278aSCristian Dumitrescu struct action **actions;
97197b8278aSCristian Dumitrescu struct action *default_action;
97297b8278aSCristian Dumitrescu uint8_t *default_action_data;
97397b8278aSCristian Dumitrescu uint32_t n_actions;
97497b8278aSCristian Dumitrescu int default_action_is_const;
97597b8278aSCristian Dumitrescu uint32_t action_data_size_max;
976cd79e020SYogesh Jangra int *action_is_for_table_entries;
977cd79e020SYogesh Jangra int *action_is_for_default_entry;
97897b8278aSCristian Dumitrescu
979fa7723b5SCristian Dumitrescu struct hash_func *hf;
98097b8278aSCristian Dumitrescu uint32_t size;
981e2ecc535SCristian Dumitrescu uint32_t timeout[RTE_SWX_TABLE_LEARNER_N_KEY_TIMEOUTS_MAX];
982e2ecc535SCristian Dumitrescu uint32_t n_timeouts;
98397b8278aSCristian Dumitrescu uint32_t id;
98497b8278aSCristian Dumitrescu };
98597b8278aSCristian Dumitrescu
98697b8278aSCristian Dumitrescu TAILQ_HEAD(learner_tailq, learner);
98797b8278aSCristian Dumitrescu
98897b8278aSCristian Dumitrescu struct learner_runtime {
98997b8278aSCristian Dumitrescu void *mailbox;
99097b8278aSCristian Dumitrescu uint8_t **key;
99197b8278aSCristian Dumitrescu };
99297b8278aSCristian Dumitrescu
99397b8278aSCristian Dumitrescu struct learner_statistics {
99497b8278aSCristian Dumitrescu uint64_t n_pkts_hit[2]; /* 0 = Miss, 1 = Hit. */
99597b8278aSCristian Dumitrescu uint64_t n_pkts_learn[2]; /* 0 = Learn OK, 1 = Learn error. */
996e2ecc535SCristian Dumitrescu uint64_t n_pkts_rearm;
99797b8278aSCristian Dumitrescu uint64_t n_pkts_forget;
99897b8278aSCristian Dumitrescu uint64_t *n_pkts_action;
99997b8278aSCristian Dumitrescu };
100097b8278aSCristian Dumitrescu
100197b8278aSCristian Dumitrescu /*
100297b8278aSCristian Dumitrescu * Register array.
100397b8278aSCristian Dumitrescu */
100497b8278aSCristian Dumitrescu struct regarray {
100597b8278aSCristian Dumitrescu TAILQ_ENTRY(regarray) node;
100697b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
100797b8278aSCristian Dumitrescu uint64_t init_val;
100897b8278aSCristian Dumitrescu uint32_t size;
100997b8278aSCristian Dumitrescu uint32_t id;
101097b8278aSCristian Dumitrescu };
101197b8278aSCristian Dumitrescu
101297b8278aSCristian Dumitrescu TAILQ_HEAD(regarray_tailq, regarray);
101397b8278aSCristian Dumitrescu
101497b8278aSCristian Dumitrescu struct regarray_runtime {
101597b8278aSCristian Dumitrescu uint64_t *regarray;
101697b8278aSCristian Dumitrescu uint32_t size_mask;
101797b8278aSCristian Dumitrescu };
101897b8278aSCristian Dumitrescu
101997b8278aSCristian Dumitrescu /*
102097b8278aSCristian Dumitrescu * Meter array.
102197b8278aSCristian Dumitrescu */
102297b8278aSCristian Dumitrescu struct meter_profile {
102397b8278aSCristian Dumitrescu TAILQ_ENTRY(meter_profile) node;
102497b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
102597b8278aSCristian Dumitrescu struct rte_meter_trtcm_params params;
102697b8278aSCristian Dumitrescu struct rte_meter_trtcm_profile profile;
102797b8278aSCristian Dumitrescu uint32_t n_users;
102897b8278aSCristian Dumitrescu };
102997b8278aSCristian Dumitrescu
103097b8278aSCristian Dumitrescu TAILQ_HEAD(meter_profile_tailq, meter_profile);
103197b8278aSCristian Dumitrescu
103297b8278aSCristian Dumitrescu struct metarray {
103397b8278aSCristian Dumitrescu TAILQ_ENTRY(metarray) node;
103497b8278aSCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
103597b8278aSCristian Dumitrescu uint32_t size;
103697b8278aSCristian Dumitrescu uint32_t id;
103797b8278aSCristian Dumitrescu };
103897b8278aSCristian Dumitrescu
103997b8278aSCristian Dumitrescu TAILQ_HEAD(metarray_tailq, metarray);
104097b8278aSCristian Dumitrescu
104197b8278aSCristian Dumitrescu struct meter {
104297b8278aSCristian Dumitrescu struct rte_meter_trtcm m;
104397b8278aSCristian Dumitrescu struct meter_profile *profile;
104497b8278aSCristian Dumitrescu enum rte_color color_mask;
104597b8278aSCristian Dumitrescu uint8_t pad[20];
104697b8278aSCristian Dumitrescu
104797b8278aSCristian Dumitrescu uint64_t n_pkts[RTE_COLORS];
104897b8278aSCristian Dumitrescu uint64_t n_bytes[RTE_COLORS];
104997b8278aSCristian Dumitrescu };
105097b8278aSCristian Dumitrescu
105197b8278aSCristian Dumitrescu struct metarray_runtime {
105297b8278aSCristian Dumitrescu struct meter *metarray;
105397b8278aSCristian Dumitrescu uint32_t size_mask;
105497b8278aSCristian Dumitrescu };
105597b8278aSCristian Dumitrescu
105697b8278aSCristian Dumitrescu /*
105797b8278aSCristian Dumitrescu * Pipeline.
105897b8278aSCristian Dumitrescu */
105997b8278aSCristian Dumitrescu struct thread {
106097b8278aSCristian Dumitrescu /* Packet. */
106197b8278aSCristian Dumitrescu struct rte_swx_pkt pkt;
106297b8278aSCristian Dumitrescu uint8_t *ptr;
1063dac0ecd9SCristian Dumitrescu uint32_t *mirroring_slots;
1064dac0ecd9SCristian Dumitrescu uint64_t mirroring_slots_mask;
10655ec76d29SCristian Dumitrescu int recirculate;
10665ec76d29SCristian Dumitrescu uint32_t recirc_pass_id;
106797b8278aSCristian Dumitrescu
106897b8278aSCristian Dumitrescu /* Structures. */
106997b8278aSCristian Dumitrescu uint8_t **structs;
107097b8278aSCristian Dumitrescu
107197b8278aSCristian Dumitrescu /* Packet headers. */
107297b8278aSCristian Dumitrescu struct header_runtime *headers; /* Extracted or generated headers. */
107397b8278aSCristian Dumitrescu struct header_out_runtime *headers_out; /* Emitted headers. */
107497b8278aSCristian Dumitrescu uint8_t *header_storage;
107597b8278aSCristian Dumitrescu uint8_t *header_out_storage;
107697b8278aSCristian Dumitrescu uint64_t valid_headers;
107797b8278aSCristian Dumitrescu uint32_t n_headers_out;
107897b8278aSCristian Dumitrescu
107997b8278aSCristian Dumitrescu /* Packet meta-data. */
108097b8278aSCristian Dumitrescu uint8_t *metadata;
108197b8278aSCristian Dumitrescu
108297b8278aSCristian Dumitrescu /* Tables. */
108397b8278aSCristian Dumitrescu struct table_runtime *tables;
108497b8278aSCristian Dumitrescu struct selector_runtime *selectors;
108597b8278aSCristian Dumitrescu struct learner_runtime *learners;
108697b8278aSCristian Dumitrescu struct rte_swx_table_state *table_state;
108797b8278aSCristian Dumitrescu uint64_t action_id;
108842605e56SCristian Dumitrescu size_t entry_id;
108997b8278aSCristian Dumitrescu int hit; /* 0 = Miss, 1 = Hit. */
109097b8278aSCristian Dumitrescu uint32_t learner_id;
109197b8278aSCristian Dumitrescu uint64_t time;
109297b8278aSCristian Dumitrescu
109397b8278aSCristian Dumitrescu /* Extern objects and functions. */
109497b8278aSCristian Dumitrescu struct extern_obj_runtime *extern_objs;
109597b8278aSCristian Dumitrescu struct extern_func_runtime *extern_funcs;
109697b8278aSCristian Dumitrescu
109797b8278aSCristian Dumitrescu /* Instructions. */
109897b8278aSCristian Dumitrescu struct instruction *ip;
109997b8278aSCristian Dumitrescu struct instruction *ret;
110097b8278aSCristian Dumitrescu };
110197b8278aSCristian Dumitrescu
110297b8278aSCristian Dumitrescu #define MASK64_BIT_GET(mask, pos) ((mask) & (1LLU << (pos)))
110397b8278aSCristian Dumitrescu #define MASK64_BIT_SET(mask, pos) ((mask) | (1LLU << (pos)))
110497b8278aSCristian Dumitrescu #define MASK64_BIT_CLR(mask, pos) ((mask) & ~(1LLU << (pos)))
110597b8278aSCristian Dumitrescu
110697b8278aSCristian Dumitrescu #define HEADER_VALID(thread, header_id) \
110797b8278aSCristian Dumitrescu MASK64_BIT_GET((thread)->valid_headers, header_id)
110897b8278aSCristian Dumitrescu
110940baf712SCristian Dumitrescu static inline uint64_t
instr_operand_hbo(struct thread * t,const struct instr_operand * x)111040baf712SCristian Dumitrescu instr_operand_hbo(struct thread *t, const struct instr_operand *x)
111140baf712SCristian Dumitrescu {
111240baf712SCristian Dumitrescu uint8_t *x_struct = t->structs[x->struct_id];
111340baf712SCristian Dumitrescu uint64_t *x64_ptr = (uint64_t *)&x_struct[x->offset];
111440baf712SCristian Dumitrescu uint64_t x64 = *x64_ptr;
111540baf712SCristian Dumitrescu uint64_t x64_mask = UINT64_MAX >> (64 - x->n_bits);
111640baf712SCristian Dumitrescu
111740baf712SCristian Dumitrescu return x64 & x64_mask;
111840baf712SCristian Dumitrescu }
111940baf712SCristian Dumitrescu
112040baf712SCristian Dumitrescu #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
112140baf712SCristian Dumitrescu
112240baf712SCristian Dumitrescu static inline uint64_t
instr_operand_nbo(struct thread * t,const struct instr_operand * x)112340baf712SCristian Dumitrescu instr_operand_nbo(struct thread *t, const struct instr_operand *x)
112440baf712SCristian Dumitrescu {
112540baf712SCristian Dumitrescu uint8_t *x_struct = t->structs[x->struct_id];
112640baf712SCristian Dumitrescu uint64_t *x64_ptr = (uint64_t *)&x_struct[x->offset];
112740baf712SCristian Dumitrescu uint64_t x64 = *x64_ptr;
112840baf712SCristian Dumitrescu
112940baf712SCristian Dumitrescu return ntoh64(x64) >> (64 - x->n_bits);
113040baf712SCristian Dumitrescu }
113140baf712SCristian Dumitrescu
113240baf712SCristian Dumitrescu #else
113340baf712SCristian Dumitrescu
113440baf712SCristian Dumitrescu #define instr_operand_nbo instr_operand_hbo
113540baf712SCristian Dumitrescu
113640baf712SCristian Dumitrescu #endif
113740baf712SCristian Dumitrescu
113897b8278aSCristian Dumitrescu #define ALU(thread, ip, operator) \
113997b8278aSCristian Dumitrescu { \
114097b8278aSCristian Dumitrescu uint8_t *dst_struct = (thread)->structs[(ip)->alu.dst.struct_id]; \
114197b8278aSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->alu.dst.offset]; \
114297b8278aSCristian Dumitrescu uint64_t dst64 = *dst64_ptr; \
114397b8278aSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->alu.dst.n_bits); \
114497b8278aSCristian Dumitrescu uint64_t dst = dst64 & dst64_mask; \
114597b8278aSCristian Dumitrescu \
114697b8278aSCristian Dumitrescu uint8_t *src_struct = (thread)->structs[(ip)->alu.src.struct_id]; \
114797b8278aSCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[(ip)->alu.src.offset]; \
114897b8278aSCristian Dumitrescu uint64_t src64 = *src64_ptr; \
114997b8278aSCristian Dumitrescu uint64_t src64_mask = UINT64_MAX >> (64 - (ip)->alu.src.n_bits); \
115097b8278aSCristian Dumitrescu uint64_t src = src64 & src64_mask; \
115197b8278aSCristian Dumitrescu \
115297b8278aSCristian Dumitrescu uint64_t result = dst operator src; \
115397b8278aSCristian Dumitrescu \
115497b8278aSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | (result & dst64_mask); \
115597b8278aSCristian Dumitrescu }
115697b8278aSCristian Dumitrescu
115797b8278aSCristian Dumitrescu #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
115897b8278aSCristian Dumitrescu
115997b8278aSCristian Dumitrescu #define ALU_MH(thread, ip, operator) \
116097b8278aSCristian Dumitrescu { \
116197b8278aSCristian Dumitrescu uint8_t *dst_struct = (thread)->structs[(ip)->alu.dst.struct_id]; \
116297b8278aSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->alu.dst.offset]; \
116397b8278aSCristian Dumitrescu uint64_t dst64 = *dst64_ptr; \
116497b8278aSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->alu.dst.n_bits); \
116597b8278aSCristian Dumitrescu uint64_t dst = dst64 & dst64_mask; \
116697b8278aSCristian Dumitrescu \
116797b8278aSCristian Dumitrescu uint8_t *src_struct = (thread)->structs[(ip)->alu.src.struct_id]; \
116897b8278aSCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[(ip)->alu.src.offset]; \
116997b8278aSCristian Dumitrescu uint64_t src64 = *src64_ptr; \
117097b8278aSCristian Dumitrescu uint64_t src = ntoh64(src64) >> (64 - (ip)->alu.src.n_bits); \
117197b8278aSCristian Dumitrescu \
117297b8278aSCristian Dumitrescu uint64_t result = dst operator src; \
117397b8278aSCristian Dumitrescu \
117497b8278aSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | (result & dst64_mask); \
117597b8278aSCristian Dumitrescu }
117697b8278aSCristian Dumitrescu
117797b8278aSCristian Dumitrescu #define ALU_HM(thread, ip, operator) \
117897b8278aSCristian Dumitrescu { \
117997b8278aSCristian Dumitrescu uint8_t *dst_struct = (thread)->structs[(ip)->alu.dst.struct_id]; \
118097b8278aSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->alu.dst.offset]; \
118197b8278aSCristian Dumitrescu uint64_t dst64 = *dst64_ptr; \
118297b8278aSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->alu.dst.n_bits); \
118397b8278aSCristian Dumitrescu uint64_t dst = ntoh64(dst64) >> (64 - (ip)->alu.dst.n_bits); \
118497b8278aSCristian Dumitrescu \
118597b8278aSCristian Dumitrescu uint8_t *src_struct = (thread)->structs[(ip)->alu.src.struct_id]; \
118697b8278aSCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[(ip)->alu.src.offset]; \
118797b8278aSCristian Dumitrescu uint64_t src64 = *src64_ptr; \
118897b8278aSCristian Dumitrescu uint64_t src64_mask = UINT64_MAX >> (64 - (ip)->alu.src.n_bits); \
118997b8278aSCristian Dumitrescu uint64_t src = src64 & src64_mask; \
119097b8278aSCristian Dumitrescu \
119197b8278aSCristian Dumitrescu uint64_t result = dst operator src; \
119297b8278aSCristian Dumitrescu result = hton64(result << (64 - (ip)->alu.dst.n_bits)); \
119397b8278aSCristian Dumitrescu \
119497b8278aSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | result; \
119597b8278aSCristian Dumitrescu }
119697b8278aSCristian Dumitrescu
119797b8278aSCristian Dumitrescu #define ALU_HM_FAST(thread, ip, operator) \
119897b8278aSCristian Dumitrescu { \
119997b8278aSCristian Dumitrescu uint8_t *dst_struct = (thread)->structs[(ip)->alu.dst.struct_id]; \
120097b8278aSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->alu.dst.offset]; \
120197b8278aSCristian Dumitrescu uint64_t dst64 = *dst64_ptr; \
120297b8278aSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->alu.dst.n_bits); \
120397b8278aSCristian Dumitrescu uint64_t dst = dst64 & dst64_mask; \
120497b8278aSCristian Dumitrescu \
120597b8278aSCristian Dumitrescu uint8_t *src_struct = (thread)->structs[(ip)->alu.src.struct_id]; \
120697b8278aSCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[(ip)->alu.src.offset]; \
120797b8278aSCristian Dumitrescu uint64_t src64 = *src64_ptr; \
120897b8278aSCristian Dumitrescu uint64_t src64_mask = UINT64_MAX >> (64 - (ip)->alu.src.n_bits); \
120997b8278aSCristian Dumitrescu uint64_t src = hton64(src64 & src64_mask) >> (64 - (ip)->alu.dst.n_bits); \
121097b8278aSCristian Dumitrescu \
121197b8278aSCristian Dumitrescu uint64_t result = dst operator src; \
121297b8278aSCristian Dumitrescu \
121397b8278aSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | result; \
121497b8278aSCristian Dumitrescu }
121597b8278aSCristian Dumitrescu
121697b8278aSCristian Dumitrescu #define ALU_HH(thread, ip, operator) \
121797b8278aSCristian Dumitrescu { \
121897b8278aSCristian Dumitrescu uint8_t *dst_struct = (thread)->structs[(ip)->alu.dst.struct_id]; \
121997b8278aSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->alu.dst.offset]; \
122097b8278aSCristian Dumitrescu uint64_t dst64 = *dst64_ptr; \
122197b8278aSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->alu.dst.n_bits); \
122297b8278aSCristian Dumitrescu uint64_t dst = ntoh64(dst64) >> (64 - (ip)->alu.dst.n_bits); \
122397b8278aSCristian Dumitrescu \
122497b8278aSCristian Dumitrescu uint8_t *src_struct = (thread)->structs[(ip)->alu.src.struct_id]; \
122597b8278aSCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[(ip)->alu.src.offset]; \
122697b8278aSCristian Dumitrescu uint64_t src64 = *src64_ptr; \
122797b8278aSCristian Dumitrescu uint64_t src = ntoh64(src64) >> (64 - (ip)->alu.src.n_bits); \
122897b8278aSCristian Dumitrescu \
122997b8278aSCristian Dumitrescu uint64_t result = dst operator src; \
123097b8278aSCristian Dumitrescu result = hton64(result << (64 - (ip)->alu.dst.n_bits)); \
123197b8278aSCristian Dumitrescu \
123297b8278aSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | result; \
123397b8278aSCristian Dumitrescu }
123497b8278aSCristian Dumitrescu
123597b8278aSCristian Dumitrescu #define ALU_HH_FAST(thread, ip, operator) \
123697b8278aSCristian Dumitrescu { \
123797b8278aSCristian Dumitrescu uint8_t *dst_struct = (thread)->structs[(ip)->alu.dst.struct_id]; \
123897b8278aSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->alu.dst.offset]; \
123997b8278aSCristian Dumitrescu uint64_t dst64 = *dst64_ptr; \
124097b8278aSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->alu.dst.n_bits); \
124197b8278aSCristian Dumitrescu uint64_t dst = dst64 & dst64_mask; \
124297b8278aSCristian Dumitrescu \
124397b8278aSCristian Dumitrescu uint8_t *src_struct = (thread)->structs[(ip)->alu.src.struct_id]; \
124497b8278aSCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[(ip)->alu.src.offset]; \
124597b8278aSCristian Dumitrescu uint64_t src64 = *src64_ptr; \
124697b8278aSCristian Dumitrescu uint64_t src = (src64 << (64 - (ip)->alu.src.n_bits)) >> (64 - (ip)->alu.dst.n_bits); \
124797b8278aSCristian Dumitrescu \
124897b8278aSCristian Dumitrescu uint64_t result = dst operator src; \
124997b8278aSCristian Dumitrescu \
125097b8278aSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | result; \
125197b8278aSCristian Dumitrescu }
125297b8278aSCristian Dumitrescu
125397b8278aSCristian Dumitrescu #else
125497b8278aSCristian Dumitrescu
125597b8278aSCristian Dumitrescu #define ALU_MH ALU
125697b8278aSCristian Dumitrescu #define ALU_HM ALU
125797b8278aSCristian Dumitrescu #define ALU_HM_FAST ALU
125897b8278aSCristian Dumitrescu #define ALU_HH ALU
125997b8278aSCristian Dumitrescu #define ALU_HH_FAST ALU
126097b8278aSCristian Dumitrescu
126197b8278aSCristian Dumitrescu #endif
126297b8278aSCristian Dumitrescu
126397b8278aSCristian Dumitrescu #define ALU_I(thread, ip, operator) \
126497b8278aSCristian Dumitrescu { \
126597b8278aSCristian Dumitrescu uint8_t *dst_struct = (thread)->structs[(ip)->alu.dst.struct_id]; \
126697b8278aSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->alu.dst.offset]; \
126797b8278aSCristian Dumitrescu uint64_t dst64 = *dst64_ptr; \
126897b8278aSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->alu.dst.n_bits); \
126997b8278aSCristian Dumitrescu uint64_t dst = dst64 & dst64_mask; \
127097b8278aSCristian Dumitrescu \
127197b8278aSCristian Dumitrescu uint64_t src = (ip)->alu.src_val; \
127297b8278aSCristian Dumitrescu \
127397b8278aSCristian Dumitrescu uint64_t result = dst operator src; \
127497b8278aSCristian Dumitrescu \
127597b8278aSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | (result & dst64_mask); \
127697b8278aSCristian Dumitrescu }
127797b8278aSCristian Dumitrescu
127897b8278aSCristian Dumitrescu #define ALU_MI ALU_I
127997b8278aSCristian Dumitrescu
128097b8278aSCristian Dumitrescu #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
128197b8278aSCristian Dumitrescu
128297b8278aSCristian Dumitrescu #define ALU_HI(thread, ip, operator) \
128397b8278aSCristian Dumitrescu { \
128497b8278aSCristian Dumitrescu uint8_t *dst_struct = (thread)->structs[(ip)->alu.dst.struct_id]; \
128597b8278aSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->alu.dst.offset]; \
128697b8278aSCristian Dumitrescu uint64_t dst64 = *dst64_ptr; \
128797b8278aSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->alu.dst.n_bits); \
128897b8278aSCristian Dumitrescu uint64_t dst = ntoh64(dst64) >> (64 - (ip)->alu.dst.n_bits); \
128997b8278aSCristian Dumitrescu \
129097b8278aSCristian Dumitrescu uint64_t src = (ip)->alu.src_val; \
129197b8278aSCristian Dumitrescu \
129297b8278aSCristian Dumitrescu uint64_t result = dst operator src; \
129397b8278aSCristian Dumitrescu result = hton64(result << (64 - (ip)->alu.dst.n_bits)); \
129497b8278aSCristian Dumitrescu \
129597b8278aSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | result; \
129697b8278aSCristian Dumitrescu }
129797b8278aSCristian Dumitrescu
129897b8278aSCristian Dumitrescu #else
129997b8278aSCristian Dumitrescu
130097b8278aSCristian Dumitrescu #define ALU_HI ALU_I
130197b8278aSCristian Dumitrescu
130297b8278aSCristian Dumitrescu #endif
130397b8278aSCristian Dumitrescu
130497b8278aSCristian Dumitrescu #define MOV(thread, ip) \
130597b8278aSCristian Dumitrescu { \
130697b8278aSCristian Dumitrescu uint8_t *dst_struct = (thread)->structs[(ip)->mov.dst.struct_id]; \
130797b8278aSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->mov.dst.offset]; \
130897b8278aSCristian Dumitrescu uint64_t dst64 = *dst64_ptr; \
130997b8278aSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->mov.dst.n_bits); \
131097b8278aSCristian Dumitrescu \
131197b8278aSCristian Dumitrescu uint8_t *src_struct = (thread)->structs[(ip)->mov.src.struct_id]; \
131297b8278aSCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[(ip)->mov.src.offset]; \
131397b8278aSCristian Dumitrescu uint64_t src64 = *src64_ptr; \
131497b8278aSCristian Dumitrescu uint64_t src64_mask = UINT64_MAX >> (64 - (ip)->mov.src.n_bits); \
131597b8278aSCristian Dumitrescu uint64_t src = src64 & src64_mask; \
131697b8278aSCristian Dumitrescu \
131797b8278aSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | (src & dst64_mask); \
131897b8278aSCristian Dumitrescu }
131997b8278aSCristian Dumitrescu
132097b8278aSCristian Dumitrescu #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
132197b8278aSCristian Dumitrescu
132297b8278aSCristian Dumitrescu #define MOV_MH(thread, ip) \
132397b8278aSCristian Dumitrescu { \
132497b8278aSCristian Dumitrescu uint8_t *dst_struct = (thread)->structs[(ip)->mov.dst.struct_id]; \
132597b8278aSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->mov.dst.offset]; \
132697b8278aSCristian Dumitrescu uint64_t dst64 = *dst64_ptr; \
132797b8278aSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->mov.dst.n_bits); \
132897b8278aSCristian Dumitrescu \
132997b8278aSCristian Dumitrescu uint8_t *src_struct = (thread)->structs[(ip)->mov.src.struct_id]; \
133097b8278aSCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[(ip)->mov.src.offset]; \
133197b8278aSCristian Dumitrescu uint64_t src64 = *src64_ptr; \
133297b8278aSCristian Dumitrescu uint64_t src = ntoh64(src64) >> (64 - (ip)->mov.src.n_bits); \
133397b8278aSCristian Dumitrescu \
133497b8278aSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | (src & dst64_mask); \
133597b8278aSCristian Dumitrescu }
133697b8278aSCristian Dumitrescu
133797b8278aSCristian Dumitrescu #define MOV_HM(thread, ip) \
133897b8278aSCristian Dumitrescu { \
133997b8278aSCristian Dumitrescu uint8_t *dst_struct = (thread)->structs[(ip)->mov.dst.struct_id]; \
134097b8278aSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->mov.dst.offset]; \
134197b8278aSCristian Dumitrescu uint64_t dst64 = *dst64_ptr; \
134297b8278aSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->mov.dst.n_bits); \
134397b8278aSCristian Dumitrescu \
134497b8278aSCristian Dumitrescu uint8_t *src_struct = (thread)->structs[(ip)->mov.src.struct_id]; \
134597b8278aSCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[(ip)->mov.src.offset]; \
134697b8278aSCristian Dumitrescu uint64_t src64 = *src64_ptr; \
134797b8278aSCristian Dumitrescu uint64_t src64_mask = UINT64_MAX >> (64 - (ip)->mov.src.n_bits); \
134897b8278aSCristian Dumitrescu uint64_t src = src64 & src64_mask; \
134997b8278aSCristian Dumitrescu \
135097b8278aSCristian Dumitrescu src = hton64(src) >> (64 - (ip)->mov.dst.n_bits); \
135197b8278aSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | src; \
135297b8278aSCristian Dumitrescu }
135397b8278aSCristian Dumitrescu
135497b8278aSCristian Dumitrescu #define MOV_HH(thread, ip) \
135597b8278aSCristian Dumitrescu { \
135697b8278aSCristian Dumitrescu uint8_t *dst_struct = (thread)->structs[(ip)->mov.dst.struct_id]; \
135797b8278aSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->mov.dst.offset]; \
135897b8278aSCristian Dumitrescu uint64_t dst64 = *dst64_ptr; \
135997b8278aSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->mov.dst.n_bits); \
136097b8278aSCristian Dumitrescu \
136197b8278aSCristian Dumitrescu uint8_t *src_struct = (thread)->structs[(ip)->mov.src.struct_id]; \
136297b8278aSCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[(ip)->mov.src.offset]; \
136397b8278aSCristian Dumitrescu uint64_t src64 = *src64_ptr; \
136497b8278aSCristian Dumitrescu \
136597b8278aSCristian Dumitrescu uint64_t src = src64 << (64 - (ip)->mov.src.n_bits); \
136697b8278aSCristian Dumitrescu src = src >> (64 - (ip)->mov.dst.n_bits); \
136797b8278aSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | src; \
136897b8278aSCristian Dumitrescu }
136997b8278aSCristian Dumitrescu
137097b8278aSCristian Dumitrescu #else
137197b8278aSCristian Dumitrescu
137297b8278aSCristian Dumitrescu #define MOV_MH MOV
137397b8278aSCristian Dumitrescu #define MOV_HM MOV
137497b8278aSCristian Dumitrescu #define MOV_HH MOV
137597b8278aSCristian Dumitrescu
137697b8278aSCristian Dumitrescu #endif
137797b8278aSCristian Dumitrescu
137897b8278aSCristian Dumitrescu #define MOV_I(thread, ip) \
137997b8278aSCristian Dumitrescu { \
138097b8278aSCristian Dumitrescu uint8_t *dst_struct = (thread)->structs[(ip)->mov.dst.struct_id]; \
138197b8278aSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[(ip)->mov.dst.offset]; \
138297b8278aSCristian Dumitrescu uint64_t dst64 = *dst64_ptr; \
138397b8278aSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - (ip)->mov.dst.n_bits); \
138497b8278aSCristian Dumitrescu \
138597b8278aSCristian Dumitrescu uint64_t src = (ip)->mov.src_val; \
138697b8278aSCristian Dumitrescu \
138797b8278aSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | (src & dst64_mask); \
138897b8278aSCristian Dumitrescu }
138997b8278aSCristian Dumitrescu
139097b8278aSCristian Dumitrescu #define JMP_CMP(thread, ip, operator) \
139197b8278aSCristian Dumitrescu { \
139297b8278aSCristian Dumitrescu uint8_t *a_struct = (thread)->structs[(ip)->jmp.a.struct_id]; \
139397b8278aSCristian Dumitrescu uint64_t *a64_ptr = (uint64_t *)&a_struct[(ip)->jmp.a.offset]; \
139497b8278aSCristian Dumitrescu uint64_t a64 = *a64_ptr; \
139597b8278aSCristian Dumitrescu uint64_t a64_mask = UINT64_MAX >> (64 - (ip)->jmp.a.n_bits); \
139697b8278aSCristian Dumitrescu uint64_t a = a64 & a64_mask; \
139797b8278aSCristian Dumitrescu \
139897b8278aSCristian Dumitrescu uint8_t *b_struct = (thread)->structs[(ip)->jmp.b.struct_id]; \
139997b8278aSCristian Dumitrescu uint64_t *b64_ptr = (uint64_t *)&b_struct[(ip)->jmp.b.offset]; \
140097b8278aSCristian Dumitrescu uint64_t b64 = *b64_ptr; \
140197b8278aSCristian Dumitrescu uint64_t b64_mask = UINT64_MAX >> (64 - (ip)->jmp.b.n_bits); \
140297b8278aSCristian Dumitrescu uint64_t b = b64 & b64_mask; \
140397b8278aSCristian Dumitrescu \
140497b8278aSCristian Dumitrescu (thread)->ip = (a operator b) ? (ip)->jmp.ip : ((thread)->ip + 1); \
140597b8278aSCristian Dumitrescu }
140697b8278aSCristian Dumitrescu
140797b8278aSCristian Dumitrescu #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
140897b8278aSCristian Dumitrescu
140997b8278aSCristian Dumitrescu #define JMP_CMP_MH(thread, ip, operator) \
141097b8278aSCristian Dumitrescu { \
141197b8278aSCristian Dumitrescu uint8_t *a_struct = (thread)->structs[(ip)->jmp.a.struct_id]; \
141297b8278aSCristian Dumitrescu uint64_t *a64_ptr = (uint64_t *)&a_struct[(ip)->jmp.a.offset]; \
141397b8278aSCristian Dumitrescu uint64_t a64 = *a64_ptr; \
141497b8278aSCristian Dumitrescu uint64_t a64_mask = UINT64_MAX >> (64 - (ip)->jmp.a.n_bits); \
141597b8278aSCristian Dumitrescu uint64_t a = a64 & a64_mask; \
141697b8278aSCristian Dumitrescu \
141797b8278aSCristian Dumitrescu uint8_t *b_struct = (thread)->structs[(ip)->jmp.b.struct_id]; \
141897b8278aSCristian Dumitrescu uint64_t *b64_ptr = (uint64_t *)&b_struct[(ip)->jmp.b.offset]; \
141997b8278aSCristian Dumitrescu uint64_t b64 = *b64_ptr; \
142097b8278aSCristian Dumitrescu uint64_t b = ntoh64(b64) >> (64 - (ip)->jmp.b.n_bits); \
142197b8278aSCristian Dumitrescu \
142297b8278aSCristian Dumitrescu (thread)->ip = (a operator b) ? (ip)->jmp.ip : ((thread)->ip + 1); \
142397b8278aSCristian Dumitrescu }
142497b8278aSCristian Dumitrescu
142597b8278aSCristian Dumitrescu #define JMP_CMP_HM(thread, ip, operator) \
142697b8278aSCristian Dumitrescu { \
142797b8278aSCristian Dumitrescu uint8_t *a_struct = (thread)->structs[(ip)->jmp.a.struct_id]; \
142897b8278aSCristian Dumitrescu uint64_t *a64_ptr = (uint64_t *)&a_struct[(ip)->jmp.a.offset]; \
142997b8278aSCristian Dumitrescu uint64_t a64 = *a64_ptr; \
143097b8278aSCristian Dumitrescu uint64_t a = ntoh64(a64) >> (64 - (ip)->jmp.a.n_bits); \
143197b8278aSCristian Dumitrescu \
143297b8278aSCristian Dumitrescu uint8_t *b_struct = (thread)->structs[(ip)->jmp.b.struct_id]; \
143397b8278aSCristian Dumitrescu uint64_t *b64_ptr = (uint64_t *)&b_struct[(ip)->jmp.b.offset]; \
143497b8278aSCristian Dumitrescu uint64_t b64 = *b64_ptr; \
143597b8278aSCristian Dumitrescu uint64_t b64_mask = UINT64_MAX >> (64 - (ip)->jmp.b.n_bits); \
143697b8278aSCristian Dumitrescu uint64_t b = b64 & b64_mask; \
143797b8278aSCristian Dumitrescu \
143897b8278aSCristian Dumitrescu (thread)->ip = (a operator b) ? (ip)->jmp.ip : ((thread)->ip + 1); \
143997b8278aSCristian Dumitrescu }
144097b8278aSCristian Dumitrescu
144197b8278aSCristian Dumitrescu #define JMP_CMP_HH(thread, ip, operator) \
144297b8278aSCristian Dumitrescu { \
144397b8278aSCristian Dumitrescu uint8_t *a_struct = (thread)->structs[(ip)->jmp.a.struct_id]; \
144497b8278aSCristian Dumitrescu uint64_t *a64_ptr = (uint64_t *)&a_struct[(ip)->jmp.a.offset]; \
144597b8278aSCristian Dumitrescu uint64_t a64 = *a64_ptr; \
144697b8278aSCristian Dumitrescu uint64_t a = ntoh64(a64) >> (64 - (ip)->jmp.a.n_bits); \
144797b8278aSCristian Dumitrescu \
144897b8278aSCristian Dumitrescu uint8_t *b_struct = (thread)->structs[(ip)->jmp.b.struct_id]; \
144997b8278aSCristian Dumitrescu uint64_t *b64_ptr = (uint64_t *)&b_struct[(ip)->jmp.b.offset]; \
145097b8278aSCristian Dumitrescu uint64_t b64 = *b64_ptr; \
145197b8278aSCristian Dumitrescu uint64_t b = ntoh64(b64) >> (64 - (ip)->jmp.b.n_bits); \
145297b8278aSCristian Dumitrescu \
145397b8278aSCristian Dumitrescu (thread)->ip = (a operator b) ? (ip)->jmp.ip : ((thread)->ip + 1); \
145497b8278aSCristian Dumitrescu }
145597b8278aSCristian Dumitrescu
145697b8278aSCristian Dumitrescu #define JMP_CMP_HH_FAST(thread, ip, operator) \
145797b8278aSCristian Dumitrescu { \
145897b8278aSCristian Dumitrescu uint8_t *a_struct = (thread)->structs[(ip)->jmp.a.struct_id]; \
145997b8278aSCristian Dumitrescu uint64_t *a64_ptr = (uint64_t *)&a_struct[(ip)->jmp.a.offset]; \
146097b8278aSCristian Dumitrescu uint64_t a64 = *a64_ptr; \
146197b8278aSCristian Dumitrescu uint64_t a = a64 << (64 - (ip)->jmp.a.n_bits); \
146297b8278aSCristian Dumitrescu \
146397b8278aSCristian Dumitrescu uint8_t *b_struct = (thread)->structs[(ip)->jmp.b.struct_id]; \
146497b8278aSCristian Dumitrescu uint64_t *b64_ptr = (uint64_t *)&b_struct[(ip)->jmp.b.offset]; \
146597b8278aSCristian Dumitrescu uint64_t b64 = *b64_ptr; \
146697b8278aSCristian Dumitrescu uint64_t b = b64 << (64 - (ip)->jmp.b.n_bits); \
146797b8278aSCristian Dumitrescu \
146897b8278aSCristian Dumitrescu (thread)->ip = (a operator b) ? (ip)->jmp.ip : ((thread)->ip + 1); \
146997b8278aSCristian Dumitrescu }
147097b8278aSCristian Dumitrescu
147197b8278aSCristian Dumitrescu #else
147297b8278aSCristian Dumitrescu
147397b8278aSCristian Dumitrescu #define JMP_CMP_MH JMP_CMP
147497b8278aSCristian Dumitrescu #define JMP_CMP_HM JMP_CMP
147597b8278aSCristian Dumitrescu #define JMP_CMP_HH JMP_CMP
147697b8278aSCristian Dumitrescu #define JMP_CMP_HH_FAST JMP_CMP
147797b8278aSCristian Dumitrescu
147897b8278aSCristian Dumitrescu #endif
147997b8278aSCristian Dumitrescu
148097b8278aSCristian Dumitrescu #define JMP_CMP_I(thread, ip, operator) \
148197b8278aSCristian Dumitrescu { \
148297b8278aSCristian Dumitrescu uint8_t *a_struct = (thread)->structs[(ip)->jmp.a.struct_id]; \
148397b8278aSCristian Dumitrescu uint64_t *a64_ptr = (uint64_t *)&a_struct[(ip)->jmp.a.offset]; \
148497b8278aSCristian Dumitrescu uint64_t a64 = *a64_ptr; \
148597b8278aSCristian Dumitrescu uint64_t a64_mask = UINT64_MAX >> (64 - (ip)->jmp.a.n_bits); \
148697b8278aSCristian Dumitrescu uint64_t a = a64 & a64_mask; \
148797b8278aSCristian Dumitrescu \
148897b8278aSCristian Dumitrescu uint64_t b = (ip)->jmp.b_val; \
148997b8278aSCristian Dumitrescu \
149097b8278aSCristian Dumitrescu (thread)->ip = (a operator b) ? (ip)->jmp.ip : ((thread)->ip + 1); \
149197b8278aSCristian Dumitrescu }
149297b8278aSCristian Dumitrescu
149397b8278aSCristian Dumitrescu #define JMP_CMP_MI JMP_CMP_I
149497b8278aSCristian Dumitrescu
149597b8278aSCristian Dumitrescu #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
149697b8278aSCristian Dumitrescu
149797b8278aSCristian Dumitrescu #define JMP_CMP_HI(thread, ip, operator) \
149897b8278aSCristian Dumitrescu { \
149997b8278aSCristian Dumitrescu uint8_t *a_struct = (thread)->structs[(ip)->jmp.a.struct_id]; \
150097b8278aSCristian Dumitrescu uint64_t *a64_ptr = (uint64_t *)&a_struct[(ip)->jmp.a.offset]; \
150197b8278aSCristian Dumitrescu uint64_t a64 = *a64_ptr; \
150297b8278aSCristian Dumitrescu uint64_t a = ntoh64(a64) >> (64 - (ip)->jmp.a.n_bits); \
150397b8278aSCristian Dumitrescu \
150497b8278aSCristian Dumitrescu uint64_t b = (ip)->jmp.b_val; \
150597b8278aSCristian Dumitrescu \
150697b8278aSCristian Dumitrescu (thread)->ip = (a operator b) ? (ip)->jmp.ip : ((thread)->ip + 1); \
150797b8278aSCristian Dumitrescu }
150897b8278aSCristian Dumitrescu
150997b8278aSCristian Dumitrescu #else
151097b8278aSCristian Dumitrescu
151197b8278aSCristian Dumitrescu #define JMP_CMP_HI JMP_CMP_I
151297b8278aSCristian Dumitrescu
151397b8278aSCristian Dumitrescu #endif
151497b8278aSCristian Dumitrescu
151597b8278aSCristian Dumitrescu #define METADATA_READ(thread, offset, n_bits) \
151693998f3cSTyler Retzlaff __extension__ ({ \
151797b8278aSCristian Dumitrescu uint64_t *m64_ptr = (uint64_t *)&(thread)->metadata[offset]; \
151897b8278aSCristian Dumitrescu uint64_t m64 = *m64_ptr; \
151997b8278aSCristian Dumitrescu uint64_t m64_mask = UINT64_MAX >> (64 - (n_bits)); \
152097b8278aSCristian Dumitrescu (m64 & m64_mask); \
152197b8278aSCristian Dumitrescu })
152297b8278aSCristian Dumitrescu
152397b8278aSCristian Dumitrescu #define METADATA_WRITE(thread, offset, n_bits, value) \
152497b8278aSCristian Dumitrescu { \
152597b8278aSCristian Dumitrescu uint64_t *m64_ptr = (uint64_t *)&(thread)->metadata[offset]; \
152697b8278aSCristian Dumitrescu uint64_t m64 = *m64_ptr; \
152797b8278aSCristian Dumitrescu uint64_t m64_mask = UINT64_MAX >> (64 - (n_bits)); \
152897b8278aSCristian Dumitrescu \
152997b8278aSCristian Dumitrescu uint64_t m_new = value; \
153097b8278aSCristian Dumitrescu \
153197b8278aSCristian Dumitrescu *m64_ptr = (m64 & ~m64_mask) | (m_new & m64_mask); \
153297b8278aSCristian Dumitrescu }
153397b8278aSCristian Dumitrescu
153497b8278aSCristian Dumitrescu #ifndef RTE_SWX_PIPELINE_THREADS_MAX
153597b8278aSCristian Dumitrescu #define RTE_SWX_PIPELINE_THREADS_MAX 16
153697b8278aSCristian Dumitrescu #endif
153797b8278aSCristian Dumitrescu
1538dfa9491aSCristian Dumitrescu #ifndef RTE_SWX_PIPELINE_INSTRUCTION_TABLE_SIZE_MAX
15393d60499aSHarshad Narayane #define RTE_SWX_PIPELINE_INSTRUCTION_TABLE_SIZE_MAX 1024
1540dfa9491aSCristian Dumitrescu #endif
1541dfa9491aSCristian Dumitrescu
154297b8278aSCristian Dumitrescu struct rte_swx_pipeline {
1543d69c90c8SCristian Dumitrescu char name[RTE_SWX_NAME_SIZE];
1544d69c90c8SCristian Dumitrescu
154597b8278aSCristian Dumitrescu struct struct_type_tailq struct_types;
154697b8278aSCristian Dumitrescu struct port_in_type_tailq port_in_types;
154797b8278aSCristian Dumitrescu struct port_in_tailq ports_in;
154897b8278aSCristian Dumitrescu struct port_out_type_tailq port_out_types;
154997b8278aSCristian Dumitrescu struct port_out_tailq ports_out;
155097b8278aSCristian Dumitrescu struct extern_type_tailq extern_types;
155197b8278aSCristian Dumitrescu struct extern_obj_tailq extern_objs;
155297b8278aSCristian Dumitrescu struct extern_func_tailq extern_funcs;
155392f2944dSCristian Dumitrescu struct hash_func_tailq hash_funcs;
15548ba342ceSCristian Dumitrescu struct rss_tailq rss;
155597b8278aSCristian Dumitrescu struct header_tailq headers;
155697b8278aSCristian Dumitrescu struct struct_type *metadata_st;
155797b8278aSCristian Dumitrescu uint32_t metadata_struct_id;
155897b8278aSCristian Dumitrescu struct action_tailq actions;
155997b8278aSCristian Dumitrescu struct table_type_tailq table_types;
156097b8278aSCristian Dumitrescu struct table_tailq tables;
156197b8278aSCristian Dumitrescu struct selector_tailq selectors;
156297b8278aSCristian Dumitrescu struct learner_tailq learners;
156397b8278aSCristian Dumitrescu struct regarray_tailq regarrays;
156497b8278aSCristian Dumitrescu struct meter_profile_tailq meter_profiles;
156597b8278aSCristian Dumitrescu struct metarray_tailq metarrays;
156697b8278aSCristian Dumitrescu
156797b8278aSCristian Dumitrescu struct port_in_runtime *in;
156897b8278aSCristian Dumitrescu struct port_out_runtime *out;
1569dac0ecd9SCristian Dumitrescu struct mirroring_session *mirroring_sessions;
157097b8278aSCristian Dumitrescu struct instruction **action_instructions;
15715dc6a5f2SCristian Dumitrescu action_func_t *action_funcs;
157297b8278aSCristian Dumitrescu struct rte_swx_table_state *table_state;
157397b8278aSCristian Dumitrescu struct table_statistics *table_stats;
157497b8278aSCristian Dumitrescu struct selector_statistics *selector_stats;
157597b8278aSCristian Dumitrescu struct learner_statistics *learner_stats;
157692f2944dSCristian Dumitrescu struct hash_func_runtime *hash_func_runtime;
15778ba342ceSCristian Dumitrescu struct rss_runtime **rss_runtime;
157897b8278aSCristian Dumitrescu struct regarray_runtime *regarray_runtime;
157997b8278aSCristian Dumitrescu struct metarray_runtime *metarray_runtime;
158097b8278aSCristian Dumitrescu struct instruction *instructions;
15814bd025dcSCristian Dumitrescu struct instruction_data *instruction_data;
1582dfa9491aSCristian Dumitrescu instr_exec_t *instruction_table;
158397b8278aSCristian Dumitrescu struct thread threads[RTE_SWX_PIPELINE_THREADS_MAX];
1584f898a475SCristian Dumitrescu void *lib;
158597b8278aSCristian Dumitrescu
158697b8278aSCristian Dumitrescu uint32_t n_structs;
158797b8278aSCristian Dumitrescu uint32_t n_ports_in;
158897b8278aSCristian Dumitrescu uint32_t n_ports_out;
1589dac0ecd9SCristian Dumitrescu uint32_t n_mirroring_slots;
1590dac0ecd9SCristian Dumitrescu uint32_t n_mirroring_sessions;
159197b8278aSCristian Dumitrescu uint32_t n_extern_objs;
159297b8278aSCristian Dumitrescu uint32_t n_extern_funcs;
159392f2944dSCristian Dumitrescu uint32_t n_hash_funcs;
15948ba342ceSCristian Dumitrescu uint32_t n_rss;
159597b8278aSCristian Dumitrescu uint32_t n_actions;
159697b8278aSCristian Dumitrescu uint32_t n_tables;
159797b8278aSCristian Dumitrescu uint32_t n_selectors;
159897b8278aSCristian Dumitrescu uint32_t n_learners;
159997b8278aSCristian Dumitrescu uint32_t n_regarrays;
160097b8278aSCristian Dumitrescu uint32_t n_metarrays;
160197b8278aSCristian Dumitrescu uint32_t n_headers;
160297b8278aSCristian Dumitrescu uint32_t thread_id;
160397b8278aSCristian Dumitrescu uint32_t port_id;
160497b8278aSCristian Dumitrescu uint32_t n_instructions;
160597b8278aSCristian Dumitrescu int build_done;
160697b8278aSCristian Dumitrescu int numa_node;
160797b8278aSCristian Dumitrescu };
160897b8278aSCristian Dumitrescu
1609c693add3SCristian Dumitrescu /*
1610c693add3SCristian Dumitrescu * Instruction.
1611c693add3SCristian Dumitrescu */
1612c693add3SCristian Dumitrescu static inline void
pipeline_port_inc(struct rte_swx_pipeline * p)1613c693add3SCristian Dumitrescu pipeline_port_inc(struct rte_swx_pipeline *p)
1614c693add3SCristian Dumitrescu {
1615c66dfe7aSCristian Dumitrescu uint32_t port_id = p->port_id;
1616c66dfe7aSCristian Dumitrescu
1617c66dfe7aSCristian Dumitrescu port_id++;
1618c66dfe7aSCristian Dumitrescu if (port_id == p->n_ports_in)
1619c66dfe7aSCristian Dumitrescu port_id = 0;
1620c66dfe7aSCristian Dumitrescu
1621c66dfe7aSCristian Dumitrescu p->port_id = port_id;
1622c693add3SCristian Dumitrescu }
1623c693add3SCristian Dumitrescu
1624c693add3SCristian Dumitrescu static inline void
thread_ip_reset(struct rte_swx_pipeline * p,struct thread * t)1625c693add3SCristian Dumitrescu thread_ip_reset(struct rte_swx_pipeline *p, struct thread *t)
1626c693add3SCristian Dumitrescu {
1627c693add3SCristian Dumitrescu t->ip = p->instructions;
1628c693add3SCristian Dumitrescu }
1629c693add3SCristian Dumitrescu
1630c693add3SCristian Dumitrescu static inline void
thread_ip_set(struct thread * t,struct instruction * ip)1631c693add3SCristian Dumitrescu thread_ip_set(struct thread *t, struct instruction *ip)
1632c693add3SCristian Dumitrescu {
1633c693add3SCristian Dumitrescu t->ip = ip;
1634c693add3SCristian Dumitrescu }
1635c693add3SCristian Dumitrescu
1636c693add3SCristian Dumitrescu static inline void
thread_ip_action_call(struct rte_swx_pipeline * p,struct thread * t,uint32_t action_id)1637c693add3SCristian Dumitrescu thread_ip_action_call(struct rte_swx_pipeline *p,
1638c693add3SCristian Dumitrescu struct thread *t,
1639c693add3SCristian Dumitrescu uint32_t action_id)
1640c693add3SCristian Dumitrescu {
1641c693add3SCristian Dumitrescu t->ret = t->ip + 1;
1642c693add3SCristian Dumitrescu t->ip = p->action_instructions[action_id];
1643c693add3SCristian Dumitrescu }
1644c693add3SCristian Dumitrescu
1645c693add3SCristian Dumitrescu static inline void
1646c693add3SCristian Dumitrescu thread_ip_inc(struct rte_swx_pipeline *p);
1647c693add3SCristian Dumitrescu
1648c693add3SCristian Dumitrescu static inline void
thread_ip_inc(struct rte_swx_pipeline * p)1649c693add3SCristian Dumitrescu thread_ip_inc(struct rte_swx_pipeline *p)
1650c693add3SCristian Dumitrescu {
1651c693add3SCristian Dumitrescu struct thread *t = &p->threads[p->thread_id];
1652c693add3SCristian Dumitrescu
1653c693add3SCristian Dumitrescu t->ip++;
1654c693add3SCristian Dumitrescu }
1655c693add3SCristian Dumitrescu
1656c693add3SCristian Dumitrescu static inline void
thread_ip_inc_cond(struct thread * t,int cond)1657c693add3SCristian Dumitrescu thread_ip_inc_cond(struct thread *t, int cond)
1658c693add3SCristian Dumitrescu {
1659c693add3SCristian Dumitrescu t->ip += cond;
1660c693add3SCristian Dumitrescu }
1661c693add3SCristian Dumitrescu
1662c693add3SCristian Dumitrescu static inline void
thread_yield(struct rte_swx_pipeline * p)1663c693add3SCristian Dumitrescu thread_yield(struct rte_swx_pipeline *p)
1664c693add3SCristian Dumitrescu {
1665c693add3SCristian Dumitrescu p->thread_id = (p->thread_id + 1) & (RTE_SWX_PIPELINE_THREADS_MAX - 1);
1666c693add3SCristian Dumitrescu }
1667c693add3SCristian Dumitrescu
1668c693add3SCristian Dumitrescu static inline void
thread_yield_cond(struct rte_swx_pipeline * p,int cond)1669c693add3SCristian Dumitrescu thread_yield_cond(struct rte_swx_pipeline *p, int cond)
1670c693add3SCristian Dumitrescu {
1671c693add3SCristian Dumitrescu p->thread_id = (p->thread_id + cond) & (RTE_SWX_PIPELINE_THREADS_MAX - 1);
1672c693add3SCristian Dumitrescu }
1673c693add3SCristian Dumitrescu
1674101d7f09SCristian Dumitrescu /*
1675101d7f09SCristian Dumitrescu * rx.
1676101d7f09SCristian Dumitrescu */
1677101d7f09SCristian Dumitrescu static inline int
__instr_rx_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)1678101d7f09SCristian Dumitrescu __instr_rx_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
1679101d7f09SCristian Dumitrescu {
1680101d7f09SCristian Dumitrescu struct port_in_runtime *port = &p->in[p->port_id];
1681101d7f09SCristian Dumitrescu struct rte_swx_pkt *pkt = &t->pkt;
1682101d7f09SCristian Dumitrescu int pkt_received;
1683101d7f09SCristian Dumitrescu
16845ec76d29SCristian Dumitrescu /* Recirculation: keep the current packet. */
16855ec76d29SCristian Dumitrescu if (t->recirculate) {
16865ec76d29SCristian Dumitrescu TRACE("[Thread %2u] rx - recirculate (pass %u)\n",
16875ec76d29SCristian Dumitrescu p->thread_id,
16885ec76d29SCristian Dumitrescu t->recirc_pass_id + 1);
16895ec76d29SCristian Dumitrescu
16905ec76d29SCristian Dumitrescu /* Packet. */
16915ec76d29SCristian Dumitrescu t->ptr = &pkt->pkt[pkt->offset];
16925ec76d29SCristian Dumitrescu t->mirroring_slots_mask = 0;
16935ec76d29SCristian Dumitrescu t->recirculate = 0;
16945ec76d29SCristian Dumitrescu t->recirc_pass_id++;
16955ec76d29SCristian Dumitrescu
16965ec76d29SCristian Dumitrescu /* Headers. */
16975ec76d29SCristian Dumitrescu t->valid_headers = 0;
16985ec76d29SCristian Dumitrescu t->n_headers_out = 0;
16995ec76d29SCristian Dumitrescu
17005ec76d29SCristian Dumitrescu /* Tables. */
17015ec76d29SCristian Dumitrescu t->table_state = p->table_state;
17025ec76d29SCristian Dumitrescu
17035ec76d29SCristian Dumitrescu return 1;
17045ec76d29SCristian Dumitrescu }
17055ec76d29SCristian Dumitrescu
1706101d7f09SCristian Dumitrescu /* Packet. */
1707101d7f09SCristian Dumitrescu pkt_received = port->pkt_rx(port->obj, pkt);
1708101d7f09SCristian Dumitrescu t->ptr = &pkt->pkt[pkt->offset];
1709101d7f09SCristian Dumitrescu rte_prefetch0(t->ptr);
1710101d7f09SCristian Dumitrescu
1711101d7f09SCristian Dumitrescu TRACE("[Thread %2u] rx %s from port %u\n",
1712101d7f09SCristian Dumitrescu p->thread_id,
1713101d7f09SCristian Dumitrescu pkt_received ? "1 pkt" : "0 pkts",
1714101d7f09SCristian Dumitrescu p->port_id);
1715101d7f09SCristian Dumitrescu
1716dac0ecd9SCristian Dumitrescu t->mirroring_slots_mask = 0;
17175ec76d29SCristian Dumitrescu t->recirc_pass_id = 0;
1718dac0ecd9SCristian Dumitrescu
1719101d7f09SCristian Dumitrescu /* Headers. */
1720101d7f09SCristian Dumitrescu t->valid_headers = 0;
1721101d7f09SCristian Dumitrescu t->n_headers_out = 0;
1722101d7f09SCristian Dumitrescu
1723101d7f09SCristian Dumitrescu /* Meta-data. */
1724101d7f09SCristian Dumitrescu METADATA_WRITE(t, ip->io.io.offset, ip->io.io.n_bits, p->port_id);
1725101d7f09SCristian Dumitrescu
1726101d7f09SCristian Dumitrescu /* Tables. */
1727101d7f09SCristian Dumitrescu t->table_state = p->table_state;
1728101d7f09SCristian Dumitrescu
1729101d7f09SCristian Dumitrescu /* Thread. */
1730101d7f09SCristian Dumitrescu pipeline_port_inc(p);
1731101d7f09SCristian Dumitrescu
1732101d7f09SCristian Dumitrescu return pkt_received;
1733101d7f09SCristian Dumitrescu }
1734101d7f09SCristian Dumitrescu
1735101d7f09SCristian Dumitrescu static inline void
instr_rx_exec(struct rte_swx_pipeline * p)1736101d7f09SCristian Dumitrescu instr_rx_exec(struct rte_swx_pipeline *p)
1737101d7f09SCristian Dumitrescu {
1738101d7f09SCristian Dumitrescu struct thread *t = &p->threads[p->thread_id];
1739101d7f09SCristian Dumitrescu struct instruction *ip = t->ip;
1740101d7f09SCristian Dumitrescu int pkt_received;
1741101d7f09SCristian Dumitrescu
1742101d7f09SCristian Dumitrescu /* Packet. */
1743101d7f09SCristian Dumitrescu pkt_received = __instr_rx_exec(p, t, ip);
1744101d7f09SCristian Dumitrescu
1745101d7f09SCristian Dumitrescu /* Thread. */
1746101d7f09SCristian Dumitrescu thread_ip_inc_cond(t, pkt_received);
1747101d7f09SCristian Dumitrescu thread_yield(p);
1748101d7f09SCristian Dumitrescu }
1749101d7f09SCristian Dumitrescu
1750fcb03ae0SCristian Dumitrescu /*
1751fcb03ae0SCristian Dumitrescu * tx.
1752fcb03ae0SCristian Dumitrescu */
1753fcb03ae0SCristian Dumitrescu static inline void
emit_handler(struct thread * t)1754fcb03ae0SCristian Dumitrescu emit_handler(struct thread *t)
1755fcb03ae0SCristian Dumitrescu {
1756fcb03ae0SCristian Dumitrescu struct header_out_runtime *h0 = &t->headers_out[0];
1757fcb03ae0SCristian Dumitrescu struct header_out_runtime *h1 = &t->headers_out[1];
1758fcb03ae0SCristian Dumitrescu uint32_t offset = 0, i;
1759fcb03ae0SCristian Dumitrescu
1760fcb03ae0SCristian Dumitrescu /* No header change or header decapsulation. */
1761fcb03ae0SCristian Dumitrescu if ((t->n_headers_out == 1) &&
1762fcb03ae0SCristian Dumitrescu (h0->ptr + h0->n_bytes == t->ptr)) {
1763fcb03ae0SCristian Dumitrescu TRACE("Emit handler: no header change or header decap.\n");
1764fcb03ae0SCristian Dumitrescu
1765fcb03ae0SCristian Dumitrescu t->pkt.offset -= h0->n_bytes;
1766fcb03ae0SCristian Dumitrescu t->pkt.length += h0->n_bytes;
1767fcb03ae0SCristian Dumitrescu
1768fcb03ae0SCristian Dumitrescu return;
1769fcb03ae0SCristian Dumitrescu }
1770fcb03ae0SCristian Dumitrescu
17717be78d02SJosh Soref /* Header encapsulation (optionally, with prior header decapsulation). */
1772fcb03ae0SCristian Dumitrescu if ((t->n_headers_out == 2) &&
1773fcb03ae0SCristian Dumitrescu (h1->ptr + h1->n_bytes == t->ptr) &&
1774fcb03ae0SCristian Dumitrescu (h0->ptr == h0->ptr0)) {
1775fcb03ae0SCristian Dumitrescu uint32_t offset;
1776fcb03ae0SCristian Dumitrescu
1777fcb03ae0SCristian Dumitrescu TRACE("Emit handler: header encapsulation.\n");
1778fcb03ae0SCristian Dumitrescu
1779fcb03ae0SCristian Dumitrescu offset = h0->n_bytes + h1->n_bytes;
1780fcb03ae0SCristian Dumitrescu memcpy(t->ptr - offset, h0->ptr, h0->n_bytes);
1781fcb03ae0SCristian Dumitrescu t->pkt.offset -= offset;
1782fcb03ae0SCristian Dumitrescu t->pkt.length += offset;
1783fcb03ae0SCristian Dumitrescu
1784fcb03ae0SCristian Dumitrescu return;
1785fcb03ae0SCristian Dumitrescu }
1786fcb03ae0SCristian Dumitrescu
1787fcb03ae0SCristian Dumitrescu /* For any other case. */
1788fcb03ae0SCristian Dumitrescu TRACE("Emit handler: complex case.\n");
1789fcb03ae0SCristian Dumitrescu
1790fcb03ae0SCristian Dumitrescu for (i = 0; i < t->n_headers_out; i++) {
1791fcb03ae0SCristian Dumitrescu struct header_out_runtime *h = &t->headers_out[i];
1792fcb03ae0SCristian Dumitrescu
1793fcb03ae0SCristian Dumitrescu memcpy(&t->header_out_storage[offset], h->ptr, h->n_bytes);
1794fcb03ae0SCristian Dumitrescu offset += h->n_bytes;
1795fcb03ae0SCristian Dumitrescu }
1796fcb03ae0SCristian Dumitrescu
1797fcb03ae0SCristian Dumitrescu if (offset) {
1798fcb03ae0SCristian Dumitrescu memcpy(t->ptr - offset, t->header_out_storage, offset);
1799fcb03ae0SCristian Dumitrescu t->pkt.offset -= offset;
1800fcb03ae0SCristian Dumitrescu t->pkt.length += offset;
1801fcb03ae0SCristian Dumitrescu }
1802fcb03ae0SCristian Dumitrescu }
1803fcb03ae0SCristian Dumitrescu
1804fcb03ae0SCristian Dumitrescu static inline void
mirroring_handler(struct rte_swx_pipeline * p,struct thread * t,struct rte_swx_pkt * pkt)1805dac0ecd9SCristian Dumitrescu mirroring_handler(struct rte_swx_pipeline *p, struct thread *t, struct rte_swx_pkt *pkt)
1806dac0ecd9SCristian Dumitrescu {
1807dac0ecd9SCristian Dumitrescu uint64_t slots_mask = t->mirroring_slots_mask, slot_mask;
1808dac0ecd9SCristian Dumitrescu uint32_t slot_id;
1809dac0ecd9SCristian Dumitrescu
1810dac0ecd9SCristian Dumitrescu for (slot_id = 0, slot_mask = 1LLU ; slots_mask; slot_id++, slot_mask <<= 1)
1811dac0ecd9SCristian Dumitrescu if (slot_mask & slots_mask) {
1812dac0ecd9SCristian Dumitrescu struct port_out_runtime *port;
1813dac0ecd9SCristian Dumitrescu struct mirroring_session *session;
1814dac0ecd9SCristian Dumitrescu uint32_t port_id, session_id;
1815dac0ecd9SCristian Dumitrescu
1816dac0ecd9SCristian Dumitrescu session_id = t->mirroring_slots[slot_id];
1817dac0ecd9SCristian Dumitrescu session = &p->mirroring_sessions[session_id];
1818dac0ecd9SCristian Dumitrescu
1819dac0ecd9SCristian Dumitrescu port_id = session->port_id;
1820dac0ecd9SCristian Dumitrescu port = &p->out[port_id];
1821dac0ecd9SCristian Dumitrescu
1822dac0ecd9SCristian Dumitrescu if (session->fast_clone)
1823dac0ecd9SCristian Dumitrescu port->pkt_fast_clone_tx(port->obj, pkt);
1824dac0ecd9SCristian Dumitrescu else
1825dac0ecd9SCristian Dumitrescu port->pkt_clone_tx(port->obj, pkt, session->truncation_length);
1826dac0ecd9SCristian Dumitrescu
1827dac0ecd9SCristian Dumitrescu slots_mask &= ~slot_mask;
1828dac0ecd9SCristian Dumitrescu }
1829dac0ecd9SCristian Dumitrescu }
1830dac0ecd9SCristian Dumitrescu
1831dac0ecd9SCristian Dumitrescu static inline void
__instr_tx_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)1832fcb03ae0SCristian Dumitrescu __instr_tx_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
1833fcb03ae0SCristian Dumitrescu {
1834fcb03ae0SCristian Dumitrescu struct rte_swx_pkt *pkt = &t->pkt;
1835c66dfe7aSCristian Dumitrescu struct port_out_runtime *port;
1836c66dfe7aSCristian Dumitrescu uint64_t port_id;
1837fcb03ae0SCristian Dumitrescu
18385ec76d29SCristian Dumitrescu /* Recirculation: keep the current packet. */
18395ec76d29SCristian Dumitrescu if (t->recirculate) {
18405ec76d29SCristian Dumitrescu TRACE("[Thread %2u]: tx 1 pkt - recirculate\n",
18415ec76d29SCristian Dumitrescu p->thread_id);
18425ec76d29SCristian Dumitrescu
18435ec76d29SCristian Dumitrescu /* Headers. */
18445ec76d29SCristian Dumitrescu emit_handler(t);
18455ec76d29SCristian Dumitrescu
18465ec76d29SCristian Dumitrescu /* Packet. */
18475ec76d29SCristian Dumitrescu mirroring_handler(p, t, pkt);
18485ec76d29SCristian Dumitrescu
18495ec76d29SCristian Dumitrescu return;
18505ec76d29SCristian Dumitrescu }
18515ec76d29SCristian Dumitrescu
1852c66dfe7aSCristian Dumitrescu /* If the output port ID is invalid, then set it to the drop output port that has been set
1853c66dfe7aSCristian Dumitrescu * up internally by the pipeline for this purpose.
1854c66dfe7aSCristian Dumitrescu */
1855c66dfe7aSCristian Dumitrescu port_id = METADATA_READ(t, ip->io.io.offset, ip->io.io.n_bits);
1856c66dfe7aSCristian Dumitrescu if (port_id >= p->n_ports_out)
1857c66dfe7aSCristian Dumitrescu port_id = p->n_ports_out - 1;
1858c66dfe7aSCristian Dumitrescu
1859c66dfe7aSCristian Dumitrescu port = &p->out[port_id];
1860c66dfe7aSCristian Dumitrescu
1861fcb03ae0SCristian Dumitrescu TRACE("[Thread %2u]: tx 1 pkt to port %u\n",
1862fcb03ae0SCristian Dumitrescu p->thread_id,
1863fcb03ae0SCristian Dumitrescu (uint32_t)port_id);
1864fcb03ae0SCristian Dumitrescu
1865fcb03ae0SCristian Dumitrescu /* Headers. */
1866fcb03ae0SCristian Dumitrescu emit_handler(t);
1867fcb03ae0SCristian Dumitrescu
1868fcb03ae0SCristian Dumitrescu /* Packet. */
1869dac0ecd9SCristian Dumitrescu mirroring_handler(p, t, pkt);
1870fcb03ae0SCristian Dumitrescu port->pkt_tx(port->obj, pkt);
1871fcb03ae0SCristian Dumitrescu }
1872fcb03ae0SCristian Dumitrescu
1873fcb03ae0SCristian Dumitrescu static inline void
__instr_tx_i_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)1874fcb03ae0SCristian Dumitrescu __instr_tx_i_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
1875fcb03ae0SCristian Dumitrescu {
1876fcb03ae0SCristian Dumitrescu struct rte_swx_pkt *pkt = &t->pkt;
1877c66dfe7aSCristian Dumitrescu struct port_out_runtime *port;
1878c66dfe7aSCristian Dumitrescu uint64_t port_id;
1879fcb03ae0SCristian Dumitrescu
18805ec76d29SCristian Dumitrescu /* Recirculation: keep the current packet. */
18815ec76d29SCristian Dumitrescu if (t->recirculate) {
18825ec76d29SCristian Dumitrescu TRACE("[Thread %2u]: tx (i) 1 pkt - recirculate\n",
18835ec76d29SCristian Dumitrescu p->thread_id);
18845ec76d29SCristian Dumitrescu
18855ec76d29SCristian Dumitrescu /* Headers. */
18865ec76d29SCristian Dumitrescu emit_handler(t);
18875ec76d29SCristian Dumitrescu
18885ec76d29SCristian Dumitrescu /* Packet. */
18895ec76d29SCristian Dumitrescu mirroring_handler(p, t, pkt);
18905ec76d29SCristian Dumitrescu
18915ec76d29SCristian Dumitrescu return;
18925ec76d29SCristian Dumitrescu }
18935ec76d29SCristian Dumitrescu
1894c66dfe7aSCristian Dumitrescu /* If the output port ID is invalid, then set it to the drop output port that has been set
1895c66dfe7aSCristian Dumitrescu * up internally by the pipeline for this purpose.
1896c66dfe7aSCristian Dumitrescu *
1897c66dfe7aSCristian Dumitrescu * This test cannot be done earlier at instruction translation time, even though the output
1898c66dfe7aSCristian Dumitrescu * port ID is an immediate value, as the number of output ports is only known later at the
1899c66dfe7aSCristian Dumitrescu * pipeline build time.
1900c66dfe7aSCristian Dumitrescu */
1901c66dfe7aSCristian Dumitrescu port_id = ip->io.io.val;
1902c66dfe7aSCristian Dumitrescu if (port_id >= p->n_ports_out)
1903c66dfe7aSCristian Dumitrescu port_id = p->n_ports_out - 1;
1904c66dfe7aSCristian Dumitrescu
1905c66dfe7aSCristian Dumitrescu port = &p->out[port_id];
1906c66dfe7aSCristian Dumitrescu
1907fcb03ae0SCristian Dumitrescu TRACE("[Thread %2u]: tx (i) 1 pkt to port %u\n",
1908fcb03ae0SCristian Dumitrescu p->thread_id,
1909fcb03ae0SCristian Dumitrescu (uint32_t)port_id);
1910fcb03ae0SCristian Dumitrescu
1911fcb03ae0SCristian Dumitrescu /* Headers. */
1912fcb03ae0SCristian Dumitrescu emit_handler(t);
1913fcb03ae0SCristian Dumitrescu
1914fcb03ae0SCristian Dumitrescu /* Packet. */
1915dac0ecd9SCristian Dumitrescu mirroring_handler(p, t, pkt);
1916fcb03ae0SCristian Dumitrescu port->pkt_tx(port->obj, pkt);
1917fcb03ae0SCristian Dumitrescu }
1918fcb03ae0SCristian Dumitrescu
1919c07aaa65SCristian Dumitrescu static inline void
__instr_drop_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip __rte_unused)1920c07aaa65SCristian Dumitrescu __instr_drop_exec(struct rte_swx_pipeline *p,
1921c07aaa65SCristian Dumitrescu struct thread *t,
1922c07aaa65SCristian Dumitrescu const struct instruction *ip __rte_unused)
1923c07aaa65SCristian Dumitrescu {
1924c07aaa65SCristian Dumitrescu uint64_t port_id = p->n_ports_out - 1;
1925c07aaa65SCristian Dumitrescu struct port_out_runtime *port = &p->out[port_id];
1926c07aaa65SCristian Dumitrescu struct rte_swx_pkt *pkt = &t->pkt;
1927c07aaa65SCristian Dumitrescu
1928c07aaa65SCristian Dumitrescu TRACE("[Thread %2u]: drop 1 pkt\n",
1929c07aaa65SCristian Dumitrescu p->thread_id);
1930c07aaa65SCristian Dumitrescu
1931c07aaa65SCristian Dumitrescu /* Headers. */
1932c07aaa65SCristian Dumitrescu emit_handler(t);
1933c07aaa65SCristian Dumitrescu
1934c07aaa65SCristian Dumitrescu /* Packet. */
1935dac0ecd9SCristian Dumitrescu mirroring_handler(p, t, pkt);
1936c07aaa65SCristian Dumitrescu port->pkt_tx(port->obj, pkt);
1937c07aaa65SCristian Dumitrescu }
1938c07aaa65SCristian Dumitrescu
1939dac0ecd9SCristian Dumitrescu static inline void
__instr_mirror_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)1940dac0ecd9SCristian Dumitrescu __instr_mirror_exec(struct rte_swx_pipeline *p,
1941dac0ecd9SCristian Dumitrescu struct thread *t,
1942dac0ecd9SCristian Dumitrescu const struct instruction *ip)
1943dac0ecd9SCristian Dumitrescu {
1944dac0ecd9SCristian Dumitrescu uint64_t slot_id = instr_operand_hbo(t, &ip->mirror.dst);
1945dac0ecd9SCristian Dumitrescu uint64_t session_id = instr_operand_hbo(t, &ip->mirror.src);
1946dac0ecd9SCristian Dumitrescu
1947dac0ecd9SCristian Dumitrescu slot_id &= p->n_mirroring_slots - 1;
1948dac0ecd9SCristian Dumitrescu session_id &= p->n_mirroring_sessions - 1;
1949dac0ecd9SCristian Dumitrescu
1950dac0ecd9SCristian Dumitrescu TRACE("[Thread %2u]: mirror pkt (slot = %u, session = %u)\n",
1951dac0ecd9SCristian Dumitrescu p->thread_id,
1952dac0ecd9SCristian Dumitrescu (uint32_t)slot_id,
1953dac0ecd9SCristian Dumitrescu (uint32_t)session_id);
1954dac0ecd9SCristian Dumitrescu
1955dac0ecd9SCristian Dumitrescu t->mirroring_slots[slot_id] = session_id;
1956dac0ecd9SCristian Dumitrescu t->mirroring_slots_mask |= 1LLU << slot_id;
1957dac0ecd9SCristian Dumitrescu }
1958dac0ecd9SCristian Dumitrescu
19595ec76d29SCristian Dumitrescu static inline void
__instr_recirculate_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip __rte_unused)19605ec76d29SCristian Dumitrescu __instr_recirculate_exec(struct rte_swx_pipeline *p __rte_unused,
19615ec76d29SCristian Dumitrescu struct thread *t,
19625ec76d29SCristian Dumitrescu const struct instruction *ip __rte_unused)
19635ec76d29SCristian Dumitrescu {
19645ec76d29SCristian Dumitrescu TRACE("[Thread %2u]: recirculate\n",
19655ec76d29SCristian Dumitrescu p->thread_id);
19665ec76d29SCristian Dumitrescu
19675ec76d29SCristian Dumitrescu t->recirculate = 1;
19685ec76d29SCristian Dumitrescu }
19695ec76d29SCristian Dumitrescu
19705ec76d29SCristian Dumitrescu static inline void
__instr_recircid_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)19715ec76d29SCristian Dumitrescu __instr_recircid_exec(struct rte_swx_pipeline *p __rte_unused,
19725ec76d29SCristian Dumitrescu struct thread *t,
19735ec76d29SCristian Dumitrescu const struct instruction *ip)
19745ec76d29SCristian Dumitrescu {
19755ec76d29SCristian Dumitrescu TRACE("[Thread %2u]: recircid (pass %u)\n",
19765ec76d29SCristian Dumitrescu p->thread_id,
19775ec76d29SCristian Dumitrescu t->recirc_pass_id);
19785ec76d29SCristian Dumitrescu
19795ec76d29SCristian Dumitrescu /* Meta-data. */
19805ec76d29SCristian Dumitrescu METADATA_WRITE(t, ip->io.io.offset, ip->io.io.n_bits, t->recirc_pass_id);
19815ec76d29SCristian Dumitrescu }
19825ec76d29SCristian Dumitrescu
19832574fd60SCristian Dumitrescu /*
19842574fd60SCristian Dumitrescu * extract.
19852574fd60SCristian Dumitrescu */
19862574fd60SCristian Dumitrescu static inline void
__instr_hdr_extract_many_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip,uint32_t n_extract)19872574fd60SCristian Dumitrescu __instr_hdr_extract_many_exec(struct rte_swx_pipeline *p __rte_unused,
19882574fd60SCristian Dumitrescu struct thread *t,
19892574fd60SCristian Dumitrescu const struct instruction *ip,
19902574fd60SCristian Dumitrescu uint32_t n_extract)
19912574fd60SCristian Dumitrescu {
19922574fd60SCristian Dumitrescu uint64_t valid_headers = t->valid_headers;
19932574fd60SCristian Dumitrescu uint8_t *ptr = t->ptr;
19942574fd60SCristian Dumitrescu uint32_t offset = t->pkt.offset;
19952574fd60SCristian Dumitrescu uint32_t length = t->pkt.length;
19962574fd60SCristian Dumitrescu uint32_t i;
19972574fd60SCristian Dumitrescu
19982574fd60SCristian Dumitrescu for (i = 0; i < n_extract; i++) {
19992574fd60SCristian Dumitrescu uint32_t header_id = ip->io.hdr.header_id[i];
20002574fd60SCristian Dumitrescu uint32_t struct_id = ip->io.hdr.struct_id[i];
20012574fd60SCristian Dumitrescu uint32_t n_bytes = ip->io.hdr.n_bytes[i];
20022574fd60SCristian Dumitrescu
20032574fd60SCristian Dumitrescu TRACE("[Thread %2u]: extract header %u (%u bytes)\n",
20042574fd60SCristian Dumitrescu p->thread_id,
20052574fd60SCristian Dumitrescu header_id,
20062574fd60SCristian Dumitrescu n_bytes);
20072574fd60SCristian Dumitrescu
20082574fd60SCristian Dumitrescu /* Headers. */
20092574fd60SCristian Dumitrescu t->structs[struct_id] = ptr;
20102574fd60SCristian Dumitrescu valid_headers = MASK64_BIT_SET(valid_headers, header_id);
20112574fd60SCristian Dumitrescu
20122574fd60SCristian Dumitrescu /* Packet. */
20132574fd60SCristian Dumitrescu offset += n_bytes;
20142574fd60SCristian Dumitrescu length -= n_bytes;
20152574fd60SCristian Dumitrescu ptr += n_bytes;
20162574fd60SCristian Dumitrescu }
20172574fd60SCristian Dumitrescu
20182574fd60SCristian Dumitrescu /* Headers. */
20192574fd60SCristian Dumitrescu t->valid_headers = valid_headers;
20202574fd60SCristian Dumitrescu
20212574fd60SCristian Dumitrescu /* Packet. */
20222574fd60SCristian Dumitrescu t->pkt.offset = offset;
20232574fd60SCristian Dumitrescu t->pkt.length = length;
20242574fd60SCristian Dumitrescu t->ptr = ptr;
20252574fd60SCristian Dumitrescu }
20262574fd60SCristian Dumitrescu
20272574fd60SCristian Dumitrescu static inline void
__instr_hdr_extract_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)20282574fd60SCristian Dumitrescu __instr_hdr_extract_exec(struct rte_swx_pipeline *p,
20292574fd60SCristian Dumitrescu struct thread *t,
20302574fd60SCristian Dumitrescu const struct instruction *ip)
20312574fd60SCristian Dumitrescu {
20322574fd60SCristian Dumitrescu __instr_hdr_extract_many_exec(p, t, ip, 1);
20332574fd60SCristian Dumitrescu }
20342574fd60SCristian Dumitrescu
20352574fd60SCristian Dumitrescu static inline void
__instr_hdr_extract2_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)20362574fd60SCristian Dumitrescu __instr_hdr_extract2_exec(struct rte_swx_pipeline *p,
20372574fd60SCristian Dumitrescu struct thread *t,
20382574fd60SCristian Dumitrescu const struct instruction *ip)
20392574fd60SCristian Dumitrescu {
20402574fd60SCristian Dumitrescu TRACE("[Thread %2u] *** The next 2 instructions are fused. ***\n", p->thread_id);
20412574fd60SCristian Dumitrescu
20422574fd60SCristian Dumitrescu __instr_hdr_extract_many_exec(p, t, ip, 2);
20432574fd60SCristian Dumitrescu }
20442574fd60SCristian Dumitrescu
20452574fd60SCristian Dumitrescu static inline void
__instr_hdr_extract3_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)20462574fd60SCristian Dumitrescu __instr_hdr_extract3_exec(struct rte_swx_pipeline *p,
20472574fd60SCristian Dumitrescu struct thread *t,
20482574fd60SCristian Dumitrescu const struct instruction *ip)
20492574fd60SCristian Dumitrescu {
20502574fd60SCristian Dumitrescu TRACE("[Thread %2u] *** The next 3 instructions are fused. ***\n", p->thread_id);
20512574fd60SCristian Dumitrescu
20522574fd60SCristian Dumitrescu __instr_hdr_extract_many_exec(p, t, ip, 3);
20532574fd60SCristian Dumitrescu }
20542574fd60SCristian Dumitrescu
20552574fd60SCristian Dumitrescu static inline void
__instr_hdr_extract4_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)20562574fd60SCristian Dumitrescu __instr_hdr_extract4_exec(struct rte_swx_pipeline *p,
20572574fd60SCristian Dumitrescu struct thread *t,
20582574fd60SCristian Dumitrescu const struct instruction *ip)
20592574fd60SCristian Dumitrescu {
20602574fd60SCristian Dumitrescu TRACE("[Thread %2u] *** The next 4 instructions are fused. ***\n", p->thread_id);
20612574fd60SCristian Dumitrescu
20622574fd60SCristian Dumitrescu __instr_hdr_extract_many_exec(p, t, ip, 4);
20632574fd60SCristian Dumitrescu }
20642574fd60SCristian Dumitrescu
20652574fd60SCristian Dumitrescu static inline void
__instr_hdr_extract5_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)20662574fd60SCristian Dumitrescu __instr_hdr_extract5_exec(struct rte_swx_pipeline *p,
20672574fd60SCristian Dumitrescu struct thread *t,
20682574fd60SCristian Dumitrescu const struct instruction *ip)
20692574fd60SCristian Dumitrescu {
20702574fd60SCristian Dumitrescu TRACE("[Thread %2u] *** The next 5 instructions are fused. ***\n", p->thread_id);
20712574fd60SCristian Dumitrescu
20722574fd60SCristian Dumitrescu __instr_hdr_extract_many_exec(p, t, ip, 5);
20732574fd60SCristian Dumitrescu }
20742574fd60SCristian Dumitrescu
20752574fd60SCristian Dumitrescu static inline void
__instr_hdr_extract6_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)20762574fd60SCristian Dumitrescu __instr_hdr_extract6_exec(struct rte_swx_pipeline *p,
20772574fd60SCristian Dumitrescu struct thread *t,
20782574fd60SCristian Dumitrescu const struct instruction *ip)
20792574fd60SCristian Dumitrescu {
20802574fd60SCristian Dumitrescu TRACE("[Thread %2u] *** The next 6 instructions are fused. ***\n", p->thread_id);
20812574fd60SCristian Dumitrescu
20822574fd60SCristian Dumitrescu __instr_hdr_extract_many_exec(p, t, ip, 6);
20832574fd60SCristian Dumitrescu }
20842574fd60SCristian Dumitrescu
20852574fd60SCristian Dumitrescu static inline void
__instr_hdr_extract7_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)20862574fd60SCristian Dumitrescu __instr_hdr_extract7_exec(struct rte_swx_pipeline *p,
20872574fd60SCristian Dumitrescu struct thread *t,
20882574fd60SCristian Dumitrescu const struct instruction *ip)
20892574fd60SCristian Dumitrescu {
20902574fd60SCristian Dumitrescu TRACE("[Thread %2u] *** The next 7 instructions are fused. ***\n", p->thread_id);
20912574fd60SCristian Dumitrescu
20922574fd60SCristian Dumitrescu __instr_hdr_extract_many_exec(p, t, ip, 7);
20932574fd60SCristian Dumitrescu }
20942574fd60SCristian Dumitrescu
20952574fd60SCristian Dumitrescu static inline void
__instr_hdr_extract8_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)20962574fd60SCristian Dumitrescu __instr_hdr_extract8_exec(struct rte_swx_pipeline *p,
20972574fd60SCristian Dumitrescu struct thread *t,
20982574fd60SCristian Dumitrescu const struct instruction *ip)
20992574fd60SCristian Dumitrescu {
21002574fd60SCristian Dumitrescu TRACE("[Thread %2u] *** The next 8 instructions are fused. ***\n", p->thread_id);
21012574fd60SCristian Dumitrescu
21022574fd60SCristian Dumitrescu __instr_hdr_extract_many_exec(p, t, ip, 8);
21032574fd60SCristian Dumitrescu }
21042574fd60SCristian Dumitrescu
21052574fd60SCristian Dumitrescu static inline void
__instr_hdr_extract_m_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)21062574fd60SCristian Dumitrescu __instr_hdr_extract_m_exec(struct rte_swx_pipeline *p __rte_unused,
21072574fd60SCristian Dumitrescu struct thread *t,
21082574fd60SCristian Dumitrescu const struct instruction *ip)
21092574fd60SCristian Dumitrescu {
21102574fd60SCristian Dumitrescu uint64_t valid_headers = t->valid_headers;
21112574fd60SCristian Dumitrescu uint8_t *ptr = t->ptr;
21122574fd60SCristian Dumitrescu uint32_t offset = t->pkt.offset;
21132574fd60SCristian Dumitrescu uint32_t length = t->pkt.length;
21142574fd60SCristian Dumitrescu
21152574fd60SCristian Dumitrescu uint32_t n_bytes_last = METADATA_READ(t, ip->io.io.offset, ip->io.io.n_bits);
21162574fd60SCristian Dumitrescu uint32_t header_id = ip->io.hdr.header_id[0];
21172574fd60SCristian Dumitrescu uint32_t struct_id = ip->io.hdr.struct_id[0];
21182574fd60SCristian Dumitrescu uint32_t n_bytes = ip->io.hdr.n_bytes[0];
21192574fd60SCristian Dumitrescu
21202574fd60SCristian Dumitrescu struct header_runtime *h = &t->headers[header_id];
21212574fd60SCristian Dumitrescu
21222574fd60SCristian Dumitrescu TRACE("[Thread %2u]: extract header %u (%u + %u bytes)\n",
21232574fd60SCristian Dumitrescu p->thread_id,
21242574fd60SCristian Dumitrescu header_id,
21252574fd60SCristian Dumitrescu n_bytes,
21262574fd60SCristian Dumitrescu n_bytes_last);
21272574fd60SCristian Dumitrescu
21282574fd60SCristian Dumitrescu n_bytes += n_bytes_last;
21292574fd60SCristian Dumitrescu
21302574fd60SCristian Dumitrescu /* Headers. */
21312574fd60SCristian Dumitrescu t->structs[struct_id] = ptr;
21322574fd60SCristian Dumitrescu t->valid_headers = MASK64_BIT_SET(valid_headers, header_id);
21332574fd60SCristian Dumitrescu h->n_bytes = n_bytes;
21342574fd60SCristian Dumitrescu
21352574fd60SCristian Dumitrescu /* Packet. */
21362574fd60SCristian Dumitrescu t->pkt.offset = offset + n_bytes;
21372574fd60SCristian Dumitrescu t->pkt.length = length - n_bytes;
21382574fd60SCristian Dumitrescu t->ptr = ptr + n_bytes;
21392574fd60SCristian Dumitrescu }
21402574fd60SCristian Dumitrescu
21412574fd60SCristian Dumitrescu static inline void
__instr_hdr_lookahead_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)21422574fd60SCristian Dumitrescu __instr_hdr_lookahead_exec(struct rte_swx_pipeline *p __rte_unused,
21432574fd60SCristian Dumitrescu struct thread *t,
21442574fd60SCristian Dumitrescu const struct instruction *ip)
21452574fd60SCristian Dumitrescu {
21462574fd60SCristian Dumitrescu uint64_t valid_headers = t->valid_headers;
21472574fd60SCristian Dumitrescu uint8_t *ptr = t->ptr;
21482574fd60SCristian Dumitrescu
21492574fd60SCristian Dumitrescu uint32_t header_id = ip->io.hdr.header_id[0];
21502574fd60SCristian Dumitrescu uint32_t struct_id = ip->io.hdr.struct_id[0];
21512574fd60SCristian Dumitrescu
21522574fd60SCristian Dumitrescu TRACE("[Thread %2u]: lookahead header %u\n",
21532574fd60SCristian Dumitrescu p->thread_id,
21542574fd60SCristian Dumitrescu header_id);
21552574fd60SCristian Dumitrescu
21562574fd60SCristian Dumitrescu /* Headers. */
21572574fd60SCristian Dumitrescu t->structs[struct_id] = ptr;
21582574fd60SCristian Dumitrescu t->valid_headers = MASK64_BIT_SET(valid_headers, header_id);
21592574fd60SCristian Dumitrescu }
21602574fd60SCristian Dumitrescu
2161d60dbdc8SCristian Dumitrescu /*
2162d60dbdc8SCristian Dumitrescu * emit.
2163d60dbdc8SCristian Dumitrescu */
2164d60dbdc8SCristian Dumitrescu static inline void
__instr_hdr_emit_many_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip,uint32_t n_emit)2165d60dbdc8SCristian Dumitrescu __instr_hdr_emit_many_exec(struct rte_swx_pipeline *p __rte_unused,
2166d60dbdc8SCristian Dumitrescu struct thread *t,
2167d60dbdc8SCristian Dumitrescu const struct instruction *ip,
2168d60dbdc8SCristian Dumitrescu uint32_t n_emit)
2169d60dbdc8SCristian Dumitrescu {
2170d60dbdc8SCristian Dumitrescu uint64_t valid_headers = t->valid_headers;
2171d60dbdc8SCristian Dumitrescu uint32_t n_headers_out = t->n_headers_out;
2172775be5b5SCristian Dumitrescu struct header_out_runtime *ho = NULL;
2173d60dbdc8SCristian Dumitrescu uint8_t *ho_ptr = NULL;
2174775be5b5SCristian Dumitrescu uint32_t ho_nbytes = 0, i;
2175d60dbdc8SCristian Dumitrescu
2176d60dbdc8SCristian Dumitrescu for (i = 0; i < n_emit; i++) {
2177d60dbdc8SCristian Dumitrescu uint32_t header_id = ip->io.hdr.header_id[i];
2178d60dbdc8SCristian Dumitrescu uint32_t struct_id = ip->io.hdr.struct_id[i];
2179d60dbdc8SCristian Dumitrescu
2180d60dbdc8SCristian Dumitrescu struct header_runtime *hi = &t->headers[header_id];
2181d60dbdc8SCristian Dumitrescu uint8_t *hi_ptr0 = hi->ptr0;
2182d60dbdc8SCristian Dumitrescu uint32_t n_bytes = hi->n_bytes;
2183d60dbdc8SCristian Dumitrescu
2184d60dbdc8SCristian Dumitrescu uint8_t *hi_ptr = t->structs[struct_id];
2185d60dbdc8SCristian Dumitrescu
2186775be5b5SCristian Dumitrescu if (!MASK64_BIT_GET(valid_headers, header_id)) {
2187775be5b5SCristian Dumitrescu TRACE("[Thread %2u]: emit header %u (invalid)\n",
2188775be5b5SCristian Dumitrescu p->thread_id,
2189775be5b5SCristian Dumitrescu header_id);
2190d60dbdc8SCristian Dumitrescu
2191775be5b5SCristian Dumitrescu continue;
2192775be5b5SCristian Dumitrescu }
2193775be5b5SCristian Dumitrescu
2194775be5b5SCristian Dumitrescu TRACE("[Thread %2u]: emit header %u (valid)\n",
2195d60dbdc8SCristian Dumitrescu p->thread_id,
2196d60dbdc8SCristian Dumitrescu header_id);
2197d60dbdc8SCristian Dumitrescu
2198d60dbdc8SCristian Dumitrescu /* Headers. */
2199775be5b5SCristian Dumitrescu if (!ho) {
2200775be5b5SCristian Dumitrescu if (!n_headers_out) {
2201d60dbdc8SCristian Dumitrescu ho = &t->headers_out[0];
2202d60dbdc8SCristian Dumitrescu
2203d60dbdc8SCristian Dumitrescu ho->ptr0 = hi_ptr0;
2204d60dbdc8SCristian Dumitrescu ho->ptr = hi_ptr;
2205d60dbdc8SCristian Dumitrescu
2206d60dbdc8SCristian Dumitrescu ho_ptr = hi_ptr;
2207d60dbdc8SCristian Dumitrescu ho_nbytes = n_bytes;
2208d60dbdc8SCristian Dumitrescu
2209d60dbdc8SCristian Dumitrescu n_headers_out = 1;
2210d60dbdc8SCristian Dumitrescu
2211d60dbdc8SCristian Dumitrescu continue;
2212d60dbdc8SCristian Dumitrescu } else {
2213775be5b5SCristian Dumitrescu ho = &t->headers_out[n_headers_out - 1];
2214775be5b5SCristian Dumitrescu
2215d60dbdc8SCristian Dumitrescu ho_ptr = ho->ptr;
2216d60dbdc8SCristian Dumitrescu ho_nbytes = ho->n_bytes;
2217d60dbdc8SCristian Dumitrescu }
2218d60dbdc8SCristian Dumitrescu }
2219d60dbdc8SCristian Dumitrescu
2220d60dbdc8SCristian Dumitrescu if (ho_ptr + ho_nbytes == hi_ptr) {
2221d60dbdc8SCristian Dumitrescu ho_nbytes += n_bytes;
2222d60dbdc8SCristian Dumitrescu } else {
2223d60dbdc8SCristian Dumitrescu ho->n_bytes = ho_nbytes;
2224d60dbdc8SCristian Dumitrescu
2225d60dbdc8SCristian Dumitrescu ho++;
2226d60dbdc8SCristian Dumitrescu ho->ptr0 = hi_ptr0;
2227d60dbdc8SCristian Dumitrescu ho->ptr = hi_ptr;
2228d60dbdc8SCristian Dumitrescu
2229d60dbdc8SCristian Dumitrescu ho_ptr = hi_ptr;
2230d60dbdc8SCristian Dumitrescu ho_nbytes = n_bytes;
2231d60dbdc8SCristian Dumitrescu
2232d60dbdc8SCristian Dumitrescu n_headers_out++;
2233d60dbdc8SCristian Dumitrescu }
2234d60dbdc8SCristian Dumitrescu }
2235d60dbdc8SCristian Dumitrescu
2236775be5b5SCristian Dumitrescu if (ho)
2237d60dbdc8SCristian Dumitrescu ho->n_bytes = ho_nbytes;
2238d60dbdc8SCristian Dumitrescu t->n_headers_out = n_headers_out;
2239d60dbdc8SCristian Dumitrescu }
2240d60dbdc8SCristian Dumitrescu
2241d60dbdc8SCristian Dumitrescu static inline void
__instr_hdr_emit_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2242d60dbdc8SCristian Dumitrescu __instr_hdr_emit_exec(struct rte_swx_pipeline *p,
2243d60dbdc8SCristian Dumitrescu struct thread *t,
2244d60dbdc8SCristian Dumitrescu const struct instruction *ip)
2245d60dbdc8SCristian Dumitrescu {
2246d60dbdc8SCristian Dumitrescu __instr_hdr_emit_many_exec(p, t, ip, 1);
2247d60dbdc8SCristian Dumitrescu }
2248d60dbdc8SCristian Dumitrescu
2249d60dbdc8SCristian Dumitrescu static inline void
__instr_hdr_emit_tx_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2250d60dbdc8SCristian Dumitrescu __instr_hdr_emit_tx_exec(struct rte_swx_pipeline *p,
2251d60dbdc8SCristian Dumitrescu struct thread *t,
2252d60dbdc8SCristian Dumitrescu const struct instruction *ip)
2253d60dbdc8SCristian Dumitrescu {
2254d60dbdc8SCristian Dumitrescu TRACE("[Thread %2u] *** The next 2 instructions are fused. ***\n", p->thread_id);
2255d60dbdc8SCristian Dumitrescu
2256d60dbdc8SCristian Dumitrescu __instr_hdr_emit_many_exec(p, t, ip, 1);
2257d60dbdc8SCristian Dumitrescu __instr_tx_exec(p, t, ip);
2258d60dbdc8SCristian Dumitrescu }
2259d60dbdc8SCristian Dumitrescu
2260d60dbdc8SCristian Dumitrescu static inline void
__instr_hdr_emit2_tx_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2261d60dbdc8SCristian Dumitrescu __instr_hdr_emit2_tx_exec(struct rte_swx_pipeline *p,
2262d60dbdc8SCristian Dumitrescu struct thread *t,
2263d60dbdc8SCristian Dumitrescu const struct instruction *ip)
2264d60dbdc8SCristian Dumitrescu {
2265d60dbdc8SCristian Dumitrescu TRACE("[Thread %2u] *** The next 3 instructions are fused. ***\n", p->thread_id);
2266d60dbdc8SCristian Dumitrescu
2267d60dbdc8SCristian Dumitrescu __instr_hdr_emit_many_exec(p, t, ip, 2);
2268d60dbdc8SCristian Dumitrescu __instr_tx_exec(p, t, ip);
2269d60dbdc8SCristian Dumitrescu }
2270d60dbdc8SCristian Dumitrescu
2271d60dbdc8SCristian Dumitrescu static inline void
__instr_hdr_emit3_tx_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2272d60dbdc8SCristian Dumitrescu __instr_hdr_emit3_tx_exec(struct rte_swx_pipeline *p,
2273d60dbdc8SCristian Dumitrescu struct thread *t,
2274d60dbdc8SCristian Dumitrescu const struct instruction *ip)
2275d60dbdc8SCristian Dumitrescu {
2276d60dbdc8SCristian Dumitrescu TRACE("[Thread %2u] *** The next 4 instructions are fused. ***\n", p->thread_id);
2277d60dbdc8SCristian Dumitrescu
2278d60dbdc8SCristian Dumitrescu __instr_hdr_emit_many_exec(p, t, ip, 3);
2279d60dbdc8SCristian Dumitrescu __instr_tx_exec(p, t, ip);
2280d60dbdc8SCristian Dumitrescu }
2281d60dbdc8SCristian Dumitrescu
2282d60dbdc8SCristian Dumitrescu static inline void
__instr_hdr_emit4_tx_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2283d60dbdc8SCristian Dumitrescu __instr_hdr_emit4_tx_exec(struct rte_swx_pipeline *p,
2284d60dbdc8SCristian Dumitrescu struct thread *t,
2285d60dbdc8SCristian Dumitrescu const struct instruction *ip)
2286d60dbdc8SCristian Dumitrescu {
2287d60dbdc8SCristian Dumitrescu TRACE("[Thread %2u] *** The next 5 instructions are fused. ***\n", p->thread_id);
2288d60dbdc8SCristian Dumitrescu
2289d60dbdc8SCristian Dumitrescu __instr_hdr_emit_many_exec(p, t, ip, 4);
2290d60dbdc8SCristian Dumitrescu __instr_tx_exec(p, t, ip);
2291d60dbdc8SCristian Dumitrescu }
2292d60dbdc8SCristian Dumitrescu
2293d60dbdc8SCristian Dumitrescu static inline void
__instr_hdr_emit5_tx_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2294d60dbdc8SCristian Dumitrescu __instr_hdr_emit5_tx_exec(struct rte_swx_pipeline *p,
2295d60dbdc8SCristian Dumitrescu struct thread *t,
2296d60dbdc8SCristian Dumitrescu const struct instruction *ip)
2297d60dbdc8SCristian Dumitrescu {
2298d60dbdc8SCristian Dumitrescu TRACE("[Thread %2u] *** The next 6 instructions are fused. ***\n", p->thread_id);
2299d60dbdc8SCristian Dumitrescu
2300d60dbdc8SCristian Dumitrescu __instr_hdr_emit_many_exec(p, t, ip, 5);
2301d60dbdc8SCristian Dumitrescu __instr_tx_exec(p, t, ip);
2302d60dbdc8SCristian Dumitrescu }
2303d60dbdc8SCristian Dumitrescu
2304d60dbdc8SCristian Dumitrescu static inline void
__instr_hdr_emit6_tx_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2305d60dbdc8SCristian Dumitrescu __instr_hdr_emit6_tx_exec(struct rte_swx_pipeline *p,
2306d60dbdc8SCristian Dumitrescu struct thread *t,
2307d60dbdc8SCristian Dumitrescu const struct instruction *ip)
2308d60dbdc8SCristian Dumitrescu {
2309d60dbdc8SCristian Dumitrescu TRACE("[Thread %2u] *** The next 7 instructions are fused. ***\n", p->thread_id);
2310d60dbdc8SCristian Dumitrescu
2311d60dbdc8SCristian Dumitrescu __instr_hdr_emit_many_exec(p, t, ip, 6);
2312d60dbdc8SCristian Dumitrescu __instr_tx_exec(p, t, ip);
2313d60dbdc8SCristian Dumitrescu }
2314d60dbdc8SCristian Dumitrescu
2315d60dbdc8SCristian Dumitrescu static inline void
__instr_hdr_emit7_tx_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2316d60dbdc8SCristian Dumitrescu __instr_hdr_emit7_tx_exec(struct rte_swx_pipeline *p,
2317d60dbdc8SCristian Dumitrescu struct thread *t,
2318d60dbdc8SCristian Dumitrescu const struct instruction *ip)
2319d60dbdc8SCristian Dumitrescu {
2320d60dbdc8SCristian Dumitrescu TRACE("[Thread %2u] *** The next 8 instructions are fused. ***\n", p->thread_id);
2321d60dbdc8SCristian Dumitrescu
2322d60dbdc8SCristian Dumitrescu __instr_hdr_emit_many_exec(p, t, ip, 7);
2323d60dbdc8SCristian Dumitrescu __instr_tx_exec(p, t, ip);
2324d60dbdc8SCristian Dumitrescu }
2325d60dbdc8SCristian Dumitrescu
2326d60dbdc8SCristian Dumitrescu static inline void
__instr_hdr_emit8_tx_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2327d60dbdc8SCristian Dumitrescu __instr_hdr_emit8_tx_exec(struct rte_swx_pipeline *p,
2328d60dbdc8SCristian Dumitrescu struct thread *t,
2329d60dbdc8SCristian Dumitrescu const struct instruction *ip)
2330d60dbdc8SCristian Dumitrescu {
2331d60dbdc8SCristian Dumitrescu TRACE("[Thread %2u] *** The next 9 instructions are fused. ***\n", p->thread_id);
2332d60dbdc8SCristian Dumitrescu
2333d60dbdc8SCristian Dumitrescu __instr_hdr_emit_many_exec(p, t, ip, 8);
2334d60dbdc8SCristian Dumitrescu __instr_tx_exec(p, t, ip);
2335d60dbdc8SCristian Dumitrescu }
2336d60dbdc8SCristian Dumitrescu
23374565d7dbSCristian Dumitrescu /*
23384565d7dbSCristian Dumitrescu * validate.
23394565d7dbSCristian Dumitrescu */
23404565d7dbSCristian Dumitrescu static inline void
__instr_hdr_validate_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)23414565d7dbSCristian Dumitrescu __instr_hdr_validate_exec(struct rte_swx_pipeline *p __rte_unused,
23424565d7dbSCristian Dumitrescu struct thread *t,
23434565d7dbSCristian Dumitrescu const struct instruction *ip)
23444565d7dbSCristian Dumitrescu {
23454565d7dbSCristian Dumitrescu uint32_t header_id = ip->valid.header_id;
2346a1b2afe4SCristian Dumitrescu uint32_t struct_id = ip->valid.struct_id;
2347a1b2afe4SCristian Dumitrescu uint64_t valid_headers = t->valid_headers;
2348a1b2afe4SCristian Dumitrescu struct header_runtime *h = &t->headers[header_id];
23494565d7dbSCristian Dumitrescu
23504565d7dbSCristian Dumitrescu TRACE("[Thread %2u] validate header %u\n", p->thread_id, header_id);
23514565d7dbSCristian Dumitrescu
2352a1b2afe4SCristian Dumitrescu /* If this header is already valid, then its associated t->structs[] element is also valid
2353a1b2afe4SCristian Dumitrescu * and therefore it should not be modified. It could point to the packet buffer (in case of
2354a1b2afe4SCristian Dumitrescu * extracted header) and setting it to the default location (h->ptr0) would be incorrect.
2355a1b2afe4SCristian Dumitrescu */
2356a1b2afe4SCristian Dumitrescu if (MASK64_BIT_GET(valid_headers, header_id))
2357a1b2afe4SCristian Dumitrescu return;
2358a1b2afe4SCristian Dumitrescu
23594565d7dbSCristian Dumitrescu /* Headers. */
2360a1b2afe4SCristian Dumitrescu t->structs[struct_id] = h->ptr0;
2361a1b2afe4SCristian Dumitrescu t->valid_headers = MASK64_BIT_SET(valid_headers, header_id);
23624565d7dbSCristian Dumitrescu }
23634565d7dbSCristian Dumitrescu
23644565d7dbSCristian Dumitrescu /*
23654565d7dbSCristian Dumitrescu * invalidate.
23664565d7dbSCristian Dumitrescu */
23674565d7dbSCristian Dumitrescu static inline void
__instr_hdr_invalidate_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)23684565d7dbSCristian Dumitrescu __instr_hdr_invalidate_exec(struct rte_swx_pipeline *p __rte_unused,
23694565d7dbSCristian Dumitrescu struct thread *t,
23704565d7dbSCristian Dumitrescu const struct instruction *ip)
23714565d7dbSCristian Dumitrescu {
23724565d7dbSCristian Dumitrescu uint32_t header_id = ip->valid.header_id;
23734565d7dbSCristian Dumitrescu
23744565d7dbSCristian Dumitrescu TRACE("[Thread %2u] invalidate header %u\n", p->thread_id, header_id);
23754565d7dbSCristian Dumitrescu
23764565d7dbSCristian Dumitrescu /* Headers. */
23774565d7dbSCristian Dumitrescu t->valid_headers = MASK64_BIT_CLR(t->valid_headers, header_id);
23784565d7dbSCristian Dumitrescu }
23794565d7dbSCristian Dumitrescu
2380d1a58adaSCristian Dumitrescu /*
2381d1a58adaSCristian Dumitrescu * learn.
2382d1a58adaSCristian Dumitrescu */
2383d1a58adaSCristian Dumitrescu static inline void
__instr_learn_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2384d1a58adaSCristian Dumitrescu __instr_learn_exec(struct rte_swx_pipeline *p,
2385d1a58adaSCristian Dumitrescu struct thread *t,
2386d1a58adaSCristian Dumitrescu const struct instruction *ip)
2387d1a58adaSCristian Dumitrescu {
2388d1a58adaSCristian Dumitrescu uint64_t action_id = ip->learn.action_id;
2389e2ecc535SCristian Dumitrescu uint32_t mf_first_arg_offset = ip->learn.mf_first_arg_offset;
2390e2ecc535SCristian Dumitrescu uint32_t timeout_id = METADATA_READ(t, ip->learn.mf_timeout_id_offset,
2391e2ecc535SCristian Dumitrescu ip->learn.mf_timeout_id_n_bits);
2392d1a58adaSCristian Dumitrescu uint32_t learner_id = t->learner_id;
2393d1a58adaSCristian Dumitrescu struct rte_swx_table_state *ts = &t->table_state[p->n_tables +
2394d1a58adaSCristian Dumitrescu p->n_selectors + learner_id];
2395d1a58adaSCristian Dumitrescu struct learner_runtime *l = &t->learners[learner_id];
2396d1a58adaSCristian Dumitrescu struct learner_statistics *stats = &p->learner_stats[learner_id];
2397d1a58adaSCristian Dumitrescu uint32_t status;
2398d1a58adaSCristian Dumitrescu
2399d1a58adaSCristian Dumitrescu /* Table. */
2400d1a58adaSCristian Dumitrescu status = rte_swx_table_learner_add(ts->obj,
2401d1a58adaSCristian Dumitrescu l->mailbox,
2402d1a58adaSCristian Dumitrescu t->time,
2403d1a58adaSCristian Dumitrescu action_id,
2404e2ecc535SCristian Dumitrescu &t->metadata[mf_first_arg_offset],
2405e2ecc535SCristian Dumitrescu timeout_id);
2406d1a58adaSCristian Dumitrescu
2407d1a58adaSCristian Dumitrescu TRACE("[Thread %2u] learner %u learn %s\n",
2408d1a58adaSCristian Dumitrescu p->thread_id,
2409d1a58adaSCristian Dumitrescu learner_id,
2410d1a58adaSCristian Dumitrescu status ? "ok" : "error");
2411d1a58adaSCristian Dumitrescu
2412d1a58adaSCristian Dumitrescu stats->n_pkts_learn[status] += 1;
2413d1a58adaSCristian Dumitrescu }
2414d1a58adaSCristian Dumitrescu
2415d1a58adaSCristian Dumitrescu /*
2416e2ecc535SCristian Dumitrescu * rearm.
2417e2ecc535SCristian Dumitrescu */
2418e2ecc535SCristian Dumitrescu static inline void
__instr_rearm_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip __rte_unused)2419e2ecc535SCristian Dumitrescu __instr_rearm_exec(struct rte_swx_pipeline *p,
2420e2ecc535SCristian Dumitrescu struct thread *t,
2421e2ecc535SCristian Dumitrescu const struct instruction *ip __rte_unused)
2422e2ecc535SCristian Dumitrescu {
2423e2ecc535SCristian Dumitrescu uint32_t learner_id = t->learner_id;
2424e2ecc535SCristian Dumitrescu struct rte_swx_table_state *ts = &t->table_state[p->n_tables +
2425e2ecc535SCristian Dumitrescu p->n_selectors + learner_id];
2426e2ecc535SCristian Dumitrescu struct learner_runtime *l = &t->learners[learner_id];
2427e2ecc535SCristian Dumitrescu struct learner_statistics *stats = &p->learner_stats[learner_id];
2428e2ecc535SCristian Dumitrescu
2429e2ecc535SCristian Dumitrescu /* Table. */
2430e2ecc535SCristian Dumitrescu rte_swx_table_learner_rearm(ts->obj, l->mailbox, t->time);
2431e2ecc535SCristian Dumitrescu
2432e2ecc535SCristian Dumitrescu TRACE("[Thread %2u] learner %u rearm\n",
2433e2ecc535SCristian Dumitrescu p->thread_id,
2434e2ecc535SCristian Dumitrescu learner_id);
2435e2ecc535SCristian Dumitrescu
2436e2ecc535SCristian Dumitrescu stats->n_pkts_rearm += 1;
2437e2ecc535SCristian Dumitrescu }
2438e2ecc535SCristian Dumitrescu
2439e2ecc535SCristian Dumitrescu static inline void
__instr_rearm_new_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2440e2ecc535SCristian Dumitrescu __instr_rearm_new_exec(struct rte_swx_pipeline *p,
2441e2ecc535SCristian Dumitrescu struct thread *t,
2442e2ecc535SCristian Dumitrescu const struct instruction *ip)
2443e2ecc535SCristian Dumitrescu {
2444e2ecc535SCristian Dumitrescu uint32_t timeout_id = METADATA_READ(t, ip->learn.mf_timeout_id_offset,
2445e2ecc535SCristian Dumitrescu ip->learn.mf_timeout_id_n_bits);
2446e2ecc535SCristian Dumitrescu uint32_t learner_id = t->learner_id;
2447e2ecc535SCristian Dumitrescu struct rte_swx_table_state *ts = &t->table_state[p->n_tables +
2448e2ecc535SCristian Dumitrescu p->n_selectors + learner_id];
2449e2ecc535SCristian Dumitrescu struct learner_runtime *l = &t->learners[learner_id];
2450e2ecc535SCristian Dumitrescu struct learner_statistics *stats = &p->learner_stats[learner_id];
2451e2ecc535SCristian Dumitrescu
2452e2ecc535SCristian Dumitrescu /* Table. */
2453e2ecc535SCristian Dumitrescu rte_swx_table_learner_rearm_new(ts->obj, l->mailbox, t->time, timeout_id);
2454e2ecc535SCristian Dumitrescu
2455e2ecc535SCristian Dumitrescu TRACE("[Thread %2u] learner %u rearm with timeout ID %u\n",
2456e2ecc535SCristian Dumitrescu p->thread_id,
2457e2ecc535SCristian Dumitrescu learner_id,
2458e2ecc535SCristian Dumitrescu timeout_id);
2459e2ecc535SCristian Dumitrescu
2460e2ecc535SCristian Dumitrescu stats->n_pkts_rearm += 1;
2461e2ecc535SCristian Dumitrescu }
2462e2ecc535SCristian Dumitrescu
2463e2ecc535SCristian Dumitrescu /*
2464d1a58adaSCristian Dumitrescu * forget.
2465d1a58adaSCristian Dumitrescu */
2466d1a58adaSCristian Dumitrescu static inline void
__instr_forget_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip __rte_unused)2467d1a58adaSCristian Dumitrescu __instr_forget_exec(struct rte_swx_pipeline *p,
2468d1a58adaSCristian Dumitrescu struct thread *t,
2469d1a58adaSCristian Dumitrescu const struct instruction *ip __rte_unused)
2470d1a58adaSCristian Dumitrescu {
2471d1a58adaSCristian Dumitrescu uint32_t learner_id = t->learner_id;
2472d1a58adaSCristian Dumitrescu struct rte_swx_table_state *ts = &t->table_state[p->n_tables +
2473d1a58adaSCristian Dumitrescu p->n_selectors + learner_id];
2474d1a58adaSCristian Dumitrescu struct learner_runtime *l = &t->learners[learner_id];
2475d1a58adaSCristian Dumitrescu struct learner_statistics *stats = &p->learner_stats[learner_id];
2476d1a58adaSCristian Dumitrescu
2477d1a58adaSCristian Dumitrescu /* Table. */
2478d1a58adaSCristian Dumitrescu rte_swx_table_learner_delete(ts->obj, l->mailbox);
2479d1a58adaSCristian Dumitrescu
2480d1a58adaSCristian Dumitrescu TRACE("[Thread %2u] learner %u forget\n",
2481d1a58adaSCristian Dumitrescu p->thread_id,
2482d1a58adaSCristian Dumitrescu learner_id);
2483d1a58adaSCristian Dumitrescu
2484d1a58adaSCristian Dumitrescu stats->n_pkts_forget += 1;
2485d1a58adaSCristian Dumitrescu }
2486d1a58adaSCristian Dumitrescu
24874884264bSCristian Dumitrescu /*
2488d4e95281SCristian Dumitrescu * entryid.
2489d4e95281SCristian Dumitrescu */
2490d4e95281SCristian Dumitrescu static inline void
__instr_entryid_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2491d4e95281SCristian Dumitrescu __instr_entryid_exec(struct rte_swx_pipeline *p __rte_unused,
2492d4e95281SCristian Dumitrescu struct thread *t,
2493d4e95281SCristian Dumitrescu const struct instruction *ip)
2494d4e95281SCristian Dumitrescu {
2495d4e95281SCristian Dumitrescu TRACE("[Thread %2u]: entryid\n",
2496d4e95281SCristian Dumitrescu p->thread_id);
2497d4e95281SCristian Dumitrescu
2498d4e95281SCristian Dumitrescu /* Meta-data. */
2499d4e95281SCristian Dumitrescu METADATA_WRITE(t, ip->mov.dst.offset, ip->mov.dst.n_bits, t->entry_id);
2500d4e95281SCristian Dumitrescu }
2501d4e95281SCristian Dumitrescu
2502d4e95281SCristian Dumitrescu /*
25034884264bSCristian Dumitrescu * extern.
25044884264bSCristian Dumitrescu */
25054884264bSCristian Dumitrescu static inline uint32_t
__instr_extern_obj_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)25064884264bSCristian Dumitrescu __instr_extern_obj_exec(struct rte_swx_pipeline *p __rte_unused,
25074884264bSCristian Dumitrescu struct thread *t,
25084884264bSCristian Dumitrescu const struct instruction *ip)
25094884264bSCristian Dumitrescu {
25104884264bSCristian Dumitrescu uint32_t obj_id = ip->ext_obj.ext_obj_id;
25114884264bSCristian Dumitrescu uint32_t func_id = ip->ext_obj.func_id;
25124884264bSCristian Dumitrescu struct extern_obj_runtime *obj = &t->extern_objs[obj_id];
25134884264bSCristian Dumitrescu rte_swx_extern_type_member_func_t func = obj->funcs[func_id];
25144884264bSCristian Dumitrescu uint32_t done;
25154884264bSCristian Dumitrescu
25164884264bSCristian Dumitrescu TRACE("[Thread %2u] extern obj %u member func %u\n",
25174884264bSCristian Dumitrescu p->thread_id,
25184884264bSCristian Dumitrescu obj_id,
25194884264bSCristian Dumitrescu func_id);
25204884264bSCristian Dumitrescu
25214884264bSCristian Dumitrescu done = func(obj->obj, obj->mailbox);
25224884264bSCristian Dumitrescu
25234884264bSCristian Dumitrescu return done;
25244884264bSCristian Dumitrescu }
25254884264bSCristian Dumitrescu
25264884264bSCristian Dumitrescu static inline uint32_t
__instr_extern_func_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)25274884264bSCristian Dumitrescu __instr_extern_func_exec(struct rte_swx_pipeline *p __rte_unused,
25284884264bSCristian Dumitrescu struct thread *t,
25294884264bSCristian Dumitrescu const struct instruction *ip)
25304884264bSCristian Dumitrescu {
25314884264bSCristian Dumitrescu uint32_t ext_func_id = ip->ext_func.ext_func_id;
25324884264bSCristian Dumitrescu struct extern_func_runtime *ext_func = &t->extern_funcs[ext_func_id];
25334884264bSCristian Dumitrescu rte_swx_extern_func_t func = ext_func->func;
25344884264bSCristian Dumitrescu uint32_t done;
25354884264bSCristian Dumitrescu
25364884264bSCristian Dumitrescu TRACE("[Thread %2u] extern func %u\n",
25374884264bSCristian Dumitrescu p->thread_id,
25384884264bSCristian Dumitrescu ext_func_id);
25394884264bSCristian Dumitrescu
25404884264bSCristian Dumitrescu done = func(ext_func->mailbox);
25414884264bSCristian Dumitrescu
25424884264bSCristian Dumitrescu return done;
25434884264bSCristian Dumitrescu }
25444884264bSCristian Dumitrescu
2545b82733abSCristian Dumitrescu /*
254692f2944dSCristian Dumitrescu * hash.
254792f2944dSCristian Dumitrescu */
254892f2944dSCristian Dumitrescu static inline void
__instr_hash_func_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)254992f2944dSCristian Dumitrescu __instr_hash_func_exec(struct rte_swx_pipeline *p,
255092f2944dSCristian Dumitrescu struct thread *t,
255192f2944dSCristian Dumitrescu const struct instruction *ip)
255292f2944dSCristian Dumitrescu {
255392f2944dSCristian Dumitrescu uint32_t hash_func_id = ip->hash_func.hash_func_id;
255492f2944dSCristian Dumitrescu uint32_t dst_offset = ip->hash_func.dst.offset;
255592f2944dSCristian Dumitrescu uint32_t n_dst_bits = ip->hash_func.dst.n_bits;
255692f2944dSCristian Dumitrescu uint32_t src_struct_id = ip->hash_func.src.struct_id;
255792f2944dSCristian Dumitrescu uint32_t src_offset = ip->hash_func.src.offset;
255892f2944dSCristian Dumitrescu uint32_t n_src_bytes = ip->hash_func.src.n_bytes;
255992f2944dSCristian Dumitrescu
256092f2944dSCristian Dumitrescu struct hash_func_runtime *func = &p->hash_func_runtime[hash_func_id];
256192f2944dSCristian Dumitrescu uint8_t *src_ptr = t->structs[src_struct_id];
256292f2944dSCristian Dumitrescu uint32_t result;
256392f2944dSCristian Dumitrescu
256492f2944dSCristian Dumitrescu TRACE("[Thread %2u] hash %u\n",
256592f2944dSCristian Dumitrescu p->thread_id,
256692f2944dSCristian Dumitrescu hash_func_id);
256792f2944dSCristian Dumitrescu
256892f2944dSCristian Dumitrescu result = func->func(&src_ptr[src_offset], n_src_bytes, 0);
256992f2944dSCristian Dumitrescu METADATA_WRITE(t, dst_offset, n_dst_bits, result);
257092f2944dSCristian Dumitrescu }
257192f2944dSCristian Dumitrescu
257292f2944dSCristian Dumitrescu /*
25738ba342ceSCristian Dumitrescu * rss.
25748ba342ceSCristian Dumitrescu */
25758ba342ceSCristian Dumitrescu static inline uint32_t
rss_func(void * rss_key,uint32_t rss_key_size,void * input_data,uint32_t input_data_size)25768ba342ceSCristian Dumitrescu rss_func(void *rss_key, uint32_t rss_key_size, void *input_data, uint32_t input_data_size)
25778ba342ceSCristian Dumitrescu {
25788ba342ceSCristian Dumitrescu uint32_t *key = (uint32_t *)rss_key;
25798ba342ceSCristian Dumitrescu uint32_t *data = (uint32_t *)input_data;
25808ba342ceSCristian Dumitrescu uint32_t key_size = rss_key_size >> 2;
25818ba342ceSCristian Dumitrescu uint32_t data_size = input_data_size >> 2;
25828ba342ceSCristian Dumitrescu uint32_t hash_val = 0, i;
25838ba342ceSCristian Dumitrescu
25848ba342ceSCristian Dumitrescu for (i = 0; i < data_size; i++) {
25858ba342ceSCristian Dumitrescu uint32_t d;
25868ba342ceSCristian Dumitrescu
25878ba342ceSCristian Dumitrescu for (d = data[i]; d; d &= (d - 1)) {
25888ba342ceSCristian Dumitrescu uint32_t key0, key1, pos;
25898ba342ceSCristian Dumitrescu
25908ba342ceSCristian Dumitrescu pos = rte_bsf32(d);
25918ba342ceSCristian Dumitrescu key0 = key[i % key_size] << (31 - pos);
25928ba342ceSCristian Dumitrescu key1 = key[(i + 1) % key_size] >> (pos + 1);
25938ba342ceSCristian Dumitrescu hash_val ^= key0 | key1;
25948ba342ceSCristian Dumitrescu }
25958ba342ceSCristian Dumitrescu }
25968ba342ceSCristian Dumitrescu
25978ba342ceSCristian Dumitrescu return hash_val;
25988ba342ceSCristian Dumitrescu }
25998ba342ceSCristian Dumitrescu
26008ba342ceSCristian Dumitrescu static inline void
__instr_rss_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)26018ba342ceSCristian Dumitrescu __instr_rss_exec(struct rte_swx_pipeline *p,
26028ba342ceSCristian Dumitrescu struct thread *t,
26038ba342ceSCristian Dumitrescu const struct instruction *ip)
26048ba342ceSCristian Dumitrescu {
26058ba342ceSCristian Dumitrescu uint32_t rss_obj_id = ip->rss.rss_obj_id;
26068ba342ceSCristian Dumitrescu uint32_t dst_offset = ip->rss.dst.offset;
26078ba342ceSCristian Dumitrescu uint32_t n_dst_bits = ip->rss.dst.n_bits;
26088ba342ceSCristian Dumitrescu uint32_t src_struct_id = ip->rss.src.struct_id;
26098ba342ceSCristian Dumitrescu uint32_t src_offset = ip->rss.src.offset;
26108ba342ceSCristian Dumitrescu uint32_t n_src_bytes = ip->rss.src.n_bytes;
26118ba342ceSCristian Dumitrescu
26128ba342ceSCristian Dumitrescu struct rss_runtime *r = p->rss_runtime[rss_obj_id];
26138ba342ceSCristian Dumitrescu uint8_t *src_ptr = t->structs[src_struct_id];
26148ba342ceSCristian Dumitrescu uint32_t result;
26158ba342ceSCristian Dumitrescu
26168ba342ceSCristian Dumitrescu TRACE("[Thread %2u] rss %u\n",
26178ba342ceSCristian Dumitrescu p->thread_id,
26188ba342ceSCristian Dumitrescu rss_obj_id);
26198ba342ceSCristian Dumitrescu
26208ba342ceSCristian Dumitrescu result = rss_func(r->key, r->key_size, &src_ptr[src_offset], n_src_bytes);
26218ba342ceSCristian Dumitrescu METADATA_WRITE(t, dst_offset, n_dst_bits, result);
26228ba342ceSCristian Dumitrescu }
26238ba342ceSCristian Dumitrescu
26248ba342ceSCristian Dumitrescu /*
2625b82733abSCristian Dumitrescu * mov.
2626b82733abSCristian Dumitrescu */
2627b82733abSCristian Dumitrescu static inline void
__instr_mov_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2628b82733abSCristian Dumitrescu __instr_mov_exec(struct rte_swx_pipeline *p __rte_unused,
2629b82733abSCristian Dumitrescu struct thread *t,
2630b82733abSCristian Dumitrescu const struct instruction *ip)
2631b82733abSCristian Dumitrescu {
2632b82733abSCristian Dumitrescu TRACE("[Thread %2u] mov\n", p->thread_id);
2633b82733abSCristian Dumitrescu
2634b82733abSCristian Dumitrescu MOV(t, ip);
2635b82733abSCristian Dumitrescu }
2636b82733abSCristian Dumitrescu
2637b82733abSCristian Dumitrescu static inline void
__instr_mov_mh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2638b82733abSCristian Dumitrescu __instr_mov_mh_exec(struct rte_swx_pipeline *p __rte_unused,
2639b82733abSCristian Dumitrescu struct thread *t,
2640b82733abSCristian Dumitrescu const struct instruction *ip)
2641b82733abSCristian Dumitrescu {
2642b82733abSCristian Dumitrescu TRACE("[Thread %2u] mov (mh)\n", p->thread_id);
2643b82733abSCristian Dumitrescu
2644b82733abSCristian Dumitrescu MOV_MH(t, ip);
2645b82733abSCristian Dumitrescu }
2646b82733abSCristian Dumitrescu
2647b82733abSCristian Dumitrescu static inline void
__instr_mov_hm_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2648b82733abSCristian Dumitrescu __instr_mov_hm_exec(struct rte_swx_pipeline *p __rte_unused,
2649b82733abSCristian Dumitrescu struct thread *t,
2650b82733abSCristian Dumitrescu const struct instruction *ip)
2651b82733abSCristian Dumitrescu {
2652b82733abSCristian Dumitrescu TRACE("[Thread %2u] mov (hm)\n", p->thread_id);
2653b82733abSCristian Dumitrescu
2654b82733abSCristian Dumitrescu MOV_HM(t, ip);
2655b82733abSCristian Dumitrescu }
2656b82733abSCristian Dumitrescu
2657b82733abSCristian Dumitrescu static inline void
__instr_mov_hh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2658b82733abSCristian Dumitrescu __instr_mov_hh_exec(struct rte_swx_pipeline *p __rte_unused,
2659b82733abSCristian Dumitrescu struct thread *t,
2660b82733abSCristian Dumitrescu const struct instruction *ip)
2661b82733abSCristian Dumitrescu {
2662b82733abSCristian Dumitrescu TRACE("[Thread %2u] mov (hh)\n", p->thread_id);
2663b82733abSCristian Dumitrescu
2664b82733abSCristian Dumitrescu MOV_HH(t, ip);
2665b82733abSCristian Dumitrescu }
2666b82733abSCristian Dumitrescu
2667b82733abSCristian Dumitrescu static inline void
__instr_mov_dma_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)26689ebff617SCristian Dumitrescu __instr_mov_dma_exec(struct rte_swx_pipeline *p __rte_unused,
26699ebff617SCristian Dumitrescu struct thread *t,
26709ebff617SCristian Dumitrescu const struct instruction *ip)
26719ebff617SCristian Dumitrescu {
26725b65690eSCristian Dumitrescu uint8_t *dst = t->structs[ip->mov.dst.struct_id] + ip->mov.dst.offset;
26735b65690eSCristian Dumitrescu uint8_t *src = t->structs[ip->mov.src.struct_id] + ip->mov.src.offset;
26749ebff617SCristian Dumitrescu
26755b65690eSCristian Dumitrescu uint32_t n_dst = ip->mov.dst.n_bits >> 3;
26765b65690eSCristian Dumitrescu uint32_t n_src = ip->mov.src.n_bits >> 3;
26779ebff617SCristian Dumitrescu
26789ebff617SCristian Dumitrescu TRACE("[Thread %2u] mov (dma) %u bytes\n", p->thread_id, n);
26799ebff617SCristian Dumitrescu
26805b65690eSCristian Dumitrescu /* Both dst and src are in NBO format. */
26815b65690eSCristian Dumitrescu if (n_dst > n_src) {
26825b65690eSCristian Dumitrescu uint32_t n_dst_zero = n_dst - n_src;
26839ebff617SCristian Dumitrescu
26845b65690eSCristian Dumitrescu /* Zero padding the most significant bytes in dst. */
26855b65690eSCristian Dumitrescu memset(dst, 0, n_dst_zero);
26865b65690eSCristian Dumitrescu dst += n_dst_zero;
26879ebff617SCristian Dumitrescu
26885b65690eSCristian Dumitrescu /* Copy src to dst. */
26895b65690eSCristian Dumitrescu memcpy(dst, src, n_src);
26905b65690eSCristian Dumitrescu } else {
26915b65690eSCristian Dumitrescu uint32_t n_src_skipped = n_src - n_dst;
26929ebff617SCristian Dumitrescu
26935b65690eSCristian Dumitrescu /* Copy src to dst. */
26945b65690eSCristian Dumitrescu src += n_src_skipped;
26955b65690eSCristian Dumitrescu memcpy(dst, src, n_dst);
26965b65690eSCristian Dumitrescu }
26979ebff617SCristian Dumitrescu }
26989ebff617SCristian Dumitrescu
26999ebff617SCristian Dumitrescu static inline void
__instr_mov_128_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)27009ebff617SCristian Dumitrescu __instr_mov_128_exec(struct rte_swx_pipeline *p __rte_unused,
27019ebff617SCristian Dumitrescu struct thread *t,
27029ebff617SCristian Dumitrescu const struct instruction *ip)
27039ebff617SCristian Dumitrescu {
27049ebff617SCristian Dumitrescu uint8_t *dst_struct = t->structs[ip->mov.dst.struct_id];
27059ebff617SCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[ip->mov.dst.offset];
27069ebff617SCristian Dumitrescu
27079ebff617SCristian Dumitrescu uint8_t *src_struct = t->structs[ip->mov.src.struct_id];
27089ebff617SCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[ip->mov.src.offset];
27099ebff617SCristian Dumitrescu
27109ebff617SCristian Dumitrescu TRACE("[Thread %2u] mov (128)\n", p->thread_id);
27119ebff617SCristian Dumitrescu
27129ebff617SCristian Dumitrescu dst64_ptr[0] = src64_ptr[0];
27139ebff617SCristian Dumitrescu dst64_ptr[1] = src64_ptr[1];
27149ebff617SCristian Dumitrescu }
27159ebff617SCristian Dumitrescu
27169ebff617SCristian Dumitrescu static inline void
__instr_mov_128_64_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2717*1dd3e5e2SCristian Dumitrescu __instr_mov_128_64_exec(struct rte_swx_pipeline *p __rte_unused,
2718*1dd3e5e2SCristian Dumitrescu struct thread *t,
2719*1dd3e5e2SCristian Dumitrescu const struct instruction *ip)
2720*1dd3e5e2SCristian Dumitrescu {
2721*1dd3e5e2SCristian Dumitrescu uint8_t *dst = t->structs[ip->mov.dst.struct_id] + ip->mov.dst.offset;
2722*1dd3e5e2SCristian Dumitrescu uint8_t *src = t->structs[ip->mov.src.struct_id] + ip->mov.src.offset;
2723*1dd3e5e2SCristian Dumitrescu
2724*1dd3e5e2SCristian Dumitrescu uint64_t *dst64 = (uint64_t *)dst;
2725*1dd3e5e2SCristian Dumitrescu uint64_t *src64 = (uint64_t *)src;
2726*1dd3e5e2SCristian Dumitrescu
2727*1dd3e5e2SCristian Dumitrescu TRACE("[Thread %2u] mov (128 <- 64)\n", p->thread_id);
2728*1dd3e5e2SCristian Dumitrescu
2729*1dd3e5e2SCristian Dumitrescu dst64[0] = 0;
2730*1dd3e5e2SCristian Dumitrescu dst64[1] = src64[0];
2731*1dd3e5e2SCristian Dumitrescu }
2732*1dd3e5e2SCristian Dumitrescu
2733*1dd3e5e2SCristian Dumitrescu static inline void
__instr_mov_64_128_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2734*1dd3e5e2SCristian Dumitrescu __instr_mov_64_128_exec(struct rte_swx_pipeline *p __rte_unused,
2735*1dd3e5e2SCristian Dumitrescu struct thread *t,
2736*1dd3e5e2SCristian Dumitrescu const struct instruction *ip)
2737*1dd3e5e2SCristian Dumitrescu {
2738*1dd3e5e2SCristian Dumitrescu uint8_t *dst = t->structs[ip->mov.dst.struct_id] + ip->mov.dst.offset;
2739*1dd3e5e2SCristian Dumitrescu uint8_t *src = t->structs[ip->mov.src.struct_id] + ip->mov.src.offset;
2740*1dd3e5e2SCristian Dumitrescu
2741*1dd3e5e2SCristian Dumitrescu uint64_t *dst64 = (uint64_t *)dst;
2742*1dd3e5e2SCristian Dumitrescu uint64_t *src64 = (uint64_t *)src;
2743*1dd3e5e2SCristian Dumitrescu
2744*1dd3e5e2SCristian Dumitrescu TRACE("[Thread %2u] mov (64 <- 128)\n", p->thread_id);
2745*1dd3e5e2SCristian Dumitrescu
2746*1dd3e5e2SCristian Dumitrescu dst64[0] = src64[1];
2747*1dd3e5e2SCristian Dumitrescu }
2748*1dd3e5e2SCristian Dumitrescu
2749*1dd3e5e2SCristian Dumitrescu static inline void
__instr_mov_128_32_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)27505b65690eSCristian Dumitrescu __instr_mov_128_32_exec(struct rte_swx_pipeline *p __rte_unused,
27515b65690eSCristian Dumitrescu struct thread *t,
27525b65690eSCristian Dumitrescu const struct instruction *ip)
27535b65690eSCristian Dumitrescu {
27545b65690eSCristian Dumitrescu uint8_t *dst = t->structs[ip->mov.dst.struct_id] + ip->mov.dst.offset;
27555b65690eSCristian Dumitrescu uint8_t *src = t->structs[ip->mov.src.struct_id] + ip->mov.src.offset;
27565b65690eSCristian Dumitrescu
27575b65690eSCristian Dumitrescu uint32_t *dst32 = (uint32_t *)dst;
27585b65690eSCristian Dumitrescu uint32_t *src32 = (uint32_t *)src;
27595b65690eSCristian Dumitrescu
27605b65690eSCristian Dumitrescu TRACE("[Thread %2u] mov (128 <- 32)\n", p->thread_id);
27615b65690eSCristian Dumitrescu
27625b65690eSCristian Dumitrescu dst32[0] = 0;
27635b65690eSCristian Dumitrescu dst32[1] = 0;
27645b65690eSCristian Dumitrescu dst32[2] = 0;
27655b65690eSCristian Dumitrescu dst32[3] = src32[0];
27665b65690eSCristian Dumitrescu }
27675b65690eSCristian Dumitrescu
27685b65690eSCristian Dumitrescu static inline void
__instr_mov_32_128_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2769*1dd3e5e2SCristian Dumitrescu __instr_mov_32_128_exec(struct rte_swx_pipeline *p __rte_unused,
2770*1dd3e5e2SCristian Dumitrescu struct thread *t,
2771*1dd3e5e2SCristian Dumitrescu const struct instruction *ip)
2772*1dd3e5e2SCristian Dumitrescu {
2773*1dd3e5e2SCristian Dumitrescu uint8_t *dst = t->structs[ip->mov.dst.struct_id] + ip->mov.dst.offset;
2774*1dd3e5e2SCristian Dumitrescu uint8_t *src = t->structs[ip->mov.src.struct_id] + ip->mov.src.offset;
2775*1dd3e5e2SCristian Dumitrescu
2776*1dd3e5e2SCristian Dumitrescu uint32_t *dst32 = (uint32_t *)dst;
2777*1dd3e5e2SCristian Dumitrescu uint32_t *src32 = (uint32_t *)src;
2778*1dd3e5e2SCristian Dumitrescu
2779*1dd3e5e2SCristian Dumitrescu TRACE("[Thread %2u] mov (32 <- 128)\n", p->thread_id);
2780*1dd3e5e2SCristian Dumitrescu
2781*1dd3e5e2SCristian Dumitrescu dst32[0] = src32[3];
2782*1dd3e5e2SCristian Dumitrescu }
2783*1dd3e5e2SCristian Dumitrescu
2784*1dd3e5e2SCristian Dumitrescu static inline void
__instr_mov_i_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2785b82733abSCristian Dumitrescu __instr_mov_i_exec(struct rte_swx_pipeline *p __rte_unused,
2786b82733abSCristian Dumitrescu struct thread *t,
2787b82733abSCristian Dumitrescu const struct instruction *ip)
2788b82733abSCristian Dumitrescu {
2789b82733abSCristian Dumitrescu TRACE("[Thread %2u] mov m.f %" PRIx64 "\n", p->thread_id, ip->mov.src_val);
2790b82733abSCristian Dumitrescu
2791b82733abSCristian Dumitrescu MOV_I(t, ip);
2792b82733abSCristian Dumitrescu }
2793b82733abSCristian Dumitrescu
2794fae7b2baSCristian Dumitrescu /*
27952f8168eaSCristian Dumitrescu * movh.
27962f8168eaSCristian Dumitrescu */
27972f8168eaSCristian Dumitrescu static inline void
__instr_movh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)27982f8168eaSCristian Dumitrescu __instr_movh_exec(struct rte_swx_pipeline *p __rte_unused,
27992f8168eaSCristian Dumitrescu struct thread *t,
28002f8168eaSCristian Dumitrescu const struct instruction *ip)
28012f8168eaSCristian Dumitrescu {
28022f8168eaSCristian Dumitrescu uint8_t *dst = t->structs[ip->mov.dst.struct_id] + ip->mov.dst.offset;
28032f8168eaSCristian Dumitrescu uint8_t *src = t->structs[ip->mov.src.struct_id] + ip->mov.src.offset;
28042f8168eaSCristian Dumitrescu
28052f8168eaSCristian Dumitrescu uint64_t *dst64 = (uint64_t *)dst;
28062f8168eaSCristian Dumitrescu uint64_t *src64 = (uint64_t *)src;
28072f8168eaSCristian Dumitrescu
28082f8168eaSCristian Dumitrescu TRACE("[Thread %2u] movh\n", p->thread_id);
28092f8168eaSCristian Dumitrescu
28102f8168eaSCristian Dumitrescu dst64[0] = src64[0];
28112f8168eaSCristian Dumitrescu }
28122f8168eaSCristian Dumitrescu
28132f8168eaSCristian Dumitrescu /*
2814fae7b2baSCristian Dumitrescu * dma.
2815fae7b2baSCristian Dumitrescu */
2816fae7b2baSCristian Dumitrescu static inline void
__instr_dma_ht_many_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip,uint32_t n_dma)2817fae7b2baSCristian Dumitrescu __instr_dma_ht_many_exec(struct rte_swx_pipeline *p __rte_unused,
2818fae7b2baSCristian Dumitrescu struct thread *t,
2819fae7b2baSCristian Dumitrescu const struct instruction *ip,
2820fae7b2baSCristian Dumitrescu uint32_t n_dma)
2821fae7b2baSCristian Dumitrescu {
2822fae7b2baSCristian Dumitrescu uint8_t *action_data = t->structs[0];
2823fae7b2baSCristian Dumitrescu uint64_t valid_headers = t->valid_headers;
2824fae7b2baSCristian Dumitrescu uint32_t i;
2825fae7b2baSCristian Dumitrescu
2826fae7b2baSCristian Dumitrescu for (i = 0; i < n_dma; i++) {
2827fae7b2baSCristian Dumitrescu uint32_t header_id = ip->dma.dst.header_id[i];
2828fae7b2baSCristian Dumitrescu uint32_t struct_id = ip->dma.dst.struct_id[i];
2829fae7b2baSCristian Dumitrescu uint32_t offset = ip->dma.src.offset[i];
2830fae7b2baSCristian Dumitrescu uint32_t n_bytes = ip->dma.n_bytes[i];
2831fae7b2baSCristian Dumitrescu
2832fae7b2baSCristian Dumitrescu struct header_runtime *h = &t->headers[header_id];
2833fae7b2baSCristian Dumitrescu uint8_t *h_ptr0 = h->ptr0;
2834fae7b2baSCristian Dumitrescu uint8_t *h_ptr = t->structs[struct_id];
2835fae7b2baSCristian Dumitrescu
2836fae7b2baSCristian Dumitrescu void *dst = MASK64_BIT_GET(valid_headers, header_id) ?
2837fae7b2baSCristian Dumitrescu h_ptr : h_ptr0;
2838fae7b2baSCristian Dumitrescu void *src = &action_data[offset];
2839fae7b2baSCristian Dumitrescu
2840fae7b2baSCristian Dumitrescu TRACE("[Thread %2u] dma h.s t.f\n", p->thread_id);
2841fae7b2baSCristian Dumitrescu
2842fae7b2baSCristian Dumitrescu /* Headers. */
2843fae7b2baSCristian Dumitrescu memcpy(dst, src, n_bytes);
2844fae7b2baSCristian Dumitrescu t->structs[struct_id] = dst;
2845fae7b2baSCristian Dumitrescu valid_headers = MASK64_BIT_SET(valid_headers, header_id);
2846fae7b2baSCristian Dumitrescu }
2847fae7b2baSCristian Dumitrescu
2848fae7b2baSCristian Dumitrescu t->valid_headers = valid_headers;
2849fae7b2baSCristian Dumitrescu }
2850fae7b2baSCristian Dumitrescu
2851fae7b2baSCristian Dumitrescu static inline void
__instr_dma_ht_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2852fae7b2baSCristian Dumitrescu __instr_dma_ht_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
2853fae7b2baSCristian Dumitrescu {
2854fae7b2baSCristian Dumitrescu __instr_dma_ht_many_exec(p, t, ip, 1);
2855fae7b2baSCristian Dumitrescu }
2856fae7b2baSCristian Dumitrescu
2857fae7b2baSCristian Dumitrescu static inline void
__instr_dma_ht2_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2858fae7b2baSCristian Dumitrescu __instr_dma_ht2_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
2859fae7b2baSCristian Dumitrescu {
2860fae7b2baSCristian Dumitrescu TRACE("[Thread %2u] *** The next 2 instructions are fused. ***\n", p->thread_id);
2861fae7b2baSCristian Dumitrescu
2862fae7b2baSCristian Dumitrescu __instr_dma_ht_many_exec(p, t, ip, 2);
2863fae7b2baSCristian Dumitrescu }
2864fae7b2baSCristian Dumitrescu
2865fae7b2baSCristian Dumitrescu static inline void
__instr_dma_ht3_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2866fae7b2baSCristian Dumitrescu __instr_dma_ht3_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
2867fae7b2baSCristian Dumitrescu {
2868fae7b2baSCristian Dumitrescu TRACE("[Thread %2u] *** The next 3 instructions are fused. ***\n", p->thread_id);
2869fae7b2baSCristian Dumitrescu
2870fae7b2baSCristian Dumitrescu __instr_dma_ht_many_exec(p, t, ip, 3);
2871fae7b2baSCristian Dumitrescu }
2872fae7b2baSCristian Dumitrescu
2873fae7b2baSCristian Dumitrescu static inline void
__instr_dma_ht4_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2874fae7b2baSCristian Dumitrescu __instr_dma_ht4_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
2875fae7b2baSCristian Dumitrescu {
2876fae7b2baSCristian Dumitrescu TRACE("[Thread %2u] *** The next 4 instructions are fused. ***\n", p->thread_id);
2877fae7b2baSCristian Dumitrescu
2878fae7b2baSCristian Dumitrescu __instr_dma_ht_many_exec(p, t, ip, 4);
2879fae7b2baSCristian Dumitrescu }
2880fae7b2baSCristian Dumitrescu
2881fae7b2baSCristian Dumitrescu static inline void
__instr_dma_ht5_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2882fae7b2baSCristian Dumitrescu __instr_dma_ht5_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
2883fae7b2baSCristian Dumitrescu {
2884fae7b2baSCristian Dumitrescu TRACE("[Thread %2u] *** The next 5 instructions are fused. ***\n", p->thread_id);
2885fae7b2baSCristian Dumitrescu
2886fae7b2baSCristian Dumitrescu __instr_dma_ht_many_exec(p, t, ip, 5);
2887fae7b2baSCristian Dumitrescu }
2888fae7b2baSCristian Dumitrescu
2889fae7b2baSCristian Dumitrescu static inline void
__instr_dma_ht6_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2890fae7b2baSCristian Dumitrescu __instr_dma_ht6_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
2891fae7b2baSCristian Dumitrescu {
2892fae7b2baSCristian Dumitrescu TRACE("[Thread %2u] *** The next 6 instructions are fused. ***\n", p->thread_id);
2893fae7b2baSCristian Dumitrescu
2894fae7b2baSCristian Dumitrescu __instr_dma_ht_many_exec(p, t, ip, 6);
2895fae7b2baSCristian Dumitrescu }
2896fae7b2baSCristian Dumitrescu
2897fae7b2baSCristian Dumitrescu static inline void
__instr_dma_ht7_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2898fae7b2baSCristian Dumitrescu __instr_dma_ht7_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
2899fae7b2baSCristian Dumitrescu {
2900fae7b2baSCristian Dumitrescu TRACE("[Thread %2u] *** The next 7 instructions are fused. ***\n", p->thread_id);
2901fae7b2baSCristian Dumitrescu
2902fae7b2baSCristian Dumitrescu __instr_dma_ht_many_exec(p, t, ip, 7);
2903fae7b2baSCristian Dumitrescu }
2904fae7b2baSCristian Dumitrescu
2905fae7b2baSCristian Dumitrescu static inline void
__instr_dma_ht8_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)2906fae7b2baSCristian Dumitrescu __instr_dma_ht8_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
2907fae7b2baSCristian Dumitrescu {
2908fae7b2baSCristian Dumitrescu TRACE("[Thread %2u] *** The next 8 instructions are fused. ***\n", p->thread_id);
2909fae7b2baSCristian Dumitrescu
2910fae7b2baSCristian Dumitrescu __instr_dma_ht_many_exec(p, t, ip, 8);
2911fae7b2baSCristian Dumitrescu }
2912fae7b2baSCristian Dumitrescu
2913ed7567c9SCristian Dumitrescu /*
2914ed7567c9SCristian Dumitrescu * alu.
2915ed7567c9SCristian Dumitrescu */
2916ed7567c9SCristian Dumitrescu static inline void
__instr_alu_add_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2917ed7567c9SCristian Dumitrescu __instr_alu_add_exec(struct rte_swx_pipeline *p __rte_unused,
2918ed7567c9SCristian Dumitrescu struct thread *t,
2919ed7567c9SCristian Dumitrescu const struct instruction *ip)
2920ed7567c9SCristian Dumitrescu {
2921ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] add\n", p->thread_id);
2922ed7567c9SCristian Dumitrescu
2923ed7567c9SCristian Dumitrescu ALU(t, ip, +);
2924ed7567c9SCristian Dumitrescu }
2925ed7567c9SCristian Dumitrescu
2926ed7567c9SCristian Dumitrescu static inline void
__instr_alu_add_mh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2927ed7567c9SCristian Dumitrescu __instr_alu_add_mh_exec(struct rte_swx_pipeline *p __rte_unused,
2928ed7567c9SCristian Dumitrescu struct thread *t,
2929ed7567c9SCristian Dumitrescu const struct instruction *ip)
2930ed7567c9SCristian Dumitrescu {
2931ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] add (mh)\n", p->thread_id);
2932ed7567c9SCristian Dumitrescu
2933ed7567c9SCristian Dumitrescu ALU_MH(t, ip, +);
2934ed7567c9SCristian Dumitrescu }
2935ed7567c9SCristian Dumitrescu
2936ed7567c9SCristian Dumitrescu static inline void
__instr_alu_add_hm_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2937ed7567c9SCristian Dumitrescu __instr_alu_add_hm_exec(struct rte_swx_pipeline *p __rte_unused,
2938ed7567c9SCristian Dumitrescu struct thread *t,
2939ed7567c9SCristian Dumitrescu const struct instruction *ip)
2940ed7567c9SCristian Dumitrescu {
2941ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] add (hm)\n", p->thread_id);
2942ed7567c9SCristian Dumitrescu
2943ed7567c9SCristian Dumitrescu ALU_HM(t, ip, +);
2944ed7567c9SCristian Dumitrescu }
2945ed7567c9SCristian Dumitrescu
2946ed7567c9SCristian Dumitrescu static inline void
__instr_alu_add_hh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2947ed7567c9SCristian Dumitrescu __instr_alu_add_hh_exec(struct rte_swx_pipeline *p __rte_unused,
2948ed7567c9SCristian Dumitrescu struct thread *t,
2949ed7567c9SCristian Dumitrescu const struct instruction *ip)
2950ed7567c9SCristian Dumitrescu {
2951ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] add (hh)\n", p->thread_id);
2952ed7567c9SCristian Dumitrescu
2953ed7567c9SCristian Dumitrescu ALU_HH(t, ip, +);
2954ed7567c9SCristian Dumitrescu }
2955ed7567c9SCristian Dumitrescu
2956ed7567c9SCristian Dumitrescu static inline void
__instr_alu_add_mi_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2957ed7567c9SCristian Dumitrescu __instr_alu_add_mi_exec(struct rte_swx_pipeline *p __rte_unused,
2958ed7567c9SCristian Dumitrescu struct thread *t,
2959ed7567c9SCristian Dumitrescu const struct instruction *ip)
2960ed7567c9SCristian Dumitrescu {
2961ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] add (mi)\n", p->thread_id);
2962ed7567c9SCristian Dumitrescu
2963ed7567c9SCristian Dumitrescu ALU_MI(t, ip, +);
2964ed7567c9SCristian Dumitrescu }
2965ed7567c9SCristian Dumitrescu
2966ed7567c9SCristian Dumitrescu static inline void
__instr_alu_add_hi_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2967ed7567c9SCristian Dumitrescu __instr_alu_add_hi_exec(struct rte_swx_pipeline *p __rte_unused,
2968ed7567c9SCristian Dumitrescu struct thread *t,
2969ed7567c9SCristian Dumitrescu const struct instruction *ip)
2970ed7567c9SCristian Dumitrescu {
2971ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] add (hi)\n", p->thread_id);
2972ed7567c9SCristian Dumitrescu
2973ed7567c9SCristian Dumitrescu ALU_HI(t, ip, +);
2974ed7567c9SCristian Dumitrescu }
2975ed7567c9SCristian Dumitrescu
2976ed7567c9SCristian Dumitrescu static inline void
__instr_alu_sub_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2977ed7567c9SCristian Dumitrescu __instr_alu_sub_exec(struct rte_swx_pipeline *p __rte_unused,
2978ed7567c9SCristian Dumitrescu struct thread *t,
2979ed7567c9SCristian Dumitrescu const struct instruction *ip)
2980ed7567c9SCristian Dumitrescu {
2981ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] sub\n", p->thread_id);
2982ed7567c9SCristian Dumitrescu
2983ed7567c9SCristian Dumitrescu ALU(t, ip, -);
2984ed7567c9SCristian Dumitrescu }
2985ed7567c9SCristian Dumitrescu
2986ed7567c9SCristian Dumitrescu static inline void
__instr_alu_sub_mh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2987ed7567c9SCristian Dumitrescu __instr_alu_sub_mh_exec(struct rte_swx_pipeline *p __rte_unused,
2988ed7567c9SCristian Dumitrescu struct thread *t,
2989ed7567c9SCristian Dumitrescu const struct instruction *ip)
2990ed7567c9SCristian Dumitrescu {
2991ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] sub (mh)\n", p->thread_id);
2992ed7567c9SCristian Dumitrescu
2993ed7567c9SCristian Dumitrescu ALU_MH(t, ip, -);
2994ed7567c9SCristian Dumitrescu }
2995ed7567c9SCristian Dumitrescu
2996ed7567c9SCristian Dumitrescu static inline void
__instr_alu_sub_hm_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)2997ed7567c9SCristian Dumitrescu __instr_alu_sub_hm_exec(struct rte_swx_pipeline *p __rte_unused,
2998ed7567c9SCristian Dumitrescu struct thread *t,
2999ed7567c9SCristian Dumitrescu const struct instruction *ip)
3000ed7567c9SCristian Dumitrescu {
3001ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] sub (hm)\n", p->thread_id);
3002ed7567c9SCristian Dumitrescu
3003ed7567c9SCristian Dumitrescu ALU_HM(t, ip, -);
3004ed7567c9SCristian Dumitrescu }
3005ed7567c9SCristian Dumitrescu
3006ed7567c9SCristian Dumitrescu static inline void
__instr_alu_sub_hh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3007ed7567c9SCristian Dumitrescu __instr_alu_sub_hh_exec(struct rte_swx_pipeline *p __rte_unused,
3008ed7567c9SCristian Dumitrescu struct thread *t,
3009ed7567c9SCristian Dumitrescu const struct instruction *ip)
3010ed7567c9SCristian Dumitrescu {
3011ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] sub (hh)\n", p->thread_id);
3012ed7567c9SCristian Dumitrescu
3013ed7567c9SCristian Dumitrescu ALU_HH(t, ip, -);
3014ed7567c9SCristian Dumitrescu }
3015ed7567c9SCristian Dumitrescu
3016ed7567c9SCristian Dumitrescu static inline void
__instr_alu_sub_mi_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3017ed7567c9SCristian Dumitrescu __instr_alu_sub_mi_exec(struct rte_swx_pipeline *p __rte_unused,
3018ed7567c9SCristian Dumitrescu struct thread *t,
3019ed7567c9SCristian Dumitrescu const struct instruction *ip)
3020ed7567c9SCristian Dumitrescu {
3021ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] sub (mi)\n", p->thread_id);
3022ed7567c9SCristian Dumitrescu
3023ed7567c9SCristian Dumitrescu ALU_MI(t, ip, -);
3024ed7567c9SCristian Dumitrescu }
3025ed7567c9SCristian Dumitrescu
3026ed7567c9SCristian Dumitrescu static inline void
__instr_alu_sub_hi_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3027ed7567c9SCristian Dumitrescu __instr_alu_sub_hi_exec(struct rte_swx_pipeline *p __rte_unused,
3028ed7567c9SCristian Dumitrescu struct thread *t,
3029ed7567c9SCristian Dumitrescu const struct instruction *ip)
3030ed7567c9SCristian Dumitrescu {
3031ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] sub (hi)\n", p->thread_id);
3032ed7567c9SCristian Dumitrescu
3033ed7567c9SCristian Dumitrescu ALU_HI(t, ip, -);
3034ed7567c9SCristian Dumitrescu }
3035ed7567c9SCristian Dumitrescu
3036ed7567c9SCristian Dumitrescu static inline void
__instr_alu_shl_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3037ed7567c9SCristian Dumitrescu __instr_alu_shl_exec(struct rte_swx_pipeline *p __rte_unused,
3038ed7567c9SCristian Dumitrescu struct thread *t,
3039ed7567c9SCristian Dumitrescu const struct instruction *ip)
3040ed7567c9SCristian Dumitrescu {
3041ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] shl\n", p->thread_id);
3042ed7567c9SCristian Dumitrescu
3043ed7567c9SCristian Dumitrescu ALU(t, ip, <<);
3044ed7567c9SCristian Dumitrescu }
3045ed7567c9SCristian Dumitrescu
3046ed7567c9SCristian Dumitrescu static inline void
__instr_alu_shl_mh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3047ed7567c9SCristian Dumitrescu __instr_alu_shl_mh_exec(struct rte_swx_pipeline *p __rte_unused,
3048ed7567c9SCristian Dumitrescu struct thread *t,
3049ed7567c9SCristian Dumitrescu const struct instruction *ip)
3050ed7567c9SCristian Dumitrescu {
3051ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] shl (mh)\n", p->thread_id);
3052ed7567c9SCristian Dumitrescu
3053ed7567c9SCristian Dumitrescu ALU_MH(t, ip, <<);
3054ed7567c9SCristian Dumitrescu }
3055ed7567c9SCristian Dumitrescu
3056ed7567c9SCristian Dumitrescu static inline void
__instr_alu_shl_hm_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3057ed7567c9SCristian Dumitrescu __instr_alu_shl_hm_exec(struct rte_swx_pipeline *p __rte_unused,
3058ed7567c9SCristian Dumitrescu struct thread *t,
3059ed7567c9SCristian Dumitrescu const struct instruction *ip)
3060ed7567c9SCristian Dumitrescu {
3061ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] shl (hm)\n", p->thread_id);
3062ed7567c9SCristian Dumitrescu
3063ed7567c9SCristian Dumitrescu ALU_HM(t, ip, <<);
3064ed7567c9SCristian Dumitrescu }
3065ed7567c9SCristian Dumitrescu
3066ed7567c9SCristian Dumitrescu static inline void
__instr_alu_shl_hh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3067ed7567c9SCristian Dumitrescu __instr_alu_shl_hh_exec(struct rte_swx_pipeline *p __rte_unused,
3068ed7567c9SCristian Dumitrescu struct thread *t,
3069ed7567c9SCristian Dumitrescu const struct instruction *ip)
3070ed7567c9SCristian Dumitrescu {
3071ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] shl (hh)\n", p->thread_id);
3072ed7567c9SCristian Dumitrescu
3073ed7567c9SCristian Dumitrescu ALU_HH(t, ip, <<);
3074ed7567c9SCristian Dumitrescu }
3075ed7567c9SCristian Dumitrescu
3076ed7567c9SCristian Dumitrescu static inline void
__instr_alu_shl_mi_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3077ed7567c9SCristian Dumitrescu __instr_alu_shl_mi_exec(struct rte_swx_pipeline *p __rte_unused,
3078ed7567c9SCristian Dumitrescu struct thread *t,
3079ed7567c9SCristian Dumitrescu const struct instruction *ip)
3080ed7567c9SCristian Dumitrescu {
3081ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] shl (mi)\n", p->thread_id);
3082ed7567c9SCristian Dumitrescu
3083ed7567c9SCristian Dumitrescu ALU_MI(t, ip, <<);
3084ed7567c9SCristian Dumitrescu }
3085ed7567c9SCristian Dumitrescu
3086ed7567c9SCristian Dumitrescu static inline void
__instr_alu_shl_hi_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3087ed7567c9SCristian Dumitrescu __instr_alu_shl_hi_exec(struct rte_swx_pipeline *p __rte_unused,
3088ed7567c9SCristian Dumitrescu struct thread *t,
3089ed7567c9SCristian Dumitrescu const struct instruction *ip)
3090ed7567c9SCristian Dumitrescu {
3091ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] shl (hi)\n", p->thread_id);
3092ed7567c9SCristian Dumitrescu
3093ed7567c9SCristian Dumitrescu ALU_HI(t, ip, <<);
3094ed7567c9SCristian Dumitrescu }
3095ed7567c9SCristian Dumitrescu
3096ed7567c9SCristian Dumitrescu static inline void
__instr_alu_shr_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3097ed7567c9SCristian Dumitrescu __instr_alu_shr_exec(struct rte_swx_pipeline *p __rte_unused,
3098ed7567c9SCristian Dumitrescu struct thread *t,
3099ed7567c9SCristian Dumitrescu const struct instruction *ip)
3100ed7567c9SCristian Dumitrescu {
3101ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] shr\n", p->thread_id);
3102ed7567c9SCristian Dumitrescu
3103ed7567c9SCristian Dumitrescu ALU(t, ip, >>);
3104ed7567c9SCristian Dumitrescu }
3105ed7567c9SCristian Dumitrescu
3106ed7567c9SCristian Dumitrescu static inline void
__instr_alu_shr_mh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3107ed7567c9SCristian Dumitrescu __instr_alu_shr_mh_exec(struct rte_swx_pipeline *p __rte_unused,
3108ed7567c9SCristian Dumitrescu struct thread *t,
3109ed7567c9SCristian Dumitrescu const struct instruction *ip)
3110ed7567c9SCristian Dumitrescu {
3111ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] shr (mh)\n", p->thread_id);
3112ed7567c9SCristian Dumitrescu
3113ed7567c9SCristian Dumitrescu ALU_MH(t, ip, >>);
3114ed7567c9SCristian Dumitrescu }
3115ed7567c9SCristian Dumitrescu
3116ed7567c9SCristian Dumitrescu static inline void
__instr_alu_shr_hm_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3117ed7567c9SCristian Dumitrescu __instr_alu_shr_hm_exec(struct rte_swx_pipeline *p __rte_unused,
3118ed7567c9SCristian Dumitrescu struct thread *t,
3119ed7567c9SCristian Dumitrescu const struct instruction *ip)
3120ed7567c9SCristian Dumitrescu {
3121ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] shr (hm)\n", p->thread_id);
3122ed7567c9SCristian Dumitrescu
3123ed7567c9SCristian Dumitrescu ALU_HM(t, ip, >>);
3124ed7567c9SCristian Dumitrescu }
3125ed7567c9SCristian Dumitrescu
3126ed7567c9SCristian Dumitrescu static inline void
__instr_alu_shr_hh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3127ed7567c9SCristian Dumitrescu __instr_alu_shr_hh_exec(struct rte_swx_pipeline *p __rte_unused,
3128ed7567c9SCristian Dumitrescu struct thread *t,
3129ed7567c9SCristian Dumitrescu const struct instruction *ip)
3130ed7567c9SCristian Dumitrescu {
3131ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] shr (hh)\n", p->thread_id);
3132ed7567c9SCristian Dumitrescu
3133ed7567c9SCristian Dumitrescu ALU_HH(t, ip, >>);
3134ed7567c9SCristian Dumitrescu }
3135ed7567c9SCristian Dumitrescu
3136ed7567c9SCristian Dumitrescu static inline void
__instr_alu_shr_mi_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3137ed7567c9SCristian Dumitrescu __instr_alu_shr_mi_exec(struct rte_swx_pipeline *p __rte_unused,
3138ed7567c9SCristian Dumitrescu struct thread *t,
3139ed7567c9SCristian Dumitrescu const struct instruction *ip)
3140ed7567c9SCristian Dumitrescu {
3141ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] shr (mi)\n", p->thread_id);
3142ed7567c9SCristian Dumitrescu
3143ed7567c9SCristian Dumitrescu /* Structs. */
3144ed7567c9SCristian Dumitrescu ALU_MI(t, ip, >>);
3145ed7567c9SCristian Dumitrescu }
3146ed7567c9SCristian Dumitrescu
3147ed7567c9SCristian Dumitrescu static inline void
__instr_alu_shr_hi_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3148ed7567c9SCristian Dumitrescu __instr_alu_shr_hi_exec(struct rte_swx_pipeline *p __rte_unused,
3149ed7567c9SCristian Dumitrescu struct thread *t,
3150ed7567c9SCristian Dumitrescu const struct instruction *ip)
3151ed7567c9SCristian Dumitrescu {
3152ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] shr (hi)\n", p->thread_id);
3153ed7567c9SCristian Dumitrescu
3154ed7567c9SCristian Dumitrescu ALU_HI(t, ip, >>);
3155ed7567c9SCristian Dumitrescu }
3156ed7567c9SCristian Dumitrescu
3157ed7567c9SCristian Dumitrescu static inline void
__instr_alu_and_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3158ed7567c9SCristian Dumitrescu __instr_alu_and_exec(struct rte_swx_pipeline *p __rte_unused,
3159ed7567c9SCristian Dumitrescu struct thread *t,
3160ed7567c9SCristian Dumitrescu const struct instruction *ip)
3161ed7567c9SCristian Dumitrescu {
3162ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] and\n", p->thread_id);
3163ed7567c9SCristian Dumitrescu
3164ed7567c9SCristian Dumitrescu ALU(t, ip, &);
3165ed7567c9SCristian Dumitrescu }
3166ed7567c9SCristian Dumitrescu
3167ed7567c9SCristian Dumitrescu static inline void
__instr_alu_and_mh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3168ed7567c9SCristian Dumitrescu __instr_alu_and_mh_exec(struct rte_swx_pipeline *p __rte_unused,
3169ed7567c9SCristian Dumitrescu struct thread *t,
3170ed7567c9SCristian Dumitrescu const struct instruction *ip)
3171ed7567c9SCristian Dumitrescu {
3172ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] and (mh)\n", p->thread_id);
3173ed7567c9SCristian Dumitrescu
3174ed7567c9SCristian Dumitrescu ALU_MH(t, ip, &);
3175ed7567c9SCristian Dumitrescu }
3176ed7567c9SCristian Dumitrescu
3177ed7567c9SCristian Dumitrescu static inline void
__instr_alu_and_hm_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3178ed7567c9SCristian Dumitrescu __instr_alu_and_hm_exec(struct rte_swx_pipeline *p __rte_unused,
3179ed7567c9SCristian Dumitrescu struct thread *t,
3180ed7567c9SCristian Dumitrescu const struct instruction *ip)
3181ed7567c9SCristian Dumitrescu {
3182ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] and (hm)\n", p->thread_id);
3183ed7567c9SCristian Dumitrescu
3184ed7567c9SCristian Dumitrescu ALU_HM_FAST(t, ip, &);
3185ed7567c9SCristian Dumitrescu }
3186ed7567c9SCristian Dumitrescu
3187ed7567c9SCristian Dumitrescu static inline void
__instr_alu_and_hh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3188ed7567c9SCristian Dumitrescu __instr_alu_and_hh_exec(struct rte_swx_pipeline *p __rte_unused,
3189ed7567c9SCristian Dumitrescu struct thread *t,
3190ed7567c9SCristian Dumitrescu const struct instruction *ip)
3191ed7567c9SCristian Dumitrescu {
3192ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] and (hh)\n", p->thread_id);
3193ed7567c9SCristian Dumitrescu
3194ed7567c9SCristian Dumitrescu ALU_HH_FAST(t, ip, &);
3195ed7567c9SCristian Dumitrescu }
3196ed7567c9SCristian Dumitrescu
3197ed7567c9SCristian Dumitrescu static inline void
__instr_alu_and_i_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3198ed7567c9SCristian Dumitrescu __instr_alu_and_i_exec(struct rte_swx_pipeline *p __rte_unused,
3199ed7567c9SCristian Dumitrescu struct thread *t,
3200ed7567c9SCristian Dumitrescu const struct instruction *ip)
3201ed7567c9SCristian Dumitrescu {
3202ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] and (i)\n", p->thread_id);
3203ed7567c9SCristian Dumitrescu
3204ed7567c9SCristian Dumitrescu ALU_I(t, ip, &);
3205ed7567c9SCristian Dumitrescu }
3206ed7567c9SCristian Dumitrescu
3207ed7567c9SCristian Dumitrescu static inline void
__instr_alu_or_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3208ed7567c9SCristian Dumitrescu __instr_alu_or_exec(struct rte_swx_pipeline *p __rte_unused,
3209ed7567c9SCristian Dumitrescu struct thread *t,
3210ed7567c9SCristian Dumitrescu const struct instruction *ip)
3211ed7567c9SCristian Dumitrescu {
3212ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] or\n", p->thread_id);
3213ed7567c9SCristian Dumitrescu
3214ed7567c9SCristian Dumitrescu ALU(t, ip, |);
3215ed7567c9SCristian Dumitrescu }
3216ed7567c9SCristian Dumitrescu
3217ed7567c9SCristian Dumitrescu static inline void
__instr_alu_or_mh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3218ed7567c9SCristian Dumitrescu __instr_alu_or_mh_exec(struct rte_swx_pipeline *p __rte_unused,
3219ed7567c9SCristian Dumitrescu struct thread *t,
3220ed7567c9SCristian Dumitrescu const struct instruction *ip)
3221ed7567c9SCristian Dumitrescu {
3222ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] or (mh)\n", p->thread_id);
3223ed7567c9SCristian Dumitrescu
3224ed7567c9SCristian Dumitrescu ALU_MH(t, ip, |);
3225ed7567c9SCristian Dumitrescu }
3226ed7567c9SCristian Dumitrescu
3227ed7567c9SCristian Dumitrescu static inline void
__instr_alu_or_hm_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3228ed7567c9SCristian Dumitrescu __instr_alu_or_hm_exec(struct rte_swx_pipeline *p __rte_unused,
3229ed7567c9SCristian Dumitrescu struct thread *t,
3230ed7567c9SCristian Dumitrescu const struct instruction *ip)
3231ed7567c9SCristian Dumitrescu {
3232ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] or (hm)\n", p->thread_id);
3233ed7567c9SCristian Dumitrescu
3234ed7567c9SCristian Dumitrescu ALU_HM_FAST(t, ip, |);
3235ed7567c9SCristian Dumitrescu }
3236ed7567c9SCristian Dumitrescu
3237ed7567c9SCristian Dumitrescu static inline void
__instr_alu_or_hh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3238ed7567c9SCristian Dumitrescu __instr_alu_or_hh_exec(struct rte_swx_pipeline *p __rte_unused,
3239ed7567c9SCristian Dumitrescu struct thread *t,
3240ed7567c9SCristian Dumitrescu const struct instruction *ip)
3241ed7567c9SCristian Dumitrescu {
3242ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] or (hh)\n", p->thread_id);
3243ed7567c9SCristian Dumitrescu
3244ed7567c9SCristian Dumitrescu ALU_HH_FAST(t, ip, |);
3245ed7567c9SCristian Dumitrescu }
3246ed7567c9SCristian Dumitrescu
3247ed7567c9SCristian Dumitrescu static inline void
__instr_alu_or_i_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3248ed7567c9SCristian Dumitrescu __instr_alu_or_i_exec(struct rte_swx_pipeline *p __rte_unused,
3249ed7567c9SCristian Dumitrescu struct thread *t,
3250ed7567c9SCristian Dumitrescu const struct instruction *ip)
3251ed7567c9SCristian Dumitrescu {
3252ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] or (i)\n", p->thread_id);
3253ed7567c9SCristian Dumitrescu
3254ed7567c9SCristian Dumitrescu ALU_I(t, ip, |);
3255ed7567c9SCristian Dumitrescu }
3256ed7567c9SCristian Dumitrescu
3257ed7567c9SCristian Dumitrescu static inline void
__instr_alu_xor_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3258ed7567c9SCristian Dumitrescu __instr_alu_xor_exec(struct rte_swx_pipeline *p __rte_unused,
3259ed7567c9SCristian Dumitrescu struct thread *t,
3260ed7567c9SCristian Dumitrescu const struct instruction *ip)
3261ed7567c9SCristian Dumitrescu {
3262ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] xor\n", p->thread_id);
3263ed7567c9SCristian Dumitrescu
3264ed7567c9SCristian Dumitrescu ALU(t, ip, ^);
3265ed7567c9SCristian Dumitrescu }
3266ed7567c9SCristian Dumitrescu
3267ed7567c9SCristian Dumitrescu static inline void
__instr_alu_xor_mh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3268ed7567c9SCristian Dumitrescu __instr_alu_xor_mh_exec(struct rte_swx_pipeline *p __rte_unused,
3269ed7567c9SCristian Dumitrescu struct thread *t,
3270ed7567c9SCristian Dumitrescu const struct instruction *ip)
3271ed7567c9SCristian Dumitrescu {
3272ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] xor (mh)\n", p->thread_id);
3273ed7567c9SCristian Dumitrescu
3274ed7567c9SCristian Dumitrescu ALU_MH(t, ip, ^);
3275ed7567c9SCristian Dumitrescu }
3276ed7567c9SCristian Dumitrescu
3277ed7567c9SCristian Dumitrescu static inline void
__instr_alu_xor_hm_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3278ed7567c9SCristian Dumitrescu __instr_alu_xor_hm_exec(struct rte_swx_pipeline *p __rte_unused,
3279ed7567c9SCristian Dumitrescu struct thread *t,
3280ed7567c9SCristian Dumitrescu const struct instruction *ip)
3281ed7567c9SCristian Dumitrescu {
3282ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] xor (hm)\n", p->thread_id);
3283ed7567c9SCristian Dumitrescu
3284ed7567c9SCristian Dumitrescu ALU_HM_FAST(t, ip, ^);
3285ed7567c9SCristian Dumitrescu }
3286ed7567c9SCristian Dumitrescu
3287ed7567c9SCristian Dumitrescu static inline void
__instr_alu_xor_hh_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3288ed7567c9SCristian Dumitrescu __instr_alu_xor_hh_exec(struct rte_swx_pipeline *p __rte_unused,
3289ed7567c9SCristian Dumitrescu struct thread *t,
3290ed7567c9SCristian Dumitrescu const struct instruction *ip)
3291ed7567c9SCristian Dumitrescu {
3292ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] xor (hh)\n", p->thread_id);
3293ed7567c9SCristian Dumitrescu
3294ed7567c9SCristian Dumitrescu ALU_HH_FAST(t, ip, ^);
3295ed7567c9SCristian Dumitrescu }
3296ed7567c9SCristian Dumitrescu
3297ed7567c9SCristian Dumitrescu static inline void
__instr_alu_xor_i_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3298ed7567c9SCristian Dumitrescu __instr_alu_xor_i_exec(struct rte_swx_pipeline *p __rte_unused,
3299ed7567c9SCristian Dumitrescu struct thread *t,
3300ed7567c9SCristian Dumitrescu const struct instruction *ip)
3301ed7567c9SCristian Dumitrescu {
3302ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] xor (i)\n", p->thread_id);
3303ed7567c9SCristian Dumitrescu
3304ed7567c9SCristian Dumitrescu ALU_I(t, ip, ^);
3305ed7567c9SCristian Dumitrescu }
3306ed7567c9SCristian Dumitrescu
3307ed7567c9SCristian Dumitrescu static inline void
__instr_alu_ckadd_field_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3308ed7567c9SCristian Dumitrescu __instr_alu_ckadd_field_exec(struct rte_swx_pipeline *p __rte_unused,
3309ed7567c9SCristian Dumitrescu struct thread *t,
3310ed7567c9SCristian Dumitrescu const struct instruction *ip)
3311ed7567c9SCristian Dumitrescu {
3312ed7567c9SCristian Dumitrescu uint8_t *dst_struct, *src_struct;
3313ed7567c9SCristian Dumitrescu uint16_t *dst16_ptr, dst;
3314ed7567c9SCristian Dumitrescu uint64_t *src64_ptr, src64, src64_mask, src;
3315ed7567c9SCristian Dumitrescu uint64_t r;
3316ed7567c9SCristian Dumitrescu
3317ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] ckadd (field)\n", p->thread_id);
3318ed7567c9SCristian Dumitrescu
3319ed7567c9SCristian Dumitrescu /* Structs. */
3320ed7567c9SCristian Dumitrescu dst_struct = t->structs[ip->alu.dst.struct_id];
3321ed7567c9SCristian Dumitrescu dst16_ptr = (uint16_t *)&dst_struct[ip->alu.dst.offset];
3322ed7567c9SCristian Dumitrescu dst = *dst16_ptr;
3323ed7567c9SCristian Dumitrescu
3324ed7567c9SCristian Dumitrescu src_struct = t->structs[ip->alu.src.struct_id];
3325ed7567c9SCristian Dumitrescu src64_ptr = (uint64_t *)&src_struct[ip->alu.src.offset];
3326ed7567c9SCristian Dumitrescu src64 = *src64_ptr;
3327ed7567c9SCristian Dumitrescu src64_mask = UINT64_MAX >> (64 - ip->alu.src.n_bits);
3328ed7567c9SCristian Dumitrescu src = src64 & src64_mask;
3329ed7567c9SCristian Dumitrescu
33302a11b503SCristian Dumitrescu /* Initialize the result with destination 1's complement. */
3331ed7567c9SCristian Dumitrescu r = dst;
3332ed7567c9SCristian Dumitrescu r = ~r & 0xFFFF;
3333ed7567c9SCristian Dumitrescu
3334ed7567c9SCristian Dumitrescu /* The first input (r) is a 16-bit number. The second and the third
3335ed7567c9SCristian Dumitrescu * inputs are 32-bit numbers. In the worst case scenario, the sum of the
3336ed7567c9SCristian Dumitrescu * three numbers (output r) is a 34-bit number.
3337ed7567c9SCristian Dumitrescu */
3338ed7567c9SCristian Dumitrescu r += (src >> 32) + (src & 0xFFFFFFFF);
3339ed7567c9SCristian Dumitrescu
3340ed7567c9SCristian Dumitrescu /* The first input is a 16-bit number. The second input is an 18-bit
3341ed7567c9SCristian Dumitrescu * number. In the worst case scenario, the sum of the two numbers is a
3342ed7567c9SCristian Dumitrescu * 19-bit number.
3343ed7567c9SCristian Dumitrescu */
3344ed7567c9SCristian Dumitrescu r = (r & 0xFFFF) + (r >> 16);
3345ed7567c9SCristian Dumitrescu
3346ed7567c9SCristian Dumitrescu /* The first input is a 16-bit number (0 .. 0xFFFF). The second input is
3347ed7567c9SCristian Dumitrescu * a 3-bit number (0 .. 7). Their sum is a 17-bit number (0 .. 0x10006).
3348ed7567c9SCristian Dumitrescu */
3349ed7567c9SCristian Dumitrescu r = (r & 0xFFFF) + (r >> 16);
3350ed7567c9SCristian Dumitrescu
3351ed7567c9SCristian Dumitrescu /* When the input r is (0 .. 0xFFFF), the output r is equal to the input
3352ed7567c9SCristian Dumitrescu * r, so the output is (0 .. 0xFFFF). When the input r is (0x10000 ..
3353ed7567c9SCristian Dumitrescu * 0x10006), the output r is (0 .. 7). So no carry bit can be generated,
3354ed7567c9SCristian Dumitrescu * therefore the output r is always a 16-bit number.
3355ed7567c9SCristian Dumitrescu */
3356ed7567c9SCristian Dumitrescu r = (r & 0xFFFF) + (r >> 16);
3357ed7567c9SCristian Dumitrescu
33582a11b503SCristian Dumitrescu /* Apply 1's complement to the result. */
3359ed7567c9SCristian Dumitrescu r = ~r & 0xFFFF;
3360ed7567c9SCristian Dumitrescu r = r ? r : 0xFFFF;
3361ed7567c9SCristian Dumitrescu
3362ed7567c9SCristian Dumitrescu *dst16_ptr = (uint16_t)r;
3363ed7567c9SCristian Dumitrescu }
3364ed7567c9SCristian Dumitrescu
3365ed7567c9SCristian Dumitrescu static inline void
__instr_alu_cksub_field_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3366ed7567c9SCristian Dumitrescu __instr_alu_cksub_field_exec(struct rte_swx_pipeline *p __rte_unused,
3367ed7567c9SCristian Dumitrescu struct thread *t,
3368ed7567c9SCristian Dumitrescu const struct instruction *ip)
3369ed7567c9SCristian Dumitrescu {
3370ed7567c9SCristian Dumitrescu uint8_t *dst_struct, *src_struct;
3371ed7567c9SCristian Dumitrescu uint16_t *dst16_ptr, dst;
3372ed7567c9SCristian Dumitrescu uint64_t *src64_ptr, src64, src64_mask, src;
3373ed7567c9SCristian Dumitrescu uint64_t r;
3374ed7567c9SCristian Dumitrescu
3375ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] cksub (field)\n", p->thread_id);
3376ed7567c9SCristian Dumitrescu
3377ed7567c9SCristian Dumitrescu /* Structs. */
3378ed7567c9SCristian Dumitrescu dst_struct = t->structs[ip->alu.dst.struct_id];
3379ed7567c9SCristian Dumitrescu dst16_ptr = (uint16_t *)&dst_struct[ip->alu.dst.offset];
3380ed7567c9SCristian Dumitrescu dst = *dst16_ptr;
3381ed7567c9SCristian Dumitrescu
3382ed7567c9SCristian Dumitrescu src_struct = t->structs[ip->alu.src.struct_id];
3383ed7567c9SCristian Dumitrescu src64_ptr = (uint64_t *)&src_struct[ip->alu.src.offset];
3384ed7567c9SCristian Dumitrescu src64 = *src64_ptr;
3385ed7567c9SCristian Dumitrescu src64_mask = UINT64_MAX >> (64 - ip->alu.src.n_bits);
3386ed7567c9SCristian Dumitrescu src = src64 & src64_mask;
3387ed7567c9SCristian Dumitrescu
33882a11b503SCristian Dumitrescu /* Initialize the result with destination 1's complement. */
3389ed7567c9SCristian Dumitrescu r = dst;
3390ed7567c9SCristian Dumitrescu r = ~r & 0xFFFF;
3391ed7567c9SCristian Dumitrescu
3392ed7567c9SCristian Dumitrescu /* Subtraction in 1's complement arithmetic (i.e. a '- b) is the same as
3393ed7567c9SCristian Dumitrescu * the following sequence of operations in 2's complement arithmetic:
3394ed7567c9SCristian Dumitrescu * a '- b = (a - b) % 0xFFFF.
3395ed7567c9SCristian Dumitrescu *
3396ed7567c9SCristian Dumitrescu * In order to prevent an underflow for the below subtraction, in which
3397ed7567c9SCristian Dumitrescu * a 33-bit number (the subtrahend) is taken out of a 16-bit number (the
3398ed7567c9SCristian Dumitrescu * minuend), we first add a multiple of the 0xFFFF modulus to the
3399ed7567c9SCristian Dumitrescu * minuend. The number we add to the minuend needs to be a 34-bit number
3400ed7567c9SCristian Dumitrescu * or higher, so for readability reasons we picked the 36-bit multiple.
3401ed7567c9SCristian Dumitrescu * We are effectively turning the 16-bit minuend into a 36-bit number:
3402ed7567c9SCristian Dumitrescu * (a - b) % 0xFFFF = (a + 0xFFFF00000 - b) % 0xFFFF.
3403ed7567c9SCristian Dumitrescu */
3404ed7567c9SCristian Dumitrescu r += 0xFFFF00000ULL; /* The output r is a 36-bit number. */
3405ed7567c9SCristian Dumitrescu
3406ed7567c9SCristian Dumitrescu /* A 33-bit number is subtracted from a 36-bit number (the input r). The
3407ed7567c9SCristian Dumitrescu * result (the output r) is a 36-bit number.
3408ed7567c9SCristian Dumitrescu */
3409ed7567c9SCristian Dumitrescu r -= (src >> 32) + (src & 0xFFFFFFFF);
3410ed7567c9SCristian Dumitrescu
3411ed7567c9SCristian Dumitrescu /* The first input is a 16-bit number. The second input is a 20-bit
3412ed7567c9SCristian Dumitrescu * number. Their sum is a 21-bit number.
3413ed7567c9SCristian Dumitrescu */
3414ed7567c9SCristian Dumitrescu r = (r & 0xFFFF) + (r >> 16);
3415ed7567c9SCristian Dumitrescu
3416ed7567c9SCristian Dumitrescu /* The first input is a 16-bit number (0 .. 0xFFFF). The second input is
3417ed7567c9SCristian Dumitrescu * a 5-bit number (0 .. 31). The sum is a 17-bit number (0 .. 0x1001E).
3418ed7567c9SCristian Dumitrescu */
3419ed7567c9SCristian Dumitrescu r = (r & 0xFFFF) + (r >> 16);
3420ed7567c9SCristian Dumitrescu
3421ed7567c9SCristian Dumitrescu /* When the input r is (0 .. 0xFFFF), the output r is equal to the input
3422ed7567c9SCristian Dumitrescu * r, so the output is (0 .. 0xFFFF). When the input r is (0x10000 ..
3423ed7567c9SCristian Dumitrescu * 0x1001E), the output r is (0 .. 31). So no carry bit can be
3424ed7567c9SCristian Dumitrescu * generated, therefore the output r is always a 16-bit number.
3425ed7567c9SCristian Dumitrescu */
3426ed7567c9SCristian Dumitrescu r = (r & 0xFFFF) + (r >> 16);
3427ed7567c9SCristian Dumitrescu
34282a11b503SCristian Dumitrescu /* Apply 1's complement to the result. */
3429ed7567c9SCristian Dumitrescu r = ~r & 0xFFFF;
3430ed7567c9SCristian Dumitrescu r = r ? r : 0xFFFF;
3431ed7567c9SCristian Dumitrescu
3432ed7567c9SCristian Dumitrescu *dst16_ptr = (uint16_t)r;
3433ed7567c9SCristian Dumitrescu }
3434ed7567c9SCristian Dumitrescu
3435ed7567c9SCristian Dumitrescu static inline void
__instr_alu_ckadd_struct20_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3436ed7567c9SCristian Dumitrescu __instr_alu_ckadd_struct20_exec(struct rte_swx_pipeline *p __rte_unused,
3437ed7567c9SCristian Dumitrescu struct thread *t,
3438ed7567c9SCristian Dumitrescu const struct instruction *ip)
3439ed7567c9SCristian Dumitrescu {
3440ed7567c9SCristian Dumitrescu uint8_t *dst_struct, *src_struct;
34412a11b503SCristian Dumitrescu uint16_t *dst16_ptr, dst;
3442ed7567c9SCristian Dumitrescu uint32_t *src32_ptr;
3443ed7567c9SCristian Dumitrescu uint64_t r0, r1;
3444ed7567c9SCristian Dumitrescu
3445ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] ckadd (struct of 20 bytes)\n", p->thread_id);
3446ed7567c9SCristian Dumitrescu
3447ed7567c9SCristian Dumitrescu /* Structs. */
3448ed7567c9SCristian Dumitrescu dst_struct = t->structs[ip->alu.dst.struct_id];
3449ed7567c9SCristian Dumitrescu dst16_ptr = (uint16_t *)&dst_struct[ip->alu.dst.offset];
34502a11b503SCristian Dumitrescu dst = *dst16_ptr;
3451ed7567c9SCristian Dumitrescu
3452ed7567c9SCristian Dumitrescu src_struct = t->structs[ip->alu.src.struct_id];
3453ed7567c9SCristian Dumitrescu src32_ptr = (uint32_t *)&src_struct[0];
3454ed7567c9SCristian Dumitrescu
34552a11b503SCristian Dumitrescu /* Initialize the result with destination 1's complement. */
34562a11b503SCristian Dumitrescu r0 = dst;
34572a11b503SCristian Dumitrescu r0 = ~r0 & 0xFFFF;
34582a11b503SCristian Dumitrescu
34592a11b503SCristian Dumitrescu r0 += src32_ptr[0]; /* The output r0 is a 33-bit number. */
3460ed7567c9SCristian Dumitrescu r1 = src32_ptr[1]; /* r1 is a 32-bit number. */
34612a11b503SCristian Dumitrescu r0 += src32_ptr[2]; /* The output r0 is a 34-bit number. */
3462ed7567c9SCristian Dumitrescu r1 += src32_ptr[3]; /* The output r1 is a 33-bit number. */
3463ed7567c9SCristian Dumitrescu r0 += r1 + src32_ptr[4]; /* The output r0 is a 35-bit number. */
3464ed7567c9SCristian Dumitrescu
3465ed7567c9SCristian Dumitrescu /* The first input is a 16-bit number. The second input is a 19-bit
3466ed7567c9SCristian Dumitrescu * number. Their sum is a 20-bit number.
3467ed7567c9SCristian Dumitrescu */
3468ed7567c9SCristian Dumitrescu r0 = (r0 & 0xFFFF) + (r0 >> 16);
3469ed7567c9SCristian Dumitrescu
3470ed7567c9SCristian Dumitrescu /* The first input is a 16-bit number (0 .. 0xFFFF). The second input is
3471ed7567c9SCristian Dumitrescu * a 4-bit number (0 .. 15). The sum is a 17-bit number (0 .. 0x1000E).
3472ed7567c9SCristian Dumitrescu */
3473ed7567c9SCristian Dumitrescu r0 = (r0 & 0xFFFF) + (r0 >> 16);
3474ed7567c9SCristian Dumitrescu
3475ed7567c9SCristian Dumitrescu /* When the input r is (0 .. 0xFFFF), the output r is equal to the input
3476ed7567c9SCristian Dumitrescu * r, so the output is (0 .. 0xFFFF). When the input r is (0x10000 ..
3477ed7567c9SCristian Dumitrescu * 0x1000E), the output r is (0 .. 15). So no carry bit can be
3478ed7567c9SCristian Dumitrescu * generated, therefore the output r is always a 16-bit number.
3479ed7567c9SCristian Dumitrescu */
3480ed7567c9SCristian Dumitrescu r0 = (r0 & 0xFFFF) + (r0 >> 16);
3481ed7567c9SCristian Dumitrescu
34822a11b503SCristian Dumitrescu /* Apply 1's complement to the result. */
3483ed7567c9SCristian Dumitrescu r0 = ~r0 & 0xFFFF;
3484ed7567c9SCristian Dumitrescu r0 = r0 ? r0 : 0xFFFF;
3485ed7567c9SCristian Dumitrescu
3486ed7567c9SCristian Dumitrescu *dst16_ptr = (uint16_t)r0;
3487ed7567c9SCristian Dumitrescu }
3488ed7567c9SCristian Dumitrescu
3489ed7567c9SCristian Dumitrescu static inline void
__instr_alu_ckadd_struct_exec(struct rte_swx_pipeline * p __rte_unused,struct thread * t,const struct instruction * ip)3490ed7567c9SCristian Dumitrescu __instr_alu_ckadd_struct_exec(struct rte_swx_pipeline *p __rte_unused,
3491ed7567c9SCristian Dumitrescu struct thread *t,
3492ed7567c9SCristian Dumitrescu const struct instruction *ip)
3493ed7567c9SCristian Dumitrescu {
34942a11b503SCristian Dumitrescu uint32_t src_header_id = ip->alu.src.n_bits; /* The src header ID is stored here. */
34952a11b503SCristian Dumitrescu uint32_t n_src_header_bytes = t->headers[src_header_id].n_bytes;
3496ed7567c9SCristian Dumitrescu uint8_t *dst_struct, *src_struct;
34972a11b503SCristian Dumitrescu uint16_t *dst16_ptr, dst;
3498ed7567c9SCristian Dumitrescu uint32_t *src32_ptr;
34992a11b503SCristian Dumitrescu uint64_t r;
3500ed7567c9SCristian Dumitrescu uint32_t i;
3501ed7567c9SCristian Dumitrescu
35022a11b503SCristian Dumitrescu if (n_src_header_bytes == 20) {
35032a11b503SCristian Dumitrescu __instr_alu_ckadd_struct20_exec(p, t, ip);
35042a11b503SCristian Dumitrescu return;
35052a11b503SCristian Dumitrescu }
35062a11b503SCristian Dumitrescu
3507ed7567c9SCristian Dumitrescu TRACE("[Thread %2u] ckadd (struct)\n", p->thread_id);
3508ed7567c9SCristian Dumitrescu
3509ed7567c9SCristian Dumitrescu /* Structs. */
3510ed7567c9SCristian Dumitrescu dst_struct = t->structs[ip->alu.dst.struct_id];
3511ed7567c9SCristian Dumitrescu dst16_ptr = (uint16_t *)&dst_struct[ip->alu.dst.offset];
35122a11b503SCristian Dumitrescu dst = *dst16_ptr;
3513ed7567c9SCristian Dumitrescu
3514ed7567c9SCristian Dumitrescu src_struct = t->structs[ip->alu.src.struct_id];
3515ed7567c9SCristian Dumitrescu src32_ptr = (uint32_t *)&src_struct[0];
3516ed7567c9SCristian Dumitrescu
35172a11b503SCristian Dumitrescu /* Initialize the result with destination 1's complement. */
35182a11b503SCristian Dumitrescu r = dst;
35192a11b503SCristian Dumitrescu r = ~r & 0xFFFF;
35202a11b503SCristian Dumitrescu
35212a11b503SCristian Dumitrescu /* The max number of 32-bit words in a 32K-byte header is 2^13.
35222a11b503SCristian Dumitrescu * Therefore, in the worst case scenario, a 45-bit number is added to a
35232a11b503SCristian Dumitrescu * 16-bit number (the input r), so the output r is 46-bit number.
3524ed7567c9SCristian Dumitrescu */
35252a11b503SCristian Dumitrescu for (i = 0; i < n_src_header_bytes / 4; i++, src32_ptr++)
3526ed7567c9SCristian Dumitrescu r += *src32_ptr;
3527ed7567c9SCristian Dumitrescu
35282a11b503SCristian Dumitrescu /* The first input is a 16-bit number. The second input is a 30-bit
35292a11b503SCristian Dumitrescu * number. Their sum is a 31-bit number.
3530ed7567c9SCristian Dumitrescu */
3531ed7567c9SCristian Dumitrescu r = (r & 0xFFFF) + (r >> 16);
3532ed7567c9SCristian Dumitrescu
3533ed7567c9SCristian Dumitrescu /* The first input is a 16-bit number (0 .. 0xFFFF). The second input is
35342a11b503SCristian Dumitrescu * a 15-bit number (0 .. 0x7FFF). The sum is a 17-bit number (0 .. 0x17FFE).
3535ed7567c9SCristian Dumitrescu */
3536ed7567c9SCristian Dumitrescu r = (r & 0xFFFF) + (r >> 16);
3537ed7567c9SCristian Dumitrescu
3538ed7567c9SCristian Dumitrescu /* When the input r is (0 .. 0xFFFF), the output r is equal to the input
3539ed7567c9SCristian Dumitrescu * r, so the output is (0 .. 0xFFFF). When the input r is (0x10000 ..
35402a11b503SCristian Dumitrescu * 0x17FFE), the output r is (0 .. 0x7FFF). So no carry bit can be
3541ed7567c9SCristian Dumitrescu * generated, therefore the output r is always a 16-bit number.
3542ed7567c9SCristian Dumitrescu */
3543ed7567c9SCristian Dumitrescu r = (r & 0xFFFF) + (r >> 16);
3544ed7567c9SCristian Dumitrescu
35452a11b503SCristian Dumitrescu /* Apply 1's complement to the result. */
3546ed7567c9SCristian Dumitrescu r = ~r & 0xFFFF;
3547ed7567c9SCristian Dumitrescu r = r ? r : 0xFFFF;
3548ed7567c9SCristian Dumitrescu
3549ed7567c9SCristian Dumitrescu *dst16_ptr = (uint16_t)r;
3550ed7567c9SCristian Dumitrescu }
3551ed7567c9SCristian Dumitrescu
3552c5d03ffdSCristian Dumitrescu /*
3553c5d03ffdSCristian Dumitrescu * Register array.
3554c5d03ffdSCristian Dumitrescu */
3555c5d03ffdSCristian Dumitrescu static inline uint64_t *
instr_regarray_regarray(struct rte_swx_pipeline * p,const struct instruction * ip)3556c5d03ffdSCristian Dumitrescu instr_regarray_regarray(struct rte_swx_pipeline *p, const struct instruction *ip)
3557c5d03ffdSCristian Dumitrescu {
3558c5d03ffdSCristian Dumitrescu struct regarray_runtime *r = &p->regarray_runtime[ip->regarray.regarray_id];
3559c5d03ffdSCristian Dumitrescu return r->regarray;
3560c5d03ffdSCristian Dumitrescu }
3561c5d03ffdSCristian Dumitrescu
3562c5d03ffdSCristian Dumitrescu static inline uint64_t
instr_regarray_idx_hbo(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3563c5d03ffdSCristian Dumitrescu instr_regarray_idx_hbo(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3564c5d03ffdSCristian Dumitrescu {
3565c5d03ffdSCristian Dumitrescu struct regarray_runtime *r = &p->regarray_runtime[ip->regarray.regarray_id];
3566c5d03ffdSCristian Dumitrescu
3567c5d03ffdSCristian Dumitrescu uint8_t *idx_struct = t->structs[ip->regarray.idx.struct_id];
3568c5d03ffdSCristian Dumitrescu uint64_t *idx64_ptr = (uint64_t *)&idx_struct[ip->regarray.idx.offset];
3569c5d03ffdSCristian Dumitrescu uint64_t idx64 = *idx64_ptr;
3570c5d03ffdSCristian Dumitrescu uint64_t idx64_mask = UINT64_MAX >> (64 - ip->regarray.idx.n_bits);
3571c5d03ffdSCristian Dumitrescu uint64_t idx = idx64 & idx64_mask & r->size_mask;
3572c5d03ffdSCristian Dumitrescu
3573c5d03ffdSCristian Dumitrescu return idx;
3574c5d03ffdSCristian Dumitrescu }
3575c5d03ffdSCristian Dumitrescu
3576c5d03ffdSCristian Dumitrescu #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
3577c5d03ffdSCristian Dumitrescu
3578c5d03ffdSCristian Dumitrescu static inline uint64_t
instr_regarray_idx_nbo(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3579c5d03ffdSCristian Dumitrescu instr_regarray_idx_nbo(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3580c5d03ffdSCristian Dumitrescu {
3581c5d03ffdSCristian Dumitrescu struct regarray_runtime *r = &p->regarray_runtime[ip->regarray.regarray_id];
3582c5d03ffdSCristian Dumitrescu
3583c5d03ffdSCristian Dumitrescu uint8_t *idx_struct = t->structs[ip->regarray.idx.struct_id];
3584c5d03ffdSCristian Dumitrescu uint64_t *idx64_ptr = (uint64_t *)&idx_struct[ip->regarray.idx.offset];
3585c5d03ffdSCristian Dumitrescu uint64_t idx64 = *idx64_ptr;
3586c5d03ffdSCristian Dumitrescu uint64_t idx = (ntoh64(idx64) >> (64 - ip->regarray.idx.n_bits)) & r->size_mask;
3587c5d03ffdSCristian Dumitrescu
3588c5d03ffdSCristian Dumitrescu return idx;
3589c5d03ffdSCristian Dumitrescu }
3590c5d03ffdSCristian Dumitrescu
3591c5d03ffdSCristian Dumitrescu #else
3592c5d03ffdSCristian Dumitrescu
3593c5d03ffdSCristian Dumitrescu #define instr_regarray_idx_nbo instr_regarray_idx_hbo
3594c5d03ffdSCristian Dumitrescu
3595c5d03ffdSCristian Dumitrescu #endif
3596c5d03ffdSCristian Dumitrescu
3597c5d03ffdSCristian Dumitrescu static inline uint64_t
instr_regarray_idx_imm(struct rte_swx_pipeline * p,const struct instruction * ip)3598c5d03ffdSCristian Dumitrescu instr_regarray_idx_imm(struct rte_swx_pipeline *p, const struct instruction *ip)
3599c5d03ffdSCristian Dumitrescu {
3600c5d03ffdSCristian Dumitrescu struct regarray_runtime *r = &p->regarray_runtime[ip->regarray.regarray_id];
3601c5d03ffdSCristian Dumitrescu
3602c5d03ffdSCristian Dumitrescu uint64_t idx = ip->regarray.idx_val & r->size_mask;
3603c5d03ffdSCristian Dumitrescu
3604c5d03ffdSCristian Dumitrescu return idx;
3605c5d03ffdSCristian Dumitrescu }
3606c5d03ffdSCristian Dumitrescu
3607c5d03ffdSCristian Dumitrescu static inline uint64_t
instr_regarray_src_hbo(struct thread * t,const struct instruction * ip)3608c5d03ffdSCristian Dumitrescu instr_regarray_src_hbo(struct thread *t, const struct instruction *ip)
3609c5d03ffdSCristian Dumitrescu {
3610c5d03ffdSCristian Dumitrescu uint8_t *src_struct = t->structs[ip->regarray.dstsrc.struct_id];
3611c5d03ffdSCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[ip->regarray.dstsrc.offset];
3612c5d03ffdSCristian Dumitrescu uint64_t src64 = *src64_ptr;
3613c5d03ffdSCristian Dumitrescu uint64_t src64_mask = UINT64_MAX >> (64 - ip->regarray.dstsrc.n_bits);
3614c5d03ffdSCristian Dumitrescu uint64_t src = src64 & src64_mask;
3615c5d03ffdSCristian Dumitrescu
3616c5d03ffdSCristian Dumitrescu return src;
3617c5d03ffdSCristian Dumitrescu }
3618c5d03ffdSCristian Dumitrescu
3619c5d03ffdSCristian Dumitrescu #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
3620c5d03ffdSCristian Dumitrescu
3621c5d03ffdSCristian Dumitrescu static inline uint64_t
instr_regarray_src_nbo(struct thread * t,const struct instruction * ip)3622c5d03ffdSCristian Dumitrescu instr_regarray_src_nbo(struct thread *t, const struct instruction *ip)
3623c5d03ffdSCristian Dumitrescu {
3624c5d03ffdSCristian Dumitrescu uint8_t *src_struct = t->structs[ip->regarray.dstsrc.struct_id];
3625c5d03ffdSCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[ip->regarray.dstsrc.offset];
3626c5d03ffdSCristian Dumitrescu uint64_t src64 = *src64_ptr;
3627c5d03ffdSCristian Dumitrescu uint64_t src = ntoh64(src64) >> (64 - ip->regarray.dstsrc.n_bits);
3628c5d03ffdSCristian Dumitrescu
3629c5d03ffdSCristian Dumitrescu return src;
3630c5d03ffdSCristian Dumitrescu }
3631c5d03ffdSCristian Dumitrescu
3632c5d03ffdSCristian Dumitrescu #else
3633c5d03ffdSCristian Dumitrescu
3634c5d03ffdSCristian Dumitrescu #define instr_regarray_src_nbo instr_regarray_src_hbo
3635c5d03ffdSCristian Dumitrescu
3636c5d03ffdSCristian Dumitrescu #endif
3637c5d03ffdSCristian Dumitrescu
3638c5d03ffdSCristian Dumitrescu static inline void
instr_regarray_dst_hbo_src_hbo_set(struct thread * t,const struct instruction * ip,uint64_t src)3639c5d03ffdSCristian Dumitrescu instr_regarray_dst_hbo_src_hbo_set(struct thread *t, const struct instruction *ip, uint64_t src)
3640c5d03ffdSCristian Dumitrescu {
3641c5d03ffdSCristian Dumitrescu uint8_t *dst_struct = t->structs[ip->regarray.dstsrc.struct_id];
3642c5d03ffdSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[ip->regarray.dstsrc.offset];
3643c5d03ffdSCristian Dumitrescu uint64_t dst64 = *dst64_ptr;
3644c5d03ffdSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - ip->regarray.dstsrc.n_bits);
3645c5d03ffdSCristian Dumitrescu
3646c5d03ffdSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | (src & dst64_mask);
3647c5d03ffdSCristian Dumitrescu
3648c5d03ffdSCristian Dumitrescu }
3649c5d03ffdSCristian Dumitrescu
3650c5d03ffdSCristian Dumitrescu #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
3651c5d03ffdSCristian Dumitrescu
3652c5d03ffdSCristian Dumitrescu static inline void
instr_regarray_dst_nbo_src_hbo_set(struct thread * t,const struct instruction * ip,uint64_t src)3653c5d03ffdSCristian Dumitrescu instr_regarray_dst_nbo_src_hbo_set(struct thread *t, const struct instruction *ip, uint64_t src)
3654c5d03ffdSCristian Dumitrescu {
3655c5d03ffdSCristian Dumitrescu uint8_t *dst_struct = t->structs[ip->regarray.dstsrc.struct_id];
3656c5d03ffdSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[ip->regarray.dstsrc.offset];
3657c5d03ffdSCristian Dumitrescu uint64_t dst64 = *dst64_ptr;
3658c5d03ffdSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - ip->regarray.dstsrc.n_bits);
3659c5d03ffdSCristian Dumitrescu
3660c5d03ffdSCristian Dumitrescu src = hton64(src) >> (64 - ip->regarray.dstsrc.n_bits);
3661c5d03ffdSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | (src & dst64_mask);
3662c5d03ffdSCristian Dumitrescu }
3663c5d03ffdSCristian Dumitrescu
3664c5d03ffdSCristian Dumitrescu #else
3665c5d03ffdSCristian Dumitrescu
3666c5d03ffdSCristian Dumitrescu #define instr_regarray_dst_nbo_src_hbo_set instr_regarray_dst_hbo_src_hbo_set
3667c5d03ffdSCristian Dumitrescu
3668c5d03ffdSCristian Dumitrescu #endif
3669c5d03ffdSCristian Dumitrescu
3670c5d03ffdSCristian Dumitrescu static inline void
__instr_regprefetch_rh_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3671c5d03ffdSCristian Dumitrescu __instr_regprefetch_rh_exec(struct rte_swx_pipeline *p,
3672c5d03ffdSCristian Dumitrescu struct thread *t,
3673c5d03ffdSCristian Dumitrescu const struct instruction *ip)
3674c5d03ffdSCristian Dumitrescu {
3675c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx;
3676c5d03ffdSCristian Dumitrescu
3677c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regprefetch (r[h])\n", p->thread_id);
3678c5d03ffdSCristian Dumitrescu
3679c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3680c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_nbo(p, t, ip);
3681c5d03ffdSCristian Dumitrescu rte_prefetch0(®array[idx]);
3682c5d03ffdSCristian Dumitrescu }
3683c5d03ffdSCristian Dumitrescu
3684c5d03ffdSCristian Dumitrescu static inline void
__instr_regprefetch_rm_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3685c5d03ffdSCristian Dumitrescu __instr_regprefetch_rm_exec(struct rte_swx_pipeline *p,
3686c5d03ffdSCristian Dumitrescu struct thread *t,
3687c5d03ffdSCristian Dumitrescu const struct instruction *ip)
3688c5d03ffdSCristian Dumitrescu {
3689c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx;
3690c5d03ffdSCristian Dumitrescu
3691c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regprefetch (r[m])\n", p->thread_id);
3692c5d03ffdSCristian Dumitrescu
3693c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3694c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_hbo(p, t, ip);
3695c5d03ffdSCristian Dumitrescu rte_prefetch0(®array[idx]);
3696c5d03ffdSCristian Dumitrescu }
3697c5d03ffdSCristian Dumitrescu
3698c5d03ffdSCristian Dumitrescu static inline void
__instr_regprefetch_ri_exec(struct rte_swx_pipeline * p,struct thread * t __rte_unused,const struct instruction * ip)3699c5d03ffdSCristian Dumitrescu __instr_regprefetch_ri_exec(struct rte_swx_pipeline *p,
3700c5d03ffdSCristian Dumitrescu struct thread *t __rte_unused,
3701c5d03ffdSCristian Dumitrescu const struct instruction *ip)
3702c5d03ffdSCristian Dumitrescu {
3703c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx;
3704c5d03ffdSCristian Dumitrescu
3705c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regprefetch (r[i])\n", p->thread_id);
3706c5d03ffdSCristian Dumitrescu
3707c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3708c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_imm(p, ip);
3709c5d03ffdSCristian Dumitrescu rte_prefetch0(®array[idx]);
3710c5d03ffdSCristian Dumitrescu }
3711c5d03ffdSCristian Dumitrescu
3712c5d03ffdSCristian Dumitrescu static inline void
__instr_regrd_hrh_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3713c5d03ffdSCristian Dumitrescu __instr_regrd_hrh_exec(struct rte_swx_pipeline *p,
3714c5d03ffdSCristian Dumitrescu struct thread *t,
3715c5d03ffdSCristian Dumitrescu const struct instruction *ip)
3716c5d03ffdSCristian Dumitrescu {
3717c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx;
3718c5d03ffdSCristian Dumitrescu
3719c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regrd (h = r[h])\n", p->thread_id);
3720c5d03ffdSCristian Dumitrescu
3721c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3722c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_nbo(p, t, ip);
3723c5d03ffdSCristian Dumitrescu instr_regarray_dst_nbo_src_hbo_set(t, ip, regarray[idx]);
3724c5d03ffdSCristian Dumitrescu }
3725c5d03ffdSCristian Dumitrescu
3726c5d03ffdSCristian Dumitrescu static inline void
__instr_regrd_hrm_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3727c5d03ffdSCristian Dumitrescu __instr_regrd_hrm_exec(struct rte_swx_pipeline *p,
3728c5d03ffdSCristian Dumitrescu struct thread *t,
3729c5d03ffdSCristian Dumitrescu const struct instruction *ip)
3730c5d03ffdSCristian Dumitrescu {
3731c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx;
3732c5d03ffdSCristian Dumitrescu
3733c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regrd (h = r[m])\n", p->thread_id);
3734c5d03ffdSCristian Dumitrescu
3735c5d03ffdSCristian Dumitrescu /* Structs. */
3736c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3737c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_hbo(p, t, ip);
3738c5d03ffdSCristian Dumitrescu instr_regarray_dst_nbo_src_hbo_set(t, ip, regarray[idx]);
3739c5d03ffdSCristian Dumitrescu }
3740c5d03ffdSCristian Dumitrescu
3741c5d03ffdSCristian Dumitrescu static inline void
__instr_regrd_mrh_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3742c5d03ffdSCristian Dumitrescu __instr_regrd_mrh_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3743c5d03ffdSCristian Dumitrescu {
3744c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx;
3745c5d03ffdSCristian Dumitrescu
3746c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regrd (m = r[h])\n", p->thread_id);
3747c5d03ffdSCristian Dumitrescu
3748c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3749c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_nbo(p, t, ip);
3750c5d03ffdSCristian Dumitrescu instr_regarray_dst_hbo_src_hbo_set(t, ip, regarray[idx]);
3751c5d03ffdSCristian Dumitrescu }
3752c5d03ffdSCristian Dumitrescu
3753c5d03ffdSCristian Dumitrescu static inline void
__instr_regrd_mrm_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3754c5d03ffdSCristian Dumitrescu __instr_regrd_mrm_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3755c5d03ffdSCristian Dumitrescu {
3756c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx;
3757c5d03ffdSCristian Dumitrescu
3758c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regrd (m = r[m])\n", p->thread_id);
3759c5d03ffdSCristian Dumitrescu
3760c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3761c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_hbo(p, t, ip);
3762c5d03ffdSCristian Dumitrescu instr_regarray_dst_hbo_src_hbo_set(t, ip, regarray[idx]);
3763c5d03ffdSCristian Dumitrescu }
3764c5d03ffdSCristian Dumitrescu
3765c5d03ffdSCristian Dumitrescu static inline void
__instr_regrd_hri_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3766c5d03ffdSCristian Dumitrescu __instr_regrd_hri_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3767c5d03ffdSCristian Dumitrescu {
3768c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx;
3769c5d03ffdSCristian Dumitrescu
3770c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regrd (h = r[i])\n", p->thread_id);
3771c5d03ffdSCristian Dumitrescu
3772c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3773c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_imm(p, ip);
3774c5d03ffdSCristian Dumitrescu instr_regarray_dst_nbo_src_hbo_set(t, ip, regarray[idx]);
3775c5d03ffdSCristian Dumitrescu }
3776c5d03ffdSCristian Dumitrescu
3777c5d03ffdSCristian Dumitrescu static inline void
__instr_regrd_mri_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3778c5d03ffdSCristian Dumitrescu __instr_regrd_mri_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3779c5d03ffdSCristian Dumitrescu {
3780c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx;
3781c5d03ffdSCristian Dumitrescu
3782c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regrd (m = r[i])\n", p->thread_id);
3783c5d03ffdSCristian Dumitrescu
3784c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3785c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_imm(p, ip);
3786c5d03ffdSCristian Dumitrescu instr_regarray_dst_hbo_src_hbo_set(t, ip, regarray[idx]);
3787c5d03ffdSCristian Dumitrescu }
3788c5d03ffdSCristian Dumitrescu
3789c5d03ffdSCristian Dumitrescu static inline void
__instr_regwr_rhh_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3790c5d03ffdSCristian Dumitrescu __instr_regwr_rhh_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3791c5d03ffdSCristian Dumitrescu {
3792c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3793c5d03ffdSCristian Dumitrescu
3794c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regwr (r[h] = h)\n", p->thread_id);
3795c5d03ffdSCristian Dumitrescu
3796c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3797c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_nbo(p, t, ip);
3798c5d03ffdSCristian Dumitrescu src = instr_regarray_src_nbo(t, ip);
3799c5d03ffdSCristian Dumitrescu regarray[idx] = src;
3800c5d03ffdSCristian Dumitrescu }
3801c5d03ffdSCristian Dumitrescu
3802c5d03ffdSCristian Dumitrescu static inline void
__instr_regwr_rhm_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3803c5d03ffdSCristian Dumitrescu __instr_regwr_rhm_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3804c5d03ffdSCristian Dumitrescu {
3805c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3806c5d03ffdSCristian Dumitrescu
3807c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regwr (r[h] = m)\n", p->thread_id);
3808c5d03ffdSCristian Dumitrescu
3809c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3810c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_nbo(p, t, ip);
3811c5d03ffdSCristian Dumitrescu src = instr_regarray_src_hbo(t, ip);
3812c5d03ffdSCristian Dumitrescu regarray[idx] = src;
3813c5d03ffdSCristian Dumitrescu }
3814c5d03ffdSCristian Dumitrescu
3815c5d03ffdSCristian Dumitrescu static inline void
__instr_regwr_rmh_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3816c5d03ffdSCristian Dumitrescu __instr_regwr_rmh_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3817c5d03ffdSCristian Dumitrescu {
3818c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3819c5d03ffdSCristian Dumitrescu
3820c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regwr (r[m] = h)\n", p->thread_id);
3821c5d03ffdSCristian Dumitrescu
3822c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3823c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_hbo(p, t, ip);
3824c5d03ffdSCristian Dumitrescu src = instr_regarray_src_nbo(t, ip);
3825c5d03ffdSCristian Dumitrescu regarray[idx] = src;
3826c5d03ffdSCristian Dumitrescu }
3827c5d03ffdSCristian Dumitrescu
3828c5d03ffdSCristian Dumitrescu static inline void
__instr_regwr_rmm_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3829c5d03ffdSCristian Dumitrescu __instr_regwr_rmm_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3830c5d03ffdSCristian Dumitrescu {
3831c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3832c5d03ffdSCristian Dumitrescu
3833c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regwr (r[m] = m)\n", p->thread_id);
3834c5d03ffdSCristian Dumitrescu
3835c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3836c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_hbo(p, t, ip);
3837c5d03ffdSCristian Dumitrescu src = instr_regarray_src_hbo(t, ip);
3838c5d03ffdSCristian Dumitrescu regarray[idx] = src;
3839c5d03ffdSCristian Dumitrescu }
3840c5d03ffdSCristian Dumitrescu
3841c5d03ffdSCristian Dumitrescu static inline void
__instr_regwr_rhi_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3842c5d03ffdSCristian Dumitrescu __instr_regwr_rhi_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3843c5d03ffdSCristian Dumitrescu {
3844c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3845c5d03ffdSCristian Dumitrescu
3846c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regwr (r[h] = i)\n", p->thread_id);
3847c5d03ffdSCristian Dumitrescu
3848c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3849c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_nbo(p, t, ip);
3850c5d03ffdSCristian Dumitrescu src = ip->regarray.dstsrc_val;
3851c5d03ffdSCristian Dumitrescu regarray[idx] = src;
3852c5d03ffdSCristian Dumitrescu }
3853c5d03ffdSCristian Dumitrescu
3854c5d03ffdSCristian Dumitrescu static inline void
__instr_regwr_rmi_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3855c5d03ffdSCristian Dumitrescu __instr_regwr_rmi_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3856c5d03ffdSCristian Dumitrescu {
3857c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3858c5d03ffdSCristian Dumitrescu
3859c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regwr (r[m] = i)\n", p->thread_id);
3860c5d03ffdSCristian Dumitrescu
3861c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3862c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_hbo(p, t, ip);
3863c5d03ffdSCristian Dumitrescu src = ip->regarray.dstsrc_val;
3864c5d03ffdSCristian Dumitrescu regarray[idx] = src;
3865c5d03ffdSCristian Dumitrescu }
3866c5d03ffdSCristian Dumitrescu
3867c5d03ffdSCristian Dumitrescu static inline void
__instr_regwr_rih_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3868c5d03ffdSCristian Dumitrescu __instr_regwr_rih_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3869c5d03ffdSCristian Dumitrescu {
3870c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3871c5d03ffdSCristian Dumitrescu
3872c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regwr (r[i] = h)\n", p->thread_id);
3873c5d03ffdSCristian Dumitrescu
3874c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3875c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_imm(p, ip);
3876c5d03ffdSCristian Dumitrescu src = instr_regarray_src_nbo(t, ip);
3877c5d03ffdSCristian Dumitrescu regarray[idx] = src;
3878c5d03ffdSCristian Dumitrescu }
3879c5d03ffdSCristian Dumitrescu
3880c5d03ffdSCristian Dumitrescu static inline void
__instr_regwr_rim_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3881c5d03ffdSCristian Dumitrescu __instr_regwr_rim_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3882c5d03ffdSCristian Dumitrescu {
3883c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3884c5d03ffdSCristian Dumitrescu
3885c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regwr (r[i] = m)\n", p->thread_id);
3886c5d03ffdSCristian Dumitrescu
3887c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3888c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_imm(p, ip);
3889c5d03ffdSCristian Dumitrescu src = instr_regarray_src_hbo(t, ip);
3890c5d03ffdSCristian Dumitrescu regarray[idx] = src;
3891c5d03ffdSCristian Dumitrescu }
3892c5d03ffdSCristian Dumitrescu
3893c5d03ffdSCristian Dumitrescu static inline void
__instr_regwr_rii_exec(struct rte_swx_pipeline * p,struct thread * t __rte_unused,const struct instruction * ip)3894c5d03ffdSCristian Dumitrescu __instr_regwr_rii_exec(struct rte_swx_pipeline *p,
3895c5d03ffdSCristian Dumitrescu struct thread *t __rte_unused,
3896c5d03ffdSCristian Dumitrescu const struct instruction *ip)
3897c5d03ffdSCristian Dumitrescu {
3898c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3899c5d03ffdSCristian Dumitrescu
3900c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regwr (r[i] = i)\n", p->thread_id);
3901c5d03ffdSCristian Dumitrescu
3902c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3903c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_imm(p, ip);
3904c5d03ffdSCristian Dumitrescu src = ip->regarray.dstsrc_val;
3905c5d03ffdSCristian Dumitrescu regarray[idx] = src;
3906c5d03ffdSCristian Dumitrescu }
3907c5d03ffdSCristian Dumitrescu
3908c5d03ffdSCristian Dumitrescu static inline void
__instr_regadd_rhh_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3909c5d03ffdSCristian Dumitrescu __instr_regadd_rhh_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3910c5d03ffdSCristian Dumitrescu {
3911c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3912c5d03ffdSCristian Dumitrescu
3913c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regadd (r[h] += h)\n", p->thread_id);
3914c5d03ffdSCristian Dumitrescu
3915c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3916c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_nbo(p, t, ip);
3917c5d03ffdSCristian Dumitrescu src = instr_regarray_src_nbo(t, ip);
3918c5d03ffdSCristian Dumitrescu regarray[idx] += src;
3919c5d03ffdSCristian Dumitrescu }
3920c5d03ffdSCristian Dumitrescu
3921c5d03ffdSCristian Dumitrescu static inline void
__instr_regadd_rhm_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3922c5d03ffdSCristian Dumitrescu __instr_regadd_rhm_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3923c5d03ffdSCristian Dumitrescu {
3924c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3925c5d03ffdSCristian Dumitrescu
3926c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regadd (r[h] += m)\n", p->thread_id);
3927c5d03ffdSCristian Dumitrescu
3928c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3929c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_nbo(p, t, ip);
3930c5d03ffdSCristian Dumitrescu src = instr_regarray_src_hbo(t, ip);
3931c5d03ffdSCristian Dumitrescu regarray[idx] += src;
3932c5d03ffdSCristian Dumitrescu }
3933c5d03ffdSCristian Dumitrescu
3934c5d03ffdSCristian Dumitrescu static inline void
__instr_regadd_rmh_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3935c5d03ffdSCristian Dumitrescu __instr_regadd_rmh_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3936c5d03ffdSCristian Dumitrescu {
3937c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3938c5d03ffdSCristian Dumitrescu
3939c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regadd (r[m] += h)\n", p->thread_id);
3940c5d03ffdSCristian Dumitrescu
3941c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3942c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_hbo(p, t, ip);
3943c5d03ffdSCristian Dumitrescu src = instr_regarray_src_nbo(t, ip);
3944c5d03ffdSCristian Dumitrescu regarray[idx] += src;
3945c5d03ffdSCristian Dumitrescu }
3946c5d03ffdSCristian Dumitrescu
3947c5d03ffdSCristian Dumitrescu static inline void
__instr_regadd_rmm_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3948c5d03ffdSCristian Dumitrescu __instr_regadd_rmm_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3949c5d03ffdSCristian Dumitrescu {
3950c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3951c5d03ffdSCristian Dumitrescu
3952c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regadd (r[m] += m)\n", p->thread_id);
3953c5d03ffdSCristian Dumitrescu
3954c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3955c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_hbo(p, t, ip);
3956c5d03ffdSCristian Dumitrescu src = instr_regarray_src_hbo(t, ip);
3957c5d03ffdSCristian Dumitrescu regarray[idx] += src;
3958c5d03ffdSCristian Dumitrescu }
3959c5d03ffdSCristian Dumitrescu
3960c5d03ffdSCristian Dumitrescu static inline void
__instr_regadd_rhi_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3961c5d03ffdSCristian Dumitrescu __instr_regadd_rhi_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3962c5d03ffdSCristian Dumitrescu {
3963c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3964c5d03ffdSCristian Dumitrescu
3965c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regadd (r[h] += i)\n", p->thread_id);
3966c5d03ffdSCristian Dumitrescu
3967c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3968c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_nbo(p, t, ip);
3969c5d03ffdSCristian Dumitrescu src = ip->regarray.dstsrc_val;
3970c5d03ffdSCristian Dumitrescu regarray[idx] += src;
3971c5d03ffdSCristian Dumitrescu }
3972c5d03ffdSCristian Dumitrescu
3973c5d03ffdSCristian Dumitrescu static inline void
__instr_regadd_rmi_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3974c5d03ffdSCristian Dumitrescu __instr_regadd_rmi_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3975c5d03ffdSCristian Dumitrescu {
3976c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3977c5d03ffdSCristian Dumitrescu
3978c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regadd (r[m] += i)\n", p->thread_id);
3979c5d03ffdSCristian Dumitrescu
3980c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3981c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_hbo(p, t, ip);
3982c5d03ffdSCristian Dumitrescu src = ip->regarray.dstsrc_val;
3983c5d03ffdSCristian Dumitrescu regarray[idx] += src;
3984c5d03ffdSCristian Dumitrescu }
3985c5d03ffdSCristian Dumitrescu
3986c5d03ffdSCristian Dumitrescu static inline void
__instr_regadd_rih_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)3987c5d03ffdSCristian Dumitrescu __instr_regadd_rih_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
3988c5d03ffdSCristian Dumitrescu {
3989c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
3990c5d03ffdSCristian Dumitrescu
3991c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regadd (r[i] += h)\n", p->thread_id);
3992c5d03ffdSCristian Dumitrescu
3993c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
3994c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_imm(p, ip);
3995c5d03ffdSCristian Dumitrescu src = instr_regarray_src_nbo(t, ip);
3996c5d03ffdSCristian Dumitrescu regarray[idx] += src;
3997c5d03ffdSCristian Dumitrescu }
3998c5d03ffdSCristian Dumitrescu
3999c5d03ffdSCristian Dumitrescu static inline void
__instr_regadd_rim_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)4000c5d03ffdSCristian Dumitrescu __instr_regadd_rim_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
4001c5d03ffdSCristian Dumitrescu {
4002c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
4003c5d03ffdSCristian Dumitrescu
4004c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regadd (r[i] += m)\n", p->thread_id);
4005c5d03ffdSCristian Dumitrescu
4006c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
4007c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_imm(p, ip);
4008c5d03ffdSCristian Dumitrescu src = instr_regarray_src_hbo(t, ip);
4009c5d03ffdSCristian Dumitrescu regarray[idx] += src;
4010c5d03ffdSCristian Dumitrescu }
4011c5d03ffdSCristian Dumitrescu
4012c5d03ffdSCristian Dumitrescu static inline void
__instr_regadd_rii_exec(struct rte_swx_pipeline * p,struct thread * t __rte_unused,const struct instruction * ip)4013c5d03ffdSCristian Dumitrescu __instr_regadd_rii_exec(struct rte_swx_pipeline *p,
4014c5d03ffdSCristian Dumitrescu struct thread *t __rte_unused,
4015c5d03ffdSCristian Dumitrescu const struct instruction *ip)
4016c5d03ffdSCristian Dumitrescu {
4017c5d03ffdSCristian Dumitrescu uint64_t *regarray, idx, src;
4018c5d03ffdSCristian Dumitrescu
4019c5d03ffdSCristian Dumitrescu TRACE("[Thread %2u] regadd (r[i] += i)\n", p->thread_id);
4020c5d03ffdSCristian Dumitrescu
4021c5d03ffdSCristian Dumitrescu regarray = instr_regarray_regarray(p, ip);
4022c5d03ffdSCristian Dumitrescu idx = instr_regarray_idx_imm(p, ip);
4023c5d03ffdSCristian Dumitrescu src = ip->regarray.dstsrc_val;
4024c5d03ffdSCristian Dumitrescu regarray[idx] += src;
4025c5d03ffdSCristian Dumitrescu }
4026c5d03ffdSCristian Dumitrescu
40270d5910ddSCristian Dumitrescu /*
40280d5910ddSCristian Dumitrescu * metarray.
40290d5910ddSCristian Dumitrescu */
40300d5910ddSCristian Dumitrescu static inline struct meter *
instr_meter_idx_hbo(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)40310d5910ddSCristian Dumitrescu instr_meter_idx_hbo(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
40320d5910ddSCristian Dumitrescu {
40330d5910ddSCristian Dumitrescu struct metarray_runtime *r = &p->metarray_runtime[ip->meter.metarray_id];
40340d5910ddSCristian Dumitrescu
40350d5910ddSCristian Dumitrescu uint8_t *idx_struct = t->structs[ip->meter.idx.struct_id];
40360d5910ddSCristian Dumitrescu uint64_t *idx64_ptr = (uint64_t *)&idx_struct[ip->meter.idx.offset];
40370d5910ddSCristian Dumitrescu uint64_t idx64 = *idx64_ptr;
40380d5910ddSCristian Dumitrescu uint64_t idx64_mask = UINT64_MAX >> (64 - (ip)->meter.idx.n_bits);
40390d5910ddSCristian Dumitrescu uint64_t idx = idx64 & idx64_mask & r->size_mask;
40400d5910ddSCristian Dumitrescu
40410d5910ddSCristian Dumitrescu return &r->metarray[idx];
40420d5910ddSCristian Dumitrescu }
40430d5910ddSCristian Dumitrescu
40440d5910ddSCristian Dumitrescu #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
40450d5910ddSCristian Dumitrescu
40460d5910ddSCristian Dumitrescu static inline struct meter *
instr_meter_idx_nbo(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)40470d5910ddSCristian Dumitrescu instr_meter_idx_nbo(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
40480d5910ddSCristian Dumitrescu {
40490d5910ddSCristian Dumitrescu struct metarray_runtime *r = &p->metarray_runtime[ip->meter.metarray_id];
40500d5910ddSCristian Dumitrescu
40510d5910ddSCristian Dumitrescu uint8_t *idx_struct = t->structs[ip->meter.idx.struct_id];
40520d5910ddSCristian Dumitrescu uint64_t *idx64_ptr = (uint64_t *)&idx_struct[ip->meter.idx.offset];
40530d5910ddSCristian Dumitrescu uint64_t idx64 = *idx64_ptr;
40540d5910ddSCristian Dumitrescu uint64_t idx = (ntoh64(idx64) >> (64 - ip->meter.idx.n_bits)) & r->size_mask;
40550d5910ddSCristian Dumitrescu
40560d5910ddSCristian Dumitrescu return &r->metarray[idx];
40570d5910ddSCristian Dumitrescu }
40580d5910ddSCristian Dumitrescu
40590d5910ddSCristian Dumitrescu #else
40600d5910ddSCristian Dumitrescu
40610d5910ddSCristian Dumitrescu #define instr_meter_idx_nbo instr_meter_idx_hbo
40620d5910ddSCristian Dumitrescu
40630d5910ddSCristian Dumitrescu #endif
40640d5910ddSCristian Dumitrescu
40650d5910ddSCristian Dumitrescu static inline struct meter *
instr_meter_idx_imm(struct rte_swx_pipeline * p,const struct instruction * ip)40660d5910ddSCristian Dumitrescu instr_meter_idx_imm(struct rte_swx_pipeline *p, const struct instruction *ip)
40670d5910ddSCristian Dumitrescu {
40680d5910ddSCristian Dumitrescu struct metarray_runtime *r = &p->metarray_runtime[ip->meter.metarray_id];
40690d5910ddSCristian Dumitrescu
40700d5910ddSCristian Dumitrescu uint64_t idx = ip->meter.idx_val & r->size_mask;
40710d5910ddSCristian Dumitrescu
40720d5910ddSCristian Dumitrescu return &r->metarray[idx];
40730d5910ddSCristian Dumitrescu }
40740d5910ddSCristian Dumitrescu
40750d5910ddSCristian Dumitrescu static inline uint32_t
instr_meter_length_hbo(struct thread * t,const struct instruction * ip)40760d5910ddSCristian Dumitrescu instr_meter_length_hbo(struct thread *t, const struct instruction *ip)
40770d5910ddSCristian Dumitrescu {
40780d5910ddSCristian Dumitrescu uint8_t *src_struct = t->structs[ip->meter.length.struct_id];
40790d5910ddSCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[ip->meter.length.offset];
40800d5910ddSCristian Dumitrescu uint64_t src64 = *src64_ptr;
40810d5910ddSCristian Dumitrescu uint64_t src64_mask = UINT64_MAX >> (64 - (ip)->meter.length.n_bits);
40820d5910ddSCristian Dumitrescu uint64_t src = src64 & src64_mask;
40830d5910ddSCristian Dumitrescu
40840d5910ddSCristian Dumitrescu return (uint32_t)src;
40850d5910ddSCristian Dumitrescu }
40860d5910ddSCristian Dumitrescu
40870d5910ddSCristian Dumitrescu #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
40880d5910ddSCristian Dumitrescu
40890d5910ddSCristian Dumitrescu static inline uint32_t
instr_meter_length_nbo(struct thread * t,const struct instruction * ip)40900d5910ddSCristian Dumitrescu instr_meter_length_nbo(struct thread *t, const struct instruction *ip)
40910d5910ddSCristian Dumitrescu {
40920d5910ddSCristian Dumitrescu uint8_t *src_struct = t->structs[ip->meter.length.struct_id];
40930d5910ddSCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[ip->meter.length.offset];
40940d5910ddSCristian Dumitrescu uint64_t src64 = *src64_ptr;
40950d5910ddSCristian Dumitrescu uint64_t src = ntoh64(src64) >> (64 - ip->meter.length.n_bits);
40960d5910ddSCristian Dumitrescu
40970d5910ddSCristian Dumitrescu return (uint32_t)src;
40980d5910ddSCristian Dumitrescu }
40990d5910ddSCristian Dumitrescu
41000d5910ddSCristian Dumitrescu #else
41010d5910ddSCristian Dumitrescu
41020d5910ddSCristian Dumitrescu #define instr_meter_length_nbo instr_meter_length_hbo
41030d5910ddSCristian Dumitrescu
41040d5910ddSCristian Dumitrescu #endif
41050d5910ddSCristian Dumitrescu
41060d5910ddSCristian Dumitrescu static inline enum rte_color
instr_meter_color_in_hbo(struct thread * t,const struct instruction * ip)41070d5910ddSCristian Dumitrescu instr_meter_color_in_hbo(struct thread *t, const struct instruction *ip)
41080d5910ddSCristian Dumitrescu {
41090d5910ddSCristian Dumitrescu uint8_t *src_struct = t->structs[ip->meter.color_in.struct_id];
41100d5910ddSCristian Dumitrescu uint64_t *src64_ptr = (uint64_t *)&src_struct[ip->meter.color_in.offset];
41110d5910ddSCristian Dumitrescu uint64_t src64 = *src64_ptr;
41120d5910ddSCristian Dumitrescu uint64_t src64_mask = UINT64_MAX >> (64 - ip->meter.color_in.n_bits);
41130d5910ddSCristian Dumitrescu uint64_t src = src64 & src64_mask;
41140d5910ddSCristian Dumitrescu
41150d5910ddSCristian Dumitrescu return (enum rte_color)src;
41160d5910ddSCristian Dumitrescu }
41170d5910ddSCristian Dumitrescu
41180d5910ddSCristian Dumitrescu static inline void
instr_meter_color_out_hbo_set(struct thread * t,const struct instruction * ip,enum rte_color color_out)41190d5910ddSCristian Dumitrescu instr_meter_color_out_hbo_set(struct thread *t,
41200d5910ddSCristian Dumitrescu const struct instruction *ip,
41210d5910ddSCristian Dumitrescu enum rte_color color_out)
41220d5910ddSCristian Dumitrescu {
41230d5910ddSCristian Dumitrescu uint8_t *dst_struct = t->structs[ip->meter.color_out.struct_id];
41240d5910ddSCristian Dumitrescu uint64_t *dst64_ptr = (uint64_t *)&dst_struct[ip->meter.color_out.offset];
41250d5910ddSCristian Dumitrescu uint64_t dst64 = *dst64_ptr;
41260d5910ddSCristian Dumitrescu uint64_t dst64_mask = UINT64_MAX >> (64 - ip->meter.color_out.n_bits);
41270d5910ddSCristian Dumitrescu
41280d5910ddSCristian Dumitrescu uint64_t src = (uint64_t)color_out;
41290d5910ddSCristian Dumitrescu
41300d5910ddSCristian Dumitrescu *dst64_ptr = (dst64 & ~dst64_mask) | (src & dst64_mask);
41310d5910ddSCristian Dumitrescu }
41320d5910ddSCristian Dumitrescu
41330d5910ddSCristian Dumitrescu static inline void
__instr_metprefetch_h_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)41340d5910ddSCristian Dumitrescu __instr_metprefetch_h_exec(struct rte_swx_pipeline *p,
41350d5910ddSCristian Dumitrescu struct thread *t,
41360d5910ddSCristian Dumitrescu const struct instruction *ip)
41370d5910ddSCristian Dumitrescu {
41380d5910ddSCristian Dumitrescu struct meter *m;
41390d5910ddSCristian Dumitrescu
41400d5910ddSCristian Dumitrescu TRACE("[Thread %2u] metprefetch (h)\n", p->thread_id);
41410d5910ddSCristian Dumitrescu
41420d5910ddSCristian Dumitrescu m = instr_meter_idx_nbo(p, t, ip);
41430d5910ddSCristian Dumitrescu rte_prefetch0(m);
41440d5910ddSCristian Dumitrescu }
41450d5910ddSCristian Dumitrescu
41460d5910ddSCristian Dumitrescu static inline void
__instr_metprefetch_m_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)41470d5910ddSCristian Dumitrescu __instr_metprefetch_m_exec(struct rte_swx_pipeline *p,
41480d5910ddSCristian Dumitrescu struct thread *t,
41490d5910ddSCristian Dumitrescu const struct instruction *ip)
41500d5910ddSCristian Dumitrescu {
41510d5910ddSCristian Dumitrescu struct meter *m;
41520d5910ddSCristian Dumitrescu
41530d5910ddSCristian Dumitrescu TRACE("[Thread %2u] metprefetch (m)\n", p->thread_id);
41540d5910ddSCristian Dumitrescu
41550d5910ddSCristian Dumitrescu m = instr_meter_idx_hbo(p, t, ip);
41560d5910ddSCristian Dumitrescu rte_prefetch0(m);
41570d5910ddSCristian Dumitrescu }
41580d5910ddSCristian Dumitrescu
41590d5910ddSCristian Dumitrescu static inline void
__instr_metprefetch_i_exec(struct rte_swx_pipeline * p,struct thread * t __rte_unused,const struct instruction * ip)41600d5910ddSCristian Dumitrescu __instr_metprefetch_i_exec(struct rte_swx_pipeline *p,
41610d5910ddSCristian Dumitrescu struct thread *t __rte_unused,
41620d5910ddSCristian Dumitrescu const struct instruction *ip)
41630d5910ddSCristian Dumitrescu {
41640d5910ddSCristian Dumitrescu struct meter *m;
41650d5910ddSCristian Dumitrescu
41660d5910ddSCristian Dumitrescu TRACE("[Thread %2u] metprefetch (i)\n", p->thread_id);
41670d5910ddSCristian Dumitrescu
41680d5910ddSCristian Dumitrescu m = instr_meter_idx_imm(p, ip);
41690d5910ddSCristian Dumitrescu rte_prefetch0(m);
41700d5910ddSCristian Dumitrescu }
41710d5910ddSCristian Dumitrescu
41720d5910ddSCristian Dumitrescu static inline void
__instr_meter_hhm_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)41730d5910ddSCristian Dumitrescu __instr_meter_hhm_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
41740d5910ddSCristian Dumitrescu {
41750d5910ddSCristian Dumitrescu struct meter *m;
41760d5910ddSCristian Dumitrescu uint64_t time, n_pkts, n_bytes;
41770d5910ddSCristian Dumitrescu uint32_t length;
41780d5910ddSCristian Dumitrescu enum rte_color color_in, color_out;
41790d5910ddSCristian Dumitrescu
41800d5910ddSCristian Dumitrescu TRACE("[Thread %2u] meter (hhm)\n", p->thread_id);
41810d5910ddSCristian Dumitrescu
41820d5910ddSCristian Dumitrescu m = instr_meter_idx_nbo(p, t, ip);
41830d5910ddSCristian Dumitrescu rte_prefetch0(m->n_pkts);
41840d5910ddSCristian Dumitrescu time = rte_get_tsc_cycles();
41850d5910ddSCristian Dumitrescu length = instr_meter_length_nbo(t, ip);
41860d5910ddSCristian Dumitrescu color_in = instr_meter_color_in_hbo(t, ip);
41870d5910ddSCristian Dumitrescu
41880d5910ddSCristian Dumitrescu color_out = rte_meter_trtcm_color_aware_check(&m->m,
41890d5910ddSCristian Dumitrescu &m->profile->profile,
41900d5910ddSCristian Dumitrescu time,
41910d5910ddSCristian Dumitrescu length,
41920d5910ddSCristian Dumitrescu color_in);
41930d5910ddSCristian Dumitrescu
41940d5910ddSCristian Dumitrescu color_out &= m->color_mask;
41950d5910ddSCristian Dumitrescu
41960d5910ddSCristian Dumitrescu n_pkts = m->n_pkts[color_out];
41970d5910ddSCristian Dumitrescu n_bytes = m->n_bytes[color_out];
41980d5910ddSCristian Dumitrescu
41990d5910ddSCristian Dumitrescu instr_meter_color_out_hbo_set(t, ip, color_out);
42000d5910ddSCristian Dumitrescu
42010d5910ddSCristian Dumitrescu m->n_pkts[color_out] = n_pkts + 1;
42020d5910ddSCristian Dumitrescu m->n_bytes[color_out] = n_bytes + length;
42030d5910ddSCristian Dumitrescu }
42040d5910ddSCristian Dumitrescu
42050d5910ddSCristian Dumitrescu static inline void
__instr_meter_hhi_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)42060d5910ddSCristian Dumitrescu __instr_meter_hhi_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
42070d5910ddSCristian Dumitrescu {
42080d5910ddSCristian Dumitrescu struct meter *m;
42090d5910ddSCristian Dumitrescu uint64_t time, n_pkts, n_bytes;
42100d5910ddSCristian Dumitrescu uint32_t length;
42110d5910ddSCristian Dumitrescu enum rte_color color_in, color_out;
42120d5910ddSCristian Dumitrescu
42130d5910ddSCristian Dumitrescu TRACE("[Thread %2u] meter (hhi)\n", p->thread_id);
42140d5910ddSCristian Dumitrescu
42150d5910ddSCristian Dumitrescu m = instr_meter_idx_nbo(p, t, ip);
42160d5910ddSCristian Dumitrescu rte_prefetch0(m->n_pkts);
42170d5910ddSCristian Dumitrescu time = rte_get_tsc_cycles();
42180d5910ddSCristian Dumitrescu length = instr_meter_length_nbo(t, ip);
42190d5910ddSCristian Dumitrescu color_in = (enum rte_color)ip->meter.color_in_val;
42200d5910ddSCristian Dumitrescu
42210d5910ddSCristian Dumitrescu color_out = rte_meter_trtcm_color_aware_check(&m->m,
42220d5910ddSCristian Dumitrescu &m->profile->profile,
42230d5910ddSCristian Dumitrescu time,
42240d5910ddSCristian Dumitrescu length,
42250d5910ddSCristian Dumitrescu color_in);
42260d5910ddSCristian Dumitrescu
42270d5910ddSCristian Dumitrescu color_out &= m->color_mask;
42280d5910ddSCristian Dumitrescu
42290d5910ddSCristian Dumitrescu n_pkts = m->n_pkts[color_out];
42300d5910ddSCristian Dumitrescu n_bytes = m->n_bytes[color_out];
42310d5910ddSCristian Dumitrescu
42320d5910ddSCristian Dumitrescu instr_meter_color_out_hbo_set(t, ip, color_out);
42330d5910ddSCristian Dumitrescu
42340d5910ddSCristian Dumitrescu m->n_pkts[color_out] = n_pkts + 1;
42350d5910ddSCristian Dumitrescu m->n_bytes[color_out] = n_bytes + length;
42360d5910ddSCristian Dumitrescu }
42370d5910ddSCristian Dumitrescu
42380d5910ddSCristian Dumitrescu static inline void
__instr_meter_hmm_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)42390d5910ddSCristian Dumitrescu __instr_meter_hmm_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
42400d5910ddSCristian Dumitrescu {
42410d5910ddSCristian Dumitrescu struct meter *m;
42420d5910ddSCristian Dumitrescu uint64_t time, n_pkts, n_bytes;
42430d5910ddSCristian Dumitrescu uint32_t length;
42440d5910ddSCristian Dumitrescu enum rte_color color_in, color_out;
42450d5910ddSCristian Dumitrescu
42460d5910ddSCristian Dumitrescu TRACE("[Thread %2u] meter (hmm)\n", p->thread_id);
42470d5910ddSCristian Dumitrescu
42480d5910ddSCristian Dumitrescu m = instr_meter_idx_nbo(p, t, ip);
42490d5910ddSCristian Dumitrescu rte_prefetch0(m->n_pkts);
42500d5910ddSCristian Dumitrescu time = rte_get_tsc_cycles();
42510d5910ddSCristian Dumitrescu length = instr_meter_length_hbo(t, ip);
42520d5910ddSCristian Dumitrescu color_in = instr_meter_color_in_hbo(t, ip);
42530d5910ddSCristian Dumitrescu
42540d5910ddSCristian Dumitrescu color_out = rte_meter_trtcm_color_aware_check(&m->m,
42550d5910ddSCristian Dumitrescu &m->profile->profile,
42560d5910ddSCristian Dumitrescu time,
42570d5910ddSCristian Dumitrescu length,
42580d5910ddSCristian Dumitrescu color_in);
42590d5910ddSCristian Dumitrescu
42600d5910ddSCristian Dumitrescu color_out &= m->color_mask;
42610d5910ddSCristian Dumitrescu
42620d5910ddSCristian Dumitrescu n_pkts = m->n_pkts[color_out];
42630d5910ddSCristian Dumitrescu n_bytes = m->n_bytes[color_out];
42640d5910ddSCristian Dumitrescu
42650d5910ddSCristian Dumitrescu instr_meter_color_out_hbo_set(t, ip, color_out);
42660d5910ddSCristian Dumitrescu
42670d5910ddSCristian Dumitrescu m->n_pkts[color_out] = n_pkts + 1;
42680d5910ddSCristian Dumitrescu m->n_bytes[color_out] = n_bytes + length;
42690d5910ddSCristian Dumitrescu }
42700d5910ddSCristian Dumitrescu
42710d5910ddSCristian Dumitrescu static inline void
__instr_meter_hmi_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)42720d5910ddSCristian Dumitrescu __instr_meter_hmi_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
42730d5910ddSCristian Dumitrescu {
42740d5910ddSCristian Dumitrescu struct meter *m;
42750d5910ddSCristian Dumitrescu uint64_t time, n_pkts, n_bytes;
42760d5910ddSCristian Dumitrescu uint32_t length;
42770d5910ddSCristian Dumitrescu enum rte_color color_in, color_out;
42780d5910ddSCristian Dumitrescu
42790d5910ddSCristian Dumitrescu TRACE("[Thread %2u] meter (hmi)\n", p->thread_id);
42800d5910ddSCristian Dumitrescu
42810d5910ddSCristian Dumitrescu m = instr_meter_idx_nbo(p, t, ip);
42820d5910ddSCristian Dumitrescu rte_prefetch0(m->n_pkts);
42830d5910ddSCristian Dumitrescu time = rte_get_tsc_cycles();
42840d5910ddSCristian Dumitrescu length = instr_meter_length_hbo(t, ip);
42850d5910ddSCristian Dumitrescu color_in = (enum rte_color)ip->meter.color_in_val;
42860d5910ddSCristian Dumitrescu
42870d5910ddSCristian Dumitrescu color_out = rte_meter_trtcm_color_aware_check(&m->m,
42880d5910ddSCristian Dumitrescu &m->profile->profile,
42890d5910ddSCristian Dumitrescu time,
42900d5910ddSCristian Dumitrescu length,
42910d5910ddSCristian Dumitrescu color_in);
42920d5910ddSCristian Dumitrescu
42930d5910ddSCristian Dumitrescu color_out &= m->color_mask;
42940d5910ddSCristian Dumitrescu
42950d5910ddSCristian Dumitrescu n_pkts = m->n_pkts[color_out];
42960d5910ddSCristian Dumitrescu n_bytes = m->n_bytes[color_out];
42970d5910ddSCristian Dumitrescu
42980d5910ddSCristian Dumitrescu instr_meter_color_out_hbo_set(t, ip, color_out);
42990d5910ddSCristian Dumitrescu
43000d5910ddSCristian Dumitrescu m->n_pkts[color_out] = n_pkts + 1;
43010d5910ddSCristian Dumitrescu m->n_bytes[color_out] = n_bytes + length;
43020d5910ddSCristian Dumitrescu }
43030d5910ddSCristian Dumitrescu
43040d5910ddSCristian Dumitrescu static inline void
__instr_meter_mhm_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)43050d5910ddSCristian Dumitrescu __instr_meter_mhm_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
43060d5910ddSCristian Dumitrescu {
43070d5910ddSCristian Dumitrescu struct meter *m;
43080d5910ddSCristian Dumitrescu uint64_t time, n_pkts, n_bytes;
43090d5910ddSCristian Dumitrescu uint32_t length;
43100d5910ddSCristian Dumitrescu enum rte_color color_in, color_out;
43110d5910ddSCristian Dumitrescu
43120d5910ddSCristian Dumitrescu TRACE("[Thread %2u] meter (mhm)\n", p->thread_id);
43130d5910ddSCristian Dumitrescu
43140d5910ddSCristian Dumitrescu m = instr_meter_idx_hbo(p, t, ip);
43150d5910ddSCristian Dumitrescu rte_prefetch0(m->n_pkts);
43160d5910ddSCristian Dumitrescu time = rte_get_tsc_cycles();
43170d5910ddSCristian Dumitrescu length = instr_meter_length_nbo(t, ip);
43180d5910ddSCristian Dumitrescu color_in = instr_meter_color_in_hbo(t, ip);
43190d5910ddSCristian Dumitrescu
43200d5910ddSCristian Dumitrescu color_out = rte_meter_trtcm_color_aware_check(&m->m,
43210d5910ddSCristian Dumitrescu &m->profile->profile,
43220d5910ddSCristian Dumitrescu time,
43230d5910ddSCristian Dumitrescu length,
43240d5910ddSCristian Dumitrescu color_in);
43250d5910ddSCristian Dumitrescu
43260d5910ddSCristian Dumitrescu color_out &= m->color_mask;
43270d5910ddSCristian Dumitrescu
43280d5910ddSCristian Dumitrescu n_pkts = m->n_pkts[color_out];
43290d5910ddSCristian Dumitrescu n_bytes = m->n_bytes[color_out];
43300d5910ddSCristian Dumitrescu
43310d5910ddSCristian Dumitrescu instr_meter_color_out_hbo_set(t, ip, color_out);
43320d5910ddSCristian Dumitrescu
43330d5910ddSCristian Dumitrescu m->n_pkts[color_out] = n_pkts + 1;
43340d5910ddSCristian Dumitrescu m->n_bytes[color_out] = n_bytes + length;
43350d5910ddSCristian Dumitrescu }
43360d5910ddSCristian Dumitrescu
43370d5910ddSCristian Dumitrescu static inline void
__instr_meter_mhi_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)43380d5910ddSCristian Dumitrescu __instr_meter_mhi_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
43390d5910ddSCristian Dumitrescu {
43400d5910ddSCristian Dumitrescu struct meter *m;
43410d5910ddSCristian Dumitrescu uint64_t time, n_pkts, n_bytes;
43420d5910ddSCristian Dumitrescu uint32_t length;
43430d5910ddSCristian Dumitrescu enum rte_color color_in, color_out;
43440d5910ddSCristian Dumitrescu
43450d5910ddSCristian Dumitrescu TRACE("[Thread %2u] meter (mhi)\n", p->thread_id);
43460d5910ddSCristian Dumitrescu
43470d5910ddSCristian Dumitrescu m = instr_meter_idx_hbo(p, t, ip);
43480d5910ddSCristian Dumitrescu rte_prefetch0(m->n_pkts);
43490d5910ddSCristian Dumitrescu time = rte_get_tsc_cycles();
43500d5910ddSCristian Dumitrescu length = instr_meter_length_nbo(t, ip);
43510d5910ddSCristian Dumitrescu color_in = (enum rte_color)ip->meter.color_in_val;
43520d5910ddSCristian Dumitrescu
43530d5910ddSCristian Dumitrescu color_out = rte_meter_trtcm_color_aware_check(&m->m,
43540d5910ddSCristian Dumitrescu &m->profile->profile,
43550d5910ddSCristian Dumitrescu time,
43560d5910ddSCristian Dumitrescu length,
43570d5910ddSCristian Dumitrescu color_in);
43580d5910ddSCristian Dumitrescu
43590d5910ddSCristian Dumitrescu color_out &= m->color_mask;
43600d5910ddSCristian Dumitrescu
43610d5910ddSCristian Dumitrescu n_pkts = m->n_pkts[color_out];
43620d5910ddSCristian Dumitrescu n_bytes = m->n_bytes[color_out];
43630d5910ddSCristian Dumitrescu
43640d5910ddSCristian Dumitrescu instr_meter_color_out_hbo_set(t, ip, color_out);
43650d5910ddSCristian Dumitrescu
43660d5910ddSCristian Dumitrescu m->n_pkts[color_out] = n_pkts + 1;
43670d5910ddSCristian Dumitrescu m->n_bytes[color_out] = n_bytes + length;
43680d5910ddSCristian Dumitrescu }
43690d5910ddSCristian Dumitrescu
43700d5910ddSCristian Dumitrescu static inline void
__instr_meter_mmm_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)43710d5910ddSCristian Dumitrescu __instr_meter_mmm_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
43720d5910ddSCristian Dumitrescu {
43730d5910ddSCristian Dumitrescu struct meter *m;
43740d5910ddSCristian Dumitrescu uint64_t time, n_pkts, n_bytes;
43750d5910ddSCristian Dumitrescu uint32_t length;
43760d5910ddSCristian Dumitrescu enum rte_color color_in, color_out;
43770d5910ddSCristian Dumitrescu
43780d5910ddSCristian Dumitrescu TRACE("[Thread %2u] meter (mmm)\n", p->thread_id);
43790d5910ddSCristian Dumitrescu
43800d5910ddSCristian Dumitrescu m = instr_meter_idx_hbo(p, t, ip);
43810d5910ddSCristian Dumitrescu rte_prefetch0(m->n_pkts);
43820d5910ddSCristian Dumitrescu time = rte_get_tsc_cycles();
43830d5910ddSCristian Dumitrescu length = instr_meter_length_hbo(t, ip);
43840d5910ddSCristian Dumitrescu color_in = instr_meter_color_in_hbo(t, ip);
43850d5910ddSCristian Dumitrescu
43860d5910ddSCristian Dumitrescu color_out = rte_meter_trtcm_color_aware_check(&m->m,
43870d5910ddSCristian Dumitrescu &m->profile->profile,
43880d5910ddSCristian Dumitrescu time,
43890d5910ddSCristian Dumitrescu length,
43900d5910ddSCristian Dumitrescu color_in);
43910d5910ddSCristian Dumitrescu
43920d5910ddSCristian Dumitrescu color_out &= m->color_mask;
43930d5910ddSCristian Dumitrescu
43940d5910ddSCristian Dumitrescu n_pkts = m->n_pkts[color_out];
43950d5910ddSCristian Dumitrescu n_bytes = m->n_bytes[color_out];
43960d5910ddSCristian Dumitrescu
43970d5910ddSCristian Dumitrescu instr_meter_color_out_hbo_set(t, ip, color_out);
43980d5910ddSCristian Dumitrescu
43990d5910ddSCristian Dumitrescu m->n_pkts[color_out] = n_pkts + 1;
44000d5910ddSCristian Dumitrescu m->n_bytes[color_out] = n_bytes + length;
44010d5910ddSCristian Dumitrescu }
44020d5910ddSCristian Dumitrescu
44030d5910ddSCristian Dumitrescu static inline void
__instr_meter_mmi_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)44040d5910ddSCristian Dumitrescu __instr_meter_mmi_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
44050d5910ddSCristian Dumitrescu {
44060d5910ddSCristian Dumitrescu struct meter *m;
44070d5910ddSCristian Dumitrescu uint64_t time, n_pkts, n_bytes;
44080d5910ddSCristian Dumitrescu uint32_t length;
44090d5910ddSCristian Dumitrescu enum rte_color color_in, color_out;
44100d5910ddSCristian Dumitrescu
44110d5910ddSCristian Dumitrescu TRACE("[Thread %2u] meter (mmi)\n", p->thread_id);
44120d5910ddSCristian Dumitrescu
44130d5910ddSCristian Dumitrescu m = instr_meter_idx_hbo(p, t, ip);
44140d5910ddSCristian Dumitrescu rte_prefetch0(m->n_pkts);
44150d5910ddSCristian Dumitrescu time = rte_get_tsc_cycles();
44160d5910ddSCristian Dumitrescu length = instr_meter_length_hbo(t, ip);
44170d5910ddSCristian Dumitrescu color_in = (enum rte_color)ip->meter.color_in_val;
44180d5910ddSCristian Dumitrescu
44190d5910ddSCristian Dumitrescu color_out = rte_meter_trtcm_color_aware_check(&m->m,
44200d5910ddSCristian Dumitrescu &m->profile->profile,
44210d5910ddSCristian Dumitrescu time,
44220d5910ddSCristian Dumitrescu length,
44230d5910ddSCristian Dumitrescu color_in);
44240d5910ddSCristian Dumitrescu
44250d5910ddSCristian Dumitrescu color_out &= m->color_mask;
44260d5910ddSCristian Dumitrescu
44270d5910ddSCristian Dumitrescu n_pkts = m->n_pkts[color_out];
44280d5910ddSCristian Dumitrescu n_bytes = m->n_bytes[color_out];
44290d5910ddSCristian Dumitrescu
44300d5910ddSCristian Dumitrescu instr_meter_color_out_hbo_set(t, ip, color_out);
44310d5910ddSCristian Dumitrescu
44320d5910ddSCristian Dumitrescu m->n_pkts[color_out] = n_pkts + 1;
44330d5910ddSCristian Dumitrescu m->n_bytes[color_out] = n_bytes + length;
44340d5910ddSCristian Dumitrescu }
44350d5910ddSCristian Dumitrescu
44360d5910ddSCristian Dumitrescu static inline void
__instr_meter_ihm_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)44370d5910ddSCristian Dumitrescu __instr_meter_ihm_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
44380d5910ddSCristian Dumitrescu {
44390d5910ddSCristian Dumitrescu struct meter *m;
44400d5910ddSCristian Dumitrescu uint64_t time, n_pkts, n_bytes;
44410d5910ddSCristian Dumitrescu uint32_t length;
44420d5910ddSCristian Dumitrescu enum rte_color color_in, color_out;
44430d5910ddSCristian Dumitrescu
44440d5910ddSCristian Dumitrescu TRACE("[Thread %2u] meter (ihm)\n", p->thread_id);
44450d5910ddSCristian Dumitrescu
44460d5910ddSCristian Dumitrescu m = instr_meter_idx_imm(p, ip);
44470d5910ddSCristian Dumitrescu rte_prefetch0(m->n_pkts);
44480d5910ddSCristian Dumitrescu time = rte_get_tsc_cycles();
44490d5910ddSCristian Dumitrescu length = instr_meter_length_nbo(t, ip);
44500d5910ddSCristian Dumitrescu color_in = instr_meter_color_in_hbo(t, ip);
44510d5910ddSCristian Dumitrescu
44520d5910ddSCristian Dumitrescu color_out = rte_meter_trtcm_color_aware_check(&m->m,
44530d5910ddSCristian Dumitrescu &m->profile->profile,
44540d5910ddSCristian Dumitrescu time,
44550d5910ddSCristian Dumitrescu length,
44560d5910ddSCristian Dumitrescu color_in);
44570d5910ddSCristian Dumitrescu
44580d5910ddSCristian Dumitrescu color_out &= m->color_mask;
44590d5910ddSCristian Dumitrescu
44600d5910ddSCristian Dumitrescu n_pkts = m->n_pkts[color_out];
44610d5910ddSCristian Dumitrescu n_bytes = m->n_bytes[color_out];
44620d5910ddSCristian Dumitrescu
44630d5910ddSCristian Dumitrescu instr_meter_color_out_hbo_set(t, ip, color_out);
44640d5910ddSCristian Dumitrescu
44650d5910ddSCristian Dumitrescu m->n_pkts[color_out] = n_pkts + 1;
44660d5910ddSCristian Dumitrescu m->n_bytes[color_out] = n_bytes + length;
44670d5910ddSCristian Dumitrescu }
44680d5910ddSCristian Dumitrescu
44690d5910ddSCristian Dumitrescu static inline void
__instr_meter_ihi_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)44700d5910ddSCristian Dumitrescu __instr_meter_ihi_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
44710d5910ddSCristian Dumitrescu {
44720d5910ddSCristian Dumitrescu struct meter *m;
44730d5910ddSCristian Dumitrescu uint64_t time, n_pkts, n_bytes;
44740d5910ddSCristian Dumitrescu uint32_t length;
44750d5910ddSCristian Dumitrescu enum rte_color color_in, color_out;
44760d5910ddSCristian Dumitrescu
44770d5910ddSCristian Dumitrescu TRACE("[Thread %2u] meter (ihi)\n", p->thread_id);
44780d5910ddSCristian Dumitrescu
44790d5910ddSCristian Dumitrescu m = instr_meter_idx_imm(p, ip);
44800d5910ddSCristian Dumitrescu rte_prefetch0(m->n_pkts);
44810d5910ddSCristian Dumitrescu time = rte_get_tsc_cycles();
44820d5910ddSCristian Dumitrescu length = instr_meter_length_nbo(t, ip);
44830d5910ddSCristian Dumitrescu color_in = (enum rte_color)ip->meter.color_in_val;
44840d5910ddSCristian Dumitrescu
44850d5910ddSCristian Dumitrescu color_out = rte_meter_trtcm_color_aware_check(&m->m,
44860d5910ddSCristian Dumitrescu &m->profile->profile,
44870d5910ddSCristian Dumitrescu time,
44880d5910ddSCristian Dumitrescu length,
44890d5910ddSCristian Dumitrescu color_in);
44900d5910ddSCristian Dumitrescu
44910d5910ddSCristian Dumitrescu color_out &= m->color_mask;
44920d5910ddSCristian Dumitrescu
44930d5910ddSCristian Dumitrescu n_pkts = m->n_pkts[color_out];
44940d5910ddSCristian Dumitrescu n_bytes = m->n_bytes[color_out];
44950d5910ddSCristian Dumitrescu
44960d5910ddSCristian Dumitrescu instr_meter_color_out_hbo_set(t, ip, color_out);
44970d5910ddSCristian Dumitrescu
44980d5910ddSCristian Dumitrescu m->n_pkts[color_out] = n_pkts + 1;
44990d5910ddSCristian Dumitrescu m->n_bytes[color_out] = n_bytes + length;
45000d5910ddSCristian Dumitrescu }
45010d5910ddSCristian Dumitrescu
45020d5910ddSCristian Dumitrescu static inline void
__instr_meter_imm_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)45030d5910ddSCristian Dumitrescu __instr_meter_imm_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
45040d5910ddSCristian Dumitrescu {
45050d5910ddSCristian Dumitrescu struct meter *m;
45060d5910ddSCristian Dumitrescu uint64_t time, n_pkts, n_bytes;
45070d5910ddSCristian Dumitrescu uint32_t length;
45080d5910ddSCristian Dumitrescu enum rte_color color_in, color_out;
45090d5910ddSCristian Dumitrescu
45100d5910ddSCristian Dumitrescu TRACE("[Thread %2u] meter (imm)\n", p->thread_id);
45110d5910ddSCristian Dumitrescu
45120d5910ddSCristian Dumitrescu m = instr_meter_idx_imm(p, ip);
45130d5910ddSCristian Dumitrescu rte_prefetch0(m->n_pkts);
45140d5910ddSCristian Dumitrescu time = rte_get_tsc_cycles();
45150d5910ddSCristian Dumitrescu length = instr_meter_length_hbo(t, ip);
45160d5910ddSCristian Dumitrescu color_in = instr_meter_color_in_hbo(t, ip);
45170d5910ddSCristian Dumitrescu
45180d5910ddSCristian Dumitrescu color_out = rte_meter_trtcm_color_aware_check(&m->m,
45190d5910ddSCristian Dumitrescu &m->profile->profile,
45200d5910ddSCristian Dumitrescu time,
45210d5910ddSCristian Dumitrescu length,
45220d5910ddSCristian Dumitrescu color_in);
45230d5910ddSCristian Dumitrescu
45240d5910ddSCristian Dumitrescu color_out &= m->color_mask;
45250d5910ddSCristian Dumitrescu
45260d5910ddSCristian Dumitrescu n_pkts = m->n_pkts[color_out];
45270d5910ddSCristian Dumitrescu n_bytes = m->n_bytes[color_out];
45280d5910ddSCristian Dumitrescu
45290d5910ddSCristian Dumitrescu instr_meter_color_out_hbo_set(t, ip, color_out);
45300d5910ddSCristian Dumitrescu
45310d5910ddSCristian Dumitrescu m->n_pkts[color_out] = n_pkts + 1;
45320d5910ddSCristian Dumitrescu m->n_bytes[color_out] = n_bytes + length;
45330d5910ddSCristian Dumitrescu }
45340d5910ddSCristian Dumitrescu
45350d5910ddSCristian Dumitrescu static inline void
__instr_meter_imi_exec(struct rte_swx_pipeline * p,struct thread * t,const struct instruction * ip)45360d5910ddSCristian Dumitrescu __instr_meter_imi_exec(struct rte_swx_pipeline *p, struct thread *t, const struct instruction *ip)
45370d5910ddSCristian Dumitrescu {
45380d5910ddSCristian Dumitrescu struct meter *m;
45390d5910ddSCristian Dumitrescu uint64_t time, n_pkts, n_bytes;
45400d5910ddSCristian Dumitrescu uint32_t length;
45410d5910ddSCristian Dumitrescu enum rte_color color_in, color_out;
45420d5910ddSCristian Dumitrescu
45430d5910ddSCristian Dumitrescu TRACE("[Thread %2u] meter (imi)\n", p->thread_id);
45440d5910ddSCristian Dumitrescu
45450d5910ddSCristian Dumitrescu m = instr_meter_idx_imm(p, ip);
45460d5910ddSCristian Dumitrescu rte_prefetch0(m->n_pkts);
45470d5910ddSCristian Dumitrescu time = rte_get_tsc_cycles();
45480d5910ddSCristian Dumitrescu length = instr_meter_length_hbo(t, ip);
45490d5910ddSCristian Dumitrescu color_in = (enum rte_color)ip->meter.color_in_val;
45500d5910ddSCristian Dumitrescu
45510d5910ddSCristian Dumitrescu color_out = rte_meter_trtcm_color_aware_check(&m->m,
45520d5910ddSCristian Dumitrescu &m->profile->profile,
45530d5910ddSCristian Dumitrescu time,
45540d5910ddSCristian Dumitrescu length,
45550d5910ddSCristian Dumitrescu color_in);
45560d5910ddSCristian Dumitrescu
45570d5910ddSCristian Dumitrescu color_out &= m->color_mask;
45580d5910ddSCristian Dumitrescu
45590d5910ddSCristian Dumitrescu n_pkts = m->n_pkts[color_out];
45600d5910ddSCristian Dumitrescu n_bytes = m->n_bytes[color_out];
45610d5910ddSCristian Dumitrescu
45620d5910ddSCristian Dumitrescu instr_meter_color_out_hbo_set(t, ip, color_out);
45630d5910ddSCristian Dumitrescu
45640d5910ddSCristian Dumitrescu m->n_pkts[color_out] = n_pkts + 1;
45650d5910ddSCristian Dumitrescu m->n_bytes[color_out] = n_bytes + length;
45660d5910ddSCristian Dumitrescu }
45670d5910ddSCristian Dumitrescu
456897b8278aSCristian Dumitrescu #endif
4569