diff options
Diffstat (limited to 'host/lib/rfnoc/epid_allocator.cpp')
-rw-r--r-- | host/lib/rfnoc/epid_allocator.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/host/lib/rfnoc/epid_allocator.cpp b/host/lib/rfnoc/epid_allocator.cpp index 97a30dc64..60544eb58 100644 --- a/host/lib/rfnoc/epid_allocator.cpp +++ b/host/lib/rfnoc/epid_allocator.cpp @@ -12,7 +12,6 @@ using namespace uhd::rfnoc; epid_allocator::epid_allocator(sep_id_t start_epid) : _next_epid(start_epid) {} - sep_id_t epid_allocator::allocate_epid(const sep_addr_t& addr) { std::lock_guard<std::mutex> lock(_mutex); @@ -27,6 +26,24 @@ sep_id_t epid_allocator::allocate_epid(const sep_addr_t& addr) } } +sep_id_t epid_allocator::allocate_epid( + const sep_addr_t& addr, mgmt::mgmt_portal& mgmt_portal, chdr_ctrl_xport& xport) +{ + std::lock_guard<std::mutex> lock(_mutex); + + if (_epid_map.count(addr) == 0) { + sep_id_t new_epid = _next_epid++; + _epid_map[addr] = new_epid; + _addr_map[new_epid] = addr; + mgmt_portal.initialize_endpoint(xport, addr, new_epid); + return new_epid; + } else { + sep_id_t epid = _epid_map.at(addr); + mgmt_portal.register_endpoint(addr, epid); + return epid; + } +} + sep_id_t epid_allocator::get_epid(const sep_addr_t& addr) { std::lock_guard<std::mutex> lock(_mutex); |