61 #define RTK_UL_EDCA 0xa44f
62 #define RTK_DL_EDCA 0x5e4322
84 static void dm_init_bandwidth_autoswitch(
struct net_device *
dev);
88 static void dm_check_txpower_tracking(
struct net_device *
dev);
94 static void dm_bb_initialgain_restore(
struct net_device *
dev);
101 static void dm_ctrl_initgain_byrssi_highpwr(
struct net_device *
dev);
102 static void dm_ctrl_initgain_byrssi_by_driverrssi(
struct net_device *
dev);
103 static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(
struct net_device *
dev);
116 static void dm_check_rx_path_selection(
struct net_device *
dev);
117 static void dm_init_rxpath_selection(
struct net_device *
dev);
124 static void dm_check_txrateandretrycount(
struct net_device *
dev);
144 dm_init_dynamic_txpower(dev);
150 dm_init_bandwidth_autoswitch(dev);
152 dm_init_rxpath_selection(dev);
153 dm_init_ctstoself(dev);
155 dm_Init_WA_Broadcom_IOT(dev);
163 dm_deInit_fsync(dev);
173 dm_check_ac_dc_power(dev);
175 dm_check_pbc_gpio(dev);
176 dm_check_txrateandretrycount(dev);
177 dm_check_edca_turbo(dev);
179 dm_check_rate_adaptive(dev);
180 dm_dynamic_txpower(dev);
181 dm_check_txpower_tracking(dev);
183 dm_ctrl_initgain_byrssi(dev);
184 dm_bandwidth_autoswitch(dev);
186 dm_check_rx_path_selection(dev);
189 dm_send_rssi_tofw(dev);
196 static char *ac_dc_check_script_path =
"/etc/acpi/wireless-rtl-ac-dc-power.sh";
197 char *argv[] = {ac_dc_check_script_path,
DRV_NAME,
NULL};
198 static char *envp[] = {
"HOME=/",
200 "PATH=/usr/bin:/bin",
205 "GPIOChangeRFWorkItemCallBack(): Silent Reset!!!!!!!\n");
211 call_usermodehelper(ac_dc_check_script_path, argv, envp,
UMH_WAIT_PROC);
258 static void dm_check_rate_adaptive(
struct net_device *dev)
263 u32 currentRATR, targetRATR = 0;
264 u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0;
265 bool bshort_gi_enabled =
false;
266 static u8 ping_rssi_state;
269 RT_TRACE(
COMP_RATE,
"<---- dm_check_rate_adaptive(): driver is going to unload\n");
340 if (priv->
rtllib->GetHalfNmodeSupportByAPsHandler(dev))
341 targetRATR &= 0xf00fffff;
344 if (targetRATR != currentRATR) {
346 ratr_value = targetRATR;
348 "currentRATR = %x, targetRATR = %x\n",
349 currentRATR, targetRATR);
363 static void dm_init_bandwidth_autoswitch(
struct net_device *dev)
369 priv->
rtllib->bandwidth_auto_switch.bforced_tx20Mhz =
false;
370 priv->
rtllib->bandwidth_auto_switch.bautoswitch_enable =
false;
373 static void dm_bandwidth_autoswitch(
struct net_device *dev)
378 !priv->
rtllib->bandwidth_auto_switch.bautoswitch_enable) {
381 if (priv->
rtllib->bandwidth_auto_switch.bforced_tx20Mhz ==
false) {
383 priv->
rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz)
384 priv->
rtllib->bandwidth_auto_switch.bforced_tx20Mhz =
true;
387 priv->
rtllib->bandwidth_auto_switch.threshold_20Mhzto40Mhz)
388 priv->
rtllib->bandwidth_auto_switch.bforced_tx20Mhz =
false;
417 {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04},
418 {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03},
419 {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03},
420 {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03},
421 {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02},
422 {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02},
423 {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02},
424 {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02},
425 {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01},
426 {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01},
427 {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01},
428 {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}
432 {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00},
433 {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00},
434 {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00},
435 {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00},
436 {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00},
437 {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00},
438 {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00},
439 {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00},
440 {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00},
441 {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00},
442 {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},
443 {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}
446 #define Pw_Track_Flag 0x11d
447 #define Tssi_Mea_Value 0x13c
448 #define Tssi_Report_Value1 0x134
449 #define Tssi_Report_Value2 0x13e
450 #define FW_Busy_Flag 0x13f
452 static void dm_TXPowerTrackingCallback_TSSI(
struct net_device *dev)
455 bool bHighpowerstate, viviflag =
false;
457 u8 powerlevelOFDM24G;
458 int i = 0,
j = 0,
k = 0;
459 u8 RF_Type, tmp_report[5] = {0, 0, 0, 0, 0};
462 u16 Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver = 0;
468 priv->
rtllib->bdynamic_txpower_enable =
false;
473 Value = (RF_Type<<8) | powerlevelOFDM24G;
479 for (
j = 0;
j <= 30;
j++) {
488 for (i = 0; i <= 30; i++) {
496 "we are in silent reset progress, so return\n");
503 "we are in power save, so return\n");
514 if (Avg_TSSI_Meas == 0) {
520 for (
k = 0;
k < 5;
k++) {
529 "TSSI_report_value = %d\n",
532 if (tmp_report[k] <= 20) {
538 if (viviflag ==
true) {
542 for (
k = 0;
k < 5;
k++)
547 for (
k = 0;
k < 5;
k++)
548 Avg_TSSI_Meas_from_driver += tmp_report[
k];
550 Avg_TSSI_Meas_from_driver = Avg_TSSI_Meas_from_driver*100/5;
552 "Avg_TSSI_Meas_from_driver = %d\n",
553 Avg_TSSI_Meas_from_driver);
557 if (Avg_TSSI_Meas_from_driver > TSSI_13dBm)
558 delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm;
560 delta = TSSI_13dBm - Avg_TSSI_Meas_from_driver;
563 priv->
rtllib->bdynamic_txpower_enable =
true;
567 "tx power track is done\n");
569 "priv->rfa_txpowertrackingindex = %d\n",
572 "priv->rfa_txpowertrackingindex_real = %d\n",
575 "priv->CCKPresentAttentuation_difference = %d\n",
578 "priv->CCKPresentAttentuation = %d\n",
692 if (priv->
rtllib->current_network.channel == 14 &&
703 "priv->rfa_txpowertrackingindex = %d\n",
706 "priv->rfa_txpowertrackingindex_real = %d\n",
709 "priv->CCKPresentAttentuation_difference = %d\n",
712 "priv->CCKPresentAttentuation = %d\n",
716 priv->
rtllib->bdynamic_txpower_enable =
true;
724 Avg_TSSI_Meas_from_driver = 0;
725 for (
k = 0;
k < 5;
k++)
731 priv->
rtllib->bdynamic_txpower_enable =
true;
735 static void dm_TXPowerTrackingCallback_ThermalMeter(
struct net_device *dev)
737 #define ThermalMeterVal 9
739 u32 tmpRegA, TempCCk;
740 u8 tmpOFDMindex, tmpCCKindex, tmpCCK20Mindex, tmpCCK40Mindex, tmpval;
741 int i = 0, CCKSwingNeedUpdate = 0;
746 if (tmpRegA == OFDMSwingTable[i]) {
755 if (TempCCk == (
u32)CCKSwingTable_Ch1_Ch13[i][0]) {
758 " = 0x%x, CCK_index = 0x%x\n",
770 if (tmpRegA < 3 || tmpRegA > 13)
779 tmpOFDMindex = tmpCCK20Mindex = 6+(priv->
ThermalMeter[0] -
781 tmpCCK40Mindex = tmpCCK20Mindex - 6;
782 if (tmpOFDMindex >= OFDM_Table_Length)
783 tmpOFDMindex = OFDM_Table_Length-1;
784 if (tmpCCK20Mindex >= CCK_Table_length)
785 tmpCCK20Mindex = CCK_Table_length-1;
786 if (tmpCCK40Mindex >= CCK_Table_length)
787 tmpCCK40Mindex = CCK_Table_length-1;
791 tmpOFDMindex = tmpCCK20Mindex = 0;
793 tmpOFDMindex = tmpCCK20Mindex = 6 - tmpval;
797 tmpCCKindex = tmpCCK40Mindex;
799 tmpCCKindex = tmpCCK20Mindex;
804 "Mindex = %d / %d.\n",
807 if (priv->
rtllib->current_network.channel == 14 &&
810 CCKSwingNeedUpdate = 1;
811 }
else if (priv->
rtllib->current_network.channel != 14 &&
814 CCKSwingNeedUpdate = 1;
819 CCKSwingNeedUpdate = 1;
822 if (CCKSwingNeedUpdate)
842 dm_TXPowerTrackingCallback_TSSI(dev);
844 dm_TXPowerTrackingCallback_ThermalMeter(dev);
847 static void dm_InitializeTXPowerTracking_TSSI(
struct net_device *dev)
1347 static void dm_InitializeTXPowerTracking_ThermalMeter(
struct net_device *dev)
1352 if (priv->
rtllib->FwRWRF)
1366 dm_InitializeTXPowerTracking_TSSI(dev);
1368 dm_InitializeTXPowerTracking_ThermalMeter(dev);
1371 static void dm_CheckTXPowerTracking_TSSI(
struct net_device *dev)
1374 static u32 tx_power_track_counter;
1380 tx_power_track_counter++;
1383 if (tx_power_track_counter >= 180) {
1385 tx_power_track_counter = 0;
1389 static void dm_CheckTXPowerTracking_ThermalMeter(
struct net_device *dev)
1392 static u8 TM_Trigger;
1393 u8 TxPowerCheckCnt = 0;
1396 TxPowerCheckCnt = 5;
1398 TxPowerCheckCnt = 2;
1418 printk(
KERN_INFO "===============>Schedule TxPowerTrackingWorkItem\n");
1426 static void dm_check_txpower_tracking(
struct net_device *dev)
1431 dm_CheckTXPowerTracking_TSSI(dev);
1433 dm_CheckTXPowerTracking_ThermalMeter(dev);
1436 static void dm_CCKTxPowerAdjust_TSSI(
struct net_device *dev,
bool bInCH14)
1478 static void dm_CCKTxPowerAdjust_ThermalMeter(
struct net_device *dev,
bool bInCH14)
1485 TempVal = CCKSwingTable_Ch1_Ch13[priv->
CCK_index][0] +
1486 (CCKSwingTable_Ch1_Ch13[priv->
CCK_index][1]<<8) ;
1491 TempVal = CCKSwingTable_Ch1_Ch13[priv->
CCK_index][2] +
1492 (CCKSwingTable_Ch1_Ch13[priv->
CCK_index][3]<<8) +
1493 (CCKSwingTable_Ch1_Ch13[priv->
CCK_index][4]<<16)+
1494 (CCKSwingTable_Ch1_Ch13[priv->
CCK_index][5]<<24);
1499 TempVal = CCKSwingTable_Ch1_Ch13[priv->
CCK_index][6] +
1500 (CCKSwingTable_Ch1_Ch13[priv->
CCK_index][7]<<8) ;
1506 TempVal = CCKSwingTable_Ch14[priv->
CCK_index][0] +
1507 (CCKSwingTable_Ch14[priv->
CCK_index][1]<<8) ;
1513 TempVal = CCKSwingTable_Ch14[priv->
CCK_index][2] +
1514 (CCKSwingTable_Ch14[priv->
CCK_index][3]<<8) +
1515 (CCKSwingTable_Ch14[priv->
CCK_index][4]<<16)+
1516 (CCKSwingTable_Ch14[priv->
CCK_index][5]<<24);
1521 TempVal = CCKSwingTable_Ch14[priv->
CCK_index][6] +
1522 (CCKSwingTable_Ch14[priv->
CCK_index][7]<<8) ;
1534 dm_CCKTxPowerAdjust_TSSI(dev, binch14);
1536 dm_CCKTxPowerAdjust_ThermalMeter(dev, binch14);
1539 static void dm_txpower_reset_recovery(
struct net_device *dev)
1574 RT_TRACE(
COMP_RATE,
"<---- dm_restore_dynamic_mechanism_state(): driver is going to unload\n");
1583 ratr_value = reg_ratr;
1589 dm_txpower_reset_recovery(dev);
1591 dm_bb_initialgain_restore(dev);
1595 static void dm_bb_initialgain_restore(
struct net_device *dev)
1598 u32 bit_mask = 0x7f;
1627 dm_bb_initialgain_backup(dev);
1632 static void dm_bb_initialgain_backup(
struct net_device *dev)
1657 u32 dm_type,
u32 dm_value)
1664 dm_digtable.rssi_high_power_highthresh = dm_value;
1666 dm_digtable.rssi_high_power_highthresh = dm_value;
1696 if (dm_value > 0x50)
1702 static void dm_dig_init(
struct net_device *dev)
1742 static void dm_ctrl_initgain_byrssi(
struct net_device *dev)
1749 dm_ctrl_initgain_byrssi_by_fwfalse_alarm(dev);
1751 dm_ctrl_initgain_byrssi_by_driverrssi(dev);
1774 static void dm_ctrl_initgain_byrssi_by_driverrssi(
1787 for (i = 0; i < 3; i++)
1801 dm_initial_gain(dev);
1810 static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(
1814 static u32 reset_cnt;
1822 for (i = 0; i < 3; i++)
1865 dm_ctrl_initgain_byrssi_highpwr(dev);
1876 if (reset_flag == 1) {
1897 dm_ctrl_initgain_byrssi_highpwr(dev);
1901 static void dm_ctrl_initgain_byrssi_highpwr(
struct net_device *dev)
1904 static u32 reset_cnt_highpwr;
1939 static void dm_initial_gain(
struct net_device *dev)
1942 u8 initial_gain = 0;
1944 static u32 reset_cnt;
1984 || !initialized || force_write) {
2000 static u32 reset_cnt;
2031 (initialized <= 3) || force_write) {
2049 if (initialized <= 3)
2055 static void dm_cs_ratio(
struct net_device *dev)
2059 static u32 reset_cnt;
2088 !initialized || force_write) {
2104 priv->
rtllib->bis_any_nonbepkts =
false;
2108 static void dm_check_edca_turbo(
struct net_device *dev)
2113 static unsigned long lastTxOkCnt;
2114 static unsigned long lastRxOkCnt;
2115 unsigned long curTxOkCnt = 0;
2116 unsigned long curRxOkCnt = 0;
2119 goto dm_CheckEdcaTurbo_EXIT;
2121 goto dm_CheckEdcaTurbo_EXIT;
2123 goto dm_CheckEdcaTurbo_EXIT;
2126 u8 *peername[11] = {
2127 "unknown",
"realtek_90",
"realtek_92se",
"broadcom",
2128 "ralink",
"atheros",
"cisco",
"marvell",
"92u_softap",
2136 priv->
rtllib->current_network.bssid);
2140 if (!priv->
rtllib->bis_any_nonbepkts) {
2141 curTxOkCnt = priv->
stats.txbytesunicast - lastTxOkCnt;
2142 curRxOkCnt = priv->
stats.rxbytesunicast - lastRxOkCnt;
2144 if (curTxOkCnt > 4*curRxOkCnt) {
2148 edca_setting_UL[pHTInfo->
IOTPeer]);
2156 edca_setting_DL_GMode[pHTInfo->
IOTPeer]);
2159 edca_setting_DL[pHTInfo->
IOTPeer]);
2165 if (curRxOkCnt > 4*curTxOkCnt) {
2169 edca_setting_DL_GMode[pHTInfo->
IOTPeer]);
2172 edca_setting_DL[pHTInfo->
IOTPeer]);
2179 edca_setting_UL[pHTInfo->
IOTPeer]);
2196 dm_CheckEdcaTurbo_EXIT:
2197 priv->
rtllib->bis_any_nonbepkts =
false;
2198 lastTxOkCnt = priv->
stats.txbytesunicast;
2199 lastRxOkCnt = priv->
stats.rxbytesunicast;
2202 static void dm_init_ctstoself(
struct net_device *dev)
2206 priv->
rtllib->bCTSToSelfEnable =
true;
2210 static void dm_ctstoself(
struct net_device *dev)
2214 static unsigned long lastTxOkCnt;
2215 static unsigned long lastRxOkCnt;
2216 unsigned long curTxOkCnt = 0;
2217 unsigned long curRxOkCnt = 0;
2219 if (priv->
rtllib->bCTSToSelfEnable !=
true) {
2224 curTxOkCnt = priv->
stats.txbytesunicast - lastTxOkCnt;
2225 curRxOkCnt = priv->
stats.rxbytesunicast - lastRxOkCnt;
2226 if (curRxOkCnt > 4*curTxOkCnt)
2231 lastTxOkCnt = priv->
stats.txbytesunicast;
2232 lastRxOkCnt = priv->
stats.rxbytesunicast;
2237 static void dm_Init_WA_Broadcom_IOT(
struct net_device *dev)
2246 static void dm_check_pbc_gpio(
struct net_device *dev)
2257 bool bActuallySet =
false;
2259 static char *RadioPowerPath =
"/etc/acpi/events/RadioPower.sh";
2260 static char *envp[] = {
"HOME=/",
"TERM=linux",
"PATH=/usr/bin:/bin",
NULL};
2262 bActuallySet =
false;
2280 bActuallySet =
true;
2285 bActuallySet =
true;
2297 argv[0] = RadioPowerPath;
2299 call_usermodehelper(RadioPowerPath, argv, envp,
UMH_WAIT_PROC);
2314 if (rfpath & (0x01<<i))
2322 dm_rxpath_sel_byrssi(dev);
2325 static void dm_init_rxpath_selection(
struct net_device *dev)
2339 for (i = 0; i < 4; i++) {
2346 #define PWDB_IN_RANGE ((cur_cck_pwdb < tmp_cck_max_pwdb) && \
2347 (cur_cck_pwdb > tmp_cck_sec_pwdb))
2349 static void dm_rxpath_sel_byrssi(
struct net_device *dev)
2352 u8 i, max_rssi_index = 0, min_rssi_index = 0;
2353 u8 sec_rssi_index = 0, rf_num = 0;
2354 u8 tmp_max_rssi = 0, tmp_min_rssi = 0, tmp_sec_rssi = 0;
2355 u8 cck_default_Rx = 0x2;
2356 u8 cck_optional_Rx = 0x3;
2357 long tmp_cck_max_pwdb = 0, tmp_cck_min_pwdb = 0, tmp_cck_sec_pwdb = 0;
2358 u8 cck_rx_ver2_max_index = 0, cck_rx_ver2_min_index = 0;
2359 u8 cck_rx_ver2_sec_index = 0;
2362 static u8 disabled_rf_cnt, cck_Rx_Path_initialized;
2363 u8 update_cck_rx_path;
2368 if (!cck_Rx_Path_initialized) {
2370 cck_Rx_Path_initialized = 1;
2388 max_rssi_index = min_rssi_index = sec_rssi_index =
i;
2389 tmp_max_rssi = tmp_min_rssi = tmp_sec_rssi = cur_rf_rssi;
2390 }
else if (rf_num == 2) {
2391 if (cur_rf_rssi >= tmp_max_rssi) {
2392 tmp_max_rssi = cur_rf_rssi;
2395 tmp_sec_rssi = tmp_min_rssi = cur_rf_rssi;
2396 sec_rssi_index = min_rssi_index =
i;
2399 if (cur_rf_rssi > tmp_max_rssi) {
2400 tmp_sec_rssi = tmp_max_rssi;
2401 sec_rssi_index = max_rssi_index;
2402 tmp_max_rssi = cur_rf_rssi;
2404 }
else if (cur_rf_rssi == tmp_max_rssi) {
2405 tmp_sec_rssi = cur_rf_rssi;
2407 }
else if ((cur_rf_rssi < tmp_max_rssi) &&
2408 (cur_rf_rssi > tmp_sec_rssi)) {
2409 tmp_sec_rssi = cur_rf_rssi;
2411 }
else if (cur_rf_rssi == tmp_sec_rssi) {
2412 if (tmp_sec_rssi == tmp_min_rssi) {
2413 tmp_sec_rssi = cur_rf_rssi;
2416 }
else if ((cur_rf_rssi < tmp_sec_rssi) &&
2417 (cur_rf_rssi > tmp_min_rssi)) {
2419 }
else if (cur_rf_rssi == tmp_min_rssi) {
2420 if (tmp_sec_rssi == tmp_min_rssi) {
2421 tmp_min_rssi = cur_rf_rssi;
2424 }
else if (cur_rf_rssi < tmp_min_rssi) {
2425 tmp_min_rssi = cur_rf_rssi;
2441 cck_rx_ver2_max_index =
i;
2442 cck_rx_ver2_min_index =
i;
2443 cck_rx_ver2_sec_index =
i;
2444 tmp_cck_max_pwdb = cur_cck_pwdb;
2445 tmp_cck_min_pwdb = cur_cck_pwdb;
2446 tmp_cck_sec_pwdb = cur_cck_pwdb;
2447 }
else if (rf_num == 2) {
2448 if (cur_cck_pwdb >= tmp_cck_max_pwdb) {
2449 tmp_cck_max_pwdb = cur_cck_pwdb;
2450 cck_rx_ver2_max_index =
i;
2452 tmp_cck_sec_pwdb = cur_cck_pwdb;
2453 tmp_cck_min_pwdb = cur_cck_pwdb;
2454 cck_rx_ver2_sec_index =
i;
2455 cck_rx_ver2_min_index =
i;
2458 if (cur_cck_pwdb > tmp_cck_max_pwdb) {
2461 cck_rx_ver2_sec_index =
2462 cck_rx_ver2_max_index;
2463 tmp_cck_max_pwdb = cur_cck_pwdb;
2464 cck_rx_ver2_max_index =
i;
2465 }
else if (cur_cck_pwdb ==
2467 tmp_cck_sec_pwdb = cur_cck_pwdb;
2468 cck_rx_ver2_sec_index =
i;
2470 tmp_cck_sec_pwdb = cur_cck_pwdb;
2471 cck_rx_ver2_sec_index =
i;
2472 }
else if (cur_cck_pwdb ==
2474 if (tmp_cck_sec_pwdb ==
2478 cck_rx_ver2_sec_index =
2481 }
else if ((cur_cck_pwdb < tmp_cck_sec_pwdb) &&
2482 (cur_cck_pwdb > tmp_cck_min_pwdb)) {
2484 }
else if (cur_cck_pwdb == tmp_cck_min_pwdb) {
2485 if (tmp_cck_sec_pwdb == tmp_cck_min_pwdb) {
2486 tmp_cck_min_pwdb = cur_cck_pwdb;
2487 cck_rx_ver2_min_index =
i;
2489 }
else if (cur_cck_pwdb < tmp_cck_min_pwdb) {
2490 tmp_cck_min_pwdb = cur_cck_pwdb;
2491 cck_rx_ver2_min_index =
i;
2499 update_cck_rx_path = 0;
2501 cck_default_Rx = cck_rx_ver2_max_index;
2502 cck_optional_Rx = cck_rx_ver2_sec_index;
2503 if (tmp_cck_max_pwdb != -64)
2504 update_cck_rx_path = 1;
2508 if ((tmp_max_rssi - tmp_min_rssi) >=
2513 0x1<<min_rssi_index, 0x0);
2515 0x1<<min_rssi_index, 0x0);
2519 cck_default_Rx = max_rssi_index;
2520 cck_optional_Rx = sec_rssi_index;
2522 update_cck_rx_path = 1;
2526 if (update_cck_rx_path) {
2534 for (i = 0; i < 4; i++) {
2553 static void dm_check_rx_path_selection(
struct net_device *dev)
2561 static void dm_init_fsync(
struct net_device *dev)
2565 priv->
rtllib->fsync_time_interval = 500;
2566 priv->
rtllib->fsync_rate_bitmap = 0x0f000800;
2567 priv->
rtllib->fsync_rssi_threshold = 30;
2568 priv->
rtllib->bfsync_enable =
false;
2569 priv->
rtllib->fsync_multiple_timeinterval = 3;
2570 priv->
rtllib->fsync_firstdiff_ratethreshold = 100;
2571 priv->
rtllib->fsync_seconddiff_ratethreshold = 200;
2577 (
unsigned long) dev);
2581 static void dm_deInit_fsync(
struct net_device *dev)
2591 u32 rate_index, rate_count = 0, rate_count_diff = 0;
2592 bool bSwitchFromCountDiff =
false;
2593 bool bDoubleTimeInterval =
false;
2596 priv->
rtllib->bfsync_enable &&
2599 for (rate_index = 0; rate_index <= 27; rate_index++) {
2600 rate_bitmap = 1 << rate_index;
2601 if (priv->
rtllib->fsync_rate_bitmap & rate_bitmap)
2603 priv->
stats.received_rate_histogram[1]
2608 rate_count_diff = 0xffffffff - rate_count +
2617 priv->
rtllib->fsync_seconddiff_ratethreshold)
2623 bSwitchFromCountDiff =
true;
2630 if (rate_count_diff <=
2631 priv->
rtllib->fsync_firstdiff_ratethreshold) {
2632 bSwitchFromCountDiff =
true;
2638 "Countdiff %d bSwitchFsync %d\n", priv->
rate_record,
2641 priv->
rtllib->fsync_rssi_threshold &&
2642 bSwitchFromCountDiff) {
2643 bDoubleTimeInterval =
true;
2653 priv->
rtllib->fsync_rssi_threshold) {
2660 if (bDoubleTimeInterval) {
2665 priv->
rtllib->fsync_multiple_timeinterval);
2685 "bSwitchFsync %d\n", priv->
rate_record, rate_count,
2689 static void dm_StartHWFsync(
struct net_device *dev)
2691 u8 rf_timing = 0x77;
2696 (
u8 *)(&rf_timing));
2700 static void dm_EndHWFsync(
struct net_device *dev)
2702 u8 rf_timing = 0xaa;
2711 static void dm_EndSWFsync(
struct net_device *dev)
2730 static void dm_StartSWFsync(
struct net_device *dev)
2743 priv->
rtllib->fsync_firstdiff_ratethreshold = 600;
2744 priv->
rtllib->fsync_seconddiff_ratethreshold = 0xffff;
2746 priv->
rtllib->fsync_firstdiff_ratethreshold = 200;
2747 priv->
rtllib->fsync_seconddiff_ratethreshold = 200;
2749 for (rateIndex = 0; rateIndex <= 27; rateIndex++) {
2750 rateBitmap = 1 << rateIndex;
2751 if (priv->
rtllib->fsync_rate_bitmap & rateBitmap)
2753 priv->
stats.received_rate_histogram[1]
2768 #define RegC38_Default 0
2769 #define RegC38_NonFsync_Other_AP 1
2770 #define RegC38_Fsync_AP_BCM 2
2773 static u32 reset_cnt;
2776 "%d\n", priv->
rtllib->fsync_rssi_threshold,
2777 priv->
rtllib->fsync_time_interval,
2778 priv->
rtllib->fsync_multiple_timeinterval);
2780 "DiffRateThreshold %d\n", priv->
rtllib->fsync_rate_bitmap,
2781 priv->
rtllib->fsync_firstdiff_ratethreshold,
2782 priv->
rtllib->fsync_seconddiff_ratethreshold);
2786 if (priv->
rtllib->bfsync_enable == 0) {
2787 switch (priv->
rtllib->fsync_state) {
2789 dm_StartHWFsync(dev);
2794 dm_StartHWFsync(dev);
2802 switch (priv->
rtllib->fsync_state) {
2804 dm_StartSWFsync(dev);
2809 dm_StartSWFsync(dev);
2826 switch (priv->
rtllib->fsync_state) {
2844 if (reg_c38_State !=
2855 if (reg_c38_State) {
2863 if (reg_c38_State) {
2879 if (reg_c38_State) {
2892 for (page = 0; page < 5; page++)
2893 for (offset = 0; offset < 256; offset++)
2897 for (page = 8; page < 11; page++)
2898 for (offset = 0; offset < 256; offset++)
2902 for (page = 12; page < 15; page++)
2903 for (offset = 0; offset < 256; offset++)
2910 static void dm_init_dynamic_txpower(
struct net_device *dev)
2914 priv->
rtllib->bdynamic_txpower_enable =
true;
2921 static void dm_dynamic_txpower(
struct net_device *dev)
2924 unsigned int txhipower_threshhold = 0;
2925 unsigned int txlowpower_threshold = 0;
2926 if (priv->
rtllib->bdynamic_txpower_enable !=
true) {
2949 txlowpower_threshold &&
2965 priv->
rtllib->current_network.channel);
2968 priv->
rtllib->current_network.channel);
2975 static void dm_check_txrateandretrycount(
struct net_device *dev)
2990 static void dm_send_rssi_tofw(
struct net_device *dev)