bmv2
Designing your own switch target with bmv2
|
Go to the source code of this file.
Classes | |
class | bm::ActionPrimitive< Args > |
Macros | |
#define | REGISTER_PRIMITIVE(primitive_name) |
#define | REGISTER_PRIMITIVE_W_NAME(primitive_name, primitive) |
Each action primitive supported by the target needs to be declared as a functor. This is how you declare one:
You can then register them like this:
And use them by their name in the P4 program / JSON file:
Valid functor parameters for an action primitive include:
const Data &
for any P4 numerical values (it can be a P4 constant, a field, action data or the result of an expression).Data &
for a writable P4 numerical value (essentially a field)[const] Field &
for P4 field references[const] Header &
for P4 header referencesconst NamedCalculation &
for P4 field list calculations[const] MeterArray &
[const] CounterArray &
[const] RegisterArray &
[const] HeaderUnion &
[const] StackIface &
for arbitrary P4 stacks[const] HeaderStack &
for P4 header stacks[const] HeaderUnionStack &
for P4 header union stacksconst std::string &
or const char *
for stringsconst std::vector<Data>
for lists of numerical valuesYou can declare and register primitives anywhere in your switch target C++ code.
#define REGISTER_PRIMITIVE | ( | primitive_name | ) |
When implementing an action primitive for a target, this macro needs to be called to make this module aware of the primitive existence.
#define REGISTER_PRIMITIVE_W_NAME | ( | primitive_name, | |
primitive | |||
) |
This macro can also be called when registering a primitive for a target, in case you want to register the primitive under a different name than its functor name