root/drivers/net/wireless/realtek/rtw88/debug.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. rtw_debugfs_single_show
  2. rtw_debugfs_common_write
  3. rtw_debugfs_single_write
  4. rtw_debugfs_single_open_rw
  5. rtw_debugfs_close
  6. rtw_debugfs_get_read_reg
  7. rtw_debugfs_get_rf_read
  8. rtw_debugfs_copy_from_user
  9. rtw_debugfs_set_read_reg
  10. rtw_debugfs_get_dump_cam
  11. rtw_debugfs_get_rsvd_page
  12. rtw_debugfs_set_rsvd_page
  13. rtw_debugfs_set_single_input
  14. rtw_debugfs_set_write_reg
  15. rtw_debugfs_set_rf_write
  16. rtw_debugfs_set_rf_read
  17. rtw_debug_get_mac_page
  18. rtw_debug_get_bb_page
  19. rtw_debug_get_rf_dump
  20. rtw_print_cck_rate_txt
  21. rtw_print_ofdm_rate_txt
  22. rtw_print_ht_rate_txt
  23. rtw_print_vht_rate_txt
  24. rtw_debugfs_get_tx_pwr_tbl
  25. rtw_debugfs_init
  26. __rtw_dbg

   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 "sec.h"
   9 #include "fw.h"
  10 #include "debug.h"
  11 #include "phy.h"
  12 
  13 #ifdef CONFIG_RTW88_DEBUGFS
  14 
  15 struct rtw_debugfs_priv {
  16         struct rtw_dev *rtwdev;
  17         int (*cb_read)(struct seq_file *m, void *v);
  18         ssize_t (*cb_write)(struct file *filp, const char __user *buffer,
  19                             size_t count, loff_t *loff);
  20         union {
  21                 u32 cb_data;
  22                 u8 *buf;
  23                 struct {
  24                         u32 page_offset;
  25                         u32 page_num;
  26                 } rsvd_page;
  27                 struct {
  28                         u8 rf_path;
  29                         u32 rf_addr;
  30                         u32 rf_mask;
  31                 };
  32                 struct {
  33                         u32 addr;
  34                         u32 len;
  35                 } read_reg;
  36         };
  37 };
  38 
  39 static int rtw_debugfs_single_show(struct seq_file *m, void *v)
  40 {
  41         struct rtw_debugfs_priv *debugfs_priv = m->private;
  42 
  43         return debugfs_priv->cb_read(m, v);
  44 }
  45 
  46 static ssize_t rtw_debugfs_common_write(struct file *filp,
  47                                         const char __user *buffer,
  48                                         size_t count, loff_t *loff)
  49 {
  50         struct rtw_debugfs_priv *debugfs_priv = filp->private_data;
  51 
  52         return debugfs_priv->cb_write(filp, buffer, count, loff);
  53 }
  54 
  55 static ssize_t rtw_debugfs_single_write(struct file *filp,
  56                                         const char __user *buffer,
  57                                         size_t count, loff_t *loff)
  58 {
  59         struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
  60         struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
  61 
  62         return debugfs_priv->cb_write(filp, buffer, count, loff);
  63 }
  64 
  65 static int rtw_debugfs_single_open_rw(struct inode *inode, struct file *filp)
  66 {
  67         return single_open(filp, rtw_debugfs_single_show, inode->i_private);
  68 }
  69 
  70 static int rtw_debugfs_close(struct inode *inode, struct file *filp)
  71 {
  72         return 0;
  73 }
  74 
  75 static const struct file_operations file_ops_single_r = {
  76         .owner = THIS_MODULE,
  77         .open = rtw_debugfs_single_open_rw,
  78         .read = seq_read,
  79         .llseek = seq_lseek,
  80         .release = single_release,
  81 };
  82 
  83 static const struct file_operations file_ops_single_rw = {
  84         .owner = THIS_MODULE,
  85         .open = rtw_debugfs_single_open_rw,
  86         .release = single_release,
  87         .read = seq_read,
  88         .llseek = seq_lseek,
  89         .write = rtw_debugfs_single_write,
  90 };
  91 
  92 static const struct file_operations file_ops_common_write = {
  93         .owner = THIS_MODULE,
  94         .write = rtw_debugfs_common_write,
  95         .open = simple_open,
  96         .release = rtw_debugfs_close,
  97 };
  98 
  99 static int rtw_debugfs_get_read_reg(struct seq_file *m, void *v)
 100 {
 101         struct rtw_debugfs_priv *debugfs_priv = m->private;
 102         struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 103         u32 val, len, addr;
 104 
 105         len = debugfs_priv->read_reg.len;
 106         addr = debugfs_priv->read_reg.addr;
 107         switch (len) {
 108         case 1:
 109                 val = rtw_read8(rtwdev, addr);
 110                 seq_printf(m, "reg 0x%03x: 0x%02x\n", addr, val);
 111                 break;
 112         case 2:
 113                 val = rtw_read16(rtwdev, addr);
 114                 seq_printf(m, "reg 0x%03x: 0x%04x\n", addr, val);
 115                 break;
 116         case 4:
 117                 val = rtw_read32(rtwdev, addr);
 118                 seq_printf(m, "reg 0x%03x: 0x%08x\n", addr, val);
 119                 break;
 120         }
 121         return 0;
 122 }
 123 
 124 static int rtw_debugfs_get_rf_read(struct seq_file *m, void *v)
 125 {
 126         struct rtw_debugfs_priv *debugfs_priv = m->private;
 127         struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 128         u32 val, addr, mask;
 129         u8 path;
 130 
 131         path = debugfs_priv->rf_path;
 132         addr = debugfs_priv->rf_addr;
 133         mask = debugfs_priv->rf_mask;
 134 
 135         val = rtw_read_rf(rtwdev, path, addr, mask);
 136 
 137         seq_printf(m, "rf_read path:%d addr:0x%08x mask:0x%08x val=0x%08x\n",
 138                    path, addr, mask, val);
 139 
 140         return 0;
 141 }
 142 
 143 static int rtw_debugfs_copy_from_user(char tmp[], int size,
 144                                       const char __user *buffer, size_t count,
 145                                       int num)
 146 {
 147         int tmp_len;
 148 
 149         if (count < num)
 150                 return -EFAULT;
 151 
 152         tmp_len = (count > size - 1 ? size - 1 : count);
 153 
 154         if (!buffer || copy_from_user(tmp, buffer, tmp_len))
 155                 return count;
 156 
 157         tmp[tmp_len] = '\0';
 158 
 159         return 0;
 160 }
 161 
 162 static ssize_t rtw_debugfs_set_read_reg(struct file *filp,
 163                                         const char __user *buffer,
 164                                         size_t count, loff_t *loff)
 165 {
 166         struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
 167         struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 168         struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 169         char tmp[32 + 1];
 170         u32 addr, len;
 171         int num;
 172 
 173         rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2);
 174 
 175         num = sscanf(tmp, "%x %x", &addr, &len);
 176 
 177         if (num !=  2)
 178                 return count;
 179 
 180         if (len != 1 && len != 2 && len != 4) {
 181                 rtw_warn(rtwdev, "read reg setting wrong len\n");
 182                 return -EINVAL;
 183         }
 184         debugfs_priv->read_reg.addr = addr;
 185         debugfs_priv->read_reg.len = len;
 186 
 187         return count;
 188 }
 189 
 190 static int rtw_debugfs_get_dump_cam(struct seq_file *m, void *v)
 191 {
 192         struct rtw_debugfs_priv *debugfs_priv = m->private;
 193         struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 194         u32 val, command;
 195         u32 hw_key_idx = debugfs_priv->cb_data << RTW_SEC_CAM_ENTRY_SHIFT;
 196         u32 read_cmd = RTW_SEC_CMD_POLLING;
 197         int i;
 198 
 199         seq_printf(m, "cam entry%d\n", debugfs_priv->cb_data);
 200         seq_puts(m, "0x0      0x1      0x2     0x3     ");
 201         seq_puts(m, "0x4     0x5\n");
 202         mutex_lock(&rtwdev->mutex);
 203         for (i = 0; i <= 5; i++) {
 204                 command = read_cmd | (hw_key_idx + i);
 205                 rtw_write32(rtwdev, RTW_SEC_CMD_REG, command);
 206                 val = rtw_read32(rtwdev, RTW_SEC_READ_REG);
 207                 seq_printf(m, "%8.8x", val);
 208                 if (i < 2)
 209                         seq_puts(m, " ");
 210         }
 211         seq_puts(m, "\n");
 212         mutex_unlock(&rtwdev->mutex);
 213         return 0;
 214 }
 215 
 216 static int rtw_debugfs_get_rsvd_page(struct seq_file *m, void *v)
 217 {
 218         struct rtw_debugfs_priv *debugfs_priv = m->private;
 219         struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 220         u8 page_size = rtwdev->chip->page_size;
 221         u32 buf_size = debugfs_priv->rsvd_page.page_num * page_size;
 222         u32 offset = debugfs_priv->rsvd_page.page_offset * page_size;
 223         u8 *buf;
 224         int i;
 225         int ret;
 226 
 227         buf = vzalloc(buf_size);
 228         if (!buf)
 229                 return -ENOMEM;
 230 
 231         ret = rtw_dump_drv_rsvd_page(rtwdev, offset, buf_size, (u32 *)buf);
 232         if (ret) {
 233                 rtw_err(rtwdev, "failed to dump rsvd page\n");
 234                 vfree(buf);
 235                 return ret;
 236         }
 237 
 238         for (i = 0 ; i < buf_size ; i += 8) {
 239                 if (i % page_size == 0)
 240                         seq_printf(m, "PAGE %d\n", (i + offset) / page_size);
 241                 seq_printf(m, "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n",
 242                            *(buf + i), *(buf + i + 1),
 243                            *(buf + i + 2), *(buf + i + 3),
 244                            *(buf + i + 4), *(buf + i + 5),
 245                            *(buf + i + 6), *(buf + i + 7));
 246         }
 247         vfree(buf);
 248 
 249         return 0;
 250 }
 251 
 252 static ssize_t rtw_debugfs_set_rsvd_page(struct file *filp,
 253                                          const char __user *buffer,
 254                                          size_t count, loff_t *loff)
 255 {
 256         struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
 257         struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 258         struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 259         char tmp[32 + 1];
 260         u32 offset, page_num;
 261         int num;
 262 
 263         rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2);
 264 
 265         num = sscanf(tmp, "%d %d", &offset, &page_num);
 266 
 267         if (num != 2) {
 268                 rtw_warn(rtwdev, "invalid arguments\n");
 269                 return num;
 270         }
 271 
 272         debugfs_priv->rsvd_page.page_offset = offset;
 273         debugfs_priv->rsvd_page.page_num = page_num;
 274 
 275         return count;
 276 }
 277 
 278 static ssize_t rtw_debugfs_set_single_input(struct file *filp,
 279                                             const char __user *buffer,
 280                                             size_t count, loff_t *loff)
 281 {
 282         struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
 283         struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 284         struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 285         char tmp[32 + 1];
 286         u32 input;
 287         int num;
 288 
 289         rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 1);
 290 
 291         num = kstrtoint(tmp, 0, &input);
 292 
 293         if (num) {
 294                 rtw_warn(rtwdev, "kstrtoint failed\n");
 295                 return num;
 296         }
 297 
 298         debugfs_priv->cb_data = input;
 299 
 300         return count;
 301 }
 302 
 303 static ssize_t rtw_debugfs_set_write_reg(struct file *filp,
 304                                          const char __user *buffer,
 305                                          size_t count, loff_t *loff)
 306 {
 307         struct rtw_debugfs_priv *debugfs_priv = filp->private_data;
 308         struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 309         char tmp[32 + 1];
 310         u32 addr, val, len;
 311         int num;
 312 
 313         rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3);
 314 
 315         /* write BB/MAC register */
 316         num = sscanf(tmp, "%x %x %x", &addr, &val, &len);
 317 
 318         if (num !=  3)
 319                 return count;
 320 
 321         switch (len) {
 322         case 1:
 323                 rtw_dbg(rtwdev, RTW_DBG_DEBUGFS,
 324                         "reg write8 0x%03x: 0x%08x\n", addr, val);
 325                 rtw_write8(rtwdev, addr, (u8)val);
 326                 break;
 327         case 2:
 328                 rtw_dbg(rtwdev, RTW_DBG_DEBUGFS,
 329                         "reg write16 0x%03x: 0x%08x\n", addr, val);
 330                 rtw_write16(rtwdev, addr, (u16)val);
 331                 break;
 332         case 4:
 333                 rtw_dbg(rtwdev, RTW_DBG_DEBUGFS,
 334                         "reg write32 0x%03x: 0x%08x\n", addr, val);
 335                 rtw_write32(rtwdev, addr, (u32)val);
 336                 break;
 337         default:
 338                 rtw_dbg(rtwdev, RTW_DBG_DEBUGFS,
 339                         "error write length = %d\n", len);
 340                 break;
 341         }
 342 
 343         return count;
 344 }
 345 
 346 static ssize_t rtw_debugfs_set_rf_write(struct file *filp,
 347                                         const char __user *buffer,
 348                                         size_t count, loff_t *loff)
 349 {
 350         struct rtw_debugfs_priv *debugfs_priv = filp->private_data;
 351         struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 352         char tmp[32 + 1];
 353         u32 path, addr, mask, val;
 354         int num;
 355 
 356         rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 4);
 357 
 358         num = sscanf(tmp, "%x %x %x %x", &path, &addr, &mask, &val);
 359 
 360         if (num !=  4) {
 361                 rtw_warn(rtwdev, "invalid args, [path] [addr] [mask] [val]\n");
 362                 return count;
 363         }
 364 
 365         rtw_write_rf(rtwdev, path, addr, mask, val);
 366         rtw_dbg(rtwdev, RTW_DBG_DEBUGFS,
 367                 "write_rf path:%d addr:0x%08x mask:0x%08x, val:0x%08x\n",
 368                 path, addr, mask, val);
 369 
 370         return count;
 371 }
 372 
 373 static ssize_t rtw_debugfs_set_rf_read(struct file *filp,
 374                                        const char __user *buffer,
 375                                        size_t count, loff_t *loff)
 376 {
 377         struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
 378         struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 379         struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 380         char tmp[32 + 1];
 381         u32 path, addr, mask;
 382         int num;
 383 
 384         rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3);
 385 
 386         num = sscanf(tmp, "%x %x %x", &path, &addr, &mask);
 387 
 388         if (num !=  3) {
 389                 rtw_warn(rtwdev, "invalid args, [path] [addr] [mask] [val]\n");
 390                 return count;
 391         }
 392 
 393         debugfs_priv->rf_path = path;
 394         debugfs_priv->rf_addr = addr;
 395         debugfs_priv->rf_mask = mask;
 396 
 397         return count;
 398 }
 399 
 400 static int rtw_debug_get_mac_page(struct seq_file *m, void *v)
 401 {
 402         struct rtw_debugfs_priv *debugfs_priv = m->private;
 403         struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 404         u32 val;
 405         u32 page = debugfs_priv->cb_data;
 406         int i, n;
 407         int max = 0xff;
 408 
 409         val = rtw_read32(rtwdev, debugfs_priv->cb_data);
 410         for (n = 0; n <= max; ) {
 411                 seq_printf(m, "\n%8.8x  ", n + page);
 412                 for (i = 0; i < 4 && n <= max; i++, n += 4)
 413                         seq_printf(m, "%8.8x    ",
 414                                    rtw_read32(rtwdev, (page | n)));
 415         }
 416         seq_puts(m, "\n");
 417         return 0;
 418 }
 419 
 420 static int rtw_debug_get_bb_page(struct seq_file *m, void *v)
 421 {
 422         struct rtw_debugfs_priv *debugfs_priv = m->private;
 423         struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 424         u32 val;
 425         u32 page = debugfs_priv->cb_data;
 426         int i, n;
 427         int max = 0xff;
 428 
 429         val = rtw_read32(rtwdev, debugfs_priv->cb_data);
 430         for (n = 0; n <= max; ) {
 431                 seq_printf(m, "\n%8.8x  ", n + page);
 432                 for (i = 0; i < 4 && n <= max; i++, n += 4)
 433                         seq_printf(m, "%8.8x    ",
 434                                    rtw_read32(rtwdev, (page | n)));
 435         }
 436         seq_puts(m, "\n");
 437         return 0;
 438 }
 439 
 440 static int rtw_debug_get_rf_dump(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 addr, offset, data;
 445         u8 path;
 446 
 447         for (path = 0; path < rtwdev->hal.rf_path_num; path++) {
 448                 seq_printf(m, "RF path:%d\n", path);
 449                 for (addr = 0; addr < 0x100; addr += 4) {
 450                         seq_printf(m, "%8.8x  ", addr);
 451                         for (offset = 0; offset < 4; offset++) {
 452                                 data = rtw_read_rf(rtwdev, path, addr + offset,
 453                                                    0xffffffff);
 454                                 seq_printf(m, "%8.8x    ", data);
 455                         }
 456                         seq_puts(m, "\n");
 457                 }
 458                 seq_puts(m, "\n");
 459         }
 460 
 461         return 0;
 462 }
 463 
 464 static void rtw_print_cck_rate_txt(struct seq_file *m, u8 rate)
 465 {
 466         static const char * const
 467         cck_rate[] = {"1M", "2M", "5.5M", "11M"};
 468         u8 idx = rate - DESC_RATE1M;
 469 
 470         seq_printf(m, " CCK_%-5s", cck_rate[idx]);
 471 }
 472 
 473 static void rtw_print_ofdm_rate_txt(struct seq_file *m, u8 rate)
 474 {
 475         static const char * const
 476         ofdm_rate[] = {"6M", "9M", "12M", "18M", "24M", "36M", "48M", "54M"};
 477         u8 idx = rate - DESC_RATE6M;
 478 
 479         seq_printf(m, " OFDM_%-4s", ofdm_rate[idx]);
 480 }
 481 
 482 static void rtw_print_ht_rate_txt(struct seq_file *m, u8 rate)
 483 {
 484         u8 mcs_n = rate - DESC_RATEMCS0;
 485 
 486         seq_printf(m, " MCS%-6u", mcs_n);
 487 }
 488 
 489 static void rtw_print_vht_rate_txt(struct seq_file *m, u8 rate)
 490 {
 491         u8 idx = rate - DESC_RATEVHT1SS_MCS0;
 492         u8 n_ss, mcs_n;
 493 
 494         /* n spatial stream */
 495         n_ss = 1 + idx / 10;
 496         /* MCS n */
 497         mcs_n = idx % 10;
 498         seq_printf(m, " VHT%uSMCS%u", n_ss, mcs_n);
 499 }
 500 
 501 static int rtw_debugfs_get_tx_pwr_tbl(struct seq_file *m, void *v)
 502 {
 503         struct rtw_debugfs_priv *debugfs_priv = m->private;
 504         struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 505         struct rtw_hal *hal = &rtwdev->hal;
 506         void (*print_rate)(struct seq_file *, u8) = NULL;
 507         u8 path, rate;
 508         struct rtw_power_params pwr_param = {0};
 509         u8 bw = hal->current_band_width;
 510         u8 ch = hal->current_channel;
 511         u8 regd = rtwdev->regd.txpwr_regd;
 512 
 513         seq_printf(m, "%-4s %-10s %-3s%6s %-4s %4s (%-4s %-4s)\n",
 514                    "path", "rate", "pwr", "", "base", "", "byr", "lmt");
 515 
 516         mutex_lock(&hal->tx_power_mutex);
 517         for (path = RF_PATH_A; path <= RF_PATH_B; path++) {
 518                 /* there is no CCK rates used in 5G */
 519                 if (hal->current_band_type == RTW_BAND_5G)
 520                         rate = DESC_RATE6M;
 521                 else
 522                         rate = DESC_RATE1M;
 523 
 524                 /* now, not support vht 3ss and vht 4ss*/
 525                 for (; rate <= DESC_RATEVHT2SS_MCS9; rate++) {
 526                         /* now, not support ht 3ss and ht 4ss*/
 527                         if (rate > DESC_RATEMCS15 &&
 528                             rate < DESC_RATEVHT1SS_MCS0)
 529                                 continue;
 530 
 531                         switch (rate) {
 532                         case DESC_RATE1M...DESC_RATE11M:
 533                                 print_rate = rtw_print_cck_rate_txt;
 534                                 break;
 535                         case DESC_RATE6M...DESC_RATE54M:
 536                                 print_rate = rtw_print_ofdm_rate_txt;
 537                                 break;
 538                         case DESC_RATEMCS0...DESC_RATEMCS15:
 539                                 print_rate = rtw_print_ht_rate_txt;
 540                                 break;
 541                         case DESC_RATEVHT1SS_MCS0...DESC_RATEVHT2SS_MCS9:
 542                                 print_rate = rtw_print_vht_rate_txt;
 543                                 break;
 544                         default:
 545                                 print_rate = NULL;
 546                                 break;
 547                         }
 548 
 549                         rtw_get_tx_power_params(rtwdev, path, rate, bw,
 550                                                 ch, regd, &pwr_param);
 551 
 552                         seq_printf(m, "%4c ", path + 'A');
 553                         if (print_rate)
 554                                 print_rate(m, rate);
 555                         seq_printf(m, " %3u(0x%02x) %4u %4d (%4d %4d)\n",
 556                                    hal->tx_pwr_tbl[path][rate],
 557                                    hal->tx_pwr_tbl[path][rate],
 558                                    pwr_param.pwr_base,
 559                                    min_t(s8, pwr_param.pwr_offset,
 560                                          pwr_param.pwr_limit),
 561                                    pwr_param.pwr_offset, pwr_param.pwr_limit);
 562                 }
 563         }
 564 
 565         mutex_unlock(&hal->tx_power_mutex);
 566 
 567         return 0;
 568 }
 569 
 570 #define rtw_debug_impl_mac(page, addr)                          \
 571 static struct rtw_debugfs_priv rtw_debug_priv_mac_ ##page = {   \
 572         .cb_read = rtw_debug_get_mac_page,                      \
 573         .cb_data = addr,                                        \
 574 }
 575 
 576 rtw_debug_impl_mac(0, 0x0000);
 577 rtw_debug_impl_mac(1, 0x0100);
 578 rtw_debug_impl_mac(2, 0x0200);
 579 rtw_debug_impl_mac(3, 0x0300);
 580 rtw_debug_impl_mac(4, 0x0400);
 581 rtw_debug_impl_mac(5, 0x0500);
 582 rtw_debug_impl_mac(6, 0x0600);
 583 rtw_debug_impl_mac(7, 0x0700);
 584 rtw_debug_impl_mac(10, 0x1000);
 585 rtw_debug_impl_mac(11, 0x1100);
 586 rtw_debug_impl_mac(12, 0x1200);
 587 rtw_debug_impl_mac(13, 0x1300);
 588 rtw_debug_impl_mac(14, 0x1400);
 589 rtw_debug_impl_mac(15, 0x1500);
 590 rtw_debug_impl_mac(16, 0x1600);
 591 rtw_debug_impl_mac(17, 0x1700);
 592 
 593 #define rtw_debug_impl_bb(page, addr)                   \
 594 static struct rtw_debugfs_priv rtw_debug_priv_bb_ ##page = {    \
 595         .cb_read = rtw_debug_get_bb_page,                       \
 596         .cb_data = addr,                                        \
 597 }
 598 
 599 rtw_debug_impl_bb(8, 0x0800);
 600 rtw_debug_impl_bb(9, 0x0900);
 601 rtw_debug_impl_bb(a, 0x0a00);
 602 rtw_debug_impl_bb(b, 0x0b00);
 603 rtw_debug_impl_bb(c, 0x0c00);
 604 rtw_debug_impl_bb(d, 0x0d00);
 605 rtw_debug_impl_bb(e, 0x0e00);
 606 rtw_debug_impl_bb(f, 0x0f00);
 607 rtw_debug_impl_bb(18, 0x1800);
 608 rtw_debug_impl_bb(19, 0x1900);
 609 rtw_debug_impl_bb(1a, 0x1a00);
 610 rtw_debug_impl_bb(1b, 0x1b00);
 611 rtw_debug_impl_bb(1c, 0x1c00);
 612 rtw_debug_impl_bb(1d, 0x1d00);
 613 rtw_debug_impl_bb(1e, 0x1e00);
 614 rtw_debug_impl_bb(1f, 0x1f00);
 615 rtw_debug_impl_bb(2c, 0x2c00);
 616 rtw_debug_impl_bb(2d, 0x2d00);
 617 rtw_debug_impl_bb(40, 0x4000);
 618 rtw_debug_impl_bb(41, 0x4100);
 619 
 620 static struct rtw_debugfs_priv rtw_debug_priv_rf_dump = {
 621         .cb_read = rtw_debug_get_rf_dump,
 622 };
 623 
 624 static struct rtw_debugfs_priv rtw_debug_priv_tx_pwr_tbl = {
 625         .cb_read = rtw_debugfs_get_tx_pwr_tbl,
 626 };
 627 
 628 static struct rtw_debugfs_priv rtw_debug_priv_write_reg = {
 629         .cb_write = rtw_debugfs_set_write_reg,
 630 };
 631 
 632 static struct rtw_debugfs_priv rtw_debug_priv_rf_write = {
 633         .cb_write = rtw_debugfs_set_rf_write,
 634 };
 635 
 636 static struct rtw_debugfs_priv rtw_debug_priv_rf_read = {
 637         .cb_write = rtw_debugfs_set_rf_read,
 638         .cb_read = rtw_debugfs_get_rf_read,
 639 };
 640 
 641 static struct rtw_debugfs_priv rtw_debug_priv_read_reg = {
 642         .cb_write = rtw_debugfs_set_read_reg,
 643         .cb_read = rtw_debugfs_get_read_reg,
 644 };
 645 
 646 static struct rtw_debugfs_priv rtw_debug_priv_dump_cam = {
 647         .cb_write = rtw_debugfs_set_single_input,
 648         .cb_read = rtw_debugfs_get_dump_cam,
 649 };
 650 
 651 static struct rtw_debugfs_priv rtw_debug_priv_rsvd_page = {
 652         .cb_write = rtw_debugfs_set_rsvd_page,
 653         .cb_read = rtw_debugfs_get_rsvd_page,
 654 };
 655 
 656 #define rtw_debugfs_add_core(name, mode, fopname, parent)               \
 657         do {                                                            \
 658                 rtw_debug_priv_ ##name.rtwdev = rtwdev;                 \
 659                 if (!debugfs_create_file(#name, mode,                   \
 660                                          parent, &rtw_debug_priv_ ##name,\
 661                                          &file_ops_ ##fopname))         \
 662                         pr_debug("Unable to initialize debugfs:%s\n",   \
 663                                #name);                                  \
 664         } while (0)
 665 
 666 #define rtw_debugfs_add_w(name)                                         \
 667         rtw_debugfs_add_core(name, S_IFREG | 0222, common_write, debugfs_topdir)
 668 #define rtw_debugfs_add_rw(name)                                        \
 669         rtw_debugfs_add_core(name, S_IFREG | 0666, single_rw, debugfs_topdir)
 670 #define rtw_debugfs_add_r(name)                                         \
 671         rtw_debugfs_add_core(name, S_IFREG | 0444, single_r, debugfs_topdir)
 672 
 673 void rtw_debugfs_init(struct rtw_dev *rtwdev)
 674 {
 675         struct dentry *debugfs_topdir;
 676 
 677         debugfs_topdir = debugfs_create_dir("rtw88",
 678                                             rtwdev->hw->wiphy->debugfsdir);
 679         rtw_debugfs_add_w(write_reg);
 680         rtw_debugfs_add_rw(read_reg);
 681         rtw_debugfs_add_w(rf_write);
 682         rtw_debugfs_add_rw(rf_read);
 683         rtw_debugfs_add_rw(dump_cam);
 684         rtw_debugfs_add_rw(rsvd_page);
 685         rtw_debugfs_add_r(mac_0);
 686         rtw_debugfs_add_r(mac_1);
 687         rtw_debugfs_add_r(mac_2);
 688         rtw_debugfs_add_r(mac_3);
 689         rtw_debugfs_add_r(mac_4);
 690         rtw_debugfs_add_r(mac_5);
 691         rtw_debugfs_add_r(mac_6);
 692         rtw_debugfs_add_r(mac_7);
 693         rtw_debugfs_add_r(bb_8);
 694         rtw_debugfs_add_r(bb_9);
 695         rtw_debugfs_add_r(bb_a);
 696         rtw_debugfs_add_r(bb_b);
 697         rtw_debugfs_add_r(bb_c);
 698         rtw_debugfs_add_r(bb_d);
 699         rtw_debugfs_add_r(bb_e);
 700         rtw_debugfs_add_r(bb_f);
 701         rtw_debugfs_add_r(mac_10);
 702         rtw_debugfs_add_r(mac_11);
 703         rtw_debugfs_add_r(mac_12);
 704         rtw_debugfs_add_r(mac_13);
 705         rtw_debugfs_add_r(mac_14);
 706         rtw_debugfs_add_r(mac_15);
 707         rtw_debugfs_add_r(mac_16);
 708         rtw_debugfs_add_r(mac_17);
 709         rtw_debugfs_add_r(bb_18);
 710         rtw_debugfs_add_r(bb_19);
 711         rtw_debugfs_add_r(bb_1a);
 712         rtw_debugfs_add_r(bb_1b);
 713         rtw_debugfs_add_r(bb_1c);
 714         rtw_debugfs_add_r(bb_1d);
 715         rtw_debugfs_add_r(bb_1e);
 716         rtw_debugfs_add_r(bb_1f);
 717         if (rtwdev->chip->id == RTW_CHIP_TYPE_8822C) {
 718                 rtw_debugfs_add_r(bb_2c);
 719                 rtw_debugfs_add_r(bb_2d);
 720                 rtw_debugfs_add_r(bb_40);
 721                 rtw_debugfs_add_r(bb_41);
 722         }
 723         rtw_debugfs_add_r(rf_dump);
 724         rtw_debugfs_add_r(tx_pwr_tbl);
 725 }
 726 
 727 #endif /* CONFIG_RTW88_DEBUGFS */
 728 
 729 #ifdef CONFIG_RTW88_DEBUG
 730 
 731 void __rtw_dbg(struct rtw_dev *rtwdev, enum rtw_debug_mask mask,
 732                const char *fmt, ...)
 733 {
 734         struct va_format vaf = {
 735                 .fmt = fmt,
 736         };
 737         va_list args;
 738 
 739         va_start(args, fmt);
 740         vaf.va = &args;
 741 
 742         if (rtw_debug_mask & mask)
 743                 dev_printk(KERN_DEBUG, rtwdev->dev, "%pV", &vaf);
 744 
 745         va_end(args);
 746 }
 747 EXPORT_SYMBOL(__rtw_dbg);
 748 
 749 #endif /* CONFIG_RTW88_DEBUG */

/* [<][>][^][v][top][bottom][index][help] */