aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sunrpc/rpc_rdma.h
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2020-03-29 16:44:13 -0400
committerChuck Lever <chuck.lever@oracle.com>2020-07-13 17:28:24 -0400
commitf60a08697d28b138c73b14c3204947bc8e637197 (patch)
treefe7668654225e1352e5bbd2fb7dbc5375352de52 /include/linux/sunrpc/rpc_rdma.h
parentSUNRPC: Add helpers for decoding list discriminators symbolically (diff)
downloadlinux-dev-f60a08697d28b138c73b14c3204947bc8e637197.tar.xz
linux-dev-f60a08697d28b138c73b14c3204947bc8e637197.zip
svcrdma: Add common XDR decoders for RDMA and Read segments
Clean up: De-duplicate some code. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'include/linux/sunrpc/rpc_rdma.h')
-rw-r--r--include/linux/sunrpc/rpc_rdma.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/include/linux/sunrpc/rpc_rdma.h b/include/linux/sunrpc/rpc_rdma.h
index 320c672d84de..db50380f64f4 100644
--- a/include/linux/sunrpc/rpc_rdma.h
+++ b/include/linux/sunrpc/rpc_rdma.h
@@ -124,4 +124,41 @@ rpcrdma_decode_buffer_size(u8 val)
return ((unsigned int)val + 1) << 10;
}
+/**
+ * xdr_decode_rdma_segment - Decode contents of an RDMA segment
+ * @p: Pointer to the undecoded RDMA segment
+ * @handle: Upon return, the RDMA handle
+ * @length: Upon return, the RDMA length
+ * @offset: Upon return, the RDMA offset
+ *
+ * Return value:
+ * Pointer to the XDR item that follows the RDMA segment
+ */
+static inline __be32 *xdr_decode_rdma_segment(__be32 *p, u32 *handle,
+ u32 *length, u64 *offset)
+{
+ *handle = be32_to_cpup(p++);
+ *length = be32_to_cpup(p++);
+ return xdr_decode_hyper(p, offset);
+}
+
+/**
+ * xdr_decode_read_segment - Decode contents of a Read segment
+ * @p: Pointer to the undecoded Read segment
+ * @position: Upon return, the segment's position
+ * @handle: Upon return, the RDMA handle
+ * @length: Upon return, the RDMA length
+ * @offset: Upon return, the RDMA offset
+ *
+ * Return value:
+ * Pointer to the XDR item that follows the Read segment
+ */
+static inline __be32 *xdr_decode_read_segment(__be32 *p, u32 *position,
+ u32 *handle, u32 *length,
+ u64 *offset)
+{
+ *position = be32_to_cpup(p++);
+ return xdr_decode_rdma_segment(p, handle, length, offset);
+}
+
#endif /* _LINUX_SUNRPC_RPC_RDMA_H */