1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 Gaƫtan Rivet
6 #include <rte_bus_pci.h>
9 #include <rte_kvargs.h>
19 static const char * const pci_params_keys[] = {
20 [RTE_PCI_PARAM_ADDR] = "addr",
21 [RTE_PCI_PARAM_MAX] = NULL,
25 pci_addr_kv_cmp(const char *key __rte_unused,
29 struct rte_pci_addr _addr1;
30 struct rte_pci_addr *addr1 = &_addr1;
31 struct rte_pci_addr *addr2 = _addr2;
33 if (rte_pci_addr_parse(value, addr1))
35 return -abs(rte_pci_addr_cmp(addr1, addr2));
39 pci_dev_match(const struct rte_device *dev,
42 const struct rte_kvargs *kvlist = _kvlist;
43 const struct rte_pci_device *pdev;
46 /* Empty string matches everything. */
48 pdev = RTE_DEV_TO_PCI_CONST(dev);
49 /* if any field does not match. */
50 if (rte_kvargs_process(kvlist, pci_params_keys[RTE_PCI_PARAM_ADDR],
52 (void *)(intptr_t)&pdev->addr))
58 rte_pci_dev_iterate(const void *start,
60 const struct rte_dev_iterator *it __rte_unused)
62 rte_bus_find_device_t find_device;
63 struct rte_kvargs *kvargs = NULL;
64 struct rte_device *dev;
67 kvargs = rte_kvargs_parse(str, pci_params_keys);
69 RTE_LOG(ERR, EAL, "cannot parse argument list\n");
74 find_device = rte_pci_bus.bus.find_device;
75 dev = find_device(start, pci_dev_match, kvargs);
76 rte_kvargs_free(kvargs);