aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/mpmd
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/mpmd')
-rw-r--r--host/lib/usrp/mpmd/mpmd_xport_ctrl_dpdk_udp.cpp41
-rw-r--r--host/lib/usrp/mpmd/mpmd_xport_ctrl_liberio.cpp48
-rw-r--r--host/lib/usrp/mpmd/mpmd_xport_ctrl_udp.cpp86
3 files changed, 128 insertions, 47 deletions
diff --git a/host/lib/usrp/mpmd/mpmd_xport_ctrl_dpdk_udp.cpp b/host/lib/usrp/mpmd/mpmd_xport_ctrl_dpdk_udp.cpp
index a496e8e69..38d295728 100644
--- a/host/lib/usrp/mpmd/mpmd_xport_ctrl_dpdk_udp.cpp
+++ b/host/lib/usrp/mpmd/mpmd_xport_ctrl_dpdk_udp.cpp
@@ -21,6 +21,8 @@ constexpr unsigned int MPMD_UDP_RESERVED_FRAME_SIZE = 64;
//! Maximum CHDR packet size in bytes
const size_t MPMD_10GE_DATA_FRAME_MAX_SIZE = 4000;
+const size_t MPMD_10GE_DATA_FRAME_DEFAULT_SIZE = 4000;
+const size_t MPMD_10GE_MSG_FRAME_DEFAULT_SIZE = 256;
//! Number of send/recv frames
const size_t MPMD_ETH_NUM_SEND_FRAMES = 32;
@@ -194,27 +196,36 @@ uhd::both_xports_t
mpmd_xport_ctrl_dpdk_udp::make_transport(
mpmd_xport_mgr::xport_info_t &xport_info,
const usrp::device3_impl::xport_type_t xport_type,
- const uhd::device_addr_t& xport_args_
+ const uhd::device_addr_t& xport_args
) {
- auto xport_args = xport_args_;
- transport::zero_copy_xport_params default_buff_args;
+ // Constrain by this transport's MTU and the MTU in the xport_args
+ const size_t send_mtu = std::min(get_mtu(uhd::TX_DIRECTION),
+ xport_args.cast<size_t>("mtu", get_mtu(uhd::TX_DIRECTION)));
+ const size_t recv_mtu = std::min(get_mtu(uhd::RX_DIRECTION),
+ xport_args.cast<size_t>("mtu", get_mtu(uhd::RX_DIRECTION)));
+
// Create actual UHD-DPDK UDP transport
- default_buff_args.recv_frame_size =
- xport_args.cast<size_t>("recv_frame_size", get_mtu(uhd::RX_DIRECTION));
- default_buff_args.send_frame_size =
- xport_args.cast<size_t>("send_frame_size", get_mtu(uhd::TX_DIRECTION));
- if (xport_type == usrp::device3_impl::ASYNC_MSG or
- xport_type == usrp::device3_impl::CTRL) {
- default_buff_args.num_recv_frames =
- xport_args.cast<size_t>("num_recv_frames", MPMD_ETH_NUM_CTRL_FRAMES);
- default_buff_args.num_send_frames =
- xport_args.cast<size_t>("num_send_frames", MPMD_ETH_NUM_CTRL_FRAMES);
- } else {
+ transport::zero_copy_xport_params default_buff_args;
+ default_buff_args.num_recv_frames = MPMD_ETH_NUM_CTRL_FRAMES;
+ default_buff_args.num_send_frames = MPMD_ETH_NUM_CTRL_FRAMES;
+ default_buff_args.recv_frame_size = MPMD_10GE_MSG_FRAME_DEFAULT_SIZE;
+ default_buff_args.send_frame_size = MPMD_10GE_MSG_FRAME_DEFAULT_SIZE;
+
+ if (xport_type == usrp::device3_impl::RX_DATA) {
default_buff_args.num_recv_frames =
xport_args.cast<size_t>("num_recv_frames", MPMD_ETH_NUM_RECV_FRAMES);
+ default_buff_args.recv_frame_size = std::min(
+ xport_args.cast<size_t>("recv_frame_size",
+ MPMD_10GE_DATA_FRAME_DEFAULT_SIZE),
+ recv_mtu);
+ } else if (xport_type == usrp::device3_impl::TX_DATA) {
default_buff_args.num_send_frames =
xport_args.cast<size_t>("num_send_frames", MPMD_ETH_NUM_SEND_FRAMES);
+ default_buff_args.send_frame_size = std::min(
+ xport_args.cast<size_t>("send_frame_size",
+ MPMD_10GE_DATA_FRAME_DEFAULT_SIZE),
+ send_mtu);
}
UHD_LOG_TRACE("BUFF", "num_recv_frames=" << default_buff_args.num_recv_frames
@@ -234,7 +245,7 @@ mpmd_xport_ctrl_dpdk_udp::make_transport(
xport_info["port"],
"0",
default_buff_args,
- xport_args
+ uhd::device_addr_t()
);
const uint16_t port = recv->get_local_port();
const std::string src_ip_addr = recv->get_local_addr();
diff --git a/host/lib/usrp/mpmd/mpmd_xport_ctrl_liberio.cpp b/host/lib/usrp/mpmd/mpmd_xport_ctrl_liberio.cpp
index 78751c94f..c53eb97a1 100644
--- a/host/lib/usrp/mpmd/mpmd_xport_ctrl_liberio.cpp
+++ b/host/lib/usrp/mpmd/mpmd_xport_ctrl_liberio.cpp
@@ -47,15 +47,49 @@ mpmd_xport_ctrl_liberio::mpmd_xport_ctrl_liberio(const uhd::device_addr_t& mb_ar
uhd::both_xports_t mpmd_xport_ctrl_liberio::make_transport(
mpmd_xport_mgr::xport_info_t& xport_info,
const usrp::device3_impl::xport_type_t xport_type,
- const uhd::device_addr_t& xport_args)
+ const uhd::device_addr_t& xport_args_)
{
+ auto xport_args = (xport_type == usrp::device3_impl::CTRL) ?
+ uhd::device_addr_t() : xport_args_;
+
+ // Constrain by this transport's MTU and the MTU passed in
+ const size_t send_mtu = std::min(get_mtu(uhd::TX_DIRECTION),
+ xport_args.cast<size_t>("mtu", get_mtu(uhd::TX_DIRECTION)));
+ const size_t recv_mtu = std::min(get_mtu(uhd::RX_DIRECTION),
+ xport_args.cast<size_t>("mtu", get_mtu(uhd::RX_DIRECTION)));
+ size_t send_frame_size = xport_args.cast<size_t>("send_frame_size", send_mtu);
+ size_t recv_frame_size = xport_args.cast<size_t>("recv_frame_size", recv_mtu);
+
+ // Check any user supplied frame sizes and constrain to MTU
+ if (xport_args.has_key("send_frame_size") and
+ xport_type == usrp::device3_impl::TX_DATA)
+ {
+ if (send_frame_size > send_mtu) {
+ UHD_LOGGER_WARNING("MPMD")
+ << boost::format("Requested send_frame_size of %d exceeds the "
+ "maximum supported by the hardware. Using %d.")
+ % send_frame_size % send_mtu;
+ send_frame_size = send_mtu;
+ }
+ }
+ if (xport_args.has_key("recv_frame_size") and
+ xport_type == usrp::device3_impl::RX_DATA)
+ {
+ size_t recv_frame_size = xport_args.cast<size_t>("recv_frame_size", recv_mtu);
+ if (recv_frame_size > recv_mtu) {
+ UHD_LOGGER_WARNING("MPMD")
+ << boost::format("Requested recv_frame_size of %d exceeds the "
+ "maximum supported by the hardware. Using %d.")
+ % recv_frame_size % recv_mtu;
+ recv_frame_size = recv_mtu;
+ }
+ }
+
transport::zero_copy_xport_params default_buff_args;
/* default ones for RX / TX, override below */
- default_buff_args.send_frame_size =
- xport_args.cast<size_t>("send_frame_size", get_mtu(uhd::TX_DIRECTION));
- default_buff_args.recv_frame_size =
- xport_args.cast<size_t>("recv_frame_size", get_mtu(uhd::RX_DIRECTION));
+ default_buff_args.send_frame_size = send_mtu;
+ default_buff_args.recv_frame_size = recv_mtu;
default_buff_args.num_recv_frames = LIBERIO_NUM_RECV_FRAMES;
default_buff_args.num_send_frames = LIBERIO_NUM_SEND_FRAMES;
@@ -70,9 +104,11 @@ uhd::both_xports_t mpmd_xport_ctrl_liberio::make_transport(
default_buff_args.send_frame_size = LIBERIO_ASYNC_FRAME_MAX_SIZE;
default_buff_args.recv_frame_size = LIBERIO_ASYNC_FRAME_MAX_SIZE;
} else if (xport_type == usrp::device3_impl::RX_DATA) {
+ default_buff_args.recv_frame_size = recv_frame_size;
default_buff_args.send_frame_size = LIBERIO_FC_FRAME_MAX_SIZE;
} else {
default_buff_args.recv_frame_size = LIBERIO_FC_FRAME_MAX_SIZE;
+ default_buff_args.send_frame_size = send_frame_size;
}
const std::string tx_dev = xport_info["tx_dev"];
@@ -140,7 +176,7 @@ bool mpmd_xport_ctrl_liberio::is_valid(
return xport_info.at("type") == "liberio";
}
-size_t mpmd_xport_ctrl_liberio::get_mtu(const uhd::direction_t dir) const
+size_t mpmd_xport_ctrl_liberio::get_mtu(const uhd::direction_t /*dir*/) const
{
return LIBERIO_PAGES_PER_BUF * getpagesize();
}
diff --git a/host/lib/usrp/mpmd/mpmd_xport_ctrl_udp.cpp b/host/lib/usrp/mpmd/mpmd_xport_ctrl_udp.cpp
index bdb32b8f6..ba827fcf4 100644
--- a/host/lib/usrp/mpmd/mpmd_xport_ctrl_udp.cpp
+++ b/host/lib/usrp/mpmd/mpmd_xport_ctrl_udp.cpp
@@ -1,5 +1,6 @@
//
// Copyright 2017 Ettus Research, National Instruments Company
+// Copyright 2019 Ettus Research, National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
@@ -20,11 +21,20 @@ namespace {
//! Maximum CHDR packet size in bytes
const size_t MPMD_10GE_DATA_FRAME_MAX_SIZE = 4000;
-//! Maximum CHDR packet size in bytes
-const size_t MPMD_10GE_ASYNCMSG_FRAME_MAX_SIZE = 1472;
-
-//! Number of send/recv frames
-const size_t MPMD_ETH_NUM_FRAMES = 32;
+//! Default number of send frames
+const size_t MPMD_UDP_DEFAULT_NUM_SEND_FRAMES = 1;
+//! Default number of recv frames
+const size_t MPMD_UDP_DEFAULT_NUM_RECV_FRAMES = 1;
+//! Default message frame size
+const size_t MPMD_UDP_MSG_FRAME_SIZE = 256;
+//! Default 1GbE send frame size
+const size_t MPMD_UDP_1GE_DEFAULT_SEND_FRAME_SIZE = 1472;
+//! Default 1GbE receive frame size
+const size_t MPMD_UDP_1GE_DEFAULT_RECV_FRAME_SIZE = 1472;
+//! Default 10GbE send frame size
+const size_t MPMD_UDP_10GE_DEFAULT_SEND_FRAME_SIZE = 4000;
+//! Default 10GbE receive frame size
+const size_t MPMD_UDP_10GE_DEFAULT_RECV_FRAME_SIZE = 4000;
//!
const double MPMD_BUFFER_DEPTH = 50.0e-3; // s
@@ -33,8 +43,8 @@ const double MPMD_BUFFER_DEPTH = 50.0e-3; // s
const double MPMD_MTU_DISCOVERY_TIMEOUT = 0.02;
// TODO: move these to appropriate header file for all other devices
-const size_t MAX_RATE_1GIGE = 1e9 / 8; // byte/s
-const size_t MAX_RATE_10GIGE = 10e9 / 8; // byte/s
+const double MAX_RATE_1GIGE = 1e9 / 8; // byte/s
+const double MAX_RATE_10GIGE = 10e9 / 8; // byte/s
std::vector<std::string> get_addrs_from_mb_args(const uhd::device_addr_t& mb_args)
{
@@ -163,11 +173,10 @@ mpmd_xport_ctrl_udp::mpmd_xport_ctrl_udp(const uhd::device_addr_t& mb_args)
uhd::both_xports_t mpmd_xport_ctrl_udp::make_transport(
mpmd_xport_mgr::xport_info_t& xport_info,
const usrp::device3_impl::xport_type_t xport_type,
- const uhd::device_addr_t& xport_args_)
+ const uhd::device_addr_t& xport_args)
{
- auto xport_args = xport_args_;
- size_t link_speed = MAX_RATE_1GIGE;
+ double link_speed = MAX_RATE_1GIGE;
if (xport_info.count("link_speed") == 0) {
UHD_LOG_WARNING("MPMD",
"Could not determine link speed; using 1GibE max speed of "
@@ -176,29 +185,54 @@ uhd::both_xports_t mpmd_xport_ctrl_udp::make_transport(
link_speed = xport_info.at("link_speed") == "10000" ? MAX_RATE_10GIGE
: MAX_RATE_1GIGE;
}
- transport::zero_copy_xport_params default_buff_args;
+
+ // Constrain by this transport's MTU and the MTU in the xport_args
+ const size_t send_mtu = std::min(get_mtu(uhd::TX_DIRECTION),
+ xport_args.cast<size_t>("mtu", get_mtu(uhd::TX_DIRECTION)));
+ const size_t recv_mtu = std::min(get_mtu(uhd::RX_DIRECTION),
+ xport_args.cast<size_t>("mtu", get_mtu(uhd::RX_DIRECTION)));
+
// Create actual UDP transport
- default_buff_args.num_send_frames = 1;
- default_buff_args.num_recv_frames =
- xport_type == usrp::device3_impl::CTRL ?
- (uhd::rfnoc::CMD_FIFO_SIZE / uhd::rfnoc::MAX_CMD_PKT_SIZE) :
- 1;
- default_buff_args.recv_frame_size =
- xport_args.cast<size_t>("recv_frame_size", get_mtu(uhd::RX_DIRECTION));
- default_buff_args.recv_buff_size = link_speed * MPMD_BUFFER_DEPTH;
- default_buff_args.send_buff_size = link_speed * MPMD_BUFFER_DEPTH;
- if (xport_type == usrp::device3_impl::ASYNC_MSG) {
- default_buff_args.send_frame_size = MPMD_10GE_ASYNCMSG_FRAME_MAX_SIZE;
- } else {
+ transport::zero_copy_xport_params default_buff_args;
+ default_buff_args.num_send_frames = MPMD_UDP_DEFAULT_NUM_SEND_FRAMES;
+ default_buff_args.num_recv_frames = MPMD_UDP_DEFAULT_NUM_RECV_FRAMES;
+ default_buff_args.recv_frame_size = MPMD_UDP_MSG_FRAME_SIZE;
+ default_buff_args.send_frame_size = MPMD_UDP_MSG_FRAME_SIZE;
+ if (xport_type == usrp::device3_impl::CTRL) {
+ default_buff_args.num_recv_frames =
+ uhd::rfnoc::CMD_FIFO_SIZE / uhd::rfnoc::MAX_CMD_PKT_SIZE;
+ } else if (xport_type == usrp::device3_impl::TX_DATA) {
+ const size_t default_frame_size = (link_speed == MAX_RATE_10GIGE ?
+ MPMD_UDP_10GE_DEFAULT_SEND_FRAME_SIZE :
+ MPMD_UDP_1GE_DEFAULT_SEND_FRAME_SIZE);
default_buff_args.send_frame_size =
- xport_args.cast<size_t>("send_frame_size", get_mtu(uhd::TX_DIRECTION));
+ xport_args.cast<size_t>("send_frame_size",
+ std::min(default_frame_size, send_mtu));
+ default_buff_args.num_send_frames =
+ xport_args.cast<size_t>("num_send_frames",
+ default_buff_args.num_send_frames);
+ default_buff_args.send_buff_size =
+ xport_args.cast<size_t>("send_buff_size",
+ default_buff_args.send_buff_size);
+ } else if (xport_type == usrp::device3_impl::RX_DATA) {
+ const size_t default_frame_size = (link_speed == MAX_RATE_10GIGE ?
+ MPMD_UDP_10GE_DEFAULT_RECV_FRAME_SIZE :
+ MPMD_UDP_1GE_DEFAULT_RECV_FRAME_SIZE);
+ default_buff_args.recv_frame_size =
+ xport_args.cast<size_t>("recv_frame_size",
+ std::min(default_frame_size, recv_mtu));
+ default_buff_args.num_recv_frames =
+ xport_args.cast<size_t>("num_recv_frames",
+ default_buff_args.num_recv_frames);
+ default_buff_args.recv_buff_size =
+ xport_args.cast<size_t>("recv_buff_size",
+ default_buff_args.recv_buff_size);
}
transport::udp_zero_copy::buff_params buff_params;
auto recv = transport::udp_zero_copy::make(xport_info["ipv4"],
xport_info["port"],
default_buff_args,
- buff_params,
- xport_args);
+ buff_params);
const uint16_t port = recv->get_local_port();
const std::string src_ip_addr = recv->get_local_addr();
xport_info["src_port"] = std::to_string(port);