blob: d55c5716f7f07dcbd3c37acfcb6abcc88df8f9f4 [file] [log] [blame]
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -08001/*
2 * Copyright 2017-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/* -*- P4_16 -*- */
18#ifndef __CUSTOM_HEADERS__
19#define __CUSTOM_HEADERS__
20
21/* INT headers */
22header int_header_t {
23 bit<2> ver;
24 bit<2> rep;
25 bit<1> c;
26 bit<1> e;
27 bit<5> rsvd1;
28 bit<5> ins_cnt;
29 bit<8> max_hop_cnt;
30 bit<8> total_hop_cnt;
31 bit<4> instruction_mask_0003; /* split the bits for lookup */
32 bit<4> instruction_mask_0407;
33 bit<4> instruction_mask_0811;
34 bit<4> instruction_mask_1215;
35 bit<16> rsvd2;
36}
37
38// INT meta-value headers - different header for each value type
39header int_switch_id_t {
40 bit<32> switch_id;
41}
42header int_port_ids_t {
43 bit<16> ingress_port_id;
44 bit<16> egress_port_id;
45}
46header int_hop_latency_t {
47 bit<32> hop_latency;
48}
49header int_q_occupancy_t {
50 bit<8> q_id;
51 bit<24> q_occupancy;
52}
53header int_ingress_tstamp_t {
54 bit<32> ingress_tstamp;
55}
56header int_egress_tstamp_t {
57 bit<32> egress_tstamp;
58}
59header int_q_congestion_t {
60 bit<8> q_id;
61 bit<24> q_congestion;
62}
63header int_egress_port_tx_util_t {
64 bit<32> egress_port_tx_util;
65}
66
67header int_data_t {
68 // Maximum int metadata stack size in bits:
69 // (0xFF -4) * 32 (excluding INT shim header, tail header and INT header)
70 varbit<8032> data;
71}
72
73/* INT shim header for TCP/UDP */
74header intl4_shim_t {
75 bit<8> int_type;
76 bit<8> rsvd1;
77 bit<8> len;
78 bit<8> rsvd2;
79}
80/* INT tail header for TCP/UDP */
81header intl4_tail_t {
82 bit<8> next_proto;
83 bit<16> dest_port;
84 bit<8> dscp;
85}
86
Jonghwan Hyun8be03392017-12-04 15:48:44 -080087struct int_metadata_t {
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080088 switch_id_t switch_id;
89 bit<16> insert_byte_cnt;
90 bit<1> source;
91 bit<1> sink;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080092 bit<8> mirror_id;
93 bit<16> flow_id;
94 bit<8> metadata_len;
95}
96
97struct headers_t {
98 packet_out_header_t packet_out;
99 packet_in_header_t packet_in;
100 ethernet_t ethernet;
101 ipv4_t ipv4;
102 tcp_t tcp;
103 udp_t udp;
104
105 // INT specific headers
106 intl4_shim_t intl4_shim;
107 int_header_t int_header;
108 int_data_t int_data;
109 int_switch_id_t int_switch_id;
110 int_port_ids_t int_port_ids;
111 int_hop_latency_t int_hop_latency;
112 int_q_occupancy_t int_q_occupancy;
113 int_ingress_tstamp_t int_ingress_tstamp;
114 int_egress_tstamp_t int_egress_tstamp;
115 int_q_congestion_t int_q_congestion;
116 int_egress_port_tx_util_t int_egress_tx_util;
117 intl4_tail_t intl4_tail;
118}
119
120struct local_metadata_t {
121 bit<16> l4_src_port;
122 bit<16> l4_dst_port;
123 next_hop_id_t next_hop_id;
124 bit<16> selector;
125 int_metadata_t int_meta;
126}
127
128#endif