]> git.proxmox.com Git - qemu.git/blame - hw/srp.h
Merge remote-tracking branch 'kraxel/usb.31' into staging
[qemu.git] / hw / srp.h
CommitLineData
6e270446
BH
1/*
2 * Copyright (c) 2005 Cisco Systems. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * 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
21 * provided with the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 *
32 */
33
34#ifndef SCSI_SRP_H
35#define SCSI_SRP_H
36
37/*
38 * Structures and constants for the SCSI RDMA Protocol (SRP) as
39 * defined by the INCITS T10 committee. This file was written using
40 * draft Revision 16a of the SRP standard.
41 */
42
43enum {
44
45 SRP_LOGIN_REQ = 0x00,
46 SRP_TSK_MGMT = 0x01,
47 SRP_CMD = 0x02,
48 SRP_I_LOGOUT = 0x03,
49 SRP_LOGIN_RSP = 0xc0,
50 SRP_RSP = 0xc1,
51 SRP_LOGIN_REJ = 0xc2,
52 SRP_T_LOGOUT = 0x80,
53 SRP_CRED_REQ = 0x81,
54 SRP_AER_REQ = 0x82,
55 SRP_CRED_RSP = 0x41,
56 SRP_AER_RSP = 0x42
57};
58
59enum {
60 SRP_BUF_FORMAT_DIRECT = 1 << 1,
61 SRP_BUF_FORMAT_INDIRECT = 1 << 2
62};
63
64enum {
65 SRP_NO_DATA_DESC = 0,
66 SRP_DATA_DESC_DIRECT = 1,
67 SRP_DATA_DESC_INDIRECT = 2
68};
69
70enum {
71 SRP_TSK_ABORT_TASK = 0x01,
72 SRP_TSK_ABORT_TASK_SET = 0x02,
73 SRP_TSK_CLEAR_TASK_SET = 0x04,
74 SRP_TSK_LUN_RESET = 0x08,
75 SRP_TSK_CLEAR_ACA = 0x40
76};
77
78enum srp_login_rej_reason {
79 SRP_LOGIN_REJ_UNABLE_ESTABLISH_CHANNEL = 0x00010000,
80 SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES = 0x00010001,
81 SRP_LOGIN_REJ_REQ_IT_IU_LENGTH_TOO_LARGE = 0x00010002,
82 SRP_LOGIN_REJ_UNABLE_ASSOCIATE_CHANNEL = 0x00010003,
83 SRP_LOGIN_REJ_UNSUPPORTED_DESCRIPTOR_FMT = 0x00010004,
84 SRP_LOGIN_REJ_MULTI_CHANNEL_UNSUPPORTED = 0x00010005,
85 SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED = 0x00010006
86};
87
88enum {
89 SRP_REV10_IB_IO_CLASS = 0xff00,
90 SRP_REV16A_IB_IO_CLASS = 0x0100
91};
92
93struct srp_direct_buf {
94 uint64_t va;
95 uint32_t key;
96 uint32_t len;
97};
98
99/*
100 * We need the packed attribute because the SRP spec puts the list of
101 * descriptors at an offset of 20, which is not aligned to the size of
102 * struct srp_direct_buf. The whole structure must be packed to avoid
103 * having the 20-byte structure padded to 24 bytes on 64-bit architectures.
104 */
105struct srp_indirect_buf {
106 struct srp_direct_buf table_desc;
107 uint32_t len;
108 struct srp_direct_buf desc_list[0];
541dc0d4 109} QEMU_PACKED;
6e270446
BH
110
111enum {
112 SRP_MULTICHAN_SINGLE = 0,
113 SRP_MULTICHAN_MULTI = 1
114};
115
116struct srp_login_req {
117 uint8_t opcode;
118 uint8_t reserved1[7];
119 uint64_t tag;
120 uint32_t req_it_iu_len;
121 uint8_t reserved2[4];
122 uint16_t req_buf_fmt;
123 uint8_t req_flags;
124 uint8_t reserved3[5];
125 uint8_t initiator_port_id[16];
126 uint8_t target_port_id[16];
127};
128
129/*
130 * The SRP spec defines the size of the LOGIN_RSP structure to be 52
131 * bytes, so it needs to be packed to avoid having it padded to 56
132 * bytes on 64-bit architectures.
133 */
134struct srp_login_rsp {
135 uint8_t opcode;
136 uint8_t reserved1[3];
137 uint32_t req_lim_delta;
138 uint64_t tag;
139 uint32_t max_it_iu_len;
140 uint32_t max_ti_iu_len;
141 uint16_t buf_fmt;
142 uint8_t rsp_flags;
143 uint8_t reserved2[25];
541dc0d4 144} QEMU_PACKED;
6e270446
BH
145
146struct srp_login_rej {
147 uint8_t opcode;
148 uint8_t reserved1[3];
149 uint32_t reason;
150 uint64_t tag;
151 uint8_t reserved2[8];
152 uint16_t buf_fmt;
153 uint8_t reserved3[6];
154};
155
156struct srp_i_logout {
157 uint8_t opcode;
158 uint8_t reserved[7];
159 uint64_t tag;
160};
161
162struct srp_t_logout {
163 uint8_t opcode;
164 uint8_t sol_not;
165 uint8_t reserved[2];
166 uint32_t reason;
167 uint64_t tag;
168};
169
170/*
171 * We need the packed attribute because the SRP spec only aligns the
172 * 8-byte LUN field to 4 bytes.
173 */
174struct srp_tsk_mgmt {
175 uint8_t opcode;
176 uint8_t sol_not;
177 uint8_t reserved1[6];
178 uint64_t tag;
179 uint8_t reserved2[4];
541dc0d4 180 uint64_t lun QEMU_PACKED;
6e270446
BH
181 uint8_t reserved3[2];
182 uint8_t tsk_mgmt_func;
183 uint8_t reserved4;
184 uint64_t task_tag;
185 uint8_t reserved5[8];
186};
187
188/*
189 * We need the packed attribute because the SRP spec only aligns the
190 * 8-byte LUN field to 4 bytes.
191 */
192struct srp_cmd {
193 uint8_t opcode;
194 uint8_t sol_not;
195 uint8_t reserved1[3];
196 uint8_t buf_fmt;
197 uint8_t data_out_desc_cnt;
198 uint8_t data_in_desc_cnt;
199 uint64_t tag;
200 uint8_t reserved2[4];
541dc0d4 201 uint64_t lun QEMU_PACKED;
6e270446
BH
202 uint8_t reserved3;
203 uint8_t task_attr;
204 uint8_t reserved4;
205 uint8_t add_cdb_len;
206 uint8_t cdb[16];
207 uint8_t add_data[0];
208};
209
210enum {
211 SRP_RSP_FLAG_RSPVALID = 1 << 0,
212 SRP_RSP_FLAG_SNSVALID = 1 << 1,
213 SRP_RSP_FLAG_DOOVER = 1 << 2,
214 SRP_RSP_FLAG_DOUNDER = 1 << 3,
215 SRP_RSP_FLAG_DIOVER = 1 << 4,
216 SRP_RSP_FLAG_DIUNDER = 1 << 5
217};
218
219/*
220 * The SRP spec defines the size of the RSP structure to be 36 bytes,
221 * so it needs to be packed to avoid having it padded to 40 bytes on
222 * 64-bit architectures.
223 */
224struct srp_rsp {
225 uint8_t opcode;
226 uint8_t sol_not;
227 uint8_t reserved1[2];
228 uint32_t req_lim_delta;
229 uint64_t tag;
230 uint8_t reserved2[2];
231 uint8_t flags;
232 uint8_t status;
233 uint32_t data_out_res_cnt;
234 uint32_t data_in_res_cnt;
235 uint32_t sense_data_len;
236 uint32_t resp_data_len;
237 uint8_t data[0];
541dc0d4 238} QEMU_PACKED;
6e270446
BH
239
240#endif /* SCSI_SRP_H */