Lines Matching refs:qp

195 static int is_sqp(struct mthca_dev *dev, struct mthca_qp *qp)  in is_sqp()  argument
197 return qp->qpn >= dev->qp_table.sqp_start && in is_sqp()
198 qp->qpn <= dev->qp_table.sqp_start + 3; in is_sqp()
201 static int is_qp0(struct mthca_dev *dev, struct mthca_qp *qp) in is_qp0() argument
203 return qp->qpn >= dev->qp_table.sqp_start && in is_qp0()
204 qp->qpn <= dev->qp_table.sqp_start + 1; in is_qp0()
207 static void *get_recv_wqe(struct mthca_qp *qp, int n) in get_recv_wqe() argument
209 if (qp->is_direct) in get_recv_wqe()
210 return qp->queue.direct.buf + (n << qp->rq.wqe_shift); in get_recv_wqe()
212 return qp->queue.page_list[(n << qp->rq.wqe_shift) >> PAGE_SHIFT].buf + in get_recv_wqe()
213 ((n << qp->rq.wqe_shift) & (PAGE_SIZE - 1)); in get_recv_wqe()
216 static void *get_send_wqe(struct mthca_qp *qp, int n) in get_send_wqe() argument
218 if (qp->is_direct) in get_send_wqe()
219 return qp->queue.direct.buf + qp->send_wqe_offset + in get_send_wqe()
220 (n << qp->sq.wqe_shift); in get_send_wqe()
222 return qp->queue.page_list[(qp->send_wqe_offset + in get_send_wqe()
223 (n << qp->sq.wqe_shift)) >> in get_send_wqe()
225 ((qp->send_wqe_offset + (n << qp->sq.wqe_shift)) & in get_send_wqe()
240 struct mthca_qp *qp; in mthca_qp_event() local
244 qp = mthca_array_get(&dev->qp_table.qp, qpn & (dev->limits.num_qps - 1)); in mthca_qp_event()
245 if (qp) in mthca_qp_event()
246 ++qp->refcount; in mthca_qp_event()
249 if (!qp) { in mthca_qp_event()
256 qp->port = qp->alt_port; in mthca_qp_event()
260 event.element.qp = &qp->ibqp; in mthca_qp_event()
261 if (qp->ibqp.event_handler) in mthca_qp_event()
262 qp->ibqp.event_handler(&event, qp->ibqp.qp_context); in mthca_qp_event()
265 if (!--qp->refcount) in mthca_qp_event()
266 wake_up(&qp->wait); in mthca_qp_event()
327 static __be32 get_hw_access_flags(struct mthca_qp *qp, const struct ib_qp_attr *attr, in get_hw_access_flags() argument
337 dest_rd_atomic = qp->resp_depth; in get_hw_access_flags()
342 access_flags = qp->atomic_rd_en; in get_hw_access_flags()
428 struct mthca_qp *qp = to_mqp(ibqp); in mthca_query_qp() local
435 mutex_lock(&qp->mutex); in mthca_query_qp()
437 if (qp->state == IB_QPS_RESET) { in mthca_query_qp()
448 err = mthca_QUERY_QP(dev, qp->qpn, 0, mailbox); in mthca_query_qp()
458 qp->state = to_ib_qp_state(mthca_state); in mthca_query_qp()
459 qp_attr->qp_state = qp->state; in mthca_query_qp()
470 if (qp->transport == RC || qp->transport == UC) { in mthca_query_qp()
498 qp_attr->cap.max_send_wr = qp->sq.max; in mthca_query_qp()
499 qp_attr->cap.max_recv_wr = qp->rq.max; in mthca_query_qp()
500 qp_attr->cap.max_send_sge = qp->sq.max_gs; in mthca_query_qp()
501 qp_attr->cap.max_recv_sge = qp->rq.max_gs; in mthca_query_qp()
502 qp_attr->cap.max_inline_data = qp->max_inline_data; in mthca_query_qp()
505 qp_init_attr->sq_sig_type = qp->sq_policy; in mthca_query_qp()
511 mutex_unlock(&qp->mutex); in mthca_query_qp()
548 struct mthca_qp *qp = to_mqp(ibqp); in __mthca_modify_qp() local
565 (to_mthca_st(qp->transport) << 16)); in __mthca_modify_qp()
586 if (qp->transport == MLX || qp->transport == UD) in __mthca_modify_qp()
598 if (qp->rq.max) in __mthca_modify_qp()
599 qp_context->rq_size_stride = ilog2(qp->rq.max) << 3; in __mthca_modify_qp()
600 qp_context->rq_size_stride |= qp->rq.wqe_shift - 4; in __mthca_modify_qp()
602 if (qp->sq.max) in __mthca_modify_qp()
603 qp_context->sq_size_stride = ilog2(qp->sq.max) << 3; in __mthca_modify_qp()
604 qp_context->sq_size_stride |= qp->sq.wqe_shift - 4; in __mthca_modify_qp()
609 if (qp->ibqp.uobject) in __mthca_modify_qp()
611 cpu_to_be32(to_mucontext(qp->ibqp.uobject->context)->uar.index); in __mthca_modify_qp()
614 qp_context->local_qpn = cpu_to_be32(qp->qpn); in __mthca_modify_qp()
619 if (qp->transport == MLX) in __mthca_modify_qp()
621 cpu_to_be32(qp->port << 24); in __mthca_modify_qp()
645 attr_mask & IB_QP_PORT ? attr->port_num : qp->port)) in __mthca_modify_qp()
695 qp_context->wqe_lkey = cpu_to_be32(qp->mr.ibmr.lkey); in __mthca_modify_qp()
699 if (qp->sq_policy == IB_SIGNAL_ALL_WR) in __mthca_modify_qp()
722 qp_context->snd_wqe_base_l = cpu_to_be32(qp->send_wqe_offset); in __mthca_modify_qp()
723 qp_context->snd_db_index = cpu_to_be32(qp->sq.db_index); in __mthca_modify_qp()
735 qp_context->params2 |= get_hw_access_flags(qp, attr, attr_mask); in __mthca_modify_qp()
755 ((qp->qpn & (dev->limits.num_qps - 1)) * MTHCA_RDB_ENTRY_SIZE << in __mthca_modify_qp()
761 qp_context->rcv_db_index = cpu_to_be32(qp->rq.db_index); in __mthca_modify_qp()
777 err = mthca_MODIFY_QP(dev, cur_state, new_state, qp->qpn, 0, in __mthca_modify_qp()
785 qp->state = new_state; in __mthca_modify_qp()
787 qp->atomic_rd_en = attr->qp_access_flags; in __mthca_modify_qp()
789 qp->resp_depth = attr->max_dest_rd_atomic; in __mthca_modify_qp()
791 qp->port = attr->port_num; in __mthca_modify_qp()
793 qp->alt_port = attr->alt_port_num; in __mthca_modify_qp()
795 if (is_sqp(dev, qp)) in __mthca_modify_qp()
796 store_attrs(to_msqp(qp), attr, attr_mask); in __mthca_modify_qp()
802 if (is_qp0(dev, qp)) { in __mthca_modify_qp()
805 init_port(dev, qp->port); in __mthca_modify_qp()
811 mthca_CLOSE_IB(dev, qp->port); in __mthca_modify_qp()
818 if (new_state == IB_QPS_RESET && !qp->ibqp.uobject) { in __mthca_modify_qp()
819 mthca_cq_clean(dev, to_mcq(qp->ibqp.recv_cq), qp->qpn, in __mthca_modify_qp()
820 qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); in __mthca_modify_qp()
821 if (qp->ibqp.send_cq != qp->ibqp.recv_cq) in __mthca_modify_qp()
822 mthca_cq_clean(dev, to_mcq(qp->ibqp.send_cq), qp->qpn, NULL); in __mthca_modify_qp()
824 mthca_wq_reset(&qp->sq); in __mthca_modify_qp()
825 qp->sq.last = get_send_wqe(qp, qp->sq.max - 1); in __mthca_modify_qp()
827 mthca_wq_reset(&qp->rq); in __mthca_modify_qp()
828 qp->rq.last = get_recv_wqe(qp, qp->rq.max - 1); in __mthca_modify_qp()
831 *qp->sq.db = 0; in __mthca_modify_qp()
832 *qp->rq.db = 0; in __mthca_modify_qp()
846 struct mthca_qp *qp = to_mqp(ibqp); in mthca_modify_qp() local
850 mutex_lock(&qp->mutex); in mthca_modify_qp()
854 spin_lock_irq(&qp->sq.lock); in mthca_modify_qp()
855 spin_lock(&qp->rq.lock); in mthca_modify_qp()
856 cur_state = qp->state; in mthca_modify_qp()
857 spin_unlock(&qp->rq.lock); in mthca_modify_qp()
858 spin_unlock_irq(&qp->sq.lock); in mthca_modify_qp()
867 qp->transport, cur_state, new_state, in mthca_modify_qp()
907 mutex_unlock(&qp->mutex); in mthca_modify_qp()
911 static int mthca_max_data_size(struct mthca_dev *dev, struct mthca_qp *qp, int desc_sz) in mthca_max_data_size() argument
919 switch (qp->transport) { in mthca_max_data_size()
947 struct mthca_qp *qp) in mthca_adjust_qp_caps() argument
949 int max_data_size = mthca_max_data_size(dev, qp, in mthca_adjust_qp_caps()
951 1 << qp->sq.wqe_shift)); in mthca_adjust_qp_caps()
953 qp->max_inline_data = mthca_max_inline_data(pd, max_data_size); in mthca_adjust_qp_caps()
955 qp->sq.max_gs = min_t(int, dev->limits.max_sg, in mthca_adjust_qp_caps()
957 qp->rq.max_gs = min_t(int, dev->limits.max_sg, in mthca_adjust_qp_caps()
958 (min(dev->limits.max_desc_sz, 1 << qp->rq.wqe_shift) - in mthca_adjust_qp_caps()
972 struct mthca_qp *qp) in mthca_alloc_wqe_buf() argument
978 qp->rq.max_gs * sizeof (struct mthca_data_seg); in mthca_alloc_wqe_buf()
983 for (qp->rq.wqe_shift = 6; 1 << qp->rq.wqe_shift < size; in mthca_alloc_wqe_buf()
984 qp->rq.wqe_shift++) in mthca_alloc_wqe_buf()
987 size = qp->sq.max_gs * sizeof (struct mthca_data_seg); in mthca_alloc_wqe_buf()
988 switch (qp->transport) { in mthca_alloc_wqe_buf()
1027 for (qp->sq.wqe_shift = 6; 1 << qp->sq.wqe_shift < size; in mthca_alloc_wqe_buf()
1028 qp->sq.wqe_shift++) in mthca_alloc_wqe_buf()
1031 qp->send_wqe_offset = ALIGN(qp->rq.max << qp->rq.wqe_shift, in mthca_alloc_wqe_buf()
1032 1 << qp->sq.wqe_shift); in mthca_alloc_wqe_buf()
1042 size = PAGE_ALIGN(qp->send_wqe_offset + in mthca_alloc_wqe_buf()
1043 (qp->sq.max << qp->sq.wqe_shift)); in mthca_alloc_wqe_buf()
1045 qp->wrid = kmalloc((qp->rq.max + qp->sq.max) * sizeof (u64), in mthca_alloc_wqe_buf()
1047 if (!qp->wrid) in mthca_alloc_wqe_buf()
1051 &qp->queue, &qp->is_direct, pd, 0, &qp->mr); in mthca_alloc_wqe_buf()
1058 kfree(qp->wrid); in mthca_alloc_wqe_buf()
1063 struct mthca_qp *qp) in mthca_free_wqe_buf() argument
1065 mthca_buf_free(dev, PAGE_ALIGN(qp->send_wqe_offset + in mthca_free_wqe_buf()
1066 (qp->sq.max << qp->sq.wqe_shift)), in mthca_free_wqe_buf()
1067 &qp->queue, qp->is_direct, &qp->mr); in mthca_free_wqe_buf()
1068 kfree(qp->wrid); in mthca_free_wqe_buf()
1072 struct mthca_qp *qp) in mthca_map_memfree() argument
1077 ret = mthca_table_get(dev, dev->qp_table.qp_table, qp->qpn); in mthca_map_memfree()
1081 ret = mthca_table_get(dev, dev->qp_table.eqp_table, qp->qpn); in mthca_map_memfree()
1086 qp->qpn << dev->qp_table.rdb_shift); in mthca_map_memfree()
1095 mthca_table_put(dev, dev->qp_table.eqp_table, qp->qpn); in mthca_map_memfree()
1098 mthca_table_put(dev, dev->qp_table.qp_table, qp->qpn); in mthca_map_memfree()
1104 struct mthca_qp *qp) in mthca_unmap_memfree() argument
1107 qp->qpn << dev->qp_table.rdb_shift); in mthca_unmap_memfree()
1108 mthca_table_put(dev, dev->qp_table.eqp_table, qp->qpn); in mthca_unmap_memfree()
1109 mthca_table_put(dev, dev->qp_table.qp_table, qp->qpn); in mthca_unmap_memfree()
1113 struct mthca_qp *qp) in mthca_alloc_memfree() argument
1116 qp->rq.db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_RQ, in mthca_alloc_memfree()
1117 qp->qpn, &qp->rq.db); in mthca_alloc_memfree()
1118 if (qp->rq.db_index < 0) in mthca_alloc_memfree()
1121 qp->sq.db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_SQ, in mthca_alloc_memfree()
1122 qp->qpn, &qp->sq.db); in mthca_alloc_memfree()
1123 if (qp->sq.db_index < 0) { in mthca_alloc_memfree()
1124 mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index); in mthca_alloc_memfree()
1133 struct mthca_qp *qp) in mthca_free_memfree() argument
1136 mthca_free_db(dev, MTHCA_DB_TYPE_SQ, qp->sq.db_index); in mthca_free_memfree()
1137 mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index); in mthca_free_memfree()
1146 struct mthca_qp *qp) in mthca_alloc_qp_common() argument
1152 qp->refcount = 1; in mthca_alloc_qp_common()
1153 init_waitqueue_head(&qp->wait); in mthca_alloc_qp_common()
1154 mutex_init(&qp->mutex); in mthca_alloc_qp_common()
1155 qp->state = IB_QPS_RESET; in mthca_alloc_qp_common()
1156 qp->atomic_rd_en = 0; in mthca_alloc_qp_common()
1157 qp->resp_depth = 0; in mthca_alloc_qp_common()
1158 qp->sq_policy = send_policy; in mthca_alloc_qp_common()
1159 mthca_wq_reset(&qp->sq); in mthca_alloc_qp_common()
1160 mthca_wq_reset(&qp->rq); in mthca_alloc_qp_common()
1162 spin_lock_init(&qp->sq.lock); in mthca_alloc_qp_common()
1163 spin_lock_init(&qp->rq.lock); in mthca_alloc_qp_common()
1165 ret = mthca_map_memfree(dev, qp); in mthca_alloc_qp_common()
1169 ret = mthca_alloc_wqe_buf(dev, pd, qp); in mthca_alloc_qp_common()
1171 mthca_unmap_memfree(dev, qp); in mthca_alloc_qp_common()
1175 mthca_adjust_qp_caps(dev, pd, qp); in mthca_alloc_qp_common()
1185 ret = mthca_alloc_memfree(dev, qp); in mthca_alloc_qp_common()
1187 mthca_free_wqe_buf(dev, qp); in mthca_alloc_qp_common()
1188 mthca_unmap_memfree(dev, qp); in mthca_alloc_qp_common()
1195 qp->rq.max_gs * sizeof (struct mthca_data_seg)) / 16; in mthca_alloc_qp_common()
1197 for (i = 0; i < qp->rq.max; ++i) { in mthca_alloc_qp_common()
1198 next = get_recv_wqe(qp, i); in mthca_alloc_qp_common()
1199 next->nda_op = cpu_to_be32(((i + 1) & (qp->rq.max - 1)) << in mthca_alloc_qp_common()
1200 qp->rq.wqe_shift); in mthca_alloc_qp_common()
1204 (void *) scatter < (void *) next + (1 << qp->rq.wqe_shift); in mthca_alloc_qp_common()
1209 for (i = 0; i < qp->sq.max; ++i) { in mthca_alloc_qp_common()
1210 next = get_send_wqe(qp, i); in mthca_alloc_qp_common()
1211 next->nda_op = cpu_to_be32((((i + 1) & (qp->sq.max - 1)) << in mthca_alloc_qp_common()
1212 qp->sq.wqe_shift) + in mthca_alloc_qp_common()
1213 qp->send_wqe_offset); in mthca_alloc_qp_common()
1216 for (i = 0; i < qp->rq.max; ++i) { in mthca_alloc_qp_common()
1217 next = get_recv_wqe(qp, i); in mthca_alloc_qp_common()
1218 next->nda_op = htonl((((i + 1) % qp->rq.max) << in mthca_alloc_qp_common()
1219 qp->rq.wqe_shift) | 1); in mthca_alloc_qp_common()
1224 qp->sq.last = get_send_wqe(qp, qp->sq.max - 1); in mthca_alloc_qp_common()
1225 qp->rq.last = get_recv_wqe(qp, qp->rq.max - 1); in mthca_alloc_qp_common()
1231 struct mthca_pd *pd, struct mthca_qp *qp) in mthca_set_qp_size() argument
1233 int max_data_size = mthca_max_data_size(dev, qp, dev->limits.max_desc_sz); in mthca_set_qp_size()
1247 if (qp->transport == MLX && cap->max_send_sge + 2 > dev->limits.max_sg) in mthca_set_qp_size()
1251 qp->rq.max = cap->max_recv_wr ? in mthca_set_qp_size()
1253 qp->sq.max = cap->max_send_wr ? in mthca_set_qp_size()
1256 qp->rq.max = cap->max_recv_wr; in mthca_set_qp_size()
1257 qp->sq.max = cap->max_send_wr; in mthca_set_qp_size()
1260 qp->rq.max_gs = cap->max_recv_sge; in mthca_set_qp_size()
1261 qp->sq.max_gs = max_t(int, cap->max_send_sge, in mthca_set_qp_size()
1276 struct mthca_qp *qp) in mthca_alloc_qp() argument
1281 case IB_QPT_RC: qp->transport = RC; break; in mthca_alloc_qp()
1282 case IB_QPT_UC: qp->transport = UC; break; in mthca_alloc_qp()
1283 case IB_QPT_UD: qp->transport = UD; break; in mthca_alloc_qp()
1287 err = mthca_set_qp_size(dev, cap, pd, qp); in mthca_alloc_qp()
1291 qp->qpn = mthca_alloc(&dev->qp_table.alloc); in mthca_alloc_qp()
1292 if (qp->qpn == -1) in mthca_alloc_qp()
1296 qp->port = 0; in mthca_alloc_qp()
1299 send_policy, qp); in mthca_alloc_qp()
1301 mthca_free(&dev->qp_table.alloc, qp->qpn); in mthca_alloc_qp()
1306 mthca_array_set(&dev->qp_table.qp, in mthca_alloc_qp()
1307 qp->qpn & (dev->limits.num_qps - 1), qp); in mthca_alloc_qp()
1356 sqp->qp.transport = MLX; in mthca_alloc_sqp()
1357 err = mthca_set_qp_size(dev, cap, pd, &sqp->qp); in mthca_alloc_sqp()
1361 sqp->header_buf_size = sqp->qp.sq.max * MTHCA_UD_HEADER_SIZE; in mthca_alloc_sqp()
1368 if (mthca_array_get(&dev->qp_table.qp, mqpn)) in mthca_alloc_sqp()
1371 mthca_array_set(&dev->qp_table.qp, mqpn, sqp); in mthca_alloc_sqp()
1377 sqp->qp.port = port; in mthca_alloc_sqp()
1378 sqp->qp.qpn = mqpn; in mthca_alloc_sqp()
1379 sqp->qp.transport = MLX; in mthca_alloc_sqp()
1382 send_policy, &sqp->qp); in mthca_alloc_sqp()
1398 mthca_array_clear(&dev->qp_table.qp, mqpn); in mthca_alloc_sqp()
1410 static inline int get_qp_refcount(struct mthca_dev *dev, struct mthca_qp *qp) in get_qp_refcount() argument
1415 c = qp->refcount; in get_qp_refcount()
1422 struct mthca_qp *qp) in mthca_free_qp() argument
1427 send_cq = to_mcq(qp->ibqp.send_cq); in mthca_free_qp()
1428 recv_cq = to_mcq(qp->ibqp.recv_cq); in mthca_free_qp()
1437 mthca_array_clear(&dev->qp_table.qp, in mthca_free_qp()
1438 qp->qpn & (dev->limits.num_qps - 1)); in mthca_free_qp()
1439 --qp->refcount; in mthca_free_qp()
1444 wait_event(qp->wait, !get_qp_refcount(dev, qp)); in mthca_free_qp()
1446 if (qp->state != IB_QPS_RESET) in mthca_free_qp()
1447 mthca_MODIFY_QP(dev, qp->state, IB_QPS_RESET, qp->qpn, 0, in mthca_free_qp()
1455 if (!qp->ibqp.uobject) { in mthca_free_qp()
1456 mthca_cq_clean(dev, recv_cq, qp->qpn, in mthca_free_qp()
1457 qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); in mthca_free_qp()
1459 mthca_cq_clean(dev, send_cq, qp->qpn, NULL); in mthca_free_qp()
1461 mthca_free_memfree(dev, qp); in mthca_free_qp()
1462 mthca_free_wqe_buf(dev, qp); in mthca_free_qp()
1465 mthca_unmap_memfree(dev, qp); in mthca_free_qp()
1467 if (is_sqp(dev, qp)) { in mthca_free_qp()
1468 atomic_dec(&(to_mpd(qp->ibqp.pd)->sqp_count)); in mthca_free_qp()
1470 to_msqp(qp)->header_buf_size, in mthca_free_qp()
1471 to_msqp(qp)->header_buf, in mthca_free_qp()
1472 to_msqp(qp)->header_dma); in mthca_free_qp()
1474 mthca_free(&dev->qp_table.alloc, qp->qpn); in mthca_free_qp()
1495 mlx->flags |= cpu_to_be32((!sqp->qp.ibqp.qp_num ? MTHCA_MLX_VL15 : 0) | in build_mlx_header()
1516 sqp->ud_header.lrh.virtual_lane = !sqp->qp.ibqp.qp_num ? 15 : 0; in build_mlx_header()
1520 if (!sqp->qp.ibqp.qp_num) in build_mlx_header()
1521 ib_get_cached_pkey(&dev->ib_dev, sqp->qp.port, in build_mlx_header()
1524 ib_get_cached_pkey(&dev->ib_dev, sqp->qp.port, in build_mlx_header()
1531 sqp->ud_header.deth.source_qpn = cpu_to_be32(sqp->qp.ibqp.qp_num); in build_mlx_header()
1538 data->lkey = cpu_to_be32(to_mpd(sqp->qp.ibqp.pd)->ntmr.ibmr.lkey); in build_mlx_header()
1606 struct mthca_qp *qp = to_mqp(ibqp); in mthca_tavor_post_send() local
1626 spin_lock_irqsave(&qp->sq.lock, flags); in mthca_tavor_post_send()
1630 ind = qp->sq.next_ind; in mthca_tavor_post_send()
1633 if (mthca_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)) { in mthca_tavor_post_send()
1635 " %d max, %d nreq)\n", qp->qpn, in mthca_tavor_post_send()
1636 qp->sq.head, qp->sq.tail, in mthca_tavor_post_send()
1637 qp->sq.max, nreq); in mthca_tavor_post_send()
1643 wqe = get_send_wqe(qp, ind); in mthca_tavor_post_send()
1644 prev_wqe = qp->sq.last; in mthca_tavor_post_send()
1645 qp->sq.last = wqe; in mthca_tavor_post_send()
1662 switch (qp->transport) { in mthca_tavor_post_send()
1717 err = build_mlx_header(dev, to_msqp(qp), ind, ud_wr(wr), in mthca_tavor_post_send()
1729 if (wr->num_sge > qp->sq.max_gs) { in mthca_tavor_post_send()
1743 if (qp->transport == MLX) { in mthca_tavor_post_send()
1751 qp->wrid[ind + qp->rq.max] = wr->wr_id; in mthca_tavor_post_send()
1761 cpu_to_be32(((ind << qp->sq.wqe_shift) + in mthca_tavor_post_send()
1762 qp->send_wqe_offset) | in mthca_tavor_post_send()
1778 if (unlikely(ind >= qp->sq.max)) in mthca_tavor_post_send()
1779 ind -= qp->sq.max; in mthca_tavor_post_send()
1786 mthca_write64(((qp->sq.next_ind << qp->sq.wqe_shift) + in mthca_tavor_post_send()
1787 qp->send_wqe_offset) | f0 | op0, in mthca_tavor_post_send()
1788 (qp->qpn << 8) | size0, in mthca_tavor_post_send()
1798 qp->sq.next_ind = ind; in mthca_tavor_post_send()
1799 qp->sq.head += nreq; in mthca_tavor_post_send()
1801 spin_unlock_irqrestore(&qp->sq.lock, flags); in mthca_tavor_post_send()
1809 struct mthca_qp *qp = to_mqp(ibqp); in mthca_tavor_post_receive() local
1827 spin_lock_irqsave(&qp->rq.lock, flags); in mthca_tavor_post_receive()
1831 ind = qp->rq.next_ind; in mthca_tavor_post_receive()
1834 if (mthca_wq_overflow(&qp->rq, nreq, qp->ibqp.recv_cq)) { in mthca_tavor_post_receive()
1836 " %d max, %d nreq)\n", qp->qpn, in mthca_tavor_post_receive()
1837 qp->rq.head, qp->rq.tail, in mthca_tavor_post_receive()
1838 qp->rq.max, nreq); in mthca_tavor_post_receive()
1844 wqe = get_recv_wqe(qp, ind); in mthca_tavor_post_receive()
1845 prev_wqe = qp->rq.last; in mthca_tavor_post_receive()
1846 qp->rq.last = wqe; in mthca_tavor_post_receive()
1855 if (unlikely(wr->num_sge > qp->rq.max_gs)) { in mthca_tavor_post_receive()
1867 qp->wrid[ind] = wr->wr_id; in mthca_tavor_post_receive()
1876 if (unlikely(ind >= qp->rq.max)) in mthca_tavor_post_receive()
1877 ind -= qp->rq.max; in mthca_tavor_post_receive()
1885 mthca_write64((qp->rq.next_ind << qp->rq.wqe_shift) | size0, in mthca_tavor_post_receive()
1886 qp->qpn << 8, dev->kar + MTHCA_RECEIVE_DOORBELL, in mthca_tavor_post_receive()
1889 qp->rq.next_ind = ind; in mthca_tavor_post_receive()
1890 qp->rq.head += MTHCA_TAVOR_MAX_WQES_PER_RECV_DB; in mthca_tavor_post_receive()
1898 mthca_write64((qp->rq.next_ind << qp->rq.wqe_shift) | size0, in mthca_tavor_post_receive()
1899 qp->qpn << 8 | nreq, dev->kar + MTHCA_RECEIVE_DOORBELL, in mthca_tavor_post_receive()
1903 qp->rq.next_ind = ind; in mthca_tavor_post_receive()
1904 qp->rq.head += nreq; in mthca_tavor_post_receive()
1912 spin_unlock_irqrestore(&qp->rq.lock, flags); in mthca_tavor_post_receive()
1920 struct mthca_qp *qp = to_mqp(ibqp); in mthca_arbel_post_send() local
1941 spin_lock_irqsave(&qp->sq.lock, flags); in mthca_arbel_post_send()
1945 ind = qp->sq.head & (qp->sq.max - 1); in mthca_arbel_post_send()
1952 ((qp->sq.head & 0xffff) << 8) | f0 | op0; in mthca_arbel_post_send()
1954 qp->sq.head += MTHCA_ARBEL_MAX_WQES_PER_SEND_DB; in mthca_arbel_post_send()
1961 *qp->sq.db = cpu_to_be32(qp->sq.head & 0xffff); in mthca_arbel_post_send()
1969 mthca_write64(dbhi, (qp->qpn << 8) | size0, in mthca_arbel_post_send()
1974 if (mthca_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)) { in mthca_arbel_post_send()
1976 " %d max, %d nreq)\n", qp->qpn, in mthca_arbel_post_send()
1977 qp->sq.head, qp->sq.tail, in mthca_arbel_post_send()
1978 qp->sq.max, nreq); in mthca_arbel_post_send()
1984 wqe = get_send_wqe(qp, ind); in mthca_arbel_post_send()
1985 prev_wqe = qp->sq.last; in mthca_arbel_post_send()
1986 qp->sq.last = wqe; in mthca_arbel_post_send()
2003 switch (qp->transport) { in mthca_arbel_post_send()
2058 err = build_mlx_header(dev, to_msqp(qp), ind, ud_wr(wr), in mthca_arbel_post_send()
2070 if (wr->num_sge > qp->sq.max_gs) { in mthca_arbel_post_send()
2084 if (qp->transport == MLX) { in mthca_arbel_post_send()
2092 qp->wrid[ind + qp->rq.max] = wr->wr_id; in mthca_arbel_post_send()
2102 cpu_to_be32(((ind << qp->sq.wqe_shift) + in mthca_arbel_post_send()
2103 qp->send_wqe_offset) | in mthca_arbel_post_send()
2119 if (unlikely(ind >= qp->sq.max)) in mthca_arbel_post_send()
2120 ind -= qp->sq.max; in mthca_arbel_post_send()
2125 dbhi = (nreq << 24) | ((qp->sq.head & 0xffff) << 8) | f0 | op0; in mthca_arbel_post_send()
2127 qp->sq.head += nreq; in mthca_arbel_post_send()
2134 *qp->sq.db = cpu_to_be32(qp->sq.head & 0xffff); in mthca_arbel_post_send()
2142 mthca_write64(dbhi, (qp->qpn << 8) | size0, dev->kar + MTHCA_SEND_DOORBELL, in mthca_arbel_post_send()
2152 spin_unlock_irqrestore(&qp->sq.lock, flags); in mthca_arbel_post_send()
2160 struct mthca_qp *qp = to_mqp(ibqp); in mthca_arbel_post_receive() local
2168 spin_lock_irqsave(&qp->rq.lock, flags); in mthca_arbel_post_receive()
2172 ind = qp->rq.head & (qp->rq.max - 1); in mthca_arbel_post_receive()
2175 if (mthca_wq_overflow(&qp->rq, nreq, qp->ibqp.recv_cq)) { in mthca_arbel_post_receive()
2177 " %d max, %d nreq)\n", qp->qpn, in mthca_arbel_post_receive()
2178 qp->rq.head, qp->rq.tail, in mthca_arbel_post_receive()
2179 qp->rq.max, nreq); in mthca_arbel_post_receive()
2185 wqe = get_recv_wqe(qp, ind); in mthca_arbel_post_receive()
2191 if (unlikely(wr->num_sge > qp->rq.max_gs)) { in mthca_arbel_post_receive()
2202 if (i < qp->rq.max_gs) in mthca_arbel_post_receive()
2205 qp->wrid[ind] = wr->wr_id; in mthca_arbel_post_receive()
2208 if (unlikely(ind >= qp->rq.max)) in mthca_arbel_post_receive()
2209 ind -= qp->rq.max; in mthca_arbel_post_receive()
2213 qp->rq.head += nreq; in mthca_arbel_post_receive()
2220 *qp->rq.db = cpu_to_be32(qp->rq.head & 0xffff); in mthca_arbel_post_receive()
2223 spin_unlock_irqrestore(&qp->rq.lock, flags); in mthca_arbel_post_receive()
2227 void mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send, in mthca_free_err_wqe() argument
2236 if (qp->ibqp.srq && !is_send) { in mthca_free_err_wqe()
2242 next = get_send_wqe(qp, index); in mthca_free_err_wqe()
2244 next = get_recv_wqe(qp, index); in mthca_free_err_wqe()
2274 err = mthca_array_init(&dev->qp_table.qp, in mthca_init_qp_table()
2296 mthca_array_cleanup(&dev->qp_table.qp, dev->limits.num_qps); in mthca_init_qp_table()
2309 mthca_array_cleanup(&dev->qp_table.qp, dev->limits.num_qps); in mthca_cleanup_qp_table()