6 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
8 * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * $Id: ng_bt3c_var.h,v 1.1 2002/11/24 19:46:54 max Exp $
35 * XXX XXX XX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
37 * Based on information obrained from: Jose Orlando Pereira <jop@di.uminho.pt>
38 * and disassembled w2k driver.
40 * XXX XXX XX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
44 #ifndef _NG_BT3C_VAR_H_
45 #define _NG_BT3C_VAR_H_
48 #define NG_BT3C_ALERT if (sc->debug >= NG_BT3C_ALERT_LEVEL) device_printf
49 #define NG_BT3C_ERR if (sc->debug >= NG_BT3C_ERR_LEVEL) device_printf
50 #define NG_BT3C_WARN if (sc->debug >= NG_BT3C_WARN_LEVEL) device_printf
51 #define NG_BT3C_INFO if (sc->debug >= NG_BT3C_INFO_LEVEL) device_printf
53 /* Device registers */
54 #define BT3C_DATA_L 0x00 /* data low byte */
55 #define BT3C_DATA_H 0x01 /* high byte */
56 #define BT3C_ADDR_L 0x02 /* address low byte */
57 #define BT3C_ADDR_H 0x03 /* high byte */
58 #define BT3C_CONTROL 0x04 /* control */
60 #define BT3C_FIFO_SIZE 256
62 /* Device softc structure */
65 device_t dev; /* pointer back to device */
66 int iobase_rid; /* iobase RID */
67 struct resource *iobase; /* iobase */
68 bus_space_tag_t iot; /* I/O tag */
69 bus_space_handle_t ioh; /* I/O handle */
70 int irq_rid; /* irq RID */
71 struct resource *irq; /* irq */
72 void *irq_cookie; /* irq cookie */
74 /* Netgraph specific */
75 node_p node; /* pointer back to node */
76 hook_p hook; /* hook */
78 ng_bt3c_node_debug_ep debug; /* debug level */
79 u_int16_t flags; /* device flags */
80 #define BT3C_ANTENNA_OUT (1 << 0) /* antena is out */
81 #define BT3C_XMIT (1 << 1) /* xmit in progress */
83 ng_bt3c_node_state_ep state; /* receiving state */
85 ng_bt3c_node_stat_ep stat; /* statistic */
86 #define NG_BT3C_STAT_PCKTS_SENT(s) (s).pckts_sent ++
87 #define NG_BT3C_STAT_BYTES_SENT(s, n) (s).bytes_sent += (n)
88 #define NG_BT3C_STAT_PCKTS_RECV(s) (s).pckts_recv ++
89 #define NG_BT3C_STAT_BYTES_RECV(s, n) (s).bytes_recv += (n)
90 #define NG_BT3C_STAT_OERROR(s) (s).oerrors ++
91 #define NG_BT3C_STAT_IERROR(s) (s).ierrors ++
92 #define NG_BT3C_STAT_RESET(s) bzero(&(s), sizeof((s)))
94 u_int32_t status; /* from ISR */
95 void *ith; /* ithread handler */
97 struct mbuf *m; /* current frame */
98 u_int32_t want; /* # of chars we want */
100 struct ifqueue inq; /* queue of incoming mbuf's */
101 struct ifqueue outq; /* queue of outgoing mbuf's */
102 #define BT3C_DEFAULTQLEN 12 /* XXX max. size of out queue */
105 typedef struct bt3c_softc bt3c_softc_t;
106 typedef struct bt3c_softc * bt3c_softc_p;
108 #endif /* ndef _NG_BT3C_VAR_H_ */