xref: /freebsd/share/man/man4/ng_ubt.4 (revision 0986ab12e44caea472245845f9a89ced4f137d73)
1878ed226SJulian Elischer.\" Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
2878ed226SJulian Elischer.\" All rights reserved.
3878ed226SJulian Elischer.\"
4878ed226SJulian Elischer.\" Redistribution and use in source and binary forms, with or without
5878ed226SJulian Elischer.\" modification, are permitted provided that the following conditions
6878ed226SJulian Elischer.\" are met:
7878ed226SJulian Elischer.\" 1. Redistributions of source code must retain the above copyright
8878ed226SJulian Elischer.\"    notice, this list of conditions and the following disclaimer.
9878ed226SJulian Elischer.\" 2. Redistributions in binary form must reproduce the above copyright
10878ed226SJulian Elischer.\"    notice, this list of conditions and the following disclaimer in the
11878ed226SJulian Elischer.\"    documentation and/or other materials provided with the distribution.
12878ed226SJulian Elischer.\"
13878ed226SJulian Elischer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14878ed226SJulian Elischer.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15878ed226SJulian Elischer.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16878ed226SJulian Elischer.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17878ed226SJulian Elischer.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18878ed226SJulian Elischer.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19878ed226SJulian Elischer.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20878ed226SJulian Elischer.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21878ed226SJulian Elischer.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22878ed226SJulian Elischer.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23878ed226SJulian Elischer.\" SUCH DAMAGE.
24878ed226SJulian Elischer.\"
250986ab12SMaksim Yevmenkin.\" $Id: ng_ubt.4,v 1.3 2003/05/21 19:37:35 max Exp $
26878ed226SJulian Elischer.\" $FreeBSD$
2772f00208SRuslan Ermilov.\"
28878ed226SJulian Elischer.Dd June 14, 2002
29878ed226SJulian Elischer.Dt NG_UBT 4
30878ed226SJulian Elischer.Os
31878ed226SJulian Elischer.Sh NAME
3272f00208SRuslan Ermilov.Nm ng_ubt
33878ed226SJulian Elischer.Nd Netgraph node type that is also a driver for Bluetooth USB devices
34878ed226SJulian Elischer.Sh SYNOPSIS
35878ed226SJulian Elischer.In sys/types.h
36878ed226SJulian Elischer.In ng_ubt.h
37878ed226SJulian Elischer.Sh DESCRIPTION
38878ed226SJulian ElischerThe
3972f00208SRuslan Ermilov.Nm ubt
40878ed226SJulian Elischernode type is both a persistent Netgraph node type and a driver for
4172f00208SRuslan ErmilovBluetooth USB devices.
4272f00208SRuslan ErmilovIt implements a Bluetooth USB transport layer
4372f00208SRuslan Ermilovas per chapter H2 of the Bluetooth Specification Book v1.1.
4472f00208SRuslan ErmilovA new node 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
4972f00208SRuslan Ermilov(according to the length).
5072f00208SRuslan ErmilovFull HCI frames are sent out on the hook.
5172f00208SRuslan ErmilovThe node will add HCI frame indicator if device did not send it.
5272f00208SRuslan ErmilovHCI frames received on
53878ed226SJulian Elischer.Dv hook
5472f00208SRuslan Ermilovare transmitted out.
5572f00208SRuslan ErmilovThe node will drop HCI frame indicator unless device
56878ed226SJulian Elischerrequires it to be present.
57878ed226SJulian Elischer.Sh HOOKS
58878ed226SJulian ElischerThis node type supports the following hooks:
5972f00208SRuslan Ermilov.Bl -tag -width indent
60878ed226SJulian Elischer.It Dv hook
61878ed226SJulian Elischersingle HCI frame contained in single
6272f00208SRuslan Ermilov.Vt mbuf
63878ed226SJulian Elischerstructure.
64878ed226SJulian Elischer.El
65878ed226SJulian Elischer.Sh CONTROL MESSAGES
66878ed226SJulian ElischerThis node type supports the generic control messages, plus the following:
6772f00208SRuslan Ermilov.Bl -tag -width indent
68878ed226SJulian Elischer.It Dv NGM_UBT_NODE_GET_DEBUG
69878ed226SJulian ElischerReturns an integer containing the current debug level for the node.
70878ed226SJulian Elischer.It Dv NGM_UBT_NODE_SET_DEBUG
71878ed226SJulian ElischerThis command takes an integer argument and sets current debug level
72878ed226SJulian Elischerfor the node.
73878ed226SJulian Elischer.It Dv NGM_UBT_NODE_GET_QLEN
74878ed226SJulian ElischerThis command takes a parameter that specifies queue number and returns
75878ed226SJulian Elischercurrent maximal length of the queue for the node.
76878ed226SJulian Elischer.It Dv NGM_UBT_NODE_SET_QLEN
77878ed226SJulian ElischerThis command takes two parameters that specify queue number and maximum
78878ed226SJulian Elischerlength of the queue and sets maximal length of the queue for the node.
79878ed226SJulian Elischer.It Dv NGM_UBT_NODE_GET_STAT
80878ed226SJulian ElischerReturns various statistic information for the node, such as: number of
81878ed226SJulian Elischerbytes (frames) sent, number of bytes (frames) received and number of
82878ed226SJulian Elischerinput (output) errors.
83878ed226SJulian Elischer.It Dv NGM_UBT_NODE_RESET_STAT
84878ed226SJulian ElischerReset all statistic counters to zero.
85f2bb1caeSJulian Elischer.It Dv NGM_UBT_NODE_DEV_NODES
8672f00208SRuslan ErmilovThis command takes single integer parameter.
8772f00208SRuslan ErmilovIf the parameter's value is not zero, then the driver will create device nodes
8872f00208SRuslan Ermilovfor the control, interrupt, bulk-in and bulk-out endpoints.
8972f00208SRuslan ErmilovIf the parameter's value is zero, then the driver will destroy device nodes
9072f00208SRuslan Ermilovfor the endpoints.
9172f00208SRuslan ErmilovThe device nodes interface is mutually exclusive with Netgraph interface.
92f2bb1caeSJulian Elischer.El
93f2bb1caeSJulian Elischer.Sh DEVICE NODES INTERFACE
94f2bb1caeSJulian ElischerThe
9572f00208SRuslan Ermilov.Nm ubt
9672f00208SRuslan Ermilovdriver can create or destroy endpoint device nodes on request.
9772f00208SRuslan ErmilovThis feature can be used to implement external firmware download utility.
98f2bb1caeSJulian Elischer.Pp
99f2bb1caeSJulian ElischerThe control transfers can only happen on the control endpoint which
10072f00208SRuslan Ermilovis always endpoint 0.
10172f00208SRuslan ErmilovControl requests are issued by
102f2bb1caeSJulian Elischer.Xr ioctl 2
103f2bb1caeSJulian Elischercalls.
104f2bb1caeSJulian Elischer.Pp
10572f00208SRuslan ErmilovOnly incoming transfers are supported on an interrupt endpoint.
10672f00208SRuslan ErmilovTo perform I/O on an interrupt endpoint,
107f2bb1caeSJulian Elischer.Xr read 2
10872f00208SRuslan Ermilovshould be used.
10972f00208SRuslan ErmilovAll I/O operations on an interrupt endpoint are unbuffered.
110f2bb1caeSJulian Elischer.Pp
11172f00208SRuslan ErmilovThe bulk transfers can be in or out depending on the endpoint.
11272f00208SRuslan ErmilovTo perform I/O on a bulk endpoint,
113f2bb1caeSJulian Elischer.Xr read 2
114f2bb1caeSJulian Elischerand
115f2bb1caeSJulian Elischer.Xr write 2
11672f00208SRuslan Ermilovshould be used.
11772f00208SRuslan ErmilovAll I/O operations on a bulk endpoint are unbuffered.
118f2bb1caeSJulian Elischer.Pp
119f2bb1caeSJulian ElischerThe control endpoint (endpoint 0) handles the following
120f2bb1caeSJulian Elischer.Xr ioctl 2
121f2bb1caeSJulian Elischercalls:
12272f00208SRuslan Ermilov.Bl -tag -width indent
123f2bb1caeSJulian Elischer.It Dv USB_GET_DEVICE_DESC Pq Vt usb_device_descriptor_t
124f2bb1caeSJulian ElischerReturn the device descriptor.
125f2bb1caeSJulian Elischer.It Dv USB_GET_STRING_DESC Pq Vt "struct usb_string_desc"
12672f00208SRuslan ErmilovGet a string descriptor for the given language ID and string index.
127f2bb1caeSJulian Elischer.Bd -literal
128f2bb1caeSJulian Elischerstruct usb_string_desc {
129f2bb1caeSJulian Elischer        int                     string_index;
130f2bb1caeSJulian Elischer        int                     language_id;
131f2bb1caeSJulian Elischer        usb_string_descriptor_t desc;
132f2bb1caeSJulian Elischer};
133f2bb1caeSJulian Elischer.Ed
134f2bb1caeSJulian Elischer.It Dv USB_DO_REQUEST Pq Vt "struct usb_ctl_request"
135f2bb1caeSJulian ElischerSend a USB request to the device on the control endpoint.
136f2bb1caeSJulian ElischerAny data sent to/from the device is located at
137f2bb1caeSJulian Elischer.Va data .
138f2bb1caeSJulian ElischerThe size of the transferred data is determined from the
139f2bb1caeSJulian Elischer.Va request .
140f2bb1caeSJulian ElischerThe
141f2bb1caeSJulian Elischer.Va addr
142f2bb1caeSJulian Elischerfield is ignored in this call.
143f2bb1caeSJulian ElischerThe
144f2bb1caeSJulian Elischer.Va flags
145f2bb1caeSJulian Elischerfield can be used to flag that the request is allowed to
146f2bb1caeSJulian Elischerbe shorter than the requested size, and the
147f2bb1caeSJulian Elischer.Va actlen
148f2bb1caeSJulian Elischerwill contain the actual size on completion.
149f2bb1caeSJulian Elischer.Bd -literal
150f2bb1caeSJulian Elischerstruct usb_ctl_request {
151f2bb1caeSJulian Elischer        int                  addr;
152f2bb1caeSJulian Elischer        usb_device_request_t request;
153f2bb1caeSJulian Elischer        void                 *data;
154f2bb1caeSJulian Elischer        int                  flags;
155f2bb1caeSJulian Elischer#define USBD_SHORT_XFER_OK   0x04    /* allow short reads */
156f2bb1caeSJulian Elischer        int                  actlen; /* actual length transferred */
157f2bb1caeSJulian Elischer};
158f2bb1caeSJulian Elischer.Ed
159f2bb1caeSJulian ElischerThis is a dangerous operation in that it can perform arbitrary operations
16072f00208SRuslan Ermilovon the device.
16172f00208SRuslan ErmilovSome of the most dangerous (e.g., changing the device address) are not allowed.
162f2bb1caeSJulian Elischer.It Dv USB_GET_DEVICEINFO Pq Vt "struct usb_device_info"
16372f00208SRuslan ErmilovGet an information summary for the device.
16472f00208SRuslan ErmilovThis call will not issue any USB transactions.
165878ed226SJulian Elischer.El
166878ed226SJulian Elischer.Sh SHUTDOWN
167878ed226SJulian ElischerThis node shuts down when the corresponding USB device is un-plugged.
168878ed226SJulian Elischer.Sh BUGS
16972f00208SRuslan ErmilovIsochronous USB transfers are broken.
17072f00208SRuslan ErmilovIt means that USB device will not be able to transfer SCO data (voice).
17172f00208SRuslan ErmilovUSB interrupt transfers are implemented as bulk-in transfers (not really a bug).
172f2bb1caeSJulian Elischer.Sh FILES
173f2bb1caeSJulian Elischer.Bl -tag -width ".Pa /dev/ubt Ns Ar N Ns Pa \&. Ns Ar EE" -compact
174f2bb1caeSJulian Elischer.It Pa /dev/ubt Ns Ar N Ns Pa \&. Ns Ar EE
175f2bb1caeSJulian ElischerEndpoint
176f2bb1caeSJulian Elischer.Ar EE
177f2bb1caeSJulian Elischerof device
178f2bb1caeSJulian Elischer.Ar N .
179f2bb1caeSJulian Elischer.El
180878ed226SJulian Elischer.Sh SEE ALSO
181f2bb1caeSJulian Elischer.Xr netgraph 4 ,
18272f00208SRuslan Ermilov.Xr ugen 4 ,
18372f00208SRuslan Ermilov.Xr usb 4 ,
184878ed226SJulian Elischer.Xr ngctl 8
185878ed226SJulian Elischer.Sh HISTORY
186878ed226SJulian ElischerThe
18772f00208SRuslan Ermilov.Nm ubt
188878ed226SJulian Elischernode type was implemented in
189878ed226SJulian Elischer.Fx 5.0 .
190878ed226SJulian Elischer.Sh AUTHORS
191878ed226SJulian Elischer.An Maksim Yevmenkin Aq m_evmenkin@yahoo.com
192