112
121
return iwlagn_send_beacon_cmd(priv);
124
static int iwlagn_send_rxon_assoc(struct iwl_priv *priv,
125
struct iwl_rxon_context *ctx)
128
struct iwl_rxon_assoc_cmd rxon_assoc;
129
const struct iwl_rxon_cmd *rxon1 = &ctx->staging;
130
const struct iwl_rxon_cmd *rxon2 = &ctx->active;
132
if ((rxon1->flags == rxon2->flags) &&
133
(rxon1->filter_flags == rxon2->filter_flags) &&
134
(rxon1->cck_basic_rates == rxon2->cck_basic_rates) &&
135
(rxon1->ofdm_ht_single_stream_basic_rates ==
136
rxon2->ofdm_ht_single_stream_basic_rates) &&
137
(rxon1->ofdm_ht_dual_stream_basic_rates ==
138
rxon2->ofdm_ht_dual_stream_basic_rates) &&
139
(rxon1->ofdm_ht_triple_stream_basic_rates ==
140
rxon2->ofdm_ht_triple_stream_basic_rates) &&
141
(rxon1->acquisition_data == rxon2->acquisition_data) &&
142
(rxon1->rx_chain == rxon2->rx_chain) &&
143
(rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) {
144
IWL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n");
148
rxon_assoc.flags = ctx->staging.flags;
149
rxon_assoc.filter_flags = ctx->staging.filter_flags;
150
rxon_assoc.ofdm_basic_rates = ctx->staging.ofdm_basic_rates;
151
rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates;
152
rxon_assoc.reserved1 = 0;
153
rxon_assoc.reserved2 = 0;
154
rxon_assoc.reserved3 = 0;
155
rxon_assoc.ofdm_ht_single_stream_basic_rates =
156
ctx->staging.ofdm_ht_single_stream_basic_rates;
157
rxon_assoc.ofdm_ht_dual_stream_basic_rates =
158
ctx->staging.ofdm_ht_dual_stream_basic_rates;
159
rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain;
160
rxon_assoc.ofdm_ht_triple_stream_basic_rates =
161
ctx->staging.ofdm_ht_triple_stream_basic_rates;
162
rxon_assoc.acquisition_data = ctx->staging.acquisition_data;
164
ret = iwl_send_cmd_pdu_async(priv, ctx->rxon_assoc_cmd,
165
sizeof(rxon_assoc), &rxon_assoc, NULL);
172
static int iwlagn_rxon_disconn(struct iwl_priv *priv,
173
struct iwl_rxon_context *ctx)
176
struct iwl_rxon_cmd *active = (void *)&ctx->active;
178
if (ctx->ctxid == IWL_RXON_CTX_BSS)
179
ret = iwlagn_disable_bss(priv, ctx, &ctx->staging);
181
ret = iwlagn_disable_pan(priv, ctx, &ctx->staging);
186
* Un-assoc RXON clears the station table and WEP
187
* keys, so we have to restore those afterwards.
189
iwl_clear_ucode_stations(priv, ctx);
190
iwl_restore_stations(priv, ctx);
191
ret = iwl_restore_default_wep_keys(priv, ctx);
193
IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret);
197
memcpy(active, &ctx->staging, sizeof(*active));
201
static int iwlagn_rxon_connect(struct iwl_priv *priv,
202
struct iwl_rxon_context *ctx)
205
struct iwl_rxon_cmd *active = (void *)&ctx->active;
207
/* RXON timing must be before associated RXON */
208
ret = iwl_send_rxon_timing(priv, ctx);
210
IWL_ERR(priv, "Failed to send timing (%d)!\n", ret);
213
/* QoS info may be cleared by previous un-assoc RXON */
214
iwlagn_update_qos(priv, ctx);
217
* We'll run into this code path when beaconing is
218
* enabled, but then we also need to send the beacon
221
if (ctx->vif && (ctx->vif->type == NL80211_IFTYPE_AP)) {
222
ret = iwlagn_update_beacon(priv, ctx->vif);
225
"Error sending required beacon (%d)!\n",
231
priv->start_calib = 0;
233
* Apply the new configuration.
235
* Associated RXON doesn't clear the station table in uCode,
236
* so we don't need to restore stations etc. after this.
238
ret = iwl_send_cmd_pdu(priv, ctx->rxon_cmd,
239
sizeof(struct iwl_rxon_cmd), &ctx->staging);
241
IWL_ERR(priv, "Error setting new RXON (%d)\n", ret);
244
memcpy(active, &ctx->staging, sizeof(*active));
246
iwl_reprogram_ap_sta(priv, ctx);
248
/* IBSS beacon needs to be sent after setting assoc */
249
if (ctx->vif && (ctx->vif->type == NL80211_IFTYPE_ADHOC))
250
if (iwlagn_update_beacon(priv, ctx->vif))
251
IWL_ERR(priv, "Error sending IBSS beacon\n");
252
iwl_init_sensitivity(priv);
255
* If we issue a new RXON command which required a tune then
256
* we must send a new TXPOWER command or we won't be able to
259
* It's expected we set power here if channel is changing.
261
ret = iwl_set_tx_power(priv, priv->tx_power_next, true);
263
IWL_ERR(priv, "Error sending TX power (%d)\n", ret);
116
270
* iwlagn_commit_rxon - commit staging_rxon to hardware
119
273
* the active_rxon structure is updated with the new data. This
120
274
* function correctly transitions out of the RXON_ASSOC_MSK state if
121
275
* a HW tune is required based on the RXON structure changes.
277
* The connect/disconnect flow should be as the following:
279
* 1. make sure send RXON command with association bit unset if not connect
280
* this should include the channel and the band for the candidate
282
* 2. Add Station before RXON association with the AP
283
* 3. RXON_timing has to send before RXON for connection
284
* 4. full RXON command - associated bit set
285
* 5. use RXON_ASSOC command to update any flags changes
123
287
int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
125
289
/* cast away the const for active_rxon in this function */
126
290
struct iwl_rxon_cmd *active = (void *)&ctx->active;
127
291
bool new_assoc = !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK);
128
bool old_assoc = !!(ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK);
131
294
lockdep_assert_held(&priv->mutex);
145
308
/* always get timestamp with Rx frame */
146
309
ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK;
311
if (ctx->ctxid == IWL_RXON_CTX_PAN && priv->_agn.hw_roc_channel) {
312
struct ieee80211_channel *chan = priv->_agn.hw_roc_channel;
314
iwl_set_rxon_channel(priv, chan, ctx);
315
iwl_set_flags_for_band(priv, ctx, chan->band, NULL);
316
ctx->staging.filter_flags |=
317
RXON_FILTER_ASSOC_MSK |
318
RXON_FILTER_PROMISC_MSK |
319
RXON_FILTER_CTL2HOST_MSK;
320
ctx->staging.dev_type = RXON_DEV_TYPE_P2P;
323
if (memcmp(&ctx->staging, &ctx->active,
324
sizeof(ctx->staging)) == 0)
329
* force CTS-to-self frames protection if RTS-CTS is not preferred
330
* one aggregation protection method
332
if (!(priv->cfg->ht_params &&
333
priv->cfg->ht_params->use_rts_for_aggregation))
334
ctx->staging.flags |= RXON_FLG_SELF_CTS_EN;
148
336
if ((ctx->vif && ctx->vif->bss_conf.use_short_slot) ||
149
337
!(ctx->staging.flags & RXON_FLG_BAND_24G_MSK))
150
338
ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
152
340
ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
342
iwl_print_rx_config_cmd(priv, ctx);
154
343
ret = iwl_check_rxon_cmd(priv, ctx);
156
345
IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n");
208
401
* AP station must be done after the BSSID is set to correctly
209
402
* set up filters in the device.
211
if ((old_assoc && new_assoc) || !new_assoc) {
212
if (ctx->ctxid == IWL_RXON_CTX_BSS)
213
ret = iwlagn_disable_bss(priv, ctx, &ctx->staging);
215
ret = iwlagn_disable_pan(priv, ctx, &ctx->staging);
219
memcpy(active, &ctx->staging, sizeof(*active));
222
* Un-assoc RXON clears the station table and WEP
223
* keys, so we have to restore those afterwards.
225
iwl_clear_ucode_stations(priv, ctx);
226
iwl_restore_stations(priv, ctx);
227
ret = iwl_restore_default_wep_keys(priv, ctx);
229
IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret);
234
/* RXON timing must be before associated RXON */
235
ret = iwl_send_rxon_timing(priv, ctx);
237
IWL_ERR(priv, "Failed to send timing (%d)!\n", ret);
242
/* QoS info may be cleared by previous un-assoc RXON */
243
iwlagn_update_qos(priv, ctx);
246
* We'll run into this code path when beaconing is
247
* enabled, but then we also need to send the beacon
250
if (ctx->vif && (ctx->vif->type == NL80211_IFTYPE_AP)) {
251
ret = iwlagn_update_beacon(priv, ctx->vif);
254
"Error sending required beacon (%d)!\n",
260
priv->start_calib = 0;
262
* Apply the new configuration.
264
* Associated RXON doesn't clear the station table in uCode,
265
* so we don't need to restore stations etc. after this.
267
ret = iwl_send_cmd_pdu(priv, ctx->rxon_cmd,
268
sizeof(struct iwl_rxon_cmd), &ctx->staging);
270
IWL_ERR(priv, "Error setting new RXON (%d)\n", ret);
273
memcpy(active, &ctx->staging, sizeof(*active));
275
iwl_reprogram_ap_sta(priv, ctx);
277
/* IBSS beacon needs to be sent after setting assoc */
278
if (ctx->vif && (ctx->vif->type == NL80211_IFTYPE_ADHOC))
279
if (iwlagn_update_beacon(priv, ctx->vif))
280
IWL_ERR(priv, "Error sending IBSS beacon\n");
283
iwl_print_rx_config_cmd(priv, ctx);
285
iwl_init_sensitivity(priv);
288
* If we issue a new RXON command which required a tune then we must
289
* send a new TXPOWER command or we won't be able to Tx any frames.
291
* FIXME: which RXON requires a tune? Can we optimise this out in
294
ret = iwl_set_tx_power(priv, priv->tx_power_user_lmt, true);
296
IWL_ERR(priv, "Error sending TX power (%d)\n", ret);
404
ret = iwlagn_rxon_disconn(priv, ctx);
409
return iwlagn_rxon_connect(priv, ctx);
452
559
case NL80211_IFTYPE_STATION:
454
561
sta = ieee80211_find_sta(vif, bss_conf->bssid);
456
struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap;
564
* If at all, this can only happen through a race
565
* when the AP disconnects us while we're still
566
* setting up the connection, in that case mac80211
567
* will soon tell us about that.
569
need_multiple = false;
574
ht_cap = &sta->ht_cap;
576
need_multiple = true;
579
* If the peer advertises no support for receiving 2 and 3
580
* stream MCS rates, it can't be transmitting them either.
582
if (ht_cap->mcs.rx_mask[1] == 0 &&
583
ht_cap->mcs.rx_mask[2] == 0) {
584
need_multiple = false;
585
} else if (!(ht_cap->mcs.tx_params &
586
IEEE80211_HT_MCS_TX_DEFINED)) {
587
/* If it can't TX MCS at all ... */
588
need_multiple = false;
589
} else if (ht_cap->mcs.tx_params &
590
IEEE80211_HT_MCS_TX_RX_DIFF) {
594
* But if it can receive them, it might still not
595
* be able to transmit them, which is what we need
596
* to check here -- so check the number of streams
597
* it advertises for TX (if different from RX).
459
600
maxstreams = (ht_cap->mcs.tx_params &
460
IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK)
461
>> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT;
601
IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK);
603
IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT;
464
need_multiple = true;
466
if ((ht_cap->mcs.rx_mask[1] == 0) &&
467
(ht_cap->mcs.rx_mask[2] == 0))
468
need_multiple = false;
469
606
if (maxstreams <= 1)
470
607
need_multiple = false;
473
* If at all, this can only happen through a race
474
* when the AP disconnects us while we're still
475
* setting up the connection, in that case mac80211
476
* will soon tell us about that.
478
need_multiple = false;
480
610
rcu_read_unlock();
482
612
case NL80211_IFTYPE_ADHOC: