diff options
author | Ashish Chaudhari <ashish@ettus.com> | 2019-05-31 14:55:59 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:21 -0800 |
commit | de9cbe9c7c0a6e9296c561423d3b568bc1513133 (patch) | |
tree | 4ad7f19e6a33d409afe163aef3b4844442b094a8 /host/lib/include | |
parent | fff4fd59b7b7995904ecb2b010f05f78e9d0a0de (diff) | |
download | uhd-de9cbe9c7c0a6e9296c561423d3b568bc1513133.tar.gz uhd-de9cbe9c7c0a6e9296c561423d3b568bc1513133.tar.bz2 uhd-de9cbe9c7c0a6e9296c561423d3b568bc1513133.zip |
rfnoc: Graph and link stream manager API cleanup
Diffstat (limited to 'host/lib/include')
-rw-r--r-- | host/lib/include/uhdlib/rfnoc/epid_allocator.hpp | 9 | ||||
-rw-r--r-- | host/lib/include/uhdlib/rfnoc/graph_stream_manager.hpp | 50 | ||||
-rw-r--r-- | host/lib/include/uhdlib/rfnoc/link_stream_manager.hpp | 89 | ||||
-rw-r--r-- | host/lib/include/uhdlib/rfnoc/mgmt_portal.hpp | 31 | ||||
-rw-r--r-- | host/lib/include/uhdlib/rfnoc/rfnoc_common.hpp | 18 |
5 files changed, 161 insertions, 36 deletions
diff --git a/host/lib/include/uhdlib/rfnoc/epid_allocator.hpp b/host/lib/include/uhdlib/rfnoc/epid_allocator.hpp index c92ca013d..ec23dcb50 100644 --- a/host/lib/include/uhdlib/rfnoc/epid_allocator.hpp +++ b/host/lib/include/uhdlib/rfnoc/epid_allocator.hpp @@ -33,12 +33,19 @@ public: */ sep_id_t allocate_epid(const sep_addr_t& addr); + /*! \brief Get a pre-allocated EPID. Throws an exception is not allocated + * + * \param addr The physical address (device, instance) of the stream endpoint + * \return The allocated EPID + */ + sep_id_t get_epid(const sep_addr_t& addr); + /*! \brief Lookup an EPID and return the address associated with it. * * \param epid The allocated EPID * \return The physical address (device, instance) of the stream endpoint */ - sep_addr_t lookup_epid(const sep_id_t& epid) const; + sep_addr_t lookup_addr(const sep_id_t& epid) const; /*! \brief Deallocate the specified EPID. * diff --git a/host/lib/include/uhdlib/rfnoc/graph_stream_manager.hpp b/host/lib/include/uhdlib/rfnoc/graph_stream_manager.hpp index 81657453d..120b0e0f8 100644 --- a/host/lib/include/uhdlib/rfnoc/graph_stream_manager.hpp +++ b/host/lib/include/uhdlib/rfnoc/graph_stream_manager.hpp @@ -15,6 +15,7 @@ #include <functional> #include <memory> #include <set> +#include <tuple> namespace uhd { namespace rfnoc { @@ -41,25 +42,34 @@ public: */ virtual const std::set<sep_addr_t>& get_reachable_endpoints() const = 0; - /*! \brief Initialize a control endpoint to the specified destination + /*! \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 * \return A pair (source, destination) endpoint IDs for the control stream */ - virtual sep_id_pair_t init_ctrl_stream( - sep_addr_t dst_addr, device_id_t via_device = NULL_DEVICE_ID) = 0; + virtual sep_id_pair_t connect_host_to_device( + sep_addr_t dst_addr, device_id_t host_device = NULL_DEVICE_ID) = 0; + + /*! \brief Connect two remote endpoints to each other + * + * \param dst_addr The physical address of the destination endpoint + * \param src_addr The physical address of the source endpoint + * \return A pair (source, destination) endpoint IDs for the src/dst + */ + virtual sep_id_pair_t connect_device_to_device( + sep_addr_t dst_addr, sep_addr_t src_addr) = 0; /*! \brief Get a register iface (ctrlport endpoint) to a particular block * - * \param dst_epid The endpoint ID of the destination + * \param dst_addr The physical address of the destination endpoint * \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 * \return An interface to the ctrlport endpoint */ - virtual ctrlport_endpoint::sptr get_block_register_iface(sep_id_t dst_epid, + 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, @@ -72,8 +82,36 @@ public: * \return An interface to the client zero instance */ virtual detail::client_zero::sptr get_client_zero( - sep_id_t dst_epid, device_id_t via_device = NULL_DEVICE_ID) const = 0; + sep_addr_t dst_addr, device_id_t via_device = NULL_DEVICE_ID) const = 0; + /*! Configure a flow controlled data stream from the endpoint with ID src_epid to the + * endpoint with ID dst_epid + * + * \param dst_addr The physical address of the destination endpoint + * \param src_addr The physical address of the source endpoint + * \param lossy_xport Is the transport lossy? + * \param fc_freq_ratio Flow control response frequency as a ratio of the buff params + * \param fc_headroom_ratio Flow control headroom as a ratio of the buff params + * \param reset Optionally reset the stream + */ + virtual std::tuple<sep_id_pair_t, stream_buff_params_t> + create_device_to_device_data_stream(const sep_addr_t dst_addr, + const sep_addr_t src_addr, + const bool lossy_xport, + const double fc_freq_ratio, + const double fc_headroom_ratio, + const bool reset = false) = 0; + + // TODO: Implement functions to get graph-wide streamers + + /*! + * \brief Create a graph_stream_manager and return a unique_ptr to it + * + * \param pkt_factory A factory for generating CHDR packets + * \param epid_alloc The allocator for all EPIDs in the graph + * \param links Pairs of host devices and motherboards that should be connected + * \return A unique_ptr to the newly-created graph_stream_manager + */ static uptr make(const chdr::chdr_packet_factory& pkt_factory, const epid_allocator::sptr& epid_alloc, const std::vector<std::pair<device_id_t, mb_iface*>>& links); diff --git a/host/lib/include/uhdlib/rfnoc/link_stream_manager.hpp b/host/lib/include/uhdlib/rfnoc/link_stream_manager.hpp index c31bf8987..4ff69bb3e 100644 --- a/host/lib/include/uhdlib/rfnoc/link_stream_manager.hpp +++ b/host/lib/include/uhdlib/rfnoc/link_stream_manager.hpp @@ -13,12 +13,19 @@ #include <uhdlib/rfnoc/mb_iface.hpp> #include <functional> #include <memory> +#include <set> namespace uhd { namespace rfnoc { /*! A class that is responsible managing all data endpoints, control endpoints and client - * zero instances accessible via a physical link. There must be one instance this this - * class per physical link (Ethernet cable, PCIe connection, etc) + * zero instances accessible via a logical link between the host device and + * motherboard. + * + * Note that each transport adapter on the host has its own set of streaming endpoints, + * and thus, the host's device_id_t uniquely identifies the host-side transport adapter + * to use for packet transmission/reception. + * + * There must be one instance of this class per logical link. */ class link_stream_manager { @@ -39,12 +46,30 @@ public: */ virtual const std::set<sep_addr_t>& get_reachable_endpoints() const = 0; - /*! \brief Initialize a control endpoint to the specified destination + /*! \brief Connect the host to the specified destination and init a control endpoint * * \param dst_addr The physical address of the destination endpoint * \return A pair (source, destination) endpoint IDs for the control stream */ - virtual sep_id_pair_t init_ctrl_stream(sep_addr_t dst_addr) = 0; + virtual sep_id_pair_t connect_host_to_device(sep_addr_t dst_addr) = 0; + + /*! \brief Check if the two specified endpoints can be connected remotely + * + * \param dst_addr The physical address of the destination endpoint + * \param src_addr The physical address of the source endpoint + * \return true if the endpoints can be connected + */ + virtual bool can_connect_device_to_device( + sep_addr_t dst_addr, sep_addr_t src_addr) const = 0; + + /*! \brief Connect two remote endpoints to each other + * + * \param dst_addr The physical address of the destination endpoint + * \param src_addr The physical address of the source endpoint + * \return A pair (source, destination) endpoint IDs for the src/dst + */ + virtual sep_id_pair_t connect_device_to_device( + sep_addr_t dst_addr, sep_addr_t src_addr) = 0; /*! \brief Get a register iface (ctrlport endpoint) to a particular block * @@ -66,15 +91,61 @@ public: */ virtual detail::client_zero::sptr get_client_zero(sep_id_t dst_epid) const = 0; - /*! \brief Create a data stream + /*! Configure a flow controlled data stream from the endpoint with ID src_epid to the + * endpoint with ID dst_epid * * \param dst_epid The endpoint ID of the destination - * \param vc The virtual channel - * \param xport_args The transport argument + * \param src_epid The endpoint ID of the source + * \param lossy_xport Is the transport lossy? + * \param fc_freq_ratio Flow control response frequency as a ratio of the buff params + * \param fc_headroom_ratio Flow control headroom as a ratio of the buff params + * \param reset Optionally reset the stream + */ + virtual stream_buff_params_t create_device_to_device_data_stream( + const sep_id_t& dst_epid, + const sep_id_t& src_epid, + const bool lossy_xport, + const double fc_freq_ratio, + const double fc_headroom_ratio, + const bool reset = false) = 0; + + /*! \brief Create a data stream going from the host to the device + * + * \param dst_addr The address of the destination stream endpoint + * \param lossy_xport Is the transport lossy? + * \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 fc_freq_ratio Flow control response frequency as a ratio of the buff params + * \param fc_headroom_ratio Flow control headroom as a ratio of the buff params + * \param xport_args The transport arguments + * \return An transport instance + */ + virtual chdr_data_xport_t create_host_to_device_data_stream(const sep_addr_t dst_addr, + const bool lossy_xport, + const sw_buff_t pyld_buff_fmt, + const sw_buff_t mdata_buff_fmt, + const double fc_freq_ratio, + const double fc_headroom_ratio, + const device_addr_t& xport_args) = 0; + + /*! \brief Create a data stream going from the device to the host + * + * \param dst_addr The address of the destination stream endpoint + * \param lossy_xport Is the transport lossy? + * \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 fc_freq_ratio Flow control response frequency as a ratio of the buff params + * \param fc_headroom_ratio Flow control headroom as a ratio of the buff params + * \param xport_args The transport arguments * \return An transport instance */ - virtual chdr_data_xport_t create_data_stream( - sep_addr_t dst_addr, sep_vc_t vc, const device_addr_t& xport_args) = 0; + virtual chdr_data_xport_t create_device_to_host_data_stream(const sep_addr_t src_addr, + const bool lossy_xport, + const sw_buff_t pyld_buff_fmt, + const sw_buff_t mdata_buff_fmt, + const double fc_freq_ratio, + const double fc_headroom_ratio, + const device_addr_t& xport_args) = 0; static uptr make(const chdr::chdr_packet_factory& pkt_factory, mb_iface& mb_if, diff --git a/host/lib/include/uhdlib/rfnoc/mgmt_portal.hpp b/host/lib/include/uhdlib/rfnoc/mgmt_portal.hpp index 12f40f172..1412d0e3d 100644 --- a/host/lib/include/uhdlib/rfnoc/mgmt_portal.hpp +++ b/host/lib/include/uhdlib/rfnoc/mgmt_portal.hpp @@ -9,6 +9,7 @@ #include <uhdlib/rfnoc/chdr_types.hpp> #include <memory> +#include <set> namespace uhd { namespace rfnoc { namespace mgmt { @@ -26,13 +27,6 @@ public: using xport_cfg_fn_t = std::function<void( device_id_t devid, uint16_t inst, uint8_t subtype, chdr::mgmt_hop_t& hop)>; - //! Flow control buffer configuration parameters - struct buff_params_t - { - uint64_t bytes; - uint32_t packets; - }; - //! Information about a stream endpoint struct sep_info_t { @@ -50,9 +44,6 @@ public: sep_addr_t addr; }; - //! The data type of the buffer used to capture/generate data - enum sw_buff_t { BUFF_U64 = 0, BUFF_U32 = 1, BUFF_U16 = 2, BUFF_U8 = 3 }; - virtual ~mgmt_portal() = 0; //! Get addresses for all stream endpoints reachable from this SW mgmt portal @@ -90,6 +81,14 @@ public: // virtual void setup_local_route(const sep_id_t& dst_epid) = 0; + //! Can a route from between the source and destination endpoints be established? + // + // \param dst_epid The endpoint ID of the destination + // \param src_epid The endpoint ID of the source + // + virtual bool can_remote_route( + const sep_addr_t& dst_addr, const sep_addr_t& src_addr) const = 0; + //! Setup a route from between the source and destination endpoints // // After a route is established, it should be possible for the source to send packets @@ -121,8 +120,8 @@ public: const bool lossy_xport, const sw_buff_t pyld_buff_fmt, const sw_buff_t mdata_buff_fmt, - const buff_params_t& fc_freq, - const buff_params_t& fc_headroom, + const stream_buff_params_t& fc_freq, + const stream_buff_params_t& fc_headroom, const bool reset = false) = 0; //! Finish configuring a flow controlled receive data stream from the endpoint with @@ -130,7 +129,7 @@ public: // // \param epid The endpoint ID of the data source // - virtual buff_params_t config_local_rx_stream_commit( + virtual stream_buff_params_t config_local_rx_stream_commit( const sep_id_t& epid, const double timeout = 0.2) = 0; //! Configure a flow controlled transmit data stream from this SW mgmt portal to the @@ -156,11 +155,11 @@ public: // \param fc_freq Flow control response frequency parameters // \param fc_freq Flow control headroom parameters // - virtual buff_params_t config_remote_stream(const sep_id_t& dst_epid, + virtual stream_buff_params_t config_remote_stream(const sep_id_t& dst_epid, const sep_id_t& src_epid, const bool lossy_xport, - const buff_params_t& fc_freq, - const buff_params_t& fc_headroom, + const stream_buff_params_t& fc_freq, + const stream_buff_params_t& fc_headroom, const bool reset = false, const double timeout = 0.2) = 0; diff --git a/host/lib/include/uhdlib/rfnoc/rfnoc_common.hpp b/host/lib/include/uhdlib/rfnoc/rfnoc_common.hpp index bac510f04..c08c8d74a 100644 --- a/host/lib/include/uhdlib/rfnoc/rfnoc_common.hpp +++ b/host/lib/include/uhdlib/rfnoc/rfnoc_common.hpp @@ -56,16 +56,26 @@ static constexpr sep_addr_t NULL_DEVICE_ADDR{NULL_DEVICE_ID, 0}; static constexpr sep_id_t NULL_EPID = 0; +//! Flow control buffer configuration parameters +struct stream_buff_params_t +{ + uint64_t bytes; + uint32_t packets; +}; + +//! The data type of the buffer used to capture/generate data +enum sw_buff_t { BUFF_U64 = 0, BUFF_U32 = 1, BUFF_U16 = 2, BUFF_U8 = 3 }; + // TODO: Update these struct chdr_ctrl_xport_t { chdr_ctrl_xport_t() = default; uhd::transport::zero_copy_if::sptr recv; uhd::transport::zero_copy_if::sptr send; - size_t recv_buff_size = 0; - size_t send_buff_size = 0; - sep_id_t src_epid = 0; - sep_id_t dst_epid = 0; + stream_buff_params_t recv_buff_params{0, 0}; + stream_buff_params_t send_buff_params{0, 0}; + sep_id_t src_epid{0}; + sep_id_t dst_epid{0}; }; using chdr_data_xport_t = chdr_ctrl_xport_t; |