From: Adrien Mazarguil Date: Fri, 27 Feb 2015 18:27:00 +0000 (+0100) Subject: mlx4: avoid init errors when kernel modules are not loaded X-Git-Tag: spdx-start~9450 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=66e1591687ac;p=dpdk.git mlx4: avoid init errors when kernel modules are not loaded Mimic UIO/VFIO drivers behavior by not causing errors when a device cannot be initialized due to missing or mismatching kernel modules. Display helpful messages instead, such as: [...] EAL: PCI device 0000:83:00.0 on NUMA socket 1 EAL: probe driver: 15b3:1007 librte_pmd_mlx4 PMD: librte_pmd_mlx4: PCI information matches, using device "mlx4_0" (VF: false) PMD: librte_pmd_mlx4: cannot use device, are drivers up to date? EAL: PCI device 0000:84:00.0 on NUMA socket 1 EAL: probe driver: 15b3:1007 librte_pmd_mlx4 PMD: librte_pmd_mlx4: PCI information matches, using device "mlx4_1" (VF: false) PMD: librte_pmd_mlx4: cannot use device, are drivers up to date? EAL: No probed ethernet devices [...] Signed-off-by: Adrien Mazarguil --- diff --git a/lib/librte_pmd_mlx4/mlx4.c b/lib/librte_pmd_mlx4/mlx4.c index b5774c4801..3a45746418 100644 --- a/lib/librte_pmd_mlx4/mlx4.c +++ b/lib/librte_pmd_mlx4/mlx4.c @@ -4423,6 +4423,10 @@ mlx4_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) list = ibv_get_device_list(&i); if (list == NULL) { assert(errno); + if (errno == ENOSYS) { + WARN("cannot list devices, is ib_uverbs loaded?"); + return 0; + } return -errno; } assert(i >= 0); @@ -4451,9 +4455,15 @@ mlx4_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) break; } if (attr_ctx == NULL) { - if (err == 0) - err = ENODEV; ibv_free_device_list(list); + switch (err) { + case 0: + WARN("cannot access device, is mlx4_ib loaded?"); + return 0; + case EINVAL: + WARN("cannot use device, are drivers up to date?"); + return 0; + } assert(err > 0); return -err; }