Browse Source

merge new version v4.3.14 from https://github.com/ptpt52/rtl8812au (#160)

pull/161/head
Chen Minqiang Harshavardhana 5 years ago
parent
commit
00aedbde5c
100 changed files with 95159 additions and 27505 deletions
  1. +30
    -19
      CONTRIBUTORS.md
  2. +3
    -3
      Kconfig
  3. +648
    -137
      Makefile
  4. +27
    -0
      Makefile.dkms
  5. +22
    -13
      README.md
  6. +1
    -1
      contributors.sh
  7. +615
    -385
      core/efuse/rtw_efuse.c
  8. +1331
    -1226
      core/rtw_ap.c
  9. +936
    -0
      core/rtw_beamforming.c
  10. +666
    -783
      core/rtw_br_ext.c
  11. +778
    -840
      core/rtw_bt_mp.c
  12. +1726
    -0
      core/rtw_btcoex.c
  13. +1787
    -958
      core/rtw_cmd.c
  14. +1922
    -1614
      core/rtw_debug.c
  15. +80
    -86
      core/rtw_eeprom.c
  16. +709
    -547
      core/rtw_ieee80211.c
  17. +78
    -30
      core/rtw_io.c
  18. +87
    -94
      core/rtw_ioctl_query.c
  19. +188
    -274
      core/rtw_ioctl_rtl.c
  20. +543
    -519
      core/rtw_ioctl_set.c
  21. +71
    -78
      core/rtw_iol.c
  22. +97
    -0
      core/rtw_mem.c
  23. +1966
    -1648
      core/rtw_mlme.c
  24. +5096
    -4315
      core/rtw_mlme_ext.c
  25. +1136
    -700
      core/rtw_mp.c
  26. +397
    -427
      core/rtw_mp_ioctl.c
  27. +326
    -0
      core/rtw_odm.c
  28. +1307
    -1384
      core/rtw_p2p.c
  29. +1446
    -629
      core/rtw_pwrctrl.c
  30. +2108
    -1254
      core/rtw_recv.c
  31. +7
    -11
      core/rtw_rf.c
  32. +1485
    -1207
      core/rtw_security.c
  33. +80
    -77
      core/rtw_sreset.c
  34. +219
    -227
      core/rtw_sta_mgt.c
  35. +1733
    -1826
      core/rtw_tdls.c
  36. +269
    -185
      core/rtw_vht.c
  37. +269
    -344
      core/rtw_wapi.c
  38. +248
    -256
      core/rtw_wapi_sms4.c
  39. +2440
    -1203
      core/rtw_wlan_util.c
  40. +1884
    -1569
      core/rtw_xmit.c
  41. +7
    -7
      dkms.conf
  42. +92
    -96
      hal/HalPwrSeqCmd.c
  43. +1709
    -0
      hal/OUTSRC-BTCoexist/HalBtc8188c2Ant.c
  44. +149
    -0
      hal/OUTSRC-BTCoexist/HalBtc8188c2Ant.h
  45. +1732
    -0
      hal/OUTSRC-BTCoexist/HalBtc8192d2Ant.c
  46. +170
    -0
      hal/OUTSRC-BTCoexist/HalBtc8192d2Ant.h
  47. +2851
    -0
      hal/OUTSRC-BTCoexist/HalBtc8192e1Ant.c
  48. +214
    -0
      hal/OUTSRC-BTCoexist/HalBtc8192e1Ant.h
  49. +3624
    -0
      hal/OUTSRC-BTCoexist/HalBtc8192e2Ant.c
  50. +205
    -0
      hal/OUTSRC-BTCoexist/HalBtc8192e2Ant.h
  51. +1369
    -0
      hal/OUTSRC-BTCoexist/HalBtc8723a1Ant.c
  52. +170
    -0
      hal/OUTSRC-BTCoexist/HalBtc8723a1Ant.h
  53. +3080
    -0
      hal/OUTSRC-BTCoexist/HalBtc8723a2Ant.c
  54. +183
    -0
      hal/OUTSRC-BTCoexist/HalBtc8723a2Ant.h
  55. +4269
    -0
      hal/OUTSRC-BTCoexist/HalBtc8723b1Ant.c
  56. +314
    -0
      hal/OUTSRC-BTCoexist/HalBtc8723b1Ant.h
  57. +4101
    -0
      hal/OUTSRC-BTCoexist/HalBtc8723b2Ant.c
  58. +225
    -0
      hal/OUTSRC-BTCoexist/HalBtc8723b2Ant.h
  59. +2579
    -0
      hal/OUTSRC-BTCoexist/HalBtc8812a1Ant.c
  60. +206
    -0
      hal/OUTSRC-BTCoexist/HalBtc8812a1Ant.h
  61. +4236
    -0
      hal/OUTSRC-BTCoexist/HalBtc8812a2Ant.c
  62. +218
    -0
      hal/OUTSRC-BTCoexist/HalBtc8812a2Ant.h
  63. +3034
    -0
      hal/OUTSRC-BTCoexist/HalBtc8821a1Ant.c
  64. +212
    -0
      hal/OUTSRC-BTCoexist/HalBtc8821a1Ant.h
  65. +3970
    -0
      hal/OUTSRC-BTCoexist/HalBtc8821a2Ant.c
  66. +225
    -0
      hal/OUTSRC-BTCoexist/HalBtc8821a2Ant.h
  67. +3632
    -0
      hal/OUTSRC-BTCoexist/HalBtc8821aCsr2Ant.c
  68. +206
    -0
      hal/OUTSRC-BTCoexist/HalBtc8821aCsr2Ant.h
  69. +777
    -0
      hal/OUTSRC-BTCoexist/HalBtcOutSrc.h
  70. +57
    -0
      hal/OUTSRC-BTCoexist/Mp_Precomp.h
  71. +284
    -250
      hal/OUTSRC/HalPhyRf.c
  72. +19
    -19
      hal/OUTSRC/HalPhyRf.h
  73. +23
    -0
      hal/OUTSRC/Mp_Precomp.h
  74. +834
    -0
      hal/OUTSRC/PhyDM_Adaptivity.c
  75. +141
    -0
      hal/OUTSRC/PhyDM_Adaptivity.h
  76. +332
    -332
      hal/OUTSRC/odm_HWConfig.h
  77. +57
    -57
      hal/OUTSRC/odm_RegDefine11AC.h
  78. +174
    -174
      hal/OUTSRC/odm_RegDefine11N.h
  79. +892
    -892
      hal/OUTSRC/odm_debug.h
  80. +382
    -382
      hal/OUTSRC/odm_interface.h
  81. +304
    -304
      hal/OUTSRC/odm_precomp.h
  82. +123
    -123
      hal/OUTSRC/odm_reg.h
  83. +1670
    -0
      hal/OUTSRC/phydm.c
  84. +1321
    -0
      hal/OUTSRC/phydm.h
  85. +196
    -0
      hal/OUTSRC/phydm_ACS.c
  86. +60
    -0
      hal/OUTSRC/phydm_ACS.h
  87. +1063
    -0
      hal/OUTSRC/phydm_AntDect.c
  88. +95
    -0
      hal/OUTSRC/phydm_AntDect.h
  89. +3651
    -0
      hal/OUTSRC/phydm_AntDiv.c
  90. +533
    -0
      hal/OUTSRC/phydm_AntDiv.h
  91. +323
    -0
      hal/OUTSRC/phydm_CfoTracking.c
  92. +67
    -0
      hal/OUTSRC/phydm_CfoTracking.h
  93. +1787
    -0
      hal/OUTSRC/phydm_DIG.c
  94. +307
    -0
      hal/OUTSRC/phydm_DIG.h
  95. +191
    -0
      hal/OUTSRC/phydm_DynamicBBPowerSaving.c
  96. +62
    -0
      hal/OUTSRC/phydm_DynamicBBPowerSaving.h
  97. +764
    -0
      hal/OUTSRC/phydm_DynamicTxPower.c
  98. +89
    -0
      hal/OUTSRC/phydm_DynamicTxPower.h
  99. +740
    -0
      hal/OUTSRC/phydm_EdcaTurboCheck.c
  100. +98
    -0
      hal/OUTSRC/phydm_EdcaTurboCheck.h

+ 30
- 19
CONTRIBUTORS.md View File

@@ -1,23 +1,34 @@
## Contributors
<!-- DO NOT EDIT - CONTRIBUTORS.md is autogenerated from git commit log by contributors.sh script. -->

- Anand Babu (AB) Periasamy
- Andreas Hofmann
- Andrew Mann
- AndyPi
- Anton
- archshift
- bits3rpent
- Anand Babu (AB) Periasamy
- Andreas Hofmann
- Andrew Mann
- AndyPi
- Anton
- archshift
- bits3rpent
- Chen Minqiang
- Daiki Tamada
- HackDefendr
- Harshavardhana
- Joe Acosta
- John Lenz
- Karl-Philipp Richter
- Marco Milanesi
- mpoly
- pgroenbech
- scrivy
- Vicent Llongo
- Victor Azizi
- Daiki Tamada
- Fjodor42
- gremsto
- HackDefendr
- Harshavardhana
- jjones-jr
- Joe
- Joe Acosta
- John Lenz
- Jos Dehaes
- Karl-Philipp Richter
- Marco Milanesi
- Mauro Ribeiro
- Maximilian Schwerin
- mpoly
- Nick Bartos
- Peter H. Li
- pgroenbech
- scrivy
- Taehan Stott
- Vicent Llongo
- Victor Azizi
- 赵迤晨 (Zhao, Yichen)

+ 3
- 3
Kconfig View File

@@ -1,6 +1,6 @@
config RTL8821AU
tristate "Realtek 8821 USB WiFi"
config RTL8812AU
tristate "Realtek 8812A USB WiFi"
depends on USB
---help---
Help message of RTL8821AU
Help message of RTL8812AU


+ 648
- 137
Makefile
File diff suppressed because it is too large
View File


+ 27
- 0
Makefile.dkms View File

@@ -0,0 +1,27 @@
modname := rtl8812au
DKMS := dkms
modver := 4.3.14

# directory in which generated files are stored
DKMS_DEST := /usr/src/$(modname)-$(modver)

all: install

src_install:
make clean
mkdir -p '$(DKMS_DEST)'
cp -r dkms.conf Kconfig Makefile.dkms Makefile platform core hal include os_dep '$(DKMS_DEST)'
cp Makefile '$(DKMS_DEST)/Makefile'
sed 's/#MODULE_VERSION#/$(modver)/' dkms.conf > '$(DKMS_DEST)/dkms.conf'

