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)
104} __attribute__((preserve_access_index));
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_delete(
struct __sk_buff *skb_ctx,
167 const u32 params__sz,
168 void *key,
const u32 key__sz) __ksym;
171xdp_p4tc_entry_delete(
struct xdp_md *xdp_ctx,
173 const u32 params__sz,
174 void *key,
const u32 key__sz) __ksym;
178#define P4TC_EXT_CNT_DIRECT 0x1
179#define P4TC_EXT_CNT_INDIRECT 0x2
180#define P4TC_EXT_METER_DIRECT (1 << 2)
181#define P4TC_EXT_METER_INDIRECT (1 << 3)
202bpf_p4tc_extern_count_pktsnbytes(
struct __sk_buff *skb_ctx,
204 const u32 params__sz,
void *key,
const u32 key__sz) __ksym;
207bpf_p4tc_extern_count_pkts(
struct __sk_buff *skb_ctx,
209 const u32 params__sz,
void *key,
const u32 key__sz) __ksym;
212bpf_p4tc_extern_count_bytes(
struct __sk_buff *skb_ctx,
214 const u32 params__sz,
void *key,
const u32 key__sz) __ksym;
217xdp_p4tc_extern_indirect_count_pktsnbytes(
struct xdp_md *xdp_ctx,
219 const u32 params__sz) __ksym;
222xdp_p4tc_extern_indirect_count_pktsonly(
struct xdp_md *xdp_ctx,
224 const u32 params__sz) __ksym;
227xdp_p4tc_extern_indirect_count_bytesonly(
struct xdp_md *xdp_ctx,
229 const u32 params__sz) __ksym;
231extern int bpf_p4tc_extern_meter_bytes_color(
struct __sk_buff *skb_ctx,
233 const u32 params__sz,
void *key,
234 const u32 key__sz) __ksym;
236bpf_p4tc_extern_meter_bytes(
struct __sk_buff *skb,
238 const u32 params__sz,
void *key,
239 const u32 key__sz) __ksym;
241extern int bpf_p4tc_extern_meter_pkts_color(
struct __sk_buff *skb_ctx,
243 const u32 params__sz,
void *key,
244 const u32 key__sz) __ksym;
246bpf_p4tc_extern_meter_pkts(
struct __sk_buff *skb,
248 const u32 params__sz,
void *key,
249 const u32 key__sz) __ksym;
251extern int xdp_p4tc_extern_meter_bytes_color(
struct xdp_md *xdp_ctx,
253 const u32 params__sz,
void *key,
254 const u32 key__sz) __ksym;
256extern int xdp_p4tc_extern_meter_bytes(
struct xdp_md *xdp_ctx,
258 const u32 params__sz,
void *key,
259 const u32 key__sz) __ksym;
261extern int xdp_p4tc_extern_meter_pkts_color(
struct xdp_md *xdp_ctx,
263 const u32 params__sz,
void *key,
264 const u32 key__sz) __ksym;
266extern int xdp_p4tc_extern_meter_pkts(
struct xdp_md *xdp_ctx,
268 const u32 params__sz,
void *key,
269 const u32 key__sz) __ksym;
280 const void *data,
const u32 data__sz) __ksym;
292 const u32 params__sz,
293 const void *data,
const u32 data__sz) __ksym;
297 const u32 params__sz) __ksym;
301 const u32 params__sz) __ksym;
305 const u32 params__sz) __ksym;
310 const u32 params__sz,
311 const void *data,
int len) __ksym;
315 const u32 params__sz,
316 const void *data,
const u32 data__sz) __ksym;
320 const u32 params__sz) __ksym;
324 const u32 params__sz,
329bpf_p4tc_ext_hash_crc16(
const void *data,
int len, u16 seed) __ksym;
333bpf_p4tc_ext_hash_base_crc16(
const void *data,
const u32 data__sz,
334 u32 base, u32 max, u16 seed) {
335 u16 hash = bpf_p4tc_ext_hash_crc16(data, data__sz, seed);
337 return (base + (hash % max));
342bpf_p4tc_ext_hash_crc32(
const void *data,
const u32 data__sz, u32 seed) __ksym;
346bpf_p4tc_ext_hash_base_crc32(
const void *data,
const u32 data__sz,
347 u32 base, u32 max, u32 seed) {
348 u32 hash = bpf_p4tc_ext_hash_crc32(data, data__sz, seed);
350 return (base + (hash % max));
355bpf_p4tc_ext_hash_16bit_complement(
const void *data,
const u32 data__sz,
360bpf_p4tc_ext_hash_base_16bit_complement(
const void *data,
const u32 data__sz,
361 u32 base, u32 max, u16 seed) {
362 u16 hash = bpf_p4tc_ext_hash_16bit_complement(data, data__sz, seed);
364 return (base + (hash % max));
370bpf_p4tc_is_net_port(
struct __sk_buff *skb_ctx,
const u32 ifindex) __ksym;
375bpf_p4tc_is_host_port(
struct __sk_buff *skb_ctx,
const u32 ifindex) __ksym;
380xdp_p4tc_is_net_port(
struct xdp_md *xdp_ctx,
const u32 ifindex) __ksym;
385xdp_p4tc_is_host_port(
struct xdp_md *xdp_ctx,
const u32 ifindex) __ksym;
399#define EXTERN_IS_NET_PORT 1234
400#define EXTERN_IS_HOST_PORT 4567
404bpf_p4tc_extern_md_read(
struct __sk_buff *skb_ctx,
406 const u32 params__sz) __ksym;
409extern int bpf_p4tc_extern_md_write(
struct __sk_buff *skb_ctx,
411 const u32 params__sz,
413 const u32 val__sz) __ksym;
417xdp_p4tc_extern_md_read(
struct xdp_md *xdp_ctx,
419 const u32 params__sz) __ksym;
422extern int xdp_p4tc_extern_md_write(
struct xdp_md *xdp_ctx,
424 const u32 params__sz,
426 const u32 val__sz) __ksym;
428int bpf_p4tc_extern_digest_pack(
struct __sk_buff *skb,
430 const u32 params__sz) __ksym;
432int xdp_p4tc_extern_digest_pack(
struct xdp_md *xdp_ctx,
434 const u32 params__sz) __ksym;
437static inline u64 bpf_p4tc_extern_timestamp() {
438 return bpf_ktime_get_ns();
441#define U32_MAX ((u32)~0U)
444static inline u32 bpf_p4tc_extern_random(u32 min, u32 max) {
446 return (min + bpf_get_prandom_u32());
448 return (min + bpf_get_prandom_u32()) % (max + 1);
Definition ebpf/runtime/psa.h:124