[openib-general] [PATCH] Update my branch's MW functions
Roland Dreier
roland at topspin.com
Mon Aug 9 13:15:20 PDT 2004
Pretty trivial because I haven't implemented memory windows in mthca
and I don't have any ULPs that use MWs.
- R.
Index: src/linux-kernel/infiniband/include/ib_verbs.h
===================================================================
--- src/linux-kernel/infiniband/include/ib_verbs.h (revision 607)
+++ src/linux-kernel/infiniband/include/ib_verbs.h (working copy)
@@ -153,6 +153,8 @@
IB_MR_REREG_ACCESS = (1<<2)
};
+struct ib_mw_bind;
+
struct ib_pd {
struct ib_device *device;
atomic_t usecnt; /* count all resources */
@@ -181,6 +183,12 @@
atomic_t usecnt; /* count number of MWs */
};
+struct ib_mw {
+ struct ib_device *device;
+ struct ib_pd *pd;
+ u32 rkey;
+};
+
struct ib_device {
IB_DECLARE_MAGIC
@@ -243,9 +251,11 @@
int num_phys_buf,
int mr_access_flags,
u64 *iova_start);
- ib_mw_create_func mw_create;
- ib_mw_destroy_func mw_destroy;
- ib_mw_bind_func mw_bind;
+ struct ib_mw * (*alloc_mw)(struct ib_pd *pd);
+ int (*bind_mw)(struct ib_qp *qp,
+ struct ib_mw *mw,
+ struct ib_mw_bind *mw_bind);
+ int (*dealloc_mw)(struct ib_mw *mw);
ib_fmr_create_func fmr_create;
ib_fmr_destroy_func fmr_destroy;
ib_fmr_map_func fmr_map;
@@ -328,6 +338,20 @@
int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);
int ib_dereg_mr(struct ib_mr *mr);
+struct ib_mw *ib_alloc_mw(struct ib_pd *pd);
+
+static inline int ib_bind_mw(struct ib_qp *qp,
+ struct ib_mw *mw,
+ struct ib_mw_bind *mw_bind)
+{
+ /* XXX reference counting in mw? */
+ return mw->device->bind_mw ?
+ mw->device->bind_mw(qp, mw, mw_bind) :
+ -ENOSYS;
+}
+
+int ib_dealloc_mw(struct ib_mw *mw);
+
#endif /* __KERNEL __ */
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
Index: src/linux-kernel/infiniband/include/ts_ib_core_types.h
===================================================================
--- src/linux-kernel/infiniband/include/ts_ib_core_types.h (revision 607)
+++ src/linux-kernel/infiniband/include/ts_ib_core_types.h (working copy)
@@ -405,14 +405,6 @@
/* structures */
-struct ib_mw {
- IB_DECLARE_MAGIC
- struct ib_device *device;
- struct ib_pd *pd;
- u32 rkey;
- void *private;
-};
-
enum {
IB_DEVICE_NOTIFIER_ADD,
IB_DEVICE_NOTIFIER_REMOVE
@@ -531,17 +523,6 @@
int signaled:1;
};
-struct ib_mw_bind_param {
- u64 work_request_id;
- u32 rkey;
- u32 lkey;
- u64 address;
- u64 length;
- enum ib_memory_access access;
- int signaled:1;
- int fence:1;
-};
-
struct ib_fmr_pool_param {
int max_pages_per_fmr;
enum ib_memory_access access;
@@ -599,14 +580,6 @@
typedef int (*ib_receive_post_func)(struct ib_qp *qp,
struct ib_receive_param *param,
int num_work_requests);
-typedef int (*ib_mw_create_func)(struct ib_pd *pd,
- struct ib_mw **mw,
- u32 *rkey);
-typedef int (*ib_mw_destroy_func)(struct ib_mw *mw);
-typedef int (*ib_mw_bind_func)(struct ib_qp *qp,
- struct ib_mw *mw,
- struct ib_mw_bind_param *param,
- u32 *new_rkey);
typedef int (*ib_fmr_create_func)(struct ib_pd *pd,
enum ib_memory_access access,
int max_pages,
Index: src/linux-kernel/infiniband/include/ts_ib_core.h
===================================================================
--- src/linux-kernel/infiniband/include/ts_ib_core.h (revision 607)
+++ src/linux-kernel/infiniband/include/ts_ib_core.h (working copy)
@@ -93,15 +93,6 @@
return qp->device->receive_post(qp, param, num_work_requests);
}
-int ib_mw_create(struct ib_pd *pd,
- struct ib_mw **mw,
- u32 *rkey);
-int ib_mw_destroy(struct ib_mw *mw);
-int ib_mw_bind(struct ib_qp *qp,
- struct ib_mw *mw,
- struct ib_mw_bind_param *param,
- u32 *new_rkey);
-
int ib_fmr_pool_create(struct ib_pd *pd,
struct ib_fmr_pool_param *params,
struct ib_fmr_pool **pool);
Index: src/linux-kernel/infiniband/core/core_mw.c
===================================================================
--- src/linux-kernel/infiniband/core/core_mw.c (revision 576)
+++ src/linux-kernel/infiniband/core/core_mw.c (working copy)
@@ -30,71 +30,38 @@
#include "ts_kernel_trace.h"
#include "ts_kernel_services.h"
-int ib_mw_create(struct ib_pd *pd,
- struct ib_mw **mw,
- u32 *rkey)
+struct ib_mw *ib_alloc_mw(struct ib_pd *pd)
{
- int ret;
+ struct ib_mw *mw;
- if (!pd->device->mw_create)
- return -ENOSYS;
+ if (!pd->device->alloc_mw)
+ return ERR_PTR(-ENOSYS);
- *mw = kmalloc(sizeof **mw, GFP_KERNEL);
- if (!*mw)
- return -ENOMEM;
-
- (*mw)->device = pd->device;
- (*mw)->pd = pd;
-
- ret = pd->device->mw_create(pd, mw, &(*mw)->rkey);
- if (ret) {
- kfree(mw);
- return ret;
+ mw = pd->device->alloc_mw(pd);
+ if (!IS_ERR(mw)) {
+ mw->device = pd->device;
+ mw->pd = pd;
+ atomic_inc(&pd->usecnt);
}
- IB_SET_MAGIC(*mw, MW);
- *rkey = (*mw)->rkey;
-
- return 0;
+ return mw;
}
-EXPORT_SYMBOL(ib_mw_create);
+EXPORT_SYMBOL(ib_alloc_mw);
-int ib_mw_destroy(struct ib_mw *mw)
+int ib_dealloc_mw(struct ib_mw *mw)
{
+ struct ib_pd *pd;
int ret;
- IB_CHECK_MAGIC(mw, MW);
+ pd = mw->pd;
+ ret = mw->device->dealloc_mw(mw);
+ if (!ret)
+ atomic_inc(&pd->usecnt);
- if (!mw->device->mw_destroy)
- return -ENOSYS;
-
- ret = mw->device->mw_destroy(mw);
- if (ret)
- return ret;
-
- IB_CLEAR_MAGIC(mw);
- kfree(mw);
-
- return 0;
+ return ret;
}
-EXPORT_SYMBOL(ib_mw_destroy);
+EXPORT_SYMBOL(ib_dealloc_mw);
-int ib_mw_bind(struct ib_qp *qp,
- struct ib_mw *mw,
- struct ib_mw_bind_param *param,
- u32 *new_rkey)
-{
- IB_CHECK_MAGIC(qp, QP);
- IB_CHECK_MAGIC(mw, MW);
-
- if (qp->device != mw->device)
- return -EINVAL;
-
- return mw->device->mw_bind ?
- mw->device->mw_bind(qp, mw, param, new_rkey) : -ENOSYS;
-}
-EXPORT_SYMBOL(ib_mw_bind);
-
/*
* Local Variables:
* c-file-style: "linux"
More information about the general
mailing list