···11+/*22+ * Copyright(c) 2007 Intel Corporation. All rights reserved.33+ *44+ * This program is free software; you can redistribute it and/or modify it55+ * under the terms and conditions of the GNU General Public License,66+ * version 2, as published by the Free Software Foundation.77+ *88+ * This program is distributed in the hope it will be useful, but WITHOUT99+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1010+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for1111+ * more details.1212+ *1313+ * You should have received a copy of the GNU General Public License along with1414+ * this program; if not, write to the Free Software Foundation, Inc.,1515+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.1616+ *1717+ * Maintained at www.Open-FCoE.org1818+ */1919+2020+#ifndef _FC_ELS_H_2121+#define _FC_ELS_H_2222+2323+/*2424+ * Fibre Channel Switch - Enhanced Link Services definitions.2525+ * From T11 FC-LS Rev 1.2 June 7, 2005.2626+ */2727+2828+/*2929+ * ELS Command codes - byte 0 of the frame payload3030+ */3131+enum fc_els_cmd {3232+ ELS_LS_RJT = 0x01, /* ESL reject */3333+ ELS_LS_ACC = 0x02, /* ESL Accept */3434+ ELS_PLOGI = 0x03, /* N_Port login */3535+ ELS_FLOGI = 0x04, /* F_Port login */3636+ ELS_LOGO = 0x05, /* Logout */3737+ ELS_ABTX = 0x06, /* Abort exchange - obsolete */3838+ ELS_RCS = 0x07, /* read connection status */3939+ ELS_RES = 0x08, /* read exchange status block */4040+ ELS_RSS = 0x09, /* read sequence status block */4141+ ELS_RSI = 0x0a, /* read sequence initiative */4242+ ELS_ESTS = 0x0b, /* establish streaming */4343+ ELS_ESTC = 0x0c, /* estimate credit */4444+ ELS_ADVC = 0x0d, /* advise credit */4545+ ELS_RTV = 0x0e, /* read timeout value */4646+ ELS_RLS = 0x0f, /* read link error status block */4747+ ELS_ECHO = 0x10, /* echo */4848+ ELS_TEST = 0x11, /* test */4949+ ELS_RRQ = 0x12, /* reinstate recovery qualifier */5050+ ELS_REC = 0x13, /* read exchange concise */5151+ ELS_SRR = 0x14, /* sequence retransmission request */5252+ ELS_PRLI = 0x20, /* process login */5353+ ELS_PRLO = 0x21, /* process logout */5454+ ELS_SCN = 0x22, /* state change notification */5555+ ELS_TPLS = 0x23, /* test process login state */5656+ ELS_TPRLO = 0x24, /* third party process logout */5757+ ELS_LCLM = 0x25, /* login control list mgmt (obs) */5858+ ELS_GAID = 0x30, /* get alias_ID */5959+ ELS_FACT = 0x31, /* fabric activate alias_id */6060+ ELS_FDACDT = 0x32, /* fabric deactivate alias_id */6161+ ELS_NACT = 0x33, /* N-port activate alias_id */6262+ ELS_NDACT = 0x34, /* N-port deactivate alias_id */6363+ ELS_QOSR = 0x40, /* quality of service request */6464+ ELS_RVCS = 0x41, /* read virtual circuit status */6565+ ELS_PDISC = 0x50, /* discover N_port service params */6666+ ELS_FDISC = 0x51, /* discover F_port service params */6767+ ELS_ADISC = 0x52, /* discover address */6868+ ELS_RNC = 0x53, /* report node cap (obs) */6969+ ELS_FARP_REQ = 0x54, /* FC ARP request */7070+ ELS_FARP_REPL = 0x55, /* FC ARP reply */7171+ ELS_RPS = 0x56, /* read port status block */7272+ ELS_RPL = 0x57, /* read port list */7373+ ELS_RPBC = 0x58, /* read port buffer condition */7474+ ELS_FAN = 0x60, /* fabric address notification */7575+ ELS_RSCN = 0x61, /* registered state change notification */7676+ ELS_SCR = 0x62, /* state change registration */7777+ ELS_RNFT = 0x63, /* report node FC-4 types */7878+ ELS_CSR = 0x68, /* clock synch. request */7979+ ELS_CSU = 0x69, /* clock synch. update */8080+ ELS_LINIT = 0x70, /* loop initialize */8181+ ELS_LSTS = 0x72, /* loop status */8282+ ELS_RNID = 0x78, /* request node ID data */8383+ ELS_RLIR = 0x79, /* registered link incident report */8484+ ELS_LIRR = 0x7a, /* link incident record registration */8585+ ELS_SRL = 0x7b, /* scan remote loop */8686+ ELS_SBRP = 0x7c, /* set bit-error reporting params */8787+ ELS_RPSC = 0x7d, /* report speed capabilities */8888+ ELS_QSA = 0x7e, /* query security attributes */8989+ ELS_EVFP = 0x7f, /* exchange virt. fabrics params */9090+ ELS_LKA = 0x80, /* link keep-alive */9191+ ELS_AUTH_ELS = 0x90, /* authentication ELS */9292+};9393+9494+/*9595+ * Initializer useful for decoding table.9696+ * Please keep this in sync with the above definitions.9797+ */9898+#define FC_ELS_CMDS_INIT { \9999+ [ELS_LS_RJT] = "LS_RJT", \100100+ [ELS_LS_ACC] = "LS_ACC", \101101+ [ELS_PLOGI] = "PLOGI", \102102+ [ELS_FLOGI] = "FLOGI", \103103+ [ELS_LOGO] = "LOGO", \104104+ [ELS_ABTX] = "ABTX", \105105+ [ELS_RCS] = "RCS", \106106+ [ELS_RES] = "RES", \107107+ [ELS_RSS] = "RSS", \108108+ [ELS_RSI] = "RSI", \109109+ [ELS_ESTS] = "ESTS", \110110+ [ELS_ESTC] = "ESTC", \111111+ [ELS_ADVC] = "ADVC", \112112+ [ELS_RTV] = "RTV", \113113+ [ELS_RLS] = "RLS", \114114+ [ELS_ECHO] = "ECHO", \115115+ [ELS_TEST] = "TEST", \116116+ [ELS_RRQ] = "RRQ", \117117+ [ELS_REC] = "REC", \118118+ [ELS_SRR] = "SRR", \119119+ [ELS_PRLI] = "PRLI", \120120+ [ELS_PRLO] = "PRLO", \121121+ [ELS_SCN] = "SCN", \122122+ [ELS_TPLS] = "TPLS", \123123+ [ELS_TPRLO] = "TPRLO", \124124+ [ELS_LCLM] = "LCLM", \125125+ [ELS_GAID] = "GAID", \126126+ [ELS_FACT] = "FACT", \127127+ [ELS_FDACDT] = "FDACDT", \128128+ [ELS_NACT] = "NACT", \129129+ [ELS_NDACT] = "NDACT", \130130+ [ELS_QOSR] = "QOSR", \131131+ [ELS_RVCS] = "RVCS", \132132+ [ELS_PDISC] = "PDISC", \133133+ [ELS_FDISC] = "FDISC", \134134+ [ELS_ADISC] = "ADISC", \135135+ [ELS_RNC] = "RNC", \136136+ [ELS_FARP_REQ] = "FARP_REQ", \137137+ [ELS_FARP_REPL] = "FARP_REPL", \138138+ [ELS_RPS] = "RPS", \139139+ [ELS_RPL] = "RPL", \140140+ [ELS_RPBC] = "RPBC", \141141+ [ELS_FAN] = "FAN", \142142+ [ELS_RSCN] = "RSCN", \143143+ [ELS_SCR] = "SCR", \144144+ [ELS_RNFT] = "RNFT", \145145+ [ELS_CSR] = "CSR", \146146+ [ELS_CSU] = "CSU", \147147+ [ELS_LINIT] = "LINIT", \148148+ [ELS_LSTS] = "LSTS", \149149+ [ELS_RNID] = "RNID", \150150+ [ELS_RLIR] = "RLIR", \151151+ [ELS_LIRR] = "LIRR", \152152+ [ELS_SRL] = "SRL", \153153+ [ELS_SBRP] = "SBRP", \154154+ [ELS_RPSC] = "RPSC", \155155+ [ELS_QSA] = "QSA", \156156+ [ELS_EVFP] = "EVFP", \157157+ [ELS_LKA] = "LKA", \158158+ [ELS_AUTH_ELS] = "AUTH_ELS", \159159+}160160+161161+/*162162+ * LS_ACC payload.163163+ */164164+struct fc_els_ls_acc {165165+ __u8 la_cmd; /* command code ELS_LS_ACC */166166+ __u8 la_resv[3]; /* reserved */167167+};168168+169169+/*170170+ * ELS reject payload.171171+ */172172+struct fc_els_ls_rjt {173173+ __u8 er_cmd; /* command code ELS_LS_RJT */174174+ __u8 er_resv[4]; /* reserved must be zero */175175+ __u8 er_reason; /* reason (enum fc_els_rjt_reason below) */176176+ __u8 er_explan; /* explanation (enum fc_els_rjt_explan below) */177177+ __u8 er_vendor; /* vendor specific code */178178+};179179+180180+/*181181+ * ELS reject reason codes (er_reason).182182+ */183183+enum fc_els_rjt_reason {184184+ ELS_RJT_NONE = 0, /* no reject - not to be sent */185185+ ELS_RJT_INVAL = 0x01, /* invalid ELS command code */186186+ ELS_RJT_LOGIC = 0x03, /* logical error */187187+ ELS_RJT_BUSY = 0x05, /* logical busy */188188+ ELS_RJT_PROT = 0x07, /* protocol error */189189+ ELS_RJT_UNAB = 0x09, /* unable to perform command request */190190+ ELS_RJT_UNSUP = 0x0b, /* command not supported */191191+ ELS_RJT_INPROG = 0x0e, /* command already in progress */192192+ ELS_RJT_VENDOR = 0xff, /* vendor specific error */193193+};194194+195195+196196+/*197197+ * reason code explanation (er_explan).198198+ */199199+enum fc_els_rjt_explan {200200+ ELS_EXPL_NONE = 0x00, /* No additional explanation */201201+ ELS_EXPL_SPP_OPT_ERR = 0x01, /* service parameter error - options */202202+ ELS_EXPL_SPP_ICTL_ERR = 0x03, /* service parm error - initiator ctl */203203+ ELS_EXPL_AH = 0x11, /* invalid association header */204204+ ELS_EXPL_AH_REQ = 0x13, /* association_header required */205205+ ELS_EXPL_SID = 0x15, /* invalid originator S_ID */206206+ ELS_EXPL_OXID_RXID = 0x17, /* invalid OX_ID-RX_ID combination */207207+ ELS_EXPL_INPROG = 0x19, /* Request already in progress */208208+ ELS_EXPL_PLOGI_REQD = 0x1e, /* N_Port login required */209209+ ELS_EXPL_INSUF_RES = 0x29, /* insufficient resources */210210+ ELS_EXPL_UNAB_DATA = 0x2a, /* unable to supply requested data */211211+ ELS_EXPL_UNSUPR = 0x2c, /* Request not supported */212212+ ELS_EXPL_INV_LEN = 0x2d, /* Invalid payload length */213213+ /* TBD - above definitions incomplete */214214+};215215+216216+/*217217+ * Common service parameters (N ports).218218+ */219219+struct fc_els_csp {220220+ __u8 sp_hi_ver; /* highest version supported (obs.) */221221+ __u8 sp_lo_ver; /* highest version supported (obs.) */222222+ __be16 sp_bb_cred; /* buffer-to-buffer credits */223223+ __be16 sp_features; /* common feature flags */224224+ __be16 sp_bb_data; /* b-b state number and data field sz */225225+ union {226226+ struct {227227+ __be16 _sp_tot_seq; /* total concurrent sequences */228228+ __be16 _sp_rel_off; /* rel. offset by info cat */229229+ } sp_plogi;230230+ struct {231231+ __be32 _sp_r_a_tov; /* resource alloc. timeout msec */232232+ } sp_flogi_acc;233233+ } sp_u;234234+ __be32 sp_e_d_tov; /* error detect timeout value */235235+};236236+#define sp_tot_seq sp_u.sp_plogi._sp_tot_seq237237+#define sp_rel_off sp_u.sp_plogi._sp_rel_off238238+#define sp_r_a_tov sp_u.sp_flogi_acc._sp_r_a_tov239239+240240+#define FC_SP_BB_DATA_MASK 0xfff /* mask for data field size in sp_bb_data */241241+242242+/*243243+ * Minimum and maximum values for max data field size in service parameters.244244+ */245245+#define FC_SP_MIN_MAX_PAYLOAD FC_MIN_MAX_PAYLOAD246246+#define FC_SP_MAX_MAX_PAYLOAD FC_MAX_PAYLOAD247247+248248+/*249249+ * sp_features250250+ */251251+#define FC_SP_FT_CIRO 0x8000 /* continuously increasing rel. off. */252252+#define FC_SP_FT_CLAD 0x8000 /* clean address (in FLOGI LS_ACC) */253253+#define FC_SP_FT_RAND 0x4000 /* random relative offset */254254+#define FC_SP_FT_VAL 0x2000 /* valid vendor version level */255255+#define FC_SP_FT_FPORT 0x1000 /* F port (1) vs. N port (0) */256256+#define FC_SP_FT_ABB 0x0800 /* alternate BB_credit management */257257+#define FC_SP_FT_EDTR 0x0400 /* E_D_TOV Resolution is nanoseconds */258258+#define FC_SP_FT_MCAST 0x0200 /* multicast */259259+#define FC_SP_FT_BCAST 0x0100 /* broadcast */260260+#define FC_SP_FT_HUNT 0x0080 /* hunt group */261261+#define FC_SP_FT_SIMP 0x0040 /* dedicated simplex */262262+#define FC_SP_FT_SEC 0x0020 /* reserved for security */263263+#define FC_SP_FT_CSYN 0x0010 /* clock synch. supported */264264+#define FC_SP_FT_RTTOV 0x0008 /* R_T_TOV value 100 uS, else 100 mS */265265+#define FC_SP_FT_HALF 0x0004 /* dynamic half duplex */266266+#define FC_SP_FT_SEQC 0x0002 /* SEQ_CNT */267267+#define FC_SP_FT_PAYL 0x0001 /* FLOGI payload length 256, else 116 */268268+269269+/*270270+ * Class-specific service parameters.271271+ */272272+struct fc_els_cssp {273273+ __be16 cp_class; /* class flags */274274+ __be16 cp_init; /* initiator flags */275275+ __be16 cp_recip; /* recipient flags */276276+ __be16 cp_rdfs; /* receive data field size */277277+ __be16 cp_con_seq; /* concurrent sequences */278278+ __be16 cp_ee_cred; /* N-port end-to-end credit */279279+ __u8 cp_resv1; /* reserved */280280+ __u8 cp_open_seq; /* open sequences per exchange */281281+ __u8 _cp_resv2[2]; /* reserved */282282+};283283+284284+/*285285+ * cp_class flags.286286+ */287287+#define FC_CPC_VALID 0x8000 /* class valid */288288+#define FC_CPC_IMIX 0x4000 /* intermix mode */289289+#define FC_CPC_SEQ 0x0800 /* sequential delivery */290290+#define FC_CPC_CAMP 0x0200 /* camp-on */291291+#define FC_CPC_PRI 0x0080 /* priority */292292+293293+/*294294+ * cp_init flags.295295+ * (TBD: not all flags defined here).296296+ */297297+#define FC_CPI_CSYN 0x0010 /* clock synch. capable */298298+299299+/*300300+ * cp_recip flags.301301+ */302302+#define FC_CPR_CSYN 0x0008 /* clock synch. capable */303303+304304+/*305305+ * NFC_ELS_FLOGI: Fabric login request.306306+ * NFC_ELS_PLOGI: Port login request (same format).307307+ */308308+struct fc_els_flogi {309309+ __u8 fl_cmd; /* command */310310+ __u8 _fl_resvd[3]; /* must be zero */311311+ struct fc_els_csp fl_csp; /* common service parameters */312312+ __be64 fl_wwpn; /* port name */313313+ __be64 fl_wwnn; /* node name */314314+ struct fc_els_cssp fl_cssp[4]; /* class 1-4 service parameters */315315+ __u8 fl_vend[16]; /* vendor version level */316316+} __attribute__((__packed__));317317+318318+/*319319+ * Process login service parameter page.320320+ */321321+struct fc_els_spp {322322+ __u8 spp_type; /* type code or common service params */323323+ __u8 spp_type_ext; /* type code extension */324324+ __u8 spp_flags;325325+ __u8 _spp_resvd;326326+ __be32 spp_orig_pa; /* originator process associator */327327+ __be32 spp_resp_pa; /* responder process associator */328328+ __be32 spp_params; /* service parameters */329329+};330330+331331+/*332332+ * spp_flags.333333+ */334334+#define FC_SPP_OPA_VAL 0x80 /* originator proc. assoc. valid */335335+#define FC_SPP_RPA_VAL 0x40 /* responder proc. assoc. valid */336336+#define FC_SPP_EST_IMG_PAIR 0x20 /* establish image pair */337337+#define FC_SPP_RESP_MASK 0x0f /* mask for response code (below) */338338+339339+/*340340+ * SPP response code in spp_flags - lower 4 bits.341341+ */342342+enum fc_els_spp_resp {343343+ FC_SPP_RESP_ACK = 1, /* request executed */344344+ FC_SPP_RESP_RES = 2, /* unable due to lack of resources */345345+ FC_SPP_RESP_INIT = 3, /* initialization not complete */346346+ FC_SPP_RESP_NO_PA = 4, /* unknown process associator */347347+ FC_SPP_RESP_CONF = 5, /* configuration precludes image pair */348348+ FC_SPP_RESP_COND = 6, /* request completed conditionally */349349+ FC_SPP_RESP_MULT = 7, /* unable to handle multiple SPPs */350350+ FC_SPP_RESP_INVL = 8, /* SPP is invalid */351351+};352352+353353+/*354354+ * ELS_RRQ - Reinstate Recovery Qualifier355355+ */356356+struct fc_els_rrq {357357+ __u8 rrq_cmd; /* command (0x12) */358358+ __u8 rrq_zero[3]; /* specified as zero - part of cmd */359359+ __u8 rrq_resvd; /* reserved */360360+ __u8 rrq_s_id[3]; /* originator FID */361361+ __be16 rrq_ox_id; /* originator exchange ID */362362+ __be16 rrq_rx_id; /* responders exchange ID */363363+};364364+365365+/*366366+ * ELS_REC - Read exchange concise.367367+ */368368+struct fc_els_rec {369369+ __u8 rec_cmd; /* command (0x13) */370370+ __u8 rec_zero[3]; /* specified as zero - part of cmd */371371+ __u8 rec_resvd; /* reserved */372372+ __u8 rec_s_id[3]; /* originator FID */373373+ __be16 rec_ox_id; /* originator exchange ID */374374+ __be16 rec_rx_id; /* responders exchange ID */375375+};376376+377377+/*378378+ * ELS_REC LS_ACC payload.379379+ */380380+struct fc_els_rec_acc {381381+ __u8 reca_cmd; /* accept (0x02) */382382+ __u8 reca_zero[3]; /* specified as zero - part of cmd */383383+ __be16 reca_ox_id; /* originator exchange ID */384384+ __be16 reca_rx_id; /* responders exchange ID */385385+ __u8 reca_resvd1; /* reserved */386386+ __u8 reca_ofid[3]; /* originator FID */387387+ __u8 reca_resvd2; /* reserved */388388+ __u8 reca_rfid[3]; /* responder FID */389389+ __be32 reca_fc4value; /* FC4 value */390390+ __be32 reca_e_stat; /* ESB (exchange status block) status */391391+};392392+393393+/*394394+ * ELS_PRLI - Process login request and response.395395+ */396396+struct fc_els_prli {397397+ __u8 prli_cmd; /* command */398398+ __u8 prli_spp_len; /* length of each serv. parm. page */399399+ __be16 prli_len; /* length of entire payload */400400+ /* service parameter pages follow */401401+};402402+403403+/*404404+ * ELS_ADISC payload405405+ */406406+struct fc_els_adisc {407407+ __u8 adisc_cmd;408408+ __u8 adisc_resv[3];409409+ __u8 adisc_resv1;410410+ __u8 adisc_hard_addr[3];411411+ __be64 adisc_wwpn;412412+ __be64 adisc_wwnn;413413+ __u8 adisc_resv2;414414+ __u8 adisc_port_id[3];415415+} __attribute__((__packed__));416416+417417+/*418418+ * ELS_LOGO - process or fabric logout.419419+ */420420+struct fc_els_logo {421421+ __u8 fl_cmd; /* command code */422422+ __u8 fl_zero[3]; /* specified as zero - part of cmd */423423+ __u8 fl_resvd; /* reserved */424424+ __u8 fl_n_port_id[3];/* N port ID */425425+ __be64 fl_n_port_wwn; /* port name */426426+};427427+428428+/*429429+ * ELS_RTV - read timeout value.430430+ */431431+struct fc_els_rtv {432432+ __u8 rtv_cmd; /* command code 0x0e */433433+ __u8 rtv_zero[3]; /* specified as zero - part of cmd */434434+};435435+436436+/*437437+ * LS_ACC for ELS_RTV - read timeout value.438438+ */439439+struct fc_els_rtv_acc {440440+ __u8 rtv_cmd; /* command code 0x02 */441441+ __u8 rtv_zero[3]; /* specified as zero - part of cmd */442442+ __be32 rtv_r_a_tov; /* resource allocation timeout value */443443+ __be32 rtv_e_d_tov; /* error detection timeout value */444444+ __be32 rtv_toq; /* timeout qualifier (see below) */445445+};446446+447447+/*448448+ * rtv_toq bits.449449+ */450450+#define FC_ELS_RTV_EDRES (1 << 26) /* E_D_TOV resolution is nS else mS */451451+#define FC_ELS_RTV_RTTOV (1 << 19) /* R_T_TOV is 100 uS else 100 mS */452452+453453+/*454454+ * ELS_SCR - state change registration payload.455455+ */456456+struct fc_els_scr {457457+ __u8 scr_cmd; /* command code */458458+ __u8 scr_resv[6]; /* reserved */459459+ __u8 scr_reg_func; /* registration function (see below) */460460+};461461+462462+enum fc_els_scr_func {463463+ ELS_SCRF_FAB = 1, /* fabric-detected registration */464464+ ELS_SCRF_NPORT = 2, /* Nx_Port-detected registration */465465+ ELS_SCRF_FULL = 3, /* full registration */466466+ ELS_SCRF_CLEAR = 255, /* remove any current registrations */467467+};468468+469469+/*470470+ * ELS_RSCN - registered state change notification payload.471471+ */472472+struct fc_els_rscn {473473+ __u8 rscn_cmd; /* RSCN opcode (0x61) */474474+ __u8 rscn_page_len; /* page length (4) */475475+ __be16 rscn_plen; /* payload length including this word */476476+477477+ /* followed by 4-byte generic affected Port_ID pages */478478+};479479+480480+struct fc_els_rscn_page {481481+ __u8 rscn_page_flags; /* event and address format */482482+ __u8 rscn_fid[3]; /* fabric ID */483483+};484484+485485+#define ELS_RSCN_EV_QUAL_BIT 2 /* shift count for event qualifier */486486+#define ELS_RSCN_EV_QUAL_MASK 0xf /* mask for event qualifier */487487+#define ELS_RSCN_ADDR_FMT_BIT 0 /* shift count for address format */488488+#define ELS_RSCN_ADDR_FMT_MASK 0x3 /* mask for address format */489489+490490+enum fc_els_rscn_ev_qual {491491+ ELS_EV_QUAL_NONE = 0, /* unspecified */492492+ ELS_EV_QUAL_NS_OBJ = 1, /* changed name server object */493493+ ELS_EV_QUAL_PORT_ATTR = 2, /* changed port attribute */494494+ ELS_EV_QUAL_SERV_OBJ = 3, /* changed service object */495495+ ELS_EV_QUAL_SW_CONFIG = 4, /* changed switch configuration */496496+ ELS_EV_QUAL_REM_OBJ = 5, /* removed object */497497+};498498+499499+enum fc_els_rscn_addr_fmt {500500+ ELS_ADDR_FMT_PORT = 0, /* rscn_fid is a port address */501501+ ELS_ADDR_FMT_AREA = 1, /* rscn_fid is a area address */502502+ ELS_ADDR_FMT_DOM = 2, /* rscn_fid is a domain address */503503+ ELS_ADDR_FMT_FAB = 3, /* anything on fabric may have changed */504504+};505505+506506+/*507507+ * ELS_RNID - request Node ID.508508+ */509509+struct fc_els_rnid {510510+ __u8 rnid_cmd; /* RNID opcode (0x78) */511511+ __u8 rnid_resv[3]; /* reserved */512512+ __u8 rnid_fmt; /* data format */513513+ __u8 rnid_resv2[3]; /* reserved */514514+};515515+516516+/*517517+ * Node Identification Data formats (rnid_fmt)518518+ */519519+enum fc_els_rnid_fmt {520520+ ELS_RNIDF_NONE = 0, /* no specific identification data */521521+ ELS_RNIDF_GEN = 0xdf, /* general topology discovery format */522522+};523523+524524+/*525525+ * ELS_RNID response.526526+ */527527+struct fc_els_rnid_resp {528528+ __u8 rnid_cmd; /* response code (LS_ACC) */529529+ __u8 rnid_resv[3]; /* reserved */530530+ __u8 rnid_fmt; /* data format */531531+ __u8 rnid_cid_len; /* common ID data length */532532+ __u8 rnid_resv2; /* reserved */533533+ __u8 rnid_sid_len; /* specific ID data length */534534+};535535+536536+struct fc_els_rnid_cid {537537+ __be64 rnid_wwpn; /* N port name */538538+ __be64 rnid_wwnn; /* node name */539539+};540540+541541+struct fc_els_rnid_gen {542542+ __u8 rnid_vend_id[16]; /* vendor-unique ID */543543+ __be32 rnid_atype; /* associated type (see below) */544544+ __be32 rnid_phys_port; /* physical port number */545545+ __be32 rnid_att_nodes; /* number of attached nodes */546546+ __u8 rnid_node_mgmt; /* node management (see below) */547547+ __u8 rnid_ip_ver; /* IP version (see below) */548548+ __be16 rnid_prot_port; /* UDP / TCP port number */549549+ __be32 rnid_ip_addr[4]; /* IP address */550550+ __u8 rnid_resvd[2]; /* reserved */551551+ __be16 rnid_vend_spec; /* vendor-specific field */552552+};553553+554554+enum fc_els_rnid_atype {555555+ ELS_RNIDA_UNK = 0x01, /* unknown */556556+ ELS_RNIDA_OTHER = 0x02, /* none of the following */557557+ ELS_RNIDA_HUB = 0x03,558558+ ELS_RNIDA_SWITCH = 0x04,559559+ ELS_RNIDA_GATEWAY = 0x05,560560+ ELS_RNIDA_CONV = 0x06, /* Obsolete, do not use this value */561561+ ELS_RNIDA_HBA = 0x07, /* Obsolete, do not use this value */562562+ ELS_RNIDA_PROXY = 0x08, /* Obsolete, do not use this value */563563+ ELS_RNIDA_STORAGE = 0x09,564564+ ELS_RNIDA_HOST = 0x0a,565565+ ELS_RNIDA_SUBSYS = 0x0b, /* storage subsystem (e.g., RAID) */566566+ ELS_RNIDA_ACCESS = 0x0e, /* access device (e.g. media changer) */567567+ ELS_RNIDA_NAS = 0x11, /* NAS server */568568+ ELS_RNIDA_BRIDGE = 0x12, /* bridge */569569+ ELS_RNIDA_VIRT = 0x13, /* virtualization device */570570+ ELS_RNIDA_MF = 0xff, /* multifunction device (bits below) */571571+ ELS_RNIDA_MF_HUB = 1UL << 31, /* hub */572572+ ELS_RNIDA_MF_SW = 1UL << 30, /* switch */573573+ ELS_RNIDA_MF_GW = 1UL << 29, /* gateway */574574+ ELS_RNIDA_MF_ST = 1UL << 28, /* storage */575575+ ELS_RNIDA_MF_HOST = 1UL << 27, /* host */576576+ ELS_RNIDA_MF_SUB = 1UL << 26, /* storage subsystem */577577+ ELS_RNIDA_MF_ACC = 1UL << 25, /* storage access dev */578578+ ELS_RNIDA_MF_WDM = 1UL << 24, /* wavelength division mux */579579+ ELS_RNIDA_MF_NAS = 1UL << 23, /* NAS server */580580+ ELS_RNIDA_MF_BR = 1UL << 22, /* bridge */581581+ ELS_RNIDA_MF_VIRT = 1UL << 21, /* virtualization device */582582+};583583+584584+enum fc_els_rnid_mgmt {585585+ ELS_RNIDM_SNMP = 0,586586+ ELS_RNIDM_TELNET = 1,587587+ ELS_RNIDM_HTTP = 2,588588+ ELS_RNIDM_HTTPS = 3,589589+ ELS_RNIDM_XML = 4, /* HTTP + XML */590590+};591591+592592+enum fc_els_rnid_ipver {593593+ ELS_RNIDIP_NONE = 0, /* no IP support or node mgmt. */594594+ ELS_RNIDIP_V4 = 1, /* IPv4 */595595+ ELS_RNIDIP_V6 = 2, /* IPv6 */596596+};597597+598598+/*599599+ * ELS RPL - Read Port List.600600+ */601601+struct fc_els_rpl {602602+ __u8 rpl_cmd; /* command */603603+ __u8 rpl_resv[5]; /* reserved - must be zero */604604+ __be16 rpl_max_size; /* maximum response size or zero */605605+ __u8 rpl_resv1; /* reserved - must be zero */606606+ __u8 rpl_index[3]; /* starting index */607607+};608608+609609+/*610610+ * Port number block in RPL response.611611+ */612612+struct fc_els_pnb {613613+ __be32 pnb_phys_pn; /* physical port number */614614+ __u8 pnb_resv; /* reserved */615615+ __u8 pnb_port_id[3]; /* port ID */616616+ __be64 pnb_wwpn; /* port name */617617+};618618+619619+/*620620+ * RPL LS_ACC response.621621+ */622622+struct fc_els_rpl_resp {623623+ __u8 rpl_cmd; /* ELS_LS_ACC */624624+ __u8 rpl_resv1; /* reserved - must be zero */625625+ __be16 rpl_plen; /* payload length */626626+ __u8 rpl_resv2; /* reserved - must be zero */627627+ __u8 rpl_llen[3]; /* list length */628628+ __u8 rpl_resv3; /* reserved - must be zero */629629+ __u8 rpl_index[3]; /* starting index */630630+ struct fc_els_pnb rpl_pnb[1]; /* variable number of PNBs */631631+};632632+633633+/*634634+ * Link Error Status Block.635635+ */636636+struct fc_els_lesb {637637+ __be32 lesb_link_fail; /* link failure count */638638+ __be32 lesb_sync_loss; /* loss of synchronization count */639639+ __be32 lesb_sig_loss; /* loss of signal count */640640+ __be32 lesb_prim_err; /* primitive sequence error count */641641+ __be32 lesb_inv_word; /* invalid transmission word count */642642+ __be32 lesb_inv_crc; /* invalid CRC count */643643+};644644+645645+/*646646+ * ELS RPS - Read Port Status Block request.647647+ */648648+struct fc_els_rps {649649+ __u8 rps_cmd; /* command */650650+ __u8 rps_resv[2]; /* reserved - must be zero */651651+ __u8 rps_flag; /* flag - see below */652652+ __be64 rps_port_spec; /* port selection */653653+};654654+655655+enum fc_els_rps_flag {656656+ FC_ELS_RPS_DID = 0x00, /* port identified by D_ID of req. */657657+ FC_ELS_RPS_PPN = 0x01, /* port_spec is physical port number */658658+ FC_ELS_RPS_WWPN = 0x02, /* port_spec is port WWN */659659+};660660+661661+/*662662+ * ELS RPS LS_ACC response.663663+ */664664+struct fc_els_rps_resp {665665+ __u8 rps_cmd; /* command - LS_ACC */666666+ __u8 rps_resv[2]; /* reserved - must be zero */667667+ __u8 rps_flag; /* flag - see below */668668+ __u8 rps_resv2[2]; /* reserved */669669+ __be16 rps_status; /* port status - see below */670670+ struct fc_els_lesb rps_lesb; /* link error status block */671671+};672672+673673+enum fc_els_rps_resp_flag {674674+ FC_ELS_RPS_LPEV = 0x01, /* L_port extension valid */675675+};676676+677677+enum fc_els_rps_resp_status {678678+ FC_ELS_RPS_PTP = 1 << 5, /* point-to-point connection */679679+ FC_ELS_RPS_LOOP = 1 << 4, /* loop mode */680680+ FC_ELS_RPS_FAB = 1 << 3, /* fabric present */681681+ FC_ELS_RPS_NO_SIG = 1 << 2, /* loss of signal */682682+ FC_ELS_RPS_NO_SYNC = 1 << 1, /* loss of synchronization */683683+ FC_ELS_RPS_RESET = 1 << 0, /* in link reset protocol */684684+};685685+686686+/*687687+ * ELS LIRR - Link Incident Record Registration request.688688+ */689689+struct fc_els_lirr {690690+ __u8 lirr_cmd; /* command */691691+ __u8 lirr_resv[3]; /* reserved - must be zero */692692+ __u8 lirr_func; /* registration function */693693+ __u8 lirr_fmt; /* FC-4 type of RLIR requested */694694+ __u8 lirr_resv2[2]; /* reserved - must be zero */695695+};696696+697697+enum fc_els_lirr_func {698698+ ELS_LIRR_SET_COND = 0x01, /* set - conditionally receive */699699+ ELS_LIRR_SET_UNCOND = 0x02, /* set - unconditionally receive */700700+ ELS_LIRR_CLEAR = 0xff /* clear registration */701701+};702702+703703+/*704704+ * ELS SRL - Scan Remote Loop request.705705+ */706706+struct fc_els_srl {707707+ __u8 srl_cmd; /* command */708708+ __u8 srl_resv[3]; /* reserved - must be zero */709709+ __u8 srl_flag; /* flag - see below */710710+ __u8 srl_flag_param[3]; /* flag parameter */711711+};712712+713713+enum fc_els_srl_flag {714714+ FC_ELS_SRL_ALL = 0x00, /* scan all FL ports */715715+ FC_ELS_SRL_ONE = 0x01, /* scan specified loop */716716+ FC_ELS_SRL_EN_PER = 0x02, /* enable periodic scanning (param) */717717+ FC_ELS_SRL_DIS_PER = 0x03, /* disable periodic scanning */718718+};719719+720720+/*721721+ * ELS RLS - Read Link Error Status Block request.722722+ */723723+struct fc_els_rls {724724+ __u8 rls_cmd; /* command */725725+ __u8 rls_resv[4]; /* reserved - must be zero */726726+ __u8 rls_port_id[3]; /* port ID */727727+};728728+729729+/*730730+ * ELS RLS LS_ACC Response.731731+ */732732+struct fc_els_rls_resp {733733+ __u8 rls_cmd; /* ELS_LS_ACC */734734+ __u8 rls_resv[3]; /* reserved - must be zero */735735+ struct fc_els_lesb rls_lesb; /* link error status block */736736+};737737+738738+/*739739+ * ELS RLIR - Registered Link Incident Report.740740+ * This is followed by the CLIR and the CLID, described below.741741+ */742742+struct fc_els_rlir {743743+ __u8 rlir_cmd; /* command */744744+ __u8 rlir_resv[3]; /* reserved - must be zero */745745+ __u8 rlir_fmt; /* format (FC4-type if type specific) */746746+ __u8 rlir_clr_len; /* common link incident record length */747747+ __u8 rlir_cld_len; /* common link incident desc. length */748748+ __u8 rlir_slr_len; /* spec. link incident record length */749749+};750750+751751+/*752752+ * CLIR - Common Link Incident Record Data. - Sent via RLIR.753753+ */754754+struct fc_els_clir {755755+ __be64 clir_wwpn; /* incident port name */756756+ __be64 clir_wwnn; /* incident port node name */757757+ __u8 clir_port_type; /* incident port type */758758+ __u8 clir_port_id[3]; /* incident port ID */759759+760760+ __be64 clir_conn_wwpn; /* connected port name */761761+ __be64 clir_conn_wwnn; /* connected node name */762762+ __be64 clir_fab_name; /* fabric name */763763+ __be32 clir_phys_port; /* physical port number */764764+ __be32 clir_trans_id; /* transaction ID */765765+ __u8 clir_resv[3]; /* reserved */766766+ __u8 clir_ts_fmt; /* time stamp format */767767+ __be64 clir_timestamp; /* time stamp */768768+};769769+770770+/*771771+ * CLIR clir_ts_fmt - time stamp format values.772772+ */773773+enum fc_els_clir_ts_fmt {774774+ ELS_CLIR_TS_UNKNOWN = 0, /* time stamp field unknown */775775+ ELS_CLIR_TS_SEC_FRAC = 1, /* time in seconds and fractions */776776+ ELS_CLIR_TS_CSU = 2, /* time in clock synch update format */777777+};778778+779779+/*780780+ * Common Link Incident Descriptor - sent via RLIR.781781+ */782782+struct fc_els_clid {783783+ __u8 clid_iq; /* incident qualifier flags */784784+ __u8 clid_ic; /* incident code */785785+ __be16 clid_epai; /* domain/area of ISL */786786+};787787+788788+/*789789+ * CLID incident qualifier flags.790790+ */791791+enum fc_els_clid_iq {792792+ ELS_CLID_SWITCH = 0x20, /* incident port is a switch node */793793+ ELS_CLID_E_PORT = 0x10, /* incident is an ISL (E) port */794794+ ELS_CLID_SEV_MASK = 0x0c, /* severity 2-bit field mask */795795+ ELS_CLID_SEV_INFO = 0x00, /* report is informational */796796+ ELS_CLID_SEV_INOP = 0x08, /* link not operational */797797+ ELS_CLID_SEV_DEG = 0x04, /* link degraded but operational */798798+ ELS_CLID_LASER = 0x02, /* subassembly is a laser */799799+ ELS_CLID_FRU = 0x01, /* format can identify a FRU */800800+};801801+802802+/*803803+ * CLID incident code.804804+ */805805+enum fc_els_clid_ic {806806+ ELS_CLID_IC_IMPL = 1, /* implicit incident */807807+ ELS_CLID_IC_BER = 2, /* bit-error-rate threshold exceeded */808808+ ELS_CLID_IC_LOS = 3, /* loss of synch or signal */809809+ ELS_CLID_IC_NOS = 4, /* non-operational primitive sequence */810810+ ELS_CLID_IC_PST = 5, /* primitive sequence timeout */811811+ ELS_CLID_IC_INVAL = 6, /* invalid primitive sequence */812812+ ELS_CLID_IC_LOOP_TO = 7, /* loop initialization time out */813813+ ELS_CLID_IC_LIP = 8, /* receiving LIP */814814+};815815+816816+#endif /* _FC_ELS_H_ */
+138
include/scsi/fc/fc_encaps.h
···11+/*22+ * Copyright(c) 2007 Intel Corporation. All rights reserved.33+ *44+ * This program is free software; you can redistribute it and/or modify it55+ * under the terms and conditions of the GNU General Public License,66+ * version 2, as published by the Free Software Foundation.77+ *88+ * This program is distributed in the hope it will be useful, but WITHOUT99+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1010+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for1111+ * more details.1212+ *1313+ * You should have received a copy of the GNU General Public License along with1414+ * this program; if not, write to the Free Software Foundation, Inc.,1515+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.1616+ *1717+ * Maintained at www.Open-FCoE.org1818+ */1919+#ifndef _FC_ENCAPS_H_2020+#define _FC_ENCAPS_H_2121+2222+/*2323+ * Protocol definitions from RFC 3643 - Fibre Channel Frame Encapsulation.2424+ *2525+ * Note: The frame length field is the number of 32-bit words in2626+ * the encapsulation including the fcip_encaps_header, CRC and EOF words.2727+ * The minimum frame length value in bytes is (32 + 24 + 4 + 4) * 4 = 64.2828+ * The maximum frame length value in bytes is (32 + 24 + 2112 + 4 + 4) = 2172.2929+ */3030+#define FC_ENCAPS_MIN_FRAME_LEN 64 /* min frame len (bytes) (see above) */3131+#define FC_ENCAPS_MAX_FRAME_LEN (FC_ENCAPS_MIN_FRAME_LEN + FC_MAX_PAYLOAD)3232+3333+#define FC_ENCAPS_VER 1 /* current version number */3434+3535+struct fc_encaps_hdr {3636+ __u8 fc_proto; /* protocol number */3737+ __u8 fc_ver; /* version of encapsulation */3838+ __u8 fc_proto_n; /* ones complement of protocol */3939+ __u8 fc_ver_n; /* ones complement of version */4040+4141+ unsigned char fc_proto_data[8]; /* protocol specific data */4242+4343+ __be16 fc_len_flags; /* 10-bit length/4 w/ 6 flag bits */4444+ __be16 fc_len_flags_n; /* ones complement of length / flags */4545+4646+ /*4747+ * Offset 0x104848+ */4949+ __be32 fc_time[2]; /* time stamp: seconds and fraction */5050+ __be32 fc_crc; /* CRC */5151+ __be32 fc_sof; /* start of frame (see FC_SOF below) */5252+5353+ /* 0x20 - FC frame content followed by EOF word */5454+};5555+5656+#define FCIP_ENCAPS_HDR_LEN 0x20 /* expected length for asserts */5757+5858+/*5959+ * Macro's for making redundant copies of EOF and SOF.6060+ */6161+#define FC_XY(x, y) ((((x) & 0xff) << 8) | ((y) & 0xff))6262+#define FC_XYXY(x, y) ((FCIP_XY(x, y) << 16) | FCIP_XY(x, y))6363+#define FC_XYNN(x, y) (FCIP_XYXY(x, y) ^ 0xffff)6464+6565+#define FC_SOF_ENCODE(n) FC_XYNN(n, n)6666+#define FC_EOF_ENCODE(n) FC_XYNN(n, n)6767+6868+/*6969+ * SOF / EOF bytes.7070+ */7171+enum fc_sof {7272+ FC_SOF_F = 0x28, /* fabric */7373+ FC_SOF_I4 = 0x29, /* initiate class 4 */7474+ FC_SOF_I2 = 0x2d, /* initiate class 2 */7575+ FC_SOF_I3 = 0x2e, /* initiate class 3 */7676+ FC_SOF_N4 = 0x31, /* normal class 4 */7777+ FC_SOF_N2 = 0x35, /* normal class 2 */7878+ FC_SOF_N3 = 0x36, /* normal class 3 */7979+ FC_SOF_C4 = 0x39, /* activate class 4 */8080+} __attribute__((packed));8181+8282+enum fc_eof {8383+ FC_EOF_N = 0x41, /* normal (not last frame of seq) */8484+ FC_EOF_T = 0x42, /* terminate (last frame of sequence) */8585+ FC_EOF_RT = 0x44,8686+ FC_EOF_DT = 0x46, /* disconnect-terminate class-1 */8787+ FC_EOF_NI = 0x49, /* normal-invalid */8888+ FC_EOF_DTI = 0x4e, /* disconnect-terminate-invalid */8989+ FC_EOF_RTI = 0x4f,9090+ FC_EOF_A = 0x50, /* abort */9191+} __attribute__((packed));9292+9393+#define FC_SOF_CLASS_MASK 0x06 /* mask for class of service in SOF */9494+9595+/*9696+ * Define classes in terms of the SOF code (initial).9797+ */9898+enum fc_class {9999+ FC_CLASS_NONE = 0, /* software value indicating no class */100100+ FC_CLASS_2 = FC_SOF_I2,101101+ FC_CLASS_3 = FC_SOF_I3,102102+ FC_CLASS_4 = FC_SOF_I4,103103+ FC_CLASS_F = FC_SOF_F,104104+};105105+106106+/*107107+ * Determine whether SOF code indicates the need for a BLS ACK.108108+ */109109+static inline int fc_sof_needs_ack(enum fc_sof sof)110110+{111111+ return (~sof) & 0x02; /* true for class 1, 2, 4, 6, or F */112112+}113113+114114+/*115115+ * Given an fc_class, return the normal (non-initial) SOF value.116116+ */117117+static inline enum fc_sof fc_sof_normal(enum fc_class class)118118+{119119+ return class + FC_SOF_N3 - FC_SOF_I3; /* diff is always 8 */120120+}121121+122122+/*123123+ * Compute class from SOF value.124124+ */125125+static inline enum fc_class fc_sof_class(enum fc_sof sof)126126+{127127+ return (sof & 0x7) | FC_SOF_F;128128+}129129+130130+/*131131+ * Determine whether SOF is for the initial frame of a sequence.132132+ */133133+static inline int fc_sof_is_init(enum fc_sof sof)134134+{135135+ return sof < 0x30;136136+}137137+138138+#endif /* _FC_ENCAPS_H_ */
+124
include/scsi/fc/fc_fc2.h
···11+/*22+ * Copyright(c) 2007 Intel Corporation. All rights reserved.33+ *44+ * This program is free software; you can redistribute it and/or modify it55+ * under the terms and conditions of the GNU General Public License,66+ * version 2, as published by the Free Software Foundation.77+ *88+ * This program is distributed in the hope it will be useful, but WITHOUT99+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1010+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for1111+ * more details.1212+ *1313+ * You should have received a copy of the GNU General Public License along with1414+ * this program; if not, write to the Free Software Foundation, Inc.,1515+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.1616+ *1717+ * Maintained at www.Open-FCoE.org1818+ */1919+2020+#ifndef _FC_FC2_H_2121+#define _FC_FC2_H_2222+2323+/*2424+ * Fibre Channel Exchanges and Sequences.2525+ */2626+#ifndef PACKED2727+#define PACKED __attribute__ ((__packed__))2828+#endif /* PACKED */2929+3030+3131+/*3232+ * Sequence Status Block.3333+ * This format is set by the FC-FS standard and is sent over the wire.3434+ * Note that the fields aren't all naturally aligned.3535+ */3636+struct fc_ssb {3737+ __u8 ssb_seq_id; /* sequence ID */3838+ __u8 _ssb_resvd;3939+ __be16 ssb_low_seq_cnt; /* lowest SEQ_CNT */4040+4141+ __be16 ssb_high_seq_cnt; /* highest SEQ_CNT */4242+ __be16 ssb_s_stat; /* sequence status flags */4343+4444+ __be16 ssb_err_seq_cnt; /* error SEQ_CNT */4545+ __u8 ssb_fh_cs_ctl; /* frame header CS_CTL */4646+ __be16 ssb_fh_ox_id; /* frame header OX_ID */4747+ __be16 ssb_rx_id; /* responder's exchange ID */4848+ __u8 _ssb_resvd2[2];4949+} PACKED;5050+5151+/*5252+ * The SSB should be 17 bytes. Since it's layout is somewhat strange,5353+ * we define the size here so that code can ASSERT that the size comes out5454+ * correct.5555+ */5656+#define FC_SSB_SIZE 17 /* length of fc_ssb for assert */5757+5858+/*5959+ * ssb_s_stat - flags from FC-FS-2 T11/1619-D Rev 0.90.6060+ */6161+#define SSB_ST_RESP (1 << 15) /* sequence responder */6262+#define SSB_ST_ACTIVE (1 << 14) /* sequence is active */6363+#define SSB_ST_ABNORMAL (1 << 12) /* abnormal ending condition */6464+6565+#define SSB_ST_REQ_MASK (3 << 10) /* ACK, abort sequence condition */6666+#define SSB_ST_REQ_CONT (0 << 10)6767+#define SSB_ST_REQ_ABORT (1 << 10)6868+#define SSB_ST_REQ_STOP (2 << 10)6969+#define SSB_ST_REQ_RETRANS (3 << 10)7070+7171+#define SSB_ST_ABTS (1 << 9) /* ABTS protocol completed */7272+#define SSB_ST_RETRANS (1 << 8) /* retransmission completed */7373+#define SSB_ST_TIMEOUT (1 << 7) /* sequence timed out by recipient */7474+#define SSB_ST_P_RJT (1 << 6) /* P_RJT transmitted */7575+7676+#define SSB_ST_CLASS_BIT 4 /* class of service field LSB */7777+#define SSB_ST_CLASS_MASK 3 /* class of service mask */7878+#define SSB_ST_ACK (1 << 3) /* ACK (EOFt or EOFdt) transmitted */7979+8080+/*8181+ * Exchange Status Block.8282+ * This format is set by the FC-FS standard and is sent over the wire.8383+ * Note that the fields aren't all naturally aligned.8484+ */8585+struct fc_esb {8686+ __u8 esb_cs_ctl; /* CS_CTL for frame header */8787+ __be16 esb_ox_id; /* originator exchange ID */8888+ __be16 esb_rx_id; /* responder exchange ID */8989+ __be32 esb_orig_fid; /* fabric ID of originator */9090+ __be32 esb_resp_fid; /* fabric ID of responder */9191+ __be32 esb_e_stat; /* status */9292+ __u8 _esb_resvd[4];9393+ __u8 esb_service_params[112]; /* TBD */9494+ __u8 esb_seq_status[8]; /* sequence statuses, 8 bytes each */9595+} __attribute__((packed));;9696+9797+9898+/*9999+ * Define expected size for ASSERTs.100100+ * See comments on FC_SSB_SIZE.101101+ */102102+#define FC_ESB_SIZE (1 + 5*4 + 112 + 8) /* expected size */103103+104104+/*105105+ * esb_e_stat - flags from FC-FS-2 T11/1619-D Rev 0.90.106106+ */107107+#define ESB_ST_RESP (1 << 31) /* responder to exchange */108108+#define ESB_ST_SEQ_INIT (1 << 30) /* port holds sequence initiaive */109109+#define ESB_ST_COMPLETE (1 << 29) /* exchange is complete */110110+#define ESB_ST_ABNORMAL (1 << 28) /* abnormal ending condition */111111+#define ESB_ST_REC_QUAL (1 << 26) /* recovery qualifier active */112112+113113+#define ESB_ST_ERRP_BIT 24 /* LSB for error policy */114114+#define ESB_ST_ERRP_MASK (3 << 24) /* mask for error policy */115115+#define ESB_ST_ERRP_MULT (0 << 24) /* abort, discard multiple sequences */116116+#define ESB_ST_ERRP_SING (1 << 24) /* abort, discard single sequence */117117+#define ESB_ST_ERRP_INF (2 << 24) /* process with infinite buffers */118118+#define ESB_ST_ERRP_IMM (3 << 24) /* discard mult. with immed. retran. */119119+120120+#define ESB_ST_OX_ID_INVL (1 << 23) /* originator XID invalid */121121+#define ESB_ST_RX_ID_INVL (1 << 22) /* responder XID invalid */122122+#define ESB_ST_PRI_INUSE (1 << 21) /* priority / preemption in use */123123+124124+#endif /* _FC_FC2_H_ */
+114
include/scsi/fc/fc_fcoe.h
···11+/*22+ * Copyright(c) 2007 Intel Corporation. All rights reserved.33+ *44+ * This program is free software; you can redistribute it and/or modify it55+ * under the terms and conditions of the GNU General Public License,66+ * version 2, as published by the Free Software Foundation.77+ *88+ * This program is distributed in the hope it will be useful, but WITHOUT99+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1010+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for1111+ * more details.1212+ *1313+ * You should have received a copy of the GNU General Public License along with1414+ * this program; if not, write to the Free Software Foundation, Inc.,1515+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.1616+ *1717+ * Maintained at www.Open-FCoE.org1818+ */1919+2020+#ifndef _FC_FCOE_H_2121+#define _FC_FCOE_H_2222+2323+/*2424+ * FCoE - Fibre Channel over Ethernet.2525+ */2626+2727+/*2828+ * The FCoE ethertype eventually goes in net/if_ether.h.2929+ */3030+#ifndef ETH_P_FCOE3131+#define ETH_P_FCOE 0x8906 /* FCOE ether type */3232+#endif3333+3434+#ifndef ETH_P_8021Q3535+#define ETH_P_8021Q 0x81003636+#endif3737+3838+/*3939+ * FC_FCOE_OUI hasn't been standardized yet. XXX TBD.4040+ */4141+#ifndef FC_FCOE_OUI4242+#define FC_FCOE_OUI 0x0efc00 /* upper 24 bits of FCOE dest MAC TBD */4343+#endif4444+4545+/*4646+ * The destination MAC address for the fabric login may get a different OUI.4747+ * This isn't standardized yet.4848+ */4949+#ifndef FC_FCOE_FLOGI_MAC5050+/* gateway MAC - TBD */5151+#define FC_FCOE_FLOGI_MAC { 0x0e, 0xfc, 0x00, 0xff, 0xff, 0xfe }5252+#endif5353+5454+#define FC_FCOE_VER 0 /* version */5555+5656+/*5757+ * Ethernet Addresses based on FC S_ID and D_ID.5858+ * Generated by FC_FCOE_OUI | S_ID/D_ID5959+ */6060+#define FC_FCOE_ENCAPS_ID(n) (((u64) FC_FCOE_OUI << 24) | (n))6161+#define FC_FCOE_DECAPS_ID(n) ((n) >> 24)6262+6363+/*6464+ * FCoE frame header - 14 bytes6565+ *6666+ * This is the August 2007 version of the FCoE header as defined by T11.6767+ * This follows the VLAN header, which includes the ethertype.6868+ */6969+struct fcoe_hdr {7070+ __u8 fcoe_ver; /* version field - upper 4 bits */7171+ __u8 fcoe_resvd[12]; /* reserved - send zero and ignore */7272+ __u8 fcoe_sof; /* start of frame per RFC 3643 */7373+};7474+7575+#define FC_FCOE_DECAPS_VER(hp) ((hp)->fcoe_ver >> 4)7676+#define FC_FCOE_ENCAPS_VER(hp, ver) ((hp)->fcoe_ver = (ver) << 4)7777+7878+/*7979+ * FCoE CRC & EOF - 8 bytes.8080+ */8181+struct fcoe_crc_eof {8282+ __le32 fcoe_crc32; /* CRC for FC packet */8383+ __u8 fcoe_eof; /* EOF from RFC 3643 */8484+ __u8 fcoe_resvd[3]; /* reserved - send zero and ignore */8585+} __attribute__((packed));8686+8787+/*8888+ * Minimum FCoE + FC header length8989+ * 14 bytes FCoE header + 24 byte FC header = 38 bytes9090+ */9191+#define FCOE_HEADER_LEN 389292+9393+/*9494+ * Minimum FCoE frame size9595+ * 14 bytes FCoE header + 24 byte FC header + 8 byte FCoE trailer = 46 bytes9696+ */9797+#define FCOE_MIN_FRAME 469898+9999+/*100100+ * fc_fcoe_set_mac - Store OUI + DID into MAC address field.101101+ * @mac: mac address to be set102102+ * @did: fc dest id to use103103+ */104104+static inline void fc_fcoe_set_mac(u8 *mac, u8 *did)105105+{106106+ mac[0] = (u8) (FC_FCOE_OUI >> 16);107107+ mac[1] = (u8) (FC_FCOE_OUI >> 8);108108+ mac[2] = (u8) FC_FCOE_OUI;109109+ mac[3] = did[0];110110+ mac[4] = did[1];111111+ mac[5] = did[2];112112+}113113+114114+#endif /* _FC_FCOE_H_ */
+199
include/scsi/fc/fc_fcp.h
···11+/*22+ * Copyright(c) 2007 Intel Corporation. All rights reserved.33+ *44+ * This program is free software; you can redistribute it and/or modify it55+ * under the terms and conditions of the GNU General Public License,66+ * version 2, as published by the Free Software Foundation.77+ *88+ * This program is distributed in the hope it will be useful, but WITHOUT99+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1010+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for1111+ * more details.1212+ *1313+ * You should have received a copy of the GNU General Public License along with1414+ * this program; if not, write to the Free Software Foundation, Inc.,1515+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.1616+ *1717+ * Maintained at www.Open-FCoE.org1818+ */1919+2020+#ifndef _FC_FCP_H_2121+#define _FC_FCP_H_2222+2323+/*2424+ * Fibre Channel Protocol for SCSI.2525+ * From T10 FCP-3, T10 project 1560-D Rev 4, Sept. 13, 2005.2626+ */2727+2828+/*2929+ * fc/fs.h defines FC_TYPE_FCP.3030+ */3131+3232+/*3333+ * Service parameter page parameters (word 3 bits) for Process Login.3434+ */3535+#define FCP_SPPF_TASK_RETRY_ID 0x0200 /* task retry ID requested */3636+#define FCP_SPPF_RETRY 0x0100 /* retry supported */3737+#define FCP_SPPF_CONF_COMPL 0x0080 /* confirmed completion allowed */3838+#define FCP_SPPF_OVLY_ALLOW 0x0040 /* data overlay allowed */3939+#define FCP_SPPF_INIT_FCN 0x0020 /* initiator function */4040+#define FCP_SPPF_TARG_FCN 0x0010 /* target function */4141+#define FCP_SPPF_RD_XRDY_DIS 0x0002 /* disable XFER_RDY for reads */4242+#define FCP_SPPF_WR_XRDY_DIS 0x0001 /* disable XFER_RDY for writes */4343+4444+/*4545+ * FCP_CMND IU Payload.4646+ */4747+struct fcp_cmnd {4848+ __u8 fc_lun[8]; /* logical unit number */4949+ __u8 fc_cmdref; /* commmand reference number */5050+ __u8 fc_pri_ta; /* priority and task attribute */5151+ __u8 fc_tm_flags; /* task management flags */5252+ __u8 fc_flags; /* additional len & flags */5353+ __u8 fc_cdb[16]; /* base CDB */5454+ __be32 fc_dl; /* data length (must follow fc_cdb) */5555+};5656+5757+#define FCP_CMND_LEN 32 /* expected length of structure */5858+5959+struct fcp_cmnd32 {6060+ __u8 fc_lun[8]; /* logical unit number */6161+ __u8 fc_cmdref; /* commmand reference number */6262+ __u8 fc_pri_ta; /* priority and task attribute */6363+ __u8 fc_tm_flags; /* task management flags */6464+ __u8 fc_flags; /* additional len & flags */6565+ __u8 fc_cdb[32]; /* base CDB */6666+ __be32 fc_dl; /* data length (must follow fc_cdb) */6767+};6868+6969+#define FCP_CMND32_LEN 48 /* expected length of structure */7070+#define FCP_CMND32_ADD_LEN (16 / 4) /* Additional cdb length */7171+7272+/*7373+ * fc_pri_ta.7474+ */7575+#define FCP_PTA_SIMPLE 0 /* simple task attribute */7676+#define FCP_PTA_HEADQ 1 /* head of queue task attribute */7777+#define FCP_PTA_ORDERED 2 /* ordered task attribute */7878+#define FCP_PTA_ACA 4 /* auto. contigent allegiance */7979+#define FCP_PRI_SHIFT 3 /* priority field starts in bit 3 */8080+#define FCP_PRI_RESVD_MASK 0x80 /* reserved bits in priority field */8181+8282+/*8383+ * fc_tm_flags - task management flags field.8484+ */8585+#define FCP_TMF_CLR_ACA 0x40 /* clear ACA condition */8686+#define FCP_TMF_LUN_RESET 0x10 /* logical unit reset task management */8787+#define FCP_TMF_CLR_TASK_SET 0x04 /* clear task set */8888+#define FCP_TMF_ABT_TASK_SET 0x02 /* abort task set */8989+9090+/*9191+ * fc_flags.9292+ * Bits 7:2 are the additional FCP_CDB length / 4.9393+ */9494+#define FCP_CFL_LEN_MASK 0xfc /* mask for additional length */9595+#define FCP_CFL_LEN_SHIFT 2 /* shift bits for additional length */9696+#define FCP_CFL_RDDATA 0x02 /* read data */9797+#define FCP_CFL_WRDATA 0x01 /* write data */9898+9999+/*100100+ * FCP_TXRDY IU - transfer ready payload.101101+ */102102+struct fcp_txrdy {103103+ __be32 ft_data_ro; /* data relative offset */104104+ __be32 ft_burst_len; /* burst length */105105+ __u8 _ft_resvd[4]; /* reserved */106106+};107107+108108+#define FCP_TXRDY_LEN 12 /* expected length of structure */109109+110110+/*111111+ * FCP_RESP IU - response payload.112112+ *113113+ * The response payload comes in three parts: the flags/status, the114114+ * sense/response lengths and the sense data/response info section.115115+ *116116+ * From FCP3r04, note 6 of section 9.5.13:117117+ *118118+ * Some early implementations presented the FCP_RSP IU without the FCP_RESID,119119+ * FCP_SNS_LEN, and FCP_RSP_LEN fields if the FCP_RESID_UNDER, FCP_RESID_OVER,120120+ * FCP_SNS_LEN_VALID, and FCP_RSP_LEN_VALID bits were all set to zero. This121121+ * non-standard behavior should be tolerated.122122+ *123123+ * All response frames will always contain the fcp_resp template. Some124124+ * will also include the fcp_resp_len template.125125+ */126126+struct fcp_resp {127127+ __u8 _fr_resvd[8]; /* reserved */128128+ __be16 fr_retry_delay; /* retry delay timer */129129+ __u8 fr_flags; /* flags */130130+ __u8 fr_status; /* SCSI status code */131131+};132132+133133+#define FCP_RESP_LEN 12 /* expected length of structure */134134+135135+struct fcp_resp_ext {136136+ __be32 fr_resid; /* Residual value */137137+ __be32 fr_sns_len; /* SCSI Sense length */138138+ __be32 fr_rsp_len; /* Response Info length */139139+140140+ /*141141+ * Optionally followed by RSP info and/or SNS info and/or142142+ * bidirectional read residual length, if any.143143+ */144144+};145145+146146+#define FCP_RESP_EXT_LEN 12 /* expected length of the structure */147147+148148+struct fcp_resp_rsp_info {149149+ __u8 _fr_resvd[3]; /* reserved */150150+ __u8 rsp_code; /* Response Info Code */151151+ __u8 _fr_resvd2[4]; /* reserved */152152+};153153+154154+struct fcp_resp_with_ext {155155+ struct fcp_resp resp;156156+ struct fcp_resp_ext ext;157157+};158158+159159+#define FCP_RESP_WITH_EXT (FCP_RESP_LEN + FCP_RESP_EXT_LEN)160160+161161+/*162162+ * fr_flags.163163+ */164164+#define FCP_BIDI_RSP 0x80 /* bidirectional read response */165165+#define FCP_BIDI_READ_UNDER 0x40 /* bidir. read less than requested */166166+#define FCP_BIDI_READ_OVER 0x20 /* DL insufficient for full transfer */167167+#define FCP_CONF_REQ 0x10 /* confirmation requested */168168+#define FCP_RESID_UNDER 0x08 /* transfer shorter than expected */169169+#define FCP_RESID_OVER 0x04 /* DL insufficient for full transfer */170170+#define FCP_SNS_LEN_VAL 0x02 /* SNS_LEN field is valid */171171+#define FCP_RSP_LEN_VAL 0x01 /* RSP_LEN field is valid */172172+173173+/*174174+ * rsp_codes175175+ */176176+enum fcp_resp_rsp_codes {177177+ FCP_TMF_CMPL = 0,178178+ FCP_DATA_LEN_INVALID = 1,179179+ FCP_CMND_FIELDS_INVALID = 2,180180+ FCP_DATA_PARAM_MISMATCH = 3,181181+ FCP_TMF_REJECTED = 4,182182+ FCP_TMF_FAILED = 5,183183+ FCP_TMF_INVALID_LUN = 9,184184+};185185+186186+/*187187+ * FCP SRR Link Service request - Sequence Retransmission Request.188188+ */189189+struct fcp_srr {190190+ __u8 srr_op; /* opcode ELS_SRR */191191+ __u8 srr_resvd[3]; /* opcode / reserved - must be zero */192192+ __be16 srr_ox_id; /* OX_ID of failed command */193193+ __be16 srr_rx_id; /* RX_ID of failed command */194194+ __be32 srr_rel_off; /* relative offset */195195+ __u8 srr_r_ctl; /* r_ctl for the information unit */196196+ __u8 srr_resvd2[3]; /* reserved */197197+};198198+199199+#endif /* _FC_FCP_H_ */
+340
include/scsi/fc/fc_fs.h
···11+/*22+ * Copyright(c) 2007 Intel Corporation. All rights reserved.33+ *44+ * This program is free software; you can redistribute it and/or modify it55+ * under the terms and conditions of the GNU General Public License,66+ * version 2, as published by the Free Software Foundation.77+ *88+ * This program is distributed in the hope it will be useful, but WITHOUT99+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1010+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for1111+ * more details.1212+ *1313+ * You should have received a copy of the GNU General Public License along with1414+ * this program; if not, write to the Free Software Foundation, Inc.,1515+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.1616+ *1717+ * Maintained at www.Open-FCoE.org1818+ */1919+2020+#ifndef _FC_FS_H_2121+#define _FC_FS_H_2222+2323+/*2424+ * Fibre Channel Framing and Signalling definitions.2525+ * From T11 FC-FS-2 Rev 0.90 - 9 August 2005.2626+ */2727+2828+/*2929+ * Frame header3030+ */3131+struct fc_frame_header {3232+ __u8 fh_r_ctl; /* routing control */3333+ __u8 fh_d_id[3]; /* Destination ID */3434+3535+ __u8 fh_cs_ctl; /* class of service control / pri */3636+ __u8 fh_s_id[3]; /* Source ID */3737+3838+ __u8 fh_type; /* see enum fc_fh_type below */3939+ __u8 fh_f_ctl[3]; /* frame control */4040+4141+ __u8 fh_seq_id; /* sequence ID */4242+ __u8 fh_df_ctl; /* data field control */4343+ __be16 fh_seq_cnt; /* sequence count */4444+4545+ __be16 fh_ox_id; /* originator exchange ID */4646+ __be16 fh_rx_id; /* responder exchange ID */4747+ __be32 fh_parm_offset; /* parameter or relative offset */4848+};4949+5050+#define FC_FRAME_HEADER_LEN 24 /* expected length of structure */5151+5252+#define FC_MAX_PAYLOAD 2112U /* max payload length in bytes */5353+#define FC_MIN_MAX_PAYLOAD 256U /* lower limit on max payload */5454+5555+#define FC_MAX_FRAME (FC_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)5656+#define FC_MIN_MAX_FRAME (FC_MIN_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)5757+5858+/*5959+ * fh_r_ctl - Routing control definitions.6060+ */6161+ /*6262+ * FC-4 device_data.6363+ */6464+enum fc_rctl {6565+ FC_RCTL_DD_UNCAT = 0x00, /* uncategorized information */6666+ FC_RCTL_DD_SOL_DATA = 0x01, /* solicited data */6767+ FC_RCTL_DD_UNSOL_CTL = 0x02, /* unsolicited control */6868+ FC_RCTL_DD_SOL_CTL = 0x03, /* solicited control or reply */6969+ FC_RCTL_DD_UNSOL_DATA = 0x04, /* unsolicited data */7070+ FC_RCTL_DD_DATA_DESC = 0x05, /* data descriptor */7171+ FC_RCTL_DD_UNSOL_CMD = 0x06, /* unsolicited command */7272+ FC_RCTL_DD_CMD_STATUS = 0x07, /* command status */7373+7474+#define FC_RCTL_ILS_REQ FC_RCTL_DD_UNSOL_CTL /* ILS request */7575+#define FC_RCTL_ILS_REP FC_RCTL_DD_SOL_CTL /* ILS reply */7676+7777+ /*7878+ * Extended Link_Data7979+ */8080+ FC_RCTL_ELS_REQ = 0x22, /* extended link services request */8181+ FC_RCTL_ELS_REP = 0x23, /* extended link services reply */8282+ FC_RCTL_ELS4_REQ = 0x32, /* FC-4 ELS request */8383+ FC_RCTL_ELS4_REP = 0x33, /* FC-4 ELS reply */8484+ /*8585+ * Optional Extended Headers8686+ */8787+ FC_RCTL_VFTH = 0x50, /* virtual fabric tagging header */8888+ FC_RCTL_IFRH = 0x51, /* inter-fabric routing header */8989+ FC_RCTL_ENCH = 0x52, /* encapsulation header */9090+ /*9191+ * Basic Link Services fh_r_ctl values.9292+ */9393+ FC_RCTL_BA_NOP = 0x80, /* basic link service NOP */9494+ FC_RCTL_BA_ABTS = 0x81, /* basic link service abort */9595+ FC_RCTL_BA_RMC = 0x82, /* remove connection */9696+ FC_RCTL_BA_ACC = 0x84, /* basic accept */9797+ FC_RCTL_BA_RJT = 0x85, /* basic reject */9898+ FC_RCTL_BA_PRMT = 0x86, /* dedicated connection preempted */9999+ /*100100+ * Link Control Information.101101+ */102102+ FC_RCTL_ACK_1 = 0xc0, /* acknowledge_1 */103103+ FC_RCTL_ACK_0 = 0xc1, /* acknowledge_0 */104104+ FC_RCTL_P_RJT = 0xc2, /* port reject */105105+ FC_RCTL_F_RJT = 0xc3, /* fabric reject */106106+ FC_RCTL_P_BSY = 0xc4, /* port busy */107107+ FC_RCTL_F_BSY = 0xc5, /* fabric busy to data frame */108108+ FC_RCTL_F_BSYL = 0xc6, /* fabric busy to link control frame */109109+ FC_RCTL_LCR = 0xc7, /* link credit reset */110110+ FC_RCTL_END = 0xc9, /* end */111111+};112112+ /* incomplete list of definitions */113113+114114+/*115115+ * R_CTL names initializer.116116+ * Please keep this matching the above definitions.117117+ */118118+#define FC_RCTL_NAMES_INIT { \119119+ [FC_RCTL_DD_UNCAT] = "uncat", \120120+ [FC_RCTL_DD_SOL_DATA] = "sol data", \121121+ [FC_RCTL_DD_UNSOL_CTL] = "unsol ctl", \122122+ [FC_RCTL_DD_SOL_CTL] = "sol ctl/reply", \123123+ [FC_RCTL_DD_UNSOL_DATA] = "unsol data", \124124+ [FC_RCTL_DD_DATA_DESC] = "data desc", \125125+ [FC_RCTL_DD_UNSOL_CMD] = "unsol cmd", \126126+ [FC_RCTL_DD_CMD_STATUS] = "cmd status", \127127+ [FC_RCTL_ELS_REQ] = "ELS req", \128128+ [FC_RCTL_ELS_REP] = "ELS rep", \129129+ [FC_RCTL_ELS4_REQ] = "FC-4 ELS req", \130130+ [FC_RCTL_ELS4_REP] = "FC-4 ELS rep", \131131+ [FC_RCTL_BA_NOP] = "BLS NOP", \132132+ [FC_RCTL_BA_ABTS] = "BLS abort", \133133+ [FC_RCTL_BA_RMC] = "BLS remove connection", \134134+ [FC_RCTL_BA_ACC] = "BLS accept", \135135+ [FC_RCTL_BA_RJT] = "BLS reject", \136136+ [FC_RCTL_BA_PRMT] = "BLS dedicated connection preempted", \137137+ [FC_RCTL_ACK_1] = "LC ACK_1", \138138+ [FC_RCTL_ACK_0] = "LC ACK_0", \139139+ [FC_RCTL_P_RJT] = "LC port reject", \140140+ [FC_RCTL_F_RJT] = "LC fabric reject", \141141+ [FC_RCTL_P_BSY] = "LC port busy", \142142+ [FC_RCTL_F_BSY] = "LC fabric busy to data frame", \143143+ [FC_RCTL_F_BSYL] = "LC fabric busy to link control frame",\144144+ [FC_RCTL_LCR] = "LC link credit reset", \145145+ [FC_RCTL_END] = "LC end", \146146+}147147+148148+/*149149+ * Well-known fabric addresses.150150+ */151151+enum fc_well_known_fid {152152+ FC_FID_BCAST = 0xffffff, /* broadcast */153153+ FC_FID_FLOGI = 0xfffffe, /* fabric login */154154+ FC_FID_FCTRL = 0xfffffd, /* fabric controller */155155+ FC_FID_DIR_SERV = 0xfffffc, /* directory server */156156+ FC_FID_TIME_SERV = 0xfffffb, /* time server */157157+ FC_FID_MGMT_SERV = 0xfffffa, /* management server */158158+ FC_FID_QOS = 0xfffff9, /* QoS Facilitator */159159+ FC_FID_ALIASES = 0xfffff8, /* alias server (FC-PH2) */160160+ FC_FID_SEC_KEY = 0xfffff7, /* Security key dist. server */161161+ FC_FID_CLOCK = 0xfffff6, /* clock synch server */162162+ FC_FID_MCAST_SERV = 0xfffff5, /* multicast server */163163+};164164+165165+#define FC_FID_WELL_KNOWN_MAX 0xffffff /* highest well-known fabric ID */166166+#define FC_FID_WELL_KNOWN_BASE 0xfffff5 /* start of well-known fabric ID */167167+168168+/*169169+ * Other well-known addresses, outside the above contiguous range.170170+ */171171+#define FC_FID_DOM_MGR 0xfffc00 /* domain manager base */172172+173173+/*174174+ * Fabric ID bytes.175175+ */176176+#define FC_FID_DOMAIN 0177177+#define FC_FID_PORT 1178178+#define FC_FID_LINK 2179179+180180+/*181181+ * fh_type codes182182+ */183183+enum fc_fh_type {184184+ FC_TYPE_BLS = 0x00, /* basic link service */185185+ FC_TYPE_ELS = 0x01, /* extended link service */186186+ FC_TYPE_IP = 0x05, /* IP over FC, RFC 4338 */187187+ FC_TYPE_FCP = 0x08, /* SCSI FCP */188188+ FC_TYPE_CT = 0x20, /* Fibre Channel Services (FC-CT) */189189+ FC_TYPE_ILS = 0x22, /* internal link service */190190+};191191+192192+/*193193+ * FC_TYPE names initializer.194194+ * Please keep this matching the above definitions.195195+ */196196+#define FC_TYPE_NAMES_INIT { \197197+ [FC_TYPE_BLS] = "BLS", \198198+ [FC_TYPE_ELS] = "ELS", \199199+ [FC_TYPE_IP] = "IP", \200200+ [FC_TYPE_FCP] = "FCP", \201201+ [FC_TYPE_CT] = "CT", \202202+ [FC_TYPE_ILS] = "ILS", \203203+}204204+205205+/*206206+ * Exchange IDs.207207+ */208208+#define FC_XID_UNKNOWN 0xffff /* unknown exchange ID */209209+#define FC_XID_MIN 0x0 /* supported min exchange ID */210210+#define FC_XID_MAX 0xfffe /* supported max exchange ID */211211+212212+/*213213+ * fh_f_ctl - Frame control flags.214214+ */215215+#define FC_FC_EX_CTX (1 << 23) /* sent by responder to exchange */216216+#define FC_FC_SEQ_CTX (1 << 22) /* sent by responder to sequence */217217+#define FC_FC_FIRST_SEQ (1 << 21) /* first sequence of this exchange */218218+#define FC_FC_LAST_SEQ (1 << 20) /* last sequence of this exchange */219219+#define FC_FC_END_SEQ (1 << 19) /* last frame of sequence */220220+#define FC_FC_END_CONN (1 << 18) /* end of class 1 connection pending */221221+#define FC_FC_RES_B17 (1 << 17) /* reserved */222222+#define FC_FC_SEQ_INIT (1 << 16) /* transfer of sequence initiative */223223+#define FC_FC_X_ID_REASS (1 << 15) /* exchange ID has been changed */224224+#define FC_FC_X_ID_INVAL (1 << 14) /* exchange ID invalidated */225225+226226+#define FC_FC_ACK_1 (1 << 12) /* 13:12 = 1: ACK_1 expected */227227+#define FC_FC_ACK_N (2 << 12) /* 13:12 = 2: ACK_N expected */228228+#define FC_FC_ACK_0 (3 << 12) /* 13:12 = 3: ACK_0 expected */229229+230230+#define FC_FC_RES_B11 (1 << 11) /* reserved */231231+#define FC_FC_RES_B10 (1 << 10) /* reserved */232232+#define FC_FC_RETX_SEQ (1 << 9) /* retransmitted sequence */233233+#define FC_FC_UNI_TX (1 << 8) /* unidirectional transmit (class 1) */234234+#define FC_FC_CONT_SEQ(i) ((i) << 6)235235+#define FC_FC_ABT_SEQ(i) ((i) << 4)236236+#define FC_FC_REL_OFF (1 << 3) /* parameter is relative offset */237237+#define FC_FC_RES2 (1 << 2) /* reserved */238238+#define FC_FC_FILL(i) ((i) & 3) /* 1:0: bytes of trailing fill */239239+240240+/*241241+ * BA_ACC payload.242242+ */243243+struct fc_ba_acc {244244+ __u8 ba_seq_id_val; /* SEQ_ID validity */245245+#define FC_BA_SEQ_ID_VAL 0x80246246+ __u8 ba_seq_id; /* SEQ_ID of seq last deliverable */247247+ __u8 ba_resvd[2]; /* reserved */248248+ __be16 ba_ox_id; /* OX_ID for aborted seq or exch */249249+ __be16 ba_rx_id; /* RX_ID for aborted seq or exch */250250+ __be16 ba_low_seq_cnt; /* low SEQ_CNT of aborted seq */251251+ __be16 ba_high_seq_cnt; /* high SEQ_CNT of aborted seq */252252+};253253+254254+/*255255+ * BA_RJT: Basic Reject payload.256256+ */257257+struct fc_ba_rjt {258258+ __u8 br_resvd; /* reserved */259259+ __u8 br_reason; /* reason code */260260+ __u8 br_explan; /* reason explanation */261261+ __u8 br_vendor; /* vendor unique code */262262+};263263+264264+/*265265+ * BA_RJT reason codes.266266+ * From FS-2.267267+ */268268+enum fc_ba_rjt_reason {269269+ FC_BA_RJT_NONE = 0, /* in software this means no reject */270270+ FC_BA_RJT_INVL_CMD = 0x01, /* invalid command code */271271+ FC_BA_RJT_LOG_ERR = 0x03, /* logical error */272272+ FC_BA_RJT_LOG_BUSY = 0x05, /* logical busy */273273+ FC_BA_RJT_PROTO_ERR = 0x07, /* protocol error */274274+ FC_BA_RJT_UNABLE = 0x09, /* unable to perform request */275275+ FC_BA_RJT_VENDOR = 0xff, /* vendor-specific (see br_vendor) */276276+};277277+278278+/*279279+ * BA_RJT reason code explanations.280280+ */281281+enum fc_ba_rjt_explan {282282+ FC_BA_RJT_EXP_NONE = 0x00, /* no additional expanation */283283+ FC_BA_RJT_INV_XID = 0x03, /* invalid OX_ID-RX_ID combination */284284+ FC_BA_RJT_ABT = 0x05, /* sequence aborted, no seq info */285285+};286286+287287+/*288288+ * P_RJT or F_RJT: Port Reject or Fabric Reject parameter field.289289+ */290290+struct fc_pf_rjt {291291+ __u8 rj_action; /* reserved */292292+ __u8 rj_reason; /* reason code */293293+ __u8 rj_resvd; /* reserved */294294+ __u8 rj_vendor; /* vendor unique code */295295+};296296+297297+/*298298+ * P_RJT and F_RJT reject reason codes.299299+ */300300+enum fc_pf_rjt_reason {301301+ FC_RJT_NONE = 0, /* non-reject (reserved by standard) */302302+ FC_RJT_INVL_DID = 0x01, /* invalid destination ID */303303+ FC_RJT_INVL_SID = 0x02, /* invalid source ID */304304+ FC_RJT_P_UNAV_T = 0x03, /* port unavailable, temporary */305305+ FC_RJT_P_UNAV = 0x04, /* port unavailable, permanent */306306+ FC_RJT_CLS_UNSUP = 0x05, /* class not supported */307307+ FC_RJT_DEL_USAGE = 0x06, /* delimiter usage error */308308+ FC_RJT_TYPE_UNSUP = 0x07, /* type not supported */309309+ FC_RJT_LINK_CTL = 0x08, /* invalid link control */310310+ FC_RJT_R_CTL = 0x09, /* invalid R_CTL field */311311+ FC_RJT_F_CTL = 0x0a, /* invalid F_CTL field */312312+ FC_RJT_OX_ID = 0x0b, /* invalid originator exchange ID */313313+ FC_RJT_RX_ID = 0x0c, /* invalid responder exchange ID */314314+ FC_RJT_SEQ_ID = 0x0d, /* invalid sequence ID */315315+ FC_RJT_DF_CTL = 0x0e, /* invalid DF_CTL field */316316+ FC_RJT_SEQ_CNT = 0x0f, /* invalid SEQ_CNT field */317317+ FC_RJT_PARAM = 0x10, /* invalid parameter field */318318+ FC_RJT_EXCH_ERR = 0x11, /* exchange error */319319+ FC_RJT_PROTO = 0x12, /* protocol error */320320+ FC_RJT_LEN = 0x13, /* incorrect length */321321+ FC_RJT_UNEXP_ACK = 0x14, /* unexpected ACK */322322+ FC_RJT_FAB_CLASS = 0x15, /* class unsupported by fabric entity */323323+ FC_RJT_LOGI_REQ = 0x16, /* login required */324324+ FC_RJT_SEQ_XS = 0x17, /* excessive sequences attempted */325325+ FC_RJT_EXCH_EST = 0x18, /* unable to establish exchange */326326+ FC_RJT_FAB_UNAV = 0x1a, /* fabric unavailable */327327+ FC_RJT_VC_ID = 0x1b, /* invalid VC_ID (class 4) */328328+ FC_RJT_CS_CTL = 0x1c, /* invalid CS_CTL field */329329+ FC_RJT_INSUF_RES = 0x1d, /* insuff. resources for VC (Class 4) */330330+ FC_RJT_INVL_CLS = 0x1f, /* invalid class of service */331331+ FC_RJT_PREEMT_RJT = 0x20, /* preemption request rejected */332332+ FC_RJT_PREEMT_DIS = 0x21, /* preemption not enabled */333333+ FC_RJT_MCAST_ERR = 0x22, /* multicast error */334334+ FC_RJT_MCAST_ET = 0x23, /* multicast error terminate */335335+ FC_RJT_PRLI_REQ = 0x24, /* process login required */336336+ FC_RJT_INVL_ATT = 0x25, /* invalid attachment */337337+ FC_RJT_VENDOR = 0xff, /* vendor specific reject */338338+};339339+340340+#endif /* _FC_FS_H_ */
+93
include/scsi/fc/fc_gs.h
···11+/*22+ * Copyright(c) 2007 Intel Corporation. All rights reserved.33+ *44+ * This program is free software; you can redistribute it and/or modify it55+ * under the terms and conditions of the GNU General Public License,66+ * version 2, as published by the Free Software Foundation.77+ *88+ * This program is distributed in the hope it will be useful, but WITHOUT99+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1010+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for1111+ * more details.1212+ *1313+ * You should have received a copy of the GNU General Public License along with1414+ * this program; if not, write to the Free Software Foundation, Inc.,1515+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.1616+ *1717+ * Maintained at www.Open-FCoE.org1818+ */1919+2020+#ifndef _FC_GS_H_2121+#define _FC_GS_H_2222+2323+/*2424+ * Fibre Channel Services - Common Transport.2525+ * From T11.org FC-GS-2 Rev 5.3 November 1998.2626+ */2727+2828+struct fc_ct_hdr {2929+ __u8 ct_rev; /* revision */3030+ __u8 ct_in_id[3]; /* N_Port ID of original requestor */3131+ __u8 ct_fs_type; /* type of fibre channel service */3232+ __u8 ct_fs_subtype; /* subtype */3333+ __u8 ct_options;3434+ __u8 _ct_resvd1;3535+ __be16 ct_cmd; /* command / response code */3636+ __be16 ct_mr_size; /* maximum / residual size */3737+ __u8 _ct_resvd2;3838+ __u8 ct_reason; /* reject reason */3939+ __u8 ct_explan; /* reason code explanation */4040+ __u8 ct_vendor; /* vendor unique data */4141+};4242+4343+#define FC_CT_HDR_LEN 16 /* expected sizeof (struct fc_ct_hdr) */4444+4545+enum fc_ct_rev {4646+ FC_CT_REV = 1 /* common transport revision */4747+};4848+4949+/*5050+ * ct_fs_type values.5151+ */5252+enum fc_ct_fs_type {5353+ FC_FST_ALIAS = 0xf8, /* alias service */5454+ FC_FST_MGMT = 0xfa, /* management service */5555+ FC_FST_TIME = 0xfb, /* time service */5656+ FC_FST_DIR = 0xfc, /* directory service */5757+};5858+5959+/*6060+ * ct_cmd: Command / response codes6161+ */6262+enum fc_ct_cmd {6363+ FC_FS_RJT = 0x8001, /* reject */6464+ FC_FS_ACC = 0x8002, /* accept */6565+};6666+6767+/*6868+ * FS_RJT reason codes.6969+ */7070+enum fc_ct_reason {7171+ FC_FS_RJT_CMD = 0x01, /* invalid command code */7272+ FC_FS_RJT_VER = 0x02, /* invalid version level */7373+ FC_FS_RJT_LOG = 0x03, /* logical error */7474+ FC_FS_RJT_IUSIZ = 0x04, /* invalid IU size */7575+ FC_FS_RJT_BSY = 0x05, /* logical busy */7676+ FC_FS_RJT_PROTO = 0x07, /* protocol error */7777+ FC_FS_RJT_UNABL = 0x09, /* unable to perform command request */7878+ FC_FS_RJT_UNSUP = 0x0b, /* command not supported */7979+};8080+8181+/*8282+ * FS_RJT reason code explanations.8383+ */8484+enum fc_ct_explan {8585+ FC_FS_EXP_NONE = 0x00, /* no additional explanation */8686+ FC_FS_EXP_PID = 0x01, /* port ID not registered */8787+ FC_FS_EXP_PNAM = 0x02, /* port name not registered */8888+ FC_FS_EXP_NNAM = 0x03, /* node name not registered */8989+ FC_FS_EXP_COS = 0x04, /* class of service not registered */9090+ /* definitions not complete */9191+};9292+9393+#endif /* _FC_GS_H_ */
+159
include/scsi/fc/fc_ns.h
···11+/*22+ * Copyright(c) 2007 Intel Corporation. All rights reserved.33+ *44+ * This program is free software; you can redistribute it and/or modify it55+ * under the terms and conditions of the GNU General Public License,66+ * version 2, as published by the Free Software Foundation.77+ *88+ * This program is distributed in the hope it will be useful, but WITHOUT99+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1010+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for1111+ * more details.1212+ *1313+ * You should have received a copy of the GNU General Public License along with1414+ * this program; if not, write to the Free Software Foundation, Inc.,1515+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.1616+ *1717+ * Maintained at www.Open-FCoE.org1818+ */1919+2020+#ifndef _FC_NS_H_2121+#define _FC_NS_H_2222+2323+/*2424+ * Fibre Channel Services - Name Service (dNS)2525+ * From T11.org FC-GS-2 Rev 5.3 November 1998.2626+ */2727+2828+/*2929+ * Common-transport sub-type for Name Server.3030+ */3131+#define FC_NS_SUBTYPE 2 /* fs_ct_hdr.ct_fs_subtype */3232+3333+/*3434+ * Name server Requests.3535+ * Note: this is an incomplete list, some unused requests are omitted.3636+ */3737+enum fc_ns_req {3838+ FC_NS_GA_NXT = 0x0100, /* get all next */3939+ FC_NS_GI_A = 0x0101, /* get identifiers - scope */4040+ FC_NS_GPN_ID = 0x0112, /* get port name by ID */4141+ FC_NS_GNN_ID = 0x0113, /* get node name by ID */4242+ FC_NS_GID_PN = 0x0121, /* get ID for port name */4343+ FC_NS_GID_NN = 0x0131, /* get IDs for node name */4444+ FC_NS_GID_FT = 0x0171, /* get IDs by FC4 type */4545+ FC_NS_GPN_FT = 0x0172, /* get port names by FC4 type */4646+ FC_NS_GID_PT = 0x01a1, /* get IDs by port type */4747+ FC_NS_RFT_ID = 0x0217, /* reg FC4 type for ID */4848+ FC_NS_RPN_ID = 0x0212, /* reg port name for ID */4949+ FC_NS_RNN_ID = 0x0213, /* reg node name for ID */5050+};5151+5252+/*5353+ * Port type values.5454+ */5555+enum fc_ns_pt {5656+ FC_NS_UNID_PORT = 0x00, /* unidentified */5757+ FC_NS_N_PORT = 0x01, /* N port */5858+ FC_NS_NL_PORT = 0x02, /* NL port */5959+ FC_NS_FNL_PORT = 0x03, /* F/NL port */6060+ FC_NS_NX_PORT = 0x7f, /* Nx port */6161+ FC_NS_F_PORT = 0x81, /* F port */6262+ FC_NS_FL_PORT = 0x82, /* FL port */6363+ FC_NS_E_PORT = 0x84, /* E port */6464+ FC_NS_B_PORT = 0x85, /* B port */6565+};6666+6767+/*6868+ * Port type object.6969+ */7070+struct fc_ns_pt_obj {7171+ __u8 pt_type;7272+};7373+7474+/*7575+ * Port ID object7676+ */7777+struct fc_ns_fid {7878+ __u8 fp_flags; /* flags for responses only */7979+ __u8 fp_fid[3];8080+};8181+8282+/*8383+ * fp_flags in port ID object, for responses only.8484+ */8585+#define FC_NS_FID_LAST 0x80 /* last object */8686+8787+/*8888+ * FC4-types object.8989+ */9090+#define FC_NS_TYPES 256 /* number of possible FC-4 types */9191+#define FC_NS_BPW 32 /* bits per word in bitmap */9292+9393+struct fc_ns_fts {9494+ __be32 ff_type_map[FC_NS_TYPES / FC_NS_BPW]; /* bitmap of FC-4 types */9595+};9696+9797+/*9898+ * GID_PT request.9999+ */100100+struct fc_ns_gid_pt {101101+ __u8 fn_pt_type;102102+ __u8 fn_domain_id_scope;103103+ __u8 fn_area_id_scope;104104+ __u8 fn_resvd;105105+};106106+107107+/*108108+ * GID_FT or GPN_FT request.109109+ */110110+struct fc_ns_gid_ft {111111+ __u8 fn_resvd;112112+ __u8 fn_domain_id_scope;113113+ __u8 fn_area_id_scope;114114+ __u8 fn_fc4_type;115115+};116116+117117+/*118118+ * GPN_FT response.119119+ */120120+struct fc_gpn_ft_resp {121121+ __u8 fp_flags; /* see fp_flags definitions above */122122+ __u8 fp_fid[3]; /* port ID */123123+ __be32 fp_resvd;124124+ __be64 fp_wwpn; /* port name */125125+};126126+127127+/*128128+ * GID_PN request129129+ */130130+struct fc_ns_gid_pn {131131+ __be64 fn_wwpn; /* port name */132132+};133133+134134+/*135135+ * GID_PN response136136+ */137137+struct fc_gid_pn_resp {138138+ __u8 fp_resvd;139139+ __u8 fp_fid[3]; /* port ID */140140+};141141+142142+/*143143+ * RFT_ID request - register FC-4 types for ID.144144+ */145145+struct fc_ns_rft_id {146146+ struct fc_ns_fid fr_fid; /* port ID object */147147+ struct fc_ns_fts fr_fts; /* FC-4 types object */148148+};149149+150150+/*151151+ * RPN_ID request - register port name for ID.152152+ * RNN_ID request - register node name for ID.153153+ */154154+struct fc_ns_rn_id {155155+ struct fc_ns_fid fr_fid; /* port ID object */156156+ __be64 fr_wwn; /* node name or port name */157157+} __attribute__((__packed__));158158+159159+#endif /* _FC_NS_H_ */