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