P4C
The P4 Compiler
Loading...
Searching...
No Matches
ebpf/runtime/psa.h
1/*
2Copyright 2022-present Orange
3Copyright 2022-present Open Networking Foundation
4
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16*/
17#ifndef P4C_PSA_H
18#define P4C_PSA_H
19
20#include <stdbool.h>
21
22typedef __u32 PortId_t;
23typedef __u64 Timestamp_t;
24typedef __u8 ClassOfService_t;
25typedef __u16 CloneSessionId_t;
26typedef __u32 MulticastGroup_t;
27typedef __u16 EgressInstance_t;
28
29// Instead of using enum we define PSA_PacketPath_t as __u8 to save memory.
30typedef __u8 PSA_PacketPath_t;
31
32static const PSA_PacketPath_t NORMAL = 0;
33static const PSA_PacketPath_t NORMAL_UNICAST = 1;
34static const PSA_PacketPath_t NORMAL_MULTICAST = 2;
35static const PSA_PacketPath_t CLONE_I2E = 3;
36static const PSA_PacketPath_t CLONE_E2E = 4;
37static const PSA_PacketPath_t RESUBMIT = 5;
38static const PSA_PacketPath_t RECIRCULATE = 6;
39
41typedef __u8 ParserError_t;
42static const ParserError_t NoError = 0;
43static const ParserError_t PacketTooShort = 1;
44static const ParserError_t NoMatch = 2;
45static const ParserError_t StackOutOfBounds = 3;
46static const ParserError_t HeaderTooShort = 4;
47static const ParserError_t ParserTimeout = 5;
48static const ParserError_t ParserInvalidArgument = 6;
50
51enum PSA_MeterColor_t { RED, GREEN, YELLOW };
52
53
56 PortId_t ingress_port; // taken from xdp_md or __sk_buff
57 PSA_PacketPath_t packet_path; // taken from psa_global_metadata
58} __attribute__((aligned(4)));
59
61 // All of these values are initialized by the architecture before
62 // the Ingress control block begins executing.
63 PortId_t ingress_port; // taken from xdp_md or __sk_buff
64 PSA_PacketPath_t packet_path; // taken from psa_global_metadata
65 Timestamp_t ingress_timestamp; // taken from bpf helper
66 ParserError_t parser_error; // local to ingress parser
67} __attribute__((aligned(4)));;
68
70 // The comment after each field specifies its initial value when the
71 // Ingress control block begins executing.
72 MulticastGroup_t multicast_group; // 0, set in ingress as global metadata
73 PortId_t egress_port; // initial value is undefined, set in ingress as global metadata
74 ClassOfService_t class_of_service; // 0, set in ingress as global metadata
75 bool clone; // false, set in ingress/egress as global metadata
76 CloneSessionId_t clone_session_id; // initial value is undefined, set in ingress/egress as global metadata
77 bool drop; // true, set in ingress/egress as global metadata
78 bool resubmit; // false, local to ingress?
79} __attribute__((aligned(4)));
80
81/*
82 * EGRESS data types
83 */
84
86 PortId_t egress_port; // taken from xdp_md or __sk_buff
87 PSA_PacketPath_t packet_path; // taken from psa_global_metadata
88} __attribute__((aligned(4)));
89
91 ClassOfService_t class_of_service; // taken from global metadata
92 PortId_t egress_port; // taken taken from xdp_md or __sk_buff
93 PSA_PacketPath_t packet_path; // taken from global metadata
94 EgressInstance_t instance; // instance comes from the PacketReplicationEngine
95 // set by PRE as global metadata,
96 // in Egress taken from global metadata
97 Timestamp_t egress_timestamp; // taken from bpf_helper
98 ParserError_t parser_error; // local to egress pipeline
99} __attribute__((aligned(4)));
100
102 // The comment after each field specifies its initial value when the
103 // Egress control block begins executing.
104 bool clone; // false, set in egress as global metadata
105 CloneSessionId_t clone_session_id; // initial value is undefined, set in egress as global metadata
106 bool drop; // false, set in egress as global metadata
107} __attribute__((aligned(4)));
108
110 PortId_t egress_port; // local to egress pipeline, set by in egress
111} __attribute__((aligned(4)));
112
113/*
114 * Opaque struct to be used to share global PSA metadata fields between eBPF program attached to Ingress and Egress.
115 * The size of this struct must be less than 32 bytes.
116 */
118 PSA_PacketPath_t packet_path;
119 EgressInstance_t instance;
120 __u8 mark;
122} __attribute__((aligned(4)));
123
125 __u32 egress_port;
126 __u16 instance;
127 __u8 class_of_service;
128 __u8 truncate;
129 __u16 packet_length_bytes;
130} __attribute__((aligned(4)));
131
132#endif //P4C_PSA_H
Definition ebpf/runtime/psa.h:124
Definition ebpf/runtime/psa.h:109
Definition ebpf/runtime/psa.h:90
Definition ebpf/runtime/psa.h:101
Definition ebpf/runtime/psa.h:85
Definition ebpf/runtime/psa.h:117
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:121
EgressInstance_t instance
set by eBPF program as helper variable, read by ingress/egress
Definition ebpf/runtime/psa.h:119
__u8 mark
set by PRE, read by Egress
Definition ebpf/runtime/psa.h:120
Definition ebpf/runtime/psa.h:60
Definition ebpf/runtime/psa.h:69
INGRESS data types.
Definition ebpf/runtime/psa.h:55