Refactor fabric.p4 INT support to allow compilation on more P4 targets
Also use constant entries for instruction mask tables to avoid
programming them at runtime.
Change-Id: Ia1ab1ecd42a433daec171f9a30bcdba3b8484061
diff --git a/pipelines/fabric/src/main/resources/include/header.p4 b/pipelines/fabric/src/main/resources/include/header.p4
index 5591c11..46fa022 100644
--- a/pipelines/fabric/src/main/resources/include/header.p4
+++ b/pipelines/fabric/src/main/resources/include/header.p4
@@ -18,6 +18,7 @@
#define __HEADER__
#include "define.p4"
+#include "int/int_header.p4"
@controller_header("packet_in")
header packet_in_header_t {
@@ -147,122 +148,6 @@
}
#endif // WITH_SPGW
-#ifdef WITH_INT
-// Report Telemetry Headers
-header report_fixed_header_t {
- bit<4> ver;
- bit<4> nproto;
- bit<1> d;
- bit<1> q;
- bit<1> f;
- bit<15> rsvd;
- bit<6> hw_id;
- bit<32> seq_no;
- bit<32> ingress_tstamp;
-}
-
-// Telemetry drop report header
-header drop_report_header_t {
- bit<32> switch_id;
- bit<16> ingress_port_id;
- bit<16> egress_port_id;
- bit<8> queue_id;
- bit<8> drop_reason;
- bit<16> pad;
-}
-
-// Switch Local Report Header
-header local_report_header_t {
- bit<32> switch_id;
- bit<16> ingress_port_id;
- bit<16> egress_port_id;
- bit<8> queue_id;
- bit<24> queue_occupancy;
- bit<32> egress_tstamp;
-}
-
-header_union local_report_t {
- drop_report_header_t drop_report_header;
- local_report_header_t local_report_header;
-}
-
-// INT headers
-header int_header_t {
- bit<2> ver;
- bit<2> rep;
- bit<1> c;
- bit<1> e;
- bit<5> rsvd1;
- bit<5> ins_cnt;
- bit<8> max_hop_cnt;
- bit<8> total_hop_cnt;
- bit<4> instruction_mask_0003; /* split the bits for lookup */
- bit<4> instruction_mask_0407;
- bit<4> instruction_mask_0811;
- bit<4> instruction_mask_1215;
- bit<16> rsvd2;
-}
-
-// INT meta-value headers - different header for each value type
-header int_switch_id_t {
- bit<32> switch_id;
-}
-header int_port_ids_t {
- bit<16> ingress_port_id;
- bit<16> egress_port_id;
-}
-header int_hop_latency_t {
- bit<32> hop_latency;
-}
-header int_q_occupancy_t {
- bit<8> q_id;
- bit<24> q_occupancy;
-}
-header int_ingress_tstamp_t {
- bit<32> ingress_tstamp;
-}
-header int_egress_tstamp_t {
- bit<32> egress_tstamp;
-}
-header int_q_congestion_t {
- bit<8> q_id;
- bit<24> q_congestion;
-}
-header int_egress_port_tx_util_t {
- bit<32> egress_port_tx_util;
-}
-
-header int_data_t {
- // Maximum int metadata stack size in bits:
- // (0xFF -4) * 32 (excluding INT shim header, tail header and INT header)
- varbit<8032> data;
-}
-
-/* INT shim header for TCP/UDP */
-header intl4_shim_t {
- bit<8> int_type;
- bit<8> rsvd1;
- bit<8> len;
- bit<8> rsvd2;
-}
-/* INT tail header for TCP/UDP */
-header intl4_tail_t {
- bit<8> next_proto;
- bit<16> dest_port;
- bit<8> dscp;
-}
-
-struct int_metadata_t {
- switch_id_t switch_id;
- bit<16> insert_byte_cnt;
- bit<1> source;
- bit<1> sink;
- bit<8> mirror_id;
- bit<16> flow_id;
- bit<8> metadata_len;
-}
-#endif // WITH_INT
-
//Custom metadata definition
struct fabric_metadata_t {
fwd_type_t fwd_type;
@@ -279,7 +164,6 @@
#endif // WITH_SPGW
#ifdef WITH_INT
int_metadata_t int_meta;
- bool compute_checksum;
#endif // WITH_INT
}
@@ -304,18 +188,19 @@
icmp_t icmp;
packet_out_header_t packet_out;
packet_in_header_t packet_in;
-#ifdef WITH_INT
- // INT Report Encapsulation
+#ifdef WITH_INT_SINK
+ // INT Report encap
ethernet_t report_ethernet;
ipv4_t report_ipv4;
udp_t report_udp;
- // INT Report Headers
+ // INT Report header (support only fixed)
report_fixed_header_t report_fixed_header;
- local_report_t report_local;
+ // local_report_t report_local;
+#endif // WITH_INT_SINK
+#ifdef WITH_INT
// INT specific headers
intl4_shim_t intl4_shim;
int_header_t int_header;
- int_data_t int_data;
int_switch_id_t int_switch_id;
int_port_ids_t int_port_ids;
int_hop_latency_t int_hop_latency;
@@ -324,6 +209,7 @@
int_egress_tstamp_t int_egress_tstamp;
int_q_congestion_t int_q_congestion;
int_egress_port_tx_util_t int_egress_tx_util;
+ int_data_t int_data;
intl4_tail_t intl4_tail;
#endif //WITH_INT
}