RMM API 2.0.0
Loading...
Searching...
No Matches
Topology.h
1#pragma once
2
3#include <bits/stdc++.h>
4
5#include <map>
6#include <memory>
7#include <mutex>
8#include <string>
9#include <unordered_map>
10#include <vector>
11
12#define NUMBER_NODES 32
13#define NUMBER_RINGS 12
14
15class FrontEndBase; // Forward class declaration
16using FENRegMap = std::unordered_map<std::string, uint32_t>;
17using TopologyMap = std::unordered_map<uint32_t, std::unordered_map<uint32_t, std::shared_ptr<FrontEndBase>>>;
18
24 std::string name;
25 std::shared_ptr<FrontEndBase> instance;
26 int ring;
27 int node;
28};
29
30using TopologyList = std::vector<FrontEndEntry>;
31using NodesList = std::map<int, FrontEndEntry>;
32
40class Topology {
41 public:
42 Topology();
47 const TopologyList& getAllEntries() const { return topology; };
48
49 void addEntry(const FrontEndEntry& entry);
50 const NodesList getNodesForRing(int ring);
51 const uint8_t getNumberOfNodesInRing(int ring);
52 const FENRegMap& getAddrMap(int ring, int node);
53 const FrontEndBase* getFEN(int ring, int node);
54 const std::vector<int> getActiveRings();
55 void fillNodesArray(uint8_t* rings, size_t size = NUMBER_RINGS);
56
57 private:
58 TopologyList topology;
59 TopologyMap topMap;
60 size_t mapped_topology[NUMBER_RINGS][NUMBER_NODES]{};
61 uint8_t active_nodes[NUMBER_RINGS]{};
62 std::mutex topology_mutex;
63};
Base class for frontend devices, providing common functionality.
Definition FrontEndBase.h:17
const std::vector< int > getActiveRings()
Returns which rings have populated nodes.
Definition Topology.cpp:83
const TopologyList & getAllEntries() const
Retrieve all entries in the topology.
Definition Topology.h:47
void fillNodesArray(uint8_t *rings, size_t size=NUMBER_RINGS)
Fills the number of nodes per ring in an array.
Definition Topology.cpp:63
const NodesList getNodesForRing(int ring)
Retrieves all nodes associated with a specific ring.
Definition Topology.cpp:33
Topology()
Constructor for the Topology class.
Definition Topology.cpp:8
const uint8_t getNumberOfNodesInRing(int ring)
Retrieves the number of nodes in a specific ring.
Definition Topology.cpp:52
const FrontEndBase * getFEN(int ring, int node)
gets the FrontEnd in given ring and node. Returns NULL if not found.
Definition Topology.cpp:99
const FENRegMap & getAddrMap(int ring, int node)
Returns the register map for a given ring-node pair.
Definition Topology.cpp:75
void addEntry(const FrontEndEntry &entry)
Adds a front-end entry to the topology map.
Definition Topology.cpp:15
Struct to hold the information about a registered frontend device.
Definition Topology.h:23
std::shared_ptr< FrontEndBase > instance
Shared pointer to the frontend instance.
Definition Topology.h:25
int node
The node ID within the ring.
Definition Topology.h:27
std::string name
Name of the frontend device.
Definition Topology.h:24
int ring
The ring ID where the frontend device is located.
Definition Topology.h:26