Home | History | Annotate | Line # | Download | only in ic
mfivar.h revision 1.14.16.1
      1  1.14.16.1       riz /* $NetBSD: mfivar.h,v 1.14.16.1 2012/03/22 23:04:27 riz Exp $ */
      2        1.1    bouyer /* $OpenBSD: mfivar.h,v 1.28 2006/08/31 18:18:46 marco Exp $ */
      3        1.1    bouyer /*
      4        1.1    bouyer  * Copyright (c) 2006 Marco Peereboom <marco (at) peereboom.us>
      5        1.1    bouyer  *
      6        1.1    bouyer  * Permission to use, copy, modify, and distribute this software for any
      7        1.1    bouyer  * purpose with or without fee is hereby granted, provided that the above
      8        1.1    bouyer  * copyright notice and this permission notice appear in all copies.
      9        1.1    bouyer  *
     10        1.1    bouyer  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     11        1.1    bouyer  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     12        1.1    bouyer  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     13        1.1    bouyer  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     14        1.1    bouyer  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     15        1.1    bouyer  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     16        1.1    bouyer  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     17        1.1    bouyer  */
     18        1.1    bouyer 
     19        1.4    bouyer #include <dev/sysmon/sysmonvar.h>
     20        1.4    bouyer #include <sys/envsys.h>
     21        1.4    bouyer 
     22       1.12    dyoung #define DEVNAME(_s)     (device_xname((_s)->sc_dev))
     23        1.1    bouyer 
     24        1.7   xtraeme /* #define MFI_DEBUG */
     25        1.1    bouyer #ifdef MFI_DEBUG
     26        1.1    bouyer extern uint32_t			mfi_debug;
     27        1.1    bouyer #define DPRINTF(x...)		do { if (mfi_debug) printf(x); } while(0)
     28        1.1    bouyer #define DNPRINTF(n,x...)	do { if (mfi_debug & n) printf(x); } while(0)
     29        1.1    bouyer #define	MFI_D_CMD		0x0001
     30        1.1    bouyer #define	MFI_D_INTR		0x0002
     31        1.1    bouyer #define	MFI_D_MISC		0x0004
     32        1.1    bouyer #define	MFI_D_DMA		0x0008
     33        1.1    bouyer #define	MFI_D_IOCTL		0x0010
     34        1.1    bouyer #define	MFI_D_RW		0x0020
     35        1.1    bouyer #define	MFI_D_MEM		0x0040
     36        1.1    bouyer #define	MFI_D_CCB		0x0080
     37        1.1    bouyer #else
     38       1.10  gmcgarry #define DPRINTF(x, ...)
     39       1.10  gmcgarry #define DNPRINTF(n, x, ...)
     40        1.1    bouyer #endif
     41        1.1    bouyer 
     42        1.1    bouyer struct mfi_mem {
     43        1.1    bouyer 	bus_dmamap_t		am_map;
     44        1.1    bouyer 	bus_dma_segment_t	am_seg;
     45        1.1    bouyer 	size_t			am_size;
     46        1.3  christos 	void *			am_kva;
     47        1.1    bouyer };
     48        1.1    bouyer 
     49        1.1    bouyer #define MFIMEM_MAP(_am)		((_am)->am_map)
     50        1.1    bouyer #define MFIMEM_DVA(_am)		((_am)->am_map->dm_segs[0].ds_addr)
     51        1.1    bouyer #define MFIMEM_KVA(_am)		((void *)(_am)->am_kva)
     52        1.1    bouyer 
     53        1.1    bouyer struct mfi_prod_cons {
     54        1.1    bouyer 	uint32_t		mpc_producer;
     55        1.1    bouyer 	uint32_t		mpc_consumer;
     56        1.1    bouyer 	uint32_t		mpc_reply_q[1]; /* compensate for 1 extra reply per spec */
     57        1.1    bouyer };
     58        1.1    bouyer 
     59        1.1    bouyer struct mfi_ccb {
     60        1.1    bouyer 	struct mfi_softc	*ccb_sc;
     61        1.1    bouyer 
     62        1.1    bouyer 	union mfi_frame		*ccb_frame;
     63        1.1    bouyer 	paddr_t			ccb_pframe;
     64        1.1    bouyer 	uint32_t		ccb_frame_size;
     65        1.1    bouyer 	uint32_t		ccb_extra_frames;
     66        1.1    bouyer 
     67        1.1    bouyer 	struct mfi_sense	*ccb_sense;
     68        1.1    bouyer 	paddr_t			ccb_psense;
     69        1.1    bouyer 
     70        1.1    bouyer 	bus_dmamap_t		ccb_dmamap;
     71        1.1    bouyer 
     72        1.1    bouyer 	union mfi_sgl		*ccb_sgl;
     73        1.1    bouyer 
     74        1.1    bouyer 	/* data for sgl */
     75        1.1    bouyer 	void			*ccb_data;
     76        1.1    bouyer 	uint32_t		ccb_len;
     77        1.1    bouyer 
     78        1.1    bouyer 	uint32_t		ccb_direction;
     79        1.1    bouyer #define MFI_DATA_NONE	0
     80        1.1    bouyer #define MFI_DATA_IN	1
     81        1.1    bouyer #define MFI_DATA_OUT	2
     82        1.1    bouyer 
     83        1.1    bouyer 	struct scsipi_xfer	*ccb_xs;
     84        1.1    bouyer 
     85        1.1    bouyer 	void			(*ccb_done)(struct mfi_ccb *);
     86        1.1    bouyer 
     87        1.1    bouyer 	volatile enum {
     88        1.1    bouyer 		MFI_CCB_FREE,
     89        1.1    bouyer 		MFI_CCB_READY,
     90        1.1    bouyer 		MFI_CCB_DONE
     91        1.1    bouyer 	}			ccb_state;
     92        1.1    bouyer 	uint32_t		ccb_flags;
     93        1.1    bouyer #define MFI_CCB_F_ERR			(1<<0)
     94        1.1    bouyer 	TAILQ_ENTRY(mfi_ccb)	ccb_link;
     95        1.1    bouyer };
     96        1.1    bouyer 
     97        1.1    bouyer TAILQ_HEAD(mfi_ccb_list, mfi_ccb);
     98        1.1    bouyer 
     99        1.7   xtraeme enum mfi_iop {
    100        1.7   xtraeme 	MFI_IOP_XSCALE,
    101       1.14   msaitoh 	MFI_IOP_PPC,
    102  1.14.16.1       riz 	MFI_IOP_GEN2,
    103  1.14.16.1       riz 	MFI_IOP_SKINNY
    104        1.7   xtraeme };
    105        1.7   xtraeme 
    106        1.7   xtraeme struct mfi_iop_ops {
    107        1.7   xtraeme 	uint32_t 		(*mio_fw_state)(struct mfi_softc *);
    108       1.11    dyoung 	void 			(*mio_intr_dis)(struct mfi_softc *);
    109        1.7   xtraeme 	void 			(*mio_intr_ena)(struct mfi_softc *);
    110        1.7   xtraeme 	int 			(*mio_intr)(struct mfi_softc *);
    111        1.7   xtraeme 	void 			(*mio_post)(struct mfi_softc *, struct mfi_ccb *);
    112        1.7   xtraeme };
    113        1.7   xtraeme 
    114        1.1    bouyer struct mfi_softc {
    115       1.12    dyoung 	device_t		sc_dev;
    116        1.1    bouyer 	struct scsipi_channel	sc_chan;
    117        1.1    bouyer 	struct scsipi_adapter	sc_adapt;
    118        1.1    bouyer 
    119        1.7   xtraeme 	const struct mfi_iop_ops *sc_iop;
    120        1.7   xtraeme 
    121        1.1    bouyer 	void			*sc_ih;
    122        1.1    bouyer 
    123        1.7   xtraeme 	uint32_t		sc_flags;
    124        1.1    bouyer 
    125        1.1    bouyer 	bus_space_tag_t		sc_iot;
    126        1.1    bouyer 	bus_space_handle_t	sc_ioh;
    127        1.1    bouyer 	bus_dma_tag_t		sc_dmat;
    128       1.11    dyoung 	bus_size_t		sc_size;
    129        1.1    bouyer 
    130        1.1    bouyer 	/* save some useful information for logical drives that is missing
    131        1.1    bouyer 	 * in sc_ld_list
    132        1.1    bouyer 	 */
    133        1.1    bouyer 	struct {
    134        1.1    bouyer 		uint32_t	ld_present;
    135        1.1    bouyer 		char		ld_dev[16];	/* device name sd? */
    136        1.1    bouyer 	}			sc_ld[MFI_MAX_LD];
    137        1.1    bouyer 
    138        1.1    bouyer 	/* firmware determined max, totals and other information*/
    139        1.1    bouyer 	uint32_t		sc_max_cmds;
    140        1.1    bouyer 	uint32_t		sc_max_sgl;
    141        1.1    bouyer 	uint32_t		sc_max_ld;
    142        1.1    bouyer 	uint32_t		sc_ld_cnt;
    143        1.1    bouyer 	/* XXX these struct should be local to mgmt function */
    144        1.1    bouyer 	struct mfi_ctrl_info	sc_info;
    145        1.1    bouyer 	struct mfi_ld_list	sc_ld_list;
    146        1.1    bouyer 	struct mfi_ld_details	sc_ld_details;
    147        1.1    bouyer 
    148        1.1    bouyer 	/* all commands */
    149        1.1    bouyer 	struct mfi_ccb		*sc_ccb;
    150        1.1    bouyer 
    151        1.1    bouyer 	/* producer/consumer pointers and reply queue */
    152        1.1    bouyer 	struct mfi_mem		*sc_pcq;
    153        1.1    bouyer 
    154        1.1    bouyer 	/* frame memory */
    155        1.1    bouyer 	struct mfi_mem		*sc_frames;
    156        1.1    bouyer 	uint32_t		sc_frames_size;
    157        1.1    bouyer 
    158        1.1    bouyer 	/* sense memory */
    159        1.1    bouyer 	struct mfi_mem		*sc_sense;
    160        1.1    bouyer 
    161        1.1    bouyer 	struct mfi_ccb_list	sc_ccb_freeq;
    162        1.1    bouyer 
    163        1.6   xtraeme 	struct sysmon_envsys    *sc_sme;
    164        1.6   xtraeme 	envsys_data_t		*sc_sensor;
    165        1.4    bouyer 
    166       1.13    dyoung 	device_t		sc_child;
    167        1.1    bouyer };
    168        1.1    bouyer 
    169       1.13    dyoung int	mfi_rescan(device_t, const char *, const int *);
    170       1.13    dyoung void	mfi_childdetached(device_t, device_t);
    171       1.11    dyoung int	mfi_attach(struct mfi_softc *, enum mfi_iop);
    172       1.11    dyoung int	mfi_detach(struct mfi_softc *, int);
    173        1.1    bouyer int	mfi_intr(void *);
    174