if_vxvar.h revision 199559
197403Sobrien/*-
297403Sobrien * Copyright (c) 1993 Herb Peyerl (hpeyerl@novatel.ca) All rights reserved.
397403Sobrien *
497403Sobrien * Redistribution and use in source and binary forms, with or without
597403Sobrien * modification, are permitted provided that the following conditions are
697403Sobrien * met: 1. Redistributions of source code must retain the above copyright
797403Sobrien * notice, this list of conditions and the following disclaimer. 2. The name
897403Sobrien * of the author may not be used to endorse or promote products derived from
997403Sobrien * this software without specific prior written permission
1097403Sobrien *
1197403Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
1297403Sobrien * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
1397403Sobrien * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
1497403Sobrien * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1597403Sobrien * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
1697403Sobrien * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
1797403Sobrien * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
18169691Skan * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
1997403Sobrien * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2097403Sobrien * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2197403Sobrien *
2297403Sobrien * $FreeBSD: head/sys/dev/vx/if_vxvar.h 199559 2009-11-19 22:06:40Z jhb $
2397403Sobrien *
2497403Sobrien October 2, 1994
2597403Sobrien
2697403Sobrien Modified by: Andres Vega Garcia
2797403Sobrien
2897403Sobrien INRIA - Sophia Antipolis, France
2997403Sobrien e-mail: avega@sophia.inria.fr
3097403Sobrien finger: avega@pax.inria.fr
3197403Sobrien
3297403Sobrien */
3397403Sobrien
3497403Sobrien/*
3597403Sobrien * Ethernet software status per interface.
3697403Sobrien */
3797403Sobrienstruct vx_softc {
3897403Sobrien	struct ifnet *vx_ifp;
3997403Sobrien	bus_space_tag_t vx_bst;
4097403Sobrien	bus_space_handle_t vx_bsh;
4197403Sobrien	void *vx_intrhand;
4297403Sobrien	struct resource *vx_irq;
4397403Sobrien	struct resource *vx_res;
44132720Skan#define MAX_MBS  8			/* # of mbufs we keep around	 */
45132720Skan	struct mbuf *vx_mb[MAX_MBS];	/* spare mbuf storage.		 */
4697403Sobrien	int vx_next_mb;			/* Which mbuf to use next. 	 */
4797403Sobrien	int vx_last_mb;			/* Last mbuf.			 */
4897403Sobrien	char vx_connectors;		/* Connectors on this card.	 */
4997403Sobrien	char vx_connector;		/* Connector to use.		 */
5097403Sobrien	short vx_tx_start_thresh;	/* Current TX_start_thresh.	 */
5197403Sobrien	int vx_tx_succ_ok;		/* # packets sent in sequence	 */
52132720Skan					/* w/o underrun			 */
53	struct callout vx_callout;	/* Callout for timeouts		 */
54	struct callout vx_watchdog;
55	struct mtx vx_mtx;
56	int vx_buffill_pending;
57	int vx_timer;
58};
59
60#define CSR_WRITE_4(sc, reg, val)	\
61	bus_space_write_4(sc->vx_bst, sc->vx_bsh, reg, val)
62#define CSR_WRITE_2(sc, reg, val)	\
63	bus_space_write_2(sc->vx_bst, sc->vx_bsh, reg, val)
64#define CSR_WRITE_1(sc, reg, val)	\
65	bus_space_write_1(sc->vx_bst, sc->vx_bsh, reg, val)
66
67#define CSR_READ_4(sc, reg)		\
68	bus_space_read_4(sc->vx_bst, sc->vx_bsh, reg)
69#define CSR_READ_2(sc, reg)		\
70	bus_space_read_2(sc->vx_bst, sc->vx_bsh, reg)
71#define CSR_READ_1(sc, reg)		\
72	bus_space_read_1(sc->vx_bst, sc->vx_bsh, reg)
73
74#define	VX_LOCK(sc)		mtx_lock(&(sc)->vx_mtx)
75#define	VX_UNLOCK(sc)		mtx_unlock(&(sc)->vx_mtx)
76#define	VX_LOCK_ASSERT(sc)	mtx_assert(&(sc)->vx_mtx, MA_OWNED)
77
78int	vx_attach(device_t);
79void	vx_stop(struct vx_softc *);
80void	vx_intr(void *);
81int	vx_busy_eeprom(struct vx_softc *);
82