![]() |
P4C
The P4 Compiler
|
#include <bfruntime_arch_handler.h>
Classes | |
struct | SnapshotInfo |
Public Member Functions | |
BFRuntimeArchHandlerTofino (ReferenceMap *refMap, TypeMap *typeMap, const IR::ToplevelBlock *evaluatedProgram) | |
void | addExternFunction (const P4RuntimeSymbolTableIface &, p4configv1::P4Info *, const P4::ExternFunction *) override |
void | addExternInstance (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4info, const IR::ExternBlock *externBlock) override |
void | addLpf (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const Lpf &lpfInstance, const cstring pipeName) |
void | addParserChoices (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, cstring name, const ::barefoot::ParserChoices &parserChoices) |
void | addPortMetadata (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const PortMetadata &portMetadataExtract, const cstring &name, const IR::ParserBlock *parserBlock) |
void | addPortMetadataDefault (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const cstring &name, const IR::ParserBlock *parserBlock) |
void | addPortMetadataExternFunction (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4info, const P4::ExternFunction *externFunction, const IR::ParserBlock *parserBlock) |
void | addRegisterParam (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const RegisterParam ®isterParamInstance, cstring pipeName=cstring::empty) |
void | addSnapshot (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const SnapshotInfo &snapshotInstance) |
void | addTableProperties (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4info, p4configv1::Table *table, const IR::TableBlock *tableBlock) override |
void | addWred (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const Wred &wredInstance, const cstring pipeName) |
void | analyzeParser (const P4RuntimeSymbolTableIface &symbols, ::p4::config::v1::P4Info *p4info, const IR::ParserBlock *parserBlock) |
void | collectExternFunction (P4RuntimeSymbolTableIface *, const P4::ExternFunction *) override |
void | collectExternInstance (P4RuntimeSymbolTableIface *symbols, const IR::ExternBlock *externBlock) override |
Collects architecture-specific @externBlock instance in @symbols table. | |
void | collectExtra (P4RuntimeSymbolTableIface *symbols) override |
void | collectParserChoices (P4RuntimeSymbolTableIface *symbols) |
void | collectParserSymbols (P4RuntimeSymbolTableIface *symbols, const IR::ParserBlock *parserBlock) |
void | collectPortMetadataExternFunction (P4RuntimeSymbolTableIface *symbols, const P4::ExternFunction *externFunction, const IR::ParserBlock *parserBlock) |
void | collectSnapshot (P4RuntimeSymbolTableIface *symbols, const IR::ControlBlock *controlBlock, SnapshotFieldIdTable *fieldIds) |
template<typename Func> | |
void | forAllPipeBlocks (const IR::ToplevelBlock *evaluatedProgram, Func function) |
template<typename Func> | |
void | forAllPortMetadataBlocks (const IR::ToplevelBlock *evaluatedProgram, Func function) |
cstring | getBlockNamePrefix (const IR::Block *blk) override |
void | getSnapshotControls () |
void | postAdd (const P4RuntimeSymbolTableIface &symbols, ::p4::config::v1::P4Info *p4info) override |
void | postCollect (const P4RuntimeSymbolTableIface &symbols) override |
template<typename Kind> | |
void | setWredCommon (Kind *wred, const Wred &wredInstance) |
Set common fields between barefoot::Wred and barefoot::DirectWred. | |
![]() | |
google::protobuf::util::JsonPrintOptions | getJsonPrintOptions () override |
Control how JSON is output. | |
![]() | |
virtual void | addExternEntries (const p4::v1::WriteRequest *entries, const P4RuntimeSymbolTableIface &symbols, const IR::ExternBlock *externBlock)=0 |
This method is called to add target specific extern entries. | |
virtual void | addExternFunction (const P4RuntimeSymbolTableIface &symbols, ::p4::config::v1::P4Info *p4info, const P4::ExternFunction *externFunction)=0 |
virtual void | addExternInstance (const P4RuntimeSymbolTableIface &symbols, ::p4::config::v1::P4Info *p4info, const IR::ExternBlock *externBlock)=0 |
virtual void | addTableProperties (const P4RuntimeSymbolTableIface &symbols, ::p4::config::v1::P4Info *p4info, ::p4::config::v1::Table *table, const IR::TableBlock *tableBlock)=0 |
virtual void | collectAssignmentStatement (P4RuntimeSymbolTableIface *symbols, const IR::BaseAssignmentStatement *assign)=0 |
Collects architecture-specific used in assignment statements. | |
virtual void | collectExternMethod (P4RuntimeSymbolTableIface *symbols, const P4::ExternMethod *externMethod)=0 |
Collects architecture-specific @externMethod instance in @symbols table. | |
virtual void | collectTableProperties (P4RuntimeSymbolTableIface *symbols, const IR::TableBlock *tableBlock)=0 |
Static Public Member Functions | |
template<typename T> | |
static std::optional< T > | getDirectFilter (const IR::P4Table *table, ReferenceMap *refMap, TypeMap *typeMap, cstring filterType) |
static std::optional< Lpf > | getDirectLpf (const IR::P4Table *table, ReferenceMap *refMap, TypeMap *typeMap) |
static std::optional< Wred > | getDirectWred (const IR::P4Table *table, ReferenceMap *refMap, TypeMap *typeMap) |
static std::optional< PortMetadata > | getPortMetadataExtract (const P4::ExternFunction *function, ReferenceMap *refMap, TypeMap *typeMap, p4configv1::P4TypeInfo *p4RtTypeInfo) |
Additional Inherited Members | |
![]() | |
using | ArchCounterExtern |
using | ArchMeterExtern |
using | CounterTraits |
using | MeterTraits |
![]() | |
BFRuntimeArchHandlerCommon (ReferenceMap *refMap, TypeMap *typeMap, const IR::ToplevelBlock *evaluatedProgram) | |
void | addActionProfile (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const ActionProfile &actionProfile, cstring pipeName=cstring::empty) |
virtual void | addActionSelector (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const ActionSelector &actionSelector, cstring blockPrefix=cstring::empty) |
void | addCounter (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const Helpers::Counterlike< ArchCounterExtern > &counterInstance, const cstring blockPrefix=cstring::empty) |
void | addDigest (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const Digest &digestInstance, cstring pipeName=cstring::empty) |
void | addDynHash (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const DynHash &dynHashInstance, cstring pipeName=cstring::empty) |
void | addExternEntries (const p4::v1::WriteRequest *, const P4RuntimeSymbolTableIface &, const IR::ExternBlock *) override |
This method is called to add target specific extern entries. | |
void | addExternFunction (const P4RuntimeSymbolTableIface &, p4configv1::P4Info *, const P4::ExternFunction *) override |
void | addExternInstance (const P4RuntimeSymbolTableIface &, p4configv1::P4Info *, const IR::ExternBlock *) override |
void | addExternInstanceCommon (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4info, const IR::ExternBlock *externBlock, cstring pipeName=cstring::empty) |
void | addMeter (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const Helpers::Counterlike< ArchMeterExtern > &meterInstance, const cstring blockPrefix=cstring::empty) |
void | addRegister (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4Info, const Register ®isterInstance, cstring pipeName=cstring::empty) |
void | addTablePropertiesCommon (const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4info, p4configv1::Table *table, const IR::TableBlock *tableBlock, cstring blockPrefix=cstring::empty) |
void | addValueSet (const P4RuntimeSymbolTableIface &symbols, ::p4::config::v1::P4Info *p4info, const ValueSet &valueSetInstance) |
void | analyzeParser (const P4RuntimeSymbolTableIface &symbols, ::p4::config::v1::P4Info *p4info, const IR::ParserBlock *parserBlock) |
void | collectAssignmentStatement (P4RuntimeSymbolTableIface *, const IR::BaseAssignmentStatement *) override |
Collects architecture-specific used in assignment statements. | |
void | collectExternFunction (P4RuntimeSymbolTableIface *, const P4::ExternFunction *) override |
void | collectExternInstanceCommon (P4RuntimeSymbolTableIface *symbols, const IR::ExternBlock *externBlock) |
void | collectExternMethod (P4RuntimeSymbolTableIface *, const P4::ExternMethod *) override |
Collects architecture-specific @externMethod instance in @symbols table. | |
void | collectExtra (P4RuntimeSymbolTableIface *symbols) override |
void | collectParserSymbols (P4RuntimeSymbolTableIface *symbols, const IR::ParserBlock *parserBlock) |
void | collectTableProperties (P4RuntimeSymbolTableIface *symbols, const IR::TableBlock *tableBlock) override |
bool | filterAnnotations (cstring) override |
called when processing annotations via setPreamble | |
void | forAllExternMethodCalls (const IR::IDeclaration *object, Func function) |
calls function on every extern method applied to the extern object | |
std::optional< ActionProfile > | getActionProfile (const IR::P4Table *table, ReferenceMap *refMap, TypeMap *typeMap) |
std::optional< ActionSelector > | getActionSelector (const IR::ExternBlock *instance) |
std::optional< ActionSelector > | getActionSelector (const IR::P4Table *table, ReferenceMap *refMap, TypeMap *typeMap) |
cstring | getControlPlaneName (const IR::Block *block) override |
Get control plane name for @block. | |
cstring | getControlPlaneName (const IR::Block *block, const IR::IDeclaration *decl) |
std::optional< Digest > | getDigest (const IR::Declaration_Instance *decl, p4configv1::P4TypeInfo *p4RtTypeInfo) |
std::optional< DynHash > | getDynHash (const IR::Declaration_Instance *decl, p4configv1::P4TypeInfo *p4RtTypeInfo) |
cstring | getFullyQualifiedName (const IR::Block *block, const cstring name, bool skip_control_plane_name=false) |
const IR::IAnnotated * | getTableImplementationAnnotations (const IR::P4Table *table, ReferenceMap *refMap) |
std::optional< cstring > | getTableImplementationName (const IR::P4Table *table, ReferenceMap *refMap) |
const IR::Property * | getTableImplementationProperty (const IR::P4Table *table) |
void | postAdd (const P4RuntimeSymbolTableIface &symbols, ::p4::config::v1::P4Info *p4info) override |
void | setCounterCommon (Kind *counter, const Helpers::Counterlike< ArchCounterExtern > &counterInstance) |
Set common fields between barefoot::Counter and barefoot::DirectCounter. | |
void | setMeterCommon (Kind *meter, const Helpers::Counterlike< ArchMeterExtern > &meterInstance) |
Set common fields between barefoot::Meter and barefoot::DirectMeter. | |
![]() | |
static void | addP4InfoExternInstance (const P4RuntimeSymbolTableIface &symbols, P4::ControlPlaneAPI::P4RuntimeSymbolType typeId, cstring typeName, cstring name, const IR::IAnnotated *annotations, const ::google::protobuf::Message &message, p4configv1::P4Info *p4info) |
static std::optional< ActionProfile > | getActionProfile (const IR::ExternBlock *instance) |
static std::optional< Register > | getDirectRegister (const IR::P4Table *table, ReferenceMap *refMap, TypeMap *typeMap, p4configv1::P4TypeInfo *p4RtTypeInfo) |
static p4configv1::Extern * | getP4InfoExtern (P4::ControlPlaneAPI::P4RuntimeSymbolType typeId, cstring typeName, p4configv1::P4Info *p4info) |
static bool | getSupportsTimeout (const IR::P4Table *table) |
![]() | |
std::unordered_map< cstring, std::set< cstring > > | actionProfilesRefs |
Maps each action profile / selector to the set of tables referencing it. | |
std::unordered_set< cstring > | colorAwareMeters |
The set of color-aware meters in the program. | |
cstring | defaultPipeName |
const IR::ToplevelBlock * | evaluatedProgram |
cstring | implementationString |
google::protobuf::util::JsonPrintOptions | jsonPrintOptions |
ReferenceMap * | refMap |
TypeMap * | typeMap |
![]() | |
static constexpr int64_t | defaultMaxGroupSize |
Implements BFRuntimeArchHandlerIface for the Tofino architecture. The overridden methods will be called by the P4RuntimeSerializer to collect and serialize Tofino-specific symbols which are exposed to the control-plane.
struct BFN::BFRuntimeArchHandlerTofino::SnapshotInfo |
Holds information about each ingress and egress control flow in the P4 program. This information is used to generate the Snapshot messages in P4Info.
Class Members | ||
---|---|---|
set< SnapshotFieldInfo > | fields |
the control name as provided by the P4 program the list of fields to be exposed for snapshot for this control (including "POV bits"). Unlike previous struct fields, which are set by getSnapshotControls(), this vector is populated by collectSnapshot(). |
cstring | gress | one of "pipe0", "pipe1", "pipe2", "pipe3" |
cstring | name | the index of the "hdr" parameter in the control parameter list |
cstring | pipe | |
size_t | userHdrParamIdx | one of "ingress", "egress" |
|
inlineoverridevirtual |
Collects extern method call @externFunction in @symbols table in case it needs to be exposed to the control-plane (e.g. digest call for v1model).
Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.
|
inlineoverridevirtual |
Collects architecture-specific @externBlock instance in @symbols table.
Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.
|
inlineoverridevirtual |
Collects any extra symbols you may want to include in the symbol table and that are not covered by the above collection methods.
Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.
|
inline |
For programs not using the MultiParserSwitch package, this method does not do antyhing. Otherwise, for each pipe and each gress within each pipe, it builds the list of possible parsers. For each parser, we store the "architecture name", the "P4 type name" and the "user-provided name" (if applicable, i.e. if the P4 programmer used a declaration).
|
inline |
This method is called for each control block. If a control is relevant for snapshot - based on the snapshotInfo map populated by getSnapshotControls() - then we inspect its parameters using the SnapshotFieldFinder pass to build a list of snapshot fields. The caller is expected to pass the same fieldIds
table for every call to this method.
|
inlineoverridevirtual |
Reimplemented from BFN::BFRuntimeArchHandlerCommon< Arch::TNA >.
|
inlinestatic |
table
, if it has one, or std::nullopt otherwise. Used as a helper for getDirectLpf and getDirectWred.
|
inlinestatic |
table
, if it has one, or std::nullopt otherwise.
|
inlinestatic |
table
, if it has one, or std::nullopt otherwise.
|
inlinestatic |
|
inline |
Looks at all control objects relevant to snapshot (based on architecture knowledge) and populates the snapshotInfo map.
|
inlineoverridevirtual |
This method is called after the add pass in case the architecture requires some logic to be performed then.
Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.
|
inlineoverridevirtual |
This method is called between the two passes (collect and add) in case the architecture requires some logic to be performed then.
Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.