⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 card.c

📁 VIA VT6656 USB linux source code.
💻 C
📖 第 1 页 / 共 3 页
字号:
/* * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * * This software is copyrighted by and is the sole property of * VIA Networking Technologies, Inc. This software may only be used * in accordance with the corresponding license agreement. Any unauthorized * use, duplication, transmission, distribution, or disclosure of this * software is expressly forbidden. * * This software is provided by VIA Networking Technologies, Inc. "as is" * and any express or implied warranties, including, but not limited to, the * implied warranties of merchantability and fitness for a particular purpose * are disclaimed. In no event shall VIA Networking Technologies, Inc. * be liable for any direct, indirect, incidental, special, exemplary, or * consequential damages.  * * File: card.c * Purpose: Provide functions to setup NIC operation mode  * Functions: *      s_vSafeResetTx - Rest Tx *      CARDvSetRSPINF - Set RSPINF *      vUpdateIFS - Update slotTime,SIFS,DIFS, and EIFS *      CARDvUpdateBasicTopRate - Update BasicTopRate *      CARDbAddBasicRate - Add to BasicRateSet *      CARDbSetBasicRate - Set Basic Tx Rate *      CARDbIsOFDMinBasicRate - Check if any OFDM rate is in BasicRateSet *      CARDvSetLoopbackMode - Set Loopback mode *      CARDbSoftwareReset - Sortware reset NIC *      CARDqGetTSFOffset - Caculate TSFOffset *      CARDbGetCurrentTSF - Read Current NIC TSF counter *      CARDqGetNextTBTT - Caculate Next Beacon TSF counter *      CARDvSetFirstNextTBTT - Set NIC Beacon time *      CARDvUpdateNextTBTT - Sync. NIC Beacon time *      CARDbRadioPowerOff - Turn Off NIC Radio Power *      CARDbRadioPowerOn - Turn On NIC Radio Power *      CARDbSetWEPMode - Set NIC Wep mode *      CARDbSetTxPower - Set NIC tx power * * Revision History: *      06-10-2003 Bryan YC Fan:  Re-write codes to support VT3253 spec. *      08-26-2003 Kyle Hsu:      Modify the defination type of dwIoBase. *      09-01-2003 Bryan YC Fan:  Add vUpdateIFS().  * */#if !defined(__TMACRO_H__)#include "tmacro.h"#endif#if !defined(__CARD_H__)#include "card.h"#endif#if !defined(__TBIT_H__)#include "tbit.h"#endif#if !defined(__BASEBAND_H__)#include "baseband.h"#endif#if !defined(__MAC_H__)#include "mac.h"#endif#if !defined(__DESC_H__)#include "desc.h"#endif#if !defined(__RF_H__)#include "rf.h"#endif#if !defined(__POWER_H__)#include "power.h"#endif#if !defined(__KEY_H__)#include "key.h"#endif#if !defined(__RC4_H__)#include "rc4.h"#endif#if !defined(__COUNTRY_H__)#include "country.h"#endif#if !defined(__UMEM_H__)#include "umem.h"#endif#if !defined(__DATARATE_H__)#include "datarate.h"#endif#if !defined(__RNDIS_H__)#include "rndis.h"#endif#if !defined(__CONTROL_H__)#include "control.h"#endif/*---------------------  Static Definitions -------------------------*///static int          msglevel                =MSG_LEVEL_DEBUG;static int          msglevel                =MSG_LEVEL_INFO;/*---------------------  Static Definitions -------------------------*/#define CB_TXPOWER_LEVEL            6/*---------------------  Static Classes  ----------------------------*//*---------------------  Static Variables  --------------------------*///const WORD cwRXBCNTSFOff[MAX_RATE] =//{17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3};const WORD cwRXBCNTSFOff[MAX_RATE] ={192, 96, 34, 17, 34, 23, 17, 11, 8, 5, 4, 3};/*---------------------  Static Functions  --------------------------*//*---------------------  Export Variables  --------------------------*//*---------------------  Export Functions  --------------------------*//* * Description: Set NIC media channel * * Parameters: *  In: *      pDevice             - The adapter to be set *      uConnectionChannel  - Channel to be set *  Out: *      none * * Return Value: TRUE if succeeded; FALSE if failed. * */BOOL CARDbSetMediaChannel (PVOID pDeviceHandler, UINT uConnectionChannel){PSDevice            pDevice = (PSDevice) pDeviceHandler;    BOOL                bResult = TRUE;        if (pDevice->byBBType == BB_TYPE_11A) { // 15 ~ 38        if ((uConnectionChannel < (CB_MAX_CHANNEL_24G+1)) || (uConnectionChannel > CB_MAX_CHANNEL))            uConnectionChannel = (CB_MAX_CHANNEL_24G+1);    } else {        if ((uConnectionChannel > CB_MAX_CHANNEL_24G) || (uConnectionChannel == 0)) // 1 ~ 14            uConnectionChannel = 1;    }        // clear NAV    MACvRegBitsOn(pDevice, MAC_REG_MACCR, MACCR_CLRNAV);        // Set Channel[7] = 0 to tell H/W channel is changing now.    MACvRegBitsOff(pDevice, MAC_REG_CHANNEL, 0x80);    //if (pMgmt->uCurrChannel == uConnectionChannel)    //    return bResult;    CONTROLnsRequestOut(pDevice,                        MESSAGE_TYPE_SELECT_CHANNLE,                        (WORD) uConnectionChannel,                        0,                        0,                        NULL                        );                                            //{{ RobertYu: 20041202    //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput        if (pDevice->byBBType == BB_TYPE_11A) {        pDevice->byCurPwr = 0xFF;        RFbRawSetPower(pDevice, pDevice->abyOFDMAPwrTbl[uConnectionChannel-15], RATE_54M);    } else if (pDevice->byBBType == BB_TYPE_11G) {        pDevice->byCurPwr = 0xFF;        RFbRawSetPower(pDevice, pDevice->abyOFDMPwrTbl[uConnectionChannel-1], RATE_54M);    } else {        pDevice->byCurPwr = 0xFF;        RFbRawSetPower(pDevice, pDevice->abyCCKPwrTbl[uConnectionChannel-1], RATE_1M);    }    ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_CHANNEL,(BYTE)(uConnectionChannel|0x80));    return(bResult);}/* * Description: Get CCK mode basic rate * * Parameters: *  In: *      pDevice             - The adapter to be set *      wRateIdx            - Receiving data rate *  Out: *      none * * Return Value: response Control frame rate * */staticWORD swGetCCKControlRate(PVOID pDeviceHandler, WORD wRateIdx){    PSDevice    pDevice = (PSDevice) pDeviceHandler;        UINT ui = (UINT)wRateIdx;    while (ui > RATE_1M) {        if (pDevice->wBasicRate & ((WORD)1 << ui)) {            return (WORD)ui;        }        ui --;    }    return (WORD)RATE_1M;}/* * Description: Get OFDM mode basic rate * * Parameters: *  In: *      pDevice             - The adapter to be set *      wRateIdx            - Receiving data rate *  Out: *      none * * Return Value: response Control frame rate * */staticWORD swGetOFDMControlRate (PVOID pDeviceHandler, WORD wRateIdx){    PSDevice    pDevice = (PSDevice) pDeviceHandler;        UINT ui = (UINT)wRateIdx;    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n", pDevice->wBasicRate);    if (!CARDbIsOFDMinBasicRate(pDevice)) {        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx);        if (wRateIdx > RATE_24M)            wRateIdx = RATE_24M;        return wRateIdx;    }    while (ui > RATE_11M) {        if (pDevice->wBasicRate & ((WORD)1 << ui)) {            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate : %d\n", ui);            return (WORD)ui;        }        ui --;    }    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate: 6M\n");    return (WORD)RATE_24M;}/* * Description: Caculate TxRate and RsvTime fields for RSPINF in OFDM mode. * * Parameters: *  In: *      wRate           - Tx Rate *      byPktType       - Tx Packet type *  Out: *      pbyTxRate       - pointer to RSPINF TxRate field *      pbyRsvTime      - pointer to RSPINF RsvTime field * * Return Value: none * */VOIDCARDvCaculateOFDMRParameter (    IN  WORD wRate,    IN  BYTE byBBType,    OUT PBYTE pbyTxRate,    OUT PBYTE pbyRsvTime    ){    switch (wRate) {    case RATE_6M :        if (byBBType == BB_TYPE_11A) {//5GHZ            *pbyTxRate = 0x9B;            *pbyRsvTime = 24;        }        else {            *pbyTxRate = 0x8B;            *pbyRsvTime = 30;        }        break;    case RATE_9M :        if (byBBType == BB_TYPE_11A) {//5GHZ            *pbyTxRate = 0x9F;            *pbyRsvTime = 16;        }        else {            *pbyTxRate = 0x8F;            *pbyRsvTime = 22;        }        break;   case RATE_12M :        if (byBBType == BB_TYPE_11A) {//5GHZ            *pbyTxRate = 0x9A;            *pbyRsvTime = 12;        }        else {            *pbyTxRate = 0x8A;            *pbyRsvTime = 18;        }        break;   case RATE_18M :        if (byBBType == BB_TYPE_11A) {//5GHZ            *pbyTxRate = 0x9E;            *pbyRsvTime = 8;        }        else {            *pbyTxRate = 0x8E;            *pbyRsvTime = 14;        }        break;    case RATE_36M :        if (byBBType == BB_TYPE_11A) {//5GHZ            *pbyTxRate = 0x9D;            *pbyRsvTime = 4;        }        else {            *pbyTxRate = 0x8D;            *pbyRsvTime = 10;        }        break;    case RATE_48M :        if (byBBType == BB_TYPE_11A) {//5GHZ            *pbyTxRate = 0x98;            *pbyRsvTime = 4;        }        else {            *pbyTxRate = 0x88;            *pbyRsvTime = 10;        }        break;    case RATE_54M :        if (byBBType == BB_TYPE_11A) {//5GHZ            *pbyTxRate = 0x9C;            *pbyRsvTime = 4;        }        else {            *pbyTxRate = 0x8C;            *pbyRsvTime = 10;        }        break;    case RATE_24M :    default :        if (byBBType == BB_TYPE_11A) {//5GHZ            *pbyTxRate = 0x99;            *pbyRsvTime = 8;        }        else {            *pbyTxRate = 0x89;            *pbyRsvTime = 14;        }        break;    }}/* * Description: Set RSPINF * * Parameters: *  In: *      pDevice             - The adapter to be set *  Out: *      none * * Return Value: None. * */void CARDvSetRSPINF (PVOID pDeviceHandler, BYTE byBBType){    PSDevice    pDevice = (PSDevice) pDeviceHandler;        BYTE    abyServ[4] = {0,0,0,0};             // For CCK    BYTE    abySignal[4] = {0,0,0,0};    WORD    awLen[4] = {0,0,0,0};    BYTE    abyTxRate[9] = {0,0,0,0,0,0,0,0,0}; // For OFDM    BYTE    abyRsvTime[9] = {0,0,0,0,0,0,0,0,0};    BYTE    abyData[34];    int     i;    //RSPINF_b_1    BBvCaculateParameter(pDevice,                         14,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -