From 35db8f741b4b6c0bccf04e68e81bc4ecb5018357 Mon Sep 17 00:00:00 2001 From: Ciro Nishiguchi Date: Mon, 12 Aug 2019 11:59:16 -0500 Subject: rfnoc: Add MTU property to TX streamer --- .../lib/include/uhdlib/rfnoc/rfnoc_tx_streamer.hpp | 10 ++++++++ .../include/uhdlib/transport/tx_streamer_impl.hpp | 29 ++++++++++++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) (limited to 'host/lib/include') diff --git a/host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer.hpp b/host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer.hpp index 4acee45cc..3bfc9d05a 100644 --- a/host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer.hpp +++ b/host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer.hpp @@ -69,6 +69,15 @@ public: bool check_topology(const std::vector& connected_inputs, const std::vector& connected_outputs); + /*! Connects a channel to the streamer port + * + * Overrides method in tx_streamer_impl. + * + * \param channel The streamer channel to which to connect + * \param xport The transport for the specified channel + */ + void connect_channel(const size_t channel, chdr_tx_data_xport::uptr xport); + private: void _register_props(const size_t chan, const std::string& otw_format); @@ -77,6 +86,7 @@ private: std::vector> _samp_rate_out; std::vector> _tick_rate_out; std::vector> _type_out; + std::vector> _mtu_out; // Streamer unique ID const std::string _unique_id; diff --git a/host/lib/include/uhdlib/transport/tx_streamer_impl.hpp b/host/lib/include/uhdlib/transport/tx_streamer_impl.hpp index 60881dad2..819ed5558 100644 --- a/host/lib/include/uhdlib/transport/tx_streamer_impl.hpp +++ b/host/lib/include/uhdlib/transport/tx_streamer_impl.hpp @@ -79,14 +79,14 @@ public: _spp = stream_args.args.cast("spp", _spp); } - void connect_channel(const size_t channel, typename transport_t::uptr xport) + virtual void connect_channel(const size_t channel, typename transport_t::uptr xport) { - const size_t max_pyld_size = xport->get_max_payload_size(); + const size_t mtu = xport->get_max_payload_size(); _zero_copy_streamer.connect_channel(channel, std::move(xport)); - // Set spp based on the transport frame size - const size_t xport_spp = max_pyld_size / _convert_info.bytes_per_otw_item; - _spp = std::min(_spp, xport_spp); + if (mtu < _mtu) { + set_mtu(mtu); + } } size_t get_num_channels() const @@ -187,6 +187,22 @@ public: } protected: + //! Returns the size in bytes of a sample in a packet + size_t get_mtu() const + { + return _mtu; + } + + //! Sets the MTU and calculates spp + void set_mtu(const size_t mtu) + { + _mtu = mtu; + + // Check if spp needs to be lowered. SPP may already be lower than the + // value allowed by mtu if the user specified it using stream_args. + _spp = std::min(_spp, _mtu / _convert_info.bytes_per_otw_item); + } + //! Configures scaling factor for conversion void set_scale_factor(const size_t chan, const double scale_factor) { @@ -295,6 +311,9 @@ private: // Sample rate used to calculate metadata time_spec_t double _samp_rate = 1.0; + // Maximum payload size + size_t _mtu = std::numeric_limits::max(); + // Maximum number of samples per packet size_t _spp = std::numeric_limits::max(); -- cgit v1.2.3