aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYishai Hadas <yishaih@mellanox.com>2016-02-08 14:43:17 +0200
committerYishai Hadas <yishaih@mellanox.com>2016-05-17 16:40:13 +0300
commit518fcbd42a29fb8d089883cdfef932068a9e783d (patch)
treec0610e8c3e2afbecc5e228eb7658e97ee73db22f
parente29e171145b0d663e98f4f3117b4c1aaa59f8224 (diff)
downloadlibibverbs-518fcbd42a29fb8d089883cdfef932068a9e783d.tar.gz
Add alloc/dealloc Memory Window verbs
Add alloc/dealloc Memory Window verbs, those verbs are used by both MW types one and two. Signed-off-by: Yishai Hadas <yishaih@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--include/infiniband/driver.h6
-rw-r--r--include/infiniband/kern-abi.h23
-rw-r--r--include/infiniband/verbs.h27
-rw-r--r--src/cmd.c37
-rw-r--r--src/libibverbs.map3
5 files changed, 96 insertions, 0 deletions
diff --git a/include/infiniband/driver.h b/include/infiniband/driver.h
index b7f1fae..a37ee06 100644
--- a/include/infiniband/driver.h
+++ b/include/infiniband/driver.h
@@ -139,6 +139,12 @@ int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
size_t cmd_size,
struct ibv_reg_mr_resp *resp, size_t resp_size);
int ibv_cmd_dereg_mr(struct ibv_mr *mr);
+int ibv_cmd_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type,
+ struct ibv_mw *mw, struct ibv_alloc_mw *cmd,
+ size_t cmd_size,
+ struct ibv_alloc_mw_resp *resp, size_t resp_size);
+int ibv_cmd_dealloc_mw(struct ibv_mw *mw,
+ struct ibv_dealloc_mw *cmd, size_t cmd_size);
int ibv_cmd_create_cq(struct ibv_context *context, int cqe,
struct ibv_comp_channel *channel,
int comp_vector, struct ibv_cq *cq,
diff --git a/include/infiniband/kern-abi.h b/include/infiniband/kern-abi.h
index 2278f63..9f733bb 100644
--- a/include/infiniband/kern-abi.h
+++ b/include/infiniband/kern-abi.h
@@ -371,6 +371,29 @@ struct ibv_dereg_mr {
__u32 mr_handle;
};
+struct ibv_alloc_mw {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u32 pd_handle;
+ __u8 mw_type;
+ __u8 reserved[3];
+};
+
+struct ibv_alloc_mw_resp {
+ __u32 mw_handle;
+ __u32 rkey;
+};
+
+struct ibv_dealloc_mw {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u32 mw_handle;
+ __u32 reserved;
+};
+
struct ibv_create_comp_channel {
__u32 command;
__u16 in_words;
diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h
index 941e5dc..fbf9e48 100644
--- a/include/infiniband/verbs.h
+++ b/include/infiniband/verbs.h
@@ -433,6 +433,8 @@ struct ibv_mw {
struct ibv_context *context;
struct ibv_pd *pd;
uint32_t rkey;
+ uint32_t handle;
+ enum ibv_mw_type type;
};
struct ibv_global_route {
@@ -1240,6 +1242,31 @@ struct ibv_mr *ibv_reg_mr(struct ibv_pd *pd, void *addr,
int ibv_dereg_mr(struct ibv_mr *mr);
/**
+ * ibv_alloc_mw - Allocate a memory window
+ */
+static inline struct ibv_mw *ibv_alloc_mw(struct ibv_pd *pd,
+ enum ibv_mw_type type)
+{
+ struct ibv_mw *mw;
+
+ if (!pd->context->ops.alloc_mw) {
+ errno = ENOSYS;
+ return NULL;
+ }
+
+ mw = pd->context->ops.alloc_mw(pd, type);
+ return mw;
+}
+
+/**
+ * ibv_dealloc_mw - Free a memory window
+ */
+static inline int ibv_dealloc_mw(struct ibv_mw *mw)
+{
+ return mw->context->ops.dealloc_mw(mw);
+}
+
+/**
* ibv_create_comp_channel - Create a completion event channel
*/
struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context);
diff --git a/src/cmd.c b/src/cmd.c
index ab0fd24..5b5bfee 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -347,6 +347,43 @@ int ibv_cmd_dereg_mr(struct ibv_mr *mr)
return 0;
}
+int ibv_cmd_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type,
+ struct ibv_mw *mw, struct ibv_alloc_mw *cmd,
+ size_t cmd_size,
+ struct ibv_alloc_mw_resp *resp, size_t resp_size)
+{
+ IBV_INIT_CMD_RESP(cmd, cmd_size, ALLOC_MW, resp, resp_size);
+ cmd->pd_handle = pd->handle;
+ cmd->mw_type = type;
+ memset(cmd->reserved, 0, sizeof(cmd->reserved));
+
+ if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ mw->context = pd->context;
+ mw->pd = pd;
+ mw->rkey = resp->rkey;
+ mw->handle = resp->mw_handle;
+ mw->type = type;
+
+ return 0;
+}
+
+int ibv_cmd_dealloc_mw(struct ibv_mw *mw,
+ struct ibv_dealloc_mw *cmd, size_t cmd_size)
+{
+ IBV_INIT_CMD(cmd, cmd_size, DEALLOC_MW);
+ cmd->mw_handle = mw->handle;
+ cmd->reserved = 0;
+
+ if (write(mw->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ return 0;
+}
+
int ibv_cmd_create_cq(struct ibv_context *context, int cqe,
struct ibv_comp_channel *channel,
int comp_vector, struct ibv_cq *cq,
diff --git a/src/libibverbs.map b/src/libibverbs.map
index b302f5e..dd269bf 100644
--- a/src/libibverbs.map
+++ b/src/libibverbs.map
@@ -102,6 +102,9 @@ IBVERBS_1.1 {
ibv_event_type_str;
ibv_wc_status_str;
+ ibv_cmd_alloc_mw;
+ ibv_cmd_dealloc_mw;
+
ibv_rate_to_mbps;
mbps_to_ibv_rate;