forked from p4lang/p4app-switchML
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathheaders.p4
178 lines (157 loc) · 3.71 KB
/
headers.p4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
Copyright 2021 Intel-KAUST-Microsoft
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _HEADERS_
#define _HEADERS_
#include "types.p4"
header ethernet_h {
mac_addr_t dst_addr;
mac_addr_t src_addr;
bit<16> ether_type;
}
header ipv4_h {
bit<4> version;
bit<4> ihl;
bit<8> diffserv;
bit<16> total_len;
bit<16> identification;
bit<3> flags;
bit<13> frag_offset;
bit<8> ttl;
ip_protocol_t protocol;
bit<16> hdr_checksum;
ipv4_addr_t src_addr;
ipv4_addr_t dst_addr;
}
header icmp_h {
icmp_type_t msg_type;
bit<8> msg_code;
bit<16> checksum;
}
header arp_h {
bit<16> hw_type;
ether_type_t proto_type;
bit<8> hw_addr_len;
bit<8> proto_addr_len;
arp_opcode_t opcode;
}
header arp_ipv4_h {
mac_addr_t src_hw_addr;
ipv4_addr_t src_proto_addr;
mac_addr_t dst_hw_addr;
ipv4_addr_t dst_proto_addr;
}
header udp_h {
bit<16> src_port;
bit<16> dst_port;
bit<16> length;
bit<16> checksum;
}
// SwitchML header
header switchml_h {
bit<4> msg_type;
bit<1> unused;
packet_size_t size;
bit<8> job_number;
bit<32> tsi;
bit<16> pool_index;
}
// InfiniBand-RoCE Base Transport Header
header ib_bth_h {
ib_opcode_t opcode;
bit<1> se;
bit<1> migration_req;
bit<2> pad_count;
bit<4> transport_version;
bit<16> partition_key;
bit<1> f_res1;
bit<1> b_res1;
bit<6> reserved;
queue_pair_t dst_qp;
bit<1> ack_req;
bit<7> reserved2;
sequence_number_t psn;
}
@pa_container_size("ingress", "hdr.ib_bth.psn", 32)
// InfiniBand-RoCE RDMA Extended Transport Header
header ib_reth_h {
bit<64> addr;
bit<32> r_key;
bit<32> len;
}
// InfiniBand-RoCE Immediate Header
header ib_immediate_h {
bit<32> immediate;
}
// InfiniBand-RoCE ICRC Header
header ib_icrc_h {
bit<32> icrc;
}
// Exponent headers
header exponents_h {
exponent_t e0;
exponent_t e1;
}
// 128-byte data header
header data_h {
value_t d00;
value_t d01;
value_t d02;
value_t d03;
value_t d04;
value_t d05;
value_t d06;
value_t d07;
value_t d08;
value_t d09;
value_t d10;
value_t d11;
value_t d12;
value_t d13;
value_t d14;
value_t d15;
value_t d16;
value_t d17;
value_t d18;
value_t d19;
value_t d20;
value_t d21;
value_t d22;
value_t d23;
value_t d24;
value_t d25;
value_t d26;
value_t d27;
value_t d28;
value_t d29;
value_t d30;
value_t d31;
}
// Full header stack
struct header_t {
ethernet_h ethernet;
arp_h arp;
arp_ipv4_h arp_ipv4;
ipv4_h ipv4;
icmp_h icmp;
udp_h udp;
switchml_h switchml;
exponents_h exponents;
ib_bth_h ib_bth;
ib_reth_h ib_reth;
ib_immediate_h ib_immediate;
// Two 128-byte data headers to support harvesting 256 bytes with recirculation
data_h d0;
data_h d1;
ib_icrc_h ib_icrc;
}
#endif /* _HEADERS_ */