aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/rfnoc
diff options
context:
space:
mode:
authorCiro Nishiguchi <ciro.nishiguchi@ni.com>2019-10-02 21:49:53 -0500
committerMartin Braun <martin.braun@ettus.com>2019-11-26 12:21:32 -0800
commit912ed28b3df13b9f9c33f2fa92867ec0ac7445fd (patch)
tree4c3f06c9332547ec47d08397b9bbde88e9be6ae8 /host/lib/rfnoc
parent2f97f8bd0167d4179427efa8a955046fbf417e91 (diff)
downloaduhd-912ed28b3df13b9f9c33f2fa92867ec0ac7445fd.tar.gz
uhd-912ed28b3df13b9f9c33f2fa92867ec0ac7445fd.tar.bz2
uhd-912ed28b3df13b9f9c33f2fa92867ec0ac7445fd.zip
rfnoc: Make trasnport safe to use with offload threads
Make transports safe to use with an offload thread by ensuring that the callbacks and the API methods can execute concurrently. Also, ensure that the transports release their I/O service clients prior to allowing their other member variables be destroyed.
Diffstat (limited to 'host/lib/rfnoc')
-rw-r--r--host/lib/rfnoc/chdr_ctrl_xport.cpp10
-rw-r--r--host/lib/rfnoc/chdr_rx_data_xport.cpp9
-rw-r--r--host/lib/rfnoc/chdr_tx_data_xport.cpp6
3 files changed, 24 insertions, 1 deletions
diff --git a/host/lib/rfnoc/chdr_ctrl_xport.cpp b/host/lib/rfnoc/chdr_ctrl_xport.cpp
index f9f7c9e1b..6b185efab 100644
--- a/host/lib/rfnoc/chdr_ctrl_xport.cpp
+++ b/host/lib/rfnoc/chdr_ctrl_xport.cpp
@@ -78,6 +78,16 @@ chdr_ctrl_xport::chdr_ctrl_xport(io_service::sptr io_srv,
recv_link, 1, mgmt_recv_cb, send_link_if::sptr(), 0, release_cb);
}
+
+chdr_ctrl_xport::~chdr_ctrl_xport()
+{
+ // Release I/O service clients before allowing members needed by callbacks
+ // be destroyed
+ _send_if.reset();
+ _ctrl_recv_if.reset();
+ _mgmt_recv_if.reset();
+}
+
/*!
* Get an empty frame buffer in which to write packet contents.
*
diff --git a/host/lib/rfnoc/chdr_rx_data_xport.cpp b/host/lib/rfnoc/chdr_rx_data_xport.cpp
index cdcd70393..b0c68f2b4 100644
--- a/host/lib/rfnoc/chdr_rx_data_xport.cpp
+++ b/host/lib/rfnoc/chdr_rx_data_xport.cpp
@@ -45,7 +45,8 @@ chdr_rx_data_xport::chdr_rx_data_xport(uhd::transport::io_service::sptr io_srv,
"Creating rx xport with local epid=" << epids.second
<< ", remote epid=" << epids.first);
- _recv_packet = pkt_factory.make_generic();
+ _recv_packet = pkt_factory.make_generic();
+ _recv_packet_cb = pkt_factory.make_generic();
_fc_sender.set_capacity(fc_params.buff_capacity);
// Calculate max payload size
@@ -81,6 +82,12 @@ chdr_rx_data_xport::chdr_rx_data_xport(uhd::transport::io_service::sptr io_srv,
<< ", packets=" << fc_params.freq.packets);
}
+chdr_rx_data_xport::~chdr_rx_data_xport()
+{
+ // Release recv_io before allowing members needed by callbacks be destroyed
+ _recv_io.reset();
+}
+
chdr_rx_data_xport::fc_params_t chdr_rx_data_xport::configure_sep(io_service::sptr io_srv,
recv_link_if::sptr recv_link,
send_link_if::sptr send_link,
diff --git a/host/lib/rfnoc/chdr_tx_data_xport.cpp b/host/lib/rfnoc/chdr_tx_data_xport.cpp
index cb28c7ac9..550dde59a 100644
--- a/host/lib/rfnoc/chdr_tx_data_xport.cpp
+++ b/host/lib/rfnoc/chdr_tx_data_xport.cpp
@@ -69,6 +69,12 @@ chdr_tx_data_xport::chdr_tx_data_xport(uhd::transport::io_service::sptr io_srv,
recv_cb);
}
+chdr_tx_data_xport::~chdr_tx_data_xport()
+{
+ // Release send_io before allowing members needed by callbacks be destroyed
+ _send_io.reset();
+}
+
/*
* To configure flow control, we need to send an init strc packet, then
* receive a strs containing the stream endpoint ingress buffer size. We