Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wlcore: abstract debugfs fw_stats to be handled by the lower drivers

The FW statistics differ from hardware to hardware. This commit
prepares for hardware-specific implementation of the FW statistics
debugfs entries.

Signed-off-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: Arik Nemtsov <arik@wizery.com>

+105 -491
+2 -2
drivers/net/wireless/ti/wlcore/acx.c
··· 709 709 return ret; 710 710 } 711 711 712 - int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats) 712 + int wl1271_acx_statistics(struct wl1271 *wl, void *stats) 713 713 { 714 714 int ret; 715 715 716 716 wl1271_debug(DEBUG_ACX, "acx statistics"); 717 717 718 718 ret = wl1271_cmd_interrogate(wl, ACX_STATISTICS, stats, 719 - sizeof(*stats)); 719 + wl->stats.fw_stats_len); 720 720 if (ret < 0) { 721 721 wl1271_warning("acx statistics failed: %d", ret); 722 722 return -ENOMEM;
+1 -223
drivers/net/wireless/ti/wlcore/acx.h
··· 417 417 u8 padding[2]; 418 418 } __packed; 419 419 420 - struct acx_tx_statistics { 421 - __le32 internal_desc_overflow; 422 - } __packed; 423 - 424 - struct acx_rx_statistics { 425 - __le32 out_of_mem; 426 - __le32 hdr_overflow; 427 - __le32 hw_stuck; 428 - __le32 dropped; 429 - __le32 fcs_err; 430 - __le32 xfr_hint_trig; 431 - __le32 path_reset; 432 - __le32 reset_counter; 433 - } __packed; 434 - 435 - struct acx_dma_statistics { 436 - __le32 rx_requested; 437 - __le32 rx_errors; 438 - __le32 tx_requested; 439 - __le32 tx_errors; 440 - } __packed; 441 - 442 - struct acx_isr_statistics { 443 - /* host command complete */ 444 - __le32 cmd_cmplt; 445 - 446 - /* fiqisr() */ 447 - __le32 fiqs; 448 - 449 - /* (INT_STS_ND & INT_TRIG_RX_HEADER) */ 450 - __le32 rx_headers; 451 - 452 - /* (INT_STS_ND & INT_TRIG_RX_CMPLT) */ 453 - __le32 rx_completes; 454 - 455 - /* (INT_STS_ND & INT_TRIG_NO_RX_BUF) */ 456 - __le32 rx_mem_overflow; 457 - 458 - /* (INT_STS_ND & INT_TRIG_S_RX_RDY) */ 459 - __le32 rx_rdys; 460 - 461 - /* irqisr() */ 462 - __le32 irqs; 463 - 464 - /* (INT_STS_ND & INT_TRIG_TX_PROC) */ 465 - __le32 tx_procs; 466 - 467 - /* (INT_STS_ND & INT_TRIG_DECRYPT_DONE) */ 468 - __le32 decrypt_done; 469 - 470 - /* (INT_STS_ND & INT_TRIG_DMA0) */ 471 - __le32 dma0_done; 472 - 473 - /* (INT_STS_ND & INT_TRIG_DMA1) */ 474 - __le32 dma1_done; 475 - 476 - /* (INT_STS_ND & INT_TRIG_TX_EXC_CMPLT) */ 477 - __le32 tx_exch_complete; 478 - 479 - /* (INT_STS_ND & INT_TRIG_COMMAND) */ 480 - __le32 commands; 481 - 482 - /* (INT_STS_ND & INT_TRIG_RX_PROC) */ 483 - __le32 rx_procs; 484 - 485 - /* (INT_STS_ND & INT_TRIG_PM_802) */ 486 - __le32 hw_pm_mode_changes; 487 - 488 - /* (INT_STS_ND & INT_TRIG_ACKNOWLEDGE) */ 489 - __le32 host_acknowledges; 490 - 491 - /* (INT_STS_ND & INT_TRIG_PM_PCI) */ 492 - __le32 pci_pm; 493 - 494 - /* (INT_STS_ND & INT_TRIG_ACM_WAKEUP) */ 495 - __le32 wakeups; 496 - 497 - /* (INT_STS_ND & INT_TRIG_LOW_RSSI) */ 498 - __le32 low_rssi; 499 - } __packed; 500 - 501 - struct acx_wep_statistics { 502 - /* WEP address keys configured */ 503 - __le32 addr_key_count; 504 - 505 - /* default keys configured */ 506 - __le32 default_key_count; 507 - 508 - __le32 reserved; 509 - 510 - /* number of times that WEP key not found on lookup */ 511 - __le32 key_not_found; 512 - 513 - /* number of times that WEP key decryption failed */ 514 - __le32 decrypt_fail; 515 - 516 - /* WEP packets decrypted */ 517 - __le32 packets; 518 - 519 - /* WEP decrypt interrupts */ 520 - __le32 interrupt; 521 - } __packed; 522 - 523 - #define ACX_MISSED_BEACONS_SPREAD 10 524 - 525 - struct acx_pwr_statistics { 526 - /* the amount of enters into power save mode (both PD & ELP) */ 527 - __le32 ps_enter; 528 - 529 - /* the amount of enters into ELP mode */ 530 - __le32 elp_enter; 531 - 532 - /* the amount of missing beacon interrupts to the host */ 533 - __le32 missing_bcns; 534 - 535 - /* the amount of wake on host-access times */ 536 - __le32 wake_on_host; 537 - 538 - /* the amount of wake on timer-expire */ 539 - __le32 wake_on_timer_exp; 540 - 541 - /* the number of packets that were transmitted with PS bit set */ 542 - __le32 tx_with_ps; 543 - 544 - /* the number of packets that were transmitted with PS bit clear */ 545 - __le32 tx_without_ps; 546 - 547 - /* the number of received beacons */ 548 - __le32 rcvd_beacons; 549 - 550 - /* the number of entering into PowerOn (power save off) */ 551 - __le32 power_save_off; 552 - 553 - /* the number of entries into power save mode */ 554 - __le16 enable_ps; 555 - 556 - /* 557 - * the number of exits from power save, not including failed PS 558 - * transitions 559 - */ 560 - __le16 disable_ps; 561 - 562 - /* 563 - * the number of times the TSF counter was adjusted because 564 - * of drift 565 - */ 566 - __le32 fix_tsf_ps; 567 - 568 - /* Gives statistics about the spread continuous missed beacons. 569 - * The 16 LSB are dedicated for the PS mode. 570 - * The 16 MSB are dedicated for the PS mode. 571 - * cont_miss_bcns_spread[0] - single missed beacon. 572 - * cont_miss_bcns_spread[1] - two continuous missed beacons. 573 - * cont_miss_bcns_spread[2] - three continuous missed beacons. 574 - * ... 575 - * cont_miss_bcns_spread[9] - ten and more continuous missed beacons. 576 - */ 577 - __le32 cont_miss_bcns_spread[ACX_MISSED_BEACONS_SPREAD]; 578 - 579 - /* the number of beacons in awake mode */ 580 - __le32 rcvd_awake_beacons; 581 - } __packed; 582 - 583 - struct acx_mic_statistics { 584 - __le32 rx_pkts; 585 - __le32 calc_failure; 586 - } __packed; 587 - 588 - struct acx_aes_statistics { 589 - __le32 encrypt_fail; 590 - __le32 decrypt_fail; 591 - __le32 encrypt_packets; 592 - __le32 decrypt_packets; 593 - __le32 encrypt_interrupt; 594 - __le32 decrypt_interrupt; 595 - } __packed; 596 - 597 - struct acx_event_statistics { 598 - __le32 heart_beat; 599 - __le32 calibration; 600 - __le32 rx_mismatch; 601 - __le32 rx_mem_empty; 602 - __le32 rx_pool; 603 - __le32 oom_late; 604 - __le32 phy_transmit_error; 605 - __le32 tx_stuck; 606 - } __packed; 607 - 608 - struct acx_ps_statistics { 609 - __le32 pspoll_timeouts; 610 - __le32 upsd_timeouts; 611 - __le32 upsd_max_sptime; 612 - __le32 upsd_max_apturn; 613 - __le32 pspoll_max_apturn; 614 - __le32 pspoll_utilization; 615 - __le32 upsd_utilization; 616 - } __packed; 617 - 618 - struct acx_rxpipe_statistics { 619 - __le32 rx_prep_beacon_drop; 620 - __le32 descr_host_int_trig_rx_data; 621 - __le32 beacon_buffer_thres_host_int_trig_rx_data; 622 - __le32 missed_beacon_host_int_trig_rx_data; 623 - __le32 tx_xfr_host_int_trig_rx_data; 624 - } __packed; 625 - 626 - struct acx_statistics { 627 - struct acx_header header; 628 - 629 - struct acx_tx_statistics tx; 630 - struct acx_rx_statistics rx; 631 - struct acx_dma_statistics dma; 632 - struct acx_isr_statistics isr; 633 - struct acx_wep_statistics wep; 634 - struct acx_pwr_statistics pwr; 635 - struct acx_aes_statistics aes; 636 - struct acx_mic_statistics mic; 637 - struct acx_event_statistics event; 638 - struct acx_ps_statistics ps; 639 - struct acx_rxpipe_statistics rxpipe; 640 - } __packed; 641 - 642 420 struct acx_rate_class { 643 421 __le32 enabled_rates; 644 422 u8 short_retry_limit; ··· 1062 1284 enum acx_preamble_type preamble); 1063 1285 int wl1271_acx_cts_protect(struct wl1271 *wl, struct wl12xx_vif *wlvif, 1064 1286 enum acx_ctsprotect_type ctsprotect); 1065 - int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats); 1287 + int wl1271_acx_statistics(struct wl1271 *wl, void *stats); 1066 1288 int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif); 1067 1289 int wl1271_acx_ap_rate_policy(struct wl1271 *wl, struct conf_tx_rate_class *c, 1068 1290 u8 idx);
+23 -258
drivers/net/wireless/ti/wlcore/debugfs.c
··· 25 25 26 26 #include <linux/skbuff.h> 27 27 #include <linux/slab.h> 28 + #include <linux/module.h> 28 29 29 30 #include "wlcore.h" 30 31 #include "debug.h" ··· 33 32 #include "ps.h" 34 33 #include "io.h" 35 34 #include "tx.h" 35 + #include "hw_ops.h" 36 36 37 37 /* ms */ 38 38 #define WL1271_DEBUGFS_STATS_LIFETIME 1000 39 39 40 40 /* debugfs macros idea from mac80211 */ 41 41 #define DEBUGFS_FORMAT_BUFFER_SIZE 100 42 - static int wl1271_format_buffer(char __user *userbuf, size_t count, 43 - loff_t *ppos, char *fmt, ...) 42 + int wl1271_format_buffer(char __user *userbuf, size_t count, 43 + loff_t *ppos, char *fmt, ...) 44 44 { 45 45 va_list args; 46 46 char buf[DEBUGFS_FORMAT_BUFFER_SIZE]; ··· 53 51 54 52 return simple_read_from_buffer(userbuf, count, ppos, buf, res); 55 53 } 54 + EXPORT_SYMBOL_GPL(wl1271_format_buffer); 56 55 57 - #define DEBUGFS_READONLY_FILE(name, fmt, value...) \ 58 - static ssize_t name## _read(struct file *file, char __user *userbuf, \ 59 - size_t count, loff_t *ppos) \ 60 - { \ 61 - struct wl1271 *wl = file->private_data; \ 62 - return wl1271_format_buffer(userbuf, count, ppos, \ 63 - fmt "\n", ##value); \ 64 - } \ 65 - \ 66 - static const struct file_operations name## _ops = { \ 67 - .read = name## _read, \ 68 - .open = simple_open, \ 69 - .llseek = generic_file_llseek, \ 70 - }; 71 - 72 - #define DEBUGFS_ADD(name, parent) \ 73 - entry = debugfs_create_file(#name, 0400, parent, \ 74 - wl, &name## _ops); \ 75 - if (!entry || IS_ERR(entry)) \ 76 - goto err; \ 77 - 78 - #define DEBUGFS_ADD_PREFIX(prefix, name, parent) \ 79 - do { \ 80 - entry = debugfs_create_file(#name, 0400, parent, \ 81 - wl, &prefix## _## name## _ops); \ 82 - if (!entry || IS_ERR(entry)) \ 83 - goto err; \ 84 - } while (0); 85 - 86 - #define DEBUGFS_FWSTATS_FILE(sub, name, fmt) \ 87 - static ssize_t sub## _ ##name## _read(struct file *file, \ 88 - char __user *userbuf, \ 89 - size_t count, loff_t *ppos) \ 90 - { \ 91 - struct wl1271 *wl = file->private_data; \ 92 - \ 93 - wl1271_debugfs_update_stats(wl); \ 94 - \ 95 - return wl1271_format_buffer(userbuf, count, ppos, fmt "\n", \ 96 - wl->stats.fw_stats->sub.name); \ 97 - } \ 98 - \ 99 - static const struct file_operations sub## _ ##name## _ops = { \ 100 - .read = sub## _ ##name## _read, \ 101 - .open = simple_open, \ 102 - .llseek = generic_file_llseek, \ 103 - }; 104 - 105 - #define DEBUGFS_FWSTATS_ADD(sub, name) \ 106 - DEBUGFS_ADD(sub## _ ##name, stats) 107 - 108 - static void wl1271_debugfs_update_stats(struct wl1271 *wl) 56 + void wl1271_debugfs_update_stats(struct wl1271 *wl) 109 57 { 110 58 int ret; 111 59 ··· 77 125 out: 78 126 mutex_unlock(&wl->mutex); 79 127 } 80 - 81 - DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, "%u"); 82 - 83 - DEBUGFS_FWSTATS_FILE(rx, out_of_mem, "%u"); 84 - DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, "%u"); 85 - DEBUGFS_FWSTATS_FILE(rx, hw_stuck, "%u"); 86 - DEBUGFS_FWSTATS_FILE(rx, dropped, "%u"); 87 - DEBUGFS_FWSTATS_FILE(rx, fcs_err, "%u"); 88 - DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, "%u"); 89 - DEBUGFS_FWSTATS_FILE(rx, path_reset, "%u"); 90 - DEBUGFS_FWSTATS_FILE(rx, reset_counter, "%u"); 91 - 92 - DEBUGFS_FWSTATS_FILE(dma, rx_requested, "%u"); 93 - DEBUGFS_FWSTATS_FILE(dma, rx_errors, "%u"); 94 - DEBUGFS_FWSTATS_FILE(dma, tx_requested, "%u"); 95 - DEBUGFS_FWSTATS_FILE(dma, tx_errors, "%u"); 96 - 97 - DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, "%u"); 98 - DEBUGFS_FWSTATS_FILE(isr, fiqs, "%u"); 99 - DEBUGFS_FWSTATS_FILE(isr, rx_headers, "%u"); 100 - DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, "%u"); 101 - DEBUGFS_FWSTATS_FILE(isr, rx_rdys, "%u"); 102 - DEBUGFS_FWSTATS_FILE(isr, irqs, "%u"); 103 - DEBUGFS_FWSTATS_FILE(isr, tx_procs, "%u"); 104 - DEBUGFS_FWSTATS_FILE(isr, decrypt_done, "%u"); 105 - DEBUGFS_FWSTATS_FILE(isr, dma0_done, "%u"); 106 - DEBUGFS_FWSTATS_FILE(isr, dma1_done, "%u"); 107 - DEBUGFS_FWSTATS_FILE(isr, tx_exch_complete, "%u"); 108 - DEBUGFS_FWSTATS_FILE(isr, commands, "%u"); 109 - DEBUGFS_FWSTATS_FILE(isr, rx_procs, "%u"); 110 - DEBUGFS_FWSTATS_FILE(isr, hw_pm_mode_changes, "%u"); 111 - DEBUGFS_FWSTATS_FILE(isr, host_acknowledges, "%u"); 112 - DEBUGFS_FWSTATS_FILE(isr, pci_pm, "%u"); 113 - DEBUGFS_FWSTATS_FILE(isr, wakeups, "%u"); 114 - DEBUGFS_FWSTATS_FILE(isr, low_rssi, "%u"); 115 - 116 - DEBUGFS_FWSTATS_FILE(wep, addr_key_count, "%u"); 117 - DEBUGFS_FWSTATS_FILE(wep, default_key_count, "%u"); 118 - /* skipping wep.reserved */ 119 - DEBUGFS_FWSTATS_FILE(wep, key_not_found, "%u"); 120 - DEBUGFS_FWSTATS_FILE(wep, decrypt_fail, "%u"); 121 - DEBUGFS_FWSTATS_FILE(wep, packets, "%u"); 122 - DEBUGFS_FWSTATS_FILE(wep, interrupt, "%u"); 123 - 124 - DEBUGFS_FWSTATS_FILE(pwr, ps_enter, "%u"); 125 - DEBUGFS_FWSTATS_FILE(pwr, elp_enter, "%u"); 126 - DEBUGFS_FWSTATS_FILE(pwr, missing_bcns, "%u"); 127 - DEBUGFS_FWSTATS_FILE(pwr, wake_on_host, "%u"); 128 - DEBUGFS_FWSTATS_FILE(pwr, wake_on_timer_exp, "%u"); 129 - DEBUGFS_FWSTATS_FILE(pwr, tx_with_ps, "%u"); 130 - DEBUGFS_FWSTATS_FILE(pwr, tx_without_ps, "%u"); 131 - DEBUGFS_FWSTATS_FILE(pwr, rcvd_beacons, "%u"); 132 - DEBUGFS_FWSTATS_FILE(pwr, power_save_off, "%u"); 133 - DEBUGFS_FWSTATS_FILE(pwr, enable_ps, "%u"); 134 - DEBUGFS_FWSTATS_FILE(pwr, disable_ps, "%u"); 135 - DEBUGFS_FWSTATS_FILE(pwr, fix_tsf_ps, "%u"); 136 - /* skipping cont_miss_bcns_spread for now */ 137 - DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_beacons, "%u"); 138 - 139 - DEBUGFS_FWSTATS_FILE(mic, rx_pkts, "%u"); 140 - DEBUGFS_FWSTATS_FILE(mic, calc_failure, "%u"); 141 - 142 - DEBUGFS_FWSTATS_FILE(aes, encrypt_fail, "%u"); 143 - DEBUGFS_FWSTATS_FILE(aes, decrypt_fail, "%u"); 144 - DEBUGFS_FWSTATS_FILE(aes, encrypt_packets, "%u"); 145 - DEBUGFS_FWSTATS_FILE(aes, decrypt_packets, "%u"); 146 - DEBUGFS_FWSTATS_FILE(aes, encrypt_interrupt, "%u"); 147 - DEBUGFS_FWSTATS_FILE(aes, decrypt_interrupt, "%u"); 148 - 149 - DEBUGFS_FWSTATS_FILE(event, heart_beat, "%u"); 150 - DEBUGFS_FWSTATS_FILE(event, calibration, "%u"); 151 - DEBUGFS_FWSTATS_FILE(event, rx_mismatch, "%u"); 152 - DEBUGFS_FWSTATS_FILE(event, rx_mem_empty, "%u"); 153 - DEBUGFS_FWSTATS_FILE(event, rx_pool, "%u"); 154 - DEBUGFS_FWSTATS_FILE(event, oom_late, "%u"); 155 - DEBUGFS_FWSTATS_FILE(event, phy_transmit_error, "%u"); 156 - DEBUGFS_FWSTATS_FILE(event, tx_stuck, "%u"); 157 - 158 - DEBUGFS_FWSTATS_FILE(ps, pspoll_timeouts, "%u"); 159 - DEBUGFS_FWSTATS_FILE(ps, upsd_timeouts, "%u"); 160 - DEBUGFS_FWSTATS_FILE(ps, upsd_max_sptime, "%u"); 161 - DEBUGFS_FWSTATS_FILE(ps, upsd_max_apturn, "%u"); 162 - DEBUGFS_FWSTATS_FILE(ps, pspoll_max_apturn, "%u"); 163 - DEBUGFS_FWSTATS_FILE(ps, pspoll_utilization, "%u"); 164 - DEBUGFS_FWSTATS_FILE(ps, upsd_utilization, "%u"); 165 - 166 - DEBUGFS_FWSTATS_FILE(rxpipe, rx_prep_beacon_drop, "%u"); 167 - DEBUGFS_FWSTATS_FILE(rxpipe, descr_host_int_trig_rx_data, "%u"); 168 - DEBUGFS_FWSTATS_FILE(rxpipe, beacon_buffer_thres_host_int_trig_rx_data, "%u"); 169 - DEBUGFS_FWSTATS_FILE(rxpipe, missed_beacon_host_int_trig_rx_data, "%u"); 170 - DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, "%u"); 128 + EXPORT_SYMBOL_GPL(wl1271_debugfs_update_stats); 171 129 172 130 DEBUGFS_READONLY_FILE(retry_count, "%u", wl->stats.retry_count); 173 131 DEBUGFS_READONLY_FILE(excessive_retries, "%u", ··· 864 1002 }; 865 1003 866 1004 static int wl1271_debugfs_add_files(struct wl1271 *wl, 867 - struct dentry *rootdir) 1005 + struct dentry *rootdir) 868 1006 { 869 1007 int ret = 0; 870 - struct dentry *entry, *stats, *streaming; 871 - 872 - stats = debugfs_create_dir("fw-statistics", rootdir); 873 - if (!stats || IS_ERR(stats)) { 874 - entry = stats; 875 - goto err; 876 - } 877 - 878 - DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow); 879 - 880 - DEBUGFS_FWSTATS_ADD(rx, out_of_mem); 881 - DEBUGFS_FWSTATS_ADD(rx, hdr_overflow); 882 - DEBUGFS_FWSTATS_ADD(rx, hw_stuck); 883 - DEBUGFS_FWSTATS_ADD(rx, dropped); 884 - DEBUGFS_FWSTATS_ADD(rx, fcs_err); 885 - DEBUGFS_FWSTATS_ADD(rx, xfr_hint_trig); 886 - DEBUGFS_FWSTATS_ADD(rx, path_reset); 887 - DEBUGFS_FWSTATS_ADD(rx, reset_counter); 888 - 889 - DEBUGFS_FWSTATS_ADD(dma, rx_requested); 890 - DEBUGFS_FWSTATS_ADD(dma, rx_errors); 891 - DEBUGFS_FWSTATS_ADD(dma, tx_requested); 892 - DEBUGFS_FWSTATS_ADD(dma, tx_errors); 893 - 894 - DEBUGFS_FWSTATS_ADD(isr, cmd_cmplt); 895 - DEBUGFS_FWSTATS_ADD(isr, fiqs); 896 - DEBUGFS_FWSTATS_ADD(isr, rx_headers); 897 - DEBUGFS_FWSTATS_ADD(isr, rx_mem_overflow); 898 - DEBUGFS_FWSTATS_ADD(isr, rx_rdys); 899 - DEBUGFS_FWSTATS_ADD(isr, irqs); 900 - DEBUGFS_FWSTATS_ADD(isr, tx_procs); 901 - DEBUGFS_FWSTATS_ADD(isr, decrypt_done); 902 - DEBUGFS_FWSTATS_ADD(isr, dma0_done); 903 - DEBUGFS_FWSTATS_ADD(isr, dma1_done); 904 - DEBUGFS_FWSTATS_ADD(isr, tx_exch_complete); 905 - DEBUGFS_FWSTATS_ADD(isr, commands); 906 - DEBUGFS_FWSTATS_ADD(isr, rx_procs); 907 - DEBUGFS_FWSTATS_ADD(isr, hw_pm_mode_changes); 908 - DEBUGFS_FWSTATS_ADD(isr, host_acknowledges); 909 - DEBUGFS_FWSTATS_ADD(isr, pci_pm); 910 - DEBUGFS_FWSTATS_ADD(isr, wakeups); 911 - DEBUGFS_FWSTATS_ADD(isr, low_rssi); 912 - 913 - DEBUGFS_FWSTATS_ADD(wep, addr_key_count); 914 - DEBUGFS_FWSTATS_ADD(wep, default_key_count); 915 - /* skipping wep.reserved */ 916 - DEBUGFS_FWSTATS_ADD(wep, key_not_found); 917 - DEBUGFS_FWSTATS_ADD(wep, decrypt_fail); 918 - DEBUGFS_FWSTATS_ADD(wep, packets); 919 - DEBUGFS_FWSTATS_ADD(wep, interrupt); 920 - 921 - DEBUGFS_FWSTATS_ADD(pwr, ps_enter); 922 - DEBUGFS_FWSTATS_ADD(pwr, elp_enter); 923 - DEBUGFS_FWSTATS_ADD(pwr, missing_bcns); 924 - DEBUGFS_FWSTATS_ADD(pwr, wake_on_host); 925 - DEBUGFS_FWSTATS_ADD(pwr, wake_on_timer_exp); 926 - DEBUGFS_FWSTATS_ADD(pwr, tx_with_ps); 927 - DEBUGFS_FWSTATS_ADD(pwr, tx_without_ps); 928 - DEBUGFS_FWSTATS_ADD(pwr, rcvd_beacons); 929 - DEBUGFS_FWSTATS_ADD(pwr, power_save_off); 930 - DEBUGFS_FWSTATS_ADD(pwr, enable_ps); 931 - DEBUGFS_FWSTATS_ADD(pwr, disable_ps); 932 - DEBUGFS_FWSTATS_ADD(pwr, fix_tsf_ps); 933 - /* skipping cont_miss_bcns_spread for now */ 934 - DEBUGFS_FWSTATS_ADD(pwr, rcvd_awake_beacons); 935 - 936 - DEBUGFS_FWSTATS_ADD(mic, rx_pkts); 937 - DEBUGFS_FWSTATS_ADD(mic, calc_failure); 938 - 939 - DEBUGFS_FWSTATS_ADD(aes, encrypt_fail); 940 - DEBUGFS_FWSTATS_ADD(aes, decrypt_fail); 941 - DEBUGFS_FWSTATS_ADD(aes, encrypt_packets); 942 - DEBUGFS_FWSTATS_ADD(aes, decrypt_packets); 943 - DEBUGFS_FWSTATS_ADD(aes, encrypt_interrupt); 944 - DEBUGFS_FWSTATS_ADD(aes, decrypt_interrupt); 945 - 946 - DEBUGFS_FWSTATS_ADD(event, heart_beat); 947 - DEBUGFS_FWSTATS_ADD(event, calibration); 948 - DEBUGFS_FWSTATS_ADD(event, rx_mismatch); 949 - DEBUGFS_FWSTATS_ADD(event, rx_mem_empty); 950 - DEBUGFS_FWSTATS_ADD(event, rx_pool); 951 - DEBUGFS_FWSTATS_ADD(event, oom_late); 952 - DEBUGFS_FWSTATS_ADD(event, phy_transmit_error); 953 - DEBUGFS_FWSTATS_ADD(event, tx_stuck); 954 - 955 - DEBUGFS_FWSTATS_ADD(ps, pspoll_timeouts); 956 - DEBUGFS_FWSTATS_ADD(ps, upsd_timeouts); 957 - DEBUGFS_FWSTATS_ADD(ps, upsd_max_sptime); 958 - DEBUGFS_FWSTATS_ADD(ps, upsd_max_apturn); 959 - DEBUGFS_FWSTATS_ADD(ps, pspoll_max_apturn); 960 - DEBUGFS_FWSTATS_ADD(ps, pspoll_utilization); 961 - DEBUGFS_FWSTATS_ADD(ps, upsd_utilization); 962 - 963 - DEBUGFS_FWSTATS_ADD(rxpipe, rx_prep_beacon_drop); 964 - DEBUGFS_FWSTATS_ADD(rxpipe, descr_host_int_trig_rx_data); 965 - DEBUGFS_FWSTATS_ADD(rxpipe, beacon_buffer_thres_host_int_trig_rx_data); 966 - DEBUGFS_FWSTATS_ADD(rxpipe, missed_beacon_host_int_trig_rx_data); 967 - DEBUGFS_FWSTATS_ADD(rxpipe, tx_xfr_host_int_trig_rx_data); 1008 + struct dentry *entry, *streaming; 968 1009 969 1010 DEBUGFS_ADD(tx_queue_len, rootdir); 970 1011 DEBUGFS_ADD(retry_count, rootdir); ··· 909 1144 if (!wl->stats.fw_stats) 910 1145 return; 911 1146 912 - memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats)); 1147 + memset(wl->stats.fw_stats, 0, wl->stats.fw_stats_len); 913 1148 wl->stats.retry_count = 0; 914 1149 wl->stats.excessive_retries = 0; 915 1150 } ··· 924 1159 925 1160 if (IS_ERR(rootdir)) { 926 1161 ret = PTR_ERR(rootdir); 927 - goto err; 1162 + goto out; 928 1163 } 929 1164 930 - wl->stats.fw_stats = kzalloc(sizeof(*wl->stats.fw_stats), 931 - GFP_KERNEL); 932 - 1165 + wl->stats.fw_stats = kzalloc(wl->stats.fw_stats_len, GFP_KERNEL); 933 1166 if (!wl->stats.fw_stats) { 934 1167 ret = -ENOMEM; 935 - goto err_fw; 1168 + goto out_remove; 936 1169 } 937 1170 938 1171 wl->stats.fw_stats_update = jiffies; 939 1172 940 1173 ret = wl1271_debugfs_add_files(wl, rootdir); 941 - 942 1174 if (ret < 0) 943 - goto err_file; 1175 + goto out_exit; 944 1176 945 - return 0; 1177 + ret = wlcore_debugfs_init(wl, rootdir); 1178 + if (ret < 0) 1179 + goto out_exit; 946 1180 947 - err_file: 948 - kfree(wl->stats.fw_stats); 949 - wl->stats.fw_stats = NULL; 1181 + goto out; 950 1182 951 - err_fw: 1183 + out_exit: 1184 + wl1271_debugfs_exit(wl); 1185 + 1186 + out_remove: 952 1187 debugfs_remove_recursive(rootdir); 953 1188 954 - err: 1189 + out: 955 1190 return ret; 956 1191 } 957 1192
+60
drivers/net/wireless/ti/wlcore/debugfs.h
··· 26 26 27 27 #include "wlcore.h" 28 28 29 + int wl1271_format_buffer(char __user *userbuf, size_t count, 30 + loff_t *ppos, char *fmt, ...); 31 + 29 32 int wl1271_debugfs_init(struct wl1271 *wl); 30 33 void wl1271_debugfs_exit(struct wl1271 *wl); 31 34 void wl1271_debugfs_reset(struct wl1271 *wl); 35 + void wl1271_debugfs_update_stats(struct wl1271 *wl); 36 + 37 + #define DEBUGFS_READONLY_FILE(name, fmt, value...) \ 38 + static ssize_t name## _read(struct file *file, char __user *userbuf, \ 39 + size_t count, loff_t *ppos) \ 40 + { \ 41 + struct wl1271 *wl = file->private_data; \ 42 + return wl1271_format_buffer(userbuf, count, ppos, \ 43 + fmt "\n", ##value); \ 44 + } \ 45 + \ 46 + static const struct file_operations name## _ops = { \ 47 + .read = name## _read, \ 48 + .open = simple_open, \ 49 + .llseek = generic_file_llseek, \ 50 + }; 51 + 52 + #define DEBUGFS_ADD(name, parent) \ 53 + do { \ 54 + entry = debugfs_create_file(#name, 0400, parent, \ 55 + wl, &name## _ops); \ 56 + if (!entry || IS_ERR(entry)) \ 57 + goto err; \ 58 + } while (0); 59 + 60 + 61 + #define DEBUGFS_ADD_PREFIX(prefix, name, parent) \ 62 + do { \ 63 + entry = debugfs_create_file(#name, 0400, parent, \ 64 + wl, &prefix## _## name## _ops); \ 65 + if (!entry || IS_ERR(entry)) \ 66 + goto err; \ 67 + } while (0); 68 + 69 + #define DEBUGFS_FWSTATS_FILE(sub, name, fmt, struct_type) \ 70 + static ssize_t sub## _ ##name## _read(struct file *file, \ 71 + char __user *userbuf, \ 72 + size_t count, loff_t *ppos) \ 73 + { \ 74 + struct wl1271 *wl = file->private_data; \ 75 + struct struct_type *stats = wl->stats.fw_stats; \ 76 + \ 77 + wl1271_debugfs_update_stats(wl); \ 78 + \ 79 + return wl1271_format_buffer(userbuf, count, ppos, fmt "\n", \ 80 + stats->sub.name); \ 81 + } \ 82 + \ 83 + static const struct file_operations sub## _ ##name## _ops = { \ 84 + .read = sub## _ ##name## _read, \ 85 + .open = simple_open, \ 86 + .llseek = generic_file_llseek, \ 87 + }; 88 + 89 + #define DEBUGFS_FWSTATS_ADD(sub, name) \ 90 + DEBUGFS_ADD(sub## _ ##name, stats) 91 + 32 92 33 93 #endif /* WL1271_DEBUGFS_H */
+9
drivers/net/wireless/ti/wlcore/hw_ops.h
··· 149 149 return 0; 150 150 } 151 151 152 + static inline int 153 + wlcore_debugfs_init(struct wl1271 *wl, struct dentry *rootdir) 154 + { 155 + if (wl->ops->debugfs_init) 156 + return wl->ops->debugfs_init(wl, rootdir); 157 + 158 + return 0; 159 + } 160 + 152 161 #endif
+10
drivers/net/wireless/ti/wlcore/wlcore.h
··· 71 71 struct sk_buff *skb); 72 72 u32 (*ap_get_mimo_wide_rate_mask)(struct wl1271 *wl, 73 73 struct wl12xx_vif *wlvif); 74 + int (*debugfs_init)(struct wl1271 *wl, struct dentry *rootdir); 74 75 }; 75 76 76 77 enum wlcore_partitions { ··· 118 117 REG_RAW_FW_STATUS_ADDR, 119 118 120 119 REG_TABLE_LEN, 120 + }; 121 + 122 + struct wl1271_stats { 123 + void *fw_stats; 124 + unsigned long fw_stats_update; 125 + size_t fw_stats_len; 126 + 127 + unsigned int retry_count; 128 + unsigned int excessive_retries; 121 129 }; 122 130 123 131 struct wl1271 {
-8
drivers/net/wireless/ti/wlcore/wlcore_i.h
··· 132 132 unsigned int fw_ver[NUM_FW_VER]; 133 133 }; 134 134 135 - struct wl1271_stats { 136 - struct acx_statistics *fw_stats; 137 - unsigned long fw_stats_update; 138 - 139 - unsigned int retry_count; 140 - unsigned int excessive_retries; 141 - }; 142 - 143 135 #define NUM_TX_QUEUES 4 144 136 145 137 #define AP_MAX_STATIONS 8