cxio_dbg.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 "common.h"
  35. #include "cxgb3_ioctl.h"
  36. #include "cxio_hal.h"
  37. #include "cxio_wr.h"
  38. void cxio_dump_tpt(struct cxio_rdev *rdev, u32 stag)
  39. {
  40. struct ch_mem_range *m;
  41. u64 *data;
  42. int rc;
  43. int size = 32;
  44. m = kmalloc(sizeof(*m) + size, GFP_ATOMIC);
  45. if (!m) {
  46. PDBG("%s couldn't allocate memory.\n", __func__);
  47. return;
  48. }
  49. m->mem_id = MEM_PMRX;
  50. m->addr = (stag>>8) * 32 + rdev->rnic_info.tpt_base;
  51. m->len = size;
  52. PDBG("%s TPT addr 0x%x len %d\n", __func__, m->addr, m->len);
  53. rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
  54. if (rc) {
  55. PDBG("%s toectl returned error %d\n", __func__, rc);
  56. kfree(m);
  57. return;
  58. }
  59. data = (u64 *)m->buf;
  60. while (size > 0) {
  61. PDBG("TPT %08x: %016llx\n", m->addr, (unsigned long long) *data);
  62. size -= 8;
  63. data++;
  64. m->addr += 8;
  65. }
  66. kfree(m);
  67. }
  68. void cxio_dump_pbl(struct cxio_rdev *rdev, u32 pbl_addr, uint len, u8 shift)
  69. {
  70. struct ch_mem_range *m;
  71. u64 *data;
  72. int rc;
  73. int size, npages;
  74. shift += 12;
  75. npages = (len + (1ULL << shift) - 1) >> shift;
  76. size = npages * sizeof(u64);
  77. m = kmalloc(sizeof(*m) + size, GFP_ATOMIC);
  78. if (!m) {
  79. PDBG("%s couldn't allocate memory.\n", __func__);
  80. return;
  81. }
  82. m->mem_id = MEM_PMRX;
  83. m->addr = pbl_addr;
  84. m->len = size;
  85. PDBG("%s PBL addr 0x%x len %d depth %d\n",
  86. __func__, m->addr, m->len, npages);
  87. rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
  88. if (rc) {
  89. PDBG("%s toectl returned error %d\n", __func__, rc);
  90. kfree(m);
  91. return;
  92. }
  93. data = (u64 *)m->buf;
  94. while (size > 0) {
  95. PDBG("PBL %08x: %016llx\n", m->addr, (unsigned long long) *data);
  96. size -= 8;
  97. data++;
  98. m->addr += 8;
  99. }
  100. kfree(m);
  101. }
  102. void cxio_dump_wqe(union t3_wr *wqe)
  103. {
  104. __be64 *data = (__be64 *)wqe;
  105. uint size = (uint)(be64_to_cpu(*data) & 0xff);
  106. if (size == 0)
  107. size = 8;
  108. while (size > 0) {
  109. PDBG("WQE %p: %016llx\n", data,
  110. (unsigned long long) be64_to_cpu(*data));
  111. size--;
  112. data++;
  113. }
  114. }
  115. void cxio_dump_wce(struct t3_cqe *wce)
  116. {
  117. __be64 *data = (__be64 *)wce;
  118. int size = sizeof(*wce);
  119. while (size > 0) {
  120. PDBG("WCE %p: %016llx\n", data,
  121. (unsigned long long) be64_to_cpu(*data));
  122. size -= 8;
  123. data++;
  124. }
  125. }
  126. void cxio_dump_rqt(struct cxio_rdev *rdev, u32 hwtid, int nents)
  127. {
  128. struct ch_mem_range *m;
  129. int size = nents * 64;
  130. u64 *data;
  131. int rc;
  132. m = kmalloc(sizeof(*m) + size, GFP_ATOMIC);
  133. if (!m) {
  134. PDBG("%s couldn't allocate memory.\n", __func__);
  135. return;
  136. }
  137. m->mem_id = MEM_PMRX;
  138. m->addr = ((hwtid)<<10) + rdev->rnic_info.rqt_base;
  139. m->len = size;
  140. PDBG("%s RQT addr 0x%x len %d\n", __func__, m->addr, m->len);
  141. rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
  142. if (rc) {
  143. PDBG("%s toectl returned error %d\n", __func__, rc);
  144. kfree(m);
  145. return;
  146. }
  147. data = (u64 *)m->buf;
  148. while (size > 0) {
  149. PDBG("RQT %08x: %016llx\n", m->addr, (unsigned long long) *data);
  150. size -= 8;
  151. data++;
  152. m->addr += 8;
  153. }
  154. kfree(m);
  155. }
  156. void cxio_dump_tcb(struct cxio_rdev *rdev, u32 hwtid)
  157. {
  158. struct ch_mem_range *m;
  159. int size = TCB_SIZE;
  160. u32 *data;
  161. int rc;
  162. m = kmalloc(sizeof(*m) + size, GFP_ATOMIC);
  163. if (!m) {
  164. PDBG("%s couldn't allocate memory.\n", __func__);
  165. return;
  166. }
  167. m->mem_id = MEM_CM;
  168. m->addr = hwtid * size;
  169. m->len = size;
  170. PDBG("%s TCB %d len %d\n", __func__, m->addr, m->len);
  171. rc = rdev->t3cdev_p->ctl(rdev->t3cdev_p, RDMA_GET_MEM, m);
  172. if (rc) {
  173. PDBG("%s toectl returned error %d\n", __func__, rc);
  174. kfree(m);
  175. return;
  176. }
  177. data = (u32 *)m->buf;
  178. while (size > 0) {
  179. printk("%2u: %08x %08x %08x %08x %08x %08x %08x %08x\n",
  180. m->addr,
  181. *(data+2), *(data+3), *(data),*(data+1),
  182. *(data+6), *(data+7), *(data+4), *(data+5));
  183. size -= 32;
  184. data += 8;
  185. m->addr += 32;
  186. }
  187. kfree(m);
  188. }
  189. #endif