2008-04-15 12:16:06 +08:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2010-01-16 05:43:41 +08:00
|
|
|
* Copyright(c) 2003 - 2010 Intel Corporation. All rights reserved.
|
2008-04-15 12:16:06 +08:00
|
|
|
*
|
|
|
|
* Portions of this file are derived from the ipw3945 project, as well
|
|
|
|
* as portions of the ieee80211 subsystem header files.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
|
|
|
*
|
|
|
|
* The full GNU General Public License is included in this distribution in the
|
|
|
|
* file called LICENSE.
|
|
|
|
*
|
|
|
|
* Contact Information:
|
2008-12-10 03:28:58 +08:00
|
|
|
* Intel Linux Wireless <ilw@linux.intel.com>
|
2008-04-15 12:16:06 +08:00
|
|
|
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include <net/mac80211.h>
|
2008-04-17 07:34:48 +08:00
|
|
|
#include <linux/etherdevice.h>
|
2010-02-23 08:24:47 +08:00
|
|
|
#include <linux/sched.h>
|
2010-06-16 18:30:27 +08:00
|
|
|
#include <linux/lockdep.h>
|
2008-04-15 12:16:06 +08:00
|
|
|
|
2008-04-25 02:55:38 +08:00
|
|
|
#include "iwl-dev.h"
|
2008-04-15 12:16:06 +08:00
|
|
|
#include "iwl-core.h"
|
|
|
|
#include "iwl-sta.h"
|
2008-05-29 16:35:02 +08:00
|
|
|
|
2010-01-23 06:22:48 +08:00
|
|
|
/* priv->sta_lock must be held */
|
2008-06-30 17:23:03 +08:00
|
|
|
static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
|
|
|
|
{
|
|
|
|
|
2009-06-04 02:44:07 +08:00
|
|
|
if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE))
|
2010-01-23 06:22:48 +08:00
|
|
|
IWL_ERR(priv, "ACTIVATE a non DRIVER active station id %u addr %pM\n",
|
|
|
|
sta_id, priv->stations[sta_id].sta.sta.addr);
|
2008-06-30 17:23:03 +08:00
|
|
|
|
2010-01-23 06:22:48 +08:00
|
|
|
if (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE) {
|
|
|
|
IWL_DEBUG_ASSOC(priv,
|
|
|
|
"STA id %u addr %pM already present in uCode (according to driver)\n",
|
|
|
|
sta_id, priv->stations[sta_id].sta.sta.addr);
|
|
|
|
} else {
|
|
|
|
priv->stations[sta_id].used |= IWL_STA_UCODE_ACTIVE;
|
|
|
|
IWL_DEBUG_ASSOC(priv, "Added STA id %u addr %pM to uCode\n",
|
|
|
|
sta_id, priv->stations[sta_id].sta.sta.addr);
|
|
|
|
}
|
2008-06-30 17:23:03 +08:00
|
|
|
}
|
|
|
|
|
2010-06-14 23:32:38 +08:00
|
|
|
static int iwl_process_add_sta_resp(struct iwl_priv *priv,
|
|
|
|
struct iwl_addsta_cmd *addsta,
|
|
|
|
struct iwl_rx_packet *pkt,
|
|
|
|
bool sync)
|
2008-05-29 16:35:03 +08:00
|
|
|
{
|
2008-10-15 03:32:43 +08:00
|
|
|
u8 sta_id = addsta->sta.sta_id;
|
2010-01-23 06:22:48 +08:00
|
|
|
unsigned long flags;
|
2010-06-14 23:32:38 +08:00
|
|
|
int ret = -EIO;
|
2008-05-29 16:35:03 +08:00
|
|
|
|
2009-10-09 17:19:45 +08:00
|
|
|
if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) {
|
2008-12-19 10:37:33 +08:00
|
|
|
IWL_ERR(priv, "Bad return from REPLY_ADD_STA (0x%08X)\n",
|
2010-01-23 06:22:48 +08:00
|
|
|
pkt->hdr.flags);
|
2010-06-14 23:32:38 +08:00
|
|
|
return ret;
|
2008-05-29 16:35:03 +08:00
|
|
|
}
|
|
|
|
|
2010-01-23 06:22:48 +08:00
|
|
|
IWL_DEBUG_INFO(priv, "Processing response for adding station %u\n",
|
|
|
|
sta_id);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->sta_lock, flags);
|
|
|
|
|
2009-10-09 17:19:45 +08:00
|
|
|
switch (pkt->u.add_sta.status) {
|
2008-05-29 16:35:03 +08:00
|
|
|
case ADD_STA_SUCCESS_MSK:
|
2010-01-23 06:22:48 +08:00
|
|
|
IWL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n");
|
2008-06-30 17:23:03 +08:00
|
|
|
iwl_sta_ucode_activate(priv, sta_id);
|
2010-06-14 23:32:38 +08:00
|
|
|
ret = 0;
|
2010-01-23 06:22:48 +08:00
|
|
|
break;
|
|
|
|
case ADD_STA_NO_ROOM_IN_TABLE:
|
|
|
|
IWL_ERR(priv, "Adding station %d failed, no room in table.\n",
|
|
|
|
sta_id);
|
|
|
|
break;
|
|
|
|
case ADD_STA_NO_BLOCK_ACK_RESOURCE:
|
|
|
|
IWL_ERR(priv, "Adding station %d failed, no block ack resource.\n",
|
|
|
|
sta_id);
|
|
|
|
break;
|
|
|
|
case ADD_STA_MODIFY_NON_EXIST_STA:
|
2010-03-25 05:19:58 +08:00
|
|
|
IWL_ERR(priv, "Attempting to modify non-existing station %d\n",
|
2010-01-23 06:22:48 +08:00
|
|
|
sta_id);
|
|
|
|
break;
|
2008-05-29 16:35:03 +08:00
|
|
|
default:
|
2010-01-23 06:22:48 +08:00
|
|
|
IWL_DEBUG_ASSOC(priv, "Received REPLY_ADD_STA:(0x%08X)\n",
|
|
|
|
pkt->u.add_sta.status);
|
2008-05-29 16:35:03 +08:00
|
|
|
break;
|
|
|
|
}
|
2010-01-23 06:22:48 +08:00
|
|
|
|
|
|
|
IWL_DEBUG_INFO(priv, "%s station id %u addr %pM\n",
|
|
|
|
priv->stations[sta_id].sta.mode ==
|
|
|
|
STA_CONTROL_MODIFY_MSK ? "Modified" : "Added",
|
|
|
|
sta_id, priv->stations[sta_id].sta.sta.addr);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: The MAC address in the command buffer is often changed from
|
|
|
|
* the original sent to the device. That is, the MAC address
|
|
|
|
* written to the command buffer often is not the same MAC adress
|
|
|
|
* read from the command buffer when the command returns. This
|
|
|
|
* issue has not yet been resolved and this debugging is left to
|
|
|
|
* observe the problem.
|
|
|
|
*/
|
|
|
|
IWL_DEBUG_INFO(priv, "%s station according to cmd buffer %pM\n",
|
|
|
|
priv->stations[sta_id].sta.mode ==
|
|
|
|
STA_CONTROL_MODIFY_MSK ? "Modified" : "Added",
|
|
|
|
addsta->sta.addr);
|
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags);
|
2010-06-14 23:32:38 +08:00
|
|
|
|
|
|
|
return ret;
|
2010-01-23 06:22:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void iwl_add_sta_callback(struct iwl_priv *priv,
|
|
|
|
struct iwl_device_cmd *cmd,
|
|
|
|
struct iwl_rx_packet *pkt)
|
|
|
|
{
|
|
|
|
struct iwl_addsta_cmd *addsta =
|
|
|
|
(struct iwl_addsta_cmd *)cmd->cmd.payload;
|
|
|
|
|
|
|
|
iwl_process_add_sta_resp(priv, addsta, pkt, false);
|
|
|
|
|
2008-05-29 16:35:03 +08:00
|
|
|
}
|
|
|
|
|
2009-01-24 05:45:20 +08:00
|
|
|
int iwl_send_add_sta(struct iwl_priv *priv,
|
2008-05-05 10:22:34 +08:00
|
|
|
struct iwl_addsta_cmd *sta, u8 flags)
|
|
|
|
{
|
2009-10-09 17:19:45 +08:00
|
|
|
struct iwl_rx_packet *pkt = NULL;
|
2008-05-05 10:22:34 +08:00
|
|
|
int ret = 0;
|
|
|
|
u8 data[sizeof(*sta)];
|
|
|
|
struct iwl_host_cmd cmd = {
|
|
|
|
.id = REPLY_ADD_STA,
|
2009-07-25 02:13:05 +08:00
|
|
|
.flags = flags,
|
2008-05-05 10:22:34 +08:00
|
|
|
.data = data,
|
|
|
|
};
|
2010-04-06 01:43:10 +08:00
|
|
|
u8 sta_id __maybe_unused = sta->sta.sta_id;
|
2010-02-23 08:24:47 +08:00
|
|
|
|
|
|
|
IWL_DEBUG_INFO(priv, "Adding sta %u (%pM) %ssynchronously\n",
|
|
|
|
sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : "");
|
2008-05-05 10:22:34 +08:00
|
|
|
|
2008-05-29 16:35:03 +08:00
|
|
|
if (flags & CMD_ASYNC)
|
2009-07-25 02:13:05 +08:00
|
|
|
cmd.callback = iwl_add_sta_callback;
|
2010-06-16 18:30:27 +08:00
|
|
|
else {
|
2009-07-25 02:13:05 +08:00
|
|
|
cmd.flags |= CMD_WANT_SKB;
|
2010-06-16 18:30:27 +08:00
|
|
|
might_sleep();
|
|
|
|
}
|
2008-05-05 10:22:34 +08:00
|
|
|
|
|
|
|
cmd.len = priv->cfg->ops->utils->build_addsta_hcmd(sta, data);
|
|
|
|
ret = iwl_send_cmd(priv, &cmd);
|
|
|
|
|
|
|
|
if (ret || (flags & CMD_ASYNC))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (ret == 0) {
|
2010-01-23 06:22:48 +08:00
|
|
|
pkt = (struct iwl_rx_packet *)cmd.reply_page;
|
2010-06-14 23:32:38 +08:00
|
|
|
ret = iwl_process_add_sta_resp(priv, sta, pkt, true);
|
2008-05-05 10:22:34 +08:00
|
|
|
}
|
2009-12-11 06:37:21 +08:00
|
|
|
iwl_free_pages(priv, cmd.reply_page);
|
2008-05-05 10:22:34 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2009-01-24 05:45:20 +08:00
|
|
|
EXPORT_SYMBOL(iwl_send_add_sta);
|
2008-04-17 07:34:48 +08:00
|
|
|
|
2008-05-15 13:54:04 +08:00
|
|
|
static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
|
2010-08-23 16:46:46 +08:00
|
|
|
struct ieee80211_sta *sta,
|
|
|
|
struct iwl_rxon_context *ctx)
|
2008-05-15 13:54:04 +08:00
|
|
|
{
|
2010-08-23 16:46:45 +08:00
|
|
|
struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->ht_cap;
|
2008-05-15 13:54:04 +08:00
|
|
|
__le32 sta_flags;
|
|
|
|
u8 mimo_ps_mode;
|
|
|
|
|
2010-08-23 16:46:45 +08:00
|
|
|
if (!sta || !sta_ht_inf->ht_supported)
|
2008-05-15 13:54:04 +08:00
|
|
|
goto done;
|
|
|
|
|
2008-09-03 11:26:42 +08:00
|
|
|
mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2;
|
2009-10-31 05:36:17 +08:00
|
|
|
IWL_DEBUG_ASSOC(priv, "spatial multiplexing power save mode: %s\n",
|
|
|
|
(mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ?
|
|
|
|
"static" :
|
|
|
|
(mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ?
|
|
|
|
"dynamic" : "disabled");
|
2008-05-15 13:54:04 +08:00
|
|
|
|
|
|
|
sta_flags = priv->stations[index].sta.station_flags;
|
|
|
|
|
|
|
|
sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK);
|
|
|
|
|
|
|
|
switch (mimo_ps_mode) {
|
2008-09-03 11:26:42 +08:00
|
|
|
case WLAN_HT_CAP_SM_PS_STATIC:
|
2008-05-15 13:54:04 +08:00
|
|
|
sta_flags |= STA_FLG_MIMO_DIS_MSK;
|
|
|
|
break;
|
2008-09-03 11:26:42 +08:00
|
|
|
case WLAN_HT_CAP_SM_PS_DYNAMIC:
|
2008-05-15 13:54:04 +08:00
|
|
|
sta_flags |= STA_FLG_RTS_MIMO_PROT_MSK;
|
|
|
|
break;
|
2008-09-03 11:26:42 +08:00
|
|
|
case WLAN_HT_CAP_SM_PS_DISABLED:
|
2008-05-15 13:54:04 +08:00
|
|
|
break;
|
|
|
|
default:
|
2008-12-19 10:37:32 +08:00
|
|
|
IWL_WARN(priv, "Invalid MIMO PS mode %d\n", mimo_ps_mode);
|
2008-05-15 13:54:04 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
sta_flags |= cpu_to_le32(
|
|
|
|
(u32)sta_ht_inf->ampdu_factor << STA_FLG_MAX_AGG_SIZE_POS);
|
|
|
|
|
|
|
|
sta_flags |= cpu_to_le32(
|
|
|
|
(u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS);
|
|
|
|
|
2010-08-23 16:46:46 +08:00
|
|
|
if (iwl_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap))
|
2009-08-08 06:41:38 +08:00
|
|
|
sta_flags |= STA_FLG_HT40_EN_MSK;
|
2008-05-15 13:54:04 +08:00
|
|
|
else
|
2009-08-08 06:41:38 +08:00
|
|
|
sta_flags &= ~STA_FLG_HT40_EN_MSK;
|
2008-05-15 13:54:04 +08:00
|
|
|
|
|
|
|
priv->stations[index].sta.station_flags = sta_flags;
|
|
|
|
done:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-02-23 08:24:47 +08:00
|
|
|
* iwl_prep_station - Prepare station information for addition
|
|
|
|
*
|
|
|
|
* should be called with sta_lock held
|
2008-05-15 13:54:04 +08:00
|
|
|
*/
|
2010-09-23 00:02:01 +08:00
|
|
|
u8 iwl_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
|
|
|
|
const u8 *addr, bool is_ap, struct ieee80211_sta *sta)
|
2008-05-15 13:54:04 +08:00
|
|
|
{
|
|
|
|
struct iwl_station_entry *station;
|
2009-06-04 02:44:07 +08:00
|
|
|
int i;
|
2010-02-23 08:24:47 +08:00
|
|
|
u8 sta_id = IWL_INVALID_STATION;
|
2009-06-04 02:44:07 +08:00
|
|
|
u16 rate;
|
2008-05-15 13:54:04 +08:00
|
|
|
|
|
|
|
if (is_ap)
|
2010-08-23 16:46:42 +08:00
|
|
|
sta_id = ctx->ap_sta_id;
|
2008-05-15 13:54:04 +08:00
|
|
|
else if (is_broadcast_ether_addr(addr))
|
2010-08-27 23:53:46 +08:00
|
|
|
sta_id = ctx->bcast_sta_id;
|
2008-05-15 13:54:04 +08:00
|
|
|
else
|
|
|
|
for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) {
|
|
|
|
if (!compare_ether_addr(priv->stations[i].sta.sta.addr,
|
|
|
|
addr)) {
|
2008-06-30 17:23:03 +08:00
|
|
|
sta_id = i;
|
2008-05-15 13:54:04 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!priv->stations[i].used &&
|
2008-06-30 17:23:03 +08:00
|
|
|
sta_id == IWL_INVALID_STATION)
|
|
|
|
sta_id = i;
|
2008-05-15 13:54:04 +08:00
|
|
|
}
|
|
|
|
|
2010-02-23 08:24:47 +08:00
|
|
|
/*
|
|
|
|
* These two conditions have the same outcome, but keep them
|
|
|
|
* separate
|
|
|
|
*/
|
|
|
|
if (unlikely(sta_id == IWL_INVALID_STATION))
|
|
|
|
return sta_id;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* uCode is not able to deal with multiple requests to add a
|
|
|
|
* station. Keep track if one is in progress so that we do not send
|
|
|
|
* another.
|
|
|
|
*/
|
|
|
|
if (priv->stations[sta_id].used & IWL_STA_UCODE_INPROGRESS) {
|
|
|
|
IWL_DEBUG_INFO(priv, "STA %d already in process of being added.\n",
|
|
|
|
sta_id);
|
2008-06-30 17:23:03 +08:00
|
|
|
return sta_id;
|
2008-05-15 13:54:04 +08:00
|
|
|
}
|
|
|
|
|
2010-02-23 08:24:47 +08:00
|
|
|
if ((priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) &&
|
|
|
|
(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE) &&
|
2008-06-30 17:23:03 +08:00
|
|
|
!compare_ether_addr(priv->stations[sta_id].sta.sta.addr, addr)) {
|
2010-02-23 08:24:47 +08:00
|
|
|
IWL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not adding again.\n",
|
|
|
|
sta_id, addr);
|
2008-06-30 17:23:03 +08:00
|
|
|
return sta_id;
|
2008-05-15 13:54:04 +08:00
|
|
|
}
|
|
|
|
|
2008-06-30 17:23:03 +08:00
|
|
|
station = &priv->stations[sta_id];
|
|
|
|
station->used = IWL_STA_DRIVER_ACTIVE;
|
2009-01-28 06:27:56 +08:00
|
|
|
IWL_DEBUG_ASSOC(priv, "Add STA to driver ID %d: %pM\n",
|
2008-10-28 06:59:26 +08:00
|
|
|
sta_id, addr);
|
2008-05-15 13:54:04 +08:00
|
|
|
priv->num_stations++;
|
|
|
|
|
|
|
|
/* Set up the REPLY_ADD_STA command to send to device */
|
|
|
|
memset(&station->sta, 0, sizeof(struct iwl_addsta_cmd));
|
|
|
|
memcpy(station->sta.sta.addr, addr, ETH_ALEN);
|
|
|
|
station->sta.mode = 0;
|
2008-06-30 17:23:03 +08:00
|
|
|
station->sta.sta.sta_id = sta_id;
|
2010-08-23 16:46:44 +08:00
|
|
|
station->sta.station_flags = ctx->station_flags;
|
2010-08-27 23:55:52 +08:00
|
|
|
station->ctxid = ctx->ctxid;
|
2008-05-15 13:54:04 +08:00
|
|
|
|
2010-08-23 16:46:45 +08:00
|
|
|
if (sta) {
|
|
|
|
struct iwl_station_priv_common *sta_priv;
|
|
|
|
|
|
|
|
sta_priv = (void *)sta->drv_priv;
|
|
|
|
sta_priv->ctx = ctx;
|
|
|
|
}
|
|
|
|
|
2010-05-01 02:30:50 +08:00
|
|
|
/*
|
|
|
|
* OK to call unconditionally, since local stations (IBSS BSSID
|
2010-08-23 16:46:45 +08:00
|
|
|
* STA and broadcast STA) pass in a NULL sta, and mac80211
|
2010-05-01 02:30:50 +08:00
|
|
|
* doesn't allow HT IBSS.
|
|
|
|
*/
|
2010-08-23 16:46:46 +08:00
|
|
|
iwl_set_ht_add_station(priv, sta_id, sta, ctx);
|
2008-05-15 13:54:04 +08:00
|
|
|
|
2009-06-04 02:44:07 +08:00
|
|
|
/* 3945 only */
|
|
|
|
rate = (priv->band == IEEE80211_BAND_5GHZ) ?
|
|
|
|
IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP;
|
|
|
|
/* Turn on both antennas for the station... */
|
|
|
|
station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK);
|
|
|
|
|
2010-02-23 08:24:47 +08:00
|
|
|
return sta_id;
|
|
|
|
|
|
|
|
}
|
2010-09-23 00:02:01 +08:00
|
|
|
EXPORT_SYMBOL_GPL(iwl_prep_station);
|
2010-02-23 08:24:47 +08:00
|
|
|
|
|
|
|
#define STA_WAIT_TIMEOUT (HZ/2)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* iwl_add_station_common -
|
|
|
|
*/
|
2010-08-27 23:53:46 +08:00
|
|
|
int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
|
|
|
|
const u8 *addr, bool is_ap,
|
2010-08-23 16:46:45 +08:00
|
|
|
struct ieee80211_sta *sta, u8 *sta_id_r)
|
2010-02-23 08:24:47 +08:00
|
|
|
{
|
|
|
|
unsigned long flags_spin;
|
|
|
|
int ret = 0;
|
|
|
|
u8 sta_id;
|
2010-05-05 17:26:06 +08:00
|
|
|
struct iwl_addsta_cmd sta_cmd;
|
2010-02-23 08:24:47 +08:00
|
|
|
|
|
|
|
*sta_id_r = 0;
|
|
|
|
spin_lock_irqsave(&priv->sta_lock, flags_spin);
|
2010-08-23 16:46:45 +08:00
|
|
|
sta_id = iwl_prep_station(priv, ctx, addr, is_ap, sta);
|
2010-02-23 08:24:47 +08:00
|
|
|
if (sta_id == IWL_INVALID_STATION) {
|
|
|
|
IWL_ERR(priv, "Unable to prepare station %pM for addition\n",
|
|
|
|
addr);
|
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* uCode is not able to deal with multiple requests to add a
|
|
|
|
* station. Keep track if one is in progress so that we do not send
|
|
|
|
* another.
|
|
|
|
*/
|
|
|
|
if (priv->stations[sta_id].used & IWL_STA_UCODE_INPROGRESS) {
|
|
|
|
IWL_DEBUG_INFO(priv, "STA %d already in process of being added.\n",
|
|
|
|
sta_id);
|
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
|
|
|
|
return -EEXIST;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) &&
|
|
|
|
(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) {
|
|
|
|
IWL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not adding again.\n",
|
|
|
|
sta_id, addr);
|
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
|
|
|
|
return -EEXIST;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->stations[sta_id].used |= IWL_STA_UCODE_INPROGRESS;
|
2010-05-05 17:26:06 +08:00
|
|
|
memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(struct iwl_addsta_cmd));
|
2008-05-15 13:54:04 +08:00
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
|
|
|
|
|
|
|
|
/* Add station to device's station table */
|
2010-05-05 17:26:06 +08:00
|
|
|
ret = iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC);
|
2010-02-23 08:24:47 +08:00
|
|
|
if (ret) {
|
|
|
|
spin_lock_irqsave(&priv->sta_lock, flags_spin);
|
2010-05-05 17:26:06 +08:00
|
|
|
IWL_ERR(priv, "Adding station %pM failed.\n",
|
|
|
|
priv->stations[sta_id].sta.sta.addr);
|
2010-02-23 08:24:47 +08:00
|
|
|
priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE;
|
|
|
|
priv->stations[sta_id].used &= ~IWL_STA_UCODE_INPROGRESS;
|
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
|
|
|
|
}
|
|
|
|
*sta_id_r = sta_id;
|
|
|
|
return ret;
|
2008-05-15 13:54:04 +08:00
|
|
|
}
|
2010-02-23 08:24:47 +08:00
|
|
|
EXPORT_SYMBOL(iwl_add_station_common);
|
2008-05-15 13:54:04 +08:00
|
|
|
|
2010-02-23 08:24:47 +08:00
|
|
|
/**
|
|
|
|
* iwl_sta_ucode_deactivate - deactivate ucode status for a station
|
|
|
|
*
|
|
|
|
* priv->sta_lock must be held
|
|
|
|
*/
|
|
|
|
static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, u8 sta_id)
|
|
|
|
{
|
|
|
|
/* Ucode must be active and driver must be non active */
|
2010-04-24 01:33:33 +08:00
|
|
|
if ((priv->stations[sta_id].used &
|
|
|
|
(IWL_STA_UCODE_ACTIVE | IWL_STA_DRIVER_ACTIVE)) != IWL_STA_UCODE_ACTIVE)
|
2010-02-23 08:24:47 +08:00
|
|
|
IWL_ERR(priv, "removed non active STA %u\n", sta_id);
|
|
|
|
|
|
|
|
priv->stations[sta_id].used &= ~IWL_STA_UCODE_ACTIVE;
|
|
|
|
|
|
|
|
memset(&priv->stations[sta_id], 0, sizeof(struct iwl_station_entry));
|
|
|
|
IWL_DEBUG_ASSOC(priv, "Removed STA %u\n", sta_id);
|
2008-05-29 16:35:02 +08:00
|
|
|
}
|
|
|
|
|
2010-02-23 08:24:47 +08:00
|
|
|
static int iwl_send_remove_station(struct iwl_priv *priv,
|
2010-11-11 10:25:48 +08:00
|
|
|
const u8 *addr, int sta_id,
|
|
|
|
bool temporary)
|
2008-05-29 16:35:02 +08:00
|
|
|
{
|
2009-10-09 17:19:45 +08:00
|
|
|
struct iwl_rx_packet *pkt;
|
2008-05-29 16:35:02 +08:00
|
|
|
int ret;
|
|
|
|
|
2010-02-23 08:24:47 +08:00
|
|
|
unsigned long flags_spin;
|
2008-05-29 16:35:02 +08:00
|
|
|
struct iwl_rem_sta_cmd rm_sta_cmd;
|
|
|
|
|
|
|
|
struct iwl_host_cmd cmd = {
|
|
|
|
.id = REPLY_REMOVE_STA,
|
|
|
|
.len = sizeof(struct iwl_rem_sta_cmd),
|
2010-02-23 08:24:47 +08:00
|
|
|
.flags = CMD_SYNC,
|
2008-05-29 16:35:02 +08:00
|
|
|
.data = &rm_sta_cmd,
|
|
|
|
};
|
|
|
|
|
|
|
|
memset(&rm_sta_cmd, 0, sizeof(rm_sta_cmd));
|
|
|
|
rm_sta_cmd.num_sta = 1;
|
2010-05-05 17:26:06 +08:00
|
|
|
memcpy(&rm_sta_cmd.addr, addr, ETH_ALEN);
|
2010-02-23 08:24:47 +08:00
|
|
|
|
|
|
|
cmd.flags |= CMD_WANT_SKB;
|
2008-05-29 16:35:02 +08:00
|
|
|
|
|
|
|
ret = iwl_send_cmd(priv, &cmd);
|
|
|
|
|
2010-02-23 08:24:47 +08:00
|
|
|
if (ret)
|
2008-05-29 16:35:02 +08:00
|
|
|
return ret;
|
|
|
|
|
2009-10-09 17:19:45 +08:00
|
|
|
pkt = (struct iwl_rx_packet *)cmd.reply_page;
|
|
|
|
if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) {
|
2008-12-19 10:37:33 +08:00
|
|
|
IWL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n",
|
2009-10-09 17:19:45 +08:00
|
|
|
pkt->hdr.flags);
|
2008-05-29 16:35:02 +08:00
|
|
|
ret = -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret) {
|
2009-10-09 17:19:45 +08:00
|
|
|
switch (pkt->u.rem_sta.status) {
|
2008-05-29 16:35:02 +08:00
|
|
|
case REM_STA_SUCCESS_MSK:
|
2010-11-11 10:25:48 +08:00
|
|
|
if (!temporary) {
|
|
|
|
spin_lock_irqsave(&priv->sta_lock, flags_spin);
|
|
|
|
iwl_sta_ucode_deactivate(priv, sta_id);
|
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
|
|
|
|
}
|
2009-01-28 06:27:56 +08:00
|
|
|
IWL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n");
|
2008-05-29 16:35:02 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EIO;
|
2008-12-19 10:37:33 +08:00
|
|
|
IWL_ERR(priv, "REPLY_REMOVE_STA failed\n");
|
2008-05-29 16:35:02 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-12-11 06:37:21 +08:00
|
|
|
iwl_free_pages(priv, cmd.reply_page);
|
2008-05-29 16:35:02 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2008-06-12 09:47:18 +08:00
|
|
|
|
2008-05-29 16:35:02 +08:00
|
|
|
/**
|
|
|
|
* iwl_remove_station - Remove driver's knowledge of station.
|
|
|
|
*/
|
2010-05-01 02:30:43 +08:00
|
|
|
int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id,
|
|
|
|
const u8 *addr)
|
2008-05-29 16:35:02 +08:00
|
|
|
{
|
2010-05-01 02:30:43 +08:00
|
|
|
unsigned long flags;
|
2010-02-23 08:24:47 +08:00
|
|
|
|
|
|
|
if (!iwl_is_ready(priv)) {
|
|
|
|
IWL_DEBUG_INFO(priv,
|
2010-03-25 05:19:58 +08:00
|
|
|
"Unable to remove station %pM, device not ready.\n",
|
2010-04-28 23:44:51 +08:00
|
|
|
addr);
|
2010-02-23 08:24:47 +08:00
|
|
|
/*
|
|
|
|
* It is typical for stations to be removed when we are
|
|
|
|
* going down. Return success since device will be down
|
|
|
|
* soon anyway
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
}
|
2008-05-29 16:35:02 +08:00
|
|
|
|
2010-05-01 02:30:43 +08:00
|
|
|
IWL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n",
|
|
|
|
sta_id, addr);
|
2008-05-29 16:35:02 +08:00
|
|
|
|
2010-05-01 02:30:43 +08:00
|
|
|
if (WARN_ON(sta_id == IWL_INVALID_STATION))
|
|
|
|
return -EINVAL;
|
2008-05-29 16:35:02 +08:00
|
|
|
|
2010-05-01 02:30:43 +08:00
|
|
|
spin_lock_irqsave(&priv->sta_lock, flags);
|
2008-06-30 17:23:03 +08:00
|
|
|
|
|
|
|
if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) {
|
2010-02-23 08:24:47 +08:00
|
|
|
IWL_DEBUG_INFO(priv, "Removing %pM but non DRIVER active\n",
|
2010-04-28 23:44:51 +08:00
|
|
|
addr);
|
2010-05-01 02:30:43 +08:00
|
|
|
goto out_err;
|
2008-06-30 17:23:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) {
|
2010-02-23 08:24:47 +08:00
|
|
|
IWL_DEBUG_INFO(priv, "Removing %pM but non UCODE active\n",
|
2010-04-28 23:44:51 +08:00
|
|
|
addr);
|
2010-05-01 02:30:43 +08:00
|
|
|
goto out_err;
|
2008-05-29 16:35:02 +08:00
|
|
|
}
|
|
|
|
|
2010-04-28 23:44:52 +08:00
|
|
|
if (priv->stations[sta_id].used & IWL_STA_LOCAL) {
|
|
|
|
kfree(priv->stations[sta_id].lq);
|
|
|
|
priv->stations[sta_id].lq = NULL;
|
|
|
|
}
|
2008-06-30 17:23:03 +08:00
|
|
|
|
|
|
|
priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE;
|
|
|
|
|
|
|
|
priv->num_stations--;
|
|
|
|
|
2008-05-29 16:35:02 +08:00
|
|
|
BUG_ON(priv->num_stations < 0);
|
2008-06-30 17:23:03 +08:00
|
|
|
|
2008-05-29 16:35:02 +08:00
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags);
|
2008-06-30 17:23:03 +08:00
|
|
|
|
2010-11-11 10:25:48 +08:00
|
|
|
return iwl_send_remove_station(priv, addr, sta_id, false);
|
2010-05-01 02:30:43 +08:00
|
|
|
out_err:
|
2008-05-29 16:35:02 +08:00
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags);
|
2010-05-01 02:30:43 +08:00
|
|
|
return -EINVAL;
|
2008-05-29 16:35:02 +08:00
|
|
|
}
|
2010-04-28 23:44:52 +08:00
|
|
|
EXPORT_SYMBOL_GPL(iwl_remove_station);
|
2008-06-30 17:23:03 +08:00
|
|
|
|
2008-11-20 07:32:23 +08:00
|
|
|
/**
|
iwlwifi: rework broadcast station management
Currently, the broadcast station is managed along
with the interface type, rather than always being
present. That leads to a bug with injection -- it
is currently not possible to inject frames when
the only virtual interface is a monitor, because
in that the required broadcast station is missing.
Additionally, allocating and deallocating the
broadcast station's LQ all the time is wasteful,
and the code to support this is fairly complex.
So this changes completely the way we manage the
broadcast station. Rather than manage it along
with any interface, we now allocate it when we
bring the device up, and remove it again when we
bring the device down. When we bring the device
up, we don't immediately program the broadcast
station into it, instead we just mark it active
and rely on the next restore cycle to upload it
to the device. This works because an unassociated
RXON is always required at least once to set up
device parameters, which implies a reprogramming
of stations into the device.
As we now manage all stations properly, there no
longer is a need for forcing a clearing of them
via iwl_clear_ucode_stations(), which can become
a lot simpler.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
2010-04-29 15:53:29 +08:00
|
|
|
* iwl_clear_ucode_stations - clear ucode station table bits
|
|
|
|
*
|
|
|
|
* This function clears all the bits in the driver indicating
|
|
|
|
* which stations are active in the ucode. Call when something
|
|
|
|
* other than explicit station management would cause this in
|
|
|
|
* the ucode, e.g. unassociated RXON.
|
2008-11-20 07:32:23 +08:00
|
|
|
*/
|
2010-08-27 23:55:52 +08:00
|
|
|
void iwl_clear_ucode_stations(struct iwl_priv *priv,
|
|
|
|
struct iwl_rxon_context *ctx)
|
2008-11-20 07:32:23 +08:00
|
|
|
{
|
2009-03-12 02:17:59 +08:00
|
|
|
int i;
|
2010-02-19 14:58:32 +08:00
|
|
|
unsigned long flags_spin;
|
|
|
|
bool cleared = false;
|
|
|
|
|
iwlwifi: rework broadcast station management
Currently, the broadcast station is managed along
with the interface type, rather than always being
present. That leads to a bug with injection -- it
is currently not possible to inject frames when
the only virtual interface is a monitor, because
in that the required broadcast station is missing.
Additionally, allocating and deallocating the
broadcast station's LQ all the time is wasteful,
and the code to support this is fairly complex.
So this changes completely the way we manage the
broadcast station. Rather than manage it along
with any interface, we now allocate it when we
bring the device up, and remove it again when we
bring the device down. When we bring the device
up, we don't immediately program the broadcast
station into it, instead we just mark it active
and rely on the next restore cycle to upload it
to the device. This works because an unassociated
RXON is always required at least once to set up
device parameters, which implies a reprogramming
of stations into the device.
As we now manage all stations properly, there no
longer is a need for forcing a clearing of them
via iwl_clear_ucode_stations(), which can become
a lot simpler.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
2010-04-29 15:53:29 +08:00
|
|
|
IWL_DEBUG_INFO(priv, "Clearing ucode stations in driver\n");
|
2008-11-20 07:32:23 +08:00
|
|
|
|
2010-02-19 14:58:32 +08:00
|
|
|
spin_lock_irqsave(&priv->sta_lock, flags_spin);
|
iwlwifi: rework broadcast station management
Currently, the broadcast station is managed along
with the interface type, rather than always being
present. That leads to a bug with injection -- it
is currently not possible to inject frames when
the only virtual interface is a monitor, because
in that the required broadcast station is missing.
Additionally, allocating and deallocating the
broadcast station's LQ all the time is wasteful,
and the code to support this is fairly complex.
So this changes completely the way we manage the
broadcast station. Rather than manage it along
with any interface, we now allocate it when we
bring the device up, and remove it again when we
bring the device down. When we bring the device
up, we don't immediately program the broadcast
station into it, instead we just mark it active
and rely on the next restore cycle to upload it
to the device. This works because an unassociated
RXON is always required at least once to set up
device parameters, which implies a reprogramming
of stations into the device.
As we now manage all stations properly, there no
longer is a need for forcing a clearing of them
via iwl_clear_ucode_stations(), which can become
a lot simpler.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
2010-04-29 15:53:29 +08:00
|
|
|
for (i = 0; i < priv->hw_params.max_stations; i++) {
|
2010-08-27 23:55:52 +08:00
|
|
|
if (ctx && ctx->ctxid != priv->stations[i].ctxid)
|
|
|
|
continue;
|
|
|
|
|
iwlwifi: rework broadcast station management
Currently, the broadcast station is managed along
with the interface type, rather than always being
present. That leads to a bug with injection -- it
is currently not possible to inject frames when
the only virtual interface is a monitor, because
in that the required broadcast station is missing.
Additionally, allocating and deallocating the
broadcast station's LQ all the time is wasteful,
and the code to support this is fairly complex.
So this changes completely the way we manage the
broadcast station. Rather than manage it along
with any interface, we now allocate it when we
bring the device up, and remove it again when we
bring the device down. When we bring the device
up, we don't immediately program the broadcast
station into it, instead we just mark it active
and rely on the next restore cycle to upload it
to the device. This works because an unassociated
RXON is always required at least once to set up
device parameters, which implies a reprogramming
of stations into the device.
As we now manage all stations properly, there no
longer is a need for forcing a clearing of them
via iwl_clear_ucode_stations(), which can become
a lot simpler.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
2010-04-29 15:53:29 +08:00
|
|
|
if (priv->stations[i].used & IWL_STA_UCODE_ACTIVE) {
|
|
|
|
IWL_DEBUG_INFO(priv, "Clearing ucode active for station %d\n", i);
|
|
|
|
priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE;
|
|
|
|
cleared = true;
|
2010-02-19 14:58:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
|
|
|
|
|
|
|
|
if (!cleared)
|
|
|
|
IWL_DEBUG_INFO(priv, "No active stations found to be cleared\n");
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(iwl_clear_ucode_stations);
|
2008-11-20 07:32:23 +08:00
|
|
|
|
2010-02-19 14:58:32 +08:00
|
|
|
/**
|
|
|
|
* iwl_restore_stations() - Restore driver known stations to device
|
|
|
|
*
|
|
|
|
* All stations considered active by driver, but not present in ucode, is
|
|
|
|
* restored.
|
2010-02-23 08:24:47 +08:00
|
|
|
*
|
|
|
|
* Function sleeps.
|
2010-02-19 14:58:32 +08:00
|
|
|
*/
|
2010-08-27 23:55:52 +08:00
|
|
|
void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
|
2010-02-19 14:58:32 +08:00
|
|
|
{
|
2010-05-05 17:26:06 +08:00
|
|
|
struct iwl_addsta_cmd sta_cmd;
|
|
|
|
struct iwl_link_quality_cmd lq;
|
2010-02-19 14:58:32 +08:00
|
|
|
unsigned long flags_spin;
|
|
|
|
int i;
|
|
|
|
bool found = false;
|
2010-02-23 08:24:47 +08:00
|
|
|
int ret;
|
2010-05-05 17:26:06 +08:00
|
|
|
bool send_lq;
|
2008-11-20 07:32:23 +08:00
|
|
|
|
2010-02-19 14:58:32 +08:00
|
|
|
if (!iwl_is_ready(priv)) {
|
|
|
|
IWL_DEBUG_INFO(priv, "Not ready yet, not restoring any stations.\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-11-20 07:32:23 +08:00
|
|
|
|
2010-02-19 14:58:32 +08:00
|
|
|
IWL_DEBUG_ASSOC(priv, "Restoring all known stations ... start.\n");
|
|
|
|
spin_lock_irqsave(&priv->sta_lock, flags_spin);
|
|
|
|
for (i = 0; i < priv->hw_params.max_stations; i++) {
|
2010-08-27 23:55:52 +08:00
|
|
|
if (ctx->ctxid != priv->stations[i].ctxid)
|
|
|
|
continue;
|
2010-02-19 14:58:32 +08:00
|
|
|
if ((priv->stations[i].used & IWL_STA_DRIVER_ACTIVE) &&
|
|
|
|
!(priv->stations[i].used & IWL_STA_UCODE_ACTIVE)) {
|
|
|
|
IWL_DEBUG_ASSOC(priv, "Restoring sta %pM\n",
|
|
|
|
priv->stations[i].sta.sta.addr);
|
|
|
|
priv->stations[i].sta.mode = 0;
|
|
|
|
priv->stations[i].used |= IWL_STA_UCODE_INPROGRESS;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
2009-01-29 01:38:30 +08:00
|
|
|
|
2010-02-19 14:58:32 +08:00
|
|
|
for (i = 0; i < priv->hw_params.max_stations; i++) {
|
|
|
|
if ((priv->stations[i].used & IWL_STA_UCODE_INPROGRESS)) {
|
2010-05-05 17:26:06 +08:00
|
|
|
memcpy(&sta_cmd, &priv->stations[i].sta,
|
|
|
|
sizeof(struct iwl_addsta_cmd));
|
|
|
|
send_lq = false;
|
|
|
|
if (priv->stations[i].lq) {
|
|
|
|
memcpy(&lq, priv->stations[i].lq,
|
|
|
|
sizeof(struct iwl_link_quality_cmd));
|
|
|
|
send_lq = true;
|
|
|
|
}
|
2010-02-23 08:24:47 +08:00
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
|
2010-05-05 17:26:06 +08:00
|
|
|
ret = iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC);
|
2010-02-23 08:24:47 +08:00
|
|
|
if (ret) {
|
|
|
|
spin_lock_irqsave(&priv->sta_lock, flags_spin);
|
2010-05-05 17:26:06 +08:00
|
|
|
IWL_ERR(priv, "Adding station %pM failed.\n",
|
|
|
|
priv->stations[i].sta.sta.addr);
|
2010-02-23 08:24:47 +08:00
|
|
|
priv->stations[i].used &= ~IWL_STA_DRIVER_ACTIVE;
|
|
|
|
priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS;
|
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Rate scaling has already been initialized, send
|
|
|
|
* current LQ command
|
|
|
|
*/
|
2010-05-05 17:26:06 +08:00
|
|
|
if (send_lq)
|
2010-08-23 16:46:46 +08:00
|
|
|
iwl_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true);
|
2010-02-23 08:24:47 +08:00
|
|
|
spin_lock_irqsave(&priv->sta_lock, flags_spin);
|
2010-02-19 14:58:32 +08:00
|
|
|
priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS;
|
|
|
|
}
|
2009-03-12 02:17:59 +08:00
|
|
|
}
|
|
|
|
|
2010-02-19 14:58:32 +08:00
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
|
|
|
|
if (!found)
|
|
|
|
IWL_DEBUG_INFO(priv, "Restoring all known stations .... no stations to be restored.\n");
|
|
|
|
else
|
2010-02-23 08:24:47 +08:00
|
|
|
IWL_DEBUG_INFO(priv, "Restoring all known stations .... complete.\n");
|
2008-11-20 07:32:23 +08:00
|
|
|
}
|
2010-02-19 14:58:32 +08:00
|
|
|
EXPORT_SYMBOL(iwl_restore_stations);
|
2008-11-20 07:32:23 +08:00
|
|
|
|
2010-11-11 10:25:48 +08:00
|
|
|
void iwl_reprogram_ap_sta(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int sta_id = ctx->ap_sta_id;
|
|
|
|
int ret;
|
|
|
|
struct iwl_addsta_cmd sta_cmd;
|
|
|
|
struct iwl_link_quality_cmd lq;
|
|
|
|
bool active;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->sta_lock, flags);
|
|
|
|
if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) {
|
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(sta_cmd));
|
|
|
|
sta_cmd.mode = 0;
|
|
|
|
memcpy(&lq, priv->stations[sta_id].lq, sizeof(lq));
|
|
|
|
|
|
|
|
active = priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE;
|
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags);
|
|
|
|
|
|
|
|
if (active) {
|
|
|
|
ret = iwl_send_remove_station(
|
|
|
|
priv, priv->stations[sta_id].sta.sta.addr,
|
|
|
|
sta_id, true);
|
|
|
|
if (ret)
|
|
|
|
IWL_ERR(priv, "failed to remove STA %pM (%d)\n",
|
|
|
|
priv->stations[sta_id].sta.sta.addr, ret);
|
|
|
|
}
|
|
|
|
ret = iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC);
|
|
|
|
if (ret)
|
|
|
|
IWL_ERR(priv, "failed to re-add STA %pM (%d)\n",
|
|
|
|
priv->stations[sta_id].sta.sta.addr, ret);
|
|
|
|
iwl_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(iwl_reprogram_ap_sta);
|
|
|
|
|
2009-02-28 08:21:21 +08:00
|
|
|
int iwl_get_free_ucode_key_index(struct iwl_priv *priv)
|
2008-04-15 12:16:08 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2010-08-23 16:46:43 +08:00
|
|
|
for (i = 0; i < priv->sta_key_max_num; i++)
|
2008-04-16 07:01:44 +08:00
|
|
|
if (!test_and_set_bit(i, &priv->ucode_key_table))
|
2008-04-15 12:16:08 +08:00
|
|
|
return i;
|
|
|
|
|
2008-11-26 05:29:03 +08:00
|
|
|
return WEP_INVALID_OFFSET;
|
2008-04-15 12:16:08 +08:00
|
|
|
}
|
2009-02-28 08:21:21 +08:00
|
|
|
EXPORT_SYMBOL(iwl_get_free_ucode_key_index);
|
2008-04-15 12:16:06 +08:00
|
|
|
|
2010-09-23 00:02:01 +08:00
|
|
|
void iwl_dealloc_bcast_stations(struct iwl_priv *priv)
|
2008-11-13 05:14:05 +08:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int i;
|
|
|
|
|
2008-04-15 12:16:09 +08:00
|
|
|
spin_lock_irqsave(&priv->sta_lock, flags);
|
2010-09-23 00:02:01 +08:00
|
|
|
for (i = 0; i < priv->hw_params.max_stations; i++) {
|
|
|
|
if (!(priv->stations[i].used & IWL_STA_BCAST))
|
|
|
|
continue;
|
2008-11-26 05:29:03 +08:00
|
|
|
|
2010-09-23 00:02:01 +08:00
|
|
|
priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE;
|
|
|
|
priv->num_stations--;
|
|
|
|
BUG_ON(priv->num_stations < 0);
|
|
|
|
kfree(priv->stations[i].lq);
|
|
|
|
priv->stations[i].lq = NULL;
|
2009-07-18 00:30:18 +08:00
|
|
|
}
|
2008-04-18 07:03:36 +08:00
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags);
|
2008-04-15 12:16:09 +08:00
|
|
|
}
|
2010-09-23 00:02:01 +08:00
|
|
|
EXPORT_SYMBOL_GPL(iwl_dealloc_bcast_stations);
|
2008-04-15 12:16:09 +08:00
|
|
|
|
2008-04-16 07:01:40 +08:00
|
|
|
#ifdef CONFIG_IWLWIFI_DEBUG
|
|
|
|
static void iwl_dump_lq_cmd(struct iwl_priv *priv,
|
|
|
|
struct iwl_link_quality_cmd *lq)
|
|
|
|
{
|
|
|
|
int i;
|
2009-01-28 06:27:56 +08:00
|
|
|
IWL_DEBUG_RATE(priv, "lq station id 0x%x\n", lq->sta_id);
|
|
|
|
IWL_DEBUG_RATE(priv, "lq ant 0x%X 0x%X\n",
|
2008-04-16 07:01:40 +08:00
|
|
|
lq->general_params.single_stream_ant_msk,
|
|
|
|
lq->general_params.dual_stream_ant_msk);
|
|
|
|
|
|
|
|
for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++)
|
2009-01-28 06:27:56 +08:00
|
|
|
IWL_DEBUG_RATE(priv, "lq index %d 0x%X\n",
|
2008-04-16 07:01:40 +08:00
|
|
|
i, lq->rs_table[i].rate_n_flags);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline void iwl_dump_lq_cmd(struct iwl_priv *priv,
|
|
|
|
struct iwl_link_quality_cmd *lq)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-04-14 07:11:19 +08:00
|
|
|
/**
|
|
|
|
* is_lq_table_valid() - Test one aspect of LQ cmd for validity
|
|
|
|
*
|
|
|
|
* It sometimes happens when a HT rate has been in use and we
|
|
|
|
* loose connectivity with AP then mac80211 will first tell us that the
|
|
|
|
* current channel is not HT anymore before removing the station. In such a
|
|
|
|
* scenario the RXON flags will be updated to indicate we are not
|
|
|
|
* communicating HT anymore, but the LQ command may still contain HT rates.
|
|
|
|
* Test for this to prevent driver from sending LQ command between the time
|
|
|
|
* RXON flags are updated and when LQ command is updated.
|
|
|
|
*/
|
|
|
|
static bool is_lq_table_valid(struct iwl_priv *priv,
|
2010-08-23 16:46:46 +08:00
|
|
|
struct iwl_rxon_context *ctx,
|
2010-04-14 07:11:19 +08:00
|
|
|
struct iwl_link_quality_cmd *lq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2010-08-23 16:46:46 +08:00
|
|
|
if (ctx->ht.enabled)
|
2010-04-14 07:11:19 +08:00
|
|
|
return true;
|
|
|
|
|
|
|
|
IWL_DEBUG_INFO(priv, "Channel %u is not an HT channel\n",
|
2010-08-23 16:46:32 +08:00
|
|
|
ctx->active.channel);
|
2010-04-14 07:11:19 +08:00
|
|
|
for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
|
|
|
|
if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) {
|
|
|
|
IWL_DEBUG_INFO(priv,
|
|
|
|
"index %d of LQ expects HT channel\n",
|
|
|
|
i);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-23 08:24:47 +08:00
|
|
|
/**
|
|
|
|
* iwl_send_lq_cmd() - Send link quality command
|
|
|
|
* @init: This command is sent as part of station initialization right
|
|
|
|
* after station has been added.
|
|
|
|
*
|
|
|
|
* The link quality command is sent as the last step of station creation.
|
|
|
|
* This is the special case in which init is set and we call a callback in
|
|
|
|
* this case to clear the state indicating that station creation is in
|
|
|
|
* progress.
|
|
|
|
*/
|
2010-08-23 16:46:46 +08:00
|
|
|
int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
|
2010-02-23 08:24:47 +08:00
|
|
|
struct iwl_link_quality_cmd *lq, u8 flags, bool init)
|
2008-04-16 07:01:40 +08:00
|
|
|
{
|
2010-02-23 08:24:47 +08:00
|
|
|
int ret = 0;
|
|
|
|
unsigned long flags_spin;
|
|
|
|
|
2008-04-16 07:01:40 +08:00
|
|
|
struct iwl_host_cmd cmd = {
|
|
|
|
.id = REPLY_TX_LINK_QUALITY_CMD,
|
|
|
|
.len = sizeof(struct iwl_link_quality_cmd),
|
2009-07-25 02:13:05 +08:00
|
|
|
.flags = flags,
|
2008-04-16 07:01:40 +08:00
|
|
|
.data = lq,
|
|
|
|
};
|
|
|
|
|
2010-03-30 17:46:29 +08:00
|
|
|
if (WARN_ON(lq->sta_id == IWL_INVALID_STATION))
|
2008-04-16 07:01:40 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2008-07-21 07:40:14 +08:00
|
|
|
iwl_dump_lq_cmd(priv, lq);
|
2010-02-23 08:24:47 +08:00
|
|
|
BUG_ON(init && (cmd.flags & CMD_ASYNC));
|
2008-04-16 07:01:40 +08:00
|
|
|
|
2010-08-23 16:46:46 +08:00
|
|
|
if (is_lq_table_valid(priv, ctx, lq))
|
2010-04-14 07:11:19 +08:00
|
|
|
ret = iwl_send_cmd(priv, &cmd);
|
|
|
|
else
|
|
|
|
ret = -EINVAL;
|
2010-04-24 01:33:33 +08:00
|
|
|
|
|
|
|
if (cmd.flags & CMD_ASYNC)
|
2010-02-23 08:24:47 +08:00
|
|
|
return ret;
|
2008-04-16 07:01:40 +08:00
|
|
|
|
2010-02-23 08:24:47 +08:00
|
|
|
if (init) {
|
2010-03-25 05:19:58 +08:00
|
|
|
IWL_DEBUG_INFO(priv, "init LQ command complete, clearing sta addition status for sta %d\n",
|
2010-02-23 08:24:47 +08:00
|
|
|
lq->sta_id);
|
|
|
|
spin_lock_irqsave(&priv->sta_lock, flags_spin);
|
|
|
|
priv->stations[lq->sta_id].used &= ~IWL_STA_UCODE_INPROGRESS;
|
|
|
|
spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
|
|
|
|
}
|
2010-04-24 01:33:33 +08:00
|
|
|
return ret;
|
2008-04-16 07:01:40 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(iwl_send_lq_cmd);
|
|
|
|
|
2010-02-23 08:24:47 +08:00
|
|
|
int iwl_mac_sta_remove(struct ieee80211_hw *hw,
|
2010-05-01 02:30:43 +08:00
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta)
|
2010-02-23 08:24:47 +08:00
|
|
|
{
|
|
|
|
struct iwl_priv *priv = hw->priv;
|
2010-05-01 02:30:43 +08:00
|
|
|
struct iwl_station_priv_common *sta_common = (void *)sta->drv_priv;
|
|
|
|
int ret;
|
|
|
|
|
2010-02-23 08:24:47 +08:00
|
|
|
IWL_DEBUG_INFO(priv, "received request to remove station %pM\n",
|
|
|
|
sta->addr);
|
2010-05-29 00:28:39 +08:00
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n",
|
|
|
|
sta->addr);
|
2010-05-01 02:30:43 +08:00
|
|
|
ret = iwl_remove_station(priv, sta_common->sta_id, sta->addr);
|
2010-02-23 08:24:47 +08:00
|
|
|
if (ret)
|
|
|
|
IWL_ERR(priv, "Error removing station %pM\n",
|
|
|
|
sta->addr);
|
2010-05-29 00:28:39 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
2010-02-23 08:24:47 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(iwl_mac_sta_remove);
|