Deleted Added
full compact
aic7xxx.c (66717) aic7xxx.c (66800)
1/*
2 * Core routines and tables shareable across OS platforms.
3 *
4 * Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000 Justin T. Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 16 unchanged lines hidden (view full) ---

25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * $Id: //depot/src/aic7xxx/aic7xxx.c#9 $
32 *
1/*
2 * Core routines and tables shareable across OS platforms.
3 *
4 * Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000 Justin T. Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 16 unchanged lines hidden (view full) ---

25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * $Id: //depot/src/aic7xxx/aic7xxx.c#9 $
32 *
33 * $FreeBSD: head/sys/dev/aic7xxx/aic7xxx.c 66717 2000-10-06 04:01:06Z gibbs $
33 * $FreeBSD: head/sys/dev/aic7xxx/aic7xxx.c 66800 2000-10-08 03:37:52Z gibbs $
34 */
35
36#ifdef __linux__
37#include "aic7xxx_linux.h"
38#include "aic7xxx_inline.h"
39#include "aicasm/aicasm_insformat.h"
40#endif
41

--- 87 unchanged lines hidden (view full) ---

129#include "aic7xxx_seq.h"
130
131/**************************** Function Declarations ***************************/
132static struct tmode_tstate*
133 ahc_alloc_tstate(struct ahc_softc *ahc,
134 u_int scsi_id, char channel);
135static void ahc_free_tstate(struct ahc_softc *ahc,
136 u_int scsi_id, char channel, int force);
34 */
35
36#ifdef __linux__
37#include "aic7xxx_linux.h"
38#include "aic7xxx_inline.h"
39#include "aicasm/aicasm_insformat.h"
40#endif
41

--- 87 unchanged lines hidden (view full) ---

129#include "aic7xxx_seq.h"
130
131/**************************** Function Declarations ***************************/
132static struct tmode_tstate*
133 ahc_alloc_tstate(struct ahc_softc *ahc,
134 u_int scsi_id, char channel);
135static void ahc_free_tstate(struct ahc_softc *ahc,
136 u_int scsi_id, char channel, int force);
137static void ahc_qinfifo_requeue(struct ahc_softc *ahc,
138 struct scb *prev_scb,
139 struct scb *scb);
140static struct ahc_syncrate*
141 ahc_devlimited_syncrate(struct ahc_softc *ahc,
142 u_int *period,
143 u_int *ppr_options);
144static void ahc_update_target_msg_request(struct ahc_softc *ahc,
145 struct ahc_devinfo *devinfo,
146 struct ahc_initiator_tinfo *tinfo,
147 int force, int paused);

--- 820 unchanged lines hidden (view full) ---

