diff mbox series

[v2,1/7] IB/verbs: add ib_ucontext to ib_udata

Message ID 20181014070445.4130-2-shamir.rabinovitch@oracle.com (mailing list archive)
State Changes Requested
Headers show
Series convey ib_ucontext via ib_udata | expand

Commit Message

Shamir Rabinovitch Oct. 14, 2018, 7:04 a.m. UTC
ib_udata is used in (almost) all the places in the code that require
ib_ucontext and can convey this information to the ib core and driver
layers.

Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
---
 include/rdma/ib_verbs.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
diff mbox series

Patch

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index ad116c5e6675..46fe51d0c6d1 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1532,8 +1532,36 @@  struct ib_udata {
 	void __user *outbuf;
 	size_t       inlen;
 	size_t       outlen;
+	struct ib_ucontext     *context;        /* associated user context */
 };
 
+/**
+ * _rdma_udata_context - Get ucontext from udata
+ * @udata: The udata object
+ * @warn: Warn true/false if ucontext is NULL
+ *
+ * NOTE:
+ * Most of the code should use rdma_udata_context which turn
+ * the NULL ucontext warning on. Use this function if you need
+ * to *test* if udata has ucontext and want to turn the warning
+ * off.
+ */
+static inline struct ib_ucontext *_rdma_udata_context(struct ib_udata *udata,
+						      bool warn)
+{
+	WARN_ON(warn && !udata->context);
+	return udata->context;
+}
+
+/**
+ * rdma_udata_context - Get ucontext from udata
+ * @udata: The udata object
+ *
+ * NOTE: Assume valid ucontext & warn if ucontext is NULL!
+ */
+#define rdma_udata_context(udata) \
+	_rdma_udata_context(udata, true)
+
 struct ib_pd {
 	u32			local_dma_lkey;
 	u32			flags;