cxio_dbg.c 4.8 KB

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