mpmd: Skip find if "resource" key is specified

MPM devices were being discovered when trying to locate PCIe connected
devices.  Adding filter to exclude them if the "resource" key is
specified in the device address arguments.

Replaces "lib: disable non pcie types in find with resource" to reduce
impact to older devices and remove API change.

Signed-off-by: michael-west <michael.west@ettus.com>
This commit is contained in:
michael-west 2021-02-06 14:34:19 -08:00 committed by Aaron Rossetto
parent 910db73c9a
commit 13f1dc28f1
9 changed files with 14 additions and 56 deletions

View File

@ -49,13 +49,6 @@ public:
*/
device_addr_t(const std::map<std::string, std::string>& info);
/*!
* Looks for any key that matches the prefix.
* \param prefix string to compare keys to
* \return a bool true if found else false
*/
bool has_key_with_prefix(const std::string& prefix) const;
/*!
* Convert a device address into a pretty print string.
* \return a printable string representing the device address

View File

@ -9,7 +9,6 @@
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
#include <boost/tokenizer.hpp>
#include <algorithm>
#include <regex>
#include <sstream>
#include <stdexcept>
@ -52,14 +51,6 @@ device_addr_t::device_addr_t(const std::map<std::string, std::string>& info)
}
}
bool device_addr_t::has_key_with_prefix(const std::string& prefix) const
{
auto dev_keys = this->keys();
return std::any_of(dev_keys.begin(), dev_keys.end(), [prefix](const auto& key) {
return key.substr(0, prefix.size()) == prefix;
});
}
std::string device_addr_t::to_pp_string(void) const
{
if (this->size() == 0)

View File

@ -44,15 +44,9 @@ static device_addrs_t b100_find(const device_addr_t& hint)
// Return an empty list of addresses when an address or resource is specified,
// since an address and resource is intended for a different, non-USB, device.
if (hint.has_key("addr"))
if (hint.has_key("addr") || hint.has_key("resource"))
return b100_addrs;
if (hint.has_key_with_prefix("resource")) {
UHD_LOG_TRACE(
"B100 FIND", "Returning early, PCIe is not supported with b100 devices.");
return b100_addrs;
}
uint16_t vid, pid;
if (hint.has_key("vid") && hint.has_key("pid") && hint.has_key("type")

View File

@ -182,14 +182,8 @@ static device_addrs_t b200_find(const device_addr_t& hint)
// Return an empty list of addresses when an address or resource is specified,
// since an address and resource is intended for a different, non-USB, device.
for (device_addr_t hint_i : separate_device_addr(hint)) {
if (hint_i.has_key("addr"))
if (hint_i.has_key("addr") || hint_i.has_key("resource"))
return b200_addrs;
if (hint.has_key_with_prefix("resource")) {
UHD_LOG_TRACE(
"B200 FIND", "Returning early, PCIe is not supported with b200 devices.");
return b200_addrs;
}
}
// Important note:

View File

@ -139,6 +139,9 @@ 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 (hint.has_key("resource")) {
continue;
}
if (not(hint.has_key(xport::FIRST_ADDR_KEY) or hint.has_key(MGMT_ADDR_KEY))) {
UHD_LOG_DEBUG("MPMD FIND", "No address given in hint " << hint.to_string());
continue;
@ -169,6 +172,9 @@ device_addrs_t mpmd_find_with_addrs(const device_addrs_t& hints)
device_addrs_t mpmd_find_with_bcast(const device_addr_t& hint)
{
device_addrs_t addrs;
if (hint.has_key("resource")) {
return addrs;
}
UHD_LOG_TRACE(
"MPMD FIND", "Broadcasting on all available interfaces to find MPM devices.");
std::vector<std::future<device_addrs_t>> task_list;
@ -224,12 +230,6 @@ device_addrs_t mpmd_find(const device_addr_t& hint_)
return {};
}
}
if (hint_.has_key_with_prefix("resource")) {
UHD_LOG_TRACE(
"MPMD FIND", "Returning early, PCIe is not support with mpm devices.");
return {};
}
UHD_LOG_TRACE("MPMD FIND", "Finding with " << hints.size() << " different hint(s).");
// Scenario 1): User gave us at least one address

View File

@ -47,15 +47,9 @@ static device_addrs_t usrp1_find(const device_addr_t& hint)
// Return an empty list of addresses when an address or resource is specified,
// since an address and resource is intended for a different, non-USB, device.
if (hint.has_key("addr"))
if (hint.has_key("addr") || hint.has_key("resource"))
return usrp1_addrs;
if (hint.has_key_with_prefix("resource")) {
UHD_LOG_TRACE(
"USRP1 FIND", "Returning early, PCIe is not supported with usrp1 devices.");
return usrp1_addrs;
}
uint16_t vid, pid;
if (hint.has_key("vid") && hint.has_key("pid") && hint.has_key("type")
@ -127,7 +121,7 @@ static device_addrs_t usrp1_find(const device_addr_t& hint)
// this is a found usrp1 when the hint serial and name match or blank
if ((not hint.has_key("name") or hint["name"] == new_addr["name"])
and (not hint.has_key("serial")
or hint["serial"] == new_addr["serial"])) {
or hint["serial"] == new_addr["serial"])) {
usrp1_addrs.push_back(new_addr);
}
}

View File

@ -68,11 +68,8 @@ device_addrs_t usrp2_find(const device_addr_t& hint_)
// Return an empty list of addresses when a resource is specified,
// since a resource is intended for a different, non-USB, device.
if (hint.has_key_with_prefix("resource")) {
UHD_LOG_TRACE(
"USRP2 FIND", "Returning early, PCIe is not supported with usrp2 devices.");
if (hint.has_key("resource"))
return usrp2_addrs;
}
// if no address was specified, send a broadcast on each interface
if (not hint.has_key("addr")) {

View File

@ -100,9 +100,7 @@ device_addrs_t x300_find(const device_addr_t& hint_)
return reply_addrs;
}
bool has_resource_key = hint.has_key_with_prefix("resource");
if (!has_resource_key) {
if (!hint.has_key("resource")) {
// otherwise, no address was specified, send a broadcast on each interface
for (const transport::if_addrs_t& if_addrs : transport::get_if_addrs()) {
// avoid the loopback device
@ -137,7 +135,7 @@ device_addrs_t x300_find(const device_addr_t& hint_)
}
}
device_addrs_t pcie_addrs = pcie_manager::find(hint, has_resource_key);
device_addrs_t pcie_addrs = pcie_manager::find(hint, hint.has_key("resource"));
if (not pcie_addrs.empty()) {
addrs.insert(addrs.end(), pcie_addrs.begin(), pcie_addrs.end());
}

View File

@ -71,11 +71,8 @@ device_addrs_t octoclock_find(const device_addr_t& hint)
// Return an empty list of addresses when a resource is specified,
// since a resource is intended for a different, non-USB, device.
if (hint.has_key_with_prefix("resource")) {
UHD_LOG_TRACE("OCTOCLOCK FIND",
"Returning early, PCIe is not supported with octoclock devices.");
if (hint.has_key("resource"))
return octoclock_addrs;
}
// If no address was specified, send a broadcast on each interface
if (not _hint.has_key("addr")) {