iwch_qp.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053
  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. #include "iwch_provider.h"
  33. #include "iwch.h"
  34. #include "iwch_cm.h"
  35. #include "cxio_hal.h"
  36. #define NO_SUPPORT -1
  37. static int iwch_build_rdma_send(union t3_wr *wqe, struct ib_send_wr *wr,
  38. u8 * flit_cnt)
  39. {
  40. int i;
  41. u32 plen;
  42. switch (wr->opcode) {
  43. case IB_WR_SEND:
  44. case IB_WR_SEND_WITH_IMM:
  45. if (wr->send_flags & IB_SEND_SOLICITED)
  46. wqe->send.rdmaop = T3_SEND_WITH_SE;
  47. else
  48. wqe->send.rdmaop = T3_SEND;
  49. wqe->send.rem_stag = 0;
  50. break;
  51. #if 0 /* Not currently supported */
  52. case TYPE_SEND_INVALIDATE:
  53. case TYPE_SEND_INVALIDATE_IMMEDIATE:
  54. wqe->send.rdmaop = T3_SEND_WITH_INV;
  55. wqe->send.rem_stag = cpu_to_be32(wr->wr.rdma.rkey);
  56. break;
  57. case TYPE_SEND_SE_INVALIDATE:
  58. wqe->send.rdmaop = T3_SEND_WITH_SE_INV;
  59. wqe->send.rem_stag = cpu_to_be32(wr->wr.rdma.rkey);
  60. break;
  61. #endif
  62. default:
  63. break;
  64. }
  65. if (wr->num_sge > T3_MAX_SGE)
  66. return -EINVAL;
  67. wqe->send.reserved[0] = 0;
  68. wqe->send.reserved[1] = 0;
  69. wqe->send.reserved[2] = 0;
  70. if (wr->opcode == IB_WR_SEND_WITH_IMM) {
  71. plen = 4;
  72. wqe->send.sgl[0].stag = wr->ex.imm_data;
  73. wqe->send.sgl[0].len = __constant_cpu_to_be32(0);
  74. wqe->send.num_sgle = __constant_cpu_to_be32(0);
  75. *flit_cnt = 5;
  76. } else {
  77. plen = 0;
  78. for (i = 0; i < wr->num_sge; i++) {
  79. if ((plen + wr->sg_list[i].length) < plen) {
  80. return -EMSGSIZE;
  81. }
  82. plen += wr->sg_list[i].length;
  83. wqe->send.sgl[i].stag =
  84. cpu_to_be32(wr->sg_list[i].lkey);
  85. wqe->send.sgl[i].len =
  86. cpu_to_be32(wr->sg_list[i].length);
  87. wqe->send.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr);
  88. }
  89. wqe->send.num_sgle = cpu_to_be32(wr->num_sge);
  90. *flit_cnt = 4 + ((wr->num_sge) << 1);
  91. }
  92. wqe->send.plen = cpu_to_be32(plen);
  93. return 0;
  94. }
  95. static int iwch_build_rdma_write(union t3_wr *wqe, struct ib_send_wr *wr,
  96. u8 *flit_cnt)
  97. {
  98. int i;
  99. u32 plen;
  100. if (wr->num_sge > T3_MAX_SGE)
  101. return -EINVAL;
  102. wqe->write.rdmaop = T3_RDMA_WRITE;
  103. wqe->write.reserved[0] = 0;
  104. wqe->write.reserved[1] = 0;
  105. wqe->write.reserved[2] = 0;
  106. wqe->write.stag_sink = cpu_to_be32(wr->wr.rdma.rkey);
  107. wqe->write.to_sink = cpu_to_be64(wr->wr.rdma.remote_addr);
  108. if (wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM) {
  109. plen = 4;
  110. wqe->write.sgl[0].stag = wr->ex.imm_data;
  111. wqe->write.sgl[0].len = __constant_cpu_to_be32(0);
  112. wqe->write.num_sgle = __constant_cpu_to_be32(0);
  113. *flit_cnt = 6;
  114. } else {
  115. plen = 0;
  116. for (i = 0; i < wr->num_sge; i++) {
  117. if ((plen + wr->sg_list[i].length) < plen) {
  118. return -EMSGSIZE;
  119. }
  120. plen += wr->sg_list[i].length;
  121. wqe->write.sgl[i].stag =
  122. cpu_to_be32(wr->sg_list[i].lkey);
  123. wqe->write.sgl[i].len =
  124. cpu_to_be32(wr->sg_list[i].length);
  125. wqe->write.sgl[i].to =
  126. cpu_to_be64(wr->sg_list[i].addr);
  127. }
  128. wqe->write.num_sgle = cpu_to_be32(wr->num_sge);
  129. *flit_cnt = 5 + ((wr->num_sge) << 1);
  130. }
  131. wqe->write.plen = cpu_to_be32(plen);
  132. return 0;
  133. }
  134. static int iwch_build_rdma_read(union t3_wr *wqe, struct ib_send_wr *wr,
  135. u8 *flit_cnt)
  136. {
  137. if (wr->num_sge > 1)
  138. return -EINVAL;
  139. wqe->read.rdmaop = T3_READ_REQ;
  140. wqe->read.reserved[0] = 0;
  141. wqe->read.reserved[1] = 0;
  142. wqe->read.reserved[2] = 0;
  143. wqe->read.rem_stag = cpu_to_be32(wr->wr.rdma.rkey);
  144. wqe->read.rem_to = cpu_to_be64(wr->wr.rdma.remote_addr);
  145. wqe->read.local_stag = cpu_to_be32(wr->sg_list[0].lkey);
  146. wqe->read.local_len = cpu_to_be32(wr->sg_list[0].length);
  147. wqe->read.local_to = cpu_to_be64(wr->sg_list[0].addr);
  148. *flit_cnt = sizeof(struct t3_rdma_read_wr) >> 3;
  149. return 0;
  150. }
  151. /*
  152. * TBD: this is going to be moved to firmware. Missing pdid/qpid check for now.
  153. */
  154. static int iwch_sgl2pbl_map(struct iwch_dev *rhp, struct ib_sge *sg_list,
  155. u32 num_sgle, u32 * pbl_addr, u8 * page_size)
  156. {
  157. int i;
  158. struct iwch_mr *mhp;
  159. u32 offset;
  160. for (i = 0; i < num_sgle; i++) {
  161. mhp = get_mhp(rhp, (sg_list[i].lkey) >> 8);
  162. if (!mhp) {
  163. PDBG("%s %d\n", __func__, __LINE__);
  164. return -EIO;
  165. }
  166. if (!mhp->attr.state) {
  167. PDBG("%s %d\n", __func__, __LINE__);
  168. return -EIO;
  169. }
  170. if (mhp->attr.zbva) {
  171. PDBG("%s %d\n", __func__, __LINE__);
  172. return -EIO;
  173. }
  174. if (sg_list[i].addr < mhp->attr.va_fbo) {
  175. PDBG("%s %d\n", __func__, __LINE__);
  176. return -EINVAL;
  177. }
  178. if (sg_list[i].addr + ((u64) sg_list[i].length) <
  179. sg_list[i].addr) {
  180. PDBG("%s %d\n", __func__, __LINE__);
  181. return -EINVAL;
  182. }
  183. if (sg_list[i].addr + ((u64) sg_list[i].length) >
  184. mhp->attr.va_fbo + ((u64) mhp->attr.len)) {
  185. PDBG("%s %d\n", __func__, __LINE__);
  186. return -EINVAL;
  187. }
  188. offset = sg_list[i].addr - mhp->attr.va_fbo;
  189. offset += ((u32) mhp->attr.va_fbo) %
  190. (1UL << (12 + mhp->attr.page_size));
  191. pbl_addr[i] = ((mhp->attr.pbl_addr -
  192. rhp->rdev.rnic_info.pbl_base) >> 3) +
  193. (offset >> (12 + mhp->attr.page_size));
  194. page_size[i] = mhp->attr.page_size;
  195. }
  196. return 0;
  197. }
  198. static int iwch_build_rdma_recv(struct iwch_dev *rhp, union t3_wr *wqe,
  199. struct ib_recv_wr *wr)
  200. {
  201. int i;
  202. if (wr->num_sge > T3_MAX_SGE)
  203. return -EINVAL;
  204. wqe->recv.num_sgle = cpu_to_be32(wr->num_sge);
  205. for (i = 0; i < wr->num_sge; i++) {
  206. wqe->recv.sgl[i].stag = cpu_to_be32(wr->sg_list[i].lkey);
  207. wqe->recv.sgl[i].len = cpu_to_be32(wr->sg_list[i].length);
  208. wqe->recv.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr);
  209. }
  210. for (; i < T3_MAX_SGE; i++) {
  211. wqe->recv.sgl[i].stag = 0;
  212. wqe->recv.sgl[i].len = 0;
  213. wqe->recv.sgl[i].to = 0;
  214. }
  215. return 0;
  216. }
  217. int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
  218. struct ib_send_wr **bad_wr)
  219. {
  220. int err = 0;
  221. u8 uninitialized_var(t3_wr_flit_cnt);
  222. enum t3_wr_opcode t3_wr_opcode = 0;
  223. enum t3_wr_flags t3_wr_flags;
  224. struct iwch_qp *qhp;
  225. u32 idx;
  226. union t3_wr *wqe;
  227. u32 num_wrs;
  228. unsigned long flag;
  229. struct t3_swsq *sqp;
  230. qhp = to_iwch_qp(ibqp);
  231. spin_lock_irqsave(&qhp->lock, flag);
  232. if (qhp->attr.state > IWCH_QP_STATE_RTS) {
  233. spin_unlock_irqrestore(&qhp->lock, flag);
  234. return -EINVAL;
  235. }
  236. num_wrs = Q_FREECNT(qhp->wq.sq_rptr, qhp->wq.sq_wptr,
  237. qhp->wq.sq_size_log2);
  238. if (num_wrs <= 0) {
  239. spin_unlock_irqrestore(&qhp->lock, flag);
  240. return -ENOMEM;
  241. }
  242. while (wr) {
  243. if (num_wrs == 0) {
  244. err = -ENOMEM;
  245. *bad_wr = wr;
  246. break;
  247. }
  248. idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2);
  249. wqe = (union t3_wr *) (qhp->wq.queue + idx);
  250. t3_wr_flags = 0;
  251. if (wr->send_flags & IB_SEND_SOLICITED)
  252. t3_wr_flags |= T3_SOLICITED_EVENT_FLAG;
  253. if (wr->send_flags & IB_SEND_FENCE)
  254. t3_wr_flags |= T3_READ_FENCE_FLAG;
  255. if (wr->send_flags & IB_SEND_SIGNALED)
  256. t3_wr_flags |= T3_COMPLETION_FLAG;
  257. sqp = qhp->wq.sq +
  258. Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2);
  259. switch (wr->opcode) {
  260. case IB_WR_SEND:
  261. case IB_WR_SEND_WITH_IMM:
  262. t3_wr_opcode = T3_WR_SEND;
  263. err = iwch_build_rdma_send(wqe, wr, &t3_wr_flit_cnt);
  264. break;
  265. case IB_WR_RDMA_WRITE:
  266. case IB_WR_RDMA_WRITE_WITH_IMM:
  267. t3_wr_opcode = T3_WR_WRITE;
  268. err = iwch_build_rdma_write(wqe, wr, &t3_wr_flit_cnt);
  269. break;
  270. case IB_WR_RDMA_READ:
  271. t3_wr_opcode = T3_WR_READ;
  272. t3_wr_flags = 0; /* T3 reads are always signaled */
  273. err = iwch_build_rdma_read(wqe, wr, &t3_wr_flit_cnt);
  274. if (err)
  275. break;
  276. sqp->read_len = wqe->read.local_len;
  277. if (!qhp->wq.oldest_read)
  278. qhp->wq.oldest_read = sqp;
  279. break;
  280. default:
  281. PDBG("%s post of type=%d TBD!\n", __func__,
  282. wr->opcode);
  283. err = -EINVAL;
  284. }
  285. if (err) {
  286. *bad_wr = wr;
  287. break;
  288. }
  289. wqe->send.wrid.id0.hi = qhp->wq.sq_wptr;
  290. sqp->wr_id = wr->wr_id;
  291. sqp->opcode = wr2opcode(t3_wr_opcode);
  292. sqp->sq_wptr = qhp->wq.sq_wptr;
  293. sqp->complete = 0;
  294. sqp->signaled = (wr->send_flags & IB_SEND_SIGNALED);
  295. build_fw_riwrh((void *) wqe, t3_wr_opcode, t3_wr_flags,
  296. Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2),
  297. 0, t3_wr_flit_cnt);
  298. PDBG("%s cookie 0x%llx wq idx 0x%x swsq idx %ld opcode %d\n",
  299. __func__, (unsigned long long) wr->wr_id, idx,
  300. Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2),
  301. sqp->opcode);
  302. wr = wr->next;
  303. num_wrs--;
  304. ++(qhp->wq.wptr);
  305. ++(qhp->wq.sq_wptr);
  306. }
  307. spin_unlock_irqrestore(&qhp->lock, flag);
  308. ring_doorbell(qhp->wq.doorbell, qhp->wq.qpid);
  309. return err;
  310. }
  311. int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
  312. struct ib_recv_wr **bad_wr)
  313. {
  314. int err = 0;
  315. struct iwch_qp *qhp;
  316. u32 idx;
  317. union t3_wr *wqe;
  318. u32 num_wrs;
  319. unsigned long flag;
  320. qhp = to_iwch_qp(ibqp);
  321. spin_lock_irqsave(&qhp->lock, flag);
  322. if (qhp->attr.state > IWCH_QP_STATE_RTS) {
  323. spin_unlock_irqrestore(&qhp->lock, flag);
  324. return -EINVAL;
  325. }
  326. num_wrs = Q_FREECNT(qhp->wq.rq_rptr, qhp->wq.rq_wptr,
  327. qhp->wq.rq_size_log2) - 1;
  328. if (!wr) {
  329. spin_unlock_irqrestore(&qhp->lock, flag);
  330. return -EINVAL;
  331. }
  332. while (wr) {
  333. idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2);
  334. wqe = (union t3_wr *) (qhp->wq.queue + idx);
  335. if (num_wrs)
  336. err = iwch_build_rdma_recv(qhp->rhp, wqe, wr);
  337. else
  338. err = -ENOMEM;
  339. if (err) {
  340. *bad_wr = wr;
  341. break;
  342. }
  343. qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr, qhp->wq.rq_size_log2)] =
  344. wr->wr_id;
  345. build_fw_riwrh((void *) wqe, T3_WR_RCV, T3_COMPLETION_FLAG,
  346. Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2),
  347. 0, sizeof(struct t3_receive_wr) >> 3);
  348. PDBG("%s cookie 0x%llx idx 0x%x rq_wptr 0x%x rw_rptr 0x%x "
  349. "wqe %p \n", __func__, (unsigned long long) wr->wr_id,
  350. idx, qhp->wq.rq_wptr, qhp->wq.rq_rptr, wqe);
  351. ++(qhp->wq.rq_wptr);
  352. ++(qhp->wq.wptr);
  353. wr = wr->next;
  354. num_wrs--;
  355. }
  356. spin_unlock_irqrestore(&qhp->lock, flag);
  357. ring_doorbell(qhp->wq.doorbell, qhp->wq.qpid);
  358. return err;
  359. }
  360. int iwch_bind_mw(struct ib_qp *qp,
  361. struct ib_mw *mw,
  362. struct ib_mw_bind *mw_bind)
  363. {
  364. struct iwch_dev *rhp;
  365. struct iwch_mw *mhp;
  366. struct iwch_qp *qhp;
  367. union t3_wr *wqe;
  368. u32 pbl_addr;
  369. u8 page_size;
  370. u32 num_wrs;
  371. unsigned long flag;
  372. struct ib_sge sgl;
  373. int err=0;
  374. enum t3_wr_flags t3_wr_flags;
  375. u32 idx;
  376. struct t3_swsq *sqp;
  377. qhp = to_iwch_qp(qp);
  378. mhp = to_iwch_mw(mw);
  379. rhp = qhp->rhp;
  380. spin_lock_irqsave(&qhp->lock, flag);
  381. if (qhp->attr.state > IWCH_QP_STATE_RTS) {
  382. spin_unlock_irqrestore(&qhp->lock, flag);
  383. return -EINVAL;
  384. }
  385. num_wrs = Q_FREECNT(qhp->wq.sq_rptr, qhp->wq.sq_wptr,
  386. qhp->wq.sq_size_log2);
  387. if ((num_wrs) <= 0) {
  388. spin_unlock_irqrestore(&qhp->lock, flag);
  389. return -ENOMEM;
  390. }
  391. idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2);
  392. PDBG("%s: idx 0x%0x, mw 0x%p, mw_bind 0x%p\n", __func__, idx,
  393. mw, mw_bind);
  394. wqe = (union t3_wr *) (qhp->wq.queue + idx);
  395. t3_wr_flags = 0;
  396. if (mw_bind->send_flags & IB_SEND_SIGNALED)
  397. t3_wr_flags = T3_COMPLETION_FLAG;
  398. sgl.addr = mw_bind->addr;
  399. sgl.lkey = mw_bind->mr->lkey;
  400. sgl.length = mw_bind->length;
  401. wqe->bind.reserved = 0;
  402. wqe->bind.type = T3_VA_BASED_TO;
  403. /* TBD: check perms */
  404. wqe->bind.perms = iwch_ib_to_mwbind_access(mw_bind->mw_access_flags);
  405. wqe->bind.mr_stag = cpu_to_be32(mw_bind->mr->lkey);
  406. wqe->bind.mw_stag = cpu_to_be32(mw->rkey);
  407. wqe->bind.mw_len = cpu_to_be32(mw_bind->length);
  408. wqe->bind.mw_va = cpu_to_be64(mw_bind->addr);
  409. err = iwch_sgl2pbl_map(rhp, &sgl, 1, &pbl_addr, &page_size);
  410. if (err) {
  411. spin_unlock_irqrestore(&qhp->lock, flag);
  412. return err;
  413. }
  414. wqe->send.wrid.id0.hi = qhp->wq.sq_wptr;
  415. sqp = qhp->wq.sq + Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2);
  416. sqp->wr_id = mw_bind->wr_id;
  417. sqp->opcode = T3_BIND_MW;
  418. sqp->sq_wptr = qhp->wq.sq_wptr;
  419. sqp->complete = 0;
  420. sqp->signaled = (mw_bind->send_flags & IB_SEND_SIGNALED);
  421. wqe->bind.mr_pbl_addr = cpu_to_be32(pbl_addr);
  422. wqe->bind.mr_pagesz = page_size;
  423. wqe->flit[T3_SQ_COOKIE_FLIT] = mw_bind->wr_id;
  424. build_fw_riwrh((void *)wqe, T3_WR_BIND, t3_wr_flags,
  425. Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), 0,
  426. sizeof(struct t3_bind_mw_wr) >> 3);
  427. ++(qhp->wq.wptr);
  428. ++(qhp->wq.sq_wptr);
  429. spin_unlock_irqrestore(&qhp->lock, flag);
  430. ring_doorbell(qhp->wq.doorbell, qhp->wq.qpid);
  431. return err;
  432. }
  433. static inline void build_term_codes(struct respQ_msg_t *rsp_msg,
  434. u8 *layer_type, u8 *ecode)
  435. {
  436. int status = TPT_ERR_INTERNAL_ERR;
  437. int tagged = 0;
  438. int opcode = -1;
  439. int rqtype = 0;
  440. int send_inv = 0;
  441. if (rsp_msg) {
  442. status = CQE_STATUS(rsp_msg->cqe);
  443. opcode = CQE_OPCODE(rsp_msg->cqe);
  444. rqtype = RQ_TYPE(rsp_msg->cqe);
  445. send_inv = (opcode == T3_SEND_WITH_INV) ||
  446. (opcode == T3_SEND_WITH_SE_INV);
  447. tagged = (opcode == T3_RDMA_WRITE) ||
  448. (rqtype && (opcode == T3_READ_RESP));
  449. }
  450. switch (status) {
  451. case TPT_ERR_STAG:
  452. if (send_inv) {
  453. *layer_type = LAYER_RDMAP|RDMAP_REMOTE_OP;
  454. *ecode = RDMAP_CANT_INV_STAG;
  455. } else {
  456. *layer_type = LAYER_RDMAP|RDMAP_REMOTE_PROT;
  457. *ecode = RDMAP_INV_STAG;
  458. }
  459. break;
  460. case TPT_ERR_PDID:
  461. *layer_type = LAYER_RDMAP|RDMAP_REMOTE_PROT;
  462. if ((opcode == T3_SEND_WITH_INV) ||
  463. (opcode == T3_SEND_WITH_SE_INV))
  464. *ecode = RDMAP_CANT_INV_STAG;
  465. else
  466. *ecode = RDMAP_STAG_NOT_ASSOC;
  467. break;
  468. case TPT_ERR_QPID:
  469. *layer_type = LAYER_RDMAP|RDMAP_REMOTE_PROT;
  470. *ecode = RDMAP_STAG_NOT_ASSOC;
  471. break;
  472. case TPT_ERR_ACCESS:
  473. *layer_type = LAYER_RDMAP|RDMAP_REMOTE_PROT;
  474. *ecode = RDMAP_ACC_VIOL;
  475. break;
  476. case TPT_ERR_WRAP:
  477. *layer_type = LAYER_RDMAP|RDMAP_REMOTE_PROT;
  478. *ecode = RDMAP_TO_WRAP;
  479. break;
  480. case TPT_ERR_BOUND:
  481. if (tagged) {
  482. *layer_type = LAYER_DDP|DDP_TAGGED_ERR;
  483. *ecode = DDPT_BASE_BOUNDS;
  484. } else {
  485. *layer_type = LAYER_RDMAP|RDMAP_REMOTE_PROT;
  486. *ecode = RDMAP_BASE_BOUNDS;
  487. }
  488. break;
  489. case TPT_ERR_INVALIDATE_SHARED_MR:
  490. case TPT_ERR_INVALIDATE_MR_WITH_MW_BOUND:
  491. *layer_type = LAYER_RDMAP|RDMAP_REMOTE_OP;
  492. *ecode = RDMAP_CANT_INV_STAG;
  493. break;
  494. case TPT_ERR_ECC:
  495. case TPT_ERR_ECC_PSTAG:
  496. case TPT_ERR_INTERNAL_ERR:
  497. *layer_type = LAYER_RDMAP|RDMAP_LOCAL_CATA;
  498. *ecode = 0;
  499. break;
  500. case TPT_ERR_OUT_OF_RQE:
  501. *layer_type = LAYER_DDP|DDP_UNTAGGED_ERR;
  502. *ecode = DDPU_INV_MSN_NOBUF;
  503. break;
  504. case TPT_ERR_PBL_ADDR_BOUND:
  505. *layer_type = LAYER_DDP|DDP_TAGGED_ERR;
  506. *ecode = DDPT_BASE_BOUNDS;
  507. break;
  508. case TPT_ERR_CRC:
  509. *layer_type = LAYER_MPA|DDP_LLP;
  510. *ecode = MPA_CRC_ERR;
  511. break;
  512. case TPT_ERR_MARKER:
  513. *layer_type = LAYER_MPA|DDP_LLP;
  514. *ecode = MPA_MARKER_ERR;
  515. break;
  516. case TPT_ERR_PDU_LEN_ERR:
  517. *layer_type = LAYER_DDP|DDP_UNTAGGED_ERR;
  518. *ecode = DDPU_MSG_TOOBIG;
  519. break;
  520. case TPT_ERR_DDP_VERSION:
  521. if (tagged) {
  522. *layer_type = LAYER_DDP|DDP_TAGGED_ERR;
  523. *ecode = DDPT_INV_VERS;
  524. } else {
  525. *layer_type = LAYER_DDP|DDP_UNTAGGED_ERR;
  526. *ecode = DDPU_INV_VERS;
  527. }
  528. break;
  529. case TPT_ERR_RDMA_VERSION:
  530. *layer_type = LAYER_RDMAP|RDMAP_REMOTE_OP;
  531. *ecode = RDMAP_INV_VERS;
  532. break;
  533. case TPT_ERR_OPCODE:
  534. *layer_type = LAYER_RDMAP|RDMAP_REMOTE_OP;
  535. *ecode = RDMAP_INV_OPCODE;
  536. break;
  537. case TPT_ERR_DDP_QUEUE_NUM:
  538. *layer_type = LAYER_DDP|DDP_UNTAGGED_ERR;
  539. *ecode = DDPU_INV_QN;
  540. break;
  541. case TPT_ERR_MSN:
  542. case TPT_ERR_MSN_GAP:
  543. case TPT_ERR_MSN_RANGE:
  544. case TPT_ERR_IRD_OVERFLOW:
  545. *layer_type = LAYER_DDP|DDP_UNTAGGED_ERR;
  546. *ecode = DDPU_INV_MSN_RANGE;
  547. break;
  548. case TPT_ERR_TBIT:
  549. *layer_type = LAYER_DDP|DDP_LOCAL_CATA;
  550. *ecode = 0;
  551. break;
  552. case TPT_ERR_MO:
  553. *layer_type = LAYER_DDP|DDP_UNTAGGED_ERR;
  554. *ecode = DDPU_INV_MO;
  555. break;
  556. default:
  557. *layer_type = LAYER_RDMAP|DDP_LOCAL_CATA;
  558. *ecode = 0;
  559. break;
  560. }
  561. }
  562. int iwch_post_zb_read(struct iwch_qp *qhp)
  563. {
  564. union t3_wr *wqe;
  565. struct sk_buff *skb;
  566. u8 flit_cnt = sizeof(struct t3_rdma_read_wr) >> 3;
  567. PDBG("%s enter\n", __func__);
  568. skb = alloc_skb(40, GFP_KERNEL);
  569. if (!skb) {
  570. printk(KERN_ERR "%s cannot send zb_read!!\n", __func__);
  571. return -ENOMEM;
  572. }
  573. wqe = (union t3_wr *)skb_put(skb, sizeof(struct t3_rdma_read_wr));
  574. memset(wqe, 0, sizeof(struct t3_rdma_read_wr));
  575. wqe->read.rdmaop = T3_READ_REQ;
  576. wqe->read.reserved[0] = 0;
  577. wqe->read.reserved[1] = 0;
  578. wqe->read.reserved[2] = 0;
  579. wqe->read.rem_stag = cpu_to_be32(1);
  580. wqe->read.rem_to = cpu_to_be64(1);
  581. wqe->read.local_stag = cpu_to_be32(1);
  582. wqe->read.local_len = cpu_to_be32(0);
  583. wqe->read.local_to = cpu_to_be64(1);
  584. wqe->send.wrh.op_seop_flags = cpu_to_be32(V_FW_RIWR_OP(T3_WR_READ));
  585. wqe->send.wrh.gen_tid_len = cpu_to_be32(V_FW_RIWR_TID(qhp->ep->hwtid)|
  586. V_FW_RIWR_LEN(flit_cnt));
  587. skb->priority = CPL_PRIORITY_DATA;
  588. return cxgb3_ofld_send(qhp->rhp->rdev.t3cdev_p, skb);
  589. }
  590. /*
  591. * This posts a TERMINATE with layer=RDMA, type=catastrophic.
  592. */
  593. int iwch_post_terminate(struct iwch_qp *qhp, struct respQ_msg_t *rsp_msg)
  594. {
  595. union t3_wr *wqe;
  596. struct terminate_message *term;
  597. struct sk_buff *skb;
  598. PDBG("%s %d\n", __func__, __LINE__);
  599. skb = alloc_skb(40, GFP_ATOMIC);
  600. if (!skb) {
  601. printk(KERN_ERR "%s cannot send TERMINATE!\n", __func__);
  602. return -ENOMEM;
  603. }
  604. wqe = (union t3_wr *)skb_put(skb, 40);
  605. memset(wqe, 0, 40);
  606. wqe->send.rdmaop = T3_TERMINATE;
  607. /* immediate data length */
  608. wqe->send.plen = htonl(4);
  609. /* immediate data starts here. */
  610. term = (struct terminate_message *)wqe->send.sgl;
  611. build_term_codes(rsp_msg, &term->layer_etype, &term->ecode);
  612. wqe->send.wrh.op_seop_flags = cpu_to_be32(V_FW_RIWR_OP(T3_WR_SEND) |
  613. V_FW_RIWR_FLAGS(T3_COMPLETION_FLAG | T3_NOTIFY_FLAG));
  614. wqe->send.wrh.gen_tid_len = cpu_to_be32(V_FW_RIWR_TID(qhp->ep->hwtid));
  615. skb->priority = CPL_PRIORITY_DATA;
  616. return cxgb3_ofld_send(qhp->rhp->rdev.t3cdev_p, skb);
  617. }
  618. /*
  619. * Assumes qhp lock is held.
  620. */
  621. static void __flush_qp(struct iwch_qp *qhp, unsigned long *flag)
  622. {
  623. struct iwch_cq *rchp, *schp;
  624. int count;
  625. int flushed;
  626. rchp = get_chp(qhp->rhp, qhp->attr.rcq);
  627. schp = get_chp(qhp->rhp, qhp->attr.scq);
  628. PDBG("%s qhp %p rchp %p schp %p\n", __func__, qhp, rchp, schp);
  629. /* take a ref on the qhp since we must release the lock */
  630. atomic_inc(&qhp->refcnt);
  631. spin_unlock_irqrestore(&qhp->lock, *flag);
  632. /* locking heirarchy: cq lock first, then qp lock. */
  633. spin_lock_irqsave(&rchp->lock, *flag);
  634. spin_lock(&qhp->lock);
  635. cxio_flush_hw_cq(&rchp->cq);
  636. cxio_count_rcqes(&rchp->cq, &qhp->wq, &count);
  637. flushed = cxio_flush_rq(&qhp->wq, &rchp->cq, count);
  638. spin_unlock(&qhp->lock);
  639. spin_unlock_irqrestore(&rchp->lock, *flag);
  640. if (flushed)
  641. (*rchp->ibcq.comp_handler)(&rchp->ibcq, rchp->ibcq.cq_context);
  642. /* locking heirarchy: cq lock first, then qp lock. */
  643. spin_lock_irqsave(&schp->lock, *flag);
  644. spin_lock(&qhp->lock);
  645. cxio_flush_hw_cq(&schp->cq);
  646. cxio_count_scqes(&schp->cq, &qhp->wq, &count);
  647. flushed = cxio_flush_sq(&qhp->wq, &schp->cq, count);
  648. spin_unlock(&qhp->lock);
  649. spin_unlock_irqrestore(&schp->lock, *flag);
  650. if (flushed)
  651. (*schp->ibcq.comp_handler)(&schp->ibcq, schp->ibcq.cq_context);
  652. /* deref */
  653. if (atomic_dec_and_test(&qhp->refcnt))
  654. wake_up(&qhp->wait);
  655. spin_lock_irqsave(&qhp->lock, *flag);
  656. }
  657. static void flush_qp(struct iwch_qp *qhp, unsigned long *flag)
  658. {
  659. if (qhp->ibqp.uobject)
  660. cxio_set_wq_in_error(&qhp->wq);
  661. else
  662. __flush_qp(qhp, flag);
  663. }
  664. /*
  665. * Return count of RECV WRs posted
  666. */
  667. u16 iwch_rqes_posted(struct iwch_qp *qhp)
  668. {
  669. union t3_wr *wqe = qhp->wq.queue;
  670. u16 count = 0;
  671. while ((count+1) != 0 && fw_riwrh_opcode((struct fw_riwrh *)wqe) == T3_WR_RCV) {
  672. count++;
  673. wqe++;
  674. }
  675. PDBG("%s qhp %p count %u\n", __func__, qhp, count);
  676. return count;
  677. }
  678. static int rdma_init(struct iwch_dev *rhp, struct iwch_qp *qhp,
  679. enum iwch_qp_attr_mask mask,
  680. struct iwch_qp_attributes *attrs)
  681. {
  682. struct t3_rdma_init_attr init_attr;
  683. int ret;
  684. init_attr.tid = qhp->ep->hwtid;
  685. init_attr.qpid = qhp->wq.qpid;
  686. init_attr.pdid = qhp->attr.pd;
  687. init_attr.scqid = qhp->attr.scq;
  688. init_attr.rcqid = qhp->attr.rcq;
  689. init_attr.rq_addr = qhp->wq.rq_addr;
  690. init_attr.rq_size = 1 << qhp->wq.rq_size_log2;
  691. init_attr.mpaattrs = uP_RI_MPA_IETF_ENABLE |
  692. qhp->attr.mpa_attr.recv_marker_enabled |
  693. (qhp->attr.mpa_attr.xmit_marker_enabled << 1) |
  694. (qhp->attr.mpa_attr.crc_enabled << 2);
  695. /*
  696. * XXX - The IWCM doesn't quite handle getting these
  697. * attrs set before going into RTS. For now, just turn
  698. * them on always...
  699. */
  700. #if 0
  701. init_attr.qpcaps = qhp->attr.enableRdmaRead |
  702. (qhp->attr.enableRdmaWrite << 1) |
  703. (qhp->attr.enableBind << 2) |
  704. (qhp->attr.enable_stag0_fastreg << 3) |
  705. (qhp->attr.enable_stag0_fastreg << 4);
  706. #else
  707. init_attr.qpcaps = 0x1f;
  708. #endif
  709. init_attr.tcp_emss = qhp->ep->emss;
  710. init_attr.ord = qhp->attr.max_ord;
  711. init_attr.ird = qhp->attr.max_ird;
  712. init_attr.qp_dma_addr = qhp->wq.dma_addr;
  713. init_attr.qp_dma_size = (1UL << qhp->wq.size_log2);
  714. init_attr.rqe_count = iwch_rqes_posted(qhp);
  715. init_attr.flags = qhp->attr.mpa_attr.initiator ? MPA_INITIATOR : 0;
  716. init_attr.flags |= capable(CAP_NET_BIND_SERVICE) ? PRIV_QP : 0;
  717. if (peer2peer) {
  718. init_attr.rtr_type = RTR_READ;
  719. if (init_attr.ord == 0 && qhp->attr.mpa_attr.initiator)
  720. init_attr.ord = 1;
  721. if (init_attr.ird == 0 && !qhp->attr.mpa_attr.initiator)
  722. init_attr.ird = 1;
  723. } else
  724. init_attr.rtr_type = 0;
  725. init_attr.irs = qhp->ep->rcv_seq;
  726. PDBG("%s init_attr.rq_addr 0x%x init_attr.rq_size = %d "
  727. "flags 0x%x qpcaps 0x%x\n", __func__,
  728. init_attr.rq_addr, init_attr.rq_size,
  729. init_attr.flags, init_attr.qpcaps);
  730. ret = cxio_rdma_init(&rhp->rdev, &init_attr);
  731. PDBG("%s ret %d\n", __func__, ret);
  732. return ret;
  733. }
  734. int iwch_modify_qp(struct iwch_dev *rhp, struct iwch_qp *qhp,
  735. enum iwch_qp_attr_mask mask,
  736. struct iwch_qp_attributes *attrs,
  737. int internal)
  738. {
  739. int ret = 0;
  740. struct iwch_qp_attributes newattr = qhp->attr;
  741. unsigned long flag;
  742. int disconnect = 0;
  743. int terminate = 0;
  744. int abort = 0;
  745. int free = 0;
  746. struct iwch_ep *ep = NULL;
  747. PDBG("%s qhp %p qpid 0x%x ep %p state %d -> %d\n", __func__,
  748. qhp, qhp->wq.qpid, qhp->ep, qhp->attr.state,
  749. (mask & IWCH_QP_ATTR_NEXT_STATE) ? attrs->next_state : -1);
  750. spin_lock_irqsave(&qhp->lock, flag);
  751. /* Process attr changes if in IDLE */
  752. if (mask & IWCH_QP_ATTR_VALID_MODIFY) {
  753. if (qhp->attr.state != IWCH_QP_STATE_IDLE) {
  754. ret = -EIO;
  755. goto out;
  756. }
  757. if (mask & IWCH_QP_ATTR_ENABLE_RDMA_READ)
  758. newattr.enable_rdma_read = attrs->enable_rdma_read;
  759. if (mask & IWCH_QP_ATTR_ENABLE_RDMA_WRITE)
  760. newattr.enable_rdma_write = attrs->enable_rdma_write;
  761. if (mask & IWCH_QP_ATTR_ENABLE_RDMA_BIND)
  762. newattr.enable_bind = attrs->enable_bind;
  763. if (mask & IWCH_QP_ATTR_MAX_ORD) {
  764. if (attrs->max_ord >
  765. rhp->attr.max_rdma_read_qp_depth) {
  766. ret = -EINVAL;
  767. goto out;
  768. }
  769. newattr.max_ord = attrs->max_ord;
  770. }
  771. if (mask & IWCH_QP_ATTR_MAX_IRD) {
  772. if (attrs->max_ird >
  773. rhp->attr.max_rdma_reads_per_qp) {
  774. ret = -EINVAL;
  775. goto out;
  776. }
  777. newattr.max_ird = attrs->max_ird;
  778. }
  779. qhp->attr = newattr;
  780. }
  781. if (!(mask & IWCH_QP_ATTR_NEXT_STATE))
  782. goto out;
  783. if (qhp->attr.state == attrs->next_state)
  784. goto out;
  785. switch (qhp->attr.state) {
  786. case IWCH_QP_STATE_IDLE:
  787. switch (attrs->next_state) {
  788. case IWCH_QP_STATE_RTS:
  789. if (!(mask & IWCH_QP_ATTR_LLP_STREAM_HANDLE)) {
  790. ret = -EINVAL;
  791. goto out;
  792. }
  793. if (!(mask & IWCH_QP_ATTR_MPA_ATTR)) {
  794. ret = -EINVAL;
  795. goto out;
  796. }
  797. qhp->attr.mpa_attr = attrs->mpa_attr;
  798. qhp->attr.llp_stream_handle = attrs->llp_stream_handle;
  799. qhp->ep = qhp->attr.llp_stream_handle;
  800. qhp->attr.state = IWCH_QP_STATE_RTS;
  801. /*
  802. * Ref the endpoint here and deref when we
  803. * disassociate the endpoint from the QP. This
  804. * happens in CLOSING->IDLE transition or *->ERROR
  805. * transition.
  806. */
  807. get_ep(&qhp->ep->com);
  808. spin_unlock_irqrestore(&qhp->lock, flag);
  809. ret = rdma_init(rhp, qhp, mask, attrs);
  810. spin_lock_irqsave(&qhp->lock, flag);
  811. if (ret)
  812. goto err;
  813. break;
  814. case IWCH_QP_STATE_ERROR:
  815. qhp->attr.state = IWCH_QP_STATE_ERROR;
  816. flush_qp(qhp, &flag);
  817. break;
  818. default:
  819. ret = -EINVAL;
  820. goto out;
  821. }
  822. break;
  823. case IWCH_QP_STATE_RTS:
  824. switch (attrs->next_state) {
  825. case IWCH_QP_STATE_CLOSING:
  826. BUG_ON(atomic_read(&qhp->ep->com.kref.refcount) < 2);
  827. qhp->attr.state = IWCH_QP_STATE_CLOSING;
  828. if (!internal) {
  829. abort=0;
  830. disconnect = 1;
  831. ep = qhp->ep;
  832. get_ep(&ep->com);
  833. }
  834. break;
  835. case IWCH_QP_STATE_TERMINATE:
  836. qhp->attr.state = IWCH_QP_STATE_TERMINATE;
  837. if (qhp->ibqp.uobject)
  838. cxio_set_wq_in_error(&qhp->wq);
  839. if (!internal)
  840. terminate = 1;
  841. break;
  842. case IWCH_QP_STATE_ERROR:
  843. qhp->attr.state = IWCH_QP_STATE_ERROR;
  844. if (!internal) {
  845. abort=1;
  846. disconnect = 1;
  847. ep = qhp->ep;
  848. get_ep(&ep->com);
  849. }
  850. goto err;
  851. break;
  852. default:
  853. ret = -EINVAL;
  854. goto out;
  855. }
  856. break;
  857. case IWCH_QP_STATE_CLOSING:
  858. if (!internal) {
  859. ret = -EINVAL;
  860. goto out;
  861. }
  862. switch (attrs->next_state) {
  863. case IWCH_QP_STATE_IDLE:
  864. flush_qp(qhp, &flag);
  865. qhp->attr.state = IWCH_QP_STATE_IDLE;
  866. qhp->attr.llp_stream_handle = NULL;
  867. put_ep(&qhp->ep->com);
  868. qhp->ep = NULL;
  869. wake_up(&qhp->wait);
  870. break;
  871. case IWCH_QP_STATE_ERROR:
  872. goto err;
  873. default:
  874. ret = -EINVAL;
  875. goto err;
  876. }
  877. break;
  878. case IWCH_QP_STATE_ERROR:
  879. if (attrs->next_state != IWCH_QP_STATE_IDLE) {
  880. ret = -EINVAL;
  881. goto out;
  882. }
  883. if (!Q_EMPTY(qhp->wq.sq_rptr, qhp->wq.sq_wptr) ||
  884. !Q_EMPTY(qhp->wq.rq_rptr, qhp->wq.rq_wptr)) {
  885. ret = -EINVAL;
  886. goto out;
  887. }
  888. qhp->attr.state = IWCH_QP_STATE_IDLE;
  889. memset(&qhp->attr, 0, sizeof(qhp->attr));
  890. break;
  891. case IWCH_QP_STATE_TERMINATE:
  892. if (!internal) {
  893. ret = -EINVAL;
  894. goto out;
  895. }
  896. goto err;
  897. break;
  898. default:
  899. printk(KERN_ERR "%s in a bad state %d\n",
  900. __func__, qhp->attr.state);
  901. ret = -EINVAL;
  902. goto err;
  903. break;
  904. }
  905. goto out;
  906. err:
  907. PDBG("%s disassociating ep %p qpid 0x%x\n", __func__, qhp->ep,
  908. qhp->wq.qpid);
  909. /* disassociate the LLP connection */
  910. qhp->attr.llp_stream_handle = NULL;
  911. ep = qhp->ep;
  912. qhp->ep = NULL;
  913. qhp->attr.state = IWCH_QP_STATE_ERROR;
  914. free=1;
  915. wake_up(&qhp->wait);
  916. BUG_ON(!ep);
  917. flush_qp(qhp, &flag);
  918. out:
  919. spin_unlock_irqrestore(&qhp->lock, flag);
  920. if (terminate)
  921. iwch_post_terminate(qhp, NULL);
  922. /*
  923. * If disconnect is 1, then we need to initiate a disconnect
  924. * on the EP. This can be a normal close (RTS->CLOSING) or
  925. * an abnormal close (RTS/CLOSING->ERROR).
  926. */
  927. if (disconnect) {
  928. iwch_ep_disconnect(ep, abort, GFP_KERNEL);
  929. put_ep(&ep->com);
  930. }
  931. /*
  932. * If free is 1, then we've disassociated the EP from the QP
  933. * and we need to dereference the EP.
  934. */
  935. if (free)
  936. put_ep(&ep->com);
  937. PDBG("%s exit state %d\n", __func__, qhp->attr.state);
  938. return ret;
  939. }
  940. static int quiesce_qp(struct iwch_qp *qhp)
  941. {
  942. spin_lock_irq(&qhp->lock);
  943. iwch_quiesce_tid(qhp->ep);
  944. qhp->flags |= QP_QUIESCED;
  945. spin_unlock_irq(&qhp->lock);
  946. return 0;
  947. }
  948. static int resume_qp(struct iwch_qp *qhp)
  949. {
  950. spin_lock_irq(&qhp->lock);
  951. iwch_resume_tid(qhp->ep);
  952. qhp->flags &= ~QP_QUIESCED;
  953. spin_unlock_irq(&qhp->lock);
  954. return 0;
  955. }
  956. int iwch_quiesce_qps(struct iwch_cq *chp)
  957. {
  958. int i;
  959. struct iwch_qp *qhp;
  960. for (i=0; i < T3_MAX_NUM_QP; i++) {
  961. qhp = get_qhp(chp->rhp, i);
  962. if (!qhp)
  963. continue;
  964. if ((qhp->attr.rcq == chp->cq.cqid) && !qp_quiesced(qhp)) {
  965. quiesce_qp(qhp);
  966. continue;
  967. }
  968. if ((qhp->attr.scq == chp->cq.cqid) && !qp_quiesced(qhp))
  969. quiesce_qp(qhp);
  970. }
  971. return 0;
  972. }
  973. int iwch_resume_qps(struct iwch_cq *chp)
  974. {
  975. int i;
  976. struct iwch_qp *qhp;
  977. for (i=0; i < T3_MAX_NUM_QP; i++) {
  978. qhp = get_qhp(chp->rhp, i);
  979. if (!qhp)
  980. continue;
  981. if ((qhp->attr.rcq == chp->cq.cqid) && qp_quiesced(qhp)) {
  982. resume_qp(qhp);
  983. continue;
  984. }
  985. if ((qhp->attr.scq == chp->cq.cqid) && qp_quiesced(qhp))
  986. resume_qp(qhp);
  987. }
  988. return 0;
  989. }