P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::EBPF::EBPFTablePSA Class Reference
Inheritance diagram for P4::EBPF::EBPFTablePSA:
[legend]

Public Member Functions

 EBPFTablePSA (const EBPFProgram *program, CodeGenInspector *codeGen, cstring name)
 
 EBPFTablePSA (const EBPFProgram *program, const IR::TableBlock *table, CodeGenInspector *codeGen)
 
bool cacheEnabled () override
 
 DECLARE_TYPEINFO (EBPFTablePSA, EBPFTable)
 
bool dropOnNoMatchingEntryFound () const override
 
void emitAction (CodeBuilder *builder, cstring valueName, cstring actionRunVariable) override
 
void emitCacheInstance (CodeBuilder *builder)
 
void emitCacheLookup (CodeBuilder *builder, cstring key, cstring value) override
 
virtual void emitCacheTypes (CodeBuilder *builder)
 
void emitCacheUpdate (CodeBuilder *builder, cstring key, cstring value) override
 
void emitDirectValueTypes (CodeBuilder *builder) override
 
void emitInitializer (CodeBuilder *builder) override
 
void emitInstance (CodeBuilder *builder) override
 
void emitLookupDefault (CodeBuilder *builder, cstring key, cstring value, cstring actionRunVariable) override
 
void emitTypes (CodeBuilder *builder) override
 
void emitValueStructStructure (CodeBuilder *builder) override
 
const IR::PathExpression * getActionNameExpression (const IR::Expression *expr) const
 
EBPFCounterPSAgetDirectCounter (cstring name) const
 
EBPFMeterPSAgetMeter (cstring name) const
 
bool isMatchTypeSupported (const IR::Declaration_ID *matchType) override
 
- Public Member Functions inherited from P4::EBPF::EBPFTable
 EBPFTable (const EBPFProgram *program, CodeGenInspector *codeGen, cstring name)
 
 EBPFTable (const EBPFProgram *program, const IR::TableBlock *table, CodeGenInspector *codeGen)
 
 DECLARE_TYPEINFO (EBPFTable, EBPFTableBase)
 
void emitActionArguments (CodeBuilder *builder, const IR::P4Action *action, cstring name)
 
void emitKey (CodeBuilder *builder, cstring keyName)
 
virtual void emitKeyType (CodeBuilder *builder)
 
virtual void emitLookup (CodeBuilder *builder, cstring key, cstring value)
 
virtual void emitValueActionIDNames (CodeBuilder *builder)
 
virtual void emitValueType (CodeBuilder *builder)
 
bool isLPMTable () const
 
bool isTernaryTable () const
 
cstring p4ActionToActionIDName (const IR::P4Action *action) const
 
- Public Member Functions inherited from P4::EBPF::EBPFObject
 DECLARE_TYPEINFO (EBPFObject)
 
- Public Member Functions inherited from P4::ICastable
template<typename T >
T & as ()
 Tries to convert the class to type T. A BUG occurs if the cast fails.
 
template<typename T >
const T & as () const
 Tries to convert the class to type T. A BUG occurs if the cast fails.
 
template<typename T >
T * checkedTo ()
 Performs a checked cast. A BUG occurs if the cast fails.
 
template<typename T >
const T * checkedTo () const
 Performs a checked cast. A BUG occurs if the cast fails.
 
- Public Member Functions inherited from P4::RTTI::Base
template<typename T >
bool is () const noexcept
 
virtual bool isA (TypeId typeId) const noexcept=0
 
template<typename T >
const T * to () const noexcept
 Same as to, but returns const pointer to T.
 
template<typename T >
T * to () noexcept
 
virtual TypeId typeId () const noexcept=0
 

Static Public Member Functions

static cstring addPrefixFunc (bool trace)
 
- Static Public Member Functions inherited from P4::EBPF::EBPFObject
static cstring externalName (const IR::IDeclaration *declaration)
 
static cstring getSpecializedTypeName (const IR::Declaration_Instance *di)
 
static cstring getTypeName (const IR::Declaration_Instance *di)
 

Public Attributes

std::vector< std::pair< cstring, EBPFCounterPSA * > > counters
 
EBPFTableImplementationPSAimplementation
 
std::vector< std::pair< cstring, EBPFMeterPSA * > > meters
 
- Public Attributes inherited from P4::EBPF::EBPFTable
const IR::ActionList * actionList
 
cstring defaultActionMapName
 
std::map< const IR::KeyElement *, cstringkeyFieldNames
 
const IR::Key * keyGenerator
 
std::map< const IR::KeyElement *, EBPFType * > keyTypes
 
const cstring prefixFieldName = "prefixlen"_cs
 
size_t size = 1024
 
const IR::TableBlock * table
 
- Public Attributes inherited from P4::EBPF::EBPFTableBase
CodeGenInspectorcodeGen
 
cstring dataMapName
 
cstring instanceName
 
cstring keyTypeName
 
const EBPFProgramprogram
 
cstring valueTypeName
 

Protected Member Functions

ActionTranslationVisitorcreateActionTranslationVisitor (cstring valueName, const EBPFProgram *program) const override
 
void createCacheTypeNames (bool isCacheKeyType, bool isCacheValueType)
 
