61 #define SYM_OPT_HANDLE_DEVICE_QUEUEING
62 #define SYM_OPT_LIMIT_COMMAND_REORDERING
70 #define DEBUG_ALLOC (0x0001)
71 #define DEBUG_PHASE (0x0002)
72 #define DEBUG_POLL (0x0004)
73 #define DEBUG_QUEUE (0x0008)
74 #define DEBUG_RESULT (0x0010)
75 #define DEBUG_SCATTER (0x0020)
76 #define DEBUG_SCRIPT (0x0040)
77 #define DEBUG_TINY (0x0080)
78 #define DEBUG_TIMING (0x0100)
79 #define DEBUG_NEGO (0x0200)
80 #define DEBUG_TAGS (0x0400)
81 #define DEBUG_POINTER (0x0800)
84 #define DEBUG_FLAGS (0x0000)
88 #define sym_verbose (np->verbose)
95 #define assert(expression) { \
96 if (!(expression)) { \
98 "assertion \"%s\" failed: file \"%s\", line %d\n", \
100 __FILE__, __LINE__); \
108 #if SYM_CONF_MAX_TAG_ORDER > 8
109 #error "more than 256 tags per logical unit not allowed."
111 #define SYM_CONF_MAX_TASK (1<<SYM_CONF_MAX_TAG_ORDER)
116 #ifndef SYM_CONF_MAX_TAG
117 #define SYM_CONF_MAX_TAG SYM_CONF_MAX_TASK
119 #if SYM_CONF_MAX_TAG > SYM_CONF_MAX_TASK
120 #undef SYM_CONF_MAX_TAG
121 #define SYM_CONF_MAX_TAG SYM_CONF_MAX_TASK
132 #if SYM_CONF_MAX_TARGET > 16
133 #error "more than 16 targets not allowed."
139 #if SYM_CONF_MAX_LUN > 64
140 #error "more than 64 logical units per target not allowed."
147 #define SYM_CONF_MIN_ASYNC (40)
154 #define SYM_MEM_WARN 1
156 #define SYM_MEM_PAGE_ORDER 0
157 #define SYM_MEM_CLUSTER_SHIFT (PAGE_SHIFT+SYM_MEM_PAGE_ORDER)
158 #define SYM_MEM_FREE_UNUSED
164 #define SYM_MEM_SHIFT 4
165 #define SYM_MEM_CLUSTER_SIZE (1UL << SYM_MEM_CLUSTER_SHIFT)
166 #define SYM_MEM_CLUSTER_MASK (SYM_MEM_CLUSTER_SIZE-1)
174 #ifdef SYM_CONF_MAX_START
175 #define SYM_CONF_MAX_QUEUE (SYM_CONF_MAX_START+2)
177 #define SYM_CONF_MAX_QUEUE (7*SYM_CONF_MAX_TASK+2)
178 #define SYM_CONF_MAX_START (SYM_CONF_MAX_QUEUE-2)
181 #if SYM_CONF_MAX_QUEUE > SYM_MEM_CLUSTER_SIZE/8
182 #undef SYM_CONF_MAX_QUEUE
183 #define SYM_CONF_MAX_QUEUE (SYM_MEM_CLUSTER_SIZE/8)
184 #undef SYM_CONF_MAX_START
185 #define SYM_CONF_MAX_START (SYM_CONF_MAX_QUEUE-2)
191 #define MAX_QUEUE SYM_CONF_MAX_QUEUE
197 #define INB_OFF(np, o) ioread8(np->s.ioaddr + (o))
198 #define INW_OFF(np, o) ioread16(np->s.ioaddr + (o))
199 #define INL_OFF(np, o) ioread32(np->s.ioaddr + (o))
201 #define OUTB_OFF(np, o, val) iowrite8((val), np->s.ioaddr + (o))
202 #define OUTW_OFF(np, o, val) iowrite16((val), np->s.ioaddr + (o))
203 #define OUTL_OFF(np, o, val) iowrite32((val), np->s.ioaddr + (o))
205 #define INB(np, r) INB_OFF(np, offsetof(struct sym_reg, r))
206 #define INW(np, r) INW_OFF(np, offsetof(struct sym_reg, r))
207 #define INL(np, r) INL_OFF(np, offsetof(struct sym_reg, r))
209 #define OUTB(np, r, v) OUTB_OFF(np, offsetof(struct sym_reg, r), (v))
210 #define OUTW(np, r, v) OUTW_OFF(np, offsetof(struct sym_reg, r), (v))
211 #define OUTL(np, r, v) OUTL_OFF(np, offsetof(struct sym_reg, r), (v))
213 #define OUTONB(np, r, m) OUTB(np, r, INB(np, r) | (m))
214 #define OUTOFFB(np, r, m) OUTB(np, r, INB(np, r) & ~(m))
215 #define OUTONW(np, r, m) OUTW(np, r, INW(np, r) | (m))
216 #define OUTOFFW(np, r, m) OUTW(np, r, INW(np, r) & ~(m))
217 #define OUTONL(np, r, m) OUTL(np, r, INL(np, r) | (m))
218 #define OUTOFFL(np, r, m) OUTL(np, r, INL(np, r) & ~(m))
225 #define OUTL_DSP(np, v) \
227 MEMORY_WRITE_BARRIER(); \
228 OUTL(np, nc_dsp, (v)); \
231 #define OUTONB_STD() \
233 MEMORY_WRITE_BARRIER(); \
234 OUTONB(np, nc_dcntl, (STD|NOCOM)); \
242 #define HS_NEGOTIATE (2)
243 #define HS_DISCONNECT (3)
246 #define HS_DONEMASK (0x80)
247 #define HS_COMPLETE (4|HS_DONEMASK)
248 #define HS_SEL_TIMEOUT (5|HS_DONEMASK)
249 #define HS_UNEXPECTED (6|HS_DONEMASK)
250 #define HS_COMP_ERR (7|HS_DONEMASK)
255 #define SIR_BAD_SCSI_STATUS (1)
256 #define SIR_SEL_ATN_NO_MSG_OUT (2)
257 #define SIR_MSG_RECEIVED (3)
258 #define SIR_MSG_WEIRD (4)
259 #define SIR_NEGO_FAILED (5)
260 #define SIR_NEGO_PROTO (6)
261 #define SIR_SCRIPT_STOPPED (7)
262 #define SIR_REJECT_TO_SEND (8)
263 #define SIR_SWIDE_OVERRUN (9)
264 #define SIR_SODL_UNDERRUN (10)
265 #define SIR_RESEL_NO_MSG_IN (11)
266 #define SIR_RESEL_NO_IDENTIFY (12)
267 #define SIR_RESEL_BAD_LUN (13)
268 #define SIR_TARGET_SELECTED (14)
269 #define SIR_RESEL_BAD_I_T_L (15)
270 #define SIR_RESEL_BAD_I_T_L_Q (16)
271 #define SIR_ABORT_SENT (17)
272 #define SIR_RESEL_ABORTED (18)
273 #define SIR_MSG_OUT_DONE (19)
274 #define SIR_COMPLETE_ERROR (20)
275 #define SIR_DATA_OVERRUN (21)
276 #define SIR_BAD_PHASE (22)
277 #if SYM_CONF_DMA_ADDRESSING_MODE == 2
278 #define SIR_DMAP_DIRTY (23)
288 #define XE_EXTRA_DATA (1)
289 #define XE_BAD_PHASE (1<<1)
290 #define XE_PARITY_ERR (1<<2)
291 #define XE_SODL_UNRUN (1<<3)
292 #define XE_SWIDE_OVRUN (1<<4)
306 #define CCB_HASH_SHIFT 8
307 #define CCB_HASH_SIZE (1UL << CCB_HASH_SHIFT)
308 #define CCB_HASH_MASK (CCB_HASH_SIZE-1)
310 #define CCB_HASH_CODE(dsa) \
311 (((dsa) >> (_LGRU16_(sizeof(struct sym_ccb)))) & CCB_HASH_MASK)
313 #define CCB_HASH_CODE(dsa) (((dsa) >> 9) & CCB_HASH_MASK)
316 #if SYM_CONF_DMA_ADDRESSING_MODE == 2
321 #define SYM_DMAP_SHIFT (4)
322 #define SYM_DMAP_SIZE (1u<<SYM_DMAP_SHIFT)
323 #define SYM_DMAP_MASK (SYM_DMAP_SIZE-1)
329 #define SYM_DISC_ENABLED (1)
330 #define SYM_TAGS_ENABLED (1<<1)
331 #define SYM_SCAN_BOOT_DISABLED (1<<2)
332 #define SYM_SCAN_LUNS_DISABLED (1<<3)
337 #define SYM_AVOID_BUS_RESET (1)
342 #define SYM_SNOOP_TIMEOUT (10000000)
410 #if SYM_CONF_MAX_LUN > 1
516 #ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
530 #ifdef SYM_OPT_LIMIT_COMMAND_REORDERING
580 #if SYM_CONF_MAX_LUN <= 1
581 #define sym_lp(tp, lun) (!lun) ? (tp)->lun0p : NULL
583 #define sym_lp(tp, lun) \
584 (!lun) ? (tp)->lun0p : (tp)->lunmp ? (tp)->lunmp[(lun)] : NULL
600 #define HX_PRT nc_scr0
602 #define HS_PRT nc_scr1
604 #define SS_PRT nc_scr2
606 #define HF_PRT nc_scr3
611 #define host_xflags phys.head.status[0]
612 #define host_status phys.head.status[1]
613 #define ssss_status phys.head.status[2]
614 #define host_flags phys.head.status[3]
620 #define HF_IN_PM1 (1u<<1)
621 #define HF_ACT_PM (1u<<2)
622 #define HF_DP_SAVED (1u<<3)
623 #define HF_SENSE (1u<<4)
624 #define HF_EXT_ERR (1u<<5)
625 #define HF_DATA_IN (1u<<6)
626 #ifdef SYM_CONF_IARB_SUPPORT
627 #define HF_HINT_IARB (1u<<7)
633 #if SYM_CONF_DMA_ADDRESSING_MODE == 2
634 #define HX_DMAP_DIRTY (1u<<7)
676 #if SYM_CONF_GENERIC_SUPPORT
677 #define sym_set_script_dp(np, cp, dp) \
679 if (np->features & FE_LDSTR) \
680 cp->phys.head.lastp = cpu_to_scr(dp); \
682 np->ccb_head.lastp = cpu_to_scr(dp); \
684 #define sym_get_script_dp(np, cp) \
685 scr_to_cpu((np->features & FE_LDSTR) ? \
686 cp->phys.head.lastp : np->ccb_head.lastp)
688 #define sym_set_script_dp(np, cp, dp) \
690 cp->phys.head.lastp = cpu_to_scr(dp); \
693 #define sym_get_script_dp(np, cp) (cp->phys.head.lastp)
747 #define SYM_SNS_BBUF_LEN 32
793 #ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
798 #ifdef SYM_OPT_LIMIT_COMMAND_REORDERING
803 #define CCB_BA(cp,lbl) cpu_to_scr(cp->ccb_ba + offsetof(struct sym_ccb, lbl))
817 #if SYM_CONF_GENERIC_SUPPORT
990 #ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
1006 #ifdef SYM_CONF_IARB_SUPPORT
1025 #if SYM_CONF_DMA_ADDRESSING_MODE != 0
1027 #if SYM_CONF_DMA_ADDRESSING_MODE == 2
1029 u32 dmap_bah[SYM_DMAP_SIZE];
1034 #if SYM_CONF_DMA_ADDRESSING_MODE == 0
1035 #define use_dac(np) 0
1036 #define set_dac(np) do { } while (0)
1038 #define use_dac(np) (np)->use_dac
1039 #define set_dac(np) (np)->use_dac = 1
1042 #define HCB_BA(np, lbl) (np->hcb_ba + offsetof(struct sym_hcb, lbl))
1058 #ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
1059 void sym_start_next_ccbs(
struct sym_hcb *np,
struct sym_lcb *
lp,
int maxn);
1084 #if SYM_CONF_DMA_ADDRESSING_MODE == 0
1085 #define DMA_DAC_MASK DMA_BIT_MASK(32)
1086 #define sym_build_sge(np, data, badd, len) \
1088 (data)->addr = cpu_to_scr(badd); \
1089 (data)->size = cpu_to_scr(len); \
1091 #elif SYM_CONF_DMA_ADDRESSING_MODE == 1
1092 #define DMA_DAC_MASK DMA_BIT_MASK(40)
1093 #define sym_build_sge(np, data, badd, len) \
1095 (data)->addr = cpu_to_scr(badd); \
1096 (data)->size = cpu_to_scr((((badd) >> 8) & 0xff000000) + len); \
1098 #elif SYM_CONF_DMA_ADDRESSING_MODE == 2
1099 #define DMA_DAC_MASK DMA_BIT_MASK(64)
1105 int s = (h&SYM_DMAP_MASK);
1107 if (h != np->dmap_bah[s])
1114 s = sym_lookup_dmap(np, h, s);
1118 #error "Unsupported DMA addressing mode"
1125 #define sym_get_mem_cluster() \
1126 (void *) __get_free_pages(GFP_ATOMIC, SYM_MEM_PAGE_ORDER)
1127 #define sym_free_mem_cluster(p) \
1128 free_pages((unsigned long)p, SYM_MEM_PAGE_ORDER)
1148 #define VTOB_HASH_SHIFT 5
1149 #define VTOB_HASH_SIZE (1UL << VTOB_HASH_SHIFT)
1150 #define VTOB_HASH_MASK (VTOB_HASH_SIZE-1)
1151 #define VTOB_HASH_CODE(m) \
1152 ((((unsigned long)(m)) >> SYM_MEM_CLUSTER_SHIFT) & VTOB_HASH_MASK)
1166 #ifdef SYM_MEM_FREE_UNUSED
1169 #define M_GET_MEM_CLUSTER() mp->get_mem_cluster(mp)
1170 #define M_FREE_MEM_CLUSTER(p) mp->free_mem_cluster(mp, p)
1190 #define _uvptv_(p) ((void *)((u_long)(p)))
1192 #define _sym_calloc_dma(np, l, n) __sym_calloc_dma(np->bus_dmat, l, n)
1193 #define _sym_mfree_dma(np, p, l, n) \
1194 __sym_mfree_dma(np->bus_dmat, _uvptv_(p), l, n)
1195 #define sym_calloc_dma(l, n) _sym_calloc_dma(np, l, n)
1196 #define sym_mfree_dma(p, l, n) _sym_mfree_dma(np, p, l, n)
1197 #define vtobus(p) __vtobus(np->bus_dmat, _uvptv_(p))
1204 #define sym_m_pool_match(mp_id1, mp_id2) (mp_id1 == mp_id2)