@@ -333,7 +333,12 @@ test_pci(struct rte_bus *pci_bus, const char *dev_name, const char *name2)
pci_dev->bus = pci_bus;
- if (rte_cmp_dev_name(pci_dev, name2) != 0) {
+ struct rte_bus_address addr = {
+ .addr = name2,
+ .size = strlen(name2)
+ };
+
+ if (rte_cmp_dev_name(pci_dev, &addr) != 0) {
printf("rte_cmp_dev_name(%s, %s) device name (%s) not expected (%s)\n",
pci_dev->name, name2, pci_dev->name, name2);
return -1;
@@ -350,20 +355,30 @@ test_vdev(struct rte_bus *vdev_bus, const char *dev_name, const char *name2)
return -1;
}
- struct rte_device *vdev_dev = vdev_bus->find_device(NULL, rte_cmp_dev_name, dev_name);
+ struct rte_bus_address dev_addr = {
+ .addr = dev_name,
+ .size = strlen(dev_name)
+ };
+
+ struct rte_device *vdev_dev = vdev_bus->find_device(NULL, rte_cmp_dev_name, &dev_addr);
if (vdev_dev == NULL) {
printf("Cannot find %s vdev\n", dev_name);
rte_vdev_uninit(dev_name);
return -1;
}
- int ret = rte_cmp_dev_name(vdev_dev, name2);
+
+ struct rte_bus_address dev_addr2 = {
+ .addr = name2,
+ .size = strlen(name2)
+ };
+ int ret = rte_cmp_dev_name(vdev_dev, &dev_addr2);
if (ret != 0) {
printf("rte_cmp_dev_name(%s, %s) device name (%s) not expected (%s)\n",
vdev_dev->name, name2, vdev_dev->name, name2);
return -1;
}
- if (vdev_dev != vdev_bus->find_device(NULL, rte_cmp_dev_name, name2)) {
+ if (vdev_dev != vdev_bus->find_device(NULL, rte_cmp_dev_name, &dev_addr2)) {
printf("rte_cmp_dev_name(%s, %s) device name (%s) not expected (%s)\n",
vdev_dev->name, name2, vdev_dev->name, name2);
return -1;
@@ -21,9 +21,9 @@ static const char * const valid_keys[] = {
};
static int
-cmp_dev_match(const struct rte_device *dev, const void *_kvlist)
+cmp_dev_match(const struct rte_device *dev, const struct rte_bus_address *_kvlist)
{
- const struct rte_kvargs *kvlist = _kvlist;
+ const struct rte_kvargs *kvlist = _kvlist->addr;
const char *key = TEST_VDEV_KEY_NAME;
const char *name;
@@ -54,7 +54,11 @@ get_matching_vdev(const char *match_str)
}
}
- dev = vdev_bus->find_device(NULL, cmp_dev_match, kvargs);
+ struct rte_bus_address dev_addr = {
+ .addr = kvargs,
+ .size = sizeof(struct rte_kvargs),
+ };
+ dev = vdev_bus->find_device(NULL, cmp_dev_match, &dev_addr);
rte_kvargs_free(kvargs);
return dev;
@@ -76,7 +80,12 @@ test_vdev_bus(void)
printf("Failed to create vdev net_null_test0\n");
goto fail;
}
- dev0 = vdev_bus->find_device(NULL, rte_cmp_dev_name, "net_null_test0");
+
+ struct rte_bus_address dev0_addr = {
+ .addr = "net_null_test0",
+ .size = strlen("net_null_test0")
+ };
+ dev0 = vdev_bus->find_device(NULL, rte_cmp_dev_name, &dev0_addr);
if (dev0 == NULL) {
printf("Cannot find net_null_test0 vdev\n");
goto fail;
@@ -87,7 +96,11 @@ test_vdev_bus(void)
printf("Failed to create vdev net_null_test1\n");
goto fail;
}
- dev1 = vdev_bus->find_device(NULL, rte_cmp_dev_name, "net_null_test1");
+ struct rte_bus_address dev1_addr = {
+ .addr = "net_null_test1",
+ .size = strlen("net_null_test1")
+ };
+ dev1 = vdev_bus->find_device(NULL, rte_cmp_dev_name, &dev1_addr);
if (dev1 == NULL) {
printf("Cannot find net_null_test1 vdev\n");
goto fail;
@@ -300,7 +300,7 @@ rte_auxiliary_remove_device(struct rte_auxiliary_device *auxiliary_dev)
static struct rte_device *
auxiliary_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
- const void *data)
+ const struct rte_bus_address *data)
{
const struct rte_auxiliary_device *pstart;
struct rte_auxiliary_device *adev;
@@ -22,9 +22,9 @@ static const char * const auxiliary_params_keys[] = {
static int
auxiliary_dev_match(const struct rte_device *dev,
- const void *_kvlist)
+ const struct rte_bus_address *_kvlist)
{
- const struct rte_kvargs *kvlist = _kvlist;
+ const struct rte_kvargs *kvlist = _kvlist->addr;
const char *key = auxiliary_params_keys[RTE_AUXILIARY_PARAM_NAME];
const char *name;
@@ -59,7 +59,11 @@ auxiliary_dev_iterate(const void *start,
}
}
find_device = auxiliary_bus.bus.find_device;
- dev = find_device(start, auxiliary_dev_match, kvargs);
+ struct rte_bus_address dev_addr = {
+ .addr = kvargs,
+ .size = sizeof(struct rte_kvargs),
+ };
+ dev = find_device(start, auxiliary_dev_match, &dev_addr);
rte_kvargs_free(kvargs);
return dev;
}
@@ -500,7 +500,7 @@ rte_cdx_unregister(struct rte_cdx_driver *driver)
static struct rte_device *
cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
- const void *data)
+ const struct rte_bus_address *data)
{
const struct rte_cdx_device *cdx_start;
struct rte_cdx_device *cdx_dev;
@@ -613,9 +613,9 @@ cdx_get_iommu_class(void)
static int
cdx_dev_match(const struct rte_device *dev,
- const void *_kvlist)
+ const struct rte_bus_address *_kvlist)
{
- const struct rte_kvargs *kvlist = _kvlist;
+ const struct rte_kvargs *kvlist = _kvlist->addr;
const char *key = cdx_params_keys[RTE_CDX_PARAM_NAME];
const char *name;
@@ -649,7 +649,11 @@ cdx_dev_iterate(const void *start,
}
}
find_device = rte_cdx_bus.bus.find_device;
- dev = find_device(start, cdx_dev_match, kvargs);
+ struct rte_bus_address dev_addr = {
+ .addr = kvargs,
+ .size = sizeof(struct rte_kvargs),
+ };
+ dev = find_device(start, cdx_dev_match, &dev_addr);
rte_kvargs_free(kvargs);
return dev;
}
@@ -745,7 +745,7 @@ rte_dpaa_bus_probe(void)
static struct rte_device *
rte_dpaa_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
- const void *data)
+ const struct rte_bus_address *data)
{
struct rte_dpaa_device *dev;
const struct rte_dpaa_device *dstart;
@@ -497,7 +497,7 @@ rte_fslmc_probe(void)
static struct rte_device *
rte_fslmc_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
- const void *data)
+ const struct rte_bus_address *data)
{
const struct rte_dpaa2_device *dstart;
struct rte_dpaa2_device *dev;
@@ -443,7 +443,7 @@ ifpga_unplug(struct rte_device *dev)
static struct rte_device *
ifpga_find_device(const struct rte_device *start,
- rte_dev_cmp_t cmp, const void *data)
+ rte_dev_cmp_t cmp, const struct rte_bus_address *data)
{
struct rte_afu_device *afu_dev;
@@ -540,7 +540,7 @@ rte_pci_remove_device(struct rte_pci_device *pci_dev)
static struct rte_device *
pci_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
- const void *data)
+ const struct rte_bus_address *data)
{
const struct rte_pci_device *pstart;
struct rte_pci_device *pdev;
@@ -41,9 +41,9 @@ pci_addr_kv_cmp(const char *key __rte_unused,
static int
pci_dev_match(const struct rte_device *dev,
- const void *_kvlist)
+ const struct rte_bus_address *_kvlist)
{
- const struct rte_kvargs *kvlist = _kvlist;
+ const struct rte_kvargs *kvlist = _kvlist->addr;
const struct rte_pci_device *pdev;
if (kvlist == NULL)
@@ -76,7 +76,11 @@ rte_pci_dev_iterate(const void *start,
}
}
find_device = rte_pci_bus.bus.find_device;
- dev = find_device(start, pci_dev_match, kvargs);
+ struct rte_bus_address dev_addr = {
+ .addr = kvargs,
+ .size = sizeof(struct rte_kvargs),
+ };
+ dev = find_device(start, pci_dev_match, &dev_addr);
rte_kvargs_free(kvargs);
return dev;
}
@@ -473,7 +473,8 @@ platform_bus_probe(void)
}
static struct rte_device *
-platform_bus_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, const void *data)
+platform_bus_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
+ const struct rte_bus_address *data)
{
struct rte_platform_device *pdev;
@@ -27,10 +27,10 @@ static const char * const platform_params_keys[] = {
};
static int
-platform_dev_match(const struct rte_device *dev, const void *_kvlist)
+platform_dev_match(const struct rte_device *dev, const struct rte_bus_address *_kvlist)
{
const char *key = platform_params_keys[RTE_PLATFORM_PARAM_NAME];
- const struct rte_kvargs *kvlist = _kvlist;
+ const struct rte_kvargs *kvlist = _kvlist->addr;
const char *name;
/* no kvlist arg, all devices match */
@@ -68,7 +68,11 @@ platform_bus_dev_iterate(const void *start, const char *str,
return NULL;
}
- dev = platform_bus.bus.find_device(start, platform_dev_match, kvargs);
+ struct rte_bus_address dev_addr = {
+ .addr = kvargs,
+ .size = sizeof(struct rte_kvargs),
+ };
+ dev = platform_bus.bus.find_device(start, platform_dev_match, &dev_addr);
rte_kvargs_free(kvargs);
return dev;
@@ -508,7 +508,8 @@ uacce_unplug(struct rte_device *dev)
}
static struct rte_device *
-uacce_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, const void *data)
+uacce_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
+ const struct rte_bus_address *data)
{
const struct rte_uacce_device *uacce_start;
struct rte_uacce_device *uacce_dev;
@@ -549,10 +550,10 @@ uacce_parse(const char *name, void *addr, int addr_size, int *out_size)
}
static int
-uacce_dev_match(const struct rte_device *dev, const void *_kvlist)
+uacce_dev_match(const struct rte_device *dev, const struct rte_bus_address *_kvlist)
{
const char *key = uacce_params_keys[RTE_UACCE_PARAM_NAME];
- const struct rte_kvargs *kvlist = _kvlist;
+ const struct rte_kvargs *kvlist = _kvlist->addr;
const char *name;
/* no kvlist arg, all devices match. */
@@ -583,7 +584,11 @@ uacce_dev_iterate(const void *start, const char *str,
}
}
find_device = uacce_bus.bus.find_device;
- dev = find_device(start, uacce_dev_match, kvargs);
+ struct rte_bus_address dev_addr = {
+ .addr = kvargs,
+ .size = sizeof(struct rte_kvargs),
+ };
+ dev = find_device(start, uacce_dev_match, &dev_addr);
rte_kvargs_free(kvargs);
return dev;
}
@@ -621,7 +621,7 @@ vdev_cleanup(void)
struct rte_device *
rte_vdev_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
- const void *data)
+ const struct rte_bus_address *data)
{
const struct rte_vdev_device *vstart;
struct rte_vdev_device *dev;
@@ -24,9 +24,9 @@ static const char * const vdev_params_keys[] = {
static int
vdev_dev_match(const struct rte_device *dev,
- const void *_kvlist)
+ const struct rte_bus_address *_kvlist)
{
- const struct rte_kvargs *kvlist = _kvlist;
+ const struct rte_kvargs *kvlist = _kvlist->addr;
const char *key = vdev_params_keys[RTE_VDEV_PARAM_NAME];
const char *name;
@@ -58,7 +58,11 @@ rte_vdev_dev_iterate(const void *start,
return NULL;
}
}
- dev = rte_vdev_find_device(start, vdev_dev_match, kvargs);
+ struct rte_bus_address dev_addr = {
+ .addr = kvargs,
+ .size = sizeof(struct rte_kvargs),
+ };
+ dev = rte_vdev_find_device(start, vdev_dev_match, &dev_addr);
rte_kvargs_free(kvargs);
return dev;
}
@@ -14,7 +14,7 @@ extern "C" {
struct rte_device *
rte_vdev_find_device(const struct rte_device *start,
rte_dev_cmp_t cmp,
- const void *data);
+ const struct rte_bus_address *data);
void *
rte_vdev_dev_iterate(const void *start,
@@ -323,7 +323,7 @@ vmbus_remove_device(struct rte_vmbus_device *vmbus_dev)
/* VMBUS doesn't support hotplug */
static struct rte_device *
vmbus_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
- const void *data)
+ const struct rte_bus_address *data)
{
struct rte_vmbus_device *dev;
@@ -45,7 +45,7 @@ struct dsa_bus;
static int dsa_scan(void);
static int dsa_probe(void);
static struct rte_device *dsa_find_device(const struct rte_device *start,
- rte_dev_cmp_t cmp, const void *data);
+ rte_dev_cmp_t cmp, const struct rte_bus_address *data);
static enum rte_iova_mode dsa_get_iommu_class(void);
static int dsa_addr_parse(const char *name, void *addr, int addr_size, int *out_size);
@@ -366,7 +366,7 @@ dsa_scan(void)
static struct rte_device *
dsa_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
- const void *data)
+ const struct rte_bus_address *data)
{
struct rte_dsa_device *dev = TAILQ_FIRST(&dsa_bus.device_list);
@@ -23,15 +23,6 @@ const char *pmd_bond_init_valid_arguments[] = {
NULL
};
-static inline int
-bond_pci_addr_cmp(const struct rte_device *dev, const void *_pci_addr)
-{
- const struct rte_pci_device *pdev = RTE_DEV_TO_PCI_CONST(dev);
- const struct rte_pci_addr *paddr = _pci_addr;
-
- return rte_pci_addr_cmp(&pdev->addr, paddr);
-}
-
static inline int
find_port_id_by_pci_addr(const struct rte_pci_addr *pci_addr)
{
@@ -45,7 +36,11 @@ find_port_id_by_pci_addr(const struct rte_pci_addr *pci_addr)
return -1;
}
- dev = pci_bus->find_device(NULL, bond_pci_addr_cmp, pci_addr);
+ struct rte_bus_address dev_addr = {
+ .addr = pci_addr,
+ .size = PCI_PRI_STR_SIZE
+ };
+ dev = pci_bus->find_device(NULL, rte_cmp_dev_name, &dev_addr);
if (dev == NULL) {
RTE_BOND_LOG(ERR, "unable to find PCI device");
return -1;
@@ -771,7 +771,7 @@ RTE_PMD_REGISTER_PARAM_STRING(net_vdev_netvsc,
/** Compare function for vdev find device operation. */
static int
vdev_netvsc_cmp_rte_device(const struct rte_device *dev1,
- __rte_unused const void *_dev2)
+ __rte_unused const struct rte_bus_address *_dev2)
{
return strncmp(dev1->devargs->name, VDEV_NETVSC_DRIVER_NAME,
VDEV_NETVSC_DRIVER_NAME_LEN);
@@ -794,8 +794,12 @@ vdev_netvsc_scan_callback(__rte_unused void *arg)
VDEV_NETVSC_DRIVER_NAME_LEN))
return;
+ struct rte_bus_address dev_addr = {
+ .addr = VDEV_NETVSC_DRIVER_NAME,
+ .size = VDEV_NETVSC_DRIVER_NAME_LEN,
+ };
dev = vbus->find_device(NULL, vdev_netvsc_cmp_rte_device,
- VDEV_NETVSC_DRIVER_NAME);
+ &dev_addr);
if (dev)
return;
if (rte_devargs_add(RTE_DEVTYPE_VIRTUAL, VDEV_NETVSC_DRIVER_NAME))
@@ -1868,7 +1868,11 @@ ifpga_cfg_remove(struct rte_vdev_device *vdev)
args.port, args.bdf);
bus = rte_bus_find_by_name(RTE_STR(IFPGA_BUS_NAME));
if (bus) {
- if (bus->find_device(NULL, rte_cmp_dev_name, dev_name)) {
+ struct rte_bus_address dev_addr = {
+ .addr = dev_name,
+ .size = RTE_RAWDEV_NAME_MAX_LEN
+ };
+ if (bus->find_device(NULL, rte_cmp_dev_name, &dev_addr)) {
ret = rte_eal_hotplug_remove(RTE_STR(IFPGA_BUS_NAME),
dev_name);
}
@@ -159,9 +159,9 @@ rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp,
}
static int
-cmp_rte_device(const struct rte_device *dev1, const void *_dev2)
+cmp_rte_device(const struct rte_device *dev1, const struct rte_bus_address *_dev2)
{
- const struct rte_device *dev2 = _dev2;
+ const struct rte_device *dev2 = _dev2->addr;
return dev1 != dev2;
}
@@ -171,7 +171,11 @@ bus_find_device(const struct rte_bus *bus, const void *_dev)
{
struct rte_device *dev;
- dev = bus->find_device(NULL, cmp_rte_device, _dev);
+ struct rte_bus_address dev_addr = {
+ .addr = _dev,
+ .size = 0,
+ };
+ dev = bus->find_device(NULL, cmp_rte_device, &dev_addr);
return dev == NULL;
}
@@ -108,7 +108,7 @@ struct dev_next_ctx {
(((struct dev_next_ctx *)(intptr_t)ptr)->cls_str)
int
-rte_cmp_dev_name(const struct rte_device *dev1, const void *name2)
+rte_cmp_dev_name(const struct rte_device *dev1, const struct rte_bus_address *dev2_addr)
{
void *parsed_name1;
void *parsed_name2;
@@ -117,7 +117,7 @@ rte_cmp_dev_name(const struct rte_device *dev1, const void *name2)
int ret;
if (dev1->bus->parse(dev1->name, NULL, 0, &size1) != 0 ||
- dev1->bus->parse(name2, NULL, 0, &size2) != 0)
+ dev1->bus->parse(dev2_addr->addr, NULL, 0, &size2) != 0)
return 1;
if (size1 != size2)
@@ -137,7 +137,7 @@ rte_cmp_dev_name(const struct rte_device *dev1, const void *name2)
memset(parsed_name2, 0, size2);
dev1->bus->parse(dev1->name, parsed_name1, size1, NULL);
- dev1->bus->parse(name2, parsed_name2, size2, NULL);
+ dev1->bus->parse(dev2_addr->addr, parsed_name2, size2, NULL);
ret = memcmp(parsed_name1, parsed_name2, size1);
free(parsed_name1);
@@ -228,7 +228,11 @@ local_dev_probe(const char *devargs, struct rte_device **new_dev)
if (ret)
goto err_devarg;
- dev = da->bus->find_device(NULL, rte_cmp_dev_name, da->name);
+ struct rte_bus_address dev_addr = {
+ .addr = da->name,
+ .size = RTE_DEV_NAME_MAX_LEN
+ };
+ dev = da->bus->find_device(NULL, rte_cmp_dev_name, &dev_addr);
if (dev == NULL) {
EAL_LOG(ERR, "Cannot find device (%s)",
da->name);
@@ -366,7 +370,11 @@ rte_eal_hotplug_remove(const char *busname, const char *devname)
return -ENOENT;
}
- dev = bus->find_device(NULL, rte_cmp_dev_name, devname);
+ struct rte_bus_address dev_addr = {
+ .addr = devname,
+ .size = strlen(devname)
+ };
+ dev = bus->find_device(NULL, rte_cmp_dev_name, &dev_addr);
if (dev == NULL) {
EAL_LOG(ERR, "Cannot find plugged device (%s)", devname);
return -EINVAL;
@@ -128,7 +128,11 @@ __handle_secondary_request(void *param)
goto finish;
}
- dev = bus->find_device(NULL, rte_cmp_dev_name, da.name);
+ struct rte_bus_address dev_addr = {
+ .addr = da.name,
+ .size = RTE_DEV_NAME_MAX_LEN
+ };
+ dev = bus->find_device(NULL, rte_cmp_dev_name, &dev_addr);
if (dev == NULL) {
EAL_LOG(ERR, "Cannot find plugged device (%s)", da.name);
ret = -ENOENT;
@@ -255,7 +259,11 @@ static void __handle_primary_request(void *param)
goto quit;
}
- dev = bus->find_device(NULL, rte_cmp_dev_name, da->name);
+ struct rte_bus_address dev_addr = {
+ .addr = da->name,
+ .size = RTE_DEV_NAME_MAX_LEN
+ };
+ dev = bus->find_device(NULL, rte_cmp_dev_name, &dev_addr);
if (dev == NULL) {
EAL_LOG(ERR, "Cannot find plugged device (%s)", da->name);
ret = -ENOENT;
@@ -70,7 +70,7 @@ typedef int (*rte_bus_probe_t)(void);
*/
typedef struct rte_device *
(*rte_bus_find_device_t)(const struct rte_device *start, rte_dev_cmp_t cmp,
- const void *data);
+ const struct rte_bus_address *data);
/**
* Implementation specific probe function which is responsible for linking
@@ -171,19 +171,24 @@ int rte_dev_is_probed(const struct rte_device *dev);
int rte_eal_hotplug_add(const char *busname, const char *devname,
const char *drvargs);
+struct rte_bus_address {
+ const void *addr;
+ size_t size;
+};
+
/**
* General device name comparison. Will compare by using the specific bus
* compare function or by comparing the names directly.
*
* @param dev
* Device handle.
- * @param name
- * Name to compare against.
+ * @param addr
+ * Address to compare against.
* @return
- * 0 if the device matches the name. Nonzero otherwise.
+ * 0 if the device matches the address. Nonzero otherwise.
*/
__rte_internal
-int rte_cmp_dev_name(const struct rte_device *dev, const void *name);
+int rte_cmp_dev_name(const struct rte_device *dev, const struct rte_bus_address *addr);
/**
* Add matching devices.
@@ -245,7 +250,7 @@ int rte_dev_remove(struct rte_device *dev);
* <0 if ordering is possible and the device is lower than the data.
* >0 if ordering is possible and the device is greater than the data.
*/
-typedef int (*rte_dev_cmp_t)(const struct rte_device *dev, const void *data);
+typedef int (*rte_dev_cmp_t)(const struct rte_device *dev, const struct rte_bus_address *data);
#define RTE_PMD_EXPORT_NAME_ARRAY(n, idx) n##idx[]
@@ -272,8 +272,12 @@ dev_uev_handler(__rte_unused void *param)
goto failure_handle_err;
}
+ const struct rte_bus_address dev_addr = {
+ .addr = uevent.devname,
+ .size = strlen(uevent.devname)
+ };
dev = bus->find_device(NULL, rte_cmp_dev_name,
- uevent.devname);
+ &dev_addr);
if (dev == NULL) {
EAL_LOG(ERR, "Cannot find device (%s) on "
"bus (%s)", uevent.devname, busname);