@@ -49,5 +49,7 @@ DECLARE_DRV_CMD(urxe_modify_srq, IB_USER_VERBS_CMD_MODIFY_SRQ,
rxe_modify_srq_cmd, empty);
DECLARE_DRV_CMD(urxe_resize_cq, IB_USER_VERBS_CMD_RESIZE_CQ,
empty, rxe_resize_cq_resp);
+DECLARE_DRV_CMD(urxe_import_pd, IB_USER_VERBS_CMD_IMPORT_PD,
+ empty, ib_uverbs_alloc_pd_resp);
#endif /* RXE_ABI_H */
@@ -49,6 +49,7 @@
#include <pthread.h>
#include <stddef.h>
+#include <rdma/ib_user_ioctl_cmds.h>
#include <infiniband/driver.h>
#include <infiniband/verbs.h>
@@ -111,6 +112,32 @@ static struct ibv_pd *rxe_alloc_pd(struct ibv_context *context)
return pd;
}
+static struct ibv_pd *rxe_import_pd(struct ibv_context *context, uint32_t fd,
+ uint32_t handle)
+{
+ struct ibv_import_pd cmd = {
+ .handle = handle,
+ .type = UVERBS_OBJECT_PD,
+ .fd = fd,
+ };
+ struct urxe_import_pd_resp resp;
+ struct ibv_pd *pd;
+ int ret;
+
+ pd = calloc(1, sizeof(*pd));
+ if (!pd)
+ return NULL;
+
+ ret = ibv_cmd_import_pd(context, pd, &cmd, sizeof(cmd), &resp.ibv_resp,
+ sizeof(resp));
+ if (ret) {
+ free(pd);
+ return NULL;
+ }
+
+ return pd;
+}
+
static int rxe_dealloc_pd(struct ibv_pd *pd)
{
int ret;
@@ -835,6 +862,7 @@ static const struct verbs_context_ops rxe_ctx_ops = {
.query_port = rxe_query_port,
.alloc_pd = rxe_alloc_pd,
.dealloc_pd = rxe_dealloc_pd,
+ .import_pd = rxe_import_pd,
.reg_mr = rxe_reg_mr,
.dereg_mr = rxe_dereg_mr,
.create_cq = rxe_create_cq,