diff mbox series

[1/2] RDMA/rxe: Exchange capabilities with provider

Message ID 20201106230319.17477-2-rpearson@hpe.com (mailing list archive)
State Not Applicable
Headers show
Series RDMA/rxe: Implement extended verbs APIs | expand

Commit Message

Bob Pearson Nov. 6, 2020, 11:03 p.m. UTC
Exchange provider and driver capabilities during
alloc_ucontext verb. Default is none. Will allow
more flexibility in ABI extensions without breaking
compatibility.

Signed-off-by: Bob Pearson <rpearson@hpe.com>
---
 drivers/infiniband/sw/rxe/rxe.c       |  2 ++
 drivers/infiniband/sw/rxe/rxe_verbs.c | 23 +++++++++++++++++++++++
 drivers/infiniband/sw/rxe/rxe_verbs.h |  3 +++
 include/uapi/rdma/rdma_user_rxe.h     | 12 ++++++++++++
 4 files changed, 40 insertions(+)
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe.c b/drivers/infiniband/sw/rxe/rxe.c
index 95f0de0c8b49..dbd84347e7df 100644
--- a/drivers/infiniband/sw/rxe/rxe.c
+++ b/drivers/infiniband/sw/rxe/rxe.c
@@ -73,6 +73,8 @@  static void rxe_init_device_param(struct rxe_dev *rxe)
 			rxe->ndev->dev_addr);
 
 	rxe->max_ucontext			= RXE_MAX_UCONTEXT;
+
+	rxe->driver_cap				= RXE_CAP_NONE;
 }
 
 /* initialize port attributes */
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c
index 8af2bb968f6d..070f050b9793 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.c
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.c
@@ -110,6 +110,29 @@  static int rxe_alloc_ucontext(struct ib_ucontext *uctx, struct ib_udata *udata)
 {
 	struct rxe_dev *rxe = to_rdev(uctx->device);
 	struct rxe_ucontext *uc = to_ruc(uctx);
+	struct rxe_alloc_context_cmd cmd = {};
+	struct rxe_alloc_context_resp __user *resp = NULL;
+	int err;
+
+	if (udata) {
+		if (udata->inlen >= sizeof(cmd)) {
+			err = ib_copy_from_udata(&cmd, udata, sizeof(cmd));
+			if (err)
+				return err;
+		}
+
+		if (udata->outlen >= sizeof(resp))
+			resp = udata->outbuf;
+	}
+
+	uc->provider_cap = cmd.provider_cap;
+
+	if (resp) {
+		err = copy_to_user(&resp->driver_cap, &rxe->driver_cap,
+				   sizeof(resp->driver_cap));
+		if (err)
+			return err;
+	}
 
 	return rxe_add_to_pool(&rxe->uc_pool, &uc->pelem);
 }
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h
index 57967fc39c04..bc021f15ef06 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.h
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.h
@@ -36,6 +36,7 @@  static inline int psn_compare(u32 psn_a, u32 psn_b)
 struct rxe_ucontext {
 	struct ib_ucontext ibuc;
 	struct rxe_pool_entry	pelem;
+	u64			provider_cap;
 };
 
 struct rxe_pd {
@@ -358,6 +359,8 @@  struct rxe_dev {
 
 	struct net_device	*ndev;
 
+	u64			driver_cap;
+
 	int			xmit_errors;
 
 	struct rxe_pool		uc_pool;
diff --git a/include/uapi/rdma/rdma_user_rxe.h b/include/uapi/rdma/rdma_user_rxe.h
index e591d8c1f3cf..70ac031e0a88 100644
--- a/include/uapi/rdma/rdma_user_rxe.h
+++ b/include/uapi/rdma/rdma_user_rxe.h
@@ -158,6 +158,18 @@  struct rxe_recv_wqe {
 	struct rxe_dma_info	dma;
 };
 
+enum rxe_capabilities {
+	RXE_CAP_NONE		= 0,
+};
+
+struct rxe_alloc_context_cmd {
+	__aligned_u64		provider_cap;
+};
+
+struct rxe_alloc_context_resp {
+	__aligned_u64		driver_cap;
+};
+
 struct rxe_create_cq_resp {
 	struct mminfo mi;
 };