/*1* Copyright(c) 2007 Intel Corporation. All rights reserved.2*3* This program is free software; you can redistribute it and/or modify it4* under the terms and conditions of the GNU General Public License,5* version 2, as published by the Free Software Foundation.6*7* This program is distributed in the hope it will be useful, but WITHOUT8* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or9* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for10* more details.11*12* You should have received a copy of the GNU General Public License along with13* this program; if not, write to the Free Software Foundation, Inc.,14* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.15*16* Maintained at www.Open-FCoE.org17*/1819#ifndef _FC_FS_H_20#define _FC_FS_H_2122#include <linux/types.h>2324/*25* Fibre Channel Framing and Signalling definitions.26* From T11 FC-FS-2 Rev 0.90 - 9 August 2005.27*/2829/*30* Frame header31*/32struct fc_frame_header {33__u8 fh_r_ctl; /* routing control */34__u8 fh_d_id[3]; /* Destination ID */3536__u8 fh_cs_ctl; /* class of service control / pri */37__u8 fh_s_id[3]; /* Source ID */3839__u8 fh_type; /* see enum fc_fh_type below */40__u8 fh_f_ctl[3]; /* frame control */4142__u8 fh_seq_id; /* sequence ID */43__u8 fh_df_ctl; /* data field control */44__be16 fh_seq_cnt; /* sequence count */4546__be16 fh_ox_id; /* originator exchange ID */47__be16 fh_rx_id; /* responder exchange ID */48__be32 fh_parm_offset; /* parameter or relative offset */49};5051#define FC_FRAME_HEADER_LEN 24 /* expected length of structure */5253#define FC_MAX_PAYLOAD 2112U /* max payload length in bytes */54#define FC_MIN_MAX_PAYLOAD 256U /* lower limit on max payload */5556#define FC_MAX_FRAME (FC_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)57#define FC_MIN_MAX_FRAME (FC_MIN_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)5859/*60* fh_r_ctl - Routing control definitions.61*/62/*63* FC-4 device_data.64*/65enum fc_rctl {66FC_RCTL_DD_UNCAT = 0x00, /* uncategorized information */67FC_RCTL_DD_SOL_DATA = 0x01, /* solicited data */68FC_RCTL_DD_UNSOL_CTL = 0x02, /* unsolicited control */69FC_RCTL_DD_SOL_CTL = 0x03, /* solicited control or reply */70FC_RCTL_DD_UNSOL_DATA = 0x04, /* unsolicited data */71FC_RCTL_DD_DATA_DESC = 0x05, /* data descriptor */72FC_RCTL_DD_UNSOL_CMD = 0x06, /* unsolicited command */73FC_RCTL_DD_CMD_STATUS = 0x07, /* command status */7475#define FC_RCTL_ILS_REQ FC_RCTL_DD_UNSOL_CTL /* ILS request */76#define FC_RCTL_ILS_REP FC_RCTL_DD_SOL_CTL /* ILS reply */7778/*79* Extended Link_Data80*/81FC_RCTL_ELS_REQ = 0x22, /* extended link services request */82FC_RCTL_ELS_REP = 0x23, /* extended link services reply */83FC_RCTL_ELS4_REQ = 0x32, /* FC-4 ELS request */84FC_RCTL_ELS4_REP = 0x33, /* FC-4 ELS reply */85/*86* Optional Extended Headers87*/88FC_RCTL_VFTH = 0x50, /* virtual fabric tagging header */89FC_RCTL_IFRH = 0x51, /* inter-fabric routing header */90FC_RCTL_ENCH = 0x52, /* encapsulation header */91/*92* Basic Link Services fh_r_ctl values.93*/94FC_RCTL_BA_NOP = 0x80, /* basic link service NOP */95FC_RCTL_BA_ABTS = 0x81, /* basic link service abort */96FC_RCTL_BA_RMC = 0x82, /* remove connection */97FC_RCTL_BA_ACC = 0x84, /* basic accept */98FC_RCTL_BA_RJT = 0x85, /* basic reject */99FC_RCTL_BA_PRMT = 0x86, /* dedicated connection preempted */100/*101* Link Control Information.102*/103FC_RCTL_ACK_1 = 0xc0, /* acknowledge_1 */104FC_RCTL_ACK_0 = 0xc1, /* acknowledge_0 */105FC_RCTL_P_RJT = 0xc2, /* port reject */106FC_RCTL_F_RJT = 0xc3, /* fabric reject */107FC_RCTL_P_BSY = 0xc4, /* port busy */108FC_RCTL_F_BSY = 0xc5, /* fabric busy to data frame */109FC_RCTL_F_BSYL = 0xc6, /* fabric busy to link control frame */110FC_RCTL_LCR = 0xc7, /* link credit reset */111FC_RCTL_END = 0xc9, /* end */112};113/* incomplete list of definitions */114115/*116* R_CTL names initializer.117* Please keep this matching the above definitions.118*/119#define FC_RCTL_NAMES_INIT { \120[FC_RCTL_DD_UNCAT] = "uncat", \121[FC_RCTL_DD_SOL_DATA] = "sol data", \122[FC_RCTL_DD_UNSOL_CTL] = "unsol ctl", \123[FC_RCTL_DD_SOL_CTL] = "sol ctl/reply", \124[FC_RCTL_DD_UNSOL_DATA] = "unsol data", \125[FC_RCTL_DD_DATA_DESC] = "data desc", \126[FC_RCTL_DD_UNSOL_CMD] = "unsol cmd", \127[FC_RCTL_DD_CMD_STATUS] = "cmd status", \128[FC_RCTL_ELS_REQ] = "ELS req", \129[FC_RCTL_ELS_REP] = "ELS rep", \130[FC_RCTL_ELS4_REQ] = "FC-4 ELS req", \131[FC_RCTL_ELS4_REP] = "FC-4 ELS rep", \132[FC_RCTL_BA_NOP] = "BLS NOP", \133[FC_RCTL_BA_ABTS] = "BLS abort", \134[FC_RCTL_BA_RMC] = "BLS remove connection", \135[FC_RCTL_BA_ACC] = "BLS accept", \136[FC_RCTL_BA_RJT] = "BLS reject", \137[FC_RCTL_BA_PRMT] = "BLS dedicated connection preempted", \138[FC_RCTL_ACK_1] = "LC ACK_1", \139[FC_RCTL_ACK_0] = "LC ACK_0", \140[FC_RCTL_P_RJT] = "LC port reject", \141[FC_RCTL_F_RJT] = "LC fabric reject", \142[FC_RCTL_P_BSY] = "LC port busy", \143[FC_RCTL_F_BSY] = "LC fabric busy to data frame", \144[FC_RCTL_F_BSYL] = "LC fabric busy to link control frame",\145[FC_RCTL_LCR] = "LC link credit reset", \146[FC_RCTL_END] = "LC end", \147}148149/*150* Well-known fabric addresses.151*/152enum fc_well_known_fid {153FC_FID_NONE = 0x000000, /* No destination */154FC_FID_BCAST = 0xffffff, /* broadcast */155FC_FID_FLOGI = 0xfffffe, /* fabric login */156FC_FID_FCTRL = 0xfffffd, /* fabric controller */157FC_FID_DIR_SERV = 0xfffffc, /* directory server */158FC_FID_TIME_SERV = 0xfffffb, /* time server */159FC_FID_MGMT_SERV = 0xfffffa, /* management server */160FC_FID_QOS = 0xfffff9, /* QoS Facilitator */161FC_FID_ALIASES = 0xfffff8, /* alias server (FC-PH2) */162FC_FID_SEC_KEY = 0xfffff7, /* Security key dist. server */163FC_FID_CLOCK = 0xfffff6, /* clock synch server */164FC_FID_MCAST_SERV = 0xfffff5, /* multicast server */165};166167#define FC_FID_WELL_KNOWN_MAX 0xffffff /* highest well-known fabric ID */168#define FC_FID_WELL_KNOWN_BASE 0xfffff5 /* start of well-known fabric ID */169170/*171* Other well-known addresses, outside the above contiguous range.172*/173#define FC_FID_DOM_MGR 0xfffc00 /* domain manager base */174175/*176* Fabric ID bytes.177*/178#define FC_FID_DOMAIN 0179#define FC_FID_PORT 1180#define FC_FID_LINK 2181182/*183* fh_type codes184*/185enum fc_fh_type {186FC_TYPE_BLS = 0x00, /* basic link service */187FC_TYPE_ELS = 0x01, /* extended link service */188FC_TYPE_IP = 0x05, /* IP over FC, RFC 4338 */189FC_TYPE_FCP = 0x08, /* SCSI FCP */190FC_TYPE_CT = 0x20, /* Fibre Channel Services (FC-CT) */191FC_TYPE_ILS = 0x22, /* internal link service */192};193194/*195* FC_TYPE names initializer.196* Please keep this matching the above definitions.197*/198#define FC_TYPE_NAMES_INIT { \199[FC_TYPE_BLS] = "BLS", \200[FC_TYPE_ELS] = "ELS", \201[FC_TYPE_IP] = "IP", \202[FC_TYPE_FCP] = "FCP", \203[FC_TYPE_CT] = "CT", \204[FC_TYPE_ILS] = "ILS", \205}206207/*208* Exchange IDs.209*/210#define FC_XID_UNKNOWN 0xffff /* unknown exchange ID */211#define FC_XID_MIN 0x0 /* supported min exchange ID */212#define FC_XID_MAX 0xfffe /* supported max exchange ID */213214/*215* fh_f_ctl - Frame control flags.216*/217#define FC_FC_EX_CTX (1 << 23) /* sent by responder to exchange */218#define FC_FC_SEQ_CTX (1 << 22) /* sent by responder to sequence */219#define FC_FC_FIRST_SEQ (1 << 21) /* first sequence of this exchange */220#define FC_FC_LAST_SEQ (1 << 20) /* last sequence of this exchange */221#define FC_FC_END_SEQ (1 << 19) /* last frame of sequence */222#define FC_FC_END_CONN (1 << 18) /* end of class 1 connection pending */223#define FC_FC_RES_B17 (1 << 17) /* reserved */224#define FC_FC_SEQ_INIT (1 << 16) /* transfer of sequence initiative */225#define FC_FC_X_ID_REASS (1 << 15) /* exchange ID has been changed */226#define FC_FC_X_ID_INVAL (1 << 14) /* exchange ID invalidated */227228#define FC_FC_ACK_1 (1 << 12) /* 13:12 = 1: ACK_1 expected */229#define FC_FC_ACK_N (2 << 12) /* 13:12 = 2: ACK_N expected */230#define FC_FC_ACK_0 (3 << 12) /* 13:12 = 3: ACK_0 expected */231232#define FC_FC_RES_B11 (1 << 11) /* reserved */233#define FC_FC_RES_B10 (1 << 10) /* reserved */234#define FC_FC_RETX_SEQ (1 << 9) /* retransmitted sequence */235#define FC_FC_UNI_TX (1 << 8) /* unidirectional transmit (class 1) */236#define FC_FC_CONT_SEQ(i) ((i) << 6)237#define FC_FC_ABT_SEQ(i) ((i) << 4)238#define FC_FC_REL_OFF (1 << 3) /* parameter is relative offset */239#define FC_FC_RES2 (1 << 2) /* reserved */240#define FC_FC_FILL(i) ((i) & 3) /* 1:0: bytes of trailing fill */241242/*243* BA_ACC payload.244*/245struct fc_ba_acc {246__u8 ba_seq_id_val; /* SEQ_ID validity */247#define FC_BA_SEQ_ID_VAL 0x80248__u8 ba_seq_id; /* SEQ_ID of seq last deliverable */249__u8 ba_resvd[2]; /* reserved */250__be16 ba_ox_id; /* OX_ID for aborted seq or exch */251__be16 ba_rx_id; /* RX_ID for aborted seq or exch */252__be16 ba_low_seq_cnt; /* low SEQ_CNT of aborted seq */253__be16 ba_high_seq_cnt; /* high SEQ_CNT of aborted seq */254};255256/*257* BA_RJT: Basic Reject payload.258*/259struct fc_ba_rjt {260__u8 br_resvd; /* reserved */261__u8 br_reason; /* reason code */262__u8 br_explan; /* reason explanation */263__u8 br_vendor; /* vendor unique code */264};265266/*267* BA_RJT reason codes.268* From FS-2.269*/270enum fc_ba_rjt_reason {271FC_BA_RJT_NONE = 0, /* in software this means no reject */272FC_BA_RJT_INVL_CMD = 0x01, /* invalid command code */273FC_BA_RJT_LOG_ERR = 0x03, /* logical error */274FC_BA_RJT_LOG_BUSY = 0x05, /* logical busy */275FC_BA_RJT_PROTO_ERR = 0x07, /* protocol error */276FC_BA_RJT_UNABLE = 0x09, /* unable to perform request */277FC_BA_RJT_VENDOR = 0xff, /* vendor-specific (see br_vendor) */278};279280/*281* BA_RJT reason code explanations.282*/283enum fc_ba_rjt_explan {284FC_BA_RJT_EXP_NONE = 0x00, /* no additional expanation */285FC_BA_RJT_INV_XID = 0x03, /* invalid OX_ID-RX_ID combination */286FC_BA_RJT_ABT = 0x05, /* sequence aborted, no seq info */287};288289/*290* P_RJT or F_RJT: Port Reject or Fabric Reject parameter field.291*/292struct fc_pf_rjt {293__u8 rj_action; /* reserved */294__u8 rj_reason; /* reason code */295__u8 rj_resvd; /* reserved */296__u8 rj_vendor; /* vendor unique code */297};298299/*300* P_RJT and F_RJT reject reason codes.301*/302enum fc_pf_rjt_reason {303FC_RJT_NONE = 0, /* non-reject (reserved by standard) */304FC_RJT_INVL_DID = 0x01, /* invalid destination ID */305FC_RJT_INVL_SID = 0x02, /* invalid source ID */306FC_RJT_P_UNAV_T = 0x03, /* port unavailable, temporary */307FC_RJT_P_UNAV = 0x04, /* port unavailable, permanent */308FC_RJT_CLS_UNSUP = 0x05, /* class not supported */309FC_RJT_DEL_USAGE = 0x06, /* delimiter usage error */310FC_RJT_TYPE_UNSUP = 0x07, /* type not supported */311FC_RJT_LINK_CTL = 0x08, /* invalid link control */312FC_RJT_R_CTL = 0x09, /* invalid R_CTL field */313FC_RJT_F_CTL = 0x0a, /* invalid F_CTL field */314FC_RJT_OX_ID = 0x0b, /* invalid originator exchange ID */315FC_RJT_RX_ID = 0x0c, /* invalid responder exchange ID */316FC_RJT_SEQ_ID = 0x0d, /* invalid sequence ID */317FC_RJT_DF_CTL = 0x0e, /* invalid DF_CTL field */318FC_RJT_SEQ_CNT = 0x0f, /* invalid SEQ_CNT field */319FC_RJT_PARAM = 0x10, /* invalid parameter field */320FC_RJT_EXCH_ERR = 0x11, /* exchange error */321FC_RJT_PROTO = 0x12, /* protocol error */322FC_RJT_LEN = 0x13, /* incorrect length */323FC_RJT_UNEXP_ACK = 0x14, /* unexpected ACK */324FC_RJT_FAB_CLASS = 0x15, /* class unsupported by fabric entity */325FC_RJT_LOGI_REQ = 0x16, /* login required */326FC_RJT_SEQ_XS = 0x17, /* excessive sequences attempted */327FC_RJT_EXCH_EST = 0x18, /* unable to establish exchange */328FC_RJT_FAB_UNAV = 0x1a, /* fabric unavailable */329FC_RJT_VC_ID = 0x1b, /* invalid VC_ID (class 4) */330FC_RJT_CS_CTL = 0x1c, /* invalid CS_CTL field */331FC_RJT_INSUF_RES = 0x1d, /* insuff. resources for VC (Class 4) */332FC_RJT_INVL_CLS = 0x1f, /* invalid class of service */333FC_RJT_PREEMT_RJT = 0x20, /* preemption request rejected */334FC_RJT_PREEMT_DIS = 0x21, /* preemption not enabled */335FC_RJT_MCAST_ERR = 0x22, /* multicast error */336FC_RJT_MCAST_ET = 0x23, /* multicast error terminate */337FC_RJT_PRLI_REQ = 0x24, /* process login required */338FC_RJT_INVL_ATT = 0x25, /* invalid attachment */339FC_RJT_VENDOR = 0xff, /* vendor specific reject */340};341342/* default timeout values */343344#define FC_DEF_E_D_TOV 2000UL345#define FC_DEF_R_A_TOV 10000UL346347#endif /* _FC_FS_H_ */348349350