build: src_install
$(DKMS) add -m $(modname) -v $(modver) 2>/dev/null || true
$(DKMS) build -m $(modname) -v $(modver)

install: build
$(DKMS) install -m $(modname) -v $(modver)

uninstall:
$(DKMS) remove -m $(modname) -v $(modver) --all

.PHONY: all src_install build install uninstall

+ 22
- 13
README.md View File

@@ -1,23 +1,21 @@
# rtl8812AU_8821AU_linux
# rtl8812au

rtl8812AU_8821AU linux kernel driver for AC1200 (801.11ac) Wireless Dual-Band USB Adapter
Realtek 8812AU/8821AU USB WiFi driver.

## Compiling on Ubuntu 16.04
for AC1200 (801.11ac) Wireless Dual-Band USB Adapter

```cd``` into folder.
This code is base on version 4.3.14 from https://github.com/diederikdehaas/rtl8812AU

```sh
# sudo make
# sudo make install
## Known Supported Devices:

```
* COMFAST 1200Mbps USB Wireless Adapter(Model: CF-912AC)
```

## Compiling with DKMS

```sh
# sudo cp -R . /usr/src/rtl8812AU_8821AU_linux-1.0
# sudo dkms add -m rtl8812AU_8821AU_linux -v 1.0
# sudo dkms build -m rtl8812AU_8821AU_linux -v 1.0
# sudo dkms install -m rtl8812AU_8821AU_linux -v 1.0
# sudo make -f Makefile.dkms install
```

### Compiling for Raspberry Pi
@@ -43,11 +41,11 @@ CONFIG_PLATFORM_ARM_RPI = y
```

```sh
# cd /usr/src/rtl8812AU_8821AU_linux
# cd /usr/src/rtl8812au
# sudo make clean
# sudo make
# sudo make install
# sudo modprobe -a 8812au
# sudo modprobe -a rtl8812au
```

## Contributors
@@ -62,14 +60,25 @@ CONFIG_PLATFORM_ARM_RPI = y
- bits3rpent
- Chen Minqiang
- Daiki Tamada
- Fjodor42
- gremsto
- HackDefendr
- Harshavardhana
- jjones-jr
- Joe
- Joe Acosta
- John Lenz
- Jos Dehaes
- Karl-Philipp Richter
- Marco Milanesi
- Mauro Ribeiro
- Maximilian Schwerin
- mpoly
- Nick Bartos
- Peter H. Li
- pgroenbech
- scrivy
- Taehan Stott
- Vicent Llongo
- Victor Azizi
- 赵迤晨 (Zhao, Yichen)

+ 1
- 1
contributors.sh View File

@@ -11,5 +11,5 @@ cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
<!-- DO NOT EDIT - CONTRIBUTORS.md is autogenerated from git commit log by contributors.sh script. -->
EOH
echo
git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf | cut -f1 -d'<' | sed 's/^/- /g'
git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf | cut -f1 -d'<' | sed 's/^/- /g' | sort | uniq
} > CONTRIBUTORS.md

+ 615
- 385
core/efuse/rtw_efuse.c
File diff suppressed because it is too large
View File


+ 1331
- 1226
core/rtw_ap.c
File diff suppressed because it is too large
View File


+ 936
- 0
core/rtw_beamforming.c View File

@@ -0,0 +1,936 @@
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* 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, USA
*
*
******************************************************************************/
#define _RTW_BEAMFORMING_C_

#include <drv_types.h>
#include <hal_data.h>

#ifdef CONFIG_BEAMFORMING

struct beamforming_entry *beamforming_get_entry_by_addr(struct mlme_priv *pmlmepriv, u8* ra,u8* idx)
{
u8 i = 0;
struct beamforming_info *pBeamInfo = GET_BEAMFORM_INFO(pmlmepriv);

for(i = 0; i < BEAMFORMING_ENTRY_NUM; i++) {
if( pBeamInfo->beamforming_entry[i].bUsed &&
(_rtw_memcmp(ra,pBeamInfo->beamforming_entry[i].mac_addr, ETH_ALEN))) {
*idx = i;
return &(pBeamInfo->beamforming_entry[i]);
}
}

return NULL;
}

BEAMFORMING_CAP beamforming_get_entry_beam_cap_by_mac_id(PVOID pmlmepriv ,u8 mac_id)
{
u8 i = 0;
struct beamforming_info *pBeamInfo = GET_BEAMFORM_INFO((struct mlme_priv *)pmlmepriv);
BEAMFORMING_CAP BeamformEntryCap = BEAMFORMING_CAP_NONE;

for(i = 0; i < BEAMFORMING_ENTRY_NUM; i++) {
if( pBeamInfo->beamforming_entry[i].bUsed &&
(mac_id == pBeamInfo->beamforming_entry[i].mac_id)) {
BeamformEntryCap = pBeamInfo->beamforming_entry[i].beamforming_entry_cap;
i = BEAMFORMING_ENTRY_NUM;
}
}

return BeamformEntryCap;
}

struct beamforming_entry *beamforming_get_free_entry(struct mlme_priv *pmlmepriv, u8* idx)
{
u8 i = 0;
struct beamforming_info *pBeamInfo = GET_BEAMFORM_INFO(pmlmepriv);

for(i = 0; i < BEAMFORMING_ENTRY_NUM; i++) {
if(pBeamInfo->beamforming_entry[i].bUsed == _FALSE) {
*idx = i;
return &(pBeamInfo->beamforming_entry[i]);
}
}
return NULL;
}


struct beamforming_entry *beamforming_add_entry(PADAPTER adapter, u8* ra, u16 aid,
u16 mac_id, CHANNEL_WIDTH bw, BEAMFORMING_CAP beamfrom_cap, u8* idx)
{
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
struct beamforming_entry *pEntry = beamforming_get_free_entry(pmlmepriv, idx);

if(pEntry != NULL) {
pEntry->bUsed = _TRUE;
pEntry->aid = aid;
pEntry->mac_id = mac_id;
pEntry->sound_bw = bw;
if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
u16 BSSID = ((adapter->eeprompriv.mac_addr[5] & 0xf0) >> 4) ^
(adapter->eeprompriv.mac_addr[5] & 0xf); // BSSID[44:47] xor BSSID[40:43]
pEntry->p_aid = (aid + BSSID * 32) & 0x1ff; // (dec(A) + dec(B)*32) mod 512
} else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
pEntry->p_aid = 0;
} else {
pEntry->p_aid = ra[5]; // BSSID[39:47]
pEntry->p_aid = (pEntry->p_aid << 1) | (ra[4] >> 7 );
}
_rtw_memcpy(pEntry->mac_addr, ra, ETH_ALEN);
pEntry->bSound = _FALSE;

//3 TODO SW/FW sound period
pEntry->sound_period = 200;
pEntry->beamforming_entry_cap = beamfrom_cap;
pEntry->beamforming_entry_state = BEAMFORMING_ENTRY_STATE_UNINITIALIZE;

pEntry->LogSeq = 0xff;
pEntry->LogRetryCnt = 0;
pEntry->LogSuccessCnt = 0;
pEntry->LogStatusFailCnt = 0;

return pEntry;
} else
return NULL;
}

BOOLEAN beamforming_remove_entry(struct mlme_priv *pmlmepriv, u8* ra, u8* idx)
{
struct beamforming_entry *pEntry = beamforming_get_entry_by_addr(pmlmepriv, ra, idx);

if(pEntry != NULL) {
pEntry->bUsed = _FALSE;
pEntry->beamforming_entry_cap = BEAMFORMING_CAP_NONE;
pEntry->beamforming_entry_state = BEAMFORMING_ENTRY_STATE_UNINITIALIZE;
return _TRUE;
} else
return _FALSE;
}

/* Used for BeamformingStart_V1 */
void beamforming_dym_ndpa_rate(PADAPTER adapter)
{
u16 NDPARate = MGN_6M;
PHAL_DATA_TYPE pHalData = GET_HAL_DATA(adapter);

if(pHalData->dmpriv.MinUndecoratedPWDBForDM > 30) // link RSSI > 30%
NDPARate = MGN_24M;
else
NDPARate = MGN_6M;

//BW = CHANNEL_WIDTH_20;
NDPARate = NDPARate << 8;
rtw_hal_set_hwreg(adapter, HW_VAR_SOUNDING_RATE, (u8 *)&NDPARate);
}

void beamforming_dym_period(PADAPTER Adapter)
{
u8 Idx;
BOOLEAN bChangePeriod = _FALSE;
u16 SoundPeriod_SW, SoundPeriod_FW;
//PHAL_DATA_TYPE pHalData = GET_HAL_DATA(Adapter);
struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(Adapter);
struct beamforming_entry *pBeamformEntry;
struct beamforming_info *pBeamInfo = GET_BEAMFORM_INFO(( &Adapter->mlmepriv));
struct sounding_info *pSoundInfo = &(pBeamInfo->sounding_info);

//3 TODO per-client throughput caculation.

if(pdvobjpriv->traffic_stat.cur_tx_tp + pdvobjpriv->traffic_stat.cur_rx_tp > 2) {
SoundPeriod_SW = 32*20;
SoundPeriod_FW = 2;
} else {
SoundPeriod_SW = 32*2000;
SoundPeriod_FW = 200;
}

for(Idx = 0; Idx < BEAMFORMING_ENTRY_NUM; Idx++) {
pBeamformEntry = pBeamInfo->beamforming_entry+Idx;
if(pBeamformEntry->bDefaultCSI) {
SoundPeriod_SW = 32*2000;
SoundPeriod_FW = 200;
}

if(pBeamformEntry->beamforming_entry_cap & (BEAMFORMER_CAP_HT_EXPLICIT |BEAMFORMER_CAP_VHT_SU)) {
if(pSoundInfo->sound_mode == SOUNDING_FW_VHT_TIMER || pSoundInfo->sound_mode == SOUNDING_FW_HT_TIMER) {
if(pBeamformEntry->sound_period != SoundPeriod_FW) {
pBeamformEntry->sound_period = SoundPeriod_FW;
bChangePeriod = _TRUE; // Only FW sounding need to send H2C packet to change sound period.
}
} else if(pBeamformEntry->sound_period != SoundPeriod_SW) {
pBeamformEntry->sound_period = SoundPeriod_SW;
}
}
}

if(bChangePeriod)
rtw_hal_set_hwreg(Adapter, HW_VAR_SOUNDING_FW_NDPA, (u8 *)&Idx);
}

