[dpdk-dev] [PATCH 06/12] net/failsafe: add fail-safe PMD
Stephen Hemminger
stephen at networkplumber.org
Fri Mar 3 18:38:11 CET 2017
On Fri, 3 Mar 2017 16:40:28 +0100
Gaetan Rivet <gaetan.rivet at 6wind.com> wrote:
> +
> +static struct rte_eth_dev *
> +pci_addr_to_eth_dev(struct rte_pci_addr *addr)
> +{
> + uint8_t pid;
> +
> + if (addr == NULL)
> + return NULL;
> + for (pid = 0; pid < RTE_MAX_ETHPORTS; pid++) {
> + struct rte_pci_addr *addr2;
> + struct rte_eth_dev *edev;
> +
> + edev = &rte_eth_devices[pid];
> + if (edev->device == NULL ||
> + edev->device->devargs == NULL)
> + continue;
> + addr2 = &edev->device->devargs->pci.addr;
> + if (rte_eal_compare_pci_addr(addr, addr2) == 0)
> + return edev;
> + }
> + return NULL;
> +}
> +
> +static int
> +pci_scan_one(struct sub_device *sdev)
> +{
> + struct rte_devargs *da;
> + char dirname[PATH_MAX];
> +
> + da = &sdev->devargs;
> + snprintf(dirname, sizeof(dirname),
> + "%s/" PCI_PRI_FMT,
> + pci_get_sysfs_path(),
> + da->pci.addr.domain,
> + da->pci.addr.bus,
> + da->pci.addr.devid,
> + da->pci.addr.function);
> + errno = 0;
> + if (rte_eal_pci_parse_sysfs_entry(&sdev->pci_device,
> + dirname, &da->pci.addr) < 0) {
> + if (errno == ENOENT) {
> + DEBUG("Could not scan requested device " PCI_PRI_FMT,
> + da->pci.addr.domain,
> + da->pci.addr.bus,
> + da->pci.addr.devid,
> + da->pci.addr.function);
> + } else {
> + ERROR("Error while scanning sysfs entry %s",
> + dirname);
> + return -1;
> + }
> + } else {
> + sdev->state = DEV_SCANNED;
> + }
> + return 0;
> +}
This needs to be generic and in EAL.
A bigger problem is that it PCI specific and therefore won't work in environments
where devices are attached to different busses (SOC and Hyper-V).
Please rework to play well with bus model.
More information about the dev
mailing list