cpqfcTSstructs.h 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530
  1. /* Copyright(c) 2000, Compaq Computer Corporation
  2. * Fibre Channel Host Bus Adapter 64-bit, 66MHz PCI
  3. * Originally developed and tested on:
  4. * (front): [chip] Tachyon TS HPFC-5166A/1.2 L2C1090 ...
  5. * SP# P225CXCBFIEL6T, Rev XC
  6. * SP# 161290-001, Rev XD
  7. * (back): Board No. 010008-001 A/W Rev X5, FAB REV X5
  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 as published by the
  11. * Free Software Foundation; either version 2, or (at your option) any
  12. * later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. * Written by Don Zimmerman
  19. */
  20. #ifndef CPQFCTSSTRUCTS_H
  21. #define CPQFCTSSTRUCTS_H
  22. #include <linux/timer.h> // timer declaration in our host data
  23. #include <linux/interrupt.h>
  24. #include <asm/atomic.h>
  25. #include "cpqfcTSioctl.h"
  26. #define DbgDelay(secs) { int wait_time; printk( " DbgDelay %ds ", secs); \
  27. for( wait_time=jiffies + (secs*HZ); \
  28. time_before(jiffies, wait_time) ;) ; }
  29. #define CPQFCTS_DRIVER_VER(maj,min,submin) ((maj<<16)|(min<<8)|(submin))
  30. // don't forget to also change MODULE_DESCRIPTION in cpqfcTSinit.c
  31. #define VER_MAJOR 2
  32. #define VER_MINOR 5
  33. #define VER_SUBMINOR 4
  34. // Macros for kernel (esp. SMP) tracing using a PCI analyzer
  35. // (e.g. x86).
  36. //#define PCI_KERNEL_TRACE
  37. #ifdef PCI_KERNEL_TRACE
  38. #define PCI_TRACE(x) inl( fcChip->Registers.IOBaseL +x);
  39. #define PCI_TRACEO(x,y) outl( x, (fcChip->Registers.IOBaseL +y));
  40. #else
  41. #define PCI_TRACE(x)
  42. #define PCI_TRACEO(x,y)
  43. #endif
  44. //#define DEBUG_CMND 1 // debug output for Linux Scsi CDBs
  45. //#define DUMMYCMND_DBG 1
  46. //#define DEBUG_CPQFCTS 1
  47. //#undef DEBUG_CPQFCTS
  48. #ifdef DEBUG_CPQFCTS
  49. #define ENTER(x) printk("cpqfcts : entering %s()\n", x);
  50. #define LEAVE(x) printk("cpqfcts : leaving %s()\n", x);
  51. #define DEBUG(x) x
  52. #else
  53. #define ENTER(x)
  54. #define LEAVE(x)
  55. #define DEBUG(x)
  56. #endif /* DEBUG_CPQFCTS */
  57. //#define DEBUG_CPQFCTS_PCI 1
  58. //#undef DEBUG_CPQFCTS_PCI
  59. #if DEBUG_CPQFCTS_PCI
  60. #define DEBUG_PCI(x) x
  61. #else
  62. #define DEBUG_PCI(x)
  63. #endif /* DEBUG_CPQFCTS_PCI */
  64. #define STACHLITE66_TS12 "Compaq FibreChannel HBA Tachyon TS HPFC-5166A/1.2"
  65. #define STACHLITE66_TS13 "Compaq FibreChannel HBA Tachyon TS HPFC-5166A/1.3"
  66. #define STACHLITE_UNKNOWN "Compaq FibreChannel HBA Tachyon Chip/Board Ver??"
  67. #define SAGILENT_XL2_21 "Agilent FC HBA, Tachyon XL2 HPFC-5200B/2.1"
  68. // PDA is Peripheral Device Address, VSA is Volume Set Addressing
  69. // Linux SCSI parameters
  70. #define CPQFCTS_MAX_TARGET_ID 64
  71. // Note, changing CPQFCTS_MAX_LUN to less than 32 (e.g, 8) will result in
  72. // strange behavior if a box with more than, e.g. 8, is on the loop.
  73. #define CPQFCTS_MAX_LUN 32 // The RA-4x00 supports 32 (Linux SCSI supports 8)
  74. #define CPQFCTS_MAX_CHANNEL 0 // One FC port on cpqfcTS HBA
  75. #define CPQFCTS_CMD_PER_LUN 15 // power of 2 -1, must be >0
  76. #define CPQFCTS_REQ_QUEUE_LEN (TACH_SEST_LEN/2) // must be < TACH_SEST_LEN
  77. #define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
  78. #ifndef DECLARE_MUTEX_LOCKED
  79. #define DECLARE_MUTEX_LOCKED(sem) struct semaphore sem = MUTEX_LOCKED
  80. #endif
  81. #define DEV_NAME "cpqfcTS"
  82. struct SupportedPCIcards
  83. {
  84. __u16 vendor_id;
  85. __u16 device_id;
  86. };
  87. // nn:nn denotes bit field
  88. // TachyonHeader struct def.
  89. // the fields shared with ODB
  90. // need to have same value
  91. #ifndef BYTE
  92. //typedef UCHAR BYTE;
  93. typedef __u8 BYTE;
  94. #endif
  95. #ifndef UCHAR
  96. typedef __u8 UCHAR;
  97. #endif
  98. #ifndef LONG
  99. typedef __s32 LONG;
  100. #endif
  101. #ifndef ULONG
  102. typedef __u32 ULONG;
  103. #endif
  104. #ifndef PVOID
  105. typedef void * PVOID;
  106. #endif
  107. #ifndef USHORT
  108. typedef __u16 USHORT;
  109. #endif
  110. #ifndef BOOLEAN
  111. typedef __u8 BOOLEAN;
  112. #endif
  113. // macro for FC-PH reject codes
  114. // payload format for LS_RJT (FC payloads are big endian):
  115. // byte 0 1 2 3 (MSB)
  116. // DWORD 0 01 00 00 00
  117. // DWORD 1 resvd code expl. vendor
  118. #define LS_RJT_REASON( code, expl) (( code<<8) | (expl <<16))
  119. #define TachLiteSTATUS 0x12
  120. // Fibre Channel EXCHANGE status codes for Tachyon chips/ driver software
  121. // 32-bit ERROR word defines
  122. #define INVALID_ARGS 0x1
  123. #define LNKDWN_OSLS 0x2
  124. #define LNKDWN_LASER 0x4
  125. #define OUTQUE_FULL 0x8
  126. #define DRIVERQ_FULL 0x10
  127. #define SEST_FULL 0x20
  128. #define BAD_ALPA 0x40
  129. #define OVERFLOW 0x80 // inbound CM
  130. #define COUNT_ERROR 0x100 // inbound CM
  131. #define LINKFAIL_RX 0x200 // inbound CM
  132. #define ABORTSEQ_NOTIFY 0x400 // outbound CM
  133. #define LINKFAIL_TX 0x800 // outbound CM
  134. #define HOSTPROG_ERR 0x1000 // outbound CM
  135. #define FRAME_TO 0x2000 // outbound CM
  136. #define INV_ENTRY 0x4000 // outbound CM
  137. #define SESTPROG_ERR 0x8000 // outbound CM
  138. #define OUTBOUND_TIMEOUT 0x10000L // timeout waiting for Tachyon outbound CM
  139. #define INITIATOR_ABORT 0x20000L // initiator exchange timeout or O/S ABORT
  140. #define MEMPOOL_FAIL 0x40000L // O/S memory pool allocation failed
  141. #define FC2_TIMEOUT 0x80000L // driver timeout for lost frames
  142. #define TARGET_ABORT 0x100000L // ABTS received from FC port
  143. #define EXCHANGE_QUEUED 0x200000L // e.g. Link State was LDn on fcStart
  144. #define PORTID_CHANGED 0x400000L // fc Port address changed
  145. #define DEVICE_REMOVED 0x800000L // fc Port address changed
  146. // Several error scenarios result in SEST Exchange frames
  147. // unexpectedly arriving in the SFQ
  148. #define SFQ_FRAME 0x1000000L // SFQ frames from open Exchange
  149. // Maximum number of Host Bus Adapters (HBA) / controllers supported
  150. // only important for mem allocation dimensions - increase as necessary
  151. #define MAX_ADAPTERS 8
  152. #define MAX_RX_PAYLOAD 1024 // hardware dependent max frame payload
  153. // Tach header struc defines
  154. #define SOFi3 0x7
  155. #define SOFf 0x8
  156. #define SOFn3 0xB
  157. #define EOFn 0x5
  158. #define EOFt 0x6
  159. // FCP R_CTL defines
  160. #define FCP_CMND 0x6
  161. #define FCP_XFER_RDY 0x5
  162. #define FCP_RSP 0x7
  163. #define FCP_RESPONSE 0x777 // (arbitrary #)
  164. #define NEED_FCP_RSP 0x77 // (arbitrary #)
  165. #define FCP_DATA 0x1
  166. #define RESET_TACH 0x100 // Reset Tachyon/TachLite
  167. #define SCSI_IWE 0x2000 // initiator write entry (for SEST)
  168. #define SCSI_IRE 0x3000 // initiator read entry (for SEST)
  169. #define SCSI_TRE 0x400 // target read entry (for SEST)
  170. #define SCSI_TWE 0x500 // target write entry (for SEST)
  171. #define TOGGLE_LASER 0x800
  172. #define LIP 0x900
  173. #define CLEAR_FCPORTS 99 // (arbitrary #) free mem for Logged in ports
  174. #define FMINIT 0x707 // (arbitrary) for Frame Manager Init command
  175. // BLS == Basic Link Service
  176. // ELS == Extended Link Service
  177. #define BLS_NOP 4
  178. #define BLS_ABTS 0x10 // FC-PH Basic Link Service Abort Sequence
  179. #define BLS_ABTS_ACC 0x100 // FC-PH Basic Link Service Abort Sequence Accept
  180. #define BLS_ABTS_RJT 0x101 // FC-PH Basic Link Service Abort Sequence Reject
  181. #define ELS_PLOGI 0x03 // FC-PH Port Login (arbitrary assign)
  182. #define ELS_SCR 0x70 // (arb assign) State Change Registration (Fabric)
  183. #define FCS_NSR 0x72 // (arb assign) Name Service Request (Fabric)
  184. #define ELS_FLOGI 0x44 // (arb assign) Fabric Login
  185. #define ELS_FDISC 0x41 // (arb assign) Fabric Discovery (Login)
  186. #define ELS_PDISC 0x50 // FC-PH2 Port Discovery
  187. #define ELS_ABTX 0x06 // FC-PH Abort Exchange
  188. #define ELS_LOGO 0x05 // FC-PH Port Logout
  189. #define ELS_PRLI 0x20 // FCP-SCSI Process Login
  190. #define ELS_PRLO 0x21 // FCP-SCSI Process Logout
  191. #define ELS_LOGO_ACC 0x07 // {FC-PH} Port Logout Accept
  192. #define ELS_PLOGI_ACC 0x08 // {FC-PH} Port Login Accept
  193. #define ELS_ACC 0x18 // {FC-PH} (generic) ACCept
  194. #define ELS_PRLI_ACC 0x22 // {FCP-SCSI} Process Login Accept
  195. #define ELS_RJT 0x1000000
  196. #define SCSI_REPORT_LUNS 0x0A0
  197. #define FCP_TARGET_RESET 0x200
  198. #define ELS_LILP_FRAME 0x00000711 // 1st payload word of LILP frame
  199. #define SFQ_UNASSISTED_FCP 1 // ICM, DWord3, "Type" unassisted FCP
  200. #define SFQ_UNKNOWN 0x31 // (arbitrary) ICM, DWord3, "Type" unknown
  201. // these "LINK" bits refer to loop or non-loop
  202. #define LINKACTIVE 0x2 // fcLinkQ type - LINK UP Tachyon FM 'Lup' bit set
  203. #define LINKDOWN 0xf2 // fcLinkQ type - LINK DOWN Tachyon FM 'Ldn' bit set
  204. //#define VOLUME_SET_ADDRESSING 1 // "channel" or "bus" 1
  205. typedef struct // 32 bytes hdr ONLY (e.g. FCP_DATA buffer for SEST)
  206. {
  207. ULONG reserved; // dword 0 (don't use)
  208. ULONG sof_eof;
  209. ULONG d_id; // dword 2 - 31:24 R_CTL, 23:0 D_ID
  210. ULONG s_id; // dword 3 - 31:24 CS_CTL, 23:0 S_ID
  211. ULONG f_ctl; // dword 4 - 31:24 Type, 23:0 F_CTL
  212. ULONG seq_cnt; // dword 5 - 31:24 SEQ_ID, 23:16 DF_CTL, 15:0 SEQ_CNT
  213. ULONG ox_rx_id; // dword 6 - 31:16 OX_ID, 15:0 RX_ID
  214. ULONG ro; // dword 7 - relative offset
  215. } TachFCHDR;
  216. // NOTE!! the following struct MUST be 64 bytes.
  217. typedef struct // 32 bytes hdr + 32 bytes payload
  218. {
  219. ULONG reserved; // dword 0 (don't use - must clear to 0)
  220. ULONG sof_eof; // dword 1 - 31:24 SOF:EOF, UAM,CLS, LCr, TFV, TimeStamp
  221. ULONG d_id; // dword 2 - 31:24 R_CTL, 23:0 D_ID
  222. ULONG s_id; // dword 3 - 31:24 CS_CTL, 23:0 S_ID
  223. ULONG f_ctl; // dword 4 - 31:24 Type, 23:0 F_CTL
  224. ULONG seq_cnt; // dword 5 - 31:24 SEQ_ID, 23:16 DF_CTL, 15:0 SEQ_CNT
  225. ULONG ox_rx_id; // dword 6 - 31:16 OX_ID, 15:0 RX_ID
  226. ULONG ro; // dword 7 - relative offset
  227. //---------
  228. __u32 pl[8]; // dwords 8-15 frame data payload
  229. } TachFCHDR_CMND;
  230. typedef struct // 32 bytes hdr + 120 bytes payload
  231. {
  232. ULONG reserved; // dword 0 (don't use - must clear to 0)
  233. ULONG sof_eof; // dword 1 - 31:24 SOF:EOF, UAM,CLS, LCr, TFV, TimeStamp
  234. ULONG d_id; // dword 2 - 31:24 R_CTL, 23:0 D_ID
  235. ULONG s_id; // dword 3 - 31:24 CS_CTL, 23:0 S_ID
  236. ULONG f_ctl; // dword 4 - 31:24 Type, 23:0 F_CTL
  237. ULONG seq_cnt; // dword 5 - 31:24 SEQ_ID, 23:16 DF_CTL, 15:0 SEQ_CNT
  238. ULONG ox_rx_id; // dword 6 - 31:16 OX_ID, 15:0 RX_ID
  239. ULONG ro; // dword 7 - relative offset
  240. //---------
  241. __u32 pl[30]; // largest necessary payload (for LOGIN cmnds)
  242. } TachFCHDR_GCMND;
  243. typedef struct // 32 bytes hdr + 64 bytes payload
  244. {
  245. ULONG reserved; // dword 0 (don't use)
  246. ULONG sof_eof;
  247. ULONG d_id; // dword 2 - 31:24 R_CTL, 23:0 D_ID
  248. ULONG s_id; // dword 3 - 31:24 CS_CTL, 23:0 S_ID
  249. ULONG f_ctl; // dword 4 - 31:24 Type, 23:0 F_CTL
  250. ULONG seq_cnt; // dword 5 - 31:24 SEQ_ID, 23:16 DF_CTL, 15:0 SEQ_CNT
  251. ULONG ox_rx_id; // dword 6 - 31:16 OX_ID, 15:0 RX_ID
  252. ULONG ro; // dword 7 - relative offset
  253. //---------
  254. __u32 pl[18]; // payload for FCP-RSP (response buffer) RA-4x00 is 72bytes
  255. } TachFCHDR_RSP;
  256. // Inbound Message Queue structures...
  257. typedef struct // each entry 8 words (32 bytes)
  258. {
  259. ULONG type; // IMQ completion message types
  260. ULONG word[7]; // remainder of structure
  261. // interpreted by IMQ type
  262. } TachyonIMQE;
  263. // Queues for TachLite not in original Tachyon
  264. // ERQ - Exchange Request Queue (for outbound commands)
  265. // SFQ - Single Frame Queue (for incoming frames)
  266. // Define Tachyon Outbound Command Que
  267. // (Since many Tachyon registers are Read
  268. // only, maintain copies for debugging)
  269. // most Tach ques need power-of-2 sizes,
  270. // where registers are loaded with po2 -1
  271. #define TACH_SEST_LEN 512 // TachLite SEST
  272. #define ELS_EXCHANGES 64 // e.g. PLOGI, RSCN, ...
  273. // define the total number of outstanding (simultaneous) exchanges
  274. #define TACH_MAX_XID (TACH_SEST_LEN + ELS_EXCHANGES) // ELS exchanges
  275. #define ERQ_LEN 128 // power of 2, max 4096
  276. // Inbound Message Queue structures...
  277. #define IMQ_LEN 512 // minimum 4 entries [(power of 2) - 1]
  278. typedef struct // 8 words - 32 bytes
  279. {
  280. TachyonIMQE QEntry[IMQ_LEN];
  281. ULONG producerIndex; // IMQ Producer Index register
  282. // @32 byte align
  283. ULONG consumerIndex; // Consumer Index register (in Tachyon)
  284. ULONG length; // Length register
  285. ULONG base;
  286. } TachyonIMQ; // @ 32 * IMQ_LEN align
  287. typedef struct // inbound completion message
  288. {
  289. ULONG Type;
  290. ULONG Index;
  291. ULONG TransferLength;
  292. } TachyonInbCM;
  293. // arbitrary numeric tags for TL structures
  294. #define TL_FCHS 1 // TachLite Fibre Channel Header Structure
  295. #define TL_IWE 2 // initiator write entry (for SEST)
  296. #define TL_TWE 3 // target write entry (for SEST)
  297. #define TL_IRE 4 // initiator read entry (for SEST)
  298. #define TL_TRE 5 // target read entry (for SEST)
  299. #define TL_IRB 6 // I/O request block
  300. // for INCOMING frames
  301. #define SFQ_LEN 32 // minimum 32 entries, max 4096
  302. typedef struct // Single Frame Que
  303. {
  304. TachFCHDR_CMND QEntry[SFQ_LEN]; // must be 64 bytes!!
  305. ULONG producerIndex; // IMQ Producer Index register
  306. // @32 byte align
  307. ULONG consumerIndex; // Consumer Index register (in Tachyon)
  308. ULONG length; // Length register
  309. ULONG base;
  310. } TachLiteSFQ;
  311. typedef struct // I/O Request Block flags
  312. {
  313. UCHAR BRD : 1;
  314. UCHAR : 1; // reserved
  315. UCHAR SFA : 1;
  316. UCHAR DNC : 1;
  317. UCHAR DIN : 1;
  318. UCHAR DCM : 1;
  319. UCHAR CTS : 1;
  320. UCHAR SBV : 1; // IRB entry valid - IRB'B' only
  321. } IRBflags;
  322. typedef struct // I/O Request Block
  323. { // Request 'A'
  324. ULONG Req_A_SFS_Len; // total frame len (hdr + payload), min 32
  325. ULONG Req_A_SFS_Addr; // 32-bit pointer to FCHS struct (to be sent)
  326. ULONG Req_A_SFS_D_ID; // 24-bit FC destination (i.e. 8 bit al_pa)
  327. ULONG Req_A_Trans_ID; // X_ID (OX_ID or RX_ID) and/or Index in SEST
  328. // Request 'B'
  329. ULONG Req_B_SFS_Len; // total frame len (hdr + payload), min 32
  330. ULONG Req_B_SFS_Addr; // 32-bit pointer to FCHS struct (to be sent)
  331. ULONG Req_B_SFS_D_ID; // 24-bit FC destination (i.e. 8 bit al_pa)
  332. ULONG Req_B_Trans_ID; // X_ID (OX_ID or RX_ID) and/or Index in SEST
  333. } TachLiteIRB;
  334. typedef struct // TachLite placeholder for IRBs
  335. { // aligned @sizeof(ERQ) for TachLite
  336. // MAX commands is sum of SEST len and ERQ
  337. // we know that each SEST entry requires an
  338. // IRB (ERQ) entry; in addition, we provide
  339. // ERQ_LEN
  340. TachLiteIRB QEntry[ERQ_LEN]; // Base register; entries 32 bytes ea.
  341. ULONG consumerIndex; // Consumer Index register
  342. ULONG producerIndex; // ERQ Producer Index register
  343. ULONG length; // Length register
  344. ULONG base; // copy of base ptr for debug
  345. // struct is sized for largest expected cmnd (LOGIN)
  346. } TachLiteERQ;
  347. // for now, just 32 bit DMA, eventually 40something, with code changes
  348. #define CPQFCTS_DMA_MASK ((unsigned long) (0x00000000FFFFFFFF))
  349. #define TL_MAX_SG_ELEM_LEN 0x7ffff // Max buffer length a single S/G entry
  350. // may represent (a hardware limitation). The
  351. // only reason to ever change this is if you
  352. // want to exercise very-hard-to-reach code in
  353. // cpqfcTSworker.c:build_SEST_sglist().
  354. #define TL_DANGER_SGPAGES 7 // arbitrary high water mark for # of S/G pages
  355. // we must exceed to elicit a warning indicative
  356. // of EXTREMELY large data transfers or
  357. // EXTREME memory fragmentation.
  358. // (means we just used up 2048 S/G elements,
  359. // Never seen this is real life, only in
  360. // testing with tricked up driver.)
  361. #define TL_EXT_SG_PAGE_COUNT 256 // Number of Extended Scatter/Gather a/l PAIRS
  362. // Tachyon register (IOBaseU 0x68)
  363. // power-of-2 value ONLY! 4 min, 256 max
  364. // byte len is #Pairs * 2 ULONG/Pair * 4 bytes/ULONG
  365. #define TL_EXT_SG_PAGE_BYTELEN (TL_EXT_SG_PAGE_COUNT *2 *4)
  366. // SEST entry types: IWE, IRE, TWE, TRE
  367. typedef struct
  368. {
  369. ULONG Hdr_Len;
  370. ULONG Hdr_Addr;
  371. ULONG RSP_Len;
  372. ULONG RSP_Addr;
  373. ULONG Buff_Off;
  374. #define USES_EXTENDED_SGLIST(this_sest, x_ID) \
  375. (!((this_sest)->u[ x_ID ].IWE.Buff_Off & 0x80000000))
  376. ULONG Link;
  377. ULONG RX_ID;
  378. ULONG Data_Len;
  379. ULONG Exp_RO;
  380. ULONG Exp_Byte_Cnt;
  381. // --- extended/local Gather Len/Address pairs
  382. ULONG GLen1;
  383. ULONG GAddr1;
  384. ULONG GLen2;
  385. ULONG GAddr2;
  386. ULONG GLen3;
  387. ULONG GAddr3;
  388. } TachLiteIWE;
  389. typedef struct
  390. {
  391. ULONG Seq_Accum;
  392. ULONG reserved; // must clear to 0
  393. ULONG RSP_Len;
  394. ULONG RSP_Addr;
  395. ULONG Buff_Off;
  396. ULONG Buff_Index; // ULONG 5
  397. ULONG Exp_RO;
  398. ULONG Byte_Count;
  399. ULONG reserved_; // ULONG 8
  400. ULONG Exp_Byte_Cnt;
  401. // --- extended/local Scatter Len/Address pairs
  402. ULONG SLen1;
  403. ULONG SAddr1;
  404. ULONG SLen2;
  405. ULONG SAddr2;
  406. ULONG SLen3;
  407. ULONG SAddr3;
  408. } TachLiteIRE;
  409. typedef struct // Target Write Entry
  410. {
  411. ULONG Seq_Accum; // dword 0
  412. ULONG reserved; // dword 1 must clear to 0
  413. ULONG Remote_Node_ID;
  414. ULONG reserved1; // dword 3 must clear to 0
  415. ULONG Buff_Off;
  416. ULONG Buff_Index; // ULONG 5
  417. ULONG Exp_RO;
  418. ULONG Byte_Count;
  419. ULONG reserved_; // ULONG 8
  420. ULONG Exp_Byte_Cnt;
  421. // --- extended/local Scatter Len/Address pairs
  422. ULONG SLen1;
  423. ULONG SAddr1;
  424. ULONG SLen2;
  425. ULONG SAddr2;
  426. ULONG SLen3;
  427. ULONG SAddr3;
  428. } TachLiteTWE;
  429. typedef struct
  430. {
  431. ULONG Hdr_Len;
  432. ULONG Hdr_Addr;
  433. ULONG RSP_Len; // DWord 2
  434. ULONG RSP_Addr;
  435. ULONG Buff_Off;
  436. ULONG Buff_Index; // DWord 5
  437. ULONG reserved;
  438. ULONG Data_Len;
  439. ULONG reserved_;
  440. ULONG reserved__;
  441. // --- extended/local Gather Len/Address pairs
  442. ULONG GLen1; // DWord A
  443. ULONG GAddr1;
  444. ULONG GLen2;
  445. ULONG GAddr2;
  446. ULONG GLen3;
  447. ULONG GAddr3;
  448. } TachLiteTRE;
  449. typedef struct ext_sg_page_ptr_t *PSGPAGES;
  450. typedef struct ext_sg_page_ptr_t
  451. {
  452. unsigned char page[TL_EXT_SG_PAGE_BYTELEN * 2]; // 2x for alignment
  453. dma_addr_t busaddr; // need the bus addresses and
  454. unsigned int maplen; // lengths for later pci unmapping.
  455. PSGPAGES next;
  456. } SGPAGES; // linked list of S/G pairs, by Exchange
  457. typedef struct // SCSI Exchange State Table
  458. {
  459. union // Entry can be IWE, IRE, TWE, TRE
  460. { // 64 bytes per entry
  461. TachLiteIWE IWE;
  462. TachLiteIRE IRE;
  463. TachLiteTWE TWE;
  464. TachLiteTRE TRE;
  465. } u[TACH_SEST_LEN];
  466. TachFCHDR DataHDR[TACH_SEST_LEN]; // for SEST FCP_DATA frame hdr (no pl)
  467. TachFCHDR_RSP RspHDR[TACH_SEST_LEN]; // space for SEST FCP_RSP frame
  468. PSGPAGES sgPages[TACH_SEST_LEN]; // head of linked list of Pool-allocations
  469. ULONG length; // Length register
  470. ULONG base; // copy of base ptr for debug
  471. } TachSEST;
  472. typedef struct // each register has it's own address
  473. // and value (used for write-only regs)
  474. {
  475. void* address;
  476. volatile ULONG value;
  477. } FCREGISTER;
  478. typedef struct // Host copy - TachLite Registers
  479. {
  480. ULONG IOBaseL, IOBaseU; // I/O port lower and upper TL register addresses
  481. ULONG MemBase; // memory mapped register addresses
  482. void* ReMapMemBase; // O/S VM reference for MemBase
  483. ULONG wwn_hi; // WWN is set once at startup
  484. ULONG wwn_lo;
  485. ULONG my_al_pa; // al_pa received after LIP()
  486. ULONG ROMCTR; // flags for on-board RAM/ROM
  487. ULONG RAMBase; // on-board RAM (i.e. some Tachlites)
  488. ULONG SROMBase; // on-board EEPROM (some Tachlites)
  489. ULONG PCIMCTR; // PCI Master Control Reg (has bus width)
  490. FCREGISTER INTEN; // copy of interrupt enable mask
  491. FCREGISTER INTPEND; // interrupt pending
  492. FCREGISTER INTSTAT; // interrupt status
  493. FCREGISTER SFQconsumerIndex;
  494. FCREGISTER ERQproducerIndex;
  495. FCREGISTER TYconfig; // TachYon (chip level)
  496. FCREGISTER TYcontrol;
  497. FCREGISTER TYstatus;
  498. FCREGISTER FMconfig; // Frame Manager (FC loop level)
  499. FCREGISTER FMcontrol;
  500. FCREGISTER FMstatus;
  501. FCREGISTER FMLinkStatus1;
  502. FCREGISTER FMLinkStatus2;
  503. FCREGISTER FMBB_CreditZero;
  504. FCREGISTER status;
  505. FCREGISTER ed_tov; // error detect time-out value
  506. FCREGISTER rcv_al_pa; // received arb. loop physical address
  507. FCREGISTER primitive; // e.g. LIP(), OPN(), ...
  508. } TL_REGISTERS;
  509. typedef struct
  510. {
  511. ULONG ok;
  512. ULONG invalidArgs;
  513. ULONG linkDown;
  514. ULONG linkUp;
  515. ULONG outQueFull;
  516. ULONG SESTFull;
  517. ULONG hpe; // host programming err (from Tach)
  518. ULONG FC4aborted; // aborts from Application or upper driver layer
  519. ULONG FC2aborted; // aborts from our driver's timeouts
  520. ULONG timeouts; // our driver timeout (on individual exchanges)
  521. ULONG logouts; // explicit - sent LOGO; implicit - device removed
  522. ULONG retries;
  523. ULONG linkFailTX;
  524. ULONG linkFailRX;
  525. ULONG CntErrors; // byte count expected != count received (typ. SEST)
  526. ULONG e_stores; // elastic store errs
  527. ULONG resets; // hard or soft controller resets
  528. ULONG FMinits; // TACH Frame Manager Init (e.g. LIPs)
  529. ULONG lnkQueFull; // too many LOGIN, loop commands
  530. ULONG ScsiQueFull; // too many FCP-SCSI inbound frames
  531. ULONG LossofSignal; // FM link status 1 regs
  532. ULONG BadRXChar; // FM link status 1 regs
  533. ULONG LossofSync; // FM link status 1 regs
  534. ULONG Rx_EOFa; // FM link status 2 regs (received EOFa)
  535. ULONG Dis_Frm; // FM link status 2 regs (discarded frames)
  536. ULONG Bad_CRC; // FM link status 2 regs
  537. ULONG BB0_Timer; // FM BB_Credit Zero Timer Reg
  538. ULONG loopBreaks; // infinite loop exits
  539. ULONG lastBB0timer; // static accum. buffer needed by Tachlite
  540. } FCSTATS;
  541. typedef struct // Config Options
  542. { // LS Bit first
  543. USHORT : 1; // bit0:
  544. USHORT flogi : 1; // bit1: We sent FLOGI - wait for Fabric logins
  545. USHORT fabric: 1; // bit2: Tachyon detected Fabric (FM stat LG)
  546. USHORT LILPin: 1; // bit3: We can use an FC-AL LILP frame
  547. USHORT target: 1; // bit4: this Port has SCSI target capability
  548. USHORT initiator: 1; // bit5: this Port has SCSI initiator capability
  549. USHORT extLoopback: 1; // bit6: loopback at GBIC
  550. USHORT intLoopback: 1; // bit7: loopback in HP silicon
  551. USHORT : 1; // bit8:
  552. USHORT : 1; // bit9:
  553. USHORT : 1; // bit10:
  554. USHORT : 1; // bit11:
  555. USHORT : 1; // bit12:
  556. USHORT : 1; // bit13:
  557. USHORT : 1; // bit14:
  558. USHORT : 1; // bit15:
  559. } FC_OPTIONS;
  560. typedef struct dyn_mem_pair
  561. {
  562. void *BaseAllocated; // address as allocated from O/S;
  563. unsigned long AlignedAddress; // aligned address (used by Tachyon DMA)
  564. dma_addr_t dma_handle;
  565. size_t size;
  566. } ALIGNED_MEM;
  567. // these structs contain only CRUCIAL (stuff we actually use) parameters
  568. // from FC-PH(n) logins. (Don't save entire LOGIN payload to save mem.)
  569. // Implicit logout happens when the loop goes down - we require PDISC
  570. // to restore. Explicit logout is when WE decide never to talk to someone,
  571. // or when a target refuses to talk to us, i.e. sends us a LOGO frame or
  572. // LS_RJT reject in response to our PLOGI request.
  573. #define IMPLICIT_LOGOUT 1
  574. #define EXPLICIT_LOGOUT 2
  575. typedef struct
  576. {
  577. UCHAR channel; // SCSI "bus"
  578. UCHAR target;
  579. UCHAR InqDeviceType; // byte 0 from SCSI Inquiry response
  580. UCHAR VolumeSetAddressing; // FCP-SCSI LUN coding (40h for VSA)
  581. UCHAR LunMasking; // True if selective presentation supported
  582. UCHAR lun[CPQFCTS_MAX_LUN];
  583. } SCSI_NEXUS;
  584. typedef struct
  585. {
  586. union
  587. {
  588. UCHAR ucWWN[8]; // a FC 64-bit World Wide Name/ PortID of target
  589. // addressing of single target on single loop...
  590. u64 liWWN;
  591. } u;
  592. ULONG port_id; // a FC 24-bit address of port (lower 8 bits = al_pa)
  593. #define REPORT_LUNS_PL 256
  594. UCHAR ReportLunsPayload[REPORT_LUNS_PL];
  595. SCSI_NEXUS ScsiNexus; // LUNs per FC device
  596. ULONG LOGO_counter; // might try several times before logging out for good
  597. ULONG LOGO_timer; // after LIP, ports expecting PDISC must time-out and
  598. // LOGOut if successful PDISC not completed in 2 secs
  599. ULONG concurrent_seq; // must be 1 or greater
  600. ULONG rx_data_size; // e.g. 128, 256, 1024, 2048 per FC-PH spec
  601. ULONG BB_credit;
  602. ULONG EE_credit;
  603. ULONG fcp_info; // from PRLI (i.e. INITIATOR/ TARGET flags)
  604. // flags for login process
  605. BOOLEAN Originator; // Login sequence Originated (if false, we
  606. // responded to another port's login sequence)
  607. BOOLEAN plogi; // PLOGI frame ACCepted (originated or responded)
  608. BOOLEAN pdisc; // PDISC frame was ORIGINATED (self-login logic)
  609. BOOLEAN prli; // PRLI frame ACCepted (originated or responded)
  610. BOOLEAN flogi; // FLOGI frame ACCepted (originated or responded)
  611. BOOLEAN logo; // port permanently logged out (invalid login param)
  612. BOOLEAN flogiReq; // Fabric login required (set in LIP process)
  613. UCHAR highest_ver;
  614. UCHAR lowest_ver;
  615. // when the "target" (actually FC Port) is waiting for login
  616. // (e.g. after Link reset), set the device_blocked bit;
  617. // after Port completes login, un-block target.
  618. UCHAR device_blocked; // see Scsi_Device struct
  619. // define singly-linked list of logged-in ports
  620. // once a port_id is identified, it is remembered,
  621. // even if the port is removed indefinitely
  622. PVOID pNextPort; // actually, type PFC_LOGGEDIN_PORT; void for Compiler
  623. } FC_LOGGEDIN_PORT, *PFC_LOGGEDIN_PORT;
  624. // This serves as the ESB (Exchange Status Block),
  625. // and has timeout counter; used for ABORTs
  626. typedef struct
  627. { // FC-1 X_IDs
  628. ULONG type; // ELS_PLOGI, SCSI_IWE, ... (0 if free)
  629. PFC_LOGGEDIN_PORT pLoggedInPort; // FC device on other end of Exchange
  630. Scsi_Cmnd *Cmnd; // Linux SCSI command packet includes S/G list
  631. ULONG timeOut; // units of ??, DEC by driver, Abort when 0
  632. ULONG reTries; // need one or more retries?
  633. ULONG status; // flags indicating errors (0 if none)
  634. TachLiteIRB IRB; // I/O Request Block, gets copied to ERQ
  635. TachFCHDR_GCMND fchs; // location of IRB's Req_A_SFS_Addr
  636. } FC_EXCHANGE, *PFC_EXCHANGE;
  637. // Unfortunately, Linux limits our kmalloc() allocations to 128k.
  638. // Because of this and the fact that our ScsiRegister allocation
  639. // is also constrained, we move this large structure out for
  640. // allocation after Scsi Register.
  641. // (In other words, this cumbersome indirection is necessary
  642. // because of kernel memory allocation constraints!)
  643. typedef struct // we will allocate this dynamically
  644. {
  645. FC_EXCHANGE fcExchange[ TACH_MAX_XID ];
  646. } FC_EXCHANGES;
  647. typedef struct
  648. {
  649. char Name[64]; // name of controller ("HP Tachlite TL Rev2.0, 33MHz, 64bit bus")
  650. //PVOID pAdapterDevExt; // back pointer to device object/extension
  651. ULONG ChipType; // local numeric key for Tachyon Type / Rev.
  652. ULONG status; // our Driver - logical status
  653. TL_REGISTERS Registers; // reg addresses & host memory copies
  654. // FC-4 mapping of 'transaction' to X_IDs
  655. UCHAR LILPmap[32*4]; // Loop Position Map of ALPAs (late FC-AL only)
  656. FC_OPTIONS Options; // e.g. Target, Initiator, loopback...
  657. UCHAR highest_FCPH_ver; // FC-PH version limits
  658. UCHAR lowest_FCPH_ver; // FC-PH version limits
  659. FC_EXCHANGES *Exchanges;
  660. ULONG fcLsExchangeLRU; // Least Recently Used counter (Link Service)
  661. ULONG fcSestExchangeLRU; // Least Recently Used counter (FCP-SCSI)
  662. FC_LOGGEDIN_PORT fcPorts; // linked list of every FC port ever seen
  663. FCSTATS fcStats; // FC comm err counters
  664. // Host memory QUEUE pointers
  665. TachLiteERQ *ERQ; // Exchange Request Que
  666. TachyonIMQ *IMQ; // Inbound Message Que
  667. TachLiteSFQ *SFQ; // Single Frame Queue
  668. TachSEST *SEST; // SCSI Exchange State Table
  669. dma_addr_t exch_dma_handle;
  670. // these function pointers are for "generic" functions, which are
  671. // replaced with Host Bus Adapter types at
  672. // runtime.
  673. int (*CreateTachyonQues)( void* , int);
  674. int (*DestroyTachyonQues)( void* , int);
  675. int (*LaserControl)(void*, int ); // e.g. On/Off
  676. int (*ResetTachyon)(void*, int );
  677. void (*FreezeTachyon)(void*, int );
  678. void (*UnFreezeTachyon)(void*, int );
  679. int (*InitializeTachyon)(void*, int, int );
  680. int (*InitializeFrameManager)(void*, int );
  681. int (*ProcessIMQEntry)(void*);
  682. int (*ReadWriteWWN)(void*, int ReadWrite);
  683. int (*ReadWriteNVRAM)(void*, void*, int ReadWrite);
  684. } TACHYON, *PTACHYON;
  685. void cpqfcTSClearLinkStatusCounters(TACHYON * fcChip);
  686. int CpqTsCreateTachLiteQues( void* pHBA, int opcode);
  687. int CpqTsDestroyTachLiteQues( void* , int);
  688. int CpqTsInitializeTachLite( void *pHBA, int opcode1, int opcode2);
  689. int CpqTsProcessIMQEntry(void* pHBA);
  690. int CpqTsResetTachLite(void *pHBA, int type);
  691. void CpqTsFreezeTachlite(void *pHBA, int type);
  692. void CpqTsUnFreezeTachlite(void *pHBA, int type);
  693. int CpqTsInitializeFrameManager(void *pHBA, int);
  694. int CpqTsLaserControl( void* addrBase, int opcode );
  695. int CpqTsReadWriteWWN(void*, int ReadWrite);
  696. int CpqTsReadWriteNVRAM(void*, void* data, int ReadWrite);
  697. void cpqfcTS_WorkTask( struct Scsi_Host *HostAdapter);
  698. void cpqfcTSWorkerThread( void *host);
  699. int cpqfcTS_GetNVRAM_data( UCHAR *wwnbuf, UCHAR *buf );
  700. ULONG cpqfcTS_ReadNVRAM( void* GPIOin, void* GPIOout , USHORT count,
  701. UCHAR *buf );
  702. BOOLEAN tl_write_i2c_nvram( void* GPIOin, void* GPIOout,
  703. USHORT startOffset, // e.g. 0x2f for WWN start
  704. USHORT count,
  705. UCHAR *buf );
  706. // define misc functions
  707. int cpqfcTSGetLPSM( PTACHYON fcChip, char cErrorString[]);
  708. int cpqfcTSDecodeGBICtype( PTACHYON fcChip, char cErrorString[]);
  709. void* fcMemManager( struct pci_dev *pdev,
  710. ALIGNED_MEM *dyn_mem_pair, ULONG n_alloc, ULONG ab,
  711. ULONG ulAlignedAddress, dma_addr_t *dma_handle);
  712. void BigEndianSwap( UCHAR *source, UCHAR *dest, USHORT cnt);
  713. //ULONG virt_to_phys( PVOID virtaddr );
  714. // Linux interrupt handler
  715. irqreturn_t cpqfcTS_intr_handler( int irq,void *dev_id,struct pt_regs *regs);
  716. void cpqfcTSheartbeat( unsigned long ptr );
  717. // The biggest Q element we deal with is Aborts - we
  718. // need 4 bytes for x_ID, and a Scsi_Cmnd (~284 bytes)
  719. //#define LINKQ_ITEM_SIZE ((4+sizeof(Scsi_Cmnd)+3)/4)
  720. #define LINKQ_ITEM_SIZE (3*16)
  721. typedef struct
  722. {
  723. ULONG Type; // e.g. LINKUP, SFQENTRY, PDISC, BLS_ABTS, ...
  724. ULONG ulBuff[ LINKQ_ITEM_SIZE ];
  725. } LINKQ_ITEM;
  726. #define FC_LINKQ_DEPTH TACH_MAX_XID
  727. typedef struct
  728. {
  729. ULONG producer;
  730. ULONG consumer; // when producer equals consumer, Q empty
  731. LINKQ_ITEM Qitem[ FC_LINKQ_DEPTH ];
  732. } FC_LINK_QUE, *PFC_LINK_QUE;
  733. // DPC routines post to here on Inbound SCSI frames
  734. // User thread processes
  735. #define FC_SCSIQ_DEPTH 32
  736. typedef struct
  737. {
  738. int Type; // e.g. SCSI
  739. ULONG ulBuff[ 3*16 ];
  740. } SCSIQ_ITEM;
  741. typedef struct
  742. {
  743. ULONG producer;
  744. ULONG consumer; // when producer equals consumer, Q empty
  745. SCSIQ_ITEM Qitem[ FC_SCSIQ_DEPTH ];
  746. } FC_SCSI_QUE, *PFC_SCSI_QUE;
  747. typedef struct {
  748. /* This is tacked on to a Scsi_Request in upper_private_data
  749. for pasthrough ioctls, as a place to hold data that can't
  750. be stashed anywhere else in the Scsi_Request. We differentiate
  751. this from _real_ upper_private_data by checking if the virt addr
  752. is within our special pool. */
  753. ushort bus;
  754. ushort pdrive;
  755. } cpqfc_passthru_private_t;
  756. #define CPQFC_MAX_PASSTHRU_CMDS 100
  757. #define DYNAMIC_ALLOCATIONS 4 // Tachyon aligned allocations: ERQ,IMQ,SFQ,SEST
  758. // Linux space allocated per HBA (chip state, etc.)
  759. typedef struct
  760. {
  761. struct Scsi_Host *HostAdapter; // back pointer to Linux Scsi struct
  762. TACHYON fcChip; // All Tachyon registers, Queues, functions
  763. ALIGNED_MEM dynamic_mem[DYNAMIC_ALLOCATIONS];
  764. struct pci_dev *PciDev;
  765. dma_addr_t fcLQ_dma_handle;
  766. Scsi_Cmnd *LinkDnCmnd[CPQFCTS_REQ_QUEUE_LEN]; // collects Cmnds during LDn
  767. // (for Acceptable targets)
  768. Scsi_Cmnd *BoardLockCmnd[CPQFCTS_REQ_QUEUE_LEN]; // SEST was full
  769. Scsi_Cmnd *BadTargetCmnd[CPQFCTS_MAX_TARGET_ID]; // missing targets
  770. u_char HBAnum; // 0-based host number
  771. struct timer_list cpqfcTStimer; // FC utility timer for implicit
  772. // logouts, FC protocol timeouts, etc.
  773. int fcStatsTime; // Statistics delta reporting time
  774. struct task_struct *worker_thread; // our kernel thread
  775. int PortDiscDone; // set by SendLogins(), cleared by LDn
  776. struct semaphore *TachFrozen;
  777. struct semaphore *TYOBcomplete; // handshake for Tach outbound frames
  778. struct semaphore *fcQueReady; // FibreChannel work for our kernel thread
  779. struct semaphore *notify_wt; // synchronizes kernel thread kill
  780. struct semaphore *BoardLock;
  781. PFC_LINK_QUE fcLQ; // the WorkerThread operates on this
  782. spinlock_t hba_spinlock; // held/released by WorkerThread
  783. cpqfc_passthru_private_t *private_data_pool;
  784. unsigned long *private_data_bits;
  785. } CPQFCHBA;
  786. #define CPQ_SPINLOCK_HBA( x ) spin_lock(&x->hba_spinlock);
  787. #define CPQ_SPINUNLOCK_HBA(x) spin_unlock(&x->hba_spinlock);
  788. void cpqfcTSImplicitLogout( CPQFCHBA* cpqfcHBAdata,
  789. PFC_LOGGEDIN_PORT pFcPort);
  790. void cpqfcTSTerminateExchange( CPQFCHBA*, SCSI_NEXUS *target, int );
  791. PFC_LOGGEDIN_PORT fcPortLoggedIn(
  792. CPQFCHBA *cpqfcHBAdata,
  793. TachFCHDR_GCMND* fchs,
  794. BOOLEAN,
  795. BOOLEAN);
  796. void fcProcessLoggedIn(
  797. CPQFCHBA *cpqfcHBAdata, TachFCHDR_GCMND* fchs);
  798. ULONG cpqfcTSBuildExchange(
  799. CPQFCHBA *cpqfcHBAdata,
  800. ULONG type, // e.g. PLOGI
  801. TachFCHDR_GCMND* InFCHS, // incoming FCHS
  802. void *Data, // the CDB, scatter/gather, etc.
  803. LONG *ExchangeID ); // allocated exchange ID
  804. ULONG cpqfcTSStartExchange(
  805. CPQFCHBA *cpqfcHBAdata,
  806. LONG ExchangeID );
  807. void cpqfcTSCompleteExchange(
  808. struct pci_dev *pcidev,
  809. PTACHYON fcChip,
  810. ULONG exchange_ID);
  811. PFC_LOGGEDIN_PORT fcFindLoggedInPort(
  812. PTACHYON fcChip,
  813. Scsi_Cmnd *Cmnd, // (We want the channel/target/lun Nexus from Cmnd)
  814. ULONG port_id, // search linked list for al_pa, or
  815. UCHAR wwn[8], // search linked list for WWN, or...
  816. PFC_LOGGEDIN_PORT *pLastLoggedInPort
  817. );
  818. void cpqfcTSPutLinkQue(
  819. CPQFCHBA *cpqfcHBAdata,
  820. int Type,
  821. void *QueContent);
  822. void fcPutScsiQue(
  823. CPQFCHBA *cpqfcHBAdata,
  824. int Type,
  825. void *QueContent);
  826. void fcLinkQReset(
  827. CPQFCHBA *);
  828. void fcScsiQReset(
  829. CPQFCHBA *);
  830. void fcSestReset(
  831. CPQFCHBA *);
  832. void cpqfc_pci_unmap(struct pci_dev *pcidev,
  833. Scsi_Cmnd *cmd,
  834. PTACHYON fcChip,
  835. ULONG x_ID);
  836. extern const UCHAR valid_al_pa[];
  837. extern const int number_of_al_pa;
  838. #define FCP_RESID_UNDER 0x80000
  839. #define FCP_RESID_OVER 0x40000
  840. #define FCP_SNS_LEN_VALID 0x20000
  841. #define FCP_RSP_LEN_VALID 0x10000
  842. // RSP_CODE definitions (dpANS Fibre Channel Protocol for SCSI, pg 34)
  843. #define FCP_DATA_LEN_NOT_BURST_LEN 0x1000000
  844. #define FCP_CMND_FIELD_INVALID 0x2000000
  845. #define FCP_DATA_RO_NOT_XRDY_RO 0x3000000
  846. #define FCP_TASKFUNCTION_NS 0x4000000
  847. #define FCP_TASKFUNCTION_FAIL 0x5000000
  848. // FCP-SCSI response status struct
  849. typedef struct // see "TachFCHDR_RSP" definition - 64 bytes
  850. {
  851. __u32 reserved;
  852. __u32 reserved1;
  853. __u32 fcp_status; // field validity and SCSI status
  854. __u32 fcp_resid;
  855. __u32 fcp_sns_len; // length of FCP_SNS_INFO field
  856. __u32 fcp_rsp_len; // length of FCP_RSP_INFO field (expect 8)
  857. __u32 fcp_rsp_info; // 4 bytes of FCP protocol response information
  858. __u32 fcp_rsp_info2; // (4 more bytes, since most implementations use 8)
  859. __u8 fcp_sns_info[36]; // bytes for SCSI sense (ASC, ASCQ)
  860. } FCP_STATUS_RESPONSE, *PFCP_STATUS_RESPONSE;
  861. // Fabric State Change Registration
  862. typedef struct scrpl
  863. {
  864. __u32 command;
  865. __u32 function;
  866. } SCR_PL;
  867. // Fabric Name Service Request
  868. typedef struct nsrpl
  869. {
  870. __u32 CT_Rev; // (& IN_ID) WORD 0
  871. __u32 FCS_Type; // WORD 1
  872. __u32 Command_code; // WORD 2
  873. __u32 reason_code; // WORD 3
  874. __u32 FCP; // WORD 4 (lower byte)
  875. } NSR_PL;
  876. // "FC.H"
  877. #define MAX_RX_SIZE 0x800 // Max Receive Buffer Size is 2048
  878. #define MIN_RX_SIZE 0x100 // Min Size is 256, per FC-PLDA Spec
  879. #define MAX_TARGET_RXIDS SEST_DEPTH
  880. #define TARGET_RX_SIZE SEST_BUFFER_LENGTH
  881. #define CLASS_1 0x01
  882. #define CLASS_2 0x02
  883. #define CLASS_3 0x03
  884. #define FC_PH42 0x08
  885. #define FC_PH43 0x09
  886. #define FC_PH3 0x20
  887. #define RR_TOV 2 // Minimum Time for target to wait for
  888. // PDISC after a LIP.
  889. #define E_D_TOV 2 // Minimum Time to wait for Sequence
  890. // Completion.
  891. #define R_A_TOV 0 // Minimum Time for Target to wait
  892. // before reclaiming resources.
  893. //
  894. // R_CTL Field
  895. //
  896. // Routing Bits (31-28)
  897. //
  898. #define FC4_DEVICE_DATA 0x00000000
  899. #define EXT_LINK_DATA 0x20000000
  900. #define FC4_LINK_DATA 0x30000000
  901. #define VIDEO_DATA 0x40000000
  902. #define BASIC_LINK_DATA 0x80000000
  903. #define LINK_CONTROL 0xC0000000
  904. #define ROUTING_MASK 0xF0000000
  905. //
  906. // Information Bits (27-24)
  907. //
  908. #define UNCAT_INFORMATION 0x00000000
  909. #define SOLICITED_DATA 0x01000000
  910. #define UNSOLICITED_CONTROL 0x02000000
  911. #define SOLICITED_CONTROL 0x03000000
  912. #define UNSOLICITED_DATA 0x04000000
  913. #define DATA_DESCRIPTOR 0x05000000
  914. #define UNSOLICITED_COMMAND 0x06000000
  915. #define COMMAND_STATUS 0x07000000
  916. #define INFO_MASK 0x0F000000
  917. //
  918. // (Link Control Codes)
  919. //
  920. #define ACK_1 0x00000000
  921. #define ACK_0_OR_N 0x01000000
  922. #define P_RJT 0x02000000
  923. #define F_RJT 0x03000000
  924. #define P_BSY 0x04000000
  925. #define FABRIC_BUSY_TO_DF 0x05000000 // Fabric Busy to Data Frame
  926. #define FABRIC_BUSY_TO_LC 0x06000000 // Fabric Busy to Link Ctl Frame
  927. #define LINK_CREDIT_RESET 0x07000000
  928. //
  929. // (Link Service Command Codes)
  930. //
  931. //#define LS_RJT 0x01000000 // LS Reject
  932. #define LS_ACC 0x02000000 // LS Accept
  933. #define LS_PLOGI 0x03000000 // N_PORT Login
  934. #define LS_FLOGI 0x04000000 // F_PORT Login
  935. #define LS_LOGO 0x05000000 // Logout
  936. #define LS_ABTX 0x06000000 // Abort Exchange
  937. #define LS_RCS 0x07000000 // Read Connection Status
  938. #define LS_RES 0x08000000 // Read Exchange Status
  939. #define LS_RSS 0x09000000 // Read Sequence Status
  940. #define LS_RSI 0x0A000000 // Request Seq Initiative
  941. #define LS_ESTS 0x0B000000 // Establish Steaming
  942. #define LS_ESTC 0x0C000000 // Estimate Credit
  943. #define LS_ADVC 0x0D000000 // Advice Credit
  944. #define LS_RTV 0x0E000000 // Read Timeout Value
  945. #define LS_RLS 0x0F000000 // Read Link Status
  946. #define LS_ECHO 0x10000000 // Echo
  947. #define LS_TEST 0x11000000 // Test
  948. #define LS_RRQ 0x12000000 // Reinstate Rec. Qual.
  949. #define LS_PRLI 0x20000000 // Process Login
  950. #define LS_PRLO 0x21000000 // Process Logout
  951. #define LS_TPRLO 0x24000000 // 3rd Party Process Logout
  952. #define LS_PDISC 0x50000000 // Process Discovery
  953. #define LS_FDISC 0x51000000 // Fabric Discovery
  954. #define LS_ADISC 0x52000000 // Discover Address
  955. #define LS_RNC 0x53000000 // Report Node Capability
  956. #define LS_SCR 0x62000000 // State Change Registration
  957. #define LS_MASK 0xFF000000
  958. //
  959. // TYPE Bit Masks
  960. //
  961. #define BASIC_LINK_SERVICE 0x00000000
  962. #define EXT_LINK_SERVICE 0x01000000
  963. #define LLC 0x04000000
  964. #define LLC_SNAP 0x05000000
  965. #define SCSI_FCP 0x08000000
  966. #define SCSI_GPP 0x09000000
  967. #define IPI3_MASTER 0x11000000
  968. #define IPI3_SLAVE 0x12000000
  969. #define IPI3_PEER 0x13000000
  970. #define CP_IPI3_MASTER 0x15000000
  971. #define CP_IPI3_SLAVE 0x16000000
  972. #define CP_IPI3_PEER 0x17000000
  973. #define SBCCS_CHANNEL 0x19000000
  974. #define SBCCS_CONTROL 0x1A000000
  975. #define FIBRE_SERVICES 0x20000000
  976. #define FC_FG 0x21000000
  977. #define FC_XS 0x22000000
  978. #define FC_AL 0x23000000
  979. #define SNMP 0x24000000
  980. #define HIPPI_FP 0x40000000
  981. #define TYPE_MASK 0xFF000000
  982. typedef struct {
  983. UCHAR seq_id_valid;
  984. UCHAR seq_id;
  985. USHORT reserved; // 2 bytes reserved
  986. ULONG ox_rx_id;
  987. USHORT low_seq_cnt;
  988. USHORT high_seq_cnt;
  989. } BA_ACC_PAYLOAD;
  990. typedef struct {
  991. UCHAR reserved;
  992. UCHAR reason_code;
  993. UCHAR reason_explain;
  994. UCHAR vendor_unique;
  995. } BA_RJT_PAYLOAD;
  996. typedef struct {
  997. ULONG command_code;
  998. ULONG sid;
  999. USHORT ox_id;
  1000. USHORT rx_id;
  1001. } RRQ_MESSAGE;
  1002. typedef struct {
  1003. ULONG command_code;
  1004. UCHAR vendor;
  1005. UCHAR explain;
  1006. UCHAR reason;
  1007. UCHAR reserved;
  1008. } REJECT_MESSAGE;
  1009. #define N_OR_F_PORT 0x1000
  1010. #define RANDOM_RELATIVE_OFFSET 0x4000
  1011. #define CONTINUOSLY_INCREASING 0x8000
  1012. #define CLASS_VALID 0x8000
  1013. #define INTERMIX_MODE 0x4000
  1014. #define TRANSPARENT_STACKED 0x2000
  1015. #define LOCKDOWN_STACKED 0x1000
  1016. #define SEQ_DELIVERY 0x800
  1017. #define XID_NOT_SUPPORTED 0x00
  1018. #define XID_SUPPORTED 0x4000
  1019. #define XID_REQUIRED 0xC000
  1020. #define ASSOCIATOR_NOT_SUPPORTED 0x00
  1021. #define ASSOCIATOR_SUPPORTED 0x1000
  1022. #define ASSOCIATOR_REQUIRED 0x3000
  1023. #define INIT_ACK0_SUPPORT 0x800
  1024. #define INIT_ACKN_SUPPORT 0x400
  1025. #define RECIP_ACK0_SUPPORT 0x8000
  1026. #define RECIP_ACKN_SUPPORT 0x4000
  1027. #define X_ID_INTERLOCK 0x2000
  1028. #define ERROR_POLICY 0x1800 // Error Policy Supported
  1029. #define ERROR_DISCARD 0x00 // Only Discard Supported
  1030. #define ERROR_DISC_PROCESS 0x02 // Discard and process supported
  1031. #define NODE_ID 0x01
  1032. #define IEEE_EXT 0x20
  1033. //
  1034. // Categories Supported Per Sequence
  1035. //
  1036. #define CATEGORIES_PER_SEQUENCE 0x300
  1037. #define ONE_CATEGORY_SEQUENCE 0x00 // 1 Category per Sequence
  1038. #define TWO_CATEGORY_SEQUENCE 0x01 // 2 Categories per Sequence
  1039. #define MANY_CATEGORY_SEQUENCE 0x03 // > 2 Categories/Sequence
  1040. typedef struct {
  1041. USHORT initiator_control;
  1042. USHORT service_options;
  1043. USHORT rx_data_size;
  1044. USHORT recipient_control;
  1045. USHORT ee_credit;
  1046. USHORT concurrent_sequences;
  1047. USHORT reserved;
  1048. USHORT open_sequences;
  1049. } CLASS_PARAMETERS;
  1050. typedef struct {
  1051. ULONG login_cmd;
  1052. //
  1053. // Common Service Parameters
  1054. //
  1055. struct {
  1056. USHORT bb_credit;
  1057. UCHAR lowest_ver;
  1058. UCHAR highest_ver;
  1059. USHORT bb_rx_size;
  1060. USHORT common_features;
  1061. USHORT rel_offset;
  1062. USHORT concurrent_seq;
  1063. ULONG e_d_tov;
  1064. } cmn_services;
  1065. //
  1066. // Port Name
  1067. //
  1068. UCHAR port_name[8];
  1069. //
  1070. // Node/Fabric Name
  1071. //
  1072. UCHAR node_name[8];
  1073. //
  1074. // Class 1, 2 and 3 Service Parameters
  1075. //
  1076. CLASS_PARAMETERS class1;
  1077. CLASS_PARAMETERS class2;
  1078. CLASS_PARAMETERS class3;
  1079. ULONG reserved[4];
  1080. //
  1081. // Vendor Version Level
  1082. //
  1083. UCHAR vendor_id[2];
  1084. UCHAR vendor_version[6];
  1085. ULONG buffer_size;
  1086. USHORT rxid_start;
  1087. USHORT total_rxids;
  1088. } LOGIN_PAYLOAD;
  1089. typedef struct
  1090. {
  1091. ULONG cmd; // 4 bytes
  1092. UCHAR n_port_identifier[3];
  1093. UCHAR reserved;
  1094. UCHAR port_name[8];
  1095. } LOGOUT_PAYLOAD;
  1096. //
  1097. // PRLI Request Service Parameter Defines
  1098. //
  1099. #define PRLI_ACC 0x01
  1100. #define PRLI_REQ 0x02
  1101. #define ORIG_PROCESS_ASSOC_VALID 0x8000
  1102. #define RESP_PROCESS_ASSOC_VALID 0x4000
  1103. #define ESTABLISH_PAIR 0x2000
  1104. #define DATA_OVERLAY_ALLOWED 0x40
  1105. #define INITIATOR_FUNCTION 0x20
  1106. #define TARGET_FUNCTION 0x10
  1107. #define CMD_DATA_MIXED 0x08
  1108. #define DATA_RESP_MIXED 0x04
  1109. #define READ_XFER_RDY 0x02
  1110. #define WRITE_XFER_RDY 0x01
  1111. #define RESPONSE_CODE_MASK 0xF00
  1112. #define REQUEST_EXECUTED 0x100
  1113. #define NO_RESOURCES 0x200
  1114. #define INIT_NOT_COMPLETE 0x300
  1115. #define IMAGE_DOES_NOT_EXIST 0x400
  1116. #define BAD_PREDEFINED_COND 0x500
  1117. #define REQ_EXEC_COND 0x600
  1118. #define NO_MULTI_PAGE 0x700
  1119. typedef struct {
  1120. USHORT payload_length;
  1121. UCHAR page_length;
  1122. UCHAR cmd;
  1123. ULONG valid;
  1124. ULONG orig_process_associator;
  1125. ULONG resp_process_associator;
  1126. ULONG fcp_info;
  1127. } PRLI_REQUEST;
  1128. typedef struct {
  1129. USHORT payload_length;
  1130. UCHAR page_length;
  1131. UCHAR cmd;
  1132. ULONG valid;
  1133. ULONG orig_process_associator;
  1134. ULONG resp_process_associator;
  1135. ULONG reserved;
  1136. } PRLO_REQUEST;
  1137. typedef struct {
  1138. ULONG cmd;
  1139. ULONG hard_address;
  1140. UCHAR port_name[8];
  1141. UCHAR node_name[8];
  1142. ULONG s_id;
  1143. } ADISC_PAYLOAD;
  1144. struct ext_sg_entry_t {
  1145. __u32 len:18; /* buffer length, bits 0-17 */
  1146. __u32 uba:13; /* upper bus address bits 18-31 */
  1147. __u32 lba; /* lower bus address bits 0-31 */
  1148. };
  1149. // J. McCarty's LINK.H
  1150. //
  1151. // LS_RJT Reason Codes
  1152. //
  1153. #define INVALID_COMMAND_CODE 0x01
  1154. #define LOGICAL_ERROR 0x03
  1155. #define LOGICAL_BUSY 0x05
  1156. #define PROTOCOL_ERROR 0x07
  1157. #define UNABLE_TO_PERFORM 0x09
  1158. #define COMMAND_NOT_SUPPORTED 0x0B
  1159. #define LS_VENDOR_UNIQUE 0xFF
  1160. //
  1161. // LS_RJT Reason Codes Explanations
  1162. //
  1163. #define NO_REASON 0x00
  1164. #define OPTIONS_ERROR 0x01
  1165. #define INITIATOR_CTL_ERROR 0x03
  1166. #define RECIPIENT_CTL_ERROR 0x05
  1167. #define DATA_FIELD_SIZE_ERROR 0x07
  1168. #define CONCURRENT_SEQ_ERROR 0x09
  1169. #define CREDIT_ERROR 0x0B
  1170. #define INVALID_PORT_NAME 0x0D
  1171. #define INVALID_NODE_NAME 0x0E
  1172. #define INVALID_CSP 0x0F // Invalid Service Parameters
  1173. #define INVALID_ASSOC_HDR 0x11 // Invalid Association Header
  1174. #define ASSOC_HDR_REQUIRED 0x13 // Association Header Required
  1175. #define LS_INVALID_S_ID 0x15
  1176. #define INVALID_OX_RX_ID 0x17 // Invalid OX_ID RX_ID Combination
  1177. #define CMD_IN_PROCESS 0x19
  1178. #define INVALID_IDENTIFIER 0x1F // Invalid N_PORT Identifier
  1179. #define INVALID_SEQ_ID 0x21
  1180. #define ABT_INVALID_XCHNG 0x23 // Attempt to Abort an invalid Exchange
  1181. #define ABT_INACTIVE_XCHNG 0x25 // Attempt to Abort an inactive Exchange
  1182. #define NEED_REC_QUAL 0x27 // Recovery Qualifier required
  1183. #define NO_LOGIN_RESOURCES 0x29 // No resources to support login
  1184. #define NO_DATA 0x2A // Unable to supply requested data
  1185. #define REQUEST_NOT_SUPPORTED 0x2C // Request Not Supported
  1186. //
  1187. // Link Control Codes
  1188. //
  1189. //
  1190. // P_BSY Action Codes
  1191. //
  1192. #define SEQUENCE_TERMINATED 0x01000000
  1193. #define SEQUENCE_ACTIVE 0x02000000
  1194. //
  1195. // P_BSY Reason Codes
  1196. //
  1197. #define PHYS_NPORT_BUSY 0x010000
  1198. #define NPORT_RESOURCE_BUSY 0x020000
  1199. //
  1200. // P_RJT, F_RJT Action Codes
  1201. //
  1202. #define RETRYABLE_ERROR 0x01000000
  1203. #define NON_RETRYABLE_ERROR 0x02000000
  1204. //
  1205. // P_RJT, F_RJT Reason Codes
  1206. //
  1207. #define INVALID_D_ID 0x010000
  1208. #define INVALID_S_ID 0x020000
  1209. #define NPORT_NOT_AVAIL_TMP 0x030000
  1210. #define NPORT_NOT_AVAIL_PERM 0x040000
  1211. #define CLASS_NOT_SUPPORTED 0x050000
  1212. #define USAGE_ERROR 0x060000
  1213. #define TYPE_NOT_SUPPORTED 0x070000
  1214. #define INVAL_LINK_CONTROL 0x080000
  1215. #define INVAL_R_CTL 0x090000
  1216. #define INVAL_F_CTL 0x0A0000
  1217. #define INVAL_OX_ID 0x0B0000
  1218. #define INVAL_RX_ID 0x0C0000
  1219. #define INVAL_SEQ_ID 0x0D0000
  1220. #define INVAL_DF_CTL 0x0E0000
  1221. #define INVAL_SEQ_CNT 0x0F0000
  1222. #define INVAL_PARAMS 0x100000
  1223. #define EXCHANGE_ERROR 0x110000
  1224. #define LS_PROTOCOL_ERROR 0x120000
  1225. #define INCORRECT_LENGTH 0x130000
  1226. #define UNEXPECTED_ACK 0x140000
  1227. #define LOGIN_REQ 0x160000
  1228. #define EXCESSIVE_SEQ 0x170000
  1229. #define NO_EXCHANGE 0x180000
  1230. #define SEC_HDR_NOT_SUPPORTED 0x190000
  1231. #define NO_FABRIC 0x1A0000
  1232. #define P_VENDOR_UNIQUE 0xFF0000
  1233. //
  1234. // BA_RJT Reason Codes
  1235. //
  1236. #define BA_INVALID_COMMAND 0x00010000
  1237. #define BA_LOGICAL_ERROR 0x00030000
  1238. #define BA_LOGICAL_BUSY 0x00050000
  1239. #define BA_PROTOCOL_ERROR 0x00070000
  1240. #define BA_UNABLE_TO_PERFORM 0x00090000
  1241. //
  1242. // BA_RJT Reason Explanation Codes
  1243. //
  1244. #define BA_NO_REASON 0x00000000
  1245. #define BA_INVALID_OX_RX 0x00000300
  1246. #define BA_SEQUENCE_ABORTED 0x00000500
  1247. #endif /* CPQFCTSSTRUCTS_H */