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