aacraid.h 78 KB

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