qla_def.h 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309
  1. /*
  2. * QLogic Fibre Channel HBA Driver
  3. * Copyright (c) 2003-2013 QLogic Corporation
  4. *
  5. * See LICENSE.qla2xxx for copyright and licensing details.
  6. */
  7. #ifndef __QLA_DEF_H
  8. #define __QLA_DEF_H
  9. #include <linux/kernel.h>
  10. #include <linux/init.h>
  11. #include <linux/types.h>
  12. #include <linux/module.h>
  13. #include <linux/list.h>
  14. #include <linux/pci.h>
  15. #include <linux/dma-mapping.h>
  16. #include <linux/sched.h>
  17. #include <linux/slab.h>
  18. #include <linux/dmapool.h>
  19. #include <linux/mempool.h>
  20. #include <linux/spinlock.h>
  21. #include <linux/completion.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/workqueue.h>
  24. #include <linux/firmware.h>
  25. #include <linux/aer.h>
  26. #include <linux/mutex.h>
  27. #include <scsi/scsi.h>
  28. #include <scsi/scsi_host.h>
  29. #include <scsi/scsi_device.h>
  30. #include <scsi/scsi_cmnd.h>
  31. #include <scsi/scsi_transport_fc.h>
  32. #include <scsi/scsi_bsg_fc.h>
  33. #include "qla_bsg.h"
  34. #include "qla_nx.h"
  35. #define QLA2XXX_DRIVER_NAME "qla2xxx"
  36. #define QLA2XXX_APIDEV "ql2xapidev"
  37. #define QLA2XXX_MANUFACTURER "QLogic Corporation"
  38. /*
  39. * We have MAILBOX_REGISTER_COUNT sized arrays in a few places,
  40. * but that's fine as we don't look at the last 24 ones for
  41. * ISP2100 HBAs.
  42. */
  43. #define MAILBOX_REGISTER_COUNT_2100 8
  44. #define MAILBOX_REGISTER_COUNT_2200 24
  45. #define MAILBOX_REGISTER_COUNT 32
  46. #define QLA2200A_RISC_ROM_VER 4
  47. #define FPM_2300 6
  48. #define FPM_2310 7
  49. #include "qla_settings.h"
  50. /*
  51. * Data bit definitions
  52. */
  53. #define BIT_0 0x1
  54. #define BIT_1 0x2
  55. #define BIT_2 0x4
  56. #define BIT_3 0x8
  57. #define BIT_4 0x10
  58. #define BIT_5 0x20
  59. #define BIT_6 0x40
  60. #define BIT_7 0x80
  61. #define BIT_8 0x100
  62. #define BIT_9 0x200
  63. #define BIT_10 0x400
  64. #define BIT_11 0x800
  65. #define BIT_12 0x1000
  66. #define BIT_13 0x2000
  67. #define BIT_14 0x4000
  68. #define BIT_15 0x8000
  69. #define BIT_16 0x10000
  70. #define BIT_17 0x20000
  71. #define BIT_18 0x40000
  72. #define BIT_19 0x80000
  73. #define BIT_20 0x100000
  74. #define BIT_21 0x200000
  75. #define BIT_22 0x400000
  76. #define BIT_23 0x800000
  77. #define BIT_24 0x1000000
  78. #define BIT_25 0x2000000
  79. #define BIT_26 0x4000000
  80. #define BIT_27 0x8000000
  81. #define BIT_28 0x10000000
  82. #define BIT_29 0x20000000
  83. #define BIT_30 0x40000000
  84. #define BIT_31 0x80000000
  85. #define LSB(x) ((uint8_t)(x))
  86. #define MSB(x) ((uint8_t)((uint16_t)(x) >> 8))
  87. #define LSW(x) ((uint16_t)(x))
  88. #define MSW(x) ((uint16_t)((uint32_t)(x) >> 16))
  89. #define LSD(x) ((uint32_t)((uint64_t)(x)))
  90. #define MSD(x) ((uint32_t)((((uint64_t)(x)) >> 16) >> 16))
  91. #define MAKE_HANDLE(x, y) ((uint32_t)((((uint32_t)(x)) << 16) | (uint32_t)(y)))
  92. /*
  93. * I/O register
  94. */
  95. #define RD_REG_BYTE(addr) readb(addr)
  96. #define RD_REG_WORD(addr) readw(addr)
  97. #define RD_REG_DWORD(addr) readl(addr)
  98. #define RD_REG_BYTE_RELAXED(addr) readb_relaxed(addr)
  99. #define RD_REG_WORD_RELAXED(addr) readw_relaxed(addr)
  100. #define RD_REG_DWORD_RELAXED(addr) readl_relaxed(addr)
  101. #define WRT_REG_BYTE(addr, data) writeb(data,addr)
  102. #define WRT_REG_WORD(addr, data) writew(data,addr)
  103. #define WRT_REG_DWORD(addr, data) writel(data,addr)
  104. /*
  105. * ISP83XX specific remote register addresses
  106. */
  107. #define QLA83XX_LED_PORT0 0x00201320
  108. #define QLA83XX_LED_PORT1 0x00201328
  109. #define QLA83XX_IDC_DEV_STATE 0x22102384
  110. #define QLA83XX_IDC_MAJOR_VERSION 0x22102380
  111. #define QLA83XX_IDC_MINOR_VERSION 0x22102398
  112. #define QLA83XX_IDC_DRV_PRESENCE 0x22102388
  113. #define QLA83XX_IDC_DRIVER_ACK 0x2210238c
  114. #define QLA83XX_IDC_CONTROL 0x22102390
  115. #define QLA83XX_IDC_AUDIT 0x22102394
  116. #define QLA83XX_IDC_LOCK_RECOVERY 0x2210239c
  117. #define QLA83XX_DRIVER_LOCKID 0x22102104
  118. #define QLA83XX_DRIVER_LOCK 0x8111c028
  119. #define QLA83XX_DRIVER_UNLOCK 0x8111c02c
  120. #define QLA83XX_FLASH_LOCKID 0x22102100
  121. #define QLA83XX_FLASH_LOCK 0x8111c010
  122. #define QLA83XX_FLASH_UNLOCK 0x8111c014
  123. #define QLA83XX_DEV_PARTINFO1 0x221023e0
  124. #define QLA83XX_DEV_PARTINFO2 0x221023e4
  125. #define QLA83XX_FW_HEARTBEAT 0x221020b0
  126. #define QLA83XX_PEG_HALT_STATUS1 0x221020a8
  127. #define QLA83XX_PEG_HALT_STATUS2 0x221020ac
  128. /* 83XX: Macros defining 8200 AEN Reason codes */
  129. #define IDC_DEVICE_STATE_CHANGE BIT_0
  130. #define IDC_PEG_HALT_STATUS_CHANGE BIT_1
  131. #define IDC_NIC_FW_REPORTED_FAILURE BIT_2
  132. #define IDC_HEARTBEAT_FAILURE BIT_3
  133. /* 83XX: Macros defining 8200 AEN Error-levels */
  134. #define ERR_LEVEL_NON_FATAL 0x1
  135. #define ERR_LEVEL_RECOVERABLE_FATAL 0x2
  136. #define ERR_LEVEL_UNRECOVERABLE_FATAL 0x4
  137. /* 83XX: Macros for IDC Version */
  138. #define QLA83XX_SUPP_IDC_MAJOR_VERSION 0x01
  139. #define QLA83XX_SUPP_IDC_MINOR_VERSION 0x0
  140. /* 83XX: Macros for scheduling dpc tasks */
  141. #define QLA83XX_NIC_CORE_RESET 0x1
  142. #define QLA83XX_IDC_STATE_HANDLER 0x2
  143. #define QLA83XX_NIC_CORE_UNRECOVERABLE 0x3
  144. /* 83XX: Macros for defining IDC-Control bits */
  145. #define QLA83XX_IDC_RESET_DISABLED BIT_0
  146. #define QLA83XX_IDC_GRACEFUL_RESET BIT_1
  147. /* 83XX: Macros for different timeouts */
  148. #define QLA83XX_IDC_INITIALIZATION_TIMEOUT 30
  149. #define QLA83XX_IDC_RESET_ACK_TIMEOUT 10
  150. #define QLA83XX_MAX_LOCK_RECOVERY_WAIT (2 * HZ)
  151. /* 83XX: Macros for defining class in DEV-Partition Info register */
  152. #define QLA83XX_CLASS_TYPE_NONE 0x0
  153. #define QLA83XX_CLASS_TYPE_NIC 0x1
  154. #define QLA83XX_CLASS_TYPE_FCOE 0x2
  155. #define QLA83XX_CLASS_TYPE_ISCSI 0x3
  156. /* 83XX: Macros for IDC Lock-Recovery stages */
  157. #define IDC_LOCK_RECOVERY_STAGE1 0x1 /* Stage1: Intent for
  158. * lock-recovery
  159. */
  160. #define IDC_LOCK_RECOVERY_STAGE2 0x2 /* Stage2: Perform lock-recovery */
  161. /* 83XX: Macros for IDC Audit type */
  162. #define IDC_AUDIT_TIMESTAMP 0x0 /* IDC-AUDIT: Record timestamp of
  163. * dev-state change to NEED-RESET
  164. * or NEED-QUIESCENT
  165. */
  166. #define IDC_AUDIT_COMPLETION 0x1 /* IDC-AUDIT: Record duration of
  167. * reset-recovery completion is
  168. * second
  169. */
  170. /*
  171. * The ISP2312 v2 chip cannot access the FLASH/GPIO registers via MMIO in an
  172. * 133Mhz slot.
  173. */
  174. #define RD_REG_WORD_PIO(addr) (inw((unsigned long)addr))
  175. #define WRT_REG_WORD_PIO(addr, data) (outw(data,(unsigned long)addr))
  176. /*
  177. * Fibre Channel device definitions.
  178. */
  179. #define WWN_SIZE 8 /* Size of WWPN, WWN & WWNN */
  180. #define MAX_FIBRE_DEVICES_2100 512
  181. #define MAX_FIBRE_DEVICES_2400 2048
  182. #define MAX_FIBRE_DEVICES_LOOP 128
  183. #define MAX_FIBRE_DEVICES_MAX MAX_FIBRE_DEVICES_2400
  184. #define LOOPID_MAP_SIZE (ha->max_fibre_devices)
  185. #define MAX_FIBRE_LUNS 0xFFFF
  186. #define MAX_HOST_COUNT 16
  187. /*
  188. * Host adapter default definitions.
  189. */
  190. #define MAX_BUSES 1 /* We only have one bus today */
  191. #define MIN_LUNS 8
  192. #define MAX_LUNS MAX_FIBRE_LUNS
  193. #define MAX_CMDS_PER_LUN 255
  194. /*
  195. * Fibre Channel device definitions.
  196. */
  197. #define SNS_LAST_LOOP_ID_2100 0xfe
  198. #define SNS_LAST_LOOP_ID_2300 0x7ff
  199. #define LAST_LOCAL_LOOP_ID 0x7d
  200. #define SNS_FL_PORT 0x7e
  201. #define FABRIC_CONTROLLER 0x7f
  202. #define SIMPLE_NAME_SERVER 0x80
  203. #define SNS_FIRST_LOOP_ID 0x81
  204. #define MANAGEMENT_SERVER 0xfe
  205. #define BROADCAST 0xff
  206. /*
  207. * There is no correspondence between an N-PORT id and an AL_PA. Therefore the
  208. * valid range of an N-PORT id is 0 through 0x7ef.
  209. */
  210. #define NPH_LAST_HANDLE 0x7ef
  211. #define NPH_MGMT_SERVER 0x7fa /* FFFFFA */
  212. #define NPH_SNS 0x7fc /* FFFFFC */
  213. #define NPH_FABRIC_CONTROLLER 0x7fd /* FFFFFD */
  214. #define NPH_F_PORT 0x7fe /* FFFFFE */
  215. #define NPH_IP_BROADCAST 0x7ff /* FFFFFF */
  216. #define MAX_CMDSZ 16 /* SCSI maximum CDB size. */
  217. #include "qla_fw.h"
  218. /*
  219. * Timeout timer counts in seconds
  220. */
  221. #define PORT_RETRY_TIME 1
  222. #define LOOP_DOWN_TIMEOUT 60
  223. #define LOOP_DOWN_TIME 255 /* 240 */
  224. #define LOOP_DOWN_RESET (LOOP_DOWN_TIME - 30)
  225. #define DEFAULT_OUTSTANDING_COMMANDS 1024
  226. #define MIN_OUTSTANDING_COMMANDS 128
  227. /* ISP request and response entry counts (37-65535) */
  228. #define REQUEST_ENTRY_CNT_2100 128 /* Number of request entries. */
  229. #define REQUEST_ENTRY_CNT_2200 2048 /* Number of request entries. */
  230. #define REQUEST_ENTRY_CNT_24XX 2048 /* Number of request entries. */
  231. #define RESPONSE_ENTRY_CNT_2100 64 /* Number of response entries.*/
  232. #define RESPONSE_ENTRY_CNT_2300 512 /* Number of response entries.*/
  233. #define RESPONSE_ENTRY_CNT_MQ 128 /* Number of response entries.*/
  234. #define ATIO_ENTRY_CNT_24XX 4096 /* Number of ATIO entries. */
  235. struct req_que;
  236. /*
  237. * (sd.h is not exported, hence local inclusion)
  238. * Data Integrity Field tuple.
  239. */
  240. struct sd_dif_tuple {
  241. __be16 guard_tag; /* Checksum */
  242. __be16 app_tag; /* Opaque storage */
  243. __be32 ref_tag; /* Target LBA or indirect LBA */
  244. };
  245. /*
  246. * SCSI Request Block
  247. */
  248. struct srb_cmd {
  249. struct scsi_cmnd *cmd; /* Linux SCSI command pkt */
  250. uint32_t request_sense_length;
  251. uint8_t *request_sense_ptr;
  252. void *ctx;
  253. };
  254. /*
  255. * SRB flag definitions
  256. */
  257. #define SRB_DMA_VALID BIT_0 /* Command sent to ISP */
  258. #define SRB_FCP_CMND_DMA_VALID BIT_12 /* DIF: DSD List valid */
  259. #define SRB_CRC_CTX_DMA_VALID BIT_2 /* DIF: context DMA valid */
  260. #define SRB_CRC_PROT_DMA_VALID BIT_4 /* DIF: prot DMA valid */
  261. #define SRB_CRC_CTX_DSD_VALID BIT_5 /* DIF: dsd_list valid */
  262. /* To identify if a srb is of T10-CRC type. @sp => srb_t pointer */
  263. #define IS_PROT_IO(sp) (sp->flags & SRB_CRC_CTX_DSD_VALID)
  264. /*
  265. * SRB extensions.
  266. */
  267. struct srb_iocb {
  268. union {
  269. struct {
  270. uint16_t flags;
  271. #define SRB_LOGIN_RETRIED BIT_0
  272. #define SRB_LOGIN_COND_PLOGI BIT_1
  273. #define SRB_LOGIN_SKIP_PRLI BIT_2
  274. uint16_t data[2];
  275. } logio;
  276. struct {
  277. /*
  278. * Values for flags field below are as
  279. * defined in tsk_mgmt_entry struct
  280. * for control_flags field in qla_fw.h.
  281. */
  282. uint32_t flags;
  283. uint32_t lun;
  284. uint32_t data;
  285. } tmf;
  286. } u;
  287. struct timer_list timer;
  288. void (*timeout)(void *);
  289. };
  290. /* Values for srb_ctx type */
  291. #define SRB_LOGIN_CMD 1
  292. #define SRB_LOGOUT_CMD 2
  293. #define SRB_ELS_CMD_RPT 3
  294. #define SRB_ELS_CMD_HST 4
  295. #define SRB_CT_CMD 5
  296. #define SRB_ADISC_CMD 6
  297. #define SRB_TM_CMD 7
  298. #define SRB_SCSI_CMD 8
  299. #define SRB_BIDI_CMD 9
  300. typedef struct srb {
  301. atomic_t ref_count;
  302. struct fc_port *fcport;
  303. uint32_t handle;
  304. uint16_t flags;
  305. uint16_t type;
  306. char *name;
  307. int iocbs;
  308. union {
  309. struct srb_iocb iocb_cmd;
  310. struct fc_bsg_job *bsg_job;
  311. struct srb_cmd scmd;
  312. } u;
  313. void (*done)(void *, void *, int);
  314. void (*free)(void *, void *);
  315. } srb_t;
  316. #define GET_CMD_SP(sp) (sp->u.scmd.cmd)
  317. #define SET_CMD_SP(sp, cmd) (sp->u.scmd.cmd = cmd)
  318. #define GET_CMD_CTX_SP(sp) (sp->u.scmd.ctx)
  319. #define GET_CMD_SENSE_LEN(sp) \
  320. (sp->u.scmd.request_sense_length)
  321. #define SET_CMD_SENSE_LEN(sp, len) \
  322. (sp->u.scmd.request_sense_length = len)
  323. #define GET_CMD_SENSE_PTR(sp) \
  324. (sp->u.scmd.request_sense_ptr)
  325. #define SET_CMD_SENSE_PTR(sp, ptr) \
  326. (sp->u.scmd.request_sense_ptr = ptr)
  327. struct msg_echo_lb {
  328. dma_addr_t send_dma;
  329. dma_addr_t rcv_dma;
  330. uint16_t req_sg_cnt;
  331. uint16_t rsp_sg_cnt;
  332. uint16_t options;
  333. uint32_t transfer_size;
  334. };
  335. /*
  336. * ISP I/O Register Set structure definitions.
  337. */
  338. struct device_reg_2xxx {
  339. uint16_t flash_address; /* Flash BIOS address */
  340. uint16_t flash_data; /* Flash BIOS data */
  341. uint16_t unused_1[1]; /* Gap */
  342. uint16_t ctrl_status; /* Control/Status */
  343. #define CSR_FLASH_64K_BANK BIT_3 /* Flash upper 64K bank select */
  344. #define CSR_FLASH_ENABLE BIT_1 /* Flash BIOS Read/Write enable */
  345. #define CSR_ISP_SOFT_RESET BIT_0 /* ISP soft reset */
  346. uint16_t ictrl; /* Interrupt control */
  347. #define ICR_EN_INT BIT_15 /* ISP enable interrupts. */
  348. #define ICR_EN_RISC BIT_3 /* ISP enable RISC interrupts. */
  349. uint16_t istatus; /* Interrupt status */
  350. #define ISR_RISC_INT BIT_3 /* RISC interrupt */
  351. uint16_t semaphore; /* Semaphore */
  352. uint16_t nvram; /* NVRAM register. */
  353. #define NVR_DESELECT 0
  354. #define NVR_BUSY BIT_15
  355. #define NVR_WRT_ENABLE BIT_14 /* Write enable */
  356. #define NVR_PR_ENABLE BIT_13 /* Protection register enable */
  357. #define NVR_DATA_IN BIT_3
  358. #define NVR_DATA_OUT BIT_2
  359. #define NVR_SELECT BIT_1
  360. #define NVR_CLOCK BIT_0
  361. #define NVR_WAIT_CNT 20000
  362. union {
  363. struct {
  364. uint16_t mailbox0;
  365. uint16_t mailbox1;
  366. uint16_t mailbox2;
  367. uint16_t mailbox3;
  368. uint16_t mailbox4;
  369. uint16_t mailbox5;
  370. uint16_t mailbox6;
  371. uint16_t mailbox7;
  372. uint16_t unused_2[59]; /* Gap */
  373. } __attribute__((packed)) isp2100;
  374. struct {
  375. /* Request Queue */
  376. uint16_t req_q_in; /* In-Pointer */
  377. uint16_t req_q_out; /* Out-Pointer */
  378. /* Response Queue */
  379. uint16_t rsp_q_in; /* In-Pointer */
  380. uint16_t rsp_q_out; /* Out-Pointer */
  381. /* RISC to Host Status */
  382. uint32_t host_status;
  383. #define HSR_RISC_INT BIT_15 /* RISC interrupt */
  384. #define HSR_RISC_PAUSED BIT_8 /* RISC Paused */
  385. /* Host to Host Semaphore */
  386. uint16_t host_semaphore;
  387. uint16_t unused_3[17]; /* Gap */
  388. uint16_t mailbox0;
  389. uint16_t mailbox1;
  390. uint16_t mailbox2;
  391. uint16_t mailbox3;
  392. uint16_t mailbox4;
  393. uint16_t mailbox5;
  394. uint16_t mailbox6;
  395. uint16_t mailbox7;
  396. uint16_t mailbox8;
  397. uint16_t mailbox9;
  398. uint16_t mailbox10;
  399. uint16_t mailbox11;
  400. uint16_t mailbox12;
  401. uint16_t mailbox13;
  402. uint16_t mailbox14;
  403. uint16_t mailbox15;
  404. uint16_t mailbox16;
  405. uint16_t mailbox17;
  406. uint16_t mailbox18;
  407. uint16_t mailbox19;
  408. uint16_t mailbox20;
  409. uint16_t mailbox21;
  410. uint16_t mailbox22;
  411. uint16_t mailbox23;
  412. uint16_t mailbox24;
  413. uint16_t mailbox25;
  414. uint16_t mailbox26;
  415. uint16_t mailbox27;
  416. uint16_t mailbox28;
  417. uint16_t mailbox29;
  418. uint16_t mailbox30;
  419. uint16_t mailbox31;
  420. uint16_t fb_cmd;
  421. uint16_t unused_4[10]; /* Gap */
  422. } __attribute__((packed)) isp2300;
  423. } u;
  424. uint16_t fpm_diag_config;
  425. uint16_t unused_5[0x4]; /* Gap */
  426. uint16_t risc_hw;
  427. uint16_t unused_5_1; /* Gap */
  428. uint16_t pcr; /* Processor Control Register. */
  429. uint16_t unused_6[0x5]; /* Gap */
  430. uint16_t mctr; /* Memory Configuration and Timing. */
  431. uint16_t unused_7[0x3]; /* Gap */
  432. uint16_t fb_cmd_2100; /* Unused on 23XX */
  433. uint16_t unused_8[0x3]; /* Gap */
  434. uint16_t hccr; /* Host command & control register. */
  435. #define HCCR_HOST_INT BIT_7 /* Host interrupt bit */
  436. #define HCCR_RISC_PAUSE BIT_5 /* Pause mode bit */
  437. /* HCCR commands */
  438. #define HCCR_RESET_RISC 0x1000 /* Reset RISC */
  439. #define HCCR_PAUSE_RISC 0x2000 /* Pause RISC */
  440. #define HCCR_RELEASE_RISC 0x3000 /* Release RISC from reset. */
  441. #define HCCR_SET_HOST_INT 0x5000 /* Set host interrupt */
  442. #define HCCR_CLR_HOST_INT 0x6000 /* Clear HOST interrupt */
  443. #define HCCR_CLR_RISC_INT 0x7000 /* Clear RISC interrupt */
  444. #define HCCR_DISABLE_PARITY_PAUSE 0x4001 /* Disable parity error RISC pause. */
  445. #define HCCR_ENABLE_PARITY 0xA000 /* Enable PARITY interrupt */
  446. uint16_t unused_9[5]; /* Gap */
  447. uint16_t gpiod; /* GPIO Data register. */
  448. uint16_t gpioe; /* GPIO Enable register. */
  449. #define GPIO_LED_MASK 0x00C0
  450. #define GPIO_LED_GREEN_OFF_AMBER_OFF 0x0000
  451. #define GPIO_LED_GREEN_ON_AMBER_OFF 0x0040
  452. #define GPIO_LED_GREEN_OFF_AMBER_ON 0x0080
  453. #define GPIO_LED_GREEN_ON_AMBER_ON 0x00C0
  454. #define GPIO_LED_ALL_OFF 0x0000
  455. #define GPIO_LED_RED_ON_OTHER_OFF 0x0001 /* isp2322 */
  456. #define GPIO_LED_RGA_ON 0x00C1 /* isp2322: red green amber */
  457. union {
  458. struct {
  459. uint16_t unused_10[8]; /* Gap */
  460. uint16_t mailbox8;
  461. uint16_t mailbox9;
  462. uint16_t mailbox10;
  463. uint16_t mailbox11;
  464. uint16_t mailbox12;
  465. uint16_t mailbox13;
  466. uint16_t mailbox14;
  467. uint16_t mailbox15;
  468. uint16_t mailbox16;
  469. uint16_t mailbox17;
  470. uint16_t mailbox18;
  471. uint16_t mailbox19;
  472. uint16_t mailbox20;
  473. uint16_t mailbox21;
  474. uint16_t mailbox22;
  475. uint16_t mailbox23; /* Also probe reg. */
  476. } __attribute__((packed)) isp2200;
  477. } u_end;
  478. };
  479. struct device_reg_25xxmq {
  480. uint32_t req_q_in;
  481. uint32_t req_q_out;
  482. uint32_t rsp_q_in;
  483. uint32_t rsp_q_out;
  484. uint32_t atio_q_in;
  485. uint32_t atio_q_out;
  486. };
  487. typedef union {
  488. struct device_reg_2xxx isp;
  489. struct device_reg_24xx isp24;
  490. struct device_reg_25xxmq isp25mq;
  491. struct device_reg_82xx isp82;
  492. } device_reg_t;
  493. #define ISP_REQ_Q_IN(ha, reg) \
  494. (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  495. &(reg)->u.isp2100.mailbox4 : \
  496. &(reg)->u.isp2300.req_q_in)
  497. #define ISP_REQ_Q_OUT(ha, reg) \
  498. (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  499. &(reg)->u.isp2100.mailbox4 : \
  500. &(reg)->u.isp2300.req_q_out)
  501. #define ISP_RSP_Q_IN(ha, reg) \
  502. (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  503. &(reg)->u.isp2100.mailbox5 : \
  504. &(reg)->u.isp2300.rsp_q_in)
  505. #define ISP_RSP_Q_OUT(ha, reg) \
  506. (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  507. &(reg)->u.isp2100.mailbox5 : \
  508. &(reg)->u.isp2300.rsp_q_out)
  509. #define ISP_ATIO_Q_IN(vha) (vha->hw->tgt.atio_q_in)
  510. #define ISP_ATIO_Q_OUT(vha) (vha->hw->tgt.atio_q_out)
  511. #define MAILBOX_REG(ha, reg, num) \
  512. (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  513. (num < 8 ? \
  514. &(reg)->u.isp2100.mailbox0 + (num) : \
  515. &(reg)->u_end.isp2200.mailbox8 + (num) - 8) : \
  516. &(reg)->u.isp2300.mailbox0 + (num))
  517. #define RD_MAILBOX_REG(ha, reg, num) \
  518. RD_REG_WORD(MAILBOX_REG(ha, reg, num))
  519. #define WRT_MAILBOX_REG(ha, reg, num, data) \
  520. WRT_REG_WORD(MAILBOX_REG(ha, reg, num), data)
  521. #define FB_CMD_REG(ha, reg) \
  522. (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  523. &(reg)->fb_cmd_2100 : \
  524. &(reg)->u.isp2300.fb_cmd)
  525. #define RD_FB_CMD_REG(ha, reg) \
  526. RD_REG_WORD(FB_CMD_REG(ha, reg))
  527. #define WRT_FB_CMD_REG(ha, reg, data) \
  528. WRT_REG_WORD(FB_CMD_REG(ha, reg), data)
  529. typedef struct {
  530. uint32_t out_mb; /* outbound from driver */
  531. uint32_t in_mb; /* Incoming from RISC */
  532. uint16_t mb[MAILBOX_REGISTER_COUNT];
  533. long buf_size;
  534. void *bufp;
  535. uint32_t tov;
  536. uint8_t flags;
  537. #define MBX_DMA_IN BIT_0
  538. #define MBX_DMA_OUT BIT_1
  539. #define IOCTL_CMD BIT_2
  540. } mbx_cmd_t;
  541. #define MBX_TOV_SECONDS 30
  542. /*
  543. * ISP product identification definitions in mailboxes after reset.
  544. */
  545. #define PROD_ID_1 0x4953
  546. #define PROD_ID_2 0x0000
  547. #define PROD_ID_2a 0x5020
  548. #define PROD_ID_3 0x2020
  549. /*
  550. * ISP mailbox Self-Test status codes
  551. */
  552. #define MBS_FRM_ALIVE 0 /* Firmware Alive. */
  553. #define MBS_CHKSUM_ERR 1 /* Checksum Error. */
  554. #define MBS_BUSY 4 /* Busy. */
  555. /*
  556. * ISP mailbox command complete status codes
  557. */
  558. #define MBS_COMMAND_COMPLETE 0x4000
  559. #define MBS_INVALID_COMMAND 0x4001
  560. #define MBS_HOST_INTERFACE_ERROR 0x4002
  561. #define MBS_TEST_FAILED 0x4003
  562. #define MBS_COMMAND_ERROR 0x4005
  563. #define MBS_COMMAND_PARAMETER_ERROR 0x4006
  564. #define MBS_PORT_ID_USED 0x4007
  565. #define MBS_LOOP_ID_USED 0x4008
  566. #define MBS_ALL_IDS_IN_USE 0x4009
  567. #define MBS_NOT_LOGGED_IN 0x400A
  568. #define MBS_LINK_DOWN_ERROR 0x400B
  569. #define MBS_DIAG_ECHO_TEST_ERROR 0x400C
  570. /*
  571. * ISP mailbox asynchronous event status codes
  572. */
  573. #define MBA_ASYNC_EVENT 0x8000 /* Asynchronous event. */
  574. #define MBA_RESET 0x8001 /* Reset Detected. */
  575. #define MBA_SYSTEM_ERR 0x8002 /* System Error. */
  576. #define MBA_REQ_TRANSFER_ERR 0x8003 /* Request Transfer Error. */
  577. #define MBA_RSP_TRANSFER_ERR 0x8004 /* Response Transfer Error. */
  578. #define MBA_WAKEUP_THRES 0x8005 /* Request Queue Wake-up. */
  579. #define MBA_LIP_OCCURRED 0x8010 /* Loop Initialization Procedure */
  580. /* occurred. */
  581. #define MBA_LOOP_UP 0x8011 /* FC Loop UP. */
  582. #define MBA_LOOP_DOWN 0x8012 /* FC Loop Down. */
  583. #define MBA_LIP_RESET 0x8013 /* LIP reset occurred. */
  584. #define MBA_PORT_UPDATE 0x8014 /* Port Database update. */
  585. #define MBA_RSCN_UPDATE 0x8015 /* Register State Chg Notification. */
  586. #define MBA_LIP_F8 0x8016 /* Received a LIP F8. */
  587. #define MBA_LOOP_INIT_ERR 0x8017 /* Loop Initialization Error. */
  588. #define MBA_FABRIC_AUTH_REQ 0x801b /* Fabric Authentication Required. */
  589. #define MBA_SCSI_COMPLETION 0x8020 /* SCSI Command Complete. */
  590. #define MBA_CTIO_COMPLETION 0x8021 /* CTIO Complete. */
  591. #define MBA_IP_COMPLETION 0x8022 /* IP Transmit Command Complete. */
  592. #define MBA_IP_RECEIVE 0x8023 /* IP Received. */
  593. #define MBA_IP_BROADCAST 0x8024 /* IP Broadcast Received. */
  594. #define MBA_IP_LOW_WATER_MARK 0x8025 /* IP Low Water Mark reached. */
  595. #define MBA_IP_RCV_BUFFER_EMPTY 0x8026 /* IP receive buffer queue empty. */
  596. #define MBA_IP_HDR_DATA_SPLIT 0x8027 /* IP header/data splitting feature */
  597. /* used. */
  598. #define MBA_TRACE_NOTIFICATION 0x8028 /* Trace/Diagnostic notification. */
  599. #define MBA_POINT_TO_POINT 0x8030 /* Point to point mode. */
  600. #define MBA_CMPLT_1_16BIT 0x8031 /* Completion 1 16bit IOSB. */
  601. #define MBA_CMPLT_2_16BIT 0x8032 /* Completion 2 16bit IOSB. */
  602. #define MBA_CMPLT_3_16BIT 0x8033 /* Completion 3 16bit IOSB. */
  603. #define MBA_CMPLT_4_16BIT 0x8034 /* Completion 4 16bit IOSB. */
  604. #define MBA_CMPLT_5_16BIT 0x8035 /* Completion 5 16bit IOSB. */
  605. #define MBA_CHG_IN_CONNECTION 0x8036 /* Change in connection mode. */
  606. #define MBA_RIO_RESPONSE 0x8040 /* RIO response queue update. */
  607. #define MBA_ZIO_RESPONSE 0x8040 /* ZIO response queue update. */
  608. #define MBA_CMPLT_2_32BIT 0x8042 /* Completion 2 32bit IOSB. */
  609. #define MBA_BYPASS_NOTIFICATION 0x8043 /* Auto bypass notification. */
  610. #define MBA_DISCARD_RND_FRAME 0x8048 /* discard RND frame due to error. */
  611. #define MBA_REJECTED_FCP_CMD 0x8049 /* rejected FCP_CMD. */
  612. /* 83XX FCoE specific */
  613. #define MBA_IDC_AEN 0x8200 /* FCoE: NIC Core state change AEN */
  614. /* Interrupt type codes */
  615. #define INTR_ROM_MB_SUCCESS 0x1
  616. #define INTR_ROM_MB_FAILED 0x2
  617. #define INTR_MB_SUCCESS 0x10
  618. #define INTR_MB_FAILED 0x11
  619. #define INTR_ASYNC_EVENT 0x12
  620. #define INTR_RSP_QUE_UPDATE 0x13
  621. #define INTR_RSP_QUE_UPDATE_83XX 0x14
  622. #define INTR_ATIO_QUE_UPDATE 0x1C
  623. #define INTR_ATIO_RSP_QUE_UPDATE 0x1D
  624. /* ISP mailbox loopback echo diagnostic error code */
  625. #define MBS_LB_RESET 0x17
  626. /*
  627. * Firmware options 1, 2, 3.
  628. */
  629. #define FO1_AE_ON_LIPF8 BIT_0
  630. #define FO1_AE_ALL_LIP_RESET BIT_1
  631. #define FO1_CTIO_RETRY BIT_3
  632. #define FO1_DISABLE_LIP_F7_SW BIT_4
  633. #define FO1_DISABLE_100MS_LOS_WAIT BIT_5
  634. #define FO1_DISABLE_GPIO6_7 BIT_6 /* LED bits */
  635. #define FO1_AE_ON_LOOP_INIT_ERR BIT_7
  636. #define FO1_SET_EMPHASIS_SWING BIT_8
  637. #define FO1_AE_AUTO_BYPASS BIT_9
  638. #define FO1_ENABLE_PURE_IOCB BIT_10
  639. #define FO1_AE_PLOGI_RJT BIT_11
  640. #define FO1_ENABLE_ABORT_SEQUENCE BIT_12
  641. #define FO1_AE_QUEUE_FULL BIT_13
  642. #define FO2_ENABLE_ATIO_TYPE_3 BIT_0
  643. #define FO2_REV_LOOPBACK BIT_1
  644. #define FO3_ENABLE_EMERG_IOCB BIT_0
  645. #define FO3_AE_RND_ERROR BIT_1
  646. /* 24XX additional firmware options */
  647. #define ADD_FO_COUNT 3
  648. #define ADD_FO1_DISABLE_GPIO_LED_CTRL BIT_6 /* LED bits */
  649. #define ADD_FO1_ENABLE_PUREX_IOCB BIT_10
  650. #define ADD_FO2_ENABLE_SEL_CLS2 BIT_5
  651. #define ADD_FO3_NO_ABT_ON_LINK_DOWN BIT_14
  652. /*
  653. * ISP mailbox commands
  654. */
  655. #define MBC_LOAD_RAM 1 /* Load RAM. */
  656. #define MBC_EXECUTE_FIRMWARE 2 /* Execute firmware. */
  657. #define MBC_WRITE_RAM_WORD 4 /* Write RAM word. */
  658. #define MBC_READ_RAM_WORD 5 /* Read RAM word. */
  659. #define MBC_MAILBOX_REGISTER_TEST 6 /* Wrap incoming mailboxes */
  660. #define MBC_VERIFY_CHECKSUM 7 /* Verify checksum. */
  661. #define MBC_GET_FIRMWARE_VERSION 8 /* Get firmware revision. */
  662. #define MBC_LOAD_RISC_RAM 9 /* Load RAM command. */
  663. #define MBC_DUMP_RISC_RAM 0xa /* Dump RAM command. */
  664. #define MBC_LOAD_RISC_RAM_EXTENDED 0xb /* Load RAM extended. */
  665. #define MBC_DUMP_RISC_RAM_EXTENDED 0xc /* Dump RAM extended. */
  666. #define MBC_WRITE_RAM_WORD_EXTENDED 0xd /* Write RAM word extended */
  667. #define MBC_READ_RAM_EXTENDED 0xf /* Read RAM extended. */
  668. #define MBC_IOCB_COMMAND 0x12 /* Execute IOCB command. */
  669. #define MBC_STOP_FIRMWARE 0x14 /* Stop firmware. */
  670. #define MBC_ABORT_COMMAND 0x15 /* Abort IOCB command. */
  671. #define MBC_ABORT_DEVICE 0x16 /* Abort device (ID/LUN). */
  672. #define MBC_ABORT_TARGET 0x17 /* Abort target (ID). */
  673. #define MBC_RESET 0x18 /* Reset. */
  674. #define MBC_GET_ADAPTER_LOOP_ID 0x20 /* Get loop id of ISP2200. */
  675. #define MBC_GET_RETRY_COUNT 0x22 /* Get f/w retry cnt/delay. */
  676. #define MBC_DISABLE_VI 0x24 /* Disable VI operation. */
  677. #define MBC_ENABLE_VI 0x25 /* Enable VI operation. */
  678. #define MBC_GET_FIRMWARE_OPTION 0x28 /* Get Firmware Options. */
  679. #define MBC_SET_FIRMWARE_OPTION 0x38 /* Set Firmware Options. */
  680. #define MBC_LOOP_PORT_BYPASS 0x40 /* Loop Port Bypass. */
  681. #define MBC_LOOP_PORT_ENABLE 0x41 /* Loop Port Enable. */
  682. #define MBC_GET_RESOURCE_COUNTS 0x42 /* Get Resource Counts. */
  683. #define MBC_NON_PARTICIPATE 0x43 /* Non-Participating Mode. */
  684. #define MBC_DIAGNOSTIC_ECHO 0x44 /* Diagnostic echo. */
  685. #define MBC_DIAGNOSTIC_LOOP_BACK 0x45 /* Diagnostic loop back. */
  686. #define MBC_ONLINE_SELF_TEST 0x46 /* Online self-test. */
  687. #define MBC_ENHANCED_GET_PORT_DATABASE 0x47 /* Get port database + login */
  688. #define MBC_CONFIGURE_VF 0x4b /* Configure VFs */
  689. #define MBC_RESET_LINK_STATUS 0x52 /* Reset Link Error Status */
  690. #define MBC_IOCB_COMMAND_A64 0x54 /* Execute IOCB command (64) */
  691. #define MBC_PORT_LOGOUT 0x56 /* Port Logout request */
  692. #define MBC_SEND_RNID_ELS 0x57 /* Send RNID ELS request */
  693. #define MBC_SET_RNID_PARAMS 0x59 /* Set RNID parameters */
  694. #define MBC_GET_RNID_PARAMS 0x5a /* Get RNID parameters */
  695. #define MBC_DATA_RATE 0x5d /* Data Rate */
  696. #define MBC_INITIALIZE_FIRMWARE 0x60 /* Initialize firmware */
  697. #define MBC_INITIATE_LIP 0x62 /* Initiate Loop */
  698. /* Initialization Procedure */
  699. #define MBC_GET_FC_AL_POSITION_MAP 0x63 /* Get FC_AL Position Map. */
  700. #define MBC_GET_PORT_DATABASE 0x64 /* Get Port Database. */
  701. #define MBC_CLEAR_ACA 0x65 /* Clear ACA. */
  702. #define MBC_TARGET_RESET 0x66 /* Target Reset. */
  703. #define MBC_CLEAR_TASK_SET 0x67 /* Clear Task Set. */
  704. #define MBC_ABORT_TASK_SET 0x68 /* Abort Task Set. */
  705. #define MBC_GET_FIRMWARE_STATE 0x69 /* Get firmware state. */
  706. #define MBC_GET_PORT_NAME 0x6a /* Get port name. */
  707. #define MBC_GET_LINK_STATUS 0x6b /* Get port link status. */
  708. #define MBC_LIP_RESET 0x6c /* LIP reset. */
  709. #define MBC_SEND_SNS_COMMAND 0x6e /* Send Simple Name Server */
  710. /* commandd. */
  711. #define MBC_LOGIN_FABRIC_PORT 0x6f /* Login fabric port. */
  712. #define MBC_SEND_CHANGE_REQUEST 0x70 /* Send Change Request. */
  713. #define MBC_LOGOUT_FABRIC_PORT 0x71 /* Logout fabric port. */
  714. #define MBC_LIP_FULL_LOGIN 0x72 /* Full login LIP. */
  715. #define MBC_LOGIN_LOOP_PORT 0x74 /* Login Loop Port. */
  716. #define MBC_PORT_NODE_NAME_LIST 0x75 /* Get port/node name list. */
  717. #define MBC_INITIALIZE_RECEIVE_QUEUE 0x77 /* Initialize receive queue */
  718. #define MBC_UNLOAD_IP 0x79 /* Shutdown IP */
  719. #define MBC_GET_ID_LIST 0x7C /* Get Port ID list. */
  720. #define MBC_SEND_LFA_COMMAND 0x7D /* Send Loop Fabric Address */
  721. #define MBC_LUN_RESET 0x7E /* Send LUN reset */
  722. /*
  723. * ISP24xx mailbox commands
  724. */
  725. #define MBC_SERDES_PARAMS 0x10 /* Serdes Tx Parameters. */
  726. #define MBC_GET_IOCB_STATUS 0x12 /* Get IOCB status command. */
  727. #define MBC_PORT_PARAMS 0x1A /* Port iDMA Parameters. */
  728. #define MBC_GET_TIMEOUT_PARAMS 0x22 /* Get FW timeouts. */
  729. #define MBC_TRACE_CONTROL 0x27 /* Trace control command. */
  730. #define MBC_GEN_SYSTEM_ERROR 0x2a /* Generate System Error. */
  731. #define MBC_WRITE_SFP 0x30 /* Write SFP Data. */
  732. #define MBC_READ_SFP 0x31 /* Read SFP Data. */
  733. #define MBC_SET_TIMEOUT_PARAMS 0x32 /* Set FW timeouts. */
  734. #define MBC_MID_INITIALIZE_FIRMWARE 0x48 /* MID Initialize firmware. */
  735. #define MBC_MID_GET_VP_DATABASE 0x49 /* MID Get VP Database. */
  736. #define MBC_MID_GET_VP_ENTRY 0x4a /* MID Get VP Entry. */
  737. #define MBC_HOST_MEMORY_COPY 0x53 /* Host Memory Copy. */
  738. #define MBC_SEND_RNFT_ELS 0x5e /* Send RNFT ELS request */
  739. #define MBC_GET_LINK_PRIV_STATS 0x6d /* Get link & private data. */
  740. #define MBC_LINK_INITIALIZATION 0x72 /* Do link initialization. */
  741. #define MBC_SET_VENDOR_ID 0x76 /* Set Vendor ID. */
  742. #define MBC_PORT_RESET 0x120 /* Port Reset */
  743. #define MBC_SET_PORT_CONFIG 0x122 /* Set port configuration */
  744. #define MBC_GET_PORT_CONFIG 0x123 /* Get port configuration */
  745. /*
  746. * ISP81xx mailbox commands
  747. */
  748. #define MBC_WRITE_MPI_REGISTER 0x01 /* Write MPI Register. */
  749. /* Firmware return data sizes */
  750. #define FCAL_MAP_SIZE 128
  751. /* Mailbox bit definitions for out_mb and in_mb */
  752. #define MBX_31 BIT_31
  753. #define MBX_30 BIT_30
  754. #define MBX_29 BIT_29
  755. #define MBX_28 BIT_28
  756. #define MBX_27 BIT_27
  757. #define MBX_26 BIT_26
  758. #define MBX_25 BIT_25
  759. #define MBX_24 BIT_24
  760. #define MBX_23 BIT_23
  761. #define MBX_22 BIT_22
  762. #define MBX_21 BIT_21
  763. #define MBX_20 BIT_20
  764. #define MBX_19 BIT_19
  765. #define MBX_18 BIT_18
  766. #define MBX_17 BIT_17
  767. #define MBX_16 BIT_16
  768. #define MBX_15 BIT_15
  769. #define MBX_14 BIT_14
  770. #define MBX_13 BIT_13
  771. #define MBX_12 BIT_12
  772. #define MBX_11 BIT_11
  773. #define MBX_10 BIT_10
  774. #define MBX_9 BIT_9
  775. #define MBX_8 BIT_8
  776. #define MBX_7 BIT_7
  777. #define MBX_6 BIT_6
  778. #define MBX_5 BIT_5
  779. #define MBX_4 BIT_4
  780. #define MBX_3 BIT_3
  781. #define MBX_2 BIT_2
  782. #define MBX_1 BIT_1
  783. #define MBX_0 BIT_0
  784. #define RNID_TYPE_ASIC_TEMP 0xC
  785. /*
  786. * Firmware state codes from get firmware state mailbox command
  787. */
  788. #define FSTATE_CONFIG_WAIT 0
  789. #define FSTATE_WAIT_AL_PA 1
  790. #define FSTATE_WAIT_LOGIN 2
  791. #define FSTATE_READY 3
  792. #define FSTATE_LOSS_OF_SYNC 4
  793. #define FSTATE_ERROR 5
  794. #define FSTATE_REINIT 6
  795. #define FSTATE_NON_PART 7
  796. #define FSTATE_CONFIG_CORRECT 0
  797. #define FSTATE_P2P_RCV_LIP 1
  798. #define FSTATE_P2P_CHOOSE_LOOP 2
  799. #define FSTATE_P2P_RCV_UNIDEN_LIP 3
  800. #define FSTATE_FATAL_ERROR 4
  801. #define FSTATE_LOOP_BACK_CONN 5
  802. /*
  803. * Port Database structure definition
  804. * Little endian except where noted.
  805. */
  806. #define PORT_DATABASE_SIZE 128 /* bytes */
  807. typedef struct {
  808. uint8_t options;
  809. uint8_t control;
  810. uint8_t master_state;
  811. uint8_t slave_state;
  812. uint8_t reserved[2];
  813. uint8_t hard_address;
  814. uint8_t reserved_1;
  815. uint8_t port_id[4];
  816. uint8_t node_name[WWN_SIZE];
  817. uint8_t port_name[WWN_SIZE];
  818. uint16_t execution_throttle;
  819. uint16_t execution_count;
  820. uint8_t reset_count;
  821. uint8_t reserved_2;
  822. uint16_t resource_allocation;
  823. uint16_t current_allocation;
  824. uint16_t queue_head;
  825. uint16_t queue_tail;
  826. uint16_t transmit_execution_list_next;
  827. uint16_t transmit_execution_list_previous;
  828. uint16_t common_features;
  829. uint16_t total_concurrent_sequences;
  830. uint16_t RO_by_information_category;
  831. uint8_t recipient;
  832. uint8_t initiator;
  833. uint16_t receive_data_size;
  834. uint16_t concurrent_sequences;
  835. uint16_t open_sequences_per_exchange;
  836. uint16_t lun_abort_flags;
  837. uint16_t lun_stop_flags;
  838. uint16_t stop_queue_head;
  839. uint16_t stop_queue_tail;
  840. uint16_t port_retry_timer;
  841. uint16_t next_sequence_id;
  842. uint16_t frame_count;
  843. uint16_t PRLI_payload_length;
  844. uint8_t prli_svc_param_word_0[2]; /* Big endian */
  845. /* Bits 15-0 of word 0 */
  846. uint8_t prli_svc_param_word_3[2]; /* Big endian */
  847. /* Bits 15-0 of word 3 */
  848. uint16_t loop_id;
  849. uint16_t extended_lun_info_list_pointer;
  850. uint16_t extended_lun_stop_list_pointer;
  851. } port_database_t;
  852. /*
  853. * Port database slave/master states
  854. */
  855. #define PD_STATE_DISCOVERY 0
  856. #define PD_STATE_WAIT_DISCOVERY_ACK 1
  857. #define PD_STATE_PORT_LOGIN 2
  858. #define PD_STATE_WAIT_PORT_LOGIN_ACK 3
  859. #define PD_STATE_PROCESS_LOGIN 4
  860. #define PD_STATE_WAIT_PROCESS_LOGIN_ACK 5
  861. #define PD_STATE_PORT_LOGGED_IN 6
  862. #define PD_STATE_PORT_UNAVAILABLE 7
  863. #define PD_STATE_PROCESS_LOGOUT 8
  864. #define PD_STATE_WAIT_PROCESS_LOGOUT_ACK 9
  865. #define PD_STATE_PORT_LOGOUT 10
  866. #define PD_STATE_WAIT_PORT_LOGOUT_ACK 11
  867. #define QLA_ZIO_MODE_6 (BIT_2 | BIT_1)
  868. #define QLA_ZIO_DISABLED 0
  869. #define QLA_ZIO_DEFAULT_TIMER 2
  870. /*
  871. * ISP Initialization Control Block.
  872. * Little endian except where noted.
  873. */
  874. #define ICB_VERSION 1
  875. typedef struct {
  876. uint8_t version;
  877. uint8_t reserved_1;
  878. /*
  879. * LSB BIT 0 = Enable Hard Loop Id
  880. * LSB BIT 1 = Enable Fairness
  881. * LSB BIT 2 = Enable Full-Duplex
  882. * LSB BIT 3 = Enable Fast Posting
  883. * LSB BIT 4 = Enable Target Mode
  884. * LSB BIT 5 = Disable Initiator Mode
  885. * LSB BIT 6 = Enable ADISC
  886. * LSB BIT 7 = Enable Target Inquiry Data
  887. *
  888. * MSB BIT 0 = Enable PDBC Notify
  889. * MSB BIT 1 = Non Participating LIP
  890. * MSB BIT 2 = Descending Loop ID Search
  891. * MSB BIT 3 = Acquire Loop ID in LIPA
  892. * MSB BIT 4 = Stop PortQ on Full Status
  893. * MSB BIT 5 = Full Login after LIP
  894. * MSB BIT 6 = Node Name Option
  895. * MSB BIT 7 = Ext IFWCB enable bit
  896. */
  897. uint8_t firmware_options[2];
  898. uint16_t frame_payload_size;
  899. uint16_t max_iocb_allocation;
  900. uint16_t execution_throttle;
  901. uint8_t retry_count;
  902. uint8_t retry_delay; /* unused */
  903. uint8_t port_name[WWN_SIZE]; /* Big endian. */
  904. uint16_t hard_address;
  905. uint8_t inquiry_data;
  906. uint8_t login_timeout;
  907. uint8_t node_name[WWN_SIZE]; /* Big endian. */
  908. uint16_t request_q_outpointer;
  909. uint16_t response_q_inpointer;
  910. uint16_t request_q_length;
  911. uint16_t response_q_length;
  912. uint32_t request_q_address[2];
  913. uint32_t response_q_address[2];
  914. uint16_t lun_enables;
  915. uint8_t command_resource_count;
  916. uint8_t immediate_notify_resource_count;
  917. uint16_t timeout;
  918. uint8_t reserved_2[2];
  919. /*
  920. * LSB BIT 0 = Timer Operation mode bit 0
  921. * LSB BIT 1 = Timer Operation mode bit 1
  922. * LSB BIT 2 = Timer Operation mode bit 2
  923. * LSB BIT 3 = Timer Operation mode bit 3
  924. * LSB BIT 4 = Init Config Mode bit 0
  925. * LSB BIT 5 = Init Config Mode bit 1
  926. * LSB BIT 6 = Init Config Mode bit 2
  927. * LSB BIT 7 = Enable Non part on LIHA failure
  928. *
  929. * MSB BIT 0 = Enable class 2
  930. * MSB BIT 1 = Enable ACK0
  931. * MSB BIT 2 =
  932. * MSB BIT 3 =
  933. * MSB BIT 4 = FC Tape Enable
  934. * MSB BIT 5 = Enable FC Confirm
  935. * MSB BIT 6 = Enable command queuing in target mode
  936. * MSB BIT 7 = No Logo On Link Down
  937. */
  938. uint8_t add_firmware_options[2];
  939. uint8_t response_accumulation_timer;
  940. uint8_t interrupt_delay_timer;
  941. /*
  942. * LSB BIT 0 = Enable Read xfr_rdy
  943. * LSB BIT 1 = Soft ID only
  944. * LSB BIT 2 =
  945. * LSB BIT 3 =
  946. * LSB BIT 4 = FCP RSP Payload [0]
  947. * LSB BIT 5 = FCP RSP Payload [1] / Sbus enable - 2200
  948. * LSB BIT 6 = Enable Out-of-Order frame handling
  949. * LSB BIT 7 = Disable Automatic PLOGI on Local Loop
  950. *
  951. * MSB BIT 0 = Sbus enable - 2300
  952. * MSB BIT 1 =
  953. * MSB BIT 2 =
  954. * MSB BIT 3 =
  955. * MSB BIT 4 = LED mode
  956. * MSB BIT 5 = enable 50 ohm termination
  957. * MSB BIT 6 = Data Rate (2300 only)
  958. * MSB BIT 7 = Data Rate (2300 only)
  959. */
  960. uint8_t special_options[2];
  961. uint8_t reserved_3[26];
  962. } init_cb_t;
  963. /*
  964. * Get Link Status mailbox command return buffer.
  965. */
  966. #define GLSO_SEND_RPS BIT_0
  967. #define GLSO_USE_DID BIT_3
  968. struct link_statistics {
  969. uint32_t link_fail_cnt;
  970. uint32_t loss_sync_cnt;
  971. uint32_t loss_sig_cnt;
  972. uint32_t prim_seq_err_cnt;
  973. uint32_t inval_xmit_word_cnt;
  974. uint32_t inval_crc_cnt;
  975. uint32_t lip_cnt;
  976. uint32_t unused1[0x1a];
  977. uint32_t tx_frames;
  978. uint32_t rx_frames;
  979. uint32_t dumped_frames;
  980. uint32_t unused2[2];
  981. uint32_t nos_rcvd;
  982. };
  983. /*
  984. * NVRAM Command values.
  985. */
  986. #define NV_START_BIT BIT_2
  987. #define NV_WRITE_OP (BIT_26+BIT_24)
  988. #define NV_READ_OP (BIT_26+BIT_25)
  989. #define NV_ERASE_OP (BIT_26+BIT_25+BIT_24)
  990. #define NV_MASK_OP (BIT_26+BIT_25+BIT_24)
  991. #define NV_DELAY_COUNT 10
  992. /*
  993. * QLogic ISP2100, ISP2200 and ISP2300 NVRAM structure definition.
  994. */
  995. typedef struct {
  996. /*
  997. * NVRAM header
  998. */
  999. uint8_t id[4];
  1000. uint8_t nvram_version;
  1001. uint8_t reserved_0;
  1002. /*
  1003. * NVRAM RISC parameter block
  1004. */
  1005. uint8_t parameter_block_version;
  1006. uint8_t reserved_1;
  1007. /*
  1008. * LSB BIT 0 = Enable Hard Loop Id
  1009. * LSB BIT 1 = Enable Fairness
  1010. * LSB BIT 2 = Enable Full-Duplex
  1011. * LSB BIT 3 = Enable Fast Posting
  1012. * LSB BIT 4 = Enable Target Mode
  1013. * LSB BIT 5 = Disable Initiator Mode
  1014. * LSB BIT 6 = Enable ADISC
  1015. * LSB BIT 7 = Enable Target Inquiry Data
  1016. *
  1017. * MSB BIT 0 = Enable PDBC Notify
  1018. * MSB BIT 1 = Non Participating LIP
  1019. * MSB BIT 2 = Descending Loop ID Search
  1020. * MSB BIT 3 = Acquire Loop ID in LIPA
  1021. * MSB BIT 4 = Stop PortQ on Full Status
  1022. * MSB BIT 5 = Full Login after LIP
  1023. * MSB BIT 6 = Node Name Option
  1024. * MSB BIT 7 = Ext IFWCB enable bit
  1025. */
  1026. uint8_t firmware_options[2];
  1027. uint16_t frame_payload_size;
  1028. uint16_t max_iocb_allocation;
  1029. uint16_t execution_throttle;
  1030. uint8_t retry_count;
  1031. uint8_t retry_delay; /* unused */
  1032. uint8_t port_name[WWN_SIZE]; /* Big endian. */
  1033. uint16_t hard_address;
  1034. uint8_t inquiry_data;
  1035. uint8_t login_timeout;
  1036. uint8_t node_name[WWN_SIZE]; /* Big endian. */
  1037. /*
  1038. * LSB BIT 0 = Timer Operation mode bit 0
  1039. * LSB BIT 1 = Timer Operation mode bit 1
  1040. * LSB BIT 2 = Timer Operation mode bit 2
  1041. * LSB BIT 3 = Timer Operation mode bit 3
  1042. * LSB BIT 4 = Init Config Mode bit 0
  1043. * LSB BIT 5 = Init Config Mode bit 1
  1044. * LSB BIT 6 = Init Config Mode bit 2
  1045. * LSB BIT 7 = Enable Non part on LIHA failure
  1046. *
  1047. * MSB BIT 0 = Enable class 2
  1048. * MSB BIT 1 = Enable ACK0
  1049. * MSB BIT 2 =
  1050. * MSB BIT 3 =
  1051. * MSB BIT 4 = FC Tape Enable
  1052. * MSB BIT 5 = Enable FC Confirm
  1053. * MSB BIT 6 = Enable command queuing in target mode
  1054. * MSB BIT 7 = No Logo On Link Down
  1055. */
  1056. uint8_t add_firmware_options[2];
  1057. uint8_t response_accumulation_timer;
  1058. uint8_t interrupt_delay_timer;
  1059. /*
  1060. * LSB BIT 0 = Enable Read xfr_rdy
  1061. * LSB BIT 1 = Soft ID only
  1062. * LSB BIT 2 =
  1063. * LSB BIT 3 =
  1064. * LSB BIT 4 = FCP RSP Payload [0]
  1065. * LSB BIT 5 = FCP RSP Payload [1] / Sbus enable - 2200
  1066. * LSB BIT 6 = Enable Out-of-Order frame handling
  1067. * LSB BIT 7 = Disable Automatic PLOGI on Local Loop
  1068. *
  1069. * MSB BIT 0 = Sbus enable - 2300
  1070. * MSB BIT 1 =
  1071. * MSB BIT 2 =
  1072. * MSB BIT 3 =
  1073. * MSB BIT 4 = LED mode
  1074. * MSB BIT 5 = enable 50 ohm termination
  1075. * MSB BIT 6 = Data Rate (2300 only)
  1076. * MSB BIT 7 = Data Rate (2300 only)
  1077. */
  1078. uint8_t special_options[2];
  1079. /* Reserved for expanded RISC parameter block */
  1080. uint8_t reserved_2[22];
  1081. /*
  1082. * LSB BIT 0 = Tx Sensitivity 1G bit 0
  1083. * LSB BIT 1 = Tx Sensitivity 1G bit 1
  1084. * LSB BIT 2 = Tx Sensitivity 1G bit 2
  1085. * LSB BIT 3 = Tx Sensitivity 1G bit 3
  1086. * LSB BIT 4 = Rx Sensitivity 1G bit 0
  1087. * LSB BIT 5 = Rx Sensitivity 1G bit 1
  1088. * LSB BIT 6 = Rx Sensitivity 1G bit 2
  1089. * LSB BIT 7 = Rx Sensitivity 1G bit 3
  1090. *
  1091. * MSB BIT 0 = Tx Sensitivity 2G bit 0
  1092. * MSB BIT 1 = Tx Sensitivity 2G bit 1
  1093. * MSB BIT 2 = Tx Sensitivity 2G bit 2
  1094. * MSB BIT 3 = Tx Sensitivity 2G bit 3
  1095. * MSB BIT 4 = Rx Sensitivity 2G bit 0
  1096. * MSB BIT 5 = Rx Sensitivity 2G bit 1
  1097. * MSB BIT 6 = Rx Sensitivity 2G bit 2
  1098. * MSB BIT 7 = Rx Sensitivity 2G bit 3
  1099. *
  1100. * LSB BIT 0 = Output Swing 1G bit 0
  1101. * LSB BIT 1 = Output Swing 1G bit 1
  1102. * LSB BIT 2 = Output Swing 1G bit 2
  1103. * LSB BIT 3 = Output Emphasis 1G bit 0
  1104. * LSB BIT 4 = Output Emphasis 1G bit 1
  1105. * LSB BIT 5 = Output Swing 2G bit 0
  1106. * LSB BIT 6 = Output Swing 2G bit 1
  1107. * LSB BIT 7 = Output Swing 2G bit 2
  1108. *
  1109. * MSB BIT 0 = Output Emphasis 2G bit 0
  1110. * MSB BIT 1 = Output Emphasis 2G bit 1
  1111. * MSB BIT 2 = Output Enable
  1112. * MSB BIT 3 =
  1113. * MSB BIT 4 =
  1114. * MSB BIT 5 =
  1115. * MSB BIT 6 =
  1116. * MSB BIT 7 =
  1117. */
  1118. uint8_t seriallink_options[4];
  1119. /*
  1120. * NVRAM host parameter block
  1121. *
  1122. * LSB BIT 0 = Enable spinup delay
  1123. * LSB BIT 1 = Disable BIOS
  1124. * LSB BIT 2 = Enable Memory Map BIOS
  1125. * LSB BIT 3 = Enable Selectable Boot
  1126. * LSB BIT 4 = Disable RISC code load
  1127. * LSB BIT 5 = Set cache line size 1
  1128. * LSB BIT 6 = PCI Parity Disable
  1129. * LSB BIT 7 = Enable extended logging
  1130. *
  1131. * MSB BIT 0 = Enable 64bit addressing
  1132. * MSB BIT 1 = Enable lip reset
  1133. * MSB BIT 2 = Enable lip full login
  1134. * MSB BIT 3 = Enable target reset
  1135. * MSB BIT 4 = Enable database storage
  1136. * MSB BIT 5 = Enable cache flush read
  1137. * MSB BIT 6 = Enable database load
  1138. * MSB BIT 7 = Enable alternate WWN
  1139. */
  1140. uint8_t host_p[2];
  1141. uint8_t boot_node_name[WWN_SIZE];
  1142. uint8_t boot_lun_number;
  1143. uint8_t reset_delay;
  1144. uint8_t port_down_retry_count;
  1145. uint8_t boot_id_number;
  1146. uint16_t max_luns_per_target;
  1147. uint8_t fcode_boot_port_name[WWN_SIZE];
  1148. uint8_t alternate_port_name[WWN_SIZE];
  1149. uint8_t alternate_node_name[WWN_SIZE];
  1150. /*
  1151. * BIT 0 = Selective Login
  1152. * BIT 1 = Alt-Boot Enable
  1153. * BIT 2 =
  1154. * BIT 3 = Boot Order List
  1155. * BIT 4 =
  1156. * BIT 5 = Selective LUN
  1157. * BIT 6 =
  1158. * BIT 7 = unused
  1159. */
  1160. uint8_t efi_parameters;
  1161. uint8_t link_down_timeout;
  1162. uint8_t adapter_id[16];
  1163. uint8_t alt1_boot_node_name[WWN_SIZE];
  1164. uint16_t alt1_boot_lun_number;
  1165. uint8_t alt2_boot_node_name[WWN_SIZE];
  1166. uint16_t alt2_boot_lun_number;
  1167. uint8_t alt3_boot_node_name[WWN_SIZE];
  1168. uint16_t alt3_boot_lun_number;
  1169. uint8_t alt4_boot_node_name[WWN_SIZE];
  1170. uint16_t alt4_boot_lun_number;
  1171. uint8_t alt5_boot_node_name[WWN_SIZE];
  1172. uint16_t alt5_boot_lun_number;
  1173. uint8_t alt6_boot_node_name[WWN_SIZE];
  1174. uint16_t alt6_boot_lun_number;
  1175. uint8_t alt7_boot_node_name[WWN_SIZE];
  1176. uint16_t alt7_boot_lun_number;
  1177. uint8_t reserved_3[2];
  1178. /* Offset 200-215 : Model Number */
  1179. uint8_t model_number[16];
  1180. /* OEM related items */
  1181. uint8_t oem_specific[16];
  1182. /*
  1183. * NVRAM Adapter Features offset 232-239
  1184. *
  1185. * LSB BIT 0 = External GBIC
  1186. * LSB BIT 1 = Risc RAM parity
  1187. * LSB BIT 2 = Buffer Plus Module
  1188. * LSB BIT 3 = Multi Chip Adapter
  1189. * LSB BIT 4 = Internal connector
  1190. * LSB BIT 5 =
  1191. * LSB BIT 6 =
  1192. * LSB BIT 7 =
  1193. *
  1194. * MSB BIT 0 =
  1195. * MSB BIT 1 =
  1196. * MSB BIT 2 =
  1197. * MSB BIT 3 =
  1198. * MSB BIT 4 =
  1199. * MSB BIT 5 =
  1200. * MSB BIT 6 =
  1201. * MSB BIT 7 =
  1202. */
  1203. uint8_t adapter_features[2];
  1204. uint8_t reserved_4[16];
  1205. /* Subsystem vendor ID for ISP2200 */
  1206. uint16_t subsystem_vendor_id_2200;
  1207. /* Subsystem device ID for ISP2200 */
  1208. uint16_t subsystem_device_id_2200;
  1209. uint8_t reserved_5;
  1210. uint8_t checksum;
  1211. } nvram_t;
  1212. /*
  1213. * ISP queue - response queue entry definition.
  1214. */
  1215. typedef struct {
  1216. uint8_t entry_type; /* Entry type. */
  1217. uint8_t entry_count; /* Entry count. */
  1218. uint8_t sys_define; /* System defined. */
  1219. uint8_t entry_status; /* Entry Status. */
  1220. uint32_t handle; /* System defined handle */
  1221. uint8_t data[52];
  1222. uint32_t signature;
  1223. #define RESPONSE_PROCESSED 0xDEADDEAD /* Signature */
  1224. } response_t;
  1225. /*
  1226. * ISP queue - ATIO queue entry definition.
  1227. */
  1228. struct atio {
  1229. uint8_t entry_type; /* Entry type. */
  1230. uint8_t entry_count; /* Entry count. */
  1231. uint8_t data[58];
  1232. uint32_t signature;
  1233. #define ATIO_PROCESSED 0xDEADDEAD /* Signature */
  1234. };
  1235. typedef union {
  1236. uint16_t extended;
  1237. struct {
  1238. uint8_t reserved;
  1239. uint8_t standard;
  1240. } id;
  1241. } target_id_t;
  1242. #define SET_TARGET_ID(ha, to, from) \
  1243. do { \
  1244. if (HAS_EXTENDED_IDS(ha)) \
  1245. to.extended = cpu_to_le16(from); \
  1246. else \
  1247. to.id.standard = (uint8_t)from; \
  1248. } while (0)
  1249. /*
  1250. * ISP queue - command entry structure definition.
  1251. */
  1252. #define COMMAND_TYPE 0x11 /* Command entry */
  1253. typedef struct {
  1254. uint8_t entry_type; /* Entry type. */
  1255. uint8_t entry_count; /* Entry count. */
  1256. uint8_t sys_define; /* System defined. */
  1257. uint8_t entry_status; /* Entry Status. */
  1258. uint32_t handle; /* System handle. */
  1259. target_id_t target; /* SCSI ID */
  1260. uint16_t lun; /* SCSI LUN */
  1261. uint16_t control_flags; /* Control flags. */
  1262. #define CF_WRITE BIT_6
  1263. #define CF_READ BIT_5
  1264. #define CF_SIMPLE_TAG BIT_3
  1265. #define CF_ORDERED_TAG BIT_2
  1266. #define CF_HEAD_TAG BIT_1
  1267. uint16_t reserved_1;
  1268. uint16_t timeout; /* Command timeout. */
  1269. uint16_t dseg_count; /* Data segment count. */
  1270. uint8_t scsi_cdb[MAX_CMDSZ]; /* SCSI command words. */
  1271. uint32_t byte_count; /* Total byte count. */
  1272. uint32_t dseg_0_address; /* Data segment 0 address. */
  1273. uint32_t dseg_0_length; /* Data segment 0 length. */
  1274. uint32_t dseg_1_address; /* Data segment 1 address. */
  1275. uint32_t dseg_1_length; /* Data segment 1 length. */
  1276. uint32_t dseg_2_address; /* Data segment 2 address. */
  1277. uint32_t dseg_2_length; /* Data segment 2 length. */
  1278. } cmd_entry_t;
  1279. /*
  1280. * ISP queue - 64-Bit addressing, command entry structure definition.
  1281. */
  1282. #define COMMAND_A64_TYPE 0x19 /* Command A64 entry */
  1283. typedef struct {
  1284. uint8_t entry_type; /* Entry type. */
  1285. uint8_t entry_count; /* Entry count. */
  1286. uint8_t sys_define; /* System defined. */
  1287. uint8_t entry_status; /* Entry Status. */
  1288. uint32_t handle; /* System handle. */
  1289. target_id_t target; /* SCSI ID */
  1290. uint16_t lun; /* SCSI LUN */
  1291. uint16_t control_flags; /* Control flags. */
  1292. uint16_t reserved_1;
  1293. uint16_t timeout; /* Command timeout. */
  1294. uint16_t dseg_count; /* Data segment count. */
  1295. uint8_t scsi_cdb[MAX_CMDSZ]; /* SCSI command words. */
  1296. uint32_t byte_count; /* Total byte count. */
  1297. uint32_t dseg_0_address[2]; /* Data segment 0 address. */
  1298. uint32_t dseg_0_length; /* Data segment 0 length. */
  1299. uint32_t dseg_1_address[2]; /* Data segment 1 address. */
  1300. uint32_t dseg_1_length; /* Data segment 1 length. */
  1301. } cmd_a64_entry_t, request_t;
  1302. /*
  1303. * ISP queue - continuation entry structure definition.
  1304. */
  1305. #define CONTINUE_TYPE 0x02 /* Continuation entry. */
  1306. typedef struct {
  1307. uint8_t entry_type; /* Entry type. */
  1308. uint8_t entry_count; /* Entry count. */
  1309. uint8_t sys_define; /* System defined. */
  1310. uint8_t entry_status; /* Entry Status. */
  1311. uint32_t reserved;
  1312. uint32_t dseg_0_address; /* Data segment 0 address. */
  1313. uint32_t dseg_0_length; /* Data segment 0 length. */
  1314. uint32_t dseg_1_address; /* Data segment 1 address. */
  1315. uint32_t dseg_1_length; /* Data segment 1 length. */
  1316. uint32_t dseg_2_address; /* Data segment 2 address. */
  1317. uint32_t dseg_2_length; /* Data segment 2 length. */
  1318. uint32_t dseg_3_address; /* Data segment 3 address. */
  1319. uint32_t dseg_3_length; /* Data segment 3 length. */
  1320. uint32_t dseg_4_address; /* Data segment 4 address. */
  1321. uint32_t dseg_4_length; /* Data segment 4 length. */
  1322. uint32_t dseg_5_address; /* Data segment 5 address. */
  1323. uint32_t dseg_5_length; /* Data segment 5 length. */
  1324. uint32_t dseg_6_address; /* Data segment 6 address. */
  1325. uint32_t dseg_6_length; /* Data segment 6 length. */
  1326. } cont_entry_t;
  1327. /*
  1328. * ISP queue - 64-Bit addressing, continuation entry structure definition.
  1329. */
  1330. #define CONTINUE_A64_TYPE 0x0A /* Continuation A64 entry. */
  1331. typedef struct {
  1332. uint8_t entry_type; /* Entry type. */
  1333. uint8_t entry_count; /* Entry count. */
  1334. uint8_t sys_define; /* System defined. */
  1335. uint8_t entry_status; /* Entry Status. */
  1336. uint32_t dseg_0_address[2]; /* Data segment 0 address. */
  1337. uint32_t dseg_0_length; /* Data segment 0 length. */
  1338. uint32_t dseg_1_address[2]; /* Data segment 1 address. */
  1339. uint32_t dseg_1_length; /* Data segment 1 length. */
  1340. uint32_t dseg_2_address [2]; /* Data segment 2 address. */
  1341. uint32_t dseg_2_length; /* Data segment 2 length. */
  1342. uint32_t dseg_3_address[2]; /* Data segment 3 address. */
  1343. uint32_t dseg_3_length; /* Data segment 3 length. */
  1344. uint32_t dseg_4_address[2]; /* Data segment 4 address. */
  1345. uint32_t dseg_4_length; /* Data segment 4 length. */
  1346. } cont_a64_entry_t;
  1347. #define PO_MODE_DIF_INSERT 0
  1348. #define PO_MODE_DIF_REMOVE 1
  1349. #define PO_MODE_DIF_PASS 2
  1350. #define PO_MODE_DIF_REPLACE 3
  1351. #define PO_MODE_DIF_TCP_CKSUM 6
  1352. #define PO_ENABLE_DIF_BUNDLING BIT_8
  1353. #define PO_ENABLE_INCR_GUARD_SEED BIT_3
  1354. #define PO_DISABLE_INCR_REF_TAG BIT_5
  1355. #define PO_DISABLE_GUARD_CHECK BIT_4
  1356. /*
  1357. * ISP queue - 64-Bit addressing, continuation crc entry structure definition.
  1358. */
  1359. struct crc_context {
  1360. uint32_t handle; /* System handle. */
  1361. uint32_t ref_tag;
  1362. uint16_t app_tag;
  1363. uint8_t ref_tag_mask[4]; /* Validation/Replacement Mask*/
  1364. uint8_t app_tag_mask[2]; /* Validation/Replacement Mask*/
  1365. uint16_t guard_seed; /* Initial Guard Seed */
  1366. uint16_t prot_opts; /* Requested Data Protection Mode */
  1367. uint16_t blk_size; /* Data size in bytes */
  1368. uint16_t runt_blk_guard; /* Guard value for runt block (tape
  1369. * only) */
  1370. uint32_t byte_count; /* Total byte count/ total data
  1371. * transfer count */
  1372. union {
  1373. struct {
  1374. uint32_t reserved_1;
  1375. uint16_t reserved_2;
  1376. uint16_t reserved_3;
  1377. uint32_t reserved_4;
  1378. uint32_t data_address[2];
  1379. uint32_t data_length;
  1380. uint32_t reserved_5[2];
  1381. uint32_t reserved_6;
  1382. } nobundling;
  1383. struct {
  1384. uint32_t dif_byte_count; /* Total DIF byte
  1385. * count */
  1386. uint16_t reserved_1;
  1387. uint16_t dseg_count; /* Data segment count */
  1388. uint32_t reserved_2;
  1389. uint32_t data_address[2];
  1390. uint32_t data_length;
  1391. uint32_t dif_address[2];
  1392. uint32_t dif_length; /* Data segment 0
  1393. * length */
  1394. } bundling;
  1395. } u;
  1396. struct fcp_cmnd fcp_cmnd;
  1397. dma_addr_t crc_ctx_dma;
  1398. /* List of DMA context transfers */
  1399. struct list_head dsd_list;
  1400. /* This structure should not exceed 512 bytes */
  1401. };
  1402. #define CRC_CONTEXT_LEN_FW (offsetof(struct crc_context, fcp_cmnd.lun))
  1403. #define CRC_CONTEXT_FCPCMND_OFF (offsetof(struct crc_context, fcp_cmnd.lun))
  1404. /*
  1405. * ISP queue - status entry structure definition.
  1406. */
  1407. #define STATUS_TYPE 0x03 /* Status entry. */
  1408. typedef struct {
  1409. uint8_t entry_type; /* Entry type. */
  1410. uint8_t entry_count; /* Entry count. */
  1411. uint8_t sys_define; /* System defined. */
  1412. uint8_t entry_status; /* Entry Status. */
  1413. uint32_t handle; /* System handle. */
  1414. uint16_t scsi_status; /* SCSI status. */
  1415. uint16_t comp_status; /* Completion status. */
  1416. uint16_t state_flags; /* State flags. */
  1417. uint16_t status_flags; /* Status flags. */
  1418. uint16_t rsp_info_len; /* Response Info Length. */
  1419. uint16_t req_sense_length; /* Request sense data length. */
  1420. uint32_t residual_length; /* Residual transfer length. */
  1421. uint8_t rsp_info[8]; /* FCP response information. */
  1422. uint8_t req_sense_data[32]; /* Request sense data. */
  1423. } sts_entry_t;
  1424. /*
  1425. * Status entry entry status
  1426. */
  1427. #define RF_RQ_DMA_ERROR BIT_6 /* Request Queue DMA error. */
  1428. #define RF_INV_E_ORDER BIT_5 /* Invalid entry order. */
  1429. #define RF_INV_E_COUNT BIT_4 /* Invalid entry count. */
  1430. #define RF_INV_E_PARAM BIT_3 /* Invalid entry parameter. */
  1431. #define RF_INV_E_TYPE BIT_2 /* Invalid entry type. */
  1432. #define RF_BUSY BIT_1 /* Busy */
  1433. #define RF_MASK (RF_RQ_DMA_ERROR | RF_INV_E_ORDER | RF_INV_E_COUNT | \
  1434. RF_INV_E_PARAM | RF_INV_E_TYPE | RF_BUSY)
  1435. #define RF_MASK_24XX (RF_INV_E_ORDER | RF_INV_E_COUNT | RF_INV_E_PARAM | \
  1436. RF_INV_E_TYPE)
  1437. /*
  1438. * Status entry SCSI status bit definitions.
  1439. */
  1440. #define SS_MASK 0xfff /* Reserved bits BIT_12-BIT_15*/
  1441. #define SS_RESIDUAL_UNDER BIT_11
  1442. #define SS_RESIDUAL_OVER BIT_10
  1443. #define SS_SENSE_LEN_VALID BIT_9
  1444. #define SS_RESPONSE_INFO_LEN_VALID BIT_8
  1445. #define SS_RESERVE_CONFLICT (BIT_4 | BIT_3)
  1446. #define SS_BUSY_CONDITION BIT_3
  1447. #define SS_CONDITION_MET BIT_2
  1448. #define SS_CHECK_CONDITION BIT_1
  1449. /*
  1450. * Status entry completion status
  1451. */
  1452. #define CS_COMPLETE 0x0 /* No errors */
  1453. #define CS_INCOMPLETE 0x1 /* Incomplete transfer of cmd. */
  1454. #define CS_DMA 0x2 /* A DMA direction error. */
  1455. #define CS_TRANSPORT 0x3 /* Transport error. */
  1456. #define CS_RESET 0x4 /* SCSI bus reset occurred */
  1457. #define CS_ABORTED 0x5 /* System aborted command. */
  1458. #define CS_TIMEOUT 0x6 /* Timeout error. */
  1459. #define CS_DATA_OVERRUN 0x7 /* Data overrun. */
  1460. #define CS_DIF_ERROR 0xC /* DIF error detected */
  1461. #define CS_DATA_UNDERRUN 0x15 /* Data Underrun. */
  1462. #define CS_QUEUE_FULL 0x1C /* Queue Full. */
  1463. #define CS_PORT_UNAVAILABLE 0x28 /* Port unavailable */
  1464. /* (selection timeout) */
  1465. #define CS_PORT_LOGGED_OUT 0x29 /* Port Logged Out */
  1466. #define CS_PORT_CONFIG_CHG 0x2A /* Port Configuration Changed */
  1467. #define CS_PORT_BUSY 0x2B /* Port Busy */
  1468. #define CS_COMPLETE_CHKCOND 0x30 /* Error? */
  1469. #define CS_BAD_PAYLOAD 0x80 /* Driver defined */
  1470. #define CS_UNKNOWN 0x81 /* Driver defined */
  1471. #define CS_RETRY 0x82 /* Driver defined */
  1472. #define CS_LOOP_DOWN_ABORT 0x83 /* Driver defined */
  1473. #define CS_BIDIR_RD_OVERRUN 0x700
  1474. #define CS_BIDIR_RD_WR_OVERRUN 0x707
  1475. #define CS_BIDIR_RD_OVERRUN_WR_UNDERRUN 0x715
  1476. #define CS_BIDIR_RD_UNDERRUN 0x1500
  1477. #define CS_BIDIR_RD_UNDERRUN_WR_OVERRUN 0x1507
  1478. #define CS_BIDIR_RD_WR_UNDERRUN 0x1515
  1479. #define CS_BIDIR_DMA 0x200
  1480. /*
  1481. * Status entry status flags
  1482. */
  1483. #define SF_ABTS_TERMINATED BIT_10
  1484. #define SF_LOGOUT_SENT BIT_13
  1485. /*
  1486. * ISP queue - status continuation entry structure definition.
  1487. */
  1488. #define STATUS_CONT_TYPE 0x10 /* Status continuation entry. */
  1489. typedef struct {
  1490. uint8_t entry_type; /* Entry type. */
  1491. uint8_t entry_count; /* Entry count. */
  1492. uint8_t sys_define; /* System defined. */
  1493. uint8_t entry_status; /* Entry Status. */
  1494. uint8_t data[60]; /* data */
  1495. } sts_cont_entry_t;
  1496. /*
  1497. * ISP queue - RIO Type 1 status entry (32 bit I/O entry handles)
  1498. * structure definition.
  1499. */
  1500. #define STATUS_TYPE_21 0x21 /* Status entry. */
  1501. typedef struct {
  1502. uint8_t entry_type; /* Entry type. */
  1503. uint8_t entry_count; /* Entry count. */
  1504. uint8_t handle_count; /* Handle count. */
  1505. uint8_t entry_status; /* Entry Status. */
  1506. uint32_t handle[15]; /* System handles. */
  1507. } sts21_entry_t;
  1508. /*
  1509. * ISP queue - RIO Type 2 status entry (16 bit I/O entry handles)
  1510. * structure definition.
  1511. */
  1512. #define STATUS_TYPE_22 0x22 /* Status entry. */
  1513. typedef struct {
  1514. uint8_t entry_type; /* Entry type. */
  1515. uint8_t entry_count; /* Entry count. */
  1516. uint8_t handle_count; /* Handle count. */
  1517. uint8_t entry_status; /* Entry Status. */
  1518. uint16_t handle[30]; /* System handles. */
  1519. } sts22_entry_t;
  1520. /*
  1521. * ISP queue - marker entry structure definition.
  1522. */
  1523. #define MARKER_TYPE 0x04 /* Marker entry. */
  1524. typedef struct {
  1525. uint8_t entry_type; /* Entry type. */
  1526. uint8_t entry_count; /* Entry count. */
  1527. uint8_t handle_count; /* Handle count. */
  1528. uint8_t entry_status; /* Entry Status. */
  1529. uint32_t sys_define_2; /* System defined. */
  1530. target_id_t target; /* SCSI ID */
  1531. uint8_t modifier; /* Modifier (7-0). */
  1532. #define MK_SYNC_ID_LUN 0 /* Synchronize ID/LUN */
  1533. #define MK_SYNC_ID 1 /* Synchronize ID */
  1534. #define MK_SYNC_ALL 2 /* Synchronize all ID/LUN */
  1535. #define MK_SYNC_LIP 3 /* Synchronize all ID/LUN, */
  1536. /* clear port changed, */
  1537. /* use sequence number. */
  1538. uint8_t reserved_1;
  1539. uint16_t sequence_number; /* Sequence number of event */
  1540. uint16_t lun; /* SCSI LUN */
  1541. uint8_t reserved_2[48];
  1542. } mrk_entry_t;
  1543. /*
  1544. * ISP queue - Management Server entry structure definition.
  1545. */
  1546. #define MS_IOCB_TYPE 0x29 /* Management Server IOCB entry */
  1547. typedef struct {
  1548. uint8_t entry_type; /* Entry type. */
  1549. uint8_t entry_count; /* Entry count. */
  1550. uint8_t handle_count; /* Handle count. */
  1551. uint8_t entry_status; /* Entry Status. */
  1552. uint32_t handle1; /* System handle. */
  1553. target_id_t loop_id;
  1554. uint16_t status;
  1555. uint16_t control_flags; /* Control flags. */
  1556. uint16_t reserved2;
  1557. uint16_t timeout;
  1558. uint16_t cmd_dsd_count;
  1559. uint16_t total_dsd_count;
  1560. uint8_t type;
  1561. uint8_t r_ctl;
  1562. uint16_t rx_id;
  1563. uint16_t reserved3;
  1564. uint32_t handle2;
  1565. uint32_t rsp_bytecount;
  1566. uint32_t req_bytecount;
  1567. uint32_t dseg_req_address[2]; /* Data segment 0 address. */
  1568. uint32_t dseg_req_length; /* Data segment 0 length. */
  1569. uint32_t dseg_rsp_address[2]; /* Data segment 1 address. */
  1570. uint32_t dseg_rsp_length; /* Data segment 1 length. */
  1571. } ms_iocb_entry_t;
  1572. /*
  1573. * ISP queue - Mailbox Command entry structure definition.
  1574. */
  1575. #define MBX_IOCB_TYPE 0x39
  1576. struct mbx_entry {
  1577. uint8_t entry_type;
  1578. uint8_t entry_count;
  1579. uint8_t sys_define1;
  1580. /* Use sys_define1 for source type */
  1581. #define SOURCE_SCSI 0x00
  1582. #define SOURCE_IP 0x01
  1583. #define SOURCE_VI 0x02
  1584. #define SOURCE_SCTP 0x03
  1585. #define SOURCE_MP 0x04
  1586. #define SOURCE_MPIOCTL 0x05
  1587. #define SOURCE_ASYNC_IOCB 0x07
  1588. uint8_t entry_status;
  1589. uint32_t handle;
  1590. target_id_t loop_id;
  1591. uint16_t status;
  1592. uint16_t state_flags;
  1593. uint16_t status_flags;
  1594. uint32_t sys_define2[2];
  1595. uint16_t mb0;
  1596. uint16_t mb1;
  1597. uint16_t mb2;
  1598. uint16_t mb3;
  1599. uint16_t mb6;
  1600. uint16_t mb7;
  1601. uint16_t mb9;
  1602. uint16_t mb10;
  1603. uint32_t reserved_2[2];
  1604. uint8_t node_name[WWN_SIZE];
  1605. uint8_t port_name[WWN_SIZE];
  1606. };
  1607. /*
  1608. * ISP request and response queue entry sizes
  1609. */
  1610. #define RESPONSE_ENTRY_SIZE (sizeof(response_t))
  1611. #define REQUEST_ENTRY_SIZE (sizeof(request_t))
  1612. /*
  1613. * 24 bit port ID type definition.
  1614. */
  1615. typedef union {
  1616. uint32_t b24 : 24;
  1617. struct {
  1618. #ifdef __BIG_ENDIAN
  1619. uint8_t domain;
  1620. uint8_t area;
  1621. uint8_t al_pa;
  1622. #elif defined(__LITTLE_ENDIAN)
  1623. uint8_t al_pa;
  1624. uint8_t area;
  1625. uint8_t domain;
  1626. #else
  1627. #error "__BIG_ENDIAN or __LITTLE_ENDIAN must be defined!"
  1628. #endif
  1629. uint8_t rsvd_1;
  1630. } b;
  1631. } port_id_t;
  1632. #define INVALID_PORT_ID 0xFFFFFF
  1633. /*
  1634. * Switch info gathering structure.
  1635. */
  1636. typedef struct {
  1637. port_id_t d_id;
  1638. uint8_t node_name[WWN_SIZE];
  1639. uint8_t port_name[WWN_SIZE];
  1640. uint8_t fabric_port_name[WWN_SIZE];
  1641. uint16_t fp_speed;
  1642. uint8_t fc4_type;
  1643. } sw_info_t;
  1644. /* FCP-4 types */
  1645. #define FC4_TYPE_FCP_SCSI 0x08
  1646. #define FC4_TYPE_OTHER 0x0
  1647. #define FC4_TYPE_UNKNOWN 0xff
  1648. /*
  1649. * Fibre channel port type.
  1650. */
  1651. typedef enum {
  1652. FCT_UNKNOWN,
  1653. FCT_RSCN,
  1654. FCT_SWITCH,
  1655. FCT_BROADCAST,
  1656. FCT_INITIATOR,
  1657. FCT_TARGET
  1658. } fc_port_type_t;
  1659. /*
  1660. * Fibre channel port structure.
  1661. */
  1662. typedef struct fc_port {
  1663. struct list_head list;
  1664. struct scsi_qla_host *vha;
  1665. uint8_t node_name[WWN_SIZE];
  1666. uint8_t port_name[WWN_SIZE];
  1667. port_id_t d_id;
  1668. uint16_t loop_id;
  1669. uint16_t old_loop_id;
  1670. uint8_t fcp_prio;
  1671. uint8_t fabric_port_name[WWN_SIZE];
  1672. uint16_t fp_speed;
  1673. fc_port_type_t port_type;
  1674. atomic_t state;
  1675. uint32_t flags;
  1676. int login_retry;
  1677. struct fc_rport *rport, *drport;
  1678. u32 supported_classes;
  1679. uint8_t fc4_type;
  1680. uint8_t scan_state;
  1681. } fc_port_t;
  1682. /*
  1683. * Fibre channel port/lun states.
  1684. */
  1685. #define FCS_UNCONFIGURED 1
  1686. #define FCS_DEVICE_DEAD 2
  1687. #define FCS_DEVICE_LOST 3
  1688. #define FCS_ONLINE 4
  1689. static const char * const port_state_str[] = {
  1690. "Unknown",
  1691. "UNCONFIGURED",
  1692. "DEAD",
  1693. "LOST",
  1694. "ONLINE"
  1695. };
  1696. /*
  1697. * FC port flags.
  1698. */
  1699. #define FCF_FABRIC_DEVICE BIT_0
  1700. #define FCF_LOGIN_NEEDED BIT_1
  1701. #define FCF_FCP2_DEVICE BIT_2
  1702. #define FCF_ASYNC_SENT BIT_3
  1703. #define FCF_CONF_COMP_SUPPORTED BIT_4
  1704. /* No loop ID flag. */
  1705. #define FC_NO_LOOP_ID 0x1000
  1706. /*
  1707. * FC-CT interface
  1708. *
  1709. * NOTE: All structures are big-endian in form.
  1710. */
  1711. #define CT_REJECT_RESPONSE 0x8001
  1712. #define CT_ACCEPT_RESPONSE 0x8002
  1713. #define CT_REASON_INVALID_COMMAND_CODE 0x01
  1714. #define CT_REASON_CANNOT_PERFORM 0x09
  1715. #define CT_REASON_COMMAND_UNSUPPORTED 0x0b
  1716. #define CT_EXPL_ALREADY_REGISTERED 0x10
  1717. #define NS_N_PORT_TYPE 0x01
  1718. #define NS_NL_PORT_TYPE 0x02
  1719. #define NS_NX_PORT_TYPE 0x7F
  1720. #define GA_NXT_CMD 0x100
  1721. #define GA_NXT_REQ_SIZE (16 + 4)
  1722. #define GA_NXT_RSP_SIZE (16 + 620)
  1723. #define GID_PT_CMD 0x1A1
  1724. #define GID_PT_REQ_SIZE (16 + 4)
  1725. #define GPN_ID_CMD 0x112
  1726. #define GPN_ID_REQ_SIZE (16 + 4)
  1727. #define GPN_ID_RSP_SIZE (16 + 8)
  1728. #define GNN_ID_CMD 0x113
  1729. #define GNN_ID_REQ_SIZE (16 + 4)
  1730. #define GNN_ID_RSP_SIZE (16 + 8)
  1731. #define GFT_ID_CMD 0x117
  1732. #define GFT_ID_REQ_SIZE (16 + 4)
  1733. #define GFT_ID_RSP_SIZE (16 + 32)
  1734. #define RFT_ID_CMD 0x217
  1735. #define RFT_ID_REQ_SIZE (16 + 4 + 32)
  1736. #define RFT_ID_RSP_SIZE 16
  1737. #define RFF_ID_CMD 0x21F
  1738. #define RFF_ID_REQ_SIZE (16 + 4 + 2 + 1 + 1)
  1739. #define RFF_ID_RSP_SIZE 16
  1740. #define RNN_ID_CMD 0x213
  1741. #define RNN_ID_REQ_SIZE (16 + 4 + 8)
  1742. #define RNN_ID_RSP_SIZE 16
  1743. #define RSNN_NN_CMD 0x239
  1744. #define RSNN_NN_REQ_SIZE (16 + 8 + 1 + 255)
  1745. #define RSNN_NN_RSP_SIZE 16
  1746. #define GFPN_ID_CMD 0x11C
  1747. #define GFPN_ID_REQ_SIZE (16 + 4)
  1748. #define GFPN_ID_RSP_SIZE (16 + 8)
  1749. #define GPSC_CMD 0x127
  1750. #define GPSC_REQ_SIZE (16 + 8)
  1751. #define GPSC_RSP_SIZE (16 + 2 + 2)
  1752. #define GFF_ID_CMD 0x011F
  1753. #define GFF_ID_REQ_SIZE (16 + 4)
  1754. #define GFF_ID_RSP_SIZE (16 + 128)
  1755. /*
  1756. * HBA attribute types.
  1757. */
  1758. #define FDMI_HBA_ATTR_COUNT 9
  1759. #define FDMI_HBA_NODE_NAME 1
  1760. #define FDMI_HBA_MANUFACTURER 2
  1761. #define FDMI_HBA_SERIAL_NUMBER 3
  1762. #define FDMI_HBA_MODEL 4
  1763. #define FDMI_HBA_MODEL_DESCRIPTION 5
  1764. #define FDMI_HBA_HARDWARE_VERSION 6
  1765. #define FDMI_HBA_DRIVER_VERSION 7
  1766. #define FDMI_HBA_OPTION_ROM_VERSION 8
  1767. #define FDMI_HBA_FIRMWARE_VERSION 9
  1768. #define FDMI_HBA_OS_NAME_AND_VERSION 0xa
  1769. #define FDMI_HBA_MAXIMUM_CT_PAYLOAD_LENGTH 0xb
  1770. struct ct_fdmi_hba_attr {
  1771. uint16_t type;
  1772. uint16_t len;
  1773. union {
  1774. uint8_t node_name[WWN_SIZE];
  1775. uint8_t manufacturer[32];
  1776. uint8_t serial_num[8];
  1777. uint8_t model[16];
  1778. uint8_t model_desc[80];
  1779. uint8_t hw_version[16];
  1780. uint8_t driver_version[32];
  1781. uint8_t orom_version[16];
  1782. uint8_t fw_version[16];
  1783. uint8_t os_version[128];
  1784. uint8_t max_ct_len[4];
  1785. } a;
  1786. };
  1787. struct ct_fdmi_hba_attributes {
  1788. uint32_t count;
  1789. struct ct_fdmi_hba_attr entry[FDMI_HBA_ATTR_COUNT];
  1790. };
  1791. /*
  1792. * Port attribute types.
  1793. */
  1794. #define FDMI_PORT_ATTR_COUNT 6
  1795. #define FDMI_PORT_FC4_TYPES 1
  1796. #define FDMI_PORT_SUPPORT_SPEED 2
  1797. #define FDMI_PORT_CURRENT_SPEED 3
  1798. #define FDMI_PORT_MAX_FRAME_SIZE 4
  1799. #define FDMI_PORT_OS_DEVICE_NAME 5
  1800. #define FDMI_PORT_HOST_NAME 6
  1801. #define FDMI_PORT_SPEED_1GB 0x1
  1802. #define FDMI_PORT_SPEED_2GB 0x2
  1803. #define FDMI_PORT_SPEED_10GB 0x4
  1804. #define FDMI_PORT_SPEED_4GB 0x8
  1805. #define FDMI_PORT_SPEED_8GB 0x10
  1806. #define FDMI_PORT_SPEED_16GB 0x20
  1807. #define FDMI_PORT_SPEED_UNKNOWN 0x8000
  1808. struct ct_fdmi_port_attr {
  1809. uint16_t type;
  1810. uint16_t len;
  1811. union {
  1812. uint8_t fc4_types[32];
  1813. uint32_t sup_speed;
  1814. uint32_t cur_speed;
  1815. uint32_t max_frame_size;
  1816. uint8_t os_dev_name[32];
  1817. uint8_t host_name[32];
  1818. } a;
  1819. };
  1820. /*
  1821. * Port Attribute Block.
  1822. */
  1823. struct ct_fdmi_port_attributes {
  1824. uint32_t count;
  1825. struct ct_fdmi_port_attr entry[FDMI_PORT_ATTR_COUNT];
  1826. };
  1827. /* FDMI definitions. */
  1828. #define GRHL_CMD 0x100
  1829. #define GHAT_CMD 0x101
  1830. #define GRPL_CMD 0x102
  1831. #define GPAT_CMD 0x110
  1832. #define RHBA_CMD 0x200
  1833. #define RHBA_RSP_SIZE 16
  1834. #define RHAT_CMD 0x201
  1835. #define RPRT_CMD 0x210
  1836. #define RPA_CMD 0x211
  1837. #define RPA_RSP_SIZE 16
  1838. #define DHBA_CMD 0x300
  1839. #define DHBA_REQ_SIZE (16 + 8)
  1840. #define DHBA_RSP_SIZE 16
  1841. #define DHAT_CMD 0x301
  1842. #define DPRT_CMD 0x310
  1843. #define DPA_CMD 0x311
  1844. /* CT command header -- request/response common fields */
  1845. struct ct_cmd_hdr {
  1846. uint8_t revision;
  1847. uint8_t in_id[3];
  1848. uint8_t gs_type;
  1849. uint8_t gs_subtype;
  1850. uint8_t options;
  1851. uint8_t reserved;
  1852. };
  1853. /* CT command request */
  1854. struct ct_sns_req {
  1855. struct ct_cmd_hdr header;
  1856. uint16_t command;
  1857. uint16_t max_rsp_size;
  1858. uint8_t fragment_id;
  1859. uint8_t reserved[3];
  1860. union {
  1861. /* GA_NXT, GPN_ID, GNN_ID, GFT_ID, GFPN_ID */
  1862. struct {
  1863. uint8_t reserved;
  1864. uint8_t port_id[3];
  1865. } port_id;
  1866. struct {
  1867. uint8_t port_type;
  1868. uint8_t domain;
  1869. uint8_t area;
  1870. uint8_t reserved;
  1871. } gid_pt;
  1872. struct {
  1873. uint8_t reserved;
  1874. uint8_t port_id[3];
  1875. uint8_t fc4_types[32];
  1876. } rft_id;
  1877. struct {
  1878. uint8_t reserved;
  1879. uint8_t port_id[3];
  1880. uint16_t reserved2;
  1881. uint8_t fc4_feature;
  1882. uint8_t fc4_type;
  1883. } rff_id;
  1884. struct {
  1885. uint8_t reserved;
  1886. uint8_t port_id[3];
  1887. uint8_t node_name[8];
  1888. } rnn_id;
  1889. struct {
  1890. uint8_t node_name[8];
  1891. uint8_t name_len;
  1892. uint8_t sym_node_name[255];
  1893. } rsnn_nn;
  1894. struct {
  1895. uint8_t hba_indentifier[8];
  1896. } ghat;
  1897. struct {
  1898. uint8_t hba_identifier[8];
  1899. uint32_t entry_count;
  1900. uint8_t port_name[8];
  1901. struct ct_fdmi_hba_attributes attrs;
  1902. } rhba;
  1903. struct {
  1904. uint8_t hba_identifier[8];
  1905. struct ct_fdmi_hba_attributes attrs;
  1906. } rhat;
  1907. struct {
  1908. uint8_t port_name[8];
  1909. struct ct_fdmi_port_attributes attrs;
  1910. } rpa;
  1911. struct {
  1912. uint8_t port_name[8];
  1913. } dhba;
  1914. struct {
  1915. uint8_t port_name[8];
  1916. } dhat;
  1917. struct {
  1918. uint8_t port_name[8];
  1919. } dprt;
  1920. struct {
  1921. uint8_t port_name[8];
  1922. } dpa;
  1923. struct {
  1924. uint8_t port_name[8];
  1925. } gpsc;
  1926. struct {
  1927. uint8_t reserved;
  1928. uint8_t port_name[3];
  1929. } gff_id;
  1930. } req;
  1931. };
  1932. /* CT command response header */
  1933. struct ct_rsp_hdr {
  1934. struct ct_cmd_hdr header;
  1935. uint16_t response;
  1936. uint16_t residual;
  1937. uint8_t fragment_id;
  1938. uint8_t reason_code;
  1939. uint8_t explanation_code;
  1940. uint8_t vendor_unique;
  1941. };
  1942. struct ct_sns_gid_pt_data {
  1943. uint8_t control_byte;
  1944. uint8_t port_id[3];
  1945. };
  1946. struct ct_sns_rsp {
  1947. struct ct_rsp_hdr header;
  1948. union {
  1949. struct {
  1950. uint8_t port_type;
  1951. uint8_t port_id[3];
  1952. uint8_t port_name[8];
  1953. uint8_t sym_port_name_len;
  1954. uint8_t sym_port_name[255];
  1955. uint8_t node_name[8];
  1956. uint8_t sym_node_name_len;
  1957. uint8_t sym_node_name[255];
  1958. uint8_t init_proc_assoc[8];
  1959. uint8_t node_ip_addr[16];
  1960. uint8_t class_of_service[4];
  1961. uint8_t fc4_types[32];
  1962. uint8_t ip_address[16];
  1963. uint8_t fabric_port_name[8];
  1964. uint8_t reserved;
  1965. uint8_t hard_address[3];
  1966. } ga_nxt;
  1967. struct {
  1968. /* Assume the largest number of targets for the union */
  1969. struct ct_sns_gid_pt_data
  1970. entries[MAX_FIBRE_DEVICES_MAX];
  1971. } gid_pt;
  1972. struct {
  1973. uint8_t port_name[8];
  1974. } gpn_id;
  1975. struct {
  1976. uint8_t node_name[8];
  1977. } gnn_id;
  1978. struct {
  1979. uint8_t fc4_types[32];
  1980. } gft_id;
  1981. struct {
  1982. uint32_t entry_count;
  1983. uint8_t port_name[8];
  1984. struct ct_fdmi_hba_attributes attrs;
  1985. } ghat;
  1986. struct {
  1987. uint8_t port_name[8];
  1988. } gfpn_id;
  1989. struct {
  1990. uint16_t speeds;
  1991. uint16_t speed;
  1992. } gpsc;
  1993. #define GFF_FCP_SCSI_OFFSET 7
  1994. struct {
  1995. uint8_t fc4_features[128];
  1996. } gff_id;
  1997. } rsp;
  1998. };
  1999. struct ct_sns_pkt {
  2000. union {
  2001. struct ct_sns_req req;
  2002. struct ct_sns_rsp rsp;
  2003. } p;
  2004. };
  2005. /*
  2006. * SNS command structures -- for 2200 compatibility.
  2007. */
  2008. #define RFT_ID_SNS_SCMD_LEN 22
  2009. #define RFT_ID_SNS_CMD_SIZE 60
  2010. #define RFT_ID_SNS_DATA_SIZE 16
  2011. #define RNN_ID_SNS_SCMD_LEN 10
  2012. #define RNN_ID_SNS_CMD_SIZE 36
  2013. #define RNN_ID_SNS_DATA_SIZE 16
  2014. #define GA_NXT_SNS_SCMD_LEN 6
  2015. #define GA_NXT_SNS_CMD_SIZE 28
  2016. #define GA_NXT_SNS_DATA_SIZE (620 + 16)
  2017. #define GID_PT_SNS_SCMD_LEN 6
  2018. #define GID_PT_SNS_CMD_SIZE 28
  2019. /*
  2020. * Assume MAX_FIBRE_DEVICES_2100 as these defines are only used with older
  2021. * adapters.
  2022. */
  2023. #define GID_PT_SNS_DATA_SIZE (MAX_FIBRE_DEVICES_2100 * 4 + 16)
  2024. #define GPN_ID_SNS_SCMD_LEN 6
  2025. #define GPN_ID_SNS_CMD_SIZE 28
  2026. #define GPN_ID_SNS_DATA_SIZE (8 + 16)
  2027. #define GNN_ID_SNS_SCMD_LEN 6
  2028. #define GNN_ID_SNS_CMD_SIZE 28
  2029. #define GNN_ID_SNS_DATA_SIZE (8 + 16)
  2030. struct sns_cmd_pkt {
  2031. union {
  2032. struct {
  2033. uint16_t buffer_length;
  2034. uint16_t reserved_1;
  2035. uint32_t buffer_address[2];
  2036. uint16_t subcommand_length;
  2037. uint16_t reserved_2;
  2038. uint16_t subcommand;
  2039. uint16_t size;
  2040. uint32_t reserved_3;
  2041. uint8_t param[36];
  2042. } cmd;
  2043. uint8_t rft_data[RFT_ID_SNS_DATA_SIZE];
  2044. uint8_t rnn_data[RNN_ID_SNS_DATA_SIZE];
  2045. uint8_t gan_data[GA_NXT_SNS_DATA_SIZE];
  2046. uint8_t gid_data[GID_PT_SNS_DATA_SIZE];
  2047. uint8_t gpn_data[GPN_ID_SNS_DATA_SIZE];
  2048. uint8_t gnn_data[GNN_ID_SNS_DATA_SIZE];
  2049. } p;
  2050. };
  2051. struct fw_blob {
  2052. char *name;
  2053. uint32_t segs[4];
  2054. const struct firmware *fw;
  2055. };
  2056. /* Return data from MBC_GET_ID_LIST call. */
  2057. struct gid_list_info {
  2058. uint8_t al_pa;
  2059. uint8_t area;
  2060. uint8_t domain;
  2061. uint8_t loop_id_2100; /* ISP2100/ISP2200 -- 4 bytes. */
  2062. uint16_t loop_id; /* ISP23XX -- 6 bytes. */
  2063. uint16_t reserved_1; /* ISP24XX -- 8 bytes. */
  2064. };
  2065. /* NPIV */
  2066. typedef struct vport_info {
  2067. uint8_t port_name[WWN_SIZE];
  2068. uint8_t node_name[WWN_SIZE];
  2069. int vp_id;
  2070. uint16_t loop_id;
  2071. unsigned long host_no;
  2072. uint8_t port_id[3];
  2073. int loop_state;
  2074. } vport_info_t;
  2075. typedef struct vport_params {
  2076. uint8_t port_name[WWN_SIZE];
  2077. uint8_t node_name[WWN_SIZE];
  2078. uint32_t options;
  2079. #define VP_OPTS_RETRY_ENABLE BIT_0
  2080. #define VP_OPTS_VP_DISABLE BIT_1
  2081. } vport_params_t;
  2082. /* NPIV - return codes of VP create and modify */
  2083. #define VP_RET_CODE_OK 0
  2084. #define VP_RET_CODE_FATAL 1
  2085. #define VP_RET_CODE_WRONG_ID 2
  2086. #define VP_RET_CODE_WWPN 3
  2087. #define VP_RET_CODE_RESOURCES 4
  2088. #define VP_RET_CODE_NO_MEM 5
  2089. #define VP_RET_CODE_NOT_FOUND 6
  2090. struct qla_hw_data;
  2091. struct rsp_que;
  2092. /*
  2093. * ISP operations
  2094. */
  2095. struct isp_operations {
  2096. int (*pci_config) (struct scsi_qla_host *);
  2097. void (*reset_chip) (struct scsi_qla_host *);
  2098. int (*chip_diag) (struct scsi_qla_host *);
  2099. void (*config_rings) (struct scsi_qla_host *);
  2100. void (*reset_adapter) (struct scsi_qla_host *);
  2101. int (*nvram_config) (struct scsi_qla_host *);
  2102. void (*update_fw_options) (struct scsi_qla_host *);
  2103. int (*load_risc) (struct scsi_qla_host *, uint32_t *);
  2104. char * (*pci_info_str) (struct scsi_qla_host *, char *);
  2105. char * (*fw_version_str) (struct scsi_qla_host *, char *);
  2106. irq_handler_t intr_handler;
  2107. void (*enable_intrs) (struct qla_hw_data *);
  2108. void (*disable_intrs) (struct qla_hw_data *);
  2109. int (*abort_command) (srb_t *);
  2110. int (*target_reset) (struct fc_port *, unsigned int, int);
  2111. int (*lun_reset) (struct fc_port *, unsigned int, int);
  2112. int (*fabric_login) (struct scsi_qla_host *, uint16_t, uint8_t,
  2113. uint8_t, uint8_t, uint16_t *, uint8_t);
  2114. int (*fabric_logout) (struct scsi_qla_host *, uint16_t, uint8_t,
  2115. uint8_t, uint8_t);
  2116. uint16_t (*calc_req_entries) (uint16_t);
  2117. void (*build_iocbs) (srb_t *, cmd_entry_t *, uint16_t);
  2118. void * (*prep_ms_iocb) (struct scsi_qla_host *, uint32_t, uint32_t);
  2119. void * (*prep_ms_fdmi_iocb) (struct scsi_qla_host *, uint32_t,
  2120. uint32_t);
  2121. uint8_t * (*read_nvram) (struct scsi_qla_host *, uint8_t *,
  2122. uint32_t, uint32_t);
  2123. int (*write_nvram) (struct scsi_qla_host *, uint8_t *, uint32_t,
  2124. uint32_t);
  2125. void (*fw_dump) (struct scsi_qla_host *, int);
  2126. int (*beacon_on) (struct scsi_qla_host *);
  2127. int (*beacon_off) (struct scsi_qla_host *);
  2128. void (*beacon_blink) (struct scsi_qla_host *);
  2129. uint8_t * (*read_optrom) (struct scsi_qla_host *, uint8_t *,
  2130. uint32_t, uint32_t);
  2131. int (*write_optrom) (struct scsi_qla_host *, uint8_t *, uint32_t,
  2132. uint32_t);
  2133. int (*get_flash_version) (struct scsi_qla_host *, void *);
  2134. int (*start_scsi) (srb_t *);
  2135. int (*abort_isp) (struct scsi_qla_host *);
  2136. int (*iospace_config)(struct qla_hw_data*);
  2137. };
  2138. /* MSI-X Support *************************************************************/
  2139. #define QLA_MSIX_CHIP_REV_24XX 3
  2140. #define QLA_MSIX_FW_MODE(m) (((m) & (BIT_7|BIT_8|BIT_9)) >> 7)
  2141. #define QLA_MSIX_FW_MODE_1(m) (QLA_MSIX_FW_MODE(m) == 1)
  2142. #define QLA_MSIX_DEFAULT 0x00
  2143. #define QLA_MSIX_RSP_Q 0x01
  2144. #define QLA_MIDX_DEFAULT 0
  2145. #define QLA_MIDX_RSP_Q 1
  2146. #define QLA_PCI_MSIX_CONTROL 0xa2
  2147. #define QLA_83XX_PCI_MSIX_CONTROL 0x92
  2148. struct scsi_qla_host;
  2149. struct qla_msix_entry {
  2150. int have_irq;
  2151. uint32_t vector;
  2152. uint16_t entry;
  2153. struct rsp_que *rsp;
  2154. };
  2155. #define WATCH_INTERVAL 1 /* number of seconds */
  2156. /* Work events. */
  2157. enum qla_work_type {
  2158. QLA_EVT_AEN,
  2159. QLA_EVT_IDC_ACK,
  2160. QLA_EVT_ASYNC_LOGIN,
  2161. QLA_EVT_ASYNC_LOGIN_DONE,
  2162. QLA_EVT_ASYNC_LOGOUT,
  2163. QLA_EVT_ASYNC_LOGOUT_DONE,
  2164. QLA_EVT_ASYNC_ADISC,
  2165. QLA_EVT_ASYNC_ADISC_DONE,
  2166. QLA_EVT_UEVENT,
  2167. };
  2168. struct qla_work_evt {
  2169. struct list_head list;
  2170. enum qla_work_type type;
  2171. u32 flags;
  2172. #define QLA_EVT_FLAG_FREE 0x1
  2173. union {
  2174. struct {
  2175. enum fc_host_event_code code;
  2176. u32 data;
  2177. } aen;
  2178. struct {
  2179. #define QLA_IDC_ACK_REGS 7
  2180. uint16_t mb[QLA_IDC_ACK_REGS];
  2181. } idc_ack;
  2182. struct {
  2183. struct fc_port *fcport;
  2184. #define QLA_LOGIO_LOGIN_RETRIED BIT_0
  2185. u16 data[2];
  2186. } logio;
  2187. struct {
  2188. u32 code;
  2189. #define QLA_UEVENT_CODE_FW_DUMP 0
  2190. } uevent;
  2191. } u;
  2192. };
  2193. struct qla_chip_state_84xx {
  2194. struct list_head list;
  2195. struct kref kref;
  2196. void *bus;
  2197. spinlock_t access_lock;
  2198. struct mutex fw_update_mutex;
  2199. uint32_t fw_update;
  2200. uint32_t op_fw_version;
  2201. uint32_t op_fw_size;
  2202. uint32_t op_fw_seq_size;
  2203. uint32_t diag_fw_version;
  2204. uint32_t gold_fw_version;
  2205. };
  2206. struct qla_statistics {
  2207. uint32_t total_isp_aborts;
  2208. uint64_t input_bytes;
  2209. uint64_t output_bytes;
  2210. };
  2211. struct bidi_statistics {
  2212. unsigned long long io_count;
  2213. unsigned long long transfer_bytes;
  2214. };
  2215. /* Multi queue support */
  2216. #define MBC_INITIALIZE_MULTIQ 0x1f
  2217. #define QLA_QUE_PAGE 0X1000
  2218. #define QLA_MQ_SIZE 32
  2219. #define QLA_MAX_QUEUES 256
  2220. #define ISP_QUE_REG(ha, id) \
  2221. ((ha->mqenable || IS_QLA83XX(ha)) ? \
  2222. ((device_reg_t __iomem *)(ha->mqiobase) +\
  2223. (QLA_QUE_PAGE * id)) :\
  2224. ((device_reg_t __iomem *)(ha->iobase)))
  2225. #define QLA_REQ_QUE_ID(tag) \
  2226. ((tag < QLA_MAX_QUEUES && tag > 0) ? tag : 0)
  2227. #define QLA_DEFAULT_QUE_QOS 5
  2228. #define QLA_PRECONFIG_VPORTS 32
  2229. #define QLA_MAX_VPORTS_QLA24XX 128
  2230. #define QLA_MAX_VPORTS_QLA25XX 256
  2231. /* Response queue data structure */
  2232. struct rsp_que {
  2233. dma_addr_t dma;
  2234. response_t *ring;
  2235. response_t *ring_ptr;
  2236. uint32_t __iomem *rsp_q_in; /* FWI2-capable only. */
  2237. uint32_t __iomem *rsp_q_out;
  2238. uint16_t ring_index;
  2239. uint16_t out_ptr;
  2240. uint16_t length;
  2241. uint16_t options;
  2242. uint16_t rid;
  2243. uint16_t id;
  2244. uint16_t vp_idx;
  2245. struct qla_hw_data *hw;
  2246. struct qla_msix_entry *msix;
  2247. struct req_que *req;
  2248. srb_t *status_srb; /* status continuation entry */
  2249. struct work_struct q_work;
  2250. };
  2251. /* Request queue data structure */
  2252. struct req_que {
  2253. dma_addr_t dma;
  2254. request_t *ring;
  2255. request_t *ring_ptr;
  2256. uint32_t __iomem *req_q_in; /* FWI2-capable only. */
  2257. uint32_t __iomem *req_q_out;
  2258. uint16_t ring_index;
  2259. uint16_t in_ptr;
  2260. uint16_t cnt;
  2261. uint16_t length;
  2262. uint16_t options;
  2263. uint16_t rid;
  2264. uint16_t id;
  2265. uint16_t qos;
  2266. uint16_t vp_idx;
  2267. struct rsp_que *rsp;
  2268. srb_t **outstanding_cmds;
  2269. uint32_t current_outstanding_cmd;
  2270. uint16_t num_outstanding_cmds;
  2271. #define MAX_Q_DEPTH 32
  2272. int max_q_depth;
  2273. };
  2274. /* Place holder for FW buffer parameters */
  2275. struct qlfc_fw {
  2276. void *fw_buf;
  2277. dma_addr_t fw_dma;
  2278. uint32_t len;
  2279. };
  2280. struct qlt_hw_data {
  2281. /* Protected by hw lock */
  2282. uint32_t enable_class_2:1;
  2283. uint32_t enable_explicit_conf:1;
  2284. uint32_t ini_mode_force_reverse:1;
  2285. uint32_t node_name_set:1;
  2286. dma_addr_t atio_dma; /* Physical address. */
  2287. struct atio *atio_ring; /* Base virtual address */
  2288. struct atio *atio_ring_ptr; /* Current address. */
  2289. uint16_t atio_ring_index; /* Current index. */
  2290. uint16_t atio_q_length;
  2291. uint32_t __iomem *atio_q_in;
  2292. uint32_t __iomem *atio_q_out;
  2293. void *target_lport_ptr;
  2294. struct qla_tgt_func_tmpl *tgt_ops;
  2295. struct qla_tgt *qla_tgt;
  2296. struct qla_tgt_cmd *cmds[DEFAULT_OUTSTANDING_COMMANDS];
  2297. uint16_t current_handle;
  2298. struct qla_tgt_vp_map *tgt_vp_map;
  2299. struct mutex tgt_mutex;
  2300. struct mutex tgt_host_action_mutex;
  2301. int saved_set;
  2302. uint16_t saved_exchange_count;
  2303. uint32_t saved_firmware_options_1;
  2304. uint32_t saved_firmware_options_2;
  2305. uint32_t saved_firmware_options_3;
  2306. uint8_t saved_firmware_options[2];
  2307. uint8_t saved_add_firmware_options[2];
  2308. uint8_t tgt_node_name[WWN_SIZE];
  2309. };
  2310. /*
  2311. * Qlogic host adapter specific data structure.
  2312. */
  2313. struct qla_hw_data {
  2314. struct pci_dev *pdev;
  2315. /* SRB cache. */
  2316. #define SRB_MIN_REQ 128
  2317. mempool_t *srb_mempool;
  2318. volatile struct {
  2319. uint32_t mbox_int :1;
  2320. uint32_t mbox_busy :1;
  2321. uint32_t disable_risc_code_load :1;
  2322. uint32_t enable_64bit_addressing :1;
  2323. uint32_t enable_lip_reset :1;
  2324. uint32_t enable_target_reset :1;
  2325. uint32_t enable_lip_full_login :1;
  2326. uint32_t enable_led_scheme :1;
  2327. uint32_t msi_enabled :1;
  2328. uint32_t msix_enabled :1;
  2329. uint32_t disable_serdes :1;
  2330. uint32_t gpsc_supported :1;
  2331. uint32_t npiv_supported :1;
  2332. uint32_t pci_channel_io_perm_failure :1;
  2333. uint32_t fce_enabled :1;
  2334. uint32_t fac_supported :1;
  2335. uint32_t chip_reset_done :1;
  2336. uint32_t port0 :1;
  2337. uint32_t running_gold_fw :1;
  2338. uint32_t eeh_busy :1;
  2339. uint32_t cpu_affinity_enabled :1;
  2340. uint32_t disable_msix_handshake :1;
  2341. uint32_t fcp_prio_enabled :1;
  2342. uint32_t isp82xx_fw_hung:1;
  2343. uint32_t nic_core_hung:1;
  2344. uint32_t quiesce_owner:1;
  2345. uint32_t nic_core_reset_hdlr_active:1;
  2346. uint32_t nic_core_reset_owner:1;
  2347. uint32_t isp82xx_no_md_cap:1;
  2348. uint32_t host_shutting_down:1;
  2349. uint32_t idc_compl_status:1;
  2350. /* 32 bits */
  2351. } flags;
  2352. /* This spinlock is used to protect "io transactions", you must
  2353. * acquire it before doing any IO to the card, eg with RD_REG*() and
  2354. * WRT_REG*() for the duration of your entire commandtransaction.
  2355. *
  2356. * This spinlock is of lower priority than the io request lock.
  2357. */
  2358. spinlock_t hardware_lock ____cacheline_aligned;
  2359. int bars;
  2360. int mem_only;
  2361. device_reg_t __iomem *iobase; /* Base I/O address */
  2362. resource_size_t pio_address;
  2363. #define MIN_IOBASE_LEN 0x100
  2364. /* Multi queue data structs */
  2365. device_reg_t __iomem *mqiobase;
  2366. device_reg_t __iomem *msixbase;
  2367. uint16_t msix_count;
  2368. uint8_t mqenable;
  2369. struct req_que **req_q_map;
  2370. struct rsp_que **rsp_q_map;
  2371. unsigned long req_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
  2372. unsigned long rsp_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
  2373. uint8_t max_req_queues;
  2374. uint8_t max_rsp_queues;
  2375. struct qla_npiv_entry *npiv_info;
  2376. uint16_t nvram_npiv_size;
  2377. uint16_t switch_cap;
  2378. #define FLOGI_SEQ_DEL BIT_8
  2379. #define FLOGI_MID_SUPPORT BIT_10
  2380. #define FLOGI_VSAN_SUPPORT BIT_12
  2381. #define FLOGI_SP_SUPPORT BIT_13
  2382. uint8_t port_no; /* Physical port of adapter */
  2383. /* Timeout timers. */
  2384. uint8_t loop_down_abort_time; /* port down timer */
  2385. atomic_t loop_down_timer; /* loop down timer */
  2386. uint8_t link_down_timeout; /* link down timeout */
  2387. uint16_t max_loop_id;
  2388. uint16_t max_fibre_devices; /* Maximum number of targets */
  2389. uint16_t fb_rev;
  2390. uint16_t min_external_loopid; /* First external loop Id */
  2391. #define PORT_SPEED_UNKNOWN 0xFFFF
  2392. #define PORT_SPEED_1GB 0x00
  2393. #define PORT_SPEED_2GB 0x01
  2394. #define PORT_SPEED_4GB 0x03
  2395. #define PORT_SPEED_8GB 0x04
  2396. #define PORT_SPEED_16GB 0x05
  2397. #define PORT_SPEED_10GB 0x13
  2398. uint16_t link_data_rate; /* F/W operating speed */
  2399. uint8_t current_topology;
  2400. uint8_t prev_topology;
  2401. #define ISP_CFG_NL 1
  2402. #define ISP_CFG_N 2
  2403. #define ISP_CFG_FL 4
  2404. #define ISP_CFG_F 8
  2405. uint8_t operating_mode; /* F/W operating mode */
  2406. #define LOOP 0
  2407. #define P2P 1
  2408. #define LOOP_P2P 2
  2409. #define P2P_LOOP 3
  2410. uint8_t interrupts_on;
  2411. uint32_t isp_abort_cnt;
  2412. #define PCI_DEVICE_ID_QLOGIC_ISP2532 0x2532
  2413. #define PCI_DEVICE_ID_QLOGIC_ISP8432 0x8432
  2414. #define PCI_DEVICE_ID_QLOGIC_ISP8001 0x8001
  2415. #define PCI_DEVICE_ID_QLOGIC_ISP8031 0x8031
  2416. #define PCI_DEVICE_ID_QLOGIC_ISP2031 0x2031
  2417. uint32_t device_type;
  2418. #define DT_ISP2100 BIT_0
  2419. #define DT_ISP2200 BIT_1
  2420. #define DT_ISP2300 BIT_2
  2421. #define DT_ISP2312 BIT_3
  2422. #define DT_ISP2322 BIT_4
  2423. #define DT_ISP6312 BIT_5
  2424. #define DT_ISP6322 BIT_6
  2425. #define DT_ISP2422 BIT_7
  2426. #define DT_ISP2432 BIT_8
  2427. #define DT_ISP5422 BIT_9
  2428. #define DT_ISP5432 BIT_10
  2429. #define DT_ISP2532 BIT_11
  2430. #define DT_ISP8432 BIT_12
  2431. #define DT_ISP8001 BIT_13
  2432. #define DT_ISP8021 BIT_14
  2433. #define DT_ISP2031 BIT_15
  2434. #define DT_ISP8031 BIT_16
  2435. #define DT_ISP_LAST (DT_ISP8031 << 1)
  2436. #define DT_T10_PI BIT_25
  2437. #define DT_IIDMA BIT_26
  2438. #define DT_FWI2 BIT_27
  2439. #define DT_ZIO_SUPPORTED BIT_28
  2440. #define DT_OEM_001 BIT_29
  2441. #define DT_ISP2200A BIT_30
  2442. #define DT_EXTENDED_IDS BIT_31
  2443. #define DT_MASK(ha) ((ha)->device_type & (DT_ISP_LAST - 1))
  2444. #define IS_QLA2100(ha) (DT_MASK(ha) & DT_ISP2100)
  2445. #define IS_QLA2200(ha) (DT_MASK(ha) & DT_ISP2200)
  2446. #define IS_QLA2300(ha) (DT_MASK(ha) & DT_ISP2300)
  2447. #define IS_QLA2312(ha) (DT_MASK(ha) & DT_ISP2312)
  2448. #define IS_QLA2322(ha) (DT_MASK(ha) & DT_ISP2322)
  2449. #define IS_QLA6312(ha) (DT_MASK(ha) & DT_ISP6312)
  2450. #define IS_QLA6322(ha) (DT_MASK(ha) & DT_ISP6322)
  2451. #define IS_QLA2422(ha) (DT_MASK(ha) & DT_ISP2422)
  2452. #define IS_QLA2432(ha) (DT_MASK(ha) & DT_ISP2432)
  2453. #define IS_QLA5422(ha) (DT_MASK(ha) & DT_ISP5422)
  2454. #define IS_QLA5432(ha) (DT_MASK(ha) & DT_ISP5432)
  2455. #define IS_QLA2532(ha) (DT_MASK(ha) & DT_ISP2532)
  2456. #define IS_QLA8432(ha) (DT_MASK(ha) & DT_ISP8432)
  2457. #define IS_QLA8001(ha) (DT_MASK(ha) & DT_ISP8001)
  2458. #define IS_QLA81XX(ha) (IS_QLA8001(ha))
  2459. #define IS_QLA82XX(ha) (DT_MASK(ha) & DT_ISP8021)
  2460. #define IS_QLA2031(ha) (DT_MASK(ha) & DT_ISP2031)
  2461. #define IS_QLA8031(ha) (DT_MASK(ha) & DT_ISP8031)
  2462. #define IS_QLA23XX(ha) (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \
  2463. IS_QLA6312(ha) || IS_QLA6322(ha))
  2464. #define IS_QLA24XX(ha) (IS_QLA2422(ha) || IS_QLA2432(ha))
  2465. #define IS_QLA54XX(ha) (IS_QLA5422(ha) || IS_QLA5432(ha))
  2466. #define IS_QLA25XX(ha) (IS_QLA2532(ha))
  2467. #define IS_QLA83XX(ha) (IS_QLA2031(ha) || IS_QLA8031(ha))
  2468. #define IS_QLA84XX(ha) (IS_QLA8432(ha))
  2469. #define IS_QLA24XX_TYPE(ha) (IS_QLA24XX(ha) || IS_QLA54XX(ha) || \
  2470. IS_QLA84XX(ha))
  2471. #define IS_CNA_CAPABLE(ha) (IS_QLA81XX(ha) || IS_QLA82XX(ha) || \
  2472. IS_QLA8031(ha))
  2473. #define IS_QLA2XXX_MIDTYPE(ha) (IS_QLA24XX(ha) || IS_QLA84XX(ha) || \
  2474. IS_QLA25XX(ha) || IS_QLA81XX(ha) || \
  2475. IS_QLA82XX(ha) || IS_QLA83XX(ha))
  2476. #define IS_MSIX_NACK_CAPABLE(ha) (IS_QLA81XX(ha) || IS_QLA83XX(ha))
  2477. #define IS_NOPOLLING_TYPE(ha) ((IS_QLA25XX(ha) || IS_QLA81XX(ha) || \
  2478. IS_QLA83XX(ha)) && (ha)->flags.msix_enabled)
  2479. #define IS_FAC_REQUIRED(ha) (IS_QLA81XX(ha) || IS_QLA83XX(ha))
  2480. #define IS_NOCACHE_VPD_TYPE(ha) (IS_QLA81XX(ha) || IS_QLA83XX(ha))
  2481. #define IS_ALOGIO_CAPABLE(ha) (IS_QLA23XX(ha) || IS_FWI2_CAPABLE(ha))
  2482. #define IS_T10_PI_CAPABLE(ha) ((ha)->device_type & DT_T10_PI)
  2483. #define IS_IIDMA_CAPABLE(ha) ((ha)->device_type & DT_IIDMA)
  2484. #define IS_FWI2_CAPABLE(ha) ((ha)->device_type & DT_FWI2)
  2485. #define IS_ZIO_SUPPORTED(ha) ((ha)->device_type & DT_ZIO_SUPPORTED)
  2486. #define IS_OEM_001(ha) ((ha)->device_type & DT_OEM_001)
  2487. #define HAS_EXTENDED_IDS(ha) ((ha)->device_type & DT_EXTENDED_IDS)
  2488. #define IS_CT6_SUPPORTED(ha) ((ha)->device_type & DT_CT6_SUPPORTED)
  2489. #define IS_MQUE_CAPABLE(ha) ((ha)->mqenable || IS_QLA83XX(ha))
  2490. #define IS_BIDI_CAPABLE(ha) ((IS_QLA25XX(ha) || IS_QLA2031(ha)))
  2491. /* Bit 21 of fw_attributes decides the MCTP capabilities */
  2492. #define IS_MCTP_CAPABLE(ha) (IS_QLA2031(ha) && \
  2493. ((ha)->fw_attributes_ext[0] & BIT_0))
  2494. #define IS_PI_UNINIT_CAPABLE(ha) (IS_QLA83XX(ha))
  2495. #define IS_PI_IPGUARD_CAPABLE(ha) (IS_QLA83XX(ha))
  2496. #define IS_PI_DIFB_DIX0_CAPABLE(ha) (0)
  2497. #define IS_PI_SPLIT_DET_CAPABLE_HBA(ha) (IS_QLA83XX(ha))
  2498. #define IS_PI_SPLIT_DET_CAPABLE(ha) (IS_PI_SPLIT_DET_CAPABLE_HBA(ha) && \
  2499. (((ha)->fw_attributes_h << 16 | (ha)->fw_attributes) & BIT_22))
  2500. #define IS_ATIO_MSIX_CAPABLE(ha) (IS_QLA83XX(ha))
  2501. #define IS_TGT_MODE_CAPABLE(ha) (ha->tgt.atio_q_length)
  2502. /* HBA serial number */
  2503. uint8_t serial0;
  2504. uint8_t serial1;
  2505. uint8_t serial2;
  2506. /* NVRAM configuration data */
  2507. #define MAX_NVRAM_SIZE 4096
  2508. #define VPD_OFFSET MAX_NVRAM_SIZE / 2
  2509. uint16_t nvram_size;
  2510. uint16_t nvram_base;
  2511. void *nvram;
  2512. uint16_t vpd_size;
  2513. uint16_t vpd_base;
  2514. void *vpd;
  2515. uint16_t loop_reset_delay;
  2516. uint8_t retry_count;
  2517. uint8_t login_timeout;
  2518. uint16_t r_a_tov;
  2519. int port_down_retry_count;
  2520. uint8_t mbx_count;
  2521. uint32_t login_retry_count;
  2522. /* SNS command interfaces. */
  2523. ms_iocb_entry_t *ms_iocb;
  2524. dma_addr_t ms_iocb_dma;
  2525. struct ct_sns_pkt *ct_sns;
  2526. dma_addr_t ct_sns_dma;
  2527. /* SNS command interfaces for 2200. */
  2528. struct sns_cmd_pkt *sns_cmd;
  2529. dma_addr_t sns_cmd_dma;
  2530. #define SFP_DEV_SIZE 256
  2531. #define SFP_BLOCK_SIZE 64
  2532. void *sfp_data;
  2533. dma_addr_t sfp_data_dma;
  2534. #define XGMAC_DATA_SIZE 4096
  2535. void *xgmac_data;
  2536. dma_addr_t xgmac_data_dma;
  2537. #define DCBX_TLV_DATA_SIZE 4096
  2538. void *dcbx_tlv;
  2539. dma_addr_t dcbx_tlv_dma;
  2540. struct task_struct *dpc_thread;
  2541. uint8_t dpc_active; /* DPC routine is active */
  2542. dma_addr_t gid_list_dma;
  2543. struct gid_list_info *gid_list;
  2544. int gid_list_info_size;
  2545. /* Small DMA pool allocations -- maximum 256 bytes in length. */
  2546. #define DMA_POOL_SIZE 256
  2547. struct dma_pool *s_dma_pool;
  2548. dma_addr_t init_cb_dma;
  2549. init_cb_t *init_cb;
  2550. int init_cb_size;
  2551. dma_addr_t ex_init_cb_dma;
  2552. struct ex_init_cb_81xx *ex_init_cb;
  2553. void *async_pd;
  2554. dma_addr_t async_pd_dma;
  2555. void *swl;
  2556. /* These are used by mailbox operations. */
  2557. volatile uint16_t mailbox_out[MAILBOX_REGISTER_COUNT];
  2558. mbx_cmd_t *mcp;
  2559. unsigned long mbx_cmd_flags;
  2560. #define MBX_INTERRUPT 1
  2561. #define MBX_INTR_WAIT 2
  2562. #define MBX_UPDATE_FLASH_ACTIVE 3
  2563. struct mutex vport_lock; /* Virtual port synchronization */
  2564. spinlock_t vport_slock; /* order is hardware_lock, then vport_slock */
  2565. struct completion mbx_cmd_comp; /* Serialize mbx access */
  2566. struct completion mbx_intr_comp; /* Used for completion notification */
  2567. struct completion dcbx_comp; /* For set port config notification */
  2568. struct completion lb_portup_comp; /* Used to wait for link up during
  2569. * loopback */
  2570. #define DCBX_COMP_TIMEOUT 20
  2571. #define LB_PORTUP_COMP_TIMEOUT 10
  2572. int notify_dcbx_comp;
  2573. int notify_lb_portup_comp;
  2574. struct mutex selflogin_lock;
  2575. /* Basic firmware related information. */
  2576. uint16_t fw_major_version;
  2577. uint16_t fw_minor_version;
  2578. uint16_t fw_subminor_version;
  2579. uint16_t fw_attributes;
  2580. uint16_t fw_attributes_h;
  2581. uint16_t fw_attributes_ext[2];
  2582. uint32_t fw_memory_size;
  2583. uint32_t fw_transfer_size;
  2584. uint32_t fw_srisc_address;
  2585. #define RISC_START_ADDRESS_2100 0x1000
  2586. #define RISC_START_ADDRESS_2300 0x800
  2587. #define RISC_START_ADDRESS_2400 0x100000
  2588. uint16_t fw_xcb_count;
  2589. uint16_t fw_iocb_count;
  2590. uint16_t fw_options[16]; /* slots: 1,2,3,10,11 */
  2591. uint8_t fw_seriallink_options[4];
  2592. uint16_t fw_seriallink_options24[4];
  2593. uint8_t mpi_version[3];
  2594. uint32_t mpi_capabilities;
  2595. uint8_t phy_version[3];
  2596. /* Firmware dump information. */
  2597. struct qla2xxx_fw_dump *fw_dump;
  2598. uint32_t fw_dump_len;
  2599. int fw_dumped;
  2600. int fw_dump_reading;
  2601. dma_addr_t eft_dma;
  2602. void *eft;
  2603. /* Current size of mctp dump is 0x086064 bytes */
  2604. #define MCTP_DUMP_SIZE 0x086064
  2605. dma_addr_t mctp_dump_dma;
  2606. void *mctp_dump;
  2607. int mctp_dumped;
  2608. int mctp_dump_reading;
  2609. uint32_t chain_offset;
  2610. struct dentry *dfs_dir;
  2611. struct dentry *dfs_fce;
  2612. dma_addr_t fce_dma;
  2613. void *fce;
  2614. uint32_t fce_bufs;
  2615. uint16_t fce_mb[8];
  2616. uint64_t fce_wr, fce_rd;
  2617. struct mutex fce_mutex;
  2618. uint32_t pci_attr;
  2619. uint16_t chip_revision;
  2620. uint16_t product_id[4];
  2621. uint8_t model_number[16+1];
  2622. #define BINZERO "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
  2623. char model_desc[80];
  2624. uint8_t adapter_id[16+1];
  2625. /* Option ROM information. */
  2626. char *optrom_buffer;
  2627. uint32_t optrom_size;
  2628. int optrom_state;
  2629. #define QLA_SWAITING 0
  2630. #define QLA_SREADING 1
  2631. #define QLA_SWRITING 2
  2632. uint32_t optrom_region_start;
  2633. uint32_t optrom_region_size;
  2634. /* PCI expansion ROM image information. */
  2635. #define ROM_CODE_TYPE_BIOS 0
  2636. #define ROM_CODE_TYPE_FCODE 1
  2637. #define ROM_CODE_TYPE_EFI 3
  2638. uint8_t bios_revision[2];
  2639. uint8_t efi_revision[2];
  2640. uint8_t fcode_revision[16];
  2641. uint32_t fw_revision[4];
  2642. uint32_t gold_fw_version[4];
  2643. /* Offsets for flash/nvram access (set to ~0 if not used). */
  2644. uint32_t flash_conf_off;
  2645. uint32_t flash_data_off;
  2646. uint32_t nvram_conf_off;
  2647. uint32_t nvram_data_off;
  2648. uint32_t fdt_wrt_disable;
  2649. uint32_t fdt_erase_cmd;
  2650. uint32_t fdt_block_size;
  2651. uint32_t fdt_unprotect_sec_cmd;
  2652. uint32_t fdt_protect_sec_cmd;
  2653. uint32_t flt_region_flt;
  2654. uint32_t flt_region_fdt;
  2655. uint32_t flt_region_boot;
  2656. uint32_t flt_region_fw;
  2657. uint32_t flt_region_vpd_nvram;
  2658. uint32_t flt_region_vpd;
  2659. uint32_t flt_region_nvram;
  2660. uint32_t flt_region_npiv_conf;
  2661. uint32_t flt_region_gold_fw;
  2662. uint32_t flt_region_fcp_prio;
  2663. uint32_t flt_region_bootload;
  2664. /* Needed for BEACON */
  2665. uint16_t beacon_blink_led;
  2666. uint8_t beacon_color_state;
  2667. #define QLA_LED_GRN_ON 0x01
  2668. #define QLA_LED_YLW_ON 0x02
  2669. #define QLA_LED_ABR_ON 0x04
  2670. #define QLA_LED_ALL_ON 0x07 /* yellow, green, amber. */
  2671. /* ISP2322: red, green, amber. */
  2672. uint16_t zio_mode;
  2673. uint16_t zio_timer;
  2674. struct qla_msix_entry *msix_entries;
  2675. struct list_head vp_list; /* list of VP */
  2676. unsigned long vp_idx_map[(MAX_MULTI_ID_FABRIC / 8) /
  2677. sizeof(unsigned long)];
  2678. uint16_t num_vhosts; /* number of vports created */
  2679. uint16_t num_vsans; /* number of vsan created */
  2680. uint16_t max_npiv_vports; /* 63 or 125 per topoloty */
  2681. int cur_vport_count;
  2682. struct qla_chip_state_84xx *cs84xx;
  2683. struct isp_operations *isp_ops;
  2684. struct workqueue_struct *wq;
  2685. struct qlfc_fw fw_buf;
  2686. /* FCP_CMND priority support */
  2687. struct qla_fcp_prio_cfg *fcp_prio_cfg;
  2688. struct dma_pool *dl_dma_pool;
  2689. #define DSD_LIST_DMA_POOL_SIZE 512
  2690. struct dma_pool *fcp_cmnd_dma_pool;
  2691. mempool_t *ctx_mempool;
  2692. #define FCP_CMND_DMA_POOL_SIZE 512
  2693. unsigned long nx_pcibase; /* Base I/O address */
  2694. uint8_t *nxdb_rd_ptr; /* Doorbell read pointer */
  2695. unsigned long nxdb_wr_ptr; /* Door bell write pointer */
  2696. uint32_t crb_win;
  2697. uint32_t curr_window;
  2698. uint32_t ddr_mn_window;
  2699. unsigned long mn_win_crb;
  2700. unsigned long ms_win_crb;
  2701. int qdr_sn_window;
  2702. uint32_t fcoe_dev_init_timeout;
  2703. uint32_t fcoe_reset_timeout;
  2704. rwlock_t hw_lock;
  2705. uint16_t portnum; /* port number */
  2706. int link_width;
  2707. struct fw_blob *hablob;
  2708. struct qla82xx_legacy_intr_set nx_legacy_intr;
  2709. uint16_t gbl_dsd_inuse;
  2710. uint16_t gbl_dsd_avail;
  2711. struct list_head gbl_dsd_list;
  2712. #define NUM_DSD_CHAIN 4096
  2713. uint8_t fw_type;
  2714. __le32 file_prd_off; /* File firmware product offset */
  2715. uint32_t md_template_size;
  2716. void *md_tmplt_hdr;
  2717. dma_addr_t md_tmplt_hdr_dma;
  2718. void *md_dump;
  2719. uint32_t md_dump_size;
  2720. void *loop_id_map;
  2721. /* QLA83XX IDC specific fields */
  2722. uint32_t idc_audit_ts;
  2723. /* DPC low-priority workqueue */
  2724. struct workqueue_struct *dpc_lp_wq;
  2725. struct work_struct idc_aen;
  2726. /* DPC high-priority workqueue */
  2727. struct workqueue_struct *dpc_hp_wq;
  2728. struct work_struct nic_core_reset;
  2729. struct work_struct idc_state_handler;
  2730. struct work_struct nic_core_unrecoverable;
  2731. #define HOST_QUEUE_RAMPDOWN_INTERVAL (60 * HZ)
  2732. #define HOST_QUEUE_RAMPUP_INTERVAL (30 * HZ)
  2733. unsigned long host_last_rampdown_time;
  2734. unsigned long host_last_rampup_time;
  2735. int cfg_lun_q_depth;
  2736. struct qlt_hw_data tgt;
  2737. uint16_t thermal_support;
  2738. #define THERMAL_SUPPORT_I2C BIT_0
  2739. #define THERMAL_SUPPORT_ISP BIT_1
  2740. };
  2741. /*
  2742. * Qlogic scsi host structure
  2743. */
  2744. typedef struct scsi_qla_host {
  2745. struct list_head list;
  2746. struct list_head vp_fcports; /* list of fcports */
  2747. struct list_head work_list;
  2748. spinlock_t work_lock;
  2749. /* Commonly used flags and state information. */
  2750. struct Scsi_Host *host;
  2751. unsigned long host_no;
  2752. uint8_t host_str[16];
  2753. volatile struct {
  2754. uint32_t init_done :1;
  2755. uint32_t online :1;
  2756. uint32_t reset_active :1;
  2757. uint32_t management_server_logged_in :1;
  2758. uint32_t process_response_queue :1;
  2759. uint32_t difdix_supported:1;
  2760. uint32_t delete_progress:1;
  2761. } flags;
  2762. atomic_t loop_state;
  2763. #define LOOP_TIMEOUT 1
  2764. #define LOOP_DOWN 2
  2765. #define LOOP_UP 3
  2766. #define LOOP_UPDATE 4
  2767. #define LOOP_READY 5
  2768. #define LOOP_DEAD 6
  2769. unsigned long dpc_flags;
  2770. #define RESET_MARKER_NEEDED 0 /* Send marker to ISP. */
  2771. #define RESET_ACTIVE 1
  2772. #define ISP_ABORT_NEEDED 2 /* Initiate ISP abort. */
  2773. #define ABORT_ISP_ACTIVE 3 /* ISP abort in progress. */
  2774. #define LOOP_RESYNC_NEEDED 4 /* Device Resync needed. */
  2775. #define LOOP_RESYNC_ACTIVE 5
  2776. #define LOCAL_LOOP_UPDATE 6 /* Perform a local loop update. */
  2777. #define RSCN_UPDATE 7 /* Perform an RSCN update. */
  2778. #define RELOGIN_NEEDED 8
  2779. #define REGISTER_FC4_NEEDED 9 /* SNS FC4 registration required. */
  2780. #define ISP_ABORT_RETRY 10 /* ISP aborted. */
  2781. #define BEACON_BLINK_NEEDED 11
  2782. #define REGISTER_FDMI_NEEDED 12
  2783. #define FCPORT_UPDATE_NEEDED 13
  2784. #define VP_DPC_NEEDED 14 /* wake up for VP dpc handling */
  2785. #define UNLOADING 15
  2786. #define NPIV_CONFIG_NEEDED 16
  2787. #define ISP_UNRECOVERABLE 17
  2788. #define FCOE_CTX_RESET_NEEDED 18 /* Initiate FCoE context reset */
  2789. #define MPI_RESET_NEEDED 19 /* Initiate MPI FW reset */
  2790. #define ISP_QUIESCE_NEEDED 20 /* Driver need some quiescence */
  2791. #define SCR_PENDING 21 /* SCR in target mode */
  2792. #define HOST_RAMP_DOWN_QUEUE_DEPTH 22
  2793. #define HOST_RAMP_UP_QUEUE_DEPTH 23
  2794. uint32_t device_flags;
  2795. #define SWITCH_FOUND BIT_0
  2796. #define DFLG_NO_CABLE BIT_1
  2797. #define DFLG_DEV_FAILED BIT_5
  2798. /* ISP configuration data. */
  2799. uint16_t loop_id; /* Host adapter loop id */
  2800. uint16_t self_login_loop_id; /* host adapter loop id
  2801. * get it on self login
  2802. */
  2803. fc_port_t bidir_fcport; /* fcport used for bidir cmnds
  2804. * no need of allocating it for
  2805. * each command
  2806. */
  2807. port_id_t d_id; /* Host adapter port id */
  2808. uint8_t marker_needed;
  2809. uint16_t mgmt_svr_loop_id;
  2810. /* Timeout timers. */
  2811. uint8_t loop_down_abort_time; /* port down timer */
  2812. atomic_t loop_down_timer; /* loop down timer */
  2813. uint8_t link_down_timeout; /* link down timeout */
  2814. uint32_t timer_active;
  2815. struct timer_list timer;
  2816. uint8_t node_name[WWN_SIZE];
  2817. uint8_t port_name[WWN_SIZE];
  2818. uint8_t fabric_node_name[WWN_SIZE];
  2819. uint16_t fcoe_vlan_id;
  2820. uint16_t fcoe_fcf_idx;
  2821. uint8_t fcoe_vn_port_mac[6];
  2822. uint32_t vp_abort_cnt;
  2823. struct fc_vport *fc_vport; /* holds fc_vport * for each vport */
  2824. uint16_t vp_idx; /* vport ID */
  2825. unsigned long vp_flags;
  2826. #define VP_IDX_ACQUIRED 0 /* bit no 0 */
  2827. #define VP_CREATE_NEEDED 1
  2828. #define VP_BIND_NEEDED 2
  2829. #define VP_DELETE_NEEDED 3
  2830. #define VP_SCR_NEEDED 4 /* State Change Request registration */
  2831. atomic_t vp_state;
  2832. #define VP_OFFLINE 0
  2833. #define VP_ACTIVE 1
  2834. #define VP_FAILED 2
  2835. // #define VP_DISABLE 3
  2836. uint16_t vp_err_state;
  2837. uint16_t vp_prev_err_state;
  2838. #define VP_ERR_UNKWN 0
  2839. #define VP_ERR_PORTDWN 1
  2840. #define VP_ERR_FAB_UNSUPPORTED 2
  2841. #define VP_ERR_FAB_NORESOURCES 3
  2842. #define VP_ERR_FAB_LOGOUT 4
  2843. #define VP_ERR_ADAP_NORESOURCES 5
  2844. struct qla_hw_data *hw;
  2845. struct req_que *req;
  2846. int fw_heartbeat_counter;
  2847. int seconds_since_last_heartbeat;
  2848. struct fc_host_statistics fc_host_stat;
  2849. struct qla_statistics qla_stats;
  2850. struct bidi_statistics bidi_stats;
  2851. atomic_t vref_count;
  2852. } scsi_qla_host_t;
  2853. #define SET_VP_IDX 1
  2854. #define SET_AL_PA 2
  2855. #define RESET_VP_IDX 3
  2856. #define RESET_AL_PA 4
  2857. struct qla_tgt_vp_map {
  2858. uint8_t idx;
  2859. scsi_qla_host_t *vha;
  2860. };
  2861. /*
  2862. * Macros to help code, maintain, etc.
  2863. */
  2864. #define LOOP_TRANSITION(ha) \
  2865. (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \
  2866. test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) || \
  2867. atomic_read(&ha->loop_state) == LOOP_DOWN)
  2868. #define QLA_VHA_MARK_BUSY(__vha, __bail) do { \
  2869. atomic_inc(&__vha->vref_count); \
  2870. mb(); \
  2871. if (__vha->flags.delete_progress) { \
  2872. atomic_dec(&__vha->vref_count); \
  2873. __bail = 1; \
  2874. } else { \
  2875. __bail = 0; \
  2876. } \
  2877. } while (0)
  2878. #define QLA_VHA_MARK_NOT_BUSY(__vha) do { \
  2879. atomic_dec(&__vha->vref_count); \
  2880. } while (0)
  2881. /*
  2882. * qla2x00 local function return status codes
  2883. */
  2884. #define MBS_MASK 0x3fff
  2885. #define QLA_SUCCESS (MBS_COMMAND_COMPLETE & MBS_MASK)
  2886. #define QLA_INVALID_COMMAND (MBS_INVALID_COMMAND & MBS_MASK)
  2887. #define QLA_INTERFACE_ERROR (MBS_HOST_INTERFACE_ERROR & MBS_MASK)
  2888. #define QLA_TEST_FAILED (MBS_TEST_FAILED & MBS_MASK)
  2889. #define QLA_COMMAND_ERROR (MBS_COMMAND_ERROR & MBS_MASK)
  2890. #define QLA_PARAMETER_ERROR (MBS_COMMAND_PARAMETER_ERROR & MBS_MASK)
  2891. #define QLA_PORT_ID_USED (MBS_PORT_ID_USED & MBS_MASK)
  2892. #define QLA_LOOP_ID_USED (MBS_LOOP_ID_USED & MBS_MASK)
  2893. #define QLA_ALL_IDS_IN_USE (MBS_ALL_IDS_IN_USE & MBS_MASK)
  2894. #define QLA_NOT_LOGGED_IN (MBS_NOT_LOGGED_IN & MBS_MASK)
  2895. #define QLA_FUNCTION_TIMEOUT 0x100
  2896. #define QLA_FUNCTION_PARAMETER_ERROR 0x101
  2897. #define QLA_FUNCTION_FAILED 0x102
  2898. #define QLA_MEMORY_ALLOC_FAILED 0x103
  2899. #define QLA_LOCK_TIMEOUT 0x104
  2900. #define QLA_ABORTED 0x105
  2901. #define QLA_SUSPENDED 0x106
  2902. #define QLA_BUSY 0x107
  2903. #define QLA_ALREADY_REGISTERED 0x109
  2904. #define NVRAM_DELAY() udelay(10)
  2905. /*
  2906. * Flash support definitions
  2907. */
  2908. #define OPTROM_SIZE_2300 0x20000
  2909. #define OPTROM_SIZE_2322 0x100000
  2910. #define OPTROM_SIZE_24XX 0x100000
  2911. #define OPTROM_SIZE_25XX 0x200000
  2912. #define OPTROM_SIZE_81XX 0x400000
  2913. #define OPTROM_SIZE_82XX 0x800000
  2914. #define OPTROM_SIZE_83XX 0x1000000
  2915. #define OPTROM_BURST_SIZE 0x1000
  2916. #define OPTROM_BURST_DWORDS (OPTROM_BURST_SIZE / 4)
  2917. #define QLA_DSDS_PER_IOCB 37
  2918. #define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr)
  2919. #define QLA_SG_ALL 1024
  2920. enum nexus_wait_type {
  2921. WAIT_HOST = 0,
  2922. WAIT_TARGET,
  2923. WAIT_LUN,
  2924. };
  2925. #include "qla_gbl.h"
  2926. #include "qla_dbg.h"
  2927. #include "qla_inline.h"
  2928. #endif