P4C
The P4 Compiler
Loading...
Searching...
No Matches
dpdk/control-plane/bfruntime_ext.h
1/* Copyright 2021 Intel Corporation
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14*/
15
16#ifndef DPDK_CONTROL_PLANE_BFRUNTIME_EXT_H_
17#define DPDK_CONTROL_PLANE_BFRUNTIME_EXT_H_
18
19#include "backends/dpdk/constants.h"
20#include "backends/dpdk/options.h"
21#include "backends/dpdk/p4/config/p4info.pb.h"
22#include "control-plane/bfruntime.h"
23
24namespace P4 {
25
26namespace BFRT {
27
31 public:
32 BFRuntimeSchemaGenerator(const p4configv1::P4Info &p4info, bool isTDI,
33 DPDK::DpdkOptions &options)
34 : BFRuntimeGenerator(p4info), isTDI(isTDI), options(options) {}
35
37 const Util::JsonObject *genSchema() const override;
38
39 private:
40 bool isTDI;
41 DPDK::DpdkOptions &options;
44
48 enum BFRuntimeDataFieldIds : P4Id {
54 BF_RT_DATA_START = TD_DATA_END,
55
56 BF_RT_DATA_ACTION_MEMBER_ID,
57 BF_RT_DATA_SELECTOR_GROUP_ID,
58 BF_RT_DATA_ACTION_MEMBER_STATUS,
59 BF_RT_DATA_MAX_GROUP_SIZE,
60 BF_RT_DATA_HASH_VALUE,
61 };
63 struct ActionSelector;
64
65 void addDPDKExterns(Util::JsonArray *tablesJson, Util::JsonArray *learnFiltersJson) const;
66 void addActionSelectorCommon(Util::JsonArray *tablesJson,
67 const ActionSelector &actionProf) const;
68 void addActionSelectorGetMemberCommon(Util::JsonArray *tablesJson,
69 const ActionSelector &actionProf) const;
70 void addConstTableAttr(Util::JsonArray *attrJson) const override;
71 bool addMatchTypePriority(std::optional<cstring> &matchType) const override;
72 void addActionProfs(Util::JsonArray *tablesJson) const override;
73 bool addActionProfIds(const p4configv1::Table &table,
74 Util::JsonObject *tableJson) const override;
75 void addMatchActionData(const p4configv1::Table &table, Util::JsonObject *tableJson,
76 Util::JsonArray *dataJson, P4Id maxActionParamId) const;
77
78 std::optional<bool> actProfHasSelector(P4Id actProfId) const override;
79
80 static std::optional<ActionProf> fromDPDKActionProfile(
81 const p4configv1::P4Info &p4info, const p4configv1::ExternInstance &externInstance) {
82 const auto &pre = externInstance.preamble();
83 p4configv1::ActionProfile actionProfile;
84 if (!externInstance.info().UnpackTo(&actionProfile)) {
85 ::P4::error(ErrorType::ERR_NOT_FOUND,
86 "Extern instance %1% does not pack an ActionProfile object", pre.name());
87 return std::nullopt;
88 }
89 auto tableIds = collectTableIds(p4info, actionProfile.table_ids().begin(),
90 actionProfile.table_ids().end());
91 return ActionProf{pre.name(), pre.id(), actionProfile.size(), tableIds,
92 transformAnnotations(pre)};
93 };
94};
95
96} // namespace BFRT
97
98} // namespace P4
99
100#endif // DPDK_CONTROL_PLANE_BFRUNTIME_EXT_H_
Definition control-plane/bfruntime.h:271
Definition dpdk/control-plane/bfruntime_ext.h:30
const Util::JsonObject * genSchema() const override
Generates the schema as a Json object for the provided P4Info instance.
Definition dpdk/control-plane/bfruntime_ext.cpp:222
Definition backends/dpdk/options.h:24
Definition json.h:115
Definition json.h:164
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
void error(const char *format, Args &&...args)
Report an error with the given message.
Definition lib/error.h:51
Definition control-plane/bfruntime.h:351
Definition dpdk/control-plane/bfruntime_ext.cpp:24