qla_def.h 143 KB

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