if_snvar.h revision 147256
1/*-
2 * Copyright (c) 1999 M. Warner Losh <imp@village.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * $FreeBSD: head/sys/dev/sn/if_snvar.h 147256 2005-06-10 16:49:24Z brooks $
26 */
27
28#ifndef _IF_SNVAR_H
29#define _IF_SNVAR_H
30
31#include <net/if_arp.h>
32
33struct sn_softc {
34	struct ifnet    *ifp;
35	bus_space_tag_t	bst;
36	bus_space_handle_t bsh;
37	struct mtx sc_mtx;
38	int             pages_wanted;	/* Size of outstanding MMU ALLOC */
39	int             intr_mask;	/* Most recently set interrupt mask */
40	device_t	dev;
41	void		*intrhand;
42	struct resource *irq_res;
43	int		irq_rid;
44	struct resource	*port_res;
45	int		port_rid;
46	int		pccard_enaddr;	/* MAC address in pccard CIS tupple */
47};
48
49int	sn_probe(device_t, int);
50int	sn_attach(device_t);
51int	sn_detach(device_t);
52void	sn_intr(void *);
53
54int	sn_activate(device_t);
55void	sn_deactivate(device_t);
56
57#define CSR_READ_1(sc, off) (bus_space_read_1((sc)->bst, (sc)->bsh, off))
58#define CSR_READ_2(sc, off) (bus_space_read_2((sc)->bst, (sc)->bsh, off))
59#define CSR_WRITE_1(sc, off, val) \
60	bus_space_write_1(sc->bst, sc->bsh, off, val)
61#define CSR_WRITE_2(sc, off, val) \
62	bus_space_write_2(sc->bst, sc->bsh, off, val)
63#define CSR_WRITE_MULTI_1(sc, off, addr, count) \
64	bus_space_write_multi_1(sc->bst, sc->bsh, off, addr, count)
65#define CSR_WRITE_MULTI_2(sc, off, addr, count) \
66	bus_space_write_multi_2(sc->bst, sc->bsh, off, addr, count)
67#define CSR_READ_MULTI_1(sc, off, addr, count) \
68	bus_space_read_multi_1(sc->bst, sc->bsh, off, addr, count)
69#define CSR_READ_MULTI_2(sc, off, addr, count) \
70	bus_space_read_multi_2(sc->bst, sc->bsh, off, addr, count)
71
72#define SN_LOCK(_sc)		mtx_lock(&(_sc)->sc_mtx)
73#define	SN_UNLOCK(_sc)		mtx_unlock(&(_sc)->sc_mtx)
74#define SN_LOCK_INIT(_sc) \
75	mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->dev), \
76	    MTX_NETWORK_LOCK, MTX_DEF)
77#define SN_LOCK_DESTORY(_sc)	mtx_destroy(&_sc->sc_mtx);
78#define SN_ASSERT_LOCKED(_sc)	mtx_assert(&_sc->sc_mtx, MA_OWNED);
79#define SN_ASSERT_UNLOCKED(_sc)	mtx_assert(&_sc->sc_mtx, MA_NOTOWNED);
80
81#endif /* _IF_SNVAR_H */
82