cxio_dbg.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  2. * Copyright (c) 2006 Chelsio, Inc. All rights reserved.
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and/or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. */
  32. #ifdef DEBUG
  33. #include <linux/types.h>
  34. #include <linux/slab.h>
  35. #include "common.h"
  36. #include "cxgb3_ioctl.h"
  37. #include "cxio_hal.h"
  38. #include "cxio_wr.h"
  39. void cxio_dump_tpt(struct cxio_rdev *rdev, u32 stag)
  40. {
  41. struct ch_mem_range *m;
  42. u64 *data;
  43. int rc;
  44. int size = 32;
  45. m = kmalloc(sizeof(*m) + size, GFP_ATOMIC);
  46. if (!m) {
  47. PDBG("%s couldn't allocate memory.\n", __func__);
  48. return;
  49. }
  50. m->mem_id = MEM_PMRX;
  51. m->addr = (stag>>8) * 32 + rdev->rnic_info.tpt_base;
  52. m->len = size;
  53. PDBG("%s TPT addr 0x%x len %d\n", __func__, m->addr, m->len);
  54. rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
  55. if (rc) {
  56. PDBG("%s toectl returned error %d\n", __func__, rc);
  57. kfree(m);
  58. return;
  59. }
  60. data = (u64 *)m->buf;
  61. while (size > 0) {
  62. PDBG("TPT %08x: %016llx\n", m->addr, (unsigned long long) *data);
  63. size -= 8;
  64. data++;
  65. m->addr += 8;
  66. }
  67. kfree(m);
  68. }
  69. void cxio_dump_pbl(struct cxio_rdev *rdev, u32 pbl_addr, uint len, u8 shift)
  70. {
  71. struct ch_mem_range *m;
  72. u64 *data;
  73. int rc;
  74. int size, npages;
  75. shift += 12;
  76. npages = (len + (1ULL << shift) - 1) >> shift;
  77. size = npages * sizeof(u64);
  78. m = kmalloc(sizeof(*m) + size, GFP_ATOMIC);
  79. if (!m) {
  80. PDBG("%s couldn't allocate memory.\n", __func__);
  81. return;
  82. }
  83. m->mem_id = MEM_PMRX;
  84. m->addr = pbl_addr;
  85. m->len = size;
  86. PDBG("%s PBL addr 0x%x len %d depth %d\n",
  87. __func__, m->addr, m->len, npages);
  88. rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
  89. if (rc) {
  90. PDBG("%s toectl returned error %d\n", __func__, rc);
  91. kfree(m);
  92. return;
  93. }
  94. data = (u64 *)m->buf;
  95. while (size > 0) {
  96. PDBG("PBL %08x: %016llx\n", m->addr, (unsigned long long) *data);
  97. size -= 8;
  98. data++;
  99. m->addr += 8;
  100. }
  101. kfree(m);
  102. }
  103. void cxio_dump_wqe(union t3_wr *wqe)
  104. {
  105. __be64 *data = (__be64 *)wqe;
  106. uint size = (uint)(be64_to_cpu(*data) & 0xff);
  107. if (size == 0)
  108. size = 8;
  109. while (size > 0) {
  110. PDBG("WQE %p: %016llx\n", data,
  111. (unsigned long long) be64_to_cpu(*data));
  112. size--;
  113. data++;
  114. }
  115. }
  116. void cxio_dump_wce(struct t3_cqe *wce)
  117. {
  118. __be64 *data = (__be64 *)wce;
  119. int size = sizeof(*wce);
  120. while (size > 0) {
  121. PDBG("WCE %p: %016llx\n", data,
  122. (unsigned long long) be64_to_cpu(*data));
  123. size -= 8;
  124. data++;
  125. }
  126. }
  127. void cxio_dump_rqt(struct cxio_rdev *rdev, u32 hwtid, int nents)
  128. {
  129. struct ch_mem_range *m;
  130. int size = nents * 64;
  131. u64 *data;
  132. int rc;
  133. m = kmalloc(sizeof(*m) + size, GFP_ATOMIC);
  134. if (!m) {
  135. PDBG("%s couldn't allocate memory.\n", __func__);
  136. return;
  137. }
  138. m->mem_id = MEM_PMRX;
  139. m->addr = ((hwtid)<<10) + rdev->rnic_info.rqt_base;
  140. m->len = size;
  141. PDBG("%s RQT addr 0x%x len %d\n", __func__, m->addr, m->len);
  142. rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
  143. if (rc) {
  144. PDBG("%s toectl returned error %d\n", __func__, rc);
  145. kfree(m);
  146. return;
  147. }
  148. data = (u64 *)m->buf;
  149. while (size > 0) {
  150. PDBG("RQT %08x: %016llx\n", m->addr, (unsigned long long) *data);
  151. size -= 8;
  152. data++;
  153. m->addr += 8;
  154. }
  155. kfree(m);
  156. }
  157. void cxio_dump_tcb(struct cxio_rdev *rdev, u32 hwtid)
  158. {
  159. struct ch_mem_range *m;
  160. int size = TCB_SIZE;
  161. u32 *data;
  162. int rc;
  163. m = kmalloc(sizeof(*m) + size, GFP_ATOMIC);
  164. if (!m) {
  165. PDBG("%s couldn't allocate memory.\n", __func__);
  166. return;
  167. }
  168. m->mem_id = MEM_CM;
  169. m->addr = hwtid * size;
  170. m->len = size;
  171. PDBG("%s TCB %d len %d\n", __func__, m->addr, m->len);
  172. rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
  173. if (rc) {
  174. PDBG("%s toectl returned error %d\n", __func__, rc);
  175. kfree(m);
  176. return;
  177. }
  178. data = (u32 *)m->buf;
  179. while (size > 0) {
  180. printk("%2u: %08x %08x %08x %08x %08x %08x %08x %08x\n",
  181. m->addr,
  182. *(data+2), *(data+3), *(data),*(data+1),
  183. *(data+6), *(data+7), *(data+4), *(data+5));
  184. size -= 32;
  185. data += 8;
  186. m->addr += 32;
  187. }
  188. kfree(m);
  189. }
  190. #endif