| IEEE80211(9) | Kernel Developer's Manual | IEEE80211(9) |
IEEE80211 — 802.11
network layer
#include
<net80211/ieee80211_var.h>
void
ieee80211_ifattach(struct
ieee80211com *ic);
void
ieee80211_ifdetach(struct
ieee80211com *ic);
int
ieee80211_mhz2ieee(u_int
freq, u_int
flags);
int
ieee80211_chan2ieee(struct
ieee80211com *ic, const
struct ieee80211_channel *c);
u_int
ieee80211_ieee2mhz(u_int
chan, u_int
flags);
int
ieee80211_media_change(struct
ifnet *ifp);
void
ieee80211_media_status(struct
ifnet *ifp, struct
ifmediareq *imr);
int
ieee80211_setmode(struct
ieee80211com *ic, enum
ieee80211_phymode mode);
enum ieee80211_phymode
ieee80211_chan2mode(const struct
ieee80211_channel *chan);
int
ieee80211_rate2media(struct
ieee80211com *ic, int rate, enum
ieee80211_phymode mode);
int
ieee80211_media2rate(int
mword);
IEEE 802.11 device drivers are written to use the infrastructure
provided by the IEEE80211 software layer. This
software provides a support framework for drivers that includes ifnet
cloning, state management, and a user management API by which applications
interact with 802.11 devices. Most drivers depend on the
IEEE80211 layer for protocol services but devices
that off-load functionality may bypass the layer to connect directly to the
device (e.g. the ndis(4) emulation support does this).
A IEEE80211 device driver implements a
virtual radio API that is exported to users through network interfaces (aka
vaps) that are cloned from the underlying device. These interfaces have an
operating mode (station, adhoc, hostap, wds, monitor, etc.) that is fixed
for the lifetime of the interface. Devices that can support multiple
concurrent interfaces allow multiple vaps to be cloned. This enables
construction of interesting applications such as an AP vap and one or more
WDS vaps or multiple AP vaps, each with a different security model. The
IEEE80211 layer virtualizes most 802.11 state and
coordinates vap state changes including scheduling multiple vaps. State that
is not virtualized includes the current channel and WME/WMM parameters.
Protocol processing is typically handled entirely in the
IEEE80211 layer with drivers responsible purely for
moving data between the host and device. Similarly,
IEEE80211 handles most ioctl(2)
requests without entering the driver; instead drivers are notified of state
changes that require their involvement.
The virtual radio interface defined by the
IEEE80211 layer means that drivers must be
structured to follow specific rules. Drivers that support only a single
interface at any time must still follow these rules.
Most of these functions require that attachment to the stack is performed before calling.
The
ieee80211_ifattach()
function attaches the wireless network interface ic to
the 802.11 network stack layer. This function must be called before using
any of the IEEE80211 functions which need to store
driver state across invocations.
The
ieee80211_ifdetach()
function frees any IEEE80211 structures associated
with the driver, and performs Ethernet and BPF detachment on behalf of the
caller.
The
ieee80211_mhz2ieee()
utility function converts the frequency freq
(specified in MHz) to an IEEE 802.11 channel number. The
flags argument is a hint which specifies whether the
frequency is in the 2GHz ISM band
(IEEE80211_CHAN_2GHZ) or the 5GHz band
(IEEE80211_CHAN_5GHZ); appropriate clipping of the
result is then performed.
The
ieee80211_chan2ieee()
function converts the channel specified in *c to an
IEEE channel number for the driver ic. If the
conversion would be invalid, an error message is printed to the system
console. This function REQUIRES that the driver is hooked up to the
IEEE80211 subsystem.
The
ieee80211_ieee2mhz()
utility function converts the IEEE channel number chan
to a frequency (in MHz). The flags argument is a hint
which specifies whether the frequency is in the 2GHz ISM band
(IEEE80211_CHAN_2GHZ) or the 5GHz band
(IEEE80211_CHAN_5GHZ); appropriate clipping of the
result is then performed.
The
ieee80211_media_status()
and
ieee80211_media_change()
functions are device-independent handlers for ifmedia
commands and are not intended to be called directly.
The
ieee80211_setmode()
function is called from within the 802.11 stack to change the mode of the
driver's PHY; it is not intended to be called directly.
The
ieee80211_chan2mode()
function returns the PHY mode required for use with the channel
chan. This is typically used when selecting a rate
set, to be advertised in beacons, for example.
The
ieee80211_rate2media()
function converts the bit rate rate (measured in units
of 0.5Mbps) to an ifmedia sub-type, for the device
ic running in PHY mode mode. The
ieee80211_media2rate()
performs the reverse of this conversion, returning the bit rate (in 0.5Mbps
units) corresponding to an ifmedia sub-type.
The virtual radio architecture splits state between a single
per-device ieee80211com structure and one or more
ieee80211vap structures. Drivers are expected to setup
various shared state in these structures at device attach and during vap
creation but otherwise should treat them as read-only. The
ieee80211com structure is allocated by the
IEEE80211 layer as adjunct data to a device's
ifnet; it is accessed through the
if_l2com structure member. The
ieee80211vap structure is allocated by the driver in
the “vap create” method and should be extended with any
driver-private state. This technique of giving the driver control to
allocate data structures is used for other IEEE80211
data structures and should be exploited to maintain driver-private state
together with public IEEE80211 state.
The other main data structures are the station, or node, table that tracks peers in the local BSS, and the channel table that defines the current set of available radio channels. Both tables are bound to the ieee80211com structure and shared by all vaps. Long-lasting references to a node are counted to guard against premature reclamation. In particular every packet sent/received holds a node reference (either explicitly for transmit or implicitly on receive).
The ieee80211com and
ieee80211vap structures also hold a collection of
method pointers that drivers fill-in and/or override to take control of
certain operations. These methods are the primary way drivers are bound to
the IEEE80211 layer and are described below.
Drivers attach to the IEEE80211 layer with
the
ieee80211_ifattach()
function. The driver is expected to allocate and setup any device-private
data structures before passing control. The
ieee80211com structure must be pre-initialized with
state required to setup the IEEE80211 layer:
ic_ifpic_capsic_channelsic_nchanic_channels.On return from
ieee80211_ifattach()
the driver is expected to override default callback functions in the
ieee80211com structure to register it's private
routines. Methods marked with a “*” must be provided by the
driver.
ic_vap_create*ic_vap_delete*ic_vap_create.ic_getradiocapsic_setregdomainic_send_mgmtIEEE80211 state and passes it to the driver
through the ic_raw_xmit method.ic_raw_xmitic_updateslotic_update_mcastic_update_promiscic_newassocic_node_allocM_80211_NODE to balance
the memory allocation statistics.ic_node_freeic_node_alloc. Drivers are expected to
interpose
their own method to cleanup private state but must call through this
method to allow IEEE80211 to reclaim it's private
state.ic_node_cleanupic_node_alloc. This operation is distinguished
from ic_node_free in that it may be called long
before the node is actually reclaimed to cleanup adjunct state. This can
happen, for example, when a node must not be reclaimed due to references
held by packets in the transmit queue. Drivers typically interpose
ic_node_cleanup instead of
ic_node_free.ic_node_ageic_node_drainic_node_getrssiic_node_getsignal. The default method
calculates a filtered average over the last ten samples passed in to
ieee80211_input(9) or
ieee80211_input_all(9).ic_node_getsignalic_node_getmimoinfoIEEE80211_IOC_STA_INFO ioctl request. The default
method returns nothing.ic_scan_start*ic_scan_end*ic_set_channel*ic_scan_curchanic_scan_mindwellic_recv_actionic_send_actionic_ampdu_enableic_addba_requestic_addb_responseic_addb_stopic_bar_responseic_ampdu_rx_startic_ampdu_rx_stopOnce the IEEE80211 layer is attached to a
driver there are two more steps typically done to complete the work:
State is torn down and reclaimed with a
call to
ieee80211_ifdetach().
Note this call may result in multiple callbacks into the driver so it should
be done before any critical driver state is reclaimed. On return from
ieee80211_ifdetach() all associated vaps and ifnet
structures are reclaimed or inaccessible to user applications so it is safe
to teardown driver state without worry about being re-entered. The driver is
responsible for calling if_free(9) on the ifnet it
allocated for the physical device.
Driver/device capabilities are specified using several sets of
flags in the ieee80211com structure. General
capabilities are specified by ic_caps. Hardware
cryptographic capabilities are specified by
ic_cryptocaps. 802.11n capabilities, if any, are
specified by ic_htcaps. The
IEEE80211 layer propagates a subset of these
capabilities to each vap through the equivalent fields:
iv_caps, iv_cryptocaps, and
iv_htcaps. The following general capabilities are
defined:
IEEE80211_C_STAIEEE80211_C_8023ENCAPIEEE80211 will encapsulate all outbound
frames as 802.11 frames (without a PLCP header).IEEE80211_C_FFIEEE80211_C_TURBOPIEEE80211_C_IBSSIEEE80211_C_PMGTIEEE80211_C_HOSTAPIEEE80211_C_AHDEMOIEEE80211_C_SWRETRYIEEE80211_C_TXPMGTIEEE80211_C_SHSLOTIEEE80211_C_SHPREAMBLEIEEE80211_C_MONITORIEEE80211_C_DFSIEEE80211 but the device must be
capable of detecting radar events.IEEE80211_C_MBSSIEEE80211_C_WPA1IEEE80211_C_WPA2IEEE80211_C_BURSTIEEE80211_C_WMEIEEE80211_C_WDSIEEE80211_C_BGSCANIEEE80211_C_TXFRAGIEEE80211_C_TDMAThe follow general crypto capabilities are defined. In general
IEEE80211 will fall-back to software support when a
device is not capable of hardware acceleration of a cipher. This can be done
on a per-key basis. IEEE80211 can also handle
software Michael calculation combined with hardware
AES acceleration.
IEEE80211_CRYPTO_WEPIEEE80211_CRYPTO_TKIPIEEE80211_CRYPTO_AES_OCBIEEE80211_CRYPTO_AES_CCMIEEE80211_CRYPTO_TKIPMICIEEE80211_CRYPTO_CKIPThe follow general 802.11n capabilities are defined. The first
capabilities are defined exactly as they appear in the 802.11n
specification. Capabilities beginning with IEEE80211_HTC_AMPDU are used
solely by the IEEE80211 layer.
IEEE80211_HTCAP_CHWIDTH40IEEE80211_HTCAP_SMPS_DYNAMICIEEE80211_HTCAP_SMPS_ENAIEEE80211_HTCAP_GREENFIELDIEEE80211_HTCAP_SHORTGI20IEEE80211_HTCAP_SHORTGI40IEEE80211_HTCAP_TXSTBCIEEE80211_HTCAP_RXSTBC_1STREAMIEEE80211_HTCAP_RXSTBC_2STREAMIEEE80211_HTCAP_RXSTBC_3STREAMIEEE80211_HTCAP_MAXAMSDU_7935IEEE80211_HTCAP_MAXAMSDU_3839IEEE80211_HTCAP_DSSSCCK40IEEE80211_HTCAP_PSMPIEEE80211_HTCAP_40INTOLERANTIEEE80211_HTCAP_LSIGTXOPPROTIEEE80211_HTC_AMPDUIEEE80211_HTC_AMSDUIEEE80211_HTC_HTIEEE80211.IEEE80211_HTC_SMPSIEEE80211_HTC_RIFSioctl(2), ndis(4), ieee80211_amrr(9), ieee80211_beacon(9), ieee80211_bmiss(9), ieee80211_crypto(9), ieee80211_ddb(9), ieee80211_input(9), ieee80211_node(9), ieee80211_output(9), ieee80211_proto(9), ieee80211_radiotap(9), ieee80211_regdomain(9), ieee80211_scan(9), ieee80211_vap(9), ifnet(9), malloc(9)
The IEEE80211 series of functions first
appeared in NetBSD 1.5, and were later ported to
FreeBSD 4.6. This man page was updated with the
information from NetBSD
IEEE80211 man page.
The original NetBSD
IEEE80211 man page was written by
Bruce M. Simpson
<bms@FreeBSD.org> and
Darron Broad
<darron@kewl.org>.
| December 31, 2017 | Debian |