2009-06-13 13:38:31 +02: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.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* File: wcmd.c
|
|
|
|
*
|
|
|
|
* Purpose: Handles the management command interface functions
|
|
|
|
*
|
|
|
|
* Author: Lyndon Chen
|
|
|
|
*
|
|
|
|
* Date: May 8, 2003
|
|
|
|
*
|
|
|
|
* Functions:
|
2014-07-13 11:42:47 +02:00
|
|
|
* vnt_cmd_complete - Command Complete function
|
2014-07-13 11:42:53 +02:00
|
|
|
* vnt_schedule_command - Push Command and wait Command Scheduler to do
|
2014-07-13 11:42:48 +02:00
|
|
|
* vnt_cmd_timer_wait- Call back timer
|
2009-06-13 13:38:31 +02:00
|
|
|
*
|
|
|
|
* Revision History:
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "device.h"
|
|
|
|
#include "mac.h"
|
|
|
|
#include "wcmd.h"
|
|
|
|
#include "power.h"
|
2014-05-26 14:59:07 +02:00
|
|
|
#include "usbpipe.h"
|
2009-06-13 13:38:31 +02:00
|
|
|
#include "rxtx.h"
|
|
|
|
#include "rf.h"
|
|
|
|
|
2014-07-13 11:42:48 +02:00
|
|
|
static void vnt_cmd_timer_wait(struct vnt_private *priv, unsigned long msecs)
|
2009-06-13 13:38:31 +02:00
|
|
|
{
|
2014-07-12 08:53:39 +02:00
|
|
|
schedule_delayed_work(&priv->run_command_work, msecs_to_jiffies(msecs));
|
2009-06-13 13:38:31 +02:00
|
|
|
}
|
|
|
|
|
2014-07-13 11:42:47 +02:00
|
|
|
static int vnt_cmd_complete(struct vnt_private *priv)
|
|
|
|
{
|
|
|
|
priv->command_state = WLAN_CMD_IDLE;
|
|
|
|
if (priv->free_cmd_queue == CMD_Q_SIZE) {
|
|
|
|
/* Command Queue Empty */
|
|
|
|
priv->cmd_running = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->command = priv->cmd_queue[priv->cmd_dequeue_idx];
|
|
|
|
|
|
|
|
ADD_ONE_WITH_WRAP_AROUND(priv->cmd_dequeue_idx, CMD_Q_SIZE);
|
|
|
|
priv->free_cmd_queue++;
|
|
|
|
priv->cmd_running = true;
|
|
|
|
|
|
|
|
switch (priv->command) {
|
|
|
|
case WLAN_CMD_INIT_MAC80211:
|
|
|
|
priv->command_state = WLAN_CMD_INIT_MAC80211_START;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WLAN_CMD_TBTT_WAKEUP:
|
|
|
|
priv->command_state = WLAN_CMD_TBTT_WAKEUP_START;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WLAN_CMD_BECON_SEND:
|
|
|
|
priv->command_state = WLAN_CMD_BECON_SEND_START;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WLAN_CMD_SETPOWER:
|
|
|
|
priv->command_state = WLAN_CMD_SETPOWER_START;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WLAN_CMD_CHANGE_ANTENNA:
|
|
|
|
priv->command_state = WLAN_CMD_CHANGE_ANTENNA_START;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-07-13 11:42:48 +02:00
|
|
|
vnt_cmd_timer_wait(priv, 0);
|
2014-07-13 11:42:47 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-07-13 11:42:49 +02:00
|
|
|
void vnt_run_command(struct work_struct *work)
|
2009-06-13 13:38:31 +02:00
|
|
|
{
|
2014-07-12 08:53:42 +02:00
|
|
|
struct vnt_private *priv =
|
2013-09-27 17:48:14 +02:00
|
|
|
container_of(work, struct vnt_private, run_command_work.work);
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2014-07-24 22:13:20 +02:00
|
|
|
if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags))
|
2013-10-14 20:51:45 +02:00
|
|
|
return;
|
|
|
|
|
2016-03-22 13:55:37 +01:00
|
|
|
if (!priv->cmd_running)
|
2013-11-12 18:35:35 +01:00
|
|
|
return;
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2014-07-13 11:42:42 +02:00
|
|
|
switch (priv->command_state) {
|
2014-06-25 22:14:27 +02:00
|
|
|
case WLAN_CMD_INIT_MAC80211_START:
|
2014-07-12 08:53:42 +02:00
|
|
|
if (priv->mac_hw)
|
2014-06-25 22:14:27 +02:00
|
|
|
break;
|
|
|
|
|
2014-07-12 08:53:42 +02:00
|
|
|
dev_info(&priv->usb->dev, "Starting mac80211\n");
|
2014-06-25 22:14:27 +02:00
|
|
|
|
2014-07-12 08:53:42 +02:00
|
|
|
if (vnt_init(priv)) {
|
2014-06-25 22:14:27 +02:00
|
|
|
/* If fail all ends TODO retry */
|
2014-07-12 08:53:42 +02:00
|
|
|
dev_err(&priv->usb->dev, "failed to start\n");
|
|
|
|
ieee80211_free_hw(priv->hw);
|
2014-06-25 22:14:27 +02:00
|
|
|
return;
|
|
|
|
}
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2013-11-12 18:35:36 +01:00
|
|
|
break;
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2013-11-12 18:35:36 +01:00
|
|
|
case WLAN_CMD_TBTT_WAKEUP_START:
|
2014-07-12 08:53:42 +02:00
|
|
|
vnt_next_tbtt_wakeup(priv);
|
2013-11-12 18:35:36 +01:00
|
|
|
break;
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2013-11-12 18:35:36 +01:00
|
|
|
case WLAN_CMD_BECON_SEND_START:
|
2014-07-12 08:53:42 +02:00
|
|
|
if (!priv->vif)
|
2014-06-25 22:14:30 +02:00
|
|
|
break;
|
|
|
|
|
2014-07-12 08:53:42 +02:00
|
|
|
vnt_beacon_make(priv, priv->vif);
|
2014-06-25 22:14:30 +02:00
|
|
|
|
2014-07-12 08:53:42 +02:00
|
|
|
vnt_mac_reg_bits_on(priv, MAC_REG_TCR, TCR_AUTOBCNTX);
|
2014-06-25 22:14:30 +02:00
|
|
|
|
2013-11-12 18:35:36 +01:00
|
|
|
break;
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2013-11-12 18:35:36 +01:00
|
|
|
case WLAN_CMD_SETPOWER_START:
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2014-07-20 16:33:19 +02:00
|
|
|
vnt_rf_setpower(priv, priv->current_rate,
|
2014-07-12 08:53:42 +02:00
|
|
|
priv->hw->conf.chandef.chan->hw_value);
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2013-11-12 18:35:36 +01:00
|
|
|
break;
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2013-11-12 18:35:36 +01:00
|
|
|
case WLAN_CMD_CHANGE_ANTENNA_START:
|
2014-07-12 08:53:48 +02:00
|
|
|
dev_dbg(&priv->usb->dev, "Change from Antenna%d to",
|
2017-02-14 19:09:15 +01:00
|
|
|
priv->rx_antenna_sel);
|
2014-07-12 08:53:42 +02:00
|
|
|
|
2014-07-19 13:30:16 +02:00
|
|
|
if (priv->rx_antenna_sel == 0) {
|
|
|
|
priv->rx_antenna_sel = 1;
|
2016-03-22 13:55:37 +01:00
|
|
|
if (priv->tx_rx_ant_inv)
|
2014-07-16 23:21:52 +02:00
|
|
|
vnt_set_antenna_mode(priv, ANT_RXA);
|
2013-11-12 18:35:35 +01:00
|
|
|
else
|
2014-07-16 23:21:52 +02:00
|
|
|
vnt_set_antenna_mode(priv, ANT_RXB);
|
2013-11-12 18:35:35 +01:00
|
|
|
} else {
|
2014-07-19 13:30:16 +02:00
|
|
|
priv->rx_antenna_sel = 0;
|
2016-03-22 13:55:37 +01:00
|
|
|
if (priv->tx_rx_ant_inv)
|
2014-07-16 23:21:52 +02:00
|
|
|
vnt_set_antenna_mode(priv, ANT_RXB);
|
2013-11-12 18:35:35 +01:00
|
|
|
else
|
2014-07-16 23:21:52 +02:00
|
|
|
vnt_set_antenna_mode(priv, ANT_RXA);
|
2013-11-12 18:35:35 +01:00
|
|
|
}
|
2013-11-12 18:35:36 +01:00
|
|
|
break;
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2013-11-12 18:35:36 +01:00
|
|
|
default:
|
|
|
|
break;
|
2014-07-13 11:42:53 +02:00
|
|
|
}
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2014-07-13 11:42:47 +02:00
|
|
|
vnt_cmd_complete(priv);
|
2009-06-13 13:38:31 +02:00
|
|
|
}
|
|
|
|
|
2014-07-13 11:42:50 +02:00
|
|
|
int vnt_schedule_command(struct vnt_private *priv, enum vnt_cmd command)
|
2009-06-13 13:38:31 +02:00
|
|
|
{
|
2014-07-13 11:42:45 +02:00
|
|
|
if (priv->free_cmd_queue == 0)
|
2013-11-12 18:35:37 +01:00
|
|
|
return false;
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2014-07-13 11:42:45 +02:00
|
|
|
priv->cmd_queue[priv->cmd_enqueue_idx] = command;
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2014-07-13 11:42:45 +02:00
|
|
|
ADD_ONE_WITH_WRAP_AROUND(priv->cmd_enqueue_idx, CMD_Q_SIZE);
|
|
|
|
priv->free_cmd_queue--;
|
2014-07-12 08:53:46 +02:00
|
|
|
|
2016-03-22 13:55:37 +01:00
|
|
|
if (!priv->cmd_running)
|
2014-07-13 11:42:47 +02:00
|
|
|
vnt_cmd_complete(priv);
|
2013-11-12 18:35:30 +01:00
|
|
|
|
2013-11-12 18:35:37 +01:00
|
|
|
return true;
|
2009-06-13 13:38:31 +02:00
|
|
|
}
|
|
|
|
|
2014-07-13 11:42:51 +02:00
|
|
|
void vnt_reset_command_timer(struct vnt_private *priv)
|
2009-06-13 13:38:31 +02:00
|
|
|
{
|
2014-07-13 11:42:45 +02:00
|
|
|
priv->free_cmd_queue = CMD_Q_SIZE;
|
|
|
|
priv->cmd_dequeue_idx = 0;
|
|
|
|
priv->cmd_enqueue_idx = 0;
|
2014-07-13 11:42:42 +02:00
|
|
|
priv->command_state = WLAN_CMD_IDLE;
|
2014-07-13 11:42:45 +02:00
|
|
|
priv->cmd_running = false;
|
2009-06-13 13:38:31 +02:00
|
|
|
}
|