7 #define MEGARAID_VERSION \
8 "v2.00.4 (Release Date: Thu Feb 9 08:51:30 EST 2006)\n"
21 #define MEGA_HAVE_COALESCING 0
28 #define MEGA_HAVE_CLUSTERING 1
37 #define MEGA_HAVE_STATS 0
44 #define MEGA_HAVE_ENH_PROC 1
46 #define MAX_DEV_TYPE 32
48 #define PCI_DEVICE_ID_DISCOVERY 0x000E
49 #define PCI_DEVICE_ID_PERC4_DI 0x000F
50 #define PCI_DEVICE_ID_PERC4_QC_VERDE 0x0407
52 #define HBA_SIGNATURE 0x3344
53 #define HBA_SIGNATURE_471 0xCCCC
54 #define HBA_SIGNATURE_64BIT 0x0299
56 #define MBOX_BUSY_WAIT 10
58 #define DEFAULT_INITIATOR_ID 7
62 #define MAX_COMMANDS 126
63 #define CMDID_INT_CMDS MAX_COMMANDS+1
67 #define MAX_CDB_LEN 10
68 #define MAX_EXT_CDB_LEN 16
70 #define DEF_CMD_PER_LUN 63
71 #define MAX_CMD_PER_LUN MAX_COMMANDS
72 #define MAX_FIRMWARE_STATUS 46
73 #define MAX_XFER_PER_CMD (64*1024)
74 #define MAX_SECTORS_PER_IO 128
76 #define MAX_LOGICAL_DRIVES_40LD 40
77 #define FC_MAX_PHYSICAL_DEVICES 256
78 #define MAX_LOGICAL_DRIVES_8LD 8
79 #define MAX_CHANNELS 5
81 #define MAX_PHYSICAL_DRIVES MAX_CHANNELS*MAX_TARGET
82 #define MAX_ROW_SIZE_40LD 32
83 #define MAX_ROW_SIZE_8LD 8
84 #define MAX_SPAN_DEPTH 8
123 #define MAX_REQ_SENSE_LEN 0x20
201 mega_passthru *
pthru;
203 mega_ext_passthru *epthru;
210 #define SCB_FREE 0x0000
211 #define SCB_ACTIVE 0x0001
212 #define SCB_PENDQ 0x0002
213 #define SCB_ISSUED 0x0004
214 #define SCB_ABORT 0x0008
215 #define SCB_RESET 0x0010
224 u32 config_signature;
294 #define MAX_NOTIFY_SIZE 0x80
295 #define CUR_NOTIFY_SIZE sizeof(struct notify)
305 u8 cache_flush_interval;
307 u8 drive_insert_count;
331 u8 max_targ_per_chan;
337 u8 cache_flush_interval;
341 u8 write_config_count;
343 u8 drive_inserted_count;
359 u8 dec_fault_bus_info;
379 mega_ldrv_info logdrv_info;
380 mega_pdrv_info pdrv_info;
386 mraid_inquiry raid_inq;
466 #define IOCTL_MAX_DATALEN 4096
477 #if BITS_PER_LONG == 32
481 #if BITS_PER_LONG == 64
489 #if BITS_PER_LONG == 32
493 #if BITS_PER_LONG == 64
505 #define MAX_CONTROLLERS 32
539 #define MEGAIOC_MAGIC 'm'
541 #define MEGAIOC_QNADAP 'm'
542 #define MEGAIOC_QDRVRVER 'e'
543 #define MEGAIOC_QADAPINFO 'g'
544 #define MKADAP(adapno) (MEGAIOC_MAGIC << 8 | (adapno) )
545 #define GETADAP(mkadap) ( (mkadap) ^ MEGAIOC_MAGIC << 8 )
554 #define VENDOR_SPECIFIC_COMMANDS 0xE0
555 #define MEGA_INTERNAL_CMD VENDOR_SPECIFIC_COMMANDS + 0x01
560 #define USCSICMD VENDOR_SPECIFIC_COMMANDS
565 #define UIOC_RD 0x00001
566 #define UIOC_WR 0x00002
571 #define MBOX_CMD 0x00000
572 #define GET_DRIVER_VER 0x10000
573 #define GET_N_ADAP 0x20000
574 #define GET_ADAP_INFO 0x30000
575 #define GET_CAP 0x40000
576 #define GET_STATS 0x50000
593 #define uioc_rmbox __ua.__raw_mbox
594 #define MBOX(uioc) ((megacmd_t *)&((uioc).__ua.__raw_mbox[0]))
595 #define MBOX_P(uioc) ((megacmd_t __user *)&((uioc)->__ua.__raw_mbox[0]))
596 #define uioc_uaddr __ua.__uaddr
656 #define MEGA_MBOXCMD_LREAD 0x01
657 #define MEGA_MBOXCMD_LWRITE 0x02
658 #define MEGA_MBOXCMD_PASSTHRU 0x03
659 #define MEGA_MBOXCMD_ADPEXTINQ 0x04
660 #define MEGA_MBOXCMD_ADAPTERINQ 0x05
661 #define MEGA_MBOXCMD_LREAD64 0xA7
662 #define MEGA_MBOXCMD_LWRITE64 0xA8
663 #define MEGA_MBOXCMD_PASSTHRU64 0xC3
664 #define MEGA_MBOXCMD_EXTPTHRU 0xE3
666 #define MAIN_MISC_OPCODE 0xA4
667 #define GET_MAX_SG_SUPPORT 0x01
669 #define FC_NEW_CONFIG 0xA1
670 #define NC_SUBOP_PRODUCT_INFO 0x0E
671 #define NC_SUBOP_ENQUIRY3 0x0F
672 #define ENQ3_GET_SOLICITED_FULL 0x02
673 #define OP_DCMD_READ_CONFIG 0x04
674 #define NEW_READ_CONFIG_8LD 0x67
675 #define READ_CONFIG_8LD 0x07
676 #define FLUSH_ADAPTER 0x0A
677 #define FLUSH_SYSTEM 0xFE
682 #define FC_DEL_LOGDRV 0xA4
683 #define OP_SUP_DEL_LOGDRV 0x2A
684 #define OP_GET_LDID_MAP 0x18
685 #define OP_DEL_LOGDRV 0x1C
690 #define IS_BIOS_ENABLED 0x62
691 #define GET_BIOS 0x01
692 #define CHNL_CLASS 0xA9
693 #define GET_CHNL_CLASS 0x00
694 #define SET_CHNL_CLASS 0x01
697 #define BIOS_PVT_DATA 0x40
698 #define GET_BIOS_PVT_DATA 0x00
704 #define MEGA_GET_TARGET_ID 0x7D
705 #define MEGA_CLUSTER_OP 0x70
706 #define MEGA_GET_CLUSTER_MODE 0x02
707 #define MEGA_CLUSTER_CMD 0x6E
708 #define MEGA_RESERVE_LD 0x01
709 #define MEGA_RELEASE_LD 0x02
710 #define MEGA_RESET_RESERVATIONS 0x03
711 #define MEGA_RESERVATION_STATUS 0x04
712 #define MEGA_RESERVE_PD 0x05
713 #define MEGA_RELEASE_PD 0x06
719 #define MEGA_BATT_MODULE_MISSING 0x01
720 #define MEGA_BATT_LOW_VOLTAGE 0x02
721 #define MEGA_BATT_TEMP_HIGH 0x04
722 #define MEGA_BATT_PACK_MISSING 0x08
723 #define MEGA_BATT_CHARGE_MASK 0x30
724 #define MEGA_BATT_CHARGE_DONE 0x00
725 #define MEGA_BATT_CHARGE_INPROG 0x10
726 #define MEGA_BATT_CHARGE_FAIL 0x20
727 #define MEGA_BATT_CYCLES_EXCEEDED 0x40
733 #define PDRV_ONLINE 3
734 #define PDRV_FAILED 4
736 #define PDRV_HOTSPARE 6
742 #define RDRV_OFFLINE 0
743 #define RDRV_DEGRADED 1
744 #define RDRV_OPTIMAL 2
745 #define RDRV_DELETED 3
750 #define NO_READ_AHEAD 0
752 #define ADAP_READ_AHEAD 2
753 #define WRMODE_WRITE_THRU 0
754 #define WRMODE_WRITE_BACK 1
759 #define SCSI_LIST(scp) ((struct list_head *)(&(scp)->SCp))
773 mbox64_t *una_mbox64;
776 volatile mbox64_t *mbox64;
777 volatile mbox_t *
mbox;
788 #define MEGA_BUFFER_SIZE (2*1024)
814 #ifdef CONFIG_PROC_FS
820 #if MEGA_HAVE_ENH_PROC
823 #define MAX_PROC_CHANNELS 4
832 int boot_ldrv_enabled;
834 int boot_pdrv_enabled;
839 int support_random_del;
858 struct mutex int_mtx;
877 #define IN_ABORT 0x80000000L
878 #define IN_RESET 0x40000000L
879 #define BOARD_MEMMAP 0x20000000L
880 #define BOARD_IOMAP 0x10000000L
881 #define BOARD_40LD 0x08000000L
882 #define BOARD_64BIT 0x04000000L
884 #define INTR_VALID 0x40
886 #define PCI_CONF_AMISIG 0xa0
887 #define PCI_CONF_AMISIG64 0xa4
890 #define MEGA_DMA_TYPE_NONE 0xFFFF
891 #define MEGA_BULK_DATA 0x0001
892 #define MEGA_SGLIST 0x0002
899 #define CMD_PORT 0x00
900 #define ACK_PORT 0x00
901 #define TOGGLE_PORT 0x01
902 #define INTR_PORT 0x0a
904 #define MBOX_BUSY_PORT 0x00
905 #define MBOX_PORT0 0x04
906 #define MBOX_PORT1 0x05
907 #define MBOX_PORT2 0x06
908 #define MBOX_PORT3 0x07
909 #define ENABLE_MBOX_REGION 0x0B
912 #define ISSUE_BYTE 0x10
913 #define ACK_BYTE 0x08
914 #define ENABLE_INTR_BYTE 0xc0
915 #define DISABLE_INTR_BYTE 0x00
916 #define VALID_INTR_BYTE 0x40
917 #define MBOX_BUSY_BYTE 0x10
918 #define ENABLE_MBOX_BYTE 0x00
922 #define issue_command(adapter) \
923 outb_p(ISSUE_BYTE, (adapter)->base + CMD_PORT)
925 #define irq_state(adapter) inb_p((adapter)->base + INTR_PORT)
927 #define set_irq_state(adapter, value) \
928 outb_p((value), (adapter)->base + INTR_PORT)
930 #define irq_ack(adapter) \
931 outb_p(ACK_BYTE, (adapter)->base + ACK_PORT)
933 #define irq_enable(adapter) \
934 outb_p(ENABLE_INTR_BYTE, (adapter)->base + TOGGLE_PORT)
936 #define irq_disable(adapter) \
937 outb_p(DISABLE_INTR_BYTE, (adapter)->base + TOGGLE_PORT)
951 static int mega_query_adapter(
adapter_t *);
953 static int mega_setup_mailbox(
adapter_t *);
957 static void __mega_runpendq(
adapter_t *);
960 static irqreturn_t megaraid_isr_memmapped(
int,
void *);
961 static irqreturn_t megaraid_isr_iomapped(
int,
void *);
973 static int __mega_busywait_mbox (
adapter_t *);
975 static void mega_cmd_done(
adapter_t *,
u8 [],
int,
int);
977 static void mega_8_to_40ld (mraid_inquiry *
inquiry,
978 mega_inquiry3 *enquiry3, mega_product_info *);
980 static int megadev_open (
struct inode *,
struct file *);
981 static int megadev_ioctl (
struct file *,
unsigned int,
unsigned long);
982 static int mega_m_to_n(
void __user *,
nitioctl_t *);
983 static int mega_n_to_m(
void __user *, megacmd_t *);
987 static int mega_is_bios_enabled (
adapter_t *);
989 #ifdef CONFIG_PROC_FS
990 static int mega_print_inquiry(
char *,
char *);
992 static int proc_read_config(
char *,
char **,
off_t,
int,
int *,
void *);
993 static int proc_read_stat(
char *,
char **,
off_t,
int,
int *,
void *);
994 static int proc_read_mbox(
char *,
char **,
off_t,
int,
int *,
void *);
995 static int proc_rebuild_rate(
char *,
char **,
off_t,
int,
int *,
void *);
996 static int proc_battery(
char *,
char **,
off_t,
int,
int *,
void *);
997 static int proc_pdrv_ch0(
char *,
char **,
off_t,
int,
int *,
void *);
998 static int proc_pdrv_ch1(
char *,
char **,
off_t,
int,
int *,
void *);
999 static int proc_pdrv_ch2(
char *,
char **,
off_t,
int,
int *,
void *);
1000 static int proc_pdrv_ch3(
char *,
char **,
off_t,
int,
int *,
void *);
1001 static int proc_pdrv(
adapter_t *,
char *,
int);
1002 static int proc_rdrv_10(
char *,
char **,
off_t,
int,
int *,
void *);
1003 static int proc_rdrv_20(
char *,
char **,
off_t,
int,
int *,
void *);
1004 static int proc_rdrv_30(
char *,
char **,
off_t,
int,
int *,
void *);
1005 static int proc_rdrv_40(
char *,
char **,
off_t,
int,
int *,
void *);
1006 static int proc_rdrv(
adapter_t *,
char *,
int,
int);
1012 static int mega_support_ext_cdb(
adapter_t *);
1013 static mega_passthru* mega_prepare_passthru(
adapter_t *,
scb_t *,
1015 static mega_ext_passthru* mega_prepare_extpassthru(
adapter_t *,
1017 static void mega_enum_raid_scsi(
adapter_t *);
1018 static void mega_get_boot_drv(
adapter_t *);
1019 static int mega_support_random_del(
adapter_t *);
1020 static int mega_del_logdrv(
adapter_t *,
int);
1021 static int mega_do_del_logdrv(
adapter_t *,
int);
1022 static void mega_get_max_sgl(
adapter_t *);
1023 static int mega_internal_command(
adapter_t *, megacmd_t *, mega_passthru *);
1024 static void mega_internal_done(
Scsi_Cmnd *);
1025 static int mega_support_cluster(
adapter_t *);