1 // SPDX-License-Identifier: GPL-2.0-only 2 /****************************************************************************** 3 * 4 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 5 * 6 * Contact Information: 7 * Intel Linux Wireless <ilw@linux.intel.com> 8 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 9 *****************************************************************************/ 10 #include "common.h" 11 #include "4965.h" 12 13 static const char *fmt_value = " %-30s %10u\n"; 14 static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; 15 static const char *fmt_header = 16 "%-32s current cumulative delta max\n"; 17 18 static int 19 il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) 20 { 21 int p = 0; 22 u32 flag; 23 24 flag = le32_to_cpu(il->_4965.stats.flag); 25 26 p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); 27 if (flag & UCODE_STATS_CLEAR_MSK) 28 p += scnprintf(buf + p, bufsz - p, 29 "\tStatistics have been cleared\n"); 30 p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", 31 (flag & UCODE_STATS_FREQUENCY_MSK) ? "2.4 GHz" : 32 "5.2 GHz"); 33 p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", 34 (flag & UCODE_STATS_NARROW_BAND_MSK) ? "enabled" : 35 "disabled"); 36 37 return p; 38 } 39 40 static ssize_t 41 il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, 42 size_t count, loff_t *ppos) 43 { 44 struct il_priv *il = file->private_data; 45 int pos = 0; 46 char *buf; 47 int bufsz = 48 sizeof(struct stats_rx_phy) * 40 + 49 sizeof(struct stats_rx_non_phy) * 40 + 50 sizeof(struct stats_rx_ht_phy) * 40 + 400; 51 ssize_t ret; 52 struct stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; 53 struct stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; 54 struct stats_rx_non_phy *general, *accum_general; 55 struct stats_rx_non_phy *delta_general, *max_general; 56 struct stats_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; 57 58 if (!il_is_alive(il)) 59 return -EAGAIN; 60 61 buf = kzalloc(bufsz, GFP_KERNEL); 62 if (!buf) { 63 IL_ERR("Can not allocate Buffer\n"); 64 return -ENOMEM; 65 } 66 67 /* 68 * the statistic information display here is based on 69 * the last stats notification from uCode 70 * might not reflect the current uCode activity 71 */ 72 ofdm = &il->_4965.stats.rx.ofdm; 73 cck = &il->_4965.stats.rx.cck; 74 general = &il->_4965.stats.rx.general; 75 ht = &il->_4965.stats.rx.ofdm_ht; 76 accum_ofdm = &il->_4965.accum_stats.rx.ofdm; 77 accum_cck = &il->_4965.accum_stats.rx.cck; 78 accum_general = &il->_4965.accum_stats.rx.general; 79 accum_ht = &il->_4965.accum_stats.rx.ofdm_ht; 80 delta_ofdm = &il->_4965.delta_stats.rx.ofdm; 81 delta_cck = &il->_4965.delta_stats.rx.cck; 82 delta_general = &il->_4965.delta_stats.rx.general; 83 delta_ht = &il->_4965.delta_stats.rx.ofdm_ht; 84 max_ofdm = &il->_4965.max_delta.rx.ofdm; 85 max_cck = &il->_4965.max_delta.rx.cck; 86 max_general = &il->_4965.max_delta.rx.general; 87 max_ht = &il->_4965.max_delta.rx.ofdm_ht; 88 89 pos += il4965_stats_flag(il, buf, bufsz); 90 pos += 91 scnprintf(buf + pos, bufsz - pos, fmt_header, 92 "Statistics_Rx - OFDM:"); 93 pos += 94 scnprintf(buf + pos, bufsz - pos, fmt_table, "ina_cnt:", 95 le32_to_cpu(ofdm->ina_cnt), accum_ofdm->ina_cnt, 96 delta_ofdm->ina_cnt, max_ofdm->ina_cnt); 97 pos += 98 scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_cnt:", 99 le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, 100 delta_ofdm->fina_cnt, max_ofdm->fina_cnt); 101 pos += 102 scnprintf(buf + pos, bufsz - pos, fmt_table, "plcp_err:", 103 le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, 104 delta_ofdm->plcp_err, max_ofdm->plcp_err); 105 pos += 106 scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_err:", 107 le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, 108 delta_ofdm->crc32_err, max_ofdm->crc32_err); 109 pos += 110 scnprintf(buf + pos, bufsz - pos, fmt_table, "overrun_err:", 111 le32_to_cpu(ofdm->overrun_err), accum_ofdm->overrun_err, 112 delta_ofdm->overrun_err, max_ofdm->overrun_err); 113 pos += 114 scnprintf(buf + pos, bufsz - pos, fmt_table, "early_overrun_err:", 115 le32_to_cpu(ofdm->early_overrun_err), 116 accum_ofdm->early_overrun_err, 117 delta_ofdm->early_overrun_err, 118 max_ofdm->early_overrun_err); 119 pos += 120 scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_good:", 121 le32_to_cpu(ofdm->crc32_good), accum_ofdm->crc32_good, 122 delta_ofdm->crc32_good, max_ofdm->crc32_good); 123 pos += 124 scnprintf(buf + pos, bufsz - pos, fmt_table, "false_alarm_cnt:", 125 le32_to_cpu(ofdm->false_alarm_cnt), 126 accum_ofdm->false_alarm_cnt, delta_ofdm->false_alarm_cnt, 127 max_ofdm->false_alarm_cnt); 128 pos += 129 scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_sync_err_cnt:", 130 le32_to_cpu(ofdm->fina_sync_err_cnt), 131 accum_ofdm->fina_sync_err_cnt, 132 delta_ofdm->fina_sync_err_cnt, 133 max_ofdm->fina_sync_err_cnt); 134 pos += 135 scnprintf(buf + pos, bufsz - pos, fmt_table, "sfd_timeout:", 136 le32_to_cpu(ofdm->sfd_timeout), accum_ofdm->sfd_timeout, 137 delta_ofdm->sfd_timeout, max_ofdm->sfd_timeout); 138 pos += 139 scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_timeout:", 140 le32_to_cpu(ofdm->fina_timeout), accum_ofdm->fina_timeout, 141 delta_ofdm->fina_timeout, max_ofdm->fina_timeout); 142 pos += 143 scnprintf(buf + pos, bufsz - pos, fmt_table, "unresponded_rts:", 144 le32_to_cpu(ofdm->unresponded_rts), 145 accum_ofdm->unresponded_rts, delta_ofdm->unresponded_rts, 146 max_ofdm->unresponded_rts); 147 pos += 148 scnprintf(buf + pos, bufsz - pos, fmt_table, "rxe_frame_lmt_ovrun:", 149 le32_to_cpu(ofdm->rxe_frame_limit_overrun), 150 accum_ofdm->rxe_frame_limit_overrun, 151 delta_ofdm->rxe_frame_limit_overrun, 152 max_ofdm->rxe_frame_limit_overrun); 153 pos += 154 scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ack_cnt:", 155 le32_to_cpu(ofdm->sent_ack_cnt), accum_ofdm->sent_ack_cnt, 156 delta_ofdm->sent_ack_cnt, max_ofdm->sent_ack_cnt); 157 pos += 158 scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_cts_cnt:", 159 le32_to_cpu(ofdm->sent_cts_cnt), accum_ofdm->sent_cts_cnt, 160 delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt); 161 pos += 162 scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ba_rsp_cnt:", 163 le32_to_cpu(ofdm->sent_ba_rsp_cnt), 164 accum_ofdm->sent_ba_rsp_cnt, delta_ofdm->sent_ba_rsp_cnt, 165 max_ofdm->sent_ba_rsp_cnt); 166 pos += 167 scnprintf(buf + pos, bufsz - pos, fmt_table, "dsp_self_kill:", 168 le32_to_cpu(ofdm->dsp_self_kill), 169 accum_ofdm->dsp_self_kill, delta_ofdm->dsp_self_kill, 170 max_ofdm->dsp_self_kill); 171 pos += 172 scnprintf(buf + pos, bufsz - pos, fmt_table, "mh_format_err:", 173 le32_to_cpu(ofdm->mh_format_err), 174 accum_ofdm->mh_format_err, delta_ofdm->mh_format_err, 175 max_ofdm->mh_format_err); 176 pos += 177 scnprintf(buf + pos, bufsz - pos, fmt_table, 178 "re_acq_main_rssi_sum:", 179 le32_to_cpu(ofdm->re_acq_main_rssi_sum), 180 accum_ofdm->re_acq_main_rssi_sum, 181 delta_ofdm->re_acq_main_rssi_sum, 182 max_ofdm->re_acq_main_rssi_sum); 183 184 pos += 185 scnprintf(buf + pos, bufsz - pos, fmt_header, 186 "Statistics_Rx - CCK:"); 187 pos += 188 scnprintf(buf + pos, bufsz - pos, fmt_table, "ina_cnt:", 189 le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, 190 delta_cck->ina_cnt, max_cck->ina_cnt); 191 pos += 192 scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_cnt:", 193 le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, 194 delta_cck->fina_cnt, max_cck->fina_cnt); 195 pos += 196 scnprintf(buf + pos, bufsz - pos, fmt_table, "plcp_err:", 197 le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, 198 delta_cck->plcp_err, max_cck->plcp_err); 199 pos += 200 scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_err:", 201 le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, 202 delta_cck->crc32_err, max_cck->crc32_err); 203 pos += 204 scnprintf(buf + pos, bufsz - pos, fmt_table, "overrun_err:", 205 le32_to_cpu(cck->overrun_err), accum_cck->overrun_err, 206 delta_cck->overrun_err, max_cck->overrun_err); 207 pos += 208 scnprintf(buf + pos, bufsz - pos, fmt_table, "early_overrun_err:", 209 le32_to_cpu(cck->early_overrun_err), 210 accum_cck->early_overrun_err, 211 delta_cck->early_overrun_err, max_cck->early_overrun_err); 212 pos += 213 scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_good:", 214 le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, 215 delta_cck->crc32_good, max_cck->crc32_good); 216 pos += 217 scnprintf(buf + pos, bufsz - pos, fmt_table, "false_alarm_cnt:", 218 le32_to_cpu(cck->false_alarm_cnt), 219 accum_cck->false_alarm_cnt, delta_cck->false_alarm_cnt, 220 max_cck->false_alarm_cnt); 221 pos += 222 scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_sync_err_cnt:", 223 le32_to_cpu(cck->fina_sync_err_cnt), 224 accum_cck->fina_sync_err_cnt, 225 delta_cck->fina_sync_err_cnt, max_cck->fina_sync_err_cnt); 226 pos += 227 scnprintf(buf + pos, bufsz - pos, fmt_table, "sfd_timeout:", 228 le32_to_cpu(cck->sfd_timeout), accum_cck->sfd_timeout, 229 delta_cck->sfd_timeout, max_cck->sfd_timeout); 230 pos += 231 scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_timeout:", 232 le32_to_cpu(cck->fina_timeout), accum_cck->fina_timeout, 233 delta_cck->fina_timeout, max_cck->fina_timeout); 234 pos += 235 scnprintf(buf + pos, bufsz - pos, fmt_table, "unresponded_rts:", 236 le32_to_cpu(cck->unresponded_rts), 237 accum_cck->unresponded_rts, delta_cck->unresponded_rts, 238 max_cck->unresponded_rts); 239 pos += 240 scnprintf(buf + pos, bufsz - pos, fmt_table, "rxe_frame_lmt_ovrun:", 241 le32_to_cpu(cck->rxe_frame_limit_overrun), 242 accum_cck->rxe_frame_limit_overrun, 243 delta_cck->rxe_frame_limit_overrun, 244 max_cck->rxe_frame_limit_overrun); 245 pos += 246 scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ack_cnt:", 247 le32_to_cpu(cck->sent_ack_cnt), accum_cck->sent_ack_cnt, 248 delta_cck->sent_ack_cnt, max_cck->sent_ack_cnt); 249 pos += 250 scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_cts_cnt:", 251 le32_to_cpu(cck->sent_cts_cnt), accum_cck->sent_cts_cnt, 252 delta_cck->sent_cts_cnt, max_cck->sent_cts_cnt); 253 pos += 254 scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ba_rsp_cnt:", 255 le32_to_cpu(cck->sent_ba_rsp_cnt), 256 accum_cck->sent_ba_rsp_cnt, delta_cck->sent_ba_rsp_cnt, 257 max_cck->sent_ba_rsp_cnt); 258 pos += 259 scnprintf(buf + pos, bufsz - pos, fmt_table, "dsp_self_kill:", 260 le32_to_cpu(cck->dsp_self_kill), accum_cck->dsp_self_kill, 261 delta_cck->dsp_self_kill, max_cck->dsp_self_kill); 262 pos += 263 scnprintf(buf + pos, bufsz - pos, fmt_table, "mh_format_err:", 264 le32_to_cpu(cck->mh_format_err), accum_cck->mh_format_err, 265 delta_cck->mh_format_err, max_cck->mh_format_err); 266 pos += 267 scnprintf(buf + pos, bufsz - pos, fmt_table, 268 "re_acq_main_rssi_sum:", 269 le32_to_cpu(cck->re_acq_main_rssi_sum), 270 accum_cck->re_acq_main_rssi_sum, 271 delta_cck->re_acq_main_rssi_sum, 272 max_cck->re_acq_main_rssi_sum); 273 274 pos += 275 scnprintf(buf + pos, bufsz - pos, fmt_header, 276 "Statistics_Rx - GENERAL:"); 277 pos += 278 scnprintf(buf + pos, bufsz - pos, fmt_table, "bogus_cts:", 279 le32_to_cpu(general->bogus_cts), accum_general->bogus_cts, 280 delta_general->bogus_cts, max_general->bogus_cts); 281 pos += 282 scnprintf(buf + pos, bufsz - pos, fmt_table, "bogus_ack:", 283 le32_to_cpu(general->bogus_ack), accum_general->bogus_ack, 284 delta_general->bogus_ack, max_general->bogus_ack); 285 pos += 286 scnprintf(buf + pos, bufsz - pos, fmt_table, "non_bssid_frames:", 287 le32_to_cpu(general->non_bssid_frames), 288 accum_general->non_bssid_frames, 289 delta_general->non_bssid_frames, 290 max_general->non_bssid_frames); 291 pos += 292 scnprintf(buf + pos, bufsz - pos, fmt_table, "filtered_frames:", 293 le32_to_cpu(general->filtered_frames), 294 accum_general->filtered_frames, 295 delta_general->filtered_frames, 296 max_general->filtered_frames); 297 pos += 298 scnprintf(buf + pos, bufsz - pos, fmt_table, "non_channel_beacons:", 299 le32_to_cpu(general->non_channel_beacons), 300 accum_general->non_channel_beacons, 301 delta_general->non_channel_beacons, 302 max_general->non_channel_beacons); 303 pos += 304 scnprintf(buf + pos, bufsz - pos, fmt_table, "channel_beacons:", 305 le32_to_cpu(general->channel_beacons), 306 accum_general->channel_beacons, 307 delta_general->channel_beacons, 308 max_general->channel_beacons); 309 pos += 310 scnprintf(buf + pos, bufsz - pos, fmt_table, "num_missed_bcon:", 311 le32_to_cpu(general->num_missed_bcon), 312 accum_general->num_missed_bcon, 313 delta_general->num_missed_bcon, 314 max_general->num_missed_bcon); 315 pos += 316 scnprintf(buf + pos, bufsz - pos, fmt_table, 317 "adc_rx_saturation_time:", 318 le32_to_cpu(general->adc_rx_saturation_time), 319 accum_general->adc_rx_saturation_time, 320 delta_general->adc_rx_saturation_time, 321 max_general->adc_rx_saturation_time); 322 pos += 323 scnprintf(buf + pos, bufsz - pos, fmt_table, 324 "ina_detect_search_tm:", 325 le32_to_cpu(general->ina_detection_search_time), 326 accum_general->ina_detection_search_time, 327 delta_general->ina_detection_search_time, 328 max_general->ina_detection_search_time); 329 pos += 330 scnprintf(buf + pos, bufsz - pos, fmt_table, 331 "beacon_silence_rssi_a:", 332 le32_to_cpu(general->beacon_silence_rssi_a), 333 accum_general->beacon_silence_rssi_a, 334 delta_general->beacon_silence_rssi_a, 335 max_general->beacon_silence_rssi_a); 336 pos += 337 scnprintf(buf + pos, bufsz - pos, fmt_table, 338 "beacon_silence_rssi_b:", 339 le32_to_cpu(general->beacon_silence_rssi_b), 340 accum_general->beacon_silence_rssi_b, 341 delta_general->beacon_silence_rssi_b, 342 max_general->beacon_silence_rssi_b); 343 pos += 344 scnprintf(buf + pos, bufsz - pos, fmt_table, 345 "beacon_silence_rssi_c:", 346 le32_to_cpu(general->beacon_silence_rssi_c), 347 accum_general->beacon_silence_rssi_c, 348 delta_general->beacon_silence_rssi_c, 349 max_general->beacon_silence_rssi_c); 350 pos += 351 scnprintf(buf + pos, bufsz - pos, fmt_table, 352 "interference_data_flag:", 353 le32_to_cpu(general->interference_data_flag), 354 accum_general->interference_data_flag, 355 delta_general->interference_data_flag, 356 max_general->interference_data_flag); 357 pos += 358 scnprintf(buf + pos, bufsz - pos, fmt_table, "channel_load:", 359 le32_to_cpu(general->channel_load), 360 accum_general->channel_load, delta_general->channel_load, 361 max_general->channel_load); 362 pos += 363 scnprintf(buf + pos, bufsz - pos, fmt_table, "dsp_false_alarms:", 364 le32_to_cpu(general->dsp_false_alarms), 365 accum_general->dsp_false_alarms, 366 delta_general->dsp_false_alarms, 367 max_general->dsp_false_alarms); 368 pos += 369 scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_rssi_a:", 370 le32_to_cpu(general->beacon_rssi_a), 371 accum_general->beacon_rssi_a, 372 delta_general->beacon_rssi_a, max_general->beacon_rssi_a); 373 pos += 374 scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_rssi_b:", 375 le32_to_cpu(general->beacon_rssi_b), 376 accum_general->beacon_rssi_b, 377 delta_general->beacon_rssi_b, max_general->beacon_rssi_b); 378 pos += 379 scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_rssi_c:", 380 le32_to_cpu(general->beacon_rssi_c), 381 accum_general->beacon_rssi_c, 382 delta_general->beacon_rssi_c, max_general->beacon_rssi_c); 383 pos += 384 scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_energy_a:", 385 le32_to_cpu(general->beacon_energy_a), 386 accum_general->beacon_energy_a, 387 delta_general->beacon_energy_a, 388 max_general->beacon_energy_a); 389 pos += 390 scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_energy_b:", 391 le32_to_cpu(general->beacon_energy_b), 392 accum_general->beacon_energy_b, 393 delta_general->beacon_energy_b, 394 max_general->beacon_energy_b); 395 pos += 396 scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_energy_c:", 397 le32_to_cpu(general->beacon_energy_c), 398 accum_general->beacon_energy_c, 399 delta_general->beacon_energy_c, 400 max_general->beacon_energy_c); 401 402 pos += 403 scnprintf(buf + pos, bufsz - pos, fmt_header, 404 "Statistics_Rx - OFDM_HT:"); 405 pos += 406 scnprintf(buf + pos, bufsz - pos, fmt_table, "plcp_err:", 407 le32_to_cpu(ht->plcp_err), accum_ht->plcp_err, 408 delta_ht->plcp_err, max_ht->plcp_err); 409 pos += 410 scnprintf(buf + pos, bufsz - pos, fmt_table, "overrun_err:", 411 le32_to_cpu(ht->overrun_err), accum_ht->overrun_err, 412 delta_ht->overrun_err, max_ht->overrun_err); 413 pos += 414 scnprintf(buf + pos, bufsz - pos, fmt_table, "early_overrun_err:", 415 le32_to_cpu(ht->early_overrun_err), 416 accum_ht->early_overrun_err, delta_ht->early_overrun_err, 417 max_ht->early_overrun_err); 418 pos += 419 scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_good:", 420 le32_to_cpu(ht->crc32_good), accum_ht->crc32_good, 421 delta_ht->crc32_good, max_ht->crc32_good); 422 pos += 423 scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_err:", 424 le32_to_cpu(ht->crc32_err), accum_ht->crc32_err, 425 delta_ht->crc32_err, max_ht->crc32_err); 426 pos += 427 scnprintf(buf + pos, bufsz - pos, fmt_table, "mh_format_err:", 428 le32_to_cpu(ht->mh_format_err), accum_ht->mh_format_err, 429 delta_ht->mh_format_err, max_ht->mh_format_err); 430 pos += 431 scnprintf(buf + pos, bufsz - pos, fmt_table, "agg_crc32_good:", 432 le32_to_cpu(ht->agg_crc32_good), accum_ht->agg_crc32_good, 433 delta_ht->agg_crc32_good, max_ht->agg_crc32_good); 434 pos += 435 scnprintf(buf + pos, bufsz - pos, fmt_table, "agg_mpdu_cnt:", 436 le32_to_cpu(ht->agg_mpdu_cnt), accum_ht->agg_mpdu_cnt, 437 delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt); 438 pos += 439 scnprintf(buf + pos, bufsz - pos, fmt_table, "agg_cnt:", 440 le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt, 441 delta_ht->agg_cnt, max_ht->agg_cnt); 442 pos += 443 scnprintf(buf + pos, bufsz - pos, fmt_table, "unsupport_mcs:", 444 le32_to_cpu(ht->unsupport_mcs), accum_ht->unsupport_mcs, 445 delta_ht->unsupport_mcs, max_ht->unsupport_mcs); 446 447 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 448 kfree(buf); 449 return ret; 450 } 451 452 static ssize_t 453 il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, 454 size_t count, loff_t *ppos) 455 { 456 struct il_priv *il = file->private_data; 457 int pos = 0; 458 char *buf; 459 int bufsz = (sizeof(struct stats_tx) * 48) + 250; 460 ssize_t ret; 461 struct stats_tx *tx, *accum_tx, *delta_tx, *max_tx; 462 463 if (!il_is_alive(il)) 464 return -EAGAIN; 465 466 buf = kzalloc(bufsz, GFP_KERNEL); 467 if (!buf) { 468 IL_ERR("Can not allocate Buffer\n"); 469 return -ENOMEM; 470 } 471 472 /* the statistic information display here is based on 473 * the last stats notification from uCode 474 * might not reflect the current uCode activity 475 */ 476 tx = &il->_4965.stats.tx; 477 accum_tx = &il->_4965.accum_stats.tx; 478 delta_tx = &il->_4965.delta_stats.tx; 479 max_tx = &il->_4965.max_delta.tx; 480 481 pos += il4965_stats_flag(il, buf, bufsz); 482 pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Tx:"); 483 pos += 484 scnprintf(buf + pos, bufsz - pos, fmt_table, "preamble:", 485 le32_to_cpu(tx->preamble_cnt), accum_tx->preamble_cnt, 486 delta_tx->preamble_cnt, max_tx->preamble_cnt); 487 pos += 488 scnprintf(buf + pos, bufsz - pos, fmt_table, "rx_detected_cnt:", 489 le32_to_cpu(tx->rx_detected_cnt), 490 accum_tx->rx_detected_cnt, delta_tx->rx_detected_cnt, 491 max_tx->rx_detected_cnt); 492 pos += 493 scnprintf(buf + pos, bufsz - pos, fmt_table, "bt_prio_defer_cnt:", 494 le32_to_cpu(tx->bt_prio_defer_cnt), 495 accum_tx->bt_prio_defer_cnt, delta_tx->bt_prio_defer_cnt, 496 max_tx->bt_prio_defer_cnt); 497 pos += 498 scnprintf(buf + pos, bufsz - pos, fmt_table, "bt_prio_kill_cnt:", 499 le32_to_cpu(tx->bt_prio_kill_cnt), 500 accum_tx->bt_prio_kill_cnt, delta_tx->bt_prio_kill_cnt, 501 max_tx->bt_prio_kill_cnt); 502 pos += 503 scnprintf(buf + pos, bufsz - pos, fmt_table, "few_bytes_cnt:", 504 le32_to_cpu(tx->few_bytes_cnt), accum_tx->few_bytes_cnt, 505 delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); 506 pos += 507 scnprintf(buf + pos, bufsz - pos, fmt_table, "cts_timeout:", 508 le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, 509 delta_tx->cts_timeout, max_tx->cts_timeout); 510 pos += 511 scnprintf(buf + pos, bufsz - pos, fmt_table, "ack_timeout:", 512 le32_to_cpu(tx->ack_timeout), accum_tx->ack_timeout, 513 delta_tx->ack_timeout, max_tx->ack_timeout); 514 pos += 515 scnprintf(buf + pos, bufsz - pos, fmt_table, "expected_ack_cnt:", 516 le32_to_cpu(tx->expected_ack_cnt), 517 accum_tx->expected_ack_cnt, delta_tx->expected_ack_cnt, 518 max_tx->expected_ack_cnt); 519 pos += 520 scnprintf(buf + pos, bufsz - pos, fmt_table, "actual_ack_cnt:", 521 le32_to_cpu(tx->actual_ack_cnt), accum_tx->actual_ack_cnt, 522 delta_tx->actual_ack_cnt, max_tx->actual_ack_cnt); 523 pos += 524 scnprintf(buf + pos, bufsz - pos, fmt_table, "dump_msdu_cnt:", 525 le32_to_cpu(tx->dump_msdu_cnt), accum_tx->dump_msdu_cnt, 526 delta_tx->dump_msdu_cnt, max_tx->dump_msdu_cnt); 527 pos += 528 scnprintf(buf + pos, bufsz - pos, fmt_table, 529 "abort_nxt_frame_mismatch:", 530 le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt), 531 accum_tx->burst_abort_next_frame_mismatch_cnt, 532 delta_tx->burst_abort_next_frame_mismatch_cnt, 533 max_tx->burst_abort_next_frame_mismatch_cnt); 534 pos += 535 scnprintf(buf + pos, bufsz - pos, fmt_table, 536 "abort_missing_nxt_frame:", 537 le32_to_cpu(tx->burst_abort_missing_next_frame_cnt), 538 accum_tx->burst_abort_missing_next_frame_cnt, 539 delta_tx->burst_abort_missing_next_frame_cnt, 540 max_tx->burst_abort_missing_next_frame_cnt); 541 pos += 542 scnprintf(buf + pos, bufsz - pos, fmt_table, 543 "cts_timeout_collision:", 544 le32_to_cpu(tx->cts_timeout_collision), 545 accum_tx->cts_timeout_collision, 546 delta_tx->cts_timeout_collision, 547 max_tx->cts_timeout_collision); 548 pos += 549 scnprintf(buf + pos, bufsz - pos, fmt_table, 550 "ack_ba_timeout_collision:", 551 le32_to_cpu(tx->ack_or_ba_timeout_collision), 552 accum_tx->ack_or_ba_timeout_collision, 553 delta_tx->ack_or_ba_timeout_collision, 554 max_tx->ack_or_ba_timeout_collision); 555 pos += 556 scnprintf(buf + pos, bufsz - pos, fmt_table, "agg ba_timeout:", 557 le32_to_cpu(tx->agg.ba_timeout), accum_tx->agg.ba_timeout, 558 delta_tx->agg.ba_timeout, max_tx->agg.ba_timeout); 559 pos += 560 scnprintf(buf + pos, bufsz - pos, fmt_table, 561 "agg ba_resched_frames:", 562 le32_to_cpu(tx->agg.ba_reschedule_frames), 563 accum_tx->agg.ba_reschedule_frames, 564 delta_tx->agg.ba_reschedule_frames, 565 max_tx->agg.ba_reschedule_frames); 566 pos += 567 scnprintf(buf + pos, bufsz - pos, fmt_table, 568 "agg scd_query_agg_frame:", 569 le32_to_cpu(tx->agg.scd_query_agg_frame_cnt), 570 accum_tx->agg.scd_query_agg_frame_cnt, 571 delta_tx->agg.scd_query_agg_frame_cnt, 572 max_tx->agg.scd_query_agg_frame_cnt); 573 pos += 574 scnprintf(buf + pos, bufsz - pos, fmt_table, 575 "agg scd_query_no_agg:", 576 le32_to_cpu(tx->agg.scd_query_no_agg), 577 accum_tx->agg.scd_query_no_agg, 578 delta_tx->agg.scd_query_no_agg, 579 max_tx->agg.scd_query_no_agg); 580 pos += 581 scnprintf(buf + pos, bufsz - pos, fmt_table, "agg scd_query_agg:", 582 le32_to_cpu(tx->agg.scd_query_agg), 583 accum_tx->agg.scd_query_agg, delta_tx->agg.scd_query_agg, 584 max_tx->agg.scd_query_agg); 585 pos += 586 scnprintf(buf + pos, bufsz - pos, fmt_table, 587 "agg scd_query_mismatch:", 588 le32_to_cpu(tx->agg.scd_query_mismatch), 589 accum_tx->agg.scd_query_mismatch, 590 delta_tx->agg.scd_query_mismatch, 591 max_tx->agg.scd_query_mismatch); 592 pos += 593 scnprintf(buf + pos, bufsz - pos, fmt_table, "agg frame_not_ready:", 594 le32_to_cpu(tx->agg.frame_not_ready), 595 accum_tx->agg.frame_not_ready, 596 delta_tx->agg.frame_not_ready, 597 max_tx->agg.frame_not_ready); 598 pos += 599 scnprintf(buf + pos, bufsz - pos, fmt_table, "agg underrun:", 600 le32_to_cpu(tx->agg.underrun), accum_tx->agg.underrun, 601 delta_tx->agg.underrun, max_tx->agg.underrun); 602 pos += 603 scnprintf(buf + pos, bufsz - pos, fmt_table, "agg bt_prio_kill:", 604 le32_to_cpu(tx->agg.bt_prio_kill), 605 accum_tx->agg.bt_prio_kill, delta_tx->agg.bt_prio_kill, 606 max_tx->agg.bt_prio_kill); 607 pos += 608 scnprintf(buf + pos, bufsz - pos, fmt_table, "agg rx_ba_rsp_cnt:", 609 le32_to_cpu(tx->agg.rx_ba_rsp_cnt), 610 accum_tx->agg.rx_ba_rsp_cnt, delta_tx->agg.rx_ba_rsp_cnt, 611 max_tx->agg.rx_ba_rsp_cnt); 612 613 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 614 kfree(buf); 615 return ret; 616 } 617 618 static ssize_t 619 il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, 620 size_t count, loff_t *ppos) 621 { 622 struct il_priv *il = file->private_data; 623 int pos = 0; 624 char *buf; 625 int bufsz = sizeof(struct stats_general) * 10 + 300; 626 ssize_t ret; 627 struct stats_general_common *general, *accum_general; 628 struct stats_general_common *delta_general, *max_general; 629 struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; 630 struct stats_div *div, *accum_div, *delta_div, *max_div; 631 632 if (!il_is_alive(il)) 633 return -EAGAIN; 634 635 buf = kzalloc(bufsz, GFP_KERNEL); 636 if (!buf) { 637 IL_ERR("Can not allocate Buffer\n"); 638 return -ENOMEM; 639 } 640 641 /* the statistic information display here is based on 642 * the last stats notification from uCode 643 * might not reflect the current uCode activity 644 */ 645 general = &il->_4965.stats.general.common; 646 dbg = &il->_4965.stats.general.common.dbg; 647 div = &il->_4965.stats.general.common.div; 648 accum_general = &il->_4965.accum_stats.general.common; 649 accum_dbg = &il->_4965.accum_stats.general.common.dbg; 650 accum_div = &il->_4965.accum_stats.general.common.div; 651 delta_general = &il->_4965.delta_stats.general.common; 652 max_general = &il->_4965.max_delta.general.common; 653 delta_dbg = &il->_4965.delta_stats.general.common.dbg; 654 max_dbg = &il->_4965.max_delta.general.common.dbg; 655 delta_div = &il->_4965.delta_stats.general.common.div; 656 max_div = &il->_4965.max_delta.general.common.div; 657 658 pos += il4965_stats_flag(il, buf, bufsz); 659 pos += 660 scnprintf(buf + pos, bufsz - pos, fmt_header, 661 "Statistics_General:"); 662 pos += 663 scnprintf(buf + pos, bufsz - pos, fmt_value, "temperature:", 664 le32_to_cpu(general->temperature)); 665 pos += 666 scnprintf(buf + pos, bufsz - pos, fmt_value, "ttl_timestamp:", 667 le32_to_cpu(general->ttl_timestamp)); 668 pos += 669 scnprintf(buf + pos, bufsz - pos, fmt_table, "burst_check:", 670 le32_to_cpu(dbg->burst_check), accum_dbg->burst_check, 671 delta_dbg->burst_check, max_dbg->burst_check); 672 pos += 673 scnprintf(buf + pos, bufsz - pos, fmt_table, "burst_count:", 674 le32_to_cpu(dbg->burst_count), accum_dbg->burst_count, 675 delta_dbg->burst_count, max_dbg->burst_count); 676 pos += 677 scnprintf(buf + pos, bufsz - pos, fmt_table, 678 "wait_for_silence_timeout_count:", 679 le32_to_cpu(dbg->wait_for_silence_timeout_cnt), 680 accum_dbg->wait_for_silence_timeout_cnt, 681 delta_dbg->wait_for_silence_timeout_cnt, 682 max_dbg->wait_for_silence_timeout_cnt); 683 pos += 684 scnprintf(buf + pos, bufsz - pos, fmt_table, "sleep_time:", 685 le32_to_cpu(general->sleep_time), 686 accum_general->sleep_time, delta_general->sleep_time, 687 max_general->sleep_time); 688 pos += 689 scnprintf(buf + pos, bufsz - pos, fmt_table, "slots_out:", 690 le32_to_cpu(general->slots_out), accum_general->slots_out, 691 delta_general->slots_out, max_general->slots_out); 692 pos += 693 scnprintf(buf + pos, bufsz - pos, fmt_table, "slots_idle:", 694 le32_to_cpu(general->slots_idle), 695 accum_general->slots_idle, delta_general->slots_idle, 696 max_general->slots_idle); 697 pos += 698 scnprintf(buf + pos, bufsz - pos, fmt_table, "tx_on_a:", 699 le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, 700 delta_div->tx_on_a, max_div->tx_on_a); 701 pos += 702 scnprintf(buf + pos, bufsz - pos, fmt_table, "tx_on_b:", 703 le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, 704 delta_div->tx_on_b, max_div->tx_on_b); 705 pos += 706 scnprintf(buf + pos, bufsz - pos, fmt_table, "exec_time:", 707 le32_to_cpu(div->exec_time), accum_div->exec_time, 708 delta_div->exec_time, max_div->exec_time); 709 pos += 710 scnprintf(buf + pos, bufsz - pos, fmt_table, "probe_time:", 711 le32_to_cpu(div->probe_time), accum_div->probe_time, 712 delta_div->probe_time, max_div->probe_time); 713 pos += 714 scnprintf(buf + pos, bufsz - pos, fmt_table, "rx_enable_counter:", 715 le32_to_cpu(general->rx_enable_counter), 716 accum_general->rx_enable_counter, 717 delta_general->rx_enable_counter, 718 max_general->rx_enable_counter); 719 pos += 720 scnprintf(buf + pos, bufsz - pos, fmt_table, "num_of_sos_states:", 721 le32_to_cpu(general->num_of_sos_states), 722 accum_general->num_of_sos_states, 723 delta_general->num_of_sos_states, 724 max_general->num_of_sos_states); 725 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 726 kfree(buf); 727 return ret; 728 } 729 730 const struct il_debugfs_ops il4965_debugfs_ops = { 731 .rx_stats_read = il4965_ucode_rx_stats_read, 732 .tx_stats_read = il4965_ucode_tx_stats_read, 733 .general_stats_read = il4965_ucode_general_stats_read, 734 }; 735