aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/include
diff options
context:
space:
mode:
authormichael-west <michael.west@ettus.com>2020-07-07 13:37:25 -0700
committerAaron Rossetto <aaron.rossetto@ni.com>2020-08-04 15:41:07 -0500
commitd7c64eb4b13670dbc5728f994e70dca60616af63 (patch)
tree706844126fe06450e8f262ef1b48dedbe14680de /host/lib/include
parent6d4c07d09ad54155df7ed374e7fbfebd9d40758b (diff)
downloaduhd-d7c64eb4b13670dbc5728f994e70dca60616af63.tar.gz
uhd-d7c64eb4b13670dbc5728f994e70dca60616af63.tar.bz2
uhd-d7c64eb4b13670dbc5728f994e70dca60616af63.zip
RFNoC: Add xport disconnect callbacks
Transports were not disconnecting their links from the I/O service upon destruction, leaving behind inaccessible send and recv links used by nothing. This led to I/O errors after creating several transports. Added callbacks to transports to automatically disconnect their links from the I/O service when the transport is destroyed. Updated all callers to supply a disconnect callback. Signed-off-by: michael-west <michael.west@ettus.com>
Diffstat (limited to 'host/lib/include')
-rw-r--r--host/lib/include/uhdlib/rfnoc/chdr_ctrl_xport.hpp26
-rw-r--r--host/lib/include/uhdlib/rfnoc/chdr_rx_data_xport.hpp16
-rw-r--r--host/lib/include/uhdlib/rfnoc/chdr_tx_data_xport.hpp12
-rw-r--r--host/lib/include/uhdlib/transport/io_service.hpp7
4 files changed, 46 insertions, 15 deletions
diff --git a/host/lib/include/uhdlib/rfnoc/chdr_ctrl_xport.hpp b/host/lib/include/uhdlib/rfnoc/chdr_ctrl_xport.hpp
index 38acd7a34..7d5613f5d 100644
--- a/host/lib/include/uhdlib/rfnoc/chdr_ctrl_xport.hpp
+++ b/host/lib/include/uhdlib/rfnoc/chdr_ctrl_xport.hpp
@@ -19,12 +19,13 @@ namespace uhd { namespace rfnoc {
class chdr_ctrl_xport
{
public:
- using io_service = uhd::transport::io_service;
- using frame_buff = uhd::transport::frame_buff;
- using send_link_if = uhd::transport::send_link_if;
- using recv_link_if = uhd::transport::recv_link_if;
- using send_io_if = uhd::transport::send_io_if;
- using recv_io_if = uhd::transport::recv_io_if;
+ using io_service = uhd::transport::io_service;
+ using frame_buff = uhd::transport::frame_buff;
+ using send_link_if = uhd::transport::send_link_if;
+ using recv_link_if = uhd::transport::recv_link_if;
+ using send_io_if = uhd::transport::send_io_if;
+ using recv_io_if = uhd::transport::recv_io_if;
+ using disconnect_callback_t = uhd::transport::disconnect_callback_t;
using sptr = std::shared_ptr<chdr_ctrl_xport>;
@@ -37,6 +38,7 @@ public:
* \param my_epid The local EPID for this transport
* \param num_send_frames Number of frames to reserve for TX
* \param num_recv_frames Number of frames to reserve for RX
+ * \param disconnect Callback function to disconnect the links
*/
static sptr make(io_service::sptr io_srv,
send_link_if::sptr send_link,
@@ -44,7 +46,8 @@ public:
const chdr::chdr_packet_factory& pkt_factory,
sep_id_t my_epid,
size_t num_send_frames,
- size_t num_recv_frames)
+ size_t num_recv_frames,
+ disconnect_callback_t disconnect)
{
return std::make_shared<chdr_ctrl_xport>(io_srv,
send_link,
@@ -52,7 +55,8 @@ public:
pkt_factory,
my_epid,
num_send_frames,
- num_recv_frames);
+ num_recv_frames,
+ disconnect);
}
/*!
@@ -64,6 +68,7 @@ public:
* \param my_epid The local EPID for this transport
* \param num_send_frames Number of frames to reserve for TX
* \param num_recv_frames Number of frames to reserve for RX
+ * \param disconnect Callback function to disconnect the links
*/
chdr_ctrl_xport(io_service::sptr io_srv,
send_link_if::sptr send_link,
@@ -71,7 +76,8 @@ public:
const chdr::chdr_packet_factory& pkt_factory,
sep_id_t my_epid,
size_t num_send_frames,
- size_t num_recv_frames);
+ size_t num_recv_frames,
+ disconnect_callback_t disconnect);
~chdr_ctrl_xport();
@@ -151,6 +157,8 @@ private:
recv_io_if::sptr _ctrl_recv_if;
recv_io_if::sptr _mgmt_recv_if;
+ // Disconnect callback
+ disconnect_callback_t _disconnect;
// FIXME: Remove this when have threaded_io_service
std::mutex _mutex;
diff --git a/host/lib/include/uhdlib/rfnoc/chdr_rx_data_xport.hpp b/host/lib/include/uhdlib/rfnoc/chdr_rx_data_xport.hpp
index d6a2e6628..cb0987446 100644
--- a/host/lib/include/uhdlib/rfnoc/chdr_rx_data_xport.hpp
+++ b/host/lib/include/uhdlib/rfnoc/chdr_rx_data_xport.hpp
@@ -100,8 +100,9 @@ private:
class chdr_rx_data_xport
{
public:
- using uptr = std::unique_ptr<chdr_rx_data_xport>;
- using buff_t = transport::frame_buff;
+ using uptr = std::unique_ptr<chdr_rx_data_xport>;
+ using buff_t = transport::frame_buff;
+ using disconnect_callback_t = uhd::transport::disconnect_callback_t;
//! Values extracted from received RX data packets
struct packet_info_t
@@ -135,6 +136,7 @@ public:
* \param fc_freq Frequency of flow control status messages
* \param fc_headroom Headroom for flow control status messages
* \param lossy_xport Whether the xport is lossy, for flow control configuration
+ * \param disconnect Callback function to disconnect the links
* \return Parameters for xport flow control
*/
static fc_params_t configure_sep(uhd::transport::io_service::sptr io_srv,
@@ -148,7 +150,8 @@ public:
const stream_buff_params_t& recv_capacity,
const stream_buff_params_t& fc_freq,
const stream_buff_params_t& fc_headroom,
- const bool lossy_xport);
+ const bool lossy_xport,
+ disconnect_callback_t disconnect);
/*! Constructor
*
@@ -159,6 +162,7 @@ public:
* \param epids Source and destination endpoint IDs
* \param num_recv_frames Num frames to reserve from the recv link
* \param fc_params Parameters for flow control
+ * \param disconnect Callback function to disconnect the links
*/
chdr_rx_data_xport(uhd::transport::io_service::sptr io_srv,
uhd::transport::recv_link_if::sptr recv_link,
@@ -166,7 +170,8 @@ public:
const chdr::chdr_packet_factory& pkt_factory,
const uhd::rfnoc::sep_id_pair_t& epids,
const size_t num_recv_frames,
- const fc_params_t& fc_params);
+ const fc_params_t& fc_params,
+ disconnect_callback_t disconnect);
/*! Destructor
*/
@@ -404,6 +409,9 @@ private:
//! The CHDR width in bytes.
size_t _chdr_w_bytes;
+
+ // Disconnect callback
+ disconnect_callback_t _disconnect;
};
}} // namespace uhd::rfnoc
diff --git a/host/lib/include/uhdlib/rfnoc/chdr_tx_data_xport.hpp b/host/lib/include/uhdlib/rfnoc/chdr_tx_data_xport.hpp
index ed008c1db..4e8ebe24d 100644
--- a/host/lib/include/uhdlib/rfnoc/chdr_tx_data_xport.hpp
+++ b/host/lib/include/uhdlib/rfnoc/chdr_tx_data_xport.hpp
@@ -106,6 +106,7 @@ public:
using buff_t = transport::frame_buff;
using enqueue_async_msg_fn_t =
std::function<void(async_metadata_t::event_code_t, bool, uint64_t)>;
+ using disconnect_callback_t = uhd::transport::disconnect_callback_t;
//! Information about data packet
struct packet_info_t
@@ -135,6 +136,7 @@ public:
* \param mdata_buff_fmt Datatype of SW buffer that holds the data metadata
* \param fc_freq_ratio Ratio to use to configure the device fc frequency
* \param fc_headroom_ratio Ratio to use to configure the device fc headroom
+ * \param disconnect Callback function to disconnect the links
* \return Parameters for xport flow control
*/
static fc_params_t configure_sep(uhd::transport::io_service::sptr io_srv,
@@ -146,7 +148,8 @@ public:
const uhd::rfnoc::sw_buff_t pyld_buff_fmt,
const uhd::rfnoc::sw_buff_t mdata_buff_fmt,
const double fc_freq_ratio,
- const double fc_headroom_ratio);
+ const double fc_headroom_ratio,
+ disconnect_callback_t disconnect);
/*! Constructor
*
@@ -157,6 +160,7 @@ public:
* \param epids Source and destination endpoint IDs
* \param num_send_frames Num frames to reserve from the send link
* \param fc_params Parameters for flow control
+ * \param disconnect Callback function to disconnect the links
*/
chdr_tx_data_xport(uhd::transport::io_service::sptr io_srv,
uhd::transport::recv_link_if::sptr recv_link,
@@ -164,7 +168,8 @@ public:
const chdr::chdr_packet_factory& pkt_factory,
const uhd::rfnoc::sep_id_pair_t& epids,
const size_t num_send_frames,
- const fc_params_t fc_params);
+ const fc_params_t fc_params,
+ disconnect_callback_t disconnect);
/*! Destructor
*/
@@ -397,6 +402,9 @@ private:
//! The size of the send frame
size_t _frame_size;
+
+ // Disconnect callback
+ disconnect_callback_t _disconnect;
};
}} // namespace uhd::rfnoc
diff --git a/host/lib/include/uhdlib/transport/io_service.hpp b/host/lib/include/uhdlib/transport/io_service.hpp
index 62dfdfe0d..0cc2f86e3 100644
--- a/host/lib/include/uhdlib/transport/io_service.hpp
+++ b/host/lib/include/uhdlib/transport/io_service.hpp
@@ -78,6 +78,13 @@ using recv_callback_t =
std::function<bool(frame_buff::uptr&, recv_link_if*, send_link_if*)>;
/*!
+ * Callback to disconnect links. This allows a function to be registered
+ * that can call back to the io_service_mgr to completely disconnect the
+ * links.
+ */
+using disconnect_callback_t = std::function<void()>;
+
+/*!
* Interface for a recv transport to request/release buffers from a link. A
* recv transport is a transport with a primary purpose of receiving data, and
* the recv_io_if class interacts with the io_service to schedule the data