/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */1/*2* FC Transport BSG Interface3*4* Copyright (C) 2008 James Smart, Emulex Corporation5*/67#ifndef SCSI_BSG_FC_H8#define SCSI_BSG_FC_H910#include <linux/types.h>1112/*13* This file intended to be included by both kernel and user space14*/1516/*17* FC Transport SGIO v4 BSG Message Support18*/1920/* Default BSG request timeout (in seconds) */21#define FC_DEFAULT_BSG_TIMEOUT (10 * HZ)222324/*25* Request Message Codes supported by the FC Transport26*/2728/* define the class masks for the message codes */29#define FC_BSG_CLS_MASK 0xF0000000 /* find object class */30#define FC_BSG_HST_MASK 0x80000000 /* fc host class */31#define FC_BSG_RPT_MASK 0x40000000 /* fc rport class */3233/* fc_host Message Codes */34#define FC_BSG_HST_ADD_RPORT (FC_BSG_HST_MASK | 0x00000001)35#define FC_BSG_HST_DEL_RPORT (FC_BSG_HST_MASK | 0x00000002)36#define FC_BSG_HST_ELS_NOLOGIN (FC_BSG_HST_MASK | 0x00000003)37#define FC_BSG_HST_CT (FC_BSG_HST_MASK | 0x00000004)38#define FC_BSG_HST_VENDOR (FC_BSG_HST_MASK | 0x000000FF)3940/* fc_rport Message Codes */41#define FC_BSG_RPT_ELS (FC_BSG_RPT_MASK | 0x00000001)42#define FC_BSG_RPT_CT (FC_BSG_RPT_MASK | 0x00000002)43444546/*47* FC Address Identifiers in Message Structures :48*49* Whenever a command payload contains a FC Address Identifier50* (aka port_id), the value is effectively in big-endian51* order, thus the array elements are decoded as follows:52* element [0] is bits 23:16 of the FC Address Identifier53* element [1] is bits 15:8 of the FC Address Identifier54* element [2] is bits 7:0 of the FC Address Identifier55*/565758/*59* FC Host Messages60*/6162/* FC_BSG_HST_ADDR_PORT : */6364/* Request:65* This message requests the FC host to login to the remote port66* at the specified N_Port_Id. The remote port is to be enumerated67* with the transport upon completion of the login.68*/69struct fc_bsg_host_add_rport {70__u8 reserved;7172/* FC Address Identier of the remote port to login to */73__u8 port_id[3];74};7576/* Response:77* There is no additional response data - fc_bsg_reply->result is sufficient78*/798081/* FC_BSG_HST_DEL_RPORT : */8283/* Request:84* This message requests the FC host to remove an enumerated85* remote port and to terminate the login to it.86*87* Note: The driver is free to reject this request if it desires to88* remain logged in with the remote port.89*/90struct fc_bsg_host_del_rport {91__u8 reserved;9293/* FC Address Identier of the remote port to logout of */94__u8 port_id[3];95};9697/* Response:98* There is no additional response data - fc_bsg_reply->result is sufficient99*/100101102/* FC_BSG_HST_ELS_NOLOGIN : */103104/* Request:105* This message requests the FC_Host to send an ELS to a specific106* N_Port_ID. The host does not need to log into the remote port,107* nor does it need to enumerate the rport for further traffic108* (although, the FC host is free to do so if it desires).109*/110struct fc_bsg_host_els {111/*112* ELS Command Code being sent (must be the same as byte 0113* of the payload)114*/115__u8 command_code;116117/* FC Address Identier of the remote port to send the ELS to */118__u8 port_id[3];119};120121/* Response:122*/123/* fc_bsg_ctels_reply->status values */124#define FC_CTELS_STATUS_OK 0x00000000125#define FC_CTELS_STATUS_REJECT 0x00000001126#define FC_CTELS_STATUS_P_RJT 0x00000002127#define FC_CTELS_STATUS_F_RJT 0x00000003128#define FC_CTELS_STATUS_P_BSY 0x00000004129#define FC_CTELS_STATUS_F_BSY 0x00000006130struct fc_bsg_ctels_reply {131/*132* Note: An ELS LS_RJT may be reported in 2 ways:133* a) A status of FC_CTELS_STATUS_OK is returned. The caller134* is to look into the ELS receive payload to determine135* LS_ACC or LS_RJT (by contents of word 0). The reject136* data will be in word 1.137* b) A status of FC_CTELS_STATUS_REJECT is returned, The138* rjt_data field will contain valid data.139*140* Note: ELS LS_ACC is determined by an FC_CTELS_STATUS_OK, and141* the receive payload word 0 indicates LS_ACC142* (e.g. value is 0x02xxxxxx).143*144* Note: Similarly, a CT Reject may be reported in 2 ways:145* a) A status of FC_CTELS_STATUS_OK is returned. The caller146* is to look into the CT receive payload to determine147* Accept or Reject (by contents of word 2). The reject148* data will be in word 3.149* b) A status of FC_CTELS_STATUS_REJECT is returned, The150* rjt_data field will contain valid data.151*152* Note: x_RJT/BSY status will indicae that the rjt_data field153* is valid and contains the reason/explanation values.154*/155__u32 status; /* See FC_CTELS_STATUS_xxx */156157/* valid if status is not FC_CTELS_STATUS_OK */158struct {159__u8 action; /* fragment_id for CT REJECT */160__u8 reason_code;161__u8 reason_explanation;162__u8 vendor_unique;163} rjt_data;164};165166167/* FC_BSG_HST_CT : */168169/* Request:170* This message requests that a CT Request be performed with the171* indicated N_Port_ID. The driver is responsible for logging in with172* the fabric and/or N_Port_ID, etc as per FC rules. This request does173* not mandate that the driver must enumerate the destination in the174* transport. The driver is allowed to decide whether to enumerate it,175* and whether to tear it down after the request.176*/177struct fc_bsg_host_ct {178__u8 reserved;179180/* FC Address Identier of the remote port to send the ELS to */181__u8 port_id[3];182183/*184* We need words 0-2 of the generic preamble for the LLD's185*/186__u32 preamble_word0; /* revision & IN_ID */187__u32 preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */188__u32 preamble_word2; /* Cmd Code, Max Size */189190};191/* Response:192*193* The reply structure is an fc_bsg_ctels_reply structure194*/195196197/* FC_BSG_HST_VENDOR : */198199/* Request:200* Note: When specifying vendor_id, be sure to read the Vendor Type and ID201* formatting requirements specified in scsi_netlink.h202*/203struct fc_bsg_host_vendor {204/*205* Identifies the vendor that the message is formatted for. This206* should be the recipient of the message.207*/208__u64 vendor_id;209210/* start of vendor command area */211__u32 vendor_cmd[];212};213214/* Response:215*/216struct fc_bsg_host_vendor_reply {217/* start of vendor response area */218__DECLARE_FLEX_ARRAY(__u32, vendor_rsp);219};220221222223/*224* FC Remote Port Messages225*/226227/* FC_BSG_RPT_ELS : */228229/* Request:230* This message requests that an ELS be performed with the rport.231*/232struct fc_bsg_rport_els {233/*234* ELS Command Code being sent (must be the same as235* byte 0 of the payload)236*/237__u8 els_code;238};239240/* Response:241*242* The reply structure is an fc_bsg_ctels_reply structure243*/244245246/* FC_BSG_RPT_CT : */247248/* Request:249* This message requests that a CT Request be performed with the rport.250*/251struct fc_bsg_rport_ct {252/*253* We need words 0-2 of the generic preamble for the LLD's254*/255__u32 preamble_word0; /* revision & IN_ID */256__u32 preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */257__u32 preamble_word2; /* Cmd Code, Max Size */258};259/* Response:260*261* The reply structure is an fc_bsg_ctels_reply structure262*/263264265266267/* request (CDB) structure of the sg_io_v4 */268struct fc_bsg_request {269__u32 msgcode;270union {271struct fc_bsg_host_add_rport h_addrport;272struct fc_bsg_host_del_rport h_delrport;273struct fc_bsg_host_els h_els;274struct fc_bsg_host_ct h_ct;275struct fc_bsg_host_vendor h_vendor;276277struct fc_bsg_rport_els r_els;278struct fc_bsg_rport_ct r_ct;279} rqst_data;280} __attribute__((packed));281282283/* response (request sense data) structure of the sg_io_v4 */284struct fc_bsg_reply {285/*286* The completion result. Result exists in two forms:287* if negative, it is an -Exxx system errno value. There will288* be no further reply information supplied.289* else, it's the 4-byte scsi error result, with driver, host,290* msg and status fields. The per-msgcode reply structure291* will contain valid data.292*/293__u32 result;294295/* If there was reply_payload, how much was recevied ? */296__u32 reply_payload_rcv_len;297298union {299struct fc_bsg_host_vendor_reply vendor_reply;300301struct fc_bsg_ctels_reply ctels_reply;302} reply_data;303};304305306#endif /* SCSI_BSG_FC_H */307308309310