2008-05-07 12:36:19 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* Driver for Solarflare Solarstorm network controllers and boards
|
|
|
|
* Copyright 2005-2006 Fen Systems Ltd.
|
2011-02-25 00:01:34 +00:00
|
|
|
* Copyright 2006-2010 Solarflare Communications Inc.
|
2008-05-07 12:36:19 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 as published
|
|
|
|
* by the Free Software Foundation, incorporated herein by reference.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/kernel_stat.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <linux/ip.h>
|
|
|
|
#include <linux/in.h>
|
|
|
|
#include <linux/udp.h>
|
|
|
|
#include <linux/rtnetlink.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/slab.h>
|
2008-05-07 12:36:19 +00:00
|
|
|
#include "net_driver.h"
|
|
|
|
#include "efx.h"
|
2009-11-29 15:12:08 +00:00
|
|
|
#include "nic.h"
|
2008-05-07 12:36:19 +00:00
|
|
|
#include "selftest.h"
|
|
|
|
#include "workarounds.h"
|
|
|
|
|
2012-02-28 20:40:53 +00:00
|
|
|
/* IRQ latency can be enormous because:
|
|
|
|
* - All IRQs may be disabled on a CPU for a *long* time by e.g. a
|
|
|
|
* slow serial console or an old IDE driver doing error recovery
|
|
|
|
* - The PREEMPT_RT patches mostly deal with this, but also allow a
|
|
|
|
* tasklet or normal task to be given higher priority than our IRQ
|
|
|
|
* threads
|
|
|
|
* Try to avoid blaming the hardware for this.
|
|
|
|
*/
|
|
|
|
#define IRQ_TIMEOUT HZ
|
|
|
|
|
2008-05-07 12:36:19 +00:00
|
|
|
/*
|
|
|
|
* Loopback test packet structure
|
|
|
|
*
|
|
|
|
* The self-test should stress every RSS vector, and unfortunately
|
|
|
|
* Falcon only performs RSS on TCP/UDP packets.
|
|
|
|
*/
|
|
|
|
struct efx_loopback_payload {
|
|
|
|
struct ethhdr header;
|
|
|
|
struct iphdr ip;
|
|
|
|
struct udphdr udp;
|
|
|
|
__be16 iteration;
|
|
|
|
const char msg[64];
|
2010-06-02 18:10:09 +00:00
|
|
|
} __packed;
|
2008-05-07 12:36:19 +00:00
|
|
|
|
|
|
|
/* Loopback test source MAC address */
|
|
|
|
static const unsigned char payload_source[ETH_ALEN] = {
|
|
|
|
0x00, 0x0f, 0x53, 0x1b, 0x1b, 0x1b,
|
|
|
|
};
|
|
|
|
|
2009-12-13 01:41:29 +00:00
|
|
|
static const char payload_msg[] =
|
2008-05-07 12:36:19 +00:00
|
|
|
"Hello world! This is an Efx loopback test in progress!";
|
|
|
|
|
2010-10-18 05:27:31 +00:00
|
|
|
/* Interrupt mode names */
|
|
|
|
static const unsigned int efx_interrupt_mode_max = EFX_INT_MODE_MAX;
|
2012-01-05 19:05:20 +00:00
|
|
|
static const char *const efx_interrupt_mode_names[] = {
|
2010-10-18 05:27:31 +00:00
|
|
|
[EFX_INT_MODE_MSIX] = "MSI-X",
|
|
|
|
[EFX_INT_MODE_MSI] = "MSI",
|
|
|
|
[EFX_INT_MODE_LEGACY] = "legacy",
|
|
|
|
};
|
|
|
|
#define INT_MODE(efx) \
|
|
|
|
STRING_TABLE_LOOKUP(efx->interrupt_mode, efx_interrupt_mode)
|
|
|
|
|
2008-05-07 12:36:19 +00:00
|
|
|
/**
|
2008-09-01 11:49:02 +00:00
|
|
|
* efx_loopback_state - persistent state during a loopback selftest
|
2008-05-07 12:36:19 +00:00
|
|
|
* @flush: Drop all packets in efx_loopback_rx_packet
|
|
|
|
* @packet_count: Number of packets being used in this test
|
|
|
|
* @skbs: An array of skbs transmitted
|
2009-11-25 16:12:24 +00:00
|
|
|
* @offload_csum: Checksums are being offloaded
|
2008-05-07 12:36:19 +00:00
|
|
|
* @rx_good: RX good packet count
|
|
|
|
* @rx_bad: RX bad packet count
|
|
|
|
* @payload: Payload used in tests
|
|
|
|
*/
|
2008-09-01 11:49:02 +00:00
|
|
|
struct efx_loopback_state {
|
2008-09-01 11:46:50 +00:00
|
|
|
bool flush;
|
2008-05-07 12:36:19 +00:00
|
|
|
int packet_count;
|
|
|
|
struct sk_buff **skbs;
|
2008-09-01 11:46:50 +00:00
|
|
|
bool offload_csum;
|
2008-05-07 12:36:19 +00:00
|
|
|
atomic_t rx_good;
|
|
|
|
atomic_t rx_bad;
|
|
|
|
struct efx_loopback_payload payload;
|
|
|
|
};
|
|
|
|
|
2012-02-28 20:40:53 +00:00
|
|
|
/* How long to wait for all the packets to arrive (in ms) */
|
|
|
|
#define LOOPBACK_TIMEOUT_MS 1000
|
|
|
|
|
2008-05-07 12:36:19 +00:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
2008-09-01 11:49:02 +00:00
|
|
|
* MII, NVRAM and register tests
|
2008-05-07 12:36:19 +00:00
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
2010-02-03 09:30:50 +00:00
|
|
|
static int efx_test_phy_alive(struct efx_nic *efx, struct efx_self_tests *tests)
|
2008-09-01 11:49:02 +00:00
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
|
2010-02-03 09:30:50 +00:00
|
|
|
if (efx->phy_op->test_alive) {
|
|
|
|
rc = efx->phy_op->test_alive(efx);
|
|
|
|
tests->phy_alive = rc ? -1 : 1;
|
2008-09-01 11:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int efx_test_nvram(struct efx_nic *efx, struct efx_self_tests *tests)
|
|
|
|
{
|
2009-11-29 03:43:33 +00:00
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
if (efx->type->test_nvram) {
|
|
|
|
rc = efx->type->test_nvram(efx);
|
|
|
|
tests->nvram = rc ? -1 : 1;
|
|
|
|
}
|
2008-09-01 11:49:02 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2008-05-07 12:36:19 +00:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Interrupt and event queue testing
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/* Test generation and receipt of interrupts */
|
|
|
|
static int efx_test_interrupts(struct efx_nic *efx,
|
|
|
|
struct efx_self_tests *tests)
|
|
|
|
{
|
2012-02-28 20:40:53 +00:00
|
|
|
unsigned long timeout, wait;
|
2012-01-05 20:14:10 +00:00
|
|
|
int cpu;
|
|
|
|
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, drv, efx->net_dev, "testing interrupts\n");
|
2008-05-07 12:36:19 +00:00
|
|
|
tests->interrupt = -1;
|
|
|
|
|
2012-02-28 23:37:35 +00:00
|
|
|
efx_nic_irq_test_start(efx);
|
2012-02-28 20:40:53 +00:00
|
|
|
timeout = jiffies + IRQ_TIMEOUT;
|
|
|
|
wait = 1;
|
2008-05-07 12:36:19 +00:00
|
|
|
|
|
|
|
/* Wait for arrival of test interrupt. */
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, drv, efx->net_dev, "waiting for test interrupt\n");
|
2012-02-28 20:40:53 +00:00
|
|
|
do {
|
|
|
|
schedule_timeout_uninterruptible(wait);
|
2012-02-28 23:37:35 +00:00
|
|
|
cpu = efx_nic_irq_test_irq_cpu(efx);
|
2012-02-28 20:40:53 +00:00
|
|
|
if (cpu >= 0)
|
|
|
|
goto success;
|
|
|
|
wait *= 2;
|
|
|
|
} while (time_before(jiffies, timeout));
|
2008-05-07 12:36:19 +00:00
|
|
|
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev, "timed out waiting for interrupt\n");
|
2008-05-07 12:36:19 +00:00
|
|
|
return -ETIMEDOUT;
|
|
|
|
|
|
|
|
success:
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, drv, efx->net_dev, "%s test interrupt seen on CPU%d\n",
|
2012-01-05 20:14:10 +00:00
|
|
|
INT_MODE(efx), cpu);
|
2008-05-07 12:36:19 +00:00
|
|
|
tests->interrupt = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test generation and receipt of interrupting events */
|
2012-02-28 20:40:54 +00:00
|
|
|
static int efx_test_eventq_irq(struct efx_nic *efx,
|
2008-05-07 12:36:19 +00:00
|
|
|
struct efx_self_tests *tests)
|
|
|
|
{
|
2012-02-28 20:40:54 +00:00
|
|
|
struct efx_channel *channel;
|
|
|
|
unsigned int read_ptr[EFX_MAX_CHANNELS];
|
|
|
|
unsigned long napi_ran = 0, dma_pend = 0, int_pend = 0;
|
2012-02-28 20:40:53 +00:00
|
|
|
unsigned long timeout, wait;
|
2008-05-07 12:36:19 +00:00
|
|
|
|
2012-02-28 20:40:54 +00:00
|
|
|
BUILD_BUG_ON(EFX_MAX_CHANNELS > BITS_PER_LONG);
|
|
|
|
|
|
|
|
efx_for_each_channel(channel, efx) {
|
|
|
|
read_ptr[channel->channel] = channel->eventq_read_ptr;
|
|
|
|
set_bit(channel->channel, &dma_pend);
|
|
|
|
set_bit(channel->channel, &int_pend);
|
2012-02-28 23:37:35 +00:00
|
|
|
efx_nic_event_test_start(channel);
|
2012-02-28 20:40:54 +00:00
|
|
|
}
|
2008-05-07 12:36:19 +00:00
|
|
|
|
2012-02-28 20:40:53 +00:00
|
|
|
timeout = jiffies + IRQ_TIMEOUT;
|
|
|
|
wait = 1;
|
2008-05-07 12:36:19 +00:00
|
|
|
|
2012-02-28 20:40:54 +00:00
|
|
|
/* Wait for arrival of interrupts. NAPI processing may or may
|
2011-11-04 23:06:04 +00:00
|
|
|
* not complete in time, but we can cope in any case.
|
|
|
|
*/
|
2012-02-28 20:40:53 +00:00
|
|
|
do {
|
|
|
|
schedule_timeout_uninterruptible(wait);
|
|
|
|
|
2012-02-28 20:40:54 +00:00
|
|
|
efx_for_each_channel(channel, efx) {
|
|
|
|
napi_disable(&channel->napi_str);
|
|
|
|
if (channel->eventq_read_ptr !=
|
|
|
|
read_ptr[channel->channel]) {
|
|
|
|
set_bit(channel->channel, &napi_ran);
|
|
|
|
clear_bit(channel->channel, &dma_pend);
|
|
|
|
clear_bit(channel->channel, &int_pend);
|
|
|
|
} else {
|
|
|
|
if (efx_nic_event_present(channel))
|
|
|
|
clear_bit(channel->channel, &dma_pend);
|
2012-02-28 23:37:35 +00:00
|
|
|
if (efx_nic_event_test_irq_cpu(channel) >= 0)
|
2012-02-28 20:40:54 +00:00
|
|
|
clear_bit(channel->channel, &int_pend);
|
|
|
|
}
|
|
|
|
napi_enable(&channel->napi_str);
|
|
|
|
efx_nic_eventq_read_ack(channel);
|
2012-02-28 20:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wait *= 2;
|
2012-02-28 20:40:54 +00:00
|
|
|
} while ((dma_pend || int_pend) && time_before(jiffies, timeout));
|
2011-11-04 23:06:04 +00:00
|
|
|
|
2012-02-28 20:40:54 +00:00
|
|
|
efx_for_each_channel(channel, efx) {
|
|
|
|
bool dma_seen = !test_bit(channel->channel, &dma_pend);
|
|
|
|
bool int_seen = !test_bit(channel->channel, &int_pend);
|
|
|
|
|
|
|
|
tests->eventq_dma[channel->channel] = dma_seen ? 1 : -1;
|
|
|
|
tests->eventq_int[channel->channel] = int_seen ? 1 : -1;
|
|
|
|
|
|
|
|
if (dma_seen && int_seen) {
|
|
|
|
netif_dbg(efx, drv, efx->net_dev,
|
|
|
|
"channel %d event queue passed (with%s NAPI)\n",
|
|
|
|
channel->channel,
|
|
|
|
test_bit(channel->channel, &napi_ran) ?
|
|
|
|
"" : "out");
|
|
|
|
} else {
|
|
|
|
/* Report failure and whether either interrupt or DMA
|
|
|
|
* worked
|
|
|
|
*/
|
2011-11-04 23:06:04 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev,
|
2012-02-28 20:40:54 +00:00
|
|
|
"channel %d timed out waiting for event queue\n",
|
2011-11-04 23:06:04 +00:00
|
|
|
channel->channel);
|
2012-02-28 20:40:54 +00:00
|
|
|
if (int_seen)
|
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"channel %d saw interrupt "
|
|
|
|
"during event queue test\n",
|
|
|
|
channel->channel);
|
|
|
|
if (dma_seen)
|
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"channel %d event was generated, but "
|
|
|
|
"failed to trigger an interrupt\n",
|
|
|
|
channel->channel);
|
|
|
|
}
|
2008-05-07 12:36:19 +00:00
|
|
|
}
|
2012-02-28 20:40:54 +00:00
|
|
|
|
|
|
|
return (dma_pend || int_pend) ? -ETIMEDOUT : 0;
|
2008-05-07 12:36:19 +00:00
|
|
|
}
|
|
|
|
|
2008-12-26 21:47:25 +00:00
|
|
|
static int efx_test_phy(struct efx_nic *efx, struct efx_self_tests *tests,
|
|
|
|
unsigned flags)
|
2008-05-07 12:36:19 +00:00
|
|
|
{
|
2008-09-01 11:49:02 +00:00
|
|
|
int rc;
|
2008-05-07 12:36:19 +00:00
|
|
|
|
2008-12-26 21:47:25 +00:00
|
|
|
if (!efx->phy_op->run_tests)
|
2008-05-07 12:36:19 +00:00
|
|
|
return 0;
|
|
|
|
|
2008-09-01 11:49:02 +00:00
|
|
|
mutex_lock(&efx->mac_lock);
|
2010-02-03 09:30:50 +00:00
|
|
|
rc = efx->phy_op->run_tests(efx, tests->phy_ext, flags);
|
2008-09-01 11:49:02 +00:00
|
|
|
mutex_unlock(&efx->mac_lock);
|
|
|
|
return rc;
|
2008-05-07 12:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Loopback testing
|
|
|
|
* NB Only one loopback test can be executing concurrently.
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/* Loopback test RX callback
|
|
|
|
* This is called for each received packet during loopback testing.
|
|
|
|
*/
|
|
|
|
void efx_loopback_rx_packet(struct efx_nic *efx,
|
|
|
|
const char *buf_ptr, int pkt_len)
|
|
|
|
{
|
2008-09-01 11:49:02 +00:00
|
|
|
struct efx_loopback_state *state = efx->loopback_selftest;
|
2008-05-07 12:36:19 +00:00
|
|
|
struct efx_loopback_payload *received;
|
|
|
|
struct efx_loopback_payload *payload;
|
|
|
|
|
|
|
|
BUG_ON(!buf_ptr);
|
|
|
|
|
|
|
|
/* If we are just flushing, then drop the packet */
|
|
|
|
if ((state == NULL) || state->flush)
|
|
|
|
return;
|
|
|
|
|
|
|
|
payload = &state->payload;
|
2008-09-01 11:49:02 +00:00
|
|
|
|
2008-05-16 20:20:00 +00:00
|
|
|
received = (struct efx_loopback_payload *) buf_ptr;
|
2008-05-07 12:36:19 +00:00
|
|
|
received->ip.saddr = payload->ip.saddr;
|
2008-09-01 11:44:59 +00:00
|
|
|
if (state->offload_csum)
|
|
|
|
received->ip.check = payload->ip.check;
|
|
|
|
|
2008-05-07 12:36:19 +00:00
|
|
|
/* Check that header exists */
|
|
|
|
if (pkt_len < sizeof(received->header)) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"saw runt RX packet (length %d) in %s loopback "
|
|
|
|
"test\n", pkt_len, LOOPBACK_MODE(efx));
|
2008-05-07 12:36:19 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check that the ethernet header exists */
|
|
|
|
if (memcmp(&received->header, &payload->header, ETH_HLEN) != 0) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"saw non-loopback RX packet in %s loopback test\n",
|
|
|
|
LOOPBACK_MODE(efx));
|
2008-05-07 12:36:19 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check packet length */
|
|
|
|
if (pkt_len != sizeof(*payload)) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"saw incorrect RX packet length %d (wanted %d) in "
|
|
|
|
"%s loopback test\n", pkt_len, (int)sizeof(*payload),
|
|
|
|
LOOPBACK_MODE(efx));
|
2008-05-07 12:36:19 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check that IP header matches */
|
|
|
|
if (memcmp(&received->ip, &payload->ip, sizeof(payload->ip)) != 0) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"saw corrupted IP header in %s loopback test\n",
|
|
|
|
LOOPBACK_MODE(efx));
|
2008-05-07 12:36:19 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check that msg and padding matches */
|
|
|
|
if (memcmp(&received->msg, &payload->msg, sizeof(received->msg)) != 0) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"saw corrupted RX packet in %s loopback test\n",
|
|
|
|
LOOPBACK_MODE(efx));
|
2008-05-07 12:36:19 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check that iteration matches */
|
|
|
|
if (received->iteration != payload->iteration) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"saw RX packet from iteration %d (wanted %d) in "
|
|
|
|
"%s loopback test\n", ntohs(received->iteration),
|
|
|
|
ntohs(payload->iteration), LOOPBACK_MODE(efx));
|
2008-05-07 12:36:19 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Increase correct RX count */
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_vdbg(efx, drv, efx->net_dev,
|
|
|
|
"got loopback RX in %s loopback test\n", LOOPBACK_MODE(efx));
|
2008-05-07 12:36:19 +00:00
|
|
|
|
|
|
|
atomic_inc(&state->rx_good);
|
|
|
|
return;
|
|
|
|
|
|
|
|
err:
|
2011-11-04 22:29:14 +00:00
|
|
|
#ifdef DEBUG
|
2008-05-07 12:36:19 +00:00
|
|
|
if (atomic_read(&state->rx_bad) == 0) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev, "received packet:\n");
|
2008-05-07 12:36:19 +00:00
|
|
|
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1,
|
|
|
|
buf_ptr, pkt_len, 0);
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev, "expected packet:\n");
|
2008-05-07 12:36:19 +00:00
|
|
|
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1,
|
|
|
|
&state->payload, sizeof(state->payload), 0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
atomic_inc(&state->rx_bad);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialise an efx_selftest_state for a new iteration */
|
|
|
|
static void efx_iterate_state(struct efx_nic *efx)
|
|
|
|
{
|
2008-09-01 11:49:02 +00:00
|
|
|
struct efx_loopback_state *state = efx->loopback_selftest;
|
2008-05-07 12:36:19 +00:00
|
|
|
struct net_device *net_dev = efx->net_dev;
|
|
|
|
struct efx_loopback_payload *payload = &state->payload;
|
|
|
|
|
|
|
|
/* Initialise the layerII header */
|
|
|
|
memcpy(&payload->header.h_dest, net_dev->dev_addr, ETH_ALEN);
|
|
|
|
memcpy(&payload->header.h_source, &payload_source, ETH_ALEN);
|
|
|
|
payload->header.h_proto = htons(ETH_P_IP);
|
|
|
|
|
|
|
|
/* saddr set later and used as incrementing count */
|
|
|
|
payload->ip.daddr = htonl(INADDR_LOOPBACK);
|
|
|
|
payload->ip.ihl = 5;
|
2012-09-06 01:11:06 +00:00
|
|
|
payload->ip.check = (__force __sum16) htons(0xdead);
|
2008-05-07 12:36:19 +00:00
|
|
|
payload->ip.tot_len = htons(sizeof(*payload) - sizeof(struct ethhdr));
|
|
|
|
payload->ip.version = IPVERSION;
|
|
|
|
payload->ip.protocol = IPPROTO_UDP;
|
|
|
|
|
|
|
|
/* Initialise udp header */
|
|
|
|
payload->udp.source = 0;
|
|
|
|
payload->udp.len = htons(sizeof(*payload) - sizeof(struct ethhdr) -
|
|
|
|
sizeof(struct iphdr));
|
|
|
|
payload->udp.check = 0; /* checksum ignored */
|
|
|
|
|
|
|
|
/* Fill out payload */
|
|
|
|
payload->iteration = htons(ntohs(payload->iteration) + 1);
|
|
|
|
memcpy(&payload->msg, payload_msg, sizeof(payload_msg));
|
|
|
|
|
|
|
|
/* Fill out remaining state members */
|
|
|
|
atomic_set(&state->rx_good, 0);
|
|
|
|
atomic_set(&state->rx_bad, 0);
|
|
|
|
smp_wmb();
|
|
|
|
}
|
|
|
|
|
2008-09-01 11:46:33 +00:00
|
|
|
static int efx_begin_loopback(struct efx_tx_queue *tx_queue)
|
2008-05-07 12:36:19 +00:00
|
|
|
{
|
|
|
|
struct efx_nic *efx = tx_queue->efx;
|
2008-09-01 11:49:02 +00:00
|
|
|
struct efx_loopback_state *state = efx->loopback_selftest;
|
2008-05-07 12:36:19 +00:00
|
|
|
struct efx_loopback_payload *payload;
|
|
|
|
struct sk_buff *skb;
|
2009-08-31 19:50:58 +00:00
|
|
|
int i;
|
|
|
|
netdev_tx_t rc;
|
2008-05-07 12:36:19 +00:00
|
|
|
|
|
|
|
/* Transmit N copies of buffer */
|
|
|
|
for (i = 0; i < state->packet_count; i++) {
|
2008-09-01 11:49:02 +00:00
|
|
|
/* Allocate an skb, holding an extra reference for
|
2008-05-07 12:36:19 +00:00
|
|
|
* transmit completion counting */
|
|
|
|
skb = alloc_skb(sizeof(state->payload), GFP_KERNEL);
|
|
|
|
if (!skb)
|
|
|
|
return -ENOMEM;
|
|
|
|
state->skbs[i] = skb;
|
|
|
|
skb_get(skb);
|
|
|
|
|
|
|
|
/* Copy the payload in, incrementing the source address to
|
|
|
|
* exercise the rss vectors */
|
|
|
|
payload = ((struct efx_loopback_payload *)
|
|
|
|
skb_put(skb, sizeof(state->payload)));
|
|
|
|
memcpy(payload, &state->payload, sizeof(state->payload));
|
|
|
|
payload->ip.saddr = htonl(INADDR_LOOPBACK | (i << 2));
|
|
|
|
|
|
|
|
/* Ensure everything we've written is visible to the
|
|
|
|
* interrupt handler. */
|
|
|
|
smp_wmb();
|
|
|
|
|
2012-01-09 19:47:08 +00:00
|
|
|
netif_tx_lock_bh(efx->net_dev);
|
2009-11-23 16:07:05 +00:00
|
|
|
rc = efx_enqueue_skb(tx_queue, skb);
|
2012-01-09 19:47:08 +00:00
|
|
|
netif_tx_unlock_bh(efx->net_dev);
|
2008-05-07 12:36:19 +00:00
|
|
|
|
|
|
|
if (rc != NETDEV_TX_OK) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"TX queue %d could not transmit packet %d of "
|
|
|
|
"%d in %s loopback test\n", tx_queue->queue,
|
|
|
|
i + 1, state->packet_count,
|
|
|
|
LOOPBACK_MODE(efx));
|
2008-05-07 12:36:19 +00:00
|
|
|
|
|
|
|
/* Defer cleaning up the other skbs for the caller */
|
|
|
|
kfree_skb(skb);
|
|
|
|
return -EPIPE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-09-01 11:46:33 +00:00
|
|
|
static int efx_poll_loopback(struct efx_nic *efx)
|
|
|
|
{
|
2008-09-01 11:49:02 +00:00
|
|
|
struct efx_loopback_state *state = efx->loopback_selftest;
|
2008-09-01 11:46:33 +00:00
|
|
|
struct efx_channel *channel;
|
|
|
|
|
|
|
|
/* NAPI polling is not enabled, so process channels
|
|
|
|
* synchronously */
|
2008-09-01 11:47:38 +00:00
|
|
|
efx_for_each_channel(channel, efx) {
|
2008-09-01 11:46:33 +00:00
|
|
|
if (channel->work_pending)
|
|
|
|
efx_process_channel_now(channel);
|
|
|
|
}
|
|
|
|
return atomic_read(&state->rx_good) == state->packet_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int efx_end_loopback(struct efx_tx_queue *tx_queue,
|
|
|
|
struct efx_loopback_self_tests *lb_tests)
|
2008-05-07 12:36:19 +00:00
|
|
|
{
|
|
|
|
struct efx_nic *efx = tx_queue->efx;
|
2008-09-01 11:49:02 +00:00
|
|
|
struct efx_loopback_state *state = efx->loopback_selftest;
|
2008-05-07 12:36:19 +00:00
|
|
|
struct sk_buff *skb;
|
|
|
|
int tx_done = 0, rx_good, rx_bad;
|
|
|
|
int i, rc = 0;
|
|
|
|
|
2012-01-09 19:47:08 +00:00
|
|
|
netif_tx_lock_bh(efx->net_dev);
|
2008-05-07 12:36:19 +00:00
|
|
|
|
|
|
|
/* Count the number of tx completions, and decrement the refcnt. Any
|
|
|
|
* skbs not already completed will be free'd when the queue is flushed */
|
2012-01-05 17:19:45 +00:00
|
|
|
for (i = 0; i < state->packet_count; i++) {
|
2008-05-07 12:36:19 +00:00
|
|
|
skb = state->skbs[i];
|
|
|
|
if (skb && !skb_shared(skb))
|
|
|
|
++tx_done;
|
2012-07-02 22:03:02 +00:00
|
|
|
dev_kfree_skb(skb);
|
2008-05-07 12:36:19 +00:00
|
|
|
}
|
|
|
|
|
2012-01-09 19:47:08 +00:00
|
|
|
netif_tx_unlock_bh(efx->net_dev);
|
2008-05-07 12:36:19 +00:00
|
|
|
|
|
|
|
/* Check TX completion and received packet counts */
|
|
|
|
rx_good = atomic_read(&state->rx_good);
|
|
|
|
rx_bad = atomic_read(&state->rx_bad);
|
|
|
|
if (tx_done != state->packet_count) {
|
|
|
|
/* Don't free the skbs; they will be picked up on TX
|
|
|
|
* overflow or channel teardown.
|
|
|
|
*/
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"TX queue %d saw only %d out of an expected %d "
|
|
|
|
"TX completion events in %s loopback test\n",
|
|
|
|
tx_queue->queue, tx_done, state->packet_count,
|
|
|
|
LOOPBACK_MODE(efx));
|
2008-05-07 12:36:19 +00:00
|
|
|
rc = -ETIMEDOUT;
|
|
|
|
/* Allow to fall through so we see the RX errors as well */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We may always be up to a flush away from our desired packet total */
|
|
|
|
if (rx_good != state->packet_count) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, drv, efx->net_dev,
|
|
|
|
"TX queue %d saw only %d out of an expected %d "
|
|
|
|
"received packets in %s loopback test\n",
|
|
|
|
tx_queue->queue, rx_good, state->packet_count,
|
|
|
|
LOOPBACK_MODE(efx));
|
2008-05-07 12:36:19 +00:00
|
|
|
rc = -ETIMEDOUT;
|
|
|
|
/* Fall through */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update loopback test structure */
|
|
|
|
lb_tests->tx_sent[tx_queue->queue] += state->packet_count;
|
|
|
|
lb_tests->tx_done[tx_queue->queue] += tx_done;
|
|
|
|
lb_tests->rx_good += rx_good;
|
|
|
|
lb_tests->rx_bad += rx_bad;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
efx_test_loopback(struct efx_tx_queue *tx_queue,
|
|
|
|
struct efx_loopback_self_tests *lb_tests)
|
|
|
|
{
|
|
|
|
struct efx_nic *efx = tx_queue->efx;
|
2008-09-01 11:49:02 +00:00
|
|
|
struct efx_loopback_state *state = efx->loopback_selftest;
|
2008-09-01 11:46:33 +00:00
|
|
|
int i, begin_rc, end_rc;
|
2008-05-07 12:36:19 +00:00
|
|
|
|
2008-09-01 11:49:02 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
2008-05-07 12:36:19 +00:00
|
|
|
/* Determine how many packets to send */
|
2010-09-10 06:42:22 +00:00
|
|
|
state->packet_count = efx->txq_entries / 3;
|
2008-05-07 12:36:19 +00:00
|
|
|
state->packet_count = min(1 << (i << 2), state->packet_count);
|
2011-12-02 12:36:13 +00:00
|
|
|
state->skbs = kcalloc(state->packet_count,
|
|
|
|
sizeof(state->skbs[0]), GFP_KERNEL);
|
2008-05-16 20:20:20 +00:00
|
|
|
if (!state->skbs)
|
|
|
|
return -ENOMEM;
|
2008-09-01 11:46:50 +00:00
|
|
|
state->flush = false;
|
2008-05-07 12:36:19 +00:00
|
|
|
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, drv, efx->net_dev,
|
|
|
|
"TX queue %d testing %s loopback with %d packets\n",
|
|
|
|
tx_queue->queue, LOOPBACK_MODE(efx),
|
|
|
|
state->packet_count);
|
2008-05-07 12:36:19 +00:00
|
|
|
|
|
|
|
efx_iterate_state(efx);
|
2008-09-01 11:46:33 +00:00
|
|
|
begin_rc = efx_begin_loopback(tx_queue);
|
|
|
|
|
|
|
|
/* This will normally complete very quickly, but be
|
2012-02-28 20:40:53 +00:00
|
|
|
* prepared to wait much longer. */
|
2008-09-01 11:46:33 +00:00
|
|
|
msleep(1);
|
|
|
|
if (!efx_poll_loopback(efx)) {
|
2012-02-28 20:40:53 +00:00
|
|
|
msleep(LOOPBACK_TIMEOUT_MS);
|
2008-09-01 11:46:33 +00:00
|
|
|
efx_poll_loopback(efx);
|
2008-05-07 12:36:19 +00:00
|
|
|
}
|
|
|
|
|
2008-09-01 11:46:33 +00:00
|
|
|
end_rc = efx_end_loopback(tx_queue, lb_tests);
|
2008-05-07 12:36:19 +00:00
|
|
|
kfree(state->skbs);
|
|
|
|
|
2008-09-01 11:46:33 +00:00
|
|
|
if (begin_rc || end_rc) {
|
2008-05-07 12:36:19 +00:00
|
|
|
/* Wait a while to ensure there are no packets
|
|
|
|
* floating around after a failure. */
|
|
|
|
schedule_timeout_uninterruptible(HZ / 10);
|
2008-09-01 11:46:33 +00:00
|
|
|
return begin_rc ? begin_rc : end_rc;
|
2008-05-07 12:36:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_dbg(efx, drv, efx->net_dev,
|
|
|
|
"TX queue %d passed %s loopback test with a burst length "
|
|
|
|
"of %d packets\n", tx_queue->queue, LOOPBACK_MODE(efx),
|
|
|
|
state->packet_count);
|
2008-05-07 12:36:19 +00:00
|
|
|
|
2008-09-01 11:45:08 +00:00
|
|
|
return 0;
|
2008-05-07 12:36:19 +00:00
|
|
|
}
|
|
|
|
|
2009-11-29 03:43:00 +00:00
|
|
|
/* Wait for link up. On Falcon, we would prefer to rely on efx_monitor, but
|
|
|
|
* any contention on the mac lock (via e.g. efx_mac_mcast_work) causes it
|
|
|
|
* to delay and retry. Therefore, it's safer to just poll directly. Wait
|
|
|
|
* for link up and any faults to dissipate. */
|
|
|
|
static int efx_wait_for_link(struct efx_nic *efx)
|
|
|
|
{
|
|
|
|
struct efx_link_state *link_state = &efx->link_state;
|
2010-06-01 11:18:28 +00:00
|
|
|
int count, link_up_count = 0;
|
2009-11-29 03:43:00 +00:00
|
|
|
bool link_up;
|
|
|
|
|
|
|
|
for (count = 0; count < 40; count++) {
|
|
|
|
schedule_timeout_uninterruptible(HZ / 10);
|
|
|
|
|
|
|
|
if (efx->type->monitor != NULL) {
|
|
|
|
mutex_lock(&efx->mac_lock);
|
|
|
|
efx->type->monitor(efx);
|
|
|
|
mutex_unlock(&efx->mac_lock);
|
|
|
|
} else {
|
2010-09-10 06:41:47 +00:00
|
|
|
struct efx_channel *channel = efx_get_channel(efx, 0);
|
2009-11-29 03:43:00 +00:00
|
|
|
if (channel->work_pending)
|
|
|
|
efx_process_channel_now(channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_lock(&efx->mac_lock);
|
|
|
|
link_up = link_state->up;
|
|
|
|
if (link_up)
|
2011-09-02 23:15:00 +00:00
|
|
|
link_up = !efx->type->check_mac_fault(efx);
|
2009-11-29 03:43:00 +00:00
|
|
|
mutex_unlock(&efx->mac_lock);
|
|
|
|
|
2010-06-01 11:18:28 +00:00
|
|
|
if (link_up) {
|
|
|
|
if (++link_up_count == 2)
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
link_up_count = 0;
|
|
|
|
}
|
2009-11-29 03:43:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return -ETIMEDOUT;
|
|
|
|
}
|
|
|
|
|
2008-12-26 21:46:38 +00:00
|
|
|
static int efx_test_loopbacks(struct efx_nic *efx, struct efx_self_tests *tests,
|
2008-05-07 12:36:19 +00:00
|
|
|
unsigned int loopback_modes)
|
|
|
|
{
|
2008-09-01 11:49:02 +00:00
|
|
|
enum efx_loopback_mode mode;
|
|
|
|
struct efx_loopback_state *state;
|
2012-09-13 01:22:52 +00:00
|
|
|
struct efx_channel *channel =
|
|
|
|
efx_get_channel(efx, efx->tx_channel_offset);
|
2008-05-07 12:36:19 +00:00
|
|
|
struct efx_tx_queue *tx_queue;
|
2009-11-29 03:43:00 +00:00
|
|
|
int rc = 0;
|
2008-05-07 12:36:19 +00:00
|
|
|
|
2008-09-01 11:49:02 +00:00
|
|
|
/* Set the port loopback_selftest member. From this point on
|
|
|
|
* all received packets will be dropped. Mark the state as
|
|
|
|
* "flushing" so all inflight packets are dropped */
|
|
|
|
state = kzalloc(sizeof(*state), GFP_KERNEL);
|
|
|
|
if (state == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
BUG_ON(efx->loopback_selftest);
|
|
|
|
state->flush = true;
|
|
|
|
efx->loopback_selftest = state;
|
2008-05-07 12:36:19 +00:00
|
|
|
|
|
|
|
/* Test all supported loopback modes */
|
2008-09-01 11:49:02 +00:00
|
|
|
for (mode = LOOPBACK_NONE; mode <= LOOPBACK_TEST_MAX; mode++) {
|
2008-05-07 12:36:19 +00:00
|
|
|
if (!(loopback_modes & (1 << mode)))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Move the port into the specified loopback mode. */
|
2008-09-01 11:46:50 +00:00
|
|
|
state->flush = true;
|
2009-11-29 03:43:00 +00:00
|
|
|
mutex_lock(&efx->mac_lock);
|
2008-05-07 12:36:19 +00:00
|
|
|
efx->loopback_mode = mode;
|
2009-11-29 03:43:00 +00:00
|
|
|
rc = __efx_reconfigure_port(efx);
|
|
|
|
mutex_unlock(&efx->mac_lock);
|
|
|
|
if (rc) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"unable to move into %s loopback\n",
|
|
|
|
LOOPBACK_MODE(efx));
|
2009-11-29 03:43:00 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2008-05-07 12:36:19 +00:00
|
|
|
|
2009-11-29 03:43:00 +00:00
|
|
|
rc = efx_wait_for_link(efx);
|
|
|
|
if (rc) {
|
2010-06-23 11:30:07 +00:00
|
|
|
netif_err(efx, drv, efx->net_dev,
|
|
|
|
"loopback %s never came up\n",
|
|
|
|
LOOPBACK_MODE(efx));
|
2008-05-07 12:36:19 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-01-10 21:18:20 +00:00
|
|
|
/* Test all enabled types of TX queue */
|
2010-09-10 06:41:47 +00:00
|
|
|
efx_for_each_channel_tx_queue(tx_queue, channel) {
|
2010-04-28 09:30:43 +00:00
|
|
|
state->offload_csum = (tx_queue->queue &
|
|
|
|
EFX_TXQ_TYPE_OFFLOAD);
|
2008-09-01 11:46:28 +00:00
|
|
|
rc = efx_test_loopback(tx_queue,
|
|
|
|
&tests->loopback[mode]);
|
2008-05-07 12:36:19 +00:00
|
|
|
if (rc)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2008-09-01 11:49:02 +00:00
|
|
|
/* Remove the flush. The caller will remove the loopback setting */
|
2008-09-01 11:46:50 +00:00
|
|
|
state->flush = true;
|
2008-09-01 11:49:02 +00:00
|
|
|
efx->loopback_selftest = NULL;
|
|
|
|
wmb();
|
|
|
|
kfree(state);
|
2008-05-07 12:36:19 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
2008-12-26 21:47:04 +00:00
|
|
|
* Entry point
|
2008-05-07 12:36:19 +00:00
|
|
|
*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2008-12-26 21:47:04 +00:00
|
|
|
int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests,
|
|
|
|
unsigned flags)
|
2008-05-07 12:36:19 +00:00
|
|
|
{
|
2008-12-26 21:47:04 +00:00
|
|
|
enum efx_loopback_mode loopback_mode = efx->loopback_mode;
|
|
|
|
int phy_mode = efx->phy_mode;
|
2012-07-04 02:58:33 +00:00
|
|
|
int rc_test = 0, rc_reset, rc;
|
2008-12-26 21:47:04 +00:00
|
|
|
|
2012-02-28 23:40:21 +00:00
|
|
|
efx_selftest_async_cancel(efx);
|
|
|
|
|
2008-12-26 21:47:04 +00:00
|
|
|
/* Online (i.e. non-disruptive) testing
|
|
|
|
* This checks interrupt generation, event delivery and PHY presence. */
|
2008-09-01 11:49:02 +00:00
|
|
|
|
2010-02-03 09:30:50 +00:00
|
|
|
rc = efx_test_phy_alive(efx, tests);
|
2008-12-26 21:47:04 +00:00
|
|
|
if (rc && !rc_test)
|
|
|
|
rc_test = rc;
|
2008-09-01 11:49:02 +00:00
|
|
|
|
|
|
|
rc = efx_test_nvram(efx, tests);
|
2008-12-26 21:47:04 +00:00
|
|
|
if (rc && !rc_test)
|
|
|
|
rc_test = rc;
|
2008-05-07 12:36:19 +00:00
|
|
|
|
2008-09-01 11:46:28 +00:00
|
|
|
rc = efx_test_interrupts(efx, tests);
|
2008-12-26 21:47:04 +00:00
|
|
|
if (rc && !rc_test)
|
|
|
|
rc_test = rc;
|
2008-09-01 11:49:02 +00:00
|
|
|
|
2012-02-28 20:40:54 +00:00
|
|
|
rc = efx_test_eventq_irq(efx, tests);
|
|
|
|
if (rc && !rc_test)
|
|
|
|
rc_test = rc;
|
2008-09-01 11:49:02 +00:00
|
|
|
|
2008-12-26 21:47:04 +00:00
|
|
|
if (rc_test)
|
|
|
|
return rc_test;
|
2008-05-07 12:36:19 +00:00
|
|
|
|
2008-12-26 21:47:04 +00:00
|
|
|
if (!(flags & ETH_TEST_FL_OFFLINE))
|
2008-12-26 21:47:25 +00:00
|
|
|
return efx_test_phy(efx, tests, flags);
|
2008-12-26 21:47:04 +00:00
|
|
|
|
|
|
|
/* Offline (i.e. disruptive) testing
|
|
|
|
* This checks MAC and PHY loopback on the specified port. */
|
2008-09-01 11:49:02 +00:00
|
|
|
|
2011-05-16 17:51:24 +00:00
|
|
|
/* Detach the device so the kernel doesn't transmit during the
|
|
|
|
* loopback test and the watchdog timeout doesn't fire.
|
2008-09-01 11:49:02 +00:00
|
|
|
*/
|
2012-10-17 12:21:23 +00:00
|
|
|
efx_device_detach_sync(efx);
|
2011-05-16 17:51:24 +00:00
|
|
|
|
2012-07-04 02:58:33 +00:00
|
|
|
if (efx->type->test_chip) {
|
|
|
|
rc_reset = efx->type->test_chip(efx, tests);
|
|
|
|
if (rc_reset) {
|
|
|
|
netif_err(efx, hw, efx->net_dev,
|
|
|
|
"Unable to recover from chip test\n");
|
|
|
|
efx_schedule_reset(efx, RESET_TYPE_DISABLE);
|
|
|
|
return rc_reset;
|
|
|
|
}
|
2008-09-01 11:49:02 +00:00
|
|
|
|
2012-07-04 02:58:33 +00:00
|
|
|
if ((tests->registers < 0) && !rc_test)
|
|
|
|
rc_test = -EIO;
|
|
|
|
}
|
2008-09-01 11:49:02 +00:00
|
|
|
|
2008-12-26 21:46:38 +00:00
|
|
|
/* Ensure that the phy is powered and out of loopback
|
|
|
|
* for the bist and loopback tests */
|
2012-07-04 02:58:33 +00:00
|
|
|
mutex_lock(&efx->mac_lock);
|
2008-12-26 21:46:38 +00:00
|
|
|
efx->phy_mode &= ~PHY_MODE_LOW_POWER;
|
2008-09-01 11:49:02 +00:00
|
|
|
efx->loopback_mode = LOOPBACK_NONE;
|
2012-07-04 02:58:33 +00:00
|
|
|
__efx_reconfigure_port(efx);
|
|
|
|
mutex_unlock(&efx->mac_lock);
|
2008-05-07 12:36:19 +00:00
|
|
|
|
2008-12-26 21:47:25 +00:00
|
|
|
rc = efx_test_phy(efx, tests, flags);
|
2008-12-26 21:47:04 +00:00
|
|
|
if (rc && !rc_test)
|
|
|
|
rc_test = rc;
|
2008-05-07 12:36:19 +00:00
|
|
|
|
2008-12-26 21:47:04 +00:00
|
|
|
rc = efx_test_loopbacks(efx, tests, efx->loopback_modes);
|
|
|
|
if (rc && !rc_test)
|
|
|
|
rc_test = rc;
|
2008-05-07 12:36:19 +00:00
|
|
|
|
2008-09-01 11:49:02 +00:00
|
|
|
/* restore the PHY to the previous state */
|
2009-11-29 03:42:41 +00:00
|
|
|
mutex_lock(&efx->mac_lock);
|
2008-09-01 11:49:02 +00:00
|
|
|
efx->phy_mode = phy_mode;
|
2009-11-29 03:42:41 +00:00
|
|
|
efx->loopback_mode = loopback_mode;
|
|
|
|
__efx_reconfigure_port(efx);
|
|
|
|
mutex_unlock(&efx->mac_lock);
|
2008-09-01 11:49:02 +00:00
|
|
|
|
2011-05-16 17:51:24 +00:00
|
|
|
netif_device_attach(efx->net_dev);
|
2011-04-04 12:46:23 +00:00
|
|
|
|
2008-12-26 21:47:04 +00:00
|
|
|
return rc_test;
|
2008-05-07 12:36:19 +00:00
|
|
|
}
|
|
|
|
|
2012-02-28 23:40:21 +00:00
|
|
|
void efx_selftest_async_start(struct efx_nic *efx)
|
|
|
|
{
|
|
|
|
struct efx_channel *channel;
|
|
|
|
|
|
|
|
efx_for_each_channel(channel, efx)
|
|
|
|
efx_nic_event_test_start(channel);
|
|
|
|
schedule_delayed_work(&efx->selftest_work, IRQ_TIMEOUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
void efx_selftest_async_cancel(struct efx_nic *efx)
|
|
|
|
{
|
|
|
|
cancel_delayed_work_sync(&efx->selftest_work);
|
|
|
|
}
|
|
|
|
|
|
|
|
void efx_selftest_async_work(struct work_struct *data)
|
|
|
|
{
|
|
|
|
struct efx_nic *efx = container_of(data, struct efx_nic,
|
|
|
|
selftest_work.work);
|
|
|
|
struct efx_channel *channel;
|
|
|
|
int cpu;
|
|
|
|
|
|
|
|
efx_for_each_channel(channel, efx) {
|
|
|
|
cpu = efx_nic_event_test_irq_cpu(channel);
|
|
|
|
if (cpu < 0)
|
|
|
|
netif_err(efx, ifup, efx->net_dev,
|
|
|
|
"channel %d failed to trigger an interrupt\n",
|
|
|
|
channel->channel);
|
|
|
|
else
|
|
|
|
netif_dbg(efx, ifup, efx->net_dev,
|
|
|
|
"channel %d triggered interrupt on CPU %d\n",
|
|
|
|
channel->channel, cpu);
|
|
|
|
}
|
|
|
|
}
|