debug.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. * Wireless Host Controller (WHC) debug.
  3. *
  4. * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License version
  8. * 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/debugfs.h>
  20. #include <linux/seq_file.h>
  21. #include "../../wusbcore/wusbhc.h"
  22. #include "whcd.h"
  23. struct whc_dbg {
  24. struct dentry *di_f;
  25. struct dentry *asl_f;
  26. struct dentry *pzl_f;
  27. };
  28. void qset_print(struct seq_file *s, struct whc_qset *qset)
  29. {
  30. struct whc_std *std;
  31. struct urb *urb = NULL;
  32. int i;
  33. seq_printf(s, "qset %08x\n", (u32)qset->qset_dma);
  34. seq_printf(s, " -> %08x\n", (u32)qset->qh.link);
  35. seq_printf(s, " info: %08x %08x %08x\n",
  36. qset->qh.info1, qset->qh.info2, qset->qh.info3);
  37. seq_printf(s, " sts: %04x errs: %d\n", qset->qh.status, qset->qh.err_count);
  38. seq_printf(s, " TD: sts: %08x opts: %08x\n",
  39. qset->qh.overlay.qtd.status, qset->qh.overlay.qtd.options);
  40. for (i = 0; i < WHCI_QSET_TD_MAX; i++) {
  41. seq_printf(s, " %c%c TD[%d]: sts: %08x opts: %08x ptr: %08x\n",
  42. i == qset->td_start ? 'S' : ' ',
  43. i == qset->td_end ? 'E' : ' ',
  44. i, qset->qtd[i].status, qset->qtd[i].options,
  45. (u32)qset->qtd[i].page_list_ptr);
  46. }
  47. seq_printf(s, " ntds: %d\n", qset->ntds);
  48. list_for_each_entry(std, &qset->stds, list_node) {
  49. if (urb != std->urb) {
  50. urb = std->urb;
  51. seq_printf(s, " urb %p transferred: %d bytes\n", urb,
  52. urb->actual_length);
  53. }
  54. if (std->qtd)
  55. seq_printf(s, " sTD[%td]: %zu bytes @ %08x\n",
  56. std->qtd - &qset->qtd[0],
  57. std->len, std->num_pointers ?
  58. (u32)(std->pl_virt[0].buf_ptr) : (u32)std->dma_addr);
  59. else
  60. seq_printf(s, " sTD[-]: %zd bytes @ %08x\n",
  61. std->len, std->num_pointers ?
  62. (u32)(std->pl_virt[0].buf_ptr) : (u32)std->dma_addr);
  63. }
  64. }
  65. static int di_print(struct seq_file *s, void *p)
  66. {
  67. struct whc *whc = s->private;
  68. char buf[72];
  69. int d;
  70. for (d = 0; d < whc->n_devices; d++) {
  71. struct di_buf_entry *di = &whc->di_buf[d];
  72. bitmap_scnprintf(buf, sizeof(buf),
  73. (unsigned long *)di->availability_info, UWB_NUM_MAS);
  74. seq_printf(s, "DI[%d]\n", d);
  75. seq_printf(s, " availability: %s\n", buf);
  76. seq_printf(s, " %c%c key idx: %d dev addr: %d\n",
  77. (di->addr_sec_info & WHC_DI_SECURE) ? 'S' : ' ',
  78. (di->addr_sec_info & WHC_DI_DISABLE) ? 'D' : ' ',
  79. (di->addr_sec_info & WHC_DI_KEY_IDX_MASK) >> 8,
  80. (di->addr_sec_info & WHC_DI_DEV_ADDR_MASK));
  81. }
  82. return 0;
  83. }
  84. static int asl_print(struct seq_file *s, void *p)
  85. {
  86. struct whc *whc = s->private;
  87. struct whc_qset *qset;
  88. list_for_each_entry(qset, &whc->async_list, list_node) {
  89. qset_print(s, qset);
  90. }
  91. return 0;
  92. }
  93. static int pzl_print(struct seq_file *s, void *p)
  94. {
  95. struct whc *whc = s->private;
  96. struct whc_qset *qset;
  97. int period;
  98. for (period = 0; period < 5; period++) {
  99. seq_printf(s, "Period %d\n", period);
  100. list_for_each_entry(qset, &whc->periodic_list[period], list_node) {
  101. qset_print(s, qset);
  102. }
  103. }
  104. return 0;
  105. }
  106. static int di_open(struct inode *inode, struct file *file)
  107. {
  108. return single_open(file, di_print, inode->i_private);
  109. }
  110. static int asl_open(struct inode *inode, struct file *file)
  111. {
  112. return single_open(file, asl_print, inode->i_private);
  113. }
  114. static int pzl_open(struct inode *inode, struct file *file)
  115. {
  116. return single_open(file, pzl_print, inode->i_private);
  117. }
  118. static struct file_operations di_fops = {
  119. .open = di_open,
  120. .read = seq_read,
  121. .llseek = seq_lseek,
  122. .release = single_release,
  123. .owner = THIS_MODULE,
  124. };
  125. static struct file_operations asl_fops = {
  126. .open = asl_open,
  127. .read = seq_read,
  128. .llseek = seq_lseek,
  129. .release = single_release,
  130. .owner = THIS_MODULE,
  131. };
  132. static struct file_operations pzl_fops = {
  133. .open = pzl_open,
  134. .read = seq_read,
  135. .llseek = seq_lseek,
  136. .release = single_release,
  137. .owner = THIS_MODULE,
  138. };
  139. void whc_dbg_init(struct whc *whc)
  140. {
  141. if (whc->wusbhc.pal.debugfs_dir == NULL)
  142. return;
  143. whc->dbg = kzalloc(sizeof(struct whc_dbg), GFP_KERNEL);
  144. if (whc->dbg == NULL)
  145. return;
  146. whc->dbg->di_f = debugfs_create_file("di", 0444,
  147. whc->wusbhc.pal.debugfs_dir, whc,
  148. &di_fops);
  149. whc->dbg->asl_f = debugfs_create_file("asl", 0444,
  150. whc->wusbhc.pal.debugfs_dir, whc,
  151. &asl_fops);
  152. whc->dbg->pzl_f = debugfs_create_file("pzl", 0444,
  153. whc->wusbhc.pal.debugfs_dir, whc,
  154. &pzl_fops);
  155. }
  156. void whc_dbg_clean_up(struct whc *whc)
  157. {
  158. if (whc->dbg) {
  159. debugfs_remove(whc->dbg->pzl_f);
  160. debugfs_remove(whc->dbg->asl_f);
  161. debugfs_remove(whc->dbg->di_f);
  162. kfree(whc->dbg);
  163. }
  164. }