diff options
author | Emmanuel Grumbach <emmanuel.grumbach@intel.com> | 2011-08-26 02:10:50 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-08-29 15:25:32 -0400 |
commit | 87e5666c0722d5f4cad3560ab5c180c8bba62b8b (patch) | |
tree | d1cb4c0349cc7270a0d67e1a4aee77baebb6e4d0 /drivers/net/wireless/iwlwifi/iwl-debugfs.c | |
parent | 6fbfae8e65139061080c70c8c337f74c50e8fd55 (diff) |
iwlagn: transport handler can register debugfs entries
Add a handler in iwl_trans_ops to allow it to add entries under debugfs dir
given by the upper level.
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-debugfs.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-debugfs.c | 181 |
1 files changed, 3 insertions, 178 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 0aa84560dc2d..d3223214a801 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c | |||
@@ -882,178 +882,6 @@ DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); | |||
882 | DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override); | 882 | DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override); |
883 | DEBUGFS_READ_FILE_OPS(current_sleep_command); | 883 | DEBUGFS_READ_FILE_OPS(current_sleep_command); |
884 | 884 | ||
885 | static ssize_t iwl_dbgfs_traffic_log_read(struct file *file, | ||
886 | char __user *user_buf, | ||
887 | size_t count, loff_t *ppos) | ||
888 | { | ||
889 | struct iwl_priv *priv = file->private_data; | ||
890 | int pos = 0, ofs = 0; | ||
891 | int cnt = 0, entry; | ||
892 | struct iwl_tx_queue *txq; | ||
893 | struct iwl_queue *q; | ||
894 | struct iwl_rx_queue *rxq = &priv->rxq; | ||
895 | char *buf; | ||
896 | int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) + | ||
897 | (priv->cfg->base_params->num_of_queues * 32 * 8) + 400; | ||
898 | const u8 *ptr; | ||
899 | ssize_t ret; | ||
900 | |||
901 | if (!priv->txq) { | ||
902 | IWL_ERR(priv, "txq not ready\n"); | ||
903 | return -EAGAIN; | ||
904 | } | ||
905 | buf = kzalloc(bufsz, GFP_KERNEL); | ||
906 | if (!buf) { | ||
907 | IWL_ERR(priv, "Can not allocate buffer\n"); | ||
908 | return -ENOMEM; | ||
909 | } | ||
910 | pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n"); | ||
911 | for (cnt = 0; cnt < hw_params(priv).max_txq_num; cnt++) { | ||
912 | txq = &priv->txq[cnt]; | ||
913 | q = &txq->q; | ||
914 | pos += scnprintf(buf + pos, bufsz - pos, | ||
915 | "q[%d]: read_ptr: %u, write_ptr: %u\n", | ||
916 | cnt, q->read_ptr, q->write_ptr); | ||
917 | } | ||
918 | if (priv->tx_traffic && | ||
919 | (iwl_get_debug_level(priv->shrd) & IWL_DL_TX)) { | ||
920 | ptr = priv->tx_traffic; | ||
921 | pos += scnprintf(buf + pos, bufsz - pos, | ||
922 | "Tx Traffic idx: %u\n", priv->tx_traffic_idx); | ||
923 | for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { | ||
924 | for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; | ||
925 | entry++, ofs += 16) { | ||
926 | pos += scnprintf(buf + pos, bufsz - pos, | ||
927 | "0x%.4x ", ofs); | ||
928 | hex_dump_to_buffer(ptr + ofs, 16, 16, 2, | ||
929 | buf + pos, bufsz - pos, 0); | ||
930 | pos += strlen(buf + pos); | ||
931 | if (bufsz - pos > 0) | ||
932 | buf[pos++] = '\n'; | ||
933 | } | ||
934 | } | ||
935 | } | ||
936 | |||
937 | pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n"); | ||
938 | pos += scnprintf(buf + pos, bufsz - pos, | ||
939 | "read: %u, write: %u\n", | ||
940 | rxq->read, rxq->write); | ||
941 | |||
942 | if (priv->rx_traffic && | ||
943 | (iwl_get_debug_level(priv->shrd) & IWL_DL_RX)) { | ||
944 | ptr = priv->rx_traffic; | ||
945 | pos += scnprintf(buf + pos, bufsz - pos, | ||
946 | "Rx Traffic idx: %u\n", priv->rx_traffic_idx); | ||
947 | for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { | ||
948 | for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; | ||
949 | entry++, ofs += 16) { | ||
950 | pos += scnprintf(buf + pos, bufsz - pos, | ||
951 | "0x%.4x ", ofs); | ||
952 | hex_dump_to_buffer(ptr + ofs, 16, 16, 2, | ||
953 | buf + pos, bufsz - pos, 0); | ||
954 | pos += strlen(buf + pos); | ||
955 | if (bufsz - pos > 0) | ||
956 | buf[pos++] = '\n'; | ||
957 | } | ||
958 | } | ||
959 | } | ||
960 | |||
961 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); | ||
962 | kfree(buf); | ||
963 | return ret; | ||
964 | } | ||
965 | |||
966 | static ssize_t iwl_dbgfs_traffic_log_write(struct file *file, | ||
967 | const char __user *user_buf, | ||
968 | size_t count, loff_t *ppos) | ||
969 | { | ||
970 | struct iwl_priv *priv = file->private_data; | ||
971 | char buf[8]; | ||
972 | int buf_size; | ||
973 | int traffic_log; | ||
974 | |||
975 | memset(buf, 0, sizeof(buf)); | ||
976 | buf_size = min(count, sizeof(buf) - 1); | ||
977 | if (copy_from_user(buf, user_buf, buf_size)) | ||
978 | return -EFAULT; | ||
979 | if (sscanf(buf, "%d", &traffic_log) != 1) | ||
980 | return -EFAULT; | ||
981 | if (traffic_log == 0) | ||
982 | iwl_reset_traffic_log(priv); | ||
983 | |||
984 | return count; | ||
985 | } | ||
986 | |||
987 | static ssize_t iwl_dbgfs_tx_queue_read(struct file *file, | ||
988 | char __user *user_buf, | ||
989 | size_t count, loff_t *ppos) { | ||
990 | |||
991 | struct iwl_priv *priv = file->private_data; | ||
992 | struct iwl_tx_queue *txq; | ||
993 | struct iwl_queue *q; | ||
994 | char *buf; | ||
995 | int pos = 0; | ||
996 | int cnt; | ||
997 | int ret; | ||
998 | const size_t bufsz = sizeof(char) * 64 * | ||
999 | priv->cfg->base_params->num_of_queues; | ||
1000 | |||
1001 | if (!priv->txq) { | ||
1002 | IWL_ERR(priv, "txq not ready\n"); | ||
1003 | return -EAGAIN; | ||
1004 | } | ||
1005 | buf = kzalloc(bufsz, GFP_KERNEL); | ||
1006 | if (!buf) | ||
1007 | return -ENOMEM; | ||
1008 | |||
1009 | for (cnt = 0; cnt < hw_params(priv).max_txq_num; cnt++) { | ||
1010 | txq = &priv->txq[cnt]; | ||
1011 | q = &txq->q; | ||
1012 | pos += scnprintf(buf + pos, bufsz - pos, | ||
1013 | "hwq %.2d: read=%u write=%u stop=%d" | ||
1014 | " swq_id=%#.2x (ac %d/hwq %d)\n", | ||
1015 | cnt, q->read_ptr, q->write_ptr, | ||
1016 | !!test_bit(cnt, priv->queue_stopped), | ||
1017 | txq->swq_id, txq->swq_id & 3, | ||
1018 | (txq->swq_id >> 2) & 0x1f); | ||
1019 | if (cnt >= 4) | ||
1020 | continue; | ||
1021 | /* for the ACs, display the stop count too */ | ||
1022 | pos += scnprintf(buf + pos, bufsz - pos, | ||
1023 | " stop-count: %d\n", | ||
1024 | atomic_read(&priv->queue_stop_count[cnt])); | ||
1025 | } | ||
1026 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); | ||
1027 | kfree(buf); | ||
1028 | return ret; | ||
1029 | } | ||
1030 | |||
1031 | static ssize_t iwl_dbgfs_rx_queue_read(struct file *file, | ||
1032 | char __user *user_buf, | ||
1033 | size_t count, loff_t *ppos) { | ||
1034 | |||
1035 | struct iwl_priv *priv = file->private_data; | ||
1036 | struct iwl_rx_queue *rxq = &priv->rxq; | ||
1037 | char buf[256]; | ||
1038 | int pos = 0; | ||
1039 | const size_t bufsz = sizeof(buf); | ||
1040 | |||
1041 | pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n", | ||
1042 | rxq->read); | ||
1043 | pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n", | ||
1044 | rxq->write); | ||
1045 | pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n", | ||
1046 | rxq->free_count); | ||
1047 | if (rxq->rb_stts) { | ||
1048 | pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n", | ||
1049 | le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF); | ||
1050 | } else { | ||
1051 | pos += scnprintf(buf + pos, bufsz - pos, | ||
1052 | "closed_rb_num: Not Allocated\n"); | ||
1053 | } | ||
1054 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); | ||
1055 | } | ||
1056 | |||
1057 | static const char *fmt_value = " %-30s %10u\n"; | 885 | static const char *fmt_value = " %-30s %10u\n"; |
1058 | static const char *fmt_hex = " %-30s 0x%02X\n"; | 886 | static const char *fmt_hex = " %-30s 0x%02X\n"; |
1059 | static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; | 887 | static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; |
@@ -2630,9 +2458,6 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file, | |||
2630 | 2458 | ||
2631 | DEBUGFS_READ_FILE_OPS(rx_statistics); | 2459 | DEBUGFS_READ_FILE_OPS(rx_statistics); |
2632 | DEBUGFS_READ_FILE_OPS(tx_statistics); | 2460 | DEBUGFS_READ_FILE_OPS(tx_statistics); |
2633 | DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); | ||
2634 | DEBUGFS_READ_FILE_OPS(rx_queue); | ||
2635 | DEBUGFS_READ_FILE_OPS(tx_queue); | ||
2636 | DEBUGFS_READ_FILE_OPS(ucode_rx_stats); | 2461 | DEBUGFS_READ_FILE_OPS(ucode_rx_stats); |
2637 | DEBUGFS_READ_FILE_OPS(ucode_tx_stats); | 2462 | DEBUGFS_READ_FILE_OPS(ucode_tx_stats); |
2638 | DEBUGFS_READ_FILE_OPS(ucode_general_stats); | 2463 | DEBUGFS_READ_FILE_OPS(ucode_general_stats); |
@@ -2696,9 +2521,6 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) | |||
2696 | DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); | 2521 | DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); |
2697 | DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR); | 2522 | DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR); |
2698 | DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR); | 2523 | DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR); |
2699 | DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR); | ||
2700 | DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR); | ||
2701 | DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR); | ||
2702 | DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); | 2524 | DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); |
2703 | DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR); | 2525 | DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR); |
2704 | DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR); | 2526 | DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR); |
@@ -2727,6 +2549,9 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) | |||
2727 | &priv->disable_sens_cal); | 2549 | &priv->disable_sens_cal); |
2728 | DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, | 2550 | DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, |
2729 | &priv->disable_chain_noise_cal); | 2551 | &priv->disable_chain_noise_cal); |
2552 | |||
2553 | if (iwl_trans_dbgfs_register(trans(priv), dir_debug)) | ||
2554 | goto err; | ||
2730 | return 0; | 2555 | return 0; |
2731 | 2556 | ||
2732 | err: | 2557 | err: |