]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - drivers/net/vxge/vxge-main.c
vxge: check for card status before continuing in device close
[mirror_ubuntu-zesty-kernel.git] / drivers / net / vxge / vxge-main.c
index 6c838b3e063a6fc6905e1eb6b429d0472b12a2e9..dd2add1d7566c460599222ef157e8b0105ca5521 100644 (file)
@@ -1000,7 +1000,7 @@ vxge_xmit(struct sk_buff *skb, struct net_device *dev)
        VXGE_COMPLETE_VPATH_TX(fifo);
        vxge_debug_entryexit(VXGE_TRACE, "%s: %s:%d  Exiting...",
                dev->name, __func__, __LINE__);
-       return 0;
+       return NETDEV_TX_OK;
 
 _exit0:
        vxge_debug_tx(VXGE_TRACE, "%s: pci_map_page failed", dev->name);
@@ -1024,7 +1024,7 @@ _exit2:
        spin_unlock_irqrestore(&fifo->tx_lock, flags);
        VXGE_COMPLETE_VPATH_TX(fifo);
 
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 /*
@@ -2890,6 +2890,9 @@ int do_vxge_close(struct net_device *dev, int do_io)
        vdev = (struct vxgedev *)netdev_priv(dev);
        hldev = (struct __vxge_hw_device *) pci_get_drvdata(vdev->pdev);
 
+       if (unlikely(!is_vxge_card_up(vdev)))
+               return 0;
+
        /* If vxge_handle_crit_err task is executing,
         * wait till it completes. */
        while (test_and_set_bit(__VXGE_STATE_RESET_CARD, &vdev->state))
@@ -4152,18 +4155,6 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
                attr.bar0,
                (unsigned long long)pci_resource_start(pdev, 0));
 
-       attr.bar1 = pci_ioremap_bar(pdev, 2);
-       if (!attr.bar1) {
-               vxge_debug_init(VXGE_ERR,
-                       "%s : cannot remap io memory bar2", __func__);
-               ret = -ENODEV;
-               goto _exit3;
-       }
-       vxge_debug_ll_config(VXGE_TRACE,
-               "pci ioremap bar1: %p:0x%llx",
-               attr.bar1,
-               (unsigned long long)pci_resource_start(pdev, 2));
-
        status = vxge_hw_device_hw_info_get(attr.bar0,
                        &ll_config.device_hw_info);
        if (status != VXGE_HW_OK) {
@@ -4171,7 +4162,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
                        "%s: Reading of hardware info failed."
                        "Please try upgrading the firmware.", VXGE_DRIVER_NAME);
                ret = -EINVAL;
-               goto _exit4;
+               goto _exit3;
        }
 
        if (ll_config.device_hw_info.fw_version.major !=
@@ -4181,7 +4172,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
                        ll_config.device_hw_info.fw_version.major,
                        VXGE_DRIVER_VERSION_MAJOR);
                ret = -EINVAL;
-               goto _exit4;
+               goto _exit3;
        }
 
        vpath_mask = ll_config.device_hw_info.vpath_mask;
@@ -4189,7 +4180,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
                vxge_debug_ll_config(VXGE_TRACE,
                        "%s: No vpaths available in device", VXGE_DRIVER_NAME);
                ret = -EINVAL;
-               goto _exit4;
+               goto _exit3;
        }
 
        vxge_debug_ll_config(VXGE_TRACE,
@@ -4203,6 +4194,16 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
                max_vpath_supported++;
        }
 
+       /* Enable SRIOV mode, if firmware has SRIOV support and if it is a PF */
+       if ((VXGE_HW_FUNCTION_MODE_SRIOV ==
+               ll_config.device_hw_info.function_mode) &&
+               (max_config_dev > 1) && (pdev->is_physfn)) {
+                       ret = pci_enable_sriov(pdev, max_config_dev - 1);
+                       if (ret)
+                               vxge_debug_ll_config(VXGE_ERR,
+                                       "Failed to enable SRIOV: %d \n", ret);
+       }
+
        /*
         * Configure vpaths and get driver configured number of vpaths
         * which is less than or equal to the maximum vpaths per function.
@@ -4212,7 +4213,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
                vxge_debug_ll_config(VXGE_ERR,
                        "%s: No more vpaths to configure", VXGE_DRIVER_NAME);
                ret = 0;
-               goto _exit4;
+               goto _exit3;
        }
 
        /* Setting driver callbacks */
@@ -4225,7 +4226,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
                vxge_debug_init(VXGE_ERR,
                        "Failed to initialize device (%d)", status);
                        ret = -EINVAL;
-                       goto _exit4;
+                       goto _exit3;
        }
 
        vxge_hw_device_debug_set(hldev, VXGE_ERR, VXGE_COMPONENT_LL);
@@ -4250,7 +4251,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
        if (vxge_device_register(hldev, &ll_config, high_dma, no_of_vpath,
                &vdev)) {
                ret = -EINVAL;
-               goto _exit5;
+               goto _exit4;
        }
 
        vxge_hw_device_debug_set(hldev, VXGE_TRACE, VXGE_COMPONENT_LL);
@@ -4261,7 +4262,6 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
        hldev->ndev = vdev->ndev;
        vdev->mtu = VXGE_HW_DEFAULT_MTU;
        vdev->bar0 = attr.bar0;
-       vdev->bar1 = attr.bar1;
        vdev->max_vpath_supported = max_vpath_supported;
        vdev->no_of_vpath = no_of_vpath;
 
@@ -4343,7 +4343,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
                                "%s: mac_addr_list : memory allocation failed",
                                vdev->ndev->name);
                        ret = -EPERM;
-                       goto _exit6;
+                       goto _exit5;
                }
                macaddr = (u8 *)&entry->macaddr;
                memcpy(macaddr, vdev->ndev->dev_addr, ETH_ALEN);
@@ -4351,6 +4351,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
                vdev->vpaths[i].mac_addr_cnt = 1;
        }
 
+       kfree(device_config);
        vxge_debug_entryexit(VXGE_TRACE, "%s: %s:%d  Exiting...",
                vdev->ndev->name, __func__, __LINE__);
 
@@ -4360,15 +4361,14 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
 
        return 0;
 
-_exit6:
+_exit5:
        for (i = 0; i < vdev->no_of_vpath; i++)
                vxge_free_mac_add_list(&vdev->vpaths[i]);
 
        vxge_device_unregister(hldev);
-_exit5:
-       vxge_hw_device_terminate(hldev);
 _exit4:
-       iounmap(attr.bar1);
+       pci_disable_sriov(pdev);
+       vxge_hw_device_terminate(hldev);
 _exit3:
        iounmap(attr.bar0);
 _exit2:
@@ -4427,7 +4427,8 @@ vxge_remove(struct pci_dev *pdev)
        kfree(vdev->vpaths);
 
        iounmap(vdev->bar0);
-       iounmap(vdev->bar1);
+
+       pci_disable_sriov(pdev);
 
        /* we are safe to free it now */
        free_netdev(dev);