diff -ruN rt2570-1.1.0-b1/CHANGELOG rt2570-cvs-2005122616/CHANGELOG --- rt2570-1.1.0-b1/CHANGELOG 2005-07-30 11:44:48.000000000 -0500 +++ rt2570-cvs-2005122616/CHANGELOG 2005-12-06 02:24:45.000000000 -0600 @@ -22,6 +22,17 @@ Changelog for 802.11g rt2570 USB driver + Version: CVS + * Bugfix to allow multiple rt2570 devices + * Fix for module unloading under 2.4 kernel + * Fix for signal quality reporting (1247985) + * Enhancement for TX during RFMON (i.e. aireplay support) + * Prism Headers in RFMON + * Added new USB devices (F5D7050, Linksys@Home) + * Bugfix : race condition between thread stop and incoming mlme commands + (Mathieu Desnoyers mathieu.desnoyers@polymtl.ca) + + Version: 1.1.0-beta1 * Initial baseline code from Ralink (2.0.3.0) * Added new USB devices (F5D7060,UB801R,C54RU,MSI6861,GN-WBKG) diff -ruN rt2570-1.1.0-b1/Module/connect.c rt2570-cvs-2005122616/Module/connect.c --- rt2570-1.1.0-b1/Module/connect.c 2005-07-30 11:44:30.000000000 -0500 +++ rt2570-cvs-2005122616/Module/connect.c 2005-12-02 06:55:15.000000000 -0600 @@ -1282,8 +1282,13 @@ ULONG BulkOutLength; PTX_CONTEXT pBeaconContext = &(pAd->BeaconContext[0]); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if (pAd->MLMEThr_pid <= 0) return; +#else + if (!pAd->MLMEThr_active) + return; +#endif // 2003-12-10 802.11g WIFI spec disallow OFDM rates in 802.11g ADHOC mode // make sure 1,2,5.5,11 are the firt 4 rates in PortCfg.SupportedRates[] array if ((pAd->PortCfg.PhyMode == PHY_11BG_MIXED) && (pAd->PortCfg.AdhocMode == 0)) diff -ruN rt2570-1.1.0-b1/Module/iwpriv_usage.txt rt2570-cvs-2005122616/Module/iwpriv_usage.txt --- rt2570-1.1.0-b1/Module/iwpriv_usage.txt 2005-07-30 11:44:30.000000000 -0500 +++ rt2570-cvs-2005122616/Module/iwpriv_usage.txt 2005-11-30 07:43:27.000000000 -0600 @@ -1,151 +1,70 @@ - -This file provides some basic examples on the configuration of the driver using standard linux wireless tools. Where possible iwconfig should be used to adjust settings. Some settings are currently not avaiable via iwconfig and these include WPA, for these functions it is currently necessary to use iwpriv. - - -Configuration Examples -=================================================================== -------------------------------------------------------------------------------------------------------- -Example I: Config STA to link with AP which is OPEN/NONE(Authentication/Encryption) - 1. iwconfig ra0 mode managed - 2. iwconfig ra0 key open - 3. iwconfig ra0 key off - 4. iwconfig ra0 essid "AP's SSID" - -Example II: Config STA to link with AP which is SHARED/WEP(Authentication/Encryption) - 1. iwconfig ra0 mode managed - 2. iwconfig ra0 key restricted - 3. iwconfig ra0 Key [1] "s:AP's wep key" - 4. iwconfig ra0 key [1] - 5. iwconfig ra0 essid "AP's SSID" - -Example III: Config STA to create/link as adhoc mode - 1. iwconfig ra0 mode ad-hoc - 2. iwconfig ra0 key off - 4. iwconfig ra0 essid "AP's SSID" - -Example IV: Config STA to link with AP which is WPAPSK/TKIP(Authentication/Encryption) - 1. iwconfig ra0 mode managed - 2. iwpriv ra0 set AuthMode=WPAPSK - 3. iwpriv ra0 set EncrypType=TKIP - 4. iwpriv ra0 set WPAPSK="AP's wpa-preshared key" - 5. iwconfig ra0 essid "AP's SSID" - -Example V: Config STA to link with AP which is WPAPSK/AES(Authentication/Encryption) - 1. iwconfig ra0 mode managed - 2. iwpriv ra0 set AuthMode=WPAPSK - 3. iwpriv ra0 set EncrypType=AES - 5. iwpriv ra0 set WPAPSK="AP's wpa-preshared key" - 6. iwconfig ra0 essid "AP's SSID" - - - -iwpriv -================= -This is detailed explanation of each parameters for iwpriv. -Before reading this document, make sure you already read README. - -------------------------------------------------------------------------------------------------------- -USAGE: - iwpriv ra0 set [parameters]=[val] - -where - -[parameters] [val] range explaination ------------------ ----------------------- --------------------------------------------- -CountryRegion {0~7} Set country region - 0: use 1 ~ 11 Channel - 1: use 1 ~ 11 Channel - 2: use 1 ~ 13 Channel - 3: use 10, 11 Channel - 4: use 10 ~ 13 Channel - 5: use 14 Channel - 6: use 1 ~ 14 Channel - 7: use 3 ~ 9 Channel - -WirelessMode {0~2} Set Wireless Mode - 0:11b/g mixed, 1:11B only - -TxRate {0~12} Set TxRate - 0:Auto, 1:1Mbps, 2:2Mbps, 3:5.5Mbps, 4:11Mbps, - 5:6Mbps, 6:9Mbps, 7:12Mbps, 8:18Mbps, 9:24Mbps, - 10:36Mbps, 11:48Mbps, 12:54Mbps - -BGProtection {0~2} Set 11B/11G Protection - 0:Auto, 1:Always on, 2:Always off - -TxPreamble {0~2} Set TxPreamble - 0:Preamble Long, 1:Preamble Short, 2:Auto - -TxBurst {0,1} Set TxBurst Enable or Disable - 0:Disable, 1:Enable - -TurboRate {0,1} Set TurboRate Enable or Disable - 0:Disable, 1:Enable - -AdhocOfdm {0, 1} Set Adhoc mode tx rate - 0: adhere WIFI spec., 1: violate WIFI spec. - (802.11g WIFI spec disallow OFDM rates in 802.11g ADHOC mode) - AuthMode {OPEN,SHARED,WPAPSK} Set Authentication mode - -EncrypType {NONE,WEP,TKIP,AES} Set Encryption Type - -WPAPSK {8~63 ASCII or 64 HEX characters} WPA Pre-Shared Key - -ApClient {0,1} Set ApClient mode - 0:Disable, 1:Enable - -iwlist -================= -This is detailed explanation of each parameters for iwlist. - -------------------------------------------------------------------------------------------------------- - -iwlist ra0 scanning ; list the result after scanning(site survey) - - - - ----------------------------------------------------------------------------------------------------------------------------------- - - -Deprecated iwpriv -================= - -*** PLEASE DO NOT USE THESE FUNCTIONS, THIS IS FOR HISTORICAL REFERENCE ONLY *** -As the configuration utility still uses some iwpriv commands they have not been -removed from the driver yet. These commands are likely to dissapear if the utility is -updated. - -** ALL THESE COMMANDS HAVE A IWCONFIG REPLACEMENT, USE IT **** - -SSID {0~z, less than 32 characters} Set SoftAP SSID - -Channel {1~14} depends on country region Set Channel - -RTSThreshold {1~2347} Set RTS Threshold - -FragThreshold {256~2346} Set Fragment Threshold - -NetworkType {Infra,Adhoc} Set Network type - -DefaultKeyID {1~4} Set Default Key ID - -Key1 {5 ascii characters or Set Key1 String - 10 hex number or - 13 ascii characters or - 26 hex numbers} - -Key2 {5 ascii characters or Set Key2 String - 10 hex number or - 13 ascii characters or - 26 hex numbers} - -Key3 {5 ascii characters or Set Key3 String - 10 hex number or - 13 ascii characters or - 26 hex numbers} - -Key4 {5 ascii characters or Set Key4 String - 10 hex number or - 13 ascii characters or - 26 hex numbers} +iwpriv +================= +This is detailed explanation of each parameters for iwpriv. +Before reading this document, make sure you already read README. + +------------------------------------------------------------------------------------------------------- +USAGE: + iwpriv rausb0 set [parameters]=[val] + +where + +[parameters] [val] range explaination +----------------- ----------------------- --------------------------------------------- +auth 0~2 0:open + 1:shared + 2:wpapsk + 3:wpanone + +keyid 1~4 wep key id + +enc 1~3 1:none + 2:wep + 3:tkip + +wpapsk 8~63 chars WPAPSK password + +adhocmode 0~2 0: Plain 11Mbps + mode in + Ad-Hoc + (IEEE + 802.11g + standard) + 1: Auto mode + in Ad-Hoc + (violates + IEEE 802.11g + standard) + 2: 54Mbps only. + +Examples +=================================================================== +------------------------------------------------------------------------------------------------------- +Example I: Config STA to link with AP which is OPEN/NONE(Authentication/Encryption) + 1. iwconfig rausb0 mode Managed + 2. iwconfig rausb0 enc none + 3. iwconfig rausb0 essid "AP's SSID" + +Example II: Config STA to link with AP which is OPEN/WEP(Authentication/Encryption) + 1. iwconfig rausb0 enc s:abcde + 2. iwconfig rausb0 essid "AP's SSID" + + +Example III: Config STA to link with AP which is WPAPSK/TKIP(Authentication/Encryption) + 1. iwpriv rausb0 enc 3 + 2. iwconfig rausb0 essid "AP's SSID" + 3. iwpriv rausb0 wpapsk 12345678 + 4. iwconfig rausb0 essid "AP's SSID" + +p.s Step 2 is part of generating wpapsk password and is necessary. + +NOTE: + +iwlist +================= +This is detailed explanation of each parameters for iwlist. + +------------------------------------------------------------------------------------------------------- + +iwlist rausb0 scanning ; list the result after scanning(site survey) + diff -ruN rt2570-1.1.0-b1/Module/Makefile rt2570-cvs-2005122616/Module/Makefile --- rt2570-1.1.0-b1/Module/Makefile 2005-07-30 11:44:30.000000000 -0500 +++ rt2570-cvs-2005122616/Module/Makefile 2005-10-23 07:24:29.000000000 -0500 @@ -73,6 +73,12 @@ MODULE_ROOT := /lib/modules/$(shell uname -r)/extra endif +ifdef KERNOUT + KERNEL_OUTPUT := KBUILD_OUTPUT=$(KERNOUT) +else + KERNEL_OUTPUT := +endif + src ?= . obj ?= . @@ -89,7 +95,7 @@ $(LD) $(EXTRA_LDFLAGS) -r -o $@ $($(MODULE_NAME)-objs) endif -KBUILD_PARAMS := -C $(KERNEL_SOURCES) SUBDIRS=$(PWD) +KBUILD_PARAMS := -C $(KERNEL_SOURCES) SUBDIRS=$(PWD) $(KERNEL_OUTPUT) module: @$(MAKE) $(KBUILD_PARAMS) modules; \ @@ -98,6 +104,20 @@ exit 1; \ fi +arm: + @$(MAKE) $(KBUILD_PARAMS) 'EXTRA_CFLAGS=-mstructure-size-boundary=8 -I$(src)' modules; + if ! [ -f $(MODULE_OBJECT) ]; then \ + echo "$(MODULE_OBJECT) failed to build!"; \ + exit 1; \ + fi + +armdebug: + @$(MAKE) $(KBUILD_PARAMS) 'EXTRA_CFLAGS=-mstructure-size-boundary=8 -I$(src) -DRT2500_DBG' modules; + if ! [ -f $(MODULE_OBJECT) ]; then \ + echo "$(MODULE_OBJECT) failed to build!"; \ + exit 1; \ + fi + debug: @$(MAKE) $(KBUILD_PARAMS) 'EXTRA_CFLAGS=-I$(src) -DRT2500_DBG' modules; \ if ! [ -f $(MODULE_OBJECT) ]; then \ @@ -122,8 +142,10 @@ else echo "2.6 module install" make $(KBUILD_PARAMS) modules_install + /sbin/depmod -a endif + install: modules_install @if ! grep -q 'rausb0' $(MODULE_CONF) ; then \ echo "append 'alias rausb0 rt2570' to $(MODULE_CONF)"; \ diff -ruN rt2570-1.1.0-b1/Module/mlme.c rt2570-cvs-2005122616/Module/mlme.c --- rt2570-1.1.0-b1/Module/mlme.c 2005-07-30 11:44:30.000000000 -0500 +++ rt2570-cvs-2005122616/Module/mlme.c 2005-12-02 06:55:15.000000000 -0600 @@ -31,6 +31,7 @@ * Name Date Modification logs * Jan Lee 2005-06-01 Release * MathiasK 09-07-2005 kmalloc ATOMIC fixes + * RobinC 31-08-2005 Block mlme in MONITOR mode to keep from sending probe requests ***************************************************************************/ #include "rt_config.h" @@ -368,7 +369,7 @@ break; } //From message type, determine which state machine I should drive - if (MlmeDequeue(&pAd->Mlme.Queue, &Elem)) + if (MlmeDequeue(&pAd->Mlme.Queue, &Elem) && pAd->PortCfg.BssType!=BSS_MONITOR) { // if dequeue success switch (Elem->Machine) @@ -1083,7 +1084,7 @@ Csr18.field.Offset = (temp & 0x000F); Csr18.field.Interval = (temp >> 6); RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); - DBGPRINT_RAW(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); + DBGPRINT(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); pAd->BeaconIntervalChangeAllowed = FALSE; } @@ -1093,7 +1094,7 @@ Csr18.field.Offset = (temp & 0x000F); Csr18.field.Interval = (temp >> 6); RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); - DBGPRINT_RAW(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); + DBGPRINT(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); pAd->BeaconIntervalChangeAllowed = FALSE; } @@ -1103,7 +1104,7 @@ Csr18.field.Offset = (temp & 0x000F); Csr18.field.Interval = (temp >> 6); RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); - DBGPRINT_RAW(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); + DBGPRINT(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); pAd->BeaconIntervalChangeAllowed = FALSE; } @@ -1114,7 +1115,7 @@ Csr18.field.Offset = (temp & 0x000F); Csr18.field.Interval = (temp >> 6); RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); - DBGPRINT_RAW(RT_DEBUG_TRACE, ("TXRX_CSR18 = 0x%x\n", Csr18.value)); + DBGPRINT(RT_DEBUG_TRACE, ("TXRX_CSR18 = 0x%x\n", Csr18.value)); pAd->BeaconIntervalChangeAllowed = FALSE; } @@ -1123,7 +1124,7 @@ #if 0 else if (pAd->ReceivedBeaconsCount > 9 * pAd->SentBeaconsCount) { - DBGPRINT_RAW(RT_DEBUG_TRACE, ("Do Nothing\n")); + DBGPRINT(RT_DEBUG_TRACE, ("Do Nothing\n")); } #endif else @@ -1132,7 +1133,7 @@ Csr18.field.Offset = (temp & 0x000F); Csr18.field.Interval = (temp >> 6); RTUSBWriteMACRegister(pAd, TXRX_CSR18, Csr18.value); - DBGPRINT_RAW(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); + DBGPRINT(RT_DEBUG_INFO, "TXRX_CSR18 = 0x%x\n", Csr18.value); pAd->BeaconIntervalChangeAllowed = TRUE; } @@ -1309,11 +1310,11 @@ if (pAd->DrsCounters.fNoisyEnvironment) { - DBGPRINT_RAW(RT_DEBUG_TRACE,"DRS(noisy):"); + DBGPRINT(RT_DEBUG_TRACE,"DRS(noisy): "); } else { - DBGPRINT_RAW(RT_DEBUG_TRACE,"DRS:"); + DBGPRINT(RT_DEBUG_TRACE,"DRS: "); } DBGPRINT_RAW(RT_DEBUG_TRACE,"Qty[%d]=%d PER=%d%% %d-sec, Qty[%d]=%d, Pty=%d\n", RateIdToMbps[CurrRate], pAd->DrsCounters.TxQuality[CurrRate], @@ -1401,7 +1402,7 @@ // if rate-up happen, clear all bad history of all TX rates if (pAd->PortCfg.TxRate > CurrRate) { - DBGPRINT_RAW(RT_DEBUG_TRACE,"DRS: ++TX rate from %d to %d Mbps\n", RateIdToMbps[CurrRate],RateIdToMbps[pAd->PortCfg.TxRate]); + DBGPRINT(RT_DEBUG_TRACE,"DRS: ++TX rate from %d to %d Mbps\n", RateIdToMbps[CurrRate],RateIdToMbps[pAd->PortCfg.TxRate]); pAd->DrsCounters.CurrTxRateStableTime = 0; pAd->DrsCounters.TxRateUpPenalty = 0; pAd->DrsCounters.LastSecTxRateChangeAction = 1; // rate UP @@ -1411,7 +1412,7 @@ // if rate-down happen, only clear DownRate's bad history else if (pAd->PortCfg.TxRate < CurrRate) { - DBGPRINT_RAW(RT_DEBUG_TRACE,"DRS: --TX rate from %d to %d Mbps\n", RateIdToMbps[CurrRate],RateIdToMbps[pAd->PortCfg.TxRate]); + DBGPRINT(RT_DEBUG_TRACE,"DRS: --TX rate from %d to %d Mbps\n", RateIdToMbps[CurrRate],RateIdToMbps[pAd->PortCfg.TxRate]); // shorter stable time require more penalty in next rate UP criteria if (pAd->DrsCounters.CurrTxRateStableTime < 4) // less then 4 sec pAd->DrsCounters.TxRateUpPenalty = DRS_PENALTY; // add 8 sec penalty @@ -1775,11 +1776,11 @@ RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF); DBGPRINT(RT_DEBUG_ERROR, "4Set fRTMP_ADAPTER_RADIO_OFF "); } - DBGPRINT_RAW(RT_DEBUG_TEMP," MlmeRadioOff \n" ); + DBGPRINT_RAW(RT_DEBUG_TEMP,"MlmeRadioOff \n"); RTUSBRejectPendingPackets(pAd);//reject all NDIS packets waiting in TX queue RTUSBCleanUpDataBulkOutQueue(pAd); MlmeSuspend(pAd); - DBGPRINT_RAW(RT_DEBUG_TEMP," 2MlmeRadioOff \n" ); + DBGPRINT_RAW(RT_DEBUG_TEMP,"2MlmeRadioOff \n"); // Abort Tx // Disable Rx RTUSBWriteMACRegister(pAd, TXRX_CSR2, 1); @@ -1788,7 +1789,7 @@ { if (atomic_read(&pAd->PendingRx) > 0) { - DBGPRINT_RAW(RT_DEBUG_TRACE, "BulkIn IRP Pending!!!\n"); + DBGPRINT(RT_DEBUG_TRACE, "BulkIn IRP Pending!!!\n"); RTUSB_VendorRequest(pAd, 0, DEVICE_VENDOR_REQUEST_OUT, @@ -1801,7 +1802,7 @@ if (pAd->BulkOutPending == TRUE) { - DBGPRINT_RAW(RT_DEBUG_TRACE, "BulkOut IRP Pending!!!\n"); + DBGPRINT(RT_DEBUG_TRACE, "BulkOut IRP Pending!!!\n"); if (i == 0) { RTUSBCancelPendingBulkOutIRP(pAd); @@ -1824,7 +1825,7 @@ // Clean up old bss table BssTableInit(&pAd->PortCfg.BssTab); - DBGPRINT_RAW(RT_DEBUG_TEMP," <==MlmeRadioOff \n" ); + DBGPRINT(RT_DEBUG_TEMP,"<==MlmeRadioOff \n" ); #endif } @@ -2727,7 +2728,11 @@ INT Tail; MLME_QUEUE *Queue = (MLME_QUEUE *)&pAd->Mlme.Queue; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if (pAd->MLMEThr_pid > 0) +#else + if (pAd->MLMEThr_active) +#endif { if (MlmeQueueFull(Queue)) @@ -2783,8 +2788,13 @@ ULONG MsgType; //DBGPRINT(RT_DEBUG_ERROR,"MlmeEnqueueForRecv "); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if((pAd->MLMEThr_pid <= 0)) return FALSE; +#else + if(!pAd->MLMEThr_active) + return FALSE; +#endif // First check the size, it MUST not exceed the mlme queue size if (MsgLen > MAX_LEN_OF_MLME_BUFFER) { diff -ruN rt2570-1.1.0-b1/Module/oid.h rt2570-cvs-2005122616/Module/oid.h --- rt2570-1.1.0-b1/Module/oid.h 2005-07-30 11:44:30.000000000 -0500 +++ rt2570-cvs-2005122616/Module/oid.h 2005-11-30 07:43:27.000000000 -0600 @@ -44,13 +44,12 @@ #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE #endif -#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 1) -#define RTPRIV_IOCTL_SET (SIOCIWFIRSTPRIV + 0) -#define RTPRIV_IOCTL_AUTH (SIOCIWFIRSTPRIV + 2) -#define RTPRIV_IOCTL_KEYID (SIOCIWFIRSTPRIV + 7) -#define RTPRIV_IOCTL_WEPSTATUS (SIOCIWFIRSTPRIV + 4) -#define RTPRIV_IOCTL_WPAPSK (SIOCIWFIRSTPRIV + 5) -#define RTPRIV_IOCTL_PSM (SIOCIWFIRSTPRIV + 6) +#define RTPRIV_IOCTL_AUTH (SIOCIWFIRSTPRIV + 0) +#define RTPRIV_IOCTL_WEPSTATUS (SIOCIWFIRSTPRIV + 1) +#define RTPRIV_IOCTL_WPAPSK (SIOCIWFIRSTPRIV + 2) +#define RTPRIV_IOCTL_PSM (SIOCIWFIRSTPRIV + 3) +#define RTPRIV_IOCTL_ADHOCMODE (SIOCIWFIRSTPRIV + 4) +#define RTPRIV_IOCTL_RFMONTX (SIOCIWFIRSTPRIV + 5) // @@ -59,8 +58,8 @@ #ifdef RT2500_DBG -#define RTPRIV_IOCTL_BBP SIOCIWFIRSTPRIV + 0x03 -#define RTPRIV_IOCTL_MAC SIOCIWFIRSTPRIV + 0x05 +#define RTPRIV_IOCTL_BBP SIOCIWFIRSTPRIV + 0x06 +#define RTPRIV_IOCTL_MAC SIOCIWFIRSTPRIV + 0x07 #endif @@ -567,7 +566,7 @@ #define RT_OID_802_11_POWER_MODE (OID_GET_SET_TOGGLE | OID_802_11_POWER_MODE) #define RT_OID_802_11_STATISTICS (OID_GET_SET_TOGGLE | OID_802_11_STATISTICS) -#if DBG +#ifdef DBG #define RT_OID_802_11_QUERY_HARDWARE_REGISTER 0x0D710105 #define RT_OID_802_11_SET_HARDWARE_REGISTER (OID_GET_SET_TOGGLE | RT_OID_802_11_QUERY_HARDWARE_REGISTER) #endif diff -ruN rt2570-1.1.0-b1/Module/rt2570sw.h rt2570-cvs-2005122616/Module/rt2570sw.h --- rt2570-1.1.0-b1/Module/rt2570sw.h 2005-07-30 11:44:30.000000000 -0500 +++ rt2570-cvs-2005122616/Module/rt2570sw.h 2005-12-09 17:41:12.000000000 -0600 @@ -37,13 +37,16 @@ * PeterF 27-06-2005 Added GN-WBKG * zak 03-07-2005 Added second GN-WBKG * PedroP 04-07-2005 Added EMINENT 3035 + * MarkW 06-12-2005 Added Linksys@Home ***************************************************************************/ #ifndef __vnetsw_h_OK__ #define __vnetsw_h_OK__ - +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) +#include +#endif //red,extern unsigned long NIC_VENDOR_DRIVER_VERSION;//blue //////////////////////////////////////////////////////////////////////////// @@ -116,6 +119,8 @@ { USB_DEVICE(0x0411, 0x0066)}, /* Melco */ \ { USB_DEVICE(0x0411, 0x0067)}, /* Melco */ \ { USB_DEVICE(0x050d, 0x7050)}, /* Belkin */ \ + { USB_DEVICE(0x050d, 0x705a)}, /* Belkin */ \ + { USB_DEVICE(0x06f8, 0xe000)}, /* GUILLEMOT */ \ { USB_DEVICE(0x0707, 0xee13)}, /* SMC */ \ { USB_DEVICE(0x0b05, 0x1706)}, /* ASUS */ \ { USB_DEVICE(0x0b05, 0x1707)}, /* ASUS */ \ @@ -127,12 +132,15 @@ { USB_DEVICE(0x114b, 0x0110)}, /* Spairon */ \ { USB_DEVICE(0x13b1, 0x000d)}, /* Cisco Systems */ \ { USB_DEVICE(0x13b1, 0x0011)}, /* Cisco Systems */ \ + { USB_DEVICE(0x13b1, 0x001a)}, /* Cisco Systems */ \ { USB_DEVICE(0x148f, 0x1706)}, /* Ralink */ \ { USB_DEVICE(0x148f, 0x2570)}, /* Ralink */ \ + { USB_DEVICE(0x148f, 0x2573)}, /* CNET CWD-854 */ \ { USB_DEVICE(0x148f, 0x9020)}, /* Ralink */ \ { USB_DEVICE(0x14b2, 0x3c02)}, /* Conceptronic */ \ { USB_DEVICE(0x14f8, 0x2570)}, /* Eminent */ \ { USB_DEVICE(0x2001, 0x3c00)}, /* D-LINK */ \ + { USB_DEVICE(0x0411, 0x008b)}, /* Nintendo */ \ {0,} \ } @@ -157,24 +165,22 @@ // // MACRO for debugging information // -#if RT2500_DBG +#ifdef RT2500_DBG extern ULONG debug; #define DBGPRINT(Level, fmt, args...) \ { \ - if (Level <= debug) \ + if (Level <= debug) \ { \ - printk(NIC_DBG_STRING); \ - printk(KERN_DEBUG fmt, ## args); \ + printk(KERN_DEBUG NIC_DBG_STRING fmt, ## args); \ } \ } -#define DBGPRINT_RAW(Level, fmt, args...) \ -{ \ - if (Level <= debug) \ +#define DBGPRINT_RAW(Level, fmt, args...) \ + { \ + if (Level <= debug) \ { \ - printk(" "); \ - printk(KERN_DEBUG fmt, ## args); \ + printk(fmt, ## args); \ } \ } @@ -272,10 +278,11 @@ dev_kfree_skb_any(skb); \ } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) #define RTUSBUp(pAd, semaphore) \ -{ \ +{ \ if(pAd->MLMEThr_pid>0) \ - up(semaphore); \ + up(semaphore); \ } #define RTUSBCMDUp(pAd, semaphore) \ @@ -283,7 +290,19 @@ if(pAd->RTUSBCmdThr_pid>0) \ up(semaphore); \ } +#else +#define RTUSBUp(pAd, semaphore) \ +{ \ + if(pAd->MLMEThr_active) \ + up(semaphore); \ +} +#define RTUSBCMDUp(pAd, semaphore) \ +{ \ + if(pAd->RTUSBCmdThr_active) \ + up(semaphore); \ +} +#endif //Setup Packet used in Ctrl urb's filler.... @@ -911,6 +930,9 @@ BOOLEAN Massoc; BOOLEAN Mauth; + // RFMON logic flags + BOOLEAN MallowRFMONTx; + // PHY specification UCHAR PhyMode; // PHY_11A, PHY_11B, PHY_11BG_MIXED, PHY_ABG_MIXED USHORT Dsifs; // in units of usec @@ -1458,9 +1480,16 @@ // Thread struct semaphore mlme_semaphore; /* to sleep thread on */ struct semaphore RTUSBCmd_semaphore; /* to sleep thread on */ - struct completion notify; /* thread begin/end */ - pid_t MLMEThr_pid; - pid_t RTUSBCmdThr_pid; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) + struct completion notify; /* thread begin/end */ + pid_t MLMEThr_pid; + pid_t RTUSBCmdThr_pid; +#else + struct task_struct * MLMEThr; + volatile int MLMEThr_active; + struct task_struct * RTUSBCmdThr; + volatile int RTUSBCmdThr_active; +#endif wait_queue_head_t *wait; spinlock_t *lock; @@ -3697,4 +3726,55 @@ int USB_CallUSBD(PRT2570ADAPTER Adapter, IN PURB Urb); + +#endif + +#ifndef _PRISMHEADER +#define _PRISMHEADER + +enum { + DIDmsg_lnxind_wlansniffrm = 0x00000044, + DIDmsg_lnxind_wlansniffrm_hosttime = 0x00010044, + DIDmsg_lnxind_wlansniffrm_mactime = 0x00020044, + DIDmsg_lnxind_wlansniffrm_channel = 0x00030044, + DIDmsg_lnxind_wlansniffrm_rssi = 0x00040044, + DIDmsg_lnxind_wlansniffrm_sq = 0x00050044, + DIDmsg_lnxind_wlansniffrm_signal = 0x00060044, + DIDmsg_lnxind_wlansniffrm_noise = 0x00070044, + DIDmsg_lnxind_wlansniffrm_rate = 0x00080044, + DIDmsg_lnxind_wlansniffrm_istx = 0x00090044, + DIDmsg_lnxind_wlansniffrm_frmlen = 0x000A0044 +}; +enum { + P80211ENUM_msgitem_status_no_value = 0x00 +}; +enum { + P80211ENUM_truth_false = 0x00, + P80211ENUM_truth_true = 0x01 +}; + +typedef struct { + u_int32_t did; + u_int16_t status; + u_int16_t len; + u_int32_t data; +} p80211item_uint32_t; + +typedef struct { + u_int32_t msgcode; + u_int32_t msglen; +#define WLAN_DEVNAMELEN_MAX 16 + u_int8_t devname[WLAN_DEVNAMELEN_MAX]; + p80211item_uint32_t hosttime; + p80211item_uint32_t mactime; + p80211item_uint32_t channel; + p80211item_uint32_t rssi; + p80211item_uint32_t sq; + p80211item_uint32_t signal; + p80211item_uint32_t noise; + p80211item_uint32_t rate; + p80211item_uint32_t istx; + p80211item_uint32_t frmlen; +} wlan_ng_prism2_header; + #endif diff -ruN rt2570-1.1.0-b1/Module/rt_config.h rt2570-cvs-2005122616/Module/rt_config.h --- rt2570-1.1.0-b1/Module/rt_config.h 2005-07-30 11:45:39.000000000 -0500 +++ rt2570-cvs-2005122616/Module/rt_config.h 2005-07-11 04:38:21.000000000 -0500 @@ -40,16 +40,16 @@ #define PROFILE_PATH "/etc/Wireless/RT2570STA/RT2570STA.dat" #define NIC_DEVICE_NAME "RT2500USBSTA" #define DRV_MAJORVERSION 1 -#define DRV_MINORVERSION 1 +#define DRV_MINORVERSION 0 #define DRV_SUBVERSION 0 #define DRV_TESTVERSION 0 #define DRV_YEAR 2005 -#define DRV_MONTH 7 -#define DRV_DAY 31 +#define DRV_MONTH 6 +#define DRV_DAY 1 #define DRV_NAME "rt2570" -#define DRV_VERSION "1.1.0 BETA1" -#define DRV_RELDATE "2005/07/31" +#define DRV_VERSION "1.0.0 - CVS" +#define DRV_RELDATE "2005/06/01" /* Operational parameters that are set at compile time. */ diff -ruN rt2570-1.1.0-b1/Module/rtmp_def.h rt2570-cvs-2005122616/Module/rtmp_def.h --- rt2570-1.1.0-b1/Module/rtmp_def.h 2005-07-30 11:44:30.000000000 -0500 +++ rt2570-cvs-2005122616/Module/rtmp_def.h 2005-08-03 08:54:12.000000000 -0500 @@ -49,7 +49,7 @@ #define RT_DEBUG_ADHOC 3 #define NIC_TAG ((ULONG)'0752') -#define NIC_DBG_STRING ("RTUSB ") +#define NIC_DBG_STRING "RTUSB " // // update the driver version number every time you release a new driver diff -ruN rt2570-1.1.0-b1/Module/rtmp_tkip.c rt2570-cvs-2005122616/Module/rtmp_tkip.c --- rt2570-1.1.0-b1/Module/rtmp_tkip.c 2005-07-30 11:44:29.000000000 -0500 +++ rt2570-cvs-2005122616/Module/rtmp_tkip.c 2005-08-17 04:00:39.000000000 -0500 @@ -562,14 +562,14 @@ // Since the MIC value might cross MPDUs. if(memcmp(pAdapter->PrivateInfo.Rx.MIC, OldMic, 8) != 0) { - DBGPRINT_RAW(RT_DEBUG_ERROR, "! TKIP MIC Error Len=%d!\n", Len); //MIC error. - DBGPRINT_RAW(RT_DEBUG_INFO, "Orig MIC value ="); //MIC error. + DBGPRINT(RT_DEBUG_ERROR, "! TKIP MIC Error Len=%d!\n", Len); //MIC error. + DBGPRINT(RT_DEBUG_INFO, "Orig MIC value = "); //MIC error. for (i = 0; i < 8; i++) { DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", OldMic[i]); //MIC error. } DBGPRINT_RAW(RT_DEBUG_INFO, "\n"); //MIC error. - DBGPRINT_RAW(RT_DEBUG_INFO, "Calculated MIC value ="); //MIC error. + DBGPRINT(RT_DEBUG_INFO, "Calculated MIC value = "); //MIC error. for (i = 0; i < 8; i++) { DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pAdapter->PrivateInfo.Rx.MIC[i]); //MIC error. @@ -647,13 +647,13 @@ if(memcmp(pAdapter->PrivateInfo.Rx.MIC, OldMic, 8) != 0) { DBGPRINT_RAW(RT_DEBUG_ERROR, "! TKIP MIC Error !\n"); //MIC error. - DBGPRINT_RAW(RT_DEBUG_INFO, "Orig MIC value ="); //MIC error. + DBGPRINT(RT_DEBUG_INFO, "Orig MIC value = "); //MIC error. for (i = 0; i < 8; i++) { DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", OldMic[i]); //MIC error. } DBGPRINT_RAW(RT_DEBUG_INFO, "\n"); //MIC error. - DBGPRINT_RAW(RT_DEBUG_INFO, "Calculated MIC value ="); //MIC error. + DBGPRINT(RT_DEBUG_INFO, "Calculated MIC value = "); //MIC error. for (i = 0; i < 8; i++) { DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pAdapter->PrivateInfo.Rx.MIC[i]); //MIC error. diff -ruN rt2570-1.1.0-b1/Module/rtusb_bulk.c rt2570-cvs-2005122616/Module/rtusb_bulk.c --- rt2570-1.1.0-b1/Module/rtusb_bulk.c 2005-07-30 11:44:29.000000000 -0500 +++ rt2570-cvs-2005122616/Module/rtusb_bulk.c 2005-09-12 08:46:15.000000000 -0500 @@ -107,7 +107,9 @@ NdisReleaseSpinLock(&pAdapter->BulkOutLock); return; } - else if (pAdapter->MediaState == NdisMediaStateDisconnected) + else if (pAdapter->MediaState == NdisMediaStateDisconnected && + !( pAdapter->PortCfg.BssType == BSS_MONITOR && pAdapter->PortCfg.MallowRFMONTx == TRUE ) + ) { // // Since there is no connection, so we need to empty the Tx Bulk out Ring. diff -ruN rt2570-1.1.0-b1/Module/rtusb_data.c rt2570-cvs-2005122616/Module/rtusb_data.c --- rt2570-1.1.0-b1/Module/rtusb_data.c 2005-07-30 11:44:30.000000000 -0500 +++ rt2570-cvs-2005122616/Module/rtusb_data.c 2005-11-25 05:36:41.000000000 -0600 @@ -40,6 +40,7 @@ 0, /* RATE_1 */ 1, /* RATE_2 */ 2, /* RATE_5_5 */ 3, /* RATE_11 */ // see BBP spec 11, /* RATE_6 */ 15, /* RATE_9 */ 10, /* RATE_12 */ 14, /* RATE_18 */ // see IEEE802.11a-1999 p.14 9, /* RATE_24 */ 13, /* RATE_36 */ 8, /* RATE_48 */ 12 /* RATE_54 */ }; // see IEEE802.11a-1999 p.14 +static UINT _11G_RATES[12] = { 0, 0, 0, 0, 6, 9, 12, 18, 24, 36, 48, 54 }; static UCHAR SNAP_802_1H[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00}; static UCHAR SNAP_BRIDGE_TUNNEL[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8}; static UCHAR EAPOL[] = {0x88, 0x8e}; @@ -84,7 +85,9 @@ return 0; } // Drop packets if no associations - else if (!INFRA_ON(pAdapter) && !ADHOC_ON(pAdapter)) + else if (!INFRA_ON(pAdapter) && !ADHOC_ON(pAdapter) && + !( pAdapter->PortCfg.BssType == BSS_MONITOR && pAdapter->PortCfg.MallowRFMONTx == TRUE ) + ) { RTUSBFreeSkbBuffer(skb); return 0; @@ -140,6 +143,15 @@ // Init priority value Priority = 0; AccessCategory = 0; + + if (skb && pAdapter->PortCfg.BssType == BSS_MONITOR && + pAdapter->PortCfg.MallowRFMONTx == TRUE) + { + NdisAcquireSpinLock(&pAdapter->SendTxWaitQueueLock); + skb_queue_tail(&pAdapter->SendTxWaitQueue, skb); + NdisReleaseSpinLock(&pAdapter->SendTxWaitQueueLock); + return (NDIS_STATUS_SUCCESS); + } if (skb) { @@ -806,6 +818,36 @@ DBGPRINT(RT_DEBUG_ERROR, "Error, Null skb data buffer!!!\n"); return (NDIS_STATUS_FAILURE); } + + if (pAdapter->PortCfg.BssType == BSS_MONITOR && pAdapter->PortCfg.MallowRFMONTx == TRUE) + { + pTxContext = &pAdapter->TxContext[pAdapter->NextTxIndex]; + pTxContext->InUse = TRUE; + pTxContext->LastOne = TRUE; + + pAdapter->NextTxIndex++; + if (pAdapter->NextTxIndex >= TX_RING_SIZE) + pAdapter->NextTxIndex = 0; + + pTxD = &(pTxContext->TransferBuffer->TxDesc); + memset(pTxD, 0, sizeof(TXD_STRUC)); + pDest = pTxContext->TransferBuffer->WirelessPacket; + + memcpy( pDest, skb->data, skb->len ); + + RTUSBWriteTxDescriptor(pTxD, FALSE, 0, FALSE, FALSE, TRUE, IFS_BACKOFF, skb->len, FALSE, 0, CW_MIN_IN_BITS, CW_MAX_IN_BITS, skb->len + 4, pAdapter->PortCfg.TxRate, 4, pAdapter->PortCfg.TxPreambleInUsed); + + TransferBufferLength = skb->len + sizeof(TXD_STRUC); + if ((TransferBufferLength % 2) == 1) + TransferBufferLength++; + + pTxContext->BulkOutSize = TransferBufferLength; + atomic_inc(&pAdapter->TxCount); + RTUSB_SET_BULK_FLAG(pAdapter, fRTUSB_BULK_OUT_DATA_FRAG); + RTUSBFreeSkbBuffer(skb); + return (NDIS_STATUS_SUCCESS); + } + if (NdisBufferLength < 14) { DBGPRINT_RAW(RT_DEBUG_ERROR, "RTUSBHardEncrypt --> Ndis Packet buffer error !!!\n"); @@ -1105,19 +1147,19 @@ { INT i; - DBGPRINT_RAW(RT_DEBUG_INFO, "RTMPHardEncrypt TKIP Key = "); + DBGPRINT(RT_DEBUG_INFO, "RTMPHardEncrypt TKIP Key = "); for (i = 0; i < 16; i++) { DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pWpaKey->Key[i]); } DBGPRINT_RAW(RT_DEBUG_INFO, "\n"); - DBGPRINT_RAW(RT_DEBUG_INFO, "RTMPHardEncrypt TKIP TxMic = "); + DBGPRINT(RT_DEBUG_INFO, "RTMPHardEncrypt TKIP TxMic = "); for (i = 0; i < 8; i++) { DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pWpaKey->TxMic[i]); } DBGPRINT_RAW(RT_DEBUG_INFO, "\n"); - DBGPRINT_RAW(RT_DEBUG_INFO, "RTMPHardEncrypt TKIP TxTsc = "); + DBGPRINT(RT_DEBUG_INFO, "RTMPHardEncrypt TKIP TxTsc = "); for (i = 0; i < 6; i++) { DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pWpaKey->TxTsc[i]); @@ -1407,7 +1449,7 @@ INT i; NdisBufferLength = 8; // Set length to MIC length - DBGPRINT_RAW(RT_DEBUG_INFO, "Calculated TX MIC value ="); + DBGPRINT(RT_DEBUG_INFO, "Calculated TX MIC value = "); for (i = 0; i < 8; i++) { DBGPRINT_RAW(RT_DEBUG_INFO, "%02x:", pAdapter->PrivateInfo.Tx.MIC[i]); @@ -1631,6 +1673,7 @@ NDIS_802_11_ENCRYPTION_STATUS Cipher; struct sk_buff *skb; PVOID pManage; + wlan_ng_prism2_header *ph; pRxContext= (PRX_CONTEXT)pUrb->context; pAdapter = pRxContext->pAdapter; @@ -1668,6 +1711,62 @@ struct sk_buff *skb; if ((skb = __dev_alloc_skb(2048, GFP_DMA|GFP_ATOMIC)) != NULL) { + if (pAdapter->PortCfg.MallowRFMONTx == TRUE) + goto rfmontx_80211_receive; + + // setup the wlan-ng prismheader + + if (skb_headroom(skb) < sizeof(wlan_ng_prism2_header)) + pskb_expand_head(skb, sizeof(wlan_ng_prism2_header), 0, GFP_ATOMIC); + + ph = (wlan_ng_prism2_header *) + skb_push(skb, sizeof(wlan_ng_prism2_header)); + memset(ph, 0, sizeof(wlan_ng_prism2_header)); + + ph->msgcode = DIDmsg_lnxind_wlansniffrm; + ph->msglen = sizeof(wlan_ng_prism2_header); + strcpy(ph->devname, pAdapter->net->name); + + ph->hosttime.did = DIDmsg_lnxind_wlansniffrm_hosttime; + ph->mactime.did = DIDmsg_lnxind_wlansniffrm_mactime; + ph->channel.did = DIDmsg_lnxind_wlansniffrm_channel; + ph->rssi.did = DIDmsg_lnxind_wlansniffrm_rssi; + ph->signal.did = DIDmsg_lnxind_wlansniffrm_signal; + ph->noise.did = DIDmsg_lnxind_wlansniffrm_noise; + ph->rate.did = DIDmsg_lnxind_wlansniffrm_rate; + ph->istx.did = DIDmsg_lnxind_wlansniffrm_istx; + ph->frmlen.did = DIDmsg_lnxind_wlansniffrm_frmlen; + + ph->hosttime.len = 4; + ph->mactime.len = 4; + ph->channel.len = 4; + ph->rssi.len = 4; + ph->signal.len = 4; + ph->noise.len = 4; + ph->rate.len = 4; + ph->istx.len = 4; + ph->frmlen.len = 4; + + ph->hosttime.data = jiffies; + ph->channel.data = pAdapter->PortCfg.IbssConfig.Channel; + ph->signal.data = pRxD->BBR1; + ph->noise.data = pAdapter->PortCfg.LastR17Value; + ph->rssi.data = ph->signal.data - ph->noise.data; + ph->frmlen.data = pRxD->DataByteCnt; + + if (pRxD->Ofdm == 1) + { + for (i = 4; i < 12; i++) + if (pRxD->BBR0 == PlcpSignal[i]) + ph->rate.data = _11G_RATES[i] * 2; + } + else + ph->rate.data = pRxD->BBR0 / 5; + + // end prismheader setup + + rfmontx_80211_receive: + skb->dev = pAdapter->net; memcpy(skb_put(skb, pRxD->DataByteCnt-4), pData, pRxD->DataByteCnt-4); skb->mac.raw = skb->data; @@ -2027,7 +2126,7 @@ { pWpaKey = (PWPA_KEY) &pAdapter->PortCfg.PairwiseKey[idx]; pWpaKey->Type = PAIRWISE_KEY; - DBGPRINT(RT_DEBUG_TEMP, "Rx Use Pairwise Key %d\n",idx); + DBGPRINT(RT_DEBUG_LOUD, "Rx Use Pairwise Key %d\n",idx); break; } } @@ -2160,7 +2259,7 @@ pAdapter->netstats.rx_packets++; } //memset(Header802_3, 0, LENGTH_802_3); - DBGPRINT_RAW(RT_DEBUG_INFO, "!!! Broadcast Ethenet rx Indicated !!!\n"); + DBGPRINT_RAW(RT_DEBUG_INFO, "!!! Broadcast Ethernet rx Indicated !!!\n"); } //if (pRxD->Bcast || pRxD->Mcast) // Begin process unicast to me frame else if (pRxD->U2M) diff -ruN rt2570-1.1.0-b1/Module/rtusb.h rt2570-cvs-2005122616/Module/rtusb.h --- rt2570-1.1.0-b1/Module/rtusb.h 2005-07-30 11:44:30.000000000 -0500 +++ rt2570-cvs-2005122616/Module/rtusb.h 2005-10-21 12:31:22.000000000 -0500 @@ -38,7 +38,7 @@ // // MACRO definitions // -#if (_WIN32_WINNT >= 0x0501) +#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0501) #define NDIS_QUERY_BUFFER(_NdisBuf, _ppVA, _pBufLen) \ NdisQueryBufferSafe(_NdisBuf, _ppVA, _pBufLen, NormalPagePriority) #else diff -ruN rt2570-1.1.0-b1/Module/rtusb_info.c rt2570-cvs-2005122616/Module/rtusb_info.c --- rt2570-1.1.0-b1/Module/rtusb_info.c 2005-07-30 11:44:30.000000000 -0500 +++ rt2570-cvs-2005122616/Module/rtusb_info.c 2005-12-02 06:55:15.000000000 -0600 @@ -200,6 +200,14 @@ pAdapter->PortCfg.IbssConfig.Channel = chan; DBGPRINT(RT_DEBUG_ERROR, "<==SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n", SIOCSIWFREQ, pAdapter->PortCfg.IbssConfig.Channel); + // CD: setting the channel in Monitor mode is unrelated to RFMONTx + + if (pAdapter->PortCfg.BssType == BSS_MONITOR) + { + pAdapter->PortCfg.Channel = pAdapter->PortCfg.IbssConfig.Channel; + AsicSwitchChannel(pAdapter, pAdapter->PortCfg.Channel); + AsicLockChannel(pAdapter, pAdapter->PortCfg.Channel); + } return 0; } @@ -269,7 +277,10 @@ pAdapter->PortCfg.BssType=BSS_MONITOR; RTUSBEnqueueInternalCmd(pAdapter, RT_OID_LINK_DOWN); pAdapter->bConfigChanged = TRUE; - pAdapter->net->type = 801; + if (pAdapter->PortCfg.MallowRFMONTx == TRUE) + pAdapter->net->type = 801; // ARPHRD_IEEE80211 + else + pAdapter->net->type = 802; // ARPHRD_IEEE80211_PRISM RTUSBWriteMACRegister(pAdapter, TXRX_CSR2, 0x4e); break; default: @@ -288,10 +299,15 @@ __u32 *mode, char *extra) { PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv; - if (ADHOC_ON(pAdapter)) - *mode = IW_MODE_ADHOC; + if (pAdapter->PortCfg.BssType == BSS_MONITOR) + *mode = IW_MODE_MONITOR; else - *mode = IW_MODE_INFRA; + { + if (ADHOC_ON(pAdapter)) + *mode = IW_MODE_ADHOC; + else + *mode = IW_MODE_INFRA; + } DBGPRINT(RT_DEBUG_TEMP,"--->rtusb_ioctl_giwmode\n"); return 0; } @@ -372,9 +388,7 @@ break; } - range->max_qual.qual = 70; /* what is correct max? This was not - * documented exactly. At least - * 69 has been observed. */ + range->max_qual.qual = 100; /* percentage */ range->max_qual.level = 0; /* dB */ range->max_qual.noise = 0; /* dB */ @@ -502,7 +516,11 @@ if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF)) return 0; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if ((pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE) && (pAdapter->MLMEThr_pid > 0)) +#else + if ((pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE) && (pAdapter->MLMEThr_active)) +#endif { DBGPRINT(RT_DEBUG_ERROR, "!!! MLME busy, reset MLME state machine !!!\n"); MlmeRestartStateMachine(pAdapter); @@ -539,6 +557,13 @@ char *current_val; struct iw_event iwe; + if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)){ + /* + * Still scanning, indicate the caller should try again. + */ + return -EAGAIN; + } + for (i = 0; i < pAdapter->PortCfg.BssTab.BssNr; i++) { if (current_ev >= end_buf) @@ -644,8 +669,11 @@ // this request, because this request is initiated by NDIS. pAdapter->Mlme.CntlAux.CurrReqIsFromNdis = FALSE; DBGPRINT(RT_DEBUG_TRACE,"--->Ssid.SsidLength = %d, %s\n",Ssid.SsidLength, Ssid.Ssid); - +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if (pAdapter->MLMEThr_pid > 0) +#else + if (!IS_ERR(pAdapter->MLMEThr)) +#endif MlmeEnqueue(pAdapter, MLME_CNTL_STATE_MACHINE, OID_802_11_SSID, @@ -909,9 +937,9 @@ void *w, char *extra) { PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv; - int *param = (int *) extra; + int param = *(int *) extra; - switch(param[0]) + switch(param) { case 1: pAdapter->PortCfg.AuthMode = Ndis802_11AuthModeOpen; @@ -936,7 +964,7 @@ } - pAdapter->PortCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED; + pAdapter->PortCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED; return 0; } @@ -946,10 +974,10 @@ { PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv; - int *param = (int *) extra; + int param = *(int *)extra; USHORT Value; - switch(param[0]) + switch(param) { case 1: pAdapter->PortCfg.DefaultKeyId = 0; @@ -990,12 +1018,12 @@ { PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv; - int *param = (int *) extra; + int param = *(int *)extra; NDIS_802_11_WEP_STATUS WepStatus;//set by OID_802_11_WEP_STATUS DBGPRINT(RT_DEBUG_TRACE, "===>setencryp\n"); DBGPRINT(RT_DEBUG_TRACE, "===>info->cmd 0x%x \n",(info->cmd)); - DBGPRINT(RT_DEBUG_TRACE, "===>info->flags 0x%x , param %x , extra %x\n",(info->flags), param[0],*extra); - switch(param[0]) + DBGPRINT(RT_DEBUG_TRACE, "===>info->flags 0x%x , param %x , extra %x\n",(info->flags), param,*extra); + switch(param) { case 1: pAdapter->PortCfg.WepStatus= Ndis802_11WEPDisabled; @@ -1100,14 +1128,74 @@ return 0; } + +static int rtusb_ioctl_setrfmontx(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *data, char *extra) +{ + PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv; + int param; + char value; + + if (extra) { /* Change the state if there's param. */ + param = *(int *)extra; + switch(param) + { + case 1: + pAdapter->PortCfg.MallowRFMONTx = TRUE; + pAdapter->net->type = 801; // ARPHRD_IEEE80211 + break; + case 0: + pAdapter->PortCfg.MallowRFMONTx = FALSE; + pAdapter->net->type = 802; // ARPHRD_IEEE80211_PRISM + break; + default: + return -EOPNOTSUPP; + } + } + + value = pAdapter->PortCfg.MallowRFMONTx == TRUE ? '1' : '0'; + + data->length = sizeof (char); + if (data->pointer != NULL && copy_to_user (data->pointer, &value, data->length)) + DBGPRINT (RT_DEBUG_ERROR, "rtusb_ioctl_setrfmontx - copy to user failure.\n"); + + return 0; +} + +static int rtusb_ioctl_setadhocmode(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *data, char *extra) +{ + PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv; + int param = *(int *)extra; + + switch(param) + { + case 0: + pAdapter->PortCfg.AdhocMode = 0; + break; + case 1: + pAdapter->PortCfg.AdhocMode = 1; + break; + case 2: + pAdapter->PortCfg.AdhocMode = 2; + break; + default: + return -EOPNOTSUPP; + } + + return 0; +} + static int rtusb_ioctl_setpsm(struct net_device *dev, struct iw_request_info *info, void *w, char *extra) { PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) dev->priv; - int *param = (int *) extra; + int param = *(int *)extra; - switch(param[0]) + switch(param) { case 0: // clear PSM bit immediately @@ -1187,30 +1275,30 @@ (iw_handler) NULL, /* SIOCGIWPOWER 2d*/ }; static const iw_handler rtusb_priv_handlers[] = { - (iw_handler) NULL, /* SIOCWFIRSTPRIV+0 */ - (iw_handler) NULL, /* SIOCWFIRSTPRIV+3 */ - (iw_handler) rtusb_ioctl_setauth, /* SIOCWFIRSTPRIV+2 */ - (iw_handler) NULL, /* SIOCWFIRSTPRIV+3 */ - (iw_handler) rtusb_ioctl_setencryp, /* SIOCWFIRSTPRIV+4 */ - (iw_handler) rtusb_ioctl_setwpapsk, /* SIOCWFIRSTPRIV+5 */ - (iw_handler) rtusb_ioctl_setpsm, /* SIOCWFIRSTPRIV+6 */ -// (iw_handler) rtusb_ioctl_setkeyid, /* SIOCWFIRSTPRIV+1 */ + (iw_handler) rtusb_ioctl_setauth, /* SIOCWFIRSTPRIV+0 */ + (iw_handler) rtusb_ioctl_setencryp, /* SIOCWFIRSTPRIV+1 */ + (iw_handler) rtusb_ioctl_setwpapsk, /* SIOCWFIRSTPRIV+2 */ + (iw_handler) rtusb_ioctl_setpsm, /* SIOCWFIRSTPRIV+3 */ + (iw_handler) rtusb_ioctl_setadhocmode, /* SIOCWFIRSTPRIV+4 */ + (iw_handler) rtusb_ioctl_setrfmontx, /* SIOCWFIRSTPRIV+5 */ }; -struct iw_priv_args privtab[] = { -// { RTPRIV_IOCTL_SET, -// IW_PRIV_TYPE_INT |1, 0, ""}, // Variable arg count - { 1, - IW_PRIV_TYPE_INT |1, 0, ""}, // Variable arg count -// { RTPRIV_IOCTL_KEYID, -// IW_PRIV_TYPE_INT |1, 0, "kid"}, // Variable arg count + +#define MAX_WPAPSK_STRING 64 +static const struct iw_priv_args privtab[] = { { RTPRIV_IOCTL_AUTH, - IW_PRIV_TYPE_INT |1, 0, "auth"}, // Variable arg count + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "auth"}, { RTPRIV_IOCTL_WEPSTATUS, - IW_PRIV_TYPE_INT |1, 0, "enc"}, // Variable arg count + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "enc"}, { RTPRIV_IOCTL_WPAPSK, - IW_PRIV_TYPE_CHAR |64, 0, "wpapsk"}, // Variable arg count + IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WPAPSK_STRING, + 0, "wpapsk"}, // Variable arg count { RTPRIV_IOCTL_PSM, - IW_PRIV_TYPE_INT |1, 0, "psm"}, // Variable arg count + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "psm"}, // Variable arg count + { RTPRIV_IOCTL_ADHOCMODE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "adhocmode"}, + { RTPRIV_IOCTL_RFMONTX, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | sizeof(char), "rfmontx"}, #if 0 { RTPRIV_IOCTL_BBP, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024, @@ -1223,14 +1311,14 @@ const struct iw_handler_def rt2500usb_iw_handler_def = { -#define N(a) (sizeof (a) / sizeof (a[0])) - .standard = (iw_handler *) rtusb_handler, - .num_standard = sizeof(rtusb_handler) / sizeof(iw_handler), - .private = (iw_handler *) rtusb_priv_handlers, - .num_private = N(rtusb_priv_handlers), - .private_args = (struct iw_priv_args *) privtab, - .num_private_args = N(privtab), + .standard = (iw_handler *) rtusb_handler, + .num_standard = sizeof(rtusb_handler) / sizeof(iw_handler), + .private = (iw_handler *) rtusb_priv_handlers, + .num_private = ARRAY_SIZE(rtusb_handler), + .private_args = (struct iw_priv_args *) privtab, + .num_private_args = ARRAY_SIZE(privtab), }; + INT RTMPQueryInformation( IN PRT2570ADAPTER pAdapter, IN OUT struct ifreq *rq, @@ -2174,14 +2262,17 @@ #ifdef RT2500_DBG { int i; - printk("RT_OID_802_11_ADD_WPA Key => \n"); + DBGPRINT(RT_DEBUG_LOUD, "RT_OID_802_11_ADD_WPA Key => \n"); + DBGPRINT(RT_DEBUG_LOUD, " "); for (i = 0; i < Key.KeyLength; i++) { - printk("%02x:", pAdapter->PortCfg.PskKey.Key[i]); - if (i%16 == 15) - printk("\n"); + DBGPRINT_RAW(RT_DEBUG_LOUD, "%02x:", pAdapter->PortCfg.PskKey.Key[i]); + if (i%16 == 15) { + DBGPRINT_RAW(RT_DEBUG_LOUD, "\n"); + DBGPRINT(RT_DEBUG_LOUD, " "); + } } - printk("\n"); + DBGPRINT_RAW(RT_DEBUG_LOUD, "\n"); } #endif DBGPRINT(RT_DEBUG_TRACE, "Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", Key.KeyIndex, Key.KeyLength); @@ -2238,10 +2329,10 @@ TXRX_CSR0_STRUC TxRxCsr0; UCHAR ZeroKey[4 * 16]; - DBGPRINT_RAW(RT_DEBUG_TEMP,"===>RTMPWPAAddKeyProc\n" ); + DBGPRINT(RT_DEBUG_TEMP,"===>RTMPWPAAddKeyProc\n" ); pKey = (PNDIS_802_11_KEY) pBuf; KeyIdx = pKey->KeyIndex & 0xff; - DBGPRINT_RAW(RT_DEBUG_TEMP,"RTMPWPAAddKeyProc KeyIdx = %x\n", pKey->KeyIndex ); + DBGPRINT(RT_DEBUG_TEMP,"RTMPWPAAddKeyProc KeyIdx = %x\n", pKey->KeyIndex ); // Bit 31 of Add-key, Tx Key bTxKey = (pKey->KeyIndex & 0x80000000) ? TRUE : FALSE; // Bit 30 of Add-key PairwiseKey @@ -2337,32 +2428,32 @@ Status = NDIS_STATUS_SUCCESS; - DBGPRINT_RAW(RT_DEBUG_TEMP,"Add Pairwise TKIP Key %d= ",PairwiseIdx); - DBGPRINT_RAW(RT_DEBUG_TEMP,"Pairwise TKIP Key = "); + DBGPRINT(RT_DEBUG_TEMP,"Add Pairwise TKIP Key %d= ",PairwiseIdx); + DBGPRINT(RT_DEBUG_TEMP,"Pairwise TKIP Key = "); for (i = 0; i < 16; i++) { DBGPRINT_RAW(RT_DEBUG_INFO,"%02x:", pAdapter->PortCfg.PairwiseKey[PairwiseIdx].Key[i]); } DBGPRINT_RAW(RT_DEBUG_INFO,"\n"); - DBGPRINT_RAW(RT_DEBUG_INFO,"TKIP Rx MIC Key = "); + DBGPRINT(RT_DEBUG_INFO,"TKIP Rx MIC Key = "); for (i = 0; i < 8; i++) { DBGPRINT_RAW(RT_DEBUG_INFO,"%02x:", pAdapter->PortCfg.PairwiseKey[PairwiseIdx].RxMic[i]); } DBGPRINT_RAW(RT_DEBUG_INFO,"\n"); - DBGPRINT_RAW(RT_DEBUG_INFO,"TKIP Tx MIC Key = "); + DBGPRINT(RT_DEBUG_INFO,"TKIP Tx MIC Key = "); for (i = 0; i < 8; i++) { DBGPRINT_RAW(RT_DEBUG_INFO,"%02x:", pAdapter->PortCfg.PairwiseKey[PairwiseIdx].TxMic[i]); } DBGPRINT_RAW(RT_DEBUG_INFO,"\n"); - DBGPRINT_RAW(RT_DEBUG_INFO,"TKIP RxTSC = "); + DBGPRINT(RT_DEBUG_INFO,"TKIP RxTSC = "); for (i = 0; i < 6; i++) { DBGPRINT_RAW(RT_DEBUG_INFO,"%02x:", pAdapter->PortCfg.PairwiseKey[PairwiseIdx].RxTsc[i]); } DBGPRINT_RAW(RT_DEBUG_INFO,"\n"); - DBGPRINT_RAW(RT_DEBUG_INFO,"BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n", + DBGPRINT(RT_DEBUG_INFO,"BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n", pKey->BSSID[0],pKey->BSSID[1],pKey->BSSID[2],pKey->BSSID[3],pKey->BSSID[4],pKey->BSSID[5]); } @@ -2453,13 +2544,13 @@ { DBGPRINT_RAW(RT_DEBUG_ERROR,"%02x:", pAdapter->PortCfg.GroupKey[KeyIdx].Key[i]); } - DBGPRINT(RT_DEBUG_ERROR,"\n"); + DBGPRINT_RAW(RT_DEBUG_ERROR,"\n"); DBGPRINT(RT_DEBUG_TRACE,"TKIP Rx MIC Key = \n"); for (i = 0; i < 8; i++) { DBGPRINT_RAW(RT_DEBUG_TRACE,"%02x:", pAdapter->PortCfg.GroupKey[KeyIdx].RxMic[i]); } - DBGPRINT(RT_DEBUG_TRACE,"\n"); + DBGPRINT_RAW(RT_DEBUG_TRACE,"\n"); DBGPRINT(RT_DEBUG_TRACE,"TKIP Tx MIC Key = \n"); for (i = 0; i < 8; i++) { @@ -2471,7 +2562,7 @@ { DBGPRINT_RAW(RT_DEBUG_TRACE,"%02x:", pAdapter->PortCfg.GroupKey[KeyIdx].RxTsc[i]); } - DBGPRINT(RT_DEBUG_TRACE,"\n"); + DBGPRINT_RAW(RT_DEBUG_TRACE,"\n"); DBGPRINT(RT_DEBUG_INFO,"BSSID:%02x:%02x:%02x:%02x:%02x:%02x \n", pKey->BSSID[0],pKey->BSSID[1],pKey->BSSID[2],pKey->BSSID[3],pKey->BSSID[4],pKey->BSSID[5]); @@ -3814,14 +3905,17 @@ // Start STA supplicant state machine pAdapter->PortCfg.WpaState = SS_START; #ifdef RT2500_DBG - printk("Set_WPAPSK_Proc WPAPSK Key => \n"); + DBGPRINT(RT_DEBUG_LOUD, "Set_WPAPSK_Proc WPAPSK Key => \n"); + DBGPRINT(RT_DEBUG_LOUD, " "); for (i = 0; i < 32; i++) { - printk("%02x:", pAdapter->PortCfg.PskKey.Key[i]); - if (i%16 == 15) - printk("\n"); + DBGPRINT_RAW(RT_DEBUG_LOUD, "%02x:", pAdapter->PortCfg.PskKey.Key[i]); + if (i%16 == 15) { + DBGPRINT_RAW(RT_DEBUG_LOUD, "\n"); + DBGPRINT(RT_DEBUG_LOUD, " "); + } } - printk("\n"); + DBGPRINT_RAW(RT_DEBUG_LOUD, "\n"); #endif #endif return TRUE; @@ -3841,7 +3935,6 @@ NDIS_802_11_FRAGMENTATION_THRESHOLD FragThresh; NDIS_802_11_MAC_ADDRESS Bssid; INT Status = NDIS_STATUS_SUCCESS; - USHORT subcmd; BOOLEAN StateMachineTouched = FALSE; int chan = -1, index = 0, len = 0; USHORT Value; @@ -3851,8 +3944,13 @@ DBGPRINT(RT_DEBUG_TRACE,"INFO::remove in progress!\n"); return -ENETDOWN; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if (pAdapter->RTUSBCmdThr_pid < 0) return -ENETDOWN; +#else + if (!pAdapter->RTUSBCmdThr_active) + return -ENETDOWN; +#endif switch(cmd) { @@ -4091,74 +4189,16 @@ DBGPRINT(RT_DEBUG_TEMP, "Query::SIOCGIWAPLIST (%d BSS returned)\n",pAdapter->PortCfg.BssTab.BssNr); DBGPRINT(RT_DEBUG_TEMP,"<==>WIRELESS_EXT=%d IOCTL::SIOCGIWAPLIST \n",WIRELESS_EXT); break; - case RT_PRIV_IOCTL: - subcmd = wrq->u.data.flags; - if( subcmd & OID_GET_SET_TOGGLE) - Status = RTMPSetInformation(pAdapter, rq, subcmd); - else - Status = RTMPQueryInformation(pAdapter, rq, subcmd); - break; case SIOCGIWPRIV: if (wrq->u.data.pointer) { - if ( verify_area(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) ) + if ( !access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) ) break; wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]); if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab))) Status = -EFAULT; } break; - case RTPRIV_IOCTL_SET: -#if 0 - { - int i; - if( verify_area(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) ) - break; - - DBGPRINT(RT_DEBUG_TEMP, "RTPRIV_IOCTL_SET 0x%08x, wrq->u.data.length = %d\n", cmd,wrq->u.data.length, wrq->u.data.length); - DBGPRINT_RAW(RT_DEBUG_TRACE, "\n"); - for (i=0;iu.data.length;i++) - DBGPRINT_RAW(RT_DEBUG_TRACE, "[%c]", (wrq->u.data.length+i)); - DBGPRINT_RAW(RT_DEBUG_TRACE, "\n"); - #if 0 - char *this_char; - char *value; - char *poi = wrq->u.data.pointer; - while ((this_char = strsep(&poi, ",")) != NULL) - { - if (!*this_char) - continue; - - if ((value = strchr(this_char, '=')) != NULL) - *value++ = 0; - - if (!value || !*value) - continue; - - for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++) - { - if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0) - { - DBGPRINT(RT_DEBUG_TRACE, "ioctl::(iwpriv) [%s]\n", PRTMP_PRIVATE_SET_PROC->name); - if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value)) - { //FALSE:Set private failed then return Invalid argument - Status = -EINVAL; - } - break; //Exit for loop. - } - } - - if(PRTMP_PRIVATE_SET_PROC->name == NULL) - { //Not found argument - Status = -EINVAL; - DBGPRINT(RT_DEBUG_TRACE, "ioctl::(iwpriv) Not Support Set Command [%s=%s]\n", this_char, value); - break; - } - } - #endif - } -#endif - break; default: DBGPRINT(RT_DEBUG_INFO, "IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd); Status = -EOPNOTSUPP; diff -ruN rt2570-1.1.0-b1/Module/rtusb_init.c rt2570-cvs-2005122616/Module/rtusb_init.c --- rt2570-1.1.0-b1/Module/rtusb_init.c 2005-07-30 11:44:30.000000000 -0500 +++ rt2570-cvs-2005122616/Module/rtusb_init.c 2005-12-08 11:28:03.000000000 -0600 @@ -36,6 +36,7 @@ #include "rt_config.h" #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) +#include #define RT2570_USB_ALLOC_URB(iso) usb_alloc_urb(iso, GFP_ATOMIC); #else #define RT2570_USB_ALLOC_URB(iso) usb_alloc_urb(iso); @@ -367,14 +368,16 @@ // Use RaConfig as PSK agent. // Start STA supplicant state machine pAd->PortCfg.WpaState = SS_START; - printk("%s WPAPSK Key => \n", __FUNCTION__); + DBGPRINT(RT_DEBUG_LOUD, "%s WPAPSK Key => \n", __FUNCTION__); + DBGPRINT(RT_DEBUG_LOUD, " "); for (i = 0; i < 32; i++) { - printk("%02x:", pAd->PortCfg.PskKey.Key[i]); - if (i%16 == 15) - printk("\n"); + DBGPRINT_RAW(RT_DEBUG_LOUD, "%02x:", pAd->PortCfg.PskKey.Key[i]); + if (i%16 == 15) { + DBGPRINT_RAW(RT_DEBUG_LOUD, "\n"); + DBGPRINT(RT_DEBUG_LOUD, " "); } - printk("\n"); + DBGPRINT_RAW(RT_DEBUG_LOUD, "\n"); } } //DefaultKeyID @@ -1119,7 +1122,7 @@ RTUSBWriteMACRegister(pAdapter, MAC_CSR1, 4); RTUSBReadMACRegister(pAdapter, MAC_CSR0, &temp); - if ( temp == 3){ + if ( temp >= 3){ RTUSBReadMACRegister(pAdapter, PHY_CSR2, &temp); RTUSBWriteMACRegister(pAdapter, PHY_CSR2, temp & 0xFFFD); } @@ -1244,25 +1247,32 @@ PRT2570ADAPTER pAdapter = (PRT2570ADAPTER) net_dev->priv; // Creat MLME Thread +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) + // Creat MLME Thread pAdapter->MLMEThr_pid= -1; pAdapter->MLMEThr_pid = kernel_thread(MlmeThread, pAdapter, CLONE_VM); - if (pAdapter->MLMEThr_pid < 0) { - printk (KERN_WARNING "%s: unable to start mlme thread\n",pAdapter->net->name); - } + if (pAdapter->MLMEThr_pid < 0) + printk(KERN_WARNING "%s: unable to start mlme thread\n",pAdapter->net->name); // Creat Command Thread pAdapter->RTUSBCmdThr_pid= -1; - pAdapter->RTUSBCmdThr_pid = kernel_thread(RTUSBCmdThread, pAdapter, CLONE_VM); - if (pAdapter->RTUSBCmdThr_pid < 0) { - printk (KERN_WARNING "%s: unable to start RTUSBCmd thread\n",pAdapter->net->name); - } + if (pAdapter->RTUSBCmdThr_pid < 0) + printk(KERN_WARNING "%s: unable to start RTUSBCmd thread\n",pAdapter->net->name); +#else + // Creat MLME Thread + pAdapter->MLMEThr = kthread_run(MlmeThread, pAdapter, "rtusb-mlme"); + if (IS_ERR(pAdapter->MLMEThr)) + printk(KERN_WARNING "%s: unable to start mlme thread\n",pAdapter->net->name); + // Creat Command Thread + pAdapter->RTUSBCmdThr = kthread_run(RTUSBCmdThread, pAdapter, "rtusb-usbcmd"); + if (IS_ERR(pAdapter->RTUSBCmdThr)) + printk(KERN_WARNING "%s: unable to start RTUSBCmd thread\n",pAdapter->net->name); +#endif +} - /* Wait for the thread to start */ - //wait_for_completion(&(pAdapter->notify)); -} NDIS_STATUS RTMPAllocAdapterBlock( PRT2570ADAPTER *ppAdapter ) { NDIS_STATUS Status=NDIS_STATUS_SUCCESS; @@ -1639,7 +1649,9 @@ init_MUTEX(&(pAdapter->usbdev_semaphore)); init_MUTEX_LOCKED(&(pAdapter->mlme_semaphore)); init_MUTEX_LOCKED(&(pAdapter->RTUSBCmd_semaphore)); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) init_completion (&pAdapter->notify); +#endif NdisAllocateSpinLock(&pAdapter->CmdQLock); NdisAllocateSpinLock(&pAdapter->SendTxWaitQueueLock); NdisAllocateSpinLock(&pAdapter->BulkOutLock); @@ -1886,6 +1898,7 @@ pAdapter->PortCfg.Mibss = FALSE; pAdapter->PortCfg.Massoc = FALSE; pAdapter->PortCfg.Mauth = FALSE; + pAdapter->PortCfg.MallowRFMONTx = FALSE; // PHY specification pAdapter->PortCfg.PhyMode = PHY_11BG_MIXED; @@ -1920,11 +1933,12 @@ pAdapter->PortCfg.bHwRadio = TRUE; pAdapter->PortCfg.bSwRadio = TRUE; pAdapter->PortCfg.bRadio = TRUE; - printk("INIT bRadio=%d\n", pAdapter->PortCfg.bRadio); + DBGPRINT(RT_DEBUG_TEMP, "INIT bRadio=%d\n", pAdapter->PortCfg.bRadio); pAdapter->PortCfg.bHardwareRadio = FALSE; // Default is OFF pAdapter->PortCfg.bAutoTxAgc = FALSE; // Default is OFF pAdapter->PortCfg.bShowHiddenSSID = FALSE; // Default no show - + pAdapter->PortCfg.AdhocMode = 0; // b/g in adhoc + // Nitro mode control pAdapter->PortCfg.EnableTxBurst = 0; pAdapter->PortCfg.AutoReconnect = TRUE; @@ -2106,4 +2120,3 @@ del_timer_sync(&pTimer->Timer); } - diff -ruN rt2570-1.1.0-b1/Module/rtusb_io.c rt2570-cvs-2005122616/Module/rtusb_io.c --- rt2570-1.1.0-b1/Module/rtusb_io.c 2005-07-30 11:44:30.000000000 -0500 +++ rt2570-cvs-2005122616/Module/rtusb_io.c 2005-12-02 06:55:15.000000000 -0600 @@ -725,10 +725,14 @@ IN ULONG InformationBufferLength) { PCmdQElmt cmdqelmt = NULL; - - if (pAdapter->RTUSBCmdThr_pid < 0) - return NDIS_STATUS_RESOURCES; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) + if (pAdapter->RTUSBCmdThr_pid < 0) + return NDIS_STATUS_RESOURCES; +#else + if (!pAdapter->RTUSBCmdThr_active) + return NDIS_STATUS_RESOURCES; +#endif cmdqelmt = (PCmdQElmt) kmalloc(sizeof(CmdQElmt), GFP_KERNEL); if (!cmdqelmt) { @@ -815,8 +819,13 @@ { PCmdQElmt cmdqelmt = NULL; - if (pAdapter->RTUSBCmdThr_pid < 0) - return; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) + if (pAdapter->RTUSBCmdThr_pid < 0) + return NDIS_STATUS_RESOURCES; +#else + if (!pAdapter->RTUSBCmdThr_active) + return NDIS_STATUS_RESOURCES; +#endif switch (Oid) { @@ -865,7 +874,11 @@ break; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if ((cmdqelmt != NULL) && (cmdqelmt->InUse == FALSE) && (pAdapter->RTUSBCmdThr_pid > 0)) +#else + if ((cmdqelmt != NULL) && (cmdqelmt->InUse == FALSE) && (pAdapter->RTUSBCmdThr_active)) +#endif { cmdqelmt->InUse = TRUE; cmdqelmt->command = Oid; diff -ruN rt2570-1.1.0-b1/Module/rtusb_main.c rt2570-cvs-2005122616/Module/rtusb_main.c --- rt2570-1.1.0-b1/Module/rtusb_main.c 2005-07-30 11:44:30.000000000 -0500 +++ rt2570-cvs-2005122616/Module/rtusb_main.c 2005-12-18 15:59:59.000000000 -0600 @@ -43,12 +43,14 @@ #define KERNEL_20424 0x20418 #define KERNEL_20418 0x20412 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) /* Kernel thread and vars, which handles packets that are completed. Only * packets that have a "complete" function are sent here. This way, the * completion is run out of kernel context, and doesn't block the rest of * the stack. */ static int mlme_kill; static int RTUSBCmd_kill; +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) */ extern const struct iw_handler_def rt2500usb_iw_handler_def; @@ -199,7 +201,7 @@ pAd->iw_stats.status = 0; // Status - device dependent for now - pAd->iw_stats.qual.qual = 0;//pAd->Mlme.RoamCqi; // link quality (%retries, SNR, %missed beacons or better...) + pAd->iw_stats.qual.qual = pAd->Mlme.ChannelQuality;//pAd->Mlme.RoamCqi; // link quality (%retries, SNR, %missed beacons or better...) pAd->iw_stats.qual.level = pAd->PortCfg.LastRssi - RSSI_TO_DBM_OFFSET; // signal level (dBm) pAd->iw_stats.qual.noise = (pAd->PortCfg.LastR17Value > BBP_R17_DYNAMIC_UP_BOUND) ? BBP_R17_DYNAMIC_UP_BOUND : ((ULONG) pAd->PortCfg.LastR17Value); // noise level (dBm) @@ -244,22 +246,6 @@ MLME_QUEUE_ELEM MsgElem; DBGPRINT(RT_DEBUG_TRACE, "====> RTUSBHalt\n"); - // kill Mlme thread in close handler -#if 0 - if (pAdapter->MLMEThr_pid >= 0) { - printk("kill MLME thread Process\n"); - mlme_kill = 1; - up(&pAdapter->mlme_semaphore); - wmb(); // need to check - ret = kill_proc (pAdapter->MLMEThr_pid, SIGTERM, 1); - if (ret) { - printk (KERN_ERR "%s: unable to signal thread\n", pAdapter->net->name); - return; - } - wait_for_completion (&pAdapter->notify); - } -#endif - // // before set flag fRTMP_ADAPTER_HALT_IN_PROGRESS, // we should send a disassoc frame to our AP. // @@ -1090,13 +1076,13 @@ DBGPRINT(RT_DEBUG_TRACE, "Set::OID_802_11_ADD_KEY \n"); { int i = 0; - PNDIS_802_11_KEY pkey = (PNDIS_802_11_KEY)pData; - DBGPRINT(RT_DEBUG_INFO,"pKey->KeyMaterial =\n "); + DBGPRINT(RT_DEBUG_INFO,"pKey->KeyMaterial = "); for (i = 0; i < 16; i++) { - DBGPRINT_RAW(RT_DEBUG_INFO,"%02x:", pkey->KeyMaterial[i]); + DBGPRINT_RAW(RT_DEBUG_INFO,"%02x:", + ((PNDIS_802_11_KEY)pData)->KeyMaterial[i]); } - DBGPRINT(RT_DEBUG_INFO,"\n"); + DBGPRINT_RAW(RT_DEBUG_INFO,"\n"); } NdisStatus = RTMPWPAAddKeyProc(pAdapter, pData); RTUSBBulkReceive(pAdapter); @@ -1135,7 +1121,7 @@ if ((cmdqelmt->command != RT_OID_SINGLE_READ_MAC) && (cmdqelmt->command != RT_OID_MULTI_READ_MAC) && (cmdqelmt->command != RT_OID_VENDOR_READ_BBP) && -#if DBG +#ifdef DBG (cmdqelmt->command != RT_OID_802_11_QUERY_HARDWARE_REGISTER) && #endif (cmdqelmt->command != RT_OID_USB_VENDOR_EEPROM_READ)) @@ -1223,8 +1209,10 @@ } // mlmethread flag restart +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) mlme_kill = 0; RTUSBCmd_kill =0; +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) */ CreateThreads(net_dev); // at every open handler, copy mac address. @@ -1289,10 +1277,11 @@ pAdapter->wait = NULL; remove_wait_queue (&unlink_wakeup, &wait); - if (pAdapter->MLMEThr_pid >= 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) + if (pAdapter->MLMEThr_pid >= 0) { mlme_kill = 1; - RTUSBUp(pAdapter, (&(pAdapter->mlme_semaphore))); + RTUSBCMDUp(pAdapter, (&(pAdapter->mlme_semaphore))); wmb(); // need to check ret = kill_proc (pAdapter->MLMEThr_pid, SIGTERM, 1); if (ret) @@ -1302,10 +1291,10 @@ } wait_for_completion (&pAdapter->notify); } - if (pAdapter->RTUSBCmdThr_pid>= 0) + if (pAdapter->RTUSBCmdThr_pid>= 0) { RTUSBCmd_kill = 1; - RTUSBUp(pAdapter, (&(pAdapter->RTUSBCmd_semaphore))); + RTUSBCMDUp(pAdapter, (&(pAdapter->RTUSBCmd_semaphore))); wmb(); // need to check ret = kill_proc (pAdapter->RTUSBCmdThr_pid, SIGTERM, 1); if (ret) @@ -1313,8 +1302,28 @@ printk (KERN_ERR "%s: unable to signal thread\n", pAdapter->net->name); return ret; } - wait_for_completion (&pAdapter->notify); + wait_for_completion (&pAdapter->notify); + } +#else + if (pAdapter->MLMEThr_active) + { + ret = kthread_stop(pAdapter->MLMEThr); + if (ret) + { + printk (KERN_ERR "%s: unable to stop thread\n", pAdapter->net->name); + return ret; + } } + if (pAdapter->RTUSBCmdThr_active) + { + ret = kthread_stop(pAdapter->RTUSBCmdThr); + if (ret) + { + printk (KERN_ERR "%s: unable to stop thread\n", pAdapter->net->name); + return ret; + } + } +#endif RTUSBHalt( pAdapter, FALSE); DBGPRINT(RT_DEBUG_TEMP,"<--usb_rt2570_close\n"); @@ -1326,23 +1335,28 @@ int MlmeThread(void * Context) { PRT2570ADAPTER pAdapter = (PRT2570ADAPTER)Context; - +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) + pAdapter->MLMEThr_active = 1; +#else daemonize(); current->flags |= PF_NOFREEZE; /* signal that we've started the thread */ complete(&(pAdapter->notify)); -#if 1 +#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) */ + while (1) { - //if(down_interruptible(&pAdapter->mlme_semaphore)) - //break; - +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) + if (kthread_should_stop()) + break; +#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) */ /* lock the device pointers */ down(&(pAdapter->mlme_semaphore)); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if (mlme_kill) break; - +#endif /* lock the device pointers , need to check if required*/ down(&(pAdapter->usbdev_semaphore)); MlmeHandler(pAdapter); @@ -1350,67 +1364,56 @@ /* unlock the device pointers */ up(&(pAdapter->usbdev_semaphore)); } -#else - // I tried this way for thread handling - while(1) - { - timeout = next_tick; - do { - timeout = interruptible_sleep_on_timeout (&pAdapter->MLMEThr_wait, timeout); - /* make swsusp happy with our thread */ - if (current->flags & PF_FREEZE) - refrigerator(PF_FREEZE); - DBGPRINT(RT_DEBUG_TRACE, "current->flags = 0x%x\n",current->flags ); - } while (!signal_pending (current) && (timeout > 0)); - - if (signal_pending (current)) { - flush_signals(current); - } - - if (mlme_kill) - break; - } -#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) /* notify the exit routine that we're actually exiting now - * - * complete()/wait_for_completion() is similar to up()/down(), - * except that complete() is safe in the case where the structure - * is getting deleted in a parallel mode of execution (i.e. just - * after the down() -- that's necessary for the thread-shutdown - * case. - * - * complete_and_exit() goes even further than this -- it is safe in - * the case that the thread of the caller is going away (not just - * the structure) -- this is necessary for the module-remove case. - * This is important in preemption kernels, which transfer the flow - * of execution immediately upon a complete(). - */ + * + * complete()/wait_for_completion() is similar to up()/down(), + * except that complete() is safe in the case where the structure + * is getting deleted in a parallel mode of execution (i.e. just + * after the down() -- that's necessary for the thread-shutdown + * case. + * + * complete_and_exit() goes even further than this -- it is safe in + * the case that the thread of the caller is going away (not just + * the structure) -- this is necessary for the module-remove case. + * This is important in preemption kernels, which transfer the flow + * of execution immediately upon a complete(). + */ complete_and_exit (&pAdapter->notify, 0); DBGPRINT(RT_DEBUG_TRACE, "<---MlmeThread\n"); - +#else + DBGPRINT(RT_DEBUG_TRACE, "MlmeThread end\n"); + pAdapter->MLMEThr_active = 0; +#endif + return 0; } + int RTUSBCmdThread(void * Context) { - PRT2570ADAPTER pAdapter = (PRT2570ADAPTER)Context; - +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) daemonize(); current->flags |= PF_NOFREEZE; /* signal that we've started the thread */ complete(&(pAdapter->notify)); +#else + pAdapter->RTUSBCmdThr_active = 1; +#endif while (1) { - //if(down_interruptible(&pAdapter->mlme_semaphore)) - //break; +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) + if (kthread_should_stop()) + break; +#endif /* lock the device pointers */ down(&(pAdapter->RTUSBCmd_semaphore)); - +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if (RTUSBCmd_kill) break; - +#endif /* lock the device pointers , need to check if required*/ down(&(pAdapter->usbdev_semaphore)); CMDHandler(pAdapter); @@ -1418,24 +1421,14 @@ /* unlock the device pointers */ up(&(pAdapter->usbdev_semaphore)); } - - /* notify the exit routine that we're actually exiting now - * - * complete()/wait_for_completion() is similar to up()/down(), - * except that complete() is safe in the case where the structure - * is getting deleted in a parallel mode of execution (i.e. just - * after the down() -- that's necessary for the thread-shutdown - * case. - * - * complete_and_exit() goes even further than this -- it is safe in - * the case that the thread of the caller is going away (not just - * the structure) -- this is necessary for the module-remove case. - * This is important in preemption kernels, which transfer the flow - * of execution immediately upon a complete(). - */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) complete_and_exit (&pAdapter->notify, 0); DBGPRINT(RT_DEBUG_TRACE, "<---RTUSBCmdThread\n"); - +#else + DBGPRINT(RT_DEBUG_TRACE, "RTUSBCmdThread end\n"); + pAdapter->RTUSBCmdThr_active = 0; +#endif + return 0; } static void *usb_rtusb_probe(struct usb_device *dev, UINT interface, @@ -1449,10 +1442,12 @@ for (i = 0; i < rtusb_usb_id_len; i++) { - if (dev->descriptor.idVendor == rtusb_usb_id[i].idVendor && - dev->descriptor.idProduct == rtusb_usb_id[i].idProduct) + if (le16_to_cpu(dev->descriptor.idVendor) == rtusb_usb_id[i].idVendor && + le16_to_cpu(dev->descriptor.idProduct) == rtusb_usb_id[i].idProduct) { - printk("idVendor = 0x%x, idProduct = 0x%x \n",dev->descriptor.idVendor, dev->descriptor.idProduct); + printk("idVendor = 0x%x, idProduct = 0x%x \n", + le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct)); break; } } @@ -1508,7 +1503,7 @@ for (device = dev_base; device != NULL; device = device->next) { - if (strncmp(device->name, slot_name, 4) == 0) + if (strncmp(device->name, slot_name, 6) == 0) { break; } @@ -1535,7 +1530,7 @@ // start as if the link is up // netif_device_attach (pAdapter->net); - PortInitCfg(pAdapter); + PortCfgInit(pAdapter); return pAdapter; out3: @@ -1564,13 +1559,7 @@ printk("unregister_netdev( )\n"); unregister_netdev (pAdapter->net); } - udelay(1); - udelay(1); - while (MOD_IN_USE > 0) { - MOD_DEC_USE_COUNT; - } - udelay(1); DBGPRINT(RT_DEBUG_ERROR,"<=== RTUSB disconnect successfully\n"); } @@ -1601,10 +1590,11 @@ pAdapter->wait = NULL; remove_wait_queue (&unlink_wakeup, &wait); - if (pAdapter->MLMEThr_pid >= 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) + if (pAdapter->MLMEThr_pid >= 0) { mlme_kill = 1; - RTUSBUp(pAdapter, (&(pAdapter->mlme_semaphore))); + RTUSBCMDUp(pAdapter, (&(pAdapter->mlme_semaphore))); wmb(); // need to check ret = kill_proc (pAdapter->MLMEThr_pid, SIGTERM, 1); if (ret) @@ -1614,10 +1604,10 @@ } wait_for_completion (&pAdapter->notify); } - if (pAdapter->RTUSBCmdThr_pid>= 0) + if (pAdapter->RTUSBCmdThr_pid>= 0) { RTUSBCmd_kill = 1; - RTUSBUp(pAdapter, (&(pAdapter->RTUSBCmd_semaphore))); + RTUSBCMDUp(pAdapter, (&(pAdapter->RTUSBCmd_semaphore))); wmb(); // need to check ret = kill_proc (pAdapter->RTUSBCmdThr_pid, SIGTERM, 1); if (ret) @@ -1627,6 +1617,26 @@ } wait_for_completion (&pAdapter->notify); } +#else + if (pAdapter->MLMEThr_active) + { + ret = kthread_stop(pAdapter->MLMEThr); + if (ret) + { + printk (KERN_ERR "%s: unable to stop thread\n", pAdapter->net->name); + return ret; + } + } + if (pAdapter->RTUSBCmdThr_active) + { + ret = kthread_stop(pAdapter->RTUSBCmdThr); + if (ret) + { + printk (KERN_ERR "%s: unable to stop thread\n", pAdapter->net->name); + return ret; + } + } +#endif RTUSBHalt( pAdapter, FALSE); DBGPRINT(RT_DEBUG_TEMP,"<--usb_rt2570_close\n"); @@ -1638,130 +1648,91 @@ int MlmeThread(void * Context) { PRT2570ADAPTER pAdapter = (PRT2570ADAPTER)Context; - +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) daemonize("rt2500usb"); allow_signal(SIGTERM); current->flags |= PF_NOFREEZE; /* signal that we've started the thread */ complete(&(pAdapter->notify)); -#if 1 +#else + pAdapter->MLMEThr_active = 1; +#endif + while (1) { - //if(down_interruptible(&pAdapter->mlme_semaphore)) - //break; - +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) + if (kthread_should_stop()) + break; +#endif /* lock the device pointers */ down(&(pAdapter->mlme_semaphore)); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if (mlme_kill) break; - +#endif /* lock the device pointers , need to check if required*/ down(&(pAdapter->usbdev_semaphore)); -#if 0 - if (current->flags & PF_FREEZE) { - refrigerator(0); - } -#endif + MlmeHandler(pAdapter); /* unlock the device pointers */ up(&(pAdapter->usbdev_semaphore)); } -#else - // I tried this way for thread handling - while(1) - { - timeout = next_tick; - do { - timeout = interruptible_sleep_on_timeout (&pAdapter->MLMEThr_wait, timeout); - /* make swsusp happy with our thread */ - if (current->flags & PF_FREEZE) - refrigerator(PF_FREEZE); - DBGPRINT(RT_DEBUG_TRACE, "current->flags = 0x%x\n",current->flags ); - } while (!signal_pending (current) && (timeout > 0)); - - if (signal_pending (current)) { - flush_signals(current); - } - - if (mlme_kill) - break; - } -#endif - - /* notify the exit routine that we're actually exiting now - * - * complete()/wait_for_completion() is similar to up()/down(), - * except that complete() is safe in the case where the structure - * is getting deleted in a parallel mode of execution (i.e. just - * after the down() -- that's necessary for the thread-shutdown - * case. - * - * complete_and_exit() goes even further than this -- it is safe in - * the case that the thread of the caller is going away (not just - * the structure) -- this is necessary for the module-remove case. - * This is important in preemption kernels, which transfer the flow - * of execution immediately upon a complete(). - */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) complete_and_exit (&pAdapter->notify, 0); DBGPRINT(RT_DEBUG_TRACE, "<---MlmeThread\n"); - +#else + DBGPRINT(RT_DEBUG_TRACE, "MlmeThread end\n"); + pAdapter->MLMEThr_active = 0; +#endif + return 0; } + int RTUSBCmdThread(void * Context) { PRT2570ADAPTER pAdapter = (PRT2570ADAPTER)Context; - +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) daemonize("rt2500usb"); allow_signal(SIGTERM); current->flags |= PF_NOFREEZE; /* signal that we've started the thread */ complete(&(pAdapter->notify)); +#else + pAdapter->RTUSBCmdThr_active = 1; +#endif while (1) { - //if(down_interruptible(&pAdapter->mlme_semaphore)) - //break; - +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0) + if (kthread_should_stop()) + break; +#endif /* lock the device pointers */ down(&(pAdapter->RTUSBCmd_semaphore)); - +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) if (RTUSBCmd_kill) break; - +#endif /* lock the device pointers , need to check if required*/ down(&(pAdapter->usbdev_semaphore)); -#if 0 - if (current->flags & PF_FREEZE) { - refrigerator(0); - // continue; - } -#endif + CMDHandler(pAdapter); /* unlock the device pointers */ up(&(pAdapter->usbdev_semaphore)); } - - /* notify the exit routine that we're actually exiting now - * - * complete()/wait_for_completion() is similar to up()/down(), - * except that complete() is safe in the case where the structure - * is getting deleted in a parallel mode of execution (i.e. just - * after the down() -- that's necessary for the thread-shutdown - * case. - * - * complete_and_exit() goes even further than this -- it is safe in - * the case that the thread of the caller is going away (not just - * the structure) -- this is necessary for the module-remove case. - * This is important in preemption kernels, which transfer the flow - * of execution immediately upon a complete(). - */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) complete_and_exit (&pAdapter->notify, 0); DBGPRINT(RT_DEBUG_TRACE, "<---RTUSBCmdThread\n"); - +#else + DBGPRINT(RT_DEBUG_TRACE, "RTUSBCmdThread end\n"); + pAdapter->RTUSBCmdThr_active = 0; +#endif + return 0; } + static int usb_rtusb_probe (struct usb_interface *intf, const struct usb_device_id *id) { @@ -1775,10 +1746,12 @@ usb_get_dev(dev); for (i = 0; i < rtusb_usb_id_len; i++) { - if (dev->descriptor.idVendor == rtusb_usb_id[i].idVendor && - dev->descriptor.idProduct == rtusb_usb_id[i].idProduct) + if (le16_to_cpu(dev->descriptor.idVendor) == rtusb_usb_id[i].idVendor && + le16_to_cpu(dev->descriptor.idProduct) == rtusb_usb_id[i].idProduct) { - printk("idVendor = 0x%x, idProduct = 0x%x \n",dev->descriptor.idVendor, dev->descriptor.idProduct); + printk("idVendor = 0x%x, idProduct = 0x%x \n", + le16_to_cpu(dev->descriptor.idVendor), + le16_to_cpu(dev->descriptor.idProduct)); break; } } @@ -1822,8 +1795,13 @@ pAdapter->net->addr_len = 6; pAdapter->net->weight = 64; pAdapter->MediaState = NdisMediaStateDisconnected; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0) pAdapter->MLMEThr_pid= -1; pAdapter->RTUSBCmdThr_pid= -1; +#else + pAdapter->MLMEThr_active = 0; + pAdapter->RTUSBCmdThr_active = 0; +#endif RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_RESET_IN_PROGRESS); SET_NETDEV_DEV(pAdapter->net, &intf->dev); @@ -1839,7 +1817,7 @@ for (device = dev_base; device != NULL; device = device->next) { - if (strncmp(device->name, slot_name, 4) == 0) + if (strncmp(device->name, slot_name, 6) == 0) { break; } diff -ruN rt2570-1.1.0-b1/Module/sync.c rt2570-cvs-2005122616/Module/sync.c --- rt2570-1.1.0-b1/Module/sync.c 2005-07-30 11:44:30.000000000 -0500 +++ rt2570-cvs-2005122616/Module/sync.c 2005-09-12 08:46:15.000000000 -0500 @@ -203,6 +203,9 @@ UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, ScanType, BssType; ULONG Now; + if (pAd->PortCfg.BssType == BSS_MONITOR) + return; + DBGPRINT(RT_DEBUG_INFO, "SYNC - MlmeScanReqAction\n"); #if 0 // Check the total scan tries for one single OID command diff -ruN rt2570-1.1.0-b1/README rt2570-cvs-2005122616/README --- rt2570-1.1.0-b1/README 1969-12-31 18:00:00.000000000 -0600 +++ rt2570-cvs-2005122616/README 2005-11-18 18:05:36.000000000 -0600 @@ -0,0 +1,53 @@ +Installation instructions for the rt2570 Module + +======================================================================= +Build Instructions: +==================== + For 2.4 or 2.6 series kernel: + + a. $tar -xvzf rt2570-x.x.x.tar.gz + go to "./rt2570-x.x.x/Module" directory. + + b. $make # compile driver source code + + c. $make install # installs kernel module driver + + d. $modprobe rt2570 + +======================================================================= +UTILITY +==================== + There is no utility as of yet, use iwconfig to configure your usb stick. + +======================================================================= +CONFIGURATION: +==================== + RT2570 driver can be configured via following interfaces, + i.e. (i)"iwconfig" command, (ii)"iwpriv" command + + i) iwconfig comes with kernel. + ii) iwpriv usage, please refer to file "iwpriv_usage.txt" for details. + +MORE INFORMATION +================================================================================= + If you want for rt2570 driver to auto-load at boot time: + + A) choose rausb0 for first RT2570 WLAN card, rausb1 for second RT2570 WLAN card, etc. + + B) create(edit) 'ifcfg-rausb0' file in /etc/sysconfig/network-scripts/, + edit( or add the line) in /etc/modules.conf: + alias rausb0 rt2570 + + C) edit(create) the file /etc/sysconfig/network-scripts/ifcfg-rausb0 + DEVICE='rausb0' + ONBOOT='yes' + + + NOTE: + if you use dhcp, add this line too . + BOOTPROTO='dhcp' + + *D) To ease the Default Gateway setting, + add the line + GATEWAY=x.x.x.x + in /etc/sysconfig/network diff -ruN rt2570-1.1.0-b1/THANKS rt2570-cvs-2005122616/THANKS --- rt2570-1.1.0-b1/THANKS 2005-07-30 11:44:30.000000000 -0500 +++ rt2570-cvs-2005122616/THANKS 2005-11-18 18:05:36.000000000 -0600 @@ -17,3 +17,5 @@ and hence progressed the rt2570 along the way * Christian Casteyde - casteydec@users.sourceforge.net * Mathias Klein - ma_klein@gmx.de +* Stephen Warren - SWarren@nvidia.com +* James Elsdon - monkesys@westnet.com.au