xref: /dflybsd-src/sys/netgraph7/bluetooth/drivers/h4/ng_h4_var.h (revision 805c8e8e4093ceca2e27510ad3a66d4de8060a55)
1b06ebda0SMatthew Dillon /*
2b06ebda0SMatthew Dillon  * ng_h4_var.h
3b06ebda0SMatthew Dillon  */
4b06ebda0SMatthew Dillon 
5b06ebda0SMatthew Dillon /*-
6b06ebda0SMatthew Dillon  * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
7b06ebda0SMatthew Dillon  * All rights reserved.
8b06ebda0SMatthew Dillon  *
9b06ebda0SMatthew Dillon  * Redistribution and use in source and binary forms, with or without
10b06ebda0SMatthew Dillon  * modification, are permitted provided that the following conditions
11b06ebda0SMatthew Dillon  * are met:
12b06ebda0SMatthew Dillon  * 1. Redistributions of source code must retain the above copyright
13b06ebda0SMatthew Dillon  *    notice, this list of conditions and the following disclaimer.
14b06ebda0SMatthew Dillon  * 2. Redistributions in binary form must reproduce the above copyright
15b06ebda0SMatthew Dillon  *    notice, this list of conditions and the following disclaimer in the
16b06ebda0SMatthew Dillon  *    documentation and/or other materials provided with the distribution.
17b06ebda0SMatthew Dillon  *
18b06ebda0SMatthew Dillon  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19b06ebda0SMatthew Dillon  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20b06ebda0SMatthew Dillon  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21b06ebda0SMatthew Dillon  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22b06ebda0SMatthew Dillon  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23b06ebda0SMatthew Dillon  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24b06ebda0SMatthew Dillon  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25b06ebda0SMatthew Dillon  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26b06ebda0SMatthew Dillon  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27b06ebda0SMatthew Dillon  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28b06ebda0SMatthew Dillon  * SUCH DAMAGE.
29b06ebda0SMatthew Dillon  *
30b06ebda0SMatthew Dillon  * $Id: ng_h4_var.h,v 1.5 2005/10/31 17:57:43 max Exp $
31e85b99abSSascha Wildner  * $FreeBSD: head/sys/netgraph/bluetooth/drivers/h4/ng_h4_var.h 171818 2007-08-13 17:19:28Z emax $
32b06ebda0SMatthew Dillon  *
33b06ebda0SMatthew Dillon  * Based on:
34b06ebda0SMatthew Dillon  * ---------
35b06ebda0SMatthew Dillon  *
36b06ebda0SMatthew Dillon  * FreeBSD: src/sys/netgraph/ng_tty.h
37b06ebda0SMatthew Dillon  * Author: Archie Cobbs <archie@freebsd.org>
38b06ebda0SMatthew Dillon  */
39b06ebda0SMatthew Dillon 
40b06ebda0SMatthew Dillon #ifndef _NETGRAPH_H4_VAR_H_
41b06ebda0SMatthew Dillon #define _NETGRAPH_H4_VAR_H_
42b06ebda0SMatthew Dillon 
43b06ebda0SMatthew Dillon /*
44b06ebda0SMatthew Dillon  * Malloc declaration
45b06ebda0SMatthew Dillon  */
46b06ebda0SMatthew Dillon 
47b06ebda0SMatthew Dillon #ifndef NG_SEPARATE_MALLOC
48*805c8e8eSzrj #if MALLOC_DECLARE
49b06ebda0SMatthew Dillon MALLOC_DECLARE(M_NETGRAPH_H4);
50*805c8e8eSzrj #endif
51b06ebda0SMatthew Dillon #else
52b06ebda0SMatthew Dillon #define M_NETGRAPH_H4 M_NETGRAPH
53b06ebda0SMatthew Dillon #endif /* NG_SEPARATE_MALLOC */
54b06ebda0SMatthew Dillon 
55b06ebda0SMatthew Dillon /*
56b06ebda0SMatthew Dillon  * Debug
57b06ebda0SMatthew Dillon  */
58b06ebda0SMatthew Dillon 
59a62226e4SSascha Wildner #define	NG_H4_ALERT	if (sc->debug >= NG_H4_ALERT_LEVEL) kprintf
60a62226e4SSascha Wildner #define	NG_H4_ERR	if (sc->debug >= NG_H4_ERR_LEVEL)   kprintf
61a62226e4SSascha Wildner #define	NG_H4_WARN	if (sc->debug >= NG_H4_WARN_LEVEL)  kprintf
62a62226e4SSascha Wildner #define	NG_H4_INFO	if (sc->debug >= NG_H4_INFO_LEVEL)  kprintf
63b06ebda0SMatthew Dillon 
64b06ebda0SMatthew Dillon #define NG_H4_HIWATER		256	/* High water mark on output */
65b06ebda0SMatthew Dillon 
66b06ebda0SMatthew Dillon /*
67b06ebda0SMatthew Dillon  * Per-node private info
68b06ebda0SMatthew Dillon  */
69b06ebda0SMatthew Dillon 
70b06ebda0SMatthew Dillon typedef struct ng_h4_info {
71b06ebda0SMatthew Dillon 	struct tty		*tp;	/* Terminal device */
72b06ebda0SMatthew Dillon 	node_p			 node;	/* Netgraph node */
73b06ebda0SMatthew Dillon 
74b06ebda0SMatthew Dillon 	ng_h4_node_debug_ep	 debug;	/* Debug level */
75b06ebda0SMatthew Dillon 	ng_h4_node_state_ep	 state;	/* State */
76b06ebda0SMatthew Dillon 
77b06ebda0SMatthew Dillon 	ng_h4_node_stat_ep	 stat;
78b06ebda0SMatthew Dillon #define NG_H4_STAT_PCKTS_SENT(s)	(s).pckts_sent ++
79b06ebda0SMatthew Dillon #define NG_H4_STAT_BYTES_SENT(s, n)	(s).bytes_sent += (n)
80b06ebda0SMatthew Dillon #define NG_H4_STAT_PCKTS_RECV(s)	(s).pckts_recv ++
81b06ebda0SMatthew Dillon #define NG_H4_STAT_BYTES_RECV(s, n)	(s).bytes_recv += (n)
82b06ebda0SMatthew Dillon #define NG_H4_STAT_OERROR(s)		(s).oerrors ++
83b06ebda0SMatthew Dillon #define NG_H4_STAT_IERROR(s)		(s).ierrors ++
84b06ebda0SMatthew Dillon #define NG_H4_STAT_RESET(s)		bzero(&(s), sizeof((s)))
85b06ebda0SMatthew Dillon 
86b06ebda0SMatthew Dillon 	struct ifqueue		outq;	/* Queue of outgoing mbuf's */
87b06ebda0SMatthew Dillon #define NG_H4_DEFAULTQLEN	 12     /* XXX max number of mbuf's in outq */
88e85b99abSSascha Wildner #define	NG_H4_LOCK(sc)		crit_enter();
89e85b99abSSascha Wildner #define	NG_H4_UNLOCK(sc)	crit_exit();
90b06ebda0SMatthew Dillon 
91b06ebda0SMatthew Dillon #define NG_H4_IBUF_SIZE		1024	/* XXX must be big enough to hold full
92b06ebda0SMatthew Dillon 					   frame */
93b06ebda0SMatthew Dillon 	u_int8_t		 ibuf[NG_H4_IBUF_SIZE];	/* Incoming data */
94b06ebda0SMatthew Dillon 	u_int32_t		 got;	/* Number of bytes we have received */
95b06ebda0SMatthew Dillon 	u_int32_t		 want;	/* Number of bytes we want to receive */
96b06ebda0SMatthew Dillon 
97b06ebda0SMatthew Dillon 	hook_p			 hook;	/* Upstream hook */
98b06ebda0SMatthew Dillon 	struct callout		 timo;	/* See man timeout(9) */
99b06ebda0SMatthew Dillon 
100b06ebda0SMatthew Dillon 	u_int8_t		 dying;	/* are we dying? */
101b06ebda0SMatthew Dillon } ng_h4_info_t;
102b06ebda0SMatthew Dillon typedef ng_h4_info_t *		 ng_h4_info_p;
103b06ebda0SMatthew Dillon 
104b06ebda0SMatthew Dillon #endif /* _NETGRAPH_H4_VAR_H_ */
105b06ebda0SMatthew Dillon 
106