/*
* 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 "tmacro.h"
#include "device.h"
#include "mac.h"
#include "card.h"
#include "80211hdr.h"
#include "wcmd.h"
#include "wmgr.h"
#include "power.h"
#include "wctl.h"
#include "baseband.h"
#include "usbpipe.h"
#include "rxtx.h"
#include "rf.h"
#include "channel.h"
#include "iowpa.h"
static int msglevel = MSG_LEVEL_INFO;
//static int msglevel = MSG_LEVEL_DEBUG;
static void s_vProbeChannel(struct vnt_private *);
static struct vnt_tx_mgmt *s_MgrMakeProbeRequest(struct vnt_private *,
struct vnt_manager *pMgmt, u8 *pScanBSSID, PWLAN_IE_SSID pSSID,
PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates);
static int s_bCommandComplete(struct vnt_private *);
static int s_bClearBSSID_SCAN(struct vnt_private *);
/*
* Description:
* Stop AdHoc beacon during scan process
*
* Parameters:
* In:
* pDevice - Pointer to the adapter
* Out:
* none
*
* Return Value: none
*
*/
static void vAdHocBeaconStop(struct vnt_private *pDevice)
{
struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
int bStop;
/*
* temporarily stop Beacon packet for AdHoc Server
* if all of the following coditions are met:
* (1) STA is in AdHoc mode
* (2) VT3253 is programmed as automatic Beacon Transmitting
* (3) One of the following conditions is met
* (3.1) AdHoc channel is in B/G band and the
* current scan channel is in A band
* or
* (3.2) AdHoc channel is in A mode
*/
bStop = false;
if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
(pMgmt->eCurrState >= WMAC_STATE_STARTED)) {
if ((pMgmt->uIBSSChannel <= CB_MAX_CHANNEL_24G) &&
(pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) {
bStop = true;
}
if (pMgmt->uIBSSChannel > CB_MAX_CHANNEL_24G)
bStop = true;
}
if (bStop) {
//PMESG(("STOP_BEACON: IBSSChannel = %u, ScanChannel = %u\n",
// pMgmt->uIBSSChannel, pMgmt->uScanChannel));
MACvRegBitsOff(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
}
} /* vAdHocBeaconStop */
/*
* Description:
* Restart AdHoc beacon after scan process complete
*
* Parameters:
* In:
* pDevice - Pointer to the adapter
* Out:
* none
*
* Return Value: none
*
*/
static void vAdHocBeaconRestart(struct vnt_private *pDevice)
{
struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
/*
* Restart Beacon packet for AdHoc Server
* if all of the following coditions are met:
* (1) STA is in AdHoc mode
* (2) VT3253 is programmed as automatic Beacon Transmitting
*/
if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
(pMgmt->eCurrState >= WMAC_STATE_STARTED)) {
//PMESG(("RESTART_BEACON\n"));
MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
}
}
/*+
*
* Routine Description:
* Prepare and send probe request management frames.
*
*
* Return Value:
* none.
*
-*/
static void s_vProbeChannel(struct vnt_private *pDevice)
{
struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
struct vnt_tx_mgmt *pTxPacket;
u8 abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES,
8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
/* 1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M*/
u8 abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES,
4, 0x0C, 0x12, 0x18, 0x60};
/* 6M, 9M, 12M, 48M*/
u8 abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES,
8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
u8 abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES,
4, 0x02, 0x04, 0x0B, 0x16};
u8 *pbyRate;
int ii;
if (pDevice->byBBType == BB_TYPE_11A)
pbyRate = &abyCurrSuppRatesA[