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