blob: 91a4e4ff9a9bbeb28d66394299e3ef3c938e5b0c [file] [log] [blame]
James Smart9e4f5e22009-03-26 13:33:19 -04001/*
2 * FC Transport BSG Interface
3 *
4 * Copyright (C) 2008 James Smart, Emulex Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22#ifndef SCSI_BSG_FC_H
23#define SCSI_BSG_FC_H
24
25/*
26 * This file intended to be included by both kernel and user space
27 */
28
29#include <scsi/scsi.h>
30
31/*
32 * FC Transport SGIO v4 BSG Message Support
33 */
34
35/* Default BSG request timeout (in seconds) */
36#define FC_DEFAULT_BSG_TIMEOUT (10 * HZ)
37
38
39/*
40 * Request Message Codes supported by the FC Transport
41 */
42
43/* define the class masks for the message codes */
44#define FC_BSG_CLS_MASK 0xF0000000 /* find object class */
45#define FC_BSG_HST_MASK 0x80000000 /* fc host class */
46#define FC_BSG_RPT_MASK 0x40000000 /* fc rport class */
47
48 /* fc_host Message Codes */
49#define FC_BSG_HST_ADD_RPORT (FC_BSG_HST_MASK | 0x00000001)
50#define FC_BSG_HST_DEL_RPORT (FC_BSG_HST_MASK | 0x00000002)
51#define FC_BSG_HST_ELS_NOLOGIN (FC_BSG_HST_MASK | 0x00000003)
52#define FC_BSG_HST_CT (FC_BSG_HST_MASK | 0x00000004)
53#define FC_BSG_HST_VENDOR (FC_BSG_HST_MASK | 0x000000FF)
54
55 /* fc_rport Message Codes */
56#define FC_BSG_RPT_ELS (FC_BSG_RPT_MASK | 0x00000001)
57#define FC_BSG_RPT_CT (FC_BSG_RPT_MASK | 0x00000002)
58
59
60
61/*
62 * FC Address Identifiers in Message Structures :
63 *
64 * Whenever a command payload contains a FC Address Identifier
65 * (aka port_id), the value is effectively in big-endian
66 * order, thus the array elements are decoded as follows:
67 * element [0] is bits 23:16 of the FC Address Identifier
68 * element [1] is bits 15:8 of the FC Address Identifier
69 * element [2] is bits 7:0 of the FC Address Identifier
70 */
71
72
73/*
74 * FC Host Messages
75 */
76
77/* FC_BSG_HST_ADDR_PORT : */
78
79/* Request:
80 * This message requests the FC host to login to the remote port
81 * at the specified N_Port_Id. The remote port is to be enumerated
82 * with the transport upon completion of the login.
83 */
84struct fc_bsg_host_add_rport {
85 uint8_t reserved;
86
87 /* FC Address Identier of the remote port to login to */
88 uint8_t port_id[3];
89};
90
91/* Response:
92 * There is no additional response data - fc_bsg_reply->result is sufficient
93 */
94
95
96/* FC_BSG_HST_DEL_RPORT : */
97
98/* Request:
99 * This message requests the FC host to remove an enumerated
100 * remote port and to terminate the login to it.
101 *
102 * Note: The driver is free to reject this request if it desires to
103 * remain logged in with the remote port.
104 */
105struct fc_bsg_host_del_rport {
106 uint8_t reserved;
107
108 /* FC Address Identier of the remote port to logout of */
109 uint8_t port_id[3];
110};
111
112/* Response:
113 * There is no additional response data - fc_bsg_reply->result is sufficient
114 */
115
116
117/* FC_BSG_HST_ELS_NOLOGIN : */
118
119/* Request:
120 * This message requests the FC_Host to send an ELS to a specific
121 * N_Port_ID. The host does not need to log into the remote port,
122 * nor does it need to enumerate the rport for further traffic
123 * (although, the FC host is free to do so if it desires).
124 */
125struct fc_bsg_host_els {
126 /*
127 * ELS Command Code being sent (must be the same as byte 0
128 * of the payload)
129 */
130 uint8_t command_code;
131
132 /* FC Address Identier of the remote port to send the ELS to */
133 uint8_t port_id[3];
134};
135
136/* Response:
137 */
138/* fc_bsg_ctels_reply->status values */
139#define FC_CTELS_STATUS_OK 0x00000000
140#define FC_CTELS_STATUS_REJECT 0x00000001
141#define FC_CTELS_STATUS_P_RJT 0x00000002
142#define FC_CTELS_STATUS_F_RJT 0x00000003
143#define FC_CTELS_STATUS_P_BSY 0x00000004
144#define FC_CTELS_STATUS_F_BSY 0x00000006
145struct fc_bsg_ctels_reply {
146 /*
147 * Note: An ELS LS_RJT may be reported in 2 ways:
148 * a) A status of FC_CTELS_STATUS_OK is returned. The caller
149 * is to look into the ELS receive payload to determine
150 * LS_ACC or LS_RJT (by contents of word 0). The reject
151 * data will be in word 1.
152 * b) A status of FC_CTELS_STATUS_REJECT is returned, The
153 * rjt_data field will contain valid data.
154 *
155 * Note: ELS LS_ACC is determined by an FC_CTELS_STATUS_OK, and
156 * the receive payload word 0 indicates LS_ACC
157 * (e.g. value is 0x02xxxxxx).
158 *
159 * Note: Similarly, a CT Reject may be reported in 2 ways:
160 * a) A status of FC_CTELS_STATUS_OK is returned. The caller
161 * is to look into the CT receive payload to determine
162 * Accept or Reject (by contents of word 2). The reject
163 * data will be in word 3.
164 * b) A status of FC_CTELS_STATUS_REJECT is returned, The
165 * rjt_data field will contain valid data.
166 *
167 * Note: x_RJT/BSY status will indicae that the rjt_data field
168 * is valid and contains the reason/explanation values.
169 */
170 uint32_t status; /* See FC_CTELS_STATUS_xxx */
171
172 /* valid if status is not FC_CTELS_STATUS_OK */
173 struct {
174 uint8_t action; /* fragment_id for CT REJECT */
175 uint8_t reason_code;
176 uint8_t reason_explanation;
177 uint8_t vendor_unique;
178 } rjt_data;
179};
180
181
182/* FC_BSG_HST_CT : */
183
184/* Request:
185 * This message requests that a CT Request be performed with the
186 * indicated N_Port_ID. The driver is responsible for logging in with
187 * the fabric and/or N_Port_ID, etc as per FC rules. This request does
188 * not mandate that the driver must enumerate the destination in the
189 * transport. The driver is allowed to decide whether to enumerate it,
190 * and whether to tear it down after the request.
191 */
192struct fc_bsg_host_ct {
193 uint8_t reserved;
194
195 /* FC Address Identier of the remote port to send the ELS to */
196 uint8_t port_id[3];
197
198 /*
199 * We need words 0-2 of the generic preamble for the LLD's
200 */
201 uint32_t preamble_word0; /* revision & IN_ID */
202 uint32_t preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
203 uint32_t preamble_word2; /* Cmd Code, Max Size */
204
205};
206/* Response:
207 *
208 * The reply structure is an fc_bsg_ctels_reply structure
209 */
210
211
212/* FC_BSG_HST_VENDOR : */
213
214/* Request:
215 * Note: When specifying vendor_id, be sure to read the Vendor Type and ID
216 * formatting requirements specified in scsi_netlink.h
217 */
218struct fc_bsg_host_vendor {
219 /*
220 * Identifies the vendor that the message is formatted for. This
221 * should be the recipient of the message.
222 */
223 uint64_t vendor_id;
224
225 /* start of vendor command area */
226 uint32_t vendor_cmd[0];
227};
228
229/* Response:
230 */
231struct fc_bsg_host_vendor_reply {
232 /* start of vendor response area */
233 uint32_t vendor_rsp[0];
234};
235
236
237
238/*
239 * FC Remote Port Messages
240 */
241
242/* FC_BSG_RPT_ELS : */
243
244/* Request:
245 * This message requests that an ELS be performed with the rport.
246 */
247struct fc_bsg_rport_els {
248 /*
249 * ELS Command Code being sent (must be the same as
250 * byte 0 of the payload)
251 */
252 uint8_t els_code;
253};
254
255/* Response:
256 *
257 * The reply structure is an fc_bsg_ctels_reply structure
258 */
259
260
261/* FC_BSG_RPT_CT : */
262
263/* Request:
264 * This message requests that a CT Request be performed with the rport.
265 */
266struct fc_bsg_rport_ct {
267 /*
268 * We need words 0-2 of the generic preamble for the LLD's
269 */
270 uint32_t preamble_word0; /* revision & IN_ID */
271 uint32_t preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
272 uint32_t preamble_word2; /* Cmd Code, Max Size */
273};
274/* Response:
275 *
276 * The reply structure is an fc_bsg_ctels_reply structure
277 */
278
279
280
281
282/* request (CDB) structure of the sg_io_v4 */
283struct fc_bsg_request {
284 uint32_t msgcode;
285 union {
286 struct fc_bsg_host_add_rport h_addrport;
287 struct fc_bsg_host_del_rport h_delrport;
288 struct fc_bsg_host_els h_els;
289 struct fc_bsg_host_ct h_ct;
290 struct fc_bsg_host_vendor h_vendor;
291
292 struct fc_bsg_rport_els r_els;
293 struct fc_bsg_rport_ct r_ct;
294 } rqst_data;
Harish Zunjarraoeda05a22010-01-12 12:59:50 -0800295} __attribute__((packed));
James Smart9e4f5e22009-03-26 13:33:19 -0400296
297
298/* response (request sense data) structure of the sg_io_v4 */
299struct fc_bsg_reply {
300 /*
301 * The completion result. Result exists in two forms:
302 * if negative, it is an -Exxx system errno value. There will
303 * be no further reply information supplied.
304 * else, it's the 4-byte scsi error result, with driver, host,
305 * msg and status fields. The per-msgcode reply structure
306 * will contain valid data.
307 */
308 uint32_t result;
309
310 /* If there was reply_payload, how much was recevied ? */
311 uint32_t reply_payload_rcv_len;
312
313 union {
314 struct fc_bsg_host_vendor_reply vendor_reply;
315
316 struct fc_bsg_ctels_reply ctels_reply;
317 } reply_data;
318};
319
320
321#endif /* SCSI_BSG_FC_H */
322