24 #ifndef BM_BM_SIM_SIMPLE_PRE_H_
25 #define BM_BM_SIM_SIMPLE_PRE_H_
28 #include <unordered_map>
31 #include <boost/thread/shared_mutex.hpp>
33 #include "handle_mgr.h"
56 using mgrp_hdl_t = uintptr_t;
57 using l1_hdl_t = uintptr_t;
58 using l2_hdl_t = uintptr_t;
85 static constexpr
size_t PORT_MAP_SIZE = 512;
86 using PortMap = McPre::Set<PORT_MAP_SIZE>;
88 static constexpr
size_t LAG_MAP_SIZE = 512;
89 using LagMap = McPre::Set<LAG_MAP_SIZE>;
92 McReturnCode mc_mgrp_create(
const mgrp_t, mgrp_hdl_t *);
93 McReturnCode mc_mgrp_destroy(
const mgrp_hdl_t);
94 McReturnCode mc_node_create(
const rid_t,
95 const PortMap &port_map,
97 McReturnCode mc_node_associate(
const mgrp_hdl_t,
const l1_hdl_t);
98 McReturnCode mc_node_dissociate(
const mgrp_hdl_t,
const l1_hdl_t);
99 McReturnCode mc_node_destroy(
const l1_hdl_t);
100 McReturnCode mc_node_update(
const l1_hdl_t l1_hdl,
101 const PortMap &port_map);
103 std::string mc_get_entries()
const;
129 std::vector<McOut>
replicate(
const McIn)
const;
142 static constexpr
int MGID_TABLE_SIZE = 4096;
143 static constexpr
int L1_MAX_ENTRIES = 4096;
144 static constexpr
int L2_MAX_ENTRIES = 8192;
148 std::vector<l1_hdl_t> l1_list{};
151 explicit MgidEntry(
mgrp_t mgid)
156 mgrp_hdl_t mgrp_hdl{};
159 bool is_associated{
false};
162 explicit L1Entry(
rid_t rid)
172 L2Entry(l1_hdl_t l1_hdl,
const PortMap &port_map)
173 : l1_hdl(l1_hdl), port_map(port_map) {}
175 L2Entry(l1_hdl_t l1_hdl,
const PortMap &port_map,
const LagMap &lag_map)
176 : l1_hdl(l1_hdl), port_map(port_map), lag_map(lag_map) {}
183 void get_entries_common(Json::Value *root)
const;
186 void node_dissociate(MgidEntry *mgid_entry, l1_hdl_t l1_hdl);
188 std::unordered_map<mgrp_hdl_t, MgidEntry> mgid_entries{};
189 std::unordered_map<l1_hdl_t, L1Entry> l1_entries{};
190 std::unordered_map<l2_hdl_t, L2Entry> l2_entries{};
191 HandleMgr l1_handles{};
192 HandleMgr l2_handles{};
193 mutable boost::shared_mutex mutex{};
198 #endif // BM_BM_SIM_SIMPLE_PRE_H_