![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 0002 /* 0003 * Copyright (c) 2015-2017 Oracle. All rights reserved. 0004 * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved. 0005 * 0006 * This software is available to you under a choice of one of two 0007 * licenses. You may choose to be licensed under the terms of the GNU 0008 * General Public License (GPL) Version 2, available from the file 0009 * COPYING in the main directory of this source tree, or the BSD-type 0010 * license below: 0011 * 0012 * Redistribution and use in source and binary forms, with or without 0013 * modification, are permitted provided that the following conditions 0014 * are met: 0015 * 0016 * Redistributions of source code must retain the above copyright 0017 * notice, this list of conditions and the following disclaimer. 0018 * 0019 * Redistributions in binary form must reproduce the above 0020 * copyright notice, this list of conditions and the following 0021 * disclaimer in the documentation and/or other materials provided 0022 * with the distribution. 0023 * 0024 * Neither the name of the Network Appliance, Inc. nor the names of 0025 * its contributors may be used to endorse or promote products 0026 * derived from this software without specific prior written 0027 * permission. 0028 * 0029 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0030 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0031 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0032 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0033 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0034 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0035 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0036 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0037 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0038 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0039 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0040 */ 0041 0042 #ifndef _LINUX_SUNRPC_RPC_RDMA_H 0043 #define _LINUX_SUNRPC_RPC_RDMA_H 0044 0045 #include <linux/types.h> 0046 #include <linux/bitops.h> 0047 0048 #define RPCRDMA_VERSION 1 0049 #define rpcrdma_version cpu_to_be32(RPCRDMA_VERSION) 0050 0051 enum { 0052 RPCRDMA_V1_DEF_INLINE_SIZE = 1024, 0053 }; 0054 0055 /* 0056 * XDR sizes, in quads 0057 */ 0058 enum { 0059 rpcrdma_fixed_maxsz = 4, 0060 rpcrdma_segment_maxsz = 4, 0061 rpcrdma_readseg_maxsz = 1 + rpcrdma_segment_maxsz, 0062 rpcrdma_readchunk_maxsz = 1 + rpcrdma_readseg_maxsz, 0063 }; 0064 0065 /* 0066 * Smallest RPC/RDMA header: rm_xid through rm_type, then rm_nochunks 0067 */ 0068 #define RPCRDMA_HDRLEN_MIN (sizeof(__be32) * 7) 0069 #define RPCRDMA_HDRLEN_ERR (sizeof(__be32) * 5) 0070 0071 enum rpcrdma_errcode { 0072 ERR_VERS = 1, 0073 ERR_CHUNK = 2 0074 }; 0075 0076 enum rpcrdma_proc { 0077 RDMA_MSG = 0, /* An RPC call or reply msg */ 0078 RDMA_NOMSG = 1, /* An RPC call or reply msg - separate body */ 0079 RDMA_MSGP = 2, /* An RPC call or reply msg with padding */ 0080 RDMA_DONE = 3, /* Client signals reply completion */ 0081 RDMA_ERROR = 4 /* An RPC RDMA encoding error */ 0082 }; 0083 0084 #define rdma_msg cpu_to_be32(RDMA_MSG) 0085 #define rdma_nomsg cpu_to_be32(RDMA_NOMSG) 0086 #define rdma_msgp cpu_to_be32(RDMA_MSGP) 0087 #define rdma_done cpu_to_be32(RDMA_DONE) 0088 #define rdma_error cpu_to_be32(RDMA_ERROR) 0089 0090 #define err_vers cpu_to_be32(ERR_VERS) 0091 #define err_chunk cpu_to_be32(ERR_CHUNK) 0092 0093 /* 0094 * Private extension to RPC-over-RDMA Version One. 0095 * Message passed during RDMA-CM connection set-up. 0096 * 0097 * Add new fields at the end, and don't permute existing 0098 * fields. 0099 */ 0100 struct rpcrdma_connect_private { 0101 __be32 cp_magic; 0102 u8 cp_version; 0103 u8 cp_flags; 0104 u8 cp_send_size; 0105 u8 cp_recv_size; 0106 } __packed; 0107 0108 #define rpcrdma_cmp_magic __cpu_to_be32(0xf6ab0e18) 0109 0110 enum { 0111 RPCRDMA_CMP_VERSION = 1, 0112 RPCRDMA_CMP_F_SND_W_INV_OK = BIT(0), 0113 }; 0114 0115 static inline u8 0116 rpcrdma_encode_buffer_size(unsigned int size) 0117 { 0118 return (size >> 10) - 1; 0119 } 0120 0121 static inline unsigned int 0122 rpcrdma_decode_buffer_size(u8 val) 0123 { 0124 return ((unsigned int)val + 1) << 10; 0125 } 0126 0127 /** 0128 * xdr_encode_rdma_segment - Encode contents of an RDMA segment 0129 * @p: Pointer into a send buffer 0130 * @handle: The RDMA handle to encode 0131 * @length: The RDMA length to encode 0132 * @offset: The RDMA offset to encode 0133 * 0134 * Return value: 0135 * Pointer to the XDR position that follows the encoded RDMA segment 0136 */ 0137 static inline __be32 *xdr_encode_rdma_segment(__be32 *p, u32 handle, 0138 u32 length, u64 offset) 0139 { 0140 *p++ = cpu_to_be32(handle); 0141 *p++ = cpu_to_be32(length); 0142 return xdr_encode_hyper(p, offset); 0143 } 0144 0145 /** 0146 * xdr_encode_read_segment - Encode contents of a Read segment 0147 * @p: Pointer into a send buffer 0148 * @position: The position to encode 0149 * @handle: The RDMA handle to encode 0150 * @length: The RDMA length to encode 0151 * @offset: The RDMA offset to encode 0152 * 0153 * Return value: 0154 * Pointer to the XDR position that follows the encoded Read segment 0155 */ 0156 static inline __be32 *xdr_encode_read_segment(__be32 *p, u32 position, 0157 u32 handle, u32 length, 0158 u64 offset) 0159 { 0160 *p++ = cpu_to_be32(position); 0161 return xdr_encode_rdma_segment(p, handle, length, offset); 0162 } 0163 0164 /** 0165 * xdr_decode_rdma_segment - Decode contents of an RDMA segment 0166 * @p: Pointer to the undecoded RDMA segment 0167 * @handle: Upon return, the RDMA handle 0168 * @length: Upon return, the RDMA length 0169 * @offset: Upon return, the RDMA offset 0170 * 0171 * Return value: 0172 * Pointer to the XDR item that follows the RDMA segment 0173 */ 0174 static inline __be32 *xdr_decode_rdma_segment(__be32 *p, u32 *handle, 0175 u32 *length, u64 *offset) 0176 { 0177 *handle = be32_to_cpup(p++); 0178 *length = be32_to_cpup(p++); 0179 return xdr_decode_hyper(p, offset); 0180 } 0181 0182 /** 0183 * xdr_decode_read_segment - Decode contents of a Read segment 0184 * @p: Pointer to the undecoded Read segment 0185 * @position: Upon return, the segment's position 0186 * @handle: Upon return, the RDMA handle 0187 * @length: Upon return, the RDMA length 0188 * @offset: Upon return, the RDMA offset 0189 * 0190 * Return value: 0191 * Pointer to the XDR item that follows the Read segment 0192 */ 0193 static inline __be32 *xdr_decode_read_segment(__be32 *p, u32 *position, 0194 u32 *handle, u32 *length, 0195 u64 *offset) 0196 { 0197 *position = be32_to_cpup(p++); 0198 return xdr_decode_rdma_segment(p, handle, length, offset); 0199 } 0200 0201 #endif /* _LINUX_SUNRPC_RPC_RDMA_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |