qla_def.h 91 KB

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