Support tofino build for P4_14 test programs
Also, modified programs such that both the P4_14 and P4_16 versions
produce the same forwarding behaviour and control API (i.e. P4Info)
Change-Id: I90b7fdfedff5f2a89e0f2295d32e2bb61cd0e0eb
diff --git a/tools/test/p4src/p4-14/ecmp.p4 b/tools/test/p4src/p4-14/ecmp.p4
index f751049..341e1e1 100644
--- a/tools/test/p4src/p4-14/ecmp.p4
+++ b/tools/test/p4src/p4-14/ecmp.p4
@@ -3,12 +3,19 @@
#include "include/parser.p4"
#include "include/actions.p4"
#include "include/port_counters.p4"
+#include "include/packet_io.p4"
+
+/*
+ Expected number of ports of an ECMP group.
+ This value is fixed, .i.e. we do not support ECMP over port groups of different size.
+ Due to hardware limitations, this value must be constant and a power of 2.
+*/
+#define ECMP_GROUP_SIZE 4
header_type ecmp_metadata_t {
fields {
groupId : 16;
selector : 16;
- groupSize : 32; // Not used. Workaround to avoid p4c complaining about inferring type to groupSize.
}
}
@@ -32,24 +39,26 @@
output_width : 32;
}
-action ecmp_group(groupId, groupSize) {
+action ecmp_group(groupId) {
modify_field(ecmp_metadata.groupId, groupId);
- modify_field(ecmp_metadata.groupSize, groupSize);
- modify_field_with_hash_based_offset(ecmp_metadata.selector, 0, ecmp_hash, groupSize);
+ modify_field_with_hash_based_offset(ecmp_metadata.selector, 0, ecmp_hash, ECMP_GROUP_SIZE);
}
+#ifdef __TOFINO_BUILD__
+@pragma immediate 0
+#endif
table table0 {
reads {
- standard_metadata.ingress_port : ternary;
- ethernet.dstAddr : ternary;
- ethernet.srcAddr : ternary;
+ IGR_PORT_FIELD : ternary;
+ ethernet.dstAddr : ternary;
+ ethernet.srcAddr : ternary;
ethernet.etherType : ternary;
}
actions {
set_egress_port;
ecmp_group;
send_to_cpu;
- drop;
+ _drop;
}
support_timeout: true;
}
@@ -77,10 +86,17 @@
}
control ingress {
- apply(table0) {
- ecmp_group {
- apply(ecmp_group_table);
+ ingress_pkt_io();
+ if (not valid(packet_out_hdr)) {
+ apply(table0) {
+ ecmp_group {
+ apply(ecmp_group_table);
+ }
}
}
process_port_counters();
+}
+
+control egress {
+ egress_pkt_io();
}
\ No newline at end of file