qla_def.h 78 KB

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