From 91e01c484475600fcd659bb433ab86efa5146426 Mon Sep 17 00:00:00 2001 From: Alex Williams Date: Tue, 6 Aug 2019 18:32:29 -0700 Subject: rfnoc: Centralize initialization state of SEPs to epid_allocator Because the initialization state of SEPs is a graph-wide property, link_stream_managers and mgmt_portals cannot rely on their private members to determine if they can reset an SEP. Move the call to init SEPs into the epid_allocator, and have it call into a mgmt_portal to gain access to the SEP. Thus, link_stream_managers only request that an epid_allocator ensure an SEP is numbered and initialized, and they provide a path to communicate with the SEP. The epid_allocator will ensure init only happens once, so a stream currently running on another link_stream_manager does not get interrupted. This could happen, for example, if the OSTRM went to one device, and the ISTRM came from another. In general, EPIDs should only be assigned once. --- host/lib/rfnoc/epid_allocator.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'host/lib/rfnoc/epid_allocator.cpp') 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 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 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 lock(_mutex); -- cgit v1.2.3