mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roland Dreier <roland@topspin.com>
To: linux-kernel@vger.kernel.org, openib-general@openib.org
Subject: [PATCH][RFC][1/4] IB: core changes for userspace verbs
Date: Mon, 4 Apr 2005 15:09:00 -0700	[thread overview]
Message-ID: <200544159.Qg0tUfQc4xGRabsc@topspin.com> (raw)
In-Reply-To: <200544159.Ahk9l0puXy39U6u6@topspin.com>

Add new structs and struct members required by userspace verbs to IB core.

Signed-off-by: Roland Dreier <roland@topspin.com>

--- linux-export.orig/drivers/infiniband/core/verbs.c	2005-01-11 09:35:27.046388000 -0800
+++ linux-export/drivers/infiniband/core/verbs.c	2005-04-04 14:50:59.579791210 -0700
@@ -47,10 +47,11 @@
 {
 	struct ib_pd *pd;
 
-	pd = device->alloc_pd(device);
+	pd = device->alloc_pd(device, NULL, NULL, 0);
 
 	if (!IS_ERR(pd)) {
-		pd->device = device;
+		pd->device  = device;
+		pd->uobject = NULL;
 		atomic_set(&pd->usecnt, 0);
 	}
 
@@ -76,8 +77,9 @@
 	ah = pd->device->create_ah(pd, ah_attr);
 
 	if (!IS_ERR(ah)) {
-		ah->device = pd->device;
-		ah->pd     = pd;
+		ah->device  = pd->device;
+		ah->pd      = pd;
+		ah->uobject = NULL;
 		atomic_inc(&pd->usecnt);
 	}
 
@@ -122,7 +124,7 @@
 {
 	struct ib_qp *qp;
 
-	qp = pd->device->create_qp(pd, qp_init_attr);
+	qp = pd->device->create_qp(pd, qp_init_attr, NULL, 0);
 
 	if (!IS_ERR(qp)) {
 		qp->device     	  = pd->device;
@@ -130,6 +132,7 @@
 		qp->send_cq    	  = qp_init_attr->send_cq;
 		qp->recv_cq    	  = qp_init_attr->recv_cq;
 		qp->srq	       	  = qp_init_attr->srq;
+		qp->uobject       = NULL;
 		qp->event_handler = qp_init_attr->event_handler;
 		qp->qp_context    = qp_init_attr->qp_context;
 		qp->qp_type	  = qp_init_attr->qp_type;
@@ -197,10 +200,11 @@
 {
 	struct ib_cq *cq;
 
-	cq = device->create_cq(device, cqe);
+	cq = device->create_cq(device, cqe, NULL, NULL, 0);
 
 	if (!IS_ERR(cq)) {
 		cq->device        = device;
+		cq->uobject       = NULL;
 		cq->comp_handler  = comp_handler;
 		cq->event_handler = event_handler;
 		cq->cq_context    = cq_context;
@@ -245,8 +249,9 @@
 	mr = pd->device->get_dma_mr(pd, mr_access_flags);
 
 	if (!IS_ERR(mr)) {
-		mr->device = pd->device;
-		mr->pd     = pd;
+		mr->device  = pd->device;
+		mr->pd      = pd;
+		mr->uobject = NULL;
 		atomic_inc(&pd->usecnt);
 		atomic_set(&mr->usecnt, 0);
 	}
@@ -267,8 +272,9 @@
 				     mr_access_flags, iova_start);
 
 	if (!IS_ERR(mr)) {
-		mr->device = pd->device;
-		mr->pd     = pd;
+		mr->device  = pd->device;
+		mr->pd      = pd;
+		mr->uobject = NULL;
 		atomic_inc(&pd->usecnt);
 		atomic_set(&mr->usecnt, 0);
 	}
@@ -344,8 +350,9 @@
 
 	mw = pd->device->alloc_mw(pd);
 	if (!IS_ERR(mw)) {
-		mw->device = pd->device;
-		mw->pd     = pd;
+		mw->device  = pd->device;
+		mw->pd      = pd;
+		mw->uobject = NULL;
 		atomic_inc(&pd->usecnt);
 	}
 
--- linux-export.orig/drivers/infiniband/include/ib_verbs.h	2005-02-22 10:14:06.623746000 -0800
+++ linux-export/drivers/infiniband/include/ib_verbs.h	2005-04-04 14:50:42.054602327 -0700
@@ -41,7 +41,9 @@
 
 #include <linux/types.h>
 #include <linux/device.h>
+
 #include <asm/atomic.h>
+#include <asm/scatterlist.h>
 
 union ib_gid {
 	u8	raw[16];
@@ -618,29 +620,78 @@
 	u8	page_size;
 };
 
+struct ib_ucontext {
+	struct ib_device       *device;
+	struct list_head	pd_list;
+	struct list_head	mr_list;
+	struct list_head	mw_list;
+	struct list_head	cq_list;
+	struct list_head	qp_list;
+	struct list_head	srq_list;
+	struct list_head	ah_list;
+	spinlock_t              lock;
+};
+
+struct ib_uobject {
+	u64			user_handle;	/* handle given to us by userspace */
+	struct ib_ucontext     *context;	/* associated user context */
+	struct list_head	list;		/* link to context's list */
+	u32			id;		/* index into kernel idr */
+};
+
+struct ib_umem {
+	unsigned long		user_base;
+	unsigned long		virt_base;
+	size_t			length;
+	int			offset;
+	int			page_size;
+	struct list_head	chunk_list;
+};
+
+struct ib_umem_chunk {
+	struct list_head	list;
+	int                     nents;
+	int                     nmap;
+	struct scatterlist      page_list[0];
+};
+
+#define IB_UMEM_MAX_PAGE_CHUNK						\
+	((PAGE_SIZE - offsetof(struct ib_umem_chunk, page_list)) /	\
+	 ((void *) &((struct ib_umem_chunk *) 0)->page_list[1] -	\
+	  (void *) &((struct ib_umem_chunk *) 0)->page_list[0]))
+
+struct ib_umem_object {
+	struct ib_uobject	uobject;
+	struct ib_umem		umem;
+};
+
 struct ib_pd {
-	struct ib_device *device;
-	atomic_t          usecnt; /* count all resources */
+	struct ib_device       *device;
+	struct ib_uobject      *uobject;
+	atomic_t          	usecnt; /* count all resources */
 };
 
 struct ib_ah {
 	struct ib_device	*device;
 	struct ib_pd		*pd;
+	struct ib_uobject      *uobject;
 };
 
 typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context);
 
 struct ib_cq {
-	struct ib_device *device;
-	ib_comp_handler   comp_handler;
-	void             (*event_handler)(struct ib_event *, void *);
-	void *            cq_context;
-	int               cqe;
-	atomic_t          usecnt; /* count number of work queues */
+	struct ib_device       *device;
+	struct ib_uobject      *uobject;
+	ib_comp_handler   	comp_handler;
+	void                  (*event_handler)(struct ib_event *, void *);
+	void *            	cq_context;
+	int               	cqe;
+	atomic_t          	usecnt; /* count number of work queues */
 };
 
 struct ib_srq {
 	struct ib_device	*device;
+	struct ib_uobject	*uobject;
 	struct ib_pd		*pd;
 	void			*srq_context;
 	atomic_t		usecnt;
@@ -652,6 +703,7 @@
 	struct ib_cq	       *send_cq;
 	struct ib_cq	       *recv_cq;
 	struct ib_srq	       *srq;
+	struct ib_uobject      *uobject;
 	void                  (*event_handler)(struct ib_event *, void *);
 	void		       *qp_context;
 	u32			qp_num;
@@ -659,16 +711,18 @@
 };
 
 struct ib_mr {
-	struct ib_device *device;
-	struct ib_pd     *pd;
-	u32		  lkey;
-	u32		  rkey;
-	atomic_t          usecnt; /* count number of MWs */
+	struct ib_device  *device;
+	struct ib_pd	  *pd;
+	struct ib_uobject *uobject;
+	u32		   lkey;
+	u32		   rkey;
+	atomic_t	   usecnt; /* count number of MWs */
 };
 
 struct ib_mw {
 	struct ib_device	*device;
 	struct ib_pd		*pd;
+	struct ib_uobject	*uobject;
 	u32			rkey;
 };
 
@@ -737,7 +791,12 @@
 	int		           (*modify_port)(struct ib_device *device,
 						  u8 port_num, int port_modify_mask,
 						  struct ib_port_modify *port_modify);
-	struct ib_pd *             (*alloc_pd)(struct ib_device *device);
+	struct ib_ucontext *       (*alloc_ucontext)(struct ib_device *device,
+						     const void __user *udata, int udatalen);
+	int                        (*dealloc_ucontext)(struct ib_ucontext *context);
+	struct ib_pd *             (*alloc_pd)(struct ib_device *device,
+					       struct ib_ucontext *context,
+					       const void __user *udata, int udatalen);
 	int                        (*dealloc_pd)(struct ib_pd *pd);
 	struct ib_ah *             (*create_ah)(struct ib_pd *pd,
 						struct ib_ah_attr *ah_attr);
@@ -747,7 +806,8 @@
 					       struct ib_ah_attr *ah_attr);
 	int                        (*destroy_ah)(struct ib_ah *ah);
 	struct ib_qp *             (*create_qp)(struct ib_pd *pd,
-						struct ib_qp_init_attr *qp_init_attr);
+						struct ib_qp_init_attr *qp_init_attr,
+						const void __user *udata, int udatalen);
 	int                        (*modify_qp)(struct ib_qp *qp,
 						struct ib_qp_attr *qp_attr,
 						int qp_attr_mask);
@@ -762,8 +822,9 @@
 	int                        (*post_recv)(struct ib_qp *qp,
 						struct ib_recv_wr *recv_wr,
 						struct ib_recv_wr **bad_recv_wr);
-	struct ib_cq *             (*create_cq)(struct ib_device *device,
-						int cqe);
+	struct ib_cq *             (*create_cq)(struct ib_device *device, int cqe,
+						struct ib_ucontext *context,
+						const void __user *udata, int udatalen);
 	int                        (*destroy_cq)(struct ib_cq *cq);
 	int                        (*resize_cq)(struct ib_cq *cq, int *cqe);
 	int                        (*poll_cq)(struct ib_cq *cq, int num_entries,
@@ -780,6 +841,11 @@
 						  int num_phys_buf,
 						  int mr_access_flags,
 						  u64 *iova_start);
+	struct ib_mr *             (*reg_user_mr)(struct ib_pd *pd,
+						  struct ib_umem *region,
+						  int mr_access_flags,
+						  const void __user *udata,
+						  int udatalen);
 	int                        (*query_mr)(struct ib_mr *mr,
 					       struct ib_mr_attr *mr_attr);
 	int                        (*dereg_mr)(struct ib_mr *mr);
@@ -816,7 +882,10 @@
 						  struct ib_grh *in_grh,
 						  struct ib_mad *in_mad,
 						  struct ib_mad *out_mad);
