From ef30ed1743f470756eadab4067587caf0341be8e Mon Sep 17 00:00:00 2001 From: Aaron Rossetto Date: Tue, 1 Feb 2022 14:04:23 -0600 Subject: rfnoc: Fix _set_subdev_spec() helper function In 716ed77, refactoring was performed to merge `set_tx_subdev_spec()` and `set_rx_subdev_spec()` via the use of a shared helper function, `_set_subdev_spec()`, which factors out differences in the two directions by accepting lambda functions from the caller. However, there were two bugs introduced in the refactoring: - The channel map parameter, which is either `_rx_chans` or `_tx_chans` based on direction, was passed by value and not reference, so changes made by the function were not persisted in the member variables maintained in the `multi_usrp_rfnoc` class. - The connection removal loop checks for the presence of an SEP block on an edge as its termination condition. In the pre-refactored code, the direction determined whether the source or destination of the edge was checked for the SEP. However, in the refactoring, the source of the edge is checked for both TX and RX. While this works for the `set_tx_subdev_spec()` call, it breaks the `set_rx_subdev_spec()` call. This commit fixes the issue by adding another lambda parameter to the `set_subdev_spec()` function, which puts the onus of the edge check on the direction-specific code to ensure it is looking at the correct side of the edge. --- host/lib/usrp/multi_usrp_rfnoc.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'host') diff --git a/host/lib/usrp/multi_usrp_rfnoc.cpp b/host/lib/usrp/multi_usrp_rfnoc.cpp index 4ab6abcbd..c71668c33 100644 --- a/host/lib/usrp/multi_usrp_rfnoc.cpp +++ b/host/lib/usrp/multi_usrp_rfnoc.cpp @@ -1065,6 +1065,8 @@ public: return this->get_rx_subdev_spec(current_mboard); }, [this](uhd::usrp::subdev_spec_t current_spec, size_t current_mboard) { return this->_generate_mboard_rx_chans(current_spec, current_mboard); + }, [](uhd::rfnoc::graph_edge_t edge) { + return block_id_t(edge.dst_blockid).match(NODE_ID_SEP); }, spec, mboard); } @@ -1662,6 +1664,8 @@ public: return this->get_tx_subdev_spec(current_mboard); }, [this](uhd::usrp::subdev_spec_t current_spec, size_t current_mboard) { return this->_generate_mboard_tx_chans(current_spec, current_mboard); + }, [](uhd::rfnoc::graph_edge_t edge) { + return block_id_t(edge.src_blockid).match(NODE_ID_SEP); }, spec, mboard); } @@ -2420,11 +2424,12 @@ private: return edges; } - template + template void _set_subdev_spec( - std::unordered_map chans, + std::unordered_map& chans, GetSubdevSpecFn&& get_subdev_spec, GenChansFn&& generate_chans, + CheckEdgeForSepFn&& check_edge_for_sep, const uhd::usrp::subdev_spec_t& spec, size_t mboard) { @@ -2461,7 +2466,7 @@ private: UHD_LOG_TRACE("MULTI_USRP", "Disconnecting chains"); for (auto entry : chans) { for (auto edge : entry.second.edge_list) { - if (block_id_t(edge.src_blockid).match(NODE_ID_SEP)) { + if (check_edge_for_sep(edge)) { break; } _graph->disconnect( -- cgit v1.2.3