1 This patch includes the following commits from OFED 1.3 libibverbs:
2 Implement eXtended Reliable Connections (a7df4af8eb84738f36db4161a4272fa02fc6741e)
3 Re-define IBV_DEVICE_XRC to conform to its new position (5042a9cab0ae2f7ad61bdf88dfed6fb10b700797)
4 Set "is_srq" flag only when the QP has an SRQ (6f6d29e74ca0c19a8821990aad603e3c575b7f4d)
5 for XRC QPs, return xrc_domain in ibv_query_qp (018c44a44ff0344dfe7cf5f6598f81d81769164e)
8 1. checkpatch.pl cleanups
9 2. fixed u64 alignment problems in uverbs.h ABI structs
10 3. eliminated unnecessary default_symvers
11 4. modified xrc_ops to more_ops
13 Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
14 include/infiniband/driver.h | 11 +++++
15 include/infiniband/kern-abi.h | 47 ++++++++++++++++++++++-
16 include/infiniband/verbs.h | 85 ++++++++++++++++++++++++++++++++++++++++-
17 src/cmd.c | 72 ++++++++++++++++++++++++++++++++++-
18 src/libibverbs.map | 6 +++
19 src/verbs.c | 54 ++++++++++++++++++++++++++
20 6 files changed, 271 insertions(+), 4 deletions(-)
22 Index: libibverbs/include/infiniband/driver.h
23 ===================================================================
24 --- libibverbs.orig/include/infiniband/driver.h 2009-11-01 15:18:17.920111000 +0200
25 +++ libibverbs/include/infiniband/driver.h 2009-11-01 15:18:20.624171000 +0200
26 @@ -99,6 +99,11 @@ int ibv_cmd_create_srq(struct ibv_pd *pd
27 struct ibv_srq *srq, struct ibv_srq_init_attr *attr,
28 struct ibv_create_srq *cmd, size_t cmd_size,
29 struct ibv_create_srq_resp *resp, size_t resp_size);
30 +int ibv_cmd_create_xrc_srq(struct ibv_pd *pd,
31 + struct ibv_srq *srq, struct ibv_srq_init_attr *attr,
32 + uint32_t xrc_domain, uint32_t xrc_cq,
33 + struct ibv_create_xrc_srq *cmd, size_t cmd_size,
34 + struct ibv_create_srq_resp *resp, size_t resp_size);
35 int ibv_cmd_modify_srq(struct ibv_srq *srq,
36 struct ibv_srq_attr *srq_attr,
38 @@ -134,6 +139,12 @@ int ibv_cmd_detach_mcast(struct ibv_qp *
40 int ibv_dontfork_range(void *base, size_t size);
41 int ibv_dofork_range(void *base, size_t size);
42 +int ibv_cmd_open_xrc_domain(struct ibv_context *context, int fd, int oflag,
43 + struct ibv_xrc_domain *d,
44 + struct ibv_open_xrc_domain_resp *resp,
46 +int ibv_cmd_close_xrc_domain(struct ibv_xrc_domain *d);
50 * sysfs helper functions
51 Index: libibverbs/include/infiniband/kern-abi.h
52 ===================================================================
53 --- libibverbs.orig/include/infiniband/kern-abi.h 2009-11-01 15:18:17.921121000 +0200
54 +++ libibverbs/include/infiniband/kern-abi.h 2009-11-01 15:18:20.629168000 +0200
55 @@ -85,7 +85,10 @@ enum {
56 IB_USER_VERBS_CMD_MODIFY_SRQ,
57 IB_USER_VERBS_CMD_QUERY_SRQ,
58 IB_USER_VERBS_CMD_DESTROY_SRQ,
59 - IB_USER_VERBS_CMD_POST_SRQ_RECV
60 + IB_USER_VERBS_CMD_POST_SRQ_RECV,
61 + IB_USER_VERBS_CMD_CREATE_XRC_SRQ,
62 + IB_USER_VERBS_CMD_OPEN_XRC_DOMAIN,
63 + IB_USER_VERBS_CMD_CLOSE_XRC_DOMAIN
67 @@ -706,6 +709,21 @@ struct ibv_create_srq {
71 +struct ibv_create_xrc_srq {
83 + __u64 driver_data[0];
86 struct ibv_create_srq_resp {
89 @@ -754,6 +772,30 @@ struct ibv_destroy_srq_resp {
90 __u32 events_reported;
93 +struct ibv_open_xrc_domain {
100 + __u64 driver_data[0];
103 +struct ibv_open_xrc_domain_resp {
107 +struct ibv_close_xrc_domain {
114 + __u64 driver_data[0];
118 * Compatibility with older ABI versions
120 @@ -803,6 +845,9 @@ enum {
121 * trick opcodes in IBV_INIT_CMD() doesn't break.
123 IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL_V2 = -1,
124 + IB_USER_VERBS_CMD_CREATE_XRC_SRQ_V2 = -1,
125 + IB_USER_VERBS_CMD_OPEN_XRC_DOMAIN_V2 = -1,
126 + IB_USER_VERBS_CMD_CLOSE_XRC_DOMAIN_V2 = -1,
129 struct ibv_destroy_cq_v1 {
130 Index: libibverbs/include/infiniband/verbs.h
131 ===================================================================
132 --- libibverbs.orig/include/infiniband/verbs.h 2009-11-01 15:18:17.924118000 +0200
133 +++ libibverbs/include/infiniband/verbs.h 2009-11-01 15:18:20.635171000 +0200
134 @@ -92,7 +92,8 @@ enum ibv_device_cap_flags {
135 IBV_DEVICE_SYS_IMAGE_GUID = 1 << 11,
136 IBV_DEVICE_RC_RNR_NAK_GEN = 1 << 12,
137 IBV_DEVICE_SRQ_RESIZE = 1 << 13,
138 - IBV_DEVICE_N_NOTIFY_CQ = 1 << 14
139 + IBV_DEVICE_N_NOTIFY_CQ = 1 << 14,
140 + IBV_DEVICE_XRC = 1 << 20
143 enum ibv_atomic_cap {
144 @@ -371,6 +372,11 @@ struct ibv_ah_attr {
148 +struct ibv_xrc_domain {
149 + struct ibv_context *context;
153 enum ibv_srq_attr_mask {
154 IBV_SRQ_MAX_WR = 1 << 0,
155 IBV_SRQ_LIMIT = 1 << 1
156 @@ -390,7 +396,8 @@ struct ibv_srq_init_attr {
166 @@ -409,6 +416,7 @@ struct ibv_qp_init_attr {
167 struct ibv_qp_cap cap;
168 enum ibv_qp_type qp_type;
170 + struct ibv_xrc_domain *xrc_domain;
173 enum ibv_qp_attr_mask {
174 @@ -527,6 +535,7 @@ struct ibv_send_wr {
175 uint32_t remote_qkey;
178 + uint32_t xrc_remote_srq_num;
182 @@ -554,6 +563,10 @@ struct ibv_srq {
183 pthread_mutex_t mutex;
185 uint32_t events_completed;
187 + uint32_t xrc_srq_num;
188 + struct ibv_xrc_domain *xrc_domain;
189 + struct ibv_cq *xrc_cq;
193 @@ -571,6 +584,8 @@ struct ibv_qp {
194 pthread_mutex_t mutex;
196 uint32_t events_completed;
198 + struct ibv_xrc_domain *xrc_domain;
201 struct ibv_comp_channel {
202 @@ -625,6 +640,16 @@ struct ibv_device {
203 char ibdev_path[IBV_SYSFS_PATH_MAX];
206 +struct ibv_more_ops {
207 + struct ibv_srq * (*create_xrc_srq)(struct ibv_pd *pd,
208 + struct ibv_xrc_domain *xrc_domain,
209 + struct ibv_cq *xrc_cq,
210 + struct ibv_srq_init_attr *srq_init_attr);
211 + struct ibv_xrc_domain * (*open_xrc_domain)(struct ibv_context *context,
212 + int fd, int oflag);
213 + int (*close_xrc_domain)(struct ibv_xrc_domain *d);
216 struct ibv_context_ops {
217 int (*query_device)(struct ibv_context *context,
218 struct ibv_device_attr *device_attr);
219 @@ -691,6 +716,7 @@ struct ibv_context {
220 int num_comp_vectors;
221 pthread_mutex_t mutex;
223 + struct ibv_more_ops *more_ops;
227 @@ -913,6 +939,25 @@ struct ibv_srq *ibv_create_srq(struct ib
228 struct ibv_srq_init_attr *srq_init_attr);
231 + * ibv_create_xrc_srq - Creates a SRQ associated with the specified protection
232 + * domain and xrc domain.
233 + * @pd: The protection domain associated with the SRQ.
234 + * @xrc_domain: The XRC domain associated with the SRQ.
235 + * @xrc_cq: CQ to report completions for XRC packets on.
237 + * @srq_init_attr: A list of initial attributes required to create the SRQ.
239 + * srq_attr->max_wr and srq_attr->max_sge are read the determine the
240 + * requested size of the SRQ, and set to the actual values allocated
241 + * on return. If ibv_create_srq() succeeds, then max_wr and max_sge
242 + * will always be at least as large as the requested values.
244 +struct ibv_srq *ibv_create_xrc_srq(struct ibv_pd *pd,
245 + struct ibv_xrc_domain *xrc_domain,
246 + struct ibv_cq *xrc_cq,
247 + struct ibv_srq_init_attr *srq_init_attr);
250 * ibv_modify_srq - Modifies the attributes for the specified SRQ.
251 * @srq: The SRQ to modify.
252 * @srq_attr: On input, specifies the SRQ attributes to modify. On output,
253 @@ -1093,6 +1138,42 @@ const char *ibv_port_state_str(enum ibv_
255 const char *ibv_event_type_str(enum ibv_event_type event);
258 + * ibv_open_xrc_domain - open an XRC domain
259 + * Returns a reference to an XRC domain.
261 + * @context: Device context
262 + * @fd: descriptor for inode associated with the domain
263 + * If fd == -1, no inode is associated with the domain; in this ca= se,
264 + * the only legal value for oflag is O_CREAT
266 + * @oflag: oflag values are constructed by OR-ing flags from the following list
269 + * If a domain belonging to device named by context is already associated
270 + * with the inode, this flag has no effect, except as noted under O_EXCL
271 + * below. Otherwise, a new XRC domain is created and is associated with
272 + * inode specified by fd.
275 + * If O_EXCL and O_CREAT are set, open will fail if a domain associated with
276 + * the inode exists. The check for the existence of the domain and creation
277 + * of the domain if it does not exist is atomic with respect to other
278 + * processes executing open with fd naming the same inode.
280 +struct ibv_xrc_domain *ibv_open_xrc_domain(struct ibv_context *context,
281 + int fd, int oflag);
284 + * ibv_close_xrc_domain - close an XRC domain
285 + * If this is the last reference, destroys the domain.
287 + * @d: reference to XRC domain to close
289 + * close is implicitly performed at process exit.
291 +int ibv_close_xrc_domain(struct ibv_xrc_domain *d);
295 # undef __attribute_const
296 Index: libibverbs/src/cmd.c
297 ===================================================================
298 --- libibverbs.orig/src/cmd.c 2009-11-01 15:18:17.927111000 +0200
299 +++ libibverbs/src/cmd.c 2009-11-01 15:18:20.643167000 +0200
300 @@ -483,6 +483,34 @@ int ibv_cmd_create_srq(struct ibv_pd *pd
304 +int ibv_cmd_create_xrc_srq(struct ibv_pd *pd,
305 + struct ibv_srq *srq, struct ibv_srq_init_attr *attr,
306 + uint32_t xrcd_handle, uint32_t xrc_cq,
307 + struct ibv_create_xrc_srq *cmd, size_t cmd_size,
308 + struct ibv_create_srq_resp *resp, size_t resp_size)
310 + IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_XRC_SRQ, resp, resp_size);
311 + cmd->user_handle = (uintptr_t) srq;
312 + cmd->pd_handle = pd->handle;
313 + cmd->max_wr = attr->attr.max_wr;
314 + cmd->max_sge = attr->attr.max_sge;
315 + cmd->srq_limit = attr->attr.srq_limit;
316 + cmd->xrcd_handle = xrcd_handle;
317 + cmd->xrc_cq = xrc_cq;
319 + if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
322 + VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
324 + srq->handle = resp->srq_handle;
325 + srq->context = pd->context;
326 + attr->attr.max_wr = resp->max_wr;
327 + attr->attr.max_sge = resp->max_sge;
332 static int ibv_cmd_modify_srq_v3(struct ibv_srq *srq,
333 struct ibv_srq_attr *srq_attr,
335 @@ -603,7 +631,6 @@ int ibv_cmd_create_qp(struct ibv_pd *pd,
336 cmd->pd_handle = pd->handle;
337 cmd->send_cq_handle = attr->send_cq->handle;
338 cmd->recv_cq_handle = attr->recv_cq->handle;
339 - cmd->srq_handle = attr->srq ? attr->srq->handle : 0;
340 cmd->max_send_wr = attr->cap.max_send_wr;
341 cmd->max_recv_wr = attr->cap.max_recv_wr;
342 cmd->max_send_sge = attr->cap.max_send_sge;
343 @@ -612,6 +639,9 @@ int ibv_cmd_create_qp(struct ibv_pd *pd,
344 cmd->sq_sig_all = attr->sq_sig_all;
345 cmd->qp_type = attr->qp_type;
346 cmd->is_srq = !!attr->srq;
347 + cmd->srq_handle = attr->qp_type == IBV_QPT_XRC ?
348 + (attr->xrc_domain ? attr->xrc_domain->handle : 0) :
349 + (attr->srq ? attr->srq->handle : 0);
352 if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
353 @@ -722,6 +752,8 @@ int ibv_cmd_query_qp(struct ibv_qp *qp,
354 init_attr->recv_cq = qp->recv_cq;
355 init_attr->srq = qp->srq;
356 init_attr->qp_type = qp->qp_type;
357 + if (qp->qp_type == IBV_QPT_XRC)
358 + init_attr->xrc_domain = qp->xrc_domain;
359 init_attr->cap.max_send_wr = resp.max_send_wr;
360 init_attr->cap.max_recv_wr = resp.max_recv_wr;
361 init_attr->cap.max_send_sge = resp.max_send_sge;
362 @@ -1122,3 +1154,41 @@ int ibv_cmd_detach_mcast(struct ibv_qp *
367 +int ibv_cmd_open_xrc_domain(struct ibv_context *context, int fd, int oflag,
368 + struct ibv_xrc_domain *d,
369 + struct ibv_open_xrc_domain_resp *resp,
372 + struct ibv_open_xrc_domain cmd;
377 + IBV_INIT_CMD_RESP(&cmd, sizeof cmd, OPEN_XRC_DOMAIN, resp, resp_size);
379 + cmd.oflags = oflag;
381 + if (write(context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
384 + d->handle = resp->xrcd_handle;
389 +int ibv_cmd_close_xrc_domain(struct ibv_xrc_domain *d)
391 + struct ibv_close_xrc_domain cmd;
396 + IBV_INIT_CMD(&cmd, sizeof cmd, CLOSE_XRC_DOMAIN);
397 + cmd.xrcd_handle = d->handle;
399 + if (write(d->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
404 Index: libibverbs/src/libibverbs.map
405 ===================================================================
406 --- libibverbs.orig/src/libibverbs.map 2009-11-01 15:18:17.928115000 +0200
407 +++ libibverbs/src/libibverbs.map 2009-11-01 15:18:20.646169000 +0200
408 @@ -91,6 +91,12 @@ IBVERBS_1.1 {
412 + ibv_create_xrc_srq;
413 + ibv_cmd_create_xrc_srq;
414 + ibv_open_xrc_domain;
415 + ibv_cmd_open_xrc_domain;
416 + ibv_close_xrc_domain;
417 + ibv_cmd_close_xrc_domain;
421 Index: libibverbs/src/verbs.c
422 ===================================================================
423 --- libibverbs.orig/src/verbs.c 2009-11-01 15:18:17.931119000 +0200
424 +++ libibverbs/src/verbs.c 2009-11-01 15:18:20.650169000 +0200
425 @@ -366,6 +366,9 @@ struct ibv_srq *__ibv_create_srq(struct
426 srq->context = pd->context;
427 srq->srq_context = srq_init_attr->srq_context;
429 + srq->xrc_domain = NULL;
430 + srq->xrc_cq = NULL;
431 + srq->xrc_srq_num = 0;
432 srq->events_completed = 0;
433 pthread_mutex_init(&srq->mutex, NULL);
434 pthread_cond_init(&srq->cond, NULL);
435 @@ -375,6 +378,32 @@ struct ibv_srq *__ibv_create_srq(struct
437 default_symver(__ibv_create_srq, ibv_create_srq);
439 +struct ibv_srq *ibv_create_xrc_srq(struct ibv_pd *pd,
440 + struct ibv_xrc_domain *xrc_domain,
441 + struct ibv_cq *xrc_cq,
442 + struct ibv_srq_init_attr *srq_init_attr)
444 + struct ibv_srq *srq;
446 + if (!pd->context->more_ops)
449 + srq = pd->context->more_ops->create_xrc_srq(pd, xrc_domain,
450 + xrc_cq, srq_init_attr);
452 + srq->context = pd->context;
453 + srq->srq_context = srq_init_attr->srq_context;
455 + srq->xrc_domain = xrc_domain;
456 + srq->xrc_cq = xrc_cq;
457 + srq->events_completed = 0;
458 + pthread_mutex_init(&srq->mutex, NULL);
459 + pthread_cond_init(&srq->cond, NULL);
465 int __ibv_modify_srq(struct ibv_srq *srq,
466 struct ibv_srq_attr *srq_attr,
468 @@ -410,6 +439,8 @@ struct ibv_qp *__ibv_create_qp(struct ib
469 qp->qp_type = qp_init_attr->qp_type;
470 qp->state = IBV_QPS_RESET;
471 qp->events_completed = 0;
472 + qp->xrc_domain = qp_init_attr->qp_type == IBV_QPT_XRC ?
473 + qp_init_attr->xrc_domain : NULL;
474 pthread_mutex_init(&qp->mutex, NULL);
475 pthread_cond_init(&qp->cond, NULL);
477 @@ -543,3 +574,26 @@ int __ibv_detach_mcast(struct ibv_qp *qp
478 return qp->context->ops.detach_mcast(qp, gid, lid);
480 default_symver(__ibv_detach_mcast, ibv_detach_mcast);
482 +struct ibv_xrc_domain *ibv_open_xrc_domain(struct ibv_context *context,
485 + struct ibv_xrc_domain *d;
487 + if (!context->more_ops)
490 + d = context->more_ops->open_xrc_domain(context, fd, oflag);
492 + d->context = context;
497 +int ibv_close_xrc_domain(struct ibv_xrc_domain *d)
499 + if (!d->context->more_ops)
502 + return d->context->more_ops->close_xrc_domain(d);