Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /*
0003  * Copyright(c) 2007 Intel Corporation. All rights reserved.
0004  *
0005  * Maintained at www.Open-FCoE.org
0006  */
0007 
0008 #ifndef _FC_FS_H_
0009 #define _FC_FS_H_
0010 
0011 #include <linux/types.h>
0012 
0013 /*
0014  * Fibre Channel Framing and Signalling definitions.
0015  * From T11 FC-FS-2 Rev 0.90 - 9 August 2005.
0016  */
0017 
0018 /*
0019  * Frame header
0020  */
0021 struct fc_frame_header {
0022     __u8          fh_r_ctl; /* routing control */
0023     __u8          fh_d_id[3];   /* Destination ID */
0024 
0025     __u8          fh_cs_ctl;    /* class of service control / pri */
0026     __u8          fh_s_id[3];   /* Source ID */
0027 
0028     __u8          fh_type;      /* see enum fc_fh_type below */
0029     __u8          fh_f_ctl[3];  /* frame control */
0030 
0031     __u8          fh_seq_id;    /* sequence ID */
0032     __u8          fh_df_ctl;    /* data field control */
0033     __be16        fh_seq_cnt;   /* sequence count */
0034 
0035     __be16        fh_ox_id;     /* originator exchange ID */
0036     __be16        fh_rx_id;     /* responder exchange ID */
0037     __be32        fh_parm_offset;   /* parameter or relative offset */
0038 };
0039 
0040 #define FC_FRAME_HEADER_LEN 24  /* expected length of structure */
0041 
0042 #define FC_MAX_PAYLOAD  2112U       /* max payload length in bytes */
0043 #define FC_MIN_MAX_PAYLOAD  256U    /* lower limit on max payload */
0044 
0045 #define FC_MAX_FRAME    (FC_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)
0046 #define FC_MIN_MAX_FRAME (FC_MIN_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)
0047 
0048 /*
0049  * fh_r_ctl - Routing control definitions.
0050  */
0051     /*
0052      * FC-4 device_data.
0053      */
0054 enum fc_rctl {
0055     FC_RCTL_DD_UNCAT = 0x00,    /* uncategorized information */
0056     FC_RCTL_DD_SOL_DATA = 0x01, /* solicited data */
0057     FC_RCTL_DD_UNSOL_CTL = 0x02,    /* unsolicited control */
0058     FC_RCTL_DD_SOL_CTL = 0x03,  /* solicited control or reply */
0059     FC_RCTL_DD_UNSOL_DATA = 0x04,   /* unsolicited data */
0060     FC_RCTL_DD_DATA_DESC = 0x05,    /* data descriptor */
0061     FC_RCTL_DD_UNSOL_CMD = 0x06,    /* unsolicited command */
0062     FC_RCTL_DD_CMD_STATUS = 0x07,   /* command status */
0063 
0064 #define FC_RCTL_ILS_REQ FC_RCTL_DD_UNSOL_CTL    /* ILS request */
0065 #define FC_RCTL_ILS_REP FC_RCTL_DD_SOL_CTL  /* ILS reply */
0066 
0067     /*
0068      * Extended Link_Data
0069      */
0070     FC_RCTL_ELS_REQ = 0x22, /* extended link services request */
0071     FC_RCTL_ELS_REP = 0x23, /* extended link services reply */
0072     FC_RCTL_ELS4_REQ = 0x32, /* FC-4 ELS request */
0073     FC_RCTL_ELS4_REP = 0x33, /* FC-4 ELS reply */
0074     /*
0075      * Optional Extended Headers
0076      */
0077     FC_RCTL_VFTH = 0x50,    /* virtual fabric tagging header */
0078     FC_RCTL_IFRH = 0x51,    /* inter-fabric routing header */
0079     FC_RCTL_ENCH = 0x52,    /* encapsulation header */
0080     /*
0081      * Basic Link Services fh_r_ctl values.
0082      */
0083     FC_RCTL_BA_NOP = 0x80,  /* basic link service NOP */
0084     FC_RCTL_BA_ABTS = 0x81, /* basic link service abort */
0085     FC_RCTL_BA_RMC = 0x82,  /* remove connection */
0086     FC_RCTL_BA_ACC = 0x84,  /* basic accept */
0087     FC_RCTL_BA_RJT = 0x85,  /* basic reject */
0088     FC_RCTL_BA_PRMT = 0x86, /* dedicated connection preempted */
0089     /*
0090      * Link Control Information.
0091      */
0092     FC_RCTL_ACK_1 = 0xc0,   /* acknowledge_1 */
0093     FC_RCTL_ACK_0 = 0xc1,   /* acknowledge_0 */
0094     FC_RCTL_P_RJT = 0xc2,   /* port reject */
0095     FC_RCTL_F_RJT = 0xc3,   /* fabric reject */
0096     FC_RCTL_P_BSY = 0xc4,   /* port busy */
0097     FC_RCTL_F_BSY = 0xc5,   /* fabric busy to data frame */
0098     FC_RCTL_F_BSYL = 0xc6,  /* fabric busy to link control frame */
0099     FC_RCTL_LCR = 0xc7, /* link credit reset */
0100     FC_RCTL_END = 0xc9, /* end */
0101 };
0102                     /* incomplete list of definitions */
0103 
0104 /*
0105  * R_CTL names initializer.
0106  * Please keep this matching the above definitions.
0107  */
0108 #define FC_RCTL_NAMES_INIT { \
0109     [FC_RCTL_DD_UNCAT] =        "uncat",            \
0110     [FC_RCTL_DD_SOL_DATA] =     "sol data",         \
0111     [FC_RCTL_DD_UNSOL_CTL] =    "unsol ctl",            \
0112     [FC_RCTL_DD_SOL_CTL] =      "sol ctl/reply",        \
0113     [FC_RCTL_DD_UNSOL_DATA] =   "unsol data",           \
0114     [FC_RCTL_DD_DATA_DESC] =    "data desc",            \
0115     [FC_RCTL_DD_UNSOL_CMD] =    "unsol cmd",            \
0116     [FC_RCTL_DD_CMD_STATUS] =   "cmd status",           \
0117     [FC_RCTL_ELS_REQ] =     "ELS req",          \
0118     [FC_RCTL_ELS_REP] =     "ELS rep",          \
0119     [FC_RCTL_ELS4_REQ] =        "FC-4 ELS req",         \
0120     [FC_RCTL_ELS4_REP] =        "FC-4 ELS rep",         \
0121     [FC_RCTL_BA_NOP] =      "BLS NOP",          \
0122     [FC_RCTL_BA_ABTS] =     "BLS abort",            \
0123     [FC_RCTL_BA_RMC] =      "BLS remove connection",    \
0124     [FC_RCTL_BA_ACC] =      "BLS accept",           \
0125     [FC_RCTL_BA_RJT] =      "BLS reject",           \
0126     [FC_RCTL_BA_PRMT] =     "BLS dedicated connection preempted", \
0127     [FC_RCTL_ACK_1] =       "LC ACK_1",         \
0128     [FC_RCTL_ACK_0] =       "LC ACK_0",         \
0129     [FC_RCTL_P_RJT] =       "LC port reject",       \
0130     [FC_RCTL_F_RJT] =       "LC fabric reject",     \
0131     [FC_RCTL_P_BSY] =       "LC port busy",         \
0132     [FC_RCTL_F_BSY] =       "LC fabric busy to data frame", \
0133     [FC_RCTL_F_BSYL] =      "LC fabric busy to link control frame",\
0134     [FC_RCTL_LCR] =         "LC link credit reset",     \
0135     [FC_RCTL_END] =         "LC end",           \
0136 }
0137 
0138 /*
0139  * Well-known fabric addresses.
0140  */
0141 enum fc_well_known_fid {
0142     FC_FID_NONE =           0x000000,       /* No destination */
0143     FC_FID_BCAST =      0xffffff,   /* broadcast */
0144     FC_FID_FLOGI =      0xfffffe,   /* fabric login */
0145     FC_FID_FCTRL =      0xfffffd,   /* fabric controller */
0146     FC_FID_DIR_SERV =   0xfffffc,   /* directory server */
0147     FC_FID_TIME_SERV =  0xfffffb,   /* time server */
0148     FC_FID_MGMT_SERV =  0xfffffa,   /* management server */
0149     FC_FID_QOS =        0xfffff9,   /* QoS Facilitator */
0150     FC_FID_ALIASES =    0xfffff8,   /* alias server (FC-PH2) */
0151     FC_FID_SEC_KEY =    0xfffff7,   /* Security key dist. server */
0152     FC_FID_CLOCK =      0xfffff6,   /* clock synch server */
0153     FC_FID_MCAST_SERV = 0xfffff5,   /* multicast server */
0154 };
0155 
0156 #define FC_FID_WELL_KNOWN_MAX   0xffffff /* highest well-known fabric ID */
0157 #define FC_FID_WELL_KNOWN_BASE  0xfffff5 /* start of well-known fabric ID */
0158 
0159 /*
0160  * Other well-known addresses, outside the above contiguous range.
0161  */
0162 #define FC_FID_DOM_MGR      0xfffc00    /* domain manager base */
0163 
0164 /*
0165  * Fabric ID bytes.
0166  */
0167 #define FC_FID_DOMAIN       0
0168 #define FC_FID_PORT     1
0169 #define FC_FID_LINK     2
0170 
0171 /*
0172  * fh_type codes
0173  */
0174 enum fc_fh_type {
0175     FC_TYPE_BLS =   0x00,   /* basic link service */
0176     FC_TYPE_ELS =   0x01,   /* extended link service */
0177     FC_TYPE_IP =    0x05,   /* IP over FC, RFC 4338 */
0178     FC_TYPE_FCP =   0x08,   /* SCSI FCP */
0179     FC_TYPE_CT =    0x20,   /* Fibre Channel Services (FC-CT) */
0180     FC_TYPE_ILS =   0x22,   /* internal link service */
0181     FC_TYPE_NVME =  0x28,   /* FC-NVME */
0182 };
0183 
0184 /*
0185  * FC_TYPE names initializer.
0186  * Please keep this matching the above definitions.
0187  */
0188 #define FC_TYPE_NAMES_INIT {                \
0189     [FC_TYPE_BLS] =     "BLS",          \
0190     [FC_TYPE_ELS] =     "ELS",          \
0191     [FC_TYPE_IP] =      "IP",           \
0192     [FC_TYPE_FCP] =     "FCP",          \
0193     [FC_TYPE_CT] =      "CT",           \
0194     [FC_TYPE_ILS] =     "ILS",          \
0195     [FC_TYPE_NVME] =    "NVME",         \
0196 }
0197 
0198 /*
0199  * Exchange IDs.
0200  */
0201 #define FC_XID_UNKNOWN  0xffff  /* unknown exchange ID */
0202 #define FC_XID_MIN  0x0 /* supported min exchange ID */
0203 #define FC_XID_MAX  0xfffe  /* supported max exchange ID */
0204 
0205 /*
0206  * fh_f_ctl - Frame control flags.
0207  */
0208 #define FC_FC_EX_CTX    (1 << 23)   /* sent by responder to exchange */
0209 #define FC_FC_SEQ_CTX   (1 << 22)   /* sent by responder to sequence */
0210 #define FC_FC_FIRST_SEQ (1 << 21)   /* first sequence of this exchange */
0211 #define FC_FC_LAST_SEQ  (1 << 20)   /* last sequence of this exchange */
0212 #define FC_FC_END_SEQ   (1 << 19)   /* last frame of sequence */
0213 #define FC_FC_END_CONN  (1 << 18)   /* end of class 1 connection pending */
0214 #define FC_FC_RES_B17   (1 << 17)   /* reserved */
0215 #define FC_FC_SEQ_INIT  (1 << 16)   /* transfer of sequence initiative */
0216 #define FC_FC_X_ID_REASS (1 << 15)  /* exchange ID has been changed */
0217 #define FC_FC_X_ID_INVAL (1 << 14)  /* exchange ID invalidated */
0218 
0219 #define FC_FC_ACK_1 (1 << 12)   /* 13:12 = 1: ACK_1 expected */
0220 #define FC_FC_ACK_N (2 << 12)   /* 13:12 = 2: ACK_N expected */
0221 #define FC_FC_ACK_0 (3 << 12)   /* 13:12 = 3: ACK_0 expected */
0222 
0223 #define FC_FC_RES_B11   (1 << 11)   /* reserved */
0224 #define FC_FC_RES_B10   (1 << 10)   /* reserved */
0225 #define FC_FC_RETX_SEQ  (1 << 9)    /* retransmitted sequence */
0226 #define FC_FC_UNI_TX    (1 << 8)    /* unidirectional transmit (class 1) */
0227 #define FC_FC_CONT_SEQ(i) ((i) << 6)
0228 #define FC_FC_ABT_SEQ(i) ((i) << 4)
0229 #define FC_FC_REL_OFF   (1 << 3)    /* parameter is relative offset */
0230 #define FC_FC_RES2  (1 << 2)    /* reserved */
0231 #define FC_FC_FILL(i)   ((i) & 3)   /* 1:0: bytes of trailing fill */
0232 
0233 /*
0234  * BA_ACC payload.
0235  */
0236 struct fc_ba_acc {
0237     __u8        ba_seq_id_val;  /* SEQ_ID validity */
0238 #define FC_BA_SEQ_ID_VAL 0x80
0239     __u8        ba_seq_id;  /* SEQ_ID of seq last deliverable */
0240     __u8        ba_resvd[2];    /* reserved */
0241     __be16      ba_ox_id;   /* OX_ID for aborted seq or exch */
0242     __be16      ba_rx_id;   /* RX_ID for aborted seq or exch */
0243     __be16      ba_low_seq_cnt; /* low SEQ_CNT of aborted seq */
0244     __be16      ba_high_seq_cnt; /* high SEQ_CNT of aborted seq */
0245 };
0246 
0247 /*
0248  * BA_RJT: Basic Reject payload.
0249  */
0250 struct fc_ba_rjt {
0251     __u8        br_resvd;   /* reserved */
0252     __u8        br_reason;  /* reason code */
0253     __u8        br_explan;  /* reason explanation */
0254     __u8        br_vendor;  /* vendor unique code */
0255 };
0256 
0257 /*
0258  * BA_RJT reason codes.
0259  * From FS-2.
0260  */
0261 enum fc_ba_rjt_reason {
0262     FC_BA_RJT_NONE =    0,  /* in software this means no reject */
0263     FC_BA_RJT_INVL_CMD =    0x01,   /* invalid command code */
0264     FC_BA_RJT_LOG_ERR = 0x03,   /* logical error */
0265     FC_BA_RJT_LOG_BUSY =    0x05,   /* logical busy */
0266     FC_BA_RJT_PROTO_ERR =   0x07,   /* protocol error */
0267     FC_BA_RJT_UNABLE =  0x09,   /* unable to perform request */
0268     FC_BA_RJT_VENDOR =  0xff,   /* vendor-specific (see br_vendor) */
0269 };
0270 
0271 /*
0272  * BA_RJT reason code explanations.
0273  */
0274 enum fc_ba_rjt_explan {
0275     FC_BA_RJT_EXP_NONE =    0x00,   /* no additional expanation */
0276     FC_BA_RJT_INV_XID = 0x03,   /* invalid OX_ID-RX_ID combination */
0277     FC_BA_RJT_ABT =     0x05,   /* sequence aborted, no seq info */
0278 };
0279 
0280 /*
0281  * P_RJT or F_RJT: Port Reject or Fabric Reject parameter field.
0282  */
0283 struct fc_pf_rjt {
0284     __u8        rj_action;  /* reserved */
0285     __u8        rj_reason;  /* reason code */
0286     __u8        rj_resvd;   /* reserved */
0287     __u8        rj_vendor;  /* vendor unique code */
0288 };
0289 
0290 /*
0291  * P_RJT and F_RJT reject reason codes.
0292  */
0293 enum fc_pf_rjt_reason {
0294     FC_RJT_NONE =       0,  /* non-reject (reserved by standard) */
0295     FC_RJT_INVL_DID =   0x01,   /* invalid destination ID */
0296     FC_RJT_INVL_SID =   0x02,   /* invalid source ID */
0297     FC_RJT_P_UNAV_T =   0x03,   /* port unavailable, temporary */
0298     FC_RJT_P_UNAV =     0x04,   /* port unavailable, permanent */
0299     FC_RJT_CLS_UNSUP =  0x05,   /* class not supported */
0300     FC_RJT_DEL_USAGE =  0x06,   /* delimiter usage error */
0301     FC_RJT_TYPE_UNSUP = 0x07,   /* type not supported */
0302     FC_RJT_LINK_CTL =   0x08,   /* invalid link control */
0303     FC_RJT_R_CTL =      0x09,   /* invalid R_CTL field */
0304     FC_RJT_F_CTL =      0x0a,   /* invalid F_CTL field */
0305     FC_RJT_OX_ID =      0x0b,   /* invalid originator exchange ID */
0306     FC_RJT_RX_ID =      0x0c,   /* invalid responder exchange ID */
0307     FC_RJT_SEQ_ID =     0x0d,   /* invalid sequence ID */
0308     FC_RJT_DF_CTL =     0x0e,   /* invalid DF_CTL field */
0309     FC_RJT_SEQ_CNT =    0x0f,   /* invalid SEQ_CNT field */
0310     FC_RJT_PARAM =      0x10,   /* invalid parameter field */
0311     FC_RJT_EXCH_ERR =   0x11,   /* exchange error */
0312     FC_RJT_PROTO =      0x12,   /* protocol error */
0313     FC_RJT_LEN =        0x13,   /* incorrect length */
0314     FC_RJT_UNEXP_ACK =  0x14,   /* unexpected ACK */
0315     FC_RJT_FAB_CLASS =  0x15,   /* class unsupported by fabric entity */
0316     FC_RJT_LOGI_REQ =   0x16,   /* login required */
0317     FC_RJT_SEQ_XS =     0x17,   /* excessive sequences attempted */
0318     FC_RJT_EXCH_EST =   0x18,   /* unable to establish exchange */
0319     FC_RJT_FAB_UNAV =   0x1a,   /* fabric unavailable */
0320     FC_RJT_VC_ID =      0x1b,   /* invalid VC_ID (class 4) */
0321     FC_RJT_CS_CTL =     0x1c,   /* invalid CS_CTL field */
0322     FC_RJT_INSUF_RES =  0x1d,   /* insuff. resources for VC (Class 4) */
0323     FC_RJT_INVL_CLS =   0x1f,   /* invalid class of service */
0324     FC_RJT_PREEMT_RJT = 0x20,   /* preemption request rejected */
0325     FC_RJT_PREEMT_DIS = 0x21,   /* preemption not enabled */
0326     FC_RJT_MCAST_ERR =  0x22,   /* multicast error */
0327     FC_RJT_MCAST_ET =   0x23,   /* multicast error terminate */
0328     FC_RJT_PRLI_REQ =   0x24,   /* process login required */
0329     FC_RJT_INVL_ATT =   0x25,   /* invalid attachment */
0330     FC_RJT_VENDOR =     0xff,   /* vendor specific reject */
0331 };
0332 
0333 /* default timeout values */
0334 
0335 #define FC_DEF_E_D_TOV  2000UL
0336 #define FC_DEF_R_A_TOV  10000UL
0337 
0338 #endif /* _FC_FS_H_ */