summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_var.h
blob: 89ac57c06af10c9efb46029a1d63f90965158e8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
 * ng_bt3c_var.h
 *
 * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $Id: ng_bt3c_var.h,v 1.1 2002/11/09 19:07:56 max Exp $
 * $FreeBSD$
 *
 * XXX XXX XX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX 
 *
 * Based on information obrained from: Jose Orlando Pereira <jop@di.uminho.pt>
 * and disassembled w2k driver.
 *
 * XXX XXX XX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX 
 *
 */

#ifndef _NG_BT3C_VAR_H_
#define _NG_BT3C_VAR_H_

/* Debug printf's */
#define NG_BT3C_ALERT	if (sc->debug >= NG_BT3C_ALERT_LEVEL) device_printf
#define NG_BT3C_ERR	if (sc->debug >= NG_BT3C_ERR_LEVEL)   device_printf
#define NG_BT3C_WARN	if (sc->debug >= NG_BT3C_WARN_LEVEL)  device_printf
#define NG_BT3C_INFO	if (sc->debug >= NG_BT3C_INFO_LEVEL)  device_printf

/* Device registers */
#define	BT3C_DATA_L		0x00		/* data low byte */
#define	BT3C_DATA_H		0x01		/* high byte */
#define	BT3C_ADDR_L		0x02		/* address low byte */
#define	BT3C_ADDR_H		0x03		/* high byte */
#define	BT3C_CONTROL		0x04		/* control */

#define BT3C_FIFO_SIZE		256

/* Device softc structure */
struct bt3c_softc {
	/* Device specific */
	device_t		 dev;		/* pointer back to device */
	int			 iobase_rid;	/* iobase RID */
	struct resource		*iobase;	/* iobase */
	int			 irq_rid;       /* irq RID */
	struct resource		*irq;		/* irq */
	void			*irq_cookie;	/* irq cookie */

	/* Netgraph specific */
	node_p			 node;		/* pointer back to node */
	hook_p			 hook;		/* hook */

	ng_bt3c_node_debug_ep	 debug;		/* debug level */
	u_int16_t		 flags;		/* device flags */
#define BT3C_ANTENNA_OUT	(1 << 0)	/* antena is out */
#define BT3C_XMIT		(1 << 1)	/* xmit in progress */

	ng_bt3c_node_state_ep	 state;		/* receiving state */

	ng_bt3c_node_stat_ep	 stat;		/* statistic */
#define NG_BT3C_STAT_PCKTS_SENT(s)	(s).pckts_sent ++
#define NG_BT3C_STAT_BYTES_SENT(s, n)	(s).bytes_sent += (n)
#define NG_BT3C_STAT_PCKTS_RECV(s)	(s).pckts_recv ++
#define NG_BT3C_STAT_BYTES_RECV(s, n)	(s).bytes_recv += (n)
#define NG_BT3C_STAT_OERROR(s)		(s).oerrors ++
#define NG_BT3C_STAT_IERROR(s)		(s).ierrors ++
#define NG_BT3C_STAT_RESET(s)		bzero(&(s), sizeof((s)))

	u_int32_t		 status;	/* from ISR */
	void			*ith;		/* ithread handler */

	struct mbuf		*m;		/* current frame */
	u_int32_t		 want;		/* # of chars we want */

	struct ifqueue		 inq;		/* queue of incoming mbuf's */
	struct ifqueue		 outq;		/* queue of outgoing mbuf's */
#define BT3C_DEFAULTQLEN	 12		/* XXX max. size of out queue */
};

typedef struct bt3c_softc	bt3c_softc_t;
typedef struct bt3c_softc *	bt3c_softc_p;

#endif /* ndef _NG_BT3C_VAR_H_ */

OpenPOWER on IntegriCloud