mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roland Dreier <rolandd@cisco.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, openib-general@openib.org
Subject: [PATCH 10/16] IB uverbs: add mthca user context support
Date: Tue, 28 Jun 2005 16:03:43 -0700	[thread overview]
Message-ID: <2005628163.o84QGfsM7oMSy0oU@cisco.com> (raw)
In-Reply-To: <2005628163.UOpVQTxEtDs4UiFi@cisco.com>

Add support for managing userspace contexts to mthca.

Signed-off-by: Roland Dreier <rolandd@cisco.com>

---

 drivers/infiniband/hw/mthca/mthca_provider.c |   58 +++++++++++++++++++++++++++
 drivers/infiniband/hw/mthca/mthca_provider.h |   14 ++++++
 2 files changed, 72 insertions(+)



--- linux.orig/drivers/infiniband/hw/mthca/mthca_provider.c	2005-06-28 15:20:00.882715841 -0700
+++ linux/drivers/infiniband/hw/mthca/mthca_provider.c	2005-06-28 15:20:16.611313860 -0700
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2005 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
@@ -37,6 +38,8 @@
 
 #include "mthca_dev.h"
 #include "mthca_cmd.h"
+#include "mthca_user.h"
+#include "mthca_memfree.h"
 
 static int mthca_query_device(struct ib_device *ibdev,
 			      struct ib_device_attr *props)
@@ -284,6 +287,59 @@ static int mthca_query_gid(struct ib_dev
 	return err;
 }
 
+static struct ib_ucontext *mthca_alloc_ucontext(struct ib_device *ibdev,
+						struct ib_udata *udata)
+{
+	struct mthca_alloc_ucontext_resp uresp;
+	struct mthca_ucontext           *context;
+	int                              err;
+
+	memset(&uresp, 0, sizeof uresp);
+
+	uresp.qp_tab_size = to_mdev(ibdev)->limits.num_qps;
+	if (mthca_is_memfree(to_mdev(ibdev)))
+		uresp.uarc_size = to_mdev(ibdev)->uar_table.uarc_size;
+	else
+		uresp.uarc_size = 0;
+
+	context = kmalloc(sizeof *context, GFP_KERNEL);
+	if (!context)
+		return ERR_PTR(-ENOMEM);
+
+	err = mthca_uar_alloc(to_mdev(ibdev), &context->uar);
+	if (err) {
+		kfree(context);
+		return ERR_PTR(err);
+	}
+
+	context->db_tab = mthca_init_user_db_tab(to_mdev(ibdev));
+	if (IS_ERR(context->db_tab)) {
+		err = PTR_ERR(context->db_tab);
+		mthca_uar_free(to_mdev(ibdev), &context->uar);
+		kfree(context);
+		return ERR_PTR(err);
+	}
+
+	if (ib_copy_to_udata(udata, &uresp, sizeof uresp)) {
+		mthca_cleanup_user_db_tab(to_mdev(ibdev), &context->uar, context->db_tab);
+		mthca_uar_free(to_mdev(ibdev), &context->uar);
+		kfree(context);
+		return ERR_PTR(-EFAULT);
+	}
+
+	return &context->ibucontext;
+}
+
+static int mthca_dealloc_ucontext(struct ib_ucontext *context)
+{
+	mthca_cleanup_user_db_tab(to_mdev(context->device), &to_mucontext(context)->uar,
+				  to_mucontext(context)->db_tab);
+	mthca_uar_free(to_mdev(context->device), &to_mucontext(context)->uar);
+	kfree(to_mucontext(context));
+
+	return 0;
+}
+
 static struct ib_pd *mthca_alloc_pd(struct ib_device *ibdev,
 				    struct ib_ucontext *context,
 				    struct ib_udata *udata)
