| 1 |
// SPDX-License-Identifier: GPL-2.0-only |
| 2 |
/* |
| 3 |
* This file is part of wl18xx |
| 4 |
* |
| 5 |
* Copyright (C) 2009 Nokia Corporation |
| 6 |
* Copyright (C) 2011-2012 Texas Instruments |
| 7 |
*/ |
| 8 |
|
| 9 |
#include <linux/pm_runtime.h> |
| 10 |
|
| 11 |
#include "../wlcore/debugfs.h" |
| 12 |
#include "../wlcore/wlcore.h" |
| 13 |
#include "../wlcore/debug.h" |
| 14 |
#include "../wlcore/ps.h" |
| 15 |
|
| 16 |
#include "wl18xx.h" |
| 17 |
#include "acx.h" |
| 18 |
#include "cmd.h" |
| 19 |
#include "debugfs.h" |
| 20 |
|
| 21 |
#define WL18XX_DEBUGFS_FWSTATS_FILE(a, b, c) \ |
| 22 |
DEBUGFS_FWSTATS_FILE(a, b, c, wl18xx_acx_statistics) |
| 23 |
#define WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(a, b, c) \ |
| 24 |
DEBUGFS_FWSTATS_FILE_ARRAY(a, b, c, wl18xx_acx_statistics) |
| 25 |
|
| 26 |
|
| 27 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, error_frame_non_ctrl, "%u"); |
| 28 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, error_frame_ctrl, "%u"); |
| 29 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, error_frame_during_protection, "%u"); |
| 30 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, null_frame_tx_start, "%u"); |
| 31 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, null_frame_cts_start, "%u"); |
| 32 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, bar_retry, "%u"); |
| 33 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, num_frame_cts_nul_flid, "%u"); |
| 34 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, tx_abort_failure, "%u"); |
| 35 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, tx_resume_failure, "%u"); |
| 36 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, rx_cmplt_db_overflow_cnt, "%u"); |
| 37 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, elp_while_rx_exch, "%u"); |
| 38 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, elp_while_tx_exch, "%u"); |
| 39 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, elp_while_tx, "%u"); |
| 40 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, elp_while_nvic_pending, "%u"); |
| 41 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, rx_excessive_frame_len, "%u"); |
| 42 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, burst_mismatch, "%u"); |
| 43 |
WL18XX_DEBUGFS_FWSTATS_FILE(error, tbc_exch_mismatch, "%u"); |
| 44 |
|
| 45 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_prepared_descs, "%u"); |
| 46 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_cmplt, "%u"); |
| 47 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_template_prepared, "%u"); |
| 48 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_data_prepared, "%u"); |
| 49 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_template_programmed, "%u"); |
| 50 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_data_programmed, "%u"); |
| 51 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_burst_programmed, "%u"); |
| 52 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_starts, "%u"); |
| 53 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_stop, "%u"); |
| 54 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_start_templates, "%u"); |
| 55 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_start_int_templates, "%u"); |
| 56 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_start_fw_gen, "%u"); |
| 57 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_start_data, "%u"); |
| 58 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_start_null_frame, "%u"); |
| 59 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_exch, "%u"); |
| 60 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_retry_template, "%u"); |
| 61 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_retry_data, "%u"); |
| 62 |
WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(tx, tx_retry_per_rate, |
| 63 |
NUM_OF_RATES_INDEXES); |
| 64 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_exch_pending, "%u"); |
| 65 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_exch_expiry, "%u"); |
| 66 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_done_template, "%u"); |
| 67 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_done_data, "%u"); |
| 68 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_done_int_template, "%u"); |
| 69 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_cfe1, "%u"); |
| 70 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, tx_cfe2, "%u"); |
| 71 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_called, "%u"); |
| 72 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_mpdu_alloc_failed, "%u"); |
| 73 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_init_called, "%u"); |
| 74 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_in_process_called, "%u"); |
| 75 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_tkip_called, "%u"); |
| 76 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_key_not_found, "%u"); |
| 77 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_need_fragmentation, "%u"); |
| 78 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_bad_mblk_num, "%u"); |
| 79 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_failed, "%u"); |
| 80 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_cache_hit, "%u"); |
| 81 |
WL18XX_DEBUGFS_FWSTATS_FILE(tx, frag_cache_miss, "%u"); |
| 82 |
|
| 83 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_beacon_early_term, "%u"); |
| 84 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_out_of_mpdu_nodes, "%u"); |
| 85 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_hdr_overflow, "%u"); |
| 86 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_dropped_frame, "%u"); |
| 87 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_done, "%u"); |
| 88 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_defrag, "%u"); |
| 89 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_defrag_end, "%u"); |
| 90 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_cmplt, "%u"); |
| 91 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_pre_complt, "%u"); |
| 92 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_cmplt_task, "%u"); |
| 93 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_phy_hdr, "%u"); |
| 94 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_timeout, "%u"); |
| 95 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_rts_timeout, "%u"); |
| 96 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_timeout_wa, "%u"); |
| 97 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, defrag_called, "%u"); |
| 98 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, defrag_init_called, "%u"); |
| 99 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, defrag_in_process_called, "%u"); |
| 100 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, defrag_tkip_called, "%u"); |
| 101 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, defrag_need_defrag, "%u"); |
| 102 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, defrag_decrypt_failed, "%u"); |
| 103 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, decrypt_key_not_found, "%u"); |
| 104 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, defrag_need_decrypt, "%u"); |
| 105 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_tkip_replays, "%u"); |
| 106 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx, rx_xfr, "%u"); |
| 107 |
|
| 108 |
WL18XX_DEBUGFS_FWSTATS_FILE(isr, irqs, "%u"); |
| 109 |
|
| 110 |
WL18XX_DEBUGFS_FWSTATS_FILE(pwr, missing_bcns_cnt, "%u"); |
| 111 |
WL18XX_DEBUGFS_FWSTATS_FILE(pwr, rcvd_bcns_cnt, "%u"); |
| 112 |
WL18XX_DEBUGFS_FWSTATS_FILE(pwr, connection_out_of_sync, "%u"); |
| 113 |
WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(pwr, cont_miss_bcns_spread, |
| 114 |
PWR_STAT_MAX_CONT_MISSED_BCNS_SPREAD); |
| 115 |
WL18XX_DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_bcns_cnt, "%u"); |
| 116 |
WL18XX_DEBUGFS_FWSTATS_FILE(pwr, sleep_time_count, "%u"); |
| 117 |
WL18XX_DEBUGFS_FWSTATS_FILE(pwr, sleep_time_avg, "%u"); |
| 118 |
WL18XX_DEBUGFS_FWSTATS_FILE(pwr, sleep_cycle_avg, "%u"); |
| 119 |
WL18XX_DEBUGFS_FWSTATS_FILE(pwr, sleep_percent, "%u"); |
| 120 |
WL18XX_DEBUGFS_FWSTATS_FILE(pwr, ap_sleep_active_conf, "%u"); |
| 121 |
WL18XX_DEBUGFS_FWSTATS_FILE(pwr, ap_sleep_user_conf, "%u"); |
| 122 |
WL18XX_DEBUGFS_FWSTATS_FILE(pwr, ap_sleep_counter, "%u"); |
| 123 |
|
| 124 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, beacon_filter, "%u"); |
| 125 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, arp_filter, "%u"); |
| 126 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, mc_filter, "%u"); |
| 127 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, dup_filter, "%u"); |
| 128 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, data_filter, "%u"); |
| 129 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, ibss_filter, "%u"); |
| 130 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, protection_filter, "%u"); |
| 131 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, accum_arp_pend_requests, "%u"); |
| 132 |
WL18XX_DEBUGFS_FWSTATS_FILE(rx_filter, max_arp_queue_dep, "%u"); |
| 133 |
|
| 134 |
WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(rx_rate, rx_frames_per_rates, 50); |
| 135 |
|
| 136 |
WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(aggr_size, tx_agg_rate, |
| 137 |
AGGR_STATS_TX_AGG); |
| 138 |
WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(aggr_size, tx_agg_len, |
| 139 |
AGGR_STATS_TX_AGG); |
| 140 |
WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(aggr_size, rx_size, |
| 141 |
AGGR_STATS_RX_SIZE_LEN); |
| 142 |
|
| 143 |
WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, hs_tx_stat_fifo_int, "%u"); |
| 144 |
WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, enc_tx_stat_fifo_int, "%u"); |
| 145 |
WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, enc_rx_stat_fifo_int, "%u"); |
| 146 |
WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, rx_complete_stat_fifo_int, "%u"); |
| 147 |
WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, pre_proc_swi, "%u"); |
| 148 |
WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, post_proc_swi, "%u"); |
| 149 |
WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, sec_frag_swi, "%u"); |
| 150 |
WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, pre_to_defrag_swi, "%u"); |
| 151 |
WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, defrag_to_rx_xfer_swi, "%u"); |
| 152 |
WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, dec_packet_in, "%u"); |
| 153 |
WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, dec_packet_in_fifo_full, "%u"); |
| 154 |
WL18XX_DEBUGFS_FWSTATS_FILE(pipeline, dec_packet_out, "%u"); |
| 155 |
|
| 156 |
WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(pipeline, pipeline_fifo_full, |
| 157 |
PIPE_STATS_HW_FIFO); |
| 158 |
|
| 159 |
WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(diversity, num_of_packets_per_ant, |
| 160 |
DIVERSITY_STATS_NUM_OF_ANT); |
| 161 |
WL18XX_DEBUGFS_FWSTATS_FILE(diversity, total_num_of_toggles, "%u"); |
| 162 |
|
| 163 |
WL18XX_DEBUGFS_FWSTATS_FILE(thermal, irq_thr_low, "%u"); |
| 164 |
WL18XX_DEBUGFS_FWSTATS_FILE(thermal, irq_thr_high, "%u"); |
| 165 |
WL18XX_DEBUGFS_FWSTATS_FILE(thermal, tx_stop, "%u"); |
| 166 |
WL18XX_DEBUGFS_FWSTATS_FILE(thermal, tx_resume, "%u"); |
| 167 |
WL18XX_DEBUGFS_FWSTATS_FILE(thermal, false_irq, "%u"); |
| 168 |
WL18XX_DEBUGFS_FWSTATS_FILE(thermal, adc_source_unexpected, "%u"); |
| 169 |
|
| 170 |
WL18XX_DEBUGFS_FWSTATS_FILE_ARRAY(calib, fail_count, |
| 171 |
WL18XX_NUM_OF_CALIBRATIONS_ERRORS); |
| 172 |
WL18XX_DEBUGFS_FWSTATS_FILE(calib, calib_count, "%u"); |
| 173 |
|
| 174 |
WL18XX_DEBUGFS_FWSTATS_FILE(roaming, rssi_level, "%d"); |
| 175 |
|
| 176 |
WL18XX_DEBUGFS_FWSTATS_FILE(dfs, num_of_radar_detections, "%d"); |
| 177 |
|
| 178 |
static ssize_t conf_read(struct file *file, char __user *user_buf, |
| 179 |
size_t count, loff_t *ppos) |
| 180 |
{ |
| 181 |
struct wl1271 *wl = file->private_data; |
| 182 |
struct wl18xx_priv *priv = wl->priv; |
| 183 |
struct wlcore_conf_header header; |
| 184 |
char *buf, *pos; |
| 185 |
size_t len; |
| 186 |
int ret; |
| 187 |
|
| 188 |
len = WL18XX_CONF_SIZE; |
| 189 |
buf = kmalloc(len, GFP_KERNEL); |
| 190 |
if (!buf) |
| 191 |
return -ENOMEM; |
| 192 |
|
| 193 |
header.magic = cpu_to_le32(WL18XX_CONF_MAGIC); |
| 194 |
header.version = cpu_to_le32(WL18XX_CONF_VERSION); |
| 195 |
header.checksum = 0; |
| 196 |
|
| 197 |
mutex_lock(&wl->mutex); |
| 198 |
|
| 199 |
pos = buf; |
| 200 |
memcpy(pos, &header, sizeof(header)); |
| 201 |
pos += sizeof(header); |
| 202 |
memcpy(pos, &wl->conf, sizeof(wl->conf)); |
| 203 |
pos += sizeof(wl->conf); |
| 204 |
memcpy(pos, &priv->conf, sizeof(priv->conf)); |
| 205 |
|
| 206 |
mutex_unlock(&wl->mutex); |
| 207 |
|
| 208 |
ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 209 |
|
| 210 |
kfree(buf); |
| 211 |
return ret; |
| 212 |
} |
| 213 |
|
| 214 |
static const struct file_operations conf_ops = { |
| 215 |
.read = conf_read, |
| 216 |
.open = simple_open, |
| 217 |
.llseek = default_llseek, |
| 218 |
}; |
| 219 |
|
| 220 |
static ssize_t clear_fw_stats_write(struct file *file, |
| 221 |
const char __user *user_buf, |
| 222 |
size_t count, loff_t *ppos) |
| 223 |
{ |
| 224 |
struct wl1271 *wl = file->private_data; |
| 225 |
int ret; |
| 226 |
|
| 227 |
mutex_lock(&wl->mutex); |
| 228 |
|
| 229 |
if (unlikely(wl->state != WLCORE_STATE_ON)) |
| 230 |
goto out; |
| 231 |
|
| 232 |
ret = wl18xx_acx_clear_statistics(wl); |
| 233 |
if (ret < 0) { |
| 234 |
count = ret; |
| 235 |
goto out; |
| 236 |
} |
| 237 |
out: |
| 238 |
mutex_unlock(&wl->mutex); |
| 239 |
return count; |
| 240 |
} |
| 241 |
|
| 242 |
static const struct file_operations clear_fw_stats_ops = { |
| 243 |
.write = clear_fw_stats_write, |
| 244 |
.open = simple_open, |
| 245 |
.llseek = default_llseek, |
| 246 |
}; |
| 247 |
|
| 248 |
static ssize_t radar_detection_write(struct file *file, |
| 249 |
const char __user *user_buf, |
| 250 |
size_t count, loff_t *ppos) |
| 251 |
{ |
| 252 |
struct wl1271 *wl = file->private_data; |
| 253 |
int ret; |
| 254 |
u8 channel; |
| 255 |
|
| 256 |
ret = kstrtou8_from_user(user_buf, count, 10, &channel); |
| 257 |
if (ret < 0) { |
| 258 |
wl1271_warning("illegal channel"); |
| 259 |
return -EINVAL; |
| 260 |
} |
| 261 |
|
| 262 |
mutex_lock(&wl->mutex); |
| 263 |
|
| 264 |
if (unlikely(wl->state != WLCORE_STATE_ON)) |
| 265 |
goto out; |
| 266 |
|
| 267 |
ret = pm_runtime_resume_and_get(wl->dev); |
| 268 |
if (ret < 0) |
| 269 |
goto out; |
| 270 |
|
| 271 |
ret = wl18xx_cmd_radar_detection_debug(wl, channel); |
| 272 |
if (ret < 0) |
| 273 |
count = ret; |
| 274 |
|
| 275 |
pm_runtime_put_autosuspend(wl->dev); |
| 276 |
out: |
| 277 |
mutex_unlock(&wl->mutex); |
| 278 |
return count; |
| 279 |
} |
| 280 |
|
| 281 |
static const struct file_operations radar_detection_ops = { |
| 282 |
.write = radar_detection_write, |
| 283 |
.open = simple_open, |
| 284 |
.llseek = default_llseek, |
| 285 |
}; |
| 286 |
|
| 287 |
static ssize_t dynamic_fw_traces_write(struct file *file, |
| 288 |
const char __user *user_buf, |
| 289 |
size_t count, loff_t *ppos) |
| 290 |
{ |
| 291 |
struct wl1271 *wl = file->private_data; |
| 292 |
unsigned long value; |
| 293 |
int ret; |
| 294 |
|
| 295 |
ret = kstrtoul_from_user(user_buf, count, 0, &value); |
| 296 |
if (ret < 0) |
| 297 |
return ret; |
| 298 |
|
| 299 |
mutex_lock(&wl->mutex); |
| 300 |
|
| 301 |
wl->dynamic_fw_traces = value; |
| 302 |
|
| 303 |
if (unlikely(wl->state != WLCORE_STATE_ON)) |
| 304 |
goto out; |
| 305 |
|
| 306 |
ret = pm_runtime_resume_and_get(wl->dev); |
| 307 |
if (ret < 0) |
| 308 |
goto out; |
| 309 |
|
| 310 |
ret = wl18xx_acx_dynamic_fw_traces(wl); |
| 311 |
if (ret < 0) |
| 312 |
count = ret; |
| 313 |
|
| 314 |
pm_runtime_put_autosuspend(wl->dev); |
| 315 |
out: |
| 316 |
mutex_unlock(&wl->mutex); |
| 317 |
return count; |
| 318 |
} |
| 319 |
|
| 320 |
static ssize_t dynamic_fw_traces_read(struct file *file, |
| 321 |
char __user *userbuf, |
| 322 |
size_t count, loff_t *ppos) |
| 323 |
{ |
| 324 |
struct wl1271 *wl = file->private_data; |
| 325 |
return wl1271_format_buffer(userbuf, count, ppos, |
| 326 |
"%d\n", wl->dynamic_fw_traces); |
| 327 |
} |
| 328 |
|
| 329 |
static const struct file_operations dynamic_fw_traces_ops = { |
| 330 |
.read = dynamic_fw_traces_read, |
| 331 |
.write = dynamic_fw_traces_write, |
| 332 |
.open = simple_open, |
| 333 |
.llseek = default_llseek, |
| 334 |
}; |
| 335 |
|
| 336 |
#ifdef CONFIG_CFG80211_CERTIFICATION_ONUS |
| 337 |
static ssize_t radar_debug_mode_write(struct file *file, |
| 338 |
const char __user *user_buf, |
| 339 |
size_t count, loff_t *ppos) |
| 340 |
{ |
| 341 |
struct wl1271 *wl = file->private_data; |
| 342 |
struct wl12xx_vif *wlvif; |
| 343 |
unsigned long value; |
| 344 |
int ret; |
| 345 |
|
| 346 |
ret = kstrtoul_from_user(user_buf, count, 10, &value); |
| 347 |
if (ret < 0) { |
| 348 |
wl1271_warning("illegal radar_debug_mode value!"); |
| 349 |
return -EINVAL; |
| 350 |
} |
| 351 |
|
| 352 |
/* valid values: 0/1 */ |
| 353 |
if (!(value == 0 || value == 1)) { |
| 354 |
wl1271_warning("value is not in valid!"); |
| 355 |
return -EINVAL; |
| 356 |
} |
| 357 |
|
| 358 |
mutex_lock(&wl->mutex); |
| 359 |
|
| 360 |
wl->radar_debug_mode = value; |
| 361 |
|
| 362 |
if (unlikely(wl->state != WLCORE_STATE_ON)) |
| 363 |
goto out; |
| 364 |
|
| 365 |
ret = pm_runtime_resume_and_get(wl->dev); |
| 366 |
if (ret < 0) |
| 367 |
goto out; |
| 368 |
|
| 369 |
wl12xx_for_each_wlvif_ap(wl, wlvif) { |
| 370 |
wlcore_cmd_generic_cfg(wl, wlvif, |
| 371 |
WLCORE_CFG_FEATURE_RADAR_DEBUG, |
| 372 |
wl->radar_debug_mode, 0); |
| 373 |
} |
| 374 |
|
| 375 |
pm_runtime_put_autosuspend(wl->dev); |
| 376 |
out: |
| 377 |
mutex_unlock(&wl->mutex); |
| 378 |
return count; |
| 379 |
} |
| 380 |
|
| 381 |
static ssize_t radar_debug_mode_read(struct file *file, |
| 382 |
char __user *userbuf, |
| 383 |
size_t count, loff_t *ppos) |
| 384 |
{ |
| 385 |
struct wl1271 *wl = file->private_data; |
| 386 |
|
| 387 |
return wl1271_format_buffer(userbuf, count, ppos, |
| 388 |
"%d\n", wl->radar_debug_mode); |
| 389 |
} |
| 390 |
|
| 391 |
static const struct file_operations radar_debug_mode_ops = { |
| 392 |
.write = radar_debug_mode_write, |
| 393 |
.read = radar_debug_mode_read, |
| 394 |
.open = simple_open, |
| 395 |
.llseek = default_llseek, |
| 396 |
}; |
| 397 |
#endif /* CFG80211_CERTIFICATION_ONUS */ |
| 398 |
|
| 399 |
int wl18xx_debugfs_add_files(struct wl1271 *wl, |
| 400 |
struct dentry *rootdir) |
| 401 |
{ |
| 402 |
struct dentry *stats, *moddir; |
| 403 |
|
| 404 |
moddir = debugfs_create_dir(KBUILD_MODNAME, rootdir); |
| 405 |
stats = debugfs_create_dir("fw_stats", moddir); |
| 406 |
|
| 407 |
DEBUGFS_ADD(clear_fw_stats, stats); |
| 408 |
|
| 409 |
DEBUGFS_FWSTATS_ADD(error, error_frame_non_ctrl); |
| 410 |
DEBUGFS_FWSTATS_ADD(error, error_frame_ctrl); |
| 411 |
DEBUGFS_FWSTATS_ADD(error, error_frame_during_protection); |
| 412 |
DEBUGFS_FWSTATS_ADD(error, null_frame_tx_start); |
| 413 |
DEBUGFS_FWSTATS_ADD(error, null_frame_cts_start); |
| 414 |
DEBUGFS_FWSTATS_ADD(error, bar_retry); |
| 415 |
DEBUGFS_FWSTATS_ADD(error, num_frame_cts_nul_flid); |
| 416 |
DEBUGFS_FWSTATS_ADD(error, tx_abort_failure); |
| 417 |
DEBUGFS_FWSTATS_ADD(error, tx_resume_failure); |
| 418 |
DEBUGFS_FWSTATS_ADD(error, rx_cmplt_db_overflow_cnt); |
| 419 |
DEBUGFS_FWSTATS_ADD(error, elp_while_rx_exch); |
| 420 |
DEBUGFS_FWSTATS_ADD(error, elp_while_tx_exch); |
| 421 |
DEBUGFS_FWSTATS_ADD(error, elp_while_tx); |
| 422 |
DEBUGFS_FWSTATS_ADD(error, elp_while_nvic_pending); |
| 423 |
DEBUGFS_FWSTATS_ADD(error, rx_excessive_frame_len); |
| 424 |
DEBUGFS_FWSTATS_ADD(error, burst_mismatch); |
| 425 |
DEBUGFS_FWSTATS_ADD(error, tbc_exch_mismatch); |
| 426 |
|
| 427 |
DEBUGFS_FWSTATS_ADD(tx, tx_prepared_descs); |
| 428 |
DEBUGFS_FWSTATS_ADD(tx, tx_cmplt); |
| 429 |
DEBUGFS_FWSTATS_ADD(tx, tx_template_prepared); |
| 430 |
DEBUGFS_FWSTATS_ADD(tx, tx_data_prepared); |
| 431 |
DEBUGFS_FWSTATS_ADD(tx, tx_template_programmed); |
| 432 |
DEBUGFS_FWSTATS_ADD(tx, tx_data_programmed); |
| 433 |
DEBUGFS_FWSTATS_ADD(tx, tx_burst_programmed); |
| 434 |
DEBUGFS_FWSTATS_ADD(tx, tx_starts); |
| 435 |
DEBUGFS_FWSTATS_ADD(tx, tx_stop); |
| 436 |
DEBUGFS_FWSTATS_ADD(tx, tx_start_templates); |
| 437 |
DEBUGFS_FWSTATS_ADD(tx, tx_start_int_templates); |
| 438 |
DEBUGFS_FWSTATS_ADD(tx, tx_start_fw_gen); |
| 439 |
DEBUGFS_FWSTATS_ADD(tx, tx_start_data); |
| 440 |
DEBUGFS_FWSTATS_ADD(tx, tx_start_null_frame); |
| 441 |
DEBUGFS_FWSTATS_ADD(tx, tx_exch); |
| 442 |
DEBUGFS_FWSTATS_ADD(tx, tx_retry_template); |
| 443 |
DEBUGFS_FWSTATS_ADD(tx, tx_retry_data); |
| 444 |
DEBUGFS_FWSTATS_ADD(tx, tx_retry_per_rate); |
| 445 |
DEBUGFS_FWSTATS_ADD(tx, tx_exch_pending); |
| 446 |
DEBUGFS_FWSTATS_ADD(tx, tx_exch_expiry); |
| 447 |
DEBUGFS_FWSTATS_ADD(tx, tx_done_template); |
| 448 |
DEBUGFS_FWSTATS_ADD(tx, tx_done_data); |
| 449 |
DEBUGFS_FWSTATS_ADD(tx, tx_done_int_template); |
| 450 |
DEBUGFS_FWSTATS_ADD(tx, tx_cfe1); |
| 451 |
DEBUGFS_FWSTATS_ADD(tx, tx_cfe2); |
| 452 |
DEBUGFS_FWSTATS_ADD(tx, frag_called); |
| 453 |
DEBUGFS_FWSTATS_ADD(tx, frag_mpdu_alloc_failed); |
| 454 |
DEBUGFS_FWSTATS_ADD(tx, frag_init_called); |
| 455 |
DEBUGFS_FWSTATS_ADD(tx, frag_in_process_called); |
| 456 |
DEBUGFS_FWSTATS_ADD(tx, frag_tkip_called); |
| 457 |
DEBUGFS_FWSTATS_ADD(tx, frag_key_not_found); |
| 458 |
DEBUGFS_FWSTATS_ADD(tx, frag_need_fragmentation); |
| 459 |
DEBUGFS_FWSTATS_ADD(tx, frag_bad_mblk_num); |
| 460 |
DEBUGFS_FWSTATS_ADD(tx, frag_failed); |
| 461 |
DEBUGFS_FWSTATS_ADD(tx, frag_cache_hit); |
| 462 |
DEBUGFS_FWSTATS_ADD(tx, frag_cache_miss); |
| 463 |
|
| 464 |
DEBUGFS_FWSTATS_ADD(rx, rx_beacon_early_term); |
| 465 |
DEBUGFS_FWSTATS_ADD(rx, rx_out_of_mpdu_nodes); |
| 466 |
DEBUGFS_FWSTATS_ADD(rx, rx_hdr_overflow); |
| 467 |
DEBUGFS_FWSTATS_ADD(rx, rx_dropped_frame); |
| 468 |
DEBUGFS_FWSTATS_ADD(rx, rx_done); |
| 469 |
DEBUGFS_FWSTATS_ADD(rx, rx_defrag); |
| 470 |
DEBUGFS_FWSTATS_ADD(rx, rx_defrag_end); |
| 471 |
DEBUGFS_FWSTATS_ADD(rx, rx_cmplt); |
| 472 |
DEBUGFS_FWSTATS_ADD(rx, rx_pre_complt); |
| 473 |
DEBUGFS_FWSTATS_ADD(rx, rx_cmplt_task); |
| 474 |
DEBUGFS_FWSTATS_ADD(rx, rx_phy_hdr); |
| 475 |
DEBUGFS_FWSTATS_ADD(rx, rx_timeout); |
| 476 |
DEBUGFS_FWSTATS_ADD(rx, rx_rts_timeout); |
| 477 |
DEBUGFS_FWSTATS_ADD(rx, rx_timeout_wa); |
| 478 |
DEBUGFS_FWSTATS_ADD(rx, defrag_called); |
| 479 |
DEBUGFS_FWSTATS_ADD(rx, defrag_init_called); |
| 480 |
DEBUGFS_FWSTATS_ADD(rx, defrag_in_process_called); |
| 481 |
DEBUGFS_FWSTATS_ADD(rx, defrag_tkip_called); |
| 482 |
DEBUGFS_FWSTATS_ADD(rx, defrag_need_defrag); |
| 483 |
DEBUGFS_FWSTATS_ADD(rx, defrag_decrypt_failed); |
| 484 |
DEBUGFS_FWSTATS_ADD(rx, decrypt_key_not_found); |
| 485 |
DEBUGFS_FWSTATS_ADD(rx, defrag_need_decrypt); |
| 486 |
DEBUGFS_FWSTATS_ADD(rx, rx_tkip_replays); |
| 487 |
DEBUGFS_FWSTATS_ADD(rx, rx_xfr); |
| 488 |
|
| 489 |
DEBUGFS_FWSTATS_ADD(isr, irqs); |
| 490 |
|
| 491 |
DEBUGFS_FWSTATS_ADD(pwr, missing_bcns_cnt); |
| 492 |
DEBUGFS_FWSTATS_ADD(pwr, rcvd_bcns_cnt); |
| 493 |
DEBUGFS_FWSTATS_ADD(pwr, connection_out_of_sync); |
| 494 |
DEBUGFS_FWSTATS_ADD(pwr, cont_miss_bcns_spread); |
| 495 |
DEBUGFS_FWSTATS_ADD(pwr, rcvd_awake_bcns_cnt); |
| 496 |
DEBUGFS_FWSTATS_ADD(pwr, sleep_time_count); |
| 497 |
DEBUGFS_FWSTATS_ADD(pwr, sleep_time_avg); |
| 498 |
DEBUGFS_FWSTATS_ADD(pwr, sleep_cycle_avg); |
| 499 |
DEBUGFS_FWSTATS_ADD(pwr, sleep_percent); |
| 500 |
DEBUGFS_FWSTATS_ADD(pwr, ap_sleep_active_conf); |
| 501 |
DEBUGFS_FWSTATS_ADD(pwr, ap_sleep_user_conf); |
| 502 |
DEBUGFS_FWSTATS_ADD(pwr, ap_sleep_counter); |
| 503 |
|
| 504 |
DEBUGFS_FWSTATS_ADD(rx_filter, beacon_filter); |
| 505 |
DEBUGFS_FWSTATS_ADD(rx_filter, arp_filter); |
| 506 |
DEBUGFS_FWSTATS_ADD(rx_filter, mc_filter); |
| 507 |
DEBUGFS_FWSTATS_ADD(rx_filter, dup_filter); |
| 508 |
DEBUGFS_FWSTATS_ADD(rx_filter, data_filter); |
| 509 |
DEBUGFS_FWSTATS_ADD(rx_filter, ibss_filter); |
| 510 |
DEBUGFS_FWSTATS_ADD(rx_filter, protection_filter); |
| 511 |
DEBUGFS_FWSTATS_ADD(rx_filter, accum_arp_pend_requests); |
| 512 |
DEBUGFS_FWSTATS_ADD(rx_filter, max_arp_queue_dep); |
| 513 |
|
| 514 |
DEBUGFS_FWSTATS_ADD(rx_rate, rx_frames_per_rates); |
| 515 |
|
| 516 |
DEBUGFS_FWSTATS_ADD(aggr_size, tx_agg_rate); |
| 517 |
DEBUGFS_FWSTATS_ADD(aggr_size, tx_agg_len); |
| 518 |
DEBUGFS_FWSTATS_ADD(aggr_size, rx_size); |
| 519 |
|
| 520 |
DEBUGFS_FWSTATS_ADD(pipeline, hs_tx_stat_fifo_int); |
| 521 |
DEBUGFS_FWSTATS_ADD(pipeline, enc_tx_stat_fifo_int); |
| 522 |
DEBUGFS_FWSTATS_ADD(pipeline, enc_rx_stat_fifo_int); |
| 523 |
DEBUGFS_FWSTATS_ADD(pipeline, rx_complete_stat_fifo_int); |
| 524 |
DEBUGFS_FWSTATS_ADD(pipeline, pre_proc_swi); |
| 525 |
DEBUGFS_FWSTATS_ADD(pipeline, post_proc_swi); |
| 526 |
DEBUGFS_FWSTATS_ADD(pipeline, sec_frag_swi); |
| 527 |
DEBUGFS_FWSTATS_ADD(pipeline, pre_to_defrag_swi); |
| 528 |
DEBUGFS_FWSTATS_ADD(pipeline, defrag_to_rx_xfer_swi); |
| 529 |
DEBUGFS_FWSTATS_ADD(pipeline, dec_packet_in); |
| 530 |
DEBUGFS_FWSTATS_ADD(pipeline, dec_packet_in_fifo_full); |
| 531 |
DEBUGFS_FWSTATS_ADD(pipeline, dec_packet_out); |
| 532 |
DEBUGFS_FWSTATS_ADD(pipeline, pipeline_fifo_full); |
| 533 |
|
| 534 |
DEBUGFS_FWSTATS_ADD(diversity, num_of_packets_per_ant); |
| 535 |
DEBUGFS_FWSTATS_ADD(diversity, total_num_of_toggles); |
| 536 |
|
| 537 |
DEBUGFS_FWSTATS_ADD(thermal, irq_thr_low); |
| 538 |
DEBUGFS_FWSTATS_ADD(thermal, irq_thr_high); |
| 539 |
DEBUGFS_FWSTATS_ADD(thermal, tx_stop); |
| 540 |
DEBUGFS_FWSTATS_ADD(thermal, tx_resume); |
| 541 |
DEBUGFS_FWSTATS_ADD(thermal, false_irq); |
| 542 |
DEBUGFS_FWSTATS_ADD(thermal, adc_source_unexpected); |
| 543 |
|
| 544 |
DEBUGFS_FWSTATS_ADD(calib, fail_count); |
| 545 |
|
| 546 |
DEBUGFS_FWSTATS_ADD(calib, calib_count); |
| 547 |
|
| 548 |
DEBUGFS_FWSTATS_ADD(roaming, rssi_level); |
| 549 |
|
| 550 |
DEBUGFS_FWSTATS_ADD(dfs, num_of_radar_detections); |
| 551 |
|
| 552 |
DEBUGFS_ADD(conf, moddir); |
| 553 |
DEBUGFS_ADD(radar_detection, moddir); |
| 554 |
#ifdef CONFIG_CFG80211_CERTIFICATION_ONUS |
| 555 |
DEBUGFS_ADD(radar_debug_mode, moddir); |
| 556 |
#endif |
| 557 |
DEBUGFS_ADD(dynamic_fw_traces, moddir); |
| 558 |
|
| 559 |
return 0; |
| 560 |
} |