1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2 /* Copyright(c) 2018-2019 Realtek Corporation 3 */ 4 5 #include <linux/debugfs.h> 6 #include <linux/seq_file.h> 7 #include "main.h" 8 #include "coex.h" 9 #include "sec.h" 10 #include "fw.h" 11 #include "debug.h" 12 #include "phy.h" 13 #include "reg.h" 14 #include "ps.h" 15 #include "regd.h" 16 17 #ifdef CONFIG_RTW88_DEBUGFS 18 19 struct rtw_debugfs_priv { 20 struct rtw_dev *rtwdev; 21 int (*cb_read)(struct seq_file *m, void *v); 22 ssize_t (*cb_write)(struct file *filp, const char __user *buffer, 23 size_t count, loff_t *loff); 24 union { 25 u32 cb_data; 26 u8 *buf; 27 struct { 28 u32 page_offset; 29 u32 page_num; 30 } rsvd_page; 31 struct { 32 u8 rf_path; 33 u32 rf_addr; 34 u32 rf_mask; 35 }; 36 struct { 37 u32 addr; 38 u32 len; 39 } read_reg; 40 struct { 41 u8 bit; 42 } dm_cap; 43 }; 44 }; 45 46 static const char * const rtw_dm_cap_strs[] = { 47 [RTW_DM_CAP_NA] = "NA", 48 [RTW_DM_CAP_TXGAPK] = "TXGAPK", 49 }; 50 51 static int rtw_debugfs_single_show(struct seq_file *m, void *v) 52 { 53 struct rtw_debugfs_priv *debugfs_priv = m->private; 54 55 return debugfs_priv->cb_read(m, v); 56 } 57 58 static ssize_t rtw_debugfs_common_write(struct file *filp, 59 const char __user *buffer, 60 size_t count, loff_t *loff) 61 { 62 struct rtw_debugfs_priv *debugfs_priv = filp->private_data; 63 64 return debugfs_priv->cb_write(filp, buffer, count, loff); 65 } 66 67 static ssize_t rtw_debugfs_single_write(struct file *filp, 68 const char __user *buffer, 69 size_t count, loff_t *loff) 70 { 71 struct seq_file *seqpriv = (struct seq_file *)filp->private_data; 72 struct rtw_debugfs_priv *debugfs_priv = seqpriv->private; 73 74 return debugfs_priv->cb_write(filp, buffer, count, loff); 75 } 76 77 static int rtw_debugfs_single_open_rw(struct inode *inode, struct file *filp) 78 { 79 return single_open(filp, rtw_debugfs_single_show, inode->i_private); 80 } 81 82 static int rtw_debugfs_close(struct inode *inode, struct file *filp) 83 { 84 return 0; 85 } 86 87 static const struct file_operations file_ops_single_r = { 88 .owner = THIS_MODULE, 89 .open = rtw_debugfs_single_open_rw, 90 .read = seq_read, 91 .llseek = seq_lseek, 92 .release = single_release, 93 }; 94 95 static const struct file_operations file_ops_single_rw = { 96 .owner = THIS_MODULE, 97 .open = rtw_debugfs_single_open_rw, 98 .release = single_release, 99 .read = seq_read, 100 .llseek = seq_lseek, 101 .write = rtw_debugfs_single_write, 102 }; 103 104 static const struct file_operations file_ops_common_write = { 105 .owner = THIS_MODULE, 106 .write = rtw_debugfs_common_write, 107 .open = simple_open, 108 .release = rtw_debugfs_close, 109 }; 110 111 static int rtw_debugfs_get_read_reg(struct seq_file *m, void *v) 112 { 113 struct rtw_debugfs_priv *debugfs_priv = m->private; 114 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 115 u32 val, len, addr; 116 117 len = debugfs_priv->read_reg.len; 118 addr = debugfs_priv->read_reg.addr; 119 switch (len) { 120 case 1: 121 val = rtw_read8(rtwdev, addr); 122 seq_printf(m, "reg 0x%03x: 0x%02x\n", addr, val); 123 break; 124 case 2: 125 val = rtw_read16(rtwdev, addr); 126 seq_printf(m, "reg 0x%03x: 0x%04x\n", addr, val); 127 break; 128 case 4: 129 val = rtw_read32(rtwdev, addr); 130 seq_printf(m, "reg 0x%03x: 0x%08x\n", addr, val); 131 break; 132 } 133 return 0; 134 } 135 136 static int rtw_debugfs_get_rf_read(struct seq_file *m, void *v) 137 { 138 struct rtw_debugfs_priv *debugfs_priv = m->private; 139 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 140 u32 val, addr, mask; 141 u8 path; 142 143 path = debugfs_priv->rf_path; 144 addr = debugfs_priv->rf_addr; 145 mask = debugfs_priv->rf_mask; 146 147 val = rtw_read_rf(rtwdev, path, addr, mask); 148 149 seq_printf(m, "rf_read path:%d addr:0x%08x mask:0x%08x val=0x%08x\n", 150 path, addr, mask, val); 151 152 return 0; 153 } 154 155 static int rtw_debugfs_copy_from_user(char tmp[], int size, 156 const char __user *buffer, size_t count, 157 int num) 158 { 159 int tmp_len; 160 161 memset(tmp, 0, size); 162 163 if (count < num) 164 return -EFAULT; 165 166 tmp_len = (count > size - 1 ? size - 1 : count); 167 168 if (!buffer || copy_from_user(tmp, buffer, tmp_len)) 169 return count; 170 171 tmp[tmp_len] = '\0'; 172 173 return 0; 174 } 175 176 static ssize_t rtw_debugfs_set_read_reg(struct file *filp, 177 const char __user *buffer, 178 size_t count, loff_t *loff) 179 { 180 struct seq_file *seqpriv = (struct seq_file *)filp->private_data; 181 struct rtw_debugfs_priv *debugfs_priv = seqpriv->private; 182 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 183 char tmp[32 + 1]; 184 u32 addr, len; 185 int num; 186 187 rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2); 188 189 num = sscanf(tmp, "%x %x", &addr, &len); 190 191 if (num != 2) 192 return count; 193 194 if (len != 1 && len != 2 && len != 4) { 195 rtw_warn(rtwdev, "read reg setting wrong len\n"); 196 return -EINVAL; 197 } 198 debugfs_priv->read_reg.addr = addr; 199 debugfs_priv->read_reg.len = len; 200 201 return count; 202 } 203 204 static int rtw_debugfs_get_dump_cam(struct seq_file *m, void *v) 205 { 206 struct rtw_debugfs_priv *debugfs_priv = m->private; 207 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 208 u32 val, command; 209 u32 hw_key_idx = debugfs_priv->cb_data << RTW_SEC_CAM_ENTRY_SHIFT; 210 u32 read_cmd = RTW_SEC_CMD_POLLING; 211 int i; 212 213 seq_printf(m, "cam entry%d\n", debugfs_priv->cb_data); 214 seq_puts(m, "0x0 0x1 0x2 0x3 "); 215 seq_puts(m, "0x4 0x5\n"); 216 mutex_lock(&rtwdev->mutex); 217 for (i = 0; i <= 5; i++) { 218 command = read_cmd | (hw_key_idx + i); 219 rtw_write32(rtwdev, RTW_SEC_CMD_REG, command); 220 val = rtw_read32(rtwdev, RTW_SEC_READ_REG); 221 seq_printf(m, "%8.8x", val); 222 if (i < 2) 223 seq_puts(m, " "); 224 } 225 seq_puts(m, "\n"); 226 mutex_unlock(&rtwdev->mutex); 227 return 0; 228 } 229 230 static int rtw_debugfs_get_rsvd_page(struct seq_file *m, void *v) 231 { 232 struct rtw_debugfs_priv *debugfs_priv = m->private; 233 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 234 u8 page_size = rtwdev->chip->page_size; 235 u32 buf_size = debugfs_priv->rsvd_page.page_num * page_size; 236 u32 offset = debugfs_priv->rsvd_page.page_offset * page_size; 237 u8 *buf; 238 int i; 239 int ret; 240 241 buf = vzalloc(buf_size); 242 if (!buf) 243 return -ENOMEM; 244 245 ret = rtw_fw_dump_fifo(rtwdev, RTW_FW_FIFO_SEL_RSVD_PAGE, offset, 246 buf_size, (u32 *)buf); 247 if (ret) { 248 rtw_err(rtwdev, "failed to dump rsvd page\n"); 249 vfree(buf); 250 return ret; 251 } 252 253 for (i = 0 ; i < buf_size ; i += 8) { 254 if (i % page_size == 0) 255 seq_printf(m, "PAGE %d\n", (i + offset) / page_size); 256 seq_printf(m, "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", 257 *(buf + i), *(buf + i + 1), 258 *(buf + i + 2), *(buf + i + 3), 259 *(buf + i + 4), *(buf + i + 5), 260 *(buf + i + 6), *(buf + i + 7)); 261 } 262 vfree(buf); 263 264 return 0; 265 } 266 267 static ssize_t rtw_debugfs_set_rsvd_page(struct file *filp, 268 const char __user *buffer, 269 size_t count, loff_t *loff) 270 { 271 struct seq_file *seqpriv = (struct seq_file *)filp->private_data; 272 struct rtw_debugfs_priv *debugfs_priv = seqpriv->private; 273 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 274 char tmp[32 + 1]; 275 u32 offset, page_num; 276 int num; 277 278 rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2); 279 280 num = sscanf(tmp, "%d %d", &offset, &page_num); 281 282 if (num != 2) { 283 rtw_warn(rtwdev, "invalid arguments\n"); 284 return -EINVAL; 285 } 286 287 debugfs_priv->rsvd_page.page_offset = offset; 288 debugfs_priv->rsvd_page.page_num = page_num; 289 290 return count; 291 } 292 293 static ssize_t rtw_debugfs_set_single_input(struct file *filp, 294 const char __user *buffer, 295 size_t count, loff_t *loff) 296 { 297 struct seq_file *seqpriv = (struct seq_file *)filp->private_data; 298 struct rtw_debugfs_priv *debugfs_priv = seqpriv->private; 299 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 300 char tmp[32 + 1]; 301 u32 input; 302 int num; 303 304 rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 1); 305 306 num = kstrtoint(tmp, 0, &input); 307 308 if (num) { 309 rtw_warn(rtwdev, "kstrtoint failed\n"); 310 return num; 311 } 312 313 debugfs_priv->cb_data = input; 314 315 return count; 316 } 317 318 static ssize_t rtw_debugfs_set_write_reg(struct file *filp, 319 const char __user *buffer, 320 size_t count, loff_t *loff) 321 { 322 struct rtw_debugfs_priv *debugfs_priv = filp->private_data; 323 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 324 char tmp[32 + 1]; 325 u32 addr, val, len; 326 int num; 327 328 rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3); 329 330 /* write BB/MAC register */ 331 num = sscanf(tmp, "%x %x %x", &addr, &val, &len); 332 333 if (num != 3) 334 return count; 335 336 switch (len) { 337 case 1: 338 rtw_dbg(rtwdev, RTW_DBG_DEBUGFS, 339 "reg write8 0x%03x: 0x%08x\n", addr, val); 340 rtw_write8(rtwdev, addr, (u8)val); 341 break; 342 case 2: 343 rtw_dbg(rtwdev, RTW_DBG_DEBUGFS, 344 "reg write16 0x%03x: 0x%08x\n", addr, val); 345 rtw_write16(rtwdev, addr, (u16)val); 346 break; 347 case 4: 348 rtw_dbg(rtwdev, RTW_DBG_DEBUGFS, 349 "reg write32 0x%03x: 0x%08x\n", addr, val); 350 rtw_write32(rtwdev, addr, (u32)val); 351 break; 352 default: 353 rtw_dbg(rtwdev, RTW_DBG_DEBUGFS, 354 "error write length = %d\n", len); 355 break; 356 } 357 358 return count; 359 } 360 361 static ssize_t rtw_debugfs_set_h2c(struct file *filp, 362 const char __user *buffer, 363 size_t count, loff_t *loff) 364 { 365 struct rtw_debugfs_priv *debugfs_priv = filp->private_data; 366 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 367 char tmp[32 + 1]; 368 u8 param[8]; 369 int num; 370 371 rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3); 372 373 num = sscanf(tmp, "%hhx,%hhx,%hhx,%hhx,%hhx,%hhx,%hhx,%hhx", 374 ¶m[0], ¶m[1], ¶m[2], ¶m[3], 375 ¶m[4], ¶m[5], ¶m[6], ¶m[7]); 376 if (num != 8) { 377 rtw_info(rtwdev, "invalid H2C command format for debug\n"); 378 return -EINVAL; 379 } 380 381 rtw_fw_h2c_cmd_dbg(rtwdev, param); 382 383 return count; 384 } 385 386 static ssize_t rtw_debugfs_set_rf_write(struct file *filp, 387 const char __user *buffer, 388 size_t count, loff_t *loff) 389 { 390 struct rtw_debugfs_priv *debugfs_priv = filp->private_data; 391 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 392 char tmp[32 + 1]; 393 u32 path, addr, mask, val; 394 int num; 395 396 rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 4); 397 398 num = sscanf(tmp, "%x %x %x %x", &path, &addr, &mask, &val); 399 400 if (num != 4) { 401 rtw_warn(rtwdev, "invalid args, [path] [addr] [mask] [val]\n"); 402 return count; 403 } 404 405 rtw_write_rf(rtwdev, path, addr, mask, val); 406 rtw_dbg(rtwdev, RTW_DBG_DEBUGFS, 407 "write_rf path:%d addr:0x%08x mask:0x%08x, val:0x%08x\n", 408 path, addr, mask, val); 409 410 return count; 411 } 412 413 static ssize_t rtw_debugfs_set_rf_read(struct file *filp, 414 const char __user *buffer, 415 size_t count, loff_t *loff) 416 { 417 struct seq_file *seqpriv = (struct seq_file *)filp->private_data; 418 struct rtw_debugfs_priv *debugfs_priv = seqpriv->private; 419 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 420 char tmp[32 + 1]; 421 u32 path, addr, mask; 422 int num; 423 424 rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3); 425 426 num = sscanf(tmp, "%x %x %x", &path, &addr, &mask); 427 428 if (num != 3) { 429 rtw_warn(rtwdev, "invalid args, [path] [addr] [mask] [val]\n"); 430 return count; 431 } 432 433 debugfs_priv->rf_path = path; 434 debugfs_priv->rf_addr = addr; 435 debugfs_priv->rf_mask = mask; 436 437 return count; 438 } 439 440 static int rtw_debug_get_mac_page(struct seq_file *m, void *v) 441 { 442 struct rtw_debugfs_priv *debugfs_priv = m->private; 443 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 444 u32 page = debugfs_priv->cb_data; 445 int i, n; 446 int max = 0xff; 447 448 rtw_read32(rtwdev, debugfs_priv->cb_data); 449 for (n = 0; n <= max; ) { 450 seq_printf(m, "\n%8.8x ", n + page); 451 for (i = 0; i < 4 && n <= max; i++, n += 4) 452 seq_printf(m, "%8.8x ", 453 rtw_read32(rtwdev, (page | n))); 454 } 455 seq_puts(m, "\n"); 456 return 0; 457 } 458 459 static int rtw_debug_get_bb_page(struct seq_file *m, void *v) 460 { 461 struct rtw_debugfs_priv *debugfs_priv = m->private; 462 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 463 u32 page = debugfs_priv->cb_data; 464 int i, n; 465 int max = 0xff; 466 467 rtw_read32(rtwdev, debugfs_priv->cb_data); 468 for (n = 0; n <= max; ) { 469 seq_printf(m, "\n%8.8x ", n + page); 470 for (i = 0; i < 4 && n <= max; i++, n += 4) 471 seq_printf(m, "%8.8x ", 472 rtw_read32(rtwdev, (page | n))); 473 } 474 seq_puts(m, "\n"); 475 return 0; 476 } 477 478 static int rtw_debug_get_rf_dump(struct seq_file *m, void *v) 479 { 480 struct rtw_debugfs_priv *debugfs_priv = m->private; 481 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 482 u32 addr, offset, data; 483 u8 path; 484 485 for (path = 0; path < rtwdev->hal.rf_path_num; path++) { 486 seq_printf(m, "RF path:%d\n", path); 487 for (addr = 0; addr < 0x100; addr += 4) { 488 seq_printf(m, "%8.8x ", addr); 489 for (offset = 0; offset < 4; offset++) { 490 data = rtw_read_rf(rtwdev, path, addr + offset, 491 0xffffffff); 492 seq_printf(m, "%8.8x ", data); 493 } 494 seq_puts(m, "\n"); 495 } 496 seq_puts(m, "\n"); 497 } 498 499 return 0; 500 } 501 502 static void rtw_print_cck_rate_txt(struct seq_file *m, u8 rate) 503 { 504 static const char * const 505 cck_rate[] = {"1M", "2M", "5.5M", "11M"}; 506 u8 idx = rate - DESC_RATE1M; 507 508 seq_printf(m, " CCK_%-5s", cck_rate[idx]); 509 } 510 511 static void rtw_print_ofdm_rate_txt(struct seq_file *m, u8 rate) 512 { 513 static const char * const 514 ofdm_rate[] = {"6M", "9M", "12M", "18M", "24M", "36M", "48M", "54M"}; 515 u8 idx = rate - DESC_RATE6M; 516 517 seq_printf(m, " OFDM_%-4s", ofdm_rate[idx]); 518 } 519 520 static void rtw_print_ht_rate_txt(struct seq_file *m, u8 rate) 521 { 522 u8 mcs_n = rate - DESC_RATEMCS0; 523 524 seq_printf(m, " MCS%-6u", mcs_n); 525 } 526 527 static void rtw_print_vht_rate_txt(struct seq_file *m, u8 rate) 528 { 529 u8 idx = rate - DESC_RATEVHT1SS_MCS0; 530 u8 n_ss, mcs_n; 531 532 /* n spatial stream */ 533 n_ss = 1 + idx / 10; 534 /* MCS n */ 535 mcs_n = idx % 10; 536 seq_printf(m, " VHT%uSMCS%u", n_ss, mcs_n); 537 } 538 539 static void rtw_print_rate(struct seq_file *m, u8 rate) 540 { 541 switch (rate) { 542 case DESC_RATE1M...DESC_RATE11M: 543 rtw_print_cck_rate_txt(m, rate); 544 break; 545 case DESC_RATE6M...DESC_RATE54M: 546 rtw_print_ofdm_rate_txt(m, rate); 547 break; 548 case DESC_RATEMCS0...DESC_RATEMCS15: 549 rtw_print_ht_rate_txt(m, rate); 550 break; 551 case DESC_RATEVHT1SS_MCS0...DESC_RATEVHT2SS_MCS9: 552 rtw_print_vht_rate_txt(m, rate); 553 break; 554 default: 555 seq_printf(m, " Unknown rate=0x%x\n", rate); 556 break; 557 } 558 } 559 560 #define case_REGD(src) \ 561 case RTW_REGD_##src: return #src 562 563 static const char *rtw_get_regd_string(u8 regd) 564 { 565 switch (regd) { 566 case_REGD(FCC); 567 case_REGD(MKK); 568 case_REGD(ETSI); 569 case_REGD(IC); 570 case_REGD(KCC); 571 case_REGD(ACMA); 572 case_REGD(CHILE); 573 case_REGD(UKRAINE); 574 case_REGD(MEXICO); 575 case_REGD(CN); 576 case_REGD(WW); 577 default: 578 return "Unknown"; 579 } 580 } 581 582 static int rtw_debugfs_get_tx_pwr_tbl(struct seq_file *m, void *v) 583 { 584 struct rtw_debugfs_priv *debugfs_priv = m->private; 585 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 586 struct rtw_hal *hal = &rtwdev->hal; 587 u8 path, rate; 588 struct rtw_power_params pwr_param = {0}; 589 u8 bw = hal->current_band_width; 590 u8 ch = hal->current_channel; 591 u8 regd = rtw_regd_get(rtwdev); 592 593 seq_printf(m, "regulatory: %s\n", rtw_get_regd_string(regd)); 594 seq_printf(m, "%-4s %-10s %-3s%6s %-4s %4s (%-4s %-4s) %-4s\n", 595 "path", "rate", "pwr", "", "base", "", "byr", "lmt", "rem"); 596 597 mutex_lock(&hal->tx_power_mutex); 598 for (path = RF_PATH_A; path <= RF_PATH_B; path++) { 599 /* there is no CCK rates used in 5G */ 600 if (hal->current_band_type == RTW_BAND_5G) 601 rate = DESC_RATE6M; 602 else 603 rate = DESC_RATE1M; 604 605 /* now, not support vht 3ss and vht 4ss*/ 606 for (; rate <= DESC_RATEVHT2SS_MCS9; rate++) { 607 /* now, not support ht 3ss and ht 4ss*/ 608 if (rate > DESC_RATEMCS15 && 609 rate < DESC_RATEVHT1SS_MCS0) 610 continue; 611 612 rtw_get_tx_power_params(rtwdev, path, rate, bw, 613 ch, regd, &pwr_param); 614 615 seq_printf(m, "%4c ", path + 'A'); 616 rtw_print_rate(m, rate); 617 seq_printf(m, " %3u(0x%02x) %4u %4d (%4d %4d) %4d\n", 618 hal->tx_pwr_tbl[path][rate], 619 hal->tx_pwr_tbl[path][rate], 620 pwr_param.pwr_base, 621 min_t(s8, pwr_param.pwr_offset, 622 pwr_param.pwr_limit), 623 pwr_param.pwr_offset, pwr_param.pwr_limit, 624 pwr_param.pwr_remnant); 625 } 626 } 627 628 mutex_unlock(&hal->tx_power_mutex); 629 630 return 0; 631 } 632 633 void rtw_debugfs_get_simple_phy_info(struct seq_file *m) 634 { 635 struct rtw_debugfs_priv *debugfs_priv = m->private; 636 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 637 struct rtw_hal *hal = &rtwdev->hal; 638 struct rtw_dm_info *dm_info = &rtwdev->dm_info; 639 struct rtw_traffic_stats *stats = &rtwdev->stats; 640 641 seq_printf(m, "%-40s = %ddBm/ %d\n", "RSSI/ STA Channel", 642 dm_info->rssi[RF_PATH_A] - 100, hal->current_channel); 643 644 seq_printf(m, "TP {Tx, Rx} = {%u, %u}Mbps\n", 645 stats->tx_throughput, stats->rx_throughput); 646 647 seq_puts(m, "[Tx Rate] = "); 648 rtw_print_rate(m, dm_info->tx_rate); 649 seq_printf(m, "(0x%x)\n", dm_info->tx_rate); 650 651 seq_puts(m, "[Rx Rate] = "); 652 rtw_print_rate(m, dm_info->curr_rx_rate); 653 seq_printf(m, "(0x%x)\n", dm_info->curr_rx_rate); 654 } 655 656 static int rtw_debugfs_get_phy_info(struct seq_file *m, void *v) 657 { 658 struct rtw_debugfs_priv *debugfs_priv = m->private; 659 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 660 struct rtw_dm_info *dm_info = &rtwdev->dm_info; 661 struct rtw_traffic_stats *stats = &rtwdev->stats; 662 struct rtw_pkt_count *last_cnt = &dm_info->last_pkt_count; 663 struct rtw_efuse *efuse = &rtwdev->efuse; 664 struct ewma_evm *ewma_evm = dm_info->ewma_evm; 665 struct ewma_snr *ewma_snr = dm_info->ewma_snr; 666 u8 ss, rate_id; 667 668 seq_puts(m, "==========[Common Info]========\n"); 669 seq_printf(m, "Is link = %c\n", rtw_is_assoc(rtwdev) ? 'Y' : 'N'); 670 seq_printf(m, "Current CH(fc) = %u\n", rtwdev->hal.current_channel); 671 seq_printf(m, "Current BW = %u\n", rtwdev->hal.current_band_width); 672 seq_printf(m, "Current IGI = 0x%x\n", dm_info->igi_history[0]); 673 seq_printf(m, "TP {Tx, Rx} = {%u, %u}Mbps\n\n", 674 stats->tx_throughput, stats->rx_throughput); 675 676 seq_puts(m, "==========[Tx Phy Info]========\n"); 677 seq_puts(m, "[Tx Rate] = "); 678 rtw_print_rate(m, dm_info->tx_rate); 679 seq_printf(m, "(0x%x)\n\n", dm_info->tx_rate); 680 681 seq_puts(m, "==========[Rx Phy Info]========\n"); 682 seq_printf(m, "[Rx Beacon Count] = %u\n", last_cnt->num_bcn_pkt); 683 seq_puts(m, "[Rx Rate] = "); 684 rtw_print_rate(m, dm_info->curr_rx_rate); 685 seq_printf(m, "(0x%x)\n", dm_info->curr_rx_rate); 686 687 seq_puts(m, "[Rx Rate Count]:\n"); 688 seq_printf(m, " * CCK = {%u, %u, %u, %u}\n", 689 last_cnt->num_qry_pkt[DESC_RATE1M], 690 last_cnt->num_qry_pkt[DESC_RATE2M], 691 last_cnt->num_qry_pkt[DESC_RATE5_5M], 692 last_cnt->num_qry_pkt[DESC_RATE11M]); 693 694 seq_printf(m, " * OFDM = {%u, %u, %u, %u, %u, %u, %u, %u}\n", 695 last_cnt->num_qry_pkt[DESC_RATE6M], 696 last_cnt->num_qry_pkt[DESC_RATE9M], 697 last_cnt->num_qry_pkt[DESC_RATE12M], 698 last_cnt->num_qry_pkt[DESC_RATE18M], 699 last_cnt->num_qry_pkt[DESC_RATE24M], 700 last_cnt->num_qry_pkt[DESC_RATE36M], 701 last_cnt->num_qry_pkt[DESC_RATE48M], 702 last_cnt->num_qry_pkt[DESC_RATE54M]); 703 704 for (ss = 0; ss < efuse->hw_cap.nss; ss++) { 705 rate_id = DESC_RATEMCS0 + ss * 8; 706 seq_printf(m, " * HT_MCS[%u:%u] = {%u, %u, %u, %u, %u, %u, %u, %u}\n", 707 ss * 8, ss * 8 + 7, 708 last_cnt->num_qry_pkt[rate_id], 709 last_cnt->num_qry_pkt[rate_id + 1], 710 last_cnt->num_qry_pkt[rate_id + 2], 711 last_cnt->num_qry_pkt[rate_id + 3], 712 last_cnt->num_qry_pkt[rate_id + 4], 713 last_cnt->num_qry_pkt[rate_id + 5], 714 last_cnt->num_qry_pkt[rate_id + 6], 715 last_cnt->num_qry_pkt[rate_id + 7]); 716 } 717 718 for (ss = 0; ss < efuse->hw_cap.nss; ss++) { 719 rate_id = DESC_RATEVHT1SS_MCS0 + ss * 10; 720 seq_printf(m, " * VHT_MCS-%uss MCS[0:9] = {%u, %u, %u, %u, %u, %u, %u, %u, %u, %u}\n", 721 ss + 1, 722 last_cnt->num_qry_pkt[rate_id], 723 last_cnt->num_qry_pkt[rate_id + 1], 724 last_cnt->num_qry_pkt[rate_id + 2], 725 last_cnt->num_qry_pkt[rate_id + 3], 726 last_cnt->num_qry_pkt[rate_id + 4], 727 last_cnt->num_qry_pkt[rate_id + 5], 728 last_cnt->num_qry_pkt[rate_id + 6], 729 last_cnt->num_qry_pkt[rate_id + 7], 730 last_cnt->num_qry_pkt[rate_id + 8], 731 last_cnt->num_qry_pkt[rate_id + 9]); 732 } 733 734 seq_printf(m, "[RSSI(dBm)] = {%d, %d}\n", 735 dm_info->rssi[RF_PATH_A] - 100, 736 dm_info->rssi[RF_PATH_B] - 100); 737 seq_printf(m, "[Rx EVM(dB)] = {-%d, -%d}\n", 738 dm_info->rx_evm_dbm[RF_PATH_A], 739 dm_info->rx_evm_dbm[RF_PATH_B]); 740 seq_printf(m, "[Rx SNR] = {%d, %d}\n", 741 dm_info->rx_snr[RF_PATH_A], 742 dm_info->rx_snr[RF_PATH_B]); 743 seq_printf(m, "[CFO_tail(KHz)] = {%d, %d}\n", 744 dm_info->cfo_tail[RF_PATH_A], 745 dm_info->cfo_tail[RF_PATH_B]); 746 747 if (dm_info->curr_rx_rate >= DESC_RATE11M) { 748 seq_puts(m, "[Rx Average Status]:\n"); 749 seq_printf(m, " * OFDM, EVM: {-%d}, SNR: {%d}\n", 750 (u8)ewma_evm_read(&ewma_evm[RTW_EVM_OFDM]), 751 (u8)ewma_snr_read(&ewma_snr[RTW_SNR_OFDM_A])); 752 seq_printf(m, " * 1SS, EVM: {-%d}, SNR: {%d}\n", 753 (u8)ewma_evm_read(&ewma_evm[RTW_EVM_1SS]), 754 (u8)ewma_snr_read(&ewma_snr[RTW_SNR_1SS_A])); 755 seq_printf(m, " * 2SS, EVM: {-%d, -%d}, SNR: {%d, %d}\n", 756 (u8)ewma_evm_read(&ewma_evm[RTW_EVM_2SS_A]), 757 (u8)ewma_evm_read(&ewma_evm[RTW_EVM_2SS_B]), 758 (u8)ewma_snr_read(&ewma_snr[RTW_SNR_2SS_A]), 759 (u8)ewma_snr_read(&ewma_snr[RTW_SNR_2SS_B])); 760 } 761 762 seq_puts(m, "[Rx Counter]:\n"); 763 seq_printf(m, " * CCA (CCK, OFDM, Total) = (%u, %u, %u)\n", 764 dm_info->cck_cca_cnt, 765 dm_info->ofdm_cca_cnt, 766 dm_info->total_cca_cnt); 767 seq_printf(m, " * False Alarm (CCK, OFDM, Total) = (%u, %u, %u)\n", 768 dm_info->cck_fa_cnt, 769 dm_info->ofdm_fa_cnt, 770 dm_info->total_fa_cnt); 771 seq_printf(m, " * CCK cnt (ok, err) = (%u, %u)\n", 772 dm_info->cck_ok_cnt, dm_info->cck_err_cnt); 773 seq_printf(m, " * OFDM cnt (ok, err) = (%u, %u)\n", 774 dm_info->ofdm_ok_cnt, dm_info->ofdm_err_cnt); 775 seq_printf(m, " * HT cnt (ok, err) = (%u, %u)\n", 776 dm_info->ht_ok_cnt, dm_info->ht_err_cnt); 777 seq_printf(m, " * VHT cnt (ok, err) = (%u, %u)\n", 778 dm_info->vht_ok_cnt, dm_info->vht_err_cnt); 779 780 return 0; 781 } 782 783 static int rtw_debugfs_get_coex_info(struct seq_file *m, void *v) 784 { 785 struct rtw_debugfs_priv *debugfs_priv = m->private; 786 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 787 788 rtw_coex_display_coex_info(rtwdev, m); 789 790 return 0; 791 } 792 793 static ssize_t rtw_debugfs_set_coex_enable(struct file *filp, 794 const char __user *buffer, 795 size_t count, loff_t *loff) 796 { 797 struct seq_file *seqpriv = (struct seq_file *)filp->private_data; 798 struct rtw_debugfs_priv *debugfs_priv = seqpriv->private; 799 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 800 struct rtw_coex *coex = &rtwdev->coex; 801 char tmp[32 + 1]; 802 bool enable; 803 int ret; 804 805 rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 1); 806 807 ret = kstrtobool(tmp, &enable); 808 if (ret) { 809 rtw_warn(rtwdev, "invalid arguments\n"); 810 return ret; 811 } 812 813 mutex_lock(&rtwdev->mutex); 814 coex->manual_control = !enable; 815 mutex_unlock(&rtwdev->mutex); 816 817 return count; 818 } 819 820 static int rtw_debugfs_get_coex_enable(struct seq_file *m, void *v) 821 { 822 struct rtw_debugfs_priv *debugfs_priv = m->private; 823 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 824 struct rtw_coex *coex = &rtwdev->coex; 825 826 seq_printf(m, "coex mechanism %s\n", 827 coex->manual_control ? "disabled" : "enabled"); 828 829 return 0; 830 } 831 832 static ssize_t rtw_debugfs_set_edcca_enable(struct file *filp, 833 const char __user *buffer, 834 size_t count, loff_t *loff) 835 { 836 struct seq_file *seqpriv = (struct seq_file *)filp->private_data; 837 struct rtw_debugfs_priv *debugfs_priv = seqpriv->private; 838 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 839 bool input; 840 int err; 841 842 err = kstrtobool_from_user(buffer, count, &input); 843 if (err) 844 return err; 845 846 rtw_edcca_enabled = input; 847 rtw_phy_adaptivity_set_mode(rtwdev); 848 849 return count; 850 } 851 852 static int rtw_debugfs_get_edcca_enable(struct seq_file *m, void *v) 853 { 854 struct rtw_debugfs_priv *debugfs_priv = m->private; 855 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 856 struct rtw_dm_info *dm_info = &rtwdev->dm_info; 857 858 seq_printf(m, "EDCCA %s: EDCCA mode %d\n", 859 rtw_edcca_enabled ? "enabled" : "disabled", 860 dm_info->edcca_mode); 861 return 0; 862 } 863 864 static ssize_t rtw_debugfs_set_fw_crash(struct file *filp, 865 const char __user *buffer, 866 size_t count, loff_t *loff) 867 { 868 struct seq_file *seqpriv = (struct seq_file *)filp->private_data; 869 struct rtw_debugfs_priv *debugfs_priv = seqpriv->private; 870 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 871 char tmp[32 + 1]; 872 bool input; 873 int ret; 874 875 rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 1); 876 877 ret = kstrtobool(tmp, &input); 878 if (ret) 879 return -EINVAL; 880 881 if (!input) 882 return -EINVAL; 883 884 if (test_bit(RTW_FLAG_RESTARTING, rtwdev->flags)) 885 return -EINPROGRESS; 886 887 mutex_lock(&rtwdev->mutex); 888 rtw_leave_lps_deep(rtwdev); 889 set_bit(RTW_FLAG_RESTART_TRIGGERING, rtwdev->flags); 890 rtw_write8(rtwdev, REG_HRCV_MSG, 1); 891 mutex_unlock(&rtwdev->mutex); 892 893 return count; 894 } 895 896 static int rtw_debugfs_get_fw_crash(struct seq_file *m, void *v) 897 { 898 struct rtw_debugfs_priv *debugfs_priv = m->private; 899 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 900 901 seq_printf(m, "%d\n", 902 test_bit(RTW_FLAG_RESTART_TRIGGERING, rtwdev->flags) || 903 test_bit(RTW_FLAG_RESTARTING, rtwdev->flags)); 904 return 0; 905 } 906 907 static ssize_t rtw_debugfs_set_dm_cap(struct file *filp, 908 const char __user *buffer, 909 size_t count, loff_t *loff) 910 { 911 struct seq_file *seqpriv = (struct seq_file *)filp->private_data; 912 struct rtw_debugfs_priv *debugfs_priv = seqpriv->private; 913 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 914 struct rtw_dm_info *dm_info = &rtwdev->dm_info; 915 int bit; 916 bool en; 917 918 if (kstrtoint_from_user(buffer, count, 10, &bit)) 919 return -EINVAL; 920 921 en = bit > 0; 922 bit = abs(bit); 923 924 if (bit >= RTW_DM_CAP_NUM) { 925 rtw_warn(rtwdev, "unknown DM CAP %d\n", bit); 926 return -EINVAL; 927 } 928 929 if (en) 930 dm_info->dm_flags &= ~BIT(bit); 931 else 932 dm_info->dm_flags |= BIT(bit); 933 934 debugfs_priv->dm_cap.bit = bit; 935 936 return count; 937 } 938 939 static void dump_gapk_status(struct rtw_dev *rtwdev, struct seq_file *m) 940 { 941 struct rtw_dm_info *dm_info = &rtwdev->dm_info; 942 struct rtw_gapk_info *txgapk = &rtwdev->dm_info.gapk; 943 int i, path; 944 u32 val; 945 946 seq_printf(m, "\n(%2d) %c%s\n\n", RTW_DM_CAP_TXGAPK, 947 dm_info->dm_flags & BIT(RTW_DM_CAP_TXGAPK) ? '-' : '+', 948 rtw_dm_cap_strs[RTW_DM_CAP_TXGAPK]); 949 950 for (path = 0; path < rtwdev->hal.rf_path_num; path++) { 951 val = rtw_read_rf(rtwdev, path, RF_GAINTX, RFREG_MASK); 952 seq_printf(m, "path %d:\n0x%x = 0x%x\n", path, RF_GAINTX, val); 953 954 for (i = 0; i < RF_HW_OFFSET_NUM; i++) 955 seq_printf(m, "[TXGAPK] offset %d %d\n", 956 txgapk->rf3f_fs[path][i], i); 957 seq_puts(m, "\n"); 958 } 959 } 960 961 static int rtw_debugfs_get_dm_cap(struct seq_file *m, void *v) 962 { 963 struct rtw_debugfs_priv *debugfs_priv = m->private; 964 struct rtw_dev *rtwdev = debugfs_priv->rtwdev; 965 struct rtw_dm_info *dm_info = &rtwdev->dm_info; 966 int i; 967 968 switch (debugfs_priv->dm_cap.bit) { 969 case RTW_DM_CAP_TXGAPK: 970 dump_gapk_status(rtwdev, m); 971 break; 972 default: 973 for (i = 1; i < RTW_DM_CAP_NUM; i++) { 974 seq_printf(m, "(%2d) %c%s\n", i, 975 dm_info->dm_flags & BIT(i) ? '-' : '+', 976 rtw_dm_cap_strs[i]); 977 } 978 break; 979 } 980 debugfs_priv->dm_cap.bit = RTW_DM_CAP_NA; 981 return 0; 982 } 983 984 #define rtw_debug_impl_mac(page, addr) \ 985 static struct rtw_debugfs_priv rtw_debug_priv_mac_ ##page = { \ 986 .cb_read = rtw_debug_get_mac_page, \ 987 .cb_data = addr, \ 988 } 989 990 rtw_debug_impl_mac(0, 0x0000); 991 rtw_debug_impl_mac(1, 0x0100); 992 rtw_debug_impl_mac(2, 0x0200); 993 rtw_debug_impl_mac(3, 0x0300); 994 rtw_debug_impl_mac(4, 0x0400); 995 rtw_debug_impl_mac(5, 0x0500); 996 rtw_debug_impl_mac(6, 0x0600); 997 rtw_debug_impl_mac(7, 0x0700); 998 rtw_debug_impl_mac(10, 0x1000); 999 rtw_debug_impl_mac(11, 0x1100); 1000 rtw_debug_impl_mac(12, 0x1200); 1001 rtw_debug_impl_mac(13, 0x1300); 1002 rtw_debug_impl_mac(14, 0x1400); 1003 rtw_debug_impl_mac(15, 0x1500); 1004 rtw_debug_impl_mac(16, 0x1600); 1005 rtw_debug_impl_mac(17, 0x1700); 1006 1007 #define rtw_debug_impl_bb(page, addr) \ 1008 static struct rtw_debugfs_priv rtw_debug_priv_bb_ ##page = { \ 1009 .cb_read = rtw_debug_get_bb_page, \ 1010 .cb_data = addr, \ 1011 } 1012 1013 rtw_debug_impl_bb(8, 0x0800); 1014 rtw_debug_impl_bb(9, 0x0900); 1015 rtw_debug_impl_bb(a, 0x0a00); 1016 rtw_debug_impl_bb(b, 0x0b00); 1017 rtw_debug_impl_bb(c, 0x0c00); 1018 rtw_debug_impl_bb(d, 0x0d00); 1019 rtw_debug_impl_bb(e, 0x0e00); 1020 rtw_debug_impl_bb(f, 0x0f00); 1021 rtw_debug_impl_bb(18, 0x1800); 1022 rtw_debug_impl_bb(19, 0x1900); 1023 rtw_debug_impl_bb(1a, 0x1a00); 1024 rtw_debug_impl_bb(1b, 0x1b00); 1025 rtw_debug_impl_bb(1c, 0x1c00); 1026 rtw_debug_impl_bb(1d, 0x1d00); 1027 rtw_debug_impl_bb(1e, 0x1e00); 1028 rtw_debug_impl_bb(1f, 0x1f00); 1029 rtw_debug_impl_bb(2c, 0x2c00); 1030 rtw_debug_impl_bb(2d, 0x2d00); 1031 rtw_debug_impl_bb(40, 0x4000); 1032 rtw_debug_impl_bb(41, 0x4100); 1033 1034 static struct rtw_debugfs_priv rtw_debug_priv_rf_dump = { 1035 .cb_read = rtw_debug_get_rf_dump, 1036 }; 1037 1038 static struct rtw_debugfs_priv rtw_debug_priv_tx_pwr_tbl = { 1039 .cb_read = rtw_debugfs_get_tx_pwr_tbl, 1040 }; 1041 1042 static struct rtw_debugfs_priv rtw_debug_priv_write_reg = { 1043 .cb_write = rtw_debugfs_set_write_reg, 1044 }; 1045 1046 static struct rtw_debugfs_priv rtw_debug_priv_h2c = { 1047 .cb_write = rtw_debugfs_set_h2c, 1048 }; 1049 1050 static struct rtw_debugfs_priv rtw_debug_priv_rf_write = { 1051 .cb_write = rtw_debugfs_set_rf_write, 1052 }; 1053 1054 static struct rtw_debugfs_priv rtw_debug_priv_rf_read = { 1055 .cb_write = rtw_debugfs_set_rf_read, 1056 .cb_read = rtw_debugfs_get_rf_read, 1057 }; 1058 1059 static struct rtw_debugfs_priv rtw_debug_priv_read_reg = { 1060 .cb_write = rtw_debugfs_set_read_reg, 1061 .cb_read = rtw_debugfs_get_read_reg, 1062 }; 1063 1064 static struct rtw_debugfs_priv rtw_debug_priv_dump_cam = { 1065 .cb_write = rtw_debugfs_set_single_input, 1066 .cb_read = rtw_debugfs_get_dump_cam, 1067 }; 1068 1069 static struct rtw_debugfs_priv rtw_debug_priv_rsvd_page = { 1070 .cb_write = rtw_debugfs_set_rsvd_page, 1071 .cb_read = rtw_debugfs_get_rsvd_page, 1072 }; 1073 1074 static struct rtw_debugfs_priv rtw_debug_priv_phy_info = { 1075 .cb_read = rtw_debugfs_get_phy_info, 1076 }; 1077 1078 static struct rtw_debugfs_priv rtw_debug_priv_coex_enable = { 1079 .cb_write = rtw_debugfs_set_coex_enable, 1080 .cb_read = rtw_debugfs_get_coex_enable, 1081 }; 1082 1083 static struct rtw_debugfs_priv rtw_debug_priv_coex_info = { 1084 .cb_read = rtw_debugfs_get_coex_info, 1085 }; 1086 1087 static struct rtw_debugfs_priv rtw_debug_priv_edcca_enable = { 1088 .cb_write = rtw_debugfs_set_edcca_enable, 1089 .cb_read = rtw_debugfs_get_edcca_enable, 1090 }; 1091 1092 static struct rtw_debugfs_priv rtw_debug_priv_fw_crash = { 1093 .cb_write = rtw_debugfs_set_fw_crash, 1094 .cb_read = rtw_debugfs_get_fw_crash, 1095 }; 1096 1097 static struct rtw_debugfs_priv rtw_debug_priv_dm_cap = { 1098 .cb_write = rtw_debugfs_set_dm_cap, 1099 .cb_read = rtw_debugfs_get_dm_cap, 1100 }; 1101 1102 #define rtw_debugfs_add_core(name, mode, fopname, parent) \ 1103 do { \ 1104 rtw_debug_priv_ ##name.rtwdev = rtwdev; \ 1105 if (!debugfs_create_file(#name, mode, \ 1106 parent, &rtw_debug_priv_ ##name,\ 1107 &file_ops_ ##fopname)) \ 1108 pr_debug("Unable to initialize debugfs:%s\n", \ 1109 #name); \ 1110 } while (0) 1111 1112 #define rtw_debugfs_add_w(name) \ 1113 rtw_debugfs_add_core(name, S_IFREG | 0222, common_write, debugfs_topdir) 1114 #define rtw_debugfs_add_rw(name) \ 1115 rtw_debugfs_add_core(name, S_IFREG | 0666, single_rw, debugfs_topdir) 1116 #define rtw_debugfs_add_r(name) \ 1117 rtw_debugfs_add_core(name, S_IFREG | 0444, single_r, debugfs_topdir) 1118 1119 void rtw_debugfs_init(struct rtw_dev *rtwdev) 1120 { 1121 struct dentry *debugfs_topdir; 1122 1123 debugfs_topdir = debugfs_create_dir("rtw88", 1124 rtwdev->hw->wiphy->debugfsdir); 1125 rtw_debugfs_add_w(write_reg); 1126 rtw_debugfs_add_rw(read_reg); 1127 rtw_debugfs_add_w(rf_write); 1128 rtw_debugfs_add_rw(rf_read); 1129 rtw_debugfs_add_rw(dump_cam); 1130 rtw_debugfs_add_rw(rsvd_page); 1131 rtw_debugfs_add_r(phy_info); 1132 rtw_debugfs_add_r(coex_info); 1133 rtw_debugfs_add_rw(coex_enable); 1134 rtw_debugfs_add_w(h2c); 1135 rtw_debugfs_add_r(mac_0); 1136 rtw_debugfs_add_r(mac_1); 1137 rtw_debugfs_add_r(mac_2); 1138 rtw_debugfs_add_r(mac_3); 1139 rtw_debugfs_add_r(mac_4); 1140 rtw_debugfs_add_r(mac_5); 1141 rtw_debugfs_add_r(mac_6); 1142 rtw_debugfs_add_r(mac_7); 1143 rtw_debugfs_add_r(bb_8); 1144 rtw_debugfs_add_r(bb_9); 1145 rtw_debugfs_add_r(bb_a); 1146 rtw_debugfs_add_r(bb_b); 1147 rtw_debugfs_add_r(bb_c); 1148 rtw_debugfs_add_r(bb_d); 1149 rtw_debugfs_add_r(bb_e); 1150 rtw_debugfs_add_r(bb_f); 1151 rtw_debugfs_add_r(mac_10); 1152 rtw_debugfs_add_r(mac_11); 1153 rtw_debugfs_add_r(mac_12); 1154 rtw_debugfs_add_r(mac_13); 1155 rtw_debugfs_add_r(mac_14); 1156 rtw_debugfs_add_r(mac_15); 1157 rtw_debugfs_add_r(mac_16); 1158 rtw_debugfs_add_r(mac_17); 1159 rtw_debugfs_add_r(bb_18); 1160 rtw_debugfs_add_r(bb_19); 1161 rtw_debugfs_add_r(bb_1a); 1162 rtw_debugfs_add_r(bb_1b); 1163 rtw_debugfs_add_r(bb_1c); 1164 rtw_debugfs_add_r(bb_1d); 1165 rtw_debugfs_add_r(bb_1e); 1166 rtw_debugfs_add_r(bb_1f); 1167 if (rtwdev->chip->id == RTW_CHIP_TYPE_8822C) { 1168 rtw_debugfs_add_r(bb_2c); 1169 rtw_debugfs_add_r(bb_2d); 1170 rtw_debugfs_add_r(bb_40); 1171 rtw_debugfs_add_r(bb_41); 1172 } 1173 rtw_debugfs_add_r(rf_dump); 1174 rtw_debugfs_add_r(tx_pwr_tbl); 1175 rtw_debugfs_add_rw(edcca_enable); 1176 rtw_debugfs_add_rw(fw_crash); 1177 rtw_debugfs_add_rw(dm_cap); 1178 } 1179 1180 #endif /* CONFIG_RTW88_DEBUGFS */ 1181 1182 #ifdef CONFIG_RTW88_DEBUG 1183 1184 void __rtw_dbg(struct rtw_dev *rtwdev, enum rtw_debug_mask mask, 1185 const char *fmt, ...) 1186 { 1187 struct va_format vaf = { 1188 .fmt = fmt, 1189 }; 1190 va_list args; 1191 1192 va_start(args, fmt); 1193 vaf.va = &args; 1194 1195 if (rtw_debug_mask & mask) 1196 dev_printk(KERN_DEBUG, rtwdev->dev, "%pV", &vaf); 1197 1198 va_end(args); 1199 } 1200 EXPORT_SYMBOL(__rtw_dbg); 1201 1202 #endif /* CONFIG_RTW88_DEBUG */ 1203