Home | History | Annotate | Line # | Download | only in ic
siopvar_common.h revision 1.6
      1  1.6  bouyer /*	$NetBSD: siopvar_common.h,v 1.6 2000/10/18 17:06:52 bouyer Exp $	*/
      2  1.1  bouyer 
      3  1.1  bouyer /*
      4  1.1  bouyer  * Copyright (c) 2000 Manuel Bouyer.
      5  1.1  bouyer  *
      6  1.1  bouyer  * Redistribution and use in source and binary forms, with or without
      7  1.1  bouyer  * modification, are permitted provided that the following conditions
      8  1.1  bouyer  * are met:
      9  1.1  bouyer  * 1. Redistributions of source code must retain the above copyright
     10  1.1  bouyer  *    notice, this list of conditions and the following disclaimer.
     11  1.1  bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  bouyer  *    notice, this list of conditions and the following disclaimer in the
     13  1.1  bouyer  *    documentation and/or other materials provided with the distribution.
     14  1.1  bouyer  * 3. All advertising materials mentioning features or use of this software
     15  1.1  bouyer  *    must display the following acknowledgement:
     16  1.1  bouyer  *	This product includes software developed by Manuel Bouyer
     17  1.1  bouyer  * 4. The name of the author may not be used to endorse or promote products
     18  1.1  bouyer  *    derived from this software without specific prior written permission.
     19  1.1  bouyer  *
     20  1.1  bouyer  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  1.1  bouyer  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  1.1  bouyer  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  1.1  bouyer  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  1.1  bouyer  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  1.1  bouyer  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  1.1  bouyer  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  1.1  bouyer  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  1.1  bouyer  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  1.1  bouyer  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  1.1  bouyer  *
     31  1.1  bouyer  */
     32  1.1  bouyer 
     33  1.1  bouyer /* common struct and routines used by siop and esiop */
     34  1.1  bouyer 
     35  1.1  bouyer #ifndef SIOP_DEFAULT_TARGET
     36  1.1  bouyer #define SIOP_DEFAULT_TARGET 7
     37  1.1  bouyer #endif
     38  1.1  bouyer 
     39  1.1  bouyer /* tables used by SCRIPT */
     40  1.1  bouyer typedef struct scr_table {
     41  1.1  bouyer 	u_int32_t count;
     42  1.1  bouyer 	u_int32_t addr;
     43  1.1  bouyer } scr_table_t ;
     44  1.1  bouyer 
     45  1.1  bouyer /* Number of scatter/gather entries */
     46  1.1  bouyer #define SIOP_NSG	(MAXPHYS/NBPG + 1)
     47  1.1  bouyer 
     48  1.1  bouyer /*
     49  1.1  bouyer  * This structure interfaces the SCRIPT with the driver; it describes a full
     50  1.6  bouyer  * transfer.
     51  1.1  bouyer  */
     52  1.6  bouyer struct siop_xfer_common {
     53  1.1  bouyer 	u_int8_t msg_out[8];	/* 0 */
     54  1.1  bouyer 	u_int8_t msg_in[8];	/* 8 */
     55  1.1  bouyer 	int status;		/* 16 */
     56  1.1  bouyer 	u_int32_t pad1;		/* 20 */
     57  1.1  bouyer 	u_int32_t id;		/* 24 */
     58  1.1  bouyer 	u_int32_t pad2;		/* 28 */
     59  1.1  bouyer 	scr_table_t t_msgin;	/* 32 */
     60  1.1  bouyer 	scr_table_t t_extmsgin;	/* 40 */
     61  1.1  bouyer 	scr_table_t t_extmsgdata; /* 48 */
     62  1.1  bouyer 	scr_table_t t_msgtag;	/* 56 */
     63  1.1  bouyer 	scr_table_t t_msgout;	/* 64 */
     64  1.1  bouyer 	scr_table_t cmd;	/* 72 */
     65  1.1  bouyer 	scr_table_t t_status;	/* 80 */
     66  1.1  bouyer 	scr_table_t data[SIOP_NSG]; /* 88 */
     67  1.1  bouyer } __attribute__((__packed__));
     68  1.1  bouyer 
     69  1.6  bouyer /* xfer description of the script: tables and reselect script */
     70  1.6  bouyer struct siop_xfer {
     71  1.6  bouyer 	struct siop_xfer_common tables;
     72  1.6  bouyer 	/* u_int32_t resel[sizeof(load_dsa) / sizeof(load_dsa[0])]; */
     73  1.6  bouyer 	u_int32_t resel[14];
     74  1.6  bouyer } __attribute__((__packed__));
     75  1.6  bouyer 
     76  1.1  bouyer /*
     77  1.1  bouyer  * This decribes a command handled by the SCSI controller
     78  1.1  bouyer  * These are chained in either a free list or a active list
     79  1.1  bouyer  * We have one queue per target
     80  1.1  bouyer  */
     81  1.1  bouyer struct siop_cmd {
     82  1.1  bouyer 	TAILQ_ENTRY (siop_cmd) next;
     83  1.6  bouyer 	struct siop_softc *siop_sc; /* points back to our adapter */
     84  1.1  bouyer 	struct siop_target *siop_target; /* pointer to our target def */
     85  1.1  bouyer 	struct scsipi_xfer *xs; /* xfer from the upper level */
     86  1.6  bouyer 	struct siop_xfer *siop_xfer; /* tables dealing with this xfer */
     87  1.6  bouyer #define siop_tables siop_xfer->tables
     88  1.2  bouyer 	struct siop_cbd *siop_cbdp; /* pointer to our siop_cbd */
     89  1.1  bouyer 	bus_addr_t	dsa; /* DSA value to load */
     90  1.1  bouyer 	bus_dmamap_t	dmamap_cmd;
     91  1.1  bouyer 	bus_dmamap_t	dmamap_data;
     92  1.1  bouyer 	struct scsipi_sense rs_cmd; /* request sense command buffer */
     93  1.1  bouyer 	int       status;
     94  1.1  bouyer 	int       flags;
     95  1.5  bouyer 	int       reselslot; /* the reselect slot used */
     96  1.2  bouyer };
     97  1.2  bouyer 
     98  1.2  bouyer /* command block descriptors: an array of siop_cmd + an array of siop_xfer */
     99  1.2  bouyer 
    100  1.2  bouyer struct siop_cbd {
    101  1.2  bouyer 	TAILQ_ENTRY (siop_cbd) next;
    102  1.2  bouyer 	struct siop_cmd *cmds;
    103  1.2  bouyer 	struct siop_xfer *xfers;
    104  1.2  bouyer 	bus_dmamap_t xferdma; /* DMA map for this block of xfers */
    105  1.1  bouyer };
    106  1.1  bouyer 
    107  1.1  bouyer /* status defs */
    108  1.1  bouyer #define CMDST_FREE		0 /* cmd slot is free */
    109  1.1  bouyer #define CMDST_READY		1 /* cmd slot is waiting for processing */
    110  1.1  bouyer #define CMDST_ACTIVE		2 /* cmd slot is being processed */
    111  1.1  bouyer #define CMDST_SENSE		3 /* cmd slot is being requesting sense */
    112  1.1  bouyer #define CMDST_SENSE_ACTIVE	4 /* request sense active */
    113  1.1  bouyer #define CMDST_SENSE_DONE 	5 /* request sense done */
    114  1.1  bouyer #define CMDST_DONE		6 /* cmd slot has been processed */
    115  1.1  bouyer /* flags defs */
    116  1.1  bouyer #define CMDFL_TIMEOUT	0x0001 /* cmd timed out */
    117  1.6  bouyer #define CMDFL_TAG	0x0002 /* tagged cmd */
    118  1.6  bouyer 
    119  1.6  bouyer /* per lun struct */
    120  1.6  bouyer struct siop_lun {
    121  1.6  bouyer 	struct siop_cmd *active; /* active command */
    122  1.6  bouyer 	int reseloff; /* XXX tmp */
    123  1.6  bouyer };
    124  1.1  bouyer 
    125  1.1  bouyer /* per-target struct */
    126  1.1  bouyer struct siop_target {
    127  1.1  bouyer 	int status;	/* target status, see below */
    128  1.1  bouyer 	int flags;	/* target flags, see below */
    129  1.1  bouyer 	u_int32_t id;	/* for SELECT FROM */
    130  1.6  bouyer 	struct siop_lun siop_lun[8]; /* per-lun state, XXX should be dynamic */
    131  1.6  bouyer 	int reseloff; /* XXX tmp */
    132  1.6  bouyer 	struct siop_lunsw *lunsw; /* XXX tmp */
    133  1.1  bouyer };
    134  1.1  bouyer 
    135  1.1  bouyer /* target status */
    136  1.1  bouyer #define TARST_PROBING	0 /* target is being probed */
    137  1.1  bouyer #define TARST_ASYNC	1 /* target needs sync/wide negotiation */
    138  1.1  bouyer #define TARST_WIDE_NEG	2 /* target is doing wide negotiation */
    139  1.1  bouyer #define TARST_SYNC_NEG	3 /* target is doing sync negotiation */
    140  1.1  bouyer #define TARST_OK	4 /* sync/wide agreement is valid */
    141  1.1  bouyer 
    142  1.1  bouyer /* target flags */
    143  1.6  bouyer #define TARF_SYNC	0x01 /* target can do sync */
    144  1.6  bouyer #define TARF_WIDE	0x02 /* target can do wide */
    145  1.6  bouyer #define TARF_TAG	0x04 /* target can do tags */
    146  1.6  bouyer #define TARF_ISWIDE	0x08 /* target is wide */
    147  1.6  bouyer 
    148  1.6  bouyer struct siop_lunsw {
    149  1.6  bouyer 	TAILQ_ENTRY (siop_lunsw) next;
    150  1.6  bouyer 	u_int32_t lunsw_off; /* offset of this lun sw, from sc_scriptaddr*/
    151  1.6  bouyer };
    152  1.1  bouyer 
    153  1.1  bouyer void	siop_common_reset __P((struct siop_softc *));
    154  1.3  bouyer int	siop_modechange __P((struct siop_softc *));
    155  1.1  bouyer 
    156  1.1  bouyer int	siop_wdtr_neg __P((struct siop_cmd *siop_cmd));
    157  1.1  bouyer int	siop_sdtr_neg __P((struct siop_cmd *siop_cmd));
    158  1.1  bouyer /* actions to take at return of siop_wdtr_neg() and siop_sdtr_neg() */
    159  1.1  bouyer #define SIOP_NEG_NOP	0x0
    160  1.1  bouyer #define SIOP_NEG_MSGOUT	0x1
    161  1.1  bouyer #define SIOP_NEG_ACK	0x2
    162  1.1  bouyer 
    163  1.1  bouyer void	siop_minphys __P((struct buf *));
    164  1.1  bouyer int	siop_ioctl __P((struct scsipi_link *, u_long,
    165  1.1  bouyer 		caddr_t, int, struct proc *));
    166  1.1  bouyer void 	siop_sdp __P((struct siop_cmd *));
    167  1.1  bouyer void	siop_clearfifo __P((struct siop_softc *));
    168  1.4  bouyer void	siop_resetbus __P((struct siop_softc *));
    169