u32 beamforming_get_report_frame(PADAPTER Adapter, union recv_frame *precv_frame)
{
u32 ret = _SUCCESS;
struct beamforming_entry *pBeamformEntry = NULL;
struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv);
u8 *pframe = precv_frame->u.hdr.rx_data;
u32 frame_len = precv_frame->u.hdr.len;
u8 *ta;
u8 idx, offset;

//DBG_871X("beamforming_get_report_frame\n");

//Memory comparison to see if CSI report is the same with previous one
ta = GetAddr2Ptr(pframe);
pBeamformEntry = beamforming_get_entry_by_addr(pmlmepriv, ta, &idx);
if(pBeamformEntry->beamforming_entry_cap & BEAMFORMER_CAP_VHT_SU)
offset = 31; //24+(1+1+3)+2 MAC header+(Category+ActionCode+MIMOControlField)+SNR(Nc=2)
else if(pBeamformEntry->beamforming_entry_cap & BEAMFORMER_CAP_HT_EXPLICIT)
offset = 34; //24+(1+1+6)+2 MAC header+(Category+ActionCode+MIMOControlField)+SNR(Nc=2)
else
return ret;

//DBG_871X("%s MacId %d offset=%d\n", __FUNCTION__, pBeamformEntry->mac_id, offset);

if(_rtw_memcmp(pBeamformEntry->PreCsiReport + offset, pframe+offset, frame_len-offset) == _FALSE) {
pBeamformEntry->DefaultCsiCnt = 0;
//DBG_871X("%s CSI report is NOT the same with previos one\n", __FUNCTION__);
} else {
pBeamformEntry->DefaultCsiCnt ++;
//DBG_871X("%s CSI report is the SAME with previos one\n", __FUNCTION__);
}
_rtw_memcpy(&pBeamformEntry->PreCsiReport, pframe, frame_len);

pBeamformEntry->bDefaultCSI = _FALSE;

if(pBeamformEntry->DefaultCsiCnt > 20)
pBeamformEntry->bDefaultCSI = _TRUE;
else
pBeamformEntry->bDefaultCSI = _FALSE;

return ret;
}

void beamforming_get_ndpa_frame(PADAPTER Adapter, union recv_frame *precv_frame)
{
u8 *ta;
u8 idx, Sequence;
u8 *pframe = precv_frame->u.hdr.rx_data;
struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv);
struct beamforming_entry *pBeamformEntry = NULL;

//DBG_871X("beamforming_get_ndpa_frame\n");

if(IS_HARDWARE_TYPE_8812(Adapter) == _FALSE)
return;
else if(GetFrameSubType(pframe) != WIFI_NDPA)
return;

ta = GetAddr2Ptr(pframe);
// Remove signaling TA.
ta[0] = ta[0] & 0xFE;

pBeamformEntry = beamforming_get_entry_by_addr(pmlmepriv, ta, &idx);

if(pBeamformEntry == NULL)
return;
else if(!(pBeamformEntry->beamforming_entry_cap & BEAMFORMEE_CAP_VHT_SU))
return;
else if(pBeamformEntry->LogSuccessCnt > 1)
return;

Sequence = (pframe[16]) >> 2;

if(pBeamformEntry->LogSeq != Sequence) {
/* Previous frame doesn't retry when meet new sequence number */
if(pBeamformEntry->LogSeq != 0xff && pBeamformEntry->LogRetryCnt == 0)
pBeamformEntry->LogSuccessCnt++;

pBeamformEntry->LogSeq = Sequence;
pBeamformEntry->LogRetryCnt = 0;
} else {
if(pBeamformEntry->LogRetryCnt == 3)
beamforming_wk_cmd(Adapter, BEAMFORMING_CTRL_SOUNDING_CLK, NULL, 0, 1);

pBeamformEntry->LogRetryCnt++;
}

DBG_871X("%s LogSeq %d LogRetryCnt %d LogSuccessCnt %d\n",
__FUNCTION__, pBeamformEntry->LogSeq, pBeamformEntry->LogRetryCnt, pBeamformEntry->LogSuccessCnt);
}

BOOLEAN issue_ht_ndpa_packet(PADAPTER Adapter, u8 *ra, CHANNEL_WIDTH bw, u8 qidx)
{
struct xmit_frame *pmgntframe;
struct pkt_attrib *pattrib;
struct rtw_ieee80211_hdr *pwlanhdr;
struct xmit_priv *pxmitpriv = &(Adapter->xmitpriv);
struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
u8 ActionHdr[4] = {ACT_CAT_VENDOR, 0x00, 0xe0, 0x4c};
u8 *pframe;
u16 *fctrl;
u16 duration = 0;
u8 aSifsTime = 0;

if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) {
return _FALSE;
}

//update attribute
pattrib = &pmgntframe->attrib;
update_mgntframe_attrib(Adapter, pattrib);

if (qidx == BCN_QUEUE_INX)
pattrib->qsel = QSLT_BEACON;
pattrib->rate = MGN_MCS8;
pattrib->bwmode = bw;
pattrib->order = 1;
pattrib->subtype = WIFI_ACTION_NOACK;

_rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);

pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;

pwlanhdr = (struct rtw_ieee80211_hdr*)pframe;

fctrl = &pwlanhdr->frame_ctl;
*(fctrl) = 0;

SetOrderBit(pframe);
SetFrameSubType(pframe, WIFI_ACTION_NOACK);

_rtw_memcpy(pwlanhdr->addr1, ra, ETH_ALEN);
_rtw_memcpy(pwlanhdr->addr2, myid(&(Adapter->eeprompriv)), ETH_ALEN);
_rtw_memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);

if( pmlmeext->cur_wireless_mode == WIRELESS_11B)
aSifsTime = 10;
else
aSifsTime = 16;

duration = 2*aSifsTime + 40;

if(bw == CHANNEL_WIDTH_40)
duration+= 87;
else
duration+= 180;

SetDuration(pframe, duration);

//HT control field
SET_HT_CTRL_CSI_STEERING(pframe+24, 3);
SET_HT_CTRL_NDP_ANNOUNCEMENT(pframe+24, 1);

_rtw_memcpy(pframe+28, ActionHdr, 4);

pattrib->pktlen = 32;

pattrib->last_txcmdsz = pattrib->pktlen;

dump_mgntframe(Adapter, pmgntframe);

return _TRUE;
}

BOOLEAN beamforming_send_ht_ndpa_packet(PADAPTER Adapter, u8 *ra, CHANNEL_WIDTH bw, u8 qidx)
{
return issue_ht_ndpa_packet(Adapter, ra, bw, qidx);
}

BOOLEAN issue_vht_ndpa_packet(PADAPTER Adapter, u8 *ra, u16 aid, CHANNEL_WIDTH bw, u8 qidx)
{
struct xmit_frame *pmgntframe;
struct pkt_attrib *pattrib;
struct rtw_ieee80211_hdr *pwlanhdr;
struct xmit_priv *pxmitpriv = &(Adapter->xmitpriv);
struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv);
struct beamforming_info *pBeamInfo = GET_BEAMFORM_INFO(pmlmepriv);
struct rtw_ndpa_sta_info sta_info;
u8 *pframe;
u16 *fctrl;
u16 duration = 0;
u8 sequence = 0, aSifsTime = 0;

if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) {
return _FALSE;
}

//update attribute
pattrib = &pmgntframe->attrib;
update_mgntframe_attrib(Adapter, pattrib);

if (qidx == BCN_QUEUE_INX)
pattrib->qsel = QSLT_BEACON;
pattrib->rate = MGN_VHT2SS_MCS0;
pattrib->bwmode = bw;
pattrib->subtype = WIFI_NDPA;

_rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET);

pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET;

pwlanhdr = (struct rtw_ieee80211_hdr*)pframe;

fctrl = &pwlanhdr->frame_ctl;
*(fctrl) = 0;

SetFrameSubType(pframe, WIFI_NDPA);

_rtw_memcpy(pwlanhdr->addr1, ra, ETH_ALEN);
_rtw_memcpy(pwlanhdr->addr2, myid(&(Adapter->eeprompriv)), ETH_ALEN);

if (IsSupported5G(pmlmeext->cur_wireless_mode) || IsSupportedHT(pmlmeext->cur_wireless_mode))
aSifsTime = 16;
else
aSifsTime = 10;

duration = 2*aSifsTime + 44;

if(bw == CHANNEL_WIDTH_80)
duration += 40;
else if(bw == CHANNEL_WIDTH_40)
duration+= 87;
else
duration+= 180;

SetDuration(pframe, duration);

sequence = pBeamInfo->sounding_sequence<< 2;
if (pBeamInfo->sounding_sequence >= 0x3f)
pBeamInfo->sounding_sequence = 0;
else
pBeamInfo->sounding_sequence++;

_rtw_memcpy(pframe+16, &sequence,1);

if(((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE))
aid = 0;

sta_info.aid = aid;
sta_info.feedback_type = 0;
sta_info.nc_index= 0;

_rtw_memcpy(pframe+17, (u8 *)&sta_info, 2);

pattrib->pktlen = 19;

pattrib->last_txcmdsz = pattrib->pktlen;

dump_mgntframe(Adapter, pmgntframe);

return _TRUE;
}

BOOLEAN beamforming_send_vht_ndpa_packet(PADAPTER Adapter, u8 *ra, u16 aid, CHANNEL_WIDTH bw, u8 qidx)
{
return issue_vht_ndpa_packet(Adapter, ra, aid, bw, qidx);
}

BOOLEAN beamfomring_bSounding(struct beamforming_info *pBeamInfo)
{
BOOLEAN bSounding = _FALSE;

if(( beamforming_get_beamform_cap(pBeamInfo) & BEAMFORMER_CAP) == 0)
bSounding = _FALSE;
else
bSounding = _TRUE;

return bSounding;
}

u8 beamforming_sounding_idx(struct beamforming_info *pBeamInfo)
{
u8 idx = 0;
u8 i;

for(i = 0; i < BEAMFORMING_ENTRY_NUM; i++) {
if (pBeamInfo->beamforming_entry[i].bUsed &&
(_FALSE == pBeamInfo->beamforming_entry[i].bSound)) {
idx = i;
break;
}
}

return idx;
}

