diff options
Diffstat (limited to 'drivers/net/wireless/rtlwifi/rtl8188ee/trx.c')
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8188ee/trx.c | 443 |
1 files changed, 321 insertions, 122 deletions
diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c index 5b4c225396f2..df549c96adef 100644 --- a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c | |||
@@ -11,10 +11,6 @@ | |||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
12 | * more details. | 12 | * more details. |
13 | * | 13 | * |
14 | * You should have received a copy of the GNU General Public License along with | ||
15 | * this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA | ||
17 | * | ||
18 | * The full GNU General Public License is included in this distribution in the | 14 | * The full GNU General Public License is included in this distribution in the |
19 | * file called LICENSE. | 15 | * file called LICENSE. |
20 | * | 16 | * |
@@ -37,6 +33,7 @@ | |||
37 | #include "trx.h" | 33 | #include "trx.h" |
38 | #include "led.h" | 34 | #include "led.h" |
39 | #include "dm.h" | 35 | #include "dm.h" |
36 | #include "phy.h" | ||
40 | 37 | ||
41 | static u8 _rtl88ee_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue) | 38 | static u8 _rtl88ee_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue) |
42 | { | 39 | { |
@@ -50,6 +47,164 @@ static u8 _rtl88ee_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue) | |||
50 | return skb->priority; | 47 | return skb->priority; |
51 | } | 48 | } |
52 | 49 | ||
50 | /* mac80211's rate_idx is like this: | ||
51 | * | ||
52 | * 2.4G band:rx_status->band == IEEE80211_BAND_2GHZ | ||
53 | * | ||
54 | * B/G rate: | ||
55 | * (rx_status->flag & RX_FLAG_HT) = 0, | ||
56 | * DESC92C_RATE1M-->DESC92C_RATE54M ==> idx is 0-->11, | ||
57 | * | ||
58 | * N rate: | ||
59 | * (rx_status->flag & RX_FLAG_HT) = 1, | ||
60 | * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15 | ||
61 | * | ||
62 | * 5G band:rx_status->band == IEEE80211_BAND_5GHZ | ||
63 | * A rate: | ||
64 | * (rx_status->flag & RX_FLAG_HT) = 0, | ||
65 | * DESC92C_RATE6M-->DESC92C_RATE54M ==> idx is 0-->7, | ||
66 | * | ||
67 | * N rate: | ||
68 | * (rx_status->flag & RX_FLAG_HT) = 1, | ||
69 | * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15 | ||
70 | */ | ||
71 | static int _rtl88ee_rate_mapping(struct ieee80211_hw *hw, | ||
72 | bool isht, u8 desc_rate) | ||
73 | { | ||
74 | int rate_idx; | ||
75 | |||
76 | if (!isht) { | ||
77 | if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) { | ||
78 | switch (desc_rate) { | ||
79 | case DESC92C_RATE1M: | ||
80 | rate_idx = 0; | ||
81 | break; | ||
82 | case DESC92C_RATE2M: | ||
83 | rate_idx = 1; | ||
84 | break; | ||
85 | case DESC92C_RATE5_5M: | ||
86 | rate_idx = 2; | ||
87 | break; | ||
88 | case DESC92C_RATE11M: | ||
89 | rate_idx = 3; | ||
90 | break; | ||
91 | case DESC92C_RATE6M: | ||
92 | rate_idx = 4; | ||
93 | break; | ||
94 | case DESC92C_RATE9M: | ||
95 | rate_idx = 5; | ||
96 | break; | ||
97 | case DESC92C_RATE12M: | ||
98 | rate_idx = 6; | ||
99 | break; | ||
100 | case DESC92C_RATE18M: | ||
101 | rate_idx = 7; | ||
102 | break; | ||
103 | case DESC92C_RATE24M: | ||
104 | rate_idx = 8; | ||
105 | break; | ||
106 | case DESC92C_RATE36M: | ||
107 | rate_idx = 9; | ||
108 | break; | ||
109 | case DESC92C_RATE48M: | ||
110 | rate_idx = 10; | ||
111 | break; | ||
112 | case DESC92C_RATE54M: | ||
113 | rate_idx = 11; | ||
114 | break; | ||
115 | default: | ||
116 | rate_idx = 0; | ||
117 | break; | ||
118 | } | ||
119 | } else { | ||
120 | switch (desc_rate) { | ||
121 | case DESC92C_RATE6M: | ||
122 | rate_idx = 0; | ||
123 | break; | ||
124 | case DESC92C_RATE9M: | ||
125 | rate_idx = 1; | ||
126 | break; | ||
127 | case DESC92C_RATE12M: | ||
128 | rate_idx = 2; | ||
129 | break; | ||
130 | case DESC92C_RATE18M: | ||
131 | rate_idx = 3; | ||
132 | break; | ||
133 | case DESC92C_RATE24M: | ||
134 | rate_idx = 4; | ||
135 | break; | ||
136 | case DESC92C_RATE36M: | ||
137 | rate_idx = 5; | ||
138 | break; | ||
139 | case DESC92C_RATE48M: | ||
140 | rate_idx = 6; | ||
141 | break; | ||
142 | case DESC92C_RATE54M: | ||
143 | rate_idx = 7; | ||
144 | break; | ||
145 | default: | ||
146 | rate_idx = 0; | ||
147 | break; | ||
148 | } | ||
149 | } | ||
150 | } else { | ||
151 | switch (desc_rate) { | ||
152 | case DESC92C_RATEMCS0: | ||
153 | rate_idx = 0; | ||
154 | break; | ||
155 | case DESC92C_RATEMCS1: | ||
156 | rate_idx = 1; | ||
157 | break; | ||
158 | case DESC92C_RATEMCS2: | ||
159 | rate_idx = 2; | ||
160 | break; | ||
161 | case DESC92C_RATEMCS3: | ||
162 | rate_idx = 3; | ||
163 | break; | ||
164 | case DESC92C_RATEMCS4: | ||
165 | rate_idx = 4; | ||
166 | break; | ||
167 | case DESC92C_RATEMCS5: | ||
168 | rate_idx = 5; | ||
169 | break; | ||
170 | case DESC92C_RATEMCS6: | ||
171 | rate_idx = 6; | ||
172 | break; | ||
173 | case DESC92C_RATEMCS7: | ||
174 | rate_idx = 7; | ||
175 | break; | ||
176 | case DESC92C_RATEMCS8: | ||
177 | rate_idx = 8; | ||
178 | break; | ||
179 | case DESC92C_RATEMCS9: | ||
180 | rate_idx = 9; | ||
181 | break; | ||
182 | case DESC92C_RATEMCS10: | ||
183 | rate_idx = 10; | ||
184 | break; | ||
185 | case DESC92C_RATEMCS11: | ||
186 | rate_idx = 11; | ||
187 | break; | ||
188 | case DESC92C_RATEMCS12: | ||
189 | rate_idx = 12; | ||
190 | break; | ||
191 | case DESC92C_RATEMCS13: | ||
192 | rate_idx = 13; | ||
193 | break; | ||
194 | case DESC92C_RATEMCS14: | ||
195 | rate_idx = 14; | ||
196 | break; | ||
197 | case DESC92C_RATEMCS15: | ||
198 | rate_idx = 15; | ||
199 | break; | ||
200 | default: | ||
201 | rate_idx = 0; | ||
202 | break; | ||
203 | } | ||
204 | } | ||
205 | return rate_idx; | ||
206 | } | ||
207 | |||
53 | static void _rtl88ee_query_rxphystatus(struct ieee80211_hw *hw, | 208 | static void _rtl88ee_query_rxphystatus(struct ieee80211_hw *hw, |
54 | struct rtl_stats *pstatus, u8 *pdesc, | 209 | struct rtl_stats *pstatus, u8 *pdesc, |
55 | struct rx_fwinfo_88e *p_drvinfo, | 210 | struct rx_fwinfo_88e *p_drvinfo, |
@@ -59,7 +214,8 @@ static void _rtl88ee_query_rxphystatus(struct ieee80211_hw *hw, | |||
59 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 214 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
60 | struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv); | 215 | struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv); |
61 | struct phy_sts_cck_8192s_t *cck_buf; | 216 | struct phy_sts_cck_8192s_t *cck_buf; |
62 | struct phy_status_rpt *phystrpt = (struct phy_status_rpt *)p_drvinfo; | 217 | struct phy_status_rpt *phystrpt = |
218 | (struct phy_status_rpt *)p_drvinfo; | ||
63 | struct rtl_dm *rtldm = rtl_dm(rtl_priv(hw)); | 219 | struct rtl_dm *rtldm = rtl_dm(rtl_priv(hw)); |
64 | char rx_pwr_all = 0, rx_pwr[4]; | 220 | char rx_pwr_all = 0, rx_pwr[4]; |
65 | u8 rf_rx_num = 0, evm, pwdb_all; | 221 | u8 rf_rx_num = 0, evm, pwdb_all; |
@@ -72,11 +228,11 @@ static void _rtl88ee_query_rxphystatus(struct ieee80211_hw *hw, | |||
72 | pstatus->packet_matchbssid = bpacket_match_bssid; | 228 | pstatus->packet_matchbssid = bpacket_match_bssid; |
73 | pstatus->packet_toself = bpacket_toself; | 229 | pstatus->packet_toself = bpacket_toself; |
74 | pstatus->packet_beacon = packet_beacon; | 230 | pstatus->packet_beacon = packet_beacon; |
75 | pstatus->rx_mimo_sig_qual[0] = -1; | 231 | pstatus->rx_mimo_signalquality[0] = -1; |
76 | pstatus->rx_mimo_sig_qual[1] = -1; | 232 | pstatus->rx_mimo_signalquality[1] = -1; |
77 | 233 | ||
78 | if (is_cck) { | 234 | if (is_cck) { |
79 | u8 cck_hipwr; | 235 | u8 cck_highpwr; |
80 | u8 cck_agc_rpt; | 236 | u8 cck_agc_rpt; |
81 | /* CCK Driver info Structure is not the same as OFDM packet. */ | 237 | /* CCK Driver info Structure is not the same as OFDM packet. */ |
82 | cck_buf = (struct phy_sts_cck_8192s_t *)p_drvinfo; | 238 | cck_buf = (struct phy_sts_cck_8192s_t *)p_drvinfo; |
@@ -87,53 +243,58 @@ static void _rtl88ee_query_rxphystatus(struct ieee80211_hw *hw, | |||
87 | * hardware (for rate adaptive) | 243 | * hardware (for rate adaptive) |
88 | */ | 244 | */ |
89 | if (ppsc->rfpwr_state == ERFON) | 245 | if (ppsc->rfpwr_state == ERFON) |
90 | cck_hipwr = rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, | 246 | cck_highpwr = |
247 | (u8)rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, | ||
91 | BIT(9)); | 248 | BIT(9)); |
92 | else | 249 | else |
93 | cck_hipwr = false; | 250 | cck_highpwr = false; |
94 | 251 | ||
95 | lan_idx = ((cck_agc_rpt & 0xE0) >> 5); | 252 | lan_idx = ((cck_agc_rpt & 0xE0) >> 5); |
96 | vga_idx = (cck_agc_rpt & 0x1f); | 253 | vga_idx = (cck_agc_rpt & 0x1f); |
97 | switch (lan_idx) { | 254 | switch (lan_idx) { |
98 | case 7: | 255 | case 7: |
99 | if (vga_idx <= 27) | 256 | if (vga_idx <= 27) |
100 | rx_pwr_all = -100 + 2 * (27 - vga_idx); | 257 | /*VGA_idx = 27~2*/ |
258 | rx_pwr_all = -100 + 2*(27-vga_idx); | ||
101 | else | 259 | else |
102 | rx_pwr_all = -100; | 260 | rx_pwr_all = -100; |
103 | break; | 261 | break; |
104 | case 6: | 262 | case 6: |
105 | rx_pwr_all = -48 + 2 * (2 - vga_idx); /*VGA_idx = 2~0*/ | 263 | /*VGA_idx = 2~0*/ |
264 | rx_pwr_all = -48 + 2*(2-vga_idx); | ||
106 | break; | 265 | break; |
107 | case 5: | 266 | case 5: |
108 | rx_pwr_all = -42 + 2 * (7 - vga_idx); /*VGA_idx = 7~5*/ | 267 | /*VGA_idx = 7~5*/ |
268 | rx_pwr_all = -42 + 2*(7-vga_idx); | ||
109 | break; | 269 | break; |
110 | case 4: | 270 | case 4: |
111 | rx_pwr_all = -36 + 2 * (7 - vga_idx); /*VGA_idx = 7~4*/ | 271 | /*VGA_idx = 7~4*/ |
272 | rx_pwr_all = -36 + 2*(7-vga_idx); | ||
112 | break; | 273 | break; |
113 | case 3: | 274 | case 3: |
114 | rx_pwr_all = -24 + 2 * (7 - vga_idx); /*VGA_idx = 7~0*/ | 275 | /*VGA_idx = 7~0*/ |
276 | rx_pwr_all = -24 + 2*(7-vga_idx); | ||
115 | break; | 277 | break; |
116 | case 2: | 278 | case 2: |
117 | if (cck_hipwr) | 279 | if (cck_highpwr) |
118 | rx_pwr_all = -12 + 2 * (5 - vga_idx); | 280 | /*VGA_idx = 5~0*/ |
281 | rx_pwr_all = -12 + 2*(5-vga_idx); | ||
119 | else | 282 | else |
120 | rx_pwr_all = -6 + 2 * (5 - vga_idx); | 283 | rx_pwr_all = -6 + 2*(5-vga_idx); |
121 | break; | 284 | break; |
122 | case 1: | 285 | case 1: |
123 | rx_pwr_all = 8 - 2 * vga_idx; | 286 | rx_pwr_all = 8-2*vga_idx; |
124 | break; | 287 | break; |
125 | case 0: | 288 | case 0: |
126 | rx_pwr_all = 14 - 2 * vga_idx; | 289 | rx_pwr_all = 14-2*vga_idx; |
127 | break; | 290 | break; |
128 | default: | 291 | default: |
129 | break; | 292 | break; |
130 | } | 293 | } |
131 | rx_pwr_all += 6; | 294 | rx_pwr_all += 6; |
132 | pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all); | 295 | pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all); |
133 | /* CCK gain is smaller than OFDM/MCS gain, | 296 | /* CCK gain is smaller than OFDM/MCS gain, */ |
134 | * so we add gain diff by experiences, | 297 | /* so we add gain diff by experiences, the val is 6 */ |
135 | * the val is 6 | ||
136 | */ | ||
137 | pwdb_all += 6; | 298 | pwdb_all += 6; |
138 | if (pwdb_all > 100) | 299 | if (pwdb_all > 100) |
139 | pwdb_all = 100; | 300 | pwdb_all = 100; |
@@ -148,10 +309,10 @@ static void _rtl88ee_query_rxphystatus(struct ieee80211_hw *hw, | |||
148 | pwdb_all -= 8; | 309 | pwdb_all -= 8; |
149 | else if (pwdb_all > 4 && pwdb_all <= 14) | 310 | else if (pwdb_all > 4 && pwdb_all <= 14) |
150 | pwdb_all -= 4; | 311 | pwdb_all -= 4; |
151 | if (cck_hipwr == false) { | 312 | if (!cck_highpwr) { |
152 | if (pwdb_all >= 80) | 313 | if (pwdb_all >= 80) |
153 | pwdb_all = ((pwdb_all - 80)<<1) + | 314 | pwdb_all = ((pwdb_all-80)<<1) + |
154 | ((pwdb_all - 80)>>1) + 80; | 315 | ((pwdb_all-80)>>1) + 80; |
155 | else if ((pwdb_all <= 78) && (pwdb_all >= 20)) | 316 | else if ((pwdb_all <= 78) && (pwdb_all >= 20)) |
156 | pwdb_all += 3; | 317 | pwdb_all += 3; |
157 | if (pwdb_all > 100) | 318 | if (pwdb_all > 100) |
@@ -165,9 +326,9 @@ static void _rtl88ee_query_rxphystatus(struct ieee80211_hw *hw, | |||
165 | if (bpacket_match_bssid) { | 326 | if (bpacket_match_bssid) { |
166 | u8 sq; | 327 | u8 sq; |
167 | 328 | ||
168 | if (pstatus->rx_pwdb_all > 40) { | 329 | if (pstatus->rx_pwdb_all > 40) |
169 | sq = 100; | 330 | sq = 100; |
170 | } else { | 331 | else { |
171 | sq = cck_buf->sq_rpt; | 332 | sq = cck_buf->sq_rpt; |
172 | if (sq > 64) | 333 | if (sq > 64) |
173 | sq = 0; | 334 | sq = 0; |
@@ -178,8 +339,8 @@ static void _rtl88ee_query_rxphystatus(struct ieee80211_hw *hw, | |||
178 | } | 339 | } |
179 | 340 | ||
180 | pstatus->signalquality = sq; | 341 | pstatus->signalquality = sq; |
181 | pstatus->rx_mimo_sig_qual[0] = sq; | 342 | pstatus->rx_mimo_signalquality[0] = sq; |
182 | pstatus->rx_mimo_sig_qual[1] = -1; | 343 | pstatus->rx_mimo_signalquality[1] = -1; |
183 | } | 344 | } |
184 | } else { | 345 | } else { |
185 | rtlpriv->dm.rfpath_rxenable[0] = | 346 | rtlpriv->dm.rfpath_rxenable[0] = |
@@ -191,18 +352,20 @@ static void _rtl88ee_query_rxphystatus(struct ieee80211_hw *hw, | |||
191 | if (rtlpriv->dm.rfpath_rxenable[i]) | 352 | if (rtlpriv->dm.rfpath_rxenable[i]) |
192 | rf_rx_num++; | 353 | rf_rx_num++; |
193 | 354 | ||
194 | rx_pwr[i] = ((p_drvinfo->gain_trsw[i] & 0x3f) * 2)-110; | 355 | rx_pwr[i] = ((p_drvinfo->gain_trsw[i] & |
356 | 0x3f) * 2) - 110; | ||
195 | 357 | ||
196 | /* Translate DBM to percentage. */ | 358 | /* Translate DBM to percentage. */ |
197 | rssi = rtl_query_rxpwrpercentage(rx_pwr[i]); | 359 | rssi = rtl_query_rxpwrpercentage(rx_pwr[i]); |
198 | total_rssi += rssi; | 360 | total_rssi += rssi; |
199 | 361 | ||
200 | /* Get Rx snr value in DB */ | 362 | /* Get Rx snr value in DB */ |
201 | rtlpriv->stats.rx_snr_db[i] = p_drvinfo->rxsnr[i] / 2; | 363 | rtlpriv->stats.rx_snr_db[i] = |
364 | (long)(p_drvinfo->rxsnr[i] / 2); | ||
202 | 365 | ||
203 | /* Record Signal Strength for next packet */ | 366 | /* Record Signal Strength for next packet */ |
204 | if (bpacket_match_bssid) | 367 | if (bpacket_match_bssid) |
205 | pstatus->rx_mimo_signalstrength[i] = (u8) rssi; | 368 | pstatus->rx_mimo_signalstrength[i] = (u8)rssi; |
206 | } | 369 | } |
207 | 370 | ||
208 | /* (2)PWDB, Average PWDB cacluated by | 371 | /* (2)PWDB, Average PWDB cacluated by |
@@ -227,11 +390,13 @@ static void _rtl88ee_query_rxphystatus(struct ieee80211_hw *hw, | |||
227 | 390 | ||
228 | if (bpacket_match_bssid) { | 391 | if (bpacket_match_bssid) { |
229 | /* Fill value in RFD, Get the first | 392 | /* Fill value in RFD, Get the first |
230 | * spatial stream only | 393 | * spatial stream onlyi |
231 | */ | 394 | */ |
232 | if (i == 0) | 395 | if (i == 0) |
233 | pstatus->signalquality = evm & 0xff; | 396 | pstatus->signalquality = |
234 | pstatus->rx_mimo_sig_qual[i] = evm & 0xff; | 397 | (u8)(evm & 0xff); |
398 | pstatus->rx_mimo_signalquality[i] = | ||
399 | (u8)(evm & 0xff); | ||
235 | } | 400 | } |
236 | } | 401 | } |
237 | } | 402 | } |
@@ -241,10 +406,10 @@ static void _rtl88ee_query_rxphystatus(struct ieee80211_hw *hw, | |||
241 | */ | 406 | */ |
242 | if (is_cck) | 407 | if (is_cck) |
243 | pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw, | 408 | pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw, |
244 | pwdb_all)); | 409 | pwdb_all)); |
245 | else if (rf_rx_num != 0) | 410 | else if (rf_rx_num != 0) |
246 | pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw, | 411 | pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw, |
247 | total_rssi /= rf_rx_num)); | 412 | total_rssi /= rf_rx_num)); |
248 | /*HW antenna diversity*/ | 413 | /*HW antenna diversity*/ |
249 | rtldm->fat_table.antsel_rx_keep_0 = phystrpt->ant_sel; | 414 | rtldm->fat_table.antsel_rx_keep_0 = phystrpt->ant_sel; |
250 | rtldm->fat_table.antsel_rx_keep_1 = phystrpt->ant_sel_b; | 415 | rtldm->fat_table.antsel_rx_keep_1 = phystrpt->ant_sel_b; |
@@ -256,34 +421,39 @@ static void _rtl88ee_smart_antenna(struct ieee80211_hw *hw, | |||
256 | { | 421 | { |
257 | struct rtl_dm *rtldm = rtl_dm(rtl_priv(hw)); | 422 | struct rtl_dm *rtldm = rtl_dm(rtl_priv(hw)); |
258 | struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); | 423 | struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); |
259 | u8 ant_mux; | 424 | u8 antsel_tr_mux; |
260 | struct fast_ant_training *pfat = &(rtldm->fat_table); | 425 | struct fast_ant_training *pfat_table = &rtldm->fat_table; |
261 | 426 | ||
262 | if (rtlefuse->antenna_div_type == CG_TRX_SMART_ANTDIV) { | 427 | if (rtlefuse->antenna_div_type == CG_TRX_SMART_ANTDIV) { |
263 | if (pfat->fat_state == FAT_TRAINING_STATE) { | 428 | if (pfat_table->fat_state == FAT_TRAINING_STATE) { |
264 | if (pstatus->packet_toself) { | 429 | if (pstatus->packet_toself) { |
265 | ant_mux = (pfat->antsel_rx_keep_2 << 2) | | 430 | antsel_tr_mux = |
266 | (pfat->antsel_rx_keep_1 << 1) | | 431 | (pfat_table->antsel_rx_keep_2 << 2) | |
267 | pfat->antsel_rx_keep_0; | 432 | (pfat_table->antsel_rx_keep_1 << 1) | |
268 | pfat->ant_sum[ant_mux] += pstatus->rx_pwdb_all; | 433 | pfat_table->antsel_rx_keep_0; |
269 | pfat->ant_cnt[ant_mux]++; | 434 | pfat_table->ant_sum[antsel_tr_mux] += |
435 | pstatus->rx_pwdb_all; | ||
436 | pfat_table->ant_cnt[antsel_tr_mux]++; | ||
270 | } | 437 | } |
271 | } | 438 | } |
272 | } else if ((rtlefuse->antenna_div_type == CG_TRX_HW_ANTDIV) || | 439 | } else if ((rtlefuse->antenna_div_type == CG_TRX_HW_ANTDIV) || |
273 | (rtlefuse->antenna_div_type == CGCS_RX_HW_ANTDIV)) { | 440 | (rtlefuse->antenna_div_type == CGCS_RX_HW_ANTDIV)) { |
274 | if (pstatus->packet_toself || pstatus->packet_matchbssid) { | 441 | if (pstatus->packet_toself || pstatus->packet_matchbssid) { |
275 | ant_mux = (pfat->antsel_rx_keep_2 << 2) | | 442 | antsel_tr_mux = (pfat_table->antsel_rx_keep_2 << 2) | |
276 | (pfat->antsel_rx_keep_1 << 1) | | 443 | (pfat_table->antsel_rx_keep_1 << 1) | |
277 | pfat->antsel_rx_keep_0; | 444 | pfat_table->antsel_rx_keep_0; |
278 | rtl88e_dm_ant_sel_statistics(hw, ant_mux, 0, | 445 | rtl88e_dm_ant_sel_statistics(hw, antsel_tr_mux, 0, |
279 | pstatus->rx_pwdb_all); | 446 | pstatus->rx_pwdb_all); |
280 | } | 447 | } |
448 | |||
281 | } | 449 | } |
282 | } | 450 | } |
283 | 451 | ||
284 | static void _rtl88ee_translate_rx_signal_stuff(struct ieee80211_hw *hw, | 452 | static void _rtl88ee_translate_rx_signal_stuff(struct ieee80211_hw *hw, |
285 | struct sk_buff *skb, struct rtl_stats *pstatus, | 453 | struct sk_buff *skb, |
286 | u8 *pdesc, struct rx_fwinfo_88e *p_drvinfo) | 454 | struct rtl_stats *pstatus, |
455 | u8 *pdesc, | ||
456 | struct rx_fwinfo_88e *p_drvinfo) | ||
287 | { | 457 | { |
288 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | 458 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
289 | struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); | 459 | struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); |
@@ -292,42 +462,42 @@ static void _rtl88ee_translate_rx_signal_stuff(struct ieee80211_hw *hw, | |||
292 | u8 *praddr; | 462 | u8 *praddr; |
293 | u8 *psaddr; | 463 | u8 *psaddr; |
294 | __le16 fc; | 464 | __le16 fc; |
295 | u16 type, ufc; | 465 | bool packet_matchbssid, packet_toself, packet_beacon; |
296 | bool match_bssid, packet_toself, packet_beacon = false, addr; | ||
297 | 466 | ||
298 | tmp_buf = skb->data + pstatus->rx_drvinfo_size + pstatus->rx_bufshift; | 467 | tmp_buf = skb->data + pstatus->rx_drvinfo_size + pstatus->rx_bufshift; |
299 | 468 | ||
300 | hdr = (struct ieee80211_hdr *)tmp_buf; | 469 | hdr = (struct ieee80211_hdr *)tmp_buf; |
301 | fc = hdr->frame_control; | 470 | fc = hdr->frame_control; |
302 | ufc = le16_to_cpu(fc); | ||
303 | type = WLAN_FC_GET_TYPE(fc); | ||
304 | praddr = hdr->addr1; | 471 | praddr = hdr->addr1; |
305 | psaddr = ieee80211_get_SA(hdr); | 472 | psaddr = ieee80211_get_SA(hdr); |
306 | memcpy(pstatus->psaddr, psaddr, ETH_ALEN); | 473 | memcpy(pstatus->psaddr, psaddr, ETH_ALEN); |
307 | 474 | ||
308 | addr = ether_addr_equal(mac->bssid, | 475 | packet_matchbssid = ((!ieee80211_is_ctl(fc)) && |
309 | (ufc & IEEE80211_FCTL_TODS) ? hdr->addr1 : | 476 | (ether_addr_equal(mac->bssid, ieee80211_has_tods(fc) ? |
310 | (ufc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 : | 477 | hdr->addr1 : ieee80211_has_fromds(fc) ? |
311 | hdr->addr3); | 478 | hdr->addr2 : hdr->addr3)) && |
312 | match_bssid = ((IEEE80211_FTYPE_CTL != type) && (!pstatus->hwerror) && | 479 | (!pstatus->hwerror) && |
313 | (!pstatus->crc) && (!pstatus->icv)) && addr; | 480 | (!pstatus->crc) && (!pstatus->icv)); |
314 | 481 | ||
315 | addr = ether_addr_equal(praddr, rtlefuse->dev_addr); | 482 | packet_toself = packet_matchbssid && |
316 | packet_toself = match_bssid && addr; | 483 | (ether_addr_equal(praddr, rtlefuse->dev_addr)); |
317 | 484 | ||
318 | if (ieee80211_is_beacon(fc)) | 485 | if (ieee80211_is_beacon(hdr->frame_control)) |
319 | packet_beacon = true; | 486 | packet_beacon = true; |
487 | else | ||
488 | packet_beacon = false; | ||
320 | 489 | ||
321 | _rtl88ee_query_rxphystatus(hw, pstatus, pdesc, p_drvinfo, | 490 | _rtl88ee_query_rxphystatus(hw, pstatus, pdesc, p_drvinfo, |
322 | match_bssid, packet_toself, packet_beacon); | 491 | packet_matchbssid, packet_toself, |
492 | packet_beacon); | ||
323 | _rtl88ee_smart_antenna(hw, pstatus); | 493 | _rtl88ee_smart_antenna(hw, pstatus); |
324 | rtl_process_phyinfo(hw, tmp_buf, pstatus); | 494 | rtl_process_phyinfo(hw, tmp_buf, pstatus); |
325 | } | 495 | } |
326 | 496 | ||
327 | static void insert_em(struct rtl_tcb_desc *ptcb_desc, u8 *virtualaddress) | 497 | static void _rtl88ee_insert_emcontent(struct rtl_tcb_desc *ptcb_desc, |
498 | u8 *virtualaddress) | ||
328 | { | 499 | { |
329 | u32 dwtmp = 0; | 500 | u32 dwtmp = 0; |
330 | |||
331 | memset(virtualaddress, 0, 8); | 501 | memset(virtualaddress, 0, 8); |
332 | 502 | ||
333 | SET_EARLYMODE_PKTNUM(virtualaddress, ptcb_desc->empkt_num); | 503 | SET_EARLYMODE_PKTNUM(virtualaddress, ptcb_desc->empkt_num); |
@@ -335,7 +505,7 @@ static void insert_em(struct rtl_tcb_desc *ptcb_desc, u8 *virtualaddress) | |||
335 | dwtmp = ptcb_desc->empkt_len[0]; | 505 | dwtmp = ptcb_desc->empkt_len[0]; |
336 | } else { | 506 | } else { |
337 | dwtmp = ptcb_desc->empkt_len[0]; | 507 | dwtmp = ptcb_desc->empkt_len[0]; |
338 | dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; | 508 | dwtmp += ((dwtmp%4) ? (4-dwtmp%4) : 0)+4; |
339 | dwtmp += ptcb_desc->empkt_len[1]; | 509 | dwtmp += ptcb_desc->empkt_len[1]; |
340 | } | 510 | } |
341 | SET_EARLYMODE_LEN0(virtualaddress, dwtmp); | 511 | SET_EARLYMODE_LEN0(virtualaddress, dwtmp); |
@@ -344,7 +514,7 @@ static void insert_em(struct rtl_tcb_desc *ptcb_desc, u8 *virtualaddress) | |||
344 | dwtmp = ptcb_desc->empkt_len[2]; | 514 | dwtmp = ptcb_desc->empkt_len[2]; |
345 | } else { | 515 | } else { |
346 | dwtmp = ptcb_desc->empkt_len[2]; | 516 | dwtmp = ptcb_desc->empkt_len[2]; |
347 | dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; | 517 | dwtmp += ((dwtmp%4) ? (4-dwtmp%4) : 0)+4; |
348 | dwtmp += ptcb_desc->empkt_len[3]; | 518 | dwtmp += ptcb_desc->empkt_len[3]; |
349 | } | 519 | } |
350 | SET_EARLYMODE_LEN1(virtualaddress, dwtmp); | 520 | SET_EARLYMODE_LEN1(virtualaddress, dwtmp); |
@@ -352,7 +522,7 @@ static void insert_em(struct rtl_tcb_desc *ptcb_desc, u8 *virtualaddress) | |||
352 | dwtmp = ptcb_desc->empkt_len[4]; | 522 | dwtmp = ptcb_desc->empkt_len[4]; |
353 | } else { | 523 | } else { |
354 | dwtmp = ptcb_desc->empkt_len[4]; | 524 | dwtmp = ptcb_desc->empkt_len[4]; |
355 | dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; | 525 | dwtmp += ((dwtmp%4) ? (4-dwtmp%4) : 0)+4; |
356 | dwtmp += ptcb_desc->empkt_len[5]; | 526 | dwtmp += ptcb_desc->empkt_len[5]; |
357 | } | 527 | } |
358 | SET_EARLYMODE_LEN2_1(virtualaddress, dwtmp & 0xF); | 528 | SET_EARLYMODE_LEN2_1(virtualaddress, dwtmp & 0xF); |
@@ -361,7 +531,7 @@ static void insert_em(struct rtl_tcb_desc *ptcb_desc, u8 *virtualaddress) | |||
361 | dwtmp = ptcb_desc->empkt_len[6]; | 531 | dwtmp = ptcb_desc->empkt_len[6]; |
362 | } else { | 532 | } else { |
363 | dwtmp = ptcb_desc->empkt_len[6]; | 533 | dwtmp = ptcb_desc->empkt_len[6]; |
364 | dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; | 534 | dwtmp += ((dwtmp%4) ? (4-dwtmp%4) : 0)+4; |
365 | dwtmp += ptcb_desc->empkt_len[7]; | 535 | dwtmp += ptcb_desc->empkt_len[7]; |
366 | } | 536 | } |
367 | SET_EARLYMODE_LEN3(virtualaddress, dwtmp); | 537 | SET_EARLYMODE_LEN3(virtualaddress, dwtmp); |
@@ -369,7 +539,7 @@ static void insert_em(struct rtl_tcb_desc *ptcb_desc, u8 *virtualaddress) | |||
369 | dwtmp = ptcb_desc->empkt_len[8]; | 539 | dwtmp = ptcb_desc->empkt_len[8]; |
370 | } else { | 540 | } else { |
371 | dwtmp = ptcb_desc->empkt_len[8]; | 541 | dwtmp = ptcb_desc->empkt_len[8]; |
372 | dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; | 542 | dwtmp += ((dwtmp%4) ? (4-dwtmp%4) : 0)+4; |
373 | dwtmp += ptcb_desc->empkt_len[9]; | 543 | dwtmp += ptcb_desc->empkt_len[9]; |
374 | } | 544 | } |
375 | SET_EARLYMODE_LEN4(virtualaddress, dwtmp); | 545 | SET_EARLYMODE_LEN4(virtualaddress, dwtmp); |
@@ -387,21 +557,21 @@ bool rtl88ee_rx_query_desc(struct ieee80211_hw *hw, | |||
387 | u32 phystatus = GET_RX_DESC_PHYST(pdesc); | 557 | u32 phystatus = GET_RX_DESC_PHYST(pdesc); |
388 | status->packet_report_type = (u8)GET_RX_STATUS_DESC_RPT_SEL(pdesc); | 558 | status->packet_report_type = (u8)GET_RX_STATUS_DESC_RPT_SEL(pdesc); |
389 | if (status->packet_report_type == TX_REPORT2) | 559 | if (status->packet_report_type == TX_REPORT2) |
390 | status->length = (u16) GET_RX_RPT2_DESC_PKT_LEN(pdesc); | 560 | status->length = (u16)GET_RX_RPT2_DESC_PKT_LEN(pdesc); |
391 | else | 561 | else |
392 | status->length = (u16) GET_RX_DESC_PKT_LEN(pdesc); | 562 | status->length = (u16)GET_RX_DESC_PKT_LEN(pdesc); |
393 | status->rx_drvinfo_size = (u8) GET_RX_DESC_DRV_INFO_SIZE(pdesc) * | 563 | status->rx_drvinfo_size = (u8)GET_RX_DESC_DRV_INFO_SIZE(pdesc) * |
394 | RX_DRV_INFO_SIZE_UNIT; | 564 | RX_DRV_INFO_SIZE_UNIT; |
395 | status->rx_bufshift = (u8) (GET_RX_DESC_SHIFT(pdesc) & 0x03); | 565 | status->rx_bufshift = (u8)(GET_RX_DESC_SHIFT(pdesc) & 0x03); |
396 | status->icv = (u16) GET_RX_DESC_ICV(pdesc); | 566 | status->icv = (u16)GET_RX_DESC_ICV(pdesc); |
397 | status->crc = (u16) GET_RX_DESC_CRC32(pdesc); | 567 | status->crc = (u16)GET_RX_DESC_CRC32(pdesc); |
398 | status->hwerror = (status->crc | status->icv); | 568 | status->hwerror = (status->crc | status->icv); |
399 | status->decrypted = !GET_RX_DESC_SWDEC(pdesc); | 569 | status->decrypted = !GET_RX_DESC_SWDEC(pdesc); |
400 | status->rate = (u8) GET_RX_DESC_RXMCS(pdesc); | 570 | status->rate = (u8)GET_RX_DESC_RXMCS(pdesc); |
401 | status->shortpreamble = (u16) GET_RX_DESC_SPLCP(pdesc); | 571 | status->shortpreamble = (u16)GET_RX_DESC_SPLCP(pdesc); |
402 | status->isampdu = (bool) (GET_RX_DESC_PAGGR(pdesc) == 1); | 572 | status->isampdu = (bool) (GET_RX_DESC_PAGGR(pdesc) == 1); |
403 | status->isfirst_ampdu = (bool) ((GET_RX_DESC_PAGGR(pdesc) == 1) && | 573 | status->isfirst_ampdu = (bool)((GET_RX_DESC_PAGGR(pdesc) == 1) && |
404 | (GET_RX_DESC_FAGGR(pdesc) == 1)); | 574 | (GET_RX_DESC_FAGGR(pdesc) == 1)); |
405 | if (status->packet_report_type == NORMAL_RX) | 575 | if (status->packet_report_type == NORMAL_RX) |
406 | status->timestamp_low = GET_RX_DESC_TSFL(pdesc); | 576 | status->timestamp_low = GET_RX_DESC_TSFL(pdesc); |
407 | status->rx_is40Mhzpacket = (bool) GET_RX_DESC_BW(pdesc); | 577 | status->rx_is40Mhzpacket = (bool) GET_RX_DESC_BW(pdesc); |
@@ -420,11 +590,14 @@ bool rtl88ee_rx_query_desc(struct ieee80211_hw *hw, | |||
420 | status->wake_match = 0; | 590 | status->wake_match = 0; |
421 | if (status->wake_match) | 591 | if (status->wake_match) |
422 | RT_TRACE(rtlpriv, COMP_RXDESC, DBG_LOUD, | 592 | RT_TRACE(rtlpriv, COMP_RXDESC, DBG_LOUD, |
423 | "Get Wakeup Packet!! WakeMatch =%d\n", | 593 | "GGGGGGGGGGGGGet Wakeup Packet!! WakeMatch=%d\n", |
424 | status->wake_match); | 594 | status->wake_match); |
425 | rx_status->freq = hw->conf.chandef.chan->center_freq; | 595 | rx_status->freq = hw->conf.chandef.chan->center_freq; |
426 | rx_status->band = hw->conf.chandef.chan->band; | 596 | rx_status->band = hw->conf.chandef.chan->band; |
427 | 597 | ||
598 | hdr = (struct ieee80211_hdr *)(skb->data + status->rx_drvinfo_size | ||
599 | + status->rx_bufshift); | ||
600 | |||
428 | if (status->crc) | 601 | if (status->crc) |
429 | rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; | 602 | rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; |
430 | 603 | ||
@@ -445,18 +618,11 @@ bool rtl88ee_rx_query_desc(struct ieee80211_hw *hw, | |||
445 | * to decrypt it | 618 | * to decrypt it |
446 | */ | 619 | */ |
447 | if (status->decrypted) { | 620 | if (status->decrypted) { |
448 | hdr = (struct ieee80211_hdr *)(skb->data + | 621 | if ((!_ieee80211_is_robust_mgmt_frame(hdr)) && |
449 | status->rx_drvinfo_size + status->rx_bufshift); | ||
450 | |||
451 | if (!hdr) { | ||
452 | /* During testing, hdr was NULL */ | ||
453 | return false; | ||
454 | } | ||
455 | if ((_ieee80211_is_robust_mgmt_frame(hdr)) && | ||
456 | (ieee80211_has_protected(hdr->frame_control))) | 622 | (ieee80211_has_protected(hdr->frame_control))) |
457 | rx_status->flag &= ~RX_FLAG_DECRYPTED; | ||
458 | else | ||
459 | rx_status->flag |= RX_FLAG_DECRYPTED; | 623 | rx_status->flag |= RX_FLAG_DECRYPTED; |
624 | else | ||
625 | rx_status->flag &= ~RX_FLAG_DECRYPTED; | ||
460 | } | 626 | } |
461 | 627 | ||
462 | /* rate_idx: index of data rate into band's | 628 | /* rate_idx: index of data rate into band's |
@@ -464,19 +630,18 @@ bool rtl88ee_rx_query_desc(struct ieee80211_hw *hw, | |||
464 | * are use (RX_FLAG_HT) | 630 | * are use (RX_FLAG_HT) |
465 | * Notice: this is diff with windows define | 631 | * Notice: this is diff with windows define |
466 | */ | 632 | */ |
467 | rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht, | 633 | rx_status->rate_idx = _rtl88ee_rate_mapping(hw, |
468 | status->rate, false); | 634 | status->is_ht, status->rate); |
469 | 635 | ||
470 | rx_status->mactime = status->timestamp_low; | 636 | rx_status->mactime = status->timestamp_low; |
471 | if (phystatus == true) { | 637 | if (phystatus == true) { |
472 | p_drvinfo = (struct rx_fwinfo_88e *)(skb->data + | 638 | p_drvinfo = (struct rx_fwinfo_88e *)(skb->data + |
473 | status->rx_bufshift); | 639 | status->rx_bufshift); |
474 | 640 | ||
475 | _rtl88ee_translate_rx_signal_stuff(hw, skb, status, pdesc, | 641 | _rtl88ee_translate_rx_signal_stuff(hw, |
642 | skb, status, pdesc, | ||
476 | p_drvinfo); | 643 | p_drvinfo); |
477 | } | 644 | } |
478 | |||
479 | /*rx_status->qual = status->signal; */ | ||
480 | rx_status->signal = status->recvsignalpower + 10; | 645 | rx_status->signal = status->recvsignalpower + 10; |
481 | if (status->packet_report_type == TX_REPORT2) { | 646 | if (status->packet_report_type == TX_REPORT2) { |
482 | status->macid_valid_entry[0] = | 647 | status->macid_valid_entry[0] = |
@@ -489,15 +654,17 @@ bool rtl88ee_rx_query_desc(struct ieee80211_hw *hw, | |||
489 | 654 | ||
490 | void rtl88ee_tx_fill_desc(struct ieee80211_hw *hw, | 655 | void rtl88ee_tx_fill_desc(struct ieee80211_hw *hw, |
491 | struct ieee80211_hdr *hdr, u8 *pdesc_tx, | 656 | struct ieee80211_hdr *hdr, u8 *pdesc_tx, |
492 | u8 *pbd_desc_tx, struct ieee80211_tx_info *info, | 657 | u8 *txbd, struct ieee80211_tx_info *info, |
493 | struct ieee80211_sta *sta, struct sk_buff *skb, | 658 | struct ieee80211_sta *sta, |
659 | struct sk_buff *skb, | ||
494 | u8 hw_queue, struct rtl_tcb_desc *ptcb_desc) | 660 | u8 hw_queue, struct rtl_tcb_desc *ptcb_desc) |
661 | |||
495 | { | 662 | { |
496 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 663 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
497 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | 664 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
498 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | 665 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); |
499 | struct rtl_hal *rtlhal = rtl_hal(rtlpriv); | 666 | struct rtl_hal *rtlhal = rtl_hal(rtlpriv); |
500 | u8 *pdesc = pdesc_tx; | 667 | u8 *pdesc = (u8 *)pdesc_tx; |
501 | u16 seq_number; | 668 | u16 seq_number; |
502 | __le16 fc = hdr->frame_control; | 669 | __le16 fc = hdr->frame_control; |
503 | unsigned int buf_len = 0; | 670 | unsigned int buf_len = 0; |
@@ -547,8 +714,9 @@ void rtl88ee_tx_fill_desc(struct ieee80211_hw *hw, | |||
547 | if (ptcb_desc->empkt_num) { | 714 | if (ptcb_desc->empkt_num) { |
548 | RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, | 715 | RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, |
549 | "Insert 8 byte.pTcb->EMPktNum:%d\n", | 716 | "Insert 8 byte.pTcb->EMPktNum:%d\n", |
550 | ptcb_desc->empkt_num); | 717 | ptcb_desc->empkt_num); |
551 | insert_em(ptcb_desc, (u8 *)(skb->data)); | 718 | _rtl88ee_insert_emcontent(ptcb_desc, |
719 | (u8 *)(skb->data)); | ||
552 | } | 720 | } |
553 | } else { | 721 | } else { |
554 | SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN); | 722 | SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN); |
@@ -560,6 +728,7 @@ void rtl88ee_tx_fill_desc(struct ieee80211_hw *hw, | |||
560 | short_gi = (ptcb_desc->use_shortgi) ? 1 : 0; | 728 | short_gi = (ptcb_desc->use_shortgi) ? 1 : 0; |
561 | else | 729 | else |
562 | short_gi = (ptcb_desc->use_shortpreamble) ? 1 : 0; | 730 | short_gi = (ptcb_desc->use_shortpreamble) ? 1 : 0; |
731 | |||
563 | SET_TX_DESC_DATA_SHORTGI(pdesc, short_gi); | 732 | SET_TX_DESC_DATA_SHORTGI(pdesc, short_gi); |
564 | 733 | ||
565 | if (info->flags & IEEE80211_TX_CTL_AMPDU) { | 734 | if (info->flags & IEEE80211_TX_CTL_AMPDU) { |
@@ -568,7 +737,7 @@ void rtl88ee_tx_fill_desc(struct ieee80211_hw *hw, | |||
568 | } | 737 | } |
569 | SET_TX_DESC_SEQ(pdesc, seq_number); | 738 | SET_TX_DESC_SEQ(pdesc, seq_number); |
570 | SET_TX_DESC_RTS_ENABLE(pdesc, ((ptcb_desc->rts_enable && | 739 | SET_TX_DESC_RTS_ENABLE(pdesc, ((ptcb_desc->rts_enable && |
571 | !ptcb_desc->cts_enable) ? 1 : 0)); | 740 | !ptcb_desc->cts_enable) ? 1 : 0)); |
572 | SET_TX_DESC_HW_RTS_ENABLE(pdesc, 0); | 741 | SET_TX_DESC_HW_RTS_ENABLE(pdesc, 0); |
573 | SET_TX_DESC_CTS2SELF(pdesc, ((ptcb_desc->cts_enable) ? 1 : 0)); | 742 | SET_TX_DESC_CTS2SELF(pdesc, ((ptcb_desc->cts_enable) ? 1 : 0)); |
574 | SET_TX_DESC_RTS_STBC(pdesc, ((ptcb_desc->rts_stbc) ? 1 : 0)); | 743 | SET_TX_DESC_RTS_STBC(pdesc, ((ptcb_desc->rts_stbc) ? 1 : 0)); |
@@ -581,17 +750,17 @@ void rtl88ee_tx_fill_desc(struct ieee80211_hw *hw, | |||
581 | (ptcb_desc->rts_use_shortpreamble ? 1 : 0) : | 750 | (ptcb_desc->rts_use_shortpreamble ? 1 : 0) : |
582 | (ptcb_desc->rts_use_shortgi ? 1 : 0))); | 751 | (ptcb_desc->rts_use_shortgi ? 1 : 0))); |
583 | 752 | ||
584 | if (ptcb_desc->btx_enable_sw_calc_duration) | 753 | if (ptcb_desc->tx_enable_sw_calc_duration) |
585 | SET_TX_DESC_NAV_USE_HDR(pdesc, 1); | 754 | SET_TX_DESC_NAV_USE_HDR(pdesc, 1); |
586 | 755 | ||
587 | if (bw_40) { | 756 | if (bw_40) { |
588 | if (ptcb_desc->packet_bw) { | 757 | if (ptcb_desc->packet_bw == HT_CHANNEL_WIDTH_20_40) { |
589 | SET_TX_DESC_DATA_BW(pdesc, 1); | 758 | SET_TX_DESC_DATA_BW(pdesc, 1); |
590 | SET_TX_DESC_TX_SUB_CARRIER(pdesc, 3); | 759 | SET_TX_DESC_TX_SUB_CARRIER(pdesc, 3); |
591 | } else { | 760 | } else { |
592 | SET_TX_DESC_DATA_BW(pdesc, 0); | 761 | SET_TX_DESC_DATA_BW(pdesc, 0); |
593 | SET_TX_DESC_TX_SUB_CARRIER(pdesc, | 762 | SET_TX_DESC_TX_SUB_CARRIER(pdesc, |
594 | mac->cur_40_prime_sc); | 763 | mac->cur_40_prime_sc); |
595 | } | 764 | } |
596 | } else { | 765 | } else { |
597 | SET_TX_DESC_DATA_BW(pdesc, 0); | 766 | SET_TX_DESC_DATA_BW(pdesc, 0); |
@@ -599,13 +768,14 @@ void rtl88ee_tx_fill_desc(struct ieee80211_hw *hw, | |||
599 | } | 768 | } |
600 | 769 | ||
601 | SET_TX_DESC_LINIP(pdesc, 0); | 770 | SET_TX_DESC_LINIP(pdesc, 0); |
602 | SET_TX_DESC_PKT_SIZE(pdesc, (u16) skb_len); | 771 | SET_TX_DESC_PKT_SIZE(pdesc, (u16)skb_len); |
603 | if (sta) { | 772 | if (sta) { |
604 | u8 ampdu_density = sta->ht_cap.ampdu_density; | 773 | u8 ampdu_density = sta->ht_cap.ampdu_density; |
605 | SET_TX_DESC_AMPDU_DENSITY(pdesc, ampdu_density); | 774 | SET_TX_DESC_AMPDU_DENSITY(pdesc, ampdu_density); |
606 | } | 775 | } |
607 | if (info->control.hw_key) { | 776 | if (info->control.hw_key) { |
608 | struct ieee80211_key_conf *keyconf; | 777 | struct ieee80211_key_conf *keyconf; |
778 | |||
609 | keyconf = info->control.hw_key; | 779 | keyconf = info->control.hw_key; |
610 | switch (keyconf->cipher) { | 780 | switch (keyconf->cipher) { |
611 | case WLAN_CIPHER_SUITE_WEP40: | 781 | case WLAN_CIPHER_SUITE_WEP40: |
@@ -619,6 +789,7 @@ void rtl88ee_tx_fill_desc(struct ieee80211_hw *hw, | |||
619 | default: | 789 | default: |
620 | SET_TX_DESC_SEC_TYPE(pdesc, 0x0); | 790 | SET_TX_DESC_SEC_TYPE(pdesc, 0x0); |
621 | break; | 791 | break; |
792 | |||
622 | } | 793 | } |
623 | } | 794 | } |
624 | 795 | ||
@@ -629,6 +800,7 @@ void rtl88ee_tx_fill_desc(struct ieee80211_hw *hw, | |||
629 | 1 : 0); | 800 | 1 : 0); |
630 | SET_TX_DESC_USE_RATE(pdesc, ptcb_desc->use_driver_rate ? 1 : 0); | 801 | SET_TX_DESC_USE_RATE(pdesc, ptcb_desc->use_driver_rate ? 1 : 0); |
631 | 802 | ||
803 | /*SET_TX_DESC_PWR_STATUS(pdesc, pwr_status);*/ | ||
632 | /* Set TxRate and RTSRate in TxDesc */ | 804 | /* Set TxRate and RTSRate in TxDesc */ |
633 | /* This prevent Tx initial rate of new-coming packets */ | 805 | /* This prevent Tx initial rate of new-coming packets */ |
634 | /* from being overwritten by retried packet rate.*/ | 806 | /* from being overwritten by retried packet rate.*/ |
@@ -639,7 +811,7 @@ void rtl88ee_tx_fill_desc(struct ieee80211_hw *hw, | |||
639 | if (ieee80211_is_data_qos(fc)) { | 811 | if (ieee80211_is_data_qos(fc)) { |
640 | if (mac->rdg_en) { | 812 | if (mac->rdg_en) { |
641 | RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, | 813 | RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, |
642 | "Enable RDG function.\n"); | 814 | "Enable RDG function.\n"); |
643 | SET_TX_DESC_RDG_ENABLE(pdesc, 1); | 815 | SET_TX_DESC_RDG_ENABLE(pdesc, 1); |
644 | SET_TX_DESC_HTC(pdesc, 1); | 816 | SET_TX_DESC_HTC(pdesc, 1); |
645 | } | 817 | } |
@@ -648,7 +820,7 @@ void rtl88ee_tx_fill_desc(struct ieee80211_hw *hw, | |||
648 | 820 | ||
649 | SET_TX_DESC_FIRST_SEG(pdesc, (firstseg ? 1 : 0)); | 821 | SET_TX_DESC_FIRST_SEG(pdesc, (firstseg ? 1 : 0)); |
650 | SET_TX_DESC_LAST_SEG(pdesc, (lastseg ? 1 : 0)); | 822 | SET_TX_DESC_LAST_SEG(pdesc, (lastseg ? 1 : 0)); |
651 | SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16) buf_len); | 823 | SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16)buf_len); |
652 | SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping); | 824 | SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping); |
653 | if (rtlpriv->dm.useramask) { | 825 | if (rtlpriv->dm.useramask) { |
654 | SET_TX_DESC_RATE_ID(pdesc, ptcb_desc->ratr_index); | 826 | SET_TX_DESC_RATE_ID(pdesc, ptcb_desc->ratr_index); |
@@ -664,8 +836,9 @@ void rtl88ee_tx_fill_desc(struct ieee80211_hw *hw, | |||
664 | SET_TX_DESC_HWSEQ_EN(pdesc, 1); | 836 | SET_TX_DESC_HWSEQ_EN(pdesc, 1); |
665 | SET_TX_DESC_MORE_FRAG(pdesc, (lastseg ? 0 : 1)); | 837 | SET_TX_DESC_MORE_FRAG(pdesc, (lastseg ? 0 : 1)); |
666 | if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) || | 838 | if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) || |
667 | is_broadcast_ether_addr(ieee80211_get_DA(hdr))) | 839 | is_broadcast_ether_addr(ieee80211_get_DA(hdr))) { |
668 | SET_TX_DESC_BMC(pdesc, 1); | 840 | SET_TX_DESC_BMC(pdesc, 1); |
841 | } | ||
669 | 842 | ||
670 | rtl88e_dm_set_tx_ant_by_tx_info(hw, pdesc, ptcb_desc->mac_id); | 843 | rtl88e_dm_set_tx_ant_by_tx_info(hw, pdesc, ptcb_desc->mac_id); |
671 | RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "\n"); | 844 | RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "\n"); |
@@ -733,8 +906,8 @@ void rtl88ee_tx_fill_cmddesc(struct ieee80211_hw *hw, | |||
733 | pdesc, TX_DESC_SIZE); | 906 | pdesc, TX_DESC_SIZE); |
734 | } | 907 | } |
735 | 908 | ||
736 | void rtl88ee_set_desc(struct ieee80211_hw *hw, u8 *pdesc, bool istx, | 909 | void rtl88ee_set_desc(struct ieee80211_hw *hw, u8 *pdesc, |
737 | u8 desc_name, u8 *val) | 910 | bool istx, u8 desc_name, u8 *val) |
738 | { | 911 | { |
739 | if (istx == true) { | 912 | if (istx == true) { |
740 | switch (desc_name) { | 913 | switch (desc_name) { |
@@ -745,7 +918,7 @@ void rtl88ee_set_desc(struct ieee80211_hw *hw, u8 *pdesc, bool istx, | |||
745 | SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *)val); | 918 | SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *)val); |
746 | break; | 919 | break; |
747 | default: | 920 | default: |
748 | RT_ASSERT(false, "ERR txdesc :%d not processed\n", | 921 | RT_ASSERT(false, "ERR txdesc :%d not process\n", |
749 | desc_name); | 922 | desc_name); |
750 | break; | 923 | break; |
751 | } | 924 | } |
@@ -764,7 +937,7 @@ void rtl88ee_set_desc(struct ieee80211_hw *hw, u8 *pdesc, bool istx, | |||
764 | SET_RX_DESC_EOR(pdesc, 1); | 937 | SET_RX_DESC_EOR(pdesc, 1); |
765 | break; | 938 | break; |
766 | default: | 939 | default: |
767 | RT_ASSERT(false, "ERR rxdesc :%d not processed\n", | 940 | RT_ASSERT(false, "ERR rxdesc :%d not process\n", |
768 | desc_name); | 941 | desc_name); |
769 | break; | 942 | break; |
770 | } | 943 | } |
@@ -784,7 +957,7 @@ u32 rtl88ee_get_desc(u8 *pdesc, bool istx, u8 desc_name) | |||
784 | ret = GET_TX_DESC_TX_BUFFER_ADDRESS(pdesc); | 957 | ret = GET_TX_DESC_TX_BUFFER_ADDRESS(pdesc); |
785 | break; | 958 | break; |
786 | default: | 959 | default: |
787 | RT_ASSERT(false, "ERR txdesc :%d not processed\n", | 960 | RT_ASSERT(false, "ERR txdesc :%d not process\n", |
788 | desc_name); | 961 | desc_name); |
789 | break; | 962 | break; |
790 | } | 963 | } |
@@ -796,8 +969,11 @@ u32 rtl88ee_get_desc(u8 *pdesc, bool istx, u8 desc_name) | |||
796 | case HW_DESC_RXPKT_LEN: | 969 | case HW_DESC_RXPKT_LEN: |
797 | ret = GET_RX_DESC_PKT_LEN(pdesc); | 970 | ret = GET_RX_DESC_PKT_LEN(pdesc); |
798 | break; | 971 | break; |
972 | case HW_DESC_RXBUFF_ADDR: | ||
973 | ret = GET_RX_DESC_BUFF_ADDR(pdesc); | ||
974 | break; | ||
799 | default: | 975 | default: |
800 | RT_ASSERT(false, "ERR rxdesc :%d not processed\n", | 976 | RT_ASSERT(false, "ERR rxdesc :%d not process\n", |
801 | desc_name); | 977 | desc_name); |
802 | break; | 978 | break; |
803 | } | 979 | } |
@@ -805,6 +981,22 @@ u32 rtl88ee_get_desc(u8 *pdesc, bool istx, u8 desc_name) | |||
805 | return ret; | 981 | return ret; |
806 | } | 982 | } |
807 | 983 | ||
984 | bool rtl88ee_is_tx_desc_closed(struct ieee80211_hw *hw, u8 hw_queue, u16 index) | ||
985 | { | ||
986 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | ||
987 | struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue]; | ||
988 | u8 *entry = (u8 *)(&ring->desc[ring->idx]); | ||
989 | u8 own = (u8)rtl88ee_get_desc(entry, true, HW_DESC_OWN); | ||
990 | |||
991 | /*beacon packet will only use the first | ||
992 | *descriptor defautly,and the own may not | ||
993 | *be cleared by the hardware | ||
994 | */ | ||
995 | if (own) | ||
996 | return false; | ||
997 | return true; | ||
998 | } | ||
999 | |||
808 | void rtl88ee_tx_polling(struct ieee80211_hw *hw, u8 hw_queue) | 1000 | void rtl88ee_tx_polling(struct ieee80211_hw *hw, u8 hw_queue) |
809 | { | 1001 | { |
810 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 1002 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
@@ -815,3 +1007,10 @@ void rtl88ee_tx_polling(struct ieee80211_hw *hw, u8 hw_queue) | |||
815 | BIT(0) << (hw_queue)); | 1007 | BIT(0) << (hw_queue)); |
816 | } | 1008 | } |
817 | } | 1009 | } |
1010 | |||
1011 | u32 rtl88ee_rx_command_packet(struct ieee80211_hw *hw, | ||
1012 | struct rtl_stats status, | ||
1013 | struct sk_buff *skb) | ||
1014 | { | ||
1015 | return 0; | ||
1016 | } | ||