blob: c98ea3134b5aa06597ab7b91566d53816def9611 [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
25// INT headers
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080026header int_header_t {
27 bit<2> ver;
28 bit<2> rep;
29 bit<1> c;
30 bit<1> e;
31 bit<5> rsvd1;
32 bit<5> ins_cnt;
33 bit<8> max_hop_cnt;
34 bit<8> total_hop_cnt;
35 bit<4> instruction_mask_0003; /* split the bits for lookup */
36 bit<4> instruction_mask_0407;
37 bit<4> instruction_mask_0811;
38 bit<4> instruction_mask_1215;
39 bit<16> rsvd2;
40}
41
42// INT meta-value headers - different header for each value type
43header int_switch_id_t {
44 bit<32> switch_id;
45}
46header int_port_ids_t {
47 bit<16> ingress_port_id;
48 bit<16> egress_port_id;
49}
50header int_hop_latency_t {
51 bit<32> hop_latency;
52}
53header int_q_occupancy_t {
54 bit<8> q_id;
55 bit<24> q_occupancy;
56}
57header int_ingress_tstamp_t {
58 bit<32> ingress_tstamp;
59}
60header int_egress_tstamp_t {
61 bit<32> egress_tstamp;
62}
63header int_q_congestion_t {
64 bit<8> q_id;
65 bit<24> q_congestion;
66}
67header int_egress_port_tx_util_t {
68 bit<32> egress_port_tx_util;
69}
70
71header int_data_t {
72 // Maximum int metadata stack size in bits:
73 // (0xFF -4) * 32 (excluding INT shim header, tail header and INT header)
74 varbit<8032> data;
75}
76
Jonghwan Hyun6777d532018-11-18 20:50:16 +090077// INT shim header for TCP/UDP
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080078header intl4_shim_t {
79 bit<8> int_type;
80 bit<8> rsvd1;
81 bit<8> len;
82 bit<8> rsvd2;
83}
Jonghwan Hyun6777d532018-11-18 20:50:16 +090084// INT tail header for TCP/UDP
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080085header intl4_tail_t {
86 bit<8> next_proto;
87 bit<16> dest_port;
88 bit<8> dscp;
89}
90
Jonghwan Hyun8be03392017-12-04 15:48:44 -080091struct int_metadata_t {
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080092 switch_id_t switch_id;
93 bit<16> insert_byte_cnt;
94 bit<1> source;
95 bit<1> sink;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -080096 bit<8> mirror_id;
97 bit<16> flow_id;
98 bit<8> metadata_len;
99}
100
101struct headers_t {
102 packet_out_header_t packet_out;
103 packet_in_header_t packet_in;
Jonghwan Hyun6777d532018-11-18 20:50:16 +0900104 // INT Report Encapsulation
105 ethernet_t report_ethernet;
106 ipv4_t report_ipv4;
107 udp_t report_udp;
108 // INT Report Headers
109 report_fixed_header_t report_fixed_header;
110 local_report_t report_local;
111 // Original packet's headers
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800112 ethernet_t ethernet;
113 ipv4_t ipv4;
114 tcp_t tcp;
115 udp_t udp;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800116 // INT specific headers
117 intl4_shim_t intl4_shim;
118 int_header_t int_header;
119 int_data_t int_data;
120 int_switch_id_t int_switch_id;
121 int_port_ids_t int_port_ids;
122 int_hop_latency_t int_hop_latency;
123 int_q_occupancy_t int_q_occupancy;
124 int_ingress_tstamp_t int_ingress_tstamp;
125 int_egress_tstamp_t int_egress_tstamp;
126 int_q_congestion_t int_q_congestion;
127 int_egress_port_tx_util_t int_egress_tx_util;
128 intl4_tail_t intl4_tail;
129}
130
131struct local_metadata_t {
132 bit<16> l4_src_port;
133 bit<16> l4_dst_port;
134 next_hop_id_t next_hop_id;
135 bit<16> selector;
136 int_metadata_t int_meta;
Jonghwan Hyun6777d532018-11-18 20:50:16 +0900137 bool compute_checksum;
Jonghwan Hyun4a9a6712017-11-13 14:43:55 -0800138}
139
Jonghwan Hyun6777d532018-11-18 20:50:16 +0900140#endif // __INT_HEADERS__
141#endif // __CUSTOM_HEADERS__