aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichael-west <michael.west@ettus.com>2020-06-12 10:14:55 -0700
committerAaron Rossetto <aaron.rossetto@ni.com>2020-08-04 15:41:07 -0500
commitf659c1af8f5a0e2e629ec67c9a3a4d54f8c7d529 (patch)
tree2f5dceff2c6af501d880f2d09afb506c2b922f92
parent5a00f4d7864c6258f0d070b4753569413c7cfc4f (diff)
downloaduhd-f659c1af8f5a0e2e629ec67c9a3a4d54f8c7d529.tar.gz
uhd-f659c1af8f5a0e2e629ec67c9a3a4d54f8c7d529.tar.bz2
uhd-f659c1af8f5a0e2e629ec67c9a3a4d54f8c7d529.zip
RFNoC: Added support for destruction of streamers
- Added rfnoc_graph method to disconnect a connection. - Added rfnoc_graph method to disconnect a streamer. - Added rfnoc_graph method to disconnect a port on a streamer. - Added disconnect callback to rfnoc_rx_streamer and rfnoc_tx_streamer. - Registered disconnect callback functions to streamers returned by get_rx_streamer and get_tx_streamer methods. Signed-off-by: michael-west <michael.west@ettus.com>
-rw-r--r--host/lib/include/uhdlib/rfnoc/rfnoc_rx_streamer.hpp15
-rw-r--r--host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer.hpp15
-rw-r--r--host/lib/rfnoc/rfnoc_rx_streamer.cpp15
-rw-r--r--host/lib/rfnoc/rfnoc_tx_streamer.cpp15
4 files changed, 52 insertions, 8 deletions
diff --git a/host/lib/include/uhdlib/rfnoc/rfnoc_rx_streamer.hpp b/host/lib/include/uhdlib/rfnoc/rfnoc_rx_streamer.hpp
index 8ce3725a7..9cda81785 100644
--- a/host/lib/include/uhdlib/rfnoc/rfnoc_rx_streamer.hpp
+++ b/host/lib/include/uhdlib/rfnoc/rfnoc_rx_streamer.hpp
@@ -22,13 +22,23 @@ namespace uhd { namespace rfnoc {
class rfnoc_rx_streamer : public node_t,
public transport::rx_streamer_impl<chdr_rx_data_xport>
{
+ using disconnect_fn_t = std::function<void(const std::string&)>;
+
public:
/*! Constructor
*
* \param num_ports The number of ports
* \param stream_args Arguments to aid the construction of the streamer
+ * \param disconnect_cb Callback function to disconnect the streamer when
+ * the object is destroyed
+ */
+ rfnoc_rx_streamer(const size_t num_ports,
+ const uhd::stream_args_t stream_args,
+ disconnect_fn_t disconnect_cb);
+
+ /*! Destructor
*/
- rfnoc_rx_streamer(const size_t num_ports, const uhd::stream_args_t stream_args);
+ ~rfnoc_rx_streamer();
/*! Returns a unique identifier string for this node. In every RFNoC graph,
* no two nodes cannot have the same ID. Returns a string in the form of
@@ -107,6 +117,9 @@ private:
// Stream args provided at construction
const uhd::stream_args_t _stream_args;
+ // Callback function to disconnect
+ const disconnect_fn_t _disconnect_cb;
+
std::atomic<bool> _overrun_handling_mode{false};
size_t _overrun_channel = 0;
};
diff --git a/host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer.hpp b/host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer.hpp
index ce989420c..5d741a844 100644
--- a/host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer.hpp
+++ b/host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer.hpp
@@ -22,13 +22,23 @@ namespace uhd { namespace rfnoc {
class rfnoc_tx_streamer : public node_t,
public transport::tx_streamer_impl<chdr_tx_data_xport>
{
+ using disconnect_fn_t = std::function<void(const std::string&)>;
+
public:
/*! Constructor
*
* \param num_ports The number of ports
* \param stream_args Arguments to aid the construction of the streamer
+ * \param disconnect_cb Callback function to disconnect the streamer when
+ * the object is destroyed
+ */
+ rfnoc_tx_streamer(const size_t num_ports,
+ const uhd::stream_args_t stream_args,
+ disconnect_fn_t disconnect_cb);
+
+ /*! Destructor
*/
- rfnoc_tx_streamer(const size_t num_chans, const uhd::stream_args_t stream_args);
+ ~rfnoc_tx_streamer();
/*! Returns a unique identifier string for this node. In every RFNoC graph,
* no two nodes cannot have the same ID. Returns a string in the form of
@@ -109,6 +119,9 @@ private:
// Stream args provided at construction
const uhd::stream_args_t _stream_args;
+
+ // Callback function to disconnect
+ const disconnect_fn_t _disconnect_cb;
};
}} // namespace uhd::rfnoc
diff --git a/host/lib/rfnoc/rfnoc_rx_streamer.cpp b/host/lib/rfnoc/rfnoc_rx_streamer.cpp
index 081682a94..180f5e87f 100644
--- a/host/lib/rfnoc/rfnoc_rx_streamer.cpp
+++ b/host/lib/rfnoc/rfnoc_rx_streamer.cpp
@@ -18,11 +18,13 @@ using namespace uhd::rfnoc;
const std::string STREAMER_ID = "RxStreamer";
static std::atomic<uint64_t> streamer_inst_ctr;
-rfnoc_rx_streamer::rfnoc_rx_streamer(
- const size_t num_chans, const uhd::stream_args_t stream_args)
- : rx_streamer_impl<chdr_rx_data_xport>(num_chans, stream_args)
+rfnoc_rx_streamer::rfnoc_rx_streamer(const size_t num_chans,
+ const uhd::stream_args_t stream_args,
+ disconnect_fn_t disconnect_cb)
+ : rx_streamer_impl<chdr_rx_data_xport>(stream_args.channels.size(), stream_args)
, _unique_id(STREAMER_ID + "#" + std::to_string(streamer_inst_ctr++))
, _stream_args(stream_args)
+ , _disconnect_cb(disconnect_cb)
{
set_overrun_handler([this]() { this->_handle_overrun(); });
@@ -90,6 +92,13 @@ rfnoc_rx_streamer::rfnoc_rx_streamer(
node_accessor.init_props(this);
}
+rfnoc_rx_streamer::~rfnoc_rx_streamer()
+{
+ if (_disconnect_cb) {
+ _disconnect_cb(_unique_id);
+ }
+}
+
std::string rfnoc_rx_streamer::get_unique_id() const
{
return _unique_id;
diff --git a/host/lib/rfnoc/rfnoc_tx_streamer.cpp b/host/lib/rfnoc/rfnoc_tx_streamer.cpp
index 9b511818e..578db5cdf 100644
--- a/host/lib/rfnoc/rfnoc_tx_streamer.cpp
+++ b/host/lib/rfnoc/rfnoc_tx_streamer.cpp
@@ -16,11 +16,13 @@ const std::string STREAMER_ID = "TxStreamer";
static std::atomic<uint64_t> streamer_inst_ctr;
static constexpr size_t ASYNC_MSG_QUEUE_SIZE = 1000;
-rfnoc_tx_streamer::rfnoc_tx_streamer(
- const size_t num_chans, const uhd::stream_args_t stream_args)
- : tx_streamer_impl<chdr_tx_data_xport>(num_chans, stream_args)
+rfnoc_tx_streamer::rfnoc_tx_streamer(const size_t num_chans,
+ const uhd::stream_args_t stream_args,
+ disconnect_fn_t disconnect_cb)
+ : tx_streamer_impl<chdr_tx_data_xport>(stream_args.channels.size(), stream_args)
, _unique_id(STREAMER_ID + "#" + std::to_string(streamer_inst_ctr++))
, _stream_args(stream_args)
+ , _disconnect_cb(disconnect_cb)
{
_async_msg_queue = std::make_shared<tx_async_msg_queue>(ASYNC_MSG_QUEUE_SIZE);
@@ -78,6 +80,13 @@ rfnoc_tx_streamer::rfnoc_tx_streamer(
node_accessor.init_props(this);
}
+rfnoc_tx_streamer::~rfnoc_tx_streamer()
+{
+ if (_disconnect_cb) {
+ _disconnect_cb(_unique_id);
+ }
+}
+
std::string rfnoc_tx_streamer::get_unique_id() const
{
return _unique_id;