blob: 8ea6f0ee9ba69f2f68d5ac93046c16ab9f280c57 [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
Jonghwan Hyun6777d532018-11-18 20:50:16 +090021#ifndef __INT_HEADERS__
22#define __INT_HEADERS__
23#include "telemetry_report_headers.p4"
24
Jonghwan Hyunc235d462019-01-30 23:31:48 +090025// INT version 1.0
26
27// INT header
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080028header int_header_t {
Jonghwan Hyunc235d462019-01-30 23:31:48 +090029 bit<4> ver;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080030 bit<2> rep;
31 bit<1> c;
32 bit<1> e;
Jonghwan Hyunc235d462019-01-30 23:31:48 +090033 bit<1> m;
34 bit<7> rsvd1;
35 bit<3> rsvd2;
36 bit<5> hop_metadata_len;
37 bit<8> remaining_hop_cnt;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080038 bit<4> instruction_mask_0003; /* split the bits for lookup */
39 bit<4> instruction_mask_0407;
40 bit<4> instruction_mask_0811;
41 bit<4> instruction_mask_1215;
Jonghwan Hyunc235d462019-01-30 23:31:48 +090042 bit<16> rsvd3;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080043}
44
45// INT meta-value headers - different header for each value type
46header int_switch_id_t {
47 bit<32> switch_id;
48}
Jonghwan Hyunc235d462019-01-30 23:31:48 +090049header int_level1_port_ids_t {
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080050 bit<16> ingress_port_id;
51 bit<16> egress_port_id;
52}
53header int_hop_latency_t {
54 bit<32> hop_latency;
55}
56header int_q_occupancy_t {
57 bit<8> q_id;
58 bit<24> q_occupancy;
59}
60header int_ingress_tstamp_t {
61 bit<32> ingress_tstamp;
62}
63header int_egress_tstamp_t {
64 bit<32> egress_tstamp;
65}
Jonghwan Hyunc235d462019-01-30 23:31:48 +090066header int_level2_port_ids_t {
67 bit<32> ingress_port_id;
68 bit<32> egress_port_id;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080069}
70header int_egress_port_tx_util_t {
71 bit<32> egress_port_tx_util;
72}
73
74header int_data_t {
75 // Maximum int metadata stack size in bits:
Jonghwan Hyunc235d462019-01-30 23:31:48 +090076 // (0x3F - 3) * 4 * 8 (excluding INT shim header and INT header)
77 varbit<1920> data;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080078}
79
Jonghwan Hyun6777d532018-11-18 20:50:16 +090080// INT shim header for TCP/UDP
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080081header intl4_shim_t {
82 bit<8> int_type;
83 bit<8> rsvd1;
84 bit<8> len;
Jonghwan Hyunc235d462019-01-30 23:31:48 +090085 bit<6> dscp;
86 bit<2> rsvd2;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080087}
88
Jonghwan Hyun8be03392017-12-04 15:48:44 -080089struct int_metadata_t {
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080090 switch_id_t switch_id;
Jonghwan Hyunc235d462019-01-30 23:31:48 +090091 bit<16> new_bytes;
92 bit<8> new_words;
93 _BOOL source;
94 _BOOL sink;
95 _BOOL transit;
96 bit<8> intl4_shim_len;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080097}
98
99struct headers_t {
100 packet_out_header_t packet_out;
101 packet_in_header_t packet_in;
Jonghwan Hyun6777d532018-11-18 20:50:16 +0900102 // INT Report Encapsulation
103 ethernet_t report_ethernet;
104 ipv4_t report_ipv4;
105 udp_t report_udp;
106 // INT Report Headers
107 report_fixed_header_t report_fixed_header;
108 local_report_t report_local;
109 // Original packet's headers
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800110 ethernet_t ethernet;
111 ipv4_t ipv4;
112 tcp_t tcp;
113 udp_t udp;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800114 // INT specific headers
115 intl4_shim_t intl4_shim;
116 int_header_t int_header;
117 int_data_t int_data;
118 int_switch_id_t int_switch_id;
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900119 int_level1_port_ids_t int_level1_port_ids;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800120 int_hop_latency_t int_hop_latency;
121 int_q_occupancy_t int_q_occupancy;
122 int_ingress_tstamp_t int_ingress_tstamp;
123 int_egress_tstamp_t int_egress_tstamp;
Jonghwan Hyunc235d462019-01-30 23:31:48 +0900124 int_level2_port_ids_t int_level2_port_ids;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800125 int_egress_port_tx_util_t int_egress_tx_util;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800126}
127
128struct local_metadata_t {
129 bit<16> l4_src_port;
130 bit<16> l4_dst_port;
131 next_hop_id_t next_hop_id;
132 bit<16> selector;
133 int_metadata_t int_meta;
Jonghwan Hyun6777d532018-11-18 20:50:16 +0900134 bool compute_checksum;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800135}
136
Jonghwan Hyun6777d532018-11-18 20:50:16 +0900137#endif // __INT_HEADERS__
138#endif // __CUSTOM_HEADERS__