diff options
author | Michael West <michael.west@ettus.com> | 2019-06-19 13:25:32 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-07-18 08:46:16 -0700 |
commit | 028a052dec8733f552fbfe0792126f5e9f8ca526 (patch) | |
tree | 67d42f21e4a2d20eadad036b655c2a0a40f71605 /host/lib/usrp/device3/device3_io_impl.cpp | |
parent | ab6893ab32f001d9aab1606bad34fafc4ab76933 (diff) | |
download | uhd-028a052dec8733f552fbfe0792126f5e9f8ca526.tar.gz uhd-028a052dec8733f552fbfe0792126f5e9f8ca526.tar.bz2 uhd-028a052dec8733f552fbfe0792126f5e9f8ca526.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/device3/device3_io_impl.cpp')
-rw-r--r-- | host/lib/usrp/device3/device3_io_impl.cpp | 86 |
1 files changed, 48 insertions, 38 deletions
diff --git a/host/lib/usrp/device3/device3_io_impl.cpp b/host/lib/usrp/device3/device3_io_impl.cpp index 06415dd91..800d2f5a8 100644 --- a/host/lib/usrp/device3/device3_io_impl.cpp +++ b/host/lib/usrp/device3/device3_io_impl.cpp @@ -168,7 +168,9 @@ static size_t get_rx_flow_control_window( size_t window_in_bytes = (static_cast<size_t>(fullness_factor * sw_buff_size)); if (rx_args.has_key("max_recv_window")) { window_in_bytes = std::min( - window_in_bytes, pkt_size * rx_args.cast<size_t>("max_recv_window", 1)); + window_in_bytes, + pkt_size * rx_args.cast<size_t>("max_recv_window", 1) + ); } if (window_in_bytes < pkt_size) { throw uhd::value_error("recv_buff_size must be larger than the recv_frame_size."); @@ -336,10 +338,13 @@ rx_streamer::sptr device3_impl::get_rx_stream(const stream_args_t& args_) // Setup the DSP transport hints device_addr_t rx_hints = get_rx_hints(mb_index); - // Traverse the upstream nodes for minimum mtu - size_t min_mtu = blk_ctrl->get_mtu(block_port); - UHD_RX_STREAMER_LOG() << "Maximum MTU supported by " << blk_ctrl->unique_id() - << ": " << min_mtu; + // Search the device and all nodes for lowest MTU + size_t mtu = std::min( + get_mtu(mb_index, uhd::direction_t::RX_DIRECTION), + blk_ctrl->get_mtu(block_port)); + UHD_RX_STREAMER_LOG() << "Maximum MTU supported by " + << blk_ctrl->unique_id() + << ": " << blk_ctrl->get_mtu(block_port); std::vector<boost::shared_ptr<uhd::rfnoc::source_block_ctrl_base>> upstream_source_nodes = blk_ctrl->find_upstream_node<uhd::rfnoc::source_block_ctrl_base>(); @@ -349,20 +354,19 @@ rx_streamer::sptr device3_impl::get_rx_stream(const stream_args_t& args_) // currently we use port 0 of a block in case of channel 1. UHD_RX_STREAMER_LOG() << "Maximum MTU supported by " << node->unique_id() << ": " << node->get_mtu(0); - min_mtu = std::min(min_mtu, node->get_mtu(0)); + mtu = std::min(mtu, node->get_mtu(0)); } - // Contraint min_mtu by device mtu - min_mtu = std::min(min_mtu, get_mtu(mb_index, uhd::direction_t::RX_DIRECTION)); - if (rx_hints.has_key("recv_frame_size")) { - if (rx_hints.cast<size_t>("recv_frame_size", min_mtu) > min_mtu) { - UHD_RX_STREAMER_LOG() - << "Requested recv_frame_size of " << rx_hints["recv_frame_size"] - << " exceeds the maximum possible on this stream. Using " << min_mtu; - } - min_mtu = - std::min(min_mtu, rx_hints.cast<size_t>("recv_frame_size", min_mtu)); + rx_hints["mtu"] = std::to_string(mtu); + + // Make sure user supplied recv_frame_size is less than the MTU + if (rx_hints.cast<size_t>("recv_frame_size", mtu) > mtu) { + UHD_LOGGER_WARNING("STREAMER") + << "Requested recv_frame_size of " + << rx_hints["recv_frame_size"] + << " exceeds the maximum possible on this stream. Using " + << mtu; + rx_hints["recv_frame_size"] = std::to_string(mtu); } - rx_hints["recv_frame_size"] = std::to_string(min_mtu); // allocate sid and create transport uhd::sid_t stream_address = blk_ctrl->get_address(block_port); @@ -448,8 +452,7 @@ rx_streamer::sptr device3_impl::get_rx_stream(const stream_args_t& args_) convert::get_bytes_per_item(args.otw_format); // bytes per item const size_t spp = std::min(args.args.cast<size_t>("spp", bpp / bpi), bpp / bpi); // samples per packet - UHD_RX_STREAMER_LOG() - << "bpp == " << bpp << ", bpi == " << bpi << ", spp == " << spp; + UHD_RX_STREAMER_LOG() << "bpp == " << bpp << ", bpi == " << bpi << ", spp == " << spp; my_streamer = boost::make_shared<device3_recv_packet_streamer>( spp, recv_terminator, xport); @@ -605,10 +608,13 @@ tx_streamer::sptr device3_impl::get_tx_stream(const uhd::stream_args_t& args_) // Setup the dsp transport hints device_addr_t tx_hints = get_tx_hints(mb_index); - // Traverse the downstream nodes for minimum mtu - size_t min_mtu = blk_ctrl->get_mtu(block_port); - UHD_TX_STREAMER_LOG() << "Maximum MTU supported by " << blk_ctrl->unique_id() - << ": " << min_mtu; + // Search the device and all nodes for lowest MTU + size_t mtu = std::min( + get_mtu(mb_index, uhd::direction_t::TX_DIRECTION), + blk_ctrl->get_mtu(block_port)); + UHD_TX_STREAMER_LOG() << "Maximum MTU supported by " + << blk_ctrl->unique_id() << ": " + << blk_ctrl->get_mtu(block_port); std::vector<boost::shared_ptr<uhd::rfnoc::sink_block_ctrl_base>> downstream_sink_nodes = blk_ctrl->find_downstream_node<uhd::rfnoc::sink_block_ctrl_base>(); @@ -616,21 +622,22 @@ tx_streamer::sptr device3_impl::get_tx_stream(const uhd::stream_args_t& args_) downstream_sink_nodes) { // Get MTU from Port 0 of the downstream nodes. This is okay for now as // currently we use port 0 of a block in case of channel 1. - UHD_TX_STREAMER_LOG() << "Maximum MTU supported by " << node->unique_id() - << ": " << node->get_mtu(0); - min_mtu = std::min(min_mtu, node->get_mtu(0)); + UHD_TX_STREAMER_LOG() << "Maximum MTU supported by " + << node->unique_id() << ": " + << node->get_mtu(0); + mtu = std::min(mtu, node->get_mtu(0)); } - min_mtu = std::min(min_mtu, get_mtu(mb_index, uhd::direction_t::TX_DIRECTION)); - if (tx_hints.has_key("send_frame_size")) { - if (tx_hints.cast<size_t>("send_frame_size", min_mtu) > min_mtu) { - UHD_TX_STREAMER_LOG() - << "Requested send_frame_size of " << tx_hints["send_frame_size"] - << " exceeds the maximum possible on this stream. Using " << min_mtu; - } - min_mtu = - std::min(min_mtu, tx_hints.cast<size_t>("send_frame_size", min_mtu)); + tx_hints["mtu"] = std::to_string(mtu); + + // Make sure user supplied send_frame_size is less than the MTU + if (tx_hints.cast<size_t>("send_frame_size", mtu) > mtu) { + UHD_LOGGER_WARNING("STREAMER") + << "Requested send_frame_size of " + << tx_hints["send_frame_size"] + << " exceeds the maximum possible on this stream. Using " + << mtu; + tx_hints["send_frame_size"] = std::to_string(mtu); } - tx_hints["send_frame_size"] = std::to_string(min_mtu); const size_t fifo_size = blk_ctrl->get_fifo_size(block_port); // Allocate sid and create transport @@ -729,13 +736,16 @@ tx_streamer::sptr device3_impl::get_tx_stream(const uhd::stream_args_t& args_) // To calculate the max number of samples per packet, we assume the maximum // header length to avoid fragmentation should the entire header be used. const size_t bpp = - tx_hints.cast<size_t>("bpp", pkt_size) - stream_options.tx_max_len_hdr; + tx_hints.cast<size_t>("bpp", pkt_size) - + stream_options.tx_max_len_hdr; const size_t bpi = convert::get_bytes_per_item(args.otw_format); // bytes per item const size_t spp = std::min(args.args.cast<size_t>("spp", bpp / bpi), bpp / bpi); // samples per packet UHD_TX_STREAMER_LOG() - << "bpp == " << bpp << ", bpi == " << bpi << ", spp == " << spp; + << "bpp == " << bpp + << ", bpi == " << bpi + << ", spp == " << spp; my_streamer = boost::make_shared<device3_send_packet_streamer>( spp, send_terminator, xport, async_xport); |