mthca_srq.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. /*
  2. * Copyright (c) 2005 Cisco Systems. 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. * $Id: mthca_srq.c 3047 2005-08-10 03:59:35Z roland $
  33. */
  34. #include "mthca_dev.h"
  35. #include "mthca_cmd.h"
  36. #include "mthca_memfree.h"
  37. #include "mthca_wqe.h"
  38. enum {
  39. MTHCA_MAX_DIRECT_SRQ_SIZE = 4 * PAGE_SIZE
  40. };
  41. struct mthca_tavor_srq_context {
  42. __be64 wqe_base_ds; /* low 6 bits is descriptor size */
  43. __be32 state_pd;
  44. __be32 lkey;
  45. __be32 uar;
  46. __be32 wqe_cnt;
  47. u32 reserved[2];
  48. };
  49. struct mthca_arbel_srq_context {
  50. __be32 state_logsize_srqn;
  51. __be32 lkey;
  52. __be32 db_index;
  53. __be32 logstride_usrpage;
  54. __be64 wqe_base;
  55. __be32 eq_pd;
  56. __be16 limit_watermark;
  57. __be16 wqe_cnt;
  58. u16 reserved1;
  59. __be16 wqe_counter;
  60. u32 reserved2[3];
  61. };
  62. static void *get_wqe(struct mthca_srq *srq, int n)
  63. {
  64. if (srq->is_direct)
  65. return srq->queue.direct.buf + (n << srq->wqe_shift);
  66. else
  67. return srq->queue.page_list[(n << srq->wqe_shift) >> PAGE_SHIFT].buf +
  68. ((n << srq->wqe_shift) & (PAGE_SIZE - 1));
  69. }
  70. /*
  71. * Return a pointer to the location within a WQE that we're using as a
  72. * link when the WQE is in the free list. We use an offset of 4
  73. * because in the Tavor case, posting a WQE may overwrite the first
  74. * four bytes of the previous WQE. The offset avoids corrupting our
  75. * free list if the WQE has already completed and been put on the free
  76. * list when we post the next WQE.
  77. */
  78. static inline int *wqe_to_link(void *wqe)
  79. {
  80. return (int *) (wqe + 4);
  81. }
  82. static void mthca_tavor_init_srq_context(struct mthca_dev *dev,
  83. struct mthca_pd *pd,
  84. struct mthca_srq *srq,
  85. struct mthca_tavor_srq_context *context)
  86. {
  87. memset(context, 0, sizeof *context);
  88. context->wqe_base_ds = cpu_to_be64(1 << (srq->wqe_shift - 4));
  89. context->state_pd = cpu_to_be32(pd->pd_num);
  90. context->lkey = cpu_to_be32(srq->mr.ibmr.lkey);
  91. if (pd->ibpd.uobject)
  92. context->uar =
  93. cpu_to_be32(to_mucontext(pd->ibpd.uobject->context)->uar.index);
  94. else
  95. context->uar = cpu_to_be32(dev->driver_uar.index);
  96. }
  97. static void mthca_arbel_init_srq_context(struct mthca_dev *dev,
  98. struct mthca_pd *pd,
  99. struct mthca_srq *srq,
  100. struct mthca_arbel_srq_context *context)
  101. {
  102. int logsize;
  103. memset(context, 0, sizeof *context);
  104. logsize = long_log2(srq->max) + srq->wqe_shift;
  105. context->state_logsize_srqn = cpu_to_be32(logsize << 24 | srq->srqn);
  106. context->lkey = cpu_to_be32(srq->mr.ibmr.lkey);
  107. context->db_index = cpu_to_be32(srq->db_index);
  108. context->logstride_usrpage = cpu_to_be32((srq->wqe_shift - 4) << 29);
  109. if (pd->ibpd.uobject)
  110. context->logstride_usrpage |=
  111. cpu_to_be32(to_mucontext(pd->ibpd.uobject->context)->uar.index);
  112. else
  113. context->logstride_usrpage |= cpu_to_be32(dev->driver_uar.index);
  114. context->eq_pd = cpu_to_be32(MTHCA_EQ_ASYNC << 24 | pd->pd_num);
  115. }
  116. static void mthca_free_srq_buf(struct mthca_dev *dev, struct mthca_srq *srq)
  117. {
  118. mthca_buf_free(dev, srq->max << srq->wqe_shift, &srq->queue,
  119. srq->is_direct, &srq->mr);
  120. kfree(srq->wrid);
  121. }
  122. static int mthca_alloc_srq_buf(struct mthca_dev *dev, struct mthca_pd *pd,
  123. struct mthca_srq *srq)
  124. {
  125. struct mthca_data_seg *scatter;
  126. void *wqe;
  127. int err;
  128. int i;
  129. if (pd->ibpd.uobject)
  130. return 0;
  131. srq->wrid = kmalloc(srq->max * sizeof (u64), GFP_KERNEL);
  132. if (!srq->wrid)
  133. return -ENOMEM;
  134. err = mthca_buf_alloc(dev, srq->max << srq->wqe_shift,
  135. MTHCA_MAX_DIRECT_SRQ_SIZE,
  136. &srq->queue, &srq->is_direct, pd, 1, &srq->mr);
  137. if (err) {
  138. kfree(srq->wrid);
  139. return err;
  140. }
  141. /*
  142. * Now initialize the SRQ buffer so that all of the WQEs are
  143. * linked into the list of free WQEs. In addition, set the
  144. * scatter list L_Keys to the sentry value of 0x100.
  145. */
  146. for (i = 0; i < srq->max; ++i) {
  147. wqe = get_wqe(srq, i);
  148. *wqe_to_link(wqe) = i < srq->max - 1 ? i + 1 : -1;
  149. for (scatter = wqe + sizeof (struct mthca_next_seg);
  150. (void *) scatter < wqe + (1 << srq->wqe_shift);
  151. ++scatter)
  152. scatter->lkey = cpu_to_be32(MTHCA_INVAL_LKEY);
  153. }
  154. srq->last = get_wqe(srq, srq->max - 1);
  155. return 0;
  156. }
  157. int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
  158. struct ib_srq_attr *attr, struct mthca_srq *srq)
  159. {
  160. struct mthca_mailbox *mailbox;
  161. u8 status;
  162. int ds;
  163. int err;
  164. /* Sanity check SRQ size before proceeding */
  165. if (attr->max_wr > dev->limits.max_srq_wqes ||
  166. attr->max_sge > dev->limits.max_sg)
  167. return -EINVAL;
  168. srq->max = attr->max_wr;
  169. srq->max_gs = attr->max_sge;
  170. srq->counter = 0;
  171. if (mthca_is_memfree(dev))
  172. srq->max = roundup_pow_of_two(srq->max + 1);
  173. ds = min(64UL,
  174. roundup_pow_of_two(sizeof (struct mthca_next_seg) +
  175. srq->max_gs * sizeof (struct mthca_data_seg)));
  176. srq->wqe_shift = long_log2(ds);
  177. srq->srqn = mthca_alloc(&dev->srq_table.alloc);
  178. if (srq->srqn == -1)
  179. return -ENOMEM;
  180. if (mthca_is_memfree(dev)) {
  181. err = mthca_table_get(dev, dev->srq_table.table, srq->srqn);
  182. if (err)
  183. goto err_out;
  184. if (!pd->ibpd.uobject) {
  185. srq->db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_SRQ,
  186. srq->srqn, &srq->db);
  187. if (srq->db_index < 0) {
  188. err = -ENOMEM;
  189. goto err_out_icm;
  190. }
  191. }
  192. }
  193. mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
  194. if (IS_ERR(mailbox)) {
  195. err = PTR_ERR(mailbox);
  196. goto err_out_db;
  197. }
  198. err = mthca_alloc_srq_buf(dev, pd, srq);
  199. if (err)
  200. goto err_out_mailbox;
  201. spin_lock_init(&srq->lock);
  202. atomic_set(&srq->refcount, 1);
  203. init_waitqueue_head(&srq->wait);
  204. if (mthca_is_memfree(dev))
  205. mthca_arbel_init_srq_context(dev, pd, srq, mailbox->buf);
  206. else
  207. mthca_tavor_init_srq_context(dev, pd, srq, mailbox->buf);
  208. err = mthca_SW2HW_SRQ(dev, mailbox, srq->srqn, &status);
  209. if (err) {
  210. mthca_warn(dev, "SW2HW_SRQ failed (%d)\n", err);
  211. goto err_out_free_buf;
  212. }
  213. if (status) {
  214. mthca_warn(dev, "SW2HW_SRQ returned status 0x%02x\n",
  215. status);
  216. err = -EINVAL;
  217. goto err_out_free_buf;
  218. }
  219. spin_lock_irq(&dev->srq_table.lock);
  220. if (mthca_array_set(&dev->srq_table.srq,
  221. srq->srqn & (dev->limits.num_srqs - 1),
  222. srq)) {
  223. spin_unlock_irq(&dev->srq_table.lock);
  224. goto err_out_free_srq;
  225. }
  226. spin_unlock_irq(&dev->srq_table.lock);
  227. mthca_free_mailbox(dev, mailbox);
  228. srq->first_free = 0;
  229. srq->last_free = srq->max - 1;
  230. return 0;
  231. err_out_free_srq:
  232. err = mthca_HW2SW_SRQ(dev, mailbox, srq->srqn, &status);
  233. if (err)
  234. mthca_warn(dev, "HW2SW_SRQ failed (%d)\n", err);
  235. else if (status)
  236. mthca_warn(dev, "HW2SW_SRQ returned status 0x%02x\n", status);
  237. err_out_free_buf:
  238. if (!pd->ibpd.uobject)
  239. mthca_free_srq_buf(dev, srq);
  240. err_out_mailbox:
  241. mthca_free_mailbox(dev, mailbox);
  242. err_out_db:
  243. if (!pd->ibpd.uobject && mthca_is_memfree(dev))
  244. mthca_free_db(dev, MTHCA_DB_TYPE_SRQ, srq->db_index);
  245. err_out_icm:
  246. mthca_table_put(dev, dev->srq_table.table, srq->srqn);
  247. err_out:
  248. mthca_free(&dev->srq_table.alloc, srq->srqn);
  249. return err;
  250. }
  251. void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq)
  252. {
  253. struct mthca_mailbox *mailbox;
  254. int err;
  255. u8 status;
  256. mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
  257. if (IS_ERR(mailbox)) {
  258. mthca_warn(dev, "No memory for mailbox to free SRQ.\n");
  259. return;
  260. }
  261. err = mthca_HW2SW_SRQ(dev, mailbox, srq->srqn, &status);
  262. if (err)
  263. mthca_warn(dev, "HW2SW_SRQ failed (%d)\n", err);
  264. else if (status)
  265. mthca_warn(dev, "HW2SW_SRQ returned status 0x%02x\n", status);
  266. spin_lock_irq(&dev->srq_table.lock);
  267. mthca_array_clear(&dev->srq_table.srq,
  268. srq->srqn & (dev->limits.num_srqs - 1));
  269. spin_unlock_irq(&dev->srq_table.lock);
  270. atomic_dec(&srq->refcount);
  271. wait_event(srq->wait, !atomic_read(&srq->refcount));
  272. if (!srq->ibsrq.uobject) {
  273. mthca_free_srq_buf(dev, srq);
  274. if (mthca_is_memfree(dev))
  275. mthca_free_db(dev, MTHCA_DB_TYPE_SRQ, srq->db_index);
  276. }
  277. mthca_table_put(dev, dev->srq_table.table, srq->srqn);
  278. mthca_free(&dev->srq_table.alloc, srq->srqn);
  279. mthca_free_mailbox(dev, mailbox);
  280. }
  281. int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
  282. enum ib_srq_attr_mask attr_mask)
  283. {
  284. struct mthca_dev *dev = to_mdev(ibsrq->device);
  285. struct mthca_srq *srq = to_msrq(ibsrq);
  286. int ret;
  287. u8 status;
  288. /* We don't support resizing SRQs (yet?) */
  289. if (attr_mask & IB_SRQ_MAX_WR)
  290. return -EINVAL;
  291. if (attr_mask & IB_SRQ_LIMIT) {
  292. ret = mthca_ARM_SRQ(dev, srq->srqn, attr->srq_limit, &status);
  293. if (ret)
  294. return ret;
  295. if (status)
  296. return -EINVAL;
  297. }
  298. return 0;
  299. }
  300. void mthca_srq_event(struct mthca_dev *dev, u32 srqn,
  301. enum ib_event_type event_type)
  302. {
  303. struct mthca_srq *srq;
  304. struct ib_event event;
  305. spin_lock(&dev->srq_table.lock);
  306. srq = mthca_array_get(&dev->srq_table.srq, srqn & (dev->limits.num_srqs - 1));
  307. if (srq)
  308. atomic_inc(&srq->refcount);
  309. spin_unlock(&dev->srq_table.lock);
  310. if (!srq) {
  311. mthca_warn(dev, "Async event for bogus SRQ %08x\n", srqn);
  312. return;
  313. }
  314. if (!srq->ibsrq.event_handler)
  315. goto out;
  316. event.device = &dev->ib_dev;
  317. event.event = event_type;
  318. event.element.srq = &srq->ibsrq;
  319. srq->ibsrq.event_handler(&event, srq->ibsrq.srq_context);
  320. out:
  321. if (atomic_dec_and_test(&srq->refcount))
  322. wake_up(&srq->wait);
  323. }
  324. /*
  325. * This function must be called with IRQs disabled.
  326. */
  327. void mthca_free_srq_wqe(struct mthca_srq *srq, u32 wqe_addr)
  328. {
  329. int ind;
  330. ind = wqe_addr >> srq->wqe_shift;
  331. spin_lock(&srq->lock);
  332. if (likely(srq->first_free >= 0))
  333. *wqe_to_link(get_wqe(srq, srq->last_free)) = ind;
  334. else
  335. srq->first_free = ind;
  336. *wqe_to_link(get_wqe(srq, ind)) = -1;
  337. srq->last_free = ind;
  338. spin_unlock(&srq->lock);
  339. }
  340. int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
  341. struct ib_recv_wr **bad_wr)
  342. {
  343. struct mthca_dev *dev = to_mdev(ibsrq->device);
  344. struct mthca_srq *srq = to_msrq(ibsrq);
  345. unsigned long flags;
  346. int err = 0;
  347. int first_ind;
  348. int ind;
  349. int next_ind;
  350. int nreq;
  351. int i;
  352. void *wqe;
  353. void *prev_wqe;
  354. spin_lock_irqsave(&srq->lock, flags);
  355. first_ind = srq->first_free;
  356. for (nreq = 0; wr; ++nreq, wr = wr->next) {
  357. ind = srq->first_free;
  358. if (ind < 0) {
  359. mthca_err(dev, "SRQ %06x full\n", srq->srqn);
  360. err = -ENOMEM;
  361. *bad_wr = wr;
  362. break;
  363. }
  364. wqe = get_wqe(srq, ind);
  365. next_ind = *wqe_to_link(wqe);
  366. if (next_ind < 0) {
  367. mthca_err(dev, "SRQ %06x full\n", srq->srqn);
  368. err = -ENOMEM;
  369. *bad_wr = wr;
  370. break;
  371. }
  372. prev_wqe = srq->last;
  373. srq->last = wqe;
  374. ((struct mthca_next_seg *) wqe)->nda_op = 0;
  375. ((struct mthca_next_seg *) wqe)->ee_nds = 0;
  376. /* flags field will always remain 0 */
  377. wqe += sizeof (struct mthca_next_seg);
  378. if (unlikely(wr->num_sge > srq->max_gs)) {
  379. err = -EINVAL;
  380. *bad_wr = wr;
  381. srq->last = prev_wqe;
  382. break;
  383. }
  384. for (i = 0; i < wr->num_sge; ++i) {
  385. ((struct mthca_data_seg *) wqe)->byte_count =
  386. cpu_to_be32(wr->sg_list[i].length);
  387. ((struct mthca_data_seg *) wqe)->lkey =
  388. cpu_to_be32(wr->sg_list[i].lkey);
  389. ((struct mthca_data_seg *) wqe)->addr =
  390. cpu_to_be64(wr->sg_list[i].addr);
  391. wqe += sizeof (struct mthca_data_seg);
  392. }
  393. if (i < srq->max_gs) {
  394. ((struct mthca_data_seg *) wqe)->byte_count = 0;
  395. ((struct mthca_data_seg *) wqe)->lkey = cpu_to_be32(MTHCA_INVAL_LKEY);
  396. ((struct mthca_data_seg *) wqe)->addr = 0;
  397. }
  398. ((struct mthca_next_seg *) prev_wqe)->nda_op =
  399. cpu_to_be32((ind << srq->wqe_shift) | 1);
  400. wmb();
  401. ((struct mthca_next_seg *) prev_wqe)->ee_nds =
  402. cpu_to_be32(MTHCA_NEXT_DBD);
  403. srq->wrid[ind] = wr->wr_id;
  404. srq->first_free = next_ind;
  405. }
  406. if (likely(nreq)) {
  407. __be32 doorbell[2];
  408. doorbell[0] = cpu_to_be32(first_ind << srq->wqe_shift);
  409. doorbell[1] = cpu_to_be32((srq->srqn << 8) | nreq);
  410. /*
  411. * Make sure that descriptors are written before
  412. * doorbell is rung.
  413. */
  414. wmb();
  415. mthca_write64(doorbell,
  416. dev->kar + MTHCA_RECEIVE_DOORBELL,
  417. MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
  418. }
  419. spin_unlock_irqrestore(&srq->lock, flags);
  420. return err;
  421. }
  422. int mthca_arbel_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
  423. struct ib_recv_wr **bad_wr)
  424. {
  425. struct mthca_dev *dev = to_mdev(ibsrq->device);
  426. struct mthca_srq *srq = to_msrq(ibsrq);
  427. unsigned long flags;
  428. int err = 0;
  429. int ind;
  430. int next_ind;
  431. int nreq;
  432. int i;
  433. void *wqe;
  434. spin_lock_irqsave(&srq->lock, flags);
  435. for (nreq = 0; wr; ++nreq, wr = wr->next) {
  436. ind = srq->first_free;
  437. if (ind < 0) {
  438. mthca_err(dev, "SRQ %06x full\n", srq->srqn);
  439. err = -ENOMEM;
  440. *bad_wr = wr;
  441. break;
  442. }
  443. wqe = get_wqe(srq, ind);
  444. next_ind = *wqe_to_link(wqe);
  445. if (next_ind < 0) {
  446. mthca_err(dev, "SRQ %06x full\n", srq->srqn);
  447. err = -ENOMEM;
  448. *bad_wr = wr;
  449. break;
  450. }
  451. ((struct mthca_next_seg *) wqe)->nda_op =
  452. cpu_to_be32((next_ind << srq->wqe_shift) | 1);
  453. ((struct mthca_next_seg *) wqe)->ee_nds = 0;
  454. /* flags field will always remain 0 */
  455. wqe += sizeof (struct mthca_next_seg);
  456. if (unlikely(wr->num_sge > srq->max_gs)) {
  457. err = -EINVAL;
  458. *bad_wr = wr;
  459. break;
  460. }
  461. for (i = 0; i < wr->num_sge; ++i) {
  462. ((struct mthca_data_seg *) wqe)->byte_count =
  463. cpu_to_be32(wr->sg_list[i].length);
  464. ((struct mthca_data_seg *) wqe)->lkey =
  465. cpu_to_be32(wr->sg_list[i].lkey);
  466. ((struct mthca_data_seg *) wqe)->addr =
  467. cpu_to_be64(wr->sg_list[i].addr);
  468. wqe += sizeof (struct mthca_data_seg);
  469. }
  470. if (i < srq->max_gs) {
  471. ((struct mthca_data_seg *) wqe)->byte_count = 0;
  472. ((struct mthca_data_seg *) wqe)->lkey = cpu_to_be32(MTHCA_INVAL_LKEY);
  473. ((struct mthca_data_seg *) wqe)->addr = 0;
  474. }
  475. srq->wrid[ind] = wr->wr_id;
  476. srq->first_free = next_ind;
  477. }
  478. if (likely(nreq)) {
  479. srq->counter += nreq;
  480. /*
  481. * Make sure that descriptors are written before
  482. * we write doorbell record.
  483. */
  484. wmb();
  485. *srq->db = cpu_to_be32(srq->counter);
  486. }
  487. spin_unlock_irqrestore(&srq->lock, flags);
  488. return err;
  489. }
  490. int __devinit mthca_init_srq_table(struct mthca_dev *dev)
  491. {
  492. int err;
  493. if (!(dev->mthca_flags & MTHCA_FLAG_SRQ))
  494. return 0;
  495. spin_lock_init(&dev->srq_table.lock);
  496. err = mthca_alloc_init(&dev->srq_table.alloc,
  497. dev->limits.num_srqs,
  498. dev->limits.num_srqs - 1,
  499. dev->limits.reserved_srqs);
  500. if (err)
  501. return err;
  502. err = mthca_array_init(&dev->srq_table.srq,
  503. dev->limits.num_srqs);
  504. if (err)
  505. mthca_alloc_cleanup(&dev->srq_table.alloc);
  506. return err;
  507. }
  508. void __devexit mthca_cleanup_srq_table(struct mthca_dev *dev)
  509. {
  510. if (!(dev->mthca_flags & MTHCA_FLAG_SRQ))
  511. return;
  512. mthca_array_cleanup(&dev->srq_table.srq, dev->limits.num_srqs);
  513. mthca_alloc_cleanup(&dev->srq_table.alloc);
  514. }