@@ -386,6 +386,22 @@ int rdma_create_qp(struct rdma_cm_id *id, struct ibv_pd *pd,
struct ibv_qp_init_attr *qp_init_attr);
/**
+ * rdma_query_qp - Query a QP.
+ * @id: RDMA identifier.
+ * @qp_init_attr: initial QP attributes.
+ * Description:
+ * Query QP init attributes.
+ * Notes:
+ * The rdma_cm_id must be bound to QP before calling this function.
+ * This function should be used to check QP capabilities.
+ * See also:
+ * rdma_create_ep, rdma_get_request, rdma_create_qp, ibv_create_qp,
+ * ibv_query_qp
+ */
+int rdma_query_qp(struct rdma_cm_id *id,
+ struct ibv_qp_init_attr *qp_init_attr);
+
+/**
* rdma_destroy_qp - Deallocate a QP.
* @id: RDMA identifier.
* Description:
@@ -1265,6 +1265,30 @@ err1:
return ret;
}
+int rdma_query_qp(struct rdma_cm_id *id,
+ struct ibv_qp_init_attr *qp_init_attr)
+{
+ struct ibv_qp_attr attr;
+ int ret;
+
+ memset(&attr, 0, sizeof attr);
+ memset(qp_init_attr, 0, sizeof *qp_init_attr);
+
+ ret = ibv_query_qp(id->qp, &attr, IBV_QP_CAP, qp_init_attr);
+ if (ret)
+ return ERR(ret);
+
+ assert(attr.cap.max_send_wr == qp_init_attr->cap.max_send_wr);
+ assert(attr.cap.max_recv_wr == qp_init_attr->cap.max_recv_wr);
+
+ assert(attr.cap.max_send_sge == qp_init_attr->cap.max_send_sge);
+ assert(attr.cap.max_recv_sge == qp_init_attr->cap.max_recv_sge);
+
+ assert(attr.cap.max_inline_data == qp_init_attr->cap.max_inline_data);
+
+ return 0;
+}
+
void rdma_destroy_qp(struct rdma_cm_id *id)
{
ibv_destroy_qp(id->qp);
@@ -8,6 +8,7 @@ RDMACM_1.0 {
rdma_resolve_addr;
rdma_resolve_route;
rdma_create_qp;
+ rdma_query_qp;
rdma_destroy_qp;
rdma_connect;
rdma_listen;
This patch adds a new function used to retrieve the QP initial parameters and capabilities. This function is especially useful to retrieve information on QP created by rdma_get_request(): its parameters and capabilities might be slightly different from those registered as part of rdma_create_ep(). Signed-off-by: Yann Droneaud <ydroneaud@opteya.com> --- include/rdma/rdma_cma.h | 16 ++++++++++++++++ src/cma.c | 24 ++++++++++++++++++++++++ src/librdmacm.map | 1 + 3 files changed, 41 insertions(+)