Commit 8a531400 authored by Jon Cooper's avatar Jon Cooper Committed by David S. Miller

sfc: harden driver against MC resets during initial probe

This is mainly to prepare for a future overlay networking patch that
 could cause an MC reset at probe time if the UDP tunnel port list is
 set immediately upon driver load.
Signed-off-by: default avatarEdward Cree <ecree@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent da50ae2e
...@@ -3136,6 +3136,51 @@ static int efx_pci_probe_main(struct efx_nic *efx) ...@@ -3136,6 +3136,51 @@ static int efx_pci_probe_main(struct efx_nic *efx)
return rc; return rc;
} }
static int efx_pci_probe_post_io(struct efx_nic *efx)
{
struct net_device *net_dev = efx->net_dev;
int rc = efx_pci_probe_main(efx);
if (rc)
return rc;
if (efx->type->sriov_init) {
rc = efx->type->sriov_init(efx);
if (rc)
netif_err(efx, probe, efx->net_dev,
"SR-IOV can't be enabled rc %d\n", rc);
}
/* Determine netdevice features */
net_dev->features |= (efx->type->offload_features | NETIF_F_SG |
NETIF_F_TSO | NETIF_F_RXCSUM);
if (efx->type->offload_features & (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM))
net_dev->features |= NETIF_F_TSO6;
/* Check whether device supports TSO */
if (!efx->type->tso_versions || !efx->type->tso_versions(efx))
net_dev->features &= ~NETIF_F_ALL_TSO;
/* Mask for features that also apply to VLAN devices */
net_dev->vlan_features |= (NETIF_F_HW_CSUM | NETIF_F_SG |
NETIF_F_HIGHDMA | NETIF_F_ALL_TSO |
NETIF_F_RXCSUM);
net_dev->hw_features = net_dev->features & ~efx->fixed_features;
/* Disable VLAN filtering by default. It may be enforced if
* the feature is fixed (i.e. VLAN filters are required to
* receive VLAN tagged packets due to vPort restrictions).
*/
net_dev->features &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
net_dev->features |= efx->fixed_features;
rc = efx_register_netdev(efx);
if (!rc)
return 0;
efx_pci_remove_main(efx);
return rc;
}
/* NIC initialisation /* NIC initialisation
* *
* This is called at module load (or hotplug insertion, * This is called at module load (or hotplug insertion,
...@@ -3178,41 +3223,27 @@ static int efx_pci_probe(struct pci_dev *pci_dev, ...@@ -3178,41 +3223,27 @@ static int efx_pci_probe(struct pci_dev *pci_dev,
if (rc) if (rc)
goto fail2; goto fail2;
rc = efx_pci_probe_main(efx); rc = efx_pci_probe_post_io(efx);
if (rc) if (rc) {
goto fail3; /* On failure, retry once immediately.
* If we aborted probe due to a scheduled reset, dismiss it.
net_dev->features |= (efx->type->offload_features | NETIF_F_SG |
NETIF_F_TSO | NETIF_F_RXCSUM);
if (efx->type->offload_features & (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM))
net_dev->features |= NETIF_F_TSO6;
/* Check whether device supports TSO */
if (!efx->type->tso_versions || !efx->type->tso_versions(efx))
net_dev->features &= ~NETIF_F_ALL_TSO;
/* Mask for features that also apply to VLAN devices */
net_dev->vlan_features |= (NETIF_F_HW_CSUM | NETIF_F_SG |
NETIF_F_HIGHDMA | NETIF_F_ALL_TSO |
NETIF_F_RXCSUM);
net_dev->hw_features = net_dev->features & ~efx->fixed_features;
/* Disable VLAN filtering by default. It may be enforced if
* the feature is fixed (i.e. VLAN filters are required to
* receive VLAN tagged packets due to vPort restrictions).
*/ */
net_dev->features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; efx->reset_pending = 0;
net_dev->features |= efx->fixed_features; rc = efx_pci_probe_post_io(efx);
if (rc) {
rc = efx_register_netdev(efx); /* On another failure, retry once more
if (rc) * after a 50-305ms delay.
goto fail4; */
unsigned char r;
if (efx->type->sriov_init) { get_random_bytes(&r, 1);
rc = efx->type->sriov_init(efx); msleep((unsigned int)r + 50);
if (rc) efx->reset_pending = 0;
netif_err(efx, probe, efx->net_dev, rc = efx_pci_probe_post_io(efx);
"SR-IOV can't be enabled rc %d\n", rc);
} }
}
if (rc)
goto fail3;
netif_dbg(efx, probe, efx->net_dev, "initialisation successful\n"); netif_dbg(efx, probe, efx->net_dev, "initialisation successful\n");
...@@ -3232,8 +3263,6 @@ static int efx_pci_probe(struct pci_dev *pci_dev, ...@@ -3232,8 +3263,6 @@ static int efx_pci_probe(struct pci_dev *pci_dev,
return 0; return 0;
fail4:
efx_pci_remove_main(efx);
fail3: fail3:
efx_fini_io(efx); efx_fini_io(efx);
fail2: fail2:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment