aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAshish Chaudhari <ashish@ettus.com>2017-12-20 11:44:12 -0800
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:06:03 -0800
commit6af41376c18c62ca7bfe8cccdd6564922d3fdd6a (patch)
tree9a7fa7c759bdf9feefc0a4a20e18c7fbf8486607
parent2a83c6133f5541e6ffed34681cd6e8f5ff90fe76 (diff)
downloaduhd-6af41376c18c62ca7bfe8cccdd6564922d3fdd6a.tar.gz
uhd-6af41376c18c62ca7bfe8cccdd6564922d3fdd6a.tar.bz2
uhd-6af41376c18c62ca7bfe8cccdd6564922d3fdd6a.zip
mpmd: Device discovery fixes and cleanup
- Fixed issue where the "addr" device args was not honored - Results returned by find only enumerate mgmt_addrs - Explicitly require addr to be specified for RFNoC comms - Cleaned up constants for mgmt_addr, addr and second_addr Reviewed-by: Martin Braun <martin.braun@ettus.com>
-rw-r--r--host/lib/usrp/mpmd/mpmd_impl.cpp45
-rw-r--r--host/lib/usrp/mpmd/mpmd_xport_ctrl_udp.cpp10
-rw-r--r--host/lib/usrp/mpmd/mpmd_xport_mgr.cpp4
-rw-r--r--host/lib/usrp/mpmd/mpmd_xport_mgr.hpp11
4 files changed, 38 insertions, 32 deletions
diff --git a/host/lib/usrp/mpmd/mpmd_impl.cpp b/host/lib/usrp/mpmd/mpmd_impl.cpp
index 92f8039a4..c44cc2040 100644
--- a/host/lib/usrp/mpmd/mpmd_impl.cpp
+++ b/host/lib/usrp/mpmd/mpmd_impl.cpp
@@ -42,8 +42,6 @@ namespace {
//! MPM Compatibility number
const std::vector<size_t> MPM_COMPAT_NUM = {1, 0};
- const std::string MPMD_MGMT_ADDR_KEY = "mgmt_addr";
-
/*************************************************************************
* Helper functions
************************************************************************/
@@ -336,8 +334,7 @@ mpmd_mboard_impl::uptr mpmd_impl::setup_mb(
const size_t mb_index,
const uhd::device_addr_t& device_args
) {
- const std::string rpc_addr =
- device_args.get(MPMD_MGMT_ADDR_KEY, device_args.get("addr", ""));
+ const std::string rpc_addr = device_args.get(xport::MGMT_ADDR_KEY);
UHD_LOGGER_DEBUG("MPMD")
<< "Initializing mboard " << mb_index
<< ". Device args: `" << device_args.to_string()
@@ -482,20 +479,13 @@ size_t mpmd_impl::allocate_xbar_local_addr()
/*****************************************************************************
* Find, Factory & Registry
****************************************************************************/
-device_addrs_t mpmd_find_with_addr(const device_addr_t& hint_)
+device_addrs_t mpmd_find_with_addr(const std::string& mgmt_addr, const device_addr_t& hint_)
{
- device_addrs_t addrs;
- const std::string query_addr =
- hint_.get(MPMD_MGMT_ADDR_KEY, hint_.get("addr", ""));
- if (query_addr.empty()) {
- UHD_LOG_WARNING("MPMD FIND",
- "Was supposed to find with addr, but no addr was given (hint was: "
- << hint_.to_string() << ")");
- return addrs;
- }
+ UHD_ASSERT_THROW(not mgmt_addr.empty());
+ device_addrs_t addrs;
transport::udp_simple::sptr comm = transport::udp_simple::make_broadcast(
- query_addr, std::to_string(mpmd_impl::MPM_DISCOVERY_PORT));
+ mgmt_addr, std::to_string(mpmd_impl::MPM_DISCOVERY_PORT));
comm->send(
boost::asio::buffer(
mpmd_impl::MPM_DISCOVERY_CMD.c_str(),
@@ -540,11 +530,10 @@ device_addrs_t mpmd_find_with_addr(const device_addr_t& hint_)
if (external_iface) {
continue;
}
+
+ // Create result to return
device_addr_t new_addr;
- new_addr[MPMD_MGMT_ADDR_KEY] = recv_addr;
- if (not new_addr.has_key("addr")) {
- new_addr["addr"] = recv_addr;
- }
+ new_addr[xport::MGMT_ADDR_KEY] = recv_addr;
new_addr["type"] = "mpmd"; // hwd will overwrite this
// remove ident string and put other informations into device_args dict
result.erase(result.begin());
@@ -559,7 +548,7 @@ device_addrs_t mpmd_find_with_addr(const device_addr_t& hint_)
}
// filter the discovered device below by matching optional keys
if (
- (not hint_.has_key("name") or hint_["name"] == new_addr["name"])
+ (not hint_.has_key("name") or hint_["name"] == new_addr["name"])
and (not hint_.has_key("serial") or hint_["serial"] == new_addr["serial"])
and (not hint_.has_key("type") or hint_["type"] == new_addr["type"])
and (not hint_.has_key("product") or hint_["product"] == new_addr["product"])
@@ -585,12 +574,15 @@ device_addrs_t mpmd_find_with_addrs(const device_addrs_t& hints)
device_addrs_t found_devices;
found_devices.reserve(hints.size());
for (const auto& hint : hints) {
- if (not (hint.has_key("addr") or hint.has_key(MPMD_MGMT_ADDR_KEY))) {
+ if (not (hint.has_key(xport::FIRST_ADDR_KEY) or
+ hint.has_key(xport::MGMT_ADDR_KEY))) {
UHD_LOG_DEBUG("MPMD FIND",
"No address given in hint " << hint.to_string());
continue;
}
- device_addrs_t reply_addrs = mpmd_find_with_addr(hint);
+ const std::string mgmt_addr =
+ hint.get(xport::MGMT_ADDR_KEY, hint.get(xport::FIRST_ADDR_KEY, ""));
+ device_addrs_t reply_addrs = mpmd_find_with_addr(mgmt_addr, hint);
if (reply_addrs.size() > 1) {
UHD_LOG_ERROR("MPMD",
"Could not resolve device hint \"" << hint.to_string()
@@ -616,10 +608,7 @@ device_addrs_t mpmd_find_with_bcast(const device_addr_t& hint)
UHD_LOG_TRACE("MPMD FIND",
"Broadcasting on all available interfaces to find MPM devices.");
for (const transport::if_addrs_t& if_addr : transport::get_if_addrs()) {
- device_addr_t new_hint = hint;
- new_hint[MPMD_MGMT_ADDR_KEY] = if_addr.bcast;
-
- device_addrs_t reply_addrs = mpmd_find_with_addr(new_hint);
+ device_addrs_t reply_addrs = mpmd_find_with_addr(if_addr.bcast, hint);
addrs.insert(addrs.begin(), reply_addrs.begin(), reply_addrs.end());
}
return addrs;
@@ -649,8 +638,8 @@ device_addrs_t mpmd_find(const device_addr_t& hint_)
// Scenario 1): User gave us at least one address
if (not hints.empty() and
- (hints[0].has_key("addr") or
- hints[0].has_key(MPMD_MGMT_ADDR_KEY))) {
+ (hints[0].has_key(xport::FIRST_ADDR_KEY) or
+ hints[0].has_key(xport::MGMT_ADDR_KEY))) {
return mpmd_find_with_addrs(hints);
}
diff --git a/host/lib/usrp/mpmd/mpmd_xport_ctrl_udp.cpp b/host/lib/usrp/mpmd/mpmd_xport_ctrl_udp.cpp
index de4b3bbba..0da080724 100644
--- a/host/lib/usrp/mpmd/mpmd_xport_ctrl_udp.cpp
+++ b/host/lib/usrp/mpmd/mpmd_xport_ctrl_udp.cpp
@@ -26,9 +26,13 @@ namespace {
const uhd::device_addr_t& mb_args
) {
// mb_args must always include addr
- std::vector<std::string> addrs{mb_args["addr"]};
- if (mb_args.has_key("second_addr")){
- addrs.push_back(mb_args["second_addr"]);
+ if (not mb_args.has_key(FIRST_ADDR_KEY)) {
+ throw uhd::runtime_error("The " + FIRST_ADDR_KEY + " key must be specified in "
+ "device args to create an Ethernet transport to an RFNoC block");
+ }
+ 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]);
}
return addrs;
}
diff --git a/host/lib/usrp/mpmd/mpmd_xport_mgr.cpp b/host/lib/usrp/mpmd/mpmd_xport_mgr.cpp
index 0de832b34..0ca77c740 100644
--- a/host/lib/usrp/mpmd/mpmd_xport_mgr.cpp
+++ b/host/lib/usrp/mpmd/mpmd_xport_mgr.cpp
@@ -93,7 +93,9 @@ private:
}
}
- throw uhd::runtime_error("Could not select a transport option!");
+ throw uhd::runtime_error("Could not select a transport option! "
+ "Either a transport hint was not specified or the specified "
+ "hint does not support communication with RFNoC blocks.");
}
//! Create an instance of an xport manager implementation
diff --git a/host/lib/usrp/mpmd/mpmd_xport_mgr.hpp b/host/lib/usrp/mpmd/mpmd_xport_mgr.hpp
index 2da4af323..cdb082111 100644
--- a/host/lib/usrp/mpmd/mpmd_xport_mgr.hpp
+++ b/host/lib/usrp/mpmd/mpmd_xport_mgr.hpp
@@ -16,6 +16,17 @@
namespace uhd { namespace mpmd { namespace xport {
+/*
+ * Transport specifiers
+ */
+
+//! Ethernet address for management and RPC communication
+const std::string MGMT_ADDR_KEY = "mgmt_addr";
+//! Primary Ethernet address for streaming and RFNoC communication
+const std::string FIRST_ADDR_KEY = "addr";
+//! Secondary Ethernet address for streaming and RFNoC communication
+const std::string SECOND_ADDR_KEY = "second_addr";
+
/*! Return filtered subset from a device_addr_t
*
* The return dictionary will contain all key/value pairs from \p args