2019-06-04 08:11:33 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2008-04-27 11:55:59 +00:00
|
|
|
/****************************************************************************
|
2013-08-29 22:32:48 +00:00
|
|
|
* Driver for Solarflare network controllers and boards
|
2008-04-27 11:55:59 +00:00
|
|
|
* Copyright 2005-2006 Fen Systems Ltd.
|
2013-08-29 22:32:48 +00:00
|
|
|
* Copyright 2005-2013 Solarflare Communications Inc.
|
2008-04-27 11:55:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/notifier.h>
|
|
|
|
#include <linux/ip.h>
|
|
|
|
#include <linux/tcp.h>
|
|
|
|
#include <linux/in.h>
|
|
|
|
#include <linux/ethtool.h>
|
2008-07-18 18:03:10 +00:00
|
|
|
#include <linux/topology.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/gfp.h>
|
2013-01-14 17:20:22 +00:00
|
|
|
#include <linux/aer.h>
|
2013-03-21 16:41:43 +00:00
|
|
|
#include <linux/interrupt.h>
|
2008-04-27 11:55:59 +00:00
|
|
|
#include "net_driver.h"
|
2017-02-08 16:52:10 +00:00
|
|
|
#include <net/gre.h>
|
|
|
|
#include <net/udp_tunnel.h>
|
2008-04-27 11:55:59 +00:00
|
|
|
#include "efx.h"
|
2020-01-08 16:10:32 +00:00
|
|
|
#include "efx_common.h"
|
|
|
|
#include "efx_channels.h"
|
2020-07-27 11:55:55 +00:00
|
|
|
#include "ef100.h"
|
2020-01-08 16:10:32 +00:00
|
|
|
#include "rx_common.h"
|
|
|
|
#include "tx_common.h"
|
2009-11-29 15:12:08 +00:00
|
|
|
#include "nic.h"
|
2017-12-18 16:56:19 +00:00
|
|
|
#include "io.h"
|
2012-02-28 23:40:21 +00:00
|
|
|
#include "selftest.h"
|
2015-05-05 23:55:13 +00:00
|
|
|
#include "sriov.h"
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2009-11-29 15:15:41 +00:00
|
|
|
#include "mcdi.h"
|
2017-02-08 16:52:10 +00:00
|
|
|
#include "mcdi_pcol.h"
|
2010-06-01 11:17:51 +00:00
|
|
|
#include "workarounds.h"
|
2009-11-29 15:15:41 +00:00
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Configurable values
|
|
|
|
*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2020-07-02 16:28:13 +00:00
|
|
|
module_param_named(interrupt_mode, efx_interrupt_mode, uint, 0444);
|
|
|
|
MODULE_PARM_DESC(interrupt_mode,
|
|
|
|
"Interrupt mode (0=>MSIX 1=>MSI 2=>legacy)");
|
|
|
|
|
2020-07-02 16:29:09 +00:00
|
|
|
module_param(rss_cpus, uint, 0444);
|
|
|
|
MODULE_PARM_DESC(rss_cpus, "Number of CPUs to use for Receive-Side Scaling");
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
/*
|
|
|
|
* Use separate channels for TX and RX events
|
|
|
|
*
|
2008-12-13 05:41:06 +00:00
|
|
|
* Set this to 1 to use separate channels for TX and RX. It allows us
|
|
|
|
* to control interrupt affinity separately for TX and RX.
|
2008-04-27 11:55:59 +00:00
|
|
|
*
|
2008-12-13 05:41:06 +00:00
|
|
|
* This is only used in MSI-X interrupt mode
|
2008-04-27 11:55:59 +00:00
|
|
|
*/
|
2015-08-28 09:55:42 +00:00
|
|
|
bool efx_separate_tx_channels;
|
|
|
|
module_param(efx_separate_tx_channels, bool, 0444);
|
|
|
|
MODULE_PARM_DESC(efx_separate_tx_channels,
|
2008-12-13 05:41:06 +00:00
|
|
|
"Use separate channels for TX and RX");
|
2008-04-27 11:55:59 +00:00
|
|
|
|
|
|
|
/* Initial interrupt moderation settings. They can be modified after
|
|
|
|
* module load with ethtool.
|
|
|
|
*
|
|
|
|
* The default for RX should strike a balance between increasing the
|
|
|
|
* round-trip latency and reducing overhead.
|
|
|
|
*/
|
|
|
|
static unsigned int rx_irq_mod_usec = 60;
|
|
|
|
|
|
|
|
/* Initial interrupt moderation settings. They can be modified after
|
|
|
|
* module load with ethtool.
|
|
|
|
*
|
|
|
|
* This default is chosen to ensure that a 10G link does not go idle
|
|
|
|
* while a TX queue is stopped after it has become full. A queue is
|
|
|
|
* restarted when it drops below half full. The time this takes (assuming
|
|
|
|
* worst case 3 descriptors per packet and 1024 descriptors) is
|
|
|
|
* 512 / 3 * 1.2 = 205 usec.
|
|
|
|
*/
|
|
|
|
static unsigned int tx_irq_mod_usec = 150;
|
|
|
|
|
2012-11-28 04:12:41 +00:00
|
|
|
static bool phy_flash_cfg;
|
|
|
|
module_param(phy_flash_cfg, bool, 0644);
|
2008-12-13 05:34:54 +00:00
|
|
|
MODULE_PARM_DESC(phy_flash_cfg, "Set PHYs into reflash mode initially");
|
|
|
|
|
2010-06-23 11:30:07 +00:00
|
|
|
static unsigned debug = (NETIF_MSG_DRV | NETIF_MSG_PROBE |
|
|
|
|
NETIF_MSG_LINK | NETIF_MSG_IFDOWN |
|
|
|
|
NETIF_MSG_IFUP | NETIF_MSG_RX_ERR |
|
|
|
|
NETIF_MSG_TX_ERR | NETIF_MSG_HW);
|
|
|
|
module_param(debug, uint, 0);
|
|
|
|
MODULE_PARM_DESC(debug, "Bitmapped debugging message enable value");
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Utility functions and prototypes
|
|
|
|
*
|
|
|
|
*************************************************************************/
|
2010-09-10 06:42:33 +00:00
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
static void efx_remove_port(struct efx_nic *efx);
|
2019-10-31 10:23:37 +00:00
|
|
|
static int efx_xdp_setup_prog(struct efx_nic *efx, struct bpf_prog *prog);
|
|
|
|
static int efx_xdp(struct net_device *dev, struct netdev_bpf *xdp);
|
2019-10-31 10:24:12 +00:00
|
|
|
static int efx_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **xdpfs,
|
|
|
|
u32 flags);
|
2008-04-27 11:55:59 +00:00
|
|
|
|
|
|
|
#define EFX_ASSERT_RESET_SERIALISED(efx) \
|
|
|
|
do { \
|
2012-07-27 18:31:16 +00:00
|
|
|
if ((efx->state == STATE_READY) || \
|
2013-01-14 17:20:22 +00:00
|
|
|
(efx->state == STATE_RECOVERY) || \
|
2009-11-25 16:08:52 +00:00
|
|
|
(efx->state == STATE_DISABLED)) \
|
2008-04-27 11:55:59 +00:00
|
|
|
ASSERT_RTNL(); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Port handling
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
2009-03-04 09:52:52 +00:00
|
|
|
static void efx_fini_port(struct efx_nic *efx);
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
static int efx_probe_port(struct efx_nic *efx)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, probe, efx->net_dev, "create port\n");
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2009-12-23 13:46:36 +00:00
|
|
|
if (phy_flash_cfg)
|
|
|
|
efx->phy_mode = PHY_MODE_SPECIAL;
|
|
|
|
|
2009-11-29 03:42:31 +00:00
|
|
|
/* Connect up MAC/PHY operations table */
|
|
|
|
rc = efx->type->probe_port(efx);
|
2008-04-27 11:55:59 +00:00
|
|
|
if (rc)
|
2010-09-10 06:41:19 +00:00
|
|
|
return rc;
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2011-12-20 01:22:51 +00:00
|
|
|
/* Initialise MAC address to permanent address */
|
2014-03-07 18:27:41 +00:00
|
|
|
ether_addr_copy(efx->net_dev->dev_addr, efx->net_dev->perm_addr);
|
2008-04-27 11:55:59 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int efx_init_port(struct efx_nic *efx)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, drv, efx->net_dev, "init port\n");
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2009-11-25 16:11:19 +00:00
|
|
|
mutex_lock(&efx->mac_lock);
|
|
|
|
|
2008-12-13 05:50:08 +00:00
|
|
|
rc = efx->phy_op->init(efx);
|
2008-04-27 11:55:59 +00:00
|
|
|
if (rc)
|
2009-11-25 16:11:19 +00:00
|
|
|
goto fail1;
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2008-09-01 11:46:50 +00:00
|
|
|
efx->port_initialized = true;
|
2009-11-25 16:11:19 +00:00
|
|
|
|
2009-11-29 03:42:41 +00:00
|
|
|
/* Ensure the PHY advertises the correct flow control settings */
|
|
|
|
rc = efx->phy_op->reconfigure(efx);
|
sfc: Cope with permissions enforcement added to firmware for SR-IOV
* Accept EPERM in some simple cases, the following cases are handled:
1) efx_mcdi_read_assertion()
Unprivileged PCI functions aren't allowed to GET_ASSERTS.
We return success as it's up to the primary PF to deal with asserts.
2) efx_mcdi_mon_probe() in efx_ef10_probe()
Unprivileged PCI functions aren't allowed to read sensor info, and
worrying about sensor data is the primary PF's job.
3) phy_op->reconfigure() in efx_init_port() and efx_reset_up()
Unprivileged functions aren't allowed to MC_CMD_SET_LINK, they just have
to accept the settings (including flow-control, which is what
efx_init_port() is worried about) they've been given.
4) Fallback to GET_WORKAROUNDS in efx_ef10_probe()
Unprivileged PCI functions aren't allowed to set workarounds. So if
efx_mcdi_set_workaround() fails EPERM, use efx_mcdi_get_workarounds()
to find out if workaround_35388 is enabled.
5) If DRV_ATTACH gets EPERM, try without specifying fw-variant
Unprivileged PCI functions have to use a FIRMWARE_ID of 0xffffffff
(MC_CMD_FW_DONT_CARE).
6) Don't try to exit_assertion unless one had fired
Previously we called efx_mcdi_exit_assertion even if
efx_mcdi_read_assertion had received MC_CMD_GET_ASSERTS_FLAGS_NO_FAILS.
This is unnecessary, and the resulting MC_CMD_REBOOT, even if the
AFTER_ASSERTION flag made it a no-op, would fail EPERM for unprivileged
PCI functions.
So make efx_mcdi_read_assertion return whether an assert happened, and only
call efx_mcdi_exit_assertion if it has.
Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-05-05 23:59:18 +00:00
|
|
|
if (rc && rc != -EPERM)
|
2009-11-29 03:42:41 +00:00
|
|
|
goto fail2;
|
|
|
|
|
2009-11-25 16:11:19 +00:00
|
|
|
mutex_unlock(&efx->mac_lock);
|
2008-04-27 11:55:59 +00:00
|
|
|
return 0;
|
2008-12-13 05:50:08 +00:00
|
|
|
|
2009-11-25 16:11:19 +00:00
|
|
|
fail2:
|
2008-12-13 05:50:08 +00:00
|
|
|
efx->phy_op->fini(efx);
|
2009-11-25 16:11:19 +00:00
|
|
|
fail1:
|
|
|
|
mutex_unlock(&efx->mac_lock);
|
2008-12-13 05:50:08 +00:00
|
|
|
return rc;
|
2008-04-27 11:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void efx_fini_port(struct efx_nic *efx)
|
|
|
|
{
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, drv, efx->net_dev, "shut down port\n");
|
2008-04-27 11:55:59 +00:00
|
|
|
|
|
|
|
if (!efx->port_initialized)
|
|
|
|
return;
|
|
|
|
|
2008-12-13 05:50:08 +00:00
|
|
|
efx->phy_op->fini(efx);
|
2008-09-01 11:46:50 +00:00
|
|
|
efx->port_initialized = false;
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2009-11-23 16:06:30 +00:00
|
|
|
efx->link_state.up = false;
|
2008-04-27 11:55:59 +00:00
|
|
|
efx_link_status_changed(efx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void efx_remove_port(struct efx_nic *efx)
|
|
|
|
{
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, drv, efx->net_dev, "destroying port\n");
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2009-11-29 03:42:31 +00:00
|
|
|
efx->type->remove_port(efx);
|
2008-04-27 11:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* NIC handling
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
2013-10-18 18:21:45 +00:00
|
|
|
static LIST_HEAD(efx_primary_list);
|
|
|
|
static LIST_HEAD(efx_unassociated_list);
|
|
|
|
|
|
|
|
static bool efx_same_controller(struct efx_nic *left, struct efx_nic *right)
|
|
|
|
{
|
|
|
|
return left->type == right->type &&
|
|
|
|
left->vpd_sn && right->vpd_sn &&
|
|
|
|
!strcmp(left->vpd_sn, right->vpd_sn);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void efx_associate(struct efx_nic *efx)
|
|
|
|
{
|
|
|
|
struct efx_nic *other, *next;
|
|
|
|
|
|
|
|
if (efx->primary == efx) {
|
|
|
|
/* Adding primary function; look for secondaries */
|
|
|
|
|
|
|
|
netif_dbg(efx, probe, efx->net_dev, "adding to primary list\n");
|
|
|
|
list_add_tail(&efx->node, &efx_primary_list);
|
|
|
|
|
|
|
|
list_for_each_entry_safe(other, next, &efx_unassociated_list,
|
|
|
|
node) {
|
|
|
|
if (efx_same_controller(efx, other)) {
|
|
|
|
list_del(&other->node);
|
|
|
|
netif_dbg(other, probe, other->net_dev,
|
|
|
|
"moving to secondary list of %s %s\n",
|
|
|
|
pci_name(efx->pci_dev),
|
|
|
|
efx->net_dev->name);
|
|
|
|
list_add_tail(&other->node,
|
|
|
|
&efx->secondary_list);
|
|
|
|
other->primary = efx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Adding secondary function; look for primary */
|
|
|
|
|
|
|
|
list_for_each_entry(other, &efx_primary_list, node) {
|
|
|
|
if (efx_same_controller(efx, other)) {
|
|
|
|
netif_dbg(efx, probe, efx->net_dev,
|
|
|
|
"adding to secondary list of %s %s\n",
|
|
|
|
pci_name(other->pci_dev),
|
|
|
|
other->net_dev->name);
|
|
|
|
list_add_tail(&efx->node,
|
|
|
|
&other->secondary_list);
|
|
|
|
efx->primary = other;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
netif_dbg(efx, probe, efx->net_dev,
|
|
|
|
"adding to unassociated list\n");
|
|
|
|
list_add_tail(&efx->node, &efx_unassociated_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void efx_dissociate(struct efx_nic *efx)
|
|
|
|
{
|
|
|
|
struct efx_nic *other, *next;
|
|
|
|
|
|
|
|
list_del(&efx->node);
|
|
|
|
efx->primary = NULL;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(other, next, &efx->secondary_list, node) {
|
|
|
|
list_del(&other->node);
|
|
|
|
netif_dbg(other, probe, other->net_dev,
|
|
|
|
"moving to unassociated list\n");
|
|
|
|
list_add_tail(&other->node, &efx_unassociated_list);
|
|
|
|
other->primary = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
static int efx_probe_nic(struct efx_nic *efx)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, probe, efx->net_dev, "creating NIC\n");
|
2008-04-27 11:55:59 +00:00
|
|
|
|
|
|
|
/* Carry out hardware-type specific initialisation */
|
2009-11-29 03:42:31 +00:00
|
|
|
rc = efx->type->probe(efx);
|
2008-04-27 11:55:59 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2015-08-28 09:55:42 +00:00
|
|
|
do {
|
|
|
|
if (!efx->max_channels || !efx->max_tx_channels) {
|
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"Insufficient resources to allocate"
|
|
|
|
" any channels\n");
|
|
|
|
rc = -ENOSPC;
|
|
|
|
goto fail1;
|
|
|
|
}
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2015-08-28 09:55:42 +00:00
|
|
|
/* Determine the number of channels and queues by trying
|
|
|
|
* to hook in MSI-X interrupts.
|
|
|
|
*/
|
|
|
|
rc = efx_probe_interrupts(efx);
|
|
|
|
if (rc)
|
|
|
|
goto fail1;
|
2014-04-01 12:10:34 +00:00
|
|
|
|
2019-10-31 10:23:49 +00:00
|
|
|
rc = efx_set_channels(efx);
|
|
|
|
if (rc)
|
|
|
|
goto fail1;
|
2015-08-28 09:55:42 +00:00
|
|
|
|
|
|
|
/* dimension_resources can fail with EAGAIN */
|
|
|
|
rc = efx->type->dimension_resources(efx);
|
|
|
|
if (rc != 0 && rc != -EAGAIN)
|
|
|
|
goto fail2;
|
|
|
|
|
|
|
|
if (rc == -EAGAIN)
|
|
|
|
/* try again with new max_channels */
|
|
|
|
efx_remove_interrupts(efx);
|
|
|
|
|
|
|
|
} while (rc == -EAGAIN);
|
2012-02-15 01:58:49 +00:00
|
|
|
|
2010-06-25 07:05:43 +00:00
|
|
|
if (efx->n_channels > 1)
|
2018-03-08 15:45:17 +00:00
|
|
|
netdev_rss_key_fill(efx->rss_context.rx_hash_key,
|
|
|
|
sizeof(efx->rss_context.rx_hash_key));
|
|
|
|
efx_set_default_rx_indir_table(efx, &efx->rss_context);
|
2010-06-25 07:05:43 +00:00
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
/* Initialise the interrupt moderation settings */
|
2016-08-11 12:02:09 +00:00
|
|
|
efx->irq_mod_step_us = DIV_ROUND_UP(efx->timer_quantum_ns, 1000);
|
2011-09-05 07:43:04 +00:00
|
|
|
efx_init_irq_moderation(efx, tx_irq_mod_usec, rx_irq_mod_usec, true,
|
|
|
|
true);
|
2008-04-27 11:55:59 +00:00
|
|
|
|
|
|
|
return 0;
|
2011-01-05 00:50:41 +00:00
|
|
|
|
2013-08-28 23:45:48 +00:00
|
|
|
fail2:
|
|
|
|
efx_remove_interrupts(efx);
|
|
|
|
fail1:
|
2011-01-05 00:50:41 +00:00
|
|
|
efx->type->remove(efx);
|
|
|
|
return rc;
|
2008-04-27 11:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void efx_remove_nic(struct efx_nic *efx)
|
|
|
|
{
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, drv, efx->net_dev, "destroying NIC\n");
|
2008-04-27 11:55:59 +00:00
|
|
|
|
|
|
|
efx_remove_interrupts(efx);
|
2009-11-29 03:42:31 +00:00
|
|
|
efx->type->remove(efx);
|
2008-04-27 11:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* NIC startup/shutdown
|
|
|
|
*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
static int efx_probe_all(struct efx_nic *efx)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = efx_probe_nic(efx);
|
|
|
|
if (rc) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, probe, efx->net_dev, "failed to create NIC\n");
|
2008-04-27 11:55:59 +00:00
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = efx_probe_port(efx);
|
|
|
|
if (rc) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, probe, efx->net_dev, "failed to create port\n");
|
2008-04-27 11:55:59 +00:00
|
|
|
goto fail2;
|
|
|
|
}
|
|
|
|
|
2012-07-30 15:57:44 +00:00
|
|
|
BUILD_BUG_ON(EFX_DEFAULT_DMAQ_SIZE < EFX_RXQ_MIN_ENT);
|
|
|
|
if (WARN_ON(EFX_DEFAULT_DMAQ_SIZE < EFX_TXQ_MIN_ENT(efx))) {
|
|
|
|
rc = -EINVAL;
|
|
|
|
goto fail3;
|
|
|
|
}
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2015-05-05 23:57:34 +00:00
|
|
|
#ifdef CONFIG_SFC_SRIOV
|
|
|
|
rc = efx->type->vswitching_probe(efx);
|
|
|
|
if (rc) /* not fatal; the PF will still work fine */
|
|
|
|
netif_warn(efx, probe, efx->net_dev,
|
|
|
|
"failed to setup vswitching rc=%d;"
|
|
|
|
" VFs may not function\n", rc);
|
|
|
|
#endif
|
|
|
|
|
2010-09-20 08:43:07 +00:00
|
|
|
rc = efx_probe_filters(efx);
|
|
|
|
if (rc) {
|
|
|
|
netif_err(efx, probe, efx->net_dev,
|
|
|
|
"failed to create filter tables\n");
|
2015-05-05 23:57:34 +00:00
|
|
|
goto fail4;
|
2010-09-20 08:43:07 +00:00
|
|
|
}
|
|
|
|
|
2012-02-13 23:45:02 +00:00
|
|
|
rc = efx_probe_channels(efx);
|
|
|
|
if (rc)
|
2015-05-05 23:57:34 +00:00
|
|
|
goto fail5;
|
2012-02-13 23:45:02 +00:00
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
return 0;
|
|
|
|
|
2015-05-05 23:57:34 +00:00
|
|
|
fail5:
|
2012-02-13 23:45:02 +00:00
|
|
|
efx_remove_filters(efx);
|
2015-05-05 23:57:34 +00:00
|
|
|
fail4:
|
|
|
|
#ifdef CONFIG_SFC_SRIOV
|
|
|
|
efx->type->vswitching_remove(efx);
|
|
|
|
#endif
|
2008-04-27 11:55:59 +00:00
|
|
|
fail3:
|
|
|
|
efx_remove_port(efx);
|
|
|
|
fail2:
|
|
|
|
efx_remove_nic(efx);
|
|
|
|
fail1:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void efx_remove_all(struct efx_nic *efx)
|
|
|
|
{
|
2019-10-31 10:23:37 +00:00
|
|
|
rtnl_lock();
|
|
|
|
efx_xdp_setup_prog(efx, NULL);
|
|
|
|
rtnl_unlock();
|
|
|
|
|
2010-09-10 06:42:33 +00:00
|
|
|
efx_remove_channels(efx);
|
2012-02-13 23:45:02 +00:00
|
|
|
efx_remove_filters(efx);
|
2015-05-05 23:57:34 +00:00
|
|
|
#ifdef CONFIG_SFC_SRIOV
|
|
|
|
efx->type->vswitching_remove(efx);
|
|
|
|
#endif
|
2008-04-27 11:55:59 +00:00
|
|
|
efx_remove_port(efx);
|
|
|
|
efx_remove_nic(efx);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Interrupt moderation
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
2016-08-11 12:02:09 +00:00
|
|
|
unsigned int efx_usecs_to_ticks(struct efx_nic *efx, unsigned int usecs)
|
2009-10-23 08:32:13 +00:00
|
|
|
{
|
2011-09-05 07:41:44 +00:00
|
|
|
if (usecs == 0)
|
|
|
|
return 0;
|
2016-08-11 12:02:09 +00:00
|
|
|
if (usecs * 1000 < efx->timer_quantum_ns)
|
2009-10-23 08:32:13 +00:00
|
|
|
return 1; /* never round down to 0 */
|
2016-08-11 12:02:09 +00:00
|
|
|
return usecs * 1000 / efx->timer_quantum_ns;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int efx_ticks_to_usecs(struct efx_nic *efx, unsigned int ticks)
|
|
|
|
{
|
|
|
|
/* We must round up when converting ticks to microseconds
|
|
|
|
* because we round down when converting the other way.
|
|
|
|
*/
|
|
|
|
return DIV_ROUND_UP(ticks * efx->timer_quantum_ns, 1000);
|
2009-10-23 08:32:13 +00:00
|
|
|
}
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
/* Set interrupt moderation parameters */
|
2011-09-05 07:43:04 +00:00
|
|
|
int efx_init_irq_moderation(struct efx_nic *efx, unsigned int tx_usecs,
|
|
|
|
unsigned int rx_usecs, bool rx_adaptive,
|
|
|
|
bool rx_may_override_tx)
|
2008-04-27 11:55:59 +00:00
|
|
|
{
|
2010-09-10 06:41:47 +00:00
|
|
|
struct efx_channel *channel;
|
2016-08-11 12:02:36 +00:00
|
|
|
unsigned int timer_max_us;
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
EFX_ASSERT_RESET_SERIALISED(efx);
|
|
|
|
|
2016-08-11 12:02:36 +00:00
|
|
|
timer_max_us = efx->timer_max_ns / 1000;
|
|
|
|
|
|
|
|
if (tx_usecs > timer_max_us || rx_usecs > timer_max_us)
|
2011-09-05 07:43:04 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2016-08-11 12:02:09 +00:00
|
|
|
if (tx_usecs != rx_usecs && efx->tx_channel_offset == 0 &&
|
2011-09-05 07:43:04 +00:00
|
|
|
!rx_may_override_tx) {
|
|
|
|
netif_err(efx, drv, efx->net_dev, "Channels are shared. "
|
|
|
|
"RX and TX IRQ moderation must be equal\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2009-03-20 13:30:37 +00:00
|
|
|
efx->irq_rx_adaptive = rx_adaptive;
|
2016-08-11 12:02:09 +00:00
|
|
|
efx->irq_rx_moderation_us = rx_usecs;
|
2010-09-10 06:41:47 +00:00
|
|
|
efx_for_each_channel(channel, efx) {
|
2011-02-07 23:04:38 +00:00
|
|
|
if (efx_channel_has_rx_queue(channel))
|
2016-08-11 12:02:09 +00:00
|
|
|
channel->irq_moderation_us = rx_usecs;
|
2011-02-07 23:04:38 +00:00
|
|
|
else if (efx_channel_has_tx_queues(channel))
|
2016-08-11 12:02:09 +00:00
|
|
|
channel->irq_moderation_us = tx_usecs;
|
2019-10-31 10:23:49 +00:00
|
|
|
else if (efx_channel_is_xdp_tx(channel))
|
|
|
|
channel->irq_moderation_us = tx_usecs;
|
2010-09-10 06:41:47 +00:00
|
|
|
}
|
2011-09-05 07:43:04 +00:00
|
|
|
|
|
|
|
return 0;
|
2008-04-27 11:55:59 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 07:42:25 +00:00
|
|
|
void efx_get_irq_moderation(struct efx_nic *efx, unsigned int *tx_usecs,
|
|
|
|
unsigned int *rx_usecs, bool *rx_adaptive)
|
|
|
|
{
|
|
|
|
*rx_adaptive = efx->irq_rx_adaptive;
|
2016-08-11 12:02:09 +00:00
|
|
|
*rx_usecs = efx->irq_rx_moderation_us;
|
2011-09-05 07:42:25 +00:00
|
|
|
|
|
|
|
/* If channels are shared between RX and TX, so is IRQ
|
|
|
|
* moderation. Otherwise, IRQ moderation is the same for all
|
|
|
|
* TX channels and is not adaptive.
|
|
|
|
*/
|
2016-08-11 12:02:09 +00:00
|
|
|
if (efx->tx_channel_offset == 0) {
|
2011-09-05 07:42:25 +00:00
|
|
|
*tx_usecs = *rx_usecs;
|
2016-08-11 12:02:09 +00:00
|
|
|
} else {
|
|
|
|
struct efx_channel *tx_channel;
|
|
|
|
|
|
|
|
tx_channel = efx->channel[efx->tx_channel_offset];
|
|
|
|
*tx_usecs = tx_channel->irq_moderation_us;
|
|
|
|
}
|
2011-09-05 07:42:25 +00:00
|
|
|
}
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* ioctls
|
|
|
|
*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
/* Net device ioctl
|
|
|
|
* Context: process, rtnl_lock() held.
|
|
|
|
*/
|
|
|
|
static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
|
|
|
|
{
|
2008-09-01 11:43:14 +00:00
|
|
|
struct efx_nic *efx = netdev_priv(net_dev);
|
2009-04-29 08:05:08 +00:00
|
|
|
struct mii_ioctl_data *data = if_mii(ifr);
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2012-09-03 10:09:36 +00:00
|
|
|
if (cmd == SIOCSHWTSTAMP)
|
2013-11-14 01:26:21 +00:00
|
|
|
return efx_ptp_set_ts_config(efx, ifr);
|
|
|
|
if (cmd == SIOCGHWTSTAMP)
|
|
|
|
return efx_ptp_get_ts_config(efx, ifr);
|
2012-09-03 10:09:36 +00:00
|
|
|
|
2009-04-29 08:05:08 +00:00
|
|
|
/* Convert phy_id from older PRTAD/DEVAD format */
|
|
|
|
if ((cmd == SIOCGMIIREG || cmd == SIOCSMIIREG) &&
|
|
|
|
(data->phy_id & 0xfc00) == 0x0400)
|
|
|
|
data->phy_id ^= MDIO_PHY_ID_C45 | 0x0400;
|
|
|
|
|
|
|
|
return mdio_mii_ioctl(&efx->mdio, data, cmd);
|
2008-04-27 11:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Kernel net device interface
|
|
|
|
*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
/* Context: process, rtnl_lock() held. */
|
2015-05-20 10:11:03 +00:00
|
|
|
int efx_net_open(struct net_device *net_dev)
|
2008-04-27 11:55:59 +00:00
|
|
|
{
|
2008-09-01 11:43:14 +00:00
|
|
|
struct efx_nic *efx = netdev_priv(net_dev);
|
2012-07-27 19:46:41 +00:00
|
|
|
int rc;
|
|
|
|
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, ifup, efx->net_dev, "opening device on CPU %d\n",
|
|
|
|
raw_smp_processor_id());
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2012-07-27 19:46:41 +00:00
|
|
|
rc = efx_check_disabled(efx);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
2008-09-01 11:48:17 +00:00
|
|
|
if (efx->phy_mode & PHY_MODE_SPECIAL)
|
|
|
|
return -EBUSY;
|
2009-11-29 15:15:41 +00:00
|
|
|
if (efx_mcdi_poll_reboot(efx) && efx_reset(efx, RESET_TYPE_ALL))
|
|
|
|
return -EIO;
|
2008-09-01 11:48:17 +00:00
|
|
|
|
2009-11-29 03:43:00 +00:00
|
|
|
/* Notify the kernel of the link state polled during driver load,
|
|
|
|
* before the monitor starts running */
|
|
|
|
efx_link_status_changed(efx);
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
efx_start_all(efx);
|
2017-02-17 15:50:43 +00:00
|
|
|
if (efx->state == STATE_DISABLED || efx->reset_pending)
|
|
|
|
netif_device_detach(efx->net_dev);
|
2012-02-28 23:40:21 +00:00
|
|
|
efx_selftest_async_start(efx);
|
2008-04-27 11:55:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Context: process, rtnl_lock() held.
|
|
|
|
* Note that the kernel will ignore our return code; this method
|
|
|
|
* should really be a void.
|
|
|
|
*/
|
2015-05-20 10:11:03 +00:00
|
|
|
int efx_net_stop(struct net_device *net_dev)
|
2008-04-27 11:55:59 +00:00
|
|
|
{
|
2008-09-01 11:43:14 +00:00
|
|
|
struct efx_nic *efx = netdev_priv(net_dev);
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, ifdown, efx->net_dev, "closing on CPU %d\n",
|
|
|
|
raw_smp_processor_id());
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2012-07-27 19:46:41 +00:00
|
|
|
/* Stop the device and flush all the channels */
|
|
|
|
efx_stop_all(efx);
|
2008-04-27 11:55:59 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-06-15 16:48:32 +00:00
|
|
|
static int efx_vlan_rx_add_vid(struct net_device *net_dev, __be16 proto, u16 vid)
|
|
|
|
{
|
|
|
|
struct efx_nic *efx = netdev_priv(net_dev);
|
|
|
|
|
|
|
|
if (efx->type->vlan_rx_add_vid)
|
|
|
|
return efx->type->vlan_rx_add_vid(efx, proto, vid);
|
|
|
|
else
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int efx_vlan_rx_kill_vid(struct net_device *net_dev, __be16 proto, u16 vid)
|
|
|
|
{
|
|
|
|
struct efx_nic *efx = netdev_priv(net_dev);
|
|
|
|
|
|
|
|
if (efx->type->vlan_rx_kill_vid)
|
|
|
|
return efx->type->vlan_rx_kill_vid(efx, proto, vid);
|
|
|
|
else
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2015-05-05 23:55:13 +00:00
|
|
|
static const struct net_device_ops efx_netdev_ops = {
|
2008-11-22 01:32:54 +00:00
|
|
|
.ndo_open = efx_net_open,
|
|
|
|
.ndo_stop = efx_net_stop,
|
2010-06-08 07:21:12 +00:00
|
|
|
.ndo_get_stats64 = efx_net_stats,
|
2008-11-22 01:32:54 +00:00
|
|
|
.ndo_tx_timeout = efx_watchdog,
|
|
|
|
.ndo_start_xmit = efx_hard_start_xmit,
|
|
|
|
.ndo_validate_addr = eth_validate_addr,
|
|
|
|
.ndo_do_ioctl = efx_ioctl,
|
|
|
|
.ndo_change_mtu = efx_change_mtu,
|
|
|
|
.ndo_set_mac_address = efx_set_mac_address,
|
2012-01-09 19:54:44 +00:00
|
|
|
.ndo_set_rx_mode = efx_set_rx_mode,
|
2011-04-05 14:00:02 +00:00
|
|
|
.ndo_set_features = efx_set_features,
|
2016-06-15 16:48:32 +00:00
|
|
|
.ndo_vlan_rx_add_vid = efx_vlan_rx_add_vid,
|
|
|
|
.ndo_vlan_rx_kill_vid = efx_vlan_rx_kill_vid,
|
sfc: Add SR-IOV back-end support for SFC9000 family
On the SFC9000 family, each port has 1024 Virtual Interfaces (VIs),
each with an RX queue, a TX queue, an event queue and a mailbox
register. These may be assigned to up to 127 SR-IOV virtual functions
per port, with up to 64 VIs per VF.
We allocate an extra channel (IRQ and event queue only) to receive
requests from VF drivers.
There is a per-port limit of 4 concurrent RX queue flushes, and queue
flushes may be initiated by the MC in response to a Function Level
Reset (FLR) of a VF. Therefore, when SR-IOV is in use, we submit all
flush requests via the MC.
The RSS indirection table is shared with VFs, so the number of RX
queues used in the PF is limited to the number of VIs per VF.
This is almost entirely the work of Steve Hodgson, formerly
shodgson@solarflare.com.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-02-14 00:48:07 +00:00
|
|
|
#ifdef CONFIG_SFC_SRIOV
|
2015-05-05 23:55:13 +00:00
|
|
|
.ndo_set_vf_mac = efx_sriov_set_vf_mac,
|
|
|
|
.ndo_set_vf_vlan = efx_sriov_set_vf_vlan,
|
|
|
|
.ndo_set_vf_spoofchk = efx_sriov_set_vf_spoofchk,
|
|
|
|
.ndo_get_vf_config = efx_sriov_get_vf_config,
|
2015-05-20 10:12:13 +00:00
|
|
|
.ndo_set_vf_link_state = efx_sriov_set_vf_link_state,
|
sfc: Add SR-IOV back-end support for SFC9000 family
On the SFC9000 family, each port has 1024 Virtual Interfaces (VIs),
each with an RX queue, a TX queue, an event queue and a mailbox
register. These may be assigned to up to 127 SR-IOV virtual functions
per port, with up to 64 VIs per VF.
We allocate an extra channel (IRQ and event queue only) to receive
requests from VF drivers.
There is a per-port limit of 4 concurrent RX queue flushes, and queue
flushes may be initiated by the MC in response to a Function Level
Reset (FLR) of a VF. Therefore, when SR-IOV is in use, we submit all
flush requests via the MC.
The RSS indirection table is shared with VFs, so the number of RX
queues used in the PF is limited to the number of VIs per VF.
This is almost entirely the work of Steve Hodgson, formerly
shodgson@solarflare.com.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-02-14 00:48:07 +00:00
|
|
|
#endif
|
2017-01-10 16:23:33 +00:00
|
|
|
.ndo_get_phys_port_id = efx_get_phys_port_id,
|
2017-01-10 16:23:56 +00:00
|
|
|
.ndo_get_phys_port_name = efx_get_phys_port_name,
|
2011-01-10 21:18:20 +00:00
|
|
|
.ndo_setup_tc = efx_setup_tc,
|
2011-01-05 00:50:41 +00:00
|
|
|
#ifdef CONFIG_RFS_ACCEL
|
|
|
|
.ndo_rx_flow_steer = efx_filter_rfs,
|
|
|
|
#endif
|
sfc: convert to new udp_tunnel infrastructure
Check MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_TRUSTED, before setting
the info, which will hopefully protect us from -EPERM errors
the previous code was gracefully ignoring. Ed reports this
is not the 100% correct bit, but it's the best approximation
we have. Shared code reports the port information back to user
space, so we really want to know what was added and what failed.
Ignoring -EPERM is not an option.
The driver does not call udp_tunnel_get_rx_info(), so its own
management of table state is not really all that problematic,
we can leave it be. This allows the driver to continue with its
copious table syncing, and matching the ports to TX frames,
which it will reportedly do one day.
Leave the feature checking in the callbacks, as the device may
remove the capabilities on reset.
Inline the loop from __efx_ef10_udp_tnl_lookup_port() into
efx_ef10_udp_tnl_has_port(), since it's the only caller now.
With new infra this driver gains port replace - when space frees
up in a full table a new port will be selected for offload.
Plus efx will no longer sleep in an atomic context.
v2:
- amend the commit message about TRUSTED not being 100%
- add TUNNEL_ENCAP_UDP_PORT_ENTRY_INVALID to mark unsed
entries
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-By: Edward Cree <ecree@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-22 19:05:10 +00:00
|
|
|
.ndo_udp_tunnel_add = udp_tunnel_nic_add_port,
|
|
|
|
.ndo_udp_tunnel_del = udp_tunnel_nic_del_port,
|
2019-10-31 10:24:12 +00:00
|
|
|
.ndo_xdp_xmit = efx_xdp_xmit,
|
2019-10-31 10:23:37 +00:00
|
|
|
.ndo_bpf = efx_xdp
|
2008-11-22 01:32:54 +00:00
|
|
|
};
|
|
|
|
|
2019-10-31 10:23:37 +00:00
|
|
|
static int efx_xdp_setup_prog(struct efx_nic *efx, struct bpf_prog *prog)
|
|
|
|
{
|
|
|
|
struct bpf_prog *old_prog;
|
|
|
|
|
|
|
|
if (efx->xdp_rxq_info_failed) {
|
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"Unable to bind XDP program due to previous failure of rxq_info\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prog && efx->net_dev->mtu > efx_xdp_max_mtu(efx)) {
|
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"Unable to configure XDP with MTU of %d (max: %d)\n",
|
|
|
|
efx->net_dev->mtu, efx_xdp_max_mtu(efx));
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
old_prog = rtnl_dereference(efx->xdp_prog);
|
|
|
|
rcu_assign_pointer(efx->xdp_prog, prog);
|
|
|
|
/* Release the reference that was originally passed by the caller. */
|
|
|
|
if (old_prog)
|
|
|
|
bpf_prog_put(old_prog);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Context: process, rtnl_lock() held. */
|
|
|
|
static int efx_xdp(struct net_device *dev, struct netdev_bpf *xdp)
|
|
|
|
{
|
|
|
|
struct efx_nic *efx = netdev_priv(dev);
|
|
|
|
struct bpf_prog *xdp_prog;
|
|
|
|
|
|
|
|
switch (xdp->command) {
|
|
|
|
case XDP_SETUP_PROG:
|
|
|
|
return efx_xdp_setup_prog(efx, xdp->prog);
|
|
|
|
case XDP_QUERY_PROG:
|
|
|
|
xdp_prog = rtnl_dereference(efx->xdp_prog);
|
|
|
|
xdp->prog_id = xdp_prog ? xdp_prog->aux->id : 0;
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-31 10:24:12 +00:00
|
|
|
static int efx_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **xdpfs,
|
|
|
|
u32 flags)
|
|
|
|
{
|
|
|
|
struct efx_nic *efx = netdev_priv(dev);
|
|
|
|
|
|
|
|
if (!netif_running(dev))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return efx_xdp_tx_buffers(efx, n, xdpfs, flags & XDP_XMIT_FLUSH);
|
|
|
|
}
|
|
|
|
|
2008-12-13 06:09:38 +00:00
|
|
|
static void efx_update_name(struct efx_nic *efx)
|
|
|
|
{
|
|
|
|
strcpy(efx->name, efx->net_dev->name);
|
|
|
|
efx_mtd_rename(efx);
|
|
|
|
efx_set_channel_names(efx);
|
|
|
|
}
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
static int efx_netdev_event(struct notifier_block *this,
|
|
|
|
unsigned long event, void *ptr)
|
|
|
|
{
|
2013-05-28 01:30:21 +00:00
|
|
|
struct net_device *net_dev = netdev_notifier_info_to_dev(ptr);
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2015-05-05 23:55:13 +00:00
|
|
|
if ((net_dev->netdev_ops == &efx_netdev_ops) &&
|
2008-12-13 06:09:38 +00:00
|
|
|
event == NETDEV_CHANGENAME)
|
|
|
|
efx_update_name(netdev_priv(net_dev));
|
2008-04-27 11:55:59 +00:00
|
|
|
|
|
|
|
return NOTIFY_DONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct notifier_block efx_netdev_notifier = {
|
|
|
|
.notifier_call = efx_netdev_event,
|
|
|
|
};
|
|
|
|
|
2008-12-13 05:47:23 +00:00
|
|
|
static ssize_t
|
|
|
|
show_phy_type(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2019-07-24 11:26:58 +00:00
|
|
|
struct efx_nic *efx = dev_get_drvdata(dev);
|
2008-12-13 05:47:23 +00:00
|
|
|
return sprintf(buf, "%d\n", efx->phy_type);
|
|
|
|
}
|
2013-06-18 16:45:40 +00:00
|
|
|
static DEVICE_ATTR(phy_type, 0444, show_phy_type, NULL);
|
2008-12-13 05:47:23 +00:00
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
static int efx_register_netdev(struct efx_nic *efx)
|
|
|
|
{
|
|
|
|
struct net_device *net_dev = efx->net_dev;
|
2010-12-10 01:24:16 +00:00
|
|
|
struct efx_channel *channel;
|
2008-04-27 11:55:59 +00:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
net_dev->watchdog_timeo = 5 * HZ;
|
|
|
|
net_dev->irq = efx->pci_dev->irq;
|
2015-05-05 23:55:13 +00:00
|
|
|
net_dev->netdev_ops = &efx_netdev_ops;
|
|
|
|
if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0)
|
2013-08-29 18:19:29 +00:00
|
|
|
net_dev->priv_flags |= IFF_UNICAST_FLT;
|
2014-05-11 00:12:32 +00:00
|
|
|
net_dev->ethtool_ops = &efx_ethtool_ops;
|
2012-07-30 15:57:44 +00:00
|
|
|
net_dev->gso_max_segs = EFX_TSO_MAX_SEGS;
|
2016-10-18 16:47:45 +00:00
|
|
|
net_dev->min_mtu = EFX_MIN_MTU;
|
|
|
|
net_dev->max_mtu = EFX_MAX_MTU;
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2008-12-13 06:09:38 +00:00
|
|
|
rtnl_lock();
|
2009-08-26 08:16:27 +00:00
|
|
|
|
2012-07-27 19:50:52 +00:00
|
|
|
/* Enable resets to be scheduled and check whether any were
|
|
|
|
* already requested. If so, the NIC is probably hosed so we
|
|
|
|
* abort.
|
|
|
|
*/
|
|
|
|
efx->state = STATE_READY;
|
|
|
|
smp_mb(); /* ensure we change state before checking reset_pending */
|
|
|
|
if (efx->reset_pending) {
|
|
|
|
netif_err(efx, probe, efx->net_dev,
|
|
|
|
"aborting probe due to scheduled reset\n");
|
|
|
|
rc = -EIO;
|
|
|
|
goto fail_locked;
|
|
|
|
}
|
|
|
|
|
2009-08-26 08:16:27 +00:00
|
|
|
rc = dev_alloc_name(net_dev, net_dev->name);
|
|
|
|
if (rc < 0)
|
|
|
|
goto fail_locked;
|
2008-12-13 06:09:38 +00:00
|
|
|
efx_update_name(efx);
|
2009-08-26 08:16:27 +00:00
|
|
|
|
2012-08-24 17:04:38 +00:00
|
|
|
/* Always start with carrier off; PHY events will detect the link */
|
|
|
|
netif_carrier_off(net_dev);
|
|
|
|
|
2009-08-26 08:16:27 +00:00
|
|
|
rc = register_netdevice(net_dev);
|
|
|
|
if (rc)
|
|
|
|
goto fail_locked;
|
|
|
|
|
2010-12-10 01:24:16 +00:00
|
|
|
efx_for_each_channel(channel, efx) {
|
|
|
|
struct efx_tx_queue *tx_queue;
|
2011-01-12 18:39:40 +00:00
|
|
|
efx_for_each_channel_tx_queue(tx_queue, channel)
|
|
|
|
efx_init_tx_queue_core_txq(tx_queue);
|
2010-12-10 01:24:16 +00:00
|
|
|
}
|
|
|
|
|
2013-10-18 18:21:45 +00:00
|
|
|
efx_associate(efx);
|
|
|
|
|
2008-12-13 06:09:38 +00:00
|
|
|
rtnl_unlock();
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2008-12-13 05:47:23 +00:00
|
|
|
rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_type);
|
|
|
|
if (rc) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"failed to init net dev attributes\n");
|
2008-12-13 05:47:23 +00:00
|
|
|
goto fail_registered;
|
|
|
|
}
|
2020-01-09 15:45:45 +00:00
|
|
|
|
|
|
|
efx_init_mcdi_logging(efx);
|
2008-12-13 05:47:23 +00:00
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
return 0;
|
2008-12-13 05:47:23 +00:00
|
|
|
|
2012-07-27 19:50:52 +00:00
|
|
|
fail_registered:
|
|
|
|
rtnl_lock();
|
2013-10-18 18:21:45 +00:00
|
|
|
efx_dissociate(efx);
|
2012-07-27 19:50:52 +00:00
|
|
|
unregister_netdevice(net_dev);
|
2009-08-26 08:16:27 +00:00
|
|
|
fail_locked:
|
2012-07-27 19:50:52 +00:00
|
|
|
efx->state = STATE_UNINIT;
|
2009-08-26 08:16:27 +00:00
|
|
|
rtnl_unlock();
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev, "could not register net dev\n");
|
2009-08-26 08:16:27 +00:00
|
|
|
return rc;
|
2008-04-27 11:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void efx_unregister_netdev(struct efx_nic *efx)
|
|
|
|
{
|
|
|
|
if (!efx->net_dev)
|
|
|
|
return;
|
|
|
|
|
2008-09-01 11:43:14 +00:00
|
|
|
BUG_ON(netdev_priv(efx->net_dev) != efx);
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2015-05-27 12:14:01 +00:00
|
|
|
if (efx_dev_registered(efx)) {
|
|
|
|
strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name));
|
2020-01-09 15:45:45 +00:00
|
|
|
efx_fini_mcdi_logging(efx);
|
2015-05-27 12:14:01 +00:00
|
|
|
device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type);
|
|
|
|
unregister_netdev(efx->net_dev);
|
|
|
|
}
|
2008-04-27 11:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* List of NICs we support
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/* PCI device ID table */
|
2014-08-08 13:56:03 +00:00
|
|
|
static const struct pci_device_id efx_pci_table[] = {
|
2011-12-02 18:23:56 +00:00
|
|
|
{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0803), /* SFC9020 */
|
2009-11-29 15:15:41 +00:00
|
|
|
.driver_data = (unsigned long) &siena_a0_nic_type},
|
2011-12-02 18:23:56 +00:00
|
|
|
{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0813), /* SFL9021 */
|
2009-11-29 15:15:41 +00:00
|
|
|
.driver_data = (unsigned long) &siena_a0_nic_type},
|
2013-08-29 18:19:29 +00:00
|
|
|
{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0903), /* SFC9120 PF */
|
|
|
|
.driver_data = (unsigned long) &efx_hunt_a0_nic_type},
|
2015-05-06 00:00:07 +00:00
|
|
|
{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x1903), /* SFC9120 VF */
|
|
|
|
.driver_data = (unsigned long) &efx_hunt_a0_vf_nic_type},
|
2014-07-14 07:38:49 +00:00
|
|
|
{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0923), /* SFC9140 PF */
|
|
|
|
.driver_data = (unsigned long) &efx_hunt_a0_nic_type},
|
2015-11-30 09:05:47 +00:00
|
|
|
{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x1923), /* SFC9140 VF */
|
|
|
|
.driver_data = (unsigned long) &efx_hunt_a0_vf_nic_type},
|
|
|
|
{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0a03), /* SFC9220 PF */
|
|
|
|
.driver_data = (unsigned long) &efx_hunt_a0_nic_type},
|
|
|
|
{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x1a03), /* SFC9220 VF */
|
|
|
|
.driver_data = (unsigned long) &efx_hunt_a0_vf_nic_type},
|
2017-12-18 16:56:34 +00:00
|
|
|
{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x0b03), /* SFC9250 PF */
|
|
|
|
.driver_data = (unsigned long) &efx_hunt_a0_nic_type},
|
|
|
|
{PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x1b03), /* SFC9250 VF */
|
|
|
|
.driver_data = (unsigned long) &efx_hunt_a0_vf_nic_type},
|
2008-04-27 11:55:59 +00:00
|
|
|
{0} /* end of list */
|
|
|
|
};
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Data housekeeping
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
2014-07-15 10:58:12 +00:00
|
|
|
void efx_update_sw_stats(struct efx_nic *efx, u64 *stats)
|
|
|
|
{
|
|
|
|
u64 n_rx_nodesc_trunc = 0;
|
|
|
|
struct efx_channel *channel;
|
|
|
|
|
|
|
|
efx_for_each_channel(channel, efx)
|
|
|
|
n_rx_nodesc_trunc += channel->n_rx_nodesc_trunc;
|
|
|
|
stats[GENERIC_STAT_rx_nodesc_trunc] = n_rx_nodesc_trunc;
|
|
|
|
stats[GENERIC_STAT_rx_noskb_drops] = atomic_read(&efx->n_rx_noskb_drops);
|
|
|
|
}
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* PCI interface
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/* Main body of final NIC shutdown code
|
|
|
|
* This is called only at module unload (or hotplug removal).
|
|
|
|
*/
|
|
|
|
static void efx_pci_remove_main(struct efx_nic *efx)
|
|
|
|
{
|
2012-07-27 19:50:52 +00:00
|
|
|
/* Flush reset_work. It can no longer be scheduled since we
|
|
|
|
* are not READY.
|
|
|
|
*/
|
|
|
|
BUG_ON(efx->state == STATE_READY);
|
2020-01-08 16:10:59 +00:00
|
|
|
efx_flush_reset_workqueue(efx);
|
2012-07-27 19:50:52 +00:00
|
|
|
|
2012-10-05 22:35:41 +00:00
|
|
|
efx_disable_interrupts(efx);
|
2018-04-19 16:37:25 +00:00
|
|
|
efx_clear_interrupt_affinity(efx);
|
2009-11-29 03:43:56 +00:00
|
|
|
efx_nic_fini_interrupt(efx);
|
2008-04-27 11:55:59 +00:00
|
|
|
efx_fini_port(efx);
|
2009-11-29 03:42:31 +00:00
|
|
|
efx->type->fini(efx);
|
2008-04-27 11:55:59 +00:00
|
|
|
efx_fini_napi(efx);
|
|
|
|
efx_remove_all(efx);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Final NIC shutdown
|
2015-06-02 10:40:46 +00:00
|
|
|
* This is called only at module unload (or hotplug removal). A PF can call
|
|
|
|
* this on its VFs to ensure they are unbound first.
|
2008-04-27 11:55:59 +00:00
|
|
|
*/
|
|
|
|
static void efx_pci_remove(struct pci_dev *pci_dev)
|
|
|
|
{
|
|
|
|
struct efx_nic *efx;
|
|
|
|
|
|
|
|
efx = pci_get_drvdata(pci_dev);
|
|
|
|
if (!efx)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Mark the NIC as fini, then stop the interface */
|
|
|
|
rtnl_lock();
|
2013-10-18 18:21:45 +00:00
|
|
|
efx_dissociate(efx);
|
2008-04-27 11:55:59 +00:00
|
|
|
dev_close(efx->net_dev);
|
2012-10-05 22:35:41 +00:00
|
|
|
efx_disable_interrupts(efx);
|
2015-06-15 17:27:54 +00:00
|
|
|
efx->state = STATE_UNINIT;
|
2008-04-27 11:55:59 +00:00
|
|
|
rtnl_unlock();
|
|
|
|
|
2015-05-05 23:55:13 +00:00
|
|
|
if (efx->type->sriov_fini)
|
|
|
|
efx->type->sriov_fini(efx);
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
efx_unregister_netdev(efx);
|
|
|
|
|
2008-12-13 06:09:38 +00:00
|
|
|
efx_mtd_remove(efx);
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
efx_pci_remove_main(efx);
|
|
|
|
|
2020-06-29 13:35:33 +00:00
|
|
|
efx_fini_io(efx);
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, drv, efx->net_dev, "shutdown successful\n");
|
2008-04-27 11:55:59 +00:00
|
|
|
|
|
|
|
efx_fini_struct(efx);
|
|
|
|
free_netdev(efx->net_dev);
|
2013-01-14 17:20:22 +00:00
|
|
|
|
|
|
|
pci_disable_pcie_error_reporting(pci_dev);
|
2008-04-27 11:55:59 +00:00
|
|
|
};
|
|
|
|
|
2012-03-05 15:35:39 +00:00
|
|
|
/* NIC VPD information
|
|
|
|
* Called during probe to display the part number of the
|
|
|
|
* installed NIC. VPD is potentially very large but this should
|
|
|
|
* always appear within the first 512 bytes.
|
|
|
|
*/
|
|
|
|
#define SFC_VPD_LEN 512
|
2013-12-05 20:13:22 +00:00
|
|
|
static void efx_probe_vpd_strings(struct efx_nic *efx)
|
2012-03-05 15:35:39 +00:00
|
|
|
{
|
|
|
|
struct pci_dev *dev = efx->pci_dev;
|
|
|
|
char vpd_data[SFC_VPD_LEN];
|
|
|
|
ssize_t vpd_size;
|
2013-12-05 20:13:22 +00:00
|
|
|
int ro_start, ro_size, i, j;
|
2012-03-05 15:35:39 +00:00
|
|
|
|
|
|
|
/* Get the vpd data from the device */
|
|
|
|
vpd_size = pci_read_vpd(dev, 0, sizeof(vpd_data), vpd_data);
|
|
|
|
if (vpd_size <= 0) {
|
|
|
|
netif_err(efx, drv, efx->net_dev, "Unable to read VPD\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the Read only section */
|
2013-12-05 20:13:22 +00:00
|
|
|
ro_start = pci_vpd_find_tag(vpd_data, 0, vpd_size, PCI_VPD_LRDT_RO_DATA);
|
|
|
|
if (ro_start < 0) {
|
2012-03-05 15:35:39 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev, "VPD Read-only not found\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-05 20:13:22 +00:00
|
|
|
ro_size = pci_vpd_lrdt_size(&vpd_data[ro_start]);
|
|
|
|
j = ro_size;
|
|
|
|
i = ro_start + PCI_VPD_LRDT_TAG_SIZE;
|
2012-03-05 15:35:39 +00:00
|
|
|
if (i + j > vpd_size)
|
|
|
|
j = vpd_size - i;
|
|
|
|
|
|
|
|
/* Get the Part number */
|
|
|
|
i = pci_vpd_find_info_keyword(vpd_data, i, j, "PN");
|
|
|
|
if (i < 0) {
|
|
|
|
netif_err(efx, drv, efx->net_dev, "Part number not found\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
j = pci_vpd_info_field_size(&vpd_data[i]);
|
|
|
|
i += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
|
|
if (i + j > vpd_size) {
|
|
|
|
netif_err(efx, drv, efx->net_dev, "Incomplete part number\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
netif_info(efx, drv, efx->net_dev,
|
|
|
|
"Part Number : %.*s\n", j, &vpd_data[i]);
|
2013-12-05 20:13:22 +00:00
|
|
|
|
|
|
|
i = ro_start + PCI_VPD_LRDT_TAG_SIZE;
|
|
|
|
j = ro_size;
|
|
|
|
i = pci_vpd_find_info_keyword(vpd_data, i, j, "SN");
|
|
|
|
if (i < 0) {
|
|
|
|
netif_err(efx, drv, efx->net_dev, "Serial number not found\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
j = pci_vpd_info_field_size(&vpd_data[i]);
|
|
|
|
i += PCI_VPD_INFO_FLD_HDR_SIZE;
|
|
|
|
if (i + j > vpd_size) {
|
|
|
|
netif_err(efx, drv, efx->net_dev, "Incomplete serial number\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
efx->vpd_sn = kmalloc(j + 1, GFP_KERNEL);
|
|
|
|
if (!efx->vpd_sn)
|
|
|
|
return;
|
|
|
|
|
|
|
|
snprintf(efx->vpd_sn, j + 1, "%s", &vpd_data[i]);
|
2012-03-05 15:35:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
/* Main body of NIC initialisation
|
|
|
|
* This is called at module load (or hotplug insertion, theoretically).
|
|
|
|
*/
|
|
|
|
static int efx_pci_probe_main(struct efx_nic *efx)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* Do start-of-day initialisation */
|
|
|
|
rc = efx_probe_all(efx);
|
|
|
|
if (rc)
|
|
|
|
goto fail1;
|
|
|
|
|
2010-12-07 19:47:34 +00:00
|
|
|
efx_init_napi(efx);
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2018-07-11 10:45:10 +00:00
|
|
|
down_write(&efx->filter_sem);
|
2009-11-29 03:42:31 +00:00
|
|
|
rc = efx->type->init(efx);
|
2018-07-11 10:45:10 +00:00
|
|
|
up_write(&efx->filter_sem);
|
2008-04-27 11:55:59 +00:00
|
|
|
if (rc) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, probe, efx->net_dev,
|
|
|
|
"failed to initialise NIC\n");
|
2009-11-23 16:05:12 +00:00
|
|
|
goto fail3;
|
2008-04-27 11:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rc = efx_init_port(efx);
|
|
|
|
if (rc) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, probe, efx->net_dev,
|
|
|
|
"failed to initialise port\n");
|
2009-11-23 16:05:12 +00:00
|
|
|
goto fail4;
|
2008-04-27 11:55:59 +00:00
|
|
|
}
|
|
|
|
|
2009-11-29 03:43:56 +00:00
|
|
|
rc = efx_nic_init_interrupt(efx);
|
2008-04-27 11:55:59 +00:00
|
|
|
if (rc)
|
2009-11-23 16:05:12 +00:00
|
|
|
goto fail5;
|
2018-04-19 16:37:25 +00:00
|
|
|
|
|
|
|
efx_set_interrupt_affinity(efx);
|
2013-04-15 17:51:54 +00:00
|
|
|
rc = efx_enable_interrupts(efx);
|
|
|
|
if (rc)
|
|
|
|
goto fail6;
|
2008-04-27 11:55:59 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2013-04-15 17:51:54 +00:00
|
|
|
fail6:
|
2018-04-19 16:37:25 +00:00
|
|
|
efx_clear_interrupt_affinity(efx);
|
2013-04-15 17:51:54 +00:00
|
|
|
efx_nic_fini_interrupt(efx);
|
2009-11-23 16:05:12 +00:00
|
|
|
fail5:
|
2008-04-27 11:55:59 +00:00
|
|
|
efx_fini_port(efx);
|
|
|
|
fail4:
|
2009-11-29 03:42:31 +00:00
|
|
|
efx->type->fini(efx);
|
2008-04-27 11:55:59 +00:00
|
|
|
fail3:
|
|
|
|
efx_fini_napi(efx);
|
|
|
|
efx_remove_all(efx);
|
|
|
|
fail1:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2017-02-08 16:51:18 +00:00
|
|
|
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 |
|
2017-10-31 14:29:47 +00:00
|
|
|
NETIF_F_TSO | NETIF_F_RXCSUM | NETIF_F_RXALL);
|
2017-02-08 16:51:18 +00:00
|
|
|
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);
|
|
|
|
|
2017-10-31 14:29:47 +00:00
|
|
|
net_dev->hw_features |= net_dev->features & ~efx->fixed_features;
|
|
|
|
|
|
|
|
/* Disable receiving frames with bad FCS, by default. */
|
|
|
|
net_dev->features &= ~NETIF_F_RXALL;
|
2017-02-08 16:51:18 +00:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
/* NIC initialisation
|
|
|
|
*
|
|
|
|
* This is called at module load (or hotplug insertion,
|
2012-01-09 19:47:08 +00:00
|
|
|
* theoretically). It sets up PCI mappings, resets the NIC,
|
2008-04-27 11:55:59 +00:00
|
|
|
* sets up and registers the network devices with the kernel and hooks
|
|
|
|
* the interrupt service routine. It does not prepare the device for
|
|
|
|
* transmission; this is left to the first time one of the network
|
|
|
|
* interfaces is brought up (i.e. efx_net_open).
|
|
|
|
*/
|
2012-12-03 14:23:32 +00:00
|
|
|
static int efx_pci_probe(struct pci_dev *pci_dev,
|
2012-12-06 14:30:56 +00:00
|
|
|
const struct pci_device_id *entry)
|
2008-04-27 11:55:59 +00:00
|
|
|
{
|
|
|
|
struct net_device *net_dev;
|
|
|
|
struct efx_nic *efx;
|
2011-11-19 00:35:47 +00:00
|
|
|
int rc;
|
2008-04-27 11:55:59 +00:00
|
|
|
|
|
|
|
/* Allocate and initialise a struct net_device and struct efx_nic */
|
2011-01-10 21:18:20 +00:00
|
|
|
net_dev = alloc_etherdev_mqs(sizeof(*efx), EFX_MAX_CORE_TX_QUEUES,
|
|
|
|
EFX_MAX_RX_QUEUES);
|
2008-04-27 11:55:59 +00:00
|
|
|
if (!net_dev)
|
|
|
|
return -ENOMEM;
|
2012-08-02 00:39:38 +00:00
|
|
|
efx = netdev_priv(net_dev);
|
|
|
|
efx->type = (const struct efx_nic_type *) entry->driver_data;
|
2016-06-15 16:43:20 +00:00
|
|
|
efx->fixed_features |= NETIF_F_HIGHDMA;
|
2016-06-15 16:51:36 +00:00
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
pci_set_drvdata(pci_dev, efx);
|
2010-06-23 11:30:07 +00:00
|
|
|
SET_NETDEV_DEV(net_dev, &pci_dev->dev);
|
2012-08-02 00:39:38 +00:00
|
|
|
rc = efx_init_struct(efx, pci_dev, net_dev);
|
2008-04-27 11:55:59 +00:00
|
|
|
if (rc)
|
|
|
|
goto fail1;
|
|
|
|
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_info(efx, probe, efx->net_dev,
|
2011-07-13 15:21:24 +00:00
|
|
|
"Solarflare NIC detected\n");
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2015-05-06 00:00:07 +00:00
|
|
|
if (!efx->type->is_vf)
|
|
|
|
efx_probe_vpd_strings(efx);
|
2012-03-05 15:35:39 +00:00
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
/* Set up basic I/O (BAR mappings etc) */
|
2020-01-08 16:10:45 +00:00
|
|
|
rc = efx_init_io(efx, efx->type->mem_bar(efx), efx->type->max_dma_mask,
|
|
|
|
efx->type->mem_map_size(efx));
|
2008-04-27 11:55:59 +00:00
|
|
|
if (rc)
|
|
|
|
goto fail2;
|
|
|
|
|
2017-02-08 16:51:18 +00:00
|
|
|
rc = efx_pci_probe_post_io(efx);
|
|
|
|
if (rc) {
|
|
|
|
/* On failure, retry once immediately.
|
|
|
|
* If we aborted probe due to a scheduled reset, dismiss it.
|
|
|
|
*/
|
|
|
|
efx->reset_pending = 0;
|
|
|
|
rc = efx_pci_probe_post_io(efx);
|
|
|
|
if (rc) {
|
|
|
|
/* On another failure, retry once more
|
|
|
|
* after a 50-305ms delay.
|
|
|
|
*/
|
|
|
|
unsigned char r;
|
|
|
|
|
|
|
|
get_random_bytes(&r, 1);
|
|
|
|
msleep((unsigned int)r + 50);
|
|
|
|
efx->reset_pending = 0;
|
|
|
|
rc = efx_pci_probe_post_io(efx);
|
|
|
|
}
|
|
|
|
}
|
2011-11-19 00:35:47 +00:00
|
|
|
if (rc)
|
|
|
|
goto fail3;
|
2008-04-27 11:55:59 +00:00
|
|
|
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, probe, efx->net_dev, "initialisation successful\n");
|
2009-10-23 08:33:09 +00:00
|
|
|
|
2012-01-27 17:23:58 +00:00
|
|
|
/* Try to create MTDs, but allow this to fail */
|
2009-10-23 08:33:09 +00:00
|
|
|
rtnl_lock();
|
2012-01-27 17:23:58 +00:00
|
|
|
rc = efx_mtd_probe(efx);
|
2009-10-23 08:33:09 +00:00
|
|
|
rtnl_unlock();
|
2015-12-23 08:58:15 +00:00
|
|
|
if (rc && rc != -EPERM)
|
2012-01-27 17:23:58 +00:00
|
|
|
netif_warn(efx, probe, efx->net_dev,
|
|
|
|
"failed to create MTDs (%d)\n", rc);
|
|
|
|
|
2019-07-08 11:07:11 +00:00
|
|
|
(void)pci_enable_pcie_error_reporting(pci_dev);
|
2013-01-14 17:20:22 +00:00
|
|
|
|
2017-02-08 16:52:10 +00:00
|
|
|
if (efx->type->udp_tnl_push_ports)
|
|
|
|
efx->type->udp_tnl_push_ports(efx);
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail3:
|
2020-06-29 13:35:33 +00:00
|
|
|
efx_fini_io(efx);
|
2008-04-27 11:55:59 +00:00
|
|
|
fail2:
|
|
|
|
efx_fini_struct(efx);
|
|
|
|
fail1:
|
2010-02-12 20:32:27 +00:00
|
|
|
WARN_ON(rc > 0);
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, drv, efx->net_dev, "initialisation failed. rc=%d\n", rc);
|
2008-04-27 11:55:59 +00:00
|
|
|
free_netdev(net_dev);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2015-05-05 23:55:58 +00:00
|
|
|
/* efx_pci_sriov_configure returns the actual number of Virtual Functions
|
|
|
|
* enabled on success
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_SFC_SRIOV
|
|
|
|
static int efx_pci_sriov_configure(struct pci_dev *dev, int num_vfs)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
struct efx_nic *efx = pci_get_drvdata(dev);
|
|
|
|
|
|
|
|
if (efx->type->sriov_configure) {
|
|
|
|
rc = efx->type->sriov_configure(efx, num_vfs);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
else
|
|
|
|
return num_vfs;
|
|
|
|
} else
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-11-29 03:43:07 +00:00
|
|
|
static int efx_pm_freeze(struct device *dev)
|
|
|
|
{
|
2019-07-24 11:26:58 +00:00
|
|
|
struct efx_nic *efx = dev_get_drvdata(dev);
|
2009-11-29 03:43:07 +00:00
|
|
|
|
2012-07-27 18:35:39 +00:00
|
|
|
rtnl_lock();
|
|
|
|
|
2012-07-27 18:35:47 +00:00
|
|
|
if (efx->state != STATE_DISABLED) {
|
|
|
|
efx->state = STATE_UNINIT;
|
2009-11-29 03:43:07 +00:00
|
|
|
|
2012-10-17 12:21:23 +00:00
|
|
|
efx_device_detach_sync(efx);
|
2009-11-29 03:43:07 +00:00
|
|
|
|
2012-07-27 18:35:47 +00:00
|
|
|
efx_stop_all(efx);
|
2012-10-05 22:35:41 +00:00
|
|
|
efx_disable_interrupts(efx);
|
2012-07-27 18:35:47 +00:00
|
|
|
}
|
2009-11-29 03:43:07 +00:00
|
|
|
|
2012-07-27 18:35:39 +00:00
|
|
|
rtnl_unlock();
|
|
|
|
|
2009-11-29 03:43:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int efx_pm_thaw(struct device *dev)
|
|
|
|
{
|
2013-04-15 17:51:54 +00:00
|
|
|
int rc;
|
2019-07-24 11:26:58 +00:00
|
|
|
struct efx_nic *efx = dev_get_drvdata(dev);
|
2009-11-29 03:43:07 +00:00
|
|
|
|
2012-07-27 18:35:39 +00:00
|
|
|
rtnl_lock();
|
|
|
|
|
2012-07-27 18:35:47 +00:00
|
|
|
if (efx->state != STATE_DISABLED) {
|
2013-04-15 17:51:54 +00:00
|
|
|
rc = efx_enable_interrupts(efx);
|
|
|
|
if (rc)
|
|
|
|
goto fail;
|
2009-11-29 03:43:07 +00:00
|
|
|
|
2012-07-27 18:35:47 +00:00
|
|
|
mutex_lock(&efx->mac_lock);
|
|
|
|
efx->phy_op->reconfigure(efx);
|
|
|
|
mutex_unlock(&efx->mac_lock);
|
2009-11-29 03:43:07 +00:00
|
|
|
|
2012-07-27 18:35:47 +00:00
|
|
|
efx_start_all(efx);
|
2009-11-29 03:43:07 +00:00
|
|
|
|
2017-02-17 15:50:43 +00:00
|
|
|
efx_device_attach_if_not_resetting(efx);
|
2009-11-29 03:43:07 +00:00
|
|
|
|
2012-07-27 18:35:47 +00:00
|
|
|
efx->state = STATE_READY;
|
2009-11-29 03:43:07 +00:00
|
|
|
|
2012-07-27 18:35:47 +00:00
|
|
|
efx->type->resume_wol(efx);
|
|
|
|
}
|
2009-11-29 03:43:07 +00:00
|
|
|
|
2012-07-27 18:35:39 +00:00
|
|
|
rtnl_unlock();
|
|
|
|
|
2010-06-01 11:17:24 +00:00
|
|
|
/* Reschedule any quenched resets scheduled during efx_pm_freeze() */
|
2020-01-08 16:10:59 +00:00
|
|
|
efx_queue_reset_work(efx);
|
2010-06-01 11:17:24 +00:00
|
|
|
|
2009-11-29 03:43:07 +00:00
|
|
|
return 0;
|
2013-04-15 17:51:54 +00:00
|
|
|
|
|
|
|
fail:
|
|
|
|
rtnl_unlock();
|
|
|
|
|
|
|
|
return rc;
|
2009-11-29 03:43:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int efx_pm_poweroff(struct device *dev)
|
|
|
|
{
|
|
|
|
struct pci_dev *pci_dev = to_pci_dev(dev);
|
|
|
|
struct efx_nic *efx = pci_get_drvdata(pci_dev);
|
|
|
|
|
|
|
|
efx->type->fini(efx);
|
|
|
|
|
2011-06-24 19:46:31 +00:00
|
|
|
efx->reset_pending = 0;
|
2009-11-29 03:43:07 +00:00
|
|
|
|
|
|
|
pci_save_state(pci_dev);
|
|
|
|
return pci_set_power_state(pci_dev, PCI_D3hot);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Used for both resume and restore */
|
|
|
|
static int efx_pm_resume(struct device *dev)
|
|
|
|
{
|
|
|
|
struct pci_dev *pci_dev = to_pci_dev(dev);
|
|
|
|
struct efx_nic *efx = pci_get_drvdata(pci_dev);
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = pci_set_power_state(pci_dev, PCI_D0);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
pci_restore_state(pci_dev);
|
|
|
|
rc = pci_enable_device(pci_dev);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
pci_set_master(efx->pci_dev);
|
|
|
|
rc = efx->type->reset(efx, RESET_TYPE_ALL);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
2018-07-11 10:45:10 +00:00
|
|
|
down_write(&efx->filter_sem);
|
2009-11-29 03:43:07 +00:00
|
|
|
rc = efx->type->init(efx);
|
2018-07-11 10:45:10 +00:00
|
|
|
up_write(&efx->filter_sem);
|
2009-11-29 03:43:07 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
2013-04-15 17:51:54 +00:00
|
|
|
rc = efx_pm_thaw(dev);
|
|
|
|
return rc;
|
2009-11-29 03:43:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int efx_pm_suspend(struct device *dev)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
efx_pm_freeze(dev);
|
|
|
|
rc = efx_pm_poweroff(dev);
|
|
|
|
if (rc)
|
|
|
|
efx_pm_resume(dev);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-01-05 19:05:20 +00:00
|
|
|
static const struct dev_pm_ops efx_pm_ops = {
|
2009-11-29 03:43:07 +00:00
|
|
|
.suspend = efx_pm_suspend,
|
|
|
|
.resume = efx_pm_resume,
|
|
|
|
.freeze = efx_pm_freeze,
|
|
|
|
.thaw = efx_pm_thaw,
|
|
|
|
.poweroff = efx_pm_poweroff,
|
|
|
|
.restore = efx_pm_resume,
|
|
|
|
};
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
static struct pci_driver efx_pci_driver = {
|
2010-06-23 11:30:26 +00:00
|
|
|
.name = KBUILD_MODNAME,
|
2008-04-27 11:55:59 +00:00
|
|
|
.id_table = efx_pci_table,
|
|
|
|
.probe = efx_pci_probe,
|
|
|
|
.remove = efx_pci_remove,
|
2009-11-29 03:43:07 +00:00
|
|
|
.driver.pm = &efx_pm_ops,
|
2013-01-14 17:20:22 +00:00
|
|
|
.err_handler = &efx_err_handlers,
|
2015-05-05 23:55:58 +00:00
|
|
|
#ifdef CONFIG_SFC_SRIOV
|
|
|
|
.sriov_configure = efx_pci_sriov_configure,
|
|
|
|
#endif
|
2008-04-27 11:55:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Kernel module interface
|
|
|
|
*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
static int __init efx_init_module(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
printk(KERN_INFO "Solarflare NET driver v" EFX_DRIVER_VERSION "\n");
|
|
|
|
|
|
|
|
rc = register_netdevice_notifier(&efx_netdev_notifier);
|
|
|
|
if (rc)
|
|
|
|
goto err_notifier;
|
|
|
|
|
2015-05-05 23:55:13 +00:00
|
|
|
#ifdef CONFIG_SFC_SRIOV
|
sfc: Add SR-IOV back-end support for SFC9000 family
On the SFC9000 family, each port has 1024 Virtual Interfaces (VIs),
each with an RX queue, a TX queue, an event queue and a mailbox
register. These may be assigned to up to 127 SR-IOV virtual functions
per port, with up to 64 VIs per VF.
We allocate an extra channel (IRQ and event queue only) to receive
requests from VF drivers.
There is a per-port limit of 4 concurrent RX queue flushes, and queue
flushes may be initiated by the MC in response to a Function Level
Reset (FLR) of a VF. Therefore, when SR-IOV is in use, we submit all
flush requests via the MC.
The RSS indirection table is shared with VFs, so the number of RX
queues used in the PF is limited to the number of VIs per VF.
This is almost entirely the work of Steve Hodgson, formerly
shodgson@solarflare.com.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-02-14 00:48:07 +00:00
|
|
|
rc = efx_init_sriov();
|
|
|
|
if (rc)
|
|
|
|
goto err_sriov;
|
2015-05-05 23:55:13 +00:00
|
|
|
#endif
|
sfc: Add SR-IOV back-end support for SFC9000 family
On the SFC9000 family, each port has 1024 Virtual Interfaces (VIs),
each with an RX queue, a TX queue, an event queue and a mailbox
register. These may be assigned to up to 127 SR-IOV virtual functions
per port, with up to 64 VIs per VF.
We allocate an extra channel (IRQ and event queue only) to receive
requests from VF drivers.
There is a per-port limit of 4 concurrent RX queue flushes, and queue
flushes may be initiated by the MC in response to a Function Level
Reset (FLR) of a VF. Therefore, when SR-IOV is in use, we submit all
flush requests via the MC.
The RSS indirection table is shared with VFs, so the number of RX
queues used in the PF is limited to the number of VIs per VF.
This is almost entirely the work of Steve Hodgson, formerly
shodgson@solarflare.com.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-02-14 00:48:07 +00:00
|
|
|
|
2020-01-08 16:10:59 +00:00
|
|
|
rc = efx_create_reset_workqueue();
|
|
|
|
if (rc)
|
2008-12-13 05:33:02 +00:00
|
|
|
goto err_reset;
|
2008-04-27 11:55:59 +00:00
|
|
|
|
|
|
|
rc = pci_register_driver(&efx_pci_driver);
|
|
|
|
if (rc < 0)
|
|
|
|
goto err_pci;
|
|
|
|
|
2020-07-27 11:55:55 +00:00
|
|
|
rc = pci_register_driver(&ef100_pci_driver);
|
|
|
|
if (rc < 0)
|
|
|
|
goto err_pci_ef100;
|
|
|
|
|
2008-04-27 11:55:59 +00:00
|
|
|
return 0;
|
|
|
|
|
2020-07-27 11:55:55 +00:00
|
|
|
err_pci_ef100:
|
|
|
|
pci_unregister_driver(&efx_pci_driver);
|
2008-04-27 11:55:59 +00:00
|
|
|
err_pci:
|
2020-01-08 16:10:59 +00:00
|
|
|
efx_destroy_reset_workqueue();
|
2008-12-13 05:33:02 +00:00
|
|
|
err_reset:
|
2015-05-05 23:55:13 +00:00
|
|
|
#ifdef CONFIG_SFC_SRIOV
|
sfc: Add SR-IOV back-end support for SFC9000 family
On the SFC9000 family, each port has 1024 Virtual Interfaces (VIs),
each with an RX queue, a TX queue, an event queue and a mailbox
register. These may be assigned to up to 127 SR-IOV virtual functions
per port, with up to 64 VIs per VF.
We allocate an extra channel (IRQ and event queue only) to receive
requests from VF drivers.
There is a per-port limit of 4 concurrent RX queue flushes, and queue
flushes may be initiated by the MC in response to a Function Level
Reset (FLR) of a VF. Therefore, when SR-IOV is in use, we submit all
flush requests via the MC.
The RSS indirection table is shared with VFs, so the number of RX
queues used in the PF is limited to the number of VIs per VF.
This is almost entirely the work of Steve Hodgson, formerly
shodgson@solarflare.com.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-02-14 00:48:07 +00:00
|
|
|
efx_fini_sriov();
|
|
|
|
err_sriov:
|
2015-05-05 23:55:13 +00:00
|
|
|
#endif
|
2008-04-27 11:55:59 +00:00
|
|
|
unregister_netdevice_notifier(&efx_netdev_notifier);
|
|
|
|
err_notifier:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit efx_exit_module(void)
|
|
|
|
{
|
|
|
|
printk(KERN_INFO "Solarflare NET driver unloading\n");
|
|
|
|
|
2020-07-27 11:55:55 +00:00
|
|
|
pci_unregister_driver(&ef100_pci_driver);
|
2008-04-27 11:55:59 +00:00
|
|
|
pci_unregister_driver(&efx_pci_driver);
|
2020-01-08 16:10:59 +00:00
|
|
|
efx_destroy_reset_workqueue();
|
2015-05-05 23:55:13 +00:00
|
|
|
#ifdef CONFIG_SFC_SRIOV
|
sfc: Add SR-IOV back-end support for SFC9000 family
On the SFC9000 family, each port has 1024 Virtual Interfaces (VIs),
each with an RX queue, a TX queue, an event queue and a mailbox
register. These may be assigned to up to 127 SR-IOV virtual functions
per port, with up to 64 VIs per VF.
We allocate an extra channel (IRQ and event queue only) to receive
requests from VF drivers.
There is a per-port limit of 4 concurrent RX queue flushes, and queue
flushes may be initiated by the MC in response to a Function Level
Reset (FLR) of a VF. Therefore, when SR-IOV is in use, we submit all
flush requests via the MC.
The RSS indirection table is shared with VFs, so the number of RX
queues used in the PF is limited to the number of VIs per VF.
This is almost entirely the work of Steve Hodgson, formerly
shodgson@solarflare.com.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-02-14 00:48:07 +00:00
|
|
|
efx_fini_sriov();
|
2015-05-05 23:55:13 +00:00
|
|
|
#endif
|
2008-04-27 11:55:59 +00:00
|
|
|
unregister_netdevice_notifier(&efx_netdev_notifier);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(efx_init_module);
|
|
|
|
module_exit(efx_exit_module);
|
|
|
|
|
2009-11-29 15:16:19 +00:00
|
|
|
MODULE_AUTHOR("Solarflare Communications and "
|
|
|
|
"Michael Brown <mbrown@fensystems.co.uk>");
|
2014-02-12 19:00:07 +00:00
|
|
|
MODULE_DESCRIPTION("Solarflare network driver");
|
2008-04-27 11:55:59 +00:00
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DEVICE_TABLE(pci, efx_pci_table);
|
2017-01-03 15:46:00 +00:00
|
|
|
MODULE_VERSION(EFX_DRIVER_VERSION);
|