diff options
author | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-02-01 14:04:23 -0600 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-02-01 14:35:29 -0600 |
commit | ef30ed1743f470756eadab4067587caf0341be8e (patch) | |
tree | c9fe10619225f14b3e0cdc88adf197917d4f5069 /host | |
parent | a4fc11e6ef08be2141f3cfea7c521aae0ba65634 (diff) | |
download | uhd-ef30ed1743f470756eadab4067587caf0341be8e.tar.gz uhd-ef30ed1743f470756eadab4067587caf0341be8e.tar.bz2 uhd-ef30ed1743f470756eadab4067587caf0341be8e.zip |
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.
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/usrp/multi_usrp_rfnoc.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
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<typename ChanType, typename GetSubdevSpecFn, typename GenChansFn> + template<typename ChanType, typename GetSubdevSpecFn, typename GenChansFn, typename CheckEdgeForSepFn> void _set_subdev_spec( - std::unordered_map<size_t, ChanType> chans, + std::unordered_map<size_t, ChanType>& 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( |