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