aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/include/uhdlib/transport/udp_common.hpp
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/udp_common.hpp
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/udp_common.hpp')
-rw-r--r--host/lib/include/uhdlib/transport/udp_common.hpp75
1 files changed, 75 insertions, 0 deletions
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