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

[bmv2] inlining + header stack broken #158

Closed
smolkaj opened this issue Nov 29, 2016 · 3 comments
Closed

[bmv2] inlining + header stack broken #158

smolkaj opened this issue Nov 29, 2016 · 3 comments
Assignees
Labels
fixed This topic is considered to be fixed.

Comments

@smolkaj
Copy link
Member

smolkaj commented Nov 29, 2016

The following program compiles with the bmv2 backend, but throws the error

lt-simple_switch: P4Objects.cpp:710: int bm::P4Objects::init_objects(std::istream*, bm::LookupStructureFactory*, int, size_t, std::shared_ptr<bm::TransportIface>, const std::set<std::pair<std::basic_string<char>, std::basic_string<char> > >&, const bm::P4Objects::ForceArith&): Assertion `0 && "parameter not supported"' failed.

at runtime when executed on simple_switch:
158.p4.txt

#include <core.p4>
#include <v1model.p4>
typedef standard_metadata_t std_meta_t;

header h_t {
    bit<1> f;
}
struct H { h_t[1] stack; }
struct M { }

parser ParserI(packet_in pk, out H hdr, inout M meta, inout std_meta_t std_meta) {
    state start {
        transition accept;
    }
}

control VerifyChecksumI(in H hdr, inout M meta) {
    apply { }
}

control ComputeChecksumI(inout H hdr, inout M meta) {
    apply { }
}

control Aux(inout H hdr) {
    table t {
        key = {
            // the use of a stack, together with inlining, provokes the bug
            hdr.stack[0].f : exact;
        }
        actions = { NoAction; }
    }
    
    apply {
        t.apply();
    }    
}

control IngressI(inout H hdr, inout M meta, inout std_meta_t std_meta) {
    Aux() aux;
    apply {
        aux.apply(hdr);
    }
}


control EgressI(inout H hdr, inout M meta, inout std_meta_t std_meta) {
    apply { }
}

control DeparserI(packet_out b, in H hdr) {
    apply { }
}

V1Switch(ParserI(), VerifyChecksumI(), IngressI(), EgressI(), ComputeChecksumI(), DeparserI()) main;
@smolkaj
Copy link
Member Author

smolkaj commented Nov 29, 2016

Actually, the bug is already provoked when Aux is replaced with an empty control block:

...
control Aux(inout H hdr) {
    apply { }    
}
...

@mihaibudiu
Copy link
Contributor

The last pull request under submission fixes the manifestation of this issue for this example.
However, the issue remains for a different example, if we inline the header twice, so I will leave it open until it is fixed:

control IngressI(inout H hdr, inout M meta, inout std_meta_t std_meta) {
    Aux() aux;
    apply {
        aux.apply(hdr);
        aux.apply(hdr);
    }
}

ChrisDodd pushed a commit that referenced this issue Nov 30, 2016
ChrisDodd pushed a commit that referenced this issue Nov 30, 2016
@smolkaj
Copy link
Member Author

smolkaj commented Nov 30, 2016

Good enough to get switch.p4_16 to compile & run :) 👍
Time to run some tests!

@ChrisDodd ChrisDodd added the fixed This topic is considered to be fixed. label Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed This topic is considered to be fixed.
Projects
None yet
Development

No branches or pull requests

3 participants