From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH 06/12] net/failsafe: add fail-safe PMD Date: Fri, 3 Mar 2017 09:38:11 -0800 Message-ID: <20170303093811.0e770367@xeon-e3> References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: Gaetan Rivet Return-path: Received: from mail-pg0-f52.google.com (mail-pg0-f52.google.com [74.125.83.52]) by dpdk.org (Postfix) with ESMTP id 125B8FA78 for ; Fri, 3 Mar 2017 18:38:19 +0100 (CET) Received: by mail-pg0-f52.google.com with SMTP id 25so46125564pgy.0 for ; Fri, 03 Mar 2017 09:38:18 -0800 (PST) In-Reply-To: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Fri, 3 Mar 2017 16:40:28 +0100 Gaetan Rivet 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.