/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */1/*2* Copyright(c) 2007 Intel Corporation. All rights reserved.3*4* Maintained at www.Open-FCoE.org5*/67#ifndef _FC_FS_H_8#define _FC_FS_H_910#include <linux/types.h>1112/*13* Fibre Channel Framing and Signalling definitions.14* From T11 FC-FS-2 Rev 0.90 - 9 August 2005.15*/1617/*18* Frame header19*/20struct fc_frame_header {21__u8 fh_r_ctl; /* routing control */22__u8 fh_d_id[3]; /* Destination ID */2324__u8 fh_cs_ctl; /* class of service control / pri */25__u8 fh_s_id[3]; /* Source ID */2627__u8 fh_type; /* see enum fc_fh_type below */28__u8 fh_f_ctl[3]; /* frame control */2930__u8 fh_seq_id; /* sequence ID */31__u8 fh_df_ctl; /* data field control */32__be16 fh_seq_cnt; /* sequence count */3334__be16 fh_ox_id; /* originator exchange ID */35__be16 fh_rx_id; /* responder exchange ID */36__be32 fh_parm_offset; /* parameter or relative offset */37};3839#define FC_FRAME_HEADER_LEN 24 /* expected length of structure */4041#define FC_MAX_PAYLOAD 2112U /* max payload length in bytes */42#define FC_MIN_MAX_PAYLOAD 256U /* lower limit on max payload */4344#define FC_MAX_FRAME (FC_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)45#define FC_MIN_MAX_FRAME (FC_MIN_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)4647/*48* fh_r_ctl - Routing control definitions.49*/50/*51* FC-4 device_data.52*/53enum fc_rctl {54FC_RCTL_DD_UNCAT = 0x00, /* uncategorized information */55FC_RCTL_DD_SOL_DATA = 0x01, /* solicited data */56FC_RCTL_DD_UNSOL_CTL = 0x02, /* unsolicited control */57FC_RCTL_DD_SOL_CTL = 0x03, /* solicited control or reply */58FC_RCTL_DD_UNSOL_DATA = 0x04, /* unsolicited data */59FC_RCTL_DD_DATA_DESC = 0x05, /* data descriptor */60FC_RCTL_DD_UNSOL_CMD = 0x06, /* unsolicited command */61FC_RCTL_DD_CMD_STATUS = 0x07, /* command status */6263#define FC_RCTL_ILS_REQ FC_RCTL_DD_UNSOL_CTL /* ILS request */64#define FC_RCTL_ILS_REP FC_RCTL_DD_SOL_CTL /* ILS reply */6566/*67* Extended Link_Data68*/69FC_RCTL_ELS_REQ = 0x22, /* extended link services request */70FC_RCTL_ELS_REP = 0x23, /* extended link services reply */71FC_RCTL_ELS4_REQ = 0x32, /* FC-4 ELS request */72FC_RCTL_ELS4_REP = 0x33, /* FC-4 ELS reply */73/*74* Optional Extended Headers75*/76FC_RCTL_VFTH = 0x50, /* virtual fabric tagging header */77FC_RCTL_IFRH = 0x51, /* inter-fabric routing header */78FC_RCTL_ENCH = 0x52, /* encapsulation header */79/*80* Basic Link Services fh_r_ctl values.81*/82FC_RCTL_BA_NOP = 0x80, /* basic link service NOP */83FC_RCTL_BA_ABTS = 0x81, /* basic link service abort */84FC_RCTL_BA_RMC = 0x82, /* remove connection */85FC_RCTL_BA_ACC = 0x84, /* basic accept */86FC_RCTL_BA_RJT = 0x85, /* basic reject */87FC_RCTL_BA_PRMT = 0x86, /* dedicated connection preempted */88/*89* Link Control Information.90*/91FC_RCTL_ACK_1 = 0xc0, /* acknowledge_1 */92FC_RCTL_ACK_0 = 0xc1, /* acknowledge_0 */93FC_RCTL_P_RJT = 0xc2, /* port reject */94FC_RCTL_F_RJT = 0xc3, /* fabric reject */95FC_RCTL_P_BSY = 0xc4, /* port busy */96FC_RCTL_F_BSY = 0xc5, /* fabric busy to data frame */97FC_RCTL_F_BSYL = 0xc6, /* fabric busy to link control frame */98FC_RCTL_LCR = 0xc7, /* link credit reset */99FC_RCTL_END = 0xc9, /* end */100};101/* incomplete list of definitions */102103/*104* R_CTL names initializer.105* Please keep this matching the above definitions.106*/107#define FC_RCTL_NAMES_INIT { \108[FC_RCTL_DD_UNCAT] = "uncat", \109[FC_RCTL_DD_SOL_DATA] = "sol data", \110[FC_RCTL_DD_UNSOL_CTL] = "unsol ctl", \111[FC_RCTL_DD_SOL_CTL] = "sol ctl/reply", \112[FC_RCTL_DD_UNSOL_DATA] = "unsol data", \113[FC_RCTL_DD_DATA_DESC] = "data desc", \114[FC_RCTL_DD_UNSOL_CMD] = "unsol cmd", \115[FC_RCTL_DD_CMD_STATUS] = "cmd status", \116[FC_RCTL_ELS_REQ] = "ELS req", \117[FC_RCTL_ELS_REP] = "ELS rep", \118[FC_RCTL_ELS4_REQ] = "FC-4 ELS req", \119[FC_RCTL_ELS4_REP] = "FC-4 ELS rep", \120[FC_RCTL_BA_NOP] = "BLS NOP", \121[FC_RCTL_BA_ABTS] = "BLS abort", \122[FC_RCTL_BA_RMC] = "BLS remove connection", \123[FC_RCTL_BA_ACC] = "BLS accept", \124[FC_RCTL_BA_RJT] = "BLS reject", \125[FC_RCTL_BA_PRMT] = "BLS dedicated connection preempted", \126[FC_RCTL_ACK_1] = "LC ACK_1", \127[FC_RCTL_ACK_0] = "LC ACK_0", \128[FC_RCTL_P_RJT] = "LC port reject", \129[FC_RCTL_F_RJT] = "LC fabric reject", \130[FC_RCTL_P_BSY] = "LC port busy", \131[FC_RCTL_F_BSY] = "LC fabric busy to data frame", \132[FC_RCTL_F_BSYL] = "LC fabric busy to link control frame",\133[FC_RCTL_LCR] = "LC link credit reset", \134[FC_RCTL_END] = "LC end", \135}136137/*138* Well-known fabric addresses.139*/140enum fc_well_known_fid {141FC_FID_NONE = 0x000000, /* No destination */142FC_FID_BCAST = 0xffffff, /* broadcast */143FC_FID_FLOGI = 0xfffffe, /* fabric login */144FC_FID_FCTRL = 0xfffffd, /* fabric controller */145FC_FID_DIR_SERV = 0xfffffc, /* directory server */146FC_FID_TIME_SERV = 0xfffffb, /* time server */147FC_FID_MGMT_SERV = 0xfffffa, /* management server */148FC_FID_QOS = 0xfffff9, /* QoS Facilitator */149FC_FID_ALIASES = 0xfffff8, /* alias server (FC-PH2) */150FC_FID_SEC_KEY = 0xfffff7, /* Security key dist. server */151FC_FID_CLOCK = 0xfffff6, /* clock synch server */152FC_FID_MCAST_SERV = 0xfffff5, /* multicast server */153};154155#define FC_FID_WELL_KNOWN_MAX 0xffffff /* highest well-known fabric ID */156#define FC_FID_WELL_KNOWN_BASE 0xfffff5 /* start of well-known fabric ID */157158/*159* Other well-known addresses, outside the above contiguous range.160*/161#define FC_FID_DOM_MGR 0xfffc00 /* domain manager base */162163/*164* Fabric ID bytes.165*/166#define FC_FID_DOMAIN 0167#define FC_FID_PORT 1168#define FC_FID_LINK 2169170/*171* fh_type codes172*/173enum fc_fh_type {174FC_TYPE_BLS = 0x00, /* basic link service */175FC_TYPE_ELS = 0x01, /* extended link service */176FC_TYPE_IP = 0x05, /* IP over FC, RFC 4338 */177FC_TYPE_FCP = 0x08, /* SCSI FCP */178FC_TYPE_CT = 0x20, /* Fibre Channel Services (FC-CT) */179FC_TYPE_ILS = 0x22, /* internal link service */180FC_TYPE_NVME = 0x28, /* FC-NVME */181};182183/*184* FC_TYPE names initializer.185* Please keep this matching the above definitions.186*/187#define FC_TYPE_NAMES_INIT { \188[FC_TYPE_BLS] = "BLS", \189[FC_TYPE_ELS] = "ELS", \190[FC_TYPE_IP] = "IP", \191[FC_TYPE_FCP] = "FCP", \192[FC_TYPE_CT] = "CT", \193[FC_TYPE_ILS] = "ILS", \194[FC_TYPE_NVME] = "NVME", \195}196197/*198* Exchange IDs.199*/200#define FC_XID_UNKNOWN 0xffff /* unknown exchange ID */201#define FC_XID_MIN 0x0 /* supported min exchange ID */202#define FC_XID_MAX 0xfffe /* supported max exchange ID */203204/*205* fh_f_ctl - Frame control flags.206*/207#define FC_FC_EX_CTX (1 << 23) /* sent by responder to exchange */208#define FC_FC_SEQ_CTX (1 << 22) /* sent by responder to sequence */209#define FC_FC_FIRST_SEQ (1 << 21) /* first sequence of this exchange */210#define FC_FC_LAST_SEQ (1 << 20) /* last sequence of this exchange */211#define FC_FC_END_SEQ (1 << 19) /* last frame of sequence */212#define FC_FC_END_CONN (1 << 18) /* end of class 1 connection pending */213#define FC_FC_RES_B17 (1 << 17) /* reserved */214#define FC_FC_SEQ_INIT (1 << 16) /* transfer of sequence initiative */215#define FC_FC_X_ID_REASS (1 << 15) /* exchange ID has been changed */216#define FC_FC_X_ID_INVAL (1 << 14) /* exchange ID invalidated */217218#define FC_FC_ACK_1 (1 << 12) /* 13:12 = 1: ACK_1 expected */219#define FC_FC_ACK_N (2 << 12) /* 13:12 = 2: ACK_N expected */220#define FC_FC_ACK_0 (3 << 12) /* 13:12 = 3: ACK_0 expected */221222#define FC_FC_RES_B11 (1 << 11) /* reserved */223#define FC_FC_RES_B10 (1 << 10) /* reserved */224#define FC_FC_RETX_SEQ (1 << 9) /* retransmitted sequence */225#define FC_FC_UNI_TX (1 << 8) /* unidirectional transmit (class 1) */226#define FC_FC_CONT_SEQ(i) ((i) << 6)227#define FC_FC_ABT_SEQ(i) ((i) << 4)228#define FC_FC_REL_OFF (1 << 3) /* parameter is relative offset */229#define FC_FC_RES2 (1 << 2) /* reserved */230#define FC_FC_FILL(i) ((i) & 3) /* 1:0: bytes of trailing fill */231232/*233* BA_ACC payload.234*/235struct fc_ba_acc {236__u8 ba_seq_id_val; /* SEQ_ID validity */237#define FC_BA_SEQ_ID_VAL 0x80238__u8 ba_seq_id; /* SEQ_ID of seq last deliverable */239__u8 ba_resvd[2]; /* reserved */240__be16 ba_ox_id; /* OX_ID for aborted seq or exch */241__be16 ba_rx_id; /* RX_ID for aborted seq or exch */242__be16 ba_low_seq_cnt; /* low SEQ_CNT of aborted seq */243__be16 ba_high_seq_cnt; /* high SEQ_CNT of aborted seq */244};245246/*247* BA_RJT: Basic Reject payload.248*/249struct fc_ba_rjt {250__u8 br_resvd; /* reserved */251__u8 br_reason; /* reason code */252__u8 br_explan; /* reason explanation */253__u8 br_vendor; /* vendor unique code */254};255256/*257* BA_RJT reason codes.258* From FS-2.259*/260enum fc_ba_rjt_reason {261FC_BA_RJT_NONE = 0, /* in software this means no reject */262FC_BA_RJT_INVL_CMD = 0x01, /* invalid command code */263FC_BA_RJT_LOG_ERR = 0x03, /* logical error */264FC_BA_RJT_LOG_BUSY = 0x05, /* logical busy */265FC_BA_RJT_PROTO_ERR = 0x07, /* protocol error */266FC_BA_RJT_UNABLE = 0x09, /* unable to perform request */267FC_BA_RJT_VENDOR = 0xff, /* vendor-specific (see br_vendor) */268};269270/*271* BA_RJT reason code explanations.272*/273enum fc_ba_rjt_explan {274FC_BA_RJT_EXP_NONE = 0x00, /* no additional expanation */275FC_BA_RJT_INV_XID = 0x03, /* invalid OX_ID-RX_ID combination */276FC_BA_RJT_ABT = 0x05, /* sequence aborted, no seq info */277};278279/*280* P_RJT or F_RJT: Port Reject or Fabric Reject parameter field.281*/282struct fc_pf_rjt {283__u8 rj_action; /* reserved */284__u8 rj_reason; /* reason code */285__u8 rj_resvd; /* reserved */286__u8 rj_vendor; /* vendor unique code */287};288289/*290* P_RJT and F_RJT reject reason codes.291*/292enum fc_pf_rjt_reason {293FC_RJT_NONE = 0, /* non-reject (reserved by standard) */294FC_RJT_INVL_DID = 0x01, /* invalid destination ID */295FC_RJT_INVL_SID = 0x02, /* invalid source ID */296FC_RJT_P_UNAV_T = 0x03, /* port unavailable, temporary */297FC_RJT_P_UNAV = 0x04, /* port unavailable, permanent */298FC_RJT_CLS_UNSUP = 0x05, /* class not supported */299FC_RJT_DEL_USAGE = 0x06, /* delimiter usage error */300FC_RJT_TYPE_UNSUP = 0x07, /* type not supported */301FC_RJT_LINK_CTL = 0x08, /* invalid link control */302FC_RJT_R_CTL = 0x09, /* invalid R_CTL field */303FC_RJT_F_CTL = 0x0a, /* invalid F_CTL field */304FC_RJT_OX_ID = 0x0b, /* invalid originator exchange ID */305FC_RJT_RX_ID = 0x0c, /* invalid responder exchange ID */306FC_RJT_SEQ_ID = 0x0d, /* invalid sequence ID */307FC_RJT_DF_CTL = 0x0e, /* invalid DF_CTL field */308FC_RJT_SEQ_CNT = 0x0f, /* invalid SEQ_CNT field */309FC_RJT_PARAM = 0x10, /* invalid parameter field */310FC_RJT_EXCH_ERR = 0x11, /* exchange error */311FC_RJT_PROTO = 0x12, /* protocol error */312FC_RJT_LEN = 0x13, /* incorrect length */313FC_RJT_UNEXP_ACK = 0x14, /* unexpected ACK */314FC_RJT_FAB_CLASS = 0x15, /* class unsupported by fabric entity */315FC_RJT_LOGI_REQ = 0x16, /* login required */316FC_RJT_SEQ_XS = 0x17, /* excessive sequences attempted */317FC_RJT_EXCH_EST = 0x18, /* unable to establish exchange */318FC_RJT_FAB_UNAV = 0x1a, /* fabric unavailable */319FC_RJT_VC_ID = 0x1b, /* invalid VC_ID (class 4) */320FC_RJT_CS_CTL = 0x1c, /* invalid CS_CTL field */321FC_RJT_INSUF_RES = 0x1d, /* insuff. resources for VC (Class 4) */322FC_RJT_INVL_CLS = 0x1f, /* invalid class of service */323FC_RJT_PREEMT_RJT = 0x20, /* preemption request rejected */324FC_RJT_PREEMT_DIS = 0x21, /* preemption not enabled */325FC_RJT_MCAST_ERR = 0x22, /* multicast error */326FC_RJT_MCAST_ET = 0x23, /* multicast error terminate */327FC_RJT_PRLI_REQ = 0x24, /* process login required */328FC_RJT_INVL_ATT = 0x25, /* invalid attachment */329FC_RJT_VENDOR = 0xff, /* vendor specific reject */330};331332/* default timeout values */333334#define FC_DEF_E_D_TOV 2000UL335#define FC_DEF_R_A_TOV 10000UL336337#endif /* _FC_FS_H_ */338339340