From cd03692e92c0f44fbd45875a8782dd6febee0f68 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 1 Jun 2017 00:04:24 -0700 Subject: mpmd: Refactored code to allow multi-device initialization --- host/lib/usrp/mpmd/mpmd_impl.hpp | 53 +++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 11 deletions(-) (limited to 'host/lib/usrp/mpmd/mpmd_impl.hpp') diff --git a/host/lib/usrp/mpmd/mpmd_impl.hpp b/host/lib/usrp/mpmd/mpmd_impl.hpp index 9a8b25ba0..6af2e4385 100644 --- a/host/lib/usrp/mpmd/mpmd_impl.hpp +++ b/host/lib/usrp/mpmd/mpmd_impl.hpp @@ -34,6 +34,7 @@ static const char MPM_DISCOVERY_CMD[] = "MPM-DISC"; static const char MPM_ECHO_CMD[] = "MPM-ECHO"; static const size_t MPMD_10GE_DATA_FRAME_MAX_SIZE = 8000; // CHDR packet size in bytes + struct frame_size_t { size_t recv_frame_size; @@ -46,35 +47,49 @@ struct frame_size_t class mpmd_mboard_impl { public: + /*** Types ***************************************************************/ using uptr = std::unique_ptr; using dev_info = std::map; + + /*** Structors ***********************************************************/ mpmd_mboard_impl(const std::string& addr); ~mpmd_mboard_impl(); + + /*** Factory *************************************************************/ static uptr make(const std::string& addr); - bool initialization_done = false; + /*** Public attributes ***************************************************/ + //! Device information is read back via MPM and stored here. uhd::dict device_info; - uhd::dict recv_args; - uhd::dict send_args; - std::map data_interfaces; - std::string loaded_fpga_image; - std::string xport_path; - /*! Reference the RPC client for this motherboard + //! Number of RFNoC crossbars on this device + size_t num_xbars = 0; + + /*! Reference to the RPC client for this motherboard * * We store a shared ptr, because we might share it with some of the RFNoC * blocks. */ uhd::rpc_client::sptr rpc; + + + /************************************************************************* + * API + ************************************************************************/ uhd::sid_t allocate_sid(const uint16_t port, const uhd::sid_t address, const uint32_t xbar_src_addr, const uint32_t xbar_src_dst); private: + /*! Renew the claim onto the device. + * + * This is meant to be called repeatedly, e.g., using a UHD task. + */ bool claim(); - std::string generate_token() const; - std::string _rpc_token; + + /*! Continuously reclaims the device. + */ uhd::task::sptr _claimer_task; }; @@ -91,19 +106,35 @@ class mpmd_impl : public uhd::usrp::device3_impl mpmd_impl(const uhd::device_addr_t& device_addr); ~mpmd_impl(); - mpmd_mboard_impl::uptr setup_mb(const size_t mb_i, - const uhd::device_addr_t& dev_addr); uhd::both_xports_t make_transport(const uhd::sid_t&, uhd::usrp::device3_impl::xport_type_t, const uhd::device_addr_t&); private: + mpmd_mboard_impl::uptr setup_mb( + const size_t mb_i, + const uhd::device_addr_t& dev_addr + ); + + void setup_rfnoc_blocks( + const size_t mb_i, + const uhd::device_addr_t& dev_addr + ); + + //! Configure all blocks that require access to an RPC client + void setup_rpc_blocks(const uhd::device_addr_t &block_args); + uhd::device_addr_t get_rx_hints(size_t mb_index); + uhd::dict recv_args; + uhd::dict send_args; + uhd::device_addr_t _device_addr; std::vector _mb; size_t _sid_framer; }; + uhd::device_addrs_t mpmd_find(const uhd::device_addr_t& hint_); + #endif /* INCLUDED_MPMD_IMPL_HPP */ // vim: sw=4 expandtab: -- cgit v1.2.3