📄 cmdtest.c
字号:
/* cmdTest.c - contains more tests for ART can be run from command line or within ART */
/* Copyright (c) 2002 Atheros Communications, Inc., All Rights Reserved */
#ident "ACI $Id: //depot/sw/branches/ART_V53_dragon/sw/src/dk/mdk/devmld/cmdTest.c#1 $, $Header: //depot/sw/branches/ART_V53_dragon/sw/src/dk/mdk/devmld/cmdTest.c#1 $"
#ifdef __ATH_DJGPPDOS__
#include <unistd.h>
#ifndef EILSEQ
#define EILSEQ EIO
#endif // EILSEQ
#define __int64 long long
#define HANDLE long
typedef unsigned long DWORD;
#define Sleep delay
#include <bios.h>
#include <dir.h>
#endif // #ifdef __ATH_DJGPPDOS__
#ifdef _WINDOWS
#include <windows.h>
#endif
#include "common_hw.h"
#ifdef JUNGO
#include "mld.h"
#endif
#ifdef LINUX
#include "linux_ansi.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#ifndef LINUX
#include <conio.h>
#include <io.h>
#endif
#include <string.h>
#include <ctype.h>
#include "wlantype.h"
#include "wlanproto.h"
#ifdef LINUX
#include "linuxdrv.h"
#else
#include "ntdrv.h"
#endif
#include "athreg.h"
#include "manlib.h" /* The Manufacturing Library */
#include "manlibInst.h" /* The Manufacturing Library Instrument Library extension */
#include "art_if.h"
#include "pci.h" /* PCI Config Space definitions */
#include "test.h"
#include "dynamic_optimizations.h"
#include "maui_cal.h"
#include "parse.h"
#include "dk_cmds.h"
#include "cmdTest.h"
#ifndef __ATH_DJGPPDOS__
#include "MLIBif.h" /* Manufacturing Library low level driver support functions */
#else
#include "mlibif_dos.h"
#endif
#ifdef LINUX
#include <unistd.h>
#endif
static A_UCHAR bssID[6] = {0x50, 0x55, 0x55, 0x55, 0x55, 0x05};
static A_UCHAR goldenStation[6] = {0x10, 0x11, 0x11, 0x11, 0x11, 0x01}; // DUT
static A_UCHAR dutStation[6] = {0x20, 0x22, 0x22, 0x22, 0x22, 0x02}; // Golden
static A_UINT32 globalTestMask;
static void goldenSetup(A_UINT32 devNum);
static A_UINT32 transmitTest(A_UINT32 devNum, A_UINT32 testChannel, A_UINT32 testMode, A_UINT32 turbo, A_UINT16 antenna, A_UINT16 goldAntenna);
static A_UINT32 receiveTest(A_UINT32 devNum, A_UINT32 testChannel, A_UINT32 testMode, A_UINT32 turbo, A_UINT16 antenna, A_UINT16 goldAntenna);
static A_UINT32 broadcastTest(A_UINT32 devNum, A_UINT32 testChannel, A_UINT32 testMode, A_UINT32 turbo, A_UINT16 antenna);
static A_UINT32 throughputUpTest(A_UINT32 devNum, A_UINT32 testChannel, A_UINT32 testMode, A_UINT32 turbo, A_UINT16 antenna, A_UINT16 goldAntenna);
static A_UINT32 throughputDownTest(A_UINT32 devNum, A_UINT32 testChannel, A_UINT32 testMode, A_UINT32 turbo, A_UINT16 antenna, A_UINT16 goldAntenna);
static void printTestMenu(void);
static void dutSendWakeupCall(A_UINT32 devNum, A_UINT32 testType, A_UINT32 testChannel, A_UINT32 testMode, A_UINT32 turbo, A_UINT16 goldAntenna, A_UINT32 miscParam);
static void goldenWait4WakeupCall(A_UINT32 devNum, TEST_INFO_STRUCT *pTestInfo);
static void goldenCompleteWakeupCall(A_UINT32 devNum);
static void printFailures(A_UINT32 reasonFailMask);
static void printFailLetters(A_UINT32 reasonFailMask);
static A_UINT32 analyzeLinkResults( A_UINT32 devNum, A_UINT32 rateMask, A_UINT32 testMode, A_UINT32 turbo, A_BOOL remoteStats, A_UINT16 antenna);
static A_UINT32 analyzeThroughputResults(A_UINT32 devNum, A_UINT32 rateIndex, A_UINT32 testMode, A_UINT32 turbo, A_BOOL remoteStats,
A_UINT16 antenna, A_UINT32 testChannel, A_CHAR *testString);
static A_UINT32 printTestSummary(A_UINT32 reasonFailMask);
static A_BOOL parseTestFile(void);
static A_BOOL printFooter(void);
static A_BOOL prepareRangeLogging(void);
static A_CHAR goldAntString[20];
extern A_BOOL thin_client;
extern WLAN_MACADDR macAddr;
extern const A_CHAR *DataRateStr[];
extern const A_CHAR *DataRate_11b[];
static FILE *rangeLogFileHandle;
const A_CHAR *DataRateShortStr[] = {" 6", " 9", " 12", " 18", " 24", " 36", " 48", " 54",
" 1L", " 2L", " 2S", "5.5L", "5.5S", " 11L", " 11S"};
const A_CHAR *DataRateShortStr_11b[] = {" 1L", " 1L", " 2L", " 2S", "5.5L", "5.5S", " 11L", " 11S"};
TEST_CONFIG testSetup =
{
5, //num iterations
100, //num packets
800, //num packets throughput
100, //num packets throughput CCK
1000, //packet size
1500, //throughput packet size
7, //throughput data rate index
90, //PER Pass threshold
-9, //PPM Min
9, //PPM Max
40, //RSSI threshold 11a ant A
40, //RSSI threshold 11a ant B
40, //RSSI threshold 11b ant A
40, //RSSI threshold 11b ant B
40, //RSSI threshold 11g ant A
40, //RSSI threshold 11g ant B
50, //max allowed CRC
10000, //beacon timeout (milliseconds)
20.0, //throughput threshold 11a
10.0, //throughput threshold 11b
10.0, //throughput threshold 11g
750, //throughput PER (num packets)
90, //throughput 11b PER (num packets)
"", //MACaddr min
"", //MACaddr mac
5140, //5G side channel
2302, //2G side channel
'N', //DUT Orientation
'N', //AP Orientation
};
A_UINT32 performCmdLineTests
(
A_UINT32 devNum
)
{
A_UINT16 i, j, k;
A_UINT16 antennaMask = configSetup.antennaMask;
A_UINT16 goldAntennaMask = configSetup.goldAntennaMask;
A_UINT16 numAntenna = 1;
A_UINT16 numGoldAntenna = 1;
char *modeStr[] = {"11a", "11g", "11b", "OFDM@2.4"};
A_UINT16 antennaSelected = DESC_ANT_A;
A_UINT16 goldAntenna;
A_UINT32 lastErrorCode;
A_UINT32 eepromValue;
globalTestMask = 0;
if(!parseTestFile()) {
return ERR_TEST_SETUP;
}
//if the golden test mask is set, this will be the only test performed
if(configSetup.cmdLineTestMask & GOLDEN_TEST_MASK) {
uiPrintf("Setting up for golden, this will be the only test operation performed\n");
goldenSetup(devNum);
return ERR_TEST_SETUP;
}
if(configSetup.cmdLineTestMask & MAC_ADDR_MASK) {
if(!testMacAddress(&macAddr)) {
uiPrintf("MAC address is outside of comparison range. Error code %d\n", ERR_MAC_ADDR_MISMATCH);
return (ERR_MAC_ADDR_MISMATCH);
}
else {
uiPrintf("MAC Address Test PASS, return code 0\n");
}
}
//check to see if the user entered any channels on the command line, if not, then
//set one up with the defaults.
if(configSetup.numListChannels == 0) {
//create one.
configSetup.testChannelList = (TEST_CHANNEL_INFO *)malloc(sizeof(TEST_CHANNEL_INFO));
if(!configSetup.testChannelList) {
uiPrintf("Unable to allocate memory for testChannel list\n");
return ERR_SYSTEM;
}
configSetup.testChannelList->channel = configSetup.channel;
configSetup.testChannelList->mode = configSetup.mode;
configSetup.testChannelList->turbo = configSetup.turbo;
configSetup.numListChannels = 1;
}
//num antenna is either 1 (ie user selected one, or we use the default) or we want to test both
if(antennaMask == (ANTENNA_A_MASK | ANTENNA_B_MASK)) {
numAntenna = 2;
}
if(goldAntennaMask == (ANTENNA_A_MASK | ANTENNA_B_MASK)) {
numGoldAntenna = 2;
}
if(configSetup.rangeLogging) {
if(!prepareRangeLogging()) {
uiPrintf("Unable to prepare for range logging \n");
return ERR_TEST_SETUP;
}
}
for (i = 0; i < configSetup.numListChannels; i++) {
goldAntennaMask = configSetup.goldAntennaMask;
for(k = 0; k < numGoldAntenna; k++) {
if (goldAntennaMask & ANTENNA_A_MASK) {
goldAntenna = USE_DESC_ANT|DESC_ANT_A;
goldAntennaMask = goldAntennaMask & ~ANTENNA_A_MASK;
strcpy(goldAntString, "A");
}
else if (goldAntennaMask & ANTENNA_B_MASK) {
goldAntenna = USE_DESC_ANT|DESC_ANT_B;
goldAntennaMask = goldAntennaMask & ~ANTENNA_B_MASK;
strcpy(goldAntString, "B");
}
else {
//have the golden unit use the default antenna
goldAntenna = 0;
strcpy(goldAntString, "default");
}
//reinitialize the dut antennaMask
antennaMask = configSetup.antennaMask;
for(j = 0; j < numAntenna; j++) {
if (antennaMask & ANTENNA_A_MASK) {
configSetup.antenna = USE_DESC_ANT|DESC_ANT_A;
antennaMask = antennaMask & ~ANTENNA_A_MASK;
antennaSelected = DESC_ANT_A;
}
else if (antennaMask & ANTENNA_B_MASK) {
configSetup.antenna = USE_DESC_ANT|DESC_ANT_B;
antennaMask = antennaMask & ~ANTENNA_B_MASK;
antennaSelected = DESC_ANT_B;
}
//perform the tests that have masks set
if(configSetup.cmdLineTestMask & TX_TEST_MASK) {
uiPrintf("\n\n===========================================================================\n");
uiPrintf("Performing transmit test on DUT Antenna %c, golden Antenna %s at Channel %d in mode %s %s\n",
(configSetup.antenna==(USE_DESC_ANT|DESC_ANT_A)) ? 'A' : 'B',
goldAntString,
configSetup.testChannelList[i].channel, modeStr[configSetup.testChannelList[i].mode],
(configSetup.testChannelList[i].turbo == TURBO_ENABLE) ? "turbo" : "" );
globalTestMask |= transmitTest(devNum, configSetup.testChannelList[i].channel, configSetup.
testChannelList[i].mode, configSetup.testChannelList[i].turbo, antennaSelected, goldAntenna);
Sleep(1000);
}
if(configSetup.cmdLineTestMask & RX_TEST_MASK) {
uiPrintf("\n\n===========================================================================\n");
uiPrintf("Performing receive test on DUT Antenna %c, golden Antenna %s at Channel %d in mode %s %s\n",
(configSetup.antenna==(USE_DESC_ANT|DESC_ANT_A)) ? 'A' : 'B',
goldAntString,
configSetup.testChannelList[i].channel, modeStr[configSetup.testChannelList[i].mode],
(configSetup.testChannelList[i].turbo == TURBO_ENABLE) ? "turbo" : "" );
globalTestMask |= receiveTest(devNum, configSetup.testChannelList[i].channel,
configSetup.testChannelList[i].mode, configSetup.testChannelList[i].turbo, antennaSelected, goldAntenna);
Sleep(1000);
}
if(configSetup.cmdLineTestMask & BEACON_TEST_MASK) {
uiPrintf("\n\n===========================================================================\n");
uiPrintf("Performing beacon receive test on DUT Antenna %c, golden Antenna %s at Channel %d in mode %s %s\n",
(configSetup.antenna==(USE_DESC_ANT|DESC_ANT_A)) ? 'A' : 'B',
goldAntString,
configSetup.testChannelList[i].channel, modeStr[configSetup.testChannelList[i].mode],
(configSetup.testChannelList[i].turbo == TURBO_ENABLE) ? "turbo" : "" );
globalTestMask |= broadcastTest(devNum, configSetup.testChannelList[i].channel,
configSetup.testChannelList[i].mode, configSetup.testChannelList[i].turbo, antennaSelected);
Sleep(1000);
}
if(configSetup.cmdLineTestMask & TP_TEST_UP_MASK) {
uiPrintf("\n\n===========================================================================\n");
uiPrintf("Performing throughput uplink test on DUT Antenna %c, golden Antenna %s at Channel %d in mode %s %s\n",
(configSetup.antenna==(USE_DESC_ANT|DESC_ANT_A)) ? 'A' : 'B',
goldAntString,
configSetup.testChannelList[i].channel, modeStr[configSetup.testChannelList[i].mode],
(configSetup.testChannelList[i].turbo == TURBO_ENABLE) ? "turbo" : "" );
globalTestMask |= throughputUpTest(devNum, configSetup.testChannelList[i].channel,
configSetup.testChannelList[i].mode, configSetup.testChannelList[i].turbo, antennaSelected, goldAntenna);
//### Sleep(1000);
}
if(configSetup.cmdLineTestMask & TP_TEST_DOWN_MASK) {
uiPrintf("\n\n===========================================================================\n");
uiPrintf("Performing throughput downlink test on DUT Antenna %c, golden Antenna %s at Channel %d in mode %s %s\n",
(configSetup.antenna==(USE_DESC_ANT|DESC_ANT_A)) ? 'A' : 'B',
goldAntString,
configSetup.testChannelList[i].channel, modeStr[configSetup.testChannelList[i].mode],
(configSetup.testChannelList[i].turbo == TURBO_ENABLE) ? "turbo" : "" );
globalTestMask |= throughputDownTest(devNum, configSetup.testChannelList[i].channel,
configSetup.testChannelList[i].mode, configSetup.testChannelList[i].turbo, antennaSelected, goldAntenna);
//### Sleep(1000);
}
if(configSetup.cmdLineTestMask & BACKUP_EEPROM_MASK) {
if(!backupEeprom(devNum, configSetup.eepBackupFilename)) {
uiPrintf("EEPROM Backup Failed\n");
globalTestMask |= MASK_EEPROM_BACKUP_FAIL;
}
}
if(configSetup.cmdLineTestMask & RESTORE_EEPROM_MASK) {
if(!restoreEeprom(devNum, configSetup.eepRestoreFilename)) {
uiPrintf("EEPROM Restore Failed\n");
globalTestMask |= MASK_EEPROM_RESTORE_FAIL;
}
}
if(configSetup.cmdLineTestMask & EEP_COMPARE_MASK) {
eepromValue = art_eepromRead(devNum, testSetup.eepromCompareSingleLocation);
if( eepromValue != configSetup.eepromCompareSingleValue) {
uiPrintf("EEPROM location 0x%04x contains 0x%04x (expected 0x%04x)\n",
testSetup.eepromCompareSingleLocation, eepromValue,
configSetup.eepromCompareSingleValue);
globalTestMask |= MASK_EEPROM_COMP_VALUE_FAIL;
}
}
}
}
}
lastErrorCode = printTestSummary(globalTestMask);
return (lastErrorCode);
}
//Golden unit will sit in loop waiting for a wakeup call from dut then setup the test
void goldenSetup
(
A_UINT32 devNum
)
{
TEST_INFO_STRUCT testInfo;
A_UINT32 waitTime = 10000;
A_UINT32 timeOut = 20000;
A_UINT32 i;
A_UCHAR pattern[] = {0xaa, 0x55};
A_UINT32 stats_mode = ENABLE_STATS_SEND ; //| ENABLE_STATS_RECEIVE;
A_UINT32 broadcast = 1;
A_BOOL enablePPM = 1;
A_UINT32 origAntenna = configSetup.antenna;
A_UINT16 numRates;
A_UINT32 rateMask;
uiPrintf("\nGolden Unit Program is running. Hit any key to quit...\n");
while(!kbhit()) {
goldenWait4WakeupCall(devNum, &testInfo);
if(kbhit())
break;
if((testInfo.mode == MODE_11B) || ((testInfo.mode == MODE_11G) && ((swDeviceID & 0xff) >= 0x0013))) {
enablePPM = 0;
}
if(testInfo.testType > THROUGHPUT_DOWN_TEST) {
uiPrintf("Illegal test type in sync packet, wait for another\n");
continue;
}
//setup the test
if(!configSetup.enableXR) {
goldenCompleteWakeupCall(devNum);
}
#if 0
uiPrintf("Num Iterations = %d\n", testInfo.numIterations);
uiPrintf("Num Packets = %d\n", testInfo.numPackets);
uiPrintf("Packet size = %d\n", testInfo.packetSize);
uiPrintf("Channel = %d\n", testInfo.channel);
uiPrintf("Test type = %d\n", testInfo.testType);
uiPrintf("Rate mask = %x\n", testInfo.rateMask);
uiPrintf("Mode = %d\n", testInfo.mode);
#endif //_DEBUG
//setup the golden antenna if needed
if(testInfo.goldAntenna) {
configSetup.antenna = testInfo.goldAntenna;
}
//set the power control if needed
if(testInfo.txPower != USE_TARGET_POWER) {
configSetup.useTargetPower = 0;
configSetup.powerOutput = (A_UINT16)testInfo.txPower;
}
art_setResetParams(devNum, configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
(A_BOOL)configSetup.eepromHeaderLoad, (A_UCHAR)testInfo.mode, configSetup.use_init);
art_resetDevice(devNum, goldenStation, bssID, testInfo.channel, testInfo.turbo);
switch(testInfo.testType) {
case TRANSMIT_TEST:
art_resetDevice(devNum, goldenStation, bssID, testInfo.channel, testInfo.turbo);
art_setAntenna(devNum, configSetup.antenna);
break;
case RECEIVE_TEST:
//doing all the receive stuff below
break;
case THROUGHPUT_UP_TEST:
art_resetDevice(devNum, goldenStation, bssID, testInfo.channel, testInfo.turbo);
art_setAntenna(devNum, configSetup.antenna);
break;
case THROUGHPUT_DOWN_TEST:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -