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

Invoking register's read() method compiles, but bmv2 fails to parse JSON #146

Closed
vikramnathan opened this issue Nov 10, 2016 · 2 comments
Closed

Comments

@vikramnathan
Copy link

vikramnathan commented Nov 10, 2016

In the attached p4 file, I'm invoking the register read function declared at v1model.p4:74 as follows:

register<bit<128>>(32w1024) keys;
apply {
    bit<128> k = 0;
    keys.read(k, 32w1);
}

This compiles using the p4-bm2-ss binary but fails when run on the simple switch target:

$ sudo ../behavioral-model/targets/simple_switch/simple_switch test.json
Thrift port was not specified, will use 9090
Calling target program-options parser
terminate called after throwing an instance of 'std::runtime_error'
  what():  in Json::Value::operator[](char const*)const: requires objectValue

I've also attached test.json for reference.

However, when I comment out keys.read(k, 32w1) or use keys.write(32k1, k) instead, simple_switch appears to be able to parse the JSON, getting as far as starting its thrift server.

Is this because theread capability is not supported in the behavioral model?

test.json.txt
test.p4.txt

@anirudhSK
Copy link
Contributor

anirudhSK commented Nov 10, 2016

#145 may be a symptom of the same problem: some extern methods from v1model.p4 aren't supported by bmv2, even though they compile fine. There's a hash function call in #145, reproduced below:

hash(meta.hash.hash,
         HashAlgorithm.crc16,
         (bit<16>)0, 
         { meta.ipv4.lkp_ipv4_sa },
         (bit<32>)65536);

Both hash (https://github.com/p4lang/p4c/blob/master/p4include/v1model.p4#L99) and register.read() (https://github.com/p4lang/p4c/blob/master/p4include/v1model.p4#L74) are extern methods declared in v1model.p4

@vikramnathan
Copy link
Author

vikramnathan commented Nov 11, 2016

It appears that this is fixed by a more recent commit (our guess is c3bdd1f).

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

2 participants