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