Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Wrong action params references in ternary operator's conditional expressions #14

Closed
shouxi opened this issue Aug 13, 2016 · 3 comments
Closed
Assignees

Comments

@shouxi
Copy link

shouxi commented Aug 13, 2016

Hi @antoninbas , a new bug follows #13
IIRC, the right reference of an action param is in the form of

{"type":"runtime_data", "value": param_index}.

But,

{"type": "hexstr", "value": hexstr(param_index)}

is given, if the param is used by a ternary operator. See L436 of the following json file as an example.

simple_router.json.txt
simple_router.p4.txt

@shouxi shouxi changed the title Wrong action params references in ternary operator's expressions Wrong action params references in ternary operator's conditional expressions Aug 13, 2016
@antoninbas antoninbas self-assigned this Aug 15, 2016
@antoninbas
Copy link
Member

hopefully fixed by f5f41af

@shouxi
Copy link
Author

shouxi commented Aug 15, 2016

Works. Cheers! BTW, what is the difference between local and runtime_data? they both act as param references?

@antoninbas
Copy link
Member

expression support was added late in bmv2. So a direct reference to an action parameter (e.g. hdrA.f1 = param1) is treated a little differently from a reference in an expression (e.g. hdrA.f1 = param1 + 7).
In the first case, you will see a runtime_data in the JSON. In the second case, the assignment will take as the source an expression and the parameter reference will appear as local. local in expression is a little more generic than just for handling runtime data in actions. It can be used for other things. For example, I may be using it in the parser code to compute the length of a variable length field (in this case local is used for previously extracted fields in the header). In other words, local can be used to represent arbitrary variables in an expression, whose value does not need to be known until the expression is evaluated.

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

No branches or pull requests

2 participants