aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-debugfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-debugfs.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c117
1 files changed, 61 insertions, 56 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 6fe80b5e7a1..bc7a965c18f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -207,18 +207,19 @@ static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
207 return ret; 207 return ret;
208} 208}
209 209
210#define BYTE1_MASK 0x000000ff;
211#define BYTE2_MASK 0x0000ffff;
212#define BYTE3_MASK 0x00ffffff;
213static ssize_t iwl_dbgfs_sram_read(struct file *file, 210static ssize_t iwl_dbgfs_sram_read(struct file *file,
214 char __user *user_buf, 211 char __user *user_buf,
215 size_t count, loff_t *ppos) 212 size_t count, loff_t *ppos)
216{ 213{
217 u32 val; 214 u32 val = 0;
218 char *buf; 215 char *buf;
219 ssize_t ret; 216 ssize_t ret;
220 int i; 217 int i = 0;
218 bool device_format = false;
219 int offset = 0;
220 int len = 0;
221 int pos = 0; 221 int pos = 0;
222 int sram;
222 struct iwl_priv *priv = file->private_data; 223 struct iwl_priv *priv = file->private_data;
223 size_t bufsz; 224 size_t bufsz;
224 225
@@ -230,35 +231,62 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
230 else 231 else
231 priv->dbgfs_sram_len = priv->ucode_data.len; 232 priv->dbgfs_sram_len = priv->ucode_data.len;
232 } 233 }
233 bufsz = 30 + priv->dbgfs_sram_len * sizeof(char) * 10; 234 len = priv->dbgfs_sram_len;
235
236 if (len == -4) {
237 device_format = true;
238 len = 4;
239 }
240
241 bufsz = 50 + len * 4;
234 buf = kmalloc(bufsz, GFP_KERNEL); 242 buf = kmalloc(bufsz, GFP_KERNEL);
235 if (!buf) 243 if (!buf)
236 return -ENOMEM; 244 return -ENOMEM;
245
237 pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", 246 pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n",
238 priv->dbgfs_sram_len); 247 len);
239 pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", 248 pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n",
240 priv->dbgfs_sram_offset); 249 priv->dbgfs_sram_offset);
241 for (i = priv->dbgfs_sram_len; i > 0; i -= 4) { 250
242 val = iwl_read_targ_mem(priv, priv->dbgfs_sram_offset + \ 251 /* adjust sram address since reads are only on even u32 boundaries */
243 priv->dbgfs_sram_len - i); 252 offset = priv->dbgfs_sram_offset & 0x3;
244 if (i < 4) { 253 sram = priv->dbgfs_sram_offset & ~0x3;
245 switch (i) { 254
246 case 1: 255 /* read the first u32 from sram */
247 val &= BYTE1_MASK; 256 val = iwl_read_targ_mem(priv, sram);
248 break; 257
249 case 2: 258 for (; len; len--) {
250 val &= BYTE2_MASK; 259 /* put the address at the start of every line */
251 break; 260 if (i == 0)
252 case 3: 261 pos += scnprintf(buf + pos, bufsz - pos,
253 val &= BYTE3_MASK; 262 "%08X: ", sram + offset);
254 break; 263
255 } 264 if (device_format)
265 pos += scnprintf(buf + pos, bufsz - pos,
266 "%02x", (val >> (8 * (3 - offset))) & 0xff);
267 else
268 pos += scnprintf(buf + pos, bufsz - pos,
269 "%02x ", (val >> (8 * offset)) & 0xff);
270
271 /* if all bytes processed, read the next u32 from sram */
272 if (++offset == 4) {
273 sram += 4;
274 offset = 0;
275 val = iwl_read_targ_mem(priv, sram);
256 } 276 }
257 if (!(i % 16)) 277
278 /* put in extra spaces and split lines for human readability */
279 if (++i == 16) {
280 i = 0;
258 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 281 pos += scnprintf(buf + pos, bufsz - pos, "\n");
259 pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); 282 } else if (!(i & 7)) {
283 pos += scnprintf(buf + pos, bufsz - pos, " ");
284 } else if (!(i & 3)) {
285 pos += scnprintf(buf + pos, bufsz - pos, " ");
286 }
260 } 287 }
261 pos += scnprintf(buf + pos, bufsz - pos, "\n"); 288 if (i)
289 pos += scnprintf(buf + pos, bufsz - pos, "\n");
262 290
263 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 291 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
264 kfree(buf); 292 kfree(buf);
@@ -282,6 +310,9 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
282 if (sscanf(buf, "%x,%x", &offset, &len) == 2) { 310 if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
283 priv->dbgfs_sram_offset = offset; 311 priv->dbgfs_sram_offset = offset;
284 priv->dbgfs_sram_len = len; 312 priv->dbgfs_sram_len = len;
313 } else if (sscanf(buf, "%x", &offset) == 1) {
314 priv->dbgfs_sram_offset = offset;
315 priv->dbgfs_sram_len = -4;
285 } else { 316 } else {
286 priv->dbgfs_sram_offset = 0; 317 priv->dbgfs_sram_offset = 0;
287 priv->dbgfs_sram_len = 0; 318 priv->dbgfs_sram_len = 0;
@@ -668,29 +699,6 @@ static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
668 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 699 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
669} 700}
670 701
671static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf,
672 size_t count, loff_t *ppos)
673{
674 struct iwl_priv *priv = file->private_data;
675 int pos = 0;
676 char buf[256];
677 const size_t bufsz = sizeof(buf);
678
679 pos += scnprintf(buf + pos, bufsz - pos,
680 "allow blinking: %s\n",
681 (priv->allow_blinking) ? "True" : "False");
682 if (priv->allow_blinking) {
683 pos += scnprintf(buf + pos, bufsz - pos,
684 "Led blinking rate: %u\n",
685 priv->last_blink_rate);
686 pos += scnprintf(buf + pos, bufsz - pos,
687 "Last blink time: %lu\n",
688 priv->last_blink_time);
689 }
690
691 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
692}
693
694static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file, 702static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
695 char __user *user_buf, 703 char __user *user_buf,
696 size_t count, loff_t *ppos) 704 size_t count, loff_t *ppos)
@@ -856,7 +864,6 @@ DEBUGFS_READ_FILE_OPS(channels);
856DEBUGFS_READ_FILE_OPS(status); 864DEBUGFS_READ_FILE_OPS(status);
857DEBUGFS_READ_WRITE_FILE_OPS(interrupt); 865DEBUGFS_READ_WRITE_FILE_OPS(interrupt);
858DEBUGFS_READ_FILE_OPS(qos); 866DEBUGFS_READ_FILE_OPS(qos);
859DEBUGFS_READ_FILE_OPS(led);
860DEBUGFS_READ_FILE_OPS(thermal_throttling); 867DEBUGFS_READ_FILE_OPS(thermal_throttling);
861DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); 868DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
862DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override); 869DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
@@ -1580,10 +1587,9 @@ static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file,
1580 "last traffic notif: %d\n", 1587 "last traffic notif: %d\n",
1581 priv->bt_status ? "On" : "Off", priv->last_bt_traffic_load); 1588 priv->bt_status ? "On" : "Off", priv->last_bt_traffic_load);
1582 pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, " 1589 pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, "
1583 "sco_active: %d, kill_ack_mask: %x, " 1590 "kill_ack_mask: %x, kill_cts_mask: %x\n",
1584 "kill_cts_mask: %x\n", 1591 priv->bt_ch_announce, priv->kill_ack_mask,
1585 priv->bt_ch_announce, priv->bt_sco_active, 1592 priv->kill_cts_mask);
1586 priv->kill_ack_mask, priv->kill_cts_mask);
1587 1593
1588 pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: "); 1594 pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: ");
1589 switch (priv->bt_traffic_load) { 1595 switch (priv->bt_traffic_load) {
@@ -1725,7 +1731,6 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
1725 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); 1731 DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
1726 DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR); 1732 DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR);
1727 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); 1733 DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
1728 DEBUGFS_ADD_FILE(led, dir_data, S_IRUSR);
1729 if (!priv->cfg->base_params->broken_powersave) { 1734 if (!priv->cfg->base_params->broken_powersave) {
1730 DEBUGFS_ADD_FILE(sleep_level_override, dir_data, 1735 DEBUGFS_ADD_FILE(sleep_level_override, dir_data,
1731 S_IWUSR | S_IRUSR); 1736 S_IWUSR | S_IRUSR);
@@ -1759,13 +1764,13 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
1759 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); 1764 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
1760 if (priv->cfg->base_params->ucode_tracing) 1765 if (priv->cfg->base_params->ucode_tracing)
1761 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR); 1766 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
1762 if (priv->cfg->bt_params && priv->cfg->bt_params->bt_statistics) 1767 if (iwl_bt_statistics(priv))
1763 DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR); 1768 DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR);
1764 DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR); 1769 DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR);
1765 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); 1770 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
1766 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); 1771 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
1767 DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR); 1772 DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR);
1768 if (priv->cfg->bt_params && priv->cfg->bt_params->advanced_bt_coexist) 1773 if (iwl_advanced_bt_coexist(priv))
1769 DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR); 1774 DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR);
1770 if (priv->cfg->base_params->sensitivity_calib_by_driver) 1775 if (priv->cfg->base_params->sensitivity_calib_by_driver)
1771 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, 1776 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf,