[openib-general] ibv_cmd_create_qp() question
Roland Dreier
rdreier at cisco.com
Wed Feb 15 13:56:44 PST 2006
Steve> Hey Roland, Why don't I use the same scheme as Heiko for
Steve> now. Then I won't hold up the release. At this point, I
Steve> can't say for sure what else we might suggest to change in
Steve> the core APIs anyway. I'll submit a patch down the road to
Steve> fix the core to handle this ala create_cq(), but it can
Steve> wait until 1.1.0.
Actually I'd rather get this straightened out sooner rather than
later. I don't want ehca merged with the scheme it uses, so I think
libibverbs needs to be ready to do it properly too.
It's pretty trivial to update ibv_cmd_create_qp(); in fact I just did
it. How does this patch look to you? (driver library changes coming
shortly)
- R.
Index: libibverbs/include/infiniband/driver.h
===================================================================
--- libibverbs/include/infiniband/driver.h (revision 5421)
+++ libibverbs/include/infiniband/driver.h (working copy)
@@ -114,7 +114,8 @@ int ibv_cmd_destroy_srq(struct ibv_srq *
int ibv_cmd_create_qp(struct ibv_pd *pd,
struct ibv_qp *qp, struct ibv_qp_init_attr *attr,
- struct ibv_create_qp *cmd, size_t cmd_size);
+ struct ibv_create_qp *cmd, size_t cmd_size,
+ struct ibv_create_qp_resp *resp, size_t resp_size);
int ibv_cmd_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *qp_attr,
enum ibv_qp_attr_mask attr_mask,
struct ibv_qp_init_attr *qp_init_attr,
Index: libibverbs/ChangeLog
===================================================================
--- libibverbs/ChangeLog (revision 5421)
+++ libibverbs/ChangeLog (working copy)
@@ -1,3 +1,11 @@
+2006-02-15 Roland Dreier <rdreier at cisco.com>
+
+ * src/cmd.c (ibv_cmd_create_qp): Allow userspace device-specific
+ driver to pass in a response buffer, so that the low-level driver
+ in the kernel can pass back device-specific information. This
+ changes the userspace driver API, since the signature of
+ ibv_cmd_create_qp() is changed.
+
2006-02-14 Roland Dreier <rdreier at cisco.com>
* Release version 1.0-rc6.
Index: libibverbs/src/cmd.c
===================================================================
--- libibverbs/src/cmd.c (revision 5421)
+++ libibverbs/src/cmd.c (working copy)
@@ -543,17 +543,11 @@ int ibv_cmd_destroy_srq(struct ibv_srq *
int ibv_cmd_create_qp(struct ibv_pd *pd,
struct ibv_qp *qp, struct ibv_qp_init_attr *attr,
- struct ibv_create_qp *cmd, size_t cmd_size)
+ struct ibv_create_qp *cmd, size_t cmd_size,
+ struct ibv_create_qp_resp *resp, size_t resp_size)
{
- union {
- struct ibv_create_qp_resp resp;
- struct ibv_create_qp_resp_v3 resp_v3;
- } r;
-
- if (abi_ver > 3)
- IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_QP, &r.resp, sizeof r.resp);
- else
- IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_QP, &r.resp_v3, sizeof r.resp_v3);
+ IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_QP, resp, resp_size);
+
cmd->user_handle = (uintptr_t) qp;
cmd->pd_handle = pd->handle;
cmd->send_cq_handle = attr->send_cq->handle;
@@ -572,16 +566,22 @@ int ibv_cmd_create_qp(struct ibv_pd *pd,
return errno;
if (abi_ver > 3) {
- qp->handle = r.resp.qp_handle;
- qp->qp_num = r.resp.qpn;
- attr->cap.max_recv_sge = r.resp.max_recv_sge;
- attr->cap.max_send_sge = r.resp.max_send_sge;
- attr->cap.max_recv_wr = r.resp.max_recv_wr;
- attr->cap.max_send_wr = r.resp.max_send_wr;
- attr->cap.max_inline_data = r.resp.max_inline_data;
+ qp->handle = resp->qp_handle;
+ qp->qp_num = resp->qpn;
+ attr->cap.max_recv_sge = resp->max_recv_sge;
+ attr->cap.max_send_sge = resp->max_send_sge;
+ attr->cap.max_recv_wr = resp->max_recv_wr;
+ attr->cap.max_send_wr = resp->max_send_wr;
+ attr->cap.max_inline_data = resp->max_inline_data;
} else {
- qp->handle = r.resp_v3.qp_handle;
- qp->qp_num = r.resp_v3.qpn;
+ struct ibv_create_qp_resp_v3 *resp_v3 =
+ (struct ibv_create_qp_resp_v3 *) resp;
+
+ qp->handle = resp_v3->qp_handle;
+ qp->qp_num = resp_v3->qpn;
+ memmove((void *) resp + sizeof *resp,
+ (void *) resp_v3 + sizeof *resp_v3,
+ resp_size - sizeof *resp);
}
return 0;
More information about the general
mailing list