17#ifndef BACKENDS_EBPF_EBPFTABLE_H_
18#define BACKENDS_EBPF_EBPFTABLE_H_
20#include "ebpfObject.h"
21#include "ebpfProgram.h"
22#include "frontends/p4/methodInstance.h"
29 const IR::P4Action *action;
37 valueName(valueName) {
41 bool preorder(
const IR::PathExpression *expression);
43 bool preorder(
const IR::P4Action *act);
44 virtual cstring getParamInstanceName(
const IR::Expression *expression)
const;
45 bool isActionParameter(
const IR::PathExpression *expression)
const;
61 : program(program), instanceName(instanceName), codeGen(codeGen) {
64 keyTypeName = instanceName +
"_key";
65 valueTypeName = instanceName +
"_value";
66 dataMapName = instanceName;
73 const int prefixLenFieldWidth = 32;
79 bool isTernaryTable()
const;
91 const IR::Key *keyGenerator;
92 const IR::ActionList *actionList;
93 const IR::TableBlock *table;
95 std::map<const IR::KeyElement *, cstring> keyFieldNames;
96 std::map<const IR::KeyElement *, EBPFType *> keyTypes;
100 const cstring prefixFieldName =
"prefixlen"_cs;
105 cstring p4ActionToActionIDName(
const IR::P4Action *action)
const;
106 void emitActionArguments(
CodeBuilder *builder,
const IR::P4Action *action,
cstring name);
113 virtual void emitValueActionIDNames(
CodeBuilder *builder);
114 virtual void emitValueStructStructure(
CodeBuilder *builder);
118 virtual void emitInitializer(
CodeBuilder *builder);
122 (void)actionRunVariable;
123 builder->target->emitTableLookup(builder, defaultActionMapName, key, value);
124 builder->endOfStatement(
true);
126 virtual bool isMatchTypeSupported(
const IR::Declaration_ID *matchType) {
127 return matchType->name.name == P4::P4CoreLibrary::instance().exactMatch.name ||
128 matchType->name.name == P4::P4CoreLibrary::instance().ternaryMatch.name ||
129 matchType->name.name == P4::P4CoreLibrary::instance().lpmMatch.name;
135 virtual bool cacheEnabled() {
return false; }
136 virtual void emitCacheLookup(CodeBuilder *builder,
cstring key,
cstring value) {
141 virtual void emitCacheUpdate(CodeBuilder *builder, cstring key, cstring value) {
147 DECLARE_TYPEINFO(EBPFTable, EBPFTableBase);
159 size_t size,
bool isHash)
160 :
EBPFTableBase(program, name, codeGen), size(size), isHash(isHash) {}
163 virtual void emitCounterIncrement(
CodeBuilder *builder,
164 const IR::MethodCallExpression *expression);
165 virtual void emitCounterAdd(
CodeBuilder *builder,
const IR::MethodCallExpression *expression);
174 const IR::P4ValueSet *pvs;
175 std::vector<std::pair<cstring, const IR::Type *>> fieldNames;
184 void emitKeyInitializer(
CodeBuilder *builder,
const IR::SelectExpression *expression,
Definition ebpfTable.h:26
Definition ebpf/codeGen.h:33
Definition ebpf/codeGen.h:41
CodeGenInspector(P4::ReferenceMap *refMap, P4::TypeMap *typeMap)
precedence of current IR::Operation
Definition ebpf/codeGen.h:57
Definition ebpfTable.h:150
Base class for EBPF objects.
Definition ebpfObject.h:31
Definition ebpfProgram.h:39
Also used to represent counters.
Definition ebpfTable.h:49
Definition ebpfTable.h:72
virtual bool dropOnNoMatchingEntryFound() const
Definition ebpfTable.h:133
virtual void emitDirectValueTypes(CodeBuilder *builder)
Emits value types used by direct externs.
Definition ebpfTable.h:116
size_t size
Definition ebpfTable.h:99
bool isLPMTable() const
Definition ebpfTable.cpp:867
virtual void validateKeys() const
Definition ebpfTable.cpp:111
Definition ebpfTable.h:171
Definition methodInstance.h:168
Definition codeGen.cpp:25