diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2010-06-23 07:30:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-06-25 01:13:22 -0400 |
commit | 62776d034cc40c49bafdb3551a6ba35f78e3f08d (patch) | |
tree | 1cd2132940ced266ad53619a0c947e153cc83a5e /drivers/net/sfc/selftest.c | |
parent | 0c605a2061670412d3b5580c92f1e161b1a693d2 (diff) |
sfc: Implement message level control
Replace EFX_ERR() with netif_err(), EFX_INFO() with netif_info(),
EFX_LOG() with netif_dbg() and EFX_TRACE() and EFX_REGDUMP() with
netif_vdbg().
Replace EFX_ERR_RL(), EFX_INFO_RL() and EFX_LOG_RL() using explicit
calls to net_ratelimit().
Implement the ethtool operations to get and set message level flags,
and add a 'debug' module parameter for the initial value.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sfc/selftest.c')
-rw-r--r-- | drivers/net/sfc/selftest.c | 126 |
1 files changed, 73 insertions, 53 deletions
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c index 1f83404af63b..85f015f005d5 100644 --- a/drivers/net/sfc/selftest.c +++ b/drivers/net/sfc/selftest.c | |||
@@ -123,7 +123,7 @@ static int efx_test_interrupts(struct efx_nic *efx, | |||
123 | { | 123 | { |
124 | struct efx_channel *channel; | 124 | struct efx_channel *channel; |
125 | 125 | ||
126 | EFX_LOG(efx, "testing interrupts\n"); | 126 | netif_dbg(efx, drv, efx->net_dev, "testing interrupts\n"); |
127 | tests->interrupt = -1; | 127 | tests->interrupt = -1; |
128 | 128 | ||
129 | /* Reset interrupt flag */ | 129 | /* Reset interrupt flag */ |
@@ -142,16 +142,17 @@ static int efx_test_interrupts(struct efx_nic *efx, | |||
142 | efx_nic_generate_interrupt(efx); | 142 | efx_nic_generate_interrupt(efx); |
143 | 143 | ||
144 | /* Wait for arrival of test interrupt. */ | 144 | /* Wait for arrival of test interrupt. */ |
145 | EFX_LOG(efx, "waiting for test interrupt\n"); | 145 | netif_dbg(efx, drv, efx->net_dev, "waiting for test interrupt\n"); |
146 | schedule_timeout_uninterruptible(HZ / 10); | 146 | schedule_timeout_uninterruptible(HZ / 10); |
147 | if (efx->last_irq_cpu >= 0) | 147 | if (efx->last_irq_cpu >= 0) |
148 | goto success; | 148 | goto success; |
149 | 149 | ||
150 | EFX_ERR(efx, "timed out waiting for interrupt\n"); | 150 | netif_err(efx, drv, efx->net_dev, "timed out waiting for interrupt\n"); |
151 | return -ETIMEDOUT; | 151 | return -ETIMEDOUT; |
152 | 152 | ||
153 | success: | 153 | success: |
154 | EFX_LOG(efx, "%s test interrupt seen on CPU%d\n", INT_MODE(efx), | 154 | netif_dbg(efx, drv, efx->net_dev, "%s test interrupt seen on CPU%d\n", |
155 | INT_MODE(efx), | ||
155 | efx->last_irq_cpu); | 156 | efx->last_irq_cpu); |
156 | tests->interrupt = 1; | 157 | tests->interrupt = 1; |
157 | return 0; | 158 | return 0; |
@@ -161,6 +162,7 @@ static int efx_test_interrupts(struct efx_nic *efx, | |||
161 | static int efx_test_eventq_irq(struct efx_channel *channel, | 162 | static int efx_test_eventq_irq(struct efx_channel *channel, |
162 | struct efx_self_tests *tests) | 163 | struct efx_self_tests *tests) |
163 | { | 164 | { |
165 | struct efx_nic *efx = channel->efx; | ||
164 | unsigned int magic_count, count; | 166 | unsigned int magic_count, count; |
165 | 167 | ||
166 | tests->eventq_dma[channel->channel] = -1; | 168 | tests->eventq_dma[channel->channel] = -1; |
@@ -185,29 +187,32 @@ static int efx_test_eventq_irq(struct efx_channel *channel, | |||
185 | goto eventq_ok; | 187 | goto eventq_ok; |
186 | } while (++count < 2); | 188 | } while (++count < 2); |
187 | 189 | ||
188 | EFX_ERR(channel->efx, "channel %d timed out waiting for event queue\n", | 190 | netif_err(efx, drv, efx->net_dev, |
189 | channel->channel); | 191 | "channel %d timed out waiting for event queue\n", |
192 | channel->channel); | ||
190 | 193 | ||
191 | /* See if interrupt arrived */ | 194 | /* See if interrupt arrived */ |
192 | if (channel->efx->last_irq_cpu >= 0) { | 195 | if (channel->efx->last_irq_cpu >= 0) { |
193 | EFX_ERR(channel->efx, "channel %d saw interrupt on CPU%d " | 196 | netif_err(efx, drv, efx->net_dev, |
194 | "during event queue test\n", channel->channel, | 197 | "channel %d saw interrupt on CPU%d " |
195 | raw_smp_processor_id()); | 198 | "during event queue test\n", channel->channel, |
199 | raw_smp_processor_id()); | ||
196 | tests->eventq_int[channel->channel] = 1; | 200 | tests->eventq_int[channel->channel] = 1; |
197 | } | 201 | } |
198 | 202 | ||
199 | /* Check to see if event was received even if interrupt wasn't */ | 203 | /* Check to see if event was received even if interrupt wasn't */ |
200 | efx_process_channel_now(channel); | 204 | efx_process_channel_now(channel); |
201 | if (channel->magic_count != magic_count) { | 205 | if (channel->magic_count != magic_count) { |
202 | EFX_ERR(channel->efx, "channel %d event was generated, but " | 206 | netif_err(efx, drv, efx->net_dev, |
203 | "failed to trigger an interrupt\n", channel->channel); | 207 | "channel %d event was generated, but " |
208 | "failed to trigger an interrupt\n", channel->channel); | ||
204 | tests->eventq_dma[channel->channel] = 1; | 209 | tests->eventq_dma[channel->channel] = 1; |
205 | } | 210 | } |
206 | 211 | ||
207 | return -ETIMEDOUT; | 212 | return -ETIMEDOUT; |
208 | eventq_ok: | 213 | eventq_ok: |
209 | EFX_LOG(channel->efx, "channel %d event queue passed\n", | 214 | netif_dbg(efx, drv, efx->net_dev, "channel %d event queue passed\n", |
210 | channel->channel); | 215 | channel->channel); |
211 | tests->eventq_dma[channel->channel] = 1; | 216 | tests->eventq_dma[channel->channel] = 1; |
212 | tests->eventq_int[channel->channel] = 1; | 217 | tests->eventq_int[channel->channel] = 1; |
213 | tests->eventq_poll[channel->channel] = 1; | 218 | tests->eventq_poll[channel->channel] = 1; |
@@ -260,51 +265,57 @@ void efx_loopback_rx_packet(struct efx_nic *efx, | |||
260 | 265 | ||
261 | /* Check that header exists */ | 266 | /* Check that header exists */ |
262 | if (pkt_len < sizeof(received->header)) { | 267 | if (pkt_len < sizeof(received->header)) { |
263 | EFX_ERR(efx, "saw runt RX packet (length %d) in %s loopback " | 268 | netif_err(efx, drv, efx->net_dev, |
264 | "test\n", pkt_len, LOOPBACK_MODE(efx)); | 269 | "saw runt RX packet (length %d) in %s loopback " |
270 | "test\n", pkt_len, LOOPBACK_MODE(efx)); | ||
265 | goto err; | 271 | goto err; |
266 | } | 272 | } |
267 | 273 | ||
268 | /* Check that the ethernet header exists */ | 274 | /* Check that the ethernet header exists */ |
269 | if (memcmp(&received->header, &payload->header, ETH_HLEN) != 0) { | 275 | if (memcmp(&received->header, &payload->header, ETH_HLEN) != 0) { |
270 | EFX_ERR(efx, "saw non-loopback RX packet in %s loopback test\n", | 276 | netif_err(efx, drv, efx->net_dev, |
271 | LOOPBACK_MODE(efx)); | 277 | "saw non-loopback RX packet in %s loopback test\n", |
278 | LOOPBACK_MODE(efx)); | ||
272 | goto err; | 279 | goto err; |
273 | } | 280 | } |
274 | 281 | ||
275 | /* Check packet length */ | 282 | /* Check packet length */ |
276 | if (pkt_len != sizeof(*payload)) { | 283 | if (pkt_len != sizeof(*payload)) { |
277 | EFX_ERR(efx, "saw incorrect RX packet length %d (wanted %d) in " | 284 | netif_err(efx, drv, efx->net_dev, |
278 | "%s loopback test\n", pkt_len, (int)sizeof(*payload), | 285 | "saw incorrect RX packet length %d (wanted %d) in " |
279 | LOOPBACK_MODE(efx)); | 286 | "%s loopback test\n", pkt_len, (int)sizeof(*payload), |
287 | LOOPBACK_MODE(efx)); | ||
280 | goto err; | 288 | goto err; |
281 | } | 289 | } |
282 | 290 | ||
283 | /* Check that IP header matches */ | 291 | /* Check that IP header matches */ |
284 | if (memcmp(&received->ip, &payload->ip, sizeof(payload->ip)) != 0) { | 292 | if (memcmp(&received->ip, &payload->ip, sizeof(payload->ip)) != 0) { |
285 | EFX_ERR(efx, "saw corrupted IP header in %s loopback test\n", | 293 | netif_err(efx, drv, efx->net_dev, |
286 | LOOPBACK_MODE(efx)); | 294 | "saw corrupted IP header in %s loopback test\n", |
295 | LOOPBACK_MODE(efx)); | ||
287 | goto err; | 296 | goto err; |
288 | } | 297 | } |
289 | 298 | ||
290 | /* Check that msg and padding matches */ | 299 | /* Check that msg and padding matches */ |
291 | if (memcmp(&received->msg, &payload->msg, sizeof(received->msg)) != 0) { | 300 | if (memcmp(&received->msg, &payload->msg, sizeof(received->msg)) != 0) { |
292 | EFX_ERR(efx, "saw corrupted RX packet in %s loopback test\n", | 301 | netif_err(efx, drv, efx->net_dev, |
293 | LOOPBACK_MODE(efx)); | 302 | "saw corrupted RX packet in %s loopback test\n", |
303 | LOOPBACK_MODE(efx)); | ||
294 | goto err; | 304 | goto err; |
295 | } | 305 | } |
296 | 306 | ||
297 | /* Check that iteration matches */ | 307 | /* Check that iteration matches */ |
298 | if (received->iteration != payload->iteration) { | 308 | if (received->iteration != payload->iteration) { |
299 | EFX_ERR(efx, "saw RX packet from iteration %d (wanted %d) in " | 309 | netif_err(efx, drv, efx->net_dev, |
300 | "%s loopback test\n", ntohs(received->iteration), | 310 | "saw RX packet from iteration %d (wanted %d) in " |
301 | ntohs(payload->iteration), LOOPBACK_MODE(efx)); | 311 | "%s loopback test\n", ntohs(received->iteration), |
312 | ntohs(payload->iteration), LOOPBACK_MODE(efx)); | ||
302 | goto err; | 313 | goto err; |
303 | } | 314 | } |
304 | 315 | ||
305 | /* Increase correct RX count */ | 316 | /* Increase correct RX count */ |
306 | EFX_TRACE(efx, "got loopback RX in %s loopback test\n", | 317 | netif_vdbg(efx, drv, efx->net_dev, |
307 | LOOPBACK_MODE(efx)); | 318 | "got loopback RX in %s loopback test\n", LOOPBACK_MODE(efx)); |
308 | 319 | ||
309 | atomic_inc(&state->rx_good); | 320 | atomic_inc(&state->rx_good); |
310 | return; | 321 | return; |
@@ -312,10 +323,10 @@ void efx_loopback_rx_packet(struct efx_nic *efx, | |||
312 | err: | 323 | err: |
313 | #ifdef EFX_ENABLE_DEBUG | 324 | #ifdef EFX_ENABLE_DEBUG |
314 | if (atomic_read(&state->rx_bad) == 0) { | 325 | if (atomic_read(&state->rx_bad) == 0) { |
315 | EFX_ERR(efx, "received packet:\n"); | 326 | netif_err(efx, drv, efx->net_dev, "received packet:\n"); |
316 | print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1, | 327 | print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1, |
317 | buf_ptr, pkt_len, 0); | 328 | buf_ptr, pkt_len, 0); |
318 | EFX_ERR(efx, "expected packet:\n"); | 329 | netif_err(efx, drv, efx->net_dev, "expected packet:\n"); |
319 | print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1, | 330 | print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1, |
320 | &state->payload, sizeof(state->payload), 0); | 331 | &state->payload, sizeof(state->payload), 0); |
321 | } | 332 | } |
@@ -396,9 +407,11 @@ static int efx_begin_loopback(struct efx_tx_queue *tx_queue) | |||
396 | netif_tx_unlock_bh(efx->net_dev); | 407 | netif_tx_unlock_bh(efx->net_dev); |
397 | 408 | ||
398 | if (rc != NETDEV_TX_OK) { | 409 | if (rc != NETDEV_TX_OK) { |
399 | EFX_ERR(efx, "TX queue %d could not transmit packet %d " | 410 | netif_err(efx, drv, efx->net_dev, |
400 | "of %d in %s loopback test\n", tx_queue->queue, | 411 | "TX queue %d could not transmit packet %d of " |
401 | i + 1, state->packet_count, LOOPBACK_MODE(efx)); | 412 | "%d in %s loopback test\n", tx_queue->queue, |
413 | i + 1, state->packet_count, | ||
414 | LOOPBACK_MODE(efx)); | ||
402 | 415 | ||
403 | /* Defer cleaning up the other skbs for the caller */ | 416 | /* Defer cleaning up the other skbs for the caller */ |
404 | kfree_skb(skb); | 417 | kfree_skb(skb); |
@@ -454,20 +467,22 @@ static int efx_end_loopback(struct efx_tx_queue *tx_queue, | |||
454 | /* Don't free the skbs; they will be picked up on TX | 467 | /* Don't free the skbs; they will be picked up on TX |
455 | * overflow or channel teardown. | 468 | * overflow or channel teardown. |
456 | */ | 469 | */ |
457 | EFX_ERR(efx, "TX queue %d saw only %d out of an expected %d " | 470 | netif_err(efx, drv, efx->net_dev, |
458 | "TX completion events in %s loopback test\n", | 471 | "TX queue %d saw only %d out of an expected %d " |
459 | tx_queue->queue, tx_done, state->packet_count, | 472 | "TX completion events in %s loopback test\n", |
460 | LOOPBACK_MODE(efx)); | 473 | tx_queue->queue, tx_done, state->packet_count, |
474 | LOOPBACK_MODE(efx)); | ||
461 | rc = -ETIMEDOUT; | 475 | rc = -ETIMEDOUT; |
462 | /* Allow to fall through so we see the RX errors as well */ | 476 | /* Allow to fall through so we see the RX errors as well */ |
463 | } | 477 | } |
464 | 478 | ||
465 | /* We may always be up to a flush away from our desired packet total */ | 479 | /* We may always be up to a flush away from our desired packet total */ |
466 | if (rx_good != state->packet_count) { | 480 | if (rx_good != state->packet_count) { |
467 | EFX_LOG(efx, "TX queue %d saw only %d out of an expected %d " | 481 | netif_dbg(efx, drv, efx->net_dev, |
468 | "received packets in %s loopback test\n", | 482 | "TX queue %d saw only %d out of an expected %d " |
469 | tx_queue->queue, rx_good, state->packet_count, | 483 | "received packets in %s loopback test\n", |
470 | LOOPBACK_MODE(efx)); | 484 | tx_queue->queue, rx_good, state->packet_count, |
485 | LOOPBACK_MODE(efx)); | ||
471 | rc = -ETIMEDOUT; | 486 | rc = -ETIMEDOUT; |
472 | /* Fall through */ | 487 | /* Fall through */ |
473 | } | 488 | } |
@@ -499,9 +514,10 @@ efx_test_loopback(struct efx_tx_queue *tx_queue, | |||
499 | return -ENOMEM; | 514 | return -ENOMEM; |
500 | state->flush = false; | 515 | state->flush = false; |
501 | 516 | ||
502 | EFX_LOG(efx, "TX queue %d testing %s loopback with %d " | 517 | netif_dbg(efx, drv, efx->net_dev, |
503 | "packets\n", tx_queue->queue, LOOPBACK_MODE(efx), | 518 | "TX queue %d testing %s loopback with %d packets\n", |
504 | state->packet_count); | 519 | tx_queue->queue, LOOPBACK_MODE(efx), |
520 | state->packet_count); | ||
505 | 521 | ||
506 | efx_iterate_state(efx); | 522 | efx_iterate_state(efx); |
507 | begin_rc = efx_begin_loopback(tx_queue); | 523 | begin_rc = efx_begin_loopback(tx_queue); |
@@ -525,9 +541,10 @@ efx_test_loopback(struct efx_tx_queue *tx_queue, | |||
525 | } | 541 | } |
526 | } | 542 | } |
527 | 543 | ||
528 | EFX_LOG(efx, "TX queue %d passed %s loopback test with a burst length " | 544 | netif_dbg(efx, drv, efx->net_dev, |
529 | "of %d packets\n", tx_queue->queue, LOOPBACK_MODE(efx), | 545 | "TX queue %d passed %s loopback test with a burst length " |
530 | state->packet_count); | 546 | "of %d packets\n", tx_queue->queue, LOOPBACK_MODE(efx), |
547 | state->packet_count); | ||
531 | 548 | ||
532 | return 0; | 549 | return 0; |
533 | } | 550 | } |
@@ -602,15 +619,17 @@ static int efx_test_loopbacks(struct efx_nic *efx, struct efx_self_tests *tests, | |||
602 | rc = __efx_reconfigure_port(efx); | 619 | rc = __efx_reconfigure_port(efx); |
603 | mutex_unlock(&efx->mac_lock); | 620 | mutex_unlock(&efx->mac_lock); |
604 | if (rc) { | 621 | if (rc) { |
605 | EFX_ERR(efx, "unable to move into %s loopback\n", | 622 | netif_err(efx, drv, efx->net_dev, |
606 | LOOPBACK_MODE(efx)); | 623 | "unable to move into %s loopback\n", |
624 | LOOPBACK_MODE(efx)); | ||
607 | goto out; | 625 | goto out; |
608 | } | 626 | } |
609 | 627 | ||
610 | rc = efx_wait_for_link(efx); | 628 | rc = efx_wait_for_link(efx); |
611 | if (rc) { | 629 | if (rc) { |
612 | EFX_ERR(efx, "loopback %s never came up\n", | 630 | netif_err(efx, drv, efx->net_dev, |
613 | LOOPBACK_MODE(efx)); | 631 | "loopback %s never came up\n", |
632 | LOOPBACK_MODE(efx)); | ||
614 | goto out; | 633 | goto out; |
615 | } | 634 | } |
616 | 635 | ||
@@ -718,7 +737,8 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests, | |||
718 | rc_reset = rc; | 737 | rc_reset = rc; |
719 | 738 | ||
720 | if (rc_reset) { | 739 | if (rc_reset) { |
721 | EFX_ERR(efx, "Unable to recover from chip test\n"); | 740 | netif_err(efx, drv, efx->net_dev, |
741 | "Unable to recover from chip test\n"); | ||
722 | efx_schedule_reset(efx, RESET_TYPE_DISABLE); | 742 | efx_schedule_reset(efx, RESET_TYPE_DISABLE); |
723 | return rc_reset; | 743 | return rc_reset; |
724 | } | 744 | } |