+	int                        (*mmap)(struct ib_ucontext *context,
+					   struct vm_area_struct *vma);
 
+	struct module               *owner;
 	struct class_device          class_dev;
 	struct kobject               ports_parent;
 	struct list_head             port_list;


  reply	other threads:[~2005-04-04 22:38 UTC|newest]

Thread overview: 143+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-04 22:09 [PATCH][RFC][0/4] InfiniBand userspace verbs implementation Roland Dreier
2005-04-04 22:09 ` Roland Dreier [this message]
2005-04-04 22:09   ` [PATCH][RFC][2/4] IB: userspace verbs main module Roland Dreier
2005-04-04 22:09     ` [PATCH][RFC][3/4] IB: userspace verbs mthca changes Roland Dreier
2005-04-04 22:09       ` [PATCH][RFC][4/4] IB: userspace verbs Kconfig/Makefile changes Roland Dreier
2005-04-04 22:49       ` [openib-general] [PATCH][RFC][3/4] IB: userspace verbs mthca changes Tom Duffy
2005-04-04 23:34         ` Roland Dreier
2005-04-21  0:37       ` [PATCH][MTHCA] fix sparc build WAS: " Tom Duffy
2005-04-21  0:38         ` David S. Miller
2005-04-11 14:22 ` [PATCH][RFC][0/4] InfiniBand userspace verbs implementation Troy Benjegerdes
2005-04-11 15:34   ` Roland Dreier
2005-04-11 16:33     ` Troy Benjegerdes
2005-04-11 16:56       ` Roland Dreier
2005-04-11 18:01         ` Troy Benjegerdes
2005-04-11 18:03           ` Roland Dreier
2005-04-12  0:13             ` Andrew Morton
2005-04-12  0:21               ` Roland Dreier
2005-04-12 18:23                 ` Michael S. Tsirkin
2005-04-13 18:28                   ` Roland Dreier
2005-04-13 19:32                     ` Andrew Morton
2005-04-13  1:04               ` [openib-general] " Libor Michalek
2005-04-18 17:15                 ` Timur Tabi
2005-04-26  3:31                 ` Libor Michalek
2005-05-04 18:27                   ` Timur Tabi
2005-05-05 18:48                     ` Timur Tabi
2005-05-06 23:08                       ` Timur Tabi
2005-05-07 13:18                         ` Hugh Dickins
2005-05-07 14:45                           ` Timur Tabi
2005-05-07 16:30                             ` Hugh Dickins
2005-05-11 20:12                               ` William Jordan
2005-05-11 20:42                                 ` Hugh Dickins
2005-05-11 22:52                                   ` Andrea Arcangeli
2005-05-11 22:49                                 ` Andrea Arcangeli
2005-05-11 22:53                                   ` Timur Tabi
2005-05-11 23:05                                     ` Andrea Arcangeli
2005-05-05 23:34                     ` Libor Michalek
2005-04-18 16:22               ` Timur Tabi
2005-04-18 16:43                 ` Christoph Hellwig
2005-04-18 16:45                   ` Timur Tabi
2005-04-24  2:44                     ` Andrew Morton
2005-04-24 14:23                       ` Timur Tabi
2005-04-24 20:53                         ` Greg KH
2005-04-24 21:52                           ` Timur Tabi
2005-04-25  1:03                             ` Greg KH
2005-04-25  4:12                               ` Timur Tabi
2005-04-25 13:30                                 ` Dave Hansen
2005-04-25 13:15                         ` Roland Dreier
2005-04-25 13:17                           ` Christoph Hellwig
2005-04-25 14:16                             ` Roland Dreier
2005-04-25 20:54                           ` Andrew Morton
2005-04-25 21:12                             ` Roland Dreier
2005-04-25 22:14                               ` Andrew Morton
2005-04-25 22:21                                 ` Timur Tabi
2005-04-25 22:32                                   ` Andrew Morton
2005-04-25 23:58                                     ` Roland Dreier
2005-04-26  0:11                                       ` Andrew Morton
2005-04-26  0:23                                         ` Roland Dreier
2005-04-26  0:37                                           ` Andrew Morton
2005-04-26  2:21                                             ` Timur Tabi
2005-04-26  3:16                                               ` Andrew Morton
2005-04-26  3:38                                                 ` Timur Tabi
2005-04-26  4:33                                                   ` Andrew Morton
2005-04-26 14:07                                                     ` Timur Tabi
2005-04-26 15:31                                             ` Roland Dreier
2005-04-26 15:42                                               ` [openib-general] " Libor Michalek
2005-04-26 15:49                                                 ` Roland Dreier
2005-04-26 19:28                                                   ` Andrew Morton
2005-04-26 20:14                                                     ` Roland Dreier
2005-04-26 20:18                                                       ` Timur Tabi
2005-04-26 20:37                                                         ` Andrew Morton
2005-04-29 14:26                                                           ` Bill Jordan
2005-04-29 15:56                                                             ` Caitlin Bestler
2005-04-29 16:45                                                               ` RDMA memory registration (was: [openib-general] Re: [PATCH][RFC][0/4] InfiniBand userspace verbs implementation) Roland Dreier
2005-04-29 17:23                                                                 ` Libor Michalek
2005-04-29 18:22                                                                 ` RDMA memory registration Brice Goglin
2005-04-29 18:31                                                                   ` Roland Dreier
2005-04-29 19:33                                                                   ` [openib-general] " Grant Grundler
2005-05-03  8:42                                                                     ` David Addison
2005-05-03 15:36                                                                       ` Grant Grundler
2005-04-29 19:43                                                                 ` RDMA memory registration (was: [openib-general] Re: [PATCH][RFC][0/4] InfiniBand userspace verbs implementation) Bill Jordan
2005-04-29 19:45                                                                   ` RDMA memory registration Roland Dreier
2005-04-29 17:04                                                               ` [openib-general] Re: [PATCH][RFC][0/4] InfiniBand userspace verbs implementation Libor Michalek
2005-04-30  0:31                                                                 ` Caitlin Bestler
2005-05-03 18:43                                                                   ` Andy Isaacson
2005-05-03 19:04                                                                     ` Caitlin Bestler
2005-05-04 18:22                                                                     ` William Jordan
2005-05-05  1:27                                                                       ` Rik van Riel
2005-05-05  1:57                                                                         ` Andy Isaacson
2005-04-26 20:32                                                       ` Andrew Morton
2005-04-26 21:23                                                         ` Roland Dreier
2005-04-27  0:05                                                           ` Andrew Morton
2005-04-27  2:13                                                             ` Roland Dreier
2005-04-27  3:21                                                             ` Caitlin Bestler
2005-04-27  3:15                                                     ` Caitlin Bestler
2005-04-26  2:03                                       ` IWAMOTO Toshihiro
2005-04-26  2:16                                         ` Timur Tabi
2005-04-26  2:26                                         ` [openib-general] " Stephen Langdon
2005-04-25 22:23                                 ` Timur Tabi
2005-04-25 22:35                                   ` Andrew Morton
2005-04-25 22:42                                     ` Timur Tabi
2005-04-25 23:13                                       ` Andrew Morton
2005-04-25 23:21                                         ` Timur Tabi
2005-04-25 23:27                                           ` Andrew Morton
2005-04-26  0:08                                         ` Roland Dreier
2005-04-25 22:51                                     ` [openib-general] Re: [PATCH][RFC][0/4] InfiniBand userspace verbsimplementation Bob Woodruff
2005-04-25 23:13                                       ` Timur Tabi
2005-04-25 23:17                                         ` Andrew Morton
2005-04-25 23:29                                         ` Bob Woodruff
2005-04-25 23:17                                     ` [openib-general] Re: [PATCH][RFC][0/4] InfiniBand userspace verbs implementation Libor Michalek
2005-04-25 23:24                                       ` Andrew Morton
2005-04-25 23:37                                         ` Caitlin Bestler
2005-04-26  0:10                                           ` Andrew Morton
2005-04-26  3:55                                         ` Libor Michalek
2005-04-26  0:02                                 ` Roland Dreier
2005-04-26  6:12                                   ` Christoph Hellwig
2005-04-26 13:45                                     ` [openib-general] " Caitlin Bestler
2005-04-26 15:24                                     ` Timur Tabi
2005-04-25 19:11                       ` Andy Isaacson
2005-04-18 16:09     ` Timur Tabi
2005-04-18 16:12       ` Roland Dreier
2005-04-18 16:50         ` Timur Tabi
2005-04-21 19:47           ` Pavel Machek
2005-04-18 16:16       ` Arjan van de Ven
2005-04-18 16:25         ` Timur Tabi
2005-04-18 19:40           ` Arjan van de Ven
2005-04-18 20:00             ` Timur Tabi
2005-04-18 20:05               ` Arjan van de Ven
2005-04-18 20:19                 ` Timur Tabi
2005-04-18 20:07             ` [openib-general] " Bernhard Fischer
2005-04-21  2:17               ` Troy Benjegerdes
2005-04-21  3:07                 ` Timur Tabi
2005-04-21 17:38                   ` Andy Isaacson
2005-04-21 18:39                     ` Timur Tabi
2005-04-21 19:56                       ` Andy Isaacson
2005-04-21 20:07                         ` Timur Tabi
2005-04-21 20:12                           ` Chris Wright
2005-04-21 20:14                             ` Timur Tabi
2005-04-21 20:25                               ` Chris Wright
2005-04-21 20:30                                 ` Arjan van de Ven
2005-04-22  6:14                           ` Greg KH
2005-04-22 17:55         ` Timur Tabi
2005-04-22 18:12           ` Arjan van de Ven
2005-04-29  0:56         ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200544159.Qg0tUfQc4xGRabsc@topspin.com \
    --to=roland@topspin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openib-general@openib.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®