aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/include/uhdlib/transport
diff options
context:
space:
mode:
authorAaron Rossetto <aaron.rossetto@ni.com>2019-10-17 08:44:11 -0500
committerMartin Braun <martin.braun@ettus.com>2019-11-26 12:21:32 -0800
commit0bd233e64210c6605e8a6ec1424fa81f9ea8a681 (patch)
treef97729a7bba21cdfc45ee756bee1ac0489358544 /host/lib/include/uhdlib/transport
parent912ed28b3df13b9f9c33f2fa92867ec0ac7445fd (diff)
downloaduhd-0bd233e64210c6605e8a6ec1424fa81f9ea8a681.tar.gz
uhd-0bd233e64210c6605e8a6ec1424fa81f9ea8a681.tar.bz2
uhd-0bd233e64210c6605e8a6ec1424fa81f9ea8a681.zip
uhd: Introduce I/O service manager
- Implement I/O service detach link methods - The I/O service manager instantiates new I/O services or connects links to existing I/O services based on options provided by the user in stream_args. - Add a streamer ID parameter to methods to create transports so that the I/O service manager can group transports appropriately when using offload threads. - Change X300 and MPMD to use I/O service manager to connect links to I/O services. - There is now a single I/O service manager per rfnoc_graph (and it is also stored in the graph) - The I/O service manager now also knows the device args for the rfnoc_graph it was created with, and can make decisions based upon those (e.g, use a specific I/O service for DPDK, share cores between streamers, etc.) - The I/O Service Manager does not get any decision logic with this commit, though - The MB ifaces for mpmd and x300 now access this global I/O service manager - Add configuration of link parameters with overrides Co-Authored-By: Martin Braun <martin.braun@ettus.com> Co-Authored-By: Aaron Rossetto <aaron.rossetto@ni.com>
Diffstat (limited to 'host/lib/include/uhdlib/transport')
-rw-r--r--host/lib/include/uhdlib/transport/inline_io_service.hpp6
-rw-r--r--host/lib/include/uhdlib/transport/io_service.hpp13
-rw-r--r--host/lib/include/uhdlib/transport/links.hpp3
-rw-r--r--host/lib/include/uhdlib/transport/offload_io_service.hpp14
-rw-r--r--host/lib/include/uhdlib/transport/udp_common.hpp75
5 files changed, 94 insertions, 17 deletions
diff --git a/host/lib/include/uhdlib/transport/inline_io_service.hpp b/host/lib/include/uhdlib/transport/inline_io_service.hpp
index f207d15a0..fe41b96b6 100644
--- a/host/lib/include/uhdlib/transport/inline_io_service.hpp
+++ b/host/lib/include/uhdlib/transport/inline_io_service.hpp
@@ -37,6 +37,9 @@ public:
void attach_recv_link(recv_link_if::sptr link);
void attach_send_link(send_link_if::sptr link);
+ void detach_recv_link(recv_link_if::sptr link);
+ void detach_send_link(send_link_if::sptr link);
+
recv_io_if::sptr make_recv_client(recv_link_if::sptr data_link,
size_t num_recv_frames,
recv_callback_t cb,
@@ -102,8 +105,7 @@ private:
inline_recv_cb* recv_io_cb, recv_link_if* recv_link, int32_t timeout_ms);
/* Track whether link is muxed and the callback */
- std::unordered_map<recv_link_if*,
- std::tuple<inline_recv_mux*, inline_recv_cb*>>
+ std::unordered_map<recv_link_if*, std::tuple<inline_recv_mux*, inline_recv_cb*>>
_recv_tbl;
/* Shared ptr kept to avoid untimely release */
diff --git a/host/lib/include/uhdlib/transport/io_service.hpp b/host/lib/include/uhdlib/transport/io_service.hpp
index 69a3a523e..399b693dc 100644
--- a/host/lib/include/uhdlib/transport/io_service.hpp
+++ b/host/lib/include/uhdlib/transport/io_service.hpp
@@ -282,10 +282,19 @@ public:
*/
virtual void attach_send_link(send_link_if::sptr link) = 0;
- /* TODO: Cleanup functions
+ /*!
+ * Detach a recv_link_if previously attached to this I/O service.
+ *
+ * \param link the recv_link_if to detach
+ */
virtual void detach_recv_link(recv_link_if::sptr link) = 0;
+
+ /*!
+ * Detach a send_link_if previously attached to this I/O service.
+ *
+ * \param link the send_link_if to detach
+ */
virtual void detach_send_link(send_link_if::sptr link) = 0;
- */
/*!
* Create a send_io_if so a transport may send packets through the link.
diff --git a/host/lib/include/uhdlib/transport/links.hpp b/host/lib/include/uhdlib/transport/links.hpp
index 64673f02f..09872b145 100644
--- a/host/lib/include/uhdlib/transport/links.hpp
+++ b/host/lib/include/uhdlib/transport/links.hpp
@@ -16,8 +16,7 @@ namespace uhd { namespace transport {
enum class link_type_t { CTRL = 0, ASYNC_MSG, TX_DATA, RX_DATA };
//! Contains all information regarding a link interface
-using both_links_t = std::tuple<uhd::transport::io_service::sptr,
- uhd::transport::send_link_if::sptr,
+using both_links_t = std::tuple<uhd::transport::send_link_if::sptr,
size_t, // num_send_frames
uhd::transport::recv_link_if::sptr,
size_t, // num_recv_frames
diff --git a/host/lib/include/uhdlib/transport/offload_io_service.hpp b/host/lib/include/uhdlib/transport/offload_io_service.hpp
index a7d9d211d..02231c502 100644
--- a/host/lib/include/uhdlib/transport/offload_io_service.hpp
+++ b/host/lib/include/uhdlib/transport/offload_io_service.hpp
@@ -8,6 +8,7 @@
#define INCLUDED_UHDLIB_TRANSPORT_OFFLOAD_IO_SERVICE_HPP
#include <uhdlib/transport/io_service.hpp>
+#include <vector>
namespace uhd { namespace transport {
@@ -21,18 +22,9 @@ namespace uhd { namespace transport {
class offload_io_service : public io_service
{
public:
- enum client_type_t
- {
- RECV_ONLY,
- SEND_ONLY,
- BOTH_SEND_AND_RECV
- };
+ enum client_type_t { RECV_ONLY, SEND_ONLY, BOTH_SEND_AND_RECV };
- enum wait_mode_t
- {
- POLL,
- BLOCK
- };
+ enum wait_mode_t { POLL, BLOCK };
/*!
* Options for configuring offload I/O service
diff --git a/host/lib/include/uhdlib/transport/udp_common.hpp b/host/lib/include/uhdlib/transport/udp_common.hpp
index 5f5a18c27..6c87ef498 100644
--- a/host/lib/include/uhdlib/transport/udp_common.hpp
+++ b/host/lib/include/uhdlib/transport/udp_common.hpp
@@ -10,7 +10,10 @@
#include <uhd/config.hpp>
#include <uhd/exception.hpp>
+#include <uhd/rfnoc/constants.hpp>
+#include <uhd/types/device_addr.hpp>
#include <uhd/utils/log.hpp>
+#include <uhdlib/transport/links.hpp>
#include <boost/asio.hpp>
#include <boost/format.hpp>
#include <thread>
@@ -194,6 +197,78 @@ UHD_INLINE size_t resize_udp_socket_buffer_with_warning(
return actual_size;
}
+/*!
+ * Determines a set of values to use for a UDP CHDR link based on defaults and
+ * any overrides that the user may have provided. In cases where both device
+ * and stream arguments can be used to override a value, note that the stream
+ * argument will always take precedence.
+ *
+ * \param link_type the link type (CTRL, RX, TX) to calculate parameters for
+ * \param send_mtu the MTU of link for Tx cases
+ * \param recv_mtu the MTU of link for Rx cases
+ * \param default_link_params default values to use for the link parameters
+ * \param device_args device-level argument dictionary for overrides
+ * \param link_args argument dictionary with stream-level overrides (come from
+ * stream params)
+ * \return Parameters to apply
+ */
+inline link_params_t calculate_udp_link_params(
+ const uhd::transport::link_type_t link_type,
+ const size_t send_mtu,
+ const size_t recv_mtu,
+ const link_params_t& default_link_params,
+ const uhd::device_addr_t& device_args,
+ const uhd::device_addr_t& link_args)
+{
+ // Apply any device-level overrides to the default values first.
+ // If the MTU is overridden, it will be capped to the value provided by
+ // the caller.
+ const size_t constrained_send_mtu =
+ std::min(send_mtu, device_args.cast<size_t>("mtu", send_mtu));
+ const size_t constrained_recv_mtu =
+ std::min(recv_mtu, device_args.cast<size_t>("mtu", recv_mtu));
+
+ link_params_t link_params;
+ link_params.num_send_frames =
+ device_args.cast<size_t>("num_send_frames", default_link_params.num_send_frames);
+ link_params.num_recv_frames =
+ device_args.cast<size_t>("num_recv_frames", default_link_params.num_recv_frames);
+ link_params.send_frame_size =
+ device_args.cast<size_t>("send_frame_size", default_link_params.send_frame_size);
+ link_params.recv_frame_size =
+ device_args.cast<size_t>("recv_frame_size", default_link_params.recv_frame_size);
+ link_params.send_buff_size =
+ device_args.cast<size_t>("send_buff_size", default_link_params.send_buff_size);
+ link_params.recv_buff_size =
+ device_args.cast<size_t>("recv_buff_size", default_link_params.recv_buff_size);
+
+ // Now apply stream-level overrides based on the link type.
+ if (link_type == link_type_t::CTRL) {
+ // Control links typically do not allow the number of frames to be
+ // configured.
+ link_params.num_recv_frames =
+ uhd::rfnoc::CMD_FIFO_SIZE / uhd::rfnoc::MAX_CMD_PKT_SIZE;
+ } else if (link_type == link_type_t::TX_DATA) {
+ // Note that the send frame size will be capped to the Tx MTU.
+ link_params.send_frame_size = link_args.cast<size_t>("send_frame_size",
+ std::min(link_params.send_frame_size, constrained_send_mtu));
+ link_params.num_send_frames =
+ link_args.cast<size_t>("num_send_frames", link_params.num_send_frames);
+ link_params.send_buff_size =
+ link_args.cast<size_t>("send_buff_size", link_params.send_buff_size);
+ } else if (link_type == link_type_t::RX_DATA) {
+ // Note that the receive frame size will be capped to the Rx MTU.
+ link_params.recv_frame_size = link_args.cast<size_t>("recv_frame_size",
+ std::min(link_params.recv_frame_size, constrained_recv_mtu));
+ link_params.num_recv_frames =
+ link_args.cast<size_t>("num_recv_frames", link_params.num_recv_frames);
+ link_params.recv_buff_size =
+ link_args.cast<size_t>("recv_buff_size", link_params.recv_buff_size);
+ }
+
+ return link_params;
+}
+
}} // namespace uhd::transport