xref: /freebsd/share/man/man4/ng_ubt.4 (revision f2bb1cae36283a8eb5a0f19d8612c6abc5148e8f)
1f2bb1caeSJulian Elischer.\" ng_ubt.4
2f2bb1caeSJulian Elischer.\"
3878ed226SJulian Elischer.\" Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
4878ed226SJulian Elischer.\" All rights reserved.
5878ed226SJulian Elischer.\"
6878ed226SJulian Elischer.\" Redistribution and use in source and binary forms, with or without
7878ed226SJulian Elischer.\" modification, are permitted provided that the following conditions
8878ed226SJulian Elischer.\" are met:
9878ed226SJulian Elischer.\" 1. Redistributions of source code must retain the above copyright
10878ed226SJulian Elischer.\"    notice, this list of conditions and the following disclaimer.
11878ed226SJulian Elischer.\" 2. Redistributions in binary form must reproduce the above copyright
12878ed226SJulian Elischer.\"    notice, this list of conditions and the following disclaimer in the
13878ed226SJulian Elischer.\"    documentation and/or other materials provided with the distribution.
14878ed226SJulian Elischer.\"
15878ed226SJulian Elischer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16878ed226SJulian Elischer.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17878ed226SJulian Elischer.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18878ed226SJulian Elischer.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19878ed226SJulian Elischer.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20878ed226SJulian Elischer.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21878ed226SJulian Elischer.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22878ed226SJulian Elischer.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23878ed226SJulian Elischer.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24878ed226SJulian Elischer.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25878ed226SJulian Elischer.\" SUCH DAMAGE.
26878ed226SJulian Elischer.\"
27f2bb1caeSJulian Elischer.\" $Id: ng_ubt.4,v 1.2 2003/03/22 23:44:32 max Exp $
28878ed226SJulian Elischer.\" $FreeBSD$
29878ed226SJulian Elischer.Dd June 14, 2002
30878ed226SJulian Elischer.Dt NG_UBT 4
31878ed226SJulian Elischer.Os
32878ed226SJulian Elischer.Sh NAME
33f2bb1caeSJulian Elischer.Nm ubt
34878ed226SJulian Elischer.Nd Netgraph node type that is also a driver for Bluetooth USB devices
35878ed226SJulian Elischer.Sh SYNOPSIS
36878ed226SJulian Elischer.In sys/types.h
37878ed226SJulian Elischer.In ng_ubt.h
38878ed226SJulian Elischer.Sh DESCRIPTION
39878ed226SJulian ElischerThe
40f2bb1caeSJulian Elischer.Nm
41878ed226SJulian Elischernode type is both a persistent Netgraph node type and a driver for
42f2bb1caeSJulian ElischerBluetooth USB devices. It implements a Bluetooth USB transport layer
43f2bb1caeSJulian Elischeras per chapter H2 of the Bluetooth Specification Book v1.1. A new
44f2bb1caeSJulian Elischernode is created when supported USB device is plugged.
45878ed226SJulian Elischer.Pp
46878ed226SJulian ElischerThe node has a single hook called
47878ed226SJulian Elischer.Dv hook .
48878ed226SJulian ElischerIncoming bytes received on the device are re-assembled into HCI frames
49f2bb1caeSJulian Elischer(according to the length). Full HCI frames are sent out on the hook. The node
50f2bb1caeSJulian Elischerwill add HCI frame indicator if device did not send it. HCI frames received
51f2bb1caeSJulian Elischeron
52878ed226SJulian Elischer.Dv hook
53f2bb1caeSJulian Elischerare transmitted out. The node will drop HCI frame indicator unless device
54878ed226SJulian Elischerrequires it to be present.
55878ed226SJulian Elischer.Sh HOOKS
56878ed226SJulian ElischerThis node type supports the following hooks:
57f2bb1caeSJulian Elischer.Pp
58f2bb1caeSJulian Elischer.Bl -tag -width foobar
59878ed226SJulian Elischer.It Dv hook
60878ed226SJulian Elischersingle HCI frame contained in single
61f2bb1caeSJulian Elischer.Dv mbuf
62878ed226SJulian Elischerstructure.
63878ed226SJulian Elischer.El
64878ed226SJulian Elischer.Sh CONTROL MESSAGES
65878ed226SJulian ElischerThis node type supports the generic control messages, plus the following:
66f2bb1caeSJulian Elischer.Bl -tag -width foo
67878ed226SJulian Elischer.It Dv NGM_UBT_NODE_GET_DEBUG
68878ed226SJulian ElischerReturns an integer containing the current debug level for the node.
69878ed226SJulian Elischer.It Dv NGM_UBT_NODE_SET_DEBUG
70878ed226SJulian ElischerThis command takes an integer argument and sets current debug level
71878ed226SJulian Elischerfor the node.
72878ed226SJulian Elischer.It Dv NGM_UBT_NODE_GET_QLEN
73878ed226SJulian ElischerThis command takes a parameter that specifies queue number and returns
74878ed226SJulian Elischercurrent maximal length of the queue for the node.
75878ed226SJulian Elischer.It Dv NGM_UBT_NODE_SET_QLEN
76878ed226SJulian ElischerThis command takes two parameters that specify queue number and maximum
77878ed226SJulian Elischerlength of the queue and sets maximal length of the queue for the node.
78878ed226SJulian Elischer.It Dv NGM_UBT_NODE_GET_STAT
79878ed226SJulian ElischerReturns various statistic information for the node, such as: number of
80878ed226SJulian Elischerbytes (frames) sent, number of bytes (frames) received and number of
81878ed226SJulian Elischerinput (output) errors.
82878ed226SJulian Elischer.It Dv NGM_UBT_NODE_RESET_STAT
83878ed226SJulian ElischerReset all statistic counters to zero.
84f2bb1caeSJulian Elischer.It Dv NGM_UBT_NODE_DEV_NODES
85f2bb1caeSJulian ElischerThis command takes single integer parameter. If the parameter's value
86f2bb1caeSJulian Elischeris not zero then the driver will create device nodes for the control,
87f2bb1caeSJulian Elischerinterrupt, bulk-in and bulk-out endpoints. If the parameter's value is
88f2bb1caeSJulian Elischerzero then the driver will destroy device nodes for the endpoints. The
89f2bb1caeSJulian Elischerdevice nodes interface is mutually exclusive with Netgraph interface.
90f2bb1caeSJulian Elischer.El
91f2bb1caeSJulian Elischer.Sh DEVICE NODES INTERFACE
92f2bb1caeSJulian ElischerThe
93f2bb1caeSJulian Elischer.Nm
94f2bb1caeSJulian Elischerdriver can create or destroy endpoint device nodes on request. This
95f2bb1caeSJulian Elischerfeature can be used to implement external firmware download utility.
96f2bb1caeSJulian Elischer.Pp
97f2bb1caeSJulian ElischerThe control transfers can only happen on the control endpoint which
98f2bb1caeSJulian Elischeris always endpoint 0. Control request are issued by
99f2bb1caeSJulian Elischer.Xr ioctl 2
100f2bb1caeSJulian Elischercalls.
101f2bb1caeSJulian Elischer.Pp
102f2bb1caeSJulian ElischerOnly incoming transfers are supported on an interrupt endpoint. To perform I/O
103f2bb1caeSJulian Elischeron an interrupt endpoint
104f2bb1caeSJulian Elischer.Xr read 2
105f2bb1caeSJulian Elischershould be used.  All I/O operations on a interrupt endpoint are unbuffered.
106f2bb1caeSJulian Elischer.Pp
107f2bb1caeSJulian ElischerThe bulk transfers can be in or out depending on the endpoint. To perform
108f2bb1caeSJulian ElischerI/O on a bulk endpoint
109f2bb1caeSJulian Elischer.Xr read 2
110f2bb1caeSJulian Elischerand
111f2bb1caeSJulian Elischer.Xr write 2
112f2bb1caeSJulian Elischershould be used. All I/O operations on a bulk endpoint are unbuffered.
113f2bb1caeSJulian Elischer.Pp
114f2bb1caeSJulian ElischerThe control endpoint (endpoint 0) handles the following
115f2bb1caeSJulian Elischer.Xr ioctl 2
116f2bb1caeSJulian Elischercalls:
117f2bb1caeSJulian Elischer.Bl -tag -width foo
118f2bb1caeSJulian Elischer.It Dv USB_GET_DEVICE_DESC Pq Vt usb_device_descriptor_t
119f2bb1caeSJulian ElischerReturn the device descriptor.
120f2bb1caeSJulian Elischer.It Dv USB_GET_STRING_DESC Pq Vt "struct usb_string_desc"
121f2bb1caeSJulian ElischerGet a string descriptor for the given language ID and
122f2bb1caeSJulian Elischerstring index.
123f2bb1caeSJulian Elischer.Bd -literal
124f2bb1caeSJulian Elischerstruct usb_string_desc {
125f2bb1caeSJulian Elischer        int                     string_index;
126f2bb1caeSJulian Elischer        int                     language_id;
127f2bb1caeSJulian Elischer        usb_string_descriptor_t desc;
128f2bb1caeSJulian Elischer};
129f2bb1caeSJulian Elischer.Ed
130f2bb1caeSJulian Elischer.It Dv USB_DO_REQUEST Pq Vt "struct usb_ctl_request"
131f2bb1caeSJulian ElischerSend a USB request to the device on the control endpoint.
132f2bb1caeSJulian ElischerAny data sent to/from the device is located at
133f2bb1caeSJulian Elischer.Va data .
134f2bb1caeSJulian ElischerThe size of the transferred data is determined from the
135f2bb1caeSJulian Elischer.Va request .
136f2bb1caeSJulian ElischerThe
137f2bb1caeSJulian Elischer.Va addr
138f2bb1caeSJulian Elischerfield is ignored in this call.
139f2bb1caeSJulian ElischerThe
140f2bb1caeSJulian Elischer.Va flags
141f2bb1caeSJulian Elischerfield can be used to flag that the request is allowed to
142f2bb1caeSJulian Elischerbe shorter than the requested size, and the
143f2bb1caeSJulian Elischer.Va actlen
144f2bb1caeSJulian Elischerwill contain the actual size on completion.
145f2bb1caeSJulian Elischer.Bd -literal
146f2bb1caeSJulian Elischerstruct usb_ctl_request {
147f2bb1caeSJulian Elischer        int                  addr;
148f2bb1caeSJulian Elischer        usb_device_request_t request;
149f2bb1caeSJulian Elischer        void                 *data;
150f2bb1caeSJulian Elischer        int                  flags;
151f2bb1caeSJulian Elischer#define USBD_SHORT_XFER_OK   0x04    /* allow short reads */
152f2bb1caeSJulian Elischer        int                  actlen; /* actual length transferred */
153f2bb1caeSJulian Elischer};
154f2bb1caeSJulian Elischer.Ed
155f2bb1caeSJulian ElischerThis is a dangerous operation in that it can perform arbitrary operations
156f2bb1caeSJulian Elischeron the device.  Some of the most dangerous (e.g., changing the device
157f2bb1caeSJulian Elischeraddress) are not allowed.
158f2bb1caeSJulian Elischer.It Dv USB_GET_DEVICEINFO Pq Vt "struct usb_device_info"
159f2bb1caeSJulian ElischerGet an information summary for the device. This call will not issue any USB
160f2bb1caeSJulian Elischertransactions.
161878ed226SJulian Elischer.El
162878ed226SJulian Elischer.Sh SHUTDOWN
163878ed226SJulian ElischerThis node shuts down when the corresponding USB device is un-plugged.
164878ed226SJulian Elischer.Sh BUGS
165f2bb1caeSJulian ElischerIsochronous USB transfers are broken. It means that USB device will not be able
166f2bb1caeSJulian Elischerto transfer SCO data (voice). USB interrupt transfers are implemented as bulk-in
167f2bb1caeSJulian Elischertransfers (not really a bug).
168f2bb1caeSJulian Elischer.Sh FILES
169f2bb1caeSJulian Elischer.Bl -tag -width ".Pa /dev/ubt Ns Ar N Ns Pa \&. Ns Ar EE" -compact
170f2bb1caeSJulian Elischer.It Pa /dev/ubt Ns Ar N Ns Pa \&. Ns Ar EE
171f2bb1caeSJulian ElischerEndpoint
172f2bb1caeSJulian Elischer.Ar EE
173f2bb1caeSJulian Elischerof device
174f2bb1caeSJulian Elischer.Ar N .
175f2bb1caeSJulian Elischer.El
176878ed226SJulian Elischer.Sh SEE ALSO
177f393f498SRuslan Ermilov.Xr usb 4 ,
178f2bb1caeSJulian Elischer.Xr ugen 4 ,
179f2bb1caeSJulian Elischer.Xr netgraph 4 ,
180878ed226SJulian Elischer.Xr ngctl 8
181878ed226SJulian Elischer.Sh HISTORY
182878ed226SJulian ElischerThe
183f2bb1caeSJulian Elischer.Nm
184878ed226SJulian Elischernode type was implemented in
185878ed226SJulian Elischer.Fx 5.0 .
186878ed226SJulian Elischer.Sh AUTHORS
187878ed226SJulian Elischer.An Maksim Yevmenkin Aq m_evmenkin@yahoo.com
188