Implement SCB paging which allows up to 255 active commands on aic7770

(Rev E or greater), aic7850, aic7860, aic7870, and aic7880 controllers.
SCB paging is enabled with the option "AHC_SCBPAGING_ENABLE".  Full
comments on the algorithm are at the top of i386/scsi/aic7xxx.c.

options "AHC_TAGENABLE" and "AHC_QUEUE_FULL" have been removed.  The
default is 4 tags without SCB paging, 8 with.

Clear the SCSIRSTI bit after throwing a bus reset.  Some cards seem to get
confused otherwise.

Handle SCSIRSTI interrupts before checking to see if there is a valid
SCB in use since this can happen. (Clears PR# i386/1123)

Clean up the way we determine the number of SCBs on the card
(courtesy of Dan Eischen).

Guard against attempts to negotiate wide to a narrow controller.

Fix some comments.

Update my copyrights.
This commit is contained in:
Justin T. Gibbs 1996-04-20 21:29:27 +00:00
parent 1d7ded8adf
commit 102d19a473
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=15331
2 changed files with 790 additions and 411 deletions

File diff suppressed because it is too large Load Diff

View File

@ -15,10 +15,20 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Absolutely no warranty of function or purpose is made by the author
* Justin T. Gibbs.
* 4. Modifications may be freely made to this file if the above conditions
* are met.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: aic7xxx.h,v 1.23 1996/03/31 03:15:31 gibbs Exp $
*/
@ -38,7 +48,6 @@
* aic7850 has only 3.
*/
/* #define AHCDEBUG */
typedef unsigned long int physaddr;
extern u_long ahc_unit;
@ -55,6 +64,7 @@ typedef enum {
AHC_TWIN = 0x008, /* Twin Channel */
AHC_AIC7770 = 0x010,
AHC_AIC7850 = 0x020,
AHC_AIC7860 = 0x021, /* ULTRA version of the aic7850 */
AHC_AIC7870 = 0x040,
AHC_AIC7880 = 0x041,
AHC_AIC78X0 = 0x060, /* PCI Based Controller */
@ -70,13 +80,13 @@ typedef enum {
AHC_FNONE = 0x00,
AHC_INIT = 0x01,
AHC_RUNNING = 0x02,
AHC_USEDEFAULTS = 0x04, /*
AHC_PAGESCBS = 0x04, /* Enable SCB paging */
AHC_USEDEFAULTS = 0x10, /*
* For cards without an seeprom
* or a BIOS to initialize the chip's
* SRAM, we use the default chip and
* target settings.
*/
AHC_EXTSCB = 0x10, /* External SCBs present */
AHC_CHNLB = 0x20, /*
* Second controller on 3940
* Also encodes the offset in the
@ -87,15 +97,14 @@ typedef enum {
/*
* The driver keeps up to MAX_SCB scb structures per card in memory. Only the
* first 26 bytes of the structure need to be transfered to the card during
* normal operation. The remaining fields (next_waiting and host_scb) are
* initialized the first time an SCB is allocated in get_scb(). The fields
* starting at byte 32 are used for kernel level bookkeeping.
* normal operation. The fields starting at byte 32 are used for kernel level
* bookkeeping.
*/
struct scb {
/* ------------ Begin hardware supported fields ---------------- */
/*0*/ u_char control;
/*1*/ u_char target_channel_lun; /* 4/1/3 bits */
/*2*/ u_char target_status;
/*1*/ u_char tcl; /* 4/1/3 bits */
/*2*/ u_char status;
/*3*/ u_char SG_segment_count;
/*4*/ physaddr SG_list_pointer;
/*8*/ u_char residual_SG_segment_count;
@ -107,14 +116,20 @@ struct scb {
*/
/*20*/ physaddr cmdpointer;
/*24*/ u_char cmdlen;
#define SCB_PIO_TRANSFER_SIZE 25 /* amount we need to upload/download
/*25*/ u_char tag; /* Index into our kernel SCB array.
* Also used as the tag for tagged I/O
*/
#define SCB_PIO_TRANSFER_SIZE 26 /* amount we need to upload/download
* via PIO to initialize a transaction.
*/
/*25*/ u_char next_waiting; /* Used to thread SCBs awaiting
* selection
/*26*/ u_char next; /* Used for threading SCBs in the
* "Waiting for Selection" and
* "Disconnected SCB" lists down
* in the sequencer.
*/
/*27*/ u_char prev;
/*-----------------end of hardware supported fields----------------*/
SLIST_ENTRY(scb) next; /* in free list */
STAILQ_ENTRY(scb) links; /* for chaining */
struct scsi_xfer *xs; /* the scsi_xfer for this cmd */
int flags;
#define SCB_FREE 0x00
@ -125,7 +140,8 @@ struct scb {
#define SCB_SENSE 0x10
#define SCB_TIMEDOUT 0x20
#define SCB_QUEUED_FOR_DONE 0x40
int position; /* Position in scbarray */
#define SCB_PAGED_OUT 0x80
u_char position; /* Position in card's scbarray */
struct ahc_dma_seg ahc_dma[AHC_NSEG] __attribute__ ((packed));
struct scsi_sense sense_cmd; /* SCSI command block */
};
@ -136,11 +152,27 @@ struct ahc_data {
ahc_flag flags;
u_long baseport;
struct scb *scbarray[AHC_SCB_MAX]; /* Mirror boards scbarray */
SLIST_HEAD(, scb) free_scb;
int our_id; /* our scsi id */
int our_id_b; /* B channel scsi id */
int vect;
struct scb *immed_ecb; /* an outstanding immediate command */
struct scb *pagedout_ntscbs[16];/*
* Paged out, non-tagged scbs
* indexed by target.
*/
STAILQ_HEAD(, scb) free_scbs; /*
* SCBs assigned to free slots
* on the card. (no paging required)
*/
STAILQ_HEAD(, scb) page_scbs; /*
* SCBs that will require paging
* before use (no assigned slot)
*/
STAILQ_HEAD(, scb) waiting_scbs;/*
* SCBs waiting to be paged in
* and started.
*/
STAILQ_HEAD(, scb)assigned_scbs;/*
* SCBs that were waiting but have
* now been assigned a slot by
* ahc_free_scb.
*/
struct scsi_link sc_link;
struct scsi_link sc_link_b; /* Second bus for Twin channel cards */
u_short needsdtr_orig; /* Targets we initiate sync neg with */
@ -151,15 +183,23 @@ struct ahc_data {
u_short wdtrpending; /* Pending WDTR to these targets */
u_short tagenable; /* Targets that can handle tagqueing */
u_short discenable; /* Targets allowed to disconnect */
int numscbs;
int activescbs;
u_char maxscbs;
u_char our_id; /* our scsi id */
u_char our_id_b; /* B channel scsi id */
u_char numscbs;
u_char activescbs;
u_char maxhscbs; /* Number of SCBs on the card */
u_char maxscbs; /*
* Max SCBs we allocate total including
* any that will force us to page SCBs
*/
u_char qcntmask;
u_char unpause;
u_char pause;
u_char in_timeout;
};
/* #define AHC_DEBUG */
#ifdef AHC_DEBUG
/* Different debugging levels used when AHC_DEBUG is defined */
#define AHC_SHOWMISC 0x0001
#define AHC_SHOWCMDS 0x0002
@ -167,9 +207,9 @@ struct ahc_data {
#define AHC_SHOWABORTS 0x0008
#define AHC_SHOWSENSE 0x0010
#define AHC_SHOWSCBCNT 0x0020
/* #define AHC_DEBUG */
extern int ahc_debug; /* Initialized in i386/scsi/aic7xxx.c */
#endif
void ahc_reset __P((u_long iobase));
struct ahc_data *ahc_alloc __P((int unit, u_long io_base, ahc_type type, ahc_flag flags));