Merge branch 'upstream-16.11-stable' into 16.11.x
[deb_dpdk.git] / drivers / net / mlx5 / mlx5.c
index aa9d2dc..eb266b2 100644 (file)
@@ -422,17 +422,16 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                break;
        }
        if (attr_ctx == NULL) {
-               ibv_free_device_list(list);
                switch (err) {
                case 0:
                        ERROR("cannot access device, is mlx5_ib loaded?");
-                       return -ENODEV;
+                       err = ENODEV;
+                       break;
                case EINVAL:
                        ERROR("cannot use device, are drivers up to date?");
-                       return -EINVAL;
+                       break;
                }
-               assert(err > 0);
-               return -err;
+               goto error;
        }
        ibv_dev = list[i];
 
@@ -463,8 +462,10 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                DEBUG("using port %u (%08" PRIx32 ")", port, test);
 
                ctx = ibv_open_device(ibv_dev);
-               if (ctx == NULL)
+               if (ctx == NULL) {
+                       err = ENODEV;
                        goto port_error;
+               }
 
                /* Check port status. */
                err = ibv_query_port(ctx, port, &port_attr);
@@ -476,6 +477,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) {
                        ERROR("port %d is not configured in Ethernet mode",
                              port);
+                       err = EINVAL;
                        goto port_error;
                }
 
@@ -519,6 +521,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                }
                if (ibv_exp_query_device(ctx, &exp_device_attr)) {
                        ERROR("ibv_exp_query_device() failed");
+                       err = ENODEV;
                        goto port_error;
                }
 
@@ -581,6 +584,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                if (priv_get_mac(priv, &mac.addr_bytes)) {
                        ERROR("cannot get MAC address, is mlx5_en loaded?"
                              " (errno: %s)", strerror(errno));
+                       err = ENODEV;
                        goto port_error;
                }
                INFO("port %u MAC address is %02x:%02x:%02x:%02x:%02x:%02x",
@@ -680,6 +684,8 @@ port_error:
                        claim_zero(ibv_dealloc_pd(pd));
                if (ctx)
                        claim_zero(ibv_close_device(ctx));
+               if (eth_dev && rte_eal_process_type() == RTE_PROC_PRIMARY)
+                       rte_eth_dev_release_port(eth_dev);
                break;
        }