45 switch (ctx->
vif->type) {
67 IWL_ERR(priv,
"Unsupported interface type %d\n",
75 if (!hw_to_local(priv->
hw)->short_preamble)
82 priv->
band = priv->
hw->conf.channel->band;
92 ctx->
staging.ofdm_ht_single_stream_basic_rates = 0xff;
93 ctx->
staging.ofdm_ht_dual_stream_basic_rates = 0xff;
94 ctx->
staging.ofdm_ht_triple_stream_basic_rates = 0xff;
112 "Error clearing ASSOC_MSK on BSS (%d)\n", ret);
117 static int iwlagn_disable_pan(
struct iwl_priv *priv,
125 static const u8 deactivate_cmd[] = {
142 IWL_ERR(priv,
"Error disabling PAN (%d)\n", ret);
148 IWL_ERR(priv,
"Timed out waiting for PAN disable\n");
154 static int iwlagn_disconn_pan(
struct iwl_priv *priv,
163 sizeof(*send), send);
170 static void iwlagn_update_qos(
struct iwl_priv *priv,
178 ctx->
qos_data.def_qos_parm.qos_flags = 0;
181 ctx->
qos_data.def_qos_parm.qos_flags |=
187 IWL_DEBUG_INFO(priv,
"send QoS cmd with Qos active=%d FLAGS=0x%X\n",
189 ctx->
qos_data.def_qos_parm.qos_flags);
198 static int iwlagn_update_beacon(
struct iwl_priv *priv,
210 static int iwlagn_send_rxon_assoc(
struct iwl_priv *priv,
230 IWL_DEBUG_INFO(priv,
"Using current RXON_ASSOC. Not resending.\n");
234 rxon_assoc.flags = ctx->
staging.flags;
235 rxon_assoc.filter_flags = ctx->
staging.filter_flags;
236 rxon_assoc.ofdm_basic_rates = ctx->
staging.ofdm_basic_rates;
237 rxon_assoc.cck_basic_rates = ctx->
staging.cck_basic_rates;
238 rxon_assoc.reserved1 = 0;
239 rxon_assoc.reserved2 = 0;
240 rxon_assoc.reserved3 = 0;
241 rxon_assoc.ofdm_ht_single_stream_basic_rates =
242 ctx->
staging.ofdm_ht_single_stream_basic_rates;
243 rxon_assoc.ofdm_ht_dual_stream_basic_rates =
244 ctx->
staging.ofdm_ht_dual_stream_basic_rates;
245 rxon_assoc.rx_chain_select_flags = ctx->
staging.rx_chain;
246 rxon_assoc.ofdm_ht_triple_stream_basic_rates =
247 ctx->
staging.ofdm_ht_triple_stream_basic_rates;
248 rxon_assoc.acquisition_data = ctx->
staging.acquisition_data;
251 CMD_ASYNC,
sizeof(rxon_assoc), &rxon_assoc);
255 static u16 iwl_adjust_beacon_interval(
u16 beacon_val,
u16 max_beacon_val)
281 beacon_factor = (beacon_val + max_beacon_val) / max_beacon_val;
282 new_val = beacon_val / beacon_factor;
285 new_val = max_beacon_val;
290 static int iwl_send_rxon_timing(
struct iwl_priv *priv,
294 s32 interval_tm, rem;
299 conf = &priv->
hw->conf;
308 beacon_int = vif ? vif->
bss_conf.beacon_int : 0;
314 ctx->
timing.atim_window = 0;
321 ctx->
timing.beacon_interval =
328 (!iwl_is_associated_ctx(ctx) || !ctx->
vif ||
329 !ctx->
vif->bss_conf.beacon_int)) {
330 ctx->
timing.beacon_interval =
334 beacon_int = iwl_adjust_beacon_interval(beacon_int,
343 rem =
do_div(tsf, interval_tm);
346 ctx->
timing.dtim_period = vif ? (vif->
bss_conf.dtim_period ?: 1) : 1;
349 "beacon interval %d beacon timer %d beacon tim %d\n",
358 static int iwlagn_rxon_disconn(
struct iwl_priv *priv,
365 ret = iwlagn_disable_bss(priv, ctx, &ctx->
staging);
367 ret = iwlagn_disable_pan(priv, ctx, &ctx->
staging);
371 ret = iwl_send_rxon_timing(priv, ctx);
373 IWL_ERR(priv,
"Failed to send timing (%d)!\n", ret);
376 ret = iwlagn_disconn_pan(priv, ctx, &ctx->
staging);
392 IWL_ERR(priv,
"Failed to restore WEP keys (%d)\n", ret);
417 "Requested user TXPOWER %d below lower limit %d.\n",
425 "Requested user TXPOWER %d above upper limit %d.\n",
430 if (!iwl_is_ready_rf(priv))
440 if (defer && !force) {
458 static int iwlagn_rxon_connect(
struct iwl_priv *priv,
466 ret = iwl_send_rxon_timing(priv, ctx);
468 IWL_ERR(priv,
"Failed to send timing (%d)!\n", ret);
473 iwlagn_update_qos(priv, ctx);
481 ret = iwlagn_update_beacon(priv, ctx->
vif);
484 "Error sending required beacon (%d)!\n",
500 IWL_ERR(priv,
"Error setting new RXON (%d)\n", ret);
507 if (iwlagn_update_beacon(priv, ctx->
vif))
508 IWL_ERR(priv,
"Error sending IBSS beacon\n");
520 IWL_ERR(priv,
"Error sending TX power (%d)\n", ret);
525 priv->
cfg->ht_params && priv->
cfg->ht_params->smps_mode)
527 priv->
cfg->ht_params->smps_mode);
558 memset(&cmd, 0,
sizeof(cmd));
563 cmd.
slots[0].type = 0;
564 cmd.
slots[1].type = 1;
570 }
else if (ctx_bss->
vif && ctx_pan->
vif) {
572 int dtim = ctx_pan->
vif->bss_conf.dtim_period ?: 1;
581 "beacon intervals don't match (%d, %d)\n",
584 bcnint =
max_t(
int, bcnint,
592 (!ctx_bss->
vif->bss_conf.idle &&
593 !ctx_bss->
vif->bss_conf.assoc)) {
596 }
else if (!ctx_pan->
vif->bss_conf.idle &&
597 !ctx_pan->
vif->bss_conf.assoc) {
601 }
else if (ctx_pan->
vif) {
619 IWL_ERR(priv,
"Error setting PAN parameters (%d)\n", ret);
624 static void _iwl_set_rxon_ht(
struct iwl_priv *priv,
630 if (!ctx->
ht.enabled) {
651 if (ctx->
ht.protection ==
658 switch (ctx->
ht.extension_chan_offset) {
673 switch (ctx->
ht.extension_chan_offset) {
690 "invalid extension channel offset\n");
701 "extension channel offset 0x%x\n",
703 ctx->
ht.extension_chan_offset);
711 _iwl_set_rxon_ht(priv, ht_conf, ctx);
728 (priv->
band == band))
739 IWL_DEBUG_INFO(priv,
"Staging channel set to %d [%d]\n", channel, band);
755 if (vif && vif->
bss_conf.use_short_slot)
766 static void iwl_set_rxon_hwcrypto(
struct iwl_priv *priv,
779 static int iwl_check_rxon_cmd(
struct iwl_priv *priv,
787 IWL_WARN(priv,
"check 2.4G: wrong narrow\n");
791 IWL_WARN(priv,
"check 2.4G: wrong radar\n");
796 IWL_WARN(priv,
"check 5.2G: not short slot!\n");
800 IWL_WARN(priv,
"check 5.2G: CCK!\n");
805 IWL_WARN(priv,
"mac/bssid mcast!\n");
812 IWL_WARN(priv,
"neither 1 nor 6 are basic\n");
823 IWL_WARN(priv,
"CCK and short slot\n");
829 IWL_WARN(priv,
"CCK and auto detect");
836 IWL_WARN(priv,
"TGg but no auto-detect\n");
841 IWL_WARN(priv,
"zero channel is invalid\n");
845 WARN(errors,
"Invalid RXON (%#x), channel %d",
848 return errors ? -
EINVAL : 0;
859 static int iwl_full_rxon_required(
struct iwl_priv *priv,
867 IWL_DEBUG_INFO(priv, "need full RXON - " #cond "\n"); \
871 #define CHK_NEQ(c1, c2) \
872 if ((c1) != (c2)) { \
873 IWL_DEBUG_INFO(priv, "need full RXON - " \
874 #c1 " != " #c2 " - %d != %d\n", \
880 CHK(!iwl_is_associated_ctx(ctx));
914 #ifdef CONFIG_IWLWIFI_DEBUG
915 void iwl_print_rx_config_cmd(
struct iwl_priv *priv,
941 static void iwl_calc_basic_rates(
struct iwl_priv *priv,
944 int lowest_present_ofdm = 100;
945 int lowest_present_cck = 100;
951 unsigned long basic = ctx->
vif->bss_conf.basic_rates;
954 sband = priv->
hw->wiphy->bands[priv->
hw->conf.channel->band];
960 if (lowest_present_ofdm > hw)
961 lowest_present_ofdm =
hw;
966 if (lowest_present_cck > hw)
967 lowest_present_cck =
hw;
1059 if (!iwl_is_alive(priv))
1072 iwl_calc_basic_rates(priv, ctx);
1078 if (!priv->
hw_params.use_rts_for_aggregation)
1081 if ((ctx->
vif && ctx->
vif->bss_conf.use_short_slot) ||
1087 iwl_print_rx_config_cmd(priv, ctx->
ctxid);
1088 ret = iwl_check_rxon_cmd(priv, ctx);
1090 IWL_ERR(priv,
"Invalid RXON configuration. Not committing.\n");
1110 if (!iwl_full_rxon_required(priv, ctx)) {
1111 ret = iwlagn_send_rxon_assoc(priv, ctx);
1113 IWL_ERR(priv,
"Error setting RXON_ASSOC (%d)\n", ret);
1133 "Going to commit RXON\n"
1134 " * with%s RXON_FILTER_ASSOC_MSK\n"
1137 (new_assoc ?
"" :
"out"),
1147 ret = iwlagn_rxon_disconn(priv, ctx);
1156 return iwlagn_rxon_connect(priv, ctx);
1164 if (conf_is_ht40_minus(conf)) {
1165 ctx->
ht.extension_chan_offset =
1167 ctx->
ht.is_40mhz =
true;
1168 }
else if (conf_is_ht40_plus(conf)) {
1169 ctx->
ht.extension_chan_offset =
1171 ctx->
ht.is_40mhz =
true;
1173 ctx->
ht.extension_chan_offset =
1175 ctx->
ht.is_40mhz =
false;
1196 if (!iwl_is_ready(priv)) {
1220 if (ctx->
ht.enabled != conf_is_ht(conf))
1221 ctx->
ht.enabled = conf_is_ht(conf);
1223 if (ctx->
ht.enabled) {
1226 if (!ctx->
ht.is_40mhz ||
1227 !iwl_is_associated_ctx(ctx))
1230 ctx->
ht.is_40mhz =
false;
1281 static void iwlagn_check_needed_chains(
struct iwl_priv *priv,
1294 switch (vif->
type) {
1305 need_multiple =
false;
1312 need_multiple =
true;
1318 if (ht_cap->
mcs.rx_mask[1] == 0 &&
1319 ht_cap->
mcs.rx_mask[2] == 0) {
1320 need_multiple =
false;
1321 }
else if (!(ht_cap->
mcs.tx_params &
1324 need_multiple =
false;
1325 }
else if (ht_cap->
mcs.tx_params &
1336 maxstreams = (ht_cap->
mcs.tx_params &
1342 if (maxstreams <= 1)
1343 need_multiple =
false;
1350 need_multiple =
false;
1354 need_multiple =
true;
1360 if (!need_multiple) {
1366 need_multiple =
true;
1375 static void iwlagn_chain_noise_reset(
struct iwl_priv *priv)
1384 iwl_is_any_associated(priv)) {
1397 iwl_set_calib_hdr(&
cmd.hdr,
1404 "Could not send REPLY_PHY_CALIBRATION_CMD\n");
1422 if (
unlikely(!iwl_is_ready(priv))) {
1439 iwlagn_update_qos(priv, ctx);
1443 if (vif->
bss_conf.use_short_preamble)
1449 if (bss_conf->
assoc) {
1472 if (ctx->
ht.enabled) {
1477 iwlagn_check_needed_chains(priv, ctx, bss_conf);
1515 if (!bss_conf->
assoc)
1525 if (changes & BSS_CHANGED_ASSOC && bss_conf->
assoc) {
1535 iwlagn_chain_noise_reset(priv);
1543 IWL_ERR(priv,
"failed to %s IBSS station %pM\n",
1550 if (iwlagn_update_beacon(priv, vif))
1551 IWL_ERR(priv,
"Error sending IBSS beacon\n");