aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/sw/rdmavt/vt.c
diff options
context:
space:
mode:
authorHarish Chegondi <harish.chegondi@intel.com>2016-01-22 12:50:05 -0800
committerDoug Ledford <dledford@redhat.com>2016-03-10 20:37:19 -0500
commit6c43cf4b4851704de28cbd5fdfc55275744153fa (patch)
treef053211353c49b197248afa74333e21af815702a /drivers/infiniband/sw/rdmavt/vt.c
parentIB/qib: Remove srq from qib (diff)
downloadlinux-dev-6c43cf4b4851704de28cbd5fdfc55275744153fa.tar.xz
linux-dev-6c43cf4b4851704de28cbd5fdfc55275744153fa.zip
IB/rdmavt: Add IB user context allocation and de-alloction functions
Adding IB user context alloc and dealloc functions to rdmavt so that the drivers that use rdmavt can use these functions instead of defining their own functions. Reviewed-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Harish Chegondi <harish.chegondi@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/sw/rdmavt/vt.c')
-rw-r--r--drivers/infiniband/sw/rdmavt/vt.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/drivers/infiniband/sw/rdmavt/vt.c b/drivers/infiniband/sw/rdmavt/vt.c
index 18b5f43e6824..df2df361c342 100644
--- a/drivers/infiniband/sw/rdmavt/vt.c
+++ b/drivers/infiniband/sw/rdmavt/vt.c
@@ -189,6 +189,16 @@ static int rvt_query_gid(struct ib_device *ibdev, u8 port,
return -EOPNOTSUPP;
}
+struct rvt_ucontext {
+ struct ib_ucontext ibucontext;
+};
+
+static inline struct rvt_ucontext *to_iucontext(struct ib_ucontext
+ *ibucontext)
+{
+ return container_of(ibucontext, struct rvt_ucontext, ibucontext);
+}
+
/**
* rvt_alloc_ucontext - Allocate a user context
* @ibdev: Vers IB dev
@@ -197,7 +207,12 @@ static int rvt_query_gid(struct ib_device *ibdev, u8 port,
static struct ib_ucontext *rvt_alloc_ucontext(struct ib_device *ibdev,
struct ib_udata *udata)
{
- return ERR_PTR(-EOPNOTSUPP);
+ struct rvt_ucontext *context;
+
+ context = kmalloc(sizeof(*context), GFP_KERNEL);
+ if (!context)
+ return ERR_PTR(-ENOMEM);
+ return &context->ibucontext;
}
/**
@@ -206,7 +221,8 @@ static struct ib_ucontext *rvt_alloc_ucontext(struct ib_device *ibdev,
*/
static int rvt_dealloc_ucontext(struct ib_ucontext *context)
{
- return -EOPNOTSUPP;
+ kfree(to_iucontext(context));
+ return 0;
}
static int rvt_get_port_immutable(struct ib_device *ibdev, u8 port_num,