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