qla_def.h 106 KB

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