SOUNDING_MODE beamforming_sounding_mode(struct beamforming_info *pBeamInfo, u8 idx)
{
struct beamforming_entry BeamEntry = pBeamInfo->beamforming_entry[idx];
SOUNDING_MODE mode;

if(BeamEntry.beamforming_entry_cap & BEAMFORMER_CAP_VHT_SU) {
mode = SOUNDING_FW_VHT_TIMER;
} else if(BeamEntry.beamforming_entry_cap & BEAMFORMER_CAP_HT_EXPLICIT) {
mode = SOUNDING_FW_HT_TIMER;
} else {
mode = SOUNDING_STOP_All_TIMER;
}

return mode;
}

u16 beamforming_sounding_time(struct beamforming_info *pBeamInfo, SOUNDING_MODE mode, u8 idx)
{
u16 sounding_time = 0xffff;
struct beamforming_entry BeamEntry = pBeamInfo->beamforming_entry[idx];

sounding_time = BeamEntry.sound_period;

return sounding_time;
}

CHANNEL_WIDTH beamforming_sounding_bw(struct beamforming_info *pBeamInfo, SOUNDING_MODE mode, u8 idx)
{
CHANNEL_WIDTH sounding_bw = CHANNEL_WIDTH_20;
struct beamforming_entry BeamEntry = pBeamInfo->beamforming_entry[idx];

sounding_bw = BeamEntry.sound_bw;

return sounding_bw;
}

BOOLEAN beamforming_select_beam_entry(struct beamforming_info *pBeamInfo)
{
struct sounding_info *pSoundInfo = &(pBeamInfo->sounding_info);

pSoundInfo->sound_idx = beamforming_sounding_idx(pBeamInfo);

if(pSoundInfo->sound_idx < BEAMFORMING_ENTRY_NUM)
pSoundInfo->sound_mode = beamforming_sounding_mode(pBeamInfo, pSoundInfo->sound_idx);
else
pSoundInfo->sound_mode = SOUNDING_STOP_All_TIMER;

if(SOUNDING_STOP_All_TIMER == pSoundInfo->sound_mode) {
return _FALSE;
} else {
pSoundInfo->sound_bw = beamforming_sounding_bw(pBeamInfo, pSoundInfo->sound_mode, pSoundInfo->sound_idx );
pSoundInfo->sound_period = beamforming_sounding_time(pBeamInfo, pSoundInfo->sound_mode, pSoundInfo->sound_idx );
return _TRUE;
}
}

BOOLEAN beamforming_start_fw(PADAPTER adapter, u8 idx)
{
//u8 *RA = NULL;
struct beamforming_entry *pEntry;
//BOOLEAN ret = _TRUE;
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
struct beamforming_info *pBeamInfo = GET_BEAMFORM_INFO(pmlmepriv);

pEntry = &(pBeamInfo->beamforming_entry[idx]);
if(pEntry->bUsed == _FALSE) {
DBG_871X("Skip Beamforming, no entry for Idx =%d\n", idx);
return _FALSE;
}

pEntry->beamforming_entry_state = BEAMFORMING_ENTRY_STATE_PROGRESSING;
pEntry->bSound = _TRUE;
rtw_hal_set_hwreg(adapter, HW_VAR_SOUNDING_FW_NDPA, (u8 *)&idx);

return _TRUE;
}

void beamforming_end_fw(PADAPTER adapter)
{
u8 idx = 0;

rtw_hal_set_hwreg(adapter, HW_VAR_SOUNDING_FW_NDPA, (u8 *)&idx);

DBG_871X("%s\n", __FUNCTION__);
}

BOOLEAN beamforming_start_period(PADAPTER adapter)
{
BOOLEAN ret = _TRUE;
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
struct beamforming_info *pBeamInfo = GET_BEAMFORM_INFO(pmlmepriv);
struct sounding_info *pSoundInfo = &(pBeamInfo->sounding_info);

beamforming_dym_ndpa_rate(adapter);

beamforming_select_beam_entry(pBeamInfo);

if(pSoundInfo->sound_mode == SOUNDING_FW_VHT_TIMER || pSoundInfo->sound_mode == SOUNDING_FW_HT_TIMER) {
ret = beamforming_start_fw(adapter, pSoundInfo->sound_idx);
} else {
ret = _FALSE;
}

DBG_871X("%s Idx %d Mode %d BW %d Period %d\n", __FUNCTION__,
pSoundInfo->sound_idx, pSoundInfo->sound_mode, pSoundInfo->sound_bw, pSoundInfo->sound_period);

return ret;
}

void beamforming_end_period(PADAPTER adapter)
{
//u8 idx = 0;
//struct beamforming_entry *pBeamformEntry;
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
struct beamforming_info *pBeamInfo = GET_BEAMFORM_INFO(pmlmepriv);
struct sounding_info *pSoundInfo = &(pBeamInfo->sounding_info);


if(pSoundInfo->sound_mode == SOUNDING_FW_VHT_TIMER || pSoundInfo->sound_mode == SOUNDING_FW_HT_TIMER) {
beamforming_end_fw(adapter);
}
}

void beamforming_notify(PADAPTER adapter)
{
BOOLEAN bSounding = _FALSE;
struct beamforming_info *pBeamInfo = GET_BEAMFORM_INFO(&(adapter->mlmepriv));

bSounding = beamfomring_bSounding(pBeamInfo);

if(pBeamInfo->beamforming_state == BEAMFORMING_STATE_IDLE) {
if(bSounding) {
if(beamforming_start_period(adapter) == _TRUE)
pBeamInfo->beamforming_state = BEAMFORMING_STATE_START;
}
} else if(pBeamInfo->beamforming_state == BEAMFORMING_STATE_START) {
if(bSounding) {
if(beamforming_start_period(adapter) == _FALSE)
pBeamInfo->beamforming_state = BEAMFORMING_STATE_END;
} else {
beamforming_end_period(adapter);
pBeamInfo->beamforming_state = BEAMFORMING_STATE_END;
}
} else if(pBeamInfo->beamforming_state == BEAMFORMING_STATE_END) {
if(bSounding) {
if(beamforming_start_period(adapter) == _TRUE)
pBeamInfo->beamforming_state = BEAMFORMING_STATE_START;
}
} else {
DBG_871X("%s BeamformState %d\n", __FUNCTION__, pBeamInfo->beamforming_state);
}

DBG_871X("%s BeamformState %d bSounding %d\n", __FUNCTION__, pBeamInfo->beamforming_state, bSounding);
}

BOOLEAN beamforming_init_entry(PADAPTER adapter, struct sta_info *psta, u8* idx)
{
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
struct ht_priv *phtpriv = &(pmlmepriv->htpriv);
#ifdef CONFIG_80211AC_VHT
struct vht_priv *pvhtpriv = &(pmlmepriv->vhtpriv);
#endif
//struct mlme_ext_priv *pmlmeext = &(adapter->mlmeextpriv);
//struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
struct beamforming_entry *pBeamformEntry = NULL;
u8 *ra;
u16 aid, mac_id;
u8 wireless_mode;
CHANNEL_WIDTH bw = CHANNEL_WIDTH_20;
BEAMFORMING_CAP beamform_cap = BEAMFORMING_CAP_NONE;

// The current setting does not support Beaforming
if (0 == phtpriv->beamform_cap
#ifdef CONFIG_80211AC_VHT
&& 0 == pvhtpriv->beamform_cap
#endif
) {
DBG_871X("The configuration disabled Beamforming! Skip...\n");
return _FALSE;
}

aid = psta->aid;
ra = psta->hwaddr;
mac_id = psta->mac_id;
wireless_mode = psta->wireless_mode;
bw = psta->bw_mode;

if (IsSupportedHT(wireless_mode) || IsSupportedVHT(wireless_mode)) {
//3 // HT
u8 cur_beamform;

cur_beamform = psta->htpriv.beamform_cap;

// We are Beamformee because the STA is Beamformer
if(TEST_FLAG(cur_beamform, BEAMFORMING_HT_BEAMFORMER_ENABLE))
beamform_cap =(BEAMFORMING_CAP)(beamform_cap |BEAMFORMEE_CAP_HT_EXPLICIT);

// We are Beamformer because the STA is Beamformee
if(TEST_FLAG(cur_beamform, BEAMFORMING_HT_BEAMFORMEE_ENABLE))
beamform_cap =(BEAMFORMING_CAP)(beamform_cap | BEAMFORMER_CAP_HT_EXPLICIT);
#ifdef CONFIG_80211AC_VHT
if (IsSupportedVHT(wireless_mode)) {
//3 // VHT
cur_beamform = psta->vhtpriv.beamform_cap;

// We are Beamformee because the STA is Beamformer
if(TEST_FLAG(cur_beamform, BEAMFORMING_VHT_BEAMFORMER_ENABLE))
beamform_cap =(BEAMFORMING_CAP)(beamform_cap |BEAMFORMEE_CAP_VHT_SU);
// We are Beamformer because the STA is Beamformee
if(TEST_FLAG(cur_beamform, BEAMFORMING_VHT_BEAMFORMEE_ENABLE))
beamform_cap =(BEAMFORMING_CAP)(beamform_cap |BEAMFORMER_CAP_VHT_SU);
}
#endif //CONFIG_80211AC_VHT

if(beamform_cap == BEAMFORMING_CAP_NONE)
return _FALSE;

DBG_871X("Beamforming Config Capability = 0x%02X\n", beamform_cap);

pBeamformEntry = beamforming_get_entry_by_addr(pmlmepriv, ra, idx);
if (pBeamformEntry == NULL) {
pBeamformEntry = beamforming_add_entry(adapter, ra, aid, mac_id, bw, beamform_cap, idx);
if(pBeamformEntry == NULL)
return _FALSE;
else
pBeamformEntry->beamforming_entry_state = BEAMFORMING_ENTRY_STATE_INITIALIZEING;
} else {
// Entry has been created. If entry is initialing or progressing then errors occur.
if (pBeamformEntry->beamforming_entry_state != BEAMFORMING_ENTRY_STATE_INITIALIZED &&
pBeamformEntry->beamforming_entry_state != BEAMFORMING_ENTRY_STATE_PROGRESSED) {
DBG_871X("Error State of Beamforming");
return _FALSE;
} else {
pBeamformEntry->beamforming_entry_state = BEAMFORMING_ENTRY_STATE_INITIALIZEING;
}
}

pBeamformEntry->beamforming_entry_state = BEAMFORMING_ENTRY_STATE_INITIALIZED;

DBG_871X("%s Idx %d\n", __FUNCTION__, *idx);
} else {
return _FALSE;
}

return _SUCCESS;
}

