qla_def.h 125 KB

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