qla_def.h 125 KB

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