aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath5k/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath5k/debug.c')
-rw-r--r--drivers/net/wireless/ath/ath5k/debug.c212
1 files changed, 212 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index 747508c15d34..bccd4a78027e 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -364,6 +364,207 @@ static const struct file_operations fops_debug = {
364}; 364};
365 365
366 366
367/* debugfs: antenna */
368
369static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
370 size_t count, loff_t *ppos)
371{
372 struct ath5k_softc *sc = file->private_data;
373 char buf[700];
374 unsigned int len = 0;
375 unsigned int i;
376 unsigned int v;
377
378 len += snprintf(buf+len, sizeof(buf)-len, "antenna mode\t%d\n",
379 sc->ah->ah_ant_mode);
380 len += snprintf(buf+len, sizeof(buf)-len, "default antenna\t%d\n",
381 sc->ah->ah_def_ant);
382 len += snprintf(buf+len, sizeof(buf)-len, "tx antenna\t%d\n",
383 sc->ah->ah_tx_ant);
384
385 len += snprintf(buf+len, sizeof(buf)-len, "\nANTENNA\t\tRX\tTX\n");
386 for (i = 1; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) {
387 len += snprintf(buf+len, sizeof(buf)-len,
388 "[antenna %d]\t%d\t%d\n",
389 i, sc->stats.antenna_rx[i], sc->stats.antenna_tx[i]);
390 }
391 len += snprintf(buf+len, sizeof(buf)-len, "[invalid]\t%d\t%d\n",
392 sc->stats.antenna_rx[0], sc->stats.antenna_tx[0]);
393
394 v = ath5k_hw_reg_read(sc->ah, AR5K_DEFAULT_ANTENNA);
395 len += snprintf(buf+len, sizeof(buf)-len,
396 "\nAR5K_DEFAULT_ANTENNA\t0x%08x\n", v);
397
398 v = ath5k_hw_reg_read(sc->ah, AR5K_STA_ID1);
399 len += snprintf(buf+len, sizeof(buf)-len,
400 "AR5K_STA_ID1_DEFAULT_ANTENNA\t%d\n",
401 (v & AR5K_STA_ID1_DEFAULT_ANTENNA) != 0);
402 len += snprintf(buf+len, sizeof(buf)-len,
403 "AR5K_STA_ID1_DESC_ANTENNA\t%d\n",
404 (v & AR5K_STA_ID1_DESC_ANTENNA) != 0);
405 len += snprintf(buf+len, sizeof(buf)-len,
406 "AR5K_STA_ID1_RTS_DEF_ANTENNA\t%d\n",
407 (v & AR5K_STA_ID1_RTS_DEF_ANTENNA) != 0);
408 len += snprintf(buf+len, sizeof(buf)-len,
409 "AR5K_STA_ID1_SELFGEN_DEF_ANT\t%d\n",
410 (v & AR5K_STA_ID1_SELFGEN_DEF_ANT) != 0);
411
412 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_AGCCTL);
413 len += snprintf(buf+len, sizeof(buf)-len,
414 "\nAR5K_PHY_AGCCTL_OFDM_DIV_DIS\t%d\n",
415 (v & AR5K_PHY_AGCCTL_OFDM_DIV_DIS) != 0);
416
417 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_RESTART);
418 len += snprintf(buf+len, sizeof(buf)-len,
419 "AR5K_PHY_RESTART_DIV_GC\t\t%x\n",
420 (v & AR5K_PHY_RESTART_DIV_GC) >> AR5K_PHY_RESTART_DIV_GC_S);
421
422 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_FAST_ANT_DIV);
423 len += snprintf(buf+len, sizeof(buf)-len,
424 "AR5K_PHY_FAST_ANT_DIV_EN\t%d\n",
425 (v & AR5K_PHY_FAST_ANT_DIV_EN) != 0);
426
427 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
428}
429
430static ssize_t write_file_antenna(struct file *file,
431 const char __user *userbuf,
432 size_t count, loff_t *ppos)
433{
434 struct ath5k_softc *sc = file->private_data;
435 unsigned int i;
436 char buf[20];
437
438 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
439 return -EFAULT;
440
441 if (strncmp(buf, "diversity", 9) == 0) {
442 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_DEFAULT);
443 printk(KERN_INFO "ath5k debug: enable diversity\n");
444 } else if (strncmp(buf, "fixed-a", 7) == 0) {
445 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_A);
446 printk(KERN_INFO "ath5k debugfs: fixed antenna A\n");
447 } else if (strncmp(buf, "fixed-b", 7) == 0) {
448 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_B);
449 printk(KERN_INFO "ath5k debug: fixed antenna B\n");
450 } else if (strncmp(buf, "clear", 5) == 0) {
451 for (i = 0; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) {
452 sc->stats.antenna_rx[i] = 0;
453 sc->stats.antenna_tx[i] = 0;
454 }
455 printk(KERN_INFO "ath5k debug: cleared antenna stats\n");
456 }
457 return count;
458}
459
460static const struct file_operations fops_antenna = {
461 .read = read_file_antenna,
462 .write = write_file_antenna,
463 .open = ath5k_debugfs_open,
464 .owner = THIS_MODULE,
465};
466
467
468/* debugfs: frameerrors */
469
470static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf,
471 size_t count, loff_t *ppos)
472{
473 struct ath5k_softc *sc = file->private_data;
474 struct ath5k_statistics *st = &sc->stats;
475 char buf[700];
476 unsigned int len = 0;
477
478 len += snprintf(buf+len, sizeof(buf)-len,
479 "RX\n---------------------\n");
480 len += snprintf(buf+len, sizeof(buf)-len, "CRC\t%d\t(%d%%)\n",
481 st->rxerr_crc,
482 st->rx_all_count > 0 ?
483 st->rxerr_crc*100/st->rx_all_count : 0);
484 len += snprintf(buf+len, sizeof(buf)-len, "PHY\t%d\t(%d%%)\n",
485 st->rxerr_phy,
486 st->rx_all_count > 0 ?
487 st->rxerr_phy*100/st->rx_all_count : 0);
488 len += snprintf(buf+len, sizeof(buf)-len, "FIFO\t%d\t(%d%%)\n",
489 st->rxerr_fifo,
490 st->rx_all_count > 0 ?
491 st->rxerr_fifo*100/st->rx_all_count : 0);
492 len += snprintf(buf+len, sizeof(buf)-len, "decrypt\t%d\t(%d%%)\n",
493 st->rxerr_decrypt,
494 st->rx_all_count > 0 ?
495 st->rxerr_decrypt*100/st->rx_all_count : 0);
496 len += snprintf(buf+len, sizeof(buf)-len, "MIC\t%d\t(%d%%)\n",
497 st->rxerr_mic,
498 st->rx_all_count > 0 ?
499 st->rxerr_mic*100/st->rx_all_count : 0);
500 len += snprintf(buf+len, sizeof(buf)-len, "process\t%d\t(%d%%)\n",
501 st->rxerr_proc,
502 st->rx_all_count > 0 ?
503 st->rxerr_proc*100/st->rx_all_count : 0);
504 len += snprintf(buf+len, sizeof(buf)-len, "jumbo\t%d\t(%d%%)\n",
505 st->rxerr_jumbo,
506 st->rx_all_count > 0 ?
507 st->rxerr_jumbo*100/st->rx_all_count : 0);
508 len += snprintf(buf+len, sizeof(buf)-len, "[RX all\t%d]\n",
509 st->rx_all_count);
510
511 len += snprintf(buf+len, sizeof(buf)-len,
512 "\nTX\n---------------------\n");
513 len += snprintf(buf+len, sizeof(buf)-len, "retry\t%d\t(%d%%)\n",
514 st->txerr_retry,
515 st->tx_all_count > 0 ?
516 st->txerr_retry*100/st->tx_all_count : 0);
517 len += snprintf(buf+len, sizeof(buf)-len, "FIFO\t%d\t(%d%%)\n",
518 st->txerr_fifo,
519 st->tx_all_count > 0 ?
520 st->txerr_fifo*100/st->tx_all_count : 0);
521 len += snprintf(buf+len, sizeof(buf)-len, "filter\t%d\t(%d%%)\n",
522 st->txerr_filt,
523 st->tx_all_count > 0 ?
524 st->txerr_filt*100/st->tx_all_count : 0);
525 len += snprintf(buf+len, sizeof(buf)-len, "[TX all\t%d]\n",
526 st->tx_all_count);
527
528 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
529}
530
531static ssize_t write_file_frameerrors(struct file *file,
532 const char __user *userbuf,
533 size_t count, loff_t *ppos)
534{
535 struct ath5k_softc *sc = file->private_data;
536 struct ath5k_statistics *st = &sc->stats;
537 char buf[20];
538
539 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
540 return -EFAULT;
541
542 if (strncmp(buf, "clear", 5) == 0) {
543 st->rxerr_crc = 0;
544 st->rxerr_phy = 0;
545 st->rxerr_fifo = 0;
546 st->rxerr_decrypt = 0;
547 st->rxerr_mic = 0;
548 st->rxerr_proc = 0;
549 st->rxerr_jumbo = 0;
550 st->rx_all_count = 0;
551 st->txerr_retry = 0;
552 st->txerr_fifo = 0;
553 st->txerr_filt = 0;
554 st->tx_all_count = 0;
555 printk(KERN_INFO "ath5k debug: cleared frameerrors stats\n");
556 }
557 return count;
558}
559
560static const struct file_operations fops_frameerrors = {
561 .read = read_file_frameerrors,
562 .write = write_file_frameerrors,
563 .open = ath5k_debugfs_open,
564 .owner = THIS_MODULE,
565};
566
567
367/* init */ 568/* init */
368 569
369void 570void
@@ -393,6 +594,15 @@ ath5k_debug_init_device(struct ath5k_softc *sc)
393 594
394 sc->debug.debugfs_reset = debugfs_create_file("reset", S_IWUSR, 595 sc->debug.debugfs_reset = debugfs_create_file("reset", S_IWUSR,
395 sc->debug.debugfs_phydir, sc, &fops_reset); 596 sc->debug.debugfs_phydir, sc, &fops_reset);
597
598 sc->debug.debugfs_antenna = debugfs_create_file("antenna",
599 S_IWUSR | S_IRUSR,
600 sc->debug.debugfs_phydir, sc, &fops_antenna);
601
602 sc->debug.debugfs_frameerrors = debugfs_create_file("frameerrors",
603 S_IWUSR | S_IRUSR,
604 sc->debug.debugfs_phydir, sc,
605 &fops_frameerrors);
396} 606}
397 607
398void 608void
@@ -408,6 +618,8 @@ ath5k_debug_finish_device(struct ath5k_softc *sc)
408 debugfs_remove(sc->debug.debugfs_registers); 618 debugfs_remove(sc->debug.debugfs_registers);
409 debugfs_remove(sc->debug.debugfs_beacon); 619 debugfs_remove(sc->debug.debugfs_beacon);
410 debugfs_remove(sc->debug.debugfs_reset); 620 debugfs_remove(sc->debug.debugfs_reset);
621 debugfs_remove(sc->debug.debugfs_antenna);
622 debugfs_remove(sc->debug.debugfs_frameerrors);
411 debugfs_remove(sc->debug.debugfs_phydir); 623 debugfs_remove(sc->debug.debugfs_phydir);
412} 624}
413 625