aacraid.h 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Adaptec AAC series RAID controller driver
  4. * (c) Copyright 2001 Red Hat Inc. <[email protected]>
  5. *
  6. * based on the old aacraid driver that is..
  7. * Adaptec aacraid device driver for Linux.
  8. *
  9. * Copyright (c) 2000-2010 Adaptec, Inc.
  10. * 2010-2015 PMC-Sierra, Inc. ([email protected])
  11. * 2016-2017 Microsemi Corp. ([email protected])
  12. *
  13. * Module Name:
  14. * aacraid.h
  15. *
  16. * Abstract: Contains all routines for control of the aacraid driver
  17. */
  18. #ifndef _AACRAID_H_
  19. #define _AACRAID_H_
  20. #ifndef dprintk
  21. # define dprintk(x)
  22. #endif
  23. /* eg: if (nblank(dprintk(x))) */
  24. #define _nblank(x) #x
  25. #define nblank(x) _nblank(x)[0]
  26. #include <linux/interrupt.h>
  27. #include <linux/completion.h>
  28. #include <linux/pci.h>
  29. #include <scsi/scsi_host.h>
  30. #include <scsi/scsi_cmnd.h>
  31. /*------------------------------------------------------------------------------
  32. * D E F I N E S
  33. *----------------------------------------------------------------------------*/
  34. #define AAC_MAX_MSIX 32 /* vectors */
  35. #define AAC_PCI_MSI_ENABLE 0x8000
  36. enum {
  37. AAC_ENABLE_INTERRUPT = 0x0,
  38. AAC_DISABLE_INTERRUPT,
  39. AAC_ENABLE_MSIX,
  40. AAC_DISABLE_MSIX,
  41. AAC_CLEAR_AIF_BIT,
  42. AAC_CLEAR_SYNC_BIT,
  43. AAC_ENABLE_INTX
  44. };
  45. #define AAC_INT_MODE_INTX (1<<0)
  46. #define AAC_INT_MODE_MSI (1<<1)
  47. #define AAC_INT_MODE_AIF (1<<2)
  48. #define AAC_INT_MODE_SYNC (1<<3)
  49. #define AAC_INT_MODE_MSIX (1<<16)
  50. #define AAC_INT_ENABLE_TYPE1_INTX 0xfffffffb
  51. #define AAC_INT_ENABLE_TYPE1_MSIX 0xfffffffa
  52. #define AAC_INT_DISABLE_ALL 0xffffffff
  53. /* Bit definitions in IOA->Host Interrupt Register */
  54. #define PMC_TRANSITION_TO_OPERATIONAL (1<<31)
  55. #define PMC_IOARCB_TRANSFER_FAILED (1<<28)
  56. #define PMC_IOA_UNIT_CHECK (1<<27)
  57. #define PMC_NO_HOST_RRQ_FOR_CMD_RESPONSE (1<<26)
  58. #define PMC_CRITICAL_IOA_OP_IN_PROGRESS (1<<25)
  59. #define PMC_IOARRIN_LOST (1<<4)
  60. #define PMC_SYSTEM_BUS_MMIO_ERROR (1<<3)
  61. #define PMC_IOA_PROCESSOR_IN_ERROR_STATE (1<<2)
  62. #define PMC_HOST_RRQ_VALID (1<<1)
  63. #define PMC_OPERATIONAL_STATUS (1<<31)
  64. #define PMC_ALLOW_MSIX_VECTOR0 (1<<0)
  65. #define PMC_IOA_ERROR_INTERRUPTS (PMC_IOARCB_TRANSFER_FAILED | \
  66. PMC_IOA_UNIT_CHECK | \
  67. PMC_NO_HOST_RRQ_FOR_CMD_RESPONSE | \
  68. PMC_IOARRIN_LOST | \
  69. PMC_SYSTEM_BUS_MMIO_ERROR | \
  70. PMC_IOA_PROCESSOR_IN_ERROR_STATE)
  71. #define PMC_ALL_INTERRUPT_BITS (PMC_IOA_ERROR_INTERRUPTS | \
  72. PMC_HOST_RRQ_VALID | \
  73. PMC_TRANSITION_TO_OPERATIONAL | \
  74. PMC_ALLOW_MSIX_VECTOR0)
  75. #define PMC_GLOBAL_INT_BIT2 0x00000004
  76. #define PMC_GLOBAL_INT_BIT0 0x00000001
  77. #ifndef AAC_DRIVER_BUILD
  78. # define AAC_DRIVER_BUILD 50983
  79. # define AAC_DRIVER_BRANCH "-custom"
  80. #endif
  81. #define MAXIMUM_NUM_CONTAINERS 32
  82. #define AAC_NUM_MGT_FIB 8
  83. #define AAC_NUM_IO_FIB (1024 - AAC_NUM_MGT_FIB)
  84. #define AAC_NUM_FIB (AAC_NUM_IO_FIB + AAC_NUM_MGT_FIB)
  85. #define AAC_MAX_LUN 256
  86. #define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff)
  87. #define AAC_MAX_32BIT_SGBCOUNT ((unsigned short)256)
  88. #define AAC_DEBUG_INSTRUMENT_AIF_DELETE
  89. #define AAC_MAX_NATIVE_TARGETS 1024
  90. /* Thor: 5 phys. buses: #0: empty, 1-4: 256 targets each */
  91. #define AAC_MAX_BUSES 5
  92. #define AAC_MAX_TARGETS 256
  93. #define AAC_BUS_TARGET_LOOP (AAC_MAX_BUSES * AAC_MAX_TARGETS)
  94. #define AAC_MAX_NATIVE_SIZE 2048
  95. #define FW_ERROR_BUFFER_SIZE 512
  96. #define AAC_SA_TIMEOUT 180
  97. #define AAC_ARC_TIMEOUT 60
  98. #define get_bus_number(x) (x/AAC_MAX_TARGETS)
  99. #define get_target_number(x) (x%AAC_MAX_TARGETS)
  100. /* Thor AIF events */
  101. #define SA_AIF_HOTPLUG (1<<1)
  102. #define SA_AIF_HARDWARE (1<<2)
  103. #define SA_AIF_PDEV_CHANGE (1<<4)
  104. #define SA_AIF_LDEV_CHANGE (1<<5)
  105. #define SA_AIF_BPSTAT_CHANGE (1<<30)
  106. #define SA_AIF_BPCFG_CHANGE (1U<<31)
  107. #define HBA_MAX_SG_EMBEDDED 28
  108. #define HBA_MAX_SG_SEPARATE 90
  109. #define HBA_SENSE_DATA_LEN_MAX 32
  110. #define HBA_REQUEST_TAG_ERROR_FLAG 0x00000002
  111. #define HBA_SGL_FLAGS_EXT 0x80000000UL
  112. struct aac_hba_sgl {
  113. u32 addr_lo; /* Lower 32-bits of SGL element address */
  114. u32 addr_hi; /* Upper 32-bits of SGL element address */
  115. u32 len; /* Length of SGL element in bytes */
  116. u32 flags; /* SGL element flags */
  117. };
  118. enum {
  119. HBA_IU_TYPE_SCSI_CMD_REQ = 0x40,
  120. HBA_IU_TYPE_SCSI_TM_REQ = 0x41,
  121. HBA_IU_TYPE_SATA_REQ = 0x42,
  122. HBA_IU_TYPE_RESP = 0x60,
  123. HBA_IU_TYPE_COALESCED_RESP = 0x61,
  124. HBA_IU_TYPE_INT_COALESCING_CFG_REQ = 0x70
  125. };
  126. enum {
  127. HBA_CMD_BYTE1_DATA_DIR_IN = 0x1,
  128. HBA_CMD_BYTE1_DATA_DIR_OUT = 0x2,
  129. HBA_CMD_BYTE1_DATA_TYPE_DDR = 0x4,
  130. HBA_CMD_BYTE1_CRYPTO_ENABLE = 0x8
  131. };
  132. enum {
  133. HBA_CMD_BYTE1_BITOFF_DATA_DIR_IN = 0x0,
  134. HBA_CMD_BYTE1_BITOFF_DATA_DIR_OUT,
  135. HBA_CMD_BYTE1_BITOFF_DATA_TYPE_DDR,
  136. HBA_CMD_BYTE1_BITOFF_CRYPTO_ENABLE
  137. };
  138. enum {
  139. HBA_RESP_DATAPRES_NO_DATA = 0x0,
  140. HBA_RESP_DATAPRES_RESPONSE_DATA,
  141. HBA_RESP_DATAPRES_SENSE_DATA
  142. };
  143. enum {
  144. HBA_RESP_SVCRES_TASK_COMPLETE = 0x0,
  145. HBA_RESP_SVCRES_FAILURE,
  146. HBA_RESP_SVCRES_TMF_COMPLETE,
  147. HBA_RESP_SVCRES_TMF_SUCCEEDED,
  148. HBA_RESP_SVCRES_TMF_REJECTED,
  149. HBA_RESP_SVCRES_TMF_LUN_INVALID
  150. };
  151. enum {
  152. HBA_RESP_STAT_IO_ERROR = 0x1,
  153. HBA_RESP_STAT_IO_ABORTED,
  154. HBA_RESP_STAT_NO_PATH_TO_DEVICE,
  155. HBA_RESP_STAT_INVALID_DEVICE,
  156. HBA_RESP_STAT_HBAMODE_DISABLED = 0xE,
  157. HBA_RESP_STAT_UNDERRUN = 0x51,
  158. HBA_RESP_STAT_OVERRUN = 0x75
  159. };
  160. struct aac_hba_cmd_req {
  161. u8 iu_type; /* HBA information unit type */
  162. /*
  163. * byte1:
  164. * [1:0] DIR - 0=No data, 0x1 = IN, 0x2 = OUT
  165. * [2] TYPE - 0=PCI, 1=DDR
  166. * [3] CRYPTO_ENABLE - 0=Crypto disabled, 1=Crypto enabled
  167. */
  168. u8 byte1;
  169. u8 reply_qid; /* Host reply queue to post response to */
  170. u8 reserved1;
  171. __le32 it_nexus; /* Device handle for the request */
  172. __le32 request_id; /* Sender context */
  173. /* Lower 32-bits of tweak value for crypto enabled IOs */
  174. __le32 tweak_value_lo;
  175. u8 cdb[16]; /* SCSI CDB of the command */
  176. u8 lun[8]; /* SCSI LUN of the command */
  177. /* Total data length in bytes to be read/written (if any) */
  178. __le32 data_length;
  179. /* [2:0] Task Attribute, [6:3] Command Priority */
  180. u8 attr_prio;
  181. /* Number of SGL elements embedded in the HBA req */
  182. u8 emb_data_desc_count;
  183. __le16 dek_index; /* DEK index for crypto enabled IOs */
  184. /* Lower 32-bits of reserved error data target location on the host */
  185. __le32 error_ptr_lo;
  186. /* Upper 32-bits of reserved error data target location on the host */
  187. __le32 error_ptr_hi;
  188. /* Length of reserved error data area on the host in bytes */
  189. __le32 error_length;
  190. /* Upper 32-bits of tweak value for crypto enabled IOs */
  191. __le32 tweak_value_hi;
  192. struct aac_hba_sgl sge[HBA_MAX_SG_SEPARATE+2]; /* SG list space */
  193. /*
  194. * structure must not exceed
  195. * AAC_MAX_NATIVE_SIZE-FW_ERROR_BUFFER_SIZE
  196. */
  197. };
  198. /* Task Management Functions (TMF) */
  199. #define HBA_TMF_ABORT_TASK 0x01
  200. #define HBA_TMF_LUN_RESET 0x08
  201. struct aac_hba_tm_req {
  202. u8 iu_type; /* HBA information unit type */
  203. u8 reply_qid; /* Host reply queue to post response to */
  204. u8 tmf; /* Task management function */
  205. u8 reserved1;
  206. __le32 it_nexus; /* Device handle for the command */
  207. u8 lun[8]; /* SCSI LUN */
  208. /* Used to hold sender context. */
  209. __le32 request_id; /* Sender context */
  210. __le32 reserved2;
  211. /* Request identifier of managed task */
  212. __le32 managed_request_id; /* Sender context being managed */
  213. __le32 reserved3;
  214. /* Lower 32-bits of reserved error data target location on the host */
  215. __le32 error_ptr_lo;
  216. /* Upper 32-bits of reserved error data target location on the host */
  217. __le32 error_ptr_hi;
  218. /* Length of reserved error data area on the host in bytes */
  219. __le32 error_length;
  220. };
  221. struct aac_hba_reset_req {
  222. u8 iu_type; /* HBA information unit type */
  223. /* 0 - reset specified device, 1 - reset all devices */
  224. u8 reset_type;
  225. u8 reply_qid; /* Host reply queue to post response to */
  226. u8 reserved1;
  227. __le32 it_nexus; /* Device handle for the command */
  228. __le32 request_id; /* Sender context */
  229. /* Lower 32-bits of reserved error data target location on the host */
  230. __le32 error_ptr_lo;
  231. /* Upper 32-bits of reserved error data target location on the host */
  232. __le32 error_ptr_hi;
  233. /* Length of reserved error data area on the host in bytes */
  234. __le32 error_length;
  235. };
  236. struct aac_hba_resp {
  237. u8 iu_type; /* HBA information unit type */
  238. u8 reserved1[3];
  239. __le32 request_identifier; /* sender context */
  240. __le32 reserved2;
  241. u8 service_response; /* SCSI service response */
  242. u8 status; /* SCSI status */
  243. u8 datapres; /* [1:0] - data present, [7:2] - reserved */
  244. u8 sense_response_data_len; /* Sense/response data length */
  245. __le32 residual_count; /* Residual data length in bytes */
  246. /* Sense/response data */
  247. u8 sense_response_buf[HBA_SENSE_DATA_LEN_MAX];
  248. };
  249. struct aac_native_hba {
  250. union {
  251. struct aac_hba_cmd_req cmd;
  252. struct aac_hba_tm_req tmr;
  253. u8 cmd_bytes[AAC_MAX_NATIVE_SIZE-FW_ERROR_BUFFER_SIZE];
  254. } cmd;
  255. union {
  256. struct aac_hba_resp err;
  257. u8 resp_bytes[FW_ERROR_BUFFER_SIZE];
  258. } resp;
  259. };
  260. #define CISS_REPORT_PHYSICAL_LUNS 0xc3
  261. #define WRITE_HOST_WELLNESS 0xa5
  262. #define CISS_IDENTIFY_PHYSICAL_DEVICE 0x15
  263. #define BMIC_IN 0x26
  264. #define BMIC_OUT 0x27
  265. struct aac_ciss_phys_luns_resp {
  266. u8 list_length[4]; /* LUN list length (N-7, big endian) */
  267. u8 resp_flag; /* extended response_flag */
  268. u8 reserved[3];
  269. struct _ciss_lun {
  270. u8 tid[3]; /* Target ID */
  271. u8 bus; /* Bus, flag (bits 6,7) */
  272. u8 level3[2];
  273. u8 level2[2];
  274. u8 node_ident[16]; /* phys. node identifier */
  275. } lun[1]; /* List of phys. devices */
  276. };
  277. /*
  278. * Interrupts
  279. */
  280. #define AAC_MAX_HRRQ 64
  281. struct aac_ciss_identify_pd {
  282. u8 scsi_bus; /* SCSI Bus number on controller */
  283. u8 scsi_id; /* SCSI ID on this bus */
  284. u16 block_size; /* sector size in bytes */
  285. u32 total_blocks; /* number for sectors on drive */
  286. u32 reserved_blocks; /* controller reserved (RIS) */
  287. u8 model[40]; /* Physical Drive Model */
  288. u8 serial_number[40]; /* Drive Serial Number */
  289. u8 firmware_revision[8]; /* drive firmware revision */
  290. u8 scsi_inquiry_bits; /* inquiry byte 7 bits */
  291. u8 compaq_drive_stamp; /* 0 means drive not stamped */
  292. u8 last_failure_reason;
  293. u8 flags;
  294. u8 more_flags;
  295. u8 scsi_lun; /* SCSI LUN for phys drive */
  296. u8 yet_more_flags;
  297. u8 even_more_flags;
  298. u32 spi_speed_rules; /* SPI Speed :Ultra disable diagnose */
  299. u8 phys_connector[2]; /* connector number on controller */
  300. u8 phys_box_on_bus; /* phys enclosure this drive resides */
  301. u8 phys_bay_in_box; /* phys drv bay this drive resides */
  302. u32 rpm; /* Drive rotational speed in rpm */
  303. u8 device_type; /* type of drive */
  304. u8 sata_version; /* only valid when drive_type is SATA */
  305. u64 big_total_block_count;
  306. u64 ris_starting_lba;
  307. u32 ris_size;
  308. u8 wwid[20];
  309. u8 controller_phy_map[32];
  310. u16 phy_count;
  311. u8 phy_connected_dev_type[256];
  312. u8 phy_to_drive_bay_num[256];
  313. u16 phy_to_attached_dev_index[256];
  314. u8 box_index;
  315. u8 spitfire_support;
  316. u16 extra_physical_drive_flags;
  317. u8 negotiated_link_rate[256];
  318. u8 phy_to_phy_map[256];
  319. u8 redundant_path_present_map;
  320. u8 redundant_path_failure_map;
  321. u8 active_path_number;
  322. u16 alternate_paths_phys_connector[8];
  323. u8 alternate_paths_phys_box_on_port[8];
  324. u8 multi_lun_device_lun_count;
  325. u8 minimum_good_fw_revision[8];
  326. u8 unique_inquiry_bytes[20];
  327. u8 current_temperature_degreesC;
  328. u8 temperature_threshold_degreesC;
  329. u8 max_temperature_degreesC;
  330. u8 logical_blocks_per_phys_block_exp; /* phyblocksize = 512 * 2^exp */
  331. u16 current_queue_depth_limit;
  332. u8 switch_name[10];
  333. u16 switch_port;
  334. u8 alternate_paths_switch_name[40];
  335. u8 alternate_paths_switch_port[8];
  336. u16 power_on_hours; /* valid only if gas gauge supported */
  337. u16 percent_endurance_used; /* valid only if gas gauge supported. */
  338. u8 drive_authentication;
  339. u8 smart_carrier_authentication;
  340. u8 smart_carrier_app_fw_version;
  341. u8 smart_carrier_bootloader_fw_version;
  342. u8 SanitizeSecureEraseSupport;
  343. u8 DriveKeyFlags;
  344. u8 encryption_key_name[64];
  345. u32 misc_drive_flags;
  346. u16 dek_index;
  347. u16 drive_encryption_flags;
  348. u8 sanitize_maximum_time[6];
  349. u8 connector_info_mode;
  350. u8 connector_info_number[4];
  351. u8 long_connector_name[64];
  352. u8 device_unique_identifier[16];
  353. u8 padto_2K[17];
  354. } __packed;
  355. /*
  356. * These macros convert from physical channels to virtual channels
  357. */
  358. #define CONTAINER_CHANNEL (0)
  359. #define NATIVE_CHANNEL (1)
  360. #define CONTAINER_TO_CHANNEL(cont) (CONTAINER_CHANNEL)
  361. #define CONTAINER_TO_ID(cont) (cont)
  362. #define CONTAINER_TO_LUN(cont) (0)
  363. #define ENCLOSURE_CHANNEL (3)
  364. #define PMC_DEVICE_S6 0x28b
  365. #define PMC_DEVICE_S7 0x28c
  366. #define PMC_DEVICE_S8 0x28d
  367. #define aac_phys_to_logical(x) ((x)+1)
  368. #define aac_logical_to_phys(x) ((x)?(x)-1:0)
  369. /*
  370. * These macros are for keeping track of
  371. * character device state.
  372. */
  373. #define AAC_CHARDEV_UNREGISTERED (-1)
  374. #define AAC_CHARDEV_NEEDS_REINIT (-2)
  375. /* #define AAC_DETAILED_STATUS_INFO */
  376. struct diskparm
  377. {
  378. int heads;
  379. int sectors;
  380. int cylinders;
  381. };
  382. /*
  383. * Firmware constants
  384. */
  385. #define CT_NONE 0
  386. #define CT_OK 218
  387. #define FT_FILESYS 8 /* ADAPTEC's "FSA"(tm) filesystem */
  388. #define FT_DRIVE 9 /* physical disk - addressable in scsi by bus/id/lun */
  389. /*
  390. * Host side memory scatter gather list
  391. * Used by the adapter for read, write, and readdirplus operations
  392. * We have separate 32 and 64 bit version because even
  393. * on 64 bit systems not all cards support the 64 bit version
  394. */
  395. struct sgentry {
  396. __le32 addr; /* 32-bit address. */
  397. __le32 count; /* Length. */
  398. };
  399. struct user_sgentry {
  400. u32 addr; /* 32-bit address. */
  401. u32 count; /* Length. */
  402. };
  403. struct sgentry64 {
  404. __le32 addr[2]; /* 64-bit addr. 2 pieces for data alignment */
  405. __le32 count; /* Length. */
  406. };
  407. struct user_sgentry64 {
  408. u32 addr[2]; /* 64-bit addr. 2 pieces for data alignment */
  409. u32 count; /* Length. */
  410. };
  411. struct sgentryraw {
  412. __le32 next; /* reserved for F/W use */
  413. __le32 prev; /* reserved for F/W use */
  414. __le32 addr[2];
  415. __le32 count;
  416. __le32 flags; /* reserved for F/W use */
  417. };
  418. struct user_sgentryraw {
  419. u32 next; /* reserved for F/W use */
  420. u32 prev; /* reserved for F/W use */
  421. u32 addr[2];
  422. u32 count;
  423. u32 flags; /* reserved for F/W use */
  424. };
  425. struct sge_ieee1212 {
  426. u32 addrLow;
  427. u32 addrHigh;
  428. u32 length;
  429. u32 flags;
  430. };
  431. /*
  432. * SGMAP
  433. *
  434. * This is the SGMAP structure for all commands that use
  435. * 32-bit addressing.
  436. */
  437. struct sgmap {
  438. __le32 count;
  439. struct sgentry sg[1];
  440. };
  441. struct user_sgmap {
  442. u32 count;
  443. struct user_sgentry sg[1];
  444. };
  445. struct sgmap64 {
  446. __le32 count;
  447. struct sgentry64 sg[1];
  448. };
  449. struct user_sgmap64 {
  450. u32 count;
  451. struct user_sgentry64 sg[1];
  452. };
  453. struct sgmapraw {
  454. __le32 count;
  455. struct sgentryraw sg[1];
  456. };
  457. struct user_sgmapraw {
  458. u32 count;
  459. struct user_sgentryraw sg[1];
  460. };
  461. struct creation_info
  462. {
  463. u8 buildnum; /* e.g., 588 */
  464. u8 usec; /* e.g., 588 */
  465. u8 via; /* e.g., 1 = FSU,
  466. * 2 = API
  467. */
  468. u8 year; /* e.g., 1997 = 97 */
  469. __le32 date; /*
  470. * unsigned Month :4; // 1 - 12
  471. * unsigned Day :6; // 1 - 32
  472. * unsigned Hour :6; // 0 - 23
  473. * unsigned Minute :6; // 0 - 60
  474. * unsigned Second :6; // 0 - 60
  475. */
  476. __le32 serial[2]; /* e.g., 0x1DEADB0BFAFAF001 */
  477. };
  478. /*
  479. * Define all the constants needed for the communication interface
  480. */
  481. /*
  482. * Define how many queue entries each queue will have and the total
  483. * number of entries for the entire communication interface. Also define
  484. * how many queues we support.
  485. *
  486. * This has to match the controller
  487. */
  488. #define NUMBER_OF_COMM_QUEUES 8 // 4 command; 4 response
  489. #define HOST_HIGH_CMD_ENTRIES 4
  490. #define HOST_NORM_CMD_ENTRIES 8
  491. #define ADAP_HIGH_CMD_ENTRIES 4
  492. #define ADAP_NORM_CMD_ENTRIES 512
  493. #define HOST_HIGH_RESP_ENTRIES 4
  494. #define HOST_NORM_RESP_ENTRIES 512
  495. #define ADAP_HIGH_RESP_ENTRIES 4
  496. #define ADAP_NORM_RESP_ENTRIES 8
  497. #define TOTAL_QUEUE_ENTRIES \
  498. (HOST_NORM_CMD_ENTRIES + HOST_HIGH_CMD_ENTRIES + ADAP_NORM_CMD_ENTRIES + ADAP_HIGH_CMD_ENTRIES + \
  499. HOST_NORM_RESP_ENTRIES + HOST_HIGH_RESP_ENTRIES + ADAP_NORM_RESP_ENTRIES + ADAP_HIGH_RESP_ENTRIES)
  500. /*
  501. * Set the queues on a 16 byte alignment
  502. */
  503. #define QUEUE_ALIGNMENT 16
  504. /*
  505. * The queue headers define the Communication Region queues. These
  506. * are physically contiguous and accessible by both the adapter and the
  507. * host. Even though all queue headers are in the same contiguous block
  508. * they will be represented as individual units in the data structures.
  509. */
  510. struct aac_entry {
  511. __le32 size; /* Size in bytes of Fib which this QE points to */
  512. __le32 addr; /* Receiver address of the FIB */
  513. };
  514. /*
  515. * The adapter assumes the ProducerIndex and ConsumerIndex are grouped
  516. * adjacently and in that order.
  517. */
  518. struct aac_qhdr {
  519. __le64 header_addr;/* Address to hand the adapter to access
  520. to this queue head */
  521. __le32 *producer; /* The producer index for this queue (host address) */
  522. __le32 *consumer; /* The consumer index for this queue (host address) */
  523. };
  524. /*
  525. * Define all the events which the adapter would like to notify
  526. * the host of.
  527. */
  528. #define HostNormCmdQue 1 /* Change in host normal priority command queue */
  529. #define HostHighCmdQue 2 /* Change in host high priority command queue */
  530. #define HostNormRespQue 3 /* Change in host normal priority response queue */
  531. #define HostHighRespQue 4 /* Change in host high priority response queue */
  532. #define AdapNormRespNotFull 5
  533. #define AdapHighRespNotFull 6
  534. #define AdapNormCmdNotFull 7
  535. #define AdapHighCmdNotFull 8
  536. #define SynchCommandComplete 9
  537. #define AdapInternalError 0xfe /* The adapter detected an internal error shutting down */
  538. /*
  539. * Define all the events the host wishes to notify the
  540. * adapter of. The first four values much match the Qid the
  541. * corresponding queue.
  542. */
  543. #define AdapNormCmdQue 2
  544. #define AdapHighCmdQue 3
  545. #define AdapNormRespQue 6
  546. #define AdapHighRespQue 7
  547. #define HostShutdown 8
  548. #define HostPowerFail 9
  549. #define FatalCommError 10
  550. #define HostNormRespNotFull 11
  551. #define HostHighRespNotFull 12
  552. #define HostNormCmdNotFull 13
  553. #define HostHighCmdNotFull 14
  554. #define FastIo 15
  555. #define AdapPrintfDone 16
  556. /*
  557. * Define all the queues that the adapter and host use to communicate
  558. * Number them to match the physical queue layout.
  559. */
  560. enum aac_queue_types {
  561. HostNormCmdQueue = 0, /* Adapter to host normal priority command traffic */
  562. HostHighCmdQueue, /* Adapter to host high priority command traffic */
  563. AdapNormCmdQueue, /* Host to adapter normal priority command traffic */
  564. AdapHighCmdQueue, /* Host to adapter high priority command traffic */
  565. HostNormRespQueue, /* Adapter to host normal priority response traffic */
  566. HostHighRespQueue, /* Adapter to host high priority response traffic */
  567. AdapNormRespQueue, /* Host to adapter normal priority response traffic */
  568. AdapHighRespQueue /* Host to adapter high priority response traffic */
  569. };
  570. /*
  571. * Assign type values to the FSA communication data structures
  572. */
  573. #define FIB_MAGIC 0x0001
  574. #define FIB_MAGIC2 0x0004
  575. #define FIB_MAGIC2_64 0x0005
  576. /*
  577. * Define the priority levels the FSA communication routines support.
  578. */
  579. #define FsaNormal 1
  580. /* transport FIB header (PMC) */
  581. struct aac_fib_xporthdr {
  582. __le64 HostAddress; /* FIB host address w/o xport header */
  583. __le32 Size; /* FIB size excluding xport header */
  584. __le32 Handle; /* driver handle to reference the FIB */
  585. __le64 Reserved[2];
  586. };
  587. #define ALIGN32 32
  588. /*
  589. * Define the FIB. The FIB is the where all the requested data and
  590. * command information are put to the application on the FSA adapter.
  591. */
  592. struct aac_fibhdr {
  593. __le32 XferState; /* Current transfer state for this CCB */
  594. __le16 Command; /* Routing information for the destination */
  595. u8 StructType; /* Type FIB */
  596. u8 Unused; /* Unused */
  597. __le16 Size; /* Size of this FIB in bytes */
  598. __le16 SenderSize; /* Size of the FIB in the sender
  599. (for response sizing) */
  600. __le32 SenderFibAddress; /* Host defined data in the FIB */
  601. union {
  602. __le32 ReceiverFibAddress;/* Logical address of this FIB for
  603. the adapter (old) */
  604. __le32 SenderFibAddressHigh;/* upper 32bit of phys. FIB address */
  605. __le32 TimeStamp; /* otherwise timestamp for FW internal use */
  606. } u;
  607. __le32 Handle; /* FIB handle used for MSGU commnunication */
  608. u32 Previous; /* FW internal use */
  609. u32 Next; /* FW internal use */
  610. };
  611. struct hw_fib {
  612. struct aac_fibhdr header;
  613. u8 data[512-sizeof(struct aac_fibhdr)]; // Command specific data
  614. };
  615. /*
  616. * FIB commands
  617. */
  618. #define TestCommandResponse 1
  619. #define TestAdapterCommand 2
  620. /*
  621. * Lowlevel and comm commands
  622. */
  623. #define LastTestCommand 100
  624. #define ReinitHostNormCommandQueue 101
  625. #define ReinitHostHighCommandQueue 102
  626. #define ReinitHostHighRespQueue 103
  627. #define ReinitHostNormRespQueue 104
  628. #define ReinitAdapNormCommandQueue 105
  629. #define ReinitAdapHighCommandQueue 107
  630. #define ReinitAdapHighRespQueue 108
  631. #define ReinitAdapNormRespQueue 109
  632. #define InterfaceShutdown 110
  633. #define DmaCommandFib 120
  634. #define StartProfile 121
  635. #define TermProfile 122
  636. #define SpeedTest 123
  637. #define TakeABreakPt 124
  638. #define RequestPerfData 125
  639. #define SetInterruptDefTimer 126
  640. #define SetInterruptDefCount 127
  641. #define GetInterruptDefStatus 128
  642. #define LastCommCommand 129
  643. /*
  644. * Filesystem commands
  645. */
  646. #define NuFileSystem 300
  647. #define UFS 301
  648. #define HostFileSystem 302
  649. #define LastFileSystemCommand 303
  650. /*
  651. * Container Commands
  652. */
  653. #define ContainerCommand 500
  654. #define ContainerCommand64 501
  655. #define ContainerRawIo 502
  656. #define ContainerRawIo2 503
  657. /*
  658. * Scsi Port commands (scsi passthrough)
  659. */
  660. #define ScsiPortCommand 600
  661. #define ScsiPortCommand64 601
  662. /*
  663. * Misc house keeping and generic adapter initiated commands
  664. */
  665. #define AifRequest 700
  666. #define CheckRevision 701
  667. #define FsaHostShutdown 702
  668. #define RequestAdapterInfo 703
  669. #define IsAdapterPaused 704
  670. #define SendHostTime 705
  671. #define RequestSupplementAdapterInfo 706
  672. #define LastMiscCommand 707
  673. /*
  674. * Commands that will target the failover level on the FSA adapter
  675. */
  676. enum fib_xfer_state {
  677. HostOwned = (1<<0),
  678. AdapterOwned = (1<<1),
  679. FibInitialized = (1<<2),
  680. FibEmpty = (1<<3),
  681. AllocatedFromPool = (1<<4),
  682. SentFromHost = (1<<5),
  683. SentFromAdapter = (1<<6),
  684. ResponseExpected = (1<<7),
  685. NoResponseExpected = (1<<8),
  686. AdapterProcessed = (1<<9),
  687. HostProcessed = (1<<10),
  688. HighPriority = (1<<11),
  689. NormalPriority = (1<<12),
  690. Async = (1<<13),
  691. AsyncIo = (1<<13), // rpbfix: remove with new regime
  692. PageFileIo = (1<<14), // rpbfix: remove with new regime
  693. ShutdownRequest = (1<<15),
  694. LazyWrite = (1<<16), // rpbfix: remove with new regime
  695. AdapterMicroFib = (1<<17),
  696. BIOSFibPath = (1<<18),
  697. FastResponseCapable = (1<<19),
  698. ApiFib = (1<<20), /* Its an API Fib */
  699. /* PMC NEW COMM: There is no more AIF data pending */
  700. NoMoreAifDataAvailable = (1<<21)
  701. };
  702. /*
  703. * The following defines needs to be updated any time there is an
  704. * incompatible change made to the aac_init structure.
  705. */
  706. #define ADAPTER_INIT_STRUCT_REVISION 3
  707. #define ADAPTER_INIT_STRUCT_REVISION_4 4 // rocket science
  708. #define ADAPTER_INIT_STRUCT_REVISION_6 6 /* PMC src */
  709. #define ADAPTER_INIT_STRUCT_REVISION_7 7 /* Denali */
  710. #define ADAPTER_INIT_STRUCT_REVISION_8 8 // Thor
  711. union aac_init
  712. {
  713. struct _r7 {
  714. __le32 init_struct_revision;
  715. __le32 no_of_msix_vectors;
  716. __le32 fsrev;
  717. __le32 comm_header_address;
  718. __le32 fast_io_comm_area_address;
  719. __le32 adapter_fibs_physical_address;
  720. __le32 adapter_fibs_virtual_address;
  721. __le32 adapter_fibs_size;
  722. __le32 adapter_fib_align;
  723. __le32 printfbuf;
  724. __le32 printfbufsiz;
  725. /* number of 4k pages of host phys. mem. */
  726. __le32 host_phys_mem_pages;
  727. /* number of seconds since 1970. */
  728. __le32 host_elapsed_seconds;
  729. /* ADAPTER_INIT_STRUCT_REVISION_4 begins here */
  730. __le32 init_flags; /* flags for supported features */
  731. #define INITFLAGS_NEW_COMM_SUPPORTED 0x00000001
  732. #define INITFLAGS_DRIVER_USES_UTC_TIME 0x00000010
  733. #define INITFLAGS_DRIVER_SUPPORTS_PM 0x00000020
  734. #define INITFLAGS_NEW_COMM_TYPE1_SUPPORTED 0x00000040
  735. #define INITFLAGS_FAST_JBOD_SUPPORTED 0x00000080
  736. #define INITFLAGS_NEW_COMM_TYPE2_SUPPORTED 0x00000100
  737. #define INITFLAGS_DRIVER_SUPPORTS_HBA_MODE 0x00000400
  738. __le32 max_io_commands; /* max outstanding commands */
  739. __le32 max_io_size; /* largest I/O command */
  740. __le32 max_fib_size; /* largest FIB to adapter */
  741. /* ADAPTER_INIT_STRUCT_REVISION_5 begins here */
  742. __le32 max_num_aif; /* max number of aif */
  743. /* ADAPTER_INIT_STRUCT_REVISION_6 begins here */
  744. /* Host RRQ (response queue) for SRC */
  745. __le32 host_rrq_addr_low;
  746. __le32 host_rrq_addr_high;
  747. } r7;
  748. struct _r8 {
  749. /* ADAPTER_INIT_STRUCT_REVISION_8 */
  750. __le32 init_struct_revision;
  751. __le32 rr_queue_count;
  752. __le32 host_elapsed_seconds; /* number of secs since 1970. */
  753. __le32 init_flags;
  754. __le32 max_io_size; /* largest I/O command */
  755. __le32 max_num_aif; /* max number of aif */
  756. __le32 reserved1;
  757. __le32 reserved2;
  758. struct _rrq {
  759. __le32 host_addr_low;
  760. __le32 host_addr_high;
  761. __le16 msix_id;
  762. __le16 element_count;
  763. __le16 comp_thresh;
  764. __le16 unused;
  765. } rrq[1]; /* up to 64 RRQ addresses */
  766. } r8;
  767. };
  768. enum aac_log_level {
  769. LOG_AAC_INIT = 10,
  770. LOG_AAC_INFORMATIONAL = 20,
  771. LOG_AAC_WARNING = 30,
  772. LOG_AAC_LOW_ERROR = 40,
  773. LOG_AAC_MEDIUM_ERROR = 50,
  774. LOG_AAC_HIGH_ERROR = 60,
  775. LOG_AAC_PANIC = 70,
  776. LOG_AAC_DEBUG = 80,
  777. LOG_AAC_WINDBG_PRINT = 90
  778. };
  779. #define FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT 0x030b
  780. #define FSAFS_NTC_FIB_CONTEXT 0x030c
  781. struct aac_dev;
  782. struct fib;
  783. struct scsi_cmnd;
  784. struct adapter_ops
  785. {
  786. /* Low level operations */
  787. void (*adapter_interrupt)(struct aac_dev *dev);
  788. void (*adapter_notify)(struct aac_dev *dev, u32 event);
  789. void (*adapter_disable_int)(struct aac_dev *dev);
  790. void (*adapter_enable_int)(struct aac_dev *dev);
  791. 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);
  792. int (*adapter_check_health)(struct aac_dev *dev);
  793. int (*adapter_restart)(struct aac_dev *dev, int bled, u8 reset_type);
  794. void (*adapter_start)(struct aac_dev *dev);
  795. /* Transport operations */
  796. int (*adapter_ioremap)(struct aac_dev * dev, u32 size);
  797. irq_handler_t adapter_intr;
  798. /* Packet operations */
  799. int (*adapter_deliver)(struct fib * fib);
  800. int (*adapter_bounds)(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba);
  801. int (*adapter_read)(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count);
  802. int (*adapter_write)(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count, int fua);
  803. int (*adapter_scsi)(struct fib * fib, struct scsi_cmnd * cmd);
  804. /* Administrative operations */
  805. int (*adapter_comm)(struct aac_dev * dev, int comm);
  806. };
  807. /*
  808. * Define which interrupt handler needs to be installed
  809. */
  810. struct aac_driver_ident
  811. {
  812. int (*init)(struct aac_dev *dev);
  813. char * name;
  814. char * vname;
  815. char * model;
  816. u16 channels;
  817. int quirks;
  818. };
  819. /*
  820. * Some adapter firmware needs communication memory
  821. * below 2gig. This tells the init function to set the
  822. * dma mask such that fib memory will be allocated where the
  823. * adapter firmware can get to it.
  824. */
  825. #define AAC_QUIRK_31BIT 0x0001
  826. /*
  827. * Some adapter firmware, when the raid card's cache is turned off, can not
  828. * split up scatter gathers in order to deal with the limits of the
  829. * underlying CHIM. This limit is 34 scatter gather elements.
  830. */
  831. #define AAC_QUIRK_34SG 0x0002
  832. /*
  833. * This adapter is a slave (no Firmware)
  834. */
  835. #define AAC_QUIRK_SLAVE 0x0004
  836. /*
  837. * This adapter is a master.
  838. */
  839. #define AAC_QUIRK_MASTER 0x0008
  840. /*
  841. * Some adapter firmware perform poorly when it must split up scatter gathers
  842. * in order to deal with the limits of the underlying CHIM. This limit in this
  843. * class of adapters is 17 scatter gather elements.
  844. */
  845. #define AAC_QUIRK_17SG 0x0010
  846. /*
  847. * Some adapter firmware does not support 64 bit scsi passthrough
  848. * commands.
  849. */
  850. #define AAC_QUIRK_SCSI_32 0x0020
  851. /*
  852. * SRC based adapters support the AifReqEvent functions
  853. */
  854. #define AAC_QUIRK_SRC 0x0040
  855. /*
  856. * The adapter interface specs all queues to be located in the same
  857. * physically contiguous block. The host structure that defines the
  858. * commuication queues will assume they are each a separate physically
  859. * contiguous memory region that will support them all being one big
  860. * contiguous block.
  861. * There is a command and response queue for each level and direction of
  862. * commuication. These regions are accessed by both the host and adapter.
  863. */
  864. struct aac_queue {
  865. u64 logical; /*address we give the adapter */
  866. struct aac_entry *base; /*system virtual address */
  867. struct aac_qhdr headers; /*producer,consumer q headers*/
  868. u32 entries; /*Number of queue entries */
  869. wait_queue_head_t qfull; /*Event to wait on if q full */
  870. wait_queue_head_t cmdready; /*Cmd ready from the adapter */
  871. /* This is only valid for adapter to host command queues. */
  872. spinlock_t *lock; /* Spinlock for this queue must take this lock before accessing the lock */
  873. spinlock_t lockdata; /* Actual lock (used only on one side of the lock) */
  874. struct list_head cmdq; /* A queue of FIBs which need to be prcessed by the FS thread. This is */
  875. /* only valid for command queues which receive entries from the adapter. */
  876. /* Number of entries on outstanding queue. */
  877. atomic_t numpending;
  878. struct aac_dev * dev; /* Back pointer to adapter structure */
  879. };
  880. /*
  881. * Message queues. The order here is important, see also the
  882. * queue type ordering
  883. */
  884. struct aac_queue_block
  885. {
  886. struct aac_queue queue[8];
  887. };
  888. /*
  889. * SaP1 Message Unit Registers
  890. */
  891. struct sa_drawbridge_CSR {
  892. /* Offset | Name */
  893. __le32 reserved[10]; /* 00h-27h | Reserved */
  894. u8 LUT_Offset; /* 28h | Lookup Table Offset */
  895. u8 reserved1[3]; /* 29h-2bh | Reserved */
  896. __le32 LUT_Data; /* 2ch | Looup Table Data */
  897. __le32 reserved2[26]; /* 30h-97h | Reserved */
  898. __le16 PRICLEARIRQ; /* 98h | Primary Clear Irq */
  899. __le16 SECCLEARIRQ; /* 9ah | Secondary Clear Irq */
  900. __le16 PRISETIRQ; /* 9ch | Primary Set Irq */
  901. __le16 SECSETIRQ; /* 9eh | Secondary Set Irq */
  902. __le16 PRICLEARIRQMASK;/* a0h | Primary Clear Irq Mask */
  903. __le16 SECCLEARIRQMASK;/* a2h | Secondary Clear Irq Mask */
  904. __le16 PRISETIRQMASK; /* a4h | Primary Set Irq Mask */
  905. __le16 SECSETIRQMASK; /* a6h | Secondary Set Irq Mask */
  906. __le32 MAILBOX0; /* a8h | Scratchpad 0 */
  907. __le32 MAILBOX1; /* ach | Scratchpad 1 */
  908. __le32 MAILBOX2; /* b0h | Scratchpad 2 */
  909. __le32 MAILBOX3; /* b4h | Scratchpad 3 */
  910. __le32 MAILBOX4; /* b8h | Scratchpad 4 */
  911. __le32 MAILBOX5; /* bch | Scratchpad 5 */
  912. __le32 MAILBOX6; /* c0h | Scratchpad 6 */
  913. __le32 MAILBOX7; /* c4h | Scratchpad 7 */
  914. __le32 ROM_Setup_Data; /* c8h | Rom Setup and Data */
  915. __le32 ROM_Control_Addr;/* cch | Rom Control and Address */
  916. __le32 reserved3[12]; /* d0h-ffh | reserved */
  917. __le32 LUT[64]; /* 100h-1ffh | Lookup Table Entries */
  918. };
  919. #define Mailbox0 SaDbCSR.MAILBOX0
  920. #define Mailbox1 SaDbCSR.MAILBOX1
  921. #define Mailbox2 SaDbCSR.MAILBOX2
  922. #define Mailbox3 SaDbCSR.MAILBOX3
  923. #define Mailbox4 SaDbCSR.MAILBOX4
  924. #define Mailbox5 SaDbCSR.MAILBOX5
  925. #define Mailbox6 SaDbCSR.MAILBOX6
  926. #define Mailbox7 SaDbCSR.MAILBOX7
  927. #define DoorbellReg_p SaDbCSR.PRISETIRQ
  928. #define DoorbellReg_s SaDbCSR.SECSETIRQ
  929. #define DoorbellClrReg_p SaDbCSR.PRICLEARIRQ
  930. #define DOORBELL_0 0x0001
  931. #define DOORBELL_1 0x0002
  932. #define DOORBELL_2 0x0004
  933. #define DOORBELL_3 0x0008
  934. #define DOORBELL_4 0x0010
  935. #define DOORBELL_5 0x0020
  936. #define DOORBELL_6 0x0040
  937. #define PrintfReady DOORBELL_5
  938. #define PrintfDone DOORBELL_5
  939. struct sa_registers {
  940. struct sa_drawbridge_CSR SaDbCSR; /* 98h - c4h */
  941. };
  942. #define SA_INIT_NUM_MSIXVECTORS 1
  943. #define SA_MINIPORT_REVISION SA_INIT_NUM_MSIXVECTORS
  944. #define sa_readw(AEP, CSR) readl(&((AEP)->regs.sa->CSR))
  945. #define sa_readl(AEP, CSR) readl(&((AEP)->regs.sa->CSR))
  946. #define sa_writew(AEP, CSR, value) writew(value, &((AEP)->regs.sa->CSR))
  947. #define sa_writel(AEP, CSR, value) writel(value, &((AEP)->regs.sa->CSR))
  948. /*
  949. * Rx Message Unit Registers
  950. */
  951. struct rx_mu_registers {
  952. /* Local | PCI*| Name */
  953. __le32 ARSR; /* 1300h | 00h | APIC Register Select Register */
  954. __le32 reserved0; /* 1304h | 04h | Reserved */
  955. __le32 AWR; /* 1308h | 08h | APIC Window Register */
  956. __le32 reserved1; /* 130Ch | 0Ch | Reserved */
  957. __le32 IMRx[2]; /* 1310h | 10h | Inbound Message Registers */
  958. __le32 OMRx[2]; /* 1318h | 18h | Outbound Message Registers */
  959. __le32 IDR; /* 1320h | 20h | Inbound Doorbell Register */
  960. __le32 IISR; /* 1324h | 24h | Inbound Interrupt
  961. Status Register */
  962. __le32 IIMR; /* 1328h | 28h | Inbound Interrupt
  963. Mask Register */
  964. __le32 ODR; /* 132Ch | 2Ch | Outbound Doorbell Register */
  965. __le32 OISR; /* 1330h | 30h | Outbound Interrupt
  966. Status Register */
  967. __le32 OIMR; /* 1334h | 34h | Outbound Interrupt
  968. Mask Register */
  969. __le32 reserved2; /* 1338h | 38h | Reserved */
  970. __le32 reserved3; /* 133Ch | 3Ch | Reserved */
  971. __le32 InboundQueue;/* 1340h | 40h | Inbound Queue Port relative to firmware */
  972. __le32 OutboundQueue;/*1344h | 44h | Outbound Queue Port relative to firmware */
  973. /* * Must access through ATU Inbound
  974. Translation Window */
  975. };
  976. struct rx_inbound {
  977. __le32 Mailbox[8];
  978. };
  979. #define INBOUNDDOORBELL_0 0x00000001
  980. #define INBOUNDDOORBELL_1 0x00000002
  981. #define INBOUNDDOORBELL_2 0x00000004
  982. #define INBOUNDDOORBELL_3 0x00000008
  983. #define INBOUNDDOORBELL_4 0x00000010
  984. #define INBOUNDDOORBELL_5 0x00000020
  985. #define INBOUNDDOORBELL_6 0x00000040
  986. #define OUTBOUNDDOORBELL_0 0x00000001
  987. #define OUTBOUNDDOORBELL_1 0x00000002
  988. #define OUTBOUNDDOORBELL_2 0x00000004
  989. #define OUTBOUNDDOORBELL_3 0x00000008
  990. #define OUTBOUNDDOORBELL_4 0x00000010
  991. #define InboundDoorbellReg MUnit.IDR
  992. #define OutboundDoorbellReg MUnit.ODR
  993. struct rx_registers {
  994. struct rx_mu_registers MUnit; /* 1300h - 1347h */
  995. __le32 reserved1[2]; /* 1348h - 134ch */
  996. struct rx_inbound IndexRegs;
  997. };
  998. #define rx_readb(AEP, CSR) readb(&((AEP)->regs.rx->CSR))
  999. #define rx_readl(AEP, CSR) readl(&((AEP)->regs.rx->CSR))
  1000. #define rx_writeb(AEP, CSR, value) writeb(value, &((AEP)->regs.rx->CSR))
  1001. #define rx_writel(AEP, CSR, value) writel(value, &((AEP)->regs.rx->CSR))
  1002. /*
  1003. * Rkt Message Unit Registers (same as Rx, except a larger reserve region)
  1004. */
  1005. #define rkt_mu_registers rx_mu_registers
  1006. #define rkt_inbound rx_inbound
  1007. struct rkt_registers {
  1008. struct rkt_mu_registers MUnit; /* 1300h - 1347h */
  1009. __le32 reserved1[1006]; /* 1348h - 22fch */
  1010. struct rkt_inbound IndexRegs; /* 2300h - */
  1011. };
  1012. #define rkt_readb(AEP, CSR) readb(&((AEP)->regs.rkt->CSR))
  1013. #define rkt_readl(AEP, CSR) readl(&((AEP)->regs.rkt->CSR))
  1014. #define rkt_writeb(AEP, CSR, value) writeb(value, &((AEP)->regs.rkt->CSR))
  1015. #define rkt_writel(AEP, CSR, value) writel(value, &((AEP)->regs.rkt->CSR))
  1016. /*
  1017. * PMC SRC message unit registers
  1018. */
  1019. #define src_inbound rx_inbound
  1020. struct src_mu_registers {
  1021. /* PCI*| Name */
  1022. __le32 reserved0[6]; /* 00h | Reserved */
  1023. __le32 IOAR[2]; /* 18h | IOA->host interrupt register */
  1024. __le32 IDR; /* 20h | Inbound Doorbell Register */
  1025. __le32 IISR; /* 24h | Inbound Int. Status Register */
  1026. __le32 reserved1[3]; /* 28h | Reserved */
  1027. __le32 OIMR; /* 34h | Outbound Int. Mask Register */
  1028. __le32 reserved2[25]; /* 38h | Reserved */
  1029. __le32 ODR_R; /* 9ch | Outbound Doorbell Read */
  1030. __le32 ODR_C; /* a0h | Outbound Doorbell Clear */
  1031. __le32 reserved3[3]; /* a4h | Reserved */
  1032. __le32 SCR0; /* b0h | Scratchpad 0 */
  1033. __le32 reserved4[2]; /* b4h | Reserved */
  1034. __le32 OMR; /* bch | Outbound Message Register */
  1035. __le32 IQ_L; /* c0h | Inbound Queue (Low address) */
  1036. __le32 IQ_H; /* c4h | Inbound Queue (High address) */
  1037. __le32 ODR_MSI; /* c8h | MSI register for sync./AIF */
  1038. __le32 reserved5; /* cch | Reserved */
  1039. __le32 IQN_L; /* d0h | Inbound (native cmd) low */
  1040. __le32 IQN_H; /* d4h | Inbound (native cmd) high */
  1041. };
  1042. struct src_registers {
  1043. struct src_mu_registers MUnit; /* 00h - cbh */
  1044. union {
  1045. struct {
  1046. __le32 reserved1[130786]; /* d8h - 7fc5fh */
  1047. struct src_inbound IndexRegs; /* 7fc60h */
  1048. } tupelo;
  1049. struct {
  1050. __le32 reserved1[970]; /* d8h - fffh */
  1051. struct src_inbound IndexRegs; /* 1000h */
  1052. } denali;
  1053. } u;
  1054. };
  1055. #define src_readb(AEP, CSR) readb(&((AEP)->regs.src.bar0->CSR))
  1056. #define src_readl(AEP, CSR) readl(&((AEP)->regs.src.bar0->CSR))
  1057. #define src_writeb(AEP, CSR, value) writeb(value, \
  1058. &((AEP)->regs.src.bar0->CSR))
  1059. #define src_writel(AEP, CSR, value) writel(value, \
  1060. &((AEP)->regs.src.bar0->CSR))
  1061. #if defined(writeq)
  1062. #define src_writeq(AEP, CSR, value) writeq(value, \
  1063. &((AEP)->regs.src.bar0->CSR))
  1064. #endif
  1065. #define SRC_ODR_SHIFT 12
  1066. #define SRC_IDR_SHIFT 9
  1067. #define SRC_MSI_READ_MASK 0x1000
  1068. typedef void (*fib_callback)(void *ctxt, struct fib *fibctx);
  1069. struct aac_fib_context {
  1070. s16 type; // used for verification of structure
  1071. s16 size;
  1072. u32 unique; // unique value representing this context
  1073. ulong jiffies; // used for cleanup - dmb changed to ulong
  1074. struct list_head next; // used to link context's into a linked list
  1075. struct completion completion; // this is used to wait for the next fib to arrive.
  1076. int wait; // Set to true when thread is in WaitForSingleObject
  1077. unsigned long count; // total number of FIBs on FibList
  1078. struct list_head fib_list; // this holds fibs and their attachd hw_fibs
  1079. };
  1080. struct sense_data {
  1081. u8 error_code; /* 70h (current errors), 71h(deferred errors) */
  1082. u8 valid:1; /* A valid bit of one indicates that the information */
  1083. /* field contains valid information as defined in the
  1084. * SCSI-2 Standard.
  1085. */
  1086. u8 segment_number; /* Only used for COPY, COMPARE, or COPY AND VERIFY Commands */
  1087. u8 sense_key:4; /* Sense Key */
  1088. u8 reserved:1;
  1089. u8 ILI:1; /* Incorrect Length Indicator */
  1090. u8 EOM:1; /* End Of Medium - reserved for random access devices */
  1091. u8 filemark:1; /* Filemark - reserved for random access devices */
  1092. u8 information[4]; /* for direct-access devices, contains the unsigned
  1093. * logical block address or residue associated with
  1094. * the sense key
  1095. */
  1096. u8 add_sense_len; /* number of additional sense bytes to follow this field */
  1097. u8 cmnd_info[4]; /* not used */
  1098. u8 ASC; /* Additional Sense Code */
  1099. u8 ASCQ; /* Additional Sense Code Qualifier */
  1100. u8 FRUC; /* Field Replaceable Unit Code - not used */
  1101. u8 bit_ptr:3; /* indicates which byte of the CDB or parameter data
  1102. * was in error
  1103. */
  1104. u8 BPV:1; /* bit pointer valid (BPV): 1- indicates that
  1105. * the bit_ptr field has valid value
  1106. */
  1107. u8 reserved2:2;
  1108. u8 CD:1; /* command data bit: 1- illegal parameter in CDB.
  1109. * 0- illegal parameter in data.
  1110. */
  1111. u8 SKSV:1;
  1112. u8 field_ptr[2]; /* byte of the CDB or parameter data in error */
  1113. };
  1114. struct fsa_dev_info {
  1115. u64 last;
  1116. u64 size;
  1117. u32 type;
  1118. u32 config_waiting_on;
  1119. unsigned long config_waiting_stamp;
  1120. u16 queue_depth;
  1121. u8 config_needed;
  1122. u8 valid;
  1123. u8 ro;
  1124. u8 locked;
  1125. u8 deleted;
  1126. char devname[8];
  1127. struct sense_data sense_data;
  1128. u32 block_size;
  1129. u8 identifier[16];
  1130. };
  1131. struct fib {
  1132. void *next; /* this is used by the allocator */
  1133. s16 type;
  1134. s16 size;
  1135. /*
  1136. * The Adapter that this I/O is destined for.
  1137. */
  1138. struct aac_dev *dev;
  1139. /*
  1140. * This is the event the sendfib routine will wait on if the
  1141. * caller did not pass one and this is synch io.
  1142. */
  1143. struct completion event_wait;
  1144. spinlock_t event_lock;
  1145. u32 done; /* gets set to 1 when fib is complete */
  1146. fib_callback callback;
  1147. void *callback_data;
  1148. u32 flags; // u32 dmb was ulong
  1149. /*
  1150. * And for the internal issue/reply queues (we may be able
  1151. * to merge these two)
  1152. */
  1153. struct list_head fiblink;
  1154. void *data;
  1155. u32 vector_no;
  1156. struct hw_fib *hw_fib_va; /* also used for native */
  1157. dma_addr_t hw_fib_pa; /* physical address of hw_fib*/
  1158. dma_addr_t hw_sgl_pa; /* extra sgl for native */
  1159. dma_addr_t hw_error_pa; /* error buffer for native */
  1160. u32 hbacmd_size; /* cmd size for native */
  1161. };
  1162. #define AAC_INIT 0
  1163. #define AAC_RESCAN 1
  1164. #define AAC_DEVTYPE_RAID_MEMBER 1
  1165. #define AAC_DEVTYPE_ARC_RAW 2
  1166. #define AAC_DEVTYPE_NATIVE_RAW 3
  1167. #define AAC_RESCAN_DELAY (10 * HZ)
  1168. struct aac_hba_map_info {
  1169. __le32 rmw_nexus; /* nexus for native HBA devices */
  1170. u8 devtype; /* device type */
  1171. s8 reset_state; /* 0 - no reset, 1..x - */
  1172. /* after xth TM LUN reset */
  1173. u16 qd_limit;
  1174. u32 scan_counter;
  1175. struct aac_ciss_identify_pd *safw_identify_resp;
  1176. };
  1177. /*
  1178. * Adapter Information Block
  1179. *
  1180. * This is returned by the RequestAdapterInfo block
  1181. */
  1182. struct aac_adapter_info
  1183. {
  1184. __le32 platform;
  1185. __le32 cpu;
  1186. __le32 subcpu;
  1187. __le32 clock;
  1188. __le32 execmem;
  1189. __le32 buffermem;
  1190. __le32 totalmem;
  1191. __le32 kernelrev;
  1192. __le32 kernelbuild;
  1193. __le32 monitorrev;
  1194. __le32 monitorbuild;
  1195. __le32 hwrev;
  1196. __le32 hwbuild;
  1197. __le32 biosrev;
  1198. __le32 biosbuild;
  1199. __le32 cluster;
  1200. __le32 clusterchannelmask;
  1201. __le32 serial[2];
  1202. __le32 battery;
  1203. __le32 options;
  1204. __le32 OEM;
  1205. };
  1206. struct aac_supplement_adapter_info
  1207. {
  1208. u8 adapter_type_text[17+1];
  1209. u8 pad[2];
  1210. __le32 flash_memory_byte_size;
  1211. __le32 flash_image_id;
  1212. __le32 max_number_ports;
  1213. __le32 version;
  1214. __le32 feature_bits;
  1215. u8 slot_number;
  1216. u8 reserved_pad0[3];
  1217. u8 build_date[12];
  1218. __le32 current_number_ports;
  1219. struct {
  1220. u8 assembly_pn[8];
  1221. u8 fru_pn[8];
  1222. u8 battery_fru_pn[8];
  1223. u8 ec_version_string[8];
  1224. u8 tsid[12];
  1225. } vpd_info;
  1226. __le32 flash_firmware_revision;
  1227. __le32 flash_firmware_build;
  1228. __le32 raid_type_morph_options;
  1229. __le32 flash_firmware_boot_revision;
  1230. __le32 flash_firmware_boot_build;
  1231. u8 mfg_pcba_serial_no[12];
  1232. u8 mfg_wwn_name[8];
  1233. __le32 supported_options2;
  1234. __le32 struct_expansion;
  1235. /* StructExpansion == 1 */
  1236. __le32 feature_bits3;
  1237. __le32 supported_performance_modes;
  1238. u8 host_bus_type; /* uses HOST_BUS_TYPE_xxx defines */
  1239. u8 host_bus_width; /* actual width in bits or links */
  1240. u16 host_bus_speed; /* actual bus speed/link rate in MHz */
  1241. u8 max_rrc_drives; /* max. number of ITP-RRC drives/pool */
  1242. u8 max_disk_xtasks; /* max. possible num of DiskX Tasks */
  1243. u8 cpld_ver_loaded;
  1244. u8 cpld_ver_in_flash;
  1245. __le64 max_rrc_capacity;
  1246. __le32 compiled_max_hist_log_level;
  1247. u8 custom_board_name[12];
  1248. u16 supported_cntlr_mode; /* identify supported controller mode */
  1249. u16 reserved_for_future16;
  1250. __le32 supported_options3; /* reserved for future options */
  1251. __le16 virt_device_bus; /* virt. SCSI device for Thor */
  1252. __le16 virt_device_target;
  1253. __le16 virt_device_lun;
  1254. __le16 unused;
  1255. __le32 reserved_for_future_growth[68];
  1256. };
  1257. #define AAC_FEATURE_FALCON cpu_to_le32(0x00000010)
  1258. #define AAC_FEATURE_JBOD cpu_to_le32(0x08000000)
  1259. /* SupportedOptions2 */
  1260. #define AAC_OPTION_MU_RESET cpu_to_le32(0x00000001)
  1261. #define AAC_OPTION_IGNORE_RESET cpu_to_le32(0x00000002)
  1262. #define AAC_OPTION_POWER_MANAGEMENT cpu_to_le32(0x00000004)
  1263. #define AAC_OPTION_DOORBELL_RESET cpu_to_le32(0x00004000)
  1264. /* 4KB sector size */
  1265. #define AAC_OPTION_VARIABLE_BLOCK_SIZE cpu_to_le32(0x00040000)
  1266. /* 240 simple volume support */
  1267. #define AAC_OPTION_SUPPORTED_240_VOLUMES cpu_to_le32(0x10000000)
  1268. /*
  1269. * Supports FIB dump sync command send prior to IOP_RESET
  1270. */
  1271. #define AAC_OPTION_SUPPORTED3_IOP_RESET_FIB_DUMP cpu_to_le32(0x00004000)
  1272. #define AAC_SIS_VERSION_V3 3
  1273. #define AAC_SIS_SLOT_UNKNOWN 0xFF
  1274. #define GetBusInfo 0x00000009
  1275. struct aac_bus_info {
  1276. __le32 Command; /* VM_Ioctl */
  1277. __le32 ObjType; /* FT_DRIVE */
  1278. __le32 MethodId; /* 1 = SCSI Layer */
  1279. __le32 ObjectId; /* Handle */
  1280. __le32 CtlCmd; /* GetBusInfo */
  1281. };
  1282. struct aac_bus_info_response {
  1283. __le32 Status; /* ST_OK */
  1284. __le32 ObjType;
  1285. __le32 MethodId; /* unused */
  1286. __le32 ObjectId; /* unused */
  1287. __le32 CtlCmd; /* unused */
  1288. __le32 ProbeComplete;
  1289. __le32 BusCount;
  1290. __le32 TargetsPerBus;
  1291. u8 InitiatorBusId[10];
  1292. u8 BusValid[10];
  1293. };
  1294. /*
  1295. * Battery platforms
  1296. */
  1297. #define AAC_BAT_REQ_PRESENT (1)
  1298. #define AAC_BAT_REQ_NOTPRESENT (2)
  1299. #define AAC_BAT_OPT_PRESENT (3)
  1300. #define AAC_BAT_OPT_NOTPRESENT (4)
  1301. #define AAC_BAT_NOT_SUPPORTED (5)
  1302. /*
  1303. * cpu types
  1304. */
  1305. #define AAC_CPU_SIMULATOR (1)
  1306. #define AAC_CPU_I960 (2)
  1307. #define AAC_CPU_STRONGARM (3)
  1308. /*
  1309. * Supported Options
  1310. */
  1311. #define AAC_OPT_SNAPSHOT cpu_to_le32(1)
  1312. #define AAC_OPT_CLUSTERS cpu_to_le32(1<<1)
  1313. #define AAC_OPT_WRITE_CACHE cpu_to_le32(1<<2)
  1314. #define AAC_OPT_64BIT_DATA cpu_to_le32(1<<3)
  1315. #define AAC_OPT_HOST_TIME_FIB cpu_to_le32(1<<4)
  1316. #define AAC_OPT_RAID50 cpu_to_le32(1<<5)
  1317. #define AAC_OPT_4GB_WINDOW cpu_to_le32(1<<6)
  1318. #define AAC_OPT_SCSI_UPGRADEABLE cpu_to_le32(1<<7)
  1319. #define AAC_OPT_SOFT_ERR_REPORT cpu_to_le32(1<<8)
  1320. #define AAC_OPT_SUPPORTED_RECONDITION cpu_to_le32(1<<9)
  1321. #define AAC_OPT_SGMAP_HOST64 cpu_to_le32(1<<10)
  1322. #define AAC_OPT_ALARM cpu_to_le32(1<<11)
  1323. #define AAC_OPT_NONDASD cpu_to_le32(1<<12)
  1324. #define AAC_OPT_SCSI_MANAGED cpu_to_le32(1<<13)
  1325. #define AAC_OPT_RAID_SCSI_MODE cpu_to_le32(1<<14)
  1326. #define AAC_OPT_SUPPLEMENT_ADAPTER_INFO cpu_to_le32(1<<16)
  1327. #define AAC_OPT_NEW_COMM cpu_to_le32(1<<17)
  1328. #define AAC_OPT_NEW_COMM_64 cpu_to_le32(1<<18)
  1329. #define AAC_OPT_EXTENDED cpu_to_le32(1<<23)
  1330. #define AAC_OPT_NATIVE_HBA cpu_to_le32(1<<25)
  1331. #define AAC_OPT_NEW_COMM_TYPE1 cpu_to_le32(1<<28)
  1332. #define AAC_OPT_NEW_COMM_TYPE2 cpu_to_le32(1<<29)
  1333. #define AAC_OPT_NEW_COMM_TYPE3 cpu_to_le32(1<<30)
  1334. #define AAC_OPT_NEW_COMM_TYPE4 cpu_to_le32(1<<31)
  1335. #define AAC_COMM_PRODUCER 0
  1336. #define AAC_COMM_MESSAGE 1
  1337. #define AAC_COMM_MESSAGE_TYPE1 3
  1338. #define AAC_COMM_MESSAGE_TYPE2 4
  1339. #define AAC_COMM_MESSAGE_TYPE3 5
  1340. #define AAC_EXTOPT_SA_FIRMWARE cpu_to_le32(1<<1)
  1341. #define AAC_EXTOPT_SOFT_RESET cpu_to_le32(1<<16)
  1342. /* MSIX context */
  1343. struct aac_msix_ctx {
  1344. int vector_no;
  1345. struct aac_dev *dev;
  1346. };
  1347. struct aac_dev
  1348. {
  1349. struct list_head entry;
  1350. const char *name;
  1351. int id;
  1352. /*
  1353. * negotiated FIB settings
  1354. */
  1355. unsigned int max_fib_size;
  1356. unsigned int sg_tablesize;
  1357. unsigned int max_num_aif;
  1358. unsigned int max_cmd_size; /* max_fib_size or MAX_NATIVE */
  1359. /*
  1360. * Map for 128 fib objects (64k)
  1361. */
  1362. dma_addr_t hw_fib_pa; /* also used for native cmd */
  1363. struct hw_fib *hw_fib_va; /* also used for native cmd */
  1364. struct hw_fib *aif_base_va;
  1365. /*
  1366. * Fib Headers
  1367. */
  1368. struct fib *fibs;
  1369. struct fib *free_fib;
  1370. spinlock_t fib_lock;
  1371. struct mutex ioctl_mutex;
  1372. struct mutex scan_mutex;
  1373. struct aac_queue_block *queues;
  1374. /*
  1375. * The user API will use an IOCTL to register itself to receive
  1376. * FIBs from the adapter. The following list is used to keep
  1377. * track of all the threads that have requested these FIBs. The
  1378. * mutex is used to synchronize access to all data associated
  1379. * with the adapter fibs.
  1380. */
  1381. struct list_head fib_list;
  1382. struct adapter_ops a_ops;
  1383. unsigned long fsrev; /* Main driver's revision number */
  1384. resource_size_t base_start; /* main IO base */
  1385. resource_size_t dbg_base; /* address of UART
  1386. * debug buffer */
  1387. resource_size_t base_size, dbg_size; /* Size of
  1388. * mapped in region */
  1389. /*
  1390. * Holds initialization info
  1391. * to communicate with adapter
  1392. */
  1393. union aac_init *init;
  1394. dma_addr_t init_pa; /* Holds physical address of the init struct */
  1395. /* response queue (if AAC_COMM_MESSAGE_TYPE1) */
  1396. __le32 *host_rrq;
  1397. dma_addr_t host_rrq_pa; /* phys. address */
  1398. /* index into rrq buffer */
  1399. u32 host_rrq_idx[AAC_MAX_MSIX];
  1400. atomic_t rrq_outstanding[AAC_MAX_MSIX];
  1401. u32 fibs_pushed_no;
  1402. struct pci_dev *pdev; /* Our PCI interface */
  1403. /* pointer to buffer used for printf's from the adapter */
  1404. void *printfbuf;
  1405. void *comm_addr; /* Base address of Comm area */
  1406. dma_addr_t comm_phys; /* Physical Address of Comm area */
  1407. size_t comm_size;
  1408. struct Scsi_Host *scsi_host_ptr;
  1409. int maximum_num_containers;
  1410. int maximum_num_physicals;
  1411. int maximum_num_channels;
  1412. struct fsa_dev_info *fsa_dev;
  1413. struct task_struct *thread;
  1414. struct delayed_work safw_rescan_work;
  1415. struct delayed_work src_reinit_aif_worker;
  1416. int cardtype;
  1417. /*
  1418. *This lock will protect the two 32-bit
  1419. *writes to the Inbound Queue
  1420. */
  1421. spinlock_t iq_lock;
  1422. /*
  1423. * The following is the device specific extension.
  1424. */
  1425. #ifndef AAC_MIN_FOOTPRINT_SIZE
  1426. # define AAC_MIN_FOOTPRINT_SIZE 8192
  1427. # define AAC_MIN_SRC_BAR0_SIZE 0x400000
  1428. # define AAC_MIN_SRC_BAR1_SIZE 0x800
  1429. # define AAC_MIN_SRCV_BAR0_SIZE 0x100000
  1430. # define AAC_MIN_SRCV_BAR1_SIZE 0x400
  1431. #endif
  1432. union
  1433. {
  1434. struct sa_registers __iomem *sa;
  1435. struct rx_registers __iomem *rx;
  1436. struct rkt_registers __iomem *rkt;
  1437. struct {
  1438. struct src_registers __iomem *bar0;
  1439. char __iomem *bar1;
  1440. } src;
  1441. } regs;
  1442. volatile void __iomem *base, *dbg_base_mapped;
  1443. volatile struct rx_inbound __iomem *IndexRegs;
  1444. u32 OIMR; /* Mask Register Cache */
  1445. /*
  1446. * AIF thread states
  1447. */
  1448. u32 aif_thread;
  1449. struct aac_adapter_info adapter_info;
  1450. struct aac_supplement_adapter_info supplement_adapter_info;
  1451. /* These are in adapter info but they are in the io flow so
  1452. * lets break them out so we don't have to do an AND to check them
  1453. */
  1454. u8 nondasd_support;
  1455. u8 jbod;
  1456. u8 cache_protected;
  1457. u8 dac_support;
  1458. u8 needs_dac;
  1459. u8 raid_scsi_mode;
  1460. u8 comm_interface;
  1461. u8 raw_io_interface;
  1462. u8 raw_io_64;
  1463. u8 printf_enabled;
  1464. u8 in_reset;
  1465. u8 in_soft_reset;
  1466. u8 msi;
  1467. u8 sa_firmware;
  1468. int management_fib_count;
  1469. spinlock_t manage_lock;
  1470. spinlock_t sync_lock;
  1471. int sync_mode;
  1472. struct fib *sync_fib;
  1473. struct list_head sync_fib_list;
  1474. u32 doorbell_mask;
  1475. u32 max_msix; /* max. MSI-X vectors */
  1476. u32 vector_cap; /* MSI-X vector capab.*/
  1477. int msi_enabled; /* MSI/MSI-X enabled */
  1478. atomic_t msix_counter;
  1479. u32 scan_counter;
  1480. struct msix_entry msixentry[AAC_MAX_MSIX];
  1481. struct aac_msix_ctx aac_msix[AAC_MAX_MSIX]; /* context */
  1482. struct aac_hba_map_info hba_map[AAC_MAX_BUSES][AAC_MAX_TARGETS];
  1483. struct aac_ciss_phys_luns_resp *safw_phys_luns;
  1484. u8 adapter_shutdown;
  1485. u32 handle_pci_error;
  1486. bool init_reset;
  1487. u8 soft_reset_support;
  1488. u8 use_map_queue;
  1489. };
  1490. #define aac_adapter_interrupt(dev) \
  1491. (dev)->a_ops.adapter_interrupt(dev)
  1492. #define aac_adapter_notify(dev, event) \
  1493. (dev)->a_ops.adapter_notify(dev, event)
  1494. #define aac_adapter_disable_int(dev) \
  1495. (dev)->a_ops.adapter_disable_int(dev)
  1496. #define aac_adapter_enable_int(dev) \
  1497. (dev)->a_ops.adapter_enable_int(dev)
  1498. #define aac_adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4) \
  1499. (dev)->a_ops.adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4)
  1500. #define aac_adapter_restart(dev, bled, reset_type) \
  1501. ((dev)->a_ops.adapter_restart(dev, bled, reset_type))
  1502. #define aac_adapter_start(dev) \
  1503. ((dev)->a_ops.adapter_start(dev))
  1504. #define aac_adapter_ioremap(dev, size) \
  1505. (dev)->a_ops.adapter_ioremap(dev, size)
  1506. #define aac_adapter_deliver(fib) \
  1507. ((fib)->dev)->a_ops.adapter_deliver(fib)
  1508. #define aac_adapter_bounds(dev,cmd,lba) \
  1509. dev->a_ops.adapter_bounds(dev,cmd,lba)
  1510. #define aac_adapter_read(fib,cmd,lba,count) \
  1511. ((fib)->dev)->a_ops.adapter_read(fib,cmd,lba,count)
  1512. #define aac_adapter_write(fib,cmd,lba,count,fua) \
  1513. ((fib)->dev)->a_ops.adapter_write(fib,cmd,lba,count,fua)
  1514. #define aac_adapter_scsi(fib,cmd) \
  1515. ((fib)->dev)->a_ops.adapter_scsi(fib,cmd)
  1516. #define aac_adapter_comm(dev,comm) \
  1517. (dev)->a_ops.adapter_comm(dev, comm)
  1518. #define FIB_CONTEXT_FLAG_TIMED_OUT (0x00000001)
  1519. #define FIB_CONTEXT_FLAG (0x00000002)
  1520. #define FIB_CONTEXT_FLAG_WAIT (0x00000004)
  1521. #define FIB_CONTEXT_FLAG_FASTRESP (0x00000008)
  1522. #define FIB_CONTEXT_FLAG_NATIVE_HBA (0x00000010)
  1523. #define FIB_CONTEXT_FLAG_NATIVE_HBA_TMF (0x00000020)
  1524. #define FIB_CONTEXT_FLAG_SCSI_CMD (0x00000040)
  1525. #define FIB_CONTEXT_FLAG_EH_RESET (0x00000080)
  1526. /*
  1527. * Define the command values
  1528. */
  1529. #define Null 0
  1530. #define GetAttributes 1
  1531. #define SetAttributes 2
  1532. #define Lookup 3
  1533. #define ReadLink 4
  1534. #define Read 5
  1535. #define Write 6
  1536. #define Create 7
  1537. #define MakeDirectory 8
  1538. #define SymbolicLink 9
  1539. #define MakeNode 10
  1540. #define Removex 11
  1541. #define RemoveDirectoryx 12
  1542. #define Rename 13
  1543. #define Link 14
  1544. #define ReadDirectory 15
  1545. #define ReadDirectoryPlus 16
  1546. #define FileSystemStatus 17
  1547. #define FileSystemInfo 18
  1548. #define PathConfigure 19
  1549. #define Commit 20
  1550. #define Mount 21
  1551. #define UnMount 22
  1552. #define Newfs 23
  1553. #define FsCheck 24
  1554. #define FsSync 25
  1555. #define SimReadWrite 26
  1556. #define SetFileSystemStatus 27
  1557. #define BlockRead 28
  1558. #define BlockWrite 29
  1559. #define NvramIoctl 30
  1560. #define FsSyncWait 31
  1561. #define ClearArchiveBit 32
  1562. #define SetAcl 33
  1563. #define GetAcl 34
  1564. #define AssignAcl 35
  1565. #define FaultInsertion 36 /* Fault Insertion Command */
  1566. #define CrazyCache 37 /* Crazycache */
  1567. #define MAX_FSACOMMAND_NUM 38
  1568. /*
  1569. * Define the status returns. These are very unixlike although
  1570. * most are not in fact used
  1571. */
  1572. #define ST_OK 0
  1573. #define ST_PERM 1
  1574. #define ST_NOENT 2
  1575. #define ST_IO 5
  1576. #define ST_NXIO 6
  1577. #define ST_E2BIG 7
  1578. #define ST_MEDERR 8
  1579. #define ST_ACCES 13
  1580. #define ST_EXIST 17
  1581. #define ST_XDEV 18
  1582. #define ST_NODEV 19
  1583. #define ST_NOTDIR 20
  1584. #define ST_ISDIR 21
  1585. #define ST_INVAL 22
  1586. #define ST_FBIG 27
  1587. #define ST_NOSPC 28
  1588. #define ST_ROFS 30
  1589. #define ST_MLINK 31
  1590. #define ST_WOULDBLOCK 35
  1591. #define ST_NAMETOOLONG 63
  1592. #define ST_NOTEMPTY 66
  1593. #define ST_DQUOT 69
  1594. #define ST_STALE 70
  1595. #define ST_REMOTE 71
  1596. #define ST_NOT_READY 72
  1597. #define ST_BADHANDLE 10001
  1598. #define ST_NOT_SYNC 10002
  1599. #define ST_BAD_COOKIE 10003
  1600. #define ST_NOTSUPP 10004
  1601. #define ST_TOOSMALL 10005
  1602. #define ST_SERVERFAULT 10006
  1603. #define ST_BADTYPE 10007
  1604. #define ST_JUKEBOX 10008
  1605. #define ST_NOTMOUNTED 10009
  1606. #define ST_MAINTMODE 10010
  1607. #define ST_STALEACL 10011
  1608. /*
  1609. * On writes how does the client want the data written.
  1610. */
  1611. #define CACHE_CSTABLE 1
  1612. #define CACHE_UNSTABLE 2
  1613. /*
  1614. * Lets the client know at which level the data was committed on
  1615. * a write request
  1616. */
  1617. #define CMFILE_SYNCH_NVRAM 1
  1618. #define CMDATA_SYNCH_NVRAM 2
  1619. #define CMFILE_SYNCH 3
  1620. #define CMDATA_SYNCH 4
  1621. #define CMUNSTABLE 5
  1622. #define RIO_TYPE_WRITE 0x0000
  1623. #define RIO_TYPE_READ 0x0001
  1624. #define RIO_SUREWRITE 0x0008
  1625. #define RIO2_IO_TYPE 0x0003
  1626. #define RIO2_IO_TYPE_WRITE 0x0000
  1627. #define RIO2_IO_TYPE_READ 0x0001
  1628. #define RIO2_IO_TYPE_VERIFY 0x0002
  1629. #define RIO2_IO_ERROR 0x0004
  1630. #define RIO2_IO_SUREWRITE 0x0008
  1631. #define RIO2_SGL_CONFORMANT 0x0010
  1632. #define RIO2_SG_FORMAT 0xF000
  1633. #define RIO2_SG_FORMAT_ARC 0x0000
  1634. #define RIO2_SG_FORMAT_SRL 0x1000
  1635. #define RIO2_SG_FORMAT_IEEE1212 0x2000
  1636. struct aac_read
  1637. {
  1638. __le32 command;
  1639. __le32 cid;
  1640. __le32 block;
  1641. __le32 count;
  1642. struct sgmap sg; // Must be last in struct because it is variable
  1643. };
  1644. struct aac_read64
  1645. {
  1646. __le32 command;
  1647. __le16 cid;
  1648. __le16 sector_count;
  1649. __le32 block;
  1650. __le16 pad;
  1651. __le16 flags;
  1652. struct sgmap64 sg; // Must be last in struct because it is variable
  1653. };
  1654. struct aac_read_reply
  1655. {
  1656. __le32 status;
  1657. __le32 count;
  1658. };
  1659. struct aac_write
  1660. {
  1661. __le32 command;
  1662. __le32 cid;
  1663. __le32 block;
  1664. __le32 count;
  1665. __le32 stable; // Not used
  1666. struct sgmap sg; // Must be last in struct because it is variable
  1667. };
  1668. struct aac_write64
  1669. {
  1670. __le32 command;
  1671. __le16 cid;
  1672. __le16 sector_count;
  1673. __le32 block;
  1674. __le16 pad;
  1675. __le16 flags;
  1676. struct sgmap64 sg; // Must be last in struct because it is variable
  1677. };
  1678. struct aac_write_reply
  1679. {
  1680. __le32 status;
  1681. __le32 count;
  1682. __le32 committed;
  1683. };
  1684. struct aac_raw_io
  1685. {
  1686. __le32 block[2];
  1687. __le32 count;
  1688. __le16 cid;
  1689. __le16 flags; /* 00 W, 01 R */
  1690. __le16 bpTotal; /* reserved for F/W use */
  1691. __le16 bpComplete; /* reserved for F/W use */
  1692. struct sgmapraw sg;
  1693. };
  1694. struct aac_raw_io2 {
  1695. __le32 blockLow;
  1696. __le32 blockHigh;
  1697. __le32 byteCount;
  1698. __le16 cid;
  1699. __le16 flags; /* RIO2 flags */
  1700. __le32 sgeFirstSize; /* size of first sge el. */
  1701. __le32 sgeNominalSize; /* size of 2nd sge el. (if conformant) */
  1702. u8 sgeCnt; /* only 8 bits required */
  1703. u8 bpTotal; /* reserved for F/W use */
  1704. u8 bpComplete; /* reserved for F/W use */
  1705. u8 sgeFirstIndex; /* reserved for F/W use */
  1706. u8 unused[4];
  1707. struct sge_ieee1212 sge[];
  1708. };
  1709. #define CT_FLUSH_CACHE 129
  1710. struct aac_synchronize {
  1711. __le32 command; /* VM_ContainerConfig */
  1712. __le32 type; /* CT_FLUSH_CACHE */
  1713. __le32 cid;
  1714. __le32 parm1;
  1715. __le32 parm2;
  1716. __le32 parm3;
  1717. __le32 parm4;
  1718. __le32 count; /* sizeof(((struct aac_synchronize_reply *)NULL)->data) */
  1719. };
  1720. struct aac_synchronize_reply {
  1721. __le32 dummy0;
  1722. __le32 dummy1;
  1723. __le32 status; /* CT_OK */
  1724. __le32 parm1;
  1725. __le32 parm2;
  1726. __le32 parm3;
  1727. __le32 parm4;
  1728. __le32 parm5;
  1729. u8 data[16];
  1730. };
  1731. #define CT_POWER_MANAGEMENT 245
  1732. #define CT_PM_START_UNIT 2
  1733. #define CT_PM_STOP_UNIT 3
  1734. #define CT_PM_UNIT_IMMEDIATE 1
  1735. struct aac_power_management {
  1736. __le32 command; /* VM_ContainerConfig */
  1737. __le32 type; /* CT_POWER_MANAGEMENT */
  1738. __le32 sub; /* CT_PM_* */
  1739. __le32 cid;
  1740. __le32 parm; /* CT_PM_sub_* */
  1741. };
  1742. #define CT_PAUSE_IO 65
  1743. #define CT_RELEASE_IO 66
  1744. struct aac_pause {
  1745. __le32 command; /* VM_ContainerConfig */
  1746. __le32 type; /* CT_PAUSE_IO */
  1747. __le32 timeout; /* 10ms ticks */
  1748. __le32 min;
  1749. __le32 noRescan;
  1750. __le32 parm3;
  1751. __le32 parm4;
  1752. __le32 count; /* sizeof(((struct aac_pause_reply *)NULL)->data) */
  1753. };
  1754. struct aac_srb
  1755. {
  1756. __le32 function;
  1757. __le32 channel;
  1758. __le32 id;
  1759. __le32 lun;
  1760. __le32 timeout;
  1761. __le32 flags;
  1762. __le32 count; // Data xfer size
  1763. __le32 retry_limit;
  1764. __le32 cdb_size;
  1765. u8 cdb[16];
  1766. struct sgmap sg;
  1767. };
  1768. /*
  1769. * This and associated data structs are used by the
  1770. * ioctl caller and are in cpu order.
  1771. */
  1772. struct user_aac_srb
  1773. {
  1774. u32 function;
  1775. u32 channel;
  1776. u32 id;
  1777. u32 lun;
  1778. u32 timeout;
  1779. u32 flags;
  1780. u32 count; // Data xfer size
  1781. u32 retry_limit;
  1782. u32 cdb_size;
  1783. u8 cdb[16];
  1784. struct user_sgmap sg;
  1785. };
  1786. #define AAC_SENSE_BUFFERSIZE 30
  1787. struct aac_srb_reply
  1788. {
  1789. __le32 status;
  1790. __le32 srb_status;
  1791. __le32 scsi_status;
  1792. __le32 data_xfer_length;
  1793. __le32 sense_data_size;
  1794. u8 sense_data[AAC_SENSE_BUFFERSIZE]; // Can this be SCSI_SENSE_BUFFERSIZE
  1795. };
  1796. struct aac_srb_unit {
  1797. struct aac_srb srb;
  1798. struct aac_srb_reply srb_reply;
  1799. };
  1800. /*
  1801. * SRB Flags
  1802. */
  1803. #define SRB_NoDataXfer 0x0000
  1804. #define SRB_DisableDisconnect 0x0004
  1805. #define SRB_DisableSynchTransfer 0x0008
  1806. #define SRB_BypassFrozenQueue 0x0010
  1807. #define SRB_DisableAutosense 0x0020
  1808. #define SRB_DataIn 0x0040
  1809. #define SRB_DataOut 0x0080
  1810. /*
  1811. * SRB Functions - set in aac_srb->function
  1812. */
  1813. #define SRBF_ExecuteScsi 0x0000
  1814. #define SRBF_ClaimDevice 0x0001
  1815. #define SRBF_IO_Control 0x0002
  1816. #define SRBF_ReceiveEvent 0x0003
  1817. #define SRBF_ReleaseQueue 0x0004
  1818. #define SRBF_AttachDevice 0x0005
  1819. #define SRBF_ReleaseDevice 0x0006
  1820. #define SRBF_Shutdown 0x0007
  1821. #define SRBF_Flush 0x0008
  1822. #define SRBF_AbortCommand 0x0010
  1823. #define SRBF_ReleaseRecovery 0x0011
  1824. #define SRBF_ResetBus 0x0012
  1825. #define SRBF_ResetDevice 0x0013
  1826. #define SRBF_TerminateIO 0x0014
  1827. #define SRBF_FlushQueue 0x0015
  1828. #define SRBF_RemoveDevice 0x0016
  1829. #define SRBF_DomainValidation 0x0017
  1830. /*
  1831. * SRB SCSI Status - set in aac_srb->scsi_status
  1832. */
  1833. #define SRB_STATUS_PENDING 0x00
  1834. #define SRB_STATUS_SUCCESS 0x01
  1835. #define SRB_STATUS_ABORTED 0x02
  1836. #define SRB_STATUS_ABORT_FAILED 0x03
  1837. #define SRB_STATUS_ERROR 0x04
  1838. #define SRB_STATUS_BUSY 0x05
  1839. #define SRB_STATUS_INVALID_REQUEST 0x06
  1840. #define SRB_STATUS_INVALID_PATH_ID 0x07
  1841. #define SRB_STATUS_NO_DEVICE 0x08
  1842. #define SRB_STATUS_TIMEOUT 0x09
  1843. #define SRB_STATUS_SELECTION_TIMEOUT 0x0A
  1844. #define SRB_STATUS_COMMAND_TIMEOUT 0x0B
  1845. #define SRB_STATUS_MESSAGE_REJECTED 0x0D
  1846. #define SRB_STATUS_BUS_RESET 0x0E
  1847. #define SRB_STATUS_PARITY_ERROR 0x0F
  1848. #define SRB_STATUS_REQUEST_SENSE_FAILED 0x10
  1849. #define SRB_STATUS_NO_HBA 0x11
  1850. #define SRB_STATUS_DATA_OVERRUN 0x12
  1851. #define SRB_STATUS_UNEXPECTED_BUS_FREE 0x13
  1852. #define SRB_STATUS_PHASE_SEQUENCE_FAILURE 0x14
  1853. #define SRB_STATUS_BAD_SRB_BLOCK_LENGTH 0x15
  1854. #define SRB_STATUS_REQUEST_FLUSHED 0x16
  1855. #define SRB_STATUS_DELAYED_RETRY 0x17
  1856. #define SRB_STATUS_INVALID_LUN 0x20
  1857. #define SRB_STATUS_INVALID_TARGET_ID 0x21
  1858. #define SRB_STATUS_BAD_FUNCTION 0x22
  1859. #define SRB_STATUS_ERROR_RECOVERY 0x23
  1860. #define SRB_STATUS_NOT_STARTED 0x24
  1861. #define SRB_STATUS_NOT_IN_USE 0x30
  1862. #define SRB_STATUS_FORCE_ABORT 0x31
  1863. #define SRB_STATUS_DOMAIN_VALIDATION_FAIL 0x32
  1864. /*
  1865. * Object-Server / Volume-Manager Dispatch Classes
  1866. */
  1867. #define VM_Null 0
  1868. #define VM_NameServe 1
  1869. #define VM_ContainerConfig 2
  1870. #define VM_Ioctl 3
  1871. #define VM_FilesystemIoctl 4
  1872. #define VM_CloseAll 5
  1873. #define VM_CtBlockRead 6
  1874. #define VM_CtBlockWrite 7
  1875. #define VM_SliceBlockRead 8 /* raw access to configured "storage objects" */
  1876. #define VM_SliceBlockWrite 9
  1877. #define VM_DriveBlockRead 10 /* raw access to physical devices */
  1878. #define VM_DriveBlockWrite 11
  1879. #define VM_EnclosureMgt 12 /* enclosure management */
  1880. #define VM_Unused 13 /* used to be diskset management */
  1881. #define VM_CtBlockVerify 14
  1882. #define VM_CtPerf 15 /* performance test */
  1883. #define VM_CtBlockRead64 16
  1884. #define VM_CtBlockWrite64 17
  1885. #define VM_CtBlockVerify64 18
  1886. #define VM_CtHostRead64 19
  1887. #define VM_CtHostWrite64 20
  1888. #define VM_DrvErrTblLog 21
  1889. #define VM_NameServe64 22
  1890. #define VM_NameServeAllBlk 30
  1891. #define MAX_VMCOMMAND_NUM 23 /* used for sizing stats array - leave last */
  1892. /*
  1893. * Descriptive information (eg, vital stats)
  1894. * that a content manager might report. The
  1895. * FileArray filesystem component is one example
  1896. * of a content manager. Raw mode might be
  1897. * another.
  1898. */
  1899. struct aac_fsinfo {
  1900. __le32 fsTotalSize; /* Consumed by fs, incl. metadata */
  1901. __le32 fsBlockSize;
  1902. __le32 fsFragSize;
  1903. __le32 fsMaxExtendSize;
  1904. __le32 fsSpaceUnits;
  1905. __le32 fsMaxNumFiles;
  1906. __le32 fsNumFreeFiles;
  1907. __le32 fsInodeDensity;
  1908. }; /* valid iff ObjType == FT_FILESYS && !(ContentState & FSCS_NOTCLEAN) */
  1909. struct aac_blockdevinfo {
  1910. __le32 block_size;
  1911. __le32 logical_phys_map;
  1912. u8 identifier[16];
  1913. };
  1914. union aac_contentinfo {
  1915. struct aac_fsinfo filesys;
  1916. struct aac_blockdevinfo bdevinfo;
  1917. };
  1918. /*
  1919. * Query for Container Configuration Status
  1920. */
  1921. #define CT_GET_CONFIG_STATUS 147
  1922. struct aac_get_config_status {
  1923. __le32 command; /* VM_ContainerConfig */
  1924. __le32 type; /* CT_GET_CONFIG_STATUS */
  1925. __le32 parm1;
  1926. __le32 parm2;
  1927. __le32 parm3;
  1928. __le32 parm4;
  1929. __le32 parm5;
  1930. __le32 count; /* sizeof(((struct aac_get_config_status_resp *)NULL)->data) */
  1931. };
  1932. #define CFACT_CONTINUE 0
  1933. #define CFACT_PAUSE 1
  1934. #define CFACT_ABORT 2
  1935. struct aac_get_config_status_resp {
  1936. __le32 response; /* ST_OK */
  1937. __le32 dummy0;
  1938. __le32 status; /* CT_OK */
  1939. __le32 parm1;
  1940. __le32 parm2;
  1941. __le32 parm3;
  1942. __le32 parm4;
  1943. __le32 parm5;
  1944. struct {
  1945. __le32 action; /* CFACT_CONTINUE, CFACT_PAUSE or CFACT_ABORT */
  1946. __le16 flags;
  1947. __le16 count;
  1948. } data;
  1949. };
  1950. /*
  1951. * Accept the configuration as-is
  1952. */
  1953. #define CT_COMMIT_CONFIG 152
  1954. struct aac_commit_config {
  1955. __le32 command; /* VM_ContainerConfig */
  1956. __le32 type; /* CT_COMMIT_CONFIG */
  1957. };
  1958. /*
  1959. * Query for Container Configuration Status
  1960. */
  1961. #define CT_GET_CONTAINER_COUNT 4
  1962. struct aac_get_container_count {
  1963. __le32 command; /* VM_ContainerConfig */
  1964. __le32 type; /* CT_GET_CONTAINER_COUNT */
  1965. };
  1966. struct aac_get_container_count_resp {
  1967. __le32 response; /* ST_OK */
  1968. __le32 dummy0;
  1969. __le32 MaxContainers;
  1970. __le32 ContainerSwitchEntries;
  1971. __le32 MaxPartitions;
  1972. __le32 MaxSimpleVolumes;
  1973. };
  1974. /*
  1975. * Query for "mountable" objects, ie, objects that are typically
  1976. * associated with a drive letter on the client (host) side.
  1977. */
  1978. struct aac_mntent {
  1979. __le32 oid;
  1980. u8 name[16]; /* if applicable */
  1981. struct creation_info create_info; /* if applicable */
  1982. __le32 capacity;
  1983. __le32 vol; /* substrate structure */
  1984. __le32 obj; /* FT_FILESYS, etc. */
  1985. __le32 state; /* unready for mounting,
  1986. readonly, etc. */
  1987. union aac_contentinfo fileinfo; /* Info specific to content
  1988. manager (eg, filesystem) */
  1989. __le32 altoid; /* != oid <==> snapshot or
  1990. broken mirror exists */
  1991. __le32 capacityhigh;
  1992. };
  1993. #define FSCS_NOTCLEAN 0x0001 /* fsck is necessary before mounting */
  1994. #define FSCS_READONLY 0x0002 /* possible result of broken mirror */
  1995. #define FSCS_HIDDEN 0x0004 /* should be ignored - set during a clear */
  1996. #define FSCS_NOT_READY 0x0008 /* Array spinning up to fulfil request */
  1997. struct aac_query_mount {
  1998. __le32 command;
  1999. __le32 type;
  2000. __le32 count;
  2001. };
  2002. struct aac_mount {
  2003. __le32 status;
  2004. __le32 type; /* should be same as that requested */
  2005. __le32 count;
  2006. struct aac_mntent mnt[1];
  2007. };
  2008. #define CT_READ_NAME 130
  2009. struct aac_get_name {
  2010. __le32 command; /* VM_ContainerConfig */
  2011. __le32 type; /* CT_READ_NAME */
  2012. __le32 cid;
  2013. __le32 parm1;
  2014. __le32 parm2;
  2015. __le32 parm3;
  2016. __le32 parm4;
  2017. __le32 count; /* sizeof(((struct aac_get_name_resp *)NULL)->data) */
  2018. };
  2019. struct aac_get_name_resp {
  2020. __le32 dummy0;
  2021. __le32 dummy1;
  2022. __le32 status; /* CT_OK */
  2023. __le32 parm1;
  2024. __le32 parm2;
  2025. __le32 parm3;
  2026. __le32 parm4;
  2027. __le32 parm5;
  2028. u8 data[17];
  2029. };
  2030. #define CT_CID_TO_32BITS_UID 165
  2031. struct aac_get_serial {
  2032. __le32 command; /* VM_ContainerConfig */
  2033. __le32 type; /* CT_CID_TO_32BITS_UID */
  2034. __le32 cid;
  2035. };
  2036. struct aac_get_serial_resp {
  2037. __le32 dummy0;
  2038. __le32 dummy1;
  2039. __le32 status; /* CT_OK */
  2040. __le32 uid;
  2041. };
  2042. /*
  2043. * The following command is sent to shut down each container.
  2044. */
  2045. struct aac_close {
  2046. __le32 command;
  2047. __le32 cid;
  2048. };
  2049. struct aac_query_disk
  2050. {
  2051. s32 cnum;
  2052. s32 bus;
  2053. s32 id;
  2054. s32 lun;
  2055. u32 valid;
  2056. u32 locked;
  2057. u32 deleted;
  2058. s32 instance;
  2059. s8 name[10];
  2060. u32 unmapped;
  2061. };
  2062. struct aac_delete_disk {
  2063. u32 disknum;
  2064. u32 cnum;
  2065. };
  2066. struct fib_ioctl
  2067. {
  2068. u32 fibctx;
  2069. s32 wait;
  2070. char __user *fib;
  2071. };
  2072. struct revision
  2073. {
  2074. u32 compat;
  2075. __le32 version;
  2076. __le32 build;
  2077. };
  2078. /*
  2079. * Ugly - non Linux like ioctl coding for back compat.
  2080. */
  2081. #define CTL_CODE(function, method) ( \
  2082. (4<< 16) | ((function) << 2) | (method) \
  2083. )
  2084. /*
  2085. * Define the method codes for how buffers are passed for I/O and FS
  2086. * controls
  2087. */
  2088. #define METHOD_BUFFERED 0
  2089. #define METHOD_NEITHER 3
  2090. /*
  2091. * Filesystem ioctls
  2092. */
  2093. #define FSACTL_SENDFIB CTL_CODE(2050, METHOD_BUFFERED)
  2094. #define FSACTL_SEND_RAW_SRB CTL_CODE(2067, METHOD_BUFFERED)
  2095. #define FSACTL_DELETE_DISK 0x163
  2096. #define FSACTL_QUERY_DISK 0x173
  2097. #define FSACTL_OPEN_GET_ADAPTER_FIB CTL_CODE(2100, METHOD_BUFFERED)
  2098. #define FSACTL_GET_NEXT_ADAPTER_FIB CTL_CODE(2101, METHOD_BUFFERED)
  2099. #define FSACTL_CLOSE_GET_ADAPTER_FIB CTL_CODE(2102, METHOD_BUFFERED)
  2100. #define FSACTL_MINIPORT_REV_CHECK CTL_CODE(2107, METHOD_BUFFERED)
  2101. #define FSACTL_GET_PCI_INFO CTL_CODE(2119, METHOD_BUFFERED)
  2102. #define FSACTL_FORCE_DELETE_DISK CTL_CODE(2120, METHOD_NEITHER)
  2103. #define FSACTL_GET_CONTAINERS 2131
  2104. #define FSACTL_SEND_LARGE_FIB CTL_CODE(2138, METHOD_BUFFERED)
  2105. #define FSACTL_RESET_IOP CTL_CODE(2140, METHOD_BUFFERED)
  2106. #define FSACTL_GET_HBA_INFO CTL_CODE(2150, METHOD_BUFFERED)
  2107. /* flags defined for IOP & HW SOFT RESET */
  2108. #define HW_IOP_RESET 0x01
  2109. #define HW_SOFT_RESET 0x02
  2110. #define IOP_HWSOFT_RESET (HW_IOP_RESET | HW_SOFT_RESET)
  2111. /* HW Soft Reset register offset */
  2112. #define IBW_SWR_OFFSET 0x4000
  2113. #define SOFT_RESET_TIME 60
  2114. struct aac_common
  2115. {
  2116. /*
  2117. * If this value is set to 1 then interrupt moderation will occur
  2118. * in the base commuication support.
  2119. */
  2120. u32 irq_mod;
  2121. u32 peak_fibs;
  2122. u32 zero_fibs;
  2123. u32 fib_timeouts;
  2124. /*
  2125. * Statistical counters in debug mode
  2126. */
  2127. #ifdef DBG
  2128. u32 FibsSent;
  2129. u32 FibRecved;
  2130. u32 NativeSent;
  2131. u32 NativeRecved;
  2132. u32 NoResponseSent;
  2133. u32 NoResponseRecved;
  2134. u32 AsyncSent;
  2135. u32 AsyncRecved;
  2136. u32 NormalSent;
  2137. u32 NormalRecved;
  2138. #endif
  2139. };
  2140. extern struct aac_common aac_config;
  2141. /*
  2142. * This is for management ioctl purpose only.
  2143. */
  2144. struct aac_hba_info {
  2145. u8 driver_name[50];
  2146. u8 adapter_number;
  2147. u8 system_io_bus_number;
  2148. u8 device_number;
  2149. u32 function_number;
  2150. u32 vendor_id;
  2151. u32 device_id;
  2152. u32 sub_vendor_id;
  2153. u32 sub_system_id;
  2154. u32 mapped_base_address_size;
  2155. u32 base_physical_address_high_part;
  2156. u32 base_physical_address_low_part;
  2157. u32 max_command_size;
  2158. u32 max_fib_size;
  2159. u32 max_scatter_gather_from_os;
  2160. u32 max_scatter_gather_to_fw;
  2161. u32 max_outstanding_fibs;
  2162. u32 queue_start_threshold;
  2163. u32 queue_dump_threshold;
  2164. u32 max_io_size_queued;
  2165. u32 outstanding_io;
  2166. u32 firmware_build_number;
  2167. u32 bios_build_number;
  2168. u32 driver_build_number;
  2169. u32 serial_number_high_part;
  2170. u32 serial_number_low_part;
  2171. u32 supported_options;
  2172. u32 feature_bits;
  2173. u32 currentnumber_ports;
  2174. u8 new_comm_interface:1;
  2175. u8 new_commands_supported:1;
  2176. u8 disable_passthrough:1;
  2177. u8 expose_non_dasd:1;
  2178. u8 queue_allowed:1;
  2179. u8 bled_check_enabled:1;
  2180. u8 reserved1:1;
  2181. u8 reserted2:1;
  2182. u32 reserved3[10];
  2183. };
  2184. /*
  2185. * The following macro is used when sending and receiving FIBs. It is
  2186. * only used for debugging.
  2187. */
  2188. #ifdef DBG
  2189. #define FIB_COUNTER_INCREMENT(counter) (counter)++
  2190. #else
  2191. #define FIB_COUNTER_INCREMENT(counter)
  2192. #endif
  2193. /*
  2194. * Adapter direct commands
  2195. * Monitor/Kernel API
  2196. */
  2197. #define BREAKPOINT_REQUEST 0x00000004
  2198. #define INIT_STRUCT_BASE_ADDRESS 0x00000005
  2199. #define READ_PERMANENT_PARAMETERS 0x0000000a
  2200. #define WRITE_PERMANENT_PARAMETERS 0x0000000b
  2201. #define HOST_CRASHING 0x0000000d
  2202. #define SEND_SYNCHRONOUS_FIB 0x0000000c
  2203. #define COMMAND_POST_RESULTS 0x00000014
  2204. #define GET_ADAPTER_PROPERTIES 0x00000019
  2205. #define GET_DRIVER_BUFFER_PROPERTIES 0x00000023
  2206. #define RCV_TEMP_READINGS 0x00000025
  2207. #define GET_COMM_PREFERRED_SETTINGS 0x00000026
  2208. #define IOP_RESET_FW_FIB_DUMP 0x00000034
  2209. #define DROP_IO 0x00000035
  2210. #define IOP_RESET 0x00001000
  2211. #define IOP_RESET_ALWAYS 0x00001001
  2212. #define RE_INIT_ADAPTER 0x000000ee
  2213. #define IOP_SRC_RESET_MASK 0x00000100
  2214. /*
  2215. * Adapter Status Register
  2216. *
  2217. * Phase Staus mailbox is 32bits:
  2218. * <31:16> = Phase Status
  2219. * <15:0> = Phase
  2220. *
  2221. * The adapter reports is present state through the phase. Only
  2222. * a single phase should be ever be set. Each phase can have multiple
  2223. * phase status bits to provide more detailed information about the
  2224. * state of the board. Care should be taken to ensure that any phase
  2225. * status bits that are set when changing the phase are also valid
  2226. * for the new phase or be cleared out. Adapter software (monitor,
  2227. * iflash, kernel) is responsible for properly maintining the phase
  2228. * status mailbox when it is running.
  2229. *
  2230. * MONKER_API Phases
  2231. *
  2232. * Phases are bit oriented. It is NOT valid to have multiple bits set
  2233. */
  2234. #define SELF_TEST_FAILED 0x00000004
  2235. #define MONITOR_PANIC 0x00000020
  2236. #define KERNEL_BOOTING 0x00000040
  2237. #define KERNEL_UP_AND_RUNNING 0x00000080
  2238. #define KERNEL_PANIC 0x00000100
  2239. #define FLASH_UPD_PENDING 0x00002000
  2240. #define FLASH_UPD_SUCCESS 0x00004000
  2241. #define FLASH_UPD_FAILED 0x00008000
  2242. #define INVALID_OMR 0xffffffff
  2243. #define FWUPD_TIMEOUT (5 * 60)
  2244. /*
  2245. * Doorbell bit defines
  2246. */
  2247. #define DoorBellSyncCmdAvailable (1<<0) /* Host -> Adapter */
  2248. #define DoorBellPrintfDone (1<<5) /* Host -> Adapter */
  2249. #define DoorBellAdapterNormCmdReady (1<<1) /* Adapter -> Host */
  2250. #define DoorBellAdapterNormRespReady (1<<2) /* Adapter -> Host */
  2251. #define DoorBellAdapterNormCmdNotFull (1<<3) /* Adapter -> Host */
  2252. #define DoorBellAdapterNormRespNotFull (1<<4) /* Adapter -> Host */
  2253. #define DoorBellPrintfReady (1<<5) /* Adapter -> Host */
  2254. #define DoorBellAifPending (1<<6) /* Adapter -> Host */
  2255. /* PMC specific outbound doorbell bits */
  2256. #define PmDoorBellResponseSent (1<<1) /* Adapter -> Host */
  2257. /*
  2258. * For FIB communication, we need all of the following things
  2259. * to send back to the user.
  2260. */
  2261. #define AifCmdEventNotify 1 /* Notify of event */
  2262. #define AifEnConfigChange 3 /* Adapter configuration change */
  2263. #define AifEnContainerChange 4 /* Container configuration change */
  2264. #define AifEnDeviceFailure 5 /* SCSI device failed */
  2265. #define AifEnEnclosureManagement 13 /* EM_DRIVE_* */
  2266. #define EM_DRIVE_INSERTION 31
  2267. #define EM_DRIVE_REMOVAL 32
  2268. #define EM_SES_DRIVE_INSERTION 33
  2269. #define EM_SES_DRIVE_REMOVAL 26
  2270. #define AifEnBatteryEvent 14 /* Change in Battery State */
  2271. #define AifEnAddContainer 15 /* A new array was created */
  2272. #define AifEnDeleteContainer 16 /* A container was deleted */
  2273. #define AifEnExpEvent 23 /* Firmware Event Log */
  2274. #define AifExeFirmwarePanic 3 /* Firmware Event Panic */
  2275. #define AifHighPriority 3 /* Highest Priority Event */
  2276. #define AifEnAddJBOD 30 /* JBOD created */
  2277. #define AifEnDeleteJBOD 31 /* JBOD deleted */
  2278. #define AifBuManagerEvent 42 /* Bu management*/
  2279. #define AifBuCacheDataLoss 10
  2280. #define AifBuCacheDataRecover 11
  2281. #define AifCmdJobProgress 2 /* Progress report */
  2282. #define AifJobCtrZero 101 /* Array Zero progress */
  2283. #define AifJobStsSuccess 1 /* Job completes */
  2284. #define AifJobStsRunning 102 /* Job running */
  2285. #define AifCmdAPIReport 3 /* Report from other user of API */
  2286. #define AifCmdDriverNotify 4 /* Notify host driver of event */
  2287. #define AifDenMorphComplete 200 /* A morph operation completed */
  2288. #define AifDenVolumeExtendComplete 201 /* A volume extend completed */
  2289. #define AifReqJobList 100 /* Gets back complete job list */
  2290. #define AifReqJobsForCtr 101 /* Gets back jobs for specific container */
  2291. #define AifReqJobsForScsi 102 /* Gets back jobs for specific SCSI device */
  2292. #define AifReqJobReport 103 /* Gets back a specific job report or list of them */
  2293. #define AifReqTerminateJob 104 /* Terminates job */
  2294. #define AifReqSuspendJob 105 /* Suspends a job */
  2295. #define AifReqResumeJob 106 /* Resumes a job */
  2296. #define AifReqSendAPIReport 107 /* API generic report requests */
  2297. #define AifReqAPIJobStart 108 /* Start a job from the API */
  2298. #define AifReqAPIJobUpdate 109 /* Update a job report from the API */
  2299. #define AifReqAPIJobFinish 110 /* Finish a job from the API */
  2300. /* PMC NEW COMM: Request the event data */
  2301. #define AifReqEvent 200
  2302. #define AifRawDeviceRemove 203 /* RAW device deleted */
  2303. #define AifNativeDeviceAdd 204 /* native HBA device added */
  2304. #define AifNativeDeviceRemove 205 /* native HBA device removed */
  2305. /*
  2306. * Adapter Initiated FIB command structures. Start with the adapter
  2307. * initiated FIBs that really come from the adapter, and get responded
  2308. * to by the host.
  2309. */
  2310. struct aac_aifcmd {
  2311. __le32 command; /* Tell host what type of notify this is */
  2312. __le32 seqnum; /* To allow ordering of reports (if necessary) */
  2313. u8 data[1]; /* Undefined length (from kernel viewpoint) */
  2314. };
  2315. /**
  2316. * Convert capacity to cylinders
  2317. * accounting for the fact capacity could be a 64 bit value
  2318. *
  2319. */
  2320. static inline unsigned int cap_to_cyls(sector_t capacity, unsigned divisor)
  2321. {
  2322. sector_div(capacity, divisor);
  2323. return capacity;
  2324. }
  2325. static inline int aac_pci_offline(struct aac_dev *dev)
  2326. {
  2327. return pci_channel_offline(dev->pdev) || dev->handle_pci_error;
  2328. }
  2329. static inline int aac_adapter_check_health(struct aac_dev *dev)
  2330. {
  2331. if (unlikely(aac_pci_offline(dev)))
  2332. return -1;
  2333. return (dev)->a_ops.adapter_check_health(dev);
  2334. }
  2335. int aac_scan_host(struct aac_dev *dev);
  2336. static inline void aac_schedule_safw_scan_worker(struct aac_dev *dev)
  2337. {
  2338. schedule_delayed_work(&dev->safw_rescan_work, AAC_RESCAN_DELAY);
  2339. }
  2340. static inline void aac_schedule_src_reinit_aif_worker(struct aac_dev *dev)
  2341. {
  2342. schedule_delayed_work(&dev->src_reinit_aif_worker, AAC_RESCAN_DELAY);
  2343. }
  2344. static inline void aac_safw_rescan_worker(struct work_struct *work)
  2345. {
  2346. struct aac_dev *dev = container_of(to_delayed_work(work),
  2347. struct aac_dev, safw_rescan_work);
  2348. wait_event(dev->scsi_host_ptr->host_wait,
  2349. !scsi_host_in_recovery(dev->scsi_host_ptr));
  2350. aac_scan_host(dev);
  2351. }
  2352. static inline void aac_cancel_rescan_worker(struct aac_dev *dev)
  2353. {
  2354. cancel_delayed_work_sync(&dev->safw_rescan_work);
  2355. cancel_delayed_work_sync(&dev->src_reinit_aif_worker);
  2356. }
  2357. enum aac_cmd_owner {
  2358. AAC_OWNER_MIDLEVEL = 0x101,
  2359. AAC_OWNER_LOWLEVEL = 0x102,
  2360. AAC_OWNER_ERROR_HANDLER = 0x103,
  2361. AAC_OWNER_FIRMWARE = 0x106,
  2362. };
  2363. struct aac_cmd_priv {
  2364. int (*callback)(struct scsi_cmnd *);
  2365. int status;
  2366. enum aac_cmd_owner owner;
  2367. bool sent_command;
  2368. };
  2369. static inline struct aac_cmd_priv *aac_priv(struct scsi_cmnd *cmd)
  2370. {
  2371. return scsi_cmd_priv(cmd);
  2372. }
  2373. void aac_safw_rescan_worker(struct work_struct *work);
  2374. void aac_src_reinit_aif_worker(struct work_struct *work);
  2375. int aac_acquire_irq(struct aac_dev *dev);
  2376. void aac_free_irq(struct aac_dev *dev);
  2377. int aac_setup_safw_adapter(struct aac_dev *dev);
  2378. const char *aac_driverinfo(struct Scsi_Host *);
  2379. void aac_fib_vector_assign(struct aac_dev *dev);
  2380. struct fib *aac_fib_alloc(struct aac_dev *dev);
  2381. struct fib *aac_fib_alloc_tag(struct aac_dev *dev, struct scsi_cmnd *scmd);
  2382. int aac_fib_setup(struct aac_dev *dev);
  2383. void aac_fib_map_free(struct aac_dev *dev);
  2384. void aac_fib_free(struct fib * context);
  2385. void aac_fib_init(struct fib * context);
  2386. void aac_printf(struct aac_dev *dev, u32 val);
  2387. int aac_fib_send(u16 command, struct fib * context, unsigned long size, int priority, int wait, int reply, fib_callback callback, void *ctxt);
  2388. int aac_hba_send(u8 command, struct fib *context,
  2389. fib_callback callback, void *ctxt);
  2390. int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entry **entry);
  2391. void aac_consumer_free(struct aac_dev * dev, struct aac_queue * q, u32 qnum);
  2392. int aac_fib_complete(struct fib * context);
  2393. void aac_hba_callback(void *context, struct fib *fibptr);
  2394. #define fib_data(fibctx) ((void *)(fibctx)->hw_fib_va->data)
  2395. struct aac_dev *aac_init_adapter(struct aac_dev *dev);
  2396. void aac_src_access_devreg(struct aac_dev *dev, int mode);
  2397. void aac_set_intx_mode(struct aac_dev *dev);
  2398. int aac_get_config_status(struct aac_dev *dev, int commit_flag);
  2399. int aac_get_containers(struct aac_dev *dev);
  2400. int aac_scsi_cmd(struct scsi_cmnd *cmd);
  2401. int aac_dev_ioctl(struct aac_dev *dev, unsigned int cmd, void __user *arg);
  2402. #ifndef shost_to_class
  2403. #define shost_to_class(shost) &shost->shost_dev
  2404. #endif
  2405. ssize_t aac_get_serial_number(struct device *dev, char *buf);
  2406. int aac_do_ioctl(struct aac_dev *dev, unsigned int cmd, void __user *arg);
  2407. int aac_rx_init(struct aac_dev *dev);
  2408. int aac_rkt_init(struct aac_dev *dev);
  2409. int aac_nark_init(struct aac_dev *dev);
  2410. int aac_sa_init(struct aac_dev *dev);
  2411. int aac_src_init(struct aac_dev *dev);
  2412. int aac_srcv_init(struct aac_dev *dev);
  2413. 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);
  2414. void aac_define_int_mode(struct aac_dev *dev);
  2415. unsigned int aac_response_normal(struct aac_queue * q);
  2416. unsigned int aac_command_normal(struct aac_queue * q);
  2417. unsigned int aac_intr_normal(struct aac_dev *dev, u32 Index,
  2418. int isAif, int isFastResponse,
  2419. struct hw_fib *aif_fib);
  2420. int aac_reset_adapter(struct aac_dev *dev, int forced, u8 reset_type);
  2421. int aac_check_health(struct aac_dev * dev);
  2422. int aac_command_thread(void *data);
  2423. int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context *fibctx);
  2424. int aac_fib_adapter_complete(struct fib * fibptr, unsigned short size);
  2425. struct aac_driver_ident* aac_get_driver_ident(int devtype);
  2426. int aac_get_adapter_info(struct aac_dev* dev);
  2427. int aac_send_shutdown(struct aac_dev *dev);
  2428. int aac_probe_container(struct aac_dev *dev, int cid);
  2429. int _aac_rx_init(struct aac_dev *dev);
  2430. int aac_rx_select_comm(struct aac_dev *dev, int comm);
  2431. int aac_rx_deliver_producer(struct fib * fib);
  2432. void aac_reinit_aif(struct aac_dev *aac, unsigned int index);
  2433. static inline int aac_is_src(struct aac_dev *dev)
  2434. {
  2435. u16 device = dev->pdev->device;
  2436. if (device == PMC_DEVICE_S6 ||
  2437. device == PMC_DEVICE_S7 ||
  2438. device == PMC_DEVICE_S8)
  2439. return 1;
  2440. return 0;
  2441. }
  2442. static inline int aac_supports_2T(struct aac_dev *dev)
  2443. {
  2444. return (dev->adapter_info.options & AAC_OPT_NEW_COMM_64);
  2445. }
  2446. char * get_container_type(unsigned type);
  2447. extern int numacb;
  2448. extern char aac_driver_version[];
  2449. extern int startup_timeout;
  2450. extern int aif_timeout;
  2451. extern int expose_physicals;
  2452. extern int aac_reset_devices;
  2453. extern int aac_msi;
  2454. extern int aac_commit;
  2455. extern int update_interval;
  2456. extern int check_interval;
  2457. extern int aac_check_reset;
  2458. extern int aac_fib_dump;
  2459. #endif