Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v5.3-rc3 457 lines 18 kB view raw
1================================ 2Linux UWB + Wireless USB + WiNET 3================================ 4 5 Copyright (C) 2005-2006 Intel Corporation 6 7 Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 8 9 This program is free software; you can redistribute it and/or 10 modify it under the terms of the GNU General Public License version 11 2 as published by the Free Software Foundation. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 02110-1301, USA. 22 23 24Please visit http://bughost.org/thewiki/Design-overview.txt-1.8 for 25updated content. 26 27 * Design-overview.txt-1.8 28 29This code implements a Ultra Wide Band stack for Linux, as well as 30drivers for the USB based UWB radio controllers defined in the 31Wireless USB 1.0 specification (including Wireless USB host controller 32and an Intel WiNET controller). 33 34.. Contents 35 1. Introduction 36 1. HWA: Host Wire adapters, your Wireless USB dongle 37 38 2. DWA: Device Wired Adaptor, a Wireless USB hub for wired 39 devices 40 3. WHCI: Wireless Host Controller Interface, the PCI WUSB host 41 adapter 42 2. The UWB stack 43 1. Devices and hosts: the basic structure 44 45 2. Host Controller life cycle 46 47 3. On the air: beacons and enumerating the radio neighborhood 48 49 4. Device lists 50 5. Bandwidth allocation 51 52 3. Wireless USB Host Controller drivers 53 54 4. Glossary 55 56 57Introduction 58============ 59 60UWB is a wide-band communication protocol that is to serve also as the 61low-level protocol for others (much like TCP sits on IP). Currently 62these others are Wireless USB and TCP/IP, but seems Bluetooth and 63Firewire/1394 are coming along. 64 65UWB uses a band from roughly 3 to 10 GHz, transmitting at a max of 66~-41dB (or 0.074 uW/MHz--geography specific data is still being 67negotiated w/ regulators, so watch for changes). That band is divided in 68a bunch of ~1.5 GHz wide channels (or band groups) composed of three 69subbands/subchannels (528 MHz each). Each channel is independent of each 70other, so you could consider them different "busses". Initially this 71driver considers them all a single one. 72 73Radio time is divided in 65536 us long /superframes/, each one divided 74in 256 256us long /MASs/ (Media Allocation Slots), which are the basic 75time/media allocation units for transferring data. At the beginning of 76each superframe there is a Beacon Period (BP), where every device 77transmit its beacon on a single MAS. The length of the BP depends on how 78many devices are present and the length of their beacons. 79 80Devices have a MAC (fixed, 48 bit address) and a device (changeable, 16 81bit address) and send periodic beacons to advertise themselves and pass 82info on what they are and do. They advertise their capabilities and a 83bunch of other stuff. 84 85The different logical parts of this driver are: 86 87 * 88 89 *UWB*: the Ultra-Wide-Band stack -- manages the radio and 90 associated spectrum to allow for devices sharing it. Allows to 91 control bandwidth assignment, beaconing, scanning, etc 92 93 * 94 95 *WUSB*: the layer that sits on top of UWB to provide Wireless USB. 96 The Wireless USB spec defines means to control a UWB radio and to 97 do the actual WUSB. 98 99 100HWA: Host Wire adapters, your Wireless USB dongle 101------------------------------------------------- 102 103WUSB also defines a device called a Host Wire Adaptor (HWA), which in 104mere terms is a USB dongle that enables your PC to have UWB and Wireless 105USB. The Wireless USB Host Controller in a HWA looks to the host like a 106[Wireless] USB controller connected via USB (!) 107 108The HWA itself is broken in two or three main interfaces: 109 110 * 111 112 *RC*: Radio control -- this implements an interface to the 113 Ultra-Wide-Band radio controller. The driver for this implements a 114 USB-based UWB Radio Controller to the UWB stack. 115 116 * 117 118 *HC*: the wireless USB host controller. It looks like a USB host 119 whose root port is the radio and the WUSB devices connect to it. 120 To the system it looks like a separate USB host. The driver (will) 121 implement a USB host controller (similar to UHCI, OHCI or EHCI) 122 for which the root hub is the radio...To reiterate: it is a USB 123 controller that is connected via USB instead of PCI. 124 125 * 126 127 *WINET*: some HW provide a WiNET interface (IP over UWB). This 128 package provides a driver for it (it looks like a network 129 interface, winetX). The driver detects when there is a link up for 130 their type and kick into gear. 131 132 133DWA: Device Wired Adaptor, a Wireless USB hub for wired devices 134--------------------------------------------------------------- 135 136These are the complement to HWAs. They are a USB host for connecting 137wired devices, but it is connected to your PC connected via Wireless 138USB. To the system it looks like yet another USB host. To the untrained 139eye, it looks like a hub that connects upstream wirelessly. 140 141We still offer no support for this; however, it should share a lot of 142code with the HWA-RC driver; there is a bunch of factorization work that 143has been done to support that in upcoming releases. 144 145 146WHCI: Wireless Host Controller Interface, the PCI WUSB host adapter 147------------------------------------------------------------------- 148 149This is your usual PCI device that implements WHCI. Similar in concept 150to EHCI, it allows your wireless USB devices (including DWAs) to connect 151to your host via a PCI interface. As in the case of the HWA, it has a 152Radio Control interface and the WUSB Host Controller interface per se. 153 154There is still no driver support for this, but will be in upcoming 155releases. 156 157 158The UWB stack 159============= 160 161The main mission of the UWB stack is to keep a tally of which devices 162are in radio proximity to allow drivers to connect to them. As well, it 163provides an API for controlling the local radio controllers (RCs from 164now on), such as to start/stop beaconing, scan, allocate bandwidth, etc. 165 166 167Devices and hosts: the basic structure 168-------------------------------------- 169 170The main building block here is the UWB device (struct uwb_dev). For 171each device that pops up in radio presence (ie: the UWB host receives a 172beacon from it) you get a struct uwb_dev that will show up in 173/sys/bus/uwb/devices. 174 175For each RC that is detected, a new struct uwb_rc and struct uwb_dev are 176created. An entry is also created in /sys/class/uwb_rc for each RC. 177 178Each RC driver is implemented by a separate driver that plugs into the 179interface that the UWB stack provides through a struct uwb_rc_ops. The 180spec creators have been nice enough to make the message format the same 181for HWA and WHCI RCs, so the driver is really a very thin transport that 182moves the requests from the UWB API to the device [/uwb_rc_ops->cmd()/] 183and sends the replies and notifications back to the API 184[/uwb_rc_neh_grok()/]. Notifications are handled to the UWB daemon, that 185is chartered, among other things, to keep the tab of how the UWB radio 186neighborhood looks, creating and destroying devices as they show up or 187disappear. 188 189Command execution is very simple: a command block is sent and a event 190block or reply is expected back. For sending/receiving command/events, a 191handle called /neh/ (Notification/Event Handle) is opened with 192/uwb_rc_neh_open()/. 193 194The HWA-RC (USB dongle) driver (drivers/uwb/hwa-rc.c) does this job for 195the USB connected HWA. Eventually, drivers/whci-rc.c will do the same 196for the PCI connected WHCI controller. 197 198 199Host Controller life cycle 200-------------------------- 201 202So let's say we connect a dongle to the system: it is detected and 203firmware uploaded if needed [for Intel's i1480 204/drivers/uwb/ptc/usb.c:ptc_usb_probe()/] and then it is reenumerated. 205Now we have a real HWA device connected and 206/drivers/uwb/hwa-rc.c:hwarc_probe()/ picks it up, that will set up the 207Wire-Adaptor environment and then suck it into the UWB stack's vision of 208the world [/drivers/uwb/lc-rc.c:uwb_rc_add()/]. 209 210 * 211 212 [*] The stack should put a new RC to scan for devices 213 [/uwb_rc_scan()/] so it finds what's available around and tries to 214 connect to them, but this is policy stuff and should be driven 215 from user space. As of now, the operator is expected to do it 216 manually; see the release notes for documentation on the procedure. 217 218When a dongle is disconnected, /drivers/uwb/hwa-rc.c:hwarc_disconnect()/ 219takes time of tearing everything down safely (or not...). 220 221 222On the air: beacons and enumerating the radio neighborhood 223---------------------------------------------------------- 224 225So assuming we have devices and we have agreed for a channel to connect 226on (let's say 9), we put the new RC to beacon: 227 228 * 229 230 $ echo 9 0 > /sys/class/uwb_rc/uwb0/beacon 231 232Now it is visible. If there were other devices in the same radio channel 233and beacon group (that's what the zero is for), the dongle's radio 234control interface will send beacon notifications on its 235notification/event endpoint (NEEP). The beacon notifications are part of 236the event stream that is funneled into the API with 237/drivers/uwb/neh.c:uwb_rc_neh_grok()/ and delivered to the UWBD, the UWB 238daemon through a notification list. 239 240UWBD wakes up and scans the event list; finds a beacon and adds it to 241the BEACON CACHE (/uwb_beca/). If he receives a number of beacons from 242the same device, he considers it to be 'onair' and creates a new device 243[/drivers/uwb/lc-dev.c:uwbd_dev_onair()/]. Similarly, when no beacons 244are received in some time, the device is considered gone and wiped out 245[uwbd calls periodically /uwb/beacon.c:uwb_beca_purge()/ that will purge 246the beacon cache of dead devices]. 247 248 249Device lists 250------------ 251 252All UWB devices are kept in the list of the struct bus_type uwb_bus_type. 253 254 255Bandwidth allocation 256-------------------- 257 258The UWB stack maintains a local copy of DRP availability through 259processing of incoming *DRP Availability Change* notifications. This 260local copy is currently used to present the current bandwidth 261availability to the user through the sysfs file 262/sys/class/uwb_rc/uwbx/bw_avail. In the future the bandwidth 263availability information will be used by the bandwidth reservation 264routines. 265 266The bandwidth reservation routines are in progress and are thus not 267present in the current release. When completed they will enable a user 268to initiate DRP reservation requests through interaction with sysfs. DRP 269reservation requests from remote UWB devices will also be handled. The 270bandwidth management done by the UWB stack will include callbacks to the 271higher layers will enable the higher layers to use the reservations upon 272completion. [Note: The bandwidth reservation work is in progress and 273subject to change.] 274 275 276Wireless USB Host Controller drivers 277==================================== 278 279*WARNING* This section needs a lot of work! 280 281As explained above, there are three different types of HCs in the WUSB 282world: HWA-HC, DWA-HC and WHCI-HC. 283 284HWA-HC and DWA-HC share that they are Wire-Adapters (USB or WUSB 285connected controllers), and their transfer management system is almost 286identical. So is their notification delivery system. 287 288HWA-HC and WHCI-HC share that they are both WUSB host controllers, so 289they have to deal with WUSB device life cycle and maintenance, wireless 290root-hub 291 292HWA exposes a Host Controller interface (HWA-HC 0xe0/02/02). This has 293three endpoints (Notifications, Data Transfer In and Data Transfer 294Out--known as NEP, DTI and DTO in the code). 295 296We reserve UWB bandwidth for our Wireless USB Cluster, create a Cluster 297ID and tell the HC to use all that. Then we start it. This means the HC 298starts sending MMCs. 299 300 * 301 302 The MMCs are blocks of data defined somewhere in the WUSB1.0 spec 303 that define a stream in the UWB channel time allocated for sending 304 WUSB IEs (host to device commands/notifications) and Device 305 Notifications (device initiated to host). Each host defines a 306 unique Wireless USB cluster through MMCs. Devices can connect to a 307 single cluster at the time. The IEs are Information Elements, and 308 among them are the bandwidth allocations that tell each device 309 when can they transmit or receive. 310 311Now it all depends on external stimuli. 312 313New device connection 314--------------------- 315 316A new device pops up, it scans the radio looking for MMCs that give out 317the existence of Wireless USB channels. Once one (or more) are found, 318selects which one to connect to. Sends a /DN_Connect/ (device 319notification connect) during the DNTS (Device Notification Time 320Slot--announced in the MMCs 321 322HC picks the /DN_Connect/ out (nep module sends to notif.c for delivery 323into /devconnect/). This process starts the authentication process for 324the device. First we allocate a /fake port/ and assign an 325unauthenticated address (128 to 255--what we really do is 3260x80 | fake_port_idx). We fiddle with the fake port status and /hub_wq/ 327sees a new connection, so he moves on to enable the fake port with a reset. 328 329So now we are in the reset path -- we know we have a non-yet enumerated 330device with an unauthorized address; we ask user space to authenticate 331(FIXME: not yet done, similar to bluetooth pairing), then we do the key 332exchange (FIXME: not yet done) and issue a /set address 0/ to bring the 333device to the default state. Device is authenticated. 334 335From here, the USB stack takes control through the usb_hcd ops. hub_wq 336has seen the port status changes, as we have been toggling them. It will 337start enumerating and doing transfers through usb_hcd->urb_enqueue() to 338read descriptors and move our data. 339 340Device life cycle and keep alives 341--------------------------------- 342 343Every time there is a successful transfer to/from a device, we update a 344per-device activity timestamp. If not, every now and then we check and 345if the activity timestamp gets old, we ping the device by sending it a 346Keep Alive IE; it responds with a /DN_Alive/ pong during the DNTS (this 347arrives to us as a notification through 348devconnect.c:wusb_handle_dn_alive(). If a device times out, we 349disconnect it from the system (cleaning up internal information and 350toggling the bits in the fake hub port, which kicks hub_wq into removing 351the rest of the stuff). 352 353This is done through devconnect:__wusb_check_devs(), which will scan the 354device list looking for whom needs refreshing. 355 356If the device wants to disconnect, it will either die (ugly) or send a 357/DN_Disconnect/ that will prompt a disconnection from the system. 358 359Sending and receiving data 360-------------------------- 361 362Data is sent and received through /Remote Pipes/ (rpipes). An rpipe is 363/aimed/ at an endpoint in a WUSB device. This is the same for HWAs and 364DWAs. 365 366Each HC has a number of rpipes and buffers that can be assigned to them; 367when doing a data transfer (xfer), first the rpipe has to be aimed and 368prepared (buffers assigned), then we can start queueing requests for 369data in or out. 370 371Data buffers have to be segmented out before sending--so we send first a 372header (segment request) and then if there is any data, a data buffer 373immediately after to the DTI interface (yep, even the request). If our 374buffer is bigger than the max segment size, then we just do multiple 375requests. 376 377[This sucks, because doing USB scatter gatter in Linux is resource 378intensive, if any...not that the current approach is not. It just has to 379be cleaned up a lot :)]. 380 381If reading, we don't send data buffers, just the segment headers saying 382we want to read segments. 383 384When the xfer is executed, we receive a notification that says data is 385ready in the DTI endpoint (handled through 386xfer.c:wa_handle_notif_xfer()). In there we read from the DTI endpoint a 387descriptor that gives us the status of the transfer, its identification 388(given when we issued it) and the segment number. If it was a data read, 389we issue another URB to read into the destination buffer the chunk of 390data coming out of the remote endpoint. Done, wait for the next guy. The 391callbacks for the URBs issued from here are the ones that will declare 392the xfer complete at some point and call its callback. 393 394Seems simple, but the implementation is not trivial. 395 396 * 397 398 *WARNING* Old!! 399 400The main xfer descriptor, wa_xfer (equivalent to a URB) contains an 401array of segments, tallys on segments and buffers and callback 402information. Buried in there is a lot of URBs for executing the segments 403and buffer transfers. 404 405For OUT xfers, there is an array of segments, one URB for each, another 406one of buffer URB. When submitting, we submit URBs for segment request 4071, buffer 1, segment 2, buffer 2...etc. Then we wait on the DTI for xfer 408result data; when all the segments are complete, we call the callback to 409finalize the transfer. 410 411For IN xfers, we only issue URBs for the segments we want to read and 412then wait for the xfer result data. 413 414URB mapping into xfers 415^^^^^^^^^^^^^^^^^^^^^^ 416 417This is done by hwahc_op_urb_[en|de]queue(). In enqueue() we aim an 418rpipe to the endpoint where we have to transmit, create a transfer 419context (wa_xfer) and submit it. When the xfer is done, our callback is 420called and we assign the status bits and release the xfer resources. 421 422In dequeue() we are basically cancelling/aborting the transfer. We issue 423a xfer abort request to the HC, cancel all the URBs we had submitted 424and not yet done and when all that is done, the xfer callback will be 425called--this will call the URB callback. 426 427 428Glossary 429======== 430 431*DWA* -- Device Wire Adapter 432 433USB host, wired for downstream devices, upstream connects wirelessly 434with Wireless USB. 435 436*EVENT* -- Response to a command on the NEEP 437 438*HWA* -- Host Wire Adapter / USB dongle for UWB and Wireless USB 439 440*NEH* -- Notification/Event Handle 441 442Handle/file descriptor for receiving notifications or events. The WA 443code requires you to get one of this to listen for notifications or 444events on the NEEP. 445 446*NEEP* -- Notification/Event EndPoint 447 448Stuff related to the management of the first endpoint of a HWA USB 449dongle that is used to deliver an stream of events and notifications to 450the host. 451 452*NOTIFICATION* -- Message coming in the NEEP as response to something. 453 454*RC* -- Radio Control 455 456Design-overview.txt-1.8 (last edited 2006-11-04 12:22:24 by 457InakyPerezGonzalez)