[P4-dev] Multiple table invocation problem

Ricardo Santos ricardo.santos at kau.se
Tue Apr 11 08:55:14 EDT 2017


Hello,

During the process of compiling a p4 program with some conditions in the 
ingress control code (using p4c-bm), I received some error messages 
referring to tables being invoked multiple times, although I'm not 
seeing any part of my code where that can happen.

I've replicated a simplified version of the control block of my program 
(in attachment) using the same condition ordering and with dummy 
values/tables, which is producing a similar output when using p4c-bm:

~/p4c-bm/p4c_bm/__main__.py dummy.p4 --json dummy.json
parsing successful
semantic checking successful
Header type standard_metadata_t not byte-aligned, adding padding
Header type test_metadata_t not byte-aligned, adding padding
ERROR: Table(s): ['table8', 'table7', 'table6', 'table4'] are invoked 
multiple times and have have next pointers set to: 
[p4_conditional_node._condition_6]
Error while building HLIR

Could anyone help me understanding what is happening in the attached 
code that is producing these compilation errors, and also how should I 
fix it?
Meanwhile I could get rid of the errors by creating copies of the 
conflicting tables (i.e. table4_1, table4_2), but obviously that's not 
the most memory efficient solution.

Thank you.

Best regards,
Ricardo Santos

-- 
Ricardo Santos
PhD student
Department of Mathematics and Computer Science
Karlstad University
+46 54 700 1073

-------------- next part --------------
/* Copyright 2013-present Barefoot Networks, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

header_type ethernet_t {
    fields {
        dstAddr : 48;
        srcAddr : 48;
        etherType : 16;
    }
}
header ethernet_t ethernet;

parser start {
    return parse_ethernet;
}

parser parse_ethernet {
    extract(ethernet);
    return ingress;
}

action _drop() {
    drop();
}

action rewrite_mac(smac) {
    modify_field(ethernet.srcAddr, smac);
}
table send_frame {
    reads {
        standard_metadata.egress_port: exact;
    }
    actions {
        rewrite_mac;
        _drop;
    }
    size: 256;
}

header_type test_metadata_t {
    fields {
    test0 : 4;
	test1 : 4;
	test2 : 4;
	test3 : 4;
	test4 : 4;
   }
}
metadata test_metadata_t test_metadata;

table table1 {
	actions {
		_drop;
	}
}

table table2 {
	actions {
		_drop;
	}
}

table table3 {
	actions {
		_drop;
	}
}

table table4 {
	actions {
		_drop;
	}
}

table table5 {
	actions {
		_drop;
	}
}

table table6 {
	actions {
		_drop;
	}
}

table table7 {
	actions {
		_drop;
	}
}

table table8 {
	actions {
		_drop;
	}
}

table table9 {
	actions {
		_drop;
	}
}

control ingress {
	if (test_metadata.test0 == 1) {
		if (test_metadata.test1 == 1) {
			if (test_metadata.test2 == 3) {
				if (test_metadata.test3 == 1) {
					apply(table1);
					apply(table3);
				}
				else if(test_metadata.test3 == 2) {
					apply(table2);
					apply(table4);
				}
				else {
					apply(table7);
				}
			} else {
				if (test_metadata.test3 == 1) {
					apply(table5);
					apply(table4);				
				}
				else {
					apply(table8);
					if (test_metadata.test4 == 1) {
						apply(table6);
						apply(table4);
					}
					else {
						apply(table7);
					}
				}
			}
		} else {
			apply(table8);
			if (test_metadata.test4 == 1){
				apply(table6);
				apply(table4);
			} else {
				apply(table7);
			}

		}
	} else {
		apply(table7);
	}
	apply(table9);
}

control egress {
    apply(send_frame);
}


More information about the P4-dev mailing list