in efawin/ibv_win_cmd.c [254:317]
int ibv_cmd_create_qp_ex(struct ibv_context* context,
struct verbs_qp* qp,
struct ibv_qp_init_attr_ex* attr_ex,
struct ibv_create_qp* cmd, size_t cmd_size,
struct ib_uverbs_create_qp_resp* resp, size_t resp_size)
{
int err;
EFA_CREATE_QP_PARAMS params = { 0 };
EFA_QP_INFO result = { 0 };
struct ibv_qp* ibv_qp = NULL;
struct efa_context* ctx = to_efa_context(context);
struct efa_dev* edev = to_efa_dev(attr_ex->pd->context->device);
struct efa_qp* efa_qp = to_efa_qp(&qp->qp);
struct efa_create_qp_resp* efa_resp = container_of(resp, struct efa_create_qp_resp, ibv_resp);
params.Pdn = attr_ex->pd->handle;
params.QpType = (attr_ex->qp_type == IBV_QPT_UD) ? EFA_WIN_QP_UD : EFA_WIN_QP_SRD;
params.SendCqIndex = attr_ex->send_cq->handle;
params.RecvCqIndex = attr_ex->recv_cq->handle;
params.SqDepth = efa_qp->sq.wq.wqe_cnt;
params.RqDepth = efa_qp->rq.wq.wqe_cnt;
params.RqRingSizeInBytes = (efa_qp->rq.wq.desc_mask + 1) * sizeof(struct efa_io_rx_desc);;
params.SqRingSizeInBytes = (efa_qp->sq.wq.desc_mask + 1) * sizeof(struct efa_io_tx_wqe);
err = efa_win_create_qp(&edev->device, ¶ms, &result);
if (err) {
return err;
}
ibv_qp = &qp->qp;
ibv_qp->handle = result.QpHandle;
ibv_qp->qp_num = result.QpNum;
ibv_qp->context = attr_ex->pd->context;
ibv_qp->qp_context = attr_ex->qp_context;
ibv_qp->pd = attr_ex->pd;
ibv_qp->send_cq = attr_ex->send_cq;
ibv_qp->recv_cq = attr_ex->recv_cq;
ibv_qp->qp_type = params.QpType;
ibv_qp->state = IBV_QPS_RESET;
ibv_qp->events_completed = 0;
pthread_cond_init(&ibv_qp->cond, 0);
pthread_mutex_init(&ibv_qp->mutex, 0);
efa_qp->page_size = PAGE_SIZE;
efa_qp->rq.buf_size = params.RqRingSizeInBytes;
efa_qp->rq.buf = result.RqAddr;
efa_qp->rq.wq.db = result.RqDoorbellAddr;
efa_qp->rq.wq.sub_cq_idx = result.RecvSubCqIndex;
efa_qp->sq.desc_ring_mmap_size = params.SqRingSizeInBytes;
efa_qp->sq.desc = result.SqAddr;
efa_qp->sq.wq.db = result.SqDoorbellAddr;
efa_qp->sq.wq.sub_cq_idx = result.SendSubCqIndex;
resp->qpn = result.QpNum;
resp->max_inline_data = attr_ex->cap.max_inline_data;
resp->max_recv_sge = attr_ex->cap.max_recv_sge;
resp->max_send_sge = attr_ex->cap.max_send_sge;
resp->max_recv_wr = attr_ex->cap.max_recv_wr;
resp->max_send_wr = attr_ex->cap.max_send_wr;
efa_resp->rq_mmap_size = efa_qp->rq.buf_size;
efa_resp->recv_sub_cq_idx = result.RecvSubCqIndex;
efa_resp->send_sub_cq_idx = result.SendSubCqIndex;
return 0;
}