void emitConstEntriesInitializer (CodeBuilder *builder)
 
void emitDefaultActionInitializer (CodeBuilder *builder)
 
void emitKeyMasks (CodeBuilder *builder, EntriesGroupedByMask_t &entriesGroupedByMask, std::vector< cstring > &keyMasksNames)
 
void emitKeysAndValues (CodeBuilder *builder, EntriesGroup_t &sameMaskEntries, std::vector< cstring > &keyNames, std::vector< cstring > &valueNames)
 
void emitMapUpdateTraceMsg (CodeBuilder *builder, cstring mapName, cstring returnCode) const
 
void emitTableValue (CodeBuilder *builder, const IR::Expression *expr, cstring valueName)
 
void emitTernaryConstEntriesInitializer (CodeBuilder *builder)
 
void emitValueMask (CodeBuilder *builder, cstring valueMask, cstring nextMask, int tupleId) const
 
void initDirectCounters ()
 
void initDirectMeters ()
 
void initImplementation ()
 
void tryEnableTableCache ()
 
- Protected Member Functions inherited from P4::EBPF::EBPFTable
void emitTernaryInstance (CodeBuilder *builder)
 
virtual void validateKeys () const
 
- Protected Member Functions inherited from P4::EBPF::EBPFTableBase
 EBPFTableBase (const EBPFProgram *program, cstring instanceName, CodeGenInspector *codeGen)
 
 DECLARE_TYPEINFO (EBPFTableBase, EBPFObject)
 
- Protected Member Functions inherited from P4::RTTI::Base
virtual const void * toImpl (TypeId typeId) const noexcept=0
 

Protected Attributes

cstring cacheKeyTypeName
 
cstring cacheTableName
 
cstring cacheValueTypeName
 
bool tableCacheEnabled = false
 

Member Function Documentation

◆ cacheEnabled()

bool P4::EBPF::EBPFTablePSA::cacheEnabled ( )
inlineoverridevirtual

Reimplemented from P4::EBPF::EBPFTable.

◆ createActionTranslationVisitor()

ActionTranslationVisitor * P4::EBPF::EBPFTablePSA::createActionTranslationVisitor ( cstring valueName,
const EBPFProgram * program ) const
overrideprotectedvirtual

Reimplemented from P4::EBPF::EBPFTable.

◆ dropOnNoMatchingEntryFound()

bool P4::EBPF::EBPFTablePSA::dropOnNoMatchingEntryFound ( ) const
overridevirtual

Whether to drop packet if no match entry found. Some table implementations may want to continue processing.

Reimplemented from P4::EBPF::EBPFTable.

◆ emitAction()

void P4::EBPF::EBPFTablePSA::emitAction ( CodeBuilder * builder,
cstring valueName,
cstring actionRunVariable )
overridevirtual

Reimplemented from P4::EBPF::EBPFTable.

◆ emitCacheLookup()

void P4::EBPF::EBPFTablePSA::emitCacheLookup ( CodeBuilder * builder,
cstring key,
cstring value )
overridevirtual

Reimplemented from P4::EBPF::EBPFTable.

◆ emitCacheUpdate()

void P4::EBPF::EBPFTablePSA::emitCacheUpdate ( CodeBuilder * builder,
cstring key,
cstring value )
overridevirtual

Reimplemented from P4::EBPF::EBPFTable.

◆ emitDirectValueTypes()

void P4::EBPF::EBPFTablePSA::emitDirectValueTypes ( CodeBuilder * builder)
overridevirtual

Order of emitting counters and meters affects generated layout of BPF map value. Do not change this order!

Reimplemented from P4::EBPF::EBPFTable.

◆ emitInitializer()

void P4::EBPF::EBPFTablePSA::emitInitializer ( CodeBuilder * builder)
overridevirtual

Reimplemented from P4::EBPF::EBPFTable.

◆ emitInstance()

void P4::EBPF::EBPFTablePSA::emitInstance ( CodeBuilder * builder)
overridevirtual

Reimplemented from P4::EBPF::EBPFTable.

◆ emitLookupDefault()

void P4::EBPF::EBPFTablePSA::emitLookupDefault ( CodeBuilder * builder,
cstring key,
cstring value,
cstring actionRunVariable )
overridevirtual

Reimplemented from P4::EBPF::EBPFTable.

◆ emitTypes()

void P4::EBPF::EBPFTablePSA::emitTypes ( CodeBuilder * builder)
overridevirtual

Reimplemented from P4::EBPF::EBPFTable.

◆ emitValueStructStructure()

void P4::EBPF::EBPFTablePSA::emitValueStructStructure ( CodeBuilder * builder)
overridevirtual

Reimplemented from P4::EBPF::EBPFTable.

◆ isMatchTypeSupported()

bool P4::EBPF::EBPFTablePSA::isMatchTypeSupported ( const IR::Declaration_ID * matchType)
inlineoverridevirtual

Reimplemented from P4::EBPF::EBPFTable.

Member Data Documentation

◆ counters

std::vector<std::pair<cstring, EBPFCounterPSA *> > P4::EBPF::EBPFTablePSA::counters

We use vectors to keep an order of Direct Meters or Counters from a P4 program. This order is important from CLI tool point of view.