]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/netgraph/bluetooth/drivers/ubt/ng_ubt_var.h
add -n option to suppress clearing the build tree and add -DNO_CLEAN
[FreeBSD/FreeBSD.git] / sys / netgraph / bluetooth / drivers / ubt / ng_ubt_var.h
1 /*
2  * ng_ubt_var.h
3  */
4
5 /*-
6  * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  * $Id: ng_ubt_var.h,v 1.5 2005/10/31 17:57:44 max Exp $
31  * $FreeBSD$
32  */
33
34 #ifndef _NG_UBT_VAR_H_
35 #define _NG_UBT_VAR_H_
36
37 /* pullup wrapper */
38 #define NG_UBT_M_PULLUP(m, s) \
39         do { \
40                 if ((m)->m_len < (s)) \
41                         (m) = m_pullup((m), (s)); \
42                 if ((m) == NULL) \
43                         NG_UBT_ALERT("%s: %s - m_pullup(%d) failed\n", \
44                                 __func__, device_get_nameunit(sc->sc_dev), (s)); \
45         } while (0)
46
47 /* Debug printf's */
48 #define NG_UBT_ALERT    if (sc->sc_debug >= NG_UBT_ALERT_LEVEL) printf
49 #define NG_UBT_ERR      if (sc->sc_debug >= NG_UBT_ERR_LEVEL)   printf
50 #define NG_UBT_WARN     if (sc->sc_debug >= NG_UBT_WARN_LEVEL)  printf
51 #define NG_UBT_INFO     if (sc->sc_debug >= NG_UBT_INFO_LEVEL)  printf
52
53 /* Bluetooth USB control request type */
54 #define UBT_HCI_REQUEST         0x20
55 #define UBT_DEFAULT_QLEN        12
56
57 /* Isoc transfers */
58 #define NG_UBT_NXFERS           3       /* max xfers to queue */
59 #define NG_UBT_NFRAMES          10      /* frames per xfer */
60
61 struct ubt_isoc_xfer {
62         usbd_xfer_handle         xfer;          /* isoc xfer */
63         void                    *buffer;        /* isoc buffer */
64         uint16_t                *frlen;         /* isoc frame length */
65         int                      active;        /* is xfer active */
66 };
67 typedef struct ubt_isoc_xfer    ubt_isoc_xfer_t;
68 typedef struct ubt_isoc_xfer *  ubt_isoc_xfer_p;
69
70 /* USB device softc structure */
71 struct ubt_softc {
72         /* State */
73         ng_ubt_node_debug_ep     sc_debug;      /* debug level */
74         uint32_t                 sc_flags;      /* device flags */
75 #define UBT_NEED_FRAME_TYPE     (1 << 0)        /* device required frame type */
76 #define UBT_HAVE_FRAME_TYPE UBT_NEED_FRAME_TYPE
77 #define UBT_CMD_XMIT            (1 << 1)        /* CMD xmit in progress */
78 #define UBT_ACL_XMIT            (1 << 2)        /* ACL xmit in progress */
79 #define UBT_SCO_XMIT            (1 << 3)        /* SCO xmit in progress */
80 #define UBT_EVT_RECV            (1 << 4)        /* EVN recv in progress */
81 #define UBT_ACL_RECV            (1 << 5)        /* ACL recv in progress */
82 #define UBT_SCO_RECV            (1 << 6)        /* SCO recv in progress */
83
84         ng_ubt_node_stat_ep      sc_stat;       /* statistic */
85 #define NG_UBT_STAT_PCKTS_SENT(s)       (s).pckts_sent ++
86 #define NG_UBT_STAT_BYTES_SENT(s, n)    (s).bytes_sent += (n)
87 #define NG_UBT_STAT_PCKTS_RECV(s)       (s).pckts_recv ++
88 #define NG_UBT_STAT_BYTES_RECV(s, n)    (s).bytes_recv += (n)
89 #define NG_UBT_STAT_OERROR(s)           (s).oerrors ++
90 #define NG_UBT_STAT_IERROR(s)           (s).ierrors ++
91 #define NG_UBT_STAT_RESET(s)            bzero(&(s), sizeof((s)))
92
93         /* USB device specific */
94         device_t                 sc_dev;        /* pointer back to USB device */
95         usbd_device_handle       sc_udev;       /* USB device handle */
96
97         usbd_interface_handle    sc_iface0;     /* USB interface 0 */
98         usbd_interface_handle    sc_iface1;     /* USB interface 1 */
99
100         /* Interrupt pipe (HCI events) */
101         int                      sc_intr_ep;    /* interrupt endpoint */
102         usbd_pipe_handle         sc_intr_pipe;  /* interrupt pipe handle */
103         usbd_xfer_handle         sc_intr_xfer;  /* intr xfer */
104         struct mbuf             *sc_intr_buffer; /* interrupt buffer */
105
106         /* Control pipe (HCI commands) */
107         usbd_xfer_handle         sc_ctrl_xfer;  /* control xfer handle */
108         void                    *sc_ctrl_buffer; /* control buffer */
109         struct ng_bt_mbufq       sc_cmdq;       /* HCI command queue */
110 #define UBT_CTRL_BUFFER_SIZE \
111                 (sizeof(ng_hci_cmd_pkt_t) + NG_HCI_CMD_PKT_SIZE)
112
113         /* Bulk in pipe (ACL data) */
114         int                      sc_bulk_in_ep; /* bulk-in enpoint */
115         usbd_pipe_handle         sc_bulk_in_pipe; /* bulk-in pipe */
116         usbd_xfer_handle         sc_bulk_in_xfer; /* bulk-in xfer */
117         struct mbuf             *sc_bulk_in_buffer; /* bulk-in buffer */
118
119         /* Bulk out pipe (ACL data) */
120         int                      sc_bulk_out_ep; /* bulk-out endpoint */
121         usbd_pipe_handle         sc_bulk_out_pipe; /* bulk-out pipe */
122         usbd_xfer_handle         sc_bulk_out_xfer; /* bulk-out xfer */
123         void                    *sc_bulk_out_buffer; /* bulk-out buffer */
124         struct ng_bt_mbufq       sc_aclq;       /* ACL data queue */
125 #define UBT_BULK_BUFFER_SIZE \
126                 MCLBYTES /* XXX should be big enough to hold one frame */
127
128         /* Isoc. in pipe (SCO data) */
129         struct mbuf             *sc_isoc_in_buffer;
130         int                      sc_isoc_in_ep; /* isoc-in endpoint */
131         usbd_pipe_handle         sc_isoc_in_pipe; /* isoc-in pipe */
132         ubt_isoc_xfer_t          sc_isoc_in[NG_UBT_NXFERS]; /* isoc-in xfers */
133
134         /* Isoc. out pipe (SCO data) */
135         int                      sc_isoc_out_ep; /* isoc-out endpoint */
136         usbd_pipe_handle         sc_isoc_out_pipe; /* isoc-out pipe */
137         ubt_isoc_xfer_t          sc_isoc_out[NG_UBT_NXFERS]; /* isoc-out xfers */
138         struct ng_bt_mbufq       sc_scoq;       /* SCO data queue */
139
140         int                      sc_isoc_size; /* max. size of isoc. packet */
141 #define UBT_ISOC_BUFFER_SIZE \
142                 (sizeof(ng_hci_scodata_pkt_t) + NG_HCI_SCO_PKT_SIZE)
143         
144         /* Netgraph specific */
145         node_p                   sc_node;       /* pointer back to node */
146         hook_p                   sc_hook;       /* upstream hook */
147 };
148 typedef struct ubt_softc        ubt_softc_t;
149 typedef struct ubt_softc *      ubt_softc_p;
150
151 #endif /* ndef _NG_UBT_VAR_H_ */
152