From 0bd233e64210c6605e8a6ec1424fa81f9ea8a681 Mon Sep 17 00:00:00 2001 From: Aaron Rossetto Date: Thu, 17 Oct 2019 08:44:11 -0500 Subject: 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 Co-Authored-By: Aaron Rossetto --- host/lib/include/uhdlib/transport/udp_common.hpp | 75 ++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'host/lib/include/uhdlib/transport/udp_common.hpp') 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 #include +#include +#include #include +#include #include #include #include @@ -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("mtu", send_mtu)); + const size_t constrained_recv_mtu = + std::min(recv_mtu, device_args.cast("mtu", recv_mtu)); + + link_params_t link_params; + link_params.num_send_frames = + device_args.cast("num_send_frames", default_link_params.num_send_frames); + link_params.num_recv_frames = + device_args.cast("num_recv_frames", default_link_params.num_recv_frames); + link_params.send_frame_size = + device_args.cast("send_frame_size", default_link_params.send_frame_size); + link_params.recv_frame_size = + device_args.cast("recv_frame_size", default_link_params.recv_frame_size); + link_params.send_buff_size = + device_args.cast("send_buff_size", default_link_params.send_buff_size); + link_params.recv_buff_size = + device_args.cast("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("send_frame_size", + std::min(link_params.send_frame_size, constrained_send_mtu)); + link_params.num_send_frames = + link_args.cast("num_send_frames", link_params.num_send_frames); + link_params.send_buff_size = + link_args.cast("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("recv_frame_size", + std::min(link_params.recv_frame_size, constrained_recv_mtu)); + link_params.num_recv_frames = + link_args.cast("num_recv_frames", link_params.num_recv_frames); + link_params.recv_buff_size = + link_args.cast("recv_buff_size", link_params.recv_buff_size); + } + + return link_params; +} + }} // namespace uhd::transport -- cgit v1.2.3