qla_def.h 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359
  1. /********************************************************************************
  2. * QLOGIC LINUX SOFTWARE
  3. *
  4. * QLogic ISP2x00 device driver for Linux 2.6.x
  5. * Copyright (C) 2003-2004 QLogic Corporation
  6. * (www.qlogic.com)
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2, or (at your option) any
  11. * later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. **
  18. ******************************************************************************/
  19. #ifndef __QLA_DEF_H
  20. #define __QLA_DEF_H
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <linux/types.h>
  24. #include <linux/module.h>
  25. #include <linux/list.h>
  26. #include <linux/pci.h>
  27. #include <linux/dma-mapping.h>
  28. #include <linux/sched.h>
  29. #include <linux/slab.h>
  30. #include <linux/dmapool.h>
  31. #include <linux/mempool.h>
  32. #include <linux/spinlock.h>
  33. #include <linux/completion.h>
  34. #include <linux/interrupt.h>
  35. #include <asm/semaphore.h>
  36. #include <scsi/scsi.h>
  37. #include <scsi/scsi_host.h>
  38. #include <scsi/scsi_device.h>
  39. #include <scsi/scsi_cmnd.h>
  40. /* XXX(hch): move to pci_ids.h */
  41. #ifndef PCI_DEVICE_ID_QLOGIC_ISP2300
  42. #define PCI_DEVICE_ID_QLOGIC_ISP2300 0x2300
  43. #endif
  44. #ifndef PCI_DEVICE_ID_QLOGIC_ISP2312
  45. #define PCI_DEVICE_ID_QLOGIC_ISP2312 0x2312
  46. #endif
  47. #ifndef PCI_DEVICE_ID_QLOGIC_ISP2322
  48. #define PCI_DEVICE_ID_QLOGIC_ISP2322 0x2322
  49. #endif
  50. #ifndef PCI_DEVICE_ID_QLOGIC_ISP6312
  51. #define PCI_DEVICE_ID_QLOGIC_ISP6312 0x6312
  52. #endif
  53. #ifndef PCI_DEVICE_ID_QLOGIC_ISP6322
  54. #define PCI_DEVICE_ID_QLOGIC_ISP6322 0x6322
  55. #endif
  56. #if defined(CONFIG_SCSI_QLA21XX) || defined(CONFIG_SCSI_QLA21XX_MODULE)
  57. #define IS_QLA2100(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2100)
  58. #else
  59. #define IS_QLA2100(ha) 0
  60. #endif
  61. #if defined(CONFIG_SCSI_QLA22XX) || defined(CONFIG_SCSI_QLA22XX_MODULE)
  62. #define IS_QLA2200(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2200)
  63. #else
  64. #define IS_QLA2200(ha) 0
  65. #endif
  66. #if defined(CONFIG_SCSI_QLA2300) || defined(CONFIG_SCSI_QLA2300_MODULE)
  67. #define IS_QLA2300(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2300)
  68. #define IS_QLA2312(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2312)
  69. #else
  70. #define IS_QLA2300(ha) 0
  71. #define IS_QLA2312(ha) 0
  72. #endif
  73. #if defined(CONFIG_SCSI_QLA2322) || defined(CONFIG_SCSI_QLA2322_MODULE)
  74. #define IS_QLA2322(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2322)
  75. #else
  76. #define IS_QLA2322(ha) 0
  77. #endif
  78. #if defined(CONFIG_SCSI_QLA6312) || defined(CONFIG_SCSI_QLA6312_MODULE)
  79. #define IS_QLA6312(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP6312)
  80. #define IS_QLA6322(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP6322)
  81. #else
  82. #define IS_QLA6312(ha) 0
  83. #define IS_QLA6322(ha) 0
  84. #endif
  85. #define IS_QLA23XX(ha) (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \
  86. IS_QLA6312(ha) || IS_QLA6322(ha))
  87. /*
  88. * Only non-ISP2[12]00 have extended addressing support in the firmware.
  89. */
  90. #define HAS_EXTENDED_IDS(ha) (!IS_QLA2100(ha) && !IS_QLA2200(ha))
  91. /*
  92. * We have MAILBOX_REGISTER_COUNT sized arrays in a few places,
  93. * but that's fine as we don't look at the last 24 ones for
  94. * ISP2100 HBAs.
  95. */
  96. #define MAILBOX_REGISTER_COUNT_2100 8
  97. #define MAILBOX_REGISTER_COUNT 32
  98. #define QLA2200A_RISC_ROM_VER 4
  99. #define FPM_2300 6
  100. #define FPM_2310 7
  101. #include "qla_settings.h"
  102. /*
  103. * Data bit definitions
  104. */
  105. #define BIT_0 0x1
  106. #define BIT_1 0x2
  107. #define BIT_2 0x4
  108. #define BIT_3 0x8
  109. #define BIT_4 0x10
  110. #define BIT_5 0x20
  111. #define BIT_6 0x40
  112. #define BIT_7 0x80
  113. #define BIT_8 0x100
  114. #define BIT_9 0x200
  115. #define BIT_10 0x400
  116. #define BIT_11 0x800
  117. #define BIT_12 0x1000
  118. #define BIT_13 0x2000
  119. #define BIT_14 0x4000
  120. #define BIT_15 0x8000
  121. #define BIT_16 0x10000
  122. #define BIT_17 0x20000
  123. #define BIT_18 0x40000
  124. #define BIT_19 0x80000
  125. #define BIT_20 0x100000
  126. #define BIT_21 0x200000
  127. #define BIT_22 0x400000
  128. #define BIT_23 0x800000
  129. #define BIT_24 0x1000000
  130. #define BIT_25 0x2000000
  131. #define BIT_26 0x4000000
  132. #define BIT_27 0x8000000
  133. #define BIT_28 0x10000000
  134. #define BIT_29 0x20000000
  135. #define BIT_30 0x40000000
  136. #define BIT_31 0x80000000
  137. #define LSB(x) ((uint8_t)(x))
  138. #define MSB(x) ((uint8_t)((uint16_t)(x) >> 8))
  139. #define LSW(x) ((uint16_t)(x))
  140. #define MSW(x) ((uint16_t)((uint32_t)(x) >> 16))
  141. #define LSD(x) ((uint32_t)((uint64_t)(x)))
  142. #define MSD(x) ((uint32_t)((((uint64_t)(x)) >> 16) >> 16))
  143. /*
  144. * I/O register
  145. */
  146. #define RD_REG_BYTE(addr) readb(addr)
  147. #define RD_REG_WORD(addr) readw(addr)
  148. #define RD_REG_DWORD(addr) readl(addr)
  149. #define RD_REG_BYTE_RELAXED(addr) readb_relaxed(addr)
  150. #define RD_REG_WORD_RELAXED(addr) readw_relaxed(addr)
  151. #define RD_REG_DWORD_RELAXED(addr) readl_relaxed(addr)
  152. #define WRT_REG_BYTE(addr, data) writeb(data,addr)
  153. #define WRT_REG_WORD(addr, data) writew(data,addr)
  154. #define WRT_REG_DWORD(addr, data) writel(data,addr)
  155. /*
  156. * Fibre Channel device definitions.
  157. */
  158. #define WWN_SIZE 8 /* Size of WWPN, WWN & WWNN */
  159. #define MAX_FIBRE_DEVICES 512
  160. #define MAX_FIBRE_LUNS 256
  161. #define MAX_RSCN_COUNT 32
  162. #define MAX_HOST_COUNT 16
  163. /*
  164. * Host adapter default definitions.
  165. */
  166. #define MAX_BUSES 1 /* We only have one bus today */
  167. #define MAX_TARGETS_2100 MAX_FIBRE_DEVICES
  168. #define MAX_TARGETS_2200 MAX_FIBRE_DEVICES
  169. #define MAX_TARGETS MAX_FIBRE_DEVICES
  170. #define MIN_LUNS 8
  171. #define MAX_LUNS MAX_FIBRE_LUNS
  172. #define MAX_CMDS_PER_LUN 255
  173. /*
  174. * Fibre Channel device definitions.
  175. */
  176. #define SNS_LAST_LOOP_ID_2100 0xfe
  177. #define SNS_LAST_LOOP_ID_2300 0x7ff
  178. #define LAST_LOCAL_LOOP_ID 0x7d
  179. #define SNS_FL_PORT 0x7e
  180. #define FABRIC_CONTROLLER 0x7f
  181. #define SIMPLE_NAME_SERVER 0x80
  182. #define SNS_FIRST_LOOP_ID 0x81
  183. #define MANAGEMENT_SERVER 0xfe
  184. #define BROADCAST 0xff
  185. #define RESERVED_LOOP_ID(x) ((x > LAST_LOCAL_LOOP_ID && \
  186. x < SNS_FIRST_LOOP_ID) || \
  187. x == MANAGEMENT_SERVER || \
  188. x == BROADCAST)
  189. /*
  190. * Timeout timer counts in seconds
  191. */
  192. #define PORT_RETRY_TIME 1
  193. #define LOOP_DOWN_TIMEOUT 60
  194. #define LOOP_DOWN_TIME 255 /* 240 */
  195. #define LOOP_DOWN_RESET (LOOP_DOWN_TIME - 30)
  196. /* Maximum outstanding commands in ISP queues (1-65535) */
  197. #define MAX_OUTSTANDING_COMMANDS 1024
  198. /* ISP request and response entry counts (37-65535) */
  199. #define REQUEST_ENTRY_CNT_2100 128 /* Number of request entries. */
  200. #define REQUEST_ENTRY_CNT_2200 2048 /* Number of request entries. */
  201. #define REQUEST_ENTRY_CNT_2XXX_EXT_MEM 4096 /* Number of request entries. */
  202. #define RESPONSE_ENTRY_CNT_2100 64 /* Number of response entries.*/
  203. #define RESPONSE_ENTRY_CNT_2300 512 /* Number of response entries.*/
  204. /*
  205. * SCSI Request Block
  206. */
  207. typedef struct srb {
  208. struct list_head list;
  209. struct scsi_qla_host *ha; /* HA the SP is queued on */
  210. struct fc_port *fcport;
  211. struct scsi_cmnd *cmd; /* Linux SCSI command pkt */
  212. struct timer_list timer; /* Command timer */
  213. atomic_t ref_count; /* Reference count for this structure */
  214. uint16_t flags;
  215. /* Request state */
  216. uint16_t state;
  217. /* Single transfer DMA context */
  218. dma_addr_t dma_handle;
  219. uint32_t request_sense_length;
  220. uint8_t *request_sense_ptr;
  221. /* SRB magic number */
  222. uint16_t magic;
  223. #define SRB_MAGIC 0x10CB
  224. } srb_t;
  225. /*
  226. * SRB flag definitions
  227. */
  228. #define SRB_TIMEOUT BIT_0 /* Command timed out */
  229. #define SRB_DMA_VALID BIT_1 /* Command sent to ISP */
  230. #define SRB_WATCHDOG BIT_2 /* Command on watchdog list */
  231. #define SRB_ABORT_PENDING BIT_3 /* Command abort sent to device */
  232. #define SRB_ABORTED BIT_4 /* Command aborted command already */
  233. #define SRB_RETRY BIT_5 /* Command needs retrying */
  234. #define SRB_GOT_SENSE BIT_6 /* Command has sense data */
  235. #define SRB_FAILOVER BIT_7 /* Command in failover state */
  236. #define SRB_BUSY BIT_8 /* Command is in busy retry state */
  237. #define SRB_FO_CANCEL BIT_9 /* Command don't need to do failover */
  238. #define SRB_IOCTL BIT_10 /* IOCTL command. */
  239. #define SRB_TAPE BIT_11 /* FCP2 (Tape) command. */
  240. /*
  241. * SRB state definitions
  242. */
  243. #define SRB_FREE_STATE 0 /* returned back */
  244. #define SRB_PENDING_STATE 1 /* queued in LUN Q */
  245. #define SRB_ACTIVE_STATE 2 /* in Active Array */
  246. #define SRB_DONE_STATE 3 /* queued in Done Queue */
  247. #define SRB_RETRY_STATE 4 /* in Retry Queue */
  248. #define SRB_SUSPENDED_STATE 5 /* in suspended state */
  249. #define SRB_NO_QUEUE_STATE 6 /* is in between states */
  250. #define SRB_ACTIVE_TIMEOUT_STATE 7 /* in Active Array but timed out */
  251. #define SRB_FAILOVER_STATE 8 /* in Failover Queue */
  252. #define SRB_SCSI_RETRY_STATE 9 /* in Scsi Retry Queue */
  253. /*
  254. * ISP I/O Register Set structure definitions.
  255. */
  256. typedef volatile struct {
  257. volatile uint16_t flash_address; /* Flash BIOS address */
  258. volatile uint16_t flash_data; /* Flash BIOS data */
  259. uint16_t unused_1[1]; /* Gap */
  260. volatile uint16_t ctrl_status; /* Control/Status */
  261. #define CSR_FLASH_64K_BANK BIT_3 /* Flash upper 64K bank select */
  262. #define CSR_FLASH_ENABLE BIT_1 /* Flash BIOS Read/Write enable */
  263. #define CSR_ISP_SOFT_RESET BIT_0 /* ISP soft reset */
  264. volatile uint16_t ictrl; /* Interrupt control */
  265. #define ICR_EN_INT BIT_15 /* ISP enable interrupts. */
  266. #define ICR_EN_RISC BIT_3 /* ISP enable RISC interrupts. */
  267. volatile uint16_t istatus; /* Interrupt status */
  268. #define ISR_RISC_INT BIT_3 /* RISC interrupt */
  269. volatile uint16_t semaphore; /* Semaphore */
  270. volatile uint16_t nvram; /* NVRAM register. */
  271. #define NVR_DESELECT 0
  272. #define NVR_BUSY BIT_15
  273. #define NVR_WRT_ENABLE BIT_14 /* Write enable */
  274. #define NVR_PR_ENABLE BIT_13 /* Protection register enable */
  275. #define NVR_DATA_IN BIT_3
  276. #define NVR_DATA_OUT BIT_2
  277. #define NVR_SELECT BIT_1
  278. #define NVR_CLOCK BIT_0
  279. union {
  280. struct {
  281. volatile uint16_t mailbox0;
  282. volatile uint16_t mailbox1;
  283. volatile uint16_t mailbox2;
  284. volatile uint16_t mailbox3;
  285. volatile uint16_t mailbox4;
  286. volatile uint16_t mailbox5;
  287. volatile uint16_t mailbox6;
  288. volatile uint16_t mailbox7;
  289. uint16_t unused_2[59]; /* Gap */
  290. } __attribute__((packed)) isp2100;
  291. struct {
  292. /* Request Queue */
  293. volatile uint16_t req_q_in; /* In-Pointer */
  294. volatile uint16_t req_q_out; /* Out-Pointer */
  295. /* Response Queue */
  296. volatile uint16_t rsp_q_in; /* In-Pointer */
  297. volatile uint16_t rsp_q_out; /* Out-Pointer */
  298. /* RISC to Host Status */
  299. volatile uint32_t host_status;
  300. #define HSR_RISC_INT BIT_15 /* RISC interrupt */
  301. #define HSR_RISC_PAUSED BIT_8 /* RISC Paused */
  302. /* Host to Host Semaphore */
  303. volatile uint16_t host_semaphore;
  304. uint16_t unused_3[17]; /* Gap */
  305. volatile uint16_t mailbox0;
  306. volatile uint16_t mailbox1;
  307. volatile uint16_t mailbox2;
  308. volatile uint16_t mailbox3;
  309. volatile uint16_t mailbox4;
  310. volatile uint16_t mailbox5;
  311. volatile uint16_t mailbox6;
  312. volatile uint16_t mailbox7;
  313. volatile uint16_t mailbox8;
  314. volatile uint16_t mailbox9;
  315. volatile uint16_t mailbox10;
  316. volatile uint16_t mailbox11;
  317. volatile uint16_t mailbox12;
  318. volatile uint16_t mailbox13;
  319. volatile uint16_t mailbox14;
  320. volatile uint16_t mailbox15;
  321. volatile uint16_t mailbox16;
  322. volatile uint16_t mailbox17;
  323. volatile uint16_t mailbox18;
  324. volatile uint16_t mailbox19;
  325. volatile uint16_t mailbox20;
  326. volatile uint16_t mailbox21;
  327. volatile uint16_t mailbox22;
  328. volatile uint16_t mailbox23;
  329. volatile uint16_t mailbox24;
  330. volatile uint16_t mailbox25;
  331. volatile uint16_t mailbox26;
  332. volatile uint16_t mailbox27;
  333. volatile uint16_t mailbox28;
  334. volatile uint16_t mailbox29;
  335. volatile uint16_t mailbox30;
  336. volatile uint16_t mailbox31;
  337. volatile uint16_t fb_cmd;
  338. uint16_t unused_4[10]; /* Gap */
  339. } __attribute__((packed)) isp2300;
  340. } u;
  341. volatile uint16_t fpm_diag_config;
  342. uint16_t unused_5[0x6]; /* Gap */
  343. volatile uint16_t pcr; /* Processor Control Register. */
  344. uint16_t unused_6[0x5]; /* Gap */
  345. volatile uint16_t mctr; /* Memory Configuration and Timing. */
  346. uint16_t unused_7[0x3]; /* Gap */
  347. volatile uint16_t fb_cmd_2100; /* Unused on 23XX */
  348. uint16_t unused_8[0x3]; /* Gap */
  349. volatile uint16_t hccr; /* Host command & control register. */
  350. #define HCCR_HOST_INT BIT_7 /* Host interrupt bit */
  351. #define HCCR_RISC_PAUSE BIT_5 /* Pause mode bit */
  352. /* HCCR commands */
  353. #define HCCR_RESET_RISC 0x1000 /* Reset RISC */
  354. #define HCCR_PAUSE_RISC 0x2000 /* Pause RISC */
  355. #define HCCR_RELEASE_RISC 0x3000 /* Release RISC from reset. */
  356. #define HCCR_SET_HOST_INT 0x5000 /* Set host interrupt */
  357. #define HCCR_CLR_HOST_INT 0x6000 /* Clear HOST interrupt */
  358. #define HCCR_CLR_RISC_INT 0x7000 /* Clear RISC interrupt */
  359. #define HCCR_DISABLE_PARITY_PAUSE 0x4001 /* Disable parity error RISC pause. */
  360. #define HCCR_ENABLE_PARITY 0xA000 /* Enable PARITY interrupt */
  361. uint16_t unused_9[5]; /* Gap */
  362. volatile uint16_t gpiod; /* GPIO Data register. */
  363. volatile uint16_t gpioe; /* GPIO Enable register. */
  364. #define GPIO_LED_MASK 0x00C0
  365. #define GPIO_LED_GREEN_OFF_AMBER_OFF 0x0000
  366. #define GPIO_LED_GREEN_ON_AMBER_OFF 0x0040
  367. #define GPIO_LED_GREEN_OFF_AMBER_ON 0x0080
  368. #define GPIO_LED_GREEN_ON_AMBER_ON 0x00C0
  369. union {
  370. struct {
  371. uint16_t unused_10[8]; /* Gap */
  372. volatile uint16_t mailbox8;
  373. volatile uint16_t mailbox9;
  374. volatile uint16_t mailbox10;
  375. volatile uint16_t mailbox11;
  376. volatile uint16_t mailbox12;
  377. volatile uint16_t mailbox13;
  378. volatile uint16_t mailbox14;
  379. volatile uint16_t mailbox15;
  380. volatile uint16_t mailbox16;
  381. volatile uint16_t mailbox17;
  382. volatile uint16_t mailbox18;
  383. volatile uint16_t mailbox19;
  384. volatile uint16_t mailbox20;
  385. volatile uint16_t mailbox21;
  386. volatile uint16_t mailbox22;
  387. volatile uint16_t mailbox23; /* Also probe reg. */
  388. } __attribute__((packed)) isp2200;
  389. } u_end;
  390. } device_reg_t;
  391. #define ISP_REQ_Q_IN(ha, reg) \
  392. (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  393. &(reg)->u.isp2100.mailbox4 : \
  394. &(reg)->u.isp2300.req_q_in)
  395. #define ISP_REQ_Q_OUT(ha, reg) \
  396. (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  397. &(reg)->u.isp2100.mailbox4 : \
  398. &(reg)->u.isp2300.req_q_out)
  399. #define ISP_RSP_Q_IN(ha, reg) \
  400. (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  401. &(reg)->u.isp2100.mailbox5 : \
  402. &(reg)->u.isp2300.rsp_q_in)
  403. #define ISP_RSP_Q_OUT(ha, reg) \
  404. (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  405. &(reg)->u.isp2100.mailbox5 : \
  406. &(reg)->u.isp2300.rsp_q_out)
  407. #define MAILBOX_REG(ha, reg, num) \
  408. (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  409. (num < 8 ? \
  410. &(reg)->u.isp2100.mailbox0 + (num) : \
  411. &(reg)->u_end.isp2200.mailbox8 + (num) - 8) : \
  412. &(reg)->u.isp2300.mailbox0 + (num))
  413. #define RD_MAILBOX_REG(ha, reg, num) \
  414. RD_REG_WORD(MAILBOX_REG(ha, reg, num))
  415. #define WRT_MAILBOX_REG(ha, reg, num, data) \
  416. WRT_REG_WORD(MAILBOX_REG(ha, reg, num), data)
  417. #define FB_CMD_REG(ha, reg) \
  418. (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  419. &(reg)->fb_cmd_2100 : \
  420. &(reg)->u.isp2300.fb_cmd)
  421. #define RD_FB_CMD_REG(ha, reg) \
  422. RD_REG_WORD(FB_CMD_REG(ha, reg))
  423. #define WRT_FB_CMD_REG(ha, reg, data) \
  424. WRT_REG_WORD(FB_CMD_REG(ha, reg), data)
  425. typedef struct {
  426. uint32_t out_mb; /* outbound from driver */
  427. uint32_t in_mb; /* Incoming from RISC */
  428. uint16_t mb[MAILBOX_REGISTER_COUNT];
  429. long buf_size;
  430. void *bufp;
  431. uint32_t tov;
  432. uint8_t flags;
  433. #define MBX_DMA_IN BIT_0
  434. #define MBX_DMA_OUT BIT_1
  435. #define IOCTL_CMD BIT_2
  436. } mbx_cmd_t;
  437. #define MBX_TOV_SECONDS 30
  438. /*
  439. * ISP product identification definitions in mailboxes after reset.
  440. */
  441. #define PROD_ID_1 0x4953
  442. #define PROD_ID_2 0x0000
  443. #define PROD_ID_2a 0x5020
  444. #define PROD_ID_3 0x2020
  445. /*
  446. * ISP mailbox Self-Test status codes
  447. */
  448. #define MBS_FRM_ALIVE 0 /* Firmware Alive. */
  449. #define MBS_CHKSUM_ERR 1 /* Checksum Error. */
  450. #define MBS_BUSY 4 /* Busy. */
  451. /*
  452. * ISP mailbox command complete status codes
  453. */
  454. #define MBS_COMMAND_COMPLETE 0x4000
  455. #define MBS_INVALID_COMMAND 0x4001
  456. #define MBS_HOST_INTERFACE_ERROR 0x4002
  457. #define MBS_TEST_FAILED 0x4003
  458. #define MBS_COMMAND_ERROR 0x4005
  459. #define MBS_COMMAND_PARAMETER_ERROR 0x4006
  460. #define MBS_PORT_ID_USED 0x4007
  461. #define MBS_LOOP_ID_USED 0x4008
  462. #define MBS_ALL_IDS_IN_USE 0x4009
  463. #define MBS_NOT_LOGGED_IN 0x400A
  464. /*
  465. * ISP mailbox asynchronous event status codes
  466. */
  467. #define MBA_ASYNC_EVENT 0x8000 /* Asynchronous event. */
  468. #define MBA_RESET 0x8001 /* Reset Detected. */
  469. #define MBA_SYSTEM_ERR 0x8002 /* System Error. */
  470. #define MBA_REQ_TRANSFER_ERR 0x8003 /* Request Transfer Error. */
  471. #define MBA_RSP_TRANSFER_ERR 0x8004 /* Response Transfer Error. */
  472. #define MBA_WAKEUP_THRES 0x8005 /* Request Queue Wake-up. */
  473. #define MBA_LIP_OCCURRED 0x8010 /* Loop Initialization Procedure */
  474. /* occurred. */
  475. #define MBA_LOOP_UP 0x8011 /* FC Loop UP. */
  476. #define MBA_LOOP_DOWN 0x8012 /* FC Loop Down. */
  477. #define MBA_LIP_RESET 0x8013 /* LIP reset occurred. */
  478. #define MBA_PORT_UPDATE 0x8014 /* Port Database update. */
  479. #define MBA_RSCN_UPDATE 0x8015 /* Register State Chg Notification. */
  480. #define MBA_LIP_F8 0x8016 /* Received a LIP F8. */
  481. #define MBA_LOOP_INIT_ERR 0x8017 /* Loop Initialization Error. */
  482. #define MBA_FABRIC_AUTH_REQ 0x801b /* Fabric Authentication Required. */
  483. #define MBA_SCSI_COMPLETION 0x8020 /* SCSI Command Complete. */
  484. #define MBA_CTIO_COMPLETION 0x8021 /* CTIO Complete. */
  485. #define MBA_IP_COMPLETION 0x8022 /* IP Transmit Command Complete. */
  486. #define MBA_IP_RECEIVE 0x8023 /* IP Received. */
  487. #define MBA_IP_BROADCAST 0x8024 /* IP Broadcast Received. */
  488. #define MBA_IP_LOW_WATER_MARK 0x8025 /* IP Low Water Mark reached. */
  489. #define MBA_IP_RCV_BUFFER_EMPTY 0x8026 /* IP receive buffer queue empty. */
  490. #define MBA_IP_HDR_DATA_SPLIT 0x8027 /* IP header/data splitting feature */
  491. /* used. */
  492. #define MBA_POINT_TO_POINT 0x8030 /* Point to point mode. */
  493. #define MBA_CMPLT_1_16BIT 0x8031 /* Completion 1 16bit IOSB. */
  494. #define MBA_CMPLT_2_16BIT 0x8032 /* Completion 2 16bit IOSB. */
  495. #define MBA_CMPLT_3_16BIT 0x8033 /* Completion 3 16bit IOSB. */
  496. #define MBA_CMPLT_4_16BIT 0x8034 /* Completion 4 16bit IOSB. */
  497. #define MBA_CMPLT_5_16BIT 0x8035 /* Completion 5 16bit IOSB. */
  498. #define MBA_CHG_IN_CONNECTION 0x8036 /* Change in connection mode. */
  499. #define MBA_RIO_RESPONSE 0x8040 /* RIO response queue update. */
  500. #define MBA_ZIO_RESPONSE 0x8040 /* ZIO response queue update. */
  501. #define MBA_CMPLT_2_32BIT 0x8042 /* Completion 2 32bit IOSB. */
  502. #define MBA_BYPASS_NOTIFICATION 0x8043 /* Auto bypass notification. */
  503. #define MBA_DISCARD_RND_FRAME 0x8048 /* discard RND frame due to error. */
  504. #define MBA_REJECTED_FCP_CMD 0x8049 /* rejected FCP_CMD. */
  505. /*
  506. * Firmware options 1, 2, 3.
  507. */
  508. #define FO1_AE_ON_LIPF8 BIT_0
  509. #define FO1_AE_ALL_LIP_RESET BIT_1
  510. #define FO1_CTIO_RETRY BIT_3
  511. #define FO1_DISABLE_LIP_F7_SW BIT_4
  512. #define FO1_DISABLE_100MS_LOS_WAIT BIT_5
  513. #define FO1_DISABLE_GPIO6_7 BIT_6
  514. #define FO1_AE_ON_LOOP_INIT_ERR BIT_7
  515. #define FO1_SET_EMPHASIS_SWING BIT_8
  516. #define FO1_AE_AUTO_BYPASS BIT_9
  517. #define FO1_ENABLE_PURE_IOCB BIT_10
  518. #define FO1_AE_PLOGI_RJT BIT_11
  519. #define FO1_ENABLE_ABORT_SEQUENCE BIT_12
  520. #define FO1_AE_QUEUE_FULL BIT_13
  521. #define FO2_ENABLE_ATIO_TYPE_3 BIT_0
  522. #define FO2_REV_LOOPBACK BIT_1
  523. #define FO3_ENABLE_EMERG_IOCB BIT_0
  524. #define FO3_AE_RND_ERROR BIT_1
  525. /*
  526. * ISP mailbox commands
  527. */
  528. #define MBC_LOAD_RAM 1 /* Load RAM. */
  529. #define MBC_EXECUTE_FIRMWARE 2 /* Execute firmware. */
  530. #define MBC_WRITE_RAM_WORD 4 /* Write RAM word. */
  531. #define MBC_READ_RAM_WORD 5 /* Read RAM word. */
  532. #define MBC_MAILBOX_REGISTER_TEST 6 /* Wrap incoming mailboxes */
  533. #define MBC_VERIFY_CHECKSUM 7 /* Verify checksum. */
  534. #define MBC_GET_FIRMWARE_VERSION 8 /* Get firmware revision. */
  535. #define MBC_LOAD_RISC_RAM 9 /* Load RAM command. */
  536. #define MBC_DUMP_RISC_RAM 0xa /* Dump RAM command. */
  537. #define MBC_LOAD_RISC_RAM_EXTENDED 0xb /* Load RAM extended. */
  538. #define MBC_DUMP_RISC_RAM_EXTENDED 0xc /* Dump RAM extended. */
  539. #define MBC_WRITE_RAM_WORD_EXTENDED 0xd /* Write RAM word extended */
  540. #define MBC_READ_RAM_EXTENDED 0xf /* Read RAM extended. */
  541. #define MBC_IOCB_COMMAND 0x12 /* Execute IOCB command. */
  542. #define MBC_ABORT_COMMAND 0x15 /* Abort IOCB command. */
  543. #define MBC_ABORT_DEVICE 0x16 /* Abort device (ID/LUN). */
  544. #define MBC_ABORT_TARGET 0x17 /* Abort target (ID). */
  545. #define MBC_RESET 0x18 /* Reset. */
  546. #define MBC_GET_ADAPTER_LOOP_ID 0x20 /* Get loop id of ISP2200. */
  547. #define MBC_GET_RETRY_COUNT 0x22 /* Get f/w retry cnt/delay. */
  548. #define MBC_DISABLE_VI 0x24 /* Disable VI operation. */
  549. #define MBC_ENABLE_VI 0x25 /* Enable VI operation. */
  550. #define MBC_GET_FIRMWARE_OPTION 0x28 /* Get Firmware Options. */
  551. #define MBC_SET_FIRMWARE_OPTION 0x38 /* Set Firmware Options. */
  552. #define MBC_LOOP_PORT_BYPASS 0x40 /* Loop Port Bypass. */
  553. #define MBC_LOOP_PORT_ENABLE 0x41 /* Loop Port Enable. */
  554. #define MBC_GET_RESOURCE_COUNTS 0x42 /* Get Resource Counts. */
  555. #define MBC_NON_PARTICIPATE 0x43 /* Non-Participating Mode. */
  556. #define MBC_DIAGNOSTIC_ECHO 0x44 /* Diagnostic echo. */
  557. #define MBC_DIAGNOSTIC_LOOP_BACK 0x45 /* Diagnostic loop back. */
  558. #define MBC_ONLINE_SELF_TEST 0x46 /* Online self-test. */
  559. #define MBC_ENHANCED_GET_PORT_DATABASE 0x47 /* Get port database + login */
  560. #define MBC_RESET_LINK_STATUS 0x52 /* Reset Link Error Status */
  561. #define MBC_IOCB_COMMAND_A64 0x54 /* Execute IOCB command (64) */
  562. #define MBC_SEND_RNID_ELS 0x57 /* Send RNID ELS request */
  563. #define MBC_SET_RNID_PARAMS 0x59 /* Set RNID parameters */
  564. #define MBC_GET_RNID_PARAMS 0x5a /* Data Rate */
  565. #define MBC_DATA_RATE 0x5d /* Get RNID parameters */
  566. #define MBC_INITIALIZE_FIRMWARE 0x60 /* Initialize firmware */
  567. #define MBC_INITIATE_LIP 0x62 /* Initiate Loop */
  568. /* Initialization Procedure */
  569. #define MBC_GET_FC_AL_POSITION_MAP 0x63 /* Get FC_AL Position Map. */
  570. #define MBC_GET_PORT_DATABASE 0x64 /* Get Port Database. */
  571. #define MBC_CLEAR_ACA 0x65 /* Clear ACA. */
  572. #define MBC_TARGET_RESET 0x66 /* Target Reset. */
  573. #define MBC_CLEAR_TASK_SET 0x67 /* Clear Task Set. */
  574. #define MBC_ABORT_TASK_SET 0x68 /* Abort Task Set. */
  575. #define MBC_GET_FIRMWARE_STATE 0x69 /* Get firmware state. */
  576. #define MBC_GET_PORT_NAME 0x6a /* Get port name. */
  577. #define MBC_GET_LINK_STATUS 0x6b /* Get port link status. */
  578. #define MBC_LIP_RESET 0x6c /* LIP reset. */
  579. #define MBC_SEND_SNS_COMMAND 0x6e /* Send Simple Name Server */
  580. /* commandd. */
  581. #define MBC_LOGIN_FABRIC_PORT 0x6f /* Login fabric port. */
  582. #define MBC_SEND_CHANGE_REQUEST 0x70 /* Send Change Request. */
  583. #define MBC_LOGOUT_FABRIC_PORT 0x71 /* Logout fabric port. */
  584. #define MBC_LIP_FULL_LOGIN 0x72 /* Full login LIP. */
  585. #define MBC_LOGIN_LOOP_PORT 0x74 /* Login Loop Port. */
  586. #define MBC_PORT_NODE_NAME_LIST 0x75 /* Get port/node name list. */
  587. #define MBC_INITIALIZE_RECEIVE_QUEUE 0x77 /* Initialize receive queue */
  588. #define MBC_UNLOAD_IP 0x79 /* Shutdown IP */
  589. #define MBC_GET_ID_LIST 0x7C /* Get Port ID list. */
  590. #define MBC_SEND_LFA_COMMAND 0x7D /* Send Loop Fabric Address */
  591. #define MBC_LUN_RESET 0x7E /* Send LUN reset */
  592. /* Firmware return data sizes */
  593. #define FCAL_MAP_SIZE 128
  594. /* Mailbox bit definitions for out_mb and in_mb */
  595. #define MBX_31 BIT_31
  596. #define MBX_30 BIT_30
  597. #define MBX_29 BIT_29
  598. #define MBX_28 BIT_28
  599. #define MBX_27 BIT_27
  600. #define MBX_26 BIT_26
  601. #define MBX_25 BIT_25
  602. #define MBX_24 BIT_24
  603. #define MBX_23 BIT_23
  604. #define MBX_22 BIT_22
  605. #define MBX_21 BIT_21
  606. #define MBX_20 BIT_20
  607. #define MBX_19 BIT_19
  608. #define MBX_18 BIT_18
  609. #define MBX_17 BIT_17
  610. #define MBX_16 BIT_16
  611. #define MBX_15 BIT_15
  612. #define MBX_14 BIT_14
  613. #define MBX_13 BIT_13
  614. #define MBX_12 BIT_12
  615. #define MBX_11 BIT_11
  616. #define MBX_10 BIT_10
  617. #define MBX_9 BIT_9
  618. #define MBX_8 BIT_8
  619. #define MBX_7 BIT_7
  620. #define MBX_6 BIT_6
  621. #define MBX_5 BIT_5
  622. #define MBX_4 BIT_4
  623. #define MBX_3 BIT_3
  624. #define MBX_2 BIT_2
  625. #define MBX_1 BIT_1
  626. #define MBX_0 BIT_0
  627. /*
  628. * Firmware state codes from get firmware state mailbox command
  629. */
  630. #define FSTATE_CONFIG_WAIT 0
  631. #define FSTATE_WAIT_AL_PA 1
  632. #define FSTATE_WAIT_LOGIN 2
  633. #define FSTATE_READY 3
  634. #define FSTATE_LOSS_OF_SYNC 4
  635. #define FSTATE_ERROR 5
  636. #define FSTATE_REINIT 6
  637. #define FSTATE_NON_PART 7
  638. #define FSTATE_CONFIG_CORRECT 0
  639. #define FSTATE_P2P_RCV_LIP 1
  640. #define FSTATE_P2P_CHOOSE_LOOP 2
  641. #define FSTATE_P2P_RCV_UNIDEN_LIP 3
  642. #define FSTATE_FATAL_ERROR 4
  643. #define FSTATE_LOOP_BACK_CONN 5
  644. /*
  645. * Port Database structure definition
  646. * Little endian except where noted.
  647. */
  648. #define PORT_DATABASE_SIZE 128 /* bytes */
  649. typedef struct {
  650. uint8_t options;
  651. uint8_t control;
  652. uint8_t master_state;
  653. uint8_t slave_state;
  654. uint8_t reserved[2];
  655. uint8_t hard_address;
  656. uint8_t reserved_1;
  657. uint8_t port_id[4];
  658. uint8_t node_name[WWN_SIZE];
  659. uint8_t port_name[WWN_SIZE];
  660. uint16_t execution_throttle;
  661. uint16_t execution_count;
  662. uint8_t reset_count;
  663. uint8_t reserved_2;
  664. uint16_t resource_allocation;
  665. uint16_t current_allocation;
  666. uint16_t queue_head;
  667. uint16_t queue_tail;
  668. uint16_t transmit_execution_list_next;
  669. uint16_t transmit_execution_list_previous;
  670. uint16_t common_features;
  671. uint16_t total_concurrent_sequences;
  672. uint16_t RO_by_information_category;
  673. uint8_t recipient;
  674. uint8_t initiator;
  675. uint16_t receive_data_size;
  676. uint16_t concurrent_sequences;
  677. uint16_t open_sequences_per_exchange;
  678. uint16_t lun_abort_flags;
  679. uint16_t lun_stop_flags;
  680. uint16_t stop_queue_head;
  681. uint16_t stop_queue_tail;
  682. uint16_t port_retry_timer;
  683. uint16_t next_sequence_id;
  684. uint16_t frame_count;
  685. uint16_t PRLI_payload_length;
  686. uint8_t prli_svc_param_word_0[2]; /* Big endian */
  687. /* Bits 15-0 of word 0 */
  688. uint8_t prli_svc_param_word_3[2]; /* Big endian */
  689. /* Bits 15-0 of word 3 */
  690. uint16_t loop_id;
  691. uint16_t extended_lun_info_list_pointer;
  692. uint16_t extended_lun_stop_list_pointer;
  693. } port_database_t;
  694. /*
  695. * Port database slave/master states
  696. */
  697. #define PD_STATE_DISCOVERY 0
  698. #define PD_STATE_WAIT_DISCOVERY_ACK 1
  699. #define PD_STATE_PORT_LOGIN 2
  700. #define PD_STATE_WAIT_PORT_LOGIN_ACK 3
  701. #define PD_STATE_PROCESS_LOGIN 4
  702. #define PD_STATE_WAIT_PROCESS_LOGIN_ACK 5
  703. #define PD_STATE_PORT_LOGGED_IN 6
  704. #define PD_STATE_PORT_UNAVAILABLE 7
  705. #define PD_STATE_PROCESS_LOGOUT 8
  706. #define PD_STATE_WAIT_PROCESS_LOGOUT_ACK 9
  707. #define PD_STATE_PORT_LOGOUT 10
  708. #define PD_STATE_WAIT_PORT_LOGOUT_ACK 11
  709. /*
  710. * ISP Initialization Control Block.
  711. * Little endian except where noted.
  712. */
  713. #define ICB_VERSION 1
  714. typedef struct {
  715. uint8_t version;
  716. uint8_t reserved_1;
  717. /*
  718. * LSB BIT 0 = Enable Hard Loop Id
  719. * LSB BIT 1 = Enable Fairness
  720. * LSB BIT 2 = Enable Full-Duplex
  721. * LSB BIT 3 = Enable Fast Posting
  722. * LSB BIT 4 = Enable Target Mode
  723. * LSB BIT 5 = Disable Initiator Mode
  724. * LSB BIT 6 = Enable ADISC
  725. * LSB BIT 7 = Enable Target Inquiry Data
  726. *
  727. * MSB BIT 0 = Enable PDBC Notify
  728. * MSB BIT 1 = Non Participating LIP
  729. * MSB BIT 2 = Descending Loop ID Search
  730. * MSB BIT 3 = Acquire Loop ID in LIPA
  731. * MSB BIT 4 = Stop PortQ on Full Status
  732. * MSB BIT 5 = Full Login after LIP
  733. * MSB BIT 6 = Node Name Option
  734. * MSB BIT 7 = Ext IFWCB enable bit
  735. */
  736. uint8_t firmware_options[2];
  737. uint16_t frame_payload_size;
  738. uint16_t max_iocb_allocation;
  739. uint16_t execution_throttle;
  740. uint8_t retry_count;
  741. uint8_t retry_delay; /* unused */
  742. uint8_t port_name[WWN_SIZE]; /* Big endian. */
  743. uint16_t hard_address;
  744. uint8_t inquiry_data;
  745. uint8_t login_timeout;
  746. uint8_t node_name[WWN_SIZE]; /* Big endian. */
  747. uint16_t request_q_outpointer;
  748. uint16_t response_q_inpointer;
  749. uint16_t request_q_length;
  750. uint16_t response_q_length;
  751. uint32_t request_q_address[2];
  752. uint32_t response_q_address[2];
  753. uint16_t lun_enables;
  754. uint8_t command_resource_count;
  755. uint8_t immediate_notify_resource_count;
  756. uint16_t timeout;
  757. uint8_t reserved_2[2];
  758. /*
  759. * LSB BIT 0 = Timer Operation mode bit 0
  760. * LSB BIT 1 = Timer Operation mode bit 1
  761. * LSB BIT 2 = Timer Operation mode bit 2
  762. * LSB BIT 3 = Timer Operation mode bit 3
  763. * LSB BIT 4 = Init Config Mode bit 0
  764. * LSB BIT 5 = Init Config Mode bit 1
  765. * LSB BIT 6 = Init Config Mode bit 2
  766. * LSB BIT 7 = Enable Non part on LIHA failure
  767. *
  768. * MSB BIT 0 = Enable class 2
  769. * MSB BIT 1 = Enable ACK0
  770. * MSB BIT 2 =
  771. * MSB BIT 3 =
  772. * MSB BIT 4 = FC Tape Enable
  773. * MSB BIT 5 = Enable FC Confirm
  774. * MSB BIT 6 = Enable command queuing in target mode
  775. * MSB BIT 7 = No Logo On Link Down
  776. */
  777. uint8_t add_firmware_options[2];
  778. uint8_t response_accumulation_timer;
  779. uint8_t interrupt_delay_timer;
  780. /*
  781. * LSB BIT 0 = Enable Read xfr_rdy
  782. * LSB BIT 1 = Soft ID only
  783. * LSB BIT 2 =
  784. * LSB BIT 3 =
  785. * LSB BIT 4 = FCP RSP Payload [0]
  786. * LSB BIT 5 = FCP RSP Payload [1] / Sbus enable - 2200
  787. * LSB BIT 6 = Enable Out-of-Order frame handling
  788. * LSB BIT 7 = Disable Automatic PLOGI on Local Loop
  789. *
  790. * MSB BIT 0 = Sbus enable - 2300
  791. * MSB BIT 1 =
  792. * MSB BIT 2 =
  793. * MSB BIT 3 =
  794. * MSB BIT 4 =
  795. * MSB BIT 5 = enable 50 ohm termination
  796. * MSB BIT 6 = Data Rate (2300 only)
  797. * MSB BIT 7 = Data Rate (2300 only)
  798. */
  799. uint8_t special_options[2];
  800. uint8_t reserved_3[26];
  801. } init_cb_t;
  802. /*
  803. * Get Link Status mailbox command return buffer.
  804. */
  805. typedef struct {
  806. uint32_t link_fail_cnt;
  807. uint32_t loss_sync_cnt;
  808. uint32_t loss_sig_cnt;
  809. uint32_t prim_seq_err_cnt;
  810. uint32_t inval_xmit_word_cnt;
  811. uint32_t inval_crc_cnt;
  812. } link_stat_t;
  813. /*
  814. * NVRAM Command values.
  815. */
  816. #define NV_START_BIT BIT_2
  817. #define NV_WRITE_OP (BIT_26+BIT_24)
  818. #define NV_READ_OP (BIT_26+BIT_25)
  819. #define NV_ERASE_OP (BIT_26+BIT_25+BIT_24)
  820. #define NV_MASK_OP (BIT_26+BIT_25+BIT_24)
  821. #define NV_DELAY_COUNT 10
  822. /*
  823. * QLogic ISP2100, ISP2200 and ISP2300 NVRAM structure definition.
  824. */
  825. typedef struct {
  826. /*
  827. * NVRAM header
  828. */
  829. uint8_t id[4];
  830. uint8_t nvram_version;
  831. uint8_t reserved_0;
  832. /*
  833. * NVRAM RISC parameter block
  834. */
  835. uint8_t parameter_block_version;
  836. uint8_t reserved_1;
  837. /*
  838. * LSB BIT 0 = Enable Hard Loop Id
  839. * LSB BIT 1 = Enable Fairness
  840. * LSB BIT 2 = Enable Full-Duplex
  841. * LSB BIT 3 = Enable Fast Posting
  842. * LSB BIT 4 = Enable Target Mode
  843. * LSB BIT 5 = Disable Initiator Mode
  844. * LSB BIT 6 = Enable ADISC
  845. * LSB BIT 7 = Enable Target Inquiry Data
  846. *
  847. * MSB BIT 0 = Enable PDBC Notify
  848. * MSB BIT 1 = Non Participating LIP
  849. * MSB BIT 2 = Descending Loop ID Search
  850. * MSB BIT 3 = Acquire Loop ID in LIPA
  851. * MSB BIT 4 = Stop PortQ on Full Status
  852. * MSB BIT 5 = Full Login after LIP
  853. * MSB BIT 6 = Node Name Option
  854. * MSB BIT 7 = Ext IFWCB enable bit
  855. */
  856. uint8_t firmware_options[2];
  857. uint16_t frame_payload_size;
  858. uint16_t max_iocb_allocation;
  859. uint16_t execution_throttle;
  860. uint8_t retry_count;
  861. uint8_t retry_delay; /* unused */
  862. uint8_t port_name[WWN_SIZE]; /* Big endian. */
  863. uint16_t hard_address;
  864. uint8_t inquiry_data;
  865. uint8_t login_timeout;
  866. uint8_t node_name[WWN_SIZE]; /* Big endian. */
  867. /*
  868. * LSB BIT 0 = Timer Operation mode bit 0
  869. * LSB BIT 1 = Timer Operation mode bit 1
  870. * LSB BIT 2 = Timer Operation mode bit 2
  871. * LSB BIT 3 = Timer Operation mode bit 3
  872. * LSB BIT 4 = Init Config Mode bit 0
  873. * LSB BIT 5 = Init Config Mode bit 1
  874. * LSB BIT 6 = Init Config Mode bit 2
  875. * LSB BIT 7 = Enable Non part on LIHA failure
  876. *
  877. * MSB BIT 0 = Enable class 2
  878. * MSB BIT 1 = Enable ACK0
  879. * MSB BIT 2 =
  880. * MSB BIT 3 =
  881. * MSB BIT 4 = FC Tape Enable
  882. * MSB BIT 5 = Enable FC Confirm
  883. * MSB BIT 6 = Enable command queuing in target mode
  884. * MSB BIT 7 = No Logo On Link Down
  885. */
  886. uint8_t add_firmware_options[2];
  887. uint8_t response_accumulation_timer;
  888. uint8_t interrupt_delay_timer;
  889. /*
  890. * LSB BIT 0 = Enable Read xfr_rdy
  891. * LSB BIT 1 = Soft ID only
  892. * LSB BIT 2 =
  893. * LSB BIT 3 =
  894. * LSB BIT 4 = FCP RSP Payload [0]
  895. * LSB BIT 5 = FCP RSP Payload [1] / Sbus enable - 2200
  896. * LSB BIT 6 = Enable Out-of-Order frame handling
  897. * LSB BIT 7 = Disable Automatic PLOGI on Local Loop
  898. *
  899. * MSB BIT 0 = Sbus enable - 2300
  900. * MSB BIT 1 =
  901. * MSB BIT 2 =
  902. * MSB BIT 3 =
  903. * MSB BIT 4 =
  904. * MSB BIT 5 = enable 50 ohm termination
  905. * MSB BIT 6 = Data Rate (2300 only)
  906. * MSB BIT 7 = Data Rate (2300 only)
  907. */
  908. uint8_t special_options[2];
  909. /* Reserved for expanded RISC parameter block */
  910. uint8_t reserved_2[22];
  911. /*
  912. * LSB BIT 0 = Tx Sensitivity 1G bit 0
  913. * LSB BIT 1 = Tx Sensitivity 1G bit 1
  914. * LSB BIT 2 = Tx Sensitivity 1G bit 2
  915. * LSB BIT 3 = Tx Sensitivity 1G bit 3
  916. * LSB BIT 4 = Rx Sensitivity 1G bit 0
  917. * LSB BIT 5 = Rx Sensitivity 1G bit 1
  918. * LSB BIT 6 = Rx Sensitivity 1G bit 2
  919. * LSB BIT 7 = Rx Sensitivity 1G bit 3
  920. *
  921. * MSB BIT 0 = Tx Sensitivity 2G bit 0
  922. * MSB BIT 1 = Tx Sensitivity 2G bit 1
  923. * MSB BIT 2 = Tx Sensitivity 2G bit 2
  924. * MSB BIT 3 = Tx Sensitivity 2G bit 3
  925. * MSB BIT 4 = Rx Sensitivity 2G bit 0
  926. * MSB BIT 5 = Rx Sensitivity 2G bit 1
  927. * MSB BIT 6 = Rx Sensitivity 2G bit 2
  928. * MSB BIT 7 = Rx Sensitivity 2G bit 3
  929. *
  930. * LSB BIT 0 = Output Swing 1G bit 0
  931. * LSB BIT 1 = Output Swing 1G bit 1
  932. * LSB BIT 2 = Output Swing 1G bit 2
  933. * LSB BIT 3 = Output Emphasis 1G bit 0
  934. * LSB BIT 4 = Output Emphasis 1G bit 1
  935. * LSB BIT 5 = Output Swing 2G bit 0
  936. * LSB BIT 6 = Output Swing 2G bit 1
  937. * LSB BIT 7 = Output Swing 2G bit 2
  938. *
  939. * MSB BIT 0 = Output Emphasis 2G bit 0
  940. * MSB BIT 1 = Output Emphasis 2G bit 1
  941. * MSB BIT 2 = Output Enable
  942. * MSB BIT 3 =
  943. * MSB BIT 4 =
  944. * MSB BIT 5 =
  945. * MSB BIT 6 =
  946. * MSB BIT 7 =
  947. */
  948. uint8_t seriallink_options[4];
  949. /*
  950. * NVRAM host parameter block
  951. *
  952. * LSB BIT 0 = Enable spinup delay
  953. * LSB BIT 1 = Disable BIOS
  954. * LSB BIT 2 = Enable Memory Map BIOS
  955. * LSB BIT 3 = Enable Selectable Boot
  956. * LSB BIT 4 = Disable RISC code load
  957. * LSB BIT 5 = Set cache line size 1
  958. * LSB BIT 6 = PCI Parity Disable
  959. * LSB BIT 7 = Enable extended logging
  960. *
  961. * MSB BIT 0 = Enable 64bit addressing
  962. * MSB BIT 1 = Enable lip reset
  963. * MSB BIT 2 = Enable lip full login
  964. * MSB BIT 3 = Enable target reset
  965. * MSB BIT 4 = Enable database storage
  966. * MSB BIT 5 = Enable cache flush read
  967. * MSB BIT 6 = Enable database load
  968. * MSB BIT 7 = Enable alternate WWN
  969. */
  970. uint8_t host_p[2];
  971. uint8_t boot_node_name[WWN_SIZE];
  972. uint8_t boot_lun_number;
  973. uint8_t reset_delay;
  974. uint8_t port_down_retry_count;
  975. uint8_t boot_id_number;
  976. uint16_t max_luns_per_target;
  977. uint8_t fcode_boot_port_name[WWN_SIZE];
  978. uint8_t alternate_port_name[WWN_SIZE];
  979. uint8_t alternate_node_name[WWN_SIZE];
  980. /*
  981. * BIT 0 = Selective Login
  982. * BIT 1 = Alt-Boot Enable
  983. * BIT 2 =
  984. * BIT 3 = Boot Order List
  985. * BIT 4 =
  986. * BIT 5 = Selective LUN
  987. * BIT 6 =
  988. * BIT 7 = unused
  989. */
  990. uint8_t efi_parameters;
  991. uint8_t link_down_timeout;
  992. uint8_t adapter_id_0[4];
  993. uint8_t adapter_id_1[4];
  994. uint8_t adapter_id_2[4];
  995. uint8_t adapter_id_3[4];
  996. uint8_t alt1_boot_node_name[WWN_SIZE];
  997. uint16_t alt1_boot_lun_number;
  998. uint8_t alt2_boot_node_name[WWN_SIZE];
  999. uint16_t alt2_boot_lun_number;
  1000. uint8_t alt3_boot_node_name[WWN_SIZE];
  1001. uint16_t alt3_boot_lun_number;
  1002. uint8_t alt4_boot_node_name[WWN_SIZE];
  1003. uint16_t alt4_boot_lun_number;
  1004. uint8_t alt5_boot_node_name[WWN_SIZE];
  1005. uint16_t alt5_boot_lun_number;
  1006. uint8_t alt6_boot_node_name[WWN_SIZE];
  1007. uint16_t alt6_boot_lun_number;
  1008. uint8_t alt7_boot_node_name[WWN_SIZE];
  1009. uint16_t alt7_boot_lun_number;
  1010. uint8_t reserved_3[2];
  1011. /* Offset 200-215 : Model Number */
  1012. uint8_t model_number[16];
  1013. /* OEM related items */
  1014. uint8_t oem_specific[16];
  1015. /*
  1016. * NVRAM Adapter Features offset 232-239
  1017. *
  1018. * LSB BIT 0 = External GBIC
  1019. * LSB BIT 1 = Risc RAM parity
  1020. * LSB BIT 2 = Buffer Plus Module
  1021. * LSB BIT 3 = Multi Chip Adapter
  1022. * LSB BIT 4 = Internal connector
  1023. * LSB BIT 5 =
  1024. * LSB BIT 6 =
  1025. * LSB BIT 7 =
  1026. *
  1027. * MSB BIT 0 =
  1028. * MSB BIT 1 =
  1029. * MSB BIT 2 =
  1030. * MSB BIT 3 =
  1031. * MSB BIT 4 =
  1032. * MSB BIT 5 =
  1033. * MSB BIT 6 =
  1034. * MSB BIT 7 =
  1035. */
  1036. uint8_t adapter_features[2];
  1037. uint8_t reserved_4[16];
  1038. /* Subsystem vendor ID for ISP2200 */
  1039. uint16_t subsystem_vendor_id_2200;
  1040. /* Subsystem device ID for ISP2200 */
  1041. uint16_t subsystem_device_id_2200;
  1042. uint8_t reserved_5;
  1043. uint8_t checksum;
  1044. } nvram_t;
  1045. /*
  1046. * ISP queue - response queue entry definition.
  1047. */
  1048. typedef struct {
  1049. uint8_t data[60];
  1050. uint32_t signature;
  1051. #define RESPONSE_PROCESSED 0xDEADDEAD /* Signature */
  1052. } response_t;
  1053. typedef union {
  1054. uint16_t extended;
  1055. struct {
  1056. uint8_t reserved;
  1057. uint8_t standard;
  1058. } id;
  1059. } target_id_t;
  1060. #define SET_TARGET_ID(ha, to, from) \
  1061. do { \
  1062. if (HAS_EXTENDED_IDS(ha)) \
  1063. to.extended = cpu_to_le16(from); \
  1064. else \
  1065. to.id.standard = (uint8_t)from; \
  1066. } while (0)
  1067. /*
  1068. * ISP queue - command entry structure definition.
  1069. */
  1070. #define COMMAND_TYPE 0x11 /* Command entry */
  1071. #define MAX_CMDSZ 16 /* SCSI maximum CDB size. */
  1072. typedef struct {
  1073. uint8_t entry_type; /* Entry type. */
  1074. uint8_t entry_count; /* Entry count. */
  1075. uint8_t sys_define; /* System defined. */
  1076. uint8_t entry_status; /* Entry Status. */
  1077. uint32_t handle; /* System handle. */
  1078. target_id_t target; /* SCSI ID */
  1079. uint16_t lun; /* SCSI LUN */
  1080. uint16_t control_flags; /* Control flags. */
  1081. #define CF_WRITE BIT_6
  1082. #define CF_READ BIT_5
  1083. #define CF_SIMPLE_TAG BIT_3
  1084. #define CF_ORDERED_TAG BIT_2
  1085. #define CF_HEAD_TAG BIT_1
  1086. uint16_t reserved_1;
  1087. uint16_t timeout; /* Command timeout. */
  1088. uint16_t dseg_count; /* Data segment count. */
  1089. uint8_t scsi_cdb[MAX_CMDSZ]; /* SCSI command words. */
  1090. uint32_t byte_count; /* Total byte count. */
  1091. uint32_t dseg_0_address; /* Data segment 0 address. */
  1092. uint32_t dseg_0_length; /* Data segment 0 length. */
  1093. uint32_t dseg_1_address; /* Data segment 1 address. */
  1094. uint32_t dseg_1_length; /* Data segment 1 length. */
  1095. uint32_t dseg_2_address; /* Data segment 2 address. */
  1096. uint32_t dseg_2_length; /* Data segment 2 length. */
  1097. } cmd_entry_t;
  1098. /*
  1099. * ISP queue - 64-Bit addressing, command entry structure definition.
  1100. */
  1101. #define COMMAND_A64_TYPE 0x19 /* Command A64 entry */
  1102. typedef struct {
  1103. uint8_t entry_type; /* Entry type. */
  1104. uint8_t entry_count; /* Entry count. */
  1105. uint8_t sys_define; /* System defined. */
  1106. uint8_t entry_status; /* Entry Status. */
  1107. uint32_t handle; /* System handle. */
  1108. target_id_t target; /* SCSI ID */
  1109. uint16_t lun; /* SCSI LUN */
  1110. uint16_t control_flags; /* Control flags. */
  1111. uint16_t reserved_1;
  1112. uint16_t timeout; /* Command timeout. */
  1113. uint16_t dseg_count; /* Data segment count. */
  1114. uint8_t scsi_cdb[MAX_CMDSZ]; /* SCSI command words. */
  1115. uint32_t byte_count; /* Total byte count. */
  1116. uint32_t dseg_0_address[2]; /* Data segment 0 address. */
  1117. uint32_t dseg_0_length; /* Data segment 0 length. */
  1118. uint32_t dseg_1_address[2]; /* Data segment 1 address. */
  1119. uint32_t dseg_1_length; /* Data segment 1 length. */
  1120. } cmd_a64_entry_t, request_t;
  1121. /*
  1122. * ISP queue - continuation entry structure definition.
  1123. */
  1124. #define CONTINUE_TYPE 0x02 /* Continuation entry. */
  1125. typedef struct {
  1126. uint8_t entry_type; /* Entry type. */
  1127. uint8_t entry_count; /* Entry count. */
  1128. uint8_t sys_define; /* System defined. */
  1129. uint8_t entry_status; /* Entry Status. */
  1130. uint32_t reserved;
  1131. uint32_t dseg_0_address; /* Data segment 0 address. */
  1132. uint32_t dseg_0_length; /* Data segment 0 length. */
  1133. uint32_t dseg_1_address; /* Data segment 1 address. */
  1134. uint32_t dseg_1_length; /* Data segment 1 length. */
  1135. uint32_t dseg_2_address; /* Data segment 2 address. */
  1136. uint32_t dseg_2_length; /* Data segment 2 length. */
  1137. uint32_t dseg_3_address; /* Data segment 3 address. */
  1138. uint32_t dseg_3_length; /* Data segment 3 length. */
  1139. uint32_t dseg_4_address; /* Data segment 4 address. */
  1140. uint32_t dseg_4_length; /* Data segment 4 length. */
  1141. uint32_t dseg_5_address; /* Data segment 5 address. */
  1142. uint32_t dseg_5_length; /* Data segment 5 length. */
  1143. uint32_t dseg_6_address; /* Data segment 6 address. */
  1144. uint32_t dseg_6_length; /* Data segment 6 length. */
  1145. } cont_entry_t;
  1146. /*
  1147. * ISP queue - 64-Bit addressing, continuation entry structure definition.
  1148. */
  1149. #define CONTINUE_A64_TYPE 0x0A /* Continuation A64 entry. */
  1150. typedef struct {
  1151. uint8_t entry_type; /* Entry type. */
  1152. uint8_t entry_count; /* Entry count. */
  1153. uint8_t sys_define; /* System defined. */
  1154. uint8_t entry_status; /* Entry Status. */
  1155. uint32_t dseg_0_address[2]; /* Data segment 0 address. */
  1156. uint32_t dseg_0_length; /* Data segment 0 length. */
  1157. uint32_t dseg_1_address[2]; /* Data segment 1 address. */
  1158. uint32_t dseg_1_length; /* Data segment 1 length. */
  1159. uint32_t dseg_2_address [2]; /* Data segment 2 address. */
  1160. uint32_t dseg_2_length; /* Data segment 2 length. */
  1161. uint32_t dseg_3_address[2]; /* Data segment 3 address. */
  1162. uint32_t dseg_3_length; /* Data segment 3 length. */
  1163. uint32_t dseg_4_address[2]; /* Data segment 4 address. */
  1164. uint32_t dseg_4_length; /* Data segment 4 length. */
  1165. } cont_a64_entry_t;
  1166. /*
  1167. * ISP queue - status entry structure definition.
  1168. */
  1169. #define STATUS_TYPE 0x03 /* Status entry. */
  1170. typedef struct {
  1171. uint8_t entry_type; /* Entry type. */
  1172. uint8_t entry_count; /* Entry count. */
  1173. uint8_t sys_define; /* System defined. */
  1174. uint8_t entry_status; /* Entry Status. */
  1175. uint32_t handle; /* System handle. */
  1176. uint16_t scsi_status; /* SCSI status. */
  1177. uint16_t comp_status; /* Completion status. */
  1178. uint16_t state_flags; /* State flags. */
  1179. uint16_t status_flags; /* Status flags. */
  1180. uint16_t rsp_info_len; /* Response Info Length. */
  1181. uint16_t req_sense_length; /* Request sense data length. */
  1182. uint32_t residual_length; /* Residual transfer length. */
  1183. uint8_t rsp_info[8]; /* FCP response information. */
  1184. uint8_t req_sense_data[32]; /* Request sense data. */
  1185. } sts_entry_t;
  1186. /*
  1187. * Status entry entry status
  1188. */
  1189. #define RF_INV_E_ORDER BIT_5 /* Invalid entry order. */
  1190. #define RF_INV_E_COUNT BIT_4 /* Invalid entry count. */
  1191. #define RF_INV_E_PARAM BIT_3 /* Invalid entry parameter. */
  1192. #define RF_INV_E_TYPE BIT_2 /* Invalid entry type. */
  1193. #define RF_BUSY BIT_1 /* Busy */
  1194. /*
  1195. * Status entry SCSI status bit definitions.
  1196. */
  1197. #define SS_MASK 0xfff /* Reserved bits BIT_12-BIT_15*/
  1198. #define SS_RESIDUAL_UNDER BIT_11
  1199. #define SS_RESIDUAL_OVER BIT_10
  1200. #define SS_SENSE_LEN_VALID BIT_9
  1201. #define SS_RESPONSE_INFO_LEN_VALID BIT_8
  1202. #define SS_RESERVE_CONFLICT (BIT_4 | BIT_3)
  1203. #define SS_BUSY_CONDITION BIT_3
  1204. #define SS_CONDITION_MET BIT_2
  1205. #define SS_CHECK_CONDITION BIT_1
  1206. /*
  1207. * Status entry completion status
  1208. */
  1209. #define CS_COMPLETE 0x0 /* No errors */
  1210. #define CS_INCOMPLETE 0x1 /* Incomplete transfer of cmd. */
  1211. #define CS_DMA 0x2 /* A DMA direction error. */
  1212. #define CS_TRANSPORT 0x3 /* Transport error. */
  1213. #define CS_RESET 0x4 /* SCSI bus reset occurred */
  1214. #define CS_ABORTED 0x5 /* System aborted command. */
  1215. #define CS_TIMEOUT 0x6 /* Timeout error. */
  1216. #define CS_DATA_OVERRUN 0x7 /* Data overrun. */
  1217. #define CS_DATA_UNDERRUN 0x15 /* Data Underrun. */
  1218. #define CS_QUEUE_FULL 0x1C /* Queue Full. */
  1219. #define CS_PORT_UNAVAILABLE 0x28 /* Port unavailable */
  1220. /* (selection timeout) */
  1221. #define CS_PORT_LOGGED_OUT 0x29 /* Port Logged Out */
  1222. #define CS_PORT_CONFIG_CHG 0x2A /* Port Configuration Changed */
  1223. #define CS_PORT_BUSY 0x2B /* Port Busy */
  1224. #define CS_COMPLETE_CHKCOND 0x30 /* Error? */
  1225. #define CS_BAD_PAYLOAD 0x80 /* Driver defined */
  1226. #define CS_UNKNOWN 0x81 /* Driver defined */
  1227. #define CS_RETRY 0x82 /* Driver defined */
  1228. #define CS_LOOP_DOWN_ABORT 0x83 /* Driver defined */
  1229. /*
  1230. * Status entry status flags
  1231. */
  1232. #define SF_ABTS_TERMINATED BIT_10
  1233. #define SF_LOGOUT_SENT BIT_13
  1234. /*
  1235. * ISP queue - status continuation entry structure definition.
  1236. */
  1237. #define STATUS_CONT_TYPE 0x10 /* Status continuation entry. */
  1238. typedef struct {
  1239. uint8_t entry_type; /* Entry type. */
  1240. uint8_t entry_count; /* Entry count. */
  1241. uint8_t sys_define; /* System defined. */
  1242. uint8_t entry_status; /* Entry Status. */
  1243. uint8_t data[60]; /* data */
  1244. } sts_cont_entry_t;
  1245. /*
  1246. * ISP queue - RIO Type 1 status entry (32 bit I/O entry handles)
  1247. * structure definition.
  1248. */
  1249. #define STATUS_TYPE_21 0x21 /* Status entry. */
  1250. typedef struct {
  1251. uint8_t entry_type; /* Entry type. */
  1252. uint8_t entry_count; /* Entry count. */
  1253. uint8_t handle_count; /* Handle count. */
  1254. uint8_t entry_status; /* Entry Status. */
  1255. uint32_t handle[15]; /* System handles. */
  1256. } sts21_entry_t;
  1257. /*
  1258. * ISP queue - RIO Type 2 status entry (16 bit I/O entry handles)
  1259. * structure definition.
  1260. */
  1261. #define STATUS_TYPE_22 0x22 /* Status entry. */
  1262. typedef struct {
  1263. uint8_t entry_type; /* Entry type. */
  1264. uint8_t entry_count; /* Entry count. */
  1265. uint8_t handle_count; /* Handle count. */
  1266. uint8_t entry_status; /* Entry Status. */
  1267. uint16_t handle[30]; /* System handles. */
  1268. } sts22_entry_t;
  1269. /*
  1270. * ISP queue - marker entry structure definition.
  1271. */
  1272. #define MARKER_TYPE 0x04 /* Marker entry. */
  1273. typedef struct {
  1274. uint8_t entry_type; /* Entry type. */
  1275. uint8_t entry_count; /* Entry count. */
  1276. uint8_t handle_count; /* Handle count. */
  1277. uint8_t entry_status; /* Entry Status. */
  1278. uint32_t sys_define_2; /* System defined. */
  1279. target_id_t target; /* SCSI ID */
  1280. uint8_t modifier; /* Modifier (7-0). */
  1281. #define MK_SYNC_ID_LUN 0 /* Synchronize ID/LUN */
  1282. #define MK_SYNC_ID 1 /* Synchronize ID */
  1283. #define MK_SYNC_ALL 2 /* Synchronize all ID/LUN */
  1284. #define MK_SYNC_LIP 3 /* Synchronize all ID/LUN, */
  1285. /* clear port changed, */
  1286. /* use sequence number. */
  1287. uint8_t reserved_1;
  1288. uint16_t sequence_number; /* Sequence number of event */
  1289. uint16_t lun; /* SCSI LUN */
  1290. uint8_t reserved_2[48];
  1291. } mrk_entry_t;
  1292. /*
  1293. * ISP queue - Management Server entry structure definition.
  1294. */
  1295. #define MS_IOCB_TYPE 0x29 /* Management Server IOCB entry */
  1296. typedef struct {
  1297. uint8_t entry_type; /* Entry type. */
  1298. uint8_t entry_count; /* Entry count. */
  1299. uint8_t handle_count; /* Handle count. */
  1300. uint8_t entry_status; /* Entry Status. */
  1301. uint32_t handle1; /* System handle. */
  1302. target_id_t loop_id;
  1303. uint16_t status;
  1304. uint16_t control_flags; /* Control flags. */
  1305. uint16_t reserved2;
  1306. uint16_t timeout;
  1307. uint16_t cmd_dsd_count;
  1308. uint16_t total_dsd_count;
  1309. uint8_t type;
  1310. uint8_t r_ctl;
  1311. uint16_t rx_id;
  1312. uint16_t reserved3;
  1313. uint32_t handle2;
  1314. uint32_t rsp_bytecount;
  1315. uint32_t req_bytecount;
  1316. uint32_t dseg_req_address[2]; /* Data segment 0 address. */
  1317. uint32_t dseg_req_length; /* Data segment 0 length. */
  1318. uint32_t dseg_rsp_address[2]; /* Data segment 1 address. */
  1319. uint32_t dseg_rsp_length; /* Data segment 1 length. */
  1320. } ms_iocb_entry_t;
  1321. /*
  1322. * ISP queue - Mailbox Command entry structure definition.
  1323. */
  1324. #define MBX_IOCB_TYPE 0x39
  1325. struct mbx_entry {
  1326. uint8_t entry_type;
  1327. uint8_t entry_count;
  1328. uint8_t sys_define1;
  1329. /* Use sys_define1 for source type */
  1330. #define SOURCE_SCSI 0x00
  1331. #define SOURCE_IP 0x01
  1332. #define SOURCE_VI 0x02
  1333. #define SOURCE_SCTP 0x03
  1334. #define SOURCE_MP 0x04
  1335. #define SOURCE_MPIOCTL 0x05
  1336. #define SOURCE_ASYNC_IOCB 0x07
  1337. uint8_t entry_status;
  1338. uint32_t handle;
  1339. target_id_t loop_id;
  1340. uint16_t status;
  1341. uint16_t state_flags;
  1342. uint16_t status_flags;
  1343. uint32_t sys_define2[2];
  1344. uint16_t mb0;
  1345. uint16_t mb1;
  1346. uint16_t mb2;
  1347. uint16_t mb3;
  1348. uint16_t mb6;
  1349. uint16_t mb7;
  1350. uint16_t mb9;
  1351. uint16_t mb10;
  1352. uint32_t reserved_2[2];
  1353. uint8_t node_name[WWN_SIZE];
  1354. uint8_t port_name[WWN_SIZE];
  1355. };
  1356. /*
  1357. * ISP request and response queue entry sizes
  1358. */
  1359. #define RESPONSE_ENTRY_SIZE (sizeof(response_t))
  1360. #define REQUEST_ENTRY_SIZE (sizeof(request_t))
  1361. /*
  1362. * 24 bit port ID type definition.
  1363. */
  1364. typedef union {
  1365. uint32_t b24 : 24;
  1366. struct {
  1367. uint8_t d_id[3];
  1368. uint8_t rsvd_1;
  1369. } r;
  1370. struct {
  1371. uint8_t al_pa;
  1372. uint8_t area;
  1373. uint8_t domain;
  1374. uint8_t rsvd_1;
  1375. } b;
  1376. } port_id_t;
  1377. #define INVALID_PORT_ID 0xFFFFFF
  1378. /*
  1379. * Switch info gathering structure.
  1380. */
  1381. typedef struct {
  1382. port_id_t d_id;
  1383. uint8_t node_name[WWN_SIZE];
  1384. uint8_t port_name[WWN_SIZE];
  1385. uint32_t type;
  1386. #define SW_TYPE_IP BIT_1
  1387. #define SW_TYPE_SCSI BIT_0
  1388. } sw_info_t;
  1389. /*
  1390. * Inquiry command structure.
  1391. */
  1392. #define INQ_DATA_SIZE 36
  1393. /*
  1394. * Inquiry mailbox IOCB packet definition.
  1395. */
  1396. typedef struct {
  1397. union {
  1398. cmd_a64_entry_t cmd;
  1399. sts_entry_t rsp;
  1400. } p;
  1401. uint8_t inq[INQ_DATA_SIZE];
  1402. } inq_cmd_rsp_t;
  1403. /*
  1404. * Report LUN command structure.
  1405. */
  1406. #define CHAR_TO_SHORT(a, b) (uint16_t)((uint8_t)b << 8 | (uint8_t)a)
  1407. typedef struct {
  1408. uint32_t len;
  1409. uint32_t rsrv;
  1410. } rpt_hdr_t;
  1411. typedef struct {
  1412. struct {
  1413. uint8_t b : 6;
  1414. uint8_t address_method : 2;
  1415. } msb;
  1416. uint8_t lsb;
  1417. uint8_t unused[6];
  1418. } rpt_lun_t;
  1419. typedef struct {
  1420. rpt_hdr_t hdr;
  1421. rpt_lun_t lst[MAX_LUNS];
  1422. } rpt_lun_lst_t;
  1423. /*
  1424. * Report Lun mailbox IOCB packet definition.
  1425. */
  1426. typedef struct {
  1427. union {
  1428. cmd_a64_entry_t cmd;
  1429. sts_entry_t rsp;
  1430. } p;
  1431. rpt_lun_lst_t list;
  1432. } rpt_lun_cmd_rsp_t;
  1433. /*
  1434. * Fibre channel port type.
  1435. */
  1436. typedef enum {
  1437. FCT_UNKNOWN,
  1438. FCT_RSCN,
  1439. FCT_SWITCH,
  1440. FCT_BROADCAST,
  1441. FCT_INITIATOR,
  1442. FCT_TARGET
  1443. } fc_port_type_t;
  1444. /*
  1445. * Fibre channel port structure.
  1446. */
  1447. typedef struct fc_port {
  1448. struct list_head list;
  1449. struct scsi_qla_host *ha;
  1450. struct scsi_qla_host *vis_ha; /* only used when suspending lun */
  1451. uint8_t node_name[WWN_SIZE];
  1452. uint8_t port_name[WWN_SIZE];
  1453. port_id_t d_id;
  1454. uint16_t loop_id;
  1455. uint16_t old_loop_id;
  1456. fc_port_type_t port_type;
  1457. atomic_t state;
  1458. uint32_t flags;
  1459. unsigned int os_target_id;
  1460. uint16_t iodesc_idx_sent;
  1461. int port_login_retry_count;
  1462. int login_retry;
  1463. atomic_t port_down_timer;
  1464. uint8_t device_type;
  1465. uint8_t unused;
  1466. uint8_t mp_byte; /* multi-path byte (not used) */
  1467. uint8_t cur_path; /* current path id */
  1468. struct fc_rport *rport;
  1469. } fc_port_t;
  1470. /*
  1471. * Fibre channel port/lun states.
  1472. */
  1473. #define FCS_UNCONFIGURED 1
  1474. #define FCS_DEVICE_DEAD 2
  1475. #define FCS_DEVICE_LOST 3
  1476. #define FCS_ONLINE 4
  1477. #define FCS_NOT_SUPPORTED 5
  1478. #define FCS_FAILOVER 6
  1479. #define FCS_FAILOVER_FAILED 7
  1480. /*
  1481. * FC port flags.
  1482. */
  1483. #define FCF_FABRIC_DEVICE BIT_0
  1484. #define FCF_LOGIN_NEEDED BIT_1
  1485. #define FCF_FO_MASKED BIT_2
  1486. #define FCF_FAILOVER_NEEDED BIT_3
  1487. #define FCF_RESET_NEEDED BIT_4
  1488. #define FCF_PERSISTENT_BOUND BIT_5
  1489. #define FCF_TAPE_PRESENT BIT_6
  1490. #define FCF_FARP_DONE BIT_7
  1491. #define FCF_FARP_FAILED BIT_8
  1492. #define FCF_FARP_REPLY_NEEDED BIT_9
  1493. #define FCF_AUTH_REQ BIT_10
  1494. #define FCF_SEND_AUTH_REQ BIT_11
  1495. #define FCF_RECEIVE_AUTH_REQ BIT_12
  1496. #define FCF_AUTH_SUCCESS BIT_13
  1497. #define FCF_RLC_SUPPORT BIT_14
  1498. #define FCF_CONFIG BIT_15 /* Needed? */
  1499. #define FCF_RESCAN_NEEDED BIT_16
  1500. #define FCF_XP_DEVICE BIT_17
  1501. #define FCF_MSA_DEVICE BIT_18
  1502. #define FCF_EVA_DEVICE BIT_19
  1503. #define FCF_MSA_PORT_ACTIVE BIT_20
  1504. #define FCF_FAILBACK_DISABLE BIT_21
  1505. #define FCF_FAILOVER_DISABLE BIT_22
  1506. #define FCF_DSXXX_DEVICE BIT_23
  1507. #define FCF_AA_EVA_DEVICE BIT_24
  1508. /* No loop ID flag. */
  1509. #define FC_NO_LOOP_ID 0x1000
  1510. /*
  1511. * FC-CT interface
  1512. *
  1513. * NOTE: All structures are big-endian in form.
  1514. */
  1515. #define CT_REJECT_RESPONSE 0x8001
  1516. #define CT_ACCEPT_RESPONSE 0x8002
  1517. #define NS_N_PORT_TYPE 0x01
  1518. #define NS_NL_PORT_TYPE 0x02
  1519. #define NS_NX_PORT_TYPE 0x7F
  1520. #define GA_NXT_CMD 0x100
  1521. #define GA_NXT_REQ_SIZE (16 + 4)
  1522. #define GA_NXT_RSP_SIZE (16 + 620)
  1523. #define GID_PT_CMD 0x1A1
  1524. #define GID_PT_REQ_SIZE (16 + 4)
  1525. #define GID_PT_RSP_SIZE (16 + (MAX_FIBRE_DEVICES * 4))
  1526. #define GPN_ID_CMD 0x112
  1527. #define GPN_ID_REQ_SIZE (16 + 4)
  1528. #define GPN_ID_RSP_SIZE (16 + 8)
  1529. #define GNN_ID_CMD 0x113
  1530. #define GNN_ID_REQ_SIZE (16 + 4)
  1531. #define GNN_ID_RSP_SIZE (16 + 8)
  1532. #define GFT_ID_CMD 0x117
  1533. #define GFT_ID_REQ_SIZE (16 + 4)
  1534. #define GFT_ID_RSP_SIZE (16 + 32)
  1535. #define RFT_ID_CMD 0x217
  1536. #define RFT_ID_REQ_SIZE (16 + 4 + 32)
  1537. #define RFT_ID_RSP_SIZE 16
  1538. #define RFF_ID_CMD 0x21F
  1539. #define RFF_ID_REQ_SIZE (16 + 4 + 2 + 1 + 1)
  1540. #define RFF_ID_RSP_SIZE 16
  1541. #define RNN_ID_CMD 0x213
  1542. #define RNN_ID_REQ_SIZE (16 + 4 + 8)
  1543. #define RNN_ID_RSP_SIZE 16
  1544. #define RSNN_NN_CMD 0x239
  1545. #define RSNN_NN_REQ_SIZE (16 + 8 + 1 + 255)
  1546. #define RSNN_NN_RSP_SIZE 16
  1547. /* CT command header -- request/response common fields */
  1548. struct ct_cmd_hdr {
  1549. uint8_t revision;
  1550. uint8_t in_id[3];
  1551. uint8_t gs_type;
  1552. uint8_t gs_subtype;
  1553. uint8_t options;
  1554. uint8_t reserved;
  1555. };
  1556. /* CT command request */
  1557. struct ct_sns_req {
  1558. struct ct_cmd_hdr header;
  1559. uint16_t command;
  1560. uint16_t max_rsp_size;
  1561. uint8_t fragment_id;
  1562. uint8_t reserved[3];
  1563. union {
  1564. /* GA_NXT, GPN_ID, GNN_ID, GFT_ID */
  1565. struct {
  1566. uint8_t reserved;
  1567. uint8_t port_id[3];
  1568. } port_id;
  1569. struct {
  1570. uint8_t port_type;
  1571. uint8_t domain;
  1572. uint8_t area;
  1573. uint8_t reserved;
  1574. } gid_pt;
  1575. struct {
  1576. uint8_t reserved;
  1577. uint8_t port_id[3];
  1578. uint8_t fc4_types[32];
  1579. } rft_id;
  1580. struct {
  1581. uint8_t reserved;
  1582. uint8_t port_id[3];
  1583. uint16_t reserved2;
  1584. uint8_t fc4_feature;
  1585. uint8_t fc4_type;
  1586. } rff_id;
  1587. struct {
  1588. uint8_t reserved;
  1589. uint8_t port_id[3];
  1590. uint8_t node_name[8];
  1591. } rnn_id;
  1592. struct {
  1593. uint8_t node_name[8];
  1594. uint8_t name_len;
  1595. uint8_t sym_node_name[255];
  1596. } rsnn_nn;
  1597. } req;
  1598. };
  1599. /* CT command response header */
  1600. struct ct_rsp_hdr {
  1601. struct ct_cmd_hdr header;
  1602. uint16_t response;
  1603. uint16_t residual;
  1604. uint8_t fragment_id;
  1605. uint8_t reason_code;
  1606. uint8_t explanation_code;
  1607. uint8_t vendor_unique;
  1608. };
  1609. struct ct_sns_gid_pt_data {
  1610. uint8_t control_byte;
  1611. uint8_t port_id[3];
  1612. };
  1613. struct ct_sns_rsp {
  1614. struct ct_rsp_hdr header;
  1615. union {
  1616. struct {
  1617. uint8_t port_type;
  1618. uint8_t port_id[3];
  1619. uint8_t port_name[8];
  1620. uint8_t sym_port_name_len;
  1621. uint8_t sym_port_name[255];
  1622. uint8_t node_name[8];
  1623. uint8_t sym_node_name_len;
  1624. uint8_t sym_node_name[255];
  1625. uint8_t init_proc_assoc[8];
  1626. uint8_t node_ip_addr[16];
  1627. uint8_t class_of_service[4];
  1628. uint8_t fc4_types[32];
  1629. uint8_t ip_address[16];
  1630. uint8_t fabric_port_name[8];
  1631. uint8_t reserved;
  1632. uint8_t hard_address[3];
  1633. } ga_nxt;
  1634. struct {
  1635. struct ct_sns_gid_pt_data entries[MAX_FIBRE_DEVICES];
  1636. } gid_pt;
  1637. struct {
  1638. uint8_t port_name[8];
  1639. } gpn_id;
  1640. struct {
  1641. uint8_t node_name[8];
  1642. } gnn_id;
  1643. struct {
  1644. uint8_t fc4_types[32];
  1645. } gft_id;
  1646. } rsp;
  1647. };
  1648. struct ct_sns_pkt {
  1649. union {
  1650. struct ct_sns_req req;
  1651. struct ct_sns_rsp rsp;
  1652. } p;
  1653. };
  1654. /*
  1655. * SNS command structures -- for 2200 compatability.
  1656. */
  1657. #define RFT_ID_SNS_SCMD_LEN 22
  1658. #define RFT_ID_SNS_CMD_SIZE 60
  1659. #define RFT_ID_SNS_DATA_SIZE 16
  1660. #define RNN_ID_SNS_SCMD_LEN 10
  1661. #define RNN_ID_SNS_CMD_SIZE 36
  1662. #define RNN_ID_SNS_DATA_SIZE 16
  1663. #define GA_NXT_SNS_SCMD_LEN 6
  1664. #define GA_NXT_SNS_CMD_SIZE 28
  1665. #define GA_NXT_SNS_DATA_SIZE (620 + 16)
  1666. #define GID_PT_SNS_SCMD_LEN 6
  1667. #define GID_PT_SNS_CMD_SIZE 28
  1668. #define GID_PT_SNS_DATA_SIZE (MAX_FIBRE_DEVICES * 4 + 16)
  1669. #define GPN_ID_SNS_SCMD_LEN 6
  1670. #define GPN_ID_SNS_CMD_SIZE 28
  1671. #define GPN_ID_SNS_DATA_SIZE (8 + 16)
  1672. #define GNN_ID_SNS_SCMD_LEN 6
  1673. #define GNN_ID_SNS_CMD_SIZE 28
  1674. #define GNN_ID_SNS_DATA_SIZE (8 + 16)
  1675. struct sns_cmd_pkt {
  1676. union {
  1677. struct {
  1678. uint16_t buffer_length;
  1679. uint16_t reserved_1;
  1680. uint32_t buffer_address[2];
  1681. uint16_t subcommand_length;
  1682. uint16_t reserved_2;
  1683. uint16_t subcommand;
  1684. uint16_t size;
  1685. uint32_t reserved_3;
  1686. uint8_t param[36];
  1687. } cmd;
  1688. uint8_t rft_data[RFT_ID_SNS_DATA_SIZE];
  1689. uint8_t rnn_data[RNN_ID_SNS_DATA_SIZE];
  1690. uint8_t gan_data[GA_NXT_SNS_DATA_SIZE];
  1691. uint8_t gid_data[GID_PT_SNS_DATA_SIZE];
  1692. uint8_t gpn_data[GPN_ID_SNS_DATA_SIZE];
  1693. uint8_t gnn_data[GNN_ID_SNS_DATA_SIZE];
  1694. } p;
  1695. };
  1696. /* IO descriptors */
  1697. #define MAX_IO_DESCRIPTORS 32
  1698. #define ABORT_IOCB_CB 0
  1699. #define ADISC_PORT_IOCB_CB 1
  1700. #define LOGOUT_PORT_IOCB_CB 2
  1701. #define LOGIN_PORT_IOCB_CB 3
  1702. #define LAST_IOCB_CB 4
  1703. #define IODESC_INVALID_INDEX 0xFFFF
  1704. #define IODESC_ADISC_NEEDED 0xFFFE
  1705. #define IODESC_LOGIN_NEEDED 0xFFFD
  1706. struct io_descriptor {
  1707. uint16_t used:1;
  1708. uint16_t idx:11;
  1709. uint16_t cb_idx:4;
  1710. struct timer_list timer;
  1711. struct scsi_qla_host *ha;
  1712. port_id_t d_id;
  1713. fc_port_t *remote_fcport;
  1714. uint32_t signature;
  1715. };
  1716. struct qla_fw_info {
  1717. unsigned short addressing; /* addressing method used to load fw */
  1718. #define FW_INFO_ADDR_NORMAL 0
  1719. #define FW_INFO_ADDR_EXTENDED 1
  1720. #define FW_INFO_ADDR_NOMORE 0xffff
  1721. unsigned short *fwcode; /* pointer to FW array */
  1722. unsigned short *fwlen; /* number of words in array */
  1723. unsigned short *fwstart; /* start address for F/W */
  1724. unsigned long *lfwstart; /* start address (long) for F/W */
  1725. };
  1726. struct qla_board_info {
  1727. char *drv_name;
  1728. char isp_name[8];
  1729. struct qla_fw_info *fw_info;
  1730. };
  1731. /* Return data from MBC_GET_ID_LIST call. */
  1732. struct gid_list_info {
  1733. uint8_t al_pa;
  1734. uint8_t area;
  1735. uint8_t domain;
  1736. uint8_t loop_id_2100; /* ISP2100/ISP2200 -- 4 bytes. */
  1737. uint16_t loop_id; /* ISP23XX -- 6 bytes. */
  1738. };
  1739. #define GID_LIST_SIZE (sizeof(struct gid_list_info) * MAX_FIBRE_DEVICES)
  1740. /*
  1741. * ISP operations
  1742. */
  1743. struct isp_operations {
  1744. int (*pci_config) (struct scsi_qla_host *);
  1745. void (*reset_chip) (struct scsi_qla_host *);
  1746. int (*chip_diag) (struct scsi_qla_host *);
  1747. void (*config_rings) (struct scsi_qla_host *);
  1748. void (*reset_adapter) (struct scsi_qla_host *);
  1749. int (*nvram_config) (struct scsi_qla_host *);
  1750. void (*update_fw_options) (struct scsi_qla_host *);
  1751. int (*load_risc) (struct scsi_qla_host *, uint32_t *);
  1752. char * (*pci_info_str) (struct scsi_qla_host *, char *);
  1753. char * (*fw_version_str) (struct scsi_qla_host *, char *);
  1754. irqreturn_t (*intr_handler) (int, void *, struct pt_regs *);
  1755. void (*enable_intrs) (struct scsi_qla_host *);
  1756. void (*disable_intrs) (struct scsi_qla_host *);
  1757. int (*abort_command) (struct scsi_qla_host *, srb_t *);
  1758. int (*abort_target) (struct fc_port *);
  1759. int (*fabric_login) (struct scsi_qla_host *, uint16_t, uint8_t,
  1760. uint8_t, uint8_t, uint16_t *, uint8_t);
  1761. int (*fabric_logout) (struct scsi_qla_host *, uint16_t);
  1762. uint16_t (*calc_req_entries) (uint16_t);
  1763. void (*build_iocbs) (srb_t *, cmd_entry_t *, uint16_t);
  1764. ms_iocb_entry_t * (*prep_ms_iocb) (struct scsi_qla_host *, uint32_t,
  1765. uint32_t);
  1766. uint8_t * (*read_nvram) (struct scsi_qla_host *, uint8_t *,
  1767. uint32_t, uint32_t);
  1768. int (*write_nvram) (struct scsi_qla_host *, uint8_t *, uint32_t,
  1769. uint32_t);
  1770. void (*fw_dump) (struct scsi_qla_host *, int);
  1771. void (*ascii_fw_dump) (struct scsi_qla_host *);
  1772. };
  1773. /*
  1774. * Linux Host Adapter structure
  1775. */
  1776. typedef struct scsi_qla_host {
  1777. struct list_head list;
  1778. /* Commonly used flags and state information. */
  1779. struct Scsi_Host *host;
  1780. struct pci_dev *pdev;
  1781. unsigned long host_no;
  1782. unsigned long instance;
  1783. volatile struct {
  1784. uint32_t init_done :1;
  1785. uint32_t online :1;
  1786. uint32_t mbox_int :1;
  1787. uint32_t mbox_busy :1;
  1788. uint32_t rscn_queue_overflow :1;
  1789. uint32_t reset_active :1;
  1790. uint32_t management_server_logged_in :1;
  1791. uint32_t process_response_queue :1;
  1792. uint32_t disable_risc_code_load :1;
  1793. uint32_t enable_64bit_addressing :1;
  1794. uint32_t enable_lip_reset :1;
  1795. uint32_t enable_lip_full_login :1;
  1796. uint32_t enable_target_reset :1;
  1797. uint32_t enable_led_scheme :1;
  1798. } flags;
  1799. atomic_t loop_state;
  1800. #define LOOP_TIMEOUT 1
  1801. #define LOOP_DOWN 2
  1802. #define LOOP_UP 3
  1803. #define LOOP_UPDATE 4
  1804. #define LOOP_READY 5
  1805. #define LOOP_DEAD 6
  1806. unsigned long dpc_flags;
  1807. #define RESET_MARKER_NEEDED 0 /* Send marker to ISP. */
  1808. #define RESET_ACTIVE 1
  1809. #define ISP_ABORT_NEEDED 2 /* Initiate ISP abort. */
  1810. #define ABORT_ISP_ACTIVE 3 /* ISP abort in progress. */
  1811. #define LOOP_RESYNC_NEEDED 4 /* Device Resync needed. */
  1812. #define LOOP_RESYNC_ACTIVE 5
  1813. #define LOCAL_LOOP_UPDATE 6 /* Perform a local loop update. */
  1814. #define RSCN_UPDATE 7 /* Perform an RSCN update. */
  1815. #define MAILBOX_RETRY 8
  1816. #define ISP_RESET_NEEDED 9 /* Initiate a ISP reset. */
  1817. #define FAILOVER_EVENT_NEEDED 10
  1818. #define FAILOVER_EVENT 11
  1819. #define FAILOVER_NEEDED 12
  1820. #define SCSI_RESTART_NEEDED 13 /* Processes SCSI retry queue. */
  1821. #define PORT_RESTART_NEEDED 14 /* Processes Retry queue. */
  1822. #define RESTART_QUEUES_NEEDED 15 /* Restarts the Lun queue. */
  1823. #define ABORT_QUEUES_NEEDED 16
  1824. #define RELOGIN_NEEDED 17
  1825. #define LOGIN_RETRY_NEEDED 18 /* Initiate required fabric logins. */
  1826. #define REGISTER_FC4_NEEDED 19 /* SNS FC4 registration required. */
  1827. #define ISP_ABORT_RETRY 20 /* ISP aborted. */
  1828. #define FCPORT_RESCAN_NEEDED 21 /* IO descriptor processing needed */
  1829. #define IODESC_PROCESS_NEEDED 22 /* IO descriptor processing needed */
  1830. #define IOCTL_ERROR_RECOVERY 23
  1831. #define LOOP_RESET_NEEDED 24
  1832. uint32_t device_flags;
  1833. #define DFLG_LOCAL_DEVICES BIT_0
  1834. #define DFLG_RETRY_LOCAL_DEVICES BIT_1
  1835. #define DFLG_FABRIC_DEVICES BIT_2
  1836. #define SWITCH_FOUND BIT_3
  1837. #define DFLG_NO_CABLE BIT_4
  1838. /* SRB cache. */
  1839. #define SRB_MIN_REQ 128
  1840. mempool_t *srb_mempool;
  1841. /* This spinlock is used to protect "io transactions", you must
  1842. * aquire it before doing any IO to the card, eg with RD_REG*() and
  1843. * WRT_REG*() for the duration of your entire commandtransaction.
  1844. *
  1845. * This spinlock is of lower priority than the io request lock.
  1846. */
  1847. spinlock_t hardware_lock ____cacheline_aligned;
  1848. device_reg_t __iomem *iobase; /* Base I/O address */
  1849. unsigned long pio_address;
  1850. unsigned long pio_length;
  1851. #define MIN_IOBASE_LEN 0x100
  1852. /* ISP ring lock, rings, and indexes */
  1853. dma_addr_t request_dma; /* Physical address. */
  1854. request_t *request_ring; /* Base virtual address */
  1855. request_t *request_ring_ptr; /* Current address. */
  1856. uint16_t req_ring_index; /* Current index. */
  1857. uint16_t req_q_cnt; /* Number of available entries. */
  1858. uint16_t request_q_length;
  1859. dma_addr_t response_dma; /* Physical address. */
  1860. response_t *response_ring; /* Base virtual address */
  1861. response_t *response_ring_ptr; /* Current address. */
  1862. uint16_t rsp_ring_index; /* Current index. */
  1863. uint16_t response_q_length;
  1864. struct isp_operations isp_ops;
  1865. /* Outstandings ISP commands. */
  1866. srb_t *outstanding_cmds[MAX_OUTSTANDING_COMMANDS];
  1867. uint32_t current_outstanding_cmd;
  1868. srb_t *status_srb; /* Status continuation entry. */
  1869. uint16_t revision;
  1870. uint8_t ports;
  1871. /* ISP configuration data. */
  1872. uint16_t loop_id; /* Host adapter loop id */
  1873. uint16_t fb_rev;
  1874. port_id_t d_id; /* Host adapter port id */
  1875. uint16_t max_public_loop_ids;
  1876. uint16_t min_external_loopid; /* First external loop Id */
  1877. uint16_t link_data_rate; /* F/W operating speed */
  1878. uint8_t current_topology;
  1879. uint8_t prev_topology;
  1880. #define ISP_CFG_NL 1
  1881. #define ISP_CFG_N 2
  1882. #define ISP_CFG_FL 4
  1883. #define ISP_CFG_F 8
  1884. uint8_t operating_mode; /* F/W operating mode */
  1885. #define LOOP 0
  1886. #define P2P 1
  1887. #define LOOP_P2P 2
  1888. #define P2P_LOOP 3
  1889. uint8_t marker_needed;
  1890. uint8_t interrupts_on;
  1891. /* HBA serial number */
  1892. uint8_t serial0;
  1893. uint8_t serial1;
  1894. uint8_t serial2;
  1895. /* NVRAM configuration data */
  1896. uint16_t nvram_base;
  1897. uint16_t loop_reset_delay;
  1898. uint8_t retry_count;
  1899. uint8_t login_timeout;
  1900. uint16_t r_a_tov;
  1901. int port_down_retry_count;
  1902. uint8_t mbx_count;
  1903. uint16_t last_loop_id;
  1904. uint32_t login_retry_count;
  1905. /* Fibre Channel Device List. */
  1906. struct list_head fcports;
  1907. struct list_head rscn_fcports;
  1908. struct io_descriptor io_descriptors[MAX_IO_DESCRIPTORS];
  1909. uint16_t iodesc_signature;
  1910. /* RSCN queue. */
  1911. uint32_t rscn_queue[MAX_RSCN_COUNT];
  1912. uint8_t rscn_in_ptr;
  1913. uint8_t rscn_out_ptr;
  1914. /* SNS command interfaces. */
  1915. ms_iocb_entry_t *ms_iocb;
  1916. dma_addr_t ms_iocb_dma;
  1917. struct ct_sns_pkt *ct_sns;
  1918. dma_addr_t ct_sns_dma;
  1919. /* SNS command interfaces for 2200. */
  1920. struct sns_cmd_pkt *sns_cmd;
  1921. dma_addr_t sns_cmd_dma;
  1922. pid_t dpc_pid;
  1923. int dpc_should_die;
  1924. struct completion dpc_inited;
  1925. struct completion dpc_exited;
  1926. struct semaphore *dpc_wait;
  1927. uint8_t dpc_active; /* DPC routine is active */
  1928. /* Timeout timers. */
  1929. uint8_t loop_down_abort_time; /* port down timer */
  1930. atomic_t loop_down_timer; /* loop down timer */
  1931. uint8_t link_down_timeout; /* link down timeout */
  1932. uint32_t timer_active;
  1933. struct timer_list timer;
  1934. dma_addr_t gid_list_dma;
  1935. struct gid_list_info *gid_list;
  1936. int gid_list_info_size;
  1937. dma_addr_t rlc_rsp_dma;
  1938. rpt_lun_cmd_rsp_t *rlc_rsp;
  1939. /* Small DMA pool allocations -- maximum 256 bytes in length. */
  1940. #define DMA_POOL_SIZE 256
  1941. struct dma_pool *s_dma_pool;
  1942. dma_addr_t init_cb_dma;
  1943. init_cb_t *init_cb;
  1944. dma_addr_t iodesc_pd_dma;
  1945. port_database_t *iodesc_pd;
  1946. /* These are used by mailbox operations. */
  1947. volatile uint16_t mailbox_out[MAILBOX_REGISTER_COUNT];
  1948. mbx_cmd_t *mcp;
  1949. unsigned long mbx_cmd_flags;
  1950. #define MBX_INTERRUPT 1
  1951. #define MBX_INTR_WAIT 2
  1952. #define MBX_UPDATE_FLASH_ACTIVE 3
  1953. spinlock_t mbx_reg_lock; /* Mbx Cmd Register Lock */
  1954. struct semaphore mbx_cmd_sem; /* Serialialize mbx access */
  1955. struct semaphore mbx_intr_sem; /* Used for completion notification */
  1956. uint32_t mbx_flags;
  1957. #define MBX_IN_PROGRESS BIT_0
  1958. #define MBX_BUSY BIT_1 /* Got the Access */
  1959. #define MBX_SLEEPING_ON_SEM BIT_2
  1960. #define MBX_POLLING_FOR_COMP BIT_3
  1961. #define MBX_COMPLETED BIT_4
  1962. #define MBX_TIMEDOUT BIT_5
  1963. #define MBX_ACCESS_TIMEDOUT BIT_6
  1964. mbx_cmd_t mc;
  1965. /* Basic firmware related information. */
  1966. struct qla_board_info *brd_info;
  1967. uint16_t fw_major_version;
  1968. uint16_t fw_minor_version;
  1969. uint16_t fw_subminor_version;
  1970. uint16_t fw_attributes;
  1971. uint32_t fw_memory_size;
  1972. uint32_t fw_transfer_size;
  1973. uint16_t fw_options[16]; /* slots: 1,2,3,10,11 */
  1974. uint8_t fw_seriallink_options[4];
  1975. /* Firmware dump information. */
  1976. void *fw_dump;
  1977. int fw_dump_order;
  1978. int fw_dump_reading;
  1979. char *fw_dump_buffer;
  1980. int fw_dump_buffer_len;
  1981. uint8_t host_str[16];
  1982. uint16_t pci_attr;
  1983. uint16_t product_id[4];
  1984. uint8_t model_number[16+1];
  1985. #define BINZERO "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
  1986. char *model_desc;
  1987. uint8_t node_name[WWN_SIZE];
  1988. uint8_t nvram_version;
  1989. uint32_t isp_abort_cnt;
  1990. /* Needed for BEACON */
  1991. uint16_t beacon_blink_led;
  1992. uint16_t beacon_green_on;
  1993. } scsi_qla_host_t;
  1994. /*
  1995. * Macros to help code, maintain, etc.
  1996. */
  1997. #define LOOP_TRANSITION(ha) \
  1998. (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \
  1999. test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))
  2000. #define LOOP_NOT_READY(ha) \
  2001. ((test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \
  2002. test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) || \
  2003. test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) || \
  2004. test_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags)) || \
  2005. atomic_read(&ha->loop_state) == LOOP_DOWN)
  2006. #define LOOP_RDY(ha) (!LOOP_NOT_READY(ha))
  2007. #define TGT_Q(ha, t) (ha->otgt[t])
  2008. #define to_qla_host(x) ((scsi_qla_host_t *) (x)->hostdata)
  2009. #define qla_printk(level, ha, format, arg...) \
  2010. dev_printk(level , &((ha)->pdev->dev) , format , ## arg)
  2011. /*
  2012. * qla2x00 local function return status codes
  2013. */
  2014. #define MBS_MASK 0x3fff
  2015. #define QLA_SUCCESS (MBS_COMMAND_COMPLETE & MBS_MASK)
  2016. #define QLA_INVALID_COMMAND (MBS_INVALID_COMMAND & MBS_MASK)
  2017. #define QLA_INTERFACE_ERROR (MBS_HOST_INTERFACE_ERROR & MBS_MASK)
  2018. #define QLA_TEST_FAILED (MBS_TEST_FAILED & MBS_MASK)
  2019. #define QLA_COMMAND_ERROR (MBS_COMMAND_ERROR & MBS_MASK)
  2020. #define QLA_PARAMETER_ERROR (MBS_COMMAND_PARAMETER_ERROR & MBS_MASK)
  2021. #define QLA_PORT_ID_USED (MBS_PORT_ID_USED & MBS_MASK)
  2022. #define QLA_LOOP_ID_USED (MBS_LOOP_ID_USED & MBS_MASK)
  2023. #define QLA_ALL_IDS_IN_USE (MBS_ALL_IDS_IN_USE & MBS_MASK)
  2024. #define QLA_NOT_LOGGED_IN (MBS_NOT_LOGGED_IN & MBS_MASK)
  2025. #define QLA_FUNCTION_TIMEOUT 0x100
  2026. #define QLA_FUNCTION_PARAMETER_ERROR 0x101
  2027. #define QLA_FUNCTION_FAILED 0x102
  2028. #define QLA_MEMORY_ALLOC_FAILED 0x103
  2029. #define QLA_LOCK_TIMEOUT 0x104
  2030. #define QLA_ABORTED 0x105
  2031. #define QLA_SUSPENDED 0x106
  2032. #define QLA_BUSY 0x107
  2033. #define QLA_RSCNS_HANDLED 0x108
  2034. /*
  2035. * Stat info for all adpaters
  2036. */
  2037. struct _qla2x00stats {
  2038. unsigned long mboxtout; /* mailbox timeouts */
  2039. unsigned long mboxerr; /* mailbox errors */
  2040. unsigned long ispAbort; /* ISP aborts */
  2041. unsigned long debugNo;
  2042. unsigned long loop_resync;
  2043. unsigned long outarray_full;
  2044. unsigned long retry_q_cnt;
  2045. };
  2046. #define NVRAM_DELAY() udelay(10)
  2047. #define INVALID_HANDLE (MAX_OUTSTANDING_COMMANDS+1)
  2048. /*
  2049. * Flash support definitions
  2050. */
  2051. #define FLASH_IMAGE_SIZE 131072
  2052. #include "qla_gbl.h"
  2053. #include "qla_dbg.h"
  2054. #include "qla_inline.h"
  2055. /*
  2056. * String arrays
  2057. */
  2058. #define LINESIZE 256
  2059. #define MAXARGS 26
  2060. #define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr)
  2061. #define CMD_COMPL_STATUS(Cmnd) ((Cmnd)->SCp.this_residual)
  2062. #define CMD_RESID_LEN(Cmnd) ((Cmnd)->SCp.buffers_residual)
  2063. #define CMD_SCSI_STATUS(Cmnd) ((Cmnd)->SCp.Status)
  2064. #define CMD_ACTUAL_SNSLEN(Cmnd) ((Cmnd)->SCp.Message)
  2065. #define CMD_ENTRY_STATUS(Cmnd) ((Cmnd)->SCp.have_data_in)
  2066. #endif