bfa_fc.h 40 KB

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