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>
37 u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr)
41 int ret = IWL_INVALID_STATION;
44 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) ||
45 (priv->iw_mode == NL80211_IFTYPE_AP))
48 if (is_broadcast_ether_addr(addr))
49 return priv->hw_params.bcast_sta_id;
51 spin_lock_irqsave(&priv->sta_lock, flags);
52 for (i = start; i < priv->hw_params.max_stations; i++)
53 if (priv->stations[i].used &&
54 (!compare_ether_addr(priv->stations[i].sta.sta.addr,
60 IWL_DEBUG_ASSOC_LIMIT(priv, "can not find STA %pM total %d\n",
61 addr, priv->num_stations);
64 spin_unlock_irqrestore(&priv->sta_lock, flags);
67 EXPORT_SYMBOL(iwl_find_station);
69 int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
71 if (priv->iw_mode == NL80211_IFTYPE_STATION) {
74 u8 *da = ieee80211_get_DA(hdr);
75 return iwl_find_station(priv, da);
78 EXPORT_SYMBOL(iwl_get_ra_sta_id);
80 /* priv->sta_lock must be held */
81 static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
84 if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE))
85 IWL_ERR(priv, "ACTIVATE a non DRIVER active station id %u addr %pM\n",
86 sta_id, priv->stations[sta_id].sta.sta.addr);
88 if (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE) {
90 "STA id %u addr %pM already present in uCode (according to driver)\n",
91 sta_id, priv->stations[sta_id].sta.sta.addr);
93 priv->stations[sta_id].used |= IWL_STA_UCODE_ACTIVE;
94 IWL_DEBUG_ASSOC(priv, "Added STA id %u addr %pM to uCode\n",
95 sta_id, priv->stations[sta_id].sta.sta.addr);
99 static void iwl_process_add_sta_resp(struct iwl_priv *priv,
100 struct iwl_addsta_cmd *addsta,
101 struct iwl_rx_packet *pkt,
104 u8 sta_id = addsta->sta.sta_id;
107 if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) {
108 IWL_ERR(priv, "Bad return from REPLY_ADD_STA (0x%08X)\n",
113 IWL_DEBUG_INFO(priv, "Processing response for adding station %u\n",
116 spin_lock_irqsave(&priv->sta_lock, flags);
118 switch (pkt->u.add_sta.status) {
119 case ADD_STA_SUCCESS_MSK:
120 IWL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n");
121 iwl_sta_ucode_activate(priv, sta_id);
123 case ADD_STA_NO_ROOM_IN_TABLE:
124 IWL_ERR(priv, "Adding station %d failed, no room in table.\n",
127 case ADD_STA_NO_BLOCK_ACK_RESOURCE:
128 IWL_ERR(priv, "Adding station %d failed, no block ack resource.\n",
131 case ADD_STA_MODIFY_NON_EXIST_STA:
132 IWL_ERR(priv, "Attempting to modify non-existing station %d \n",
136 IWL_DEBUG_ASSOC(priv, "Received REPLY_ADD_STA:(0x%08X)\n",
137 pkt->u.add_sta.status);
141 IWL_DEBUG_INFO(priv, "%s station id %u addr %pM\n",
142 priv->stations[sta_id].sta.mode ==
143 STA_CONTROL_MODIFY_MSK ? "Modified" : "Added",
144 sta_id, priv->stations[sta_id].sta.sta.addr);
147 * XXX: The MAC address in the command buffer is often changed from
148 * the original sent to the device. That is, the MAC address
149 * written to the command buffer often is not the same MAC adress
150 * read from the command buffer when the command returns. This
151 * issue has not yet been resolved and this debugging is left to
152 * observe the problem.
154 IWL_DEBUG_INFO(priv, "%s station according to cmd buffer %pM\n",
155 priv->stations[sta_id].sta.mode ==
156 STA_CONTROL_MODIFY_MSK ? "Modified" : "Added",
160 * Determine if we wanted to modify or add a station,
161 * if adding a station succeeded we have some more initialization
162 * to do when using station notification. TODO
165 spin_unlock_irqrestore(&priv->sta_lock, flags);
168 static void iwl_add_sta_callback(struct iwl_priv *priv,
169 struct iwl_device_cmd *cmd,
170 struct iwl_rx_packet *pkt)
172 struct iwl_addsta_cmd *addsta =
173 (struct iwl_addsta_cmd *)cmd->cmd.payload;
175 iwl_process_add_sta_resp(priv, addsta, pkt, false);
179 int iwl_send_add_sta(struct iwl_priv *priv,
180 struct iwl_addsta_cmd *sta, u8 flags)
182 struct iwl_rx_packet *pkt = NULL;
184 u8 data[sizeof(*sta)];
185 struct iwl_host_cmd cmd = {
191 if (flags & CMD_ASYNC)
192 cmd.callback = iwl_add_sta_callback;
194 cmd.flags |= CMD_WANT_SKB;
196 cmd.len = priv->cfg->ops->utils->build_addsta_hcmd(sta, data);
197 ret = iwl_send_cmd(priv, &cmd);
199 if (ret || (flags & CMD_ASYNC))
203 pkt = (struct iwl_rx_packet *)cmd.reply_page;
204 iwl_process_add_sta_resp(priv, sta, pkt, true);
206 iwl_free_pages(priv, cmd.reply_page);
210 EXPORT_SYMBOL(iwl_send_add_sta);
212 static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
213 struct ieee80211_sta_ht_cap *sta_ht_inf)
218 if (!sta_ht_inf || !sta_ht_inf->ht_supported)
221 mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2;
222 IWL_DEBUG_ASSOC(priv, "spatial multiplexing power save mode: %s\n",
223 (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ?
225 (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ?
226 "dynamic" : "disabled");
228 sta_flags = priv->stations[index].sta.station_flags;
230 sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK);
232 switch (mimo_ps_mode) {
233 case WLAN_HT_CAP_SM_PS_STATIC:
234 sta_flags |= STA_FLG_MIMO_DIS_MSK;
236 case WLAN_HT_CAP_SM_PS_DYNAMIC:
237 sta_flags |= STA_FLG_RTS_MIMO_PROT_MSK;
239 case WLAN_HT_CAP_SM_PS_DISABLED:
242 IWL_WARN(priv, "Invalid MIMO PS mode %d\n", mimo_ps_mode);
246 sta_flags |= cpu_to_le32(
247 (u32)sta_ht_inf->ampdu_factor << STA_FLG_MAX_AGG_SIZE_POS);
249 sta_flags |= cpu_to_le32(
250 (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS);
252 if (iwl_is_ht40_tx_allowed(priv, sta_ht_inf))
253 sta_flags |= STA_FLG_HT40_EN_MSK;
255 sta_flags &= ~STA_FLG_HT40_EN_MSK;
257 priv->stations[index].sta.station_flags = sta_flags;
263 * iwl_add_station - Add station to tables in driver and device
265 u8 iwl_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap, u8 flags,
266 struct ieee80211_sta_ht_cap *ht_info)
268 struct iwl_station_entry *station;
269 unsigned long flags_spin;
271 int sta_id = IWL_INVALID_STATION;
274 spin_lock_irqsave(&priv->sta_lock, flags_spin);
277 else if (is_broadcast_ether_addr(addr))
278 sta_id = priv->hw_params.bcast_sta_id;
280 for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) {
281 if (!compare_ether_addr(priv->stations[i].sta.sta.addr,
287 if (!priv->stations[i].used &&
288 sta_id == IWL_INVALID_STATION)
292 /* These two conditions have the same outcome, but keep them separate
293 since they have different meanings */
294 if (unlikely(sta_id == IWL_INVALID_STATION)) {
295 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
299 if (priv->stations[sta_id].used &&
300 !compare_ether_addr(priv->stations[sta_id].sta.sta.addr, addr)) {
301 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
306 station = &priv->stations[sta_id];
307 station->used = IWL_STA_DRIVER_ACTIVE;
308 IWL_DEBUG_ASSOC(priv, "Add STA to driver ID %d: %pM\n",
310 priv->num_stations++;
312 /* Set up the REPLY_ADD_STA command to send to device */
313 memset(&station->sta, 0, sizeof(struct iwl_addsta_cmd));
314 memcpy(station->sta.sta.addr, addr, ETH_ALEN);
315 station->sta.mode = 0;
316 station->sta.sta.sta_id = sta_id;
317 station->sta.station_flags = 0;
319 /* BCAST station and IBSS stations do not work in HT mode */
320 if (sta_id != priv->hw_params.bcast_sta_id &&
321 priv->iw_mode != NL80211_IFTYPE_ADHOC)
322 iwl_set_ht_add_station(priv, sta_id, ht_info);
325 rate = (priv->band == IEEE80211_BAND_5GHZ) ?
326 IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP;
327 /* Turn on both antennas for the station... */
328 station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK);
330 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
332 /* Add station to device's station table */
333 iwl_send_add_sta(priv, &station->sta, flags);
337 EXPORT_SYMBOL(iwl_add_station);
339 static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, const u8 *addr)
342 u8 sta_id = iwl_find_station(priv, addr);
344 BUG_ON(sta_id == IWL_INVALID_STATION);
346 IWL_DEBUG_ASSOC(priv, "Removed STA from Ucode: %pM\n", addr);
348 spin_lock_irqsave(&priv->sta_lock, flags);
350 /* Ucode must be active and driver must be non active */
351 if (priv->stations[sta_id].used != IWL_STA_UCODE_ACTIVE)
352 IWL_ERR(priv, "removed non active STA %d\n", sta_id);
354 priv->stations[sta_id].used &= ~IWL_STA_UCODE_ACTIVE;
356 memset(&priv->stations[sta_id], 0, sizeof(struct iwl_station_entry));
357 spin_unlock_irqrestore(&priv->sta_lock, flags);
360 static void iwl_remove_sta_callback(struct iwl_priv *priv,
361 struct iwl_device_cmd *cmd,
362 struct iwl_rx_packet *pkt)
364 struct iwl_rem_sta_cmd *rm_sta =
365 (struct iwl_rem_sta_cmd *)cmd->cmd.payload;
366 const u8 *addr = rm_sta->addr;
368 if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) {
369 IWL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n",
374 switch (pkt->u.rem_sta.status) {
375 case REM_STA_SUCCESS_MSK:
376 iwl_sta_ucode_deactivate(priv, addr);
379 IWL_ERR(priv, "REPLY_REMOVE_STA failed\n");
384 static int iwl_send_remove_station(struct iwl_priv *priv, const u8 *addr,
387 struct iwl_rx_packet *pkt;
390 struct iwl_rem_sta_cmd rm_sta_cmd;
392 struct iwl_host_cmd cmd = {
393 .id = REPLY_REMOVE_STA,
394 .len = sizeof(struct iwl_rem_sta_cmd),
399 memset(&rm_sta_cmd, 0, sizeof(rm_sta_cmd));
400 rm_sta_cmd.num_sta = 1;
401 memcpy(&rm_sta_cmd.addr, addr , ETH_ALEN);
403 if (flags & CMD_ASYNC)
404 cmd.callback = iwl_remove_sta_callback;
406 cmd.flags |= CMD_WANT_SKB;
407 ret = iwl_send_cmd(priv, &cmd);
409 if (ret || (flags & CMD_ASYNC))
412 pkt = (struct iwl_rx_packet *)cmd.reply_page;
413 if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) {
414 IWL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n",
420 switch (pkt->u.rem_sta.status) {
421 case REM_STA_SUCCESS_MSK:
422 iwl_sta_ucode_deactivate(priv, addr);
423 IWL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n");
427 IWL_ERR(priv, "REPLY_REMOVE_STA failed\n");
431 iwl_free_pages(priv, cmd.reply_page);
437 * iwl_remove_station - Remove driver's knowledge of station.
439 int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, bool is_ap)
441 int sta_id = IWL_INVALID_STATION;
442 int i, ret = -EINVAL;
445 spin_lock_irqsave(&priv->sta_lock, flags);
449 else if (is_broadcast_ether_addr(addr))
450 sta_id = priv->hw_params.bcast_sta_id;
452 for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++)
453 if (priv->stations[i].used &&
454 !compare_ether_addr(priv->stations[i].sta.sta.addr,
460 if (unlikely(sta_id == IWL_INVALID_STATION))
463 IWL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n",
466 if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) {
467 IWL_ERR(priv, "Removing %pM but non DRIVER active\n",
472 if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) {
473 IWL_ERR(priv, "Removing %pM but non UCODE active\n",
479 priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE;
481 priv->num_stations--;
483 BUG_ON(priv->num_stations < 0);
485 spin_unlock_irqrestore(&priv->sta_lock, flags);
487 ret = iwl_send_remove_station(priv, addr, CMD_ASYNC);
490 spin_unlock_irqrestore(&priv->sta_lock, flags);
495 * iwl_clear_ucode_stations() - clear entire station table driver and/or ucode
497 * @force: If set then the uCode station table needs to be cleared here. If
498 * not set then the uCode station table has already been cleared,
499 * for example after sending it a RXON command without ASSOC bit
500 * set, and we just need to change driver state here.
502 void iwl_clear_ucode_stations(struct iwl_priv *priv, bool force)
505 unsigned long flags_spin;
506 bool cleared = false;
508 IWL_DEBUG_INFO(priv, "Clearing ucode stations in driver%s\n",
509 force ? " and ucode" : "");
512 if (!iwl_is_ready(priv)) {
514 * If device is not ready at this point the station
515 * table is likely already empty (uCode not ready
516 * to receive station requests) or will soon be
517 * due to interface going down.
519 IWL_DEBUG_INFO(priv, "Unable to remove stations from device - device not ready\n");
521 iwl_send_cmd_pdu_async(priv, REPLY_REMOVE_ALL_STA, 0, NULL, NULL);
525 spin_lock_irqsave(&priv->sta_lock, flags_spin);
527 IWL_DEBUG_INFO(priv, "Clearing all station information in driver\n");
528 priv->num_stations = 0;
529 memset(priv->stations, 0, sizeof(priv->stations));
531 for (i = 0; i < priv->hw_params.max_stations; i++) {
532 if (priv->stations[i].used & IWL_STA_UCODE_ACTIVE) {
533 IWL_DEBUG_INFO(priv, "Clearing ucode active for station %d \n", i);
534 priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE;
539 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
542 IWL_DEBUG_INFO(priv, "No active stations found to be cleared\n");
544 EXPORT_SYMBOL(iwl_clear_ucode_stations);
547 * iwl_restore_stations() - Restore driver known stations to device
549 * All stations considered active by driver, but not present in ucode, is
552 void iwl_restore_stations(struct iwl_priv *priv)
554 unsigned long flags_spin;
558 if (!iwl_is_ready(priv)) {
559 IWL_DEBUG_INFO(priv, "Not ready yet, not restoring any stations.\n");
563 IWL_DEBUG_ASSOC(priv, "Restoring all known stations ... start.\n");
564 spin_lock_irqsave(&priv->sta_lock, flags_spin);
565 for (i = 0; i < priv->hw_params.max_stations; i++) {
566 if ((priv->stations[i].used & IWL_STA_DRIVER_ACTIVE) &&
567 !(priv->stations[i].used & IWL_STA_UCODE_ACTIVE)) {
568 IWL_DEBUG_ASSOC(priv, "Restoring sta %pM\n",
569 priv->stations[i].sta.sta.addr);
570 priv->stations[i].sta.mode = 0;
571 priv->stations[i].used |= IWL_STA_UCODE_INPROGRESS;
576 for (i = 0; i < priv->hw_params.max_stations; i++) {
577 if ((priv->stations[i].used & IWL_STA_UCODE_INPROGRESS)) {
578 iwl_send_add_sta(priv, &priv->stations[i].sta,
580 priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS;
584 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
586 IWL_DEBUG_INFO(priv, "Restoring all known stations .... no stations to be restored.\n");
588 IWL_DEBUG_INFO(priv, "Restoring all known stations .... in progress.\n");
590 EXPORT_SYMBOL(iwl_restore_stations);
592 int iwl_get_free_ucode_key_index(struct iwl_priv *priv)
596 for (i = 0; i < STA_KEY_MAX_NUM; i++)
597 if (!test_and_set_bit(i, &priv->ucode_key_table))
600 return WEP_INVALID_OFFSET;
602 EXPORT_SYMBOL(iwl_get_free_ucode_key_index);
604 int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty)
606 int i, not_empty = 0;
607 u8 buff[sizeof(struct iwl_wep_cmd) +
608 sizeof(struct iwl_wep_key) * WEP_KEYS_MAX];
609 struct iwl_wep_cmd *wep_cmd = (struct iwl_wep_cmd *)buff;
610 size_t cmd_size = sizeof(struct iwl_wep_cmd);
611 struct iwl_host_cmd cmd = {
619 memset(wep_cmd, 0, cmd_size +
620 (sizeof(struct iwl_wep_key) * WEP_KEYS_MAX));
622 for (i = 0; i < WEP_KEYS_MAX ; i++) {
623 wep_cmd->key[i].key_index = i;
624 if (priv->wep_keys[i].key_size) {
625 wep_cmd->key[i].key_offset = i;
628 wep_cmd->key[i].key_offset = WEP_INVALID_OFFSET;
631 wep_cmd->key[i].key_size = priv->wep_keys[i].key_size;
632 memcpy(&wep_cmd->key[i].key[3], priv->wep_keys[i].key,
633 priv->wep_keys[i].key_size);
636 wep_cmd->global_key_type = WEP_KEY_WEP_TYPE;
637 wep_cmd->num_keys = WEP_KEYS_MAX;
639 cmd_size += sizeof(struct iwl_wep_key) * WEP_KEYS_MAX;
643 if (not_empty || send_if_empty)
644 return iwl_send_cmd(priv, &cmd);
648 EXPORT_SYMBOL(iwl_send_static_wepkey_cmd);
650 int iwl_remove_default_wep_key(struct iwl_priv *priv,
651 struct ieee80211_key_conf *keyconf)
655 WARN_ON(!mutex_is_locked(&priv->mutex));
657 IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n",
660 if (!test_and_clear_bit(keyconf->keyidx, &priv->ucode_key_table))
661 IWL_ERR(priv, "index %d not used in uCode key table.\n",
664 priv->default_wep_key--;
665 memset(&priv->wep_keys[keyconf->keyidx], 0, sizeof(priv->wep_keys[0]));
666 if (iwl_is_rfkill(priv)) {
667 IWL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n");
668 /* but keys in device are clear anyway so return success */
671 ret = iwl_send_static_wepkey_cmd(priv, 1);
672 IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n",
673 keyconf->keyidx, ret);
677 EXPORT_SYMBOL(iwl_remove_default_wep_key);
679 int iwl_set_default_wep_key(struct iwl_priv *priv,
680 struct ieee80211_key_conf *keyconf)
684 WARN_ON(!mutex_is_locked(&priv->mutex));
686 if (keyconf->keylen != WEP_KEY_LEN_128 &&
687 keyconf->keylen != WEP_KEY_LEN_64) {
688 IWL_DEBUG_WEP(priv, "Bad WEP key length %d\n", keyconf->keylen);
692 keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV;
693 keyconf->hw_key_idx = HW_KEY_DEFAULT;
694 priv->stations[IWL_AP_ID].keyinfo.alg = ALG_WEP;
696 priv->default_wep_key++;
698 if (test_and_set_bit(keyconf->keyidx, &priv->ucode_key_table))
699 IWL_ERR(priv, "index %d already used in uCode key table.\n",
702 priv->wep_keys[keyconf->keyidx].key_size = keyconf->keylen;
703 memcpy(&priv->wep_keys[keyconf->keyidx].key, &keyconf->key,
706 ret = iwl_send_static_wepkey_cmd(priv, 0);
707 IWL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n",
708 keyconf->keylen, keyconf->keyidx, ret);
712 EXPORT_SYMBOL(iwl_set_default_wep_key);
714 static int iwl_set_wep_dynamic_key_info(struct iwl_priv *priv,
715 struct ieee80211_key_conf *keyconf,
719 __le16 key_flags = 0;
722 keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV;
724 key_flags |= (STA_KEY_FLG_WEP | STA_KEY_FLG_MAP_KEY_MSK);
725 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
726 key_flags &= ~STA_KEY_FLG_INVALID;
728 if (keyconf->keylen == WEP_KEY_LEN_128)
729 key_flags |= STA_KEY_FLG_KEY_SIZE_MSK;
731 if (sta_id == priv->hw_params.bcast_sta_id)
732 key_flags |= STA_KEY_MULTICAST_MSK;
734 spin_lock_irqsave(&priv->sta_lock, flags);
736 priv->stations[sta_id].keyinfo.alg = keyconf->alg;
737 priv->stations[sta_id].keyinfo.keylen = keyconf->keylen;
738 priv->stations[sta_id].keyinfo.keyidx = keyconf->keyidx;
740 memcpy(priv->stations[sta_id].keyinfo.key,
741 keyconf->key, keyconf->keylen);
743 memcpy(&priv->stations[sta_id].sta.key.key[3],
744 keyconf->key, keyconf->keylen);
746 if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK)
747 == STA_KEY_FLG_NO_ENC)
748 priv->stations[sta_id].sta.key.key_offset =
749 iwl_get_free_ucode_key_index(priv);
750 /* else, we are overriding an existing key => no need to allocated room
753 WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET,
754 "no space for a new key");
756 priv->stations[sta_id].sta.key.key_flags = key_flags;
757 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
758 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
760 ret = iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
762 spin_unlock_irqrestore(&priv->sta_lock, flags);
767 static int iwl_set_ccmp_dynamic_key_info(struct iwl_priv *priv,
768 struct ieee80211_key_conf *keyconf,
772 __le16 key_flags = 0;
775 key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK);
776 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
777 key_flags &= ~STA_KEY_FLG_INVALID;
779 if (sta_id == priv->hw_params.bcast_sta_id)
780 key_flags |= STA_KEY_MULTICAST_MSK;
782 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
784 spin_lock_irqsave(&priv->sta_lock, flags);
785 priv->stations[sta_id].keyinfo.alg = keyconf->alg;
786 priv->stations[sta_id].keyinfo.keylen = keyconf->keylen;
788 memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key,
791 memcpy(priv->stations[sta_id].sta.key.key, keyconf->key,
794 if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK)
795 == STA_KEY_FLG_NO_ENC)
796 priv->stations[sta_id].sta.key.key_offset =
797 iwl_get_free_ucode_key_index(priv);
798 /* else, we are overriding an existing key => no need to allocated room
801 WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET,
802 "no space for a new key");
804 priv->stations[sta_id].sta.key.key_flags = key_flags;
805 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
806 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
808 ret = iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
810 spin_unlock_irqrestore(&priv->sta_lock, flags);
815 static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
816 struct ieee80211_key_conf *keyconf,
821 __le16 key_flags = 0;
823 key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK);
824 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
825 key_flags &= ~STA_KEY_FLG_INVALID;
827 if (sta_id == priv->hw_params.bcast_sta_id)
828 key_flags |= STA_KEY_MULTICAST_MSK;
830 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
831 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
833 spin_lock_irqsave(&priv->sta_lock, flags);
835 priv->stations[sta_id].keyinfo.alg = keyconf->alg;
836 priv->stations[sta_id].keyinfo.keylen = 16;
838 if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK)
839 == STA_KEY_FLG_NO_ENC)
840 priv->stations[sta_id].sta.key.key_offset =
841 iwl_get_free_ucode_key_index(priv);
842 /* else, we are overriding an existing key => no need to allocated room
845 WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET,
846 "no space for a new key");
848 priv->stations[sta_id].sta.key.key_flags = key_flags;
851 /* This copy is acutally not needed: we get the key with each TX */
852 memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, 16);
854 memcpy(priv->stations[sta_id].sta.key.key, keyconf->key, 16);
856 spin_unlock_irqrestore(&priv->sta_lock, flags);
861 void iwl_update_tkip_key(struct iwl_priv *priv,
862 struct ieee80211_key_conf *keyconf,
863 const u8 *addr, u32 iv32, u16 *phase1key)
865 u8 sta_id = IWL_INVALID_STATION;
869 sta_id = iwl_find_station(priv, addr);
870 if (sta_id == IWL_INVALID_STATION) {
871 IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
876 if (iwl_scan_cancel(priv)) {
877 /* cancel scan failed, just live w/ bad key and rely
878 briefly on SW decryption */
882 spin_lock_irqsave(&priv->sta_lock, flags);
884 priv->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32;
886 for (i = 0; i < 5; i++)
887 priv->stations[sta_id].sta.key.tkip_rx_ttak[i] =
888 cpu_to_le16(phase1key[i]);
890 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
891 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
893 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
895 spin_unlock_irqrestore(&priv->sta_lock, flags);
898 EXPORT_SYMBOL(iwl_update_tkip_key);
900 int iwl_remove_dynamic_key(struct iwl_priv *priv,
901 struct ieee80211_key_conf *keyconf,
909 priv->key_mapping_key--;
911 spin_lock_irqsave(&priv->sta_lock, flags);
912 key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags);
913 keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3;
915 IWL_DEBUG_WEP(priv, "Remove dynamic key: idx=%d sta=%d\n",
916 keyconf->keyidx, sta_id);
918 if (keyconf->keyidx != keyidx) {
919 /* We need to remove a key with index different that the one
920 * in the uCode. This means that the key we need to remove has
921 * been replaced by another one with different index.
922 * Don't do anything and return ok
924 spin_unlock_irqrestore(&priv->sta_lock, flags);
928 if (priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) {
929 IWL_WARN(priv, "Removing wrong key %d 0x%x\n",
930 keyconf->keyidx, key_flags);
931 spin_unlock_irqrestore(&priv->sta_lock, flags);
935 if (!test_and_clear_bit(priv->stations[sta_id].sta.key.key_offset,
936 &priv->ucode_key_table))
937 IWL_ERR(priv, "index %d not used in uCode key table.\n",
938 priv->stations[sta_id].sta.key.key_offset);
939 memset(&priv->stations[sta_id].keyinfo, 0,
940 sizeof(struct iwl_hw_key));
941 memset(&priv->stations[sta_id].sta.key, 0,
942 sizeof(struct iwl4965_keyinfo));
943 priv->stations[sta_id].sta.key.key_flags =
944 STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID;
945 priv->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET;
946 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
947 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
949 if (iwl_is_rfkill(priv)) {
950 IWL_DEBUG_WEP(priv, "Not sending REPLY_ADD_STA command because RFKILL enabled. \n");
951 spin_unlock_irqrestore(&priv->sta_lock, flags);
954 ret = iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
955 spin_unlock_irqrestore(&priv->sta_lock, flags);
958 EXPORT_SYMBOL(iwl_remove_dynamic_key);
960 int iwl_set_dynamic_key(struct iwl_priv *priv,
961 struct ieee80211_key_conf *keyconf, u8 sta_id)
965 priv->key_mapping_key++;
966 keyconf->hw_key_idx = HW_KEY_DYNAMIC;
968 switch (keyconf->alg) {
970 ret = iwl_set_ccmp_dynamic_key_info(priv, keyconf, sta_id);
973 ret = iwl_set_tkip_dynamic_key_info(priv, keyconf, sta_id);
976 ret = iwl_set_wep_dynamic_key_info(priv, keyconf, sta_id);
980 "Unknown alg: %s alg = %d\n", __func__, keyconf->alg);
984 IWL_DEBUG_WEP(priv, "Set dynamic key: alg= %d len=%d idx=%d sta=%d ret=%d\n",
985 keyconf->alg, keyconf->keylen, keyconf->keyidx,
990 EXPORT_SYMBOL(iwl_set_dynamic_key);
992 #ifdef CONFIG_IWLWIFI_DEBUG
993 static void iwl_dump_lq_cmd(struct iwl_priv *priv,
994 struct iwl_link_quality_cmd *lq)
997 IWL_DEBUG_RATE(priv, "lq station id 0x%x\n", lq->sta_id);
998 IWL_DEBUG_RATE(priv, "lq ant 0x%X 0x%X\n",
999 lq->general_params.single_stream_ant_msk,
1000 lq->general_params.dual_stream_ant_msk);
1002 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++)
1003 IWL_DEBUG_RATE(priv, "lq index %d 0x%X\n",
1004 i, lq->rs_table[i].rate_n_flags);
1007 static inline void iwl_dump_lq_cmd(struct iwl_priv *priv,
1008 struct iwl_link_quality_cmd *lq)
1013 int iwl_send_lq_cmd(struct iwl_priv *priv,
1014 struct iwl_link_quality_cmd *lq, u8 flags)
1016 struct iwl_host_cmd cmd = {
1017 .id = REPLY_TX_LINK_QUALITY_CMD,
1018 .len = sizeof(struct iwl_link_quality_cmd),
1023 if ((lq->sta_id == 0xFF) &&
1024 (priv->iw_mode == NL80211_IFTYPE_ADHOC))
1027 if (lq->sta_id == 0xFF)
1028 lq->sta_id = IWL_AP_ID;
1030 iwl_dump_lq_cmd(priv, lq);
1032 if (iwl_is_associated(priv) && priv->assoc_station_added)
1033 return iwl_send_cmd(priv, &cmd);
1037 EXPORT_SYMBOL(iwl_send_lq_cmd);
1040 * iwl_sta_init_lq - Initialize a station's hardware rate table
1042 * The uCode's station table contains a table of fallback rates
1043 * for automatic fallback during transmission.
1045 * NOTE: This sets up a default set of values. These will be replaced later
1046 * if the driver's iwl-agn-rs rate scaling algorithm is used, instead of
1049 * NOTE: Run REPLY_ADD_STA command to set up station table entry, before
1050 * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD,
1051 * which requires station table entry to exist).
1053 static void iwl_sta_init_lq(struct iwl_priv *priv, const u8 *addr, bool is_ap)
1056 struct iwl_link_quality_cmd link_cmd = {
1061 /* Set up the rate scaling to start at selected rate, fall back
1062 * all the way down to 1M in IEEE order, and then spin on 1M */
1064 r = IWL_RATE_54M_INDEX;
1065 else if (priv->band == IEEE80211_BAND_5GHZ)
1066 r = IWL_RATE_6M_INDEX;
1068 r = IWL_RATE_1M_INDEX;
1070 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
1072 if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE)
1073 rate_flags |= RATE_MCS_CCK_MSK;
1075 rate_flags |= first_antenna(priv->hw_params.valid_tx_ant) <<
1078 link_cmd.rs_table[i].rate_n_flags =
1079 iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags);
1080 r = iwl_get_prev_ieee_rate(r);
1083 link_cmd.general_params.single_stream_ant_msk =
1084 first_antenna(priv->hw_params.valid_tx_ant);
1085 link_cmd.general_params.dual_stream_ant_msk = 3;
1086 link_cmd.agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF;
1087 link_cmd.agg_params.agg_time_limit =
1088 cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF);
1090 /* Update the rate scaling for control frame Tx to AP */
1091 link_cmd.sta_id = is_ap ? IWL_AP_ID : priv->hw_params.bcast_sta_id;
1093 iwl_send_cmd_pdu_async(priv, REPLY_TX_LINK_QUALITY_CMD,
1094 sizeof(link_cmd), &link_cmd, NULL);
1098 * iwl_rxon_add_station - add station into station table.
1100 * there is only one AP station with id= IWL_AP_ID
1101 * NOTE: mutex must be held before calling this function
1103 int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap)
1105 struct ieee80211_sta *sta;
1106 struct ieee80211_sta_ht_cap ht_config;
1107 struct ieee80211_sta_ht_cap *cur_ht_config = NULL;
1111 * Set HT capabilities. It is ok to set this struct even if not using
1112 * HT config: the priv->current_ht_config.is_ht flag will just be false
1115 sta = ieee80211_find_sta(priv->vif, addr);
1117 memcpy(&ht_config, &sta->ht_cap, sizeof(ht_config));
1118 cur_ht_config = &ht_config;
1122 /* Add station to device's station table */
1123 sta_id = iwl_add_station(priv, addr, is_ap, CMD_SYNC, cur_ht_config);
1125 /* Set up default rate scaling table in device's station table */
1126 iwl_sta_init_lq(priv, addr, is_ap);
1130 EXPORT_SYMBOL(iwl_rxon_add_station);
1133 * iwl_sta_init_bcast_lq - Initialize a bcast station's hardware rate table
1135 * NOTE: Run REPLY_ADD_STA command to set up station table entry, before
1136 * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD,
1137 * which requires station table entry to exist).
1139 static void iwl_sta_init_bcast_lq(struct iwl_priv *priv)
1142 struct iwl_link_quality_cmd link_cmd = {
1147 /* Set up the rate scaling to start at selected rate, fall back
1148 * all the way down to 1M in IEEE order, and then spin on 1M */
1149 if (priv->band == IEEE80211_BAND_5GHZ)
1150 r = IWL_RATE_6M_INDEX;
1152 r = IWL_RATE_1M_INDEX;
1154 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
1156 if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE)
1157 rate_flags |= RATE_MCS_CCK_MSK;
1159 rate_flags |= first_antenna(priv->hw_params.valid_tx_ant) <<
1162 link_cmd.rs_table[i].rate_n_flags =
1163 iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags);
1164 r = iwl_get_prev_ieee_rate(r);
1167 link_cmd.general_params.single_stream_ant_msk =
1168 first_antenna(priv->hw_params.valid_tx_ant);
1169 link_cmd.general_params.dual_stream_ant_msk = 3;
1170 link_cmd.agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF;
1171 link_cmd.agg_params.agg_time_limit =
1172 cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF);
1174 /* Update the rate scaling for control frame Tx to AP */
1175 link_cmd.sta_id = priv->hw_params.bcast_sta_id;
1177 iwl_send_cmd_pdu_async(priv, REPLY_TX_LINK_QUALITY_CMD,
1178 sizeof(link_cmd), &link_cmd, NULL);
1183 * iwl_add_bcast_station - add broadcast station into station table.
1185 void iwl_add_bcast_station(struct iwl_priv *priv)
1187 IWL_DEBUG_INFO(priv, "Adding broadcast station to station table\n");
1188 iwl_add_station(priv, iwl_bcast_addr, false, CMD_SYNC, NULL);
1190 /* Set up default rate scaling table in device's station table */
1191 iwl_sta_init_bcast_lq(priv);
1193 EXPORT_SYMBOL(iwl_add_bcast_station);
1196 * iwl3945_add_bcast_station - add broadcast station into station table.
1198 void iwl3945_add_bcast_station(struct iwl_priv *priv)
1200 IWL_DEBUG_INFO(priv, "Adding broadcast station to station table\n");
1201 iwl_add_station(priv, iwl_bcast_addr, false, CMD_SYNC, NULL);
1203 EXPORT_SYMBOL(iwl3945_add_bcast_station);
1206 * iwl_get_sta_id - Find station's index within station table
1208 * If new IBSS station, create new entry in station table
1210 int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
1213 __le16 fc = hdr->frame_control;
1215 /* If this frame is broadcast or management, use broadcast station id */
1216 if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1))
1217 return priv->hw_params.bcast_sta_id;
1219 switch (priv->iw_mode) {
1221 /* If we are a client station in a BSS network, use the special
1222 * AP station entry (that's the only station we communicate with) */
1223 case NL80211_IFTYPE_STATION:
1226 /* If we are an AP, then find the station, or use BCAST */
1227 case NL80211_IFTYPE_AP:
1228 sta_id = iwl_find_station(priv, hdr->addr1);
1229 if (sta_id != IWL_INVALID_STATION)
1231 return priv->hw_params.bcast_sta_id;
1233 /* If this frame is going out to an IBSS network, find the station,
1234 * or create a new station table entry */
1235 case NL80211_IFTYPE_ADHOC:
1236 sta_id = iwl_find_station(priv, hdr->addr1);
1237 if (sta_id != IWL_INVALID_STATION)
1240 /* Create new station table entry */
1241 sta_id = iwl_add_station(priv, hdr->addr1, false,
1244 if (sta_id != IWL_INVALID_STATION)
1247 IWL_DEBUG_DROP(priv, "Station %pM not in station map. "
1248 "Defaulting to broadcast...\n",
1250 iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr));
1251 return priv->hw_params.bcast_sta_id;
1254 IWL_WARN(priv, "Unknown mode of operation: %d\n",
1256 return priv->hw_params.bcast_sta_id;
1259 EXPORT_SYMBOL(iwl_get_sta_id);
1262 * iwl_sta_tx_modify_enable_tid - Enable Tx for this TID in station table
1264 void iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid)
1266 unsigned long flags;
1268 /* Remove "disable" flag, to enable Tx for this TID */
1269 spin_lock_irqsave(&priv->sta_lock, flags);
1270 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX;
1271 priv->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid));
1272 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1273 spin_unlock_irqrestore(&priv->sta_lock, flags);
1275 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
1277 EXPORT_SYMBOL(iwl_sta_tx_modify_enable_tid);
1279 int iwl_sta_rx_agg_start(struct iwl_priv *priv,
1280 const u8 *addr, int tid, u16 ssn)
1282 unsigned long flags;
1285 sta_id = iwl_find_station(priv, addr);
1286 if (sta_id == IWL_INVALID_STATION)
1289 spin_lock_irqsave(&priv->sta_lock, flags);
1290 priv->stations[sta_id].sta.station_flags_msk = 0;
1291 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK;
1292 priv->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid;
1293 priv->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn);
1294 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1295 spin_unlock_irqrestore(&priv->sta_lock, flags);
1297 return iwl_send_add_sta(priv, &priv->stations[sta_id].sta,
1300 EXPORT_SYMBOL(iwl_sta_rx_agg_start);
1302 int iwl_sta_rx_agg_stop(struct iwl_priv *priv, const u8 *addr, int tid)
1304 unsigned long flags;
1307 sta_id = iwl_find_station(priv, addr);
1308 if (sta_id == IWL_INVALID_STATION) {
1309 IWL_ERR(priv, "Invalid station for AGG tid %d\n", tid);
1313 spin_lock_irqsave(&priv->sta_lock, flags);
1314 priv->stations[sta_id].sta.station_flags_msk = 0;
1315 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK;
1316 priv->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid;
1317 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1318 spin_unlock_irqrestore(&priv->sta_lock, flags);
1320 return iwl_send_add_sta(priv, &priv->stations[sta_id].sta,
1323 EXPORT_SYMBOL(iwl_sta_rx_agg_stop);
1325 void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id)
1327 unsigned long flags;
1329 spin_lock_irqsave(&priv->sta_lock, flags);
1330 priv->stations[sta_id].sta.station_flags &= ~STA_FLG_PWR_SAVE_MSK;
1331 priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK;
1332 priv->stations[sta_id].sta.sta.modify_mask = 0;
1333 priv->stations[sta_id].sta.sleep_tx_count = 0;
1334 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1335 spin_unlock_irqrestore(&priv->sta_lock, flags);
1337 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
1339 EXPORT_SYMBOL(iwl_sta_modify_ps_wake);
1341 void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt)
1343 unsigned long flags;
1345 spin_lock_irqsave(&priv->sta_lock, flags);
1346 priv->stations[sta_id].sta.station_flags |= STA_FLG_PWR_SAVE_MSK;
1347 priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK;
1348 priv->stations[sta_id].sta.sta.modify_mask =
1349 STA_MODIFY_SLEEP_TX_COUNT_MSK;
1350 priv->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt);
1351 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1352 spin_unlock_irqrestore(&priv->sta_lock, flags);
1354 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);