Lines Matching +full:link +full:- +full:trigger +full:- +full:order
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2012-2013, Marco Porsch <marco.porsch@s2005.tu-chemnitz.de>
4 * Copyright 2012-2013, cozybit Inc.
16 * mps_qos_null_get - create pre-addressed QoS Null frame for mesh powersave
23 struct ieee80211_sub_if_data *sdata = sta->sdata; in mps_qos_null_get()
24 struct ieee80211_local *local = sdata->local; in mps_qos_null_get()
30 skb = dev_alloc_skb(local->hw.extra_tx_headroom + size + 2); in mps_qos_null_get()
33 skb_reserve(skb, local->hw.extra_tx_headroom); in mps_qos_null_get()
37 ieee80211_fill_mesh_addresses(nullfunc, &fc, sta->sta.addr, in mps_qos_null_get()
38 sdata->vif.addr); in mps_qos_null_get()
39 nullfunc->frame_control = fc; in mps_qos_null_get()
40 nullfunc->duration_id = 0; in mps_qos_null_get()
41 nullfunc->seq_ctrl = 0; in mps_qos_null_get()
42 /* no address resolution for this frame -> set addr 1 immediately */ in mps_qos_null_get()
43 memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); in mps_qos_null_get()
51 * mps_qos_null_tx - send a QoS Null to indicate link-specific power mode
62 mps_dbg(sta->sdata, "announcing peer-specific power mode to %pM\n", in mps_qos_null_tx()
63 sta->sta.addr); in mps_qos_null_tx()
67 u8 *qc = ieee80211_get_qos_ctl((void *) skb->data); in mps_qos_null_tx()
72 ieee80211_tx_skb(sta->sdata, skb); in mps_qos_null_tx()
76 * ieee80211_mps_local_status_update - track status of local link-specific PMs
80 * sets the non-peer power mode and triggers the driver PS (re-)configuration
83 * Returns: BSS_CHANGED_BEACON if a beacon update is in order.
87 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in ieee80211_mps_local_status_update()
96 list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) { in ieee80211_mps_local_status_update()
97 if (sdata != sta->sdata) in ieee80211_mps_local_status_update()
100 switch (sta->mesh->plink_state) { in ieee80211_mps_local_status_update()
107 if (sta->mesh->local_pm == NL80211_MESH_POWER_LIGHT_SLEEP) in ieee80211_mps_local_status_update()
109 else if (sta->mesh->local_pm == NL80211_MESH_POWER_DEEP_SLEEP) in ieee80211_mps_local_status_update()
119 * Set non-peer mode to active during peering/scanning/authentication in ieee80211_mps_local_status_update()
120 * (see IEEE802.11-2012 13.14.8.3). The non-peer mesh power mode is in ieee80211_mps_local_status_update()
123 * user-configured default value. in ieee80211_mps_local_status_update()
126 mps_dbg(sdata, "setting non-peer PM to active for peering\n"); in ieee80211_mps_local_status_update()
129 mps_dbg(sdata, "setting non-peer PM to deep sleep\n"); in ieee80211_mps_local_status_update()
132 mps_dbg(sdata, "setting non-peer PM to user value\n"); in ieee80211_mps_local_status_update()
133 nonpeer_pm = ifmsh->mshcfg.power_mode; in ieee80211_mps_local_status_update()
136 /* need update if sleep counts move between 0 and non-zero */ in ieee80211_mps_local_status_update()
137 if (ifmsh->nonpeer_pm != nonpeer_pm || in ieee80211_mps_local_status_update()
138 !ifmsh->ps_peers_light_sleep != !light_sleep_cnt || in ieee80211_mps_local_status_update()
139 !ifmsh->ps_peers_deep_sleep != !deep_sleep_cnt) in ieee80211_mps_local_status_update()
142 ifmsh->nonpeer_pm = nonpeer_pm; in ieee80211_mps_local_status_update()
143 ifmsh->ps_peers_light_sleep = light_sleep_cnt; in ieee80211_mps_local_status_update()
144 ifmsh->ps_peers_deep_sleep = deep_sleep_cnt; in ieee80211_mps_local_status_update()
150 * ieee80211_mps_set_sta_local_pm - set local PM towards a mesh STA
154 * Returns: BSS_CHANGED_BEACON if a beacon update is in order.
159 struct ieee80211_sub_if_data *sdata = sta->sdata; in ieee80211_mps_set_sta_local_pm()
161 if (sta->mesh->local_pm == pm) in ieee80211_mps_set_sta_local_pm()
165 pm, sta->sta.addr); in ieee80211_mps_set_sta_local_pm()
167 sta->mesh->local_pm = pm; in ieee80211_mps_set_sta_local_pm()
170 * announce peer-specific power mode transition in ieee80211_mps_set_sta_local_pm()
171 * (see IEEE802.11-2012 13.14.3.2 and 13.14.3.3) in ieee80211_mps_set_sta_local_pm()
173 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB) in ieee80211_mps_set_sta_local_pm()
180 * ieee80211_mps_set_frame_flags - set mesh PS flags in FC (and QoS Control)
186 * see IEEE802.11-2012 8.2.4.1.7 and 8.2.4.5.11
188 * NOTE: sta must be given when an individually-addressed QoS frame header
189 * is handled, for group-addressed and management frames it is not used
198 if (WARN_ON(is_unicast_ether_addr(hdr->addr1) && in ieee80211_mps_set_frame_flags()
199 ieee80211_is_data_qos(hdr->frame_control) && in ieee80211_mps_set_frame_flags()
203 if (is_unicast_ether_addr(hdr->addr1) && in ieee80211_mps_set_frame_flags()
204 ieee80211_is_data_qos(hdr->frame_control) && in ieee80211_mps_set_frame_flags()
205 sta->mesh->plink_state == NL80211_PLINK_ESTAB) in ieee80211_mps_set_frame_flags()
206 pm = sta->mesh->local_pm; in ieee80211_mps_set_frame_flags()
208 pm = sdata->u.mesh.nonpeer_pm; in ieee80211_mps_set_frame_flags()
211 hdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_PM); in ieee80211_mps_set_frame_flags()
213 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); in ieee80211_mps_set_frame_flags()
215 if (!ieee80211_is_data_qos(hdr->frame_control)) in ieee80211_mps_set_frame_flags()
220 if ((is_unicast_ether_addr(hdr->addr1) && in ieee80211_mps_set_frame_flags()
222 (is_multicast_ether_addr(hdr->addr1) && in ieee80211_mps_set_frame_flags()
223 sdata->u.mesh.ps_peers_deep_sleep > 0)) in ieee80211_mps_set_frame_flags()
230 * ieee80211_mps_sta_status_update - update buffering status of neighbor STA
234 * called after change of peering status or non-peer/peer-specific power mode
241 /* For non-assoc STA, prevent buffering or frame transmission */ in ieee80211_mps_sta_status_update()
242 if (sta->sta_state < IEEE80211_STA_ASSOC) in ieee80211_mps_sta_status_update()
246 * use peer-specific power mode if peering is established and the in ieee80211_mps_sta_status_update()
249 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB && in ieee80211_mps_sta_status_update()
250 sta->mesh->peer_pm != NL80211_MESH_POWER_UNKNOWN) in ieee80211_mps_sta_status_update()
251 pm = sta->mesh->peer_pm; in ieee80211_mps_sta_status_update()
253 pm = sta->mesh->nonpeer_pm; in ieee80211_mps_sta_status_update()
257 /* clear the MPSP flags for non-peers or active STA */ in ieee80211_mps_sta_status_update()
258 if (sta->mesh->plink_state != NL80211_PLINK_ESTAB) { in ieee80211_mps_sta_status_update()
271 atomic_inc(&sta->sdata->u.mesh.ps.num_sta_ps); in ieee80211_mps_sta_status_update()
272 mps_dbg(sta->sdata, "start PS buffering frames towards %pM\n", in ieee80211_mps_sta_status_update()
273 sta->sta.addr); in ieee80211_mps_sta_status_update()
290 * +----+----+---------+ in mps_set_sta_peer_pm()
295 if (ieee80211_has_pm(hdr->frame_control)) { in mps_set_sta_peer_pm()
304 if (sta->mesh->peer_pm == pm) in mps_set_sta_peer_pm()
307 mps_dbg(sta->sdata, "STA %pM enters mode %d\n", in mps_set_sta_peer_pm()
308 sta->sta.addr, pm); in mps_set_sta_peer_pm()
310 sta->mesh->peer_pm = pm; in mps_set_sta_peer_pm()
320 if (ieee80211_has_pm(hdr->frame_control)) in mps_set_sta_nonpeer_pm()
325 if (sta->mesh->nonpeer_pm == pm) in mps_set_sta_nonpeer_pm()
328 mps_dbg(sta->sdata, "STA %pM sets non-peer mode to %d\n", in mps_set_sta_nonpeer_pm()
329 sta->sta.addr, pm); in mps_set_sta_nonpeer_pm()
331 sta->mesh->nonpeer_pm = pm; in mps_set_sta_nonpeer_pm()
337 * ieee80211_mps_rx_h_sta_process - frame receive handler for mesh powersave
345 if (is_unicast_ether_addr(hdr->addr1) && in ieee80211_mps_rx_h_sta_process()
346 ieee80211_is_data_qos(hdr->frame_control)) { in ieee80211_mps_rx_h_sta_process()
349 * peer link-specific PS mode towards the local STA in ieee80211_mps_rx_h_sta_process()
353 /* check for mesh Peer Service Period trigger frames */ in ieee80211_mps_rx_h_sta_process()
358 * can only determine non-peer PS mode in ieee80211_mps_rx_h_sta_process()
359 * (see IEEE802.11-2012 8.2.4.1.7) in ieee80211_mps_rx_h_sta_process()
370 struct ieee80211_sub_if_data *sdata = sta->sdata; in mpsp_trigger_send()
380 nullfunc = (struct ieee80211_hdr *) skb->data; in mpsp_trigger_send()
382 nullfunc->frame_control |= in mpsp_trigger_send()
386 * +------+------+--------------------+ in mpsp_trigger_send()
390 * | 1 | 1 | peer STA is owner | see IEEE802.11-2012 13.14.9.2 in mpsp_trigger_send()
400 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER | in mpsp_trigger_send()
403 mps_dbg(sdata, "sending MPSP trigger%s%s to %pM\n", in mpsp_trigger_send()
404 rspi ? " RSPI" : "", eosp ? " EOSP" : "", sta->sta.addr); in mpsp_trigger_send()
410 * mpsp_qos_null_append - append QoS Null frame to MPSP skb queue if needed
421 struct ieee80211_sub_if_data *sdata = sta->sdata; in mpsp_qos_null_append()
423 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; in mpsp_qos_null_append()
426 if (ieee80211_is_data_qos(hdr->frame_control)) in mpsp_qos_null_append()
434 sta->sta.addr); in mpsp_qos_null_append()
439 new_skb->priority = 1; in mpsp_qos_null_append()
444 info->control.vif = &sdata->vif; in mpsp_qos_null_append()
445 info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING; in mpsp_qos_null_append()
451 * mps_frame_deliver - transmit frames during mesh powersave
454 * @n_frames: number of frames to transmit. -1 for all
458 struct ieee80211_local *local = sta->sdata->local; in mps_frame_deliver()
469 skb = skb_dequeue(&sta->tx_filtered[ac]); in mps_frame_deliver()
472 &sta->ps_tx_buf[ac]); in mps_frame_deliver()
474 local->total_ps_buffered--; in mps_frame_deliver()
478 n_frames--; in mps_frame_deliver()
482 if (!skb_queue_empty(&sta->tx_filtered[ac]) || in mps_frame_deliver()
483 !skb_queue_empty(&sta->ps_tx_buf[ac])) in mps_frame_deliver()
487 /* nothing to send? -> EOSP */ in mps_frame_deliver()
497 mps_dbg(sta->sdata, "sending %d frames to PS STA %pM\n", in mps_frame_deliver()
498 skb_queue_len(&frames), sta->sta.addr); in mps_frame_deliver()
503 struct ieee80211_hdr *hdr = (void *) skb->data; in mps_frame_deliver()
510 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; in mps_frame_deliver()
513 hdr->frame_control |= in mps_frame_deliver()
516 hdr->frame_control &= in mps_frame_deliver()
520 ieee80211_is_data_qos(hdr->frame_control)) { in mps_frame_deliver()
523 /* MPSP trigger frame ends service period */ in mps_frame_deliver()
525 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; in mps_frame_deliver()
534 * ieee80211_mpsp_trigger_process - track status of mesh Peer Service Periods
558 mps_frame_deliver(sta, -1); in ieee80211_mpsp_trigger_process()
562 else if (sta->mesh->local_pm != NL80211_MESH_POWER_ACTIVE) in ieee80211_mpsp_trigger_process()
566 mps_frame_deliver(sta, -1); in ieee80211_mpsp_trigger_process()
571 * ieee80211_mps_frame_release - release frames buffered due to mesh power save
576 * For peers if we have individually-addressed frames buffered or the peer
577 * indicates buffered frames, send a corresponding MPSP trigger frame. Since
579 * trigger frames. If the neighbour STA is not a peer, only send single frames.
587 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB) in ieee80211_mps_frame_release()
588 has_buffered = ieee80211_check_tim(elems->tim, elems->tim_len, in ieee80211_mps_frame_release()
589 sta->mesh->aid); in ieee80211_mps_frame_release()
592 mps_dbg(sta->sdata, "%pM indicates buffered frames\n", in ieee80211_mps_frame_release()
593 sta->sta.addr); in ieee80211_mps_frame_release()
595 /* only transmit to PS STA with announced, non-zero awake window */ in ieee80211_mps_frame_release()
597 (!elems->awake_window || !get_unaligned_le16(elems->awake_window))) in ieee80211_mps_frame_release()
602 buffer_local += skb_queue_len(&sta->ps_tx_buf[ac]) + in ieee80211_mps_frame_release()
603 skb_queue_len(&sta->tx_filtered[ac]); in ieee80211_mps_frame_release()
608 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB) in ieee80211_mps_frame_release()