Lines Matching +full:calib +full:- +full:sensitivity
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
9 #include "iwl-trans.h"
10 #include "iwl-modparams.h"
13 #include "calib.h"
21 memset(&ctx->staging, 0, sizeof(ctx->staging)); in iwl_connection_init_rx_config()
23 if (!ctx->vif) { in iwl_connection_init_rx_config()
24 ctx->staging.dev_type = ctx->unused_devtype; in iwl_connection_init_rx_config()
26 switch (ctx->vif->type) { in iwl_connection_init_rx_config()
28 ctx->staging.dev_type = ctx->ap_devtype; in iwl_connection_init_rx_config()
32 ctx->staging.dev_type = ctx->station_devtype; in iwl_connection_init_rx_config()
33 ctx->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; in iwl_connection_init_rx_config()
37 ctx->staging.dev_type = ctx->ibss_devtype; in iwl_connection_init_rx_config()
38 ctx->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; in iwl_connection_init_rx_config()
39 ctx->staging.filter_flags = RXON_FILTER_BCON_AWARE_MSK | in iwl_connection_init_rx_config()
44 ctx->staging.dev_type = RXON_DEV_TYPE_SNIFFER; in iwl_connection_init_rx_config()
49 ctx->vif->type); in iwl_connection_init_rx_config()
56 if (!hw_to_local(priv->hw)->short_preamble) in iwl_connection_init_rx_config()
57 ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; in iwl_connection_init_rx_config()
59 ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; in iwl_connection_init_rx_config()
62 ctx->staging.channel = in iwl_connection_init_rx_config()
63 cpu_to_le16(priv->hw->conf.chandef.chan->hw_value); in iwl_connection_init_rx_config()
64 priv->band = priv->hw->conf.chandef.chan->band; in iwl_connection_init_rx_config()
66 iwl_set_flags_for_band(priv, ctx, priv->band, ctx->vif); in iwl_connection_init_rx_config()
69 ctx->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED | in iwl_connection_init_rx_config()
71 if (ctx->vif) in iwl_connection_init_rx_config()
72 memcpy(ctx->staging.node_addr, ctx->vif->addr, ETH_ALEN); in iwl_connection_init_rx_config()
74 ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff; in iwl_connection_init_rx_config()
75 ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff; in iwl_connection_init_rx_config()
76 ctx->staging.ofdm_ht_triple_stream_basic_rates = 0xff; in iwl_connection_init_rx_config()
83 __le32 old_filter = send->filter_flags; in iwlagn_disable_bss()
86 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK; in iwlagn_disable_bss()
87 ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, in iwlagn_disable_bss()
90 send->filter_flags = old_filter; in iwlagn_disable_bss()
104 __le32 old_filter = send->filter_flags; in iwlagn_disable_pan()
105 u8 old_dev_type = send->dev_type; in iwlagn_disable_pan()
111 iwl_init_notification_wait(&priv->notif_wait, &disable_wait, in iwlagn_disable_pan()
115 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK; in iwlagn_disable_pan()
116 send->dev_type = RXON_DEV_TYPE_P2P; in iwlagn_disable_pan()
117 ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, in iwlagn_disable_pan()
120 send->filter_flags = old_filter; in iwlagn_disable_pan()
121 send->dev_type = old_dev_type; in iwlagn_disable_pan()
125 iwl_remove_notification(&priv->notif_wait, &disable_wait); in iwlagn_disable_pan()
127 ret = iwl_wait_notification(&priv->notif_wait, in iwlagn_disable_pan()
140 __le32 old_filter = send->filter_flags; in iwlagn_disconn_pan()
143 send->filter_flags &= ~RXON_FILTER_ASSOC_MSK; in iwlagn_disconn_pan()
144 ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, 0, in iwlagn_disconn_pan()
147 send->filter_flags = old_filter; in iwlagn_disconn_pan()
157 if (!ctx->is_active) in iwlagn_update_qos()
160 ctx->qos_data.def_qos_parm.qos_flags = 0; in iwlagn_update_qos()
162 if (ctx->qos_data.qos_active) in iwlagn_update_qos()
163 ctx->qos_data.def_qos_parm.qos_flags |= in iwlagn_update_qos()
166 if (ctx->ht.enabled) in iwlagn_update_qos()
167 ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; in iwlagn_update_qos()
170 ctx->qos_data.qos_active, in iwlagn_update_qos()
171 ctx->qos_data.def_qos_parm.qos_flags); in iwlagn_update_qos()
173 ret = iwl_dvm_send_cmd_pdu(priv, ctx->qos_cmd, 0, in iwlagn_update_qos()
175 &ctx->qos_data.def_qos_parm); in iwlagn_update_qos()
183 lockdep_assert_held(&priv->mutex); in iwlagn_update_beacon()
185 dev_kfree_skb(priv->beacon_skb); in iwlagn_update_beacon()
186 priv->beacon_skb = ieee80211_beacon_get(priv->hw, vif, 0); in iwlagn_update_beacon()
187 if (!priv->beacon_skb) in iwlagn_update_beacon()
188 return -ENOMEM; in iwlagn_update_beacon()
197 const struct iwl_rxon_cmd *rxon1 = &ctx->staging; in iwlagn_send_rxon_assoc()
198 const struct iwl_rxon_cmd *rxon2 = &ctx->active; in iwlagn_send_rxon_assoc()
200 if ((rxon1->flags == rxon2->flags) && in iwlagn_send_rxon_assoc()
201 (rxon1->filter_flags == rxon2->filter_flags) && in iwlagn_send_rxon_assoc()
202 (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && in iwlagn_send_rxon_assoc()
203 (rxon1->ofdm_ht_single_stream_basic_rates == in iwlagn_send_rxon_assoc()
204 rxon2->ofdm_ht_single_stream_basic_rates) && in iwlagn_send_rxon_assoc()
205 (rxon1->ofdm_ht_dual_stream_basic_rates == in iwlagn_send_rxon_assoc()
206 rxon2->ofdm_ht_dual_stream_basic_rates) && in iwlagn_send_rxon_assoc()
207 (rxon1->ofdm_ht_triple_stream_basic_rates == in iwlagn_send_rxon_assoc()
208 rxon2->ofdm_ht_triple_stream_basic_rates) && in iwlagn_send_rxon_assoc()
209 (rxon1->acquisition_data == rxon2->acquisition_data) && in iwlagn_send_rxon_assoc()
210 (rxon1->rx_chain == rxon2->rx_chain) && in iwlagn_send_rxon_assoc()
211 (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { in iwlagn_send_rxon_assoc()
216 rxon_assoc.flags = ctx->staging.flags; in iwlagn_send_rxon_assoc()
217 rxon_assoc.filter_flags = ctx->staging.filter_flags; in iwlagn_send_rxon_assoc()
218 rxon_assoc.ofdm_basic_rates = ctx->staging.ofdm_basic_rates; in iwlagn_send_rxon_assoc()
219 rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates; in iwlagn_send_rxon_assoc()
224 ctx->staging.ofdm_ht_single_stream_basic_rates; in iwlagn_send_rxon_assoc()
226 ctx->staging.ofdm_ht_dual_stream_basic_rates; in iwlagn_send_rxon_assoc()
227 rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain; in iwlagn_send_rxon_assoc()
229 ctx->staging.ofdm_ht_triple_stream_basic_rates; in iwlagn_send_rxon_assoc()
230 rxon_assoc.acquisition_data = ctx->staging.acquisition_data; in iwlagn_send_rxon_assoc()
232 ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_assoc_cmd, in iwlagn_send_rxon_assoc()
279 struct ieee80211_vif *vif = ctx->vif; in iwl_send_rxon_timing()
281 conf = &priv->hw->conf; in iwl_send_rxon_timing()
283 lockdep_assert_held(&priv->mutex); in iwl_send_rxon_timing()
285 memset(&ctx->timing, 0, sizeof(struct iwl_rxon_time_cmd)); in iwl_send_rxon_timing()
287 ctx->timing.timestamp = cpu_to_le64(priv->timestamp); in iwl_send_rxon_timing()
288 ctx->timing.listen_interval = cpu_to_le16(conf->listen_interval); in iwl_send_rxon_timing()
290 beacon_int = vif ? vif->bss_conf.beacon_int : 0; in iwl_send_rxon_timing()
296 ctx->timing.atim_window = 0; in iwl_send_rxon_timing()
298 if (ctx->ctxid == IWL_RXON_CTX_PAN && in iwl_send_rxon_timing()
299 (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION) && in iwl_send_rxon_timing()
301 priv->contexts[IWL_RXON_CTX_BSS].vif && in iwl_send_rxon_timing()
302 priv->contexts[IWL_RXON_CTX_BSS].vif->bss_conf.beacon_int) { in iwl_send_rxon_timing()
303 ctx->timing.beacon_interval = in iwl_send_rxon_timing()
304 priv->contexts[IWL_RXON_CTX_BSS].timing.beacon_interval; in iwl_send_rxon_timing()
305 beacon_int = le16_to_cpu(ctx->timing.beacon_interval); in iwl_send_rxon_timing()
306 } else if (ctx->ctxid == IWL_RXON_CTX_BSS && in iwl_send_rxon_timing()
308 priv->contexts[IWL_RXON_CTX_PAN].vif && in iwl_send_rxon_timing()
309 priv->contexts[IWL_RXON_CTX_PAN].vif->bss_conf.beacon_int && in iwl_send_rxon_timing()
310 (!iwl_is_associated_ctx(ctx) || !ctx->vif || in iwl_send_rxon_timing()
311 !ctx->vif->bss_conf.beacon_int)) { in iwl_send_rxon_timing()
312 ctx->timing.beacon_interval = in iwl_send_rxon_timing()
313 priv->contexts[IWL_RXON_CTX_PAN].timing.beacon_interval; in iwl_send_rxon_timing()
314 beacon_int = le16_to_cpu(ctx->timing.beacon_interval); in iwl_send_rxon_timing()
318 ctx->timing.beacon_interval = cpu_to_le16(beacon_int); in iwl_send_rxon_timing()
321 ctx->beacon_int = beacon_int; in iwl_send_rxon_timing()
323 tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */ in iwl_send_rxon_timing()
326 ctx->timing.beacon_init_val = cpu_to_le32(interval_tm - rem); in iwl_send_rxon_timing()
328 ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; in iwl_send_rxon_timing()
332 le16_to_cpu(ctx->timing.beacon_interval), in iwl_send_rxon_timing()
333 le32_to_cpu(ctx->timing.beacon_init_val), in iwl_send_rxon_timing()
334 le16_to_cpu(ctx->timing.atim_window)); in iwl_send_rxon_timing()
336 return iwl_dvm_send_cmd_pdu(priv, ctx->rxon_timing_cmd, in iwl_send_rxon_timing()
337 0, sizeof(ctx->timing), &ctx->timing); in iwl_send_rxon_timing()
344 struct iwl_rxon_cmd *active = (void *)&ctx->active; in iwlagn_rxon_disconn()
346 if (ctx->ctxid == IWL_RXON_CTX_BSS) { in iwlagn_rxon_disconn()
347 ret = iwlagn_disable_bss(priv, ctx, &ctx->staging); in iwlagn_rxon_disconn()
349 ret = iwlagn_disable_pan(priv, ctx, &ctx->staging); in iwlagn_rxon_disconn()
352 if (ctx->vif) { in iwlagn_rxon_disconn()
358 ret = iwlagn_disconn_pan(priv, ctx, &ctx->staging); in iwlagn_rxon_disconn()
365 * Un-assoc RXON clears the station table and WEP in iwlagn_rxon_disconn()
369 /* update -- might need P2P now */ in iwlagn_rxon_disconn()
378 memcpy(active, &ctx->staging, sizeof(*active)); in iwlagn_rxon_disconn()
387 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; in iwl_set_tx_power()
389 if (priv->calib_disabled & IWL_TX_POWER_CALIB_DISABLED) in iwl_set_tx_power()
392 lockdep_assert_held(&priv->mutex); in iwl_set_tx_power()
394 if (priv->tx_power_user_lmt == tx_power && !force) in iwl_set_tx_power()
402 return -EINVAL; in iwl_set_tx_power()
405 if (tx_power > DIV_ROUND_UP(priv->nvm_data->max_tx_pwr_half_dbm, 2)) { in iwl_set_tx_power()
408 tx_power, priv->nvm_data->max_tx_pwr_half_dbm); in iwl_set_tx_power()
409 return -EINVAL; in iwl_set_tx_power()
413 return -EIO; in iwl_set_tx_power()
417 priv->tx_power_next = tx_power; in iwl_set_tx_power()
420 defer = test_bit(STATUS_SCANNING, &priv->status) || in iwl_set_tx_power()
421 memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); in iwl_set_tx_power()
427 prev_tx_power = priv->tx_power_user_lmt; in iwl_set_tx_power()
428 priv->tx_power_user_lmt = tx_power; in iwl_set_tx_power()
434 priv->tx_power_user_lmt = prev_tx_power; in iwl_set_tx_power()
435 priv->tx_power_next = prev_tx_power; in iwl_set_tx_power()
444 struct iwl_rxon_cmd *active = (void *)&ctx->active; in iwlagn_rxon_connect()
447 if (ctx->ctxid == IWL_RXON_CTX_BSS) { in iwlagn_rxon_connect()
454 /* QoS info may be cleared by previous un-assoc RXON */ in iwlagn_rxon_connect()
462 if (ctx->vif && (ctx->vif->type == NL80211_IFTYPE_AP)) { in iwlagn_rxon_connect()
463 ret = iwlagn_update_beacon(priv, ctx->vif); in iwlagn_rxon_connect()
472 priv->start_calib = 0; in iwlagn_rxon_connect()
479 ret = iwl_dvm_send_cmd_pdu(priv, ctx->rxon_cmd, 0, in iwlagn_rxon_connect()
480 sizeof(struct iwl_rxon_cmd), &ctx->staging); in iwlagn_rxon_connect()
485 memcpy(active, &ctx->staging, sizeof(*active)); in iwlagn_rxon_connect()
488 if (ctx->vif && (ctx->vif->type == NL80211_IFTYPE_ADHOC)) in iwlagn_rxon_connect()
489 if (iwlagn_update_beacon(priv, ctx->vif)) in iwlagn_rxon_connect()
500 ret = iwl_set_tx_power(priv, priv->tx_power_next, true); in iwlagn_rxon_connect()
516 if (priv->valid_contexts == BIT(IWL_RXON_CTX_BSS)) in iwlagn_set_pan_params()
521 lockdep_assert_held(&priv->mutex); in iwlagn_set_pan_params()
523 ctx_bss = &priv->contexts[IWL_RXON_CTX_BSS]; in iwlagn_set_pan_params()
524 ctx_pan = &priv->contexts[IWL_RXON_CTX_PAN]; in iwlagn_set_pan_params()
530 * parameters be WLAN-only. in iwlagn_set_pan_params()
532 if (!ctx_pan->is_active) in iwlagn_set_pan_params()
543 if (ctx_bss->vif && ctx_pan->vif) { in iwlagn_set_pan_params()
544 int bcnint = ctx_pan->beacon_int; in iwlagn_set_pan_params()
545 int dtim = ctx_pan->vif->bss_conf.dtim_period ?: 1; in iwlagn_set_pan_params()
550 if (ctx_pan->vif->type == NL80211_IFTYPE_AP && in iwlagn_set_pan_params()
552 bcnint != ctx_bss->beacon_int) { in iwlagn_set_pan_params()
555 ctx_bss->beacon_int, ctx_pan->beacon_int); in iwlagn_set_pan_params()
558 ctx_bss->beacon_int); in iwlagn_set_pan_params()
562 slot1 = bcnint - slot0; in iwlagn_set_pan_params()
564 if (test_bit(STATUS_SCAN_HW, &priv->status) || in iwlagn_set_pan_params()
565 (!ctx_bss->vif->cfg.idle && in iwlagn_set_pan_params()
566 !ctx_bss->vif->cfg.assoc)) { in iwlagn_set_pan_params()
567 slot0 = dtim * bcnint * 3 - IWL_MIN_SLOT_TIME; in iwlagn_set_pan_params()
569 } else if (!ctx_pan->vif->cfg.idle && in iwlagn_set_pan_params()
570 !ctx_pan->vif->cfg.assoc) { in iwlagn_set_pan_params()
571 slot1 = dtim * bcnint * 3 - IWL_MIN_SLOT_TIME; in iwlagn_set_pan_params()
574 } else if (ctx_pan->vif) { in iwlagn_set_pan_params()
576 slot1 = max_t(int, 1, ctx_pan->vif->bss_conf.dtim_period) * in iwlagn_set_pan_params()
577 ctx_pan->beacon_int; in iwlagn_set_pan_params()
580 if (test_bit(STATUS_SCAN_HW, &priv->status)) { in iwlagn_set_pan_params()
581 slot0 = slot1 * 3 - IWL_MIN_SLOT_TIME; in iwlagn_set_pan_params()
601 struct iwl_rxon_cmd *rxon = &ctx->staging; in _iwl_set_rxon_ht()
603 if (!ctx->ht.enabled) { in _iwl_set_rxon_ht()
604 rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | in _iwl_set_rxon_ht()
612 * will be needed for rxon->flags in _iwl_set_rxon_ht()
614 rxon->flags |= cpu_to_le32(ctx->ht.protection << in _iwl_set_rxon_ht()
620 rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | in _iwl_set_rxon_ht()
624 if (ctx->ht.protection == in _iwl_set_rxon_ht()
626 rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40; in _iwl_set_rxon_ht()
631 switch (ctx->ht.extension_chan_offset) { in _iwl_set_rxon_ht()
633 rxon->flags &= in _iwl_set_rxon_ht()
637 rxon->flags |= in _iwl_set_rxon_ht()
646 switch (ctx->ht.extension_chan_offset) { in _iwl_set_rxon_ht()
648 rxon->flags &= in _iwl_set_rxon_ht()
650 rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; in _iwl_set_rxon_ht()
653 rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; in _iwl_set_rxon_ht()
654 rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; in _iwl_set_rxon_ht()
668 rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY; in _iwl_set_rxon_ht()
675 le32_to_cpu(rxon->flags), ctx->ht.protection, in _iwl_set_rxon_ht()
676 ctx->ht.extension_chan_offset); in _iwl_set_rxon_ht()
688 * iwl_set_rxon_channel - Set the band and channel values in staging RXON
692 * in the staging RXON flag structure based on the ch->band
697 enum nl80211_band band = ch->band; in iwl_set_rxon_channel()
698 u16 channel = ch->hw_value; in iwl_set_rxon_channel()
700 if ((le16_to_cpu(ctx->staging.channel) == channel) && in iwl_set_rxon_channel()
701 (priv->band == band)) in iwl_set_rxon_channel()
704 ctx->staging.channel = cpu_to_le16(channel); in iwl_set_rxon_channel()
706 ctx->staging.flags &= ~RXON_FLG_BAND_24G_MSK; in iwl_set_rxon_channel()
708 ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; in iwl_set_rxon_channel()
710 priv->band = band; in iwl_set_rxon_channel()
722 ctx->staging.flags &= in iwl_set_flags_for_band()
725 ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; in iwl_set_flags_for_band()
728 if (vif && vif->bss_conf.use_short_slot) in iwl_set_flags_for_band()
729 ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; in iwl_set_flags_for_band()
731 ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; in iwl_set_flags_for_band()
733 ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; in iwl_set_flags_for_band()
734 ctx->staging.flags |= RXON_FLG_AUTO_DETECT_MSK; in iwl_set_flags_for_band()
735 ctx->staging.flags &= ~RXON_FLG_CCK_MSK; in iwl_set_flags_for_band()
742 struct iwl_rxon_cmd *rxon = &ctx->staging; in iwl_set_rxon_hwcrypto()
745 rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; in iwl_set_rxon_hwcrypto()
747 rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK; in iwl_set_rxon_hwcrypto()
755 struct iwl_rxon_cmd *rxon = &ctx->staging; in iwl_check_rxon_cmd()
758 if (rxon->flags & RXON_FLG_BAND_24G_MSK) { in iwl_check_rxon_cmd()
759 if (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK) { in iwl_check_rxon_cmd()
763 if (rxon->flags & RXON_FLG_RADAR_DETECT_MSK) { in iwl_check_rxon_cmd()
768 if (!(rxon->flags & RXON_FLG_SHORT_SLOT_MSK)) { in iwl_check_rxon_cmd()
772 if (rxon->flags & RXON_FLG_CCK_MSK) { in iwl_check_rxon_cmd()
777 if ((rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1) { in iwl_check_rxon_cmd()
783 if ((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0 && in iwl_check_rxon_cmd()
784 (rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0) { in iwl_check_rxon_cmd()
789 if (le16_to_cpu(rxon->assoc_id) > 2007) { in iwl_check_rxon_cmd()
794 if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) in iwl_check_rxon_cmd()
800 if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) in iwl_check_rxon_cmd()
806 if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | in iwl_check_rxon_cmd()
809 IWL_WARN(priv, "TGg but no auto-detect\n"); in iwl_check_rxon_cmd()
813 if (rxon->channel == 0) { in iwl_check_rxon_cmd()
819 errors, le16_to_cpu(rxon->channel)); in iwl_check_rxon_cmd()
821 return errors ? -EINVAL : 0; in iwl_check_rxon_cmd()
825 * iwl_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed
835 const struct iwl_rxon_cmd *staging = &ctx->staging; in iwl_full_rxon_required()
836 const struct iwl_rxon_cmd *active = &ctx->active; in iwl_full_rxon_required()
840 IWL_DEBUG_INFO(priv, "need full RXON - " #cond "\n"); \ in iwl_full_rxon_required()
846 IWL_DEBUG_INFO(priv, "need full RXON - " \ in iwl_full_rxon_required()
847 #c1 " != " #c2 " - %d != %d\n", \ in iwl_full_rxon_required()
854 CHK(!ether_addr_equal(staging->bssid_addr, active->bssid_addr)); in iwl_full_rxon_required()
855 CHK(!ether_addr_equal(staging->node_addr, active->node_addr)); in iwl_full_rxon_required()
856 CHK(!ether_addr_equal(staging->wlap_bssid_addr, in iwl_full_rxon_required()
857 active->wlap_bssid_addr)); in iwl_full_rxon_required()
858 CHK_NEQ(staging->dev_type, active->dev_type); in iwl_full_rxon_required()
859 CHK_NEQ(staging->channel, active->channel); in iwl_full_rxon_required()
860 CHK_NEQ(staging->air_propagation, active->air_propagation); in iwl_full_rxon_required()
861 CHK_NEQ(staging->ofdm_ht_single_stream_basic_rates, in iwl_full_rxon_required()
862 active->ofdm_ht_single_stream_basic_rates); in iwl_full_rxon_required()
863 CHK_NEQ(staging->ofdm_ht_dual_stream_basic_rates, in iwl_full_rxon_required()
864 active->ofdm_ht_dual_stream_basic_rates); in iwl_full_rxon_required()
865 CHK_NEQ(staging->ofdm_ht_triple_stream_basic_rates, in iwl_full_rxon_required()
866 active->ofdm_ht_triple_stream_basic_rates); in iwl_full_rxon_required()
867 CHK_NEQ(staging->assoc_id, active->assoc_id); in iwl_full_rxon_required()
870 * be updated with the RXON_ASSOC command -- however only some in iwl_full_rxon_required()
874 CHK_NEQ(staging->flags & RXON_FLG_BAND_24G_MSK, in iwl_full_rxon_required()
875 active->flags & RXON_FLG_BAND_24G_MSK); in iwl_full_rxon_required()
878 CHK_NEQ(staging->filter_flags & RXON_FILTER_ASSOC_MSK, in iwl_full_rxon_required()
879 active->filter_flags & RXON_FILTER_ASSOC_MSK); in iwl_full_rxon_required()
891 struct iwl_rxon_context *ctx = &priv->contexts[ctxid]; in iwl_print_rx_config_cmd()
892 struct iwl_rxon_cmd *rxon = &ctx->staging; in iwl_print_rx_config_cmd()
897 le16_to_cpu(rxon->channel)); in iwl_print_rx_config_cmd()
899 le32_to_cpu(rxon->flags)); in iwl_print_rx_config_cmd()
901 le32_to_cpu(rxon->filter_flags)); in iwl_print_rx_config_cmd()
902 IWL_DEBUG_RADIO(priv, "u8 dev_type: 0x%x\n", rxon->dev_type); in iwl_print_rx_config_cmd()
904 rxon->ofdm_basic_rates); in iwl_print_rx_config_cmd()
906 rxon->cck_basic_rates); in iwl_print_rx_config_cmd()
907 IWL_DEBUG_RADIO(priv, "u8[6] node_addr: %pM\n", rxon->node_addr); in iwl_print_rx_config_cmd()
908 IWL_DEBUG_RADIO(priv, "u8[6] bssid_addr: %pM\n", rxon->bssid_addr); in iwl_print_rx_config_cmd()
910 le16_to_cpu(rxon->assoc_id)); in iwl_print_rx_config_cmd()
922 if (ctx->vif) { in iwl_calc_basic_rates()
924 unsigned long basic = ctx->vif->bss_conf.basic_rates; in iwl_calc_basic_rates()
927 sband = priv->hw->wiphy->bands[priv->hw->conf.chandef.chan->band]; in iwl_calc_basic_rates()
930 int hw = sband->bitrates[i].hw_value; in iwl_calc_basic_rates()
932 ofdm |= BIT(hw - IWL_FIRST_OFDM_RATE); in iwl_calc_basic_rates()
950 * and 6 Mbps because the 802.11-2007 standard says in 9.6: in iwl_calc_basic_rates()
978 * - if no CCK rates are basic, it must be ERP since there must in iwl_calc_basic_rates()
981 * - if 11M is a basic rate, it must be ERP as well, so add 5.5M in iwl_calc_basic_rates()
982 * - if 5.5M is basic, 1M and 2M are mandatory in iwl_calc_basic_rates()
983 * - if 2M is basic, 1M is mandatory in iwl_calc_basic_rates()
984 * - if 1M is basic, that's the only valid ACK rate. in iwl_calc_basic_rates()
1000 /* "basic_rates" is a misnomer here -- should be called ACK rates */ in iwl_calc_basic_rates()
1001 ctx->staging.cck_basic_rates = cck; in iwl_calc_basic_rates()
1002 ctx->staging.ofdm_basic_rates = ofdm; in iwl_calc_basic_rates()
1006 * iwlagn_commit_rxon - commit staging_rxon to hardware
1020 * 4. full RXON command - associated bit set
1026 struct iwl_rxon_cmd *active = (void *)&ctx->active; in iwlagn_commit_rxon()
1027 bool new_assoc = !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); in iwlagn_commit_rxon()
1030 lockdep_assert_held(&priv->mutex); in iwlagn_commit_rxon()
1033 return -EBUSY; in iwlagn_commit_rxon()
1035 /* This function hardcodes a bunch of dual-mode assumptions */ in iwlagn_commit_rxon()
1038 if (!ctx->is_active) in iwlagn_commit_rxon()
1042 ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK; in iwlagn_commit_rxon()
1048 * force CTS-to-self frames protection if RTS-CTS is not preferred in iwlagn_commit_rxon()
1051 if (!priv->hw_params.use_rts_for_aggregation) in iwlagn_commit_rxon()
1052 ctx->staging.flags |= RXON_FLG_SELF_CTS_EN; in iwlagn_commit_rxon()
1054 if ((ctx->vif && ctx->vif->bss_conf.use_short_slot) || in iwlagn_commit_rxon()
1055 !(ctx->staging.flags & RXON_FLG_BAND_24G_MSK)) in iwlagn_commit_rxon()
1056 ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; in iwlagn_commit_rxon()
1058 ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; in iwlagn_commit_rxon()
1060 iwl_print_rx_config_cmd(priv, ctx->ctxid); in iwlagn_commit_rxon()
1064 return -EINVAL; in iwlagn_commit_rxon()
1071 if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status) && in iwlagn_commit_rxon()
1072 (priv->switch_channel != ctx->staging.channel)) { in iwlagn_commit_rxon()
1074 le16_to_cpu(priv->switch_channel)); in iwlagn_commit_rxon()
1090 memcpy(active, &ctx->staging, sizeof(*active)); in iwlagn_commit_rxon()
1095 iwl_set_tx_power(priv, priv->tx_power_next, false); in iwlagn_commit_rxon()
1111 le16_to_cpu(ctx->staging.channel), in iwlagn_commit_rxon()
1112 ctx->staging.bssid_addr); in iwlagn_commit_rxon()
1138 ctx->ht.extension_chan_offset = in iwlagn_config_ht40()
1140 ctx->ht.is_40mhz = true; in iwlagn_config_ht40()
1142 ctx->ht.extension_chan_offset = in iwlagn_config_ht40()
1144 ctx->ht.is_40mhz = true; in iwlagn_config_ht40()
1146 ctx->ht.extension_chan_offset = in iwlagn_config_ht40()
1148 ctx->ht.is_40mhz = false; in iwlagn_config_ht40()
1156 struct ieee80211_conf *conf = &hw->conf; in iwlagn_mac_config()
1157 struct ieee80211_channel *channel = conf->chandef.chan; in iwlagn_mac_config()
1162 mutex_lock(&priv->mutex); in iwlagn_mac_config()
1164 if (unlikely(test_bit(STATUS_SCANNING, &priv->status))) { in iwlagn_mac_config()
1165 IWL_DEBUG_MAC80211(priv, "leave - scanning\n"); in iwlagn_mac_config()
1170 IWL_DEBUG_MAC80211(priv, "leave - not ready\n"); in iwlagn_mac_config()
1176 /* mac80211 uses static for non-HT which is what we want */ in iwlagn_mac_config()
1177 priv->current_ht_config.smps = conf->smps_mode; in iwlagn_mac_config()
1193 if (ctx->ht.enabled != conf_is_ht(conf)) in iwlagn_mac_config()
1194 ctx->ht.enabled = conf_is_ht(conf); in iwlagn_mac_config()
1196 if (ctx->ht.enabled) { in iwlagn_mac_config()
1199 if (!ctx->ht.is_40mhz || in iwlagn_mac_config()
1203 ctx->ht.is_40mhz = false; in iwlagn_mac_config()
1209 ctx->ht.protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE; in iwlagn_mac_config()
1214 if (le16_to_cpu(ctx->staging.channel) != in iwlagn_mac_config()
1215 channel->hw_value) in iwlagn_mac_config()
1216 ctx->staging.flags = 0; in iwlagn_mac_config()
1219 iwl_set_rxon_ht(priv, &priv->current_ht_config); in iwlagn_mac_config()
1221 iwl_set_flags_for_band(priv, ctx, channel->band, in iwlagn_mac_config()
1222 ctx->vif); in iwlagn_mac_config()
1237 priv->tx_power_user_lmt, conf->power_level); in iwlagn_mac_config()
1239 iwl_set_tx_power(priv, conf->power_level, false); in iwlagn_mac_config()
1243 if (!memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) in iwlagn_mac_config()
1248 mutex_unlock(&priv->mutex); in iwlagn_mac_config()
1258 struct ieee80211_vif *vif = ctx->vif; in iwlagn_check_needed_chains()
1261 struct iwl_ht_config *ht_conf = &priv->current_ht_config; in iwlagn_check_needed_chains()
1265 lockdep_assert_held(&priv->mutex); in iwlagn_check_needed_chains()
1267 switch (vif->type) { in iwlagn_check_needed_chains()
1270 sta = ieee80211_find_sta(vif, bss_conf->bssid); in iwlagn_check_needed_chains()
1283 ht_cap = &sta->deflink.ht_cap; in iwlagn_check_needed_chains()
1291 if (ht_cap->mcs.rx_mask[1] == 0 && in iwlagn_check_needed_chains()
1292 ht_cap->mcs.rx_mask[2] == 0) { in iwlagn_check_needed_chains()
1294 } else if (!(ht_cap->mcs.tx_params & in iwlagn_check_needed_chains()
1298 } else if (ht_cap->mcs.tx_params & in iwlagn_check_needed_chains()
1305 * to check here -- so check the number of streams in iwlagn_check_needed_chains()
1309 maxstreams = (ht_cap->mcs.tx_params & in iwlagn_check_needed_chains()
1331 ctx->ht_need_multiple_chains = need_multiple; in iwlagn_check_needed_chains()
1336 if (!tmp->vif) in iwlagn_check_needed_chains()
1338 if (tmp->ht_need_multiple_chains) { in iwlagn_check_needed_chains()
1345 ht_conf->single_chain_sufficient = !need_multiple; in iwlagn_check_needed_chains()
1350 struct iwl_chain_noise_data *data = &priv->chain_noise_data; in iwlagn_chain_noise_reset()
1353 if (priv->calib_disabled & IWL_CHAIN_NOISE_CALIB_DISABLED) in iwlagn_chain_noise_reset()
1356 if ((data->state == IWL_CHAIN_NOISE_ALIVE) && in iwlagn_chain_noise_reset()
1361 data->chain_noise_a = 0; in iwlagn_chain_noise_reset()
1362 data->chain_noise_b = 0; in iwlagn_chain_noise_reset()
1363 data->chain_noise_c = 0; in iwlagn_chain_noise_reset()
1364 data->chain_signal_a = 0; in iwlagn_chain_noise_reset()
1365 data->chain_signal_b = 0; in iwlagn_chain_noise_reset()
1366 data->chain_signal_c = 0; in iwlagn_chain_noise_reset()
1367 data->beacon_count = 0; in iwlagn_chain_noise_reset()
1371 priv->phy_calib_chain_noise_reset_cmd); in iwlagn_chain_noise_reset()
1378 data->state = IWL_CHAIN_NOISE_ACCUMULATE; in iwlagn_chain_noise_reset()
1393 mutex_lock(&priv->mutex); in iwlagn_bss_info_changed()
1395 if (changes & BSS_CHANGED_IDLE && vif->cfg.idle) { in iwlagn_bss_info_changed()
1397 * If we go idle, then clearly no "passive-no-rx" in iwlagn_bss_info_changed()
1404 IWL_DEBUG_MAC80211(priv, "leave - not ready\n"); in iwlagn_bss_info_changed()
1405 mutex_unlock(&priv->mutex); in iwlagn_bss_info_changed()
1409 if (unlikely(!ctx->vif)) { in iwlagn_bss_info_changed()
1410 IWL_DEBUG_MAC80211(priv, "leave - vif is NULL\n"); in iwlagn_bss_info_changed()
1411 mutex_unlock(&priv->mutex); in iwlagn_bss_info_changed()
1419 ctx->qos_data.qos_active = bss_conf->qos; in iwlagn_bss_info_changed()
1423 ctx->staging.assoc_id = cpu_to_le16(vif->cfg.aid); in iwlagn_bss_info_changed()
1424 if (vif->bss_conf.use_short_preamble) in iwlagn_bss_info_changed()
1425 ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; in iwlagn_bss_info_changed()
1427 ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; in iwlagn_bss_info_changed()
1430 if (vif->cfg.assoc) { in iwlagn_bss_info_changed()
1431 priv->timestamp = bss_conf->sync_tsf; in iwlagn_bss_info_changed()
1432 ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; in iwlagn_bss_info_changed()
1434 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; in iwlagn_bss_info_changed()
1436 if (ctx->ctxid == IWL_RXON_CTX_BSS) in iwlagn_bss_info_changed()
1437 priv->have_rekey_data = false; in iwlagn_bss_info_changed()
1443 if (ctx->ht.enabled) { in iwlagn_bss_info_changed()
1444 ctx->ht.protection = bss_conf->ht_operation_mode & in iwlagn_bss_info_changed()
1446 ctx->ht.non_gf_sta_present = !!(bss_conf->ht_operation_mode & in iwlagn_bss_info_changed()
1449 iwl_set_rxon_ht(priv, &priv->current_ht_config); in iwlagn_bss_info_changed()
1454 if (bss_conf->use_cts_prot && (priv->band != NL80211_BAND_5GHZ)) in iwlagn_bss_info_changed()
1455 ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; in iwlagn_bss_info_changed()
1457 ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; in iwlagn_bss_info_changed()
1459 if (bss_conf->use_cts_prot) in iwlagn_bss_info_changed()
1460 ctx->staging.flags |= RXON_FLG_SELF_CTS_EN; in iwlagn_bss_info_changed()
1462 ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN; in iwlagn_bss_info_changed()
1464 memcpy(ctx->staging.bssid_addr, bss_conf->bssid, ETH_ALEN); in iwlagn_bss_info_changed()
1466 if (vif->type == NL80211_IFTYPE_AP || in iwlagn_bss_info_changed()
1467 vif->type == NL80211_IFTYPE_ADHOC) { in iwlagn_bss_info_changed()
1468 if (vif->bss_conf.enable_beacon) { in iwlagn_bss_info_changed()
1469 ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; in iwlagn_bss_info_changed()
1470 priv->beacon_ctx = ctx; in iwlagn_bss_info_changed()
1472 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; in iwlagn_bss_info_changed()
1473 priv->beacon_ctx = NULL; in iwlagn_bss_info_changed()
1485 if (vif->type == NL80211_IFTYPE_STATION) { in iwlagn_bss_info_changed()
1486 if (!vif->cfg.assoc) in iwlagn_bss_info_changed()
1487 ctx->staging.filter_flags |= RXON_FILTER_BCON_AWARE_MSK; in iwlagn_bss_info_changed()
1489 ctx->staging.filter_flags &= in iwlagn_bss_info_changed()
1493 if (force || memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) in iwlagn_bss_info_changed()
1496 if (changes & BSS_CHANGED_ASSOC && vif->cfg.assoc) { in iwlagn_bss_info_changed()
1502 if (priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE) in iwlagn_bss_info_changed()
1505 /* Enable RX differential gain and sensitivity calibrations */ in iwlagn_bss_info_changed()
1507 priv->start_calib = 1; in iwlagn_bss_info_changed()
1512 vif->cfg.ibss_joined); in iwlagn_bss_info_changed()
1515 vif->cfg.ibss_joined ? "add" : "remove", in iwlagn_bss_info_changed()
1516 bss_conf->bssid); in iwlagn_bss_info_changed()
1519 if (changes & BSS_CHANGED_BEACON && priv->beacon_ctx == ctx) { in iwlagn_bss_info_changed()
1524 mutex_unlock(&priv->mutex); in iwlagn_bss_info_changed()
1535 iwl_power_set_mode(priv, &priv->power_data.sleep_cmd_next, false); in iwlagn_post_scan()
1536 iwl_set_tx_power(priv, priv->tx_power_next, false); in iwlagn_post_scan()
1543 if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) in iwlagn_post_scan()