qla_def.h 103 KB

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