void beamforming_deinit_entry(PADAPTER adapter, u8* ra)
{
u8 idx = 0;
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);

if(beamforming_remove_entry(pmlmepriv, ra, &idx) == _TRUE) {
rtw_hal_set_hwreg(adapter, HW_VAR_SOUNDING_LEAVE, (u8 *)&idx);
}

DBG_871X("%s Idx %d\n", __FUNCTION__, idx);
}

void beamforming_reset(PADAPTER adapter)
{
u8 idx = 0;
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
struct beamforming_info *pBeamInfo = GET_BEAMFORM_INFO(pmlmepriv);

for(idx = 0; idx < BEAMFORMING_ENTRY_NUM; idx++) {
if(pBeamInfo->beamforming_entry[idx].bUsed == _TRUE) {
pBeamInfo->beamforming_entry[idx].bUsed = _FALSE;
pBeamInfo->beamforming_entry[idx].beamforming_entry_cap = BEAMFORMING_CAP_NONE;
pBeamInfo->beamforming_entry[idx].beamforming_entry_state= BEAMFORMING_ENTRY_STATE_UNINITIALIZE;
rtw_hal_set_hwreg(adapter, HW_VAR_SOUNDING_LEAVE, (u8 *)&idx);
}
}

DBG_871X("%s\n", __FUNCTION__);
}

void beamforming_sounding_fail(PADAPTER Adapter)
{
struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv);
struct beamforming_info *pBeamInfo = GET_BEAMFORM_INFO(pmlmepriv);
struct beamforming_entry *pEntry = &(pBeamInfo->beamforming_entry[pBeamInfo->beamforming_cur_idx]);

pEntry->bSound = _FALSE;
rtw_hal_set_hwreg(Adapter, HW_VAR_SOUNDING_FW_NDPA, (u8 *)&pBeamInfo->beamforming_cur_idx);
beamforming_deinit_entry(Adapter, pEntry->mac_addr);
}

void beamforming_check_sounding_success(PADAPTER Adapter,BOOLEAN status)
{
struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv);
struct beamforming_info *pBeamInfo = GET_BEAMFORM_INFO(pmlmepriv);
struct beamforming_entry *pEntry = &(pBeamInfo->beamforming_entry[pBeamInfo->beamforming_cur_idx]);

if(status == 1) {
pEntry->LogStatusFailCnt = 0;
} else {
pEntry->LogStatusFailCnt++;
DBG_871X("%s LogStatusFailCnt %d\n", __FUNCTION__, pEntry->LogStatusFailCnt);
}
if(pEntry->LogStatusFailCnt > 20) {
DBG_871X("%s LogStatusFailCnt > 20, Stop SOUNDING\n", __FUNCTION__);
//pEntry->bSound = _FALSE;
//rtw_hal_set_hwreg(Adapter, HW_VAR_SOUNDING_FW_NDPA, (u8 *)&pBeamInfo->beamforming_cur_idx);
//beamforming_deinit_entry(Adapter, pEntry->mac_addr);
beamforming_wk_cmd(Adapter, BEAMFORMING_CTRL_SOUNDING_FAIL, NULL, 0, 1);
}
}

void beamforming_enter(PADAPTER adapter, PVOID psta)
{
u8 idx = 0xff;

if(beamforming_init_entry(adapter, (struct sta_info *)psta, &idx))
rtw_hal_set_hwreg(adapter, HW_VAR_SOUNDING_ENTER, (u8 *)&idx);

//DBG_871X("%s Idx %d\n", __FUNCTION__, idx);
}

void beamforming_leave(PADAPTER adapter,u8* ra)
{
if(ra == NULL)
beamforming_reset(adapter);
else
beamforming_deinit_entry(adapter, ra);

beamforming_notify(adapter);
}

BEAMFORMING_CAP beamforming_get_beamform_cap(struct beamforming_info *pBeamInfo)
{
u8 i;
BOOLEAN bSelfBeamformer = _FALSE;
BOOLEAN bSelfBeamformee = _FALSE;
struct beamforming_entry beamforming_entry;
BEAMFORMING_CAP beamform_cap = BEAMFORMING_CAP_NONE;

for(i = 0; i < BEAMFORMING_ENTRY_NUM; i++) {
beamforming_entry = pBeamInfo->beamforming_entry[i];

if(beamforming_entry.bUsed) {
if( (beamforming_entry.beamforming_entry_cap & BEAMFORMEE_CAP_VHT_SU) ||
(beamforming_entry.beamforming_entry_cap & BEAMFORMEE_CAP_HT_EXPLICIT))
bSelfBeamformee = _TRUE;
if( (beamforming_entry.beamforming_entry_cap & BEAMFORMER_CAP_VHT_SU) ||
(beamforming_entry.beamforming_entry_cap & BEAMFORMER_CAP_HT_EXPLICIT))
bSelfBeamformer = _TRUE;
}

if(bSelfBeamformer && bSelfBeamformee)
i = BEAMFORMING_ENTRY_NUM;
}

if(bSelfBeamformer)
beamform_cap |= BEAMFORMER_CAP;
if(bSelfBeamformee)
beamform_cap |= BEAMFORMEE_CAP;

return beamform_cap;
}

void beamforming_watchdog(PADAPTER Adapter)
{
struct beamforming_info *pBeamInfo = GET_BEAMFORM_INFO(( &(Adapter->mlmepriv)));

if(pBeamInfo->beamforming_state != BEAMFORMING_STATE_START)
return;

beamforming_dym_period(Adapter);
beamforming_dym_ndpa_rate(Adapter);
}

void beamforming_wk_hdl(_adapter *padapter, u8 type, u8 *pbuf)
{

_func_enter_;

switch(type) {
case BEAMFORMING_CTRL_ENTER:
beamforming_enter(padapter, (PVOID)pbuf);
break;

case BEAMFORMING_CTRL_LEAVE:
beamforming_leave(padapter, pbuf);
break;

case BEAMFORMING_CTRL_SOUNDING_FAIL:
beamforming_sounding_fail(padapter);
break;

case BEAMFORMING_CTRL_SOUNDING_CLK:
rtw_hal_set_hwreg(padapter, HW_VAR_SOUNDING_CLK, NULL);
break;

default:
break;
}

_func_exit_;
}

u8 beamforming_wk_cmd(_adapter*padapter, s32 type, u8 *pbuf, s32 size, u8 enqueue)
{
struct cmd_obj *ph2c;
struct drvextra_cmd_parm *pdrvextra_cmd_parm;
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
u8 res = _SUCCESS;

_func_enter_;

if(enqueue) {
u8 *wk_buf;

ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj));
if(ph2c==NULL) {
res= _FAIL;
goto exit;
}

pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm));
if(pdrvextra_cmd_parm==NULL) {
rtw_mfree((unsigned char *)ph2c, sizeof(struct cmd_obj));
res= _FAIL;
goto exit;
}

if (pbuf != NULL) {
wk_buf = rtw_zmalloc(size);
if(wk_buf==NULL) {
rtw_mfree((u8 *)ph2c, sizeof(struct cmd_obj));
rtw_mfree((u8 *)pdrvextra_cmd_parm, sizeof(struct drvextra_cmd_parm));
res= _FAIL;
goto exit;
}

_rtw_memcpy(wk_buf, pbuf, size);
} else {
wk_buf = NULL;
size = 0;
}

pdrvextra_cmd_parm->ec_id = BEAMFORMING_WK_CID;
pdrvextra_cmd_parm->type = type;
pdrvextra_cmd_parm->size = size;
pdrvextra_cmd_parm->pbuf = wk_buf;

init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));

res = rtw_enqueue_cmd(pcmdpriv, ph2c);
} else {
beamforming_wk_hdl(padapter, type, pbuf);
}

exit:

_func_exit_;

return res;
}

#endif //CONFIG_BEAMFORMING

+ 666
- 783
core/rtw_br_ext.c
File diff suppressed because it is too large
View File


+ 778
- 840
core/rtw_bt_mp.c
File diff suppressed because it is too large
View File


+ 1726
- 0
core/rtw_btcoex.c
File diff suppressed because it is too large
View File


+ 1787
- 958
core/rtw_cmd.c
File diff suppressed because it is too large
View File


+ 1922
- 1614
core/rtw_debug.c
File diff suppressed because it is too large
View File


+ 80
- 86
core/rtw_eeprom.c View File

@@ -1,7 +1,7 @@
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
@@ -25,30 +25,30 @@

void up_clk(_adapter* padapter, u16 *x)
{
_func_enter_;
_func_enter_;
*x = *x | _EESK;
rtw_write8(padapter, EE_9346CR, (u8)*x);
rtw_udelay_os(CLOCK_RATE);

_func_exit_;
_func_exit_;
}

void down_clk(_adapter * padapter, u16 *x )
{
_func_enter_;
_func_enter_;
*x = *x & ~_EESK;
rtw_write8(padapter, EE_9346CR, (u8)*x);
rtw_udelay_os(CLOCK_RATE);
_func_exit_;
_func_exit_;
}

