]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/dev/ep/if_epvar.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / dev / ep / if_epvar.h
1 /*-
2  * Copyright (c) 1993 Herb Peyerl (hpeyerl@novatel.ca) All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: 1. Redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer. 2. The name
8  * of the author may not be used to endorse or promote products derived from
9  * this software without specific prior written permission
10  *
11  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
12  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
14  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
16  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
17  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
18  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
19  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
20  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21  *
22  * $FreeBSD$
23  */
24
25 struct ep_board {
26         u_short prod_id;        /* product ID */
27         int cmd_off;            /* command offset (bit shift) */
28         int mii_trans;          /* activate MII transiever */
29         u_short res_cfg;        /* resource configuration */
30 };
31
32 /*
33  * Ethernet software status per interface.
34  */
35 struct ep_softc {
36         struct ifnet *ifp;
37         struct ifmedia ifmedia; /* media info            */
38         device_t dev;
39
40         struct mtx sc_mtx;
41         struct resource *iobase;
42         struct resource *irq;
43
44         bus_space_handle_t bsh;
45         bus_space_tag_t bst;
46         void *ep_intrhand;
47
48         struct callout watchdog_timer;
49         int tx_timer;
50
51         u_short ep_connectors;  /* Connectors on this card. */
52         u_char ep_connector;    /* Configured connector. */
53
54         struct mbuf *top;
55         struct mbuf *mcur;
56         short cur_len;
57
58         int stat;               /* some flags */
59 #define F_RX_FIRST              0x001
60 #define F_ENADDR_SKIP           0x002
61 #define F_PROMISC               0x008
62 #define F_ACCESS_32_BITS        0x100
63 #define F_HAS_TX_PLL            0x200
64
65         int gone;               /* adapter is not present (for PCCARD) */
66         struct ep_board epb;
67         uint8_t eaddr[6];
68
69 #ifdef  EP_LOCAL_STATS
70         short tx_underrun;
71         short rx_no_first;
72         short rx_no_mbuf;
73         short rx_overrunf;
74         short rx_overrunl;
75 #endif
76 };
77
78 int ep_alloc(device_t);
79 void ep_free(device_t);
80 int ep_detach(device_t);
81 void ep_get_media(struct ep_softc *);
82 int ep_attach(struct ep_softc *);
83 void ep_intr(void *);
84 int ep_get_e(struct ep_softc *, uint16_t, uint16_t *);
85
86 #define CSR_READ_1(sc, off) (bus_space_read_1((sc)->bst, (sc)->bsh, off))
87 #define CSR_READ_2(sc, off) (bus_space_read_2((sc)->bst, (sc)->bsh, off))
88 #define CSR_WRITE_1(sc, off, val) \
89         bus_space_write_1(sc->bst, sc->bsh, off, val)
90 #define CSR_WRITE_2(sc, off, val) \
91         bus_space_write_2(sc->bst, sc->bsh, off, val)
92 #define CSR_WRITE_MULTI_1(sc, off, addr, count) \
93         bus_space_write_multi_1(sc->bst, sc->bsh, off, addr, count)
94 #define CSR_WRITE_MULTI_2(sc, off, addr, count) \
95         bus_space_write_multi_2(sc->bst, sc->bsh, off, addr, count)
96 #define CSR_WRITE_MULTI_4(sc, off, addr, count) \
97         bus_space_write_multi_4(sc->bst, sc->bsh, off, addr, count)
98 #define CSR_READ_MULTI_1(sc, off, addr, count) \
99         bus_space_read_multi_1(sc->bst, sc->bsh, off, addr, count)
100 #define CSR_READ_MULTI_2(sc, off, addr, count) \
101         bus_space_read_multi_2(sc->bst, sc->bsh, off, addr, count)
102 #define CSR_READ_MULTI_4(sc, off, addr, count) \
103         bus_space_read_multi_4(sc->bst, sc->bsh, off, addr, count)
104
105 #define EP_LOCK(_sc)            mtx_lock(&(_sc)->sc_mtx)
106 #define EP_UNLOCK(_sc)          mtx_unlock(&(_sc)->sc_mtx)
107 #define EP_LOCK_INIT(_sc) \
108         mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->dev), \
109             MTX_NETWORK_LOCK, MTX_DEF)
110 #define EP_LOCK_DESTROY(_sc)    mtx_destroy(&_sc->sc_mtx);
111 #define EP_ASSERT_LOCKED(_sc)   mtx_assert(&_sc->sc_mtx, MA_OWNED);
112 #define EP_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_NOTOWNED);