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/p4c-out/ecmp.json b/tools/test/p4src/p4-14/p4c-out/ecmp.json
index 5de22a5..8c971bb 100644
--- a/tools/test/p4src/p4-14/p4c-out/ecmp.json
+++ b/tools/test/p4src/p4-14/p4c-out/ecmp.json
@@ -9,9 +9,10 @@
"name" : "scalars_0",
"id" : 0,
"fields" : [
- ["tmp", 64, false],
- ["tmp_0", 32, false],
- ["tmp_1", 32, false]
+ ["tmp_0", 104, false],
+ ["tmp", 8, false],
+ ["tmp_1", 32, false],
+ ["tmp_2", 32, false]
]
},
{
@@ -42,9 +43,25 @@
]
},
{
- "name" : "tcp_t",
+ "name" : "packet_in_t",
"id" : 3,
"fields" : [
+ ["ingress_port", 9, false],
+ ["_padding", 7, false]
+ ]
+ },
+ {
+ "name" : "packet_out_t",
+ "id" : 4,
+ "fields" : [
+ ["egress_port", 9, false],
+ ["_padding_0", 7, false]
+ ]
+ },
+ {
+ "name" : "tcp_t",
+ "id" : 5,
+ "fields" : [
["srcPort", 16, false],
["dstPort", 16, false],
["seqNo", 32, false],
@@ -60,7 +77,7 @@
},
{
"name" : "udp_t",
- "id" : 4,
+ "id" : 6,
"fields" : [
["srcPort", 16, false],
["dstPort", 16, false],
@@ -70,26 +87,15 @@
},
{
"name" : "ecmp_metadata_t",
- "id" : 5,
+ "id" : 7,
"fields" : [
["groupId", 16, false],
- ["selector", 16, false],
- ["groupSize", 32, false]
- ]
- },
- {
- "name" : "intrinsic_metadata_t",
- "id" : 6,
- "fields" : [
- ["ingress_global_timestamp", 32, false],
- ["lf_field_list", 32, false],
- ["mcast_grp", 16, false],
- ["egress_rid", 16, false]
+ ["selector", 16, false]
]
},
{
"name" : "standard_metadata",
- "id" : 7,
+ "id" : 8,
"fields" : [
["ingress_port", 9, false],
["egress_spec", 9, false],
@@ -108,7 +114,7 @@
["mcast_grp", 16, false],
["resubmit_flag", 1, false],
["egress_rid", 16, false],
- ["_padding", 5, false]
+ ["_padding_1", 5, false]
]
}
],
@@ -142,32 +148,39 @@
"pi_omit" : true
},
{
- "name" : "tcp",
+ "name" : "packet_in_hdr",
"id" : 4,
+ "header_type" : "packet_in_t",
+ "metadata" : false,
+ "pi_omit" : true
+ },
+ {
+ "name" : "packet_out_hdr",
+ "id" : 5,
+ "header_type" : "packet_out_t",
+ "metadata" : false,
+ "pi_omit" : true
+ },
+ {
+ "name" : "tcp",
+ "id" : 6,
"header_type" : "tcp_t",
"metadata" : false,
"pi_omit" : true
},
{
"name" : "udp",
- "id" : 5,
+ "id" : 7,
"header_type" : "udp_t",
"metadata" : false,
"pi_omit" : true
},
{
"name" : "ecmp_metadata",
- "id" : 6,
+ "id" : 8,
"header_type" : "ecmp_metadata_t",
"metadata" : true,
"pi_omit" : true
- },
- {
- "name" : "intrinsic_metadata",
- "id" : 7,
- "header_type" : "intrinsic_metadata_t",
- "metadata" : true,
- "pi_omit" : true
}
],
"header_stacks" : [],
@@ -191,8 +204,31 @@
"init_state" : "start",
"parse_states" : [
{
- "name" : "parse_ethernet",
+ "name" : "default_parser",
"id" : 0,
+ "parser_ops" : [],
+ "transitions" : [
+ {
+ "value" : "0x00ff",
+ "mask" : null,
+ "next_state" : "parse_pkt_out"
+ },
+ {
+ "value" : "default",
+ "mask" : null,
+ "next_state" : "parse_ethernet"
+ }
+ ],
+ "transition_key" : [
+ {
+ "type" : "field",
+ "value" : ["standard_metadata", "ingress_port"]
+ }
+ ]
+ },
+ {
+ "name" : "parse_ethernet",
+ "id" : 1,
"parser_ops" : [
{
"parameters" : [
@@ -225,7 +261,7 @@
},
{
"name" : "parse_ipv4",
- "id" : 1,
+ "id" : 2,
"parser_ops" : [
{
"parameters" : [
@@ -266,8 +302,54 @@
]
},
{
+ "name" : "parse_pkt_in",
+ "id" : 3,
+ "parser_ops" : [
+ {
+ "parameters" : [
+ {
+ "type" : "regular",
+ "value" : "packet_in_hdr"
+ }
+ ],
+ "op" : "extract"
+ }
+ ],
+ "transitions" : [
+ {
+ "value" : "default",
+ "mask" : null,
+ "next_state" : "parse_ethernet"
+ }
+ ],
+ "transition_key" : []
+ },
+ {
+ "name" : "parse_pkt_out",
+ "id" : 4,
+ "parser_ops" : [
+ {
+ "parameters" : [
+ {
+ "type" : "regular",
+ "value" : "packet_out_hdr"
+ }
+ ],
+ "op" : "extract"
+ }
+ ],
+ "transitions" : [
+ {
+ "value" : "default",
+ "mask" : null,
+ "next_state" : "parse_ethernet"
+ }
+ ],
+ "transition_key" : []
+ },
+ {
"name" : "parse_tcp",
- "id" : 2,
+ "id" : 5,
"parser_ops" : [
{
"parameters" : [
@@ -290,7 +372,7 @@
},
{
"name" : "parse_udp",
- "id" : 3,
+ "id" : 6,
"parser_ops" : [
{
"parameters" : [
@@ -313,16 +395,66 @@
},
{
"name" : "start",
- "id" : 4,
- "parser_ops" : [],
+ "id" : 7,
+ "parser_ops" : [
+ {
+ "parameters" : [
+ {
+ "type" : "field",
+ "value" : ["scalars", "tmp_0"]
+ },
+ {
+ "type" : "lookahead",
+ "value" : [0, 104]
+ }
+ ],
+ "op" : "set"
+ },
+ {
+ "parameters" : [
+ {
+ "type" : "field",
+ "value" : ["scalars", "tmp"]
+ },
+ {
+ "type" : "expression",
+ "value" : {
+ "type" : "expression",
+ "value" : {
+ "op" : "&",
+ "left" : {
+ "type" : "field",
+ "value" : ["scalars", "tmp_0"]
+ },
+ "right" : {
+ "type" : "hexstr",
+ "value" : "0xff"
+ }
+ }
+ }
+ }
+ ],
+ "op" : "set"
+ }
+ ],
"transitions" : [
{
+ "value" : "0x00",
+ "mask" : null,
+ "next_state" : "parse_pkt_in"
+ },
+ {
"value" : "default",
"mask" : null,
- "next_state" : "parse_ethernet"
+ "next_state" : "default_parser"
}
],
- "transition_key" : []
+ "transition_key" : [
+ {
+ "type" : "field",
+ "value" : ["scalars", "tmp"]
+ }
+ ]
}
]
}
@@ -331,7 +463,7 @@
{
"name" : "deparser",
"id" : 0,
- "order" : ["ethernet", "ipv4", "udp", "tcp"]
+ "order" : ["packet_out_hdr", "packet_in_hdr", "ethernet", "ipv4", "udp", "tcp"]
}
],
"meter_arrays" : [],
@@ -402,10 +534,45 @@
"learn_lists" : [],
"actions" : [
{
- "name" : "NoAction",
+ "name" : "add_packet_in_hdr",
"id" : 0,
"runtime_data" : [],
- "primitives" : []
+ "primitives" : [
+ {
+ "op" : "add_header",
+ "parameters" : [
+ {
+ "type" : "header",
+ "value" : "packet_in_hdr"
+ }
+ ],
+ "source_info" : {
+ "filename" : "include/packet_io.p4",
+ "line" : 25,
+ "column" : 4,
+ "source_fragment" : "add_header(packet_in_hdr)"
+ }
+ },
+ {
+ "op" : "assign",
+ "parameters" : [
+ {
+ "type" : "field",
+ "value" : ["packet_in_hdr", "ingress_port"]
+ },
+ {
+ "type" : "field",
+ "value" : ["standard_metadata", "ingress_port"]
+ }
+ ],
+ "source_info" : {
+ "filename" : "include/packet_io.p4",
+ "line" : 26,
+ "column" : 4,
+ "source_fragment" : "modify_field(packet_in_hdr.ingress_port, standard_metadata.ingress_port)"
+ }
+ }
+ ]
},
{
"name" : "NoAction",
@@ -443,7 +610,7 @@
],
"source_info" : {
"filename" : "include/actions.p4",
- "line" : 1,
+ "line" : 5,
"column" : 23,
"source_fragment" : "port) { ..."
}
@@ -474,7 +641,7 @@
],
"source_info" : {
"filename" : "include/actions.p4",
- "line" : 1,
+ "line" : 5,
"column" : 23,
"source_fragment" : "port) { ..."
}
@@ -488,10 +655,6 @@
{
"name" : "groupId",
"bitwidth" : 16
- },
- {
- "name" : "groupSize",
- "bitwidth" : 32
}
],
"primitives" : [
@@ -509,57 +672,12 @@
],
"source_info" : {
"filename" : "ecmp.p4",
- "line" : 35,
+ "line" : 42,
"column" : 18,
- "source_fragment" : "groupId, groupSize) { ..."
+ "source_fragment" : "groupId) { ..."
}
},
{
- "op" : "assign",
- "parameters" : [
- {
- "type" : "field",
- "value" : ["ecmp_metadata", "groupSize"]
- },
- {
- "type" : "runtime_data",
- "value" : 1
- }
- ],
- "source_info" : {
- "filename" : "ecmp.p4",
- "line" : 35,
- "column" : 27,
- "source_fragment" : "groupSize) { ..."
- }
- },
- {
- "op" : "assign",
- "parameters" : [
- {
- "type" : "field",
- "value" : ["scalars", "tmp"]
- },
- {
- "type" : "expression",
- "value" : {
- "type" : "expression",
- "value" : {
- "op" : "&",
- "left" : {
- "type" : "local",
- "value" : 1
- },
- "right" : {
- "type" : "hexstr",
- "value" : "0xffffffffffffffff"
- }
- }
- }
- }
- ]
- },
- {
"op" : "modify_field_with_hash_based_offset",
"parameters" : [
{
@@ -575,15 +693,15 @@
"value" : "calc"
},
{
- "type" : "field",
- "value" : ["scalars", "tmp"]
+ "type" : "hexstr",
+ "value" : "0x0000000000000004"
}
],
"source_info" : {
"filename" : "ecmp.p4",
- "line" : 38,
+ "line" : 44,
"column" : 4,
- "source_fragment" : "modify_field_with_hash_based_offset(ecmp_metadata.selector, 0, ecmp_hash, groupSize)"
+ "source_fragment" : "modify_field_with_hash_based_offset(ecmp_metadata.selector, 0, ecmp_hash, 4)"
}
}
]
@@ -607,7 +725,7 @@
],
"source_info" : {
"filename" : "include/actions.p4",
- "line" : 10,
+ "line" : 21,
"column" : 4,
"source_fragment" : "modify_field(standard_metadata.egress_spec, 255)"
}
@@ -615,7 +733,7 @@
]
},
{
- "name" : "drop",
+ "name" : "_drop",
"id" : 7,
"runtime_data" : [],
"primitives" : [
@@ -633,7 +751,7 @@
],
"source_info" : {
"filename" : "include/actions.p4",
- "line" : 6,
+ "line" : 13,
"column" : 4,
"source_fragment" : "modify_field(standard_metadata.egress_spec, 511)"
}
@@ -641,7 +759,7 @@
]
},
{
- "name" : "count_packet",
+ "name" : "_packet_out",
"id" : 8,
"runtime_data" : [],
"primitives" : [
@@ -650,47 +768,43 @@
"parameters" : [
{
"type" : "field",
- "value" : ["scalars", "tmp_0"]
- },
- {
- "type" : "expression",
- "value" : {
- "type" : "expression",
- "value" : {
- "op" : "&",
- "left" : {
- "type" : "field",
- "value" : ["standard_metadata", "ingress_port"]
- },
- "right" : {
- "type" : "hexstr",
- "value" : "0xffffffff"
- }
- }
- }
- }
- ]
- },
- {
- "op" : "count",
- "parameters" : [
- {
- "type" : "counter_array",
- "value" : "ingress_port_counter"
+ "value" : ["standard_metadata", "egress_spec"]
},
{
"type" : "field",
- "value" : ["scalars", "tmp_0"]
+ "value" : ["packet_out_hdr", "egress_port"]
}
],
"source_info" : {
- "filename" : "include/port_counters.p4",
- "line" : 20,
+ "filename" : "include/packet_io.p4",
+ "line" : 7,
"column" : 4,
- "source_fragment" : "count(ingress_port_counter, standard_metadata.ingress_port)"
+ "source_fragment" : "modify_field(standard_metadata.egress_spec, packet_out_hdr.egress_port)"
}
},
{
+ "op" : "remove_header",
+ "parameters" : [
+ {
+ "type" : "header",
+ "value" : "packet_out_hdr"
+ }
+ ],
+ "source_info" : {
+ "filename" : "include/packet_io.p4",
+ "line" : 8,
+ "column" : 4,
+ "source_fragment" : "remove_header(packet_out_hdr)"
+ }
+ }
+ ]
+ },
+ {
+ "name" : "count_egress",
+ "id" : 9,
+ "runtime_data" : [],
+ "primitives" : [
+ {
"op" : "assign",
"parameters" : [
{
@@ -730,26 +844,107 @@
],
"source_info" : {
"filename" : "include/port_counters.p4",
- "line" : 21,
+ "line" : 22,
"column" : 4,
"source_fragment" : "count(egress_port_counter, standard_metadata.egress_spec)"
}
}
]
+ },
+ {
+ "name" : "count_ingress",
+ "id" : 10,
+ "runtime_data" : [],
+ "primitives" : [
+ {
+ "op" : "assign",
+ "parameters" : [
+ {
+ "type" : "field",
+ "value" : ["scalars", "tmp_2"]
+ },
+ {
+ "type" : "expression",
+ "value" : {
+ "type" : "expression",
+ "value" : {
+ "op" : "&",
+ "left" : {
+ "type" : "field",
+ "value" : ["standard_metadata", "ingress_port"]
+ },
+ "right" : {
+ "type" : "hexstr",
+ "value" : "0xffffffff"
+ }
+ }
+ }
+ }
+ ]
+ },
+ {
+ "op" : "count",
+ "parameters" : [
+ {
+ "type" : "counter_array",
+ "value" : "ingress_port_counter"
+ },
+ {
+ "type" : "field",
+ "value" : ["scalars", "tmp_2"]
+ }
+ ],
+ "source_info" : {
+ "filename" : "include/port_counters.p4",
+ "line" : 18,
+ "column" : 4,
+ "source_fragment" : "count(ingress_port_counter, standard_metadata.ingress_port)"
+ }
+ }
+ ]
}
],
"pipelines" : [
{
"name" : "ingress",
"id" : 0,
- "init_table" : "table0",
+ "init_table" : "node_2",
"tables" : [
{
- "name" : "table0",
+ "name" : "ingress_pkt",
"id" : 0,
"source_info" : {
+ "filename" : "include/packet_io.p4",
+ "line" : 11,
+ "column" : 0,
+ "source_fragment" : "table ingress_pkt { ..."
+ },
+ "key" : [],
+ "match_type" : "exact",
+ "type" : "simple",
+ "max_size" : 1024,
+ "with_counters" : false,
+ "support_timeout" : false,
+ "direct_meters" : null,
+ "action_ids" : [8],
+ "actions" : ["_packet_out"],
+ "base_default_next" : "node_4",
+ "next_tables" : {
+ "_packet_out" : "node_4"
+ },
+ "default_entry" : {
+ "action_id" : 8,
+ "action_const" : false,
+ "action_data" : [],
+ "action_entry_const" : false
+ }
+ },
+ {
+ "name" : "table0",
+ "id" : 1,
+ "source_info" : {
"filename" : "ecmp.p4",
- "line" : 41,
+ "line" : 50,
"column" : 0,
"source_fragment" : "table table0 { ..."
},
@@ -781,18 +976,18 @@
"with_counters" : true,
"support_timeout" : false,
"direct_meters" : null,
- "action_ids" : [4, 5, 6, 7, 1],
- "actions" : ["set_egress_port", "ecmp_group", "send_to_cpu", "drop", "NoAction"],
- "base_default_next" : "node_4",
+ "action_ids" : [4, 5, 6, 7, 2],
+ "actions" : ["set_egress_port", "ecmp_group", "send_to_cpu", "_drop", "NoAction"],
+ "base_default_next" : "node_7",
"next_tables" : {
"ecmp_group" : "ecmp_group_table",
- "set_egress_port" : "node_4",
- "send_to_cpu" : "node_4",
- "drop" : "node_4",
- "NoAction" : "node_4"
+ "set_egress_port" : "node_7",
+ "send_to_cpu" : "node_7",
+ "_drop" : "node_7",
+ "NoAction" : "node_7"
},
"default_entry" : {
- "action_id" : 1,
+ "action_id" : 2,
"action_const" : false,
"action_data" : [],
"action_entry_const" : false
@@ -800,10 +995,10 @@
},
{
"name" : "ecmp_group_table",
- "id" : 1,
+ "id" : 2,
"source_info" : {
"filename" : "ecmp.p4",
- "line" : 57,
+ "line" : 66,
"column" : 0,
"source_fragment" : "table ecmp_group_table { ..."
},
@@ -825,28 +1020,28 @@
"with_counters" : true,
"support_timeout" : false,
"direct_meters" : null,
- "action_ids" : [3, 0],
+ "action_ids" : [3, 1],
"actions" : ["set_egress_port", "NoAction"],
- "base_default_next" : "node_4",
+ "base_default_next" : "node_7",
"next_tables" : {
- "set_egress_port" : "node_4",
- "NoAction" : "node_4"
+ "set_egress_port" : "node_7",
+ "NoAction" : "node_7"
},
"default_entry" : {
- "action_id" : 0,
+ "action_id" : 1,
"action_const" : false,
"action_data" : [],
"action_entry_const" : false
}
},
{
- "name" : "port_count_table",
- "id" : 2,
+ "name" : "ingress_port_count_table",
+ "id" : 3,
"source_info" : {
"filename" : "include/port_counters.p4",
- "line" : 13,
+ "line" : 25,
"column" : 0,
- "source_fragment" : "table port_count_table { ..."
+ "source_fragment" : "table ingress_port_count_table { ..."
},
"key" : [],
"match_type" : "exact",
@@ -855,15 +1050,43 @@
"with_counters" : false,
"support_timeout" : false,
"direct_meters" : null,
- "action_ids" : [8, 2],
- "actions" : ["count_packet", "NoAction"],
- "base_default_next" : null,
+ "action_ids" : [10],
+ "actions" : ["count_ingress"],
+ "base_default_next" : "egress_port_count_table",
"next_tables" : {
- "count_packet" : null,
- "NoAction" : null
+ "count_ingress" : "egress_port_count_table"
},
"default_entry" : {
- "action_id" : 2,
+ "action_id" : 10,
+ "action_const" : false,
+ "action_data" : [],
+ "action_entry_const" : false
+ }
+ },
+ {
+ "name" : "egress_port_count_table",
+ "id" : 4,
+ "source_info" : {
+ "filename" : "include/port_counters.p4",
+ "line" : 30,
+ "column" : 0,
+ "source_fragment" : "table egress_port_count_table { ..."
+ },
+ "key" : [],
+ "match_type" : "exact",
+ "type" : "simple",
+ "max_size" : 1024,
+ "with_counters" : false,
+ "support_timeout" : false,
+ "direct_meters" : null,
+ "action_ids" : [9],
+ "actions" : ["count_egress"],
+ "base_default_next" : null,
+ "next_tables" : {
+ "count_egress" : null
+ },
+ "default_entry" : {
+ "action_id" : 9,
"action_const" : false,
"action_data" : [],
"action_entry_const" : false
@@ -873,12 +1096,64 @@
"action_profiles" : [],
"conditionals" : [
{
- "name" : "node_4",
+ "name" : "node_2",
"id" : 0,
"source_info" : {
+ "filename" : "include/packet_io.p4",
+ "line" : 19,
+ "column" : 8,
+ "source_fragment" : "valid(packet_out_hdr)"
+ },
+ "expression" : {
+ "type" : "expression",
+ "value" : {
+ "op" : "==",
+ "left" : {
+ "type" : "field",
+ "value" : ["packet_out_hdr", "$valid$"]
+ },
+ "right" : {
+ "type" : "hexstr",
+ "value" : "0x01"
+ }
+ }
+ },
+ "true_next" : "ingress_pkt",
+ "false_next" : "node_4"
+ },
+ {
+ "name" : "node_4",
+ "id" : 1,
+ "source_info" : {
+ "filename" : "ecmp.p4",
+ "line" : 90,
+ "column" : 12,
+ "source_fragment" : "valid(packet_out_hdr)"
+ },
+ "expression" : {
+ "type" : "expression",
+ "value" : {
+ "op" : "!=",
+ "left" : {
+ "type" : "field",
+ "value" : ["packet_out_hdr", "$valid$"]
+ },
+ "right" : {
+ "type" : "hexstr",
+ "value" : "0x01"
+ }
+ }
+ },
+ "true_next" : "table0",
+ "false_next" : "node_7"
+ },
+ {
+ "name" : "node_7",
+ "id" : 2,
+ "source_info" : {
"filename" : "include/port_counters.p4",
- "line" : 26,
- "column" : 35,
+ "line" : 36,
+ "column" : 38,
"source_fragment" : "<"
},
"expression" : {
@@ -896,17 +1171,74 @@
}
},
"false_next" : null,
- "true_next" : "port_count_table"
+ "true_next" : "ingress_port_count_table"
}
]
},
{
"name" : "egress",
"id" : 1,
- "init_table" : null,
- "tables" : [],
+ "init_table" : "node_12",
+ "tables" : [
+ {
+ "name" : "egress_pkt",
+ "id" : 5,
+ "source_info" : {
+ "filename" : "include/packet_io.p4",
+ "line" : 29,
+ "column" : 0,
+ "source_fragment" : "table egress_pkt { ..."
+ },
+ "key" : [],
+ "match_type" : "exact",
+ "type" : "simple",
+ "max_size" : 1024,
+ "with_counters" : false,
+ "support_timeout" : false,
+ "direct_meters" : null,
+ "action_ids" : [0],
+ "actions" : ["add_packet_in_hdr"],
+ "base_default_next" : null,
+ "next_tables" : {
+ "add_packet_in_hdr" : null
+ },
+ "default_entry" : {
+ "action_id" : 0,
+ "action_const" : false,
+ "action_data" : [],
+ "action_entry_const" : false
+ }
+ }
+ ],
"action_profiles" : [],
- "conditionals" : []
+ "conditionals" : [
+ {
+ "name" : "node_12",
+ "id" : 3,
+ "source_info" : {
+ "filename" : "include/packet_io.p4",
+ "line" : 40,
+ "column" : 39,
+ "source_fragment" : "=="
+ },
+ "expression" : {
+ "type" : "expression",
+ "value" : {
+ "op" : "==",
+ "left" : {
+ "type" : "field",
+ "value" : ["standard_metadata", "ingress_port"]
+ },
+ "right" : {
+ "type" : "hexstr",
+ "value" : "0x00ff"
+ }
+ }
+ },
+ "false_next" : null,
+ "true_next" : "egress_pkt"
+ }
+ ]
}
],
"checksums" : [],