This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / drivers / scsi / ibmvscsi / srp.h
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, write to the Free Software               */
20 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
21 /*                                                                           */
22 /*                                                                           */
23 /* This file contains structures and definitions for the SCSI RDMA Protocol  */
24 /* (SRP) as defined in the T10 standard available at www.t10.org.  This      */
25 /* file was based on the 16a version of the standard                         */
26 /*                                                                           */
27 /*****************************************************************************/
28 #ifndef SRP_H
29 #define SRP_H
30
31 #define PACKED __attribute__((packed))
32
33 enum srp_types {
34         SRP_LOGIN_REQ_TYPE = 0x00,
35         SRP_LOGIN_RSP_TYPE = 0xC0,
36         SRP_LOGIN_REJ_TYPE = 0x80,
37         SRP_I_LOGOUT_TYPE = 0x03,
38         SRP_T_LOGOUT_TYPE = 0x80,
39         SRP_TSK_MGMT_TYPE = 0x01,
40         SRP_CMD_TYPE = 0x02,
41         SRP_RSP_TYPE = 0xC1,
42         SRP_CRED_REQ_TYPE = 0x81,
43         SRP_CRED_RSP_TYPE = 0x41,
44         SRP_AER_REQ_TYPE = 0x82,
45         SRP_AER_RSP_TYPE = 0x42
46 };
47
48 enum srp_descriptor_formats {
49         SRP_NO_BUFFER = 0x00,
50         SRP_DIRECT_BUFFER = 0x01,
51         SRP_INDIRECT_BUFFER = 0x02
52 };
53
54 struct memory_descriptor {
55         u64 virtual_address;
56         u32 memory_handle;
57         u32 length;
58 };
59
60 struct indirect_descriptor {
61         struct memory_descriptor head;
62         u32 total_length;
63         struct memory_descriptor list[1] PACKED;
64 };
65
66 struct srp_generic {
67         u8 type;
68         u8 reserved1[7];
69         u64 tag;
70 };
71
72 struct srp_login_req {
73         u8 type;
74         u8 reserved1[7];
75         u64 tag;
76         u32 max_requested_initiator_to_target_iulen;
77         u32 reserved2;
78         u16 required_buffer_formats;
79         u8 reserved3:6;
80         u8 multi_channel_action:2;
81         u8 reserved4;
82         u32 reserved5;
83         u8 initiator_port_identifier[16];
84         u8 target_port_identifier[16];
85 };
86
87 struct srp_login_rsp {
88         u8 type;
89         u8 reserved1[3];
90         u32 request_limit_delta;
91         u64 tag;
92         u32 max_initiator_to_target_iulen;
93         u32 max_target_to_initiator_iulen;
94         u16 supported_buffer_formats;
95         u8 reserved2:6;
96         u8 multi_channel_result:2;
97         u8 reserved3;
98         u8 reserved4[24];
99 };
100
101 struct srp_login_rej {
102         u8 type;
103         u8 reserved1[3];
104         u32 reason;
105         u64 tag;
106         u64 reserved2;
107         u16 supported_buffer_formats;
108         u8 reserved3[6];
109 };
110
111 struct srp_i_logout {
112         u8 type;
113         u8 reserved1[7];
114         u64 tag;
115 };
116
117 struct srp_t_logout {
118         u8 type;
119         u8 reserved1[3];
120         u32 reason;
121         u64 tag;
122 };
123
124 struct srp_tsk_mgmt {
125         u8 type;
126         u8 reserved1[7];
127         u64 tag;
128         u32 reserved2;
129         u64 lun PACKED;
130         u8 reserved3;
131         u8 reserved4;
132         u8 task_mgmt_flags;
133         u8 reserved5;
134         u64 managed_task_tag;
135         u64 reserved6;
136 };
137
138 struct srp_cmd {
139         u8 type;
140         u32 reserved1 PACKED;
141         u8 data_out_format:4;
142         u8 data_in_format:4;
143         u8 data_out_count;
144         u8 data_in_count;
145         u64 tag;
146         u32 reserved2;
147         u64 lun PACKED;
148         u8 reserved3;
149         u8 reserved4:5;
150         u8 task_attribute:3;
151         u8 reserved5;
152         u8 additional_cdb_len;
153         u8 cdb[16];
154         u8 additional_data[0x100 - 0x30];
155 };
156
157 struct srp_rsp {
158         u8 type;
159         u8 reserved1[3];
160         u32 request_limit_delta;
161         u64 tag;
162         u16 reserved2;
163         u8 reserved3:2;
164         u8 diunder:1;
165         u8 diover:1;
166         u8 dounder:1;
167         u8 doover:1;
168         u8 snsvalid:1;
169         u8 rspvalid:1;
170         u8 status;
171         u32 data_in_residual_count;
172         u32 data_out_residual_count;
173         u32 sense_data_list_length;
174         u32 response_data_list_length;
175         u8 sense_and_response_data[18];
176 };
177
178 struct srp_cred_req {
179         u8 type;
180         u8 reserved1[3];
181         u32 request_limit_delta;
182         u64 tag;
183 };
184
185 struct srp_cred_rsp {
186         u8 type;
187         u8 reserved1[7];
188         u64 tag;
189 };
190
191 struct srp_aer_req {
192         u8 type;
193         u8 reserved1[3];
194         u32 request_limit_delta;
195         u64 tag;
196         u32 reserved2;
197         u64 lun;
198         u32 sense_data_list_length;
199         u32 reserved3;
200         u8 sense_data[20];
201 };
202
203 struct srp_aer_rsp {
204         u8 type;
205         u8 reserved1[7];
206         u64 tag;
207 };
208
209 union srp_iu {
210         struct srp_generic generic;
211         struct srp_login_req login_req;
212         struct srp_login_rsp login_rsp;
213         struct srp_login_rej login_rej;
214         struct srp_i_logout i_logout;
215         struct srp_t_logout t_logout;
216         struct srp_tsk_mgmt tsk_mgmt;
217         struct srp_cmd cmd;
218         struct srp_rsp rsp;
219         struct srp_cred_req cred_req;
220         struct srp_cred_rsp cred_rsp;
221         struct srp_aer_req aer_req;
222         struct srp_aer_rsp aer_rsp;
223 };
224
225 #endif