/* d0i3/d3 assumes the AP's sta_id (of sta vif) is 0. reserve it. */ if (iftype != NL80211_IFTYPE_STATION)
reserved_ids = BIT(0);
/* Don't take rcu_read_lock() since we are protected by mvm->mutex */ for (sta_id = 0; sta_id < mvm->fw->ucode_capa.num_stations; sta_id++) { if (BIT(sta_id) & reserved_ids) continue;
if (!rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
lockdep_is_held(&mvm->mutex))) return sta_id;
} return IWL_INVALID_STA;
}
/* Calculate the ampdu density and max size */
u32 iwl_mvm_get_sta_ampdu_dens(struct ieee80211_link_sta *link_sta, struct ieee80211_bss_conf *link_conf,
u32 *_agg_size)
{
u32 agg_size = 0, mpdu_dens = 0;
if (WARN_ON(!link_sta)) return0;
/* Note that we always use only legacy & highest supported PPDUs, so *ofDraftP802.11beD.30Table10-12a--Fieldsusedforcalculating *themaximumA-MPDUsizeofvariousPPDUtypesindifferentbands, *weonlyneedtoworryaboutthehighestsupportedPPDUtypehere.
*/
if (link_sta->ht_cap.ht_supported) {
agg_size = link_sta->ht_cap.ampdu_factor;
mpdu_dens = link_sta->ht_cap.ampdu_density;
}
if (link_conf->chanreq.oper.chan->band == NL80211_BAND_6GHZ) { /* overwrite HT values on 6 GHz */
mpdu_dens = le16_get_bits(link_sta->he_6ghz_capa.capa,
IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START);
agg_size = le16_get_bits(link_sta->he_6ghz_capa.capa,
IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP);
} elseif (link_sta->vht_cap.vht_supported) { /* if VHT supported overwrite HT value */
agg_size = u32_get_bits(link_sta->vht_cap.cap,
IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
}
/* Disable aggregations for a bitmap of TIDs for a given station */ staticint iwl_mvm_invalidate_sta_queue(struct iwl_mvm *mvm, int queue, unsignedlong disable_agg_tids, bool remove_queue)
{ struct iwl_mvm_add_sta_cmd cmd = {}; struct ieee80211_sta *sta; struct iwl_mvm_sta *mvmsta;
u32 status;
u8 sta_id;
if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) return -EINVAL;
sta_id = mvm->queue_info[queue].ra_sta_id;
rcu_read_lock();
sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
if (WARN_ON_ONCE(IS_ERR_OR_NULL(sta))) {
rcu_read_unlock(); return -EINVAL;
}
/* Notify FW of queue removal from the STA queues */
status = ADD_STA_SUCCESS; return iwl_mvm_send_cmd_pdu_status(mvm, ADD_STA,
iwl_mvm_add_sta_cmd_size(mvm),
&cmd, &status);
}
/* Make sure queue info is correct even though we overwrite it */
WARN(mvm->queue_info[queue].tid_bitmap, "TXQ #%d info out-of-sync - tids=0x%x\n",
queue, mvm->queue_info[queue].tid_bitmap);
/* If we are here - the queue is freed and we can zero out these vals */
mvm->queue_info[queue].tid_bitmap = 0;
if (sta) { struct iwl_mvm_txq *mvmtxq =
iwl_mvm_txq_from_tid(sta, tid);
/* See what ACs the existing queues for this STA have */
for_each_set_bit(i, &tfd_queue_mask, IWL_MVM_DQA_MAX_DATA_QUEUE) { /* Only DATA queues can be shared */ if (i < IWL_MVM_DQA_MIN_DATA_QUEUE &&
i != IWL_MVM_DQA_BSS_CLIENT_QUEUE) continue;
/* Priority 1: An AC_BE queue */ if (ac_to_queue[IEEE80211_AC_BE] != IEEE80211_INVAL_HW_QUEUE)
queue = ac_to_queue[IEEE80211_AC_BE]; /* Priority 2: Same AC queue */ elseif (ac_to_queue[ac] != IEEE80211_INVAL_HW_QUEUE)
queue = ac_to_queue[ac]; /* Priority 3a: If new AC is VO and VI exists - use VI */ elseif (ac == IEEE80211_AC_VO &&
ac_to_queue[IEEE80211_AC_VI] != IEEE80211_INVAL_HW_QUEUE)
queue = ac_to_queue[IEEE80211_AC_VI]; /* Priority 3b: No BE so only AC less than the new one is BK */ elseif (ac_to_queue[IEEE80211_AC_BK] != IEEE80211_INVAL_HW_QUEUE)
queue = ac_to_queue[IEEE80211_AC_BK]; /* Priority 4a: No BE nor BK - use VI if exists */ elseif (ac_to_queue[IEEE80211_AC_VI] != IEEE80211_INVAL_HW_QUEUE)
queue = ac_to_queue[IEEE80211_AC_VI]; /* Priority 4b: No BE, BK nor VI - use VO if exists */ elseif (ac_to_queue[IEEE80211_AC_VO] != IEEE80211_INVAL_HW_QUEUE)
queue = ac_to_queue[IEEE80211_AC_VO];
/* Make sure queue found (or not) is legal */ if (!iwl_mvm_is_dqa_data_queue(mvm, queue) &&
!iwl_mvm_is_dqa_mgmt_queue(mvm, queue) &&
(queue != IWL_MVM_DQA_BSS_CLIENT_QUEUE)) {
IWL_ERR(mvm, "No DATA queues available to share\n"); return -ENOSPC;
}
return queue;
}
/* Re-configure the SCD for a queue that has already been configured */ staticint iwl_mvm_reconfig_scd(struct iwl_mvm *mvm, int queue, int fifo, int sta_id, int tid, int frame_limit, u16 ssn)
{ struct iwl_scd_txq_cfg_cmd cmd = {
.scd_queue = queue,
.action = SCD_CFG_ENABLE_QUEUE,
.window = frame_limit,
.sta_id = sta_id,
.ssn = cpu_to_le16(ssn),
.tx_fifo = fifo,
.aggregate = (queue >= IWL_MVM_DQA_MIN_DATA_QUEUE ||
queue == IWL_MVM_DQA_BSS_CLIENT_QUEUE),
.tid = tid,
}; int ret;
if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) return -EINVAL;
if (WARN(mvm->queue_info[queue].tid_bitmap == 0, "Trying to reconfig unallocated queue %d\n", queue)) return -ENXIO;
IWL_DEBUG_TX_QUEUES(mvm, "Reconfig SCD for TXQ #%d\n", queue);
ret = iwl_mvm_send_cmd_pdu(mvm, SCD_QUEUE_CFG, 0, sizeof(cmd), &cmd);
WARN_ONCE(ret, "Failed to re-configure queue %d on FIFO %d, ret=%d\n",
queue, fifo, ret);
return ret;
}
/* *IfagivenqueuehasahigherACthantheTIDstreamthatisbeingcompared *to,thequeueneedstoberedirectedtothelowerAC.Thisfunctiondoesthat *insuchacase,otherwise-ifnoredirectionrequired-itdoesnothing, *unlessthe%forceparamistrue.
*/ staticint iwl_mvm_redirect_queue(struct iwl_mvm *mvm, int queue, int tid, int ac, int ssn, unsignedint wdg_timeout, bool force, struct iwl_mvm_txq *txq)
{ struct iwl_scd_txq_cfg_cmd cmd = {
.scd_queue = queue,
.action = SCD_CFG_DISABLE_QUEUE,
}; bool shared_queue; int ret;
if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) return -EINVAL;
/* *IftheACislowerthancurrentone-FIFOneedstoberedirectedto *thelowestoneofthestreamsinthequeue.Checkifthisisneeded *here. *Noticethattheenumieee80211_ac_numbersis"flipped",soBKiswith *value3andVOwithvalue0,sotocheckifacXislowerthanacY *weneedtocheckifthenumericalvalueofXisLARGERthanofY.
*/ if (ac <= mvm->queue_info[queue].mac80211_ac && !force) {
IWL_DEBUG_TX_QUEUES(mvm, "No redirection needed on TXQ #%d\n",
queue); return0;
}
IWL_DEBUG_TX_QUEUES(mvm, "Redirecting TXQ #%d to FIFO #%d\n",
queue, iwl_mvm_ac_to_tx_fifo[ac]);
/* Stop the queue and wait for it to empty */
set_bit(IWL_MVM_TXQ_STATE_STOP_REDIRECT, &txq->state);
ret = iwl_trans_wait_tx_queues_empty(mvm->trans, BIT(queue)); if (ret) {
IWL_ERR(mvm, "Error draining queue %d before reconfig\n",
queue);
ret = -EIO; goto out;
}
/* Before redirecting the queue we need to de-activate it */
iwl_trans_txq_disable(mvm->trans, queue, false);
ret = iwl_mvm_send_cmd_pdu(mvm, SCD_QUEUE_CFG, 0, sizeof(cmd), &cmd); if (ret)
IWL_ERR(mvm, "Failed SCD disable TXQ %d (ret=%d)\n", queue,
ret);
/* Make sure the SCD wrptr is correctly set before reconfiguring */
iwl_trans_txq_enable_cfg(mvm->trans, queue, ssn, NULL, wdg_timeout);
/* Update the TID "owner" of the queue */
mvm->queue_info[queue].txq_tid = tid;
/* TODO: Work-around SCD bug when moving back by multiples of 0x40 */
/* Redirect to lower AC */
iwl_mvm_reconfig_scd(mvm, queue, iwl_mvm_ac_to_tx_fifo[ac],
cmd.sta_id, tid, IWL_FRAME_LIMIT, ssn);
/* Update AC marking of the queue */
mvm->queue_info[queue].mac80211_ac = ac;
/* This should not be hit with new TX path */ if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) return -ENOSPC;
/* Start by looking for a free queue */ for (i = minq; i <= maxq; i++) if (mvm->queue_info[i].tid_bitmap == 0 &&
mvm->queue_info[i].status == IWL_MVM_QUEUE_FREE) return i;
IWL_DEBUG_TX_QUEUES(mvm, "Allocating queue for sta %d on tid %d\n",
mvmsta->deflink.sta_id, tid);
queue = iwl_mvm_tvqm_enable_txq(mvm, sta, mvmsta->deflink.sta_id,
tid, wdg_timeout); if (queue < 0) return queue;
/* Make sure this TID isn't already enabled */ if (mvm->queue_info[queue].tid_bitmap & BIT(tid)) {
IWL_ERR(mvm, "Trying to enable TXQ %d with existing TID %d\n",
queue, tid); returnfalse;
}
/* Update mappings and refcounts */ if (mvm->queue_info[queue].tid_bitmap)
enable_queue = false;
WARN(iwl_mvm_send_cmd_pdu(mvm, SCD_QUEUE_CFG, 0, sizeof(cmd), &cmd), "Failed to configure queue %d on FIFO %d\n", queue, cfg->fifo);
return inc_ssn;
}
staticvoid iwl_mvm_change_queue_tid(struct iwl_mvm *mvm, int queue)
{ struct iwl_scd_txq_cfg_cmd cmd = {
.scd_queue = queue,
.action = SCD_CFG_UPDATE_QUEUE_TID,
}; int tid; unsignedlong tid_bitmap; int ret;
lockdep_assert_held(&mvm->mutex);
if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) return;
tid_bitmap = mvm->queue_info[queue].tid_bitmap;
if (WARN(!tid_bitmap, "TXQ %d has no tids assigned to it\n", queue)) return;
/* Find any TID for queue */
tid = find_first_bit(&tid_bitmap, IWL_MAX_TID_COUNT + 1);
cmd.tid = tid;
cmd.tx_fifo = iwl_mvm_ac_to_tx_fifo[tid_to_mac80211_ac[tid]];
ret = iwl_mvm_send_cmd_pdu(mvm, SCD_QUEUE_CFG, 0, sizeof(cmd), &cmd); if (ret) {
IWL_ERR(mvm, "Failed to update owner of TXQ %d (ret=%d)\n",
queue, ret); return;
}
mvm->queue_info[queue].txq_tid = tid;
IWL_DEBUG_TX_QUEUES(mvm, "Changed TXQ %d ownership to tid %d\n",
queue, tid);
}
staticvoid iwl_mvm_unshare_queue(struct iwl_mvm *mvm, int queue)
{ struct ieee80211_sta *sta; struct iwl_mvm_sta *mvmsta;
u8 sta_id; int tid = -1; unsignedlong tid_bitmap; unsignedint wdg_timeout; int ssn; int ret = true;
/* queue sharing is disabled on new TX path */ if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) return;
/* Find TID for queue, and make sure it is the only one on the queue */
tid = find_first_bit(&tid_bitmap, IWL_MAX_TID_COUNT + 1); if (tid_bitmap != BIT(tid)) {
IWL_ERR(mvm, "Failed to unshare q %d, active tids=0x%lx\n",
queue, tid_bitmap); return;
}
IWL_DEBUG_TX_QUEUES(mvm, "Unsharing TXQ %d, keeping tid %d\n", queue,
tid);
sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
lockdep_is_held(&mvm->mutex));
ret = iwl_mvm_send_cmd_pdu(mvm, ADD_STA, CMD_ASYNC,
iwl_mvm_add_sta_cmd_size(mvm), &cmd); if (!ret) {
IWL_DEBUG_TX_QUEUES(mvm, "TXQ #%d is now aggregated again\n",
queue);
/* Mark queue intenally as aggregating again */
iwl_trans_txq_set_shared_mode(mvm->trans, queue, false);
}
}
if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) returnfalse;
/* Go over all non-active TIDs, incl. IWL_MAX_TID_COUNT (for mgmt) */
for_each_set_bit(tid, &tid_bitmap, IWL_MAX_TID_COUNT + 1) { /* If some TFDs are still queued - don't mark TID as inactive */ if (iwl_mvm_tid_queued(mvm, &mvmsta->tid_data[tid]))
tid_bitmap &= ~BIT(tid);
/* Don't mark as inactive any TID that has an active BA */ if (mvmsta->tid_data[tid].state != IWL_AGG_OFF)
tid_bitmap &= ~BIT(tid);
}
/* If all TIDs in the queue are inactive - return it can be reused */ if (tid_bitmap == mvm->queue_info[queue].tid_bitmap) {
IWL_DEBUG_TX_QUEUES(mvm, "Queue %d is inactive\n", queue); returntrue;
}
/* If the queue is marked as shared - "unshare" it */ if (hweight16(mvm->queue_info[queue].tid_bitmap) == 1 &&
mvm->queue_info[queue].status == IWL_MVM_QUEUE_SHARED) {
IWL_DEBUG_TX_QUEUES(mvm, "Marking Q:%d for reconfig\n",
queue);
set_bit(queue, unshare_queues);
}
/* we skip the CMD queue below by starting at 1 */
BUILD_BUG_ON(IWL_MVM_DQA_CMD_QUEUE != 0);
for (i = 1; i < IWL_MAX_HW_QUEUES; i++) { struct ieee80211_sta *sta; struct iwl_mvm_sta *mvmsta;
u8 sta_id; int tid; unsignedlong inactive_tid_bitmap = 0; unsignedlong queue_tid_bitmap;
queue_tid_bitmap = mvm->queue_info[i].tid_bitmap; if (!queue_tid_bitmap) continue;
/* If TXQ isn't in active use anyway - nothing to do here... */ if (mvm->queue_info[i].status != IWL_MVM_QUEUE_READY &&
mvm->queue_info[i].status != IWL_MVM_QUEUE_SHARED) continue;
/* Check to see if there are inactive TIDs on this queue */
for_each_set_bit(tid, &queue_tid_bitmap,
IWL_MAX_TID_COUNT + 1) { if (time_after(mvm->queue_info[i].last_frame_time[tid] +
IWL_MVM_DQA_QUEUE_TIMEOUT, now)) continue;
inactive_tid_bitmap |= BIT(tid);
}
/* If all TIDs are active - finish check on this queue */ if (!inactive_tid_bitmap) continue;
sta_id = mvm->queue_info[i].ra_sta_id;
sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
/* *IftheSTAdoesn'texistanymore,itisn'tanerror.Itcould *bethatitwasremovedsincegettingthequeues,andinthis *caseitshould'veinactivateditsqueuesanyway.
*/ if (IS_ERR_OR_NULL(sta)) continue;
mvmsta = iwl_mvm_sta_from_mac80211(sta);
spin_lock_bh(&mvmsta->lock);
ret = iwl_mvm_remove_inactive_tids(mvm, mvmsta, i,
inactive_tid_bitmap,
&unshare_queues,
&changetid_queues); if (ret && free_queue < 0) {
queue_owner = sta;
free_queue = i;
} /* only unlock sta lock - we still need the queue info lock */
spin_unlock_bh(&mvmsta->lock);
}
/* This shouldn't happen - out of queues */ if (WARN_ON(queue <= 0)) {
IWL_ERR(mvm, "No available queues for tid %d on sta_id %d\n",
tid, cfg.sta_id); return queue;
}
if (mvmsta->reserved_queue == queue)
mvmsta->reserved_queue = IEEE80211_INVAL_HW_QUEUE;
spin_unlock_bh(&mvmsta->lock);
if (!shared_queue) {
ret = iwl_mvm_sta_send_to_fw(mvm, sta, true, STA_MODIFY_QUEUES); if (ret) goto out_err;
/* If we need to re-enable aggregations... */ if (queue_state == IWL_AGG_ON) {
ret = iwl_mvm_sta_tx_agg(mvm, sta, tid, queue, true); if (ret) goto out_err;
}
} else { /* Redirect queue, if needed */
ret = iwl_mvm_redirect_queue(mvm, queue, tid, ac, ssn,
wdg_timeout, false,
iwl_mvm_txq_from_tid(sta, tid)); if (ret) goto out_err;
}
/* will reschedule to run after restart */ if (test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status) ||
test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) return;
/* queue reserving is disabled on new TX path */ if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) return0;
/* run the general cleanup/unsharing of queues */
iwl_mvm_inactivity_check(mvm, IWL_INVALID_STA);
/* Make sure we have free resources for this STA */ if (vif_type == NL80211_IFTYPE_STATION && !sta->tdls &&
!mvm->queue_info[IWL_MVM_DQA_BSS_CLIENT_QUEUE].tid_bitmap &&
(mvm->queue_info[IWL_MVM_DQA_BSS_CLIENT_QUEUE].status ==
IWL_MVM_QUEUE_FREE))
queue = IWL_MVM_DQA_BSS_CLIENT_QUEUE; else
queue = iwl_mvm_find_free_queue(mvm, mvmsta->deflink.sta_id,
IWL_MVM_DQA_MIN_DATA_QUEUE,
IWL_MVM_DQA_MAX_DATA_QUEUE); if (queue < 0) { /* try again - this time kick out a queue if needed */
queue = iwl_mvm_inactivity_check(mvm, mvmsta->deflink.sta_id); if (queue < 0) {
IWL_ERR(mvm, "No available queues for new station\n"); return -ENOSPC;
}
}
mvm->queue_info[queue].status = IWL_MVM_QUEUE_RESERVED;
mvmsta->reserved_queue = queue;
IWL_DEBUG_TX_QUEUES(mvm, "Reserving data queue #%d for sta_id %d\n",
queue, mvmsta->deflink.sta_id);
/* Make sure reserved queue is still marked as such (if allocated) */ if (mvm_sta->reserved_queue != IEEE80211_INVAL_HW_QUEUE)
mvm->queue_info[mvm_sta->reserved_queue].status =
IWL_MVM_QUEUE_RESERVED;
for (i = 0; i <= IWL_MAX_TID_COUNT; i++) { struct iwl_mvm_tid_data *tid_data = &mvm_sta->tid_data[i]; int txq_id = tid_data->txq_id; int ac;
if (txq_id == IWL_MVM_INVALID_QUEUE) continue;
ac = tid_to_mac80211_ac[i];
if (iwl_mvm_has_new_tx_api(mvm)) {
IWL_DEBUG_TX_QUEUES(mvm, "Re-mapping sta %d tid %d\n",
mvm_sta->deflink.sta_id, i);
txq_id = iwl_mvm_tvqm_enable_txq(mvm, sta,
mvm_sta->deflink.sta_id,
i, wdg); /* *onfailures,justsetittoIWL_MVM_INVALID_QUEUE *totryagainlater,wehavenoothergoodwayof *failinghere
*/ if (txq_id < 0)
txq_id = IWL_MVM_INVALID_QUEUE;
tid_data->txq_id = txq_id;
if (fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE))
cmd.station_type = sta->type;
if (!iwl_mvm_has_new_tx_api(mvm))
cmd.tfd_queue_msk = cpu_to_le32(sta->tfd_queue_msk);
cmd.tid_disable_tx = cpu_to_le16(0xffff);
if (addr)
memcpy(cmd.addr, addr, ETH_ALEN);
ret = iwl_mvm_send_cmd_pdu_status(mvm, ADD_STA,
iwl_mvm_add_sta_cmd_size(mvm),
&cmd, &status); if (ret) return ret;
switch (status & IWL_ADD_STA_STATUS_MASK) { case ADD_STA_SUCCESS:
IWL_DEBUG_INFO(mvm, "Internal station added.\n"); return0; default:
ret = -EIO;
IWL_ERR(mvm, "Add internal station failed, status=0x%x\n",
status); break;
} return ret;
}
/* Initialize driver data of a new sta */ int iwl_mvm_sta_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif, struct ieee80211_sta *sta, int sta_id, u8 sta_type)
{ struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); struct iwl_mvm_rxq_dup_data *dup_data; int i, ret = 0;
/* for MLD sta_id(s) should be allocated for each link before calling *thisfunction
*/ if (!mvm->mld_api_is_used) { if (WARN_ON(sta_id == IWL_INVALID_STA)) return -EINVAL;
if (!iwl_mvm_has_new_tx_api(mvm)) {
ret = iwl_mvm_reserve_sta_stream(mvm, sta,
ieee80211_vif_type_p2p(vif)); if (ret) return ret;
}
/* *ifrsisregisteredwithmac80211,then"addstation"willbehandled *viathecorrespondingops,otherwiseneedtonotifyratescalinghere
*/ if (iwl_mvm_has_tlc_offload(mvm))
iwl_mvm_rs_add_sta(mvm, mvm_sta); else
spin_lock_init(&mvm_sta->deflink.lq_sta.rs_drv.pers.lock);
iwl_mvm_toggle_tx_ant(mvm, &mvm_sta->tx_ant);
/* MPDUs are counted only when EMLSR is possible */ if (vif->type == NL80211_IFTYPE_STATION && !vif->p2p &&
!sta->tdls && ieee80211_vif_is_mld(vif)) {
mvm_sta->mpdu_counters =
kcalloc(mvm->trans->info.num_rxqs, sizeof(*mvm_sta->mpdu_counters),
GFP_KERNEL); if (mvm_sta->mpdu_counters) for (int q = 0; q < mvm->trans->info.num_rxqs; q++)
spin_lock_init(&mvm_sta->mpdu_counters[q].lock);
}
/* if this is a HW restart re-alloc existing queues */ if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) { struct iwl_mvm_int_sta tmp_sta = {
.sta_id = sta_id,
.type = mvm_sta->sta_type,
};
/* First add an empty station since allocating *aqueuerequiresavalidstation
*/
ret = iwl_mvm_add_int_sta_common(mvm, &tmp_sta, sta->addr,
mvmvif->id, mvmvif->color); if (ret) goto err;
int iwl_mvm_rm_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif, struct ieee80211_sta *sta)
{ struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); int ret;
lockdep_assert_held(&mvm->mutex);
ret = iwl_mvm_drain_sta(mvm, mvm_sta, true); if (ret) return ret;
/* flush its queues here since we are freeing mvm_sta */
ret = iwl_mvm_flush_sta(mvm, mvm_sta->deflink.sta_id,
mvm_sta->tfd_queue_msk); if (ret) return ret; if (iwl_mvm_has_new_tx_api(mvm)) {
ret = iwl_mvm_wait_sta_queues_empty(mvm, mvm_sta);
} else {
u32 q_mask = mvm_sta->tfd_queue_msk;
ret = iwl_trans_wait_tx_queues_empty(mvm->trans,
q_mask);
} if (ret) return ret;
ret = iwl_mvm_drain_sta(mvm, mvm_sta, false);
iwl_mvm_disable_sta_queues(mvm, vif, sta);
/* If there is a TXQ still marked as reserved - free it */ if (mvm_sta->reserved_queue != IEEE80211_INVAL_HW_QUEUE) {
u8 reserved_txq = mvm_sta->reserved_queue; enum iwl_mvm_queue_status *status;
/* *IfnotraffichasgonethroughthereservedTXQ-it *isstillmarkedasIWL_MVM_QUEUE_RESERVED,and *shouldbemanuallymarkedasfreeagain
*/
status = &mvm->queue_info[reserved_txq].status; if (WARN((*status != IWL_MVM_QUEUE_RESERVED) &&
(*status != IWL_MVM_QUEUE_FREE), "sta_id %d reserved txq %d status %d",
mvm_sta->deflink.sta_id, reserved_txq, *status)) return -EINVAL;
*status = IWL_MVM_QUEUE_FREE;
}
iwl_mvm_sta_del(mvm, vif, sta, &sta->deflink);
ret = iwl_mvm_rm_sta_common(mvm, mvm_sta->deflink.sta_id);
RCU_INIT_POINTER(mvm->fw_id_to_mac_id[mvm_sta->deflink.sta_id], NULL);
return ret;
}
int iwl_mvm_rm_sta_id(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
u8 sta_id)
{ int ret = iwl_mvm_rm_sta_common(mvm, sta_id);
staticint iwl_mvm_add_int_sta_with_queue(struct iwl_mvm *mvm, int macidx, int maccolor, u8 *addr, struct iwl_mvm_int_sta *sta,
u16 *queue, int fifo)
{ int ret;
/* Map queue to fifo - needs to happen before adding station */ if (!iwl_mvm_has_new_tx_api(mvm))
iwl_mvm_enable_aux_snif_queue(mvm, *queue, sta->sta_id, fifo);
ret = iwl_mvm_add_int_sta_common(mvm, sta, addr, macidx, maccolor); if (ret) { if (!iwl_mvm_has_new_tx_api(mvm))
iwl_mvm_disable_txq(mvm, NULL, sta->sta_id, queue,
IWL_MAX_TID_COUNT); return ret;
}
/* *For22000firmwareandonwecannotaddqueuetoastationunknown *tofirmwaresoenablequeuehere-afterthestationwasadded
*/ if (iwl_mvm_has_new_tx_api(mvm)) { int txq;
int iwl_mvm_add_aux_sta(struct iwl_mvm *mvm, u32 lmac_id)
{ int ret;
u32 qmask = mvm->aux_queue == IWL_MVM_INVALID_QUEUE ? 0 :
BIT(mvm->aux_queue);
lockdep_assert_held(&mvm->mutex);
/* Allocate aux station and assign to it the aux queue */
ret = iwl_mvm_allocate_int_sta(mvm, &mvm->aux_sta, qmask,
NL80211_IFTYPE_UNSPECIFIED,
IWL_STA_AUX_ACTIVITY); if (ret) return ret;
/* Send the FW a request to remove the station from its internal data
* structures, but DO NOT remove the entry from the local data structures. */ int iwl_mvm_send_rm_bcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
{ struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); int ret;
lockdep_assert_held(&mvm->mutex);
iwl_mvm_free_bcast_sta_queues(mvm, vif);
ret = iwl_mvm_rm_sta_common(mvm, mvmvif->deflink.bcast_sta.sta_id); if (ret)
IWL_WARN(mvm, "Failed sending remove station\n"); return ret;
}
/* Allocate a new station entry for the broadcast station to the given vif, *andsendittotheFW. *NotethateachP2Pmacshouldhaveitsownbroadcaststation. * *@mvm:themvmcomponent *@vif:theinterfacetowhichthebroadcaststationisadded
* @bsta: the broadcast station to add. */ int iwl_mvm_add_p2p_bcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
{ struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); struct iwl_mvm_int_sta *bsta = &mvmvif->deflink.bcast_sta; int ret;
lockdep_assert_held(&mvm->mutex);
ret = iwl_mvm_alloc_bcast_sta(mvm, vif); if (ret) return ret;
status = ADD_STA_SUCCESS;
ret = iwl_mvm_send_cmd_pdu_status(mvm, ADD_STA,
iwl_mvm_add_sta_cmd_size(mvm),
&cmd, &status); if (ret) return ret;
switch (status & IWL_ADD_STA_STATUS_MASK) { case ADD_STA_SUCCESS: break; default:
ret = -EIO;
IWL_ERR(mvm, "TX BA Session failed %sing, status 0x%x\n",
start ? "start" : "stopp", status); break;
}
return ret;
}
const u8 tid_to_mac80211_ac[] = {
IEEE80211_AC_BE,
IEEE80211_AC_BK,
IEEE80211_AC_BK,
IEEE80211_AC_BE,
IEEE80211_AC_VI,
IEEE80211_AC_VI,
IEEE80211_AC_VO,
IEEE80211_AC_VO,
IEEE80211_AC_VO, /* We treat MGMT as TID 8, which is set as AC_VO */
};
if (WARN_ON_ONCE(tid >= IWL_MAX_TID_COUNT)) return -EINVAL;
if (mvmsta->tid_data[tid].state != IWL_AGG_QUEUED &&
mvmsta->tid_data[tid].state != IWL_AGG_OFF) {
IWL_ERR(mvm, "Start AGG when state is not IWL_AGG_QUEUED or IWL_AGG_OFF %d!\n",
mvmsta->tid_data[tid].state); return -ENXIO;
}
lockdep_assert_held(&mvm->mutex);
if (mvmsta->tid_data[tid].txq_id == IWL_MVM_INVALID_QUEUE &&
iwl_mvm_has_new_tx_api(mvm)) {
u8 ac = tid_to_mac80211_ac[tid];
ret = iwl_mvm_sta_alloc_queue_tvqm(mvm, sta, ac, tid); if (ret) return ret;
}
spin_lock_bh(&mvmsta->lock);
/* *Notethepossiblecases: *1.AnenabledTXQ-TXQneedstobecomeagg'ed *2.TheTXQhasn'tyetbeenenabled,sofindafreeoneandmark *itasreserved
*/
txq_id = mvmsta->tid_data[tid].txq_id; if (txq_id == IWL_MVM_INVALID_QUEUE) {
ret = iwl_mvm_find_free_queue(mvm, mvmsta->deflink.sta_id,
IWL_MVM_DQA_MIN_DATA_QUEUE,
IWL_MVM_DQA_MAX_DATA_QUEUE); if (ret < 0) {
IWL_ERR(mvm, "Failed to allocate agg queue\n"); goto out;
}
txq_id = ret;
/* TXQ hasn't yet been enabled, so mark it only as reserved */
mvm->queue_info[txq_id].status = IWL_MVM_QUEUE_RESERVED;
} elseif (WARN_ON(txq_id >= IWL_MAX_HW_QUEUES)) {
ret = -ENXIO;
IWL_ERR(mvm, "tid_id %d out of range (0, %d)!\n",
tid, IWL_MAX_HW_QUEUES - 1); goto out;
} elseif (unlikely(mvm->queue_info[txq_id].status ==
IWL_MVM_QUEUE_SHARED)) {
ret = -ENXIO;
IWL_DEBUG_TX_QUEUES(mvm, "Can't start tid %d agg on shared queue!\n",
tid); goto out;
}
IWL_DEBUG_TX_QUEUES(mvm, "AGG for tid %d will be on queue #%d\n",
tid, txq_id);
if (alloc_queue)
iwl_mvm_enable_txq(mvm, sta, queue, ssn,
&cfg, wdg_timeout);
/* Send ADD_STA command to enable aggs only if the queue isn't shared */ if (queue_status != IWL_MVM_QUEUE_SHARED) {
ret = iwl_mvm_sta_tx_agg(mvm, sta, tid, queue, true); if (ret) return -EIO;
}
/* No need to mark as reserved */
mvm->queue_info[queue].status = IWL_MVM_QUEUE_READY;
staticint iwl_mvm_set_fw_key_idx(struct iwl_mvm *mvm)
{ int i, max = -1, max_offs = -1;
lockdep_assert_held(&mvm->mutex);
/* Pick the unused key offset with the highest 'deleted' *counter.Everytimeakeyisdeleted,allthecounters *areincrementedandtheonethatwasjustdeletedis *resettozero.Thus,thehighestcounteristheone *thatwasdeletedlongestago.Pickthatone.
*/ for (i = 0; i < STA_KEY_MAX_NUM; i++) { if (test_bit(i, mvm->fw_key_table)) continue; if (mvm->fw_key_deleted[i] > max) {
max = mvm->fw_key_deleted[i];
max_offs = i;
}
}
if (key->cipher == WLAN_CIPHER_SUITE_TKIP)
i = 0; else
i = -1;
for (; i < IEEE80211_NUM_TIDS; i++) { struct ieee80211_key_seq seq = {};
u8 _rx_pn[IEEE80211_MAX_PN_LEN] = {}, *rx_pn = _rx_pn; int rx_pn_len = 8; /* there's a hole at 2/3 in FW format depending on version */ int hole = api_ver >= 3 ? 0 : 2;
if (vif->type != NL80211_IFTYPE_AP ||
keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE) { /* Get the station id from the mvm local station table */
mvm_sta = iwl_mvm_get_key_sta(mvm, vif, sta); if (!mvm_sta) {
IWL_ERR(mvm, "Failed to find station\n"); return -EINVAL;
}
sta_id = mvm_sta->deflink.sta_id;
/* *Itispossiblethatthe'sta'parameterisNULL,andthus *thereisaneedtoretrievethestafromthelocalstation *table.
*/ if (!sta) {
sta = rcu_dereference_protected(
mvm->fw_id_to_mac_id[sta_id],
lockdep_is_held(&mvm->mutex)); if (IS_ERR_OR_NULL(sta)) {
IWL_ERR(mvm, "Invalid station id\n"); return -EINVAL;
}
}
/* If the key_offset is not pre-assigned, we need to find a *newoffsettouse.Innormalcases,theoffsetisnot *pre-assigned,butduringHW_RESTARTwewanttoreusethe *sameindices,sowepassthemwhenthisfunctioniscalled. * *InD3entry,weneedtohardcodedtheindices(becausethe *firmwarehardcodesthePTKoffsetto0).Inthiscase,we *needtomakesurewedon'toverwritethehw_key_idxinthe *keyconfstructure,becauseotherwisewecannotconfigure *theoriginalonesbackwhenresuming.
*/ if (key_offset == STA_KEY_IDX_INVALID) {
key_offset = iwl_mvm_set_fw_key_idx(mvm); if (key_offset == STA_KEY_IDX_INVALID) return -ENOSPC;
keyconf->hw_key_idx = key_offset;
}
ret = __iwl_mvm_set_sta_key(mvm, vif, sta, keyconf, key_offset, mcast); if (ret) goto end;
/* Get the station from the mvm local station table */
mvm_sta = iwl_mvm_get_key_sta(mvm, vif, sta); if (mvm_sta)
sta_id = mvm_sta->deflink.sta_id; elseif (!sta && vif->type == NL80211_IFTYPE_AP && mcast)
sta_id = iwl_mvm_vif_from_mac80211(vif)->deflink.mcast_sta.sta_id;
if (!__test_and_clear_bit(keyconf->hw_key_idx, mvm->fw_key_table)) {
IWL_ERR(mvm, "offset %d not used in fw key table.\n",
keyconf->hw_key_idx); return -ENOENT;
}
/* track which key was deleted last */ for (i = 0; i < STA_KEY_MAX_NUM; i++) { if (mvm->fw_key_deleted[i] < U8_MAX)
mvm->fw_key_deleted[i]++;
}
mvm->fw_key_deleted[keyconf->hw_key_idx] = 0;
if (sta && !mvm_sta) {
IWL_DEBUG_WEP(mvm, "station non-existent, early return.\n"); return0;
}
ret = __iwl_mvm_remove_sta_key(mvm, sta_id, keyconf, mcast); if (ret) return ret;
/* delete WEP key twice to get rid of (now useless) offset */ if (keyconf->cipher == WLAN_CIPHER_SUITE_WEP40 ||
keyconf->cipher == WLAN_CIPHER_SUITE_WEP104)
ret = __iwl_mvm_remove_sta_key(mvm, sta_id, keyconf, !mcast);
/* convert TIDs to ACs - we don't support TSPEC so that's OK *Notethatthisfieldisreservedandunusedbyfirmwarenot *supportingGOuAPSD,soit'ssafetoalwaysdothis.
*/
for_each_set_bit(tid, &_tids, IWL_MAX_TID_COUNT)
cmd.awake_acs |= BIT(tid_to_ucode_ac[tid]);
/* If we're releasing frames from aggregation or dqa queues then check *ifallthequeuesthatwe'rereleasingframesfrom,combined,have: *-moreframesthantheserviceperiod,inwhichcasemore_data *needstobeset *-fewerthan'cnt'frames,inwhichcaseweneedtoadjustthe *firmwarecommand(butdothatunconditionally)
*/ if (single_sta_queue) { int remaining = cnt; int sleep_tx_count;
/* block the Tx queues until the FW updated the sleep Tx count */
ret = iwl_mvm_send_cmd_pdu(mvm, ADD_STA,
CMD_ASYNC | CMD_BLOCK_TXQS,
iwl_mvm_add_sta_cmd_size(mvm), &cmd); if (ret)
IWL_ERR(mvm, "Failed to send ADD_STA command (%d)\n", ret);
}
if (mvm->mld_api_is_used) { if (!iwl_mvm_has_no_host_disable_tx(mvm))
iwl_mvm_mld_modify_all_sta_disable_tx(mvm, mvmvif,
disable); return;
}
rcu_read_lock();
/* Block/unblock all the stations of the given mvmvif */ for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) {
sta = rcu_dereference(mvm->fw_id_to_mac_id[i]); if (IS_ERR_OR_NULL(sta)) continue;
mvm_sta = iwl_mvm_sta_from_mac80211(sta); if (mvm_sta->mac_id_n_color !=
FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color)) continue;
if (!fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) return;
/* Need to block/unblock also multicast station */ if (mvmvif->deflink.mcast_sta.sta_id != IWL_INVALID_STA)
iwl_mvm_int_sta_modify_disable_tx(mvm, mvmvif,
&mvmvif->deflink.mcast_sta,
disable);
/* *In22000HW,thenext_reclaimedindexisonly8bit,sowe'llneed *toalignthewraparoundofssnsowecomparerelevantvalues.
*/ if (mvm->trans->mac_cfg->gen2)
sn &= 0xff;
ret = iwl_mvm_send_cmd_pdu(mvm,
WIDE_ID(MAC_CONF_GROUP, CANCEL_CHANNEL_SWITCH_CMD),
CMD_ASYNC, sizeof(cancel_channel_switch_cmd),
&cancel_channel_switch_cmd); if (ret)
IWL_ERR(mvm, "Failed to cancel the channel switch\n");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.