[openib-general] [PATCH 3/6] [RFC] libibverbs changes for resize CQ

Roland Dreier rolandd at cisco.com
Mon Jan 30 09:17:27 PST 2006


libibverbs changes to handle resizing CQs.  Essentially just adding
API and support for passing the call through to provider plug-ins.

---

--- libibverbs/include/infiniband/driver.h	(revision 5201)
+++ libibverbs/include/infiniband/driver.h	(working copy)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
- * Copyright (c) 2005 Cisco Systems.  All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.
  * Copyright (c) 2005 PathScale, Inc.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -95,6 +95,8 @@ extern int ibv_cmd_create_cq(struct ibv_
 			     struct ibv_create_cq_resp *resp, size_t resp_size);
 extern int ibv_cmd_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc);
 extern int ibv_cmd_req_notify_cq(struct ibv_cq *cq, int solicited_only);
+extern int ibv_cmd_resize_cq(struct ibv_cq *cq, int cqe,
+			     struct ibv_resize_cq *cmd, size_t cmd_size);
 extern int ibv_cmd_destroy_cq(struct ibv_cq *cq);
 
 extern int ibv_cmd_create_srq(struct ibv_pd *pd,
--- libibverbs/include/infiniband/verbs.h	(revision 5201)
+++ libibverbs/include/infiniband/verbs.h	(working copy)
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2004 Intel Corporation.  All rights reserved.
- * Copyright (c) 2005 Cisco Systems.  All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.
  * Copyright (c) 2005 PathScale, Inc.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -549,6 +549,7 @@ struct ibv_context_ops {
 	int			(*poll_cq)(struct ibv_cq *cq, int num_entries, struct ibv_wc *wc);
 	int			(*req_notify_cq)(struct ibv_cq *cq, int solicited_only);
 	void			(*cq_event)(struct ibv_cq *cq);
+	int			(*resize_cq)(struct ibv_cq *cq, int cqe);
 	int			(*destroy_cq)(struct ibv_cq *cq);
 	struct ibv_srq *	(*create_srq)(struct ibv_pd *pd,
 					      struct ibv_srq_init_attr *srq_init_attr);
@@ -717,6 +718,15 @@ extern struct ibv_cq *ibv_create_cq(stru
 				    int comp_vector);
 
 /**
+ * ibv_resize_cq - Modifies the capacity of the CQ.
+ * @cq: The CQ to resize.
+ * @cqe: The minimum size of the CQ.
+ *
+ * Users can examine the cq structure to determine the actual CQ size.
+ */
+extern int ibv_resize_cq(struct ibv_cq *cq, int cqe);
+
+/**
  * ibv_destroy_cq - Destroy a completion queue
  */
 extern int ibv_destroy_cq(struct ibv_cq *cq);
--- libibverbs/include/infiniband/kern-abi.h	(revision 5201)
+++ libibverbs/include/infiniband/kern-abi.h	(working copy)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
- * Copyright (c) 2005 Cisco Systems.  All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.
  * Copyright (c) 2005 PathScale, Inc.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -343,6 +343,20 @@ struct ibv_req_notify_cq {
 	__u32 solicited;
 };
 
+struct ibv_resize_cq {
+	__u32 command;
+	__u16 in_words;
+	__u16 out_words;
+	__u64 response;
+	__u32 cq_handle;
+	__u32 cqe;
+	__u64 driver_data[0];
+};
+
+struct ibv_resize_cq_resp {
+	__u32 cqe;
+};
+
 struct ibv_destroy_cq {
 	__u32 command;
 	__u16 in_words;
--- libibverbs/ChangeLog	(revision 5201)
+++ libibverbs/ChangeLog	(working copy)
@@ -1,3 +1,17 @@
+2006-01-26  Roland Dreier  <rdreier at cisco.com>
+
+	* include/infiniband/driver.h, src/cmd.c (ibv_cmd_resize_cq): Add
+	driver interface for calling resize CQ kernel command.
+
+	* include/infiniband/kern-abi.h: Add resize CQ kernel ABI.
+
+	* include/infiniband/verbs.h, src/verbs.c (ibv_resize_cq): Add
+	resize CQ library API.  This changes the provider ABI, since a new
+	field is added to struct ibv_context_ops; source compatibility
+	with provider libraries is preserved, but binaries will have to be
+	recompiled.  Neither source nor binary compatibility with
+	consumers of libibverbs is affected.
+
 2006-01-25  Roland Dreier  <rdreier at cisco.com>
 
 	* examples/pingpong.c, examples/pingpong.h,
--- libibverbs/src/libibverbs.map	(revision 5201)
+++ libibverbs/src/libibverbs.map	(working copy)
@@ -19,6 +19,7 @@ IBVERBS_1.0 {
 		ibv_create_comp_channel;
 		ibv_destroy_comp_channel;
 		ibv_create_cq;
+		ibv_resize_cq;
 		ibv_destroy_cq;
 		ibv_get_cq_event;
 		ibv_ack_cq_events;
@@ -44,6 +45,7 @@ IBVERBS_1.0 {
 		ibv_cmd_create_cq;
 		ibv_cmd_poll_cq;
 		ibv_cmd_req_notify_cq;
+		ibv_cmd_resize_cq;
 		ibv_cmd_destroy_cq;
 		ibv_cmd_create_srq;
 		ibv_cmd_modify_srq;
--- libibverbs/src/verbs.c	(revision 5201)
+++ libibverbs/src/verbs.c	(working copy)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
+ * Copyright (c) 2006 Cisco Systems.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -212,6 +213,14 @@ struct ibv_cq *ibv_create_cq(struct ibv_
 	return cq;
 }
 
+int ibv_resize_cq(struct ibv_cq *cq, int cqe)
+{
+	if (!cq->context->ops.resize_cq)
+		return ENOSYS;
+
+	return cq->context->ops.resize_cq(cq, cqe);
+}
+
 int ibv_destroy_cq(struct ibv_cq *cq)
 {
 	return cq->context->ops.destroy_cq(cq);
--- libibverbs/src/cmd.c	(revision 5201)
+++ libibverbs/src/cmd.c	(working copy)
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 PathScale, Inc.  All rights reserved.
+ * Copyright (c) 2006 Cisco Systems.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -364,6 +365,23 @@ int ibv_cmd_req_notify_cq(struct ibv_cq 
 	return 0;
 }
 
+int ibv_cmd_resize_cq(struct ibv_cq *cq, int cqe,
+		      struct ibv_resize_cq *cmd, size_t cmd_size)
+{
+	struct ibv_resize_cq_resp resp;
+
+	IBV_INIT_CMD_RESP(cmd, cmd_size, RESIZE_CQ, &resp, sizeof resp);
+	cmd->cq_handle = cq->handle;
+	cmd->cqe       = cqe;
+
+	if (write(cq->context->cmd_fd, cmd, cmd_size) != cmd_size)
+		return errno;
+
+	cq->cqe = resp.cqe;
+
+	return 0;
+}
+
 static int ibv_cmd_destroy_cq_v1(struct ibv_cq *cq)
 {
 	struct ibv_destroy_cq_v1 cmd;
--- libibverbs/README	(revision 5201)
+++ libibverbs/README	(working copy)
@@ -98,6 +98,5 @@ necessary permissions to release your wo
 TODO
 ====
 
- * Completion queue (CQ) resizing need to be implemented.
  * Memory windows (MWs) need to be implemented.
  * Query QP, query SRQ and other query verbs need to be implemented.



More information about the general mailing list