diff options
Diffstat (limited to 'drivers/staging/vt6656')
43 files changed, 1718 insertions, 6193 deletions
diff --git a/drivers/staging/vt6656/Makefile b/drivers/staging/vt6656/Makefile index 1d829b46c2e..b5ec483f3eb 100644 --- a/drivers/staging/vt6656/Makefile +++ b/drivers/staging/vt6656/Makefile @@ -18,8 +18,6 @@ vt6656_stage-y += main_usb.o \ datarate.o \ rc4.o \ tether.o \ - tcrc.o \ - hostap.o \ wpa.o \ key.o \ tkip.o \ @@ -27,10 +25,8 @@ vt6656_stage-y += main_usb.o \ rf.o \ iwctl.o \ wpactl.o \ - aes_ccmp.o \ usbpipe.o \ channel.o \ - control.o \ firmware.o \ int.o diff --git a/drivers/staging/vt6656/aes_ccmp.c b/drivers/staging/vt6656/aes_ccmp.c deleted file mode 100644 index e2bfa8d266c..00000000000 --- a/drivers/staging/vt6656/aes_ccmp.c +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: aes_ccmp.c - * - * Purpose: AES_CCMP decryption - * - * Author: Warren Hsu - * - * Date: Feb 15, 2005 - * - * Functions: - * AESbGenCCMP - Parsing RX-packet - * - * Revision History: - */ - -#include "device.h" -#include "80211hdr.h" - -/* - * SBOX Table - */ - -static u8 sbox_table[256] = { - 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, - 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, - 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, - 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, - 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, - 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, - 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, - 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, - 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, - 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, - 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, - 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, - 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, - 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, - 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, - 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 -}; - -static u8 dot2_table[256] = { - 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, - 0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e, - 0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e, - 0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e, - 0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e, - 0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe, - 0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde, - 0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0xfe, - 0x1b, 0x19, 0x1f, 0x1d, 0x13, 0x11, 0x17, 0x15, 0x0b, 0x09, 0x0f, 0x0d, 0x03, 0x01, 0x07, 0x05, - 0x3b, 0x39, 0x3f, 0x3d, 0x33, 0x31, 0x37, 0x35, 0x2b, 0x29, 0x2f, 0x2d, 0x23, 0x21, 0x27, 0x25, - 0x5b, 0x59, 0x5f, 0x5d, 0x53, 0x51, 0x57, 0x55, 0x4b, 0x49, 0x4f, 0x4d, 0x43, 0x41, 0x47, 0x45, - 0x7b, 0x79, 0x7f, 0x7d, 0x73, 0x71, 0x77, 0x75, 0x6b, 0x69, 0x6f, 0x6d, 0x63, 0x61, 0x67, 0x65, - 0x9b, 0x99, 0x9f, 0x9d, 0x93, 0x91, 0x97, 0x95, 0x8b, 0x89, 0x8f, 0x8d, 0x83, 0x81, 0x87, 0x85, - 0xbb, 0xb9, 0xbf, 0xbd, 0xb3, 0xb1, 0xb7, 0xb5, 0xab, 0xa9, 0xaf, 0xad, 0xa3, 0xa1, 0xa7, 0xa5, - 0xdb, 0xd9, 0xdf, 0xdd, 0xd3, 0xd1, 0xd7, 0xd5, 0xcb, 0xc9, 0xcf, 0xcd, 0xc3, 0xc1, 0xc7, 0xc5, - 0xfb, 0xf9, 0xff, 0xfd, 0xf3, 0xf1, 0xf7, 0xf5, 0xeb, 0xe9, 0xef, 0xed, 0xe3, 0xe1, 0xe7, 0xe5 -}; - -static u8 dot3_table[256] = { - 0x00, 0x03, 0x06, 0x05, 0x0c, 0x0f, 0x0a, 0x09, 0x18, 0x1b, 0x1e, 0x1d, 0x14, 0x17, 0x12, 0x11, - 0x30, 0x33, 0x36, 0x35, 0x3c, 0x3f, 0x3a, 0x39, 0x28, 0x2b, 0x2e, 0x2d, 0x24, 0x27, 0x22, 0x21, - 0x60, 0x63, 0x66, 0x65, 0x6c, 0x6f, 0x6a, 0x69, 0x78, 0x7b, 0x7e, 0x7d, 0x74, 0x77, 0x72, 0x71, - 0x50, 0x53, 0x56, 0x55, 0x5c, 0x5f, 0x5a, 0x59, 0x48, 0x4b, 0x4e, 0x4d, 0x44, 0x47, 0x42, 0x41, - 0xc0, 0xc3, 0xc6, 0xc5, 0xcc, 0xcf, 0xca, 0xc9, 0xd8, 0xdb, 0xde, 0xdd, 0xd4, 0xd7, 0xd2, 0xd1, - 0xf0, 0xf3, 0xf6, 0xf5, 0xfc, 0xff, 0xfa, 0xf9, 0xe8, 0xeb, 0xee, 0xed, 0xe4, 0xe7, 0xe2, 0xe1, - 0xa0, 0xa3, 0xa6, 0xa5, 0xac, 0xaf, 0xaa, 0xa9, 0xb8, 0xbb, 0xbe, 0xbd, 0xb4, 0xb7, 0xb2, 0xb1, - 0x90, 0x93, 0x96, 0x95, 0x9c, 0x9f, 0x9a, 0x99, 0x88, 0x8b, 0x8e, 0x8d, 0x84, 0x87, 0x82, 0x81, - 0x9b, 0x98, 0x9d, 0x9e, 0x97, 0x94, 0x91, 0x92, 0x83, 0x80, 0x85, 0x86, 0x8f, 0x8c, 0x89, 0x8a, - 0xab, 0xa8, 0xad, 0xae, 0xa7, 0xa4, 0xa1, 0xa2, 0xb3, 0xb0, 0xb5, 0xb6, 0xbf, 0xbc, 0xb9, 0xba, - 0xfb, 0xf8, 0xfd, 0xfe, 0xf7, 0xf4, 0xf1, 0xf2, 0xe3, 0xe0, 0xe5, 0xe6, 0xef, 0xec, 0xe9, 0xea, - 0xcb, 0xc8, 0xcd, 0xce, 0xc7, 0xc4, 0xc1, 0xc2, 0xd3, 0xd0, 0xd5, 0xd6, 0xdf, 0xdc, 0xd9, 0xda, - 0x5b, 0x58, 0x5d, 0x5e, 0x57, 0x54, 0x51, 0x52, 0x43, 0x40, 0x45, 0x46, 0x4f, 0x4c, 0x49, 0x4a, - 0x6b, 0x68, 0x6d, 0x6e, 0x67, 0x64, 0x61, 0x62, 0x73, 0x70, 0x75, 0x76, 0x7f, 0x7c, 0x79, 0x7a, - 0x3b, 0x38, 0x3d, 0x3e, 0x37, 0x34, 0x31, 0x32, 0x23, 0x20, 0x25, 0x26, 0x2f, 0x2c, 0x29, 0x2a, - 0x0b, 0x08, 0x0d, 0x0e, 0x07, 0x04, 0x01, 0x02, 0x13, 0x10, 0x15, 0x16, 0x1f, 0x1c, 0x19, 0x1a -}; - -static void xor_128(u8 *a, u8 *b, u8 *out) -{ - u32 *dwPtrA = (u32 *) a; - u32 *dwPtrB = (u32 *) b; - u32 *dwPtrOut = (u32 *) out; - - (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); - (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); - (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); - (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); -} - -static void xor_32(u8 *a, u8 *b, u8 *out) -{ - u32 *dwPtrA = (u32 *) a; - u32 *dwPtrB = (u32 *) b; - u32 *dwPtrOut = (u32 *) out; - - (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); -} - -static void AddRoundKey(u8 *key, int round) -{ - u8 sbox_key[4]; - u8 rcon_table[10] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36}; - - sbox_key[0] = sbox_table[key[13]]; - sbox_key[1] = sbox_table[key[14]]; - sbox_key[2] = sbox_table[key[15]]; - sbox_key[3] = sbox_table[key[12]]; - - key[0] = key[0] ^ rcon_table[round]; - xor_32(&key[0], sbox_key, &key[0]); - - xor_32(&key[4], &key[0], &key[4]); - xor_32(&key[8], &key[4], &key[8]); - xor_32(&key[12], &key[8], &key[12]); -} - -static void SubBytes(u8 *in, u8 *out) -{ - int i; - - for (i = 0; i < 16; i++) - out[i] = sbox_table[in[i]]; -} - -static void ShiftRows(u8 *in, u8 *out) -{ - out[0] = in[0]; - out[1] = in[5]; - out[2] = in[10]; - out[3] = in[15]; - out[4] = in[4]; - out[5] = in[9]; - out[6] = in[14]; - out[7] = in[3]; - out[8] = in[8]; - out[9] = in[13]; - out[10] = in[2]; - out[11] = in[7]; - out[12] = in[12]; - out[13] = in[1]; - out[14] = in[6]; - out[15] = in[11]; -} - -static void MixColumns(u8 *in, u8 *out) -{ - - out[0] = dot2_table[in[0]] ^ dot3_table[in[1]] ^ in[2] ^ in[3]; - out[1] = in[0] ^ dot2_table[in[1]] ^ dot3_table[in[2]] ^ in[3]; - out[2] = in[0] ^ in[1] ^ dot2_table[in[2]] ^ dot3_table[in[3]]; - out[3] = dot3_table[in[0]] ^ in[1] ^ in[2] ^ dot2_table[in[3]]; -} - -static void AESv128(u8 *key, u8 *data, u8 *ciphertext) -{ - int i; - int round; - u8 TmpdataA[16]; - u8 TmpdataB[16]; - u8 abyRoundKey[16]; - - for (i = 0; i < 16; i++) - abyRoundKey[i] = key[i]; - - for (round = 0; round < 11; round++) { - if (round == 0) { - xor_128(abyRoundKey, data, ciphertext); - AddRoundKey(abyRoundKey, round); - } else if (round == 10) { - SubBytes(ciphertext, TmpdataA); - ShiftRows(TmpdataA, TmpdataB); - xor_128(TmpdataB, abyRoundKey, ciphertext); - } else { /* round 1 ~ 9 */ - SubBytes(ciphertext, TmpdataA); - ShiftRows(TmpdataA, TmpdataB); - MixColumns(&TmpdataB[0], &TmpdataA[0]); - MixColumns(&TmpdataB[4], &TmpdataA[4]); - MixColumns(&TmpdataB[8], &TmpdataA[8]); - MixColumns(&TmpdataB[12], &TmpdataA[12]); - xor_128(TmpdataA, abyRoundKey, ciphertext); - AddRoundKey(abyRoundKey, round); - } - } - -} - -/* - * Description: AES decryption - * - * Parameters: - * In: - * pbyRxKey - The key used to decrypt - * pbyFrame - Starting address of packet header - * wFrameSize - Total packet size including CRC - * Out: - * none - * - * Return Value: MIC compare result - * - */ - -bool AESbGenCCMP(u8 *pbyRxKey, u8 *pbyFrame, u16 wFrameSize) -{ - u8 abyNonce[13]; - u8 MIC_IV[16]; - u8 MIC_HDR1[16]; - u8 MIC_HDR2[16]; - u8 abyMIC[16]; - u8 abyCTRPLD[16]; - u8 abyTmp[16]; - u8 abyPlainText[16]; - u8 abyLastCipher[16]; - - struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *) pbyFrame; - u8 *pbyIV; - u8 *pbyPayload; - u16 wHLen = 22; - /* 8 is IV, 8 is MIC, 4 is CRC */ - u16 wPayloadSize = wFrameSize - 8 - 8 - 4 - WLAN_HDR_ADDR3_LEN; - bool bA4 = false; - u8 byTmp; - u16 wCnt; - int ii, jj, kk; - - pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN; - if (WLAN_GET_FC_TODS(*(u16 *) pbyFrame) && - WLAN_GET_FC_FROMDS(*(u16 *) pbyFrame)) { - bA4 = true; - pbyIV += 6; /* 6 is 802.11 address4 */ - wHLen += 6; - wPayloadSize -= 6; - } - pbyPayload = pbyIV + 8; /* IV-length */ - - abyNonce[0] = 0x00; /* now is 0, if Qos here will be priority */ - memcpy(&(abyNonce[1]), pMACHeader->addr2, ETH_ALEN); - abyNonce[7] = pbyIV[7]; - abyNonce[8] = pbyIV[6]; - abyNonce[9] = pbyIV[5]; - abyNonce[10] = pbyIV[4]; - abyNonce[11] = pbyIV[1]; - abyNonce[12] = pbyIV[0]; - - /* MIC_IV */ - MIC_IV[0] = 0x59; - memcpy(&(MIC_IV[1]), &(abyNonce[0]), 13); - MIC_IV[14] = (u8)(wPayloadSize >> 8); - MIC_IV[15] = (u8)(wPayloadSize & 0xff); - - /* MIC_HDR1 */ - MIC_HDR1[0] = (u8)(wHLen >> 8); - MIC_HDR1[1] = (u8)(wHLen & 0xff); - byTmp = (u8)(le16_to_cpu(pMACHeader->frame_control) >> 8); - MIC_HDR1[2] = byTmp & 0x8f; - byTmp = (u8)(le16_to_cpu(pMACHeader->frame_control) & 0xff); - byTmp &= 0x87; - MIC_HDR1[3] = byTmp | 0x40; - memcpy(&(MIC_HDR1[4]), pMACHeader->addr1, ETH_ALEN); - memcpy(&(MIC_HDR1[10]), pMACHeader->addr2, ETH_ALEN); - - /* MIC_HDR2 */ - memcpy(&(MIC_HDR2[0]), pMACHeader->addr3, ETH_ALEN); - byTmp = (u8)(le16_to_cpu(pMACHeader->seq_ctrl) >> 8); - MIC_HDR2[6] = byTmp & 0x0f; - MIC_HDR2[7] = 0; - - if (bA4) { - memcpy(&(MIC_HDR2[8]), pMACHeader->addr4, ETH_ALEN); - } else { - MIC_HDR2[8] = 0x00; - MIC_HDR2[9] = 0x00; - MIC_HDR2[10] = 0x00; - MIC_HDR2[11] = 0x00; - MIC_HDR2[12] = 0x00; - MIC_HDR2[13] = 0x00; - } - MIC_HDR2[14] = 0x00; - MIC_HDR2[15] = 0x00; - - /* CCMP */ - AESv128(pbyRxKey, MIC_IV, abyMIC); - for (kk = 0; kk < 16; kk++) - abyTmp[kk] = MIC_HDR1[kk] ^ abyMIC[kk]; - - AESv128(pbyRxKey, abyTmp, abyMIC); - for (kk = 0; kk < 16; kk++) - abyTmp[kk] = MIC_HDR2[kk] ^ abyMIC[kk]; - - AESv128(pbyRxKey, abyTmp, abyMIC); - - wCnt = 1; - abyCTRPLD[0] = 0x01; - memcpy(&(abyCTRPLD[1]), &(abyNonce[0]), 13); - - for (jj = wPayloadSize; jj > 16; jj = jj-16) { - - abyCTRPLD[14] = (u8) (wCnt >> 8); - abyCTRPLD[15] = (u8) (wCnt & 0xff); - - AESv128(pbyRxKey, abyCTRPLD, abyTmp); - - for (kk = 0; kk < 16; kk++) - abyPlainText[kk] = abyTmp[kk] ^ pbyPayload[kk]; - - for (kk = 0; kk < 16; kk++) - abyTmp[kk] = abyMIC[kk] ^ abyPlainText[kk]; - - AESv128(pbyRxKey, abyTmp, abyMIC); - - memcpy(pbyPayload, abyPlainText, 16); - wCnt++; - pbyPayload += 16; - } /* for wPayloadSize */ - - /* last payload */ - memcpy(&(abyLastCipher[0]), pbyPayload, jj); - for (ii = jj; ii < 16; ii++) - abyLastCipher[ii] = 0x00; - - abyCTRPLD[14] = (u8) (wCnt >> 8); - abyCTRPLD[15] = (u8) (wCnt & 0xff); - - AESv128(pbyRxKey, abyCTRPLD, abyTmp); - for (kk = 0; kk < 16; kk++) - abyPlainText[kk] = abyTmp[kk] ^ abyLastCipher[kk]; - - memcpy(pbyPayload, abyPlainText, jj); - pbyPayload += jj; - - /* for MIC calculation */ - for (ii = jj; ii < 16; ii++) - abyPlainText[ii] = 0x00; - for (kk = 0; kk < 16; kk++) - abyTmp[kk] = abyMIC[kk] ^ abyPlainText[kk]; - - AESv128(pbyRxKey, abyTmp, abyMIC); - - /* => above is the calculated MIC */ - - wCnt = 0; - abyCTRPLD[14] = (u8) (wCnt >> 8); - abyCTRPLD[15] = (u8) (wCnt & 0xff); - AESv128(pbyRxKey, abyCTRPLD, abyTmp); - - for (kk = 0; kk < 8; kk++) - abyTmp[kk] = abyTmp[kk] ^ pbyPayload[kk]; - - /* => above is the packet dec-MIC */ - - if (!memcmp(abyMIC, abyTmp, 8)) - return true; - else - return false; -} diff --git a/drivers/staging/vt6656/aes_ccmp.h b/drivers/staging/vt6656/aes_ccmp.h deleted file mode 100644 index ed6a9ae315d..00000000000 --- a/drivers/staging/vt6656/aes_ccmp.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: aes_ccmp.h - * - * Purpose: AES_CCMP Decryption - * - * Author: Warren Hsu - * - * Date: Feb 15, 2005 - * - */ - -#ifndef __AES_H__ -#define __AES_H__ - -bool AESbGenCCMP(u8 * pbyRxKey, u8 * pbyFrame, u16 wFrameSize); - -#endif /* __AES_CCMP_H__ */ diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 3d4610e25fc..694e34a5ff9 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -40,13 +40,8 @@ #include "mac.h" #include "baseband.h" #include "rf.h" -#include "srom.h" -#include "control.h" +#include "usbpipe.h" #include "datarate.h" -#include "rndis.h" - -static int msglevel =MSG_LEVEL_INFO; -//static int msglevel =MSG_LEVEL_DEBUG; static u8 abyVT3184_AGC[] = { 0x00, //0 @@ -638,80 +633,59 @@ static const u16 awcFrameTime[MAX_RATE] = {10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216}; /* -static -unsigned long -s_ulGetLowSQ3(PSDevice pDevice); - -static -unsigned long -s_ulGetRatio(PSDevice pDevice); - -static -void -s_vClearSQ3Value(PSDevice pDevice); -*/ - -/* * Description: Calculate data frame transmitting time * * Parameters: * In: - * byPreambleType - Preamble Type - * byPktType - PK_TYPE_11A, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA - * cbFrameLength - Baseband Type - * wRate - Tx Rate + * preamble_type - Preamble Type + * pkt_type - PK_TYPE_11A, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA + * frame_length - Baseband Type + * tx_rate - Tx Rate * Out: * * Return Value: FrameTime * */ -unsigned int -BBuGetFrameTime( - u8 byPreambleType, - u8 byPktType, - unsigned int cbFrameLength, - u16 wRate - ) +unsigned int BBuGetFrameTime(u8 preamble_type, u8 pkt_type, + unsigned int frame_length, u16 tx_rate) { - unsigned int uFrameTime; - unsigned int uPreamble; - unsigned int uTmp; - unsigned int uRateIdx = (unsigned int)wRate; - unsigned int uRate = 0; - - if (uRateIdx > RATE_54M) { - return 0; - } - - uRate = (unsigned int)awcFrameTime[uRateIdx]; - - if (uRateIdx <= 3) { //CCK mode - - if (byPreambleType == 1) {//Short - uPreamble = 96; - } else { - uPreamble = 192; - } - uFrameTime = (cbFrameLength * 80) / uRate; //????? - uTmp = (uFrameTime * uRate) / 80; - if (cbFrameLength != uTmp) { - uFrameTime ++; - } - - return (uPreamble + uFrameTime); - } - else { - uFrameTime = (cbFrameLength * 8 + 22) / uRate; //???????? - uTmp = ((uFrameTime * uRate) - 22) / 8; - if(cbFrameLength != uTmp) { - uFrameTime ++; - } - uFrameTime = uFrameTime * 4; //??????? - if(byPktType != PK_TYPE_11A) { - uFrameTime += 6; - } - return (20 + uFrameTime); //?????? - } + unsigned int frame_time; + unsigned int preamble; + unsigned int tmp; + unsigned int rate = 0; + + if (tx_rate > RATE_54M) + return 0; + + rate = (unsigned int)awcFrameTime[tx_rate]; + + if (tx_rate <= 3) { + if (preamble_type == 1) + preamble = 96; + else + preamble = 192; + + frame_time = (frame_length * 80) / rate; + tmp = (frame_time * rate) / 80; + + if (frame_length != tmp) + frame_time++; + + return preamble + frame_time; + } else { + frame_time = (frame_length * 8 + 22) / rate; + tmp = ((frame_time * rate) - 22) / 8; + + if (frame_length != tmp) + frame_time++; + + frame_time = frame_time * 4; + + if (pkt_type != PK_TYPE_11A) + frame_time += 6; + + return 20 + frame_time; + } } /* @@ -719,9 +693,9 @@ BBuGetFrameTime( * * Parameters: * In: - * pDevice - Device Structure - * cbFrameLength - Tx Frame Length - * wRate - Tx Rate + * priv - Device Structure + * frame_length - Tx Frame Length + * tx_rate - Tx Rate * Out: * struct vnt_phy_field *phy * - pointer to Phy Length field @@ -731,153 +705,135 @@ BBuGetFrameTime( * Return Value: none * */ -void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength, - u16 wRate, u8 byPacketType, struct vnt_phy_field *phy) +void BBvCalculateParameter(struct vnt_private *priv, u32 frame_length, + u16 tx_rate, u8 pkt_type, struct vnt_phy_field *phy) { - u32 cbBitCount; - u32 cbUsCount = 0; - u32 cbTmp; - int bExtBit; - u8 byPreambleType = pDevice->byPreambleType; - int bCCK = pDevice->bCCK; - - cbBitCount = cbFrameLength * 8; - bExtBit = false; - - switch (wRate) { - case RATE_1M : - cbUsCount = cbBitCount; - phy->signal = 0x00; - break; - - case RATE_2M : - cbUsCount = cbBitCount / 2; - if (byPreambleType == 1) - phy->signal = 0x09; - else // long preamble - phy->signal = 0x01; - break; - - case RATE_5M : - if (bCCK == false) - cbBitCount ++; - cbUsCount = (cbBitCount * 10) / 55; - cbTmp = (cbUsCount * 55) / 10; - if (cbTmp != cbBitCount) - cbUsCount ++; - if (byPreambleType == 1) - phy->signal = 0x0a; - else // long preamble - phy->signal = 0x02; - break; - - case RATE_11M : - - if (bCCK == false) - cbBitCount ++; - cbUsCount = cbBitCount / 11; - cbTmp = cbUsCount * 11; - if (cbTmp != cbBitCount) { - cbUsCount ++; - if ((cbBitCount - cbTmp) <= 3) - bExtBit = true; - } - if (byPreambleType == 1) - phy->signal = 0x0b; - else // long preamble - phy->signal = 0x03; - break; - - case RATE_6M : - if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x9b; - } - else {//11g, 2.4GHZ - phy->signal = 0x8b; - } - break; - - case RATE_9M : - if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x9f; - } - else {//11g, 2.4GHZ - phy->signal = 0x8f; - } - break; - - case RATE_12M : - if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x9a; - } - else {//11g, 2.4GHZ - phy->signal = 0x8a; - } - break; - - case RATE_18M : - if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x9e; - } - else {//11g, 2.4GHZ - phy->signal = 0x8e; - } - break; - - case RATE_24M : - if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x99; - } - else {//11g, 2.4GHZ - phy->signal = 0x89; - } - break; - - case RATE_36M : - if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x9d; - } - else {//11g, 2.4GHZ - phy->signal = 0x8d; - } - break; - - case RATE_48M : - if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x98; - } - else {//11g, 2.4GHZ - phy->signal = 0x88; - } - break; - - case RATE_54M : - if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x9c; - } - else {//11g, 2.4GHZ - phy->signal = 0x8c; - } - break; - - default : - if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x9c; - } - else {//11g, 2.4GHZ - phy->signal = 0x8c; - } - break; - } - - if (byPacketType == PK_TYPE_11B) { + u32 bit_count; + u32 count = 0; + u32 tmp; + int ext_bit; + u8 preamble_type = priv->byPreambleType; + + bit_count = frame_length * 8; + ext_bit = false; + + switch (tx_rate) { + case RATE_1M: + count = bit_count; + + phy->signal = 0x00; + + break; + case RATE_2M: + count = bit_count / 2; + + if (preamble_type == 1) + phy->signal = 0x09; + else + phy->signal = 0x01; + + break; + case RATE_5M: + count = (bit_count * 10) / 55; + tmp = (count * 55) / 10; + + if (tmp != bit_count) + count++; + + if (preamble_type == 1) + phy->signal = 0x0a; + else + phy->signal = 0x02; + + break; + case RATE_11M: + count = bit_count / 11; + tmp = count * 11; + + if (tmp != bit_count) { + count++; + + if ((bit_count - tmp) <= 3) + ext_bit = true; + } + + if (preamble_type == 1) + phy->signal = 0x0b; + else + phy->signal = 0x03; + + break; + case RATE_6M: + if (pkt_type == PK_TYPE_11A) + phy->signal = 0x9b; + else + phy->signal = 0x8b; + + break; + case RATE_9M: + if (pkt_type == PK_TYPE_11A) + phy->signal = 0x9f; + else + phy->signal = 0x8f; + + break; + case RATE_12M: + if (pkt_type == PK_TYPE_11A) + phy->signal = 0x9a; + else + phy->signal = 0x8a; + + break; + case RATE_18M: + if (pkt_type == PK_TYPE_11A) + phy->signal = 0x9e; + else + phy->signal = 0x8e; + + break; + case RATE_24M: + if (pkt_type == PK_TYPE_11A) + phy->signal = 0x99; + else + phy->signal = 0x89; + + break; + case RATE_36M: + if (pkt_type == PK_TYPE_11A) + phy->signal = 0x9d; + else + phy->signal = 0x8d; + + break; + case RATE_48M: + if (pkt_type == PK_TYPE_11A) + phy->signal = 0x98; + else + phy->signal = 0x88; + + break; + case RATE_54M: + if (pkt_type == PK_TYPE_11A) + phy->signal = 0x9c; + else + phy->signal = 0x8c; + break; + default: + if (pkt_type == PK_TYPE_11A) + phy->signal = 0x9c; + else + phy->signal = 0x8c; + break; + } + + if (pkt_type == PK_TYPE_11B) { phy->service = 0x00; - if (bExtBit) + if (ext_bit) phy->service |= 0x80; - phy->len = cpu_to_le16((u16)cbUsCount); + phy->len = cpu_to_le16((u16)count); } else { phy->service = 0x00; - phy->len = cpu_to_le16((u16)cbFrameLength); + phy->len = cpu_to_le16((u16)frame_length); } } @@ -886,35 +842,31 @@ void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength, * * Parameters: * In: - * pDevice - Device Structure - * byAntennaMode - Antenna Mode + * priv - Device Structure + * antenna_mode - Antenna Mode * Out: * none * * Return Value: none * */ -void BBvSetAntennaMode(struct vnt_private *pDevice, u8 byAntennaMode) +void BBvSetAntennaMode(struct vnt_private *priv, u8 antenna_mode) { - switch (byAntennaMode) { - case ANT_TXA: - case ANT_TXB: - break; - case ANT_RXA: - pDevice->byBBRxConf &= 0xFC; - break; - case ANT_RXB: - pDevice->byBBRxConf &= 0xFE; - pDevice->byBBRxConf |= 0x02; - break; - } - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_SET_ANTMD, - (u16) byAntennaMode, - 0, - 0, - NULL); + switch (antenna_mode) { + case ANT_TXA: + case ANT_TXB: + break; + case ANT_RXA: + priv->byBBRxConf &= 0xFC; + break; + case ANT_RXB: + priv->byBBRxConf &= 0xFE; + priv->byBBRxConf |= 0x02; + break; + } + + vnt_control_out(priv, MESSAGE_TYPE_SET_ANTMD, + (u16)antenna_mode, 0, 0, NULL); } /* @@ -934,14 +886,14 @@ void BBvSetAntennaMode(struct vnt_private *pDevice, u8 byAntennaMode) int BBbVT3184Init(struct vnt_private *priv) { int status; - u16 lenght; + u16 length; u8 *addr; u8 *agc; - u16 lenght_agc; + u16 length_agc; u8 array[256]; u8 data; - status = CONTROLnsRequestIn(priv, MESSAGE_TYPE_READ, 0, + status = vnt_control_in(priv, MESSAGE_TYPE_READ, 0, MESSAGE_REQUEST_EEPROM, EEP_MAX_CONTEXT_SIZE, priv->abyEEPROM); if (status != STATUS_SUCCESS) @@ -955,20 +907,20 @@ int BBbVT3184Init(struct vnt_private *priv) (priv->abyEEPROM[EEP_OFS_ZONETYPE] != 0x00)) { priv->abyEEPROM[EEP_OFS_ZONETYPE] = 0; priv->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0B; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Init Zone Type :USA\n"); + + dev_dbg(&priv->usb->dev, "Init Zone Type :USA\n"); } else if ((priv->config_file.ZoneType == 1) && (priv->abyEEPROM[EEP_OFS_ZONETYPE] != 0x01)) { priv->abyEEPROM[EEP_OFS_ZONETYPE] = 0x01; priv->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Init Zone Type :Japan\n"); + + dev_dbg(&priv->usb->dev, "Init Zone Type :Japan\n"); } else if ((priv->config_file.ZoneType == 2) && (priv->abyEEPROM[EEP_OFS_ZONETYPE] != 0x02)) { priv->abyEEPROM[EEP_OFS_ZONETYPE] = 0x02; priv->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Init Zone Type :Europe\n"); + + dev_dbg(&priv->usb->dev, "Init Zone Type :Europe\n"); } else { if (priv->config_file.ZoneType != priv->abyEEPROM[EEP_OFS_ZONETYPE]) @@ -988,18 +940,17 @@ int BBbVT3184Init(struct vnt_private *priv) priv->byRFType = priv->abyEEPROM[EEP_OFS_RFTYPE]; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Zone Type %x\n", - priv->byZoneType); + dev_dbg(&priv->usb->dev, "Zone Type %x\n", priv->byZoneType); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RF Type %d\n", priv->byRFType); + dev_dbg(&priv->usb->dev, "RF Type %d\n", priv->byRFType); if ((priv->byRFType == RF_AL2230) || (priv->byRFType == RF_AL2230S)) { priv->byBBRxConf = abyVT3184_AL2230[10]; - lenght = sizeof(abyVT3184_AL2230); + length = sizeof(abyVT3184_AL2230); addr = abyVT3184_AL2230; agc = abyVT3184_AGC; - lenght_agc = sizeof(abyVT3184_AGC); + length_agc = sizeof(abyVT3184_AGC); priv->abyBBVGA[0] = 0x1C; priv->abyBBVGA[1] = 0x10; @@ -1011,10 +962,10 @@ int BBbVT3184Init(struct vnt_private *priv) priv->ldBmThreshold[3] = 0; } else if (priv->byRFType == RF_AIROHA7230) { priv->byBBRxConf = abyVT3184_AL2230[10]; - lenght = sizeof(abyVT3184_AL2230); + length = sizeof(abyVT3184_AL2230); addr = abyVT3184_AL2230; agc = abyVT3184_AGC; - lenght_agc = sizeof(abyVT3184_AGC); + length_agc = sizeof(abyVT3184_AGC); addr[0xd7] = 0x06; @@ -1029,10 +980,10 @@ int BBbVT3184Init(struct vnt_private *priv) } else if ((priv->byRFType == RF_VT3226) || (priv->byRFType == RF_VT3226D0)) { priv->byBBRxConf = abyVT3184_VT3226D0[10]; - lenght = sizeof(abyVT3184_VT3226D0); + length = sizeof(abyVT3184_VT3226D0); addr = abyVT3184_VT3226D0; agc = abyVT3184_AGC; - lenght_agc = sizeof(abyVT3184_AGC); + length_agc = sizeof(abyVT3184_AGC); priv->abyBBVGA[0] = 0x20; priv->abyBBVGA[1] = 0x10; @@ -1046,10 +997,10 @@ int BBbVT3184Init(struct vnt_private *priv) MACvRegBitsOn(priv, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT); } else if ((priv->byRFType == RF_VT3342A0)) { priv->byBBRxConf = abyVT3184_VT3226D0[10]; - lenght = sizeof(abyVT3184_VT3226D0); + length = sizeof(abyVT3184_VT3226D0); addr = abyVT3184_VT3226D0; agc = abyVT3184_AGC; - lenght_agc = sizeof(abyVT3184_AGC); + length_agc = sizeof(abyVT3184_AGC); priv->abyBBVGA[0] = 0x20; priv->abyBBVGA[1] = 0x10; @@ -1065,40 +1016,39 @@ int BBbVT3184Init(struct vnt_private *priv) return true; } - memcpy(array, addr, lenght); + memcpy(array, addr, length); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, 0, - MESSAGE_REQUEST_BBREG, lenght, array); + vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, + MESSAGE_REQUEST_BBREG, length, array); - memcpy(array, agc, lenght_agc); + memcpy(array, agc, length_agc); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, 0, - MESSAGE_REQUEST_BBAGC, lenght_agc, array); + vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, + MESSAGE_REQUEST_BBAGC, length_agc, array); if ((priv->byRFType == RF_VT3226) || (priv->byRFType == RF_VT3342A0)) { - ControlvWriteByte(priv, MESSAGE_REQUEST_MACREG, + vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, MAC_REG_ITRTMSET, 0x23); MACvRegBitsOn(priv, MAC_REG_PAPEDELAY, 0x01); } else if (priv->byRFType == RF_VT3226D0) { - ControlvWriteByte(priv, MESSAGE_REQUEST_MACREG, + vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, MAC_REG_ITRTMSET, 0x11); MACvRegBitsOn(priv, MAC_REG_PAPEDELAY, 0x01); } - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x04, 0x7f); - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01); - - RFbRFTableDownload(priv); + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x04, 0x7f); + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01); + vnt_rf_table_download(priv); /* Fix for TX USB resets from vendors driver */ - CONTROLnsRequestIn(priv, MESSAGE_TYPE_READ, USB_REG4, + vnt_control_in(priv, MESSAGE_TYPE_READ, USB_REG4, MESSAGE_REQUEST_MEM, sizeof(data), &data); data |= 0x2; - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, USB_REG4, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, USB_REG4, MESSAGE_REQUEST_MEM, sizeof(data), &data); return true; @@ -1109,41 +1059,42 @@ int BBbVT3184Init(struct vnt_private *priv) * * Parameters: * In: - * pDevice - Device Structure + * priv - Device Structure * Out: * none * * Return Value: none * */ -void BBvSetShortSlotTime(struct vnt_private *pDevice) +void BBvSetShortSlotTime(struct vnt_private *priv) { - u8 byBBVGA=0; + u8 bb_vga = 0; - if (pDevice->bShortSlotTime) - pDevice->byBBRxConf &= 0xDF;//1101 1111 + if (priv->bShortSlotTime) + priv->byBBRxConf &= 0xdf; else - pDevice->byBBRxConf |= 0x20;//0010 0000 + priv->byBBRxConf |= 0x20; + + vnt_control_in_u8(priv, MESSAGE_REQUEST_BBREG, 0xe7, &bb_vga); - ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0xE7, &byBBVGA); - if (byBBVGA == pDevice->abyBBVGA[0]) - pDevice->byBBRxConf |= 0x20;//0010 0000 + if (bb_vga == priv->abyBBVGA[0]) + priv->byBBRxConf |= 0x20; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf); + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->byBBRxConf); } -void BBvSetVGAGainOffset(struct vnt_private *pDevice, u8 byData) +void BBvSetVGAGainOffset(struct vnt_private *priv, u8 data) { - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, byData); + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xE7, data); - // patch for 3253B0 Baseband with Cardbus module - if (pDevice->bShortSlotTime) - pDevice->byBBRxConf &= 0xDF; /* 1101 1111 */ + /* patch for 3253B0 Baseband with Cardbus module */ + if (priv->bShortSlotTime) + priv->byBBRxConf &= 0xdf; /* 1101 1111 */ else - pDevice->byBBRxConf |= 0x20; /* 0010 0000 */ + priv->byBBRxConf |= 0x20; /* 0010 0000 */ - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf);//CR10 + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->byBBRxConf); } /* @@ -1151,735 +1102,288 @@ void BBvSetVGAGainOffset(struct vnt_private *pDevice, u8 byData) * * Parameters: * In: - * pDevice - Device Structure + * priv - Device Structure * Out: * none * * Return Value: none * */ -void BBvSetDeepSleep(struct vnt_private *pDevice) -{ - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);//CR12 - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0xB9);//CR13 -} - -void BBvExitDeepSleep(struct vnt_private *pDevice) +void BBvSetDeepSleep(struct vnt_private *priv) { - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0C, 0x00);//CR12 - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0x01);//CR13 + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);/* CR12 */ + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0xB9);/* CR13 */ } -static unsigned long s_ulGetLowSQ3(struct vnt_private *pDevice) +void BBvExitDeepSleep(struct vnt_private *priv) { - int ii; - unsigned long ulSQ3 = 0; - unsigned long ulMaxPacket; - - ulMaxPacket = pDevice->aulPktNum[RATE_54M]; - if (pDevice->aulPktNum[RATE_54M] != 0) - ulSQ3 = pDevice->aulSQ3Val[RATE_54M] / pDevice->aulPktNum[RATE_54M]; - - for (ii = RATE_48M; ii >= RATE_6M; ii--) - if (pDevice->aulPktNum[ii] > ulMaxPacket) { - ulMaxPacket = pDevice->aulPktNum[ii]; - ulSQ3 = pDevice->aulSQ3Val[ii] / pDevice->aulPktNum[ii]; - } - - return ulSQ3; + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x00);/* CR12 */ + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);/* CR13 */ } -static unsigned long s_ulGetRatio(struct vnt_private *pDevice) +void BBvUpdatePreEDThreshold(struct vnt_private *priv, int scanning) { - int ii, jj; - unsigned long ulRatio = 0; - unsigned long ulMaxPacket; - unsigned long ulPacketNum; - - //This is a thousand-ratio - ulMaxPacket = pDevice->aulPktNum[RATE_54M]; - if ( pDevice->aulPktNum[RATE_54M] != 0 ) { - ulPacketNum = pDevice->aulPktNum[RATE_54M]; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - ulRatio += TOP_RATE_54M; - } - for (ii = RATE_48M; ii >= RATE_1M; ii--) - if ( pDevice->aulPktNum[ii] > ulMaxPacket ) { - ulPacketNum = 0; - for ( jj=RATE_54M;jj>=ii;jj--) - ulPacketNum += pDevice->aulPktNum[jj]; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - ulRatio += TOP_RATE_48M; - ulMaxPacket = pDevice->aulPktNum[ii]; - } - - return ulRatio; -} - -static void s_vClearSQ3Value(struct vnt_private *pDevice) -{ - int ii; - pDevice->uDiversityCnt = 0; - - for ( ii=RATE_1M;ii<MAX_RATE;ii++) { - pDevice->aulPktNum[ii] = 0; - pDevice->aulSQ3Val[ii] = 0; - } -} - -/* - * Description: Antenna Diversity - * - * Parameters: - * In: - * pDevice - Device Structure - * byRSR - RSR from received packet - * bySQ3 - SQ3 value from received packet - * Out: - * none - * - * Return Value: none - * - */ - -void BBvAntennaDiversity(struct vnt_private *pDevice, - u8 byRxRate, u8 bySQ3) -{ - - pDevice->uDiversityCnt++; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pDevice->uDiversityCnt = %d\n", (int)pDevice->uDiversityCnt); - - if (byRxRate == 2) { - pDevice->aulPktNum[RATE_1M]++; - } - else if (byRxRate==4) { - pDevice->aulPktNum[RATE_2M]++; - } - else if (byRxRate==11) { - pDevice->aulPktNum[RATE_5M]++; - } - else if (byRxRate==22) { - pDevice->aulPktNum[RATE_11M]++; - } - else if(byRxRate==12){ - pDevice->aulPktNum[RATE_6M]++; - pDevice->aulSQ3Val[RATE_6M] += bySQ3; - } - else if(byRxRate==18){ - pDevice->aulPktNum[RATE_9M]++; - pDevice->aulSQ3Val[RATE_9M] += bySQ3; - } - else if(byRxRate==24){ - pDevice->aulPktNum[RATE_12M]++; - pDevice->aulSQ3Val[RATE_12M] += bySQ3; - } - else if(byRxRate==36){ - pDevice->aulPktNum[RATE_18M]++; - pDevice->aulSQ3Val[RATE_18M] += bySQ3; - } - else if(byRxRate==48){ - pDevice->aulPktNum[RATE_24M]++; - pDevice->aulSQ3Val[RATE_24M] += bySQ3; - } - else if(byRxRate==72){ - pDevice->aulPktNum[RATE_36M]++; - pDevice->aulSQ3Val[RATE_36M] += bySQ3; - } - else if(byRxRate==96){ - pDevice->aulPktNum[RATE_48M]++; - pDevice->aulSQ3Val[RATE_48M] += bySQ3; - } - else if(byRxRate==108){ - pDevice->aulPktNum[RATE_54M]++; - pDevice->aulSQ3Val[RATE_54M] += bySQ3; - } - - if (pDevice->byAntennaState == 0) { - - if (pDevice->uDiversityCnt > pDevice->ulDiversityNValue) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ulDiversityNValue=[%d],54M-[%d]\n",(int)pDevice->ulDiversityNValue, (int)pDevice->aulPktNum[RATE_54M]); - - pDevice->ulSQ3_State0 = s_ulGetLowSQ3(pDevice); - pDevice->ulRatio_State0 = s_ulGetRatio(pDevice); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0, SQ3= [%08x] rate = [%08x]\n",(int)pDevice->ulSQ3_State0,(int)pDevice->ulRatio_State0); - - if ( ((pDevice->aulPktNum[RATE_54M] < pDevice->ulDiversityNValue/2) && - (pDevice->ulSQ3_State0 > pDevice->ulSQ3TH) ) || - (pDevice->ulSQ3_State0 == 0 ) ) { - - if ( pDevice->byTMax == 0 ) - return; - - bScheduleCommand((void *) pDevice, - WLAN_CMD_CHANGE_ANTENNA, - NULL); - - pDevice->byAntennaState = 1; - - del_timer(&pDevice->TimerSQ3Tmax3); - del_timer(&pDevice->TimerSQ3Tmax2); - pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ); - add_timer(&pDevice->TimerSQ3Tmax1); - - } else { - pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ); - add_timer(&pDevice->TimerSQ3Tmax3); - } - s_vClearSQ3Value(pDevice); - - } - } else { //byAntennaState == 1 - - if (pDevice->uDiversityCnt > pDevice->ulDiversityMValue) { - - del_timer(&pDevice->TimerSQ3Tmax1); - pDevice->ulSQ3_State1 = s_ulGetLowSQ3(pDevice); - pDevice->ulRatio_State1 = s_ulGetRatio(pDevice); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State1, rate0 = %08x,rate1 = %08x\n",(int)pDevice->ulRatio_State0,(int)pDevice->ulRatio_State1); - - if ( ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 != 0)) || - ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 == 0) && (pDevice->ulRatio_State1 < pDevice->ulRatio_State0)) || - ((pDevice->ulSQ3_State1 != 0) && (pDevice->ulSQ3_State0 != 0) && (pDevice->ulSQ3_State0 < pDevice->ulSQ3_State1)) - ) { - - bScheduleCommand((void *) pDevice, - WLAN_CMD_CHANGE_ANTENNA, - NULL); - - pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ); - pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ); - add_timer(&pDevice->TimerSQ3Tmax3); - add_timer(&pDevice->TimerSQ3Tmax2); - - } - pDevice->byAntennaState = 0; - s_vClearSQ3Value(pDevice); - } - } //byAntennaState -} - -/*+ - * - * Description: - * Timer for SQ3 antenna diversity - * - * Parameters: - * In: - * pvSysSpec1 - * hDeviceContext - Pointer to the adapter - * pvSysSpec2 - * pvSysSpec3 - * Out: - * none - * - * Return Value: none - * --*/ - -void TimerSQ3CallBack(struct vnt_private *pDevice) -{ - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3CallBack..."); - spin_lock_irq(&pDevice->lock); - - bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL); - pDevice->byAntennaState = 0; - s_vClearSQ3Value(pDevice); - pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ); - pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ); - add_timer(&pDevice->TimerSQ3Tmax3); - add_timer(&pDevice->TimerSQ3Tmax2); - - spin_unlock_irq(&pDevice->lock); -} + u8 cr_201 = 0x0, cr_206 = 0x0; + u8 ed_inx = priv->byBBPreEDIndex; + + switch (priv->byRFType) { + case RF_AL2230: + case RF_AL2230S: + case RF_AIROHA7230: + if (scanning) { /* Max sensitivity */ + ed_inx = 0; + cr_206 = 0x30; + break; + } -/*+ - * - * Description: - * Timer for SQ3 antenna diversity - * - * Parameters: - * In: - * pvSysSpec1 - * hDeviceContext - Pointer to the adapter - * pvSysSpec2 - * pvSysSpec3 - * Out: - * none - * - * Return Value: none - * --*/ + if (priv->byBBPreEDRSSI <= 45) { + ed_inx = 20; + cr_201 = 0xff; + } else if (priv->byBBPreEDRSSI <= 46) { + ed_inx = 19; + cr_201 = 0x1a; + } else if (priv->byBBPreEDRSSI <= 47) { + ed_inx = 18; + cr_201 = 0x15; + } else if (priv->byBBPreEDRSSI <= 49) { + ed_inx = 17; + cr_201 = 0xe; + } else if (priv->byBBPreEDRSSI <= 51) { + ed_inx = 16; + cr_201 = 0x9; + } else if (priv->byBBPreEDRSSI <= 53) { + ed_inx = 15; + cr_201 = 0x6; + } else if (priv->byBBPreEDRSSI <= 55) { + ed_inx = 14; + cr_201 = 0x3; + } else if (priv->byBBPreEDRSSI <= 56) { + ed_inx = 13; + cr_201 = 0x2; + cr_206 = 0xa0; + } else if (priv->byBBPreEDRSSI <= 57) { + ed_inx = 12; + cr_201 = 0x2; + cr_206 = 0x20; + } else if (priv->byBBPreEDRSSI <= 58) { + ed_inx = 11; + cr_201 = 0x1; + cr_206 = 0xa0; + } else if (priv->byBBPreEDRSSI <= 59) { + ed_inx = 10; + cr_201 = 0x1; + cr_206 = 0x54; + } else if (priv->byBBPreEDRSSI <= 60) { + ed_inx = 9; + cr_201 = 0x1; + cr_206 = 0x18; + } else if (priv->byBBPreEDRSSI <= 61) { + ed_inx = 8; + cr_206 = 0xe3; + } else if (priv->byBBPreEDRSSI <= 62) { + ed_inx = 7; + cr_206 = 0xb9; + } else if (priv->byBBPreEDRSSI <= 63) { + ed_inx = 6; + cr_206 = 0x93; + } else if (priv->byBBPreEDRSSI <= 64) { + ed_inx = 5; + cr_206 = 0x79; + } else if (priv->byBBPreEDRSSI <= 65) { + ed_inx = 4; + cr_206 = 0x62; + } else if (priv->byBBPreEDRSSI <= 66) { + ed_inx = 3; + cr_206 = 0x51; + } else if (priv->byBBPreEDRSSI <= 67) { + ed_inx = 2; + cr_206 = 0x43; + } else if (priv->byBBPreEDRSSI <= 68) { + ed_inx = 1; + cr_206 = 0x36; + } else { + ed_inx = 0; + cr_206 = 0x30; + } + break; + + case RF_VT3226: + case RF_VT3226D0: + if (scanning) { /* Max sensitivity */ + ed_inx = 0; + cr_206 = 0x24; + break; + } -void TimerSQ3Tmax3CallBack(struct vnt_private *pDevice) -{ + if (priv->byBBPreEDRSSI <= 41) { + ed_inx = 22; + cr_201 = 0xff; + } else if (priv->byBBPreEDRSSI <= 42) { + ed_inx = 21; + cr_201 = 0x36; + } else if (priv->byBBPreEDRSSI <= 43) { + ed_inx = 20; + cr_201 = 0x26; + } else if (priv->byBBPreEDRSSI <= 45) { + ed_inx = 19; + cr_201 = 0x18; + } else if (priv->byBBPreEDRSSI <= 47) { + ed_inx = 18; + cr_201 = 0x11; + } else if (priv->byBBPreEDRSSI <= 49) { + ed_inx = 17; + cr_201 = 0xa; + } else if (priv->byBBPreEDRSSI <= 51) { + ed_inx = 16; + cr_201 = 0x7; + } else if (priv->byBBPreEDRSSI <= 53) { + ed_inx = 15; + cr_201 = 0x4; + } else if (priv->byBBPreEDRSSI <= 55) { + ed_inx = 14; + cr_201 = 0x2; + cr_206 = 0xc0; + } else if (priv->byBBPreEDRSSI <= 56) { + ed_inx = 13; + cr_201 = 0x2; + cr_206 = 0x30; + } else if (priv->byBBPreEDRSSI <= 57) { + ed_inx = 12; + cr_201 = 0x1; + cr_206 = 0xb0; + } else if (priv->byBBPreEDRSSI <= 58) { + ed_inx = 11; + cr_201 = 0x1; + cr_206 = 0x70; + } else if (priv->byBBPreEDRSSI <= 59) { + ed_inx = 10; + cr_201 = 0x1; + cr_206 = 0x30; + } else if (priv->byBBPreEDRSSI <= 60) { + ed_inx = 9; + cr_206 = 0xea; + } else if (priv->byBBPreEDRSSI <= 61) { + ed_inx = 8; + cr_206 = 0xc0; + } else if (priv->byBBPreEDRSSI <= 62) { + ed_inx = 7; + cr_206 = 0x9c; + } else if (priv->byBBPreEDRSSI <= 63) { + ed_inx = 6; + cr_206 = 0x80; + } else if (priv->byBBPreEDRSSI <= 64) { + ed_inx = 5; + cr_206 = 0x68; + } else if (priv->byBBPreEDRSSI <= 65) { + ed_inx = 4; + cr_206 = 0x52; + } else if (priv->byBBPreEDRSSI <= 66) { + ed_inx = 3; + cr_206 = 0x43; + } else if (priv->byBBPreEDRSSI <= 67) { + ed_inx = 2; + cr_206 = 0x36; + } else if (priv->byBBPreEDRSSI <= 68) { + ed_inx = 1; + cr_206 = 0x2d; + } else { + ed_inx = 0; + cr_206 = 0x24; + } + break; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3Tmax3CallBack..."); - spin_lock_irq(&pDevice->lock); + case RF_VT3342A0: + if (scanning) { /* need Max sensitivity */ + ed_inx = 0; + cr_206 = 0x38; + break; + } - pDevice->ulRatio_State0 = s_ulGetRatio(pDevice); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0 = [%08x]\n",(int)pDevice->ulRatio_State0); + if (priv->byBBPreEDRSSI <= 41) { + ed_inx = 20; + cr_201 = 0xff; + } else if (priv->byBBPreEDRSSI <= 42) { + ed_inx = 19; + cr_201 = 0x36; + } else if (priv->byBBPreEDRSSI <= 43) { + ed_inx = 18; + cr_201 = 0x26; + } else if (priv->byBBPreEDRSSI <= 45) { + ed_inx = 17; + cr_201 = 0x18; + } else if (priv->byBBPreEDRSSI <= 47) { + ed_inx = 16; + cr_201 = 0x11; + } else if (priv->byBBPreEDRSSI <= 49) { + ed_inx = 15; + cr_201 = 0xa; + } else if (priv->byBBPreEDRSSI <= 51) { + ed_inx = 14; + cr_201 = 0x7; + } else if (priv->byBBPreEDRSSI <= 53) { + ed_inx = 13; + cr_201 = 0x4; + } else if (priv->byBBPreEDRSSI <= 55) { + ed_inx = 12; + cr_201 = 0x2; + cr_206 = 0xc0; + } else if (priv->byBBPreEDRSSI <= 56) { + ed_inx = 11; + cr_201 = 0x2; + cr_206 = 0x30; + } else if (priv->byBBPreEDRSSI <= 57) { + ed_inx = 10; + cr_201 = 0x1; + cr_206 = 0xb0; + } else if (priv->byBBPreEDRSSI <= 58) { + ed_inx = 9; + cr_201 = 0x1; + cr_206 = 0x70; + } else if (priv->byBBPreEDRSSI <= 59) { + ed_inx = 8; + cr_201 = 0x1; + cr_206 = 0x30; + } else if (priv->byBBPreEDRSSI <= 60) { + ed_inx = 7; + cr_206 = 0xea; + } else if (priv->byBBPreEDRSSI <= 61) { + ed_inx = 6; + cr_206 = 0xc0; + } else if (priv->byBBPreEDRSSI <= 62) { + ed_inx = 5; + cr_206 = 0x9c; + } else if (priv->byBBPreEDRSSI <= 63) { + ed_inx = 4; + cr_206 = 0x80; + } else if (priv->byBBPreEDRSSI <= 64) { + ed_inx = 3; + cr_206 = 0x68; + } else if (priv->byBBPreEDRSSI <= 65) { + ed_inx = 2; + cr_206 = 0x52; + } else if (priv->byBBPreEDRSSI <= 66) { + ed_inx = 1; + cr_206 = 0x43; + } else { + ed_inx = 0; + cr_206 = 0x38; + } + break; - s_vClearSQ3Value(pDevice); - if ( pDevice->byTMax == 0 ) { - pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ); - add_timer(&pDevice->TimerSQ3Tmax3); - spin_unlock_irq(&pDevice->lock); - return; - } + } - bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL); - pDevice->byAntennaState = 1; - del_timer(&pDevice->TimerSQ3Tmax3); - del_timer(&pDevice->TimerSQ3Tmax2); - pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ); - add_timer(&pDevice->TimerSQ3Tmax1); + if (ed_inx == priv->byBBPreEDIndex && !scanning) + return; - spin_unlock_irq(&pDevice->lock); -} + priv->byBBPreEDIndex = ed_inx; -void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) -{ + dev_dbg(&priv->usb->dev, "%s byBBPreEDRSSI %d\n", + __func__, priv->byBBPreEDRSSI); - switch(pDevice->byRFType) - { - case RF_AL2230: - case RF_AL2230S: - case RF_AIROHA7230: - //RobertYu:20060627, update new table - - if( bScanning ) - { // need Max sensitivity //RSSI -69, -70,.... - pDevice->byBBPreEDIndex = 0; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70, -71,...\n"); - break; - } - - if(pDevice->byBBPreEDRSSI <= 45) { // RSSI 0, -1,-2,....-45 - if(pDevice->byBBPreEDIndex == 20) break; - pDevice->byBBPreEDIndex = 20; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-45\n"); - } else if(pDevice->byBBPreEDRSSI <= 46) { //RSSI -46 - if(pDevice->byBBPreEDIndex == 19) break; - pDevice->byBBPreEDIndex = 19; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x1A); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46\n"); - } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -47 - if(pDevice->byBBPreEDIndex == 18) break; - pDevice->byBBPreEDIndex = 18; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x15); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -47\n"); - } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49 - if(pDevice->byBBPreEDIndex == 17) break; - pDevice->byBBPreEDIndex = 17; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0E); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n"); - } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51 - if(pDevice->byBBPreEDIndex == 16) break; - pDevice->byBBPreEDIndex = 16; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x09); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n"); - } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53 - if(pDevice->byBBPreEDIndex == 15) break; - pDevice->byBBPreEDIndex = 15; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x06); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n"); - } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55 - if(pDevice->byBBPreEDIndex == 14) break; - pDevice->byBBPreEDIndex = 14; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x03); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n"); - } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56 - if(pDevice->byBBPreEDIndex == 13) break; - pDevice->byBBPreEDIndex = 13; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n"); - } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57 - if(pDevice->byBBPreEDIndex == 12) break; - pDevice->byBBPreEDIndex = 12; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x20); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n"); - } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58 - if(pDevice->byBBPreEDIndex == 11) break; - pDevice->byBBPreEDIndex = 11; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n"); - } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59 - if(pDevice->byBBPreEDIndex == 10) break; - pDevice->byBBPreEDIndex = 10; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x54); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n"); - } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60 - if(pDevice->byBBPreEDIndex == 9) break; - pDevice->byBBPreEDIndex = 9; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x18); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n"); - } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61 - if(pDevice->byBBPreEDIndex == 8) break; - pDevice->byBBPreEDIndex = 8; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xE3); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n"); - } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62 - if(pDevice->byBBPreEDIndex == 7) break; - pDevice->byBBPreEDIndex = 7; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB9); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n"); - } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63 - if(pDevice->byBBPreEDIndex == 6) break; - pDevice->byBBPreEDIndex = 6; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x93); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n"); - } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64 - if(pDevice->byBBPreEDIndex == 5) break; - pDevice->byBBPreEDIndex = 5; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x79); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n"); - } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65 - if(pDevice->byBBPreEDIndex == 4) break; - pDevice->byBBPreEDIndex = 4; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x62); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n"); - } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66 - if(pDevice->byBBPreEDIndex == 3) break; - pDevice->byBBPreEDIndex = 3; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x51); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n"); - } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67 - if(pDevice->byBBPreEDIndex == 2) break; - pDevice->byBBPreEDIndex = 2; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n"); - } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68 - if(pDevice->byBBPreEDIndex == 1) break; - pDevice->byBBPreEDIndex = 1; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n"); - } else { //RSSI -69, -70,.... - if(pDevice->byBBPreEDIndex == 0) break; - pDevice->byBBPreEDIndex = 0; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,...\n"); - } - break; - - case RF_VT3226: - case RF_VT3226D0: - //RobertYu:20060627, update new table - - if( bScanning ) - { // need Max sensitivity //RSSI -69, -70, ... - pDevice->byBBPreEDIndex = 0; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n"); - break; - } - - if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41 - if(pDevice->byBBPreEDIndex == 22) break; - pDevice->byBBPreEDIndex = 22; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n"); - } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42 - if(pDevice->byBBPreEDIndex == 21) break; - pDevice->byBBPreEDIndex = 21; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n"); - } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43 - if(pDevice->byBBPreEDIndex == 20) break; - pDevice->byBBPreEDIndex = 20; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n"); - } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45 - if(pDevice->byBBPreEDIndex == 19) break; - pDevice->byBBPreEDIndex = 19; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n"); - } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47 - if(pDevice->byBBPreEDIndex == 18) break; - pDevice->byBBPreEDIndex = 18; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n"); - } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49 - if(pDevice->byBBPreEDIndex == 17) break; - pDevice->byBBPreEDIndex = 17; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n"); - } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51 - if(pDevice->byBBPreEDIndex == 16) break; - pDevice->byBBPreEDIndex = 16; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n"); - } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53 - if(pDevice->byBBPreEDIndex == 15) break; - pDevice->byBBPreEDIndex = 15; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n"); - } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55 - if(pDevice->byBBPreEDIndex == 14) break; - pDevice->byBBPreEDIndex = 14; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n"); - } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56 - if(pDevice->byBBPreEDIndex == 13) break; - pDevice->byBBPreEDIndex = 13; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n"); - } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57 - if(pDevice->byBBPreEDIndex == 12) break; - pDevice->byBBPreEDIndex = 12; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n"); - } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58 - if(pDevice->byBBPreEDIndex == 11) break; - pDevice->byBBPreEDIndex = 11; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n"); - } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59 - if(pDevice->byBBPreEDIndex == 10) break; - pDevice->byBBPreEDIndex = 10; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n"); - } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60 - if(pDevice->byBBPreEDIndex == 9) break; - pDevice->byBBPreEDIndex = 9; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n"); - } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61 - if(pDevice->byBBPreEDIndex == 8) break; - pDevice->byBBPreEDIndex = 8; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n"); - } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62 - if(pDevice->byBBPreEDIndex == 7) break; - pDevice->byBBPreEDIndex = 7; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n"); - } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63 - if(pDevice->byBBPreEDIndex == 6) break; - pDevice->byBBPreEDIndex = 6; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n"); - } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64 - if(pDevice->byBBPreEDIndex == 5) break; - pDevice->byBBPreEDIndex = 5; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n"); - } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65 - if(pDevice->byBBPreEDIndex == 4) break; - pDevice->byBBPreEDIndex = 4; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n"); - } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66 - if(pDevice->byBBPreEDIndex == 3) break; - pDevice->byBBPreEDIndex = 3; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n"); - } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67 - if(pDevice->byBBPreEDIndex == 2) break; - pDevice->byBBPreEDIndex = 2; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n"); - } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68 - if(pDevice->byBBPreEDIndex == 1) break; - pDevice->byBBPreEDIndex = 1; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x2D); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n"); - } else { //RSSI -69, -70, ... - if(pDevice->byBBPreEDIndex == 0) break; - pDevice->byBBPreEDIndex = 0; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n"); - } - break; - - case RF_VT3342A0: //RobertYu:20060627, testing table - if( bScanning ) - { // need Max sensitivity //RSSI -67, -68, ... - pDevice->byBBPreEDIndex = 0; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n"); - break; - } - - if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41 - if(pDevice->byBBPreEDIndex == 20) break; - pDevice->byBBPreEDIndex = 20; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n"); - } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42 - if(pDevice->byBBPreEDIndex == 19) break; - pDevice->byBBPreEDIndex = 19; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n"); - } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43 - if(pDevice->byBBPreEDIndex == 18) break; - pDevice->byBBPreEDIndex = 18; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n"); - } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45 - if(pDevice->byBBPreEDIndex == 17) break; - pDevice->byBBPreEDIndex = 17; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n"); - } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47 - if(pDevice->byBBPreEDIndex == 16) break; - pDevice->byBBPreEDIndex = 16; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n"); - } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49 - if(pDevice->byBBPreEDIndex == 15) break; - pDevice->byBBPreEDIndex = 15; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n"); - } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51 - if(pDevice->byBBPreEDIndex == 14) break; - pDevice->byBBPreEDIndex = 14; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n"); - } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53 - if(pDevice->byBBPreEDIndex == 13) break; - pDevice->byBBPreEDIndex = 13; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n"); - } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55 - if(pDevice->byBBPreEDIndex == 12) break; - pDevice->byBBPreEDIndex = 12; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n"); - } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56 - if(pDevice->byBBPreEDIndex == 11) break; - pDevice->byBBPreEDIndex = 11; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n"); - } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57 - if(pDevice->byBBPreEDIndex == 10) break; - pDevice->byBBPreEDIndex = 10; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n"); - } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58 - if(pDevice->byBBPreEDIndex == 9) break; - pDevice->byBBPreEDIndex = 9; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n"); - } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59 - if(pDevice->byBBPreEDIndex == 8) break; - pDevice->byBBPreEDIndex = 8; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n"); - } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60 - if(pDevice->byBBPreEDIndex == 7) break; - pDevice->byBBPreEDIndex = 7; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n"); - } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61 - if(pDevice->byBBPreEDIndex == 6) break; - pDevice->byBBPreEDIndex = 6; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n"); - } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62 - if(pDevice->byBBPreEDIndex == 5) break; - pDevice->byBBPreEDIndex = 5; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n"); - } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63 - if(pDevice->byBBPreEDIndex == 4) break; - pDevice->byBBPreEDIndex = 4; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n"); - } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64 - if(pDevice->byBBPreEDIndex == 3) break; - pDevice->byBBPreEDIndex = 3; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n"); - } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65 - if(pDevice->byBBPreEDIndex == 2) break; - pDevice->byBBPreEDIndex = 2; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n"); - } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66 - if(pDevice->byBBPreEDIndex == 1) break; - pDevice->byBBPreEDIndex = 1; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n"); - } else { //RSSI -67, -68, ... - if(pDevice->byBBPreEDIndex == 0) break; - pDevice->byBBPreEDIndex = 0; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n"); - } - break; - - } + if (!cr_201 && !cr_206) + return; + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xc9, cr_201); + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xce, cr_206); } diff --git a/drivers/staging/vt6656/baseband.h b/drivers/staging/vt6656/baseband.h index 79faedf4a5e..3044d6c4205 100644 --- a/drivers/staging/vt6656/baseband.h +++ b/drivers/staging/vt6656/baseband.h @@ -88,23 +88,11 @@ struct vnt_phy_field { __le16 len; } __packed; -unsigned int -BBuGetFrameTime( - u8 byPreambleType, - u8 byFreqType, - unsigned int cbFrameLength, - u16 wRate - ); +unsigned int BBuGetFrameTime(u8 preamble_type, u8 pkt_type, + unsigned int frame_length, u16 tx_rate); -void BBvCalculateParameter(struct vnt_private *, u32 cbFrameLength, - u16 wRate, u8 byPacketType, struct vnt_phy_field *); - -/* timer for antenna diversity */ - -void TimerSQ3CallBack(struct vnt_private *); -void TimerSQ3Tmax3CallBack(struct vnt_private *); - -void BBvAntennaDiversity(struct vnt_private *, u8 byRxRate, u8 bySQ3); +void BBvCalculateParameter(struct vnt_private *, u32 frame_length, + u16 tx_rate, u8 pkt_type, struct vnt_phy_field *); void BBvSetShortSlotTime(struct vnt_private *); void BBvSetVGAGainOffset(struct vnt_private *, u8 byData); @@ -112,6 +100,6 @@ void BBvSetAntennaMode(struct vnt_private *, u8 byAntennaMode); int BBbVT3184Init(struct vnt_private *); void BBvSetDeepSleep(struct vnt_private *); void BBvExitDeepSleep(struct vnt_private *); -void BBvUpdatePreEDThreshold(struct vnt_private *, int bScanning); +void BBvUpdatePreEDThreshold(struct vnt_private *, int scanning); #endif /* __BASEBAND_H__ */ diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c index 9c78dab95d3..8e9ce96442a 100644 --- a/drivers/staging/vt6656/bssdb.c +++ b/drivers/staging/vt6656/bssdb.c @@ -53,8 +53,7 @@ #include "card.h" #include "mac.h" #include "wpa2.h" -#include "control.h" -#include "rndis.h" +#include "usbpipe.h" #include "iowpa.h" #include "power.h" @@ -456,16 +455,15 @@ int BSSbInsertToBSSList(struct vnt_private *pDevice, } } - if (pDevice->bUpdateBBVGA) { - /* Monitor if RSSI is too strong. */ - pBSSList->byRSSIStatCnt = 0; - RFvRSSITodBm(pDevice, (u8) (pRxPacket->uRSSI), - &pBSSList->ldBmMAX); - pBSSList->ldBmAverage[0] = pBSSList->ldBmMAX; - pBSSList->ldBmAverRange = pBSSList->ldBmMAX; - for (ii = 1; ii < RSSI_STAT_COUNT; ii++) - pBSSList->ldBmAverage[ii] = 0; - } + /* Monitor if RSSI is too strong. */ + pBSSList->byRSSIStatCnt = 0; + + vnt_rf_rssi_to_dbm(pDevice, (u8)pRxPacket->uRSSI, &pBSSList->ldBmMAX); + + pBSSList->ldBmAverage[0] = pBSSList->ldBmMAX; + pBSSList->ldBmAverRange = pBSSList->ldBmMAX; + for (ii = 1; ii < RSSI_STAT_COUNT; ii++) + pBSSList->ldBmAverage[ii] = 0; pBSSList->uIELength = uIELength; if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN) @@ -581,7 +579,7 @@ int BSSbUpdateToBSSList(struct vnt_private *pDevice, } if (pRxPacket->uRSSI != 0) { - RFvRSSITodBm(pDevice, (u8) (pRxPacket->uRSSI), &ldBm); + vnt_rf_rssi_to_dbm(pDevice, (u8)pRxPacket->uRSSI, &ldBm); /* Monitor if RSSI is too strong. */ pBSSList->byRSSIStatCnt++; pBSSList->byRSSIStatCnt %= RSSI_STAT_COUNT; @@ -774,8 +772,8 @@ void BSSvAddMulticastNode(struct vnt_private *pDevice) { struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - if (!pDevice->bEnableHostWEP) - memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB)); + memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB)); + memset(pMgmt->sNodeDBTable[0].abyMACAddr, 0xff, WLAN_ADDR_LEN); pMgmt->sNodeDBTable[0].bActive = true; pMgmt->sNodeDBTable[0].bPSEnable = false; @@ -818,8 +816,6 @@ void BSSvSecondCallBack(struct work_struct *work) if (pDevice->Flags & fMP_DISCONNECTED) return; - spin_lock_irq(&pDevice->lock); - pDevice->uAssocCount = 0; /* Power Saving Mode Tx Burst */ @@ -1001,10 +997,8 @@ void BSSvSecondCallBack(struct work_struct *work) if (pMgmt->sNodeDBTable[0].bActive) { /* Assoc with BSS */ - if (pDevice->bUpdateBBVGA) { - s_vCheckSensitivity(pDevice); - s_vCheckPreEDThreshold(pDevice); - } + s_vCheckSensitivity(pDevice); + s_vCheckPreEDThreshold(pDevice); if (pMgmt->sNodeDBTable[0].uInActiveCount >= (LOST_BEACON_COUNT/2) && @@ -1022,10 +1016,10 @@ void BSSvSecondCallBack(struct work_struct *work) pMgmt->eCurrState = WMAC_STATE_IDLE; netif_stop_queue(pDevice->dev); pDevice->bLinkPass = false; - ControlvMaskByte(pDevice, - MESSAGE_REQUEST_MACREG, - MAC_REG_PAPEDELAY, LEDSTS_STS, - LEDSTS_SLOW); + + vnt_mac_set_led(pDevice, LEDSTS_STS, + LEDSTS_SLOW); + pDevice->bRoaming = true; pDevice->bIsRoaming = false; @@ -1121,10 +1115,9 @@ void BSSvSecondCallBack(struct work_struct *work) } if (pMgmt->eCurrState == WMAC_STATE_JOINTED) { - if (pDevice->bUpdateBBVGA) { - s_vCheckSensitivity(pDevice); - s_vCheckPreEDThreshold(pDevice); - } + s_vCheckSensitivity(pDevice); + s_vCheckPreEDThreshold(pDevice); + if (pMgmt->sNodeDBTable[0].uInActiveCount >= ADHOC_LOST_BEACON_COUNT) { DBG_PRT(MSG_LEVEL_NOTICE, @@ -1134,10 +1127,8 @@ void BSSvSecondCallBack(struct work_struct *work) pMgmt->eCurrState = WMAC_STATE_STARTED; netif_stop_queue(pDevice->dev); pDevice->bLinkPass = false; - ControlvMaskByte(pDevice, - MESSAGE_REQUEST_MACREG, - MAC_REG_PAPEDELAY, LEDSTS_STS, - LEDSTS_SLOW); + vnt_mac_set_led(pDevice, LEDSTS_STS, + LEDSTS_SLOW); } } } @@ -1158,8 +1149,6 @@ void BSSvSecondCallBack(struct work_struct *work) netif_wake_queue(pDevice->dev); } - spin_unlock_irq(&pDevice->lock); - schedule_delayed_work(&pDevice->second_callback_work, HZ); } @@ -1429,7 +1418,7 @@ static void s_uCalculateLinkQual(struct vnt_private *pDevice) if (pDevice->bLinkPass != true) { pDevice->wstats.qual.qual = 0; } else { - RFvRSSITodBm(pDevice, (u8) (pDevice->uCurrRSSI), &ldBm); + vnt_rf_rssi_to_dbm(pDevice, (u8) (pDevice->uCurrRSSI), &ldBm); if (-ldBm < 50) RssiRatio = 4000; else if (-ldBm > 90) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 0d8772858f0..d662e5431da 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -57,11 +57,7 @@ #include "rc4.h" #include "country.h" #include "datarate.h" -#include "rndis.h" -#include "control.h" - -//static int msglevel =MSG_LEVEL_DEBUG; -static int msglevel =MSG_LEVEL_INFO; +#include "usbpipe.h" //const u16 cwRXBCNTSFOff[MAX_RATE] = //{17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3}; @@ -98,24 +94,24 @@ void CARDbSetMediaChannel(struct vnt_private *priv, u32 connection_channel) /* Set Channel[7] = 0 to tell H/W channel is changing now. */ MACvRegBitsOff(priv, MAC_REG_CHANNEL, 0xb0); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_SELECT_CHANNLE, + vnt_control_out(priv, MESSAGE_TYPE_SELECT_CHANNLE, connection_channel, 0, 0, NULL); if (priv->byBBType == BB_TYPE_11A) { priv->byCurPwr = 0xff; - RFbRawSetPower(priv, + vnt_rf_set_txpower(priv, priv->abyOFDMAPwrTbl[connection_channel-15], RATE_54M); } else if (priv->byBBType == BB_TYPE_11G) { priv->byCurPwr = 0xff; - RFbRawSetPower(priv, + vnt_rf_set_txpower(priv, priv->abyOFDMPwrTbl[connection_channel-1], RATE_54M); } else { priv->byCurPwr = 0xff; - RFbRawSetPower(priv, + vnt_rf_set_txpower(priv, priv->abyCCKPwrTbl[connection_channel-1], RATE_1M); } - ControlvWriteByte(priv, MESSAGE_REQUEST_MACREG, MAC_REG_CHANNEL, + vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, MAC_REG_CHANNEL, (u8)(connection_channel|0x80)); } @@ -124,20 +120,20 @@ void CARDbSetMediaChannel(struct vnt_private *priv, u32 connection_channel) * * Parameters: * In: - * pDevice - The adapter to be set - * wRateIdx - Receiving data rate + * priv - The adapter to be set + * rate_idx - Receiving data rate * Out: * none * * Return Value: response Control frame rate * */ -static u16 swGetCCKControlRate(struct vnt_private *pDevice, u16 wRateIdx) +static u16 swGetCCKControlRate(struct vnt_private *priv, u16 rate_idx) { - u16 ui = wRateIdx; + u16 ui = rate_idx; while (ui > RATE_1M) { - if (pDevice->wBasicRate & (1 << ui)) + if (priv->wBasicRate & (1 << ui)) return ui; ui--; } @@ -150,39 +146,39 @@ static u16 swGetCCKControlRate(struct vnt_private *pDevice, u16 wRateIdx) * * Parameters: * In: - * pDevice - The adapter to be set - * wRateIdx - Receiving data rate + * priv - The adapter to be set + * rate_idx - Receiving data rate * Out: * none * * Return Value: response Control frame rate * */ -static u16 swGetOFDMControlRate(struct vnt_private *pDevice, u16 wRateIdx) +static u16 swGetOFDMControlRate(struct vnt_private *priv, u16 rate_idx) { - u16 ui = wRateIdx; + u16 ui = rate_idx; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n", - pDevice->wBasicRate); + dev_dbg(&priv->usb->dev, "%s basic rate: %d\n", + __func__, priv->wBasicRate); - if (!CARDbIsOFDMinBasicRate(pDevice)) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "swGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx); - if (wRateIdx > RATE_24M) - wRateIdx = RATE_24M; - return wRateIdx; + if (!CARDbIsOFDMinBasicRate(priv)) { + dev_dbg(&priv->usb->dev, "%s (NO OFDM) %d\n", + __func__, rate_idx); + if (rate_idx > RATE_24M) + rate_idx = RATE_24M; + return rate_idx; } while (ui > RATE_11M) { - if (pDevice->wBasicRate & (1 << ui)) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "swGetOFDMControlRate: %d\n", ui); + if (priv->wBasicRate & (1 << ui)) { + dev_dbg(&priv->usb->dev, "%s rate: %d\n", + __func__, ui); return ui; } ui--; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate: 6M\n"); + dev_dbg(&priv->usb->dev, "%s basic rate: 24M\n", __func__); return RATE_24M; } @@ -191,114 +187,95 @@ static u16 swGetOFDMControlRate(struct vnt_private *pDevice, u16 wRateIdx) * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode. * * Parameters: - * In: - * wRate - Tx Rate - * byPktType - Tx Packet type - * Out: - * pbyTxRate - pointer to RSPINF TxRate field - * pbyRsvTime - pointer to RSPINF RsvTime field + * In: + * rate - Tx Rate + * bb_type - Tx Packet type + * Out: + * tx_rate - pointer to RSPINF TxRate field + * rsv_time- pointer to RSPINF RsvTime field * * Return Value: none * */ -static void -CARDvCalculateOFDMRParameter ( - u16 wRate, - u8 byBBType, - u8 * pbyTxRate, - u8 * pbyRsvTime - ) +static void CARDvCalculateOFDMRParameter(u16 rate, u8 bb_type, + u8 *tx_rate, u8 *rsv_time) { - switch (wRate) { - case RATE_6M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9B; - *pbyRsvTime = 24; - } - else { - *pbyTxRate = 0x8B; - *pbyRsvTime = 30; - } - break; - - case RATE_9M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9F; - *pbyRsvTime = 16; - } - else { - *pbyTxRate = 0x8F; - *pbyRsvTime = 22; - } - break; - - case RATE_12M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9A; - *pbyRsvTime = 12; - } - else { - *pbyTxRate = 0x8A; - *pbyRsvTime = 18; - } - break; - - case RATE_18M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9E; - *pbyRsvTime = 8; - } - else { - *pbyTxRate = 0x8E; - *pbyRsvTime = 14; - } - break; - - case RATE_36M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9D; - *pbyRsvTime = 4; - } - else { - *pbyTxRate = 0x8D; - *pbyRsvTime = 10; - } - break; - - case RATE_48M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x98; - *pbyRsvTime = 4; - } - else { - *pbyTxRate = 0x88; - *pbyRsvTime = 10; - } - break; - - case RATE_54M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9C; - *pbyRsvTime = 4; - } - else { - *pbyTxRate = 0x8C; - *pbyRsvTime = 10; - } - break; - - case RATE_24M : - default : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x99; - *pbyRsvTime = 8; - } - else { - *pbyTxRate = 0x89; - *pbyRsvTime = 14; - } - break; - } + + switch (rate) { + case RATE_6M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9b; + *rsv_time = 24; + } else { + *tx_rate = 0x8b; + *rsv_time = 30; + } + break; + case RATE_9M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9f; + *rsv_time = 16; + } else { + *tx_rate = 0x8f; + *rsv_time = 22; + } + break; + case RATE_12M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9a; + *rsv_time = 12; + } else { + *tx_rate = 0x8a; + *rsv_time = 18; + } + break; + case RATE_18M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9e; + *rsv_time = 8; + } else { + *tx_rate = 0x8e; + *rsv_time = 14; + } + break; + case RATE_36M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9d; + *rsv_time = 4; + } else { + *tx_rate = 0x8d; + *rsv_time = 10; + } + break; + case RATE_48M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x98; + *rsv_time = 4; + } else { + *tx_rate = 0x88; + *rsv_time = 10; + } + break; + case RATE_54M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9c; + *rsv_time = 4; + } else { + *tx_rate = 0x8c; + *rsv_time = 10; + } + break; + case RATE_24M: + default: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x99; + *rsv_time = 8; + } else { + *tx_rate = 0x89; + *rsv_time = 14; + } + break; + } } /* @@ -313,112 +290,91 @@ CARDvCalculateOFDMRParameter ( * Return Value: None. * */ -void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType) + +void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type) { struct vnt_phy_field phy[4]; - u8 abyTxRate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */ - u8 abyRsvTime[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; - u8 abyData[34]; + u8 tx_rate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */ + u8 rsv_time[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; + u8 data[34]; int i; - //RSPINF_b_1 - BBvCalculateParameter(pDevice, 14, - swGetCCKControlRate(pDevice, RATE_1M), PK_TYPE_11B, &phy[0]); - - ///RSPINF_b_2 - BBvCalculateParameter(pDevice, 14, - swGetCCKControlRate(pDevice, RATE_2M), PK_TYPE_11B, &phy[1]); - - //RSPINF_b_5 - BBvCalculateParameter(pDevice, 14, - swGetCCKControlRate(pDevice, RATE_5M), PK_TYPE_11B, &phy[2]); - - //RSPINF_b_11 - BBvCalculateParameter(pDevice, 14, - swGetCCKControlRate(pDevice, RATE_11M), PK_TYPE_11B, &phy[3]); - - //RSPINF_a_6 - CARDvCalculateOFDMRParameter (RATE_6M, - byBBType, - &abyTxRate[0], - &abyRsvTime[0]); - - //RSPINF_a_9 - CARDvCalculateOFDMRParameter (RATE_9M, - byBBType, - &abyTxRate[1], - &abyRsvTime[1]); - - //RSPINF_a_12 - CARDvCalculateOFDMRParameter (RATE_12M, - byBBType, - &abyTxRate[2], - &abyRsvTime[2]); - - //RSPINF_a_18 - CARDvCalculateOFDMRParameter (RATE_18M, - byBBType, - &abyTxRate[3], - &abyRsvTime[3]); - - //RSPINF_a_24 - CARDvCalculateOFDMRParameter (RATE_24M, - byBBType, - &abyTxRate[4], - &abyRsvTime[4]); - - //RSPINF_a_36 - CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_36M), - byBBType, - &abyTxRate[5], - &abyRsvTime[5]); - - //RSPINF_a_48 - CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_48M), - byBBType, - &abyTxRate[6], - &abyRsvTime[6]); - - //RSPINF_a_54 - CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_54M), - byBBType, - &abyTxRate[7], - &abyRsvTime[7]); - - //RSPINF_a_72 - CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_54M), - byBBType, - &abyTxRate[8], - &abyRsvTime[8]); - - put_unaligned(phy[0].len, (u16 *)&abyData[0]); - abyData[2] = phy[0].signal; - abyData[3] = phy[0].service; - - put_unaligned(phy[1].len, (u16 *)&abyData[4]); - abyData[6] = phy[1].signal; - abyData[7] = phy[1].service; - - put_unaligned(phy[2].len, (u16 *)&abyData[8]); - abyData[10] = phy[2].signal; - abyData[11] = phy[2].service; - - put_unaligned(phy[3].len, (u16 *)&abyData[12]); - abyData[14] = phy[3].signal; - abyData[15] = phy[3].service; - - for (i = 0; i < 9; i++) { - abyData[16+i*2] = abyTxRate[i]; - abyData[16+i*2+1] = abyRsvTime[i]; - } - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - MAC_REG_RSPINF_B_1, - MESSAGE_REQUEST_MACREG, - 34, - &abyData[0]); + /*RSPINF_b_1*/ + BBvCalculateParameter(priv, 14, + swGetCCKControlRate(priv, RATE_1M), PK_TYPE_11B, &phy[0]); + + /*RSPINF_b_2*/ + BBvCalculateParameter(priv, 14, + swGetCCKControlRate(priv, RATE_2M), PK_TYPE_11B, &phy[1]); + + /*RSPINF_b_5*/ + BBvCalculateParameter(priv, 14, + swGetCCKControlRate(priv, RATE_5M), PK_TYPE_11B, &phy[2]); + + /*RSPINF_b_11*/ + BBvCalculateParameter(priv, 14, + swGetCCKControlRate(priv, RATE_11M), PK_TYPE_11B, &phy[3]); + + + /*RSPINF_a_6*/ + CARDvCalculateOFDMRParameter(RATE_6M, bb_type, + &tx_rate[0], &rsv_time[0]); + /*RSPINF_a_9*/ + CARDvCalculateOFDMRParameter(RATE_9M, bb_type, + &tx_rate[1], &rsv_time[1]); + + /*RSPINF_a_12*/ + CARDvCalculateOFDMRParameter(RATE_12M, bb_type, + &tx_rate[2], &rsv_time[2]); + + /*RSPINF_a_18*/ + CARDvCalculateOFDMRParameter(RATE_18M, bb_type, + &tx_rate[3], &rsv_time[3]); + + /*RSPINF_a_24*/ + CARDvCalculateOFDMRParameter(RATE_24M, bb_type, + &tx_rate[4], &rsv_time[4]); + + /*RSPINF_a_36*/ + CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_36M), + bb_type, &tx_rate[5], &rsv_time[5]); + + /*RSPINF_a_48*/ + CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_48M), + bb_type, &tx_rate[6], &rsv_time[6]); + + /*RSPINF_a_54*/ + CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_54M), + bb_type, &tx_rate[7], &rsv_time[7]); + + /*RSPINF_a_72*/ + CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_54M), + bb_type, &tx_rate[8], &rsv_time[8]); + + put_unaligned(phy[0].len, (u16 *)&data[0]); + data[2] = phy[0].signal; + data[3] = phy[0].service; + + put_unaligned(phy[1].len, (u16 *)&data[4]); + data[6] = phy[1].signal; + data[7] = phy[1].service; + + put_unaligned(phy[2].len, (u16 *)&data[8]); + data[10] = phy[2].signal; + data[11] = phy[2].service; + + put_unaligned(phy[3].len, (u16 *)&data[12]); + data[14] = phy[3].signal; + data[15] = phy[3].service; + + for (i = 0; i < 9; i++) { + data[16 + i * 2] = tx_rate[i]; + data[16 + i * 2 + 1] = rsv_time[i]; + } + + vnt_control_out(priv, MESSAGE_TYPE_WRITE, + MAC_REG_RSPINF_B_1, MESSAGE_REQUEST_MACREG, 34, &data[0]); } /* @@ -426,120 +382,119 @@ void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType) * * Parameters: * In: - * pDevice - The adapter to be set - * Out: - * none + * priv - The adapter to be set + * Out: + * none * * Return Value: None. * */ -void vUpdateIFS(struct vnt_private *pDevice) +void vUpdateIFS(struct vnt_private *priv) { - u8 byMaxMin = 0; - u8 byData[4]; - - if (pDevice->byPacketType==PK_TYPE_11A) {//0000 0000 0000 0000,11a - pDevice->uSlot = C_SLOT_SHORT; - pDevice->uSIFS = C_SIFS_A; - pDevice->uDIFS = C_SIFS_A + 2*C_SLOT_SHORT; - pDevice->uCwMin = C_CWMIN_A; - byMaxMin = 4; - } - else if (pDevice->byPacketType==PK_TYPE_11B) {//0000 0001 0000 0000,11b - pDevice->uSlot = C_SLOT_LONG; - pDevice->uSIFS = C_SIFS_BG; - pDevice->uDIFS = C_SIFS_BG + 2*C_SLOT_LONG; - pDevice->uCwMin = C_CWMIN_B; - byMaxMin = 5; - } - else {// PK_TYPE_11GA & PK_TYPE_11GB - u8 byRate = 0; - bool bOFDMRate = false; - unsigned int ii = 0; - PWLAN_IE_SUPP_RATES pItemRates = NULL; - - pDevice->uSIFS = C_SIFS_BG; - if (pDevice->bShortSlotTime) { - pDevice->uSlot = C_SLOT_SHORT; - } else { - pDevice->uSlot = C_SLOT_LONG; - } - pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot; - - pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->vnt_mgmt.abyCurrSuppRates; - for (ii = 0; ii < pItemRates->len; ii++) { - byRate = (u8)(pItemRates->abyRates[ii]&0x7F); - if (RATEwGetRateIdx(byRate) > RATE_11M) { - bOFDMRate = true; - break; - } - } - if (bOFDMRate == false) { - pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->vnt_mgmt - .abyCurrExtSuppRates; - for (ii = 0; ii < pItemRates->len; ii++) { - byRate = (u8)(pItemRates->abyRates[ii]&0x7F); - if (RATEwGetRateIdx(byRate) > RATE_11M) { - bOFDMRate = true; - break; - } - } - } - if (bOFDMRate == true) { - pDevice->uCwMin = C_CWMIN_A; - byMaxMin = 4; - } else { - pDevice->uCwMin = C_CWMIN_B; - byMaxMin = 5; - } - } - - pDevice->uCwMax = C_CWMAX; - pDevice->uEIFS = C_EIFS; - - byData[0] = (u8)pDevice->uSIFS; - byData[1] = (u8)pDevice->uDIFS; - byData[2] = (u8)pDevice->uEIFS; - byData[3] = (u8)pDevice->uSlot; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - MAC_REG_SIFS, - MESSAGE_REQUEST_MACREG, - 4, - &byData[0]); - - byMaxMin |= 0xA0;//1010 1111,C_CWMAX = 1023 - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - MAC_REG_CWMAXMIN0, - MESSAGE_REQUEST_MACREG, - 1, - &byMaxMin); + u8 max_min = 0; + u8 data[4]; + + if (priv->byPacketType == PK_TYPE_11A) { + priv->uSlot = C_SLOT_SHORT; + priv->uSIFS = C_SIFS_A; + priv->uDIFS = C_SIFS_A + 2 * C_SLOT_SHORT; + priv->uCwMin = C_CWMIN_A; + max_min = 4; + } else if (priv->byPacketType == PK_TYPE_11B) { + priv->uSlot = C_SLOT_LONG; + priv->uSIFS = C_SIFS_BG; + priv->uDIFS = C_SIFS_BG + 2 * C_SLOT_LONG; + priv->uCwMin = C_CWMIN_B; + max_min = 5; + } else {/* PK_TYPE_11GA & PK_TYPE_11GB */ + u8 rate = 0; + bool ofdm_rate = false; + unsigned int ii = 0; + PWLAN_IE_SUPP_RATES item_rates = NULL; + + priv->uSIFS = C_SIFS_BG; + + if (priv->bShortSlotTime) + priv->uSlot = C_SLOT_SHORT; + else + priv->uSlot = C_SLOT_LONG; + + priv->uDIFS = C_SIFS_BG + 2 * priv->uSlot; + + item_rates = + (PWLAN_IE_SUPP_RATES)priv->vnt_mgmt.abyCurrSuppRates; + + for (ii = 0; ii < item_rates->len; ii++) { + rate = (u8)(item_rates->abyRates[ii] & 0x7f); + if (RATEwGetRateIdx(rate) > RATE_11M) { + ofdm_rate = true; + break; + } + } + + if (ofdm_rate == false) { + item_rates = (PWLAN_IE_SUPP_RATES)priv->vnt_mgmt + .abyCurrExtSuppRates; + for (ii = 0; ii < item_rates->len; ii++) { + rate = (u8)(item_rates->abyRates[ii] & 0x7f); + if (RATEwGetRateIdx(rate) > RATE_11M) { + ofdm_rate = true; + break; + } + } + } + + if (ofdm_rate == true) { + priv->uCwMin = C_CWMIN_A; + max_min = 4; + } else { + priv->uCwMin = C_CWMIN_B; + max_min = 5; + } + } + + priv->uCwMax = C_CWMAX; + priv->uEIFS = C_EIFS; + + data[0] = (u8)priv->uSIFS; + data[1] = (u8)priv->uDIFS; + data[2] = (u8)priv->uEIFS; + data[3] = (u8)priv->uSlot; + + vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_SIFS, + MESSAGE_REQUEST_MACREG, 4, &data[0]); + + max_min |= 0xa0; + + vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_CWMAXMIN0, + MESSAGE_REQUEST_MACREG, 1, &max_min); } -void CARDvUpdateBasicTopRate(struct vnt_private *pDevice) +void CARDvUpdateBasicTopRate(struct vnt_private *priv) { - u8 byTopOFDM = RATE_24M, byTopCCK = RATE_1M; - u8 ii; - - //Determines the highest basic rate. - for (ii = RATE_54M; ii >= RATE_6M; ii --) { - if ( (pDevice->wBasicRate) & ((u16)(1<<ii)) ) { - byTopOFDM = ii; - break; - } - } - pDevice->byTopOFDMBasicRate = byTopOFDM; - - for (ii = RATE_11M;; ii --) { - if ( (pDevice->wBasicRate) & ((u16)(1<<ii)) ) { - byTopCCK = ii; - break; - } - if (ii == RATE_1M) - break; - } - pDevice->byTopCCKBasicRate = byTopCCK; + u8 top_ofdm = RATE_24M, top_cck = RATE_1M; + u8 i; + + /*Determines the highest basic rate.*/ + for (i = RATE_54M; i >= RATE_6M; i--) { + if (priv->wBasicRate & (u16)(1 << i)) { + top_ofdm = i; + break; + } + } + + priv->byTopOFDMBasicRate = top_ofdm; + + for (i = RATE_11M;; i--) { + if (priv->wBasicRate & (u16)(1 << i)) { + top_cck = i; + break; + } + if (i == RATE_1M) + break; + } + + priv->byTopCCKBasicRate = top_cck; } /* @@ -555,39 +510,36 @@ void CARDvUpdateBasicTopRate(struct vnt_private *pDevice) * Return Value: true if succeeded; false if failed. * */ -void CARDbAddBasicRate(struct vnt_private *pDevice, u16 wRateIdx) +void CARDbAddBasicRate(struct vnt_private *priv, u16 rate_idx) { - u16 wRate = (1 << wRateIdx); - pDevice->wBasicRate |= wRate; + priv->wBasicRate |= (1 << rate_idx); - //Determines the highest basic rate. - CARDvUpdateBasicTopRate(pDevice); + /*Determines the highest basic rate.*/ + CARDvUpdateBasicTopRate(priv); } -int CARDbIsOFDMinBasicRate(struct vnt_private *pDevice) +int CARDbIsOFDMinBasicRate(struct vnt_private *priv) { int ii; - for (ii = RATE_54M; ii >= RATE_6M; ii --) { - if ((pDevice->wBasicRate) & ((u16)(1<<ii))) - return true; - } - return false; + for (ii = RATE_54M; ii >= RATE_6M; ii--) { + if ((priv->wBasicRate) & ((u16)(1 << ii))) + return true; + } + + return false; } -u8 CARDbyGetPktType(struct vnt_private *pDevice) +u8 CARDbyGetPktType(struct vnt_private *priv) { - if (pDevice->byBBType == BB_TYPE_11A || pDevice->byBBType == BB_TYPE_11B) { - return (u8)pDevice->byBBType; - } - else if (CARDbIsOFDMinBasicRate(pDevice)) { - return PK_TYPE_11GA; - } - else { - return PK_TYPE_11GB; - } + if (priv->byBBType == BB_TYPE_11A || priv->byBBType == BB_TYPE_11B) + return (u8)priv->byBBType; + else if (CARDbIsOFDMinBasicRate(priv)) + return PK_TYPE_11GA; + else + return PK_TYPE_11GB; } /* @@ -596,27 +548,27 @@ u8 CARDbyGetPktType(struct vnt_private *pDevice) * * Parameters: * In: - * pDevice - The adapter to be sync. - * qwTSF1 - Rx BCN's TSF - * qwTSF2 - Local TSF + * rx_rate - rx rate. + * tsf1 - Rx BCN's TSF + * tsf2 - Local TSF * Out: * none * * Return Value: TSF Offset value * */ -u64 CARDqGetTSFOffset(u8 byRxRate, u64 qwTSF1, u64 qwTSF2) +u64 CARDqGetTSFOffset(u8 rx_rate, u64 tsf1, u64 tsf2) { - u64 qwTSFOffset = 0; - u16 wRxBcnTSFOffst = 0; + u64 tsf_offset = 0; + u16 rx_bcn_offset = 0; - wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate % MAX_RATE]; + rx_bcn_offset = cwRXBCNTSFOff[rx_rate % MAX_RATE]; - qwTSF2 += (u64)wRxBcnTSFOffst; + tsf2 += (u64)rx_bcn_offset; - qwTSFOffset = qwTSF1 - qwTSF2; + tsf_offset = tsf1 - tsf2; - return qwTSFOffset; + return tsf_offset; } /* @@ -625,42 +577,34 @@ u64 CARDqGetTSFOffset(u8 byRxRate, u64 qwTSF1, u64 qwTSF2) * * Parameters: * In: - * pDevice - The adapter to be sync. - * qwBSSTimestamp - Rx BCN's TSF - * qwLocalTSF - Local TSF + * priv - The adapter to be sync. + * time_stamp - Rx BCN's TSF + * local_tsf - Local TSF * Out: * none * * Return Value: none * */ -void CARDvAdjustTSF(struct vnt_private *pDevice, u8 byRxRate, - u64 qwBSSTimestamp, u64 qwLocalTSF) +void CARDvAdjustTSF(struct vnt_private *priv, u8 rx_rate, + u64 time_stamp, u64 local_tsf) { - u64 qwTSFOffset = 0; - u8 pbyData[8]; - - qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, qwLocalTSF); - // adjust TSF - // HW's TSF add TSF Offset reg - - pbyData[0] = (u8)qwTSFOffset; - pbyData[1] = (u8)(qwTSFOffset >> 8); - pbyData[2] = (u8)(qwTSFOffset >> 16); - pbyData[3] = (u8)(qwTSFOffset >> 24); - pbyData[4] = (u8)(qwTSFOffset >> 32); - pbyData[5] = (u8)(qwTSFOffset >> 40); - pbyData[6] = (u8)(qwTSFOffset >> 48); - pbyData[7] = (u8)(qwTSFOffset >> 56); - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_SET_TSFTBTT, - MESSAGE_REQUEST_TSF, - 0, - 8, - pbyData - ); - + u64 tsf_offset = 0; + u8 data[8]; + + tsf_offset = CARDqGetTSFOffset(rx_rate, time_stamp, local_tsf); + + data[0] = (u8)tsf_offset; + data[1] = (u8)(tsf_offset >> 8); + data[2] = (u8)(tsf_offset >> 16); + data[3] = (u8)(tsf_offset >> 24); + data[4] = (u8)(tsf_offset >> 32); + data[5] = (u8)(tsf_offset >> 40); + data[6] = (u8)(tsf_offset >> 48); + data[7] = (u8)(tsf_offset >> 56); + + vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT, + MESSAGE_REQUEST_TSF, 0, 8, data); } /* * Description: Read NIC TSF counter @@ -668,17 +612,17 @@ void CARDvAdjustTSF(struct vnt_private *pDevice, u8 byRxRate, * * Parameters: * In: - * pDevice - The adapter to be read + * priv - The adapter to be read * Out: - * qwCurrTSF - Current TSF counter + * current_tsf - Current TSF counter * * Return Value: true if success; otherwise false * */ -bool CARDbGetCurrentTSF(struct vnt_private *pDevice, u64 *pqwCurrTSF) +bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *current_tsf) { - *pqwCurrTSF = pDevice->qwCurrTSF; + *current_tsf = priv->qwCurrTSF; return true; } @@ -689,17 +633,17 @@ bool CARDbGetCurrentTSF(struct vnt_private *pDevice, u64 *pqwCurrTSF) * * Parameters: * In: - * pDevice - The adapter to be read + * priv - The adapter to be read * * Return Value: true if success; otherwise false * */ -bool CARDbClearCurrentTSF(struct vnt_private *pDevice) +bool CARDbClearCurrentTSF(struct vnt_private *priv) { - MACvRegBitsOn(pDevice, MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); + MACvRegBitsOn(priv, MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); - pDevice->qwCurrTSF = 0; + priv->qwCurrTSF = 0; return true; } @@ -710,30 +654,30 @@ bool CARDbClearCurrentTSF(struct vnt_private *pDevice) * * Parameters: * In: - * qwTSF - Current TSF counter - * wbeaconInterval - Beacon Interval + * tsf - Current TSF counter + * beacon_interval - Beacon Interval * Out: - * qwCurrTSF - Current TSF counter + * tsf - Current TSF counter * * Return Value: TSF value of next Beacon * */ -u64 CARDqGetNextTBTT(u64 qwTSF, u16 wBeaconInterval) +u64 CARDqGetNextTBTT(u64 tsf, u16 beacon_interval) { - u32 uBeaconInterval; + u32 beacon_int; - uBeaconInterval = wBeaconInterval * 1024; + beacon_int = beacon_interval * 1024; /* Next TBTT = * ((local_current_TSF / beacon_interval) + 1) * beacon_interval */ - if (uBeaconInterval) { - do_div(qwTSF, uBeaconInterval); - qwTSF += 1; - qwTSF *= uBeaconInterval; + if (beacon_int) { + do_div(tsf, beacon_int); + tsf += 1; + tsf *= beacon_int; } - return qwTSF; + return tsf; } /* @@ -743,41 +687,35 @@ u64 CARDqGetNextTBTT(u64 qwTSF, u16 wBeaconInterval) * Parameters: * In: * dwIoBase - IO Base - * wBeaconInterval - Beacon Interval + * beacon_interval - Beacon Interval * Out: * none * * Return Value: none * */ -void CARDvSetFirstNextTBTT(struct vnt_private *pDevice, u16 wBeaconInterval) +void CARDvSetFirstNextTBTT(struct vnt_private *priv, u16 beacon_interval) { - u64 qwNextTBTT = 0; - u8 pbyData[8]; - - CARDbClearCurrentTSF(pDevice); - //CARDbGetCurrentTSF(pDevice, &qwNextTBTT); //Get Local TSF counter - qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval); - // Set NextTBTT - - pbyData[0] = (u8)qwNextTBTT; - pbyData[1] = (u8)(qwNextTBTT >> 8); - pbyData[2] = (u8)(qwNextTBTT >> 16); - pbyData[3] = (u8)(qwNextTBTT >> 24); - pbyData[4] = (u8)(qwNextTBTT >> 32); - pbyData[5] = (u8)(qwNextTBTT >> 40); - pbyData[6] = (u8)(qwNextTBTT >> 48); - pbyData[7] = (u8)(qwNextTBTT >> 56); - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_SET_TSFTBTT, - MESSAGE_REQUEST_TBTT, - 0, - 8, - pbyData - ); - - return; + u64 next_tbtt = 0; + u8 data[8]; + + CARDbClearCurrentTSF(priv); + + next_tbtt = CARDqGetNextTBTT(next_tbtt, beacon_interval); + + data[0] = (u8)next_tbtt; + data[1] = (u8)(next_tbtt >> 8); + data[2] = (u8)(next_tbtt >> 16); + data[3] = (u8)(next_tbtt >> 24); + data[4] = (u8)(next_tbtt >> 32); + data[5] = (u8)(next_tbtt >> 40); + data[6] = (u8)(next_tbtt >> 48); + data[7] = (u8)(next_tbtt >> 56); + + vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT, + MESSAGE_REQUEST_TBTT, 0, 8, data); + + return; } /* @@ -786,45 +724,37 @@ void CARDvSetFirstNextTBTT(struct vnt_private *pDevice, u16 wBeaconInterval) * * Parameters: * In: - * pDevice - The adapter to be set - * qwTSF - Current TSF counter - * wBeaconInterval - Beacon Interval + * priv - The adapter to be set + * tsf - Current TSF counter + * beacon_interval - Beacon Interval * Out: * none * * Return Value: none * */ -void CARDvUpdateNextTBTT(struct vnt_private *pDevice, u64 qwTSF, - u16 wBeaconInterval) +void CARDvUpdateNextTBTT(struct vnt_private *priv, u64 tsf, + u16 beacon_interval) { - u8 pbyData[8]; - - qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval); + u8 data[8]; - // Set NextTBTT + tsf = CARDqGetNextTBTT(tsf, beacon_interval); - pbyData[0] = (u8)qwTSF; - pbyData[1] = (u8)(qwTSF >> 8); - pbyData[2] = (u8)(qwTSF >> 16); - pbyData[3] = (u8)(qwTSF >> 24); - pbyData[4] = (u8)(qwTSF >> 32); - pbyData[5] = (u8)(qwTSF >> 40); - pbyData[6] = (u8)(qwTSF >> 48); - pbyData[7] = (u8)(qwTSF >> 56); + data[0] = (u8)tsf; + data[1] = (u8)(tsf >> 8); + data[2] = (u8)(tsf >> 16); + data[3] = (u8)(tsf >> 24); + data[4] = (u8)(tsf >> 32); + data[5] = (u8)(tsf >> 40); + data[6] = (u8)(tsf >> 48); + data[7] = (u8)(tsf >> 56); - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_SET_TSFTBTT, - MESSAGE_REQUEST_TBTT, - 0, - 8, - pbyData - ); + vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT, + MESSAGE_REQUEST_TBTT, 0, 8, data); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Card:Update Next TBTT[%8lx]\n", (unsigned long)qwTSF); + dev_dbg(&priv->usb->dev, "%s TBTT: %8llx\n", __func__, tsf); - return; + return; } /* @@ -832,38 +762,36 @@ void CARDvUpdateNextTBTT(struct vnt_private *pDevice, u64 qwTSF, * * Parameters: * In: - * pDevice - The adapter to be turned off + * priv - The adapter to be turned off * Out: * none * * Return Value: true if success; otherwise false * */ -int CARDbRadioPowerOff(struct vnt_private *pDevice) +int CARDbRadioPowerOff(struct vnt_private *priv) { - int bResult = true; - - //if (pDevice->bRadioOff == true) - // return true; - - pDevice->bRadioOff = true; - - switch (pDevice->byRFType) { - case RF_AL2230: - case RF_AL2230S: - case RF_AIROHA7230: - case RF_VT3226: //RobertYu:20051111 - case RF_VT3226D0: - case RF_VT3342A0: //RobertYu:20060609 - MACvRegBitsOff(pDevice, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); - break; - } + int ret = true; + + priv->bRadioOff = true; + + switch (priv->byRFType) { + case RF_AL2230: + case RF_AL2230S: + case RF_AIROHA7230: + case RF_VT3226: + case RF_VT3226D0: + case RF_VT3342A0: + MACvRegBitsOff(priv, MAC_REG_SOFTPWRCTL, + (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); + break; + } - MACvRegBitsOff(pDevice, MAC_REG_HOSTCR, HOSTCR_RXON); + MACvRegBitsOff(priv, MAC_REG_HOSTCR, HOSTCR_RXON); - BBvSetDeepSleep(pDevice); + BBvSetDeepSleep(priv); - return bResult; + return ret; } /* @@ -871,84 +799,79 @@ int CARDbRadioPowerOff(struct vnt_private *pDevice) * * Parameters: * In: - * pDevice - The adapter to be turned on + * priv - The adapter to be turned on * Out: * none * * Return Value: true if success; otherwise false * */ -int CARDbRadioPowerOn(struct vnt_private *pDevice) +int CARDbRadioPowerOn(struct vnt_private *priv) { - int bResult = true; + int ret = true; - if ((pDevice->bHWRadioOff == true) || (pDevice->bRadioControlOff == true)) { - return false; - } + if (priv->bHWRadioOff == true || priv->bRadioControlOff == true) + return false; - //if (pDevice->bRadioOff == false) - // return true; + priv->bRadioOff = false; - pDevice->bRadioOff = false; + BBvExitDeepSleep(priv); - BBvExitDeepSleep(pDevice); + MACvRegBitsOn(priv, MAC_REG_HOSTCR, HOSTCR_RXON); - MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_RXON); - - switch (pDevice->byRFType) { - case RF_AL2230: - case RF_AL2230S: - case RF_AIROHA7230: - case RF_VT3226: //RobertYu:20051111 - case RF_VT3226D0: - case RF_VT3342A0: //RobertYu:20060609 - MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); - break; - } + switch (priv->byRFType) { + case RF_AL2230: + case RF_AL2230S: + case RF_AIROHA7230: + case RF_VT3226: + case RF_VT3226D0: + case RF_VT3342A0: + MACvRegBitsOn(priv, MAC_REG_SOFTPWRCTL, + (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); + break; + } - return bResult; + return ret; } -void CARDvSetBSSMode(struct vnt_private *pDevice) +void CARDvSetBSSMode(struct vnt_private *priv) { - // Set BB and packet type at the same time.//{{RobertYu:20050222, AL7230 have two TX PA output, only connet to b/g now - // so in 11a mode need to set the MAC Reg0x4C to 11b/g mode to turn on PA - if( (pDevice->byRFType == RF_AIROHA7230 ) && (pDevice->byBBType == BB_TYPE_11A) ) - { - MACvSetBBType(pDevice, BB_TYPE_11G); - } - else - { - MACvSetBBType(pDevice, pDevice->byBBType); - } - pDevice->byPacketType = CARDbyGetPktType(pDevice); - - if (pDevice->byBBType == BB_TYPE_11A) { - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x03); - } else if (pDevice->byBBType == BB_TYPE_11B) { - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x02); - } else if (pDevice->byBBType == BB_TYPE_11G) { - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x08); - } - - vUpdateIFS(pDevice); - CARDvSetRSPINF(pDevice, (u8)pDevice->byBBType); - - if ( pDevice->byBBType == BB_TYPE_11A ) { - //request by Jack 2005-04-26 - if (pDevice->byRFType == RF_AIROHA7230) { - pDevice->abyBBVGA[0] = 0x20; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, pDevice->abyBBVGA[0]); - } - pDevice->abyBBVGA[2] = 0x10; - pDevice->abyBBVGA[3] = 0x10; - } else { - //request by Jack 2005-04-26 - if (pDevice->byRFType == RF_AIROHA7230) { - pDevice->abyBBVGA[0] = 0x1C; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, pDevice->abyBBVGA[0]); - } - pDevice->abyBBVGA[2] = 0x0; - pDevice->abyBBVGA[3] = 0x0; - } + if (priv->byRFType == RF_AIROHA7230 && priv->byBBType == BB_TYPE_11A) + MACvSetBBType(priv, BB_TYPE_11G); + else + MACvSetBBType(priv, priv->byBBType); + + priv->byPacketType = CARDbyGetPktType(priv); + + if (priv->byBBType == BB_TYPE_11A) + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x03); + else if (priv->byBBType == BB_TYPE_11B) + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x02); + else if (priv->byBBType == BB_TYPE_11G) + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x08); + + vUpdateIFS(priv); + CARDvSetRSPINF(priv, (u8)priv->byBBType); + + if (priv->byBBType == BB_TYPE_11A) { + if (priv->byRFType == RF_AIROHA7230) { + priv->abyBBVGA[0] = 0x20; + + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, + 0xe7, priv->abyBBVGA[0]); + } + + priv->abyBBVGA[2] = 0x10; + priv->abyBBVGA[3] = 0x10; + } else { + if (priv->byRFType == RF_AIROHA7230) { + priv->abyBBVGA[0] = 0x1c; + + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, + 0xe7, priv->abyBBVGA[0]); + } + + priv->abyBBVGA[2] = 0x0; + priv->abyBBVGA[3] = 0x0; + } } diff --git a/drivers/staging/vt6656/card.h b/drivers/staging/vt6656/card.h index f843e50875f..ac734714c7d 100644 --- a/drivers/staging/vt6656/card.h +++ b/drivers/staging/vt6656/card.h @@ -46,10 +46,10 @@ typedef enum _CARD_PHY_TYPE { struct vnt_private; void CARDbSetMediaChannel(struct vnt_private *pDevice, u32 uConnectionChannel); -void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType); -void vUpdateIFS(struct vnt_private *pDevice); -void CARDvUpdateBasicTopRate(struct vnt_private *pDevice); -void CARDbAddBasicRate(struct vnt_private *pDevice, u16 wRateIdx); +void CARDvSetRSPINF(struct vnt_private *, u8); +void vUpdateIFS(struct vnt_private *); +void CARDvUpdateBasicTopRate(struct vnt_private *); +void CARDbAddBasicRate(struct vnt_private *, u16); int CARDbIsOFDMinBasicRate(struct vnt_private *pDevice); void CARDvAdjustTSF(struct vnt_private *pDevice, u8 byRxRate, u64 qwBSSTimestamp, u64 qwLocalTSF); diff --git a/drivers/staging/vt6656/control.c b/drivers/staging/vt6656/control.c deleted file mode 100644 index 026784fcde8..00000000000 --- a/drivers/staging/vt6656/control.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: control.c - * - * Purpose: Handle USB control endpoint - * - * Author: Jerry Chen - * - * Date: Apr. 5, 2004 - * - * Functions: - * CONTROLnsRequestOut - Write variable length bytes to MEM/BB/MAC/EEPROM - * CONTROLnsRequestIn - Read variable length bytes from MEM/BB/MAC/EEPROM - * ControlvWriteByte - Write one byte to MEM/BB/MAC/EEPROM - * ControlvReadByte - Read one byte from MEM/BB/MAC/EEPROM - * ControlvMaskByte - Read one byte from MEM/BB/MAC/EEPROM and clear/set - * some bits in the same address - * - * Revision History: - * 04-05-2004 Jerry Chen: Initial release - * 11-24-2004 Warren Hsu: Add ControlvWriteByte, ControlvReadByte, - * ControlvMaskByte - * - */ - -#include "control.h" -#include "rndis.h" - -/* static int msglevel =MSG_LEVEL_INFO; */ -/* static int msglevel =MSG_LEVEL_DEBUG; */ - -void ControlvWriteByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, - u8 data) -{ - - CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE, reg_off, reg, - sizeof(u8), &data); - - return; -} - -void ControlvReadByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, - u8 *data) -{ - CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, - reg_off, reg, sizeof(u8), data); - return; -} - -void ControlvMaskByte(struct vnt_private *pDevice, u8 reg_type, u8 reg_off, - u8 reg_mask, u8 data) -{ - u8 reg_data[2]; - - reg_data[0] = data; - reg_data[1] = reg_mask; - - CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE_MASK, reg_off, - reg_type, ARRAY_SIZE(reg_data), reg_data); - - return; -} diff --git a/drivers/staging/vt6656/control.h b/drivers/staging/vt6656/control.h deleted file mode 100644 index 9da9b96add7..00000000000 --- a/drivers/staging/vt6656/control.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: control.h - * - * Purpose: - * - * Author: Jerry Chen - * - * Date: Apr. 5, 2004 - * - */ - -#ifndef __CONTROL_H__ -#define __CONTROL_H__ - -#include "device.h" -#include "usbpipe.h" - -#define CONTROLnsRequestOut(Device, Request, Value, Index, Length, Buffer) \ - PIPEnsControlOut(Device, Request, Value, Index, Length, Buffer) - -#define CONTROLnsRequestOutAsyn(Device, Request, Value, Index, Length, Buffer) \ - PIPEnsControlOutAsyn(Device, Request, Value, Index, Length, Buffer) - -#define CONTROLnsRequestIn(Device, Request, Value, Index, Length, Buffer) \ - PIPEnsControlIn(Device, Request, Value, Index, Length, Buffer) - -void ControlvWriteByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, - u8 data); - -void ControlvReadByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, - u8 *data); - -void ControlvMaskByte(struct vnt_private *pDevice, u8 reg_type, u8 reg_off, - u8 reg_mask, u8 data); - -#endif /* __CONTROL_H__ */ diff --git a/drivers/staging/vt6656/datarate.c b/drivers/staging/vt6656/datarate.c index 547db6f0c53..8032d6b5b38 100644 --- a/drivers/staging/vt6656/datarate.c +++ b/drivers/staging/vt6656/datarate.c @@ -40,7 +40,6 @@ #include "datarate.h" #include "card.h" #include "baseband.h" -#include "srom.h" #include "rf.h" /* static int msglevel = MSG_LEVEL_DEBUG; */ diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index 7c6dd5f5229..617d479b85c 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -39,28 +39,15 @@ /* max transmit or receive buffer size */ #define CB_MAX_BUF_SIZE 2900U /* NOTE: must be multiple of 4 */ -/* max TX buffer size */ -#define CB_MAX_TX_BUF_SIZE CB_MAX_BUF_SIZE -/* max RX buffer size when not use Multi-RD */ -#define CB_MAX_RX_BUF_SIZE_NORMAL CB_MAX_BUF_SIZE - -#define CB_BEACON_BUF_SIZE 512U /* default beacon buffer size */ - #define MAX_TOTAL_SIZE_WITH_ALL_HEADERS CB_MAX_BUF_SIZE #define MAX_INTERRUPT_SIZE 32 -#define RX_BLOCKS 64 /* from 0x60 to 0xA0 */ -#define TX_BLOCKS 32 /* from 0xA0 to 0xC0 */ - #define CB_MAX_RX_DESC 128 /* max # of descriptors */ #define CB_MIN_RX_DESC 16 /* min # of RX descriptors */ #define CB_MAX_TX_DESC 128 /* max # of descriptors */ #define CB_MIN_TX_DESC 16 /* min # of TX descriptors */ -#define CB_RD_NUM 64 /* default # of RD */ -#define CB_TD_NUM 64 /* default # of TD */ - /* * bits in the RSR register */ @@ -91,15 +78,6 @@ #define TSR_ACKDATA 0x02 #define TSR_VALID 0x01 -#define CB_PROTOCOL_RESERVED_SECTION 16 - -/* - * if retries exceed 15 times, TX will abort, and - * if TX fifo underflow, TX will fail - * we should try to resend it - */ -#define CB_MAX_TX_ABORT_RETRY 3 - #define FIFOCTL_AUTO_FB_1 0x1000 #define FIFOCTL_AUTO_FB_0 0x0800 #define FIFOCTL_GRPACK 0x0400 @@ -126,50 +104,4 @@ #define FRAGCTL_STAFRAG 0x0001 #define FRAGCTL_NONFRAG 0x0000 -#define TYPE_TXDMA0 0 -#define TYPE_AC0DMA 1 -#define TYPE_ATIMDMA 2 -#define TYPE_SYNCDMA 3 -#define TYPE_MAXTD 2 - -#define TYPE_BEACONDMA 4 - -#define TYPE_RXDMA0 0 -#define TYPE_RXDMA1 1 -#define TYPE_MAXRD 2 - -/* TD_INFO flags control bit */ -#define TD_FLAGS_NETIF_SKB 0x01 /* check if need release skb */ -#define TD_FLAGS_PRIV_SKB 0x02 /* check if called from private skb(hostap) */ -#define TD_FLAGS_PS_RETRY 0x04 /* check if PS STA frame re-transmit */ - -/* - * TX FIFO header - */ -typedef struct tagSBEACONCtl { - u32 BufReady:1; - u32 TSF:15; - u32 BufLen:11; - u32 Reserved:5; -} __attribute__ ((__packed__)) -SBEACONCtl; - -typedef struct tagSSecretKey { - u32 dwLowDword; - u8 byHighByte; -} __attribute__ ((__packed__)) -SSecretKey; - -typedef struct tagSKeyEntry { - u8 abyAddrHi[2]; - u16 wKCTL; - u8 abyAddrLo[4]; - u32 dwKey0[4]; - u32 dwKey1[4]; - u32 dwKey2[4]; - u32 dwKey3[4]; - u32 dwKey4[4]; -} __attribute__ ((__packed__)) -SKeyEntry; - #endif /* __DESC_H__ */ diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index e2abe3ddd24..5b64ca7b62f 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -52,53 +52,35 @@ #undef DEVICE_ETHTOOL_IOCTL_SUPPORT #endif -/* please copy below macro to driver_event.c for API */ -#define RT_INSMOD_EVENT_FLAG 0x0101 -#define RT_UPDEV_EVENT_FLAG 0x0102 -#define RT_DISCONNECTED_EVENT_FLAG 0x0103 -#define RT_WPACONNECTED_EVENT_FLAG 0x0104 -#define RT_DOWNDEV_EVENT_FLAG 0x0105 -#define RT_RMMOD_EVENT_FLAG 0x0106 +#define MAX_RATE 12 /* * device specific */ -#include "device_cfg.h" #include "80211hdr.h" #include "tether.h" #include "wmgr.h" #include "wcmd.h" -#include "srom.h" #include "rc4.h" #include "desc.h" #include "key.h" #include "card.h" -#include "rndis.h" #define VNT_USB_VENDOR_ID 0x160a #define VNT_USB_PRODUCT_ID 0x3184 -#define MAC_MAX_CONTEXT_REG (256+128) +#define DEVICE_NAME "vt6656" +#define DEVICE_FULL_DRV_NAM "VIA Networking Wireless LAN USB Driver" -#define MAX_MULTICAST_ADDRESS_NUM 32 -#define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * ETH_ALEN) +#define DEVICE_VERSION "1.19_12" -#define DUPLICATE_RX_CACHE_LENGTH 5 - -#define NUM_KEY_ENTRY 11 +#define CONFIG_PATH "/etc/vntconfiguration.dat" -#define TX_WEP_NONE 0 -#define TX_WEP_OTF 1 -#define TX_WEP_SW 2 -#define TX_WEP_SWOTP 3 -#define TX_WEP_OTPSW 4 -#define TX_WEP_SW232 5 +#define MAX_UINTS 8 +#define OPTION_DEFAULT { [0 ... MAX_UINTS-1] = -1} -#define KEYSEL_WEP40 0 -#define KEYSEL_WEP104 1 -#define KEYSEL_TKIP 2 -#define KEYSEL_CCMP 3 +#define DUPLICATE_RX_CACHE_LENGTH 5 #define AUTO_FB_NONE 0 #define AUTO_FB_0 1 @@ -119,23 +101,86 @@ #define ANT_RXA 2 #define ANT_RXB 3 -#define MAXCHECKHANGCNT 4 - -/* Packet type */ -#define TX_PKT_UNI 0x00 -#define TX_PKT_MULTI 0x01 -#define TX_PKT_BROAD 0x02 - #define BB_VGA_LEVEL 4 #define BB_VGA_CHANGE_THRESHOLD 3 +#define EEP_MAX_CONTEXT_SIZE 256 + +/* Contents in the EEPROM */ +#define EEP_OFS_PAR 0x0 +#define EEP_OFS_ANTENNA 0x17 +#define EEP_OFS_RADIOCTL 0x18 +#define EEP_OFS_RFTYPE 0x1b +#define EEP_OFS_MINCHANNEL 0x1c +#define EEP_OFS_MAXCHANNEL 0x1d +#define EEP_OFS_SIGNATURE 0x1e +#define EEP_OFS_ZONETYPE 0x1f +#define EEP_OFS_RFTABLE 0x20 +#define EEP_OFS_PWR_CCK 0x20 +#define EEP_OFS_SETPT_CCK 0x21 +#define EEP_OFS_PWR_OFDMG 0x23 + +#define EEP_OFS_CALIB_TX_IQ 0x24 +#define EEP_OFS_CALIB_TX_DC 0x25 +#define EEP_OFS_CALIB_RX_IQ 0x26 + +#define EEP_OFS_MAJOR_VER 0x2e +#define EEP_OFS_MINOR_VER 0x2f + +#define EEP_OFS_CCK_PWR_TBL 0x30 +#define EEP_OFS_OFDM_PWR_TBL 0x40 +#define EEP_OFS_OFDMA_PWR_TBL 0x50 + +/* Bits in EEP_OFS_ANTENNA */ +#define EEP_ANTENNA_MAIN 0x1 +#define EEP_ANTENNA_AUX 0x2 +#define EEP_ANTINV 0x4 + +/* Bits in EEP_OFS_RADIOCTL */ +#define EEP_RADIOCTL_ENABLE 0x80 + +/* control commands */ +#define MESSAGE_TYPE_READ 0x1 +#define MESSAGE_TYPE_WRITE 0x0 +#define MESSAGE_TYPE_LOCK_OR 0x2 +#define MESSAGE_TYPE_LOCK_AND 0x3 +#define MESSAGE_TYPE_WRITE_MASK 0x4 +#define MESSAGE_TYPE_CARDINIT 0x5 +#define MESSAGE_TYPE_INIT_RSP 0x6 +#define MESSAGE_TYPE_MACSHUTDOWN 0x7 +#define MESSAGE_TYPE_SETKEY 0x8 +#define MESSAGE_TYPE_CLRKEYENTRY 0x9 +#define MESSAGE_TYPE_WRITE_MISCFF 0xa +#define MESSAGE_TYPE_SET_ANTMD 0xb +#define MESSAGE_TYPE_SELECT_CHANNLE 0xc +#define MESSAGE_TYPE_SET_TSFTBTT 0xd +#define MESSAGE_TYPE_SET_SSTIFS 0xe +#define MESSAGE_TYPE_CHANGE_BBTYPE 0xf +#define MESSAGE_TYPE_DISABLE_PS 0x10 +#define MESSAGE_TYPE_WRITE_IFRF 0x11 + +/* command read/write(index) */ +#define MESSAGE_REQUEST_MEM 0x1 +#define MESSAGE_REQUEST_BBREG 0x2 +#define MESSAGE_REQUEST_MACREG 0x3 +#define MESSAGE_REQUEST_EEPROM 0x4 +#define MESSAGE_REQUEST_TSF 0x5 +#define MESSAGE_REQUEST_TBTT 0x6 +#define MESSAGE_REQUEST_BBAGC 0x7 +#define MESSAGE_REQUEST_VERSION 0x8 +#define MESSAGE_REQUEST_RF_INIT 0x9 +#define MESSAGE_REQUEST_RF_INIT2 0xa +#define MESSAGE_REQUEST_RF_CH0 0xb +#define MESSAGE_REQUEST_RF_CH1 0xc +#define MESSAGE_REQUEST_RF_CH2 0xd + +/* USB registers */ +#define USB_REG4 0x604 + #ifndef RUN_AT #define RUN_AT(x) (jiffies+(x)) #endif -/* DMA related */ -#define RESERV_AC0DMA 4 - #define PRIVATE_Message 0 #define DBG_PRT(l, p, args...) { if (l <= msglevel) printk(p, ##args); } @@ -153,6 +198,23 @@ typedef enum __device_msg_level { #define DEVICE_INIT_RESET 0x1 /* reset init or Dx to D0 power remain */ #define DEVICE_INIT_DXPL 0x2 /* Dx to D0 power lost init */ +/* Device init */ +struct vnt_cmd_card_init { + u8 init_class; + u8 exist_sw_net_addr; + u8 sw_net_addr[6]; + u8 short_retry_limit; + u8 long_retry_limit; +}; + +struct vnt_rsp_card_init { + u8 status; + u8 net_addr[6]; + u8 rf_type; + u8 min_channel; + u8 max_channel; +}; + /* USB */ /* @@ -176,13 +238,13 @@ struct vnt_rcb { /* used to track bulk out irps */ struct vnt_usb_send_context { - void *pDevice; - struct sk_buff *pPacket; - struct urb *pUrb; - unsigned int uBufLen; + void *priv; + struct sk_buff *skb; + struct urb *urb; + unsigned int buf_len; u8 type; - bool bBoolInUse; - unsigned char Data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS]; + bool in_use; + unsigned char data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS]; }; /* tx packet info for rxtx */ @@ -278,9 +340,9 @@ typedef struct tagSPMKIDCandidateEvent { /* The receive duplicate detection cache entry */ typedef struct tagSCacheEntry{ - u16 wFmSequence; - u8 abyAddr2[ETH_ALEN]; - u16 wFrameCtl; + __le16 wFmSequence; + u8 abyAddr2[ETH_ALEN]; + __le16 wFrameCtl; } SCacheEntry, *PSCacheEntry; typedef struct tagSCache{ @@ -309,29 +371,9 @@ typedef struct tagSDeFragControlBlock /* flags for options */ #define DEVICE_FLAGS_UNPLUG 0x00000001UL -#define DEVICE_FLAGS_PREAMBLE_TYPE 0x00000002UL -#define DEVICE_FLAGS_OP_MODE 0x00000004UL -#define DEVICE_FLAGS_PS_MODE 0x00000008UL -#define DEVICE_FLAGS_80211h_MODE 0x00000010UL /* flags for driver status */ #define DEVICE_FLAGS_OPENED 0x00010000UL -#define DEVICE_FLAGS_WOL_ENABLED 0x00080000UL -/* flags for capabilities */ -#define DEVICE_FLAGS_TX_ALIGN 0x01000000UL -#define DEVICE_FLAGS_HAVE_CAM 0x02000000UL -#define DEVICE_FLAGS_FLOW_CTRL 0x04000000UL - -/* flags for MII status */ -#define DEVICE_LINK_FAIL 0x00000001UL -#define DEVICE_SPEED_10 0x00000002UL -#define DEVICE_SPEED_100 0x00000004UL -#define DEVICE_SPEED_1000 0x00000008UL -#define DEVICE_DUPLEX_FULL 0x00000010UL -#define DEVICE_AUTONEG_ENABLE 0x00000020UL -#define DEVICE_FORCED_BY_EEPROM 0x00000040UL -/* for device_set_media_duplex */ -#define DEVICE_LINK_CHANGE 0x00000001UL typedef struct __device_opt { int nRxDescs0; /* number of RX descriptors 0 */ @@ -363,11 +405,10 @@ struct vnt_private { u8 byRxMode; spinlock_t lock; + struct mutex usb_lock; u32 rx_bytes; - u8 byRevId; - u32 flags; unsigned long Flags; @@ -379,9 +420,7 @@ struct vnt_private { u32 uCurrentDFCBIdx; /* USB */ - struct urb *pControlURB; struct urb *pInterruptURB; - struct usb_ctrlrequest sUsbCtlRequest; u32 int_interval; /* Variables to track resources for the BULK In Pipe */ @@ -453,30 +492,6 @@ struct vnt_private { u8 byRadioCtl; u8 bHWRadioOff; - /* SQ3 functions for antenna diversity */ - struct timer_list TimerSQ3Tmax1; - struct timer_list TimerSQ3Tmax2; - struct timer_list TimerSQ3Tmax3; - - int bDiversityRegCtlON; - int bDiversityEnable; - unsigned long ulDiversityNValue; - unsigned long ulDiversityMValue; - u8 byTMax; - u8 byTMax2; - u8 byTMax3; - unsigned long ulSQ3TH; - - unsigned long uDiversityCnt; - u8 byAntennaState; - unsigned long ulRatio_State0; - unsigned long ulRatio_State1; - unsigned long ulSQ3_State0; - unsigned long ulSQ3_State1; - - unsigned long aulSQ3Val[MAX_RATE]; - unsigned long aulPktNum[MAX_RATE]; - /* IFS & Cw */ u32 uSIFS; /* Current SIFS */ u32 uDIFS; /* Current DIFS */ @@ -496,14 +511,9 @@ struct vnt_private { u8 byBBType; /* 0: 11A, 1:11B, 2:11G */ u8 byPacketType; /* 0:11a 1:11b 2:11gb 3:11ga */ u16 wBasicRate; - u8 byACKRate; u8 byTopOFDMBasicRate; u8 byTopCCKBasicRate; - u32 dwAotoRateTxOkCnt; - u32 dwAotoRateTxFailCnt; - u32 dwErrorRateThreshold[13]; - u32 dwTPTable[MAX_RATE]; u8 abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /*u32 alignment */ u8 byMinChannel; @@ -542,7 +552,6 @@ struct vnt_private { u32 dwMaxReceiveLifetime; /* dot11MaxReceiveLifetime */ - int bCCK; int bEncryptionEnable; int bShortSlotTime; int bProtectMode; @@ -569,7 +578,6 @@ struct vnt_private { int bBeaconSent; int bFixRate; u8 byCurrentCh; - u32 uScanTime; CMD_STATE eCommandState; @@ -600,7 +608,6 @@ struct vnt_private { u8 bSameBSSCurNum; int bRoaming; int b11hEable; - unsigned long ulTxPower; /* Encryption */ NDIS_802_11_WEP_STATUS eEncryptionStatus; @@ -629,7 +636,6 @@ struct vnt_private { int bRxMICFail; /* For Update BaseBand VGA Gain Offset */ - int bUpdateBBVGA; u32 uBBVGADiffCount; u8 byBBVGANew; u8 byBBVGACurrent; @@ -641,18 +647,6 @@ struct vnt_private { int bRadioCmd; - /* For FOE Tuning */ - u8 byFOETuning; - - /* For Auto Power Tunning */ - u8 byAutoPwrTunning; - - /* BaseBand Loopback Use */ - u8 byBBCR4d; - u8 byBBCRc9; - u8 byBBCR88; - u8 byBBCR09; - /* command timer */ struct delayed_work run_command_work; /* One second callback */ @@ -689,13 +683,6 @@ struct vnt_private { int bwextstep3; int bWPASuppWextEnabled; - /* user space daemon: hostapd, is used for HOSTAP */ - int bEnableHostapd; - int bEnable8021x; - int bEnableHostWEP; - struct net_device *apdev; - int (*tx_80211)(struct sk_buff *skb, struct net_device *dev); - u32 uChannel; struct iw_statistics wstats; /* wireless stats */ @@ -732,25 +719,15 @@ struct vnt_private { (uVar)++; \ } -#define fMP_RESET_IN_PROGRESS 0x00000001 #define fMP_DISCONNECTED 0x00000002 -#define fMP_HALT_IN_PROGRESS 0x00000004 -#define fMP_SURPRISE_REMOVED 0x00000008 -#define fMP_RECV_LOOKASIDE 0x00000010 -#define fMP_INIT_IN_PROGRESS 0x00000020 -#define fMP_SEND_SIDE_RESOURCE_ALLOCATED 0x00000040 -#define fMP_RECV_SIDE_RESOURCE_ALLOCATED 0x00000080 #define fMP_POST_READS 0x00000100 #define fMP_POST_WRITES 0x00000200 -#define fMP_CONTROL_READS 0x00000400 -#define fMP_CONTROL_WRITES 0x00000800 #define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F)) #define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F)) #define MP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F)) -#define MP_IS_READY(_M) (((_M)->Flags & \ - (fMP_DISCONNECTED | fMP_RESET_IN_PROGRESS | fMP_HALT_IN_PROGRESS | fMP_INIT_IN_PROGRESS | fMP_SURPRISE_REMOVED)) == 0) +#define MP_IS_READY(_M) (((_M)->Flags & fMP_DISCONNECTED) == 0) int device_alloc_frag_buf(struct vnt_private *, PSDeFragControlBlock pDeF); void vnt_configure_filter(struct vnt_private *); diff --git a/drivers/staging/vt6656/device_cfg.h b/drivers/staging/vt6656/device_cfg.h deleted file mode 100644 index 0b9d8349c2e..00000000000 --- a/drivers/staging/vt6656/device_cfg.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: device_cfg.h - * - * Purpose: Driver configuration header - * Author: Lyndon Chen - * - * Date: Dec 9, 2005 - * - */ -#ifndef __DEVICE_CONFIG_H -#define __DEVICE_CONFIG_H - -#include <linux/types.h> - -typedef -struct _version { - unsigned char major; - unsigned char minor; - unsigned char build; -} version_t, *pversion_t; - -#ifndef false -#define false (0) -#endif - -#ifndef true -#define true (!(false)) -#endif - -#define VID_TABLE_SIZE 64 -#define MCAST_TABLE_SIZE 64 -#define MCAM_SIZE 32 -#define VCAM_SIZE 32 -#define TX_QUEUE_NO 8 - -#define DEVICE_NAME "vt6656" -#define DEVICE_FULL_DRV_NAM "VIA Networking Wireless LAN USB Driver" - -#ifndef MAJOR_VERSION -#define MAJOR_VERSION 1 -#endif - -#ifndef MINOR_VERSION -#define MINOR_VERSION 13 -#endif - -#ifndef DEVICE_VERSION -#define DEVICE_VERSION "1.19_12" -#endif - -#define MAX_RATE 12 - -/* config file */ -#include <linux/fs.h> -#include <linux/fcntl.h> -#ifndef CONFIG_PATH -#define CONFIG_PATH "/etc/vntconfiguration.dat" -#endif - -/* Max: 2378 = 2312 Payload + 30HD + 4CRC + 2Padding + 4Len + 8TSF + 4RSR */ -#define PKT_BUF_SZ 2390 - -#define MAX_UINTS 8 -#define OPTION_DEFAULT { [0 ... MAX_UINTS-1] = -1} - -typedef enum _chip_type { - VT3184 = 1 -} CHIP_TYPE, *PCHIP_TYPE; - -#endif diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index 4ccaa7e29a1..c0ec5b37aa7 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -26,10 +26,7 @@ * * Functions: * device_receive_frame - Rcv 802.11 frame function - * s_bAPModeRxCtl- AP Rcv frame filer Ctl. - * s_bAPModeRxData- AP Rcv data frame handle * s_bHandleRxEncryption- Rcv decrypted data via on-fly - * s_bHostWepRxEncryption- Rcv encrypted data via host * s_byGetRateIdx- get rate index * s_vGetDASA- get data offset * s_vProcessRxMACHeader- Rcv 802.11 and translate to 802.3 @@ -48,12 +45,9 @@ #include "baseband.h" #include "michael.h" #include "tkip.h" -#include "tcrc.h" #include "wctl.h" -#include "hostap.h" #include "rf.h" #include "iowpa.h" -#include "aes_ccmp.h" #include "datarate.h" #include "usbpipe.h" @@ -77,20 +71,10 @@ static void s_vProcessRxMACHeader(struct vnt_private *pDevice, u8 *pbyRxBufferAddr, u32 cbPacketSize, int bIsWEP, int bExtIV, u32 *pcbHeadSize); -static int s_bAPModeRxCtl(struct vnt_private *pDevice, u8 *pbyFrame, - s32 iSANodeIndex); - -static int s_bAPModeRxData(struct vnt_private *pDevice, struct sk_buff *skb, - u32 FrameSize, u32 cbHeaderOffset, s32 iSANodeIndex, s32 iDANodeIndex); - static int s_bHandleRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, u32 FrameSize, u8 *pbyRsr, u8 *pbyNewRsr, PSKeyItem *pKeyOut, s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16); -static int s_bHostWepRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, - u32 FrameSize, u8 *pbyRsr, int bOnFly, PSKeyItem pKey, u8 *pbyNewRsr, - s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16); - /*+ * * Description: @@ -261,14 +245,13 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, u32 cbHeaderOffset, cbIVOffset; u32 FrameSize; u16 wEtherType = 0; - s32 iSANodeIndex = -1, iDANodeIndex = -1; + s32 iSANodeIndex = -1; int ii; u8 *pbyRxSts, *pbyRxRate, *pbySQ, *pby3SQ; u32 cbHeaderSize; PSKeyItem pKey = NULL; u16 wRxTSC15_0 = 0; u32 dwRxTSC47_16 = 0; - SKeyItem STempKey; /* signed long ldBm = 0; */ int bIsWEP = false; int bExtIV = false; u32 dwWbkStatus; @@ -390,50 +373,14 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, } } - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - if (s_bAPModeRxCtl(pDevice, pbyFrame, iSANodeIndex) == true) { - return false; - } - } - if (IS_FC_WEP(pbyFrame)) { bool bRxDecryOK = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"rx WEP pkt\n"); bIsWEP = true; - if ((pDevice->bEnableHostWEP) && (iSANodeIndex >= 0)) { - pKey = &STempKey; - pKey->byCipherSuite = pMgmt->sNodeDBTable[iSANodeIndex].byCipherSuite; - pKey->dwKeyIndex = pMgmt->sNodeDBTable[iSANodeIndex].dwKeyIndex; - pKey->uKeyLength = pMgmt->sNodeDBTable[iSANodeIndex].uWepKeyLength; - pKey->dwTSC47_16 = pMgmt->sNodeDBTable[iSANodeIndex].dwTSC47_16; - pKey->wTSC15_0 = pMgmt->sNodeDBTable[iSANodeIndex].wTSC15_0; - memcpy(pKey->abyKey, - &pMgmt->sNodeDBTable[iSANodeIndex].abyWepKey[0], - pKey->uKeyLength - ); - - bRxDecryOK = s_bHostWepRxEncryption(pDevice, - pbyFrame, - FrameSize, - pbyRsr, - pMgmt->sNodeDBTable[iSANodeIndex].bOnFly, - pKey, - pbyNewRsr, - &bExtIV, - &wRxTSC15_0, - &dwRxTSC47_16); - } else { - bRxDecryOK = s_bHandleRxEncryption(pDevice, - pbyFrame, - FrameSize, - pbyRsr, - pbyNewRsr, - &pKey, - &bExtIV, - &wRxTSC15_0, - &dwRxTSC47_16); - } + + bRxDecryOK = s_bHandleRxEncryption(pDevice, pbyFrame, FrameSize, + pbyRsr, pbyNewRsr, &pKey, &bExtIV, &wRxTSC15_0, &dwRxTSC47_16); if (bRxDecryOK) { if ((*pbyNewRsr & NEWRSR_DECRYPTOK) == 0) { @@ -517,22 +464,6 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, } pRxPacket->byRxChannel = (*pbyRxSts) >> 2; - // hostap Deamon handle 802.11 management - if (pDevice->bEnableHostapd) { - skb->dev = pDevice->apdev; - //skb->data += 4; - //skb->tail += 4; - skb->data += 8; - skb->tail += 8; - skb_put(skb, FrameSize); - skb_reset_mac_header(skb); - skb->pkt_type = PACKET_OTHERHOST; - skb->protocol = htons(ETH_P_802_2); - memset(skb->cb, 0, sizeof(skb->cb)); - netif_rx(skb); - return true; - } - // // Insert the RCB in the Recv Mng list // @@ -625,13 +556,6 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, } } - // Now it only supports 802.11g Infrastructure Mode, and support rate must up to 54 Mbps - if (pDevice->bDiversityEnable && (FrameSize>50) && - pDevice->op_mode == NL80211_IFTYPE_STATION && - (pDevice->bLinkPass == true)) { - BBvAntennaDiversity(pDevice, s_byGetRateIdx(*pbyRxRate), 0); - } - // ++++++++ For BaseBand Algorithm +++++++++++++++ pDevice->uCurrRSSI = *pbyRSSI; pDevice->byCurrSQ = *pbySQ; @@ -654,45 +578,6 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, } */ - // ----------------------------------------------- - - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnable8021x == true)){ - u8 abyMacHdr[24]; - - // Only 802.1x packet incoming allowed - if (bIsWEP) - cbIVOffset = 8; - else - cbIVOffset = 0; - wEtherType = (skb->data[cbIVOffset + 8 + 24 + 6] << 8) | - skb->data[cbIVOffset + 8 + 24 + 6 + 1]; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wEtherType = %04x \n", wEtherType); - if (wEtherType == ETH_P_PAE) { - skb->dev = pDevice->apdev; - - if (bIsWEP == true) { - // strip IV header(8) - memcpy(&abyMacHdr[0], (skb->data + 8), 24); - memcpy((skb->data + 8 + cbIVOffset), &abyMacHdr[0], 24); - } - - skb->data += (cbIVOffset + 8); - skb->tail += (cbIVOffset + 8); - skb_put(skb, FrameSize); - skb_reset_mac_header(skb); - skb->pkt_type = PACKET_OTHERHOST; - skb->protocol = htons(ETH_P_802_2); - memset(skb->cb, 0, sizeof(skb->cb)); - netif_rx(skb); - return true; - - } - // check if 802.1x authorized - if (!(pMgmt->sNodeDBTable[iSANodeIndex].dwFlags & WLAN_STA_AUTHORIZED)) - return false; - } - if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) { if (bIsWEP) { FrameSize -= 8; //MIC @@ -827,26 +712,6 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, if (FrameSize < 12) return false; - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - if (s_bAPModeRxData(pDevice, - skb, - FrameSize, - cbHeaderOffset, - iSANodeIndex, - iDANodeIndex - ) == false) { - - if (bDeFragRx) { - if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) { - DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n", - pDevice->dev->name); - } - } - return false; - } - - } - skb->data += cbHeaderOffset; skb->tail += cbHeaderOffset; skb_put(skb, FrameSize); @@ -866,112 +731,6 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, return true; } -static int s_bAPModeRxCtl(struct vnt_private *pDevice, u8 *pbyFrame, - s32 iSANodeIndex) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - struct ieee80211_hdr *p802_11Header; - CMD_STATUS Status; - - if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) { - - p802_11Header = (struct ieee80211_hdr *) (pbyFrame); - if (!IS_TYPE_MGMT(pbyFrame)) { - - // Data & PS-Poll packet - // check frame class - if (iSANodeIndex > 0) { - // frame class 3 fliter & checking - if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_AUTH) { - // send deauth notification - // reason = (6) class 2 received from nonauth sta - vMgrDeAuthenBeginSta(pDevice, - pMgmt, - (u8 *)(p802_11Header->addr2), - (WLAN_MGMT_REASON_CLASS2_NONAUTH), - &Status - ); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDeAuthenBeginSta 1\n"); - return true; - } - if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_ASSOC) { - // send deassoc notification - // reason = (7) class 3 received from nonassoc sta - vMgrDisassocBeginSta(pDevice, - pMgmt, - (u8 *)(p802_11Header->addr2), - (WLAN_MGMT_REASON_CLASS3_NONASSOC), - &Status - ); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDisassocBeginSta 2\n"); - return true; - } - - if (pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable) { - // delcare received ps-poll event - if (IS_CTL_PSPOLL(pbyFrame)) { - pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true; - bScheduleCommand((void *) pDevice, - WLAN_CMD_RX_PSPOLL, - NULL); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: WLAN_CMD_RX_PSPOLL 1\n"); - } - else { - // check Data PS state - // if PW bit off, send out all PS bufferring packets. - if (!IS_FC_POWERMGT(pbyFrame)) { - pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = false; - pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true; - bScheduleCommand((void *) pDevice, - WLAN_CMD_RX_PSPOLL, - NULL); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: WLAN_CMD_RX_PSPOLL 2\n"); - } - } - } - else { - if (IS_FC_POWERMGT(pbyFrame)) { - pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = true; - // Once if STA in PS state, enable multicast bufferring - pMgmt->sNodeDBTable[0].bPSEnable = true; - } - else { - // clear all pending PS frame. - if (pMgmt->sNodeDBTable[iSANodeIndex].wEnQueueCnt > 0) { - pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = false; - pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true; - bScheduleCommand((void *) pDevice, - WLAN_CMD_RX_PSPOLL, - NULL); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: WLAN_CMD_RX_PSPOLL 3\n"); - - } - } - } - } - else { - vMgrDeAuthenBeginSta(pDevice, - pMgmt, - (u8 *)(p802_11Header->addr2), - (WLAN_MGMT_REASON_CLASS2_NONAUTH), - &Status - ); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDeAuthenBeginSta 3\n"); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BSSID:%pM\n", - p802_11Header->addr3); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR2:%pM\n", - p802_11Header->addr2); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR1:%pM\n", - p802_11Header->addr1); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: frame_control= %x\n", p802_11Header->frame_control); - return true; - } - } - } - return false; - -} - static int s_bHandleRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, u32 FrameSize, u8 *pbyRsr, u8 *pbyNewRsr, PSKeyItem *pKeyOut, s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16) @@ -1098,213 +857,20 @@ static int s_bHandleRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, return true; } -static int s_bHostWepRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, - u32 FrameSize, u8 *pbyRsr, int bOnFly, PSKeyItem pKey, u8 *pbyNewRsr, - s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - struct ieee80211_hdr *pMACHeader; - u32 PayloadLen = FrameSize; - u8 *pbyIV; - u8 byKeyIdx; - u8 byDecMode = KEY_CTL_WEP; - - *pwRxTSC15_0 = 0; - *pdwRxTSC47_16 = 0; - - pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN; - if ( WLAN_GET_FC_TODS(*(u16 *)pbyFrame) && - WLAN_GET_FC_FROMDS(*(u16 *)pbyFrame) ) { - pbyIV += 6; // 6 is 802.11 address4 - PayloadLen -= 6; - } - byKeyIdx = (*(pbyIV+3) & 0xc0); - byKeyIdx >>= 6; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\nKeyIdx: %d\n", byKeyIdx); - - if (pMgmt->byCSSGK == KEY_CTL_TKIP) - byDecMode = KEY_CTL_TKIP; - else if (pMgmt->byCSSGK == KEY_CTL_CCMP) - byDecMode = KEY_CTL_CCMP; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"AES:%d %d %d\n", pMgmt->byCSSPK, pMgmt->byCSSGK, byDecMode); - - if (byDecMode != pKey->byCipherSuite) { - return false; - } - - if (byDecMode == KEY_CTL_WEP) { - // handle WEP - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"byDecMode == KEY_CTL_WEP\n"); - if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || - (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == true) || - (bOnFly == false)) { - // Software WEP - // 1. 3253A - // 2. WEP 256 - // 3. NotOnFly - - PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4); // 24 is 802.11 header,4 is IV, 4 is crc - memcpy(pDevice->abyPRNG, pbyIV, 3); - memcpy(pDevice->abyPRNG + 3, pKey->abyKey, pKey->uKeyLength); - rc4_init(&pDevice->SBox, pDevice->abyPRNG, pKey->uKeyLength + 3); - rc4_encrypt(&pDevice->SBox, pbyIV+4, pbyIV+4, PayloadLen); - - if (ETHbIsBufferCrc32Ok(pbyIV+4, PayloadLen)) { - *pbyNewRsr |= NEWRSR_DECRYPTOK; - } - } - } else if ((byDecMode == KEY_CTL_TKIP) || - (byDecMode == KEY_CTL_CCMP)) { - // TKIP/AES - - PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); // 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc - *pdwRxTSC47_16 = cpu_to_le32(*(u32 *)(pbyIV + 4)); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ExtIV: %x\n", *pdwRxTSC47_16); - - if (byDecMode == KEY_CTL_TKIP) { - *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV+2), *pbyIV)); - } else { - *pwRxTSC15_0 = cpu_to_le16(*(u16 *)pbyIV); - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TSC0_15: %x\n", *pwRxTSC15_0); - - if (byDecMode == KEY_CTL_TKIP) { - - if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || (bOnFly == false)) { - // Software TKIP - // 1. 3253 A - // 2. NotOnFly - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"soft KEY_CTL_TKIP \n"); - pMACHeader = (struct ieee80211_hdr *) (pbyFrame); - TKIPvMixKey(pKey->abyKey, pMACHeader->addr2, *pwRxTSC15_0, *pdwRxTSC47_16, pDevice->abyPRNG); - rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN); - rc4_encrypt(&pDevice->SBox, pbyIV+8, pbyIV+8, PayloadLen); - if (ETHbIsBufferCrc32Ok(pbyIV+8, PayloadLen)) { - *pbyNewRsr |= NEWRSR_DECRYPTOK; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV OK!\n"); - } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV FAIL!!!\n"); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PayloadLen = %d\n", PayloadLen); - } - } - } - - if (byDecMode == KEY_CTL_CCMP) { - if (bOnFly == false) { - // Software CCMP - // NotOnFly - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"soft KEY_CTL_CCMP\n"); - if (AESbGenCCMP(pKey->abyKey, pbyFrame, FrameSize)) { - *pbyNewRsr |= NEWRSR_DECRYPTOK; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CCMP MIC compare OK!\n"); - } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CCMP MIC fail!\n"); - } - } - } - - }// end of TKIP/AES - - if ((*(pbyIV+3) & 0x20) != 0) - *pbExtIV = true; - return true; -} - -static int s_bAPModeRxData(struct vnt_private *pDevice, struct sk_buff *skb, - u32 FrameSize, u32 cbHeaderOffset, s32 iSANodeIndex, s32 iDANodeIndex) -{ - struct sk_buff *skbcpy; - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - int bRelayAndForward = false; - int bRelayOnly = false; - u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; - u16 wAID; - - if (FrameSize > CB_MAX_BUF_SIZE) - return false; - // check DA - if (is_multicast_ether_addr((u8 *)(skb->data+cbHeaderOffset))) { - if (pMgmt->sNodeDBTable[0].bPSEnable) { - - skbcpy = netdev_alloc_skb(pDevice->dev, pDevice->rx_buf_sz); - - // if any node in PS mode, buffer packet until DTIM. - if (skbcpy == NULL) { - DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "relay multicast no skb available \n"); - } - else { - skbcpy->len = FrameSize; - memcpy(skbcpy->data, skb->data+cbHeaderOffset, FrameSize); - skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skbcpy); - pMgmt->sNodeDBTable[0].wEnQueueCnt++; - // set tx map - pMgmt->abyPSTxMap[0] |= byMask[0]; - } - } - else { - bRelayAndForward = true; - } - } - else { - // check if relay - if (BSSbIsSTAInNodeDB(pDevice, (u8 *)(skb->data+cbHeaderOffset), &iDANodeIndex)) { - if (pMgmt->sNodeDBTable[iDANodeIndex].eNodeState >= NODE_ASSOC) { - if (pMgmt->sNodeDBTable[iDANodeIndex].bPSEnable) { - // queue this skb until next PS tx, and then release. - - skb->data += cbHeaderOffset; - skb->tail += cbHeaderOffset; - skb_put(skb, FrameSize); - skb_queue_tail(&pMgmt->sNodeDBTable[iDANodeIndex].sTxPSQueue, skb); - - pMgmt->sNodeDBTable[iDANodeIndex].wEnQueueCnt++; - wAID = pMgmt->sNodeDBTable[iDANodeIndex].wAID; - pMgmt->abyPSTxMap[wAID >> 3] |= byMask[wAID & 7]; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "relay: index= %d, pMgmt->abyPSTxMap[%d]= %d\n", - iDANodeIndex, (wAID >> 3), pMgmt->abyPSTxMap[wAID >> 3]); - return true; - } - else { - bRelayOnly = true; - } - } - } - } - - if (bRelayOnly || bRelayAndForward) { - // relay this packet right now - if (bRelayAndForward) - iDANodeIndex = 0; - - if ((pDevice->uAssocCount > 1) && (iDANodeIndex >= 0)) { - bRelayPacketSend(pDevice, (u8 *) (skb->data + cbHeaderOffset), - FrameSize, (unsigned int) iDANodeIndex); - } - - if (bRelayOnly) - return false; - } - // none associate, don't forward - if (pDevice->uAssocCount == 0) - return false; - - return true; -} - void RXvWorkItem(struct work_struct *work) { struct vnt_private *priv = container_of(work, struct vnt_private, read_work_item); int status; struct vnt_rcb *rcb = NULL; + unsigned long flags; if (priv->Flags & fMP_DISCONNECTED) return; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Rx Polling Thread\n"); - spin_lock_irq(&priv->lock); + spin_lock_irqsave(&priv->lock, flags); while ((priv->Flags & fMP_POST_READS) && MP_IS_READY(priv) && (priv->NumRecvFreeList != 0)) { @@ -1319,7 +885,7 @@ void RXvWorkItem(struct work_struct *work) priv->bIsRxWorkItemQueued = false; - spin_unlock_irq(&priv->lock); + spin_unlock_irqrestore(&priv->lock, flags); } void RXvFreeRCB(struct vnt_rcb *rcb, int re_alloc_skb) @@ -1363,34 +929,43 @@ void RXvMngWorkItem(struct work_struct *work) struct vnt_rcb *pRCB = NULL; struct vnt_rx_mgmt *pRxPacket; int bReAllocSkb = false; + unsigned long flags; if (pDevice->Flags & fMP_DISCONNECTED) return; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Rx Mng Thread\n"); - spin_lock_irq(&pDevice->lock); while (pDevice->NumRecvMngList!=0) { + spin_lock_irqsave(&pDevice->lock, flags); + pRCB = pDevice->FirstRecvMngList; pDevice->NumRecvMngList--; DequeueRCB(pDevice->FirstRecvMngList, pDevice->LastRecvMngList); + + spin_unlock_irqrestore(&pDevice->lock, flags); + if(!pRCB){ break; } pRxPacket = &(pRCB->sMngPacket); vMgrRxManagePacket(pDevice, &pDevice->vnt_mgmt, pRxPacket); pRCB->Ref--; - if(pRCB->Ref == 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeMng %d %d\n",pDevice->NumRecvFreeList, pDevice->NumRecvMngList); - RXvFreeRCB(pRCB, bReAllocSkb); - } else { + if (pRCB->Ref == 0) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeMng %d %d\n", + pDevice->NumRecvFreeList, pDevice->NumRecvMngList); + + spin_lock_irqsave(&pDevice->lock, flags); + + RXvFreeRCB(pRCB, bReAllocSkb); + + spin_unlock_irqrestore(&pDevice->lock, flags); + } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Rx Mng Only we have the right to free RCB\n"); } } pDevice->bIsRxMngWorkItemQueued = false; - spin_unlock_irq(&pDevice->lock); - } diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c index cd2ea76c8b1..1159f0b3457 100644 --- a/drivers/staging/vt6656/firmware.c +++ b/drivers/staging/vt6656/firmware.c @@ -31,9 +31,9 @@ * */ +#include <linux/compiler.h> #include "firmware.h" -#include "control.h" -#include "rndis.h" +#include "usbpipe.h" static int msglevel = MSG_LEVEL_INFO; /* static int msglevel = MSG_LEVEL_DEBUG; */ @@ -54,7 +54,6 @@ int FIRMWAREbDownload(struct vnt_private *pDevice) int ii, rc; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Download firmware\n"); - spin_unlock_irq(&pDevice->lock); rc = request_firmware(&fw, FIRMWARE_NAME, dev); if (rc) { @@ -71,7 +70,7 @@ int FIRMWAREbDownload(struct vnt_private *pDevice) wLength = min_t(int, fw->size - ii, FIRMWARE_CHUNK_SIZE); memcpy(pBuffer, fw->data + ii, wLength); - NdisStatus = CONTROLnsRequestOutAsyn(pDevice, + NdisStatus = vnt_control_out(pDevice, 0, 0x1200+ii, 0x0000, @@ -91,7 +90,6 @@ free_fw: out: kfree(pBuffer); - spin_lock_irq(&pDevice->lock); return result; } MODULE_FIRMWARE(FIRMWARE_NAME); @@ -102,7 +100,7 @@ int FIRMWAREbBrach2Sram(struct vnt_private *pDevice) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Branch to Sram\n"); - NdisStatus = CONTROLnsRequestOut(pDevice, + NdisStatus = vnt_control_out(pDevice, 1, 0x1200, 0x0000, @@ -118,7 +116,7 @@ int FIRMWAREbCheckVersion(struct vnt_private *pDevice) { int ntStatus; - ntStatus = CONTROLnsRequestIn(pDevice, + ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_READ, 0, MESSAGE_REQUEST_VERSION, diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c deleted file mode 100644 index 67ba48b9a8d..00000000000 --- a/drivers/staging/vt6656/hostap.c +++ /dev/null @@ -1,779 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: hostap.c - * - * Purpose: handle hostap daemon ioctl input/out functions - * - * Author: Lyndon Chen - * - * Date: Oct. 20, 2003 - * - * Functions: - * - * Revision History: - * - */ - -#include "hostap.h" -#include "iocmd.h" -#include "mac.h" -#include "card.h" -#include "baseband.h" -#include "wpactl.h" -#include "key.h" -#include "datarate.h" - -#define VIAWGET_HOSTAPD_MAX_BUF_SIZE 1024 -#define HOSTAP_CRYPT_FLAG_SET_TX_KEY BIT0 -#define HOSTAP_CRYPT_ERR_UNKNOWN_ADDR 3 -#define HOSTAP_CRYPT_ERR_KEY_SET_FAILED 5 - -static int msglevel =MSG_LEVEL_INFO; - -/* - * Description: - * register net_device (AP) for hostap daemon - * - * Parameters: - * In: - * pDevice - - * rtnl_locked - - * Out: - * - * Return Value: - * - */ - -static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked) -{ - struct vnt_private *apdev_priv; - struct net_device *dev = pDevice->dev; - int ret; - const struct net_device_ops apdev_netdev_ops = { - .ndo_start_xmit = pDevice->tx_80211, - }; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name); - - pDevice->apdev = kzalloc(sizeof(struct net_device), GFP_KERNEL); - if (pDevice->apdev == NULL) - return -ENOMEM; - - apdev_priv = netdev_priv(pDevice->apdev); - *apdev_priv = *pDevice; - memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN); - - pDevice->apdev->netdev_ops = &apdev_netdev_ops; - - pDevice->apdev->type = ARPHRD_IEEE80211; - - pDevice->apdev->base_addr = dev->base_addr; - pDevice->apdev->irq = dev->irq; - pDevice->apdev->mem_start = dev->mem_start; - pDevice->apdev->mem_end = dev->mem_end; - sprintf(pDevice->apdev->name, "%sap", dev->name); - if (rtnl_locked) - ret = register_netdevice(pDevice->apdev); - else - ret = register_netdev(pDevice->apdev); - if (ret) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: register_netdevice(AP) failed!\n", - dev->name); - return -1; - } - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Registered netdevice %s for AP management\n", - dev->name, pDevice->apdev->name); - - KeyvInitTable(pDevice,&pDevice->sKey); - - return 0; -} - -/* - * Description: - * unregister net_device(AP) - * - * Parameters: - * In: - * pDevice - - * rtnl_locked - - * Out: - * - * Return Value: - * - */ - -static int hostap_disable_hostapd(struct vnt_private *pDevice, int rtnl_locked) -{ - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: disabling hostapd mode\n", pDevice->dev->name); - - if (pDevice->apdev && pDevice->apdev->name && pDevice->apdev->name[0]) { - if (rtnl_locked) - unregister_netdevice(pDevice->apdev); - else - unregister_netdev(pDevice->apdev); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Netdevice %s unregistered\n", - pDevice->dev->name, pDevice->apdev->name); - } - if (pDevice->apdev) - free_netdev(pDevice->apdev); - pDevice->apdev = NULL; - pDevice->bEnable8021x = false; - pDevice->bEnableHostWEP = false; - pDevice->bEncryptionEnable = false; - - return 0; -} - -/* - * Description: - * Set enable/disable hostapd mode - * - * Parameters: - * In: - * pDevice - - * rtnl_locked - - * Out: - * - * Return Value: - * - */ - -int vt6656_hostap_set_hostapd(struct vnt_private *pDevice, - int val, int rtnl_locked) -{ - if (val < 0 || val > 1) - return -EINVAL; - - if (pDevice->bEnableHostapd == val) - return 0; - - pDevice->bEnableHostapd = val; - - if (val) - return hostap_enable_hostapd(pDevice, rtnl_locked); - else - return hostap_disable_hostapd(pDevice, rtnl_locked); -} - -/* - * Description: - * remove station function supported for hostap daemon - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_remove_sta(struct vnt_private *pDevice, - struct viawget_hostapd_param *param) -{ - unsigned int uNodeIndex; - - if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) { - BSSvRemoveOneNode(pDevice, uNodeIndex); - } - else { - return -ENOENT; - } - return 0; -} - -/* - * Description: - * add a station from hostap daemon - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_add_sta(struct vnt_private *pDevice, - struct viawget_hostapd_param *param) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - unsigned int uNodeIndex; - - if (!BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) - BSSvCreateOneNode(pDevice, &uNodeIndex); - - memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, param->sta_addr, WLAN_ADDR_LEN); - pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC; - pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = param->u.add_sta.capability; -// TODO listenInterval -// pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = 1; - pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = false; - pMgmt->sNodeDBTable[uNodeIndex].bySuppRate = param->u.add_sta.tx_supp_rates; - - // set max tx rate - pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate = - pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate; - // set max basic rate - pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate = RATE_2M; - // Todo: check sta preamble, if ap can't support, set status code - pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = - WLAN_GET_CAP_INFO_SHORTPREAMBLE(pMgmt->sNodeDBTable[uNodeIndex].wCapInfo); - - pMgmt->sNodeDBTable[uNodeIndex].wAID = (u16)param->u.add_sta.aid; - - pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer = jiffies; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Add STA AID= %d \n", pMgmt->sNodeDBTable[uNodeIndex].wAID); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n", - param->sta_addr[0], - param->sta_addr[1], - param->sta_addr[2], - param->sta_addr[3], - param->sta_addr[4], - param->sta_addr[5] - ) ; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Max Support rate = %d \n", - pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate); - - return 0; -} - -/* - * Description: - * get station info - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ - -static int hostap_get_info_sta(struct vnt_private *pDevice, - struct viawget_hostapd_param *param) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - unsigned int uNodeIndex; - - if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) { - param->u.get_info_sta.inactive_sec = - (jiffies - pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer) / HZ; - - //param->u.get_info_sta.txexc = pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts; - } - else { - return -ENOENT; - } - - return 0; -} - -/* - * Description: - * set station flag - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_set_flags_sta(struct vnt_private *pDevice, - struct viawget_hostapd_param *param) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - unsigned int uNodeIndex; - - if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) { - pMgmt->sNodeDBTable[uNodeIndex].dwFlags |= param->u.set_flags_sta.flags_or; - pMgmt->sNodeDBTable[uNodeIndex].dwFlags &= param->u.set_flags_sta.flags_and; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " dwFlags = %x\n", - (unsigned int) pMgmt->sNodeDBTable[uNodeIndex].dwFlags); - } - else { - return -ENOENT; - } - - return 0; -} - -/* - * Description: - * set generic element (wpa ie) - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_set_generic_element(struct vnt_private *pDevice, - struct viawget_hostapd_param *param) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - - memcpy( pMgmt->abyWPAIE, - param->u.generic_elem.data, - param->u.generic_elem.len - ); - - pMgmt->wWPAIELen = param->u.generic_elem.len; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pMgmt->wWPAIELen = %d\n", pMgmt->wWPAIELen); - - // disable wpa - if (pMgmt->wWPAIELen == 0) { - pMgmt->eAuthenMode = WMAC_AUTH_OPEN; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " No WPAIE, Disable WPA \n"); - } else { - // enable wpa - if ((pMgmt->abyWPAIE[0] == WLAN_EID_RSN_WPA) || - (pMgmt->abyWPAIE[0] == WLAN_EID_RSN)) { - pMgmt->eAuthenMode = WMAC_AUTH_WPANONE; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set WPAIE enable WPA\n"); - } else - return -EINVAL; - } - - return 0; -} - -/* - * Description: - * flush station nodes table. - * - * Parameters: - * In: - * pDevice - - * Out: - * - * Return Value: - * - */ - -static void hostap_flush_sta(struct vnt_private *pDevice) -{ - // reserved node index =0 for multicast node. - BSSvClearNodeDBTable(pDevice, 1); - pDevice->uAssocCount = 0; - - return; -} - -/* - * Description: - * set each stations encryption key - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_set_encryption(struct vnt_private *pDevice, - struct viawget_hostapd_param *param, int param_len) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - u32 dwKeyIndex = 0; - u8 abyKey[MAX_KEY_LEN]; - u8 abySeq[MAX_KEY_LEN]; - NDIS_802_11_KEY_RSC KeyRSC; - u8 byKeyDecMode = KEY_CTL_WEP; - int ret = 0; - s32 iNodeIndex = -1; - int ii; - bool bKeyTableFull = false; - u16 wKeyCtl = 0; - - param->u.crypt.err = 0; - - if (param->u.crypt.alg > WPA_ALG_CCMP) - return -EINVAL; - - if ((param->u.crypt.idx > 3) || (param->u.crypt.key_len > MAX_KEY_LEN)) { - param->u.crypt.err = HOSTAP_CRYPT_ERR_KEY_SET_FAILED; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " HOSTAP_CRYPT_ERR_KEY_SET_FAILED\n"); - return -EINVAL; - } - - if (is_broadcast_ether_addr(param->sta_addr)) { - if (param->u.crypt.idx >= MAX_GROUP_KEY) - return -EINVAL; - iNodeIndex = 0; - - } else { - if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &iNodeIndex) == false) { - param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n"); - return -EINVAL; - } - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " hostap_set_encryption: sta_index %d \n", iNodeIndex); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " hostap_set_encryption: alg %d \n", param->u.crypt.alg); - - if (param->u.crypt.alg == WPA_ALG_NONE) { - - if (pMgmt->sNodeDBTable[iNodeIndex].bOnFly == true) { - if (KeybRemoveKey( pDevice, - &(pDevice->sKey), - param->sta_addr, - pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex - ) == false) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybRemoveKey fail \n"); - } - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = false; - } - pMgmt->sNodeDBTable[iNodeIndex].byKeyIndex = 0; - pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = 0; - pMgmt->sNodeDBTable[iNodeIndex].uWepKeyLength = 0; - pMgmt->sNodeDBTable[iNodeIndex].KeyRSC = 0; - pMgmt->sNodeDBTable[iNodeIndex].dwTSC47_16 = 0; - pMgmt->sNodeDBTable[iNodeIndex].wTSC15_0 = 0; - pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = 0; - memset(&pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0], - 0, - MAX_KEY_LEN - ); - - return ret; - } - - memcpy(abyKey, param->u.crypt.key, param->u.crypt.key_len); - // copy to node key tbl - pMgmt->sNodeDBTable[iNodeIndex].byKeyIndex = param->u.crypt.idx; - pMgmt->sNodeDBTable[iNodeIndex].uWepKeyLength = param->u.crypt.key_len; - memcpy(&pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0], - param->u.crypt.key, - param->u.crypt.key_len - ); - - dwKeyIndex = (u32)(param->u.crypt.idx); - if (param->u.crypt.flags & HOSTAP_CRYPT_FLAG_SET_TX_KEY) { - pDevice->byKeyIndex = (u8)dwKeyIndex; - pDevice->bTransmitKey = true; - dwKeyIndex |= (1 << 31); - } - - if (param->u.crypt.alg == WPA_ALG_WEP) { - - if ((pDevice->bEnable8021x == false) || (iNodeIndex == 0)) { - KeybSetDefaultKey( pDevice, - &(pDevice->sKey), - dwKeyIndex & ~(BIT30 | USE_KEYRSC), - param->u.crypt.key_len, - NULL, - abyKey, - KEY_CTL_WEP - ); - - } else { - // 8021x enable, individual key - dwKeyIndex |= (1 << 30); // set pairwise key - if (KeybSetKey(pDevice, &(pDevice->sKey), - ¶m->sta_addr[0], - dwKeyIndex & ~(USE_KEYRSC), - param->u.crypt.key_len, - &KeyRSC, (u8 *)abyKey, - KEY_CTL_WEP - ) == true) { - - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = true; - - } else { - // Key Table Full - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = false; - bKeyTableFull = true; - } - } - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - pDevice->bEncryptionEnable = true; - pMgmt->byCSSPK = KEY_CTL_WEP; - pMgmt->byCSSGK = KEY_CTL_WEP; - pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = KEY_CTL_WEP; - pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = dwKeyIndex; - return ret; - } - - if (param->u.crypt.seq) { - memcpy(&abySeq, param->u.crypt.seq, 8); - for (ii = 0 ; ii < 8 ; ii++) - KeyRSC |= (unsigned long)abySeq[ii] << (ii * 8); - - dwKeyIndex |= 1 << 29; - pMgmt->sNodeDBTable[iNodeIndex].KeyRSC = KeyRSC; - } - - if (param->u.crypt.alg == WPA_ALG_TKIP) { - if (param->u.crypt.key_len != MAX_KEY_LEN) - return -EINVAL; - pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; - byKeyDecMode = KEY_CTL_TKIP; - pMgmt->byCSSPK = KEY_CTL_TKIP; - pMgmt->byCSSGK = KEY_CTL_TKIP; - } - - if (param->u.crypt.alg == WPA_ALG_CCMP) { - if ((param->u.crypt.key_len != AES_KEY_LEN) || - (pDevice->byLocalID <= REV_ID_VT3253_A1)) - return -EINVAL; - pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; - byKeyDecMode = KEY_CTL_CCMP; - pMgmt->byCSSPK = KEY_CTL_CCMP; - pMgmt->byCSSGK = KEY_CTL_CCMP; - } - - if (iNodeIndex == 0) { - KeybSetDefaultKey( pDevice, - &(pDevice->sKey), - dwKeyIndex, - param->u.crypt.key_len, - &KeyRSC, - abyKey, - byKeyDecMode - ); - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = true; - - } else { - dwKeyIndex |= (1 << 30); // set pairwise key - if (KeybSetKey(pDevice, - &(pDevice->sKey), - ¶m->sta_addr[0], - dwKeyIndex, - param->u.crypt.key_len, - &KeyRSC, - (u8 *)abyKey, - byKeyDecMode - ) == true) { - - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = true; - - } else { - // Key Table Full - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = false; - bKeyTableFull = true; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Key Table Full\n"); - } - - } - - if (bKeyTableFull == true) { - wKeyCtl &= 0x7F00; // clear all key control filed - wKeyCtl |= (byKeyDecMode << 4); - wKeyCtl |= (byKeyDecMode); - wKeyCtl |= 0x0044; // use group key for all address - wKeyCtl |= 0x4000; // disable KeyTable[MAX_KEY_TABLE-1] on-fly to genernate rx int -// Todo.. xxxxxx - //MACvSetDefaultKeyCtl(pDevice->PortOffset, wKeyCtl, MAX_KEY_TABLE-1, pDevice->byLocalID); - } - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set key sta_index= %d \n", iNodeIndex); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " tx_index=%d len=%d \n", param->u.crypt.idx, - param->u.crypt.key_len ); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " key=%x-%x-%x-%x-%x-xxxxx \n", - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[1], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[2], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[3], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[4] - ); - - // set wep key - pDevice->bEncryptionEnable = true; - pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = byKeyDecMode; - pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = dwKeyIndex; - pMgmt->sNodeDBTable[iNodeIndex].dwTSC47_16 = 0; - pMgmt->sNodeDBTable[iNodeIndex].wTSC15_0 = 0; - - return ret; -} - -/* - * Description: - * get each stations encryption key - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_get_encryption(struct vnt_private *pDevice, - struct viawget_hostapd_param *param, - int param_len) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - int ret = 0; - int ii; - s32 iNodeIndex = 0; - - param->u.crypt.err = 0; - - if (is_broadcast_ether_addr(param->sta_addr)) { - iNodeIndex = 0; - } else { - if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &iNodeIndex) == false) { - param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "hostap_get_encryption: HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n"); - return -EINVAL; - } - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "hostap_get_encryption: %d\n", iNodeIndex); - memset(param->u.crypt.seq, 0, 8); - for (ii = 0 ; ii < 8 ; ii++) { - param->u.crypt.seq[ii] = (u8)pMgmt->sNodeDBTable[iNodeIndex].KeyRSC >> (ii * 8); - } - - return ret; -} - -/* - * Description: - * vt6656_hostap_ioctl main function supported for hostap daemon. - * - * Parameters: - * In: - * pDevice - - * iw_point - - * Out: - * - * Return Value: - * - */ - -int vt6656_hostap_ioctl(struct vnt_private *pDevice, struct iw_point *p) -{ - struct viawget_hostapd_param *param; - int ret = 0; - int ap_ioctl = 0; - - if (p->length < sizeof(struct viawget_hostapd_param) || - p->length > VIAWGET_HOSTAPD_MAX_BUF_SIZE || !p->pointer) - return -EINVAL; - - param = kmalloc((int)p->length, GFP_KERNEL); - if (param == NULL) - return -ENOMEM; - - if (copy_from_user(param, p->pointer, p->length)) { - ret = -EFAULT; - goto out; - } - - switch (param->cmd) { - case VIAWGET_HOSTAPD_SET_ENCRYPTION: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_ENCRYPTION \n"); - spin_lock_irq(&pDevice->lock); - ret = hostap_set_encryption(pDevice, param, p->length); - spin_unlock_irq(&pDevice->lock); - break; - case VIAWGET_HOSTAPD_GET_ENCRYPTION: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_GET_ENCRYPTION \n"); - spin_lock_irq(&pDevice->lock); - ret = hostap_get_encryption(pDevice, param, p->length); - spin_unlock_irq(&pDevice->lock); - break; - case VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR \n"); - ret = -EOPNOTSUPP; - goto out; - case VIAWGET_HOSTAPD_FLUSH: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_FLUSH \n"); - spin_lock_irq(&pDevice->lock); - hostap_flush_sta(pDevice); - spin_unlock_irq(&pDevice->lock); - break; - case VIAWGET_HOSTAPD_ADD_STA: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_ADD_STA \n"); - spin_lock_irq(&pDevice->lock); - ret = hostap_add_sta(pDevice, param); - spin_unlock_irq(&pDevice->lock); - break; - case VIAWGET_HOSTAPD_REMOVE_STA: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_REMOVE_STA \n"); - spin_lock_irq(&pDevice->lock); - ret = hostap_remove_sta(pDevice, param); - spin_unlock_irq(&pDevice->lock); - break; - case VIAWGET_HOSTAPD_GET_INFO_STA: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_GET_INFO_STA \n"); - ret = hostap_get_info_sta(pDevice, param); - ap_ioctl = 1; - break; - case VIAWGET_HOSTAPD_SET_FLAGS_STA: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_FLAGS_STA \n"); - ret = hostap_set_flags_sta(pDevice, param); - break; - - case VIAWGET_HOSTAPD_MLME: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_MLME \n"); - return -EOPNOTSUPP; - - case VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT \n"); - ret = hostap_set_generic_element(pDevice, param); - break; - - case VIAWGET_HOSTAPD_SCAN_REQ: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SCAN_REQ \n"); - return -EOPNOTSUPP; - - case VIAWGET_HOSTAPD_STA_CLEAR_STATS: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_STA_CLEAR_STATS \n"); - ret = -EOPNOTSUPP; - goto out; - default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "vt6656_hostap_ioctl: unknown cmd=%d\n", - (int)param->cmd); - ret = -EOPNOTSUPP; - goto out; - } - - if ((ret == 0) && ap_ioctl) { - if (copy_to_user(p->pointer, param, p->length)) { - ret = -EFAULT; - goto out; - } - } - - out: - kfree(param); - - return ret; -} - diff --git a/drivers/staging/vt6656/hostap.h b/drivers/staging/vt6656/hostap.h deleted file mode 100644 index 6a68f7e69cf..00000000000 --- a/drivers/staging/vt6656/hostap.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: hostap.h - * - * Purpose: - * - * Author: Lyndon Chen - * - * Date: May 21, 2003 - * - */ - -#ifndef __HOSTAP_H__ -#define __HOSTAP_H__ - -#include "device.h" - -#define WLAN_RATE_1M BIT0 -#define WLAN_RATE_2M BIT1 -#define WLAN_RATE_5M5 BIT2 -#define WLAN_RATE_11M BIT3 -#define WLAN_RATE_6M BIT4 -#define WLAN_RATE_9M BIT5 -#define WLAN_RATE_12M BIT6 -#define WLAN_RATE_18M BIT7 -#define WLAN_RATE_24M BIT8 -#define WLAN_RATE_36M BIT9 -#define WLAN_RATE_48M BIT10 -#define WLAN_RATE_54M BIT11 - -#ifndef ETH_P_PAE -#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ -#endif /* ETH_P_PAE */ - -#ifndef ARPHRD_IEEE80211 -#define ARPHRD_IEEE80211 801 -#endif - -int vt6656_hostap_set_hostapd(struct vnt_private *, int val, int rtnl_locked); -int vt6656_hostap_ioctl(struct vnt_private *, struct iw_point *p); - -#endif /* __HOSTAP_H__ */ diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c index cca56b2f243..f2a5225b50f 100644 --- a/drivers/staging/vt6656/int.c +++ b/drivers/staging/vt6656/int.c @@ -65,15 +65,16 @@ static int msglevel = MSG_LEVEL_INFO; /* MSG_LEVEL_DEBUG */ -*/ void INTvWorkItem(struct vnt_private *pDevice) { + unsigned long flags; int ntStatus; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n"); - spin_lock_irq(&pDevice->lock); + spin_lock_irqsave(&pDevice->lock, flags); ntStatus = PIPEnsInterruptRead(pDevice); - spin_unlock_irq(&pDevice->lock); + spin_unlock_irqrestore(&pDevice->lock, flags); } void INTnsProcessData(struct vnt_private *priv) diff --git a/drivers/staging/vt6656/iocmd.h b/drivers/staging/vt6656/iocmd.h index f3406da7336..b957e6d475a 100644 --- a/drivers/staging/vt6656/iocmd.h +++ b/drivers/staging/vt6656/iocmd.h @@ -29,397 +29,10 @@ #ifndef __IOCMD_H__ #define __IOCMD_H__ -// ioctl Command code -#define MAGIC_CODE 0x3142 -#define IOCTL_CMD_TEST (SIOCDEVPRIVATE + 0) -#define IOCTL_CMD_SET (SIOCDEVPRIVATE + 1) -#define IOCTL_CMD_HOSTAPD (SIOCDEVPRIVATE + 2) -#define IOCTL_CMD_WPA (SIOCDEVPRIVATE + 3) - -typedef enum tagWMAC_CMD { - - WLAN_CMD_BSS_SCAN, - WLAN_CMD_BSS_JOIN, - WLAN_CMD_DISASSOC, - WLAN_CMD_SET_WEP, - WLAN_CMD_GET_LINK, - WLAN_CMD_GET_LISTLEN, - WLAN_CMD_GET_LIST, - WLAN_CMD_GET_MIB, - WLAN_CMD_GET_STAT, - WLAN_CMD_STOP_MAC, - WLAN_CMD_START_MAC, - WLAN_CMD_AP_START, - WLAN_CMD_SET_HOSTAPD, - WLAN_CMD_SET_HOSTAPD_STA, - WLAN_CMD_SET_802_1X, - WLAN_CMD_SET_HOST_WEP, - WLAN_CMD_SET_WPA, - WLAN_CMD_GET_NODE_CNT, - WLAN_CMD_ZONETYPE_SET, - WLAN_CMD_GET_NODE_LIST - -} WMAC_CMD, *PWMAC_CMD; - typedef enum tagWZONETYPE { ZoneType_USA = 0, ZoneType_Japan = 1, ZoneType_Europe = 2 } WZONETYPE; -#define ADHOC 0 -#define INFRA 1 -#define BOTH 2 -#define AP 3 - -#define ADHOC_STARTED 1 -#define ADHOC_JOINTED 2 - -#define PHY80211a 0 -#define PHY80211b 1 -#define PHY80211g 2 - -#define SSID_ID 0 -#define SSID_MAXLEN 32 -#define BSSID_LEN 6 -#define WEP_NKEYS 4 -#define WEP_KEYMAXLEN 29 -#define WEP_40BIT_LEN 5 -#define WEP_104BIT_LEN 13 -#define WEP_232BIT_LEN 16 - -// Ioctl interface structure -// Command structure -// -typedef struct tagSCmdRequest { - u8 name[16]; - void *data; - u16 wResult; - u16 wCmdCode; -} __packed SCmdRequest, *PSCmdRequest; - -// -// Scan -// - -typedef struct tagSCmdScan { - - u8 ssid[SSID_MAXLEN + 2]; - -} __packed SCmdScan, *PSCmdScan; - -// -// BSS Join -// - -typedef struct tagSCmdBSSJoin { - - u16 wBSSType; - u16 wBBPType; - u8 ssid[SSID_MAXLEN + 2]; - u32 uChannel; - bool bPSEnable; - bool bShareKeyAuth; - -} __packed SCmdBSSJoin, *PSCmdBSSJoin; - -// -// Zonetype Setting -// - -typedef struct tagSCmdZoneTypeSet { - - bool bWrite; - WZONETYPE ZoneType; - -} __packed SCmdZoneTypeSet, *PSCmdZoneTypeSet; - -typedef struct tagSWPAResult { - char ifname[100]; - u8 proto; - u8 key_mgmt; - u8 eap_type; - bool authenticated; -} __packed SWPAResult, *PSWPAResult; - -typedef struct tagSCmdStartAP { - - u16 wBSSType; - u16 wBBPType; - u8 ssid[SSID_MAXLEN + 2]; - u32 uChannel; - u32 uBeaconInt; - bool bShareKeyAuth; - u8 byBasicRate; - -} __packed SCmdStartAP, *PSCmdStartAP; - -typedef struct tagSCmdSetWEP { - - bool bEnableWep; - u8 byKeyIndex; - u8 abyWepKey[WEP_NKEYS][WEP_KEYMAXLEN]; - bool bWepKeyAvailable[WEP_NKEYS]; - u32 auWepKeyLength[WEP_NKEYS]; - -} __packed SCmdSetWEP, *PSCmdSetWEP; - -typedef struct tagSBSSIDItem { - - u32 uChannel; - u8 abyBSSID[BSSID_LEN]; - u8 abySSID[SSID_MAXLEN + 1]; - u16 wBeaconInterval; - u16 wCapInfo; - u8 byNetType; - bool bWEPOn; - u32 uRSSI; - -} __packed SBSSIDItem; - -typedef struct tagSBSSIDList { - - u32 uItem; - SBSSIDItem sBSSIDList[0]; -} __packed SBSSIDList, *PSBSSIDList; - -typedef struct tagSNodeItem { - // STA info - u16 wAID; - u8 abyMACAddr[6]; - u16 wTxDataRate; - u16 wInActiveCount; - u16 wEnQueueCnt; - u16 wFlags; - bool bPWBitOn; - u8 byKeyIndex; - u16 wWepKeyLength; - u8 abyWepKey[WEP_KEYMAXLEN]; - // Auto rate fallback vars - bool bIsInFallback; - u32 uTxFailures; - u32 uTxAttempts; - u16 wFailureRatio; - -} __packed SNodeItem; - -typedef struct tagSNodeList { - - u32 uItem; - SNodeItem sNodeList[0]; - -} __packed SNodeList, *PSNodeList; - -typedef struct tagSCmdLinkStatus { - - bool bLink; - u16 wBSSType; - u8 byState; - u8 abyBSSID[BSSID_LEN]; - u8 abySSID[SSID_MAXLEN + 2]; - u32 uChannel; - u32 uLinkRate; - -} __packed SCmdLinkStatus, *PSCmdLinkStatus; - -// -// 802.11 counter -// -typedef struct tagSDot11MIBCount { - u32 TransmittedFragmentCount; - u32 MulticastTransmittedFrameCount; - u32 FailedCount; - u32 RetryCount; - u32 MultipleRetryCount; - u32 RTSSuccessCount; - u32 RTSFailureCount; - u32 ACKFailureCount; - u32 FrameDuplicateCount; - u32 ReceivedFragmentCount; - u32 MulticastReceivedFrameCount; - u32 FCSErrorCount; -} __packed SDot11MIBCount, *PSDot11MIBCount; - -// -// statistic counter -// -typedef struct tagSStatMIBCount { - // - // ISR status count - // - u32 dwIsrTx0OK; - u32 dwIsrTx1OK; - u32 dwIsrBeaconTxOK; - u32 dwIsrRxOK; - u32 dwIsrTBTTInt; - u32 dwIsrSTIMERInt; - u32 dwIsrUnrecoverableError; - u32 dwIsrSoftInterrupt; - u32 dwIsrRxNoBuf; - ///////////////////////////////////// - - u32 dwIsrUnknown; /* unknown interrupt count */ - - // RSR status count - // - u32 dwRsrFrmAlgnErr; - u32 dwRsrErr; - u32 dwRsrCRCErr; - u32 dwRsrCRCOk; - u32 dwRsrBSSIDOk; - u32 dwRsrADDROk; - u32 dwRsrICVOk; - u32 dwNewRsrShortPreamble; - u32 dwRsrLong; - u32 dwRsrRunt; - - u32 dwRsrRxControl; - u32 dwRsrRxData; - u32 dwRsrRxManage; - - u32 dwRsrRxPacket; - u32 dwRsrRxOctet; - u32 dwRsrBroadcast; - u32 dwRsrMulticast; - u32 dwRsrDirected; - // 64-bit OID - u32 ullRsrOK; - - // for some optional OIDs (64 bits) and DMI support - u32 ullRxBroadcastBytes; - u32 ullRxMulticastBytes; - u32 ullRxDirectedBytes; - u32 ullRxBroadcastFrames; - u32 ullRxMulticastFrames; - u32 ullRxDirectedFrames; - - u32 dwRsrRxFragment; - u32 dwRsrRxFrmLen64; - u32 dwRsrRxFrmLen65_127; - u32 dwRsrRxFrmLen128_255; - u32 dwRsrRxFrmLen256_511; - u32 dwRsrRxFrmLen512_1023; - u32 dwRsrRxFrmLen1024_1518; - - // TSR0,1 status count - // - u32 dwTsrTotalRetry[2]; /* total collision retry count */ - u32 dwTsrOnceRetry[2]; /* this packet had one collision */ - u32 dwTsrMoreThanOnceRetry[2]; /* this packet had many collisions */ - u32 dwTsrRetry[2]; /* this packet has ever occur collision, - * that is (dwTsrOnceCollision0 plus - * dwTsrMoreThanOnceCollision0) */ - u32 dwTsrACKData[2]; - u32 dwTsrErr[2]; - u32 dwAllTsrOK[2]; - u32 dwTsrRetryTimeout[2]; - u32 dwTsrTransmitTimeout[2]; - - u32 dwTsrTxPacket[2]; - u32 dwTsrTxOctet[2]; - u32 dwTsrBroadcast[2]; - u32 dwTsrMulticast[2]; - u32 dwTsrDirected[2]; - - // RD/TD count - u32 dwCntRxFrmLength; - u32 dwCntTxBufLength; - - u8 abyCntRxPattern[16]; - u8 abyCntTxPattern[16]; - - /* Software check.... */ - u32 dwCntRxDataErr; /* rx buffer data CRC err count */ - u32 dwCntDecryptErr; /* rx buffer data CRC err count */ - u32 dwCntRxICVErr; /* rx buffer data CRC err count */ - u32 idxRxErrorDesc; /* index for rx data error RD */ - - /* 64-bit OID */ - u32 ullTsrOK[2]; - - // for some optional OIDs (64 bits) and DMI support - u32 ullTxBroadcastFrames[2]; - u32 ullTxMulticastFrames[2]; - u32 ullTxDirectedFrames[2]; - u32 ullTxBroadcastBytes[2]; - u32 ullTxMulticastBytes[2]; - u32 ullTxDirectedBytes[2]; -} __packed SStatMIBCount, *PSStatMIBCount; - -typedef struct tagSCmdValue { - - u32 dwValue; - -} __packed SCmdValue, *PSCmdValue; - -// -// hostapd & viawget ioctl related -// - -// VIAGWET_IOCTL_HOSTAPD ioctl() cmd: -enum { - VIAWGET_HOSTAPD_FLUSH = 1, - VIAWGET_HOSTAPD_ADD_STA = 2, - VIAWGET_HOSTAPD_REMOVE_STA = 3, - VIAWGET_HOSTAPD_GET_INFO_STA = 4, - VIAWGET_HOSTAPD_SET_ENCRYPTION = 5, - VIAWGET_HOSTAPD_GET_ENCRYPTION = 6, - VIAWGET_HOSTAPD_SET_FLAGS_STA = 7, - VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR = 8, - VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT = 9, - VIAWGET_HOSTAPD_MLME = 10, - VIAWGET_HOSTAPD_SCAN_REQ = 11, - VIAWGET_HOSTAPD_STA_CLEAR_STATS = 12, -}; - -#define VIAWGET_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \ -((int) (&((struct viawget_hostapd_param *) 0)->u.generic_elem.data)) - -// Maximum length for algorithm names (-1 for nul termination) used in ioctl() - -struct viawget_hostapd_param { - u32 cmd; - u8 sta_addr[6]; - union { - struct { - u16 aid; - u16 capability; - u8 tx_supp_rates; - } add_sta; - struct { - u32 inactive_sec; - } get_info_sta; - struct { - u8 alg; - u32 flags; - u32 err; - u8 idx; - u8 seq[8]; - u16 key_len; - u8 key[0]; - } crypt; - struct { - u32 flags_and; - u32 flags_or; - } set_flags_sta; - struct { - u16 rid; - u16 len; - u8 data[0]; - } rid; - struct { - u8 len; - u8 data[0]; - } generic_elem; - struct { - u16 cmd; - u16 reason_code; - } mlme; - struct { - u8 ssid_len; - u8 ssid[32]; - } scan_req; - } u; -} __packed; - #endif /* __IOCMD_H__ */ diff --git a/drivers/staging/vt6656/iowpa.h b/drivers/staging/vt6656/iowpa.h index 97af32e1fa4..98f2b2195af 100644 --- a/drivers/staging/vt6656/iowpa.h +++ b/drivers/staging/vt6656/iowpa.h @@ -31,43 +31,6 @@ #define WPA_IE_LEN 64 -//WPA related -/* -typedef enum { WPA_ALG_NONE, WPA_ALG_WEP, WPA_ALG_TKIP, WPA_ALG_CCMP } wpa_alg; -typedef enum { CIPHER_NONE, CIPHER_WEP40, CIPHER_TKIP, CIPHER_CCMP, - CIPHER_WEP104 } wpa_cipher; -typedef enum { KEY_MGMT_802_1X, KEY_MGMT_PSK, KEY_MGMT_NONE, - KEY_MGMT_802_1X_NO_WPA, KEY_MGMT_WPA_NONE } wpa_key_mgmt; -*/ - -enum { - VIAWGET_SET_WPA = 1, - VIAWGET_SET_KEY = 2, - VIAWGET_SET_SCAN = 3, - VIAWGET_GET_SCAN = 4, - VIAWGET_GET_SSID = 5, - VIAWGET_GET_BSSID = 6, - VIAWGET_SET_DROP_UNENCRYPT = 7, - VIAWGET_SET_DEAUTHENTICATE = 8, - VIAWGET_SET_ASSOCIATE = 9, - VIAWGET_SET_DISASSOCIATE = 10 -}; - -enum { - VIAWGET_ASSOC_MSG = 1, - VIAWGET_DISASSOC_MSG = 2, - VIAWGET_PTK_MIC_MSG = 3, - VIAWGET_GTK_MIC_MSG = 4, - VIAWGET_CCKM_ROAM_MSG = 5, - VIAWGET_DEVICECLOSE_MSG = 6 -}; - -typedef struct viawget_wpa_header { - u8 type; - u16 req_ie_len; - u16 resp_ie_len; -} __packed viawget_wpa_header; - struct viawget_wpa_param { u32 cmd; u8 addr[6]; @@ -109,20 +72,4 @@ struct viawget_wpa_param { } u; } __packed; -struct viawget_scan_result { - u8 bssid[6]; - u8 ssid[32]; - u16 ssid_len; - u8 wpa_ie[WPA_IE_LEN]; - u16 wpa_ie_len; - u8 rsn_ie[WPA_IE_LEN]; - u16 rsn_ie_len; - int freq; // MHz - int caps; // e.g. privacy - int qual; // signal quality - int noise; - int level; - int maxrate; -} __packed; - #endif /* __IOWPA_H__ */ diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index cf4c06a4288..c43718d788c 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -34,13 +34,11 @@ #include "iwctl.h" #include "mac.h" #include "card.h" -#include "hostap.h" #include "power.h" #include "rf.h" #include "iowpa.h" #include "wpactl.h" -#include "control.h" -#include "rndis.h" +#include "usbpipe.h" #include "baseband.h" static const long frequency_list[] = { @@ -59,7 +57,7 @@ struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev) long ldBm; pDevice->wstats.status = pDevice->op_mode; - RFvRSSITodBm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); + vnt_rf_rssi_to_dbm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); pDevice->wstats.qual.level = ldBm; pDevice->wstats.qual.noise = 0; pDevice->wstats.qual.updated = 1; @@ -93,6 +91,7 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, struct iw_scan_req *req = (struct iw_scan_req *)extra; u8 abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; PWLAN_IE_SSID pItemSSID = NULL; + unsigned long flags; if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) return -EINVAL; @@ -117,7 +116,7 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, return 0; } - spin_lock_irq(&pDevice->lock); + spin_lock_irqsave(&pDevice->lock, flags); BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); @@ -138,7 +137,8 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n", ((PWLAN_IE_SSID)abyScanSSID)->abySSID, ((PWLAN_IE_SSID)abyScanSSID)->len); bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID); - spin_unlock_irq(&pDevice->lock); + + spin_unlock_irqrestore(&pDevice->lock, flags); return 0; } else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) { // passive scan @@ -150,7 +150,8 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, pMgmt->eScanType = WMAC_SCAN_PASSIVE; bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL); - spin_unlock_irq(&pDevice->lock); + + spin_unlock_irqrestore(&pDevice->lock, flags); return 0; } @@ -234,7 +235,7 @@ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info, // ADD quality memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVQUAL; - RFvRSSITodBm(pDevice, (u8)(pBSS->uRSSI), &ldBm); + vnt_rf_rssi_to_dbm(pDevice, (u8)(pBSS->uRSSI), &ldBm); iwe.u.qual.level = ldBm; iwe.u.qual.noise = 0; @@ -377,6 +378,7 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, struct vnt_private *pDevice = netdev_priv(dev); __u32 *wmode = &wrqu->mode; struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + unsigned long flags; int rc = 0; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE\n"); @@ -384,12 +386,6 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, if (pMgmt == NULL) return -EFAULT; - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Can't set operation mode, hostapd is running\n"); - return rc; - } - switch (*wmode) { case IW_MODE_ADHOC: if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) { @@ -409,19 +405,9 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure\n"); break; case IW_MODE_MASTER: - - pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; rc = -EOPNOTSUPP; break; - if (pMgmt->eConfigMode != WMAC_CONFIG_AP) { - pMgmt->eConfigMode = WMAC_CONFIG_AP; - if (pDevice->flags & DEVICE_FLAGS_OPENED) - pDevice->bCommit = true; - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point\n"); - break; - case IW_MODE_REPEAT: pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; rc = -EOPNOTSUPP; @@ -433,16 +419,17 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, if (pDevice->bCommit) { if (pMgmt->eConfigMode == WMAC_CONFIG_AP) { netif_stop_queue(pDevice->dev); - spin_lock_irq(&pDevice->lock); + + spin_lock_irqsave(&pDevice->lock, flags); + bScheduleCommand((void *) pDevice, WLAN_CMD_RUN_AP, NULL); - spin_unlock_irq(&pDevice->lock); + + spin_unlock_irqrestore(&pDevice->lock, flags); } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Commit the settings\n"); - spin_lock_irq(&pDevice->lock); - if (pDevice->bLinkPass && memcmp(pMgmt->abyCurrSSID, pMgmt->abyDesireSSID, @@ -455,9 +442,7 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, memset(pMgmt->abyCurrBSSID, 0, 6); } - ControlvMaskByte(pDevice, - MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, - LEDSTS_STS, LEDSTS_SLOW); + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW); netif_stop_queue(pDevice->dev); @@ -471,8 +456,6 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL); - - spin_unlock_irq(&pDevice->lock); } pDevice->bCommit = false; } @@ -1172,7 +1155,7 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrq = &wrqu->encoding; u32 dwKeyIndex = (u32)(wrq->flags & IW_ENCODE_INDEX); int ii; - int uu; + u8 uu; int rc = 0; int index = (wrq->flags & IW_ENCODE_INDEX); @@ -1212,14 +1195,12 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]); if (pDevice->flags & DEVICE_FLAGS_OPENED) { - spin_lock_irq(&pDevice->lock); KeybSetDefaultKey(pDevice, &(pDevice->sKey), dwKeyIndex | (1 << 31), wrq->length, NULL, pDevice->abyKey, KEY_CTL_WEP); - spin_unlock_irq(&pDevice->lock); } pDevice->byKeyIndex = (u8)dwKeyIndex; pDevice->uKeyLength = wrq->length; @@ -1242,10 +1223,8 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, pDevice->bEncryptionEnable = false; pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; if (pDevice->flags & DEVICE_FLAGS_OPENED) { - spin_lock_irq(&pDevice->lock); for (uu = 0; uu < MAX_KEY_TABLE; uu++) MACvDisableKeyEntry(pDevice, uu); - spin_unlock_irq(&pDevice->lock); } } if (wrq->flags & IW_ENCODE_RESTRICTED) { @@ -1342,12 +1321,9 @@ int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info, return rc; } - spin_lock_irq(&pDevice->lock); - if (wrq->disabled) { pDevice->ePSMode = WMAC_POWER_CAM; PSvDisablePowerSaving(pDevice); - spin_unlock_irq(&pDevice->lock); return rc; } if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { @@ -1359,8 +1335,6 @@ int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info, PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval); } - spin_unlock_irq(&pDevice->lock); - switch (wrq->flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R\n"); @@ -1425,7 +1399,7 @@ int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS\n"); if (pDevice->bLinkPass == true) { - RFvRSSITodBm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); + vnt_rf_rssi_to_dbm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); wrq->value = ldBm; } else { wrq->value = 0; @@ -1723,9 +1697,7 @@ int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info, KeyvInitTable(pDevice, &pDevice->sKey); } /*******/ - spin_lock_irq(&pDevice->lock); ret = wpa_set_keys(pDevice, param); - spin_unlock_irq(&pDevice->lock); error: kfree(buf); diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c index be92c048a12..38ea67531d9 100644 --- a/drivers/staging/vt6656/key.c +++ b/drivers/staging/vt6656/key.c @@ -39,8 +39,7 @@ #include "mac.h" #include "tmacro.h" #include "key.h" -#include "rndis.h" -#include "control.h" +#include "usbpipe.h" static int msglevel =MSG_LEVEL_INFO; //static int msglevel =MSG_LEVEL_DEBUG; @@ -68,15 +67,10 @@ static void s_vCheckKeyTableValid(struct vnt_private *pDevice, //MACvDisableKeyEntry(pDevice, i); } } - if ( wLength != 0 ) { - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_CLRKEYENTRY, - 0, - 0, - wLength, - pbyData - ); - } + + if (wLength != 0) + vnt_control_out(pDevice, MESSAGE_TYPE_CLRKEYENTRY, + 0, 0, wLength, pbyData); } @@ -97,7 +91,6 @@ void KeyvInitTable(struct vnt_private *pDevice, PSKeyManagement pTable) int i, jj; u8 pbyData[MAX_KEY_TABLE+1]; - spin_lock_irq(&pDevice->lock); for (i=0;i<MAX_KEY_TABLE;i++) { pTable->KeyTable[i].bInUse = false; pTable->KeyTable[i].PairwiseKey.bKeyValid = false; @@ -114,15 +107,9 @@ void KeyvInitTable(struct vnt_private *pDevice, PSKeyManagement pTable) pbyData[i] = (u8) i; } pbyData[i] = (u8) i; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_CLRKEYENTRY, - 0, - 0, - 11, - pbyData - ); - spin_unlock_irq(&pDevice->lock); + vnt_control_out(pDevice, MESSAGE_TYPE_CLRKEYENTRY, + 0, 0, 11, pbyData); return; } @@ -251,7 +238,9 @@ int KeybSetKey(struct vnt_private *pDevice, PSKeyManagement pTable, if (uKeyLength == WLAN_WEP104_KEYLEN) pKey->abyKey[15] |= 0x80; } - MACvSetKeyEntry(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pbyBSSID, (u32 *)pKey->abyKey); + + MACvSetKeyEntry(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, + pbyBSSID, pKey->abyKey); if ((dwKeyIndex & USE_KEYRSC) == 0) pKey->KeyRSC = 0; /* RSC set by NIC */ @@ -319,7 +308,9 @@ int KeybSetKey(struct vnt_private *pDevice, PSKeyManagement pTable, if (uKeyLength == WLAN_WEP104_KEYLEN) pKey->abyKey[15] |= 0x80; } - MACvSetKeyEntry(pDevice, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, pbyBSSID, (u32 *)pKey->abyKey); + + MACvSetKeyEntry(pDevice, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, + pbyBSSID, pKey->abyKey); if ((dwKeyIndex & USE_KEYRSC) == 0) pKey->KeyRSC = 0; /* RSC set by NIC */ @@ -614,7 +605,9 @@ int KeybSetDefaultKey(struct vnt_private *pDevice, PSKeyManagement pTable, pKey->abyKey[15] |= 0x80; } - MACvSetKeyEntry(pDevice, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, MAX_KEY_TABLE-1, uKeyIdx, pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, (u32 *) pKey->abyKey); + MACvSetKeyEntry(pDevice, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, + MAX_KEY_TABLE-1, uKeyIdx, + pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, pKey->abyKey); if ((dwKeyIndex & USE_KEYRSC) == 0) pKey->KeyRSC = 0; /* RSC set by NIC */ @@ -708,7 +701,8 @@ int KeybSetAllGroupKey(struct vnt_private *pDevice, PSKeyManagement pTable, pKey->abyKey[15] |= 0x80; } - MACvSetKeyEntry(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pTable->KeyTable[i].abyBSSID, (u32 *) pKey->abyKey); + MACvSetKeyEntry(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, + pTable->KeyTable[i].abyBSSID, pKey->abyKey); if ((dwKeyIndex & USE_KEYRSC) == 0) pKey->KeyRSC = 0; /* RSC set by NIC */ diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 3ce19ddbc56..cadf7cd280c 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -35,11 +35,7 @@ #include "desc.h" #include "mac.h" #include "80211hdr.h" -#include "rndis.h" -#include "control.h" - -//static int msglevel =MSG_LEVEL_DEBUG; -static int msglevel =MSG_LEVEL_INFO; +#include "usbpipe.h" /* * Description: @@ -54,11 +50,11 @@ static int msglevel =MSG_LEVEL_INFO; * Return Value: none * */ -void MACvWriteMultiAddr(struct vnt_private *pDevice, u64 mc_filter) +void MACvWriteMultiAddr(struct vnt_private *priv, u64 mc_filter) { __le64 le_mc = cpu_to_le64(mc_filter); - CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE, MAC_REG_MAR0, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_MAR0, MESSAGE_REQUEST_MACREG, sizeof(le_mc), (u8 *)&le_mc); } @@ -73,31 +69,20 @@ void MACvWriteMultiAddr(struct vnt_private *pDevice, u64 mc_filter) * * */ -void MACbShutdown(struct vnt_private *pDevice) +void MACbShutdown(struct vnt_private *priv) { - CONTROLnsRequestOutAsyn(pDevice, - MESSAGE_TYPE_MACSHUTDOWN, - 0, - 0, - 0, - NULL - ); + vnt_control_out(priv, MESSAGE_TYPE_MACSHUTDOWN, 0, 0, 0, NULL); } -void MACvSetBBType(struct vnt_private *pDevice, u8 byType) +void MACvSetBBType(struct vnt_private *priv, u8 type) { - u8 pbyData[2]; - - pbyData[0] = byType; - pbyData[1] = EnCFG_BBType_MASK; - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - MAC_REG_ENCFG0, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + u8 data[2]; + + data[0] = type; + data[1] = EnCFG_BBType_MASK; + + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_ENCFG0, + MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } /* @@ -114,20 +99,10 @@ void MACvSetBBType(struct vnt_private *pDevice, u8 byType) * Return Value: none * */ -void MACvDisableKeyEntry(struct vnt_private *pDevice, u32 uEntryIdx) +void MACvDisableKeyEntry(struct vnt_private *priv, u8 entry_idx) { - u8 byData; - - byData = (u8) uEntryIdx; - - //issue write misc fifo command to device - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_CLRKEYENTRY, - 0, - 0, - 1, - &byData - ); + vnt_control_out(priv, MESSAGE_TYPE_CLRKEYENTRY, 0, 0, + sizeof(entry_idx), &entry_idx); } /* @@ -144,210 +119,137 @@ void MACvDisableKeyEntry(struct vnt_private *pDevice, u32 uEntryIdx) * Return Value: none * */ -void MACvSetKeyEntry(struct vnt_private *pDevice, u16 wKeyCtl, u32 uEntryIdx, - u32 uKeyIdx, u8 *pbyAddr, u32 *pdwKey) +void MACvSetKeyEntry(struct vnt_private *priv, u16 key_ctl, u32 entry_idx, + u32 key_idx, u8 *addr, u8 *key) { - u8 *pbyKey; - u16 wOffset; - u32 dwData1, dwData2; - int ii; - u8 pbyData[24]; - - if (pDevice->byLocalID <= MAC_REVISION_A1) - if (pDevice->vnt_mgmt.byCSSPK == KEY_CTL_CCMP) + struct vnt_mac_set_key set_key; + u16 offset; + + if (priv->byLocalID <= MAC_REVISION_A1) + if (priv->vnt_mgmt.byCSSPK == KEY_CTL_CCMP) return; - wOffset = MISCFIFO_KEYETRY0; - wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE); - - dwData1 = 0; - dwData1 |= wKeyCtl; - dwData1 <<= 16; - dwData1 |= MAKEWORD(*(pbyAddr+4), *(pbyAddr+5)); - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"1. wOffset: %d, Data: %X,"\ - " KeyCtl:%X\n", wOffset, dwData1, wKeyCtl); - - dwData2 = 0; - dwData2 |= *(pbyAddr+3); - dwData2 <<= 8; - dwData2 |= *(pbyAddr+2); - dwData2 <<= 8; - dwData2 |= *(pbyAddr+1); - dwData2 <<= 8; - dwData2 |= *(pbyAddr+0); - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"2. wOffset: %d, Data: %X\n", - wOffset, dwData2); - - pbyKey = (u8 *)pdwKey; - - pbyData[0] = (u8)dwData1; - pbyData[1] = (u8)(dwData1>>8); - pbyData[2] = (u8)(dwData1>>16); - pbyData[3] = (u8)(dwData1>>24); - pbyData[4] = (u8)dwData2; - pbyData[5] = (u8)(dwData2>>8); - pbyData[6] = (u8)(dwData2>>16); - pbyData[7] = (u8)(dwData2>>24); - for (ii = 8; ii < 24; ii++) - pbyData[ii] = *pbyKey++; - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_SETKEY, - wOffset, - (u16)uKeyIdx, - ARRAY_SIZE(pbyData), - pbyData - ); + offset = MISCFIFO_KEYETRY0; + offset += (entry_idx * MISCFIFO_KEYENTRYSIZE); + + set_key.u.write.key_ctl = cpu_to_le16(key_ctl); + memcpy(set_key.u.write.addr, addr, ETH_ALEN); + + /* swap over swap[0] and swap[1] to get correct write order */ + swap(set_key.u.swap[0], set_key.u.swap[1]); + + memcpy(set_key.key, key, WLAN_KEY_LEN_CCMP); + dev_dbg(&priv->usb->dev, "offset %d key ctl %d set key %24ph\n", + offset, key_ctl, (u8 *)&set_key); + + vnt_control_out(priv, MESSAGE_TYPE_SETKEY, offset, + (u16)key_idx, sizeof(struct vnt_mac_set_key), (u8 *)&set_key); } -void MACvRegBitsOff(struct vnt_private *pDevice, u8 byRegOfs, u8 byBits) +void MACvRegBitsOff(struct vnt_private *priv, u8 reg_ofs, u8 bits) { - u8 pbyData[2]; - - pbyData[0] = 0; - pbyData[1] = byBits; - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - byRegOfs, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + u8 data[2]; + + data[0] = 0; + data[1] = bits; + + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, + reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void MACvRegBitsOn(struct vnt_private *pDevice, u8 byRegOfs, u8 byBits) +void MACvRegBitsOn(struct vnt_private *priv, u8 reg_ofs, u8 bits) { - u8 pbyData[2]; - - pbyData[0] = byBits; - pbyData[1] = byBits; - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - byRegOfs, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + u8 data[2]; + + data[0] = bits; + data[1] = bits; + + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, + reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void MACvWriteWord(struct vnt_private *pDevice, u8 byRegOfs, u16 wData) +void MACvWriteWord(struct vnt_private *priv, u8 reg_ofs, u16 word) { - u8 pbyData[2]; + u8 data[2]; - pbyData[0] = (u8)(wData & 0xff); - pbyData[1] = (u8)(wData >> 8); + data[0] = (u8)(word & 0xff); + data[1] = (u8)(word >> 8); - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - byRegOfs, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + vnt_control_out(priv, MESSAGE_TYPE_WRITE, + reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); +} +void MACvWriteBSSIDAddress(struct vnt_private *priv, u8 *addr) +{ + vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_BSSID0, + MESSAGE_REQUEST_MACREG, ETH_ALEN, addr); } -void MACvWriteBSSIDAddress(struct vnt_private *pDevice, u8 *pbyEtherAddr) +void MACvEnableProtectMD(struct vnt_private *priv) { - u8 pbyData[6]; - - pbyData[0] = *((u8 *)pbyEtherAddr); - pbyData[1] = *((u8 *)pbyEtherAddr+1); - pbyData[2] = *((u8 *)pbyEtherAddr+2); - pbyData[3] = *((u8 *)pbyEtherAddr+3); - pbyData[4] = *((u8 *)pbyEtherAddr+4); - pbyData[5] = *((u8 *)pbyEtherAddr+5); - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - MAC_REG_BSSID0, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + u8 data[2]; + + data[0] = EnCFG_ProtectMd; + data[1] = EnCFG_ProtectMd; + + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, + MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void MACvEnableProtectMD(struct vnt_private *pDevice) +void MACvDisableProtectMD(struct vnt_private *priv) { - u8 pbyData[2]; - - pbyData[0] = EnCFG_ProtectMd; - pbyData[1] = EnCFG_ProtectMd; - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - MAC_REG_ENCFG0, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + u8 data[2]; + + data[0] = 0; + data[1] = EnCFG_ProtectMd; + + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, + MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void MACvDisableProtectMD(struct vnt_private *pDevice) +void MACvEnableBarkerPreambleMd(struct vnt_private *priv) { - u8 pbyData[2]; - - pbyData[0] = 0; - pbyData[1] = EnCFG_ProtectMd; - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - MAC_REG_ENCFG0, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + u8 data[2]; + + data[0] = EnCFG_BarkerPream; + data[1] = EnCFG_BarkerPream; + + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, + MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void MACvEnableBarkerPreambleMd(struct vnt_private *pDevice) +void MACvDisableBarkerPreambleMd(struct vnt_private *priv) { - u8 pbyData[2]; - - pbyData[0] = EnCFG_BarkerPream; - pbyData[1] = EnCFG_BarkerPream; - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - MAC_REG_ENCFG2, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + u8 data[2]; + + data[0] = 0; + data[1] = EnCFG_BarkerPream; + + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, + MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void MACvDisableBarkerPreambleMd(struct vnt_private *pDevice) +void MACvWriteBeaconInterval(struct vnt_private *priv, u16 interval) { - u8 pbyData[2]; - - pbyData[0] = 0; - pbyData[1] = EnCFG_BarkerPream; - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - MAC_REG_ENCFG2, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + u8 data[2]; + + data[0] = (u8)(interval & 0xff); + data[1] = (u8)(interval >> 8); + + vnt_control_out(priv, MESSAGE_TYPE_WRITE, + MAC_REG_BI, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void MACvWriteBeaconInterval(struct vnt_private *pDevice, u16 wInterval) +void vnt_mac_set_led(struct vnt_private *priv, u8 state, u8 led) { - u8 pbyData[2]; - - pbyData[0] = (u8)(wInterval & 0xff); - pbyData[1] = (u8)(wInterval >> 8); - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - MAC_REG_BI, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + u8 data[2]; + + data[0] = led; + data[1] = state; + + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_PAPEDELAY, + MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); + + return; } diff --git a/drivers/staging/vt6656/mac.h b/drivers/staging/vt6656/mac.h index 4053e431ef9..986ca95f720 100644 --- a/drivers/staging/vt6656/mac.h +++ b/drivers/staging/vt6656/mac.h @@ -403,11 +403,22 @@ #define MAC_REVISION_A0 0x00 #define MAC_REVISION_A1 0x01 +struct vnt_mac_set_key { + union { + struct { + u8 addr[ETH_ALEN]; + __le16 key_ctl; + } write __packed; + u32 swap[2]; + } u; + u8 key[WLAN_KEY_LEN_CCMP]; +} __packed; + void MACvWriteMultiAddr(struct vnt_private *, u64); void MACbShutdown(struct vnt_private *); void MACvSetBBType(struct vnt_private *, u8); -void MACvDisableKeyEntry(struct vnt_private *, u32); -void MACvSetKeyEntry(struct vnt_private *, u16, u32, u32, u8 *, u32 *); +void MACvDisableKeyEntry(struct vnt_private *, u8); +void MACvSetKeyEntry(struct vnt_private *, u16, u32, u32, u8 *, u8 *); void MACvRegBitsOff(struct vnt_private *, u8, u8); void MACvRegBitsOn(struct vnt_private *, u8, u8); void MACvWriteWord(struct vnt_private *, u8, u16); @@ -417,5 +428,6 @@ void MACvDisableProtectMD(struct vnt_private *); void MACvEnableBarkerPreambleMd(struct vnt_private *); void MACvDisableBarkerPreambleMd(struct vnt_private *); void MACvWriteBeaconInterval(struct vnt_private *, u16); +void vnt_mac_set_led(struct vnt_private *priv, u8, u8); #endif /* __MAC_H__ */ diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 3c9323069e0..e18071f121c 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -57,17 +57,15 @@ #include "power.h" #include "wcmd.h" #include "iocmd.h" -#include "tcrc.h" #include "rxtx.h" #include "bssdb.h" -#include "hostap.h" #include "wpactl.h" #include "iwctl.h" #include "dpc.h" #include "datarate.h" #include "rf.h" #include "firmware.h" -#include "control.h" +#include "usbpipe.h" #include "channel.h" #include "int.h" #include "iowpa.h" @@ -216,8 +214,6 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); static int device_init_registers(struct vnt_private *pDevice); static bool device_init_defrag_cb(struct vnt_private *pDevice); -static void device_init_diversity_timer(struct vnt_private *pDevice); -static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev); static int ethtool_ioctl(struct net_device *dev, struct ifreq *); static void device_free_tx_bufs(struct vnt_private *pDevice); @@ -262,33 +258,8 @@ device_set_options(struct vnt_private *pDevice) { pDevice->byBBType = BBP_TYPE_DEF; pDevice->byPacketType = pDevice->byBBType; pDevice->byAutoFBCtrl = AUTO_FB_0; - pDevice->bUpdateBBVGA = true; - pDevice->byFOETuning = 0; - pDevice->byAutoPwrTunning = 0; pDevice->byPreambleType = 0; pDevice->bExistSWNetAddr = false; - /* pDevice->bDiversityRegCtlON = true; */ - pDevice->bDiversityRegCtlON = false; -} - -static void device_init_diversity_timer(struct vnt_private *pDevice) -{ - init_timer(&pDevice->TimerSQ3Tmax1); - pDevice->TimerSQ3Tmax1.data = (unsigned long)pDevice; - pDevice->TimerSQ3Tmax1.function = (TimerFunction)TimerSQ3CallBack; - pDevice->TimerSQ3Tmax1.expires = RUN_AT(HZ); - - init_timer(&pDevice->TimerSQ3Tmax2); - pDevice->TimerSQ3Tmax2.data = (unsigned long)pDevice; - pDevice->TimerSQ3Tmax2.function = (TimerFunction)TimerSQ3CallBack; - pDevice->TimerSQ3Tmax2.expires = RUN_AT(HZ); - - init_timer(&pDevice->TimerSQ3Tmax3); - pDevice->TimerSQ3Tmax3.data = (unsigned long)pDevice; - pDevice->TimerSQ3Tmax3.function = (TimerFunction)TimerSQ3Tmax3CallBack; - pDevice->TimerSQ3Tmax3.expires = RUN_AT(HZ); - - return; } /* @@ -312,8 +283,6 @@ static int device_init_registers(struct vnt_private *pDevice) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->INIbInitAdapter. [%d][%d]\n", DEVICE_INIT_COLD, pDevice->byPacketType); - spin_lock_irq(&pDevice->lock); - memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN); memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN); memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN); @@ -323,20 +292,17 @@ static int device_init_registers(struct vnt_private *pDevice) if (FIRMWAREbBrach2Sram(pDevice) == false) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " FIRMWAREbBrach2Sram fail\n"); - spin_unlock_irq(&pDevice->lock); return false; } } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " FIRMWAREbDownload fail\n"); - spin_unlock_irq(&pDevice->lock); return false; } } if (!BBbVT3184Init(pDevice)) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" BBbVT3184Init fail\n"); - spin_unlock_irq(&pDevice->lock); return false; } @@ -348,37 +314,31 @@ static int device_init_registers(struct vnt_private *pDevice) init_cmd->long_retry_limit = pDevice->byLongRetryLimit; /* issue card_init command to device */ - ntStatus = CONTROLnsRequestOut(pDevice, + ntStatus = vnt_control_out(pDevice, MESSAGE_TYPE_CARDINIT, 0, 0, sizeof(struct vnt_cmd_card_init), (u8 *)init_cmd); if (ntStatus != STATUS_SUCCESS) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Issue Card init fail\n"); - spin_unlock_irq(&pDevice->lock); return false; } - ntStatus = CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_INIT_RSP, 0, 0, + ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_INIT_RSP, 0, 0, sizeof(struct vnt_rsp_card_init), (u8 *)init_rsp); if (ntStatus != STATUS_SUCCESS) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Cardinit request in status fail!\n"); - spin_unlock_irq(&pDevice->lock); return false; } /* local ID for AES functions */ - ntStatus = CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, + ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_READ, MAC_REG_LOCALID, MESSAGE_REQUEST_MACREG, 1, &pDevice->byLocalID); - if (ntStatus != STATUS_SUCCESS) { - spin_unlock_irq(&pDevice->lock); + if (ntStatus != STATUS_SUCCESS) return false; - } /* do MACbSoftwareReset in MACvInitialize */ - /* force CCK */ - pDevice->bCCK = true; pDevice->bProtectMode = false; /* only used in 11g type, sync with ERP IE */ pDevice->bNonERPPresent = false; @@ -396,7 +356,7 @@ static int device_init_registers(struct vnt_private *pDevice) pDevice->byTopOFDMBasicRate = RATE_24M; pDevice->byTopCCKBasicRate = RATE_1M; - pDevice->byRevId = 0; + /* target to IF pin while programming to RF chip */ pDevice->byCurPwr = 0xFF; @@ -461,13 +421,7 @@ static int device_init_registers(struct vnt_private *pDevice) pDevice->byRxAntennaMode = ANT_A; else pDevice->byRxAntennaMode = ANT_B; - - if (pDevice->bDiversityRegCtlON) - pDevice->bDiversityEnable = true; - else - pDevice->bDiversityEnable = false; } else { - pDevice->bDiversityEnable = false; pDevice->byAntennaCount = 1; pDevice->dwTxAntennaSel = 0; pDevice->dwRxAntennaSel = 0; @@ -489,27 +443,14 @@ static int device_init_registers(struct vnt_private *pDevice) } } - pDevice->ulDiversityNValue = 100 * 255; - pDevice->ulDiversityMValue = 100 * 16; - pDevice->byTMax = 1; - pDevice->byTMax2 = 4; - pDevice->ulSQ3TH = 0; - pDevice->byTMax3 = 64; - /* get Auto Fall Back type */ pDevice->byAutoFBCtrl = AUTO_FB_0; - /* set SCAN Time */ - pDevice->uScanTime = WLAN_SCAN_MINITIME; - /* default Auto Mode */ /* pDevice->NetworkType = Ndis802_11Automode; */ pDevice->eConfigPHYMode = PHY_TYPE_AUTO; pDevice->byBBType = BB_TYPE_11G; - /* initialize BBP registers */ - pDevice->ulTxPower = 25; - /* get channel range */ pDevice->byMinChannel = 1; pDevice->byMaxChannel = CB_MAX_CHANNEL; @@ -517,11 +458,6 @@ static int device_init_registers(struct vnt_private *pDevice) /* get RFType */ pDevice->byRFType = init_rsp->rf_type; - if ((pDevice->byRFType & RF_EMU) != 0) { - /* force change RevID for VT3253 emu */ - pDevice->byRevId = 0x80; - } - /* load vt3266 calibration parameters in EEPROM */ if (pDevice->byRFType == RF_VT3226D0) { if ((pDevice->abyEEPROM[EEP_OFS_MAJOR_VER] == 0x1) && @@ -532,28 +468,28 @@ static int device_init_registers(struct vnt_private *pDevice) byCalibRXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_RX_IQ]; if (byCalibTXIQ || byCalibTXDC || byCalibRXIQ) { /* CR255, enable TX/RX IQ and DC compensation mode */ - ControlvWriteByte(pDevice, + vnt_control_out_u8(pDevice, MESSAGE_REQUEST_BBREG, 0xff, 0x03); /* CR251, TX I/Q Imbalance Calibration */ - ControlvWriteByte(pDevice, + vnt_control_out_u8(pDevice, MESSAGE_REQUEST_BBREG, 0xfb, byCalibTXIQ); /* CR252, TX DC-Offset Calibration */ - ControlvWriteByte(pDevice, + vnt_control_out_u8(pDevice, MESSAGE_REQUEST_BBREG, 0xfC, byCalibTXDC); /* CR253, RX I/Q Imbalance Calibration */ - ControlvWriteByte(pDevice, + vnt_control_out_u8(pDevice, MESSAGE_REQUEST_BBREG, 0xfd, byCalibRXIQ); } else { /* CR255, turn off BB Calibration compensation */ - ControlvWriteByte(pDevice, + vnt_control_out_u8(pDevice, MESSAGE_REQUEST_BBREG, 0xff, 0x0); @@ -590,24 +526,20 @@ static int device_init_registers(struct vnt_private *pDevice) BBvSetShortSlotTime(pDevice); CARDvSetBSSMode(pDevice); - if (pDevice->bUpdateBBVGA) { - pDevice->byBBVGACurrent = pDevice->abyBBVGA[0]; - pDevice->byBBVGANew = pDevice->byBBVGACurrent; + pDevice->byBBVGACurrent = pDevice->abyBBVGA[0]; + pDevice->byBBVGANew = pDevice->byBBVGACurrent; - BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]); - } + BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]); pDevice->byRadioCtl = pDevice->abyEEPROM[EEP_OFS_RADIOCTL]; pDevice->bHWRadioOff = false; if ((pDevice->byRadioCtl & EEP_RADIOCTL_ENABLE) != 0) { - ntStatus = CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, + ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_READ, MAC_REG_GPIOCTL1, MESSAGE_REQUEST_MACREG, 1, &byTmp); - if (ntStatus != STATUS_SUCCESS) { - spin_unlock_irq(&pDevice->lock); + if (ntStatus != STATUS_SUCCESS) return false; - } if ((byTmp & GPIO3_DATA) == 0) { pDevice->bHWRadioOff = true; @@ -619,11 +551,9 @@ static int device_init_registers(struct vnt_private *pDevice) } - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, - MAC_REG_PAPEDELAY, LEDSTS_TMLEN, 0x38); + vnt_mac_set_led(pDevice, LEDSTS_TMLEN, 0x38); - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, - MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW); + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW); MACvRegBitsOn(pDevice, MAC_REG_GPIOCTL0, 0x01); @@ -634,9 +564,6 @@ static int device_init_registers(struct vnt_private *pDevice) CARDbRadioPowerOn(pDevice); } - - spin_unlock_irq(&pDevice->lock); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----INIbInitAdapter Exit\n"); return true; @@ -709,18 +636,13 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id) device_set_options(pDevice); spin_lock_init(&pDevice->lock); + mutex_init(&pDevice->usb_lock); + INIT_DELAYED_WORK(&pDevice->run_command_work, vRunCommand); INIT_DELAYED_WORK(&pDevice->second_callback_work, BSSvSecondCallBack); INIT_WORK(&pDevice->read_work_item, RXvWorkItem); INIT_WORK(&pDevice->rx_mng_work_item, RXvMngWorkItem); - pDevice->pControlURB = usb_alloc_urb(0, GFP_ATOMIC); - if (!pDevice->pControlURB) { - DBG_PRT(MSG_LEVEL_ERR, KERN_ERR"Failed to alloc control urb\n"); - goto err_netdev; - } - - pDevice->tx_80211 = device_dma0_tx_80211; pDevice->vnt_mgmt.pAdapter = (void *) pDevice; netdev->netdev_ops = &device_netdev_ops; @@ -757,9 +679,9 @@ static void device_free_tx_bufs(struct vnt_private *priv) for (ii = 0; ii < priv->cbTD; ii++) { tx_context = priv->apTD[ii]; /* deallocate URBs */ - if (tx_context->pUrb) { - usb_kill_urb(tx_context->pUrb); - usb_free_urb(tx_context->pUrb); + if (tx_context->urb) { + usb_kill_urb(tx_context->urb); + usb_free_urb(tx_context->urb); } kfree(tx_context); @@ -825,17 +747,17 @@ static bool device_alloc_bufs(struct vnt_private *priv) } priv->apTD[ii] = tx_context; - tx_context->pDevice = priv; + tx_context->priv = priv; /* allocate URBs */ - tx_context->pUrb = usb_alloc_urb(0, GFP_ATOMIC); - if (tx_context->pUrb == NULL) { + tx_context->urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!tx_context->urb) { DBG_PRT(MSG_LEVEL_ERR, KERN_ERR "alloc tx urb failed\n"); goto free_tx; } - tx_context->bBoolInUse = false; + tx_context->in_use = false; } /* allocate RCB mem */ @@ -976,8 +898,6 @@ static int device_open(struct net_device *dev) } MP_CLEAR_FLAG(pDevice, fMP_DISCONNECTED); - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); MP_SET_FLAG(pDevice, fMP_POST_READS); MP_SET_FLAG(pDevice, fMP_POST_WRITES); @@ -999,9 +919,6 @@ static int device_open(struct net_device *dev) pDevice->bRoaming = false; pDevice->bIsRoaming = false; pDevice->bEnableRoaming = false; - if (pDevice->bDiversityRegCtlON) { - device_init_diversity_timer(pDevice); - } vMgrObjectInit(pDevice); @@ -1025,7 +942,6 @@ static int device_open(struct net_device *dev) /* if WEP key already set by iwconfig but device not yet open */ if ((pDevice->bEncryptionEnable == true) && (pDevice->bTransmitKey == true)) { - spin_lock_irq(&pDevice->lock); KeybSetDefaultKey( pDevice, &(pDevice->sKey), pDevice->byKeyIndex | (1 << 31), @@ -1034,7 +950,7 @@ static int device_open(struct net_device *dev) pDevice->abyKey, KEY_CTL_WEP ); - spin_unlock_irq(&pDevice->lock); + pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; } @@ -1066,7 +982,7 @@ static int device_close(struct net_device *dev) { struct vnt_private *pDevice = netdev_priv(dev); struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - int uu; + u8 uu; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close1\n"); if (pDevice == NULL) @@ -1081,10 +997,9 @@ static int device_close(struct net_device *dev) pMgmt->bShareKeyAlgorithm = false; pDevice->bEncryptionEnable = false; pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - spin_lock_irq(&pDevice->lock); + for (uu = 0; uu < MAX_KEY_TABLE; uu++) MACvDisableKeyEntry(pDevice,uu); - spin_unlock_irq(&pDevice->lock); if ((pDevice->flags & DEVICE_FLAGS_UNPLUG) == false) { MACbShutdown(pDevice); @@ -1097,12 +1012,6 @@ static int device_close(struct net_device *dev) cancel_delayed_work_sync(&pDevice->run_command_work); cancel_delayed_work_sync(&pDevice->second_callback_work); - if (pDevice->bDiversityRegCtlON) { - del_timer(&pDevice->TimerSQ3Tmax1); - del_timer(&pDevice->TimerSQ3Tmax2); - del_timer(&pDevice->TimerSQ3Tmax3); - } - cancel_work_sync(&pDevice->rx_mng_work_item); cancel_work_sync(&pDevice->read_work_item); @@ -1145,36 +1054,17 @@ static void vt6656_disconnect(struct usb_interface *intf) if (device->dev) { unregister_netdev(device->dev); - - usb_kill_urb(device->pControlURB); - usb_free_urb(device->pControlURB); - free_netdev(device->dev); } } -static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev) -{ - struct vnt_private *pDevice = netdev_priv(dev); - - spin_lock_irq(&pDevice->lock); - - if (unlikely(pDevice->bStopTx0Pkt)) - dev_kfree_skb_irq(skb); - else - vDMA0_tx_80211(pDevice, skb); - - spin_unlock_irq(&pDevice->lock); - - return NETDEV_TX_OK; -} - static int device_xmit(struct sk_buff *skb, struct net_device *dev) { struct vnt_private *pDevice = netdev_priv(dev); struct net_device_stats *stats = &pDevice->stats; + unsigned long flags; - spin_lock_irq(&pDevice->lock); + spin_lock_irqsave(&pDevice->lock, flags); netif_stop_queue(dev); @@ -1189,13 +1079,13 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) goto out; } - if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb)) { + if (nsDMA_tx_packet(pDevice, skb)) { if (netif_queue_stopped(dev)) netif_wake_queue(dev); } out: - spin_unlock_irq(&pDevice->lock); + spin_unlock_irqrestore(&pDevice->lock, flags); return NETDEV_TX_OK; } @@ -1377,7 +1267,7 @@ void vnt_configure_filter(struct vnt_private *priv) u8 tmp = 0; int rc; - rc = CONTROLnsRequestIn(priv, MESSAGE_TYPE_READ, + rc = vnt_control_in(priv, MESSAGE_TYPE_READ, MAC_REG_RCR, MESSAGE_REQUEST_MACREG, 1, &tmp); if (rc == 0) priv->byRxMode = tmp; @@ -1418,7 +1308,7 @@ void vnt_configure_filter(struct vnt_private *priv) priv->byRxMode &= ~(RCR_UNICAST); } - ControlvWriteByte(priv, MESSAGE_REQUEST_MACREG, + vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, MAC_REG_RCR, priv->byRxMode); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO @@ -1434,20 +1324,9 @@ static struct net_device_stats *device_get_stats(struct net_device *dev) static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct vnt_private *pDevice = netdev_priv(dev); - struct iwreq *wrq = (struct iwreq *) rq; int rc = 0; switch (cmd) { - - case IOCTL_CMD_HOSTAPD: - - if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) - rc = -EFAULT; - - rc = vt6656_hostap_ioctl(pDevice, &wrq->u.data); - break; - case SIOCETHTOOL: return ethtool_ioctl(dev, rq); diff --git a/drivers/staging/vt6656/power.c b/drivers/staging/vt6656/power.c index 43da58927cd..ddbd04695c9 100644 --- a/drivers/staging/vt6656/power.c +++ b/drivers/staging/vt6656/power.c @@ -44,8 +44,7 @@ #include "wcmd.h" #include "rxtx.h" #include "card.h" -#include "control.h" -#include "rndis.h" +#include "usbpipe.h" static int msglevel = MSG_LEVEL_INFO; @@ -130,7 +129,7 @@ void PSvDisablePowerSaving(struct vnt_private *pDevice) { /* disable power saving hw function */ - CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_DISABLE_PS, 0, + vnt_control_out(pDevice, MESSAGE_TYPE_DISABLE_PS, 0, 0, 0, NULL); /* clear AutoSleep */ @@ -163,7 +162,7 @@ int PSbConsiderPowerDown(struct vnt_private *pDevice, int bCheckRxDMA, u8 byData; /* check if already in Doze mode */ - ControlvReadByte(pDevice, MESSAGE_REQUEST_MACREG, + vnt_control_in_u8(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData); if ((byData & PSCTL_PS) != 0) diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index 1e8f64bff03..3f54ae3cfb4 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -26,7 +26,7 @@ * Date: Feb. 19, 2004 * * Functions: - * IFRFbWriteEmbedded - Embedded write RF register via MAC + * vnt_rf_write_embedded - Embedded write RF register via MAC * * Revision History: * RF_VT3226: RobertYu:20051111, VT3226C0 and before @@ -38,12 +38,9 @@ #include "mac.h" #include "rf.h" #include "baseband.h" -#include "control.h" -#include "rndis.h" +#include "usbpipe.h" #include "datarate.h" -static int msglevel =MSG_LEVEL_INFO; -//static int msglevel =MSG_LEVEL_DEBUG; #define BY_AL2230_REG_LEN 23 //24bit #define CB_AL2230_INIT_SEQ 15 #define AL2230_PWR_IDX_LEN 64 @@ -355,7 +352,7 @@ static u8 al7230_channel_table2[CB_MAX_CHANNEL][3] = { }; ///{{RobertYu:20051111 -static u8 at3226_init_table[CB_VT3226_INIT_SEQ][3] = { +static u8 vt3226_init_table[CB_VT3226_INIT_SEQ][3] = { {0x03, 0xFF, 0x80}, {0x02, 0x82, 0xA1}, {0x03, 0xC6, 0xA2}, @@ -369,7 +366,7 @@ static u8 at3226_init_table[CB_VT3226_INIT_SEQ][3] = { {0x02, 0x00, 0x2A} }; -static u8 at3226d0_init_table[CB_VT3226_INIT_SEQ][3] = { +static u8 vt3226d0_init_table[CB_VT3226_INIT_SEQ][3] = { {0x03, 0xFF, 0x80}, {0x03, 0x02, 0x21}, //RobertYu:20060327 {0x03, 0xC6, 0xA2}, @@ -707,17 +704,17 @@ const u8 RFaby11aChannelIndex[200] = { * Return Value: true if succeeded; false if failed. * */ -int IFRFbWriteEmbedded(struct vnt_private *pDevice, u32 dwData) +int vnt_rf_write_embedded(struct vnt_private *priv, u32 data) { - u8 pbyData[4]; + u8 reg_data[4]; - pbyData[0] = (u8)dwData; - pbyData[1] = (u8)(dwData >> 8); - pbyData[2] = (u8)(dwData >> 16); - pbyData[3] = (u8)(dwData >> 24); + reg_data[0] = (u8)data; + reg_data[1] = (u8)(data >> 8); + reg_data[2] = (u8)(data >> 16); + reg_data[3] = (u8)(data >> 24); - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_IFRF, 0, 0, 4, pbyData); + vnt_control_out(priv, MESSAGE_TYPE_WRITE_IFRF, + 0, 0, ARRAY_SIZE(reg_data), reg_data); return true; } @@ -735,7 +732,7 @@ int IFRFbWriteEmbedded(struct vnt_private *pDevice, u32 dwData) * Return Value: true if succeeded; false if failed. * */ -int RFbSetPower(struct vnt_private *priv, u32 rate, u32 channel) +int vnt_rf_setpower(struct vnt_private *priv, u32 rate, u32 channel) { int ret = true; u8 power = priv->byCCKPwr; @@ -764,11 +761,37 @@ int RFbSetPower(struct vnt_private *priv, u32 rate, u32 channel) break; } - ret = RFbRawSetPower(priv, power, rate); + ret = vnt_rf_set_txpower(priv, power, rate); return ret; } +static u8 vnt_rf_addpower(struct vnt_private *priv) +{ + s32 rssi = -priv->uCurrRSSI; + + if (!rssi) + return 7; + + if (priv->byRFType == RF_VT3226D0) { + if (rssi < -70) + return 9; + else if (rssi < -65) + return 7; + else if (rssi < -60) + return 5; + } else { + if (rssi < -80) + return 9; + else if (rssi < -75) + return 7; + else if (rssi < -70) + return 5; + } + + return 0; +} + /* * Description: Set Tx power * @@ -783,11 +806,15 @@ int RFbSetPower(struct vnt_private *priv, u32 rate, u32 channel) * */ -int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) +int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, u32 rate) { u32 power_setting = 0; int ret = true; + power += vnt_rf_addpower(priv); + if (power > VNT_RF_MAX_POWER) + power = VNT_RF_MAX_POWER; + if (priv->byCurPwr == power) return true; @@ -798,42 +825,42 @@ int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) if (priv->byCurPwr >= AL2230_PWR_IDX_LEN) return false; - ret &= IFRFbWriteEmbedded(priv, + ret &= vnt_rf_write_embedded(priv, al2230_power_table[priv->byCurPwr]); if (rate <= RATE_11M) - ret &= IFRFbWriteEmbedded(priv, 0x0001b400 + + ret &= vnt_rf_write_embedded(priv, 0x0001b400 + (BY_AL2230_REG_LEN << 3) + IFREGCTL_REGW); else - ret &= IFRFbWriteEmbedded(priv, 0x0005a400 + + ret &= vnt_rf_write_embedded(priv, 0x0005a400 + (BY_AL2230_REG_LEN << 3) + IFREGCTL_REGW); break; case RF_AL2230S: if (priv->byCurPwr >= AL2230_PWR_IDX_LEN) return false; - ret &= IFRFbWriteEmbedded(priv, + ret &= vnt_rf_write_embedded(priv, al2230_power_table[priv->byCurPwr]); if (rate <= RATE_11M) { - ret &= IFRFbWriteEmbedded(priv, 0x040c1400 + + ret &= vnt_rf_write_embedded(priv, 0x040c1400 + (BY_AL2230_REG_LEN << 3) + IFREGCTL_REGW); - ret &= IFRFbWriteEmbedded(priv, 0x00299b00 + + ret &= vnt_rf_write_embedded(priv, 0x00299b00 + (BY_AL2230_REG_LEN << 3) + IFREGCTL_REGW); } else { - ret &= IFRFbWriteEmbedded(priv, 0x0005a400 + + ret &= vnt_rf_write_embedded(priv, 0x0005a400 + (BY_AL2230_REG_LEN << 3) + IFREGCTL_REGW); - ret &= IFRFbWriteEmbedded(priv, 0x00099b00 + + ret &= vnt_rf_write_embedded(priv, 0x00099b00 + (BY_AL2230_REG_LEN << 3) + IFREGCTL_REGW); } break; case RF_AIROHA7230: if (rate <= RATE_11M) - ret &= IFRFbWriteEmbedded(priv, 0x111bb900 + + ret &= vnt_rf_write_embedded(priv, 0x111bb900 + (BY_AL7230_REG_LEN << 3)+IFREGCTL_REGW); else - ret &= IFRFbWriteEmbedded(priv, 0x221bb900 + + ret &= vnt_rf_write_embedded(priv, 0x221bb900 + (BY_AL7230_REG_LEN << 3)+IFREGCTL_REGW); if (priv->byCurPwr > AL7230_PWR_IDX_LEN) @@ -846,7 +873,7 @@ int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) power_setting = 0x080c0b00 | ((priv->byCurPwr) << 12) | (BY_AL7230_REG_LEN << 3) | IFREGCTL_REGW; - ret &= IFRFbWriteEmbedded(priv, power_setting); + ret &= vnt_rf_write_embedded(priv, power_setting); break; @@ -856,7 +883,7 @@ int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) power_setting = ((0x3f - priv->byCurPwr) << 20) | (0x17 << 8) | (BY_VT3226_REG_LEN << 3) | IFREGCTL_REGW; - ret &= IFRFbWriteEmbedded(priv, power_setting); + ret &= vnt_rf_write_embedded(priv, power_setting); break; case RF_VT3226D0: @@ -868,42 +895,42 @@ int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) (0xe07 << 8) | (BY_VT3226_REG_LEN << 3) | IFREGCTL_REGW; - ret &= IFRFbWriteEmbedded(priv, power_setting); - ret &= IFRFbWriteEmbedded(priv, 0x03c6a200 + + ret &= vnt_rf_write_embedded(priv, power_setting); + ret &= vnt_rf_write_embedded(priv, 0x03c6a200 + (BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); if (priv->vnt_mgmt.eScanState != WMAC_NO_SCANNING) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "RFbRawSetPower> 11B mode uCurrChannel[%d]\n", + dev_dbg(&priv->usb->dev, + "vnt_rf_set_txpower> 11B mode uCurrChannel[%d]\n", priv->vnt_mgmt.uScanChannel); - ret &= IFRFbWriteEmbedded(priv, + ret &= vnt_rf_write_embedded(priv, vt3226d0_lo_current_table[priv-> vnt_mgmt.uScanChannel - 1]); } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "RFbRawSetPower> 11B mode uCurrChannel[%d]\n", + dev_dbg(&priv->usb->dev, + "vnt_rf_set_txpower> 11B mode uCurrChannel[%d]\n", priv->vnt_mgmt.uCurrChannel); - ret &= IFRFbWriteEmbedded(priv, + ret &= vnt_rf_write_embedded(priv, vt3226d0_lo_current_table[priv-> vnt_mgmt.uCurrChannel - 1]); } - ret &= IFRFbWriteEmbedded(priv, 0x015C0800 + + ret &= vnt_rf_write_embedded(priv, 0x015C0800 + (BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "@@@@ RFbRawSetPower> 11G mode\n"); + dev_dbg(&priv->usb->dev, + "@@@@ vnt_rf_set_txpower> 11G mode\n"); power_setting = ((0x3f-priv->byCurPwr) << 20) | (0x7 << 8) | (BY_VT3226_REG_LEN << 3) | IFREGCTL_REGW; - ret &= IFRFbWriteEmbedded(priv, power_setting); - ret &= IFRFbWriteEmbedded(priv, 0x00C6A200 + + ret &= vnt_rf_write_embedded(priv, power_setting); + ret &= vnt_rf_write_embedded(priv, 0x00C6A200 + (BY_VT3226_REG_LEN << 3) + IFREGCTL_REGW); - ret &= IFRFbWriteEmbedded(priv, 0x016BC600 + + ret &= vnt_rf_write_embedded(priv, 0x016BC600 + (BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); - ret &= IFRFbWriteEmbedded(priv, 0x00900800 + + ret &= vnt_rf_write_embedded(priv, 0x00900800 + (BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); } break; @@ -916,7 +943,7 @@ int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) (0x27 << 8) | (BY_VT3342_REG_LEN << 3) | IFREGCTL_REGW; - ret &= IFRFbWriteEmbedded(priv, power_setting); + ret &= vnt_rf_write_embedded(priv, power_setting); break; default: @@ -940,7 +967,7 @@ int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) * Return Value: none * -*/ -void RFvRSSITodBm(struct vnt_private *priv, u8 rssi, long *dbm) +void vnt_rf_rssi_to_dbm(struct vnt_private *priv, u8 rssi, long *dbm) { u8 idx = (((rssi & 0xc0) >> 6) & 0x03); long b = (rssi & 0x3f); @@ -963,7 +990,7 @@ void RFvRSSITodBm(struct vnt_private *priv, u8 rssi, long *dbm) *dbm = -1 * (a + b * 2); } -void RFbRFTableDownload(struct vnt_private *priv) +void vnt_rf_table_download(struct vnt_private *priv) { u16 length1 = 0, length2 = 0, length3 = 0; u8 *addr1 = NULL, *addr2 = NULL, *addr3 = NULL; @@ -992,7 +1019,7 @@ void RFbRFTableDownload(struct vnt_private *priv) length1 = CB_VT3226_INIT_SEQ * 3; length2 = CB_MAX_CHANNEL_24G * 3; length3 = CB_MAX_CHANNEL_24G * 3; - addr1 = &at3226_init_table[0][0]; + addr1 = &vt3226_init_table[0][0]; addr2 = &vt3226_channel_table0[0][0]; addr3 = &vt3226_channel_table1[0][0]; break; @@ -1000,7 +1027,7 @@ void RFbRFTableDownload(struct vnt_private *priv) length1 = CB_VT3226_INIT_SEQ * 3; length2 = CB_MAX_CHANNEL_24G * 3; length3 = CB_MAX_CHANNEL_24G * 3; - addr1 = &at3226d0_init_table[0][0]; + addr1 = &vt3226d0_init_table[0][0]; addr2 = &vt3226_channel_table0[0][0]; addr3 = &vt3226_channel_table1[0][0]; break; @@ -1017,7 +1044,7 @@ void RFbRFTableDownload(struct vnt_private *priv) /* Init Table */ memcpy(array, addr1, length1); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, 0, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, MESSAGE_REQUEST_RF_INIT, length1, array); /* Channel Table 0 */ @@ -1030,7 +1057,7 @@ void RFbRFTableDownload(struct vnt_private *priv) memcpy(array, addr2, length); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, value, MESSAGE_REQUEST_RF_CH0, length, array); length2 -= length; @@ -1048,7 +1075,7 @@ void RFbRFTableDownload(struct vnt_private *priv) memcpy(array, addr3, length); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, value, MESSAGE_REQUEST_RF_CH1, length, array); length3 -= length; @@ -1065,7 +1092,7 @@ void RFbRFTableDownload(struct vnt_private *priv) memcpy(array, addr1, length1); /* Init Table 2 */ - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, MESSAGE_REQUEST_RF_INIT2, length1, array); /* Channel Table 0 */ @@ -1078,7 +1105,7 @@ void RFbRFTableDownload(struct vnt_private *priv) memcpy(array, addr2, length); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, value, MESSAGE_REQUEST_RF_CH2, length, array); length2 -= length; diff --git a/drivers/staging/vt6656/rf.h b/drivers/staging/vt6656/rf.h index de5c613b4ef..cb331518568 100644 --- a/drivers/staging/vt6656/rf.h +++ b/drivers/staging/vt6656/rf.h @@ -53,12 +53,14 @@ #define RF_EMU 0x80 #define RF_MASK 0x7F +#define VNT_RF_MAX_POWER 0x3f + extern const u8 RFaby11aChannelIndex[200]; -int IFRFbWriteEmbedded(struct vnt_private *, u32 dwData); -int RFbSetPower(struct vnt_private *, u32 uRATE, u32 uCH); -int RFbRawSetPower(struct vnt_private *, u8 byPwr, u32 uRATE); -void RFvRSSITodBm(struct vnt_private *, u8 byCurrRSSI, long *pldBm); -void RFbRFTableDownload(struct vnt_private *pDevice); +int vnt_rf_write_embedded(struct vnt_private *, u32); +int vnt_rf_setpower(struct vnt_private *, u32, u32); +int vnt_rf_set_txpower(struct vnt_private *, u8, u32); +void vnt_rf_rssi_to_dbm(struct vnt_private *, u8, long *); +void vnt_rf_table_download(struct vnt_private *); #endif /* __RF_H__ */ diff --git a/drivers/staging/vt6656/rndis.h b/drivers/staging/vt6656/rndis.h deleted file mode 100644 index 3661f82766e..00000000000 --- a/drivers/staging/vt6656/rndis.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: rndis.h - * - * Purpose: Interface between firmware and driver - * - * Author: Warren Hsu - * - * Date: Nov 24, 2004 - * - */ - -#ifndef __RNDIS_H__ -#define __RNDIS_H__ - -#define MESSAGE_TYPE_READ 0x01 -#define MESSAGE_TYPE_WRITE 0x00 -#define MESSAGE_TYPE_LOCK_OR 0x02 -#define MESSAGE_TYPE_LOCK_AND 0x03 -#define MESSAGE_TYPE_WRITE_MASK 0x04 -#define MESSAGE_TYPE_CARDINIT 0x05 -#define MESSAGE_TYPE_INIT_RSP 0x06 -#define MESSAGE_TYPE_MACSHUTDOWN 0x07 -#define MESSAGE_TYPE_SETKEY 0x08 -#define MESSAGE_TYPE_CLRKEYENTRY 0x09 -#define MESSAGE_TYPE_WRITE_MISCFF 0x0A -#define MESSAGE_TYPE_SET_ANTMD 0x0B -#define MESSAGE_TYPE_SELECT_CHANNLE 0x0C -#define MESSAGE_TYPE_SET_TSFTBTT 0x0D -#define MESSAGE_TYPE_SET_SSTIFS 0x0E -#define MESSAGE_TYPE_CHANGE_BBTYPE 0x0F -#define MESSAGE_TYPE_DISABLE_PS 0x10 -#define MESSAGE_TYPE_WRITE_IFRF 0x11 - -//used for read/write(index) -#define MESSAGE_REQUEST_MEM 0x01 -#define MESSAGE_REQUEST_BBREG 0x02 -#define MESSAGE_REQUEST_MACREG 0x03 -#define MESSAGE_REQUEST_EEPROM 0x04 -#define MESSAGE_REQUEST_TSF 0x05 -#define MESSAGE_REQUEST_TBTT 0x06 -#define MESSAGE_REQUEST_BBAGC 0x07 -#define MESSAGE_REQUEST_VERSION 0x08 -#define MESSAGE_REQUEST_RF_INIT 0x09 -#define MESSAGE_REQUEST_RF_INIT2 0x0A -#define MESSAGE_REQUEST_RF_CH0 0x0B -#define MESSAGE_REQUEST_RF_CH1 0x0C -#define MESSAGE_REQUEST_RF_CH2 0x0D - -#define VIAUSB20_PACKET_HEADER 0x04 - -#define USB_REG4 0x604 - -typedef struct _CMD_MESSAGE -{ - u8 byData[256]; -} CMD_MESSAGE, *PCMD_MESSAGE; - -typedef struct _CMD_WRITE_MASK -{ - u8 byData; - u8 byMask; -} CMD_WRITE_MASK, *PCMD_WRITE_MASK; - -struct vnt_cmd_card_init -{ - u8 init_class; - u8 exist_sw_net_addr; - u8 sw_net_addr[6]; - u8 short_retry_limit; - u8 long_retry_limit; -}; - -struct vnt_rsp_card_init -{ - u8 status; - u8 net_addr[6]; - u8 rf_type; - u8 min_channel; - u8 max_channel; -}; - -typedef struct _CMD_SET_KEY -{ - u16 wKCTL; - u8 abyMacAddr[6]; - u8 abyKey[16]; -} CMD_SET_KEY, *PCMD_SET_KEY; - -typedef struct _CMD_CLRKEY_ENTRY -{ - u8 abyKeyEntry[11]; -} CMD_CLRKEY_ENTRY, *PCMD_CLRKEY_ENTRY; - -typedef struct _CMD_WRITE_MISCFF -{ - u32 adwMiscFFData[22][4]; //a key entry has only 22 dwords -} CMD_WRITE_MISCFF, *PCMD_WRITE_MISCFF; - -typedef struct _CMD_SET_TSFTBTT -{ - u8 abyTSF_TBTT[8]; -} CMD_SET_TSFTBTT, *PCMD_SET_TSFTBTT; - -typedef struct _CMD_SET_SSTIFS -{ - u8 bySIFS; - u8 byDIFS; - u8 byEIFS; - u8 bySlotTime; - u8 byCwMax_Min; - u8 byBBCR10; -} CMD_SET_SSTIFS, *PCMD_SET_SSTIFS; - -typedef struct _CMD_CHANGE_BBTYPE -{ - u8 bySIFS; - u8 byDIFS; - u8 byEIFS; - u8 bySlotTime; - u8 byCwMax_Min; - u8 byBBCR10; - u8 byBB_BBType; //CR88 - u8 byMAC_BBType; - u32 dwRSPINF_b_1; - u32 dwRSPINF_b_2; - u32 dwRSPINF_b_55; - u32 dwRSPINF_b_11; - u16 wRSPINF_a[9]; -} CMD_CHANGE_BBTYPE, *PCMD_CHANGE_BBTYPE; - -#define EXCH_WORD(w) ((u16)((u16)(w)<<8) | (u16)((u16)(w)>>8)) - -#endif /* _RNDIS_H_ */ diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 3840323858f..704f4d3639b 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -54,9 +54,7 @@ #include "mac.h" #include "michael.h" #include "tkip.h" -#include "tcrc.h" #include "wctl.h" -#include "hostap.h" #include "rf.h" #include "datarate.h" #include "usbpipe.h" @@ -101,11 +99,11 @@ static struct vnt_usb_send_context *s_vGetFreeContext(struct vnt_private *); static u16 s_vGenerateTxParameter(struct vnt_private *pDevice, u8 byPktType, u16 wCurrentRate, struct vnt_tx_buffer *tx_buffer, struct vnt_mic_hdr **mic_hdr, u32 need_mic, u32 cbFrameSize, - int bNeedACK, u32 uDMAIdx, struct ethhdr *psEthHeader, bool need_rts); + int bNeedACK, struct ethhdr *psEthHeader, bool need_rts); static void s_vGenerateMACHeader(struct vnt_private *pDevice, u8 *pbyBufferAddr, u16 wDuration, struct ethhdr *psEthHeader, - int bNeedEncrypt, u16 wFragType, u32 uDMAIdx, u32 uFragIdx); + int bNeedEncrypt, u16 wFragType, u32 uFragIdx); static void s_vFillTxKey(struct vnt_private *pDevice, struct vnt_tx_fifo_head *fifo_head, u8 *pbyIVHead, @@ -119,9 +117,9 @@ static unsigned int s_uGetTxRsvTime(struct vnt_private *pDevice, u8 byPktType, u32 cbFrameLength, u16 wRate, int bNeedAck); static __le16 s_uGetRTSCTSRsvTime(struct vnt_private *priv, - u8 rsv_type, u8 pkt_type, u32 frame_lenght, u16 current_rate); + u8 rsv_type, u8 pkt_type, u32 frame_length, u16 current_rate); -static u16 s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, +static u16 s_vFillCTSHead(struct vnt_private *pDevice, u8 byPktType, union vnt_tx_data_head *head, u32 cbFrameLength, int bNeedAck, u16 wCurrentRate, u8 byFBOption); @@ -149,9 +147,9 @@ static struct vnt_usb_send_context return NULL; context = priv->apTD[ii]; - if (context->bBoolInUse == false) { - context->bBoolInUse = true; - memset(context->Data, 0, + if (context->in_use == false) { + context->in_use = true; + memset(context->data, 0, MAX_TOTAL_SIZE_WITH_ALL_HEADERS); return context; } @@ -181,41 +179,40 @@ static void s_vFillTxKey(struct vnt_private *pDevice, struct vnt_mic_hdr *mic_hdr) { u8 *pbyBuf = (u8 *)&fifo_head->adwTxKey[0]; - u32 *pdwIV = (u32 *)pbyIVHead; - u32 *pdwExtIV = (u32 *)((u8 *)pbyIVHead + 4); + __le32 *pdwIV = (__le32 *)pbyIVHead; + __le32 *pdwExtIV = (__le32 *)((u8 *)pbyIVHead + 4); struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *)pbyHdrBuf; - u32 dwRevIVCounter; + __le32 rev_iv_counter; /* Fill TXKEY */ if (pTransmitKey == NULL) return; - dwRevIVCounter = cpu_to_le32(pDevice->dwIVCounter); - *pdwIV = pDevice->dwIVCounter; + rev_iv_counter = cpu_to_le32(pDevice->dwIVCounter); + *pdwIV = cpu_to_le32(pDevice->dwIVCounter); pDevice->byKeyIndex = pTransmitKey->dwKeyIndex & 0xf; switch (pTransmitKey->byCipherSuite) { case KEY_CTL_WEP: if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN) { - memcpy(pDevice->abyPRNG, (u8 *)&dwRevIVCounter, 3); + memcpy(pDevice->abyPRNG, (u8 *)&rev_iv_counter, 3); memcpy(pDevice->abyPRNG + 3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); } else { - memcpy(pbyBuf, (u8 *)&dwRevIVCounter, 3); + memcpy(pbyBuf, (u8 *)&rev_iv_counter, 3); memcpy(pbyBuf + 3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); if (pTransmitKey->uKeyLength == WLAN_WEP40_KEYLEN) { - memcpy(pbyBuf+8, (u8 *)&dwRevIVCounter, 3); - memcpy(pbyBuf+11, pTransmitKey->abyKey, + memcpy(pbyBuf+8, (u8 *)&rev_iv_counter, 3); + memcpy(pbyBuf+11, pTransmitKey->abyKey, pTransmitKey->uKeyLength); } memcpy(pDevice->abyPRNG, pbyBuf, 16); } /* Append IV after Mac Header */ - *pdwIV &= WEP_IV_MASK; - *pdwIV |= (u32)pDevice->byKeyIndex << 30; - *pdwIV = cpu_to_le32(*pdwIV); + *pdwIV &= cpu_to_le32(WEP_IV_MASK); + *pdwIV |= cpu_to_le32((u32)pDevice->byKeyIndex << 30); pDevice->dwIVCounter++; if (pDevice->dwIVCounter > WEP_IV_MASK) @@ -256,7 +253,7 @@ static void s_vFillTxKey(struct vnt_private *pDevice, *(pbyIVHead+3) = (u8)(((pDevice->byKeyIndex << 6) & 0xc0) | 0x20); - *pdwIV |= cpu_to_le16((u16)(pTransmitKey->wTSC15_0)); + *pdwIV |= cpu_to_le32((u32)(pTransmitKey->wTSC15_0)); /* Append IV&ExtIV after Mac Header */ *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16); @@ -283,9 +280,10 @@ static void s_vFillTxKey(struct vnt_private *pDevice, /* MICHDR2 */ memcpy(mic_hdr->addr3, pMACHeader->addr3, ETH_ALEN); - mic_hdr->frame_control = cpu_to_le16(pMACHeader->frame_control - & 0xc78f); - mic_hdr->seq_ctrl = cpu_to_le16(pMACHeader->seq_ctrl & 0xf); + mic_hdr->frame_control = cpu_to_le16( + le16_to_cpu(pMACHeader->frame_control) & 0xc78f); + mic_hdr->seq_ctrl = cpu_to_le16( + le16_to_cpu(pMACHeader->seq_ctrl) & 0xf); if (ieee80211_has_a4(pMACHeader->frame_control)) memcpy(mic_hdr->addr4, pMACHeader->addr4, ETH_ALEN); @@ -305,7 +303,7 @@ static void s_vSWencryption(struct vnt_private *pDevice, if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { //======================================================================= // Append ICV after payload - dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload) + dwICV = ether_crc_le(wPayloadSize, pbyPayloadHead); pdwICV = (u32 *)(pbyPayloadHead + wPayloadSize); // finally, we must invert dwCRC to get the correct answer *pdwICV = cpu_to_le32(~dwICV); @@ -316,7 +314,7 @@ static void s_vSWencryption(struct vnt_private *pDevice, } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { //======================================================================= //Append ICV after payload - dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload) + dwICV = ether_crc_le(wPayloadSize, pbyPayloadHead); pdwICV = (u32 *)(pbyPayloadHead + wPayloadSize); // finally, we must invert dwCRC to get the correct answer *pdwICV = cpu_to_le32(~dwICV); @@ -368,14 +366,14 @@ static __le16 vnt_rxtx_rsvtime_le16(struct vnt_private *priv, u8 pkt_type, //byFreqType: 0=>5GHZ 1=>2.4GHZ static __le16 s_uGetRTSCTSRsvTime(struct vnt_private *priv, - u8 rsv_type, u8 pkt_type, u32 frame_lenght, u16 current_rate) + u8 rsv_type, u8 pkt_type, u32 frame_length, u16 current_rate) { u32 rrv_time, rts_time, cts_time, ack_time, data_time; rrv_time = rts_time = cts_time = ack_time = data_time = 0; data_time = BBuGetFrameTime(priv->byPreambleType, pkt_type, - frame_lenght, current_rate); + frame_length, current_rate); if (rsv_type == 0) { rts_time = BBuGetFrameTime(priv->byPreambleType, @@ -551,7 +549,8 @@ static int vnt_fill_ieee80211_rts(struct vnt_private *priv, __le16 duration) { rts->duration = duration; - rts->frame_control = TYPE_CTL_RTS; + rts->frame_control = + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS); if (priv->op_mode == NL80211_IFTYPE_ADHOC || priv->op_mode == NL80211_IFTYPE_AP) @@ -713,7 +712,7 @@ static u16 s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, return 0; } -static u16 s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, +static u16 s_vFillCTSHead(struct vnt_private *pDevice, u8 byPktType, union vnt_tx_data_head *head, u32 cbFrameLength, int bNeedAck, u16 wCurrentRate, u8 byFBOption) { @@ -741,7 +740,9 @@ static u16 s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, pDevice->tx_rate_fb1, bNeedAck, byFBOption); /* Get CTS Frame body */ pBuf->data.duration = pBuf->duration_ba; - pBuf->data.frame_control = TYPE_CTL_CTS; + pBuf->data.frame_control = + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS); + memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN); return vnt_rxtx_datahead_g_fb(pDevice, byPktType, wCurrentRate, @@ -757,7 +758,9 @@ static u16 s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, wCurrentRate, bNeedAck, byFBOption); /*Get CTS Frame body*/ pBuf->data.duration = pBuf->duration_ba; - pBuf->data.frame_control = TYPE_CTL_CTS; + pBuf->data.frame_control = + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS); + memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN); return vnt_rxtx_datahead_g(pDevice, byPktType, wCurrentRate, @@ -782,7 +785,6 @@ static u16 s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, * pCTS - CTS Buffer * cbFrameSize - Transmit Data Length (Hdr+Payload+FCS) * bNeedACK - If need ACK - * uDMAIdx - DMA Index * Out: * none * @@ -793,14 +795,14 @@ static u16 s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, static u16 s_vGenerateTxParameter(struct vnt_private *pDevice, u8 byPktType, u16 wCurrentRate, struct vnt_tx_buffer *tx_buffer, struct vnt_mic_hdr **mic_hdr, u32 need_mic, u32 cbFrameSize, - int bNeedACK, u32 uDMAIdx, struct ethhdr *psEthHeader, bool need_rts) + int bNeedACK, struct ethhdr *psEthHeader, bool need_rts) { struct vnt_tx_fifo_head *pFifoHead = &tx_buffer->fifo_head; union vnt_tx_data_head *head = NULL; u16 wFifoCtl; u8 byFBOption = AUTO_FB_NONE; - pFifoHead->wReserved = wCurrentRate; + pFifoHead->current_rate = cpu_to_le16(wCurrentRate); wFifoCtl = pFifoHead->wFIFOCtl; if (wFifoCtl & FIFOCTL_AUTO_FB_0) @@ -808,9 +810,6 @@ static u16 s_vGenerateTxParameter(struct vnt_private *pDevice, else if (wFifoCtl & FIFOCTL_AUTO_FB_1) byFBOption = AUTO_FB_1; - if (!pFifoHead) - return 0; - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { if (need_rts) { struct vnt_rrv_time_rts *pBuf = @@ -864,7 +863,7 @@ static u16 s_vGenerateTxParameter(struct vnt_private *pDevice, } /* Fill CTS */ - return s_vFillCTSHead(pDevice, uDMAIdx, byPktType, + return s_vFillCTSHead(pDevice, byPktType, head, cbFrameSize, bNeedACK, wCurrentRate, byFBOption); } @@ -949,12 +948,11 @@ static u16 s_vGenerateTxParameter(struct vnt_private *pDevice, static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, struct vnt_tx_buffer *tx_buffer, int bNeedEncryption, - u32 uSkbPacketLen, u32 uDMAIdx, struct ethhdr *psEthHeader, + u32 uSkbPacketLen, struct ethhdr *psEthHeader, u8 *pPacket, PSKeyItem pTransmitKey, u32 uNodeIndex, u16 wCurrentRate, u32 *pcbHeaderLen, u32 *pcbTotalLen) { struct vnt_tx_fifo_head *pTxBufHead = &tx_buffer->fifo_head; - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; u32 cbFrameSize, cbFrameBodySize; u32 cb802_1_H_len; u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbMACHdLen = 0; @@ -1008,7 +1006,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; } - pTxBufHead->wTimeStamp = DEFAULT_MSDU_LIFETIME_RES_64us; + pTxBufHead->time_stamp = cpu_to_le16(DEFAULT_MSDU_LIFETIME_RES_64us); //Set FRAGCTL_MACHDCNT cbMACHdLen = WLAN_HDR_ADDR3_LEN; @@ -1145,27 +1143,21 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, //========================= DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No Fragmentation...\n"); byFragType = FRAGCTL_NONFRAG; - //uDMAIdx = TYPE_AC0DMA; //pTxBufHead = (PSTxBufHead) &(pTxBufHead->adwTxKey[0]); /* Fill FIFO, RrvTime, RTS and CTS */ uDuration = s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, tx_buffer, &pMICHDR, cbMICHDR, - cbFrameSize, bNeedACK, uDMAIdx, psEthHeader, bRTS); + cbFrameSize, bNeedACK, psEthHeader, bRTS); // Generate TX MAC Header s_vGenerateMACHeader(pDevice, pbyMacHdr, (u16)uDuration, psEthHeader, bNeedEncryption, - byFragType, uDMAIdx, 0); + byFragType, 0); if (bNeedEncryption == true) { //Fill TXKEY s_vFillTxKey(pDevice, pTxBufHead, pbyIVHead, pTransmitKey, pbyMacHdr, (u16)cbFrameBodySize, pMICHDR); - - if (pDevice->bEnableHostWEP) { - pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; - pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; - } } /* 802.1H */ @@ -1287,7 +1279,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, static void s_vGenerateMACHeader(struct vnt_private *pDevice, u8 *pbyBufferAddr, u16 wDuration, struct ethhdr *psEthHeader, - int bNeedEncrypt, u16 wFragType, u32 uDMAIdx, u32 uFragIdx) + int bNeedEncrypt, u16 wFragType, u32 uFragIdx) { struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *)pbyBufferAddr; @@ -1383,38 +1375,39 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, u16 wTxBufSize; u32 cbMacHdLen; u16 wCurrentRate = RATE_1M; + unsigned long flags; - pContext = s_vGetFreeContext(pDevice); + if (pDevice->byBBType == BB_TYPE_11A) { + wCurrentRate = RATE_6M; + byPktType = PK_TYPE_11A; + } else { + wCurrentRate = RATE_1M; + byPktType = PK_TYPE_11B; + } - if (NULL == pContext) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ManagementSend TX...NO CONTEXT!\n"); - return CMD_STATUS_RESOURCES; - } + if (pMgmt->eScanState != WMAC_NO_SCANNING) + vnt_rf_setpower(pDevice, wCurrentRate, pDevice->byCurrentCh); + else + vnt_rf_setpower(pDevice, wCurrentRate, pMgmt->uCurrChannel); + + pDevice->wCurrentRate = wCurrentRate; + + spin_lock_irqsave(&pDevice->lock, flags); + + pContext = s_vGetFreeContext(pDevice); + if (!pContext) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "ManagementSend TX...NO CONTEXT!\n"); + spin_unlock_irqrestore(&pDevice->lock, flags); + return CMD_STATUS_RESOURCES; + } - pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; + pTX_Buffer = (struct vnt_tx_buffer *)&pContext->data[0]; cbFrameBodySize = pPacket->cbPayloadLen; pTxBufHead = &pTX_Buffer->fifo_head; pbyTxBufferAddr = (u8 *)&pTxBufHead->adwTxKey[0]; wTxBufSize = sizeof(struct vnt_tx_fifo_head); - if (pDevice->byBBType == BB_TYPE_11A) { - wCurrentRate = RATE_6M; - byPktType = PK_TYPE_11A; - } else { - wCurrentRate = RATE_1M; - byPktType = PK_TYPE_11B; - } - - // SetPower will cause error power TX state for OFDM Date packet in TX buffer. - // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability. - // And cmd timer will wait data pkt TX finish before scanning so it's OK - // to set power here. - if (pMgmt->eScanState != WMAC_NO_SCANNING) { - RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); - } else { - RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); - } - pDevice->wCurrentRate = wCurrentRate; //Set packet type if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000 @@ -1431,7 +1424,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, } pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN; - pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); + pTxBufHead->time_stamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); if (is_multicast_ether_addr(pPacket->p80211Header->sA3.abyAddr1)) { bNeedACK = false; @@ -1527,7 +1520,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, /* Fill FIFO,RrvTime,RTS,and CTS */ uDuration = s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, pTX_Buffer, &pMICHDR, 0, - cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, false); + cbFrameSize, bNeedACK, &sEthHeader, false); pMACHeader = (struct ieee80211_hdr *) (pbyTxBufferAddr + cbHeaderSize); @@ -1605,13 +1598,13 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, } } - pTX_Buffer->wTxByteCount = cpu_to_le16((u16)(cbReqCount)); + pTX_Buffer->tx_byte_count = cpu_to_le16((u16)(cbReqCount)); pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); pTX_Buffer->byType = 0x00; - pContext->pPacket = NULL; - pContext->type = CONTEXT_MGMT_PACKET; - pContext->uBufLen = (u16)cbReqCount + 4; //USB header + pContext->skb = NULL; + pContext->type = CONTEXT_MGMT_PACKET; + pContext->buf_len = (u16)cbReqCount + 4; /* USB header */ if (WLAN_GET_FC_TODS(pMACHeader->frame_control) == 0) { s_vSaveTxPktInfo(pDevice, (u8)(pTX_Buffer->byPKTNO & 0x0F), @@ -1625,6 +1618,9 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, } PIPEnsSendBulkOut(pDevice,pContext); + + spin_unlock_irqrestore(&pDevice->lock, flags); + return CMD_STATUS_PENDING; } @@ -1649,7 +1645,7 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, return status ; } - pTX_Buffer = (struct vnt_beacon_buffer *)&pContext->Data[0]; + pTX_Buffer = (struct vnt_beacon_buffer *)&pContext->data[0]; short_head = &pTX_Buffer->short_head; cbFrameBodySize = pPacket->cbPayloadLen; @@ -1697,377 +1693,19 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, cbReqCount = cbHeaderSize + WLAN_HDR_ADDR3_LEN + cbFrameBodySize; - pTX_Buffer->wTxByteCount = (u16)cbReqCount; + pTX_Buffer->tx_byte_count = cpu_to_le16((u16)cbReqCount); pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); pTX_Buffer->byType = 0x01; - pContext->pPacket = NULL; - pContext->type = CONTEXT_MGMT_PACKET; - pContext->uBufLen = (u16)cbReqCount + 4; //USB header + pContext->skb = NULL; + pContext->type = CONTEXT_MGMT_PACKET; + pContext->buf_len = (u16)cbReqCount + 4; /* USB header */ PIPEnsSendBulkOut(pDevice,pContext); return CMD_STATUS_PENDING; } -void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - struct vnt_tx_buffer *pTX_Buffer; - struct vnt_tx_fifo_head *pTxBufHead; - u8 byPktType; - u8 *pbyTxBufferAddr; - u32 uDuration, cbReqCount; - struct ieee80211_hdr *pMACHeader; - u32 cbHeaderSize, cbFrameBodySize; - int bNeedACK, bIsPSPOLL = false; - u32 cbFrameSize; - u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbFCSlen = 4; - u32 uPadding = 0; - u32 cbMICHDR = 0, uLength = 0; - u32 dwMICKey0, dwMICKey1; - u32 dwMIC_Priority; - u32 *pdwMIC_L, *pdwMIC_R; - u16 wTxBufSize; - u32 cbMacHdLen; - struct ethhdr sEthHeader; - struct vnt_mic_hdr *pMICHDR; - u32 wCurrentRate = RATE_1M; - PUWLAN_80211HDR p80211Header; - u32 uNodeIndex = 0; - int bNodeExist = false; - SKeyItem STempKey; - PSKeyItem pTransmitKey = NULL; - u8 *pbyIVHead, *pbyPayloadHead, *pbyMacHdr; - u32 cbExtSuppRate = 0; - struct vnt_usb_send_context *pContext; - - pMICHDR = NULL; - - if(skb->len <= WLAN_HDR_ADDR3_LEN) { - cbFrameBodySize = 0; - } - else { - cbFrameBodySize = skb->len - WLAN_HDR_ADDR3_LEN; - } - p80211Header = (PUWLAN_80211HDR)skb->data; - - pContext = s_vGetFreeContext(pDevice); - - if (NULL == pContext) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"DMA0 TX...NO CONTEXT!\n"); - dev_kfree_skb_irq(skb); - return ; - } - - pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; - pTxBufHead = &pTX_Buffer->fifo_head; - pbyTxBufferAddr = (u8 *)&pTxBufHead->adwTxKey[0]; - wTxBufSize = sizeof(struct vnt_tx_fifo_head); - - if (pDevice->byBBType == BB_TYPE_11A) { - wCurrentRate = RATE_6M; - byPktType = PK_TYPE_11A; - } else { - wCurrentRate = RATE_1M; - byPktType = PK_TYPE_11B; - } - - // SetPower will cause error power TX state for OFDM Date packet in TX buffer. - // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability. - // And cmd timer will wait data pkt TX finish before scanning so it's OK - // to set power here. - if (pMgmt->eScanState != WMAC_NO_SCANNING) { - RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); - } else { - RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); - } - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vDMA0_tx_80211: p80211Header->sA3.wFrameCtl = %x \n", p80211Header->sA3.wFrameCtl); - - //Set packet type - if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000 - pTxBufHead->wFIFOCtl = 0; - } - else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_11B; - } - else if (byPktType == PK_TYPE_11GB) {//0000 0010 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_11GB; - } - else if (byPktType == PK_TYPE_11GA) {//0000 0011 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_11GA; - } - - pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN; - pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); - - if (is_multicast_ether_addr(p80211Header->sA3.abyAddr1)) { - bNeedACK = false; - if (pDevice->bEnableHostWEP) { - uNodeIndex = 0; - bNodeExist = true; - } - } - else { - if (pDevice->bEnableHostWEP) { - if (BSSbIsSTAInNodeDB(pDevice, (u8 *)(p80211Header->sA3.abyAddr1), &uNodeIndex)) - bNodeExist = true; - } - bNeedACK = true; - pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; - }; - - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || - (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ) { - - pTxBufHead->wFIFOCtl |= FIFOCTL_LRETRY; - //Set Preamble type always long - //pDevice->byPreambleType = PREAMBLE_LONG; - - // probe-response don't retry - //if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) { - // bNeedACK = false; - // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK); - //} - } - - pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0); - - if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) { - bIsPSPOLL = true; - cbMacHdLen = WLAN_HDR_ADDR2_LEN; - } else { - cbMacHdLen = WLAN_HDR_ADDR3_LEN; - } - - // hostapd daemon ext support rate patch - if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) { - - if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0) { - cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN; - } - - if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0) { - cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN; - } - - if (cbExtSuppRate >0) { - cbFrameBodySize = WLAN_ASSOCRESP_OFF_SUPP_RATES; - } - } - - //Set FRAGCTL_MACHDCNT - pTxBufHead->wFragCtl |= cpu_to_le16((u16)cbMacHdLen << 10); - - // Notes: - // Although spec says MMPDU can be fragmented; In most case, - // no one will send a MMPDU under fragmentation. With RTS may occur. - - if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) { - if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) { - cbIVlen = 4; - cbICVlen = 4; - pTxBufHead->wFragCtl |= FRAGCTL_LEGACY; - } - else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { - cbIVlen = 8;//IV+ExtIV - cbMIClen = 8; - cbICVlen = 4; - pTxBufHead->wFragCtl |= FRAGCTL_TKIP; - //We need to get seed here for filling TxKey entry. - //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr, - // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG); - } - else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { - cbIVlen = 8;//RSN Header - cbICVlen = 8;//MIC - cbMICHDR = sizeof(struct vnt_mic_hdr); - pTxBufHead->wFragCtl |= FRAGCTL_AES; - } - //MAC Header should be padding 0 to DW alignment. - uPadding = 4 - (cbMacHdLen%4); - uPadding %= 4; - } - - cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen + cbExtSuppRate; - - //Set FIFOCTL_GrpAckPolicy - if (pDevice->bGrpAckPolicy == true) {//0000 0100 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; - } - //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter() - - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet - cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR + - sizeof(struct vnt_cts); - - } - else {//802.11a/b packet - cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + - sizeof(struct vnt_tx_datahead_ab); - } - memcpy(&(sEthHeader.h_dest[0]), - &(p80211Header->sA3.abyAddr1[0]), - ETH_ALEN); - memcpy(&(sEthHeader.h_source[0]), - &(p80211Header->sA3.abyAddr2[0]), - ETH_ALEN); - //========================= - // No Fragmentation - //========================= - pTxBufHead->wFragCtl |= (u16)FRAGCTL_NONFRAG; - - /* Fill FIFO,RrvTime,RTS,and CTS */ - uDuration = s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, - pTX_Buffer, &pMICHDR, cbMICHDR, - cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, false); - - pMACHeader = (struct ieee80211_hdr *) (pbyTxBufferAddr + cbHeaderSize); - - cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + (cbFrameBodySize + cbMIClen) + cbExtSuppRate; - - pbyMacHdr = (u8 *)(pbyTxBufferAddr + cbHeaderSize); - pbyPayloadHead = (u8 *)(pbyMacHdr + cbMacHdLen + uPadding + cbIVlen); - pbyIVHead = (u8 *)(pbyMacHdr + cbMacHdLen + uPadding); - - // Copy the Packet into a tx Buffer - memcpy(pbyMacHdr, skb->data, cbMacHdLen); - - // version set to 0, patch for hostapd deamon - pMACHeader->frame_control &= cpu_to_le16(0xfffc); - memcpy(pbyPayloadHead, (skb->data + cbMacHdLen), cbFrameBodySize); - - // replace support rate, patch for hostapd daemon( only support 11M) - if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) { - if (cbExtSuppRate != 0) { - if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0) - memcpy((pbyPayloadHead + cbFrameBodySize), - pMgmt->abyCurrSuppRates, - ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN - ); - if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0) - memcpy((pbyPayloadHead + cbFrameBodySize) + ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN, - pMgmt->abyCurrExtSuppRates, - ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN - ); - } - } - - // Set wep - if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) { - - if (pDevice->bEnableHostWEP) { - pTransmitKey = &STempKey; - pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; - pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; - pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; - pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; - pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; - memcpy(pTransmitKey->abyKey, - &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], - pTransmitKey->uKeyLength - ); - } - - if ((pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { - - dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]); - dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]); - - // DO Software Michael - MIC_vInit(dwMICKey0, dwMICKey1); - MIC_vAppend((u8 *)&(sEthHeader.h_dest[0]), 12); - dwMIC_Priority = 0; - MIC_vAppend((u8 *)&dwMIC_Priority, 4); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"DMA0_tx_8021:MIC KEY:"\ - " %X, %X\n", dwMICKey0, dwMICKey1); - - uLength = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen; - - MIC_vAppend((pbyTxBufferAddr + uLength), cbFrameBodySize); - - pdwMIC_L = (u32 *)(pbyTxBufferAddr + uLength + cbFrameBodySize); - pdwMIC_R = (u32 *)(pbyTxBufferAddr + uLength + cbFrameBodySize + 4); - - MIC_vGetMIC(pdwMIC_L, pdwMIC_R); - MIC_vUnInit(); - - if (pDevice->bTxMICFail == true) { - *pdwMIC_L = 0; - *pdwMIC_R = 0; - pDevice->bTxMICFail = false; - } - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uLength: %d, %d\n", uLength, cbFrameBodySize); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"cbReqCount:%d, %d, %d, %d\n", cbReqCount, cbHeaderSize, uPadding, cbIVlen); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC:%x, %x\n", - *pdwMIC_L, *pdwMIC_R); - - } - - s_vFillTxKey(pDevice, pTxBufHead, pbyIVHead, pTransmitKey, - pbyMacHdr, (u16)cbFrameBodySize, pMICHDR); - - if (pDevice->bEnableHostWEP) { - pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; - pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; - } - - if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) { - s_vSWencryption(pDevice, pTransmitKey, pbyPayloadHead, (u16)(cbFrameBodySize + cbMIClen)); - } - } - - pMACHeader->seq_ctrl = cpu_to_le16(pDevice->wSeqCounter << 4); - pDevice->wSeqCounter++ ; - if (pDevice->wSeqCounter > 0x0fff) - pDevice->wSeqCounter = 0; - - if (bIsPSPOLL) { - // The MAC will automatically replace the Duration-field of MAC header by Duration-field - // of FIFO control header. - // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is - // in the same place of other packet's Duration-field). - // And it will cause Cisco-AP to issue Disassociation-packet - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { - struct vnt_tx_datahead_g *data_head = &pTX_Buffer->tx_head. - tx_cts.tx.head.cts_g.data_head; - data_head->duration_a = - cpu_to_le16(p80211Header->sA2.wDurationID); - data_head->duration_b = - cpu_to_le16(p80211Header->sA2.wDurationID); - } else { - struct vnt_tx_datahead_ab *data_head = &pTX_Buffer->tx_head. - tx_ab.tx.head.data_head_ab; - data_head->duration = - cpu_to_le16(p80211Header->sA2.wDurationID); - } - } - - pTX_Buffer->wTxByteCount = cpu_to_le16((u16)(cbReqCount)); - pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); - pTX_Buffer->byType = 0x00; - - pContext->pPacket = skb; - pContext->type = CONTEXT_MGMT_PACKET; - pContext->uBufLen = (u16)cbReqCount + 4; //USB header - - if (WLAN_GET_FC_TODS(pMACHeader->frame_control) == 0) { - s_vSaveTxPktInfo(pDevice, (u8)(pTX_Buffer->byPKTNO & 0x0F), - &pMACHeader->addr1[0], (u16)cbFrameSize, - pTxBufHead->wFIFOCtl); - } - else { - s_vSaveTxPktInfo(pDevice, (u8)(pTX_Buffer->byPKTNO & 0x0F), - &pMACHeader->addr3[0], (u16)cbFrameSize, - pTxBufHead->wFIFOCtl); - } - PIPEnsSendBulkOut(pDevice,pContext); - return ; - -} - //TYPE_AC0DMA data tx /* * Description: @@ -2083,8 +1721,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) * Return Value: NULL */ -int nsDMA_tx_packet(struct vnt_private *pDevice, - u32 uDMAIdx, struct sk_buff *skb) +int nsDMA_tx_packet(struct vnt_private *pDevice, struct sk_buff *skb) { struct net_device_stats *pStats = &pDevice->stats; struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; @@ -2096,7 +1733,6 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, u8 byPktType; int bNeedEncryption = false; PSKeyItem pTransmitKey = NULL; - SKeyItem STempKey; int ii; int bTKIP_UseGTK = false; int bNeedDeAuth = false; @@ -2173,15 +1809,7 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, } } - pContext = s_vGetFreeContext(pDevice); - - if (pContext == NULL) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG" pContext == NULL\n"); - dev_kfree_skb_irq(skb); - return STATUS_RESOURCES; - } - - memcpy(pDevice->sTxEthHeader.h_dest, (u8 *)(skb->data), ETH_HLEN); + memcpy(&pDevice->sTxEthHeader, skb->data, ETH_HLEN); //mike add:station mode check eapol-key challenge---> { @@ -2268,22 +1896,6 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, } while(false); } - if (pDevice->bEnableHostWEP) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"acdma0: STA index %d\n", uNodeIndex); - if (pDevice->bEncryptionEnable == true) { - pTransmitKey = &STempKey; - pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; - pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; - pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; - pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; - pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; - memcpy(pTransmitKey->abyKey, - &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], - pTransmitKey->uKeyLength - ); - } - } - byPktType = (u8)pDevice->byPacketType; if (pDevice->bFixRate) { @@ -2346,12 +1958,10 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, if (pDevice->sTxEthHeader.h_proto == cpu_to_be16(ETH_P_PAE)) { if (pDevice->byBBType != BB_TYPE_11A) { pDevice->wCurrentRate = RATE_1M; - pDevice->byACKRate = RATE_1M; pDevice->byTopCCKBasicRate = RATE_1M; pDevice->byTopOFDMBasicRate = RATE_6M; } else { pDevice->wCurrentRate = RATE_6M; - pDevice->byACKRate = RATE_6M; pDevice->byTopCCKBasicRate = RATE_1M; pDevice->byTopOFDMBasicRate = RATE_6M; } @@ -2389,21 +1999,11 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, } } } - - if (pDevice->bEnableHostWEP) { - if ((uNodeIndex != 0) && - (pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex & PAIRWISE_KEY)) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Find PTK [%X]\n", - pTransmitKey->dwKeyIndex); - bNeedEncryption = true; - } - } } else { if (pTransmitKey == NULL) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"return no tx key\n"); - pContext->bBoolInUse = false; dev_kfree_skb_irq(skb); pStats->tx_dropped++; return STATUS_FAILURE; @@ -2411,21 +2011,28 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, } } - pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; + pContext = s_vGetFreeContext(pDevice); + if (!pContext) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG" pContext == NULL\n"); + dev_kfree_skb_irq(skb); + return STATUS_RESOURCES; + } + + pTX_Buffer = (struct vnt_tx_buffer *)&pContext->data[0]; fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType, pTX_Buffer, bNeedEncryption, - skb->len, uDMAIdx, &pDevice->sTxEthHeader, + skb->len, &pDevice->sTxEthHeader, (u8 *)skb->data, pTransmitKey, uNodeIndex, pDevice->wCurrentRate, &uHeaderLen, &BytesToWrite ); - if (fConvertedPacket == false) { - pContext->bBoolInUse = false; - dev_kfree_skb_irq(skb); - return STATUS_FAILURE; - } + if (fConvertedPacket == false) { + pContext->in_use = false; + dev_kfree_skb_irq(skb); + return STATUS_FAILURE; + } if ( pDevice->bEnablePSMode == true ) { if ( !pDevice->bPSModeTxBurst ) { @@ -2437,11 +2044,11 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, } pTX_Buffer->byPKTNO = (u8) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); - pTX_Buffer->wTxByteCount = (u16)BytesToWrite; + pTX_Buffer->tx_byte_count = cpu_to_le16((u16)BytesToWrite); - pContext->pPacket = skb; - pContext->type = CONTEXT_DATA_PACKET; - pContext->uBufLen = (u16)BytesToWrite + 4 ; //USB header + pContext->skb = skb; + pContext->type = CONTEXT_DATA_PACKET; + pContext->buf_len = (u16)BytesToWrite + 4 ; /* USB header */ s_vSaveTxPktInfo(pDevice, (u8)(pTX_Buffer->byPKTNO & 0x0F), &pDevice->sTxEthHeader.h_dest[0], @@ -2456,154 +2063,12 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, bScheduleCommand((void *) pDevice, WLAN_CMD_DEAUTH, (u8 *) &wReason); } - if(status!=STATUS_PENDING) { - pContext->bBoolInUse = false; - dev_kfree_skb_irq(skb); - return STATUS_FAILURE; - } - else - return 0; - -} - -/* - * Description: - * Relay packet send (AC1DMA) from rx dpc. - * - * Parameters: - * In: - * pDevice - Pointer to the adapter - * pPacket - Pointer to rx packet - * cbPacketSize - rx ethernet frame size - * Out: - * TURE, false - * - * Return Value: Return true if packet is copy to dma1; otherwise false - */ - -int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, - u32 uNodeIndex) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - struct vnt_tx_buffer *pTX_Buffer; - u32 BytesToWrite = 0, uHeaderLen = 0; - u8 byPktType = PK_TYPE_11B; - int bNeedEncryption = false; - SKeyItem STempKey; - PSKeyItem pTransmitKey = NULL; - u8 *pbyBSSID; - struct vnt_usb_send_context *pContext; - u8 byPktTyp; - int fConvertedPacket; - u32 status; - u16 wKeepRate = pDevice->wCurrentRate; - - pContext = s_vGetFreeContext(pDevice); - - if (NULL == pContext) { - return false; - } - - memcpy(pDevice->sTxEthHeader.h_dest, (u8 *)pbySkbData, ETH_HLEN); - - if (pDevice->bEncryptionEnable == true) { - bNeedEncryption = true; - // get group key - pbyBSSID = pDevice->abyBroadcastAddr; - if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) { - pTransmitKey = NULL; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"KEY is NULL. [%d]\n", pMgmt->eCurrMode); - } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n"); - } - } - - if (pDevice->bEnableHostWEP) { - if (uNodeIndex < MAX_NODE_NUM + 1) { - pTransmitKey = &STempKey; - pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; - pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; - pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; - pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; - pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; - memcpy(pTransmitKey->abyKey, - &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], - pTransmitKey->uKeyLength - ); - } - } - - if ( bNeedEncryption && (pTransmitKey == NULL) ) { - pContext->bBoolInUse = false; - return false; - } - - byPktTyp = (u8)pDevice->byPacketType; - - if (pDevice->bFixRate) { - if (pDevice->byBBType == BB_TYPE_11B) { - if (pDevice->uConnectionRate >= RATE_11M) { - pDevice->wCurrentRate = RATE_11M; - } else { - pDevice->wCurrentRate = (u16)pDevice->uConnectionRate; - } - } else { - if ((pDevice->byBBType == BB_TYPE_11A) && - (pDevice->uConnectionRate <= RATE_6M)) { - pDevice->wCurrentRate = RATE_6M; - } else { - if (pDevice->uConnectionRate >= RATE_54M) - pDevice->wCurrentRate = RATE_54M; - else - pDevice->wCurrentRate = (u16)pDevice->uConnectionRate; - } - } - } - else { - pDevice->wCurrentRate = pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate; - } - - if (wKeepRate != pDevice->wCurrentRate) { - bScheduleCommand((void *) pDevice, WLAN_CMD_SETPOWER, NULL); - } - - if (pDevice->wCurrentRate <= RATE_11M) - byPktType = PK_TYPE_11B; - - BytesToWrite = uDataLen + ETH_FCS_LEN; - - // Convert the packet to an usb frame and copy into our buffer - // and send the irp. - - pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; - - fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType, - pTX_Buffer, bNeedEncryption, - uDataLen, TYPE_AC0DMA, &pDevice->sTxEthHeader, - pbySkbData, pTransmitKey, uNodeIndex, - pDevice->wCurrentRate, - &uHeaderLen, &BytesToWrite - ); - - if (fConvertedPacket == false) { - pContext->bBoolInUse = false; - return false; - } - - pTX_Buffer->byPKTNO = (u8) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); - pTX_Buffer->wTxByteCount = (u16)BytesToWrite; - - pContext->pPacket = NULL; - pContext->type = CONTEXT_DATA_PACKET; - pContext->uBufLen = (u16)BytesToWrite + 4 ; //USB header - - s_vSaveTxPktInfo(pDevice, (u8)(pTX_Buffer->byPKTNO & 0x0F), - &pDevice->sTxEthHeader.h_dest[0], - (u16)(BytesToWrite - uHeaderLen), - pTX_Buffer->fifo_head.wFIFOCtl); + if (status != STATUS_PENDING) { + pContext->in_use = false; + dev_kfree_skb_irq(skb); + return STATUS_FAILURE; + } - status = PIPEnsSendBulkOut(pDevice,pContext); - return true; + return 0; } - diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 6d6539d29d0..6db3337f1d1 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -217,15 +217,15 @@ union vnt_tx_head { struct vnt_tx_fifo_head { u32 adwTxKey[4]; u16 wFIFOCtl; - u16 wTimeStamp; + __le16 time_stamp; u16 wFragCtl; - u16 wReserved; + __le16 current_rate; } __packed; struct vnt_tx_buffer { u8 byType; u8 byPKTNO; - u16 wTxByteCount; + __le16 tx_byte_count; struct vnt_tx_fifo_head fifo_head; union vnt_tx_head tx_head; } __packed; @@ -241,16 +241,14 @@ struct vnt_tx_short_buf_head { struct vnt_beacon_buffer { u8 byType; u8 byPKTNO; - u16 wTxByteCount; + __le16 tx_byte_count; struct vnt_tx_short_buf_head short_head; struct ieee80211_hdr hdr; } __packed; void vDMA0_tx_80211(struct vnt_private *, struct sk_buff *skb); -int nsDMA_tx_packet(struct vnt_private *, u32 uDMAIdx, struct sk_buff *skb); +int nsDMA_tx_packet(struct vnt_private *, struct sk_buff *skb); CMD_STATUS csMgmt_xmit(struct vnt_private *, struct vnt_tx_mgmt *); CMD_STATUS csBeacon_xmit(struct vnt_private *, struct vnt_tx_mgmt *); -int bRelayPacketSend(struct vnt_private *, u8 *pbySkbData, u32 uDataLen, - u32 uNodeIndex); #endif /* __RXTX_H__ */ diff --git a/drivers/staging/vt6656/srom.h b/drivers/staging/vt6656/srom.h deleted file mode 100644 index 488192d79ac..00000000000 --- a/drivers/staging/vt6656/srom.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: srom.h - * - * Purpose: Implement functions to access eeprom - * - * Author: Jerry Chen - * - * Date: Jan 29, 2003 - * - */ - -#ifndef __SROM_H__ -#define __SROM_H__ - -#define EEP_MAX_CONTEXT_SIZE 256 - -#define CB_EEPROM_READBYTE_WAIT 900 //us - -#define W_MAX_I2CRETRY 0x0fff - -// -// Contents in the EEPROM -// -#define EEP_OFS_PAR 0x00 // physical address -#define EEP_OFS_ANTENNA 0x17 -#define EEP_OFS_RADIOCTL 0x18 -#define EEP_OFS_RFTYPE 0x1B // for select RF -#define EEP_OFS_MINCHANNEL 0x1C // Min Channel # -#define EEP_OFS_MAXCHANNEL 0x1D // Max Channel # -#define EEP_OFS_SIGNATURE 0x1E // -#define EEP_OFS_ZONETYPE 0x1F // -#define EEP_OFS_RFTABLE 0x20 // RF POWER TABLE -#define EEP_OFS_PWR_CCK 0x20 -#define EEP_OFS_SETPT_CCK 0x21 -#define EEP_OFS_PWR_OFDMG 0x23 - -#define EEP_OFS_CALIB_TX_IQ 0x24 -#define EEP_OFS_CALIB_TX_DC 0x25 -#define EEP_OFS_CALIB_RX_IQ 0x26 - -#define EEP_OFS_MAJOR_VER 0x2E -#define EEP_OFS_MINOR_VER 0x2F - -#define EEP_OFS_CCK_PWR_TBL 0x30 -#define EEP_OFS_OFDM_PWR_TBL 0x40 -#define EEP_OFS_OFDMA_PWR_TBL 0x50 - -// -// Bits in EEP_OFS_ANTENNA -// -#define EEP_ANTENNA_MAIN 0x01 -#define EEP_ANTENNA_AUX 0x02 -#define EEP_ANTINV 0x04 - -// -// Bits in EEP_OFS_RADIOCTL -// -#define EEP_RADIOCTL_ENABLE 0x80 - -// AT24C02 eeprom contents -// 2048 bits = 256 bytes = 128 words -// -typedef struct tagSSromReg { - u8 abyPAR[6]; // 0x00 (u16) - - u16 wSUB_VID; // 0x03 (u16) - u16 wSUB_SID; - - u8 byBCFG0; // 0x05 (u16) - u8 byBCFG1; - - u8 byFCR0; // 0x06 (u16) - u8 byFCR1; - u8 byPMC0; // 0x07 (u16) - u8 byPMC1; - u8 byMAXLAT; // 0x08 (u16) - u8 byMINGNT; - u8 byCFG0; // 0x09 (u16) - u8 byCFG1; - u16 wCISPTR; // 0x0A (u16) - u16 wRsv0; // 0x0B (u16) - u16 wRsv1; // 0x0C (u16) - u8 byBBPAIR; // 0x0D (u16) - u8 byRFTYPE; - u8 byMinChannel; // 0x0E (u16) - u8 byMaxChannel; - u8 bySignature; // 0x0F (u16) - u8 byCheckSum; - - u8 abyReserved0[96]; // 0x10 (u16) - u8 abyCIS[128]; // 0x80 (u16) -} SSromReg, *PSSromReg; - -#endif /* __EEPROM_H__ */ diff --git a/drivers/staging/vt6656/tcrc.c b/drivers/staging/vt6656/tcrc.c deleted file mode 100644 index 7229f26c052..00000000000 --- a/drivers/staging/vt6656/tcrc.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2003 VIA Networking, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: tcrc.c - * - * Purpose: Implement functions to calculate CRC - * - * Author: Tevin Chen - * - * Date: May 21, 1996 - * - * Functions: - * CRCdwCrc32 - - * CRCdwGetCrc32 - - * CRCdwGetCrc32Ex - - * - * Revision History: - * - */ - -#include "tcrc.h" - -/* 32-bit CRC table */ -static const u32 s_adwCrc32Table[256] = { - 0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL, - 0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L, - 0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L, - 0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L, - 0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL, - 0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L, - 0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL, - 0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L, - 0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L, - 0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL, - 0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L, - 0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L, - 0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L, - 0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL, - 0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L, - 0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL, - 0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL, - 0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L, - 0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L, - 0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L, - 0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL, - 0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L, - 0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL, - 0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L, - 0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L, - 0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL, - 0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L, - 0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L, - 0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L, - 0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL, - 0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L, - 0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL, - 0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL, - 0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L, - 0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L, - 0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L, - 0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL, - 0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L, - 0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL, - 0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L, - 0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L, - 0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL, - 0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L, - 0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L, - 0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L, - 0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL, - 0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L, - 0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL, - 0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL, - 0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L, - 0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L, - 0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L, - 0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL, - 0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L, - 0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL, - 0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L, - 0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L, - 0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL, - 0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L, - 0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L, - 0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L, - 0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL, - 0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L, - 0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL -}; - -/*+ - * - * Description: - * Generate a CRC-32 from the data stream - * - * Parameters: - * In: - * pbyData - the data stream - * cbByte - the length of the stream - * dwCrcSeed - Seed for CRC32 - * Out: - * none - * - * Return Value: CRC-32 - * --*/ -u32 CRCdwCrc32(u8 * pbyData, unsigned int cbByte, u32 dwCrcSeed) -{ - u32 dwCrc; - - dwCrc = dwCrcSeed; - while (cbByte--) { - dwCrc = s_adwCrc32Table[(u8)((dwCrc ^ (*pbyData)) & 0xFF)] ^ - (dwCrc >> 8); - pbyData++; - } - - return dwCrc; -} - -/*+ - * - * Description: - * To test CRC generator, input 8 bytes packet - * -- 0xff 0xff 0xff 0xff 0x00 0x00 0x00 0x00 - * the generated CRC should be - * -- 0xff 0xff 0xff 0xff - * - * Parameters: - * In: - * pbyData - the data stream - * cbByte - the length of the stream - * Out: - * none - * - * Return Value: CRC-32 - * --*/ -u32 CRCdwGetCrc32(u8 * pbyData, unsigned int cbByte) -{ - return ~CRCdwCrc32(pbyData, cbByte, 0xFFFFFFFFL); -} - -/*+ - * - * Description: - * - * NOTE.... Because CRCdwGetCrc32Ex() is an iteration function, - * this means we will use the output of CRCdwGetCrc32Ex() - * to be a new argument to do next CRCdwGetCrc32Ex() calculation. - * Thus, the final result must be inverted to be the - * correct answer. - * - * Parameters: - * In: - * pbyData - the data stream - * cbByte - the length of the stream - * Out: - * none - * - * Return Value: CRC-32 - * --*/ -u32 CRCdwGetCrc32Ex(u8 * pbyData, unsigned int cbByte, u32 dwPreCRC) -{ - return CRCdwCrc32(pbyData, cbByte, dwPreCRC); -} - diff --git a/drivers/staging/vt6656/tcrc.h b/drivers/staging/vt6656/tcrc.h deleted file mode 100644 index 5b1f368964e..00000000000 --- a/drivers/staging/vt6656/tcrc.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2003 VIA Networking, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: tcrc.h - * - * Purpose: Implement functions to calculate CRC - * - * Author: Tevin Chen - * - * Date: Jan. 28, 1997 - * - */ - -#ifndef __TCRC_H__ -#define __TCRC_H__ - -#include <linux/types.h> - -u32 CRCdwCrc32(u8 * pbyData, unsigned int cbByte, u32 dwCrcSeed); -u32 CRCdwGetCrc32(u8 * pbyData, unsigned int cbByte); -u32 CRCdwGetCrc32Ex(u8 * pbyData, unsigned int cbByte, u32 dwPreCRC); - -#endif /* __TCRC_H__ */ diff --git a/drivers/staging/vt6656/tether.c b/drivers/staging/vt6656/tether.c index 1db1e8419a9..2ef54f608cb 100644 --- a/drivers/staging/vt6656/tether.c +++ b/drivers/staging/vt6656/tether.c @@ -33,7 +33,6 @@ #include "device.h" #include "tmacro.h" -#include "tcrc.h" #include "tether.h" /* @@ -51,11 +50,11 @@ */ bool ETHbIsBufferCrc32Ok(u8 * pbyBuffer, unsigned int cbFrameLength) { - u32 dwCRC; + u32 n_crc = ~ether_crc_le(cbFrameLength - 4, pbyBuffer); - dwCRC = CRCdwGetCrc32(pbyBuffer, cbFrameLength - 4); - if (cpu_to_le32(*((u32 *)(pbyBuffer + cbFrameLength - 4))) != dwCRC) + if (le32_to_cpu(*((__le32 *)(pbyBuffer + cbFrameLength - 4))) != n_crc) return false; + return true; } diff --git a/drivers/staging/vt6656/tether.h b/drivers/staging/vt6656/tether.h index aec6b568a4a..f57fcfdc24d 100644 --- a/drivers/staging/vt6656/tether.h +++ b/drivers/staging/vt6656/tether.h @@ -60,8 +60,6 @@ #define TYPE_DATE_NULL 0x4800 #define TYPE_CTL_PSPOLL 0xa400 -#define TYPE_CTL_RTS 0xb400 -#define TYPE_CTL_CTS 0xc400 #define TYPE_CTL_ACK 0xd400 #else //if LITTLE_ENDIAN @@ -91,8 +89,6 @@ #define TYPE_DATE_NULL 0x0048 #define TYPE_CTL_PSPOLL 0x00a4 -#define TYPE_CTL_RTS 0x00b4 -#define TYPE_CTL_CTS 0x00c4 #define TYPE_CTL_ACK 0x00d4 #endif //#ifdef __BIG_ENDIAN diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index c5838d99f89..e4751b71e4d 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -26,10 +26,10 @@ * Date: Mar. 29, 2005 * * Functions: - * CONTROLnsRequestOut - Write variable length bytes to MEM/BB/MAC/EEPROM - * CONTROLnsRequestIn - Read variable length bytes from MEM/BB/MAC/EEPROM - * ControlvWriteByte - Write one byte to MEM/BB/MAC/EEPROM - * ControlvReadByte - Read one byte from MEM/BB/MAC/EEPROM + * vnt_control_out - Write variable length bytes to MEM/BB/MAC/EEPROM + * vnt_control_in - Read variable length bytes from MEM/BB/MAC/EEPROM + * vnt_control_out_u8 - Write one byte to MEM/BB/MAC/EEPROM + * vnt_control_in_u8 - Read one byte from MEM/BB/MAC/EEPROM * ControlvMaskByte - Read one byte from MEM/BB/MAC/EEPROM and clear/set some bits in the same address * * Revision History: @@ -41,9 +41,9 @@ #include "int.h" #include "rxtx.h" #include "dpc.h" -#include "control.h" #include "desc.h" #include "device.h" +#include "usbpipe.h" //endpoint def //endpoint 0: control @@ -51,9 +51,6 @@ //endpoint 2: read bulk //endpoint 3: write bulk -//static int msglevel =MSG_LEVEL_DEBUG; -static int msglevel =MSG_LEVEL_INFO; - #define USB_CTL_WAIT 500 //ms #ifndef URB_ASYNC_UNLINK @@ -63,226 +60,61 @@ static int msglevel =MSG_LEVEL_INFO; static void s_nsInterruptUsbIoCompleteRead(struct urb *urb); static void s_nsBulkInUsbIoCompleteRead(struct urb *urb); static void s_nsBulkOutIoCompleteWrite(struct urb *urb); -static void s_nsControlInUsbIoCompleteRead(struct urb *urb); -static void s_nsControlInUsbIoCompleteWrite(struct urb *urb); -int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest, - u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer) +int vnt_control_out(struct vnt_private *priv, u8 request, u16 value, + u16 index, u16 length, u8 *buffer) { - int ntStatus; - - if (pDevice->Flags & fMP_DISCONNECTED) - return STATUS_FAILURE; - - if (pDevice->Flags & fMP_CONTROL_WRITES) - return STATUS_FAILURE; - - if (in_interrupt()) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"in_interrupt return ..byRequest %x\n", byRequest); - return STATUS_FAILURE; - } - - ntStatus = usb_control_msg( - pDevice->usb, - usb_sndctrlpipe(pDevice->usb , 0), - byRequest, - 0x40, // RequestType - wValue, - wIndex, - (void *) pbyBuffer, - wLength, - HZ - ); - if (ntStatus >= 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe ntStatus= %d\n", ntStatus); - ntStatus = 0; - } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe fail, ntStatus= %d\n", ntStatus); - } - - return ntStatus; -} - -int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue, - u16 wIndex, u16 wLength, u8 *pbyBuffer) - __releases(&pDevice->lock) - __acquires(&pDevice->lock) -{ - int ntStatus = 0; - int ii; - - if (pDevice->Flags & fMP_DISCONNECTED) - return STATUS_FAILURE; - - if (pDevice->Flags & fMP_CONTROL_WRITES) - return STATUS_FAILURE; + int status = 0; - if (pDevice->Flags & fMP_CONTROL_READS) + if (priv->Flags & fMP_DISCONNECTED) return STATUS_FAILURE; - if (pDevice->pControlURB->hcpriv) - return STATUS_FAILURE; + mutex_lock(&priv->usb_lock); - MP_SET_FLAG(pDevice, fMP_CONTROL_WRITES); - - pDevice->sUsbCtlRequest.bRequestType = 0x40; - pDevice->sUsbCtlRequest.bRequest = byRequest; - pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue); - pDevice->sUsbCtlRequest.wIndex = cpu_to_le16p(&wIndex); - pDevice->sUsbCtlRequest.wLength = cpu_to_le16p(&wLength); - pDevice->pControlURB->transfer_flags |= URB_ASYNC_UNLINK; - pDevice->pControlURB->actual_length = 0; - // Notice, pbyBuffer limited point to variable buffer, can't be constant. - usb_fill_control_urb(pDevice->pControlURB, pDevice->usb, - usb_sndctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest, - pbyBuffer, wLength, s_nsControlInUsbIoCompleteWrite, pDevice); - - ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC); - if (ntStatus != 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "control send request submission failed: %d\n", - ntStatus); - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); - return STATUS_FAILURE; - } + status = usb_control_msg(priv->usb, + usb_sndctrlpipe(priv->usb, 0), request, 0x40, value, + index, buffer, length, USB_CTL_WAIT); - spin_unlock_irq(&pDevice->lock); - for (ii = 0; ii <= USB_CTL_WAIT; ii ++) { + mutex_unlock(&priv->usb_lock); - if (pDevice->Flags & fMP_CONTROL_WRITES) - mdelay(1); - else - break; + if (status < (int)length) + return STATUS_FAILURE; - if (ii >= USB_CTL_WAIT) { - DBG_PRT(MSG_LEVEL_DEBUG, - KERN_INFO "control send request submission timeout\n"); - spin_lock_irq(&pDevice->lock); - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); - return STATUS_FAILURE; - } - } - spin_lock_irq(&pDevice->lock); - - return STATUS_SUCCESS; + return STATUS_SUCCESS; } -int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, - u16 wIndex, u16 wLength, u8 *pbyBuffer) - __releases(&pDevice->lock) - __acquires(&pDevice->lock) +void vnt_control_out_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 data) { - int ntStatus = 0; - int ii; - - if (pDevice->Flags & fMP_DISCONNECTED) - return STATUS_FAILURE; - - if (pDevice->Flags & fMP_CONTROL_READS) - return STATUS_FAILURE; - - if (pDevice->Flags & fMP_CONTROL_WRITES) - return STATUS_FAILURE; + vnt_control_out(priv, MESSAGE_TYPE_WRITE, + reg_off, reg, sizeof(u8), &data); +} - if (pDevice->pControlURB->hcpriv) - return STATUS_FAILURE; +int vnt_control_in(struct vnt_private *priv, u8 request, u16 value, + u16 index, u16 length, u8 *buffer) +{ + int status; - MP_SET_FLAG(pDevice, fMP_CONTROL_READS); - - pDevice->sUsbCtlRequest.bRequestType = 0xC0; - pDevice->sUsbCtlRequest.bRequest = byRequest; - pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue); - pDevice->sUsbCtlRequest.wIndex = cpu_to_le16p(&wIndex); - pDevice->sUsbCtlRequest.wLength = cpu_to_le16p(&wLength); - pDevice->pControlURB->transfer_flags |= URB_ASYNC_UNLINK; - pDevice->pControlURB->actual_length = 0; - usb_fill_control_urb(pDevice->pControlURB, pDevice->usb, - usb_rcvctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest, - pbyBuffer, wLength, s_nsControlInUsbIoCompleteRead, pDevice); - - ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC); - if (ntStatus != 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "control request submission failed: %d\n", ntStatus); - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); + if (priv->Flags & fMP_DISCONNECTED) return STATUS_FAILURE; - } - spin_unlock_irq(&pDevice->lock); - for (ii = 0; ii <= USB_CTL_WAIT; ii ++) { + mutex_lock(&priv->usb_lock); - if (pDevice->Flags & fMP_CONTROL_READS) - mdelay(1); - else - break; - - if (ii >= USB_CTL_WAIT) { - DBG_PRT(MSG_LEVEL_DEBUG, - KERN_INFO "control rcv request submission timeout\n"); - spin_lock_irq(&pDevice->lock); - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); - return STATUS_FAILURE; - } - } - spin_lock_irq(&pDevice->lock); - - return ntStatus; -} + status = usb_control_msg(priv->usb, + usb_rcvctrlpipe(priv->usb, 0), request, 0xc0, value, + index, buffer, length, USB_CTL_WAIT); -static void s_nsControlInUsbIoCompleteWrite(struct urb *urb) -{ - struct vnt_private *pDevice = (struct vnt_private *)urb->context; + mutex_unlock(&priv->usb_lock); - pDevice = urb->context; - switch (urb->status) { - case 0: - break; - case -EINPROGRESS: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status EINPROGRESS%d\n", urb->status); - break; - case -ENOENT: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status ENOENT %d\n", urb->status); - break; - default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status %d\n", urb->status); - } + if (status < (int)length) + return STATUS_FAILURE; - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); + return STATUS_SUCCESS; } -/* - * Description: - * Complete function of usb Control callback - * - * Parameters: - * In: - * pDevice - Pointer to the adapter - * - * Out: - * none - * - * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver - * - */ - -static void s_nsControlInUsbIoCompleteRead(struct urb *urb) +void vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data) { - struct vnt_private *pDevice = (struct vnt_private *)urb->context; - - switch (urb->status) { - case 0: - break; - case -EINPROGRESS: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status EINPROGRESS%d\n", urb->status); - break; - case -ENOENT: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status = ENOENT %d\n", urb->status); - break; - default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status %d\n", urb->status); - } - - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); + vnt_control_in(priv, MESSAGE_TYPE_READ, + reg_off, reg, sizeof(u8), data); } /* @@ -303,9 +135,6 @@ int PIPEnsInterruptRead(struct vnt_private *priv) { int status = STATUS_FAILURE; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "---->s_nsStartInterruptUsbRead()\n"); - if (priv->int_buf.in_use == true) return STATUS_FAILURE; @@ -322,14 +151,10 @@ int PIPEnsInterruptRead(struct vnt_private *priv) status = usb_submit_urb(priv->pInterruptURB, GFP_ATOMIC); if (status) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Submit int URB failed %d\n", status); + dev_dbg(&priv->usb->dev, "Submit int URB failed %d\n", status); priv->int_buf.in_use = false; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "<----s_nsStartInterruptUsbRead Return(%x)\n", status); - return status; } @@ -353,9 +178,6 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) struct vnt_private *priv = urb->context; int status; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "---->s_nsInterruptUsbIoCompleteRead\n"); - switch (urb->status) { case 0: case -ETIMEDOUT: @@ -371,22 +193,17 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) status = urb->status; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "s_nsInterruptUsbIoCompleteRead Status %d\n", status); - if (status != STATUS_SUCCESS) { priv->int_buf.in_use = false; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "IntUSBIoCompleteControl STATUS = %d\n", status); + dev_dbg(&priv->usb->dev, "%s status = %d\n", __func__, status); } else { INTnsProcessData(priv); } status = usb_submit_urb(priv->pInterruptURB, GFP_ATOMIC); if (status) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Submit int URB failed %d\n", status); + dev_dbg(&priv->usb->dev, "Submit int URB failed %d\n", status); } else { priv->int_buf.in_use = true; } @@ -413,14 +230,12 @@ int PIPEnsBulkInUsbRead(struct vnt_private *priv, struct vnt_rcb *rcb) int status = 0; struct urb *urb; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartBulkInUsbRead\n"); - if (priv->Flags & fMP_DISCONNECTED) return STATUS_FAILURE; urb = rcb->pUrb; if (rcb->skb == NULL) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"rcb->skb is null\n"); + dev_dbg(&priv->usb->dev, "rcb->skb is null\n"); return status; } @@ -434,8 +249,7 @@ int PIPEnsBulkInUsbRead(struct vnt_private *priv, struct vnt_rcb *rcb) status = usb_submit_urb(urb, GFP_ATOMIC); if (status != 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Submit Rx URB failed %d\n", status); + dev_dbg(&priv->usb->dev, "Submit Rx URB failed %d\n", status); return STATUS_FAILURE ; } @@ -464,10 +278,9 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb) { struct vnt_rcb *rcb = urb->context; struct vnt_private *priv = rcb->pDevice; + unsigned long flags; int re_alloc_skb = false; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n"); - switch (urb->status) { case 0: break; @@ -477,29 +290,29 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb) return; case -ETIMEDOUT: default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "BULK In failed %d\n", urb->status); + dev_dbg(&priv->usb->dev, "BULK In failed %d\n", urb->status); break; } if (urb->actual_length) { - spin_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, flags); if (RXbBulkInProcessData(priv, rcb, urb->actual_length) == true) re_alloc_skb = true; - spin_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, flags); } rcb->Ref--; if (rcb->Ref == 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeNormal %d\n", - priv->NumRecvFreeList); - spin_lock(&priv->lock); + dev_dbg(&priv->usb->dev, + "RxvFreeNormal %d\n", priv->NumRecvFreeList); + + spin_lock_irqsave(&priv->lock, flags); RXvFreeRCB(rcb, re_alloc_skb); - spin_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, flags); } return; @@ -527,28 +340,26 @@ int PIPEnsSendBulkOut(struct vnt_private *priv, priv->bPWBitOn = false; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsSendBulkOut\n"); - if (!(MP_IS_READY(priv) && priv->Flags & fMP_POST_WRITES)) { - context->bBoolInUse = false; + context->in_use = false; return STATUS_RESOURCES; } - urb = context->pUrb; + urb = context->urb; usb_fill_bulk_urb(urb, priv->usb, usb_sndbulkpipe(priv->usb, 3), - context->Data, - context->uBufLen, + context->data, + context->buf_len, s_nsBulkOutIoCompleteWrite, context); status = usb_submit_urb(urb, GFP_ATOMIC); if (status != 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Submit Tx URB failed %d\n", status); - context->bBoolInUse = false; + dev_dbg(&priv->usb->dev, "Submit Tx URB failed %d\n", status); + + context->in_use = false; return STATUS_FAILURE; } @@ -586,25 +397,21 @@ int PIPEnsSendBulkOut(struct vnt_private *priv, static void s_nsBulkOutIoCompleteWrite(struct urb *urb) { struct vnt_usb_send_context *context = urb->context; - struct vnt_private *priv = context->pDevice; + struct vnt_private *priv = context->priv; u8 context_type = context->type; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkOutIoCompleteWrite\n"); - switch (urb->status) { case 0: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Write %d bytes\n", context->uBufLen); + dev_dbg(&priv->usb->dev, "Write %d bytes\n", context->buf_len); break; case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: - context->bBoolInUse = false; + context->in_use = false; return; case -ETIMEDOUT: default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "BULK Out failed %d\n", urb->status); + dev_dbg(&priv->usb->dev, "BULK Out failed %d\n", urb->status); break; } @@ -612,11 +419,11 @@ static void s_nsBulkOutIoCompleteWrite(struct urb *urb) return; if (CONTEXT_DATA_PACKET == context_type) { - if (context->pPacket != NULL) { - dev_kfree_skb_irq(context->pPacket); - context->pPacket = NULL; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "tx %d bytes\n", context->uBufLen); + if (context->skb != NULL) { + dev_kfree_skb_irq(context->skb); + context->skb = NULL; + dev_dbg(&priv->usb->dev, + "tx %d bytes\n", context->buf_len); } priv->dev->trans_start = jiffies; @@ -627,7 +434,7 @@ static void s_nsBulkOutIoCompleteWrite(struct urb *urb) netif_wake_queue(priv->dev); } - context->bBoolInUse = false; + context->in_use = false; return; } diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h index f53770329e7..ea71782d890 100644 --- a/drivers/staging/vt6656/usbpipe.h +++ b/drivers/staging/vt6656/usbpipe.h @@ -32,12 +32,11 @@ #include "device.h" -int PIPEnsControlOut(struct vnt_private *, u8 byRequest, u16 wValue, - u16 wIndex, u16 wLength, u8 *pbyBuffer); -int PIPEnsControlOutAsyn(struct vnt_private *, u8 byRequest, - u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer); -int PIPEnsControlIn(struct vnt_private *, u8 byRequest, u16 wValue, - u16 wIndex, u16 wLength, u8 *pbyBuffer); +int vnt_control_out(struct vnt_private *, u8, u16, u16, u16, u8 *); +int vnt_control_in(struct vnt_private *, u8, u16, u16, u16, u8 *); + +void vnt_control_out_u8(struct vnt_private *, u8, u8, u8); +void vnt_control_in_u8(struct vnt_private *, u8, u8, u8 *); int PIPEnsInterruptRead(struct vnt_private *); int PIPEnsBulkInUsbRead(struct vnt_private *, struct vnt_rcb *pRCB); diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index 3cf3f24247a..da72d4df6fc 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -48,10 +48,9 @@ #include "power.h" #include "wctl.h" #include "baseband.h" -#include "control.h" +#include "usbpipe.h" #include "rxtx.h" #include "rf.h" -#include "rndis.h" #include "channel.h" #include "iowpa.h" @@ -279,6 +278,7 @@ void vRunCommand(struct work_struct *work) int ii; u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; u8 byData; + unsigned long flags; if (pDevice->Flags & fMP_DISCONNECTED) return; @@ -286,8 +286,6 @@ void vRunCommand(struct work_struct *work) if (pDevice->bCmdRunning != true) return; - spin_lock_irq(&pDevice->lock); - switch (pDevice->eCommandState) { case WLAN_CMD_SCAN_START: @@ -346,11 +344,10 @@ void vRunCommand(struct work_struct *work) CARDbSetMediaChannel(pDevice, pMgmt->uScanChannel); // Set Baseband to be more sensitive. - if (pDevice->bUpdateBBVGA) { - BBvSetShortSlotTime(pDevice); - BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]); - BBvUpdatePreEDThreshold(pDevice, true); - } + BBvSetShortSlotTime(pDevice); + BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]); + BBvUpdatePreEDThreshold(pDevice, true); + pMgmt->uScanChannel++; while (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel) && @@ -365,11 +362,9 @@ void vRunCommand(struct work_struct *work) if ((pMgmt->b11hEnable == false) || (pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) { s_vProbeChannel(pDevice); - spin_unlock_irq(&pDevice->lock); vCommandTimerWait((void *) pDevice, 100); return; } else { - spin_unlock_irq(&pDevice->lock); vCommandTimerWait((void *) pDevice, WCMD_PASSIVE_SCAN_TIME); return; } @@ -385,11 +380,9 @@ void vRunCommand(struct work_struct *work) CARDvSetBSSMode(pDevice); } - if (pDevice->bUpdateBBVGA) { - BBvSetShortSlotTime(pDevice); - BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent); - BBvUpdatePreEDThreshold(pDevice, false); - } + BBvSetShortSlotTime(pDevice); + BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent); + BBvUpdatePreEDThreshold(pDevice, false); // Set channel back vAdHocBeaconRestart(pDevice); @@ -433,7 +426,9 @@ void vRunCommand(struct work_struct *work) (8), &Status); pDevice->bLinkPass = false; - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW); + // unlock command busy pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; pItemSSID->len = 0; @@ -479,7 +474,8 @@ void vRunCommand(struct work_struct *work) } netif_stop_queue(pDevice->dev); pDevice->bLinkPass = false; - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW); } // set initial state pMgmt->eCurrState = WMAC_STATE_IDLE; @@ -504,7 +500,6 @@ void vRunCommand(struct work_struct *work) pDevice->byLinkWaitCount = 0; pDevice->eCommandState = WLAN_AUTHENTICATE_WAIT; vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT); - spin_unlock_irq(&pDevice->lock); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n"); return; } @@ -515,7 +510,9 @@ void vRunCommand(struct work_struct *work) if (netif_queue_stopped(pDevice->dev)) netif_wake_queue(pDevice->dev); pDevice->bLinkPass = true; - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_INTER); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER); + pMgmt->sNodeDBTable[0].bActive = true; pMgmt->sNodeDBTable[0].uInActiveCount = 0; } else { @@ -546,7 +543,6 @@ void vRunCommand(struct work_struct *work) s_bClearBSSID_SCAN(pDevice); /* pDevice->bLinkPass = true; - ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); if (netif_queue_stopped(pDevice->dev)){ netif_wake_queue(pDevice->dev); } @@ -578,7 +574,6 @@ void vRunCommand(struct work_struct *work) pDevice->byLinkWaitCount = 0; pDevice->eCommandState = WLAN_ASSOCIATE_WAIT; vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT); - spin_unlock_irq(&pDevice->lock); return; } } else if (pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) { @@ -587,7 +582,6 @@ void vRunCommand(struct work_struct *work) //mike add:wait another 2 sec if authenticated_frame delay! pDevice->byLinkWaitCount++; printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount); - spin_unlock_irq(&pDevice->lock); vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT/2); return; } @@ -610,7 +604,9 @@ void vRunCommand(struct work_struct *work) pDevice->byLinkWaitCount = 0; pDevice->byReAssocCount = 0; pDevice->bLinkPass = true; - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_INTER); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER); + s_bClearBSSID_SCAN(pDevice); if (netif_queue_stopped(pDevice->dev)) @@ -622,7 +618,6 @@ void vRunCommand(struct work_struct *work) //mike add:wait another 2 sec if associated_frame delay! pDevice->byLinkWaitCount++; printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount); - spin_unlock_irq(&pDevice->lock); vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT/2); return; } @@ -637,11 +632,11 @@ void vRunCommand(struct work_struct *work) pMgmt->eCurrState = WMAC_STATE_IDLE; pMgmt->eCurrMode = WMAC_MODE_STANDBY; pDevice->bLinkPass = false; - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW); - if (pDevice->bEnableHostWEP == true) - BSSvClearNodeDBTable(pDevice, 1); - else - BSSvClearNodeDBTable(pDevice, 0); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW); + + BSSvClearNodeDBTable(pDevice, 0); + pDevice->uAssocCount = 0; pMgmt->eCurrState = WMAC_STATE_IDLE; pDevice->bFixRate = false; @@ -659,7 +654,9 @@ void vRunCommand(struct work_struct *work) if (netif_queue_stopped(pDevice->dev)) netif_wake_queue(pDevice->dev); pDevice->bLinkPass = true; - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_INTER); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER); + schedule_delayed_work(&pDevice->second_callback_work, HZ); } break; @@ -675,9 +672,13 @@ void vRunCommand(struct work_struct *work) pDevice->bMoreData = true; } - if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) + spin_lock_irqsave(&pDevice->lock, flags); + + if (nsDMA_tx_packet(pDevice, skb) != 0) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Multicast ps tx fail\n"); + spin_unlock_irqrestore(&pDevice->lock, flags); + pMgmt->sNodeDBTable[0].wEnQueueCnt--; } } @@ -698,9 +699,13 @@ void vRunCommand(struct work_struct *work) pDevice->bMoreData = true; } - if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) + spin_lock_irqsave(&pDevice->lock, flags); + + if (nsDMA_tx_packet(pDevice, skb) != 0) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "sta ps tx fail\n"); + spin_unlock_irqrestore(&pDevice->lock, flags); + pMgmt->sNodeDBTable[ii].wEnQueueCnt--; // check if sta ps enable, wait next pspoll // if sta ps disable, send all pending buffers. @@ -729,7 +734,7 @@ void vRunCommand(struct work_struct *work) int ntStatus = STATUS_SUCCESS; u8 byTmp; - ntStatus = CONTROLnsRequestIn(pDevice, + ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_READ, MAC_REG_GPIOCTL1, MESSAGE_REQUEST_MACREG, @@ -752,9 +757,9 @@ void vRunCommand(struct work_struct *work) pDevice->byKeyIndex = 0; pDevice->bTransmitKey = false; - spin_unlock_irq(&pDevice->lock); + KeyvInitTable(pDevice, &pDevice->sKey); - spin_lock_irq(&pDevice->lock); + pMgmt->byCSSPK = KEY_CTL_NONE; pMgmt->byCSSGK = KEY_CTL_NONE; @@ -795,14 +800,17 @@ void vRunCommand(struct work_struct *work) netif_stop_queue(pDevice->dev); CARDbRadioPowerOff(pDevice); MACvRegBitsOn(pDevice, MAC_REG_GPIOCTL1, GPIO3_INTMD); - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_OFF); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_OFF); + pDevice->bHWRadioOff = true; } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_ON........................\n"); pDevice->bHWRadioOff = false; CARDbRadioPowerOn(pDevice); MACvRegBitsOff(pDevice, MAC_REG_GPIOCTL1, GPIO3_INTMD); - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_ON); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_ON); } } @@ -827,7 +835,8 @@ void vRunCommand(struct work_struct *work) case WLAN_CMD_SETPOWER_START: - RFbSetPower(pDevice, pDevice->wCurrentRate, pMgmt->uCurrChannel); + vnt_rf_setpower(pDevice, pDevice->wCurrentRate, + pMgmt->uCurrChannel); break; @@ -853,10 +862,10 @@ void vRunCommand(struct work_struct *work) break; case WLAN_CMD_MAC_DISPOWERSAVING_START: - ControlvReadByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData); + vnt_control_in_u8(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData); if ((byData & PSCTL_PS) != 0) { // disable power saving hw function - CONTROLnsRequestOut(pDevice, + vnt_control_out(pDevice, MESSAGE_TYPE_DISABLE_PS, 0, 0, @@ -882,7 +891,6 @@ void vRunCommand(struct work_struct *work) s_bCommandComplete(pDevice); - spin_unlock_irq(&pDevice->lock); return; } diff --git a/drivers/staging/vt6656/wctl.c b/drivers/staging/vt6656/wctl.c index 814342cd948..efdc5d5d38e 100644 --- a/drivers/staging/vt6656/wctl.c +++ b/drivers/staging/vt6656/wctl.c @@ -70,7 +70,7 @@ bool WCTLbIsDuplicate (PSCache pCache, struct ieee80211_hdr *pMACHeader) pCacheEntry = &(pCache->asCacheEntry[uIndex]); if ((pCacheEntry->wFmSequence == pMACHeader->seq_ctrl) && ether_addr_equal(pCacheEntry->abyAddr2, pMACHeader->addr2) && - (LOBYTE(pCacheEntry->wFrameCtl) == LOBYTE(pMACHeader->frame_control)) + (pCacheEntry->wFrameCtl == pMACHeader->frame_control) ) { /* Duplicate match */ return true; diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c index 0d69719a742..18723eab93d 100644 --- a/drivers/staging/vt6656/wmgr.c +++ b/drivers/staging/vt6656/wmgr.c @@ -78,8 +78,7 @@ #include "wpa.h" #include "rf.h" #include "iowpa.h" -#include "control.h" -#include "rndis.h" +#include "usbpipe.h" static int msglevel = MSG_LEVEL_INFO; //static int msglevel =MSG_LEVEL_DEBUG; @@ -541,10 +540,6 @@ static void s_vMgrRxAssocRequest(struct vnt_private *pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates ); if (pTxPacket != NULL ){ - - if (pDevice->bEnableHostapd) { - return; - } /* send the frame */ Status = csMgmt_xmit(pDevice, pTxPacket); if (Status != CMD_STATUS_PENDING) { @@ -690,9 +685,6 @@ static void s_vMgrRxReAssocRequest(struct vnt_private *pDevice, if (pTxPacket != NULL ){ /* send the frame */ - if (pDevice->bEnableHostapd) { - return; - } Status = csMgmt_xmit(pDevice, pTxPacket); if (Status != CMD_STATUS_PENDING) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:ReAssoc response tx failed\n"); @@ -764,7 +756,8 @@ static void s_vMgrRxAssocResponse(struct vnt_private *pDevice, pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Link with AP(SSID): %s\n", pItemSSID->abySSID); pDevice->bLinkPass = true; - ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER); //if(pDevice->bWPASuppWextEnabled == true) { @@ -1075,9 +1068,6 @@ static void s_vMgrRxAuthenSequence_1(struct vnt_private *pDevice, pTxPacket->cbMPDULen = sFrame.len; pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; // send the frame - if (pDevice->bEnableHostapd) { - return; - } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_1 tx.. \n"); if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_1 tx failed.\n"); @@ -1257,9 +1247,6 @@ reply: pTxPacket->cbMPDULen = sFrame.len; pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; // send the frame - if (pDevice->bEnableHostapd) { - return; - } if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_4 tx failed.\n"); } @@ -1412,7 +1399,8 @@ static void s_vMgrRxDeauthentication(struct vnt_private *pDevice, pMgmt->eCurrState = WMAC_STATE_IDLE; netif_stop_queue(pDevice->dev); pDevice->bLinkPass = false; - ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW); } } @@ -1897,7 +1885,9 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==true) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Current IBSS State: [Started]........to: [Jointed] \n"); pMgmt->eCurrState = WMAC_STATE_JOINTED; pDevice->bLinkPass = true; - ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER); + if (netif_queue_stopped(pDevice->dev)){ netif_wake_queue(pDevice->dev); } @@ -2502,7 +2492,9 @@ void vMgrJoinBSSBegin(struct vnt_private *pDevice, PCMD_STATUS pStatus) // Adopt BSS state in Adapter Device Object pDevice->op_mode = NL80211_IFTYPE_ADHOC; pDevice->bLinkPass = true; - ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER); + memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Join IBSS ok:%pM\n", @@ -2572,7 +2564,6 @@ static void s_vMgrSynchBSS(struct vnt_private *pDevice, u32 uBSSMode, } // Init the BSS informations - pDevice->bCCK = true; pDevice->bProtectMode = false; MACvDisableProtectMD(pDevice); pDevice->bBarkerPreambleMd = false; @@ -2655,8 +2646,7 @@ static void s_vMgrSynchBSS(struct vnt_private *pDevice, u32 uBSSMode, pMgmt->uCurrChannel = pCurr->uChannel; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "<----s_bSynchBSS Set Channel [%d]\n", pCurr->uChannel); - if ((pDevice->bUpdateBBVGA) && - (pDevice->byBBVGACurrent != pDevice->abyBBVGA[0])) { + if (pDevice->byBBVGACurrent != pDevice->abyBBVGA[0]) { pDevice->byBBVGACurrent = pDevice->abyBBVGA[0]; BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent); BBvSetShortSlotTime(pDevice); @@ -2932,16 +2922,6 @@ static struct vnt_tx_mgmt *s_MgrMakeBeacon(struct vnt_private *pDevice, ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN ); } - // hostapd wpa/wpa2 IE - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnableHostapd == true)) { - if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { - if (pMgmt->wWPAIELen != 0) { - sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); - memcpy(sFrame.pRSN, pMgmt->abyWPAIE, pMgmt->wWPAIELen); - sFrame.len += pMgmt->wWPAIELen; - } - } - } /* Adjust the length fields */ pTxPacket->cbMPDULen = sFrame.len; @@ -3052,17 +3032,6 @@ static struct vnt_tx_mgmt *s_MgrMakeProbeResponse(struct vnt_private *pDevice, ); } - // hostapd wpa/wpa2 IE - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnableHostapd == true)) { - if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { - if (pMgmt->wWPAIELen != 0) { - sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); - memcpy(sFrame.pRSN, pMgmt->abyWPAIE, pMgmt->wWPAIELen); - sFrame.len += pMgmt->wWPAIELen; - } - } - } - // Adjust the length fields pTxPacket->cbMPDULen = sFrame.len; pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; @@ -4058,14 +4027,14 @@ int bMgrPrepareBeaconToSend(struct vnt_private *pDevice, struct vnt_manager *pMgmt) { struct vnt_tx_mgmt *pTxPacket; + unsigned long flags; // pDevice->bBeaconBufReady = false; - if (pDevice->bEncryptionEnable || pDevice->bEnable8021x){ - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); - } - else { - pMgmt->wCurrCapInfo &= ~WLAN_SET_CAP_INFO_PRIVACY(1); - } + if (pDevice->bEncryptionEnable) + pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); + else + pMgmt->wCurrCapInfo &= ~WLAN_SET_CAP_INFO_PRIVACY(1); + pTxPacket = s_MgrMakeBeacon ( pDevice, @@ -4084,8 +4053,13 @@ int bMgrPrepareBeaconToSend(struct vnt_private *pDevice, (pMgmt->abyCurrBSSID[0] == 0)) return false; - csBeacon_xmit(pDevice, pTxPacket); - MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX); + spin_lock_irqsave(&pDevice->lock, flags); + + csBeacon_xmit(pDevice, pTxPacket); + + spin_unlock_irqrestore(&pDevice->lock, flags); + + MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX); return true; } diff --git a/drivers/staging/vt6656/wpactl.c b/drivers/staging/vt6656/wpactl.c index f4a8a5cb9fe..0a067151eca 100644 --- a/drivers/staging/vt6656/wpactl.c +++ b/drivers/staging/vt6656/wpactl.c @@ -38,8 +38,7 @@ #include "wmgr.h" #include "iocmd.h" #include "iowpa.h" -#include "control.h" -#include "rndis.h" +#include "usbpipe.h" #include "rf.h" static int msglevel = MSG_LEVEL_INFO; @@ -67,7 +66,7 @@ int wpa_set_keys(struct vnt_private *pDevice, void *ctx) u64 KeyRSC; u8 byKeyDecMode = KEY_CTL_WEP; int ret = 0; - int uu; + u8 uu; int ii; if (param->u.wpa_key.alg_name > WPA_ALG_CCMP) |
