1.\" Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com> 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.\" $Id: ng_ubt.4,v 1.3 2003/05/21 19:37:35 max Exp $ 26.\" $FreeBSD$ 27.\" 28.Dd September 13, 2004 29.Dt NG_UBT 4 30.Os 31.Sh NAME 32.Nm ng_ubt 33.Nd Netgraph node type that is also a driver for Bluetooth USB devices 34.Sh SYNOPSIS 35.In sys/types.h 36.In netgraph/bluetooth/include/ng_ubt.h 37.Sh DESCRIPTION 38The 39.Nm ubt 40node type is both a persistent Netgraph node type and a driver for 41Bluetooth USB devices. 42It implements a Bluetooth USB transport layer 43as per chapter H2 of the Bluetooth Specification Book v1.1. 44A new node is created when a supported USB device is plugged in. 45.Pp 46The node has a single hook called 47.Dv hook . 48Incoming bytes received on the device are re-assembled into HCI frames 49(according to the length). 50Full HCI frames are sent out on the hook. 51The node will add a HCI frame indicator if the device did not send it. 52HCI frames received on 53.Dv hook 54are transmitted out. 55The node will drop the HCI frame indicator unless the device 56requires it to be present. 57.Sh HARDWARE 58The 59.Nm 60driver supports the following Bluetooth USB devices: 61.Pp 62.Bl -bullet -compact 63.It 643Com 3CREB96 65.It 66AIPTEK BR0R02 67.It 68EPoX BT-DG02 69.It 70Mitsumi Bluetooth USB adapter 71.It 72MSI MS-6967 73.It 74TDK Bluetooth USB adapter 75.El 76.Sh HOOKS 77This node type supports the following hooks: 78.Bl -tag -width indent 79.It Dv hook 80single HCI frame contained in a single 81.Vt mbuf 82structure. 83.El 84.Sh CONTROL MESSAGES 85This node type supports the generic control messages, plus the following: 86.Bl -tag -width indent 87.It Dv NGM_UBT_NODE_GET_DEBUG 88Returns an integer containing the current debug level for the node. 89.It Dv NGM_UBT_NODE_SET_DEBUG 90This command takes an integer argument and sets the current debug level 91for the node. 92.It Dv NGM_UBT_NODE_GET_QLEN 93This command takes a parameter that specifies the queue number and returns 94the current maximal length of the queue for the node. 95.It Dv NGM_UBT_NODE_SET_QLEN 96This command takes two parameters that specify the queue number and the maximum 97length of the queue and sets the maximal length of the queue for the node. 98.It Dv NGM_UBT_NODE_GET_STAT 99Returns various statistic information for the node, such as: number of 100bytes (frames) sent, number of bytes (frames) received and number of 101input (output) errors. 102.It Dv NGM_UBT_NODE_RESET_STAT 103Reset all statistic counters to zero. 104.It Dv NGM_UBT_NODE_DEV_NODES 105This command takes a single integer parameter. 106If the parameter's value is not zero, then the driver will create device nodes 107for the control, interrupt, bulk-in and bulk-out endpoints. 108If the parameter's value is zero, then the driver will destroy the device nodes 109for the endpoints. 110The device nodes interface is mutually exclusive with the Netgraph interface. 111.El 112.Sh DEVICE NODES INTERFACE 113The 114.Nm ubt 115driver can create or destroy endpoint device nodes on request. 116This feature can be used to implement an external firmware download utility. 117.Pp 118Control transfers can only happen on the control endpoint which 119is always endpoint 0. 120Control requests are issued by 121.Xr ioctl 2 122calls. 123.Pp 124Only incoming transfers are supported on an interrupt endpoint. 125To perform I/O on an interrupt endpoint, 126.Xr read 2 127should be used. 128All I/O operations on an interrupt endpoint are unbuffered. 129.Pp 130The bulk transfers can be in or out depending on the endpoint. 131To perform I/O on a bulk endpoint, 132.Xr read 2 133and 134.Xr write 2 135should be used. 136All I/O operations on a bulk endpoint are unbuffered. 137.Pp 138The control endpoint (endpoint 0) handles the following 139.Xr ioctl 2 140calls: 141.Bl -tag -width indent 142.It Dv USB_GET_DEVICE_DESC Pq Vt usb_device_descriptor_t 143Return the device descriptor. 144.It Dv USB_GET_STRING_DESC Pq Vt "struct usb_string_desc" 145Get a string descriptor for the given language ID and string index. 146.Bd -literal 147struct usb_string_desc { 148 int string_index; 149 int language_id; 150 usb_string_descriptor_t desc; 151}; 152.Ed 153.It Dv USB_DO_REQUEST Pq Vt "struct usb_ctl_request" 154Send a USB request to the device on the control endpoint. 155Any data sent to/from the device is located at 156.Va data . 157The size of the transferred data is determined from the 158.Va request . 159The 160.Va addr 161field is ignored in this call. 162The 163.Va flags 164field can be used to flag that the request is allowed to 165be shorter than the requested size, and the 166.Va actlen 167will contain the actual size on completion. 168.Bd -literal 169struct usb_ctl_request { 170 int addr; 171 usb_device_request_t request; 172 void *data; 173 int flags; 174#define USBD_SHORT_XFER_OK 0x04 /* allow short reads */ 175 int actlen; /* actual length transferred */ 176}; 177.Ed 178This is a dangerous operation in that it can perform arbitrary operations 179on the device. 180Some of the most dangerous (e.g., changing the device address) are not allowed. 181.It Dv USB_GET_DEVICEINFO Pq Vt "struct usb_device_info" 182Get an information summary for the device. 183This call will not issue any USB transactions. 184.El 185.Sh SHUTDOWN 186This node shuts down when the corresponding USB device is un-plugged. 187.Sh BUGS 188Isochronous USB transfers are broken. 189This means that the USB device will not be able to transfer SCO data (voice). 190USB interrupt transfers are implemented as bulk-in transfers (not really a bug). 191.Sh FILES 192.Bl -tag -width ".Pa /dev/ubt Ns Ar N Ns Pa \&. Ns Ar EE" -compact 193.It Pa /dev/ubt Ns Ar N Ns Pa \&. Ns Ar EE 194Endpoint 195.Ar EE 196of device 197.Ar N . 198.El 199.Sh SEE ALSO 200.Xr netgraph 4 , 201.Xr ugen 4 , 202.Xr usb 4 , 203.Xr ngctl 8 204.Sh HISTORY 205The 206.Nm ubt 207node type was implemented in 208.Fx 5.0 . 209.Sh AUTHORS 210.An Maksim Yevmenkin Aq m_evmenkin@yahoo.com 211