/*1* FC Transport BSG Interface2*3* Copyright (C) 2008 James Smart, Emulex Corporation4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License16* along with this program; if not, write to the Free Software17* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18*19*/2021#ifndef SCSI_BSG_FC_H22#define SCSI_BSG_FC_H2324/*25* This file intended to be included by both kernel and user space26*/2728#include <scsi/scsi.h>2930/*31* FC Transport SGIO v4 BSG Message Support32*/3334/* Default BSG request timeout (in seconds) */35#define FC_DEFAULT_BSG_TIMEOUT (10 * HZ)363738/*39* Request Message Codes supported by the FC Transport40*/4142/* define the class masks for the message codes */43#define FC_BSG_CLS_MASK 0xF0000000 /* find object class */44#define FC_BSG_HST_MASK 0x80000000 /* fc host class */45#define FC_BSG_RPT_MASK 0x40000000 /* fc rport class */4647/* fc_host Message Codes */48#define FC_BSG_HST_ADD_RPORT (FC_BSG_HST_MASK | 0x00000001)49#define FC_BSG_HST_DEL_RPORT (FC_BSG_HST_MASK | 0x00000002)50#define FC_BSG_HST_ELS_NOLOGIN (FC_BSG_HST_MASK | 0x00000003)51#define FC_BSG_HST_CT (FC_BSG_HST_MASK | 0x00000004)52#define FC_BSG_HST_VENDOR (FC_BSG_HST_MASK | 0x000000FF)5354/* fc_rport Message Codes */55#define FC_BSG_RPT_ELS (FC_BSG_RPT_MASK | 0x00000001)56#define FC_BSG_RPT_CT (FC_BSG_RPT_MASK | 0x00000002)57585960/*61* FC Address Identifiers in Message Structures :62*63* Whenever a command payload contains a FC Address Identifier64* (aka port_id), the value is effectively in big-endian65* order, thus the array elements are decoded as follows:66* element [0] is bits 23:16 of the FC Address Identifier67* element [1] is bits 15:8 of the FC Address Identifier68* element [2] is bits 7:0 of the FC Address Identifier69*/707172/*73* FC Host Messages74*/7576/* FC_BSG_HST_ADDR_PORT : */7778/* Request:79* This message requests the FC host to login to the remote port80* at the specified N_Port_Id. The remote port is to be enumerated81* with the transport upon completion of the login.82*/83struct fc_bsg_host_add_rport {84uint8_t reserved;8586/* FC Address Identier of the remote port to login to */87uint8_t port_id[3];88};8990/* Response:91* There is no additional response data - fc_bsg_reply->result is sufficient92*/939495/* FC_BSG_HST_DEL_RPORT : */9697/* Request:98* This message requests the FC host to remove an enumerated99* remote port and to terminate the login to it.100*101* Note: The driver is free to reject this request if it desires to102* remain logged in with the remote port.103*/104struct fc_bsg_host_del_rport {105uint8_t reserved;106107/* FC Address Identier of the remote port to logout of */108uint8_t port_id[3];109};110111/* Response:112* There is no additional response data - fc_bsg_reply->result is sufficient113*/114115116/* FC_BSG_HST_ELS_NOLOGIN : */117118/* Request:119* This message requests the FC_Host to send an ELS to a specific120* N_Port_ID. The host does not need to log into the remote port,121* nor does it need to enumerate the rport for further traffic122* (although, the FC host is free to do so if it desires).123*/124struct fc_bsg_host_els {125/*126* ELS Command Code being sent (must be the same as byte 0127* of the payload)128*/129uint8_t command_code;130131/* FC Address Identier of the remote port to send the ELS to */132uint8_t port_id[3];133};134135/* Response:136*/137/* fc_bsg_ctels_reply->status values */138#define FC_CTELS_STATUS_OK 0x00000000139#define FC_CTELS_STATUS_REJECT 0x00000001140#define FC_CTELS_STATUS_P_RJT 0x00000002141#define FC_CTELS_STATUS_F_RJT 0x00000003142#define FC_CTELS_STATUS_P_BSY 0x00000004143#define FC_CTELS_STATUS_F_BSY 0x00000006144struct fc_bsg_ctels_reply {145/*146* Note: An ELS LS_RJT may be reported in 2 ways:147* a) A status of FC_CTELS_STATUS_OK is returned. The caller148* is to look into the ELS receive payload to determine149* LS_ACC or LS_RJT (by contents of word 0). The reject150* data will be in word 1.151* b) A status of FC_CTELS_STATUS_REJECT is returned, The152* rjt_data field will contain valid data.153*154* Note: ELS LS_ACC is determined by an FC_CTELS_STATUS_OK, and155* the receive payload word 0 indicates LS_ACC156* (e.g. value is 0x02xxxxxx).157*158* Note: Similarly, a CT Reject may be reported in 2 ways:159* a) A status of FC_CTELS_STATUS_OK is returned. The caller160* is to look into the CT receive payload to determine161* Accept or Reject (by contents of word 2). The reject162* data will be in word 3.163* b) A status of FC_CTELS_STATUS_REJECT is returned, The164* rjt_data field will contain valid data.165*166* Note: x_RJT/BSY status will indicae that the rjt_data field167* is valid and contains the reason/explanation values.168*/169uint32_t status; /* See FC_CTELS_STATUS_xxx */170171/* valid if status is not FC_CTELS_STATUS_OK */172struct {173uint8_t action; /* fragment_id for CT REJECT */174uint8_t reason_code;175uint8_t reason_explanation;176uint8_t vendor_unique;177} rjt_data;178};179180181/* FC_BSG_HST_CT : */182183/* Request:184* This message requests that a CT Request be performed with the185* indicated N_Port_ID. The driver is responsible for logging in with186* the fabric and/or N_Port_ID, etc as per FC rules. This request does187* not mandate that the driver must enumerate the destination in the188* transport. The driver is allowed to decide whether to enumerate it,189* and whether to tear it down after the request.190*/191struct fc_bsg_host_ct {192uint8_t reserved;193194/* FC Address Identier of the remote port to send the ELS to */195uint8_t port_id[3];196197/*198* We need words 0-2 of the generic preamble for the LLD's199*/200uint32_t preamble_word0; /* revision & IN_ID */201uint32_t preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */202uint32_t preamble_word2; /* Cmd Code, Max Size */203204};205/* Response:206*207* The reply structure is an fc_bsg_ctels_reply structure208*/209210211/* FC_BSG_HST_VENDOR : */212213/* Request:214* Note: When specifying vendor_id, be sure to read the Vendor Type and ID215* formatting requirements specified in scsi_netlink.h216*/217struct fc_bsg_host_vendor {218/*219* Identifies the vendor that the message is formatted for. This220* should be the recipient of the message.221*/222uint64_t vendor_id;223224/* start of vendor command area */225uint32_t vendor_cmd[0];226};227228/* Response:229*/230struct fc_bsg_host_vendor_reply {231/* start of vendor response area */232uint32_t vendor_rsp[0];233};234235236237/*238* FC Remote Port Messages239*/240241/* FC_BSG_RPT_ELS : */242243/* Request:244* This message requests that an ELS be performed with the rport.245*/246struct fc_bsg_rport_els {247/*248* ELS Command Code being sent (must be the same as249* byte 0 of the payload)250*/251uint8_t els_code;252};253254/* Response:255*256* The reply structure is an fc_bsg_ctels_reply structure257*/258259260/* FC_BSG_RPT_CT : */261262/* Request:263* This message requests that a CT Request be performed with the rport.264*/265struct fc_bsg_rport_ct {266/*267* We need words 0-2 of the generic preamble for the LLD's268*/269uint32_t preamble_word0; /* revision & IN_ID */270uint32_t preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */271uint32_t preamble_word2; /* Cmd Code, Max Size */272};273/* Response:274*275* The reply structure is an fc_bsg_ctels_reply structure276*/277278279280281/* request (CDB) structure of the sg_io_v4 */282struct fc_bsg_request {283uint32_t msgcode;284union {285struct fc_bsg_host_add_rport h_addrport;286struct fc_bsg_host_del_rport h_delrport;287struct fc_bsg_host_els h_els;288struct fc_bsg_host_ct h_ct;289struct fc_bsg_host_vendor h_vendor;290291struct fc_bsg_rport_els r_els;292struct fc_bsg_rport_ct r_ct;293} rqst_data;294} __attribute__((packed));295296297/* response (request sense data) structure of the sg_io_v4 */298struct fc_bsg_reply {299/*300* The completion result. Result exists in two forms:301* if negative, it is an -Exxx system errno value. There will302* be no further reply information supplied.303* else, it's the 4-byte scsi error result, with driver, host,304* msg and status fields. The per-msgcode reply structure305* will contain valid data.306*/307uint32_t result;308309/* If there was reply_payload, how much was recevied ? */310uint32_t reply_payload_rcv_len;311312union {313struct fc_bsg_host_vendor_reply vendor_reply;314315struct fc_bsg_ctels_reply ctels_reply;316} reply_data;317};318319320#endif /* SCSI_BSG_FC_H */321322323324