]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/sfc/selftest.c
sfc: Use separate hardware TX queues to select checksum generation
[linux-2.6-omap-h63xx.git] / drivers / net / sfc / selftest.c
index cbda15946e8f57585aa8cda81a39ed5e106c3b50..0a4778629178fd77e0b26c999162dbb3c026ab7f 100644 (file)
@@ -63,6 +63,10 @@ struct efx_selftest_state {
        int flush;
        int packet_count;
        struct sk_buff **skbs;
+
+       /* Checksums are being offloaded */
+       int offload_csum;
+
        atomic_t rx_good;
        atomic_t rx_bad;
        struct efx_loopback_payload payload;
@@ -290,10 +294,11 @@ void efx_loopback_rx_packet(struct efx_nic *efx,
 
        payload = &state->payload;
        
-       received = (struct efx_loopback_payload *)(char *) buf_ptr;
+       received = (struct efx_loopback_payload *) buf_ptr;
        received->ip.saddr = payload->ip.saddr;
-       received->ip.check = payload->ip.check;
-       
+       if (state->offload_csum)
+               received->ip.check = payload->ip.check;
+
        /* Check that header exists */
        if (pkt_len < sizeof(received->header)) {
                EFX_ERR(efx, "saw runt RX packet (length %d) in %s loopback "
@@ -424,10 +429,10 @@ static int efx_tx_loopback(struct efx_tx_queue *tx_queue)
                 * interrupt handler. */
                smp_wmb();
 
-               if (NET_DEV_REGISTERED(efx))
+               if (efx_dev_registered(efx))
                        netif_tx_lock_bh(efx->net_dev);
                rc = efx_xmit(efx, tx_queue, skb);
-               if (NET_DEV_REGISTERED(efx))
+               if (efx_dev_registered(efx))
                        netif_tx_unlock_bh(efx->net_dev);
 
                if (rc != NETDEV_TX_OK) {
@@ -453,7 +458,7 @@ static int efx_rx_loopback(struct efx_tx_queue *tx_queue,
        int tx_done = 0, rx_good, rx_bad;
        int i, rc = 0;
 
-       if (NET_DEV_REGISTERED(efx))
+       if (efx_dev_registered(efx))
                netif_tx_lock_bh(efx->net_dev);
 
        /* Count the number of tx completions, and decrement the refcnt. Any
@@ -465,7 +470,7 @@ static int efx_rx_loopback(struct efx_tx_queue *tx_queue,
                dev_kfree_skb_any(skb);
        }
 
-       if (NET_DEV_REGISTERED(efx))
+       if (efx_dev_registered(efx))
                netif_tx_unlock_bh(efx->net_dev);
 
        /* Check TX completion and received packet counts */
@@ -517,6 +522,8 @@ efx_test_loopback(struct efx_tx_queue *tx_queue,
                state->packet_count = min(1 << (i << 2), state->packet_count);
                state->skbs = kzalloc(sizeof(state->skbs[0]) *
                                      state->packet_count, GFP_KERNEL);
+               if (!state->skbs)
+                       return -ENOMEM;
                state->flush = 0;
 
                EFX_LOG(efx, "TX queue %d testing %s loopback with %d "
@@ -632,6 +639,8 @@ static int efx_test_loopbacks(struct efx_nic *efx,
 
                /* Test every TX queue */
                efx_for_each_tx_queue(tx_queue, efx) {
+                       state->offload_csum = (tx_queue->queue ==
+                                              EFX_TX_QUEUE_OFFLOAD_CSUM);
                        rc |= efx_test_loopback(tx_queue,
                                                &tests->loopback[mode]);
                        if (rc)
@@ -700,7 +709,7 @@ int efx_offline_test(struct efx_nic *efx,
         * "flushing" so all inflight packets are dropped */
        BUG_ON(efx->loopback_selftest);
        state->flush = 1;
-       efx->loopback_selftest = (void *)state;
+       efx->loopback_selftest = state;
 
        rc = efx_test_loopbacks(efx, tests, loopback_modes);