aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/include
diff options
context:
space:
mode:
authormichael-west <michael.west@ettus.com>2022-02-13 18:43:52 -0800
committerAaron Rossetto <aaron.rossetto@ni.com>2022-04-07 06:24:52 -0700
commitb3a9c7849fa249653643d01c5d5f127feb92152b (patch)
tree3c80193f6efb111a132b8d8b0b006981854e94e0 /host/lib/include
parent41aadb29b952d563bf78c38b7bfd408d2f1d2519 (diff)
downloaduhd-b3a9c7849fa249653643d01c5d5f127feb92152b.tar.gz
uhd-b3a9c7849fa249653643d01c5d5f127feb92152b.tar.bz2
uhd-b3a9c7849fa249653643d01c5d5f127feb92152b.zip
multi_usrp_rfnoc: Add TX buffering using Replay
Enabled with the "tx_replay_buffer" device argument. Buffers TX data in DRAM using the Replay block (version 1.1 or higher required), allowing more buffering of data on the device. May reduce underruns for certain applications. The Replay block is currently limited to 32 play commands, so fewer calls to send() with larger buffers will perform better than more calls with smaller buffers. Signed-off-by: michael-west <michael.west@ettus.com>
Diffstat (limited to 'host/lib/include')
-rw-r--r--host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer_replay_buffered.hpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer_replay_buffered.hpp b/host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer_replay_buffered.hpp
new file mode 100644
index 000000000..23386d8c3
--- /dev/null
+++ b/host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer_replay_buffered.hpp
@@ -0,0 +1,78 @@
+//
+// Copyright 2022 Ettus Research, a National Instruments Brand
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+
+#pragma once
+
+#include <uhd/rfnoc_graph.hpp>
+#include <uhd/rfnoc/replay_block_control.hpp>
+#include <uhdlib/rfnoc/rfnoc_tx_streamer.hpp>
+
+namespace uhd { namespace rfnoc {
+
+/*!
+ * Extends the rfnoc_tx_streamer so it can use a Replay block to
+ * buffer TX data.
+ */
+class rfnoc_tx_streamer_replay_buffered : public rfnoc_tx_streamer
+{
+public:
+ struct replay_config_t
+ {
+ replay_block_control::sptr ctrl = nullptr; // Replay block control
+ size_t port = 0; // Replay port to use
+ uint64_t start_address = 0; // Start address in memory
+ uint64_t mem_size = 0; // Size of memory block to use
+ };
+
+ struct replay_status_t {
+ const replay_config_t config;
+ uint64_t record_offset = 0;
+ uint64_t play_offset = 0;
+ uint64_t play_end = 0;
+ };
+
+ /*! Constructor
+ *
+ * \param num_ports The number of ports
+ * \param stream_args Arguments to aid the construction of the streamer
+ * \param disconnect_cb Callback function to disconnect the streamer when
+ * the object is destroyed
+ * \param replay_chans Vector of Replay configurations to use (one per channel)
+ */
+ rfnoc_tx_streamer_replay_buffered(
+ const size_t num_ports,
+ const uhd::stream_args_t stream_args,
+ std::function<void(const std::string&)> disconnect_cb,
+ std::vector<replay_config_t> replay_configs);
+
+ /*! Destructor
+ */
+ ~rfnoc_tx_streamer_replay_buffered();
+
+ /*! Send
+ *
+ * Sends data by recording to the Replay block and playing it.
+ *
+ * \param buffs a vector of read-only memory containing samples
+ * \param nsamps_per_buff the number of samples to send, per buffer
+ * \param metadata data describing the buffer's contents
+ * \param timeout the timeout in seconds to wait on a packet
+ * \return the number of samples sent
+ */
+ size_t send(const buffs_type& buffs,
+ const size_t nsamps_per_buff,
+ const tx_metadata_t& metadata,
+ const double timeout = 0.1) override;
+
+private:
+ // Size of item
+ size_t _bytes_per_otw_item;
+
+ // Status of Replay channels
+ std::vector<replay_status_t> _replay_chans;
+};
+
+}} // namespace uhd::rfnoc