1#ifndef __MEGARAID_H__
2#define __MEGARAID_H__
3
4#include <linux/spinlock.h>
5#include <linux/mutex.h>
6
7#define MEGARAID_VERSION \
8 "v2.00.4 (Release Date: Thu Feb 9 08:51:30 EST 2006)\n"
9
10
11
12
13
14
15
16
17
18
19
20
21#define MEGA_HAVE_COALESCING 0
22
23
24
25
26
27
28#define MEGA_HAVE_CLUSTERING 1
29
30
31
32
33
34
35
36
37#define MEGA_HAVE_STATS 0
38
39
40
41
42
43
44#define MEGA_HAVE_ENH_PROC 1
45
46#define MAX_DEV_TYPE 32
47
48#define PCI_DEVICE_ID_DISCOVERY 0x000E
49#define PCI_DEVICE_ID_PERC4_DI 0x000F
50#define PCI_DEVICE_ID_PERC4_QC_VERDE 0x0407
51
52#define HBA_SIGNATURE 0x3344
53#define HBA_SIGNATURE_471 0xCCCC
54#define HBA_SIGNATURE_64BIT 0x0299
55
56#define MBOX_BUSY_WAIT 10
57
58#define DEFAULT_INITIATOR_ID 7
59
60#define MAX_SGLIST 64
61#define MIN_SGLIST 26
62#define MAX_COMMANDS 126
63#define CMDID_INT_CMDS MAX_COMMANDS+1
64
65
66
67#define MAX_CDB_LEN 10
68#define MAX_EXT_CDB_LEN 16
69
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
75
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
80#define MAX_TARGET 15
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
85
86#define NVIRT_CHAN 4
87
88struct mbox_out {
89 u8 cmd;
90 u8 cmdid;
91 u16 numsectors;
92 u32 lba;
93 u32 xferaddr;
94 u8 logdrv;
95 u8 numsgelements;
96 u8 resvd;
97} __attribute__ ((packed));
98
99struct mbox_in {
100 volatile u8 busy;
101 volatile u8 numstatus;
102 volatile u8 status;
103 volatile u8 completed[MAX_FIRMWARE_STATUS];
104 volatile u8 poll;
105 volatile u8 ack;
106} __attribute__ ((packed));
107
108typedef struct {
109 struct mbox_out m_out;
110 struct mbox_in m_in;
111} __attribute__ ((packed)) mbox_t;
112
113typedef struct {
114 u32 xfer_segment_lo;
115 u32 xfer_segment_hi;
116 mbox_t mbox;
117} __attribute__ ((packed)) mbox64_t;
118
119
120
121
122
123#define MAX_REQ_SENSE_LEN 0x20
124
125typedef struct {
126 u8 timeout:3;
127 u8 ars:1;
128 u8 reserved:3;
129 u8 islogical:1;
130 u8 logdrv;
131 u8 channel;
132 u8 target;
133 u8 queuetag;
134 u8 queueaction;
135 u8 cdb[MAX_CDB_LEN];
136 u8 cdblen;
137 u8 reqsenselen;
138 u8 reqsensearea[MAX_REQ_SENSE_LEN];
139 u8 numsgelements;
140 u8 scsistatus;
141 u32 dataxferaddr;
142 u32 dataxferlen;
143} __attribute__ ((packed)) mega_passthru;
144
145
146
147
148
149typedef struct {
150 u8 timeout:3;
151 u8 ars:1;
152 u8 rsvd1:1;
153 u8 cd_rom:1;
154 u8 rsvd2:1;
155 u8 islogical:1;
156 u8 logdrv;
157 u8 channel;
158 u8 target;
159 u8 queuetag;
160 u8 queueaction;
161 u8 cdblen;
162 u8 rsvd3;
163 u8 cdb[MAX_EXT_CDB_LEN];
164 u8 numsgelements;
165 u8 status;
166 u8 reqsenselen;
167 u8 reqsensearea[MAX_REQ_SENSE_LEN];
168 u8 rsvd4;
169 u32 dataxferaddr;
170 u32 dataxferlen;
171} __attribute__ ((packed)) mega_ext_passthru;
172
173typedef struct {
174 u64 address;
175 u32 length;
176} __attribute__ ((packed)) mega_sgl64;
177
178typedef struct {
179 u32 address;
180 u32 length;
181} __attribute__ ((packed)) mega_sglist;
182
183
184
185typedef struct {
186 int idx;
187 u32 state;
188 struct list_head list;
189 u8 raw_mbox[66];
190 u32 dma_type;
191 u32 dma_direction;
192
193 Scsi_Cmnd *cmd;
194 dma_addr_t dma_h_bulkdata;
195 dma_addr_t dma_h_sgdata;
196
197 mega_sglist *sgl;
198 mega_sgl64 *sgl64;
199 dma_addr_t sgl_dma_addr;
200
201 mega_passthru *pthru;
202 dma_addr_t pthru_dma_addr;
203 mega_ext_passthru *epthru;
204 dma_addr_t epthru_dma_addr;
205} scb_t;
206
207
208
209
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
216
217
218
219
220
221typedef struct {
222 u32 data_size;
223
224 u32 config_signature;
225
226
227
228
229
230 u8 fw_version[16];
231 u8 bios_version[16];
232 u8 product_name[80];
233
234 u8 max_commands;
235 u8 nchannels;
236 u8 fc_loop_present;
237 u8 mem_type;
238
239 u32 signature;
240 u16 dram_size;
241 u16 subsysid;
242
243 u16 subsysvid;
244 u8 notify_counters;
245 u8 pad1k[889];
246} __attribute__ ((packed)) mega_product_info;
247
248struct notify {
249 u32 global_counter;
250
251 u8 param_counter;
252 u8 param_id;
253 u16 param_val;
254
255 u8 write_config_counter;
256 u8 write_config_rsvd[3];
257
258 u8 ldrv_op_counter;
259 u8 ldrv_opid;
260 u8 ldrv_opcmd;
261 u8 ldrv_opstatus;
262
263 u8 ldrv_state_counter;
264 u8 ldrv_state_id;
265 u8 ldrv_state_new;
266 u8 ldrv_state_old;
267
268 u8 pdrv_state_counter;
269 u8 pdrv_state_id;
270 u8 pdrv_state_new;
271 u8 pdrv_state_old;
272
273 u8 pdrv_fmt_counter;
274 u8 pdrv_fmt_id;
275 u8 pdrv_fmt_val;
276 u8 pdrv_fmt_rsvd;
277
278 u8 targ_xfer_counter;
279 u8 targ_xfer_id;
280 u8 targ_xfer_val;
281 u8 targ_xfer_rsvd;
282
283 u8 fcloop_id_chg_counter;
284 u8 fcloopid_pdrvid;
285 u8 fcloop_id0;
286 u8 fcloop_id1;
287
288 u8 fcloop_state_counter;
289 u8 fcloop_state0;
290 u8 fcloop_state1;
291 u8 fcloop_state_rsvd;
292} __attribute__ ((packed));
293
294#define MAX_NOTIFY_SIZE 0x80
295#define CUR_NOTIFY_SIZE sizeof(struct notify)
296
297typedef struct {
298 u32 data_size;
299
300 struct notify notify;
301
302 u8 notify_rsvd[MAX_NOTIFY_SIZE - CUR_NOTIFY_SIZE];
303
304 u8 rebuild_rate;
305 u8 cache_flush_interval;
306 u8 sense_alert;
307 u8 drive_insert_count;
308
309 u8 battery_status;
310 u8 num_ldrv;
311 u8 recon_state[MAX_LOGICAL_DRIVES_40LD / 8];
312
313 u16 ldrv_op_status[MAX_LOGICAL_DRIVES_40LD / 8];
314
315
316 u32 ldrv_size[MAX_LOGICAL_DRIVES_40LD];
317 u8 ldrv_prop[MAX_LOGICAL_DRIVES_40LD];
318 u8 ldrv_state[MAX_LOGICAL_DRIVES_40LD];
319 u8 pdrv_state[FC_MAX_PHYSICAL_DEVICES];
320 u16 pdrv_format[FC_MAX_PHYSICAL_DEVICES / 16];
321
322 u8 targ_xfer[80];
323 u8 pad1k[263];
324} __attribute__ ((packed)) mega_inquiry3;
325
326
327
328typedef struct {
329 u8 max_commands;
330 u8 rebuild_rate;
331 u8 max_targ_per_chan;
332 u8 nchannels;
333 u8 fw_version[4];
334 u16 age_of_flash;
335 u8 chip_set_value;
336 u8 dram_size;
337 u8 cache_flush_interval;
338 u8 bios_version[4];
339 u8 board_type;
340 u8 sense_alert;
341 u8 write_config_count;
342
343 u8 drive_inserted_count;
344
345 u8 inserted_drive;
346 u8 battery_status;
347
348
349
350
351
352
353
354
355
356
357
358
359 u8 dec_fault_bus_info;
360} __attribute__ ((packed)) mega_adp_info;
361
362
363typedef struct {
364 u8 num_ldrv;
365 u8 rsvd[3];
366 u32 ldrv_size[MAX_LOGICAL_DRIVES_8LD];
367 u8 ldrv_prop[MAX_LOGICAL_DRIVES_8LD];
368 u8 ldrv_state[MAX_LOGICAL_DRIVES_8LD];
369} __attribute__ ((packed)) mega_ldrv_info;
370
371typedef struct {
372 u8 pdrv_state[MAX_PHYSICAL_DRIVES];
373 u8 rsvd;
374} __attribute__ ((packed)) mega_pdrv_info;
375
376
377typedef struct {
378 mega_adp_info adapter_info;
379 mega_ldrv_info logdrv_info;
380 mega_pdrv_info pdrv_info;
381} __attribute__ ((packed)) mraid_inquiry;
382
383
384
385typedef struct {
386 mraid_inquiry raid_inq;
387 u16 phys_drv_format[MAX_CHANNELS];
388 u8 stack_attn;
389 u8 modem_status;
390 u8 rsvd[2];
391} __attribute__ ((packed)) mraid_ext_inquiry;
392
393
394typedef struct {
395 u8 channel;
396 u8 target;
397}__attribute__ ((packed)) adp_device;
398
399typedef struct {
400 u32 start_blk;
401 u32 num_blks;
402 adp_device device[MAX_ROW_SIZE_40LD];
403}__attribute__ ((packed)) adp_span_40ld;
404
405typedef struct {
406 u32 start_blk;
407 u32 num_blks;
408 adp_device device[MAX_ROW_SIZE_8LD];
409}__attribute__ ((packed)) adp_span_8ld;
410
411typedef struct {
412 u8 span_depth;
413 u8 level;
414 u8 read_ahead;
415
416 u8 stripe_sz;
417 u8 status;
418 u8 write_mode;
419 u8 direct_io;
420 u8 row_size;
421} __attribute__ ((packed)) logdrv_param;
422
423typedef struct {
424 logdrv_param lparam;
425 adp_span_40ld span[MAX_SPAN_DEPTH];
426}__attribute__ ((packed)) logdrv_40ld;
427
428typedef struct {
429 logdrv_param lparam;
430 adp_span_8ld span[MAX_SPAN_DEPTH];
431}__attribute__ ((packed)) logdrv_8ld;
432
433typedef struct {
434 u8 type;
435 u8 cur_status;
436 u8 tag_depth;
437 u8 sync_neg;
438 u32 size;
439
440}__attribute__ ((packed)) phys_drv;
441
442typedef struct {
443 u8 nlog_drives;
444 u8 resvd[3];
445 logdrv_40ld ldrv[MAX_LOGICAL_DRIVES_40LD];
446 phys_drv pdrv[MAX_PHYSICAL_DRIVES];
447}__attribute__ ((packed)) disk_array_40ld;
448
449typedef struct {
450 u8 nlog_drives;
451 u8 resvd[3];
452 logdrv_8ld ldrv[MAX_LOGICAL_DRIVES_8LD];
453 phys_drv pdrv[MAX_PHYSICAL_DRIVES];
454}__attribute__ ((packed)) disk_array_8ld;
455
456
457
458
459
460
461
462
463
464
465
466#define IOCTL_MAX_DATALEN 4096
467
468struct uioctl_t {
469 u32 inlen;
470 u32 outlen;
471 union {
472 u8 fca[16];
473 struct {
474 u8 opcode;
475 u8 subopcode;
476 u16 adapno;
477#if BITS_PER_LONG == 32
478 u8 *buffer;
479 u8 pad[4];
480#endif
481#if BITS_PER_LONG == 64
482 u8 *buffer;
483#endif
484 u32 length;
485 } __attribute__ ((packed)) fcs;
486 } __attribute__ ((packed)) ui;
487 u8 mbox[18];
488 mega_passthru pthru;
489#if BITS_PER_LONG == 32
490 char __user *data;
491 char pad[4];
492#endif
493#if BITS_PER_LONG == 64
494 char __user *data;
495#endif
496} __attribute__ ((packed));
497
498
499
500
501
502
503
504
505#define MAX_CONTROLLERS 32
506
507struct mcontroller {
508 u64 base;
509 u8 irq;
510 u8 numldrv;
511 u8 pcibus;
512 u16 pcidev;
513 u8 pcifun;
514 u16 pciid;
515 u16 pcivendor;
516 u8 pcislot;
517 u32 uid;
518};
519
520
521
522
523typedef struct {
524 u8 cmd;
525 u8 cmdid;
526 u8 opcode;
527 u8 subopcode;
528 u32 lba;
529 u32 xferaddr;
530 u8 logdrv;
531 u8 rsvd[3];
532 u8 numstatus;
533 u8 status;
534} __attribute__ ((packed)) megacmd_t;
535
536
537
538
539#define MEGAIOC_MAGIC 'm'
540
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 )
546
547
548
549
550
551
552
553
554#define VENDOR_SPECIFIC_COMMANDS 0xE0
555#define MEGA_INTERNAL_CMD VENDOR_SPECIFIC_COMMANDS + 0x01
556
557
558
559
560#define USCSICMD VENDOR_SPECIFIC_COMMANDS
561
562
563
564
565#define UIOC_RD 0x00001
566#define UIOC_WR 0x00002
567
568
569
570
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
577
578
579
580
581
582
583
584typedef struct {
585 char signature[8];
586 u32 opcode;
587 u32 adapno;
588 union {
589 u8 __raw_mbox[18];
590 void __user *__uaddr;
591 }__ua;
592
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
597
598 u32 xferlen;
599
600 u32 flags;
601}nitioctl_t;
602
603
604
605
606
607
608typedef struct {
609 int num_ldrv;
610
611 u32 nreads[MAX_LOGICAL_DRIVES_40LD];
612
613 u32 nreadblocks[MAX_LOGICAL_DRIVES_40LD];
614
615
616 u32 nwrites[MAX_LOGICAL_DRIVES_40LD];
617
618
619 u32 nwriteblocks[MAX_LOGICAL_DRIVES_40LD];
620
621
622 u32 rd_errors[MAX_LOGICAL_DRIVES_40LD];
623
624
625 u32 wr_errors[MAX_LOGICAL_DRIVES_40LD];
626
627
628}megastat_t;
629
630
631struct private_bios_data {
632 u8 geometry:4;
633
634
635
636
637
638
639 u8 unused:4;
640 u8 boot_drv;
641
642
643
644
645 u8 rsvd[12];
646 u16 cksum;
647} __attribute__ ((packed));
648
649
650
651
652
653
654
655
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
665
666#define MAIN_MISC_OPCODE 0xA4
667#define GET_MAX_SG_SUPPORT 0x01
668
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
678
679
680
681
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
686
687
688
689
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
695#define CH_RAID 0x01
696#define CH_SCSI 0x00
697#define BIOS_PVT_DATA 0x40
698#define GET_BIOS_PVT_DATA 0x00
699
700
701
702
703
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
714
715
716
717
718
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
728
729
730
731
732#define PDRV_UNCNF 0
733#define PDRV_ONLINE 3
734#define PDRV_FAILED 4
735#define PDRV_RBLD 5
736#define PDRV_HOTSPARE 6
737
738
739
740
741
742#define RDRV_OFFLINE 0
743#define RDRV_DEGRADED 1
744#define RDRV_OPTIMAL 2
745#define RDRV_DELETED 3
746
747
748
749
750#define NO_READ_AHEAD 0
751#define READ_AHEAD 1
752#define ADAP_READ_AHEAD 2
753#define WRMODE_WRITE_THRU 0
754#define WRMODE_WRITE_BACK 1
755#define CACHED_IO 0
756#define DIRECT_IO 1
757
758
759#define SCSI_LIST(scp) ((struct list_head *)(&(scp)->SCp))
760
761
762
763
764typedef struct {
765 int this_id;
766
767 u32 flag;
768
769 unsigned long base;
770 void __iomem *mmio_base;
771
772
773 mbox64_t *una_mbox64;
774 dma_addr_t una_mbox64_dma;
775
776 volatile mbox64_t *mbox64;
777 volatile mbox_t *mbox;
778 dma_addr_t mbox_dma;
779
780 struct pci_dev *dev;
781
782 struct list_head free_list;
783 struct list_head pending_list;
784 struct list_head completed_list;
785
786 struct Scsi_Host *host;
787
788#define MEGA_BUFFER_SIZE (2*1024)
789 u8 *mega_buffer;
790 dma_addr_t buf_dma_handle;
791
792 mega_product_info product_info;
793
794 u8 max_cmds;
795 scb_t *scb_list;
796
797 atomic_t pend_cmds;
798
799
800#if MEGA_HAVE_STATS
801 u32 nreads[MAX_LOGICAL_DRIVES_40LD];
802 u32 nreadblocks[MAX_LOGICAL_DRIVES_40LD];
803 u32 nwrites[MAX_LOGICAL_DRIVES_40LD];
804 u32 nwriteblocks[MAX_LOGICAL_DRIVES_40LD];
805 u32 rd_errors[MAX_LOGICAL_DRIVES_40LD];
806 u32 wr_errors[MAX_LOGICAL_DRIVES_40LD];
807#endif
808
809
810 u8 numldrv;
811 u8 fw_version[7];
812 u8 bios_version[7];
813
814#ifdef CONFIG_PROC_FS
815 struct proc_dir_entry *controller_proc_dir_entry;
816 struct proc_dir_entry *proc_read;
817 struct proc_dir_entry *proc_stat;
818 struct proc_dir_entry *proc_mbox;
819
820#if MEGA_HAVE_ENH_PROC
821 struct proc_dir_entry *proc_rr;
822 struct proc_dir_entry *proc_battery;
823#define MAX_PROC_CHANNELS 4
824 struct proc_dir_entry *proc_pdrvstat[MAX_PROC_CHANNELS];
825 struct proc_dir_entry *proc_rdrvstat[MAX_PROC_CHANNELS];
826#endif
827
828#endif
829
830 int has_64bit_addr;
831 int support_ext_cdb;
832 int boot_ldrv_enabled;
833 int boot_ldrv;
834 int boot_pdrv_enabled;
835 int boot_pdrv_ch;
836 int boot_pdrv_tgt;
837
838
839 int support_random_del;
840
841 int read_ldidmap;
842
843
844 atomic_t quiescent;
845
846
847
848 spinlock_t lock;
849
850 u8 logdrv_chan[MAX_CHANNELS+NVIRT_CHAN];
851
852 int mega_ch_class;
853
854 u8 sglen;
855
856 scb_t int_scb;
857 struct mutex int_mtx;
858
859 int int_status;
860 struct completion int_waitq;
861
862
863 int has_cluster;
864}adapter_t;
865
866
867struct mega_hbas {
868 int is_bios_enabled;
869 adapter_t *hostdata_addr;
870};
871
872
873
874
875
876
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
883
884#define INTR_VALID 0x40
885
886#define PCI_CONF_AMISIG 0xa0
887#define PCI_CONF_AMISIG64 0xa4
888
889
890#define MEGA_DMA_TYPE_NONE 0xFFFF
891#define MEGA_BULK_DATA 0x0001
892#define MEGA_SGLIST 0x0002
893
894
895
896
897
898
899#define CMD_PORT 0x00
900#define ACK_PORT 0x00
901#define TOGGLE_PORT 0x01
902#define INTR_PORT 0x0a
903
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
910
911
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
919
920
921
922#define issue_command(adapter) \
923 outb_p(ISSUE_BYTE, (adapter)->base + CMD_PORT)
924
925#define irq_state(adapter) inb_p((adapter)->base + INTR_PORT)
926
927#define set_irq_state(adapter, value) \
928 outb_p((value), (adapter)->base + INTR_PORT)
929
930#define irq_ack(adapter) \
931 outb_p(ACK_BYTE, (adapter)->base + ACK_PORT)
932
933#define irq_enable(adapter) \
934 outb_p(ENABLE_INTR_BYTE, (adapter)->base + TOGGLE_PORT)
935
936#define irq_disable(adapter) \
937 outb_p(DISABLE_INTR_BYTE, (adapter)->base + TOGGLE_PORT)
938
939
940
941
942
943
944
945
946
947
948
949const char *megaraid_info (struct Scsi_Host *);
950
951static int mega_query_adapter(adapter_t *);
952static int issue_scb(adapter_t *, scb_t *);
953static int mega_setup_mailbox(adapter_t *);
954
955static int megaraid_queue (struct Scsi_Host *, struct scsi_cmnd *);
956static scb_t * mega_build_cmd(adapter_t *, Scsi_Cmnd *, int *);
957static void __mega_runpendq(adapter_t *);
958static int issue_scb_block(adapter_t *, u_char *);
959
960static irqreturn_t megaraid_isr_memmapped(int, void *);
961static irqreturn_t megaraid_isr_iomapped(int, void *);
962
963static void mega_free_scb(adapter_t *, scb_t *);
964
965static int megaraid_abort(Scsi_Cmnd *);
966static int megaraid_reset(Scsi_Cmnd *);
967static int megaraid_abort_and_reset(adapter_t *, Scsi_Cmnd *, int);
968static int megaraid_biosparam(struct scsi_device *, struct block_device *,
969 sector_t, int []);
970
971static int mega_build_sglist (adapter_t *adapter, scb_t *scb,
972 u32 *buffer, u32 *length);
973static int __mega_busywait_mbox (adapter_t *);
974static void mega_rundoneq (adapter_t *);
975static void mega_cmd_done(adapter_t *, u8 [], int, int);
976static inline void mega_free_sgl (adapter_t *adapter);
977static void mega_8_to_40ld (mraid_inquiry *inquiry,
978 mega_inquiry3 *enquiry3, mega_product_info *);
979
980static int megadev_open (struct inode *, struct file *);
981static int megadev_ioctl (struct file *, unsigned int, unsigned long);
982static int mega_m_to_n(void __user *, nitioctl_t *);
983static int mega_n_to_m(void __user *, megacmd_t *);
984
985static int mega_init_scb (adapter_t *);
986
987static int mega_is_bios_enabled (adapter_t *);
988
989#ifdef CONFIG_PROC_FS
990static void mega_create_proc_entry(int, struct proc_dir_entry *);
991static int mega_adapinq(adapter_t *, dma_addr_t);
992static int mega_internal_dev_inquiry(adapter_t *, u8, u8, dma_addr_t);
993#endif
994
995static int mega_support_ext_cdb(adapter_t *);
996static mega_passthru* mega_prepare_passthru(adapter_t *, scb_t *,
997 Scsi_Cmnd *, int, int);
998static mega_ext_passthru* mega_prepare_extpassthru(adapter_t *,
999 scb_t *, Scsi_Cmnd *, int, int);
1000static void mega_enum_raid_scsi(adapter_t *);
1001static void mega_get_boot_drv(adapter_t *);
1002static int mega_support_random_del(adapter_t *);
1003static int mega_del_logdrv(adapter_t *, int);
1004static int mega_do_del_logdrv(adapter_t *, int);
1005static void mega_get_max_sgl(adapter_t *);
1006static int mega_internal_command(adapter_t *, megacmd_t *, mega_passthru *);
1007static int mega_support_cluster(adapter_t *);
1008#endif
1009
1010
1011