📄 test.c
字号:
/* test.c - contians an example test harness using the manufacturing library */
/* Copyright (c) 2000 Atheros Communications, Inc., All Rights Reserved */
#ident "ACI $Id: //depot/sw/branches/ART_V45/sw/src/dk/mdk/devmld/test.c#5 $, $Header: //depot/sw/branches/ART_V45/sw/src/dk/mdk/devmld/test.c#5 $"
#ifdef _WINDOWS
#include <windows.h>
#endif
#ifdef ANWI
#include "mld_anwi.h"
#endif
#ifdef JUNGO
#include "mld.h"
#endif
#ifdef LINUX
#include "mld_linux.h"
#endif
#ifdef LINUX
#include "linux_ansi.h"
#endif
#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__
#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"
#include "athreg.h"
#include "manlib.h" /* The Manufacturing Library */
#include "manlibInst.h" /* The Manufacturing Library Instrument Library extension */
#include "art_if.h"
#include "ar5210reg.h" /* AR5001 register definitions */
#include "pci.h" /* PCI Config Space definitions */
#include "art_ani.h"
#include "test.h"
#include "cmdTest.h"
#include "parse.h"
#include "dynamic_optimizations.h"
#include "maui_cal.h"
#ifndef __ATH_DJGPPDOS__
#include "MLIBif.h" /* Manufacturing Library low level driver support functions */
#include "dk_cmds.h"
#else
#include "mlibif_dos.h"
#endif
#ifdef LINUX
#include <unistd.h>
#endif
#define EEPROM_BLOCK_SIZE 256
#define OFDM_11G_IDX 20
#define CCK_11G_IDX 5
#define OFDM_CCK_DEF_IDX 0
#include "ear_externs.h"
extern A_UINT16 curr_pwr_index_offset;
extern GAIN_OPTIMIZATION_LADDER gainLadder;
extern GAIN_OPTIMIZATION_LADDER gainLadder_derby2;
extern GAIN_OPTIMIZATION_LADDER gainLadder_derby1;
GAIN_OPTIMIZATION_LADDER *pCurrGainLadder;
extern A_BOOL printLocalInfo;
// extern declarations for dut-golden sync
extern ART_SOCK_INFO *artSockInfo;
extern ART_SOCK_INFO *pArtPrimarySock;
extern ART_SOCK_INFO *pArtSecondarySock;
/* === Functional Declarations === */
static A_BOOL parseCmdLine(A_INT32 argc,A_CHAR *argv[]);
static void contMenu(A_UINT32 devNum);
static void contRxMenu(A_UINT32 devNum);
static void linkMenu(A_UINT32 devNum);
static void utilityMenu(A_UINT32 devNum);
static void changeDomain(A_UINT32 devNum);
static A_BOOL parseConfig(void);
static A_BOOL processCommonOptions( A_UINT32 devNum, A_INT16 inputKey);
static A_BOOL setRxGain(A_UINT32 devNum);
static A_BOOL setRxGain_11bg(A_UINT32 devNum);
static void setRegistersFromConfig(A_UINT32 devNum);
static void updateConfigFromRegValues(A_UINT32 devNum);
static A_BOOL initTest(A_UINT32 devNum);
static A_BOOL setupMode(void);
static void printDeviceInfo(A_UINT32 devNum);
void EEPROM_Routine(A_UINT32 devNum);
void Display_EEPROM_menu(void);
static A_UINT16 promptForCardType(A_UINT16 *pSubSystemID);
static void forcePowerOrPcdac(A_UINT32 devNum);
static A_BOOL parseCmdChannelList(A_CHAR *listString);
#ifndef __ATH_DJGPPDOS__
void progBlankEEPROM(A_UINT32 devNum);
A_BOOL setEepFile(A_UINT32 devNum);
A_BOOL addToCfgTable(A_UINT16 subSystemID,A_CHAR *pFilename, A_CHAR *pEarFilename);
#endif //__ATH_DJGPPDOS__
void printConfigSettings(A_UINT32 devNum);
A_BOOL supportMultiModes(SUPPORTED_MODES *pModes);
void throughputMenu(A_UINT32 devNum);
void getSupportedModes (A_UINT32 devNum, SUPPORTED_MODES *pModes);
A_UINT32 getNextMode (SUPPORTED_MODES *pModes);
A_UINT32 getFirstMode (SUPPORTED_MODES *pModes);
extern void topCalibrationEntry(A_UINT32 *pdevNum_inst1, A_UINT32 *pdevNum_inst2) ;
extern void displayDomain(A_UINT32 domain);
#ifdef __ATH_DJGPPDOS__
#define _makepath(path,drive,dir,name,ext)\
fnmerge(path,drive,dir,name,ext)
#endif
static A_UCHAR bssID[6] = {0x50, 0x55, 0x55, 0x55, 0x55, 0x05};
static A_UCHAR rxStation[6] = {0x10, 0x11, 0x11, 0x11, 0x11, 0x01}; // DUT
static A_UCHAR txStation[6] = {0x20, 0x22, 0x22, 0x22, 0x22, 0x02}; // Golden
// 1L 2L 2S 5.5L 5.5S 11L 11S
A_UCHAR DataRate[] = {6, 9, 12, 18, 24, 36, 48, 54, 0xb1, 0xb2, 0xd2, 0xb5, 0xd5, 0xbb, 0xdb,
// XR0.25 XR0.5 XR1 XR2 XR3
0xea, 0xeb, 0xe1, 0xe2, 0xe3};
const A_CHAR *DataRateStr[] = {" 6 Mbps", " 9 Mbps", "12 Mbps",
"18 Mbps", "24 Mbps", "36 Mbps", "48 Mbps", "54 Mbps",
"1 Mbps long", "2 Mbps long", "2 Mbps short",
"5.5 Mbps long", "5.5 Mbps short", "11 Mbps long", "11 Mbps short",
"XR 0.25 Mbps", "XR 0.5 Mbps", "XR 1 Mbps", "XR 2 Mbps", "XR 3 Mbps"};
const A_CHAR *DataRateStrTurbo[] = {" 12 Mbps", " 18 Mbps", "24 Mbps",
"36 Mbps", "48 Mbps", "72 Mbps", "96 Mbps", "108 Mbps",
"1 Mbps long", "2 Mbps long", "2 Mbps short",
"5.5 Mbps long", "5.5 Mbps short", "11 Mbps long", "11 Mbps short",
// "2 Mbps long", "4 Mbps long", "4 Mbps short",
// "11 Mbps long", "11 Mbps short", "22 Mbps long", "22 Mbps short",
"XR 0.5 Mbps", "XR 1 Mbps", "XR 2 Mbps", "XR 4 Mbps", "XR 6 Mbps"};
const A_CHAR *DataRateStrHalf[] = {" 3 Mbps", " 4.5 Mbps", "6 Mbps",
"9 Mbps", "12 Mbps", "18 Mbps", "24 Mbps", "27 Mbps",
"0.5 Mbps long", "1 Mbps long", "1 Mbps short",
"2.75 Mbps long", "2.75 Mbps short", "5.5 Mbps long", "5.5 Mbps short",
"XR 0.125 Mbps", "XR 0.25 Mbps", "XR 0.5 Mbps", "XR 1 Mbps", "XR 1.5 Mbps"};
const A_CHAR *DataRate_11b[] = {"1 Mbps long", "1 Mbps long",
"2 Mbps long", "2 Mbps short",
"5.5 Mbps long", "5.5 Mbps short",
"11 Mbps long", "11 Mbps short"};
A_UINT32 swDeviceID;
A_UINT32 hwDeviceID;
A_UINT32 subSystemID;
A_UINT32 macRev;
A_UINT32 bbRev;
A_UINT32 analogProdRev;
WLAN_MACADDR macAddr;
A_BOOL printLocalInfo;
A_BOOL progProm = 0;
A_UINT16 gainIMax = GAINI_MAX;
A_UINT16 gainIMin = GAINI_MIN;
//Arrays needed for calculating the rx gain
//static double antennaArr[] = {4.7, -6.3};
//static double rfvgaGaindBArr[] = {2.73, -9.15, 19.32, 18.57}; // [rfgain1,rfatten0]
//static double ifvgaGaindBArr[] = {-1.66, 2.42, 7.23, 11.9, 16.3, 16.3, 16.3, -6.09};
//static A_INT32 pga1GainArr[] = {0, 6, 12, 18};
//static A_INT32 pga2GainArr[] = {0, 6, 12, 18};
//static A_INT32 pga3GainArr[] = {0, 1, 2, 3, 4, 5};
//defaults for initial configuration, although a lot of these will be overwritten
//based on the contents of the external configuration file and the register file.
MLD_CONFIG configSetup =
{
4900, //channel
0, //eeprom load
0, //eeprom load override
0, //eeprom Header load
"", //create fez config file
"", //maui sombrero config file
"", //maui sombrero beanie config file
"", //oahu sombrero config file
"", //venice sombrero config file
NULL, //pointer to current config file
MAX_SOM_CHANNEL, //max channel 5G
MIN_CHANNEL, //min channel 5G
MAX_2G_CHANNEL, //Max channel 2G
MIN_2G_CHANNEL, //Min channel 2G
0, //power override on or off
0, //external power on or off
0, //xpdGainIndex
// 3, //xpdGainIndex2
0, //xpdGainIndex2
1, //applyXpdGain
0, //data rate index
6, //data rate index throughput
USE_REG_FILE, //pcdac value, initially use values in reg file
NO_PWR_CTL, //power control method. start with none.
1, //ob
1, //db
1, //b_ob
1, //b_db
1, //gainI
CONT_TX99, //continuous mode
USE_DESC_ANT | DESC_ANT_A, //antenna
PN9_PATTERN, //data pattern
0, //turbo
USE_REG_FILE, //rxGain
0, //rf_gainBoost
0, //overwriteRxGain
0, //remote
".", //machname
1, //instance
0, //user instance override
1, //validInstance
MODE_11A, //mode
0, //use_init
5360, //channel5
2412, //channel2_4
USE_REG_FILE, //power output
USE_REG_FILE, //rxGain 5GHz
USE_REG_FILE, //rxGain 2.4GHz
1, //packet interleave
0, //logging
"", //log file
0x0000, // dut SSID. an illegal value as default.
// "BLANK", //dut card type
// "BLANK", //cmd line dut card type
0, //don't open all 2GHz channels
0xff, //rate mask
"", //eep File Directory
0, //cfg table num elements
NULL, //cfg table ptr current
NULL, //cfg table ptr elements
0, //blank eep subsystemID
0, //cmd line subsystemID
0, //cmd line subsystemID
1500, //packet size for throughput
MIN_NUM_RETRIES, //num retries for throughput
MAX_NUM_PKTS, //num packets for throughput
0, //use unicast packets for throughput
0, //init primary ART to not AP
1, //enablePrint
0, //num slots
0, //eeprom contains valid calibration data
0, // use target powers
FALSE, //cmd line Test
0, //cmd line test mask
NULL, //test channel list
0, //Num test channels
ANTENNA_A_MASK, //antenna Mask
ANTENNA_A_MASK, //gold antenna mask
0, //iterations
"", //beacon bssid
0, //range Logging
"", //range Logfile
1000, //link packet size
100, //link num packets
REF_CLK_DYNAMIC, //default refClock
0, //beanie2928Mode
5, //5gChannelStep size
0, //enable XR
0, //load ear
0, //eep file version
0, //ear file version
0, //ear file identifier <filename_1.ear ==> 1>
DO_OFSET_CAL | DO_NF_CAL, //hw calibration
// ART_ANI_ENABLED, //ART ANI enabled by default
ART_ANI_DISABLED, //ART ANI disabled initially
ART_ANI_REUSE_ON, //ART ANI levels reuse on by default
{0,0,0}, //ART ANI levels
100, // max RX gain
0, // min RX gain
FALSE // userDutIdOverride
};
//#ifndef __ATH_DJGPPDOS__
ART_SOCK_INFO *artSockInfo = NULL;
ART_SOCK_INFO *pArtPrimarySock = NULL;
ART_SOCK_INFO *pArtSecondarySock = NULL;
//#else
//void *artSockInfo = NULL;
//#endif
static RX_GAIN_REGS_11bg rxGainValues_11bg[] =
{
#include "AR5111_rx_gain_2ghz.tbl"
} ;
static RX_GAIN_REGS rxGainValues[] =
{
#include "AR5111_rx_gain_5ghz.tbl"
};
static RX_GAIN_REGS_AR5112 rxGainValues_derby[] =
{
#include "AR5112_rx_gain_5ghz.tbl"
};
static RX_GAIN_REGS_AR5112 rxGainValues_derby_11bg[] =
{
#include "AR5112_rx_gain_2ghz.tbl"
};
static XPD_GAIN_INFO xpdGainValues[] =
{
18, 7,
12, 11,
6, 13,
0, 14
};
static XPD_GAIN_INFO xpdGainValues_derby[] =
{
18, 3,
12, 2,
6, 1,
0, 0
};
XPD_GAIN_INFO *gainValues;
static char delimiters[] = " \t";
main(int argc,char *argv[]) {
A_BOOL exitLoop = FALSE;
A_INT32 tempDevNum;
A_UINT32 devNum=0;
A_UINT32 devNum_2g=0;
A_UINT32 devNum_5g=0;
SUPPORTED_MODES supportedModes;
A_CHAR commentBuffer[MAX_SIZE_COMMENT_BUFFER] = {'a', 'b', 'c'};
A_UINT32 tempBackoff[3];
SUB_DEV_INFO devStruct;
if (parseCmdLine(argc,argv) == FALSE) {
uiPrintf("main: Failed to parse command line arguments \n");
exit (0);
}
if(initializeEnvironment(configSetup.remote) == FALSE) {
uiPrintf("main: Failed to initialize the Driver Environment\n");
exit(0);
}
//set the printLocalInfo flag dependent on whether already printed by lib
//or if have a remove client
printLocalInfo = 0;
#ifdef NO_LIB_PRINT
printLocalInfo = 1;
#endif
if(configSetup.remote) {
printLocalInfo = 1;
}
#ifndef CUSTOMER_REL
uiPrintf("Using %d card \n",configSetup.instance);
#endif
if(!parseConfig()) {
uiPrintf("Problem parsing %s, exiting...\n", CONFIGSETUP_FILE);
exit(0);
}
tempDevNum = art_setupDevice(configSetup.instance);
if(tempDevNum < 0) {
uiPrintf("main: Error attaching to the device - ending test\n");
closeEnvironment();
exit(0);
}
devNum = tempDevNum;
art_configureLibParams(devNum);
art_resetDevice(devNum, txStation, bssID, configSetup.channel, configSetup.turbo);
uiPrintf("Attached to the Device\n");
//get the deviceID from the library and use the swDevID
art_getDeviceInfo(devNum, &devStruct);
swDeviceID = devStruct.swDevID;
hwDeviceID = devStruct.hwDevID;
#ifndef __ATH_DJGPPDOS__
if(!setEepFile(devNum)) {
closeEnvironment();
exit(0);
}
parseSetup(devNum);
if (configSetup.instance == CalSetup.instanceForMode[MODE_11a]) {
devNum_5g = devNum;
}
if (configSetup.instance == CalSetup.instanceForMode[MODE_11g]) {
devNum_2g = devNum;
}
if((configSetup.instance != CalSetup.instanceForMode[MODE_11a]) &&
(configSetup.instance != CalSetup.instanceForMode[MODE_11g]))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -