2009-06-13 11:38:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* File: wcmd.c
|
|
|
|
*
|
|
|
|
* Purpose: Handles the management command interface functions
|
|
|
|
*
|
|
|
|
* Author: Lyndon Chen
|
|
|
|
*
|
|
|
|
* Date: May 8, 2003
|
|
|
|
*
|
|
|
|
* Functions:
|
|
|
|
* s_vProbeChannel - Active scan channel
|
|
|
|
* s_MgrMakeProbeRequest - Make ProbeRequest packet
|
|
|
|
* CommandTimer - Timer function to handle command
|
|
|
|
* s_bCommandComplete - Command Complete function
|
|
|
|
* bScheduleCommand - Push Command and wait Command Scheduler to do
|
|
|
|
* vCommandTimer- Command call back functions
|
|
|
|
* vCommandTimerWait- Call back timer
|
|
|
|
* s_bClearBSSID_SCAN- Clear BSSID_SCAN cmd in CMD Queue
|
|
|
|
*
|
|
|
|
* Revision History:
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "device.h"
|
|
|
|
#include "mac.h"
|
|
|
|
#include "card.h"
|
|
|
|
#include "wcmd.h"
|
|
|
|
#include "power.h"
|
|
|
|
#include "baseband.h"
|
2014-05-26 12:59:07 +00:00
|
|
|
#include "usbpipe.h"
|
2009-06-13 11:38:31 +00:00
|
|
|
#include "rxtx.h"
|
|
|
|
#include "rf.h"
|
|
|
|
#include "channel.h"
|
|
|
|
|
2012-12-10 22:01:23 +00:00
|
|
|
static int s_bCommandComplete(struct vnt_private *);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-07-12 06:53:39 +00:00
|
|
|
static void vCommandTimerWait(struct vnt_private *priv, unsigned long msecs)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-07-12 06:53:39 +00:00
|
|
|
schedule_delayed_work(&priv->run_command_work, msecs_to_jiffies(msecs));
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2013-09-27 15:48:14 +00:00
|
|
|
void vRunCommand(struct work_struct *work)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-07-12 06:53:42 +00:00
|
|
|
struct vnt_private *priv =
|
2013-09-27 15:48:14 +00:00
|
|
|
container_of(work, struct vnt_private, run_command_work.work);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-07-12 06:53:42 +00:00
|
|
|
if (priv->Flags & fMP_DISCONNECTED)
|
2013-10-14 18:51:45 +00:00
|
|
|
return;
|
|
|
|
|
2014-07-12 06:53:42 +00:00
|
|
|
if (priv->bCmdRunning != true)
|
2013-11-12 17:35:35 +00:00
|
|
|
return;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-07-12 06:53:42 +00:00
|
|
|
switch (priv->eCommandState) {
|
2014-06-25 20:14:27 +00:00
|
|
|
case WLAN_CMD_INIT_MAC80211_START:
|
2014-07-12 06:53:42 +00:00
|
|
|
if (priv->mac_hw)
|
2014-06-25 20:14:27 +00:00
|
|
|
break;
|
|
|
|
|
2014-07-12 06:53:42 +00:00
|
|
|
dev_info(&priv->usb->dev, "Starting mac80211\n");
|
2014-06-25 20:14:27 +00:00
|
|
|
|
2014-07-12 06:53:42 +00:00
|
|
|
if (vnt_init(priv)) {
|
2014-06-25 20:14:27 +00:00
|
|
|
/* If fail all ends TODO retry */
|
2014-07-12 06:53:42 +00:00
|
|
|
dev_err(&priv->usb->dev, "failed to start\n");
|
|
|
|
ieee80211_free_hw(priv->hw);
|
2014-06-25 20:14:27 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-12 17:35:36 +00:00
|
|
|
break;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-12 17:35:36 +00:00
|
|
|
case WLAN_CMD_TBTT_WAKEUP_START:
|
2014-07-12 06:53:42 +00:00
|
|
|
vnt_next_tbtt_wakeup(priv);
|
2013-11-12 17:35:36 +00:00
|
|
|
break;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-12 17:35:36 +00:00
|
|
|
case WLAN_CMD_BECON_SEND_START:
|
2014-07-12 06:53:42 +00:00
|
|
|
if (!priv->vif)
|
2014-06-25 20:14:30 +00:00
|
|
|
break;
|
|
|
|
|
2014-07-12 06:53:42 +00:00
|
|
|
vnt_beacon_make(priv, priv->vif);
|
2014-06-25 20:14:30 +00:00
|
|
|
|
2014-07-12 06:53:42 +00:00
|
|
|
vnt_mac_reg_bits_on(priv, MAC_REG_TCR, TCR_AUTOBCNTX);
|
2014-06-25 20:14:30 +00:00
|
|
|
|
2013-11-12 17:35:36 +00:00
|
|
|
break;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-12 17:35:36 +00:00
|
|
|
case WLAN_CMD_SETPOWER_START:
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-07-12 06:53:42 +00:00
|
|
|
vnt_rf_setpower(priv, priv->wCurrentRate,
|
|
|
|
priv->hw->conf.chandef.chan->hw_value);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-12 17:35:36 +00:00
|
|
|
break;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-12 17:35:36 +00:00
|
|
|
case WLAN_CMD_CHANGE_ANTENNA_START:
|
2014-07-12 06:53:48 +00:00
|
|
|
dev_dbg(&priv->usb->dev, "Change from Antenna%d to",
|
|
|
|
priv->dwRxAntennaSel);
|
2014-07-12 06:53:42 +00:00
|
|
|
|
|
|
|
if (priv->dwRxAntennaSel == 0) {
|
|
|
|
priv->dwRxAntennaSel = 1;
|
|
|
|
if (priv->bTxRxAntInv == true)
|
|
|
|
BBvSetAntennaMode(priv, ANT_RXA);
|
2013-11-12 17:35:35 +00:00
|
|
|
else
|
2014-07-12 06:53:42 +00:00
|
|
|
BBvSetAntennaMode(priv, ANT_RXB);
|
2013-11-12 17:35:35 +00:00
|
|
|
} else {
|
2014-07-12 06:53:42 +00:00
|
|
|
priv->dwRxAntennaSel = 0;
|
|
|
|
if (priv->bTxRxAntInv == true)
|
|
|
|
BBvSetAntennaMode(priv, ANT_RXB);
|
2013-11-12 17:35:35 +00:00
|
|
|
else
|
2014-07-12 06:53:42 +00:00
|
|
|
BBvSetAntennaMode(priv, ANT_RXA);
|
2013-11-12 17:35:35 +00:00
|
|
|
}
|
2013-11-12 17:35:36 +00:00
|
|
|
break;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-12 17:35:36 +00:00
|
|
|
case WLAN_CMD_11H_CHSW_START:
|
2014-07-12 06:53:42 +00:00
|
|
|
vnt_set_channel(priv, priv->hw->conf.chandef.chan->hw_value);
|
2013-11-12 17:35:36 +00:00
|
|
|
break;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-12 17:35:36 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} //switch
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-07-12 06:53:42 +00:00
|
|
|
s_bCommandComplete(priv);
|
2014-02-19 19:35:16 +00:00
|
|
|
|
2013-11-12 17:35:36 +00:00
|
|
|
return;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-07-12 06:53:45 +00:00
|
|
|
static int s_bCommandComplete(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
|
|
|
|
2014-07-12 06:53:45 +00:00
|
|
|
priv->eCommandState = WLAN_CMD_IDLE;
|
|
|
|
if (priv->cbFreeCmdQueue == CMD_Q_SIZE) {
|
|
|
|
/* Command Queue Empty */
|
|
|
|
priv->bCmdRunning = false;
|
2013-11-12 17:35:35 +00:00
|
|
|
return true;
|
2014-07-12 06:53:44 +00:00
|
|
|
}
|
2014-06-25 20:14:27 +00:00
|
|
|
|
2014-07-13 09:42:41 +00:00
|
|
|
priv->command = priv->eCmdQueue[priv->uCmdDequeueIdx].cmd;
|
2013-11-12 17:35:35 +00:00
|
|
|
|
2014-07-12 06:53:45 +00:00
|
|
|
ADD_ONE_WITH_WRAP_AROUND(priv->uCmdDequeueIdx, CMD_Q_SIZE);
|
|
|
|
priv->cbFreeCmdQueue++;
|
|
|
|
priv->bCmdRunning = true;
|
2013-11-12 17:35:35 +00:00
|
|
|
|
2014-07-13 09:42:41 +00:00
|
|
|
switch (priv->command) {
|
2014-07-12 06:53:44 +00:00
|
|
|
case WLAN_CMD_INIT_MAC80211:
|
2014-07-12 06:53:45 +00:00
|
|
|
priv->eCommandState = WLAN_CMD_INIT_MAC80211_START;
|
2014-07-12 06:53:44 +00:00
|
|
|
break;
|
2013-11-12 17:35:35 +00:00
|
|
|
|
2014-07-12 06:53:44 +00:00
|
|
|
case WLAN_CMD_TBTT_WAKEUP:
|
2014-07-12 06:53:45 +00:00
|
|
|
priv->eCommandState = WLAN_CMD_TBTT_WAKEUP_START;
|
2014-07-12 06:53:44 +00:00
|
|
|
break;
|
2013-11-12 17:35:35 +00:00
|
|
|
|
2014-07-12 06:53:44 +00:00
|
|
|
case WLAN_CMD_BECON_SEND:
|
2014-07-12 06:53:45 +00:00
|
|
|
priv->eCommandState = WLAN_CMD_BECON_SEND_START;
|
2014-07-12 06:53:44 +00:00
|
|
|
break;
|
2013-11-12 17:35:35 +00:00
|
|
|
|
2014-07-12 06:53:44 +00:00
|
|
|
case WLAN_CMD_SETPOWER:
|
2014-07-12 06:53:45 +00:00
|
|
|
priv->eCommandState = WLAN_CMD_SETPOWER_START;
|
2014-07-12 06:53:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WLAN_CMD_CHANGE_ANTENNA:
|
2014-07-12 06:53:45 +00:00
|
|
|
priv->eCommandState = WLAN_CMD_CHANGE_ANTENNA_START;
|
2014-07-12 06:53:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WLAN_CMD_11H_CHSW:
|
2014-07-12 06:53:45 +00:00
|
|
|
priv->eCommandState = WLAN_CMD_11H_CHSW_START;
|
2014-07-12 06:53:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2013-11-12 17:35:35 +00:00
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-07-12 06:53:45 +00:00
|
|
|
vCommandTimerWait(priv, 0);
|
2014-07-12 06:53:44 +00:00
|
|
|
|
2013-11-12 17:35:36 +00:00
|
|
|
return true;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-07-13 09:42:41 +00:00
|
|
|
int bScheduleCommand(struct vnt_private *priv, enum vnt_cmd command, u8 *item0)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
|
|
|
|
2014-07-12 06:53:46 +00:00
|
|
|
if (priv->cbFreeCmdQueue == 0)
|
2013-11-12 17:35:37 +00:00
|
|
|
return false;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-07-13 09:42:41 +00:00
|
|
|
priv->eCmdQueue[priv->uCmdEnqueueIdx].cmd = command;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-07-12 06:53:46 +00:00
|
|
|
ADD_ONE_WITH_WRAP_AROUND(priv->uCmdEnqueueIdx, CMD_Q_SIZE);
|
|
|
|
priv->cbFreeCmdQueue--;
|
|
|
|
|
|
|
|
if (priv->bCmdRunning == false)
|
|
|
|
s_bCommandComplete(priv);
|
2013-11-12 17:35:30 +00:00
|
|
|
|
2013-11-12 17:35:37 +00:00
|
|
|
return true;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-12 06:53:47 +00:00
|
|
|
void vResetCommandTimer(struct vnt_private *priv)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-07-12 06:53:47 +00:00
|
|
|
priv->cbFreeCmdQueue = CMD_Q_SIZE;
|
|
|
|
priv->uCmdDequeueIdx = 0;
|
|
|
|
priv->uCmdEnqueueIdx = 0;
|
|
|
|
priv->eCommandState = WLAN_CMD_IDLE;
|
|
|
|
priv->bCmdRunning = false;
|
|
|
|
priv->bCmdClear = false;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|