diff options
| author | Michael West <michael.west@ettus.com> | 2019-06-19 13:25:32 -0700 |
|---|---|---|
| committer | michael-west <michael.west@ettus.com> | 2019-06-28 08:21:09 -0700 |
| commit | 3f7b937d3fbabe0a885bdcaf8137502528db6e68 (patch) | |
| tree | b10d741b615cf9707420a7e24276d0ca67858c4b /host/lib/usrp/mpmd/mpmd_xport_ctrl_liberio.cpp | |
| parent | 55b9f7309f6f49eccd1157e898b77dc9a6afd238 (diff) | |
| download | uhd-3f7b937d3fbabe0a885bdcaf8137502528db6e68.tar.gz uhd-3f7b937d3fbabe0a885bdcaf8137502528db6e68.tar.bz2 uhd-3f7b937d3fbabe0a885bdcaf8137502528db6e68.zip | |
Device3: Fix MTU and default frame sizes
The latest changes to the get_*x_stream() functions to calculate the MTU for
the channel caused default frame size values to be ignored. This change fixes
that by changing the key from "send/recv_frame_size" to "mtu" and then changing
the implementations of make_transport() constrain the frame size values based
on the "mtu" value as well as any device and/or transport-specific limits.
Signed-off-by: Michael West <michael.west@ettus.com>
Diffstat (limited to 'host/lib/usrp/mpmd/mpmd_xport_ctrl_liberio.cpp')
| -rw-r--r-- | host/lib/usrp/mpmd/mpmd_xport_ctrl_liberio.cpp | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/host/lib/usrp/mpmd/mpmd_xport_ctrl_liberio.cpp b/host/lib/usrp/mpmd/mpmd_xport_ctrl_liberio.cpp index 8f3014bc7..00be452ac 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"]; @@ -126,7 +162,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(); } |
