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.\" 2838885006SChristian Brueffer.Dd September 13, 2004 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 363a08bb88SMaksim Yevmenkin.In netgraph/bluetooth/include/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. 4438885006SChristian BruefferA new node is created when a supported USB device is plugged in. 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. 5138885006SChristian BruefferThe node will add a HCI frame indicator if the device did not send it. 5272f00208SRuslan ErmilovHCI frames received on 53878ed226SJulian Elischer.Dv hook 5472f00208SRuslan Ermilovare transmitted out. 5538885006SChristian BruefferThe node will drop the HCI frame indicator unless the device 56878ed226SJulian Elischerrequires it to be present. 5738885006SChristian Brueffer.Sh HARDWARE 5838885006SChristian BruefferThe 5938885006SChristian Brueffer.Nm 6038885006SChristian Bruefferdriver supports the following Bluetooth USB devices: 6138885006SChristian Brueffer.Pp 6238885006SChristian Brueffer.Bl -bullet -compact 6338885006SChristian Brueffer.It 6438885006SChristian Brueffer3Com 3CREB96 6538885006SChristian Brueffer.It 6638885006SChristian BruefferAIPTEK BR0R02 6738885006SChristian Brueffer.It 6838885006SChristian BruefferEPoX BT-DG02 6938885006SChristian Brueffer.It 7038885006SChristian BruefferMitsumi Bluetooth USB adapter 7138885006SChristian Brueffer.It 7238885006SChristian BruefferMSI MS-6967 7338885006SChristian Brueffer.It 7438885006SChristian BruefferTDK Bluetooth USB adapter 7538885006SChristian Brueffer.El 76878ed226SJulian Elischer.Sh HOOKS 77878ed226SJulian ElischerThis node type supports the following hooks: 7872f00208SRuslan Ermilov.Bl -tag -width indent 79878ed226SJulian Elischer.It Dv hook 8038885006SChristian Brueffersingle HCI frame contained in a single 8172f00208SRuslan Ermilov.Vt mbuf 82878ed226SJulian Elischerstructure. 83878ed226SJulian Elischer.El 84878ed226SJulian Elischer.Sh CONTROL MESSAGES 85878ed226SJulian ElischerThis node type supports the generic control messages, plus the following: 8672f00208SRuslan Ermilov.Bl -tag -width indent 87878ed226SJulian Elischer.It Dv NGM_UBT_NODE_GET_DEBUG 88878ed226SJulian ElischerReturns an integer containing the current debug level for the node. 89878ed226SJulian Elischer.It Dv NGM_UBT_NODE_SET_DEBUG 9038885006SChristian BruefferThis command takes an integer argument and sets the current debug level 91878ed226SJulian Elischerfor the node. 92878ed226SJulian Elischer.It Dv NGM_UBT_NODE_GET_QLEN 9338885006SChristian BruefferThis command takes a parameter that specifies the queue number and returns 9438885006SChristian Bruefferthe current maximal length of the queue for the node. 95878ed226SJulian Elischer.It Dv NGM_UBT_NODE_SET_QLEN 9638885006SChristian BruefferThis command takes two parameters that specify the queue number and the maximum 9738885006SChristian Bruefferlength of the queue and sets the maximal length of the queue for the node. 98878ed226SJulian Elischer.It Dv NGM_UBT_NODE_GET_STAT 99878ed226SJulian ElischerReturns various statistic information for the node, such as: number of 100878ed226SJulian Elischerbytes (frames) sent, number of bytes (frames) received and number of 101878ed226SJulian Elischerinput (output) errors. 102878ed226SJulian Elischer.It Dv NGM_UBT_NODE_RESET_STAT 103878ed226SJulian ElischerReset all statistic counters to zero. 104f2bb1caeSJulian Elischer.It Dv NGM_UBT_NODE_DEV_NODES 10538885006SChristian BruefferThis command takes a single integer parameter. 10672f00208SRuslan ErmilovIf the parameter's value is not zero, then the driver will create device nodes 10772f00208SRuslan Ermilovfor the control, interrupt, bulk-in and bulk-out endpoints. 10838885006SChristian BruefferIf the parameter's value is zero, then the driver will destroy the device nodes 10972f00208SRuslan Ermilovfor the endpoints. 11038885006SChristian BruefferThe device nodes interface is mutually exclusive with the Netgraph interface. 111f2bb1caeSJulian Elischer.El 112f2bb1caeSJulian Elischer.Sh DEVICE NODES INTERFACE 113f2bb1caeSJulian ElischerThe 11472f00208SRuslan Ermilov.Nm ubt 11572f00208SRuslan Ermilovdriver can create or destroy endpoint device nodes on request. 11638885006SChristian BruefferThis feature can be used to implement an external firmware download utility. 117f2bb1caeSJulian Elischer.Pp 11838885006SChristian BruefferControl transfers can only happen on the control endpoint which 11972f00208SRuslan Ermilovis always endpoint 0. 12072f00208SRuslan ErmilovControl requests are issued by 121f2bb1caeSJulian Elischer.Xr ioctl 2 122f2bb1caeSJulian Elischercalls. 123f2bb1caeSJulian Elischer.Pp 12472f00208SRuslan ErmilovOnly incoming transfers are supported on an interrupt endpoint. 12572f00208SRuslan ErmilovTo perform I/O on an interrupt endpoint, 126f2bb1caeSJulian Elischer.Xr read 2 12772f00208SRuslan Ermilovshould be used. 12872f00208SRuslan ErmilovAll I/O operations on an interrupt endpoint are unbuffered. 129f2bb1caeSJulian Elischer.Pp 13072f00208SRuslan ErmilovThe bulk transfers can be in or out depending on the endpoint. 13172f00208SRuslan ErmilovTo perform I/O on a bulk endpoint, 132f2bb1caeSJulian Elischer.Xr read 2 133f2bb1caeSJulian Elischerand 134f2bb1caeSJulian Elischer.Xr write 2 13572f00208SRuslan Ermilovshould be used. 13672f00208SRuslan ErmilovAll I/O operations on a bulk endpoint are unbuffered. 137f2bb1caeSJulian Elischer.Pp 138f2bb1caeSJulian ElischerThe control endpoint (endpoint 0) handles the following 139f2bb1caeSJulian Elischer.Xr ioctl 2 140f2bb1caeSJulian Elischercalls: 14172f00208SRuslan Ermilov.Bl -tag -width indent 142f2bb1caeSJulian Elischer.It Dv USB_GET_DEVICE_DESC Pq Vt usb_device_descriptor_t 143f2bb1caeSJulian ElischerReturn the device descriptor. 144f2bb1caeSJulian Elischer.It Dv USB_GET_STRING_DESC Pq Vt "struct usb_string_desc" 14572f00208SRuslan ErmilovGet a string descriptor for the given language ID and string index. 146f2bb1caeSJulian Elischer.Bd -literal 147f2bb1caeSJulian Elischerstruct usb_string_desc { 148f2bb1caeSJulian Elischer int string_index; 149f2bb1caeSJulian Elischer int language_id; 150f2bb1caeSJulian Elischer usb_string_descriptor_t desc; 151f2bb1caeSJulian Elischer}; 152f2bb1caeSJulian Elischer.Ed 153f2bb1caeSJulian Elischer.It Dv USB_DO_REQUEST Pq Vt "struct usb_ctl_request" 154f2bb1caeSJulian ElischerSend a USB request to the device on the control endpoint. 155f2bb1caeSJulian ElischerAny data sent to/from the device is located at 156f2bb1caeSJulian Elischer.Va data . 157f2bb1caeSJulian ElischerThe size of the transferred data is determined from the 158f2bb1caeSJulian Elischer.Va request . 159f2bb1caeSJulian ElischerThe 160f2bb1caeSJulian Elischer.Va addr 161f2bb1caeSJulian Elischerfield is ignored in this call. 162f2bb1caeSJulian ElischerThe 163f2bb1caeSJulian Elischer.Va flags 164f2bb1caeSJulian Elischerfield can be used to flag that the request is allowed to 165f2bb1caeSJulian Elischerbe shorter than the requested size, and the 166f2bb1caeSJulian Elischer.Va actlen 167f2bb1caeSJulian Elischerwill contain the actual size on completion. 168f2bb1caeSJulian Elischer.Bd -literal 169f2bb1caeSJulian Elischerstruct usb_ctl_request { 170f2bb1caeSJulian Elischer int addr; 171f2bb1caeSJulian Elischer usb_device_request_t request; 172f2bb1caeSJulian Elischer void *data; 173f2bb1caeSJulian Elischer int flags; 174f2bb1caeSJulian Elischer#define USBD_SHORT_XFER_OK 0x04 /* allow short reads */ 175f2bb1caeSJulian Elischer int actlen; /* actual length transferred */ 176f2bb1caeSJulian Elischer}; 177f2bb1caeSJulian Elischer.Ed 178f2bb1caeSJulian ElischerThis is a dangerous operation in that it can perform arbitrary operations 17972f00208SRuslan Ermilovon the device. 18072f00208SRuslan ErmilovSome of the most dangerous (e.g., changing the device address) are not allowed. 181f2bb1caeSJulian Elischer.It Dv USB_GET_DEVICEINFO Pq Vt "struct usb_device_info" 18272f00208SRuslan ErmilovGet an information summary for the device. 18372f00208SRuslan ErmilovThis call will not issue any USB transactions. 184878ed226SJulian Elischer.El 185878ed226SJulian Elischer.Sh SHUTDOWN 186878ed226SJulian ElischerThis node shuts down when the corresponding USB device is un-plugged. 187878ed226SJulian Elischer.Sh BUGS 18872f00208SRuslan ErmilovIsochronous USB transfers are broken. 18938885006SChristian BruefferThis means that the USB device will not be able to transfer SCO data (voice). 19072f00208SRuslan ErmilovUSB interrupt transfers are implemented as bulk-in transfers (not really a bug). 191f2bb1caeSJulian Elischer.Sh FILES 192f2bb1caeSJulian Elischer.Bl -tag -width ".Pa /dev/ubt Ns Ar N Ns Pa \&. Ns Ar EE" -compact 193f2bb1caeSJulian Elischer.It Pa /dev/ubt Ns Ar N Ns Pa \&. Ns Ar EE 194f2bb1caeSJulian ElischerEndpoint 195f2bb1caeSJulian Elischer.Ar EE 196f2bb1caeSJulian Elischerof device 197f2bb1caeSJulian Elischer.Ar N . 198f2bb1caeSJulian Elischer.El 199878ed226SJulian Elischer.Sh SEE ALSO 200f2bb1caeSJulian Elischer.Xr netgraph 4 , 20172f00208SRuslan Ermilov.Xr ugen 4 , 20272f00208SRuslan Ermilov.Xr usb 4 , 203878ed226SJulian Elischer.Xr ngctl 8 204878ed226SJulian Elischer.Sh HISTORY 205878ed226SJulian ElischerThe 20672f00208SRuslan Ermilov.Nm ubt 207878ed226SJulian Elischernode type was implemented in 208878ed226SJulian Elischer.Fx 5.0 . 209878ed226SJulian Elischer.Sh AUTHORS 210878ed226SJulian Elischer.An Maksim Yevmenkin Aq m_evmenkin@yahoo.com 211