Skip to content

Commit

Permalink
librdmacm: Make rping with external qp compliant to IB spec
Browse files Browse the repository at this point in the history
[ Upstream commit 3b87263 ]

Previously rping with external qp did ibv_post_recv() while qp is still
in RESET state.

Which would cause rping to fail over an IB spec compliant driver, since
it contradicts IB spec 1.5, 10.3.1.1 RESET section, bullet C10-22: "If a
Work Request is submitted to a Work Queue while its corresponding QP is
in the Reset State, an immediate error shall be returned".

Currently simply modified the created qp to INIT state with some default
values right after the creation of the qp, this will allow the
ibv_post_recv() to succeed.

Post of the connection a second initialization is done, in order to
overwrite the default values with the real ones.

Fixes: 5f88678 ("rping: Add option to create QP independently")
Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
Reviewed-by: Mark Zhang <markzhang@nvidia.com>
Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
  • Loading branch information
PatrisiousHaddad authored and nmorey committed Mar 23, 2022
1 parent 368dec9 commit 6561dfd
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions librdmacm/examples/rping.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,17 +567,33 @@ static int rping_create_qp(struct rping_cb *cb)
init_attr.qp_type = IBV_QPT_RC;
init_attr.send_cq = cb->cq;
init_attr.recv_cq = cb->cq;
id = cb->server ? cb->child_cm_id : cb->cm_id;

if (cb->self_create_qp) {
cb->qp = ibv_create_qp(cb->pd, &init_attr);
if (!cb->qp) {
perror("ibv_create_qp");
return -1;
}
return 0;

struct ibv_qp_attr attr = {
.qp_state = IBV_QPS_INIT,
.pkey_index = 0,
.port_num = id->port_num,
.qp_access_flags = 0,
};

ret = ibv_modify_qp(cb->qp, &attr,
IBV_QP_STATE | IBV_QP_PKEY_INDEX |
IBV_QP_PORT | IBV_QP_ACCESS_FLAGS);

if (ret) {
perror("ibv_modify_qp");
ibv_destroy_qp(cb->qp);
}
return ret ? -1 : 0;
}

id = cb->server ? cb->child_cm_id : cb->cm_id;
ret = rdma_create_qp(id, cb->pd, &init_attr);
if (!ret)
cb->qp = id->qp;
Expand Down

0 comments on commit 6561dfd

Please sign in to comment.