Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Table '_____' is invoked multiple times. #231

Closed
Raymondma-public opened this issue Nov 26, 2016 · 4 comments
Closed

ERROR: Table '_____' is invoked multiple times. #231

Raymondma-public opened this issue Nov 26, 2016 · 4 comments

Comments

@Raymondma-public
Copy link

I face to a problem that when I am going to do the same thing in different switch role I defined.
I have read the following and know that applying a table multiple times is normally not allowed.
http://lists.p4.org/pipermail/p4-dev_lists.p4.org/2016-June/000388.html

But in my case I will only invoke a table for once for different switch role.
Would there be any solution for my case to reduce duplication of P4 code and switch commands?

P4 Code:

    if(user_metadata.switch_role==0){ //ECMP
	if(valid(ipv4) and ipv4.ttl > 0) {

	    apply(ecmp_group);
	    apply(forward);

	}
    }else if(user_metadata.switch_role==1){//Expeditus-ToR
    	
        //the counter show P4 recgonized SYN
        if(tcp.ctrl==TCP_SYN){ 
    	    apply(increment_SYN_table);
            apply(expeditus_header_table);
            apply(ecmp_group);
            apply(forward);
    	}

    }

Error:
ERROR: Table 'ecmp_group' is invoked multiple times.

@dhankook
Copy link

dhankook commented Nov 26, 2016 via email

@Raymondma-public
Copy link
Author

For the first option.
Indeed I will have some more roles that do not contain those "ecmp_group" and "forward". So does it mean I should use the second option that copy the tables and commands to new one with different name?

@dhankook
Copy link

dhankook commented Nov 28, 2016 via email

@antoninbas
Copy link
Member

Just adding some more info to @dhankook answer. In theory, the compiler and software switch should allow you to invoke the same table from 2 different places in the control flow, providing the 2 invocations are mutually exclusive (i.e. the same packet cannot go through the same table twice). However, because of the way we process the control flow in the current P4 compiler (we transform it into a table graph), it is actually pretty difficult to allow this, so we just throw an error if the same table is "applied" twice. While there is no immediate plan to fix this in the current compiler, we are hoping the next compiler (for P4_16) will not have this limitation.

Regarding your specific use case, I'd like to point out that most people will probably achieve different roles by writing different P4 programs and swapping the programs on the target as needed. This can be done in bmv2 through the runtime CLI. When you include all your roles in a single P4 program, you may limit the amount of physical resources available for each role. While in bmv2 your programs can be arbitrarily complex, this won't be the case for hardware P4 targets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants