| .. | .. |
|---|
| 58 | 58 | enum { |
|---|
| 59 | 59 | rpcrdma_fixed_maxsz = 4, |
|---|
| 60 | 60 | rpcrdma_segment_maxsz = 4, |
|---|
| 61 | | - rpcrdma_readchunk_maxsz = 2 + rpcrdma_segment_maxsz, |
|---|
| 61 | + rpcrdma_readseg_maxsz = 1 + rpcrdma_segment_maxsz, |
|---|
| 62 | + rpcrdma_readchunk_maxsz = 1 + rpcrdma_readseg_maxsz, |
|---|
| 62 | 63 | }; |
|---|
| 63 | 64 | |
|---|
| 64 | 65 | /* |
|---|
| .. | .. |
|---|
| 123 | 124 | return ((unsigned int)val + 1) << 10; |
|---|
| 124 | 125 | } |
|---|
| 125 | 126 | |
|---|
| 127 | +/** |
|---|
| 128 | + * xdr_encode_rdma_segment - Encode contents of an RDMA segment |
|---|
| 129 | + * @p: Pointer into a send buffer |
|---|
| 130 | + * @handle: The RDMA handle to encode |
|---|
| 131 | + * @length: The RDMA length to encode |
|---|
| 132 | + * @offset: The RDMA offset to encode |
|---|
| 133 | + * |
|---|
| 134 | + * Return value: |
|---|
| 135 | + * Pointer to the XDR position that follows the encoded RDMA segment |
|---|
| 136 | + */ |
|---|
| 137 | +static inline __be32 *xdr_encode_rdma_segment(__be32 *p, u32 handle, |
|---|
| 138 | + u32 length, u64 offset) |
|---|
| 139 | +{ |
|---|
| 140 | + *p++ = cpu_to_be32(handle); |
|---|
| 141 | + *p++ = cpu_to_be32(length); |
|---|
| 142 | + return xdr_encode_hyper(p, offset); |
|---|
| 143 | +} |
|---|
| 144 | + |
|---|
| 145 | +/** |
|---|
| 146 | + * xdr_encode_read_segment - Encode contents of a Read segment |
|---|
| 147 | + * @p: Pointer into a send buffer |
|---|
| 148 | + * @position: The position to encode |
|---|
| 149 | + * @handle: The RDMA handle to encode |
|---|
| 150 | + * @length: The RDMA length to encode |
|---|
| 151 | + * @offset: The RDMA offset to encode |
|---|
| 152 | + * |
|---|
| 153 | + * Return value: |
|---|
| 154 | + * Pointer to the XDR position that follows the encoded Read segment |
|---|
| 155 | + */ |
|---|
| 156 | +static inline __be32 *xdr_encode_read_segment(__be32 *p, u32 position, |
|---|
| 157 | + u32 handle, u32 length, |
|---|
| 158 | + u64 offset) |
|---|
| 159 | +{ |
|---|
| 160 | + *p++ = cpu_to_be32(position); |
|---|
| 161 | + return xdr_encode_rdma_segment(p, handle, length, offset); |
|---|
| 162 | +} |
|---|
| 163 | + |
|---|
| 164 | +/** |
|---|
| 165 | + * xdr_decode_rdma_segment - Decode contents of an RDMA segment |
|---|
| 166 | + * @p: Pointer to the undecoded RDMA segment |
|---|
| 167 | + * @handle: Upon return, the RDMA handle |
|---|
| 168 | + * @length: Upon return, the RDMA length |
|---|
| 169 | + * @offset: Upon return, the RDMA offset |
|---|
| 170 | + * |
|---|
| 171 | + * Return value: |
|---|
| 172 | + * Pointer to the XDR item that follows the RDMA segment |
|---|
| 173 | + */ |
|---|
| 174 | +static inline __be32 *xdr_decode_rdma_segment(__be32 *p, u32 *handle, |
|---|
| 175 | + u32 *length, u64 *offset) |
|---|
| 176 | +{ |
|---|
| 177 | + *handle = be32_to_cpup(p++); |
|---|
| 178 | + *length = be32_to_cpup(p++); |
|---|
| 179 | + return xdr_decode_hyper(p, offset); |
|---|
| 180 | +} |
|---|
| 181 | + |
|---|
| 182 | +/** |
|---|
| 183 | + * xdr_decode_read_segment - Decode contents of a Read segment |
|---|
| 184 | + * @p: Pointer to the undecoded Read segment |
|---|
| 185 | + * @position: Upon return, the segment's position |
|---|
| 186 | + * @handle: Upon return, the RDMA handle |
|---|
| 187 | + * @length: Upon return, the RDMA length |
|---|
| 188 | + * @offset: Upon return, the RDMA offset |
|---|
| 189 | + * |
|---|
| 190 | + * Return value: |
|---|
| 191 | + * Pointer to the XDR item that follows the Read segment |
|---|
| 192 | + */ |
|---|
| 193 | +static inline __be32 *xdr_decode_read_segment(__be32 *p, u32 *position, |
|---|
| 194 | + u32 *handle, u32 *length, |
|---|
| 195 | + u64 *offset) |
|---|
| 196 | +{ |
|---|
| 197 | + *position = be32_to_cpup(p++); |
|---|
| 198 | + return xdr_decode_rdma_segment(p, handle, length, offset); |
|---|
| 199 | +} |
|---|
| 200 | + |
|---|
| 126 | 201 | #endif /* _LINUX_SUNRPC_RPC_RDMA_H */ |
|---|