Lines Matching +full:de +full:- +full:asserts

1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2012-2015, 2018-2025 Intel Corporation
4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
5 * Copyright (C) 2016-2017 Intel Deutschland GmbH
24 fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) in iwl_mvm_add_sta_cmd_size()
36 WARN_ON_ONCE(test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)); in iwl_mvm_find_free_sta_id()
38 lockdep_assert_held(&mvm->mutex); in iwl_mvm_find_free_sta_id()
44 /* Don't take rcu_read_lock() since we are protected by mvm->mutex */ in iwl_mvm_find_free_sta_id()
45 for (sta_id = 0; sta_id < mvm->fw->ucode_capa.num_stations; sta_id++) { in iwl_mvm_find_free_sta_id()
49 if (!rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id], in iwl_mvm_find_free_sta_id()
50 lockdep_is_held(&mvm->mutex))) in iwl_mvm_find_free_sta_id()
67 * of Draft P802.11be D.30 Table 10-12a--Fields used for calculating in iwl_mvm_get_sta_ampdu_dens()
68 * the maximum A-MPDU size of various PPDU types in different bands, in iwl_mvm_get_sta_ampdu_dens()
72 if (link_sta->ht_cap.ht_supported) { in iwl_mvm_get_sta_ampdu_dens()
73 agg_size = link_sta->ht_cap.ampdu_factor; in iwl_mvm_get_sta_ampdu_dens()
74 mpdu_dens = link_sta->ht_cap.ampdu_density; in iwl_mvm_get_sta_ampdu_dens()
77 if (link_conf->chanreq.oper.chan->band == NL80211_BAND_6GHZ) { in iwl_mvm_get_sta_ampdu_dens()
79 mpdu_dens = le16_get_bits(link_sta->he_6ghz_capa.capa, in iwl_mvm_get_sta_ampdu_dens()
81 agg_size = le16_get_bits(link_sta->he_6ghz_capa.capa, in iwl_mvm_get_sta_ampdu_dens()
83 } else if (link_sta->vht_cap.vht_supported) { in iwl_mvm_get_sta_ampdu_dens()
85 agg_size = u32_get_bits(link_sta->vht_cap.cap, in iwl_mvm_get_sta_ampdu_dens()
89 /* D6.0 10.12.2 A-MPDU length limit rules in iwl_mvm_get_sta_ampdu_dens()
90 * A STA indicates the maximum length of the A-MPDU preEOF padding in iwl_mvm_get_sta_ampdu_dens()
91 * that it can receive in an HE PPDU in the Maximum A-MPDU Length in iwl_mvm_get_sta_ampdu_dens()
97 if (link_sta->he_cap.has_he) in iwl_mvm_get_sta_ampdu_dens()
99 u8_get_bits(link_sta->he_cap.he_cap_elem.mac_cap_info[3], in iwl_mvm_get_sta_ampdu_dens()
102 if (link_sta->eht_cap.has_eht) in iwl_mvm_get_sta_ampdu_dens()
103 agg_size += u8_get_bits(link_sta->eht_cap.eht_cap_elem.mac_cap_info[1], in iwl_mvm_get_sta_ampdu_dens()
106 /* Limit to max A-MPDU supported by FW */ in iwl_mvm_get_sta_ampdu_dens()
118 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK) in iwl_mvm_get_sta_uapsd_acs()
120 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE) in iwl_mvm_get_sta_uapsd_acs()
122 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI) in iwl_mvm_get_sta_uapsd_acs()
124 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) in iwl_mvm_get_sta_uapsd_acs()
136 .sta_id = mvm_sta->deflink.sta_id, in iwl_mvm_sta_send_to_fw()
137 .mac_id_n_color = cpu_to_le32(mvm_sta->mac_id_n_color), in iwl_mvm_sta_send_to_fw()
142 .tid_disable_tx = cpu_to_le16(mvm_sta->tid_disable_agg), in iwl_mvm_sta_send_to_fw()
148 if (fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) in iwl_mvm_sta_send_to_fw()
149 add_sta_cmd.station_type = mvm_sta->sta_type; in iwl_mvm_sta_send_to_fw()
152 memcpy(&add_sta_cmd.addr, sta->addr, ETH_ALEN); in iwl_mvm_sta_send_to_fw()
156 cpu_to_le32(mvm_sta->tfd_queue_msk); in iwl_mvm_sta_send_to_fw()
165 switch (sta->deflink.bandwidth) { in iwl_mvm_sta_send_to_fw()
177 if (sta->deflink.ht_cap.ht_supported) in iwl_mvm_sta_send_to_fw()
183 switch (sta->deflink.rx_nss) { in iwl_mvm_sta_send_to_fw()
195 switch (sta->deflink.smps_mode) { in iwl_mvm_sta_send_to_fw()
213 if (sta->deflink.ht_cap.ht_supported || in iwl_mvm_sta_send_to_fw()
214 mvm_sta->vif->bss_conf.chanreq.oper.chan->band == NL80211_BAND_6GHZ) in iwl_mvm_sta_send_to_fw()
219 mpdu_dens = iwl_mvm_get_sta_ampdu_dens(&sta->deflink, in iwl_mvm_sta_send_to_fw()
220 &mvm_sta->vif->bss_conf, in iwl_mvm_sta_send_to_fw()
227 if (mvm_sta->sta_state >= IEEE80211_STA_ASSOC) in iwl_mvm_sta_send_to_fw()
228 add_sta_cmd.assoc_id = cpu_to_le16(sta->aid); in iwl_mvm_sta_send_to_fw()
230 if (sta->wme) { in iwl_mvm_sta_send_to_fw()
233 add_sta_cmd.sp_length = sta->max_sp ? sta->max_sp * 2 : 128; in iwl_mvm_sta_send_to_fw()
248 ret = -EIO; in iwl_mvm_sta_send_to_fw()
260 struct iwl_mvm_baid_data __rcu **rcu_ptr = data->rcu_ptr; in iwl_mvm_rx_agg_session_expired()
274 if (!ba_data->timeout) in iwl_mvm_rx_agg_session_expired()
277 timeout = ba_data->last_rx + TU_TO_JIFFIES(ba_data->timeout * 2); in iwl_mvm_rx_agg_session_expired()
279 mod_timer(&ba_data->session_timer, timeout); in iwl_mvm_rx_agg_session_expired()
284 sta_id = ffs(ba_data->sta_mask) - 1; /* don't care which one */ in iwl_mvm_rx_agg_session_expired()
285 sta = rcu_dereference(ba_data->mvm->fw_id_to_mac_id[sta_id]); in iwl_mvm_rx_agg_session_expired()
289 * The firmware asserts which triggers a reconfig flow, but in iwl_mvm_rx_agg_session_expired()
292 * A-MDPU and hence the timer continues to run. Then, the in iwl_mvm_rx_agg_session_expired()
299 ieee80211_rx_ba_timer_expired(mvm_sta->vif, in iwl_mvm_rx_agg_session_expired()
300 sta->addr, ba_data->tid); in iwl_mvm_rx_agg_session_expired()
317 return -EINVAL; in iwl_mvm_invalidate_sta_queue()
319 sta_id = mvm->queue_info[queue].ra_sta_id; in iwl_mvm_invalidate_sta_queue()
323 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); in iwl_mvm_invalidate_sta_queue()
327 return -EINVAL; in iwl_mvm_invalidate_sta_queue()
332 mvmsta->tid_disable_agg |= disable_agg_tids; in iwl_mvm_invalidate_sta_queue()
334 cmd.mac_id_n_color = cpu_to_le32(mvmsta->mac_id_n_color); in iwl_mvm_invalidate_sta_queue()
335 cmd.sta_id = mvmsta->deflink.sta_id; in iwl_mvm_invalidate_sta_queue()
342 cmd.tfd_queue_msk = cpu_to_le32(mvmsta->tfd_queue_msk); in iwl_mvm_invalidate_sta_queue()
343 cmd.tid_disable_tx = cpu_to_le16(mvmsta->tid_disable_agg); in iwl_mvm_invalidate_sta_queue()
364 lockdep_assert_held(&mvm->mutex); in iwl_mvm_disable_txq()
367 if (mvm->sta_remove_requires_queue_remove) { in iwl_mvm_disable_txq()
387 iwl_trans_txq_free(mvm->trans, queue); in iwl_mvm_disable_txq()
393 if (WARN_ON(mvm->queue_info[queue].tid_bitmap == 0)) in iwl_mvm_disable_txq()
396 mvm->queue_info[queue].tid_bitmap &= ~BIT(tid); in iwl_mvm_disable_txq()
398 cmd.action = mvm->queue_info[queue].tid_bitmap ? in iwl_mvm_disable_txq()
401 mvm->queue_info[queue].status = IWL_MVM_QUEUE_FREE; in iwl_mvm_disable_txq()
406 mvm->queue_info[queue].tid_bitmap); in iwl_mvm_disable_txq()
408 /* If the queue is still enabled - nothing left to do in this func */ in iwl_mvm_disable_txq()
412 cmd.sta_id = mvm->queue_info[queue].ra_sta_id; in iwl_mvm_disable_txq()
413 cmd.tid = mvm->queue_info[queue].txq_tid; in iwl_mvm_disable_txq()
416 WARN(mvm->queue_info[queue].tid_bitmap, in iwl_mvm_disable_txq()
417 "TXQ #%d info out-of-sync - tids=0x%x\n", in iwl_mvm_disable_txq()
418 queue, mvm->queue_info[queue].tid_bitmap); in iwl_mvm_disable_txq()
420 /* If we are here - the queue is freed and we can zero out these vals */ in iwl_mvm_disable_txq()
421 mvm->queue_info[queue].tid_bitmap = 0; in iwl_mvm_disable_txq()
427 spin_lock_bh(&mvm->add_stream_lock); in iwl_mvm_disable_txq()
428 list_del_init(&mvmtxq->list); in iwl_mvm_disable_txq()
429 clear_bit(IWL_MVM_TXQ_STATE_READY, &mvmtxq->state); in iwl_mvm_disable_txq()
430 mvmtxq->txq_id = IWL_MVM_INVALID_QUEUE; in iwl_mvm_disable_txq()
431 spin_unlock_bh(&mvm->add_stream_lock); in iwl_mvm_disable_txq()
434 /* Regardless if this is a reserved TXQ for a STA - mark it as false */ in iwl_mvm_disable_txq()
435 mvm->queue_info[queue].reserved = false; in iwl_mvm_disable_txq()
437 iwl_trans_txq_disable(mvm->trans, queue, false); in iwl_mvm_disable_txq()
456 lockdep_assert_held(&mvm->mutex); in iwl_mvm_get_queue_agg_tids()
459 return -EINVAL; in iwl_mvm_get_queue_agg_tids()
461 sta_id = mvm->queue_info[queue].ra_sta_id; in iwl_mvm_get_queue_agg_tids()
462 tid_bitmap = mvm->queue_info[queue].tid_bitmap; in iwl_mvm_get_queue_agg_tids()
464 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id], in iwl_mvm_get_queue_agg_tids()
465 lockdep_is_held(&mvm->mutex)); in iwl_mvm_get_queue_agg_tids()
468 return -EINVAL; in iwl_mvm_get_queue_agg_tids()
472 spin_lock_bh(&mvmsta->lock); in iwl_mvm_get_queue_agg_tids()
474 if (mvmsta->tid_data[tid].state == IWL_AGG_ON) in iwl_mvm_get_queue_agg_tids()
477 spin_unlock_bh(&mvmsta->lock); in iwl_mvm_get_queue_agg_tids()
496 lockdep_assert_held(&mvm->mutex); in iwl_mvm_remove_sta_queue_marking()
499 return -EINVAL; in iwl_mvm_remove_sta_queue_marking()
501 sta_id = mvm->queue_info[queue].ra_sta_id; in iwl_mvm_remove_sta_queue_marking()
502 tid_bitmap = mvm->queue_info[queue].tid_bitmap; in iwl_mvm_remove_sta_queue_marking()
506 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); in iwl_mvm_remove_sta_queue_marking()
515 spin_lock_bh(&mvmsta->lock); in iwl_mvm_remove_sta_queue_marking()
521 if (mvmsta->tid_data[tid].state == IWL_AGG_ON) in iwl_mvm_remove_sta_queue_marking()
523 mvmsta->tid_data[tid].txq_id = IWL_MVM_INVALID_QUEUE; in iwl_mvm_remove_sta_queue_marking()
525 spin_lock_bh(&mvm->add_stream_lock); in iwl_mvm_remove_sta_queue_marking()
526 list_del_init(&mvmtxq->list); in iwl_mvm_remove_sta_queue_marking()
527 clear_bit(IWL_MVM_TXQ_STATE_READY, &mvmtxq->state); in iwl_mvm_remove_sta_queue_marking()
528 mvmtxq->txq_id = IWL_MVM_INVALID_QUEUE; in iwl_mvm_remove_sta_queue_marking()
529 spin_unlock_bh(&mvm->add_stream_lock); in iwl_mvm_remove_sta_queue_marking()
532 mvmsta->tfd_queue_msk &= ~BIT(queue); /* Don't use this queue anymore */ in iwl_mvm_remove_sta_queue_marking()
533 spin_unlock_bh(&mvmsta->lock); in iwl_mvm_remove_sta_queue_marking()
561 lockdep_assert_held(&mvm->mutex); in iwl_mvm_free_inactive_queue()
564 return -EINVAL; in iwl_mvm_free_inactive_queue()
566 sta_id = mvm->queue_info[queue].ra_sta_id; in iwl_mvm_free_inactive_queue()
567 tid = mvm->queue_info[queue].txq_tid; in iwl_mvm_free_inactive_queue()
573 return -EINVAL; in iwl_mvm_free_inactive_queue()
608 lockdep_assert_held(&mvm->mutex); in iwl_mvm_get_shared_queue()
611 return -EINVAL; in iwl_mvm_get_shared_queue()
622 ac_to_queue[mvm->queue_info[i].mac80211_ac] = i; in iwl_mvm_get_shared_queue()
640 /* Priority 3a: If new AC is VO and VI exists - use VI */ in iwl_mvm_get_shared_queue()
647 /* Priority 4a: No BE nor BK - use VI if exists */ in iwl_mvm_get_shared_queue()
650 /* Priority 4b: No BE, BK nor VI - use VO if exists */ in iwl_mvm_get_shared_queue()
659 return -ENOSPC; in iwl_mvm_get_shared_queue()
665 /* Re-configure the SCD for a queue that has already been configured */
683 return -EINVAL; in iwl_mvm_reconfig_scd()
685 if (WARN(mvm->queue_info[queue].tid_bitmap == 0, in iwl_mvm_reconfig_scd()
687 return -ENXIO; in iwl_mvm_reconfig_scd()
692 WARN_ONCE(ret, "Failed to re-configure queue %d on FIFO %d, ret=%d\n", in iwl_mvm_reconfig_scd()
701 * in such a case, otherwise - if no redirection required - it does nothing,
716 return -EINVAL; in iwl_mvm_redirect_queue()
719 * If the AC is lower than current one - FIFO needs to be redirected to in iwl_mvm_redirect_queue()
726 if (ac <= mvm->queue_info[queue].mac80211_ac && !force) { in iwl_mvm_redirect_queue()
733 cmd.sta_id = mvm->queue_info[queue].ra_sta_id; in iwl_mvm_redirect_queue()
734 cmd.tx_fifo = iwl_mvm_ac_to_tx_fifo[mvm->queue_info[queue].mac80211_ac]; in iwl_mvm_redirect_queue()
735 cmd.tid = mvm->queue_info[queue].txq_tid; in iwl_mvm_redirect_queue()
736 shared_queue = hweight16(mvm->queue_info[queue].tid_bitmap) > 1; in iwl_mvm_redirect_queue()
742 set_bit(IWL_MVM_TXQ_STATE_STOP_REDIRECT, &txq->state); in iwl_mvm_redirect_queue()
744 ret = iwl_trans_wait_tx_queues_empty(mvm->trans, BIT(queue)); in iwl_mvm_redirect_queue()
748 ret = -EIO; in iwl_mvm_redirect_queue()
752 /* Before redirecting the queue we need to de-activate it */ in iwl_mvm_redirect_queue()
753 iwl_trans_txq_disable(mvm->trans, queue, false); in iwl_mvm_redirect_queue()
760 iwl_trans_txq_enable_cfg(mvm->trans, queue, ssn, NULL, wdg_timeout); in iwl_mvm_redirect_queue()
763 mvm->queue_info[queue].txq_tid = tid; in iwl_mvm_redirect_queue()
765 /* TODO: Work-around SCD bug when moving back by multiples of 0x40 */ in iwl_mvm_redirect_queue()
772 mvm->queue_info[queue].mac80211_ac = ac; in iwl_mvm_redirect_queue()
781 iwl_trans_txq_set_shared_mode(mvm->trans, queue, true); in iwl_mvm_redirect_queue()
785 clear_bit(IWL_MVM_TXQ_STATE_STOP_REDIRECT, &txq->state); in iwl_mvm_redirect_queue()
795 lockdep_assert_held(&mvm->mutex); in iwl_mvm_find_free_queue()
797 if (WARN(maxq >= mvm->trans->mac_cfg->base->num_of_queues, in iwl_mvm_find_free_queue()
799 mvm->trans->mac_cfg->base->num_of_queues)) in iwl_mvm_find_free_queue()
800 maxq = mvm->trans->mac_cfg->base->num_of_queues - 1; in iwl_mvm_find_free_queue()
804 return -ENOSPC; in iwl_mvm_find_free_queue()
808 if (mvm->queue_info[i].tid_bitmap == 0 && in iwl_mvm_find_free_queue()
809 mvm->queue_info[i].status == IWL_MVM_QUEUE_FREE) in iwl_mvm_find_free_queue()
812 return -ENOSPC; in iwl_mvm_find_free_queue()
826 for (link_id = 0; link_id < ARRAY_SIZE(sta->link); link_id++) { in iwl_mvm_get_queue_size()
828 rcu_dereference(sta->link[link_id]); in iwl_mvm_get_queue_size()
834 if (link->eht_cap.has_eht && in iwl_mvm_get_queue_size()
839 if (link->he_cap.has_he && in iwl_mvm_get_queue_size()
858 mvm->trans->mac_cfg->base->min_txq_size); in iwl_mvm_tvqm_enable_txq()
869 for_each_sta_active_link(mvmsta->vif, sta, link_sta, link_id) { in iwl_mvm_tvqm_enable_txq()
871 rcu_dereference_protected(mvmsta->link[link_id], in iwl_mvm_tvqm_enable_txq()
872 lockdep_is_held(&mvm->mutex)); in iwl_mvm_tvqm_enable_txq()
877 sta_mask |= BIT(link->sta_id); in iwl_mvm_tvqm_enable_txq()
885 return -EINVAL; in iwl_mvm_tvqm_enable_txq()
887 queue = iwl_trans_txq_alloc(mvm->trans, 0, sta_mask, in iwl_mvm_tvqm_enable_txq()
906 iwl_mvm_get_wd_timeout(mvm, mvmsta->vif); in iwl_mvm_sta_alloc_queue_tvqm()
907 int queue = -1; in iwl_mvm_sta_alloc_queue_tvqm()
909 lockdep_assert_held(&mvm->mutex); in iwl_mvm_sta_alloc_queue_tvqm()
913 mvmsta->deflink.sta_id, tid); in iwl_mvm_sta_alloc_queue_tvqm()
914 queue = iwl_mvm_tvqm_enable_txq(mvm, sta, mvmsta->deflink.sta_id, in iwl_mvm_sta_alloc_queue_tvqm()
919 mvmtxq->txq_id = queue; in iwl_mvm_sta_alloc_queue_tvqm()
920 mvm->tvqm_info[queue].txq_tid = tid; in iwl_mvm_sta_alloc_queue_tvqm()
921 mvm->tvqm_info[queue].sta_id = mvmsta->deflink.sta_id; in iwl_mvm_sta_alloc_queue_tvqm()
925 spin_lock_bh(&mvmsta->lock); in iwl_mvm_sta_alloc_queue_tvqm()
926 mvmsta->tid_data[tid].txq_id = queue; in iwl_mvm_sta_alloc_queue_tvqm()
927 spin_unlock_bh(&mvmsta->lock); in iwl_mvm_sta_alloc_queue_tvqm()
939 if (mvm->queue_info[queue].tid_bitmap & BIT(tid)) { in iwl_mvm_update_txq_mapping()
946 if (mvm->queue_info[queue].tid_bitmap) in iwl_mvm_update_txq_mapping()
949 mvm->queue_info[queue].tid_bitmap |= BIT(tid); in iwl_mvm_update_txq_mapping()
950 mvm->queue_info[queue].ra_sta_id = sta_id; in iwl_mvm_update_txq_mapping()
954 mvm->queue_info[queue].mac80211_ac = in iwl_mvm_update_txq_mapping()
957 mvm->queue_info[queue].mac80211_ac = IEEE80211_AC_VO; in iwl_mvm_update_txq_mapping()
959 mvm->queue_info[queue].txq_tid = tid; in iwl_mvm_update_txq_mapping()
966 mvmtxq->txq_id = queue; in iwl_mvm_update_txq_mapping()
971 queue, mvm->queue_info[queue].tid_bitmap); in iwl_mvm_update_txq_mapping()
984 .window = cfg->frame_limit, in iwl_mvm_enable_txq()
985 .sta_id = cfg->sta_id, in iwl_mvm_enable_txq()
987 .tx_fifo = cfg->fifo, in iwl_mvm_enable_txq()
988 .aggregate = cfg->aggregate, in iwl_mvm_enable_txq()
989 .tid = cfg->tid, in iwl_mvm_enable_txq()
997 if (!iwl_mvm_update_txq_mapping(mvm, sta, queue, cfg->sta_id, cfg->tid)) in iwl_mvm_enable_txq()
1000 inc_ssn = iwl_trans_txq_enable_cfg(mvm->trans, queue, ssn, in iwl_mvm_enable_txq()
1006 "Failed to configure queue %d on FIFO %d\n", queue, cfg->fifo); in iwl_mvm_enable_txq()
1021 lockdep_assert_held(&mvm->mutex); in iwl_mvm_change_queue_tid()
1026 tid_bitmap = mvm->queue_info[queue].tid_bitmap; in iwl_mvm_change_queue_tid()
1043 mvm->queue_info[queue].txq_tid = tid; in iwl_mvm_change_queue_tid()
1053 int tid = -1; in iwl_mvm_unshare_queue()
1063 lockdep_assert_held(&mvm->mutex); in iwl_mvm_unshare_queue()
1065 sta_id = mvm->queue_info[queue].ra_sta_id; in iwl_mvm_unshare_queue()
1066 tid_bitmap = mvm->queue_info[queue].tid_bitmap; in iwl_mvm_unshare_queue()
1079 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id], in iwl_mvm_unshare_queue()
1080 lockdep_is_held(&mvm->mutex)); in iwl_mvm_unshare_queue()
1086 wdg_timeout = iwl_mvm_get_wd_timeout(mvm, mvmsta->vif); in iwl_mvm_unshare_queue()
1088 ssn = IEEE80211_SEQ_TO_SN(mvmsta->tid_data[tid].seq_number); in iwl_mvm_unshare_queue()
1099 /* If aggs should be turned back on - do it */ in iwl_mvm_unshare_queue()
1100 if (mvmsta->tid_data[tid].state == IWL_AGG_ON) { in iwl_mvm_unshare_queue()
1103 mvmsta->tid_disable_agg &= ~BIT(tid); in iwl_mvm_unshare_queue()
1105 cmd.mac_id_n_color = cpu_to_le32(mvmsta->mac_id_n_color); in iwl_mvm_unshare_queue()
1106 cmd.sta_id = mvmsta->deflink.sta_id; in iwl_mvm_unshare_queue()
1109 cmd.tfd_queue_msk = cpu_to_le32(mvmsta->tfd_queue_msk); in iwl_mvm_unshare_queue()
1110 cmd.tid_disable_tx = cpu_to_le16(mvmsta->tid_disable_agg); in iwl_mvm_unshare_queue()
1120 iwl_trans_txq_set_shared_mode(mvm->trans, queue, false); in iwl_mvm_unshare_queue()
1124 mvm->queue_info[queue].status = IWL_MVM_QUEUE_READY; in iwl_mvm_unshare_queue()
1129 * If all queue TIDs are inactive - mark the queue as inactive
1130 * If only some the queue TIDs are inactive - unmap them from the queue
1142 lockdep_assert_held(&mvmsta->lock); in iwl_mvm_remove_inactive_tids()
1143 lockdep_assert_held(&mvm->mutex); in iwl_mvm_remove_inactive_tids()
1148 /* Go over all non-active TIDs, incl. IWL_MAX_TID_COUNT (for mgmt) */ in iwl_mvm_remove_inactive_tids()
1150 /* If some TFDs are still queued - don't mark TID as inactive */ in iwl_mvm_remove_inactive_tids()
1151 if (iwl_mvm_tid_queued(mvm, &mvmsta->tid_data[tid])) in iwl_mvm_remove_inactive_tids()
1155 if (mvmsta->tid_data[tid].state != IWL_AGG_OFF) in iwl_mvm_remove_inactive_tids()
1159 /* If all TIDs in the queue are inactive - return it can be reused */ in iwl_mvm_remove_inactive_tids()
1160 if (tid_bitmap == mvm->queue_info[queue].tid_bitmap) { in iwl_mvm_remove_inactive_tids()
1166 * If we are here, this is a shared queue and not all TIDs timed-out. in iwl_mvm_remove_inactive_tids()
1172 mvmsta->tid_data[tid].txq_id = IWL_MVM_INVALID_QUEUE; in iwl_mvm_remove_inactive_tids()
1173 mvm->queue_info[queue].tid_bitmap &= ~BIT(tid); in iwl_mvm_remove_inactive_tids()
1175 q_tid_bitmap = mvm->queue_info[queue].tid_bitmap; in iwl_mvm_remove_inactive_tids()
1182 * This is mainly because if TID x continues - a new queue can't in iwl_mvm_remove_inactive_tids()
1188 if (!(q_tid_bitmap & BIT(mvm->queue_info[queue].txq_tid))) in iwl_mvm_remove_inactive_tids()
1198 mvm->queue_info[queue].tid_bitmap); in iwl_mvm_remove_inactive_tids()
1204 tid_bitmap = mvm->queue_info[queue].tid_bitmap; in iwl_mvm_remove_inactive_tids()
1206 /* If the queue is marked as shared - "unshare" it */ in iwl_mvm_remove_inactive_tids()
1207 if (hweight16(mvm->queue_info[queue].tid_bitmap) == 1 && in iwl_mvm_remove_inactive_tids()
1208 mvm->queue_info[queue].status == IWL_MVM_QUEUE_SHARED) { in iwl_mvm_remove_inactive_tids()
1218 * Check for inactivity - this includes checking if any queue
1221 * This function is also invoked as a sort of clean-up task,
1224 * Returns the queue number, or -ENOSPC.
1231 int i, ret, free_queue = -ENOSPC; in iwl_mvm_inactivity_check()
1234 lockdep_assert_held(&mvm->mutex); in iwl_mvm_inactivity_check()
1237 return -ENOSPC; in iwl_mvm_inactivity_check()
1252 queue_tid_bitmap = mvm->queue_info[i].tid_bitmap; in iwl_mvm_inactivity_check()
1256 /* If TXQ isn't in active use anyway - nothing to do here... */ in iwl_mvm_inactivity_check()
1257 if (mvm->queue_info[i].status != IWL_MVM_QUEUE_READY && in iwl_mvm_inactivity_check()
1258 mvm->queue_info[i].status != IWL_MVM_QUEUE_SHARED) in iwl_mvm_inactivity_check()
1264 if (time_after(mvm->queue_info[i].last_frame_time[tid] + in iwl_mvm_inactivity_check()
1271 /* If all TIDs are active - finish check on this queue */ in iwl_mvm_inactivity_check()
1276 * If we are here - the queue hadn't been served recently and is in iwl_mvm_inactivity_check()
1280 sta_id = mvm->queue_info[i].ra_sta_id; in iwl_mvm_inactivity_check()
1281 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); in iwl_mvm_inactivity_check()
1293 spin_lock_bh(&mvmsta->lock); in iwl_mvm_inactivity_check()
1302 /* only unlock sta lock - we still need the queue info lock */ in iwl_mvm_inactivity_check()
1303 spin_unlock_bh(&mvmsta->lock); in iwl_mvm_inactivity_check()
1331 .sta_id = mvmsta->deflink.sta_id, in iwl_mvm_sta_alloc_queue()
1336 iwl_mvm_get_wd_timeout(mvm, mvmsta->vif); in iwl_mvm_sta_alloc_queue()
1337 int queue = -1; in iwl_mvm_sta_alloc_queue()
1346 lockdep_assert_held(&mvm->mutex); in iwl_mvm_sta_alloc_queue()
1351 spin_lock_bh(&mvmsta->lock); in iwl_mvm_sta_alloc_queue()
1352 tfd_queue_mask = mvmsta->tfd_queue_msk; in iwl_mvm_sta_alloc_queue()
1353 ssn = IEEE80211_SEQ_TO_SN(mvmsta->tid_data[tid].seq_number); in iwl_mvm_sta_alloc_queue()
1354 spin_unlock_bh(&mvmsta->lock); in iwl_mvm_sta_alloc_queue()
1357 queue = iwl_mvm_find_free_queue(mvm, mvmsta->deflink.sta_id, in iwl_mvm_sta_alloc_queue()
1367 if ((queue < 0 && mvmsta->reserved_queue != IEEE80211_INVAL_HW_QUEUE) && in iwl_mvm_sta_alloc_queue()
1368 (mvm->queue_info[mvmsta->reserved_queue].status == in iwl_mvm_sta_alloc_queue()
1370 queue = mvmsta->reserved_queue; in iwl_mvm_sta_alloc_queue()
1371 mvm->queue_info[queue].reserved = true; in iwl_mvm_sta_alloc_queue()
1376 queue = iwl_mvm_find_free_queue(mvm, mvmsta->deflink.sta_id, in iwl_mvm_sta_alloc_queue()
1380 /* try harder - perhaps kill an inactive queue */ in iwl_mvm_sta_alloc_queue()
1381 queue = iwl_mvm_inactivity_check(mvm, mvmsta->deflink.sta_id); in iwl_mvm_sta_alloc_queue()
1384 /* No free queue - we'll have to share */ in iwl_mvm_sta_alloc_queue()
1389 mvm->queue_info[queue].status = IWL_MVM_QUEUE_SHARED; in iwl_mvm_sta_alloc_queue()
1396 * This will allow avoiding re-acquiring the lock at the end of the in iwl_mvm_sta_alloc_queue()
1400 mvm->queue_info[queue].status = IWL_MVM_QUEUE_READY; in iwl_mvm_sta_alloc_queue()
1402 /* This shouldn't happen - out of queues */ in iwl_mvm_sta_alloc_queue()
1411 * but for configuring the SCD to send A-MPDUs we need to mark the queue in iwl_mvm_sta_alloc_queue()
1421 mvmsta->deflink.sta_id, tid); in iwl_mvm_sta_alloc_queue()
1444 iwl_trans_txq_set_shared_mode(mvm->trans, queue, true); in iwl_mvm_sta_alloc_queue()
1446 spin_lock_bh(&mvmsta->lock); in iwl_mvm_sta_alloc_queue()
1453 mvmsta->tid_data[tid].seq_number += 0x10; in iwl_mvm_sta_alloc_queue()
1456 mvmsta->tid_data[tid].txq_id = queue; in iwl_mvm_sta_alloc_queue()
1457 mvmsta->tfd_queue_msk |= BIT(queue); in iwl_mvm_sta_alloc_queue()
1458 queue_state = mvmsta->tid_data[tid].state; in iwl_mvm_sta_alloc_queue()
1460 if (mvmsta->reserved_queue == queue) in iwl_mvm_sta_alloc_queue()
1461 mvmsta->reserved_queue = IEEE80211_INVAL_HW_QUEUE; in iwl_mvm_sta_alloc_queue()
1462 spin_unlock_bh(&mvmsta->lock); in iwl_mvm_sta_alloc_queue()
1469 /* If we need to re-enable aggregations... */ in iwl_mvm_sta_alloc_queue()
1488 iwl_mvm_disable_txq(mvm, sta, mvmsta->deflink.sta_id, &queue_tmp, tid); in iwl_mvm_sta_alloc_queue()
1497 int ret = -EINVAL; in iwl_mvm_sta_ensure_queue()
1499 lockdep_assert_held(&mvm->mutex); in iwl_mvm_sta_ensure_queue()
1501 if (likely(test_bit(IWL_MVM_TXQ_STATE_READY, &mvmtxq->state)) || in iwl_mvm_sta_ensure_queue()
1502 !txq->sta) { in iwl_mvm_sta_ensure_queue()
1506 if (!iwl_mvm_sta_alloc_queue(mvm, txq->sta, txq->ac, txq->tid)) { in iwl_mvm_sta_ensure_queue()
1507 set_bit(IWL_MVM_TXQ_STATE_READY, &mvmtxq->state); in iwl_mvm_sta_ensure_queue()
1512 spin_lock(&mvm->add_stream_lock); in iwl_mvm_sta_ensure_queue()
1513 if (!list_empty(&mvmtxq->list)) in iwl_mvm_sta_ensure_queue()
1514 list_del_init(&mvmtxq->list); in iwl_mvm_sta_ensure_queue()
1515 spin_unlock(&mvm->add_stream_lock); in iwl_mvm_sta_ensure_queue()
1529 if (test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status) || in iwl_mvm_add_new_dqa_stream_wk()
1530 test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) in iwl_mvm_add_new_dqa_stream_wk()
1535 while (!list_empty(&mvm->add_stream_txqs)) { in iwl_mvm_add_new_dqa_stream_wk()
1540 mvmtxq = list_first_entry(&mvm->add_stream_txqs, in iwl_mvm_add_new_dqa_stream_wk()
1545 tid = txq->tid; in iwl_mvm_add_new_dqa_stream_wk()
1551 * transmit anyway - so just don't transmit the frame etc. in iwl_mvm_add_new_dqa_stream_wk()
1555 if (iwl_mvm_sta_alloc_queue(mvm, txq->sta, txq->ac, tid)) { in iwl_mvm_add_new_dqa_stream_wk()
1556 spin_lock_bh(&mvm->add_stream_lock); in iwl_mvm_add_new_dqa_stream_wk()
1557 list_del_init(&mvmtxq->list); in iwl_mvm_add_new_dqa_stream_wk()
1558 spin_unlock_bh(&mvm->add_stream_lock); in iwl_mvm_add_new_dqa_stream_wk()
1565 set_bit(IWL_MVM_TXQ_STATE_READY, &mvmtxq->state); in iwl_mvm_add_new_dqa_stream_wk()
1568 spin_lock(&mvm->add_stream_lock); in iwl_mvm_add_new_dqa_stream_wk()
1569 list_del_init(&mvmtxq->list); in iwl_mvm_add_new_dqa_stream_wk()
1570 spin_unlock(&mvm->add_stream_lock); in iwl_mvm_add_new_dqa_stream_wk()
1572 iwl_mvm_mac_itxq_xmit(mvm->hw, txq); in iwl_mvm_add_new_dqa_stream_wk()
1592 if (vif_type == NL80211_IFTYPE_STATION && !sta->tdls && in iwl_mvm_reserve_sta_stream()
1593 !mvm->queue_info[IWL_MVM_DQA_BSS_CLIENT_QUEUE].tid_bitmap && in iwl_mvm_reserve_sta_stream()
1594 (mvm->queue_info[IWL_MVM_DQA_BSS_CLIENT_QUEUE].status == in iwl_mvm_reserve_sta_stream()
1598 queue = iwl_mvm_find_free_queue(mvm, mvmsta->deflink.sta_id, in iwl_mvm_reserve_sta_stream()
1602 /* try again - this time kick out a queue if needed */ in iwl_mvm_reserve_sta_stream()
1603 queue = iwl_mvm_inactivity_check(mvm, mvmsta->deflink.sta_id); in iwl_mvm_reserve_sta_stream()
1606 return -ENOSPC; in iwl_mvm_reserve_sta_stream()
1609 mvm->queue_info[queue].status = IWL_MVM_QUEUE_RESERVED; in iwl_mvm_reserve_sta_stream()
1611 mvmsta->reserved_queue = queue; in iwl_mvm_reserve_sta_stream()
1614 queue, mvmsta->deflink.sta_id); in iwl_mvm_reserve_sta_stream()
1622 * does the re-mapping and queue allocation.
1624 * Note that re-enabling aggregations isn't done in this function.
1631 iwl_mvm_get_wd_timeout(mvm, mvm_sta->vif); in iwl_mvm_realloc_queues_after_restart()
1634 .sta_id = mvm_sta->deflink.sta_id, in iwl_mvm_realloc_queues_after_restart()
1639 if (mvm_sta->reserved_queue != IEEE80211_INVAL_HW_QUEUE) in iwl_mvm_realloc_queues_after_restart()
1640 mvm->queue_info[mvm_sta->reserved_queue].status = in iwl_mvm_realloc_queues_after_restart()
1644 struct iwl_mvm_tid_data *tid_data = &mvm_sta->tid_data[i]; in iwl_mvm_realloc_queues_after_restart()
1645 int txq_id = tid_data->txq_id; in iwl_mvm_realloc_queues_after_restart()
1655 "Re-mapping sta %d tid %d\n", in iwl_mvm_realloc_queues_after_restart()
1656 mvm_sta->deflink.sta_id, i); in iwl_mvm_realloc_queues_after_restart()
1658 mvm_sta->deflink.sta_id, in iwl_mvm_realloc_queues_after_restart()
1667 tid_data->txq_id = txq_id; in iwl_mvm_realloc_queues_after_restart()
1675 tid_data->seq_number = 0; in iwl_mvm_realloc_queues_after_restart()
1677 u16 seq = IEEE80211_SEQ_TO_SN(tid_data->seq_number); in iwl_mvm_realloc_queues_after_restart()
1686 "Re-mapping sta %d tid %d to queue %d\n", in iwl_mvm_realloc_queues_after_restart()
1687 mvm_sta->deflink.sta_id, i, in iwl_mvm_realloc_queues_after_restart()
1691 mvm->queue_info[txq_id].status = IWL_MVM_QUEUE_READY; in iwl_mvm_realloc_queues_after_restart()
1705 lockdep_assert_held(&mvm->mutex); in iwl_mvm_add_int_sta_common()
1708 cmd.sta_id = sta->sta_id; in iwl_mvm_add_int_sta_common()
1710 if (iwl_mvm_has_new_station_api(mvm->fw) && in iwl_mvm_add_int_sta_common()
1711 sta->type == IWL_STA_AUX_ACTIVITY) in iwl_mvm_add_int_sta_common()
1717 if (fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) in iwl_mvm_add_int_sta_common()
1718 cmd.station_type = sta->type; in iwl_mvm_add_int_sta_common()
1721 cmd.tfd_queue_msk = cpu_to_le32(sta->tfd_queue_msk); in iwl_mvm_add_int_sta_common()
1738 ret = -EIO; in iwl_mvm_add_int_sta_common()
1755 lockdep_assert_held(&mvm->mutex); in iwl_mvm_sta_init()
1757 mvm_sta->mac_id_n_color = FW_CMD_ID_AND_COLOR(mvmvif->id, in iwl_mvm_sta_init()
1758 mvmvif->color); in iwl_mvm_sta_init()
1759 mvm_sta->vif = vif; in iwl_mvm_sta_init()
1764 if (!mvm->mld_api_is_used) { in iwl_mvm_sta_init()
1766 return -EINVAL; in iwl_mvm_sta_init()
1768 mvm_sta->deflink.sta_id = sta_id; in iwl_mvm_sta_init()
1769 rcu_assign_pointer(mvm_sta->link[0], &mvm_sta->deflink); in iwl_mvm_sta_init()
1771 if (!mvm->trans->mac_cfg->gen2) in iwl_mvm_sta_init()
1772 mvm_sta->deflink.lq_sta.rs_drv.pers.max_agg_bufsize = in iwl_mvm_sta_init()
1775 mvm_sta->deflink.lq_sta.rs_drv.pers.max_agg_bufsize = in iwl_mvm_sta_init()
1779 mvm_sta->tt_tx_protection = false; in iwl_mvm_sta_init()
1780 mvm_sta->sta_type = sta_type; in iwl_mvm_sta_init()
1782 mvm_sta->tid_disable_agg = 0xffff; /* No aggs at first */ in iwl_mvm_sta_init()
1789 mvm_sta->tid_data[i].txq_id = IWL_MVM_INVALID_QUEUE; in iwl_mvm_sta_init()
1792 for (i = 0; i < ARRAY_SIZE(sta->txq); i++) { in iwl_mvm_sta_init()
1794 iwl_mvm_txq_from_mac80211(sta->txq[i]); in iwl_mvm_sta_init()
1796 mvmtxq->txq_id = IWL_MVM_INVALID_QUEUE; in iwl_mvm_sta_init()
1797 INIT_LIST_HEAD(&mvmtxq->list); in iwl_mvm_sta_init()
1798 atomic_set(&mvmtxq->tx_request, 0); in iwl_mvm_sta_init()
1804 dup_data = kcalloc(mvm->trans->info.num_rxqs, in iwl_mvm_sta_init()
1807 return -ENOMEM; in iwl_mvm_sta_init()
1817 for (q = 0; q < mvm->trans->info.num_rxqs; q++) in iwl_mvm_sta_init()
1820 mvm_sta->dup_data = dup_data; in iwl_mvm_sta_init()
1837 spin_lock_init(&mvm_sta->deflink.lq_sta.rs_drv.pers.lock); in iwl_mvm_sta_init()
1839 iwl_mvm_toggle_tx_ant(mvm, &mvm_sta->tx_ant); in iwl_mvm_sta_init()
1842 if (vif->type == NL80211_IFTYPE_STATION && !vif->p2p && in iwl_mvm_sta_init()
1843 !sta->tdls && ieee80211_vif_is_mld(vif)) { in iwl_mvm_sta_init()
1844 mvm_sta->mpdu_counters = in iwl_mvm_sta_init()
1845 kcalloc(mvm->trans->info.num_rxqs, in iwl_mvm_sta_init()
1846 sizeof(*mvm_sta->mpdu_counters), in iwl_mvm_sta_init()
1848 if (mvm_sta->mpdu_counters) in iwl_mvm_sta_init()
1849 for (int q = 0; q < mvm->trans->info.num_rxqs; q++) in iwl_mvm_sta_init()
1850 spin_lock_init(&mvm_sta->mpdu_counters[q].lock); in iwl_mvm_sta_init()
1866 lockdep_assert_held(&mvm->mutex); in iwl_mvm_add_sta()
1868 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) in iwl_mvm_add_sta()
1872 sta_id = mvm_sta->deflink.sta_id; in iwl_mvm_add_sta()
1875 return -ENOSPC; in iwl_mvm_add_sta()
1877 spin_lock_init(&mvm_sta->lock); in iwl_mvm_add_sta()
1879 /* if this is a HW restart re-alloc existing queues */ in iwl_mvm_add_sta()
1880 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) { in iwl_mvm_add_sta()
1883 .type = mvm_sta->sta_type, in iwl_mvm_add_sta()
1889 ret = iwl_mvm_add_int_sta_common(mvm, &tmp_sta, sta->addr, in iwl_mvm_add_sta()
1890 mvmvif->id, mvmvif->color); in iwl_mvm_add_sta()
1901 sta->tdls ? IWL_STA_TDLS_LINK : IWL_STA_LINK); in iwl_mvm_add_sta()
1910 if (vif->type == NL80211_IFTYPE_STATION) { in iwl_mvm_add_sta()
1911 if (!sta->tdls) { in iwl_mvm_add_sta()
1912 WARN_ON(mvmvif->deflink.ap_sta_id != IWL_INVALID_STA); in iwl_mvm_add_sta()
1913 mvmvif->deflink.ap_sta_id = sta_id; in iwl_mvm_add_sta()
1915 WARN_ON(mvmvif->deflink.ap_sta_id == IWL_INVALID_STA); in iwl_mvm_add_sta()
1919 rcu_assign_pointer(mvm->fw_id_to_mac_id[sta_id], sta); in iwl_mvm_add_sta()
1934 lockdep_assert_held(&mvm->mutex); in iwl_mvm_drain_sta()
1936 cmd.mac_id_n_color = cpu_to_le32(mvmsta->mac_id_n_color); in iwl_mvm_drain_sta()
1937 cmd.sta_id = mvmsta->deflink.sta_id; in iwl_mvm_drain_sta()
1952 mvmsta->deflink.sta_id); in iwl_mvm_drain_sta()
1955 ret = -EIO; in iwl_mvm_drain_sta()
1958 mvmsta->deflink.sta_id); in iwl_mvm_drain_sta()
1961 mvmsta->deflink.sta_id, status); in iwl_mvm_drain_sta()
1982 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id], in iwl_mvm_rm_sta_common()
1983 lockdep_is_held(&mvm->mutex)); in iwl_mvm_rm_sta_common()
1988 return -EINVAL; in iwl_mvm_rm_sta_common()
2008 lockdep_assert_held(&mvm->mutex); in iwl_mvm_disable_sta_queues()
2010 for (i = 0; i < ARRAY_SIZE(mvm_sta->tid_data); i++) { in iwl_mvm_disable_sta_queues()
2011 if (mvm_sta->tid_data[i].txq_id == IWL_MVM_INVALID_QUEUE) in iwl_mvm_disable_sta_queues()
2014 iwl_mvm_disable_txq(mvm, sta, mvm_sta->deflink.sta_id, in iwl_mvm_disable_sta_queues()
2015 &mvm_sta->tid_data[i].txq_id, i); in iwl_mvm_disable_sta_queues()
2016 mvm_sta->tid_data[i].txq_id = IWL_MVM_INVALID_QUEUE; in iwl_mvm_disable_sta_queues()
2019 for (i = 0; i < ARRAY_SIZE(sta->txq); i++) { in iwl_mvm_disable_sta_queues()
2021 iwl_mvm_txq_from_mac80211(sta->txq[i]); in iwl_mvm_disable_sta_queues()
2023 spin_lock_bh(&mvm->add_stream_lock); in iwl_mvm_disable_sta_queues()
2024 mvmtxq->txq_id = IWL_MVM_INVALID_QUEUE; in iwl_mvm_disable_sta_queues()
2025 list_del_init(&mvmtxq->list); in iwl_mvm_disable_sta_queues()
2026 clear_bit(IWL_MVM_TXQ_STATE_READY, &mvmtxq->state); in iwl_mvm_disable_sta_queues()
2027 spin_unlock_bh(&mvm->add_stream_lock); in iwl_mvm_disable_sta_queues()
2036 for (i = 0; i < ARRAY_SIZE(mvm_sta->tid_data); i++) { in iwl_mvm_wait_sta_queues_empty()
2040 spin_lock_bh(&mvm_sta->lock); in iwl_mvm_wait_sta_queues_empty()
2041 txq_id = mvm_sta->tid_data[i].txq_id; in iwl_mvm_wait_sta_queues_empty()
2042 spin_unlock_bh(&mvm_sta->lock); in iwl_mvm_wait_sta_queues_empty()
2047 ret = iwl_trans_wait_txq_empty(mvm->trans, txq_id); in iwl_mvm_wait_sta_queues_empty()
2055 /* Execute the common part for both MLD and non-MLD modes.
2065 mvmvif->link[link_sta->link_id]; in iwl_mvm_sta_del()
2070 lockdep_assert_held(&mvm->mutex); in iwl_mvm_sta_del()
2073 rcu_dereference_protected(mvm_sta->link[link_sta->link_id], in iwl_mvm_sta_del()
2074 lockdep_is_held(&mvm->mutex)); in iwl_mvm_sta_del()
2075 sta_id = mvm_link_sta->sta_id; in iwl_mvm_sta_del()
2077 if (vif->type == NL80211_IFTYPE_STATION && in iwl_mvm_sta_del()
2078 mvm_link->ap_sta_id == sta_id) { in iwl_mvm_sta_del()
2081 link_sta->link_id); in iwl_mvm_sta_del()
2083 mvm_link->ap_sta_id = IWL_INVALID_STA; in iwl_mvm_sta_del()
2087 * This shouldn't happen - the TDLS channel switch should be canceled in iwl_mvm_sta_del()
2090 if (WARN_ON_ONCE(mvm->tdls_cs.peer.sta_id == sta_id)) { in iwl_mvm_sta_del()
2091 mvm->tdls_cs.peer.sta_id = IWL_INVALID_STA; in iwl_mvm_sta_del()
2092 cancel_delayed_work(&mvm->tdls_cs.dwork); in iwl_mvm_sta_del()
2103 lockdep_assert_held(&mvm->mutex); in iwl_mvm_rm_sta()
2110 ret = iwl_mvm_flush_sta(mvm, mvm_sta->deflink.sta_id, in iwl_mvm_rm_sta()
2111 mvm_sta->tfd_queue_msk); in iwl_mvm_rm_sta()
2117 u32 q_mask = mvm_sta->tfd_queue_msk; in iwl_mvm_rm_sta()
2119 ret = iwl_trans_wait_tx_queues_empty(mvm->trans, in iwl_mvm_rm_sta()
2129 /* If there is a TXQ still marked as reserved - free it */ in iwl_mvm_rm_sta()
2130 if (mvm_sta->reserved_queue != IEEE80211_INVAL_HW_QUEUE) { in iwl_mvm_rm_sta()
2131 u8 reserved_txq = mvm_sta->reserved_queue; in iwl_mvm_rm_sta()
2135 * If no traffic has gone through the reserved TXQ - it in iwl_mvm_rm_sta()
2139 status = &mvm->queue_info[reserved_txq].status; in iwl_mvm_rm_sta()
2143 mvm_sta->deflink.sta_id, reserved_txq, *status)) in iwl_mvm_rm_sta()
2144 return -EINVAL; in iwl_mvm_rm_sta()
2149 iwl_mvm_sta_del(mvm, vif, sta, &sta->deflink); in iwl_mvm_rm_sta()
2151 ret = iwl_mvm_rm_sta_common(mvm, mvm_sta->deflink.sta_id); in iwl_mvm_rm_sta()
2152 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[mvm_sta->deflink.sta_id], NULL); in iwl_mvm_rm_sta()
2163 lockdep_assert_held(&mvm->mutex); in iwl_mvm_rm_sta_id()
2165 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[sta_id], NULL); in iwl_mvm_rm_sta_id()
2174 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) || in iwl_mvm_allocate_int_sta()
2175 sta->sta_id == IWL_INVALID_STA) { in iwl_mvm_allocate_int_sta()
2176 sta->sta_id = iwl_mvm_find_free_sta_id(mvm, iftype); in iwl_mvm_allocate_int_sta()
2177 if (WARN_ON_ONCE(sta->sta_id == IWL_INVALID_STA)) in iwl_mvm_allocate_int_sta()
2178 return -ENOSPC; in iwl_mvm_allocate_int_sta()
2181 sta->tfd_queue_msk = qmask; in iwl_mvm_allocate_int_sta()
2182 sta->type = type; in iwl_mvm_allocate_int_sta()
2184 /* put a non-NULL value so iterating over the stations won't stop */ in iwl_mvm_allocate_int_sta()
2185 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[sta->sta_id], ERR_PTR(-EINVAL)); in iwl_mvm_allocate_int_sta()
2191 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[sta->sta_id], NULL); in iwl_mvm_dealloc_int_sta()
2193 sta->sta_id = IWL_INVALID_STA; in iwl_mvm_dealloc_int_sta()
2200 mvm->trans->mac_cfg->base->wd_timeout; in iwl_mvm_enable_aux_snif_queue()
2217 mvm->trans->mac_cfg->base->wd_timeout; in iwl_mvm_enable_aux_snif_queue_tvqm()
2232 /* Map queue to fifo - needs to happen before adding station */ in iwl_mvm_add_int_sta_with_queue()
2234 iwl_mvm_enable_aux_snif_queue(mvm, *queue, sta->sta_id, fifo); in iwl_mvm_add_int_sta_with_queue()
2239 iwl_mvm_disable_txq(mvm, NULL, sta->sta_id, queue, in iwl_mvm_add_int_sta_with_queue()
2246 * to firmware so enable queue here - after the station was added in iwl_mvm_add_int_sta_with_queue()
2251 txq = iwl_mvm_enable_aux_snif_queue_tvqm(mvm, sta->sta_id); in iwl_mvm_add_int_sta_with_queue()
2253 iwl_mvm_rm_sta_common(mvm, sta->sta_id); in iwl_mvm_add_int_sta_with_queue()
2266 u32 qmask = mvm->aux_queue == IWL_MVM_INVALID_QUEUE ? 0 : in iwl_mvm_add_aux_sta()
2267 BIT(mvm->aux_queue); in iwl_mvm_add_aux_sta()
2269 lockdep_assert_held(&mvm->mutex); in iwl_mvm_add_aux_sta()
2272 ret = iwl_mvm_allocate_int_sta(mvm, &mvm->aux_sta, qmask, in iwl_mvm_add_aux_sta()
2283 &mvm->aux_sta, &mvm->aux_queue, in iwl_mvm_add_aux_sta()
2286 iwl_mvm_dealloc_int_sta(mvm, &mvm->aux_sta); in iwl_mvm_add_aux_sta()
2297 lockdep_assert_held(&mvm->mutex); in iwl_mvm_add_snif_sta()
2299 return iwl_mvm_add_int_sta_with_queue(mvm, mvmvif->id, mvmvif->color, in iwl_mvm_add_snif_sta()
2300 NULL, &mvm->snif_sta, in iwl_mvm_add_snif_sta()
2301 &mvm->snif_queue, in iwl_mvm_add_snif_sta()
2309 lockdep_assert_held(&mvm->mutex); in iwl_mvm_rm_snif_sta()
2311 if (WARN_ON_ONCE(mvm->snif_sta.sta_id == IWL_INVALID_STA)) in iwl_mvm_rm_snif_sta()
2312 return -EINVAL; in iwl_mvm_rm_snif_sta()
2314 iwl_mvm_disable_txq(mvm, NULL, mvm->snif_sta.sta_id, in iwl_mvm_rm_snif_sta()
2315 &mvm->snif_queue, IWL_MAX_TID_COUNT); in iwl_mvm_rm_snif_sta()
2316 ret = iwl_mvm_rm_sta_common(mvm, mvm->snif_sta.sta_id); in iwl_mvm_rm_snif_sta()
2327 lockdep_assert_held(&mvm->mutex); in iwl_mvm_rm_aux_sta()
2329 if (WARN_ON_ONCE(mvm->aux_sta.sta_id == IWL_INVALID_STA)) in iwl_mvm_rm_aux_sta()
2330 return -EINVAL; in iwl_mvm_rm_aux_sta()
2332 iwl_mvm_disable_txq(mvm, NULL, mvm->aux_sta.sta_id, in iwl_mvm_rm_aux_sta()
2333 &mvm->aux_queue, IWL_MAX_TID_COUNT); in iwl_mvm_rm_aux_sta()
2334 ret = iwl_mvm_rm_sta_common(mvm, mvm->aux_sta.sta_id); in iwl_mvm_rm_aux_sta()
2337 iwl_mvm_dealloc_int_sta(mvm, &mvm->aux_sta); in iwl_mvm_rm_aux_sta()
2344 iwl_mvm_dealloc_int_sta(mvm, &mvm->snif_sta); in iwl_mvm_dealloc_snif_sta()
2358 struct iwl_mvm_int_sta *bsta = &mvmvif->deflink.bcast_sta; in iwl_mvm_send_add_bcast_sta()
2367 .sta_id = mvmvif->deflink.bcast_sta.sta_id, in iwl_mvm_send_add_bcast_sta()
2373 lockdep_assert_held(&mvm->mutex); in iwl_mvm_send_add_bcast_sta()
2376 if (vif->type == NL80211_IFTYPE_AP || in iwl_mvm_send_add_bcast_sta()
2377 vif->type == NL80211_IFTYPE_ADHOC) { in iwl_mvm_send_add_bcast_sta()
2378 queue = mvm->probe_queue; in iwl_mvm_send_add_bcast_sta()
2379 } else if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { in iwl_mvm_send_add_bcast_sta()
2380 queue = mvm->p2p_dev_queue; in iwl_mvm_send_add_bcast_sta()
2383 return -EINVAL; in iwl_mvm_send_add_bcast_sta()
2386 bsta->tfd_queue_msk |= BIT(queue); in iwl_mvm_send_add_bcast_sta()
2391 if (vif->type == NL80211_IFTYPE_ADHOC) in iwl_mvm_send_add_bcast_sta()
2392 baddr = vif->bss_conf.bssid; in iwl_mvm_send_add_bcast_sta()
2394 if (WARN_ON_ONCE(bsta->sta_id == IWL_INVALID_STA)) in iwl_mvm_send_add_bcast_sta()
2395 return -ENOSPC; in iwl_mvm_send_add_bcast_sta()
2398 mvmvif->id, mvmvif->color); in iwl_mvm_send_add_bcast_sta()
2404 * to firmware so enable queue here - after the station was added in iwl_mvm_send_add_bcast_sta()
2407 queue = iwl_mvm_tvqm_enable_txq(mvm, NULL, bsta->sta_id, in iwl_mvm_send_add_bcast_sta()
2411 iwl_mvm_rm_sta_common(mvm, bsta->sta_id); in iwl_mvm_send_add_bcast_sta()
2415 if (vif->type == NL80211_IFTYPE_AP || in iwl_mvm_send_add_bcast_sta()
2416 vif->type == NL80211_IFTYPE_ADHOC) { in iwl_mvm_send_add_bcast_sta()
2418 mvm->probe_queue = queue; in iwl_mvm_send_add_bcast_sta()
2420 mvmvif->deflink.mgmt_queue = queue; in iwl_mvm_send_add_bcast_sta()
2421 } else if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { in iwl_mvm_send_add_bcast_sta()
2422 mvm->p2p_dev_queue = queue; in iwl_mvm_send_add_bcast_sta()
2424 } else if (vif->type == NL80211_IFTYPE_AP || in iwl_mvm_send_add_bcast_sta()
2425 vif->type == NL80211_IFTYPE_ADHOC) { in iwl_mvm_send_add_bcast_sta()
2427 mvmvif->deflink.mgmt_queue = mvm->probe_queue; in iwl_mvm_send_add_bcast_sta()
2439 lockdep_assert_held(&mvm->mutex); in iwl_mvm_free_bcast_sta_queues()
2441 iwl_mvm_flush_sta(mvm, mvmvif->deflink.bcast_sta.sta_id, in iwl_mvm_free_bcast_sta_queues()
2442 mvmvif->deflink.bcast_sta.tfd_queue_msk); in iwl_mvm_free_bcast_sta_queues()
2444 switch (vif->type) { in iwl_mvm_free_bcast_sta_queues()
2447 queueptr = &mvm->probe_queue; in iwl_mvm_free_bcast_sta_queues()
2450 queueptr = &mvm->p2p_dev_queue; in iwl_mvm_free_bcast_sta_queues()
2454 vif->type); in iwl_mvm_free_bcast_sta_queues()
2459 iwl_mvm_disable_txq(mvm, NULL, mvmvif->deflink.bcast_sta.sta_id, in iwl_mvm_free_bcast_sta_queues()
2462 if (vif->type == NL80211_IFTYPE_AP || vif->type == NL80211_IFTYPE_ADHOC) in iwl_mvm_free_bcast_sta_queues()
2463 mvmvif->deflink.mgmt_queue = mvm->probe_queue; in iwl_mvm_free_bcast_sta_queues()
2468 WARN_ON(!(mvmvif->deflink.bcast_sta.tfd_queue_msk & BIT(queue))); in iwl_mvm_free_bcast_sta_queues()
2469 mvmvif->deflink.bcast_sta.tfd_queue_msk &= ~BIT(queue); in iwl_mvm_free_bcast_sta_queues()
2479 lockdep_assert_held(&mvm->mutex); in iwl_mvm_send_rm_bcast_sta()
2483 ret = iwl_mvm_rm_sta_common(mvm, mvmvif->deflink.bcast_sta.sta_id); in iwl_mvm_send_rm_bcast_sta()
2493 lockdep_assert_held(&mvm->mutex); in iwl_mvm_alloc_bcast_sta()
2495 return iwl_mvm_allocate_int_sta(mvm, &mvmvif->deflink.bcast_sta, 0, in iwl_mvm_alloc_bcast_sta()
2510 struct iwl_mvm_int_sta *bsta = &mvmvif->deflink.bcast_sta; in iwl_mvm_add_p2p_bcast_sta()
2513 lockdep_assert_held(&mvm->mutex); in iwl_mvm_add_p2p_bcast_sta()
2531 iwl_mvm_dealloc_int_sta(mvm, &mvmvif->deflink.bcast_sta); in iwl_mvm_dealloc_bcast_sta()
2542 lockdep_assert_held(&mvm->mutex); in iwl_mvm_rm_p2p_bcast_sta()
2562 struct iwl_mvm_int_sta *msta = &mvmvif->deflink.mcast_sta; in iwl_mvm_add_mcast_sta()
2566 .fifo = vif->type == NL80211_IFTYPE_AP ? in iwl_mvm_add_mcast_sta()
2568 .sta_id = msta->sta_id, in iwl_mvm_add_mcast_sta()
2576 lockdep_assert_held(&mvm->mutex); in iwl_mvm_add_mcast_sta()
2578 if (WARN_ON(vif->type != NL80211_IFTYPE_AP && in iwl_mvm_add_mcast_sta()
2579 vif->type != NL80211_IFTYPE_ADHOC)) in iwl_mvm_add_mcast_sta()
2580 return -EOPNOTSUPP; in iwl_mvm_add_mcast_sta()
2588 if (vif->type == NL80211_IFTYPE_ADHOC) in iwl_mvm_add_mcast_sta()
2589 mvmvif->deflink.cab_queue = IWL_MVM_DQA_GCAST_QUEUE; in iwl_mvm_add_mcast_sta()
2596 fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) { in iwl_mvm_add_mcast_sta()
2597 iwl_mvm_enable_txq(mvm, NULL, mvmvif->deflink.cab_queue, 0, in iwl_mvm_add_mcast_sta()
2600 msta->tfd_queue_msk |= BIT(mvmvif->deflink.cab_queue); in iwl_mvm_add_mcast_sta()
2603 mvmvif->id, mvmvif->color); in iwl_mvm_add_mcast_sta()
2615 int queue = iwl_mvm_tvqm_enable_txq(mvm, NULL, msta->sta_id, in iwl_mvm_add_mcast_sta()
2621 mvmvif->deflink.cab_queue = queue; in iwl_mvm_add_mcast_sta()
2622 } else if (!fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_add_mcast_sta()
2624 iwl_mvm_enable_txq(mvm, NULL, mvmvif->deflink.cab_queue, 0, in iwl_mvm_add_mcast_sta()
2642 bool new_api = fw_has_api(&mvm->fw->ucode_capa, in __iwl_mvm_remove_sta_key()
2652 key_flags = cpu_to_le16((keyconf->keyidx << STA_KEY_FLG_KEYID_POS) & in __iwl_mvm_remove_sta_key()
2665 u.cmd.common.key_offset = keyconf->hw_key_idx; in __iwl_mvm_remove_sta_key()
2679 ret = -EIO; in __iwl_mvm_remove_sta_key()
2696 lockdep_assert_held(&mvm->mutex); in iwl_mvm_rm_mcast_sta()
2698 iwl_mvm_flush_sta(mvm, mvmvif->deflink.mcast_sta.sta_id, in iwl_mvm_rm_mcast_sta()
2699 mvmvif->deflink.mcast_sta.tfd_queue_msk); in iwl_mvm_rm_mcast_sta()
2701 iwl_mvm_disable_txq(mvm, NULL, mvmvif->deflink.mcast_sta.sta_id, in iwl_mvm_rm_mcast_sta()
2702 &mvmvif->deflink.cab_queue, 0); in iwl_mvm_rm_mcast_sta()
2704 ret = iwl_mvm_rm_sta_common(mvm, mvmvif->deflink.mcast_sta.sta_id); in iwl_mvm_rm_mcast_sta()
2726 iwl_mvm_sync_rxq_del_ba(mvm, data->baid); in iwl_mvm_free_reorder()
2728 for (i = 0; i < mvm->trans->info.num_rxqs; i++) { in iwl_mvm_free_reorder()
2731 &data->reorder_buf[i]; in iwl_mvm_free_reorder()
2733 &data->entries[i * data->entries_per_queue]; in iwl_mvm_free_reorder()
2735 spin_lock_bh(&reorder_buf->lock); in iwl_mvm_free_reorder()
2736 if (likely(!reorder_buf->num_stored)) { in iwl_mvm_free_reorder()
2737 spin_unlock_bh(&reorder_buf->lock); in iwl_mvm_free_reorder()
2748 for (j = 0; j < data->buf_size; j++) in iwl_mvm_free_reorder()
2751 spin_unlock_bh(&reorder_buf->lock); in iwl_mvm_free_reorder()
2761 for (i = 0; i < mvm->trans->info.num_rxqs; i++) { in iwl_mvm_init_reorder_buffer()
2763 &data->reorder_buf[i]; in iwl_mvm_init_reorder_buffer()
2765 &data->entries[i * data->entries_per_queue]; in iwl_mvm_init_reorder_buffer()
2768 reorder_buf->num_stored = 0; in iwl_mvm_init_reorder_buffer()
2769 reorder_buf->head_sn = ssn; in iwl_mvm_init_reorder_buffer()
2770 spin_lock_init(&reorder_buf->lock); in iwl_mvm_init_reorder_buffer()
2771 reorder_buf->queue = i; in iwl_mvm_init_reorder_buffer()
2772 reorder_buf->valid = false; in iwl_mvm_init_reorder_buffer()
2773 for (j = 0; j < data->buf_size; j++) in iwl_mvm_init_reorder_buffer()
2785 .mac_id_n_color = cpu_to_le32(mvm_sta->mac_id_n_color), in iwl_mvm_fw_baid_op_sta()
2786 .sta_id = mvm_sta->deflink.sta_id, in iwl_mvm_fw_baid_op_sta()
2815 return -EINVAL; in iwl_mvm_fw_baid_op_sta()
2819 return -ENOSPC; in iwl_mvm_fw_baid_op_sta()
2823 return -EIO; in iwl_mvm_fw_baid_op_sta()
2848 cpu_to_le32(iwl_mvm_sta_fw_id_mask(mvm, sta, -1)); in iwl_mvm_fw_baid_op_cmd()
2852 baid = -EIO; in iwl_mvm_fw_baid_op_cmd()
2853 } else if (iwl_fw_lookup_cmd_ver(mvm->fw, hcmd.id, 1) == 1) { in iwl_mvm_fw_baid_op_cmd()
2858 cpu_to_le32(iwl_mvm_sta_fw_id_mask(mvm, sta, -1)); in iwl_mvm_fw_baid_op_cmd()
2874 if (baid < 0 || baid >= ARRAY_SIZE(mvm->baid_map)) in iwl_mvm_fw_baid_op_cmd()
2875 return -EINVAL; in iwl_mvm_fw_baid_op_cmd()
2884 if (fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_fw_baid_op()
2902 lockdep_assert_held(&mvm->mutex); in iwl_mvm_sta_rx_agg()
2904 if (start && mvm->rx_ba_sessions >= max_ba_id_sessions) { in iwl_mvm_sta_rx_agg()
2906 return -ENOSPC; in iwl_mvm_sta_rx_agg()
2910 u32 reorder_buf_size = buf_size * sizeof(baid_data->entries[0]); in iwl_mvm_sta_rx_agg()
2920 BUILD_BUG_ON(SMP_CACHE_BYTES % sizeof(baid_data->entries[0]) && in iwl_mvm_sta_rx_agg()
2921 sizeof(baid_data->entries[0]) % SMP_CACHE_BYTES); in iwl_mvm_sta_rx_agg()
2936 mvm->trans->info.num_rxqs * in iwl_mvm_sta_rx_agg()
2940 return -ENOMEM; in iwl_mvm_sta_rx_agg()
2946 baid_data->entries_per_queue = in iwl_mvm_sta_rx_agg()
2947 reorder_buf_size / sizeof(baid_data->entries[0]); in iwl_mvm_sta_rx_agg()
2951 baid = mvm_sta->tid_to_baid[tid]; in iwl_mvm_sta_rx_agg()
2954 baid = -1; in iwl_mvm_sta_rx_agg()
2958 if (start || !test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) in iwl_mvm_sta_rx_agg()
2968 mvm->rx_ba_sessions++; in iwl_mvm_sta_rx_agg()
2973 baid_data->baid = baid; in iwl_mvm_sta_rx_agg()
2974 baid_data->timeout = timeout; in iwl_mvm_sta_rx_agg()
2975 baid_data->last_rx = jiffies; in iwl_mvm_sta_rx_agg()
2976 baid_data->rcu_ptr = &mvm->baid_map[baid]; in iwl_mvm_sta_rx_agg()
2977 timer_setup(&baid_data->session_timer, in iwl_mvm_sta_rx_agg()
2979 baid_data->mvm = mvm; in iwl_mvm_sta_rx_agg()
2980 baid_data->tid = tid; in iwl_mvm_sta_rx_agg()
2981 baid_data->sta_mask = iwl_mvm_sta_fw_id_mask(mvm, sta, -1); in iwl_mvm_sta_rx_agg()
2982 baid_data->buf_size = buf_size; in iwl_mvm_sta_rx_agg()
2984 mvm_sta->tid_to_baid[tid] = baid; in iwl_mvm_sta_rx_agg()
2986 mod_timer(&baid_data->session_timer, in iwl_mvm_sta_rx_agg()
2997 mvm_sta->deflink.sta_id, tid, baid); in iwl_mvm_sta_rx_agg()
2998 WARN_ON(rcu_access_pointer(mvm->baid_map[baid])); in iwl_mvm_sta_rx_agg()
2999 rcu_assign_pointer(mvm->baid_map[baid], baid_data); in iwl_mvm_sta_rx_agg()
3001 baid = mvm_sta->tid_to_baid[tid]; in iwl_mvm_sta_rx_agg()
3003 if (mvm->rx_ba_sessions > 0) in iwl_mvm_sta_rx_agg()
3005 mvm->rx_ba_sessions--; in iwl_mvm_sta_rx_agg()
3010 return -EINVAL; in iwl_mvm_sta_rx_agg()
3012 baid_data = rcu_access_pointer(mvm->baid_map[baid]); in iwl_mvm_sta_rx_agg()
3014 return -EINVAL; in iwl_mvm_sta_rx_agg()
3018 timer_shutdown_sync(&baid_data->session_timer); in iwl_mvm_sta_rx_agg()
3019 RCU_INIT_POINTER(mvm->baid_map[baid], NULL); in iwl_mvm_sta_rx_agg()
3038 lockdep_assert_held(&mvm->mutex); in iwl_mvm_sta_tx_agg()
3041 mvm_sta->tfd_queue_msk |= BIT(queue); in iwl_mvm_sta_tx_agg()
3042 mvm_sta->tid_disable_agg &= ~BIT(tid); in iwl_mvm_sta_tx_agg()
3044 /* In DQA-mode the queue isn't removed on agg termination */ in iwl_mvm_sta_tx_agg()
3045 mvm_sta->tid_disable_agg |= BIT(tid); in iwl_mvm_sta_tx_agg()
3048 cmd.mac_id_n_color = cpu_to_le32(mvm_sta->mac_id_n_color); in iwl_mvm_sta_tx_agg()
3049 cmd.sta_id = mvm_sta->deflink.sta_id; in iwl_mvm_sta_tx_agg()
3054 cmd.tfd_queue_msk = cpu_to_le32(mvm_sta->tfd_queue_msk); in iwl_mvm_sta_tx_agg()
3055 cmd.tid_disable_tx = cpu_to_le16(mvm_sta->tid_disable_agg); in iwl_mvm_sta_tx_agg()
3068 ret = -EIO; in iwl_mvm_sta_tx_agg()
3110 return -EINVAL; in iwl_mvm_sta_tx_agg_start()
3112 if (mvmsta->tid_data[tid].state != IWL_AGG_QUEUED && in iwl_mvm_sta_tx_agg_start()
3113 mvmsta->tid_data[tid].state != IWL_AGG_OFF) { in iwl_mvm_sta_tx_agg_start()
3116 mvmsta->tid_data[tid].state); in iwl_mvm_sta_tx_agg_start()
3117 return -ENXIO; in iwl_mvm_sta_tx_agg_start()
3120 lockdep_assert_held(&mvm->mutex); in iwl_mvm_sta_tx_agg_start()
3122 if (mvmsta->tid_data[tid].txq_id == IWL_MVM_INVALID_QUEUE && in iwl_mvm_sta_tx_agg_start()
3131 spin_lock_bh(&mvmsta->lock); in iwl_mvm_sta_tx_agg_start()
3135 * 1. An enabled TXQ - TXQ needs to become agg'ed in iwl_mvm_sta_tx_agg_start()
3139 txq_id = mvmsta->tid_data[tid].txq_id; in iwl_mvm_sta_tx_agg_start()
3141 ret = iwl_mvm_find_free_queue(mvm, mvmsta->deflink.sta_id, in iwl_mvm_sta_tx_agg_start()
3152 mvm->queue_info[txq_id].status = IWL_MVM_QUEUE_RESERVED; in iwl_mvm_sta_tx_agg_start()
3154 ret = -ENXIO; in iwl_mvm_sta_tx_agg_start()
3156 tid, IWL_MAX_HW_QUEUES - 1); in iwl_mvm_sta_tx_agg_start()
3159 } else if (unlikely(mvm->queue_info[txq_id].status == in iwl_mvm_sta_tx_agg_start()
3161 ret = -ENXIO; in iwl_mvm_sta_tx_agg_start()
3172 tid_data = &mvmsta->tid_data[tid]; in iwl_mvm_sta_tx_agg_start()
3173 tid_data->ssn = IEEE80211_SEQ_TO_SN(tid_data->seq_number); in iwl_mvm_sta_tx_agg_start()
3174 tid_data->txq_id = txq_id; in iwl_mvm_sta_tx_agg_start()
3175 *ssn = tid_data->ssn; in iwl_mvm_sta_tx_agg_start()
3178 "Start AGG: sta %d tid %d queue %d - ssn = %d, next_recl = %d\n", in iwl_mvm_sta_tx_agg_start()
3179 mvmsta->deflink.sta_id, tid, txq_id, in iwl_mvm_sta_tx_agg_start()
3180 tid_data->ssn, in iwl_mvm_sta_tx_agg_start()
3181 tid_data->next_reclaimed); in iwl_mvm_sta_tx_agg_start()
3187 normalized_ssn = tid_data->ssn; in iwl_mvm_sta_tx_agg_start()
3188 if (mvm->trans->mac_cfg->gen2) in iwl_mvm_sta_tx_agg_start()
3191 if (normalized_ssn == tid_data->next_reclaimed) { in iwl_mvm_sta_tx_agg_start()
3192 tid_data->state = IWL_AGG_STARTING; in iwl_mvm_sta_tx_agg_start()
3195 tid_data->state = IWL_EMPTYING_HW_QUEUE_ADDBA; in iwl_mvm_sta_tx_agg_start()
3200 spin_unlock_bh(&mvmsta->lock); in iwl_mvm_sta_tx_agg_start()
3210 struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid]; in iwl_mvm_sta_tx_agg_oper()
3219 .sta_id = mvmsta->deflink.sta_id, in iwl_mvm_sta_tx_agg_oper()
3230 return -EINVAL; in iwl_mvm_sta_tx_agg_oper()
3232 BUILD_BUG_ON((sizeof(mvmsta->agg_tids) * BITS_PER_BYTE) in iwl_mvm_sta_tx_agg_oper()
3235 spin_lock_bh(&mvmsta->lock); in iwl_mvm_sta_tx_agg_oper()
3236 ssn = tid_data->ssn; in iwl_mvm_sta_tx_agg_oper()
3237 queue = tid_data->txq_id; in iwl_mvm_sta_tx_agg_oper()
3238 tid_data->state = IWL_AGG_ON; in iwl_mvm_sta_tx_agg_oper()
3239 mvmsta->agg_tids |= BIT(tid); in iwl_mvm_sta_tx_agg_oper()
3240 tid_data->ssn = 0xffff; in iwl_mvm_sta_tx_agg_oper()
3241 tid_data->amsdu_in_ampdu_allowed = amsdu; in iwl_mvm_sta_tx_agg_oper()
3242 spin_unlock_bh(&mvmsta->lock); in iwl_mvm_sta_tx_agg_oper()
3253 * Note that if SCD default value changes - this condition in iwl_mvm_sta_tx_agg_oper()
3257 return -EOPNOTSUPP; in iwl_mvm_sta_tx_agg_oper()
3261 return -EIO; in iwl_mvm_sta_tx_agg_oper()
3267 queue_status = mvm->queue_info[queue].status; in iwl_mvm_sta_tx_agg_oper()
3270 if (mvm->queue_info[queue].status == IWL_MVM_QUEUE_READY) in iwl_mvm_sta_tx_agg_oper()
3282 ret = iwl_trans_wait_tx_queues_empty(mvm->trans, in iwl_mvm_sta_tx_agg_oper()
3291 mvmsta->deflink.sta_id, tid, in iwl_mvm_sta_tx_agg_oper()
3308 return -EIO; in iwl_mvm_sta_tx_agg_oper()
3312 mvm->queue_info[queue].status = IWL_MVM_QUEUE_READY; in iwl_mvm_sta_tx_agg_oper()
3322 mvmsta->deflink.lq_sta.rs_drv.pers.max_agg_bufsize = in iwl_mvm_sta_tx_agg_oper()
3323 min(mvmsta->deflink.lq_sta.rs_drv.pers.max_agg_bufsize, in iwl_mvm_sta_tx_agg_oper()
3325 mvmsta->deflink.lq_sta.rs_drv.lq.agg_frame_cnt_limit = in iwl_mvm_sta_tx_agg_oper()
3326 mvmsta->deflink.lq_sta.rs_drv.pers.max_agg_bufsize; in iwl_mvm_sta_tx_agg_oper()
3329 sta->addr, tid); in iwl_mvm_sta_tx_agg_oper()
3331 return iwl_mvm_send_lq_cmd(mvm, &mvmsta->deflink.lq_sta.rs_drv.lq); in iwl_mvm_sta_tx_agg_oper()
3338 u16 txq_id = tid_data->txq_id; in iwl_mvm_unreserve_agg_queue()
3340 lockdep_assert_held(&mvm->mutex); in iwl_mvm_unreserve_agg_queue()
3352 if (mvm->queue_info[txq_id].status == IWL_MVM_QUEUE_RESERVED) { in iwl_mvm_unreserve_agg_queue()
3353 mvm->queue_info[txq_id].status = IWL_MVM_QUEUE_FREE; in iwl_mvm_unreserve_agg_queue()
3354 tid_data->txq_id = IWL_MVM_INVALID_QUEUE; in iwl_mvm_unreserve_agg_queue()
3362 struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid]; in iwl_mvm_sta_tx_agg_stop()
3370 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) { in iwl_mvm_sta_tx_agg_stop()
3371 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); in iwl_mvm_sta_tx_agg_stop()
3375 spin_lock_bh(&mvmsta->lock); in iwl_mvm_sta_tx_agg_stop()
3377 txq_id = tid_data->txq_id; in iwl_mvm_sta_tx_agg_stop()
3380 mvmsta->deflink.sta_id, tid, txq_id, in iwl_mvm_sta_tx_agg_stop()
3381 tid_data->state); in iwl_mvm_sta_tx_agg_stop()
3383 mvmsta->agg_tids &= ~BIT(tid); in iwl_mvm_sta_tx_agg_stop()
3387 switch (tid_data->state) { in iwl_mvm_sta_tx_agg_stop()
3389 tid_data->ssn = IEEE80211_SEQ_TO_SN(tid_data->seq_number); in iwl_mvm_sta_tx_agg_stop()
3393 tid_data->ssn, tid_data->next_reclaimed); in iwl_mvm_sta_tx_agg_stop()
3395 tid_data->ssn = 0xffff; in iwl_mvm_sta_tx_agg_stop()
3396 tid_data->state = IWL_AGG_OFF; in iwl_mvm_sta_tx_agg_stop()
3397 spin_unlock_bh(&mvmsta->lock); in iwl_mvm_sta_tx_agg_stop()
3399 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); in iwl_mvm_sta_tx_agg_stop()
3411 lockdep_assert_held(&mvm->mutex); in iwl_mvm_sta_tx_agg_stop()
3413 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); in iwl_mvm_sta_tx_agg_stop()
3414 tid_data->state = IWL_AGG_OFF; in iwl_mvm_sta_tx_agg_stop()
3420 mvmsta->deflink.sta_id, tid, tid_data->state); in iwl_mvm_sta_tx_agg_stop()
3422 "\ttid_data->txq_id = %d\n", tid_data->txq_id); in iwl_mvm_sta_tx_agg_stop()
3423 err = -EINVAL; in iwl_mvm_sta_tx_agg_stop()
3426 spin_unlock_bh(&mvmsta->lock); in iwl_mvm_sta_tx_agg_stop()
3435 struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid]; in iwl_mvm_sta_tx_agg_flush()
3443 spin_lock_bh(&mvmsta->lock); in iwl_mvm_sta_tx_agg_flush()
3444 txq_id = tid_data->txq_id; in iwl_mvm_sta_tx_agg_flush()
3446 mvmsta->deflink.sta_id, tid, txq_id, in iwl_mvm_sta_tx_agg_flush()
3447 tid_data->state); in iwl_mvm_sta_tx_agg_flush()
3448 old_state = tid_data->state; in iwl_mvm_sta_tx_agg_flush()
3449 tid_data->state = IWL_AGG_OFF; in iwl_mvm_sta_tx_agg_flush()
3450 mvmsta->agg_tids &= ~BIT(tid); in iwl_mvm_sta_tx_agg_flush()
3451 spin_unlock_bh(&mvmsta->lock); in iwl_mvm_sta_tx_agg_flush()
3459 if (iwl_mvm_flush_sta_tids(mvm, mvmsta->deflink.sta_id, in iwl_mvm_sta_tx_agg_flush()
3462 iwl_trans_wait_txq_empty(mvm->trans, txq_id); in iwl_mvm_sta_tx_agg_flush()
3466 iwl_trans_wait_tx_queues_empty(mvm->trans, BIT(txq_id)); in iwl_mvm_sta_tx_agg_flush()
3479 int i, max = -1, max_offs = -1; in iwl_mvm_set_fw_key_idx()
3481 lockdep_assert_held(&mvm->mutex); in iwl_mvm_set_fw_key_idx()
3490 if (test_bit(i, mvm->fw_key_table)) in iwl_mvm_set_fw_key_idx()
3492 if (mvm->fw_key_deleted[i] > max) { in iwl_mvm_set_fw_key_idx()
3493 max = mvm->fw_key_deleted[i]; in iwl_mvm_set_fw_key_idx()
3518 if (vif->type == NL80211_IFTYPE_STATION && in iwl_mvm_get_key_sta()
3519 mvmvif->deflink.ap_sta_id != IWL_INVALID_STA) { in iwl_mvm_get_key_sta()
3520 u8 sta_id = mvmvif->deflink.ap_sta_id; in iwl_mvm_get_key_sta()
3522 sta = rcu_dereference_check(mvm->fw_id_to_mac_id[sta_id], in iwl_mvm_get_key_sta()
3523 lockdep_is_held(&mvm->mutex)); in iwl_mvm_get_key_sta()
3527 * for example when a GTK is removed - the sta_id will then in iwl_mvm_get_key_sta()
3543 for (i = len - 1; i >= 0; i--) { in iwl_mvm_pn_cmp()
3547 return -1; in iwl_mvm_pn_cmp()
3569 bool new_api = fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_send_sta_key()
3571 int api_ver = iwl_fw_lookup_cmd_ver(mvm->fw, ADD_STA_KEY, in iwl_mvm_send_sta_key()
3575 return -EINVAL; in iwl_mvm_send_sta_key()
3577 keyidx = (key->keyidx << STA_KEY_FLG_KEYID_POS) & in iwl_mvm_send_sta_key()
3582 if (key->flags & IEEE80211_KEY_FLAG_SPP_AMSDU) in iwl_mvm_send_sta_key()
3585 switch (key->cipher) { in iwl_mvm_send_sta_key()
3590 &key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY], in iwl_mvm_send_sta_key()
3594 &key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY], in iwl_mvm_send_sta_key()
3596 pn = atomic64_read(&key->tx_pn); in iwl_mvm_send_sta_key()
3604 memcpy(u.cmd.common.key, key->key, key->keylen); in iwl_mvm_send_sta_key()
3608 memcpy(u.cmd.common.key, key->key, key->keylen); in iwl_mvm_send_sta_key()
3610 pn = atomic64_read(&key->tx_pn); in iwl_mvm_send_sta_key()
3617 memcpy(u.cmd.common.key + 3, key->key, key->keylen); in iwl_mvm_send_sta_key()
3624 memcpy(u.cmd.common.key, key->key, key->keylen); in iwl_mvm_send_sta_key()
3626 pn = atomic64_read(&key->tx_pn); in iwl_mvm_send_sta_key()
3630 memcpy(u.cmd.common.key, key->key, key->keylen); in iwl_mvm_send_sta_key()
3642 if (key->cipher == WLAN_CIPHER_SUITE_TKIP) in iwl_mvm_send_sta_key()
3645 i = -1; in iwl_mvm_send_sta_key()
3656 if (key->cipher == WLAN_CIPHER_SUITE_TKIP) { in iwl_mvm_send_sta_key()
3701 ret = -EIO; in iwl_mvm_send_sta_key()
3716 if (WARN_ON((keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE) || in iwl_mvm_send_sta_igtk()
3717 (keyconf->keyidx != 4 && keyconf->keyidx != 5 && in iwl_mvm_send_sta_igtk()
3718 keyconf->keyidx != 6 && keyconf->keyidx != 7) || in iwl_mvm_send_sta_igtk()
3719 (keyconf->cipher != WLAN_CIPHER_SUITE_AES_CMAC && in iwl_mvm_send_sta_igtk()
3720 keyconf->cipher != WLAN_CIPHER_SUITE_BIP_GMAC_128 && in iwl_mvm_send_sta_igtk()
3721 keyconf->cipher != WLAN_CIPHER_SUITE_BIP_GMAC_256))) in iwl_mvm_send_sta_igtk()
3722 return -EINVAL; in iwl_mvm_send_sta_igtk()
3725 keyconf->cipher != WLAN_CIPHER_SUITE_AES_CMAC)) in iwl_mvm_send_sta_igtk()
3726 return -EINVAL; in iwl_mvm_send_sta_igtk()
3728 igtk_cmd.key_id = cpu_to_le32(keyconf->keyidx); in iwl_mvm_send_sta_igtk()
3741 switch (keyconf->cipher) { in iwl_mvm_send_sta_igtk()
3750 return -EINVAL; in iwl_mvm_send_sta_igtk()
3753 memcpy(igtk_cmd.igtk, keyconf->key, keyconf->keylen); in iwl_mvm_send_sta_igtk()
3754 if (keyconf->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256) in iwl_mvm_send_sta_igtk()
3769 keyconf->keyidx >= 6 ? "B" : "", in iwl_mvm_send_sta_igtk()
3770 keyconf->keyidx, igtk_cmd.sta_id); in iwl_mvm_send_sta_igtk()
3797 return sta->addr; in iwl_mvm_get_mac_addr()
3799 if (vif->type == NL80211_IFTYPE_STATION && in iwl_mvm_get_mac_addr()
3800 mvmvif->deflink.ap_sta_id != IWL_INVALID_STA) { in iwl_mvm_get_mac_addr()
3801 u8 sta_id = mvmvif->deflink.ap_sta_id; in iwl_mvm_get_mac_addr()
3802 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id], in iwl_mvm_get_mac_addr()
3803 lockdep_is_held(&mvm->mutex)); in iwl_mvm_get_mac_addr()
3807 return sta->addr; in iwl_mvm_get_mac_addr()
3830 sta_id = mvm_sta->deflink.sta_id; in __iwl_mvm_set_sta_key()
3831 mfp = sta->mfp; in __iwl_mvm_set_sta_key()
3832 } else if (vif->type == NL80211_IFTYPE_AP && in __iwl_mvm_set_sta_key()
3833 !(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { in __iwl_mvm_set_sta_key()
3836 sta_id = mvmvif->deflink.mcast_sta.sta_id; in __iwl_mvm_set_sta_key()
3839 return -EINVAL; in __iwl_mvm_set_sta_key()
3842 if (keyconf->cipher == WLAN_CIPHER_SUITE_TKIP) { in __iwl_mvm_set_sta_key()
3846 return -EINVAL; in __iwl_mvm_set_sta_key()
3868 bool mcast = !(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE); in iwl_mvm_set_sta_key()
3874 lockdep_assert_held(&mvm->mutex); in iwl_mvm_set_sta_key()
3876 if (vif->type != NL80211_IFTYPE_AP || in iwl_mvm_set_sta_key()
3877 keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE) { in iwl_mvm_set_sta_key()
3882 return -EINVAL; in iwl_mvm_set_sta_key()
3884 sta_id = mvm_sta->deflink.sta_id; in iwl_mvm_set_sta_key()
3893 mvm->fw_id_to_mac_id[sta_id], in iwl_mvm_set_sta_key()
3894 lockdep_is_held(&mvm->mutex)); in iwl_mvm_set_sta_key()
3897 return -EINVAL; in iwl_mvm_set_sta_key()
3901 if (WARN_ON_ONCE(iwl_mvm_sta_from_mac80211(sta)->vif != vif)) in iwl_mvm_set_sta_key()
3902 return -EINVAL; in iwl_mvm_set_sta_key()
3906 sta_id = mvmvif->deflink.mcast_sta.sta_id; in iwl_mvm_set_sta_key()
3909 if (keyconf->cipher == WLAN_CIPHER_SUITE_AES_CMAC || in iwl_mvm_set_sta_key()
3910 keyconf->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 || in iwl_mvm_set_sta_key()
3911 keyconf->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256) { in iwl_mvm_set_sta_key()
3916 /* If the key_offset is not pre-assigned, we need to find a in iwl_mvm_set_sta_key()
3918 * pre-assigned, but during HW_RESTART we want to reuse the in iwl_mvm_set_sta_key()
3930 return -ENOSPC; in iwl_mvm_set_sta_key()
3931 keyconf->hw_key_idx = key_offset; in iwl_mvm_set_sta_key()
3944 if ((keyconf->cipher == WLAN_CIPHER_SUITE_WEP40 || in iwl_mvm_set_sta_key()
3945 keyconf->cipher == WLAN_CIPHER_SUITE_WEP104) && in iwl_mvm_set_sta_key()
3955 __set_bit(key_offset, mvm->fw_key_table); in iwl_mvm_set_sta_key()
3959 keyconf->cipher, keyconf->keylen, keyconf->keyidx, in iwl_mvm_set_sta_key()
3960 sta ? sta->addr : zero_addr, ret); in iwl_mvm_set_sta_key()
3969 bool mcast = !(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE); in iwl_mvm_remove_sta_key()
3974 lockdep_assert_held(&mvm->mutex); in iwl_mvm_remove_sta_key()
3979 sta_id = mvm_sta->deflink.sta_id; in iwl_mvm_remove_sta_key()
3980 else if (!sta && vif->type == NL80211_IFTYPE_AP && mcast) in iwl_mvm_remove_sta_key()
3981 sta_id = iwl_mvm_vif_from_mac80211(vif)->deflink.mcast_sta.sta_id; in iwl_mvm_remove_sta_key()
3985 keyconf->keyidx, sta_id); in iwl_mvm_remove_sta_key()
3987 if (keyconf->cipher == WLAN_CIPHER_SUITE_AES_CMAC || in iwl_mvm_remove_sta_key()
3988 keyconf->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 || in iwl_mvm_remove_sta_key()
3989 keyconf->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256) in iwl_mvm_remove_sta_key()
3992 if (!__test_and_clear_bit(keyconf->hw_key_idx, mvm->fw_key_table)) { in iwl_mvm_remove_sta_key()
3994 keyconf->hw_key_idx); in iwl_mvm_remove_sta_key()
3995 return -ENOENT; in iwl_mvm_remove_sta_key()
4000 if (mvm->fw_key_deleted[i] < U8_MAX) in iwl_mvm_remove_sta_key()
4001 mvm->fw_key_deleted[i]++; in iwl_mvm_remove_sta_key()
4003 mvm->fw_key_deleted[keyconf->hw_key_idx] = 0; in iwl_mvm_remove_sta_key()
4006 IWL_DEBUG_WEP(mvm, "station non-existent, early return.\n"); in iwl_mvm_remove_sta_key()
4015 if (keyconf->cipher == WLAN_CIPHER_SUITE_WEP40 || in iwl_mvm_remove_sta_key()
4016 keyconf->cipher == WLAN_CIPHER_SUITE_WEP104) in iwl_mvm_remove_sta_key()
4029 bool mcast = !(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE); in iwl_mvm_update_tkip_key()
4030 bool mfp = sta ? sta->mfp : false; in iwl_mvm_update_tkip_key()
4037 iwl_mvm_send_sta_key(mvm, mvm_sta->deflink.sta_id, keyconf, mcast, in iwl_mvm_update_tkip_key()
4038 iv32, phase1key, CMD_ASYNC, keyconf->hw_key_idx, in iwl_mvm_update_tkip_key()
4051 .sta_id = mvmsta->deflink.sta_id, in iwl_mvm_sta_modify_ps_wake()
4053 .mac_id_n_color = cpu_to_le32(mvmsta->mac_id_n_color), in iwl_mvm_sta_modify_ps_wake()
4072 .sta_id = mvmsta->deflink.sta_id, in iwl_mvm_sta_modify_sleep_tx_count()
4075 .mac_id_n_color = cpu_to_le32(mvmsta->mac_id_n_color), in iwl_mvm_sta_modify_sleep_tx_count()
4080 /* convert TIDs to ACs - we don't support TSPEC so that's OK in iwl_mvm_sta_modify_sleep_tx_count()
4089 * - more frames than the service period, in which case more_data in iwl_mvm_sta_modify_sleep_tx_count()
4091 * - fewer than 'cnt' frames, in which case we need to adjust the in iwl_mvm_sta_modify_sleep_tx_count()
4098 spin_lock_bh(&mvmsta->lock); in iwl_mvm_sta_modify_sleep_tx_count()
4103 tid_data = &mvmsta->tid_data[tid]; in iwl_mvm_sta_modify_sleep_tx_count()
4111 remaining -= n_queued; in iwl_mvm_sta_modify_sleep_tx_count()
4113 sleep_tx_count = cnt - remaining; in iwl_mvm_sta_modify_sleep_tx_count()
4115 mvmsta->sleep_tx_count = sleep_tx_count; in iwl_mvm_sta_modify_sleep_tx_count()
4116 spin_unlock_bh(&mvmsta->lock); in iwl_mvm_sta_modify_sleep_tx_count()
4119 if (WARN_ON(cnt - remaining == 0)) { in iwl_mvm_sta_modify_sleep_tx_count()
4130 mvmsta->next_status_eosp = true; in iwl_mvm_sta_modify_sleep_tx_count()
4148 struct iwl_mvm_eosp_notification *notif = (void *)pkt->data; in iwl_mvm_rx_eosp_notif()
4150 u32 sta_id = le32_to_cpu(notif->sta_id); in iwl_mvm_rx_eosp_notif()
4152 if (WARN_ON_ONCE(sta_id >= mvm->fw->ucode_capa.num_stations)) in iwl_mvm_rx_eosp_notif()
4156 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); in iwl_mvm_rx_eosp_notif()
4168 .sta_id = mvmsta->deflink.sta_id, in iwl_mvm_sta_modify_disable_tx()
4171 .mac_id_n_color = cpu_to_le32(mvmsta->mac_id_n_color), in iwl_mvm_sta_modify_disable_tx()
4175 if (mvm->mld_api_is_used) { in iwl_mvm_sta_modify_disable_tx()
4193 if (mvm->mld_api_is_used) { in iwl_mvm_sta_modify_disable_tx_ap()
4199 spin_lock_bh(&mvm_sta->lock); in iwl_mvm_sta_modify_disable_tx_ap()
4201 if (mvm_sta->disable_tx == disable) { in iwl_mvm_sta_modify_disable_tx_ap()
4202 spin_unlock_bh(&mvm_sta->lock); in iwl_mvm_sta_modify_disable_tx_ap()
4206 mvm_sta->disable_tx = disable; in iwl_mvm_sta_modify_disable_tx_ap()
4212 if (!ieee80211_hw_check(mvm->hw, AP_LINK_PS)) in iwl_mvm_sta_modify_disable_tx_ap()
4213 ieee80211_sta_block_awake(mvm->hw, sta, disable); in iwl_mvm_sta_modify_disable_tx_ap()
4217 spin_unlock_bh(&mvm_sta->lock); in iwl_mvm_sta_modify_disable_tx_ap()
4225 u32 id = FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color); in iwl_mvm_int_sta_modify_disable_tx()
4228 .sta_id = sta->sta_id, in iwl_mvm_int_sta_modify_disable_tx()
4249 if (mvm->mld_api_is_used) { in iwl_mvm_modify_all_sta_disable_tx()
4259 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) { in iwl_mvm_modify_all_sta_disable_tx()
4260 sta = rcu_dereference(mvm->fw_id_to_mac_id[i]); in iwl_mvm_modify_all_sta_disable_tx()
4265 if (mvm_sta->mac_id_n_color != in iwl_mvm_modify_all_sta_disable_tx()
4266 FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color)) in iwl_mvm_modify_all_sta_disable_tx()
4274 if (!fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) in iwl_mvm_modify_all_sta_disable_tx()
4278 if (mvmvif->deflink.mcast_sta.sta_id != IWL_INVALID_STA) in iwl_mvm_modify_all_sta_disable_tx()
4280 &mvmvif->deflink.mcast_sta, in iwl_mvm_modify_all_sta_disable_tx()
4287 if (!disable && mvmvif->deflink.bcast_sta.sta_id != IWL_INVALID_STA) in iwl_mvm_modify_all_sta_disable_tx()
4289 &mvmvif->deflink.bcast_sta, in iwl_mvm_modify_all_sta_disable_tx()
4300 mvmsta = iwl_mvm_sta_from_staid_rcu(mvm, mvmvif->deflink.ap_sta_id); in iwl_mvm_csa_client_absent()
4310 u16 sn = IEEE80211_SEQ_TO_SN(tid_data->seq_number); in iwl_mvm_tid_queued()
4316 if (mvm->trans->mac_cfg->gen2) in iwl_mvm_tid_queued()
4319 return ieee80211_sn_sub(sn, tid_data->next_reclaimed); in iwl_mvm_tid_queued()
4344 rcu_dereference(mvmvif->mvm->fw_id_to_link_sta[fw_sta_id]); in iwl_mvm_fw_sta_id_to_fw_link_id()
4348 return -EINVAL; in iwl_mvm_fw_sta_id_to_fw_link_id()
4350 link = mvmvif->link[link_sta->link_id]; in iwl_mvm_fw_sta_id_to_fw_link_id()
4353 return -EINVAL; in iwl_mvm_fw_sta_id_to_fw_link_id()
4355 return link->fw_link_id; in iwl_mvm_fw_sta_id_to_fw_link_id()
4363 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(mvm_sta->vif); in iwl_mvm_count_mpdu()
4364 struct iwl_mvm *mvm = mvmvif->mvm; in iwl_mvm_count_mpdu()
4371 if (!mvm_sta->mpdu_counters) in iwl_mvm_count_mpdu()
4379 queue_counter = &mvm_sta->mpdu_counters[queue]; in iwl_mvm_count_mpdu()
4380 link_counter = &queue_counter->per_link[fw_link_id]; in iwl_mvm_count_mpdu()
4382 spin_lock_bh(&queue_counter->lock); in iwl_mvm_count_mpdu()
4385 link_counter->tx += count; in iwl_mvm_count_mpdu()
4387 link_counter->rx += count; in iwl_mvm_count_mpdu()
4391 * handled during counting, when in EMLSR - in the statistics flow in iwl_mvm_count_mpdu()
4393 if (mvmvif->esr_active) in iwl_mvm_count_mpdu()
4396 if (time_is_before_jiffies(queue_counter->window_start + in iwl_mvm_count_mpdu()
4398 memset(queue_counter->per_link, 0, in iwl_mvm_count_mpdu()
4399 sizeof(queue_counter->per_link)); in iwl_mvm_count_mpdu()
4400 queue_counter->window_start = jiffies; in iwl_mvm_count_mpdu()
4406 total_mpdus += tx ? queue_counter->per_link[i].tx : in iwl_mvm_count_mpdu()
4407 queue_counter->per_link[i].rx; in iwl_mvm_count_mpdu()
4410 wiphy_work_queue(mvmvif->mvm->hw->wiphy, in iwl_mvm_count_mpdu()
4411 &mvmvif->unblock_esr_tpt_wk); in iwl_mvm_count_mpdu()
4414 spin_unlock_bh(&queue_counter->lock); in iwl_mvm_count_mpdu()