Lines Matching +full:idle +full:- +full:wait +full:- +full:delay

1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
5 * Copyright (C) 2018-2020, 2022-2024 Intel Corporation
9 #include "time-event.h"
10 #include "iwl-io.h"
11 #include "iwl-prph.h"
22 lockdep_assert_held(&mvm->mutex); in iwl_mvm_teardown_tdls_peers()
24 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) { in iwl_mvm_teardown_tdls_peers()
25 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i], in iwl_mvm_teardown_tdls_peers()
26 lockdep_is_held(&mvm->mutex)); in iwl_mvm_teardown_tdls_peers()
27 if (!sta || IS_ERR(sta) || !sta->tdls) in iwl_mvm_teardown_tdls_peers()
31 ieee80211_tdls_oper_request(mvmsta->vif, sta->addr, in iwl_mvm_teardown_tdls_peers()
45 lockdep_assert_held(&mvm->mutex); in iwl_mvm_tdls_sta_count()
47 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) { in iwl_mvm_tdls_sta_count()
48 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i], in iwl_mvm_tdls_sta_count()
49 lockdep_is_held(&mvm->mutex)); in iwl_mvm_tdls_sta_count()
50 if (!sta || IS_ERR(sta) || !sta->tdls) in iwl_mvm_tdls_sta_count()
55 if (mvmsta->vif != vif) in iwl_mvm_tdls_sta_count()
80 lockdep_assert_held(&mvm->mutex); in iwl_mvm_tdls_config()
83 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color)); in iwl_mvm_tdls_config()
91 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) { in iwl_mvm_tdls_config()
92 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i], in iwl_mvm_tdls_config()
93 lockdep_is_held(&mvm->mutex)); in iwl_mvm_tdls_config()
94 if (IS_ERR_OR_NULL(sta) || !sta->tdls) in iwl_mvm_tdls_config()
102 cpu_to_le32(sta->tdls_initiator ? 1 : 0); in iwl_mvm_tdls_config()
137 if (fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_recalc_tdls_state()
151 u32 duration = 2 * vif->bss_conf.dtim_period * vif->bss_conf.beacon_int; in iwl_mvm_mac_mgd_protect_tdls_discover()
155 if (fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_mac_mgd_protect_tdls_discover()
169 return "IDLE"; in iwl_mvm_tdls_cs_state_str()
186 if (mvm->tdls_cs.state == state) in iwl_mvm_tdls_update_cs_state()
189 IWL_DEBUG_TDLS(mvm, "TDLS channel switch state: %s -> %s\n", in iwl_mvm_tdls_update_cs_state()
190 iwl_mvm_tdls_cs_state_str(mvm->tdls_cs.state), in iwl_mvm_tdls_update_cs_state()
192 mvm->tdls_cs.state = state; in iwl_mvm_tdls_update_cs_state()
194 /* we only send requests to our switching peer - update sent time */ in iwl_mvm_tdls_update_cs_state()
196 mvm->tdls_cs.peer.sent_timestamp = iwl_mvm_get_systime(mvm); in iwl_mvm_tdls_update_cs_state()
199 mvm->tdls_cs.cur_sta_id = IWL_MVM_INVALID_STA; in iwl_mvm_tdls_update_cs_state()
205 struct iwl_tdls_channel_switch_notif *notif = (void *)pkt->data; in iwl_mvm_rx_tdls_notif()
207 unsigned int delay; in iwl_mvm_rx_tdls_notif() local
210 u32 sta_id = le32_to_cpu(notif->sta_id); in iwl_mvm_rx_tdls_notif()
212 lockdep_assert_held(&mvm->mutex); in iwl_mvm_rx_tdls_notif()
215 if (!le32_to_cpu(notif->status)) { in iwl_mvm_rx_tdls_notif()
220 if (WARN_ON(sta_id >= mvm->fw->ucode_capa.num_stations)) in iwl_mvm_rx_tdls_notif()
223 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id], in iwl_mvm_rx_tdls_notif()
224 lockdep_is_held(&mvm->mutex)); in iwl_mvm_rx_tdls_notif()
226 if (IS_ERR_OR_NULL(sta) || WARN_ON(!sta->tdls)) in iwl_mvm_rx_tdls_notif()
230 vif = mvmsta->vif; in iwl_mvm_rx_tdls_notif()
236 delay = TU_TO_MS(vif->bss_conf.dtim_period * vif->bss_conf.beacon_int); in iwl_mvm_rx_tdls_notif()
237 mod_delayed_work(system_wq, &mvm->tdls_cs.dwork, in iwl_mvm_rx_tdls_notif()
238 msecs_to_jiffies(delay)); in iwl_mvm_rx_tdls_notif()
252 if (mvm->tdls_cs.state != IWL_MVM_TDLS_SW_IDLE && in iwl_mvm_tdls_check_action()
253 mvm->tdls_cs.cur_sta_id != IWL_MVM_INVALID_STA) { in iwl_mvm_tdls_check_action()
255 mvm->fw_id_to_mac_id[mvm->tdls_cs.cur_sta_id], in iwl_mvm_tdls_check_action()
256 lockdep_is_held(&mvm->mutex)); in iwl_mvm_tdls_check_action()
258 same_peer = ether_addr_equal(peer, sta->addr); in iwl_mvm_tdls_check_action()
261 switch (mvm->tdls_cs.state) { in iwl_mvm_tdls_check_action()
268 ret = -EINVAL; in iwl_mvm_tdls_check_action()
273 ret = -EBUSY; in iwl_mvm_tdls_check_action()
277 * We received a ch-switch request while an outgoing in iwl_mvm_tdls_check_action()
281 ret = -EBUSY; in iwl_mvm_tdls_check_action()
283 /* wait for idle before sending another request */ in iwl_mvm_tdls_check_action()
284 ret = -EBUSY; in iwl_mvm_tdls_check_action()
285 else if (timestamp <= mvm->tdls_cs.peer.sent_timestamp) in iwl_mvm_tdls_check_action()
286 /* we got a stale response - ignore it */ in iwl_mvm_tdls_check_action()
287 ret = -EINVAL; in iwl_mvm_tdls_check_action()
294 ret = -EBUSY; in iwl_mvm_tdls_check_action()
300 ret = -EBUSY; in iwl_mvm_tdls_check_action()
302 ret = -EBUSY; in iwl_mvm_tdls_check_action()
304 ret = -EINVAL; in iwl_mvm_tdls_check_action()
310 * to the base channel by the current off-channel peer in iwl_mvm_tdls_check_action()
313 ret = -EBUSY; in iwl_mvm_tdls_check_action()
320 type, mvm->tdls_cs.state, peer, same_peer, in iwl_mvm_tdls_check_action()
344 u16 len = sizeof(cmd) - iwl_mvm_chan_info_padding(mvm); in iwl_mvm_tdls_config_channel_switch()
347 lockdep_assert_held(&mvm->mutex); in iwl_mvm_tdls_config_channel_switch()
354 if (!skb || WARN_ON(skb->len > IWL_TDLS_CH_SW_FRAME_MAX_SIZE)) { in iwl_mvm_tdls_config_channel_switch()
355 ret = -EINVAL; in iwl_mvm_tdls_config_channel_switch()
360 tail->timing.frame_timestamp = cpu_to_le32(timestamp); in iwl_mvm_tdls_config_channel_switch()
361 tail->timing.switch_time = cpu_to_le32(switch_time); in iwl_mvm_tdls_config_channel_switch()
362 tail->timing.switch_timeout = cpu_to_le32(switch_timeout); in iwl_mvm_tdls_config_channel_switch()
368 ret = -ENOENT; in iwl_mvm_tdls_config_channel_switch()
372 cmd.peer_sta_id = cpu_to_le32(mvmsta->deflink.sta_id); in iwl_mvm_tdls_config_channel_switch()
375 if (mvm->tdls_cs.state == IWL_MVM_TDLS_SW_REQ_SENT && in iwl_mvm_tdls_config_channel_switch()
376 mvm->tdls_cs.peer.chandef.chan) { in iwl_mvm_tdls_config_channel_switch()
378 chandef = &mvm->tdls_cs.peer.chandef; in iwl_mvm_tdls_config_channel_switch()
379 } else if (mvm->tdls_cs.state == IWL_MVM_TDLS_SW_ACTIVE && in iwl_mvm_tdls_config_channel_switch()
383 rcu_dereference(vif->bss_conf.chanctx_conf); in iwl_mvm_tdls_config_channel_switch()
390 chandef = &chanctx->def; in iwl_mvm_tdls_config_channel_switch()
397 /* keep quota calculation simple for now - 50% of DTIM for TDLS */ in iwl_mvm_tdls_config_channel_switch()
398 tail->timing.max_offchan_duration = in iwl_mvm_tdls_config_channel_switch()
399 cpu_to_le32(TU_TO_US(vif->bss_conf.dtim_period * in iwl_mvm_tdls_config_channel_switch()
400 vif->bss_conf.beacon_int) / 2); in iwl_mvm_tdls_config_channel_switch()
402 /* Switch time is the first element in the switch-timing IE. */ in iwl_mvm_tdls_config_channel_switch()
403 tail->frame.switch_time_offset = cpu_to_le32(ch_sw_tm_ie + 2); in iwl_mvm_tdls_config_channel_switch()
406 hdr = (void *)skb->data; in iwl_mvm_tdls_config_channel_switch()
407 if (info->control.hw_key) { in iwl_mvm_tdls_config_channel_switch()
408 if (info->control.hw_key->cipher != WLAN_CIPHER_SUITE_CCMP) { in iwl_mvm_tdls_config_channel_switch()
410 ret = -EINVAL; in iwl_mvm_tdls_config_channel_switch()
413 iwl_mvm_set_tx_cmd_ccmp(info, &tail->frame.tx_cmd); in iwl_mvm_tdls_config_channel_switch()
416 iwl_mvm_set_tx_cmd(mvm, skb, &tail->frame.tx_cmd, info, in iwl_mvm_tdls_config_channel_switch()
417 mvmsta->deflink.sta_id); in iwl_mvm_tdls_config_channel_switch()
419 iwl_mvm_set_tx_cmd_rate(mvm, &tail->frame.tx_cmd, info, sta, in iwl_mvm_tdls_config_channel_switch()
420 hdr->frame_control); in iwl_mvm_tdls_config_channel_switch()
423 memcpy(tail->frame.data, skb->data, skb->len); in iwl_mvm_tdls_config_channel_switch()
434 mvm->tdls_cs.cur_sta_id = mvmsta->deflink.sta_id; in iwl_mvm_tdls_config_channel_switch()
445 /* channel switch failed - we are idle */ in iwl_mvm_tdls_config_channel_switch()
458 unsigned int delay; in iwl_mvm_tdls_ch_switch_work() local
464 /* called after an active channel switch has finished or timed-out */ in iwl_mvm_tdls_ch_switch_work()
468 if (mvm->tdls_cs.peer.sta_id == IWL_MVM_INVALID_STA) in iwl_mvm_tdls_ch_switch_work()
472 mvm->fw_id_to_mac_id[mvm->tdls_cs.peer.sta_id], in iwl_mvm_tdls_ch_switch_work()
473 lockdep_is_held(&mvm->mutex)); in iwl_mvm_tdls_ch_switch_work()
475 if (!sta || IS_ERR(sta) || WARN_ON(!sta->tdls)) in iwl_mvm_tdls_ch_switch_work()
479 vif = mvmsta->vif; in iwl_mvm_tdls_ch_switch_work()
482 sta->addr, in iwl_mvm_tdls_ch_switch_work()
483 mvm->tdls_cs.peer.initiator, in iwl_mvm_tdls_ch_switch_work()
484 mvm->tdls_cs.peer.op_class, in iwl_mvm_tdls_ch_switch_work()
485 &mvm->tdls_cs.peer.chandef, in iwl_mvm_tdls_ch_switch_work()
487 mvm->tdls_cs.peer.skb, in iwl_mvm_tdls_ch_switch_work()
488 mvm->tdls_cs.peer.ch_sw_tm_ie); in iwl_mvm_tdls_ch_switch_work()
493 delay = TU_TO_MS(vif->bss_conf.dtim_period * vif->bss_conf.beacon_int); in iwl_mvm_tdls_ch_switch_work()
494 schedule_delayed_work(&mvm->tdls_cs.dwork, msecs_to_jiffies(delay)); in iwl_mvm_tdls_ch_switch_work()
506 unsigned int delay; in iwl_mvm_tdls_channel_switch() local
512 sta->addr, chandef->chan->center_freq, chandef->width); in iwl_mvm_tdls_channel_switch()
515 if (mvm->tdls_cs.peer.sta_id != IWL_MVM_INVALID_STA) { in iwl_mvm_tdls_channel_switch()
518 sta->addr); in iwl_mvm_tdls_channel_switch()
519 return -EBUSY; in iwl_mvm_tdls_channel_switch()
524 sta->addr, sta->tdls_initiator, in iwl_mvm_tdls_channel_switch()
534 mvm->tdls_cs.peer.skb = skb_copy(tmpl_skb, GFP_KERNEL); in iwl_mvm_tdls_channel_switch()
535 if (!mvm->tdls_cs.peer.skb) in iwl_mvm_tdls_channel_switch()
536 return -ENOMEM; in iwl_mvm_tdls_channel_switch()
539 mvm->tdls_cs.peer.sta_id = mvmsta->deflink.sta_id; in iwl_mvm_tdls_channel_switch()
540 mvm->tdls_cs.peer.chandef = *chandef; in iwl_mvm_tdls_channel_switch()
541 mvm->tdls_cs.peer.initiator = sta->tdls_initiator; in iwl_mvm_tdls_channel_switch()
542 mvm->tdls_cs.peer.op_class = oper_class; in iwl_mvm_tdls_channel_switch()
543 mvm->tdls_cs.peer.ch_sw_tm_ie = ch_sw_tm_ie; in iwl_mvm_tdls_channel_switch()
546 * Wait for 2 DTIM periods before attempting the next switch. The next in iwl_mvm_tdls_channel_switch()
549 delay = 2 * TU_TO_MS(vif->bss_conf.dtim_period * in iwl_mvm_tdls_channel_switch()
550 vif->bss_conf.beacon_int); in iwl_mvm_tdls_channel_switch()
551 mod_delayed_work(system_wq, &mvm->tdls_cs.dwork, in iwl_mvm_tdls_channel_switch()
552 msecs_to_jiffies(delay)); in iwl_mvm_tdls_channel_switch()
564 mutex_lock(&mvm->mutex); in iwl_mvm_tdls_cancel_channel_switch()
566 IWL_DEBUG_TDLS(mvm, "TDLS cancel channel switch with %pM\n", sta->addr); in iwl_mvm_tdls_cancel_channel_switch()
569 if (mvm->tdls_cs.peer.sta_id == IWL_MVM_INVALID_STA) { in iwl_mvm_tdls_cancel_channel_switch()
570 IWL_DEBUG_TDLS(mvm, "No ch switch peer - %pM\n", sta->addr); in iwl_mvm_tdls_cancel_channel_switch()
575 mvm->fw_id_to_mac_id[mvm->tdls_cs.peer.sta_id], in iwl_mvm_tdls_cancel_channel_switch()
576 lockdep_is_held(&mvm->mutex)); in iwl_mvm_tdls_cancel_channel_switch()
583 * wait a DTIM here to make sure the phy is back on the base channel. in iwl_mvm_tdls_cancel_channel_switch()
586 if (mvm->tdls_cs.cur_sta_id == mvm->tdls_cs.peer.sta_id && in iwl_mvm_tdls_cancel_channel_switch()
587 mvm->tdls_cs.state != IWL_MVM_TDLS_SW_IDLE) in iwl_mvm_tdls_cancel_channel_switch()
590 mvm->tdls_cs.peer.sta_id = IWL_MVM_INVALID_STA; in iwl_mvm_tdls_cancel_channel_switch()
591 dev_kfree_skb(mvm->tdls_cs.peer.skb); in iwl_mvm_tdls_cancel_channel_switch()
592 mvm->tdls_cs.peer.skb = NULL; in iwl_mvm_tdls_cancel_channel_switch()
595 mutex_unlock(&mvm->mutex); in iwl_mvm_tdls_cancel_channel_switch()
599 msleep(TU_TO_MS(vif->bss_conf.dtim_period * in iwl_mvm_tdls_cancel_channel_switch()
600 vif->bss_conf.beacon_int)); in iwl_mvm_tdls_cancel_channel_switch()
603 flush_delayed_work(&mvm->tdls_cs.dwork); in iwl_mvm_tdls_cancel_channel_switch()
605 IWL_DEBUG_TDLS(mvm, "TDLS ending channel switch with %pM\n", sta->addr); in iwl_mvm_tdls_cancel_channel_switch()
615 unsigned int delay; in iwl_mvm_tdls_recv_channel_switch() local
617 params->action_code == WLAN_TDLS_CHANNEL_SWITCH_REQUEST ? in iwl_mvm_tdls_recv_channel_switch()
624 action_str, params->sta->addr, params->status); in iwl_mvm_tdls_recv_channel_switch()
627 * we got a non-zero status from a peer we were switching to - move to in iwl_mvm_tdls_recv_channel_switch()
628 * the idle state and retry again later in iwl_mvm_tdls_recv_channel_switch()
630 if (params->action_code == WLAN_TDLS_CHANNEL_SWITCH_RESPONSE && in iwl_mvm_tdls_recv_channel_switch()
631 params->status != 0 && in iwl_mvm_tdls_recv_channel_switch()
632 mvm->tdls_cs.state == IWL_MVM_TDLS_SW_REQ_SENT && in iwl_mvm_tdls_recv_channel_switch()
633 mvm->tdls_cs.cur_sta_id != IWL_MVM_INVALID_STA) { in iwl_mvm_tdls_recv_channel_switch()
638 mvm->fw_id_to_mac_id[mvm->tdls_cs.cur_sta_id], in iwl_mvm_tdls_recv_channel_switch()
639 lockdep_is_held(&mvm->mutex)); in iwl_mvm_tdls_recv_channel_switch()
640 if (cur_sta == params->sta) { in iwl_mvm_tdls_recv_channel_switch()
647 type = (params->action_code == WLAN_TDLS_CHANNEL_SWITCH_REQUEST) ? in iwl_mvm_tdls_recv_channel_switch()
650 iwl_mvm_tdls_config_channel_switch(mvm, vif, type, params->sta->addr, in iwl_mvm_tdls_recv_channel_switch()
651 params->sta->tdls_initiator, 0, in iwl_mvm_tdls_recv_channel_switch()
652 params->chandef, params->timestamp, in iwl_mvm_tdls_recv_channel_switch()
653 params->switch_time, in iwl_mvm_tdls_recv_channel_switch()
654 params->switch_timeout, in iwl_mvm_tdls_recv_channel_switch()
655 params->tmpl_skb, in iwl_mvm_tdls_recv_channel_switch()
656 params->ch_sw_tm_ie); in iwl_mvm_tdls_recv_channel_switch()
660 delay = vif->bss_conf.dtim_period * vif->bss_conf.beacon_int * in iwl_mvm_tdls_recv_channel_switch()
662 mod_delayed_work(system_wq, &mvm->tdls_cs.dwork, in iwl_mvm_tdls_recv_channel_switch()
663 msecs_to_jiffies(delay)); in iwl_mvm_tdls_recv_channel_switch()