bfa_fc.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629
  1. /*
  2. * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
  3. * All rights reserved
  4. * www.brocade.com
  5. *
  6. * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License (GPL) Version 2 as
  10. * published by the Free Software Foundation
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. */
  17. #ifndef __BFA_FC_H__
  18. #define __BFA_FC_H__
  19. #include "bfad_drv.h"
  20. typedef u64 wwn_t;
  21. #define WWN_NULL (0)
  22. #define FC_SYMNAME_MAX 256 /* max name server symbolic name size */
  23. #define FC_ALPA_MAX 128
  24. #pragma pack(1)
  25. #define MAC_ADDRLEN (6)
  26. struct mac_s { u8 mac[MAC_ADDRLEN]; };
  27. #define mac_t struct mac_s
  28. /*
  29. * generic SCSI cdb definition
  30. */
  31. #define SCSI_MAX_CDBLEN 16
  32. struct scsi_cdb_s {
  33. u8 scsi_cdb[SCSI_MAX_CDBLEN];
  34. };
  35. /* ------------------------------------------------------------
  36. * SCSI status byte values
  37. * ------------------------------------------------------------
  38. */
  39. #define SCSI_STATUS_GOOD 0x00
  40. #define SCSI_STATUS_CHECK_CONDITION 0x02
  41. #define SCSI_STATUS_CONDITION_MET 0x04
  42. #define SCSI_STATUS_BUSY 0x08
  43. #define SCSI_STATUS_INTERMEDIATE 0x10
  44. #define SCSI_STATUS_ICM 0x14 /* intermediate condition met */
  45. #define SCSI_STATUS_RESERVATION_CONFLICT 0x18
  46. #define SCSI_STATUS_COMMAND_TERMINATED 0x22
  47. #define SCSI_STATUS_QUEUE_FULL 0x28
  48. #define SCSI_STATUS_ACA_ACTIVE 0x30
  49. #define SCSI_MAX_ALLOC_LEN 0xFF /* maximum allocarion length */
  50. /*
  51. * Fibre Channel Header Structure (FCHS) definition
  52. */
  53. struct fchs_s {
  54. #ifdef __BIG_ENDIAN
  55. u32 routing:4; /* routing bits */
  56. u32 cat_info:4; /* category info */
  57. #else
  58. u32 cat_info:4; /* category info */
  59. u32 routing:4; /* routing bits */
  60. #endif
  61. u32 d_id:24; /* destination identifier */
  62. u32 cs_ctl:8; /* class specific control */
  63. u32 s_id:24; /* source identifier */
  64. u32 type:8; /* data structure type */
  65. u32 f_ctl:24; /* initial frame control */
  66. u8 seq_id; /* sequence identifier */
  67. u8 df_ctl; /* data field control */
  68. u16 seq_cnt; /* sequence count */
  69. __be16 ox_id; /* originator exchange ID */
  70. u16 rx_id; /* responder exchange ID */
  71. u32 ro; /* relative offset */
  72. };
  73. /*
  74. * routing bit definitions
  75. */
  76. enum {
  77. FC_RTG_FC4_DEV_DATA = 0x0, /* FC-4 Device Data */
  78. FC_RTG_EXT_LINK = 0x2, /* Extended Link Data */
  79. FC_RTG_FC4_LINK_DATA = 0x3, /* FC-4 Link Data */
  80. FC_RTG_VIDEO_DATA = 0x4, /* Video Data */
  81. FC_RTG_EXT_HDR = 0x5, /* VFT, IFR or Encapsuled */
  82. FC_RTG_BASIC_LINK = 0x8, /* Basic Link data */
  83. FC_RTG_LINK_CTRL = 0xC, /* Link Control */
  84. };
  85. /*
  86. * information category for extended link data and FC-4 Link Data
  87. */
  88. enum {
  89. FC_CAT_LD_REQUEST = 0x2, /* Request */
  90. FC_CAT_LD_REPLY = 0x3, /* Reply */
  91. FC_CAT_LD_DIAG = 0xF, /* for DIAG use only */
  92. };
  93. /*
  94. * information category for extended headers (VFT, IFR or encapsulation)
  95. */
  96. enum {
  97. FC_CAT_VFT_HDR = 0x0, /* Virtual fabric tagging header */
  98. FC_CAT_IFR_HDR = 0x1, /* Inter-Fabric routing header */
  99. FC_CAT_ENC_HDR = 0x2, /* Encapsulation header */
  100. };
  101. /*
  102. * information category for FC-4 device data
  103. */
  104. enum {
  105. FC_CAT_UNCATEG_INFO = 0x0, /* Uncategorized information */
  106. FC_CAT_SOLICIT_DATA = 0x1, /* Solicited Data */
  107. FC_CAT_UNSOLICIT_CTRL = 0x2, /* Unsolicited Control */
  108. FC_CAT_SOLICIT_CTRL = 0x3, /* Solicited Control */
  109. FC_CAT_UNSOLICIT_DATA = 0x4, /* Unsolicited Data */
  110. FC_CAT_DATA_DESC = 0x5, /* Data Descriptor */
  111. FC_CAT_UNSOLICIT_CMD = 0x6, /* Unsolicited Command */
  112. FC_CAT_CMD_STATUS = 0x7, /* Command Status */
  113. };
  114. /*
  115. * Type Field Definitions. FC-PH Section 18.5 pg. 165
  116. */
  117. enum {
  118. FC_TYPE_BLS = 0x0, /* Basic Link Service */
  119. FC_TYPE_ELS = 0x1, /* Extended Link Service */
  120. FC_TYPE_IP = 0x5, /* IP */
  121. FC_TYPE_FCP = 0x8, /* SCSI-FCP */
  122. FC_TYPE_GPP = 0x9, /* SCSI_GPP */
  123. FC_TYPE_SERVICES = 0x20, /* Fibre Channel Services */
  124. FC_TYPE_FC_FSS = 0x22, /* Fabric Switch Services */
  125. FC_TYPE_FC_AL = 0x23, /* FC-AL */
  126. FC_TYPE_FC_SNMP = 0x24, /* FC-SNMP */
  127. FC_TYPE_FC_SPINFAB = 0xEE, /* SPINFAB */
  128. FC_TYPE_FC_DIAG = 0xEF, /* DIAG */
  129. FC_TYPE_MAX = 256, /* 256 FC-4 types */
  130. };
  131. /*
  132. * Frame Control Definitions. FC-PH Table-45. pg. 168
  133. */
  134. enum {
  135. FCTL_EC_ORIG = 0x000000, /* exchange originator */
  136. FCTL_EC_RESP = 0x800000, /* exchange responder */
  137. FCTL_SEQ_INI = 0x000000, /* sequence initiator */
  138. FCTL_SEQ_REC = 0x400000, /* sequence recipient */
  139. FCTL_FS_EXCH = 0x200000, /* first sequence of xchg */
  140. FCTL_LS_EXCH = 0x100000, /* last sequence of xchg */
  141. FCTL_END_SEQ = 0x080000, /* last frame of sequence */
  142. FCTL_SI_XFER = 0x010000, /* seq initiative transfer */
  143. FCTL_RO_PRESENT = 0x000008, /* relative offset present */
  144. FCTL_FILLBYTE_MASK = 0x000003 /* , fill byte mask */
  145. };
  146. /*
  147. * Fabric Well Known Addresses
  148. */
  149. enum {
  150. FC_MIN_WELL_KNOWN_ADDR = 0xFFFFF0,
  151. FC_DOMAIN_CONTROLLER_MASK = 0xFFFC00,
  152. FC_ALIAS_SERVER = 0xFFFFF8,
  153. FC_MGMT_SERVER = 0xFFFFFA,
  154. FC_TIME_SERVER = 0xFFFFFB,
  155. FC_NAME_SERVER = 0xFFFFFC,
  156. FC_FABRIC_CONTROLLER = 0xFFFFFD,
  157. FC_FABRIC_PORT = 0xFFFFFE,
  158. FC_BROADCAST_SERVER = 0xFFFFFF
  159. };
  160. /*
  161. * domain/area/port defines
  162. */
  163. #define FC_DOMAIN_MASK 0xFF0000
  164. #define FC_DOMAIN_SHIFT 16
  165. #define FC_AREA_MASK 0x00FF00
  166. #define FC_AREA_SHIFT 8
  167. #define FC_PORT_MASK 0x0000FF
  168. #define FC_PORT_SHIFT 0
  169. #define FC_GET_DOMAIN(p) (((p) & FC_DOMAIN_MASK) >> FC_DOMAIN_SHIFT)
  170. #define FC_GET_AREA(p) (((p) & FC_AREA_MASK) >> FC_AREA_SHIFT)
  171. #define FC_GET_PORT(p) (((p) & FC_PORT_MASK) >> FC_PORT_SHIFT)
  172. #define FC_DOMAIN_CTRLR(p) (FC_DOMAIN_CONTROLLER_MASK | (FC_GET_DOMAIN(p)))
  173. enum {
  174. FC_RXID_ANY = 0xFFFFU,
  175. };
  176. /*
  177. * generic ELS command
  178. */
  179. struct fc_els_cmd_s {
  180. u32 els_code:8; /* ELS Command Code */
  181. u32 reserved:24;
  182. };
  183. /*
  184. * ELS Command Codes. FC-PH Table-75. pg. 223
  185. */
  186. enum {
  187. FC_ELS_LS_RJT = 0x1, /* Link Service Reject. */
  188. FC_ELS_ACC = 0x02, /* Accept */
  189. FC_ELS_PLOGI = 0x03, /* N_Port Login. */
  190. FC_ELS_FLOGI = 0x04, /* F_Port Login. */
  191. FC_ELS_LOGO = 0x05, /* Logout. */
  192. FC_ELS_ABTX = 0x06, /* Abort Exchange */
  193. FC_ELS_RES = 0x08, /* Read Exchange status */
  194. FC_ELS_RSS = 0x09, /* Read sequence status block */
  195. FC_ELS_RSI = 0x0A, /* Request Sequence Initiative */
  196. FC_ELS_ESTC = 0x0C, /* Estimate Credit. */
  197. FC_ELS_RTV = 0x0E, /* Read Timeout Value. */
  198. FC_ELS_RLS = 0x0F, /* Read Link Status. */
  199. FC_ELS_ECHO = 0x10, /* Echo */
  200. FC_ELS_TEST = 0x11, /* Test */
  201. FC_ELS_RRQ = 0x12, /* Reinstate Recovery Qualifier. */
  202. FC_ELS_REC = 0x13, /* Add this for TAPE support in FCR */
  203. FC_ELS_PRLI = 0x20, /* Process Login */
  204. FC_ELS_PRLO = 0x21, /* Process Logout. */
  205. FC_ELS_SCN = 0x22, /* State Change Notification. */
  206. FC_ELS_TPRLO = 0x24, /* Third Party Process Logout. */
  207. FC_ELS_PDISC = 0x50, /* Discover N_Port Parameters. */
  208. FC_ELS_FDISC = 0x51, /* Discover F_Port Parameters. */
  209. FC_ELS_ADISC = 0x52, /* Discover Address. */
  210. FC_ELS_FARP_REQ = 0x54, /* FARP Request. */
  211. FC_ELS_FARP_REP = 0x55, /* FARP Reply. */
  212. FC_ELS_FAN = 0x60, /* Fabric Address Notification */
  213. FC_ELS_RSCN = 0x61, /* Reg State Change Notification */
  214. FC_ELS_SCR = 0x62, /* State Change Registration. */
  215. FC_ELS_RTIN = 0x77, /* Mangement server request */
  216. FC_ELS_RNID = 0x78, /* Mangement server request */
  217. FC_ELS_RLIR = 0x79, /* Registered Link Incident Record */
  218. FC_ELS_RPSC = 0x7D, /* Report Port Speed Capabilities */
  219. FC_ELS_QSA = 0x7E, /* Query Security Attributes. Ref FC-SP */
  220. FC_ELS_E2E_LBEACON = 0x81,
  221. /* End-to-End Link Beacon */
  222. FC_ELS_AUTH = 0x90, /* Authentication. Ref FC-SP */
  223. FC_ELS_RFCN = 0x97, /* Request Fabric Change Notification. Ref
  224. *FC-SP */
  225. };
  226. /*
  227. * Version numbers for FC-PH standards,
  228. * used in login to indicate what port
  229. * supports. See FC-PH-X table 158.
  230. */
  231. enum {
  232. FC_PH_VER_4_3 = 0x09,
  233. FC_PH_VER_PH_3 = 0x20,
  234. };
  235. /*
  236. * PDU size defines
  237. */
  238. enum {
  239. FC_MIN_PDUSZ = 512,
  240. FC_MAX_PDUSZ = 2112,
  241. };
  242. /*
  243. * N_Port PLOGI Common Service Parameters.
  244. * FC-PH-x. Figure-76. pg. 308.
  245. */
  246. struct fc_plogi_csp_s {
  247. u8 verhi; /* FC-PH high version */
  248. u8 verlo; /* FC-PH low version */
  249. __be16 bbcred; /* BB_Credit */
  250. #ifdef __BIG_ENDIAN
  251. u8 ciro:1, /* continuously increasing RO */
  252. rro:1, /* random relative offset */
  253. npiv_supp:1, /* NPIV supported */
  254. port_type:1, /* N_Port/F_port */
  255. altbbcred:1, /* alternate BB_Credit */
  256. resolution:1, /* ms/ns ED_TOV resolution */
  257. vvl_info:1, /* VVL Info included */
  258. reserved1:1;
  259. u8 hg_supp:1,
  260. query_dbc:1,
  261. security:1,
  262. sync_cap:1,
  263. r_t_tov:1,
  264. dh_dup_supp:1,
  265. cisc:1, /* continuously increasing seq count */
  266. payload:1;
  267. #else
  268. u8 reserved2:2,
  269. resolution:1, /* ms/ns ED_TOV resolution */
  270. altbbcred:1, /* alternate BB_Credit */
  271. port_type:1, /* N_Port/F_port */
  272. npiv_supp:1, /* NPIV supported */
  273. rro:1, /* random relative offset */
  274. ciro:1; /* continuously increasing RO */
  275. u8 payload:1,
  276. cisc:1, /* continuously increasing seq count */
  277. dh_dup_supp:1,
  278. r_t_tov:1,
  279. sync_cap:1,
  280. security:1,
  281. query_dbc:1,
  282. hg_supp:1;
  283. #endif
  284. __be16 rxsz; /* receive data_field size */
  285. __be16 conseq;
  286. __be16 ro_bitmap;
  287. __be32 e_d_tov;
  288. };
  289. /*
  290. * N_Port PLOGI Class Specific Parameters.
  291. * FC-PH-x. Figure 78. pg. 318.
  292. */
  293. struct fc_plogi_clp_s {
  294. #ifdef __BIG_ENDIAN
  295. u32 class_valid:1;
  296. u32 intermix:1; /* class intermix supported if set =1.
  297. * valid only for class1. Reserved for
  298. * class2 & class3 */
  299. u32 reserved1:2;
  300. u32 sequential:1;
  301. u32 reserved2:3;
  302. #else
  303. u32 reserved2:3;
  304. u32 sequential:1;
  305. u32 reserved1:2;
  306. u32 intermix:1; /* class intermix supported if set =1.
  307. * valid only for class1. Reserved for
  308. * class2 & class3 */
  309. u32 class_valid:1;
  310. #endif
  311. u32 reserved3:24;
  312. u32 reserved4:16;
  313. u32 rxsz:16; /* Receive data_field size */
  314. u32 reserved5:8;
  315. u32 conseq:8;
  316. u32 e2e_credit:16; /* end to end credit */
  317. u32 reserved7:8;
  318. u32 ospx:8;
  319. u32 reserved8:16;
  320. };
  321. /* ASCII value for each character in string "BRCD" */
  322. #define FLOGI_VVL_BRCD 0x42524344
  323. /*
  324. * PLOGI els command and reply payload
  325. */
  326. struct fc_logi_s {
  327. struct fc_els_cmd_s els_cmd; /* ELS command code */
  328. struct fc_plogi_csp_s csp; /* common service params */
  329. wwn_t port_name;
  330. wwn_t node_name;
  331. struct fc_plogi_clp_s class1; /* class 1 service parameters */
  332. struct fc_plogi_clp_s class2; /* class 2 service parameters */
  333. struct fc_plogi_clp_s class3; /* class 3 service parameters */
  334. struct fc_plogi_clp_s class4; /* class 4 service parameters */
  335. u8 vvl[16]; /* vendor version level */
  336. };
  337. /*
  338. * LOGO els command payload
  339. */
  340. struct fc_logo_s {
  341. struct fc_els_cmd_s els_cmd; /* ELS command code */
  342. u32 res1:8;
  343. u32 nport_id:24; /* N_Port identifier of source */
  344. wwn_t orig_port_name; /* Port name of the LOGO originator */
  345. };
  346. /*
  347. * ADISC els command payload
  348. */
  349. struct fc_adisc_s {
  350. struct fc_els_cmd_s els_cmd; /* ELS command code */
  351. u32 res1:8;
  352. u32 orig_HA:24; /* originator hard address */
  353. wwn_t orig_port_name; /* originator port name */
  354. wwn_t orig_node_name; /* originator node name */
  355. u32 res2:8;
  356. u32 nport_id:24; /* originator NPortID */
  357. };
  358. /*
  359. * Exchange status block
  360. */
  361. struct fc_exch_status_blk_s {
  362. u32 oxid:16;
  363. u32 rxid:16;
  364. u32 res1:8;
  365. u32 orig_np:24; /* originator NPortID */
  366. u32 res2:8;
  367. u32 resp_np:24; /* responder NPortID */
  368. u32 es_bits;
  369. u32 res3;
  370. /*
  371. * un modified section of the fields
  372. */
  373. };
  374. /*
  375. * RES els command payload
  376. */
  377. struct fc_res_s {
  378. struct fc_els_cmd_s els_cmd; /* ELS command code */
  379. u32 res1:8;
  380. u32 nport_id:24; /* N_Port identifier of source */
  381. u32 oxid:16;
  382. u32 rxid:16;
  383. u8 assoc_hdr[32];
  384. };
  385. /*
  386. * RES els accept payload
  387. */
  388. struct fc_res_acc_s {
  389. struct fc_els_cmd_s els_cmd; /* ELS command code */
  390. struct fc_exch_status_blk_s fc_exch_blk; /* Exchange status block */
  391. };
  392. /*
  393. * REC els command payload
  394. */
  395. struct fc_rec_s {
  396. struct fc_els_cmd_s els_cmd; /* ELS command code */
  397. u32 res1:8;
  398. u32 nport_id:24; /* N_Port identifier of source */
  399. u32 oxid:16;
  400. u32 rxid:16;
  401. };
  402. #define FC_REC_ESB_OWN_RSP 0x80000000 /* responder owns */
  403. #define FC_REC_ESB_SI 0x40000000 /* SI is owned */
  404. #define FC_REC_ESB_COMP 0x20000000 /* exchange is complete */
  405. #define FC_REC_ESB_ENDCOND_ABN 0x10000000 /* abnormal ending */
  406. #define FC_REC_ESB_RQACT 0x04000000 /* recovery qual active */
  407. #define FC_REC_ESB_ERRP_MSK 0x03000000
  408. #define FC_REC_ESB_OXID_INV 0x00800000 /* invalid OXID */
  409. #define FC_REC_ESB_RXID_INV 0x00400000 /* invalid RXID */
  410. #define FC_REC_ESB_PRIO_INUSE 0x00200000
  411. /*
  412. * REC els accept payload
  413. */
  414. struct fc_rec_acc_s {
  415. struct fc_els_cmd_s els_cmd; /* ELS command code */
  416. u32 oxid:16;
  417. u32 rxid:16;
  418. u32 res1:8;
  419. u32 orig_id:24; /* N_Port id of exchange originator */
  420. u32 res2:8;
  421. u32 resp_id:24; /* N_Port id of exchange responder */
  422. u32 count; /* data transfer count */
  423. u32 e_stat; /* exchange status */
  424. };
  425. /*
  426. * RSI els payload
  427. */
  428. struct fc_rsi_s {
  429. struct fc_els_cmd_s els_cmd;
  430. u32 res1:8;
  431. u32 orig_sid:24;
  432. u32 oxid:16;
  433. u32 rxid:16;
  434. };
  435. /*
  436. * structure for PRLI paramater pages, both request & response
  437. * see FC-PH-X table 113 & 115 for explanation also FCP table 8
  438. */
  439. struct fc_prli_params_s {
  440. u32 reserved:16;
  441. #ifdef __BIG_ENDIAN
  442. u32 reserved1:5;
  443. u32 rec_support:1;
  444. u32 task_retry_id:1;
  445. u32 retry:1;
  446. u32 confirm:1;
  447. u32 doverlay:1;
  448. u32 initiator:1;
  449. u32 target:1;
  450. u32 cdmix:1;
  451. u32 drmix:1;
  452. u32 rxrdisab:1;
  453. u32 wxrdisab:1;
  454. #else
  455. u32 retry:1;
  456. u32 task_retry_id:1;
  457. u32 rec_support:1;
  458. u32 reserved1:5;
  459. u32 wxrdisab:1;
  460. u32 rxrdisab:1;
  461. u32 drmix:1;
  462. u32 cdmix:1;
  463. u32 target:1;
  464. u32 initiator:1;
  465. u32 doverlay:1;
  466. u32 confirm:1;
  467. #endif
  468. };
  469. /*
  470. * valid values for rspcode in PRLI ACC payload
  471. */
  472. enum {
  473. FC_PRLI_ACC_XQTD = 0x1, /* request executed */
  474. FC_PRLI_ACC_PREDEF_IMG = 0x5, /* predefined image - no prli needed */
  475. };
  476. struct fc_prli_params_page_s {
  477. u32 type:8;
  478. u32 codext:8;
  479. #ifdef __BIG_ENDIAN
  480. u32 origprocasv:1;
  481. u32 rsppav:1;
  482. u32 imagepair:1;
  483. u32 reserved1:1;
  484. u32 rspcode:4;
  485. #else
  486. u32 rspcode:4;
  487. u32 reserved1:1;
  488. u32 imagepair:1;
  489. u32 rsppav:1;
  490. u32 origprocasv:1;
  491. #endif
  492. u32 reserved2:8;
  493. u32 origprocas;
  494. u32 rspprocas;
  495. struct fc_prli_params_s servparams;
  496. };
  497. /*
  498. * PRLI request and accept payload, FC-PH-X tables 112 & 114
  499. */
  500. struct fc_prli_s {
  501. u32 command:8;
  502. u32 pglen:8;
  503. u32 pagebytes:16;
  504. struct fc_prli_params_page_s parampage;
  505. };
  506. /*
  507. * PRLO logout params page
  508. */
  509. struct fc_prlo_params_page_s {
  510. u32 type:8;
  511. u32 type_ext:8;
  512. #ifdef __BIG_ENDIAN
  513. u32 opa_valid:1; /* originator process associator valid */
  514. u32 rpa_valid:1; /* responder process associator valid */
  515. u32 res1:14;
  516. #else
  517. u32 res1:14;
  518. u32 rpa_valid:1; /* responder process associator valid */
  519. u32 opa_valid:1; /* originator process associator valid */
  520. #endif
  521. u32 orig_process_assc;
  522. u32 resp_process_assc;
  523. u32 res2;
  524. };
  525. /*
  526. * PRLO els command payload
  527. */
  528. struct fc_prlo_s {
  529. u32 command:8;
  530. u32 page_len:8;
  531. u32 payload_len:16;
  532. struct fc_prlo_params_page_s prlo_params[1];
  533. };
  534. /*
  535. * PRLO Logout response parameter page
  536. */
  537. struct fc_prlo_acc_params_page_s {
  538. u32 type:8;
  539. u32 type_ext:8;
  540. #ifdef __BIG_ENDIAN
  541. u32 opa_valid:1; /* originator process associator valid */
  542. u32 rpa_valid:1; /* responder process associator valid */
  543. u32 res1:14;
  544. #else
  545. u32 res1:14;
  546. u32 rpa_valid:1; /* responder process associator valid */
  547. u32 opa_valid:1; /* originator process associator valid */
  548. #endif
  549. u32 orig_process_assc;
  550. u32 resp_process_assc;
  551. u32 fc4type_csp;
  552. };
  553. /*
  554. * PRLO els command ACC payload
  555. */
  556. struct fc_prlo_acc_s {
  557. u32 command:8;
  558. u32 page_len:8;
  559. u32 payload_len:16;
  560. struct fc_prlo_acc_params_page_s prlo_acc_params[1];
  561. };
  562. /*
  563. * SCR els command payload
  564. */
  565. enum {
  566. FC_SCR_REG_FUNC_FABRIC_DETECTED = 0x01,
  567. FC_SCR_REG_FUNC_N_PORT_DETECTED = 0x02,
  568. FC_SCR_REG_FUNC_FULL = 0x03,
  569. FC_SCR_REG_FUNC_CLEAR_REG = 0xFF,
  570. };
  571. /* SCR VU registrations */
  572. enum {
  573. FC_VU_SCR_REG_FUNC_FABRIC_NAME_CHANGE = 0x01
  574. };
  575. struct fc_scr_s {
  576. u32 command:8;
  577. u32 res:24;
  578. u32 vu_reg_func:8; /* Vendor Unique Registrations */
  579. u32 res1:16;
  580. u32 reg_func:8;
  581. };
  582. /*
  583. * Information category for Basic link data
  584. */
  585. enum {
  586. FC_CAT_NOP = 0x0,
  587. FC_CAT_ABTS = 0x1,
  588. FC_CAT_RMC = 0x2,
  589. FC_CAT_BA_ACC = 0x4,
  590. FC_CAT_BA_RJT = 0x5,
  591. FC_CAT_PRMT = 0x6,
  592. };
  593. /*
  594. * LS_RJT els reply payload
  595. */
  596. struct fc_ls_rjt_s {
  597. struct fc_els_cmd_s els_cmd; /* ELS command code */
  598. u32 res1:8;
  599. u32 reason_code:8; /* Reason code for reject */
  600. u32 reason_code_expl:8; /* Reason code explanation */
  601. u32 vendor_unique:8; /* Vendor specific */
  602. };
  603. /*
  604. * LS_RJT reason codes
  605. */
  606. enum {
  607. FC_LS_RJT_RSN_INV_CMD_CODE = 0x01,
  608. FC_LS_RJT_RSN_LOGICAL_ERROR = 0x03,
  609. FC_LS_RJT_RSN_LOGICAL_BUSY = 0x05,
  610. FC_LS_RJT_RSN_PROTOCOL_ERROR = 0x07,
  611. FC_LS_RJT_RSN_UNABLE_TO_PERF_CMD = 0x09,
  612. FC_LS_RJT_RSN_CMD_NOT_SUPP = 0x0B,
  613. };
  614. /*
  615. * LS_RJT reason code explanation
  616. */
  617. enum {
  618. FC_LS_RJT_EXP_NO_ADDL_INFO = 0x00,
  619. FC_LS_RJT_EXP_SPARMS_ERR_OPTIONS = 0x01,
  620. FC_LS_RJT_EXP_SPARMS_ERR_INI_CTL = 0x03,
  621. FC_LS_RJT_EXP_SPARMS_ERR_REC_CTL = 0x05,
  622. FC_LS_RJT_EXP_SPARMS_ERR_RXSZ = 0x07,
  623. FC_LS_RJT_EXP_SPARMS_ERR_CONSEQ = 0x09,
  624. FC_LS_RJT_EXP_SPARMS_ERR_CREDIT = 0x0B,
  625. FC_LS_RJT_EXP_INV_PORT_NAME = 0x0D,
  626. FC_LS_RJT_EXP_INV_NODE_FABRIC_NAME = 0x0E,
  627. FC_LS_RJT_EXP_INV_CSP = 0x0F,
  628. FC_LS_RJT_EXP_INV_ASSOC_HDR = 0x11,
  629. FC_LS_RJT_EXP_ASSOC_HDR_REQD = 0x13,
  630. FC_LS_RJT_EXP_INV_ORIG_S_ID = 0x15,
  631. FC_LS_RJT_EXP_INV_OXID_RXID_COMB = 0x17,
  632. FC_LS_RJT_EXP_CMD_ALREADY_IN_PROG = 0x19,
  633. FC_LS_RJT_EXP_LOGIN_REQUIRED = 0x1E,
  634. FC_LS_RJT_EXP_INVALID_NPORT_ID = 0x1F,
  635. FC_LS_RJT_EXP_INSUFF_RES = 0x29,
  636. FC_LS_RJT_EXP_CMD_NOT_SUPP = 0x2C,
  637. FC_LS_RJT_EXP_INV_PAYLOAD_LEN = 0x2D,
  638. };
  639. /*
  640. * RRQ els command payload
  641. */
  642. struct fc_rrq_s {
  643. struct fc_els_cmd_s els_cmd; /* ELS command code */
  644. u32 res1:8;
  645. u32 s_id:24; /* exchange originator S_ID */
  646. u32 ox_id:16; /* originator exchange ID */
  647. u32 rx_id:16; /* responder exchange ID */
  648. u32 res2[8]; /* optional association header */
  649. };
  650. /*
  651. * ABTS BA_ACC reply payload
  652. */
  653. struct fc_ba_acc_s {
  654. u32 seq_id_valid:8; /* set to 0x00 for Abort Exchange */
  655. u32 seq_id:8; /* invalid for Abort Exchange */
  656. u32 res2:16;
  657. u32 ox_id:16; /* OX_ID from ABTS frame */
  658. u32 rx_id:16; /* RX_ID from ABTS frame */
  659. u32 low_seq_cnt:16; /* set to 0x0000 for Abort Exchange */
  660. u32 high_seq_cnt:16; /* set to 0xFFFF for Abort Exchange */
  661. };
  662. /*
  663. * ABTS BA_RJT reject payload
  664. */
  665. struct fc_ba_rjt_s {
  666. u32 res1:8; /* Reserved */
  667. u32 reason_code:8; /* reason code for reject */
  668. u32 reason_expl:8; /* reason code explanation */
  669. u32 vendor_unique:8; /* vendor unique reason code,set to 0 */
  670. };
  671. /*
  672. * TPRLO logout parameter page
  673. */
  674. struct fc_tprlo_params_page_s {
  675. u32 type:8;
  676. u32 type_ext:8;
  677. #ifdef __BIG_ENDIAN
  678. u32 opa_valid:1;
  679. u32 rpa_valid:1;
  680. u32 tpo_nport_valid:1;
  681. u32 global_process_logout:1;
  682. u32 res1:12;
  683. #else
  684. u32 res1:12;
  685. u32 global_process_logout:1;
  686. u32 tpo_nport_valid:1;
  687. u32 rpa_valid:1;
  688. u32 opa_valid:1;
  689. #endif
  690. u32 orig_process_assc;
  691. u32 resp_process_assc;
  692. u32 res2:8;
  693. u32 tpo_nport_id;
  694. };
  695. /*
  696. * TPRLO ELS command payload
  697. */
  698. struct fc_tprlo_s {
  699. u32 command:8;
  700. u32 page_len:8;
  701. u32 payload_len:16;
  702. struct fc_tprlo_params_page_s tprlo_params[1];
  703. };
  704. enum fc_tprlo_type {
  705. FC_GLOBAL_LOGO = 1,
  706. FC_TPR_LOGO
  707. };
  708. /*
  709. * TPRLO els command ACC payload
  710. */
  711. struct fc_tprlo_acc_s {
  712. u32 command:8;
  713. u32 page_len:8;
  714. u32 payload_len:16;
  715. struct fc_prlo_acc_params_page_s tprlo_acc_params[1];
  716. };
  717. /*
  718. * RSCN els command req payload
  719. */
  720. #define FC_RSCN_PGLEN 0x4
  721. enum fc_rscn_format {
  722. FC_RSCN_FORMAT_PORTID = 0x0,
  723. FC_RSCN_FORMAT_AREA = 0x1,
  724. FC_RSCN_FORMAT_DOMAIN = 0x2,
  725. FC_RSCN_FORMAT_FABRIC = 0x3,
  726. };
  727. struct fc_rscn_event_s {
  728. u32 format:2;
  729. u32 qualifier:4;
  730. u32 resvd:2;
  731. u32 portid:24;
  732. };
  733. struct fc_rscn_pl_s {
  734. u8 command;
  735. u8 pagelen;
  736. __be16 payldlen;
  737. struct fc_rscn_event_s event[1];
  738. };
  739. /*
  740. * ECHO els command req payload
  741. */
  742. struct fc_echo_s {
  743. struct fc_els_cmd_s els_cmd;
  744. };
  745. /*
  746. * RNID els command
  747. */
  748. #define RNID_NODEID_DATA_FORMAT_COMMON 0x00
  749. #define RNID_NODEID_DATA_FORMAT_FCP3 0x08
  750. #define RNID_NODEID_DATA_FORMAT_DISCOVERY 0xDF
  751. #define RNID_ASSOCIATED_TYPE_UNKNOWN 0x00000001
  752. #define RNID_ASSOCIATED_TYPE_OTHER 0x00000002
  753. #define RNID_ASSOCIATED_TYPE_HUB 0x00000003
  754. #define RNID_ASSOCIATED_TYPE_SWITCH 0x00000004
  755. #define RNID_ASSOCIATED_TYPE_GATEWAY 0x00000005
  756. #define RNID_ASSOCIATED_TYPE_STORAGE_DEVICE 0x00000009
  757. #define RNID_ASSOCIATED_TYPE_HOST 0x0000000A
  758. #define RNID_ASSOCIATED_TYPE_STORAGE_SUBSYSTEM 0x0000000B
  759. #define RNID_ASSOCIATED_TYPE_STORAGE_ACCESS_DEVICE 0x0000000E
  760. #define RNID_ASSOCIATED_TYPE_NAS_SERVER 0x00000011
  761. #define RNID_ASSOCIATED_TYPE_BRIDGE 0x00000002
  762. #define RNID_ASSOCIATED_TYPE_VIRTUALIZATION_DEVICE 0x00000003
  763. #define RNID_ASSOCIATED_TYPE_MULTI_FUNCTION_DEVICE 0x000000FF
  764. /*
  765. * RNID els command payload
  766. */
  767. struct fc_rnid_cmd_s {
  768. struct fc_els_cmd_s els_cmd;
  769. u32 node_id_data_format:8;
  770. u32 reserved:24;
  771. };
  772. /*
  773. * RNID els response payload
  774. */
  775. struct fc_rnid_common_id_data_s {
  776. wwn_t port_name;
  777. wwn_t node_name;
  778. };
  779. struct fc_rnid_general_topology_data_s {
  780. u32 vendor_unique[4];
  781. __be32 asso_type;
  782. u32 phy_port_num;
  783. __be32 num_attached_nodes;
  784. u32 node_mgmt:8;
  785. u32 ip_version:8;
  786. u32 udp_tcp_port_num:16;
  787. u32 ip_address[4];
  788. u32 reserved:16;
  789. u32 vendor_specific:16;
  790. };
  791. struct fc_rnid_acc_s {
  792. struct fc_els_cmd_s els_cmd;
  793. u32 node_id_data_format:8;
  794. u32 common_id_data_length:8;
  795. u32 reserved:8;
  796. u32 specific_id_data_length:8;
  797. struct fc_rnid_common_id_data_s common_id_data;
  798. struct fc_rnid_general_topology_data_s gen_topology_data;
  799. };
  800. #define RNID_ASSOCIATED_TYPE_UNKNOWN 0x00000001
  801. #define RNID_ASSOCIATED_TYPE_OTHER 0x00000002
  802. #define RNID_ASSOCIATED_TYPE_HUB 0x00000003
  803. #define RNID_ASSOCIATED_TYPE_SWITCH 0x00000004
  804. #define RNID_ASSOCIATED_TYPE_GATEWAY 0x00000005
  805. #define RNID_ASSOCIATED_TYPE_STORAGE_DEVICE 0x00000009
  806. #define RNID_ASSOCIATED_TYPE_HOST 0x0000000A
  807. #define RNID_ASSOCIATED_TYPE_STORAGE_SUBSYSTEM 0x0000000B
  808. #define RNID_ASSOCIATED_TYPE_STORAGE_ACCESS_DEVICE 0x0000000E
  809. #define RNID_ASSOCIATED_TYPE_NAS_SERVER 0x00000011
  810. #define RNID_ASSOCIATED_TYPE_BRIDGE 0x00000002
  811. #define RNID_ASSOCIATED_TYPE_VIRTUALIZATION_DEVICE 0x00000003
  812. #define RNID_ASSOCIATED_TYPE_MULTI_FUNCTION_DEVICE 0x000000FF
  813. enum fc_rpsc_speed_cap {
  814. RPSC_SPEED_CAP_1G = 0x8000,
  815. RPSC_SPEED_CAP_2G = 0x4000,
  816. RPSC_SPEED_CAP_4G = 0x2000,
  817. RPSC_SPEED_CAP_10G = 0x1000,
  818. RPSC_SPEED_CAP_8G = 0x0800,
  819. RPSC_SPEED_CAP_16G = 0x0400,
  820. RPSC_SPEED_CAP_UNKNOWN = 0x0001,
  821. };
  822. enum fc_rpsc_op_speed {
  823. RPSC_OP_SPEED_1G = 0x8000,
  824. RPSC_OP_SPEED_2G = 0x4000,
  825. RPSC_OP_SPEED_4G = 0x2000,
  826. RPSC_OP_SPEED_10G = 0x1000,
  827. RPSC_OP_SPEED_8G = 0x0800,
  828. RPSC_OP_SPEED_16G = 0x0400,
  829. RPSC_OP_SPEED_NOT_EST = 0x0001, /* speed not established */
  830. };
  831. struct fc_rpsc_speed_info_s {
  832. __be16 port_speed_cap; /* see enum fc_rpsc_speed_cap */
  833. __be16 port_op_speed; /* see enum fc_rpsc_op_speed */
  834. };
  835. /*
  836. * If RPSC request is sent to the Domain Controller, the request is for
  837. * all the ports within that domain.
  838. */
  839. struct fc_rpsc_cmd_s {
  840. struct fc_els_cmd_s els_cmd;
  841. };
  842. /*
  843. * RPSC Acc
  844. */
  845. struct fc_rpsc_acc_s {
  846. u32 command:8;
  847. u32 rsvd:8;
  848. u32 num_entries:16;
  849. struct fc_rpsc_speed_info_s speed_info[1];
  850. };
  851. /*
  852. * If RPSC2 request is sent to the Domain Controller,
  853. */
  854. #define FC_BRCD_TOKEN 0x42524344
  855. struct fc_rpsc2_cmd_s {
  856. struct fc_els_cmd_s els_cmd;
  857. __be32 token;
  858. u16 resvd;
  859. __be16 num_pids; /* Number of pids in the request */
  860. struct {
  861. u32 rsvd1:8;
  862. u32 pid:24; /* port identifier */
  863. } pid_list[1];
  864. };
  865. enum fc_rpsc2_port_type {
  866. RPSC2_PORT_TYPE_UNKNOWN = 0,
  867. RPSC2_PORT_TYPE_NPORT = 1,
  868. RPSC2_PORT_TYPE_NLPORT = 2,
  869. RPSC2_PORT_TYPE_NPIV_PORT = 0x5f,
  870. RPSC2_PORT_TYPE_NPORT_TRUNK = 0x6f,
  871. };
  872. /*
  873. * RPSC2 portInfo entry structure
  874. */
  875. struct fc_rpsc2_port_info_s {
  876. __be32 pid; /* PID */
  877. u16 resvd1;
  878. __be16 index; /* port number / index */
  879. u8 resvd2;
  880. u8 type; /* port type N/NL/... */
  881. __be16 speed; /* port Operating Speed */
  882. };
  883. /*
  884. * RPSC2 Accept payload
  885. */
  886. struct fc_rpsc2_acc_s {
  887. u8 els_cmd;
  888. u8 resvd;
  889. __be16 num_pids; /* Number of pids in the request */
  890. struct fc_rpsc2_port_info_s port_info[1]; /* port information */
  891. };
  892. /*
  893. * bit fields so that multiple classes can be specified
  894. */
  895. enum fc_cos {
  896. FC_CLASS_2 = 0x04,
  897. FC_CLASS_3 = 0x08,
  898. FC_CLASS_2_3 = 0x0C,
  899. };
  900. /*
  901. * symbolic name
  902. */
  903. struct fc_symname_s {
  904. u8 symname[FC_SYMNAME_MAX];
  905. };
  906. struct fc_alpabm_s {
  907. u8 alpa_bm[FC_ALPA_MAX / 8];
  908. };
  909. /*
  910. * protocol default timeout values
  911. */
  912. #define FC_ED_TOV 2
  913. #define FC_REC_TOV (FC_ED_TOV + 1)
  914. #define FC_RA_TOV 10
  915. #define FC_ELS_TOV (2 * FC_RA_TOV)
  916. #define FC_FCCT_TOV (3 * FC_RA_TOV)
  917. /*
  918. * virtual fabric related defines
  919. */
  920. #define FC_VF_ID_NULL 0 /* must not be used as VF_ID */
  921. #define FC_VF_ID_MIN 1
  922. #define FC_VF_ID_MAX 0xEFF
  923. #define FC_VF_ID_CTL 0xFEF /* control VF_ID */
  924. /*
  925. * Virtual Fabric Tagging header format
  926. * @caution This is defined only in BIG ENDIAN format.
  927. */
  928. struct fc_vft_s {
  929. u32 r_ctl:8;
  930. u32 ver:2;
  931. u32 type:4;
  932. u32 res_a:2;
  933. u32 priority:3;
  934. u32 vf_id:12;
  935. u32 res_b:1;
  936. u32 hopct:8;
  937. u32 res_c:24;
  938. };
  939. /*
  940. * FCP_CMND definitions
  941. */
  942. #define FCP_CMND_CDB_LEN 16
  943. #define FCP_CMND_LUN_LEN 8
  944. struct fcp_cmnd_s {
  945. struct scsi_lun lun; /* 64-bit LU number */
  946. u8 crn; /* command reference number */
  947. #ifdef __BIG_ENDIAN
  948. u8 resvd:1,
  949. priority:4, /* FCP-3: SAM-3 priority */
  950. taskattr:3; /* scsi task attribute */
  951. #else
  952. u8 taskattr:3, /* scsi task attribute */
  953. priority:4, /* FCP-3: SAM-3 priority */
  954. resvd:1;
  955. #endif
  956. u8 tm_flags; /* task management flags */
  957. #ifdef __BIG_ENDIAN
  958. u8 addl_cdb_len:6, /* additional CDB length words */
  959. iodir:2; /* read/write FCP_DATA IUs */
  960. #else
  961. u8 iodir:2, /* read/write FCP_DATA IUs */
  962. addl_cdb_len:6; /* additional CDB length */
  963. #endif
  964. struct scsi_cdb_s cdb;
  965. __be32 fcp_dl; /* bytes to be transferred */
  966. };
  967. #define fcp_cmnd_cdb_len(_cmnd) ((_cmnd)->addl_cdb_len * 4 + FCP_CMND_CDB_LEN)
  968. #define fcp_cmnd_fcpdl(_cmnd) ((&(_cmnd)->fcp_dl)[(_cmnd)->addl_cdb_len])
  969. /*
  970. * struct fcp_cmnd_s .iodir field values
  971. */
  972. enum fcp_iodir {
  973. FCP_IODIR_NONE = 0,
  974. FCP_IODIR_WRITE = 1,
  975. FCP_IODIR_READ = 2,
  976. FCP_IODIR_RW = 3,
  977. };
  978. /*
  979. * Task management flags field - only one bit shall be set
  980. */
  981. enum fcp_tm_cmnd {
  982. FCP_TM_ABORT_TASK_SET = BIT(1),
  983. FCP_TM_CLEAR_TASK_SET = BIT(2),
  984. FCP_TM_LUN_RESET = BIT(4),
  985. FCP_TM_TARGET_RESET = BIT(5), /* obsolete in FCP-3 */
  986. FCP_TM_CLEAR_ACA = BIT(6),
  987. };
  988. /*
  989. * FCP_RSP residue flags
  990. */
  991. enum fcp_residue {
  992. FCP_NO_RESIDUE = 0, /* no residue */
  993. FCP_RESID_OVER = 1, /* more data left that was not sent */
  994. FCP_RESID_UNDER = 2, /* less data than requested */
  995. };
  996. struct fcp_rspinfo_s {
  997. u32 res0:24;
  998. u32 rsp_code:8; /* response code (as above) */
  999. u32 res1;
  1000. };
  1001. struct fcp_resp_s {
  1002. u32 reserved[2]; /* 2 words reserved */
  1003. u16 reserved2;
  1004. #ifdef __BIG_ENDIAN
  1005. u8 reserved3:3;
  1006. u8 fcp_conf_req:1; /* FCP_CONF is requested */
  1007. u8 resid_flags:2; /* underflow/overflow */
  1008. u8 sns_len_valid:1; /* sense len is valid */
  1009. u8 rsp_len_valid:1; /* response len is valid */
  1010. #else
  1011. u8 rsp_len_valid:1; /* response len is valid */
  1012. u8 sns_len_valid:1; /* sense len is valid */
  1013. u8 resid_flags:2; /* underflow/overflow */
  1014. u8 fcp_conf_req:1; /* FCP_CONF is requested */
  1015. u8 reserved3:3;
  1016. #endif
  1017. u8 scsi_status; /* one byte SCSI status */
  1018. u32 residue; /* residual data bytes */
  1019. u32 sns_len; /* length od sense info */
  1020. u32 rsp_len; /* length of response info */
  1021. };
  1022. #define fcp_snslen(__fcprsp) ((__fcprsp)->sns_len_valid ? \
  1023. (__fcprsp)->sns_len : 0)
  1024. #define fcp_rsplen(__fcprsp) ((__fcprsp)->rsp_len_valid ? \
  1025. (__fcprsp)->rsp_len : 0)
  1026. #define fcp_rspinfo(__fcprsp) ((struct fcp_rspinfo_s *)((__fcprsp) + 1))
  1027. #define fcp_snsinfo(__fcprsp) (((u8 *)fcp_rspinfo(__fcprsp)) + \
  1028. fcp_rsplen(__fcprsp))
  1029. /*
  1030. * CT
  1031. */
  1032. struct ct_hdr_s {
  1033. u32 rev_id:8; /* Revision of the CT */
  1034. u32 in_id:24; /* Initiator Id */
  1035. u32 gs_type:8; /* Generic service Type */
  1036. u32 gs_sub_type:8; /* Generic service sub type */
  1037. u32 options:8; /* options */
  1038. u32 rsvrd:8; /* reserved */
  1039. u32 cmd_rsp_code:16;/* ct command/response code */
  1040. u32 max_res_size:16;/* maximum/residual size */
  1041. u32 frag_id:8; /* fragment ID */
  1042. u32 reason_code:8; /* reason code */
  1043. u32 exp_code:8; /* explanation code */
  1044. u32 vendor_unq:8; /* vendor unique */
  1045. };
  1046. /*
  1047. * defines for the Revision
  1048. */
  1049. enum {
  1050. CT_GS3_REVISION = 0x01,
  1051. };
  1052. /*
  1053. * defines for gs_type
  1054. */
  1055. enum {
  1056. CT_GSTYPE_KEYSERVICE = 0xF7,
  1057. CT_GSTYPE_ALIASSERVICE = 0xF8,
  1058. CT_GSTYPE_MGMTSERVICE = 0xFA,
  1059. CT_GSTYPE_TIMESERVICE = 0xFB,
  1060. CT_GSTYPE_DIRSERVICE = 0xFC,
  1061. };
  1062. /*
  1063. * defines for gs_sub_type for gs type directory service
  1064. */
  1065. enum {
  1066. CT_GSSUBTYPE_NAMESERVER = 0x02,
  1067. };
  1068. /*
  1069. * defines for gs_sub_type for gs type management service
  1070. */
  1071. enum {
  1072. CT_GSSUBTYPE_CFGSERVER = 0x01,
  1073. CT_GSSUBTYPE_UNZONED_NS = 0x02,
  1074. CT_GSSUBTYPE_ZONESERVER = 0x03,
  1075. CT_GSSUBTYPE_LOCKSERVER = 0x04,
  1076. CT_GSSUBTYPE_HBA_MGMTSERVER = 0x10, /* for FDMI */
  1077. };
  1078. /*
  1079. * defines for CT response code field
  1080. */
  1081. enum {
  1082. CT_RSP_REJECT = 0x8001,
  1083. CT_RSP_ACCEPT = 0x8002,
  1084. };
  1085. /*
  1086. * defintions for CT reason code
  1087. */
  1088. enum {
  1089. CT_RSN_INV_CMD = 0x01,
  1090. CT_RSN_INV_VER = 0x02,
  1091. CT_RSN_LOGIC_ERR = 0x03,
  1092. CT_RSN_INV_SIZE = 0x04,
  1093. CT_RSN_LOGICAL_BUSY = 0x05,
  1094. CT_RSN_PROTO_ERR = 0x07,
  1095. CT_RSN_UNABLE_TO_PERF = 0x09,
  1096. CT_RSN_NOT_SUPP = 0x0B,
  1097. CT_RSN_SERVER_NOT_AVBL = 0x0D,
  1098. CT_RSN_SESSION_COULD_NOT_BE_ESTBD = 0x0E,
  1099. CT_RSN_VENDOR_SPECIFIC = 0xFF,
  1100. };
  1101. /*
  1102. * definitions for explanations code for Name server
  1103. */
  1104. enum {
  1105. CT_NS_EXP_NOADDITIONAL = 0x00,
  1106. CT_NS_EXP_ID_NOT_REG = 0x01,
  1107. CT_NS_EXP_PN_NOT_REG = 0x02,
  1108. CT_NS_EXP_NN_NOT_REG = 0x03,
  1109. CT_NS_EXP_CS_NOT_REG = 0x04,
  1110. CT_NS_EXP_IPN_NOT_REG = 0x05,
  1111. CT_NS_EXP_IPA_NOT_REG = 0x06,
  1112. CT_NS_EXP_FT_NOT_REG = 0x07,
  1113. CT_NS_EXP_SPN_NOT_REG = 0x08,
  1114. CT_NS_EXP_SNN_NOT_REG = 0x09,
  1115. CT_NS_EXP_PT_NOT_REG = 0x0A,
  1116. CT_NS_EXP_IPP_NOT_REG = 0x0B,
  1117. CT_NS_EXP_FPN_NOT_REG = 0x0C,
  1118. CT_NS_EXP_HA_NOT_REG = 0x0D,
  1119. CT_NS_EXP_FD_NOT_REG = 0x0E,
  1120. CT_NS_EXP_FF_NOT_REG = 0x0F,
  1121. CT_NS_EXP_ACCESSDENIED = 0x10,
  1122. CT_NS_EXP_UNACCEPTABLE_ID = 0x11,
  1123. CT_NS_EXP_DATABASEEMPTY = 0x12,
  1124. CT_NS_EXP_NOT_REG_IN_SCOPE = 0x13,
  1125. CT_NS_EXP_DOM_ID_NOT_PRESENT = 0x14,
  1126. CT_NS_EXP_PORT_NUM_NOT_PRESENT = 0x15,
  1127. CT_NS_EXP_NO_DEVICE_ATTACHED = 0x16
  1128. };
  1129. /*
  1130. * defintions for the explanation code for all servers
  1131. */
  1132. enum {
  1133. CT_EXP_AUTH_EXCEPTION = 0xF1,
  1134. CT_EXP_DB_FULL = 0xF2,
  1135. CT_EXP_DB_EMPTY = 0xF3,
  1136. CT_EXP_PROCESSING_REQ = 0xF4,
  1137. CT_EXP_UNABLE_TO_VERIFY_CONN = 0xF5,
  1138. CT_EXP_DEVICES_NOT_IN_CMN_ZONE = 0xF6
  1139. };
  1140. /*
  1141. * Command codes for Name server
  1142. */
  1143. enum {
  1144. GS_GID_PN = 0x0121, /* Get Id on port name */
  1145. GS_GPN_ID = 0x0112, /* Get port name on ID */
  1146. GS_GNN_ID = 0x0113, /* Get node name on ID */
  1147. GS_GID_FT = 0x0171, /* Get Id on FC4 type */
  1148. GS_GSPN_ID = 0x0118, /* Get symbolic PN on ID */
  1149. GS_RFT_ID = 0x0217, /* Register fc4type on ID */
  1150. GS_RSPN_ID = 0x0218, /* Register symbolic PN on ID */
  1151. GS_RSNN_NN = 0x0239, /* Register symbolic NN on NN */
  1152. GS_RPN_ID = 0x0212, /* Register port name */
  1153. GS_RNN_ID = 0x0213, /* Register node name */
  1154. GS_RCS_ID = 0x0214, /* Register class of service */
  1155. GS_RPT_ID = 0x021A, /* Register port type */
  1156. GS_GA_NXT = 0x0100, /* Get all next */
  1157. GS_RFF_ID = 0x021F, /* Register FC4 Feature */
  1158. };
  1159. struct fcgs_id_req_s {
  1160. u32 rsvd:8;
  1161. u32 dap:24; /* port identifier */
  1162. };
  1163. #define fcgs_gpnid_req_t struct fcgs_id_req_s
  1164. #define fcgs_gnnid_req_t struct fcgs_id_req_s
  1165. #define fcgs_gspnid_req_t struct fcgs_id_req_s
  1166. struct fcgs_gidpn_req_s {
  1167. wwn_t port_name; /* port wwn */
  1168. };
  1169. struct fcgs_gidpn_resp_s {
  1170. u32 rsvd:8;
  1171. u32 dap:24; /* port identifier */
  1172. };
  1173. /*
  1174. * RFT_ID
  1175. */
  1176. struct fcgs_rftid_req_s {
  1177. u32 rsvd:8;
  1178. u32 dap:24; /* port identifier */
  1179. __be32 fc4_type[8]; /* fc4 types */
  1180. };
  1181. /*
  1182. * RFF_ID : Register FC4 features.
  1183. */
  1184. #define FC_GS_FCP_FC4_FEATURE_INITIATOR 0x02
  1185. #define FC_GS_FCP_FC4_FEATURE_TARGET 0x01
  1186. struct fcgs_rffid_req_s {
  1187. u32 rsvd:8;
  1188. u32 dap:24; /* port identifier */
  1189. u32 rsvd1:16;
  1190. u32 fc4ftr_bits:8; /* fc4 feature bits */
  1191. u32 fc4_type:8; /* corresponding FC4 Type */
  1192. };
  1193. /*
  1194. * GID_FT Request
  1195. */
  1196. struct fcgs_gidft_req_s {
  1197. u8 reserved;
  1198. u8 domain_id; /* domain, 0 - all fabric */
  1199. u8 area_id; /* area, 0 - whole domain */
  1200. u8 fc4_type; /* FC_TYPE_FCP for SCSI devices */
  1201. };
  1202. /*
  1203. * GID_FT Response
  1204. */
  1205. struct fcgs_gidft_resp_s {
  1206. u8 last:1; /* last port identifier flag */
  1207. u8 reserved:7;
  1208. u32 pid:24; /* port identifier */
  1209. };
  1210. /*
  1211. * RSPN_ID
  1212. */
  1213. struct fcgs_rspnid_req_s {
  1214. u32 rsvd:8;
  1215. u32 dap:24; /* port identifier */
  1216. u8 spn_len; /* symbolic port name length */
  1217. u8 spn[256]; /* symbolic port name */
  1218. };
  1219. /*
  1220. * RSNN_NN
  1221. */
  1222. struct fcgs_rsnn_nn_req_s {
  1223. wwn_t node_name; /* Node name */
  1224. u8 snn_len; /* symbolic node name length */
  1225. u8 snn[256]; /* symbolic node name */
  1226. };
  1227. /*
  1228. * RPN_ID
  1229. */
  1230. struct fcgs_rpnid_req_s {
  1231. u32 rsvd:8;
  1232. u32 port_id:24;
  1233. wwn_t port_name;
  1234. };
  1235. /*
  1236. * RNN_ID
  1237. */
  1238. struct fcgs_rnnid_req_s {
  1239. u32 rsvd:8;
  1240. u32 port_id:24;
  1241. wwn_t node_name;
  1242. };
  1243. /*
  1244. * RCS_ID
  1245. */
  1246. struct fcgs_rcsid_req_s {
  1247. u32 rsvd:8;
  1248. u32 port_id:24;
  1249. u32 cos;
  1250. };
  1251. /*
  1252. * RPT_ID
  1253. */
  1254. struct fcgs_rptid_req_s {
  1255. u32 rsvd:8;
  1256. u32 port_id:24;
  1257. u32 port_type:8;
  1258. u32 rsvd1:24;
  1259. };
  1260. /*
  1261. * GA_NXT Request
  1262. */
  1263. struct fcgs_ganxt_req_s {
  1264. u32 rsvd:8;
  1265. u32 port_id:24;
  1266. };
  1267. /*
  1268. * GA_NXT Response
  1269. */
  1270. struct fcgs_ganxt_rsp_s {
  1271. u32 port_type:8; /* Port Type */
  1272. u32 port_id:24; /* Port Identifier */
  1273. wwn_t port_name; /* Port Name */
  1274. u8 spn_len; /* Length of Symbolic Port Name */
  1275. char spn[255]; /* Symbolic Port Name */
  1276. wwn_t node_name; /* Node Name */
  1277. u8 snn_len; /* Length of Symbolic Node Name */
  1278. char snn[255]; /* Symbolic Node Name */
  1279. u8 ipa[8]; /* Initial Process Associator */
  1280. u8 ip[16]; /* IP Address */
  1281. u32 cos; /* Class of Service */
  1282. u32 fc4types[8]; /* FC-4 TYPEs */
  1283. wwn_t fabric_port_name; /* Fabric Port Name */
  1284. u32 rsvd:8; /* Reserved */
  1285. u32 hard_addr:24; /* Hard Address */
  1286. };
  1287. /*
  1288. * Command codes for Fabric Configuration Server
  1289. */
  1290. enum {
  1291. GS_FC_GFN_CMD = 0x0114, /* GS FC Get Fabric Name */
  1292. GS_FC_GMAL_CMD = 0x0116, /* GS FC GMAL */
  1293. GS_FC_TRACE_CMD = 0x0400, /* GS FC Trace Route */
  1294. GS_FC_PING_CMD = 0x0401, /* GS FC Ping */
  1295. };
  1296. /*
  1297. * GMAL Command ( Get ( interconnect Element) Management Address List)
  1298. * To retrieve the IP Address of a Switch.
  1299. */
  1300. #define CT_GMAL_RESP_PREFIX_TELNET "telnet://"
  1301. #define CT_GMAL_RESP_PREFIX_HTTP "http://"
  1302. /* GMAL/GFN request */
  1303. struct fcgs_req_s {
  1304. wwn_t wwn; /* PWWN/NWWN */
  1305. };
  1306. #define fcgs_gmal_req_t struct fcgs_req_s
  1307. #define fcgs_gfn_req_t struct fcgs_req_s
  1308. /* Accept Response to GMAL */
  1309. struct fcgs_gmal_resp_s {
  1310. __be32 ms_len; /* Num of entries */
  1311. u8 ms_ma[256];
  1312. };
  1313. struct fcgs_gmal_entry_s {
  1314. u8 len;
  1315. u8 prefix[7]; /* like "http://" */
  1316. u8 ip_addr[248];
  1317. };
  1318. /*
  1319. * FDMI Command Codes
  1320. */
  1321. #define FDMI_GRHL 0x0100
  1322. #define FDMI_GHAT 0x0101
  1323. #define FDMI_GRPL 0x0102
  1324. #define FDMI_GPAT 0x0110
  1325. #define FDMI_RHBA 0x0200
  1326. #define FDMI_RHAT 0x0201
  1327. #define FDMI_RPRT 0x0210
  1328. #define FDMI_RPA 0x0211
  1329. #define FDMI_DHBA 0x0300
  1330. #define FDMI_DPRT 0x0310
  1331. /*
  1332. * FDMI reason codes
  1333. */
  1334. #define FDMI_NO_ADDITIONAL_EXP 0x00
  1335. #define FDMI_HBA_ALREADY_REG 0x10
  1336. #define FDMI_HBA_ATTRIB_NOT_REG 0x11
  1337. #define FDMI_HBA_ATTRIB_MULTIPLE 0x12
  1338. #define FDMI_HBA_ATTRIB_LENGTH_INVALID 0x13
  1339. #define FDMI_HBA_ATTRIB_NOT_PRESENT 0x14
  1340. #define FDMI_PORT_ORIG_NOT_IN_LIST 0x15
  1341. #define FDMI_PORT_HBA_NOT_IN_LIST 0x16
  1342. #define FDMI_PORT_ATTRIB_NOT_REG 0x20
  1343. #define FDMI_PORT_NOT_REG 0x21
  1344. #define FDMI_PORT_ATTRIB_MULTIPLE 0x22
  1345. #define FDMI_PORT_ATTRIB_LENGTH_INVALID 0x23
  1346. #define FDMI_PORT_ALREADY_REGISTEREED 0x24
  1347. /*
  1348. * FDMI Transmission Speed Mask values
  1349. */
  1350. #define FDMI_TRANS_SPEED_1G 0x00000001
  1351. #define FDMI_TRANS_SPEED_2G 0x00000002
  1352. #define FDMI_TRANS_SPEED_10G 0x00000004
  1353. #define FDMI_TRANS_SPEED_4G 0x00000008
  1354. #define FDMI_TRANS_SPEED_8G 0x00000010
  1355. #define FDMI_TRANS_SPEED_16G 0x00000020
  1356. #define FDMI_TRANS_SPEED_UNKNOWN 0x00008000
  1357. /*
  1358. * FDMI HBA attribute types
  1359. */
  1360. enum fdmi_hba_attribute_type {
  1361. FDMI_HBA_ATTRIB_NODENAME = 1, /* 0x0001 */
  1362. FDMI_HBA_ATTRIB_MANUFACTURER, /* 0x0002 */
  1363. FDMI_HBA_ATTRIB_SERIALNUM, /* 0x0003 */
  1364. FDMI_HBA_ATTRIB_MODEL, /* 0x0004 */
  1365. FDMI_HBA_ATTRIB_MODEL_DESC, /* 0x0005 */
  1366. FDMI_HBA_ATTRIB_HW_VERSION, /* 0x0006 */
  1367. FDMI_HBA_ATTRIB_DRIVER_VERSION, /* 0x0007 */
  1368. FDMI_HBA_ATTRIB_ROM_VERSION, /* 0x0008 */
  1369. FDMI_HBA_ATTRIB_FW_VERSION, /* 0x0009 */
  1370. FDMI_HBA_ATTRIB_OS_NAME, /* 0x000A */
  1371. FDMI_HBA_ATTRIB_MAX_CT, /* 0x000B */
  1372. FDMI_HBA_ATTRIB_NODE_SYM_NAME, /* 0x000C */
  1373. FDMI_HBA_ATTRIB_VENDOR_INFO, /* 0x000D */
  1374. FDMI_HBA_ATTRIB_NUM_PORTS, /* 0x000E */
  1375. FDMI_HBA_ATTRIB_FABRIC_NAME, /* 0x000F */
  1376. FDMI_HBA_ATTRIB_BIOS_VER, /* 0x0010 */
  1377. FDMI_HBA_ATTRIB_VENDOR_ID = 0x00E0,
  1378. FDMI_HBA_ATTRIB_MAX_TYPE
  1379. };
  1380. /*
  1381. * FDMI Port attribute types
  1382. */
  1383. enum fdmi_port_attribute_type {
  1384. FDMI_PORT_ATTRIB_FC4_TYPES = 1, /* 0x0001 */
  1385. FDMI_PORT_ATTRIB_SUPP_SPEED, /* 0x0002 */
  1386. FDMI_PORT_ATTRIB_PORT_SPEED, /* 0x0003 */
  1387. FDMI_PORT_ATTRIB_FRAME_SIZE, /* 0x0004 */
  1388. FDMI_PORT_ATTRIB_DEV_NAME, /* 0x0005 */
  1389. FDMI_PORT_ATTRIB_HOST_NAME, /* 0x0006 */
  1390. FDMI_PORT_ATTRIB_NODE_NAME, /* 0x0007 */
  1391. FDMI_PORT_ATTRIB_PORT_NAME, /* 0x0008 */
  1392. FDMI_PORT_ATTRIB_PORT_SYM_NAME, /* 0x0009 */
  1393. FDMI_PORT_ATTRIB_PORT_TYPE, /* 0x000A */
  1394. FDMI_PORT_ATTRIB_SUPP_COS, /* 0x000B */
  1395. FDMI_PORT_ATTRIB_PORT_FAB_NAME, /* 0x000C */
  1396. FDMI_PORT_ATTRIB_PORT_FC4_TYPE, /* 0x000D */
  1397. FDMI_PORT_ATTRIB_PORT_STATE = 0x101, /* 0x0101 */
  1398. FDMI_PORT_ATTRIB_PORT_NUM_RPRT = 0x102, /* 0x0102 */
  1399. FDMI_PORT_ATTR_MAX_TYPE
  1400. };
  1401. /*
  1402. * FDMI attribute
  1403. */
  1404. struct fdmi_attr_s {
  1405. __be16 type;
  1406. __be16 len;
  1407. u8 value[1];
  1408. };
  1409. /*
  1410. * HBA Attribute Block
  1411. */
  1412. struct fdmi_hba_attr_s {
  1413. __be32 attr_count; /* # of attributes */
  1414. struct fdmi_attr_s hba_attr; /* n attributes */
  1415. };
  1416. /*
  1417. * Registered Port List
  1418. */
  1419. struct fdmi_port_list_s {
  1420. __be32 num_ports; /* number Of Port Entries */
  1421. wwn_t port_entry; /* one or more */
  1422. };
  1423. /*
  1424. * Port Attribute Block
  1425. */
  1426. struct fdmi_port_attr_s {
  1427. __be32 attr_count; /* # of attributes */
  1428. struct fdmi_attr_s port_attr; /* n attributes */
  1429. };
  1430. /*
  1431. * FDMI Register HBA Attributes
  1432. */
  1433. struct fdmi_rhba_s {
  1434. wwn_t hba_id; /* HBA Identifier */
  1435. struct fdmi_port_list_s port_list; /* Registered Port List */
  1436. struct fdmi_hba_attr_s hba_attr_blk; /* HBA attribute block */
  1437. };
  1438. /*
  1439. * FDMI Register Port
  1440. */
  1441. struct fdmi_rprt_s {
  1442. wwn_t hba_id; /* HBA Identifier */
  1443. wwn_t port_name; /* Port wwn */
  1444. struct fdmi_port_attr_s port_attr_blk; /* Port Attr Block */
  1445. };
  1446. /*
  1447. * FDMI Register Port Attributes
  1448. */
  1449. struct fdmi_rpa_s {
  1450. wwn_t port_name; /* port wwn */
  1451. struct fdmi_port_attr_s port_attr_blk; /* Port Attr Block */
  1452. };
  1453. #pragma pack()
  1454. #endif /* __BFA_FC_H__ */