aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Roskin <proski@gnu.org>2007-06-04 21:04:34 -0400
committerGuido Guenther <agx@sigxcpu.org>2007-06-05 08:59:35 +0200
commit94ac6f9695da6288cb2944ae5f06e9fb3f2e847a (patch)
tree63ca98f593cf269528151a87668be6756df317fc
parentb9a4ce95821b9d50ac8d3817d78ac12b52869d62 (diff)
[PATCH] Fully separate scanning and monitoring
Don't use management timer in monitor mode, it's not needed. All that's needed is to read the status from CMD_SCAN. Remove monitor mode support from at76_handle_mgmt_timeout_scan(), reorganize the logic to reduce indentation. Split at76_start_monitor() from at76_start_scan(). Signed-off-by: Pavel Roskin <proski@gnu.org>
-rw-r--r--at76_usb.c168
1 files changed, 86 insertions, 82 deletions
diff --git a/at76_usb.c b/at76_usb.c
index 71d5fd8..1c23efc 100644
--- a/at76_usb.c
+++ b/at76_usb.c
@@ -1506,8 +1506,7 @@ static int at76_start_scan(struct at76_priv *priv, int use_essid, int ir_step)
/* atmelwlandriver differs between scan type 0 and 1 (active/passive)
For ad-hoc mode, it uses type 0 only. */
- if ((priv->international_roaming == IR_ON && ir_step == 0) ||
- priv->iw_mode == IW_MODE_MONITOR)
+ if (priv->international_roaming == IR_ON && ir_step == 0)
scan.scan_type = SCAN_TYPE_PASSIVE;
else
scan.scan_type = priv->scan_mode;
@@ -1515,11 +1514,10 @@ static int at76_start_scan(struct at76_priv *priv, int use_essid, int ir_step)
/* INFO: For probe_delay, not multiplying by 1024 as this will be
slightly less than min_channel_time
(per spec: probe delay < min. channel time) */
- if (priv->istate != MONITORING) {
- scan.min_channel_time = cpu_to_le16(priv->scan_min_time);
- scan.max_channel_time = cpu_to_le16(priv->scan_max_time);
- scan.probe_delay = cpu_to_le16(priv->scan_min_time * 1000);
- }
+ scan.min_channel_time = cpu_to_le16(priv->scan_min_time);
+ scan.max_channel_time = cpu_to_le16(priv->scan_max_time);
+ scan.probe_delay = cpu_to_le16(priv->scan_min_time * 1000);
+
if (priv->international_roaming == IR_ON && ir_step == 1)
scan.international_scan = 0;
else
@@ -1540,6 +1538,27 @@ static int at76_start_scan(struct at76_priv *priv, int use_essid, int ir_step)
}
+/* Enable monitor mode */
+static int at76_start_monitor(struct at76_priv *priv)
+{
+ struct at76_req_scan scan;
+ int ret;
+
+ memset(&scan, 0, sizeof(struct at76_req_scan));
+ memset(scan.bssid, 0xff, ETH_ALEN);
+
+ scan.channel = priv->channel;
+ scan.scan_type = SCAN_TYPE_PASSIVE;
+ scan.international_scan = priv->international_roaming;
+
+ ret = at76_set_card_command(priv->udev, CMD_SCAN, &scan, sizeof(scan));
+ if (ret >= 0)
+ ret = at76_get_cmd_status(priv->udev, CMD_SCAN);
+
+ return ret;
+}
+
+
static int at76_start_ibss(struct at76_priv *priv)
{
struct at76_req_ibss bss;
@@ -2097,72 +2116,8 @@ static void at76_handle_mgmt_timeout_scan(struct at76_priv *priv)
"scan_runs %d)",
priv->netdev->name, __FUNCTION__, __LINE__, status,
priv->istate, priv->scan_runs);
- if (status == CMD_STATUS_COMPLETE) {
- if (priv->istate == SCANNING) {
- if (at76_debug & DBG_BSS_TABLE)
- at76_dump_bss_table(priv);
- switch (priv->scan_runs) {
-
- case 1:
- at76_assert(priv->international_roaming);
- if ((ret=at76_get_mib_mdomain(priv, &mdomain)) < 0) {
- err("at76_get_mib_mdomain returned %d", ret);
- } else {
- char obuf1[2*14+1], obuf2[2*14+1];
-
- at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: channel_list %s "
- "tx_powerlevel %s",
- priv->netdev->name,
- hex2str(obuf1, mdomain.channel_list,
- (sizeof(obuf1)-1)/2,'\0'),
- hex2str(obuf2, mdomain.tx_powerlevel,
- (sizeof(obuf2)-1)/2,'\0'));
- }
- if ((ret = at76_start_scan(priv, 0, 1)) < 0) {
- err("%s: %s: start_scan (ANY) failed with %d",
- priv->netdev->name, __FUNCTION__, ret);
- }
- at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer for %d ticks",
- __FUNCTION__, __LINE__, SCAN_POLL_INTERVAL);
- mod_timer(&priv->mgmt_timer, jiffies + SCAN_POLL_INTERVAL);
- break;
-
- case 2:
- if ((ret = at76_start_scan(priv, 1, 1)) < 0) {
- err("%s: %s: start_scan (SSID) failed with %d",
- priv->netdev->name, __FUNCTION__, ret);
- }
- at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer for %d ticks",
- __FUNCTION__, __LINE__, SCAN_POLL_INTERVAL);
- mod_timer(&priv->mgmt_timer, jiffies + SCAN_POLL_INTERVAL);
- break;
-
- case 3:
- priv->scan_state = SCAN_COMPLETED;
- /* report the end of scan to user space */
- at76_iwevent_scan_complete(priv->netdev);
- priv->istate = JOINING;
- /* call join_bss immediately after
- re-run of all other threads in at76_devent */
- schedule_work(&priv->work_join);
- break;
-
- default:
- err("unexpected priv->scan_runs %d", priv->scan_runs);
- }
- priv->scan_runs++;
- } else {
-
- at76_assert(priv->istate == MONITORING);
- at76_dbg(DBG_MONITOR_MODE, "%s: MONITOR MODE: restart scan",
- priv->netdev->name);
- at76_start_scan(priv, 0, 0);
- at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer for %d ticks",
- __FUNCTION__, __LINE__, SCAN_POLL_INTERVAL);
- mod_timer(&priv->mgmt_timer, jiffies + SCAN_POLL_INTERVAL);
- }
- } else {
+ if (status != CMD_STATUS_COMPLETE) {
if ((status != CMD_STATUS_IN_PROGRESS) &&
(status != CMD_STATUS_IDLE))
err("%s: %s: Bad scan status: %s",
@@ -2174,7 +2129,61 @@ static void at76_handle_mgmt_timeout_scan(struct at76_priv *priv)
at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer for %d ticks",
__FUNCTION__, __LINE__, SCAN_POLL_INTERVAL);
mod_timer(&priv->mgmt_timer, jiffies + SCAN_POLL_INTERVAL);
+ return;
}
+
+ if (at76_debug & DBG_BSS_TABLE)
+ at76_dump_bss_table(priv);
+ switch (priv->scan_runs) {
+
+ case 1:
+ at76_assert(priv->international_roaming);
+ if ((ret=at76_get_mib_mdomain(priv, &mdomain)) < 0) {
+ err("at76_get_mib_mdomain returned %d", ret);
+ } else {
+ char obuf1[2*14+1], obuf2[2*14+1];
+
+ at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: channel_list %s "
+ "tx_powerlevel %s", priv->netdev->name,
+ hex2str(obuf1, mdomain.channel_list,
+ (sizeof(obuf1) - 1) / 2, '\0'),
+ hex2str(obuf2, mdomain.tx_powerlevel,
+ (sizeof(obuf2) - 1) / 2, '\0'));
+ }
+ if ((ret = at76_start_scan(priv, 0, 1)) < 0) {
+ err("%s: %s: start_scan (ANY) failed with %d",
+ priv->netdev->name, __FUNCTION__, ret);
+ }
+ at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer for %d ticks",
+ __FUNCTION__, __LINE__, SCAN_POLL_INTERVAL);
+ mod_timer(&priv->mgmt_timer, jiffies + SCAN_POLL_INTERVAL);
+ break;
+
+ case 2:
+ if ((ret = at76_start_scan(priv, 1, 1)) < 0) {
+ err("%s: %s: start_scan (SSID) failed with %d",
+ priv->netdev->name, __FUNCTION__, ret);
+ }
+ at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer for %d ticks",
+ __FUNCTION__, __LINE__, SCAN_POLL_INTERVAL);
+ mod_timer(&priv->mgmt_timer, jiffies + SCAN_POLL_INTERVAL);
+ break;
+
+ case 3:
+ priv->scan_state = SCAN_COMPLETED;
+ /* report the end of scan to user space */
+ at76_iwevent_scan_complete(priv->netdev);
+ priv->istate = JOINING;
+ /* call join_bss immediately after
+ re-run of all other threads in at76_devent */
+ schedule_work(&priv->work_join);
+ break;
+
+ default:
+ err("unexpected priv->scan_runs %d", priv->scan_runs);
+ }
+
+ priv->scan_runs++;
}
@@ -4436,19 +4445,19 @@ static void at76_work_mgmt_timeout(struct work_struct *work)
work_mgmt_timeout);
mutex_lock(&priv->mtx);
- if ((priv->istate != SCANNING && priv->istate != MONITORING) ||
- (at76_debug & DBG_MGMT_TIMER))
- /* this is normal behavior in states MONITORING, SCANNING ... */
+
+ /* timeouts are normal in SCANNING state, otherwise report */
+ if ((priv->istate != SCANNING) || (at76_debug & DBG_MGMT_TIMER))
at76_dbg(DBG_PROGRESS, "%s: timeout, state %d", priv->netdev->name,
priv->istate);
switch (priv->istate) {
- case MONITORING:
case SCANNING:
at76_handle_mgmt_timeout_scan(priv);
break;
+ case MONITORING:
case JOINING:
at76_assert(0);
break;
@@ -4716,12 +4725,7 @@ static void at76_work_restart(struct work_struct *work)
schedule_work(&priv->work_scan);
} else {
priv->istate = MONITORING;
- at76_start_scan(priv, 0, 0);
- at76_dbg(DBG_MGMT_TIMER,
- "%s:%d: starting mgmt_timer for %d ticks",
- __FUNCTION__, __LINE__, SCAN_POLL_INTERVAL);
- mod_timer(&priv->mgmt_timer,
- jiffies + SCAN_POLL_INTERVAL);
+ at76_start_monitor(priv);
}
mutex_unlock(&priv->mtx);