xref: /openbmc/qemu/hw/scsi/viosrp.h (revision ce799a04)
1 /*****************************************************************************/
2 /* srp.h -- SCSI RDMA Protocol definitions                                   */
3 /*                                                                           */
4 /* Written By: Colin Devilbis, IBM Corporation                               */
5 /*                                                                           */
6 /* Copyright (C) 2003 IBM Corporation                                        */
7 /*                                                                           */
8 /* This program is free software; you can redistribute it and/or modify      */
9 /* it under the terms of the GNU General Public License as published by      */
10 /* the Free Software Foundation; either version 2 of the License, or         */
11 /* (at your option) any later version.                                       */
12 /*                                                                           */
13 /* This program is distributed in the hope that it will be useful,           */
14 /* but WITHOUT ANY WARRANTY; without even the implied warranty of            */
15 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             */
16 /* GNU General Public License for more details.                              */
17 /*                                                                           */
18 /* You should have received a copy of the GNU General Public License         */
19 /* along with this program. If not, see <https://www.gnu.org/licenses/>.     */
20 /*                                                                           */
21 /*                                                                           */
22 /* This file contains structures and definitions for IBM RPA (RS/6000        */
23 /* platform architecture) implementation of the SRP (SCSI RDMA Protocol)     */
24 /* standard.  SRP is used on IBM iSeries and pSeries platforms to send SCSI  */
25 /* commands between logical partitions.                                      */
26 /*                                                                           */
27 /* SRP Information Units (IUs) are sent on a "Command/Response Queue" (CRQ)  */
28 /* between partitions.  The definitions in this file are architected,        */
29 /* and cannot be changed without breaking compatibility with other versions  */
30 /* of Linux and other operating systems (AIX, OS/400) that talk this protocol*/
31 /* between logical partitions                                                */
32 /*****************************************************************************/
33 #ifndef PPC_VIOSRP_H
34 #define PPC_VIOSRP_H
35 
36 #include "hw/scsi/srp.h"
37 
38 #define SRP_VERSION "16.a"
39 #define SRP_MAX_IU_LEN    256
40 #define SRP_MAX_LOC_LEN 32
41 
42 union srp_iu {
43     struct srp_login_req login_req;
44     struct srp_login_rsp login_rsp;
45     struct srp_login_rej login_rej;
46     struct srp_i_logout i_logout;
47     struct srp_t_logout t_logout;
48     struct srp_tsk_mgmt tsk_mgmt;
49     struct srp_cmd cmd;
50     struct srp_rsp rsp;
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 = 0x06,
59     VIOSRP_INLINE_FORMAT = 0x07
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     uint8_t valid;        /* used by RPA */
74     uint8_t format;        /* SCSI vs out-of-band */
75     uint8_t reserved;
76     uint8_t status;        /* non-scsi failure? (e.g. DMA failure) */
77     uint16_t timeout;        /* in seconds */
78     uint16_t IU_length;        /* in bytes */
79     uint64_t IU_data_ptr;    /* the TCE for transferring data */
80 };
81 
82 /* MADs are Management requests above and beyond the IUs defined in the SRP
83  * standard.
84  */
85 enum viosrp_mad_types {
86     VIOSRP_EMPTY_IU_TYPE = 0x01,
87     VIOSRP_ERROR_LOG_TYPE = 0x02,
88     VIOSRP_ADAPTER_INFO_TYPE = 0x03,
89     VIOSRP_HOST_CONFIG_TYPE = 0x04,
90     VIOSRP_CAPABILITIES_TYPE = 0x05,
91     VIOSRP_ENABLE_FAST_FAIL = 0x08,
92 };
93 
94 enum viosrp_mad_status {
95     VIOSRP_MAD_SUCCESS = 0x00,
96     VIOSRP_MAD_NOT_SUPPORTED = 0xF1,
97     VIOSRP_MAD_FAILED = 0xF7,
98 };
99 
100 enum viosrp_capability_type {
101     MIGRATION_CAPABILITIES = 0x01,
102     RESERVATION_CAPABILITIES = 0x02,
103 };
104 
105 enum viosrp_capability_support {
106     SERVER_DOES_NOT_SUPPORTS_CAP = 0x0,
107     SERVER_SUPPORTS_CAP = 0x01,
108     SERVER_CAP_DATA = 0x02,
109 };
110 
111 enum viosrp_reserve_type {
112     CLIENT_RESERVE_SCSI_2 = 0x01,
113 };
114 
115 enum viosrp_capability_flag {
116     CLIENT_MIGRATED = 0x01,
117     CLIENT_RECONNECT = 0x02,
118     CAP_LIST_SUPPORTED = 0x04,
119     CAP_LIST_DATA = 0x08,
120 };
121 
122 /*
123  * Common MAD header
124  */
125 struct mad_common {
126     uint32_t type;
127     uint16_t status;
128     uint16_t length;
129     uint64_t tag;
130 };
131 
132 /*
133  * All SRP (and MAD) requests normally flow from the
134  * client to the server.  There is no way for the server to send
135  * an asynchronous message back to the client.  The Empty IU is used
136  * to hang out a meaningless request to the server so that it can respond
137  * asynchrouously with something like a SCSI AER
138  */
139 struct viosrp_empty_iu {
140     struct mad_common common;
141     uint64_t buffer;
142     uint32_t port;
143 };
144 
145 struct viosrp_error_log {
146     struct mad_common common;
147     uint64_t buffer;
148 };
149 
150 struct viosrp_adapter_info {
151     struct mad_common common;
152     uint64_t buffer;
153 };
154 
155 struct viosrp_host_config {
156     struct mad_common common;
157     uint64_t buffer;
158 };
159 
160 struct viosrp_fast_fail {
161     struct mad_common common;
162 };
163 
164 struct viosrp_capabilities {
165     struct mad_common common;
166     uint64_t buffer;
167 };
168 
169 struct mad_capability_common {
170     uint32_t cap_type;
171     uint16_t length;
172     uint16_t server_support;
173 };
174 
175 struct mad_reserve_cap {
176     struct mad_capability_common common;
177     uint32_t type;
178 };
179 
180 struct mad_migration_cap {
181     struct mad_capability_common common;
182     uint32_t ecl;
183 };
184 
185 struct capabilities {
186     uint32_t flags;
187     char name[SRP_MAX_LOC_LEN];
188     char loc[SRP_MAX_LOC_LEN];
189     struct mad_migration_cap migration;
190     struct mad_reserve_cap reserve;
191 };
192 
193 union mad_iu {
194     struct viosrp_empty_iu empty_iu;
195     struct viosrp_error_log error_log;
196     struct viosrp_adapter_info adapter_info;
197     struct viosrp_host_config host_config;
198     struct viosrp_fast_fail fast_fail;
199     struct viosrp_capabilities capabilities;
200 };
201 
202 union viosrp_iu {
203     union srp_iu srp;
204     union mad_iu mad;
205 };
206 
207 struct mad_adapter_info_data {
208     char srp_version[8];
209     char partition_name[96];
210     uint32_t partition_number;
211     uint32_t mad_version;
212     uint32_t os_type;
213     uint32_t port_max_txu[8];    /* per-port maximum transfer */
214 };
215 
216 #endif
217