17#ifndef BACKENDS_DPDK_DPDKCONTEXT_H_
18#define BACKENDS_DPDK_DPDKCONTEXT_H_
23#include "control-plane/bfruntime.h"
24#include "dpdkProgramStructure.h"
25#include "lib/cstring.h"
27#include "lib/nullstream.h"
29#include "p4/config/v1/p4info.pb.h"
31namespace p4configv1 = ::p4::config::v1;
54 bool idle_timeout_with_auto_delete;
59 unsigned default_action_handle;
61 std::vector<std::pair<cstring, cstring>> tableKeys;
67 bool constant_default_action;
68 bool is_compiler_added_action;
69 bool allowed_as_hit_action;
70 bool allowed_as_default_action;
71 unsigned actionHandle;
90 buildDate = options.getBuildDate();
91 compileCommand = options.getCompileCommand();
92 progName = options.
file.stem();
99 unsigned max_n_groups;
100 unsigned max_n_members_per_group;
101 unsigned bound_to_action_data_table_handle;
102 void setAttributes(
const IR::P4Table *tbl,
103 const std::map<const cstring, struct TableAttributes> &tableAttrmap) {
105 max_n_members_per_group = 0;
106 auto n_groups = tbl->properties->getProperty(
"n_groups_max");
108 auto n_groups_expr = n_groups->value->to<IR::ExpressionValue>()->expression;
109 max_n_groups = n_groups_expr->to<IR::Constant>()->asInt();
111 auto n_members = tbl->properties->getProperty(
"n_members_per_group_max");
113 auto n_members_expr = n_members->value->to<IR::ExpressionValue>()->expression;
114 max_n_members_per_group = n_members_expr->to<IR::Constant>()->asInt();
117 cstring actionDataTableName = tbl->name.originalName.replace(
"_sel",
"");
118 auto actionTableAttr = ::P4::get(tableAttrmap, actionDataTableName);
119 bound_to_action_data_table_handle = actionTableAttr.tableHandle;
127 const p4configv1::P4Info &p4info;
131 std::vector<const IR::Declaration_Instance *> externs;
134 std::map<const cstring, struct TableAttributes> tableAttrmap;
135 std::map<cstring, struct actionAttributes> actionAttrMap;
136 std::map<cstring, struct externAttributes> externAttrMap;
139 std::map<cstring, size_t> context_handle_map;
143 const p4configv1::P4Info &p4info,
DpdkOptions &options)
144 : refmap(refmap), structure(structure), p4info(p4info), options(options) {}
146 void serializeContextJson(std::ostream *destination);
149 size_t getHandleId(
cstring name);
150 void collectHandleId();
154 const IR::KeyElement *key,
int position);
161 int byte_array_index);
164 void setDefaultActionHandle(
const IR::P4Table *table);
This pass generates context JSON into user specified file.
Definition dpdkContext.h:124
void addActionParam(Util::JsonArray *paramJson, const cstring name, int bitWidth, int position, int byte_array_index)
This function adds a single parameter to the parameters array.
Definition dpdkContext.cpp:372
void addMatchTables(Util::JsonArray *tablesJson)
Add tables to the context json.
Definition dpdkContext.cpp:479
void addExternInfo(Util::JsonArray *externsJson)
Add extern information to the context json.
Definition dpdkContext.cpp:534
void setActionAttributes(const IR::P4Table *table)
This function sets action attributes for actions in a table.
Definition dpdkContext.cpp:237
void addKeyField(Util::JsonArray *keyJson, const cstring name, const cstring annon, const IR::KeyElement *key, int position)
This functions insert a single key field in the match keys array.
Definition dpdkContext.cpp:166
bool addRefTables(const cstring tbl_name, const IR::P4Table **memberTable, Util::JsonObject *tableJson)
This function adds the tables referred by this table.
Definition dpdkContext.cpp:434
Util::JsonArray * addActions(const IR::P4Table *table, const cstring ctrlName, bool isMatch)
This function creates JSON objects for actions within a table.
Definition dpdkContext.cpp:384
Util::JsonObject * initTableCommonJson(const cstring name, const struct TableAttributes &attr)
This function sets the common table properties.
Definition dpdkContext.cpp:192
void addImmediateField(Util::JsonArray *paramJson, const cstring name, int dest_start, int dest_Width)
This functions creates JSON object for immediate fields (action parameters).
Definition dpdkContext.cpp:321
void CollectTablesAndSetAttributes()
Definition dpdkContext.cpp:35
Util::JsonObject * addMatchAttributes(const IR::P4Table *table, const cstring ctrlName)
This functions creates JSON object for match attributes of a table.
Definition dpdkContext.cpp:331
Definition backends/dpdk/options.h:24
cstring compilerVersion
Compiler version.
Definition parser_options.h:85
std::filesystem::path file
file to compile (- for stdin)
Definition parser_options.h:81
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
Definition dpdk/backend.cpp:37
cstring tableType
Definition dpdkContext.h:52
unsigned tableHandle
Unique ID for the table.
Definition dpdkContext.h:48
cstring direction
Direction of the table, can be ["ingress","egress"].
Definition dpdkContext.h:46
Definition dpdkContext.h:44
Definition dpdkContext.h:66
Definition dpdkContext.h:76
Selection table attributes.
Definition dpdkContext.h:98
Program level information for context json.
Definition dpdkContext.h:84
Collect information related to P4 programs targeting dpdk.
Definition dpdkProgramStructure.h:16