1139749Simp/*- 251673Smdodd * Copyright (c) 1993 Herb Peyerl (hpeyerl@novatel.ca) All rights reserved. 351673Smdodd * 451673Smdodd * Redistribution and use in source and binary forms, with or without 551673Smdodd * modification, are permitted provided that the following conditions are 651673Smdodd * met: 1. Redistributions of source code must retain the above copyright 751673Smdodd * notice, this list of conditions and the following disclaimer. 2. The name 851673Smdodd * of the author may not be used to endorse or promote products derived from 951673Smdodd * this software without specific prior written permission 1051673Smdodd * 1151673Smdodd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 1251673Smdodd * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1351673Smdodd * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 1451673Smdodd * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1551673Smdodd * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 1651673Smdodd * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 1751673Smdodd * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 1851673Smdodd * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 1951673Smdodd * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 2051673Smdodd * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2151673Smdodd * 2251673Smdodd * $FreeBSD$ 2351673Smdodd */ 2451673Smdodd 2552549Smdoddstruct ep_board { 26117700Smarkm u_short prod_id; /* product ID */ 27117700Smarkm int cmd_off; /* command offset (bit shift) */ 28117700Smarkm int mii_trans; /* activate MII transiever */ 29117700Smarkm u_short res_cfg; /* resource configuration */ 3052549Smdodd}; 3152549Smdodd 3251673Smdodd/* 3351673Smdodd * Ethernet software status per interface. 3451673Smdodd */ 3551673Smdoddstruct ep_softc { 36147256Sbrooks struct ifnet *ifp; 37117700Smarkm struct ifmedia ifmedia; /* media info */ 38117700Smarkm device_t dev; 3952549Smdodd 40121492Simp struct mtx sc_mtx; 41117700Smarkm struct resource *iobase; 42117700Smarkm struct resource *irq; 4352549Smdodd 44121231Simp bus_space_handle_t bsh; 45121231Simp bus_space_tag_t bst; 46117700Smarkm void *ep_intrhand; 4752549Smdodd 48199559Sjhb struct callout watchdog_timer; 49199559Sjhb int tx_timer; 50199559Sjhb 51117700Smarkm u_short ep_connectors; /* Connectors on this card. */ 52117700Smarkm u_char ep_connector; /* Configured connector. */ 5352549Smdodd 54117700Smarkm struct mbuf *top; 55117700Smarkm struct mbuf *mcur; 56117700Smarkm short cur_len; 5752549Smdodd 58117700Smarkm int stat; /* some flags */ 5952549Smdodd#define F_RX_FIRST 0x001 60147715Simp#define F_ENADDR_SKIP 0x002 6152549Smdodd#define F_PROMISC 0x008 6251673Smdodd#define F_ACCESS_32_BITS 0x100 63190908Simp#define F_HAS_TX_PLL 0x200 6451673Smdodd 65117700Smarkm int gone; /* adapter is not present (for PCCARD) */ 66117700Smarkm struct ep_board epb; 67147715Simp uint8_t eaddr[6]; 6851673Smdodd 6951673Smdodd#ifdef EP_LOCAL_STATS 70117700Smarkm short tx_underrun; 71117700Smarkm short rx_no_first; 72117700Smarkm short rx_no_mbuf; 73117700Smarkm short rx_overrunf; 74117700Smarkm short rx_overrunl; 7551673Smdodd#endif 7651673Smdodd}; 7751673Smdodd 78117700Smarkmint ep_alloc(device_t); 79117700Smarkmvoid ep_free(device_t); 80117700Smarkmint ep_detach(device_t); 81117700Smarkmvoid ep_get_media(struct ep_softc *); 82117700Smarkmint ep_attach(struct ep_softc *); 83117700Smarkmvoid ep_intr(void *); 84147607Simpint ep_get_e(struct ep_softc *, uint16_t, uint16_t *); 85121206Simp 86121492Simp#define CSR_READ_1(sc, off) (bus_space_read_1((sc)->bst, (sc)->bsh, off)) 87121492Simp#define CSR_READ_2(sc, off) (bus_space_read_2((sc)->bst, (sc)->bsh, off)) 88121492Simp#define CSR_WRITE_1(sc, off, val) \ 89121249Simp bus_space_write_1(sc->bst, sc->bsh, off, val) 90121492Simp#define CSR_WRITE_2(sc, off, val) \ 91121249Simp bus_space_write_2(sc->bst, sc->bsh, off, val) 92121492Simp#define CSR_WRITE_MULTI_1(sc, off, addr, count) \ 93121249Simp bus_space_write_multi_1(sc->bst, sc->bsh, off, addr, count) 94121492Simp#define CSR_WRITE_MULTI_2(sc, off, addr, count) \ 95121249Simp bus_space_write_multi_2(sc->bst, sc->bsh, off, addr, count) 96121492Simp#define CSR_WRITE_MULTI_4(sc, off, addr, count) \ 97121249Simp bus_space_write_multi_4(sc->bst, sc->bsh, off, addr, count) 98121492Simp#define CSR_READ_MULTI_1(sc, off, addr, count) \ 99121249Simp bus_space_read_multi_1(sc->bst, sc->bsh, off, addr, count) 100121492Simp#define CSR_READ_MULTI_2(sc, off, addr, count) \ 101121249Simp bus_space_read_multi_2(sc->bst, sc->bsh, off, addr, count) 102121492Simp#define CSR_READ_MULTI_4(sc, off, addr, count) \ 103121249Simp bus_space_read_multi_4(sc->bst, sc->bsh, off, addr, count) 104121492Simp 105121492Simp#define EP_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) 106121492Simp#define EP_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) 107121515Simp#define EP_LOCK_INIT(_sc) \ 108121515Simp mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->dev), \ 109121515Simp MTX_NETWORK_LOCK, MTX_DEF) 110148164Simp#define EP_LOCK_DESTROY(_sc) mtx_destroy(&_sc->sc_mtx); 111121515Simp#define EP_ASSERT_LOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_OWNED); 112121515Simp#define EP_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_NOTOWNED); 113