Lines Matching refs:qp

824 			      struct mlx5_qp *qp)
842 qp->max_tso_header = attr->max_tso_header;
861 struct mlx5_qp *qp)
871 if (qp->wq_sig)
884 struct mlx5_qp *qp)
893 wqe_size = mlx5_calc_send_wqe(ctx, attr, qp);
904 qp->max_inline_data = wqe_size - sq_overhead(attr->qp_type) -
906 attr->cap.max_inline_data = qp->max_inline_data;
918 qp->sq.wqe_cnt = wq_size / MLX5_SEND_WQE_BB;
919 if (qp->sq.wqe_cnt > ctx->max_send_wqebb) {
924 qp->sq.wqe_shift = mlx5_ilog2(MLX5_SEND_WQE_BB);
925 qp->sq.max_gs = attr->cap.max_send_sge;
926 qp->sq.max_post = wq_size / wqe_size;
967 struct mlx5_qp *qp)
982 wqe_size = mlx5_calc_rcv_wqe(ctx, attr, qp);
991 qp->rq.wqe_cnt = wq_size / wqe_size;
992 qp->rq.wqe_shift = mlx5_ilog2(wqe_size);
993 qp->rq.max_post = 1 << mlx5_ilog2(wq_size / wqe_size);
995 (qp->wq_sig ? sizeof(struct mlx5_rwqe_sig) : 0);
996 qp->rq.max_gs = scat_spc / sizeof(struct mlx5_wqe_data_seg);
998 qp->rq.wqe_cnt = 0;
999 qp->rq.wqe_shift = 0;
1000 qp->rq.max_post = 0;
1001 qp->rq.max_gs = 0;
1008 struct mlx5_qp *qp)
1013 ret = mlx5_calc_sq_size(ctx, attr, qp);
1018 ret = mlx5_calc_rq_size(ctx, attr, qp);
1024 qp->sq.offset = ret;
1025 qp->rq.offset = 0;
1030 static void map_uuar(struct ibv_context *context, struct mlx5_qp *qp,
1035 qp->bf = &ctx->bfs[uuar_index];
1051 struct mlx5_qp *qp,
1059 if (qp->sq.wqe_cnt) {
1060 qp->sq.wrid = malloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wrid));
1061 if (!qp->sq.wrid) {
1067 qp->sq.wr_data = malloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wr_data));
1068 if (!qp->sq.wr_data) {
1075 qp->sq.wqe_head = malloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head));
1076 if (!qp->sq.wqe_head) {
1082 if (qp->rq.wqe_cnt) {
1083 qp->rq.wrid = malloc(qp->rq.wqe_cnt * sizeof(uint64_t));
1084 if (!qp->rq.wrid) {
1092 qp_huge_key = qptype2key(qp->ibv_qp->qp_type);
1099 err = mlx5_alloc_prefered_buf(to_mctx(context), &qp->buf,
1100 align(qp->buf_size, to_mdev
1111 memset(qp->buf.buf, 0, qp->buf_size);
1114 size_t aligned_sq_buf_size = align(qp->sq_buf_size,
1117 err = mlx5_alloc_prefered_buf(to_mctx(context), &qp->sq_buf,
1127 memset(qp->sq_buf.buf, 0, aligned_sq_buf_size);
1132 mlx5_free_actual_buf(to_mctx(qp->verbs_qp.qp.context), &qp->buf);
1134 if (qp->rq.wrid)
1135 free(qp->rq.wrid);
1137 if (qp->sq.wqe_head)
1138 free(qp->sq.wqe_head);
1140 if (qp->sq.wr_data)
1141 free(qp->sq.wr_data);
1142 if (qp->sq.wrid)
1143 free(qp->sq.wrid);
1148 static void mlx5_free_qp_buf(struct mlx5_qp *qp)
1150 struct mlx5_context *ctx = to_mctx(qp->ibv_qp->context);
1152 mlx5_free_actual_buf(ctx, &qp->buf);
1154 if (qp->sq_buf.buf)
1155 mlx5_free_actual_buf(ctx, &qp->sq_buf);
1157 if (qp->rq.wrid)
1158 free(qp->rq.wrid);
1160 if (qp->sq.wqe_head)
1161 free(qp->sq.wqe_head);
1163 if (qp->sq.wrid)
1164 free(qp->sq.wrid);
1166 if (qp->sq.wr_data)
1167 free(qp->sq.wr_data);
1172 struct mlx5_qp *qp)
1189 ret = ibv_cmd_create_qp_ex2(context, &qp->verbs_qp,
1190 sizeof(qp->verbs_qp), attr,
1197 qp->rss_qp = 1;
1204 struct mlx5_qp *qp,
1220 ret = ibv_cmd_create_qp_ex2(context, &qp->verbs_qp,
1221 sizeof(qp->verbs_qp), attr,
1251 struct mlx5_qp *qp;
1266 qp = calloc(1, sizeof(*qp));
1267 if (!qp) {
1271 ibqp = (struct ibv_qp *)&qp->verbs_qp;
1272 qp->ibv_qp = ibqp;
1279 ret = mlx5_cmd_create_rss_qp(context, attr, qp);
1286 qp->wq_sig = qp_sig_enabled();
1287 if (qp->wq_sig)
1293 ret = mlx5_calc_wq_size(ctx, attr, qp);
1300 qp->buf_size = qp->sq.offset;
1301 qp->sq_buf_size = ret - qp->buf_size;
1302 qp->sq.offset = 0;
1304 qp->buf_size = ret;
1305 qp->sq_buf_size = 0;
1308 if (mlx5_alloc_qp_buf(context, attr, qp, ret)) {
1314 qp->sq_start = qp->sq_buf.buf;
1315 qp->sq.qend = qp->sq_buf.buf +
1316 (qp->sq.wqe_cnt << qp->sq.wqe_shift);
1318 qp->sq_start = qp->buf.buf + qp->sq.offset;
1319 qp->sq.qend = qp->buf.buf + qp->sq.offset +
1320 (qp->sq.wqe_cnt << qp->sq.wqe_shift);
1323 mlx5_init_qp_indices(qp);
1325 if (mlx5_spinlock_init(&qp->sq.lock))
1328 if (mlx5_spinlock_init(&qp->rq.lock))
1331 qp->db = mlx5_alloc_dbrec(ctx);
1332 if (!qp->db) {
1337 qp->db[MLX5_RCV_DBR] = 0;
1338 qp->db[MLX5_SND_DBR] = 0;
1340 cmd.buf_addr = (uintptr_t) qp->buf.buf;
1342 (uintptr_t) qp->sq_buf.buf : 0;
1343 cmd.db_addr = (uintptr_t) qp->db;
1344 cmd.sq_wqe_count = qp->sq.wqe_cnt;
1345 cmd.rq_wqe_count = qp->rq.wqe_cnt;
1346 cmd.rq_wqe_shift = qp->rq.wqe_shift;
1349 qp->atomics_enabled = 1;
1355 usr_idx = mlx5_store_uidx(ctx, qp);
1365 ret = mlx5_cmd_create_qp_ex(context, attr, &cmd, qp, &resp_ex);
1367 ret = ibv_cmd_create_qp_ex(context, &qp->verbs_qp, sizeof(qp->verbs_qp),
1378 if (qp->sq.wqe_cnt || qp->rq.wqe_cnt) {
1379 ret = mlx5_store_qp(ctx, ibqp->qp_num, qp);
1389 map_uuar(context, qp, uuar_index);
1391 qp->rq.max_post = qp->rq.wqe_cnt;
1393 qp->sq_signal_bits = MLX5_WQE_CTRL_CQ_UPDATE;
1395 qp->sq_signal_bits = 0;
1397 attr->cap.max_send_wr = qp->sq.max_post;
1398 attr->cap.max_recv_wr = qp->rq.max_post;
1399 attr->cap.max_recv_sge = qp->rq.max_gs;
1401 qp->rsc.type = MLX5_RSC_TYPE_QP;
1402 qp->rsc.rsn = (ctx->cqe_version && !is_xrc_tgt(attr->qp_type)) ?
1417 mlx5_free_db(to_mctx(context), qp->db);
1420 mlx5_spinlock_destroy(&qp->rq.lock);
1423 mlx5_spinlock_destroy(&qp->sq.lock);
1426 mlx5_free_qp_buf(qp);
1429 free(qp);
1437 struct ibv_qp *qp;
1444 qp = create_qp(pd->context, &attrx);
1445 if (qp)
1448 return qp;
1451 static void mlx5_lock_cqs(struct ibv_qp *qp)
1453 struct mlx5_cq *send_cq = to_mcq(qp->send_cq);
1454 struct mlx5_cq *recv_cq = to_mcq(qp->recv_cq);
1473 static void mlx5_unlock_cqs(struct ibv_qp *qp)
1475 struct mlx5_cq *send_cq = to_mcq(qp->send_cq);
1476 struct mlx5_cq *recv_cq = to_mcq(qp->recv_cq);
1497 struct mlx5_qp *qp = to_mqp(ibqp);
1501 if (qp->rss_qp) {
1520 __mlx5_cq_clean(to_mcq(ibqp->recv_cq), qp->rsc.rsn,
1523 __mlx5_cq_clean(to_mcq(ibqp->send_cq), qp->rsc.rsn, NULL);
1526 if (qp->sq.wqe_cnt || qp->rq.wqe_cnt)
1534 mlx5_clear_uidx(ctx, qp->rsc.rsn);
1536 mlx5_free_db(ctx, qp->db);
1537 mlx5_spinlock_destroy(&qp->rq.lock);
1538 mlx5_spinlock_destroy(&qp->sq.lock);
1539 mlx5_free_qp_buf(qp);
1541 free(qp);
1550 struct mlx5_qp *qp = to_mqp(ibqp);
1553 if (qp->rss_qp)
1560 init_attr->cap.max_send_wr = qp->sq.max_post;
1561 init_attr->cap.max_send_sge = qp->sq.max_gs;
1562 init_attr->cap.max_inline_data = qp->max_inline_data;
1573 int mlx5_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
1579 struct mlx5_qp *mqp = to_mqp(qp);
1580 struct mlx5_context *context = to_mctx(qp->context);
1588 switch (qp->qp_type) {
1611 ret = ibv_cmd_modify_qp_ex(qp, attr, attr_mask,
1617 ret = ibv_cmd_modify_qp(qp, attr, attr_mask,
1623 if (qp->recv_cq) {
1624 mlx5_cq_clean(to_mcq(qp->recv_cq), mqp->rsc.rsn,
1625 qp->srq ? to_msrq(qp->srq) : NULL);
1627 if (qp->send_cq != qp->recv_cq && qp->send_cq)
1628 mlx5_cq_clean(to_mcq(qp->send_cq),
1629 to_mqp(qp)->rsc.rsn, NULL);
1648 qp->qp_type == IBV_QPT_RAW_PACKET) {
1759 int mlx5_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
1761 return ibv_cmd_attach_mcast(qp, gid, lid);
1764 int mlx5_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
1766 return ibv_cmd_detach_mcast(qp, gid, lid);