aacraid.h 78 KB

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