@@ -708,6 +764,8 @@ int mthca_register_device(struct mthca_d
 	dev->ib_dev.modify_port          = mthca_modify_port;
 	dev->ib_dev.query_pkey           = mthca_query_pkey;
 	dev->ib_dev.query_gid            = mthca_query_gid;
+	dev->ib_dev.alloc_ucontext       = mthca_alloc_ucontext;
+	dev->ib_dev.dealloc_ucontext     = mthca_dealloc_ucontext;
 	dev->ib_dev.alloc_pd             = mthca_alloc_pd;
 	dev->ib_dev.dealloc_pd           = mthca_dealloc_pd;
 	dev->ib_dev.create_ah            = mthca_ah_create;
--- linux.orig/drivers/infiniband/hw/mthca/mthca_provider.h	2005-06-28 15:19:22.365034436 -0700
+++ linux/drivers/infiniband/hw/mthca/mthca_provider.h	2005-06-28 15:20:16.612313643 -0700
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
+ * Copyright (c) 2005 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
@@ -54,6 +55,14 @@ struct mthca_uar {
 	int           index;
 };
 
+struct mthca_user_db_table;
+
+struct mthca_ucontext {
+	struct ib_ucontext          ibucontext;
+	struct mthca_uar            uar;
+	struct mthca_user_db_table *db_tab;
+};
+
 struct mthca_mtt;
 
 struct mthca_mr {
@@ -236,6 +245,11 @@ struct mthca_sqp {
 	dma_addr_t      header_dma;
 };
 
+static inline struct mthca_ucontext *to_mucontext(struct ib_ucontext *ibucontext)
+{
+	return container_of(ibucontext, struct mthca_ucontext, ibucontext);
+}
+
 static inline struct mthca_fmr *to_mfmr(struct ib_fmr *ibmr)
 {
 	return container_of(ibmr, struct mthca_fmr, ibmr);

  reply	other threads:[~2005-06-28 23:32 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-28 23:03 [PATCH 00/16] Add InfiniBand userspace verbs (direct userspace access) Roland Dreier
2005-06-28 23:03 ` [PATCH 01/16] IB uverbs: core API extensions Roland Dreier
2005-06-28 23:03   ` [PATCH 02/16] IB uverbs: update kernel midlayer for new API Roland Dreier
2005-06-28 23:03     ` [PATCH 03/16] IB uverbs: update mthca " Roland Dreier
2005-06-28 23:03       ` [PATCH 04/16] IB uverbs: add user verbs ABI header Roland Dreier
2005-06-28 23:03         ` [PATCH 05/16] IB uverbs: core implementation Roland Dreier
2005-06-28 23:03           ` [PATCH 06/16] IB uverbs: memory pinning implementation Roland Dreier
2005-06-28 23:03             ` [PATCH 07/16] IB uverbs: hook up Kconfig/Makefile Roland Dreier
2005-06-28 23:03               ` [PATCH 08/16] IB uverbs: add mthca ABI header Roland Dreier
2005-06-28 23:03                 ` [PATCH 09/16] IB uverbs: add mthca user doorbell record support Roland Dreier
2005-06-28 23:03                   ` Roland Dreier [this message]
2005-06-28 23:03                     ` [PATCH 11/16] IB uverbs: add mthca mmap support Roland Dreier
2005-06-28 23:03                       ` [PATCH 12/16] IB uverbs: add mthca user PD support Roland Dreier
2005-06-28 23:03                         ` [PATCH 13/16] IB uverbs: add mthca user MR support Roland Dreier
2005-06-28 23:03                           ` [PATCH 14/16] IB uverbs: add mthca user CQ support Roland Dreier
2005-06-28 23:03                             ` [PATCH 15/16] IB uverbs: add mthca user QP support Roland Dreier
2005-06-28 23:03                               ` [PATCH 16/16] IB uverbs: add documentation file Roland Dreier
2005-06-29  0:10                             ` [PATCH 14/16] IB uverbs: add mthca user CQ support Andrew Morton
2005-06-29 16:06                               ` Roland Dreier
2005-06-29  0:07                         ` [PATCH 12/16] IB uverbs: add mthca user PD support Andrew Morton
2005-06-29 16:06                           ` Roland Dreier
2005-06-29  0:05                       ` [PATCH 11/16] IB uverbs: add mthca mmap support Andrew Morton
2005-06-29 16:06                         ` Roland Dreier
2005-07-05 19:20                         ` Roland Dreier
2005-07-05 20:53                           ` Michael S. Tsirkin
2005-07-05 22:07                             ` Roland Dreier
2005-06-29  0:02             ` [PATCH 06/16] IB uverbs: memory pinning implementation Andrew Morton
2005-06-29 16:06               ` Roland Dreier
2005-06-29  0:27           ` [PATCH 05/16] IB uverbs: core implementation Greg KH
2005-06-29  1:38             ` [openib-general] " Tom Duffy
2005-06-29  4:13             ` Troy Benjegerdes
2005-06-29 16:12               ` Greg KH
2005-06-29 16:32                 ` Troy Benjegerdes
2005-06-29 16:06             ` Roland Dreier
2005-06-29 17:01             ` Roland Dreier
2005-06-29 18:03               ` Greg KH
2005-06-30  3:13             ` [openib-general] " Ronald G. Minnich

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=2005628163.o84QGfsM7oMSy0oU@cisco.com \
    --to=rolandd@cisco.com \
    --cc=akpm@osdl.org \
    --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®