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
8 #include <linux/delay.h>
12 #include "time-event.h"
13 #include "iwl-io.h"
14 #include "iwl-prph.h"
25 lockdep_assert_held(&mvm->mutex);
27 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) {
28 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
29 lockdep_is_held(&mvm->mutex));
30 if (!sta || IS_ERR(sta) || !sta->tdls)
34 ieee80211_tdls_oper_request(mvmsta->vif, sta->addr,
48 lockdep_assert_held(&mvm->mutex);
50 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) {
51 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
52 lockdep_is_held(&mvm->mutex));
53 if (!sta || IS_ERR(sta) || !sta->tdls)
58 if (mvmsta->vif != vif)
83 lockdep_assert_held(&mvm->mutex);
86 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color));
94 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) {
95 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
96 lockdep_is_held(&mvm->mutex));
97 if (IS_ERR_OR_NULL(sta) || !sta->tdls)
105 cpu_to_le32(sta->tdls_initiator ? 1 : 0);
140 if (fw_has_capa(&mvm->fw->ucode_capa,
154 u32 duration = 2 * vif->bss_conf.dtim_period * vif->bss_conf.beacon_int;
158 if (fw_has_capa(&mvm->fw->ucode_capa,
172 return "IDLE";
189 if (mvm->tdls_cs.state == state)
192 IWL_DEBUG_TDLS(mvm, "TDLS channel switch state: %s -> %s\n",
193 iwl_mvm_tdls_cs_state_str(mvm->tdls_cs.state),
195 mvm->tdls_cs.state = state;
197 /* we only send requests to our switching peer - update sent time */
199 mvm->tdls_cs.peer.sent_timestamp = iwl_mvm_get_systime(mvm);
202 mvm->tdls_cs.cur_sta_id = IWL_MVM_INVALID_STA;
208 struct iwl_tdls_channel_switch_notif *notif = (void *)pkt->data;
210 unsigned int delay;
213 u32 sta_id = le32_to_cpu(notif->sta_id);
215 lockdep_assert_held(&mvm->mutex);
218 if (!le32_to_cpu(notif->status)) {
223 if (WARN_ON(sta_id >= mvm->fw->ucode_capa.num_stations))
226 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
227 lockdep_is_held(&mvm->mutex));
229 if (IS_ERR_OR_NULL(sta) || WARN_ON(!sta->tdls))
233 vif = mvmsta->vif;
239 delay = TU_TO_MS(vif->bss_conf.dtim_period * vif->bss_conf.beacon_int);
240 mod_delayed_work(system_wq, &mvm->tdls_cs.dwork,
241 msecs_to_jiffies(delay));
255 if (mvm->tdls_cs.state != IWL_MVM_TDLS_SW_IDLE &&
256 mvm->tdls_cs.cur_sta_id != IWL_MVM_INVALID_STA) {
258 mvm->fw_id_to_mac_id[mvm->tdls_cs.cur_sta_id],
259 lockdep_is_held(&mvm->mutex));
261 same_peer = ether_addr_equal(peer, sta->addr);
264 switch (mvm->tdls_cs.state) {
271 ret = -EINVAL;
276 ret = -EBUSY;
280 * We received a ch-switch request while an outgoing
284 ret = -EBUSY;
286 /* wait for idle before sending another request */
287 ret = -EBUSY;
288 else if (timestamp <= mvm->tdls_cs.peer.sent_timestamp)
289 /* we got a stale response - ignore it */
290 ret = -EINVAL;
297 ret = -EBUSY;
303 ret = -EBUSY;
305 ret = -EBUSY;
307 ret = -EINVAL;
313 * to the base channel by the current off-channel peer
316 ret = -EBUSY;
323 type, mvm->tdls_cs.state, peer, same_peer,
347 u16 len = sizeof(cmd) - iwl_mvm_chan_info_padding(mvm);
350 lockdep_assert_held(&mvm->mutex);
357 if (!skb || WARN_ON(skb->len > IWL_TDLS_CH_SW_FRAME_MAX_SIZE)) {
358 ret = -EINVAL;
363 tail->timing.frame_timestamp = cpu_to_le32(timestamp);
364 tail->timing.switch_time = cpu_to_le32(switch_time);
365 tail->timing.switch_timeout = cpu_to_le32(switch_timeout);
371 ret = -ENOENT;
375 cmd.peer_sta_id = cpu_to_le32(mvmsta->deflink.sta_id);
378 if (mvm->tdls_cs.state == IWL_MVM_TDLS_SW_REQ_SENT &&
379 mvm->tdls_cs.peer.chandef.chan) {
381 chandef = &mvm->tdls_cs.peer.chandef;
382 } else if (mvm->tdls_cs.state == IWL_MVM_TDLS_SW_ACTIVE &&
386 rcu_dereference(vif->bss_conf.chanctx_conf);
393 chandef = &chanctx->def;
400 /* keep quota calculation simple for now - 50% of DTIM for TDLS */
401 tail->timing.max_offchan_duration =
402 cpu_to_le32(TU_TO_US(vif->bss_conf.dtim_period *
403 vif->bss_conf.beacon_int) / 2);
405 /* Switch time is the first element in the switch-timing IE. */
406 tail->frame.switch_time_offset = cpu_to_le32(ch_sw_tm_ie + 2);
409 hdr = (void *)skb->data;
410 if (info->control.hw_key) {
411 if (info->control.hw_key->cipher != WLAN_CIPHER_SUITE_CCMP) {
413 ret = -EINVAL;
416 iwl_mvm_set_tx_cmd_ccmp(info, &tail->frame.tx_cmd);
419 iwl_mvm_set_tx_cmd(mvm, skb, &tail->frame.tx_cmd, info,
420 mvmsta->deflink.sta_id);
422 iwl_mvm_set_tx_cmd_rate(mvm, &tail->frame.tx_cmd, info, sta,
423 hdr->frame_control);
426 memcpy(tail->frame.data, skb->data, skb->len);
437 mvm->tdls_cs.cur_sta_id = mvmsta->deflink.sta_id;
448 /* channel switch failed - we are idle */
461 unsigned int delay;
467 /* called after an active channel switch has finished or timed-out */
471 if (mvm->tdls_cs.peer.sta_id == IWL_MVM_INVALID_STA)
475 mvm->fw_id_to_mac_id[mvm->tdls_cs.peer.sta_id],
476 lockdep_is_held(&mvm->mutex));
478 if (!sta || IS_ERR(sta) || WARN_ON(!sta->tdls))
482 vif = mvmsta->vif;
485 sta->addr,
486 mvm->tdls_cs.peer.initiator,
487 mvm->tdls_cs.peer.op_class,
488 &mvm->tdls_cs.peer.chandef,
490 mvm->tdls_cs.peer.skb,
491 mvm->tdls_cs.peer.ch_sw_tm_ie);
496 delay = TU_TO_MS(vif->bss_conf.dtim_period * vif->bss_conf.beacon_int);
497 schedule_delayed_work(&mvm->tdls_cs.dwork, msecs_to_jiffies(delay));
509 unsigned int delay;
515 sta->addr, chandef->chan->center_freq, chandef->width);
518 if (mvm->tdls_cs.peer.sta_id != IWL_MVM_INVALID_STA) {
521 sta->addr);
522 return -EBUSY;
527 sta->addr, sta->tdls_initiator,
537 mvm->tdls_cs.peer.skb = skb_copy(tmpl_skb, GFP_KERNEL);
538 if (!mvm->tdls_cs.peer.skb)
539 return -ENOMEM;
542 mvm->tdls_cs.peer.sta_id = mvmsta->deflink.sta_id;
543 mvm->tdls_cs.peer.chandef = *chandef;
544 mvm->tdls_cs.peer.initiator = sta->tdls_initiator;
545 mvm->tdls_cs.peer.op_class = oper_class;
546 mvm->tdls_cs.peer.ch_sw_tm_ie = ch_sw_tm_ie;
549 * Wait for 2 DTIM periods before attempting the next switch. The next
552 delay = 2 * TU_TO_MS(vif->bss_conf.dtim_period *
553 vif->bss_conf.beacon_int);
554 mod_delayed_work(system_wq, &mvm->tdls_cs.dwork,
555 msecs_to_jiffies(delay));
567 mutex_lock(&mvm->mutex);
569 IWL_DEBUG_TDLS(mvm, "TDLS cancel channel switch with %pM\n", sta->addr);
572 if (mvm->tdls_cs.peer.sta_id == IWL_MVM_INVALID_STA) {
573 IWL_DEBUG_TDLS(mvm, "No ch switch peer - %pM\n", sta->addr);
578 mvm->fw_id_to_mac_id[mvm->tdls_cs.peer.sta_id],
579 lockdep_is_held(&mvm->mutex));
586 * wait a DTIM here to make sure the phy is back on the base channel.
589 if (mvm->tdls_cs.cur_sta_id == mvm->tdls_cs.peer.sta_id &&
590 mvm->tdls_cs.state != IWL_MVM_TDLS_SW_IDLE)
593 mvm->tdls_cs.peer.sta_id = IWL_MVM_INVALID_STA;
594 dev_kfree_skb(mvm->tdls_cs.peer.skb);
595 mvm->tdls_cs.peer.skb = NULL;
598 mutex_unlock(&mvm->mutex);
603 msleep(TU_TO_MS(vif->bss_conf.dtim_period *
605 linux_msleep(TU_TO_MS(vif->bss_conf.dtim_period *
607 vif->bss_conf.beacon_int));
610 flush_delayed_work(&mvm->tdls_cs.dwork);
612 IWL_DEBUG_TDLS(mvm, "TDLS ending channel switch with %pM\n", sta->addr);
622 unsigned int delay;
624 params->action_code == WLAN_TDLS_CHANNEL_SWITCH_REQUEST ?
631 action_str, params->sta->addr, params->status);
634 * we got a non-zero status from a peer we were switching to - move to
635 * the idle state and retry again later
637 if (params->action_code == WLAN_TDLS_CHANNEL_SWITCH_RESPONSE &&
638 params->status != 0 &&
639 mvm->tdls_cs.state == IWL_MVM_TDLS_SW_REQ_SENT &&
640 mvm->tdls_cs.cur_sta_id != IWL_MVM_INVALID_STA) {
645 mvm->fw_id_to_mac_id[mvm->tdls_cs.cur_sta_id],
646 lockdep_is_held(&mvm->mutex));
647 if (cur_sta == params->sta) {
654 type = (params->action_code == WLAN_TDLS_CHANNEL_SWITCH_REQUEST) ?
657 iwl_mvm_tdls_config_channel_switch(mvm, vif, type, params->sta->addr,
658 params->sta->tdls_initiator, 0,
659 params->chandef, params->timestamp,
660 params->switch_time,
661 params->switch_timeout,
662 params->tmpl_skb,
663 params->ch_sw_tm_ie);
667 delay = vif->bss_conf.dtim_period * vif->bss_conf.beacon_int *
669 mod_delayed_work(system_wq, &mvm->tdls_cs.dwork,
670 msecs_to_jiffies(delay));