phydm_hal_txbf_api.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2017 Realtek Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. *****************************************************************************/
  15. #include "mp_precomp.h"
  16. #include "phydm_precomp.h"
  17. #if (defined(CONFIG_BB_TXBF_API))
  18. #if (RTL8822B_SUPPORT == 1 || RTL8192F_SUPPORT == 1 ||\
  19. RTL8822C_SUPPORT == 1 || RTL8198F_SUPPORT == 1 || RTL8814B_SUPPORT == 1)
  20. /*@Add by YuChen for 8822B MU-MIMO API*/
  21. /*this function is only used for BFer*/
  22. u8 phydm_get_ndpa_rate(void *dm_void)
  23. {
  24. struct dm_struct *dm = (struct dm_struct *)dm_void;
  25. u8 ndpa_rate = ODM_RATE6M;
  26. if (dm->rssi_min >= 30) /*@link RSSI > 30%*/
  27. ndpa_rate = ODM_RATE24M;
  28. else if (dm->rssi_min <= 25)
  29. ndpa_rate = ODM_RATE6M;
  30. PHYDM_DBG(dm, DBG_TXBF, "[%s] ndpa_rate = 0x%x\n", __func__, ndpa_rate);
  31. return ndpa_rate;
  32. }
  33. /*this function is only used for BFer*/
  34. u8 phydm_get_beamforming_sounding_info(void *dm_void, u16 *throughput,
  35. u8 total_bfee_num, u8 *tx_rate)
  36. {
  37. u8 idx = 0;
  38. u8 snddecision = 0xff;
  39. struct dm_struct *dm = (struct dm_struct *)dm_void;
  40. for (idx = 0; idx < total_bfee_num; idx++) {
  41. if (dm->support_ic_type & (ODM_RTL8814A)) {
  42. if ((tx_rate[idx] >= ODM_RATEVHTSS3MCS7 &&
  43. tx_rate[idx] <= ODM_RATEVHTSS3MCS9))
  44. snddecision = snddecision & ~(1 << idx);
  45. } else if (dm->support_ic_type & (ODM_RTL8822B | ODM_RTL8822C |
  46. ODM_RTL8812 | ODM_RTL8192F)) {
  47. if ((tx_rate[idx] >= ODM_RATEVHTSS2MCS7 &&
  48. tx_rate[idx] <= ODM_RATEVHTSS2MCS9))
  49. snddecision = snddecision & ~(1 << idx);
  50. } else if (dm->support_ic_type & (ODM_RTL8814B)) {
  51. if ((tx_rate[idx] >= ODM_RATEVHTSS4MCS7 &&
  52. tx_rate[idx] <= ODM_RATEVHTSS4MCS9))
  53. snddecision = snddecision & ~(1 << idx);
  54. }
  55. }
  56. for (idx = 0; idx < total_bfee_num; idx++) {
  57. if (throughput[idx] <= 10)
  58. snddecision = snddecision & ~(1 << idx);
  59. }
  60. PHYDM_DBG(dm, DBG_TXBF, "[%s] soundingdecision = 0x%x\n", __func__,
  61. snddecision);
  62. return snddecision;
  63. }
  64. /*this function is only used for BFer*/
  65. u8 phydm_get_mu_bfee_snding_decision(void *dm_void, u16 throughput)
  66. {
  67. u8 snding_score = 0;
  68. struct dm_struct *dm = (struct dm_struct *)dm_void;
  69. /*throughput unit is Mbps*/
  70. if (throughput >= 500)
  71. snding_score = 100;
  72. else if (throughput >= 450)
  73. snding_score = 90;
  74. else if (throughput >= 400)
  75. snding_score = 80;
  76. else if (throughput >= 350)
  77. snding_score = 70;
  78. else if (throughput >= 300)
  79. snding_score = 60;
  80. else if (throughput >= 250)
  81. snding_score = 50;
  82. else if (throughput >= 200)
  83. snding_score = 40;
  84. else if (throughput >= 150)
  85. snding_score = 30;
  86. else if (throughput >= 100)
  87. snding_score = 20;
  88. else if (throughput >= 50)
  89. snding_score = 10;
  90. else
  91. snding_score = 0;
  92. PHYDM_DBG(dm, DBG_TXBF, "[%s] snding_score = 0x%x\n", __func__,
  93. snding_score);
  94. return snding_score;
  95. }
  96. #endif
  97. #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
  98. u8 beamforming_get_htndp_tx_rate(void *dm_void, u8 bfer_str_num)
  99. {
  100. struct dm_struct *dm = (struct dm_struct *)dm_void;
  101. u8 nr_index = 0;
  102. u8 ndp_tx_rate;
  103. /*@Find nr*/
  104. #if (RTL8814A_SUPPORT == 1)
  105. if (dm->support_ic_type & ODM_RTL8814A)
  106. nr_index = tx_bf_nr(hal_txbf_8814a_get_ntx(dm), bfer_str_num);
  107. else
  108. #endif
  109. nr_index = tx_bf_nr(1, bfer_str_num);
  110. switch (nr_index) {
  111. case 1:
  112. ndp_tx_rate = ODM_MGN_MCS8;
  113. break;
  114. case 2:
  115. ndp_tx_rate = ODM_MGN_MCS16;
  116. break;
  117. case 3:
  118. ndp_tx_rate = ODM_MGN_MCS24;
  119. break;
  120. default:
  121. ndp_tx_rate = ODM_MGN_MCS8;
  122. break;
  123. }
  124. return ndp_tx_rate;
  125. }
  126. u8 beamforming_get_vht_ndp_tx_rate(void *dm_void, u8 bfer_str_num)
  127. {
  128. struct dm_struct *dm = (struct dm_struct *)dm_void;
  129. u8 nr_index = 0;
  130. u8 ndp_tx_rate;
  131. /*@Find nr*/
  132. #if (RTL8814A_SUPPORT == 1)
  133. if (dm->support_ic_type & ODM_RTL8814A)
  134. nr_index = tx_bf_nr(hal_txbf_8814a_get_ntx(dm), bfer_str_num);
  135. else
  136. #endif
  137. nr_index = tx_bf_nr(1, bfer_str_num);
  138. switch (nr_index) {
  139. case 1:
  140. ndp_tx_rate = ODM_MGN_VHT2SS_MCS0;
  141. break;
  142. case 2:
  143. ndp_tx_rate = ODM_MGN_VHT3SS_MCS0;
  144. break;
  145. case 3:
  146. ndp_tx_rate = ODM_MGN_VHT4SS_MCS0;
  147. break;
  148. default:
  149. ndp_tx_rate = ODM_MGN_VHT2SS_MCS0;
  150. break;
  151. }
  152. return ndp_tx_rate;
  153. }
  154. #endif
  155. #endif