~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/net/sfc/selftest.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/****************************************************************************
2
2
 * Driver for Solarflare Solarstorm network controllers and boards
3
3
 * Copyright 2005-2006 Fen Systems Ltd.
4
 
 * Copyright 2006-2009 Solarflare Communications Inc.
 
4
 * Copyright 2006-2010 Solarflare Communications Inc.
5
5
 *
6
6
 * This program is free software; you can redistribute it and/or modify it
7
7
 * under the terms of the GNU General Public License version 2 as published
131
131
static int efx_test_interrupts(struct efx_nic *efx,
132
132
                               struct efx_self_tests *tests)
133
133
{
134
 
        struct efx_channel *channel;
135
 
 
136
134
        netif_dbg(efx, drv, efx->net_dev, "testing interrupts\n");
137
135
        tests->interrupt = -1;
138
136
 
140
138
        efx->last_irq_cpu = -1;
141
139
        smp_wmb();
142
140
 
143
 
        /* ACK each interrupting event queue. Receiving an interrupt due to
144
 
         * traffic before a test event is raised is considered a pass */
145
 
        efx_for_each_channel(channel, efx) {
146
 
                if (channel->work_pending)
147
 
                        efx_process_channel_now(channel);
148
 
                if (efx->last_irq_cpu >= 0)
149
 
                        goto success;
150
 
        }
151
 
 
152
141
        efx_nic_generate_interrupt(efx);
153
142
 
154
143
        /* Wait for arrival of test interrupt. */
173
162
                               struct efx_self_tests *tests)
174
163
{
175
164
        struct efx_nic *efx = channel->efx;
176
 
        unsigned int magic_count, count;
 
165
        unsigned int read_ptr, count;
177
166
 
178
167
        tests->eventq_dma[channel->channel] = -1;
179
168
        tests->eventq_int[channel->channel] = -1;
180
169
        tests->eventq_poll[channel->channel] = -1;
181
170
 
182
 
        magic_count = channel->magic_count;
 
171
        read_ptr = channel->eventq_read_ptr;
183
172
        channel->efx->last_irq_cpu = -1;
184
173
        smp_wmb();
185
174
 
190
179
        do {
191
180
                schedule_timeout_uninterruptible(HZ / 100);
192
181
 
193
 
                if (channel->work_pending)
194
 
                        efx_process_channel_now(channel);
195
 
 
196
 
                if (channel->magic_count != magic_count)
 
182
                if (ACCESS_ONCE(channel->eventq_read_ptr) != read_ptr)
197
183
                        goto eventq_ok;
198
184
        } while (++count < 2);
199
185
 
211
197
        }
212
198
 
213
199
        /* Check to see if event was received even if interrupt wasn't */
214
 
        efx_process_channel_now(channel);
215
 
        if (channel->magic_count != magic_count) {
 
200
        if (efx_nic_event_present(channel)) {
216
201
                netif_err(efx, drv, efx->net_dev,
217
202
                          "channel %d event was generated, but "
218
203
                          "failed to trigger an interrupt\n", channel->channel);
644
629
                        goto out;
645
630
                }
646
631
 
647
 
                /* Test both types of TX queue */
 
632
                /* Test all enabled types of TX queue */
648
633
                efx_for_each_channel_tx_queue(tx_queue, channel) {
649
634
                        state->offload_csum = (tx_queue->queue &
650
635
                                               EFX_TXQ_TYPE_OFFLOAD);
710
695
        /* Offline (i.e. disruptive) testing
711
696
         * This checks MAC and PHY loopback on the specified port. */
712
697
 
713
 
        /* force the carrier state off so the kernel doesn't transmit during
714
 
         * the loopback test, and the watchdog timeout doesn't fire. Also put
715
 
         * falcon into loopback for the register test.
 
698
        /* Detach the device so the kernel doesn't transmit during the
 
699
         * loopback test and the watchdog timeout doesn't fire.
716
700
         */
 
701
        netif_device_detach(efx->net_dev);
 
702
 
717
703
        mutex_lock(&efx->mac_lock);
718
 
        efx->port_inhibited = true;
719
704
        if (efx->loopback_modes) {
720
705
                /* We need the 312 clock from the PHY to test the XMAC
721
706
                 * registers, so move into XGMII loopback if available */
765
750
        /* restore the PHY to the previous state */
766
751
        mutex_lock(&efx->mac_lock);
767
752
        efx->phy_mode = phy_mode;
768
 
        efx->port_inhibited = false;
769
753
        efx->loopback_mode = loopback_mode;
770
754
        __efx_reconfigure_port(efx);
771
755
        mutex_unlock(&efx->mac_lock);
772
756
 
 
757
        netif_device_attach(efx->net_dev);
 
758
 
773
759
        return rc_test;
774
760
}
775
761