blob: 8f144db73e380a0b042a5e70a98f4cb8bcac0c37 [file] [log] [blame]
\"Talpey, Thomas\c3a57ed2007-09-10 13:49:15 -04001/*
Chuck Lever62b56a62017-10-30 16:22:14 -04002 * Copyright (c) 2015-2017 Oracle. All rights reserved.
\"Talpey, Thomas\c3a57ed2007-09-10 13:49:15 -04003 * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the BSD-type
9 * license below:
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 *
18 * Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials provided
21 * with the distribution.
22 *
23 * Neither the name of the Network Appliance, Inc. nor the names of
24 * its contributors may be used to endorse or promote products
25 * derived from this software without specific prior written
26 * permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
41#ifndef _LINUX_SUNRPC_RPC_RDMA_H
42#define _LINUX_SUNRPC_RPC_RDMA_H
43
Boaz Harrosha600ffc2009-12-03 20:28:35 +020044#include <linux/types.h>
Chuck Leverff06bd12016-09-15 10:56:59 -040045#include <linux/bitops.h>
Boaz Harrosha600ffc2009-12-03 20:28:35 +020046
Chuck Lever284f4902015-01-21 11:02:13 -050047#define RPCRDMA_VERSION 1
48#define rpcrdma_version cpu_to_be32(RPCRDMA_VERSION)
49
Chuck Lever87cfb9a2016-09-15 10:57:07 -040050enum {
51 RPCRDMA_V1_DEF_INLINE_SIZE = 1024,
52};
53
Chuck Leverf2846482015-01-21 11:02:29 -050054/*
Chuck Levercbaf5802017-02-07 11:58:15 -050055 * XDR sizes, in quads
56 */
57enum {
58 rpcrdma_fixed_maxsz = 4,
59 rpcrdma_segment_maxsz = 4,
60 rpcrdma_readchunk_maxsz = 2 + rpcrdma_segment_maxsz,
61};
62
63/*
Chuck Leverf2846482015-01-21 11:02:29 -050064 * Smallest RPC/RDMA header: rm_xid through rm_type, then rm_nochunks
65 */
66#define RPCRDMA_HDRLEN_MIN (sizeof(__be32) * 7)
Chuck Leverd8647f22016-03-04 11:28:09 -050067#define RPCRDMA_HDRLEN_ERR (sizeof(__be32) * 5)
\"Talpey, Thomas\c3a57ed2007-09-10 13:49:15 -040068
69enum rpcrdma_errcode {
70 ERR_VERS = 1,
71 ERR_CHUNK = 2
72};
73
\"Talpey, Thomas\c3a57ed2007-09-10 13:49:15 -040074enum rpcrdma_proc {
75 RDMA_MSG = 0, /* An RPC call or reply msg */
76 RDMA_NOMSG = 1, /* An RPC call or reply msg - separate body */
77 RDMA_MSGP = 2, /* An RPC call or reply msg with padding */
78 RDMA_DONE = 3, /* Client signals reply completion */
79 RDMA_ERROR = 4 /* An RPC RDMA encoding error */
80};
81
Chuck Lever284f4902015-01-21 11:02:13 -050082#define rdma_msg cpu_to_be32(RDMA_MSG)
83#define rdma_nomsg cpu_to_be32(RDMA_NOMSG)
84#define rdma_msgp cpu_to_be32(RDMA_MSGP)
85#define rdma_done cpu_to_be32(RDMA_DONE)
86#define rdma_error cpu_to_be32(RDMA_ERROR)
87
Chuck Lever6b19cc52017-04-09 13:06:33 -040088#define err_vers cpu_to_be32(ERR_VERS)
89#define err_chunk cpu_to_be32(ERR_CHUNK)
90
Chuck Leverff06bd12016-09-15 10:56:59 -040091/*
92 * Private extension to RPC-over-RDMA Version One.
93 * Message passed during RDMA-CM connection set-up.
94 *
95 * Add new fields at the end, and don't permute existing
96 * fields.
97 */
98struct rpcrdma_connect_private {
99 __be32 cp_magic;
100 u8 cp_version;
101 u8 cp_flags;
102 u8 cp_send_size;
103 u8 cp_recv_size;
104} __packed;
105
106#define rpcrdma_cmp_magic __cpu_to_be32(0xf6ab0e18)
107
108enum {
109 RPCRDMA_CMP_VERSION = 1,
110 RPCRDMA_CMP_F_SND_W_INV_OK = BIT(0),
111};
112
113static inline u8
114rpcrdma_encode_buffer_size(unsigned int size)
115{
116 return (size >> 10) - 1;
117}
118
119static inline unsigned int
120rpcrdma_decode_buffer_size(u8 val)
121{
122 return ((unsigned int)val + 1) << 10;
123}
124
\"Talpey, Thomas\c3a57ed2007-09-10 13:49:15 -0400125#endif /* _LINUX_SUNRPC_RPC_RDMA_H */