qla_def.h 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415
  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_POINT_TO_POINT 0x8030 /* Point to point mode. */
  438. #define MBA_CMPLT_1_16BIT 0x8031 /* Completion 1 16bit IOSB. */
  439. #define MBA_CMPLT_2_16BIT 0x8032 /* Completion 2 16bit IOSB. */
  440. #define MBA_CMPLT_3_16BIT 0x8033 /* Completion 3 16bit IOSB. */
  441. #define MBA_CMPLT_4_16BIT 0x8034 /* Completion 4 16bit IOSB. */
  442. #define MBA_CMPLT_5_16BIT 0x8035 /* Completion 5 16bit IOSB. */
  443. #define MBA_CHG_IN_CONNECTION 0x8036 /* Change in connection mode. */
  444. #define MBA_RIO_RESPONSE 0x8040 /* RIO response queue update. */
  445. #define MBA_ZIO_RESPONSE 0x8040 /* ZIO response queue update. */
  446. #define MBA_CMPLT_2_32BIT 0x8042 /* Completion 2 32bit IOSB. */
  447. #define MBA_BYPASS_NOTIFICATION 0x8043 /* Auto bypass notification. */
  448. #define MBA_DISCARD_RND_FRAME 0x8048 /* discard RND frame due to error. */
  449. #define MBA_REJECTED_FCP_CMD 0x8049 /* rejected FCP_CMD. */
  450. /*
  451. * Firmware options 1, 2, 3.
  452. */
  453. #define FO1_AE_ON_LIPF8 BIT_0
  454. #define FO1_AE_ALL_LIP_RESET BIT_1
  455. #define FO1_CTIO_RETRY BIT_3
  456. #define FO1_DISABLE_LIP_F7_SW BIT_4
  457. #define FO1_DISABLE_100MS_LOS_WAIT BIT_5
  458. #define FO1_DISABLE_GPIO6_7 BIT_6 /* LED bits */
  459. #define FO1_AE_ON_LOOP_INIT_ERR BIT_7
  460. #define FO1_SET_EMPHASIS_SWING BIT_8
  461. #define FO1_AE_AUTO_BYPASS BIT_9
  462. #define FO1_ENABLE_PURE_IOCB BIT_10
  463. #define FO1_AE_PLOGI_RJT BIT_11
  464. #define FO1_ENABLE_ABORT_SEQUENCE BIT_12
  465. #define FO1_AE_QUEUE_FULL BIT_13
  466. #define FO2_ENABLE_ATIO_TYPE_3 BIT_0
  467. #define FO2_REV_LOOPBACK BIT_1
  468. #define FO3_ENABLE_EMERG_IOCB BIT_0
  469. #define FO3_AE_RND_ERROR BIT_1
  470. /* 24XX additional firmware options */
  471. #define ADD_FO_COUNT 3
  472. #define ADD_FO1_DISABLE_GPIO_LED_CTRL BIT_6 /* LED bits */
  473. #define ADD_FO1_ENABLE_PUREX_IOCB BIT_10
  474. #define ADD_FO2_ENABLE_SEL_CLS2 BIT_5
  475. #define ADD_FO3_NO_ABT_ON_LINK_DOWN BIT_14
  476. /*
  477. * ISP mailbox commands
  478. */
  479. #define MBC_LOAD_RAM 1 /* Load RAM. */
  480. #define MBC_EXECUTE_FIRMWARE 2 /* Execute firmware. */
  481. #define MBC_WRITE_RAM_WORD 4 /* Write RAM word. */
  482. #define MBC_READ_RAM_WORD 5 /* Read RAM word. */
  483. #define MBC_MAILBOX_REGISTER_TEST 6 /* Wrap incoming mailboxes */
  484. #define MBC_VERIFY_CHECKSUM 7 /* Verify checksum. */
  485. #define MBC_GET_FIRMWARE_VERSION 8 /* Get firmware revision. */
  486. #define MBC_LOAD_RISC_RAM 9 /* Load RAM command. */
  487. #define MBC_DUMP_RISC_RAM 0xa /* Dump RAM command. */
  488. #define MBC_LOAD_RISC_RAM_EXTENDED 0xb /* Load RAM extended. */
  489. #define MBC_DUMP_RISC_RAM_EXTENDED 0xc /* Dump RAM extended. */
  490. #define MBC_WRITE_RAM_WORD_EXTENDED 0xd /* Write RAM word extended */
  491. #define MBC_READ_RAM_EXTENDED 0xf /* Read RAM extended. */
  492. #define MBC_IOCB_COMMAND 0x12 /* Execute IOCB command. */
  493. #define MBC_STOP_FIRMWARE 0x14 /* Stop firmware. */
  494. #define MBC_ABORT_COMMAND 0x15 /* Abort IOCB command. */
  495. #define MBC_ABORT_DEVICE 0x16 /* Abort device (ID/LUN). */
  496. #define MBC_ABORT_TARGET 0x17 /* Abort target (ID). */
  497. #define MBC_RESET 0x18 /* Reset. */
  498. #define MBC_GET_ADAPTER_LOOP_ID 0x20 /* Get loop id of ISP2200. */
  499. #define MBC_GET_RETRY_COUNT 0x22 /* Get f/w retry cnt/delay. */
  500. #define MBC_DISABLE_VI 0x24 /* Disable VI operation. */
  501. #define MBC_ENABLE_VI 0x25 /* Enable VI operation. */
  502. #define MBC_GET_FIRMWARE_OPTION 0x28 /* Get Firmware Options. */
  503. #define MBC_SET_FIRMWARE_OPTION 0x38 /* Set Firmware Options. */
  504. #define MBC_LOOP_PORT_BYPASS 0x40 /* Loop Port Bypass. */
  505. #define MBC_LOOP_PORT_ENABLE 0x41 /* Loop Port Enable. */
  506. #define MBC_GET_RESOURCE_COUNTS 0x42 /* Get Resource Counts. */
  507. #define MBC_NON_PARTICIPATE 0x43 /* Non-Participating Mode. */
  508. #define MBC_DIAGNOSTIC_ECHO 0x44 /* Diagnostic echo. */
  509. #define MBC_DIAGNOSTIC_LOOP_BACK 0x45 /* Diagnostic loop back. */
  510. #define MBC_ONLINE_SELF_TEST 0x46 /* Online self-test. */
  511. #define MBC_ENHANCED_GET_PORT_DATABASE 0x47 /* Get port database + login */
  512. #define MBC_RESET_LINK_STATUS 0x52 /* Reset Link Error Status */
  513. #define MBC_IOCB_COMMAND_A64 0x54 /* Execute IOCB command (64) */
  514. #define MBC_SEND_RNID_ELS 0x57 /* Send RNID ELS request */
  515. #define MBC_SET_RNID_PARAMS 0x59 /* Set RNID parameters */
  516. #define MBC_GET_RNID_PARAMS 0x5a /* Data Rate */
  517. #define MBC_DATA_RATE 0x5d /* Get RNID parameters */
  518. #define MBC_INITIALIZE_FIRMWARE 0x60 /* Initialize firmware */
  519. #define MBC_INITIATE_LIP 0x62 /* Initiate Loop */
  520. /* Initialization Procedure */
  521. #define MBC_GET_FC_AL_POSITION_MAP 0x63 /* Get FC_AL Position Map. */
  522. #define MBC_GET_PORT_DATABASE 0x64 /* Get Port Database. */
  523. #define MBC_CLEAR_ACA 0x65 /* Clear ACA. */
  524. #define MBC_TARGET_RESET 0x66 /* Target Reset. */
  525. #define MBC_CLEAR_TASK_SET 0x67 /* Clear Task Set. */
  526. #define MBC_ABORT_TASK_SET 0x68 /* Abort Task Set. */
  527. #define MBC_GET_FIRMWARE_STATE 0x69 /* Get firmware state. */
  528. #define MBC_GET_PORT_NAME 0x6a /* Get port name. */
  529. #define MBC_GET_LINK_STATUS 0x6b /* Get port link status. */
  530. #define MBC_LIP_RESET 0x6c /* LIP reset. */
  531. #define MBC_SEND_SNS_COMMAND 0x6e /* Send Simple Name Server */
  532. /* commandd. */
  533. #define MBC_LOGIN_FABRIC_PORT 0x6f /* Login fabric port. */
  534. #define MBC_SEND_CHANGE_REQUEST 0x70 /* Send Change Request. */
  535. #define MBC_LOGOUT_FABRIC_PORT 0x71 /* Logout fabric port. */
  536. #define MBC_LIP_FULL_LOGIN 0x72 /* Full login LIP. */
  537. #define MBC_LOGIN_LOOP_PORT 0x74 /* Login Loop Port. */
  538. #define MBC_PORT_NODE_NAME_LIST 0x75 /* Get port/node name list. */
  539. #define MBC_INITIALIZE_RECEIVE_QUEUE 0x77 /* Initialize receive queue */
  540. #define MBC_UNLOAD_IP 0x79 /* Shutdown IP */
  541. #define MBC_GET_ID_LIST 0x7C /* Get Port ID list. */
  542. #define MBC_SEND_LFA_COMMAND 0x7D /* Send Loop Fabric Address */
  543. #define MBC_LUN_RESET 0x7E /* Send LUN reset */
  544. /*
  545. * ISP24xx mailbox commands
  546. */
  547. #define MBC_SERDES_PARAMS 0x10 /* Serdes Tx Parameters. */
  548. #define MBC_GET_IOCB_STATUS 0x12 /* Get IOCB status command. */
  549. #define MBC_GET_TIMEOUT_PARAMS 0x22 /* Get FW timeouts. */
  550. #define MBC_GEN_SYSTEM_ERROR 0x2a /* Generate System Error. */
  551. #define MBC_SET_TIMEOUT_PARAMS 0x32 /* Set FW timeouts. */
  552. #define MBC_MID_INITIALIZE_FIRMWARE 0x48 /* MID Initialize firmware. */
  553. #define MBC_MID_GET_VP_DATABASE 0x49 /* MID Get VP Database. */
  554. #define MBC_MID_GET_VP_ENTRY 0x4a /* MID Get VP Entry. */
  555. #define MBC_HOST_MEMORY_COPY 0x53 /* Host Memory Copy. */
  556. #define MBC_SEND_RNFT_ELS 0x5e /* Send RNFT ELS request */
  557. #define MBC_GET_LINK_PRIV_STATS 0x6d /* Get link & private data. */
  558. #define MBC_SET_VENDOR_ID 0x76 /* Set Vendor ID. */
  559. /* Firmware return data sizes */
  560. #define FCAL_MAP_SIZE 128
  561. /* Mailbox bit definitions for out_mb and in_mb */
  562. #define MBX_31 BIT_31
  563. #define MBX_30 BIT_30
  564. #define MBX_29 BIT_29
  565. #define MBX_28 BIT_28
  566. #define MBX_27 BIT_27
  567. #define MBX_26 BIT_26
  568. #define MBX_25 BIT_25
  569. #define MBX_24 BIT_24
  570. #define MBX_23 BIT_23
  571. #define MBX_22 BIT_22
  572. #define MBX_21 BIT_21
  573. #define MBX_20 BIT_20
  574. #define MBX_19 BIT_19
  575. #define MBX_18 BIT_18
  576. #define MBX_17 BIT_17
  577. #define MBX_16 BIT_16
  578. #define MBX_15 BIT_15
  579. #define MBX_14 BIT_14
  580. #define MBX_13 BIT_13
  581. #define MBX_12 BIT_12
  582. #define MBX_11 BIT_11
  583. #define MBX_10 BIT_10
  584. #define MBX_9 BIT_9
  585. #define MBX_8 BIT_8
  586. #define MBX_7 BIT_7
  587. #define MBX_6 BIT_6
  588. #define MBX_5 BIT_5
  589. #define MBX_4 BIT_4
  590. #define MBX_3 BIT_3
  591. #define MBX_2 BIT_2
  592. #define MBX_1 BIT_1
  593. #define MBX_0 BIT_0
  594. /*
  595. * Firmware state codes from get firmware state mailbox command
  596. */
  597. #define FSTATE_CONFIG_WAIT 0
  598. #define FSTATE_WAIT_AL_PA 1
  599. #define FSTATE_WAIT_LOGIN 2
  600. #define FSTATE_READY 3
  601. #define FSTATE_LOSS_OF_SYNC 4
  602. #define FSTATE_ERROR 5
  603. #define FSTATE_REINIT 6
  604. #define FSTATE_NON_PART 7
  605. #define FSTATE_CONFIG_CORRECT 0
  606. #define FSTATE_P2P_RCV_LIP 1
  607. #define FSTATE_P2P_CHOOSE_LOOP 2
  608. #define FSTATE_P2P_RCV_UNIDEN_LIP 3
  609. #define FSTATE_FATAL_ERROR 4
  610. #define FSTATE_LOOP_BACK_CONN 5
  611. /*
  612. * Port Database structure definition
  613. * Little endian except where noted.
  614. */
  615. #define PORT_DATABASE_SIZE 128 /* bytes */
  616. typedef struct {
  617. uint8_t options;
  618. uint8_t control;
  619. uint8_t master_state;
  620. uint8_t slave_state;
  621. uint8_t reserved[2];
  622. uint8_t hard_address;
  623. uint8_t reserved_1;
  624. uint8_t port_id[4];
  625. uint8_t node_name[WWN_SIZE];
  626. uint8_t port_name[WWN_SIZE];
  627. uint16_t execution_throttle;
  628. uint16_t execution_count;
  629. uint8_t reset_count;
  630. uint8_t reserved_2;
  631. uint16_t resource_allocation;
  632. uint16_t current_allocation;
  633. uint16_t queue_head;
  634. uint16_t queue_tail;
  635. uint16_t transmit_execution_list_next;
  636. uint16_t transmit_execution_list_previous;
  637. uint16_t common_features;
  638. uint16_t total_concurrent_sequences;
  639. uint16_t RO_by_information_category;
  640. uint8_t recipient;
  641. uint8_t initiator;
  642. uint16_t receive_data_size;
  643. uint16_t concurrent_sequences;
  644. uint16_t open_sequences_per_exchange;
  645. uint16_t lun_abort_flags;
  646. uint16_t lun_stop_flags;
  647. uint16_t stop_queue_head;
  648. uint16_t stop_queue_tail;
  649. uint16_t port_retry_timer;
  650. uint16_t next_sequence_id;
  651. uint16_t frame_count;
  652. uint16_t PRLI_payload_length;
  653. uint8_t prli_svc_param_word_0[2]; /* Big endian */
  654. /* Bits 15-0 of word 0 */
  655. uint8_t prli_svc_param_word_3[2]; /* Big endian */
  656. /* Bits 15-0 of word 3 */
  657. uint16_t loop_id;
  658. uint16_t extended_lun_info_list_pointer;
  659. uint16_t extended_lun_stop_list_pointer;
  660. } port_database_t;
  661. /*
  662. * Port database slave/master states
  663. */
  664. #define PD_STATE_DISCOVERY 0
  665. #define PD_STATE_WAIT_DISCOVERY_ACK 1
  666. #define PD_STATE_PORT_LOGIN 2
  667. #define PD_STATE_WAIT_PORT_LOGIN_ACK 3
  668. #define PD_STATE_PROCESS_LOGIN 4
  669. #define PD_STATE_WAIT_PROCESS_LOGIN_ACK 5
  670. #define PD_STATE_PORT_LOGGED_IN 6
  671. #define PD_STATE_PORT_UNAVAILABLE 7
  672. #define PD_STATE_PROCESS_LOGOUT 8
  673. #define PD_STATE_WAIT_PROCESS_LOGOUT_ACK 9
  674. #define PD_STATE_PORT_LOGOUT 10
  675. #define PD_STATE_WAIT_PORT_LOGOUT_ACK 11
  676. #define QLA_ZIO_MODE_6 (BIT_2 | BIT_1)
  677. #define QLA_ZIO_DISABLED 0
  678. #define QLA_ZIO_DEFAULT_TIMER 2
  679. /*
  680. * ISP Initialization Control Block.
  681. * Little endian except where noted.
  682. */
  683. #define ICB_VERSION 1
  684. typedef struct {
  685. uint8_t version;
  686. uint8_t reserved_1;
  687. /*
  688. * LSB BIT 0 = Enable Hard Loop Id
  689. * LSB BIT 1 = Enable Fairness
  690. * LSB BIT 2 = Enable Full-Duplex
  691. * LSB BIT 3 = Enable Fast Posting
  692. * LSB BIT 4 = Enable Target Mode
  693. * LSB BIT 5 = Disable Initiator Mode
  694. * LSB BIT 6 = Enable ADISC
  695. * LSB BIT 7 = Enable Target Inquiry Data
  696. *
  697. * MSB BIT 0 = Enable PDBC Notify
  698. * MSB BIT 1 = Non Participating LIP
  699. * MSB BIT 2 = Descending Loop ID Search
  700. * MSB BIT 3 = Acquire Loop ID in LIPA
  701. * MSB BIT 4 = Stop PortQ on Full Status
  702. * MSB BIT 5 = Full Login after LIP
  703. * MSB BIT 6 = Node Name Option
  704. * MSB BIT 7 = Ext IFWCB enable bit
  705. */
  706. uint8_t firmware_options[2];
  707. uint16_t frame_payload_size;
  708. uint16_t max_iocb_allocation;
  709. uint16_t execution_throttle;
  710. uint8_t retry_count;
  711. uint8_t retry_delay; /* unused */
  712. uint8_t port_name[WWN_SIZE]; /* Big endian. */
  713. uint16_t hard_address;
  714. uint8_t inquiry_data;
  715. uint8_t login_timeout;
  716. uint8_t node_name[WWN_SIZE]; /* Big endian. */
  717. uint16_t request_q_outpointer;
  718. uint16_t response_q_inpointer;
  719. uint16_t request_q_length;
  720. uint16_t response_q_length;
  721. uint32_t request_q_address[2];
  722. uint32_t response_q_address[2];
  723. uint16_t lun_enables;
  724. uint8_t command_resource_count;
  725. uint8_t immediate_notify_resource_count;
  726. uint16_t timeout;
  727. uint8_t reserved_2[2];
  728. /*
  729. * LSB BIT 0 = Timer Operation mode bit 0
  730. * LSB BIT 1 = Timer Operation mode bit 1
  731. * LSB BIT 2 = Timer Operation mode bit 2
  732. * LSB BIT 3 = Timer Operation mode bit 3
  733. * LSB BIT 4 = Init Config Mode bit 0
  734. * LSB BIT 5 = Init Config Mode bit 1
  735. * LSB BIT 6 = Init Config Mode bit 2
  736. * LSB BIT 7 = Enable Non part on LIHA failure
  737. *
  738. * MSB BIT 0 = Enable class 2
  739. * MSB BIT 1 = Enable ACK0
  740. * MSB BIT 2 =
  741. * MSB BIT 3 =
  742. * MSB BIT 4 = FC Tape Enable
  743. * MSB BIT 5 = Enable FC Confirm
  744. * MSB BIT 6 = Enable command queuing in target mode
  745. * MSB BIT 7 = No Logo On Link Down
  746. */
  747. uint8_t add_firmware_options[2];
  748. uint8_t response_accumulation_timer;
  749. uint8_t interrupt_delay_timer;
  750. /*
  751. * LSB BIT 0 = Enable Read xfr_rdy
  752. * LSB BIT 1 = Soft ID only
  753. * LSB BIT 2 =
  754. * LSB BIT 3 =
  755. * LSB BIT 4 = FCP RSP Payload [0]
  756. * LSB BIT 5 = FCP RSP Payload [1] / Sbus enable - 2200
  757. * LSB BIT 6 = Enable Out-of-Order frame handling
  758. * LSB BIT 7 = Disable Automatic PLOGI on Local Loop
  759. *
  760. * MSB BIT 0 = Sbus enable - 2300
  761. * MSB BIT 1 =
  762. * MSB BIT 2 =
  763. * MSB BIT 3 =
  764. * MSB BIT 4 = LED mode
  765. * MSB BIT 5 = enable 50 ohm termination
  766. * MSB BIT 6 = Data Rate (2300 only)
  767. * MSB BIT 7 = Data Rate (2300 only)
  768. */
  769. uint8_t special_options[2];
  770. uint8_t reserved_3[26];
  771. } init_cb_t;
  772. /*
  773. * Get Link Status mailbox command return buffer.
  774. */
  775. #define GLSO_SEND_RPS BIT_0
  776. #define GLSO_USE_DID BIT_3
  777. typedef struct {
  778. uint32_t link_fail_cnt;
  779. uint32_t loss_sync_cnt;
  780. uint32_t loss_sig_cnt;
  781. uint32_t prim_seq_err_cnt;
  782. uint32_t inval_xmit_word_cnt;
  783. uint32_t inval_crc_cnt;
  784. } link_stat_t;
  785. /*
  786. * NVRAM Command values.
  787. */
  788. #define NV_START_BIT BIT_2
  789. #define NV_WRITE_OP (BIT_26+BIT_24)
  790. #define NV_READ_OP (BIT_26+BIT_25)
  791. #define NV_ERASE_OP (BIT_26+BIT_25+BIT_24)
  792. #define NV_MASK_OP (BIT_26+BIT_25+BIT_24)
  793. #define NV_DELAY_COUNT 10
  794. /*
  795. * QLogic ISP2100, ISP2200 and ISP2300 NVRAM structure definition.
  796. */
  797. typedef struct {
  798. /*
  799. * NVRAM header
  800. */
  801. uint8_t id[4];
  802. uint8_t nvram_version;
  803. uint8_t reserved_0;
  804. /*
  805. * NVRAM RISC parameter block
  806. */
  807. uint8_t parameter_block_version;
  808. uint8_t reserved_1;
  809. /*
  810. * LSB BIT 0 = Enable Hard Loop Id
  811. * LSB BIT 1 = Enable Fairness
  812. * LSB BIT 2 = Enable Full-Duplex
  813. * LSB BIT 3 = Enable Fast Posting
  814. * LSB BIT 4 = Enable Target Mode
  815. * LSB BIT 5 = Disable Initiator Mode
  816. * LSB BIT 6 = Enable ADISC
  817. * LSB BIT 7 = Enable Target Inquiry Data
  818. *
  819. * MSB BIT 0 = Enable PDBC Notify
  820. * MSB BIT 1 = Non Participating LIP
  821. * MSB BIT 2 = Descending Loop ID Search
  822. * MSB BIT 3 = Acquire Loop ID in LIPA
  823. * MSB BIT 4 = Stop PortQ on Full Status
  824. * MSB BIT 5 = Full Login after LIP
  825. * MSB BIT 6 = Node Name Option
  826. * MSB BIT 7 = Ext IFWCB enable bit
  827. */
  828. uint8_t firmware_options[2];
  829. uint16_t frame_payload_size;
  830. uint16_t max_iocb_allocation;
  831. uint16_t execution_throttle;
  832. uint8_t retry_count;
  833. uint8_t retry_delay; /* unused */
  834. uint8_t port_name[WWN_SIZE]; /* Big endian. */
  835. uint16_t hard_address;
  836. uint8_t inquiry_data;
  837. uint8_t login_timeout;
  838. uint8_t node_name[WWN_SIZE]; /* Big endian. */
  839. /*
  840. * LSB BIT 0 = Timer Operation mode bit 0
  841. * LSB BIT 1 = Timer Operation mode bit 1
  842. * LSB BIT 2 = Timer Operation mode bit 2
  843. * LSB BIT 3 = Timer Operation mode bit 3
  844. * LSB BIT 4 = Init Config Mode bit 0
  845. * LSB BIT 5 = Init Config Mode bit 1
  846. * LSB BIT 6 = Init Config Mode bit 2
  847. * LSB BIT 7 = Enable Non part on LIHA failure
  848. *
  849. * MSB BIT 0 = Enable class 2
  850. * MSB BIT 1 = Enable ACK0
  851. * MSB BIT 2 =
  852. * MSB BIT 3 =
  853. * MSB BIT 4 = FC Tape Enable
  854. * MSB BIT 5 = Enable FC Confirm
  855. * MSB BIT 6 = Enable command queuing in target mode
  856. * MSB BIT 7 = No Logo On Link Down
  857. */
  858. uint8_t add_firmware_options[2];
  859. uint8_t response_accumulation_timer;
  860. uint8_t interrupt_delay_timer;
  861. /*
  862. * LSB BIT 0 = Enable Read xfr_rdy
  863. * LSB BIT 1 = Soft ID only
  864. * LSB BIT 2 =
  865. * LSB BIT 3 =
  866. * LSB BIT 4 = FCP RSP Payload [0]
  867. * LSB BIT 5 = FCP RSP Payload [1] / Sbus enable - 2200
  868. * LSB BIT 6 = Enable Out-of-Order frame handling
  869. * LSB BIT 7 = Disable Automatic PLOGI on Local Loop
  870. *
  871. * MSB BIT 0 = Sbus enable - 2300
  872. * MSB BIT 1 =
  873. * MSB BIT 2 =
  874. * MSB BIT 3 =
  875. * MSB BIT 4 = LED mode
  876. * MSB BIT 5 = enable 50 ohm termination
  877. * MSB BIT 6 = Data Rate (2300 only)
  878. * MSB BIT 7 = Data Rate (2300 only)
  879. */
  880. uint8_t special_options[2];
  881. /* Reserved for expanded RISC parameter block */
  882. uint8_t reserved_2[22];
  883. /*
  884. * LSB BIT 0 = Tx Sensitivity 1G bit 0
  885. * LSB BIT 1 = Tx Sensitivity 1G bit 1
  886. * LSB BIT 2 = Tx Sensitivity 1G bit 2
  887. * LSB BIT 3 = Tx Sensitivity 1G bit 3
  888. * LSB BIT 4 = Rx Sensitivity 1G bit 0
  889. * LSB BIT 5 = Rx Sensitivity 1G bit 1
  890. * LSB BIT 6 = Rx Sensitivity 1G bit 2
  891. * LSB BIT 7 = Rx Sensitivity 1G bit 3
  892. *
  893. * MSB BIT 0 = Tx Sensitivity 2G bit 0
  894. * MSB BIT 1 = Tx Sensitivity 2G bit 1
  895. * MSB BIT 2 = Tx Sensitivity 2G bit 2
  896. * MSB BIT 3 = Tx Sensitivity 2G bit 3
  897. * MSB BIT 4 = Rx Sensitivity 2G bit 0
  898. * MSB BIT 5 = Rx Sensitivity 2G bit 1
  899. * MSB BIT 6 = Rx Sensitivity 2G bit 2
  900. * MSB BIT 7 = Rx Sensitivity 2G bit 3
  901. *
  902. * LSB BIT 0 = Output Swing 1G bit 0
  903. * LSB BIT 1 = Output Swing 1G bit 1
  904. * LSB BIT 2 = Output Swing 1G bit 2
  905. * LSB BIT 3 = Output Emphasis 1G bit 0
  906. * LSB BIT 4 = Output Emphasis 1G bit 1
  907. * LSB BIT 5 = Output Swing 2G bit 0
  908. * LSB BIT 6 = Output Swing 2G bit 1
  909. * LSB BIT 7 = Output Swing 2G bit 2
  910. *
  911. * MSB BIT 0 = Output Emphasis 2G bit 0
  912. * MSB BIT 1 = Output Emphasis 2G bit 1
  913. * MSB BIT 2 = Output Enable
  914. * MSB BIT 3 =
  915. * MSB BIT 4 =
  916. * MSB BIT 5 =
  917. * MSB BIT 6 =
  918. * MSB BIT 7 =
  919. */
  920. uint8_t seriallink_options[4];
  921. /*
  922. * NVRAM host parameter block
  923. *
  924. * LSB BIT 0 = Enable spinup delay
  925. * LSB BIT 1 = Disable BIOS
  926. * LSB BIT 2 = Enable Memory Map BIOS
  927. * LSB BIT 3 = Enable Selectable Boot
  928. * LSB BIT 4 = Disable RISC code load
  929. * LSB BIT 5 = Set cache line size 1
  930. * LSB BIT 6 = PCI Parity Disable
  931. * LSB BIT 7 = Enable extended logging
  932. *
  933. * MSB BIT 0 = Enable 64bit addressing
  934. * MSB BIT 1 = Enable lip reset
  935. * MSB BIT 2 = Enable lip full login
  936. * MSB BIT 3 = Enable target reset
  937. * MSB BIT 4 = Enable database storage
  938. * MSB BIT 5 = Enable cache flush read
  939. * MSB BIT 6 = Enable database load
  940. * MSB BIT 7 = Enable alternate WWN
  941. */
  942. uint8_t host_p[2];
  943. uint8_t boot_node_name[WWN_SIZE];
  944. uint8_t boot_lun_number;
  945. uint8_t reset_delay;
  946. uint8_t port_down_retry_count;
  947. uint8_t boot_id_number;
  948. uint16_t max_luns_per_target;
  949. uint8_t fcode_boot_port_name[WWN_SIZE];
  950. uint8_t alternate_port_name[WWN_SIZE];
  951. uint8_t alternate_node_name[WWN_SIZE];
  952. /*
  953. * BIT 0 = Selective Login
  954. * BIT 1 = Alt-Boot Enable
  955. * BIT 2 =
  956. * BIT 3 = Boot Order List
  957. * BIT 4 =
  958. * BIT 5 = Selective LUN
  959. * BIT 6 =
  960. * BIT 7 = unused
  961. */
  962. uint8_t efi_parameters;
  963. uint8_t link_down_timeout;
  964. uint8_t adapter_id[16];
  965. uint8_t alt1_boot_node_name[WWN_SIZE];
  966. uint16_t alt1_boot_lun_number;
  967. uint8_t alt2_boot_node_name[WWN_SIZE];
  968. uint16_t alt2_boot_lun_number;
  969. uint8_t alt3_boot_node_name[WWN_SIZE];
  970. uint16_t alt3_boot_lun_number;
  971. uint8_t alt4_boot_node_name[WWN_SIZE];
  972. uint16_t alt4_boot_lun_number;
  973. uint8_t alt5_boot_node_name[WWN_SIZE];
  974. uint16_t alt5_boot_lun_number;
  975. uint8_t alt6_boot_node_name[WWN_SIZE];
  976. uint16_t alt6_boot_lun_number;
  977. uint8_t alt7_boot_node_name[WWN_SIZE];
  978. uint16_t alt7_boot_lun_number;
  979. uint8_t reserved_3[2];
  980. /* Offset 200-215 : Model Number */
  981. uint8_t model_number[16];
  982. /* OEM related items */
  983. uint8_t oem_specific[16];
  984. /*
  985. * NVRAM Adapter Features offset 232-239
  986. *
  987. * LSB BIT 0 = External GBIC
  988. * LSB BIT 1 = Risc RAM parity
  989. * LSB BIT 2 = Buffer Plus Module
  990. * LSB BIT 3 = Multi Chip Adapter
  991. * LSB BIT 4 = Internal connector
  992. * LSB BIT 5 =
  993. * LSB BIT 6 =
  994. * LSB BIT 7 =
  995. *
  996. * MSB BIT 0 =
  997. * MSB BIT 1 =
  998. * MSB BIT 2 =
  999. * MSB BIT 3 =
  1000. * MSB BIT 4 =
  1001. * MSB BIT 5 =
  1002. * MSB BIT 6 =
  1003. * MSB BIT 7 =
  1004. */
  1005. uint8_t adapter_features[2];
  1006. uint8_t reserved_4[16];
  1007. /* Subsystem vendor ID for ISP2200 */
  1008. uint16_t subsystem_vendor_id_2200;
  1009. /* Subsystem device ID for ISP2200 */
  1010. uint16_t subsystem_device_id_2200;
  1011. uint8_t reserved_5;
  1012. uint8_t checksum;
  1013. } nvram_t;
  1014. /*
  1015. * ISP queue - response queue entry definition.
  1016. */
  1017. typedef struct {
  1018. uint8_t data[60];
  1019. uint32_t signature;
  1020. #define RESPONSE_PROCESSED 0xDEADDEAD /* Signature */
  1021. } response_t;
  1022. typedef union {
  1023. uint16_t extended;
  1024. struct {
  1025. uint8_t reserved;
  1026. uint8_t standard;
  1027. } id;
  1028. } target_id_t;
  1029. #define SET_TARGET_ID(ha, to, from) \
  1030. do { \
  1031. if (HAS_EXTENDED_IDS(ha)) \
  1032. to.extended = cpu_to_le16(from); \
  1033. else \
  1034. to.id.standard = (uint8_t)from; \
  1035. } while (0)
  1036. /*
  1037. * ISP queue - command entry structure definition.
  1038. */
  1039. #define COMMAND_TYPE 0x11 /* Command entry */
  1040. typedef struct {
  1041. uint8_t entry_type; /* Entry type. */
  1042. uint8_t entry_count; /* Entry count. */
  1043. uint8_t sys_define; /* System defined. */
  1044. uint8_t entry_status; /* Entry Status. */
  1045. uint32_t handle; /* System handle. */
  1046. target_id_t target; /* SCSI ID */
  1047. uint16_t lun; /* SCSI LUN */
  1048. uint16_t control_flags; /* Control flags. */
  1049. #define CF_WRITE BIT_6
  1050. #define CF_READ BIT_5
  1051. #define CF_SIMPLE_TAG BIT_3
  1052. #define CF_ORDERED_TAG BIT_2
  1053. #define CF_HEAD_TAG BIT_1
  1054. uint16_t reserved_1;
  1055. uint16_t timeout; /* Command timeout. */
  1056. uint16_t dseg_count; /* Data segment count. */
  1057. uint8_t scsi_cdb[MAX_CMDSZ]; /* SCSI command words. */
  1058. uint32_t byte_count; /* Total byte count. */
  1059. uint32_t dseg_0_address; /* Data segment 0 address. */
  1060. uint32_t dseg_0_length; /* Data segment 0 length. */
  1061. uint32_t dseg_1_address; /* Data segment 1 address. */
  1062. uint32_t dseg_1_length; /* Data segment 1 length. */
  1063. uint32_t dseg_2_address; /* Data segment 2 address. */
  1064. uint32_t dseg_2_length; /* Data segment 2 length. */
  1065. } cmd_entry_t;
  1066. /*
  1067. * ISP queue - 64-Bit addressing, command entry structure definition.
  1068. */
  1069. #define COMMAND_A64_TYPE 0x19 /* Command A64 entry */
  1070. typedef struct {
  1071. uint8_t entry_type; /* Entry type. */
  1072. uint8_t entry_count; /* Entry count. */
  1073. uint8_t sys_define; /* System defined. */
  1074. uint8_t entry_status; /* Entry Status. */
  1075. uint32_t handle; /* System handle. */
  1076. target_id_t target; /* SCSI ID */
  1077. uint16_t lun; /* SCSI LUN */
  1078. uint16_t control_flags; /* Control flags. */
  1079. uint16_t reserved_1;
  1080. uint16_t timeout; /* Command timeout. */
  1081. uint16_t dseg_count; /* Data segment count. */
  1082. uint8_t scsi_cdb[MAX_CMDSZ]; /* SCSI command words. */
  1083. uint32_t byte_count; /* Total byte count. */
  1084. uint32_t dseg_0_address[2]; /* Data segment 0 address. */
  1085. uint32_t dseg_0_length; /* Data segment 0 length. */
  1086. uint32_t dseg_1_address[2]; /* Data segment 1 address. */
  1087. uint32_t dseg_1_length; /* Data segment 1 length. */
  1088. } cmd_a64_entry_t, request_t;
  1089. /*
  1090. * ISP queue - continuation entry structure definition.
  1091. */
  1092. #define CONTINUE_TYPE 0x02 /* Continuation entry. */
  1093. typedef struct {
  1094. uint8_t entry_type; /* Entry type. */
  1095. uint8_t entry_count; /* Entry count. */
  1096. uint8_t sys_define; /* System defined. */
  1097. uint8_t entry_status; /* Entry Status. */
  1098. uint32_t reserved;
  1099. uint32_t dseg_0_address; /* Data segment 0 address. */
  1100. uint32_t dseg_0_length; /* Data segment 0 length. */
  1101. uint32_t dseg_1_address; /* Data segment 1 address. */
  1102. uint32_t dseg_1_length; /* Data segment 1 length. */
  1103. uint32_t dseg_2_address; /* Data segment 2 address. */
  1104. uint32_t dseg_2_length; /* Data segment 2 length. */
  1105. uint32_t dseg_3_address; /* Data segment 3 address. */
  1106. uint32_t dseg_3_length; /* Data segment 3 length. */
  1107. uint32_t dseg_4_address; /* Data segment 4 address. */
  1108. uint32_t dseg_4_length; /* Data segment 4 length. */
  1109. uint32_t dseg_5_address; /* Data segment 5 address. */
  1110. uint32_t dseg_5_length; /* Data segment 5 length. */
  1111. uint32_t dseg_6_address; /* Data segment 6 address. */
  1112. uint32_t dseg_6_length; /* Data segment 6 length. */
  1113. } cont_entry_t;
  1114. /*
  1115. * ISP queue - 64-Bit addressing, continuation entry structure definition.
  1116. */
  1117. #define CONTINUE_A64_TYPE 0x0A /* Continuation A64 entry. */
  1118. typedef struct {
  1119. uint8_t entry_type; /* Entry type. */
  1120. uint8_t entry_count; /* Entry count. */
  1121. uint8_t sys_define; /* System defined. */
  1122. uint8_t entry_status; /* Entry Status. */
  1123. uint32_t dseg_0_address[2]; /* Data segment 0 address. */
  1124. uint32_t dseg_0_length; /* Data segment 0 length. */
  1125. uint32_t dseg_1_address[2]; /* Data segment 1 address. */
  1126. uint32_t dseg_1_length; /* Data segment 1 length. */
  1127. uint32_t dseg_2_address [2]; /* Data segment 2 address. */
  1128. uint32_t dseg_2_length; /* Data segment 2 length. */
  1129. uint32_t dseg_3_address[2]; /* Data segment 3 address. */
  1130. uint32_t dseg_3_length; /* Data segment 3 length. */
  1131. uint32_t dseg_4_address[2]; /* Data segment 4 address. */
  1132. uint32_t dseg_4_length; /* Data segment 4 length. */
  1133. } cont_a64_entry_t;
  1134. /*
  1135. * ISP queue - status entry structure definition.
  1136. */
  1137. #define STATUS_TYPE 0x03 /* Status entry. */
  1138. typedef struct {
  1139. uint8_t entry_type; /* Entry type. */
  1140. uint8_t entry_count; /* Entry count. */
  1141. uint8_t sys_define; /* System defined. */
  1142. uint8_t entry_status; /* Entry Status. */
  1143. uint32_t handle; /* System handle. */
  1144. uint16_t scsi_status; /* SCSI status. */
  1145. uint16_t comp_status; /* Completion status. */
  1146. uint16_t state_flags; /* State flags. */
  1147. uint16_t status_flags; /* Status flags. */
  1148. uint16_t rsp_info_len; /* Response Info Length. */
  1149. uint16_t req_sense_length; /* Request sense data length. */
  1150. uint32_t residual_length; /* Residual transfer length. */
  1151. uint8_t rsp_info[8]; /* FCP response information. */
  1152. uint8_t req_sense_data[32]; /* Request sense data. */
  1153. } sts_entry_t;
  1154. /*
  1155. * Status entry entry status
  1156. */
  1157. #define RF_RQ_DMA_ERROR BIT_6 /* Request Queue DMA error. */
  1158. #define RF_INV_E_ORDER BIT_5 /* Invalid entry order. */
  1159. #define RF_INV_E_COUNT BIT_4 /* Invalid entry count. */
  1160. #define RF_INV_E_PARAM BIT_3 /* Invalid entry parameter. */
  1161. #define RF_INV_E_TYPE BIT_2 /* Invalid entry type. */
  1162. #define RF_BUSY BIT_1 /* Busy */
  1163. #define RF_MASK (RF_RQ_DMA_ERROR | RF_INV_E_ORDER | RF_INV_E_COUNT | \
  1164. RF_INV_E_PARAM | RF_INV_E_TYPE | RF_BUSY)
  1165. #define RF_MASK_24XX (RF_INV_E_ORDER | RF_INV_E_COUNT | RF_INV_E_PARAM | \
  1166. RF_INV_E_TYPE)
  1167. /*
  1168. * Status entry SCSI status bit definitions.
  1169. */
  1170. #define SS_MASK 0xfff /* Reserved bits BIT_12-BIT_15*/
  1171. #define SS_RESIDUAL_UNDER BIT_11
  1172. #define SS_RESIDUAL_OVER BIT_10
  1173. #define SS_SENSE_LEN_VALID BIT_9
  1174. #define SS_RESPONSE_INFO_LEN_VALID BIT_8
  1175. #define SS_RESERVE_CONFLICT (BIT_4 | BIT_3)
  1176. #define SS_BUSY_CONDITION BIT_3
  1177. #define SS_CONDITION_MET BIT_2
  1178. #define SS_CHECK_CONDITION BIT_1
  1179. /*
  1180. * Status entry completion status
  1181. */
  1182. #define CS_COMPLETE 0x0 /* No errors */
  1183. #define CS_INCOMPLETE 0x1 /* Incomplete transfer of cmd. */
  1184. #define CS_DMA 0x2 /* A DMA direction error. */
  1185. #define CS_TRANSPORT 0x3 /* Transport error. */
  1186. #define CS_RESET 0x4 /* SCSI bus reset occurred */
  1187. #define CS_ABORTED 0x5 /* System aborted command. */
  1188. #define CS_TIMEOUT 0x6 /* Timeout error. */
  1189. #define CS_DATA_OVERRUN 0x7 /* Data overrun. */
  1190. #define CS_DATA_UNDERRUN 0x15 /* Data Underrun. */
  1191. #define CS_QUEUE_FULL 0x1C /* Queue Full. */
  1192. #define CS_PORT_UNAVAILABLE 0x28 /* Port unavailable */
  1193. /* (selection timeout) */
  1194. #define CS_PORT_LOGGED_OUT 0x29 /* Port Logged Out */
  1195. #define CS_PORT_CONFIG_CHG 0x2A /* Port Configuration Changed */
  1196. #define CS_PORT_BUSY 0x2B /* Port Busy */
  1197. #define CS_COMPLETE_CHKCOND 0x30 /* Error? */
  1198. #define CS_BAD_PAYLOAD 0x80 /* Driver defined */
  1199. #define CS_UNKNOWN 0x81 /* Driver defined */
  1200. #define CS_RETRY 0x82 /* Driver defined */
  1201. #define CS_LOOP_DOWN_ABORT 0x83 /* Driver defined */
  1202. /*
  1203. * Status entry status flags
  1204. */
  1205. #define SF_ABTS_TERMINATED BIT_10
  1206. #define SF_LOGOUT_SENT BIT_13
  1207. /*
  1208. * ISP queue - status continuation entry structure definition.
  1209. */
  1210. #define STATUS_CONT_TYPE 0x10 /* Status continuation entry. */
  1211. typedef struct {
  1212. uint8_t entry_type; /* Entry type. */
  1213. uint8_t entry_count; /* Entry count. */
  1214. uint8_t sys_define; /* System defined. */
  1215. uint8_t entry_status; /* Entry Status. */
  1216. uint8_t data[60]; /* data */
  1217. } sts_cont_entry_t;
  1218. /*
  1219. * ISP queue - RIO Type 1 status entry (32 bit I/O entry handles)
  1220. * structure definition.
  1221. */
  1222. #define STATUS_TYPE_21 0x21 /* Status entry. */
  1223. typedef struct {
  1224. uint8_t entry_type; /* Entry type. */
  1225. uint8_t entry_count; /* Entry count. */
  1226. uint8_t handle_count; /* Handle count. */
  1227. uint8_t entry_status; /* Entry Status. */
  1228. uint32_t handle[15]; /* System handles. */
  1229. } sts21_entry_t;
  1230. /*
  1231. * ISP queue - RIO Type 2 status entry (16 bit I/O entry handles)
  1232. * structure definition.
  1233. */
  1234. #define STATUS_TYPE_22 0x22 /* Status entry. */
  1235. typedef struct {
  1236. uint8_t entry_type; /* Entry type. */
  1237. uint8_t entry_count; /* Entry count. */
  1238. uint8_t handle_count; /* Handle count. */
  1239. uint8_t entry_status; /* Entry Status. */
  1240. uint16_t handle[30]; /* System handles. */
  1241. } sts22_entry_t;
  1242. /*
  1243. * ISP queue - marker entry structure definition.
  1244. */
  1245. #define MARKER_TYPE 0x04 /* Marker entry. */
  1246. typedef struct {
  1247. uint8_t entry_type; /* Entry type. */
  1248. uint8_t entry_count; /* Entry count. */
  1249. uint8_t handle_count; /* Handle count. */
  1250. uint8_t entry_status; /* Entry Status. */
  1251. uint32_t sys_define_2; /* System defined. */
  1252. target_id_t target; /* SCSI ID */
  1253. uint8_t modifier; /* Modifier (7-0). */
  1254. #define MK_SYNC_ID_LUN 0 /* Synchronize ID/LUN */
  1255. #define MK_SYNC_ID 1 /* Synchronize ID */
  1256. #define MK_SYNC_ALL 2 /* Synchronize all ID/LUN */
  1257. #define MK_SYNC_LIP 3 /* Synchronize all ID/LUN, */
  1258. /* clear port changed, */
  1259. /* use sequence number. */
  1260. uint8_t reserved_1;
  1261. uint16_t sequence_number; /* Sequence number of event */
  1262. uint16_t lun; /* SCSI LUN */
  1263. uint8_t reserved_2[48];
  1264. } mrk_entry_t;
  1265. /*
  1266. * ISP queue - Management Server entry structure definition.
  1267. */
  1268. #define MS_IOCB_TYPE 0x29 /* Management Server IOCB entry */
  1269. typedef struct {
  1270. uint8_t entry_type; /* Entry type. */
  1271. uint8_t entry_count; /* Entry count. */
  1272. uint8_t handle_count; /* Handle count. */
  1273. uint8_t entry_status; /* Entry Status. */
  1274. uint32_t handle1; /* System handle. */
  1275. target_id_t loop_id;
  1276. uint16_t status;
  1277. uint16_t control_flags; /* Control flags. */
  1278. uint16_t reserved2;
  1279. uint16_t timeout;
  1280. uint16_t cmd_dsd_count;
  1281. uint16_t total_dsd_count;
  1282. uint8_t type;
  1283. uint8_t r_ctl;
  1284. uint16_t rx_id;
  1285. uint16_t reserved3;
  1286. uint32_t handle2;
  1287. uint32_t rsp_bytecount;
  1288. uint32_t req_bytecount;
  1289. uint32_t dseg_req_address[2]; /* Data segment 0 address. */
  1290. uint32_t dseg_req_length; /* Data segment 0 length. */
  1291. uint32_t dseg_rsp_address[2]; /* Data segment 1 address. */
  1292. uint32_t dseg_rsp_length; /* Data segment 1 length. */
  1293. } ms_iocb_entry_t;
  1294. /*
  1295. * ISP queue - Mailbox Command entry structure definition.
  1296. */
  1297. #define MBX_IOCB_TYPE 0x39
  1298. struct mbx_entry {
  1299. uint8_t entry_type;
  1300. uint8_t entry_count;
  1301. uint8_t sys_define1;
  1302. /* Use sys_define1 for source type */
  1303. #define SOURCE_SCSI 0x00
  1304. #define SOURCE_IP 0x01
  1305. #define SOURCE_VI 0x02
  1306. #define SOURCE_SCTP 0x03
  1307. #define SOURCE_MP 0x04
  1308. #define SOURCE_MPIOCTL 0x05
  1309. #define SOURCE_ASYNC_IOCB 0x07
  1310. uint8_t entry_status;
  1311. uint32_t handle;
  1312. target_id_t loop_id;
  1313. uint16_t status;
  1314. uint16_t state_flags;
  1315. uint16_t status_flags;
  1316. uint32_t sys_define2[2];
  1317. uint16_t mb0;
  1318. uint16_t mb1;
  1319. uint16_t mb2;
  1320. uint16_t mb3;
  1321. uint16_t mb6;
  1322. uint16_t mb7;
  1323. uint16_t mb9;
  1324. uint16_t mb10;
  1325. uint32_t reserved_2[2];
  1326. uint8_t node_name[WWN_SIZE];
  1327. uint8_t port_name[WWN_SIZE];
  1328. };
  1329. /*
  1330. * ISP request and response queue entry sizes
  1331. */
  1332. #define RESPONSE_ENTRY_SIZE (sizeof(response_t))
  1333. #define REQUEST_ENTRY_SIZE (sizeof(request_t))
  1334. /*
  1335. * 24 bit port ID type definition.
  1336. */
  1337. typedef union {
  1338. uint32_t b24 : 24;
  1339. struct {
  1340. uint8_t d_id[3];
  1341. uint8_t rsvd_1;
  1342. } r;
  1343. struct {
  1344. uint8_t al_pa;
  1345. uint8_t area;
  1346. uint8_t domain;
  1347. uint8_t rsvd_1;
  1348. } b;
  1349. } port_id_t;
  1350. #define INVALID_PORT_ID 0xFFFFFF
  1351. /*
  1352. * Switch info gathering structure.
  1353. */
  1354. typedef struct {
  1355. port_id_t d_id;
  1356. uint8_t node_name[WWN_SIZE];
  1357. uint8_t port_name[WWN_SIZE];
  1358. } sw_info_t;
  1359. /*
  1360. * Fibre channel port type.
  1361. */
  1362. typedef enum {
  1363. FCT_UNKNOWN,
  1364. FCT_RSCN,
  1365. FCT_SWITCH,
  1366. FCT_BROADCAST,
  1367. FCT_INITIATOR,
  1368. FCT_TARGET
  1369. } fc_port_type_t;
  1370. /*
  1371. * Fibre channel port structure.
  1372. */
  1373. typedef struct fc_port {
  1374. struct list_head list;
  1375. struct scsi_qla_host *ha;
  1376. uint8_t node_name[WWN_SIZE];
  1377. uint8_t port_name[WWN_SIZE];
  1378. port_id_t d_id;
  1379. uint16_t loop_id;
  1380. uint16_t old_loop_id;
  1381. fc_port_type_t port_type;
  1382. atomic_t state;
  1383. uint32_t flags;
  1384. unsigned int os_target_id;
  1385. int port_login_retry_count;
  1386. int login_retry;
  1387. atomic_t port_down_timer;
  1388. spinlock_t rport_lock;
  1389. struct fc_rport *rport, *drport;
  1390. u32 supported_classes;
  1391. } fc_port_t;
  1392. /*
  1393. * Fibre channel port/lun states.
  1394. */
  1395. #define FCS_UNCONFIGURED 1
  1396. #define FCS_DEVICE_DEAD 2
  1397. #define FCS_DEVICE_LOST 3
  1398. #define FCS_ONLINE 4
  1399. #define FCS_NOT_SUPPORTED 5
  1400. #define FCS_FAILOVER 6
  1401. #define FCS_FAILOVER_FAILED 7
  1402. /*
  1403. * FC port flags.
  1404. */
  1405. #define FCF_FABRIC_DEVICE BIT_0
  1406. #define FCF_LOGIN_NEEDED BIT_1
  1407. #define FCF_FO_MASKED BIT_2
  1408. #define FCF_FAILOVER_NEEDED BIT_3
  1409. #define FCF_RESET_NEEDED BIT_4
  1410. #define FCF_PERSISTENT_BOUND BIT_5
  1411. #define FCF_TAPE_PRESENT BIT_6
  1412. #define FCF_FARP_DONE BIT_7
  1413. #define FCF_FARP_FAILED BIT_8
  1414. #define FCF_FARP_REPLY_NEEDED BIT_9
  1415. #define FCF_AUTH_REQ BIT_10
  1416. #define FCF_SEND_AUTH_REQ BIT_11
  1417. #define FCF_RECEIVE_AUTH_REQ BIT_12
  1418. #define FCF_AUTH_SUCCESS BIT_13
  1419. #define FCF_RLC_SUPPORT BIT_14
  1420. #define FCF_CONFIG BIT_15 /* Needed? */
  1421. #define FCF_RESCAN_NEEDED BIT_16
  1422. #define FCF_XP_DEVICE BIT_17
  1423. #define FCF_MSA_DEVICE BIT_18
  1424. #define FCF_EVA_DEVICE BIT_19
  1425. #define FCF_MSA_PORT_ACTIVE BIT_20
  1426. #define FCF_FAILBACK_DISABLE BIT_21
  1427. #define FCF_FAILOVER_DISABLE BIT_22
  1428. #define FCF_DSXXX_DEVICE BIT_23
  1429. #define FCF_AA_EVA_DEVICE BIT_24
  1430. #define FCF_AA_MSA_DEVICE BIT_25
  1431. /* No loop ID flag. */
  1432. #define FC_NO_LOOP_ID 0x1000
  1433. /*
  1434. * FC-CT interface
  1435. *
  1436. * NOTE: All structures are big-endian in form.
  1437. */
  1438. #define CT_REJECT_RESPONSE 0x8001
  1439. #define CT_ACCEPT_RESPONSE 0x8002
  1440. #define CT_REASON_CANNOT_PERFORM 0x09
  1441. #define CT_EXPL_ALREADY_REGISTERED 0x10
  1442. #define NS_N_PORT_TYPE 0x01
  1443. #define NS_NL_PORT_TYPE 0x02
  1444. #define NS_NX_PORT_TYPE 0x7F
  1445. #define GA_NXT_CMD 0x100
  1446. #define GA_NXT_REQ_SIZE (16 + 4)
  1447. #define GA_NXT_RSP_SIZE (16 + 620)
  1448. #define GID_PT_CMD 0x1A1
  1449. #define GID_PT_REQ_SIZE (16 + 4)
  1450. #define GID_PT_RSP_SIZE (16 + (MAX_FIBRE_DEVICES * 4))
  1451. #define GPN_ID_CMD 0x112
  1452. #define GPN_ID_REQ_SIZE (16 + 4)
  1453. #define GPN_ID_RSP_SIZE (16 + 8)
  1454. #define GNN_ID_CMD 0x113
  1455. #define GNN_ID_REQ_SIZE (16 + 4)
  1456. #define GNN_ID_RSP_SIZE (16 + 8)
  1457. #define GFT_ID_CMD 0x117
  1458. #define GFT_ID_REQ_SIZE (16 + 4)
  1459. #define GFT_ID_RSP_SIZE (16 + 32)
  1460. #define RFT_ID_CMD 0x217
  1461. #define RFT_ID_REQ_SIZE (16 + 4 + 32)
  1462. #define RFT_ID_RSP_SIZE 16
  1463. #define RFF_ID_CMD 0x21F
  1464. #define RFF_ID_REQ_SIZE (16 + 4 + 2 + 1 + 1)
  1465. #define RFF_ID_RSP_SIZE 16
  1466. #define RNN_ID_CMD 0x213
  1467. #define RNN_ID_REQ_SIZE (16 + 4 + 8)
  1468. #define RNN_ID_RSP_SIZE 16
  1469. #define RSNN_NN_CMD 0x239
  1470. #define RSNN_NN_REQ_SIZE (16 + 8 + 1 + 255)
  1471. #define RSNN_NN_RSP_SIZE 16
  1472. /*
  1473. * HBA attribute types.
  1474. */
  1475. #define FDMI_HBA_ATTR_COUNT 9
  1476. #define FDMI_HBA_NODE_NAME 1
  1477. #define FDMI_HBA_MANUFACTURER 2
  1478. #define FDMI_HBA_SERIAL_NUMBER 3
  1479. #define FDMI_HBA_MODEL 4
  1480. #define FDMI_HBA_MODEL_DESCRIPTION 5
  1481. #define FDMI_HBA_HARDWARE_VERSION 6
  1482. #define FDMI_HBA_DRIVER_VERSION 7
  1483. #define FDMI_HBA_OPTION_ROM_VERSION 8
  1484. #define FDMI_HBA_FIRMWARE_VERSION 9
  1485. #define FDMI_HBA_OS_NAME_AND_VERSION 0xa
  1486. #define FDMI_HBA_MAXIMUM_CT_PAYLOAD_LENGTH 0xb
  1487. struct ct_fdmi_hba_attr {
  1488. uint16_t type;
  1489. uint16_t len;
  1490. union {
  1491. uint8_t node_name[WWN_SIZE];
  1492. uint8_t manufacturer[32];
  1493. uint8_t serial_num[8];
  1494. uint8_t model[16];
  1495. uint8_t model_desc[80];
  1496. uint8_t hw_version[16];
  1497. uint8_t driver_version[32];
  1498. uint8_t orom_version[16];
  1499. uint8_t fw_version[16];
  1500. uint8_t os_version[128];
  1501. uint8_t max_ct_len[4];
  1502. } a;
  1503. };
  1504. struct ct_fdmi_hba_attributes {
  1505. uint32_t count;
  1506. struct ct_fdmi_hba_attr entry[FDMI_HBA_ATTR_COUNT];
  1507. };
  1508. /*
  1509. * Port attribute types.
  1510. */
  1511. #define FDMI_PORT_ATTR_COUNT 5
  1512. #define FDMI_PORT_FC4_TYPES 1
  1513. #define FDMI_PORT_SUPPORT_SPEED 2
  1514. #define FDMI_PORT_CURRENT_SPEED 3
  1515. #define FDMI_PORT_MAX_FRAME_SIZE 4
  1516. #define FDMI_PORT_OS_DEVICE_NAME 5
  1517. #define FDMI_PORT_HOST_NAME 6
  1518. struct ct_fdmi_port_attr {
  1519. uint16_t type;
  1520. uint16_t len;
  1521. union {
  1522. uint8_t fc4_types[32];
  1523. uint32_t sup_speed;
  1524. uint32_t cur_speed;
  1525. uint32_t max_frame_size;
  1526. uint8_t os_dev_name[32];
  1527. uint8_t host_name[32];
  1528. } a;
  1529. };
  1530. /*
  1531. * Port Attribute Block.
  1532. */
  1533. struct ct_fdmi_port_attributes {
  1534. uint32_t count;
  1535. struct ct_fdmi_port_attr entry[FDMI_PORT_ATTR_COUNT];
  1536. };
  1537. /* FDMI definitions. */
  1538. #define GRHL_CMD 0x100
  1539. #define GHAT_CMD 0x101
  1540. #define GRPL_CMD 0x102
  1541. #define GPAT_CMD 0x110
  1542. #define RHBA_CMD 0x200
  1543. #define RHBA_RSP_SIZE 16
  1544. #define RHAT_CMD 0x201
  1545. #define RPRT_CMD 0x210
  1546. #define RPA_CMD 0x211
  1547. #define RPA_RSP_SIZE 16
  1548. #define DHBA_CMD 0x300
  1549. #define DHBA_REQ_SIZE (16 + 8)
  1550. #define DHBA_RSP_SIZE 16
  1551. #define DHAT_CMD 0x301
  1552. #define DPRT_CMD 0x310
  1553. #define DPA_CMD 0x311
  1554. /* CT command header -- request/response common fields */
  1555. struct ct_cmd_hdr {
  1556. uint8_t revision;
  1557. uint8_t in_id[3];
  1558. uint8_t gs_type;
  1559. uint8_t gs_subtype;
  1560. uint8_t options;
  1561. uint8_t reserved;
  1562. };
  1563. /* CT command request */
  1564. struct ct_sns_req {
  1565. struct ct_cmd_hdr header;
  1566. uint16_t command;
  1567. uint16_t max_rsp_size;
  1568. uint8_t fragment_id;
  1569. uint8_t reserved[3];
  1570. union {
  1571. /* GA_NXT, GPN_ID, GNN_ID, GFT_ID */
  1572. struct {
  1573. uint8_t reserved;
  1574. uint8_t port_id[3];
  1575. } port_id;
  1576. struct {
  1577. uint8_t port_type;
  1578. uint8_t domain;
  1579. uint8_t area;
  1580. uint8_t reserved;
  1581. } gid_pt;
  1582. struct {
  1583. uint8_t reserved;
  1584. uint8_t port_id[3];
  1585. uint8_t fc4_types[32];
  1586. } rft_id;
  1587. struct {
  1588. uint8_t reserved;
  1589. uint8_t port_id[3];
  1590. uint16_t reserved2;
  1591. uint8_t fc4_feature;
  1592. uint8_t fc4_type;
  1593. } rff_id;
  1594. struct {
  1595. uint8_t reserved;
  1596. uint8_t port_id[3];
  1597. uint8_t node_name[8];
  1598. } rnn_id;
  1599. struct {
  1600. uint8_t node_name[8];
  1601. uint8_t name_len;
  1602. uint8_t sym_node_name[255];
  1603. } rsnn_nn;
  1604. struct {
  1605. uint8_t hba_indentifier[8];
  1606. } ghat;
  1607. struct {
  1608. uint8_t hba_identifier[8];
  1609. uint32_t entry_count;
  1610. uint8_t port_name[8];
  1611. struct ct_fdmi_hba_attributes attrs;
  1612. } rhba;
  1613. struct {
  1614. uint8_t hba_identifier[8];
  1615. struct ct_fdmi_hba_attributes attrs;
  1616. } rhat;
  1617. struct {
  1618. uint8_t port_name[8];
  1619. struct ct_fdmi_port_attributes attrs;
  1620. } rpa;
  1621. struct {
  1622. uint8_t port_name[8];
  1623. } dhba;
  1624. struct {
  1625. uint8_t port_name[8];
  1626. } dhat;
  1627. struct {
  1628. uint8_t port_name[8];
  1629. } dprt;
  1630. struct {
  1631. uint8_t port_name[8];
  1632. } dpa;
  1633. } req;
  1634. };
  1635. /* CT command response header */
  1636. struct ct_rsp_hdr {
  1637. struct ct_cmd_hdr header;
  1638. uint16_t response;
  1639. uint16_t residual;
  1640. uint8_t fragment_id;
  1641. uint8_t reason_code;
  1642. uint8_t explanation_code;
  1643. uint8_t vendor_unique;
  1644. };
  1645. struct ct_sns_gid_pt_data {
  1646. uint8_t control_byte;
  1647. uint8_t port_id[3];
  1648. };
  1649. struct ct_sns_rsp {
  1650. struct ct_rsp_hdr header;
  1651. union {
  1652. struct {
  1653. uint8_t port_type;
  1654. uint8_t port_id[3];
  1655. uint8_t port_name[8];
  1656. uint8_t sym_port_name_len;
  1657. uint8_t sym_port_name[255];
  1658. uint8_t node_name[8];
  1659. uint8_t sym_node_name_len;
  1660. uint8_t sym_node_name[255];
  1661. uint8_t init_proc_assoc[8];
  1662. uint8_t node_ip_addr[16];
  1663. uint8_t class_of_service[4];
  1664. uint8_t fc4_types[32];
  1665. uint8_t ip_address[16];
  1666. uint8_t fabric_port_name[8];
  1667. uint8_t reserved;
  1668. uint8_t hard_address[3];
  1669. } ga_nxt;
  1670. struct {
  1671. struct ct_sns_gid_pt_data entries[MAX_FIBRE_DEVICES];
  1672. } gid_pt;
  1673. struct {
  1674. uint8_t port_name[8];
  1675. } gpn_id;
  1676. struct {
  1677. uint8_t node_name[8];
  1678. } gnn_id;
  1679. struct {
  1680. uint8_t fc4_types[32];
  1681. } gft_id;
  1682. struct {
  1683. uint32_t entry_count;
  1684. uint8_t port_name[8];
  1685. struct ct_fdmi_hba_attributes attrs;
  1686. } ghat;
  1687. } rsp;
  1688. };
  1689. struct ct_sns_pkt {
  1690. union {
  1691. struct ct_sns_req req;
  1692. struct ct_sns_rsp rsp;
  1693. } p;
  1694. };
  1695. /*
  1696. * SNS command structures -- for 2200 compatability.
  1697. */
  1698. #define RFT_ID_SNS_SCMD_LEN 22
  1699. #define RFT_ID_SNS_CMD_SIZE 60
  1700. #define RFT_ID_SNS_DATA_SIZE 16
  1701. #define RNN_ID_SNS_SCMD_LEN 10
  1702. #define RNN_ID_SNS_CMD_SIZE 36
  1703. #define RNN_ID_SNS_DATA_SIZE 16
  1704. #define GA_NXT_SNS_SCMD_LEN 6
  1705. #define GA_NXT_SNS_CMD_SIZE 28
  1706. #define GA_NXT_SNS_DATA_SIZE (620 + 16)
  1707. #define GID_PT_SNS_SCMD_LEN 6
  1708. #define GID_PT_SNS_CMD_SIZE 28
  1709. #define GID_PT_SNS_DATA_SIZE (MAX_FIBRE_DEVICES * 4 + 16)
  1710. #define GPN_ID_SNS_SCMD_LEN 6
  1711. #define GPN_ID_SNS_CMD_SIZE 28
  1712. #define GPN_ID_SNS_DATA_SIZE (8 + 16)
  1713. #define GNN_ID_SNS_SCMD_LEN 6
  1714. #define GNN_ID_SNS_CMD_SIZE 28
  1715. #define GNN_ID_SNS_DATA_SIZE (8 + 16)
  1716. struct sns_cmd_pkt {
  1717. union {
  1718. struct {
  1719. uint16_t buffer_length;
  1720. uint16_t reserved_1;
  1721. uint32_t buffer_address[2];
  1722. uint16_t subcommand_length;
  1723. uint16_t reserved_2;
  1724. uint16_t subcommand;
  1725. uint16_t size;
  1726. uint32_t reserved_3;
  1727. uint8_t param[36];
  1728. } cmd;
  1729. uint8_t rft_data[RFT_ID_SNS_DATA_SIZE];
  1730. uint8_t rnn_data[RNN_ID_SNS_DATA_SIZE];
  1731. uint8_t gan_data[GA_NXT_SNS_DATA_SIZE];
  1732. uint8_t gid_data[GID_PT_SNS_DATA_SIZE];
  1733. uint8_t gpn_data[GPN_ID_SNS_DATA_SIZE];
  1734. uint8_t gnn_data[GNN_ID_SNS_DATA_SIZE];
  1735. } p;
  1736. };
  1737. struct fw_blob {
  1738. char *name;
  1739. uint32_t segs[4];
  1740. const struct firmware *fw;
  1741. };
  1742. /* Return data from MBC_GET_ID_LIST call. */
  1743. struct gid_list_info {
  1744. uint8_t al_pa;
  1745. uint8_t area;
  1746. uint8_t domain;
  1747. uint8_t loop_id_2100; /* ISP2100/ISP2200 -- 4 bytes. */
  1748. uint16_t loop_id; /* ISP23XX -- 6 bytes. */
  1749. uint16_t reserved_1; /* ISP24XX -- 8 bytes. */
  1750. };
  1751. #define GID_LIST_SIZE (sizeof(struct gid_list_info) * MAX_FIBRE_DEVICES)
  1752. /*
  1753. * ISP operations
  1754. */
  1755. struct isp_operations {
  1756. int (*pci_config) (struct scsi_qla_host *);
  1757. void (*reset_chip) (struct scsi_qla_host *);
  1758. int (*chip_diag) (struct scsi_qla_host *);
  1759. void (*config_rings) (struct scsi_qla_host *);
  1760. void (*reset_adapter) (struct scsi_qla_host *);
  1761. int (*nvram_config) (struct scsi_qla_host *);
  1762. void (*update_fw_options) (struct scsi_qla_host *);
  1763. int (*load_risc) (struct scsi_qla_host *, uint32_t *);
  1764. char * (*pci_info_str) (struct scsi_qla_host *, char *);
  1765. char * (*fw_version_str) (struct scsi_qla_host *, char *);
  1766. irqreturn_t (*intr_handler) (int, void *, struct pt_regs *);
  1767. void (*enable_intrs) (struct scsi_qla_host *);
  1768. void (*disable_intrs) (struct scsi_qla_host *);
  1769. int (*abort_command) (struct scsi_qla_host *, srb_t *);
  1770. int (*abort_target) (struct fc_port *);
  1771. int (*fabric_login) (struct scsi_qla_host *, uint16_t, uint8_t,
  1772. uint8_t, uint8_t, uint16_t *, uint8_t);
  1773. int (*fabric_logout) (struct scsi_qla_host *, uint16_t, uint8_t,
  1774. uint8_t, uint8_t);
  1775. uint16_t (*calc_req_entries) (uint16_t);
  1776. void (*build_iocbs) (srb_t *, cmd_entry_t *, uint16_t);
  1777. void * (*prep_ms_iocb) (struct scsi_qla_host *, uint32_t, uint32_t);
  1778. void * (*prep_ms_fdmi_iocb) (struct scsi_qla_host *, uint32_t,
  1779. uint32_t);
  1780. uint8_t * (*read_nvram) (struct scsi_qla_host *, uint8_t *,
  1781. uint32_t, uint32_t);
  1782. int (*write_nvram) (struct scsi_qla_host *, uint8_t *, uint32_t,
  1783. uint32_t);
  1784. void (*fw_dump) (struct scsi_qla_host *, int);
  1785. void (*ascii_fw_dump) (struct scsi_qla_host *);
  1786. int (*beacon_on) (struct scsi_qla_host *);
  1787. int (*beacon_off) (struct scsi_qla_host *);
  1788. void (*beacon_blink) (struct scsi_qla_host *);
  1789. uint8_t * (*read_optrom) (struct scsi_qla_host *, uint8_t *,
  1790. uint32_t, uint32_t);
  1791. int (*write_optrom) (struct scsi_qla_host *, uint8_t *, uint32_t,
  1792. uint32_t);
  1793. };
  1794. /*
  1795. * Linux Host Adapter structure
  1796. */
  1797. typedef struct scsi_qla_host {
  1798. struct list_head list;
  1799. /* Commonly used flags and state information. */
  1800. struct Scsi_Host *host;
  1801. struct pci_dev *pdev;
  1802. unsigned long host_no;
  1803. unsigned long instance;
  1804. volatile struct {
  1805. uint32_t init_done :1;
  1806. uint32_t online :1;
  1807. uint32_t mbox_int :1;
  1808. uint32_t mbox_busy :1;
  1809. uint32_t rscn_queue_overflow :1;
  1810. uint32_t reset_active :1;
  1811. uint32_t management_server_logged_in :1;
  1812. uint32_t process_response_queue :1;
  1813. uint32_t disable_risc_code_load :1;
  1814. uint32_t enable_64bit_addressing :1;
  1815. uint32_t enable_lip_reset :1;
  1816. uint32_t enable_lip_full_login :1;
  1817. uint32_t enable_target_reset :1;
  1818. uint32_t enable_led_scheme :1;
  1819. uint32_t msi_enabled :1;
  1820. uint32_t msix_enabled :1;
  1821. } flags;
  1822. atomic_t loop_state;
  1823. #define LOOP_TIMEOUT 1
  1824. #define LOOP_DOWN 2
  1825. #define LOOP_UP 3
  1826. #define LOOP_UPDATE 4
  1827. #define LOOP_READY 5
  1828. #define LOOP_DEAD 6
  1829. unsigned long dpc_flags;
  1830. #define RESET_MARKER_NEEDED 0 /* Send marker to ISP. */
  1831. #define RESET_ACTIVE 1
  1832. #define ISP_ABORT_NEEDED 2 /* Initiate ISP abort. */
  1833. #define ABORT_ISP_ACTIVE 3 /* ISP abort in progress. */
  1834. #define LOOP_RESYNC_NEEDED 4 /* Device Resync needed. */
  1835. #define LOOP_RESYNC_ACTIVE 5
  1836. #define LOCAL_LOOP_UPDATE 6 /* Perform a local loop update. */
  1837. #define RSCN_UPDATE 7 /* Perform an RSCN update. */
  1838. #define MAILBOX_RETRY 8
  1839. #define ISP_RESET_NEEDED 9 /* Initiate a ISP reset. */
  1840. #define FAILOVER_EVENT_NEEDED 10
  1841. #define FAILOVER_EVENT 11
  1842. #define FAILOVER_NEEDED 12
  1843. #define SCSI_RESTART_NEEDED 13 /* Processes SCSI retry queue. */
  1844. #define PORT_RESTART_NEEDED 14 /* Processes Retry queue. */
  1845. #define RESTART_QUEUES_NEEDED 15 /* Restarts the Lun queue. */
  1846. #define ABORT_QUEUES_NEEDED 16
  1847. #define RELOGIN_NEEDED 17
  1848. #define LOGIN_RETRY_NEEDED 18 /* Initiate required fabric logins. */
  1849. #define REGISTER_FC4_NEEDED 19 /* SNS FC4 registration required. */
  1850. #define ISP_ABORT_RETRY 20 /* ISP aborted. */
  1851. #define FCPORT_RESCAN_NEEDED 21 /* IO descriptor processing needed */
  1852. #define IODESC_PROCESS_NEEDED 22 /* IO descriptor processing needed */
  1853. #define IOCTL_ERROR_RECOVERY 23
  1854. #define LOOP_RESET_NEEDED 24
  1855. #define BEACON_BLINK_NEEDED 25
  1856. #define REGISTER_FDMI_NEEDED 26
  1857. #define FCPORT_UPDATE_NEEDED 27
  1858. uint32_t device_flags;
  1859. #define DFLG_LOCAL_DEVICES BIT_0
  1860. #define DFLG_RETRY_LOCAL_DEVICES BIT_1
  1861. #define DFLG_FABRIC_DEVICES BIT_2
  1862. #define SWITCH_FOUND BIT_3
  1863. #define DFLG_NO_CABLE BIT_4
  1864. uint32_t device_type;
  1865. #define DT_ISP2100 BIT_0
  1866. #define DT_ISP2200 BIT_1
  1867. #define DT_ISP2300 BIT_2
  1868. #define DT_ISP2312 BIT_3
  1869. #define DT_ISP2322 BIT_4
  1870. #define DT_ISP6312 BIT_5
  1871. #define DT_ISP6322 BIT_6
  1872. #define DT_ISP2422 BIT_7
  1873. #define DT_ISP2432 BIT_8
  1874. #define DT_ISP5422 BIT_9
  1875. #define DT_ISP5432 BIT_10
  1876. #define DT_ISP_LAST (DT_ISP5432 << 1)
  1877. #define DT_ZIO_SUPPORTED BIT_28
  1878. #define DT_OEM_001 BIT_29
  1879. #define DT_ISP2200A BIT_30
  1880. #define DT_EXTENDED_IDS BIT_31
  1881. #define DT_MASK(ha) ((ha)->device_type & (DT_ISP_LAST - 1))
  1882. #define IS_QLA2100(ha) (DT_MASK(ha) & DT_ISP2100)
  1883. #define IS_QLA2200(ha) (DT_MASK(ha) & DT_ISP2200)
  1884. #define IS_QLA2300(ha) (DT_MASK(ha) & DT_ISP2300)
  1885. #define IS_QLA2312(ha) (DT_MASK(ha) & DT_ISP2312)
  1886. #define IS_QLA2322(ha) (DT_MASK(ha) & DT_ISP2322)
  1887. #define IS_QLA6312(ha) (DT_MASK(ha) & DT_ISP6312)
  1888. #define IS_QLA6322(ha) (DT_MASK(ha) & DT_ISP6322)
  1889. #define IS_QLA2422(ha) (DT_MASK(ha) & DT_ISP2422)
  1890. #define IS_QLA2432(ha) (DT_MASK(ha) & DT_ISP2432)
  1891. #define IS_QLA5422(ha) (DT_MASK(ha) & DT_ISP5422)
  1892. #define IS_QLA5432(ha) (DT_MASK(ha) & DT_ISP5432)
  1893. #define IS_QLA23XX(ha) (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \
  1894. IS_QLA6312(ha) || IS_QLA6322(ha))
  1895. #define IS_QLA24XX(ha) (IS_QLA2422(ha) || IS_QLA2432(ha))
  1896. #define IS_QLA54XX(ha) (IS_QLA5422(ha) || IS_QLA5432(ha))
  1897. #define IS_ZIO_SUPPORTED(ha) ((ha)->device_type & DT_ZIO_SUPPORTED)
  1898. #define IS_OEM_001(ha) ((ha)->device_type & DT_OEM_001)
  1899. #define HAS_EXTENDED_IDS(ha) ((ha)->device_type & DT_EXTENDED_IDS)
  1900. /* SRB cache. */
  1901. #define SRB_MIN_REQ 128
  1902. mempool_t *srb_mempool;
  1903. /* This spinlock is used to protect "io transactions", you must
  1904. * aquire it before doing any IO to the card, eg with RD_REG*() and
  1905. * WRT_REG*() for the duration of your entire commandtransaction.
  1906. *
  1907. * This spinlock is of lower priority than the io request lock.
  1908. */
  1909. spinlock_t hardware_lock ____cacheline_aligned;
  1910. device_reg_t __iomem *iobase; /* Base I/O address */
  1911. unsigned long pio_address;
  1912. unsigned long pio_length;
  1913. #define MIN_IOBASE_LEN 0x100
  1914. /* ISP ring lock, rings, and indexes */
  1915. dma_addr_t request_dma; /* Physical address. */
  1916. request_t *request_ring; /* Base virtual address */
  1917. request_t *request_ring_ptr; /* Current address. */
  1918. uint16_t req_ring_index; /* Current index. */
  1919. uint16_t req_q_cnt; /* Number of available entries. */
  1920. uint16_t request_q_length;
  1921. dma_addr_t response_dma; /* Physical address. */
  1922. response_t *response_ring; /* Base virtual address */
  1923. response_t *response_ring_ptr; /* Current address. */
  1924. uint16_t rsp_ring_index; /* Current index. */
  1925. uint16_t response_q_length;
  1926. struct isp_operations isp_ops;
  1927. /* Outstandings ISP commands. */
  1928. srb_t *outstanding_cmds[MAX_OUTSTANDING_COMMANDS];
  1929. uint32_t current_outstanding_cmd;
  1930. srb_t *status_srb; /* Status continuation entry. */
  1931. /* ISP configuration data. */
  1932. uint16_t loop_id; /* Host adapter loop id */
  1933. uint16_t fb_rev;
  1934. port_id_t d_id; /* Host adapter port id */
  1935. uint16_t max_public_loop_ids;
  1936. uint16_t min_external_loopid; /* First external loop Id */
  1937. uint16_t link_data_rate; /* F/W operating speed */
  1938. #define LDR_1GB 0
  1939. #define LDR_2GB 1
  1940. #define LDR_4GB 3
  1941. #define LDR_UNKNOWN 0xFFFF
  1942. uint8_t current_topology;
  1943. uint8_t prev_topology;
  1944. #define ISP_CFG_NL 1
  1945. #define ISP_CFG_N 2
  1946. #define ISP_CFG_FL 4
  1947. #define ISP_CFG_F 8
  1948. uint8_t operating_mode; /* F/W operating mode */
  1949. #define LOOP 0
  1950. #define P2P 1
  1951. #define LOOP_P2P 2
  1952. #define P2P_LOOP 3
  1953. uint8_t marker_needed;
  1954. uint8_t interrupts_on;
  1955. /* HBA serial number */
  1956. uint8_t serial0;
  1957. uint8_t serial1;
  1958. uint8_t serial2;
  1959. /* NVRAM configuration data */
  1960. uint16_t nvram_size;
  1961. uint16_t nvram_base;
  1962. uint16_t vpd_size;
  1963. uint16_t vpd_base;
  1964. uint16_t loop_reset_delay;
  1965. uint8_t retry_count;
  1966. uint8_t login_timeout;
  1967. uint16_t r_a_tov;
  1968. int port_down_retry_count;
  1969. uint8_t mbx_count;
  1970. uint16_t last_loop_id;
  1971. uint16_t mgmt_svr_loop_id;
  1972. uint32_t login_retry_count;
  1973. /* Fibre Channel Device List. */
  1974. struct list_head fcports;
  1975. /* RSCN queue. */
  1976. uint32_t rscn_queue[MAX_RSCN_COUNT];
  1977. uint8_t rscn_in_ptr;
  1978. uint8_t rscn_out_ptr;
  1979. /* SNS command interfaces. */
  1980. ms_iocb_entry_t *ms_iocb;
  1981. dma_addr_t ms_iocb_dma;
  1982. struct ct_sns_pkt *ct_sns;
  1983. dma_addr_t ct_sns_dma;
  1984. /* SNS command interfaces for 2200. */
  1985. struct sns_cmd_pkt *sns_cmd;
  1986. dma_addr_t sns_cmd_dma;
  1987. struct task_struct *dpc_thread;
  1988. uint8_t dpc_active; /* DPC routine is active */
  1989. /* Timeout timers. */
  1990. uint8_t loop_down_abort_time; /* port down timer */
  1991. atomic_t loop_down_timer; /* loop down timer */
  1992. uint8_t link_down_timeout; /* link down timeout */
  1993. uint32_t timer_active;
  1994. struct timer_list timer;
  1995. dma_addr_t gid_list_dma;
  1996. struct gid_list_info *gid_list;
  1997. int gid_list_info_size;
  1998. /* Small DMA pool allocations -- maximum 256 bytes in length. */
  1999. #define DMA_POOL_SIZE 256
  2000. struct dma_pool *s_dma_pool;
  2001. dma_addr_t init_cb_dma;
  2002. init_cb_t *init_cb;
  2003. int init_cb_size;
  2004. /* These are used by mailbox operations. */
  2005. volatile uint16_t mailbox_out[MAILBOX_REGISTER_COUNT];
  2006. mbx_cmd_t *mcp;
  2007. unsigned long mbx_cmd_flags;
  2008. #define MBX_INTERRUPT 1
  2009. #define MBX_INTR_WAIT 2
  2010. #define MBX_UPDATE_FLASH_ACTIVE 3
  2011. spinlock_t mbx_reg_lock; /* Mbx Cmd Register Lock */
  2012. struct semaphore mbx_cmd_sem; /* Serialialize mbx access */
  2013. struct semaphore mbx_intr_sem; /* Used for completion notification */
  2014. uint32_t mbx_flags;
  2015. #define MBX_IN_PROGRESS BIT_0
  2016. #define MBX_BUSY BIT_1 /* Got the Access */
  2017. #define MBX_SLEEPING_ON_SEM BIT_2
  2018. #define MBX_POLLING_FOR_COMP BIT_3
  2019. #define MBX_COMPLETED BIT_4
  2020. #define MBX_TIMEDOUT BIT_5
  2021. #define MBX_ACCESS_TIMEDOUT BIT_6
  2022. mbx_cmd_t mc;
  2023. /* Basic firmware related information. */
  2024. uint16_t fw_major_version;
  2025. uint16_t fw_minor_version;
  2026. uint16_t fw_subminor_version;
  2027. uint16_t fw_attributes;
  2028. uint32_t fw_memory_size;
  2029. uint32_t fw_transfer_size;
  2030. uint32_t fw_srisc_address;
  2031. #define RISC_START_ADDRESS_2100 0x1000
  2032. #define RISC_START_ADDRESS_2300 0x800
  2033. #define RISC_START_ADDRESS_2400 0x100000
  2034. uint16_t fw_options[16]; /* slots: 1,2,3,10,11 */
  2035. uint8_t fw_seriallink_options[4];
  2036. uint16_t fw_seriallink_options24[4];
  2037. /* Firmware dump information. */
  2038. void *fw_dump;
  2039. int fw_dump_order;
  2040. int fw_dump_reading;
  2041. char *fw_dump_buffer;
  2042. int fw_dump_buffer_len;
  2043. int fw_dumped;
  2044. void *fw_dump24;
  2045. int fw_dump24_len;
  2046. uint8_t host_str[16];
  2047. uint32_t pci_attr;
  2048. uint16_t product_id[4];
  2049. uint8_t model_number[16+1];
  2050. #define BINZERO "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
  2051. char *model_desc;
  2052. uint8_t adapter_id[16+1];
  2053. uint8_t *node_name;
  2054. uint8_t *port_name;
  2055. uint32_t isp_abort_cnt;
  2056. /* Option ROM information. */
  2057. char *optrom_buffer;
  2058. uint32_t optrom_size;
  2059. int optrom_state;
  2060. #define QLA_SWAITING 0
  2061. #define QLA_SREADING 1
  2062. #define QLA_SWRITING 2
  2063. /* Needed for BEACON */
  2064. uint16_t beacon_blink_led;
  2065. uint8_t beacon_color_state;
  2066. #define QLA_LED_GRN_ON 0x01
  2067. #define QLA_LED_YLW_ON 0x02
  2068. #define QLA_LED_ABR_ON 0x04
  2069. #define QLA_LED_ALL_ON 0x07 /* yellow, green, amber. */
  2070. /* ISP2322: red, green, amber. */
  2071. uint16_t zio_mode;
  2072. uint16_t zio_timer;
  2073. struct fc_host_statistics fc_host_stat;
  2074. } scsi_qla_host_t;
  2075. /*
  2076. * Macros to help code, maintain, etc.
  2077. */
  2078. #define LOOP_TRANSITION(ha) \
  2079. (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \
  2080. test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) || \
  2081. atomic_read(&ha->loop_state) == LOOP_DOWN)
  2082. #define to_qla_host(x) ((scsi_qla_host_t *) (x)->hostdata)
  2083. #define qla_printk(level, ha, format, arg...) \
  2084. dev_printk(level , &((ha)->pdev->dev) , format , ## arg)
  2085. /*
  2086. * qla2x00 local function return status codes
  2087. */
  2088. #define MBS_MASK 0x3fff
  2089. #define QLA_SUCCESS (MBS_COMMAND_COMPLETE & MBS_MASK)
  2090. #define QLA_INVALID_COMMAND (MBS_INVALID_COMMAND & MBS_MASK)
  2091. #define QLA_INTERFACE_ERROR (MBS_HOST_INTERFACE_ERROR & MBS_MASK)
  2092. #define QLA_TEST_FAILED (MBS_TEST_FAILED & MBS_MASK)
  2093. #define QLA_COMMAND_ERROR (MBS_COMMAND_ERROR & MBS_MASK)
  2094. #define QLA_PARAMETER_ERROR (MBS_COMMAND_PARAMETER_ERROR & MBS_MASK)
  2095. #define QLA_PORT_ID_USED (MBS_PORT_ID_USED & MBS_MASK)
  2096. #define QLA_LOOP_ID_USED (MBS_LOOP_ID_USED & MBS_MASK)
  2097. #define QLA_ALL_IDS_IN_USE (MBS_ALL_IDS_IN_USE & MBS_MASK)
  2098. #define QLA_NOT_LOGGED_IN (MBS_NOT_LOGGED_IN & MBS_MASK)
  2099. #define QLA_FUNCTION_TIMEOUT 0x100
  2100. #define QLA_FUNCTION_PARAMETER_ERROR 0x101
  2101. #define QLA_FUNCTION_FAILED 0x102
  2102. #define QLA_MEMORY_ALLOC_FAILED 0x103
  2103. #define QLA_LOCK_TIMEOUT 0x104
  2104. #define QLA_ABORTED 0x105
  2105. #define QLA_SUSPENDED 0x106
  2106. #define QLA_BUSY 0x107
  2107. #define QLA_RSCNS_HANDLED 0x108
  2108. #define QLA_ALREADY_REGISTERED 0x109
  2109. #define NVRAM_DELAY() udelay(10)
  2110. #define INVALID_HANDLE (MAX_OUTSTANDING_COMMANDS+1)
  2111. /*
  2112. * Flash support definitions
  2113. */
  2114. #define OPTROM_SIZE_2300 0x20000
  2115. #define OPTROM_SIZE_2322 0x100000
  2116. #define OPTROM_SIZE_24XX 0x100000
  2117. #include "qla_gbl.h"
  2118. #include "qla_dbg.h"
  2119. #include "qla_inline.h"
  2120. #define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr)
  2121. #define CMD_COMPL_STATUS(Cmnd) ((Cmnd)->SCp.this_residual)
  2122. #define CMD_RESID_LEN(Cmnd) ((Cmnd)->SCp.buffers_residual)
  2123. #define CMD_SCSI_STATUS(Cmnd) ((Cmnd)->SCp.Status)
  2124. #define CMD_ACTUAL_SNSLEN(Cmnd) ((Cmnd)->SCp.Message)
  2125. #define CMD_ENTRY_STATUS(Cmnd) ((Cmnd)->SCp.have_data_in)
  2126. #endif