blob: 4e352ee3437b37e095495ea7f34ba7282576e783 [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
65header int_data_t {
66 // Maximum int metadata stack size in bits:
67 // (0xFF -4) * 32 (excluding INT shim header, tail header and INT header)
68 varbit<8032> data;
69}
70
71#ifdef WITH_INT_TRANSIT
72// INT meta-value headers - 4 bytes each
73// Different header for each value type
74header int_switch_id_t {
75 bit<32> switch_id;
76}
77header int_port_ids_t {
78 bit<16> ingress_port_id;
79 bit<16> egress_port_id;
80}
81header int_hop_latency_t {
82 bit<32> hop_latency;
83}
84header int_q_occupancy_t {
85 bit<8> q_id;
86 bit<24> q_occupancy;
87}
88header int_ingress_tstamp_t {
89 bit<32> ingress_tstamp;
90}
91header int_egress_tstamp_t {
92 bit<32> egress_tstamp;
93}
94header int_q_congestion_t {
95 bit<8> q_id;
96 bit<24> q_congestion;
97}
98header int_egress_port_tx_util_t {
99 bit<32> egress_port_tx_util;
100}
101#endif // WITH_INT_TRANSIT
102
103#ifdef WITH_INT_SINK
104// Report Telemetry Headers
105header report_fixed_header_t {
106 bit<4> ver;
107 bit<4> nproto;
108 bit<1> d;
109 bit<1> q;
110 bit<1> f;
111 bit<15> rsvd;
112 bit<6> hw_id;
113 bit<32> seq_no;
114 bit<32> ingress_tstamp;
115}
116
117// Telemetry drop report header
118header drop_report_header_t {
119 bit<32> switch_id;
120 bit<16> ingress_port_id;
121 bit<16> egress_port_id;
122 bit<8> queue_id;
123 bit<8> drop_reason;
124 bit<16> pad;
125}
126
127// Switch Local Report Header
128header local_report_header_t {
129 bit<32> switch_id;
130 bit<16> ingress_port_id;
131 bit<16> egress_port_id;
132 bit<8> queue_id;
133 bit<24> queue_occupancy;
134 bit<32> egress_tstamp;
135}
136
137header_union local_report_t {
138 drop_report_header_t drop_report_header;
139 local_report_header_t local_report_header;
140}
141#endif // WITH_INT_SINK
142
143#endif