P4C
The P4 Compiler
Loading...
Searching...
No Matches
BFN::BFRuntimeArchHandlerCommon< arch > Class Template Reference

#include <bfruntime_arch_handler.h>

Inheritance diagram for BFN::BFRuntimeArchHandlerCommon< arch >:
[legend]

Public Member Functions

google::protobuf::util::JsonPrintOptions getJsonPrintOptions () override
 Control how JSON is output.
 
- Public Member Functions inherited from P4::ControlPlaneAPI::P4RuntimeArchHandlerIface
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 collectExternInstance (P4RuntimeSymbolTableIface *symbols, const IR::ExternBlock *externBlock)=0
 Collects architecture-specific @externBlock instance in @symbols table.
 
virtual void postCollect (const P4RuntimeSymbolTableIface &symbols)=0
 

Protected Types

using ArchCounterExtern = CounterExtern<arch>
 
using ArchMeterExtern = MeterExtern<arch>
 
using CounterTraits = Helpers::CounterlikeTraits<ArchCounterExtern>
 
using MeterTraits = Helpers::CounterlikeTraits<ArchMeterExtern>
 

Protected Member Functions

 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
 
template<typename Func >
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)
 
virtual cstring getBlockNamePrefix (const IR::Block *)
 
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
 
template<typename Kind >
void setCounterCommon (Kind *counter, const Helpers::Counterlike< ArchCounterExtern > &counterInstance)
 Set common fields between barefoot::Counter and barefoot::DirectCounter.
 
template<typename Kind >
void setMeterCommon (Kind *meter, const Helpers::Counterlike< ArchMeterExtern > &meterInstance)
 Set common fields between barefoot::Meter and barefoot::DirectMeter.
 

Static Protected Member Functions

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

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 = "pipe"_cs
 
const IR::ToplevelBlock * evaluatedProgram
 
cstring implementationString
 
google::protobuf::util::JsonPrintOptions jsonPrintOptions
 
ReferenceMaprefMap
 
TypeMaptypeMap
 

Static Protected Attributes

static constexpr int64_t defaultMaxGroupSize = 120
 

Detailed Description

template<Arch arch>
class BFN::BFRuntimeArchHandlerCommon< arch >

Parent class for BFRuntimeArchHandlerV1Model and BFRuntimeArchHandlerPSA; it includes all the common code between the two architectures (which is only dependent on the arch template parameter.

Member Function Documentation

◆ addExternEntries()

template<Arch arch>
void BFN::BFRuntimeArchHandlerCommon< arch >::addExternEntries ( const p4::v1::WriteRequest * entries,
const P4RuntimeSymbolTableIface & symbols,
const IR::ExternBlock * externBlock )
inlineoverrideprotectedvirtual

This method is called to add target specific extern entries.

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ collectAssignmentStatement()

template<Arch arch>
void BFN::BFRuntimeArchHandlerCommon< arch >::collectAssignmentStatement ( P4RuntimeSymbolTableIface * symbols,
const IR::AssignmentStatement * assign )
inlineoverrideprotectedvirtual

Collects architecture-specific used in assignment statements.

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ collectExternFunction()

template<Arch arch>
void BFN::BFRuntimeArchHandlerCommon< arch >::collectExternFunction ( P4RuntimeSymbolTableIface * symbols,
const P4::ExternFunction * externFunction )
inlineoverrideprotectedvirtual

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.

◆ collectExternMethod()

template<Arch arch>
void BFN::BFRuntimeArchHandlerCommon< arch >::collectExternMethod ( P4RuntimeSymbolTableIface * symbols,
const P4::ExternMethod * externMethod )
inlineoverrideprotectedvirtual

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

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ collectExtra()

template<Arch arch>
void BFN::BFRuntimeArchHandlerCommon< arch >::collectExtra ( P4RuntimeSymbolTableIface * symbols)
inlineoverrideprotectedvirtual

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.

◆ collectTableProperties()

template<Arch arch>
void BFN::BFRuntimeArchHandlerCommon< arch >::collectTableProperties ( P4RuntimeSymbolTableIface * symbols,
const IR::TableBlock * tableBlock )
inlineoverrideprotectedvirtual

Collects architecture-specific properties for @tableBlock in @symbols table.

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ filterAnnotations()

template<Arch arch>
bool BFN::BFRuntimeArchHandlerCommon< arch >::filterAnnotations ( cstring anno)
inlineoverrideprotectedvirtual

called when processing annotations via setPreamble

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ getActionProfile() [1/2]

template<Arch arch>
static std::optional< ActionProfile > BFN::BFRuntimeArchHandlerCommon< arch >::getActionProfile ( const IR::ExternBlock * instance)
inlinestaticprotected
Returns
the action profile corresponding to instance.

◆ getActionProfile() [2/2]

template<Arch arch>
std::optional< ActionProfile > BFN::BFRuntimeArchHandlerCommon< arch >::getActionProfile ( const IR::P4Table * table,
ReferenceMap * refMap,
TypeMap * typeMap )
inlineprotected
Returns
the action profile referenced in the implementation property of table, if it has one, or std::nullopt otherwise.

◆ getActionSelector()

template<Arch arch>
std::optional< ActionSelector > BFN::BFRuntimeArchHandlerCommon< arch >::getActionSelector ( const IR::P4Table * table,
ReferenceMap * refMap,
TypeMap * typeMap )
inlineprotected
Returns
the action profile referenced in table's implementation property, if it has one, or std::nullopt otherwise.

◆ getControlPlaneName()

template<Arch arch>
cstring BFN::BFRuntimeArchHandlerCommon< arch >::getControlPlaneName ( const IR::Block * block)
inlineoverrideprotectedvirtual

Get control plane name for @block.

Reimplemented from P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ getDirectRegister()

template<Arch arch>
static std::optional< Register > BFN::BFRuntimeArchHandlerCommon< arch >::getDirectRegister ( const IR::P4Table * table,
ReferenceMap * refMap,
TypeMap * typeMap,
p4configv1::P4TypeInfo * p4RtTypeInfo )
inlinestaticprotected
Returns
the direct register associated with table, if it has one, or std::nullopt otherwise.

◆ getJsonPrintOptions()

template<Arch arch>
google::protobuf::util::JsonPrintOptions BFN::BFRuntimeArchHandlerCommon< arch >::getJsonPrintOptions ( )
inlineoverridevirtual

Control how JSON is output.

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.

◆ getSupportsTimeout()

template<Arch arch>
static bool BFN::BFRuntimeArchHandlerCommon< arch >::getSupportsTimeout ( const IR::P4Table * table)
inlinestaticprotected
Returns
true if table's 'idle_timeout' property exists and is true. This indicates that table supports entry ageing.

◆ getTableImplementationProperty()

template<Arch arch>
const IR::Property * BFN::BFRuntimeArchHandlerCommon< arch >::getTableImplementationProperty ( const IR::P4Table * table)
inlineprotected
Returns
the table implementation property, or nullptr if the table has no such property.

◆ postAdd()

template<Arch arch>
void BFN::BFRuntimeArchHandlerCommon< arch >::postAdd ( const P4RuntimeSymbolTableIface & symbols,
::p4::config::v1::P4Info * p4info )
inlineoverrideprotectedvirtual

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

Implements P4::ControlPlaneAPI::P4RuntimeArchHandlerIface.