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