0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #ifndef _BUSLOGIC_H
0022 #define _BUSLOGIC_H
0023
0024
0025 #ifndef PACKED
0026 #define PACKED __attribute__((packed))
0027 #endif
0028
0029
0030
0031
0032
0033 #define BLOGIC_MAX_ADAPTERS 16
0034
0035
0036
0037
0038
0039
0040 #define BLOGIC_MAXDEV 16
0041
0042
0043
0044
0045
0046
0047
0048
0049 #define BLOGIC_SG_LIMIT 128
0050
0051
0052
0053
0054
0055
0056
0057
0058 #define BLOGIC_MAX_TAG_DEPTH 64
0059 #define BLOGIC_MAX_AUTO_TAG_DEPTH 28
0060 #define BLOGIC_MIN_AUTO_TAG_DEPTH 7
0061 #define BLOGIC_TAG_DEPTH_BB 3
0062 #define BLOGIC_UNTAG_DEPTH 3
0063 #define BLOGIC_UNTAG_DEPTH_BB 2
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073 #define BLOGIC_BUS_SETTLE_TIME 2
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 #define BLOGIC_MAX_MAILBOX 211
0084
0085
0086
0087
0088
0089
0090
0091 #define BLOGIC_CCB_GRP_ALLOCSIZE 7
0092
0093
0094
0095
0096
0097
0098 #define BLOGIC_LINEBUF_SIZE 100
0099 #define BLOGIC_MSGBUF_SIZE 9700
0100
0101
0102
0103
0104
0105
0106 enum blogic_msglevel {
0107 BLOGIC_ANNOUNCE_LEVEL = 0,
0108 BLOGIC_INFO_LEVEL = 1,
0109 BLOGIC_NOTICE_LEVEL = 2,
0110 BLOGIC_WARN_LEVEL = 3,
0111 BLOGIC_ERR_LEVEL = 4
0112 };
0113
0114 static char *blogic_msglevelmap[] = { KERN_NOTICE, KERN_NOTICE, KERN_NOTICE, KERN_WARNING, KERN_ERR };
0115
0116
0117
0118
0119
0120
0121 #define blogic_announce(format, args...) \
0122 blogic_msg(BLOGIC_ANNOUNCE_LEVEL, format, ##args)
0123
0124 #define blogic_info(format, args...) \
0125 blogic_msg(BLOGIC_INFO_LEVEL, format, ##args)
0126
0127 #define blogic_notice(format, args...) \
0128 blogic_msg(BLOGIC_NOTICE_LEVEL, format, ##args)
0129
0130 #define blogic_warn(format, args...) \
0131 blogic_msg(BLOGIC_WARN_LEVEL, format, ##args)
0132
0133 #define blogic_err(format, args...) \
0134 blogic_msg(BLOGIC_ERR_LEVEL, format, ##args)
0135
0136
0137
0138
0139
0140
0141
0142 enum blogic_adapter_type {
0143 BLOGIC_MULTIMASTER = 1,
0144 BLOGIC_FLASHPOINT = 2
0145 } PACKED;
0146
0147 #define BLOGIC_MULTIMASTER_ADDR_COUNT 4
0148 #define BLOGIC_FLASHPOINT_ADDR_COUNT 256
0149
0150 static int blogic_adapter_addr_count[3] = { 0, BLOGIC_MULTIMASTER_ADDR_COUNT, BLOGIC_FLASHPOINT_ADDR_COUNT };
0151
0152
0153
0154
0155
0156
0157 #ifdef CONFIG_SCSI_FLASHPOINT
0158
0159 #define blogic_multimaster_type(adapter) \
0160 (adapter->adapter_type == BLOGIC_MULTIMASTER)
0161
0162 #define blogic_flashpoint_type(adapter) \
0163 (adapter->adapter_type == BLOGIC_FLASHPOINT)
0164
0165 #else
0166
0167 #define blogic_multimaster_type(adapter) (true)
0168 #define blogic_flashpoint_type(adapter) (false)
0169
0170 #endif
0171
0172
0173
0174
0175
0176
0177 enum blogic_adapter_bus_type {
0178 BLOGIC_UNKNOWN_BUS = 0,
0179 BLOGIC_ISA_BUS = 1,
0180 BLOGIC_EISA_BUS = 2,
0181 BLOGIC_PCI_BUS = 3,
0182 BLOGIC_VESA_BUS = 4,
0183 BLOGIC_MCA_BUS = 5
0184 } PACKED;
0185
0186 static char *blogic_adapter_busnames[] = { "Unknown", "ISA", "EISA", "PCI", "VESA", "MCA" };
0187
0188 static enum blogic_adapter_bus_type blogic_adater_bus_types[] = {
0189 BLOGIC_VESA_BUS,
0190 BLOGIC_ISA_BUS,
0191 BLOGIC_MCA_BUS,
0192 BLOGIC_EISA_BUS,
0193 BLOGIC_UNKNOWN_BUS,
0194 BLOGIC_PCI_BUS
0195 };
0196
0197
0198
0199
0200
0201 enum blogic_bios_diskgeometry {
0202 BLOGIC_BIOS_NODISK = 0,
0203 BLOGIC_BIOS_DISK64x32 = 1,
0204 BLOGIC_BIOS_DISK128x32 = 2,
0205 BLOGIC_BIOS_DISK255x63 = 3
0206 } PACKED;
0207
0208
0209
0210
0211
0212
0213 struct blogic_byte_count {
0214 unsigned int units;
0215 unsigned int billions;
0216 };
0217
0218
0219
0220
0221
0222
0223 struct blogic_probeinfo {
0224 enum blogic_adapter_type adapter_type;
0225 enum blogic_adapter_bus_type adapter_bus_type;
0226 unsigned long io_addr;
0227 unsigned long pci_addr;
0228 struct pci_dev *pci_device;
0229 unsigned char bus;
0230 unsigned char dev;
0231 unsigned char irq_ch;
0232 };
0233
0234
0235
0236
0237
0238 struct blogic_probe_options {
0239 bool noprobe:1;
0240 bool noprobe_pci:1;
0241 bool nosort_pci:1;
0242 bool multimaster_first:1;
0243 bool flashpoint_first:1;
0244 };
0245
0246
0247
0248
0249
0250 struct blogic_global_options {
0251 bool trace_probe:1;
0252 bool trace_hw_reset:1;
0253 bool trace_config:1;
0254 bool trace_err:1;
0255 };
0256
0257
0258
0259
0260
0261 #define BLOGIC_CNTRL_REG 0
0262 #define BLOGIC_STATUS_REG 0
0263 #define BLOGIC_CMD_PARM_REG 1
0264 #define BLOGIC_DATAIN_REG 1
0265 #define BLOGIC_INT_REG 2
0266 #define BLOGIC_GEOMETRY_REG 3
0267
0268
0269
0270
0271
0272 union blogic_cntrl_reg {
0273 unsigned char all;
0274 struct {
0275 unsigned char:4;
0276 bool bus_reset:1;
0277 bool int_reset:1;
0278 bool soft_reset:1;
0279 bool hard_reset:1;
0280 } cr;
0281 };
0282
0283
0284
0285
0286
0287 union blogic_stat_reg {
0288 unsigned char all;
0289 struct {
0290 bool cmd_invalid:1;
0291 bool rsvd:1;
0292 bool datain_ready:1;
0293 bool cmd_param_busy:1;
0294 bool adapter_ready:1;
0295 bool init_reqd:1;
0296 bool diag_failed:1;
0297 bool diag_active:1;
0298 } sr;
0299 };
0300
0301
0302
0303
0304
0305 union blogic_int_reg {
0306 unsigned char all;
0307 struct {
0308 bool mailin_loaded:1;
0309 bool mailout_avail:1;
0310 bool cmd_complete:1;
0311 bool ext_busreset:1;
0312 unsigned char rsvd:3;
0313 bool int_valid:1;
0314 } ir;
0315 };
0316
0317
0318
0319
0320
0321 union blogic_geo_reg {
0322 unsigned char all;
0323 struct {
0324 enum blogic_bios_diskgeometry d0_geo:2;
0325 enum blogic_bios_diskgeometry d1_geo:2;
0326 unsigned char:3;
0327 bool ext_trans_enable:1;
0328 } gr;
0329 };
0330
0331
0332
0333
0334
0335 enum blogic_opcode {
0336 BLOGIC_TEST_CMP_COMPLETE = 0x00,
0337 BLOGIC_INIT_MBOX = 0x01,
0338 BLOGIC_EXEC_MBOX_CMD = 0x02,
0339 BLOGIC_EXEC_BIOS_CMD = 0x03,
0340 BLOGIC_GET_BOARD_ID = 0x04,
0341 BLOGIC_ENABLE_OUTBOX_AVAIL_INT = 0x05,
0342 BLOGIC_SET_SELECT_TIMEOUT = 0x06,
0343 BLOGIC_SET_PREEMPT_TIME = 0x07,
0344 BLOGIC_SET_TIMEOFF_BUS = 0x08,
0345 BLOGIC_SET_TXRATE = 0x09,
0346 BLOGIC_INQ_DEV0TO7 = 0x0A,
0347 BLOGIC_INQ_CONFIG = 0x0B,
0348 BLOGIC_TGT_MODE = 0x0C,
0349 BLOGIC_INQ_SETUPINFO = 0x0D,
0350 BLOGIC_WRITE_LOCALRAM = 0x1A,
0351 BLOGIC_READ_LOCALRAM = 0x1B,
0352 BLOGIC_WRITE_BUSMASTER_FIFO = 0x1C,
0353 BLOGIC_READ_BUSMASTER_FIFO = 0x1D,
0354 BLOGIC_ECHO_CMDDATA = 0x1F,
0355 BLOGIC_ADAPTER_DIAG = 0x20,
0356 BLOGIC_SET_OPTIONS = 0x21,
0357 BLOGIC_INQ_DEV8TO15 = 0x23,
0358 BLOGIC_INQ_DEV = 0x24,
0359 BLOGIC_DISABLE_INT = 0x25,
0360 BLOGIC_INIT_EXT_MBOX = 0x81,
0361 BLOGIC_EXEC_SCS_CMD = 0x83,
0362 BLOGIC_INQ_FWVER_D3 = 0x84,
0363 BLOGIC_INQ_FWVER_LETTER = 0x85,
0364 BLOGIC_INQ_PCI_INFO = 0x86,
0365 BLOGIC_INQ_MODELNO = 0x8B,
0366 BLOGIC_INQ_SYNC_PERIOD = 0x8C,
0367 BLOGIC_INQ_EXTSETUP = 0x8D,
0368 BLOGIC_STRICT_RR = 0x8F,
0369 BLOGIC_STORE_LOCALRAM = 0x90,
0370 BLOGIC_FETCH_LOCALRAM = 0x91,
0371 BLOGIC_STORE_TO_EEPROM = 0x92,
0372 BLOGIC_LOAD_AUTOSCSICODE = 0x94,
0373 BLOGIC_MOD_IOADDR = 0x95,
0374 BLOGIC_SETCCB_FMT = 0x96,
0375 BLOGIC_WRITE_INQBUF = 0x9A,
0376 BLOGIC_READ_INQBUF = 0x9B,
0377 BLOGIC_FLASH_LOAD = 0xA7,
0378 BLOGIC_READ_SCAMDATA = 0xA8,
0379 BLOGIC_WRITE_SCAMDATA = 0xA9
0380 };
0381
0382
0383
0384
0385
0386 struct blogic_board_id {
0387 unsigned char type;
0388 unsigned char custom_features;
0389 unsigned char fw_ver_digit1;
0390 unsigned char fw_ver_digit2;
0391 };
0392
0393
0394
0395
0396
0397 struct blogic_config {
0398 unsigned char:5;
0399 bool dma_ch5:1;
0400 bool dma_ch6:1;
0401 bool dma_ch7:1;
0402 bool irq_ch9:1;
0403 bool irq_ch10:1;
0404 bool irq_ch11:1;
0405 bool irq_ch12:1;
0406 unsigned char:1;
0407 bool irq_ch14:1;
0408 bool irq_ch15:1;
0409 unsigned char:1;
0410 unsigned char id:4;
0411 unsigned char:4;
0412 };
0413
0414
0415
0416
0417
0418 struct blogic_syncval {
0419 unsigned char offset:4;
0420 unsigned char tx_period:3;
0421 bool sync:1;
0422 };
0423
0424 struct blogic_setup_info {
0425 bool sync:1;
0426 bool parity:1;
0427 unsigned char:6;
0428 unsigned char tx_rate;
0429 unsigned char preempt_time;
0430 unsigned char timeoff_bus;
0431 unsigned char mbox_count;
0432 unsigned char mbox_addr[3];
0433 struct blogic_syncval sync0to7[8];
0434 unsigned char disconnect_ok0to7;
0435 unsigned char sig;
0436 unsigned char char_d;
0437 unsigned char bus_type;
0438 unsigned char wide_tx_ok0to7;
0439 unsigned char wide_tx_active0to7;
0440 struct blogic_syncval sync8to15[8];
0441 unsigned char disconnect_ok8to15;
0442 unsigned char:8;
0443 unsigned char wide_tx_ok8to15;
0444 unsigned char wide_tx_active8to15;
0445 };
0446
0447
0448
0449
0450
0451 struct blogic_extmbox_req {
0452 unsigned char mbox_count;
0453 u32 base_mbox_addr;
0454 } PACKED;
0455
0456
0457
0458
0459
0460
0461
0462
0463 enum blogic_isa_ioport {
0464 BLOGIC_IO_330 = 0,
0465 BLOGIC_IO_334 = 1,
0466 BLOGIC_IO_230 = 2,
0467 BLOGIC_IO_234 = 3,
0468 BLOGIC_IO_130 = 4,
0469 BLOGIC_IO_134 = 5,
0470 BLOGIC_IO_DISABLE = 6,
0471 BLOGIC_IO_DISABLE2 = 7
0472 } PACKED;
0473
0474 struct blogic_adapter_info {
0475 enum blogic_isa_ioport isa_port;
0476 unsigned char irq_ch;
0477 bool low_term:1;
0478 bool high_term:1;
0479 unsigned char:2;
0480 bool JP1:1;
0481 bool JP2:1;
0482 bool JP3:1;
0483 bool genericinfo_valid:1;
0484 unsigned char:8;
0485 };
0486
0487
0488
0489
0490
0491 struct blogic_ext_setup {
0492 unsigned char bus_type;
0493 unsigned char bios_addr;
0494 unsigned short sg_limit;
0495 unsigned char mbox_count;
0496 u32 base_mbox_addr;
0497 struct {
0498 unsigned char:2;
0499 bool fast_on_eisa:1;
0500 unsigned char:3;
0501 bool level_int:1;
0502 unsigned char:1;
0503 } misc;
0504 unsigned char fw_rev[3];
0505 bool wide:1;
0506 bool differential:1;
0507 bool scam:1;
0508 bool ultra:1;
0509 bool smart_term:1;
0510 unsigned char:3;
0511 } PACKED;
0512
0513
0514
0515
0516
0517 enum blogic_rr_req {
0518 BLOGIC_AGGRESSIVE_RR = 0,
0519 BLOGIC_STRICT_RR_MODE = 1
0520 } PACKED;
0521
0522
0523
0524
0525
0526
0527 #define BLOGIC_BIOS_BASE 0
0528 #define BLOGIC_AUTOSCSI_BASE 64
0529
0530 struct blogic_fetch_localram {
0531 unsigned char offset;
0532 unsigned char count;
0533 };
0534
0535
0536
0537
0538
0539 struct blogic_autoscsi {
0540 unsigned char factory_sig[2];
0541 unsigned char info_bytes;
0542 unsigned char adapter_type[6];
0543 unsigned char:8;
0544 bool floppy:1;
0545 bool floppy_sec:1;
0546 bool level_int:1;
0547 unsigned char:2;
0548 unsigned char systemram_bios:3;
0549 unsigned char dma_ch:7;
0550 bool dma_autoconf:1;
0551 unsigned char irq_ch:7;
0552 bool irq_autoconf:1;
0553 unsigned char dma_tx_rate;
0554 unsigned char scsi_id;
0555 bool low_term:1;
0556 bool parity:1;
0557 bool high_term:1;
0558 bool noisy_cable:1;
0559 bool fast_sync_neg:1;
0560 bool reset_enabled:1;
0561 bool:1;
0562 bool active_negation:1;
0563 unsigned char bus_on_delay;
0564 unsigned char bus_off_delay;
0565 bool bios_enabled:1;
0566 bool int19_redir_enabled:1;
0567 bool ext_trans_enable:1;
0568 bool removable_as_fixed:1;
0569 bool:1;
0570 bool morethan2_drives:1;
0571 bool bios_int:1;
0572 bool floptical:1;
0573 unsigned short dev_enabled;
0574 unsigned short wide_ok;
0575 unsigned short fast_ok;
0576 unsigned short sync_ok;
0577 unsigned short discon_ok;
0578 unsigned short send_start_unit;
0579 unsigned short ignore_bios_scan;
0580 unsigned char pci_int_pin:2;
0581 unsigned char adapter_ioport:2;
0582 bool strict_rr_enabled:1;
0583 bool vesabus_33mhzplus:1;
0584 bool vesa_burst_write:1;
0585 bool vesa_burst_read:1;
0586 unsigned short ultra_ok;
0587 unsigned int:32;
0588 unsigned char:8;
0589 unsigned char autoscsi_maxlun;
0590 bool:1;
0591 bool scam_dominant:1;
0592 bool scam_enabled:1;
0593 bool scam_lev2:1;
0594 unsigned char:4;
0595 bool int13_exten:1;
0596 bool:1;
0597 bool cd_boot:1;
0598 unsigned char:5;
0599 unsigned char boot_id:4;
0600 unsigned char boot_ch:4;
0601 unsigned char force_scan_order:1;
0602 unsigned char:7;
0603 unsigned short nontagged_to_alt_ok;
0604 unsigned short reneg_sync_on_check;
0605 unsigned char rsvd[10];
0606 unsigned char manuf_diag[2];
0607 unsigned short cksum;
0608 } PACKED;
0609
0610
0611
0612
0613
0614 struct blogic_autoscsi_byte45 {
0615 unsigned char force_scan_order:1;
0616 unsigned char:7;
0617 };
0618
0619
0620
0621
0622
0623 #define BLOGIC_BIOS_DRVMAP 17
0624
0625 struct blogic_bios_drvmap {
0626 unsigned char tgt_idbit3:1;
0627 unsigned char:2;
0628 enum blogic_bios_diskgeometry diskgeom:2;
0629 unsigned char tgt_id:3;
0630 };
0631
0632
0633
0634
0635
0636
0637 enum blogic_setccb_fmt {
0638 BLOGIC_LEGACY_LUN_CCB = 0,
0639 BLOGIC_EXT_LUN_CCB = 1
0640 } PACKED;
0641
0642
0643
0644
0645
0646 enum blogic_action {
0647 BLOGIC_OUTBOX_FREE = 0x00,
0648 BLOGIC_MBOX_START = 0x01,
0649 BLOGIC_MBOX_ABORT = 0x02
0650 } PACKED;
0651
0652
0653
0654
0655
0656
0657
0658
0659 enum blogic_cmplt_code {
0660 BLOGIC_INBOX_FREE = 0x00,
0661 BLOGIC_CMD_COMPLETE_GOOD = 0x01,
0662 BLOGIC_CMD_ABORT_BY_HOST = 0x02,
0663 BLOGIC_CMD_NOTFOUND = 0x03,
0664 BLOGIC_CMD_COMPLETE_ERROR = 0x04,
0665 BLOGIC_INVALID_CCB = 0x05
0666 } PACKED;
0667
0668
0669
0670
0671
0672 enum blogic_ccb_opcode {
0673 BLOGIC_INITIATOR_CCB = 0x00,
0674 BLOGIC_TGT_CCB = 0x01,
0675 BLOGIC_INITIATOR_CCB_SG = 0x02,
0676 BLOGIC_INITIATOR_CCBB_RESIDUAL = 0x03,
0677 BLOGIC_INITIATOR_CCB_SG_RESIDUAL = 0x04,
0678 BLOGIC_BDR = 0x81
0679 } PACKED;
0680
0681
0682
0683
0684
0685
0686 enum blogic_datadir {
0687 BLOGIC_UNCHECKED_TX = 0,
0688 BLOGIC_DATAIN_CHECKED = 1,
0689 BLOGIC_DATAOUT_CHECKED = 2,
0690 BLOGIC_NOTX = 3
0691 };
0692
0693
0694
0695
0696
0697
0698
0699 enum blogic_adapter_status {
0700 BLOGIC_CMD_CMPLT_NORMAL = 0x00,
0701 BLOGIC_LINK_CMD_CMPLT = 0x0A,
0702 BLOGIC_LINK_CMD_CMPLT_FLAG = 0x0B,
0703 BLOGIC_DATA_UNDERRUN = 0x0C,
0704 BLOGIC_SELECT_TIMEOUT = 0x11,
0705 BLOGIC_DATA_OVERRUN = 0x12,
0706 BLOGIC_NOEXPECT_BUSFREE = 0x13,
0707 BLOGIC_INVALID_BUSPHASE = 0x14,
0708 BLOGIC_INVALID_OUTBOX_CODE = 0x15,
0709 BLOGIC_INVALID_CMD_CODE = 0x16,
0710 BLOGIC_LINKCCB_BADLUN = 0x17,
0711 BLOGIC_BAD_CMD_PARAM = 0x1A,
0712 BLOGIC_AUTOREQSENSE_FAIL = 0x1B,
0713 BLOGIC_TAGQUEUE_REJECT = 0x1C,
0714 BLOGIC_BAD_MSG_RCVD = 0x1D,
0715 BLOGIC_HW_FAIL = 0x20,
0716 BLOGIC_NORESPONSE_TO_ATN = 0x21,
0717 BLOGIC_HW_RESET = 0x22,
0718 BLOGIC_RST_FROM_OTHERDEV = 0x23,
0719 BLOGIC_BAD_RECONNECT = 0x24,
0720 BLOGIC_HW_BDR = 0x25,
0721 BLOGIC_ABRT_QUEUE = 0x26,
0722 BLOGIC_ADAPTER_SW_ERROR = 0x27,
0723 BLOGIC_HW_TIMEOUT = 0x30,
0724 BLOGIC_PARITY_ERR = 0x34
0725 } PACKED;
0726
0727
0728
0729
0730
0731
0732 enum blogic_tgt_status {
0733 BLOGIC_OP_GOOD = 0x00,
0734 BLOGIC_CHECKCONDITION = 0x02,
0735 BLOGIC_DEVBUSY = 0x08
0736 } PACKED;
0737
0738
0739
0740
0741
0742 enum blogic_queuetag {
0743 BLOGIC_SIMPLETAG = 0,
0744 BLOGIC_HEADTAG = 1,
0745 BLOGIC_ORDEREDTAG = 2,
0746 BLOGIC_RSVDTAG = 3
0747 };
0748
0749
0750
0751
0752
0753 #define BLOGIC_CDB_MAXLEN 12
0754
0755
0756
0757
0758
0759
0760
0761 struct blogic_sg_seg {
0762 u32 segbytes;
0763 u32 segdata;
0764 };
0765
0766
0767
0768
0769
0770 enum blogic_ccb_status {
0771 BLOGIC_CCB_FREE = 0,
0772 BLOGIC_CCB_ACTIVE = 1,
0773 BLOGIC_CCB_COMPLETE = 2,
0774 BLOGIC_CCB_RESET = 3
0775 } PACKED;
0776
0777
0778
0779
0780
0781
0782
0783
0784
0785
0786
0787
0788
0789
0790
0791
0792
0793
0794
0795
0796
0797 struct blogic_ccb {
0798
0799
0800
0801 enum blogic_ccb_opcode opcode;
0802 unsigned char:3;
0803 enum blogic_datadir datadir:2;
0804 bool tag_enable:1;
0805 enum blogic_queuetag queuetag:2;
0806 unsigned char cdblen;
0807 unsigned char sense_datalen;
0808 u32 datalen;
0809 u32 data;
0810 unsigned char:8;
0811 unsigned char:8;
0812 enum blogic_adapter_status adapter_status;
0813 enum blogic_tgt_status tgt_status;
0814 unsigned char tgt_id;
0815 unsigned char lun:5;
0816 bool legacytag_enable:1;
0817 enum blogic_queuetag legacy_tag:2;
0818 unsigned char cdb[BLOGIC_CDB_MAXLEN];
0819 unsigned char:8;
0820 unsigned char:8;
0821 u32 rsvd_int;
0822 u32 sensedata;
0823
0824
0825
0826 void (*callback) (struct blogic_ccb *);
0827 u32 base_addr;
0828 enum blogic_cmplt_code comp_code;
0829 #ifdef CONFIG_SCSI_FLASHPOINT
0830 unsigned char:8;
0831 u16 os_flags;
0832 unsigned char private[24];
0833 void *rsvd1;
0834 void *rsvd2;
0835 unsigned char private2[16];
0836 #endif
0837
0838
0839
0840 dma_addr_t allocgrp_head;
0841 unsigned int allocgrp_size;
0842 u32 dma_handle;
0843 enum blogic_ccb_status status;
0844 unsigned long serial;
0845 struct scsi_cmnd *command;
0846 struct blogic_adapter *adapter;
0847 struct blogic_ccb *next;
0848 struct blogic_ccb *next_all;
0849 struct blogic_sg_seg sglist[BLOGIC_SG_LIMIT];
0850 };
0851
0852
0853
0854
0855
0856 struct blogic_outbox {
0857 u32 ccb;
0858 u32:24;
0859 enum blogic_action action;
0860 };
0861
0862
0863
0864
0865
0866 struct blogic_inbox {
0867 u32 ccb;
0868 enum blogic_adapter_status adapter_status;
0869 enum blogic_tgt_status tgt_status;
0870 unsigned char:8;
0871 enum blogic_cmplt_code comp_code;
0872 };
0873
0874
0875
0876
0877
0878
0879 struct blogic_drvr_options {
0880 unsigned short tagq_ok;
0881 unsigned short tagq_ok_mask;
0882 unsigned short bus_settle_time;
0883 unsigned short stop_tgt_inquiry;
0884 unsigned char common_qdepth;
0885 unsigned char qdepth[BLOGIC_MAXDEV];
0886 };
0887
0888
0889
0890
0891
0892 struct blogic_tgt_flags {
0893 bool tgt_exists:1;
0894 bool tagq_ok:1;
0895 bool wide_ok:1;
0896 bool tagq_active:1;
0897 bool wide_active:1;
0898 bool cmd_good:1;
0899 bool tgt_info_in:1;
0900 };
0901
0902
0903
0904
0905
0906 #define BLOGIC_SZ_BUCKETS 10
0907
0908 struct blogic_tgt_stats {
0909 unsigned int cmds_tried;
0910 unsigned int cmds_complete;
0911 unsigned int read_cmds;
0912 unsigned int write_cmds;
0913 struct blogic_byte_count bytesread;
0914 struct blogic_byte_count byteswritten;
0915 unsigned int read_sz_buckets[BLOGIC_SZ_BUCKETS];
0916 unsigned int write_sz_buckets[BLOGIC_SZ_BUCKETS];
0917 unsigned short aborts_request;
0918 unsigned short aborts_tried;
0919 unsigned short aborts_done;
0920 unsigned short bdr_request;
0921 unsigned short bdr_tried;
0922 unsigned short bdr_done;
0923 unsigned short adapter_reset_req;
0924 unsigned short adapter_reset_attempt;
0925 unsigned short adapter_reset_done;
0926 };
0927
0928
0929
0930
0931
0932 #define FPOINT_BADCARD_HANDLE 0xFFFFFFFFL
0933
0934
0935
0936
0937
0938
0939
0940 struct fpoint_info {
0941 u32 base_addr;
0942 bool present;
0943 unsigned char irq_ch;
0944 unsigned char scsi_id;
0945 unsigned char scsi_lun;
0946 u16 fw_rev;
0947 u16 sync_ok;
0948 u16 fast_ok;
0949 u16 ultra_ok;
0950 u16 discon_ok;
0951 u16 wide_ok;
0952 bool parity:1;
0953 bool wide:1;
0954 bool softreset:1;
0955 bool ext_trans_enable:1;
0956 bool low_term:1;
0957 bool high_term:1;
0958 bool report_underrun:1;
0959 bool scam_enabled:1;
0960 bool scam_lev2:1;
0961 unsigned char:7;
0962 unsigned char family;
0963 unsigned char bus_type;
0964 unsigned char model[3];
0965 unsigned char relative_cardnum;
0966 unsigned char rsvd[4];
0967 u32 os_rsvd;
0968 unsigned char translation_info[4];
0969 u32 rsvd2[5];
0970 u32 sec_range;
0971 };
0972
0973
0974
0975
0976
0977 struct blogic_adapter {
0978 struct Scsi_Host *scsi_host;
0979 struct pci_dev *pci_device;
0980 enum blogic_adapter_type adapter_type;
0981 enum blogic_adapter_bus_type adapter_bus_type;
0982 unsigned long io_addr;
0983 unsigned long pci_addr;
0984 unsigned short addr_count;
0985 unsigned char host_no;
0986 unsigned char model[9];
0987 unsigned char fw_ver[6];
0988 unsigned char full_model[18];
0989 unsigned char bus;
0990 unsigned char dev;
0991 unsigned char irq_ch;
0992 unsigned char scsi_id;
0993 bool irq_acquired:1;
0994 bool ext_trans_enable:1;
0995 bool parity:1;
0996 bool reset_enabled:1;
0997 bool level_int:1;
0998 bool wide:1;
0999 bool differential:1;
1000 bool scam:1;
1001 bool ultra:1;
1002 bool ext_lun:1;
1003 bool terminfo_valid:1;
1004 bool low_term:1;
1005 bool high_term:1;
1006 bool strict_rr:1;
1007 bool scam_enabled:1;
1008 bool scam_lev2:1;
1009 bool adapter_initd:1;
1010 bool adapter_extreset:1;
1011 bool adapter_intern_err:1;
1012 bool processing_ccbs;
1013 volatile bool adapter_cmd_complete;
1014 unsigned short adapter_sglimit;
1015 unsigned short drvr_sglimit;
1016 unsigned short maxdev;
1017 unsigned short maxlun;
1018 unsigned short mbox_count;
1019 unsigned short initccbs;
1020 unsigned short inc_ccbs;
1021 unsigned short alloc_ccbs;
1022 unsigned short drvr_qdepth;
1023 unsigned short adapter_qdepth;
1024 unsigned short untag_qdepth;
1025 unsigned short common_qdepth;
1026 unsigned short bus_settle_time;
1027 unsigned short sync_ok;
1028 unsigned short fast_ok;
1029 unsigned short ultra_ok;
1030 unsigned short wide_ok;
1031 unsigned short discon_ok;
1032 unsigned short tagq_ok;
1033 unsigned short ext_resets;
1034 unsigned short adapter_intern_errors;
1035 unsigned short tgt_count;
1036 unsigned short msgbuflen;
1037 u32 bios_addr;
1038 struct blogic_drvr_options *drvr_opts;
1039 struct fpoint_info fpinfo;
1040 void *cardhandle;
1041 struct list_head host_list;
1042 struct blogic_ccb *all_ccbs;
1043 struct blogic_ccb *free_ccbs;
1044 struct blogic_ccb *firstccb;
1045 struct blogic_ccb *lastccb;
1046 struct blogic_ccb *bdr_pend[BLOGIC_MAXDEV];
1047 struct blogic_tgt_flags tgt_flags[BLOGIC_MAXDEV];
1048 unsigned char qdepth[BLOGIC_MAXDEV];
1049 unsigned char sync_period[BLOGIC_MAXDEV];
1050 unsigned char sync_offset[BLOGIC_MAXDEV];
1051 unsigned char active_cmds[BLOGIC_MAXDEV];
1052 unsigned int cmds_since_rst[BLOGIC_MAXDEV];
1053 unsigned long last_seqpoint[BLOGIC_MAXDEV];
1054 unsigned long last_resettried[BLOGIC_MAXDEV];
1055 unsigned long last_resetdone[BLOGIC_MAXDEV];
1056 struct blogic_outbox *first_outbox;
1057 struct blogic_outbox *last_outbox;
1058 struct blogic_outbox *next_outbox;
1059 struct blogic_inbox *first_inbox;
1060 struct blogic_inbox *last_inbox;
1061 struct blogic_inbox *next_inbox;
1062 struct blogic_tgt_stats tgt_stats[BLOGIC_MAXDEV];
1063 unsigned char *mbox_space;
1064 dma_addr_t mbox_space_handle;
1065 unsigned int mbox_sz;
1066 unsigned long ccb_offset;
1067 char msgbuf[BLOGIC_MSGBUF_SIZE];
1068 };
1069
1070
1071
1072
1073
1074 struct bios_diskparam {
1075 int heads;
1076 int sectors;
1077 int cylinders;
1078 };
1079
1080
1081
1082
1083
1084 struct scsi_inquiry {
1085 unsigned char devtype:5;
1086 unsigned char dev_qual:3;
1087 unsigned char dev_modifier:7;
1088 bool rmb:1;
1089 unsigned char ansi_ver:3;
1090 unsigned char ecma_ver:3;
1091 unsigned char iso_ver:2;
1092 unsigned char resp_fmt:4;
1093 unsigned char:2;
1094 bool TrmIOP:1;
1095 bool AENC:1;
1096 unsigned char addl_len;
1097 unsigned char:8;
1098 unsigned char:8;
1099 bool SftRe:1;
1100 bool CmdQue:1;
1101 bool:1;
1102 bool linked:1;
1103 bool sync:1;
1104 bool WBus16:1;
1105 bool WBus32:1;
1106 bool RelAdr:1;
1107 unsigned char vendor[8];
1108 unsigned char product[16];
1109 unsigned char product_rev[4];
1110 };
1111
1112
1113
1114
1115
1116
1117
1118 static inline void blogic_busreset(struct blogic_adapter *adapter)
1119 {
1120 union blogic_cntrl_reg cr;
1121 cr.all = 0;
1122 cr.cr.bus_reset = true;
1123 outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
1124 }
1125
1126 static inline void blogic_intreset(struct blogic_adapter *adapter)
1127 {
1128 union blogic_cntrl_reg cr;
1129 cr.all = 0;
1130 cr.cr.int_reset = true;
1131 outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
1132 }
1133
1134 static inline void blogic_softreset(struct blogic_adapter *adapter)
1135 {
1136 union blogic_cntrl_reg cr;
1137 cr.all = 0;
1138 cr.cr.soft_reset = true;
1139 outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
1140 }
1141
1142 static inline void blogic_hardreset(struct blogic_adapter *adapter)
1143 {
1144 union blogic_cntrl_reg cr;
1145 cr.all = 0;
1146 cr.cr.hard_reset = true;
1147 outb(cr.all, adapter->io_addr + BLOGIC_CNTRL_REG);
1148 }
1149
1150 static inline unsigned char blogic_rdstatus(struct blogic_adapter *adapter)
1151 {
1152 return inb(adapter->io_addr + BLOGIC_STATUS_REG);
1153 }
1154
1155 static inline void blogic_setcmdparam(struct blogic_adapter *adapter,
1156 unsigned char value)
1157 {
1158 outb(value, adapter->io_addr + BLOGIC_CMD_PARM_REG);
1159 }
1160
1161 static inline unsigned char blogic_rddatain(struct blogic_adapter *adapter)
1162 {
1163 return inb(adapter->io_addr + BLOGIC_DATAIN_REG);
1164 }
1165
1166 static inline unsigned char blogic_rdint(struct blogic_adapter *adapter)
1167 {
1168 return inb(adapter->io_addr + BLOGIC_INT_REG);
1169 }
1170
1171 static inline unsigned char blogic_rdgeom(struct blogic_adapter *adapter)
1172 {
1173 return inb(adapter->io_addr + BLOGIC_GEOMETRY_REG);
1174 }
1175
1176
1177
1178
1179
1180
1181
1182 static inline void blogic_execmbox(struct blogic_adapter *adapter)
1183 {
1184 blogic_setcmdparam(adapter, BLOGIC_EXEC_MBOX_CMD);
1185 }
1186
1187
1188
1189
1190
1191 static inline void blogic_delay(int seconds)
1192 {
1193 mdelay(1000 * seconds);
1194 }
1195
1196
1197
1198
1199
1200
1201
1202 static inline u32 virt_to_32bit_virt(void *virt_addr)
1203 {
1204 return (u32) (unsigned long) virt_addr;
1205 }
1206
1207
1208
1209
1210
1211
1212 static inline void blogic_inc_count(unsigned short *count)
1213 {
1214 if (*count < 65535)
1215 (*count)++;
1216 }
1217
1218
1219
1220
1221
1222 static inline void blogic_addcount(struct blogic_byte_count *bytecount,
1223 unsigned int amount)
1224 {
1225 bytecount->units += amount;
1226 if (bytecount->units > 999999999) {
1227 bytecount->units -= 1000000000;
1228 bytecount->billions++;
1229 }
1230 }
1231
1232
1233
1234
1235
1236 static inline void blogic_incszbucket(unsigned int *cmdsz_buckets,
1237 unsigned int amount)
1238 {
1239 int index = 0;
1240 if (amount < 8 * 1024) {
1241 if (amount < 2 * 1024)
1242 index = (amount < 1 * 1024 ? 0 : 1);
1243 else
1244 index = (amount < 4 * 1024 ? 2 : 3);
1245 } else if (amount < 128 * 1024) {
1246 if (amount < 32 * 1024)
1247 index = (amount < 16 * 1024 ? 4 : 5);
1248 else
1249 index = (amount < 64 * 1024 ? 6 : 7);
1250 } else
1251 index = (amount < 256 * 1024 ? 8 : 9);
1252 cmdsz_buckets[index]++;
1253 }
1254
1255
1256
1257
1258
1259 #define FLASHPOINT_FW_VER "5.02"
1260
1261
1262
1263
1264
1265 #define FPOINT_NORMAL_INT 0x00
1266 #define FPOINT_INTERN_ERR 0xFE
1267 #define FPOINT_EXT_RESET 0xFF
1268
1269
1270
1271
1272
1273
1274 static const char *blogic_drvr_info(struct Scsi_Host *);
1275 static int blogic_qcmd(struct Scsi_Host *h, struct scsi_cmnd *);
1276 static int blogic_diskparam(struct scsi_device *, struct block_device *, sector_t, int *);
1277 static int blogic_slaveconfig(struct scsi_device *);
1278 static void blogic_qcompleted_ccb(struct blogic_ccb *);
1279 static irqreturn_t blogic_inthandler(int, void *);
1280 static int blogic_resetadapter(struct blogic_adapter *, bool hard_reset);
1281 static void blogic_msg(enum blogic_msglevel, char *, struct blogic_adapter *, ...);
1282 static int __init blogic_setup(char *);
1283
1284 #endif