From a4274c19ebb42db112aa68a26fa499a52b9dd103 Mon Sep 17 00:00:00 2001 From: Alex Williams Date: Tue, 13 Aug 2019 09:13:46 -0700 Subject: rfnoc: Use adapter_id_t for balancing load across links Since the mb_iface allocates local device IDs, also have it track the associated adapter IDs and provide a facility to retrieve them. Incorporate the adapter IDs in the user API to select the adapter for streamers. --- .../include/uhdlib/rfnoc/graph_stream_manager.hpp | 36 ++++++++++++---------- .../include/uhdlib/rfnoc/link_stream_manager.hpp | 14 +++++++-- host/lib/include/uhdlib/rfnoc/mb_iface.hpp | 11 +++++++ host/lib/include/uhdlib/rfnoc/rfnoc_common.hpp | 4 +++ 4 files changed, 46 insertions(+), 19 deletions(-) (limited to 'host/lib/include/uhdlib/rfnoc') diff --git a/host/lib/include/uhdlib/rfnoc/graph_stream_manager.hpp b/host/lib/include/uhdlib/rfnoc/graph_stream_manager.hpp index 2227a7ad3..8a721ea26 100644 --- a/host/lib/include/uhdlib/rfnoc/graph_stream_manager.hpp +++ b/host/lib/include/uhdlib/rfnoc/graph_stream_manager.hpp @@ -8,13 +8,14 @@ #define INCLUDED_LIBUHD_RFNOC_GRAPH_STREAM_MANAGER_HPP #include +#include #include +#include +#include #include #include #include #include -#include -#include #include #include #include @@ -48,11 +49,11 @@ public: /*! \brief Connect the host to the specified destination and create a control stream * * \param dst_addr The physical address of the destination endpoint - * \param via_device The preference for the device to take to get to the destination + * \param adapter The preference for the adapter to use to get to the destination * \return A pair (source, destination) endpoint IDs for the control stream */ - virtual sep_id_pair_t connect_host_to_device( - sep_addr_t dst_addr, device_id_t host_device = NULL_DEVICE_ID) = 0; + virtual sep_id_pair_t connect_host_to_device(sep_addr_t dst_addr, + uhd::transport::adapter_id_t adapter = uhd::transport::NULL_ADAPTER_ID) = 0; /*! \brief Connect two remote endpoints to each other * @@ -69,23 +70,23 @@ public: * \param block_index The index of the block in the device * \param client_clk The clock that is driving the ctrlport slave * \param timebase_clk The clock that is driving the timebase - * \param via_device The preference for the device to take to get to the destination + * \param adapter The preference for the adapter to use to get to the destination * \return An interface to the ctrlport endpoint */ virtual ctrlport_endpoint::sptr get_block_register_iface(sep_addr_t dst_addr, uint16_t block_index, const clock_iface& client_clk, const clock_iface& timebase_clk, - device_id_t via_device = NULL_DEVICE_ID) = 0; + uhd::transport::adapter_id_t adapter = uhd::transport::NULL_ADAPTER_ID) = 0; /*! \brief Get a pointer to the client zero instance for the specified EPID * * \param dst_epid The endpoint ID of the destination - * \param via_device The preference for the device to take to get to the destination + * \param adapter The preference for the adapter to use to get to the destination * \return An interface to the client zero instance */ - virtual detail::client_zero::sptr get_client_zero( - sep_addr_t dst_addr, device_id_t via_device = NULL_DEVICE_ID) const = 0; + virtual detail::client_zero::sptr get_client_zero(sep_addr_t dst_addr, + uhd::transport::adapter_id_t adapter = uhd::transport::NULL_ADAPTER_ID) const = 0; /*! Configure a flow controlled data stream from the endpoint with ID src_epid to the @@ -111,7 +112,7 @@ public: * \param dst_addr The address of the destination stream endpoint * \param pyld_buff_fmt Datatype of SW buffer that holds the data payload * \param mdata_buff_fmt Datatype of SW buffer that holds the data metadata - * \param via_device The preference for the device to take to get to the destination + * \param adapter The preference for the adapter to use to get to the destination * \param xport_args The transport arguments * \return An transport instance */ @@ -119,7 +120,7 @@ public: sep_addr_t dst_addr, const sw_buff_t pyld_buff_fmt, const sw_buff_t mdata_buff_fmt, - const device_id_t via_device, + const uhd::transport::adapter_id_t adapter, const device_addr_t& xport_args) = 0; /*! \brief Create a data stream going from the host to the device @@ -127,7 +128,7 @@ public: * \param dst_addr The address of the destination stream endpoint * \param pyld_buff_fmt Datatype of SW buffer that holds the data payload * \param mdata_buff_fmt Datatype of SW buffer that holds the data metadata - * \param via_device The preference for the device to take to get to the destination + * \param adapter The preference for the adapter to use to get to the destination * \param xport_args The transport arguments * \return An transport instance */ @@ -135,15 +136,16 @@ public: sep_addr_t dst_addr, const sw_buff_t pyld_buff_fmt, const sw_buff_t mdata_buff_fmt, - const device_id_t via_device, + const uhd::transport::adapter_id_t adapter, const device_addr_t& xport_args) = 0; - /*! \brief Get all the via_devices that can reach the specified endpoint + /*! \brief Get all the adapters that can reach the specified endpoint * * \param addr The address of the stream endpoint - * \return A vector of all the via_devices + * \return A vector of adapter IDs */ - virtual std::vector get_via_devices(sep_addr_t addr) const = 0; + virtual std::vector get_adapters( + sep_addr_t addr) const = 0; /*! * \brief Create a graph_stream_manager and return a unique_ptr to it diff --git a/host/lib/include/uhdlib/rfnoc/link_stream_manager.hpp b/host/lib/include/uhdlib/rfnoc/link_stream_manager.hpp index 72f1cf1c7..b1a934891 100644 --- a/host/lib/include/uhdlib/rfnoc/link_stream_manager.hpp +++ b/host/lib/include/uhdlib/rfnoc/link_stream_manager.hpp @@ -7,11 +7,12 @@ #ifndef INCLUDED_LIBUHD_RFNOC_LINK_STREAM_MANAGER_HPP #define INCLUDED_LIBUHD_RFNOC_LINK_STREAM_MANAGER_HPP +#include +#include #include #include #include #include -#include #include #include #include @@ -26,6 +27,9 @@ namespace uhd { namespace rfnoc { * and thus, the host's device_id_t uniquely identifies the host-side transport adapter * to use for packet transmission/reception. * + * For convenience, the link_stream_manager also provides a method to get the + * host's transport adapter ID directly. + * * There must be one instance of this class per logical link. */ class link_stream_manager @@ -37,10 +41,16 @@ public: /*! \brief Get the software device ID associated with this instance * - * \return A vector of addresses for all reachable endpoints + * \return The software device ID associated with this instance */ virtual device_id_t get_self_device_id() const = 0; + /*! \brief Get the transport adapter ID associated with this instance + * + * \return The adapter ID associated with this instance + */ + virtual uhd::transport::adapter_id_t get_adapter_id() const = 0; + /*! \brief Get all the endpoints reachable from this link * * \return A vector of addresses for all reachable endpoints diff --git a/host/lib/include/uhdlib/rfnoc/mb_iface.hpp b/host/lib/include/uhdlib/rfnoc/mb_iface.hpp index 1a06d44e2..abfc9d1c4 100644 --- a/host/lib/include/uhdlib/rfnoc/mb_iface.hpp +++ b/host/lib/include/uhdlib/rfnoc/mb_iface.hpp @@ -7,6 +7,7 @@ #ifndef INCLUDED_LIBUHD_MB_IFACE_HPP #define INCLUDED_LIBUHD_MB_IFACE_HPP +#include #include #include #include @@ -66,6 +67,16 @@ public: */ virtual std::vector get_local_device_ids() = 0; + /*! Return the uhd::transport::adapter_id for the link associated with + * \p local_device_id + * + * A transport must be created on the adapter before this will be valid. + * Since link_stream_managers always create a chdr_ctrl_xport on + * construction, the requirement is satisfied. + */ + virtual uhd::transport::adapter_id_t get_adapter_id( + const device_id_t local_device_id) = 0; + /*! Reset the device */ virtual void reset_network() = 0; diff --git a/host/lib/include/uhdlib/rfnoc/rfnoc_common.hpp b/host/lib/include/uhdlib/rfnoc/rfnoc_common.hpp index 4785949e7..c2ec4e0e3 100644 --- a/host/lib/include/uhdlib/rfnoc/rfnoc_common.hpp +++ b/host/lib/include/uhdlib/rfnoc/rfnoc_common.hpp @@ -36,6 +36,8 @@ constexpr size_t chdr_w_to_bits(chdr_w_t chdr_w) } } +//! Device ID Type +using device_id_t = uint16_t; //! Stream Endpoint Instance Number Type using sep_inst_t = uint16_t; //! Stream Endpoint Physical Address Type @@ -49,6 +51,8 @@ using sep_id_pair_t = std::pair; //! Stream Endpoint Virtual Channel Type using sep_vc_t = uint8_t; +//! NULL/unassigned device ID +static constexpr device_id_t NULL_DEVICE_ID = 0; //! NULL/unassigned device address static constexpr sep_addr_t NULL_DEVICE_ADDR{NULL_DEVICE_ID, 0}; //! NULL/unassigned stream endpoint ID -- cgit v1.2.3