49 #include "aic79xx_reg.h"
63 #define ALL_CHANNELS '\0'
64 #define ALL_TARGETS_MASK 0xFFFF
65 #define INITIATOR_WILDCARD (~0)
66 #define SCB_LIST_NULL 0xFF00
67 #define SCB_LIST_NULL_LE (ahd_htole16(SCB_LIST_NULL))
68 #define QOUTFIFO_ENTRY_VALID 0x80
69 #define SCBID_IS_NULL(scbid) (((scbid) & 0xFF00 ) == SCB_LIST_NULL)
71 #define SCSIID_TARGET(ahd, scsiid) \
72 (((scsiid) & TID) >> TID_SHIFT)
73 #define SCSIID_OUR_ID(scsiid) \
75 #define SCSIID_CHANNEL(ahd, scsiid) ('A')
76 #define SCB_IS_SCSIBUS_B(ahd, scb) (0)
77 #define SCB_GET_OUR_ID(scb) \
78 SCSIID_OUR_ID((scb)->hscb->scsiid)
79 #define SCB_GET_TARGET(ahd, scb) \
80 SCSIID_TARGET((ahd), (scb)->hscb->scsiid)
81 #define SCB_GET_CHANNEL(ahd, scb) \
82 SCSIID_CHANNEL(ahd, (scb)->hscb->scsiid)
83 #define SCB_GET_LUN(scb) \
85 #define SCB_GET_TARGET_OFFSET(ahd, scb) \
86 SCB_GET_TARGET(ahd, scb)
87 #define SCB_GET_TARGET_MASK(ahd, scb) \
88 (0x01 << (SCB_GET_TARGET_OFFSET(ahd, scb)))
90 #define SCB_IS_SILENT(scb) \
91 ((ahd_debug & AHD_SHOW_MASKED_ERRORS) == 0 \
92 && (((scb)->flags & SCB_SILENT) != 0))
94 #define SCB_IS_SILENT(scb) \
95 (((scb)->flags & SCB_SILENT) != 0)
100 #define TCL_TARGET_OFFSET(tcl) \
101 ((((tcl) >> 4) & TID) >> 4)
102 #define TCL_LUN(tcl) \
103 (tcl & (AHD_NUM_LUNS - 1))
104 #define BUILD_TCL(scsiid, lun) \
105 ((lun) | (((scsiid) & TID) << 4))
106 #define BUILD_TCL_RAW(target, channel, lun) \
107 ((lun) | ((target) << 8))
109 #define SCB_GET_TAG(scb) \
110 ahd_le16toh(scb->hscb->tag)
112 #ifndef AHD_TARGET_MODE
113 #undef AHD_TMODE_ENABLE
114 #define AHD_TMODE_ENABLE 0
117 #define AHD_BUILD_COL_IDX(target, lun) \
118 (((lun) << 4) | target)
120 #define AHD_GET_SCB_COL_IDX(ahd, scb) \
121 ((SCB_GET_LUN(scb) << 4) | SCB_GET_TARGET(ahd, scb))
123 #define AHD_SET_SCB_COL_IDX(scb, col_idx) \
125 (scb)->hscb->scsiid = ((col_idx) << TID_SHIFT) & TID; \
126 (scb)->hscb->lun = ((col_idx) >> 4) & (AHD_NUM_LUNS_NONPKT-1); \
129 #define AHD_COPY_SCB_COL_IDX(dst, src) \
131 dst->hscb->scsiid = src->hscb->scsiid; \
132 dst->hscb->lun = src->hscb->lun; \
135 #define AHD_NEVER_COL_IDX 0xFFFF
141 #define AHD_NUM_TARGETS 16
149 #define AHD_NUM_LUNS_NONPKT 64
150 #define AHD_NUM_LUNS 256
155 #define AHD_MAXTRANSFER_SIZE 0x00ffffff
162 #define AHD_SCB_MAX 512
168 #define AHD_MAX_QUEUE AHD_SCB_MAX
174 #define AHD_QIN_SIZE AHD_MAX_QUEUE
175 #define AHD_QOUT_SIZE AHD_MAX_QUEUE
177 #define AHD_QIN_WRAP(x) ((x) & (AHD_QIN_SIZE-1))
181 #define AHD_SCB_MAX_ALLOC AHD_MAX_QUEUE
188 #define AHD_TMODE_CMDS 256
191 #define AHD_BUSRESET_DELAY 25
418 #define MAX_CDB_LEN 16
419 #define MAX_CDB_LEN_WITH_SENSE_ADDR (MAX_CDB_LEN - sizeof(sense_addr_t))
489 #define SG_PTR_MASK 0xFFFFFFF8
529 #define AHD_DMA_LAST_SEG 0x80000000
530 #define AHD_SG_HIGH_ADDR_MASK 0x7F000000
531 #define AHD_SG_LEN_MASK 0x00FFFFFF
604 #define pending_links links2.le
605 #define collision_links links2.le
622 #define AHD_MAX_LQ_CRC_ERRORS 5
634 struct scb_tailq free_scbs;
645 struct scb_list any_dev_free_scb_list;
703 #define AHD_TMODE_EVENT_BUFFER_SIZE 8
707 #define EVENT_TYPE_BUS_RESET 0xFF
718 #ifdef AHD_TARGET_MODE
719 struct ahd_tmode_lstate {
720 struct cam_path *
path;
721 struct ccb_hdr_slist accept_tios;
722 struct ccb_hdr_slist immed_notifies;
728 struct ahd_tmode_lstate;
732 #define AHD_TRANS_CUR 0x01
733 #define AHD_TRANS_ACTIVE 0x03
734 #define AHD_TRANS_GOAL 0x04
735 #define AHD_TRANS_USER 0x08
736 #define AHD_PERIOD_10MHz 0x19
738 #define AHD_WIDTH_UNKNOWN 0xFF
739 #define AHD_PERIOD_UNKNOWN 0xFF
740 #define AHD_OFFSET_UNKNOWN 0xFF
741 #define AHD_PPR_OPTS_UNKNOWN 0xFF
785 #define AHD_SYNCRATE_160 0x8
786 #define AHD_SYNCRATE_PACED 0x8
787 #define AHD_SYNCRATE_DT 0x9
788 #define AHD_SYNCRATE_ULTRA2 0xa
789 #define AHD_SYNCRATE_ULTRA 0xc
790 #define AHD_SYNCRATE_FAST 0x19
791 #define AHD_SYNCRATE_MIN_DT AHD_SYNCRATE_FAST
792 #define AHD_SYNCRATE_SYNC 0x32
793 #define AHD_SYNCRATE_MIN 0x60
794 #define AHD_SYNCRATE_ASYNC 0xFF
795 #define AHD_SYNCRATE_MAX AHD_SYNCRATE_160
798 #define AHD_ASYNC_XFER_PERIOD 0x44
807 #define AHD_SYNCRATE_REVA_120 0x8
808 #define AHD_SYNCRATE_REVA_160 0x7
828 #define CFXFER 0x003F
829 #define CFXFER_ASYNC 0x3F
831 #define CFPACKETIZED 0x0080
832 #define CFSTART 0x0100
833 #define CFINCBIOS 0x0200
834 #define CFDISC 0x0400
835 #define CFMULTILUNDEV 0x0800
836 #define CFWIDEB 0x1000
837 #define CFHOSTMANAGED 0x8000
843 #define CFSUPREM 0x0001
844 #define CFSUPREMB 0x0002
845 #define CFBIOSSTATE 0x000C
846 #define CFBS_DISABLED 0x00
847 #define CFBS_ENABLED 0x04
848 #define CFBS_DISABLED_SCAN 0x08
849 #define CFENABLEDV 0x0010
850 #define CFCTRL_A 0x0020
851 #define CFSPARITY 0x0040
852 #define CFEXTEND 0x0080
853 #define CFBOOTCD 0x0100
854 #define CFMSG_LEVEL 0x0600
855 #define CFMSG_VERBOSE 0x0000
856 #define CFMSG_SILENT 0x0200
857 #define CFMSG_DIAG 0x0400
858 #define CFRESETB 0x0800
865 #define CFAUTOTERM 0x0001
866 #define CFSTERM 0x0002
867 #define CFWSTERM 0x0004
868 #define CFSEAUTOTERM 0x0008
869 #define CFSELOWTERM 0x0010
870 #define CFSEHIGHTERM 0x0020
871 #define CFSTPWLEVEL 0x0040
872 #define CFBIOSAUTOTERM 0x0080
873 #define CFTERM_MENU 0x0100
874 #define CFCLUSTERENB 0x8000
880 #define CFSCSIID 0x000f
882 #define CFBRTIME 0xff00
888 #define CFMAXTARG 0x00ff
889 #define CFBOOTLUN 0x0f00
890 #define CFBOOTID 0xf000
893 #define CFSIGNATURE 0x400
902 #define VPDMASTERBIOS 0x0001
903 #define VPDBOOTHOST 0x0002
932 #define FLXADDR_TERMCTL 0x0
933 #define FLX_TERMCTL_ENSECHIGH 0x8
934 #define FLX_TERMCTL_ENSECLOW 0x4
935 #define FLX_TERMCTL_ENPRIHIGH 0x2
936 #define FLX_TERMCTL_ENPRILOW 0x1
937 #define FLXADDR_ROMSTAT_CURSENSECTL 0x1
938 #define FLX_ROMSTAT_SEECFG 0xF0
939 #define FLX_ROMSTAT_EECFG 0x0F
940 #define FLX_ROMSTAT_SEE_93C66 0x00
941 #define FLX_ROMSTAT_SEE_NONE 0xF0
942 #define FLX_ROMSTAT_EE_512x8 0x0
943 #define FLX_ROMSTAT_EE_1MBx8 0x1
944 #define FLX_ROMSTAT_EE_2MBx8 0x2
945 #define FLX_ROMSTAT_EE_4MBx8 0x3
946 #define FLX_ROMSTAT_EE_16MBx8 0x4
947 #define CURSENSE_ENB 0x1
948 #define FLXADDR_FLEXSTAT 0x2
949 #define FLX_FSTAT_BUSY 0x1
950 #define FLXADDR_CURRENT_STAT 0x4
951 #define FLX_CSTAT_SEC_HIGH 0xC0
952 #define FLX_CSTAT_SEC_LOW 0x30
953 #define FLX_CSTAT_PRI_HIGH 0x0C
954 #define FLX_CSTAT_PRI_LOW 0x03
955 #define FLX_CSTAT_MASK 0x03
956 #define FLX_CSTAT_SHIFT 2
957 #define FLX_CSTAT_OKAY 0x0
958 #define FLX_CSTAT_OVER 0x1
959 #define FLX_CSTAT_UNDER 0x2
960 #define FLX_CSTAT_INVALID 0x3
1038 #define AHD_MK_MSK(x) (0x01 << (x))
1039 #define AHD_MODE_DFF0_MSK AHD_MK_MSK(AHD_MODE_DFF0)
1040 #define AHD_MODE_DFF1_MSK AHD_MK_MSK(AHD_MODE_DFF1)
1041 #define AHD_MODE_CCHAN_MSK AHD_MK_MSK(AHD_MODE_CCHAN)
1042 #define AHD_MODE_SCSI_MSK AHD_MK_MSK(AHD_MODE_SCSI)
1043 #define AHD_MODE_CFG_MSK AHD_MK_MSK(AHD_MODE_CFG)
1044 #define AHD_MODE_UNKNOWN_MSK AHD_MK_MSK(AHD_MODE_UNKNOWN)
1045 #define AHD_MODE_ANY_MSK (~0)
1131 #define AHD_STAT_UPDATE_US 250000
1132 #define AHD_STAT_BUCKETS 4
1242 #define AHD_INT_COALESCING_TIMER_DEFAULT 250
1243 #define AHD_INT_COALESCING_MAXCMDS_DEFAULT 10
1244 #define AHD_INT_COALESCING_MAXCMDS_MAX 127
1245 #define AHD_INT_COALESCING_MINCMDS_DEFAULT 5
1246 #define AHD_INT_COALESCING_MINCMDS_MAX 127
1247 #define AHD_INT_COALESCING_THRESHOLD_DEFAULT 2000
1248 #define AHD_INT_COALESCING_STOP_THRESHOLD_DEFAULT 1000
1260 #define AHD_PRECOMP_SLEW_INDEX \
1261 (AHD_ANNEXCOL_PRECOMP_SLEW - AHD_ANNEXCOL_PER_DEV0)
1263 #define AHD_AMPLITUDE_INDEX \
1264 (AHD_ANNEXCOL_AMPLITUDE - AHD_ANNEXCOL_PER_DEV0)
1266 #define AHD_SET_SLEWRATE(ahd, new_slew) \
1268 (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] &= ~AHD_SLEWRATE_MASK; \
1269 (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] |= \
1270 (((new_slew) << AHD_SLEWRATE_SHIFT) & AHD_SLEWRATE_MASK); \
1273 #define AHD_SET_PRECOMP(ahd, new_pcomp) \
1275 (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] &= ~AHD_PRECOMP_MASK; \
1276 (ahd)->iocell_opts[AHD_PRECOMP_SLEW_INDEX] |= \
1277 (((new_pcomp) << AHD_PRECOMP_SHIFT) & AHD_PRECOMP_MASK); \
1280 #define AHD_SET_AMPLITUDE(ahd, new_amp) \
1282 (ahd)->iocell_opts[AHD_AMPLITUDE_INDEX] &= ~AHD_AMPLITUDE_MASK; \
1283 (ahd)->iocell_opts[AHD_AMPLITUDE_INDEX] |= \
1284 (((new_amp) << AHD_AMPLITUDE_SHIFT) & AHD_AMPLITUDE_MASK); \
1308 #define AHD_PCI_IOADDR0 PCIR_BAR(0)
1309 #define AHD_PCI_MEMADDR PCIR_BAR(1)
1310 #define AHD_PCI_IOADDR1 PCIR_BAR(3)
1331 #define AHD_EISA_SLOT_OFFSET 0xc00
1332 #define AHD_EISA_IOSIZE 0x100
1343 void ahd_pci_suspend(
struct ahd_softc *);
1344 void ahd_pci_resume(
struct ahd_softc *);
1391 int stop_on_first,
int remove,
1394 int initiate_reset);
1432 #ifdef AHD_TARGET_MODE
1433 void ahd_send_lstate_events(
struct ahd_softc *,
1434 struct ahd_tmode_lstate *);
1435 void ahd_handle_en_lun(
struct ahd_softc *ahd,
1436 struct cam_sim *sim,
union ccb *
ccb);
1438 struct cam_sim *sim,
union ccb *
ccb,
1440 struct ahd_tmode_lstate **lstate,
1441 int notfound_failure);
1442 #ifndef AHD_TMODE_ENABLE
1443 #define AHD_TMODE_ENABLE 0
1449 #define AHD_SHOW_MISC 0x00001
1450 #define AHD_SHOW_SENSE 0x00002
1451 #define AHD_SHOW_RECOVERY 0x00004
1452 #define AHD_DUMP_SEEPROM 0x00008
1453 #define AHD_SHOW_TERMCTL 0x00010
1454 #define AHD_SHOW_MEMORY 0x00020
1455 #define AHD_SHOW_MESSAGES 0x00040
1456 #define AHD_SHOW_MODEPTR 0x00080
1457 #define AHD_SHOW_SELTO 0x00100
1458 #define AHD_SHOW_FIFOS 0x00200
1459 #define AHD_SHOW_QFULL 0x00400
1460 #define AHD_SHOW_DV 0x00800
1461 #define AHD_SHOW_MASKED_ERRORS 0x01000
1462 #define AHD_SHOW_QUEUE 0x02000
1463 #define AHD_SHOW_TQIN 0x04000
1464 #define AHD_SHOW_SG 0x08000
1465 #define AHD_SHOW_INT_COALESCING 0x10000
1466 #define AHD_DEBUG_SEQUENCER 0x20000