1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
3 * FC Transport BSG Interface
5 * Copyright (C) 2008 James Smart, Emulex Corporation
11 #include <linux/types.h>
14 * This file intended to be included by both kernel and user space
18 * FC Transport SGIO v4 BSG Message Support
21 /* Default BSG request timeout (in seconds) */
22 #define FC_DEFAULT_BSG_TIMEOUT (10 * HZ)
26 * Request Message Codes supported by the FC Transport
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 */
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)
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)
48 * FC Address Identifiers in Message Structures :
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
63 /* FC_BSG_HST_ADDR_PORT : */
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.
70 struct fc_bsg_host_add_rport
{
73 /* FC Address Identier of the remote port to login to */
78 * There is no additional response data - fc_bsg_reply->result is sufficient
82 /* FC_BSG_HST_DEL_RPORT : */
85 * This message requests the FC host to remove an enumerated
86 * remote port and to terminate the login to it.
88 * Note: The driver is free to reject this request if it desires to
89 * remain logged in with the remote port.
91 struct fc_bsg_host_del_rport
{
94 /* FC Address Identier of the remote port to logout of */
99 * There is no additional response data - fc_bsg_reply->result is sufficient
103 /* FC_BSG_HST_ELS_NOLOGIN : */
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).
111 struct fc_bsg_host_els
{
113 * ELS Command Code being sent (must be the same as byte 0
118 /* FC Address Identier of the remote port to send the ELS to */
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
{
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.
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).
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.
153 * Note: x_RJT/BSY status will indicae that the rjt_data field
154 * is valid and contains the reason/explanation values.
156 __u32 status
; /* See FC_CTELS_STATUS_xxx */
158 /* valid if status is not FC_CTELS_STATUS_OK */
160 __u8 action
; /* fragment_id for CT REJECT */
162 __u8 reason_explanation
;
168 /* FC_BSG_HST_CT : */
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.
178 struct fc_bsg_host_ct
{
181 /* FC Address Identier of the remote port to send the ELS to */
185 * We need words 0-2 of the generic preamble for the LLD's
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 */
194 * The reply structure is an fc_bsg_ctels_reply structure
198 /* FC_BSG_HST_VENDOR : */
201 * Note: When specifying vendor_id, be sure to read the Vendor Type and ID
202 * formatting requirements specified in scsi_netlink.h
204 struct fc_bsg_host_vendor
{
206 * Identifies the vendor that the message is formatted for. This
207 * should be the recipient of the message.
211 /* start of vendor command area */
217 struct fc_bsg_host_vendor_reply
{
218 /* start of vendor response area */
225 * FC Remote Port Messages
228 /* FC_BSG_RPT_ELS : */
231 * This message requests that an ELS be performed with the rport.
233 struct fc_bsg_rport_els
{
235 * ELS Command Code being sent (must be the same as
236 * byte 0 of the payload)
243 * The reply structure is an fc_bsg_ctels_reply structure
247 /* FC_BSG_RPT_CT : */
250 * This message requests that a CT Request be performed with the rport.
252 struct fc_bsg_rport_ct
{
254 * We need words 0-2 of the generic preamble for the LLD's
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 */
262 * The reply structure is an fc_bsg_ctels_reply structure
268 /* request (CDB) structure of the sg_io_v4 */
269 struct fc_bsg_request
{
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
;
278 struct fc_bsg_rport_els r_els
;
279 struct fc_bsg_rport_ct r_ct
;
281 } __attribute__((packed
));
284 /* response (request sense data) structure of the sg_io_v4 */
285 struct fc_bsg_reply
{
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.
296 /* If there was reply_payload, how much was recevied ? */
297 __u32 reply_payload_rcv_len
;
300 struct fc_bsg_host_vendor_reply vendor_reply
;
302 struct fc_bsg_ctels_reply ctels_reply
;
307 #endif /* SCSI_BSG_FC_H */