2010-03-17 16:55:25 +08:00
|
|
|
/*
|
2011-05-17 16:06:18 +08:00
|
|
|
* Copyright (c) 2010-2011 Atheros Communications Inc.
|
2010-03-17 16:55:25 +08:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "htc.h"
|
|
|
|
|
|
|
|
/*************/
|
|
|
|
/* Utilities */
|
|
|
|
/*************/
|
|
|
|
|
|
|
|
/* HACK Alert: Use 11NG for 2.4, use 11NA for 5 */
|
|
|
|
static enum htc_phymode ath9k_htc_get_curmode(struct ath9k_htc_priv *priv,
|
|
|
|
struct ath9k_channel *ichan)
|
|
|
|
{
|
2013-10-12 05:30:53 +08:00
|
|
|
if (IS_CHAN_5GHZ(ichan))
|
|
|
|
return HTC_MODE_11NA;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2013-10-12 05:30:53 +08:00
|
|
|
return HTC_MODE_11NG;
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
2010-12-01 15:00:27 +08:00
|
|
|
bool ath9k_htc_setpower(struct ath9k_htc_priv *priv,
|
|
|
|
enum ath9k_power_mode mode)
|
2010-04-05 17:18:05 +08:00
|
|
|
{
|
|
|
|
bool ret;
|
|
|
|
|
|
|
|
mutex_lock(&priv->htc_pm_lock);
|
|
|
|
ret = ath9k_hw_setpower(priv->ah, mode);
|
|
|
|
mutex_unlock(&priv->htc_pm_lock);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ath9k_htc_ps_wakeup(struct ath9k_htc_priv *priv)
|
|
|
|
{
|
|
|
|
mutex_lock(&priv->htc_pm_lock);
|
|
|
|
if (++priv->ps_usecount != 1)
|
|
|
|
goto unlock;
|
|
|
|
ath9k_hw_setpower(priv->ah, ATH9K_PM_AWAKE);
|
|
|
|
|
|
|
|
unlock:
|
|
|
|
mutex_unlock(&priv->htc_pm_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ath9k_htc_ps_restore(struct ath9k_htc_priv *priv)
|
|
|
|
{
|
2012-06-25 16:24:49 +08:00
|
|
|
bool reset;
|
|
|
|
|
2010-04-05 17:18:05 +08:00
|
|
|
mutex_lock(&priv->htc_pm_lock);
|
|
|
|
if (--priv->ps_usecount != 0)
|
|
|
|
goto unlock;
|
|
|
|
|
2012-06-25 16:24:49 +08:00
|
|
|
if (priv->ps_idle) {
|
|
|
|
ath9k_hw_setrxabort(priv->ah, true);
|
|
|
|
ath9k_hw_stopdmarecv(priv->ah, &reset);
|
2010-04-27 15:35:37 +08:00
|
|
|
ath9k_hw_setpower(priv->ah, ATH9K_PM_FULL_SLEEP);
|
2012-06-25 16:24:49 +08:00
|
|
|
} else if (priv->ps_enabled) {
|
2010-04-05 17:18:05 +08:00
|
|
|
ath9k_hw_setpower(priv->ah, ATH9K_PM_NETWORK_SLEEP);
|
2012-06-25 16:24:49 +08:00
|
|
|
}
|
2010-04-27 15:35:37 +08:00
|
|
|
|
2010-04-05 17:18:05 +08:00
|
|
|
unlock:
|
|
|
|
mutex_unlock(&priv->htc_pm_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ath9k_ps_work(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv =
|
|
|
|
container_of(work, struct ath9k_htc_priv,
|
|
|
|
ps_work);
|
|
|
|
ath9k_htc_setpower(priv, ATH9K_PM_AWAKE);
|
|
|
|
|
|
|
|
/* The chip wakes up after receiving the first beacon
|
|
|
|
while network sleep is enabled. For the driver to
|
|
|
|
be in sync with the hw, set the chip to awake and
|
|
|
|
only then set it to sleep.
|
|
|
|
*/
|
|
|
|
ath9k_htc_setpower(priv, ATH9K_PM_NETWORK_SLEEP);
|
|
|
|
}
|
|
|
|
|
2011-02-21 10:18:39 +08:00
|
|
|
static void ath9k_htc_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = data;
|
|
|
|
struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
|
|
|
|
|
2013-05-09 01:16:46 +08:00
|
|
|
if ((vif->type == NL80211_IFTYPE_AP ||
|
|
|
|
vif->type == NL80211_IFTYPE_MESH_POINT) &&
|
2014-05-14 17:09:21 +08:00
|
|
|
bss_conf->enable_beacon) {
|
2011-02-21 10:19:53 +08:00
|
|
|
priv->reconfig_beacon = true;
|
2014-05-14 17:09:21 +08:00
|
|
|
priv->rearm_ani = true;
|
|
|
|
}
|
2011-02-21 10:19:53 +08:00
|
|
|
|
2011-02-21 10:18:39 +08:00
|
|
|
if (bss_conf->assoc) {
|
|
|
|
priv->rearm_ani = true;
|
|
|
|
priv->reconfig_beacon = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath9k_htc_vif_reconfig(struct ath9k_htc_priv *priv)
|
|
|
|
{
|
|
|
|
priv->rearm_ani = false;
|
|
|
|
priv->reconfig_beacon = false;
|
|
|
|
|
2012-11-07 03:23:30 +08:00
|
|
|
ieee80211_iterate_active_interfaces_atomic(
|
|
|
|
priv->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
|
|
|
|
ath9k_htc_vif_iter, priv);
|
2011-02-21 10:18:39 +08:00
|
|
|
if (priv->rearm_ani)
|
2011-02-21 10:19:38 +08:00
|
|
|
ath9k_htc_start_ani(priv);
|
2011-02-21 10:18:39 +08:00
|
|
|
|
|
|
|
if (priv->reconfig_beacon) {
|
|
|
|
ath9k_htc_ps_wakeup(priv);
|
|
|
|
ath9k_htc_beacon_reconfig(priv);
|
|
|
|
ath9k_htc_ps_restore(priv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-21 10:18:46 +08:00
|
|
|
static void ath9k_htc_bssid_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct ath9k_vif_iter_data *iter_data = data;
|
|
|
|
int i;
|
|
|
|
|
2013-11-28 19:21:45 +08:00
|
|
|
if (iter_data->hw_macaddr != NULL) {
|
|
|
|
for (i = 0; i < ETH_ALEN; i++)
|
|
|
|
iter_data->mask[i] &= ~(iter_data->hw_macaddr[i] ^ mac[i]);
|
|
|
|
} else {
|
|
|
|
iter_data->hw_macaddr = mac;
|
|
|
|
}
|
2011-02-21 10:18:46 +08:00
|
|
|
}
|
|
|
|
|
2013-11-28 19:21:45 +08:00
|
|
|
static void ath9k_htc_set_mac_bssid_mask(struct ath9k_htc_priv *priv,
|
2011-02-21 10:18:46 +08:00
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ath9k_vif_iter_data iter_data;
|
|
|
|
|
|
|
|
/*
|
2013-11-28 19:21:45 +08:00
|
|
|
* Pick the MAC address of the first interface as the new hardware
|
|
|
|
* MAC address. The hardware will use it together with the BSSID mask
|
|
|
|
* when matching addresses.
|
2011-02-21 10:18:46 +08:00
|
|
|
*/
|
2013-11-28 19:21:45 +08:00
|
|
|
iter_data.hw_macaddr = NULL;
|
2011-02-21 10:18:46 +08:00
|
|
|
memset(&iter_data.mask, 0xff, ETH_ALEN);
|
|
|
|
|
|
|
|
if (vif)
|
|
|
|
ath9k_htc_bssid_iter(&iter_data, vif->addr, vif);
|
|
|
|
|
|
|
|
/* Get list of all active MAC addresses */
|
2012-11-07 03:23:30 +08:00
|
|
|
ieee80211_iterate_active_interfaces_atomic(
|
|
|
|
priv->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
|
|
|
|
ath9k_htc_bssid_iter, &iter_data);
|
2011-02-21 10:18:46 +08:00
|
|
|
|
|
|
|
memcpy(common->bssidmask, iter_data.mask, ETH_ALEN);
|
2013-11-28 19:21:45 +08:00
|
|
|
|
|
|
|
if (iter_data.hw_macaddr)
|
|
|
|
memcpy(common->macaddr, iter_data.hw_macaddr, ETH_ALEN);
|
|
|
|
|
2011-02-21 10:18:46 +08:00
|
|
|
ath_hw_setbssidmask(common);
|
|
|
|
}
|
|
|
|
|
2011-02-21 10:19:31 +08:00
|
|
|
static void ath9k_htc_set_opmode(struct ath9k_htc_priv *priv)
|
|
|
|
{
|
|
|
|
if (priv->num_ibss_vif)
|
|
|
|
priv->ah->opmode = NL80211_IFTYPE_ADHOC;
|
|
|
|
else if (priv->num_ap_vif)
|
|
|
|
priv->ah->opmode = NL80211_IFTYPE_AP;
|
2013-05-09 01:16:46 +08:00
|
|
|
else if (priv->num_mbss_vif)
|
|
|
|
priv->ah->opmode = NL80211_IFTYPE_MESH_POINT;
|
2011-02-21 10:19:31 +08:00
|
|
|
else
|
|
|
|
priv->ah->opmode = NL80211_IFTYPE_STATION;
|
|
|
|
|
|
|
|
ath9k_hw_setopmode(priv->ah);
|
|
|
|
}
|
|
|
|
|
2010-12-28 16:58:27 +08:00
|
|
|
void ath9k_htc_reset(struct ath9k_htc_priv *priv)
|
|
|
|
{
|
|
|
|
struct ath_hw *ah = priv->ah;
|
|
|
|
struct ath_common *common = ath9k_hw_common(ah);
|
2013-03-25 23:26:57 +08:00
|
|
|
struct ieee80211_channel *channel = priv->hw->conf.chandef.chan;
|
2011-01-15 04:03:28 +08:00
|
|
|
struct ath9k_hw_cal_data *caldata = NULL;
|
2010-12-28 16:58:27 +08:00
|
|
|
enum htc_phymode mode;
|
|
|
|
__be16 htc_mode;
|
|
|
|
u8 cmd_rsp;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
ath9k_htc_ps_wakeup(priv);
|
|
|
|
|
2011-02-21 10:19:38 +08:00
|
|
|
ath9k_htc_stop_ani(priv);
|
2010-12-28 16:58:27 +08:00
|
|
|
ieee80211_stop_queues(priv->hw);
|
2011-04-13 13:55:59 +08:00
|
|
|
|
2011-04-13 13:56:39 +08:00
|
|
|
del_timer_sync(&priv->tx.cleanup_timer);
|
2011-04-13 13:55:59 +08:00
|
|
|
ath9k_htc_tx_drain(priv);
|
|
|
|
|
2010-12-28 16:58:27 +08:00
|
|
|
WMI_CMD(WMI_DISABLE_INTR_CMDID);
|
|
|
|
WMI_CMD(WMI_DRAIN_TXQ_ALL_CMDID);
|
|
|
|
WMI_CMD(WMI_STOP_RECV_CMDID);
|
|
|
|
|
2011-04-13 13:53:52 +08:00
|
|
|
ath9k_wmi_event_drain(priv);
|
|
|
|
|
2011-01-15 04:03:28 +08:00
|
|
|
caldata = &priv->caldata;
|
2010-12-28 16:58:27 +08:00
|
|
|
ret = ath9k_hw_reset(ah, ah->curchan, caldata, false);
|
|
|
|
if (ret) {
|
|
|
|
ath_err(common,
|
|
|
|
"Unable to reset device (%u Mhz) reset status %d\n",
|
|
|
|
channel->center_freq, ret);
|
|
|
|
}
|
|
|
|
|
2011-02-01 02:17:45 +08:00
|
|
|
ath9k_cmn_update_txpow(ah, priv->curtxpow, priv->txpowlimit,
|
|
|
|
&priv->curtxpow);
|
2010-12-28 16:58:27 +08:00
|
|
|
|
|
|
|
WMI_CMD(WMI_START_RECV_CMDID);
|
|
|
|
ath9k_host_rx_init(priv);
|
|
|
|
|
|
|
|
mode = ath9k_htc_get_curmode(priv, ah->curchan);
|
|
|
|
htc_mode = cpu_to_be16(mode);
|
|
|
|
WMI_CMD_BUF(WMI_SET_MODE_CMDID, &htc_mode);
|
|
|
|
|
|
|
|
WMI_CMD(WMI_ENABLE_INTR_CMDID);
|
|
|
|
htc_start(priv->htc);
|
2011-02-21 10:18:39 +08:00
|
|
|
ath9k_htc_vif_reconfig(priv);
|
2010-12-28 16:58:27 +08:00
|
|
|
ieee80211_wake_queues(priv->hw);
|
|
|
|
|
2011-04-13 13:56:39 +08:00
|
|
|
mod_timer(&priv->tx.cleanup_timer,
|
|
|
|
jiffies + msecs_to_jiffies(ATH9K_HTC_TX_CLEANUP_INTERVAL));
|
|
|
|
|
2010-12-28 16:58:27 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
}
|
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv,
|
|
|
|
struct ieee80211_hw *hw,
|
|
|
|
struct ath9k_channel *hchan)
|
|
|
|
{
|
|
|
|
struct ath_hw *ah = priv->ah;
|
|
|
|
struct ath_common *common = ath9k_hw_common(ah);
|
|
|
|
struct ieee80211_conf *conf = &common->hw->conf;
|
2010-12-28 16:58:37 +08:00
|
|
|
bool fastcc;
|
2013-03-25 23:26:57 +08:00
|
|
|
struct ieee80211_channel *channel = hw->conf.chandef.chan;
|
2011-02-18 18:39:51 +08:00
|
|
|
struct ath9k_hw_cal_data *caldata = NULL;
|
2010-03-17 16:55:25 +08:00
|
|
|
enum htc_phymode mode;
|
2010-04-16 14:24:03 +08:00
|
|
|
__be16 htc_mode;
|
2010-03-17 16:55:25 +08:00
|
|
|
u8 cmd_rsp;
|
|
|
|
int ret;
|
|
|
|
|
2014-03-02 04:15:49 +08:00
|
|
|
if (test_bit(ATH_OP_INVALID, &common->op_flags))
|
2010-03-17 16:55:25 +08:00
|
|
|
return -EIO;
|
|
|
|
|
2010-12-28 16:58:37 +08:00
|
|
|
fastcc = !!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2010-04-05 17:18:05 +08:00
|
|
|
ath9k_htc_ps_wakeup(priv);
|
2011-04-13 13:55:59 +08:00
|
|
|
|
2014-05-14 17:09:21 +08:00
|
|
|
ath9k_htc_stop_ani(priv);
|
2011-04-13 13:56:39 +08:00
|
|
|
del_timer_sync(&priv->tx.cleanup_timer);
|
2011-04-13 13:55:59 +08:00
|
|
|
ath9k_htc_tx_drain(priv);
|
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
WMI_CMD(WMI_DISABLE_INTR_CMDID);
|
|
|
|
WMI_CMD(WMI_DRAIN_TXQ_ALL_CMDID);
|
|
|
|
WMI_CMD(WMI_STOP_RECV_CMDID);
|
|
|
|
|
2011-04-13 13:53:52 +08:00
|
|
|
ath9k_wmi_event_drain(priv);
|
|
|
|
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2010-12-03 11:12:37 +08:00
|
|
|
"(%u MHz) -> (%u MHz), HT: %d, HT40: %d fastcc: %d\n",
|
|
|
|
priv->ah->curchan->channel,
|
|
|
|
channel->center_freq, conf_is_ht(conf), conf_is_ht40(conf),
|
|
|
|
fastcc);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2011-01-15 04:03:28 +08:00
|
|
|
if (!fastcc)
|
|
|
|
caldata = &priv->caldata;
|
2011-04-13 13:55:59 +08:00
|
|
|
|
2010-07-31 06:12:00 +08:00
|
|
|
ret = ath9k_hw_reset(ah, hchan, caldata, fastcc);
|
2010-03-17 16:55:25 +08:00
|
|
|
if (ret) {
|
2010-12-03 11:12:36 +08:00
|
|
|
ath_err(common,
|
|
|
|
"Unable to reset channel (%u Mhz) reset status %d\n",
|
|
|
|
channel->center_freq, ret);
|
2010-03-17 16:55:25 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2011-02-01 02:17:45 +08:00
|
|
|
ath9k_cmn_update_txpow(ah, priv->curtxpow, priv->txpowlimit,
|
|
|
|
&priv->curtxpow);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
WMI_CMD(WMI_START_RECV_CMDID);
|
|
|
|
if (ret)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
ath9k_host_rx_init(priv);
|
|
|
|
|
|
|
|
mode = ath9k_htc_get_curmode(priv, hchan);
|
|
|
|
htc_mode = cpu_to_be16(mode);
|
|
|
|
WMI_CMD_BUF(WMI_SET_MODE_CMDID, &htc_mode);
|
|
|
|
if (ret)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
WMI_CMD(WMI_ENABLE_INTR_CMDID);
|
|
|
|
if (ret)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
htc_start(priv->htc);
|
2011-02-21 10:19:53 +08:00
|
|
|
|
2014-03-02 04:15:49 +08:00
|
|
|
if (!test_bit(ATH_OP_SCANNING, &common->op_flags) &&
|
2011-02-21 10:19:53 +08:00
|
|
|
!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL))
|
|
|
|
ath9k_htc_vif_reconfig(priv);
|
|
|
|
|
2011-04-13 13:56:39 +08:00
|
|
|
mod_timer(&priv->tx.cleanup_timer,
|
|
|
|
jiffies + msecs_to_jiffies(ATH9K_HTC_TX_CLEANUP_INTERVAL));
|
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
err:
|
2010-04-05 17:18:05 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-02-21 10:18:00 +08:00
|
|
|
/*
|
|
|
|
* Monitor mode handling is a tad complicated because the firmware requires
|
|
|
|
* an interface to be created exclusively, while mac80211 doesn't associate
|
|
|
|
* an interface with the mode.
|
|
|
|
*
|
|
|
|
* So, for now, only one monitor interface can be configured.
|
|
|
|
*/
|
2011-01-03 23:52:18 +08:00
|
|
|
static void __ath9k_htc_remove_monitor_interface(struct ath9k_htc_priv *priv)
|
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ath9k_htc_target_vif hvif;
|
|
|
|
int ret = 0;
|
|
|
|
u8 cmd_rsp;
|
|
|
|
|
|
|
|
memset(&hvif, 0, sizeof(struct ath9k_htc_target_vif));
|
|
|
|
memcpy(&hvif.myaddr, common->macaddr, ETH_ALEN);
|
2011-02-21 10:18:00 +08:00
|
|
|
hvif.index = priv->mon_vif_idx;
|
2011-01-03 23:52:18 +08:00
|
|
|
WMI_CMD_BUF(WMI_VAP_REMOVE_CMDID, &hvif);
|
2011-04-20 13:30:34 +08:00
|
|
|
if (ret) {
|
|
|
|
ath_err(common, "Unable to remove monitor interface at idx: %d\n",
|
|
|
|
priv->mon_vif_idx);
|
|
|
|
}
|
|
|
|
|
2011-01-03 23:52:18 +08:00
|
|
|
priv->nvifs--;
|
2011-02-21 10:18:00 +08:00
|
|
|
priv->vif_slot &= ~(1 << priv->mon_vif_idx);
|
2011-01-03 23:52:18 +08:00
|
|
|
}
|
|
|
|
|
2010-11-27 01:54:33 +08:00
|
|
|
static int ath9k_htc_add_monitor_interface(struct ath9k_htc_priv *priv)
|
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ath9k_htc_target_vif hvif;
|
2011-01-03 23:52:18 +08:00
|
|
|
struct ath9k_htc_target_sta tsta;
|
2011-02-21 10:18:00 +08:00
|
|
|
int ret = 0, sta_idx;
|
2010-11-27 01:54:33 +08:00
|
|
|
u8 cmd_rsp;
|
|
|
|
|
2011-02-21 10:18:00 +08:00
|
|
|
if ((priv->nvifs >= ATH9K_HTC_MAX_VIF) ||
|
|
|
|
(priv->nstations >= ATH9K_HTC_MAX_STA)) {
|
|
|
|
ret = -ENOBUFS;
|
|
|
|
goto err_vif;
|
|
|
|
}
|
2010-11-27 01:54:33 +08:00
|
|
|
|
2011-02-21 10:18:00 +08:00
|
|
|
sta_idx = ffz(priv->sta_slot);
|
|
|
|
if ((sta_idx < 0) || (sta_idx > ATH9K_HTC_MAX_STA)) {
|
|
|
|
ret = -ENOBUFS;
|
|
|
|
goto err_vif;
|
|
|
|
}
|
2011-01-03 23:52:18 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add an interface.
|
|
|
|
*/
|
2010-11-27 01:54:33 +08:00
|
|
|
memset(&hvif, 0, sizeof(struct ath9k_htc_target_vif));
|
|
|
|
memcpy(&hvif.myaddr, common->macaddr, ETH_ALEN);
|
|
|
|
|
2011-04-13 13:54:43 +08:00
|
|
|
hvif.opmode = HTC_M_MONITOR;
|
2011-02-21 10:18:00 +08:00
|
|
|
hvif.index = ffz(priv->vif_slot);
|
2010-11-27 01:54:33 +08:00
|
|
|
|
|
|
|
WMI_CMD_BUF(WMI_VAP_CREATE_CMDID, &hvif);
|
|
|
|
if (ret)
|
2011-02-21 10:18:00 +08:00
|
|
|
goto err_vif;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assign the monitor interface index as a special case here.
|
|
|
|
* This is needed when the interface is brought down.
|
|
|
|
*/
|
|
|
|
priv->mon_vif_idx = hvif.index;
|
|
|
|
priv->vif_slot |= (1 << hvif.index);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the hardware mode to monitor only if there are no
|
|
|
|
* other interfaces.
|
|
|
|
*/
|
|
|
|
if (!priv->nvifs)
|
|
|
|
priv->ah->opmode = NL80211_IFTYPE_MONITOR;
|
2010-11-27 01:54:33 +08:00
|
|
|
|
|
|
|
priv->nvifs++;
|
2011-01-03 23:52:18 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Associate a station with the interface for packet injection.
|
|
|
|
*/
|
|
|
|
memset(&tsta, 0, sizeof(struct ath9k_htc_target_sta));
|
|
|
|
|
|
|
|
memcpy(&tsta.macaddr, common->macaddr, ETH_ALEN);
|
|
|
|
|
|
|
|
tsta.is_vif_sta = 1;
|
2011-02-21 10:18:00 +08:00
|
|
|
tsta.sta_index = sta_idx;
|
2011-01-03 23:52:18 +08:00
|
|
|
tsta.vif_index = hvif.index;
|
2011-04-13 13:54:37 +08:00
|
|
|
tsta.maxampdu = cpu_to_be16(0xffff);
|
2011-01-03 23:52:18 +08:00
|
|
|
|
|
|
|
WMI_CMD_BUF(WMI_NODE_CREATE_CMDID, &tsta);
|
|
|
|
if (ret) {
|
|
|
|
ath_err(common, "Unable to add station entry for monitor mode\n");
|
2011-02-21 10:18:00 +08:00
|
|
|
goto err_sta;
|
2011-01-03 23:52:18 +08:00
|
|
|
}
|
|
|
|
|
2011-02-21 10:18:00 +08:00
|
|
|
priv->sta_slot |= (1 << sta_idx);
|
2011-01-03 23:52:18 +08:00
|
|
|
priv->nstations++;
|
2011-02-21 10:18:00 +08:00
|
|
|
priv->vif_sta_pos[priv->mon_vif_idx] = sta_idx;
|
2011-01-05 03:36:21 +08:00
|
|
|
priv->ah->is_monitoring = true;
|
|
|
|
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2011-02-21 10:18:00 +08:00
|
|
|
"Attached a monitor interface at idx: %d, sta idx: %d\n",
|
|
|
|
priv->mon_vif_idx, sta_idx);
|
|
|
|
|
2010-11-27 01:54:33 +08:00
|
|
|
return 0;
|
2011-01-03 23:52:18 +08:00
|
|
|
|
2011-02-21 10:18:00 +08:00
|
|
|
err_sta:
|
2011-01-03 23:52:18 +08:00
|
|
|
/*
|
|
|
|
* Remove the interface from the target.
|
|
|
|
*/
|
|
|
|
__ath9k_htc_remove_monitor_interface(priv);
|
2011-02-21 10:18:00 +08:00
|
|
|
err_vif:
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, FATAL, "Unable to attach a monitor interface\n");
|
2011-02-21 10:18:00 +08:00
|
|
|
|
2011-01-03 23:52:18 +08:00
|
|
|
return ret;
|
2010-11-27 01:54:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ath9k_htc_remove_monitor_interface(struct ath9k_htc_priv *priv)
|
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
int ret = 0;
|
2011-01-03 23:52:18 +08:00
|
|
|
u8 cmd_rsp, sta_idx;
|
2010-11-27 01:54:33 +08:00
|
|
|
|
2011-01-03 23:52:18 +08:00
|
|
|
__ath9k_htc_remove_monitor_interface(priv);
|
2010-11-27 01:54:33 +08:00
|
|
|
|
2011-02-21 10:18:00 +08:00
|
|
|
sta_idx = priv->vif_sta_pos[priv->mon_vif_idx];
|
2011-01-03 23:52:18 +08:00
|
|
|
|
|
|
|
WMI_CMD_BUF(WMI_NODE_REMOVE_CMDID, &sta_idx);
|
|
|
|
if (ret) {
|
|
|
|
ath_err(common, "Unable to remove station entry for monitor mode\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-02-21 10:18:00 +08:00
|
|
|
priv->sta_slot &= ~(1 << sta_idx);
|
2011-01-03 23:52:18 +08:00
|
|
|
priv->nstations--;
|
2011-01-05 03:36:21 +08:00
|
|
|
priv->ah->is_monitoring = false;
|
2011-01-03 23:52:18 +08:00
|
|
|
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2011-02-21 10:18:00 +08:00
|
|
|
"Removed a monitor interface at idx: %d, sta idx: %d\n",
|
|
|
|
priv->mon_vif_idx, sta_idx);
|
|
|
|
|
2011-01-03 23:52:18 +08:00
|
|
|
return 0;
|
2010-11-27 01:54:33 +08:00
|
|
|
}
|
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
static int ath9k_htc_add_station(struct ath9k_htc_priv *priv,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta)
|
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ath9k_htc_target_sta tsta;
|
|
|
|
struct ath9k_htc_vif *avp = (struct ath9k_htc_vif *) vif->drv_priv;
|
|
|
|
struct ath9k_htc_sta *ista;
|
2011-02-21 10:18:00 +08:00
|
|
|
int ret, sta_idx;
|
2010-03-17 16:55:25 +08:00
|
|
|
u8 cmd_rsp;
|
2011-04-20 13:31:00 +08:00
|
|
|
u16 maxampdu;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
if (priv->nstations >= ATH9K_HTC_MAX_STA)
|
|
|
|
return -ENOBUFS;
|
|
|
|
|
2011-02-21 10:18:00 +08:00
|
|
|
sta_idx = ffz(priv->sta_slot);
|
|
|
|
if ((sta_idx < 0) || (sta_idx > ATH9K_HTC_MAX_STA))
|
|
|
|
return -ENOBUFS;
|
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
memset(&tsta, 0, sizeof(struct ath9k_htc_target_sta));
|
|
|
|
|
|
|
|
if (sta) {
|
|
|
|
ista = (struct ath9k_htc_sta *) sta->drv_priv;
|
|
|
|
memcpy(&tsta.macaddr, sta->addr, ETH_ALEN);
|
|
|
|
memcpy(&tsta.bssid, common->curbssid, ETH_ALEN);
|
2011-02-21 10:18:00 +08:00
|
|
|
ista->index = sta_idx;
|
2012-09-04 22:03:37 +08:00
|
|
|
tsta.is_vif_sta = 0;
|
|
|
|
maxampdu = 1 << (IEEE80211_HT_MAX_AMPDU_FACTOR +
|
|
|
|
sta->ht_cap.ampdu_factor);
|
|
|
|
tsta.maxampdu = cpu_to_be16(maxampdu);
|
2010-03-17 16:55:25 +08:00
|
|
|
} else {
|
|
|
|
memcpy(&tsta.macaddr, vif->addr, ETH_ALEN);
|
|
|
|
tsta.is_vif_sta = 1;
|
2012-09-04 22:03:37 +08:00
|
|
|
tsta.maxampdu = cpu_to_be16(0xffff);
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
2011-02-21 10:18:00 +08:00
|
|
|
tsta.sta_index = sta_idx;
|
2010-03-17 16:55:25 +08:00
|
|
|
tsta.vif_index = avp->index;
|
2011-04-20 13:31:00 +08:00
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
WMI_CMD_BUF(WMI_NODE_CREATE_CMDID, &tsta);
|
|
|
|
if (ret) {
|
|
|
|
if (sta)
|
2010-12-03 11:12:36 +08:00
|
|
|
ath_err(common,
|
|
|
|
"Unable to add station entry for: %pM\n",
|
|
|
|
sta->addr);
|
2010-03-17 16:55:25 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-02-21 10:18:00 +08:00
|
|
|
if (sta) {
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2010-12-03 11:12:37 +08:00
|
|
|
"Added a station entry for: %pM (idx: %d)\n",
|
|
|
|
sta->addr, tsta.sta_index);
|
2011-02-21 10:18:00 +08:00
|
|
|
} else {
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2011-02-21 10:18:00 +08:00
|
|
|
"Added a station entry for VIF %d (idx: %d)\n",
|
|
|
|
avp->index, tsta.sta_index);
|
|
|
|
}
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2011-02-21 10:18:00 +08:00
|
|
|
priv->sta_slot |= (1 << sta_idx);
|
2010-03-17 16:55:25 +08:00
|
|
|
priv->nstations++;
|
2011-02-21 10:18:00 +08:00
|
|
|
if (!sta)
|
|
|
|
priv->vif_sta_pos[avp->index] = sta_idx;
|
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ath9k_htc_remove_station(struct ath9k_htc_priv *priv,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta)
|
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
2011-02-21 10:18:00 +08:00
|
|
|
struct ath9k_htc_vif *avp = (struct ath9k_htc_vif *) vif->drv_priv;
|
2010-03-17 16:55:25 +08:00
|
|
|
struct ath9k_htc_sta *ista;
|
|
|
|
int ret;
|
|
|
|
u8 cmd_rsp, sta_idx;
|
|
|
|
|
|
|
|
if (sta) {
|
|
|
|
ista = (struct ath9k_htc_sta *) sta->drv_priv;
|
|
|
|
sta_idx = ista->index;
|
|
|
|
} else {
|
2011-02-21 10:18:00 +08:00
|
|
|
sta_idx = priv->vif_sta_pos[avp->index];
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
WMI_CMD_BUF(WMI_NODE_REMOVE_CMDID, &sta_idx);
|
|
|
|
if (ret) {
|
|
|
|
if (sta)
|
2010-12-03 11:12:36 +08:00
|
|
|
ath_err(common,
|
|
|
|
"Unable to remove station entry for: %pM\n",
|
|
|
|
sta->addr);
|
2010-03-17 16:55:25 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-02-21 10:18:00 +08:00
|
|
|
if (sta) {
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2010-12-03 11:12:37 +08:00
|
|
|
"Removed a station entry for: %pM (idx: %d)\n",
|
|
|
|
sta->addr, sta_idx);
|
2011-02-21 10:18:00 +08:00
|
|
|
} else {
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2011-02-21 10:18:00 +08:00
|
|
|
"Removed a station entry for VIF %d (idx: %d)\n",
|
|
|
|
avp->index, sta_idx);
|
|
|
|
}
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2011-02-21 10:18:00 +08:00
|
|
|
priv->sta_slot &= ~(1 << sta_idx);
|
2010-03-17 16:55:25 +08:00
|
|
|
priv->nstations--;
|
2011-02-21 10:18:00 +08:00
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-04-20 17:03:28 +08:00
|
|
|
int ath9k_htc_update_cap_target(struct ath9k_htc_priv *priv,
|
|
|
|
u8 enable_coex)
|
2010-03-17 16:55:25 +08:00
|
|
|
{
|
|
|
|
struct ath9k_htc_cap_target tcap;
|
|
|
|
int ret;
|
|
|
|
u8 cmd_rsp;
|
|
|
|
|
|
|
|
memset(&tcap, 0, sizeof(struct ath9k_htc_cap_target));
|
|
|
|
|
2011-04-20 17:03:28 +08:00
|
|
|
tcap.ampdu_limit = cpu_to_be32(0xffff);
|
2011-05-17 15:12:14 +08:00
|
|
|
tcap.ampdu_subframes = 0xff;
|
2011-04-20 17:03:28 +08:00
|
|
|
tcap.enable_coex = enable_coex;
|
2010-06-02 18:23:43 +08:00
|
|
|
tcap.tx_chainmask = priv->ah->caps.tx_chainmask;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
WMI_CMD_BUF(WMI_TARGET_IC_UPDATE_CMDID, &tcap);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-05-17 14:31:16 +08:00
|
|
|
static void ath9k_htc_setup_rate(struct ath9k_htc_priv *priv,
|
|
|
|
struct ieee80211_sta *sta,
|
|
|
|
struct ath9k_htc_target_rate *trate)
|
2010-03-17 16:55:25 +08:00
|
|
|
{
|
|
|
|
struct ath9k_htc_sta *ista = (struct ath9k_htc_sta *) sta->drv_priv;
|
|
|
|
struct ieee80211_supported_band *sband;
|
|
|
|
u32 caps = 0;
|
2010-05-17 14:31:16 +08:00
|
|
|
int i, j;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2013-03-25 23:26:57 +08:00
|
|
|
sband = priv->hw->wiphy->bands[priv->hw->conf.chandef.chan->band];
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
for (i = 0, j = 0; i < sband->n_bitrates; i++) {
|
|
|
|
if (sta->supp_rates[sband->band] & BIT(i)) {
|
2010-05-17 14:31:16 +08:00
|
|
|
trate->rates.legacy_rates.rs_rates[j]
|
2010-03-17 16:55:25 +08:00
|
|
|
= (sband->bitrates[i].bitrate * 2) / 10;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
2010-05-17 14:31:16 +08:00
|
|
|
trate->rates.legacy_rates.rs_nrates = j;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
if (sta->ht_cap.ht_supported) {
|
|
|
|
for (i = 0, j = 0; i < 77; i++) {
|
|
|
|
if (sta->ht_cap.mcs.rx_mask[i/8] & (1<<(i%8)))
|
2010-05-17 14:31:16 +08:00
|
|
|
trate->rates.ht_rates.rs_rates[j++] = i;
|
2010-03-17 16:55:25 +08:00
|
|
|
if (j == ATH_HTC_RATE_MAX)
|
|
|
|
break;
|
|
|
|
}
|
2010-05-17 14:31:16 +08:00
|
|
|
trate->rates.ht_rates.rs_nrates = j;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
caps = WLAN_RC_HT_FLAG;
|
2013-06-10 00:51:24 +08:00
|
|
|
if (sta->ht_cap.cap & IEEE80211_HT_CAP_RX_STBC)
|
|
|
|
caps |= ATH_RC_TX_STBC_FLAG;
|
2010-06-12 23:22:33 +08:00
|
|
|
if (sta->ht_cap.mcs.rx_mask[1])
|
|
|
|
caps |= WLAN_RC_DS_FLAG;
|
2010-08-12 16:53:28 +08:00
|
|
|
if ((sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) &&
|
|
|
|
(conf_is_ht40(&priv->hw->conf)))
|
2010-03-17 16:55:25 +08:00
|
|
|
caps |= WLAN_RC_40_FLAG;
|
2010-05-17 14:31:19 +08:00
|
|
|
if (conf_is_ht40(&priv->hw->conf) &&
|
|
|
|
(sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40))
|
|
|
|
caps |= WLAN_RC_SGI_FLAG;
|
|
|
|
else if (conf_is_ht20(&priv->hw->conf) &&
|
|
|
|
(sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20))
|
2010-03-17 16:55:25 +08:00
|
|
|
caps |= WLAN_RC_SGI_FLAG;
|
|
|
|
}
|
|
|
|
|
2010-05-17 14:31:16 +08:00
|
|
|
trate->sta_index = ista->index;
|
|
|
|
trate->isnew = 1;
|
|
|
|
trate->capflags = cpu_to_be32(caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ath9k_htc_send_rate_cmd(struct ath9k_htc_priv *priv,
|
|
|
|
struct ath9k_htc_target_rate *trate)
|
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
int ret;
|
|
|
|
u8 cmd_rsp;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2010-05-17 14:31:16 +08:00
|
|
|
WMI_CMD_BUF(WMI_RC_RATE_UPDATE_CMDID, trate);
|
2010-03-17 16:55:25 +08:00
|
|
|
if (ret) {
|
2010-12-03 11:12:36 +08:00
|
|
|
ath_err(common,
|
|
|
|
"Unable to initialize Rate information on target\n");
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
2010-05-17 14:31:16 +08:00
|
|
|
return ret;
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
2010-05-17 14:31:16 +08:00
|
|
|
static void ath9k_htc_init_rate(struct ath9k_htc_priv *priv,
|
|
|
|
struct ieee80211_sta *sta)
|
2010-03-17 16:55:25 +08:00
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
2010-05-17 14:31:16 +08:00
|
|
|
struct ath9k_htc_target_rate trate;
|
2010-03-17 16:55:25 +08:00
|
|
|
int ret;
|
|
|
|
|
2010-05-17 14:31:16 +08:00
|
|
|
memset(&trate, 0, sizeof(struct ath9k_htc_target_rate));
|
|
|
|
ath9k_htc_setup_rate(priv, sta, &trate);
|
|
|
|
ret = ath9k_htc_send_rate_cmd(priv, &trate);
|
|
|
|
if (!ret)
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2010-12-03 11:12:37 +08:00
|
|
|
"Updated target sta: %pM, rate caps: 0x%X\n",
|
|
|
|
sta->addr, be32_to_cpu(trate.capflags));
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
2010-05-17 14:31:18 +08:00
|
|
|
static void ath9k_htc_update_rate(struct ath9k_htc_priv *priv,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_bss_conf *bss_conf)
|
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ath9k_htc_target_rate trate;
|
|
|
|
struct ieee80211_sta *sta;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(&trate, 0, sizeof(struct ath9k_htc_target_rate));
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
sta = ieee80211_find_sta(vif, bss_conf->bssid);
|
|
|
|
if (!sta) {
|
|
|
|
rcu_read_unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ath9k_htc_setup_rate(priv, sta, &trate);
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
ret = ath9k_htc_send_rate_cmd(priv, &trate);
|
|
|
|
if (!ret)
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2010-12-03 11:12:37 +08:00
|
|
|
"Updated target sta: %pM, rate caps: 0x%X\n",
|
|
|
|
bss_conf->bssid, be32_to_cpu(trate.capflags));
|
2010-05-17 14:31:18 +08:00
|
|
|
}
|
|
|
|
|
2010-07-14 09:27:25 +08:00
|
|
|
static int ath9k_htc_tx_aggr_oper(struct ath9k_htc_priv *priv,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta,
|
|
|
|
enum ieee80211_ampdu_mlme_action action,
|
|
|
|
u16 tid)
|
2010-03-17 16:55:25 +08:00
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ath9k_htc_target_aggr aggr;
|
2010-05-09 00:23:20 +08:00
|
|
|
struct ath9k_htc_sta *ista;
|
2010-03-17 16:55:25 +08:00
|
|
|
int ret = 0;
|
|
|
|
u8 cmd_rsp;
|
|
|
|
|
2010-05-09 00:24:02 +08:00
|
|
|
if (tid >= ATH9K_HTC_MAX_TID)
|
2010-03-17 16:55:25 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2010-03-29 18:37:11 +08:00
|
|
|
memset(&aggr, 0, sizeof(struct ath9k_htc_target_aggr));
|
|
|
|
ista = (struct ath9k_htc_sta *) sta->drv_priv;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
aggr.sta_index = ista->index;
|
2010-06-15 12:54:37 +08:00
|
|
|
aggr.tidno = tid & 0xf;
|
|
|
|
aggr.aggr_enable = (action == IEEE80211_AMPDU_TX_START) ? true : false;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
WMI_CMD_BUF(WMI_TX_AGGR_ENABLE_CMDID, &aggr);
|
|
|
|
if (ret)
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2010-12-03 11:12:37 +08:00
|
|
|
"Unable to %s TX aggregation for (%pM, %d)\n",
|
|
|
|
(aggr.aggr_enable) ? "start" : "stop", sta->addr, tid);
|
2010-03-17 16:55:25 +08:00
|
|
|
else
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2010-12-03 11:12:37 +08:00
|
|
|
"%s TX aggregation for (%pM, %d)\n",
|
|
|
|
(aggr.aggr_enable) ? "Starting" : "Stopping",
|
|
|
|
sta->addr, tid);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2011-04-13 13:55:00 +08:00
|
|
|
spin_lock_bh(&priv->tx.tx_lock);
|
2010-06-15 12:54:37 +08:00
|
|
|
ista->tid_state[tid] = (aggr.aggr_enable && !ret) ? AGGR_START : AGGR_STOP;
|
2011-04-13 13:55:00 +08:00
|
|
|
spin_unlock_bh(&priv->tx.tx_lock);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2010-06-15 12:54:37 +08:00
|
|
|
return ret;
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******/
|
|
|
|
/* ANI */
|
|
|
|
/*******/
|
|
|
|
|
2011-02-21 10:19:38 +08:00
|
|
|
void ath9k_htc_start_ani(struct ath9k_htc_priv *priv)
|
2010-03-17 16:55:25 +08:00
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
unsigned long timestamp = jiffies_to_msecs(jiffies);
|
|
|
|
|
|
|
|
common->ani.longcal_timer = timestamp;
|
|
|
|
common->ani.shortcal_timer = timestamp;
|
|
|
|
common->ani.checkani_timer = timestamp;
|
|
|
|
|
2014-03-02 04:15:49 +08:00
|
|
|
set_bit(ATH_OP_ANI_RUN, &common->op_flags);
|
2011-02-21 10:19:38 +08:00
|
|
|
|
|
|
|
ieee80211_queue_delayed_work(common->hw, &priv->ani_work,
|
2010-03-17 16:55:25 +08:00
|
|
|
msecs_to_jiffies(ATH_ANI_POLLINTERVAL));
|
|
|
|
}
|
|
|
|
|
2011-02-21 10:19:38 +08:00
|
|
|
void ath9k_htc_stop_ani(struct ath9k_htc_priv *priv)
|
|
|
|
{
|
2014-03-02 04:15:49 +08:00
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
2011-02-21 10:19:38 +08:00
|
|
|
cancel_delayed_work_sync(&priv->ani_work);
|
2014-03-02 04:15:49 +08:00
|
|
|
clear_bit(ATH_OP_ANI_RUN, &common->op_flags);
|
2011-02-21 10:19:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ath9k_htc_ani_work(struct work_struct *work)
|
2010-03-17 16:55:25 +08:00
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv =
|
2011-02-21 10:19:38 +08:00
|
|
|
container_of(work, struct ath9k_htc_priv, ani_work.work);
|
2010-03-17 16:55:25 +08:00
|
|
|
struct ath_hw *ah = priv->ah;
|
|
|
|
struct ath_common *common = ath9k_hw_common(ah);
|
|
|
|
bool longcal = false;
|
|
|
|
bool shortcal = false;
|
|
|
|
bool aniflag = false;
|
|
|
|
unsigned int timestamp = jiffies_to_msecs(jiffies);
|
|
|
|
u32 cal_interval, short_cal_interval;
|
|
|
|
|
2011-02-21 10:19:38 +08:00
|
|
|
short_cal_interval = (ah->opmode == NL80211_IFTYPE_AP) ?
|
|
|
|
ATH_AP_SHORT_CALINTERVAL : ATH_STA_SHORT_CALINTERVAL;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2010-04-05 17:18:05 +08:00
|
|
|
/* Only calibrate if awake */
|
|
|
|
if (ah->power_mode != ATH9K_PM_AWAKE)
|
|
|
|
goto set_timer;
|
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
/* Long calibration runs independently of short calibration. */
|
|
|
|
if ((timestamp - common->ani.longcal_timer) >= ATH_LONG_CALINTERVAL) {
|
|
|
|
longcal = true;
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, ANI, "longcal @%lu\n", jiffies);
|
2010-03-17 16:55:25 +08:00
|
|
|
common->ani.longcal_timer = timestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Short calibration applies only while caldone is false */
|
|
|
|
if (!common->ani.caldone) {
|
|
|
|
if ((timestamp - common->ani.shortcal_timer) >=
|
|
|
|
short_cal_interval) {
|
|
|
|
shortcal = true;
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, ANI, "shortcal @%lu\n", jiffies);
|
2010-03-17 16:55:25 +08:00
|
|
|
common->ani.shortcal_timer = timestamp;
|
|
|
|
common->ani.resetcal_timer = timestamp;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ((timestamp - common->ani.resetcal_timer) >=
|
|
|
|
ATH_RESTART_CALINTERVAL) {
|
|
|
|
common->ani.caldone = ath9k_hw_reset_calvalid(ah);
|
|
|
|
if (common->ani.caldone)
|
|
|
|
common->ani.resetcal_timer = timestamp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Verify whether we must check ANI */
|
2013-06-03 11:49:26 +08:00
|
|
|
if ((timestamp - common->ani.checkani_timer) >= ATH_ANI_POLLINTERVAL) {
|
2010-03-17 16:55:25 +08:00
|
|
|
aniflag = true;
|
|
|
|
common->ani.checkani_timer = timestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Skip all processing if there's nothing to do. */
|
|
|
|
if (longcal || shortcal || aniflag) {
|
2010-04-05 17:18:05 +08:00
|
|
|
|
|
|
|
ath9k_htc_ps_wakeup(priv);
|
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
/* Call ANI routine if necessary */
|
|
|
|
if (aniflag)
|
|
|
|
ath9k_hw_ani_monitor(ah, ah->curchan);
|
|
|
|
|
|
|
|
/* Perform calibration if necessary */
|
2010-09-29 23:15:26 +08:00
|
|
|
if (longcal || shortcal)
|
2010-03-17 16:55:25 +08:00
|
|
|
common->ani.caldone =
|
|
|
|
ath9k_hw_calibrate(ah, ah->curchan,
|
2011-09-03 07:40:23 +08:00
|
|
|
ah->rxchainmask, longcal);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2010-04-05 17:18:05 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
2010-04-05 17:18:05 +08:00
|
|
|
set_timer:
|
2010-03-17 16:55:25 +08:00
|
|
|
/*
|
|
|
|
* Set timer interval based on previous results.
|
|
|
|
* The interval must be the shortest necessary to satisfy ANI,
|
|
|
|
* short calibration and long calibration.
|
|
|
|
*/
|
|
|
|
cal_interval = ATH_LONG_CALINTERVAL;
|
2013-06-03 11:49:26 +08:00
|
|
|
cal_interval = min(cal_interval, (u32)ATH_ANI_POLLINTERVAL);
|
2010-03-17 16:55:25 +08:00
|
|
|
if (!common->ani.caldone)
|
|
|
|
cal_interval = min(cal_interval, (u32)short_cal_interval);
|
|
|
|
|
2011-02-21 10:19:38 +08:00
|
|
|
ieee80211_queue_delayed_work(common->hw, &priv->ani_work,
|
2010-03-17 16:55:25 +08:00
|
|
|
msecs_to_jiffies(cal_interval));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************/
|
|
|
|
/* mac80211 Callbacks */
|
|
|
|
/**********************/
|
|
|
|
|
2012-07-24 03:33:42 +08:00
|
|
|
static void ath9k_htc_tx(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_tx_control *control,
|
|
|
|
struct sk_buff *skb)
|
2010-03-17 16:55:25 +08:00
|
|
|
{
|
|
|
|
struct ieee80211_hdr *hdr;
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
2011-04-13 13:55:29 +08:00
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
2011-04-13 13:55:47 +08:00
|
|
|
int padpos, padsize, ret, slot;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
hdr = (struct ieee80211_hdr *) skb->data;
|
|
|
|
|
|
|
|
/* Add the padding after the header if this is not already done */
|
2013-04-08 06:04:09 +08:00
|
|
|
padpos = ieee80211_hdrlen(hdr->frame_control);
|
2010-03-17 16:55:25 +08:00
|
|
|
padsize = padpos & 3;
|
|
|
|
if (padsize && skb->len > padpos) {
|
2011-04-13 13:55:29 +08:00
|
|
|
if (skb_headroom(skb) < padsize) {
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, XMIT, "No room for padding\n");
|
2011-02-24 21:42:06 +08:00
|
|
|
goto fail_tx;
|
2011-04-13 13:55:29 +08:00
|
|
|
}
|
2010-03-17 16:55:25 +08:00
|
|
|
skb_push(skb, padsize);
|
|
|
|
memmove(skb->data, skb->data + padsize, padpos);
|
|
|
|
}
|
|
|
|
|
2011-04-13 13:55:47 +08:00
|
|
|
slot = ath9k_htc_tx_get_slot(priv);
|
|
|
|
if (slot < 0) {
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, XMIT, "No free TX slot\n");
|
2011-04-13 13:55:47 +08:00
|
|
|
goto fail_tx;
|
|
|
|
}
|
|
|
|
|
2012-07-24 03:33:42 +08:00
|
|
|
ret = ath9k_htc_tx_start(priv, control->sta, skb, slot, false);
|
2010-03-29 18:37:17 +08:00
|
|
|
if (ret != 0) {
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, XMIT, "Tx failed\n");
|
2011-04-13 13:55:47 +08:00
|
|
|
goto clear_slot;
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
2011-04-13 13:55:29 +08:00
|
|
|
ath9k_htc_check_stop_queues(priv);
|
|
|
|
|
2011-02-24 21:42:06 +08:00
|
|
|
return;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2011-04-13 13:55:47 +08:00
|
|
|
clear_slot:
|
|
|
|
ath9k_htc_tx_clear_slot(priv, slot);
|
2010-03-17 16:55:25 +08:00
|
|
|
fail_tx:
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
}
|
|
|
|
|
2010-06-01 17:44:11 +08:00
|
|
|
static int ath9k_htc_start(struct ieee80211_hw *hw)
|
2010-03-17 16:55:25 +08:00
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
struct ath_hw *ah = priv->ah;
|
|
|
|
struct ath_common *common = ath9k_hw_common(ah);
|
2013-03-25 23:26:57 +08:00
|
|
|
struct ieee80211_channel *curchan = hw->conf.chandef.chan;
|
2010-03-17 16:55:25 +08:00
|
|
|
struct ath9k_channel *init_channel;
|
|
|
|
int ret = 0;
|
|
|
|
enum htc_phymode mode;
|
2010-04-16 14:24:03 +08:00
|
|
|
__be16 htc_mode;
|
2010-03-17 16:55:25 +08:00
|
|
|
u8 cmd_rsp;
|
|
|
|
|
2010-06-01 17:44:11 +08:00
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2010-12-03 11:12:37 +08:00
|
|
|
"Starting driver with initial channel: %d MHz\n",
|
|
|
|
curchan->center_freq);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2010-06-01 17:44:18 +08:00
|
|
|
/* Ensure that HW is awake before flushing RX */
|
|
|
|
ath9k_htc_setpower(priv, ATH9K_PM_AWAKE);
|
|
|
|
WMI_CMD(WMI_FLUSH_RECV_CMDID);
|
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
/* setup initial channel */
|
2013-10-12 05:30:57 +08:00
|
|
|
init_channel = ath9k_cmn_get_channel(hw, ah, &hw->conf.chandef);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2010-07-31 06:12:00 +08:00
|
|
|
ret = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
|
2010-03-17 16:55:25 +08:00
|
|
|
if (ret) {
|
2010-12-03 11:12:36 +08:00
|
|
|
ath_err(common,
|
|
|
|
"Unable to reset hardware; reset status %d (freq %u MHz)\n",
|
|
|
|
ret, curchan->center_freq);
|
2010-06-01 17:44:11 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
2010-04-27 15:35:37 +08:00
|
|
|
return ret;
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
2011-02-01 02:17:45 +08:00
|
|
|
ath9k_cmn_update_txpow(ah, priv->curtxpow, priv->txpowlimit,
|
|
|
|
&priv->curtxpow);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
mode = ath9k_htc_get_curmode(priv, init_channel);
|
|
|
|
htc_mode = cpu_to_be16(mode);
|
|
|
|
WMI_CMD_BUF(WMI_SET_MODE_CMDID, &htc_mode);
|
|
|
|
WMI_CMD(WMI_ATH_INIT_CMDID);
|
|
|
|
WMI_CMD(WMI_START_RECV_CMDID);
|
|
|
|
|
|
|
|
ath9k_host_rx_init(priv);
|
|
|
|
|
2011-04-20 17:03:28 +08:00
|
|
|
ret = ath9k_htc_update_cap_target(priv, 0);
|
2011-02-21 10:18:09 +08:00
|
|
|
if (ret)
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2011-02-21 10:18:09 +08:00
|
|
|
"Failed to update capability in target\n");
|
|
|
|
|
2014-03-02 04:15:49 +08:00
|
|
|
clear_bit(ATH_OP_INVALID, &common->op_flags);
|
2010-03-17 16:55:25 +08:00
|
|
|
htc_start(priv->htc);
|
|
|
|
|
2011-04-13 13:55:00 +08:00
|
|
|
spin_lock_bh(&priv->tx.tx_lock);
|
2011-04-13 13:55:29 +08:00
|
|
|
priv->tx.flags &= ~ATH9K_HTC_OP_TX_QUEUES_STOP;
|
2011-04-13 13:55:00 +08:00
|
|
|
spin_unlock_bh(&priv->tx.tx_lock);
|
2010-03-29 18:37:17 +08:00
|
|
|
|
|
|
|
ieee80211_wake_queues(hw);
|
|
|
|
|
2011-04-13 13:56:39 +08:00
|
|
|
mod_timer(&priv->tx.cleanup_timer,
|
|
|
|
jiffies + msecs_to_jiffies(ATH9K_HTC_TX_CLEANUP_INTERVAL));
|
|
|
|
|
2012-02-22 15:11:36 +08:00
|
|
|
ath9k_htc_start_btcoex(priv);
|
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
2010-04-27 15:35:37 +08:00
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-06-01 17:44:11 +08:00
|
|
|
static void ath9k_htc_stop(struct ieee80211_hw *hw)
|
2010-03-17 16:55:25 +08:00
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
struct ath_hw *ah = priv->ah;
|
|
|
|
struct ath_common *common = ath9k_hw_common(ah);
|
2011-04-20 13:30:34 +08:00
|
|
|
int ret __attribute__ ((unused));
|
2010-03-17 16:55:25 +08:00
|
|
|
u8 cmd_rsp;
|
|
|
|
|
2010-06-01 17:44:11 +08:00
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
|
2014-03-02 04:15:49 +08:00
|
|
|
if (test_bit(ATH_OP_INVALID, &common->op_flags)) {
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, ANY, "Device not present\n");
|
2010-06-01 17:44:11 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
2010-03-17 16:55:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-05 17:18:05 +08:00
|
|
|
ath9k_htc_ps_wakeup(priv);
|
2011-04-13 13:55:59 +08:00
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
WMI_CMD(WMI_DISABLE_INTR_CMDID);
|
|
|
|
WMI_CMD(WMI_DRAIN_TXQ_ALL_CMDID);
|
|
|
|
WMI_CMD(WMI_STOP_RECV_CMDID);
|
2011-01-25 21:15:12 +08:00
|
|
|
|
|
|
|
tasklet_kill(&priv->rx_tasklet);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2011-04-13 13:56:39 +08:00
|
|
|
del_timer_sync(&priv->tx.cleanup_timer);
|
2011-04-13 13:55:59 +08:00
|
|
|
ath9k_htc_tx_drain(priv);
|
2011-04-13 13:53:52 +08:00
|
|
|
ath9k_wmi_event_drain(priv);
|
|
|
|
|
2011-01-25 21:15:12 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
|
|
|
|
/* Cancel all the running timers/work .. */
|
|
|
|
cancel_work_sync(&priv->fatal_work);
|
|
|
|
cancel_work_sync(&priv->ps_work);
|
2011-04-28 18:44:05 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_MAC80211_LEDS
|
|
|
|
cancel_work_sync(&priv->led_work);
|
|
|
|
#endif
|
2011-02-21 10:19:38 +08:00
|
|
|
ath9k_htc_stop_ani(priv);
|
2011-01-25 21:15:12 +08:00
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
|
2012-02-22 15:11:36 +08:00
|
|
|
ath9k_htc_stop_btcoex(priv);
|
2010-08-18 22:27:49 +08:00
|
|
|
|
2011-02-21 10:18:00 +08:00
|
|
|
/* Remove a monitor interface if it's present. */
|
|
|
|
if (priv->ah->is_monitoring)
|
|
|
|
ath9k_htc_remove_monitor_interface(priv);
|
|
|
|
|
2010-06-01 17:44:17 +08:00
|
|
|
ath9k_hw_phy_disable(ah);
|
|
|
|
ath9k_hw_disable(ah);
|
|
|
|
ath9k_htc_ps_restore(priv);
|
|
|
|
ath9k_htc_setpower(priv, ATH9K_PM_FULL_SLEEP);
|
|
|
|
|
2014-03-02 04:15:49 +08:00
|
|
|
set_bit(ATH_OP_INVALID, &common->op_flags);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG, "Driver halt\n");
|
2010-04-27 15:35:37 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
}
|
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
static int ath9k_htc_add_interface(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
struct ath9k_htc_vif *avp = (void *)vif->drv_priv;
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ath9k_htc_target_vif hvif;
|
|
|
|
int ret = 0;
|
|
|
|
u8 cmd_rsp;
|
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
|
2010-04-05 17:18:05 +08:00
|
|
|
ath9k_htc_ps_wakeup(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
memset(&hvif, 0, sizeof(struct ath9k_htc_target_vif));
|
|
|
|
memcpy(&hvif.myaddr, vif->addr, ETH_ALEN);
|
|
|
|
|
|
|
|
switch (vif->type) {
|
|
|
|
case NL80211_IFTYPE_STATION:
|
2011-04-13 13:54:43 +08:00
|
|
|
hvif.opmode = HTC_M_STA;
|
2010-03-17 16:55:25 +08:00
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
2011-04-13 13:54:43 +08:00
|
|
|
hvif.opmode = HTC_M_IBSS;
|
2010-03-17 16:55:25 +08:00
|
|
|
break;
|
2011-02-21 10:19:23 +08:00
|
|
|
case NL80211_IFTYPE_AP:
|
2011-04-13 13:54:43 +08:00
|
|
|
hvif.opmode = HTC_M_HOSTAP;
|
2011-02-21 10:19:23 +08:00
|
|
|
break;
|
2013-05-09 01:16:46 +08:00
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
|
|
|
hvif.opmode = HTC_M_WDS; /* close enough */
|
|
|
|
break;
|
2010-03-17 16:55:25 +08:00
|
|
|
default:
|
2010-12-03 11:12:36 +08:00
|
|
|
ath_err(common,
|
2010-03-17 16:55:25 +08:00
|
|
|
"Interface type %d not yet supported\n", vif->type);
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Index starts from zero on the target */
|
2011-02-21 10:18:00 +08:00
|
|
|
avp->index = hvif.index = ffz(priv->vif_slot);
|
2010-03-17 16:55:25 +08:00
|
|
|
hvif.rtsthreshold = cpu_to_be16(2304);
|
|
|
|
WMI_CMD_BUF(WMI_VAP_CREATE_CMDID, &hvif);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We need a node in target to tx mgmt frames
|
|
|
|
* before association.
|
|
|
|
*/
|
|
|
|
ret = ath9k_htc_add_station(priv, vif, NULL);
|
2011-02-21 10:18:16 +08:00
|
|
|
if (ret) {
|
|
|
|
WMI_CMD_BUF(WMI_VAP_REMOVE_CMDID, &hvif);
|
2010-03-17 16:55:25 +08:00
|
|
|
goto out;
|
2011-02-21 10:18:16 +08:00
|
|
|
}
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2013-11-28 19:21:45 +08:00
|
|
|
ath9k_htc_set_mac_bssid_mask(priv, vif);
|
2011-02-21 10:18:46 +08:00
|
|
|
|
2011-02-21 10:18:00 +08:00
|
|
|
priv->vif_slot |= (1 << avp->index);
|
2011-02-21 10:18:16 +08:00
|
|
|
priv->nvifs++;
|
2011-02-21 10:18:00 +08:00
|
|
|
|
2011-02-21 10:19:15 +08:00
|
|
|
INC_VIF(priv, vif->type);
|
2011-04-13 13:53:08 +08:00
|
|
|
|
|
|
|
if ((vif->type == NL80211_IFTYPE_AP) ||
|
2013-05-09 01:16:46 +08:00
|
|
|
(vif->type == NL80211_IFTYPE_MESH_POINT) ||
|
2011-04-13 13:53:08 +08:00
|
|
|
(vif->type == NL80211_IFTYPE_ADHOC))
|
|
|
|
ath9k_htc_assign_bslot(priv, vif);
|
|
|
|
|
2011-02-21 10:19:31 +08:00
|
|
|
ath9k_htc_set_opmode(priv);
|
2011-02-21 10:19:15 +08:00
|
|
|
|
2011-02-21 10:19:38 +08:00
|
|
|
if ((priv->ah->opmode == NL80211_IFTYPE_AP) &&
|
2014-03-02 04:15:49 +08:00
|
|
|
!test_bit(ATH_OP_ANI_RUN, &common->op_flags)) {
|
2012-07-17 19:45:37 +08:00
|
|
|
ath9k_hw_set_tsfadjust(priv->ah, true);
|
2011-02-21 10:19:38 +08:00
|
|
|
ath9k_htc_start_ani(priv);
|
2011-04-13 13:53:17 +08:00
|
|
|
}
|
2011-02-21 10:19:38 +08:00
|
|
|
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG, "Attach a VIF of type: %d at idx: %d\n",
|
|
|
|
vif->type, avp->index);
|
2011-02-21 10:18:00 +08:00
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
out:
|
2010-04-05 17:18:05 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
2010-06-01 17:44:12 +08:00
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath9k_htc_remove_interface(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ath9k_htc_vif *avp = (void *)vif->drv_priv;
|
|
|
|
struct ath9k_htc_target_vif hvif;
|
|
|
|
int ret = 0;
|
|
|
|
u8 cmd_rsp;
|
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
2010-06-01 17:44:12 +08:00
|
|
|
ath9k_htc_ps_wakeup(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
memset(&hvif, 0, sizeof(struct ath9k_htc_target_vif));
|
|
|
|
memcpy(&hvif.myaddr, vif->addr, ETH_ALEN);
|
|
|
|
hvif.index = avp->index;
|
|
|
|
WMI_CMD_BUF(WMI_VAP_REMOVE_CMDID, &hvif);
|
2011-04-20 13:30:34 +08:00
|
|
|
if (ret) {
|
|
|
|
ath_err(common, "Unable to remove interface at idx: %d\n",
|
|
|
|
avp->index);
|
|
|
|
}
|
2010-03-17 16:55:25 +08:00
|
|
|
priv->nvifs--;
|
2011-02-21 10:18:00 +08:00
|
|
|
priv->vif_slot &= ~(1 << avp->index);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
ath9k_htc_remove_station(priv, vif, NULL);
|
|
|
|
|
2011-02-21 10:19:15 +08:00
|
|
|
DEC_VIF(priv, vif->type);
|
2011-04-13 13:53:08 +08:00
|
|
|
|
|
|
|
if ((vif->type == NL80211_IFTYPE_AP) ||
|
2013-05-09 01:16:46 +08:00
|
|
|
vif->type == NL80211_IFTYPE_MESH_POINT ||
|
2011-04-13 13:53:08 +08:00
|
|
|
(vif->type == NL80211_IFTYPE_ADHOC))
|
|
|
|
ath9k_htc_remove_bslot(priv, vif);
|
|
|
|
|
2011-02-21 10:19:31 +08:00
|
|
|
ath9k_htc_set_opmode(priv);
|
2011-02-21 10:19:15 +08:00
|
|
|
|
2013-11-28 19:21:45 +08:00
|
|
|
ath9k_htc_set_mac_bssid_mask(priv, vif);
|
2011-05-17 15:11:41 +08:00
|
|
|
|
2011-02-21 10:19:38 +08:00
|
|
|
/*
|
|
|
|
* Stop ANI only if there are no associated station interfaces.
|
|
|
|
*/
|
|
|
|
if ((vif->type == NL80211_IFTYPE_AP) && (priv->num_ap_vif == 0)) {
|
|
|
|
priv->rearm_ani = false;
|
2012-11-07 03:23:30 +08:00
|
|
|
ieee80211_iterate_active_interfaces_atomic(
|
|
|
|
priv->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
|
|
|
|
ath9k_htc_vif_iter, priv);
|
2011-02-21 10:19:38 +08:00
|
|
|
if (!priv->rearm_ani)
|
|
|
|
ath9k_htc_stop_ani(priv);
|
|
|
|
}
|
|
|
|
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG, "Detach Interface at idx: %d\n", avp->index);
|
2011-02-21 10:18:00 +08:00
|
|
|
|
2010-06-01 17:44:12 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ath9k_htc_config(struct ieee80211_hw *hw, u32 changed)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ieee80211_conf *conf = &hw->conf;
|
2012-06-25 16:24:49 +08:00
|
|
|
bool chip_reset = false;
|
|
|
|
int ret = 0;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
2012-06-25 16:24:49 +08:00
|
|
|
ath9k_htc_ps_wakeup(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2010-04-27 15:35:37 +08:00
|
|
|
if (changed & IEEE80211_CONF_CHANGE_IDLE) {
|
2010-06-01 17:44:16 +08:00
|
|
|
mutex_lock(&priv->htc_pm_lock);
|
2010-04-27 15:35:37 +08:00
|
|
|
|
2012-06-25 16:24:49 +08:00
|
|
|
priv->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
|
2013-06-20 16:27:07 +08:00
|
|
|
if (!priv->ps_idle)
|
2012-06-25 16:24:49 +08:00
|
|
|
chip_reset = true;
|
|
|
|
|
|
|
|
mutex_unlock(&priv->htc_pm_lock);
|
2010-04-27 15:35:37 +08:00
|
|
|
}
|
|
|
|
|
2011-01-05 03:36:21 +08:00
|
|
|
/*
|
|
|
|
* Monitor interface should be added before
|
|
|
|
* IEEE80211_CONF_CHANGE_CHANNEL is handled.
|
|
|
|
*/
|
|
|
|
if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
|
2011-02-21 10:18:00 +08:00
|
|
|
if ((conf->flags & IEEE80211_CONF_MONITOR) &&
|
|
|
|
!priv->ah->is_monitoring)
|
|
|
|
ath9k_htc_add_monitor_interface(priv);
|
|
|
|
else if (priv->ah->is_monitoring)
|
|
|
|
ath9k_htc_remove_monitor_interface(priv);
|
2011-01-05 03:36:21 +08:00
|
|
|
}
|
|
|
|
|
2012-06-25 16:24:49 +08:00
|
|
|
if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || chip_reset) {
|
2013-03-25 23:26:57 +08:00
|
|
|
struct ieee80211_channel *curchan = hw->conf.chandef.chan;
|
2010-03-17 16:55:25 +08:00
|
|
|
int pos = curchan->hw_value;
|
|
|
|
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG, "Set channel: %d MHz\n",
|
2010-12-03 11:12:37 +08:00
|
|
|
curchan->center_freq);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2013-10-12 05:30:57 +08:00
|
|
|
ath9k_cmn_get_channel(hw, priv->ah, &hw->conf.chandef);
|
2010-03-17 16:55:25 +08:00
|
|
|
if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) {
|
2010-12-03 11:12:36 +08:00
|
|
|
ath_err(common, "Unable to set channel\n");
|
2012-06-25 16:24:49 +08:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2010-12-07 19:01:54 +08:00
|
|
|
|
2010-04-05 17:18:05 +08:00
|
|
|
if (changed & IEEE80211_CONF_CHANGE_PS) {
|
|
|
|
if (conf->flags & IEEE80211_CONF_PS) {
|
|
|
|
ath9k_htc_setpower(priv, ATH9K_PM_NETWORK_SLEEP);
|
|
|
|
priv->ps_enabled = true;
|
|
|
|
} else {
|
|
|
|
priv->ps_enabled = false;
|
|
|
|
cancel_work_sync(&priv->ps_work);
|
|
|
|
ath9k_htc_setpower(priv, ATH9K_PM_AWAKE);
|
|
|
|
}
|
|
|
|
}
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2010-12-07 19:01:54 +08:00
|
|
|
if (changed & IEEE80211_CONF_CHANGE_POWER) {
|
|
|
|
priv->txpowlimit = 2 * conf->power_level;
|
2011-02-01 02:17:45 +08:00
|
|
|
ath9k_cmn_update_txpow(priv->ah, priv->curtxpow,
|
|
|
|
priv->txpowlimit, &priv->curtxpow);
|
2010-12-07 19:01:54 +08:00
|
|
|
}
|
|
|
|
|
2010-06-01 17:44:16 +08:00
|
|
|
out:
|
2012-06-25 16:24:49 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
2012-06-25 16:24:49 +08:00
|
|
|
return ret;
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define SUPPORTED_FILTERS \
|
|
|
|
(FIF_PROMISC_IN_BSS | \
|
|
|
|
FIF_ALLMULTI | \
|
|
|
|
FIF_CONTROL | \
|
|
|
|
FIF_PSPOLL | \
|
|
|
|
FIF_OTHER_BSS | \
|
|
|
|
FIF_BCN_PRBRESP_PROMISC | \
|
2010-10-14 13:20:26 +08:00
|
|
|
FIF_PROBE_REQ | \
|
2010-03-17 16:55:25 +08:00
|
|
|
FIF_FCSFAIL)
|
|
|
|
|
|
|
|
static void ath9k_htc_configure_filter(struct ieee80211_hw *hw,
|
|
|
|
unsigned int changed_flags,
|
|
|
|
unsigned int *total_flags,
|
|
|
|
u64 multicast)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
2014-03-02 04:15:49 +08:00
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
2010-03-17 16:55:25 +08:00
|
|
|
u32 rfilt;
|
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
changed_flags &= SUPPORTED_FILTERS;
|
|
|
|
*total_flags &= SUPPORTED_FILTERS;
|
|
|
|
|
2014-03-02 04:15:49 +08:00
|
|
|
if (test_bit(ATH_OP_INVALID, &common->op_flags)) {
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(ath9k_hw_common(priv->ah), ANY,
|
2011-07-08 02:03:38 +08:00
|
|
|
"Unable to configure filter on invalid state\n");
|
2011-08-28 02:56:00 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
2011-07-08 02:03:38 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ath9k_htc_ps_wakeup(priv);
|
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
priv->rxfilter = *total_flags;
|
2010-03-29 18:37:09 +08:00
|
|
|
rfilt = ath9k_htc_calcrxfilter(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
ath9k_hw_setrxfilter(priv->ah, rfilt);
|
|
|
|
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(ath9k_hw_common(priv->ah), CONFIG, "Set HW RX filter: 0x%x\n",
|
|
|
|
rfilt);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2010-04-05 17:18:05 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
}
|
|
|
|
|
2014-02-03 18:45:51 +08:00
|
|
|
static void ath9k_htc_sta_rc_update_work(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_sta *ista =
|
|
|
|
container_of(work, struct ath9k_htc_sta, rc_update_work);
|
|
|
|
struct ieee80211_sta *sta =
|
|
|
|
container_of((void *)ista, struct ieee80211_sta, drv_priv);
|
|
|
|
struct ath9k_htc_priv *priv = ista->htc_priv;
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ath9k_htc_target_rate trate;
|
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
ath9k_htc_ps_wakeup(priv);
|
|
|
|
|
|
|
|
memset(&trate, 0, sizeof(struct ath9k_htc_target_rate));
|
|
|
|
ath9k_htc_setup_rate(priv, sta, &trate);
|
|
|
|
if (!ath9k_htc_send_rate_cmd(priv, &trate))
|
|
|
|
ath_dbg(common, CONFIG,
|
|
|
|
"Supported rates for sta: %pM updated, rate caps: 0x%X\n",
|
|
|
|
sta->addr, be32_to_cpu(trate.capflags));
|
|
|
|
else
|
|
|
|
ath_dbg(common, CONFIG,
|
|
|
|
"Unable to update supported rates for sta: %pM\n",
|
|
|
|
sta->addr);
|
|
|
|
|
|
|
|
ath9k_htc_ps_restore(priv);
|
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
}
|
|
|
|
|
2010-05-18 17:56:04 +08:00
|
|
|
static int ath9k_htc_sta_add(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta)
|
2010-03-17 16:55:25 +08:00
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
2014-02-03 18:45:51 +08:00
|
|
|
struct ath9k_htc_sta *ista = (struct ath9k_htc_sta *) sta->drv_priv;
|
2010-03-17 16:55:25 +08:00
|
|
|
int ret;
|
|
|
|
|
2010-05-11 18:54:38 +08:00
|
|
|
mutex_lock(&priv->mutex);
|
2010-06-01 17:44:12 +08:00
|
|
|
ath9k_htc_ps_wakeup(priv);
|
2010-05-18 17:56:04 +08:00
|
|
|
ret = ath9k_htc_add_station(priv, vif, sta);
|
2014-02-03 18:45:51 +08:00
|
|
|
if (!ret) {
|
|
|
|
INIT_WORK(&ista->rc_update_work, ath9k_htc_sta_rc_update_work);
|
|
|
|
ista->htc_priv = priv;
|
2010-05-18 17:56:04 +08:00
|
|
|
ath9k_htc_init_rate(priv, sta);
|
2014-02-03 18:45:51 +08:00
|
|
|
}
|
2010-05-18 17:56:04 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
|
|
|
mutex_unlock(&priv->mutex);
|
2010-05-11 18:54:38 +08:00
|
|
|
|
2010-05-18 17:56:04 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ath9k_htc_sta_remove(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
2014-02-03 18:45:51 +08:00
|
|
|
struct ath9k_htc_sta *ista = (struct ath9k_htc_sta *) sta->drv_priv;
|
2010-05-18 17:56:04 +08:00
|
|
|
int ret;
|
2010-05-11 18:54:38 +08:00
|
|
|
|
2014-02-03 18:45:51 +08:00
|
|
|
cancel_work_sync(&ista->rc_update_work);
|
|
|
|
|
2010-05-18 17:56:04 +08:00
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
ath9k_htc_ps_wakeup(priv);
|
2011-04-13 13:56:11 +08:00
|
|
|
htc_sta_drain(priv->htc, ista->index);
|
2010-05-18 17:56:04 +08:00
|
|
|
ret = ath9k_htc_remove_station(priv, vif, sta);
|
2010-06-01 17:44:12 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2010-05-11 18:54:38 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
2010-05-18 17:56:04 +08:00
|
|
|
|
|
|
|
return ret;
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
2012-08-13 01:36:41 +08:00
|
|
|
static void ath9k_htc_sta_rc_update(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta, u32 changed)
|
|
|
|
{
|
2014-02-03 18:45:51 +08:00
|
|
|
struct ath9k_htc_sta *ista = (struct ath9k_htc_sta *) sta->drv_priv;
|
2012-08-13 01:36:41 +08:00
|
|
|
|
2014-01-28 16:14:48 +08:00
|
|
|
if (!(changed & IEEE80211_RC_SUPP_RATES_CHANGED))
|
|
|
|
return;
|
2012-08-13 01:36:41 +08:00
|
|
|
|
2014-02-03 18:45:51 +08:00
|
|
|
schedule_work(&ista->rc_update_work);
|
2012-08-13 01:36:41 +08:00
|
|
|
}
|
|
|
|
|
2011-10-02 16:15:52 +08:00
|
|
|
static int ath9k_htc_conf_tx(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif, u16 queue,
|
2010-03-17 16:55:25 +08:00
|
|
|
const struct ieee80211_tx_queue_params *params)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ath9k_tx_queue_info qi;
|
|
|
|
int ret = 0, qnum;
|
|
|
|
|
2012-11-21 20:43:10 +08:00
|
|
|
if (queue >= IEEE80211_NUM_ACS)
|
2010-03-17 16:55:25 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
2010-06-01 17:44:12 +08:00
|
|
|
ath9k_htc_ps_wakeup(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
memset(&qi, 0, sizeof(struct ath9k_tx_queue_info));
|
|
|
|
|
|
|
|
qi.tqi_aifs = params->aifs;
|
|
|
|
qi.tqi_cwmin = params->cw_min;
|
|
|
|
qi.tqi_cwmax = params->cw_max;
|
2012-07-16 01:53:34 +08:00
|
|
|
qi.tqi_burstTime = params->txop * 32;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
qnum = get_hw_qnum(queue, priv->hwq_map);
|
|
|
|
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2010-12-03 11:12:37 +08:00
|
|
|
"Configure tx [queue/hwq] [%d/%d], aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n",
|
|
|
|
queue, qnum, params->aifs, params->cw_min,
|
|
|
|
params->cw_max, params->txop);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2010-03-24 16:12:13 +08:00
|
|
|
ret = ath_htc_txq_update(priv, qnum, &qi);
|
2010-06-01 17:44:19 +08:00
|
|
|
if (ret) {
|
2010-12-03 11:12:36 +08:00
|
|
|
ath_err(common, "TXQ Update failed\n");
|
2010-06-01 17:44:19 +08:00
|
|
|
goto out;
|
|
|
|
}
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2010-06-01 17:44:19 +08:00
|
|
|
if ((priv->ah->opmode == NL80211_IFTYPE_ADHOC) &&
|
2012-11-21 20:43:10 +08:00
|
|
|
(qnum == priv->hwq_map[IEEE80211_AC_BE]))
|
2010-06-01 17:44:19 +08:00
|
|
|
ath9k_htc_beaconq_config(priv);
|
|
|
|
out:
|
2010-06-01 17:44:12 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ath9k_htc_set_key(struct ieee80211_hw *hw,
|
|
|
|
enum set_key_cmd cmd,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta,
|
|
|
|
struct ieee80211_key_conf *key)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
int ret = 0;
|
|
|
|
|
2010-03-24 16:12:13 +08:00
|
|
|
if (htc_modparam_nohwcrypt)
|
2010-03-17 16:55:25 +08:00
|
|
|
return -ENOSPC;
|
|
|
|
|
2012-01-18 06:13:30 +08:00
|
|
|
if ((vif->type == NL80211_IFTYPE_ADHOC ||
|
|
|
|
vif->type == NL80211_IFTYPE_MESH_POINT) &&
|
|
|
|
(key->cipher == WLAN_CIPHER_SUITE_TKIP ||
|
|
|
|
key->cipher == WLAN_CIPHER_SUITE_CCMP) &&
|
|
|
|
!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
|
|
|
|
/*
|
|
|
|
* For now, disable hw crypto for the RSN IBSS group keys. This
|
|
|
|
* could be optimized in the future to use a modified key cache
|
|
|
|
* design to support per-STA RX GTK, but until that gets
|
|
|
|
* implemented, use of software crypto for group addressed
|
|
|
|
* frames is a acceptable to allow RSN IBSS to be used.
|
|
|
|
*/
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
mutex_lock(&priv->mutex);
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG, "Set HW Key\n");
|
2010-04-05 17:18:05 +08:00
|
|
|
ath9k_htc_ps_wakeup(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case SET_KEY:
|
2010-09-08 15:05:04 +08:00
|
|
|
ret = ath_key_config(common, vif, sta, key);
|
2010-03-17 16:55:25 +08:00
|
|
|
if (ret >= 0) {
|
|
|
|
key->hw_key_idx = ret;
|
|
|
|
/* push IV and Michael MIC generation to stack */
|
|
|
|
key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
|
2010-08-10 15:46:38 +08:00
|
|
|
if (key->cipher == WLAN_CIPHER_SUITE_TKIP)
|
2010-03-17 16:55:25 +08:00
|
|
|
key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
|
2010-08-10 15:46:38 +08:00
|
|
|
if (priv->ah->sw_mgmt_crypto &&
|
|
|
|
key->cipher == WLAN_CIPHER_SUITE_CCMP)
|
2012-09-04 23:08:23 +08:00
|
|
|
key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX;
|
2010-03-17 16:55:25 +08:00
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DISABLE_KEY:
|
2010-09-08 15:05:04 +08:00
|
|
|
ath_key_delete(common, key);
|
2010-03-17 16:55:25 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
|
2010-04-05 17:18:05 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-05-17 15:12:03 +08:00
|
|
|
static void ath9k_htc_set_bssid(struct ath9k_htc_priv *priv)
|
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
|
|
|
|
ath9k_hw_write_associd(priv->ah);
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG, "BSSID: %pM aid: 0x%x\n",
|
2011-05-17 15:12:03 +08:00
|
|
|
common->curbssid, common->curaid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath9k_htc_bss_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *)data;
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
|
|
|
|
|
|
|
|
if ((vif->type == NL80211_IFTYPE_STATION) && bss_conf->assoc) {
|
|
|
|
common->curaid = bss_conf->aid;
|
2014-02-04 17:27:43 +08:00
|
|
|
common->last_rssi = ATH_RSSI_DUMMY_MARKER;
|
2011-05-17 15:12:03 +08:00
|
|
|
memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN);
|
2014-03-02 04:15:50 +08:00
|
|
|
set_bit(ATH_OP_PRIM_STA_VIF, &common->op_flags);
|
2011-05-17 15:12:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath9k_htc_choose_set_bssid(struct ath9k_htc_priv *priv)
|
|
|
|
{
|
|
|
|
if (priv->num_sta_assoc_vif == 1) {
|
2012-11-07 03:23:30 +08:00
|
|
|
ieee80211_iterate_active_interfaces_atomic(
|
|
|
|
priv->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
|
|
|
|
ath9k_htc_bss_iter, priv);
|
2011-05-17 15:12:03 +08:00
|
|
|
ath9k_htc_set_bssid(priv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
static void ath9k_htc_bss_info_changed(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_bss_conf *bss_conf,
|
|
|
|
u32 changed)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
struct ath_hw *ah = priv->ah;
|
|
|
|
struct ath_common *common = ath9k_hw_common(ah);
|
2014-03-02 04:15:52 +08:00
|
|
|
int slottime;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
2010-04-05 17:18:05 +08:00
|
|
|
ath9k_htc_ps_wakeup(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
if (changed & BSS_CHANGED_ASSOC) {
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG, "BSS Changed ASSOC %d\n",
|
2011-05-17 15:12:03 +08:00
|
|
|
bss_conf->assoc);
|
2011-02-27 11:50:40 +08:00
|
|
|
|
2011-05-17 15:12:03 +08:00
|
|
|
bss_conf->assoc ?
|
|
|
|
priv->num_sta_assoc_vif++ : priv->num_sta_assoc_vif--;
|
2011-02-27 11:50:40 +08:00
|
|
|
|
2014-03-02 04:15:50 +08:00
|
|
|
if (!bss_conf->assoc)
|
|
|
|
clear_bit(ATH_OP_PRIM_STA_VIF, &common->op_flags);
|
|
|
|
|
2011-05-17 15:12:03 +08:00
|
|
|
if (priv->ah->opmode == NL80211_IFTYPE_STATION) {
|
2012-06-20 18:59:20 +08:00
|
|
|
ath9k_htc_choose_set_bssid(priv);
|
2011-05-17 15:12:03 +08:00
|
|
|
if (bss_conf->assoc && (priv->num_sta_assoc_vif == 1))
|
2011-02-27 11:50:40 +08:00
|
|
|
ath9k_htc_start_ani(priv);
|
2011-05-17 15:12:03 +08:00
|
|
|
else if (priv->num_sta_assoc_vif == 0)
|
2011-02-27 11:50:40 +08:00
|
|
|
ath9k_htc_stop_ani(priv);
|
|
|
|
}
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
2012-06-20 18:59:20 +08:00
|
|
|
if (changed & BSS_CHANGED_IBSS) {
|
2011-05-17 15:12:03 +08:00
|
|
|
if (priv->ah->opmode == NL80211_IFTYPE_ADHOC) {
|
|
|
|
common->curaid = bss_conf->aid;
|
2011-02-27 11:50:40 +08:00
|
|
|
memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN);
|
2011-05-17 15:12:03 +08:00
|
|
|
ath9k_htc_set_bssid(priv);
|
2011-02-27 11:50:40 +08:00
|
|
|
}
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
2011-02-21 10:19:53 +08:00
|
|
|
if ((changed & BSS_CHANGED_BEACON_ENABLED) && bss_conf->enable_beacon) {
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG, "Beacon enabled for BSS: %pM\n",
|
|
|
|
bss_conf->bssid);
|
2011-04-13 13:53:17 +08:00
|
|
|
ath9k_htc_set_tsfadjust(priv, vif);
|
2014-03-02 04:15:47 +08:00
|
|
|
priv->cur_beacon_conf.enable_beacon = 1;
|
2010-04-05 17:18:06 +08:00
|
|
|
ath9k_htc_beacon_config(priv, vif);
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
2011-02-21 10:19:53 +08:00
|
|
|
if ((changed & BSS_CHANGED_BEACON_ENABLED) && !bss_conf->enable_beacon) {
|
|
|
|
/*
|
|
|
|
* Disable SWBA interrupt only if there are no
|
2013-05-09 01:16:46 +08:00
|
|
|
* concurrent AP/mesh or IBSS interfaces.
|
2011-02-21 10:19:53 +08:00
|
|
|
*/
|
2013-05-09 01:16:46 +08:00
|
|
|
if ((priv->num_ap_vif + priv->num_mbss_vif <= 1) ||
|
|
|
|
priv->num_ibss_vif) {
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2011-02-21 10:19:53 +08:00
|
|
|
"Beacon disabled for BSS: %pM\n",
|
|
|
|
bss_conf->bssid);
|
2014-03-02 04:15:47 +08:00
|
|
|
priv->cur_beacon_conf.enable_beacon = 0;
|
2011-02-21 10:19:53 +08:00
|
|
|
ath9k_htc_beacon_config(priv, vif);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed & BSS_CHANGED_BEACON_INT) {
|
|
|
|
/*
|
2013-05-09 01:16:46 +08:00
|
|
|
* Reset the HW TSF for the first AP or mesh interface.
|
2011-02-21 10:19:53 +08:00
|
|
|
*/
|
2013-05-09 01:16:46 +08:00
|
|
|
if (priv->nvifs == 1 &&
|
|
|
|
((priv->ah->opmode == NL80211_IFTYPE_AP &&
|
|
|
|
vif->type == NL80211_IFTYPE_AP &&
|
|
|
|
priv->num_ap_vif == 1) ||
|
|
|
|
(priv->ah->opmode == NL80211_IFTYPE_MESH_POINT &&
|
|
|
|
vif->type == NL80211_IFTYPE_MESH_POINT &&
|
|
|
|
priv->num_mbss_vif == 1))) {
|
2012-06-25 16:24:41 +08:00
|
|
|
set_bit(OP_TSF_RESET, &priv->op_flags);
|
2011-02-21 10:19:53 +08:00
|
|
|
}
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG,
|
2011-02-21 10:19:53 +08:00
|
|
|
"Beacon interval changed for BSS: %pM\n",
|
|
|
|
bss_conf->bssid);
|
2010-04-05 17:18:06 +08:00
|
|
|
ath9k_htc_beacon_config(priv, vif);
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (changed & BSS_CHANGED_ERP_SLOT) {
|
|
|
|
if (bss_conf->use_short_slot)
|
2014-03-02 04:15:52 +08:00
|
|
|
slottime = 9;
|
2010-03-17 16:55:25 +08:00
|
|
|
else
|
2014-03-02 04:15:52 +08:00
|
|
|
slottime = 20;
|
|
|
|
if (vif->type == NL80211_IFTYPE_AP) {
|
|
|
|
/*
|
|
|
|
* Defer update, so that connected stations can adjust
|
|
|
|
* their settings at the same time.
|
|
|
|
* See beacon.c for more details
|
|
|
|
*/
|
|
|
|
priv->beacon.slottime = slottime;
|
|
|
|
priv->beacon.updateslot = UPDATE;
|
|
|
|
} else {
|
|
|
|
ah->slottime = slottime;
|
|
|
|
ath9k_hw_init_global_settings(ah);
|
|
|
|
}
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
2010-05-17 14:31:18 +08:00
|
|
|
if (changed & BSS_CHANGED_HT)
|
|
|
|
ath9k_htc_update_rate(priv, vif, bss_conf);
|
|
|
|
|
2010-04-05 17:18:05 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
}
|
|
|
|
|
2011-09-21 19:06:11 +08:00
|
|
|
static u64 ath9k_htc_get_tsf(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif)
|
2010-03-17 16:55:25 +08:00
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
u64 tsf;
|
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
2010-06-01 17:44:12 +08:00
|
|
|
ath9k_htc_ps_wakeup(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
tsf = ath9k_hw_gettsf64(priv->ah);
|
2010-06-01 17:44:12 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
|
|
|
|
return tsf;
|
|
|
|
}
|
|
|
|
|
2011-09-21 19:06:11 +08:00
|
|
|
static void ath9k_htc_set_tsf(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif, u64 tsf)
|
2010-03-17 16:55:25 +08:00
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
2010-06-01 17:44:12 +08:00
|
|
|
ath9k_htc_ps_wakeup(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
ath9k_hw_settsf64(priv->ah, tsf);
|
2010-06-01 17:44:12 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
}
|
|
|
|
|
2011-09-21 19:06:11 +08:00
|
|
|
static void ath9k_htc_reset_tsf(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif)
|
2010-03-17 16:55:25 +08:00
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
2010-06-01 17:44:12 +08:00
|
|
|
ath9k_htc_ps_wakeup(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
ath9k_hw_reset_tsf(priv->ah);
|
2010-04-05 17:18:05 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2010-06-01 17:44:12 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ath9k_htc_ampdu_action(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
enum ieee80211_ampdu_mlme_action action,
|
|
|
|
struct ieee80211_sta *sta,
|
2011-01-18 20:51:05 +08:00
|
|
|
u16 tid, u16 *ssn, u8 buf_size)
|
2010-03-17 16:55:25 +08:00
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
struct ath9k_htc_sta *ista;
|
2010-06-15 12:54:37 +08:00
|
|
|
int ret = 0;
|
2010-03-17 16:55:25 +08:00
|
|
|
|
2011-02-21 10:19:08 +08:00
|
|
|
mutex_lock(&priv->mutex);
|
2011-04-20 13:31:10 +08:00
|
|
|
ath9k_htc_ps_wakeup(priv);
|
2011-02-21 10:19:08 +08:00
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
switch (action) {
|
|
|
|
case IEEE80211_AMPDU_RX_START:
|
|
|
|
break;
|
|
|
|
case IEEE80211_AMPDU_RX_STOP:
|
|
|
|
break;
|
|
|
|
case IEEE80211_AMPDU_TX_START:
|
2010-06-15 12:54:37 +08:00
|
|
|
ret = ath9k_htc_tx_aggr_oper(priv, vif, sta, action, tid);
|
|
|
|
if (!ret)
|
|
|
|
ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
|
|
|
|
break;
|
2012-07-18 19:51:25 +08:00
|
|
|
case IEEE80211_AMPDU_TX_STOP_CONT:
|
|
|
|
case IEEE80211_AMPDU_TX_STOP_FLUSH:
|
|
|
|
case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
|
2010-06-15 12:54:37 +08:00
|
|
|
ath9k_htc_tx_aggr_oper(priv, vif, sta, action, tid);
|
|
|
|
ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
|
2010-03-17 16:55:25 +08:00
|
|
|
break;
|
|
|
|
case IEEE80211_AMPDU_TX_OPERATIONAL:
|
|
|
|
ista = (struct ath9k_htc_sta *) sta->drv_priv;
|
2011-04-13 13:55:00 +08:00
|
|
|
spin_lock_bh(&priv->tx.tx_lock);
|
2010-03-17 16:55:25 +08:00
|
|
|
ista->tid_state[tid] = AGGR_OPERATIONAL;
|
2011-04-13 13:55:00 +08:00
|
|
|
spin_unlock_bh(&priv->tx.tx_lock);
|
2010-03-17 16:55:25 +08:00
|
|
|
break;
|
|
|
|
default:
|
2010-12-03 11:12:36 +08:00
|
|
|
ath_err(ath9k_hw_common(priv->ah), "Unknown AMPDU action\n");
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
2011-04-20 13:31:10 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2011-02-21 10:19:08 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
|
2010-06-15 12:54:37 +08:00
|
|
|
return ret;
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ath9k_htc_sw_scan_start(struct ieee80211_hw *hw)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
2014-03-02 04:15:49 +08:00
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
spin_lock_bh(&priv->beacon_lock);
|
2014-03-02 04:15:49 +08:00
|
|
|
set_bit(ATH_OP_SCANNING, &common->op_flags);
|
2010-03-17 16:55:25 +08:00
|
|
|
spin_unlock_bh(&priv->beacon_lock);
|
2010-04-05 17:18:05 +08:00
|
|
|
cancel_work_sync(&priv->ps_work);
|
2011-02-21 10:19:38 +08:00
|
|
|
ath9k_htc_stop_ani(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath9k_htc_sw_scan_complete(struct ieee80211_hw *hw)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
2014-03-02 04:15:49 +08:00
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
2010-03-17 16:55:25 +08:00
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
|
|
|
spin_lock_bh(&priv->beacon_lock);
|
2014-03-02 04:15:49 +08:00
|
|
|
clear_bit(ATH_OP_SCANNING, &common->op_flags);
|
2010-03-17 16:55:25 +08:00
|
|
|
spin_unlock_bh(&priv->beacon_lock);
|
2011-02-21 10:18:39 +08:00
|
|
|
ath9k_htc_ps_wakeup(priv);
|
|
|
|
ath9k_htc_vif_reconfig(priv);
|
2010-04-05 17:18:05 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2010-06-01 17:44:12 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
2010-03-17 16:55:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ath9k_htc_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath9k_htc_set_coverage_class(struct ieee80211_hw *hw,
|
|
|
|
u8 coverage_class)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
|
|
|
|
mutex_lock(&priv->mutex);
|
2010-06-01 17:44:12 +08:00
|
|
|
ath9k_htc_ps_wakeup(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
priv->ah->coverage_class = coverage_class;
|
|
|
|
ath9k_hw_init_global_settings(priv->ah);
|
2010-06-01 17:44:12 +08:00
|
|
|
ath9k_htc_ps_restore(priv);
|
2010-03-17 16:55:25 +08:00
|
|
|
mutex_unlock(&priv->mutex);
|
|
|
|
}
|
|
|
|
|
2011-04-27 19:43:40 +08:00
|
|
|
/*
|
|
|
|
* Currently, this is used only for selecting the minimum rate
|
|
|
|
* for management frames, rate selection for data frames remain
|
|
|
|
* unaffected.
|
|
|
|
*/
|
|
|
|
static int ath9k_htc_set_bitrate_mask(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
const struct cfg80211_bitrate_mask *mask)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ath9k_htc_target_rate_mask tmask;
|
|
|
|
struct ath9k_htc_vif *avp = (void *)vif->drv_priv;
|
|
|
|
int ret = 0;
|
|
|
|
u8 cmd_rsp;
|
|
|
|
|
|
|
|
memset(&tmask, 0, sizeof(struct ath9k_htc_target_rate_mask));
|
|
|
|
|
|
|
|
tmask.vif_index = avp->index;
|
|
|
|
tmask.band = IEEE80211_BAND_2GHZ;
|
|
|
|
tmask.mask = cpu_to_be32(mask->control[IEEE80211_BAND_2GHZ].legacy);
|
|
|
|
|
|
|
|
WMI_CMD_BUF(WMI_BITRATE_MASK_CMDID, &tmask);
|
|
|
|
if (ret) {
|
|
|
|
ath_err(common,
|
|
|
|
"Unable to set 2G rate mask for "
|
|
|
|
"interface at idx: %d\n", avp->index);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmask.band = IEEE80211_BAND_5GHZ;
|
|
|
|
tmask.mask = cpu_to_be32(mask->control[IEEE80211_BAND_5GHZ].legacy);
|
|
|
|
|
|
|
|
WMI_CMD_BUF(WMI_BITRATE_MASK_CMDID, &tmask);
|
|
|
|
if (ret) {
|
|
|
|
ath_err(common,
|
|
|
|
"Unable to set 5G rate mask for "
|
|
|
|
"interface at idx: %d\n", avp->index);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-12-16 06:55:53 +08:00
|
|
|
ath_dbg(common, CONFIG, "Set bitrate masks: 0x%x, 0x%x\n",
|
2011-04-27 19:43:40 +08:00
|
|
|
mask->control[IEEE80211_BAND_2GHZ].legacy,
|
|
|
|
mask->control[IEEE80211_BAND_5GHZ].legacy);
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-08-25 03:31:22 +08:00
|
|
|
|
|
|
|
static int ath9k_htc_get_stats(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_low_level_stats *stats)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
struct ath_hw *ah = priv->ah;
|
|
|
|
struct ath9k_mib_stats *mib_stats = &ah->ah_mibStats;
|
|
|
|
|
|
|
|
stats->dot11ACKFailureCount = mib_stats->ackrcv_bad;
|
|
|
|
stats->dot11RTSFailureCount = mib_stats->rts_bad;
|
|
|
|
stats->dot11FCSErrorCount = mib_stats->fcs_bad;
|
|
|
|
stats->dot11RTSSuccessCount = mib_stats->rts_good;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-20 05:02:14 +08:00
|
|
|
struct base_eep_header *ath9k_htc_get_eeprom_base(struct ath9k_htc_priv *priv)
|
|
|
|
{
|
|
|
|
struct base_eep_header *pBase = NULL;
|
|
|
|
/*
|
|
|
|
* This can be done since all the 3 EEPROM families have the
|
|
|
|
* same base header upto a certain point, and we are interested in
|
|
|
|
* the data only upto that point.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (AR_SREV_9271(priv->ah))
|
|
|
|
pBase = (struct base_eep_header *)
|
|
|
|
&priv->ah->eeprom.map4k.baseEepHeader;
|
|
|
|
else if (priv->ah->hw_version.usbdev == AR9280_USB)
|
|
|
|
pBase = (struct base_eep_header *)
|
|
|
|
&priv->ah->eeprom.def.baseEepHeader;
|
|
|
|
else if (priv->ah->hw_version.usbdev == AR9287_USB)
|
|
|
|
pBase = (struct base_eep_header *)
|
|
|
|
&priv->ah->eeprom.map9287.baseEepHeader;
|
|
|
|
return pBase;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int ath9k_htc_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant,
|
|
|
|
u32 *rx_ant)
|
|
|
|
{
|
|
|
|
struct ath9k_htc_priv *priv = hw->priv;
|
|
|
|
struct base_eep_header *pBase = ath9k_htc_get_eeprom_base(priv);
|
|
|
|
if (pBase) {
|
|
|
|
*tx_ant = pBase->txMask;
|
|
|
|
*rx_ant = pBase->rxMask;
|
|
|
|
} else {
|
|
|
|
*tx_ant = 0;
|
|
|
|
*rx_ant = 0;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-17 16:55:25 +08:00
|
|
|
struct ieee80211_ops ath9k_htc_ops = {
|
|
|
|
.tx = ath9k_htc_tx,
|
|
|
|
.start = ath9k_htc_start,
|
|
|
|
.stop = ath9k_htc_stop,
|
|
|
|
.add_interface = ath9k_htc_add_interface,
|
|
|
|
.remove_interface = ath9k_htc_remove_interface,
|
|
|
|
.config = ath9k_htc_config,
|
|
|
|
.configure_filter = ath9k_htc_configure_filter,
|
2010-05-18 17:56:04 +08:00
|
|
|
.sta_add = ath9k_htc_sta_add,
|
|
|
|
.sta_remove = ath9k_htc_sta_remove,
|
2010-03-17 16:55:25 +08:00
|
|
|
.conf_tx = ath9k_htc_conf_tx,
|
2012-08-13 01:36:41 +08:00
|
|
|
.sta_rc_update = ath9k_htc_sta_rc_update,
|
2010-03-17 16:55:25 +08:00
|
|
|
.bss_info_changed = ath9k_htc_bss_info_changed,
|
|
|
|
.set_key = ath9k_htc_set_key,
|
|
|
|
.get_tsf = ath9k_htc_get_tsf,
|
|
|
|
.set_tsf = ath9k_htc_set_tsf,
|
|
|
|
.reset_tsf = ath9k_htc_reset_tsf,
|
|
|
|
.ampdu_action = ath9k_htc_ampdu_action,
|
|
|
|
.sw_scan_start = ath9k_htc_sw_scan_start,
|
|
|
|
.sw_scan_complete = ath9k_htc_sw_scan_complete,
|
|
|
|
.set_rts_threshold = ath9k_htc_set_rts_threshold,
|
|
|
|
.rfkill_poll = ath9k_htc_rfkill_poll_state,
|
|
|
|
.set_coverage_class = ath9k_htc_set_coverage_class,
|
2011-04-27 19:43:40 +08:00
|
|
|
.set_bitrate_mask = ath9k_htc_set_bitrate_mask,
|
2011-08-25 03:31:22 +08:00
|
|
|
.get_stats = ath9k_htc_get_stats,
|
2013-06-20 05:02:14 +08:00
|
|
|
.get_antenna = ath9k_htc_get_antenna,
|
2013-06-20 05:02:15 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_ATH9K_HTC_DEBUGFS
|
|
|
|
.get_et_sset_count = ath9k_htc_get_et_sset_count,
|
|
|
|
.get_et_stats = ath9k_htc_get_et_stats,
|
|
|
|
.get_et_strings = ath9k_htc_get_et_strings,
|
|
|
|
#endif
|
2010-03-17 16:55:25 +08:00
|
|
|
};
|