1 /******************************************************************************
3 * Copyright(c) 2003 - 2010 Intel Corporation. All rights reserved.
5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of version 2 of the GNU General Public License as
10 * published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
21 * The full GNU General Public License is included in this distribution in the
22 * file called LICENSE.
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
28 *****************************************************************************/
30 #include <net/mac80211.h>
31 #include <linux/etherdevice.h>
32 #include <linux/sched.h>
38 /* priv->sta_lock must be held */
39 static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
42 if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE))
43 IWL_ERR(priv, "ACTIVATE a non DRIVER active station id %u addr %pM\n",
44 sta_id, priv->stations[sta_id].sta.sta.addr);
46 if (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE) {
48 "STA id %u addr %pM already present in uCode (according to driver)\n",
49 sta_id, priv->stations[sta_id].sta.sta.addr);
51 priv->stations[sta_id].used |= IWL_STA_UCODE_ACTIVE;
52 IWL_DEBUG_ASSOC(priv, "Added STA id %u addr %pM to uCode\n",
53 sta_id, priv->stations[sta_id].sta.sta.addr);
57 static void iwl_process_add_sta_resp(struct iwl_priv *priv,
58 struct iwl_addsta_cmd *addsta,
59 struct iwl_rx_packet *pkt,
62 u8 sta_id = addsta->sta.sta_id;
65 if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) {
66 IWL_ERR(priv, "Bad return from REPLY_ADD_STA (0x%08X)\n",
71 IWL_DEBUG_INFO(priv, "Processing response for adding station %u\n",
74 spin_lock_irqsave(&priv->sta_lock, flags);
76 switch (pkt->u.add_sta.status) {
77 case ADD_STA_SUCCESS_MSK:
78 IWL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n");
79 iwl_sta_ucode_activate(priv, sta_id);
81 case ADD_STA_NO_ROOM_IN_TABLE:
82 IWL_ERR(priv, "Adding station %d failed, no room in table.\n",
85 case ADD_STA_NO_BLOCK_ACK_RESOURCE:
86 IWL_ERR(priv, "Adding station %d failed, no block ack resource.\n",
89 case ADD_STA_MODIFY_NON_EXIST_STA:
90 IWL_ERR(priv, "Attempting to modify non-existing station %d\n",
94 IWL_DEBUG_ASSOC(priv, "Received REPLY_ADD_STA:(0x%08X)\n",
95 pkt->u.add_sta.status);
99 IWL_DEBUG_INFO(priv, "%s station id %u addr %pM\n",
100 priv->stations[sta_id].sta.mode ==
101 STA_CONTROL_MODIFY_MSK ? "Modified" : "Added",
102 sta_id, priv->stations[sta_id].sta.sta.addr);
105 * XXX: The MAC address in the command buffer is often changed from
106 * the original sent to the device. That is, the MAC address
107 * written to the command buffer often is not the same MAC adress
108 * read from the command buffer when the command returns. This
109 * issue has not yet been resolved and this debugging is left to
110 * observe the problem.
112 IWL_DEBUG_INFO(priv, "%s station according to cmd buffer %pM\n",
113 priv->stations[sta_id].sta.mode ==
114 STA_CONTROL_MODIFY_MSK ? "Modified" : "Added",
116 spin_unlock_irqrestore(&priv->sta_lock, flags);
119 static void iwl_add_sta_callback(struct iwl_priv *priv,
120 struct iwl_device_cmd *cmd,
121 struct iwl_rx_packet *pkt)
123 struct iwl_addsta_cmd *addsta =
124 (struct iwl_addsta_cmd *)cmd->cmd.payload;
126 iwl_process_add_sta_resp(priv, addsta, pkt, false);
130 int iwl_send_add_sta(struct iwl_priv *priv,
131 struct iwl_addsta_cmd *sta, u8 flags)
133 struct iwl_rx_packet *pkt = NULL;
135 u8 data[sizeof(*sta)];
136 struct iwl_host_cmd cmd = {
141 u8 sta_id __maybe_unused = sta->sta.sta_id;
143 IWL_DEBUG_INFO(priv, "Adding sta %u (%pM) %ssynchronously\n",
144 sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : "");
146 if (flags & CMD_ASYNC)
147 cmd.callback = iwl_add_sta_callback;
149 cmd.flags |= CMD_WANT_SKB;
151 cmd.len = priv->cfg->ops->utils->build_addsta_hcmd(sta, data);
152 ret = iwl_send_cmd(priv, &cmd);
154 if (ret || (flags & CMD_ASYNC))
158 pkt = (struct iwl_rx_packet *)cmd.reply_page;
159 iwl_process_add_sta_resp(priv, sta, pkt, true);
161 iwl_free_pages(priv, cmd.reply_page);
165 EXPORT_SYMBOL(iwl_send_add_sta);
167 static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
168 struct ieee80211_sta_ht_cap *sta_ht_inf)
173 if (!sta_ht_inf || !sta_ht_inf->ht_supported)
176 mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2;
177 IWL_DEBUG_ASSOC(priv, "spatial multiplexing power save mode: %s\n",
178 (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ?
180 (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ?
181 "dynamic" : "disabled");
183 sta_flags = priv->stations[index].sta.station_flags;
185 sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK);
187 switch (mimo_ps_mode) {
188 case WLAN_HT_CAP_SM_PS_STATIC:
189 sta_flags |= STA_FLG_MIMO_DIS_MSK;
191 case WLAN_HT_CAP_SM_PS_DYNAMIC:
192 sta_flags |= STA_FLG_RTS_MIMO_PROT_MSK;
194 case WLAN_HT_CAP_SM_PS_DISABLED:
197 IWL_WARN(priv, "Invalid MIMO PS mode %d\n", mimo_ps_mode);
201 sta_flags |= cpu_to_le32(
202 (u32)sta_ht_inf->ampdu_factor << STA_FLG_MAX_AGG_SIZE_POS);
204 sta_flags |= cpu_to_le32(
205 (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS);
207 if (iwl_is_ht40_tx_allowed(priv, sta_ht_inf))
208 sta_flags |= STA_FLG_HT40_EN_MSK;
210 sta_flags &= ~STA_FLG_HT40_EN_MSK;
212 priv->stations[index].sta.station_flags = sta_flags;
218 * iwl_prep_station - Prepare station information for addition
220 * should be called with sta_lock held
222 static u8 iwl_prep_station(struct iwl_priv *priv, const u8 *addr,
224 struct ieee80211_sta_ht_cap *ht_info)
226 struct iwl_station_entry *station;
228 u8 sta_id = IWL_INVALID_STATION;
233 else if (is_broadcast_ether_addr(addr))
234 sta_id = priv->hw_params.bcast_sta_id;
236 for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) {
237 if (!compare_ether_addr(priv->stations[i].sta.sta.addr,
243 if (!priv->stations[i].used &&
244 sta_id == IWL_INVALID_STATION)
249 * These two conditions have the same outcome, but keep them
252 if (unlikely(sta_id == IWL_INVALID_STATION))
256 * uCode is not able to deal with multiple requests to add a
257 * station. Keep track if one is in progress so that we do not send
260 if (priv->stations[sta_id].used & IWL_STA_UCODE_INPROGRESS) {
261 IWL_DEBUG_INFO(priv, "STA %d already in process of being added.\n",
266 if ((priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) &&
267 (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE) &&
268 !compare_ether_addr(priv->stations[sta_id].sta.sta.addr, addr)) {
269 IWL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not adding again.\n",
274 station = &priv->stations[sta_id];
275 station->used = IWL_STA_DRIVER_ACTIVE;
276 IWL_DEBUG_ASSOC(priv, "Add STA to driver ID %d: %pM\n",
278 priv->num_stations++;
280 /* Set up the REPLY_ADD_STA command to send to device */
281 memset(&station->sta, 0, sizeof(struct iwl_addsta_cmd));
282 memcpy(station->sta.sta.addr, addr, ETH_ALEN);
283 station->sta.mode = 0;
284 station->sta.sta.sta_id = sta_id;
285 station->sta.station_flags = 0;
287 /* BCAST station and IBSS stations do not work in HT mode */
288 if (sta_id != priv->hw_params.bcast_sta_id &&
289 priv->iw_mode != NL80211_IFTYPE_ADHOC)
290 iwl_set_ht_add_station(priv, sta_id, ht_info);
293 rate = (priv->band == IEEE80211_BAND_5GHZ) ?
294 IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP;
295 /* Turn on both antennas for the station... */
296 station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK);
302 #define STA_WAIT_TIMEOUT (HZ/2)
305 * iwl_add_station_common -
307 int iwl_add_station_common(struct iwl_priv *priv, const u8 *addr,
309 struct ieee80211_sta_ht_cap *ht_info,
312 struct iwl_station_entry *station;
313 unsigned long flags_spin;
318 spin_lock_irqsave(&priv->sta_lock, flags_spin);
319 sta_id = iwl_prep_station(priv, addr, is_ap, ht_info);
320 if (sta_id == IWL_INVALID_STATION) {
321 IWL_ERR(priv, "Unable to prepare station %pM for addition\n",
323 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
328 * uCode is not able to deal with multiple requests to add a
329 * station. Keep track if one is in progress so that we do not send
332 if (priv->stations[sta_id].used & IWL_STA_UCODE_INPROGRESS) {
333 IWL_DEBUG_INFO(priv, "STA %d already in process of being added.\n",
335 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
339 if ((priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) &&
340 (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) {
341 IWL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not adding again.\n",
343 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
347 priv->stations[sta_id].used |= IWL_STA_UCODE_INPROGRESS;
348 station = &priv->stations[sta_id];
349 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
351 /* Add station to device's station table */
352 ret = iwl_send_add_sta(priv, &station->sta, CMD_SYNC);
354 IWL_ERR(priv, "Adding station %pM failed.\n", station->sta.sta.addr);
355 spin_lock_irqsave(&priv->sta_lock, flags_spin);
356 priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE;
357 priv->stations[sta_id].used &= ~IWL_STA_UCODE_INPROGRESS;
358 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
363 EXPORT_SYMBOL(iwl_add_station_common);
365 static struct iwl_link_quality_cmd *iwl_sta_alloc_lq(struct iwl_priv *priv,
369 struct iwl_link_quality_cmd *link_cmd;
372 link_cmd = kzalloc(sizeof(struct iwl_link_quality_cmd), GFP_KERNEL);
374 IWL_ERR(priv, "Unable to allocate memory for LQ cmd.\n");
377 /* Set up the rate scaling to start at selected rate, fall back
378 * all the way down to 1M in IEEE order, and then spin on 1M */
379 if (priv->band == IEEE80211_BAND_5GHZ)
380 r = IWL_RATE_6M_INDEX;
382 r = IWL_RATE_1M_INDEX;
384 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
386 if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE)
387 rate_flags |= RATE_MCS_CCK_MSK;
389 rate_flags |= first_antenna(priv->hw_params.valid_tx_ant) <<
392 link_cmd->rs_table[i].rate_n_flags =
393 iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags);
394 r = iwl_get_prev_ieee_rate(r);
397 link_cmd->general_params.single_stream_ant_msk =
398 first_antenna(priv->hw_params.valid_tx_ant);
400 link_cmd->general_params.dual_stream_ant_msk =
401 priv->hw_params.valid_tx_ant &
402 ~first_antenna(priv->hw_params.valid_tx_ant);
403 if (!link_cmd->general_params.dual_stream_ant_msk) {
404 link_cmd->general_params.dual_stream_ant_msk = ANT_AB;
405 } else if (num_of_ant(priv->hw_params.valid_tx_ant) == 2) {
406 link_cmd->general_params.dual_stream_ant_msk =
407 priv->hw_params.valid_tx_ant;
410 link_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF;
411 link_cmd->agg_params.agg_time_limit =
412 cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF);
414 link_cmd->sta_id = sta_id;
420 * iwl_add_bssid_station - Add the special IBSS BSSID station
424 int iwl_add_bssid_station(struct iwl_priv *priv, const u8 *addr, bool init_rs,
429 struct iwl_link_quality_cmd *link_cmd;
433 *sta_id_r = IWL_INVALID_STATION;
435 ret = iwl_add_station_common(priv, addr, 0, NULL, &sta_id);
437 IWL_ERR(priv, "Unable to add station %pM\n", addr);
444 spin_lock_irqsave(&priv->sta_lock, flags);
445 priv->stations[sta_id].used |= IWL_STA_LOCAL;
446 spin_unlock_irqrestore(&priv->sta_lock, flags);
449 /* Set up default rate scaling table in device's station table */
450 link_cmd = iwl_sta_alloc_lq(priv, sta_id);
452 IWL_ERR(priv, "Unable to initialize rate scaling for station %pM.\n",
457 ret = iwl_send_lq_cmd(priv, link_cmd, CMD_SYNC, true);
459 IWL_ERR(priv, "Link quality command failed (%d)\n", ret);
461 spin_lock_irqsave(&priv->sta_lock, flags);
462 priv->stations[sta_id].lq = link_cmd;
463 spin_unlock_irqrestore(&priv->sta_lock, flags);
468 EXPORT_SYMBOL(iwl_add_bssid_station);
471 * iwl_sta_ucode_deactivate - deactivate ucode status for a station
473 * priv->sta_lock must be held
475 static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, u8 sta_id)
477 /* Ucode must be active and driver must be non active */
478 if ((priv->stations[sta_id].used &
479 (IWL_STA_UCODE_ACTIVE | IWL_STA_DRIVER_ACTIVE)) != IWL_STA_UCODE_ACTIVE)
480 IWL_ERR(priv, "removed non active STA %u\n", sta_id);
482 priv->stations[sta_id].used &= ~IWL_STA_UCODE_ACTIVE;
484 memset(&priv->stations[sta_id], 0, sizeof(struct iwl_station_entry));
485 IWL_DEBUG_ASSOC(priv, "Removed STA %u\n", sta_id);
488 static int iwl_send_remove_station(struct iwl_priv *priv,
489 struct iwl_station_entry *station)
491 struct iwl_rx_packet *pkt;
494 unsigned long flags_spin;
495 struct iwl_rem_sta_cmd rm_sta_cmd;
497 struct iwl_host_cmd cmd = {
498 .id = REPLY_REMOVE_STA,
499 .len = sizeof(struct iwl_rem_sta_cmd),
504 memset(&rm_sta_cmd, 0, sizeof(rm_sta_cmd));
505 rm_sta_cmd.num_sta = 1;
506 memcpy(&rm_sta_cmd.addr, &station->sta.sta.addr , ETH_ALEN);
508 cmd.flags |= CMD_WANT_SKB;
510 ret = iwl_send_cmd(priv, &cmd);
515 pkt = (struct iwl_rx_packet *)cmd.reply_page;
516 if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) {
517 IWL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n",
523 switch (pkt->u.rem_sta.status) {
524 case REM_STA_SUCCESS_MSK:
525 spin_lock_irqsave(&priv->sta_lock, flags_spin);
526 iwl_sta_ucode_deactivate(priv, station->sta.sta.sta_id);
527 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
528 IWL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n");
532 IWL_ERR(priv, "REPLY_REMOVE_STA failed\n");
536 iwl_free_pages(priv, cmd.reply_page);
542 * iwl_remove_station - Remove driver's knowledge of station.
544 int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id,
547 struct iwl_station_entry *station;
550 if (!iwl_is_ready(priv)) {
552 "Unable to remove station %pM, device not ready.\n",
555 * It is typical for stations to be removed when we are
556 * going down. Return success since device will be down
562 IWL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n",
565 if (WARN_ON(sta_id == IWL_INVALID_STATION))
568 spin_lock_irqsave(&priv->sta_lock, flags);
570 if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) {
571 IWL_DEBUG_INFO(priv, "Removing %pM but non DRIVER active\n",
576 if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) {
577 IWL_DEBUG_INFO(priv, "Removing %pM but non UCODE active\n",
582 if (priv->stations[sta_id].used & IWL_STA_LOCAL) {
583 kfree(priv->stations[sta_id].lq);
584 priv->stations[sta_id].lq = NULL;
587 priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE;
589 priv->num_stations--;
591 BUG_ON(priv->num_stations < 0);
593 station = &priv->stations[sta_id];
594 spin_unlock_irqrestore(&priv->sta_lock, flags);
596 return iwl_send_remove_station(priv, station);
598 spin_unlock_irqrestore(&priv->sta_lock, flags);
601 EXPORT_SYMBOL_GPL(iwl_remove_station);
604 * iwl_clear_ucode_stations - clear ucode station table bits
606 * This function clears all the bits in the driver indicating
607 * which stations are active in the ucode. Call when something
608 * other than explicit station management would cause this in
609 * the ucode, e.g. unassociated RXON.
611 void iwl_clear_ucode_stations(struct iwl_priv *priv)
614 unsigned long flags_spin;
615 bool cleared = false;
617 IWL_DEBUG_INFO(priv, "Clearing ucode stations in driver\n");
619 spin_lock_irqsave(&priv->sta_lock, flags_spin);
620 for (i = 0; i < priv->hw_params.max_stations; i++) {
621 if (priv->stations[i].used & IWL_STA_UCODE_ACTIVE) {
622 IWL_DEBUG_INFO(priv, "Clearing ucode active for station %d\n", i);
623 priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE;
627 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
630 IWL_DEBUG_INFO(priv, "No active stations found to be cleared\n");
632 EXPORT_SYMBOL(iwl_clear_ucode_stations);
635 * iwl_restore_stations() - Restore driver known stations to device
637 * All stations considered active by driver, but not present in ucode, is
642 void iwl_restore_stations(struct iwl_priv *priv)
644 struct iwl_station_entry *station;
645 unsigned long flags_spin;
650 if (!iwl_is_ready(priv)) {
651 IWL_DEBUG_INFO(priv, "Not ready yet, not restoring any stations.\n");
655 IWL_DEBUG_ASSOC(priv, "Restoring all known stations ... start.\n");
656 spin_lock_irqsave(&priv->sta_lock, flags_spin);
657 for (i = 0; i < priv->hw_params.max_stations; i++) {
658 if ((priv->stations[i].used & IWL_STA_DRIVER_ACTIVE) &&
659 !(priv->stations[i].used & IWL_STA_UCODE_ACTIVE)) {
660 IWL_DEBUG_ASSOC(priv, "Restoring sta %pM\n",
661 priv->stations[i].sta.sta.addr);
662 priv->stations[i].sta.mode = 0;
663 priv->stations[i].used |= IWL_STA_UCODE_INPROGRESS;
668 for (i = 0; i < priv->hw_params.max_stations; i++) {
669 if ((priv->stations[i].used & IWL_STA_UCODE_INPROGRESS)) {
670 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
671 station = &priv->stations[i];
672 ret = iwl_send_add_sta(priv, &priv->stations[i].sta, CMD_SYNC);
674 IWL_ERR(priv, "Adding station %pM failed.\n",
675 station->sta.sta.addr);
676 spin_lock_irqsave(&priv->sta_lock, flags_spin);
677 priv->stations[i].used &= ~IWL_STA_DRIVER_ACTIVE;
678 priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS;
679 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
682 * Rate scaling has already been initialized, send
686 iwl_send_lq_cmd(priv, station->lq, CMD_SYNC, true);
687 spin_lock_irqsave(&priv->sta_lock, flags_spin);
688 priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS;
692 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
694 IWL_DEBUG_INFO(priv, "Restoring all known stations .... no stations to be restored.\n");
696 IWL_DEBUG_INFO(priv, "Restoring all known stations .... complete.\n");
698 EXPORT_SYMBOL(iwl_restore_stations);
700 int iwl_get_free_ucode_key_index(struct iwl_priv *priv)
704 for (i = 0; i < STA_KEY_MAX_NUM; i++)
705 if (!test_and_set_bit(i, &priv->ucode_key_table))
708 return WEP_INVALID_OFFSET;
710 EXPORT_SYMBOL(iwl_get_free_ucode_key_index);
712 static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty)
714 int i, not_empty = 0;
715 u8 buff[sizeof(struct iwl_wep_cmd) +
716 sizeof(struct iwl_wep_key) * WEP_KEYS_MAX];
717 struct iwl_wep_cmd *wep_cmd = (struct iwl_wep_cmd *)buff;
718 size_t cmd_size = sizeof(struct iwl_wep_cmd);
719 struct iwl_host_cmd cmd = {
727 memset(wep_cmd, 0, cmd_size +
728 (sizeof(struct iwl_wep_key) * WEP_KEYS_MAX));
730 for (i = 0; i < WEP_KEYS_MAX ; i++) {
731 wep_cmd->key[i].key_index = i;
732 if (priv->wep_keys[i].key_size) {
733 wep_cmd->key[i].key_offset = i;
736 wep_cmd->key[i].key_offset = WEP_INVALID_OFFSET;
739 wep_cmd->key[i].key_size = priv->wep_keys[i].key_size;
740 memcpy(&wep_cmd->key[i].key[3], priv->wep_keys[i].key,
741 priv->wep_keys[i].key_size);
744 wep_cmd->global_key_type = WEP_KEY_WEP_TYPE;
745 wep_cmd->num_keys = WEP_KEYS_MAX;
747 cmd_size += sizeof(struct iwl_wep_key) * WEP_KEYS_MAX;
751 if (not_empty || send_if_empty)
752 return iwl_send_cmd(priv, &cmd);
757 int iwl_restore_default_wep_keys(struct iwl_priv *priv)
759 WARN_ON(!mutex_is_locked(&priv->mutex));
761 return iwl_send_static_wepkey_cmd(priv, 0);
763 EXPORT_SYMBOL(iwl_restore_default_wep_keys);
765 int iwl_remove_default_wep_key(struct iwl_priv *priv,
766 struct ieee80211_key_conf *keyconf)
770 WARN_ON(!mutex_is_locked(&priv->mutex));
772 IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n",
775 memset(&priv->wep_keys[keyconf->keyidx], 0, sizeof(priv->wep_keys[0]));
776 if (iwl_is_rfkill(priv)) {
777 IWL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n");
778 /* but keys in device are clear anyway so return success */
781 ret = iwl_send_static_wepkey_cmd(priv, 1);
782 IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n",
783 keyconf->keyidx, ret);
787 EXPORT_SYMBOL(iwl_remove_default_wep_key);
789 int iwl_set_default_wep_key(struct iwl_priv *priv,
790 struct ieee80211_key_conf *keyconf)
794 WARN_ON(!mutex_is_locked(&priv->mutex));
796 if (keyconf->keylen != WEP_KEY_LEN_128 &&
797 keyconf->keylen != WEP_KEY_LEN_64) {
798 IWL_DEBUG_WEP(priv, "Bad WEP key length %d\n", keyconf->keylen);
802 keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV;
803 keyconf->hw_key_idx = HW_KEY_DEFAULT;
804 priv->stations[IWL_AP_ID].keyinfo.alg = ALG_WEP;
806 priv->wep_keys[keyconf->keyidx].key_size = keyconf->keylen;
807 memcpy(&priv->wep_keys[keyconf->keyidx].key, &keyconf->key,
810 ret = iwl_send_static_wepkey_cmd(priv, 0);
811 IWL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n",
812 keyconf->keylen, keyconf->keyidx, ret);
816 EXPORT_SYMBOL(iwl_set_default_wep_key);
818 static int iwl_set_wep_dynamic_key_info(struct iwl_priv *priv,
819 struct ieee80211_key_conf *keyconf,
823 __le16 key_flags = 0;
826 keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV;
828 key_flags |= (STA_KEY_FLG_WEP | STA_KEY_FLG_MAP_KEY_MSK);
829 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
830 key_flags &= ~STA_KEY_FLG_INVALID;
832 if (keyconf->keylen == WEP_KEY_LEN_128)
833 key_flags |= STA_KEY_FLG_KEY_SIZE_MSK;
835 if (sta_id == priv->hw_params.bcast_sta_id)
836 key_flags |= STA_KEY_MULTICAST_MSK;
838 spin_lock_irqsave(&priv->sta_lock, flags);
840 priv->stations[sta_id].keyinfo.alg = keyconf->alg;
841 priv->stations[sta_id].keyinfo.keylen = keyconf->keylen;
842 priv->stations[sta_id].keyinfo.keyidx = keyconf->keyidx;
844 memcpy(priv->stations[sta_id].keyinfo.key,
845 keyconf->key, keyconf->keylen);
847 memcpy(&priv->stations[sta_id].sta.key.key[3],
848 keyconf->key, keyconf->keylen);
850 if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK)
851 == STA_KEY_FLG_NO_ENC)
852 priv->stations[sta_id].sta.key.key_offset =
853 iwl_get_free_ucode_key_index(priv);
854 /* else, we are overriding an existing key => no need to allocated room
857 WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET,
858 "no space for a new key");
860 priv->stations[sta_id].sta.key.key_flags = key_flags;
861 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
862 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
864 ret = iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
866 spin_unlock_irqrestore(&priv->sta_lock, flags);
871 static int iwl_set_ccmp_dynamic_key_info(struct iwl_priv *priv,
872 struct ieee80211_key_conf *keyconf,
876 __le16 key_flags = 0;
879 key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK);
880 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
881 key_flags &= ~STA_KEY_FLG_INVALID;
883 if (sta_id == priv->hw_params.bcast_sta_id)
884 key_flags |= STA_KEY_MULTICAST_MSK;
886 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
888 spin_lock_irqsave(&priv->sta_lock, flags);
889 priv->stations[sta_id].keyinfo.alg = keyconf->alg;
890 priv->stations[sta_id].keyinfo.keylen = keyconf->keylen;
892 memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key,
895 memcpy(priv->stations[sta_id].sta.key.key, keyconf->key,
898 if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK)
899 == STA_KEY_FLG_NO_ENC)
900 priv->stations[sta_id].sta.key.key_offset =
901 iwl_get_free_ucode_key_index(priv);
902 /* else, we are overriding an existing key => no need to allocated room
905 WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET,
906 "no space for a new key");
908 priv->stations[sta_id].sta.key.key_flags = key_flags;
909 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
910 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
912 ret = iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
914 spin_unlock_irqrestore(&priv->sta_lock, flags);
919 static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
920 struct ieee80211_key_conf *keyconf,
925 __le16 key_flags = 0;
927 key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK);
928 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
929 key_flags &= ~STA_KEY_FLG_INVALID;
931 if (sta_id == priv->hw_params.bcast_sta_id)
932 key_flags |= STA_KEY_MULTICAST_MSK;
934 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
935 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
937 spin_lock_irqsave(&priv->sta_lock, flags);
939 priv->stations[sta_id].keyinfo.alg = keyconf->alg;
940 priv->stations[sta_id].keyinfo.keylen = 16;
942 if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK)
943 == STA_KEY_FLG_NO_ENC)
944 priv->stations[sta_id].sta.key.key_offset =
945 iwl_get_free_ucode_key_index(priv);
946 /* else, we are overriding an existing key => no need to allocated room
949 WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET,
950 "no space for a new key");
952 priv->stations[sta_id].sta.key.key_flags = key_flags;
955 /* This copy is acutally not needed: we get the key with each TX */
956 memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, 16);
958 memcpy(priv->stations[sta_id].sta.key.key, keyconf->key, 16);
960 spin_unlock_irqrestore(&priv->sta_lock, flags);
965 void iwl_update_tkip_key(struct iwl_priv *priv,
966 struct ieee80211_key_conf *keyconf,
967 struct ieee80211_sta *sta, u32 iv32, u16 *phase1key)
974 sta_id = iwl_sta_id(sta);
976 if (sta_id == IWL_INVALID_STATION) {
977 IWL_DEBUG_MAC80211(priv, "leave - %pM not initialised.\n",
982 sta_id = priv->hw_params.bcast_sta_id;
985 if (iwl_scan_cancel(priv)) {
986 /* cancel scan failed, just live w/ bad key and rely
987 briefly on SW decryption */
991 spin_lock_irqsave(&priv->sta_lock, flags);
993 priv->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32;
995 for (i = 0; i < 5; i++)
996 priv->stations[sta_id].sta.key.tkip_rx_ttak[i] =
997 cpu_to_le16(phase1key[i]);
999 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
1000 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1002 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
1004 spin_unlock_irqrestore(&priv->sta_lock, flags);
1007 EXPORT_SYMBOL(iwl_update_tkip_key);
1009 int iwl_remove_dynamic_key(struct iwl_priv *priv,
1010 struct ieee80211_key_conf *keyconf,
1013 unsigned long flags;
1018 priv->key_mapping_key--;
1020 spin_lock_irqsave(&priv->sta_lock, flags);
1021 key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags);
1022 keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3;
1024 IWL_DEBUG_WEP(priv, "Remove dynamic key: idx=%d sta=%d\n",
1025 keyconf->keyidx, sta_id);
1027 if (keyconf->keyidx != keyidx) {
1028 /* We need to remove a key with index different that the one
1029 * in the uCode. This means that the key we need to remove has
1030 * been replaced by another one with different index.
1031 * Don't do anything and return ok
1033 spin_unlock_irqrestore(&priv->sta_lock, flags);
1037 if (priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) {
1038 IWL_WARN(priv, "Removing wrong key %d 0x%x\n",
1039 keyconf->keyidx, key_flags);
1040 spin_unlock_irqrestore(&priv->sta_lock, flags);
1044 if (!test_and_clear_bit(priv->stations[sta_id].sta.key.key_offset,
1045 &priv->ucode_key_table))
1046 IWL_ERR(priv, "index %d not used in uCode key table.\n",
1047 priv->stations[sta_id].sta.key.key_offset);
1048 memset(&priv->stations[sta_id].keyinfo, 0,
1049 sizeof(struct iwl_hw_key));
1050 memset(&priv->stations[sta_id].sta.key, 0,
1051 sizeof(struct iwl4965_keyinfo));
1052 priv->stations[sta_id].sta.key.key_flags =
1053 STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID;
1054 priv->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET;
1055 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
1056 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1058 if (iwl_is_rfkill(priv)) {
1059 IWL_DEBUG_WEP(priv, "Not sending REPLY_ADD_STA command because RFKILL enabled.\n");
1060 spin_unlock_irqrestore(&priv->sta_lock, flags);
1063 ret = iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
1064 spin_unlock_irqrestore(&priv->sta_lock, flags);
1067 EXPORT_SYMBOL(iwl_remove_dynamic_key);
1069 int iwl_set_dynamic_key(struct iwl_priv *priv,
1070 struct ieee80211_key_conf *keyconf, u8 sta_id)
1074 priv->key_mapping_key++;
1075 keyconf->hw_key_idx = HW_KEY_DYNAMIC;
1077 switch (keyconf->alg) {
1079 ret = iwl_set_ccmp_dynamic_key_info(priv, keyconf, sta_id);
1082 ret = iwl_set_tkip_dynamic_key_info(priv, keyconf, sta_id);
1085 ret = iwl_set_wep_dynamic_key_info(priv, keyconf, sta_id);
1089 "Unknown alg: %s alg = %d\n", __func__, keyconf->alg);
1093 IWL_DEBUG_WEP(priv, "Set dynamic key: alg= %d len=%d idx=%d sta=%d ret=%d\n",
1094 keyconf->alg, keyconf->keylen, keyconf->keyidx,
1099 EXPORT_SYMBOL(iwl_set_dynamic_key);
1101 #ifdef CONFIG_IWLWIFI_DEBUG
1102 static void iwl_dump_lq_cmd(struct iwl_priv *priv,
1103 struct iwl_link_quality_cmd *lq)
1106 IWL_DEBUG_RATE(priv, "lq station id 0x%x\n", lq->sta_id);
1107 IWL_DEBUG_RATE(priv, "lq ant 0x%X 0x%X\n",
1108 lq->general_params.single_stream_ant_msk,
1109 lq->general_params.dual_stream_ant_msk);
1111 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++)
1112 IWL_DEBUG_RATE(priv, "lq index %d 0x%X\n",
1113 i, lq->rs_table[i].rate_n_flags);
1116 static inline void iwl_dump_lq_cmd(struct iwl_priv *priv,
1117 struct iwl_link_quality_cmd *lq)
1123 * is_lq_table_valid() - Test one aspect of LQ cmd for validity
1125 * It sometimes happens when a HT rate has been in use and we
1126 * loose connectivity with AP then mac80211 will first tell us that the
1127 * current channel is not HT anymore before removing the station. In such a
1128 * scenario the RXON flags will be updated to indicate we are not
1129 * communicating HT anymore, but the LQ command may still contain HT rates.
1130 * Test for this to prevent driver from sending LQ command between the time
1131 * RXON flags are updated and when LQ command is updated.
1133 static bool is_lq_table_valid(struct iwl_priv *priv,
1134 struct iwl_link_quality_cmd *lq)
1137 struct iwl_ht_config *ht_conf = &priv->current_ht_config;
1142 IWL_DEBUG_INFO(priv, "Channel %u is not an HT channel\n",
1143 priv->active_rxon.channel);
1144 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
1145 if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) {
1146 IWL_DEBUG_INFO(priv,
1147 "index %d of LQ expects HT channel\n",
1156 * iwl_send_lq_cmd() - Send link quality command
1157 * @init: This command is sent as part of station initialization right
1158 * after station has been added.
1160 * The link quality command is sent as the last step of station creation.
1161 * This is the special case in which init is set and we call a callback in
1162 * this case to clear the state indicating that station creation is in
1165 int iwl_send_lq_cmd(struct iwl_priv *priv,
1166 struct iwl_link_quality_cmd *lq, u8 flags, bool init)
1169 unsigned long flags_spin;
1171 struct iwl_host_cmd cmd = {
1172 .id = REPLY_TX_LINK_QUALITY_CMD,
1173 .len = sizeof(struct iwl_link_quality_cmd),
1178 if (WARN_ON(lq->sta_id == IWL_INVALID_STATION))
1181 iwl_dump_lq_cmd(priv, lq);
1182 BUG_ON(init && (cmd.flags & CMD_ASYNC));
1184 if (is_lq_table_valid(priv, lq))
1185 ret = iwl_send_cmd(priv, &cmd);
1189 if (cmd.flags & CMD_ASYNC)
1193 IWL_DEBUG_INFO(priv, "init LQ command complete, clearing sta addition status for sta %d\n",
1195 spin_lock_irqsave(&priv->sta_lock, flags_spin);
1196 priv->stations[lq->sta_id].used &= ~IWL_STA_UCODE_INPROGRESS;
1197 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
1201 EXPORT_SYMBOL(iwl_send_lq_cmd);
1204 * iwl_alloc_bcast_station - add broadcast station into driver's station table.
1206 * This adds the broadcast station into the driver's station table
1207 * and marks it driver active, so that it will be restored to the
1208 * device at the next best time.
1210 int iwl_alloc_bcast_station(struct iwl_priv *priv, bool init_lq)
1212 struct iwl_link_quality_cmd *link_cmd;
1213 unsigned long flags;
1216 spin_lock_irqsave(&priv->sta_lock, flags);
1217 sta_id = iwl_prep_station(priv, iwl_bcast_addr, false, NULL);
1218 if (sta_id == IWL_INVALID_STATION) {
1219 IWL_ERR(priv, "Unable to prepare broadcast station\n");
1220 spin_unlock_irqrestore(&priv->sta_lock, flags);
1225 priv->stations[sta_id].used |= IWL_STA_DRIVER_ACTIVE;
1226 priv->stations[sta_id].used |= IWL_STA_BCAST;
1227 spin_unlock_irqrestore(&priv->sta_lock, flags);
1230 link_cmd = iwl_sta_alloc_lq(priv, sta_id);
1233 "Unable to initialize rate scaling for bcast station.\n");
1237 spin_lock_irqsave(&priv->sta_lock, flags);
1238 priv->stations[sta_id].lq = link_cmd;
1239 spin_unlock_irqrestore(&priv->sta_lock, flags);
1244 EXPORT_SYMBOL_GPL(iwl_alloc_bcast_station);
1246 void iwl_dealloc_bcast_station(struct iwl_priv *priv)
1248 unsigned long flags;
1251 spin_lock_irqsave(&priv->sta_lock, flags);
1252 for (i = 0; i < priv->hw_params.max_stations; i++) {
1253 if (!(priv->stations[i].used & IWL_STA_BCAST))
1256 priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE;
1257 priv->num_stations--;
1258 BUG_ON(priv->num_stations < 0);
1259 kfree(priv->stations[i].lq);
1260 priv->stations[i].lq = NULL;
1262 spin_unlock_irqrestore(&priv->sta_lock, flags);
1264 EXPORT_SYMBOL_GPL(iwl_dealloc_bcast_station);
1267 * iwl_sta_tx_modify_enable_tid - Enable Tx for this TID in station table
1269 void iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid)
1271 unsigned long flags;
1273 /* Remove "disable" flag, to enable Tx for this TID */
1274 spin_lock_irqsave(&priv->sta_lock, flags);
1275 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX;
1276 priv->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid));
1277 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1278 spin_unlock_irqrestore(&priv->sta_lock, flags);
1280 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
1282 EXPORT_SYMBOL(iwl_sta_tx_modify_enable_tid);
1284 int iwl_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta,
1287 unsigned long flags;
1290 sta_id = iwl_sta_id(sta);
1291 if (sta_id == IWL_INVALID_STATION)
1294 spin_lock_irqsave(&priv->sta_lock, flags);
1295 priv->stations[sta_id].sta.station_flags_msk = 0;
1296 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK;
1297 priv->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid;
1298 priv->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn);
1299 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1300 spin_unlock_irqrestore(&priv->sta_lock, flags);
1302 return iwl_send_add_sta(priv, &priv->stations[sta_id].sta,
1305 EXPORT_SYMBOL(iwl_sta_rx_agg_start);
1307 int iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta,
1310 unsigned long flags;
1313 sta_id = iwl_sta_id(sta);
1314 if (sta_id == IWL_INVALID_STATION) {
1315 IWL_ERR(priv, "Invalid station for AGG tid %d\n", tid);
1319 spin_lock_irqsave(&priv->sta_lock, flags);
1320 priv->stations[sta_id].sta.station_flags_msk = 0;
1321 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK;
1322 priv->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid;
1323 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1324 spin_unlock_irqrestore(&priv->sta_lock, flags);
1326 return iwl_send_add_sta(priv, &priv->stations[sta_id].sta,
1329 EXPORT_SYMBOL(iwl_sta_rx_agg_stop);
1331 void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id)
1333 unsigned long flags;
1335 spin_lock_irqsave(&priv->sta_lock, flags);
1336 priv->stations[sta_id].sta.station_flags &= ~STA_FLG_PWR_SAVE_MSK;
1337 priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK;
1338 priv->stations[sta_id].sta.sta.modify_mask = 0;
1339 priv->stations[sta_id].sta.sleep_tx_count = 0;
1340 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1341 spin_unlock_irqrestore(&priv->sta_lock, flags);
1343 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
1345 EXPORT_SYMBOL(iwl_sta_modify_ps_wake);
1347 void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt)
1349 unsigned long flags;
1351 spin_lock_irqsave(&priv->sta_lock, flags);
1352 priv->stations[sta_id].sta.station_flags |= STA_FLG_PWR_SAVE_MSK;
1353 priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK;
1354 priv->stations[sta_id].sta.sta.modify_mask =
1355 STA_MODIFY_SLEEP_TX_COUNT_MSK;
1356 priv->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt);
1357 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1358 spin_unlock_irqrestore(&priv->sta_lock, flags);
1360 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
1362 EXPORT_SYMBOL(iwl_sta_modify_sleep_tx_count);
1364 int iwl_mac_sta_remove(struct ieee80211_hw *hw,
1365 struct ieee80211_vif *vif,
1366 struct ieee80211_sta *sta)
1368 struct iwl_priv *priv = hw->priv;
1369 struct iwl_station_priv_common *sta_common = (void *)sta->drv_priv;
1372 IWL_DEBUG_INFO(priv, "received request to remove station %pM\n",
1374 ret = iwl_remove_station(priv, sta_common->sta_id, sta->addr);
1376 IWL_ERR(priv, "Error removing station %pM\n",
1380 EXPORT_SYMBOL(iwl_mac_sta_remove);