Home | History | Annotate | Line # | Download | only in i2o
iopvar.h revision 1.18.2.3
      1  1.18.2.3        ad /*	$NetBSD: iopvar.h,v 1.18.2.3 2007/07/15 15:52:43 ad Exp $	*/
      2       1.1        ad 
      3       1.1        ad /*-
      4      1.17        ad  * Copyright (c) 2000, 2001, 2002, 2007 The NetBSD Foundation, Inc.
      5       1.1        ad  * All rights reserved.
      6       1.1        ad  *
      7       1.1        ad  * This code is derived from software contributed to The NetBSD Foundation
      8       1.1        ad  * by Andrew Doran.
      9       1.1        ad  *
     10       1.1        ad  * Redistribution and use in source and binary forms, with or without
     11       1.1        ad  * modification, are permitted provided that the following conditions
     12       1.1        ad  * are met:
     13       1.1        ad  * 1. Redistributions of source code must retain the above copyright
     14       1.1        ad  *    notice, this list of conditions and the following disclaimer.
     15       1.1        ad  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1        ad  *    notice, this list of conditions and the following disclaimer in the
     17       1.1        ad  *    documentation and/or other materials provided with the distribution.
     18       1.1        ad  * 3. All advertising materials mentioning features or use of this software
     19       1.1        ad  *    must display the following acknowledgement:
     20       1.1        ad  *        This product includes software developed by the NetBSD
     21       1.1        ad  *        Foundation, Inc. and its contributors.
     22       1.1        ad  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23       1.1        ad  *    contributors may be used to endorse or promote products derived
     24       1.1        ad  *    from this software without specific prior written permission.
     25       1.1        ad  *
     26       1.1        ad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27       1.1        ad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28       1.1        ad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29       1.1        ad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30       1.1        ad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31       1.1        ad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32       1.1        ad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33       1.1        ad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34       1.1        ad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35       1.1        ad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36       1.1        ad  * POSSIBILITY OF SUCH DAMAGE.
     37       1.1        ad  */
     38       1.1        ad 
     39       1.1        ad #ifndef _I2O_IOPVAR_H_
     40       1.1        ad #define	_I2O_IOPVAR_H_
     41       1.1        ad 
     42      1.17        ad #include <sys/mutex.h>
     43      1.17        ad #include <sys/condvar.h>
     44      1.17        ad 
     45       1.1        ad /*
     46       1.1        ad  * Transfer descriptor.
     47       1.1        ad  */
     48       1.1        ad struct iop_xfer {
     49       1.1        ad 	bus_dmamap_t	ix_map;
     50       1.1        ad 	u_int		ix_size;
     51       1.1        ad 	u_int		ix_flags;
     52       1.1        ad };
     53       1.1        ad #define	IX_IN			0x0001	/* Data transfer from IOP */
     54       1.1        ad #define	IX_OUT			0x0002	/* Data transfer to IOP */
     55       1.1        ad 
     56       1.1        ad /*
     57       1.1        ad  * Message wrapper.
     58       1.1        ad  */
     59       1.1        ad struct iop_msg {
     60       1.5        ad 	SLIST_ENTRY(iop_msg)	im_chain;	/* Next free message */
     61       1.1        ad 	u_int			im_flags;	/* Control flags */
     62       1.1        ad 	u_int			im_tctx;	/* Transaction context */
     63       1.1        ad 	void			*im_dvcontext;	/* Un*x device context */
     64       1.5        ad 	struct i2o_reply	*im_rb;		/* Reply buffer */
     65  1.18.2.2        ad 	kcondvar_t		im_cv;		/* Notifier */
     66       1.5        ad 	u_int			im_reqstatus;	/* Status from reply */
     67      1.15     perry 	u_int			im_detstatus;	/* Detailed status code */
     68       1.1        ad 	struct iop_xfer		im_xfer[IOP_MAX_MSG_XFERS];
     69       1.1        ad };
     70       1.1        ad #define	IM_SYSMASK		0x00ff
     71       1.1        ad #define	IM_REPLIED		0x0001	/* Message has been replied to */
     72       1.1        ad #define	IM_ALLOCED		0x0002	/* This message wrapper is allocated */
     73       1.5        ad #define	IM_SGLOFFADJ		0x0004	/* S/G list offset adjusted */
     74      1.15     perry #define	IM_FAIL			0x0008	/* Transaction error returned */
     75       1.1        ad 
     76       1.1        ad #define	IM_USERMASK		0xff00
     77       1.5        ad #define	IM_WAIT			0x0100	/* Wait (sleep) for completion */
     78       1.5        ad #define	IM_POLL			0x0200	/* Wait (poll) for completion */
     79       1.5        ad #define	IM_NOSTATUS		0x0400	/* Don't check status if waiting */
     80       1.6        ad #define	IM_POLL_INTR		0x0800	/* Do send interrupt when polling */
     81       1.1        ad 
     82       1.1        ad struct iop_initiator {
     83       1.3        ad 	LIST_ENTRY(iop_initiator) ii_list;
     84       1.3        ad 	LIST_ENTRY(iop_initiator) ii_hash;
     85       1.3        ad 
     86       1.3        ad 	void	(*ii_intr)(struct device *, struct iop_msg *, void *);
     87       1.3        ad 	int	(*ii_reconfig)(struct device *);
     88       1.5        ad 	void	(*ii_adjqparam)(struct device *, int);
     89       1.5        ad 
     90       1.1        ad 	struct	device *ii_dv;
     91  1.18.2.2        ad 	kcondvar_t ii_cv;
     92       1.1        ad 	int	ii_flags;
     93       1.3        ad 	int	ii_ictx;		/* Initiator context */
     94       1.3        ad 	int	ii_tid;
     95       1.1        ad };
     96       1.7        ad #define	II_NOTCTX	0x0001	/* No transaction context */
     97       1.3        ad #define	II_CONFIGURED	0x0002	/* Already configured */
     98       1.5        ad #define	II_UTILITY	0x0004	/* Utility initiator (not a real device) */
     99       1.1        ad 
    100       1.1        ad #define	IOP_ICTX	0
    101       1.5        ad #define	IOP_INIT_CODE	0x80
    102       1.5        ad 
    103       1.5        ad /*
    104       1.5        ad  * Parameter group op (for async parameter retrievals).
    105       1.5        ad  */
    106       1.5        ad struct iop_pgop {
    107       1.5        ad 	struct	i2o_param_op_list_header olh;
    108       1.5        ad 	struct	i2o_param_op_all_template oat;
    109       1.5        ad } __attribute__ ((__packed__));
    110       1.1        ad 
    111       1.1        ad /*
    112       1.1        ad  * Per-IOP context.
    113       1.1        ad  */
    114       1.1        ad struct iop_softc {
    115       1.7        ad 	struct device	sc_dv;		/* Generic device data */
    116       1.7        ad 	bus_space_handle_t sc_ioh;	/* Bus space handle */
    117       1.7        ad 	bus_space_tag_t	sc_iot;		/* Bus space tag */
    118       1.7        ad 	bus_dma_tag_t	sc_dmat;	/* Bus DMA tag */
    119      1.12        ad 	bus_space_handle_t sc_msg_ioh;	/* Message queue bus space handle */
    120      1.12        ad 	bus_space_tag_t	sc_msg_iot;	/* Message queue bus space tag */
    121       1.7        ad 	void	 	*sc_ih;		/* Interrupt handler cookie */
    122       1.7        ad 
    123       1.7        ad 	struct iop_msg	*sc_ims;	/* Message wrappers */
    124       1.7        ad 	SLIST_HEAD(, iop_msg) sc_im_freelist; /* Free wrapper list */
    125  1.18.2.2        ad 	kmutex_t	sc_intrlock;	/* Interrupt level lock */
    126       1.7        ad 
    127       1.7        ad 	bus_dmamap_t	sc_rep_dmamap;	/* Reply frames DMA map */
    128       1.7        ad 	int		sc_rep_size;	/* Reply frames size */
    129       1.7        ad 	bus_addr_t	sc_rep_phys;	/* Reply frames PA */
    130      1.18  christos 	void *		sc_rep;		/* Reply frames VA */
    131       1.7        ad 
    132       1.7        ad 	int		sc_maxib;	/* Max inbound (-> IOP) queue depth */
    133       1.7        ad 	int		sc_maxob;	/* Max outbound (<- IOP) queue depth */
    134       1.7        ad 	int		sc_curib;	/* Current inbound queue depth */
    135      1.10        ad 	int		sc_framesize;	/* Max msg frame size in bytes */
    136       1.7        ad 
    137       1.7        ad 	struct i2o_hrt	*sc_hrt;	/* Hardware resource table */
    138       1.7        ad 	struct iop_tidmap *sc_tidmap;	/* TID map (per-LCT-entry flags) */
    139       1.7        ad 	struct i2o_lct	*sc_lct;	/* Logical configuration table */
    140       1.7        ad 	int		sc_nlctent;	/* Number of LCT entries */
    141       1.1        ad 	int		sc_flags;	/* IOP-wide flags */
    142       1.7        ad 	u_int32_t	sc_chgind;	/* Configuration change indicator */
    143      1.17        ad 	kmutex_t	sc_conflock;	/* Configuration lock */
    144      1.17        ad 	kcondvar_t	sc_confcv;	/* Configuration CV */
    145  1.18.2.3        ad 	lwp_t		*sc_reconf_thread;/* Auto reconfiguration process */
    146       1.7        ad 	LIST_HEAD(, iop_initiator) sc_iilist;/* Initiator list */
    147       1.7        ad 	int		sc_nii;		/* Total number of initiators */
    148       1.7        ad 	int		sc_nuii;	/* Number of utility initiators */
    149       1.7        ad 
    150       1.3        ad 	struct iop_initiator sc_eventii;/* IOP event handler */
    151       1.7        ad 	bus_dmamap_t	sc_scr_dmamap;  /* Scratch DMA map */
    152       1.7        ad 	bus_dma_segment_t sc_scr_seg[1];/* Scratch DMA segment */
    153      1.18  christos 	void *		sc_scr;		/* Scratch memory VA */
    154       1.7        ad 
    155       1.7        ad 	bus_space_tag_t	sc_bus_memt;	/* Parent bus memory tag */
    156       1.7        ad 	bus_space_tag_t	sc_bus_iot;	/* Parent but I/O tag */
    157       1.7        ad 	bus_addr_t	sc_memaddr;	/* Register window address */
    158       1.7        ad 	bus_size_t	sc_memsize;	/* Register window size */
    159       1.9        ad 	int		sc_pcibus;	/* PCI bus number */
    160       1.9        ad 	int		sc_pcidev;	/* PCI device number */
    161       1.5        ad 
    162       1.7        ad 	struct i2o_status sc_status;	/* Last retrieved status record */
    163       1.1        ad };
    164       1.1        ad #define	IOP_OPEN		0x01	/* Device interface open */
    165       1.3        ad #define	IOP_HAVESTATUS		0x02	/* Successfully retrieved status */
    166       1.3        ad #define	IOP_ONLINE		0x04	/* Can use ioctl interface */
    167       1.1        ad 
    168       1.1        ad struct iop_attach_args {
    169       1.1        ad 	int	ia_class;		/* device class */
    170       1.1        ad 	int	ia_tid;			/* target ID */
    171       1.1        ad };
    172       1.1        ad 
    173       1.3        ad void	iop_init(struct iop_softc *, const char *);
    174       1.1        ad int	iop_intr(void *);
    175       1.3        ad int	iop_lct_get(struct iop_softc *);
    176       1.5        ad int	iop_print_ident(struct iop_softc *, int);
    177       1.9        ad int	iop_post(struct iop_softc *, u_int32_t *);
    178       1.9        ad int	iop_reconfigure(struct iop_softc *, u_int);
    179       1.9        ad int	iop_status_get(struct iop_softc *, int);
    180       1.3        ad int	iop_simple_cmd(struct iop_softc *, int, int, int, int, int);
    181       1.3        ad void	iop_strvis(struct iop_softc *, const char *, int, char *, int);
    182       1.1        ad 
    183       1.5        ad void	iop_initiator_register(struct iop_softc *, struct iop_initiator *);
    184       1.1        ad void	iop_initiator_unregister(struct iop_softc *, struct iop_initiator *);
    185       1.1        ad 
    186       1.7        ad struct	iop_msg *iop_msg_alloc(struct iop_softc *, int);
    187       1.5        ad void	iop_msg_free(struct iop_softc *, struct iop_msg *);
    188       1.5        ad int	iop_msg_map(struct iop_softc *, struct iop_msg *, u_int32_t *, void *,
    189       1.7        ad 		    int, int, struct proc *);
    190       1.5        ad int	iop_msg_map_bio(struct iop_softc *, struct iop_msg *, u_int32_t *,
    191       1.5        ad 			void *, int, int);
    192       1.5        ad int	iop_msg_post(struct iop_softc *, struct iop_msg *, void *, int);
    193       1.1        ad void	iop_msg_unmap(struct iop_softc *, struct iop_msg *);
    194       1.8        ad 
    195       1.8        ad int	iop_field_get_all(struct iop_softc *, int, int, void *, int,
    196       1.8        ad 			  struct iop_initiator *);
    197       1.8        ad int	iop_field_set(struct iop_softc *, int, int, void *, int, int);
    198       1.8        ad int	iop_table_add_row(struct iop_softc *, int, int, void *, int, int);
    199       1.8        ad int	iop_table_clear(struct iop_softc *, int, int);
    200       1.8        ad int	iop_table_del_row(struct iop_softc *, int, int, int);
    201       1.8        ad int	iop_table_get_row(struct iop_softc *, int, int, void *, int, int);
    202       1.1        ad 
    203       1.3        ad int	iop_util_abort(struct iop_softc *, struct iop_initiator *, int, int,
    204       1.3        ad 		      int);
    205       1.3        ad int	iop_util_claim(struct iop_softc *, struct iop_initiator *, int, int);
    206       1.3        ad int	iop_util_eventreg(struct iop_softc *, struct iop_initiator *, int);
    207       1.1        ad 
    208       1.1        ad #endif	/* !_I2O_IOPVAR_H_ */
    209