Avoid the P4 compiler put ecmp_group_id to scalars meta

Change-Id: I4a5e71d75a4e13de645ea800afcda22988e0e728
This commit is contained in:
Yi Tseng 2017-08-29 14:20:33 -07:00 committed by Carmelo Cascone
parent 8780edc426
commit 60ef61d52c
3 changed files with 38 additions and 21 deletions

View File

@ -19,9 +19,13 @@
#include "include/defines.p4"
#include "include/headers.p4"
struct ecmp_metadata_t {
ecmp_group_id_t ecmp_group_id;
}
struct metadata_t {
intrinsic_metadata_t intrinsic_metadata;
ecmp_group_id_t ecmp_group_id;
ecmp_metadata_t ecmp_metadata;
}
#include "include/parsers.p4"
@ -35,7 +39,7 @@ control ingress(inout headers_t hdr, inout metadata_t meta, inout standard_metad
direct_counter(CounterType.packets) ecmp_counter;
action do_ecmp(ecmp_group_id_t ecmp_group_id) {
meta.ecmp_group_id = ecmp_group_id;
meta.ecmp_metadata.ecmp_group_id = ecmp_group_id;
}
table table0 {
@ -64,7 +68,7 @@ control ingress(inout headers_t hdr, inout metadata_t meta, inout standard_metad
table ecmp {
support_timeout = false;
key = {
meta.ecmp_group_id : exact;
meta.ecmp_metadata.ecmp_group_id : exact;
// Not for matching.
// Inputs to the hash function of the action selector.
hdr.ipv4.srcAddr : selector;

View File

@ -10,8 +10,7 @@
"id" : 0,
"fields" : [
["tmp", 32, false],
["tmp_0", 32, false],
["metadata_t.ecmp_group_id", 8, false]
["tmp_0", 32, false]
]
},
{
@ -117,6 +116,13 @@
["mcast_grp", 16, false],
["egress_rid", 16, false]
]
},
{
"name" : "ecmp_metadata_t",
"id" : 9,
"fields" : [
["ecmp_group_id", 8, false]
]
}
],
"headers" : [
@ -210,6 +216,13 @@
"header_type" : "intrinsic_metadata_t",
"metadata" : true,
"pi_omit" : true
},
{
"name" : "ecmp_metadata",
"id" : 13,
"header_type" : "ecmp_metadata_t",
"metadata" : true,
"pi_omit" : true
}
],
"header_stacks" : [],
@ -218,12 +231,12 @@
"header_union_stacks" : [],
"field_lists" : [],
"errors" : [
["NoError", 1],
["PacketTooShort", 2],
["NoMatch", 3],
["StackOutOfBounds", 4],
["HeaderTooShort", 5],
["ParserTimeout", 6]
["NoError", 0],
["PacketTooShort", 1],
["NoMatch", 2],
["StackOutOfBounds", 3],
["HeaderTooShort", 4],
["ParserTimeout", 5]
],
"enums" : [],
"parsers" : [
@ -3173,7 +3186,7 @@
"parameters" : [
{
"type" : "field",
"value" : ["scalars", "metadata_t.ecmp_group_id"]
"value" : ["ecmp_metadata", "ecmp_group_id"]
},
{
"type" : "runtime_data",
@ -3182,9 +3195,9 @@
],
"source_info" : {
"filename" : "default.p4",
"line" : 38,
"line" : 42,
"column" : 8,
"source_fragment" : "meta.ecmp_group_id = ecmp_group_id"
"source_fragment" : "meta.ecmp_metadata.ecmp_group_id = ecmp_group_id"
}
}
]
@ -3382,7 +3395,7 @@
"id" : 0,
"source_info" : {
"filename" : "default.p4",
"line" : 33,
"line" : 37,
"column" : 8,
"source_fragment" : "ingress"
},
@ -3416,7 +3429,7 @@
"id" : 1,
"source_info" : {
"filename" : "default.p4",
"line" : 41,
"line" : 45,
"column" : 10,
"source_fragment" : "table0"
},
@ -3468,14 +3481,14 @@
"id" : 2,
"source_info" : {
"filename" : "default.p4",
"line" : 64,
"line" : 68,
"column" : 10,
"source_fragment" : "ecmp"
},
"key" : [
{
"match_type" : "exact",
"target" : ["scalars", "metadata_t.ecmp_group_id"],
"target" : ["ecmp_metadata", "ecmp_group_id"],
"mask" : null
}
],
@ -3589,7 +3602,7 @@
"id" : 1,
"source_info" : {
"filename" : "default.p4",
"line" : 90,
"line" : 94,
"column" : 13,
"source_fragment" : "hdr.packet_out.isValid()"
},
@ -3643,7 +3656,7 @@
"id" : 1,
"source_info" : {
"filename" : "default.p4",
"line" : 102,
"line" : 106,
"column" : 8,
"source_fragment" : "egress"
},

View File

@ -51,7 +51,7 @@ tables {
}
match_fields {
id: 1
name: "meta.ecmp_group_id"
name: "meta.ecmp_metadata.ecmp_group_id"
bitwidth: 8
match_type: EXACT
}