2012-08-24 13:01:22 +04:00
|
|
|
/* $NetBSD: esiopvar.h,v 1.21 2012/08/24 09:01:22 msaitoh Exp $ */
|
2002-04-22 02:52:05 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2002 Manuel Bouyer.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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.
|
2005-02-27 03:26:58 +03:00
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
2002-04-22 02:52:05 +04:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* structure and definitions for the siop driver */
|
|
|
|
|
|
|
|
/* Number of tag */
|
|
|
|
#define ESIOP_NTAG 256
|
|
|
|
|
2002-04-22 19:53:39 +04:00
|
|
|
/*
|
|
|
|
* description of a command scheduler slot. The script uses a ring of
|
|
|
|
* A_ncmd_slots of this.
|
|
|
|
*/
|
|
|
|
struct esiop_slot {
|
2009-09-04 22:40:19 +04:00
|
|
|
uint32_t dsa; /* DSA of the xfer. The first 2 bits holds flags */
|
2007-12-25 21:33:32 +03:00
|
|
|
} __packed;
|
2002-04-22 19:53:39 +04:00
|
|
|
|
2009-09-04 22:40:19 +04:00
|
|
|
#define CMD_SLOTSIZE (sizeof(struct esiop_slot) / sizeof(uint32_t))
|
2002-04-24 13:43:14 +04:00
|
|
|
|
2002-04-22 02:52:05 +04:00
|
|
|
/*
|
|
|
|
* xfer description of the script: tables and reselect script
|
|
|
|
* In struct siop_common_cmd siop_xfer will point to this.
|
2002-04-24 13:43:14 +04:00
|
|
|
* If you change this don't forget to update o_cmd_* and cmd_slot_size in script
|
2002-04-22 02:52:05 +04:00
|
|
|
*/
|
|
|
|
struct esiop_xfer {
|
|
|
|
struct siop_common_xfer siop_tables;
|
2009-09-04 22:40:19 +04:00
|
|
|
uint32_t tlq; /* target/lun/tag loaded in scratchC by script */
|
|
|
|
uint32_t saved_offset;/* contains scratchA if script saved an offset */
|
2007-12-25 21:33:32 +03:00
|
|
|
} __packed;
|
2002-04-22 02:52:05 +04:00
|
|
|
|
2005-11-19 02:10:32 +03:00
|
|
|
#define ESIOP_XFER(cmd, m) (((struct esiop_xfer *)((cmd)->cmd_tables))->m)
|
|
|
|
|
2002-04-22 02:52:05 +04:00
|
|
|
/*
|
2003-11-02 14:07:44 +03:00
|
|
|
* This describes a command handled by the SCSI controller
|
2012-08-24 13:01:22 +04:00
|
|
|
* These are chained in either a free list or an active list
|
2002-04-22 02:52:05 +04:00
|
|
|
* We have one queue per target
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct esiop_cmd {
|
|
|
|
TAILQ_ENTRY (esiop_cmd) next;
|
|
|
|
struct siop_common_cmd cmd_c;
|
|
|
|
struct esiop_cbd *esiop_cbdp; /* pointer to our siop_cbd */
|
|
|
|
};
|
|
|
|
#define cmd_tables cmd_c.siop_tables
|
|
|
|
|
|
|
|
/* command block descriptors: an array of siop_cmd + an array of siop_xfer */
|
|
|
|
struct esiop_cbd {
|
|
|
|
TAILQ_ENTRY (esiop_cbd) next;
|
|
|
|
struct esiop_cmd *cmds;
|
|
|
|
struct esiop_xfer *xfers;
|
|
|
|
bus_dmamap_t xferdma; /* DMA map for this block of xfers */
|
|
|
|
};
|
|
|
|
|
2002-04-22 19:53:39 +04:00
|
|
|
TAILQ_HEAD(cmd_list, esiop_cmd);
|
|
|
|
TAILQ_HEAD(cbd_list, esiop_cbd);
|
|
|
|
|
|
|
|
/* DSA table descriptor for tags. Free tables are in a list */
|
|
|
|
struct esiop_dsatbl {
|
|
|
|
TAILQ_ENTRY (esiop_dsatbl) next;
|
2009-09-04 22:40:19 +04:00
|
|
|
uint32_t *tbl; /* the table itself */
|
|
|
|
uint32_t tbl_dsa; /* DSA of base of this table */
|
2002-04-22 19:53:39 +04:00
|
|
|
bus_addr_t tbl_offset; /* offset of this table in the map */
|
|
|
|
struct esiop_dsatblblk *tblblk; /* pointer back to our block */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* DSA table block descriptor. */
|
|
|
|
struct esiop_dsatblblk {
|
|
|
|
TAILQ_ENTRY (esiop_dsatblblk) next;
|
|
|
|
bus_dmamap_t blkmap; /* DMA map of this block */
|
|
|
|
};
|
|
|
|
|
|
|
|
TAILQ_HEAD(tbl_list, esiop_dsatbl);
|
|
|
|
TAILQ_HEAD(tblblk_list, esiop_dsatblblk);
|
|
|
|
|
|
|
|
/* Number of table per block */
|
2009-09-04 22:40:19 +04:00
|
|
|
#define ESIOP_NTPB ((PAGE_SIZE) / (sizeof(uint32_t) * ESIOP_NTAG))
|
2002-04-22 19:53:39 +04:00
|
|
|
|
2002-04-22 02:52:05 +04:00
|
|
|
/* per lun struct */
|
|
|
|
struct esiop_lun {
|
2002-04-22 19:53:39 +04:00
|
|
|
struct esiop_cmd *active; /* active non-tagged command */
|
|
|
|
struct esiop_cmd *tactive[ESIOP_NTAG]; /* active tagged commands */
|
|
|
|
int lun_flags; /* per-lun flags */
|
|
|
|
struct esiop_dsatbl *lun_tagtbl; /* the tag DSA table */
|
2002-04-22 02:52:05 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* per target struct; siop_common_cmd->target and siop_common_softc->targets[]
|
|
|
|
* will point to this
|
|
|
|
*/
|
|
|
|
struct esiop_target {
|
|
|
|
struct siop_common_target target_c;
|
|
|
|
struct esiop_lun *esiop_lun[8]; /* per-lun state */
|
2009-09-04 22:40:19 +04:00
|
|
|
uint32_t lun_table_offset; /* pointer to our DSA table */
|
2002-04-22 02:52:05 +04:00
|
|
|
};
|
|
|
|
|
2006-02-16 23:17:12 +03:00
|
|
|
static __inline void esiop_table_sync(struct esiop_cmd *, int);
|
|
|
|
static __inline void
|
2009-03-15 18:52:12 +03:00
|
|
|
esiop_table_sync(struct esiop_cmd *esiop_cmd, int ops)
|
2002-04-22 02:52:05 +04:00
|
|
|
{
|
|
|
|
struct siop_common_softc *sc = esiop_cmd->cmd_c.siop_sc;
|
|
|
|
bus_addr_t offset;
|
|
|
|
|
|
|
|
offset = esiop_cmd->cmd_c.dsa -
|
|
|
|
esiop_cmd->esiop_cbdp->xferdma->dm_segs[0].ds_addr;
|
|
|
|
bus_dmamap_sync(sc->sc_dmat, esiop_cmd->esiop_cbdp->xferdma, offset,
|
|
|
|
sizeof(struct esiop_xfer), ops);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Driver internal state */
|
|
|
|
struct esiop_softc {
|
|
|
|
struct siop_common_softc sc_c;
|
2009-09-04 22:40:19 +04:00
|
|
|
uint32_t sc_semoffset; /* semaphore */
|
|
|
|
uint32_t sc_shedoffset; /* base of scheduler ring */
|
2002-04-22 02:52:05 +04:00
|
|
|
int sc_currschedslot; /* current scheduler slot */
|
|
|
|
struct cbd_list cmds; /* list of command block descriptors */
|
|
|
|
struct cmd_list free_list; /* cmd descr free list */
|
2002-04-22 19:53:39 +04:00
|
|
|
struct tbl_list free_tagtbl; /* list of free tag DSA tables */
|
|
|
|
struct tblblk_list tag_tblblk; /* tag DSA table blocks */
|
2009-09-04 22:40:19 +04:00
|
|
|
uint32_t sc_flags;
|
|
|
|
uint32_t sc_free_offset; /* pointer to free RAM */
|
|
|
|
uint32_t sc_target_table_offset;/* pointer to target DSA table */
|
2002-04-27 21:39:51 +04:00
|
|
|
int sc_currdoneslot; /* current done slot */
|
|
|
|
bus_dmamap_t sc_done_map; /* dma map for done ring (shared) */
|
2009-09-04 22:29:52 +04:00
|
|
|
bus_addr_t sc_done_offset; /* offset of ring in sc_done_map */
|
2009-09-04 22:40:19 +04:00
|
|
|
uint32_t *sc_done_slot; /* The done ring itself */
|
2002-04-22 02:52:05 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* defs for sc_flags */
|
2003-11-02 14:07:44 +03:00
|
|
|
#define SCF_CHAN_NOSLOT 0x0001 /* channel out of scheduler slot */
|
2002-04-27 22:46:49 +04:00
|
|
|
#define SCF_CHAN_ADAPTREQ 0x0002 /* esiop_scsipi_request() is running */
|
2002-04-22 02:52:05 +04:00
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
void esiop_attach(struct esiop_softc *);
|
|
|
|
int esiop_intr(void *);
|
|
|
|
void esiop_add_dev(struct esiop_softc *, int, int);
|
|
|
|
void esiop_del_dev(struct esiop_softc *, int, int);
|