Commit 66101de1 authored by Pavel Machek's avatar Pavel Machek Committed by Greg Kroah-Hartman

Staging: add w35und wifi driver

This is driver for w35und usb wifi -- also in kohjinsha
subnotebook. It should work well enough to associate and ping, but it
obviously needs to be rewritten two more times...

OTOH worst horrors (like embedded wifi stack) should have been fixed
already...
Signed-off-by: default avatarPavel Machek <pavel@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 4d7b5c7f
...@@ -35,4 +35,6 @@ source "drivers/staging/go7007/Kconfig" ...@@ -35,4 +35,6 @@ source "drivers/staging/go7007/Kconfig"
source "drivers/staging/usbip/Kconfig" source "drivers/staging/usbip/Kconfig"
source "drivers/staging/winbond/Kconfig"
endif # STAGING endif # STAGING
...@@ -6,3 +6,4 @@ obj-$(CONFIG_SXG) += sxg/ ...@@ -6,3 +6,4 @@ obj-$(CONFIG_SXG) += sxg/
obj-$(CONFIG_ME4000) += me4000/ obj-$(CONFIG_ME4000) += me4000/
obj-$(CONFIG_VIDEO_GO7007) += go7007/ obj-$(CONFIG_VIDEO_GO7007) += go7007/
obj-$(CONFIG_USB_IP_COMMON) += usbip/ obj-$(CONFIG_USB_IP_COMMON) += usbip/
obj-$(CONFIG_W35UND) += winbond/
config W35UND
tristate "Winbond driver"
depends on MAC80211 && WLAN_80211 && EXPERIMENTAL && !4KSTACKS
default n
---help---
This is highly experimental driver for winbond wifi card on some Kohjinsha notebooks
Check http://code.google.com/p/winbondport/ for new version
DRIVER_DIR=./linux
w35und-objs := $(DRIVER_DIR)/wbusb.o $(DRIVER_DIR)/wb35reg.o $(DRIVER_DIR)/wb35rx.o $(DRIVER_DIR)/wb35tx.o \
mds.o \
mlmetxrx.o \
mto.o \
phy_calibration.o \
reg.o \
rxisr.o \
sme_api.o \
wbhal.o \
wblinux.o \
obj-$(CONFIG_W35UND) += w35und.o
TODO:
- sparse cleanups
- checkpatch cleanups
- kerneldoc cleanups
- remove typedefs
- remove unused ioctls
- use cfg80211 for regulatory stuff
Please send patches to Greg Kroah-Hartman <greg@kroah.com> and
Pavel Machek <pavel@suse.cz>
//
// ADAPTER.H -
// Windows NDIS global variable 'Adapter' typedef
//
#define MAX_ANSI_STRING 40
typedef struct WB32_ADAPTER
{
u32 AdapterIndex; // 20060703.4 Add for using pAdapterContext global Adapter point
WB_LOCALDESCRIPT sLocalPara; // Myself connected parameters
PWB_BSSDESCRIPTION asBSSDescriptElement;
MLME_FRAME sMlmeFrame; // connect to peerSTA parameters
MTO_PARAMETERS sMtoPara; // MTO_struct ...
hw_data_t sHwData; //For HAL
MDS Mds;
WBLINUX WbLinux;
struct iw_statistics iw_stats;
u8 LinkName[MAX_ANSI_STRING];
} WB32_ADAPTER, ADAPTER, *PWB32_ADAPTER, *PADAPTER;
//
// BSS descriptor DataBase management global function
//
void vBSSdescriptionInit(PWB32_ADAPTER Adapter);
void vBSSfoundList(PWB32_ADAPTER Adapter);
u8 boChanFilter(PWB32_ADAPTER Adapter, u8 ChanNo);
u16 wBSSallocateEntry(PWB32_ADAPTER Adapter);
u16 wBSSGetEntry(PWB32_ADAPTER Adapter);
void vSimpleHouseKeeping(PWB32_ADAPTER Adapter);
u16 wBSShouseKeeping(PWB32_ADAPTER Adapter);
void ClearBSSdescpt(PWB32_ADAPTER Adapter, u16 i);
u16 wBSSfindBssID(PWB32_ADAPTER Adapter, u8 *pbBssid);
u16 wBSSfindDedicateCandidate(PWB32_ADAPTER Adapter, struct SSID_Element *psSsid, u8 *pbBssid);
u16 wBSSfindMACaddr(PWB32_ADAPTER Adapter, u8 *pbMacAddr);
u16 wBSSsearchMACaddr(PWB32_ADAPTER Adapter, u8 *pbMacAddr, u8 band);
u16 wBSSaddScanData(PWB32_ADAPTER, u16, psRXDATA);
u16 wBSSUpdateScanData(PWB32_ADAPTER Adapter, u16 wBssIdx, psRXDATA psRcvData);
u16 wBSScreateIBSSdata(PWB32_ADAPTER Adapter, PWB_BSSDESCRIPTION psDesData);
void DesiredRate2BSSdescriptor(PWB32_ADAPTER Adapter, PWB_BSSDESCRIPTION psDesData,
u8 *pBasicRateSet, u8 BasicRateCount,
u8 *pOperationRateSet, u8 OperationRateCount);
void DesiredRate2InfoElement(PWB32_ADAPTER Adapter, u8 *addr, u16 *iFildOffset,
u8 *pBasicRateSet, u8 BasicRateCount,
u8 *pOperationRateSet, u8 OperationRateCount);
void BSSAddIBSSdata(PWB32_ADAPTER Adapter, PWB_BSSDESCRIPTION psDesData);
unsigned char boCmpMacAddr( PUCHAR, PUCHAR );
unsigned char boCmpSSID(struct SSID_Element *psSSID1, struct SSID_Element *psSSID2);
u16 wBSSfindSSID(PWB32_ADAPTER Adapter, struct SSID_Element *psSsid);
u16 wRoamingQuery(PWB32_ADAPTER Adapter);
void vRateToBitmap(PWB32_ADAPTER Adapter, u16 index);
u8 bRateToBitmapIndex(PWB32_ADAPTER Adapter, u8 bRate);
u8 bBitmapToRate(u8 i);
unsigned char boIsERPsta(PWB32_ADAPTER Adapter, u16 i);
unsigned char boCheckConnect(PWB32_ADAPTER Adapter);
unsigned char boCheckSignal(PWB32_ADAPTER Adapter);
void AddIBSSIe(PWB32_ADAPTER Adapter,PWB_BSSDESCRIPTION psDesData );//added by ws for WPA_None06/01/04
void BssScanUpToDate(PWB32_ADAPTER Adapter);
void BssUpToDate(PWB32_ADAPTER Adapter);
void RateSort(u8 *RateArray, u8 num, u8 mode);
void RateReSortForSRate(PWB32_ADAPTER Adapter, u8 *RateArray, u8 num);
void Assemble_IE(PWB32_ADAPTER Adapter, u16 wBssIdx);
void SetMaxTxRate(PWB32_ADAPTER Adapter);
void CreateWpaIE(PWB32_ADAPTER Adapter, u16* iFildOffset, PUCHAR msg, struct Management_Frame* msgHeader,
struct Association_Request_Frame_Body* msgBody, u16 iMSindex); //added by WS 05/14/05
#ifdef _WPA2_
void CreateRsnIE(PWB32_ADAPTER Adapter, u16* iFildOffset, PUCHAR msg, struct Management_Frame* msgHeader,
struct Association_Request_Frame_Body* msgBody, u16 iMSindex);//added by WS 05/14/05
u16 SearchPmkid(PWB32_ADAPTER Adapter, struct Management_Frame* msgHeader,
struct PMKID_Information_Element * AssoReq_PMKID );
#endif
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// bssdscpt.c
// BSS descriptor data base
// history :
//
// Description:
// BSS descriptor data base will store the information of the stations at the
// surrounding environment. The first entry( psBSS(0) ) will not be used and the
// second one( psBSS(1) ) will be used for the broadcast address.
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//#define MAX_ACC_RSSI_COUNT 10
#define MAX_ACC_RSSI_COUNT 6
///////////////////////////////////////////////////////////////////////////
//
// BSS Description set Element , to store scan received Beacon information
//
// Our's differs slightly from the specs. The specify a PHY_Parameter_Set.
// Since we're only doing a DS design right now, we just have a DS structure.
//////////////////////////////////////////////////////////////////////////////
typedef struct BSSDescriptionElement
{
u32 SlotValid;
u32 PowerSaveMode;
RXLAYER1 RxLayer1;
u8 abPeerAddress[ MAC_ADDR_LENGTH + 2 ]; // peer MAC Address associated with this session. 6-OCTET value
u32 dwBgScanStamp; // BgScan Sequence Counter stamp, record psROAM->dwScanCounter.
u16 Beacon_Period;
u16 wATIM_Window;
u8 abBssID[ MAC_ADDR_LENGTH + 2 ]; // 6B
u8 bBssType;
u8 DTIM_Period; // 1 octet usually from TIM element, if present
u8 boInTimerHandler;
u8 boERP; // analysis ERP or (extended) supported rate element
u8 Timestamp[8];
u8 BasicRate[32];
u8 OperationalRate[32];
u32 dwBasicRateBitmap; //bit map, retrieve from SupportedRateSet
u32 dwOperationalRateBitmap; //bit map, retrieve from SupportedRateSet and
// ExtendedSupportedRateSet
// For RSSI calculating
u32 HalRssi[MAX_ACC_RSSI_COUNT]; // Encode. It must use MACRO of HAL to get the LNA and AGC data
u32 HalRssiIndex;
////From beacon/probe response
struct SSID_Element SSID; // 34B
u8 reserved_1[ 2 ];
struct Capability_Information_Element CapabilityInformation; // 2B
u8 reserved_2[ 2 ];
struct CF_Parameter_Set_Element CF_Parameter_Set; // 8B
struct IBSS_Parameter_Set_Element IBSS_Parameter_Set; // 4B
struct TIM_Element TIM_Element_Set; // 256B
struct DS_Parameter_Set_Element DS_Parameter_Set; // 3B
u8 reserved_3;
struct ERP_Information_Element ERP_Information_Set; // 3B
u8 reserved_4;
struct Supported_Rates_Element SupportedRateSet; // 10B
u8 reserved_5[2];
struct Extended_Supported_Rates_Element ExtendedSupportedRateSet; // 257B
u8 reserved_6[3];
u8 band;
u8 reserved_7[3];
// for MLME module
u16 wState; // the current state of the system
u16 wIndex; // THIS BSS element entry index
void* psAdapter; // pointer to THIS Adapter
OS_TIMER nTimer; // MLME timer
// Authentication
u16 wAuthAlgo; // peer MAC MLME use Auth algorithm, default OPEN_AUTH
u16 wAuthSeqNum; // current local MAC sendout AuthReq sequence number
u8 auth_challengeText[128];
////For XP:
u32 ies_len; // information element length
u8 ies[256]; // information element
////For WPA
u8 RsnIe_Type[2]; //added by ws for distinguish WPA and WPA2 05/14/04
u8 RsnIe_len;
u8 Rsn_Num;
// to record the rsn cipher suites,addded by ws 09/05/04
SUITE_SELECTOR group_cipher; // 4B
SUITE_SELECTOR pairwise_key_cipher_suites[WLAN_MAX_PAIRWISE_CIPHER_SUITE_COUNT];
SUITE_SELECTOR auth_key_mgt_suites[WLAN_MAX_AUTH_KEY_MGT_SUITE_LIST_COUNT];
u16 pairwise_key_cipher_suite_count;
u16 auth_key_mgt_suite_count;
u8 pairwise_key_cipher_suite_selected;
u8 auth_key_mgt_suite_selected;
u8 reserved_8[2];
struct RSN_Capability_Element rsn_capabilities; // 2B
u8 reserved_9[2];
//to record the rsn cipher suites for WPA2
#ifdef _WPA2_
u32 pre_auth; //added by WS for distinguish for 05/04/04
SUITE_SELECTOR wpa2_group_cipher; // 4B
SUITE_SELECTOR wpa2_pairwise_key_cipher_suites[WLAN_MAX_PAIRWISE_CIPHER_SUITE_COUNT];
SUITE_SELECTOR wpa2_auth_key_mgt_suites[WLAN_MAX_AUTH_KEY_MGT_SUITE_LIST_COUNT];
u16 wpa2_pairwise_key_cipher_suite_count;
u16 wpa2_auth_key_mgt_suite_count;
u8 wpa2_pairwise_key_cipher_suite_selected;
u8 wpa2_auth_key_mgt_suite_selected;
u8 reserved_10[2];
struct RSN_Capability_Element wpa2_rsn_capabilities; // 2B
u8 reserved_11[2];
#endif //endif _WPA2_
//For Replay protection
// u8 PairwiseTSC[6];
// u8 GroupTSC[6];
////For up-to-date
u32 ScanTimeStamp; //for the decision whether the station/AP(may exist at
//different channels) has left. It must be detected by
//scanning. Local device may connected or disconnected.
u32 BssTimeStamp; //Only for the decision whether the station/AP(exist in
//the same channel, and no scanning) if local device has
//connected successfully.
// 20061108 Add for storing WPS_IE. [E id][Length][OUI][Data]
u8 WPS_IE_Data[MAX_IE_APPEND_SIZE];
u16 WPS_IE_length;
u16 WPS_IE_length_tmp; // For verify there is an WPS_IE in Beacon or probe response
} WB_BSSDESCRIPTION, *PWB_BSSDESCRIPTION;
#define wBSSConnectedSTA(Adapter) \
((u16)(Adapter)->sLocalPara.wConnectedSTAindex)
#define psBSS(i) (&(Adapter->asBSSDescriptElement[(i)]))
// Rotation functions on 32 bit values
#define ROL32( A, n ) \
( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) )
#define ROR32( A, n ) ROL32( (A), 32-(n) )
typedef struct tkip
{
u32 K0, K1; // Key
union
{
struct // Current state
{
u32 L;
u32 R;
};
u8 LR[8];
};
union
{
u32 M; // Message accumulator (single word)
u8 Mb[4];
};
s32 bytes_in_M; // # bytes in M
} tkip_t;
//void _append_data( PUCHAR pData, u16 size, tkip_t *p );
void Mds_MicGet( void* Adapter, void* pRxLayer1, PUCHAR pKey, PUCHAR pMic );
void Mds_MicFill( void* Adapter, void* pDes, PUCHAR XmitBufAddress );
#ifndef __GL_80211_H__
#define __GL_80211_H__
/****************** CONSTANT AND MACRO SECTION ******************************/
/* BSS Type */
enum {
WLAN_BSSTYPE_INFRASTRUCTURE = 0,
WLAN_BSSTYPE_INDEPENDENT,
WLAN_BSSTYPE_ANY_BSS,
};
/* Preamble_Type, see <SFS-802.11G-MIB-203> */
typedef enum preamble_type {
WLAN_PREAMBLE_TYPE_SHORT,
WLAN_PREAMBLE_TYPE_LONG,
} preamble_type_e;
/* Slot_Time_Type, see <SFS-802.11G-MIB-208> */
typedef enum slot_time_type {
WLAN_SLOT_TIME_TYPE_LONG,
WLAN_SLOT_TIME_TYPE_SHORT,
} slot_time_type_e;
/*--------------------------------------------------------------------------*/
/* Encryption Mode */
typedef enum {
WEP_DISABLE = 0,
WEP_64,
WEP_128,
ENCRYPT_DISABLE,
ENCRYPT_WEP,
ENCRYPT_WEP_NOKEY,
ENCRYPT_TKIP,
ENCRYPT_TKIP_NOKEY,
ENCRYPT_CCMP,
ENCRYPT_CCMP_NOKEY,
} encryption_mode_e;
typedef enum _WLAN_RADIO {
WLAN_RADIO_ON,
WLAN_RADIO_OFF,
WLAN_RADIO_MAX, // not a real type, defined as an upper bound
} WLAN_RADIO;
typedef struct _WLAN_RADIO_STATUS {
WLAN_RADIO HWStatus;
WLAN_RADIO SWStatus;
} WLAN_RADIO_STATUS;
//----------------------------------------------------------------------------
// 20041021 1.1.81.1000 ybjiang
// add for radio notification
typedef
void (*RADIO_NOTIFICATION_HANDLER)(
void *Data,
void *RadioStatusBuffer,
u32 RadioStatusBufferLen
);
typedef struct _WLAN_RADIO_NOTIFICATION
{
RADIO_NOTIFICATION_HANDLER RadioChangeHandler;
void *Data;
} WLAN_RADIO_NOTIFICATION;
//----------------------------------------------------------------------------
// 20041102 1.1.91.1000 ybjiang
// add for OID_802_11_CUST_REGION_CAPABILITIES and OID_802_11_OID_REGION
typedef enum _WLAN_REGION_CODE
{
WLAN_REGION_UNKNOWN,
WLAN_REGION_EUROPE,
WLAN_REGION_JAPAN,
WLAN_REGION_USA,
WLAN_REGION_FRANCE,
WLAN_REGION_SPAIN,
WLAN_REGION_ISRAEL,
WLAN_REGION_MAX, // not a real type, defined as an upper bound
} WLAN_REGION_CODE;
#define REGION_NAME_MAX_LENGTH 256
typedef struct _WLAN_REGION_CHANNELS
{
u32 Length;
u32 NameLength;
u8 Name[REGION_NAME_MAX_LENGTH];
WLAN_REGION_CODE Code;
u32 Frequency[1];
} WLAN_REGION_CHANNELS;
typedef struct _WLAN_REGION_CAPABILITIES
{
u32 NumberOfItems;
WLAN_REGION_CHANNELS Region[1];
} WLAN_REGION_CAPABILITIES;
typedef struct _region_name_map {
WLAN_REGION_CODE region;
u8 *name;
u32 *channels;
} region_name_map;
/*--------------------------------------------------------------------------*/
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
#define MACSTR "%02X:%02X:%02X:%02X:%02X:%02X"
// TODO: 0627 kevin
#define MIC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5], (a)[6], (a)[7]
#define MICSTR "%02X %02X %02X %02X %02X %02X %02X %02X"
#define MICKEY2STR(a) MIC2STR(a)
#define MICKEYSTR MICSTR
#endif /* __GL_80211_H__ */
/*** end of file ***/
This diff is collapsed.
//
// common.h
//
// This file contains the OS dependant definition and function.
// Every OS has this file individual.
//
#define DebugUsbdStatusInformation( _A )
#ifndef COMMON_DEF
#define COMMON_DEF
#include <linux/version.h>
#include <linux/usb.h>
#include <linux/kernel.h> //need for kernel alert
#include <linux/autoconf.h>
#include <linux/sched.h>
#include <linux/signal.h>
#include <linux/slab.h> //memory allocate
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/init.h>//need for init and exit modules marco
#include <linux/ctype.h>
#include <linux/wait.h>
#include <linux/list.h>
#include <linux/wireless.h>
#include <linux/if_arp.h>
#include <asm/uaccess.h>
#include <net/iw_handler.h>
#include <linux/skbuff.h>
//#define DEBUG_ENABLED 1
//===============================================================
// Common type definition
//===============================================================
typedef u8* PUCHAR;
typedef s8* PCHAR;
typedef u8* PBOOLEAN;
typedef u16* PUSHORT;
typedef u32* PULONG;
typedef s16* PSHORT;
//===========================================
#define IGNORE 2
#define SUCCESS 1
#define FAILURE 0
#ifndef true
#define true 1
#endif
#ifndef false
#define false 0
#endif
// PD43 20021108
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#define STATUS_MEDIA_CONNECT 1
#define STATUS_MEDIA_DISCONNECT 0
#ifndef BIT
#define BIT(x) (1 << (x))
#endif
typedef struct urb * PURB;
//==================================================================================================
// Common function definition
//==================================================================================================
#ifndef abs
#define abs(_T) ((_T) < 0 ? -_T : _T)
#endif
#define DEBUG_ENABLED
#define ETH_LENGTH_OF_ADDRESS 6
#ifdef DEBUG_ENABLED
#define WBDEBUG( _M ) printk _M
#else
#define WBDEBUG( _M ) 0
#endif
#define OS_DISCONNECTED 0
#define OS_CONNECTED 1
#define OS_EVENT_INDICATE( _A, _B, _F )
#define OS_PMKID_STATUS_EVENT( _A )
/* Uff, no, longs are not atomic on all architectures Linux
* supports. This should really use atomic_t */
#define OS_ATOMIC u32
#define OS_ATOMIC_READ( _A, _V ) _V
#define OS_ATOMIC_INC( _A, _V ) EncapAtomicInc( _A, (void*)_V )
#define OS_ATOMIC_DEC( _A, _V ) EncapAtomicDec( _A, (void*)_V )
#define OS_MEMORY_CLEAR( _A, _S ) memset( (PUCHAR)_A,0,_S)
#define OS_MEMORY_COMPARE( _A, _B, _S ) (memcmp(_A,_B,_S)? 0 : 1) // Definition is reverse with Ndis 1: the same 0: different
#define OS_SPIN_LOCK spinlock_t
#define OS_SPIN_LOCK_ALLOCATE( _S ) spin_lock_init( _S );
#define OS_SPIN_LOCK_FREE( _S )
#define OS_SPIN_LOCK_ACQUIRED( _S ) spin_lock_irq( _S )
#define OS_SPIN_LOCK_RELEASED( _S ) spin_unlock_irq( _S );
#define OS_TIMER struct timer_list
#define OS_TIMER_INITIAL( _T, _F, _P ) \
{ \
init_timer( _T ); \
(_T)->function = (void *)_F##_1a; \
(_T)->data = (unsigned long)_P; \
}
// _S : Millisecond
// 20060420 At least 1 large than jiffies
#define OS_TIMER_SET( _T, _S ) \
{ \
(_T)->expires = jiffies + ((_S*HZ+999)/1000);\
add_timer( _T ); \
}
#define OS_TIMER_CANCEL( _T, _B ) del_timer_sync( _T )
#define OS_TIMER_GET_SYS_TIME( _T ) (*_T=jiffies)
#endif // COMMON_DEF
//
// Winbond WLAN System Configuration defines
//
//=====================================================================
// Current directory is Linux
// The definition WB_LINUX is a keyword for this OS
//=====================================================================
#ifndef SYS_DEF_H
#define SYS_DEF_H
#define WB_LINUX
#define WB_LINUX_WPA_PSK
//#define _IBSS_BEACON_SEQ_STICK_
#define _USE_FALLBACK_RATE_
//#define ANTDIV_DEFAULT_ON
#define _WPA2_ // 20061122 It's needed for current Linux driver
#ifndef _WPA_PSK_DEBUG
#undef _WPA_PSK_DEBUG
#endif
// debug print options, mark what debug you don't need
#ifdef FULL_DEBUG
#define _PE_STATE_DUMP_
#define _PE_TX_DUMP_
#define _PE_RX_DUMP_
#define _PE_OID_DUMP_
#define _PE_DTO_DUMP_
#define _PE_REG_DUMP_
#define _PE_USB_INI_DUMP_
#endif
#include "common.h" // Individual file depends on OS
#include "../wb35_ver.h"
#include "../mac_structures.h"
#include "../ds_tkip.h"
#include "../localpara.h"
#include "../sme_s.h"
#include "../scan_s.h"
#include "../mds_s.h"
#include "../mlme_s.h"
#include "../bssdscpt.h"
#include "../sme_api.h"
#include "../gl_80211.h"
#include "../mto.h"
#include "../wblinux_s.h"
#include "../wbhal_s.h"
#include "../adapter.h"
#include "../mlme_mib.h"
#include "../mds_f.h"
#include "../bss_f.h"
#include "../mlmetxrx_f.h"
#include "../mto_f.h"
#include "../wbhal_f.h"
#include "../wblinux_f.h"
// Kernel Timer resolution, NDIS is 10ms, 10000us
#define MIN_TIMEOUT_VAL (10) //ms
#endif
This diff is collapsed.
//====================================
// Interface function declare
//====================================
unsigned char Wb35Reg_initial( phw_data_t pHwData );
void Uxx_power_on_procedure( phw_data_t pHwData );
void Uxx_power_off_procedure( phw_data_t pHwData );
void Uxx_ReadEthernetAddress( phw_data_t pHwData );
void Dxx_initial( phw_data_t pHwData );
void Mxx_initial( phw_data_t pHwData );
void RFSynthesizer_initial( phw_data_t pHwData );
//void RFSynthesizer_SwitchingChannel( phw_data_t pHwData, s8 Channel );
void RFSynthesizer_SwitchingChannel( phw_data_t pHwData, ChanInfo Channel );
void BBProcessor_initial( phw_data_t pHwData );
void BBProcessor_RateChanging( phw_data_t pHwData, u8 rate ); // 20060613.1
//void RF_RateChanging( phw_data_t pHwData, u8 rate ); // 20060626.5.c Add
u8 RFSynthesizer_SetPowerIndex( phw_data_t pHwData, u8 PowerIndex );
u8 RFSynthesizer_SetMaxim2828_24Power( phw_data_t, u8 index );
u8 RFSynthesizer_SetMaxim2828_50Power( phw_data_t, u8 index );
u8 RFSynthesizer_SetMaxim2827_24Power( phw_data_t, u8 index );
u8 RFSynthesizer_SetMaxim2827_50Power( phw_data_t, u8 index );
u8 RFSynthesizer_SetMaxim2825Power( phw_data_t, u8 index );
u8 RFSynthesizer_SetAiroha2230Power( phw_data_t, u8 index );
u8 RFSynthesizer_SetAiroha7230Power( phw_data_t, u8 index );
u8 RFSynthesizer_SetWinbond242Power( phw_data_t, u8 index );
void GetTxVgaFromEEPROM( phw_data_t pHwData );
void EEPROMTxVgaAdjust( phw_data_t pHwData ); // 20060619.5 Add
#define RFWriteControlData( _A, _V ) Wb35Reg_Write( _A, 0x0864, _V )
void Wb35Reg_destroy( phw_data_t pHwData );
unsigned char Wb35Reg_Read( phw_data_t pHwData, u16 RegisterNo, PULONG pRegisterValue );
unsigned char Wb35Reg_ReadSync( phw_data_t pHwData, u16 RegisterNo, PULONG pRegisterValue );
unsigned char Wb35Reg_Write( phw_data_t pHwData, u16 RegisterNo, u32 RegisterValue );
unsigned char Wb35Reg_WriteSync( phw_data_t pHwData, u16 RegisterNo, u32 RegisterValue );
unsigned char Wb35Reg_WriteWithCallbackValue( phw_data_t pHwData,
u16 RegisterNo,
u32 RegisterValue,
PCHAR pValue,
s8 Len);
unsigned char Wb35Reg_BurstWrite( phw_data_t pHwData, u16 RegisterNo, PULONG pRegisterData, u8 NumberOfData, u8 Flag );
void Wb35Reg_EP0VM( phw_data_t pHwData );
void Wb35Reg_EP0VM_start( phw_data_t pHwData );
void Wb35Reg_EP0VM_complete( PURB pUrb );
u32 BitReverse( u32 dwData, u32 DataLength);
void CardGetMulticastBit( u8 Address[MAC_ADDR_LENGTH], u8 *Byte, u8 *Value );
u32 CardComputeCrc( PUCHAR Buffer, u32 Length );
void Wb35Reg_phy_calibration( phw_data_t pHwData );
void Wb35Reg_Update( phw_data_t pHwData, u16 RegisterNo, u32 RegisterValue );
unsigned char adjust_TXVGA_for_iq_mag( phw_data_t pHwData );
//=======================================================================================
/*
HAL setting function
========================================
|Uxx| |Dxx| |Mxx| |BB| |RF|
========================================
| |
Wb35Reg_Read Wb35Reg_Write
----------------------------------------
WbUsb_CallUSBDASync supplied By WbUsb module
*/
//=======================================================================================
#define GetBit( dwData, i) ( dwData & (0x00000001 << i))
#define SetBit( dwData, i) ( dwData | (0x00000001 << i))
#define ClearBit( dwData, i) ( dwData & ~(0x00000001 << i))
#define IGNORE_INCREMENT 0
#define AUTO_INCREMENT 0
#define NO_INCREMENT 1
#define REG_DIRECTION(_x,_y) ((_y)->DIRECT ==0 ? usb_rcvctrlpipe(_x,0) : usb_sndctrlpipe(_x,0))
#define REG_BUF_SIZE(_x) ((_x)->bRequest== 0x04 ? cpu_to_le16((_x)->wLength) : 4)
// 20060613.2 Add the follow definition
#define BB48_DEFAULT_AL2230_11B 0x0033447c
#define BB4C_DEFAULT_AL2230_11B 0x0A00FEFF
#define BB48_DEFAULT_AL2230_11G 0x00332C1B
#define BB4C_DEFAULT_AL2230_11G 0x0A00FEFF
#define BB48_DEFAULT_WB242_11B 0x00292315 //backoff 2dB
#define BB4C_DEFAULT_WB242_11B 0x0800FEFF //backoff 2dB
//#define BB48_DEFAULT_WB242_11B 0x00201B11 //backoff 4dB
//#define BB4C_DEFAULT_WB242_11B 0x0600FF00 //backoff 4dB
#define BB48_DEFAULT_WB242_11G 0x00453B24
#define BB4C_DEFAULT_WB242_11G 0x0E00FEFF
//====================================
// Default setting for Mxx
//====================================
#define DEFAULT_CWMIN 31 //(M2C) CWmin. Its value is in the range 0-31.
#define DEFAULT_CWMAX 1023 //(M2C) CWmax. Its value is in the range 0-1023.
#define DEFAULT_AID 1 //(M34) AID. Its value is in the range 1-2007.
#ifdef _USE_FALLBACK_RATE_
#define DEFAULT_RATE_RETRY_LIMIT 2 //(M38) as named
#else
#define DEFAULT_RATE_RETRY_LIMIT 7 //(M38) as named
#endif
#define DEFAULT_LONG_RETRY_LIMIT 7 //(M38) LongRetryLimit. Its value is in the range 0-15.
#define DEFAULT_SHORT_RETRY_LIMIT 7 //(M38) ShortRetryLimit. Its value is in the range 0-15.
#define DEFAULT_PIFST 25 //(M3C) PIFS Time. Its value is in the range 0-65535.
#define DEFAULT_EIFST 354 //(M3C) EIFS Time. Its value is in the range 0-1048575.
#define DEFAULT_DIFST 45 //(M3C) DIFS Time. Its value is in the range 0-65535.
#define DEFAULT_SIFST 5 //(M3C) SIFS Time. Its value is in the range 0-65535.
#define DEFAULT_OSIFST 10 //(M3C) Original SIFS Time. Its value is in the range 0-15.
#define DEFAULT_ATIMWD 0 //(M40) ATIM Window. Its value is in the range 0-65535.
#define DEFAULT_SLOT_TIME 20 //(M40) ($) SlotTime. Its value is in the range 0-255.
#define DEFAULT_MAX_TX_MSDU_LIFE_TIME 512 //(M44) MaxTxMSDULifeTime. Its value is in the range 0-4294967295.
#define DEFAULT_BEACON_INTERVAL 500 //(M48) Beacon Interval. Its value is in the range 0-65535.
#define DEFAULT_PROBE_DELAY_TIME 200 //(M48) Probe Delay Time. Its value is in the range 0-65535.
#define DEFAULT_PROTOCOL_VERSION 0 //(M4C)
#define DEFAULT_MAC_POWER_STATE 2 //(M4C) 2: MAC at power active
#define DEFAULT_DTIM_ALERT_TIME 0
typedef struct _REG_QUEUE
{
struct urb *pUrb;
void* pUsbReq;
void* Next;
union
{
u32 VALUE;
PULONG pBuffer;
};
u8 RESERVED[4];// space reserved for communication
u16 INDEX; // For storing the register index
u8 RESERVED_VALID; //Indicate whether the RESERVED space is valid at this command.
u8 DIRECT; // 0:In 1:Out
} REG_QUEUE, *PREG_QUEUE;
//====================================
// Internal variable for module
//====================================
#define MAX_SQ3_FILTER_SIZE 5
typedef struct _WB35REG
{
//============================
// Register Bank backup
//============================
u32 U1B0; //bit16 record the h/w radio on/off status
u32 U1BC_LEDConfigure;
u32 D00_DmaControl;
u32 M00_MacControl;
union {
struct {
u32 M04_MulticastAddress1;
u32 M08_MulticastAddress2;
};
u8 Multicast[8]; // contents of card multicast registers
};
u32 M24_MacControl;
u32 M28_MacControl;
u32 M2C_MacControl;
u32 M38_MacControl;
u32 M3C_MacControl; // 20060214 backup only
u32 M40_MacControl;
u32 M44_MacControl; // 20060214 backup only
u32 M48_MacControl; // 20060214 backup only
u32 M4C_MacStatus;
u32 M60_MacControl; // 20060214 backup only
u32 M68_MacControl; // 20060214 backup only
u32 M70_MacControl; // 20060214 backup only
u32 M74_MacControl; // 20060214 backup only
u32 M78_ERPInformation;//930206.2.b
u32 M7C_MacControl; // 20060214 backup only
u32 M80_MacControl; // 20060214 backup only
u32 M84_MacControl; // 20060214 backup only
u32 M88_MacControl; // 20060214 backup only
u32 M98_MacControl; // 20060214 backup only
//[20040722 WK]
//Baseband register
u32 BB0C; // Used for LNA calculation
u32 BB2C; //
u32 BB30; //11b acquisition control register
u32 BB3C;
u32 BB48; // 20051221.1.a 20060613.1 Fix OBW issue of 11b/11g rate
u32 BB4C; // 20060613.1 Fix OBW issue of 11b/11g rate
u32 BB50; //mode control register
u32 BB54;
u32 BB58; //IQ_ALPHA
u32 BB5C; // For test
u32 BB60; // for WTO read value
//-------------------
// VM
//-------------------
OS_SPIN_LOCK EP0VM_spin_lock; // 4B
u32 EP0VM_status;//$$
PREG_QUEUE pRegFirst;
PREG_QUEUE pRegLast;
OS_ATOMIC RegFireCount;
// Hardware status
u8 EP0vm_state;
u8 mac_power_save;
u8 EEPROMPhyType; // 0 ~ 15 for Maxim (0 ĄV MAX2825, 1 ĄV MAX2827, 2 ĄV MAX2828, 3 ĄV MAX2829),
// 16 ~ 31 for Airoha (16 ĄV AL2230, 11 - AL7230)
// 32 ~ Reserved
// 33 ~ 47 For WB242 ( 33 - WB242, 34 - WB242 with new Txvga 0.5 db step)
// 48 ~ 255 ARE RESERVED.
u8 EEPROMRegion; //Region setting in EEPROM
u32 SyncIoPause; // If user use the Sync Io to access Hw, then pause the async access
u8 LNAValue[4]; //Table for speed up running
u32 SQ3_filter[MAX_SQ3_FILTER_SIZE];
u32 SQ3_index;
} WB35REG, *PWB35REG;
//============================================================================
// Copyright (c) 1996-2002 Winbond Electronic Corporation
//
// Module Name:
// Wb35Rx.c
//
// Abstract:
// Processing the Rx message from down layer
//
//============================================================================
#include "sysdef.h"
void Wb35Rx_start(phw_data_t pHwData)
{
PWB35RX pWb35Rx = &pHwData->Wb35Rx;
// Allow only one thread to run into the Wb35Rx() function
if (OS_ATOMIC_INC(pHwData->Adapter, &pWb35Rx->RxFireCounter) == 1) {
pWb35Rx->EP3vm_state = VM_RUNNING;
Wb35Rx(pHwData);
} else
OS_ATOMIC_DEC(pHwData->Adapter, &pWb35Rx->RxFireCounter);
}
// This function cannot reentrain
void Wb35Rx( phw_data_t pHwData )
{
PWB35RX pWb35Rx = &pHwData->Wb35Rx;
PUCHAR pRxBufferAddress;
PURB pUrb = (PURB)pWb35Rx->RxUrb;
int retv;
u32 RxBufferId;
//
// Issuing URB
//
do {
if (pHwData->SurpriseRemove || pHwData->HwStop)
break;
if (pWb35Rx->rx_halt)
break;
// Get RxBuffer's ID
RxBufferId = pWb35Rx->RxBufferId;
if (!pWb35Rx->RxOwner[RxBufferId]) {
// It's impossible to run here.
#ifdef _PE_RX_DUMP_
WBDEBUG(("Rx driver fifo unavailable\n"));
#endif
break;
}
// Update buffer point, then start to bulkin the data from USB
pWb35Rx->RxBufferId++;
pWb35Rx->RxBufferId %= MAX_USB_RX_BUFFER_NUMBER;
pWb35Rx->CurrentRxBufferId = RxBufferId;
if (1 != OS_MEMORY_ALLOC((void* *)&pWb35Rx->pDRx, MAX_USB_RX_BUFFER)) {
printk("w35und: Rx memory alloc failed\n");
break;
}
pRxBufferAddress = pWb35Rx->pDRx;
usb_fill_bulk_urb(pUrb, pHwData->WbUsb.udev,
usb_rcvbulkpipe(pHwData->WbUsb.udev, 3),
pRxBufferAddress, MAX_USB_RX_BUFFER,
Wb35Rx_Complete, pHwData);
pWb35Rx->EP3vm_state = VM_RUNNING;
retv = wb_usb_submit_urb(pUrb);
if (retv != 0) {
printk("Rx URB sending error\n");
break;
}
return;
} while(FALSE);
// VM stop
pWb35Rx->EP3vm_state = VM_STOP;
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Rx->RxFireCounter );
}
void Wb35Rx_Complete(PURB pUrb)
{
phw_data_t pHwData = pUrb->context;
PWB35RX pWb35Rx = &pHwData->Wb35Rx;
PUCHAR pRxBufferAddress;
u32 SizeCheck;
u16 BulkLength;
u32 RxBufferId;
R00_DESCRIPTOR R00;
// Variable setting
pWb35Rx->EP3vm_state = VM_COMPLETED;
pWb35Rx->EP3VM_status = pUrb->status;//Store the last result of Irp
do {
RxBufferId = pWb35Rx->CurrentRxBufferId;
pRxBufferAddress = pWb35Rx->pDRx;
BulkLength = (u16)pUrb->actual_length;
// The IRP is completed
pWb35Rx->EP3vm_state = VM_COMPLETED;
if (pHwData->SurpriseRemove || pHwData->HwStop) // Must be here, or RxBufferId is invalid
break;
if (pWb35Rx->rx_halt)
break;
// Start to process the data only in successful condition
pWb35Rx->RxOwner[ RxBufferId ] = 0; // Set the owner to driver
R00.value = le32_to_cpu(*(PULONG)pRxBufferAddress);
// The URB is completed, check the result
if (pWb35Rx->EP3VM_status != 0) {
#ifdef _PE_USB_STATE_DUMP_
WBDEBUG(("EP3 IoCompleteRoutine return error\n"));
DebugUsbdStatusInformation( pWb35Rx->EP3VM_status );
#endif
pWb35Rx->EP3vm_state = VM_STOP;
break;
}
// 20060220 For recovering. check if operating in single USB mode
if (!HAL_USB_MODE_BURST(pHwData)) {
SizeCheck = R00.R00_receive_byte_count; //20060926 anson's endian
if ((SizeCheck & 0x03) > 0)
SizeCheck -= 4;
SizeCheck = (SizeCheck + 3) & ~0x03;
SizeCheck += 12; // 8 + 4 badbeef
if ((BulkLength > 1600) ||
(SizeCheck > 1600) ||
(BulkLength != SizeCheck) ||
(BulkLength == 0)) { // Add for fail Urb
pWb35Rx->EP3vm_state = VM_STOP;
pWb35Rx->Ep3ErrorCount2++;
}
}
// Indicating the receiving data
pWb35Rx->ByteReceived += BulkLength;
pWb35Rx->RxBufferSize[ RxBufferId ] = BulkLength;
if (!pWb35Rx->RxOwner[ RxBufferId ])
Wb35Rx_indicate(pHwData);
kfree(pWb35Rx->pDRx);
// Do the next receive
Wb35Rx(pHwData);
return;
} while(FALSE);
pWb35Rx->RxOwner[ RxBufferId ] = 1; // Set the owner to hardware
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Rx->RxFireCounter );
pWb35Rx->EP3vm_state = VM_STOP;
}
//=====================================================================================
unsigned char Wb35Rx_initial(phw_data_t pHwData)
{
PWB35RX pWb35Rx = &pHwData->Wb35Rx;
// Initial the Buffer Queue
Wb35Rx_reset_descriptor( pHwData );
pWb35Rx->RxUrb = wb_usb_alloc_urb(0);
return (!!pWb35Rx->RxUrb);
}
void Wb35Rx_stop(phw_data_t pHwData)
{
PWB35RX pWb35Rx = &pHwData->Wb35Rx;
// Canceling the Irp if already sends it out.
if (pWb35Rx->EP3vm_state == VM_RUNNING) {
usb_unlink_urb( pWb35Rx->RxUrb ); // Only use unlink, let Wb35Rx_destroy to free them
#ifdef _PE_RX_DUMP_
WBDEBUG(("EP3 Rx stop\n"));
#endif
}
}
// Needs process context
void Wb35Rx_destroy(phw_data_t pHwData)
{
PWB35RX pWb35Rx = &pHwData->Wb35Rx;
do {
OS_SLEEP(10000); // Delay for waiting function enter 940623.1.a
} while (pWb35Rx->EP3vm_state != VM_STOP);
OS_SLEEP(10000); // Delay for waiting function exit 940623.1.b
if (pWb35Rx->RxUrb)
usb_free_urb( pWb35Rx->RxUrb );
#ifdef _PE_RX_DUMP_
WBDEBUG(("Wb35Rx_destroy OK\n"));
#endif
}
void Wb35Rx_reset_descriptor( phw_data_t pHwData )
{
PWB35RX pWb35Rx = &pHwData->Wb35Rx;
u32 i;
pWb35Rx->ByteReceived = 0;
pWb35Rx->RxProcessIndex = 0;
pWb35Rx->RxBufferId = 0;
pWb35Rx->EP3vm_state = VM_STOP;
pWb35Rx->rx_halt = 0;
// Initial the Queue. The last buffer is reserved for used if the Rx resource is unavailable.
for( i=0; i<MAX_USB_RX_BUFFER_NUMBER; i++ )
pWb35Rx->RxOwner[i] = 1;
}
void Wb35Rx_adjust(PDESCRIPTOR pRxDes)
{
PULONG pRxBufferAddress;
u32 DecryptionMethod;
u32 i;
u16 BufferSize;
DecryptionMethod = pRxDes->R01.R01_decryption_method;
pRxBufferAddress = pRxDes->buffer_address[0];
BufferSize = pRxDes->buffer_size[0];
// Adjust the last part of data. Only data left
BufferSize -= 4; // For CRC-32
if (DecryptionMethod)
BufferSize -= 4;
if (DecryptionMethod == 3) // For CCMP
BufferSize -= 4;
// Adjust the IV field which after 802.11 header and ICV field.
if (DecryptionMethod == 1) // For WEP
{
for( i=6; i>0; i-- )
pRxBufferAddress[i] = pRxBufferAddress[i-1];
pRxDes->buffer_address[0] = pRxBufferAddress + 1;
BufferSize -= 4; // 4 byte for IV
}
else if( DecryptionMethod ) // For TKIP and CCMP
{
for (i=7; i>1; i--)
pRxBufferAddress[i] = pRxBufferAddress[i-2];
pRxDes->buffer_address[0] = pRxBufferAddress + 2;//Update the descriptor, shift 8 byte
BufferSize -= 8; // 8 byte for IV + ICV
}
pRxDes->buffer_size[0] = BufferSize;
}
extern void packet_came(char *pRxBufferAddress, int PacketSize);
u16 Wb35Rx_indicate(phw_data_t pHwData)
{
DESCRIPTOR RxDes;
PWB35RX pWb35Rx = &pHwData->Wb35Rx;
PUCHAR pRxBufferAddress;
u16 PacketSize;
u16 stmp, BufferSize, stmp2 = 0;
u32 RxBufferId;
// Only one thread be allowed to run into the following
do {
RxBufferId = pWb35Rx->RxProcessIndex;
if (pWb35Rx->RxOwner[ RxBufferId ]) //Owner by VM
break;
pWb35Rx->RxProcessIndex++;
pWb35Rx->RxProcessIndex %= MAX_USB_RX_BUFFER_NUMBER;
pRxBufferAddress = pWb35Rx->pDRx;
BufferSize = pWb35Rx->RxBufferSize[ RxBufferId ];
// Parse the bulkin buffer
while (BufferSize >= 4) {
if ((cpu_to_le32(*(PULONG)pRxBufferAddress) & 0x0fffffff) == RX_END_TAG) //Is ending? 921002.9.a
break;
// Get the R00 R01 first
RxDes.R00.value = le32_to_cpu(*(PULONG)pRxBufferAddress);
PacketSize = (u16)RxDes.R00.R00_receive_byte_count;
RxDes.R01.value = le32_to_cpu(*((PULONG)(pRxBufferAddress+4)));
// For new DMA 4k
if ((PacketSize & 0x03) > 0)
PacketSize -= 4;
// Basic check for Rx length. Is length valid?
if (PacketSize > MAX_PACKET_SIZE) {
#ifdef _PE_RX_DUMP_
WBDEBUG(("Serious ERROR : Rx data size too long, size =%d\n", PacketSize));
#endif
pWb35Rx->EP3vm_state = VM_STOP;
pWb35Rx->Ep3ErrorCount2++;
break;
}
// Start to process Rx buffer
// RxDes.Descriptor_ID = RxBufferId; // Due to synchronous indicate, the field doesn't necessary to use.
BufferSize -= 8; //subtract 8 byte for 35's USB header length
pRxBufferAddress += 8;
RxDes.buffer_address[0] = pRxBufferAddress;
RxDes.buffer_size[0] = PacketSize;
RxDes.buffer_number = 1;
RxDes.buffer_start_index = 0;
RxDes.buffer_total_size = RxDes.buffer_size[0];
Wb35Rx_adjust(&RxDes);
packet_came(pRxBufferAddress, PacketSize);
// Move RxBuffer point to the next
stmp = PacketSize + 3;
stmp &= ~0x03; // 4n alignment
pRxBufferAddress += stmp;
BufferSize -= stmp;
stmp2 += stmp;
}
// Reclaim resource
pWb35Rx->RxOwner[ RxBufferId ] = 1;
} while(TRUE);
return stmp2;
}
//====================================
// Interface function declare
//====================================
void Wb35Rx_reset_descriptor( phw_data_t pHwData );
unsigned char Wb35Rx_initial( phw_data_t pHwData );
void Wb35Rx_destroy( phw_data_t pHwData );
void Wb35Rx_stop( phw_data_t pHwData );
u16 Wb35Rx_indicate( phw_data_t pHwData );
void Wb35Rx_adjust( PDESCRIPTOR pRxDes );
void Wb35Rx_start( phw_data_t pHwData );
void Wb35Rx( phw_data_t pHwData );
void Wb35Rx_Complete( PURB pUrb );
//============================================================================
// wb35rx.h --
//============================================================================
// Definition for this module used
#define MAX_USB_RX_BUFFER 4096 // This parameter must be 4096 931130.4.f
#define MAX_USB_RX_BUFFER_NUMBER ETHERNET_RX_DESCRIPTORS // Maximum 254, 255 is RESERVED ID
#define RX_INTERFACE 0 // Interface 1
#define RX_PIPE 2 // Pipe 3
#define MAX_PACKET_SIZE 1600 //1568 // 8 + 1532 + 4 + 24(IV EIV MIC ICV CRC) for check DMA data 931130.4.g
#define RX_END_TAG 0x0badbeef
//====================================
// Internal variable for module
//====================================
typedef struct _WB35RX
{
u32 ByteReceived;// For calculating throughput of BulkIn
OS_ATOMIC RxFireCounter;// Does Wb35Rx module fire?
u8 RxBuffer[ MAX_USB_RX_BUFFER_NUMBER ][ ((MAX_USB_RX_BUFFER+3) & ~0x03 ) ];
u16 RxBufferSize[ ((MAX_USB_RX_BUFFER_NUMBER+1) & ~0x01) ];
u8 RxOwner[ ((MAX_USB_RX_BUFFER_NUMBER+3) & ~0x03 ) ];//Ownership of buffer 0: SW 1:HW
u32 RxProcessIndex;//The next index to process
u32 RxBufferId;
u32 EP3vm_state;
u32 rx_halt; // For VM stopping
u16 MoreDataSize;
u16 PacketSize;
u32 CurrentRxBufferId; // For complete routine usage
u32 Rx3UrbCancel;
u32 LastR1; // For RSSI reporting
struct urb * RxUrb;
u32 Ep3ErrorCount2; // 20060625.1 Usbd for Rx DMA error count
int EP3VM_status;
PUCHAR pDRx;
} WB35RX, *PWB35RX;
//============================================================================
// Copyright (c) 1996-2002 Winbond Electronic Corporation
//
// Module Name:
// Wb35Tx.c
//
// Abstract:
// Processing the Tx message and put into down layer
//
//============================================================================
#include "sysdef.h"
unsigned char
Wb35Tx_get_tx_buffer(phw_data_t pHwData, PUCHAR *pBuffer )
{
PWB35TX pWb35Tx = &pHwData->Wb35Tx;
*pBuffer = pWb35Tx->TxBuffer[0];
return TRUE;
}
void Wb35Tx_start(phw_data_t pHwData)
{
PWB35TX pWb35Tx = &pHwData->Wb35Tx;
// Allow only one thread to run into function
if (OS_ATOMIC_INC(pHwData->Adapter, &pWb35Tx->TxFireCounter) == 1) {
pWb35Tx->EP4vm_state = VM_RUNNING;
Wb35Tx(pHwData);
} else
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Tx->TxFireCounter );
}
void Wb35Tx(phw_data_t pHwData)
{
PWB35TX pWb35Tx = &pHwData->Wb35Tx;
PADAPTER Adapter = pHwData->Adapter;
PUCHAR pTxBufferAddress;
PMDS pMds = &Adapter->Mds;
struct urb * pUrb = (struct urb *)pWb35Tx->Tx4Urb;
int retv;
u32 SendIndex;
if (pHwData->SurpriseRemove || pHwData->HwStop)
goto cleanup;
if (pWb35Tx->tx_halt)
goto cleanup;
// Ownership checking
SendIndex = pWb35Tx->TxSendIndex;
if (!pMds->TxOwner[SendIndex]) //No more data need to be sent, return immediately
goto cleanup;
pTxBufferAddress = pWb35Tx->TxBuffer[SendIndex];
//
// Issuing URB
//
usb_fill_bulk_urb(pUrb, pHwData->WbUsb.udev,
usb_sndbulkpipe(pHwData->WbUsb.udev, 4),
pTxBufferAddress, pMds->TxBufferSize[ SendIndex ],
Wb35Tx_complete, pHwData);
pWb35Tx->EP4vm_state = VM_RUNNING;
retv = wb_usb_submit_urb( pUrb );
if (retv<0) {
printk("EP4 Tx Irp sending error\n");
goto cleanup;
}
// Check if driver needs issue Irp for EP2
pWb35Tx->TxFillCount += pMds->TxCountInBuffer[SendIndex];
if (pWb35Tx->TxFillCount > 12)
Wb35Tx_EP2VM_start( pHwData );
pWb35Tx->ByteTransfer += pMds->TxBufferSize[SendIndex];
return;
cleanup:
pWb35Tx->EP4vm_state = VM_STOP;
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Tx->TxFireCounter );
}
void Wb35Tx_complete(struct urb * pUrb)
{
phw_data_t pHwData = pUrb->context;
PADAPTER Adapter = (PADAPTER)pHwData->Adapter;
PWB35TX pWb35Tx = &pHwData->Wb35Tx;
PMDS pMds = &Adapter->Mds;
printk("wb35: tx complete\n");
// Variable setting
pWb35Tx->EP4vm_state = VM_COMPLETED;
pWb35Tx->EP4VM_status = pUrb->status; //Store the last result of Irp
pMds->TxOwner[ pWb35Tx->TxSendIndex ] = 0;// Set the owner. Free the owner bit always.
pWb35Tx->TxSendIndex++;
pWb35Tx->TxSendIndex %= MAX_USB_TX_BUFFER_NUMBER;
do {
if (pHwData->SurpriseRemove || pHwData->HwStop) // Let WbWlanHalt to handle surprise remove
break;
if (pWb35Tx->tx_halt)
break;
// The URB is completed, check the result
if (pWb35Tx->EP4VM_status != 0) {
printk("URB submission failed\n");
pWb35Tx->EP4vm_state = VM_STOP;
break; // Exit while(FALSE);
}
Mds_Tx(Adapter);
Wb35Tx(pHwData);
return;
} while(FALSE);
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Tx->TxFireCounter );
pWb35Tx->EP4vm_state = VM_STOP;
}
void Wb35Tx_reset_descriptor( phw_data_t pHwData )
{
PWB35TX pWb35Tx = &pHwData->Wb35Tx;
pWb35Tx->TxSendIndex = 0;
pWb35Tx->tx_halt = 0;
}
unsigned char Wb35Tx_initial(phw_data_t pHwData)
{
PWB35TX pWb35Tx = &pHwData->Wb35Tx;
pWb35Tx->Tx4Urb = wb_usb_alloc_urb(0);
if (!pWb35Tx->Tx4Urb)
return FALSE;
pWb35Tx->Tx2Urb = wb_usb_alloc_urb(0);
if (!pWb35Tx->Tx2Urb)
{
usb_free_urb( pWb35Tx->Tx4Urb );
return FALSE;
}
return TRUE;
}
//======================================================
void Wb35Tx_stop(phw_data_t pHwData)
{
PWB35TX pWb35Tx = &pHwData->Wb35Tx;
// Trying to canceling the Trp of EP2
if (pWb35Tx->EP2vm_state == VM_RUNNING)
usb_unlink_urb( pWb35Tx->Tx2Urb ); // Only use unlink, let Wb35Tx_destrot to free them
#ifdef _PE_TX_DUMP_
WBDEBUG(("EP2 Tx stop\n"));
#endif
// Trying to canceling the Irp of EP4
if (pWb35Tx->EP4vm_state == VM_RUNNING)
usb_unlink_urb( pWb35Tx->Tx4Urb ); // Only use unlink, let Wb35Tx_destrot to free them
#ifdef _PE_TX_DUMP_
WBDEBUG(("EP4 Tx stop\n"));
#endif
}
//======================================================
void Wb35Tx_destroy(phw_data_t pHwData)
{
PWB35TX pWb35Tx = &pHwData->Wb35Tx;
// Wait for VM stop
do {
OS_SLEEP(10000); // Delay for waiting function enter 940623.1.a
} while( (pWb35Tx->EP2vm_state != VM_STOP) && (pWb35Tx->EP4vm_state != VM_STOP) );
OS_SLEEP(10000); // Delay for waiting function enter 940623.1.b
if (pWb35Tx->Tx4Urb)
usb_free_urb( pWb35Tx->Tx4Urb );
if (pWb35Tx->Tx2Urb)
usb_free_urb( pWb35Tx->Tx2Urb );
#ifdef _PE_TX_DUMP_
WBDEBUG(("Wb35Tx_destroy OK\n"));
#endif
}
void Wb35Tx_CurrentTime(phw_data_t pHwData, u32 TimeCount)
{
PWB35TX pWb35Tx = &pHwData->Wb35Tx;
unsigned char Trigger = FALSE;
if (pWb35Tx->TxTimer > TimeCount)
Trigger = TRUE;
else if (TimeCount > (pWb35Tx->TxTimer+500))
Trigger = TRUE;
if (Trigger) {
pWb35Tx->TxTimer = TimeCount;
Wb35Tx_EP2VM_start( pHwData );
}
}
void Wb35Tx_EP2VM_start(phw_data_t pHwData)
{
PWB35TX pWb35Tx = &pHwData->Wb35Tx;
// Allow only one thread to run into function
if (OS_ATOMIC_INC( pHwData->Adapter, &pWb35Tx->TxResultCount ) == 1) {
pWb35Tx->EP2vm_state = VM_RUNNING;
Wb35Tx_EP2VM( pHwData );
}
else
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Tx->TxResultCount );
}
void Wb35Tx_EP2VM(phw_data_t pHwData)
{
PWB35TX pWb35Tx = &pHwData->Wb35Tx;
struct urb * pUrb = (struct urb *)pWb35Tx->Tx2Urb;
PULONG pltmp = (PULONG)pWb35Tx->EP2_buf;
int retv;
do {
if (pHwData->SurpriseRemove || pHwData->HwStop)
break;
if (pWb35Tx->tx_halt)
break;
//
// Issuing URB
//
usb_fill_int_urb( pUrb, pHwData->WbUsb.udev, usb_rcvintpipe(pHwData->WbUsb.udev,2),
pltmp, MAX_INTERRUPT_LENGTH, Wb35Tx_EP2VM_complete, pHwData, 32);
pWb35Tx->EP2vm_state = VM_RUNNING;
retv = wb_usb_submit_urb( pUrb );
if(retv < 0) {
#ifdef _PE_TX_DUMP_
WBDEBUG(("EP2 Tx Irp sending error\n"));
#endif
break;
}
return;
} while(FALSE);
pWb35Tx->EP2vm_state = VM_STOP;
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Tx->TxResultCount );
}
void Wb35Tx_EP2VM_complete(struct urb * pUrb)
{
phw_data_t pHwData = pUrb->context;
T02_DESCRIPTOR T02, TSTATUS;
PADAPTER Adapter = (PADAPTER)pHwData->Adapter;
PWB35TX pWb35Tx = &pHwData->Wb35Tx;
PULONG pltmp = (PULONG)pWb35Tx->EP2_buf;
u32 i;
u16 InterruptInLength;
// Variable setting
pWb35Tx->EP2vm_state = VM_COMPLETED;
pWb35Tx->EP2VM_status = pUrb->status;
do {
// For Linux 2.4. Interrupt will always trigger
if( pHwData->SurpriseRemove || pHwData->HwStop ) // Let WbWlanHalt to handle surprise remove
break;
if( pWb35Tx->tx_halt )
break;
//The Urb is completed, check the result
if (pWb35Tx->EP2VM_status != 0) {
WBDEBUG(("EP2 IoCompleteRoutine return error\n"));
pWb35Tx->EP2vm_state= VM_STOP;
break; // Exit while(FALSE);
}
// Update the Tx result
InterruptInLength = pUrb->actual_length;
// Modify for minimum memory access and DWORD alignment.
T02.value = cpu_to_le32(pltmp[0]) >> 8; // [31:8] -> [24:0]
InterruptInLength -= 1;// 20051221.1.c Modify the follow for more stable
InterruptInLength >>= 2; // InterruptInLength/4
for (i=1; i<=InterruptInLength; i++) {
T02.value |= ((cpu_to_le32(pltmp[i]) & 0xff) << 24);
TSTATUS.value = T02.value; //20061009 anson's endian
Mds_SendComplete( Adapter, &TSTATUS );
T02.value = cpu_to_le32(pltmp[i]) >> 8;
}
return;
} while(FALSE);
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Tx->TxResultCount );
pWb35Tx->EP2vm_state = VM_STOP;
}
//====================================
// Interface function declare
//====================================
unsigned char Wb35Tx_initial( phw_data_t pHwData );
void Wb35Tx_destroy( phw_data_t pHwData );
unsigned char Wb35Tx_get_tx_buffer( phw_data_t pHwData, PUCHAR *pBuffer );
void Wb35Tx_EP2VM( phw_data_t pHwData );
void Wb35Tx_EP2VM_start( phw_data_t pHwData );
void Wb35Tx_EP2VM_complete( PURB purb );
void Wb35Tx_start( phw_data_t pHwData );
void Wb35Tx_stop( phw_data_t pHwData );
void Wb35Tx( phw_data_t pHwData );
void Wb35Tx_complete( PURB purb );
void Wb35Tx_reset_descriptor( phw_data_t pHwData );
void Wb35Tx_CurrentTime( phw_data_t pHwData, u32 TimeCount );
//====================================
// IS89C35 Tx related definition
//====================================
#define TX_INTERFACE 0 // Interface 1
#define TX_PIPE 3 // endpoint 4
#define TX_INTERRUPT 1 // endpoint 2
#define MAX_INTERRUPT_LENGTH 64 // It must be 64 for EP2 hardware
//====================================
// Internal variable for module
//====================================
typedef struct _WB35TX
{
// For Tx buffer
u8 TxBuffer[ MAX_USB_TX_BUFFER_NUMBER ][ MAX_USB_TX_BUFFER ];
// For Interrupt pipe
u8 EP2_buf[MAX_INTERRUPT_LENGTH];
OS_ATOMIC TxResultCount;// For thread control of EP2 931130.4.m
OS_ATOMIC TxFireCounter;// For thread control of EP4 931130.4.n
u32 ByteTransfer;
u32 TxSendIndex;// The next index of Mds array to be sent
u32 EP2vm_state; // for EP2vm state
u32 EP4vm_state; // for EP4vm state
u32 tx_halt; // Stopping VM
struct urb * Tx4Urb;
struct urb * Tx2Urb;
int EP2VM_status;
int EP4VM_status;
u32 TxFillCount; // 20060928
u32 TxTimer; // 20060928 Add if sending packet not great than 13
} WB35TX, *PWB35TX;
/*
* Copyright 2008 Pavel Machek <pavel@suse.cz>
*
* Distribute under GPLv2.
*/
#include "sysdef.h"
#include <net/mac80211.h>
MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE("GPL");
MODULE_VERSION("0.1");
//============================================================
// vendor ID and product ID can into here for others
//============================================================
static struct usb_device_id Id_Table[] =
{
{USB_DEVICE( 0x0416, 0x0035 )},
{USB_DEVICE( 0x18E8, 0x6201 )},
{USB_DEVICE( 0x18E8, 0x6206 )},
{USB_DEVICE( 0x18E8, 0x6217 )},
{USB_DEVICE( 0x18E8, 0x6230 )},
{USB_DEVICE( 0x18E8, 0x6233 )},
{USB_DEVICE( 0x1131, 0x2035 )},
{ }
};
MODULE_DEVICE_TABLE(usb, Id_Table);
static struct usb_driver wb35_driver = {
.name = "w35und",
.probe = wb35_probe,
.disconnect = wb35_disconnect,
.id_table = Id_Table,
};
static const struct ieee80211_rate wbsoft_rates[] = {
{ .bitrate = 10, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
};
static const struct ieee80211_channel wbsoft_channels[] = {
{ .center_freq = 2412},
};
int wbsoft_enabled;
struct ieee80211_hw *my_dev;
PADAPTER my_adapter;
static int wbsoft_add_interface(struct ieee80211_hw *dev,
struct ieee80211_if_init_conf *conf)
{
printk("wbsoft_add interface called\n");
return 0;
}
static void wbsoft_remove_interface(struct ieee80211_hw *dev,
struct ieee80211_if_init_conf *conf)
{
printk("wbsoft_remove interface called\n");
}
static int wbsoft_nop(void)
{
printk("wbsoft_nop called\n");
return 0;
}
static void wbsoft_configure_filter(struct ieee80211_hw *dev,
unsigned int changed_flags,
unsigned int *total_flags,
int mc_count, struct dev_mc_list *mclist)
{
unsigned int bit_nr, new_flags;
u32 mc_filter[2];
int i;
new_flags = 0;
if (*total_flags & FIF_PROMISC_IN_BSS) {
new_flags |= FIF_PROMISC_IN_BSS;
mc_filter[1] = mc_filter[0] = ~0;
} else if ((*total_flags & FIF_ALLMULTI) || (mc_count > 32)) {
new_flags |= FIF_ALLMULTI;
mc_filter[1] = mc_filter[0] = ~0;
} else {
mc_filter[1] = mc_filter[0] = 0;
for (i = 0; i < mc_count; i++) {
if (!mclist)
break;
printk("Should call ether_crc here\n");
//bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
bit_nr = 0;
bit_nr &= 0x3F;
mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
mclist = mclist->next;
}
}
dev->flags &= ~IEEE80211_HW_RX_INCLUDES_FCS;
*total_flags = new_flags;
}
static int wbsoft_tx(struct ieee80211_hw *dev, struct sk_buff *skb,
struct ieee80211_tx_control *control)
{
char *buffer = kmalloc(skb->len, GFP_ATOMIC);
printk("Sending frame %d bytes\n", skb->len);
memcpy(buffer, skb->data, skb->len);
if (1 == MLMESendFrame(my_adapter, buffer, skb->len, FRAME_TYPE_802_11_MANAGEMENT))
printk("frame sent ok (%d bytes)?\n", skb->len);
return NETDEV_TX_OK;
}
static int wbsoft_start(struct ieee80211_hw *dev)
{
wbsoft_enabled = 1;
printk("wbsoft_start called\n");
return 0;
}
static int wbsoft_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
{
ChanInfo ch;
printk("wbsoft_config called\n");
ch.band = 1;
ch.ChanNo = 1; /* Should use channel_num, or something, as that is already pre-translated */
hal_set_current_channel(&my_adapter->sHwData, ch);
hal_set_beacon_period(&my_adapter->sHwData, conf->beacon_int);
// hal_set_cap_info(&my_adapter->sHwData, ?? );
// hal_set_ssid(phw_data_t pHwData, PUCHAR pssid, u8 ssid_len); ??
hal_set_accept_broadcast(&my_adapter->sHwData, 1);
hal_set_accept_promiscuous(&my_adapter->sHwData, 1);
hal_set_accept_multicast(&my_adapter->sHwData, 1);
hal_set_accept_beacon(&my_adapter->sHwData, 1);
hal_set_radio_mode(&my_adapter->sHwData, 0);
//hal_set_antenna_number( phw_data_t pHwData, u8 number )
//hal_set_rf_power(phw_data_t pHwData, u8 PowerIndex)
// hal_start_bss(&my_adapter->sHwData, WLAN_BSSTYPE_INFRASTRUCTURE); ??
//void hal_set_rates(phw_data_t pHwData, PUCHAR pbss_rates,
// u8 length, unsigned char basic_rate_set)
return 0;
}
static int wbsoft_config_interface(struct ieee80211_hw *dev,
struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf)
{
printk("wbsoft_config_interface called\n");
return 0;
}
static u64 wbsoft_get_tsf(struct ieee80211_hw *dev)
{
printk("wbsoft_get_tsf called\n");
return 0;
}
static const struct ieee80211_ops wbsoft_ops = {
.tx = wbsoft_tx,
.start = wbsoft_start, /* Start can be pretty much empty as we do WbWLanInitialize() during probe? */
.stop = wbsoft_nop,
.add_interface = wbsoft_add_interface,
.remove_interface = wbsoft_remove_interface,
.config = wbsoft_config,
.config_interface = wbsoft_config_interface,
.configure_filter = wbsoft_configure_filter,
.get_stats = wbsoft_nop,
.get_tx_stats = wbsoft_nop,
.get_tsf = wbsoft_get_tsf,
// conf_tx: hal_set_cwmin()/hal_set_cwmax;
};
struct wbsoft_priv {
};
int __init wb35_init(void)
{
printk("[w35und]driver init\n");
return usb_register(&wb35_driver);
}
void __exit wb35_exit(void)
{
printk("[w35und]driver exit\n");
usb_deregister( &wb35_driver );
}
module_init(wb35_init);
module_exit(wb35_exit);
// Usb kernel subsystem will call this function when a new device is plugged into.
int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id_table)
{
PADAPTER Adapter;
PWBLINUX pWbLinux;
PWBUSB pWbUsb;
struct usb_host_interface *interface;
struct usb_endpoint_descriptor *endpoint;
int i, ret = -1;
u32 ltmp;
struct usb_device *udev = interface_to_usbdev(intf);
usb_get_dev(udev);
printk("[w35und]wb35_probe ->\n");
do {
for (i=0; i<(sizeof(Id_Table)/sizeof(struct usb_device_id)); i++ ) {
if ((udev->descriptor.idVendor == Id_Table[i].idVendor) &&
(udev->descriptor.idProduct == Id_Table[i].idProduct)) {
printk("[w35und]Found supported hardware\n");
break;
}
}
if ((i == (sizeof(Id_Table)/sizeof(struct usb_device_id)))) {
#ifdef _PE_USB_INI_DUMP_
WBDEBUG(("[w35und] This is not the one we are interested about\n"));
#endif
return -ENODEV;
}
// 20060630.2 Check the device if it already be opened
ret = usb_control_msg(udev, usb_rcvctrlpipe( udev, 0 ),
0x01, USB_TYPE_VENDOR|USB_RECIP_DEVICE|USB_DIR_IN,
0x0, 0x400, &ltmp, 4, HZ*100 );
if( ret < 0 )
break;
ltmp = cpu_to_le32(ltmp);
if (ltmp) // Is already initialized?
break;
Adapter = kzalloc(sizeof(ADAPTER), GFP_KERNEL);
my_adapter = Adapter;
pWbLinux = &Adapter->WbLinux;
pWbUsb = &Adapter->sHwData.WbUsb;
pWbUsb->udev = udev;
interface = intf->cur_altsetting;
endpoint = &interface->endpoint[0].desc;
if (endpoint[2].wMaxPacketSize == 512) {
printk("[w35und] Working on USB 2.0\n");
pWbUsb->IsUsb20 = 1;
}
if (!WbWLanInitialize(Adapter)) {
printk("[w35und]WbWLanInitialize fail\n");
break;
}
{
struct wbsoft_priv *priv;
struct ieee80211_hw *dev;
int res;
dev = ieee80211_alloc_hw(sizeof(*priv), &wbsoft_ops);
if (!dev) {
printk("w35und: ieee80211 alloc failed\n" );
BUG();
}
my_dev = dev;
SET_IEEE80211_DEV(dev, &udev->dev);
{
phw_data_t pHwData = &Adapter->sHwData;
unsigned char dev_addr[MAX_ADDR_LEN];
hal_get_permanent_address(pHwData, dev_addr);
SET_IEEE80211_PERM_ADDR(dev, dev_addr);
}
dev->extra_tx_headroom = 12; /* FIXME */
dev->flags = 0;
dev->channel_change_time = 1000;
// dev->max_rssi = 100;
dev->queues = 1;
static struct ieee80211_supported_band band;
band.channels = wbsoft_channels;
band.n_channels = ARRAY_SIZE(wbsoft_channels);
band.bitrates = wbsoft_rates;
band.n_bitrates = ARRAY_SIZE(wbsoft_rates);
dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band;
#if 0
wbsoft_modes[0].num_channels = 1;
wbsoft_modes[0].channels = wbsoft_channels;
wbsoft_modes[0].mode = MODE_IEEE80211B;
wbsoft_modes[0].num_rates = ARRAY_SIZE(wbsoft_rates);
wbsoft_modes[0].rates = wbsoft_rates;
res = ieee80211_register_hwmode(dev, &wbsoft_modes[0]);
BUG_ON(res);
#endif
res = ieee80211_register_hw(dev);
BUG_ON(res);
}
usb_set_intfdata( intf, Adapter );
printk("[w35und] _probe OK\n");
return 0;
} while(FALSE);
return -ENOMEM;
}
void packet_came(char *pRxBufferAddress, int PacketSize)
{
struct sk_buff *skb;
struct ieee80211_rx_status rx_status = {0};
if (!wbsoft_enabled)
return;
skb = dev_alloc_skb(PacketSize);
if (!skb) {
printk("Not enough memory for packet, FIXME\n");
return;
}
memcpy(skb_put(skb, PacketSize),
pRxBufferAddress,
PacketSize);
/*
rx_status.rate = 10;
rx_status.channel = 1;
rx_status.freq = 12345;
rx_status.phymode = MODE_IEEE80211B;
*/
ieee80211_rx_irqsafe(my_dev, skb, &rx_status);
}
unsigned char
WbUsb_initial(phw_data_t pHwData)
{
return 1;
}
void
WbUsb_destroy(phw_data_t pHwData)
{
}
int wb35_open(struct net_device *netdev)
{
PADAPTER Adapter = (PADAPTER)netdev->priv;
phw_data_t pHwData = &Adapter->sHwData;
netif_start_queue(netdev);
//TODO : put here temporarily
hal_set_accept_broadcast(pHwData, 1); // open accept broadcast
return 0;
}
int wb35_close(struct net_device *netdev)
{
netif_stop_queue(netdev);
return 0;
}
void wb35_disconnect(struct usb_interface *intf)
{
PWBLINUX pWbLinux;
PADAPTER Adapter = usb_get_intfdata(intf);
usb_set_intfdata(intf, NULL);
pWbLinux = &Adapter->WbLinux;
// Card remove
WbWlanHalt(Adapter);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Copyright (c) 1996-2004 Winbond Electronic Corporation
//
// Module Name:
// wbusb_f.h
//
// Abstract:
// Linux driver.
//
// Author:
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int wb35_open(struct net_device *netdev);
int wb35_close(struct net_device *netdev);
unsigned char WbUsb_initial(phw_data_t pHwData);
void WbUsb_destroy(phw_data_t pHwData);
unsigned char WbWLanInitialize(PADAPTER Adapter);
#define WbUsb_Stop( _A )
int wb35_probe(struct usb_interface *intf,const struct usb_device_id *id_table);
void wb35_disconnect(struct usb_interface *intf);
#define wb_usb_submit_urb(_A) usb_submit_urb(_A, GFP_ATOMIC)
#define wb_usb_alloc_urb(_A) usb_alloc_urb(_A, GFP_ATOMIC)
#define WbUsb_CheckForHang( _P )
#define WbUsb_DetectStart( _P, _I )
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Copyright (c) 1996-2004 Winbond Electronic Corporation
//
// Module Name:
// wbusb_s.h
//
// Abstract:
// Linux driver.
//
// Author:
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#define OS_SLEEP( _MT ) { set_current_state(TASK_INTERRUPTIBLE); \
schedule_timeout( _MT*HZ/1000000 ); }
//---------------------------------------------------------------------------
// RW_CONTEXT --
//
// Used to track driver-generated io irps
//---------------------------------------------------------------------------
typedef struct _RW_CONTEXT
{
void* pHwData;
PURB pUrb;
void* pCallBackFunctionParameter;
} RW_CONTEXT, *PRW_CONTEXT;
#define DRIVER_AUTHOR "Original by: Jeff Lee<YY_Lee@issc.com.tw> Adapted to 2.6.x by Costantino Leandro (Rxart Desktop) <le_costantino@pixartargentina.com.ar>"
#define DRIVER_DESC "IS89C35 802.11bg WLAN USB Driver"
typedef struct _WBUSB {
u32 IsUsb20;
struct usb_device *udev;
u32 DetectCount;
} WBUSB, *PWBUSB;
//=============================================================
// LocalPara.h -
//=============================================================
//Define the local ability
#define LOCAL_DEFAULT_BEACON_PERIOD 100 //ms
#define LOCAL_DEFAULT_ATIM_WINDOW 0
#define LOCAL_DEFAULT_ERP_CAPABILITY 0x0431 //0x0001: ESS
//0x0010: Privacy
//0x0020: short preamble
//0x0400: short slot time
#define LOCAL_DEFAULT_LISTEN_INTERVAL 5
//#define LOCAL_DEFAULT_24_CHANNEL_NUM 11 // channel 1..11
#define LOCAL_DEFAULT_24_CHANNEL_NUM 13 // channel 1..13
#define LOCAL_DEFAULT_5_CHANNEL_NUM 8 // channel 36..64
#define LOCAL_USA_24_CHANNEL_NUM 11
#define LOCAL_USA_5_CHANNEL_NUM 12
#define LOCAL_EUROPE_24_CHANNEL_NUM 13
#define LOCAL_EUROPE_5_CHANNEL_NUM 19
#define LOCAL_JAPAN_24_CHANNEL_NUM 14
#define LOCAL_JAPAN_5_CHANNEL_NUM 11
#define LOCAL_UNKNOWN_24_CHANNEL_NUM 14
#define LOCAL_UNKNOWN_5_CHANNEL_NUM 34 //not include 165
#define psLOCAL (&(Adapter->sLocalPara))
#define MODE_802_11_BG 0
#define MODE_802_11_A 1
#define MODE_802_11_ABG 2
#define MODE_802_11_BG_IBSS 3
#define MODE_802_11_B 4
#define MODE_AUTO 255
#define BAND_TYPE_DSSS 0
#define BAND_TYPE_OFDM_24 1
#define BAND_TYPE_OFDM_5 2
//refer Bitmap2RateValue table
#define LOCAL_ALL_SUPPORTED_RATES_BITMAP 0x130c1a66 //the bitmap value of all the H/W supported rates
//1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
#define LOCAL_OFDM_SUPPORTED_RATES_BITMAP 0x130c1240 //the bitmap value of all the H/W supported rates
//except to non-OFDM rates
//6, 9, 12, 18, 24, 36, 48, 54
#define LOCAL_11B_SUPPORTED_RATE_BITMAP 0x826
#define LOCAL_11B_BASIC_RATE_BITMAP 0x826
#define LOCAL_11B_OPERATION_RATE_BITMAP 0x826
#define LOCAL_11G_BASIC_RATE_BITMAP 0x826 //1, 2, 5.5, 11
#define LOCAL_11G_OPERATION_RATE_BITMAP 0x130c1240 //6, 9, 12, 18, 24, 36, 48, 54
#define LOCAL_11A_BASIC_RATE_BITMAP 0x01001040 //6, 12, 24
#define LOCAL_11A_OPERATION_RATE_BITMAP 0x120c0200 //9, 18, 36, 48, 54
#define PWR_ACTIVE 0
#define PWR_SAVE 1
#define PWR_TX_IDLE_CYCLE 6
//bPreambleMode and bSlotTimeMode
#define AUTO_MODE 0
#define LONG_MODE 1
//Region definition
#define REGION_AUTO 0xff
#define REGION_UNKNOWN 0
#define REGION_EUROPE 1 //ETSI
#define REGION_JAPAN 2 //MKK
#define REGION_USA 3 //FCC
#define REGION_FRANCE 4 //FRANCE
#define REGION_SPAIN 5 //SPAIN
#define REGION_ISRAEL 6 //ISRAEL
//#define REGION_CANADA 7 //IC
#define MAX_BSS_DESCRIPT_ELEMENT 32
#define MAX_PMKID_CandidateList 16
//High byte : Event number, low byte : reason
//Event definition
//-- SME/MLME event
#define EVENT_RCV_DEAUTH 0x0100
#define EVENT_JOIN_FAIL 0x0200
#define EVENT_AUTH_FAIL 0x0300
#define EVENT_ASSOC_FAIL 0x0400
#define EVENT_LOST_SIGNAL 0x0500
#define EVENT_BSS_DESCRIPT_LACK 0x0600
#define EVENT_COUNTERMEASURE 0x0700
#define EVENT_JOIN_FILTER 0x0800
//-- TX/RX event
#define EVENT_RX_BUFF_UNAVAILABLE 0x4100
#define EVENT_CONNECT 0x8100
#define EVENT_DISCONNECT 0x8200
#define EVENT_SCAN_REQ 0x8300
//Reason of Event
#define EVENT_REASON_FILTER_BASIC_RATE 0x0001
#define EVENT_REASON_FILTER_PRIVACY 0x0002
#define EVENT_REASON_FILTER_AUTH_MODE 0x0003
#define EVENT_REASON_TIMEOUT 0x00ff
// 20061108 WPS IE buffer
#define MAX_IE_APPEND_SIZE 256 + 4 // Due to [E id][Length][OUI][Data] may 257 bytes
typedef struct _EVENTLOG
{
u16 Count; //Total count from start
u16 index; //Buffer index, 0 ~ 63
u32 EventValue[64]; //BYTE 3~2 : count, BYTE 1 : Event, BYTE 0 : reason
} Event_Log, *pEvent_Log;
typedef struct _ChanInfo
{
u8 band;
u8 ChanNo;
} ChanInfo, *pChanInfo;
typedef struct _CHAN_LIST
{
u16 Count;
ChanInfo Channel[50]; // 100B
} CHAN_LIST, *psCHAN_LIST;
typedef struct _RadioOff
{
u8 boHwRadioOff;
u8 boSwRadioOff;
} RadioOff, *psRadioOff;
//===========================================================================
typedef struct LOCAL_PARA
{
u8 PermanentAddress[ MAC_ADDR_LENGTH + 2 ]; // read from EPROM, manufacture set for each NetCard
u8 ThisMacAddress[ MAC_ADDR_LENGTH + 2 ]; // the driver will use actually.
u32 MTUsize; // Ind to Uplayer, Max transmission unit size
u8 region_INF; //region setting from INF
u8 region; //real region setting of the device
u8 Reserved_1[2];
//// power-save variables
u8 iPowerSaveMode; // 0 indicates it is on, 1 indicates it is off
u8 ShutDowned;
u8 ATIMmode;
u8 ExcludeUnencrypted;
u16 CheckCountForPS; //Unit ime count for the decision to enter PS mode
u8 boHasTxActivity; //tx activity has occurred
u8 boMacPsValid; //Power save mode obtained from H/W is valid or not
//// Rate
u8 TxRateMode; // Initial, input from Registry, may be updated by GUI
//Tx Rate Mode: auto(DTO on), max, 1M, 2M, ..
u8 CurrentTxRate; // The current Tx rate
u8 CurrentTxRateForMng; // The current Tx rate for management frames
// It will be decided before connection succeeds.
u8 CurrentTxFallbackRate;
//for Rate handler
u8 BRateSet[32]; //basic rate set
u8 SRateSet[32]; //support rate set
u8 NumOfBRate;
u8 NumOfSRate;
u8 NumOfDsssRateInSRate; //number of DSSS rates in supported rate set
u8 reserved1;
u32 dwBasicRateBitmap; //bit map of basic rates
u32 dwSupportRateBitmap; //bit map of all support rates including
//basic and operational rates
////For SME/MLME handler
u16 wOldSTAindex; // valid when boHandover=TRUE, store old connected STA index
u16 wConnectedSTAindex; // Index of peerly connected AP or IBSS in
// the descriptionset.
u16 Association_ID; // The Association ID in the (Re)Association
// Response frame.
u16 ListenInterval; // The listen interval when SME invoking MLME_
// (Re)Associate_Request().
RadioOff RadioOffStatus;
u8 Reserved0[2];
u8 boMsRadioOff; // Ndis demands to be true when set Disassoc. OID and be false when set SSID OID.
u8 boAntennaDiversity; //TRUE/ON or FALSE/OFF
u8 bAntennaNo; //which antenna
u8 bConnectFlag; //the connect status flag for roaming task
u8 RoamStatus;
u8 reserved7[3];
ChanInfo CurrentChan; //Current channel no. and channel band. It may be changed by scanning.
u8 boHandover; // Roaming, Hnadover to other AP.
u8 boCCAbusy;
u16 CWMax; // It may not be the real value that H/W used
u8 CWMin; // 255: set according to 802.11 spec.
u8 reserved2;
//11G:
u8 bMacOperationMode; // operation in 802.11b or 802.11g
u8 bSlotTimeMode; //AUTO, s32
u8 bPreambleMode; //AUTO, s32
u8 boNonERPpresent;
u8 boProtectMechanism; // H/W will take the necessary action based on this variable
u8 boShortPreamble; // H/W will take the necessary action based on this variable
u8 boShortSlotTime; // H/W will take the necessary action based on this variable
u8 reserved_3;
u32 RSN_IE_Bitmap; //added by WS
u32 RSN_OUI_Type; //added by WS
//For the BSSID
u8 HwBssid[MAC_ADDR_LENGTH + 2];
u32 HwBssidValid;
//For scan list
u8 BssListCount; //Total count of valid descriptor indexes
u8 boReceiveUncorrectInfo; //important settings in beacon/probe resp. have been changed
u8 NoOfJoinerInIbss;
u8 reserved_4;
u8 BssListIndex[ (MAX_BSS_DESCRIPT_ELEMENT+3) & ~0x03 ]; //Store the valid descriptor indexes obtained from scannings
u8 JoinerInIbss[ (MAX_BSS_DESCRIPT_ELEMENT+3) & ~0x03 ]; //save the BssDescriptor index in this
//IBSS. The index 0 is local descriptor
//(psLOCAL->wConnectedSTAindex).
//If CONNECTED : NoOfJoinerInIbss >=2
// else : NoOfJoinerInIbss <=1
//// General Statistics, count at Rx_handler or Tx_callback interrupt handler
u64 GS_XMIT_OK; // Good Frames Transmitted
u64 GS_RCV_OK; // Good Frames Received
u32 GS_RCV_ERROR; // Frames received with crc error
u32 GS_XMIT_ERROR; // Bad Frames Transmitted
u32 GS_RCV_NO_BUFFER; // Receive Buffer underrun
u32 GS_XMIT_ONE_COLLISION; // one collision
u32 GS_XMIT_MORE_COLLISIONS;// more collisions
//================================================================
// Statistics (no matter whether it had done successfully) -wkchen
//================================================================
u32 _NumRxMSDU;
u32 _NumTxMSDU;
u32 _dot11WEPExcludedCount;
u32 _dot11WEPUndecryptableCount;
u32 _dot11FrameDuplicateCount;
ChanInfo IbssChanSetting; // 2B. Start IBSS Channel setting by registry or WWU.
u8 reserved_5[2]; //It may not be used after considering RF type,
//region and modulation type.
CHAN_LIST sSupportChanList; // 86B. It will be obtained according to RF type and region
u8 reserved_6[2]; //two variables are for wep key error detection added by ws 02/02/04
u32 bWepKeyError;
u32 bToSelfPacketReceived;
u32 WepKeyDetectTimerCount;
Event_Log EventLog;
u16 SignalLostTh;
u16 SignalRoamTh;
// 20061108 WPS IE Append
u8 IE_Append_data[MAX_IE_APPEND_SIZE];
u16 IE_Append_size;
u16 reserved_7;
} WB_LOCALDESCRIPT, *PWB_LOCALDESCRIPT;
This diff is collapsed.
This diff is collapsed.
unsigned char Mds_initial( PADAPTER Adapter );
void Mds_Destroy( PADAPTER Adapter );
void Mds_Tx( PADAPTER Adapter );
void Mds_HeaderCopy( PADAPTER Adapter, PDESCRIPTOR pDes, PUCHAR TargetBuffer );
u16 Mds_BodyCopy( PADAPTER Adapter, PDESCRIPTOR pDes, PUCHAR TargetBuffer );
void Mds_DurationSet( PADAPTER Adapter, PDESCRIPTOR pDes, PUCHAR TargetBuffer );
void Mds_SendComplete( PADAPTER Adapter, PT02_DESCRIPTOR pT02 );
void Mds_MpduProcess( PADAPTER Adapter, PDESCRIPTOR pRxDes );
void Mds_reset_descriptor( PADAPTER Adapter );
extern void DataDmp(u8 *pdata, u32 len, u32 offset);
void vRxTimerInit(PWB32_ADAPTER Adapter);
void vRxTimerStart(PWB32_ADAPTER Adapter, int timeout_value);
void RxTimerHandler_1a( PADAPTER Adapter);
void vRxTimerStop(PWB32_ADAPTER Adapter);
void RxTimerHandler( void* SystemSpecific1,
PWB32_ADAPTER Adapter,
void* SystemSpecific2,
void* SystemSpecific3);
// For Asynchronous indicating. The routine collocates with USB.
void Mds_MsduProcess( PWB32_ADAPTER Adapter, PRXLAYER1 pRxLayer1, u8 SlotIndex);
// For data frame sending 20060802
u16 MDS_GetPacketSize( PADAPTER Adapter );
void MDS_GetNextPacket( PADAPTER Adapter, PDESCRIPTOR pDes );
void MDS_GetNextPacketComplete( PADAPTER Adapter, PDESCRIPTOR pDes );
void MDS_SendResult( PADAPTER Adapter, u8 PacketId, unsigned char SendOK );
void MDS_EthernetPacketReceive( PADAPTER Adapter, PRXLAYER1 pRxLayer1 );
////////////////////////////////////////////////////////////////////////////////////////////////////////
#define MAX_USB_TX_DESCRIPTOR 15 // IS89C35 ability
#define MAX_USB_TX_BUFFER_NUMBER 4 // Virtual pre-buffer number of MAX_USB_TX_BUFFER
#define MAX_USB_TX_BUFFER 4096 // IS89C35 ability 4n alignment is required for hardware
#define MDS_EVENT_INDICATE( _A, _B, _F ) OS_EVENT_INDICATE( _A, _B, _F )
#define AUTH_REQUEST_PAIRWISE_ERROR 0 // _F flag setting
#define AUTH_REQUEST_GROUP_ERROR 1 // _F flag setting
// For variable setting
#define CURRENT_BSS_TYPE psBSS(psLOCAL->wConnectedSTAindex)->bBssType
#define CURRENT_WEP_MODE psSME->_dot11PrivacyInvoked
#define CURRENT_BSSID psBSS(psLOCAL->wConnectedSTAindex)->abBssID
#define CURRENT_DESIRED_WPA_ENABLE ((psSME->bDesiredAuthMode==WPA_AUTH)||(psSME->bDesiredAuthMode==WPAPSK_AUTH))
#ifdef _WPA2_
#define CURRENT_DESIRED_WPA2_ENABLE ((psSME->bDesiredAuthMode==WPA2_AUTH)||(psSME->bDesiredAuthMode==WPA2PSK_AUTH))
#endif //end def _WPA2_
#define CURRENT_PAIRWISE_KEY_OK psSME->pairwise_key_ok
//[20040712 WS]
#define CURRENT_GROUP_KEY_OK psSME->group_key_ok
#define CURRENT_PAIRWISE_KEY psSME->tx_mic_key
#define CURRENT_GROUP_KEY psSME->group_tx_mic_key
#define CURRENT_ENCRYPT_STATUS psSME->encrypt_status
#define CURRENT_WEP_ID Adapter->sSmePara._dot11WEPDefaultKeyID
#define CURRENT_CONTROL_PORT_BLOCK ( psSME->wpa_ok!=1 || (Adapter->Mds.boCounterMeasureBlock==1 && (CURRENT_ENCRYPT_STATUS==ENCRYPT_TKIP)) )
#define CURRENT_FRAGMENT_THRESHOLD (Adapter->Mds.TxFragmentThreshold & ~0x1)
#define CURRENT_PREAMBLE_MODE psLOCAL->boShortPreamble?WLAN_PREAMBLE_TYPE_SHORT:WLAN_PREAMBLE_TYPE_LONG
#define CURRENT_LINK_ON OS_LINK_STATUS
#define CURRENT_TX_RATE Adapter->sLocalPara.CurrentTxRate
#define CURRENT_FALL_BACK_TX_RATE Adapter->sLocalPara.CurrentTxFallbackRate
#define CURRENT_TX_RATE_FOR_MNG Adapter->sLocalPara.CurrentTxRateForMng
#define CURRENT_PROTECT_MECHANISM psLOCAL->boProtectMechanism
#define CURRENT_RTS_THRESHOLD Adapter->Mds.TxRTSThreshold
#define MIB_GS_XMIT_OK_INC Adapter->sLocalPara.GS_XMIT_OK++
#define MIB_GS_RCV_OK_INC Adapter->sLocalPara.GS_RCV_OK++
#define MIB_GS_XMIT_ERROR_INC Adapter->sLocalPara.GS_XMIT_ERROR
//---------- TX -----------------------------------
#define ETHERNET_TX_DESCRIPTORS MAX_USB_TX_BUFFER_NUMBER
//---------- RX ------------------------------------
#define ETHERNET_RX_DESCRIPTORS 8 //It's not necessary to allocate more than 2 in sync indicate
//================================================================
// Configration default value
//================================================================
#define DEFAULT_MULTICASTLISTMAX 32 // standard
#define DEFAULT_TX_BURSTLENGTH 3 // 32 Longwords
#define DEFAULT_RX_BURSTLENGTH 3 // 32 Longwords
#define DEFAULT_TX_THRESHOLD 0 // Full Packet
#define DEFAULT_RX_THRESHOLD 0 // Full Packet
#define DEFAULT_MAXTXRATE 6 // 11 Mbps (Long)
#define DEFAULT_CHANNEL 3 // Chennel 3
#define DEFAULT_RTSThreshold 2347 // Disable RTS
//#define DEFAULT_PME 1 // Enable
#define DEFAULT_PME 0 // Disable
#define DEFAULT_SIFSTIME 10
#define DEFAULT_ACKTIME_1ML 304 // 148+44+112 911220 by LCC
#define DEFAULT_ACKTIME_2ML 248 // 148+44+56 911220 by LCC
#define DEFAULT_FRAGMENT_THRESHOLD 2346 // No fragment
#define DEFAULT_PREAMBLE_LENGTH 72
#define DEFAULT_PLCPHEADERTIME_LENGTH 24
/*------------------------------------------------------------------------
0.96 sec since time unit of the R03 for the current, W89C32 is about 60ns
instead of 960 ns. This shall be fixed in the future W89C32
-------------------------------------------------------------------------*/
#define DEFAULT_MAX_RECEIVE_TIME 16440000
#define RX_BUF_SIZE 2352 // 600 // For 301 must be multiple of 8
#define MAX_RX_DESCRIPTORS 18 // Rx Layer 2
#define MAX_BUFFER_QUEUE 8 // The value is always equal 8 due to NDIS_PACKET's MiniportReserved field size
// For brand-new rx system
#define MDS_ID_IGNORE ETHERNET_RX_DESCRIPTORS
// For Tx Packet status classify
#define PACKET_FREE_TO_USE 0
#define PACKET_COME_FROM_NDIS 0x08
#define PACKET_COME_FROM_MLME 0x80
#define PACKET_SEND_COMPLETE 0xff
typedef struct _MDS
{
// For Tx usage
u8 TxOwner[ ((MAX_USB_TX_BUFFER_NUMBER + 3) & ~0x03) ];
PUCHAR pTxBuffer;
u16 TxBufferSize[ ((MAX_USB_TX_BUFFER_NUMBER + 1) & ~0x01) ];
u8 TxDesFrom[ ((MAX_USB_TX_DESCRIPTOR + 3) & ~0x03) ];//931130.4.u // 1: MLME 2: NDIS control 3: NDIS data
u8 TxCountInBuffer[ ((MAX_USB_TX_DESCRIPTOR + 3) & ~0x03) ]; // 20060928
u8 TxFillIndex;//the next index of TxBuffer can be used
u8 TxDesIndex;//The next index of TxDes can be used
u8 ScanTxPause; //data Tx pause because the scanning is progressing, but probe request Tx won't.
u8 TxPause;//For pause the Mds_Tx modult
OS_ATOMIC TxThreadCount;//For thread counting 931130.4.v
//950301 delete due to HW
// OS_ATOMIC TxConcurrentCount;//931130.4.w
u16 TxResult[ ((MAX_USB_TX_DESCRIPTOR + 1) & ~0x01) ];//Collect the sending result of Mpdu
u8 MicRedundant[8]; // For tmp use
PUCHAR MicWriteAddress[2]; //The start address to fill the Mic, use 2 point due to Mic maybe fragment
u16 MicWriteSize[2]; //931130.4.x
u16 MicAdd; // If want to add the Mic, this variable equal to 8
u16 MicWriteIndex;//The number of MicWriteAddress 931130.4.y
u8 TxRate[ ((MAX_USB_TX_DESCRIPTOR+1)&~0x01) ][2]; // [0] current tx rate, [1] fall back rate
u8 TxInfo[ ((MAX_USB_TX_DESCRIPTOR+1)&~0x01) ]; //Store information for callback function
//WKCHEN added for scanning mechanism
u8 TxToggle; //It is TRUE if there are tx activities in some time interval
u8 Reserved_[3];
//---------- for Tx Parameter
u16 TxFragmentThreshold; // For frame body only
u16 TxRTSThreshold;
u32 MaxReceiveTime;//911220.3 Add
// depend on OS,
u32 MulticastListNo;
u32 PacketFilter; // Setting by NDIS, the current packet filter in use.
u8 MulticastAddressesArray[DEFAULT_MULTICASTLISTMAX][MAC_ADDR_LENGTH];
//COUNTERMEASURE
u8 bMICfailCount;
u8 boCounterMeasureBlock;
u8 reserved_4[2];
//NDIS_MINIPORT_TIMER nTimer;
OS_TIMER nTimer;
u32 TxTsc; // 20060214
u32 TxTsc_2; // 20060214
} MDS, *PMDS;
typedef struct _RxBuffer
{
PUCHAR pBufferAddress; // Pointer the received data buffer.
u16 BufferSize;
u8 RESERVED;
u8 BufferIndex;// Only 1 byte
} RXBUFFER, *PRXBUFFER;
//
// Reveive Layer 1 Format.
//----------------------------
typedef struct _RXLAYER1
{
u16 SequenceNumber; // The sequence number of the last received packet.
u16 BufferTotalSize;
u32 InUsed;
u32 DecryptionMethod; // The desired defragment number of the next incoming packet.
u8 DeFragmentNumber;
u8 FrameType;
u8 TypeEncapsulated;
u8 BufferNumber;
u32 FirstFrameArrivedTime;
RXBUFFER BufferQueue[ MAX_BUFFER_QUEUE ];
u8 LastFrameType; // 20061004 for fix intel 3945 's bug
u8 RESERVED[3]; //@@ anson
/////////////////////////////////////////////////////////////////////////////////////////////
// For brand-new Rx system
u8 ReservedBuffer[ 2400 ];//If Buffer ID is reserved one, it must copy the data into this area
PUCHAR ReservedBufferPoint;// Point to the next availabe address of reserved buffer
}RXLAYER1, * PRXLAYER1;
//============================================================================
// MLMEMIB.H -
//
// Description:
// Get and Set some of MLME MIB attributes.
//
// Revision history:
// --------------------------------------------------------------------------
// 20030117 PD43 Austin Liu
// Initial release
//
// Copyright (c) 2003 Winbond Electronics Corp. All rights reserved.
//============================================================================
#ifndef _MLME_MIB_H
#define _MLME_MIB_H
//============================================================================
// MLMESetExcludeUnencrypted --
//
// Description:
// Set the dot11ExcludeUnencrypted value.
//
// Arguments:
// Adapter - The pointer to the miniport adapter context.
// ExUnencrypted - unsigned char type. The value to be set.
//
// Return values:
// None.
//============================================================================
#define MLMESetExcludeUnencrypted(Adapter, ExUnencrypted) \
{ \
(Adapter)->sLocalPara.ExcludeUnencrypted = ExUnencrypted; \
}
//============================================================================
// MLMEGetExcludeUnencrypted --
//
// Description:
// Get the dot11ExcludeUnencrypted value.
//
// Arguments:
// Adapter - The pointer to the miniport adapter context.
//
// Return values:
// unsigned char type. The current dot11ExcludeUnencrypted value.
//============================================================================
#define MLMEGetExcludeUnencrypted(Adapter) ((unsigned char) (Adapter)->sLocalPara.ExcludeUnencrypted)
//============================================================================
// MLMESetMaxReceiveLifeTime --
//
// Description:
// Set the dot11MaxReceiveLifeTime value.
//
// Arguments:
// Adapter - The pointer to the miniport adapter context.
// ReceiveLifeTime- u32 type. The value to be set.
//
// Return values:
// None.
//============================================================================
#define MLMESetMaxReceiveLifeTime(Adapter, ReceiveLifeTime) \
{ \
(Adapter)->Mds.MaxReceiveTime = ReceiveLifeTime; \
}
//============================================================================
// MLMESetMaxReceiveLifeTime --
//
// Description:
// Get the dot11MaxReceiveLifeTime value.
//
// Arguments:
// Adapter - The pointer to the miniport adapter context.
//
// Return values:
// u32 type. The current dot11MaxReceiveLifeTime value.
//============================================================================
#define MLMEGetMaxReceiveLifeTime(Adapter) ((u32) (Adapter)->Mds.MaxReceiveTime)
#endif
This diff is collapsed.
//============================================================================
// Module Name:
// MLMETxRx.C
//
// Description:
// The interface between MDS (MAC Data Service) and MLME.
//
// Revision History:
// --------------------------------------------------------------------------
// 200209 UN20 Jennifer Xu
// Initial Release
// 20021108 PD43 Austin Liu
// 20030117 PD43 Austin Liu
// Deleted MLMEReturnPacket and MLMEProcThread()
//
// Copyright (c) 1996-2002 Winbond Electronics Corp. All Rights Reserved.
//============================================================================
#include "os_common.h"
void MLMEResetTxRx(PWB32_ADAPTER Adapter)
{
s32 i;
// Reset the interface between MDS and MLME
for (i = 0; i < MAX_NUM_TX_MMPDU; i++)
Adapter->sMlmeFrame.TxMMPDUInUse[i] = FALSE;
for (i = 0; i < MAX_NUM_RX_MMPDU; i++)
Adapter->sMlmeFrame.SaveRxBufSlotInUse[i] = FALSE;
Adapter->sMlmeFrame.wNumRxMMPDUInMLME = 0;
Adapter->sMlmeFrame.wNumRxMMPDUDiscarded = 0;
Adapter->sMlmeFrame.wNumRxMMPDU = 0;
Adapter->sMlmeFrame.wNumTxMMPDUDiscarded = 0;
Adapter->sMlmeFrame.wNumTxMMPDU = 0;
Adapter->sLocalPara.boCCAbusy = FALSE;
Adapter->sLocalPara.iPowerSaveMode = PWR_ACTIVE; // Power active
}
//=============================================================================
// Function:
// MLMEGetMMPDUBuffer()
//
// Description:
// Return the pointer to an available data buffer with
// the size MAX_MMPDU_SIZE for a MMPDU.
//
// Arguments:
// Adapter - pointer to the miniport adapter context.
//
// Return value:
// NULL : No available data buffer available
// Otherwise: Pointer to the data buffer
//=============================================================================
/* FIXME: Should this just be replaced with kmalloc() and kfree()? */
u8 *MLMEGetMMPDUBuffer(PWB32_ADAPTER Adapter)
{
s32 i;
u8 *returnVal;
for (i = 0; i< MAX_NUM_TX_MMPDU; i++) {
if (Adapter->sMlmeFrame.TxMMPDUInUse[i] == FALSE)
break;
}
if (i >= MAX_NUM_TX_MMPDU) return NULL;
returnVal = (u8 *)&(Adapter->sMlmeFrame.TxMMPDU[i]);
Adapter->sMlmeFrame.TxMMPDUInUse[i] = TRUE;
return returnVal;
}
//=============================================================================
u8 MLMESendFrame(PWB32_ADAPTER Adapter, u8 *pMMPDU, u16 len, u8 DataType)
/* DataType : FRAME_TYPE_802_11_MANAGEMENT, FRAME_TYPE_802_11_MANAGEMENT_CHALLENGE,
FRAME_TYPE_802_11_DATA */
{
if (Adapter->sMlmeFrame.IsInUsed != PACKET_FREE_TO_USE) {
Adapter->sMlmeFrame.wNumTxMMPDUDiscarded++;
return FALSE;
}
Adapter->sMlmeFrame.IsInUsed = PACKET_COME_FROM_MLME;
// Keep information for sending
Adapter->sMlmeFrame.pMMPDU = pMMPDU;
Adapter->sMlmeFrame.DataType = DataType;
// len must be the last setting due to QUERY_SIZE_SECOND of Mds
Adapter->sMlmeFrame.len = len;
Adapter->sMlmeFrame.wNumTxMMPDU++;
// H/W will enter power save by set the register. S/W don't send null frame
//with PWRMgt bit enbled to enter power save now.
// Transmit NDIS packet
Mds_Tx(Adapter);
return TRUE;
}
void
MLME_GetNextPacket(PADAPTER Adapter, PDESCRIPTOR pDes)
{
#define DESCRIPTOR_ADD_BUFFER( _D, _A, _S ) \
{\
_D->InternalUsed = _D->buffer_start_index + _D->buffer_number; \
_D->InternalUsed %= MAX_DESCRIPTOR_BUFFER_INDEX; \
_D->buffer_address[ _D->InternalUsed ] = _A; \
_D->buffer_size[ _D->InternalUsed ] = _S; \
_D->buffer_total_size += _S; \
_D->buffer_number++;\
}
DESCRIPTOR_ADD_BUFFER( pDes, Adapter->sMlmeFrame.pMMPDU, Adapter->sMlmeFrame.len );
pDes->Type = Adapter->sMlmeFrame.DataType;
}
void MLMEfreeMMPDUBuffer(PWB32_ADAPTER Adapter, PCHAR pData)
{
int i;
// Reclaim the data buffer
for (i = 0; i < MAX_NUM_TX_MMPDU; i++) {
if (pData == (PCHAR)&(Adapter->sMlmeFrame.TxMMPDU[i]))
break;
}
if (Adapter->sMlmeFrame.TxMMPDUInUse[i])
Adapter->sMlmeFrame.TxMMPDUInUse[i] = FALSE;
else {
// Something wrong
// PD43 Add debug code here???
}
}
void
MLME_SendComplete(PADAPTER Adapter, u8 PacketID, unsigned char SendOK)
{
MLME_TXCALLBACK TxCallback;
// Reclaim the data buffer
Adapter->sMlmeFrame.len = 0;
MLMEfreeMMPDUBuffer( Adapter, Adapter->sMlmeFrame.pMMPDU );
TxCallback.bResult = MLME_SUCCESS;
// Return resource
Adapter->sMlmeFrame.IsInUsed = PACKET_FREE_TO_USE;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
extern void MTO_Init(PWB32_ADAPTER);
extern void MTO_PeriodicTimerExpired(PWB32_ADAPTER);
extern void MTO_SetDTORateRange(PWB32_ADAPTER, u8 *, u8);
extern u8 MTO_GetTxRate(MTO_FUNC_INPUT, u32 fpdu_len);
extern u8 MTO_GetTxFallbackRate(MTO_FUNC_INPUT);
extern void MTO_SetTxCount(MTO_FUNC_INPUT, u8 t0, u8 index);
#include "linux/sysdef.h"
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
//------------------------------------------------------------------------------------
// sme_api.c
//
// Copyright(C) 2002 Winbond Electronics Corp.
//
//
//------------------------------------------------------------------------------------
#include "os_common.h"
s8 sme_get_rssi(void *pcore_data, s32 *prssi)
{
BUG();
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment