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

Unsupported types for log_msg calls #2201

Closed
jafingerhut opened this issue Feb 18, 2020 · 2 comments
Closed

Unsupported types for log_msg calls #2201

jafingerhut opened this issue Feb 18, 2020 · 2 comments
Labels
enhancement This topic discusses an improvement to existing compiler code. fixed This topic is considered to be fixed.

Comments

@jafingerhut
Copy link
Contributor

I had a fairly decent sized v1model P4 program that was causing simple_switch to give an error message very soon after starting up, about some unexpected contents inside of the BMv2 JSON file, and it took a while to whittle it down and discover it was because I was trying to do log_msg on a value of type bool. Casting it to a bit<1> type caused things to work. It would be nice to at least document what types are supported, and preferably give a compile time error message for unsupported types.

From my experiments using the attached P4 program, it appears that these types cause either cryptic errors when starting simple_switch, or a run-time error and simple_switch crash when the log_msg statement is executed:

  • bool - cryptic error at simple_switch start time
  • header - crash when attempting to execute log_msg call, but at least fairly easy to localize in the code
  • struct - same as header, even if all fields of the struct are of type bit<W>

I did not try header_union, header stack, or anything more 'exotic' than header or struct, but would expect they have the same behavior as header/struct.

One enhancement possibility - Change p4c bmv2 back end to give an error if an unsupported type is used as argument to log_msg calls.

Whatever list of supported/unsupported types we decide upon, I am happy to document, either in the v1model.p4 #include file, or here, whichever seems most appropriate: https://github.com/p4lang/behavioral-model/blob/master/docs/simple_switch.md

@jafingerhut jafingerhut added the enhancement This topic discusses an improvement to existing compiler code. label Feb 18, 2020
@jafingerhut
Copy link
Contributor Author

Actually attaching example program I mentioned in comment above.
log-msg-supported-types.p4.txt

@mihaibudiu mihaibudiu added the fixed This topic is considered to be fixed. label Jul 1, 2020
@jafingerhut
Copy link
Contributor Author

Confirmed that this PR fixed this issue. Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This topic discusses an improvement to existing compiler code. fixed This topic is considered to be fixed.
Projects
None yet
Development

No branches or pull requests

2 participants