aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/include/uhdlib/usrp/common/io_service_mgr.hpp
diff options
context:
space:
mode:
authorAaron Rossetto <aaron.rossetto@ni.com>2019-10-17 08:44:11 -0500
committerMartin Braun <martin.braun@ettus.com>2019-11-26 12:21:32 -0800
commit0bd233e64210c6605e8a6ec1424fa81f9ea8a681 (patch)
treef97729a7bba21cdfc45ee756bee1ac0489358544 /host/lib/include/uhdlib/usrp/common/io_service_mgr.hpp
parent912ed28b3df13b9f9c33f2fa92867ec0ac7445fd (diff)
downloaduhd-0bd233e64210c6605e8a6ec1424fa81f9ea8a681.tar.gz
uhd-0bd233e64210c6605e8a6ec1424fa81f9ea8a681.tar.bz2
uhd-0bd233e64210c6605e8a6ec1424fa81f9ea8a681.zip
uhd: Introduce I/O service manager
- Implement I/O service detach link methods - The I/O service manager instantiates new I/O services or connects links to existing I/O services based on options provided by the user in stream_args. - Add a streamer ID parameter to methods to create transports so that the I/O service manager can group transports appropriately when using offload threads. - Change X300 and MPMD to use I/O service manager to connect links to I/O services. - There is now a single I/O service manager per rfnoc_graph (and it is also stored in the graph) - The I/O service manager now also knows the device args for the rfnoc_graph it was created with, and can make decisions based upon those (e.g, use a specific I/O service for DPDK, share cores between streamers, etc.) - The I/O Service Manager does not get any decision logic with this commit, though - The MB ifaces for mpmd and x300 now access this global I/O service manager - Add configuration of link parameters with overrides Co-Authored-By: Martin Braun <martin.braun@ettus.com> Co-Authored-By: Aaron Rossetto <aaron.rossetto@ni.com>
Diffstat (limited to 'host/lib/include/uhdlib/usrp/common/io_service_mgr.hpp')
-rw-r--r--host/lib/include/uhdlib/usrp/common/io_service_mgr.hpp104
1 files changed, 104 insertions, 0 deletions
diff --git a/host/lib/include/uhdlib/usrp/common/io_service_mgr.hpp b/host/lib/include/uhdlib/usrp/common/io_service_mgr.hpp
new file mode 100644
index 000000000..1093f7bec
--- /dev/null
+++ b/host/lib/include/uhdlib/usrp/common/io_service_mgr.hpp
@@ -0,0 +1,104 @@
+//
+// Copyright 2019 Ettus Research, a National Instruments Brand
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+
+#ifndef INCLUDED_LIBUHD_IO_SERVICE_MGR_HPP
+#define INCLUDED_LIBUHD_IO_SERVICE_MGR_HPP
+
+#include <uhd/transport/adapter_id.hpp>
+#include <uhd/types/device_addr.hpp>
+#include <uhdlib/transport/io_service.hpp>
+#include <uhdlib/transport/link_if.hpp>
+#include <uhdlib/transport/links.hpp>
+#include <uhdlib/usrp/common/io_service_args.hpp>
+#include <memory>
+
+namespace uhd { namespace usrp {
+
+/*! Class to create and manage I/O services
+ *
+ * The I/O service manager connects links to I/O services, instantiating new I/O
+ * services as needed. It chooses the I/O service to connect based on options
+ * from the user passed through stream_args, as well as defaults provided by the
+ * caller.
+ *
+ * The I/O service manager supports two types of I/O services: inline I/O service
+ * and offload I/O service. Inline I/O services execute all I/O in the caller
+ * thread. Offload I/O services execute all I/O in an offload thread. The offload
+ * thread can be configured to block or poll. All control links use inline I/O
+ * services, only RX and TX data links currently use offload I/O services.
+ *
+ * If polling I/O services are requested, the I/O service manager instantiates
+ * the number of I/O services specified by the user through args. It chooses
+ * which I/O service to connect a set of links to by selecting the I/O service
+ * with the fewest number of connections.
+ *
+ * If blocking I/O services are requested, the I/O service manager instantiates
+ * one offload I/O service for each transport adapter used by a streamer. When
+ * there are multiple streamers, this manager creates a separate set of I/O
+ * services for each streamer.
+ *
+ * Offload I/O services have a number of restrictions that must be observed:
+ * - Offload I/O services currently do not support links that require frame
+ * buffers to be released in order.
+ * - Blocking I/O services should only be used for groups of RX or TX data
+ * transport in the same streamer. Since the I/O service blocks on each
+ * channel, if two streamers were to be configured to share the I/O service,
+ * one streamer would block the progress of the other. The I/O service
+ * manager ensures this restriction is observed by grouping I/O services
+ * and links appropriately.
+ * - Blocking I/O services do not currently support muxed links, since the I/O
+ * service is specialized to either RX or TX data and the procedure to configure
+ * a data transport requires both RX and TX clients. The I/O service manager
+ * throws an exception if requested to mux a link configured with a blocking
+ * I/O service.
+ */
+class io_service_mgr
+{
+public:
+ using sptr = std::shared_ptr<io_service_mgr>;
+
+ /*! Connects a pair of links to an I/O service
+ *
+ * Call this method to connect a pair of links to an I/O service. For muxed
+ * links, the I/O service manager keeps track of the number of muxed
+ * connections (the number of times this method has been called with the same
+ * links).
+ *
+ * The last two parameters are ignored for control links.
+ *
+ * \param recv_link The recv link to connect to an I/O service
+ * \param send_link The send link to connect to an I/O service
+ * \param link_type The type of transport in which the links will be used
+ * \param io_srv_args The user-requested options for the stream
+ * \param streamer_id A unique ID for the streamer that will use the links
+ * \return The I/O service to which the links are connected
+ */
+ virtual transport::io_service::sptr connect_links(
+ transport::recv_link_if::sptr recv_link,
+ transport::send_link_if::sptr send_link,
+ const transport::link_type_t link_type,
+ const io_service_args_t& io_srv_args = io_service_args_t(),
+ const std::string& streamer_id = "") = 0;
+
+ /*! Disconnects links from their I/O service
+ *
+ * \param recv_link The recv link to disconnect from an I/O service
+ * \param send_link The send link to disconnect from an I/O service
+ */
+ virtual void disconnect_links(transport::recv_link_if::sptr recv_link,
+ transport::send_link_if::sptr send_link) = 0;
+
+ /*! Creates an instance of an I/O service manager
+ *
+ * \params Device args used to create the UHD session
+ * \return The I/O service manager instance
+ */
+ static sptr make(const uhd::device_addr_t& args);
+};
+
+}} // namespace uhd::usrp
+
+#endif /* INCLUDED_LIBUHD_IO_SERVICE_MGR_HPP */