qla_def.h 89 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254
  1. /*
  2. * QLogic Fibre Channel HBA Driver
  3. * Copyright (c) 2003-2011 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. /* ISP mailbox loopback echo diagnostic error code */
  610. #define MBS_LB_RESET 0x17
  611. /*
  612. * Firmware options 1, 2, 3.
  613. */
  614. #define FO1_AE_ON_LIPF8 BIT_0
  615. #define FO1_AE_ALL_LIP_RESET BIT_1
  616. #define FO1_CTIO_RETRY BIT_3
  617. #define FO1_DISABLE_LIP_F7_SW BIT_4
  618. #define FO1_DISABLE_100MS_LOS_WAIT BIT_5
  619. #define FO1_DISABLE_GPIO6_7 BIT_6 /* LED bits */
  620. #define FO1_AE_ON_LOOP_INIT_ERR BIT_7
  621. #define FO1_SET_EMPHASIS_SWING BIT_8
  622. #define FO1_AE_AUTO_BYPASS BIT_9
  623. #define FO1_ENABLE_PURE_IOCB BIT_10
  624. #define FO1_AE_PLOGI_RJT BIT_11
  625. #define FO1_ENABLE_ABORT_SEQUENCE BIT_12
  626. #define FO1_AE_QUEUE_FULL BIT_13
  627. #define FO2_ENABLE_ATIO_TYPE_3 BIT_0
  628. #define FO2_REV_LOOPBACK BIT_1
  629. #define FO3_ENABLE_EMERG_IOCB BIT_0
  630. #define FO3_AE_RND_ERROR BIT_1
  631. /* 24XX additional firmware options */
  632. #define ADD_FO_COUNT 3
  633. #define ADD_FO1_DISABLE_GPIO_LED_CTRL BIT_6 /* LED bits */
  634. #define ADD_FO1_ENABLE_PUREX_IOCB BIT_10
  635. #define ADD_FO2_ENABLE_SEL_CLS2 BIT_5
  636. #define ADD_FO3_NO_ABT_ON_LINK_DOWN BIT_14
  637. /*
  638. * ISP mailbox commands
  639. */
  640. #define MBC_LOAD_RAM 1 /* Load RAM. */
  641. #define MBC_EXECUTE_FIRMWARE 2 /* Execute firmware. */
  642. #define MBC_WRITE_RAM_WORD 4 /* Write RAM word. */
  643. #define MBC_READ_RAM_WORD 5 /* Read RAM word. */
  644. #define MBC_MAILBOX_REGISTER_TEST 6 /* Wrap incoming mailboxes */
  645. #define MBC_VERIFY_CHECKSUM 7 /* Verify checksum. */
  646. #define MBC_GET_FIRMWARE_VERSION 8 /* Get firmware revision. */
  647. #define MBC_LOAD_RISC_RAM 9 /* Load RAM command. */
  648. #define MBC_DUMP_RISC_RAM 0xa /* Dump RAM command. */
  649. #define MBC_LOAD_RISC_RAM_EXTENDED 0xb /* Load RAM extended. */
  650. #define MBC_DUMP_RISC_RAM_EXTENDED 0xc /* Dump RAM extended. */
  651. #define MBC_WRITE_RAM_WORD_EXTENDED 0xd /* Write RAM word extended */
  652. #define MBC_READ_RAM_EXTENDED 0xf /* Read RAM extended. */
  653. #define MBC_IOCB_COMMAND 0x12 /* Execute IOCB command. */
  654. #define MBC_STOP_FIRMWARE 0x14 /* Stop firmware. */
  655. #define MBC_ABORT_COMMAND 0x15 /* Abort IOCB command. */
  656. #define MBC_ABORT_DEVICE 0x16 /* Abort device (ID/LUN). */
  657. #define MBC_ABORT_TARGET 0x17 /* Abort target (ID). */
  658. #define MBC_RESET 0x18 /* Reset. */
  659. #define MBC_GET_ADAPTER_LOOP_ID 0x20 /* Get loop id of ISP2200. */
  660. #define MBC_GET_RETRY_COUNT 0x22 /* Get f/w retry cnt/delay. */
  661. #define MBC_DISABLE_VI 0x24 /* Disable VI operation. */
  662. #define MBC_ENABLE_VI 0x25 /* Enable VI operation. */
  663. #define MBC_GET_FIRMWARE_OPTION 0x28 /* Get Firmware Options. */
  664. #define MBC_SET_FIRMWARE_OPTION 0x38 /* Set Firmware Options. */
  665. #define MBC_LOOP_PORT_BYPASS 0x40 /* Loop Port Bypass. */
  666. #define MBC_LOOP_PORT_ENABLE 0x41 /* Loop Port Enable. */
  667. #define MBC_GET_RESOURCE_COUNTS 0x42 /* Get Resource Counts. */
  668. #define MBC_NON_PARTICIPATE 0x43 /* Non-Participating Mode. */
  669. #define MBC_DIAGNOSTIC_ECHO 0x44 /* Diagnostic echo. */
  670. #define MBC_DIAGNOSTIC_LOOP_BACK 0x45 /* Diagnostic loop back. */
  671. #define MBC_ONLINE_SELF_TEST 0x46 /* Online self-test. */
  672. #define MBC_ENHANCED_GET_PORT_DATABASE 0x47 /* Get port database + login */
  673. #define MBC_CONFIGURE_VF 0x4b /* Configure VFs */
  674. #define MBC_RESET_LINK_STATUS 0x52 /* Reset Link Error Status */
  675. #define MBC_IOCB_COMMAND_A64 0x54 /* Execute IOCB command (64) */
  676. #define MBC_PORT_LOGOUT 0x56 /* Port Logout request */
  677. #define MBC_SEND_RNID_ELS 0x57 /* Send RNID ELS request */
  678. #define MBC_SET_RNID_PARAMS 0x59 /* Set RNID parameters */
  679. #define MBC_GET_RNID_PARAMS 0x5a /* Data Rate */
  680. #define MBC_DATA_RATE 0x5d /* Get RNID parameters */
  681. #define MBC_INITIALIZE_FIRMWARE 0x60 /* Initialize firmware */
  682. #define MBC_INITIATE_LIP 0x62 /* Initiate Loop */
  683. /* Initialization Procedure */
  684. #define MBC_GET_FC_AL_POSITION_MAP 0x63 /* Get FC_AL Position Map. */
  685. #define MBC_GET_PORT_DATABASE 0x64 /* Get Port Database. */
  686. #define MBC_CLEAR_ACA 0x65 /* Clear ACA. */
  687. #define MBC_TARGET_RESET 0x66 /* Target Reset. */
  688. #define MBC_CLEAR_TASK_SET 0x67 /* Clear Task Set. */
  689. #define MBC_ABORT_TASK_SET 0x68 /* Abort Task Set. */
  690. #define MBC_GET_FIRMWARE_STATE 0x69 /* Get firmware state. */
  691. #define MBC_GET_PORT_NAME 0x6a /* Get port name. */
  692. #define MBC_GET_LINK_STATUS 0x6b /* Get port link status. */
  693. #define MBC_LIP_RESET 0x6c /* LIP reset. */
  694. #define MBC_SEND_SNS_COMMAND 0x6e /* Send Simple Name Server */
  695. /* commandd. */
  696. #define MBC_LOGIN_FABRIC_PORT 0x6f /* Login fabric port. */
  697. #define MBC_SEND_CHANGE_REQUEST 0x70 /* Send Change Request. */
  698. #define MBC_LOGOUT_FABRIC_PORT 0x71 /* Logout fabric port. */
  699. #define MBC_LIP_FULL_LOGIN 0x72 /* Full login LIP. */
  700. #define MBC_LOGIN_LOOP_PORT 0x74 /* Login Loop Port. */
  701. #define MBC_PORT_NODE_NAME_LIST 0x75 /* Get port/node name list. */
  702. #define MBC_INITIALIZE_RECEIVE_QUEUE 0x77 /* Initialize receive queue */
  703. #define MBC_UNLOAD_IP 0x79 /* Shutdown IP */
  704. #define MBC_GET_ID_LIST 0x7C /* Get Port ID list. */
  705. #define MBC_SEND_LFA_COMMAND 0x7D /* Send Loop Fabric Address */
  706. #define MBC_LUN_RESET 0x7E /* Send LUN reset */
  707. /*
  708. * ISP24xx mailbox commands
  709. */
  710. #define MBC_SERDES_PARAMS 0x10 /* Serdes Tx Parameters. */
  711. #define MBC_GET_IOCB_STATUS 0x12 /* Get IOCB status command. */
  712. #define MBC_PORT_PARAMS 0x1A /* Port iDMA Parameters. */
  713. #define MBC_GET_TIMEOUT_PARAMS 0x22 /* Get FW timeouts. */
  714. #define MBC_TRACE_CONTROL 0x27 /* Trace control command. */
  715. #define MBC_GEN_SYSTEM_ERROR 0x2a /* Generate System Error. */
  716. #define MBC_WRITE_SFP 0x30 /* Write SFP Data. */
  717. #define MBC_READ_SFP 0x31 /* Read SFP Data. */
  718. #define MBC_SET_TIMEOUT_PARAMS 0x32 /* Set FW timeouts. */
  719. #define MBC_MID_INITIALIZE_FIRMWARE 0x48 /* MID Initialize firmware. */
  720. #define MBC_MID_GET_VP_DATABASE 0x49 /* MID Get VP Database. */
  721. #define MBC_MID_GET_VP_ENTRY 0x4a /* MID Get VP Entry. */
  722. #define MBC_HOST_MEMORY_COPY 0x53 /* Host Memory Copy. */
  723. #define MBC_SEND_RNFT_ELS 0x5e /* Send RNFT ELS request */
  724. #define MBC_GET_LINK_PRIV_STATS 0x6d /* Get link & private data. */
  725. #define MBC_SET_VENDOR_ID 0x76 /* Set Vendor ID. */
  726. #define MBC_SET_PORT_CONFIG 0x122 /* Set port configuration */
  727. #define MBC_GET_PORT_CONFIG 0x123 /* Get port configuration */
  728. /*
  729. * ISP81xx mailbox commands
  730. */
  731. #define MBC_WRITE_MPI_REGISTER 0x01 /* Write MPI Register. */
  732. /* Firmware return data sizes */
  733. #define FCAL_MAP_SIZE 128
  734. /* Mailbox bit definitions for out_mb and in_mb */
  735. #define MBX_31 BIT_31
  736. #define MBX_30 BIT_30
  737. #define MBX_29 BIT_29
  738. #define MBX_28 BIT_28
  739. #define MBX_27 BIT_27
  740. #define MBX_26 BIT_26
  741. #define MBX_25 BIT_25
  742. #define MBX_24 BIT_24
  743. #define MBX_23 BIT_23
  744. #define MBX_22 BIT_22
  745. #define MBX_21 BIT_21
  746. #define MBX_20 BIT_20
  747. #define MBX_19 BIT_19
  748. #define MBX_18 BIT_18
  749. #define MBX_17 BIT_17
  750. #define MBX_16 BIT_16
  751. #define MBX_15 BIT_15
  752. #define MBX_14 BIT_14
  753. #define MBX_13 BIT_13
  754. #define MBX_12 BIT_12
  755. #define MBX_11 BIT_11
  756. #define MBX_10 BIT_10
  757. #define MBX_9 BIT_9
  758. #define MBX_8 BIT_8
  759. #define MBX_7 BIT_7
  760. #define MBX_6 BIT_6
  761. #define MBX_5 BIT_5
  762. #define MBX_4 BIT_4
  763. #define MBX_3 BIT_3
  764. #define MBX_2 BIT_2
  765. #define MBX_1 BIT_1
  766. #define MBX_0 BIT_0
  767. /*
  768. * Firmware state codes from get firmware state mailbox command
  769. */
  770. #define FSTATE_CONFIG_WAIT 0
  771. #define FSTATE_WAIT_AL_PA 1
  772. #define FSTATE_WAIT_LOGIN 2
  773. #define FSTATE_READY 3
  774. #define FSTATE_LOSS_OF_SYNC 4
  775. #define FSTATE_ERROR 5
  776. #define FSTATE_REINIT 6
  777. #define FSTATE_NON_PART 7
  778. #define FSTATE_CONFIG_CORRECT 0
  779. #define FSTATE_P2P_RCV_LIP 1
  780. #define FSTATE_P2P_CHOOSE_LOOP 2
  781. #define FSTATE_P2P_RCV_UNIDEN_LIP 3
  782. #define FSTATE_FATAL_ERROR 4
  783. #define FSTATE_LOOP_BACK_CONN 5
  784. /*
  785. * Port Database structure definition
  786. * Little endian except where noted.
  787. */
  788. #define PORT_DATABASE_SIZE 128 /* bytes */
  789. typedef struct {
  790. uint8_t options;
  791. uint8_t control;
  792. uint8_t master_state;
  793. uint8_t slave_state;
  794. uint8_t reserved[2];
  795. uint8_t hard_address;
  796. uint8_t reserved_1;
  797. uint8_t port_id[4];
  798. uint8_t node_name[WWN_SIZE];
  799. uint8_t port_name[WWN_SIZE];
  800. uint16_t execution_throttle;
  801. uint16_t execution_count;
  802. uint8_t reset_count;
  803. uint8_t reserved_2;
  804. uint16_t resource_allocation;
  805. uint16_t current_allocation;
  806. uint16_t queue_head;
  807. uint16_t queue_tail;
  808. uint16_t transmit_execution_list_next;
  809. uint16_t transmit_execution_list_previous;
  810. uint16_t common_features;
  811. uint16_t total_concurrent_sequences;
  812. uint16_t RO_by_information_category;
  813. uint8_t recipient;
  814. uint8_t initiator;
  815. uint16_t receive_data_size;
  816. uint16_t concurrent_sequences;
  817. uint16_t open_sequences_per_exchange;
  818. uint16_t lun_abort_flags;
  819. uint16_t lun_stop_flags;
  820. uint16_t stop_queue_head;
  821. uint16_t stop_queue_tail;
  822. uint16_t port_retry_timer;
  823. uint16_t next_sequence_id;
  824. uint16_t frame_count;
  825. uint16_t PRLI_payload_length;
  826. uint8_t prli_svc_param_word_0[2]; /* Big endian */
  827. /* Bits 15-0 of word 0 */
  828. uint8_t prli_svc_param_word_3[2]; /* Big endian */
  829. /* Bits 15-0 of word 3 */
  830. uint16_t loop_id;
  831. uint16_t extended_lun_info_list_pointer;
  832. uint16_t extended_lun_stop_list_pointer;
  833. } port_database_t;
  834. /*
  835. * Port database slave/master states
  836. */
  837. #define PD_STATE_DISCOVERY 0
  838. #define PD_STATE_WAIT_DISCOVERY_ACK 1
  839. #define PD_STATE_PORT_LOGIN 2
  840. #define PD_STATE_WAIT_PORT_LOGIN_ACK 3
  841. #define PD_STATE_PROCESS_LOGIN 4
  842. #define PD_STATE_WAIT_PROCESS_LOGIN_ACK 5
  843. #define PD_STATE_PORT_LOGGED_IN 6
  844. #define PD_STATE_PORT_UNAVAILABLE 7
  845. #define PD_STATE_PROCESS_LOGOUT 8
  846. #define PD_STATE_WAIT_PROCESS_LOGOUT_ACK 9
  847. #define PD_STATE_PORT_LOGOUT 10
  848. #define PD_STATE_WAIT_PORT_LOGOUT_ACK 11
  849. #define QLA_ZIO_MODE_6 (BIT_2 | BIT_1)
  850. #define QLA_ZIO_DISABLED 0
  851. #define QLA_ZIO_DEFAULT_TIMER 2
  852. /*
  853. * ISP Initialization Control Block.
  854. * Little endian except where noted.
  855. */
  856. #define ICB_VERSION 1
  857. typedef struct {
  858. uint8_t version;
  859. uint8_t reserved_1;
  860. /*
  861. * LSB BIT 0 = Enable Hard Loop Id
  862. * LSB BIT 1 = Enable Fairness
  863. * LSB BIT 2 = Enable Full-Duplex
  864. * LSB BIT 3 = Enable Fast Posting
  865. * LSB BIT 4 = Enable Target Mode
  866. * LSB BIT 5 = Disable Initiator Mode
  867. * LSB BIT 6 = Enable ADISC
  868. * LSB BIT 7 = Enable Target Inquiry Data
  869. *
  870. * MSB BIT 0 = Enable PDBC Notify
  871. * MSB BIT 1 = Non Participating LIP
  872. * MSB BIT 2 = Descending Loop ID Search
  873. * MSB BIT 3 = Acquire Loop ID in LIPA
  874. * MSB BIT 4 = Stop PortQ on Full Status
  875. * MSB BIT 5 = Full Login after LIP
  876. * MSB BIT 6 = Node Name Option
  877. * MSB BIT 7 = Ext IFWCB enable bit
  878. */
  879. uint8_t firmware_options[2];
  880. uint16_t frame_payload_size;
  881. uint16_t max_iocb_allocation;
  882. uint16_t execution_throttle;
  883. uint8_t retry_count;
  884. uint8_t retry_delay; /* unused */
  885. uint8_t port_name[WWN_SIZE]; /* Big endian. */
  886. uint16_t hard_address;
  887. uint8_t inquiry_data;
  888. uint8_t login_timeout;
  889. uint8_t node_name[WWN_SIZE]; /* Big endian. */
  890. uint16_t request_q_outpointer;
  891. uint16_t response_q_inpointer;
  892. uint16_t request_q_length;
  893. uint16_t response_q_length;
  894. uint32_t request_q_address[2];
  895. uint32_t response_q_address[2];
  896. uint16_t lun_enables;
  897. uint8_t command_resource_count;
  898. uint8_t immediate_notify_resource_count;
  899. uint16_t timeout;
  900. uint8_t reserved_2[2];
  901. /*
  902. * LSB BIT 0 = Timer Operation mode bit 0
  903. * LSB BIT 1 = Timer Operation mode bit 1
  904. * LSB BIT 2 = Timer Operation mode bit 2
  905. * LSB BIT 3 = Timer Operation mode bit 3
  906. * LSB BIT 4 = Init Config Mode bit 0
  907. * LSB BIT 5 = Init Config Mode bit 1
  908. * LSB BIT 6 = Init Config Mode bit 2
  909. * LSB BIT 7 = Enable Non part on LIHA failure
  910. *
  911. * MSB BIT 0 = Enable class 2
  912. * MSB BIT 1 = Enable ACK0
  913. * MSB BIT 2 =
  914. * MSB BIT 3 =
  915. * MSB BIT 4 = FC Tape Enable
  916. * MSB BIT 5 = Enable FC Confirm
  917. * MSB BIT 6 = Enable command queuing in target mode
  918. * MSB BIT 7 = No Logo On Link Down
  919. */
  920. uint8_t add_firmware_options[2];
  921. uint8_t response_accumulation_timer;
  922. uint8_t interrupt_delay_timer;
  923. /*
  924. * LSB BIT 0 = Enable Read xfr_rdy
  925. * LSB BIT 1 = Soft ID only
  926. * LSB BIT 2 =
  927. * LSB BIT 3 =
  928. * LSB BIT 4 = FCP RSP Payload [0]
  929. * LSB BIT 5 = FCP RSP Payload [1] / Sbus enable - 2200
  930. * LSB BIT 6 = Enable Out-of-Order frame handling
  931. * LSB BIT 7 = Disable Automatic PLOGI on Local Loop
  932. *
  933. * MSB BIT 0 = Sbus enable - 2300
  934. * MSB BIT 1 =
  935. * MSB BIT 2 =
  936. * MSB BIT 3 =
  937. * MSB BIT 4 = LED mode
  938. * MSB BIT 5 = enable 50 ohm termination
  939. * MSB BIT 6 = Data Rate (2300 only)
  940. * MSB BIT 7 = Data Rate (2300 only)
  941. */
  942. uint8_t special_options[2];
  943. uint8_t reserved_3[26];
  944. } init_cb_t;
  945. /*
  946. * Get Link Status mailbox command return buffer.
  947. */
  948. #define GLSO_SEND_RPS BIT_0
  949. #define GLSO_USE_DID BIT_3
  950. struct link_statistics {
  951. uint32_t link_fail_cnt;
  952. uint32_t loss_sync_cnt;
  953. uint32_t loss_sig_cnt;
  954. uint32_t prim_seq_err_cnt;
  955. uint32_t inval_xmit_word_cnt;
  956. uint32_t inval_crc_cnt;
  957. uint32_t lip_cnt;
  958. uint32_t unused1[0x1a];
  959. uint32_t tx_frames;
  960. uint32_t rx_frames;
  961. uint32_t dumped_frames;
  962. uint32_t unused2[2];
  963. uint32_t nos_rcvd;
  964. };
  965. /*
  966. * NVRAM Command values.
  967. */
  968. #define NV_START_BIT BIT_2
  969. #define NV_WRITE_OP (BIT_26+BIT_24)
  970. #define NV_READ_OP (BIT_26+BIT_25)
  971. #define NV_ERASE_OP (BIT_26+BIT_25+BIT_24)
  972. #define NV_MASK_OP (BIT_26+BIT_25+BIT_24)
  973. #define NV_DELAY_COUNT 10
  974. /*
  975. * QLogic ISP2100, ISP2200 and ISP2300 NVRAM structure definition.
  976. */
  977. typedef struct {
  978. /*
  979. * NVRAM header
  980. */
  981. uint8_t id[4];
  982. uint8_t nvram_version;
  983. uint8_t reserved_0;
  984. /*
  985. * NVRAM RISC parameter block
  986. */
  987. uint8_t parameter_block_version;
  988. uint8_t reserved_1;
  989. /*
  990. * LSB BIT 0 = Enable Hard Loop Id
  991. * LSB BIT 1 = Enable Fairness
  992. * LSB BIT 2 = Enable Full-Duplex
  993. * LSB BIT 3 = Enable Fast Posting
  994. * LSB BIT 4 = Enable Target Mode
  995. * LSB BIT 5 = Disable Initiator Mode
  996. * LSB BIT 6 = Enable ADISC
  997. * LSB BIT 7 = Enable Target Inquiry Data
  998. *
  999. * MSB BIT 0 = Enable PDBC Notify
  1000. * MSB BIT 1 = Non Participating LIP
  1001. * MSB BIT 2 = Descending Loop ID Search
  1002. * MSB BIT 3 = Acquire Loop ID in LIPA
  1003. * MSB BIT 4 = Stop PortQ on Full Status
  1004. * MSB BIT 5 = Full Login after LIP
  1005. * MSB BIT 6 = Node Name Option
  1006. * MSB BIT 7 = Ext IFWCB enable bit
  1007. */
  1008. uint8_t firmware_options[2];
  1009. uint16_t frame_payload_size;
  1010. uint16_t max_iocb_allocation;
  1011. uint16_t execution_throttle;
  1012. uint8_t retry_count;
  1013. uint8_t retry_delay; /* unused */
  1014. uint8_t port_name[WWN_SIZE]; /* Big endian. */
  1015. uint16_t hard_address;
  1016. uint8_t inquiry_data;
  1017. uint8_t login_timeout;
  1018. uint8_t node_name[WWN_SIZE]; /* Big endian. */
  1019. /*
  1020. * LSB BIT 0 = Timer Operation mode bit 0
  1021. * LSB BIT 1 = Timer Operation mode bit 1
  1022. * LSB BIT 2 = Timer Operation mode bit 2
  1023. * LSB BIT 3 = Timer Operation mode bit 3
  1024. * LSB BIT 4 = Init Config Mode bit 0
  1025. * LSB BIT 5 = Init Config Mode bit 1
  1026. * LSB BIT 6 = Init Config Mode bit 2
  1027. * LSB BIT 7 = Enable Non part on LIHA failure
  1028. *
  1029. * MSB BIT 0 = Enable class 2
  1030. * MSB BIT 1 = Enable ACK0
  1031. * MSB BIT 2 =
  1032. * MSB BIT 3 =
  1033. * MSB BIT 4 = FC Tape Enable
  1034. * MSB BIT 5 = Enable FC Confirm
  1035. * MSB BIT 6 = Enable command queuing in target mode
  1036. * MSB BIT 7 = No Logo On Link Down
  1037. */
  1038. uint8_t add_firmware_options[2];
  1039. uint8_t response_accumulation_timer;
  1040. uint8_t interrupt_delay_timer;
  1041. /*
  1042. * LSB BIT 0 = Enable Read xfr_rdy
  1043. * LSB BIT 1 = Soft ID only
  1044. * LSB BIT 2 =
  1045. * LSB BIT 3 =
  1046. * LSB BIT 4 = FCP RSP Payload [0]
  1047. * LSB BIT 5 = FCP RSP Payload [1] / Sbus enable - 2200
  1048. * LSB BIT 6 = Enable Out-of-Order frame handling
  1049. * LSB BIT 7 = Disable Automatic PLOGI on Local Loop
  1050. *
  1051. * MSB BIT 0 = Sbus enable - 2300
  1052. * MSB BIT 1 =
  1053. * MSB BIT 2 =
  1054. * MSB BIT 3 =
  1055. * MSB BIT 4 = LED mode
  1056. * MSB BIT 5 = enable 50 ohm termination
  1057. * MSB BIT 6 = Data Rate (2300 only)
  1058. * MSB BIT 7 = Data Rate (2300 only)
  1059. */
  1060. uint8_t special_options[2];
  1061. /* Reserved for expanded RISC parameter block */
  1062. uint8_t reserved_2[22];
  1063. /*
  1064. * LSB BIT 0 = Tx Sensitivity 1G bit 0
  1065. * LSB BIT 1 = Tx Sensitivity 1G bit 1
  1066. * LSB BIT 2 = Tx Sensitivity 1G bit 2
  1067. * LSB BIT 3 = Tx Sensitivity 1G bit 3
  1068. * LSB BIT 4 = Rx Sensitivity 1G bit 0
  1069. * LSB BIT 5 = Rx Sensitivity 1G bit 1
  1070. * LSB BIT 6 = Rx Sensitivity 1G bit 2
  1071. * LSB BIT 7 = Rx Sensitivity 1G bit 3
  1072. *
  1073. * MSB BIT 0 = Tx Sensitivity 2G bit 0
  1074. * MSB BIT 1 = Tx Sensitivity 2G bit 1
  1075. * MSB BIT 2 = Tx Sensitivity 2G bit 2
  1076. * MSB BIT 3 = Tx Sensitivity 2G bit 3
  1077. * MSB BIT 4 = Rx Sensitivity 2G bit 0
  1078. * MSB BIT 5 = Rx Sensitivity 2G bit 1
  1079. * MSB BIT 6 = Rx Sensitivity 2G bit 2
  1080. * MSB BIT 7 = Rx Sensitivity 2G bit 3
  1081. *
  1082. * LSB BIT 0 = Output Swing 1G bit 0
  1083. * LSB BIT 1 = Output Swing 1G bit 1
  1084. * LSB BIT 2 = Output Swing 1G bit 2
  1085. * LSB BIT 3 = Output Emphasis 1G bit 0
  1086. * LSB BIT 4 = Output Emphasis 1G bit 1
  1087. * LSB BIT 5 = Output Swing 2G bit 0
  1088. * LSB BIT 6 = Output Swing 2G bit 1
  1089. * LSB BIT 7 = Output Swing 2G bit 2
  1090. *
  1091. * MSB BIT 0 = Output Emphasis 2G bit 0
  1092. * MSB BIT 1 = Output Emphasis 2G bit 1
  1093. * MSB BIT 2 = Output Enable
  1094. * MSB BIT 3 =
  1095. * MSB BIT 4 =
  1096. * MSB BIT 5 =
  1097. * MSB BIT 6 =
  1098. * MSB BIT 7 =
  1099. */
  1100. uint8_t seriallink_options[4];
  1101. /*
  1102. * NVRAM host parameter block
  1103. *
  1104. * LSB BIT 0 = Enable spinup delay
  1105. * LSB BIT 1 = Disable BIOS
  1106. * LSB BIT 2 = Enable Memory Map BIOS
  1107. * LSB BIT 3 = Enable Selectable Boot
  1108. * LSB BIT 4 = Disable RISC code load
  1109. * LSB BIT 5 = Set cache line size 1
  1110. * LSB BIT 6 = PCI Parity Disable
  1111. * LSB BIT 7 = Enable extended logging
  1112. *
  1113. * MSB BIT 0 = Enable 64bit addressing
  1114. * MSB BIT 1 = Enable lip reset
  1115. * MSB BIT 2 = Enable lip full login
  1116. * MSB BIT 3 = Enable target reset
  1117. * MSB BIT 4 = Enable database storage
  1118. * MSB BIT 5 = Enable cache flush read
  1119. * MSB BIT 6 = Enable database load
  1120. * MSB BIT 7 = Enable alternate WWN
  1121. */
  1122. uint8_t host_p[2];
  1123. uint8_t boot_node_name[WWN_SIZE];
  1124. uint8_t boot_lun_number;
  1125. uint8_t reset_delay;
  1126. uint8_t port_down_retry_count;
  1127. uint8_t boot_id_number;
  1128. uint16_t max_luns_per_target;
  1129. uint8_t fcode_boot_port_name[WWN_SIZE];
  1130. uint8_t alternate_port_name[WWN_SIZE];
  1131. uint8_t alternate_node_name[WWN_SIZE];
  1132. /*
  1133. * BIT 0 = Selective Login
  1134. * BIT 1 = Alt-Boot Enable
  1135. * BIT 2 =
  1136. * BIT 3 = Boot Order List
  1137. * BIT 4 =
  1138. * BIT 5 = Selective LUN
  1139. * BIT 6 =
  1140. * BIT 7 = unused
  1141. */
  1142. uint8_t efi_parameters;
  1143. uint8_t link_down_timeout;
  1144. uint8_t adapter_id[16];
  1145. uint8_t alt1_boot_node_name[WWN_SIZE];
  1146. uint16_t alt1_boot_lun_number;
  1147. uint8_t alt2_boot_node_name[WWN_SIZE];
  1148. uint16_t alt2_boot_lun_number;
  1149. uint8_t alt3_boot_node_name[WWN_SIZE];
  1150. uint16_t alt3_boot_lun_number;
  1151. uint8_t alt4_boot_node_name[WWN_SIZE];
  1152. uint16_t alt4_boot_lun_number;
  1153. uint8_t alt5_boot_node_name[WWN_SIZE];
  1154. uint16_t alt5_boot_lun_number;
  1155. uint8_t alt6_boot_node_name[WWN_SIZE];
  1156. uint16_t alt6_boot_lun_number;
  1157. uint8_t alt7_boot_node_name[WWN_SIZE];
  1158. uint16_t alt7_boot_lun_number;
  1159. uint8_t reserved_3[2];
  1160. /* Offset 200-215 : Model Number */
  1161. uint8_t model_number[16];
  1162. /* OEM related items */
  1163. uint8_t oem_specific[16];
  1164. /*
  1165. * NVRAM Adapter Features offset 232-239
  1166. *
  1167. * LSB BIT 0 = External GBIC
  1168. * LSB BIT 1 = Risc RAM parity
  1169. * LSB BIT 2 = Buffer Plus Module
  1170. * LSB BIT 3 = Multi Chip Adapter
  1171. * LSB BIT 4 = Internal connector
  1172. * LSB BIT 5 =
  1173. * LSB BIT 6 =
  1174. * LSB BIT 7 =
  1175. *
  1176. * MSB BIT 0 =
  1177. * MSB BIT 1 =
  1178. * MSB BIT 2 =
  1179. * MSB BIT 3 =
  1180. * MSB BIT 4 =
  1181. * MSB BIT 5 =
  1182. * MSB BIT 6 =
  1183. * MSB BIT 7 =
  1184. */
  1185. uint8_t adapter_features[2];
  1186. uint8_t reserved_4[16];
  1187. /* Subsystem vendor ID for ISP2200 */
  1188. uint16_t subsystem_vendor_id_2200;
  1189. /* Subsystem device ID for ISP2200 */
  1190. uint16_t subsystem_device_id_2200;
  1191. uint8_t reserved_5;
  1192. uint8_t checksum;
  1193. } nvram_t;
  1194. /*
  1195. * ISP queue - response queue entry definition.
  1196. */
  1197. typedef struct {
  1198. uint8_t entry_type; /* Entry type. */
  1199. uint8_t entry_count; /* Entry count. */
  1200. uint8_t sys_define; /* System defined. */
  1201. uint8_t entry_status; /* Entry Status. */
  1202. uint32_t handle; /* System defined handle */
  1203. uint8_t data[52];
  1204. uint32_t signature;
  1205. #define RESPONSE_PROCESSED 0xDEADDEAD /* Signature */
  1206. } response_t;
  1207. /*
  1208. * ISP queue - ATIO queue entry definition.
  1209. */
  1210. struct atio {
  1211. uint8_t entry_type; /* Entry type. */
  1212. uint8_t entry_count; /* Entry count. */
  1213. uint8_t data[58];
  1214. uint32_t signature;
  1215. #define ATIO_PROCESSED 0xDEADDEAD /* Signature */
  1216. };
  1217. typedef union {
  1218. uint16_t extended;
  1219. struct {
  1220. uint8_t reserved;
  1221. uint8_t standard;
  1222. } id;
  1223. } target_id_t;
  1224. #define SET_TARGET_ID(ha, to, from) \
  1225. do { \
  1226. if (HAS_EXTENDED_IDS(ha)) \
  1227. to.extended = cpu_to_le16(from); \
  1228. else \
  1229. to.id.standard = (uint8_t)from; \
  1230. } while (0)
  1231. /*
  1232. * ISP queue - command entry structure definition.
  1233. */
  1234. #define COMMAND_TYPE 0x11 /* Command entry */
  1235. typedef struct {
  1236. uint8_t entry_type; /* Entry type. */
  1237. uint8_t entry_count; /* Entry count. */
  1238. uint8_t sys_define; /* System defined. */
  1239. uint8_t entry_status; /* Entry Status. */
  1240. uint32_t handle; /* System handle. */
  1241. target_id_t target; /* SCSI ID */
  1242. uint16_t lun; /* SCSI LUN */
  1243. uint16_t control_flags; /* Control flags. */
  1244. #define CF_WRITE BIT_6
  1245. #define CF_READ BIT_5
  1246. #define CF_SIMPLE_TAG BIT_3
  1247. #define CF_ORDERED_TAG BIT_2
  1248. #define CF_HEAD_TAG BIT_1
  1249. uint16_t reserved_1;
  1250. uint16_t timeout; /* Command timeout. */
  1251. uint16_t dseg_count; /* Data segment count. */
  1252. uint8_t scsi_cdb[MAX_CMDSZ]; /* SCSI command words. */
  1253. uint32_t byte_count; /* Total byte count. */
  1254. uint32_t dseg_0_address; /* Data segment 0 address. */
  1255. uint32_t dseg_0_length; /* Data segment 0 length. */
  1256. uint32_t dseg_1_address; /* Data segment 1 address. */
  1257. uint32_t dseg_1_length; /* Data segment 1 length. */
  1258. uint32_t dseg_2_address; /* Data segment 2 address. */
  1259. uint32_t dseg_2_length; /* Data segment 2 length. */
  1260. } cmd_entry_t;
  1261. /*
  1262. * ISP queue - 64-Bit addressing, command entry structure definition.
  1263. */
  1264. #define COMMAND_A64_TYPE 0x19 /* Command A64 entry */
  1265. typedef struct {
  1266. uint8_t entry_type; /* Entry type. */
  1267. uint8_t entry_count; /* Entry count. */
  1268. uint8_t sys_define; /* System defined. */
  1269. uint8_t entry_status; /* Entry Status. */
  1270. uint32_t handle; /* System handle. */
  1271. target_id_t target; /* SCSI ID */
  1272. uint16_t lun; /* SCSI LUN */
  1273. uint16_t control_flags; /* Control flags. */
  1274. uint16_t reserved_1;
  1275. uint16_t timeout; /* Command timeout. */
  1276. uint16_t dseg_count; /* Data segment count. */
  1277. uint8_t scsi_cdb[MAX_CMDSZ]; /* SCSI command words. */
  1278. uint32_t byte_count; /* Total byte count. */
  1279. uint32_t dseg_0_address[2]; /* Data segment 0 address. */
  1280. uint32_t dseg_0_length; /* Data segment 0 length. */
  1281. uint32_t dseg_1_address[2]; /* Data segment 1 address. */
  1282. uint32_t dseg_1_length; /* Data segment 1 length. */
  1283. } cmd_a64_entry_t, request_t;
  1284. /*
  1285. * ISP queue - continuation entry structure definition.
  1286. */
  1287. #define CONTINUE_TYPE 0x02 /* Continuation entry. */
  1288. typedef struct {
  1289. uint8_t entry_type; /* Entry type. */
  1290. uint8_t entry_count; /* Entry count. */
  1291. uint8_t sys_define; /* System defined. */
  1292. uint8_t entry_status; /* Entry Status. */
  1293. uint32_t reserved;
  1294. uint32_t dseg_0_address; /* Data segment 0 address. */
  1295. uint32_t dseg_0_length; /* Data segment 0 length. */
  1296. uint32_t dseg_1_address; /* Data segment 1 address. */
  1297. uint32_t dseg_1_length; /* Data segment 1 length. */
  1298. uint32_t dseg_2_address; /* Data segment 2 address. */
  1299. uint32_t dseg_2_length; /* Data segment 2 length. */
  1300. uint32_t dseg_3_address; /* Data segment 3 address. */
  1301. uint32_t dseg_3_length; /* Data segment 3 length. */
  1302. uint32_t dseg_4_address; /* Data segment 4 address. */
  1303. uint32_t dseg_4_length; /* Data segment 4 length. */
  1304. uint32_t dseg_5_address; /* Data segment 5 address. */
  1305. uint32_t dseg_5_length; /* Data segment 5 length. */
  1306. uint32_t dseg_6_address; /* Data segment 6 address. */
  1307. uint32_t dseg_6_length; /* Data segment 6 length. */
  1308. } cont_entry_t;
  1309. /*
  1310. * ISP queue - 64-Bit addressing, continuation entry structure definition.
  1311. */
  1312. #define CONTINUE_A64_TYPE 0x0A /* Continuation A64 entry. */
  1313. typedef struct {
  1314. uint8_t entry_type; /* Entry type. */
  1315. uint8_t entry_count; /* Entry count. */
  1316. uint8_t sys_define; /* System defined. */
  1317. uint8_t entry_status; /* Entry Status. */
  1318. uint32_t dseg_0_address[2]; /* Data segment 0 address. */
  1319. uint32_t dseg_0_length; /* Data segment 0 length. */
  1320. uint32_t dseg_1_address[2]; /* Data segment 1 address. */
  1321. uint32_t dseg_1_length; /* Data segment 1 length. */
  1322. uint32_t dseg_2_address [2]; /* Data segment 2 address. */
  1323. uint32_t dseg_2_length; /* Data segment 2 length. */
  1324. uint32_t dseg_3_address[2]; /* Data segment 3 address. */
  1325. uint32_t dseg_3_length; /* Data segment 3 length. */
  1326. uint32_t dseg_4_address[2]; /* Data segment 4 address. */
  1327. uint32_t dseg_4_length; /* Data segment 4 length. */
  1328. } cont_a64_entry_t;
  1329. #define PO_MODE_DIF_INSERT 0
  1330. #define PO_MODE_DIF_REMOVE BIT_0
  1331. #define PO_MODE_DIF_PASS BIT_1
  1332. #define PO_MODE_DIF_REPLACE (BIT_0 + BIT_1)
  1333. #define PO_ENABLE_DIF_BUNDLING BIT_8
  1334. #define PO_ENABLE_INCR_GUARD_SEED BIT_3
  1335. #define PO_DISABLE_INCR_REF_TAG BIT_5
  1336. #define PO_DISABLE_GUARD_CHECK BIT_4
  1337. /*
  1338. * ISP queue - 64-Bit addressing, continuation crc entry structure definition.
  1339. */
  1340. struct crc_context {
  1341. uint32_t handle; /* System handle. */
  1342. uint32_t ref_tag;
  1343. uint16_t app_tag;
  1344. uint8_t ref_tag_mask[4]; /* Validation/Replacement Mask*/
  1345. uint8_t app_tag_mask[2]; /* Validation/Replacement Mask*/
  1346. uint16_t guard_seed; /* Initial Guard Seed */
  1347. uint16_t prot_opts; /* Requested Data Protection Mode */
  1348. uint16_t blk_size; /* Data size in bytes */
  1349. uint16_t runt_blk_guard; /* Guard value for runt block (tape
  1350. * only) */
  1351. uint32_t byte_count; /* Total byte count/ total data
  1352. * transfer count */
  1353. union {
  1354. struct {
  1355. uint32_t reserved_1;
  1356. uint16_t reserved_2;
  1357. uint16_t reserved_3;
  1358. uint32_t reserved_4;
  1359. uint32_t data_address[2];
  1360. uint32_t data_length;
  1361. uint32_t reserved_5[2];
  1362. uint32_t reserved_6;
  1363. } nobundling;
  1364. struct {
  1365. uint32_t dif_byte_count; /* Total DIF byte
  1366. * count */
  1367. uint16_t reserved_1;
  1368. uint16_t dseg_count; /* Data segment count */
  1369. uint32_t reserved_2;
  1370. uint32_t data_address[2];
  1371. uint32_t data_length;
  1372. uint32_t dif_address[2];
  1373. uint32_t dif_length; /* Data segment 0
  1374. * length */
  1375. } bundling;
  1376. } u;
  1377. struct fcp_cmnd fcp_cmnd;
  1378. dma_addr_t crc_ctx_dma;
  1379. /* List of DMA context transfers */
  1380. struct list_head dsd_list;
  1381. /* This structure should not exceed 512 bytes */
  1382. };
  1383. #define CRC_CONTEXT_LEN_FW (offsetof(struct crc_context, fcp_cmnd.lun))
  1384. #define CRC_CONTEXT_FCPCMND_OFF (offsetof(struct crc_context, fcp_cmnd.lun))
  1385. /*
  1386. * ISP queue - status entry structure definition.
  1387. */
  1388. #define STATUS_TYPE 0x03 /* Status entry. */
  1389. typedef struct {
  1390. uint8_t entry_type; /* Entry type. */
  1391. uint8_t entry_count; /* Entry count. */
  1392. uint8_t sys_define; /* System defined. */
  1393. uint8_t entry_status; /* Entry Status. */
  1394. uint32_t handle; /* System handle. */
  1395. uint16_t scsi_status; /* SCSI status. */
  1396. uint16_t comp_status; /* Completion status. */
  1397. uint16_t state_flags; /* State flags. */
  1398. uint16_t status_flags; /* Status flags. */
  1399. uint16_t rsp_info_len; /* Response Info Length. */
  1400. uint16_t req_sense_length; /* Request sense data length. */
  1401. uint32_t residual_length; /* Residual transfer length. */
  1402. uint8_t rsp_info[8]; /* FCP response information. */
  1403. uint8_t req_sense_data[32]; /* Request sense data. */
  1404. } sts_entry_t;
  1405. /*
  1406. * Status entry entry status
  1407. */
  1408. #define RF_RQ_DMA_ERROR BIT_6 /* Request Queue DMA error. */
  1409. #define RF_INV_E_ORDER BIT_5 /* Invalid entry order. */
  1410. #define RF_INV_E_COUNT BIT_4 /* Invalid entry count. */
  1411. #define RF_INV_E_PARAM BIT_3 /* Invalid entry parameter. */
  1412. #define RF_INV_E_TYPE BIT_2 /* Invalid entry type. */
  1413. #define RF_BUSY BIT_1 /* Busy */
  1414. #define RF_MASK (RF_RQ_DMA_ERROR | RF_INV_E_ORDER | RF_INV_E_COUNT | \
  1415. RF_INV_E_PARAM | RF_INV_E_TYPE | RF_BUSY)
  1416. #define RF_MASK_24XX (RF_INV_E_ORDER | RF_INV_E_COUNT | RF_INV_E_PARAM | \
  1417. RF_INV_E_TYPE)
  1418. /*
  1419. * Status entry SCSI status bit definitions.
  1420. */
  1421. #define SS_MASK 0xfff /* Reserved bits BIT_12-BIT_15*/
  1422. #define SS_RESIDUAL_UNDER BIT_11
  1423. #define SS_RESIDUAL_OVER BIT_10
  1424. #define SS_SENSE_LEN_VALID BIT_9
  1425. #define SS_RESPONSE_INFO_LEN_VALID BIT_8
  1426. #define SS_RESERVE_CONFLICT (BIT_4 | BIT_3)
  1427. #define SS_BUSY_CONDITION BIT_3
  1428. #define SS_CONDITION_MET BIT_2
  1429. #define SS_CHECK_CONDITION BIT_1
  1430. /*
  1431. * Status entry completion status
  1432. */
  1433. #define CS_COMPLETE 0x0 /* No errors */
  1434. #define CS_INCOMPLETE 0x1 /* Incomplete transfer of cmd. */
  1435. #define CS_DMA 0x2 /* A DMA direction error. */
  1436. #define CS_TRANSPORT 0x3 /* Transport error. */
  1437. #define CS_RESET 0x4 /* SCSI bus reset occurred */
  1438. #define CS_ABORTED 0x5 /* System aborted command. */
  1439. #define CS_TIMEOUT 0x6 /* Timeout error. */
  1440. #define CS_DATA_OVERRUN 0x7 /* Data overrun. */
  1441. #define CS_DIF_ERROR 0xC /* DIF error detected */
  1442. #define CS_DATA_UNDERRUN 0x15 /* Data Underrun. */
  1443. #define CS_QUEUE_FULL 0x1C /* Queue Full. */
  1444. #define CS_PORT_UNAVAILABLE 0x28 /* Port unavailable */
  1445. /* (selection timeout) */
  1446. #define CS_PORT_LOGGED_OUT 0x29 /* Port Logged Out */
  1447. #define CS_PORT_CONFIG_CHG 0x2A /* Port Configuration Changed */
  1448. #define CS_PORT_BUSY 0x2B /* Port Busy */
  1449. #define CS_COMPLETE_CHKCOND 0x30 /* Error? */
  1450. #define CS_BAD_PAYLOAD 0x80 /* Driver defined */
  1451. #define CS_UNKNOWN 0x81 /* Driver defined */
  1452. #define CS_RETRY 0x82 /* Driver defined */
  1453. #define CS_LOOP_DOWN_ABORT 0x83 /* Driver defined */
  1454. #define CS_BIDIR_RD_OVERRUN 0x700
  1455. #define CS_BIDIR_RD_WR_OVERRUN 0x707
  1456. #define CS_BIDIR_RD_OVERRUN_WR_UNDERRUN 0x715
  1457. #define CS_BIDIR_RD_UNDERRUN 0x1500
  1458. #define CS_BIDIR_RD_UNDERRUN_WR_OVERRUN 0x1507
  1459. #define CS_BIDIR_RD_WR_UNDERRUN 0x1515
  1460. #define CS_BIDIR_DMA 0x200
  1461. /*
  1462. * Status entry status flags
  1463. */
  1464. #define SF_ABTS_TERMINATED BIT_10
  1465. #define SF_LOGOUT_SENT BIT_13
  1466. /*
  1467. * ISP queue - status continuation entry structure definition.
  1468. */
  1469. #define STATUS_CONT_TYPE 0x10 /* Status continuation entry. */
  1470. typedef struct {
  1471. uint8_t entry_type; /* Entry type. */
  1472. uint8_t entry_count; /* Entry count. */
  1473. uint8_t sys_define; /* System defined. */
  1474. uint8_t entry_status; /* Entry Status. */
  1475. uint8_t data[60]; /* data */
  1476. } sts_cont_entry_t;
  1477. /*
  1478. * ISP queue - RIO Type 1 status entry (32 bit I/O entry handles)
  1479. * structure definition.
  1480. */
  1481. #define STATUS_TYPE_21 0x21 /* Status entry. */
  1482. typedef struct {
  1483. uint8_t entry_type; /* Entry type. */
  1484. uint8_t entry_count; /* Entry count. */
  1485. uint8_t handle_count; /* Handle count. */
  1486. uint8_t entry_status; /* Entry Status. */
  1487. uint32_t handle[15]; /* System handles. */
  1488. } sts21_entry_t;
  1489. /*
  1490. * ISP queue - RIO Type 2 status entry (16 bit I/O entry handles)
  1491. * structure definition.
  1492. */
  1493. #define STATUS_TYPE_22 0x22 /* 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. uint16_t handle[30]; /* System handles. */
  1500. } sts22_entry_t;
  1501. /*
  1502. * ISP queue - marker entry structure definition.
  1503. */
  1504. #define MARKER_TYPE 0x04 /* Marker entry. */
  1505. typedef struct {
  1506. uint8_t entry_type; /* Entry type. */
  1507. uint8_t entry_count; /* Entry count. */
  1508. uint8_t handle_count; /* Handle count. */
  1509. uint8_t entry_status; /* Entry Status. */
  1510. uint32_t sys_define_2; /* System defined. */
  1511. target_id_t target; /* SCSI ID */
  1512. uint8_t modifier; /* Modifier (7-0). */
  1513. #define MK_SYNC_ID_LUN 0 /* Synchronize ID/LUN */
  1514. #define MK_SYNC_ID 1 /* Synchronize ID */
  1515. #define MK_SYNC_ALL 2 /* Synchronize all ID/LUN */
  1516. #define MK_SYNC_LIP 3 /* Synchronize all ID/LUN, */
  1517. /* clear port changed, */
  1518. /* use sequence number. */
  1519. uint8_t reserved_1;
  1520. uint16_t sequence_number; /* Sequence number of event */
  1521. uint16_t lun; /* SCSI LUN */
  1522. uint8_t reserved_2[48];
  1523. } mrk_entry_t;
  1524. /*
  1525. * ISP queue - Management Server entry structure definition.
  1526. */
  1527. #define MS_IOCB_TYPE 0x29 /* Management Server IOCB entry */
  1528. typedef struct {
  1529. uint8_t entry_type; /* Entry type. */
  1530. uint8_t entry_count; /* Entry count. */
  1531. uint8_t handle_count; /* Handle count. */
  1532. uint8_t entry_status; /* Entry Status. */
  1533. uint32_t handle1; /* System handle. */
  1534. target_id_t loop_id;
  1535. uint16_t status;
  1536. uint16_t control_flags; /* Control flags. */
  1537. uint16_t reserved2;
  1538. uint16_t timeout;
  1539. uint16_t cmd_dsd_count;
  1540. uint16_t total_dsd_count;
  1541. uint8_t type;
  1542. uint8_t r_ctl;
  1543. uint16_t rx_id;
  1544. uint16_t reserved3;
  1545. uint32_t handle2;
  1546. uint32_t rsp_bytecount;
  1547. uint32_t req_bytecount;
  1548. uint32_t dseg_req_address[2]; /* Data segment 0 address. */
  1549. uint32_t dseg_req_length; /* Data segment 0 length. */
  1550. uint32_t dseg_rsp_address[2]; /* Data segment 1 address. */
  1551. uint32_t dseg_rsp_length; /* Data segment 1 length. */
  1552. } ms_iocb_entry_t;
  1553. /*
  1554. * ISP queue - Mailbox Command entry structure definition.
  1555. */
  1556. #define MBX_IOCB_TYPE 0x39
  1557. struct mbx_entry {
  1558. uint8_t entry_type;
  1559. uint8_t entry_count;
  1560. uint8_t sys_define1;
  1561. /* Use sys_define1 for source type */
  1562. #define SOURCE_SCSI 0x00
  1563. #define SOURCE_IP 0x01
  1564. #define SOURCE_VI 0x02
  1565. #define SOURCE_SCTP 0x03
  1566. #define SOURCE_MP 0x04
  1567. #define SOURCE_MPIOCTL 0x05
  1568. #define SOURCE_ASYNC_IOCB 0x07
  1569. uint8_t entry_status;
  1570. uint32_t handle;
  1571. target_id_t loop_id;
  1572. uint16_t status;
  1573. uint16_t state_flags;
  1574. uint16_t status_flags;
  1575. uint32_t sys_define2[2];
  1576. uint16_t mb0;
  1577. uint16_t mb1;
  1578. uint16_t mb2;
  1579. uint16_t mb3;
  1580. uint16_t mb6;
  1581. uint16_t mb7;
  1582. uint16_t mb9;
  1583. uint16_t mb10;
  1584. uint32_t reserved_2[2];
  1585. uint8_t node_name[WWN_SIZE];
  1586. uint8_t port_name[WWN_SIZE];
  1587. };
  1588. /*
  1589. * ISP request and response queue entry sizes
  1590. */
  1591. #define RESPONSE_ENTRY_SIZE (sizeof(response_t))
  1592. #define REQUEST_ENTRY_SIZE (sizeof(request_t))
  1593. /*
  1594. * 24 bit port ID type definition.
  1595. */
  1596. typedef union {
  1597. uint32_t b24 : 24;
  1598. struct {
  1599. #ifdef __BIG_ENDIAN
  1600. uint8_t domain;
  1601. uint8_t area;
  1602. uint8_t al_pa;
  1603. #elif defined(__LITTLE_ENDIAN)
  1604. uint8_t al_pa;
  1605. uint8_t area;
  1606. uint8_t domain;
  1607. #else
  1608. #error "__BIG_ENDIAN or __LITTLE_ENDIAN must be defined!"
  1609. #endif
  1610. uint8_t rsvd_1;
  1611. } b;
  1612. } port_id_t;
  1613. #define INVALID_PORT_ID 0xFFFFFF
  1614. /*
  1615. * Switch info gathering structure.
  1616. */
  1617. typedef struct {
  1618. port_id_t d_id;
  1619. uint8_t node_name[WWN_SIZE];
  1620. uint8_t port_name[WWN_SIZE];
  1621. uint8_t fabric_port_name[WWN_SIZE];
  1622. uint16_t fp_speed;
  1623. uint8_t fc4_type;
  1624. } sw_info_t;
  1625. /* FCP-4 types */
  1626. #define FC4_TYPE_FCP_SCSI 0x08
  1627. #define FC4_TYPE_OTHER 0x0
  1628. #define FC4_TYPE_UNKNOWN 0xff
  1629. /*
  1630. * Fibre channel port type.
  1631. */
  1632. typedef enum {
  1633. FCT_UNKNOWN,
  1634. FCT_RSCN,
  1635. FCT_SWITCH,
  1636. FCT_BROADCAST,
  1637. FCT_INITIATOR,
  1638. FCT_TARGET
  1639. } fc_port_type_t;
  1640. /*
  1641. * Fibre channel port structure.
  1642. */
  1643. typedef struct fc_port {
  1644. struct list_head list;
  1645. struct scsi_qla_host *vha;
  1646. uint8_t node_name[WWN_SIZE];
  1647. uint8_t port_name[WWN_SIZE];
  1648. port_id_t d_id;
  1649. uint16_t loop_id;
  1650. uint16_t old_loop_id;
  1651. uint8_t fcp_prio;
  1652. uint8_t fabric_port_name[WWN_SIZE];
  1653. uint16_t fp_speed;
  1654. fc_port_type_t port_type;
  1655. atomic_t state;
  1656. uint32_t flags;
  1657. int login_retry;
  1658. struct fc_rport *rport, *drport;
  1659. u32 supported_classes;
  1660. uint8_t fc4_type;
  1661. uint8_t scan_state;
  1662. } fc_port_t;
  1663. #define QLA_FCPORT_SCAN_NONE 0
  1664. #define QLA_FCPORT_SCAN_FOUND 1
  1665. /*
  1666. * Fibre channel port/lun states.
  1667. */
  1668. #define FCS_UNCONFIGURED 1
  1669. #define FCS_DEVICE_DEAD 2
  1670. #define FCS_DEVICE_LOST 3
  1671. #define FCS_ONLINE 4
  1672. static const char * const port_state_str[] = {
  1673. "Unknown",
  1674. "UNCONFIGURED",
  1675. "DEAD",
  1676. "LOST",
  1677. "ONLINE"
  1678. };
  1679. /*
  1680. * FC port flags.
  1681. */
  1682. #define FCF_FABRIC_DEVICE BIT_0
  1683. #define FCF_LOGIN_NEEDED BIT_1
  1684. #define FCF_FCP2_DEVICE BIT_2
  1685. #define FCF_ASYNC_SENT BIT_3
  1686. #define FCF_CONF_COMP_SUPPORTED BIT_4
  1687. /* No loop ID flag. */
  1688. #define FC_NO_LOOP_ID 0x1000
  1689. /*
  1690. * FC-CT interface
  1691. *
  1692. * NOTE: All structures are big-endian in form.
  1693. */
  1694. #define CT_REJECT_RESPONSE 0x8001
  1695. #define CT_ACCEPT_RESPONSE 0x8002
  1696. #define CT_REASON_INVALID_COMMAND_CODE 0x01
  1697. #define CT_REASON_CANNOT_PERFORM 0x09
  1698. #define CT_REASON_COMMAND_UNSUPPORTED 0x0b
  1699. #define CT_EXPL_ALREADY_REGISTERED 0x10
  1700. #define NS_N_PORT_TYPE 0x01
  1701. #define NS_NL_PORT_TYPE 0x02
  1702. #define NS_NX_PORT_TYPE 0x7F
  1703. #define GA_NXT_CMD 0x100
  1704. #define GA_NXT_REQ_SIZE (16 + 4)
  1705. #define GA_NXT_RSP_SIZE (16 + 620)
  1706. #define GID_PT_CMD 0x1A1
  1707. #define GID_PT_REQ_SIZE (16 + 4)
  1708. #define GPN_ID_CMD 0x112
  1709. #define GPN_ID_REQ_SIZE (16 + 4)
  1710. #define GPN_ID_RSP_SIZE (16 + 8)
  1711. #define GNN_ID_CMD 0x113
  1712. #define GNN_ID_REQ_SIZE (16 + 4)
  1713. #define GNN_ID_RSP_SIZE (16 + 8)
  1714. #define GFT_ID_CMD 0x117
  1715. #define GFT_ID_REQ_SIZE (16 + 4)
  1716. #define GFT_ID_RSP_SIZE (16 + 32)
  1717. #define RFT_ID_CMD 0x217
  1718. #define RFT_ID_REQ_SIZE (16 + 4 + 32)
  1719. #define RFT_ID_RSP_SIZE 16
  1720. #define RFF_ID_CMD 0x21F
  1721. #define RFF_ID_REQ_SIZE (16 + 4 + 2 + 1 + 1)
  1722. #define RFF_ID_RSP_SIZE 16
  1723. #define RNN_ID_CMD 0x213
  1724. #define RNN_ID_REQ_SIZE (16 + 4 + 8)
  1725. #define RNN_ID_RSP_SIZE 16
  1726. #define RSNN_NN_CMD 0x239
  1727. #define RSNN_NN_REQ_SIZE (16 + 8 + 1 + 255)
  1728. #define RSNN_NN_RSP_SIZE 16
  1729. #define GFPN_ID_CMD 0x11C
  1730. #define GFPN_ID_REQ_SIZE (16 + 4)
  1731. #define GFPN_ID_RSP_SIZE (16 + 8)
  1732. #define GPSC_CMD 0x127
  1733. #define GPSC_REQ_SIZE (16 + 8)
  1734. #define GPSC_RSP_SIZE (16 + 2 + 2)
  1735. #define GFF_ID_CMD 0x011F
  1736. #define GFF_ID_REQ_SIZE (16 + 4)
  1737. #define GFF_ID_RSP_SIZE (16 + 128)
  1738. /*
  1739. * HBA attribute types.
  1740. */
  1741. #define FDMI_HBA_ATTR_COUNT 9
  1742. #define FDMI_HBA_NODE_NAME 1
  1743. #define FDMI_HBA_MANUFACTURER 2
  1744. #define FDMI_HBA_SERIAL_NUMBER 3
  1745. #define FDMI_HBA_MODEL 4
  1746. #define FDMI_HBA_MODEL_DESCRIPTION 5
  1747. #define FDMI_HBA_HARDWARE_VERSION 6
  1748. #define FDMI_HBA_DRIVER_VERSION 7
  1749. #define FDMI_HBA_OPTION_ROM_VERSION 8
  1750. #define FDMI_HBA_FIRMWARE_VERSION 9
  1751. #define FDMI_HBA_OS_NAME_AND_VERSION 0xa
  1752. #define FDMI_HBA_MAXIMUM_CT_PAYLOAD_LENGTH 0xb
  1753. struct ct_fdmi_hba_attr {
  1754. uint16_t type;
  1755. uint16_t len;
  1756. union {
  1757. uint8_t node_name[WWN_SIZE];
  1758. uint8_t manufacturer[32];
  1759. uint8_t serial_num[8];
  1760. uint8_t model[16];
  1761. uint8_t model_desc[80];
  1762. uint8_t hw_version[16];
  1763. uint8_t driver_version[32];
  1764. uint8_t orom_version[16];
  1765. uint8_t fw_version[16];
  1766. uint8_t os_version[128];
  1767. uint8_t max_ct_len[4];
  1768. } a;
  1769. };
  1770. struct ct_fdmi_hba_attributes {
  1771. uint32_t count;
  1772. struct ct_fdmi_hba_attr entry[FDMI_HBA_ATTR_COUNT];
  1773. };
  1774. /*
  1775. * Port attribute types.
  1776. */
  1777. #define FDMI_PORT_ATTR_COUNT 6
  1778. #define FDMI_PORT_FC4_TYPES 1
  1779. #define FDMI_PORT_SUPPORT_SPEED 2
  1780. #define FDMI_PORT_CURRENT_SPEED 3
  1781. #define FDMI_PORT_MAX_FRAME_SIZE 4
  1782. #define FDMI_PORT_OS_DEVICE_NAME 5
  1783. #define FDMI_PORT_HOST_NAME 6
  1784. #define FDMI_PORT_SPEED_1GB 0x1
  1785. #define FDMI_PORT_SPEED_2GB 0x2
  1786. #define FDMI_PORT_SPEED_10GB 0x4
  1787. #define FDMI_PORT_SPEED_4GB 0x8
  1788. #define FDMI_PORT_SPEED_8GB 0x10
  1789. #define FDMI_PORT_SPEED_16GB 0x20
  1790. #define FDMI_PORT_SPEED_UNKNOWN 0x8000
  1791. struct ct_fdmi_port_attr {
  1792. uint16_t type;
  1793. uint16_t len;
  1794. union {
  1795. uint8_t fc4_types[32];
  1796. uint32_t sup_speed;
  1797. uint32_t cur_speed;
  1798. uint32_t max_frame_size;
  1799. uint8_t os_dev_name[32];
  1800. uint8_t host_name[32];
  1801. } a;
  1802. };
  1803. /*
  1804. * Port Attribute Block.
  1805. */
  1806. struct ct_fdmi_port_attributes {
  1807. uint32_t count;
  1808. struct ct_fdmi_port_attr entry[FDMI_PORT_ATTR_COUNT];
  1809. };
  1810. /* FDMI definitions. */
  1811. #define GRHL_CMD 0x100
  1812. #define GHAT_CMD 0x101
  1813. #define GRPL_CMD 0x102
  1814. #define GPAT_CMD 0x110
  1815. #define RHBA_CMD 0x200
  1816. #define RHBA_RSP_SIZE 16
  1817. #define RHAT_CMD 0x201
  1818. #define RPRT_CMD 0x210
  1819. #define RPA_CMD 0x211
  1820. #define RPA_RSP_SIZE 16
  1821. #define DHBA_CMD 0x300
  1822. #define DHBA_REQ_SIZE (16 + 8)
  1823. #define DHBA_RSP_SIZE 16
  1824. #define DHAT_CMD 0x301
  1825. #define DPRT_CMD 0x310
  1826. #define DPA_CMD 0x311
  1827. /* CT command header -- request/response common fields */
  1828. struct ct_cmd_hdr {
  1829. uint8_t revision;
  1830. uint8_t in_id[3];
  1831. uint8_t gs_type;
  1832. uint8_t gs_subtype;
  1833. uint8_t options;
  1834. uint8_t reserved;
  1835. };
  1836. /* CT command request */
  1837. struct ct_sns_req {
  1838. struct ct_cmd_hdr header;
  1839. uint16_t command;
  1840. uint16_t max_rsp_size;
  1841. uint8_t fragment_id;
  1842. uint8_t reserved[3];
  1843. union {
  1844. /* GA_NXT, GPN_ID, GNN_ID, GFT_ID, GFPN_ID */
  1845. struct {
  1846. uint8_t reserved;
  1847. uint8_t port_id[3];
  1848. } port_id;
  1849. struct {
  1850. uint8_t port_type;
  1851. uint8_t domain;
  1852. uint8_t area;
  1853. uint8_t reserved;
  1854. } gid_pt;
  1855. struct {
  1856. uint8_t reserved;
  1857. uint8_t port_id[3];
  1858. uint8_t fc4_types[32];
  1859. } rft_id;
  1860. struct {
  1861. uint8_t reserved;
  1862. uint8_t port_id[3];
  1863. uint16_t reserved2;
  1864. uint8_t fc4_feature;
  1865. uint8_t fc4_type;
  1866. } rff_id;
  1867. struct {
  1868. uint8_t reserved;
  1869. uint8_t port_id[3];
  1870. uint8_t node_name[8];
  1871. } rnn_id;
  1872. struct {
  1873. uint8_t node_name[8];
  1874. uint8_t name_len;
  1875. uint8_t sym_node_name[255];
  1876. } rsnn_nn;
  1877. struct {
  1878. uint8_t hba_indentifier[8];
  1879. } ghat;
  1880. struct {
  1881. uint8_t hba_identifier[8];
  1882. uint32_t entry_count;
  1883. uint8_t port_name[8];
  1884. struct ct_fdmi_hba_attributes attrs;
  1885. } rhba;
  1886. struct {
  1887. uint8_t hba_identifier[8];
  1888. struct ct_fdmi_hba_attributes attrs;
  1889. } rhat;
  1890. struct {
  1891. uint8_t port_name[8];
  1892. struct ct_fdmi_port_attributes attrs;
  1893. } rpa;
  1894. struct {
  1895. uint8_t port_name[8];
  1896. } dhba;
  1897. struct {
  1898. uint8_t port_name[8];
  1899. } dhat;
  1900. struct {
  1901. uint8_t port_name[8];
  1902. } dprt;
  1903. struct {
  1904. uint8_t port_name[8];
  1905. } dpa;
  1906. struct {
  1907. uint8_t port_name[8];
  1908. } gpsc;
  1909. struct {
  1910. uint8_t reserved;
  1911. uint8_t port_name[3];
  1912. } gff_id;
  1913. } req;
  1914. };
  1915. /* CT command response header */
  1916. struct ct_rsp_hdr {
  1917. struct ct_cmd_hdr header;
  1918. uint16_t response;
  1919. uint16_t residual;
  1920. uint8_t fragment_id;
  1921. uint8_t reason_code;
  1922. uint8_t explanation_code;
  1923. uint8_t vendor_unique;
  1924. };
  1925. struct ct_sns_gid_pt_data {
  1926. uint8_t control_byte;
  1927. uint8_t port_id[3];
  1928. };
  1929. struct ct_sns_rsp {
  1930. struct ct_rsp_hdr header;
  1931. union {
  1932. struct {
  1933. uint8_t port_type;
  1934. uint8_t port_id[3];
  1935. uint8_t port_name[8];
  1936. uint8_t sym_port_name_len;
  1937. uint8_t sym_port_name[255];
  1938. uint8_t node_name[8];
  1939. uint8_t sym_node_name_len;
  1940. uint8_t sym_node_name[255];
  1941. uint8_t init_proc_assoc[8];
  1942. uint8_t node_ip_addr[16];
  1943. uint8_t class_of_service[4];
  1944. uint8_t fc4_types[32];
  1945. uint8_t ip_address[16];
  1946. uint8_t fabric_port_name[8];
  1947. uint8_t reserved;
  1948. uint8_t hard_address[3];
  1949. } ga_nxt;
  1950. struct {
  1951. /* Assume the largest number of targets for the union */
  1952. struct ct_sns_gid_pt_data
  1953. entries[MAX_FIBRE_DEVICES_MAX];
  1954. } gid_pt;
  1955. struct {
  1956. uint8_t port_name[8];
  1957. } gpn_id;
  1958. struct {
  1959. uint8_t node_name[8];
  1960. } gnn_id;
  1961. struct {
  1962. uint8_t fc4_types[32];
  1963. } gft_id;
  1964. struct {
  1965. uint32_t entry_count;
  1966. uint8_t port_name[8];
  1967. struct ct_fdmi_hba_attributes attrs;
  1968. } ghat;
  1969. struct {
  1970. uint8_t port_name[8];
  1971. } gfpn_id;
  1972. struct {
  1973. uint16_t speeds;
  1974. uint16_t speed;
  1975. } gpsc;
  1976. #define GFF_FCP_SCSI_OFFSET 7
  1977. struct {
  1978. uint8_t fc4_features[128];
  1979. } gff_id;
  1980. } rsp;
  1981. };
  1982. struct ct_sns_pkt {
  1983. union {
  1984. struct ct_sns_req req;
  1985. struct ct_sns_rsp rsp;
  1986. } p;
  1987. };
  1988. /*
  1989. * SNS command structures -- for 2200 compatibility.
  1990. */
  1991. #define RFT_ID_SNS_SCMD_LEN 22
  1992. #define RFT_ID_SNS_CMD_SIZE 60
  1993. #define RFT_ID_SNS_DATA_SIZE 16
  1994. #define RNN_ID_SNS_SCMD_LEN 10
  1995. #define RNN_ID_SNS_CMD_SIZE 36
  1996. #define RNN_ID_SNS_DATA_SIZE 16
  1997. #define GA_NXT_SNS_SCMD_LEN 6
  1998. #define GA_NXT_SNS_CMD_SIZE 28
  1999. #define GA_NXT_SNS_DATA_SIZE (620 + 16)
  2000. #define GID_PT_SNS_SCMD_LEN 6
  2001. #define GID_PT_SNS_CMD_SIZE 28
  2002. /*
  2003. * Assume MAX_FIBRE_DEVICES_2100 as these defines are only used with older
  2004. * adapters.
  2005. */
  2006. #define GID_PT_SNS_DATA_SIZE (MAX_FIBRE_DEVICES_2100 * 4 + 16)
  2007. #define GPN_ID_SNS_SCMD_LEN 6
  2008. #define GPN_ID_SNS_CMD_SIZE 28
  2009. #define GPN_ID_SNS_DATA_SIZE (8 + 16)
  2010. #define GNN_ID_SNS_SCMD_LEN 6
  2011. #define GNN_ID_SNS_CMD_SIZE 28
  2012. #define GNN_ID_SNS_DATA_SIZE (8 + 16)
  2013. struct sns_cmd_pkt {
  2014. union {
  2015. struct {
  2016. uint16_t buffer_length;
  2017. uint16_t reserved_1;
  2018. uint32_t buffer_address[2];
  2019. uint16_t subcommand_length;
  2020. uint16_t reserved_2;
  2021. uint16_t subcommand;
  2022. uint16_t size;
  2023. uint32_t reserved_3;
  2024. uint8_t param[36];
  2025. } cmd;
  2026. uint8_t rft_data[RFT_ID_SNS_DATA_SIZE];
  2027. uint8_t rnn_data[RNN_ID_SNS_DATA_SIZE];
  2028. uint8_t gan_data[GA_NXT_SNS_DATA_SIZE];
  2029. uint8_t gid_data[GID_PT_SNS_DATA_SIZE];
  2030. uint8_t gpn_data[GPN_ID_SNS_DATA_SIZE];
  2031. uint8_t gnn_data[GNN_ID_SNS_DATA_SIZE];
  2032. } p;
  2033. };
  2034. struct fw_blob {
  2035. char *name;
  2036. uint32_t segs[4];
  2037. const struct firmware *fw;
  2038. };
  2039. /* Return data from MBC_GET_ID_LIST call. */
  2040. struct gid_list_info {
  2041. uint8_t al_pa;
  2042. uint8_t area;
  2043. uint8_t domain;
  2044. uint8_t loop_id_2100; /* ISP2100/ISP2200 -- 4 bytes. */
  2045. uint16_t loop_id; /* ISP23XX -- 6 bytes. */
  2046. uint16_t reserved_1; /* ISP24XX -- 8 bytes. */
  2047. };
  2048. /* NPIV */
  2049. typedef struct vport_info {
  2050. uint8_t port_name[WWN_SIZE];
  2051. uint8_t node_name[WWN_SIZE];
  2052. int vp_id;
  2053. uint16_t loop_id;
  2054. unsigned long host_no;
  2055. uint8_t port_id[3];
  2056. int loop_state;
  2057. } vport_info_t;
  2058. typedef struct vport_params {
  2059. uint8_t port_name[WWN_SIZE];
  2060. uint8_t node_name[WWN_SIZE];
  2061. uint32_t options;
  2062. #define VP_OPTS_RETRY_ENABLE BIT_0
  2063. #define VP_OPTS_VP_DISABLE BIT_1
  2064. } vport_params_t;
  2065. /* NPIV - return codes of VP create and modify */
  2066. #define VP_RET_CODE_OK 0
  2067. #define VP_RET_CODE_FATAL 1
  2068. #define VP_RET_CODE_WRONG_ID 2
  2069. #define VP_RET_CODE_WWPN 3
  2070. #define VP_RET_CODE_RESOURCES 4
  2071. #define VP_RET_CODE_NO_MEM 5
  2072. #define VP_RET_CODE_NOT_FOUND 6
  2073. struct qla_hw_data;
  2074. struct rsp_que;
  2075. /*
  2076. * ISP operations
  2077. */
  2078. struct isp_operations {
  2079. int (*pci_config) (struct scsi_qla_host *);
  2080. void (*reset_chip) (struct scsi_qla_host *);
  2081. int (*chip_diag) (struct scsi_qla_host *);
  2082. void (*config_rings) (struct scsi_qla_host *);
  2083. void (*reset_adapter) (struct scsi_qla_host *);
  2084. int (*nvram_config) (struct scsi_qla_host *);
  2085. void (*update_fw_options) (struct scsi_qla_host *);
  2086. int (*load_risc) (struct scsi_qla_host *, uint32_t *);
  2087. char * (*pci_info_str) (struct scsi_qla_host *, char *);
  2088. char * (*fw_version_str) (struct scsi_qla_host *, char *);
  2089. irq_handler_t intr_handler;
  2090. void (*enable_intrs) (struct qla_hw_data *);
  2091. void (*disable_intrs) (struct qla_hw_data *);
  2092. int (*abort_command) (srb_t *);
  2093. int (*target_reset) (struct fc_port *, unsigned int, int);
  2094. int (*lun_reset) (struct fc_port *, unsigned int, int);
  2095. int (*fabric_login) (struct scsi_qla_host *, uint16_t, uint8_t,
  2096. uint8_t, uint8_t, uint16_t *, uint8_t);
  2097. int (*fabric_logout) (struct scsi_qla_host *, uint16_t, uint8_t,
  2098. uint8_t, uint8_t);
  2099. uint16_t (*calc_req_entries) (uint16_t);
  2100. void (*build_iocbs) (srb_t *, cmd_entry_t *, uint16_t);
  2101. void * (*prep_ms_iocb) (struct scsi_qla_host *, uint32_t, uint32_t);
  2102. void * (*prep_ms_fdmi_iocb) (struct scsi_qla_host *, uint32_t,
  2103. uint32_t);
  2104. uint8_t * (*read_nvram) (struct scsi_qla_host *, uint8_t *,
  2105. uint32_t, uint32_t);
  2106. int (*write_nvram) (struct scsi_qla_host *, uint8_t *, uint32_t,
  2107. uint32_t);
  2108. void (*fw_dump) (struct scsi_qla_host *, int);
  2109. int (*beacon_on) (struct scsi_qla_host *);
  2110. int (*beacon_off) (struct scsi_qla_host *);
  2111. void (*beacon_blink) (struct scsi_qla_host *);
  2112. uint8_t * (*read_optrom) (struct scsi_qla_host *, uint8_t *,
  2113. uint32_t, uint32_t);
  2114. int (*write_optrom) (struct scsi_qla_host *, uint8_t *, uint32_t,
  2115. uint32_t);
  2116. int (*get_flash_version) (struct scsi_qla_host *, void *);
  2117. int (*start_scsi) (srb_t *);
  2118. int (*abort_isp) (struct scsi_qla_host *);
  2119. int (*iospace_config)(struct qla_hw_data*);
  2120. };
  2121. /* MSI-X Support *************************************************************/
  2122. #define QLA_MSIX_CHIP_REV_24XX 3
  2123. #define QLA_MSIX_FW_MODE(m) (((m) & (BIT_7|BIT_8|BIT_9)) >> 7)
  2124. #define QLA_MSIX_FW_MODE_1(m) (QLA_MSIX_FW_MODE(m) == 1)
  2125. #define QLA_MSIX_DEFAULT 0x00
  2126. #define QLA_MSIX_RSP_Q 0x01
  2127. #define QLA_MIDX_DEFAULT 0
  2128. #define QLA_MIDX_RSP_Q 1
  2129. #define QLA_PCI_MSIX_CONTROL 0xa2
  2130. #define QLA_83XX_PCI_MSIX_CONTROL 0x92
  2131. struct scsi_qla_host;
  2132. struct qla_msix_entry {
  2133. int have_irq;
  2134. uint32_t vector;
  2135. uint16_t entry;
  2136. struct rsp_que *rsp;
  2137. };
  2138. #define WATCH_INTERVAL 1 /* number of seconds */
  2139. /* Work events. */
  2140. enum qla_work_type {
  2141. QLA_EVT_AEN,
  2142. QLA_EVT_IDC_ACK,
  2143. QLA_EVT_ASYNC_LOGIN,
  2144. QLA_EVT_ASYNC_LOGIN_DONE,
  2145. QLA_EVT_ASYNC_LOGOUT,
  2146. QLA_EVT_ASYNC_LOGOUT_DONE,
  2147. QLA_EVT_ASYNC_ADISC,
  2148. QLA_EVT_ASYNC_ADISC_DONE,
  2149. QLA_EVT_UEVENT,
  2150. };
  2151. struct qla_work_evt {
  2152. struct list_head list;
  2153. enum qla_work_type type;
  2154. u32 flags;
  2155. #define QLA_EVT_FLAG_FREE 0x1
  2156. union {
  2157. struct {
  2158. enum fc_host_event_code code;
  2159. u32 data;
  2160. } aen;
  2161. struct {
  2162. #define QLA_IDC_ACK_REGS 7
  2163. uint16_t mb[QLA_IDC_ACK_REGS];
  2164. } idc_ack;
  2165. struct {
  2166. struct fc_port *fcport;
  2167. #define QLA_LOGIO_LOGIN_RETRIED BIT_0
  2168. u16 data[2];
  2169. } logio;
  2170. struct {
  2171. u32 code;
  2172. #define QLA_UEVENT_CODE_FW_DUMP 0
  2173. } uevent;
  2174. } u;
  2175. };
  2176. struct qla_chip_state_84xx {
  2177. struct list_head list;
  2178. struct kref kref;
  2179. void *bus;
  2180. spinlock_t access_lock;
  2181. struct mutex fw_update_mutex;
  2182. uint32_t fw_update;
  2183. uint32_t op_fw_version;
  2184. uint32_t op_fw_size;
  2185. uint32_t op_fw_seq_size;
  2186. uint32_t diag_fw_version;
  2187. uint32_t gold_fw_version;
  2188. };
  2189. struct qla_statistics {
  2190. uint32_t total_isp_aborts;
  2191. uint64_t input_bytes;
  2192. uint64_t output_bytes;
  2193. };
  2194. struct bidi_statistics {
  2195. unsigned long long io_count;
  2196. unsigned long long transfer_bytes;
  2197. };
  2198. /* Multi queue support */
  2199. #define MBC_INITIALIZE_MULTIQ 0x1f
  2200. #define QLA_QUE_PAGE 0X1000
  2201. #define QLA_MQ_SIZE 32
  2202. #define QLA_MAX_QUEUES 256
  2203. #define ISP_QUE_REG(ha, id) \
  2204. ((ha->mqenable || IS_QLA83XX(ha)) ? \
  2205. ((void *)(ha->mqiobase) +\
  2206. (QLA_QUE_PAGE * id)) :\
  2207. ((void *)(ha->iobase)))
  2208. #define QLA_REQ_QUE_ID(tag) \
  2209. ((tag < QLA_MAX_QUEUES && tag > 0) ? tag : 0)
  2210. #define QLA_DEFAULT_QUE_QOS 5
  2211. #define QLA_PRECONFIG_VPORTS 32
  2212. #define QLA_MAX_VPORTS_QLA24XX 128
  2213. #define QLA_MAX_VPORTS_QLA25XX 256
  2214. /* Response queue data structure */
  2215. struct rsp_que {
  2216. dma_addr_t dma;
  2217. response_t *ring;
  2218. response_t *ring_ptr;
  2219. uint32_t __iomem *rsp_q_in; /* FWI2-capable only. */
  2220. uint32_t __iomem *rsp_q_out;
  2221. uint16_t ring_index;
  2222. uint16_t out_ptr;
  2223. uint16_t length;
  2224. uint16_t options;
  2225. uint16_t rid;
  2226. uint16_t id;
  2227. uint16_t vp_idx;
  2228. struct qla_hw_data *hw;
  2229. struct qla_msix_entry *msix;
  2230. struct req_que *req;
  2231. srb_t *status_srb; /* status continuation entry */
  2232. struct work_struct q_work;
  2233. };
  2234. /* Request queue data structure */
  2235. struct req_que {
  2236. dma_addr_t dma;
  2237. request_t *ring;
  2238. request_t *ring_ptr;
  2239. uint32_t __iomem *req_q_in; /* FWI2-capable only. */
  2240. uint32_t __iomem *req_q_out;
  2241. uint16_t ring_index;
  2242. uint16_t in_ptr;
  2243. uint16_t cnt;
  2244. uint16_t length;
  2245. uint16_t options;
  2246. uint16_t rid;
  2247. uint16_t id;
  2248. uint16_t qos;
  2249. uint16_t vp_idx;
  2250. struct rsp_que *rsp;
  2251. srb_t *outstanding_cmds[MAX_OUTSTANDING_COMMANDS];
  2252. uint32_t current_outstanding_cmd;
  2253. int max_q_depth;
  2254. };
  2255. /* Place holder for FW buffer parameters */
  2256. struct qlfc_fw {
  2257. void *fw_buf;
  2258. dma_addr_t fw_dma;
  2259. uint32_t len;
  2260. };
  2261. struct qlt_hw_data {
  2262. /* Protected by hw lock */
  2263. uint32_t enable_class_2:1;
  2264. uint32_t enable_explicit_conf:1;
  2265. uint32_t ini_mode_force_reverse:1;
  2266. uint32_t node_name_set:1;
  2267. dma_addr_t atio_dma; /* Physical address. */
  2268. struct atio *atio_ring; /* Base virtual address */
  2269. struct atio *atio_ring_ptr; /* Current address. */
  2270. uint16_t atio_ring_index; /* Current index. */
  2271. uint16_t atio_q_length;
  2272. void *target_lport_ptr;
  2273. struct qla_tgt_func_tmpl *tgt_ops;
  2274. struct qla_tgt *qla_tgt;
  2275. struct qla_tgt_cmd *cmds[MAX_OUTSTANDING_COMMANDS];
  2276. uint16_t current_handle;
  2277. struct qla_tgt_vp_map *tgt_vp_map;
  2278. struct mutex tgt_mutex;
  2279. struct mutex tgt_host_action_mutex;
  2280. int saved_set;
  2281. uint16_t saved_exchange_count;
  2282. uint32_t saved_firmware_options_1;
  2283. uint32_t saved_firmware_options_2;
  2284. uint32_t saved_firmware_options_3;
  2285. uint8_t saved_firmware_options[2];
  2286. uint8_t saved_add_firmware_options[2];
  2287. uint8_t tgt_node_name[WWN_SIZE];
  2288. };
  2289. /*
  2290. * Qlogic host adapter specific data structure.
  2291. */
  2292. struct qla_hw_data {
  2293. struct pci_dev *pdev;
  2294. /* SRB cache. */
  2295. #define SRB_MIN_REQ 128
  2296. mempool_t *srb_mempool;
  2297. volatile struct {
  2298. uint32_t mbox_int :1;
  2299. uint32_t mbox_busy :1;
  2300. uint32_t disable_risc_code_load :1;
  2301. uint32_t enable_64bit_addressing :1;
  2302. uint32_t enable_lip_reset :1;
  2303. uint32_t enable_target_reset :1;
  2304. uint32_t enable_lip_full_login :1;
  2305. uint32_t enable_led_scheme :1;
  2306. uint32_t msi_enabled :1;
  2307. uint32_t msix_enabled :1;
  2308. uint32_t disable_serdes :1;
  2309. uint32_t gpsc_supported :1;
  2310. uint32_t npiv_supported :1;
  2311. uint32_t pci_channel_io_perm_failure :1;
  2312. uint32_t fce_enabled :1;
  2313. uint32_t fac_supported :1;
  2314. uint32_t chip_reset_done :1;
  2315. uint32_t port0 :1;
  2316. uint32_t running_gold_fw :1;
  2317. uint32_t eeh_busy :1;
  2318. uint32_t cpu_affinity_enabled :1;
  2319. uint32_t disable_msix_handshake :1;
  2320. uint32_t fcp_prio_enabled :1;
  2321. uint32_t isp82xx_fw_hung:1;
  2322. uint32_t nic_core_hung:1;
  2323. uint32_t quiesce_owner:1;
  2324. uint32_t thermal_supported:1;
  2325. uint32_t nic_core_reset_hdlr_active:1;
  2326. uint32_t nic_core_reset_owner:1;
  2327. uint32_t isp82xx_no_md_cap:1;
  2328. uint32_t host_shutting_down:1;
  2329. /* 30 bits */
  2330. } flags;
  2331. /* This spinlock is used to protect "io transactions", you must
  2332. * acquire it before doing any IO to the card, eg with RD_REG*() and
  2333. * WRT_REG*() for the duration of your entire commandtransaction.
  2334. *
  2335. * This spinlock is of lower priority than the io request lock.
  2336. */
  2337. spinlock_t hardware_lock ____cacheline_aligned;
  2338. int bars;
  2339. int mem_only;
  2340. device_reg_t __iomem *iobase; /* Base I/O address */
  2341. resource_size_t pio_address;
  2342. #define MIN_IOBASE_LEN 0x100
  2343. /* Multi queue data structs */
  2344. device_reg_t __iomem *mqiobase;
  2345. device_reg_t __iomem *msixbase;
  2346. uint16_t msix_count;
  2347. uint8_t mqenable;
  2348. struct req_que **req_q_map;
  2349. struct rsp_que **rsp_q_map;
  2350. unsigned long req_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
  2351. unsigned long rsp_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
  2352. uint8_t max_req_queues;
  2353. uint8_t max_rsp_queues;
  2354. struct qla_npiv_entry *npiv_info;
  2355. uint16_t nvram_npiv_size;
  2356. uint16_t switch_cap;
  2357. #define FLOGI_SEQ_DEL BIT_8
  2358. #define FLOGI_MID_SUPPORT BIT_10
  2359. #define FLOGI_VSAN_SUPPORT BIT_12
  2360. #define FLOGI_SP_SUPPORT BIT_13
  2361. uint8_t port_no; /* Physical port of adapter */
  2362. /* Timeout timers. */
  2363. uint8_t loop_down_abort_time; /* port down timer */
  2364. atomic_t loop_down_timer; /* loop down timer */
  2365. uint8_t link_down_timeout; /* link down timeout */
  2366. uint16_t max_loop_id;
  2367. uint16_t max_fibre_devices; /* Maximum number of targets */
  2368. uint16_t fb_rev;
  2369. uint16_t min_external_loopid; /* First external loop Id */
  2370. #define PORT_SPEED_UNKNOWN 0xFFFF
  2371. #define PORT_SPEED_1GB 0x00
  2372. #define PORT_SPEED_2GB 0x01
  2373. #define PORT_SPEED_4GB 0x03
  2374. #define PORT_SPEED_8GB 0x04
  2375. #define PORT_SPEED_16GB 0x05
  2376. #define PORT_SPEED_10GB 0x13
  2377. uint16_t link_data_rate; /* F/W operating speed */
  2378. uint8_t current_topology;
  2379. uint8_t prev_topology;
  2380. #define ISP_CFG_NL 1
  2381. #define ISP_CFG_N 2
  2382. #define ISP_CFG_FL 4
  2383. #define ISP_CFG_F 8
  2384. uint8_t operating_mode; /* F/W operating mode */
  2385. #define LOOP 0
  2386. #define P2P 1
  2387. #define LOOP_P2P 2
  2388. #define P2P_LOOP 3
  2389. uint8_t interrupts_on;
  2390. uint32_t isp_abort_cnt;
  2391. #define PCI_DEVICE_ID_QLOGIC_ISP2532 0x2532
  2392. #define PCI_DEVICE_ID_QLOGIC_ISP8432 0x8432
  2393. #define PCI_DEVICE_ID_QLOGIC_ISP8001 0x8001
  2394. #define PCI_DEVICE_ID_QLOGIC_ISP8031 0x8031
  2395. #define PCI_DEVICE_ID_QLOGIC_ISP2031 0x2031
  2396. uint32_t device_type;
  2397. #define DT_ISP2100 BIT_0
  2398. #define DT_ISP2200 BIT_1
  2399. #define DT_ISP2300 BIT_2
  2400. #define DT_ISP2312 BIT_3
  2401. #define DT_ISP2322 BIT_4
  2402. #define DT_ISP6312 BIT_5
  2403. #define DT_ISP6322 BIT_6
  2404. #define DT_ISP2422 BIT_7
  2405. #define DT_ISP2432 BIT_8
  2406. #define DT_ISP5422 BIT_9
  2407. #define DT_ISP5432 BIT_10
  2408. #define DT_ISP2532 BIT_11
  2409. #define DT_ISP8432 BIT_12
  2410. #define DT_ISP8001 BIT_13
  2411. #define DT_ISP8021 BIT_14
  2412. #define DT_ISP2031 BIT_15
  2413. #define DT_ISP8031 BIT_16
  2414. #define DT_ISP_LAST (DT_ISP8031 << 1)
  2415. #define DT_T10_PI BIT_25
  2416. #define DT_IIDMA BIT_26
  2417. #define DT_FWI2 BIT_27
  2418. #define DT_ZIO_SUPPORTED BIT_28
  2419. #define DT_OEM_001 BIT_29
  2420. #define DT_ISP2200A BIT_30
  2421. #define DT_EXTENDED_IDS BIT_31
  2422. #define DT_MASK(ha) ((ha)->device_type & (DT_ISP_LAST - 1))
  2423. #define IS_QLA2100(ha) (DT_MASK(ha) & DT_ISP2100)
  2424. #define IS_QLA2200(ha) (DT_MASK(ha) & DT_ISP2200)
  2425. #define IS_QLA2300(ha) (DT_MASK(ha) & DT_ISP2300)
  2426. #define IS_QLA2312(ha) (DT_MASK(ha) & DT_ISP2312)
  2427. #define IS_QLA2322(ha) (DT_MASK(ha) & DT_ISP2322)
  2428. #define IS_QLA6312(ha) (DT_MASK(ha) & DT_ISP6312)
  2429. #define IS_QLA6322(ha) (DT_MASK(ha) & DT_ISP6322)
  2430. #define IS_QLA2422(ha) (DT_MASK(ha) & DT_ISP2422)
  2431. #define IS_QLA2432(ha) (DT_MASK(ha) & DT_ISP2432)
  2432. #define IS_QLA5422(ha) (DT_MASK(ha) & DT_ISP5422)
  2433. #define IS_QLA5432(ha) (DT_MASK(ha) & DT_ISP5432)
  2434. #define IS_QLA2532(ha) (DT_MASK(ha) & DT_ISP2532)
  2435. #define IS_QLA8432(ha) (DT_MASK(ha) & DT_ISP8432)
  2436. #define IS_QLA8001(ha) (DT_MASK(ha) & DT_ISP8001)
  2437. #define IS_QLA81XX(ha) (IS_QLA8001(ha))
  2438. #define IS_QLA82XX(ha) (DT_MASK(ha) & DT_ISP8021)
  2439. #define IS_QLA2031(ha) (DT_MASK(ha) & DT_ISP2031)
  2440. #define IS_QLA8031(ha) (DT_MASK(ha) & DT_ISP8031)
  2441. #define IS_QLA23XX(ha) (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \
  2442. IS_QLA6312(ha) || IS_QLA6322(ha))
  2443. #define IS_QLA24XX(ha) (IS_QLA2422(ha) || IS_QLA2432(ha))
  2444. #define IS_QLA54XX(ha) (IS_QLA5422(ha) || IS_QLA5432(ha))
  2445. #define IS_QLA25XX(ha) (IS_QLA2532(ha))
  2446. #define IS_QLA83XX(ha) (IS_QLA2031(ha) || IS_QLA8031(ha))
  2447. #define IS_QLA84XX(ha) (IS_QLA8432(ha))
  2448. #define IS_QLA24XX_TYPE(ha) (IS_QLA24XX(ha) || IS_QLA54XX(ha) || \
  2449. IS_QLA84XX(ha))
  2450. #define IS_CNA_CAPABLE(ha) (IS_QLA81XX(ha) || IS_QLA82XX(ha) || \
  2451. IS_QLA8031(ha))
  2452. #define IS_QLA2XXX_MIDTYPE(ha) (IS_QLA24XX(ha) || IS_QLA84XX(ha) || \
  2453. IS_QLA25XX(ha) || IS_QLA81XX(ha) || \
  2454. IS_QLA82XX(ha) || IS_QLA83XX(ha))
  2455. #define IS_MSIX_NACK_CAPABLE(ha) (IS_QLA81XX(ha) || IS_QLA83XX(ha))
  2456. #define IS_NOPOLLING_TYPE(ha) ((IS_QLA25XX(ha) || IS_QLA81XX(ha) || \
  2457. IS_QLA83XX(ha)) && (ha)->flags.msix_enabled)
  2458. #define IS_FAC_REQUIRED(ha) (IS_QLA81XX(ha) || IS_QLA83XX(ha))
  2459. #define IS_NOCACHE_VPD_TYPE(ha) (IS_QLA81XX(ha) || IS_QLA83XX(ha))
  2460. #define IS_ALOGIO_CAPABLE(ha) (IS_QLA23XX(ha) || IS_FWI2_CAPABLE(ha))
  2461. #define IS_T10_PI_CAPABLE(ha) ((ha)->device_type & DT_T10_PI)
  2462. #define IS_IIDMA_CAPABLE(ha) ((ha)->device_type & DT_IIDMA)
  2463. #define IS_FWI2_CAPABLE(ha) ((ha)->device_type & DT_FWI2)
  2464. #define IS_ZIO_SUPPORTED(ha) ((ha)->device_type & DT_ZIO_SUPPORTED)
  2465. #define IS_OEM_001(ha) ((ha)->device_type & DT_OEM_001)
  2466. #define HAS_EXTENDED_IDS(ha) ((ha)->device_type & DT_EXTENDED_IDS)
  2467. #define IS_CT6_SUPPORTED(ha) ((ha)->device_type & DT_CT6_SUPPORTED)
  2468. #define IS_MQUE_CAPABLE(ha) ((ha)->mqenable || IS_QLA83XX(ha))
  2469. #define IS_BIDI_CAPABLE(ha) ((IS_QLA25XX(ha) || IS_QLA2031(ha)))
  2470. /* HBA serial number */
  2471. uint8_t serial0;
  2472. uint8_t serial1;
  2473. uint8_t serial2;
  2474. /* NVRAM configuration data */
  2475. #define MAX_NVRAM_SIZE 4096
  2476. #define VPD_OFFSET MAX_NVRAM_SIZE / 2
  2477. uint16_t nvram_size;
  2478. uint16_t nvram_base;
  2479. void *nvram;
  2480. uint16_t vpd_size;
  2481. uint16_t vpd_base;
  2482. void *vpd;
  2483. uint16_t loop_reset_delay;
  2484. uint8_t retry_count;
  2485. uint8_t login_timeout;
  2486. uint16_t r_a_tov;
  2487. int port_down_retry_count;
  2488. uint8_t mbx_count;
  2489. uint32_t login_retry_count;
  2490. /* SNS command interfaces. */
  2491. ms_iocb_entry_t *ms_iocb;
  2492. dma_addr_t ms_iocb_dma;
  2493. struct ct_sns_pkt *ct_sns;
  2494. dma_addr_t ct_sns_dma;
  2495. /* SNS command interfaces for 2200. */
  2496. struct sns_cmd_pkt *sns_cmd;
  2497. dma_addr_t sns_cmd_dma;
  2498. #define SFP_DEV_SIZE 256
  2499. #define SFP_BLOCK_SIZE 64
  2500. void *sfp_data;
  2501. dma_addr_t sfp_data_dma;
  2502. #define XGMAC_DATA_SIZE 4096
  2503. void *xgmac_data;
  2504. dma_addr_t xgmac_data_dma;
  2505. #define DCBX_TLV_DATA_SIZE 4096
  2506. void *dcbx_tlv;
  2507. dma_addr_t dcbx_tlv_dma;
  2508. struct task_struct *dpc_thread;
  2509. uint8_t dpc_active; /* DPC routine is active */
  2510. dma_addr_t gid_list_dma;
  2511. struct gid_list_info *gid_list;
  2512. int gid_list_info_size;
  2513. /* Small DMA pool allocations -- maximum 256 bytes in length. */
  2514. #define DMA_POOL_SIZE 256
  2515. struct dma_pool *s_dma_pool;
  2516. dma_addr_t init_cb_dma;
  2517. init_cb_t *init_cb;
  2518. int init_cb_size;
  2519. dma_addr_t ex_init_cb_dma;
  2520. struct ex_init_cb_81xx *ex_init_cb;
  2521. void *async_pd;
  2522. dma_addr_t async_pd_dma;
  2523. void *swl;
  2524. /* These are used by mailbox operations. */
  2525. volatile uint16_t mailbox_out[MAILBOX_REGISTER_COUNT];
  2526. mbx_cmd_t *mcp;
  2527. unsigned long mbx_cmd_flags;
  2528. #define MBX_INTERRUPT 1
  2529. #define MBX_INTR_WAIT 2
  2530. #define MBX_UPDATE_FLASH_ACTIVE 3
  2531. struct mutex vport_lock; /* Virtual port synchronization */
  2532. spinlock_t vport_slock; /* order is hardware_lock, then vport_slock */
  2533. struct completion mbx_cmd_comp; /* Serialize mbx access */
  2534. struct completion mbx_intr_comp; /* Used for completion notification */
  2535. struct completion dcbx_comp; /* For set port config notification */
  2536. int notify_dcbx_comp;
  2537. struct mutex selflogin_lock;
  2538. /* Basic firmware related information. */
  2539. uint16_t fw_major_version;
  2540. uint16_t fw_minor_version;
  2541. uint16_t fw_subminor_version;
  2542. uint16_t fw_attributes;
  2543. uint16_t fw_attributes_h;
  2544. uint16_t fw_attributes_ext[2];
  2545. uint32_t fw_memory_size;
  2546. uint32_t fw_transfer_size;
  2547. uint32_t fw_srisc_address;
  2548. #define RISC_START_ADDRESS_2100 0x1000
  2549. #define RISC_START_ADDRESS_2300 0x800
  2550. #define RISC_START_ADDRESS_2400 0x100000
  2551. uint16_t fw_xcb_count;
  2552. uint16_t fw_options[16]; /* slots: 1,2,3,10,11 */
  2553. uint8_t fw_seriallink_options[4];
  2554. uint16_t fw_seriallink_options24[4];
  2555. uint8_t mpi_version[3];
  2556. uint32_t mpi_capabilities;
  2557. uint8_t phy_version[3];
  2558. /* Firmware dump information. */
  2559. struct qla2xxx_fw_dump *fw_dump;
  2560. uint32_t fw_dump_len;
  2561. int fw_dumped;
  2562. int fw_dump_reading;
  2563. dma_addr_t eft_dma;
  2564. void *eft;
  2565. uint32_t chain_offset;
  2566. struct dentry *dfs_dir;
  2567. struct dentry *dfs_fce;
  2568. dma_addr_t fce_dma;
  2569. void *fce;
  2570. uint32_t fce_bufs;
  2571. uint16_t fce_mb[8];
  2572. uint64_t fce_wr, fce_rd;
  2573. struct mutex fce_mutex;
  2574. uint32_t pci_attr;
  2575. uint16_t chip_revision;
  2576. uint16_t product_id[4];
  2577. uint8_t model_number[16+1];
  2578. #define BINZERO "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
  2579. char model_desc[80];
  2580. uint8_t adapter_id[16+1];
  2581. /* Option ROM information. */
  2582. char *optrom_buffer;
  2583. uint32_t optrom_size;
  2584. int optrom_state;
  2585. #define QLA_SWAITING 0
  2586. #define QLA_SREADING 1
  2587. #define QLA_SWRITING 2
  2588. uint32_t optrom_region_start;
  2589. uint32_t optrom_region_size;
  2590. /* PCI expansion ROM image information. */
  2591. #define ROM_CODE_TYPE_BIOS 0
  2592. #define ROM_CODE_TYPE_FCODE 1
  2593. #define ROM_CODE_TYPE_EFI 3
  2594. uint8_t bios_revision[2];
  2595. uint8_t efi_revision[2];
  2596. uint8_t fcode_revision[16];
  2597. uint32_t fw_revision[4];
  2598. uint32_t gold_fw_version[4];
  2599. /* Offsets for flash/nvram access (set to ~0 if not used). */
  2600. uint32_t flash_conf_off;
  2601. uint32_t flash_data_off;
  2602. uint32_t nvram_conf_off;
  2603. uint32_t nvram_data_off;
  2604. uint32_t fdt_wrt_disable;
  2605. uint32_t fdt_erase_cmd;
  2606. uint32_t fdt_block_size;
  2607. uint32_t fdt_unprotect_sec_cmd;
  2608. uint32_t fdt_protect_sec_cmd;
  2609. uint32_t flt_region_flt;
  2610. uint32_t flt_region_fdt;
  2611. uint32_t flt_region_boot;
  2612. uint32_t flt_region_fw;
  2613. uint32_t flt_region_vpd_nvram;
  2614. uint32_t flt_region_vpd;
  2615. uint32_t flt_region_nvram;
  2616. uint32_t flt_region_npiv_conf;
  2617. uint32_t flt_region_gold_fw;
  2618. uint32_t flt_region_fcp_prio;
  2619. uint32_t flt_region_bootload;
  2620. /* Needed for BEACON */
  2621. uint16_t beacon_blink_led;
  2622. uint8_t beacon_color_state;
  2623. #define QLA_LED_GRN_ON 0x01
  2624. #define QLA_LED_YLW_ON 0x02
  2625. #define QLA_LED_ABR_ON 0x04
  2626. #define QLA_LED_ALL_ON 0x07 /* yellow, green, amber. */
  2627. /* ISP2322: red, green, amber. */
  2628. uint16_t zio_mode;
  2629. uint16_t zio_timer;
  2630. struct qla_msix_entry *msix_entries;
  2631. struct list_head vp_list; /* list of VP */
  2632. unsigned long vp_idx_map[(MAX_MULTI_ID_FABRIC / 8) /
  2633. sizeof(unsigned long)];
  2634. uint16_t num_vhosts; /* number of vports created */
  2635. uint16_t num_vsans; /* number of vsan created */
  2636. uint16_t max_npiv_vports; /* 63 or 125 per topoloty */
  2637. int cur_vport_count;
  2638. struct qla_chip_state_84xx *cs84xx;
  2639. struct isp_operations *isp_ops;
  2640. struct workqueue_struct *wq;
  2641. struct qlfc_fw fw_buf;
  2642. /* FCP_CMND priority support */
  2643. struct qla_fcp_prio_cfg *fcp_prio_cfg;
  2644. struct dma_pool *dl_dma_pool;
  2645. #define DSD_LIST_DMA_POOL_SIZE 512
  2646. struct dma_pool *fcp_cmnd_dma_pool;
  2647. mempool_t *ctx_mempool;
  2648. #define FCP_CMND_DMA_POOL_SIZE 512
  2649. unsigned long nx_pcibase; /* Base I/O address */
  2650. uint8_t *nxdb_rd_ptr; /* Doorbell read pointer */
  2651. unsigned long nxdb_wr_ptr; /* Door bell write pointer */
  2652. uint32_t crb_win;
  2653. uint32_t curr_window;
  2654. uint32_t ddr_mn_window;
  2655. unsigned long mn_win_crb;
  2656. unsigned long ms_win_crb;
  2657. int qdr_sn_window;
  2658. uint32_t fcoe_dev_init_timeout;
  2659. uint32_t fcoe_reset_timeout;
  2660. rwlock_t hw_lock;
  2661. uint16_t portnum; /* port number */
  2662. int link_width;
  2663. struct fw_blob *hablob;
  2664. struct qla82xx_legacy_intr_set nx_legacy_intr;
  2665. uint16_t gbl_dsd_inuse;
  2666. uint16_t gbl_dsd_avail;
  2667. struct list_head gbl_dsd_list;
  2668. #define NUM_DSD_CHAIN 4096
  2669. uint8_t fw_type;
  2670. __le32 file_prd_off; /* File firmware product offset */
  2671. uint32_t md_template_size;
  2672. void *md_tmplt_hdr;
  2673. dma_addr_t md_tmplt_hdr_dma;
  2674. void *md_dump;
  2675. uint32_t md_dump_size;
  2676. void *loop_id_map;
  2677. /* QLA83XX IDC specific fields */
  2678. uint32_t idc_audit_ts;
  2679. /* DPC low-priority workqueue */
  2680. struct workqueue_struct *dpc_lp_wq;
  2681. struct work_struct idc_aen;
  2682. /* DPC high-priority workqueue */
  2683. struct workqueue_struct *dpc_hp_wq;
  2684. struct work_struct nic_core_reset;
  2685. struct work_struct idc_state_handler;
  2686. struct work_struct nic_core_unrecoverable;
  2687. struct qlt_hw_data tgt;
  2688. };
  2689. /*
  2690. * Qlogic scsi host structure
  2691. */
  2692. typedef struct scsi_qla_host {
  2693. struct list_head list;
  2694. struct list_head vp_fcports; /* list of fcports */
  2695. struct list_head work_list;
  2696. spinlock_t work_lock;
  2697. /* Commonly used flags and state information. */
  2698. struct Scsi_Host *host;
  2699. unsigned long host_no;
  2700. uint8_t host_str[16];
  2701. volatile struct {
  2702. uint32_t init_done :1;
  2703. uint32_t online :1;
  2704. uint32_t reset_active :1;
  2705. uint32_t management_server_logged_in :1;
  2706. uint32_t process_response_queue :1;
  2707. uint32_t difdix_supported:1;
  2708. uint32_t delete_progress:1;
  2709. } flags;
  2710. atomic_t loop_state;
  2711. #define LOOP_TIMEOUT 1
  2712. #define LOOP_DOWN 2
  2713. #define LOOP_UP 3
  2714. #define LOOP_UPDATE 4
  2715. #define LOOP_READY 5
  2716. #define LOOP_DEAD 6
  2717. unsigned long dpc_flags;
  2718. #define RESET_MARKER_NEEDED 0 /* Send marker to ISP. */
  2719. #define RESET_ACTIVE 1
  2720. #define ISP_ABORT_NEEDED 2 /* Initiate ISP abort. */
  2721. #define ABORT_ISP_ACTIVE 3 /* ISP abort in progress. */
  2722. #define LOOP_RESYNC_NEEDED 4 /* Device Resync needed. */
  2723. #define LOOP_RESYNC_ACTIVE 5
  2724. #define LOCAL_LOOP_UPDATE 6 /* Perform a local loop update. */
  2725. #define RSCN_UPDATE 7 /* Perform an RSCN update. */
  2726. #define RELOGIN_NEEDED 8
  2727. #define REGISTER_FC4_NEEDED 9 /* SNS FC4 registration required. */
  2728. #define ISP_ABORT_RETRY 10 /* ISP aborted. */
  2729. #define BEACON_BLINK_NEEDED 11
  2730. #define REGISTER_FDMI_NEEDED 12
  2731. #define FCPORT_UPDATE_NEEDED 13
  2732. #define VP_DPC_NEEDED 14 /* wake up for VP dpc handling */
  2733. #define UNLOADING 15
  2734. #define NPIV_CONFIG_NEEDED 16
  2735. #define ISP_UNRECOVERABLE 17
  2736. #define FCOE_CTX_RESET_NEEDED 18 /* Initiate FCoE context reset */
  2737. #define MPI_RESET_NEEDED 19 /* Initiate MPI FW reset */
  2738. #define ISP_QUIESCE_NEEDED 20 /* Driver need some quiescence */
  2739. #define SCR_PENDING 21 /* SCR in target mode */
  2740. uint32_t device_flags;
  2741. #define SWITCH_FOUND BIT_0
  2742. #define DFLG_NO_CABLE BIT_1
  2743. #define DFLG_DEV_FAILED BIT_5
  2744. /* ISP configuration data. */
  2745. uint16_t loop_id; /* Host adapter loop id */
  2746. uint16_t self_login_loop_id; /* host adapter loop id
  2747. * get it on self login
  2748. */
  2749. fc_port_t bidir_fcport; /* fcport used for bidir cmnds
  2750. * no need of allocating it for
  2751. * each command
  2752. */
  2753. port_id_t d_id; /* Host adapter port id */
  2754. uint8_t marker_needed;
  2755. uint16_t mgmt_svr_loop_id;
  2756. /* Timeout timers. */
  2757. uint8_t loop_down_abort_time; /* port down timer */
  2758. atomic_t loop_down_timer; /* loop down timer */
  2759. uint8_t link_down_timeout; /* link down timeout */
  2760. uint32_t timer_active;
  2761. struct timer_list timer;
  2762. uint8_t node_name[WWN_SIZE];
  2763. uint8_t port_name[WWN_SIZE];
  2764. uint8_t fabric_node_name[WWN_SIZE];
  2765. uint16_t fcoe_vlan_id;
  2766. uint16_t fcoe_fcf_idx;
  2767. uint8_t fcoe_vn_port_mac[6];
  2768. uint32_t vp_abort_cnt;
  2769. struct fc_vport *fc_vport; /* holds fc_vport * for each vport */
  2770. uint16_t vp_idx; /* vport ID */
  2771. unsigned long vp_flags;
  2772. #define VP_IDX_ACQUIRED 0 /* bit no 0 */
  2773. #define VP_CREATE_NEEDED 1
  2774. #define VP_BIND_NEEDED 2
  2775. #define VP_DELETE_NEEDED 3
  2776. #define VP_SCR_NEEDED 4 /* State Change Request registration */
  2777. atomic_t vp_state;
  2778. #define VP_OFFLINE 0
  2779. #define VP_ACTIVE 1
  2780. #define VP_FAILED 2
  2781. // #define VP_DISABLE 3
  2782. uint16_t vp_err_state;
  2783. uint16_t vp_prev_err_state;
  2784. #define VP_ERR_UNKWN 0
  2785. #define VP_ERR_PORTDWN 1
  2786. #define VP_ERR_FAB_UNSUPPORTED 2
  2787. #define VP_ERR_FAB_NORESOURCES 3
  2788. #define VP_ERR_FAB_LOGOUT 4
  2789. #define VP_ERR_ADAP_NORESOURCES 5
  2790. struct qla_hw_data *hw;
  2791. struct req_que *req;
  2792. int fw_heartbeat_counter;
  2793. int seconds_since_last_heartbeat;
  2794. struct fc_host_statistics fc_host_stat;
  2795. struct qla_statistics qla_stats;
  2796. struct bidi_statistics bidi_stats;
  2797. atomic_t vref_count;
  2798. } scsi_qla_host_t;
  2799. #define SET_VP_IDX 1
  2800. #define SET_AL_PA 2
  2801. #define RESET_VP_IDX 3
  2802. #define RESET_AL_PA 4
  2803. struct qla_tgt_vp_map {
  2804. uint8_t idx;
  2805. scsi_qla_host_t *vha;
  2806. };
  2807. /*
  2808. * Macros to help code, maintain, etc.
  2809. */
  2810. #define LOOP_TRANSITION(ha) \
  2811. (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \
  2812. test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) || \
  2813. atomic_read(&ha->loop_state) == LOOP_DOWN)
  2814. #define QLA_VHA_MARK_BUSY(__vha, __bail) do { \
  2815. atomic_inc(&__vha->vref_count); \
  2816. mb(); \
  2817. if (__vha->flags.delete_progress) { \
  2818. atomic_dec(&__vha->vref_count); \
  2819. __bail = 1; \
  2820. } else { \
  2821. __bail = 0; \
  2822. } \
  2823. } while (0)
  2824. #define QLA_VHA_MARK_NOT_BUSY(__vha) do { \
  2825. atomic_dec(&__vha->vref_count); \
  2826. } while (0)
  2827. /*
  2828. * qla2x00 local function return status codes
  2829. */
  2830. #define MBS_MASK 0x3fff
  2831. #define QLA_SUCCESS (MBS_COMMAND_COMPLETE & MBS_MASK)
  2832. #define QLA_INVALID_COMMAND (MBS_INVALID_COMMAND & MBS_MASK)
  2833. #define QLA_INTERFACE_ERROR (MBS_HOST_INTERFACE_ERROR & MBS_MASK)
  2834. #define QLA_TEST_FAILED (MBS_TEST_FAILED & MBS_MASK)
  2835. #define QLA_COMMAND_ERROR (MBS_COMMAND_ERROR & MBS_MASK)
  2836. #define QLA_PARAMETER_ERROR (MBS_COMMAND_PARAMETER_ERROR & MBS_MASK)
  2837. #define QLA_PORT_ID_USED (MBS_PORT_ID_USED & MBS_MASK)
  2838. #define QLA_LOOP_ID_USED (MBS_LOOP_ID_USED & MBS_MASK)
  2839. #define QLA_ALL_IDS_IN_USE (MBS_ALL_IDS_IN_USE & MBS_MASK)
  2840. #define QLA_NOT_LOGGED_IN (MBS_NOT_LOGGED_IN & MBS_MASK)
  2841. #define QLA_FUNCTION_TIMEOUT 0x100
  2842. #define QLA_FUNCTION_PARAMETER_ERROR 0x101
  2843. #define QLA_FUNCTION_FAILED 0x102
  2844. #define QLA_MEMORY_ALLOC_FAILED 0x103
  2845. #define QLA_LOCK_TIMEOUT 0x104
  2846. #define QLA_ABORTED 0x105
  2847. #define QLA_SUSPENDED 0x106
  2848. #define QLA_BUSY 0x107
  2849. #define QLA_ALREADY_REGISTERED 0x109
  2850. #define NVRAM_DELAY() udelay(10)
  2851. #define INVALID_HANDLE (MAX_OUTSTANDING_COMMANDS+1)
  2852. /*
  2853. * Flash support definitions
  2854. */
  2855. #define OPTROM_SIZE_2300 0x20000
  2856. #define OPTROM_SIZE_2322 0x100000
  2857. #define OPTROM_SIZE_24XX 0x100000
  2858. #define OPTROM_SIZE_25XX 0x200000
  2859. #define OPTROM_SIZE_81XX 0x400000
  2860. #define OPTROM_SIZE_82XX 0x800000
  2861. #define OPTROM_SIZE_83XX 0x1000000
  2862. #define OPTROM_BURST_SIZE 0x1000
  2863. #define OPTROM_BURST_DWORDS (OPTROM_BURST_SIZE / 4)
  2864. #define QLA_DSDS_PER_IOCB 37
  2865. #define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr)
  2866. #define QLA_SG_ALL 1024
  2867. enum nexus_wait_type {
  2868. WAIT_HOST = 0,
  2869. WAIT_TARGET,
  2870. WAIT_LUN,
  2871. };
  2872. #include "qla_gbl.h"
  2873. #include "qla_dbg.h"
  2874. #include "qla_inline.h"
  2875. #endif