31 struct ConstTernaryEntryDesc {
32 const IR::Entry *entry;
35 typedef std::vector<ConstTernaryEntryDesc> EntriesGroup_t;
36 typedef std::vector<EntriesGroup_t> EntriesGroupedByMask_t;
37 EntriesGroupedByMask_t getConstEntriesGroupedByMask();
38 bool hasConstEntries();
39 const cstring addPrefixFunctionName =
"add_prefix_and_entries"_cs;
40 const cstring tuplesMapName = instanceName +
"_tuples_map"_cs;
41 const cstring prefixesMapName = instanceName +
"_prefixes"_cs;
47 void initDirectCounters();
48 void initDirectMeters();
49 void initImplementation();
51 bool tableCacheEnabled =
false;
55 void tryEnableTableCache();
56 void createCacheTypeNames(
bool isCacheKeyType,
bool isCacheValueType);
58 void emitTableValue(
CodeBuilder *builder,
const IR::Expression *expr,
cstring valueName);
59 void emitDefaultActionInitializer(
CodeBuilder *builder);
60 void emitConstEntriesInitializer(
CodeBuilder *builder);
61 void emitTernaryConstEntriesInitializer(
CodeBuilder *builder);
65 void emitKeyMasks(
CodeBuilder *builder, EntriesGroupedByMask_t &entriesGroupedByMask,
66 std::vector<cstring> &keyMasksNames);
67 void emitKeysAndValues(
CodeBuilder *builder, EntriesGroup_t &sameMaskEntries,
68 std::vector<cstring> &keyNames, std::vector<cstring> &valueNames);
73 std::vector<std::pair<cstring, EBPFCounterPSA *>>
counters;
74 std::vector<std::pair<cstring, EBPFMeterPSA *>> meters;
83 void emitValueStructStructure(
CodeBuilder *builder)
override;
85 void emitInitializer(
CodeBuilder *builder)
override;
88 cstring actionRunVariable)
override;
90 static cstring addPrefixFunc(
bool trace);
96 const IR::PathExpression *getActionNameExpression(
const IR::Expression *expr)
const;
97 bool cacheEnabled()
override {
return tableCacheEnabled; }
101 [name](std::pair<cstring, EBPFCounterPSA *> elem) ->
bool {
102 return name == elem.first;
104 if (result !=
counters.end())
return result->second;
108 EBPFMeterPSA *getMeter(
cstring name)
const {
109 auto result = std::find_if(
110 meters.begin(), meters.end(),
111 [name](std::pair<cstring, EBPFMeterPSA *> elem) ->
bool { return name == elem.first; });
112 if (result != meters.end())
return result->second;
116 bool isMatchTypeSupported(
const IR::Declaration_ID *matchType)
override {
117 return EBPFTable::isMatchTypeSupported(matchType) || matchType->name.name ==
"selector";
120 DECLARE_TYPEINFO(EBPFTablePSA, EBPFTable);
void error(const char *format, Args &&...args)
Report an error with the given message.
Definition lib/error.h:51