xref: /freebsd/share/man/man9/ieee80211_proto.9 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
13f3f4cdbSBruce M Simpson.\"
2692eebe0SSam Leffler.\" Copyright (c) 2009 Sam Leffler, Errno Consulting
33f3f4cdbSBruce M Simpson.\" All rights reserved.
43f3f4cdbSBruce M Simpson.\"
53f3f4cdbSBruce M Simpson.\" Redistribution and use in source and binary forms, with or without
63f3f4cdbSBruce M Simpson.\" modification, are permitted provided that the following conditions
73f3f4cdbSBruce M Simpson.\" are met:
83f3f4cdbSBruce M Simpson.\" 1. Redistributions of source code must retain the above copyright
93f3f4cdbSBruce M Simpson.\"    notice, this list of conditions and the following disclaimer.
103f3f4cdbSBruce M Simpson.\" 2. Redistributions in binary form must reproduce the above copyright
113f3f4cdbSBruce M Simpson.\"    notice, this list of conditions and the following disclaimer in the
123f3f4cdbSBruce M Simpson.\"    documentation and/or other materials provided with the distribution.
133f3f4cdbSBruce M Simpson.\"
143f3f4cdbSBruce M Simpson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
153f3f4cdbSBruce M Simpson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
163f3f4cdbSBruce M Simpson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
173f3f4cdbSBruce M Simpson.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
183f3f4cdbSBruce M Simpson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
193f3f4cdbSBruce M Simpson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
203f3f4cdbSBruce M Simpson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
213f3f4cdbSBruce M Simpson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
223f3f4cdbSBruce M Simpson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
233f3f4cdbSBruce M Simpson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
243f3f4cdbSBruce M Simpson.\" SUCH DAMAGE.
253f3f4cdbSBruce M Simpson.\"
26692eebe0SSam Leffler.Dd August 4, 2009
272e777780SRuslan Ermilov.Dt IEEE80211_PROTO 9
283f3f4cdbSBruce M Simpson.Os
293f3f4cdbSBruce M Simpson.Sh NAME
303f3f4cdbSBruce M Simpson.Nm ieee80211_proto
31692eebe0SSam Leffler.Nd 802.11 state machine support
323f3f4cdbSBruce M Simpson.Sh SYNOPSIS
333f3f4cdbSBruce M Simpson.In net80211/ieee80211_var.h
34692eebe0SSam Leffler.Pp
353f3f4cdbSBruce M Simpson.Ft void
36692eebe0SSam Leffler.Fn ieee80211_start_all "struct ieee80211com *"
373f3f4cdbSBruce M Simpson.Ft void
38692eebe0SSam Leffler.Fn ieee80211_stop_all "struct ieee80211com *"
393f3f4cdbSBruce M Simpson.Ft void
40692eebe0SSam Leffler.Fn ieee80211_suspend_all "struct ieee80211com *"
413f3f4cdbSBruce M Simpson.Ft void
42692eebe0SSam Leffler.Fn ieee80211_resume_all "struct ieee80211com *"
43692eebe0SSam Leffler.Pp
44692eebe0SSam Leffler.Dv enum ieee80211_state ;
453f3f4cdbSBruce M Simpson.Ft int
46692eebe0SSam Leffler.Fn ieee80211_new_state "struct ieee80211vap *" "enum ieee80211_state" "int"
47692eebe0SSam Leffler.Pp
48692eebe0SSam Leffler.Ft void
49692eebe0SSam Leffler.Fn ieee80211_wait_for_parent "struct ieee80211com *"
503f3f4cdbSBruce M Simpson.Sh DESCRIPTION
51692eebe0SSam LefflerThe
52692eebe0SSam Leffler.Nm net80211
53692eebe0SSam Lefflerlayer that supports 802.11 device drivers uses a state machine
54692eebe0SSam Lefflerto control operation of vaps.
55692eebe0SSam LefflerThese state machines vary according to the vap operating mode.
56692eebe0SSam LefflerStation mode state machines follow the 802.11 MLME states
57692eebe0SSam Lefflerin the protocol specification.
58692eebe0SSam LefflerOther state machines are simpler and reflect operational work
59692eebe0SSam Lefflersuch as scanning for a BSS or automatically selecting a channel to
60692eebe0SSam Leffleroperate on.
61692eebe0SSam LefflerWhen multiple vaps are operational the state machines are used to
62692eebe0SSam Lefflercoordinate operation such as choosing a channel.
63692eebe0SSam LefflerThe state machine mechanism also serves to bind the
64692eebe0SSam Leffler.Nm net80211
65692eebe0SSam Lefflerlayer to a driver; this is described more below.
66692eebe0SSam Leffler.Pp
67692eebe0SSam LefflerThe following states are defined for state machines:
68692eebe0SSam Leffler.Bl -tag -width IEEE80211_S_ASSOC
69692eebe0SSam Leffler.It Dv IEEE80211_S_INIT
70692eebe0SSam LefflerDefault/initial state.
71692eebe0SSam LefflerA vap in this state should not hold any dynamic state (e.g. entries
72692eebe0SSam Lefflerfor associated stations in the node table).
73692eebe0SSam LefflerThe driver must quiesce the hardware; e.g. there should be no
74692eebe0SSam Lefflerinterrupts firing.
75692eebe0SSam Leffler.It Dv IEEE80211_S_SCAN
76692eebe0SSam LefflerScanning for a BSS or choosing a channel to operate on.
77692eebe0SSam LefflerNote that scanning can also take place in other states (e.g. when
78692eebe0SSam Lefflerbackground scanning is active); this state is entered when
79692eebe0SSam Lefflerinitially bringing a vap to an operational state or after an
80692eebe0SSam Lefflerevent such as a beacon miss (in station mode).
81692eebe0SSam Leffler.It Dv IEEE80211_S_AUTH
82692eebe0SSam LefflerAuthenticating to an access point (in station mode).
83692eebe0SSam LefflerThis state is normally reached from
84692eebe0SSam Leffler.Dv IEEE80211_S_SCAN
85692eebe0SSam Lefflerafter selecting a BSS, but may also be reached from
86692eebe0SSam Leffler.Dv IEEE80211_S_ASSOC
87692eebe0SSam Leffleror
88692eebe0SSam Leffler.Dv IEEE80211_S_RUN
89692eebe0SSam Lefflerif the authentication handshake fails.
90692eebe0SSam Leffler.It Dv IEEE80211_S_ASSOC
91692eebe0SSam LefflerAssociating to an access point (in station mode).
92692eebe0SSam LefflerThis state is reached from
93692eebe0SSam Leffler.Dv IEEE80211_S_AUTH
94692eebe0SSam Lefflerafter successfully authenticating or from
95692eebe0SSam Leffler.Dv IEEE80211_S_RUN
96692eebe0SSam Lefflerif a DisAssoc frame is received.
97692eebe0SSam Leffler.It Dv IEEE80211_S_CAC
98692eebe0SSam LefflerDoing Channel Availability Check (CAC).
99692eebe0SSam LefflerThis state is entered only when DFS is enabled and the channel selected
100692eebe0SSam Lefflerfor operation requires CAC.
101692eebe0SSam Leffler.It Dv IEEE80211_S_RUN
102692eebe0SSam LefflerOperational.
103692eebe0SSam LefflerIn this state a vap can transmit data frames, accept requests for
104692eebe0SSam Lefflerstations associating, etc.
105692eebe0SSam LefflerBeware that data traffic is also gated by whether the associated
106692eebe0SSam Leffler.Dq port
107692eebe0SSam Leffleris authorized.
108692eebe0SSam LefflerWhen WPA/802.11i/802.1x is operational authorization may happen separately;
109692eebe0SSam Lefflere.g. in station mode
110692eebe0SSam Leffler.Xr wpa_supplicant 8
111692eebe0SSam Lefflermust complete the handshakes and plumb the necessary keys before a port
112692eebe0SSam Leffleris authorized.
113692eebe0SSam LefflerIn this state a BSS is operational and associated state is valid and may
114692eebe0SSam Lefflerbe used; e.g.
115692eebe0SSam Leffler.Vt ic_bss
116692eebe0SSam Lefflerand
117692eebe0SSam Leffler.Vt ic_bsschan
118692eebe0SSam Lefflerare guaranteed to be usable.
119692eebe0SSam Leffler.It Dv IEEE80211_S_CSA
120ace02a6dSChristian BruefferChannel Switch Announcement (CSA) is pending.
121692eebe0SSam LefflerThis state is reached only from
122692eebe0SSam Leffler.Dv IEEE80211_S_RUN
123692eebe0SSam Lefflerwhen either a CSA is received from an access point (in station mode)
124692eebe0SSam Leffleror the local station is preparing to change channel.
125692eebe0SSam LefflerIn this state traffic may be muted depending on the Mute setting in the CSA.
126692eebe0SSam Leffler.It Dv IEEE80211_S_SLEEP
127692eebe0SSam LefflerAsleep to save power (in station mode).
128692eebe0SSam LefflerThis state is reached only from
129692eebe0SSam Leffler.Dv IEEE80211_S_RUN
130692eebe0SSam Lefflerwhen power save operation is enabled and the local station is deemed
131692eebe0SSam Lefflersufficiently idle to enter low power mode.
132692eebe0SSam Leffler.El
133692eebe0SSam Leffler.Pp
134692eebe0SSam LefflerNote that states are ordered (as shown above);
135692eebe0SSam Lefflere.g. a vap must be in the
136692eebe0SSam Leffler.Dv IEEE80211_S_RUN
137692eebe0SSam Leffleror
138692eebe0SSam Leffler.Dq greater
139692eebe0SSam Lefflerbefore it can transmit frames.
140692eebe0SSam LefflerCertain
141692eebe0SSam Leffler.Nm net80211
142692eebe0SSam Lefflerdata are valid only in certain states; e.g. the
143692eebe0SSam Leffler.Vt iv_bsschan
144692eebe0SSam Lefflerthat specifies the channel for the operating BSS should never be used
145692eebe0SSam Lefflerexcept in
146692eebe0SSam Leffler.Dv IEEE80211_S_RUN
147692eebe0SSam Leffleror greater.
148692eebe0SSam Leffler.Sh STATE CHANGES
149692eebe0SSam LefflerState machine changes are typically handled internal to the
150692eebe0SSam Leffler.Nm net80211
151692eebe0SSam Lefflerlayer in response to
152692eebe0SSam Leffler.Xr ioctl 2
153692eebe0SSam Lefflerrequests, received frames, or external events such as a beacon miss.
154692eebe0SSam LefflerThe
155692eebe0SSam Leffler.Fn ieee80211_new_state
156692eebe0SSam Lefflerfunction is used to initiate a state machine change on a vap.
157692eebe0SSam LefflerThe new state and an optional argument are supplied.
158692eebe0SSam LefflerThe request is initially processed to handle coordination of multiple vaps.
159692eebe0SSam LefflerFor example, only one vap at a time can be scanning, if multiple vaps
160692eebe0SSam Lefflerrequest a change to
161692eebe0SSam Leffler.Dv IEEE80211_S_SCAN
162692eebe0SSam Lefflerthe first will be permitted to run and the others will be
163692eebe0SSam Leffler.Em deferred
164692eebe0SSam Leffleruntil the scan operation completes at which time the selected channel
165692eebe0SSam Lefflerwill be adopted.
166692eebe0SSam LefflerSimilarly
167692eebe0SSam Leffler.Nm net80211
168692eebe0SSam Lefflerhandles coordination of combinations of vaps such as an AP and station vap
169692eebe0SSam Lefflerwhere the station may need to roam to follow the AP it is associated to
170692eebe0SSam Leffler(dragging along the AP vap to the new channel).
171692eebe0SSam LefflerAnother important coordination is the handling of
172692eebe0SSam Leffler.Dv IEEE80211_S_CAC
173692eebe0SSam Lefflerand
174692eebe0SSam Leffler.Dv IEEE80211_S_CSA .
175692eebe0SSam LefflerNo more than one vap can ever be actively changing state at a time.
176692eebe0SSam LefflerIn fact
177692eebe0SSam Leffler.Nm net80211
178692eebe0SSam Lefflersingle-threads the state machine logic in a dedicated
179692eebe0SSam Leffler.Xr taskqueue 9
180692eebe0SSam Lefflerthread that is also used to synchronize work such as scanning and
181692eebe0SSam Lefflerbeacon miss handling.
182692eebe0SSam Leffler.Pp
183692eebe0SSam LefflerAfter multi-vap scheduling/coordination is done the per-vap
184692eebe0SSam Leffler.Vt iv_newstate
185692eebe0SSam Lefflermethod is called to carry out the state change work.
186692eebe0SSam LefflerDrivers use this entry to setup private state and then dispatch
187692eebe0SSam Lefflerthe call to the
188692eebe0SSam Leffler.Nm net80211
189692eebe0SSam Lefflerlayer using the previously defined method pointer (in OOP-parlance they
190692eebe0SSam Lefflercall the
191692eebe0SSam Leffler.Dq super method
192692eebe0SSam Leffler).
193692eebe0SSam Leffler.Pp
194692eebe0SSam Leffler.Nm net80211
195692eebe0SSam Lefflerhandles two state changes specially.
196692eebe0SSam LefflerOn transition to
197692eebe0SSam Leffler.Dv IEEE80211_S_RUN
198692eebe0SSam Lefflerthe
199692eebe0SSam Leffler.Dv IFF_DRV_OACTIVE
200692eebe0SSam Lefflerbit on the vap's transmit queue is cleared so traffic can flow.
201692eebe0SSam LefflerOn transition to
202692eebe0SSam Leffler.Dv IEEE80211_S_INIT
203692eebe0SSam Lefflerany state in the scan cache associated with the vap is flushed
204692eebe0SSam Lefflerand any frames pending on the transmit queue are flushed.
205692eebe0SSam Leffler.Sh DRIVER INTEGRATION
206692eebe0SSam LefflerDrivers are expected to override the
207692eebe0SSam Leffler.Vt iv_newstate
208692eebe0SSam Lefflermethod to interpose their own code and handle setup work required
209692eebe0SSam Lefflerby state changes.
210692eebe0SSam LefflerOtherwise drivers must call
211692eebe0SSam Leffler.Fn ieee80211_start_all
212692eebe0SSam Lefflerin response to being marked up through an
213692eebe0SSam Leffler.Dv SIOCSIFFLAGS
214692eebe0SSam Lefflerioctl request and they should use
215692eebe0SSam Leffler.Fn ieee80211_suspend_all
216692eebe0SSam Lefflerand
217692eebe0SSam Leffler.Fn ieee80211_resume_all
218692eebe0SSam Lefflerto implement suspend/resume support.
219692eebe0SSam Leffler.Pp
220692eebe0SSam LefflerThere is also an
221692eebe0SSam Leffler.Fn ieee80211_stop_all
222692eebe0SSam Lefflercall to force all vaps to an
223692eebe0SSam Leffler.Dv IEEE80211_S_INIT
224692eebe0SSam Lefflerstate but this should not be needed by a driver; control is usually
225692eebe0SSam Lefflerhandled by
226692eebe0SSam Leffler.Nm net80211
227692eebe0SSam Leffleror, in the case of card eject or vap destroy,
228692eebe0SSam Lefflerwork will be initiated outside the driver.
2293f3f4cdbSBruce M Simpson.Sh SEE ALSO
230ace02a6dSChristian Brueffer.Xr ioctl 2 ,
231ace02a6dSChristian Brueffer.Xr wpa_supplicant 8 ,
2323f3f4cdbSBruce M Simpson.Xr ieee80211 9 ,
233ace02a6dSChristian Brueffer.Xr ifnet 9 ,
234692eebe0SSam Leffler.Xr taskqueue 9
2353f3f4cdbSBruce M Simpson.Sh HISTORY
236692eebe0SSam LefflerThe state machine concept was part of the original
2372e777780SRuslan Ermilov.Nm ieee80211
238692eebe0SSam Lefflercode base that first appeared in
239*73bbeaa5SGlen Barber.Nx 1.5 .
240