1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#ifndef _BUSLOGIC_H
29#define _BUSLOGIC_H
30
31
32#ifndef PACKED
33#define PACKED __attribute__((packed))
34#endif
35
36
37
38
39
40#define BLOGIC_MAX_ADAPTERS 16
41
42
43
44
45
46
47#define BLOGIC_MAXDEV 16
48
49
50
51
52
53
54
55
56#define BLOGIC_SG_LIMIT 128
57
58
59
60
61
62
63
64
65#define BLOGIC_MAX_TAG_DEPTH 64
66#define BLOGIC_MAX_AUTO_TAG_DEPTH 28
67#define BLOGIC_MIN_AUTO_TAG_DEPTH 7
68#define BLOGIC_TAG_DEPTH_BB 3
69#define BLOGIC_UNTAG_DEPTH 3
70#define BLOGIC_UNTAG_DEPTH_BB 2
71
72
73
74
75
76
77
78
79
80#define BLOGIC_BUS_SETTLE_TIME 2
81
82
83
84
85
86
87
88
89
90#define BLOGIC_MAX_MAILBOX 211
91
92
93
94
95
96
97
98#define BLOGIC_CCB_GRP_ALLOCSIZE 7
99
100
101
102
103
104
105#define BLOGIC_LINEBUF_SIZE 100
106#define BLOGIC_MSGBUF_SIZE 9700
107
108
109
110
111
112
113enum blogic_msglevel {
114 BLOGIC_ANNOUNCE_LEVEL = 0,
115 BLOGIC_INFO_LEVEL = 1,
116 BLOGIC_NOTICE_LEVEL = 2,
117 BLOGIC_WARN_LEVEL = 3,
118 BLOGIC_ERR_LEVEL = 4
119};
120
121static char *blogic_msglevelmap[] = { KERN_NOTICE, KERN_NOTICE, KERN_NOTICE, KERN_WARNING, KERN_ERR };
122
123
124
125
126
127
128#define blogic_announce(format, args...) \
129 blogic_msg(BLOGIC_ANNOUNCE_LEVEL, format, ##args)
130
131#define blogic_info(format, args...) \
132 blogic_msg(BLOGIC_INFO_LEVEL, format, ##args)
133
134#define blogic_notice(format, args...) \
135 blogic_msg(BLOGIC_NOTICE_LEVEL, format, ##args)
136
137#define blogic_warn(format, args...) \
138 blogic_msg(BLOGIC_WARN_LEVEL, format, ##args)
139
140#define blogic_err(format, args...) \
141 blogic_msg(BLOGIC_ERR_LEVEL, format, ##args)
142
143
144
145
146
147
148
149enum blogic_adapter_type {
150 BLOGIC_MULTIMASTER = 1,
151 BLOGIC_FLASHPOINT = 2
152} PACKED;
153
154#define BLOGIC_MULTIMASTER_ADDR_COUNT 4
155#define BLOGIC_FLASHPOINT_ADDR_COUNT 256
156
157static int blogic_adapter_addr_count[3] = { 0, BLOGIC_MULTIMASTER_ADDR_COUNT, BLOGIC_FLASHPOINT_ADDR_COUNT };
158
159
160
161
162
163
164#ifdef CONFIG_SCSI_FLASHPOINT
165
166#define blogic_multimaster_type(adapter) \
167 (adapter->adapter_type == BLOGIC_MULTIMASTER)
168
169#define blogic_flashpoint_type(adapter) \
170 (adapter->adapter_type == BLOGIC_FLASHPOINT)
171
172#else
173
174#define blogic_multimaster_type(adapter) (true)
175#define blogic_flashpoint_type(adapter) (false)
176
177#endif
178
179
180
181
182
183
184enum blogic_adapter_bus_type {
185 BLOGIC_UNKNOWN_BUS = 0,
186 BLOGIC_ISA_BUS = 1,
187 BLOGIC_EISA_BUS = 2,
188 BLOGIC_PCI_BUS = 3,
189 BLOGIC_VESA_BUS = 4,
190 BLOGIC_MCA_BUS = 5
191} PACKED;
192
193static char *blogic_adapter_busnames[] = { "Unknown", "ISA", "EISA", "PCI", "VESA", "MCA" };
194
195static enum blogic_adapter_bus_type blogic_adater_bus_types[] = {
196 BLOGIC_VESA_BUS,
197 BLOGIC_ISA_BUS,
198 BLOGIC_MCA_BUS,
199 BLOGIC_EISA_BUS,
200 BLOGIC_UNKNOWN_BUS,
201 BLOGIC_PCI_BUS
202};
203
204
205
206
207
208enum blogic_bios_diskgeometry {
209 BLOGIC_BIOS_NODISK = 0,
210 BLOGIC_BIOS_DISK64x32 = 1,
211 BLOGIC_BIOS_DISK128x32 = 2,
212 BLOGIC_BIOS_DISK255x63 = 3
213} PACKED;
214
215
216
217
218
219
220struct blogic_byte_count {
221 unsigned int units;
222 unsigned int billions;
223};
224
225
226
227
228
229
230struct blogic_probeinfo {
231 enum blogic_adapter_type adapter_type;
232 enum blogic_adapter_bus_type adapter_bus_type;
233 unsigned long io_addr;
234 unsigned long pci_addr;
235 struct pci_dev *pci_device;
236 unsigned char bus;
237 unsigned char dev;
238 unsigned char irq_ch;
239};
240
241
242
243
244
245struct blogic_probe_options {
246 bool noprobe:1;
247 bool noprobe_isa:1;
248 bool noprobe_pci:1;
249 bool nosort_pci:1;
250 bool multimaster_first:1;
251 bool flashpoint_first:1;
252 bool limited_isa:1;
253 bool probe330:1;
254 bool probe334:1;
255 bool probe230:1;
256 bool probe234:1;
257 bool probe130:1;
258 bool probe134:1;
259};
260
261
262
263
264
265struct blogic_global_options {
266 bool trace_probe:1;
267 bool trace_hw_reset:1;
268 bool trace_config:1;
269 bool trace_err:1;
270};
271
272
273
274
275
276#define BLOGIC_CNTRL_REG 0
277#define BLOGIC_STATUS_REG 0
278#define BLOGIC_CMD_PARM_REG 1
279#define BLOGIC_DATAIN_REG 1
280#define BLOGIC_INT_REG 2
281#define BLOGIC_GEOMETRY_REG 3
282
283
284
285
286
287union blogic_cntrl_reg {
288 unsigned char all;
289 struct {
290 unsigned char:4;
291 bool bus_reset:1;
292 bool int_reset:1;
293 bool soft_reset:1;
294 bool hard_reset:1;
295 } cr;
296};
297
298
299
300
301
302union blogic_stat_reg {
303 unsigned char all;
304 struct {
305 bool cmd_invalid:1;
306 bool rsvd:1;
307 bool datain_ready:1;
308 bool cmd_param_busy:1;
309 bool adapter_ready:1;
310 bool init_reqd:1;
311 bool diag_failed:1;
312 bool diag_active:1;
313 } sr;
314};
315
316
317
318
319
320union blogic_int_reg {
321 unsigned char all;
322 struct {
323 bool mailin_loaded:1;
324 bool mailout_avail:1;
325 bool cmd_complete:1;
326 bool ext_busreset:1;
327 unsigned char rsvd:3;
328 bool int_valid:1;
329 } ir;
330};
331
332
333
334
335
336union blogic_geo_reg {
337 unsigned char all;
338 struct {
339 enum blogic_bios_diskgeometry d0_geo:2;
340 enum blogic_bios_diskgeometry d1_geo:2;
341 unsigned char:3;
342 bool ext_trans_enable:1;
343 } gr;
344};
345
346
347
348
349
350enum blogic_opcode {
351 BLOGIC_TEST_CMP_COMPLETE = 0x00,
352 BLOGIC_INIT_MBOX = 0x01,
353 BLOGIC_EXEC_MBOX_CMD = 0x02,
354 BLOGIC_EXEC_BIOS_CMD = 0x03,
355 BLOGIC_GET_BOARD_ID = 0x04,
356 BLOGIC_ENABLE_OUTBOX_AVAIL_INT = 0x05,
357 BLOGIC_SET_SELECT_TIMEOUT = 0x06,
358 BLOGIC_SET_PREEMPT_TIME = 0x07,
359 BLOGIC_SET_TIMEOFF_BUS = 0x08,
360 BLOGIC_SET_TXRATE = 0x09,
361 BLOGIC_INQ_DEV0TO7 = 0x0A,
362 BLOGIC_INQ_CONFIG = 0x0B,
363 BLOGIC_TGT_MODE = 0x0C,
364 BLOGIC_INQ_SETUPINFO = 0x0D,
365 BLOGIC_WRITE_LOCALRAM = 0x1A,
366 BLOGIC_READ_LOCALRAM = 0x1B,
367 BLOGIC_WRITE_BUSMASTER_FIFO = 0x1C,
368 BLOGIC_READ_BUSMASTER_FIFO = 0x1D,
369 BLOGIC_ECHO_CMDDATA = 0x1F,
370 BLOGIC_ADAPTER_DIAG = 0x20,
371 BLOGIC_SET_OPTIONS = 0x21,
372 BLOGIC_INQ_DEV8TO15 = 0x23,
373 BLOGIC_INQ_DEV = 0x24,
374 BLOGIC_DISABLE_INT = 0x25,
375 BLOGIC_INIT_EXT_MBOX = 0x81,
376 BLOGIC_EXEC_SCS_CMD = 0x83,
377 BLOGIC_INQ_FWVER_D3 = 0x84,
378 BLOGIC_INQ_FWVER_LETTER = 0x85,
379 BLOGIC_INQ_PCI_INFO = 0x86,
380 BLOGIC_INQ_MODELNO = 0x8B,
381 BLOGIC_INQ_SYNC_PERIOD = 0x8C,
382 BLOGIC_INQ_EXTSETUP = 0x8D,
383 BLOGIC_STRICT_RR = 0x8F,
384 BLOGIC_STORE_LOCALRAM = 0x90,
385 BLOGIC_FETCH_LOCALRAM = 0x91,
386 BLOGIC_STORE_TO_EEPROM = 0x92,
387 BLOGIC_LOAD_AUTOSCSICODE = 0x94,
388 BLOGIC_MOD_IOADDR = 0x95,
389 BLOGIC_SETCCB_FMT = 0x96,
390 BLOGIC_WRITE_INQBUF = 0x9A,
391 BLOGIC_READ_INQBUF = 0x9B,
392 BLOGIC_FLASH_LOAD = 0xA7,
393 BLOGIC_READ_SCAMDATA = 0xA8,
394 BLOGIC_WRITE_SCAMDATA = 0xA9
395};
396
397
398
399
400
401struct blogic_board_id {
402 unsigned char type;
403 unsigned char custom_features;
404 unsigned char fw_ver_digit1;
405 unsigned char fw_ver_digit2;
406};
407
408
409
410
411
412struct blogic_config {
413 unsigned char:5;
414 bool dma_ch5:1;
415 bool dma_ch6:1;
416 bool dma_ch7:1;
417 bool irq_ch9:1;
418 bool irq_ch10:1;
419 bool irq_ch11:1;
420 bool irq_ch12:1;
421 unsigned char:1;
422 bool irq_ch14:1;
423 bool irq_ch15:1;
424 unsigned char:1;
425 unsigned char id:4;
426 unsigned char:4;
427};
428
429
430
431
432
433struct blogic_syncval {
434 unsigned char offset:4;
435 unsigned char tx_period:3;
436 bool sync:1;
437};
438
439struct blogic_setup_info {
440 bool sync:1;
441 bool parity:1;
442 unsigned char:6;
443 unsigned char tx_rate;
444 unsigned char preempt_time;
445 unsigned char timeoff_bus;
446 unsigned char mbox_count;
447 unsigned char mbox_addr[3];
448 struct blogic_syncval sync0to7[8];
449 unsigned char disconnect_ok0to7;
450 unsigned char sig;
451 unsigned char char_d;
452 unsigned char bus_type;
453 unsigned char wide_tx_ok0to7;
454 unsigned char wide_tx_active0to7;
455 struct blogic_syncval sync8to15[8];
456 unsigned char disconnect_ok8to15;
457 unsigned char:8;
458 unsigned char wide_tx_ok8to15;
459 unsigned char wide_tx_active8to15;
460};
461
462
463
464
465
466struct blogic_extmbox_req {
467 unsigned char mbox_count;
468 u32 base_mbox_addr;
469} PACKED;
470
471
472
473
474
475
476
477
478enum blogic_isa_ioport {
479 BLOGIC_IO_330 = 0,
480 BLOGIC_IO_334 = 1,
481 BLOGIC_IO_230 = 2,
482 BLOGIC_IO_234 = 3,
483 BLOGIC_IO_130 = 4,
484 BLOGIC_IO_134 = 5,
485 BLOGIC_IO_DISABLE = 6,
486 BLOGIC_IO_DISABLE2 = 7
487} PACKED;
488
489struct blogic_adapter_info {
490 enum blogic_isa_ioport isa_port;
491 unsigned char irq_ch;
492 bool low_term:1;
493 bool high_term:1;
494 unsigned char:2;
495 bool JP1:1;
496 bool JP2:1;
497 bool JP3:1;
498 bool genericinfo_valid:1;
499 unsigned char:8;
500};
501
502
503
504
505
506struct blogic_ext_setup {
507 unsigned char bus_type;
508 unsigned char bios_addr;
509 unsigned short sg_limit;
510 unsigned char mbox_count;
511 u32 base_mbox_addr;
512 struct {
513 unsigned char:2;
514 bool fast_on_eisa:1;
515 unsigned char:3;
516 bool level_int:1;
517 unsigned char:1;
518 } misc;
519 unsigned char fw_rev[3];
520 bool wide:1;
521 bool differential:1;
522 bool scam:1;
523 bool ultra:1;
524 bool smart_term:1;
525 unsigned char:3;
526} PACKED;
527
528
529
530
531
532enum blogic_rr_req {
533 BLOGIC_AGGRESSIVE_RR = 0,
534 BLOGIC_STRICT_RR_MODE = 1
535} PACKED;
536
537
538
539
540
541
542#define BLOGIC_BIOS_BASE 0
543#define BLOGIC_AUTOSCSI_BASE 64
544
545struct blogic_fetch_localram {
546 unsigned char offset;
547 unsigned char count;
548};
549
550
551
552
553
554struct blogic_autoscsi {
555 unsigned char factory_sig[2];
556 unsigned char info_bytes;
557 unsigned char adapter_type[6];
558 unsigned char:8;
559 bool floppy:1;
560 bool floppy_sec:1;
561 bool level_int:1;
562 unsigned char:2;
563 unsigned char systemram_bios:3;
564 unsigned char dma_ch:7;
565 bool dma_autoconf:1;
566 unsigned char irq_ch:7;
567 bool irq_autoconf:1;
568 unsigned char dma_tx_rate;
569 unsigned char scsi_id;
570 bool low_term:1;
571 bool parity:1;
572 bool high_term:1;
573 bool noisy_cable:1;
574 bool fast_sync_neg:1;
575 bool reset_enabled:1;
576 bool:1;
577 bool active_negation:1;
578 unsigned char bus_on_delay;
579 unsigned char bus_off_delay;
580 bool bios_enabled:1;
581 bool int19_redir_enabled:1;
582 bool ext_trans_enable:1;
583 bool removable_as_fixed:1;
584 bool:1;
585 bool morethan2_drives:1;
586 bool bios_int:1;
587 bool floptical:1;
588 unsigned short dev_enabled;
589 unsigned short wide_ok;
590 unsigned short fast_ok;
591 unsigned short sync_ok;
592 unsigned short discon_ok;
593 unsigned short send_start_unit;
594 unsigned short ignore_bios_scan;
595 unsigned char pci_int_pin:2;
596 unsigned char adapter_ioport:2;
597 bool strict_rr_enabled:1;
598 bool vesabus_33mhzplus:1;
599 bool vesa_burst_write:1;
600 bool vesa_burst_read:1;
601 unsigned short ultra_ok;
602 unsigned int:32;
603 unsigned char:8;
604 unsigned char autoscsi_maxlun;
605 bool:1;
606 bool scam_dominant:1;
607 bool scam_enabled:1;
608 bool scam_lev2:1;
609 unsigned char:4;
610 bool int13_exten:1;
611 bool:1;
612 bool cd_boot:1;
613 unsigned char:5;
614 unsigned char boot_id:4;
615 unsigned char boot_ch:4;
616 unsigned char force_scan_order:1;
617 unsigned char:7;
618 unsigned short nontagged_to_alt_ok;
619 unsigned short reneg_sync_on_check;
620 unsigned char rsvd[10];
621 unsigned char manuf_diag[2];
622 unsigned short cksum;
623} PACKED;
624
625
626
627
628
629struct blogic_autoscsi_byte45 {
630 unsigned char force_scan_order:1;
631 unsigned char:7;
632};
633
634
635
636
637
638#define BLOGIC_BIOS_DRVMAP 17
639
640struct blogic_bios_drvmap {
641 unsigned char tgt_idbit3:1;
642 unsigned char:2;
643 enum blogic_bios_diskgeometry diskgeom:2;
644 unsigned char tgt_id:3;
645};
646
647
648
649
650
651
652enum blogic_setccb_fmt {
653 BLOGIC_LEGACY_LUN_CCB = 0,
654 BLOGIC_EXT_LUN_CCB = 1
655} PACKED;
656
657
658
659
660
661enum blogic_action {
662 BLOGIC_OUTBOX_FREE = 0x00,
663 BLOGIC_MBOX_START = 0x01,
664 BLOGIC_MBOX_ABORT = 0x02
665} PACKED;
666
667
668
669
670
671
672
673
674enum blogic_cmplt_code {
675 BLOGIC_INBOX_FREE = 0x00,
676 BLOGIC_CMD_COMPLETE_GOOD = 0x01,
677 BLOGIC_CMD_ABORT_BY_HOST = 0x02,
678 BLOGIC_CMD_NOTFOUND = 0x03,
679 BLOGIC_CMD_COMPLETE_ERROR = 0x04,
680 BLOGIC_INVALID_CCB = 0x05
681} PACKED;
682
683
684
685
686
687enum blogic_ccb_opcode {
688 BLOGIC_INITIATOR_CCB = 0x00,
689 BLOGIC_TGT_CCB = 0x01,
690 BLOGIC_INITIATOR_CCB_SG = 0x02,
691 BLOGIC_INITIATOR_CCBB_RESIDUAL = 0x03,
692 BLOGIC_INITIATOR_CCB_SG_RESIDUAL = 0x04,
693 BLOGIC_BDR = 0x81
694} PACKED;
695
696
697
698
699
700
701enum blogic_datadir {
702 BLOGIC_UNCHECKED_TX = 0,
703 BLOGIC_DATAIN_CHECKED = 1,
704 BLOGIC_DATAOUT_CHECKED = 2,
705 BLOGIC_NOTX = 3
706};
707
708
709
710
711
712
713
714enum blogic_adapter_status {
715 BLOGIC_CMD_CMPLT_NORMAL = 0x00,
716 BLOGIC_LINK_CMD_CMPLT = 0x0A,
717 BLOGIC_LINK_CMD_CMPLT_FLAG = 0x0B,
718 BLOGIC_DATA_UNDERRUN = 0x0C,
719 BLOGIC_SELECT_TIMEOUT = 0x11,
720 BLOGIC_DATA_OVERRUN = 0x12,
721 BLOGIC_NOEXPECT_BUSFREE = 0x13,
722 BLOGIC_INVALID_BUSPHASE = 0x14,
723 BLOGIC_INVALID_OUTBOX_CODE = 0x15,
724 BLOGIC_INVALID_CMD_CODE = 0x16,
725 BLOGIC_LINKCCB_BADLUN = 0x17,
726 BLOGIC_BAD_CMD_PARAM = 0x1A,
727 BLOGIC_AUTOREQSENSE_FAIL = 0x1B,
728 BLOGIC_TAGQUEUE_REJECT = 0x1C,
729 BLOGIC_BAD_MSG_RCVD = 0x1D,
730 BLOGIC_HW_FAIL = 0x20,
731 BLOGIC_NORESPONSE_TO_ATN = 0x21,
732 BLOGIC_HW_RESET = 0x22,
733 BLOGIC_RST_FROM_OTHERDEV = 0x23,
734 BLOGIC_BAD_RECONNECT = 0x24,
735 BLOGIC_HW_BDR = 0x25,
736 BLOGIC_ABRT_QUEUE = 0x26,
737 BLOGIC_ADAPTER_SW_ERROR = 0x27,
738 BLOGIC_HW_TIMEOUT = 0x30,
739 BLOGIC_PARITY_ERR = 0x34
740} PACKED;
741
742
743
744
745
746
747enum blogic_tgt_status {
748 BLOGIC_OP_GOOD = 0x00,
749 BLOGIC_CHECKCONDITION = 0x02,
750 BLOGIC_DEVBUSY = 0x08
751} PACKED;
752
753
754
755
756
757enum blogic_queuetag {
758 BLOGIC_SIMPLETAG = 0,
759 BLOGIC_HEADTAG = 1,
760 BLOGIC_ORDEREDTAG = 2,
761 BLOGIC_RSVDTAG = 3
762};
763
764
765
766
767
768#define BLOGIC_CDB_MAXLEN 12
769
770
771
772
773
774
775
776struct blogic_sg_seg {
777 u32 segbytes;
778 u32 segdata;
779};
780
781
782
783
784
785enum blogic_ccb_status {
786 BLOGIC_CCB_FREE = 0,
787 BLOGIC_CCB_ACTIVE = 1,
788 BLOGIC_CCB_COMPLETE = 2,
789 BLOGIC_CCB_RESET = 3
790} PACKED;
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812struct blogic_ccb {
813
814
815
816 enum blogic_ccb_opcode opcode;
817 unsigned char:3;
818 enum blogic_datadir datadir:2;
819 bool tag_enable:1;
820 enum blogic_queuetag queuetag:2;
821 unsigned char cdblen;
822 unsigned char sense_datalen;
823 u32 datalen;
824 void *data;
825 unsigned char:8;
826 unsigned char:8;
827 enum blogic_adapter_status adapter_status;
828 enum blogic_tgt_status tgt_status;
829 unsigned char tgt_id;
830 unsigned char lun:5;
831 bool legacytag_enable:1;
832 enum blogic_queuetag legacy_tag:2;
833 unsigned char cdb[BLOGIC_CDB_MAXLEN];
834 unsigned char:8;
835 unsigned char:8;
836 u32 rsvd_int;
837 u32 sensedata;
838
839
840
841 void (*callback) (struct blogic_ccb *);
842 u32 base_addr;
843 enum blogic_cmplt_code comp_code;
844#ifdef CONFIG_SCSI_FLASHPOINT
845 unsigned char:8;
846 u16 os_flags;
847 unsigned char private[24];
848 void *rsvd1;
849 void *rsvd2;
850 unsigned char private2[16];
851#endif
852
853
854
855 dma_addr_t allocgrp_head;
856 unsigned int allocgrp_size;
857 u32 dma_handle;
858 enum blogic_ccb_status status;
859 unsigned long serial;
860 struct scsi_cmnd *command;
861 struct blogic_adapter *adapter;
862 struct blogic_ccb *next;
863 struct blogic_ccb *next_all;
864 struct blogic_sg_seg sglist[BLOGIC_SG_LIMIT];
865};
866
867
868
869
870
871struct blogic_outbox {
872 u32 ccb;
873 u32:24;
874 enum blogic_action action;
875};
876
877
878
879
880
881struct blogic_inbox {
882 u32 ccb;
883 enum blogic_adapter_status adapter_status;
884 enum blogic_tgt_status tgt_status;
885 unsigned char:8;
886 enum blogic_cmplt_code comp_code;
887};
888
889
890
891
892
893
894struct blogic_drvr_options {
895 unsigned short tagq_ok;
896 unsigned short tagq_ok_mask;
897 unsigned short bus_settle_time;
898 unsigned short stop_tgt_inquiry;
899 unsigned char common_qdepth;
900 unsigned char qdepth[BLOGIC_MAXDEV];
901};
902
903
904
905
906
907struct blogic_tgt_flags {
908 bool tgt_exists:1;
909 bool tagq_ok:1;
910 bool wide_ok:1;
911 bool tagq_active:1;
912 bool wide_active:1;
913 bool cmd_good:1;
914 bool tgt_info_in:1;
915};
916
917
918
919
920
921#define BLOGIC_SZ_BUCKETS 10
922
923struct blogic_tgt_stats {
924 unsigned int cmds_tried;
925 unsigned int cmds_complete;
926 unsigned int read_cmds;
927 unsigned int write_cmds;
928 struct blogic_byte_count bytesread;
929 struct blogic_byte_count byteswritten;
930 unsigned int read_sz_buckets[BLOGIC_SZ_BUCKETS];
931 unsigned int write_sz_buckets[BLOGIC_SZ_BUCKETS];
932 unsigned short aborts_request;
933 unsigned short aborts_tried;
934 unsigned short aborts_done;
935 unsigned short bdr_request;
936 unsigned short bdr_tried;
937 unsigned short bdr_done;
938 unsigned short adatper_reset_req;
939 unsigned short adapter_reset_attempt;
940 unsigned short adapter_reset_done;
941};
942
943
944
945
946
947#define FPOINT_BADCARD_HANDLE 0xFFFFFFFFL
948
949
950
951
952
953
954
955struct fpoint_info {
956 u32 base_addr;
957 bool present;
958 unsigned char irq_ch;
959 unsigned char scsi_id;
960 unsigned char scsi_lun;
961 u16 fw_rev;
962 u16 sync_ok;
963 u16 fast_ok;
964 u16 ultra_ok;
965 u16 discon_ok;
966 u16 wide_ok;
967 bool parity:1;
968 bool wide:1;
969 bool softreset:1;
970 bool ext_trans_enable:1;
971 bool low_term:1;
972 bool high_term:1;
973 bool report_underrun:1;
974 bool scam_enabled:1;
975 bool scam_lev2:1;
976 unsigned char:7;
977 unsigned char family;
978 unsigned char bus_type;
979 unsigned char model[3];
980 unsigned char relative_cardnum;
981 unsigned char rsvd[4];
982 u32 os_rsvd;
983 unsigned char translation_info[4];
984 u32 rsvd2[5];
985 u32 sec_range;
986};
987
988
989
990
991
992struct blogic_adapter {
993 struct Scsi_Host *scsi_host;
994 struct pci_dev *pci_device;
995 enum blogic_adapter_type adapter_type;
996 enum blogic_adapter_bus_type adapter_bus_type;
997 unsigned long io_addr;
998 unsigned long pci_addr;
999 unsigned short addr_count;
1000 unsigned char host_no;
1001 unsigned char model[9];
1002 unsigned char fw_ver[6];
1003 unsigned char full_model[18];
1004 unsigned char bus;
1005 unsigned char dev;
1006 unsigned char irq_ch;
1007 unsigned char dma_ch;
1008 unsigned char scsi_id;
1009 bool irq_acquired:1;
1010 bool dma_chan_acquired:1;
1011 bool ext_trans_enable:1;
1012 bool parity:1;
1013 bool reset_enabled:1;
1014 bool level_int:1;
1015 bool wide:1;
1016 bool differential:1;
1017 bool scam:1;
1018 bool ultra:1;
1019 bool ext_lun:1;
1020 bool terminfo_valid:1;
1021 bool low_term:1;
1022 bool high_term:1;
1023 bool need_bouncebuf:1;
1024 bool strict_rr:1;
1025 bool scam_enabled:1;
1026 bool scam_lev2:1;
1027 bool adapter_initd:1;
1028 bool adapter_extreset:1;
1029 bool adapter_intern_err:1;
1030 bool processing_ccbs;
1031 volatile bool adapter_cmd_complete;
1032 unsigned short adapter_sglimit;
1033 unsigned short drvr_sglimit;
1034 unsigned short maxdev;
1035 unsigned short maxlun;
1036 unsigned short mbox_count;
1037 unsigned short initccbs;
1038 unsigned short inc_ccbs;
1039 unsigned short alloc_ccbs;
1040 unsigned short drvr_qdepth;
1041 unsigned short adapter_qdepth;
1042 unsigned short untag_qdepth;
1043 unsigned short common_qdepth;
1044 unsigned short bus_settle_time;
1045 unsigned short sync_ok;
1046 unsigned short fast_ok;
1047 unsigned short ultra_ok;
1048 unsigned short wide_ok;
1049 unsigned short discon_ok;
1050 unsigned short tagq_ok;
1051 unsigned short ext_resets;
1052 unsigned short adapter_intern_errors;
1053 unsigned short tgt_count;
1054 unsigned short msgbuflen;
1055 u32 bios_addr;
1056 struct blogic_drvr_options *drvr_opts;
1057 struct fpoint_info fpinfo;
1058 void *cardhandle;
1059 struct list_head host_list;
1060 struct blogic_ccb *all_ccbs;
1061 struct blogic_ccb *free_ccbs;
1062 struct blogic_ccb *firstccb;
1063 struct blogic_ccb *lastccb;
1064 struct blogic_ccb *bdr_pend[BLOGIC_MAXDEV];
1065 struct blogic_tgt_flags tgt_flags[BLOGIC_MAXDEV];
1066 unsigned char qdepth[BLOGIC_MAXDEV];
1067 unsigned char sync_period[BLOGIC_MAXDEV];
1068 unsigned char sync_offset[BLOGIC_MAXDEV];
1069 unsigned char active_cmds[BLOGIC_MAXDEV];
1070 unsigned int cmds_since_rst[BLOGIC_MAXDEV];
1071 unsigned long last_seqpoint[BLOGIC_MAXDEV];
1072 unsigned long last_resettried[BLOGIC_MAXDEV];
1073 unsigned long last_resetdone[BLOGIC_MAXDEV];
1074 struct blogic_outbox *first_outbox;
1075 struct blogic_outbox *last_outbox;
1076 struct blogic_outbox *next_outbox;
1077 struct blogic_inbox *first_inbox;
1078 struct blogic_inbox *last_inbox;
1079 struct blogic_inbox *next_inbox;
1080 struct blogic_tgt_stats tgt_stats[BLOGIC_MAXDEV];
1081 unsigned char *mbox_space;
1082 dma_addr_t mbox_space_handle;
1083 unsigned int mbox_sz;
1084 unsigned long ccb_offset;
1085 char msgbuf[BLOGIC_MSGBUF_SIZE];
1086};
1087
1088
1089
1090
1091
1092struct bios_diskparam {
1093 int heads;
1094 int sectors;
1095 int cylinders;
1096};
1097
1098
1099
1100
1101
1102struct scsi_inquiry {
1103 unsigned char devtype:5;
1104 unsigned char dev_qual:3;
1105 unsigned char dev_modifier:7;
1106 bool rmb:1;
1107 unsigned char ansi_ver:3;
1108 unsigned char ecma_ver:3;
1109 unsigned char iso_ver:2;
1110 unsigned char resp_fmt:4;
1111 unsigned char:2;
1112 bool TrmIOP:1;
1113 bool AENC:1;
1114 unsigned char addl_len;
1115 unsigned char:8;
1116 unsigned char:8;
1117 bool SftRe:1;
1118 bool CmdQue:1;
1119 bool:1;
1120 bool linked:1;
1121 bool sync:1;
1122 bool WBus16:1;
1123 bool WBus32:1;
1124 bool RelAdr:1;
1125 unsigned char vendor[8];
1126 unsigned char product[16];
1127 unsigned char product_rev[4];
1128};
1129
1130
1131
1132
1133
1134
1135
1136static inline void blogic_busreset(struct blogic_adapter *adapter)
1137{
1138 union blogic_cntrl_reg cr;
1139 cr.all = 0;
1140 cr.cr.bus_reset = true;
1141 outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
1142}
1143
1144static inline void blogic_intreset(struct blogic_adapter *adapter)
1145{
1146 union blogic_cntrl_reg cr;
1147 cr.all = 0;
1148 cr.cr.int_reset = true;
1149 outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
1150}
1151
1152static inline void blogic_softreset(struct blogic_adapter *adapter)
1153{
1154 union blogic_cntrl_reg cr;
1155 cr.all = 0;
1156 cr.cr.soft_reset = true;
1157 outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
1158}
1159
1160static inline void blogic_hardreset(struct blogic_adapter *adapter)
1161{
1162 union blogic_cntrl_reg cr;
1163 cr.all = 0;
1164 cr.cr.hard_reset = true;
1165 outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
1166}
1167
1168static inline unsigned char blogic_rdstatus(struct blogic_adapter *adapter)
1169{
1170 return inb(adapter->io_addr + BLOGIC_STATUS_REG);
1171}
1172
1173static inline void blogic_setcmdparam(struct blogic_adapter *adapter,
1174 unsigned char value)
1175{
1176 outb(value, adapter->io_addr + BLOGIC_CMD_PARM_REG);
1177}
1178
1179static inline unsigned char blogic_rddatain(struct blogic_adapter *adapter)
1180{
1181 return inb(adapter->io_addr + BLOGIC_DATAIN_REG);
1182}
1183
1184static inline unsigned char blogic_rdint(struct blogic_adapter *adapter)
1185{
1186 return inb(adapter->io_addr + BLOGIC_INT_REG);
1187}
1188
1189static inline unsigned char blogic_rdgeom(struct blogic_adapter *adapter)
1190{
1191 return inb(adapter->io_addr + BLOGIC_GEOMETRY_REG);
1192}
1193
1194
1195
1196
1197
1198
1199
1200static inline void blogic_execmbox(struct blogic_adapter *adapter)
1201{
1202 blogic_setcmdparam(adapter, BLOGIC_EXEC_MBOX_CMD);
1203}
1204
1205
1206
1207
1208
1209static inline void blogic_delay(int seconds)
1210{
1211 mdelay(1000 * seconds);
1212}
1213
1214
1215
1216
1217
1218
1219
1220static inline u32 virt_to_32bit_virt(void *virt_addr)
1221{
1222 return (u32) (unsigned long) virt_addr;
1223}
1224
1225
1226
1227
1228
1229
1230static inline void blogic_inc_count(unsigned short *count)
1231{
1232 if (*count < 65535)
1233 (*count)++;
1234}
1235
1236
1237
1238
1239
1240static inline void blogic_addcount(struct blogic_byte_count *bytecount,
1241 unsigned int amount)
1242{
1243 bytecount->units += amount;
1244 if (bytecount->units > 999999999) {
1245 bytecount->units -= 1000000000;
1246 bytecount->billions++;
1247 }
1248}
1249
1250
1251
1252
1253
1254static inline void blogic_incszbucket(unsigned int *cmdsz_buckets,
1255 unsigned int amount)
1256{
1257 int index = 0;
1258 if (amount < 8 * 1024) {
1259 if (amount < 2 * 1024)
1260 index = (amount < 1 * 1024 ? 0 : 1);
1261 else
1262 index = (amount < 4 * 1024 ? 2 : 3);
1263 } else if (amount < 128 * 1024) {
1264 if (amount < 32 * 1024)
1265 index = (amount < 16 * 1024 ? 4 : 5);
1266 else
1267 index = (amount < 64 * 1024 ? 6 : 7);
1268 } else
1269 index = (amount < 256 * 1024 ? 8 : 9);
1270 cmdsz_buckets[index]++;
1271}
1272
1273
1274
1275
1276
1277#define FLASHPOINT_FW_VER "5.02"
1278
1279
1280
1281
1282
1283#define FPOINT_NORMAL_INT 0x00
1284#define FPOINT_INTERN_ERR 0xFE
1285#define FPOINT_EXT_RESET 0xFF
1286
1287
1288
1289
1290
1291
1292static const char *blogic_drvr_info(struct Scsi_Host *);
1293static int blogic_qcmd(struct Scsi_Host *h, struct scsi_cmnd *);
1294static int blogic_diskparam(struct scsi_device *, struct block_device *, sector_t, int *);
1295static int blogic_slaveconfig(struct scsi_device *);
1296static void blogic_qcompleted_ccb(struct blogic_ccb *);
1297static irqreturn_t blogic_inthandler(int, void *);
1298static int blogic_resetadapter(struct blogic_adapter *, bool hard_reset);
1299static void blogic_msg(enum blogic_msglevel, char *, struct blogic_adapter *, ...);
1300static int __init blogic_setup(char *);
1301
1302#endif
1303