aacraid.h 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178
  1. #ifndef dprintk
  2. # define dprintk(x)
  3. #endif
  4. /* eg: if (nblank(dprintk(x))) */
  5. #define _nblank(x) #x
  6. #define nblank(x) _nblank(x)[0]
  7. #include <linux/interrupt.h>
  8. #include <linux/pci.h>
  9. /*------------------------------------------------------------------------------
  10. * D E F I N E S
  11. *----------------------------------------------------------------------------*/
  12. #define AAC_MAX_MSIX 32 /* vectors */
  13. #define AAC_PCI_MSI_ENABLE 0x8000
  14. enum {
  15. AAC_ENABLE_INTERRUPT = 0x0,
  16. AAC_DISABLE_INTERRUPT,
  17. AAC_ENABLE_MSIX,
  18. AAC_DISABLE_MSIX,
  19. AAC_CLEAR_AIF_BIT,
  20. AAC_CLEAR_SYNC_BIT,
  21. AAC_ENABLE_INTX
  22. };
  23. #define AAC_INT_MODE_INTX (1<<0)
  24. #define AAC_INT_MODE_MSI (1<<1)
  25. #define AAC_INT_MODE_AIF (1<<2)
  26. #define AAC_INT_MODE_SYNC (1<<3)
  27. #define AAC_INT_MODE_MSIX (1<<16)
  28. #define AAC_INT_ENABLE_TYPE1_INTX 0xfffffffb
  29. #define AAC_INT_ENABLE_TYPE1_MSIX 0xfffffffa
  30. #define AAC_INT_DISABLE_ALL 0xffffffff
  31. /* Bit definitions in IOA->Host Interrupt Register */
  32. #define PMC_TRANSITION_TO_OPERATIONAL (1<<31)
  33. #define PMC_IOARCB_TRANSFER_FAILED (1<<28)
  34. #define PMC_IOA_UNIT_CHECK (1<<27)
  35. #define PMC_NO_HOST_RRQ_FOR_CMD_RESPONSE (1<<26)
  36. #define PMC_CRITICAL_IOA_OP_IN_PROGRESS (1<<25)
  37. #define PMC_IOARRIN_LOST (1<<4)
  38. #define PMC_SYSTEM_BUS_MMIO_ERROR (1<<3)
  39. #define PMC_IOA_PROCESSOR_IN_ERROR_STATE (1<<2)
  40. #define PMC_HOST_RRQ_VALID (1<<1)
  41. #define PMC_OPERATIONAL_STATUS (1<<31)
  42. #define PMC_ALLOW_MSIX_VECTOR0 (1<<0)
  43. #define PMC_IOA_ERROR_INTERRUPTS (PMC_IOARCB_TRANSFER_FAILED | \
  44. PMC_IOA_UNIT_CHECK | \
  45. PMC_NO_HOST_RRQ_FOR_CMD_RESPONSE | \
  46. PMC_IOARRIN_LOST | \
  47. PMC_SYSTEM_BUS_MMIO_ERROR | \
  48. PMC_IOA_PROCESSOR_IN_ERROR_STATE)
  49. #define PMC_ALL_INTERRUPT_BITS (PMC_IOA_ERROR_INTERRUPTS | \
  50. PMC_HOST_RRQ_VALID | \
  51. PMC_TRANSITION_TO_OPERATIONAL | \
  52. PMC_ALLOW_MSIX_VECTOR0)
  53. #define PMC_GLOBAL_INT_BIT2 0x00000004
  54. #define PMC_GLOBAL_INT_BIT0 0x00000001
  55. #ifndef AAC_DRIVER_BUILD
  56. # define AAC_DRIVER_BUILD 41010
  57. # define AAC_DRIVER_BRANCH "-ms"
  58. #endif
  59. #define MAXIMUM_NUM_CONTAINERS 32
  60. #define AAC_NUM_MGT_FIB 8
  61. #define AAC_NUM_IO_FIB (1024 - AAC_NUM_MGT_FIB)
  62. #define AAC_NUM_FIB (AAC_NUM_IO_FIB + AAC_NUM_MGT_FIB)
  63. #define AAC_MAX_LUN (8)
  64. #define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff)
  65. #define AAC_MAX_32BIT_SGBCOUNT ((unsigned short)256)
  66. #define AAC_DEBUG_INSTRUMENT_AIF_DELETE
  67. /*
  68. * These macros convert from physical channels to virtual channels
  69. */
  70. #define CONTAINER_CHANNEL (0)
  71. #define CONTAINER_TO_CHANNEL(cont) (CONTAINER_CHANNEL)
  72. #define CONTAINER_TO_ID(cont) (cont)
  73. #define CONTAINER_TO_LUN(cont) (0)
  74. #define PMC_DEVICE_S6 0x28b
  75. #define PMC_DEVICE_S7 0x28c
  76. #define PMC_DEVICE_S8 0x28d
  77. #define PMC_DEVICE_S9 0x28f
  78. #define aac_phys_to_logical(x) ((x)+1)
  79. #define aac_logical_to_phys(x) ((x)?(x)-1:0)
  80. /* #define AAC_DETAILED_STATUS_INFO */
  81. struct diskparm
  82. {
  83. int heads;
  84. int sectors;
  85. int cylinders;
  86. };
  87. /*
  88. * Firmware constants
  89. */
  90. #define CT_NONE 0
  91. #define CT_OK 218
  92. #define FT_FILESYS 8 /* ADAPTEC's "FSA"(tm) filesystem */
  93. #define FT_DRIVE 9 /* physical disk - addressable in scsi by bus/id/lun */
  94. /*
  95. * Host side memory scatter gather list
  96. * Used by the adapter for read, write, and readdirplus operations
  97. * We have separate 32 and 64 bit version because even
  98. * on 64 bit systems not all cards support the 64 bit version
  99. */
  100. struct sgentry {
  101. __le32 addr; /* 32-bit address. */
  102. __le32 count; /* Length. */
  103. };
  104. struct user_sgentry {
  105. u32 addr; /* 32-bit address. */
  106. u32 count; /* Length. */
  107. };
  108. struct sgentry64 {
  109. __le32 addr[2]; /* 64-bit addr. 2 pieces for data alignment */
  110. __le32 count; /* Length. */
  111. };
  112. struct user_sgentry64 {
  113. u32 addr[2]; /* 64-bit addr. 2 pieces for data alignment */
  114. u32 count; /* Length. */
  115. };
  116. struct sgentryraw {
  117. __le32 next; /* reserved for F/W use */
  118. __le32 prev; /* reserved for F/W use */
  119. __le32 addr[2];
  120. __le32 count;
  121. __le32 flags; /* reserved for F/W use */
  122. };
  123. struct user_sgentryraw {
  124. u32 next; /* reserved for F/W use */
  125. u32 prev; /* reserved for F/W use */
  126. u32 addr[2];
  127. u32 count;
  128. u32 flags; /* reserved for F/W use */
  129. };
  130. struct sge_ieee1212 {
  131. u32 addrLow;
  132. u32 addrHigh;
  133. u32 length;
  134. u32 flags;
  135. };
  136. /*
  137. * SGMAP
  138. *
  139. * This is the SGMAP structure for all commands that use
  140. * 32-bit addressing.
  141. */
  142. struct sgmap {
  143. __le32 count;
  144. struct sgentry sg[1];
  145. };
  146. struct user_sgmap {
  147. u32 count;
  148. struct user_sgentry sg[1];
  149. };
  150. struct sgmap64 {
  151. __le32 count;
  152. struct sgentry64 sg[1];
  153. };
  154. struct user_sgmap64 {
  155. u32 count;
  156. struct user_sgentry64 sg[1];
  157. };
  158. struct sgmapraw {
  159. __le32 count;
  160. struct sgentryraw sg[1];
  161. };
  162. struct user_sgmapraw {
  163. u32 count;
  164. struct user_sgentryraw sg[1];
  165. };
  166. struct creation_info
  167. {
  168. u8 buildnum; /* e.g., 588 */
  169. u8 usec; /* e.g., 588 */
  170. u8 via; /* e.g., 1 = FSU,
  171. * 2 = API
  172. */
  173. u8 year; /* e.g., 1997 = 97 */
  174. __le32 date; /*
  175. * unsigned Month :4; // 1 - 12
  176. * unsigned Day :6; // 1 - 32
  177. * unsigned Hour :6; // 0 - 23
  178. * unsigned Minute :6; // 0 - 60
  179. * unsigned Second :6; // 0 - 60
  180. */
  181. __le32 serial[2]; /* e.g., 0x1DEADB0BFAFAF001 */
  182. };
  183. /*
  184. * Define all the constants needed for the communication interface
  185. */
  186. /*
  187. * Define how many queue entries each queue will have and the total
  188. * number of entries for the entire communication interface. Also define
  189. * how many queues we support.
  190. *
  191. * This has to match the controller
  192. */
  193. #define NUMBER_OF_COMM_QUEUES 8 // 4 command; 4 response
  194. #define HOST_HIGH_CMD_ENTRIES 4
  195. #define HOST_NORM_CMD_ENTRIES 8
  196. #define ADAP_HIGH_CMD_ENTRIES 4
  197. #define ADAP_NORM_CMD_ENTRIES 512
  198. #define HOST_HIGH_RESP_ENTRIES 4
  199. #define HOST_NORM_RESP_ENTRIES 512
  200. #define ADAP_HIGH_RESP_ENTRIES 4
  201. #define ADAP_NORM_RESP_ENTRIES 8
  202. #define TOTAL_QUEUE_ENTRIES \
  203. (HOST_NORM_CMD_ENTRIES + HOST_HIGH_CMD_ENTRIES + ADAP_NORM_CMD_ENTRIES + ADAP_HIGH_CMD_ENTRIES + \
  204. HOST_NORM_RESP_ENTRIES + HOST_HIGH_RESP_ENTRIES + ADAP_NORM_RESP_ENTRIES + ADAP_HIGH_RESP_ENTRIES)
  205. /*
  206. * Set the queues on a 16 byte alignment
  207. */
  208. #define QUEUE_ALIGNMENT 16
  209. /*
  210. * The queue headers define the Communication Region queues. These
  211. * are physically contiguous and accessible by both the adapter and the
  212. * host. Even though all queue headers are in the same contiguous block
  213. * they will be represented as individual units in the data structures.
  214. */
  215. struct aac_entry {
  216. __le32 size; /* Size in bytes of Fib which this QE points to */
  217. __le32 addr; /* Receiver address of the FIB */
  218. };
  219. /*
  220. * The adapter assumes the ProducerIndex and ConsumerIndex are grouped
  221. * adjacently and in that order.
  222. */
  223. struct aac_qhdr {
  224. __le64 header_addr;/* Address to hand the adapter to access
  225. to this queue head */
  226. __le32 *producer; /* The producer index for this queue (host address) */
  227. __le32 *consumer; /* The consumer index for this queue (host address) */
  228. };
  229. /*
  230. * Define all the events which the adapter would like to notify
  231. * the host of.
  232. */
  233. #define HostNormCmdQue 1 /* Change in host normal priority command queue */
  234. #define HostHighCmdQue 2 /* Change in host high priority command queue */
  235. #define HostNormRespQue 3 /* Change in host normal priority response queue */
  236. #define HostHighRespQue 4 /* Change in host high priority response queue */
  237. #define AdapNormRespNotFull 5
  238. #define AdapHighRespNotFull 6
  239. #define AdapNormCmdNotFull 7
  240. #define AdapHighCmdNotFull 8
  241. #define SynchCommandComplete 9
  242. #define AdapInternalError 0xfe /* The adapter detected an internal error shutting down */
  243. /*
  244. * Define all the events the host wishes to notify the
  245. * adapter of. The first four values much match the Qid the
  246. * corresponding queue.
  247. */
  248. #define AdapNormCmdQue 2
  249. #define AdapHighCmdQue 3
  250. #define AdapNormRespQue 6
  251. #define AdapHighRespQue 7
  252. #define HostShutdown 8
  253. #define HostPowerFail 9
  254. #define FatalCommError 10
  255. #define HostNormRespNotFull 11
  256. #define HostHighRespNotFull 12
  257. #define HostNormCmdNotFull 13
  258. #define HostHighCmdNotFull 14
  259. #define FastIo 15
  260. #define AdapPrintfDone 16
  261. /*
  262. * Define all the queues that the adapter and host use to communicate
  263. * Number them to match the physical queue layout.
  264. */
  265. enum aac_queue_types {
  266. HostNormCmdQueue = 0, /* Adapter to host normal priority command traffic */
  267. HostHighCmdQueue, /* Adapter to host high priority command traffic */
  268. AdapNormCmdQueue, /* Host to adapter normal priority command traffic */
  269. AdapHighCmdQueue, /* Host to adapter high priority command traffic */
  270. HostNormRespQueue, /* Adapter to host normal priority response traffic */
  271. HostHighRespQueue, /* Adapter to host high priority response traffic */
  272. AdapNormRespQueue, /* Host to adapter normal priority response traffic */
  273. AdapHighRespQueue /* Host to adapter high priority response traffic */
  274. };
  275. /*
  276. * Assign type values to the FSA communication data structures
  277. */
  278. #define FIB_MAGIC 0x0001
  279. #define FIB_MAGIC2 0x0004
  280. #define FIB_MAGIC2_64 0x0005
  281. /*
  282. * Define the priority levels the FSA communication routines support.
  283. */
  284. #define FsaNormal 1
  285. /* transport FIB header (PMC) */
  286. struct aac_fib_xporthdr {
  287. u64 HostAddress; /* FIB host address w/o xport header */
  288. u32 Size; /* FIB size excluding xport header */
  289. u32 Handle; /* driver handle to reference the FIB */
  290. u64 Reserved[2];
  291. };
  292. #define ALIGN32 32
  293. /*
  294. * Define the FIB. The FIB is the where all the requested data and
  295. * command information are put to the application on the FSA adapter.
  296. */
  297. struct aac_fibhdr {
  298. __le32 XferState; /* Current transfer state for this CCB */
  299. __le16 Command; /* Routing information for the destination */
  300. u8 StructType; /* Type FIB */
  301. u8 Unused; /* Unused */
  302. __le16 Size; /* Size of this FIB in bytes */
  303. __le16 SenderSize; /* Size of the FIB in the sender
  304. (for response sizing) */
  305. __le32 SenderFibAddress; /* Host defined data in the FIB */
  306. union {
  307. __le32 ReceiverFibAddress;/* Logical address of this FIB for
  308. the adapter (old) */
  309. __le32 SenderFibAddressHigh;/* upper 32bit of phys. FIB address */
  310. __le32 TimeStamp; /* otherwise timestamp for FW internal use */
  311. } u;
  312. u32 Handle; /* FIB handle used for MSGU commnunication */
  313. u32 Previous; /* FW internal use */
  314. u32 Next; /* FW internal use */
  315. };
  316. struct hw_fib {
  317. struct aac_fibhdr header;
  318. u8 data[512-sizeof(struct aac_fibhdr)]; // Command specific data
  319. };
  320. /*
  321. * FIB commands
  322. */
  323. #define TestCommandResponse 1
  324. #define TestAdapterCommand 2
  325. /*
  326. * Lowlevel and comm commands
  327. */
  328. #define LastTestCommand 100
  329. #define ReinitHostNormCommandQueue 101
  330. #define ReinitHostHighCommandQueue 102
  331. #define ReinitHostHighRespQueue 103
  332. #define ReinitHostNormRespQueue 104
  333. #define ReinitAdapNormCommandQueue 105
  334. #define ReinitAdapHighCommandQueue 107
  335. #define ReinitAdapHighRespQueue 108
  336. #define ReinitAdapNormRespQueue 109
  337. #define InterfaceShutdown 110
  338. #define DmaCommandFib 120
  339. #define StartProfile 121
  340. #define TermProfile 122
  341. #define SpeedTest 123
  342. #define TakeABreakPt 124
  343. #define RequestPerfData 125
  344. #define SetInterruptDefTimer 126
  345. #define SetInterruptDefCount 127
  346. #define GetInterruptDefStatus 128
  347. #define LastCommCommand 129
  348. /*
  349. * Filesystem commands
  350. */
  351. #define NuFileSystem 300
  352. #define UFS 301
  353. #define HostFileSystem 302
  354. #define LastFileSystemCommand 303
  355. /*
  356. * Container Commands
  357. */
  358. #define ContainerCommand 500
  359. #define ContainerCommand64 501
  360. #define ContainerRawIo 502
  361. #define ContainerRawIo2 503
  362. /*
  363. * Scsi Port commands (scsi passthrough)
  364. */
  365. #define ScsiPortCommand 600
  366. #define ScsiPortCommand64 601
  367. /*
  368. * Misc house keeping and generic adapter initiated commands
  369. */
  370. #define AifRequest 700
  371. #define CheckRevision 701
  372. #define FsaHostShutdown 702
  373. #define RequestAdapterInfo 703
  374. #define IsAdapterPaused 704
  375. #define SendHostTime 705
  376. #define RequestSupplementAdapterInfo 706
  377. #define LastMiscCommand 707
  378. /*
  379. * Commands that will target the failover level on the FSA adapter
  380. */
  381. enum fib_xfer_state {
  382. HostOwned = (1<<0),
  383. AdapterOwned = (1<<1),
  384. FibInitialized = (1<<2),
  385. FibEmpty = (1<<3),
  386. AllocatedFromPool = (1<<4),
  387. SentFromHost = (1<<5),
  388. SentFromAdapter = (1<<6),
  389. ResponseExpected = (1<<7),
  390. NoResponseExpected = (1<<8),
  391. AdapterProcessed = (1<<9),
  392. HostProcessed = (1<<10),
  393. HighPriority = (1<<11),
  394. NormalPriority = (1<<12),
  395. Async = (1<<13),
  396. AsyncIo = (1<<13), // rpbfix: remove with new regime
  397. PageFileIo = (1<<14), // rpbfix: remove with new regime
  398. ShutdownRequest = (1<<15),
  399. LazyWrite = (1<<16), // rpbfix: remove with new regime
  400. AdapterMicroFib = (1<<17),
  401. BIOSFibPath = (1<<18),
  402. FastResponseCapable = (1<<19),
  403. ApiFib = (1<<20), /* Its an API Fib */
  404. /* PMC NEW COMM: There is no more AIF data pending */
  405. NoMoreAifDataAvailable = (1<<21)
  406. };
  407. /*
  408. * The following defines needs to be updated any time there is an
  409. * incompatible change made to the aac_init structure.
  410. */
  411. #define ADAPTER_INIT_STRUCT_REVISION 3
  412. #define ADAPTER_INIT_STRUCT_REVISION_4 4 // rocket science
  413. #define ADAPTER_INIT_STRUCT_REVISION_6 6 /* PMC src */
  414. #define ADAPTER_INIT_STRUCT_REVISION_7 7 /* Denali */
  415. struct aac_init
  416. {
  417. __le32 InitStructRevision;
  418. __le32 Sa_MSIXVectors;
  419. __le32 fsrev;
  420. __le32 CommHeaderAddress;
  421. __le32 FastIoCommAreaAddress;
  422. __le32 AdapterFibsPhysicalAddress;
  423. __le32 AdapterFibsVirtualAddress;
  424. __le32 AdapterFibsSize;
  425. __le32 AdapterFibAlign;
  426. __le32 printfbuf;
  427. __le32 printfbufsiz;
  428. __le32 HostPhysMemPages; /* number of 4k pages of host
  429. physical memory */
  430. __le32 HostElapsedSeconds; /* number of seconds since 1970. */
  431. /*
  432. * ADAPTER_INIT_STRUCT_REVISION_4 begins here
  433. */
  434. __le32 InitFlags; /* flags for supported features */
  435. #define INITFLAGS_NEW_COMM_SUPPORTED 0x00000001
  436. #define INITFLAGS_DRIVER_USES_UTC_TIME 0x00000010
  437. #define INITFLAGS_DRIVER_SUPPORTS_PM 0x00000020
  438. #define INITFLAGS_NEW_COMM_TYPE1_SUPPORTED 0x00000040
  439. #define INITFLAGS_FAST_JBOD_SUPPORTED 0x00000080
  440. #define INITFLAGS_NEW_COMM_TYPE2_SUPPORTED 0x00000100
  441. __le32 MaxIoCommands; /* max outstanding commands */
  442. __le32 MaxIoSize; /* largest I/O command */
  443. __le32 MaxFibSize; /* largest FIB to adapter */
  444. /* ADAPTER_INIT_STRUCT_REVISION_5 begins here */
  445. __le32 MaxNumAif; /* max number of aif */
  446. /* ADAPTER_INIT_STRUCT_REVISION_6 begins here */
  447. __le32 HostRRQ_AddrLow;
  448. __le32 HostRRQ_AddrHigh; /* Host RRQ (response queue) for SRC */
  449. };
  450. enum aac_log_level {
  451. LOG_AAC_INIT = 10,
  452. LOG_AAC_INFORMATIONAL = 20,
  453. LOG_AAC_WARNING = 30,
  454. LOG_AAC_LOW_ERROR = 40,
  455. LOG_AAC_MEDIUM_ERROR = 50,
  456. LOG_AAC_HIGH_ERROR = 60,
  457. LOG_AAC_PANIC = 70,
  458. LOG_AAC_DEBUG = 80,
  459. LOG_AAC_WINDBG_PRINT = 90
  460. };
  461. #define FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT 0x030b
  462. #define FSAFS_NTC_FIB_CONTEXT 0x030c
  463. struct aac_dev;
  464. struct fib;
  465. struct scsi_cmnd;
  466. struct adapter_ops
  467. {
  468. /* Low level operations */
  469. void (*adapter_interrupt)(struct aac_dev *dev);
  470. void (*adapter_notify)(struct aac_dev *dev, u32 event);
  471. void (*adapter_disable_int)(struct aac_dev *dev);
  472. void (*adapter_enable_int)(struct aac_dev *dev);
  473. int (*adapter_sync_cmd)(struct aac_dev *dev, u32 command, u32 p1, u32 p2, u32 p3, u32 p4, u32 p5, u32 p6, u32 *status, u32 *r1, u32 *r2, u32 *r3, u32 *r4);
  474. int (*adapter_check_health)(struct aac_dev *dev);
  475. int (*adapter_restart)(struct aac_dev *dev, int bled);
  476. void (*adapter_start)(struct aac_dev *dev);
  477. /* Transport operations */
  478. int (*adapter_ioremap)(struct aac_dev * dev, u32 size);
  479. irq_handler_t adapter_intr;
  480. /* Packet operations */
  481. int (*adapter_deliver)(struct fib * fib);
  482. int (*adapter_bounds)(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba);
  483. int (*adapter_read)(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count);
  484. int (*adapter_write)(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count, int fua);
  485. int (*adapter_scsi)(struct fib * fib, struct scsi_cmnd * cmd);
  486. /* Administrative operations */
  487. int (*adapter_comm)(struct aac_dev * dev, int comm);
  488. };
  489. /*
  490. * Define which interrupt handler needs to be installed
  491. */
  492. struct aac_driver_ident
  493. {
  494. int (*init)(struct aac_dev *dev);
  495. char * name;
  496. char * vname;
  497. char * model;
  498. u16 channels;
  499. int quirks;
  500. };
  501. /*
  502. * Some adapter firmware needs communication memory
  503. * below 2gig. This tells the init function to set the
  504. * dma mask such that fib memory will be allocated where the
  505. * adapter firmware can get to it.
  506. */
  507. #define AAC_QUIRK_31BIT 0x0001
  508. /*
  509. * Some adapter firmware, when the raid card's cache is turned off, can not
  510. * split up scatter gathers in order to deal with the limits of the
  511. * underlying CHIM. This limit is 34 scatter gather elements.
  512. */
  513. #define AAC_QUIRK_34SG 0x0002
  514. /*
  515. * This adapter is a slave (no Firmware)
  516. */
  517. #define AAC_QUIRK_SLAVE 0x0004
  518. /*
  519. * This adapter is a master.
  520. */
  521. #define AAC_QUIRK_MASTER 0x0008
  522. /*
  523. * Some adapter firmware perform poorly when it must split up scatter gathers
  524. * in order to deal with the limits of the underlying CHIM. This limit in this
  525. * class of adapters is 17 scatter gather elements.
  526. */
  527. #define AAC_QUIRK_17SG 0x0010
  528. /*
  529. * Some adapter firmware does not support 64 bit scsi passthrough
  530. * commands.
  531. */
  532. #define AAC_QUIRK_SCSI_32 0x0020
  533. /*
  534. * The adapter interface specs all queues to be located in the same
  535. * physically contiguous block. The host structure that defines the
  536. * commuication queues will assume they are each a separate physically
  537. * contiguous memory region that will support them all being one big
  538. * contiguous block.
  539. * There is a command and response queue for each level and direction of
  540. * commuication. These regions are accessed by both the host and adapter.
  541. */
  542. struct aac_queue {
  543. u64 logical; /*address we give the adapter */
  544. struct aac_entry *base; /*system virtual address */
  545. struct aac_qhdr headers; /*producer,consumer q headers*/
  546. u32 entries; /*Number of queue entries */
  547. wait_queue_head_t qfull; /*Event to wait on if q full */
  548. wait_queue_head_t cmdready; /*Cmd ready from the adapter */
  549. /* This is only valid for adapter to host command queues. */
  550. spinlock_t *lock; /* Spinlock for this queue must take this lock before accessing the lock */
  551. spinlock_t lockdata; /* Actual lock (used only on one side of the lock) */
  552. struct list_head cmdq; /* A queue of FIBs which need to be prcessed by the FS thread. This is */
  553. /* only valid for command queues which receive entries from the adapter. */
  554. /* Number of entries on outstanding queue. */
  555. atomic_t numpending;
  556. struct aac_dev * dev; /* Back pointer to adapter structure */
  557. };
  558. /*
  559. * Message queues. The order here is important, see also the
  560. * queue type ordering
  561. */
  562. struct aac_queue_block
  563. {
  564. struct aac_queue queue[8];
  565. };
  566. /*
  567. * SaP1 Message Unit Registers
  568. */
  569. struct sa_drawbridge_CSR {
  570. /* Offset | Name */
  571. __le32 reserved[10]; /* 00h-27h | Reserved */
  572. u8 LUT_Offset; /* 28h | Lookup Table Offset */
  573. u8 reserved1[3]; /* 29h-2bh | Reserved */
  574. __le32 LUT_Data; /* 2ch | Looup Table Data */
  575. __le32 reserved2[26]; /* 30h-97h | Reserved */
  576. __le16 PRICLEARIRQ; /* 98h | Primary Clear Irq */
  577. __le16 SECCLEARIRQ; /* 9ah | Secondary Clear Irq */
  578. __le16 PRISETIRQ; /* 9ch | Primary Set Irq */
  579. __le16 SECSETIRQ; /* 9eh | Secondary Set Irq */
  580. __le16 PRICLEARIRQMASK;/* a0h | Primary Clear Irq Mask */
  581. __le16 SECCLEARIRQMASK;/* a2h | Secondary Clear Irq Mask */
  582. __le16 PRISETIRQMASK; /* a4h | Primary Set Irq Mask */
  583. __le16 SECSETIRQMASK; /* a6h | Secondary Set Irq Mask */
  584. __le32 MAILBOX0; /* a8h | Scratchpad 0 */
  585. __le32 MAILBOX1; /* ach | Scratchpad 1 */
  586. __le32 MAILBOX2; /* b0h | Scratchpad 2 */
  587. __le32 MAILBOX3; /* b4h | Scratchpad 3 */
  588. __le32 MAILBOX4; /* b8h | Scratchpad 4 */
  589. __le32 MAILBOX5; /* bch | Scratchpad 5 */
  590. __le32 MAILBOX6; /* c0h | Scratchpad 6 */
  591. __le32 MAILBOX7; /* c4h | Scratchpad 7 */
  592. __le32 ROM_Setup_Data; /* c8h | Rom Setup and Data */
  593. __le32 ROM_Control_Addr;/* cch | Rom Control and Address */
  594. __le32 reserved3[12]; /* d0h-ffh | reserved */
  595. __le32 LUT[64]; /* 100h-1ffh | Lookup Table Entries */
  596. };
  597. #define Mailbox0 SaDbCSR.MAILBOX0
  598. #define Mailbox1 SaDbCSR.MAILBOX1
  599. #define Mailbox2 SaDbCSR.MAILBOX2
  600. #define Mailbox3 SaDbCSR.MAILBOX3
  601. #define Mailbox4 SaDbCSR.MAILBOX4
  602. #define Mailbox5 SaDbCSR.MAILBOX5
  603. #define Mailbox6 SaDbCSR.MAILBOX6
  604. #define Mailbox7 SaDbCSR.MAILBOX7
  605. #define DoorbellReg_p SaDbCSR.PRISETIRQ
  606. #define DoorbellReg_s SaDbCSR.SECSETIRQ
  607. #define DoorbellClrReg_p SaDbCSR.PRICLEARIRQ
  608. #define DOORBELL_0 0x0001
  609. #define DOORBELL_1 0x0002
  610. #define DOORBELL_2 0x0004
  611. #define DOORBELL_3 0x0008
  612. #define DOORBELL_4 0x0010
  613. #define DOORBELL_5 0x0020
  614. #define DOORBELL_6 0x0040
  615. #define PrintfReady DOORBELL_5
  616. #define PrintfDone DOORBELL_5
  617. struct sa_registers {
  618. struct sa_drawbridge_CSR SaDbCSR; /* 98h - c4h */
  619. };
  620. #define Sa_MINIPORT_REVISION 1
  621. #define sa_readw(AEP, CSR) readl(&((AEP)->regs.sa->CSR))
  622. #define sa_readl(AEP, CSR) readl(&((AEP)->regs.sa->CSR))
  623. #define sa_writew(AEP, CSR, value) writew(value, &((AEP)->regs.sa->CSR))
  624. #define sa_writel(AEP, CSR, value) writel(value, &((AEP)->regs.sa->CSR))
  625. /*
  626. * Rx Message Unit Registers
  627. */
  628. struct rx_mu_registers {
  629. /* Local | PCI*| Name */
  630. __le32 ARSR; /* 1300h | 00h | APIC Register Select Register */
  631. __le32 reserved0; /* 1304h | 04h | Reserved */
  632. __le32 AWR; /* 1308h | 08h | APIC Window Register */
  633. __le32 reserved1; /* 130Ch | 0Ch | Reserved */
  634. __le32 IMRx[2]; /* 1310h | 10h | Inbound Message Registers */
  635. __le32 OMRx[2]; /* 1318h | 18h | Outbound Message Registers */
  636. __le32 IDR; /* 1320h | 20h | Inbound Doorbell Register */
  637. __le32 IISR; /* 1324h | 24h | Inbound Interrupt
  638. Status Register */
  639. __le32 IIMR; /* 1328h | 28h | Inbound Interrupt
  640. Mask Register */
  641. __le32 ODR; /* 132Ch | 2Ch | Outbound Doorbell Register */
  642. __le32 OISR; /* 1330h | 30h | Outbound Interrupt
  643. Status Register */
  644. __le32 OIMR; /* 1334h | 34h | Outbound Interrupt
  645. Mask Register */
  646. __le32 reserved2; /* 1338h | 38h | Reserved */
  647. __le32 reserved3; /* 133Ch | 3Ch | Reserved */
  648. __le32 InboundQueue;/* 1340h | 40h | Inbound Queue Port relative to firmware */
  649. __le32 OutboundQueue;/*1344h | 44h | Outbound Queue Port relative to firmware */
  650. /* * Must access through ATU Inbound
  651. Translation Window */
  652. };
  653. struct rx_inbound {
  654. __le32 Mailbox[8];
  655. };
  656. #define INBOUNDDOORBELL_0 0x00000001
  657. #define INBOUNDDOORBELL_1 0x00000002
  658. #define INBOUNDDOORBELL_2 0x00000004
  659. #define INBOUNDDOORBELL_3 0x00000008
  660. #define INBOUNDDOORBELL_4 0x00000010
  661. #define INBOUNDDOORBELL_5 0x00000020
  662. #define INBOUNDDOORBELL_6 0x00000040
  663. #define OUTBOUNDDOORBELL_0 0x00000001
  664. #define OUTBOUNDDOORBELL_1 0x00000002
  665. #define OUTBOUNDDOORBELL_2 0x00000004
  666. #define OUTBOUNDDOORBELL_3 0x00000008
  667. #define OUTBOUNDDOORBELL_4 0x00000010
  668. #define InboundDoorbellReg MUnit.IDR
  669. #define OutboundDoorbellReg MUnit.ODR
  670. struct rx_registers {
  671. struct rx_mu_registers MUnit; /* 1300h - 1347h */
  672. __le32 reserved1[2]; /* 1348h - 134ch */
  673. struct rx_inbound IndexRegs;
  674. };
  675. #define rx_readb(AEP, CSR) readb(&((AEP)->regs.rx->CSR))
  676. #define rx_readl(AEP, CSR) readl(&((AEP)->regs.rx->CSR))
  677. #define rx_writeb(AEP, CSR, value) writeb(value, &((AEP)->regs.rx->CSR))
  678. #define rx_writel(AEP, CSR, value) writel(value, &((AEP)->regs.rx->CSR))
  679. /*
  680. * Rkt Message Unit Registers (same as Rx, except a larger reserve region)
  681. */
  682. #define rkt_mu_registers rx_mu_registers
  683. #define rkt_inbound rx_inbound
  684. struct rkt_registers {
  685. struct rkt_mu_registers MUnit; /* 1300h - 1347h */
  686. __le32 reserved1[1006]; /* 1348h - 22fch */
  687. struct rkt_inbound IndexRegs; /* 2300h - */
  688. };
  689. #define rkt_readb(AEP, CSR) readb(&((AEP)->regs.rkt->CSR))
  690. #define rkt_readl(AEP, CSR) readl(&((AEP)->regs.rkt->CSR))
  691. #define rkt_writeb(AEP, CSR, value) writeb(value, &((AEP)->regs.rkt->CSR))
  692. #define rkt_writel(AEP, CSR, value) writel(value, &((AEP)->regs.rkt->CSR))
  693. /*
  694. * PMC SRC message unit registers
  695. */
  696. #define src_inbound rx_inbound
  697. struct src_mu_registers {
  698. /* PCI*| Name */
  699. __le32 reserved0[6]; /* 00h | Reserved */
  700. __le32 IOAR[2]; /* 18h | IOA->host interrupt register */
  701. __le32 IDR; /* 20h | Inbound Doorbell Register */
  702. __le32 IISR; /* 24h | Inbound Int. Status Register */
  703. __le32 reserved1[3]; /* 28h | Reserved */
  704. __le32 OIMR; /* 34h | Outbound Int. Mask Register */
  705. __le32 reserved2[25]; /* 38h | Reserved */
  706. __le32 ODR_R; /* 9ch | Outbound Doorbell Read */
  707. __le32 ODR_C; /* a0h | Outbound Doorbell Clear */
  708. __le32 reserved3[6]; /* a4h | Reserved */
  709. __le32 OMR; /* bch | Outbound Message Register */
  710. __le32 IQ_L; /* c0h | Inbound Queue (Low address) */
  711. __le32 IQ_H; /* c4h | Inbound Queue (High address) */
  712. __le32 ODR_MSI; /* c8h | MSI register for sync./AIF */
  713. };
  714. struct src_registers {
  715. struct src_mu_registers MUnit; /* 00h - cbh */
  716. union {
  717. struct {
  718. __le32 reserved1[130789]; /* cch - 7fc5fh */
  719. struct src_inbound IndexRegs; /* 7fc60h */
  720. } tupelo;
  721. struct {
  722. __le32 reserved1[973]; /* cch - fffh */
  723. struct src_inbound IndexRegs; /* 1000h */
  724. } denali;
  725. } u;
  726. };
  727. #define src_readb(AEP, CSR) readb(&((AEP)->regs.src.bar0->CSR))
  728. #define src_readl(AEP, CSR) readl(&((AEP)->regs.src.bar0->CSR))
  729. #define src_writeb(AEP, CSR, value) writeb(value, \
  730. &((AEP)->regs.src.bar0->CSR))
  731. #define src_writel(AEP, CSR, value) writel(value, \
  732. &((AEP)->regs.src.bar0->CSR))
  733. #if defined(writeq)
  734. #define src_writeq(AEP, CSR, value) writeq(value, \
  735. &((AEP)->regs.src.bar0->CSR))
  736. #endif
  737. #define SRC_ODR_SHIFT 12
  738. #define SRC_IDR_SHIFT 9
  739. typedef void (*fib_callback)(void *ctxt, struct fib *fibctx);
  740. struct aac_fib_context {
  741. s16 type; // used for verification of structure
  742. s16 size;
  743. u32 unique; // unique value representing this context
  744. ulong jiffies; // used for cleanup - dmb changed to ulong
  745. struct list_head next; // used to link context's into a linked list
  746. struct semaphore wait_sem; // this is used to wait for the next fib to arrive.
  747. int wait; // Set to true when thread is in WaitForSingleObject
  748. unsigned long count; // total number of FIBs on FibList
  749. struct list_head fib_list; // this holds fibs and their attachd hw_fibs
  750. };
  751. struct sense_data {
  752. u8 error_code; /* 70h (current errors), 71h(deferred errors) */
  753. u8 valid:1; /* A valid bit of one indicates that the information */
  754. /* field contains valid information as defined in the
  755. * SCSI-2 Standard.
  756. */
  757. u8 segment_number; /* Only used for COPY, COMPARE, or COPY AND VERIFY Commands */
  758. u8 sense_key:4; /* Sense Key */
  759. u8 reserved:1;
  760. u8 ILI:1; /* Incorrect Length Indicator */
  761. u8 EOM:1; /* End Of Medium - reserved for random access devices */
  762. u8 filemark:1; /* Filemark - reserved for random access devices */
  763. u8 information[4]; /* for direct-access devices, contains the unsigned
  764. * logical block address or residue associated with
  765. * the sense key
  766. */
  767. u8 add_sense_len; /* number of additional sense bytes to follow this field */
  768. u8 cmnd_info[4]; /* not used */
  769. u8 ASC; /* Additional Sense Code */
  770. u8 ASCQ; /* Additional Sense Code Qualifier */
  771. u8 FRUC; /* Field Replaceable Unit Code - not used */
  772. u8 bit_ptr:3; /* indicates which byte of the CDB or parameter data
  773. * was in error
  774. */
  775. u8 BPV:1; /* bit pointer valid (BPV): 1- indicates that
  776. * the bit_ptr field has valid value
  777. */
  778. u8 reserved2:2;
  779. u8 CD:1; /* command data bit: 1- illegal parameter in CDB.
  780. * 0- illegal parameter in data.
  781. */
  782. u8 SKSV:1;
  783. u8 field_ptr[2]; /* byte of the CDB or parameter data in error */
  784. };
  785. struct fsa_dev_info {
  786. u64 last;
  787. u64 size;
  788. u32 type;
  789. u32 config_waiting_on;
  790. unsigned long config_waiting_stamp;
  791. u16 queue_depth;
  792. u8 config_needed;
  793. u8 valid;
  794. u8 ro;
  795. u8 locked;
  796. u8 deleted;
  797. char devname[8];
  798. struct sense_data sense_data;
  799. u32 block_size;
  800. };
  801. struct fib {
  802. void *next; /* this is used by the allocator */
  803. s16 type;
  804. s16 size;
  805. /*
  806. * The Adapter that this I/O is destined for.
  807. */
  808. struct aac_dev *dev;
  809. /*
  810. * This is the event the sendfib routine will wait on if the
  811. * caller did not pass one and this is synch io.
  812. */
  813. struct semaphore event_wait;
  814. spinlock_t event_lock;
  815. u32 done; /* gets set to 1 when fib is complete */
  816. fib_callback callback;
  817. void *callback_data;
  818. u32 flags; // u32 dmb was ulong
  819. /*
  820. * And for the internal issue/reply queues (we may be able
  821. * to merge these two)
  822. */
  823. struct list_head fiblink;
  824. void *data;
  825. u32 vector_no;
  826. struct hw_fib *hw_fib_va; /* Actual shared object */
  827. dma_addr_t hw_fib_pa; /* physical address of hw_fib*/
  828. };
  829. /*
  830. * Adapter Information Block
  831. *
  832. * This is returned by the RequestAdapterInfo block
  833. */
  834. struct aac_adapter_info
  835. {
  836. __le32 platform;
  837. __le32 cpu;
  838. __le32 subcpu;
  839. __le32 clock;
  840. __le32 execmem;
  841. __le32 buffermem;
  842. __le32 totalmem;
  843. __le32 kernelrev;
  844. __le32 kernelbuild;
  845. __le32 monitorrev;
  846. __le32 monitorbuild;
  847. __le32 hwrev;
  848. __le32 hwbuild;
  849. __le32 biosrev;
  850. __le32 biosbuild;
  851. __le32 cluster;
  852. __le32 clusterchannelmask;
  853. __le32 serial[2];
  854. __le32 battery;
  855. __le32 options;
  856. __le32 OEM;
  857. };
  858. struct aac_supplement_adapter_info
  859. {
  860. u8 AdapterTypeText[17+1];
  861. u8 Pad[2];
  862. __le32 FlashMemoryByteSize;
  863. __le32 FlashImageId;
  864. __le32 MaxNumberPorts;
  865. __le32 Version;
  866. __le32 FeatureBits;
  867. u8 SlotNumber;
  868. u8 ReservedPad0[3];
  869. u8 BuildDate[12];
  870. __le32 CurrentNumberPorts;
  871. struct {
  872. u8 AssemblyPn[8];
  873. u8 FruPn[8];
  874. u8 BatteryFruPn[8];
  875. u8 EcVersionString[8];
  876. u8 Tsid[12];
  877. } VpdInfo;
  878. __le32 FlashFirmwareRevision;
  879. __le32 FlashFirmwareBuild;
  880. __le32 RaidTypeMorphOptions;
  881. __le32 FlashFirmwareBootRevision;
  882. __le32 FlashFirmwareBootBuild;
  883. u8 MfgPcbaSerialNo[12];
  884. u8 MfgWWNName[8];
  885. __le32 SupportedOptions2;
  886. __le32 StructExpansion;
  887. /* StructExpansion == 1 */
  888. __le32 FeatureBits3;
  889. __le32 SupportedPerformanceModes;
  890. __le32 ReservedForFutureGrowth[80];
  891. };
  892. #define AAC_FEATURE_FALCON cpu_to_le32(0x00000010)
  893. #define AAC_FEATURE_JBOD cpu_to_le32(0x08000000)
  894. /* SupportedOptions2 */
  895. #define AAC_OPTION_MU_RESET cpu_to_le32(0x00000001)
  896. #define AAC_OPTION_IGNORE_RESET cpu_to_le32(0x00000002)
  897. #define AAC_OPTION_POWER_MANAGEMENT cpu_to_le32(0x00000004)
  898. #define AAC_OPTION_DOORBELL_RESET cpu_to_le32(0x00004000)
  899. /* 4KB sector size */
  900. #define AAC_OPTION_VARIABLE_BLOCK_SIZE cpu_to_le32(0x00040000)
  901. /* 240 simple volume support */
  902. #define AAC_OPTION_SUPPORTED_240_VOLUMES cpu_to_le32(0x10000000)
  903. #define AAC_SIS_VERSION_V3 3
  904. #define AAC_SIS_SLOT_UNKNOWN 0xFF
  905. #define GetBusInfo 0x00000009
  906. struct aac_bus_info {
  907. __le32 Command; /* VM_Ioctl */
  908. __le32 ObjType; /* FT_DRIVE */
  909. __le32 MethodId; /* 1 = SCSI Layer */
  910. __le32 ObjectId; /* Handle */
  911. __le32 CtlCmd; /* GetBusInfo */
  912. };
  913. struct aac_bus_info_response {
  914. __le32 Status; /* ST_OK */
  915. __le32 ObjType;
  916. __le32 MethodId; /* unused */
  917. __le32 ObjectId; /* unused */
  918. __le32 CtlCmd; /* unused */
  919. __le32 ProbeComplete;
  920. __le32 BusCount;
  921. __le32 TargetsPerBus;
  922. u8 InitiatorBusId[10];
  923. u8 BusValid[10];
  924. };
  925. /*
  926. * Battery platforms
  927. */
  928. #define AAC_BAT_REQ_PRESENT (1)
  929. #define AAC_BAT_REQ_NOTPRESENT (2)
  930. #define AAC_BAT_OPT_PRESENT (3)
  931. #define AAC_BAT_OPT_NOTPRESENT (4)
  932. #define AAC_BAT_NOT_SUPPORTED (5)
  933. /*
  934. * cpu types
  935. */
  936. #define AAC_CPU_SIMULATOR (1)
  937. #define AAC_CPU_I960 (2)
  938. #define AAC_CPU_STRONGARM (3)
  939. /*
  940. * Supported Options
  941. */
  942. #define AAC_OPT_SNAPSHOT cpu_to_le32(1)
  943. #define AAC_OPT_CLUSTERS cpu_to_le32(1<<1)
  944. #define AAC_OPT_WRITE_CACHE cpu_to_le32(1<<2)
  945. #define AAC_OPT_64BIT_DATA cpu_to_le32(1<<3)
  946. #define AAC_OPT_HOST_TIME_FIB cpu_to_le32(1<<4)
  947. #define AAC_OPT_RAID50 cpu_to_le32(1<<5)
  948. #define AAC_OPT_4GB_WINDOW cpu_to_le32(1<<6)
  949. #define AAC_OPT_SCSI_UPGRADEABLE cpu_to_le32(1<<7)
  950. #define AAC_OPT_SOFT_ERR_REPORT cpu_to_le32(1<<8)
  951. #define AAC_OPT_SUPPORTED_RECONDITION cpu_to_le32(1<<9)
  952. #define AAC_OPT_SGMAP_HOST64 cpu_to_le32(1<<10)
  953. #define AAC_OPT_ALARM cpu_to_le32(1<<11)
  954. #define AAC_OPT_NONDASD cpu_to_le32(1<<12)
  955. #define AAC_OPT_SCSI_MANAGED cpu_to_le32(1<<13)
  956. #define AAC_OPT_RAID_SCSI_MODE cpu_to_le32(1<<14)
  957. #define AAC_OPT_SUPPLEMENT_ADAPTER_INFO cpu_to_le32(1<<16)
  958. #define AAC_OPT_NEW_COMM cpu_to_le32(1<<17)
  959. #define AAC_OPT_NEW_COMM_64 cpu_to_le32(1<<18)
  960. #define AAC_OPT_NEW_COMM_TYPE1 cpu_to_le32(1<<28)
  961. #define AAC_OPT_NEW_COMM_TYPE2 cpu_to_le32(1<<29)
  962. #define AAC_OPT_NEW_COMM_TYPE3 cpu_to_le32(1<<30)
  963. #define AAC_OPT_NEW_COMM_TYPE4 cpu_to_le32(1<<31)
  964. /* MSIX context */
  965. struct aac_msix_ctx {
  966. int vector_no;
  967. struct aac_dev *dev;
  968. };
  969. struct aac_dev
  970. {
  971. struct list_head entry;
  972. const char *name;
  973. int id;
  974. /*
  975. * negotiated FIB settings
  976. */
  977. unsigned max_fib_size;
  978. unsigned sg_tablesize;
  979. unsigned max_num_aif;
  980. /*
  981. * Map for 128 fib objects (64k)
  982. */
  983. dma_addr_t hw_fib_pa;
  984. struct hw_fib *hw_fib_va;
  985. struct hw_fib *aif_base_va;
  986. /*
  987. * Fib Headers
  988. */
  989. struct fib *fibs;
  990. struct fib *free_fib;
  991. spinlock_t fib_lock;
  992. struct aac_queue_block *queues;
  993. /*
  994. * The user API will use an IOCTL to register itself to receive
  995. * FIBs from the adapter. The following list is used to keep
  996. * track of all the threads that have requested these FIBs. The
  997. * mutex is used to synchronize access to all data associated
  998. * with the adapter fibs.
  999. */
  1000. struct list_head fib_list;
  1001. struct adapter_ops a_ops;
  1002. unsigned long fsrev; /* Main driver's revision number */
  1003. resource_size_t base_start; /* main IO base */
  1004. resource_size_t dbg_base; /* address of UART
  1005. * debug buffer */
  1006. resource_size_t base_size, dbg_size; /* Size of
  1007. * mapped in region */
  1008. struct aac_init *init; /* Holds initialization info to communicate with adapter */
  1009. dma_addr_t init_pa; /* Holds physical address of the init struct */
  1010. u32 *host_rrq; /* response queue
  1011. * if AAC_COMM_MESSAGE_TYPE1 */
  1012. dma_addr_t host_rrq_pa; /* phys. address */
  1013. /* index into rrq buffer */
  1014. u32 host_rrq_idx[AAC_MAX_MSIX];
  1015. atomic_t rrq_outstanding[AAC_MAX_MSIX];
  1016. u32 fibs_pushed_no;
  1017. struct pci_dev *pdev; /* Our PCI interface */
  1018. void * printfbuf; /* pointer to buffer used for printf's from the adapter */
  1019. void * comm_addr; /* Base address of Comm area */
  1020. dma_addr_t comm_phys; /* Physical Address of Comm area */
  1021. size_t comm_size;
  1022. struct Scsi_Host *scsi_host_ptr;
  1023. int maximum_num_containers;
  1024. int maximum_num_physicals;
  1025. int maximum_num_channels;
  1026. struct fsa_dev_info *fsa_dev;
  1027. struct task_struct *thread;
  1028. int cardtype;
  1029. /*
  1030. *This lock will protect the two 32-bit
  1031. *writes to the Inbound Queue
  1032. */
  1033. spinlock_t iq_lock;
  1034. /*
  1035. * The following is the device specific extension.
  1036. */
  1037. #ifndef AAC_MIN_FOOTPRINT_SIZE
  1038. # define AAC_MIN_FOOTPRINT_SIZE 8192
  1039. # define AAC_MIN_SRC_BAR0_SIZE 0x400000
  1040. # define AAC_MIN_SRC_BAR1_SIZE 0x800
  1041. # define AAC_MIN_SRCV_BAR0_SIZE 0x100000
  1042. # define AAC_MIN_SRCV_BAR1_SIZE 0x400
  1043. #endif
  1044. union
  1045. {
  1046. struct sa_registers __iomem *sa;
  1047. struct rx_registers __iomem *rx;
  1048. struct rkt_registers __iomem *rkt;
  1049. struct {
  1050. struct src_registers __iomem *bar0;
  1051. char __iomem *bar1;
  1052. } src;
  1053. } regs;
  1054. volatile void __iomem *base, *dbg_base_mapped;
  1055. volatile struct rx_inbound __iomem *IndexRegs;
  1056. u32 OIMR; /* Mask Register Cache */
  1057. /*
  1058. * AIF thread states
  1059. */
  1060. u32 aif_thread;
  1061. struct aac_adapter_info adapter_info;
  1062. struct aac_supplement_adapter_info supplement_adapter_info;
  1063. /* These are in adapter info but they are in the io flow so
  1064. * lets break them out so we don't have to do an AND to check them
  1065. */
  1066. u8 nondasd_support;
  1067. u8 jbod;
  1068. u8 cache_protected;
  1069. u8 dac_support;
  1070. u8 needs_dac;
  1071. u8 raid_scsi_mode;
  1072. u8 comm_interface;
  1073. # define AAC_COMM_PRODUCER 0
  1074. # define AAC_COMM_MESSAGE 1
  1075. # define AAC_COMM_MESSAGE_TYPE1 3
  1076. # define AAC_COMM_MESSAGE_TYPE2 4
  1077. u8 raw_io_interface;
  1078. u8 raw_io_64;
  1079. u8 printf_enabled;
  1080. u8 in_reset;
  1081. u8 msi;
  1082. int management_fib_count;
  1083. spinlock_t manage_lock;
  1084. spinlock_t sync_lock;
  1085. int sync_mode;
  1086. struct fib *sync_fib;
  1087. struct list_head sync_fib_list;
  1088. u32 doorbell_mask;
  1089. u32 max_msix; /* max. MSI-X vectors */
  1090. u32 vector_cap; /* MSI-X vector capab.*/
  1091. int msi_enabled; /* MSI/MSI-X enabled */
  1092. struct msix_entry msixentry[AAC_MAX_MSIX];
  1093. struct aac_msix_ctx aac_msix[AAC_MAX_MSIX]; /* context */
  1094. u8 adapter_shutdown;
  1095. };
  1096. #define aac_adapter_interrupt(dev) \
  1097. (dev)->a_ops.adapter_interrupt(dev)
  1098. #define aac_adapter_notify(dev, event) \
  1099. (dev)->a_ops.adapter_notify(dev, event)
  1100. #define aac_adapter_disable_int(dev) \
  1101. (dev)->a_ops.adapter_disable_int(dev)
  1102. #define aac_adapter_enable_int(dev) \
  1103. (dev)->a_ops.adapter_enable_int(dev)
  1104. #define aac_adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4) \
  1105. (dev)->a_ops.adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4)
  1106. #define aac_adapter_check_health(dev) \
  1107. (dev)->a_ops.adapter_check_health(dev)
  1108. #define aac_adapter_restart(dev,bled) \
  1109. (dev)->a_ops.adapter_restart(dev,bled)
  1110. #define aac_adapter_start(dev) \
  1111. ((dev)->a_ops.adapter_start(dev))
  1112. #define aac_adapter_ioremap(dev, size) \
  1113. (dev)->a_ops.adapter_ioremap(dev, size)
  1114. #define aac_adapter_deliver(fib) \
  1115. ((fib)->dev)->a_ops.adapter_deliver(fib)
  1116. #define aac_adapter_bounds(dev,cmd,lba) \
  1117. dev->a_ops.adapter_bounds(dev,cmd,lba)
  1118. #define aac_adapter_read(fib,cmd,lba,count) \
  1119. ((fib)->dev)->a_ops.adapter_read(fib,cmd,lba,count)
  1120. #define aac_adapter_write(fib,cmd,lba,count,fua) \
  1121. ((fib)->dev)->a_ops.adapter_write(fib,cmd,lba,count,fua)
  1122. #define aac_adapter_scsi(fib,cmd) \
  1123. ((fib)->dev)->a_ops.adapter_scsi(fib,cmd)
  1124. #define aac_adapter_comm(dev,comm) \
  1125. (dev)->a_ops.adapter_comm(dev, comm)
  1126. #define FIB_CONTEXT_FLAG_TIMED_OUT (0x00000001)
  1127. #define FIB_CONTEXT_FLAG (0x00000002)
  1128. #define FIB_CONTEXT_FLAG_WAIT (0x00000004)
  1129. #define FIB_CONTEXT_FLAG_FASTRESP (0x00000008)
  1130. /*
  1131. * Define the command values
  1132. */
  1133. #define Null 0
  1134. #define GetAttributes 1
  1135. #define SetAttributes 2
  1136. #define Lookup 3
  1137. #define ReadLink 4
  1138. #define Read 5
  1139. #define Write 6
  1140. #define Create 7
  1141. #define MakeDirectory 8
  1142. #define SymbolicLink 9
  1143. #define MakeNode 10
  1144. #define Removex 11
  1145. #define RemoveDirectoryx 12
  1146. #define Rename 13
  1147. #define Link 14
  1148. #define ReadDirectory 15
  1149. #define ReadDirectoryPlus 16
  1150. #define FileSystemStatus 17
  1151. #define FileSystemInfo 18
  1152. #define PathConfigure 19
  1153. #define Commit 20
  1154. #define Mount 21
  1155. #define UnMount 22
  1156. #define Newfs 23
  1157. #define FsCheck 24
  1158. #define FsSync 25
  1159. #define SimReadWrite 26
  1160. #define SetFileSystemStatus 27
  1161. #define BlockRead 28
  1162. #define BlockWrite 29
  1163. #define NvramIoctl 30
  1164. #define FsSyncWait 31
  1165. #define ClearArchiveBit 32
  1166. #define SetAcl 33
  1167. #define GetAcl 34
  1168. #define AssignAcl 35
  1169. #define FaultInsertion 36 /* Fault Insertion Command */
  1170. #define CrazyCache 37 /* Crazycache */
  1171. #define MAX_FSACOMMAND_NUM 38
  1172. /*
  1173. * Define the status returns. These are very unixlike although
  1174. * most are not in fact used
  1175. */
  1176. #define ST_OK 0
  1177. #define ST_PERM 1
  1178. #define ST_NOENT 2
  1179. #define ST_IO 5
  1180. #define ST_NXIO 6
  1181. #define ST_E2BIG 7
  1182. #define ST_ACCES 13
  1183. #define ST_EXIST 17
  1184. #define ST_XDEV 18
  1185. #define ST_NODEV 19
  1186. #define ST_NOTDIR 20
  1187. #define ST_ISDIR 21
  1188. #define ST_INVAL 22
  1189. #define ST_FBIG 27
  1190. #define ST_NOSPC 28
  1191. #define ST_ROFS 30
  1192. #define ST_MLINK 31
  1193. #define ST_WOULDBLOCK 35
  1194. #define ST_NAMETOOLONG 63
  1195. #define ST_NOTEMPTY 66
  1196. #define ST_DQUOT 69
  1197. #define ST_STALE 70
  1198. #define ST_REMOTE 71
  1199. #define ST_NOT_READY 72
  1200. #define ST_BADHANDLE 10001
  1201. #define ST_NOT_SYNC 10002
  1202. #define ST_BAD_COOKIE 10003
  1203. #define ST_NOTSUPP 10004
  1204. #define ST_TOOSMALL 10005
  1205. #define ST_SERVERFAULT 10006
  1206. #define ST_BADTYPE 10007
  1207. #define ST_JUKEBOX 10008
  1208. #define ST_NOTMOUNTED 10009
  1209. #define ST_MAINTMODE 10010
  1210. #define ST_STALEACL 10011
  1211. /*
  1212. * On writes how does the client want the data written.
  1213. */
  1214. #define CACHE_CSTABLE 1
  1215. #define CACHE_UNSTABLE 2
  1216. /*
  1217. * Lets the client know at which level the data was committed on
  1218. * a write request
  1219. */
  1220. #define CMFILE_SYNCH_NVRAM 1
  1221. #define CMDATA_SYNCH_NVRAM 2
  1222. #define CMFILE_SYNCH 3
  1223. #define CMDATA_SYNCH 4
  1224. #define CMUNSTABLE 5
  1225. #define RIO_TYPE_WRITE 0x0000
  1226. #define RIO_TYPE_READ 0x0001
  1227. #define RIO_SUREWRITE 0x0008
  1228. #define RIO2_IO_TYPE 0x0003
  1229. #define RIO2_IO_TYPE_WRITE 0x0000
  1230. #define RIO2_IO_TYPE_READ 0x0001
  1231. #define RIO2_IO_TYPE_VERIFY 0x0002
  1232. #define RIO2_IO_ERROR 0x0004
  1233. #define RIO2_IO_SUREWRITE 0x0008
  1234. #define RIO2_SGL_CONFORMANT 0x0010
  1235. #define RIO2_SG_FORMAT 0xF000
  1236. #define RIO2_SG_FORMAT_ARC 0x0000
  1237. #define RIO2_SG_FORMAT_SRL 0x1000
  1238. #define RIO2_SG_FORMAT_IEEE1212 0x2000
  1239. struct aac_read
  1240. {
  1241. __le32 command;
  1242. __le32 cid;
  1243. __le32 block;
  1244. __le32 count;
  1245. struct sgmap sg; // Must be last in struct because it is variable
  1246. };
  1247. struct aac_read64
  1248. {
  1249. __le32 command;
  1250. __le16 cid;
  1251. __le16 sector_count;
  1252. __le32 block;
  1253. __le16 pad;
  1254. __le16 flags;
  1255. struct sgmap64 sg; // Must be last in struct because it is variable
  1256. };
  1257. struct aac_read_reply
  1258. {
  1259. __le32 status;
  1260. __le32 count;
  1261. };
  1262. struct aac_write
  1263. {
  1264. __le32 command;
  1265. __le32 cid;
  1266. __le32 block;
  1267. __le32 count;
  1268. __le32 stable; // Not used
  1269. struct sgmap sg; // Must be last in struct because it is variable
  1270. };
  1271. struct aac_write64
  1272. {
  1273. __le32 command;
  1274. __le16 cid;
  1275. __le16 sector_count;
  1276. __le32 block;
  1277. __le16 pad;
  1278. __le16 flags;
  1279. struct sgmap64 sg; // Must be last in struct because it is variable
  1280. };
  1281. struct aac_write_reply
  1282. {
  1283. __le32 status;
  1284. __le32 count;
  1285. __le32 committed;
  1286. };
  1287. struct aac_raw_io
  1288. {
  1289. __le32 block[2];
  1290. __le32 count;
  1291. __le16 cid;
  1292. __le16 flags; /* 00 W, 01 R */
  1293. __le16 bpTotal; /* reserved for F/W use */
  1294. __le16 bpComplete; /* reserved for F/W use */
  1295. struct sgmapraw sg;
  1296. };
  1297. struct aac_raw_io2 {
  1298. __le32 blockLow;
  1299. __le32 blockHigh;
  1300. __le32 byteCount;
  1301. __le16 cid;
  1302. __le16 flags; /* RIO2 flags */
  1303. __le32 sgeFirstSize; /* size of first sge el. */
  1304. __le32 sgeNominalSize; /* size of 2nd sge el. (if conformant) */
  1305. u8 sgeCnt; /* only 8 bits required */
  1306. u8 bpTotal; /* reserved for F/W use */
  1307. u8 bpComplete; /* reserved for F/W use */
  1308. u8 sgeFirstIndex; /* reserved for F/W use */
  1309. u8 unused[4];
  1310. struct sge_ieee1212 sge[1];
  1311. };
  1312. #define CT_FLUSH_CACHE 129
  1313. struct aac_synchronize {
  1314. __le32 command; /* VM_ContainerConfig */
  1315. __le32 type; /* CT_FLUSH_CACHE */
  1316. __le32 cid;
  1317. __le32 parm1;
  1318. __le32 parm2;
  1319. __le32 parm3;
  1320. __le32 parm4;
  1321. __le32 count; /* sizeof(((struct aac_synchronize_reply *)NULL)->data) */
  1322. };
  1323. struct aac_synchronize_reply {
  1324. __le32 dummy0;
  1325. __le32 dummy1;
  1326. __le32 status; /* CT_OK */
  1327. __le32 parm1;
  1328. __le32 parm2;
  1329. __le32 parm3;
  1330. __le32 parm4;
  1331. __le32 parm5;
  1332. u8 data[16];
  1333. };
  1334. #define CT_POWER_MANAGEMENT 245
  1335. #define CT_PM_START_UNIT 2
  1336. #define CT_PM_STOP_UNIT 3
  1337. #define CT_PM_UNIT_IMMEDIATE 1
  1338. struct aac_power_management {
  1339. __le32 command; /* VM_ContainerConfig */
  1340. __le32 type; /* CT_POWER_MANAGEMENT */
  1341. __le32 sub; /* CT_PM_* */
  1342. __le32 cid;
  1343. __le32 parm; /* CT_PM_sub_* */
  1344. };
  1345. #define CT_PAUSE_IO 65
  1346. #define CT_RELEASE_IO 66
  1347. struct aac_pause {
  1348. __le32 command; /* VM_ContainerConfig */
  1349. __le32 type; /* CT_PAUSE_IO */
  1350. __le32 timeout; /* 10ms ticks */
  1351. __le32 min;
  1352. __le32 noRescan;
  1353. __le32 parm3;
  1354. __le32 parm4;
  1355. __le32 count; /* sizeof(((struct aac_pause_reply *)NULL)->data) */
  1356. };
  1357. struct aac_srb
  1358. {
  1359. __le32 function;
  1360. __le32 channel;
  1361. __le32 id;
  1362. __le32 lun;
  1363. __le32 timeout;
  1364. __le32 flags;
  1365. __le32 count; // Data xfer size
  1366. __le32 retry_limit;
  1367. __le32 cdb_size;
  1368. u8 cdb[16];
  1369. struct sgmap sg;
  1370. };
  1371. /*
  1372. * This and associated data structs are used by the
  1373. * ioctl caller and are in cpu order.
  1374. */
  1375. struct user_aac_srb
  1376. {
  1377. u32 function;
  1378. u32 channel;
  1379. u32 id;
  1380. u32 lun;
  1381. u32 timeout;
  1382. u32 flags;
  1383. u32 count; // Data xfer size
  1384. u32 retry_limit;
  1385. u32 cdb_size;
  1386. u8 cdb[16];
  1387. struct user_sgmap sg;
  1388. };
  1389. #define AAC_SENSE_BUFFERSIZE 30
  1390. struct aac_srb_reply
  1391. {
  1392. __le32 status;
  1393. __le32 srb_status;
  1394. __le32 scsi_status;
  1395. __le32 data_xfer_length;
  1396. __le32 sense_data_size;
  1397. u8 sense_data[AAC_SENSE_BUFFERSIZE]; // Can this be SCSI_SENSE_BUFFERSIZE
  1398. };
  1399. /*
  1400. * SRB Flags
  1401. */
  1402. #define SRB_NoDataXfer 0x0000
  1403. #define SRB_DisableDisconnect 0x0004
  1404. #define SRB_DisableSynchTransfer 0x0008
  1405. #define SRB_BypassFrozenQueue 0x0010
  1406. #define SRB_DisableAutosense 0x0020
  1407. #define SRB_DataIn 0x0040
  1408. #define SRB_DataOut 0x0080
  1409. /*
  1410. * SRB Functions - set in aac_srb->function
  1411. */
  1412. #define SRBF_ExecuteScsi 0x0000
  1413. #define SRBF_ClaimDevice 0x0001
  1414. #define SRBF_IO_Control 0x0002
  1415. #define SRBF_ReceiveEvent 0x0003
  1416. #define SRBF_ReleaseQueue 0x0004
  1417. #define SRBF_AttachDevice 0x0005
  1418. #define SRBF_ReleaseDevice 0x0006
  1419. #define SRBF_Shutdown 0x0007
  1420. #define SRBF_Flush 0x0008
  1421. #define SRBF_AbortCommand 0x0010
  1422. #define SRBF_ReleaseRecovery 0x0011
  1423. #define SRBF_ResetBus 0x0012
  1424. #define SRBF_ResetDevice 0x0013
  1425. #define SRBF_TerminateIO 0x0014
  1426. #define SRBF_FlushQueue 0x0015
  1427. #define SRBF_RemoveDevice 0x0016
  1428. #define SRBF_DomainValidation 0x0017
  1429. /*
  1430. * SRB SCSI Status - set in aac_srb->scsi_status
  1431. */
  1432. #define SRB_STATUS_PENDING 0x00
  1433. #define SRB_STATUS_SUCCESS 0x01
  1434. #define SRB_STATUS_ABORTED 0x02
  1435. #define SRB_STATUS_ABORT_FAILED 0x03
  1436. #define SRB_STATUS_ERROR 0x04
  1437. #define SRB_STATUS_BUSY 0x05
  1438. #define SRB_STATUS_INVALID_REQUEST 0x06
  1439. #define SRB_STATUS_INVALID_PATH_ID 0x07
  1440. #define SRB_STATUS_NO_DEVICE 0x08
  1441. #define SRB_STATUS_TIMEOUT 0x09
  1442. #define SRB_STATUS_SELECTION_TIMEOUT 0x0A
  1443. #define SRB_STATUS_COMMAND_TIMEOUT 0x0B
  1444. #define SRB_STATUS_MESSAGE_REJECTED 0x0D
  1445. #define SRB_STATUS_BUS_RESET 0x0E
  1446. #define SRB_STATUS_PARITY_ERROR 0x0F
  1447. #define SRB_STATUS_REQUEST_SENSE_FAILED 0x10
  1448. #define SRB_STATUS_NO_HBA 0x11
  1449. #define SRB_STATUS_DATA_OVERRUN 0x12
  1450. #define SRB_STATUS_UNEXPECTED_BUS_FREE 0x13
  1451. #define SRB_STATUS_PHASE_SEQUENCE_FAILURE 0x14
  1452. #define SRB_STATUS_BAD_SRB_BLOCK_LENGTH 0x15
  1453. #define SRB_STATUS_REQUEST_FLUSHED 0x16
  1454. #define SRB_STATUS_DELAYED_RETRY 0x17
  1455. #define SRB_STATUS_INVALID_LUN 0x20
  1456. #define SRB_STATUS_INVALID_TARGET_ID 0x21
  1457. #define SRB_STATUS_BAD_FUNCTION 0x22
  1458. #define SRB_STATUS_ERROR_RECOVERY 0x23
  1459. #define SRB_STATUS_NOT_STARTED 0x24
  1460. #define SRB_STATUS_NOT_IN_USE 0x30
  1461. #define SRB_STATUS_FORCE_ABORT 0x31
  1462. #define SRB_STATUS_DOMAIN_VALIDATION_FAIL 0x32
  1463. /*
  1464. * Object-Server / Volume-Manager Dispatch Classes
  1465. */
  1466. #define VM_Null 0
  1467. #define VM_NameServe 1
  1468. #define VM_ContainerConfig 2
  1469. #define VM_Ioctl 3
  1470. #define VM_FilesystemIoctl 4
  1471. #define VM_CloseAll 5
  1472. #define VM_CtBlockRead 6
  1473. #define VM_CtBlockWrite 7
  1474. #define VM_SliceBlockRead 8 /* raw access to configured "storage objects" */
  1475. #define VM_SliceBlockWrite 9
  1476. #define VM_DriveBlockRead 10 /* raw access to physical devices */
  1477. #define VM_DriveBlockWrite 11
  1478. #define VM_EnclosureMgt 12 /* enclosure management */
  1479. #define VM_Unused 13 /* used to be diskset management */
  1480. #define VM_CtBlockVerify 14
  1481. #define VM_CtPerf 15 /* performance test */
  1482. #define VM_CtBlockRead64 16
  1483. #define VM_CtBlockWrite64 17
  1484. #define VM_CtBlockVerify64 18
  1485. #define VM_CtHostRead64 19
  1486. #define VM_CtHostWrite64 20
  1487. #define VM_DrvErrTblLog 21
  1488. #define VM_NameServe64 22
  1489. #define VM_NameServeAllBlk 30
  1490. #define MAX_VMCOMMAND_NUM 23 /* used for sizing stats array - leave last */
  1491. /*
  1492. * Descriptive information (eg, vital stats)
  1493. * that a content manager might report. The
  1494. * FileArray filesystem component is one example
  1495. * of a content manager. Raw mode might be
  1496. * another.
  1497. */
  1498. struct aac_fsinfo {
  1499. __le32 fsTotalSize; /* Consumed by fs, incl. metadata */
  1500. __le32 fsBlockSize;
  1501. __le32 fsFragSize;
  1502. __le32 fsMaxExtendSize;
  1503. __le32 fsSpaceUnits;
  1504. __le32 fsMaxNumFiles;
  1505. __le32 fsNumFreeFiles;
  1506. __le32 fsInodeDensity;
  1507. }; /* valid iff ObjType == FT_FILESYS && !(ContentState & FSCS_NOTCLEAN) */
  1508. struct aac_blockdevinfo {
  1509. __le32 block_size;
  1510. };
  1511. union aac_contentinfo {
  1512. struct aac_fsinfo filesys;
  1513. struct aac_blockdevinfo bdevinfo;
  1514. };
  1515. /*
  1516. * Query for Container Configuration Status
  1517. */
  1518. #define CT_GET_CONFIG_STATUS 147
  1519. struct aac_get_config_status {
  1520. __le32 command; /* VM_ContainerConfig */
  1521. __le32 type; /* CT_GET_CONFIG_STATUS */
  1522. __le32 parm1;
  1523. __le32 parm2;
  1524. __le32 parm3;
  1525. __le32 parm4;
  1526. __le32 parm5;
  1527. __le32 count; /* sizeof(((struct aac_get_config_status_resp *)NULL)->data) */
  1528. };
  1529. #define CFACT_CONTINUE 0
  1530. #define CFACT_PAUSE 1
  1531. #define CFACT_ABORT 2
  1532. struct aac_get_config_status_resp {
  1533. __le32 response; /* ST_OK */
  1534. __le32 dummy0;
  1535. __le32 status; /* CT_OK */
  1536. __le32 parm1;
  1537. __le32 parm2;
  1538. __le32 parm3;
  1539. __le32 parm4;
  1540. __le32 parm5;
  1541. struct {
  1542. __le32 action; /* CFACT_CONTINUE, CFACT_PAUSE or CFACT_ABORT */
  1543. __le16 flags;
  1544. __le16 count;
  1545. } data;
  1546. };
  1547. /*
  1548. * Accept the configuration as-is
  1549. */
  1550. #define CT_COMMIT_CONFIG 152
  1551. struct aac_commit_config {
  1552. __le32 command; /* VM_ContainerConfig */
  1553. __le32 type; /* CT_COMMIT_CONFIG */
  1554. };
  1555. /*
  1556. * Query for Container Configuration Status
  1557. */
  1558. #define CT_GET_CONTAINER_COUNT 4
  1559. struct aac_get_container_count {
  1560. __le32 command; /* VM_ContainerConfig */
  1561. __le32 type; /* CT_GET_CONTAINER_COUNT */
  1562. };
  1563. struct aac_get_container_count_resp {
  1564. __le32 response; /* ST_OK */
  1565. __le32 dummy0;
  1566. __le32 MaxContainers;
  1567. __le32 ContainerSwitchEntries;
  1568. __le32 MaxPartitions;
  1569. __le32 MaxSimpleVolumes;
  1570. };
  1571. /*
  1572. * Query for "mountable" objects, ie, objects that are typically
  1573. * associated with a drive letter on the client (host) side.
  1574. */
  1575. struct aac_mntent {
  1576. __le32 oid;
  1577. u8 name[16]; /* if applicable */
  1578. struct creation_info create_info; /* if applicable */
  1579. __le32 capacity;
  1580. __le32 vol; /* substrate structure */
  1581. __le32 obj; /* FT_FILESYS, etc. */
  1582. __le32 state; /* unready for mounting,
  1583. readonly, etc. */
  1584. union aac_contentinfo fileinfo; /* Info specific to content
  1585. manager (eg, filesystem) */
  1586. __le32 altoid; /* != oid <==> snapshot or
  1587. broken mirror exists */
  1588. __le32 capacityhigh;
  1589. };
  1590. #define FSCS_NOTCLEAN 0x0001 /* fsck is necessary before mounting */
  1591. #define FSCS_READONLY 0x0002 /* possible result of broken mirror */
  1592. #define FSCS_HIDDEN 0x0004 /* should be ignored - set during a clear */
  1593. #define FSCS_NOT_READY 0x0008 /* Array spinning up to fulfil request */
  1594. struct aac_query_mount {
  1595. __le32 command;
  1596. __le32 type;
  1597. __le32 count;
  1598. };
  1599. struct aac_mount {
  1600. __le32 status;
  1601. __le32 type; /* should be same as that requested */
  1602. __le32 count;
  1603. struct aac_mntent mnt[1];
  1604. };
  1605. #define CT_READ_NAME 130
  1606. struct aac_get_name {
  1607. __le32 command; /* VM_ContainerConfig */
  1608. __le32 type; /* CT_READ_NAME */
  1609. __le32 cid;
  1610. __le32 parm1;
  1611. __le32 parm2;
  1612. __le32 parm3;
  1613. __le32 parm4;
  1614. __le32 count; /* sizeof(((struct aac_get_name_resp *)NULL)->data) */
  1615. };
  1616. struct aac_get_name_resp {
  1617. __le32 dummy0;
  1618. __le32 dummy1;
  1619. __le32 status; /* CT_OK */
  1620. __le32 parm1;
  1621. __le32 parm2;
  1622. __le32 parm3;
  1623. __le32 parm4;
  1624. __le32 parm5;
  1625. u8 data[16];
  1626. };
  1627. #define CT_CID_TO_32BITS_UID 165
  1628. struct aac_get_serial {
  1629. __le32 command; /* VM_ContainerConfig */
  1630. __le32 type; /* CT_CID_TO_32BITS_UID */
  1631. __le32 cid;
  1632. };
  1633. struct aac_get_serial_resp {
  1634. __le32 dummy0;
  1635. __le32 dummy1;
  1636. __le32 status; /* CT_OK */
  1637. __le32 uid;
  1638. };
  1639. /*
  1640. * The following command is sent to shut down each container.
  1641. */
  1642. struct aac_close {
  1643. __le32 command;
  1644. __le32 cid;
  1645. };
  1646. struct aac_query_disk
  1647. {
  1648. s32 cnum;
  1649. s32 bus;
  1650. s32 id;
  1651. s32 lun;
  1652. u32 valid;
  1653. u32 locked;
  1654. u32 deleted;
  1655. s32 instance;
  1656. s8 name[10];
  1657. u32 unmapped;
  1658. };
  1659. struct aac_delete_disk {
  1660. u32 disknum;
  1661. u32 cnum;
  1662. };
  1663. struct fib_ioctl
  1664. {
  1665. u32 fibctx;
  1666. s32 wait;
  1667. char __user *fib;
  1668. };
  1669. struct revision
  1670. {
  1671. u32 compat;
  1672. __le32 version;
  1673. __le32 build;
  1674. };
  1675. /*
  1676. * Ugly - non Linux like ioctl coding for back compat.
  1677. */
  1678. #define CTL_CODE(function, method) ( \
  1679. (4<< 16) | ((function) << 2) | (method) \
  1680. )
  1681. /*
  1682. * Define the method codes for how buffers are passed for I/O and FS
  1683. * controls
  1684. */
  1685. #define METHOD_BUFFERED 0
  1686. #define METHOD_NEITHER 3
  1687. /*
  1688. * Filesystem ioctls
  1689. */
  1690. #define FSACTL_SENDFIB CTL_CODE(2050, METHOD_BUFFERED)
  1691. #define FSACTL_SEND_RAW_SRB CTL_CODE(2067, METHOD_BUFFERED)
  1692. #define FSACTL_DELETE_DISK 0x163
  1693. #define FSACTL_QUERY_DISK 0x173
  1694. #define FSACTL_OPEN_GET_ADAPTER_FIB CTL_CODE(2100, METHOD_BUFFERED)
  1695. #define FSACTL_GET_NEXT_ADAPTER_FIB CTL_CODE(2101, METHOD_BUFFERED)
  1696. #define FSACTL_CLOSE_GET_ADAPTER_FIB CTL_CODE(2102, METHOD_BUFFERED)
  1697. #define FSACTL_MINIPORT_REV_CHECK CTL_CODE(2107, METHOD_BUFFERED)
  1698. #define FSACTL_GET_PCI_INFO CTL_CODE(2119, METHOD_BUFFERED)
  1699. #define FSACTL_FORCE_DELETE_DISK CTL_CODE(2120, METHOD_NEITHER)
  1700. #define FSACTL_GET_CONTAINERS 2131
  1701. #define FSACTL_SEND_LARGE_FIB CTL_CODE(2138, METHOD_BUFFERED)
  1702. struct aac_common
  1703. {
  1704. /*
  1705. * If this value is set to 1 then interrupt moderation will occur
  1706. * in the base commuication support.
  1707. */
  1708. u32 irq_mod;
  1709. u32 peak_fibs;
  1710. u32 zero_fibs;
  1711. u32 fib_timeouts;
  1712. /*
  1713. * Statistical counters in debug mode
  1714. */
  1715. #ifdef DBG
  1716. u32 FibsSent;
  1717. u32 FibRecved;
  1718. u32 NoResponseSent;
  1719. u32 NoResponseRecved;
  1720. u32 AsyncSent;
  1721. u32 AsyncRecved;
  1722. u32 NormalSent;
  1723. u32 NormalRecved;
  1724. #endif
  1725. };
  1726. extern struct aac_common aac_config;
  1727. /*
  1728. * The following macro is used when sending and receiving FIBs. It is
  1729. * only used for debugging.
  1730. */
  1731. #ifdef DBG
  1732. #define FIB_COUNTER_INCREMENT(counter) (counter)++
  1733. #else
  1734. #define FIB_COUNTER_INCREMENT(counter)
  1735. #endif
  1736. /*
  1737. * Adapter direct commands
  1738. * Monitor/Kernel API
  1739. */
  1740. #define BREAKPOINT_REQUEST 0x00000004
  1741. #define INIT_STRUCT_BASE_ADDRESS 0x00000005
  1742. #define READ_PERMANENT_PARAMETERS 0x0000000a
  1743. #define WRITE_PERMANENT_PARAMETERS 0x0000000b
  1744. #define HOST_CRASHING 0x0000000d
  1745. #define SEND_SYNCHRONOUS_FIB 0x0000000c
  1746. #define COMMAND_POST_RESULTS 0x00000014
  1747. #define GET_ADAPTER_PROPERTIES 0x00000019
  1748. #define GET_DRIVER_BUFFER_PROPERTIES 0x00000023
  1749. #define RCV_TEMP_READINGS 0x00000025
  1750. #define GET_COMM_PREFERRED_SETTINGS 0x00000026
  1751. #define IOP_RESET 0x00001000
  1752. #define IOP_RESET_ALWAYS 0x00001001
  1753. #define RE_INIT_ADAPTER 0x000000ee
  1754. /*
  1755. * Adapter Status Register
  1756. *
  1757. * Phase Staus mailbox is 32bits:
  1758. * <31:16> = Phase Status
  1759. * <15:0> = Phase
  1760. *
  1761. * The adapter reports is present state through the phase. Only
  1762. * a single phase should be ever be set. Each phase can have multiple
  1763. * phase status bits to provide more detailed information about the
  1764. * state of the board. Care should be taken to ensure that any phase
  1765. * status bits that are set when changing the phase are also valid
  1766. * for the new phase or be cleared out. Adapter software (monitor,
  1767. * iflash, kernel) is responsible for properly maintining the phase
  1768. * status mailbox when it is running.
  1769. *
  1770. * MONKER_API Phases
  1771. *
  1772. * Phases are bit oriented. It is NOT valid to have multiple bits set
  1773. */
  1774. #define SELF_TEST_FAILED 0x00000004
  1775. #define MONITOR_PANIC 0x00000020
  1776. #define KERNEL_UP_AND_RUNNING 0x00000080
  1777. #define KERNEL_PANIC 0x00000100
  1778. #define FLASH_UPD_PENDING 0x00002000
  1779. #define FLASH_UPD_SUCCESS 0x00004000
  1780. #define FLASH_UPD_FAILED 0x00008000
  1781. #define FWUPD_TIMEOUT (5 * 60)
  1782. /*
  1783. * Doorbell bit defines
  1784. */
  1785. #define DoorBellSyncCmdAvailable (1<<0) /* Host -> Adapter */
  1786. #define DoorBellPrintfDone (1<<5) /* Host -> Adapter */
  1787. #define DoorBellAdapterNormCmdReady (1<<1) /* Adapter -> Host */
  1788. #define DoorBellAdapterNormRespReady (1<<2) /* Adapter -> Host */
  1789. #define DoorBellAdapterNormCmdNotFull (1<<3) /* Adapter -> Host */
  1790. #define DoorBellAdapterNormRespNotFull (1<<4) /* Adapter -> Host */
  1791. #define DoorBellPrintfReady (1<<5) /* Adapter -> Host */
  1792. #define DoorBellAifPending (1<<6) /* Adapter -> Host */
  1793. /* PMC specific outbound doorbell bits */
  1794. #define PmDoorBellResponseSent (1<<1) /* Adapter -> Host */
  1795. /*
  1796. * For FIB communication, we need all of the following things
  1797. * to send back to the user.
  1798. */
  1799. #define AifCmdEventNotify 1 /* Notify of event */
  1800. #define AifEnConfigChange 3 /* Adapter configuration change */
  1801. #define AifEnContainerChange 4 /* Container configuration change */
  1802. #define AifEnDeviceFailure 5 /* SCSI device failed */
  1803. #define AifEnEnclosureManagement 13 /* EM_DRIVE_* */
  1804. #define EM_DRIVE_INSERTION 31
  1805. #define EM_DRIVE_REMOVAL 32
  1806. #define EM_SES_DRIVE_INSERTION 33
  1807. #define EM_SES_DRIVE_REMOVAL 26
  1808. #define AifEnBatteryEvent 14 /* Change in Battery State */
  1809. #define AifEnAddContainer 15 /* A new array was created */
  1810. #define AifEnDeleteContainer 16 /* A container was deleted */
  1811. #define AifEnExpEvent 23 /* Firmware Event Log */
  1812. #define AifExeFirmwarePanic 3 /* Firmware Event Panic */
  1813. #define AifHighPriority 3 /* Highest Priority Event */
  1814. #define AifEnAddJBOD 30 /* JBOD created */
  1815. #define AifEnDeleteJBOD 31 /* JBOD deleted */
  1816. #define AifCmdJobProgress 2 /* Progress report */
  1817. #define AifJobCtrZero 101 /* Array Zero progress */
  1818. #define AifJobStsSuccess 1 /* Job completes */
  1819. #define AifJobStsRunning 102 /* Job running */
  1820. #define AifCmdAPIReport 3 /* Report from other user of API */
  1821. #define AifCmdDriverNotify 4 /* Notify host driver of event */
  1822. #define AifDenMorphComplete 200 /* A morph operation completed */
  1823. #define AifDenVolumeExtendComplete 201 /* A volume extend completed */
  1824. #define AifReqJobList 100 /* Gets back complete job list */
  1825. #define AifReqJobsForCtr 101 /* Gets back jobs for specific container */
  1826. #define AifReqJobsForScsi 102 /* Gets back jobs for specific SCSI device */
  1827. #define AifReqJobReport 103 /* Gets back a specific job report or list of them */
  1828. #define AifReqTerminateJob 104 /* Terminates job */
  1829. #define AifReqSuspendJob 105 /* Suspends a job */
  1830. #define AifReqResumeJob 106 /* Resumes a job */
  1831. #define AifReqSendAPIReport 107 /* API generic report requests */
  1832. #define AifReqAPIJobStart 108 /* Start a job from the API */
  1833. #define AifReqAPIJobUpdate 109 /* Update a job report from the API */
  1834. #define AifReqAPIJobFinish 110 /* Finish a job from the API */
  1835. /* PMC NEW COMM: Request the event data */
  1836. #define AifReqEvent 200
  1837. /* RAW device deleted */
  1838. #define AifRawDeviceRemove 203
  1839. /*
  1840. * Adapter Initiated FIB command structures. Start with the adapter
  1841. * initiated FIBs that really come from the adapter, and get responded
  1842. * to by the host.
  1843. */
  1844. struct aac_aifcmd {
  1845. __le32 command; /* Tell host what type of notify this is */
  1846. __le32 seqnum; /* To allow ordering of reports (if necessary) */
  1847. u8 data[1]; /* Undefined length (from kernel viewpoint) */
  1848. };
  1849. /**
  1850. * Convert capacity to cylinders
  1851. * accounting for the fact capacity could be a 64 bit value
  1852. *
  1853. */
  1854. static inline unsigned int cap_to_cyls(sector_t capacity, unsigned divisor)
  1855. {
  1856. sector_div(capacity, divisor);
  1857. return capacity;
  1858. }
  1859. /* SCp.phase values */
  1860. #define AAC_OWNER_MIDLEVEL 0x101
  1861. #define AAC_OWNER_LOWLEVEL 0x102
  1862. #define AAC_OWNER_ERROR_HANDLER 0x103
  1863. #define AAC_OWNER_FIRMWARE 0x106
  1864. int aac_acquire_irq(struct aac_dev *dev);
  1865. void aac_free_irq(struct aac_dev *dev);
  1866. const char *aac_driverinfo(struct Scsi_Host *);
  1867. void aac_fib_vector_assign(struct aac_dev *dev);
  1868. struct fib *aac_fib_alloc(struct aac_dev *dev);
  1869. int aac_fib_setup(struct aac_dev *dev);
  1870. void aac_fib_map_free(struct aac_dev *dev);
  1871. void aac_fib_free(struct fib * context);
  1872. void aac_fib_init(struct fib * context);
  1873. void aac_printf(struct aac_dev *dev, u32 val);
  1874. int aac_fib_send(u16 command, struct fib * context, unsigned long size, int priority, int wait, int reply, fib_callback callback, void *ctxt);
  1875. int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entry **entry);
  1876. void aac_consumer_free(struct aac_dev * dev, struct aac_queue * q, u32 qnum);
  1877. int aac_fib_complete(struct fib * context);
  1878. #define fib_data(fibctx) ((void *)(fibctx)->hw_fib_va->data)
  1879. struct aac_dev *aac_init_adapter(struct aac_dev *dev);
  1880. void aac_src_access_devreg(struct aac_dev *dev, int mode);
  1881. int aac_get_config_status(struct aac_dev *dev, int commit_flag);
  1882. int aac_get_containers(struct aac_dev *dev);
  1883. int aac_scsi_cmd(struct scsi_cmnd *cmd);
  1884. int aac_dev_ioctl(struct aac_dev *dev, int cmd, void __user *arg);
  1885. #ifndef shost_to_class
  1886. #define shost_to_class(shost) &shost->shost_dev
  1887. #endif
  1888. ssize_t aac_get_serial_number(struct device *dev, char *buf);
  1889. int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg);
  1890. int aac_rx_init(struct aac_dev *dev);
  1891. int aac_rkt_init(struct aac_dev *dev);
  1892. int aac_nark_init(struct aac_dev *dev);
  1893. int aac_sa_init(struct aac_dev *dev);
  1894. int aac_src_init(struct aac_dev *dev);
  1895. int aac_srcv_init(struct aac_dev *dev);
  1896. int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_fib * hw_fib, int wait, struct fib * fibptr, unsigned long *nonotify);
  1897. void aac_define_int_mode(struct aac_dev *dev);
  1898. unsigned int aac_response_normal(struct aac_queue * q);
  1899. unsigned int aac_command_normal(struct aac_queue * q);
  1900. unsigned int aac_intr_normal(struct aac_dev *dev, u32 Index,
  1901. int isAif, int isFastResponse,
  1902. struct hw_fib *aif_fib);
  1903. int aac_reset_adapter(struct aac_dev * dev, int forced);
  1904. int aac_check_health(struct aac_dev * dev);
  1905. int aac_command_thread(void *data);
  1906. int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context *fibctx);
  1907. int aac_fib_adapter_complete(struct fib * fibptr, unsigned short size);
  1908. struct aac_driver_ident* aac_get_driver_ident(int devtype);
  1909. int aac_get_adapter_info(struct aac_dev* dev);
  1910. int aac_send_shutdown(struct aac_dev *dev);
  1911. int aac_probe_container(struct aac_dev *dev, int cid);
  1912. int _aac_rx_init(struct aac_dev *dev);
  1913. int aac_rx_select_comm(struct aac_dev *dev, int comm);
  1914. int aac_rx_deliver_producer(struct fib * fib);
  1915. char * get_container_type(unsigned type);
  1916. extern int numacb;
  1917. extern int acbsize;
  1918. extern char aac_driver_version[];
  1919. extern int startup_timeout;
  1920. extern int aif_timeout;
  1921. extern int expose_physicals;
  1922. extern int aac_reset_devices;
  1923. extern int aac_msi;
  1924. extern int aac_commit;
  1925. extern int update_interval;
  1926. extern int check_interval;
  1927. extern int aac_check_reset;