blob: 9b1f0e43f59c8c490efab0818ec0e8d71a7c84ea [file] [log] [blame]
Carmelo Cascone79a3a312018-08-16 17:14:43 -07001/*
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#ifndef __INT_HEADER__
18#define __INT_HEADER__
19
20#include "../define.p4"
21
22struct int_metadata_t {
23 _BOOL source;
24 _BOOL transit;
25 _BOOL sink;
26 bit<32> switch_id;
27 bit<8> new_words;
28 bit<16> new_bytes;
Carmelo Casconefa421582018-09-13 10:05:57 -070029 bit<32> ig_tstamp;
30 bit<32> eg_tstamp;
Carmelo Cascone79a3a312018-08-16 17:14:43 -070031}
32
33// INT headers - 8 bytes
34header int_header_t {
35 bit<2> ver;
36 bit<2> rep;
37 bit<1> c;
38 bit<1> e;
39 bit<5> rsvd1;
40 bit<5> ins_cnt;
41 bit<8> max_hop_cnt;
42 bit<8> total_hop_cnt;
43 bit<4> instruction_mask_0003; /* split the bits for lookup */
44 bit<4> instruction_mask_0407;
45 bit<4> instruction_mask_0811;
46 bit<4> instruction_mask_1215;
47 bit<16> rsvd2;
48}
49
50// INT shim header for TCP/UDP - 4 bytes
51header intl4_shim_t {
52 bit<8> int_type;
53 bit<8> rsvd1;
54 bit<8> len_words; // 4-byte words.
55 bit<8> rsvd2;
56}
57// INT tail header for TCP/UDP - 4 bytes
58header intl4_tail_t {
59 bit<8> next_proto;
60 bit<16> dest_port;
61 bit<2> padding;
62 bit<6> dscp;
63}
64
Carmelo Cascone8e5818d2018-10-26 11:45:23 -070065#ifdef WITH_INT_SINK
Carmelo Cascone79a3a312018-08-16 17:14:43 -070066header int_data_t {
67 // Maximum int metadata stack size in bits:
68 // (0xFF -4) * 32 (excluding INT shim header, tail header and INT header)
69 varbit<8032> data;
70}
Carmelo Cascone8e5818d2018-10-26 11:45:23 -070071#endif // WITH_INT_SINK
Carmelo Cascone79a3a312018-08-16 17:14:43 -070072
73#ifdef WITH_INT_TRANSIT
74// INT meta-value headers - 4 bytes each
75// Different header for each value type
76header int_switch_id_t {
77 bit<32> switch_id;
78}
79header int_port_ids_t {
80 bit<16> ingress_port_id;
81 bit<16> egress_port_id;
82}
83header int_hop_latency_t {
84 bit<32> hop_latency;
85}
86header int_q_occupancy_t {
87 bit<8> q_id;
88 bit<24> q_occupancy;
89}
90header int_ingress_tstamp_t {
91 bit<32> ingress_tstamp;
92}
93header int_egress_tstamp_t {
94 bit<32> egress_tstamp;
95}
96header int_q_congestion_t {
97 bit<8> q_id;
98 bit<24> q_congestion;
99}
100header int_egress_port_tx_util_t {
101 bit<32> egress_port_tx_util;
102}
103#endif // WITH_INT_TRANSIT
104
105#ifdef WITH_INT_SINK
106// Report Telemetry Headers
107header report_fixed_header_t {
108 bit<4> ver;
109 bit<4> nproto;
110 bit<1> d;
111 bit<1> q;
112 bit<1> f;
113 bit<15> rsvd;
114 bit<6> hw_id;
115 bit<32> seq_no;
116 bit<32> ingress_tstamp;
117}
118
119// Telemetry drop report header
120header drop_report_header_t {
121 bit<32> switch_id;
122 bit<16> ingress_port_id;
123 bit<16> egress_port_id;
124 bit<8> queue_id;
125 bit<8> drop_reason;
126 bit<16> pad;
127}
128
129// Switch Local Report Header
130header local_report_header_t {
131 bit<32> switch_id;
132 bit<16> ingress_port_id;
133 bit<16> egress_port_id;
134 bit<8> queue_id;
135 bit<24> queue_occupancy;
136 bit<32> egress_tstamp;
137}
138
139header_union local_report_t {
140 drop_report_header_t drop_report_header;
141 local_report_header_t local_report_header;
142}
143#endif // WITH_INT_SINK
144
145#endif