qla_def.h 68 KB

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