diff options
-rw-r--r-- | host/lib/usrp/mpmd/mpmd_link_if_ctrl_udp.cpp | 36 | ||||
-rw-r--r-- | host/lib/usrp/mpmd/mpmd_link_if_ctrl_udp.hpp | 4 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/e31x.py | 6 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/e320.py | 6 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/n3xx.py | 6 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/xports/xportmgr_udp.py | 8 |
6 files changed, 50 insertions, 16 deletions
diff --git a/host/lib/usrp/mpmd/mpmd_link_if_ctrl_udp.cpp b/host/lib/usrp/mpmd/mpmd_link_if_ctrl_udp.cpp index 7b41ac631..14b02765d 100644 --- a/host/lib/usrp/mpmd/mpmd_link_if_ctrl_udp.cpp +++ b/host/lib/usrp/mpmd/mpmd_link_if_ctrl_udp.cpp @@ -81,18 +81,34 @@ mpmd_link_if_ctrl_udp::udp_link_info_map get_udp_info_from_xport_info( std::vector<std::string> get_addrs_from_mb_args(const uhd::device_addr_t& mb_args, const mpmd_link_if_ctrl_udp::udp_link_info_map& link_info_list) { - // mb_args must always include addr - if (not mb_args.has_key(FIRST_ADDR_KEY)) { - UHD_LOG_WARNING("MPMD::XPORT::UDP", - "The `" << FIRST_ADDR_KEY - << "' key must be specified in " - "device args to create an Ethernet transport to an RFNoC block"); - return {}; + std::vector<std::string> addrs; + if(link_info_list.size() > 0 && + link_info_list.begin()->second.link_type == "internal") { + // If link_type is "internal" we are local. In this case + // use this address always. MPM knows better than us. + addrs.push_back(link_info_list.begin()->first); } - std::vector<std::string> addrs{mb_args[FIRST_ADDR_KEY]}; - if (mb_args.has_key(SECOND_ADDR_KEY)) { - addrs.push_back(mb_args[SECOND_ADDR_KEY]); + else { + if (mb_args.has_key(FIRST_ADDR_KEY)) { + addrs.push_back(mb_args[FIRST_ADDR_KEY]); + } + if (mb_args.has_key(SECOND_ADDR_KEY)) { + addrs.push_back(mb_args[SECOND_ADDR_KEY]); + } } + if(addrs.empty()) { + if(link_info_list.size() > 0) { + addrs.push_back(link_info_list.begin()->first); + } + else { + UHD_LOG_WARNING("MPMD::XPORT::UDP", + "The `" << FIRST_ADDR_KEY + << "' key must be specified in " + "device args to create an Ethernet transport to an RFNoC block"); + return {}; + } + } + // This is where in UHD we encode the knowledge about what // get_chdr_link_options() returns to us. for (const auto& ip_addr : addrs) { diff --git a/host/lib/usrp/mpmd/mpmd_link_if_ctrl_udp.hpp b/host/lib/usrp/mpmd/mpmd_link_if_ctrl_udp.hpp index e4a0d7811..13d28e42b 100644 --- a/host/lib/usrp/mpmd/mpmd_link_if_ctrl_udp.hpp +++ b/host/lib/usrp/mpmd/mpmd_link_if_ctrl_udp.hpp @@ -9,9 +9,9 @@ #include "mpmd_link_if_ctrl_base.hpp" #include "mpmd_link_if_mgr.hpp" +#include <map> #include <uhd/types/device_addr.hpp> #include <uhdlib/rfnoc/rfnoc_common.hpp> -#include <unordered_map> namespace uhd { namespace mpmd { namespace xport { @@ -30,7 +30,7 @@ public: size_t if_mtu; }; - using udp_link_info_map = std::unordered_map<std::string, udp_link_info_t>; + using udp_link_info_map = std::map<std::string, udp_link_info_t>; mpmd_link_if_ctrl_udp(const uhd::device_addr_t& mb_args, const mpmd_link_if_mgr::xport_info_list_t& xport_info, diff --git a/mpm/python/usrp_mpm/periph_manager/e31x.py b/mpm/python/usrp_mpm/periph_manager/e31x.py index 11f65dd17..025f8b222 100644 --- a/mpm/python/usrp_mpm/periph_manager/e31x.py +++ b/mpm/python/usrp_mpm/periph_manager/e31x.py @@ -524,7 +524,11 @@ class e31x(ZynqComponents, PeriphManagerBase): self.log.warning("Can't get link options for unknown link type: `{}'." .format(xport_type)) return [] - return self._xport_mgrs[xport_type].get_chdr_link_options() + if xport_type == "udp": + return self._xport_mgrs[xport_type].get_chdr_link_options( + self.mboard_info['rpc_connection']) + else: + return self._xport_mgrs[xport_type].get_chdr_link_options() ########################################################################### # Device info diff --git a/mpm/python/usrp_mpm/periph_manager/e320.py b/mpm/python/usrp_mpm/periph_manager/e320.py index 770b449b5..f8b17df7f 100644 --- a/mpm/python/usrp_mpm/periph_manager/e320.py +++ b/mpm/python/usrp_mpm/periph_manager/e320.py @@ -399,7 +399,11 @@ class e320(ZynqComponents, PeriphManagerBase): self.log.warning("Can't get link options for unknown link type: `{}'." .format(xport_type)) return [] - return self._xport_mgrs[xport_type].get_chdr_link_options() + if xport_type == "udp": + return self._xport_mgrs[xport_type].get_chdr_link_options( + self.mboard_info['rpc_connection']) + else: + return self._xport_mgrs[xport_type].get_chdr_link_options() ########################################################################### # Device info diff --git a/mpm/python/usrp_mpm/periph_manager/n3xx.py b/mpm/python/usrp_mpm/periph_manager/n3xx.py index 7a9f61df7..4e9406c81 100644 --- a/mpm/python/usrp_mpm/periph_manager/n3xx.py +++ b/mpm/python/usrp_mpm/periph_manager/n3xx.py @@ -519,7 +519,11 @@ class n3xx(ZynqComponents, PeriphManagerBase): if xport_type not in self._xport_mgrs: self.log.warning("Can't get link options for unknown link type: `{}'.".format(xport_type)) return [] - return self._xport_mgrs[xport_type].get_chdr_link_options() + if xport_type == "udp": + return self._xport_mgrs[xport_type].get_chdr_link_options( + self.mboard_info['rpc_connection']) + else: + return self._xport_mgrs[xport_type].get_chdr_link_options() ########################################################################### # Device info diff --git a/mpm/python/usrp_mpm/xports/xportmgr_udp.py b/mpm/python/usrp_mpm/xports/xportmgr_udp.py index 65228e5da..28c50688a 100644 --- a/mpm/python/usrp_mpm/xports/xportmgr_udp.py +++ b/mpm/python/usrp_mpm/xports/xportmgr_udp.py @@ -178,7 +178,7 @@ class XportMgrUDP: (x['ip_addr'] for x in itervalues(available_interfaces)) )) - def get_chdr_link_options(self): + def get_chdr_link_options(self, host_location = 'all'): """ Returns a list of dictionaries for returning by PeriphManagerBase.get_chdr_link_options(). @@ -186,6 +186,8 @@ class XportMgrUDP: Note: This requires a claim, which means that init() was called, and deinit() was not yet called. """ + assert host_location in ('remote', 'local', 'all') + return [ { 'ipv4': str(iface_info['ip_addr']) if (self.iface_config[iface_name]['type'] != 'internal') @@ -196,6 +198,10 @@ class XportMgrUDP: 'mtu': str(iface_info['mtu']) } for iface_name, iface_info in iteritems(self._chdr_ifaces) + if((self.iface_config[iface_name]['type'] == 'internal' and host_location == 'local') or + (self.iface_config[iface_name]['type'] != 'internal' and self.iface_config[iface_name]['type'] != 'forward' + and host_location == 'remote') or + host_location == 'all') ] def _setup_forwarding(self, iface): |