Linux Kernel
3.7.1
|
#include <linux/limits.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/timer.h>
#include <linux/wait.h>
#include <linux/workqueue.h>
#include <linux/uwb/spec.h>
#include <asm/page.h>
Go to the source code of this file.
Data Structures | |
struct | uwb_dev |
struct | uwb_notifs_chain |
struct | uwb_beca |
struct | uwbd |
struct | uwb_mas_bm |
struct | uwb_rsv_target |
struct | uwb_rsv_move |
struct | uwb_rsv |
struct | uwb_drp_avail |
struct | uwb_drp_backoff_win |
struct | uwb_rc |
struct | uwb_pal |
struct | uwb_notifs_handler |
struct | uwb_est_entry |
struct | edc |
struct | stats |
Macros | |
#define | to_uwb_dev(d) container_of(d, struct uwb_dev, dev) |
#define | UWB_NUM_GLOBAL_STREAMS 1 |
Typedefs | |
typedef void(* | uwb_rsv_cb_f )(struct uwb_rsv *rsv) |
Functions | |
const char * | uwb_rsv_state_str (enum uwb_rsv_state state) |
const char * | uwb_rsv_type_str (enum uwb_drp_type type) |
struct uwb_rsv * | uwb_rsv_create (struct uwb_rc *rc, uwb_rsv_cb_f cb, void *pal_priv) |
void | uwb_rsv_destroy (struct uwb_rsv *rsv) |
int | uwb_rsv_establish (struct uwb_rsv *rsv) |
int | uwb_rsv_modify (struct uwb_rsv *rsv, int max_mas, int min_mas, int sparsity) |
void | uwb_rsv_terminate (struct uwb_rsv *rsv) |
void | uwb_rsv_accept (struct uwb_rsv *rsv, uwb_rsv_cb_f cb, void *pal_priv) |
void | uwb_rsv_get_usable_mas (struct uwb_rsv *orig_rsv, struct uwb_mas_bm *mas) |
Callback function for 'uwb_{dev,rc}_foreach()'.
: Linux device instance 'uwb_dev = container_of(dev, struct uwb_dev, dev)' : Data passed by the caller to 'uwb_{dev,rc}_foreach()'.
anonymous enum |
enum uwb_notifs |
enum uwb_notifs - UWB events that can be passed to any listeners : a new neighbour has joined the beacon group. : a neighbour has left the beacon group.
Higher layers can register callback functions with the radio controller using uwb_notifs_register(). The radio controller maintains a list of all registered handlers and will notify all nodes when an event occurs.
enum uwb_rsv_state |
uwb_rsv_state - UWB Reservation state.
NONE - reservation is not active (no DRP IE being transmitted).
Owner reservation states:
INITIATED - owner has sent an initial DRP request. PENDING - target responded with pending Reason Code. MODIFIED - reservation manager is modifying an established reservation with a different MAS allocation. ESTABLISHED - the reservation has been successfully negotiated.
Target reservation states:
DENIED - request is denied. ACCEPTED - request is accepted. PENDING - PAL has yet to make a decision to whether to accept or deny.
FIXME: further target states TBD.
enum uwb_rsv_target_type |
int uwb_dev_for_each | ( | struct uwb_rc * | rc, |
uwb_dev_for_each_f | function, | ||
void * | priv | ||
) |
Iterate over the list of UWB devices, calling a on each
See docs for bus_for_each()....
: radio controller for the devices. : function to call. : data to pass to .
|
read |
Guesses the size of a WA event
: pointer to the buffer with the event : size of the area pointed to by in bytes.
This will look at the received RCEB and guess what is the total size by checking all the tables registered with uwb_est_register(). For variable sized events, it will look further ahead into their length field to see how much data should be read.
Note this size is not final–the neh (Notification/Event Handle) might specificy an extra size to add or replace.
int uwb_est_register | ( | u8 | type, |
u8 | event_high, | ||
u16 | vendor, | ||
u16 | product, | ||
const struct uwb_est_entry * | entry, | ||
size_t | entries | ||
) |
Register an event size table
Makes room for it if the table is full, and then inserts it in the right position (entries are sorted by type, event_high, vendor and then product).
: vendor code for matching against the device (0x0000 and 0xffff mean any); use 0x0000 to force all to match without checking possible vendor specific ones, 0xfffff to match after checking vendor specific ones.
: product code from that vendor; same matching rules, use 0x0000 for not allowing vendor specific matches, 0xffff for allowing.
This arragement just makes the tables sort differenty. Because the table is sorted by growing type-event_high-vendor-product, a zero vendor will match before than a 0x456a vendor, that will match before a 0xfffff vendor.
int uwb_est_unregister | ( | u8 | type, |
u8 | event_high, | ||
u16 | vendor, | ||
u16 | product, | ||
const struct uwb_est_entry * | entry, | ||
size_t | entries | ||
) |
Unregister an event size table
This just removes the specified entry and moves the ones after it to fill in the gap. This is needed to keep the list sorted; no reallocation is done to reduce the size of the table.
We unregister by all the data we used to register instead of by pointer to the array because we might have used the same table for a bunch of IDs (for example).
|
read |
uwb_ie_next - get the next IE in a buffer : start of the buffer containing the IE data : length of the buffer
Both and are updated so subsequent calls to uwb_ie_next() will get the next IE.
NULL is returned (and and will not be updated) if there are no more IEs in the buffer or the buffer is too short.
int uwb_notifs_deregister | ( | struct uwb_rc * | , |
struct uwb_notifs_handler * | |||
) |
int uwb_notifs_register | ( | struct uwb_rc * | , |
struct uwb_notifs_handler * | |||
) |
uwb_pal_register - register a UWB PAL : the PAL
The PAL must be initialized with uwb_pal_init().
Register a new UWB radio controller
Did you call uwb_rc_init() on your rc?
We assume that this is being called with a > 0 refcount on it [through ops->{get|put}_device(). We'll take our own, though.
is our real device, the one that provides the actual UWB device
ssize_t uwb_rc_cmd | ( | struct uwb_rc * | rc, |
const char * | cmd_name, | ||
struct uwb_rccb * | cmd, | ||
size_t | cmd_size, | ||
struct uwb_rceb * | reply, | ||
size_t | reply_size | ||
) |
Generic function for issuing commands to the Radio Control Interface
: UWB Radio Control descriptor : Name of the command being issued (for error messages) : Pointer to rccb structure containing the command; normally you embed this structure as the first member of the full command structure. : Size of the whole command buffer pointed to by . : Pointer to the beginning of the confirmation event buffer. Normally bigger than an 'struct hwarc_rceb'. You need to fill out reply->bEventType and reply->wEvent (in cpu order) as the function will use them to verify the confirmation event. : Size of the reply buffer
The function checks that the length returned in the reply is at least as big as ; if not, it will be deemed an error and -EIO returned.
needs to be referenced
int uwb_rc_dev_addr_get | ( | struct uwb_rc * | rc, |
struct uwb_dev_addr * | addr | ||
) |
|
read |
Locate and refcount a radio controller given a common grand-parent
Pointer to the 'grandparent' device structure.
The Radio Control interface (or the UWB Radio Controller) is always an interface of a device. The parent is the interface, the grandparent is the device that encapsulates the interface.
There is no need to lock around as the "grandpa" would be refcounted by the target, and to remove the referemes, the uwb_rc_class->sem would have to be taken–we hold it, ergo we should be safe.
uwb_rc_ie_add - add new IEs to the radio controller's beacon : the radio controller. : the buffer containing the new IE or IEs to be added to the device's beacon. : length of all the IEs.
According to WHCI 0.95 [4.13.6] the driver will only receive the RCEB after the device sent the first beacon that includes the IEs specified in the SET IE command. We thus cannot send this command if the device is not beaconing. Instead, a SET IE command will be sent later right after we start beaconing.
Setting an IE on the device will overwrite all current IEs in device. So we take the current IEs being transmitted by the device, insert the new one, and call SET IE with all the IEs needed.
Returns 0 on success; or -ENOMEM.
int uwb_rc_mac_addr_get | ( | struct uwb_rc * | rc, |
struct uwb_mac_addr * | addr | ||
) |
Given a buffer with one or more UWB RC events/notifications, break them up and dispatch them.
: UWB Radio Controller : Buffer with the stream of notifications/events : Amount of data in the buffer
Note each notification/event starts always with a 'struct uwb_rceb', so the minimum size if 4 bytes.
The device may pass us events formatted differently than expected. These are first filtered, potentially creating a new event in a new memory location. If a new event is created by the filter it is also freed here.
For each notif/event, tries to guess the size looking at the EST tables, then looks for a neh that is waiting for that event and if found, copies the payload to the neh's buffer and calls it back. If not, the data is ignored.
Note that if we can't find a size description in the EST tables, we still might find a size in the 'neh' handle in uwb_rc_neh_lookup().
Assumptions:
->neh_lock is NOT taken
We keep track of various sizes here: size: contains the size of the buffer that is processed for the incoming event. this buffer may contain events that are not formatted as WHCI. real_size: the actual space taken by this event in the buffer. We need to keep track of the real size of an event to be able to advance the buffer correctly. event_size: the size of the event as expected by the core layer [OR] the size of the event after filtering. if the filtering created a new event in a new memory location then this is effectively the size of a new event buffer
ssize_t uwb_rc_vcmd | ( | struct uwb_rc * | rc, |
const char * | cmd_name, | ||
struct uwb_rccb * | cmd, | ||
size_t | cmd_size, | ||
u8 | expected_type, | ||
u16 | expected_event, | ||
struct uwb_rceb ** | preply | ||
) |
Generic function for issuing commands to the Radio Control Interface that return an unknown amount of data
: UWB Radio Control descriptor : Name of the command being issued (for error messages) : Pointer to rccb structure containing the command; normally you embed this structure as the first member of the full command structure. : Size of the whole command buffer pointed to by . : Expected type in the return event : Expected event code in the return event : Here a pointer to where the event data is received will be stored. Once done with the data, free with kfree().
The function checks that the length returned in the reply is at least as big as a 'struct uwb_rceb *'; if not, it will be deemed an error and -EIO returned.
needs to be referenced
void uwb_rsv_accept | ( | struct uwb_rsv * | rsv, |
uwb_rsv_cb_f | cb, | ||
void * | pal_priv | ||
) |
uwb_rsv_accept - accept a new reservation from a peer : the reservation : call back for reservation changes : data to be passed in the above call back
Reservation requests from peers are denied unless a PAL accepts it by calling this function.
The PAL call uwb_rsv_destroy() for all accepted reservations before calling uwb_pal_unregister().
uwb_rsv_create - allocate and initialize a UWB reservation structure : the radio controller : callback to use when the reservation completes or terminates : data private to the PAL to be passed in the callback
The callback is called when the state of the reservation changes from:
usb_rsv_establish - start a reservation establishment : the reservation
The PAL should fill in 's owner, target, type, max_mas, min_mas, max_interval and is_multicast fields. If the target is a uwb_dev it must be referenced.
The reservation's callback will be called when the reservation is accepted, denied or times out.
void uwb_rsv_get_usable_mas | ( | struct uwb_rsv * | rsv, |
struct uwb_mas_bm * | mas | ||
) |
const char* uwb_rsv_state_str | ( | enum uwb_rsv_state | state | ) |
uwb_rsv_terminate - terminate an established reservation : the reservation to terminate
A reservation is terminated by removing the DRP IE from the beacon, the other end will consider the reservation to be terminated when it does not see the DRP IE for at least mMaxLostBeacons.
If applicable, the reference to the target uwb_dev will be released.