P4C
The P4 Compiler
Loading...
Searching...
No Matches
BFN::BFRuntimeArchHandlerTofino Class Referencefinal

#include <bfruntime_arch_handler.h>

Inheritance diagram for BFN::BFRuntimeArchHandlerTofino:
[legend]

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 &registerParamInstance, 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.
 
- Public Member Functions inherited from BFN::BFRuntimeArchHandlerCommon< Arch::TNA >
google::protobuf::util::JsonPrintOptions getJsonPrintOptions () override
 Control how JSON is output.
 
- Public Member Functions inherited from P4::ControlPlaneAPI::P4RuntimeArchHandlerIface
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::AssignmentStatement *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< LpfgetDirectLpf (const IR::P4Table *table, ReferenceMap *refMap, TypeMap *typeMap)
 
static std::optional< WredgetDirectWred (const IR::P4Table *table, ReferenceMap *refMap, TypeMap *typeMap)
 
static std::optional< PortMetadatagetPortMetadataExtract (const P4::ExternFunction *function, ReferenceMap *refMap, TypeMap *typeMap, p4configv1::P4TypeInfo *p4RtTypeInfo)
 

Additional Inherited Members

- Protected Types inherited from BFN::BFRuntimeArchHandlerCommon< Arch::TNA >
using ArchCounterExtern
 
using ArchMeterExtern
 
using CounterTraits
 
using MeterTraits
 
- Protected Member Functions inherited from BFN::BFRuntimeArchHandlerCommon< Arch::TNA >
 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 &registerInstance, 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::AssignmentStatement *) 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< ActionProfilegetActionProfile (const IR::P4Table *table, ReferenceMap *refMap, TypeMap *typeMap)
 
std::optional< ActionSelectorgetActionSelector (const IR::ExternBlock *instance)
 
std::optional< ActionSelectorgetActionSelector (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< DigestgetDigest (const IR::Declaration_Instance *decl, p4configv1::P4TypeInfo *p4RtTypeInfo)
 
std::optional< DynHashgetDynHash (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< cstringgetTableImplementationName (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 Protected Member Functions inherited from BFN::BFRuntimeArchHandlerCommon< Arch::TNA >
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< ActionProfilegetActionProfile (const IR::ExternBlock *instance)
 
static std::optional< RegistergetDirectRegister (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)
 
- Protected Attributes inherited from BFN::BFRuntimeArchHandlerCommon< Arch::TNA >
std::unordered_map< cstring, std::set< cstring > > actionProfilesRefs
 Maps each action profile / selector to the set of tables referencing it.
 
std::unordered_set< cstringcolorAwareMeters
 The set of color-aware meters in the program.
 
cstring defaultPipeName
 
const IR::ToplevelBlock * evaluatedProgram
 
cstring implementationString
 
google::protobuf::util::JsonPrintOptions jsonPrintOptions
 
ReferenceMaprefMap
 
TypeMaptypeMap
 
- Static Protected Attributes inherited from BFN::BFRuntimeArchHandlerCommon< Arch::TNA >
static constexpr int64_t defaultMaxGroupSize
 

Detailed Description

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.


Class Documentation

◆ BFN::BFRuntimeArchHandlerTofino::SnapshotInfo

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"

Member Function Documentation

◆ collectExternFunction()

void BFN::BFRuntimeArchHandlerTofino::collectExternFunction ( P4RuntimeSymbolTableIface * symbols,
const P4::ExternFunction * externFunction )
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.

◆ collectExternInstance()

void BFN::BFRuntimeArchHandlerTofino::collectExternInstance ( P4RuntimeSymbolTableIface * symbols,
const IR::ExternBlock * externBlock )
inlineoverridevirtual

Collects architecture-specific @externBlock instance in @symbols table.

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ collectExtra()

void BFN::BFRuntimeArchHandlerTofino::collectExtra ( P4RuntimeSymbolTableIface * symbols)
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.

◆ collectParserChoices()

void BFN::BFRuntimeArchHandlerTofino::collectParserChoices ( P4RuntimeSymbolTableIface * symbols)
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).

◆ collectSnapshot()

void BFN::BFRuntimeArchHandlerTofino::collectSnapshot ( P4RuntimeSymbolTableIface * symbols,
const IR::ControlBlock * controlBlock,
SnapshotFieldIdTable * fieldIds )
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.

◆ getBlockNamePrefix()

cstring BFN::BFRuntimeArchHandlerTofino::getBlockNamePrefix ( const IR::Block * blk)
inlineoverridevirtual

◆ getDirectFilter()

template<typename T >
static std::optional< T > BFN::BFRuntimeArchHandlerTofino::getDirectFilter ( const IR::P4Table * table,
ReferenceMap * refMap,
TypeMap * typeMap,
cstring filterType )
inlinestatic
Returns
the direct filter instance associated with table, if it has one, or std::nullopt otherwise. Used as a helper for getDirectLpf and getDirectWred.

◆ getDirectLpf()

static std::optional< Lpf > BFN::BFRuntimeArchHandlerTofino::getDirectLpf ( const IR::P4Table * table,
ReferenceMap * refMap,
TypeMap * typeMap )
inlinestatic
Returns
the direct Lpf instance associated with table, if it has one, or std::nullopt otherwise.

◆ getDirectWred()

static std::optional< Wred > BFN::BFRuntimeArchHandlerTofino::getDirectWred ( const IR::P4Table * table,
ReferenceMap * refMap,
TypeMap * typeMap )
inlinestatic
Returns
the direct Wred instance associated with table, if it has one, or std::nullopt otherwise.

◆ getPortMetadataExtract()

static std::optional< PortMetadata > BFN::BFRuntimeArchHandlerTofino::getPortMetadataExtract ( const P4::ExternFunction * function,
ReferenceMap * refMap,
TypeMap * typeMap,
p4configv1::P4TypeInfo * p4RtTypeInfo )
inlinestatic
Returns
serialization information for the port_metadata_extract() call represented by call, or std::nullopt if call is not a port_metadata_extract() call or is invalid.

◆ getSnapshotControls()

void BFN::BFRuntimeArchHandlerTofino::getSnapshotControls ( )
inline

Looks at all control objects relevant to snapshot (based on architecture knowledge) and populates the snapshotInfo map.

◆ postAdd()

void BFN::BFRuntimeArchHandlerTofino::postAdd ( const P4RuntimeSymbolTableIface & symbols,
::p4::config::v1::P4Info * p4info )
inlineoverridevirtual

This method is called after the add pass in case the architecture requires some logic to be performed then.

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ postCollect()

void BFN::BFRuntimeArchHandlerTofino::postCollect ( const P4RuntimeSymbolTableIface & symbols)
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.