diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-12-01 16:14:11 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:05:58 -0800 |
commit | 87dbcd9f1a5b2b464c27af56c3a91ab00f66c441 (patch) | |
tree | 62ccd5be210d94862071aecda5ec3e667b036148 /host/lib/usrp/mpmd/mpmd_xport_mgr.hpp | |
parent | a927a364c5b07387be3a849b74546b98ba84db84 (diff) | |
download | uhd-87dbcd9f1a5b2b464c27af56c3a91ab00f66c441.tar.gz uhd-87dbcd9f1a5b2b464c27af56c3a91ab00f66c441.tar.bz2 uhd-87dbcd9f1a5b2b464c27af56c3a91ab00f66c441.zip |
mpmd: Refactor MPM transport architecture, use managers
This splits up the transport code in mpmd_impl across multiple classes
to properly leverage the request_xport/commit_xport API in MPM.
Different types of transport (UDP, liberio) use their own distinct
classes, which are generated dynamically on request.
This is a true refactoring despite the large amount of changes; there
are no functional differences.
Reviewed-By: Brent Stapleton <brent.stapleton@ettus.com>
Reviewed-By: Trung Tran <trung.tran@ettus.com>
Reviewed-By: Ashish Chaudhari <ashish.chaudhari@ettus.com>
Diffstat (limited to 'host/lib/usrp/mpmd/mpmd_xport_mgr.hpp')
-rw-r--r-- | host/lib/usrp/mpmd/mpmd_xport_mgr.hpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/host/lib/usrp/mpmd/mpmd_xport_mgr.hpp b/host/lib/usrp/mpmd/mpmd_xport_mgr.hpp new file mode 100644 index 000000000..2da4af323 --- /dev/null +++ b/host/lib/usrp/mpmd/mpmd_xport_mgr.hpp @@ -0,0 +1,95 @@ +// +// Copyright 2017 Ettus Research, a National Instruments Company +// +// SPDX-License-Identifier: GPL-3.0 +// + +#ifndef INCLUDED_MPMD_XPORT_MGR_HPP +#define INCLUDED_MPMD_XPORT_MGR_HPP + +#include "../device3/device3_impl.hpp" +#include <uhd/types/dict.hpp> +#include <memory> +#include <map> +#include <vector> +#include <string> + +namespace uhd { namespace mpmd { namespace xport { + +/*! Return filtered subset from a device_addr_t + * + * The return dictionary will contain all key/value pairs from \p args + * where the key begins with \p prefix. + * + * \param args Bucket of key/value pairs + * \param prefix Key prefix to match against + */ +uhd::dict<std::string, std::string> filter_args( + const uhd::device_addr_t& args, + const std::string& prefix +); + +/*! MPMD Transport Manager + * + * A transport manager is an object which sets up a physical connection to a + * CHDR device. Its implementation is specific to the underlying transport + * medium. For example, if the medium is Ethernet/UDP, this class will create + * sockets. + */ +class mpmd_xport_mgr +{ +public: + using uptr = std::unique_ptr<mpmd_xport_mgr>; + using xport_info_t = std::map<std::string, std::string>; + using xport_info_list_t = std::vector<std::map<std::string, std::string>>; + + /*! Return a reference to a transport manager + * + * \param mb_args Additional args from the motherboard. These may contain + * transport-related args (e.g., "recv_buff_size") which + * can be relevant to the underlying implementation. + * + * \returns Reference to manager object + * \throws uhd::key_error if \p xport_medium is not supported. The ctor of + * the underlying class that is requested can also throw. + */ + static uptr make( + const uhd::device_addr_t& mb_args + ); + + /*! Create a transports object + * + * Implementation details depend on the underlying implementation. + * In general, the implementations will follow the following recipe: + * 1. Pick a suitable element from \p xport_info_list + * 2. Do whatever system calls are necessary to create the physical + * transport; to do so, call the underlying implementation (UDP or + * whatever) + * 3. Update the selected element from xport_info_list + * 5. Return results + * + * \param xport_info_list List of possible options to choose from. Every + * element of this argument needs to have the same + * "type" key (e.g., they all need to be "UDP"). + * \param xport_type Transport type (CTRL, RX_DATA, ...) + * \param xport_args Arbitrary additional transport args. These could come + * from the user, or other places. + * \param xport_info_out The updated dictionary from xport_info_list that + * was eventually chosen + * + * \returns The both_xports_t object containing the actual transport info, + * and xport_info_out contains the updated transport option info. + * The latter needs to get sent back to MPM to complete the + * transport handshake. + */ + virtual both_xports_t make_transport( + const xport_info_list_t &xport_info_list, + const usrp::device3_impl::xport_type_t xport_type, + const uhd::device_addr_t& xport_args, + xport_info_t& xport_info_out + ) = 0; +}; + +}}} /* namespace uhd::mpmd::xport */ + +#endif /* INCLUDED_MPMD_XPORT_MGR_HPP */ |