P4C
The P4 Compiler
Loading...
Searching...
No Matches
ebpf/runtime/psa.h
1/*
2 * SPDX-FileCopyrightText: 2022 Open Networking Foundation
3 * SPDX-FileCopyrightText: 2022 Orange
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7#ifndef P4C_PSA_H
8#define P4C_PSA_H
9
10#include <stdbool.h>
11
12typedef __u32 PortId_t;
13typedef __u64 Timestamp_t;
14typedef __u8 ClassOfService_t;
15typedef __u16 CloneSessionId_t;
16typedef __u32 MulticastGroup_t;
17typedef __u16 EgressInstance_t;
18
19// Instead of using enum we define PSA_PacketPath_t as __u8 to save memory.
20typedef __u8 PSA_PacketPath_t;
21
22static const PSA_PacketPath_t NORMAL = 0;
23static const PSA_PacketPath_t NORMAL_UNICAST = 1;
24static const PSA_PacketPath_t NORMAL_MULTICAST = 2;
25static const PSA_PacketPath_t CLONE_I2E = 3;
26static const PSA_PacketPath_t CLONE_E2E = 4;
27static const PSA_PacketPath_t RESUBMIT = 5;
28static const PSA_PacketPath_t RECIRCULATE = 6;
29
31typedef __u8 ParserError_t;
32static const ParserError_t NoError = 0;
33static const ParserError_t PacketTooShort = 1;
34static const ParserError_t NoMatch = 2;
35static const ParserError_t StackOutOfBounds = 3;
36static const ParserError_t HeaderTooShort = 4;
37static const ParserError_t ParserTimeout = 5;
38static const ParserError_t ParserInvalidArgument = 6;
40
41enum PSA_MeterColor_t { RED, GREEN, YELLOW };
42
43
46 PortId_t ingress_port; // taken from xdp_md or __sk_buff
47 PSA_PacketPath_t packet_path; // taken from psa_global_metadata
48} __attribute__((aligned(4)));
49
51 // All of these values are initialized by the architecture before
52 // the Ingress control block begins executing.
53 PortId_t ingress_port; // taken from xdp_md or __sk_buff
54 PSA_PacketPath_t packet_path; // taken from psa_global_metadata
55 Timestamp_t ingress_timestamp; // taken from bpf helper
56 ParserError_t parser_error; // local to ingress parser
57} __attribute__((aligned(4)));;
58
60 // The comment after each field specifies its initial value when the
61 // Ingress control block begins executing.
62 MulticastGroup_t multicast_group; // 0, set in ingress as global metadata
63 PortId_t egress_port; // initial value is undefined, set in ingress as global metadata
64 ClassOfService_t class_of_service; // 0, set in ingress as global metadata
65 bool clone; // false, set in ingress/egress as global metadata
66 CloneSessionId_t clone_session_id; // initial value is undefined, set in ingress/egress as global metadata
67 bool drop; // true, set in ingress/egress as global metadata
68 bool resubmit; // false, local to ingress?
69} __attribute__((aligned(4)));
70
71/*
72 * EGRESS data types
73 */
74
76 PortId_t egress_port; // taken from xdp_md or __sk_buff
77 PSA_PacketPath_t packet_path; // taken from psa_global_metadata
78} __attribute__((aligned(4)));
79
81 ClassOfService_t class_of_service; // taken from global metadata
82 PortId_t egress_port; // taken taken from xdp_md or __sk_buff
83 PSA_PacketPath_t packet_path; // taken from global metadata
84 EgressInstance_t instance; // instance comes from the PacketReplicationEngine
85 // set by PRE as global metadata,
86 // in Egress taken from global metadata
87 Timestamp_t egress_timestamp; // taken from bpf_helper
88 ParserError_t parser_error; // local to egress pipeline
89} __attribute__((aligned(4)));
90
92 // The comment after each field specifies its initial value when the
93 // Egress control block begins executing.
94 bool clone; // false, set in egress as global metadata
95 CloneSessionId_t clone_session_id; // initial value is undefined, set in egress as global metadata
96 bool drop; // false, set in egress as global metadata
97} __attribute__((aligned(4)));
98
100 PortId_t egress_port; // local to egress pipeline, set by in egress
101} __attribute__((aligned(4)));
102
103/*
104 * Opaque struct to be used to share global PSA metadata fields between eBPF program attached to Ingress and Egress.
105 * The size of this struct must be less than 32 bytes.
106 */
108 PSA_PacketPath_t packet_path;
109 EgressInstance_t instance;
110 __u8 mark;
112} __attribute__((aligned(4)));
113
115 __u32 egress_port;
116 __u16 instance;
117 __u8 class_of_service;
118 __u8 truncate;
119 __u16 packet_length_bytes;
120} __attribute__((aligned(4)));
121
122#endif //P4C_PSA_H
Definition ebpf/runtime/psa.h:114
Definition ebpf/runtime/psa.h:99
Definition ebpf/runtime/psa.h:80
Definition ebpf/runtime/psa.h:91
Definition ebpf/runtime/psa.h:75
Definition ebpf/runtime/psa.h:107
bool pass_to_kernel
packet mark set by PSA/eBPF programs. Used to differentiate between packets processed by PSA/eBPF fro...
Definition ebpf/runtime/psa.h:111
EgressInstance_t instance
set by eBPF program as helper variable, read by ingress/egress
Definition ebpf/runtime/psa.h:109
__u8 mark
set by PRE, read by Egress
Definition ebpf/runtime/psa.h:110
Definition ebpf/runtime/psa.h:50
Definition ebpf/runtime/psa.h:59
INGRESS data types.
Definition ebpf/runtime/psa.h:45