25typedef __u32 PortId_t;
26typedef __u64 Timestamp_t;
27typedef __u8 ClassOfService_t;
28typedef __u16 CloneSessionId_t;
29typedef __u32 MulticastGroup_t;
30typedef __u16 EgressInstance_t;
31typedef __u8 MirrorSlotId_t;
32typedef __u16 MirrorSessionId_t;
35typedef __u8 ParserError_t;
36static const ParserError_t NoError = 0;
37static const ParserError_t PacketTooShort = 1;
38static const ParserError_t NoMatch = 2;
39static const ParserError_t StackOutOfBounds = 3;
40static const ParserError_t HeaderTooShort = 4;
41static const ParserError_t ParserTimeout = 5;
42static const ParserError_t ParserInvalidArgument = 6;
45enum PNA_Source_t { FROM_HOST, FROM_NET };
47enum PNA_MeterColor_t { RED, GREEN, YELLOW };
49enum MirrorType { NO_MIRROR, PRE_MODIFY, POST_MODIFY };
54} __attribute__((aligned(4)));
60 Timestamp_t timestamp;
61 ParserError_t parser_error;
62 ClassOfService_t class_of_service;
64} __attribute__((aligned(4)));;
69 ClassOfService_t class_of_service;
70} __attribute__((aligned(4)));
80 enum MirrorType mirror_type;
81 MirrorSlotId_t mirror_slot_id;
82 ParserError_t parser_error;
83 MirrorSessionId_t mirror_session_id;
86} __attribute__((aligned(4)));
91 __u8 class_of_service;
93 __u16 packet_length_bytes;
94} __attribute__((aligned(4)));
96#define send_to_port(x) (compiler_meta__->egress_port = x)
97#define drop_packet() (compiler_meta__->drop = true)
106struct __attribute__((__packed__)) p4tc_table_entry_act_bpf {
109 is_default_miss_act:1,
110 is_default_hit_act:1;
115 struct p4tc_table_entry_act_bpf act_bpf;
125extern struct p4tc_table_entry_act_bpf *
126bpf_p4tc_tbl_read(
struct __sk_buff *skb_ctx,
128 const u32 params__sz,
129 void *key,
const __u32 key__sz) __ksym;
131extern struct p4tc_table_entry_act_bpf *
132xdp_p4tc_tbl_read(
struct xdp_md *skb_ctx,
134 const u32 params__sz,
135 void *key,
const __u32 key__sz) __ksym;
139bpf_p4tc_entry_create(
struct __sk_buff *skb_ctx,
141 const u32 params__sz,
142 void *key,
const u32 key__sz) __ksym;
145xdp_p4tc_entry_create(
struct xdp_md *xdp_ctx,
147 const u32 params__sz,
148 void *bpf_key_mask, u32 bpf_key_mask__sz) __ksym;
152bpf_p4tc_entry_create_on_miss(
struct __sk_buff *skb_ctx,
154 const u32 params__sz,
155 void *key,
const u32 key__sz) __ksym;
158xdp_p4tc_entry_create_on_miss(
struct xdp_md *xdp_ctx,
160 const u32 params__sz,
161 void *key,
const u32 key__sz) __ksym;
165bpf_p4tc_entry_update(
struct __sk_buff *skb_ctx,
167 const u32 params__sz,
168 void *key,
const u32 key__sz) __ksym;
171xdp_p4tc_entry_update(
struct xdp_md *xdp_ctx,
173 const u32 params__sz,
174 void *key,
const u32 key__sz) __ksym;
178bpf_p4tc_entry_delete(
struct __sk_buff *skb_ctx,
180 const u32 params__sz,
181 void *key,
const u32 key__sz) __ksym;
184xdp_p4tc_entry_delete(
struct xdp_md *xdp_ctx,
186 const u32 params__sz,
187 void *key,
const u32 key__sz) __ksym;
191#define P4TC_EXT_CNT_DIRECT 0x1
192#define P4TC_EXT_CNT_INDIRECT 0x2
193#define P4TC_EXT_METER_DIRECT (1 << 2)
194#define P4TC_EXT_METER_INDIRECT (1 << 3)
215bpf_p4tc_extern_count_pktsnbytes(
struct __sk_buff *skb_ctx,
217 const u32 params__sz,
void *key,
const u32 key__sz) __ksym;
220bpf_p4tc_extern_count_pkts(
struct __sk_buff *skb_ctx,
222 const u32 params__sz,
void *key,
const u32 key__sz) __ksym;
225bpf_p4tc_extern_count_bytes(
struct __sk_buff *skb_ctx,
227 const u32 params__sz,
void *key,
const u32 key__sz) __ksym;
230xdp_p4tc_extern_count_pktsnbytes(
struct xdp_md *xdp_ctx,
232 const u32 params__sz) __ksym;
235xdp_p4tc_extern_count_pkts(
struct xdp_md *xdp_ctx,
237 const u32 params__sz) __ksym;
240xdp_p4tc_extern_count_bytes(
struct xdp_md *xdp_ctx,
242 const u32 params__sz) __ksym;
244extern int bpf_p4tc_extern_meter_bytes_color(
struct __sk_buff *skb_ctx,
246 const u32 params__sz,
void *key,
247 const u32 key__sz) __ksym;
249bpf_p4tc_extern_meter_bytes(
struct __sk_buff *skb,
251 const u32 params__sz,
void *key,
252 const u32 key__sz) __ksym;
254extern int bpf_p4tc_extern_meter_pkts_color(
struct __sk_buff *skb_ctx,
256 const u32 params__sz,
void *key,
257 const u32 key__sz) __ksym;
259bpf_p4tc_extern_meter_pkts(
struct __sk_buff *skb,
261 const u32 params__sz,
void *key,
262 const u32 key__sz) __ksym;
264extern int xdp_p4tc_extern_meter_bytes_color(
struct xdp_md *xdp_ctx,
266 const u32 params__sz,
void *key,
267 const u32 key__sz) __ksym;
269extern int xdp_p4tc_extern_meter_bytes(
struct xdp_md *xdp_ctx,
271 const u32 params__sz,
void *key,
272 const u32 key__sz) __ksym;
274extern int xdp_p4tc_extern_meter_pkts_color(
struct xdp_md *xdp_ctx,
276 const u32 params__sz,
void *key,
277 const u32 key__sz) __ksym;
279extern int xdp_p4tc_extern_meter_pkts(
struct xdp_md *xdp_ctx,
281 const u32 params__sz,
void *key,
282 const u32 key__sz) __ksym;
293 const void *data,
const u32 data__sz) __ksym;
305 const u32 params__sz,
306 const void *data,
const u32 data__sz) __ksym;
310 const u32 params__sz) __ksym;
314 const u32 params__sz) __ksym;
318 const u32 params__sz) __ksym;
323 const u32 params__sz,
324 const void *data,
int len) __ksym;
328 const u32 params__sz,
329 const void *data,
const u32 data__sz) __ksym;
333 const u32 params__sz) __ksym;
337 const u32 params__sz,
342bpf_p4tc_ext_hash_crc16(
const void *data,
int len, u16 seed) __ksym;
346bpf_p4tc_ext_hash_base_crc16(
const void *data,
const u32 data__sz,
347 u32 base, u32 max, u16 seed) {
348 u16 hash = bpf_p4tc_ext_hash_crc16(data, data__sz, seed);
350 return (base + (hash % max));
355bpf_p4tc_ext_hash_crc32(
const void *data,
const u32 data__sz, u32 seed) __ksym;
359bpf_p4tc_ext_hash_base_crc32(
const void *data,
const u32 data__sz,
360 u32 base, u32 max, u32 seed) {
361 u32 hash = bpf_p4tc_ext_hash_crc32(data, data__sz, seed);
363 return (base + (hash % max));
368bpf_p4tc_ext_hash_16bit_complement(
const void *data,
const u32 data__sz,
373bpf_p4tc_ext_hash_base_16bit_complement(
const void *data,
const u32 data__sz,
374 u32 base, u32 max, u16 seed) {
375 u16 hash = bpf_p4tc_ext_hash_16bit_complement(data, data__sz, seed);
377 return (base + (hash % max));
383bpf_p4tc_is_net_port(
struct __sk_buff *skb_ctx,
const u32 ifindex) __ksym;
388bpf_p4tc_is_host_port(
struct __sk_buff *skb_ctx,
const u32 ifindex) __ksym;
393xdp_p4tc_is_net_port(
struct xdp_md *xdp_ctx,
const u32 ifindex) __ksym;
398xdp_p4tc_is_host_port(
struct xdp_md *xdp_ctx,
const u32 ifindex) __ksym;
412#define EXTERN_IS_NET_PORT 1234
413#define EXTERN_IS_HOST_PORT 4567
417bpf_p4tc_extern_md_read(
struct __sk_buff *skb_ctx,
419 const u32 params__sz) __ksym;
422extern int bpf_p4tc_extern_md_write(
struct __sk_buff *skb_ctx,
424 const u32 params__sz,
426 const u32 val__sz) __ksym;
430xdp_p4tc_extern_md_read(
struct xdp_md *xdp_ctx,
432 const u32 params__sz) __ksym;
435extern int xdp_p4tc_extern_md_write(
struct xdp_md *xdp_ctx,
437 const u32 params__sz,
439 const u32 val__sz) __ksym;
441int bpf_p4tc_extern_digest_pack(
struct __sk_buff *skb,
443 const u32 params__sz) __ksym;
445int xdp_p4tc_extern_digest_pack(
struct xdp_md *xdp_ctx,
447 const u32 params__sz) __ksym;
450static inline u64 bpf_p4tc_extern_timestamp() {
451 return bpf_ktime_get_ns();
454#define U32_MAX ((u32)~0U)
457static inline u32 bpf_p4tc_extern_random(u32 min, u32 max) {
459 return (min + bpf_get_prandom_u32());
461 return (min + bpf_get_prandom_u32()) % (max + 1);
Definition ebpf/runtime/psa.h:124