if_snvar.h revision 147797
1279264Sdelphij/*- 2238405Sjkim * Copyright (c) 1999 M. Warner Losh <imp@village.org> 3238405Sjkim * All rights reserved. 4238405Sjkim * 5238405Sjkim * Redistribution and use in source and binary forms, with or without 6238405Sjkim * modification, are permitted provided that the following conditions 7238405Sjkim * are met: 8238405Sjkim * 1. Redistributions of source code must retain the above copyright 9238405Sjkim * notice, this list of conditions and the following disclaimer. 10238405Sjkim * 2. Redistributions in binary form must reproduce the above copyright 11238405Sjkim * notice, this list of conditions and the following disclaimer in the 12238405Sjkim * documentation and/or other materials provided with the distribution. 13238405Sjkim * 14238405Sjkim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15238405Sjkim * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16238405Sjkim * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17238405Sjkim * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18238405Sjkim * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19238405Sjkim * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20238405Sjkim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21238405Sjkim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22238405Sjkim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23238405Sjkim * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24238405Sjkim * 25238405Sjkim * $FreeBSD: head/sys/dev/sn/if_snvar.h 147797 2005-07-06 15:59:47Z imp $ 26238405Sjkim */ 27238405Sjkim 28238405Sjkim#ifndef _IF_SNVAR_H 29238405Sjkim#define _IF_SNVAR_H 30238405Sjkim 31238405Sjkim#include <net/if_arp.h> 32238405Sjkim 33238405Sjkimstruct sn_softc { 34238405Sjkim struct ifnet *ifp; 35238405Sjkim bus_space_tag_t bst; 36238405Sjkim bus_space_handle_t bsh; 37238405Sjkim struct mtx sc_mtx; 38238405Sjkim int pages_wanted; /* Size of outstanding MMU ALLOC */ 39238405Sjkim int intr_mask; /* Most recently set interrupt mask */ 40238405Sjkim device_t dev; 41279264Sdelphij void *intrhand; 42279264Sdelphij struct resource *irq_res; 43238405Sjkim int irq_rid; 44238405Sjkim struct resource *port_res; 45238405Sjkim int port_rid; 46238405Sjkim}; 47238405Sjkim 48238405Sjkimint sn_probe(device_t); 49238405Sjkimint sn_attach(device_t); 50238405Sjkimint sn_detach(device_t); 51238405Sjkimvoid sn_intr(void *); 52238405Sjkim 53279264Sdelphijint sn_activate(device_t); 54279264Sdelphijvoid sn_deactivate(device_t); 55279264Sdelphij 56238405Sjkim#define CSR_READ_1(sc, off) (bus_space_read_1((sc)->bst, (sc)->bsh, off)) 57279264Sdelphij#define CSR_READ_2(sc, off) (bus_space_read_2((sc)->bst, (sc)->bsh, off)) 58279264Sdelphij#define CSR_WRITE_1(sc, off, val) \ 59279264Sdelphij bus_space_write_1(sc->bst, sc->bsh, off, val) 60279264Sdelphij#define CSR_WRITE_2(sc, off, val) \ 61279264Sdelphij bus_space_write_2(sc->bst, sc->bsh, off, val) 62279264Sdelphij#define CSR_WRITE_MULTI_1(sc, off, addr, count) \ 63238405Sjkim bus_space_write_multi_1(sc->bst, sc->bsh, off, addr, count) 64279264Sdelphij#define CSR_WRITE_MULTI_2(sc, off, addr, count) \ 65279264Sdelphij bus_space_write_multi_2(sc->bst, sc->bsh, off, addr, count) 66279264Sdelphij#define CSR_READ_MULTI_1(sc, off, addr, count) \ 67279264Sdelphij bus_space_read_multi_1(sc->bst, sc->bsh, off, addr, count) 68279264Sdelphij#define CSR_READ_MULTI_2(sc, off, addr, count) \ 69238405Sjkim bus_space_read_multi_2(sc->bst, sc->bsh, off, addr, count) 70279264Sdelphij 71238405Sjkim#define SN_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) 72238405Sjkim#define SN_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) 73238405Sjkim#define SN_LOCK_INIT(_sc) \ 74238405Sjkim mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->dev), \ 75238405Sjkim MTX_NETWORK_LOCK, MTX_DEF) 76238405Sjkim#define SN_LOCK_DESTORY(_sc) mtx_destroy(&_sc->sc_mtx); 77238405Sjkim#define SN_ASSERT_LOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_OWNED); 78238405Sjkim#define SN_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_NOTOWNED); 79238405Sjkim 80238405Sjkim#endif /* _IF_SNVAR_H */ 81238405Sjkim