0001
0002 #ifndef __MEGARAID_H__
0003 #define __MEGARAID_H__
0004
0005 #include <linux/spinlock.h>
0006 #include <linux/mutex.h>
0007 #include <scsi/scsi_cmnd.h>
0008
0009 #define MEGARAID_VERSION \
0010 "v2.00.4 (Release Date: Thu Feb 9 08:51:30 EST 2006)\n"
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #define MEGA_HAVE_COALESCING 0
0024
0025
0026
0027
0028
0029
0030 #define MEGA_HAVE_CLUSTERING 1
0031
0032
0033
0034
0035
0036
0037
0038
0039 #define MEGA_HAVE_STATS 0
0040
0041
0042
0043
0044
0045
0046 #define MEGA_HAVE_ENH_PROC 1
0047
0048 #define MAX_DEV_TYPE 32
0049
0050 #define PCI_DEVICE_ID_DISCOVERY 0x000E
0051 #define PCI_DEVICE_ID_PERC4_DI 0x000F
0052 #define PCI_DEVICE_ID_PERC4_QC_VERDE 0x0407
0053
0054 #define HBA_SIGNATURE 0x3344
0055 #define HBA_SIGNATURE_471 0xCCCC
0056 #define HBA_SIGNATURE_64BIT 0x0299
0057
0058 #define MBOX_BUSY_WAIT 10
0059
0060 #define DEFAULT_INITIATOR_ID 7
0061
0062 #define MAX_SGLIST 64
0063 #define MIN_SGLIST 26
0064 #define MAX_COMMANDS 126
0065 #define CMDID_INT_CMDS MAX_COMMANDS+1
0066
0067
0068
0069 #define MAX_CDB_LEN 10
0070 #define MAX_EXT_CDB_LEN 16
0071
0072 #define DEF_CMD_PER_LUN 63
0073 #define MAX_CMD_PER_LUN MAX_COMMANDS
0074 #define MAX_FIRMWARE_STATUS 46
0075 #define MAX_XFER_PER_CMD (64*1024)
0076 #define MAX_SECTORS_PER_IO 128
0077
0078 #define MAX_LOGICAL_DRIVES_40LD 40
0079 #define FC_MAX_PHYSICAL_DEVICES 256
0080 #define MAX_LOGICAL_DRIVES_8LD 8
0081 #define MAX_CHANNELS 5
0082 #define MAX_TARGET 15
0083 #define MAX_PHYSICAL_DRIVES MAX_CHANNELS*MAX_TARGET
0084 #define MAX_ROW_SIZE_40LD 32
0085 #define MAX_ROW_SIZE_8LD 8
0086 #define MAX_SPAN_DEPTH 8
0087
0088 #define NVIRT_CHAN 4
0089
0090 struct mbox_out {
0091 u8 cmd;
0092 u8 cmdid;
0093 u16 numsectors;
0094 u32 lba;
0095 u32 xferaddr;
0096 u8 logdrv;
0097 u8 numsgelements;
0098 u8 resvd;
0099 } __attribute__ ((packed));
0100
0101 struct mbox_in {
0102 volatile u8 busy;
0103 volatile u8 numstatus;
0104 volatile u8 status;
0105 volatile u8 completed[MAX_FIRMWARE_STATUS];
0106 volatile u8 poll;
0107 volatile u8 ack;
0108 } __attribute__ ((packed));
0109
0110 typedef struct {
0111 struct mbox_out m_out;
0112 struct mbox_in m_in;
0113 } __attribute__ ((packed)) mbox_t;
0114
0115 typedef struct {
0116 u32 xfer_segment_lo;
0117 u32 xfer_segment_hi;
0118 mbox_t mbox;
0119 } __attribute__ ((packed)) mbox64_t;
0120
0121
0122
0123
0124
0125 #define MAX_REQ_SENSE_LEN 0x20
0126
0127 typedef struct {
0128 u8 timeout:3;
0129 u8 ars:1;
0130 u8 reserved:3;
0131 u8 islogical:1;
0132 u8 logdrv;
0133 u8 channel;
0134 u8 target;
0135 u8 queuetag;
0136 u8 queueaction;
0137 u8 cdb[MAX_CDB_LEN];
0138 u8 cdblen;
0139 u8 reqsenselen;
0140 u8 reqsensearea[MAX_REQ_SENSE_LEN];
0141 u8 numsgelements;
0142 u8 scsistatus;
0143 u32 dataxferaddr;
0144 u32 dataxferlen;
0145 } __attribute__ ((packed)) mega_passthru;
0146
0147
0148
0149
0150
0151 typedef struct {
0152 u8 timeout:3;
0153 u8 ars:1;
0154 u8 rsvd1:1;
0155 u8 cd_rom:1;
0156 u8 rsvd2:1;
0157 u8 islogical:1;
0158 u8 logdrv;
0159 u8 channel;
0160 u8 target;
0161 u8 queuetag;
0162 u8 queueaction;
0163 u8 cdblen;
0164 u8 rsvd3;
0165 u8 cdb[MAX_EXT_CDB_LEN];
0166 u8 numsgelements;
0167 u8 status;
0168 u8 reqsenselen;
0169 u8 reqsensearea[MAX_REQ_SENSE_LEN];
0170 u8 rsvd4;
0171 u32 dataxferaddr;
0172 u32 dataxferlen;
0173 } __attribute__ ((packed)) mega_ext_passthru;
0174
0175 typedef struct {
0176 u64 address;
0177 u32 length;
0178 } __attribute__ ((packed)) mega_sgl64;
0179
0180 typedef struct {
0181 u32 address;
0182 u32 length;
0183 } __attribute__ ((packed)) mega_sglist;
0184
0185
0186
0187 typedef struct {
0188 int idx;
0189 u32 state;
0190 struct list_head list;
0191 u8 raw_mbox[66];
0192 u32 dma_type;
0193 u32 dma_direction;
0194
0195 struct scsi_cmnd *cmd;
0196 dma_addr_t dma_h_bulkdata;
0197 dma_addr_t dma_h_sgdata;
0198
0199 mega_sglist *sgl;
0200 mega_sgl64 *sgl64;
0201 dma_addr_t sgl_dma_addr;
0202
0203 mega_passthru *pthru;
0204 dma_addr_t pthru_dma_addr;
0205 mega_ext_passthru *epthru;
0206 dma_addr_t epthru_dma_addr;
0207 } scb_t;
0208
0209
0210
0211
0212 #define SCB_FREE 0x0000
0213 #define SCB_ACTIVE 0x0001
0214 #define SCB_PENDQ 0x0002
0215 #define SCB_ISSUED 0x0004
0216 #define SCB_ABORT 0x0008
0217 #define SCB_RESET 0x0010
0218
0219
0220
0221
0222
0223 typedef struct {
0224 u32 data_size;
0225
0226 u32 config_signature;
0227
0228
0229
0230
0231
0232 u8 fw_version[16];
0233 u8 bios_version[16];
0234 u8 product_name[80];
0235
0236 u8 max_commands;
0237 u8 nchannels;
0238 u8 fc_loop_present;
0239 u8 mem_type;
0240
0241 u32 signature;
0242 u16 dram_size;
0243 u16 subsysid;
0244
0245 u16 subsysvid;
0246 u8 notify_counters;
0247 u8 pad1k[889];
0248 } __attribute__ ((packed)) mega_product_info;
0249
0250 struct notify {
0251 u32 global_counter;
0252
0253 u8 param_counter;
0254 u8 param_id;
0255 u16 param_val;
0256
0257 u8 write_config_counter;
0258 u8 write_config_rsvd[3];
0259
0260 u8 ldrv_op_counter;
0261 u8 ldrv_opid;
0262 u8 ldrv_opcmd;
0263 u8 ldrv_opstatus;
0264
0265 u8 ldrv_state_counter;
0266 u8 ldrv_state_id;
0267 u8 ldrv_state_new;
0268 u8 ldrv_state_old;
0269
0270 u8 pdrv_state_counter;
0271 u8 pdrv_state_id;
0272 u8 pdrv_state_new;
0273 u8 pdrv_state_old;
0274
0275 u8 pdrv_fmt_counter;
0276 u8 pdrv_fmt_id;
0277 u8 pdrv_fmt_val;
0278 u8 pdrv_fmt_rsvd;
0279
0280 u8 targ_xfer_counter;
0281 u8 targ_xfer_id;
0282 u8 targ_xfer_val;
0283 u8 targ_xfer_rsvd;
0284
0285 u8 fcloop_id_chg_counter;
0286 u8 fcloopid_pdrvid;
0287 u8 fcloop_id0;
0288 u8 fcloop_id1;
0289
0290 u8 fcloop_state_counter;
0291 u8 fcloop_state0;
0292 u8 fcloop_state1;
0293 u8 fcloop_state_rsvd;
0294 } __attribute__ ((packed));
0295
0296 #define MAX_NOTIFY_SIZE 0x80
0297 #define CUR_NOTIFY_SIZE sizeof(struct notify)
0298
0299 typedef struct {
0300 u32 data_size;
0301
0302 struct notify notify;
0303
0304 u8 notify_rsvd[MAX_NOTIFY_SIZE - CUR_NOTIFY_SIZE];
0305
0306 u8 rebuild_rate;
0307 u8 cache_flush_interval;
0308 u8 sense_alert;
0309 u8 drive_insert_count;
0310
0311 u8 battery_status;
0312 u8 num_ldrv;
0313 u8 recon_state[MAX_LOGICAL_DRIVES_40LD / 8];
0314
0315 u16 ldrv_op_status[MAX_LOGICAL_DRIVES_40LD / 8];
0316
0317
0318 u32 ldrv_size[MAX_LOGICAL_DRIVES_40LD];
0319 u8 ldrv_prop[MAX_LOGICAL_DRIVES_40LD];
0320 u8 ldrv_state[MAX_LOGICAL_DRIVES_40LD];
0321 u8 pdrv_state[FC_MAX_PHYSICAL_DEVICES];
0322 u16 pdrv_format[FC_MAX_PHYSICAL_DEVICES / 16];
0323
0324 u8 targ_xfer[80];
0325 u8 pad1k[263];
0326 } __attribute__ ((packed)) mega_inquiry3;
0327
0328
0329
0330 typedef struct {
0331 u8 max_commands;
0332 u8 rebuild_rate;
0333 u8 max_targ_per_chan;
0334 u8 nchannels;
0335 u8 fw_version[4];
0336 u16 age_of_flash;
0337 u8 chip_set_value;
0338 u8 dram_size;
0339 u8 cache_flush_interval;
0340 u8 bios_version[4];
0341 u8 board_type;
0342 u8 sense_alert;
0343 u8 write_config_count;
0344
0345 u8 drive_inserted_count;
0346
0347 u8 inserted_drive;
0348 u8 battery_status;
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361 u8 dec_fault_bus_info;
0362 } __attribute__ ((packed)) mega_adp_info;
0363
0364
0365 typedef struct {
0366 u8 num_ldrv;
0367 u8 rsvd[3];
0368 u32 ldrv_size[MAX_LOGICAL_DRIVES_8LD];
0369 u8 ldrv_prop[MAX_LOGICAL_DRIVES_8LD];
0370 u8 ldrv_state[MAX_LOGICAL_DRIVES_8LD];
0371 } __attribute__ ((packed)) mega_ldrv_info;
0372
0373 typedef struct {
0374 u8 pdrv_state[MAX_PHYSICAL_DRIVES];
0375 u8 rsvd;
0376 } __attribute__ ((packed)) mega_pdrv_info;
0377
0378
0379 typedef struct {
0380 mega_adp_info adapter_info;
0381 mega_ldrv_info logdrv_info;
0382 mega_pdrv_info pdrv_info;
0383 } __attribute__ ((packed)) mraid_inquiry;
0384
0385
0386
0387 typedef struct {
0388 mraid_inquiry raid_inq;
0389 u16 phys_drv_format[MAX_CHANNELS];
0390 u8 stack_attn;
0391 u8 modem_status;
0392 u8 rsvd[2];
0393 } __attribute__ ((packed)) mraid_ext_inquiry;
0394
0395
0396 typedef struct {
0397 u8 channel;
0398 u8 target;
0399 }__attribute__ ((packed)) adp_device;
0400
0401 typedef struct {
0402 u32 start_blk;
0403 u32 num_blks;
0404 adp_device device[MAX_ROW_SIZE_40LD];
0405 }__attribute__ ((packed)) adp_span_40ld;
0406
0407 typedef struct {
0408 u32 start_blk;
0409 u32 num_blks;
0410 adp_device device[MAX_ROW_SIZE_8LD];
0411 }__attribute__ ((packed)) adp_span_8ld;
0412
0413 typedef struct {
0414 u8 span_depth;
0415 u8 level;
0416 u8 read_ahead;
0417
0418 u8 stripe_sz;
0419 u8 status;
0420 u8 write_mode;
0421 u8 direct_io;
0422 u8 row_size;
0423 } __attribute__ ((packed)) logdrv_param;
0424
0425 typedef struct {
0426 logdrv_param lparam;
0427 adp_span_40ld span[MAX_SPAN_DEPTH];
0428 }__attribute__ ((packed)) logdrv_40ld;
0429
0430 typedef struct {
0431 logdrv_param lparam;
0432 adp_span_8ld span[MAX_SPAN_DEPTH];
0433 }__attribute__ ((packed)) logdrv_8ld;
0434
0435 typedef struct {
0436 u8 type;
0437 u8 cur_status;
0438 u8 tag_depth;
0439 u8 sync_neg;
0440 u32 size;
0441
0442 }__attribute__ ((packed)) phys_drv;
0443
0444 typedef struct {
0445 u8 nlog_drives;
0446 u8 resvd[3];
0447 logdrv_40ld ldrv[MAX_LOGICAL_DRIVES_40LD];
0448 phys_drv pdrv[MAX_PHYSICAL_DRIVES];
0449 }__attribute__ ((packed)) disk_array_40ld;
0450
0451 typedef struct {
0452 u8 nlog_drives;
0453 u8 resvd[3];
0454 logdrv_8ld ldrv[MAX_LOGICAL_DRIVES_8LD];
0455 phys_drv pdrv[MAX_PHYSICAL_DRIVES];
0456 }__attribute__ ((packed)) disk_array_8ld;
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468 #define IOCTL_MAX_DATALEN 4096
0469
0470 struct uioctl_t {
0471 u32 inlen;
0472 u32 outlen;
0473 union {
0474 u8 fca[16];
0475 struct {
0476 u8 opcode;
0477 u8 subopcode;
0478 u16 adapno;
0479 #if BITS_PER_LONG == 32
0480 u8 *buffer;
0481 u8 pad[4];
0482 #endif
0483 #if BITS_PER_LONG == 64
0484 u8 *buffer;
0485 #endif
0486 u32 length;
0487 } __attribute__ ((packed)) fcs;
0488 } __attribute__ ((packed)) ui;
0489 u8 mbox[18];
0490 mega_passthru pthru;
0491 #if BITS_PER_LONG == 32
0492 char __user *data;
0493 char pad[4];
0494 #endif
0495 #if BITS_PER_LONG == 64
0496 char __user *data;
0497 #endif
0498 } __attribute__ ((packed));
0499
0500
0501
0502
0503
0504
0505
0506
0507 #define MAX_CONTROLLERS 32
0508
0509 struct mcontroller {
0510 u64 base;
0511 u8 irq;
0512 u8 numldrv;
0513 u8 pcibus;
0514 u16 pcidev;
0515 u8 pcifun;
0516 u16 pciid;
0517 u16 pcivendor;
0518 u8 pcislot;
0519 u32 uid;
0520 };
0521
0522
0523
0524
0525 typedef struct {
0526 u8 cmd;
0527 u8 cmdid;
0528 u8 opcode;
0529 u8 subopcode;
0530 u32 lba;
0531 u32 xferaddr;
0532 u8 logdrv;
0533 u8 rsvd[3];
0534 u8 numstatus;
0535 u8 status;
0536 } __attribute__ ((packed)) megacmd_t;
0537
0538
0539
0540
0541 #define MEGAIOC_MAGIC 'm'
0542
0543 #define MEGAIOC_QNADAP 'm'
0544 #define MEGAIOC_QDRVRVER 'e'
0545 #define MEGAIOC_QADAPINFO 'g'
0546 #define MKADAP(adapno) (MEGAIOC_MAGIC << 8 | (adapno) )
0547 #define GETADAP(mkadap) ( (mkadap) ^ MEGAIOC_MAGIC << 8 )
0548
0549
0550
0551
0552
0553
0554
0555
0556 #define VENDOR_SPECIFIC_COMMANDS 0xE0
0557 #define MEGA_INTERNAL_CMD VENDOR_SPECIFIC_COMMANDS + 0x01
0558
0559
0560
0561
0562 #define USCSICMD VENDOR_SPECIFIC_COMMANDS
0563
0564
0565
0566
0567 #define UIOC_RD 0x00001
0568 #define UIOC_WR 0x00002
0569
0570
0571
0572
0573 #define MBOX_CMD 0x00000
0574 #define GET_DRIVER_VER 0x10000
0575 #define GET_N_ADAP 0x20000
0576 #define GET_ADAP_INFO 0x30000
0577 #define GET_CAP 0x40000
0578 #define GET_STATS 0x50000
0579
0580
0581
0582
0583
0584
0585
0586 typedef struct {
0587 char signature[8];
0588 u32 opcode;
0589 u32 adapno;
0590 union {
0591 u8 __raw_mbox[18];
0592 void __user *__uaddr;
0593 }__ua;
0594
0595 #define uioc_rmbox __ua.__raw_mbox
0596 #define MBOX(uioc) ((megacmd_t *)&((uioc).__ua.__raw_mbox[0]))
0597 #define MBOX_P(uioc) ((megacmd_t __user *)&((uioc)->__ua.__raw_mbox[0]))
0598 #define uioc_uaddr __ua.__uaddr
0599
0600 u32 xferlen;
0601
0602 u32 flags;
0603 }nitioctl_t;
0604
0605
0606
0607
0608
0609
0610 typedef struct {
0611 int num_ldrv;
0612
0613 u32 nreads[MAX_LOGICAL_DRIVES_40LD];
0614
0615 u32 nreadblocks[MAX_LOGICAL_DRIVES_40LD];
0616
0617
0618 u32 nwrites[MAX_LOGICAL_DRIVES_40LD];
0619
0620
0621 u32 nwriteblocks[MAX_LOGICAL_DRIVES_40LD];
0622
0623
0624 u32 rd_errors[MAX_LOGICAL_DRIVES_40LD];
0625
0626
0627 u32 wr_errors[MAX_LOGICAL_DRIVES_40LD];
0628
0629
0630 }megastat_t;
0631
0632
0633 struct private_bios_data {
0634 u8 geometry:4;
0635
0636
0637
0638
0639
0640
0641 u8 unused:4;
0642 u8 boot_drv;
0643
0644
0645
0646
0647 u8 rsvd[12];
0648 u16 cksum;
0649 } __attribute__ ((packed));
0650
0651
0652
0653
0654
0655
0656
0657
0658 #define MEGA_MBOXCMD_LREAD 0x01
0659 #define MEGA_MBOXCMD_LWRITE 0x02
0660 #define MEGA_MBOXCMD_PASSTHRU 0x03
0661 #define MEGA_MBOXCMD_ADPEXTINQ 0x04
0662 #define MEGA_MBOXCMD_ADAPTERINQ 0x05
0663 #define MEGA_MBOXCMD_LREAD64 0xA7
0664 #define MEGA_MBOXCMD_LWRITE64 0xA8
0665 #define MEGA_MBOXCMD_PASSTHRU64 0xC3
0666 #define MEGA_MBOXCMD_EXTPTHRU 0xE3
0667
0668 #define MAIN_MISC_OPCODE 0xA4
0669 #define GET_MAX_SG_SUPPORT 0x01
0670
0671 #define FC_NEW_CONFIG 0xA1
0672 #define NC_SUBOP_PRODUCT_INFO 0x0E
0673 #define NC_SUBOP_ENQUIRY3 0x0F
0674 #define ENQ3_GET_SOLICITED_FULL 0x02
0675 #define OP_DCMD_READ_CONFIG 0x04
0676 #define NEW_READ_CONFIG_8LD 0x67
0677 #define READ_CONFIG_8LD 0x07
0678 #define FLUSH_ADAPTER 0x0A
0679 #define FLUSH_SYSTEM 0xFE
0680
0681
0682
0683
0684 #define FC_DEL_LOGDRV 0xA4
0685 #define OP_SUP_DEL_LOGDRV 0x2A
0686 #define OP_GET_LDID_MAP 0x18
0687 #define OP_DEL_LOGDRV 0x1C
0688
0689
0690
0691
0692 #define IS_BIOS_ENABLED 0x62
0693 #define GET_BIOS 0x01
0694 #define CHNL_CLASS 0xA9
0695 #define GET_CHNL_CLASS 0x00
0696 #define SET_CHNL_CLASS 0x01
0697 #define CH_RAID 0x01
0698 #define CH_SCSI 0x00
0699 #define BIOS_PVT_DATA 0x40
0700 #define GET_BIOS_PVT_DATA 0x00
0701
0702
0703
0704
0705
0706 #define MEGA_GET_TARGET_ID 0x7D
0707 #define MEGA_CLUSTER_OP 0x70
0708 #define MEGA_GET_CLUSTER_MODE 0x02
0709 #define MEGA_CLUSTER_CMD 0x6E
0710 #define MEGA_RESERVE_LD 0x01
0711 #define MEGA_RELEASE_LD 0x02
0712 #define MEGA_RESET_RESERVATIONS 0x03
0713 #define MEGA_RESERVATION_STATUS 0x04
0714 #define MEGA_RESERVE_PD 0x05
0715 #define MEGA_RELEASE_PD 0x06
0716
0717
0718
0719
0720
0721 #define MEGA_BATT_MODULE_MISSING 0x01
0722 #define MEGA_BATT_LOW_VOLTAGE 0x02
0723 #define MEGA_BATT_TEMP_HIGH 0x04
0724 #define MEGA_BATT_PACK_MISSING 0x08
0725 #define MEGA_BATT_CHARGE_MASK 0x30
0726 #define MEGA_BATT_CHARGE_DONE 0x00
0727 #define MEGA_BATT_CHARGE_INPROG 0x10
0728 #define MEGA_BATT_CHARGE_FAIL 0x20
0729 #define MEGA_BATT_CYCLES_EXCEEDED 0x40
0730
0731
0732
0733
0734 #define PDRV_UNCNF 0
0735 #define PDRV_ONLINE 3
0736 #define PDRV_FAILED 4
0737 #define PDRV_RBLD 5
0738 #define PDRV_HOTSPARE 6
0739
0740
0741
0742
0743
0744 #define RDRV_OFFLINE 0
0745 #define RDRV_DEGRADED 1
0746 #define RDRV_OPTIMAL 2
0747 #define RDRV_DELETED 3
0748
0749
0750
0751
0752 #define NO_READ_AHEAD 0
0753 #define READ_AHEAD 1
0754 #define ADAP_READ_AHEAD 2
0755 #define WRMODE_WRITE_THRU 0
0756 #define WRMODE_WRITE_BACK 1
0757 #define CACHED_IO 0
0758 #define DIRECT_IO 1
0759
0760 struct megaraid_cmd_priv {
0761 struct list_head entry;
0762 };
0763
0764 #define SCSI_LIST(scp) \
0765 (&((struct megaraid_cmd_priv *)scsi_cmd_priv(scp))->entry)
0766
0767 struct scsi_cmd_and_priv {
0768 struct scsi_cmnd cmd;
0769 struct megaraid_cmd_priv priv;
0770 };
0771
0772 static inline struct scsi_cmnd *
0773 megaraid_to_scsi_cmd(struct megaraid_cmd_priv *cmd_priv)
0774 {
0775
0776 BUILD_BUG_ON(sizeof(struct scsi_cmd_and_priv) !=
0777 sizeof(struct scsi_cmnd) +
0778 sizeof(struct megaraid_cmd_priv));
0779
0780 return &container_of(cmd_priv, struct scsi_cmd_and_priv, priv)->cmd;
0781 }
0782
0783
0784
0785
0786 typedef struct {
0787 int this_id;
0788
0789 u32 flag;
0790
0791 unsigned long base;
0792 void __iomem *mmio_base;
0793
0794
0795 mbox64_t *una_mbox64;
0796 dma_addr_t una_mbox64_dma;
0797
0798 volatile mbox64_t *mbox64;
0799 volatile mbox_t *mbox;
0800 dma_addr_t mbox_dma;
0801
0802 struct pci_dev *dev;
0803
0804 struct list_head free_list;
0805 struct list_head pending_list;
0806 struct list_head completed_list;
0807
0808 struct Scsi_Host *host;
0809
0810 #define MEGA_BUFFER_SIZE (2*1024)
0811 u8 *mega_buffer;
0812 dma_addr_t buf_dma_handle;
0813
0814 mega_product_info product_info;
0815
0816 u8 max_cmds;
0817 scb_t *scb_list;
0818
0819 atomic_t pend_cmds;
0820
0821
0822 #if MEGA_HAVE_STATS
0823 u32 nreads[MAX_LOGICAL_DRIVES_40LD];
0824 u32 nreadblocks[MAX_LOGICAL_DRIVES_40LD];
0825 u32 nwrites[MAX_LOGICAL_DRIVES_40LD];
0826 u32 nwriteblocks[MAX_LOGICAL_DRIVES_40LD];
0827 u32 rd_errors[MAX_LOGICAL_DRIVES_40LD];
0828 u32 wr_errors[MAX_LOGICAL_DRIVES_40LD];
0829 #endif
0830
0831
0832 u8 numldrv;
0833 u8 fw_version[7];
0834 u8 bios_version[7];
0835
0836 #ifdef CONFIG_PROC_FS
0837 struct proc_dir_entry *controller_proc_dir_entry;
0838 #endif
0839
0840 int has_64bit_addr;
0841 int support_ext_cdb;
0842 int boot_ldrv_enabled;
0843 int boot_ldrv;
0844 int boot_pdrv_enabled;
0845 int boot_pdrv_ch;
0846 int boot_pdrv_tgt;
0847
0848
0849 int support_random_del;
0850
0851 int read_ldidmap;
0852
0853
0854 atomic_t quiescent;
0855
0856
0857
0858 spinlock_t lock;
0859
0860 u8 logdrv_chan[MAX_CHANNELS+NVIRT_CHAN];
0861
0862 int mega_ch_class;
0863
0864 u8 sglen;
0865
0866 scb_t int_scb;
0867 struct mutex int_mtx;
0868
0869 int int_status;
0870 struct completion int_waitq;
0871
0872
0873 int has_cluster;
0874 }adapter_t;
0875
0876
0877 struct mega_hbas {
0878 int is_bios_enabled;
0879 adapter_t *hostdata_addr;
0880 };
0881
0882
0883
0884
0885
0886
0887 #define IN_ABORT 0x80000000L
0888 #define IN_RESET 0x40000000L
0889 #define BOARD_MEMMAP 0x20000000L
0890 #define BOARD_IOMAP 0x10000000L
0891 #define BOARD_40LD 0x08000000L
0892 #define BOARD_64BIT 0x04000000L
0893
0894 #define INTR_VALID 0x40
0895
0896 #define PCI_CONF_AMISIG 0xa0
0897 #define PCI_CONF_AMISIG64 0xa4
0898
0899
0900 #define MEGA_DMA_TYPE_NONE 0xFFFF
0901 #define MEGA_BULK_DATA 0x0001
0902 #define MEGA_SGLIST 0x0002
0903
0904
0905
0906
0907
0908
0909 #define CMD_PORT 0x00
0910 #define ACK_PORT 0x00
0911 #define TOGGLE_PORT 0x01
0912 #define INTR_PORT 0x0a
0913
0914 #define MBOX_BUSY_PORT 0x00
0915 #define MBOX_PORT0 0x04
0916 #define MBOX_PORT1 0x05
0917 #define MBOX_PORT2 0x06
0918 #define MBOX_PORT3 0x07
0919 #define ENABLE_MBOX_REGION 0x0B
0920
0921
0922 #define ISSUE_BYTE 0x10
0923 #define ACK_BYTE 0x08
0924 #define ENABLE_INTR_BYTE 0xc0
0925 #define DISABLE_INTR_BYTE 0x00
0926 #define VALID_INTR_BYTE 0x40
0927 #define MBOX_BUSY_BYTE 0x10
0928 #define ENABLE_MBOX_BYTE 0x00
0929
0930
0931
0932 #define issue_command(adapter) \
0933 outb_p(ISSUE_BYTE, (adapter)->base + CMD_PORT)
0934
0935 #define irq_state(adapter) inb_p((adapter)->base + INTR_PORT)
0936
0937 #define set_irq_state(adapter, value) \
0938 outb_p((value), (adapter)->base + INTR_PORT)
0939
0940 #define irq_ack(adapter) \
0941 outb_p(ACK_BYTE, (adapter)->base + ACK_PORT)
0942
0943 #define irq_enable(adapter) \
0944 outb_p(ENABLE_INTR_BYTE, (adapter)->base + TOGGLE_PORT)
0945
0946 #define irq_disable(adapter) \
0947 outb_p(DISABLE_INTR_BYTE, (adapter)->base + TOGGLE_PORT)
0948
0949
0950
0951
0952
0953
0954
0955
0956
0957
0958
0959 const char *megaraid_info (struct Scsi_Host *);
0960
0961 static int mega_query_adapter(adapter_t *);
0962 static int issue_scb(adapter_t *, scb_t *);
0963 static int mega_setup_mailbox(adapter_t *);
0964
0965 static int megaraid_queue (struct Scsi_Host *, struct scsi_cmnd *);
0966 static scb_t * mega_build_cmd(adapter_t *, struct scsi_cmnd *, int *);
0967 static void __mega_runpendq(adapter_t *);
0968 static int issue_scb_block(adapter_t *, u_char *);
0969
0970 static irqreturn_t megaraid_isr_memmapped(int, void *);
0971 static irqreturn_t megaraid_isr_iomapped(int, void *);
0972
0973 static void mega_free_scb(adapter_t *, scb_t *);
0974
0975 static int megaraid_abort(struct scsi_cmnd *);
0976 static int megaraid_reset(struct scsi_cmnd *);
0977 static int megaraid_abort_and_reset(adapter_t *, struct scsi_cmnd *, int);
0978 static int megaraid_biosparam(struct scsi_device *, struct block_device *,
0979 sector_t, int []);
0980
0981 static int mega_build_sglist (adapter_t *adapter, scb_t *scb,
0982 u32 *buffer, u32 *length);
0983 static int __mega_busywait_mbox (adapter_t *);
0984 static void mega_rundoneq (adapter_t *);
0985 static void mega_cmd_done(adapter_t *, u8 [], int, int);
0986 static inline void mega_free_sgl (adapter_t *adapter);
0987 static void mega_8_to_40ld (mraid_inquiry *inquiry,
0988 mega_inquiry3 *enquiry3, mega_product_info *);
0989
0990 static int megadev_open (struct inode *, struct file *);
0991 static int megadev_ioctl (struct file *, unsigned int, unsigned long);
0992 static int mega_m_to_n(void __user *, nitioctl_t *);
0993 static int mega_n_to_m(void __user *, megacmd_t *);
0994
0995 static int mega_init_scb (adapter_t *);
0996
0997 static int mega_is_bios_enabled (adapter_t *);
0998
0999 #ifdef CONFIG_PROC_FS
1000 static void mega_create_proc_entry(int, struct proc_dir_entry *);
1001 static int mega_adapinq(adapter_t *, dma_addr_t);
1002 static int mega_internal_dev_inquiry(adapter_t *, u8, u8, dma_addr_t);
1003 #endif
1004
1005 static int mega_support_ext_cdb(adapter_t *);
1006 static mega_passthru* mega_prepare_passthru(adapter_t *, scb_t *,
1007 struct scsi_cmnd *, int, int);
1008 static mega_ext_passthru* mega_prepare_extpassthru(adapter_t *,
1009 scb_t *, struct scsi_cmnd *, int, int);
1010 static void mega_enum_raid_scsi(adapter_t *);
1011 static void mega_get_boot_drv(adapter_t *);
1012 static int mega_support_random_del(adapter_t *);
1013 static int mega_del_logdrv(adapter_t *, int);
1014 static int mega_do_del_logdrv(adapter_t *, int);
1015 static void mega_get_max_sgl(adapter_t *);
1016 static int mega_internal_command(adapter_t *, megacmd_t *, mega_passthru *);
1017 static int mega_support_cluster(adapter_t *);
1018 #endif
1019
1020