2010-03-17 08:55:25 +00:00
|
|
|
/*
|
2011-05-17 08:06:18 +00:00
|
|
|
* Copyright (c) 2010-2011 Atheros Communications Inc.
|
2010-03-17 08:55:25 +00: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"
|
|
|
|
|
|
|
|
#define FUDGE 2
|
|
|
|
|
2011-04-13 05:53:26 +00:00
|
|
|
void ath9k_htc_beaconq_config(struct ath9k_htc_priv *priv)
|
|
|
|
{
|
|
|
|
struct ath_hw *ah = priv->ah;
|
|
|
|
struct ath9k_tx_queue_info qi, qi_be;
|
|
|
|
|
|
|
|
memset(&qi, 0, sizeof(struct ath9k_tx_queue_info));
|
|
|
|
memset(&qi_be, 0, sizeof(struct ath9k_tx_queue_info));
|
|
|
|
|
2014-03-01 20:15:46 +00:00
|
|
|
ath9k_hw_get_txq_props(ah, priv->beacon.beaconq, &qi);
|
2011-04-13 05:53:26 +00:00
|
|
|
|
2013-05-08 17:16:46 +00:00
|
|
|
if (priv->ah->opmode == NL80211_IFTYPE_AP ||
|
|
|
|
priv->ah->opmode == NL80211_IFTYPE_MESH_POINT) {
|
2011-04-13 05:53:26 +00:00
|
|
|
qi.tqi_aifs = 1;
|
|
|
|
qi.tqi_cwmin = 0;
|
|
|
|
qi.tqi_cwmax = 0;
|
|
|
|
} else if (priv->ah->opmode == NL80211_IFTYPE_ADHOC) {
|
2012-11-21 12:43:10 +00:00
|
|
|
int qnum = priv->hwq_map[IEEE80211_AC_BE];
|
2011-04-13 05:53:26 +00:00
|
|
|
|
|
|
|
ath9k_hw_get_txq_props(ah, qnum, &qi_be);
|
|
|
|
|
|
|
|
qi.tqi_aifs = qi_be.tqi_aifs;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For WIFI Beacon Distribution
|
|
|
|
* Long slot time : 2x cwmin
|
|
|
|
* Short slot time : 4x cwmin
|
|
|
|
*/
|
2016-07-04 12:37:24 +00:00
|
|
|
if (ah->slottime == 20)
|
2011-04-13 05:53:26 +00:00
|
|
|
qi.tqi_cwmin = 2*qi_be.tqi_cwmin;
|
|
|
|
else
|
|
|
|
qi.tqi_cwmin = 4*qi_be.tqi_cwmin;
|
|
|
|
|
|
|
|
qi.tqi_cwmax = qi_be.tqi_cwmax;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-03-01 20:15:46 +00:00
|
|
|
if (!ath9k_hw_set_txq_props(ah, priv->beacon.beaconq, &qi)) {
|
2011-04-13 05:53:26 +00:00
|
|
|
ath_err(ath9k_hw_common(ah),
|
2014-03-01 20:15:46 +00:00
|
|
|
"Unable to update beacon queue %u!\n", priv->beacon.beaconq);
|
2011-04-13 05:53:26 +00:00
|
|
|
} else {
|
2014-03-01 20:15:46 +00:00
|
|
|
ath9k_hw_resettxqueue(ah, priv->beacon.beaconq);
|
2011-04-13 05:53:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-01 20:15:59 +00:00
|
|
|
/*
|
|
|
|
* Both nexttbtt and intval have to be in usecs.
|
|
|
|
*/
|
|
|
|
static void ath9k_htc_beacon_init(struct ath9k_htc_priv *priv,
|
|
|
|
struct ath_beacon_config *conf,
|
|
|
|
bool reset_tsf)
|
|
|
|
{
|
|
|
|
struct ath_hw *ah = priv->ah;
|
|
|
|
int ret __attribute__ ((unused));
|
|
|
|
__be32 htc_imask = 0;
|
|
|
|
u8 cmd_rsp;
|
|
|
|
|
2014-03-01 20:16:06 +00:00
|
|
|
if (conf->intval >= TU_TO_USEC(DEFAULT_SWBA_RESPONSE))
|
|
|
|
ah->config.sw_beacon_response_time = DEFAULT_SWBA_RESPONSE;
|
|
|
|
else
|
|
|
|
ah->config.sw_beacon_response_time = MIN_SWBA_RESPONSE;
|
|
|
|
|
2014-03-01 20:15:59 +00:00
|
|
|
WMI_CMD(WMI_DISABLE_INTR_CMDID);
|
|
|
|
if (reset_tsf)
|
|
|
|
ath9k_hw_reset_tsf(ah);
|
|
|
|
ath9k_htc_beaconq_config(priv);
|
|
|
|
ath9k_hw_beaconinit(ah, conf->nexttbtt, conf->intval);
|
|
|
|
priv->beacon.bmisscnt = 0;
|
|
|
|
htc_imask = cpu_to_be32(ah->imask);
|
|
|
|
WMI_CMD_BUF(WMI_ENABLE_INTR_CMDID, &htc_imask);
|
|
|
|
}
|
|
|
|
|
2010-03-17 08:55:25 +00:00
|
|
|
static void ath9k_htc_beacon_config_sta(struct ath9k_htc_priv *priv,
|
2014-03-01 20:15:45 +00:00
|
|
|
struct ath_beacon_config *bss_conf)
|
2010-03-17 08:55:25 +00:00
|
|
|
{
|
|
|
|
struct ath9k_beacon_state bs;
|
|
|
|
enum ath9k_int imask = 0;
|
2010-04-16 06:24:03 +00:00
|
|
|
__be32 htc_imask = 0;
|
2011-04-20 05:30:34 +00:00
|
|
|
int ret __attribute__ ((unused));
|
2010-03-17 08:55:25 +00:00
|
|
|
u8 cmd_rsp;
|
|
|
|
|
2014-03-01 20:15:57 +00:00
|
|
|
if (ath9k_cmn_beacon_config_sta(priv->ah, bss_conf, &bs) == -EPERM)
|
|
|
|
return;
|
2010-03-17 08:55:25 +00:00
|
|
|
|
|
|
|
WMI_CMD(WMI_DISABLE_INTR_CMDID);
|
|
|
|
ath9k_hw_set_sta_beacon_timers(priv->ah, &bs);
|
|
|
|
imask |= ATH9K_INT_BMISS;
|
|
|
|
htc_imask = cpu_to_be32(imask);
|
|
|
|
WMI_CMD_BUF(WMI_ENABLE_INTR_CMDID, &htc_imask);
|
|
|
|
}
|
|
|
|
|
2011-02-21 02:19:53 +00:00
|
|
|
static void ath9k_htc_beacon_config_ap(struct ath9k_htc_priv *priv,
|
2014-03-01 20:16:05 +00:00
|
|
|
struct ath_beacon_config *conf)
|
2011-02-21 02:19:53 +00:00
|
|
|
{
|
2014-03-01 20:16:05 +00:00
|
|
|
struct ath_hw *ah = priv->ah;
|
|
|
|
ah->imask = 0;
|
2011-02-21 02:19:53 +00:00
|
|
|
|
2014-03-01 20:16:05 +00:00
|
|
|
ath9k_cmn_beacon_config_ap(ah, conf, ATH9K_HTC_MAX_BCN_VIF);
|
|
|
|
ath9k_htc_beacon_init(priv, conf, false);
|
2011-02-21 02:19:53 +00:00
|
|
|
}
|
|
|
|
|
2010-03-17 08:55:25 +00:00
|
|
|
static void ath9k_htc_beacon_config_adhoc(struct ath9k_htc_priv *priv,
|
2014-03-01 20:16:02 +00:00
|
|
|
struct ath_beacon_config *conf)
|
2010-03-17 08:55:25 +00:00
|
|
|
{
|
2014-03-01 20:16:01 +00:00
|
|
|
struct ath_hw *ah = priv->ah;
|
2014-03-01 20:16:02 +00:00
|
|
|
ah->imask = 0;
|
2011-02-21 02:20:01 +00:00
|
|
|
|
2014-03-01 20:16:02 +00:00
|
|
|
ath9k_cmn_beacon_config_adhoc(ah, conf);
|
|
|
|
ath9k_htc_beacon_init(priv, conf, conf->ibss_creator);
|
2010-03-17 08:55:25 +00:00
|
|
|
}
|
|
|
|
|
2010-05-06 09:15:47 +00:00
|
|
|
void ath9k_htc_beaconep(void *drv_priv, struct sk_buff *skb,
|
|
|
|
enum htc_endpoint_id ep_id, bool txok)
|
2010-03-17 08:55:25 +00:00
|
|
|
{
|
2010-05-06 09:15:47 +00:00
|
|
|
dev_kfree_skb_any(skb);
|
2010-03-17 08:55:25 +00:00
|
|
|
}
|
|
|
|
|
2011-04-13 05:53:34 +00:00
|
|
|
static void ath9k_htc_send_buffered(struct ath9k_htc_priv *priv,
|
|
|
|
int slot)
|
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ieee80211_vif *vif;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct ieee80211_hdr *hdr;
|
2011-04-13 05:55:47 +00:00
|
|
|
int padpos, padsize, ret, tx_slot;
|
2011-04-13 05:53:34 +00:00
|
|
|
|
|
|
|
spin_lock_bh(&priv->beacon_lock);
|
|
|
|
|
2014-03-01 20:15:45 +00:00
|
|
|
vif = priv->beacon.bslot[slot];
|
2011-04-13 05:53:34 +00:00
|
|
|
|
|
|
|
skb = ieee80211_get_buffered_bc(priv->hw, vif);
|
|
|
|
|
|
|
|
while(skb) {
|
|
|
|
hdr = (struct ieee80211_hdr *) skb->data;
|
|
|
|
|
2013-04-07 22:04:09 +00:00
|
|
|
padpos = ieee80211_hdrlen(hdr->frame_control);
|
2011-04-13 05:53:34 +00:00
|
|
|
padsize = padpos & 3;
|
|
|
|
if (padsize && skb->len > padpos) {
|
|
|
|
if (skb_headroom(skb) < padsize) {
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
skb_push(skb, padsize);
|
|
|
|
memmove(skb->data, skb->data + padsize, padpos);
|
|
|
|
}
|
|
|
|
|
2011-04-13 05:55:47 +00:00
|
|
|
tx_slot = ath9k_htc_tx_get_slot(priv);
|
2011-04-16 08:47:39 +00:00
|
|
|
if (tx_slot < 0) {
|
2011-12-15 22:55:53 +00:00
|
|
|
ath_dbg(common, XMIT, "No free CAB slot\n");
|
2011-04-13 05:55:47 +00:00
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
|
2012-07-23 19:33:42 +00:00
|
|
|
ret = ath9k_htc_tx_start(priv, NULL, skb, tx_slot, true);
|
2011-04-13 05:53:34 +00:00
|
|
|
if (ret != 0) {
|
2011-04-13 05:55:47 +00:00
|
|
|
ath9k_htc_tx_clear_slot(priv, tx_slot);
|
2011-04-13 05:53:34 +00:00
|
|
|
dev_kfree_skb_any(skb);
|
2011-04-13 05:55:47 +00:00
|
|
|
|
2011-12-15 22:55:53 +00:00
|
|
|
ath_dbg(common, XMIT, "Failed to send CAB frame\n");
|
2011-04-13 05:55:29 +00:00
|
|
|
} else {
|
|
|
|
spin_lock_bh(&priv->tx.tx_lock);
|
|
|
|
priv->tx.queued_cnt++;
|
|
|
|
spin_unlock_bh(&priv->tx.tx_lock);
|
2011-04-13 05:53:34 +00:00
|
|
|
}
|
|
|
|
next:
|
|
|
|
skb = ieee80211_get_buffered_bc(priv->hw, vif);
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_bh(&priv->beacon_lock);
|
|
|
|
}
|
|
|
|
|
2011-04-13 05:53:08 +00:00
|
|
|
static void ath9k_htc_send_beacon(struct ath9k_htc_priv *priv,
|
|
|
|
int slot)
|
2010-03-17 08:55:25 +00:00
|
|
|
{
|
2011-04-13 05:53:44 +00:00
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
2011-04-13 05:53:08 +00:00
|
|
|
struct ieee80211_vif *vif;
|
|
|
|
struct ath9k_htc_vif *avp;
|
2010-03-17 08:55:25 +00:00
|
|
|
struct tx_beacon_header beacon_hdr;
|
2011-04-13 05:54:31 +00:00
|
|
|
struct ath9k_htc_tx_ctl *tx_ctl;
|
2010-03-17 08:55:25 +00:00
|
|
|
struct ieee80211_tx_info *info;
|
2011-04-13 05:53:17 +00:00
|
|
|
struct ieee80211_mgmt *mgmt;
|
2010-05-06 09:15:47 +00:00
|
|
|
struct sk_buff *beacon;
|
2010-03-17 08:55:25 +00:00
|
|
|
u8 *tx_fhdr;
|
2011-04-13 05:53:44 +00:00
|
|
|
int ret;
|
2010-03-17 08:55:25 +00:00
|
|
|
|
|
|
|
memset(&beacon_hdr, 0, sizeof(struct tx_beacon_header));
|
|
|
|
|
|
|
|
spin_lock_bh(&priv->beacon_lock);
|
|
|
|
|
2014-03-01 20:15:45 +00:00
|
|
|
vif = priv->beacon.bslot[slot];
|
2011-04-13 05:53:08 +00:00
|
|
|
avp = (struct ath9k_htc_vif *)vif->drv_priv;
|
|
|
|
|
2014-03-01 20:15:49 +00:00
|
|
|
if (unlikely(test_bit(ATH_OP_SCANNING, &common->op_flags))) {
|
2010-03-17 08:55:25 +00:00
|
|
|
spin_unlock_bh(&priv->beacon_lock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get a new beacon */
|
2011-04-13 05:53:08 +00:00
|
|
|
beacon = ieee80211_beacon_get(priv->hw, vif);
|
2010-05-06 09:15:47 +00:00
|
|
|
if (!beacon) {
|
2010-03-17 08:55:25 +00:00
|
|
|
spin_unlock_bh(&priv->beacon_lock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-13 05:53:17 +00:00
|
|
|
/*
|
|
|
|
* Update the TSF adjust value here, the HW will
|
|
|
|
* add this value for every beacon.
|
|
|
|
*/
|
|
|
|
mgmt = (struct ieee80211_mgmt *)beacon->data;
|
|
|
|
mgmt->u.beacon.timestamp = avp->tsfadjust;
|
|
|
|
|
2010-05-06 09:15:47 +00:00
|
|
|
info = IEEE80211_SKB_CB(beacon);
|
2010-03-17 08:55:25 +00:00
|
|
|
if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
|
|
|
|
struct ieee80211_hdr *hdr =
|
2010-05-06 09:15:47 +00:00
|
|
|
(struct ieee80211_hdr *) beacon->data;
|
2011-02-21 02:18:53 +00:00
|
|
|
avp->seq_no += 0x10;
|
2010-03-17 08:55:25 +00:00
|
|
|
hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
|
2011-02-21 02:18:53 +00:00
|
|
|
hdr->seq_ctrl |= cpu_to_le16(avp->seq_no);
|
2010-03-17 08:55:25 +00:00
|
|
|
}
|
|
|
|
|
2011-04-13 05:54:31 +00:00
|
|
|
tx_ctl = HTC_SKB_CB(beacon);
|
|
|
|
memset(tx_ctl, 0, sizeof(*tx_ctl));
|
|
|
|
|
|
|
|
tx_ctl->type = ATH9K_HTC_BEACON;
|
2011-04-13 05:55:35 +00:00
|
|
|
tx_ctl->epid = priv->beacon_ep;
|
2011-04-13 05:54:31 +00:00
|
|
|
|
2010-03-17 08:55:25 +00:00
|
|
|
beacon_hdr.vif_index = avp->index;
|
2010-05-06 09:15:47 +00:00
|
|
|
tx_fhdr = skb_push(beacon, sizeof(beacon_hdr));
|
2010-03-17 08:55:25 +00:00
|
|
|
memcpy(tx_fhdr, (u8 *) &beacon_hdr, sizeof(beacon_hdr));
|
|
|
|
|
2011-04-13 05:55:35 +00:00
|
|
|
ret = htc_send(priv->htc, beacon);
|
2011-04-13 05:53:44 +00:00
|
|
|
if (ret != 0) {
|
|
|
|
if (ret == -ENOMEM) {
|
2011-12-15 22:55:53 +00:00
|
|
|
ath_dbg(common, BSTUCK,
|
2011-04-13 05:53:44 +00:00
|
|
|
"Failed to send beacon, no free TX buffer\n");
|
|
|
|
}
|
|
|
|
dev_kfree_skb_any(beacon);
|
|
|
|
}
|
2010-03-17 08:55:25 +00:00
|
|
|
|
|
|
|
spin_unlock_bh(&priv->beacon_lock);
|
2015-06-09 07:59:49 +00:00
|
|
|
|
|
|
|
ath9k_htc_csa_is_finished(priv);
|
2010-03-17 08:55:25 +00:00
|
|
|
}
|
|
|
|
|
2011-04-13 05:53:52 +00:00
|
|
|
static int ath9k_htc_choose_bslot(struct ath9k_htc_priv *priv,
|
|
|
|
struct wmi_event_swba *swba)
|
2011-04-13 05:53:08 +00:00
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
u64 tsf;
|
|
|
|
u32 tsftu;
|
|
|
|
u16 intval;
|
|
|
|
int slot;
|
|
|
|
|
2011-05-20 12:22:11 +00:00
|
|
|
intval = priv->cur_beacon_conf.beacon_interval;
|
2011-04-13 05:53:08 +00:00
|
|
|
|
2011-04-13 05:53:52 +00:00
|
|
|
tsf = be64_to_cpu(swba->tsf);
|
2011-04-13 05:53:08 +00:00
|
|
|
tsftu = TSF_TO_TU(tsf >> 32, tsf);
|
|
|
|
slot = ((tsftu % intval) * ATH9K_HTC_MAX_BCN_VIF) / intval;
|
|
|
|
slot = ATH9K_HTC_MAX_BCN_VIF - slot - 1;
|
|
|
|
|
2011-12-15 22:55:53 +00:00
|
|
|
ath_dbg(common, BEACON,
|
2011-04-13 05:53:08 +00:00
|
|
|
"Choose slot: %d, tsf: %llu, tsftu: %u, intval: %u\n",
|
|
|
|
slot, tsf, tsftu, intval);
|
|
|
|
|
|
|
|
return slot;
|
|
|
|
}
|
|
|
|
|
2011-04-13 05:53:52 +00:00
|
|
|
void ath9k_htc_swba(struct ath9k_htc_priv *priv,
|
|
|
|
struct wmi_event_swba *swba)
|
2011-04-13 05:53:08 +00:00
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
int slot;
|
|
|
|
|
2011-04-13 05:53:52 +00:00
|
|
|
if (swba->beacon_pending != 0) {
|
2014-03-01 20:15:45 +00:00
|
|
|
priv->beacon.bmisscnt++;
|
|
|
|
if (priv->beacon.bmisscnt > BSTUCK_THRESHOLD) {
|
2011-12-15 22:55:53 +00:00
|
|
|
ath_dbg(common, BSTUCK, "Beacon stuck, HW reset\n");
|
2011-04-13 05:53:52 +00:00
|
|
|
ieee80211_queue_work(priv->hw,
|
|
|
|
&priv->fatal_work);
|
2011-04-13 05:53:08 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-01 20:15:45 +00:00
|
|
|
if (priv->beacon.bmisscnt) {
|
2011-12-15 22:55:53 +00:00
|
|
|
ath_dbg(common, BSTUCK,
|
2011-04-13 05:53:08 +00:00
|
|
|
"Resuming beacon xmit after %u misses\n",
|
2014-03-01 20:15:45 +00:00
|
|
|
priv->beacon.bmisscnt);
|
|
|
|
priv->beacon.bmisscnt = 0;
|
2011-04-13 05:53:08 +00:00
|
|
|
}
|
|
|
|
|
2011-04-13 05:53:52 +00:00
|
|
|
slot = ath9k_htc_choose_bslot(priv, swba);
|
2011-04-13 05:53:08 +00:00
|
|
|
spin_lock_bh(&priv->beacon_lock);
|
2014-03-01 20:15:45 +00:00
|
|
|
if (priv->beacon.bslot[slot] == NULL) {
|
2011-04-13 05:53:08 +00:00
|
|
|
spin_unlock_bh(&priv->beacon_lock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
spin_unlock_bh(&priv->beacon_lock);
|
|
|
|
|
2011-04-13 05:53:34 +00:00
|
|
|
ath9k_htc_send_buffered(priv, slot);
|
2011-04-13 05:53:08 +00:00
|
|
|
ath9k_htc_send_beacon(priv, slot);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ath9k_htc_assign_bslot(struct ath9k_htc_priv *priv,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ath9k_htc_vif *avp = (struct ath9k_htc_vif *)vif->drv_priv;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
spin_lock_bh(&priv->beacon_lock);
|
|
|
|
for (i = 0; i < ATH9K_HTC_MAX_BCN_VIF; i++) {
|
2014-03-01 20:15:45 +00:00
|
|
|
if (priv->beacon.bslot[i] == NULL) {
|
2011-04-13 05:53:08 +00:00
|
|
|
avp->bslot = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-01 20:15:45 +00:00
|
|
|
priv->beacon.bslot[avp->bslot] = vif;
|
2011-04-13 05:53:08 +00:00
|
|
|
spin_unlock_bh(&priv->beacon_lock);
|
|
|
|
|
2011-12-15 22:55:53 +00:00
|
|
|
ath_dbg(common, CONFIG, "Added interface at beacon slot: %d\n",
|
|
|
|
avp->bslot);
|
2011-04-13 05:53:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ath9k_htc_remove_bslot(struct ath9k_htc_priv *priv,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ath9k_htc_vif *avp = (struct ath9k_htc_vif *)vif->drv_priv;
|
|
|
|
|
|
|
|
spin_lock_bh(&priv->beacon_lock);
|
2014-03-01 20:15:45 +00:00
|
|
|
priv->beacon.bslot[avp->bslot] = NULL;
|
2011-04-13 05:53:08 +00:00
|
|
|
spin_unlock_bh(&priv->beacon_lock);
|
|
|
|
|
2011-12-15 22:55:53 +00:00
|
|
|
ath_dbg(common, CONFIG, "Removed interface at beacon slot: %d\n",
|
|
|
|
avp->bslot);
|
2011-04-13 05:53:08 +00:00
|
|
|
}
|
|
|
|
|
2011-04-13 05:53:17 +00:00
|
|
|
/*
|
|
|
|
* Calculate the TSF adjustment value for all slots
|
|
|
|
* other than zero.
|
|
|
|
*/
|
|
|
|
void ath9k_htc_set_tsfadjust(struct ath9k_htc_priv *priv,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
|
|
|
struct ath9k_htc_vif *avp = (struct ath9k_htc_vif *)vif->drv_priv;
|
2014-03-01 20:15:45 +00:00
|
|
|
struct ath_beacon_config *cur_conf = &priv->cur_beacon_conf;
|
2011-04-13 05:53:17 +00:00
|
|
|
u64 tsfadjust;
|
|
|
|
|
|
|
|
if (avp->bslot == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The beacon interval cannot be different for multi-AP mode,
|
|
|
|
* and we reach here only for VIF slots greater than zero,
|
|
|
|
* so beacon_interval is guaranteed to be set in cur_conf.
|
|
|
|
*/
|
|
|
|
tsfadjust = cur_conf->beacon_interval * avp->bslot / ATH9K_HTC_MAX_BCN_VIF;
|
|
|
|
avp->tsfadjust = cpu_to_le64(TU_TO_USEC(tsfadjust));
|
|
|
|
|
2011-12-15 22:55:53 +00:00
|
|
|
ath_dbg(common, CONFIG, "tsfadjust is: %llu for bslot: %d\n",
|
2011-04-13 05:53:17 +00:00
|
|
|
(unsigned long long)tsfadjust, avp->bslot);
|
|
|
|
}
|
|
|
|
|
2011-02-27 03:50:40 +00:00
|
|
|
static void ath9k_htc_beacon_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
|
|
|
|
{
|
2017-09-01 06:43:34 +00:00
|
|
|
bool *beacon_configured = data;
|
2011-02-27 03:50:40 +00:00
|
|
|
struct ath9k_htc_vif *avp = (struct ath9k_htc_vif *) vif->drv_priv;
|
|
|
|
|
|
|
|
if (vif->type == NL80211_IFTYPE_STATION &&
|
|
|
|
avp->beacon_configured)
|
|
|
|
*beacon_configured = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool ath9k_htc_check_beacon_config(struct ath9k_htc_priv *priv,
|
|
|
|
struct ieee80211_vif *vif)
|
2010-03-17 08:55:25 +00:00
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
2014-03-01 20:15:45 +00:00
|
|
|
struct ath_beacon_config *cur_conf = &priv->cur_beacon_conf;
|
2010-04-16 06:23:48 +00:00
|
|
|
struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
|
2011-02-27 03:50:40 +00:00
|
|
|
bool beacon_configured;
|
2010-04-05 09:18:06 +00:00
|
|
|
|
2011-02-21 02:19:53 +00:00
|
|
|
/*
|
|
|
|
* Changing the beacon interval when multiple AP interfaces
|
|
|
|
* are configured will affect beacon transmission of all
|
|
|
|
* of them.
|
|
|
|
*/
|
|
|
|
if ((priv->ah->opmode == NL80211_IFTYPE_AP) &&
|
|
|
|
(priv->num_ap_vif > 1) &&
|
|
|
|
(vif->type == NL80211_IFTYPE_AP) &&
|
|
|
|
(cur_conf->beacon_interval != bss_conf->beacon_int)) {
|
2011-12-15 22:55:53 +00:00
|
|
|
ath_dbg(common, CONFIG,
|
2011-02-21 02:19:53 +00:00
|
|
|
"Changing beacon interval of multiple AP interfaces !\n");
|
2011-02-27 03:50:40 +00:00
|
|
|
return false;
|
2011-02-21 02:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the HW is operating in AP mode, any new station interfaces that
|
|
|
|
* are added cannot change the beacon parameters.
|
|
|
|
*/
|
|
|
|
if (priv->num_ap_vif &&
|
|
|
|
(vif->type != NL80211_IFTYPE_AP)) {
|
2011-12-15 22:55:53 +00:00
|
|
|
ath_dbg(common, CONFIG,
|
2011-02-21 02:19:53 +00:00
|
|
|
"HW in AP mode, cannot set STA beacon parameters\n");
|
2011-02-27 03:50:40 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The beacon parameters are configured only for the first
|
|
|
|
* station interface.
|
|
|
|
*/
|
|
|
|
if ((priv->ah->opmode == NL80211_IFTYPE_STATION) &&
|
|
|
|
(priv->num_sta_vif > 1) &&
|
|
|
|
(vif->type == NL80211_IFTYPE_STATION)) {
|
|
|
|
beacon_configured = false;
|
2012-11-06 19:23:30 +00:00
|
|
|
ieee80211_iterate_active_interfaces_atomic(
|
|
|
|
priv->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
|
|
|
|
ath9k_htc_beacon_iter, &beacon_configured);
|
2011-02-27 03:50:40 +00:00
|
|
|
|
|
|
|
if (beacon_configured) {
|
2011-12-15 22:55:53 +00:00
|
|
|
ath_dbg(common, CONFIG,
|
2011-02-27 03:50:40 +00:00
|
|
|
"Beacon already configured for a station interface\n");
|
|
|
|
return false;
|
|
|
|
}
|
2011-02-21 02:19:53 +00:00
|
|
|
}
|
|
|
|
|
2011-02-27 03:50:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ath9k_htc_beacon_config(struct ath9k_htc_priv *priv,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
2014-03-01 20:15:45 +00:00
|
|
|
struct ath_beacon_config *cur_conf = &priv->cur_beacon_conf;
|
2011-02-27 03:50:40 +00:00
|
|
|
struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
|
|
|
|
struct ath9k_htc_vif *avp = (struct ath9k_htc_vif *) vif->drv_priv;
|
|
|
|
|
|
|
|
if (!ath9k_htc_check_beacon_config(priv, vif))
|
|
|
|
return;
|
|
|
|
|
2010-04-16 06:23:48 +00:00
|
|
|
cur_conf->beacon_interval = bss_conf->beacon_int;
|
2010-04-05 09:18:06 +00:00
|
|
|
if (cur_conf->beacon_interval == 0)
|
|
|
|
cur_conf->beacon_interval = 100;
|
|
|
|
|
2010-04-16 06:23:48 +00:00
|
|
|
cur_conf->dtim_period = bss_conf->dtim_period;
|
|
|
|
cur_conf->bmiss_timeout =
|
|
|
|
ATH_DEFAULT_BMISS_LIMIT * cur_conf->beacon_interval;
|
|
|
|
|
|
|
|
switch (vif->type) {
|
2010-03-17 08:55:25 +00:00
|
|
|
case NL80211_IFTYPE_STATION:
|
2010-04-05 09:18:06 +00:00
|
|
|
ath9k_htc_beacon_config_sta(priv, cur_conf);
|
2011-02-27 03:50:40 +00:00
|
|
|
avp->beacon_configured = true;
|
2010-03-17 08:55:25 +00:00
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
2010-04-05 09:18:06 +00:00
|
|
|
ath9k_htc_beacon_config_adhoc(priv, cur_conf);
|
2010-03-17 08:55:25 +00:00
|
|
|
break;
|
2013-05-08 17:16:46 +00:00
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
2011-02-21 02:19:53 +00:00
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
ath9k_htc_beacon_config_ap(priv, cur_conf);
|
|
|
|
break;
|
2010-03-17 08:55:25 +00:00
|
|
|
default:
|
2011-12-15 22:55:53 +00:00
|
|
|
ath_dbg(common, CONFIG, "Unsupported beaconing mode\n");
|
2010-03-17 08:55:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-02-21 02:18:39 +00:00
|
|
|
|
|
|
|
void ath9k_htc_beacon_reconfig(struct ath9k_htc_priv *priv)
|
|
|
|
{
|
|
|
|
struct ath_common *common = ath9k_hw_common(priv->ah);
|
2014-03-01 20:15:45 +00:00
|
|
|
struct ath_beacon_config *cur_conf = &priv->cur_beacon_conf;
|
2011-02-21 02:18:39 +00:00
|
|
|
|
|
|
|
switch (priv->ah->opmode) {
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
ath9k_htc_beacon_config_sta(priv, cur_conf);
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
ath9k_htc_beacon_config_adhoc(priv, cur_conf);
|
|
|
|
break;
|
2013-05-08 17:16:46 +00:00
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
2011-02-21 02:19:53 +00:00
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
ath9k_htc_beacon_config_ap(priv, cur_conf);
|
|
|
|
break;
|
2011-02-21 02:18:39 +00:00
|
|
|
default:
|
2011-12-15 22:55:53 +00:00
|
|
|
ath_dbg(common, CONFIG, "Unsupported beaconing mode\n");
|
2011-02-21 02:18:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-06-09 07:59:49 +00:00
|
|
|
|
|
|
|
bool ath9k_htc_csa_is_finished(struct ath9k_htc_priv *priv)
|
|
|
|
{
|
|
|
|
struct ieee80211_vif *vif;
|
|
|
|
|
|
|
|
vif = priv->csa_vif;
|
|
|
|
if (!vif || !vif->csa_active)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!ieee80211_csa_is_complete(vif))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ieee80211_csa_finish(vif);
|
|
|
|
|
|
|
|
priv->csa_vif = NULL;
|
|
|
|
return true;
|
|
|
|
}
|