1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
3 * FC Transport BSG Interface
5 * Copyright (C) 2008 James Smart, Emulex Corporation
12 * This file intended to be included by both kernel and user space
16 * FC Transport SGIO v4 BSG Message Support
19 /* Default BSG request timeout (in seconds) */
20 #define FC_DEFAULT_BSG_TIMEOUT (10 * HZ)
24 * Request Message Codes supported by the FC Transport
27 /* define the class masks for the message codes */
28 #define FC_BSG_CLS_MASK 0xF0000000 /* find object class */
29 #define FC_BSG_HST_MASK 0x80000000 /* fc host class */
30 #define FC_BSG_RPT_MASK 0x40000000 /* fc rport class */
32 /* fc_host Message Codes */
33 #define FC_BSG_HST_ADD_RPORT (FC_BSG_HST_MASK | 0x00000001)
34 #define FC_BSG_HST_DEL_RPORT (FC_BSG_HST_MASK | 0x00000002)
35 #define FC_BSG_HST_ELS_NOLOGIN (FC_BSG_HST_MASK | 0x00000003)
36 #define FC_BSG_HST_CT (FC_BSG_HST_MASK | 0x00000004)
37 #define FC_BSG_HST_VENDOR (FC_BSG_HST_MASK | 0x000000FF)
39 /* fc_rport Message Codes */
40 #define FC_BSG_RPT_ELS (FC_BSG_RPT_MASK | 0x00000001)
41 #define FC_BSG_RPT_CT (FC_BSG_RPT_MASK | 0x00000002)
46 * FC Address Identifiers in Message Structures :
48 * Whenever a command payload contains a FC Address Identifier
49 * (aka port_id), the value is effectively in big-endian
50 * order, thus the array elements are decoded as follows:
51 * element [0] is bits 23:16 of the FC Address Identifier
52 * element [1] is bits 15:8 of the FC Address Identifier
53 * element [2] is bits 7:0 of the FC Address Identifier
61 /* FC_BSG_HST_ADDR_PORT : */
64 * This message requests the FC host to login to the remote port
65 * at the specified N_Port_Id. The remote port is to be enumerated
66 * with the transport upon completion of the login.
68 struct fc_bsg_host_add_rport {
71 /* FC Address Identier of the remote port to login to */
76 * There is no additional response data - fc_bsg_reply->result is sufficient
80 /* FC_BSG_HST_DEL_RPORT : */
83 * This message requests the FC host to remove an enumerated
84 * remote port and to terminate the login to it.
86 * Note: The driver is free to reject this request if it desires to
87 * remain logged in with the remote port.
89 struct fc_bsg_host_del_rport {
92 /* FC Address Identier of the remote port to logout of */
97 * There is no additional response data - fc_bsg_reply->result is sufficient
101 /* FC_BSG_HST_ELS_NOLOGIN : */
104 * This message requests the FC_Host to send an ELS to a specific
105 * N_Port_ID. The host does not need to log into the remote port,
106 * nor does it need to enumerate the rport for further traffic
107 * (although, the FC host is free to do so if it desires).
109 struct fc_bsg_host_els {
111 * ELS Command Code being sent (must be the same as byte 0
114 uint8_t command_code;
116 /* FC Address Identier of the remote port to send the ELS to */
122 /* fc_bsg_ctels_reply->status values */
123 #define FC_CTELS_STATUS_OK 0x00000000
124 #define FC_CTELS_STATUS_REJECT 0x00000001
125 #define FC_CTELS_STATUS_P_RJT 0x00000002
126 #define FC_CTELS_STATUS_F_RJT 0x00000003
127 #define FC_CTELS_STATUS_P_BSY 0x00000004
128 #define FC_CTELS_STATUS_F_BSY 0x00000006
129 struct fc_bsg_ctels_reply {
131 * Note: An ELS LS_RJT may be reported in 2 ways:
132 * a) A status of FC_CTELS_STATUS_OK is returned. The caller
133 * is to look into the ELS receive payload to determine
134 * LS_ACC or LS_RJT (by contents of word 0). The reject
135 * data will be in word 1.
136 * b) A status of FC_CTELS_STATUS_REJECT is returned, The
137 * rjt_data field will contain valid data.
139 * Note: ELS LS_ACC is determined by an FC_CTELS_STATUS_OK, and
140 * the receive payload word 0 indicates LS_ACC
141 * (e.g. value is 0x02xxxxxx).
143 * Note: Similarly, a CT Reject may be reported in 2 ways:
144 * a) A status of FC_CTELS_STATUS_OK is returned. The caller
145 * is to look into the CT receive payload to determine
146 * Accept or Reject (by contents of word 2). The reject
147 * data will be in word 3.
148 * b) A status of FC_CTELS_STATUS_REJECT is returned, The
149 * rjt_data field will contain valid data.
151 * Note: x_RJT/BSY status will indicae that the rjt_data field
152 * is valid and contains the reason/explanation values.
154 uint32_t status; /* See FC_CTELS_STATUS_xxx */
156 /* valid if status is not FC_CTELS_STATUS_OK */
158 uint8_t action; /* fragment_id for CT REJECT */
160 uint8_t reason_explanation;
161 uint8_t vendor_unique;
166 /* FC_BSG_HST_CT : */
169 * This message requests that a CT Request be performed with the
170 * indicated N_Port_ID. The driver is responsible for logging in with
171 * the fabric and/or N_Port_ID, etc as per FC rules. This request does
172 * not mandate that the driver must enumerate the destination in the
173 * transport. The driver is allowed to decide whether to enumerate it,
174 * and whether to tear it down after the request.
176 struct fc_bsg_host_ct {
179 /* FC Address Identier of the remote port to send the ELS to */
183 * We need words 0-2 of the generic preamble for the LLD's
185 uint32_t preamble_word0; /* revision & IN_ID */
186 uint32_t preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
187 uint32_t preamble_word2; /* Cmd Code, Max Size */
192 * The reply structure is an fc_bsg_ctels_reply structure
196 /* FC_BSG_HST_VENDOR : */
199 * Note: When specifying vendor_id, be sure to read the Vendor Type and ID
200 * formatting requirements specified in scsi_netlink.h
202 struct fc_bsg_host_vendor {
204 * Identifies the vendor that the message is formatted for. This
205 * should be the recipient of the message.
209 /* start of vendor command area */
210 uint32_t vendor_cmd[0];
215 struct fc_bsg_host_vendor_reply {
216 /* start of vendor response area */
217 uint32_t vendor_rsp[0];
223 * FC Remote Port Messages
226 /* FC_BSG_RPT_ELS : */
229 * This message requests that an ELS be performed with the rport.
231 struct fc_bsg_rport_els {
233 * ELS Command Code being sent (must be the same as
234 * byte 0 of the payload)
241 * The reply structure is an fc_bsg_ctels_reply structure
245 /* FC_BSG_RPT_CT : */
248 * This message requests that a CT Request be performed with the rport.
250 struct fc_bsg_rport_ct {
252 * We need words 0-2 of the generic preamble for the LLD's
254 uint32_t preamble_word0; /* revision & IN_ID */
255 uint32_t preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
256 uint32_t preamble_word2; /* Cmd Code, Max Size */
260 * The reply structure is an fc_bsg_ctels_reply structure
266 /* request (CDB) structure of the sg_io_v4 */
267 struct fc_bsg_request {
270 struct fc_bsg_host_add_rport h_addrport;
271 struct fc_bsg_host_del_rport h_delrport;
272 struct fc_bsg_host_els h_els;
273 struct fc_bsg_host_ct h_ct;
274 struct fc_bsg_host_vendor h_vendor;
276 struct fc_bsg_rport_els r_els;
277 struct fc_bsg_rport_ct r_ct;
279 } __attribute__((packed));
282 /* response (request sense data) structure of the sg_io_v4 */
283 struct fc_bsg_reply {
285 * The completion result. Result exists in two forms:
286 * if negative, it is an -Exxx system errno value. There will
287 * be no further reply information supplied.
288 * else, it's the 4-byte scsi error result, with driver, host,
289 * msg and status fields. The per-msgcode reply structure
290 * will contain valid data.
294 /* If there was reply_payload, how much was recevied ? */
295 uint32_t reply_payload_rcv_len;
298 struct fc_bsg_host_vendor_reply vendor_reply;
300 struct fc_bsg_ctels_reply ctels_reply;
305 #endif /* SCSI_BSG_FC_H */