1 /******************************************************************************
3 * Copyright(c) 2007 - 2017 Realtek Corporation.
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.
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
14 *****************************************************************************/
16 #include "mp_precomp.h"
17 #include "phydm_precomp.h"
19 #if (defined(CONFIG_BB_TXBF_API))
20 #if (RTL8822B_SUPPORT == 1 || RTL8192F_SUPPORT == 1 ||\
21 RTL8822C_SUPPORT == 1 || RTL8198F_SUPPORT == 1 || RTL8814B_SUPPORT == 1)
22 /*@Add by YuChen for 8822B MU-MIMO API*/
24 /*this function is only used for BFer*/
25 u8 phydm_get_ndpa_rate(void *dm_void)
27 struct dm_struct *dm = (struct dm_struct *)dm_void;
28 u8 ndpa_rate = ODM_RATE6M;
30 if (dm->rssi_min >= 30) /*@link RSSI > 30%*/
31 ndpa_rate = ODM_RATE24M;
32 else if (dm->rssi_min <= 25)
33 ndpa_rate = ODM_RATE6M;
35 PHYDM_DBG(dm, DBG_TXBF, "[%s] ndpa_rate = 0x%x\n", __func__, ndpa_rate);
40 /*this function is only used for BFer*/
41 u8 phydm_get_beamforming_sounding_info(void *dm_void, u16 *throughput,
42 u8 total_bfee_num, u8 *tx_rate)
45 u8 snddecision = 0xff;
46 struct dm_struct *dm = (struct dm_struct *)dm_void;
48 for (idx = 0; idx < total_bfee_num; idx++) {
49 if (dm->support_ic_type & (ODM_RTL8814A)) {
50 if ((tx_rate[idx] >= ODM_RATEVHTSS3MCS7 &&
51 tx_rate[idx] <= ODM_RATEVHTSS3MCS9))
52 snddecision = snddecision & ~(1 << idx);
53 } else if (dm->support_ic_type & (ODM_RTL8822B | ODM_RTL8822C |
54 ODM_RTL8812 | ODM_RTL8192F)) {
55 if ((tx_rate[idx] >= ODM_RATEVHTSS2MCS7 &&
56 tx_rate[idx] <= ODM_RATEVHTSS2MCS9))
57 snddecision = snddecision & ~(1 << idx);
58 } else if (dm->support_ic_type & (ODM_RTL8814B)) {
59 if ((tx_rate[idx] >= ODM_RATEVHTSS4MCS7 &&
60 tx_rate[idx] <= ODM_RATEVHTSS4MCS9))
61 snddecision = snddecision & ~(1 << idx);
65 for (idx = 0; idx < total_bfee_num; idx++) {
66 if (throughput[idx] <= 10)
67 snddecision = snddecision & ~(1 << idx);
70 PHYDM_DBG(dm, DBG_TXBF, "[%s] soundingdecision = 0x%x\n", __func__,
76 /*this function is only used for BFer*/
77 u8 phydm_get_mu_bfee_snding_decision(void *dm_void, u16 throughput)
80 struct dm_struct *dm = (struct dm_struct *)dm_void;
82 /*throughput unit is Mbps*/
83 if (throughput >= 500)
85 else if (throughput >= 450)
87 else if (throughput >= 400)
89 else if (throughput >= 350)
91 else if (throughput >= 300)
93 else if (throughput >= 250)
95 else if (throughput >= 200)
97 else if (throughput >= 150)
99 else if (throughput >= 100)
101 else if (throughput >= 50)
106 PHYDM_DBG(dm, DBG_TXBF, "[%s] snding_score = 0x%x\n", __func__,
113 #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
114 u8 beamforming_get_htndp_tx_rate(void *dm_void, u8 bfer_str_num)
116 struct dm_struct *dm = (struct dm_struct *)dm_void;
120 #if (RTL8814A_SUPPORT == 1)
121 if (dm->support_ic_type & ODM_RTL8814A)
122 nr_index = tx_bf_nr(hal_txbf_8814a_get_ntx(dm), bfer_str_num);
125 nr_index = tx_bf_nr(1, bfer_str_num);
129 ndp_tx_rate = ODM_MGN_MCS8;
133 ndp_tx_rate = ODM_MGN_MCS16;
137 ndp_tx_rate = ODM_MGN_MCS24;
141 ndp_tx_rate = ODM_MGN_MCS8;
148 u8 beamforming_get_vht_ndp_tx_rate(void *dm_void, u8 bfer_str_num)
150 struct dm_struct *dm = (struct dm_struct *)dm_void;
154 #if (RTL8814A_SUPPORT == 1)
155 if (dm->support_ic_type & ODM_RTL8814A)
156 nr_index = tx_bf_nr(hal_txbf_8814a_get_ntx(dm), bfer_str_num);
159 nr_index = tx_bf_nr(1, bfer_str_num);
163 ndp_tx_rate = ODM_MGN_VHT2SS_MCS0;
167 ndp_tx_rate = ODM_MGN_VHT3SS_MCS0;
171 ndp_tx_rate = ODM_MGN_VHT4SS_MCS0;
175 ndp_tx_rate = ODM_MGN_VHT2SS_MCS0;