diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2020-04-07 22:32:14 +0300 |
---|---|---|
committer | Chuck Lever <chuck.lever@oracle.com> | 2020-07-14 00:28:24 +0300 |
commit | 379c3bc6b4eb989ee37c4ce8ab403719e06fe35f (patch) | |
tree | 9c0ace8da05d1b659ef9fe02a1e8c490a89509fe /include/linux/sunrpc | |
parent | f60a08697d28b138c73b14c3204947bc8e637197 (diff) | |
download | linux-379c3bc6b4eb989ee37c4ce8ab403719e06fe35f.tar.xz |
svcrdma: Add common XDR encoders 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')
-rw-r--r-- | include/linux/sunrpc/rpc_rdma.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/linux/sunrpc/rpc_rdma.h b/include/linux/sunrpc/rpc_rdma.h index db50380f64f4..4af31bbc8802 100644 --- a/include/linux/sunrpc/rpc_rdma.h +++ b/include/linux/sunrpc/rpc_rdma.h @@ -125,6 +125,43 @@ rpcrdma_decode_buffer_size(u8 val) } /** + * xdr_encode_rdma_segment - Encode contents of an RDMA segment + * @p: Pointer into a send buffer + * @handle: The RDMA handle to encode + * @length: The RDMA length to encode + * @offset: The RDMA offset to encode + * + * Return value: + * Pointer to the XDR position that follows the encoded RDMA segment + */ +static inline __be32 *xdr_encode_rdma_segment(__be32 *p, u32 handle, + u32 length, u64 offset) +{ + *p++ = cpu_to_be32(handle); + *p++ = cpu_to_be32(length); + return xdr_encode_hyper(p, offset); +} + +/** + * xdr_encode_read_segment - Encode contents of a Read segment + * @p: Pointer into a send buffer + * @position: The position to encode + * @handle: The RDMA handle to encode + * @length: The RDMA length to encode + * @offset: The RDMA offset to encode + * + * Return value: + * Pointer to the XDR position that follows the encoded Read segment + */ +static inline __be32 *xdr_encode_read_segment(__be32 *p, u32 position, + u32 handle, u32 length, + u64 offset) +{ + *p++ = cpu_to_be32(position); + return xdr_encode_rdma_segment(p, handle, length, offset); +} + +/** * xdr_decode_rdma_segment - Decode contents of an RDMA segment * @p: Pointer to the undecoded RDMA segment * @handle: Upon return, the RDMA handle |