P4C
The P4 Compiler
Loading...
Searching...
No Matches
p4info_map.h
1#ifndef BACKENDS_P4TOOLS_COMMON_CONTROL_PLANE_P4INFO_MAP_H_
2#define BACKENDS_P4TOOLS_COMMON_CONTROL_PLANE_P4INFO_MAP_H_
3#include <cstdint>
4#include <map>
5#include <optional>
6
7#include "control-plane/p4RuntimeArchHandler.h"
8#include "control-plane/p4RuntimeSerializer.h"
9#include "lib/cstring.h"
10
11#pragma GCC diagnostic push
12#pragma GCC diagnostic ignored "-Wunused-parameter"
13#pragma GCC diagnostic ignored "-Wpedantic"
14#include "p4/config/v1/p4info.pb.h"
15#pragma GCC diagnostic pop
16
22namespace P4::ControlPlaneAPI {
23
29uint64_t szudzikPairing(p4rt_id_t x, p4rt_id_t y);
30
39 using P4RuntimeIdToControlPlaneNameMap = std::map<uint64_t, cstring>;
40 using ControlPlaneNameToP4RuntimeIdMap = std::map<cstring, uint64_t>;
41
42 protected:
44 P4RuntimeIdToControlPlaneNameMap idToNameMap;
45
47 ControlPlaneNameToP4RuntimeIdMap nameToIdMap;
48
50 virtual void buildP4InfoMaps(const p4::config::v1::P4Info &p4Info);
51
52 public:
53 explicit P4InfoMaps(const p4::config::v1::P4Info &p4Info);
54
57 [[nodiscard]] std::optional<uint64_t> lookUpP4RuntimeId(cstring controlPlaneName) const;
58
61 [[nodiscard]] std::optional<cstring> lookUpControlPlaneName(uint64_t id) const;
62};
63
64} // namespace P4::ControlPlaneAPI
65
66#endif /* BACKENDS_P4TOOLS_COMMON_CONTROL_PLANE_P4INFO_MAP_H_ */
Definition p4info_map.h:37
ControlPlaneNameToP4RuntimeIdMap nameToIdMap
Maps control plane names to P4Runtime IDs.
Definition p4info_map.h:47
virtual void buildP4InfoMaps(const p4::config::v1::P4Info &p4Info)
Iterate over the P4Info object and build a mapping from P4 control plane names to their ids.
Definition p4info_map.cpp:16
std::optional< cstring > lookUpControlPlaneName(uint64_t id) const
Definition p4info_map.cpp:85
std::optional< uint64_t > lookUpP4RuntimeId(cstring controlPlaneName) const
Definition p4info_map.cpp:77
P4RuntimeIdToControlPlaneNameMap idToNameMap
Maps P4Runtime IDs to control plane names.
Definition p4info_map.h:44
Definition cstring.h:85
TODO(antonin): High level goals of the generator go here!!
Definition dpdk/control-plane/bfruntime_arch_handler.h:52
uint64_t szudzikPairing(p4rt_id_t x, p4rt_id_t y)
Definition p4info_map.cpp:7