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