P4C
The P4 Compiler
Loading...
Searching...
No Matches
p4infoApi.h
1#ifndef CONTROL_PLANE_P4INFOAPI_H_
2#define CONTROL_PLANE_P4INFOAPI_H_
3
4#include <optional>
5
6#include "control-plane/p4RuntimeArchHandler.h"
7#include "control-plane/p4RuntimeSerializer.h"
8#include "lib/cstring.h"
9
10#pragma GCC diagnostic push
11#pragma GCC diagnostic ignored "-Wunused-parameter"
12#pragma GCC diagnostic ignored "-Wpedantic"
13#include "p4/config/v1/p4info.pb.h"
14#pragma GCC diagnostic pop
15
16namespace P4::ControlPlaneAPI {
17
22template <typename It>
23auto findP4InfoObject(const It &first, const It &last, cstring controlPlaneName) -> const
24 typename std::iterator_traits<It>::value_type * {
25 using T = typename std::iterator_traits<It>::value_type;
26 auto desiredObject = std::find_if(
27 first, last, [&](const T &object) { return object.preamble().name() == controlPlaneName; });
28 if (desiredObject == last) {
29 return nullptr;
30 }
31 return &*desiredObject;
32}
33
38template <typename It>
39auto findP4InfoObject(const It &first, const It &last, p4rt_id_t id) -> const
40 typename std::iterator_traits<It>::value_type * {
41 using T = typename std::iterator_traits<It>::value_type;
42 auto desiredObject =
43 std::find_if(first, last, [&](const T &object) { return object.preamble().id() == id; });
44 if (desiredObject == last) {
45 return nullptr;
46 }
47 return &*desiredObject;
48}
49
52const p4::config::v1::Table *findP4RuntimeTable(const p4::config::v1::P4Info &p4Info,
53 cstring controlPlaneName);
54
57const p4::config::v1::Table *findP4RuntimeTable(const p4::config::v1::P4Info &p4Info, p4rt_id_t id);
58
61const p4::config::v1::MatchField *findP4RuntimeMatchField(const p4::config::v1::Table &p4Table,
62 cstring controlPlaneName);
63
66const p4::config::v1::MatchField *findP4RuntimeMatchField(const p4::config::v1::Table &p4Table,
67 p4rt_id_t id);
68
71const p4::config::v1::Action *findP4RuntimeAction(const p4::config::v1::P4Info &p4Info,
72 cstring controlPlaneName);
73
76const p4::config::v1::Action *findP4RuntimeAction(const p4::config::v1::P4Info &p4Info,
77 p4rt_id_t id);
78
81const p4::config::v1::ActionProfile *findP4RuntimeActionProfile(
82 const p4::config::v1::P4Info &p4Info, cstring controlPlaneName);
83
86const p4::config::v1::ActionProfile *findP4RuntimeActionProfile(
87 const p4::config::v1::P4Info &p4Info, p4rt_id_t id);
88
91const p4::config::v1::Counter *findP4RuntimeCounter(const p4::config::v1::P4Info &p4Info,
92 cstring controlPlaneName);
93
96const p4::config::v1::Counter *findP4RuntimeCounter(const p4::config::v1::P4Info &p4Info,
97 p4rt_id_t id);
98
101const p4::config::v1::DirectCounter *findP4RuntimeDirectCounter(
102 const p4::config::v1::P4Info &p4Info, cstring controlPlaneName);
103
106const p4::config::v1::DirectCounter *findP4RuntimeDirectCounter(
107 const p4::config::v1::P4Info &p4Info, p4rt_id_t id);
108
111const p4::config::v1::Meter *findP4RuntimeMeter(const p4::config::v1::P4Info &p4Info,
112 cstring controlPlaneName);
113
116const p4::config::v1::Meter *findP4RuntimeMeter(const p4::config::v1::P4Info &p4Info, p4rt_id_t id);
117
120const p4::config::v1::DirectMeter *findP4RuntimeDirectMeter(const p4::config::v1::P4Info &p4Info,
121 cstring controlPlaneName);
122
125const p4::config::v1::DirectMeter *findP4RuntimeDirectMeter(const p4::config::v1::P4Info &p4Info,
126 p4rt_id_t id);
127
130const p4::config::v1::ControllerPacketMetadata *findP4RuntimeControllerPacketMetadata(
131 const p4::config::v1::P4Info &p4Info, cstring controlPlaneName);
132
135const p4::config::v1::ControllerPacketMetadata *findP4RuntimeControllerPacketMetadata(
136 const p4::config::v1::P4Info &p4Info, p4rt_id_t id);
137
140const p4::config::v1::ValueSet *findP4RuntimeValueSet(const p4::config::v1::P4Info &p4Info,
141 cstring controlPlaneName);
142
145const p4::config::v1::ValueSet *findP4RuntimeValueSet(const p4::config::v1::P4Info &p4Info,
146 p4rt_id_t id);
147
150const p4::config::v1::Register *findP4RuntimeRegister(const p4::config::v1::P4Info &p4Info,
151 cstring controlPlaneName);
152
155const p4::config::v1::Register *findP4RuntimeRegister(const p4::config::v1::P4Info &p4Info,
156 p4rt_id_t id);
157
160const p4::config::v1::Digest *findP4RuntimeDigest(const p4::config::v1::P4Info &p4Info,
161 cstring controlPlaneName);
162
165const p4::config::v1::Digest *findP4RuntimeDigest(const p4::config::v1::P4Info &p4Info,
166 p4rt_id_t id);
167
170const p4::config::v1::Extern *findP4RuntimeExtern(const p4::config::v1::P4Info &p4Info,
171 cstring controlPlaneName);
172
175const p4::config::v1::Extern *findP4RuntimeExtern(const p4::config::v1::P4Info &p4Info,
176 p4rt_id_t id);
177
180std::optional<p4rt_id_t> getP4RuntimeId(const p4::config::v1::P4Info &p4Info,
181 const P4RuntimeSymbolType &type, cstring controlPlaneName);
182
183} // namespace P4::ControlPlaneAPI
184
185#endif /* CONTROL_PLANE_P4INFOAPI_H_ */
Definition cstring.h:85
TODO(antonin): High level goals of the generator go here!!
Definition dpdk/control-plane/bfruntime_arch_handler.h:52
const p4::config::v1::ValueSet * findP4RuntimeValueSet(const p4::config::v1::P4Info &p4Info, cstring controlPlaneName)
Definition p4infoApi.cpp:119
const p4::config::v1::Digest * findP4RuntimeDigest(const p4::config::v1::P4Info &p4Info, cstring controlPlaneName)
Definition p4infoApi.cpp:140
const p4::config::v1::Extern * findP4RuntimeExtern(const p4::config::v1::P4Info &p4Info, cstring controlPlaneName)
Definition p4infoApi.cpp:150
const p4::config::v1::Meter * findP4RuntimeMeter(const p4::config::v1::P4Info &p4Info, cstring controlPlaneName)
Definition p4infoApi.cpp:86
const p4::config::v1::DirectMeter * findP4RuntimeDirectMeter(const p4::config::v1::P4Info &p4Info, cstring controlPlaneName)
Definition p4infoApi.cpp:96
const p4::config::v1::ActionProfile * findP4RuntimeActionProfile(const p4::config::v1::P4Info &p4Info, cstring controlPlaneName)
Definition p4infoApi.cpp:54
const p4::config::v1::Register * findP4RuntimeRegister(const p4::config::v1::P4Info &p4Info, cstring controlPlaneName)
Definition p4infoApi.cpp:130
const p4::config::v1::Table * findP4RuntimeTable(const p4::config::v1::P4Info &p4Info, cstring controlPlaneName)
Definition p4infoApi.cpp:14
const p4::config::v1::Counter * findP4RuntimeCounter(const p4::config::v1::P4Info &p4Info, cstring controlPlaneName)
Definition p4infoApi.cpp:65
const p4::config::v1::MatchField * findP4RuntimeMatchField(const p4::config::v1::Table &p4Table, cstring controlPlaneName)
Definition p4infoApi.cpp:24
const p4::config::v1::Action * findP4RuntimeAction(const p4::config::v1::P4Info &p4Info, cstring controlPlaneName)
Definition p4infoApi.cpp:44
const p4::config::v1::DirectCounter * findP4RuntimeDirectCounter(const p4::config::v1::P4Info &p4Info, cstring controlPlaneName)
Definition p4infoApi.cpp:75
const p4::config::v1::ControllerPacketMetadata * findP4RuntimeControllerPacketMetadata(const p4::config::v1::P4Info &p4Info, cstring controlPlaneName)
Definition p4infoApi.cpp:107
std::optional< p4rt_id_t > getP4RuntimeId(const p4::config::v1::P4Info &p4Info, const P4RuntimeSymbolType &type, cstring controlPlaneName)
Definition p4infoApi.cpp:170