* of PCI-SCSI IO processors.
*
* Copyright (C) 1999-2001 Gerard Roudier <groudier@free.fr>
- * Copyright (c) 2003-2004 Matthew Wilcox <matthew@wil.cx>
+ * Copyright (c) 2003-2005 Matthew Wilcox <matthew@wil.cx>
*
* This driver is derived from the Linux sym53c8xx driver.
* Copyright (C) 1998-2000 Gerard Roudier
*/
static void sym_int_ma (struct sym_hcb *np);
static void sym_int_sir (struct sym_hcb *np);
-static ccb_p sym_alloc_ccb(struct sym_hcb *np);
-static ccb_p sym_ccb_from_dsa(struct sym_hcb *np, u32 dsa);
+static struct sym_ccb *sym_alloc_ccb(struct sym_hcb *np);
+static struct sym_ccb *sym_ccb_from_dsa(struct sym_hcb *np, u32 dsa);
static void sym_alloc_lcb_tags (struct sym_hcb *np, u_char tn, u_char ln);
-static void sym_complete_error (struct sym_hcb *np, ccb_p cp);
-static void sym_complete_ok (struct sym_hcb *np, ccb_p cp);
-static int sym_compute_residual(struct sym_hcb *np, ccb_p cp);
+static void sym_complete_error (struct sym_hcb *np, struct sym_ccb *cp);
+static void sym_complete_ok (struct sym_hcb *np, struct sym_ccb *cp);
+static int sym_compute_residual(struct sym_hcb *np, struct sym_ccb *cp);
/*
- * Returns the name of this driver.
+ * Print a buffer in hexadecimal format with a ".\n" at end.
*/
-char *sym_driver_name(void)
-{
- return SYM_DRIVER_NAME;
-}
-/*
- * Print a buffer in hexadecimal format.
- */
-static void sym_printb_hex (u_char *p, int n)
+static void sym_printl_hex(u_char *p, int n)
{
while (n-- > 0)
printf (" %x", *p++);
-}
-
-/*
- * Same with a label at beginning and .\n at end.
- */
-static void sym_printl_hex (char *label, u_char *p, int n)
-{
- printf ("%s", label);
- sym_printb_hex (p, n);
printf (".\n");
}
-/*
- * Print something which allows to retrieve the controler type,
- * unit, target, lun concerned by a kernel message.
- */
-static void sym_print_target (struct sym_hcb *np, int target)
-{
- printf ("%s:%d:", sym_name(np), target);
-}
-
-static void sym_print_lun(struct sym_hcb *np, int target, int lun)
-{
- printf ("%s:%d:%d:", sym_name(np), target, lun);
-}
-
/*
* Print out the content of a SCSI message.
*/
for (i=1;i<8;i++) {
if (i-1>msg[1]) break;
printf ("-%x",msg[i]);
- };
+ }
return (i+1);
} else if ((*msg & 0xf0) == 0x20) {
printf ("-%x",msg[1]);
return (2);
- };
+ }
return (1);
}
-static void sym_print_msg (ccb_p cp, char *label, u_char *msg)
+static void sym_print_msg(struct sym_ccb *cp, char *label, u_char *msg)
{
- PRINT_ADDR(cp);
- if (label)
- printf ("%s: ", label);
+ sym_print_addr(cp->cmd, "%s: ", label);
- (void) sym_show_msg (msg);
- printf (".\n");
+ sym_show_msg(msg);
+ printf(".\n");
}
-static void sym_print_nego_msg (struct sym_hcb *np, int target, char *label, u_char *msg)
+static void sym_print_nego_msg(struct sym_hcb *np, int target, char *label, u_char *msg)
{
- PRINT_TARGET(np, target);
- if (label)
- printf ("%s: ", label);
+ struct sym_tcb *tp = &np->target[target];
+ dev_info(&tp->sdev->sdev_target->dev, "%s: ", label);
- (void) sym_show_msg (msg);
- printf (".\n");
+ sym_show_msg(msg);
+ printf(".\n");
}
/*
* Print something that tells about extended errors.
*/
-void sym_print_xerr(ccb_p cp, int x_status)
+void sym_print_xerr(struct scsi_cmnd *cmd, int x_status)
{
if (x_status & XE_PARITY_ERR) {
- PRINT_ADDR(cp);
- printf ("unrecovered SCSI parity error.\n");
+ sym_print_addr(cmd, "unrecovered SCSI parity error.\n");
}
if (x_status & XE_EXTRA_DATA) {
- PRINT_ADDR(cp);
- printf ("extraneous data discarded.\n");
+ sym_print_addr(cmd, "extraneous data discarded.\n");
}
if (x_status & XE_BAD_PHASE) {
- PRINT_ADDR(cp);
- printf ("illegal scsi phase (4/5).\n");
+ sym_print_addr(cmd, "illegal scsi phase (4/5).\n");
}
if (x_status & XE_SODL_UNRUN) {
- PRINT_ADDR(cp);
- printf ("ODD transfer in DATA OUT phase.\n");
+ sym_print_addr(cmd, "ODD transfer in DATA OUT phase.\n");
}
if (x_status & XE_SWIDE_OVRUN) {
- PRINT_ADDR(cp);
- printf ("ODD transfer in DATA IN phase.\n");
+ sym_print_addr(cmd, "ODD transfer in DATA IN phase.\n");
}
}
*/
static void sym_chip_reset (struct sym_hcb *np)
{
- OUTB (nc_istat, SRST);
- UDELAY (10);
- OUTB (nc_istat, 0);
- UDELAY(2000); /* For BUS MODE to settle */
+ OUTB(np, nc_istat, SRST);
+ udelay(10);
+ OUTB(np, nc_istat, 0);
+ udelay(2000); /* For BUS MODE to settle */
}
/*
u_char istat = 0;
int i;
- if (!(np->features & FE_ISTAT1) || !(INB (nc_istat1) & SCRUN))
+ if (!(np->features & FE_ISTAT1) || !(INB(np, nc_istat1) & SCRUN))
goto do_chip_reset;
- OUTB (nc_istat, CABRT);
+ OUTB(np, nc_istat, CABRT);
for (i = 100000 ; i ; --i) {
- istat = INB (nc_istat);
+ istat = INB(np, nc_istat);
if (istat & SIP) {
- INW (nc_sist);
+ INW(np, nc_sist);
}
else if (istat & DIP) {
- if (INB (nc_dstat) & ABRT)
+ if (INB(np, nc_dstat) & ABRT)
break;
}
- UDELAY(5);
+ udelay(5);
}
- OUTB (nc_istat, 0);
+ OUTB(np, nc_istat, 0);
if (!i)
printf("%s: unable to abort current chip operation, "
"ISTAT=0x%02x.\n", sym_name(np), istat);
do_chip_reset:
- sym_chip_reset (np);
+ sym_chip_reset(np);
}
/*
*/
static void sym_start_reset(struct sym_hcb *np)
{
- (void) sym_reset_scsi_bus(np, 1);
+ sym_reset_scsi_bus(np, 1);
}
int sym_reset_scsi_bus(struct sym_hcb *np, int enab_int)
sym_soft_reset(np); /* Soft reset the chip */
if (enab_int)
- OUTW (nc_sien, RST);
+ OUTW(np, nc_sien, RST);
/*
* Enable Tolerant, reset IRQD if present and
* properly set IRQ mode, prior to resetting the bus.
*/
- OUTB (nc_stest3, TE);
- OUTB (nc_dcntl, (np->rv_dcntl & IRQM));
- OUTB (nc_scntl1, CRST);
- UDELAY (200);
+ OUTB(np, nc_stest3, TE);
+ OUTB(np, nc_dcntl, (np->rv_dcntl & IRQM));
+ OUTB(np, nc_scntl1, CRST);
+ udelay(200);
if (!SYM_SETUP_SCSI_BUS_CHECK)
goto out;
* We are expecting RESET to be TRUE and other signals to be
* FALSE.
*/
- term = INB(nc_sstat0);
+ term = INB(np, nc_sstat0);
term = ((term & 2) << 7) + ((term & 1) << 17); /* rst sdp0 */
- term |= ((INB(nc_sstat2) & 0x01) << 26) | /* sdp1 */
- ((INW(nc_sbdl) & 0xff) << 9) | /* d7-0 */
- ((INW(nc_sbdl) & 0xff00) << 10) | /* d15-8 */
- INB(nc_sbcl); /* req ack bsy sel atn msg cd io */
+ term |= ((INB(np, nc_sstat2) & 0x01) << 26) | /* sdp1 */
+ ((INW(np, nc_sbdl) & 0xff) << 9) | /* d7-0 */
+ ((INW(np, nc_sbdl) & 0xff00) << 10) | /* d15-8 */
+ INB(np, nc_sbcl); /* req ack bsy sel atn msg cd io */
if (!np->maxwide)
term &= 0x3ffff;
retv = 1;
}
out:
- OUTB (nc_scntl1, 0);
+ OUTB(np, nc_scntl1, 0);
return retv;
}
* If multiplier not present or not selected, leave here.
*/
if (np->multiplier <= 1) {
- OUTB(nc_scntl3, scntl3);
+ OUTB(np, nc_scntl3, scntl3);
return;
}
if (sym_verbose >= 2)
printf ("%s: enabling clock multiplier\n", sym_name(np));
- OUTB(nc_stest1, DBLEN); /* Enable clock multiplier */
+ OUTB(np, nc_stest1, DBLEN); /* Enable clock multiplier */
/*
* Wait for the LCKFRQ bit to be set if supported by the chip.
* Otherwise wait 50 micro-seconds (at least).
*/
if (np->features & FE_LCKFRQ) {
int i = 20;
- while (!(INB(nc_stest4) & LCKFRQ) && --i > 0)
- UDELAY (20);
+ while (!(INB(np, nc_stest4) & LCKFRQ) && --i > 0)
+ udelay(20);
if (!i)
printf("%s: the chip cannot lock the frequency\n",
sym_name(np));
} else
- UDELAY ((50+10));
- OUTB(nc_stest3, HSC); /* Halt the scsi clock */
- OUTB(nc_scntl3, scntl3);
- OUTB(nc_stest1, (DBLEN|DBLSEL));/* Select clock multiplier */
- OUTB(nc_stest3, 0x00); /* Restart scsi clock */
+ udelay((50+10));
+ OUTB(np, nc_stest3, HSC); /* Halt the scsi clock */
+ OUTB(np, nc_scntl3, scntl3);
+ OUTB(np, nc_stest1, (DBLEN|DBLSEL));/* Select clock multiplier */
+ OUTB(np, nc_stest3, 0x00); /* Restart scsi clock */
}
* performed trust the higher delay
* (lower frequency returned).
*/
- OUTW (nc_sien , 0); /* mask all scsi interrupts */
- (void) INW (nc_sist); /* clear pending scsi interrupt */
- OUTB (nc_dien , 0); /* mask all dma interrupts */
- (void) INW (nc_sist); /* another one, just to be sure :) */
+ OUTW(np, nc_sien, 0); /* mask all scsi interrupts */
+ INW(np, nc_sist); /* clear pending scsi interrupt */
+ OUTB(np, nc_dien, 0); /* mask all dma interrupts */
+ INW(np, nc_sist); /* another one, just to be sure :) */
/*
* The C1010-33 core does not report GEN in SIST,
* if this interrupt is masked in SIEN.
* I don't know yet if the C1010-66 behaves the same way.
*/
if (np->features & FE_C10) {
- OUTW (nc_sien, GEN);
- OUTB (nc_istat1, SIRQD);
+ OUTW(np, nc_sien, GEN);
+ OUTB(np, nc_istat1, SIRQD);
}
- OUTB (nc_scntl3, 4); /* set pre-scaler to divide by 3 */
- OUTB (nc_stime1, 0); /* disable general purpose timer */
- OUTB (nc_stime1, gen); /* set to nominal delay of 1<<gen * 125us */
- while (!(INW(nc_sist) & GEN) && ms++ < 100000)
- UDELAY (1000/4);/* count in 1/4 of ms */
- OUTB (nc_stime1, 0); /* disable general purpose timer */
+ OUTB(np, nc_scntl3, 4); /* set pre-scaler to divide by 3 */
+ OUTB(np, nc_stime1, 0); /* disable general purpose timer */
+ OUTB(np, nc_stime1, gen); /* set to nominal delay of 1<<gen * 125us */
+ while (!(INW(np, nc_sist) & GEN) && ms++ < 100000)
+ udelay(1000/4); /* count in 1/4 of ms */
+ OUTB(np, nc_stime1, 0); /* disable general purpose timer */
/*
* Undo C1010-33 specific settings.
*/
if (np->features & FE_C10) {
- OUTW (nc_sien, 0);
- OUTB (nc_istat1, 0);
+ OUTW(np, nc_sien, 0);
+ OUTB(np, nc_istat1, 0);
}
/*
* set prescaler to divide by whatever 0 means
* 0 ought to choose divide by 2, but appears
* to set divide by 3.5 mode in my 53c810 ...
*/
- OUTB (nc_scntl3, 0);
+ OUTB(np, nc_scntl3, 0);
/*
* adjust for prescaler, and convert into KHz
u_int f1, f2;
int gen = 8;
- (void) getfreq (np, gen); /* throw away first result */
+ getfreq (np, gen); /* throw away first result */
f1 = getfreq (np, gen);
f2 = getfreq (np, gen);
if (f1 > f2) f1 = f2; /* trust lower result */
* Otherwise trust scntl3 BIOS setting.
*/
if (np->multiplier != mult || (scntl3 & 7) < 3 || !(scntl3 & 1)) {
- OUTB (nc_stest1, 0); /* make sure doubler is OFF */
+ OUTB(np, nc_stest1, 0); /* make sure doubler is OFF */
f1 = sym_getfreq (np);
if (sym_verbose)
#else
if (1) {
#endif
- OUTB (nc_stest1, SCLK); /* Use the PCI clock as SCSI clock */
- f = (int) sym_getfreq (np);
- OUTB (nc_stest1, 0);
+ OUTB(np, nc_stest1, SCLK); /* Use the PCI clock as SCSI clock */
+ f = sym_getfreq(np);
+ OUTB(np, nc_stest1, 0);
}
np->pciclk_khz = f;
*/
static void sym_save_initial_setting (struct sym_hcb *np)
{
- np->sv_scntl0 = INB(nc_scntl0) & 0x0a;
- np->sv_scntl3 = INB(nc_scntl3) & 0x07;
- np->sv_dmode = INB(nc_dmode) & 0xce;
- np->sv_dcntl = INB(nc_dcntl) & 0xa8;
- np->sv_ctest3 = INB(nc_ctest3) & 0x01;
- np->sv_ctest4 = INB(nc_ctest4) & 0x80;
- np->sv_gpcntl = INB(nc_gpcntl);
- np->sv_stest1 = INB(nc_stest1);
- np->sv_stest2 = INB(nc_stest2) & 0x20;
- np->sv_stest4 = INB(nc_stest4);
+ np->sv_scntl0 = INB(np, nc_scntl0) & 0x0a;
+ np->sv_scntl3 = INB(np, nc_scntl3) & 0x07;
+ np->sv_dmode = INB(np, nc_dmode) & 0xce;
+ np->sv_dcntl = INB(np, nc_dcntl) & 0xa8;
+ np->sv_ctest3 = INB(np, nc_ctest3) & 0x01;
+ np->sv_ctest4 = INB(np, nc_ctest4) & 0x80;
+ np->sv_gpcntl = INB(np, nc_gpcntl);
+ np->sv_stest1 = INB(np, nc_stest1);
+ np->sv_stest2 = INB(np, nc_stest2) & 0x20;
+ np->sv_stest4 = INB(np, nc_stest4);
if (np->features & FE_C10) { /* Always large DMA fifo + ultra3 */
- np->sv_scntl4 = INB(nc_scntl4);
- np->sv_ctest5 = INB(nc_ctest5) & 0x04;
+ np->sv_scntl4 = INB(np, nc_scntl4);
+ np->sv_ctest5 = INB(np, nc_ctest5) & 0x04;
}
else
- np->sv_ctest5 = INB(nc_ctest5) & 0x24;
+ np->sv_ctest5 = INB(np, nc_ctest5) & 0x24;
}
/*
* Prepare io register values used by sym_start_up()
* according to selected and supported features.
*/
-static int sym_prepare_setting(struct sym_hcb *np, struct sym_nvram *nvram)
+static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram)
{
u_char burst_max;
u32 period;
/*
* Select some other
*/
- if (SYM_SETUP_PCI_PARITY)
- np->rv_ctest4 |= MPEE; /* Master parity checking */
- if (SYM_SETUP_SCSI_PARITY)
- np->rv_scntl0 |= 0x0a; /* full arb., ena parity, par->ATN */
+ np->rv_ctest4 |= MPEE; /* Master parity checking */
+ np->rv_scntl0 |= 0x0a; /* full arb., ena parity, par->ATN */
/*
* Get parity checking, host ID and verbose mode from NVRAM
*/
np->myaddr = 255;
- sym_nvram_setup_host (np, nvram);
+ sym_nvram_setup_host(shost, np, nvram);
/*
* Get SCSI addr of host adapter (set by bios?).
*/
if (np->myaddr == 255) {
- np->myaddr = INB(nc_scid) & 0x07;
+ np->myaddr = INB(np, nc_scid) & 0x07;
if (!np->myaddr)
np->myaddr = SYM_SETUP_HOST_ID;
}
np->scsi_mode = SMODE_HVD;
}
else if (nvram->type == SYM_SYMBIOS_NVRAM) {
- if (!(INB(nc_gpreg) & 0x08))
+ if (!(INB(np, nc_gpreg) & 0x08))
np->scsi_mode = SMODE_HVD;
}
}
* If NVRAM present get targets setup from NVRAM.
*/
for (i = 0 ; i < SYM_CONF_MAX_TARGET ; i++) {
- tcb_p tp = &np->target[i];
+ struct sym_tcb *tp = &np->target[i];
tp->usrflags |= (SYM_DISC_ENABLED | SYM_TAGS_ENABLED);
tp->usrtags = SYM_SETUP_MAX_TAG;
- sym_nvram_setup_target (np, i, nvram);
+ sym_nvram_setup_target(np, i, nvram);
if (!tp->usrtags)
tp->usrflags &= ~SYM_TAGS_ENABLED;
/*
* Let user know about the settings.
*/
- i = nvram->type;
- printf("%s: %s NVRAM, ID %d, Fast-%d, %s, %s\n", sym_name(np),
- i == SYM_SYMBIOS_NVRAM ? "Symbios" :
- (i == SYM_TEKRAM_NVRAM ? "Tekram" : "No"),
- np->myaddr,
+ printf("%s: %s, ID %d, Fast-%d, %s, %s\n", sym_name(np),
+ sym_nvram_type(nvram), np->myaddr,
(np->features & FE_ULTRA3) ? 80 :
(np->features & FE_ULTRA2) ? 40 :
(np->features & FE_ULTRA) ? 20 : 10,
*
* Has to be called with interrupts disabled.
*/
-#ifndef SYM_CONF_IOMAPPED
+#ifndef CONFIG_SCSI_SYM53C8XX_IOMAPPED
static int sym_regtest (struct sym_hcb *np)
{
register volatile u32 data;
* and try to read it back.
*/
data = 0xffffffff;
- OUTL_OFF(offsetof(struct sym_reg, nc_dstat), data);
- data = INL_OFF(offsetof(struct sym_reg, nc_dstat));
+ OUTL(np, nc_dstat, data);
+ data = INL(np, nc_dstat);
#if 1
if (data == 0xffffffff) {
#else
printf ("CACHE TEST FAILED: reg dstat-sstat2 readback %x.\n",
(unsigned) data);
return (0x10);
- };
+ }
return (0);
}
#endif
{
u32 sym_rd, sym_wr, sym_bk, host_rd, host_wr, pc, dstat;
int i, err=0;
-#ifndef SYM_CONF_IOMAPPED
+#ifndef CONFIG_SCSI_SYM53C8XX_IOMAPPED
err |= sym_regtest (np);
if (err) return (err);
#endif
* Enable Master Parity Checking as we intend
* to enable it for normal operations.
*/
- OUTB (nc_ctest4, (np->rv_ctest4 & MPEE));
+ OUTB(np, nc_ctest4, (np->rv_ctest4 & MPEE));
/*
* init
*/
- pc = SCRIPTZ_BA (np, snooptest);
+ pc = SCRIPTZ_BA(np, snooptest);
host_wr = 1;
sym_wr = 2;
/*
* Set memory and register.
*/
np->scratch = cpu_to_scr(host_wr);
- OUTL (nc_temp, sym_wr);
+ OUTL(np, nc_temp, sym_wr);
/*
* Start script (exchange values)
*/
- OUTL (nc_dsa, np->hcb_ba);
- OUTL_DSP (pc);
+ OUTL(np, nc_dsa, np->hcb_ba);
+ OUTL_DSP(np, pc);
/*
* Wait 'til done (with timeout)
*/
for (i=0; i<SYM_SNOOP_TIMEOUT; i++)
- if (INB(nc_istat) & (INTF|SIP|DIP))
+ if (INB(np, nc_istat) & (INTF|SIP|DIP))
break;
if (i>=SYM_SNOOP_TIMEOUT) {
printf ("CACHE TEST FAILED: timeout.\n");
return (0x20);
- };
+ }
/*
* Check for fatal DMA errors.
*/
- dstat = INB (nc_dstat);
+ dstat = INB(np, nc_dstat);
#if 1 /* Band aiding for broken hardwares that fail PCI parity */
if ((dstat & MDPE) && (np->rv_ctest4 & MPEE)) {
printf ("%s: PCI DATA PARITY ERROR DETECTED - "
/*
* Save termination position.
*/
- pc = INL (nc_dsp);
+ pc = INL(np, nc_dsp);
/*
* Read memory and register.
*/
host_rd = scr_to_cpu(np->scratch);
- sym_rd = INL (nc_scratcha);
- sym_bk = INL (nc_temp);
+ sym_rd = INL(np, nc_scratcha);
+ sym_bk = INL(np, nc_temp);
/*
* Check termination position.
*/
- if (pc != SCRIPTZ_BA (np, snoopend)+8) {
+ if (pc != SCRIPTZ_BA(np, snoopend)+8) {
printf ("CACHE TEST FAILED: script execution failed.\n");
printf ("start=%08lx, pc=%08lx, end=%08lx\n",
- (u_long) SCRIPTZ_BA (np, snooptest), (u_long) pc,
- (u_long) SCRIPTZ_BA (np, snoopend) +8);
+ (u_long) SCRIPTZ_BA(np, snooptest), (u_long) pc,
+ (u_long) SCRIPTZ_BA(np, snoopend) +8);
return (0x40);
- };
+ }
/*
* Show results.
*/
printf ("CACHE TEST FAILED: host wrote %d, chip read %d.\n",
(int) host_wr, (int) sym_rd);
err |= 1;
- };
+ }
if (host_rd != sym_wr) {
printf ("CACHE TEST FAILED: chip wrote %d, host read %d.\n",
(int) sym_wr, (int) host_rd);
err |= 2;
- };
+ }
if (sym_bk != sym_wr) {
printf ("CACHE TEST FAILED: chip wrote %d, read back %d.\n",
(int) sym_wr, (int) sym_bk);
err |= 4;
- };
+ }
return (err);
}
u_char *script_base;
int i;
- dsp = INL (nc_dsp);
+ dsp = INL(np, nc_dsp);
if (dsp > np->scripta_ba &&
dsp <= np->scripta_ba + np->scripta_sz) {
}
printf ("%s:%d: ERROR (%x:%x) (%x-%x-%x) (%x/%x/%x) @ (%s %x:%08x).\n",
- sym_name (np), (unsigned)INB (nc_sdid)&0x0f, dstat, sist,
- (unsigned)INB (nc_socl), (unsigned)INB (nc_sbcl),
- (unsigned)INB (nc_sbdl), (unsigned)INB (nc_sxfer),
- (unsigned)INB (nc_scntl3),
- (np->features & FE_C10) ? (unsigned)INB (nc_scntl4) : 0,
- script_name, script_ofs, (unsigned)INL (nc_dbc));
+ sym_name(np), (unsigned)INB(np, nc_sdid)&0x0f, dstat, sist,
+ (unsigned)INB(np, nc_socl), (unsigned)INB(np, nc_sbcl),
+ (unsigned)INB(np, nc_sbdl), (unsigned)INB(np, nc_sxfer),
+ (unsigned)INB(np, nc_scntl3),
+ (np->features & FE_C10) ? (unsigned)INB(np, nc_scntl4) : 0,
+ script_name, script_ofs, (unsigned)INL(np, nc_dbc));
if (((script_ofs & 3) == 0) &&
(unsigned)script_ofs < script_size) {
printf ("%s: regdump:", sym_name(np));
for (i=0; i<24;i++)
- printf (" %02x", (unsigned)INB_OFF(i));
+ printf (" %02x", (unsigned)INB_OFF(np, i));
printf (".\n");
/*
sym_log_bus_error(np);
}
-static struct sym_pci_chip sym_pci_dev_table[] = {
+static struct sym_chip sym_dev_table[] = {
{PCI_DEVICE_ID_NCR_53C810, 0x0f, "810", 4, 8, 4, 64,
FE_ERL}
,
FE_RAM|FE_IO256|FE_LEDC}
};
-#define sym_pci_num_devs \
- (sizeof(sym_pci_dev_table) / sizeof(sym_pci_dev_table[0]))
+#define sym_num_devs \
+ (sizeof(sym_dev_table) / sizeof(sym_dev_table[0]))
/*
* Look up the chip table.
* Return a pointer to the chip entry if found,
* zero otherwise.
*/
-struct sym_pci_chip *
-sym_lookup_pci_chip_table (u_short device_id, u_char revision)
+struct sym_chip *
+sym_lookup_chip_table (u_short device_id, u_char revision)
{
- struct sym_pci_chip *chip;
+ struct sym_chip *chip;
int i;
- for (i = 0; i < sym_pci_num_devs; i++) {
- chip = &sym_pci_dev_table[i];
+ for (i = 0; i < sym_num_devs; i++) {
+ chip = &sym_dev_table[i];
if (device_id != chip->device_id)
continue;
if (revision > chip->revision_id)
return;
o = offsetof(struct sym_reg, nc_scrx[0]);
for (i = 0; i < SYM_DMAP_SIZE; i++) {
- OUTL_OFF(o, np->dmap_bah[i]);
+ OUTL_OFF(np, o, np->dmap_bah[i]);
o += 4;
}
np->dmap_dirty = 0;
#endif
/* Enforce all the fiddly SPI rules and the chip limitations */
-static void sym_check_goals(struct scsi_device *sdev)
+static void sym_check_goals(struct sym_hcb *np, struct scsi_target *starget,
+ struct sym_trans *goal)
{
- struct sym_hcb *np = ((struct host_data *)sdev->host->hostdata)->ncb;
- struct sym_trans *st = &np->target[sdev->id].tinfo.goal;
-
- if (!scsi_device_wide(sdev))
- st->width = 0;
-
- if (!scsi_device_sync(sdev)) {
- st->options = 0;
- st->period = 0;
- st->offset = 0;
+ if (!spi_support_wide(starget))
+ goal->width = 0;
+
+ if (!spi_support_sync(starget)) {
+ goal->iu = 0;
+ goal->dt = 0;
+ goal->qas = 0;
+ goal->period = 0;
+ goal->offset = 0;
return;
}
- if (scsi_device_dt(sdev)) {
- if (scsi_device_dt_only(sdev))
- st->options |= PPR_OPT_DT;
+ if (spi_support_dt(starget)) {
+ if (spi_support_dt_only(starget))
+ goal->dt = 1;
- if (st->offset == 0)
- st->options &= ~PPR_OPT_DT;
+ if (goal->offset == 0)
+ goal->dt = 0;
} else {
- st->options &= ~PPR_OPT_DT;
+ goal->dt = 0;
}
/* Some targets fail to properly negotiate DT in SE mode */
if ((np->scsi_mode != SMODE_LVD) || !(np->features & FE_U3EN))
- st->options &= ~PPR_OPT_DT;
+ goal->dt = 0;
- if (st->options & PPR_OPT_DT) {
+ if (goal->dt) {
/* all DT transfers must be wide */
- st->width = 1;
- if (st->offset > np->maxoffs_dt)
- st->offset = np->maxoffs_dt;
- if (st->period < np->minsync_dt)
- st->period = np->minsync_dt;
- if (st->period > np->maxsync_dt)
- st->period = np->maxsync_dt;
+ goal->width = 1;
+ if (goal->offset > np->maxoffs_dt)
+ goal->offset = np->maxoffs_dt;
+ if (goal->period < np->minsync_dt)
+ goal->period = np->minsync_dt;
+ if (goal->period > np->maxsync_dt)
+ goal->period = np->maxsync_dt;
} else {
- st->options &= ~PPR_OPT_MASK;
- if (st->offset > np->maxoffs)
- st->offset = np->maxoffs;
- if (st->period < np->minsync)
- st->period = np->minsync;
- if (st->period > np->maxsync)
- st->period = np->maxsync;
+ goal->iu = goal->qas = 0;
+ if (goal->offset > np->maxoffs)
+ goal->offset = np->maxoffs;
+ if (goal->period < np->minsync)
+ goal->period = np->minsync;
+ if (goal->period > np->maxsync)
+ goal->period = np->maxsync;
}
}
* negotiation and the nego_status field of the CCB.
* Returns the size of the message in bytes.
*/
-static int sym_prepare_nego(struct sym_hcb *np, ccb_p cp, u_char *msgptr)
+static int sym_prepare_nego(struct sym_hcb *np, struct sym_ccb *cp, u_char *msgptr)
{
- tcb_p tp = &np->target[cp->target];
- struct scsi_device *sdev = tp->sdev;
- struct sym_trans *goal = &tp->tinfo.goal;
- struct sym_trans *curr = &tp->tinfo.curr;
+ struct sym_tcb *tp = &np->target[cp->target];
+ struct scsi_target *starget = tp->sdev->sdev_target;
+ struct sym_trans *goal = &tp->tgoal;
int msglen = 0;
int nego;
- if (likely(sdev))
- sym_check_goals(sdev);
+ sym_check_goals(np, starget, goal);
/*
* Many devices implement PPR in a buggy way, so only use it if we
* really want to.
*/
- if ((goal->options & PPR_OPT_MASK) || (goal->period < 0xa)) {
+ if (goal->iu || goal->dt || goal->qas || (goal->period < 0xa)) {
nego = NS_PPR;
- } else if (curr->width != goal->width) {
+ } else if (spi_width(starget) != goal->width) {
nego = NS_WIDE;
- } else if (curr->period != goal->period ||
- curr->offset != goal->offset) {
+ } else if (spi_period(starget) != goal->period ||
+ spi_offset(starget) != goal->offset) {
nego = NS_SYNC;
} else {
+ goal->check_nego = 0;
nego = 0;
}
msgptr[msglen++] = 0;
msgptr[msglen++] = goal->offset;
msgptr[msglen++] = goal->width;
- msgptr[msglen++] = goal->options & PPR_OPT_MASK;
+ msgptr[msglen++] = (goal->iu ? PPR_OPT_IU : 0) |
+ (goal->dt ? PPR_OPT_DT : 0) |
+ (goal->qas ? PPR_OPT_QAS : 0);
break;
- };
+ }
cp->nego_status = nego;
nego == NS_SYNC ? "sync msgout" :
nego == NS_WIDE ? "wide msgout" :
"ppr msgout", msgptr);
- };
- };
+ }
+ }
return msglen;
}
/*
* Insert a job into the start queue.
*/
-void sym_put_start_queue(struct sym_hcb *np, ccb_p cp)
+void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp)
{
u_short qidx;
* Wake it up.
*/
MEMORY_WRITE_BARRIER();
- OUTB (nc_istat, SIGP|np->istat_sem);
+ OUTB(np, nc_istat, SIGP|np->istat_sem);
}
#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
/*
* Start next ready-to-start CCBs.
*/
-void sym_start_next_ccbs(struct sym_hcb *np, lcb_p lp, int maxn)
+void sym_start_next_ccbs(struct sym_hcb *np, struct sym_lcb *lp, int maxn)
{
SYM_QUEHEAD *qp;
- ccb_p cp;
+ struct sym_ccb *cp;
/*
* Paranoia, as usual. :-)
}
lp->itlq_tbl[cp->tag] = cpu_to_scr(cp->ccb_ba);
lp->head.resel_sa =
- cpu_to_scr(SCRIPTA_BA (np, resel_tag));
+ cpu_to_scr(SCRIPTA_BA(np, resel_tag));
++lp->started_tags;
} else {
if (lp->started_no_tag || lp->started_tags) {
}
lp->head.itl_task_sa = cpu_to_scr(cp->ccb_ba);
lp->head.resel_sa =
- cpu_to_scr(SCRIPTA_BA (np, resel_no_tag));
+ cpu_to_scr(SCRIPTA_BA(np, resel_no_tag));
++lp->started_no_tag;
}
cp->started = 1;
*/
static int sym_wakeup_done (struct sym_hcb *np)
{
- ccb_p cp;
+ struct sym_ccb *cp;
int i, n;
u32 dsa;
static void sym_flush_comp_queue(struct sym_hcb *np, int cam_status)
{
SYM_QUEHEAD *qp;
- ccb_p cp;
+ struct sym_ccb *cp;
while ((qp = sym_remque_head(&np->comp_ccbq)) != 0) {
- struct scsi_cmnd *ccb;
+ struct scsi_cmnd *cmd;
cp = sym_que_entry(qp, struct sym_ccb, link_ccbq);
sym_insque_tail(&cp->link_ccbq, &np->busy_ccbq);
/* Leave quiet CCBs waiting for resources */
if (cp->host_status == HS_WAIT)
continue;
- ccb = cp->cam_ccb;
+ cmd = cp->cmd;
if (cam_status)
- sym_set_cam_status(ccb, cam_status);
+ sym_set_cam_status(cmd, cam_status);
#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
- if (sym_get_cam_status(ccb) == CAM_REQUEUE_REQ) {
- tcb_p tp = &np->target[cp->target];
- lcb_p lp = sym_lp(np, tp, cp->lun);
+ if (sym_get_cam_status(cmd) == CAM_REQUEUE_REQ) {
+ struct sym_tcb *tp = &np->target[cp->target];
+ struct sym_lcb *lp = sym_lp(tp, cp->lun);
if (lp) {
sym_remque(&cp->link2_ccbq);
sym_insque_tail(&cp->link2_ccbq,
}
#endif
sym_free_ccb(np, cp);
- sym_freeze_cam_ccb(ccb);
- sym_xpt_done(np, ccb);
+ sym_xpt_done(np, cmd);
}
}
if (reason == 1)
sym_soft_reset(np);
else {
- OUTB (nc_stest3, TE|CSF);
- OUTONB (nc_ctest3, CLF);
+ OUTB(np, nc_stest3, TE|CSF);
+ OUTONB(np, nc_ctest3, CLF);
}
/*
/*
* Init chip.
*/
- OUTB (nc_istat, 0x00 ); /* Remove Reset, abort */
- UDELAY (2000); /* The 895 needs time for the bus mode to settle */
+ OUTB(np, nc_istat, 0x00); /* Remove Reset, abort */
+ udelay(2000); /* The 895 needs time for the bus mode to settle */
- OUTB (nc_scntl0, np->rv_scntl0 | 0xc0);
+ OUTB(np, nc_scntl0, np->rv_scntl0 | 0xc0);
/* full arb., ena parity, par->ATN */
- OUTB (nc_scntl1, 0x00); /* odd parity, and remove CRST!! */
+ OUTB(np, nc_scntl1, 0x00); /* odd parity, and remove CRST!! */
sym_selectclock(np, np->rv_scntl3); /* Select SCSI clock */
- OUTB (nc_scid , RRE|np->myaddr); /* Adapter SCSI address */
- OUTW (nc_respid, 1ul<<np->myaddr); /* Id to respond to */
- OUTB (nc_istat , SIGP ); /* Signal Process */
- OUTB (nc_dmode , np->rv_dmode); /* Burst length, dma mode */
- OUTB (nc_ctest5, np->rv_ctest5); /* Large fifo + large burst */
+ OUTB(np, nc_scid , RRE|np->myaddr); /* Adapter SCSI address */
+ OUTW(np, nc_respid, 1ul<<np->myaddr); /* Id to respond to */
+ OUTB(np, nc_istat , SIGP ); /* Signal Process */
+ OUTB(np, nc_dmode , np->rv_dmode); /* Burst length, dma mode */
+ OUTB(np, nc_ctest5, np->rv_ctest5); /* Large fifo + large burst */
- OUTB (nc_dcntl , NOCOM|np->rv_dcntl); /* Protect SFBR */
- OUTB (nc_ctest3, np->rv_ctest3); /* Write and invalidate */
- OUTB (nc_ctest4, np->rv_ctest4); /* Master parity checking */
+ OUTB(np, nc_dcntl , NOCOM|np->rv_dcntl); /* Protect SFBR */
+ OUTB(np, nc_ctest3, np->rv_ctest3); /* Write and invalidate */
+ OUTB(np, nc_ctest4, np->rv_ctest4); /* Master parity checking */
/* Extended Sreq/Sack filtering not supported on the C10 */
if (np->features & FE_C10)
- OUTB (nc_stest2, np->rv_stest2);
+ OUTB(np, nc_stest2, np->rv_stest2);
else
- OUTB (nc_stest2, EXT|np->rv_stest2);
+ OUTB(np, nc_stest2, EXT|np->rv_stest2);
- OUTB (nc_stest3, TE); /* TolerANT enable */
- OUTB (nc_stime0, 0x0c); /* HTH disabled STO 0.25 sec */
+ OUTB(np, nc_stest3, TE); /* TolerANT enable */
+ OUTB(np, nc_stime0, 0x0c); /* HTH disabled STO 0.25 sec */
/*
* For now, disable AIP generation on C1010-66.
*/
if (np->device_id == PCI_DEVICE_ID_LSI_53C1010_66)
- OUTB (nc_aipcntl1, DISAIP);
+ OUTB(np, nc_aipcntl1, DISAIP);
/*
* C10101 rev. 0 errata.
*/
if (np->device_id == PCI_DEVICE_ID_LSI_53C1010_33 &&
np->revision_id < 1)
- OUTB (nc_stest1, INB(nc_stest1) | 0x30);
+ OUTB(np, nc_stest1, INB(np, nc_stest1) | 0x30);
/*
* DEL 441 - 53C876 Rev 5 - Part Number 609-0392787/2788 - ITEM 2.
* regardless revision id (kind of post-chip-design feature. ;-))
*/
if (np->device_id == PCI_DEVICE_ID_NCR_53C875)
- OUTB (nc_ctest0, (1<<5));
+ OUTB(np, nc_ctest0, (1<<5));
else if (np->device_id == PCI_DEVICE_ID_NCR_53C896)
np->rv_ccntl0 |= DPR;
* seem to support those IO registers.
*/
if (np->features & (FE_DAC|FE_NOPM)) {
- OUTB (nc_ccntl0, np->rv_ccntl0);
- OUTB (nc_ccntl1, np->rv_ccntl1);
+ OUTB(np, nc_ccntl0, np->rv_ccntl0);
+ OUTB(np, nc_ccntl1, np->rv_ccntl1);
}
#if SYM_CONF_DMA_ADDRESSING_MODE == 2
*/
if (np->use_dac) {
np->dmap_bah[0] = 0; /* ??? */
- OUTL (nc_scrx[0], np->dmap_bah[0]);
- OUTL (nc_drs, np->dmap_bah[0]);
+ OUTL(np, nc_scrx[0], np->dmap_bah[0]);
+ OUTL(np, nc_drs, np->dmap_bah[0]);
}
#endif
* set PM jump addresses.
*/
if (np->features & FE_NOPM) {
- OUTL (nc_pmjad1, SCRIPTB_BA (np, pm_handle));
- OUTL (nc_pmjad2, SCRIPTB_BA (np, pm_handle));
+ OUTL(np, nc_pmjad1, SCRIPTB_BA(np, pm_handle));
+ OUTL(np, nc_pmjad2, SCRIPTB_BA(np, pm_handle));
}
/*
* Also set GPIO5 and clear GPIO6 if hardware LED control.
*/
if (np->features & FE_LED0)
- OUTB(nc_gpcntl, INB(nc_gpcntl) & ~0x01);
+ OUTB(np, nc_gpcntl, INB(np, nc_gpcntl) & ~0x01);
else if (np->features & FE_LEDC)
- OUTB(nc_gpcntl, (INB(nc_gpcntl) & ~0x41) | 0x20);
+ OUTB(np, nc_gpcntl, (INB(np, nc_gpcntl) & ~0x41) | 0x20);
/*
* enable ints
*/
- OUTW (nc_sien , STO|HTH|MA|SGE|UDC|RST|PAR);
- OUTB (nc_dien , MDPE|BF|SSI|SIR|IID);
+ OUTW(np, nc_sien , STO|HTH|MA|SGE|UDC|RST|PAR);
+ OUTB(np, nc_dien , MDPE|BF|SSI|SIR|IID);
/*
* For 895/6 enable SBMC interrupt and save current SCSI bus mode.
* we reset the chip but not the SCSI BUS (at initialization).
*/
if (np->features & (FE_ULTRA2|FE_ULTRA3)) {
- OUTONW (nc_sien, SBMC);
+ OUTONW(np, nc_sien, SBMC);
if (reason == 0) {
mdelay(100);
- INW (nc_sist);
+ INW(np, nc_sist);
}
- np->scsi_mode = INB (nc_stest4) & SMODE;
+ np->scsi_mode = INB(np, nc_stest4) & SMODE;
}
/*
* Prepare sync negotiation according to actual SCSI bus mode.
*/
for (i=0;i<SYM_CONF_MAX_TARGET;i++) {
- tcb_p tp = &np->target[i];
+ struct sym_tcb *tp = &np->target[i];
tp->to_reset = 0;
tp->head.sval = 0;
tp->head.wval = np->rv_scntl3;
tp->head.uval = 0;
-
- tp->tinfo.curr.period = 0;
- tp->tinfo.curr.offset = 0;
- tp->tinfo.curr.width = BUS_8_BIT;
- tp->tinfo.curr.options = 0;
}
/*
* For platforms that may not support PCI memory mapping,
* we use simple SCRIPTS that performs MEMORY MOVEs.
*/
+ phys = SCRIPTA_BA(np, init);
if (np->ram_ba) {
if (sym_verbose >= 2)
- printf ("%s: Downloading SCSI SCRIPTS.\n",
- sym_name(np));
+ printf("%s: Downloading SCSI SCRIPTS.\n", sym_name(np));
+ memcpy_toio(np->s.ramaddr, np->scripta0, np->scripta_sz);
if (np->ram_ws == 8192) {
- OUTRAM_OFF(4096, np->scriptb0, np->scriptb_sz);
- phys = scr_to_cpu(np->scr_ram_seg);
- OUTL (nc_mmws, phys);
- OUTL (nc_mmrs, phys);
- OUTL (nc_sfs, phys);
- phys = SCRIPTB_BA (np, start64);
+ memcpy_toio(np->s.ramaddr + 4096, np->scriptb0, np->scriptb_sz);
+ phys = scr_to_cpu(np->scr_ram_seg);
+ OUTL(np, nc_mmws, phys);
+ OUTL(np, nc_mmrs, phys);
+ OUTL(np, nc_sfs, phys);
+ phys = SCRIPTB_BA(np, start64);
}
- else
- phys = SCRIPTA_BA (np, init);
- OUTRAM_OFF(0, np->scripta0, np->scripta_sz);
}
- else
- phys = SCRIPTA_BA (np, init);
np->istat_sem = 0;
- OUTL (nc_dsa, np->hcb_ba);
- OUTL_DSP (phys);
+ OUTL(np, nc_dsa, np->hcb_ba);
+ OUTL_DSP(np, phys);
/*
* Notify the XPT about the RESET condition.
}
/*
- * Switch trans mode for current job and it's target.
+ * Switch trans mode for current job and its target.
*/
static void sym_settrans(struct sym_hcb *np, int target, u_char opts, u_char ofs,
u_char per, u_char wide, u_char div, u_char fak)
{
SYM_QUEHEAD *qp;
u_char sval, wval, uval;
- tcb_p tp = &np->target[target];
+ struct sym_tcb *tp = &np->target[target];
- assert(target == (INB (nc_sdid) & 0x0f));
+ assert(target == (INB(np, nc_sdid) & 0x0f));
sval = tp->head.sval;
wval = tp->head.wval;
assert(np->features & FE_U3EN);
uval |= U3EN;
}
- }
- else {
+ } else {
wval = wval & ~ULTRA;
if (per <= 12) wval |= ULTRA;
}
* Not supported on the C1010.
*/
if (per < 50 && !(np->features & FE_C10))
- OUTOFFB (nc_stest2, EXT);
+ OUTOFFB(np, nc_stest2, EXT);
/*
* set actual value and sync_status
*/
- OUTB (nc_sxfer, tp->head.sval);
- OUTB (nc_scntl3, tp->head.wval);
+ OUTB(np, nc_sxfer, tp->head.sval);
+ OUTB(np, nc_scntl3, tp->head.wval);
if (np->features & FE_C10) {
- OUTB (nc_scntl4, tp->head.uval);
+ OUTB(np, nc_scntl4, tp->head.uval);
}
/*
* patch ALL busy ccbs of this target.
*/
FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) {
- ccb_p cp;
+ struct sym_ccb *cp;
cp = sym_que_entry(qp, struct sym_ccb, link_ccbq);
if (cp->target != target)
continue;
*/
static void sym_setwide(struct sym_hcb *np, int target, u_char wide)
{
- tcb_p tp = &np->target[target];
+ struct sym_tcb *tp = &np->target[target];
+ struct scsi_target *starget = tp->sdev->sdev_target;
+
+ if (spi_width(starget) == wide)
+ return;
sym_settrans(np, target, 0, 0, 0, wide, 0, 0);
- tp->tinfo.goal.width = tp->tinfo.curr.width = wide;
- tp->tinfo.curr.offset = 0;
- tp->tinfo.curr.period = 0;
- tp->tinfo.curr.options = 0;
+ tp->tgoal.width = wide;
+ spi_offset(starget) = 0;
+ spi_period(starget) = 0;
+ spi_width(starget) = wide;
+ spi_iu(starget) = 0;
+ spi_dt(starget) = 0;
+ spi_qas(starget) = 0;
- sym_xpt_async_nego_wide(np, target);
+ if (sym_verbose >= 3)
+ spi_display_xfer_agreement(starget);
}
/*
sym_setsync(struct sym_hcb *np, int target,
u_char ofs, u_char per, u_char div, u_char fak)
{
- tcb_p tp = &np->target[target];
+ struct sym_tcb *tp = &np->target[target];
+ struct scsi_target *starget = tp->sdev->sdev_target;
u_char wide = (tp->head.wval & EWS) ? BUS_16_BIT : BUS_8_BIT;
sym_settrans(np, target, 0, ofs, per, wide, div, fak);
- tp->tinfo.curr.period = per;
- tp->tinfo.curr.offset = ofs;
- tp->tinfo.curr.options = 0;
+ spi_period(starget) = per;
+ spi_offset(starget) = ofs;
+ spi_iu(starget) = spi_dt(starget) = spi_qas(starget) = 0;
- if (!(tp->tinfo.goal.options & PPR_OPT_MASK)) {
- tp->tinfo.goal.period = per;
- tp->tinfo.goal.offset = ofs;
- tp->tinfo.goal.options = 0;
+ if (!tp->tgoal.dt && !tp->tgoal.iu && !tp->tgoal.qas) {
+ tp->tgoal.period = per;
+ tp->tgoal.offset = ofs;
+ tp->tgoal.check_nego = 0;
}
- sym_xpt_async_nego_sync(np, target);
+ spi_display_xfer_agreement(starget);
}
/*
sym_setpprot(struct sym_hcb *np, int target, u_char opts, u_char ofs,
u_char per, u_char wide, u_char div, u_char fak)
{
- tcb_p tp = &np->target[target];
+ struct sym_tcb *tp = &np->target[target];
+ struct scsi_target *starget = tp->sdev->sdev_target;
sym_settrans(np, target, opts, ofs, per, wide, div, fak);
- tp->tinfo.goal.width = tp->tinfo.curr.width = wide;
- tp->tinfo.goal.period = tp->tinfo.curr.period = per;
- tp->tinfo.goal.offset = tp->tinfo.curr.offset = ofs;
- tp->tinfo.goal.options = tp->tinfo.curr.options = opts;
+ spi_width(starget) = tp->tgoal.width = wide;
+ spi_period(starget) = tp->tgoal.period = per;
+ spi_offset(starget) = tp->tgoal.offset = ofs;
+ spi_iu(starget) = tp->tgoal.iu = !!(opts & PPR_OPT_IU);
+ spi_dt(starget) = tp->tgoal.dt = !!(opts & PPR_OPT_DT);
+ spi_qas(starget) = tp->tgoal.qas = !!(opts & PPR_OPT_QAS);
+ tp->tgoal.check_nego = 0;
- sym_xpt_async_nego_ppr(np, target);
+ spi_display_xfer_agreement(starget);
}
/*
*/
static void sym_recover_scsi_int (struct sym_hcb *np, u_char hsts)
{
- u32 dsp = INL (nc_dsp);
- u32 dsa = INL (nc_dsa);
- ccb_p cp = sym_ccb_from_dsa(np, dsa);
+ u32 dsp = INL(np, nc_dsp);
+ u32 dsa = INL(np, nc_dsa);
+ struct sym_ccb *cp = sym_ccb_from_dsa(np, dsa);
/*
* If we haven't been interrupted inside the SCRIPTS
* critical pathes, we can safely restart the SCRIPTS
* and trust the DSA value if it matches a CCB.
*/
- if ((!(dsp > SCRIPTA_BA (np, getjob_begin) &&
- dsp < SCRIPTA_BA (np, getjob_end) + 1)) &&
- (!(dsp > SCRIPTA_BA (np, ungetjob) &&
- dsp < SCRIPTA_BA (np, reselect) + 1)) &&
- (!(dsp > SCRIPTB_BA (np, sel_for_abort) &&
- dsp < SCRIPTB_BA (np, sel_for_abort_1) + 1)) &&
- (!(dsp > SCRIPTA_BA (np, done) &&
- dsp < SCRIPTA_BA (np, done_end) + 1))) {
- OUTB (nc_ctest3, np->rv_ctest3 | CLF); /* clear dma fifo */
- OUTB (nc_stest3, TE|CSF); /* clear scsi fifo */
+ if ((!(dsp > SCRIPTA_BA(np, getjob_begin) &&
+ dsp < SCRIPTA_BA(np, getjob_end) + 1)) &&
+ (!(dsp > SCRIPTA_BA(np, ungetjob) &&
+ dsp < SCRIPTA_BA(np, reselect) + 1)) &&
+ (!(dsp > SCRIPTB_BA(np, sel_for_abort) &&
+ dsp < SCRIPTB_BA(np, sel_for_abort_1) + 1)) &&
+ (!(dsp > SCRIPTA_BA(np, done) &&
+ dsp < SCRIPTA_BA(np, done_end) + 1))) {
+ OUTB(np, nc_ctest3, np->rv_ctest3 | CLF); /* clear dma fifo */
+ OUTB(np, nc_stest3, TE|CSF); /* clear scsi fifo */
/*
* If we have a CCB, let the SCRIPTS call us back for
* the handling of the error with SCRATCHA filled with
*/
if (cp) {
cp->host_status = hsts;
- OUTL_DSP (SCRIPTA_BA (np, complete_error));
+ OUTL_DSP(np, SCRIPTA_BA(np, complete_error));
}
/*
* Otherwise just restart the SCRIPTS.
*/
else {
- OUTL (nc_dsa, 0xffffff);
- OUTL_DSP (SCRIPTA_BA (np, start));
+ OUTL(np, nc_dsa, 0xffffff);
+ OUTL_DSP(np, SCRIPTA_BA(np, start));
}
}
else
*/
static void sym_int_sto (struct sym_hcb *np)
{
- u32 dsp = INL (nc_dsp);
+ u32 dsp = INL(np, nc_dsp);
if (DEBUG_FLAGS & DEBUG_TINY) printf ("T");
- if (dsp == SCRIPTA_BA (np, wf_sel_done) + 8)
+ if (dsp == SCRIPTA_BA(np, wf_sel_done) + 8)
sym_recover_scsi_int(np, HS_SEL_TIMEOUT);
else
sym_start_reset(np);
*/
static void sym_int_sbmc (struct sym_hcb *np)
{
- u_char scsi_mode = INB (nc_stest4) & SMODE;
+ u_char scsi_mode = INB(np, nc_stest4) & SMODE;
/*
* Notify user.
*/
static void sym_int_par (struct sym_hcb *np, u_short sist)
{
- u_char hsts = INB (HS_PRT);
- u32 dsp = INL (nc_dsp);
- u32 dbc = INL (nc_dbc);
- u32 dsa = INL (nc_dsa);
- u_char sbcl = INB (nc_sbcl);
+ u_char hsts = INB(np, HS_PRT);
+ u32 dsp = INL(np, nc_dsp);
+ u32 dbc = INL(np, nc_dbc);
+ u32 dsa = INL(np, nc_dsa);
+ u_char sbcl = INB(np, nc_sbcl);
u_char cmd = dbc >> 24;
int phase = cmd & 7;
- ccb_p cp = sym_ccb_from_dsa(np, dsa);
+ struct sym_ccb *cp = sym_ccb_from_dsa(np, dsa);
printf("%s: SCSI parity error detected: SCR1=%d DBC=%x SBCL=%x\n",
sym_name(np), hsts, dbc, sbcl);
/*
* Check that the chip is connected to the SCSI BUS.
*/
- if (!(INB (nc_scntl1) & ISCON)) {
+ if (!(INB(np, nc_scntl1) & ISCON)) {
sym_recover_scsi_int(np, HS_UNEXPECTED);
return;
}
/*
* Keep track of the parity error.
*/
- OUTONB (HF_PRT, HF_EXT_ERR);
+ OUTONB(np, HF_PRT, HF_EXT_ERR);
cp->xerr_status |= XE_PARITY_ERR;
/*
*/
if (phase == 1 || phase == 5) {
/* Phase mismatch handled by SCRIPTS */
- if (dsp == SCRIPTB_BA (np, pm_handle))
- OUTL_DSP (dsp);
+ if (dsp == SCRIPTB_BA(np, pm_handle))
+ OUTL_DSP(np, dsp);
/* Phase mismatch handled by the C code */
else if (sist & MA)
sym_int_ma (np);
/* No phase mismatch occurred */
else {
sym_set_script_dp (np, cp, dsp);
- OUTL_DSP (SCRIPTA_BA (np, dispatch));
+ OUTL_DSP(np, SCRIPTA_BA(np, dispatch));
}
}
else if (phase == 7) /* We definitely cannot handle parity errors */
#if 1 /* in message-in phase due to the relection */
goto reset_all; /* path and various message anticipations. */
#else
- OUTL_DSP (SCRIPTA_BA (np, clrack));
+ OUTL_DSP(np, SCRIPTA_BA(np, clrack));
#endif
else
- OUTL_DSP (SCRIPTA_BA (np, dispatch));
+ OUTL_DSP(np, SCRIPTA_BA(np, dispatch));
return;
reset_all:
u_char cmd;
u_char hflags, hflags0;
struct sym_pmc *pm;
- ccb_p cp;
+ struct sym_ccb *cp;
- dsp = INL (nc_dsp);
- dbc = INL (nc_dbc);
- dsa = INL (nc_dsa);
+ dsp = INL(np, nc_dsp);
+ dbc = INL(np, nc_dbc);
+ dsa = INL(np, nc_dsa);
cmd = dbc >> 24;
rest = dbc & 0xffffff;
u_char ss0, ss2;
if (np->features & FE_DFBC)
- delta = INW (nc_dfbc);
+ delta = INW(np, nc_dfbc);
else {
u32 dfifo;
/*
* Read DFIFO, CTEST[4-6] using 1 PCI bus ownership.
*/
- dfifo = INL(nc_dfifo);
+ dfifo = INL(np, nc_dfifo);
/*
* Calculate remaining bytes in DMA fifo.
* Check the sstat2 register in case of wide transfer.
*/
rest += delta;
- ss0 = INB (nc_sstat0);
+ ss0 = INB(np, nc_sstat0);
if (ss0 & OLF) rest++;
if (!(np->features & FE_C10))
if (ss0 & ORF) rest++;
if (cp && (cp->phys.select.sel_scntl3 & EWS)) {
- ss2 = INB (nc_sstat2);
+ ss2 = INB(np, nc_sstat2);
if (ss2 & OLF1) rest++;
if (!(np->features & FE_C10))
if (ss2 & ORF1) rest++;
- };
+ }
/*
* Clear fifos.
*/
- OUTB (nc_ctest3, np->rv_ctest3 | CLF); /* dma fifo */
- OUTB (nc_stest3, TE|CSF); /* scsi fifo */
+ OUTB(np, nc_ctest3, np->rv_ctest3 | CLF); /* dma fifo */
+ OUTB(np, nc_stest3, TE|CSF); /* scsi fifo */
}
/*
* log the information
*/
if (DEBUG_FLAGS & (DEBUG_TINY|DEBUG_PHASE))
- printf ("P%x%x RL=%d D=%d ", cmd&7, INB(nc_sbcl)&7,
+ printf ("P%x%x RL=%d D=%d ", cmd&7, INB(np, nc_sbcl)&7,
(unsigned) rest, (unsigned) delta);
/*
if (DEBUG_FLAGS & DEBUG_PHASE) {
printf ("\nCP=%p DSP=%x NXT=%x VDSP=%p CMD=%x ",
cp, (unsigned)dsp, (unsigned)nxtdsp, vdsp, cmd);
- };
+ }
if (!vdsp) {
printf ("%s: interrupted SCRIPT address not found.\n",
} else {
tblp = (u32 *) 0;
olen = scr_to_cpu(vdsp[0]) & 0xffffff;
- };
+ }
if (DEBUG_FLAGS & DEBUG_PHASE) {
printf ("OCMD=%x\nTBLP=%p OLEN=%x OADR=%x\n",
tblp,
(unsigned) olen,
(unsigned) oadr);
- };
+ }
/*
* check cmd against assumed interrupted script command.
* the phase.
*/
if (((cmd & 2) ? cmd : (cmd & ~4)) != (scr_to_cpu(vdsp[0]) >> 24)) {
- PRINT_ADDR(cp);
- printf ("internal error: cmd=%02x != %02x=(vdsp[0] >> 24)\n",
- (unsigned)cmd, (unsigned)scr_to_cpu(vdsp[0]) >> 24);
+ sym_print_addr(cp->cmd,
+ "internal error: cmd=%02x != %02x=(vdsp[0] >> 24)\n",
+ cmd, scr_to_cpu(vdsp[0]) >> 24);
goto reset_all;
- };
+ }
/*
* if old phase not dataphase, leave here.
*/
if (cmd & 2) {
- PRINT_ADDR(cp);
- printf ("phase change %x-%x %d@%08x resid=%d.\n",
- cmd&7, INB(nc_sbcl)&7, (unsigned)olen,
+ sym_print_addr(cp->cmd,
+ "phase change %x-%x %d@%08x resid=%d.\n",
+ cmd&7, INB(np, nc_sbcl)&7, (unsigned)olen,
(unsigned)oadr, (unsigned)rest);
goto unexpected_phase;
- };
+ }
/*
* Choose the correct PM save area.
* SCRIPTS for the 895A, 896 and 1010 that are able to
* handle PM from the SCRIPTS processor.
*/
- hflags0 = INB (HF_PRT);
+ hflags0 = INB(np, HF_PRT);
hflags = hflags0;
if (hflags & (HF_IN_PM0 | HF_IN_PM1 | HF_DP_SAVED)) {
if (!(hflags & HF_ACT_PM)) {
pm = &cp->phys.pm0;
- newcmd = SCRIPTA_BA (np, pm0_data);
+ newcmd = SCRIPTA_BA(np, pm0_data);
}
else {
pm = &cp->phys.pm1;
- newcmd = SCRIPTA_BA (np, pm1_data);
+ newcmd = SCRIPTA_BA(np, pm1_data);
}
hflags &= ~(HF_IN_PM0 | HF_IN_PM1 | HF_DP_SAVED);
if (hflags != hflags0)
- OUTB (HF_PRT, hflags);
+ OUTB(np, HF_PRT, hflags);
/*
* fillin the phase mismatch context
* - compute the SCRIPTS address to restart from,
* - move current data pointer context by one byte.
*/
- nxtdsp = SCRIPTA_BA (np, dispatch);
+ nxtdsp = SCRIPTA_BA(np, dispatch);
if ((cmd & 7) == 1 && cp && (cp->phys.select.sel_scntl3 & EWS) &&
- (INB (nc_scntl2) & WSR)) {
+ (INB(np, nc_scntl2) & WSR)) {
u32 tmp;
/*
* Prepare the address of SCRIPTS that will
* move the residual byte to memory.
*/
- nxtdsp = SCRIPTB_BA (np, wsr_ma_helper);
+ nxtdsp = SCRIPTB_BA(np, wsr_ma_helper);
}
if (DEBUG_FLAGS & DEBUG_PHASE) {
- PRINT_ADDR(cp);
- printf ("PM %x %x %x / %x %x %x.\n",
+ sym_print_addr(cp->cmd, "PM %x %x %x / %x %x %x.\n",
hflags0, hflags, newcmd,
(unsigned)scr_to_cpu(pm->sg.addr),
(unsigned)scr_to_cpu(pm->sg.size),
* Restart the SCRIPTS processor.
*/
sym_set_script_dp (np, cp, newcmd);
- OUTL_DSP (nxtdsp);
+ OUTL_DSP(np, nxtdsp);
return;
/*
switch (cmd & 7) {
case 2: /* COMMAND phase */
- nxtdsp = SCRIPTA_BA (np, dispatch);
+ nxtdsp = SCRIPTA_BA(np, dispatch);
break;
#if 0
case 3: /* STATUS phase */
- nxtdsp = SCRIPTA_BA (np, dispatch);
+ nxtdsp = SCRIPTA_BA(np, dispatch);
break;
#endif
case 6: /* MSG OUT phase */
* since we will not be able to handle reselect.
* Otherwise, we just don't care.
*/
- if (dsp == SCRIPTA_BA (np, send_ident)) {
+ if (dsp == SCRIPTA_BA(np, send_ident)) {
if (cp->tag != NO_TAG && olen - rest <= 3) {
cp->host_status = HS_BUSY;
np->msgout[0] = IDENTIFY(0, cp->lun);
- nxtdsp = SCRIPTB_BA (np, ident_break_atn);
+ nxtdsp = SCRIPTB_BA(np, ident_break_atn);
}
else
- nxtdsp = SCRIPTB_BA (np, ident_break);
+ nxtdsp = SCRIPTB_BA(np, ident_break);
}
- else if (dsp == SCRIPTB_BA (np, send_wdtr) ||
- dsp == SCRIPTB_BA (np, send_sdtr) ||
- dsp == SCRIPTB_BA (np, send_ppr)) {
- nxtdsp = SCRIPTB_BA (np, nego_bad_phase);
+ else if (dsp == SCRIPTB_BA(np, send_wdtr) ||
+ dsp == SCRIPTB_BA(np, send_sdtr) ||
+ dsp == SCRIPTB_BA(np, send_ppr)) {
+ nxtdsp = SCRIPTB_BA(np, nego_bad_phase);
+ if (dsp == SCRIPTB_BA(np, send_ppr)) {
+ struct scsi_device *dev = cp->cmd->device;
+ dev->ppr = 0;
+ }
}
break;
#if 0
case 7: /* MSG IN phase */
- nxtdsp = SCRIPTA_BA (np, clrack);
+ nxtdsp = SCRIPTA_BA(np, clrack);
break;
#endif
}
if (nxtdsp) {
- OUTL_DSP (nxtdsp);
+ OUTL_DSP(np, nxtdsp);
return;
}
* Note that SCRIPTS also (dummy) read to memory
* prior to deliver the INTF interrupt condition.
*/
- istat = INB (nc_istat);
+ istat = INB(np, nc_istat);
if (istat & INTF) {
- OUTB (nc_istat, (istat & SIGP) | INTF | np->istat_sem);
- istat = INB (nc_istat); /* DUMMY READ */
+ OUTB(np, nc_istat, (istat & SIGP) | INTF | np->istat_sem);
+ istat = INB(np, nc_istat); /* DUMMY READ */
if (DEBUG_FLAGS & DEBUG_TINY) printf ("F ");
- (void)sym_wakeup_done (np);
- };
+ sym_wakeup_done(np);
+ }
if (!(istat & (SIP|DIP)))
return;
#if 0 /* We should never get this one */
if (istat & CABRT)
- OUTB (nc_istat, CABRT);
+ OUTB(np, nc_istat, CABRT);
#endif
/*
istatc = istat;
do {
if (istatc & SIP)
- sist |= INW (nc_sist);
+ sist |= INW(np, nc_sist);
if (istatc & DIP)
- dstat |= INB (nc_dstat);
- istatc = INB (nc_istat);
+ dstat |= INB(np, nc_dstat);
+ istatc = INB(np, nc_istat);
istat |= istatc;
} while (istatc & (SIP|DIP));
if (DEBUG_FLAGS & DEBUG_TINY)
printf ("<%d|%x:%x|%x:%x>",
- (int)INB(nc_scr0),
+ (int)INB(np, nc_scr0),
dstat,sist,
- (unsigned)INL(nc_dsp),
- (unsigned)INL(nc_dbc));
+ (unsigned)INL(np, nc_dsp),
+ (unsigned)INL(np, nc_dbc));
/*
* On paper, a memory read barrier may be needed here to
* prevent out of order LOADs by the CPU from having
if (sist & PAR) sym_int_par (np, sist);
else if (sist & MA) sym_int_ma (np);
else if (dstat & SIR) sym_int_sir (np);
- else if (dstat & SSI) OUTONB_STD ();
+ else if (dstat & SSI) OUTONB_STD();
else goto unknown_int;
return;
- };
+ }
/*
* Now, interrupts that donnot happen in normal
printf("%s: SCSI BUS reset detected.\n", sym_name(np));
sym_start_up (np, 1);
return;
- };
+ }
- OUTB (nc_ctest3, np->rv_ctest3 | CLF); /* clear dma fifo */
- OUTB (nc_stest3, TE|CSF); /* clear scsi fifo */
+ OUTB(np, nc_ctest3, np->rv_ctest3 | CLF); /* clear dma fifo */
+ OUTB(np, nc_stest3, TE|CSF); /* clear scsi fifo */
if (!(sist & (GEN|HTH|SGE)) &&
!(dstat & (MDPE|BF|ABRT|IID))) {
else if (sist & UDC) sym_int_udc (np);
else goto unknown_int;
return;
- };
+ }
/*
* Now, interrupts we are not able to recover cleanly.
(dstat & (MDPE|BF|ABRT|IID))) {
sym_start_reset(np);
return;
- };
+ }
unknown_int:
/*
sym_dequeue_from_squeue(struct sym_hcb *np, int i, int target, int lun, int task)
{
int j;
- ccb_p cp;
+ struct sym_ccb *cp;
/*
* Make sure the starting index is within range.
if ((target == -1 || cp->target == target) &&
(lun == -1 || cp->lun == lun) &&
(task == -1 || cp->tag == task)) {
- sym_set_cam_status(cp->cam_ccb, CAM_REQUEUE_REQ);
+ sym_set_cam_status(cp->cmd, CAM_REQUEUE_REQ);
sym_remque(&cp->link_ccbq);
sym_insque_tail(&cp->link_ccbq, &np->comp_ccbq);
}
* SCRATCHA is assumed to have been loaded with STARTPOS
* before the SCRIPTS called the C code.
*/
-static void sym_sir_bad_scsi_status(struct sym_hcb *np, int num, ccb_p cp)
+static void sym_sir_bad_scsi_status(struct sym_hcb *np, int num, struct sym_ccb *cp)
{
- tcb_p tp = &np->target[cp->target];
u32 startp;
u_char s_status = cp->ssss_status;
u_char h_flags = cp->host_flags;
/*
* Compute the index of the next job to start from SCRIPTS.
*/
- i = (INL (nc_scratcha) - np->squeue_ba) / 4;
+ i = (INL(np, nc_scratcha) - np->squeue_ba) / 4;
/*
* The last CCB queued used for IARB hint may be
case S_BUSY:
case S_QUEUE_FULL:
if (sym_verbose >= 2) {
- PRINT_ADDR(cp);
- printf ("%s\n",
+ sym_print_addr(cp->cmd, "%s\n",
s_status == S_BUSY ? "BUSY" : "QUEUE FULL\n");
}
default: /* S_INT, S_INT_COND_MET, S_CONFLICT */
* Dequeue all queued CCBs for that device not yet started,
* and restart the SCRIPTS processor immediately.
*/
- (void) sym_dequeue_from_squeue(np, i, cp->target, cp->lun, -1);
- OUTL_DSP (SCRIPTA_BA (np, start));
+ sym_dequeue_from_squeue(np, i, cp->target, cp->lun, -1);
+ OUTL_DSP(np, SCRIPTA_BA(np, start));
/*
* Save some info of the actual IO.
/*
* Message table indirect structure.
*/
- cp->phys.smsg.addr = cpu_to_scr(CCB_BA (cp, scsi_smsg2));
+ cp->phys.smsg.addr = cpu_to_scr(CCB_BA(cp, scsi_smsg2));
cp->phys.smsg.size = cpu_to_scr(msglen);
/*
* sense command
*/
- cp->phys.cmd.addr = cpu_to_scr(CCB_BA (cp, sensecmd));
+ cp->phys.cmd.addr = cpu_to_scr(CCB_BA(cp, sensecmd));
cp->phys.cmd.size = cpu_to_scr(6);
/*
*/
cp->sensecmd[0] = REQUEST_SENSE;
cp->sensecmd[1] = 0;
- if (tp->tinfo.curr.scsi_version <= 2 && cp->lun <= 7)
+ if (cp->cmd->device->scsi_level <= SCSI_2 && cp->lun <= 7)
cp->sensecmd[1] = cp->lun << 5;
cp->sensecmd[4] = SYM_SNS_BBUF_LEN;
cp->data_len = SYM_SNS_BBUF_LEN;
* sense data
*/
memset(cp->sns_bbuf, 0, SYM_SNS_BBUF_LEN);
- cp->phys.sense.addr = cpu_to_scr(vtobus(cp->sns_bbuf));
+ cp->phys.sense.addr = cpu_to_scr(CCB_BA(cp, sns_bbuf));
cp->phys.sense.size = cpu_to_scr(SYM_SNS_BBUF_LEN);
/*
* requeue the command.
*/
- startp = SCRIPTB_BA (np, sdata_in);
+ startp = SCRIPTB_BA(np, sdata_in);
cp->phys.head.savep = cpu_to_scr(startp);
cp->phys.head.lastp = cpu_to_scr(startp);
cp->xerr_status = 0;
cp->extra_bytes = 0;
- cp->phys.head.go.start = cpu_to_scr(SCRIPTA_BA (np, select));
+ cp->phys.head.go.start = cpu_to_scr(SCRIPTA_BA(np, select));
/*
* Requeue the command.
{
SYM_QUEHEAD qtmp, *qp;
int i = 0;
- ccb_p cp;
+ struct sym_ccb *cp;
/*
* Move the entire BUSY queue to our temporary queue.
* the BUSY queue.
*/
while ((qp = sym_remque_head(&qtmp)) != 0) {
- struct scsi_cmnd *ccb;
+ struct scsi_cmnd *cmd;
cp = sym_que_entry(qp, struct sym_ccb, link_ccbq);
- ccb = cp->cam_ccb;
+ cmd = cp->cmd;
if (cp->host_status != HS_DISCONNECT ||
cp->target != target ||
(lun != -1 && cp->lun != lun) ||
sym_insque_tail(&cp->link_ccbq, &np->comp_ccbq);
/* Preserve the software timeout condition */
- if (sym_get_cam_status(ccb) != CAM_CMD_TIMEOUT)
- sym_set_cam_status(ccb, cam_status);
+ if (sym_get_cam_status(cmd) != CAM_CMD_TIMEOUT)
+ sym_set_cam_status(cmd, cam_status);
++i;
#if 0
printf("XXXX TASK @%p CLEARED\n", cp);
static void sym_sir_task_recovery(struct sym_hcb *np, int num)
{
SYM_QUEHEAD *qp;
- ccb_p cp;
- tcb_p tp;
+ struct sym_ccb *cp;
+ struct sym_tcb *tp = NULL; /* gcc isn't quite smart enough yet */
+ struct scsi_target *starget;
int target=-1, lun=-1, task;
int i, k;
np->abrt_sel.sel_id = target;
np->abrt_sel.sel_scntl3 = tp->head.wval;
np->abrt_sel.sel_sxfer = tp->head.sval;
- OUTL(nc_dsa, np->hcb_ba);
- OUTL_DSP (SCRIPTB_BA (np, sel_for_abort));
+ OUTL(np, nc_dsa, np->hcb_ba);
+ OUTL_DSP(np, SCRIPTB_BA(np, sel_for_abort));
return;
}
* Remove the SEM flag from the ISTAT.
*/
np->istat_sem = 0;
- OUTB (nc_istat, SIGP);
+ OUTB(np, nc_istat, SIGP);
break;
}
/*
* queue the SCRIPTS intends to start and dequeue
* all CCBs for that device that haven't been started.
*/
- i = (INL (nc_scratcha) - np->squeue_ba) / 4;
+ i = (INL(np, nc_scratcha) - np->squeue_ba) / 4;
i = sym_dequeue_from_squeue(np, i, cp->target, cp->lun, -1);
/*
* Make sure at least our IO to abort has been dequeued.
*/
#ifndef SYM_OPT_HANDLE_DEVICE_QUEUEING
- assert(i && sym_get_cam_status(cp->cam_ccb) == CAM_REQUEUE_REQ);
+ assert(i && sym_get_cam_status(cp->cmd) == CAM_REQUEUE_REQ);
#else
sym_remque(&cp->link_ccbq);
sym_insque_tail(&cp->link_ccbq, &np->comp_ccbq);
* Keep track in cam status of the reason of the abort.
*/
if (cp->to_abort == 2)
- sym_set_cam_status(cp->cam_ccb, CAM_CMD_TIMEOUT);
+ sym_set_cam_status(cp->cmd, CAM_CMD_TIMEOUT);
else
- sym_set_cam_status(cp->cam_ccb, CAM_REQ_ABORTED);
+ sym_set_cam_status(cp->cmd, CAM_REQ_ABORTED);
/*
* Complete with error everything that we have dequeued.
* we may have some manual recovery to perform for.
*/
case SIR_TARGET_SELECTED:
- target = (INB (nc_sdid) & 0xf);
+ target = INB(np, nc_sdid) & 0xf;
tp = &np->target[target];
np->abrt_tbl.addr = cpu_to_scr(vtobus(np->abrt_msg));
* an IDENTIFY(lun) + ABORT MESSAGE.
*/
if (lun != -1) {
- lcb_p lp = sym_lp(np, tp, lun);
+ struct sym_lcb *lp = sym_lp(tp, lun);
lp->to_clear = 0; /* We don't expect to fail here */
np->abrt_msg[0] = IDENTIFY(0, lun);
np->abrt_msg[1] = M_ABORT;
* conditions not due to timeout.
*/
if (cp->to_abort == 2)
- sym_set_cam_status(cp->cam_ccb, CAM_CMD_TIMEOUT);
+ sym_set_cam_status(cp->cmd, CAM_CMD_TIMEOUT);
cp->to_abort = 0; /* We donnot expect to fail here */
break;
* to BUS FREE phase as we expected.
*/
case SIR_ABORT_SENT:
- target = (INB (nc_sdid) & 0xf);
+ target = INB(np, nc_sdid) & 0xf;
tp = &np->target[target];
+ starget = tp->sdev->sdev_target;
/*
** If we didn't abort anything, leave here.
tp->head.sval = 0;
tp->head.wval = np->rv_scntl3;
tp->head.uval = 0;
- tp->tinfo.curr.period = 0;
- tp->tinfo.curr.offset = 0;
- tp->tinfo.curr.width = BUS_8_BIT;
- tp->tinfo.curr.options = 0;
+ spi_period(starget) = 0;
+ spi_offset(starget) = 0;
+ spi_width(starget) = 0;
+ spi_iu(starget) = 0;
+ spi_dt(starget) = 0;
+ spi_qas(starget) = 0;
+ tp->tgoal.check_nego = 1;
}
/*
* Complete all the CCBs the device should have
* aborted due to our 'kiss of death' message.
*/
- i = (INL (nc_scratcha) - np->squeue_ba) / 4;
- (void) sym_dequeue_from_squeue(np, i, target, lun, -1);
- (void) sym_clear_tasks(np, CAM_REQ_ABORTED, target, lun, task);
+ i = (INL(np, nc_scratcha) - np->squeue_ba) / 4;
+ sym_dequeue_from_squeue(np, i, target, lun, -1);
+ sym_clear_tasks(np, CAM_REQ_ABORTED, target, lun, task);
sym_flush_comp_queue(np, 0);
/*
* Print to the log the message we intend to send.
*/
if (num == SIR_TARGET_SELECTED) {
- PRINT_TARGET(np, target);
- sym_printl_hex("control msgout:", np->abrt_msg,
- np->abrt_tbl.size);
+ dev_info(&tp->sdev->sdev_target->dev, "control msgout:");
+ sym_printl_hex(np->abrt_msg, np->abrt_tbl.size);
np->abrt_tbl.size = cpu_to_scr(np->abrt_tbl.size);
}
/*
* Let the SCRIPTS processor continue.
*/
- OUTONB_STD ();
+ OUTONB_STD();
}
/*
* pointer for both MDP and the residual calculation.
*
* I didn't want to bloat the code by more than 200
- * lignes for the handling of both MDP and the residual.
+ * lines for the handling of both MDP and the residual.
* This has been achieved by using a data pointer
* representation consisting in an index in the data
* array (dp_sg) and a negative offset (dp_ofs) that
* the corresponding values of dp_sg and dp_ofs.
*/
-static int sym_evaluate_dp(struct sym_hcb *np, ccb_p cp, u32 scr, int *ofs)
+static int sym_evaluate_dp(struct sym_hcb *np, struct sym_ccb *cp, u32 scr, int *ofs)
{
u32 dp_scr;
int dp_ofs, dp_sg, dp_sgmin;
*/
dp_scr = scr;
dp_ofs = *ofs;
- if (dp_scr == SCRIPTA_BA (np, pm0_data))
+ if (dp_scr == SCRIPTA_BA(np, pm0_data))
pm = &cp->phys.pm0;
- else if (dp_scr == SCRIPTA_BA (np, pm1_data))
+ else if (dp_scr == SCRIPTA_BA(np, pm1_data))
pm = &cp->phys.pm1;
else
pm = NULL;
* is equivalent to a MODIFY DATA POINTER (offset=-1).
*/
-static void sym_modify_dp(struct sym_hcb *np, tcb_p tp, ccb_p cp, int ofs)
+static void sym_modify_dp(struct sym_hcb *np, struct sym_tcb *tp, struct sym_ccb *cp, int ofs)
{
int dp_ofs = ofs;
u32 dp_scr = sym_get_script_dp (np, cp);
/*
* Get a context for the new current data pointer.
*/
- hflags = INB (HF_PRT);
+ hflags = INB(np, HF_PRT);
if (hflags & HF_DP_SAVED)
hflags ^= HF_ACT_PM;
if (!(hflags & HF_ACT_PM)) {
pm = &cp->phys.pm0;
- dp_scr = SCRIPTA_BA (np, pm0_data);
+ dp_scr = SCRIPTA_BA(np, pm0_data);
}
else {
pm = &cp->phys.pm1;
- dp_scr = SCRIPTA_BA (np, pm1_data);
+ dp_scr = SCRIPTA_BA(np, pm1_data);
}
hflags &= ~(HF_DP_SAVED);
- OUTB (HF_PRT, hflags);
+ OUTB(np, HF_PRT, hflags);
/*
* Set up the new current data pointer.
out_ok:
sym_set_script_dp (np, cp, dp_scr);
- OUTL_DSP (SCRIPTA_BA (np, clrack));
+ OUTL_DSP(np, SCRIPTA_BA(np, clrack));
return;
out_reject:
- OUTL_DSP (SCRIPTB_BA (np, msg_bad));
+ OUTL_DSP(np, SCRIPTB_BA(np, msg_bad));
}
* a relevant information. :)
*/
-int sym_compute_residual(struct sym_hcb *np, ccb_p cp)
+int sym_compute_residual(struct sym_hcb *np, struct sym_ccb *cp)
{
int dp_sg, dp_sgmin, resid = 0;
int dp_ofs = 0;
* chip handler for SYNCHRONOUS DATA TRANSFER REQUEST (SDTR) message.
*/
static int
-sym_sync_nego_check(struct sym_hcb *np, int req, int target)
+sym_sync_nego_check(struct sym_hcb *np, int req, struct sym_ccb *cp)
{
+ int target = cp->target;
u_char chg, ofs, per, fak, div;
if (DEBUG_FLAGS & DEBUG_NEGO) {
sym_print_nego_msg(np, target, "sync msgin", np->msgin);
- };
+ }
/*
* Get requested values.
goto reject_it;
if (DEBUG_FLAGS & DEBUG_NEGO) {
- PRINT_TARGET(np, target);
- printf ("sdtr: ofs=%d per=%d div=%d fak=%d chg=%d.\n",
- ofs, per, div, fak, chg);
+ sym_print_addr(cp->cmd,
+ "sdtr: ofs=%d per=%d div=%d fak=%d chg=%d.\n",
+ ofs, per, div, fak, chg);
}
/*
return -1;
}
-static void sym_sync_nego(struct sym_hcb *np, tcb_p tp, ccb_p cp)
+static void sym_sync_nego(struct sym_hcb *np, struct sym_tcb *tp, struct sym_ccb *cp)
{
int req = 1;
int result;
/*
* Request or answer ?
*/
- if (INB (HS_PRT) == HS_NEGOTIATE) {
- OUTB (HS_PRT, HS_BUSY);
+ if (INB(np, HS_PRT) == HS_NEGOTIATE) {
+ OUTB(np, HS_PRT, HS_BUSY);
if (cp->nego_status && cp->nego_status != NS_SYNC)
goto reject_it;
req = 0;
/*
* Check and apply new values.
*/
- result = sym_sync_nego_check(np, req, cp->target);
+ result = sym_sync_nego_check(np, req, cp);
if (result) /* Not acceptable, reject it */
goto reject_it;
if (req) { /* Was a request, send response. */
cp->nego_status = NS_SYNC;
- OUTL_DSP (SCRIPTB_BA (np, sdtr_resp));
+ OUTL_DSP(np, SCRIPTB_BA(np, sdtr_resp));
}
else /* Was a response, we are done. */
- OUTL_DSP (SCRIPTA_BA (np, clrack));
+ OUTL_DSP(np, SCRIPTA_BA(np, clrack));
return;
reject_it:
- OUTL_DSP (SCRIPTB_BA (np, msg_bad));
+ OUTL_DSP(np, SCRIPTB_BA(np, msg_bad));
}
/*
static int
sym_ppr_nego_check(struct sym_hcb *np, int req, int target)
{
- tcb_p tp = &np->target[target];
+ struct sym_tcb *tp = &np->target[target];
unsigned char fak, div;
int dt, chg = 0;
chg = 1;
wide = np->maxwide;
}
- if (!wide || !(np->features & FE_ULTRA3))
- opts = 0;
-
- if (!(np->features & FE_U3EN)) /* Broken U3EN bit not supported */
+ if (!wide || !(np->features & FE_U3EN))
opts = 0;
if (opts != (np->msgin[7] & PPR_OPT_MASK))
* ST, we may want to try a legacy negotiation later.
*/
if (!req && !opts) {
- tp->tinfo.goal.options = 0;
- tp->tinfo.goal.width = wide;
- tp->tinfo.goal.period = per;
- tp->tinfo.goal.offset = ofs;
+ tp->tgoal.period = per;
+ tp->tgoal.offset = ofs;
+ tp->tgoal.width = wide;
+ tp->tgoal.iu = tp->tgoal.dt = tp->tgoal.qas = 0;
+ tp->tgoal.check_nego = 1;
}
return -1;
}
-static void sym_ppr_nego(struct sym_hcb *np, tcb_p tp, ccb_p cp)
+static void sym_ppr_nego(struct sym_hcb *np, struct sym_tcb *tp, struct sym_ccb *cp)
{
int req = 1;
int result;
/*
* Request or answer ?
*/
- if (INB (HS_PRT) == HS_NEGOTIATE) {
- OUTB (HS_PRT, HS_BUSY);
+ if (INB(np, HS_PRT) == HS_NEGOTIATE) {
+ OUTB(np, HS_PRT, HS_BUSY);
if (cp->nego_status && cp->nego_status != NS_PPR)
goto reject_it;
req = 0;
goto reject_it;
if (req) { /* Was a request, send response. */
cp->nego_status = NS_PPR;
- OUTL_DSP (SCRIPTB_BA (np, ppr_resp));
+ OUTL_DSP(np, SCRIPTB_BA(np, ppr_resp));
}
else /* Was a response, we are done. */
- OUTL_DSP (SCRIPTA_BA (np, clrack));
+ OUTL_DSP(np, SCRIPTA_BA(np, clrack));
return;
reject_it:
- OUTL_DSP (SCRIPTB_BA (np, msg_bad));
+ OUTL_DSP(np, SCRIPTB_BA(np, msg_bad));
}
/*
* chip handler for WIDE DATA TRANSFER REQUEST (WDTR) message.
*/
static int
-sym_wide_nego_check(struct sym_hcb *np, int req, int target)
+sym_wide_nego_check(struct sym_hcb *np, int req, struct sym_ccb *cp)
{
+ int target = cp->target;
u_char chg, wide;
if (DEBUG_FLAGS & DEBUG_NEGO) {
sym_print_nego_msg(np, target, "wide msgin", np->msgin);
- };
+ }
/*
* Get requested values.
}
if (DEBUG_FLAGS & DEBUG_NEGO) {
- PRINT_TARGET(np, target);
- printf ("wdtr: wide=%d chg=%d.\n", wide, chg);
+ sym_print_addr(cp->cmd, "wdtr: wide=%d chg=%d.\n",
+ wide, chg);
}
/*
return -1;
}
-static void sym_wide_nego(struct sym_hcb *np, tcb_p tp, ccb_p cp)
+static void sym_wide_nego(struct sym_hcb *np, struct sym_tcb *tp, struct sym_ccb *cp)
{
int req = 1;
int result;
/*
* Request or answer ?
*/
- if (INB (HS_PRT) == HS_NEGOTIATE) {
- OUTB (HS_PRT, HS_BUSY);
+ if (INB(np, HS_PRT) == HS_NEGOTIATE) {
+ OUTB(np, HS_PRT, HS_BUSY);
if (cp->nego_status && cp->nego_status != NS_WIDE)
goto reject_it;
req = 0;
/*
* Check and apply new values.
*/
- result = sym_wide_nego_check(np, req, cp->target);
+ result = sym_wide_nego_check(np, req, cp);
if (result) /* Not acceptable, reject it */
goto reject_it;
if (req) { /* Was a request, send response. */
cp->nego_status = NS_WIDE;
- OUTL_DSP (SCRIPTB_BA (np, wdtr_resp));
- }
- else { /* Was a response. */
+ OUTL_DSP(np, SCRIPTB_BA(np, wdtr_resp));
+ } else { /* Was a response. */
/*
* Negotiate for SYNC immediately after WIDE response.
* This allows to negotiate for both WIDE and SYNC on
* a single SCSI command (Suggested by Justin Gibbs).
*/
- if (tp->tinfo.goal.offset) {
+ if (tp->tgoal.offset) {
np->msgout[0] = M_EXTENDED;
np->msgout[1] = 3;
np->msgout[2] = M_X_SYNC_REQ;
- np->msgout[3] = tp->tinfo.goal.period;
- np->msgout[4] = tp->tinfo.goal.offset;
+ np->msgout[3] = tp->tgoal.period;
+ np->msgout[4] = tp->tgoal.offset;
if (DEBUG_FLAGS & DEBUG_NEGO) {
sym_print_nego_msg(np, cp->target,
}
cp->nego_status = NS_SYNC;
- OUTB (HS_PRT, HS_NEGOTIATE);
- OUTL_DSP (SCRIPTB_BA (np, sdtr_resp));
+ OUTB(np, HS_PRT, HS_NEGOTIATE);
+ OUTL_DSP(np, SCRIPTB_BA(np, sdtr_resp));
return;
- }
- else
- OUTL_DSP (SCRIPTA_BA (np, clrack));
- };
+ } else
+ OUTL_DSP(np, SCRIPTA_BA(np, clrack));
+ }
return;
reject_it:
- OUTL_DSP (SCRIPTB_BA (np, msg_bad));
+ OUTL_DSP(np, SCRIPTB_BA(np, msg_bad));
}
/*
* So, if a PPR makes problems, we may just want to
* try a legacy negotiation later.
*/
-static void sym_nego_default(struct sym_hcb *np, tcb_p tp, ccb_p cp)
+static void sym_nego_default(struct sym_hcb *np, struct sym_tcb *tp, struct sym_ccb *cp)
{
switch (cp->nego_status) {
case NS_PPR:
#if 0
sym_setpprot (np, cp->target, 0, 0, 0, 0, 0, 0);
#else
- tp->tinfo.goal.options = 0;
- if (tp->tinfo.goal.period < np->minsync)
- tp->tinfo.goal.period = np->minsync;
- if (tp->tinfo.goal.offset > np->maxoffs)
- tp->tinfo.goal.offset = np->maxoffs;
+ if (tp->tgoal.period < np->minsync)
+ tp->tgoal.period = np->minsync;
+ if (tp->tgoal.offset > np->maxoffs)
+ tp->tgoal.offset = np->maxoffs;
+ tp->tgoal.iu = tp->tgoal.dt = tp->tgoal.qas = 0;
+ tp->tgoal.check_nego = 1;
#endif
break;
case NS_SYNC:
case NS_WIDE:
sym_setwide (np, cp->target, 0);
break;
- };
+ }
np->msgin [0] = M_NOOP;
np->msgout[0] = M_NOOP;
cp->nego_status = 0;
* chip handler for MESSAGE REJECT received in response to
* PPR, WIDE or SYNCHRONOUS negotiation.
*/
-static void sym_nego_rejected(struct sym_hcb *np, tcb_p tp, ccb_p cp)
+static void sym_nego_rejected(struct sym_hcb *np, struct sym_tcb *tp, struct sym_ccb *cp)
{
sym_nego_default(np, tp, cp);
- OUTB (HS_PRT, HS_BUSY);
+ OUTB(np, HS_PRT, HS_BUSY);
}
/*
*/
static void sym_int_sir (struct sym_hcb *np)
{
- u_char num = INB (nc_dsps);
- u32 dsa = INL (nc_dsa);
- ccb_p cp = sym_ccb_from_dsa(np, dsa);
- u_char target = INB (nc_sdid) & 0x0f;
- tcb_p tp = &np->target[target];
+ u_char num = INB(np, nc_dsps);
+ u32 dsa = INL(np, nc_dsa);
+ struct sym_ccb *cp = sym_ccb_from_dsa(np, dsa);
+ u_char target = INB(np, nc_sdid) & 0x0f;
+ struct sym_tcb *tp = &np->target[target];
int tmp;
if (DEBUG_FLAGS & DEBUG_TINY) printf ("I#%d", num);
if (cp) {
cp->xerr_status &= ~XE_PARITY_ERR;
if (!cp->xerr_status)
- OUTOFFB (HF_PRT, HF_EXT_ERR);
+ OUTOFFB(np, HF_PRT, HF_EXT_ERR);
}
}
goto out;
*/
case SIR_SWIDE_OVERRUN:
if (cp) {
- OUTONB (HF_PRT, HF_EXT_ERR);
+ OUTONB(np, HF_PRT, HF_EXT_ERR);
cp->xerr_status |= XE_SWIDE_OVRUN;
}
goto out;
*/
case SIR_SODL_UNDERRUN:
if (cp) {
- OUTONB (HF_PRT, HF_EXT_ERR);
+ OUTONB(np, HF_PRT, HF_EXT_ERR);
cp->xerr_status |= XE_SODL_UNRUN;
}
goto out;
*/
case SIR_DATA_OVERRUN:
if (cp) {
- OUTONB (HF_PRT, HF_EXT_ERR);
+ OUTONB(np, HF_PRT, HF_EXT_ERR);
cp->xerr_status |= XE_EXTRA_DATA;
- cp->extra_bytes += INL (nc_scratcha);
+ cp->extra_bytes += INL(np, nc_scratcha);
}
goto out;
/*
*/
case SIR_BAD_PHASE:
if (cp) {
- OUTONB (HF_PRT, HF_EXT_ERR);
+ OUTONB(np, HF_PRT, HF_EXT_ERR);
cp->xerr_status |= XE_BAD_PHASE;
}
goto out;
if (DEBUG_FLAGS & DEBUG_POINTER)
sym_print_msg(cp,"ign wide residue", np->msgin);
if (cp->host_flags & HF_SENSE)
- OUTL_DSP (SCRIPTA_BA (np, clrack));
+ OUTL_DSP(np, SCRIPTA_BA(np, clrack));
else
sym_modify_dp(np, tp, cp, -1);
return;
case M_REJECT:
- if (INB (HS_PRT) == HS_NEGOTIATE)
+ if (INB(np, HS_PRT) == HS_NEGOTIATE)
sym_nego_rejected(np, tp, cp);
else {
- PRINT_ADDR(cp);
- printf ("M_REJECT received (%x:%x).\n",
+ sym_print_addr(cp->cmd,
+ "M_REJECT received (%x:%x).\n",
scr_to_cpu(np->lastmsg), np->msgout[0]);
}
goto out_clrack;
*/
case SIR_MSG_WEIRD:
sym_print_msg(cp, "WEIRD message received", np->msgin);
- OUTL_DSP (SCRIPTB_BA (np, msg_weird));
+ OUTL_DSP(np, SCRIPTB_BA(np, msg_weird));
return;
/*
* Negotiation failed.
* Remove the HS_NEGOTIATE status.
*/
case SIR_NEGO_FAILED:
- OUTB (HS_PRT, HS_BUSY);
+ OUTB(np, HS_PRT, HS_BUSY);
/*
* Negotiation failed.
* Target does not want answer message.
case SIR_NEGO_PROTO:
sym_nego_default(np, tp, cp);
goto out;
- };
+ }
out:
- OUTONB_STD ();
+ OUTONB_STD();
return;
out_reject:
- OUTL_DSP (SCRIPTB_BA (np, msg_bad));
+ OUTL_DSP(np, SCRIPTB_BA(np, msg_bad));
return;
out_clrack:
- OUTL_DSP (SCRIPTA_BA (np, clrack));
+ OUTL_DSP(np, SCRIPTA_BA(np, clrack));
return;
out_stuck:
return;
/*
* Acquire a control block
*/
-ccb_p sym_get_ccb (struct sym_hcb *np, u_char tn, u_char ln, u_char tag_order)
+struct sym_ccb *sym_get_ccb (struct sym_hcb *np, struct scsi_cmnd *cmd, u_char tag_order)
{
- tcb_p tp = &np->target[tn];
- lcb_p lp = sym_lp(np, tp, ln);
+ u_char tn = cmd->device->id;
+ u_char ln = cmd->device->lun;
+ struct sym_tcb *tp = &np->target[tn];
+ struct sym_lcb *lp = sym_lp(tp, ln);
u_short tag = NO_TAG;
SYM_QUEHEAD *qp;
- ccb_p cp = (ccb_p) 0;
+ struct sym_ccb *cp = NULL;
/*
* Look for a free CCB
*/
if (sym_que_empty(&np->free_ccbq))
- (void) sym_alloc_ccb(np);
+ sym_alloc_ccb(np);
qp = sym_remque_head(&np->free_ccbq);
if (!qp)
goto out;
#ifndef SYM_OPT_HANDLE_DEVICE_QUEUEING
lp->itlq_tbl[tag] = cpu_to_scr(cp->ccb_ba);
lp->head.resel_sa =
- cpu_to_scr(SCRIPTA_BA (np, resel_tag));
+ cpu_to_scr(SCRIPTA_BA(np, resel_tag));
#endif
#ifdef SYM_OPT_LIMIT_COMMAND_REORDERING
cp->tags_si = lp->tags_si;
if (lp->busy_itl == 1) {
lp->head.itl_task_sa = cpu_to_scr(cp->ccb_ba);
lp->head.resel_sa =
- cpu_to_scr(SCRIPTA_BA (np, resel_no_tag));
+ cpu_to_scr(SCRIPTA_BA(np, resel_no_tag));
}
else
goto out_free;
cp->lun = ln;
if (DEBUG_FLAGS & DEBUG_TAGS) {
- PRINT_LUN(np, tn, ln);
- printf ("ccb @%p using tag %d.\n", cp, tag);
+ sym_print_addr(cmd, "ccb @%p using tag %d.\n", cp, tag);
}
out:
return cp;
out_free:
sym_insque_head(&cp->link_ccbq, &np->free_ccbq);
- return (ccb_p) 0;
+ return NULL;
}
/*
* Release one control block
*/
-void sym_free_ccb (struct sym_hcb *np, ccb_p cp)
+void sym_free_ccb (struct sym_hcb *np, struct sym_ccb *cp)
{
- tcb_p tp = &np->target[cp->target];
- lcb_p lp = sym_lp(np, tp, cp->lun);
+ struct sym_tcb *tp = &np->target[cp->target];
+ struct sym_lcb *lp = sym_lp(tp, cp->lun);
if (DEBUG_FLAGS & DEBUG_TAGS) {
- PRINT_LUN(np, cp->target, cp->lun);
- printf ("ccb @%p freeing tag %d.\n", cp, cp->tag);
+ sym_print_addr(cp->cmd, "ccb @%p freeing tag %d.\n",
+ cp, cp->tag);
}
/*
*/
if (lp->busy_itlq == 0 && lp->busy_itl == 0)
lp->head.resel_sa =
- cpu_to_scr(SCRIPTB_BA (np, resel_bad_lun));
+ cpu_to_scr(SCRIPTB_BA(np, resel_bad_lun));
}
/*
* Otherwise, we only accept 1 IO per LUN.
np->last_cp = 0;
#endif
- /*
- * Unmap user data from DMA map if needed.
- */
- sym_data_dmamap_unload(np, cp);
-
/*
* Make this CCB available.
*/
- cp->cam_ccb = NULL;
+ cp->cmd = NULL;
cp->host_status = HS_IDLE;
sym_remque(&cp->link_ccbq);
sym_insque_head(&cp->link_ccbq, &np->free_ccbq);
/*
* Allocate a CCB from memory and initialize its fixed part.
*/
-static ccb_p sym_alloc_ccb(struct sym_hcb *np)
+static struct sym_ccb *sym_alloc_ccb(struct sym_hcb *np)
{
- ccb_p cp = NULL;
+ struct sym_ccb *cp = NULL;
int hcode;
/*
if (!cp)
goto out_free;
- /*
- * Allocate a bounce buffer for sense data.
- */
- cp->sns_bbuf = sym_calloc_dma(SYM_SNS_BBUF_LEN, "SNS_BBUF");
- if (!cp->sns_bbuf)
- goto out_free;
-
- /*
- * Allocate a map for the DMA of user data.
- */
- if (sym_data_dmamap_create(np, cp))
- goto out_free;
-
/*
* Count it.
*/
/*
* Initialyze the start and restart actions.
*/
- cp->phys.head.go.start = cpu_to_scr(SCRIPTA_BA (np, idle));
- cp->phys.head.go.restart = cpu_to_scr(SCRIPTB_BA (np, bad_i_t_l));
+ cp->phys.head.go.start = cpu_to_scr(SCRIPTA_BA(np, idle));
+ cp->phys.head.go.restart = cpu_to_scr(SCRIPTB_BA(np, bad_i_t_l));
/*
* Initilialyze some other fields.
#endif
return cp;
out_free:
- if (cp) {
- if (cp->sns_bbuf)
- sym_mfree_dma(cp->sns_bbuf,SYM_SNS_BBUF_LEN,"SNS_BBUF");
+ if (cp)
sym_mfree_dma(cp, sizeof(*cp), "CCB");
- }
return NULL;
}
/*
* Look up a CCB from a DSA value.
*/
-static ccb_p sym_ccb_from_dsa(struct sym_hcb *np, u32 dsa)
+static struct sym_ccb *sym_ccb_from_dsa(struct sym_hcb *np, u32 dsa)
{
int hcode;
- ccb_p cp;
+ struct sym_ccb *cp;
hcode = CCB_HASH_CODE(dsa);
cp = np->ccbh[hcode];
/*
* Lun control block allocation and initialization.
*/
-lcb_p sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln)
+struct sym_lcb *sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln)
{
- tcb_p tp = &np->target[tn];
- lcb_p lp = sym_lp(np, tp, ln);
+ struct sym_tcb *tp = &np->target[tn];
+ struct sym_lcb *lp = sym_lp(tp, ln);
/*
* Already done, just return.
* Allocate the table of pointers for LUN(s) > 0, if needed.
*/
if (ln && !tp->lunmp) {
- tp->lunmp = sym_calloc(SYM_CONF_MAX_LUN * sizeof(lcb_p),
- "LUNMP");
+ tp->lunmp = kcalloc(SYM_CONF_MAX_LUN, sizeof(struct sym_lcb *),
+ GFP_KERNEL);
if (!tp->lunmp)
goto fail;
}
/*
* Set the reselect pattern to our default. :)
*/
- lp->head.resel_sa = cpu_to_scr(SCRIPTB_BA (np, resel_bad_lun));
+ lp->head.resel_sa = cpu_to_scr(SCRIPTB_BA(np, resel_bad_lun));
/*
* Set user capabilities.
*/
static void sym_alloc_lcb_tags (struct sym_hcb *np, u_char tn, u_char ln)
{
- tcb_p tp = &np->target[tn];
- lcb_p lp = sym_lp(np, tp, ln);
+ struct sym_tcb *tp = &np->target[tn];
+ struct sym_lcb *lp = sym_lp(tp, ln);
int i;
/*
lp->itlq_tbl = sym_calloc_dma(SYM_CONF_MAX_TASK*4, "ITLQ_TBL");
if (!lp->itlq_tbl)
goto fail;
- lp->cb_tags = sym_calloc(SYM_CONF_MAX_TASK, "CB_TAGS");
+ lp->cb_tags = kcalloc(SYM_CONF_MAX_TASK, 1, GFP_KERNEL);
if (!lp->cb_tags) {
sym_mfree_dma(lp->itlq_tbl, SYM_CONF_MAX_TASK*4, "ITLQ_TBL");
lp->itlq_tbl = NULL;
/*
* Queue a SCSI IO to the controller.
*/
-int sym_queue_scsiio(struct sym_hcb *np, struct scsi_cmnd *csio, ccb_p cp)
+int sym_queue_scsiio(struct sym_hcb *np, struct scsi_cmnd *cmd, struct sym_ccb *cp)
{
- tcb_p tp;
- lcb_p lp;
+ struct scsi_device *sdev = cmd->device;
+ struct sym_tcb *tp;
+ struct sym_lcb *lp;
u_char *msgptr;
u_int msglen;
int can_disconnect;
/*
* Keep track of the IO in our CCB.
*/
- cp->cam_ccb = csio;
+ cp->cmd = cmd;
/*
* Retrieve the target descriptor.
/*
* Retrieve the lun descriptor.
*/
- lp = sym_lp(np, tp, cp->lun);
+ lp = sym_lp(tp, sdev->lun);
can_disconnect = (cp->tag != NO_TAG) ||
(lp && (lp->curr_flags & SYM_DISC_ENABLED));
msgptr = cp->scsi_smsg;
msglen = 0;
- msgptr[msglen++] = IDENTIFY(can_disconnect, cp->lun);
+ msgptr[msglen++] = IDENTIFY(can_disconnect, sdev->lun);
/*
* Build the tag message if present.
if (lp->tags_sum[lp->tags_si]) {
order = M_ORDERED_TAG;
if ((DEBUG_FLAGS & DEBUG_TAGS)||sym_verbose>1) {
- PRINT_ADDR(cp);
- printf("ordered tag forced.\n");
+ sym_print_addr(cmd,
+ "ordered tag forced.\n");
}
}
lp->tags_since = 0;
* (nego_status is filled by sym_prepare_nego())
*/
cp->nego_status = 0;
- if (tp->tinfo.curr.width != tp->tinfo.goal.width ||
- tp->tinfo.curr.period != tp->tinfo.goal.period ||
- tp->tinfo.curr.offset != tp->tinfo.goal.offset ||
- tp->tinfo.curr.options != tp->tinfo.goal.options) {
- if (!tp->nego_cp && lp)
- msglen += sym_prepare_nego(np, cp, msgptr + msglen);
+ if (tp->tgoal.check_nego && !tp->nego_cp && lp) {
+ msglen += sym_prepare_nego(np, cp, msgptr + msglen);
}
/*
* Startqueue
*/
- cp->phys.head.go.start = cpu_to_scr(SCRIPTA_BA (np, select));
- cp->phys.head.go.restart = cpu_to_scr(SCRIPTA_BA (np, resel_dsa));
+ cp->phys.head.go.start = cpu_to_scr(SCRIPTA_BA(np, select));
+ cp->phys.head.go.restart = cpu_to_scr(SCRIPTA_BA(np, resel_dsa));
/*
* select
/*
* message
*/
- cp->phys.smsg.addr = cpu_to_scr(CCB_BA (cp, scsi_smsg));
+ cp->phys.smsg.addr = cpu_to_scr(CCB_BA(cp, scsi_smsg));
cp->phys.smsg.size = cpu_to_scr(msglen);
/*
* Build the CDB and DATA descriptor block
* and start the IO.
*/
- return sym_setup_data_and_start(np, csio, cp);
+ return sym_setup_data_and_start(np, cmd, cp);
}
/*
*/
int sym_reset_scsi_target(struct sym_hcb *np, int target)
{
- tcb_p tp;
+ struct sym_tcb *tp;
if (target == np->myaddr || (u_int)target >= SYM_CONF_MAX_TARGET)
return -1;
tp->to_reset = 1;
np->istat_sem = SEM;
- OUTB (nc_istat, SIGP|SEM);
+ OUTB(np, nc_istat, SIGP|SEM);
return 0;
}
/*
* Abort a SCSI IO.
*/
-int sym_abort_ccb(struct sym_hcb *np, ccb_p cp, int timed_out)
+static int sym_abort_ccb(struct sym_hcb *np, struct sym_ccb *cp, int timed_out)
{
/*
* Check that the IO is active.
* Tell the SCRIPTS processor to stop and synchronize with us.
*/
np->istat_sem = SEM;
- OUTB (nc_istat, SIGP|SEM);
+ OUTB(np, nc_istat, SIGP|SEM);
return 0;
}
-int sym_abort_scsiio(struct sym_hcb *np, struct scsi_cmnd *ccb, int timed_out)
+int sym_abort_scsiio(struct sym_hcb *np, struct scsi_cmnd *cmd, int timed_out)
{
- ccb_p cp;
+ struct sym_ccb *cp;
SYM_QUEHEAD *qp;
/*
*/
cp = NULL;
FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) {
- ccb_p cp2 = sym_que_entry(qp, struct sym_ccb, link_ccbq);
- if (cp2->cam_ccb == ccb) {
+ struct sym_ccb *cp2 = sym_que_entry(qp, struct sym_ccb, link_ccbq);
+ if (cp2->cmd == cmd) {
cp = cp2;
break;
}
* SCRATCHA is assumed to have been loaded with STARTPOS
* before the SCRIPTS called the C code.
*/
-void sym_complete_error (struct sym_hcb *np, ccb_p cp)
+void sym_complete_error(struct sym_hcb *np, struct sym_ccb *cp)
{
- tcb_p tp;
- lcb_p lp;
+ struct scsi_device *sdev;
+ struct scsi_cmnd *cmd;
+ struct sym_tcb *tp;
+ struct sym_lcb *lp;
int resid;
int i;
/*
* Paranoid check. :)
*/
- if (!cp || !cp->cam_ccb)
+ if (!cp || !cp->cmd)
return;
+ cmd = cp->cmd;
+ sdev = cmd->device;
if (DEBUG_FLAGS & (DEBUG_TINY|DEBUG_RESULT)) {
- printf ("CCB=%lx STAT=%x/%x/%x DEV=%d/%d\n", (unsigned long)cp,
- cp->host_status, cp->ssss_status, cp->host_flags,
- cp->target, cp->lun);
+ dev_info(&sdev->sdev_gendev, "CCB=%p STAT=%x/%x/%x\n", cp,
+ cp->host_status, cp->ssss_status, cp->host_flags);
}
/*
* Get target and lun pointers.
*/
tp = &np->target[cp->target];
- lp = sym_lp(np, tp, cp->lun);
+ lp = sym_lp(tp, sdev->lun);
/*
* Check for extended errors.
*/
if (cp->xerr_status) {
if (sym_verbose)
- sym_print_xerr(cp, cp->xerr_status);
+ sym_print_xerr(cmd, cp->xerr_status);
if (cp->host_status == HS_COMPLETE)
cp->host_status = HS_COMP_ERR;
}
* Dequeue all queued CCBs for that device
* not yet started by SCRIPTS.
*/
- i = (INL (nc_scratcha) - np->squeue_ba) / 4;
- i = sym_dequeue_from_squeue(np, i, cp->target, cp->lun, -1);
+ i = (INL(np, nc_scratcha) - np->squeue_ba) / 4;
+ i = sym_dequeue_from_squeue(np, i, cp->target, sdev->lun, -1);
/*
* Restart the SCRIPTS processor.
*/
- OUTL_DSP (SCRIPTA_BA (np, start));
+ OUTL_DSP(np, SCRIPTA_BA(np, start));
#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
if (cp->host_status == HS_COMPLETE &&
lp->num_sgood = 0;
if (sym_verbose >= 2) {
- PRINT_LUN(np, cp->target, cp->lun);
- printf(" queue depth is now %d\n", lp->started_max);
+ sym_print_addr(cmd, " queue depth is now %d\n",
+ lp->started_max);
}
/*
/*
* Let's requeue it to device.
*/
- sym_set_cam_status(cp->cam_ccb, CAM_REQUEUE_REQ);
+ sym_set_cam_status(cmd, CAM_REQUEUE_REQ);
goto finish;
}
weirdness:
#endif
- /*
- * Synchronize DMA map if needed.
- */
- sym_data_dmamap_postsync(np, cp);
-
/*
* Build result in CAM ccb.
*/
* The SCRIPTS processor is running while we are
* completing successful commands.
*/
-void sym_complete_ok (struct sym_hcb *np, ccb_p cp)
+void sym_complete_ok (struct sym_hcb *np, struct sym_ccb *cp)
{
- tcb_p tp;
- lcb_p lp;
- struct scsi_cmnd *ccb;
+ struct sym_tcb *tp;
+ struct sym_lcb *lp;
+ struct scsi_cmnd *cmd;
int resid;
/*
* Paranoid check. :)
*/
- if (!cp || !cp->cam_ccb)
+ if (!cp || !cp->cmd)
return;
assert (cp->host_status == HS_COMPLETE);
/*
* Get user command.
*/
- ccb = cp->cam_ccb;
+ cmd = cp->cmd;
/*
* Get target and lun pointers.
*/
tp = &np->target[cp->target];
- lp = sym_lp(np, tp, cp->lun);
+ lp = sym_lp(tp, cp->lun);
/*
* Assume device discovered on first success.
/*
* Wrong transfer residuals may be worse than just always
- * returning zero. User can disable this feature from
- * sym_conf.h. Residual support is enabled by default.
+ * returning zero. User can disable this feature in
+ * sym53c8xx.h. Residual support is enabled by default.
*/
if (!SYM_SETUP_RESIDUAL_SUPPORT)
resid = 0;
printf("XXXX RESID= %d - 0x%x\n", resid, resid);
#endif
- /*
- * Synchronize DMA map if needed.
- */
- sym_data_dmamap_postsync(np, cp);
-
/*
* Build result in CAM ccb.
*/
- sym_set_cam_result_ok(np, cp, resid);
+ sym_set_cam_result_ok(cp, cmd, resid);
#ifdef SYM_OPT_SNIFF_INQUIRY
/*
* not set), sniff out device capabilities.
*/
if (cp->cdb_buf[0] == INQUIRY && !(cp->cdb_buf[1] & 0x3))
- sym_sniff_inquiry(np, cp->cam_ccb, resid);
+ sym_sniff_inquiry(np, cmd, resid);
#endif
#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
lp->num_sgood = 0;
++lp->started_max;
if (sym_verbose >= 2) {
- PRINT_LUN(np, cp->target, cp->lun);
- printf(" queue depth is now %d\n",
+ sym_print_addr(cmd, " queue depth is now %d\n",
lp->started_max);
}
}
/*
* Complete the command.
*/
- sym_xpt_done(np, ccb);
+ sym_xpt_done(np, cmd);
}
/*
* Soft-attach the controller.
*/
-int sym_hcb_attach(struct sym_hcb *np, struct sym_fw *fw, struct sym_nvram *nvram)
+int sym_hcb_attach(struct Scsi_Host *shost, struct sym_fw *fw, struct sym_nvram *nvram)
{
+ struct sym_hcb *np = sym_get_hcb(shost);
int i;
/*
* that SCSI clock calibration may not work properly
* if the chip is currently active.
*/
- sym_chip_reset (np);
+ sym_chip_reset(np);
/*
* Prepare controller and devices settings, according
* to chip features, user set-up and driver set-up.
*/
- (void) sym_prepare_setting(np, nvram);
+ sym_prepare_setting(shost, np, nvram);
/*
* Check the PCI clock frequency.
/*
* Allocate the start queue.
*/
- np->squeue = (u32 *) sym_calloc_dma(sizeof(u32)*(MAX_QUEUE*2),"SQUEUE");
+ np->squeue = sym_calloc_dma(sizeof(u32)*(MAX_QUEUE*2),"SQUEUE");
if (!np->squeue)
goto attach_failed;
np->squeue_ba = vtobus(np->squeue);
/*
* Allocate the done queue.
*/
- np->dqueue = (u32 *) sym_calloc_dma(sizeof(u32)*(MAX_QUEUE*2),"DQUEUE");
+ np->dqueue = sym_calloc_dma(sizeof(u32)*(MAX_QUEUE*2),"DQUEUE");
if (!np->dqueue)
goto attach_failed;
np->dqueue_ba = vtobus(np->dqueue);
/*
* Allocate the target bus address array.
*/
- np->targtbl = (u32 *) sym_calloc_dma(256, "TARGTBL");
+ np->targtbl = sym_calloc_dma(256, "TARGTBL");
if (!np->targtbl)
goto attach_failed;
np->targtbl_ba = vtobus(np->targtbl);
/*
* Allocate the array of lists of CCBs hashed by DSA.
*/
- np->ccbh = sym_calloc(sizeof(ccb_p *)*CCB_HASH_SIZE, "CCBH");
+ np->ccbh = kcalloc(sizeof(struct sym_ccb **), CCB_HASH_SIZE, GFP_KERNEL);
if (!np->ccbh)
goto attach_failed;
/*
* Prepare the idle and invalid task actions.
*/
- np->idletask.start = cpu_to_scr(SCRIPTA_BA (np, idle));
- np->idletask.restart = cpu_to_scr(SCRIPTB_BA (np, bad_i_t_l));
+ np->idletask.start = cpu_to_scr(SCRIPTA_BA(np, idle));
+ np->idletask.restart = cpu_to_scr(SCRIPTB_BA(np, bad_i_t_l));
np->idletask_ba = vtobus(&np->idletask);
- np->notask.start = cpu_to_scr(SCRIPTA_BA (np, idle));
- np->notask.restart = cpu_to_scr(SCRIPTB_BA (np, bad_i_t_l));
+ np->notask.start = cpu_to_scr(SCRIPTA_BA(np, idle));
+ np->notask.restart = cpu_to_scr(SCRIPTB_BA(np, bad_i_t_l));
np->notask_ba = vtobus(&np->notask);
- np->bad_itl.start = cpu_to_scr(SCRIPTA_BA (np, idle));
- np->bad_itl.restart = cpu_to_scr(SCRIPTB_BA (np, bad_i_t_l));
+ np->bad_itl.start = cpu_to_scr(SCRIPTA_BA(np, idle));
+ np->bad_itl.restart = cpu_to_scr(SCRIPTB_BA(np, bad_i_t_l));
np->bad_itl_ba = vtobus(&np->bad_itl);
- np->bad_itlq.start = cpu_to_scr(SCRIPTA_BA (np, idle));
- np->bad_itlq.restart = cpu_to_scr(SCRIPTB_BA (np,bad_i_t_l_q));
+ np->bad_itlq.start = cpu_to_scr(SCRIPTA_BA(np, idle));
+ np->bad_itlq.restart = cpu_to_scr(SCRIPTB_BA(np,bad_i_t_l_q));
np->bad_itlq_ba = vtobus(&np->bad_itlq);
/*
if (!np->badluntbl)
goto attach_failed;
- np->badlun_sa = cpu_to_scr(SCRIPTB_BA (np, resel_bad_lun));
+ np->badlun_sa = cpu_to_scr(SCRIPTB_BA(np, resel_bad_lun));
for (i = 0 ; i < 64 ; i++) /* 64 luns/target, no less */
np->badluntbl[i] = cpu_to_scr(vtobus(&np->badlun_sa));
if (sym_snooptest (np)) {
printf("%s: CACHE INCORRECTLY CONFIGURED.\n", sym_name(np));
goto attach_failed;
- };
+ }
/*
* Sigh! we are done.
void sym_hcb_free(struct sym_hcb *np)
{
SYM_QUEHEAD *qp;
- ccb_p cp;
- tcb_p tp;
- lcb_p lp;
+ struct sym_ccb *cp;
+ struct sym_tcb *tp;
+ struct sym_lcb *lp;
int target, lun;
if (np->scriptz0)
if (np->actccbs) {
while ((qp = sym_remque_head(&np->free_ccbq)) != 0) {
cp = sym_que_entry(qp, struct sym_ccb, link_ccbq);
- sym_data_dmamap_destroy(np, cp);
- sym_mfree_dma(cp->sns_bbuf, SYM_SNS_BBUF_LEN,
- "SNS_BBUF");
sym_mfree_dma(cp, sizeof(*cp), "CCB");
}
}
- if (np->ccbh)
- sym_mfree(np->ccbh, sizeof(ccb_p *)*CCB_HASH_SIZE, "CCBH");
+ kfree(np->ccbh);
if (np->badluntbl)
sym_mfree_dma(np->badluntbl, 256,"BADLUNTBL");
for (target = 0; target < SYM_CONF_MAX_TARGET ; target++) {
tp = &np->target[target];
for (lun = 0 ; lun < SYM_CONF_MAX_LUN ; lun++) {
- lp = sym_lp(np, tp, lun);
+ lp = sym_lp(tp, lun);
if (!lp)
continue;
if (lp->itlq_tbl)
sym_mfree_dma(lp->itlq_tbl, SYM_CONF_MAX_TASK*4,
"ITLQ_TBL");
- if (lp->cb_tags)
- sym_mfree(lp->cb_tags, SYM_CONF_MAX_TASK,
- "CB_TAGS");
+ kfree(lp->cb_tags);
sym_mfree_dma(lp, sizeof(*lp), "LCB");
}
#if SYM_CONF_MAX_LUN > 1
- if (tp->lunmp)
- sym_mfree(tp->lunmp, SYM_CONF_MAX_LUN*sizeof(lcb_p),
- "LUNMP");
+ kfree(tp->lunmp);
#endif
}
if (np->targtbl)