P4C
The P4 Compiler
Loading...
Searching...
No Matches
dpdk/control-plane/bfruntime_ext.h
1/*
2 * Copyright 2021 Intel Corporation
3 * SPDX-FileCopyrightText: 2021 Intel Corporation
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef BACKENDS_DPDK_CONTROL_PLANE_BFRUNTIME_EXT_H_
9#define BACKENDS_DPDK_CONTROL_PLANE_BFRUNTIME_EXT_H_
10
11#include "backends/dpdk/constants.h"
12#include "backends/dpdk/options.h"
13#include "backends/dpdk/p4/config/p4info.pb.h"
14#include "control-plane/bfruntime.h"
15
16namespace P4 {
17
18namespace BFRT {
19
22class BFRuntimeSchemaGenerator : public BFRuntimeGenerator {
23 public:
24 BFRuntimeSchemaGenerator(const p4configv1::P4Info &p4info, bool isTDI,
25 DPDK::DpdkOptions &options)
26 : BFRuntimeGenerator(p4info), isTDI(isTDI), options(options) {}
27
29 const Util::JsonObject *genSchema() const override;
30
31 private:
32 bool isTDI;
33 DPDK::DpdkOptions &options;
36
40 enum BFRuntimeDataFieldIds : P4Id {
46 BF_RT_DATA_START = TD_DATA_END,
47
48 BF_RT_DATA_ACTION_MEMBER_ID,
49 BF_RT_DATA_SELECTOR_GROUP_ID,
50 BF_RT_DATA_ACTION_MEMBER_STATUS,
51 BF_RT_DATA_MAX_GROUP_SIZE,
52 BF_RT_DATA_HASH_VALUE,
53 };
55 struct ActionSelector;
56
57 void addDPDKExterns(Util::JsonArray *tablesJson, Util::JsonArray *learnFiltersJson) const;
58 void addActionSelectorCommon(Util::JsonArray *tablesJson,
59 const ActionSelector &actionProf) const;
60 void addActionSelectorGetMemberCommon(Util::JsonArray *tablesJson,
61 const ActionSelector &actionProf) const;
62 void addConstTableAttr(Util::JsonArray *attrJson) const override;
63 bool addMatchTypePriority(std::optional<cstring> &matchType) const override;
64 void addActionProfs(Util::JsonArray *tablesJson) const override;
65 bool addActionProfIds(const p4configv1::Table &table,
66 Util::JsonObject *tableJson) const override;
67 void addMatchActionData(const p4configv1::Table &table, Util::JsonObject *tableJson,
68 Util::JsonArray *dataJson, P4Id maxActionParamId) const;
69
70 std::optional<bool> actProfHasSelector(P4Id actProfId) const override;
71
72 static std::optional<ActionProf> fromDPDKActionProfile(
73 const p4configv1::P4Info &p4info, const p4configv1::ExternInstance &externInstance) {
74 const auto &pre = externInstance.preamble();
75 p4configv1::ActionProfile actionProfile;
76 if (!externInstance.info().UnpackTo(&actionProfile)) {
77 ::P4::error(ErrorType::ERR_NOT_FOUND,
78 "Extern instance %1% does not pack an ActionProfile object", pre.name());
79 return std::nullopt;
80 }
81 auto tableIds = collectTableIds(p4info, actionProfile.table_ids().begin(),
82 actionProfile.table_ids().end());
83 return ActionProf{pre.name(), pre.id(), actionProfile.size(), tableIds,
84 transformAnnotations(pre)};
85 };
86};
87
88} // namespace BFRT
89
90} // namespace P4
91
92#endif // BACKENDS_DPDK_CONTROL_PLANE_BFRUNTIME_EXT_H_
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:212
Definition backends/dpdk/options.h:15
Definition lib/json.h:128
Definition lib/json.h:177
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13
void error(const char *format, Args &&...args)
Report an error with the given message.
Definition lib/error.h:58
Definition control-plane/bfruntime.h:344
Definition dpdk/control-plane/bfruntime_ext.cpp:14