net: wireless: rockchip_wlan: add rtl8723cs support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723cs / hal / phydm / txbf / phydm_hal_txbf_api.c
1 #include "mp_precomp.h"
2 #include "phydm_precomp.h"
3
4 #if (defined(CONFIG_BB_TXBF_API))
5 #if (RTL8822B_SUPPORT == 1)
6 /*Add by YuChen for 8822B MU-MIMO API*/
7
8 /*this function is only used for BFer*/
9 u8
10 phydm_get_ndpa_rate(
11         void            *p_dm_void
12 )
13 {
14         struct PHY_DM_STRUCT    *p_dm_odm = (struct PHY_DM_STRUCT *)p_dm_void;
15         u8              ndpa_rate = ODM_RATE6M;
16
17         if (p_dm_odm->rssi_min >= 30)   /*link RSSI > 30%*/
18                 ndpa_rate = ODM_RATE24M;
19         else if (p_dm_odm->rssi_min <= 25)
20                 ndpa_rate = ODM_RATE6M;
21
22         ODM_RT_TRACE(p_dm_odm, PHYDM_COMP_TXBF, ODM_DBG_TRACE, ("[%s] ndpa_rate = 0x%x\n", __func__, ndpa_rate));
23
24         return ndpa_rate;
25
26 }
27
28 /*this function is only used for BFer*/
29 u8
30 phydm_get_beamforming_sounding_info(
31         void            *p_dm_void,
32         u16     *troughput,
33         u8      total_bfee_num,
34         u8      *tx_rate
35 )
36 {
37         u8      idx = 0;
38         u8      soundingdecision = 0xff;
39         struct PHY_DM_STRUCT    *p_dm_odm = (struct PHY_DM_STRUCT *)p_dm_void;
40
41         for (idx = 0; idx < total_bfee_num; idx++) {
42                 if (((tx_rate[idx] >= ODM_RATEVHTSS3MCS7) && (tx_rate[idx] <= ODM_RATEVHTSS3MCS9)))
43                         soundingdecision = soundingdecision & ~(1 << idx);
44         }
45
46         for (idx = 0; idx < total_bfee_num; idx++) {
47                 if (troughput[idx] <= 10)
48                         soundingdecision = soundingdecision & ~(1 << idx);
49         }
50
51         ODM_RT_TRACE(p_dm_odm, PHYDM_COMP_TXBF, ODM_DBG_TRACE, ("[%s] soundingdecision = 0x%x\n", __func__, soundingdecision));
52
53         return soundingdecision;
54
55 }
56
57 /*this function is only used for BFer*/
58 u8
59 phydm_get_mu_bfee_snding_decision(
60         void            *p_dm_void,
61         u16     throughput
62 )
63 {
64         u8      snding_score = 0;
65         struct PHY_DM_STRUCT    *p_dm_odm = (struct PHY_DM_STRUCT *)p_dm_void;
66
67         /*throughput unit is Mbps*/
68         if (throughput >= 500)
69                 snding_score = 100;
70         else if (throughput >= 450)
71                 snding_score = 90;
72         else if (throughput >= 400)
73                 snding_score = 80;
74         else if (throughput >= 350)
75                 snding_score = 70;
76         else if (throughput >= 300)
77                 snding_score = 60;
78         else if (throughput >= 250)
79                 snding_score = 50;
80         else if (throughput >= 200)
81                 snding_score = 40;
82         else if (throughput >= 150)
83                 snding_score = 30;
84         else if (throughput >= 100)
85                 snding_score = 20;
86         else if (throughput >= 50)
87                 snding_score = 10;
88         else
89                 snding_score = 0;
90
91         ODM_RT_TRACE(p_dm_odm, PHYDM_COMP_TXBF, ODM_DBG_TRACE, ("[%s] snding_score = 0x%x\n", __func__, snding_score));
92
93         return snding_score;
94
95 }
96
97
98 #endif
99 #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
100 u8
101 beamforming_get_htndp_tx_rate(
102         void    *p_dm_void,
103         u8      comp_steering_num_of_bfer
104 )
105 {
106         struct PHY_DM_STRUCT    *p_dm_odm = (struct PHY_DM_STRUCT *)p_dm_void;
107         u8 nr_index = 0;
108         u8 ndp_tx_rate;
109         /*Find nr*/
110 #if (RTL8814A_SUPPORT == 1)
111         if (p_dm_odm->support_ic_type & ODM_RTL8814A)
112                 nr_index = tx_bf_nr(hal_txbf_8814a_get_ntx(p_dm_odm), comp_steering_num_of_bfer);
113         else
114 #endif
115                 nr_index = tx_bf_nr(1, comp_steering_num_of_bfer);
116
117         switch (nr_index) {
118         case 1:
119                 ndp_tx_rate = ODM_MGN_MCS8;
120                 break;
121
122         case 2:
123                 ndp_tx_rate = ODM_MGN_MCS16;
124                 break;
125
126         case 3:
127                 ndp_tx_rate = ODM_MGN_MCS24;
128                 break;
129
130         default:
131                 ndp_tx_rate = ODM_MGN_MCS8;
132                 break;
133         }
134
135         return ndp_tx_rate;
136
137 }
138
139 u8
140 beamforming_get_vht_ndp_tx_rate(
141         void    *p_dm_void,
142         u8      comp_steering_num_of_bfer
143 )
144 {
145         struct PHY_DM_STRUCT    *p_dm_odm = (struct PHY_DM_STRUCT *)p_dm_void;
146         u8 nr_index = 0;
147         u8 ndp_tx_rate;
148         /*Find nr*/
149 #if (RTL8814A_SUPPORT == 1)
150         if (p_dm_odm->support_ic_type & ODM_RTL8814A)
151                 nr_index = tx_bf_nr(hal_txbf_8814a_get_ntx(p_dm_odm), comp_steering_num_of_bfer);
152         else
153 #endif
154                 nr_index = tx_bf_nr(1, comp_steering_num_of_bfer);
155
156         switch (nr_index) {
157         case 1:
158                 ndp_tx_rate = ODM_MGN_VHT2SS_MCS0;
159                 break;
160
161         case 2:
162                 ndp_tx_rate = ODM_MGN_VHT3SS_MCS0;
163                 break;
164
165         case 3:
166                 ndp_tx_rate = ODM_MGN_VHT4SS_MCS0;
167                 break;
168
169         default:
170                 ndp_tx_rate = ODM_MGN_VHT2SS_MCS0;
171                 break;
172         }
173
174         return ndp_tx_rate;
175
176 }
177 #endif
178
179 #endif