2009-08-06 13:25:28 +00:00
|
|
|
/*
|
|
|
|
* This file is part of wl1271
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008-2009 Nokia Corporation
|
|
|
|
*
|
|
|
|
* Contact: Luciano Coelho <luciano.coelho@nokia.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-11-21 17:25:24 +00:00
|
|
|
#include "wlcore.h"
|
2011-10-07 08:02:42 +00:00
|
|
|
#include "debug.h"
|
2010-11-08 11:20:10 +00:00
|
|
|
#include "io.h"
|
|
|
|
#include "event.h"
|
|
|
|
#include "ps.h"
|
|
|
|
#include "scan.h"
|
2009-10-08 18:56:30 +00:00
|
|
|
#include "wl12xx_80211.h"
|
2009-08-06 13:25:28 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
void wlcore_event_rssi_trigger(struct wl1271 *wl, s8 *metric_arr)
|
2010-04-09 08:07:30 +00:00
|
|
|
{
|
2012-11-22 16:06:19 +00:00
|
|
|
struct wl12xx_vif *wlvif;
|
|
|
|
struct ieee80211_vif *vif;
|
2010-04-09 08:07:30 +00:00
|
|
|
enum nl80211_cqm_rssi_threshold_event event;
|
2012-11-22 16:06:19 +00:00
|
|
|
s8 metric = metric_arr[0];
|
2010-04-09 08:07:30 +00:00
|
|
|
|
|
|
|
wl1271_debug(DEBUG_EVENT, "RSSI trigger metric: %d", metric);
|
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
/* TODO: check actual multi-role support */
|
|
|
|
wl12xx_for_each_wlvif_sta(wl, wlvif) {
|
|
|
|
if (metric <= wlvif->rssi_thold)
|
|
|
|
event = NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW;
|
|
|
|
else
|
|
|
|
event = NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH;
|
|
|
|
|
|
|
|
vif = wl12xx_wlvif_to_vif(wlvif);
|
|
|
|
if (event != wlvif->last_rssi_event)
|
|
|
|
ieee80211_cqm_rssi_notify(vif, event, GFP_KERNEL);
|
|
|
|
wlvif->last_rssi_event = event;
|
|
|
|
}
|
2010-04-09 08:07:30 +00:00
|
|
|
}
|
2012-11-22 16:06:19 +00:00
|
|
|
EXPORT_SYMBOL_GPL(wlcore_event_rssi_trigger);
|
2010-04-09 08:07:30 +00:00
|
|
|
|
2011-10-05 09:55:45 +00:00
|
|
|
static void wl1271_stop_ba_event(struct wl1271 *wl, struct wl12xx_vif *wlvif)
|
2011-05-22 13:10:22 +00:00
|
|
|
{
|
2011-10-10 08:12:57 +00:00
|
|
|
struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif);
|
|
|
|
|
2011-10-05 09:55:45 +00:00
|
|
|
if (wlvif->bss_type != BSS_TYPE_AP_BSS) {
|
2011-10-05 09:56:04 +00:00
|
|
|
if (!wlvif->sta.ba_rx_bitmap)
|
2011-08-25 09:43:16 +00:00
|
|
|
return;
|
2011-10-10 08:12:57 +00:00
|
|
|
ieee80211_stop_rx_ba_session(vif, wlvif->sta.ba_rx_bitmap,
|
|
|
|
vif->bss_conf.bssid);
|
2011-08-25 09:43:16 +00:00
|
|
|
} else {
|
2011-10-05 09:56:05 +00:00
|
|
|
u8 hlid;
|
2011-08-25 09:43:16 +00:00
|
|
|
struct wl1271_link *lnk;
|
2011-10-05 09:56:05 +00:00
|
|
|
for_each_set_bit(hlid, wlvif->ap.sta_hlid_map,
|
|
|
|
WL12XX_MAX_LINKS) {
|
|
|
|
lnk = &wl->links[hlid];
|
|
|
|
if (!lnk->ba_bitmap)
|
2011-08-25 09:43:16 +00:00
|
|
|
continue;
|
|
|
|
|
2011-10-10 08:12:57 +00:00
|
|
|
ieee80211_stop_rx_ba_session(vif,
|
2011-08-25 09:43:16 +00:00
|
|
|
lnk->ba_bitmap,
|
|
|
|
lnk->addr);
|
|
|
|
}
|
|
|
|
}
|
2011-05-22 13:10:22 +00:00
|
|
|
}
|
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
void wlcore_event_soft_gemini_sense(struct wl1271 *wl, u8 enable)
|
2011-05-15 08:10:29 +00:00
|
|
|
{
|
2011-10-10 08:12:57 +00:00
|
|
|
struct wl12xx_vif *wlvif;
|
|
|
|
|
2011-05-15 08:10:29 +00:00
|
|
|
if (enable) {
|
|
|
|
set_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags);
|
|
|
|
} else {
|
2011-10-10 08:12:59 +00:00
|
|
|
clear_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags);
|
2011-10-10 08:12:57 +00:00
|
|
|
wl12xx_for_each_wlvif_sta(wl, wlvif) {
|
2011-10-10 08:12:59 +00:00
|
|
|
wl1271_recalc_rx_streaming(wl, wlvif);
|
2011-10-10 08:12:57 +00:00
|
|
|
}
|
2011-05-15 08:10:29 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-22 16:06:19 +00:00
|
|
|
EXPORT_SYMBOL_GPL(wlcore_event_soft_gemini_sense);
|
2011-05-15 08:10:29 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
void wlcore_event_sched_scan_report(struct wl1271 *wl,
|
|
|
|
u8 status)
|
2009-08-06 13:25:28 +00:00
|
|
|
{
|
2012-11-22 16:06:19 +00:00
|
|
|
wl1271_debug(DEBUG_EVENT, "PERIODIC_SCAN_REPORT_EVENT (status 0x%0x)",
|
|
|
|
status);
|
|
|
|
|
|
|
|
wl1271_scan_sched_scan_results(wl);
|
2009-08-06 13:25:28 +00:00
|
|
|
}
|
2012-11-22 16:06:19 +00:00
|
|
|
EXPORT_SYMBOL_GPL(wlcore_event_sched_scan_report);
|
2009-08-06 13:25:28 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
void wlcore_event_sched_scan_completed(struct wl1271 *wl,
|
|
|
|
u8 status)
|
2009-08-06 13:25:28 +00:00
|
|
|
{
|
2012-11-22 16:06:19 +00:00
|
|
|
wl1271_debug(DEBUG_EVENT, "PERIODIC_SCAN_COMPLETE_EVENT (status 0x%0x)",
|
|
|
|
status);
|
2009-08-06 13:25:28 +00:00
|
|
|
|
2012-11-22 16:06:23 +00:00
|
|
|
if (wl->sched_vif) {
|
2012-11-22 16:06:19 +00:00
|
|
|
ieee80211_sched_scan_stopped(wl->hw);
|
2012-11-22 16:06:23 +00:00
|
|
|
wl->sched_vif = NULL;
|
2012-11-22 16:06:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(wlcore_event_sched_scan_completed);
|
2009-08-06 13:25:28 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
void wlcore_event_ba_rx_constraint(struct wl1271 *wl,
|
|
|
|
unsigned long roles_bitmap,
|
|
|
|
unsigned long allowed_bitmap)
|
|
|
|
{
|
|
|
|
struct wl12xx_vif *wlvif;
|
2009-08-06 13:25:28 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
wl1271_debug(DEBUG_EVENT, "%s: roles=0x%lx allowed=0x%lx",
|
|
|
|
__func__, roles_bitmap, allowed_bitmap);
|
2010-07-08 14:50:06 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
wl12xx_for_each_wlvif(wl, wlvif) {
|
|
|
|
if (wlvif->role_id == WL12XX_INVALID_ROLE_ID ||
|
|
|
|
!test_bit(wlvif->role_id , &roles_bitmap))
|
|
|
|
continue;
|
2009-08-06 13:25:28 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
wlvif->ba_allowed = !!test_bit(wlvif->role_id,
|
|
|
|
&allowed_bitmap);
|
|
|
|
if (!wlvif->ba_allowed)
|
|
|
|
wl1271_stop_ba_event(wl, wlvif);
|
2011-05-10 11:28:27 +00:00
|
|
|
}
|
2012-11-22 16:06:19 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(wlcore_event_ba_rx_constraint);
|
2011-05-10 11:28:27 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
void wlcore_event_channel_switch(struct wl1271 *wl,
|
|
|
|
unsigned long roles_bitmap,
|
|
|
|
bool success)
|
|
|
|
{
|
|
|
|
struct wl12xx_vif *wlvif;
|
|
|
|
struct ieee80211_vif *vif;
|
2011-05-10 11:28:27 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
wl1271_debug(DEBUG_EVENT, "%s: roles=0x%lx success=%d",
|
|
|
|
__func__, roles_bitmap, success);
|
2010-07-08 14:50:03 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
wl12xx_for_each_wlvif_sta(wl, wlvif) {
|
|
|
|
if (wlvif->role_id == WL12XX_INVALID_ROLE_ID ||
|
|
|
|
!test_bit(wlvif->role_id , &roles_bitmap))
|
|
|
|
continue;
|
2012-05-15 14:08:54 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
if (!test_and_clear_bit(WLVIF_FLAG_CS_PROGRESS,
|
|
|
|
&wlvif->flags))
|
|
|
|
continue;
|
2012-05-15 11:53:17 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
vif = wl12xx_wlvif_to_vif(wlvif);
|
2012-05-15 11:53:17 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
ieee80211_chswitch_done(vif, success);
|
|
|
|
cancel_delayed_work(&wlvif->channel_switch_work);
|
2012-04-26 07:35:07 +00:00
|
|
|
}
|
2012-11-22 16:06:19 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(wlcore_event_channel_switch);
|
2009-08-06 13:25:28 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
void wlcore_event_dummy_packet(struct wl1271 *wl)
|
|
|
|
{
|
|
|
|
wl1271_debug(DEBUG_EVENT, "DUMMY_PACKET_ID_EVENT_ID");
|
|
|
|
wl1271_tx_dummy_packet(wl);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(wlcore_event_dummy_packet);
|
2009-11-02 18:22:11 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
static void wlcore_disconnect_sta(struct wl1271 *wl, unsigned long sta_bitmap)
|
|
|
|
{
|
|
|
|
u32 num_packets = wl->conf.tx.max_tx_retries;
|
|
|
|
struct wl12xx_vif *wlvif;
|
|
|
|
struct ieee80211_vif *vif;
|
|
|
|
struct ieee80211_sta *sta;
|
|
|
|
const u8 *addr;
|
|
|
|
int h;
|
|
|
|
|
|
|
|
for_each_set_bit(h, &sta_bitmap, WL12XX_MAX_LINKS) {
|
|
|
|
bool found = false;
|
|
|
|
/* find the ap vif connected to this sta */
|
|
|
|
wl12xx_for_each_wlvif_ap(wl, wlvif) {
|
|
|
|
if (!test_bit(h, wlvif->ap.sta_hlid_map))
|
|
|
|
continue;
|
|
|
|
found = true;
|
|
|
|
break;
|
2011-10-10 08:12:57 +00:00
|
|
|
}
|
2012-11-22 16:06:19 +00:00
|
|
|
if (!found)
|
|
|
|
continue;
|
2011-05-22 13:10:22 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
vif = wl12xx_wlvif_to_vif(wlvif);
|
|
|
|
addr = wl->links[h].addr;
|
2011-08-25 09:43:16 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
rcu_read_lock();
|
|
|
|
sta = ieee80211_find_sta(vif, addr);
|
|
|
|
if (sta) {
|
|
|
|
wl1271_debug(DEBUG_EVENT, "remove sta %d", h);
|
|
|
|
ieee80211_report_low_ack(sta, num_packets);
|
2011-10-10 08:12:57 +00:00
|
|
|
}
|
2012-11-22 16:06:19 +00:00
|
|
|
rcu_read_unlock();
|
2011-05-22 13:10:22 +00:00
|
|
|
}
|
2012-11-22 16:06:19 +00:00
|
|
|
}
|
2011-05-22 13:10:22 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
void wlcore_event_max_tx_failure(struct wl1271 *wl, unsigned long sta_bitmap)
|
|
|
|
{
|
|
|
|
wl1271_debug(DEBUG_EVENT, "MAX_TX_FAILURE_EVENT_ID");
|
|
|
|
wlcore_disconnect_sta(wl, sta_bitmap);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(wlcore_event_max_tx_failure);
|
2012-01-24 09:46:32 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
void wlcore_event_inactive_sta(struct wl1271 *wl, unsigned long sta_bitmap)
|
|
|
|
{
|
|
|
|
wl1271_debug(DEBUG_EVENT, "INACTIVE_STA_EVENT_ID");
|
|
|
|
wlcore_disconnect_sta(wl, sta_bitmap);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(wlcore_event_inactive_sta);
|
2011-09-08 10:01:33 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
void wlcore_event_roc_complete(struct wl1271 *wl)
|
|
|
|
{
|
|
|
|
wl1271_debug(DEBUG_EVENT, "REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID");
|
|
|
|
if (wl->roc_vif)
|
|
|
|
ieee80211_ready_on_channel(wl->hw);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(wlcore_event_roc_complete);
|
2011-03-06 14:32:14 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
void wlcore_event_beacon_loss(struct wl1271 *wl, unsigned long roles_bitmap)
|
|
|
|
{
|
2011-06-26 07:36:03 +00:00
|
|
|
/*
|
2012-11-22 16:06:19 +00:00
|
|
|
* We are HW_MONITOR device. On beacon loss - queue
|
|
|
|
* connection loss work. Cancel it on REGAINED event.
|
2011-06-26 07:36:03 +00:00
|
|
|
*/
|
2012-11-22 16:06:19 +00:00
|
|
|
struct wl12xx_vif *wlvif;
|
|
|
|
struct ieee80211_vif *vif;
|
|
|
|
int delay = wl->conf.conn.synch_fail_thold *
|
|
|
|
wl->conf.conn.bss_lose_timeout;
|
2011-06-26 07:36:03 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
wl1271_info("Beacon loss detected. roles:0x%lx", roles_bitmap);
|
2012-11-20 11:20:03 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
wl12xx_for_each_wlvif_sta(wl, wlvif) {
|
|
|
|
if (wlvif->role_id == WL12XX_INVALID_ROLE_ID ||
|
|
|
|
!test_bit(wlvif->role_id , &roles_bitmap))
|
|
|
|
continue;
|
2011-06-26 07:36:03 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
/*
|
|
|
|
* if the work is already queued, it should take place.
|
|
|
|
* We don't want to delay the connection loss
|
|
|
|
* indication any more.
|
|
|
|
*/
|
|
|
|
ieee80211_queue_delayed_work(wl->hw,
|
|
|
|
&wlvif->connection_loss_work,
|
|
|
|
msecs_to_jiffies(delay));
|
2011-06-26 07:36:03 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
vif = wl12xx_wlvif_to_vif(wlvif);
|
|
|
|
ieee80211_cqm_rssi_notify(
|
|
|
|
vif,
|
|
|
|
NL80211_CQM_RSSI_BEACON_LOSS_EVENT,
|
|
|
|
GFP_KERNEL);
|
2011-06-26 07:36:03 +00:00
|
|
|
}
|
2009-08-06 13:25:28 +00:00
|
|
|
}
|
2012-11-22 16:06:19 +00:00
|
|
|
EXPORT_SYMBOL_GPL(wlcore_event_beacon_loss);
|
2009-08-06 13:25:28 +00:00
|
|
|
|
|
|
|
int wl1271_event_unmask(struct wl1271 *wl)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = wl1271_acx_event_mbox_mask(wl, ~(wl->event_mask));
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-11 13:40:59 +00:00
|
|
|
int wl1271_event_handle(struct wl1271 *wl, u8 mbox_num)
|
2009-08-06 13:25:28 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
wl1271_debug(DEBUG_EVENT, "EVENT on mbox %d", mbox_num);
|
|
|
|
|
|
|
|
if (mbox_num > 1)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* first we read the mbox descriptor */
|
2012-06-18 09:31:16 +00:00
|
|
|
ret = wlcore_read(wl, wl->mbox_ptr[mbox_num], wl->mbox,
|
2012-11-22 16:06:19 +00:00
|
|
|
wl->mbox_size, false);
|
2012-06-18 09:31:16 +00:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2009-08-06 13:25:28 +00:00
|
|
|
|
|
|
|
/* process the descriptor */
|
2012-11-22 16:06:19 +00:00
|
|
|
ret = wl->ops->process_mailbox_events(wl);
|
2009-08-06 13:25:28 +00:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2012-04-11 07:15:46 +00:00
|
|
|
/*
|
|
|
|
* TODO: we just need this because one bit is in a different
|
|
|
|
* place. Is there any better way?
|
|
|
|
*/
|
2012-06-19 21:48:23 +00:00
|
|
|
ret = wl->ops->ack_event(wl);
|
2009-08-06 13:25:28 +00:00
|
|
|
|
2012-06-19 21:48:23 +00:00
|
|
|
return ret;
|
2009-08-06 13:25:28 +00:00
|
|
|
}
|