968
969 if (scb != NULL) {
970 u_int tag;
971
972 if ((scb->hscb->control & TAG_ENB) != 0)
973 tag = scb->hscb->tag;
974 else
975 tag = SCB_LIST_NULL;
137static struct ahc_syncrate*
138 ahc_devlimited_syncrate(struct ahc_softc *ahc,
139 u_int *period,
140 u_int *ppr_options);
141static void ahc_update_target_msg_request(struct ahc_softc *ahc,
142 struct ahc_devinfo *devinfo,
143 struct ahc_initiator_tinfo *tinfo,
144 int force, int paused);

--- 820 unchanged lines hidden (view full) ---

965
966 if (scb != NULL) {
967 u_int tag;
968
969 if ((scb->hscb->control & TAG_ENB) != 0)
970 tag = scb->hscb->tag;
971 else
972 tag = SCB_LIST_NULL;
973 ahc_print_path(ahc, scb);
976 ahc_abort_scbs(ahc, target, channel,
977 SCB_GET_LUN(scb), tag,
978 ROLE_INITIATOR,
979 CAM_UNEXP_BUSFREE);
974 ahc_abort_scbs(ahc, target, channel,
975 SCB_GET_LUN(scb), tag,
976 ROLE_INITIATOR,
977 CAM_UNEXP_BUSFREE);
980 ahc_print_path(ahc, scb);
981 } else {
982 /*
983 * We had not fully identified this connection,
984 * so we cannot abort anything.
985 */
986 printf("%s: ", ahc_name(ahc));
987 }
988 for (i = 0; i < num_phases; i++) {

--- 649 unchanged lines hidden (view full) ---

1638 int pending_scb_count;
1639 int i;
1640 u_int saved_scbptr;
1641
1642 /*
1643 * Traverse the pending SCB list and ensure that all of the
1644 * SCBs there have the proper settings.
1645 */
978 } else {
979 /*
980 * We had not fully identified this connection,
981 * so we cannot abort anything.
982 */
983 printf("%s: ", ahc_name(ahc));
984 }
985 for (i = 0; i < num_phases; i++) {

--- 649 unchanged lines hidden (view full) ---

1635 int pending_scb_count;
1636 int i;
1637 u_int saved_scbptr;
1638
1639 /*
1640 * Traverse the pending SCB list and ensure that all of the
1641 * SCBs there have the proper settings.
1642 */
1646 pending_scb = LIST_FIRST(&ahc->pending_scbs);
1647 pending_scb_count = 0;
1643 pending_scb_count = 0;
1648 while (pending_scb != NULL) {
1644 LIST_FOREACH(pending_scb, &ahc->pending_scbs, pending_links) {
1649 struct ahc_devinfo devinfo;
1650 struct hardware_scb *pending_hscb;
1651 struct ahc_initiator_tinfo *tinfo;
1652 struct tmode_tstate *tstate;
1653
1654 ahc_scb_devinfo(ahc, &devinfo, pending_scb);
1655 tinfo = ahc_fetch_transinfo(ahc, devinfo.channel,
1656 devinfo.our_scsiid,
1657 devinfo.target, &tstate);
1658 pending_hscb = pending_scb->hscb;
1659 pending_hscb->control &= ~ULTRAENB;
1660 if ((tstate->ultraenb & devinfo.target_mask) != 0)
1661 pending_hscb->control |= ULTRAENB;
1662 pending_hscb->scsirate = tinfo->scsirate;
1663 pending_hscb->scsioffset = tinfo->current.offset;
1664 pending_scb_count++;
1645 struct ahc_devinfo devinfo;
1646 struct hardware_scb *pending_hscb;
1647 struct ahc_initiator_tinfo *tinfo;
1648 struct tmode_tstate *tstate;
1649
1650 ahc_scb_devinfo(ahc, &devinfo, pending_scb);
1651 tinfo = ahc_fetch_transinfo(ahc, devinfo.channel,
1652 devinfo.our_scsiid,
1653 devinfo.target, &tstate);
1654 pending_hscb = pending_scb->hscb;
1655 pending_hscb->control &= ~ULTRAENB;
1656 if ((tstate->ultraenb & devinfo.target_mask) != 0)
1657 pending_hscb->control |= ULTRAENB;
1658 pending_hscb->scsirate = tinfo->scsirate;
1659 pending_hscb->scsioffset = tinfo->current.offset;
1660 pending_scb_count++;
1665 pending_scb = LIST_NEXT(pending_scb, pending_links);
1666 }
1667
1668 if (pending_scb_count == 0)
1669 return;
1670
1671 saved_scbptr = ahc_inb(ahc, SCBPTR);
1672 /* Ensure that the hscbs down on the card match the new information */
1673 for (i = 0; i < ahc->scb_data->maxhscbs; i++) {
1661 }
1662
1663 if (pending_scb_count == 0)
1664 return;
1665
1666 saved_scbptr = ahc_inb(ahc, SCBPTR);
1667 /* Ensure that the hscbs down on the card match the new information */
1668 for (i = 0; i < ahc->scb_data->maxhscbs; i++) {
1674 u_int scb_tag;
1669 struct hardware_scb *pending_hscb;
1670 u_int control;
1671 u_int scb_tag;
1675
1676 ahc_outb(ahc, SCBPTR, i);
1677 scb_tag = ahc_inb(ahc, SCB_TAG);
1672
1673 ahc_outb(ahc, SCBPTR, i);
1674 scb_tag = ahc_inb(ahc, SCB_TAG);
1678 if (scb_tag != SCB_LIST_NULL) {
1679 struct ahc_devinfo devinfo;
1680 struct scb *pending_scb;
1681 struct hardware_scb *pending_hscb;
1682 struct ahc_initiator_tinfo *tinfo;
1683 struct tmode_tstate *tstate;
1684 u_int control;
1675 pending_scb = ahc_lookup_scb(ahc, scb_tag);
1676 if (pending_scb == NULL)
1677 continue;
1685
1678
1686 pending_scb = ahc_lookup_scb(ahc, scb_tag);
1687 if (pending_scb->flags == SCB_FREE)
1688 continue;
1689 pending_hscb = pending_scb->hscb;
1690 ahc_scb_devinfo(ahc, &devinfo, pending_scb);
1691 tinfo = ahc_fetch_transinfo(ahc, devinfo.channel,
1692 devinfo.our_scsiid,
1693 devinfo.target, &tstate);
1694 control = ahc_inb(ahc, SCB_CONTROL);
1695 control &= ~ULTRAENB;
1696 if ((tstate->ultraenb & devinfo.target_mask) != 0)
1697 control |= ULTRAENB;
1698 ahc_outb(ahc, SCB_CONTROL, control);
1699 ahc_outb(ahc, SCB_SCSIRATE, tinfo->scsirate);
1700 ahc_outb(ahc, SCB_SCSIOFFSET, tinfo->current.offset);
1701 }
1679 pending_hscb = pending_scb->hscb;
1680 control = ahc_inb(ahc, SCB_CONTROL);
1681 control &= ~ULTRAENB;
1682 if ((pending_hscb->control & ULTRAENB) != 0)
1683 control |= ULTRAENB;
1684 ahc_outb(ahc, SCB_CONTROL, control);
1685 ahc_outb(ahc, SCB_SCSIRATE, pending_hscb->scsirate);
1686 ahc_outb(ahc, SCB_SCSIOFFSET, pending_hscb->scsioffset);
1702 }
1703 ahc_outb(ahc, SCBPTR, saved_scbptr);
1704}
1705
1706/**************************** Pathing Information *****************************/
1707static void
1708ahc_fetch_devinfo(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
1709{

--- 2471 unchanged lines hidden (view full) ---

4181
4182 ahc_search_qinfifo(ahc, target, channel, lun,
4183 /*tag*/SCB_LIST_NULL, ROLE_UNKNOWN,
4184 CAM_REQUEUE_REQ, SEARCH_COMPLETE);
4185
4186 ahc_platform_freeze_devq(ahc, scb);
4187}
4188
1687 }
1688 ahc_outb(ahc, SCBPTR, saved_scbptr);
1689}
1690
1691/**************************** Pathing Information *****************************/
1692static void
1693ahc_fetch_devinfo(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
1694{

--- 2471 unchanged lines hidden (view full) ---

4166
4167 ahc_search_qinfifo(ahc, target, channel, lun,
4168 /*tag*/SCB_LIST_NULL, ROLE_UNKNOWN,
4169 CAM_REQUEUE_REQ, SEARCH_COMPLETE);
4170
4171 ahc_platform_freeze_devq(ahc, scb);
4172}
4173
4189static void
4174void
4190ahc_qinfifo_requeue(struct ahc_softc *ahc, struct scb *prev_scb,
4191 struct scb *scb)
4192{
4193 if (prev_scb == NULL)
4194 ahc_outb(ahc, NEXT_QUEUED_SCB, scb->hscb->tag);
4195 else
4196 prev_scb->hscb->next = scb->hscb->tag;
4197 ahc->qinfifo[ahc->qinfifonext++] = scb->hscb->tag;
4198 scb->hscb->next = ahc->next_queued_scb->hscb->tag;
4199}
4200
4201int
4175ahc_qinfifo_requeue(struct ahc_softc *ahc, struct scb *prev_scb,
4176 struct scb *scb)
4177{
4178 if (prev_scb == NULL)
4179 ahc_outb(ahc, NEXT_QUEUED_SCB, scb->hscb->tag);
4180 else
4181 prev_scb->hscb->next = scb->hscb->tag;
4182 ahc->qinfifo[ahc->qinfifonext++] = scb->hscb->tag;
4183 scb->hscb->next = ahc->next_queued_scb->hscb->tag;
4184}
4185
4186int
4187ahc_qinfifo_count(struct ahc_softc *ahc)
4188{
4189 u_int8_t qinpos;
4190
4191 if ((ahc->features & AHC_QUEUE_REGS) != 0) {
4192 qinpos = ahc_inb(ahc, SNSCB_QOFF);
4193 ahc_outb(ahc, SNSCB_QOFF, qinpos);
4194 } else
4195 qinpos = ahc_inb(ahc, QINPOS);
4196 return (ahc->qinfifonext - qinpos);
4197}
4198
4199int
4202ahc_search_qinfifo(struct ahc_softc *ahc, int target, char channel,
4203 int lun, u_int tag, role_t role, uint32_t status,
4204 ahc_search_action action)
4205{
4206 struct scb *scb;
4207 struct scb *prev_scb;
4208 uint8_t qinstart;
4209 uint8_t qinpos;
4210 uint8_t qintail;
4211 uint8_t next, prev;
4212 uint8_t curscbptr;
4213 int found;
4214 int maxtarget;
4215 int i;
4200ahc_search_qinfifo(struct ahc_softc *ahc, int target, char channel,
4201 int lun, u_int tag, role_t role, uint32_t status,
4202 ahc_search_action action)
4203{
4204 struct scb *scb;
4205 struct scb *prev_scb;
4206 uint8_t qinstart;
4207 uint8_t qinpos;
4208 uint8_t qintail;
4209 uint8_t next, prev;
4210 uint8_t curscbptr;
4211 int found;
4212 int maxtarget;
4213 int i;
4214 int have_qregs;
4216
4217 qintail = ahc->qinfifonext;
4215
4216 qintail = ahc->qinfifonext;
4218 if ((ahc->features & AHC_QUEUE_REGS) != 0) {
4217 have_qregs = (ahc->features & AHC_QUEUE_REGS) != 0;
4218 if (have_qregs) {
4219 qinstart = ahc_inb(ahc, SNSCB_QOFF);
4220 ahc_outb(ahc, SNSCB_QOFF, qinstart);
4221 } else
4222 qinstart = ahc_inb(ahc, QINPOS);
4223 qinpos = qinstart;
4224
4225 /*
4226 * If the next qinfifo SCB does not match the

--- 59 unchanged lines hidden (view full) ---

4286 * the qinfifo as soon as it determines that
4287 * an SCB needs to be DMA'ed down to the card.
4288 * So, if we are aborting a command that is
4289 * still in the process of being DMAed, we
4290 * must move the sequencer's qinfifo pointer
4291 * back as well.
4292 */
4293 if (qinpos == (qinstart - 1)) {
4219 qinstart = ahc_inb(ahc, SNSCB_QOFF);
4220 ahc_outb(ahc, SNSCB_QOFF, qinstart);
4221 } else
4222 qinstart = ahc_inb(ahc, QINPOS);
4223 qinpos = qinstart;
4224
4225 /*
4226 * If the next qinfifo SCB does not match the

--- 59 unchanged lines hidden (view full) ---

4286 * the qinfifo as soon as it determines that
4287 * an SCB needs to be DMA'ed down to the card.
4288 * So, if we are aborting a command that is
4289 * still in the process of being DMAed, we
4290 * must move the sequencer's qinfifo pointer
4291 * back as well.
4292 */
4293 if (qinpos == (qinstart - 1)) {
4294 ahc_outb(ahc, SNSCB_QOFF, qinpos);
4295 } else {
4296 ahc_outb(ahc, QINPOS, qinpos);
4294 if (have_qregs) {
4295 ahc_outb(ahc, SNSCB_QOFF,
4296 qinpos);
4297 } else {
4298 ahc_outb(ahc, QINPOS, qinpos);
4299 }
4297 }
4298 break;
4299 }
4300 case SEARCH_COUNT:
4301 ahc_qinfifo_requeue(ahc, prev_scb, scb);
4302 prev_scb = scb;
4303 break;
4304 }

--- 1695 unchanged lines hidden ---
4300 }
4301 break;
4302 }
4303 case SEARCH_COUNT:
4304 ahc_qinfifo_requeue(ahc, prev_scb, scb);
4305 prev_scb = scb;
4306 break;
4307 }

--- 1695 unchanged lines hidden ---