void shift_out_bits(_adapter * padapter, u16 data, u16 count)
{
u16 x,mask;
_func_enter_;
_func_enter_;

if(padapter->bSurpriseRemoved==_TRUE){
if(padapter->bSurpriseRemoved==_TRUE) {
RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==_TRUE"));
goto out;
}
@@ -57,14 +57,13 @@ _func_enter_;

x &= ~(_EEDO | _EEDI);

do
{
do {
x &= ~_EEDI;
if(data & mask)
x |= _EEDI;
if(padapter->bSurpriseRemoved==_TRUE){
RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==_TRUE"));
goto out;
if(padapter->bSurpriseRemoved==_TRUE) {
RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==_TRUE"));
goto out;
}
rtw_write8(padapter, EE_9346CR, (u8)x);
rtw_udelay_os(CLOCK_RATE);
@@ -72,21 +71,21 @@ _func_enter_;
down_clk(padapter, &x);
mask = mask >> 1;
} while(mask);
if(padapter->bSurpriseRemoved==_TRUE){
if(padapter->bSurpriseRemoved==_TRUE) {
RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==_TRUE"));
goto out;
}
x &= ~_EEDI;
rtw_write8(padapter, EE_9346CR, (u8)x);
out:
_func_exit_;
out:
_func_exit_;
}

u16 shift_in_bits (_adapter * padapter)
{
u16 x,d=0,i;
_func_enter_;
if(padapter->bSurpriseRemoved==_TRUE){
_func_enter_;
if(padapter->bSurpriseRemoved==_TRUE) {
RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==_TRUE"));
goto out;
}
@@ -95,24 +94,23 @@ _func_enter_;
x &= ~( _EEDO | _EEDI);
d = 0;

for(i=0; i<16; i++)
{
for(i=0; i<16; i++) {
d = d << 1;
up_clk(padapter, &x);
if(padapter->bSurpriseRemoved==_TRUE){
RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==_TRUE"));
goto out;
}
if(padapter->bSurpriseRemoved==_TRUE) {
RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==_TRUE"));
goto out;
}
x = rtw_read8(padapter, EE_9346CR);

x &= ~(_EEDI);
if(x & _EEDO)
d |= 1;
d |= 1;

down_clk(padapter, &x);
}
out:
_func_exit_;
out:
_func_exit_;

return d;
}
@@ -120,7 +118,7 @@ _func_exit_;
void standby(_adapter * padapter )
{
u8 x;
_func_enter_;
_func_enter_;
x = rtw_read8(padapter, EE_9346CR);

x &= ~(_EECS | _EESK);
@@ -130,56 +128,55 @@ _func_enter_;
x |= _EECS;
rtw_write8(padapter, EE_9346CR, x);
rtw_udelay_os(CLOCK_RATE);
_func_exit_;
_func_exit_;
}

u16 wait_eeprom_cmd_done(_adapter* padapter)
{
u8 x;
u16 i,res=_FALSE;
_func_enter_;
_func_enter_;
standby(padapter );
for (i=0; i<200; i++)
{
for (i=0; i<200; i++) {
x = rtw_read8(padapter, EE_9346CR);
if (x & _EEDO){
if (x & _EEDO) {
res=_TRUE;
goto exit;
}
}
rtw_udelay_os(CLOCK_RATE);
}
exit:
_func_exit_;
exit:
_func_exit_;
return res;
}

void eeprom_clean(_adapter * padapter)
{
u16 x;
_func_enter_;
if(padapter->bSurpriseRemoved==_TRUE){
_func_enter_;
if(padapter->bSurpriseRemoved==_TRUE) {
RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==_TRUE"));
goto out;
}
x = rtw_read8(padapter, EE_9346CR);
if(padapter->bSurpriseRemoved==_TRUE){
if(padapter->bSurpriseRemoved==_TRUE) {
RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==_TRUE"));
goto out;
}
x &= ~(_EECS | _EEDI);
rtw_write8(padapter, EE_9346CR, (u8)x);
if(padapter->bSurpriseRemoved==_TRUE){
if(padapter->bSurpriseRemoved==_TRUE) {
RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==_TRUE"));
goto out;
}
up_clk(padapter, &x);
if(padapter->bSurpriseRemoved==_TRUE){
if(padapter->bSurpriseRemoved==_TRUE) {
RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==_TRUE"));
goto out;
}
down_clk(padapter, &x);
out:
_func_exit_;
out:
_func_exit_;
}

void eeprom_write16(_adapter * padapter, u16 reg, u16 data)
@@ -189,19 +186,19 @@ void eeprom_write16(_adapter * padapter, u16 reg, u16 data)
u8 tmp8_ori,tmp8_new,tmp8_clk_ori,tmp8_clk_new;
tmp8_ori=rtw_read8(padapter, 0x102502f1);
tmp8_new=tmp8_ori & 0xf7;
if(tmp8_ori != tmp8_new){
if(tmp8_ori != tmp8_new) {
rtw_write8(padapter, 0x102502f1, tmp8_new);
RT_TRACE(_module_rtl871x_mp_ioctl_c_,_drv_err_,("====write 0x102502f1=====\n"));
}
tmp8_clk_ori=rtw_read8(padapter,0x10250003);
tmp8_clk_new=tmp8_clk_ori|0x20;
if(tmp8_clk_new!=tmp8_clk_ori){
if(tmp8_clk_new!=tmp8_clk_ori) {
RT_TRACE(_module_rtl871x_mp_ioctl_c_,_drv_err_,("====write 0x10250003=====\n"));
rtw_write8(padapter, 0x10250003, tmp8_clk_new);
}
}
#endif
_func_enter_;
_func_enter_;
x = rtw_read8(padapter, EE_9346CR);

x &= ~(_EEDI | _EEDO | _EESK | _EEM0);
@@ -209,12 +206,12 @@ _func_enter_;
rtw_write8(padapter, EE_9346CR, x);

shift_out_bits(padapter, EEPROM_EWEN_OPCODE, 5);
if(padapter->EepromAddressSize==8) //CF+ and SDIO
shift_out_bits(padapter, 0, 6);
else //USB
shift_out_bits(padapter, 0, 4);
standby( padapter);

// Commented out by rcnjko, 2004.0
@@ -223,7 +220,7 @@ _func_enter_;
// shift_out_bits(Adapter, EEPROM_ERASE_OPCODE, 3);
// shift_out_bits(Adapter, reg, Adapter->EepromAddressSize);
//
// if (wait_eeprom_cmd_done(Adapter ) == FALSE)
// if (wait_eeprom_cmd_done(Adapter ) == FALSE)
// {
// return;
// }
@@ -242,8 +239,7 @@ _func_enter_;
// write the data to the selected EEPROM word.
shift_out_bits(padapter, data, 16);

if (wait_eeprom_cmd_done(padapter ) == _FALSE)
{
if (wait_eeprom_cmd_done(padapter ) == _FALSE) {

goto exit;
}
@@ -254,7 +250,7 @@ _func_enter_;
shift_out_bits(padapter, reg, 4);

eeprom_clean(padapter );
exit:
exit:
#ifdef CONFIG_RTL8712
if(tmp8_clk_new!=tmp8_clk_ori)
rtw_write8(padapter, 0x10250003, tmp8_clk_ori);
@@ -262,11 +258,11 @@ exit:
rtw_write8(padapter, 0x102502f1, tmp8_ori);

#endif
_func_exit_;
_func_exit_;
return;
}

u16 eeprom_read16(_adapter * padapter, u16 reg) //ReadEEprom
u16 eeprom_read16(_adapter * padapter, u16 reg) //ReadEEprom
{

u16 x;
@@ -275,27 +271,27 @@ u16 eeprom_read16(_adapter * padapter, u16 reg) //ReadEEprom
u8 tmp8_ori,tmp8_new,tmp8_clk_ori,tmp8_clk_new;
tmp8_ori= rtw_read8(padapter, 0x102502f1);
tmp8_new = tmp8_ori & 0xf7;
if(tmp8_ori != tmp8_new){
if(tmp8_ori != tmp8_new) {
rtw_write8(padapter, 0x102502f1, tmp8_new);
RT_TRACE(_module_rtl871x_mp_ioctl_c_,_drv_err_,("====write 0x102502f1=====\n"));
}
tmp8_clk_ori=rtw_read8(padapter,0x10250003);
tmp8_clk_new=tmp8_clk_ori|0x20;
if(tmp8_clk_new!=tmp8_clk_ori){
if(tmp8_clk_new!=tmp8_clk_ori) {
RT_TRACE(_module_rtl871x_mp_ioctl_c_,_drv_err_,("====write 0x10250003=====\n"));
rtw_write8(padapter, 0x10250003, tmp8_clk_new);
}
}
#endif
_func_enter_;
_func_enter_;

if(padapter->bSurpriseRemoved==_TRUE){
if(padapter->bSurpriseRemoved==_TRUE) {
RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==_TRUE"));
goto out;
}
// select EEPROM, reset bits, set _EECS
x = rtw_read8(padapter, EE_9346CR);

if(padapter->bSurpriseRemoved==_TRUE){
if(padapter->bSurpriseRemoved==_TRUE) {
RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==_TRUE"));
goto out;
}
@@ -313,7 +309,7 @@ _func_enter_;
data = shift_in_bits(padapter);

eeprom_clean(padapter);
out:
out:
#ifdef CONFIG_RTL8712
if(tmp8_clk_new!=tmp8_clk_ori)
rtw_write8(padapter, 0x10250003, tmp8_clk_ori);
@@ -321,7 +317,7 @@ out:
rtw_write8(padapter, 0x102502f1, tmp8_ori);

#endif
_func_exit_;
_func_exit_;
return data;


@@ -331,20 +327,20 @@ _func_exit_;


//From even offset
void eeprom_read_sz(_adapter * padapter, u16 reg, u8* data, u32 sz)
void eeprom_read_sz(_adapter * padapter, u16 reg, u8* data, u32 sz)
{

u16 x, data16;
u32 i;
_func_enter_;
if(padapter->bSurpriseRemoved==_TRUE){
_func_enter_;
if(padapter->bSurpriseRemoved==_TRUE) {
RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==_TRUE"));
goto out;
}
// select EEPROM, reset bits, set _EECS
x = rtw_read8(padapter, EE_9346CR);

if(padapter->bSurpriseRemoved==_TRUE){
if(padapter->bSurpriseRemoved==_TRUE) {
RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==_TRUE"));
goto out;
}
@@ -359,16 +355,15 @@ _func_enter_;
shift_out_bits(padapter, reg, padapter->EepromAddressSize);


for(i=0; i<sz; i+=2)
{
for(i=0; i<sz; i+=2) {
data16 = shift_in_bits(padapter);
data[i] = data16 & 0xff;
data[i+1] = data16 >>8;
data[i+1] = data16 >>8;
}

eeprom_clean(padapter);
out:
_func_exit_;
out:
_func_exit_;



@@ -380,33 +375,32 @@ u8 eeprom_read(_adapter * padapter, u32 addr_off, u8 sz, u8* rbuf)
{
u8 quotient, remainder, addr_2align_odd;
u16 reg, stmp , i=0, idx = 0;
_func_enter_;
_func_enter_;
reg = (u16)(addr_off >> 1);
addr_2align_odd = (u8)(addr_off & 0x1);

if(addr_2align_odd) //read that start at high part: e.g 1,3,5,7,9,...
{
if(addr_2align_odd) { //read that start at high part: e.g 1,3,5,7,9,...
stmp = eeprom_read16(padapter, reg);
rbuf[idx++] = (u8) ((stmp>>8)&0xff); //return hogh-part of the short
reg++; sz--;
reg++;
sz--;
}
quotient = sz >> 1;
remainder = sz & 0x1;

for( i=0 ; i < quotient; i++)
{
for( i=0 ; i < quotient; i++) {
stmp = eeprom_read16(padapter, reg+i);
rbuf[idx++] = (u8) (stmp&0xff);
rbuf[idx++] = (u8) ((stmp>>8)&0xff);
}
reg = reg+i;
if(remainder){ //end of read at lower part of short : 0,2,4,6,...
if(remainder) { //end of read at lower part of short : 0,2,4,6,...
stmp = eeprom_read16(padapter, reg);
rbuf[idx] = (u8)(stmp & 0xff);
rbuf[idx] = (u8)(stmp & 0xff);
}
_func_exit_;
_func_exit_;
return _TRUE;
}

@@ -415,9 +409,9 @@ _func_exit_;
VOID read_eeprom_content(_adapter * padapter)
{

_func_enter_;
_func_enter_;


_func_exit_;
_func_exit_;
}


+ 709
- 547
core/rtw_ieee80211.c
File diff suppressed because it is too large
View File


+ 78
- 30
core/rtw_io.c View File

@@ -126,7 +126,7 @@ int _rtw_write8(_adapter *adapter, u32 addr, u8 val)

ret = _write8(pintfhdl, addr, val);
_func_exit_;
return RTW_STATUS_CODE(ret);
}
int _rtw_write16(_adapter *adapter, u32 addr, u16 val)
@@ -154,7 +154,7 @@ int _rtw_write32(_adapter *adapter, u32 addr, u32 val)
int ret;
_func_enter_;
_write32 = pintfhdl->io_ops._write32;
val = rtw_cpu_to_le32(val);
ret = _write32(pintfhdl, addr, val);
_func_exit_;
@@ -166,7 +166,7 @@ int _rtw_writeN(_adapter *adapter, u32 addr ,u32 length , u8 *pdata)
{
//struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
struct io_priv *pio_priv = &adapter->iopriv;
struct intf_hdl *pintfhdl = (struct intf_hdl*)(&(pio_priv->intf));
struct intf_hdl *pintfhdl = (struct intf_hdl*)(&(pio_priv->intf));
int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr,u32 length, u8 *pdata);
int ret;
_func_enter_;
@@ -177,6 +177,28 @@ int _rtw_writeN(_adapter *adapter, u32 addr ,u32 length , u8 *pdata)

return RTW_STATUS_CODE(ret);
}

#ifdef CONFIG_SDIO_HCI
u8 _rtw_sd_f0_read8(_adapter *adapter, u32 addr)
{
u8 r_val = 0x00;
struct io_priv *pio_priv = &adapter->iopriv;
struct intf_hdl *pintfhdl = &(pio_priv->intf);
u8 (*_sd_f0_read8)(struct intf_hdl *pintfhdl, u32 addr);

_func_enter_;
_sd_f0_read8 = pintfhdl->io_ops._sd_f0_read8;

if (_sd_f0_read8)
r_val = _sd_f0_read8(pintfhdl, addr);
else
DBG_871X_LEVEL(_drv_warning_, FUNC_ADPT_FMT" _sd_f0_read8 callback is NULL\n", FUNC_ADPT_ARG(adapter));

_func_exit_;
return r_val;
}
#endif /* CONFIG_SDIO_HCI */

int _rtw_write8_async(_adapter *adapter, u32 addr, u8 val)
{
//struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
@@ -232,10 +254,9 @@ void _rtw_read_mem(_adapter *adapter, u32 addr, u32 cnt, u8 *pmem)

_func_enter_;

if( (adapter->bDriverStopped ==_TRUE) || (adapter->bSurpriseRemoved == _TRUE))
{
RT_TRACE(_module_rtl871x_io_c_, _drv_info_, ("rtw_read_mem:bDriverStopped(%d) OR bSurpriseRemoved(%d)", adapter->bDriverStopped, adapter->bSurpriseRemoved));
return;
if( (adapter->bDriverStopped ==_TRUE) || (adapter->bSurpriseRemoved == _TRUE)) {
RT_TRACE(_module_rtl871x_io_c_, _drv_info_, ("rtw_read_mem:bDriverStopped(%d) OR bSurpriseRemoved(%d)", adapter->bDriverStopped, adapter->bSurpriseRemoved));
return;
}

_read_mem = pintfhdl->io_ops._read_mem;
@@ -272,10 +293,9 @@ void _rtw_read_port(_adapter *adapter, u32 addr, u32 cnt, u8 *pmem)

_func_enter_;

if( (adapter->bDriverStopped ==_TRUE) || (adapter->bSurpriseRemoved == _TRUE))
{
RT_TRACE(_module_rtl871x_io_c_, _drv_info_, ("rtw_read_port:bDriverStopped(%d) OR bSurpriseRemoved(%d)", adapter->bDriverStopped, adapter->bSurpriseRemoved));
return;
if( (adapter->bDriverStopped ==_TRUE) || (adapter->bSurpriseRemoved == _TRUE)) {
RT_TRACE(_module_rtl871x_io_c_, _drv_info_, ("rtw_read_port:bDriverStopped(%d) OR bSurpriseRemoved(%d)", adapter->bDriverStopped, adapter->bSurpriseRemoved));
return;
}

_read_port = pintfhdl->io_ops._read_port;
@@ -294,9 +314,10 @@ void _rtw_read_port_cancel(_adapter *adapter)

_read_port_cancel = pintfhdl->io_ops._read_port_cancel;

RTW_DISABLE_FUNC(adapter, DF_RX_BIT);

if(_read_port_cancel)
_read_port_cancel(pintfhdl);

}

u32 _rtw_write_port(_adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
@@ -310,10 +331,10 @@ u32 _rtw_write_port(_adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
_func_enter_;

_write_port = pintfhdl->io_ops._write_port;
ret = _write_port(pintfhdl, addr, cnt, pmem);

_func_exit_;
_func_exit_;

return ret;
}
@@ -330,9 +351,9 @@ u32 _rtw_write_port_and_wait(_adapter *adapter, u32 addr, u32 cnt, u8 *pmem, int
ret = _rtw_write_port(adapter, addr, cnt, pmem);

if (ret == _SUCCESS)
ret = rtw_sctx_wait(&sctx);
ret = rtw_sctx_wait(&sctx, __func__);

return ret;
return ret;
}

void _rtw_write_port_cancel(_adapter *adapter)
@@ -343,9 +364,10 @@ void _rtw_write_port_cancel(_adapter *adapter)

_write_port_cancel = pintfhdl->io_ops._write_port_cancel;

RTW_DISABLE_FUNC(adapter, DF_TX_BIT);

if(_write_port_cancel)
_write_port_cancel(pintfhdl);

}
int rtw_init_io_priv(_adapter *padapter, void (*set_intf_ops)(_adapter *padapter,struct _io_ops *pops))
{
@@ -358,22 +380,48 @@ int rtw_init_io_priv(_adapter *padapter, void (*set_intf_ops)(_adapter *padapter
piopriv->padapter = padapter;
pintf->padapter = padapter;
pintf->pintf_dev = adapter_to_dvobj(padapter);
set_intf_ops(padapter,&pintf->io_ops);
set_intf_ops(padapter,&pintf->io_ops);

return _SUCCESS;
}

/*
* Increase and check if the continual_io_error of this @param dvobjprive is larger than MAX_CONTINUAL_IO_ERR
* @return _TRUE:
* @return _FALSE:
*/
int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj)
{
int ret = _FALSE;
int value;
if( (value=ATOMIC_INC_RETURN(&dvobj->continual_io_error)) > MAX_CONTINUAL_IO_ERR) {
DBG_871X("[dvobj:%p][ERROR] continual_io_error:%d > %d\n", dvobj, value, MAX_CONTINUAL_IO_ERR);
ret = _TRUE;
} else {
//DBG_871X("[dvobj:%p] continual_io_error:%d\n", dvobj, value);
}
return ret;
}

/*
* Set the continual_io_error of this @param dvobjprive to 0
*/
void rtw_reset_continual_io_error(struct dvobj_priv *dvobj)
{
ATOMIC_SET(&dvobj->continual_io_error, 0);
}

#ifdef DBG_IO

u16 read_sniff_ranges[][2] = {
//{0x550, 0x551},
};
//{0x520, 0x523},
};

u16 write_sniff_ranges[][2] = {
//{0x550, 0x551},
//{0x520, 0x523},
//{0x4c, 0x4c},
};
};

int read_sniff_num = sizeof(read_sniff_ranges)/sizeof(u16)/2;
int write_sniff_num = sizeof(write_sniff_ranges)/sizeof(u16)/2;
@@ -385,7 +433,7 @@ bool match_read_sniff_ranges(u16 addr, u16 len)
if (addr + len > read_sniff_ranges[i][0] && addr <= read_sniff_ranges[i][1])
return _TRUE;
}
return _FALSE;
}

@@ -396,7 +444,7 @@ bool match_write_sniff_ranges(u16 addr, u16 len)
if (addr + len > write_sniff_ranges[i][0] && addr <= write_sniff_ranges[i][1])
return _TRUE;
}
return _FALSE;
}

@@ -413,7 +461,7 @@ u8 dbg_rtw_read8(_adapter *adapter, u32 addr, const char *caller, const int line
u16 dbg_rtw_read16(_adapter *adapter, u32 addr, const char *caller, const int line)
{
u16 val = _rtw_read16(adapter, addr);
if (match_read_sniff_ranges(addr, 2))
DBG_871X("DBG_IO %s:%d rtw_read16(0x%04x) return 0x%04x\n", caller, line, addr, val);

@@ -423,7 +471,7 @@ u16 dbg_rtw_read16(_adapter *adapter, u32 addr, const char *caller, const int li
u32 dbg_rtw_read32(_adapter *adapter, u32 addr, const char *caller, const int line)
{
u32 val = _rtw_read32(adapter, addr);
if (match_read_sniff_ranges(addr, 4))
DBG_871X("DBG_IO %s:%d rtw_read32(0x%04x) return 0x%08x\n", caller, line, addr, val);

@@ -434,21 +482,21 @@ int dbg_rtw_write8(_adapter *adapter, u32 addr, u8 val, const char *caller, cons
{
if (match_write_sniff_ranges(addr, 1))
DBG_871X("DBG_IO %s:%d rtw_write8(0x%04x, 0x%02x)\n", caller, line, addr, val);
return _rtw_write8(adapter, addr, val);
}
int dbg_rtw_write16(_adapter *adapter, u32 addr, u16 val, const char *caller, const int line)
{
if (match_write_sniff_ranges(addr, 2))
DBG_871X("DBG_IO %s:%d rtw_write16(0x%04x, 0x%04x)\n", caller, line, addr, val);
return _rtw_write16(adapter, addr, val);
}
int dbg_rtw_write32(_adapter *adapter, u32 addr, u32 val, const char *caller, const int line)
{
if (match_write_sniff_ranges(addr, 4))
DBG_871X("DBG_IO %s:%d rtw_write32(0x%04x, 0x%08x)\n", caller, line, addr, val);
return _rtw_write32(adapter, addr, val);
}
int dbg_rtw_writeN(_adapter *adapter, u32 addr ,u32 length , u8 *data, const char *caller, const int line)


+ 87
- 94
core/rtw_ioctl_query.c View File

@@ -1,7 +1,7 @@
/******************************************************************************
*
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
@@ -28,28 +28,27 @@
//
u8
query_802_11_capability(
_adapter* Adapter,
u8* pucBuf,
u32 * pulOutLen
_adapter* Adapter,
u8* pucBuf,
u32 * pulOutLen
)
{
static NDIS_802_11_AUTHENTICATION_ENCRYPTION szAuthEnc[] =
{
{Ndis802_11AuthModeOpen, Ndis802_11EncryptionDisabled},
static NDIS_802_11_AUTHENTICATION_ENCRYPTION szAuthEnc[] = {
{Ndis802_11AuthModeOpen, Ndis802_11EncryptionDisabled},
{Ndis802_11AuthModeOpen, Ndis802_11Encryption1Enabled},
{Ndis802_11AuthModeShared, Ndis802_11EncryptionDisabled},
{Ndis802_11AuthModeShared, Ndis802_11EncryptionDisabled},
{Ndis802_11AuthModeShared, Ndis802_11Encryption1Enabled},
{Ndis802_11AuthModeWPA, Ndis802_11Encryption2Enabled},
{Ndis802_11AuthModeWPA, Ndis802_11Encryption2Enabled},
{Ndis802_11AuthModeWPA, Ndis802_11Encryption3Enabled},
{Ndis802_11AuthModeWPAPSK, Ndis802_11Encryption2Enabled},
{Ndis802_11AuthModeWPAPSK, Ndis802_11Encryption2Enabled},
{Ndis802_11AuthModeWPAPSK, Ndis802_11Encryption3Enabled},
{Ndis802_11AuthModeWPANone, Ndis802_11Encryption2Enabled},
{Ndis802_11AuthModeWPANone, Ndis802_11Encryption2Enabled},
{Ndis802_11AuthModeWPANone, Ndis802_11Encryption3Enabled},
{Ndis802_11AuthModeWPA2, Ndis802_11Encryption2Enabled},
{Ndis802_11AuthModeWPA2, Ndis802_11Encryption2Enabled},
{Ndis802_11AuthModeWPA2, Ndis802_11Encryption3Enabled},
{Ndis802_11AuthModeWPA2PSK, Ndis802_11Encryption2Enabled},
{Ndis802_11AuthModeWPA2PSK, Ndis802_11Encryption2Enabled},
{Ndis802_11AuthModeWPA2PSK, Ndis802_11Encryption3Enabled}
};
};
static ULONG ulNumOfPairSupported = sizeof(szAuthEnc)/sizeof(NDIS_802_11_AUTHENTICATION_ENCRYPTION);
NDIS_802_11_CAPABILITY * pCap = (NDIS_802_11_CAPABILITY *)pucBuf;
u8* pucAuthEncryptionSupported = (u8*) pCap->AuthenticationEncryptionSupported;
@@ -58,19 +57,16 @@ query_802_11_capability(
pCap->Length = sizeof(NDIS_802_11_CAPABILITY);
if(ulNumOfPairSupported > 1 )
pCap->Length += (ulNumOfPairSupported-1) * sizeof(NDIS_802_11_AUTHENTICATION_ENCRYPTION);
pCap->Version = 2;
pCap->NoOfPMKIDs = NUM_PMKID_CACHE;
pCap->Version = 2;
pCap->NoOfPMKIDs = NUM_PMKID_CACHE;
pCap->NoOfAuthEncryptPairsSupported = ulNumOfPairSupported;

if( sizeof (szAuthEnc) <= 240 ) // 240 = 256 - 4*4 // SecurityInfo.szCapability: only 256 bytes in size.
{
if( sizeof (szAuthEnc) <= 240 ) { // 240 = 256 - 4*4 // SecurityInfo.szCapability: only 256 bytes in size.
_rtw_memcpy( pucAuthEncryptionSupported, (u8*)szAuthEnc, sizeof (szAuthEnc) );
*pulOutLen = pCap->Length;
return _TRUE;
}
else
{
} else {
*pulOutLen = 0;
RT_TRACE(_module_rtl871x_ioctl_query_c_,_drv_info_,("_query_802_11_capability(): szAuthEnc size is too large.\n"));
return _FALSE;
@@ -82,7 +78,7 @@ u8 query_802_11_association_information( _adapter *padapter,PNDIS_802_11_ASSOCIA
struct wlan_network *tgt_network;
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
struct security_priv *psecuritypriv=&(padapter->securitypriv);
WLAN_BSSID_EX *psecnetwork=(WLAN_BSSID_EX*)&(psecuritypriv->sec_bss);
WLAN_BSSID_EX *psecnetwork=(WLAN_BSSID_EX*)&(psecuritypriv->sec_bss);
u8 * pDest = (u8 *)pAssocInfo + sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
unsigned char i,*auth_ie,*supp_ie;

@@ -94,97 +90,94 @@ u8 query_802_11_association_information( _adapter *padapter,PNDIS_802_11_ASSOCIA
// Association Request related information
//------------------------------------------------------
// Req_1. AvailableRequestFixedIEs
if(psecnetwork!=NULL){
pAssocInfo->AvailableRequestFixedIEs |= NDIS_802_11_AI_REQFI_CAPABILITIES|NDIS_802_11_AI_REQFI_CURRENTAPADDRESS;
pAssocInfo->RequestFixedIEs.Capabilities = (unsigned short)* & psecnetwork->IEs[10];
_rtw_memcpy(pAssocInfo->RequestFixedIEs.CurrentAPAddress,
& psecnetwork->MacAddress, 6);

pAssocInfo->OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);

if(check_fwstate( pmlmepriv, _FW_UNDER_LINKING|_FW_LINKED)==_TRUE)
{
if(psecuritypriv->ndisauthtype>=Ndis802_11AuthModeWPA2)
pDest[0] =48; //RSN Information Element
else
pDest[0] =221; //WPA(SSN) Information Element
RT_TRACE(_module_rtl871x_ioctl_query_c_,_drv_info_,("\n Adapter->ndisauthtype==Ndis802_11AuthModeWPA)?0xdd:0x30 [%d]",pDest[0]));
supp_ie=&psecuritypriv->supplicant_ie[0];
for(i=0;i<supp_ie[0];i++)
{
RT_TRACE(_module_rtl871x_ioctl_query_c_,_drv_info_,("IEs [%d] = 0x%x \n\n", i,supp_ie[i]));
}
if(psecnetwork!=NULL) {

pAssocInfo->AvailableRequestFixedIEs |= NDIS_802_11_AI_REQFI_CAPABILITIES|NDIS_802_11_AI_REQFI_CURRENTAPADDRESS;
pAssocInfo->RequestFixedIEs.Capabilities = (unsigned short)* & psecnetwork->IEs[10];
_rtw_memcpy(pAssocInfo->RequestFixedIEs.CurrentAPAddress,
& psecnetwork->MacAddress, 6);

pAssocInfo->OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);

i=13; //0~11 is fixed information element
RT_TRACE(_module_rtl871x_ioctl_query_c_,_drv_info_,("i= %d tgt_network->network.IELength=%d\n\n", i,(int)psecnetwork->IELength));
while((i<supp_ie[0]) && (i<256)){
if((unsigned char)supp_ie[i]==pDest[0]){
_rtw_memcpy((u8 *)(pDest),
&supp_ie[i],
supp_ie[1+i]+2);
break;
if(check_fwstate( pmlmepriv, _FW_UNDER_LINKING|_FW_LINKED)==_TRUE) {

if(psecuritypriv->ndisauthtype>=Ndis802_11AuthModeWPA2)
pDest[0] =48; //RSN Information Element
else
pDest[0] =221; //WPA(SSN) Information Element

RT_TRACE(_module_rtl871x_ioctl_query_c_,_drv_info_,("\n Adapter->ndisauthtype==Ndis802_11AuthModeWPA)?0xdd:0x30 [%d]",pDest[0]));
supp_ie=&psecuritypriv->supplicant_ie[0];
for(i=0; i<supp_ie[0]; i++) {
RT_TRACE(_module_rtl871x_ioctl_query_c_,_drv_info_,("IEs [%d] = 0x%x \n\n", i,supp_ie[i]));
}
i=i+supp_ie[i+1]+2;
if(supp_ie[1+i]==0)
i=i+1;
RT_TRACE(_module_rtl871x_ioctl_query_c_,_drv_info_,("iteration i=%d IEs [%d] = 0x%x \n\n", i,i,supp_ie[i+1]));
}

pAssocInfo->RequestIELength += (2 + supp_ie[1+i]);// (2 + psecnetwork->IEs[1+i]+4);
i=13; //0~11 is fixed information element
RT_TRACE(_module_rtl871x_ioctl_query_c_,_drv_info_,("i= %d tgt_network->network.IELength=%d\n\n", i,(int)psecnetwork->IELength));
while((i<supp_ie[0]) && (i<256)) {
if((unsigned char)supp_ie[i]==pDest[0]) {
_rtw_memcpy((u8 *)(pDest),
&supp_ie[i],
supp_ie[1+i]+2);

break;
}

i=i+supp_ie[i+1]+2;
if(supp_ie[1+i]==0)
i=i+1;
RT_TRACE(_module_rtl871x_ioctl_query_c_,_drv_info_,("iteration i=%d IEs [%d] = 0x%x \n\n", i,i,supp_ie[i+1]));

}


pAssocInfo->RequestIELength += (2 + supp_ie[1+i]);// (2 + psecnetwork->IEs[1+i]+4);

}

}