Hi, I want my parser behaviour to be controlled by some values set by controller. My understanding is that, match action tables are a good way to do that. I was getting compiler errors while declaring a table and action in parser block.
Is this actually possible in BMV2. Or are there any other mechanisms by which parser behaviour can be controlled by the controller.
The P4 language spec does not allow tables to be instantiated within a parser. [1]
There are two other options I can suggest:
(a) P4 does support the idea of a value_set
contruct within a parser. Its main intended use is to use the result of the value set lookup in a transition select
statement, and is most often used to enable a handful of run-time configurable Ethernet protocol, IPv4/IPv6 protocol, or UDP destination port values to cause a particular parser transition to be selected, typically because a few of those values might differ in different places where a network device is deployed in a network. Search for value_set
in the P4_16 language spec for some words about it, and some code snippets: Specifications « P4 – Language Consortium
(b) You can do the best parsing job you can in the first pass, and any number of table lookups after parsing is done, and decide to resubmit or recirculate the packet, in an architecture like v1model, PSA, TNA, or PNA, preserving some metadata values that you looked up from one or more of the tables with the packet that can then be used during the next time the packet goes through your parser.
[1] Specifications « P4 – Language Consortium See Appendix F, the second table, row labeled “table”, column labeled “parser”, where the cell contains “no”, which means that it is not allowed to instantiate a table within a parser.
1 Like
Thanks a lot Andy.
I will look into value sets to see if they can be used for my problem. If not, I will use resubmit primitive in V1 model.