if_sbnivar.h revision 147256
1132718Skan/*- 2146895Skan * Copyright (c) 1997-2001 Granch, Ltd. All rights reserved. 3169689Skan * Author: Denis I.Timofeev <timofeev@granch.ru> 4132718Skan * 5132718Skan * Redistributon and use in source and binary forms, with or without 6132718Skan * modification, are permitted provided that the following conditions 7132718Skan * are met: 8132718Skan * 1. Redistributions of source code must retain the above copyright 9132718Skan * notice unmodified, this list of conditions, and the following 10132718Skan * disclaimer. 11132718Skan * 2. Redistributions in binary form must reproduce the above copyright 12132718Skan * notice, this list of conditions and the following disclaimer in the 13132718Skan * documentation and/or other materials provided with the distribution. 14132718Skan * 15132718Skan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16132718Skan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17132718Skan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18132718Skan * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19132718Skan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20169689Skan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21169689Skan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22132718Skan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23132718Skan * LIABILITY, OR TORT (INCLUDING NEIGENCE OR OTHERWISE) ARISING IN ANY WAY 24132718Skan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25132718Skan * SUCH DAMAGE. 26132718Skan * 27132718Skan * $FreeBSD: head/sys/dev/sbni/if_sbnivar.h 147256 2005-06-10 16:49:24Z brooks $ 28132718Skan */ 29132718Skan 30132718Skan/* 31132718Skan * SBNI12 definitions 32132718Skan */ 33132718Skan 34132718Skan/* 35132718Skan * CONFIGURATION PARAMETER: 36132718Skan * 37132718Skan * Uncomment this if you want to use model SBNI12D-11/ISA with same IRQ 38169689Skan * for both first and second channels. 39169689Skan */ 40169689Skan#define SBNI_DUAL_COMPOUND 1 41261188Spfg 42261188Spfg#define SBNI_DEBUG 0 43132718Skan 44132718Skan#if SBNI_DEBUG 45132718Skan#define DP(A) A 46132718Skan#else 47169689Skan#define DP(A) 48169689Skan#endif 49132718Skan 50169689Skanstruct sbni_in_stats { 51169689Skan u_int32_t all_rx_number; 52132718Skan u_int32_t bad_rx_number; 53169689Skan u_int32_t timeout_number; 54169689Skan u_int32_t all_tx_number; 55169689Skan u_int32_t resend_tx_number; 56169689Skan}; 57169689Skan 58169689Skanstruct sbni_flags { 59169689Skan u_int mac_addr : 24; 60169689Skan u_int rxl : 4; 61169689Skan u_int rate : 2; 62169689Skan u_int fixed_rxl : 1; 63132718Skan u_int fixed_rate : 1; 64132718Skan}; 65132718Skan 66132718Skan 67132718Skan#ifdef _KERNEL /* to avoid compile this decls with sbniconfig */ 68132718Skan 69132718Skanstruct sbni_softc { 70132718Skan struct ifnet *ifp; 71132718Skan u_char enaddr[6]; 72132718Skan 73132718Skan int io_rid; 74132718Skan struct resource *io_res; 75169689Skan int io_off; 76169689Skan 77169689Skan int irq_rid; 78169689Skan struct resource *irq_res; 79169689Skan void *irq_handle; 80169689Skan 81169689Skan struct mbuf *rx_buf_p; /* receive buffer ptr */ 82169689Skan struct mbuf *tx_buf_p; /* transmit buffer ptr */ 83169689Skan 84169689Skan u_int pktlen; /* length of transmitting pkt */ 85169689Skan u_int framelen; /* current frame length */ 86169689Skan u_int maxframe; /* maximum valid frame length */ 87132718Skan u_int state; 88169689Skan u_int inppos; /* positions in rx/tx buffers */ 89169689Skan u_int outpos; /* positions in rx/tx buffers */ 90169689Skan 91169689Skan /* transmitting frame number - from frames qty to 1 */ 92169689Skan u_int tx_frameno; 93169689Skan 94132718Skan /* expected number of next receiving frame */ 95132718Skan u_int wait_frameno; 96132718Skan 97132718Skan /* count of failed attempts to frame send - 32 attempts do before 98169689Skan error - while receiver tunes on opposite side of wire */ 99169689Skan u_int trans_errors; 100169689Skan 101169689Skan /* idle time; send pong when limit exceeded */ 102132718Skan u_int timer_ticks; 103169689Skan 104132718Skan /* fields used for receive level autoselection */ 105169689Skan int delta_rxl; 106169689Skan u_int cur_rxl_index; 107169689Skan u_int timeout_rxl; 108169689Skan u_int32_t cur_rxl_rcvd; 109169689Skan u_int32_t prev_rxl_rcvd; 110169689Skan 111169689Skan struct sbni_csr1 csr1; /* current value of CSR1 */ 112132718Skan struct sbni_in_stats in_stats; /* internal statistics */ 113132718Skan 114132718Skan struct callout_handle wch; 115169689Skan 116169689Skan struct sbni_softc *slave_sc; 117132718Skan 118132718Skan#ifdef SBNI_DUAL_COMPOUND 119132718Skan struct sbni_softc *link; 120169689Skan#endif 121169689Skan}; 122169689Skan 123169689Skanvoid sbni_intr(void *); 124169689Skanint sbni_probe(struct sbni_softc *); 125169689Skanvoid sbni_attach(struct sbni_softc *, int, struct sbni_flags); 126169689Skan 127169689Skanextern u_int32_t next_sbni_unit; 128169689Skan 129169689Skan#ifdef SBNI_DUAL_COMPOUND 130169689Skanextern struct sbni_softc *sbni_headlist; 131169689Skan 132132718Skanstruct sbni_softc *connect_to_master(struct sbni_softc *); 133169689Skan#endif 134132718Skan#endif /* _KERNEL */ 135132718Skan 136132718Skan/* 137169689Skan * SBNI socket ioctl params 138169689Skan */ 139169689Skan#define SIOCGHWFLAGS _IOWR('i', 62, struct ifreq) /* get flags */ 140132718Skan#define SIOCSHWFLAGS _IOWR('i', 61, struct ifreq) /* set flags */ 141169689Skan#define SIOCGINSTATS _IOWR('i', 60, struct ifreq) /* get internal stats */ 142169689Skan#define SIOCRINSTATS _IOWR('i', 63, struct ifreq) /* reset internal stats */ 143132718Skan 144132718Skan 145132718Skan/* 146132718Skan * CRC-32 stuff 147169689Skan */ 148169689Skan#define CRC32(c,crc) (crc32tab[((size_t)(crc) ^ (c)) & 0xff] ^ (((crc) >> 8) & 0x00ffffff)) 149169689Skan /* CRC generator EDB88320 */ 150132718Skan /* CRC remainder 2144DF1C */ 151132718Skan /* CRC initial value 0 */ 152169689Skan#define CRC32_REMAINDER 0x2144df1c 153169689Skan#define CRC32_INITIAL 0x00000000 154169689Skan