You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dpdk: make unique names for header and metadata struct fields (#3080)
* dpdk: inject local header variables into header struct instead of metadata struct
Instructions extract and lookahead in DPDK target assembler support
only operand which is a header, metadata fields are not supported
as operands.
Until now, all local variables were injected into main metadata
structure.
As a result, if there was an extract or lookahead call which
parsed the data from a packet into a header, there was generated
an instruction with metadata operand producing invalid spec file.
This commit makes a header from every local variable which is of
header type instead of adding it to main metadata structure.
* ExpandLookahead: add parameter for disabling expansion of headers
Some targets (f.e. DPDK target) may support lookahead with header
type argument directly without the need to expand the header,
but they might still require expansion of structures.
ExpandLookahead pass can be utilized for such targets when a new
parameter which allows to disable expansion of headers is added.
This change is backwards compatible as a default behavior remains
the same and a new parameter for constructor is optional.
* dpdk: transform base or structure type lookahead into header lookahead
Lookahead implementation in DPDK target supports only header instance
as an operand.
Variables or metadata structure fields of other than header types need
to be either rejected or transformed so that there is used lookahead
with header instance operand.
This commit implements a transformation which converts all usages
of lookahead with other than header type argument to lookahead
with header type argument.
After P4::ExpandLookahead pass lookahead method may occur only
as an assignment to a header or base bit type as follows:
T var_name;
state state_name {
var_name = pkt.lookahead<T>();
}
Lookahead with header types arguments are unchanged by newly added pass
ConvertLookahead.
Lookahead with other than header type argument is transformed to
following:
header var_name_header {
T var_name;
}
T var_name;
var_name_header var_name_tmp_h;
state state_name {
var_name_tmp_h = pkt.lookahead<var_name_header>();
var_name = var_name_tmp_h.var_name;
}
Note (limitation):
Current maximum supported width of header fields in DPDK target
is 64 bits.
As ExpandLookahead pass expands structures used as type arguments
of lookahead method into bit type of the same width as the width
of the whole structure and there is created a temporary variable
of the given width which is than part of metadata structure,
maximum supported width of the structure used as a type argument
for lookahead is also 64 bits.
* dpdk: update extract and lookahead tests
* dpdk: package ConvertLookahead pass into PassManager
* dpdk: fix year in new test license
* ExpandLookahead: add more comments for new policy flag
* dpdk: change comment format
* dpdk: update psa test to not fail with bmv2
* dpdk: simplify naming of newly synthesized variables and headers
* dpdk: insert new headers before main headers structure
* dpdk: use base type instead of header with lookahead in psa test
* dpdk: make unique names for header and metadata struct fields
0 commit comments