[openib-general] 2/2 libibverbs + libmthca changes for query QP
Dotan Barak
dotanb at mellanox.co.il
Thu Feb 9 07:50:55 PST 2006
note: this implementation don't know how to handle the masks.
libibverbs and libmthca changes to handle quering QPs. Essentially just adding
API and support for passing the call through to provider plug-ins.
Signed-off-by: Dotan Barak <dotanb at mellanox.co.il>
Index: openib_gen2/src/userspace/libibverbs/include/infiniband/driver.h
===================================================================
--- openib_gen2.orig/src/userspace/libibverbs/include/infiniband/driver.h 2006-02-07 17:00:24.000000000 +0200
+++ openib_gen2/src/userspace/libibverbs/include/infiniband/driver.h 2006-02-08 15:54:22.000000000 +0200
@@ -115,6 +115,9 @@ int ibv_cmd_create_qp(struct ibv_pd *pd,
int ibv_cmd_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
enum ibv_qp_attr_mask attr_mask,
struct ibv_modify_qp *cmd, size_t cmd_size);
+int ibv_cmd_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *qp_attr,
+ int qp_attr_mask, struct ibv_qp_init_attr *qp_init_attr,
+ struct ibv_query_qp *cmd, size_t cmd_size);
int ibv_cmd_destroy_qp(struct ibv_qp *qp);
int ibv_cmd_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
struct ibv_send_wr **bad_wr);
Index: openib_gen2/src/userspace/libibverbs/include/infiniband/kern-abi.h
===================================================================
--- openib_gen2.orig/src/userspace/libibverbs/include/infiniband/kern-abi.h 2006-02-07 17:00:24.000000000 +0200
+++ openib_gen2/src/userspace/libibverbs/include/infiniband/kern-abi.h 2006-02-08 15:54:22.000000000 +0200
@@ -509,6 +509,50 @@ struct ibv_modify_qp {
__u64 driver_data[0];
};
+struct ibv_query_qp {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u32 qp_handle;
+ __u32 attr_mask;
+ __u64 driver_data[0];
+};
+
+struct ibv_query_qp_resp {
+ struct ibv_qp_dest dest;
+ struct ibv_qp_dest alt_dest;
+ __u32 max_send_wr;
+ __u32 max_recv_wr;
+ __u32 max_send_sge;
+ __u32 max_recv_sge;
+ __u32 max_inline_data;
+ __u32 qkey;
+ __u32 rq_psn;
+ __u32 sq_psn;
+ __u32 dest_qp_num;
+ __u32 qp_access_flags;
+ __u16 pkey_index;
+ __u16 alt_pkey_index;
+ __u8 qp_state;
+ __u8 cur_qp_state;
+ __u8 path_mtu;
+ __u8 path_mig_state;
+ __u8 en_sqd_async_notify;
+ __u8 max_rd_atomic;
+ __u8 max_dest_rd_atomic;
+ __u8 min_rnr_timer;
+ __u8 port_num;
+ __u8 timeout;
+ __u8 retry_cnt;
+ __u8 rnr_retry;
+ __u8 alt_port_num;
+ __u8 alt_timeout;
+ __u8 sq_sig_all;
+ __u8 reserved[5];
+ __u64 driver_data[0];
+};
+
struct ibv_destroy_qp {
__u32 command;
__u16 in_words;
Index: openib_gen2/src/userspace/libibverbs/include/infiniband/verbs.h
===================================================================
--- openib_gen2.orig/src/userspace/libibverbs/include/infiniband/verbs.h 2006-02-07 17:00:24.000000000 +0200
+++ openib_gen2/src/userspace/libibverbs/include/infiniband/verbs.h 2006-02-08 15:54:22.000000000 +0200
@@ -563,6 +563,10 @@ struct ibv_context_ops {
struct ibv_qp * (*create_qp)(struct ibv_pd *pd, struct ibv_qp_init_attr *attr);
int (*modify_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
enum ibv_qp_attr_mask attr_mask);
+ int (*query_qp)(struct ibv_qp *qp,
+ struct ibv_qp_attr *qp_attr,
+ int qp_attr_mask,
+ struct ibv_qp_init_attr *qp_init_attr);
int (*destroy_qp)(struct ibv_qp *qp);
int (*post_send)(struct ibv_qp *qp, struct ibv_send_wr *wr,
struct ibv_send_wr **bad_wr);
@@ -847,6 +851,20 @@ int ibv_modify_qp(struct ibv_qp *qp, str
enum ibv_qp_attr_mask attr_mask);
/**
+ * ibv_query_qp - Returns the attribute list and current values for the
+ * specified QP.
+ * @qp: The QP to query.
+ * @qp_attr: The attributes of the specified QP.
+ * @qp_attr_mask: A bit-mask used to select specific attributes to query.
+ * @qp_init_attr: Additional attributes of the selected QP.
+ *
+ * The qp_attr_mask may be used to limit the query to gathering only the
+ * selected attributes.
+ */
+int ibv_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *qp_attr,
+ int qp_attr_mask, struct ibv_qp_init_attr *qp_init_attr);
+
+/**
* ibv_destroy_qp - Destroy a queue pair.
*/
int ibv_destroy_qp(struct ibv_qp *qp);
Index: openib_gen2/src/userspace/libibverbs/src/cmd.c
===================================================================
--- openib_gen2.orig/src/userspace/libibverbs/src/cmd.c 2006-02-07 17:00:24.000000000 +0200
+++ openib_gen2/src/userspace/libibverbs/src/cmd.c 2006-02-08 15:58:21.000000000 +0200
@@ -629,6 +629,86 @@ int ibv_cmd_modify_qp(struct ibv_qp *qp,
return 0;
}
+int ibv_cmd_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *qp_attr,
+ int qp_attr_mask,
+ struct ibv_qp_init_attr *qp_init_attr,
+ struct ibv_query_qp *cmd, size_t cmd_size)
+{
+ struct ibv_query_qp_resp resp;
+
+ IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_QP, &resp, sizeof resp);
+ cmd->qp_handle = qp->handle;
+ cmd->attr_mask = qp_attr_mask;
+
+ if (write(qp->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ qp_attr->qkey = resp.qkey;
+ qp_attr->rq_psn = resp.rq_psn;
+ qp_attr->sq_psn = resp.sq_psn;
+ qp_attr->dest_qp_num = resp.dest_qp_num;
+ qp_attr->qp_access_flags = resp.qp_access_flags;
+ qp_attr->pkey_index = resp.pkey_index;
+ qp_attr->alt_pkey_index = resp.alt_pkey_index;
+ qp_attr->qp_state = resp.qp_state;
+ qp_attr->cur_qp_state = resp.cur_qp_state;
+ qp_attr->path_mtu = resp.path_mtu;
+ qp_attr->path_mig_state = resp.path_mig_state;
+ qp_attr->en_sqd_async_notify = resp.en_sqd_async_notify;
+ qp_attr->max_rd_atomic = resp.max_rd_atomic;
+ qp_attr->max_dest_rd_atomic = resp.max_dest_rd_atomic;
+ qp_attr->min_rnr_timer = resp.min_rnr_timer;
+ qp_attr->port_num = resp.port_num;
+ qp_attr->timeout = resp.timeout;
+ qp_attr->retry_cnt = resp.retry_cnt;
+ qp_attr->rnr_retry = resp.rnr_retry;
+ qp_attr->alt_port_num = resp.alt_port_num;
+ qp_attr->alt_timeout = resp.alt_timeout;
+ qp_attr->cap.max_send_wr = resp.max_send_wr;
+ qp_attr->cap.max_recv_wr = resp.max_recv_wr;
+ qp_attr->cap.max_send_sge = resp.max_send_sge;
+ qp_attr->cap.max_recv_sge = resp.max_recv_sge;
+ qp_attr->cap.max_inline_data = resp.max_inline_data;
+
+ memcpy(qp_attr->ah_attr.grh.dgid.raw, resp.dest.dgid, 16);
+ qp_attr->ah_attr.grh.flow_label = resp.dest.flow_label;
+ qp_attr->ah_attr.dlid = resp.dest.dlid;
+ qp_attr->ah_attr.grh.sgid_index = resp.dest.sgid_index;
+ qp_attr->ah_attr.grh.hop_limit = resp.dest.hop_limit;
+ qp_attr->ah_attr.grh.traffic_class = resp.dest.traffic_class;
+ qp_attr->ah_attr.sl = resp.dest.sl;
+ qp_attr->ah_attr.src_path_bits = resp.dest.src_path_bits;
+ qp_attr->ah_attr.static_rate = resp.dest.static_rate;
+ qp_attr->ah_attr.is_global = resp.dest.is_global;
+ qp_attr->ah_attr.port_num = resp.dest.port_num;
+
+ memcpy(qp_attr->alt_ah_attr.grh.dgid.raw, resp.alt_dest.dgid, 16);
+ qp_attr->alt_ah_attr.grh.flow_label = resp.alt_dest.flow_label;
+ qp_attr->alt_ah_attr.dlid = resp.alt_dest.dlid;
+ qp_attr->alt_ah_attr.grh.sgid_index = resp.alt_dest.sgid_index;
+ qp_attr->alt_ah_attr.grh.hop_limit = resp.alt_dest.hop_limit;
+ qp_attr->alt_ah_attr.grh.traffic_class = resp.alt_dest.traffic_class;
+ qp_attr->alt_ah_attr.sl = resp.alt_dest.sl;
+ qp_attr->alt_ah_attr.src_path_bits = resp.alt_dest.src_path_bits;
+ qp_attr->alt_ah_attr.static_rate = resp.alt_dest.static_rate;
+ qp_attr->alt_ah_attr.is_global = resp.alt_dest.is_global;
+ qp_attr->alt_ah_attr.port_num = resp.alt_dest.port_num;
+
+ qp_init_attr->qp_context = qp->qp_context;
+ qp_init_attr->send_cq = qp->send_cq;
+ qp_init_attr->recv_cq = qp->recv_cq;
+ qp_init_attr->srq = qp->srq;
+ qp_init_attr->qp_type = qp->qp_type;
+ qp_init_attr->cap.max_send_wr = resp.max_send_wr;
+ qp_init_attr->cap.max_recv_wr = resp.max_recv_wr;
+ qp_init_attr->cap.max_send_sge = resp.max_send_sge;
+ qp_init_attr->cap.max_recv_sge = resp.max_recv_sge;
+ qp_init_attr->cap.max_inline_data = resp.max_inline_data;
+ qp_init_attr->sq_sig_all = resp.sq_sig_all;
+
+ return 0;
+}
+
static int ibv_cmd_destroy_qp_v1(struct ibv_qp *qp)
{
struct ibv_destroy_qp_v1 cmd;
Index: openib_gen2/src/userspace/libibverbs/src/libibverbs.map
===================================================================
--- openib_gen2.orig/src/userspace/libibverbs/src/libibverbs.map 2006-02-07 17:00:24.000000000 +0200
+++ openib_gen2/src/userspace/libibverbs/src/libibverbs.map 2006-02-08 15:54:22.000000000 +0200
@@ -28,6 +28,7 @@ IBVERBS_1.0 {
ibv_destroy_srq;
ibv_create_qp;
ibv_modify_qp;
+ ibv_query_qp;
ibv_destroy_qp;
ibv_create_ah;
ibv_destroy_ah;
@@ -52,6 +53,7 @@ IBVERBS_1.0 {
ibv_cmd_destroy_srq;
ibv_cmd_create_qp;
ibv_cmd_modify_qp;
+ ibv_cmd_query_qp;
ibv_cmd_destroy_qp;
ibv_cmd_post_send;
ibv_cmd_post_recv;
Index: openib_gen2/src/userspace/libibverbs/src/verbs.c
===================================================================
--- openib_gen2.orig/src/userspace/libibverbs/src/verbs.c 2006-02-07 17:00:24.000000000 +0200
+++ openib_gen2/src/userspace/libibverbs/src/verbs.c 2006-02-08 17:55:12.000000000 +0200
@@ -321,6 +321,21 @@ int ibv_modify_qp(struct ibv_qp *qp, str
return 0;
}
+int ibv_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *qp_attr,
+ int qp_attr_mask, struct ibv_qp_init_attr *qp_init_attr)
+{
+ int ret;
+
+ ret = qp->context->ops.query_qp(qp, qp_attr, qp_attr_mask, qp_init_attr);
+ if (ret)
+ return ret;
+
+ if (qp_attr_mask & IBV_QP_STATE)
+ qp->state = qp_attr->qp_state;
+
+ return 0;
+}
+
int ibv_destroy_qp(struct ibv_qp *qp)
{
return qp->context->ops.destroy_qp(qp);
Index: openib_gen2/src/userspace/libmthca/src/mthca.c
===================================================================
--- openib_gen2.orig/src/userspace/libmthca/src/mthca.c 2006-02-07 17:00:23.000000000 +0200
+++ openib_gen2/src/userspace/libmthca/src/mthca.c 2006-02-08 15:54:22.000000000 +0200
@@ -113,6 +113,7 @@ static struct ibv_context_ops mthca_ctx_
.destroy_srq = mthca_destroy_srq,
.create_qp = mthca_create_qp,
.modify_qp = mthca_modify_qp,
+ .query_qp = mthca_query_qp,
.destroy_qp = mthca_destroy_qp,
.create_ah = mthca_create_ah,
.destroy_ah = mthca_destroy_ah,
Index: openib_gen2/src/userspace/libmthca/src/mthca.h
===================================================================
--- openib_gen2.orig/src/userspace/libmthca/src/mthca.h 2006-02-07 17:00:23.000000000 +0200
+++ openib_gen2/src/userspace/libmthca/src/mthca.h 2006-02-08 15:54:22.000000000 +0200
@@ -311,6 +311,8 @@ int mthca_arbel_post_srq_recv(struct ibv
struct ibv_qp *mthca_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr);
int mthca_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
enum ibv_qp_attr_mask attr_mask);
+int mthca_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int qp_attr_mask, struct ibv_qp_init_attr *qp_init_attr);
int mthca_destroy_qp(struct ibv_qp *qp);
void mthca_init_qp_indices(struct mthca_qp *qp);
int mthca_tavor_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
Index: openib_gen2/src/userspace/libmthca/src/verbs.c
===================================================================
--- openib_gen2.orig/src/userspace/libmthca/src/verbs.c 2006-02-07 17:00:23.000000000 +0200
+++ openib_gen2/src/userspace/libmthca/src/verbs.c 2006-02-08 15:54:22.000000000 +0200
@@ -591,6 +591,14 @@ int mthca_modify_qp(struct ibv_qp *qp, s
return ret;
}
+int mthca_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int qp_attr_mask, struct ibv_qp_init_attr *qp_init_attr)
+{
+ struct ibv_query_qp cmd;
+
+ return ibv_cmd_query_qp(qp, attr, qp_attr_mask, qp_init_attr, &cmd, sizeof cmd);
+}
+
int mthca_destroy_qp(struct ibv_qp *qp)
{
int ret;
Dotan Barak
Software Verification Engineer
Mellanox Technologies
Tel: +972-4-9097200 Ext: 231 Fax: +972-4-9593245
P.O. Box 86 Yokneam 20692 ISRAEL.
Home: +972-77-8841095 Cell: 052-4222383
[ May the fork be with you ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20060209/8da90d5f/attachment.html>
More information about the general
mailing list