aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/wil6210/debugfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/wil6210/debugfs.c')
-rw-r--r--drivers/net/wireless/ath/wil6210/debugfs.c331
1 files changed, 252 insertions, 79 deletions
diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c
index 8f66186adb8c..b1c6a7293390 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2012 Qualcomm Atheros, Inc. 2 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
3 * 3 *
4 * Permission to use, copy, modify, and/or distribute this software for any 4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above 5 * purpose with or without fee is hereby granted, provided that the above
@@ -22,6 +22,7 @@
22#include <linux/power_supply.h> 22#include <linux/power_supply.h>
23 23
24#include "wil6210.h" 24#include "wil6210.h"
25#include "wmi.h"
25#include "txrx.h" 26#include "txrx.h"
26 27
27/* Nasty hack. Better have per device instances */ 28/* Nasty hack. Better have per device instances */
@@ -29,6 +30,21 @@ static u32 mem_addr;
29static u32 dbg_txdesc_index; 30static u32 dbg_txdesc_index;
30static u32 dbg_vring_index; /* 24+ for Rx, 0..23 for Tx */ 31static u32 dbg_vring_index; /* 24+ for Rx, 0..23 for Tx */
31 32
33enum dbg_off_type {
34 doff_u32 = 0,
35 doff_x32 = 1,
36 doff_ulong = 2,
37 doff_io32 = 3,
38};
39
40/* offset to "wil" */
41struct dbg_off {
42 const char *name;
43 umode_t mode;
44 ulong off;
45 enum dbg_off_type type;
46};
47
32static void wil_print_vring(struct seq_file *s, struct wil6210_priv *wil, 48static void wil_print_vring(struct seq_file *s, struct wil6210_priv *wil,
33 const char *name, struct vring *vring, 49 const char *name, struct vring *vring,
34 char _s, char _h) 50 char _s, char _h)
@@ -244,9 +260,9 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_iomem_x32, wil_debugfs_iomem_x32_get,
244static struct dentry *wil_debugfs_create_iomem_x32(const char *name, 260static struct dentry *wil_debugfs_create_iomem_x32(const char *name,
245 umode_t mode, 261 umode_t mode,
246 struct dentry *parent, 262 struct dentry *parent,
247 void __iomem *value) 263 void *value)
248{ 264{
249 return debugfs_create_file(name, mode, parent, (void * __force)value, 265 return debugfs_create_file(name, mode, parent, value,
250 &fops_iomem_x32); 266 &fops_iomem_x32);
251} 267}
252 268
@@ -270,6 +286,59 @@ static struct dentry *wil_debugfs_create_ulong(const char *name, umode_t mode,
270 return debugfs_create_file(name, mode, parent, value, &wil_fops_ulong); 286 return debugfs_create_file(name, mode, parent, value, &wil_fops_ulong);
271} 287}
272 288
289/**
290 * wil6210_debugfs_init_offset - create set of debugfs files
291 * @wil - driver's context, used for printing
292 * @dbg - directory on the debugfs, where files will be created
293 * @base - base address used in address calculation
294 * @tbl - table with file descriptions. Should be terminated with empty element.
295 *
296 * Creates files accordingly to the @tbl.
297 */
298static void wil6210_debugfs_init_offset(struct wil6210_priv *wil,
299 struct dentry *dbg, void *base,
300 const struct dbg_off * const tbl)
301{
302 int i;
303
304 for (i = 0; tbl[i].name; i++) {
305 struct dentry *f = NULL;
306
307 switch (tbl[i].type) {
308 case doff_u32:
309 f = debugfs_create_u32(tbl[i].name, tbl[i].mode, dbg,
310 base + tbl[i].off);
311 break;
312 case doff_x32:
313 f = debugfs_create_x32(tbl[i].name, tbl[i].mode, dbg,
314 base + tbl[i].off);
315 break;
316 case doff_ulong:
317 f = wil_debugfs_create_ulong(tbl[i].name, tbl[i].mode,
318 dbg, base + tbl[i].off);
319 break;
320 case doff_io32:
321 f = wil_debugfs_create_iomem_x32(tbl[i].name,
322 tbl[i].mode, dbg,
323 base + tbl[i].off);
324 break;
325 }
326 if (IS_ERR_OR_NULL(f))
327 wil_err(wil, "Create file \"%s\": err %ld\n",
328 tbl[i].name, PTR_ERR(f));
329 }
330}
331
332static const struct dbg_off isr_off[] = {
333 {"ICC", S_IRUGO | S_IWUSR, offsetof(struct RGF_ICR, ICC), doff_io32},
334 {"ICR", S_IRUGO | S_IWUSR, offsetof(struct RGF_ICR, ICR), doff_io32},
335 {"ICM", S_IRUGO | S_IWUSR, offsetof(struct RGF_ICR, ICM), doff_io32},
336 {"ICS", S_IWUSR, offsetof(struct RGF_ICR, ICS), doff_io32},
337 {"IMV", S_IRUGO | S_IWUSR, offsetof(struct RGF_ICR, IMV), doff_io32},
338 {"IMS", S_IWUSR, offsetof(struct RGF_ICR, IMS), doff_io32},
339 {"IMC", S_IWUSR, offsetof(struct RGF_ICR, IMC), doff_io32},
340 {},
341};
273static int wil6210_debugfs_create_ISR(struct wil6210_priv *wil, 342static int wil6210_debugfs_create_ISR(struct wil6210_priv *wil,
274 const char *name, 343 const char *name,
275 struct dentry *parent, u32 off) 344 struct dentry *parent, u32 off)
@@ -279,24 +348,19 @@ static int wil6210_debugfs_create_ISR(struct wil6210_priv *wil,
279 if (IS_ERR_OR_NULL(d)) 348 if (IS_ERR_OR_NULL(d))
280 return -ENODEV; 349 return -ENODEV;
281 350
282 wil_debugfs_create_iomem_x32("ICC", S_IRUGO | S_IWUSR, d, 351 wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr + off,
283 wil->csr + off); 352 isr_off);
284 wil_debugfs_create_iomem_x32("ICR", S_IRUGO | S_IWUSR, d,
285 wil->csr + off + 4);
286 wil_debugfs_create_iomem_x32("ICM", S_IRUGO | S_IWUSR, d,
287 wil->csr + off + 8);
288 wil_debugfs_create_iomem_x32("ICS", S_IWUSR, d,
289 wil->csr + off + 12);
290 wil_debugfs_create_iomem_x32("IMV", S_IRUGO | S_IWUSR, d,
291 wil->csr + off + 16);
292 wil_debugfs_create_iomem_x32("IMS", S_IWUSR, d,
293 wil->csr + off + 20);
294 wil_debugfs_create_iomem_x32("IMC", S_IWUSR, d,
295 wil->csr + off + 24);
296 353
297 return 0; 354 return 0;
298} 355}
299 356
357static const struct dbg_off pseudo_isr_off[] = {
358 {"CAUSE", S_IRUGO, HOSTADDR(RGF_DMA_PSEUDO_CAUSE), doff_io32},
359 {"MASK_SW", S_IRUGO, HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_SW), doff_io32},
360 {"MASK_FW", S_IRUGO, HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_FW), doff_io32},
361 {},
362};
363
300static int wil6210_debugfs_create_pseudo_ISR(struct wil6210_priv *wil, 364static int wil6210_debugfs_create_pseudo_ISR(struct wil6210_priv *wil,
301 struct dentry *parent) 365 struct dentry *parent)
302{ 366{
@@ -305,16 +369,19 @@ static int wil6210_debugfs_create_pseudo_ISR(struct wil6210_priv *wil,
305 if (IS_ERR_OR_NULL(d)) 369 if (IS_ERR_OR_NULL(d))
306 return -ENODEV; 370 return -ENODEV;
307 371
308 wil_debugfs_create_iomem_x32("CAUSE", S_IRUGO, d, wil->csr + 372 wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr,
309 HOSTADDR(RGF_DMA_PSEUDO_CAUSE)); 373 pseudo_isr_off);
310 wil_debugfs_create_iomem_x32("MASK_SW", S_IRUGO, d, wil->csr +
311 HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_SW));
312 wil_debugfs_create_iomem_x32("MASK_FW", S_IRUGO, d, wil->csr +
313 HOSTADDR(RGF_DMA_PSEUDO_CAUSE_MASK_FW));
314 374
315 return 0; 375 return 0;
316} 376}
317 377
378static const struct dbg_off itr_cnt_off[] = {
379 {"TRSH", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_CNT_TRSH), doff_io32},
380 {"DATA", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_CNT_DATA), doff_io32},
381 {"CTL", S_IRUGO | S_IWUSR, HOSTADDR(RGF_DMA_ITR_CNT_CRL), doff_io32},
382 {},
383};
384
318static int wil6210_debugfs_create_ITR_CNT(struct wil6210_priv *wil, 385static int wil6210_debugfs_create_ITR_CNT(struct wil6210_priv *wil,
319 struct dentry *parent) 386 struct dentry *parent)
320{ 387{
@@ -323,12 +390,8 @@ static int wil6210_debugfs_create_ITR_CNT(struct wil6210_priv *wil,
323 if (IS_ERR_OR_NULL(d)) 390 if (IS_ERR_OR_NULL(d))
324 return -ENODEV; 391 return -ENODEV;
325 392
326 wil_debugfs_create_iomem_x32("TRSH", S_IRUGO | S_IWUSR, d, wil->csr + 393 wil6210_debugfs_init_offset(wil, d, (void * __force)wil->csr,
327 HOSTADDR(RGF_DMA_ITR_CNT_TRSH)); 394 itr_cnt_off);
328 wil_debugfs_create_iomem_x32("DATA", S_IRUGO | S_IWUSR, d, wil->csr +
329 HOSTADDR(RGF_DMA_ITR_CNT_DATA));
330 wil_debugfs_create_iomem_x32("CTL", S_IRUGO | S_IWUSR, d, wil->csr +
331 HOSTADDR(RGF_DMA_ITR_CNT_CRL));
332 395
333 return 0; 396 return 0;
334} 397}
@@ -666,16 +729,79 @@ static const struct file_operations fops_txdesc = {
666}; 729};
667 730
668/*---------beamforming------------*/ 731/*---------beamforming------------*/
732static char *wil_bfstatus_str(u32 status)
733{
734 switch (status) {
735 case 0:
736 return "Failed";
737 case 1:
738 return "OK";
739 case 2:
740 return "Retrying";
741 default:
742 return "??";
743 }
744}
745
746static bool is_all_zeros(void * const x_, size_t sz)
747{
748 /* if reply is all-0, ignore this CID */
749 u32 *x = x_;
750 int n;
751
752 for (n = 0; n < sz / sizeof(*x); n++)
753 if (x[n])
754 return false;
755
756 return true;
757}
758
669static int wil_bf_debugfs_show(struct seq_file *s, void *data) 759static int wil_bf_debugfs_show(struct seq_file *s, void *data)
670{ 760{
761 int rc;
762 int i;
671 struct wil6210_priv *wil = s->private; 763 struct wil6210_priv *wil = s->private;
672 seq_printf(s, 764 struct wmi_notify_req_cmd cmd = {
673 "TSF : 0x%016llx\n" 765 .interval_usec = 0,
674 "TxMCS : %d\n" 766 };
675 "Sectors(rx:tx) my %2d:%2d peer %2d:%2d\n", 767 struct {
676 wil->stats.tsf, wil->stats.bf_mcs, 768 struct wil6210_mbox_hdr_wmi wmi;
677 wil->stats.my_rx_sector, wil->stats.my_tx_sector, 769 struct wmi_notify_req_done_event evt;
678 wil->stats.peer_rx_sector, wil->stats.peer_tx_sector); 770 } __packed reply;
771
772 for (i = 0; i < ARRAY_SIZE(wil->sta); i++) {
773 u32 status;
774
775 cmd.cid = i;
776 rc = wmi_call(wil, WMI_NOTIFY_REQ_CMDID, &cmd, sizeof(cmd),
777 WMI_NOTIFY_REQ_DONE_EVENTID, &reply,
778 sizeof(reply), 20);
779 /* if reply is all-0, ignore this CID */
780 if (rc || is_all_zeros(&reply.evt, sizeof(reply.evt)))
781 continue;
782
783 status = le32_to_cpu(reply.evt.status);
784 seq_printf(s, "CID %d {\n"
785 " TSF = 0x%016llx\n"
786 " TxMCS = %2d TxTpt = %4d\n"
787 " SQI = %4d\n"
788 " Status = 0x%08x %s\n"
789 " Sectors(rx:tx) my %2d:%2d peer %2d:%2d\n"
790 " Goodput(rx:tx) %4d:%4d\n"
791 "}\n",
792 i,
793 le64_to_cpu(reply.evt.tsf),
794 le16_to_cpu(reply.evt.bf_mcs),
795 le32_to_cpu(reply.evt.tx_tpt),
796 reply.evt.sqi,
797 status, wil_bfstatus_str(status),
798 le16_to_cpu(reply.evt.my_rx_sector),
799 le16_to_cpu(reply.evt.my_tx_sector),
800 le16_to_cpu(reply.evt.other_rx_sector),
801 le16_to_cpu(reply.evt.other_tx_sector),
802 le32_to_cpu(reply.evt.rx_goodput),
803 le32_to_cpu(reply.evt.tx_goodput));
804 }
679 return 0; 805 return 0;
680} 806}
681 807
@@ -985,6 +1111,87 @@ static void wil6210_debugfs_init_blobs(struct wil6210_priv *wil,
985 } 1111 }
986} 1112}
987 1113
1114/* misc files */
1115static const struct {
1116 const char *name;
1117 umode_t mode;
1118 const struct file_operations *fops;
1119} dbg_files[] = {
1120 {"mbox", S_IRUGO, &fops_mbox},
1121 {"vrings", S_IRUGO, &fops_vring},
1122 {"stations", S_IRUGO, &fops_sta},
1123 {"desc", S_IRUGO, &fops_txdesc},
1124 {"bf", S_IRUGO, &fops_bf},
1125 {"ssid", S_IRUGO | S_IWUSR, &fops_ssid},
1126 {"mem_val", S_IRUGO, &fops_memread},
1127 {"reset", S_IWUSR, &fops_reset},
1128 {"rxon", S_IWUSR, &fops_rxon},
1129 {"tx_mgmt", S_IWUSR, &fops_txmgmt},
1130 {"wmi_send", S_IWUSR, &fops_wmi},
1131 {"temp", S_IRUGO, &fops_temp},
1132 {"freq", S_IRUGO, &fops_freq},
1133 {"link", S_IRUGO, &fops_link},
1134 {"info", S_IRUGO, &fops_info},
1135};
1136
1137static void wil6210_debugfs_init_files(struct wil6210_priv *wil,
1138 struct dentry *dbg)
1139{
1140 int i;
1141
1142 for (i = 0; i < ARRAY_SIZE(dbg_files); i++)
1143 debugfs_create_file(dbg_files[i].name, dbg_files[i].mode, dbg,
1144 wil, dbg_files[i].fops);
1145}
1146
1147/* interrupt control blocks */
1148static const struct {
1149 const char *name;
1150 u32 icr_off;
1151} dbg_icr[] = {
1152 {"USER_ICR", HOSTADDR(RGF_USER_USER_ICR)},
1153 {"DMA_EP_TX_ICR", HOSTADDR(RGF_DMA_EP_TX_ICR)},
1154 {"DMA_EP_RX_ICR", HOSTADDR(RGF_DMA_EP_RX_ICR)},
1155 {"DMA_EP_MISC_ICR", HOSTADDR(RGF_DMA_EP_MISC_ICR)},
1156};
1157
1158static void wil6210_debugfs_init_isr(struct wil6210_priv *wil,
1159 struct dentry *dbg)
1160{
1161 int i;
1162
1163 for (i = 0; i < ARRAY_SIZE(dbg_icr); i++)
1164 wil6210_debugfs_create_ISR(wil, dbg_icr[i].name, dbg,
1165 dbg_icr[i].icr_off);
1166}
1167
1168#define WIL_FIELD(name, mode, type) { __stringify(name), mode, \
1169 offsetof(struct wil6210_priv, name), type}
1170
1171/* fields in struct wil6210_priv */
1172static const struct dbg_off dbg_wil_off[] = {
1173 WIL_FIELD(secure_pcp, S_IRUGO | S_IWUSR, doff_u32),
1174 WIL_FIELD(status, S_IRUGO | S_IWUSR, doff_ulong),
1175 WIL_FIELD(fw_version, S_IRUGO, doff_u32),
1176 WIL_FIELD(hw_version, S_IRUGO, doff_x32),
1177 {},
1178};
1179
1180static const struct dbg_off dbg_wil_regs[] = {
1181 {"RGF_MAC_MTRL_COUNTER_0", S_IRUGO, HOSTADDR(RGF_MAC_MTRL_COUNTER_0),
1182 doff_io32},
1183 {"RGF_USER_USAGE_1", S_IRUGO, HOSTADDR(RGF_USER_USAGE_1), doff_io32},
1184 {},
1185};
1186
1187/* static parameters */
1188static const struct dbg_off dbg_statics[] = {
1189 {"desc_index", S_IRUGO | S_IWUSR, (ulong)&dbg_txdesc_index, doff_u32},
1190 {"vring_index", S_IRUGO | S_IWUSR, (ulong)&dbg_vring_index, doff_u32},
1191 {"mem_addr", S_IRUGO | S_IWUSR, (ulong)&mem_addr, doff_u32},
1192 {},
1193};
1194
988int wil6210_debugfs_init(struct wil6210_priv *wil) 1195int wil6210_debugfs_init(struct wil6210_priv *wil)
989{ 1196{
990 struct dentry *dbg = wil->debug = debugfs_create_dir(WIL_NAME, 1197 struct dentry *dbg = wil->debug = debugfs_create_dir(WIL_NAME,
@@ -993,51 +1200,17 @@ int wil6210_debugfs_init(struct wil6210_priv *wil)
993 if (IS_ERR_OR_NULL(dbg)) 1200 if (IS_ERR_OR_NULL(dbg))
994 return -ENODEV; 1201 return -ENODEV;
995 1202
996 debugfs_create_file("mbox", S_IRUGO, dbg, wil, &fops_mbox); 1203 wil6210_debugfs_init_files(wil, dbg);
997 debugfs_create_file("vrings", S_IRUGO, dbg, wil, &fops_vring); 1204 wil6210_debugfs_init_isr(wil, dbg);
998 debugfs_create_file("stations", S_IRUGO, dbg, wil, &fops_sta); 1205 wil6210_debugfs_init_blobs(wil, dbg);
999 debugfs_create_file("desc", S_IRUGO, dbg, wil, &fops_txdesc); 1206 wil6210_debugfs_init_offset(wil, dbg, wil, dbg_wil_off);
1000 debugfs_create_u32("desc_index", S_IRUGO | S_IWUSR, dbg, 1207 wil6210_debugfs_init_offset(wil, dbg, (void * __force)wil->csr,
1001 &dbg_txdesc_index); 1208 dbg_wil_regs);
1002 debugfs_create_u32("vring_index", S_IRUGO | S_IWUSR, dbg, 1209 wil6210_debugfs_init_offset(wil, dbg, NULL, dbg_statics);
1003 &dbg_vring_index);
1004
1005 debugfs_create_file("bf", S_IRUGO, dbg, wil, &fops_bf);
1006 debugfs_create_file("ssid", S_IRUGO | S_IWUSR, dbg, wil, &fops_ssid);
1007 debugfs_create_u32("secure_pcp", S_IRUGO | S_IWUSR, dbg,
1008 &wil->secure_pcp);
1009 wil_debugfs_create_ulong("status", S_IRUGO | S_IWUSR, dbg,
1010 &wil->status);
1011 debugfs_create_u32("fw_version", S_IRUGO, dbg, &wil->fw_version);
1012 debugfs_create_x32("hw_version", S_IRUGO, dbg, &wil->hw_version);
1013
1014 wil6210_debugfs_create_ISR(wil, "USER_ICR", dbg,
1015 HOSTADDR(RGF_USER_USER_ICR));
1016 wil6210_debugfs_create_ISR(wil, "DMA_EP_TX_ICR", dbg,
1017 HOSTADDR(RGF_DMA_EP_TX_ICR));
1018 wil6210_debugfs_create_ISR(wil, "DMA_EP_RX_ICR", dbg,
1019 HOSTADDR(RGF_DMA_EP_RX_ICR));
1020 wil6210_debugfs_create_ISR(wil, "DMA_EP_MISC_ICR", dbg,
1021 HOSTADDR(RGF_DMA_EP_MISC_ICR));
1022 wil6210_debugfs_create_pseudo_ISR(wil, dbg);
1023 wil6210_debugfs_create_ITR_CNT(wil, dbg);
1024 1210
1025 wil_debugfs_create_iomem_x32("RGF_USER_USAGE_1", S_IRUGO, dbg, 1211 wil6210_debugfs_create_pseudo_ISR(wil, dbg);
1026 wil->csr +
1027 HOSTADDR(RGF_USER_USAGE_1));
1028 debugfs_create_u32("mem_addr", S_IRUGO | S_IWUSR, dbg, &mem_addr);
1029 debugfs_create_file("mem_val", S_IRUGO, dbg, wil, &fops_memread);
1030
1031 debugfs_create_file("reset", S_IWUSR, dbg, wil, &fops_reset);
1032 debugfs_create_file("rxon", S_IWUSR, dbg, wil, &fops_rxon);
1033 debugfs_create_file("tx_mgmt", S_IWUSR, dbg, wil, &fops_txmgmt);
1034 debugfs_create_file("wmi_send", S_IWUSR, dbg, wil, &fops_wmi);
1035 debugfs_create_file("temp", S_IRUGO, dbg, wil, &fops_temp);
1036 debugfs_create_file("freq", S_IRUGO, dbg, wil, &fops_freq);
1037 debugfs_create_file("link", S_IRUGO, dbg, wil, &fops_link);
1038 debugfs_create_file("info", S_IRUGO, dbg, wil, &fops_info);
1039 1212
1040 wil6210_debugfs_init_blobs(wil, dbg); 1213 wil6210_debugfs_create_ITR_CNT(wil, dbg);
1041 1214
1042 return 0; 1215 return 0;
1043} 1216}