mto.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * ============================================================================
  3. * MTO.C -
  4. *
  5. * Description:
  6. * MAC Throughput Optimization for W89C33 802.11g WLAN STA.
  7. *
  8. * The following MIB attributes or internal variables will be affected
  9. * while the MTO is being executed:
  10. * dot11FragmentationThreshold,
  11. * dot11RTSThreshold,
  12. * transmission rate and PLCP preamble type,
  13. * CCA mode,
  14. * antenna diversity.
  15. *
  16. * Copyright (c) 2003 Winbond Electronics Corp. All rights reserved.
  17. * ============================================================================
  18. */
  19. #include "sme_api.h"
  20. #include "wbhal.h"
  21. #include "wb35reg_f.h"
  22. #include "core.h"
  23. /* Declare SQ3 to rate and fragmentation threshold table */
  24. /* Declare fragmentation thresholds table */
  25. #define MTO_MAX_FRAG_TH_LEVELS 5
  26. #define MTO_MAX_DATA_RATE_LEVELS 12
  27. u16 MTO_Frag_Th_Tbl[MTO_MAX_FRAG_TH_LEVELS] = {
  28. 256, 384, 512, 768, 1536
  29. };
  30. /*
  31. * Declare data rate table:
  32. * The following table will be changed at anytime if the opration rate
  33. * supported by AP don't match the table
  34. */
  35. static u8 MTO_Data_Rate_Tbl[MTO_MAX_DATA_RATE_LEVELS] = {
  36. 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108
  37. };
  38. /* this record the retry rate at different data rate */
  39. static int retryrate_rec[MTO_MAX_DATA_RATE_LEVELS];
  40. static u8 boSparseTxTraffic;
  41. void MTO_Init(struct wbsoft_priv *adapter);
  42. void TxRateReductionCtrl(struct wbsoft_priv *adapter);
  43. void MTO_SetTxCount(struct wbsoft_priv *adapter, u8 t0, u8 index);
  44. void MTO_TxFailed(struct wbsoft_priv *adapter);
  45. void hal_get_dto_para(struct wbsoft_priv *adapter, char *buffer);
  46. /*
  47. * ===========================================================================
  48. * MTO_Init --
  49. *
  50. * Description:
  51. * Initialize MTO parameters.
  52. *
  53. * This function should be invoked during system initialization.
  54. *
  55. * Arguments:
  56. * adapter - The pointer to the Miniport adapter Context
  57. * ===========================================================================
  58. */
  59. void MTO_Init(struct wbsoft_priv *adapter)
  60. {
  61. int i;
  62. MTO_PREAMBLE_TYPE() = MTO_PREAMBLE_SHORT; /* for test */
  63. MTO_CNT_ANT(0) = 0;
  64. MTO_CNT_ANT(1) = 0;
  65. MTO_SQ_ANT(0) = 0;
  66. MTO_SQ_ANT(1) = 0;
  67. MTO_AGING_TIMEOUT() = 0;
  68. /* The following parameters should be initialized to the values set by user */
  69. MTO_RATE_LEVEL() = 0;
  70. MTO_FRAG_TH_LEVEL() = 4;
  71. MTO_RTS_THRESHOLD() = MTO_FRAG_TH() + 1;
  72. MTO_RTS_THRESHOLD_SETUP() = MTO_FRAG_TH() + 1;
  73. MTO_RATE_CHANGE_ENABLE() = 1;
  74. MTO_FRAG_CHANGE_ENABLE() = 0;
  75. MTO_POWER_CHANGE_ENABLE() = 1;
  76. MTO_PREAMBLE_CHANGE_ENABLE() = 1;
  77. MTO_RTS_CHANGE_ENABLE() = 0;
  78. for (i = 0; i < MTO_MAX_DATA_RATE_LEVELS; i++)
  79. retryrate_rec[i] = 5;
  80. MTO_TXFLOWCOUNT() = 0;
  81. /* --------- DTO threshold parameters ------------- */
  82. MTOPARA_PERIODIC_CHECK_CYCLE() = 10;
  83. MTOPARA_RSSI_TH_FOR_ANTDIV() = 10;
  84. MTOPARA_TXCOUNT_TH_FOR_CALC_RATE() = 50;
  85. MTOPARA_TXRATE_INC_TH() = 10;
  86. MTOPARA_TXRATE_DEC_TH() = 30;
  87. MTOPARA_TXRATE_EQ_TH() = 40;
  88. MTOPARA_TXRATE_BACKOFF() = 12;
  89. MTOPARA_TXRETRYRATE_REDUCE() = 6;
  90. if (MTO_TXPOWER_FROM_EEPROM == 0xff) {
  91. switch (MTO_HAL()->phy_type) {
  92. case RF_AIROHA_2230:
  93. case RF_AIROHA_2230S:
  94. MTOPARA_TXPOWER_INDEX() = 46; /* MAX-8 @@ Only for AL 2230 */
  95. break;
  96. case RF_AIROHA_7230:
  97. MTOPARA_TXPOWER_INDEX() = 49;
  98. break;
  99. case RF_WB_242:
  100. MTOPARA_TXPOWER_INDEX() = 10;
  101. break;
  102. case RF_WB_242_1:
  103. MTOPARA_TXPOWER_INDEX() = 24;
  104. break;
  105. }
  106. } else { /* follow the setting from EEPROM */
  107. MTOPARA_TXPOWER_INDEX() = MTO_TXPOWER_FROM_EEPROM;
  108. }
  109. RFSynthesizer_SetPowerIndex(MTO_HAL(), (u8) MTOPARA_TXPOWER_INDEX());
  110. /* ------------------------------------------------ */
  111. /* For RSSI turning -- Cancel load from EEPROM */
  112. MTO_DATA().RSSI_high = -41;
  113. MTO_DATA().RSSI_low = -60;
  114. }
  115. /* ===========================================================================
  116. * Description:
  117. * If we enable DTO, we will ignore the tx count with different tx rate
  118. * from DTO rate. This is because when we adjust DTO tx rate, there could
  119. * be some packets in the tx queue with previous tx rate
  120. */
  121. void MTO_SetTxCount(struct wbsoft_priv *adapter, u8 tx_rate, u8 index)
  122. {
  123. MTO_TXFLOWCOUNT()++;
  124. if ((MTO_ENABLE == 1) && (MTO_RATE_CHANGE_ENABLE() == 1)) {
  125. if (tx_rate == MTO_DATA_RATE()) {
  126. if (index == 0) {
  127. if (boSparseTxTraffic)
  128. MTO_HAL()->dto_tx_frag_count += MTOPARA_PERIODIC_CHECK_CYCLE();
  129. else
  130. MTO_HAL()->dto_tx_frag_count += 1;
  131. } else {
  132. if (index < 8) {
  133. MTO_HAL()->dto_tx_retry_count += index;
  134. MTO_HAL()->dto_tx_frag_count += (index + 1);
  135. } else {
  136. MTO_HAL()->dto_tx_retry_count += 7;
  137. MTO_HAL()->dto_tx_frag_count += 7;
  138. }
  139. }
  140. } else if (MTO_DATA_RATE() > 48 && tx_rate == 48) {
  141. /* for reducing data rate scheme, do not calculate different data rate. 3 is the reducing data rate at retry. */
  142. if (index < 3) {
  143. MTO_HAL()->dto_tx_retry_count += index;
  144. MTO_HAL()->dto_tx_frag_count += (index + 1);
  145. } else {
  146. MTO_HAL()->dto_tx_retry_count += 3;
  147. MTO_HAL()->dto_tx_frag_count += 3;
  148. }
  149. }
  150. } else {
  151. MTO_HAL()->dto_tx_retry_count += index;
  152. MTO_HAL()->dto_tx_frag_count += (index + 1);
  153. }
  154. }