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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 include/rdma/ib_verbs.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

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;
-- 
2.17.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux