Merge tag 'x86_cache_for_6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
[linux-block.git] / include / scsi / viosrp.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*****************************************************************************/
3 /* srp.h -- SCSI RDMA Protocol definitions                                   */
4 /*                                                                           */
5 /* Written By: Colin Devilbis, IBM Corporation                               */
6 /*                                                                           */
7 /* Copyright (C) 2003 IBM Corporation                                        */
8 /*                                                                           */
9 /*                                                                           */
10 /* This file contains structures and definitions for IBM RPA (RS/6000        */
11 /* platform architecture) implementation of the SRP (SCSI RDMA Protocol)     */
12 /* standard.  SRP is used on IBM iSeries and pSeries platforms to send SCSI  */
13 /* commands between logical partitions.                                      */
14 /*                                                                           */
15 /* SRP Information Units (IUs) are sent on a "Command/Response Queue" (CRQ)  */
16 /* between partitions.  The definitions in this file are architected,        */
17 /* and cannot be changed without breaking compatibility with other versions  */
18 /* of Linux and other operating systems (AIX, OS/400) that talk this protocol*/
19 /* between logical partitions                                                */
20 /*****************************************************************************/
21 #ifndef VIOSRP_H
22 #define VIOSRP_H
23 #include <scsi/srp.h>
24
25 #define SRP_VERSION "16.a"
26 #define SRP_MAX_IU_LEN  256
27 #define SRP_MAX_LOC_LEN 32
28
29 union srp_iu {
30         struct srp_login_req login_req;
31         struct srp_login_rsp login_rsp;
32         struct srp_login_rej login_rej;
33         struct srp_i_logout i_logout;
34         struct srp_t_logout t_logout;
35         struct srp_tsk_mgmt tsk_mgmt;
36         struct srp_cmd cmd;
37         struct srp_rsp rsp;
38         u8 reserved[SRP_MAX_IU_LEN];
39 };
40
41 enum viosrp_crq_headers {
42         VIOSRP_CRQ_FREE = 0x00,
43         VIOSRP_CRQ_CMD_RSP = 0x80,
44         VIOSRP_CRQ_INIT_RSP = 0xC0,
45         VIOSRP_CRQ_XPORT_EVENT = 0xFF
46 };
47
48 enum viosrp_crq_init_formats {
49         VIOSRP_CRQ_INIT = 0x01,
50         VIOSRP_CRQ_INIT_COMPLETE = 0x02
51 };
52
53 enum viosrp_crq_formats {
54         VIOSRP_SRP_FORMAT = 0x01,
55         VIOSRP_MAD_FORMAT = 0x02,
56         VIOSRP_OS400_FORMAT = 0x03,
57         VIOSRP_AIX_FORMAT = 0x04,
58         VIOSRP_LINUX_FORMAT = 0x05,
59         VIOSRP_INLINE_FORMAT = 0x06
60 };
61
62 enum viosrp_crq_status {
63         VIOSRP_OK = 0x0,
64         VIOSRP_NONRECOVERABLE_ERR = 0x1,
65         VIOSRP_VIOLATES_MAX_XFER = 0x2,
66         VIOSRP_PARTNER_PANIC = 0x3,
67         VIOSRP_DEVICE_BUSY = 0x8,
68         VIOSRP_ADAPTER_FAIL = 0x10,
69         VIOSRP_OK2 = 0x99,
70 };
71
72 struct viosrp_crq {
73         union {
74                 __be64 high;                    /* High 64 bits */
75                 struct {
76                         u8 valid;               /* used by RPA */
77                         u8 format;              /* SCSI vs out-of-band */
78                         u8 reserved;
79                         u8 status;              /* non-scsi failure? (e.g. DMA failure) */
80                         __be16 timeout;         /* in seconds */
81                         __be16 IU_length;       /* in bytes */
82                 };
83         };
84         __be64 IU_data_ptr;     /* the TCE for transferring data */
85 };
86
87 /* MADs are Management requests above and beyond the IUs defined in the SRP
88  * standard.
89  */
90 enum viosrp_mad_types {
91         VIOSRP_EMPTY_IU_TYPE = 0x01,
92         VIOSRP_ERROR_LOG_TYPE = 0x02,
93         VIOSRP_ADAPTER_INFO_TYPE = 0x03,
94         VIOSRP_CAPABILITIES_TYPE = 0x05,
95         VIOSRP_ENABLE_FAST_FAIL = 0x08,
96 };
97
98 enum viosrp_mad_status {
99         VIOSRP_MAD_SUCCESS = 0x00,
100         VIOSRP_MAD_NOT_SUPPORTED = 0xF1,
101         VIOSRP_MAD_FAILED = 0xF7,
102 };
103
104 enum viosrp_capability_type {
105         MIGRATION_CAPABILITIES = 0x01,
106         RESERVATION_CAPABILITIES = 0x02,
107 };
108
109 enum viosrp_capability_support {
110         SERVER_DOES_NOT_SUPPORTS_CAP = 0x0,
111         SERVER_SUPPORTS_CAP = 0x01,
112         SERVER_CAP_DATA = 0x02,
113 };
114
115 enum viosrp_reserve_type {
116         CLIENT_RESERVE_SCSI_2 = 0x01,
117 };
118
119 enum viosrp_capability_flag {
120         CLIENT_MIGRATED = 0x01,
121         CLIENT_RECONNECT = 0x02,
122         CAP_LIST_SUPPORTED = 0x04,
123         CAP_LIST_DATA = 0x08,
124 };
125
126 /*
127  * Common MAD header
128  */
129 struct mad_common {
130         __be32 type;
131         __be16 status;
132         __be16 length;
133         __be64 tag;
134 };
135
136 /*
137  * All SRP (and MAD) requests normally flow from the
138  * client to the server.  There is no way for the server to send
139  * an asynchronous message back to the client.  The Empty IU is used
140  * to hang out a meaningless request to the server so that it can respond
141  * asynchrouously with something like a SCSI AER
142  */
143 struct viosrp_empty_iu {
144         struct mad_common common;
145         __be64 buffer;
146         __be32 port;
147 };
148
149 struct viosrp_error_log {
150         struct mad_common common;
151         __be64 buffer;
152 };
153
154 struct viosrp_adapter_info {
155         struct mad_common common;
156         __be64 buffer;
157 };
158
159 struct viosrp_fast_fail {
160         struct mad_common common;
161 };
162
163 struct viosrp_capabilities {
164         struct mad_common common;
165         __be64 buffer;
166 };
167
168 struct mad_capability_common {
169         __be32 cap_type;
170         __be16 length;
171         __be16 server_support;
172 };
173
174 struct mad_reserve_cap {
175         struct mad_capability_common common;
176         __be32 type;
177 };
178
179 struct mad_migration_cap {
180         struct mad_capability_common common;
181         __be32 ecl;
182 };
183
184 struct capabilities {
185         __be32 flags;
186         char name[SRP_MAX_LOC_LEN];
187         char loc[SRP_MAX_LOC_LEN];
188         struct mad_migration_cap migration;
189         struct mad_reserve_cap reserve;
190 };
191
192 union mad_iu {
193         struct viosrp_empty_iu empty_iu;
194         struct viosrp_error_log error_log;
195         struct viosrp_adapter_info adapter_info;
196         struct viosrp_fast_fail fast_fail;
197         struct viosrp_capabilities capabilities;
198 };
199
200 union viosrp_iu {
201         union srp_iu srp;
202         union mad_iu mad;
203 };
204
205 struct mad_adapter_info_data {
206         char srp_version[8];
207         char partition_name[96];
208         __be32 partition_number;
209 #define SRP_MAD_VERSION_1 1
210         __be32 mad_version;
211 #define SRP_MAD_OS_LINUX 2
212 #define SRP_MAD_OS_AIX 3
213         __be32 os_type;
214         __be32 port_max_txu[8]; /* per-port maximum transfer */
215 };
216
217 #endif