aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rtlwifi/core.c
diff options
context:
space:
mode:
authorLarry Finger <Larry.Finger@lwfinger.net>2014-09-22 10:39:20 -0400
committerJohn W. Linville <linville@tuxdriver.com>2014-09-26 17:22:27 -0400
commitf7953b2ad66cc5fc66e13d5c0a40e61b45cdfca8 (patch)
tree42ed50f3a91fd5844c57762113212e1fccb2b720 /drivers/net/wireless/rtlwifi/core.c
parent38506ecefab911785d5e1aa5889f6eeb462e0954 (diff)
rtlwifi: Modify core.c for new drivers
Each of the routines in the rtlwifi common driver needs to be modified for the coming changes. This patch prepares core.c, but also touches other files. Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rtlwifi/core.c')
-rw-r--r--drivers/net/wireless/rtlwifi/core.c744
1 files changed, 518 insertions, 226 deletions
diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
index 98e564d61a0e..dea754aecdaf 100644
--- a/drivers/net/wireless/rtlwifi/core.c
+++ b/drivers/net/wireless/rtlwifi/core.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 *
@@ -31,10 +27,12 @@
31#include "core.h" 27#include "core.h"
32#include "cam.h" 28#include "cam.h"
33#include "base.h" 29#include "base.h"
34#include "pci.h"
35#include "ps.h" 30#include "ps.h"
36 31
32#include "btcoexist/rtl_btc.h"
33#include <linux/firmware.h>
37#include <linux/export.h> 34#include <linux/export.h>
35#include <net/cfg80211.h>
38 36
39void rtl_addr_delay(u32 addr) 37void rtl_addr_delay(u32 addr)
40{ 38{
@@ -103,7 +101,7 @@ void rtl_fw_cb(const struct firmware *firmware, void *context)
103 int err; 101 int err;
104 102
105 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 103 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
106 "Firmware callback routine entered!\n"); 104 "Firmware callback routine entered!\n");
107 complete(&rtlpriv->firmware_loading_complete); 105 complete(&rtlpriv->firmware_loading_complete);
108 if (!firmware) { 106 if (!firmware) {
109 if (rtlpriv->cfg->alt_fw_name) { 107 if (rtlpriv->cfg->alt_fw_name) {
@@ -135,7 +133,7 @@ EXPORT_SYMBOL(rtl_fw_cb);
135/*mutex for start & stop is must here. */ 133/*mutex for start & stop is must here. */
136static int rtl_op_start(struct ieee80211_hw *hw) 134static int rtl_op_start(struct ieee80211_hw *hw)
137{ 135{
138 int err; 136 int err = 0;
139 struct rtl_priv *rtlpriv = rtl_priv(hw); 137 struct rtl_priv *rtlpriv = rtl_priv(hw);
140 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 138 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
141 139
@@ -157,28 +155,33 @@ static void rtl_op_stop(struct ieee80211_hw *hw)
157 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 155 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
158 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 156 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
159 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 157 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
158 bool support_remote_wakeup = false;
160 159
161 if (is_hal_stop(rtlhal)) 160 if (is_hal_stop(rtlhal))
162 return; 161 return;
163 162
163 rtlpriv->cfg->ops->get_hw_reg(hw, HAL_DEF_WOWLAN,
164 (u8 *)(&support_remote_wakeup));
164 /* here is must, because adhoc do stop and start, 165 /* here is must, because adhoc do stop and start,
165 * but stop with RFOFF may cause something wrong, 166 * but stop with RFOFF may cause something wrong,
166 * like adhoc TP 167 * like adhoc TP
167 */ 168 */
168 if (unlikely(ppsc->rfpwr_state == ERFOFF)) { 169 if (unlikely(ppsc->rfpwr_state == ERFOFF))
169 rtl_ips_nic_on(hw); 170 rtl_ips_nic_on(hw);
170 }
171 171
172 mutex_lock(&rtlpriv->locks.conf_mutex); 172 mutex_lock(&rtlpriv->locks.conf_mutex);
173 /* if wowlan supported, DON'T clear connected info */
174 if (!(support_remote_wakeup &&
175 rtlhal->enter_pnp_sleep)) {
176 mac->link_state = MAC80211_NOLINK;
177 memset(mac->bssid, 0, 6);
178 mac->vendor = PEER_UNKNOWN;
173 179
174 mac->link_state = MAC80211_NOLINK; 180 /* reset sec info */
175 memset(mac->bssid, 0, ETH_ALEN); 181 rtl_cam_reset_sec_info(hw);
176 mac->vendor = PEER_UNKNOWN;
177
178 /*reset sec info */
179 rtl_cam_reset_sec_info(hw);
180 182
181 rtl_deinit_deferred_work(hw); 183 rtl_deinit_deferred_work(hw);
184 }
182 rtlpriv->intf_ops->adapter_stop(hw); 185 rtlpriv->intf_ops->adapter_stop(hw);
183 186
184 mutex_unlock(&rtlpriv->locks.conf_mutex); 187 mutex_unlock(&rtlpriv->locks.conf_mutex);
@@ -202,7 +205,6 @@ static void rtl_op_tx(struct ieee80211_hw *hw,
202 205
203 if (!rtlpriv->intf_ops->waitq_insert(hw, control->sta, skb)) 206 if (!rtlpriv->intf_ops->waitq_insert(hw, control->sta, skb))
204 rtlpriv->intf_ops->adapter_tx(hw, control->sta, skb, &tcb_desc); 207 rtlpriv->intf_ops->adapter_tx(hw, control->sta, skb, &tcb_desc);
205
206 return; 208 return;
207 209
208err_free: 210err_free:
@@ -216,18 +218,17 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
216 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 218 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
217 int err = 0; 219 int err = 0;
218 220
219 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
220
221 if (mac->vif) { 221 if (mac->vif) {
222 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 222 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
223 "vif has been set!! mac->vif = 0x%p\n", mac->vif); 223 "vif has been set!! mac->vif = 0x%p\n", mac->vif);
224 return -EOPNOTSUPP; 224 return -EOPNOTSUPP;
225 } 225 }
226 226
227 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
228
227 rtl_ips_nic_on(hw); 229 rtl_ips_nic_on(hw);
228 230
229 mutex_lock(&rtlpriv->locks.conf_mutex); 231 mutex_lock(&rtlpriv->locks.conf_mutex);
230
231 switch (ieee80211_vif_type_p2p(vif)) { 232 switch (ieee80211_vif_type_p2p(vif)) {
232 case NL80211_IFTYPE_P2P_CLIENT: 233 case NL80211_IFTYPE_P2P_CLIENT:
233 mac->p2p = P2P_ROLE_CLIENT; 234 mac->p2p = P2P_ROLE_CLIENT;
@@ -238,10 +239,8 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
238 "NL80211_IFTYPE_STATION\n"); 239 "NL80211_IFTYPE_STATION\n");
239 mac->beacon_enabled = 0; 240 mac->beacon_enabled = 0;
240 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0, 241 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
241 rtlpriv->cfg->maps 242 rtlpriv->cfg->maps[RTL_IBSS_INT_MASKS]);
242 [RTL_IBSS_INT_MASKS]);
243 } 243 }
244 mac->link_state = MAC80211_LINKED;
245 break; 244 break;
246 case NL80211_IFTYPE_ADHOC: 245 case NL80211_IFTYPE_ADHOC:
247 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 246 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
@@ -254,7 +253,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
254 else 253 else
255 mac->basic_rates = 0xff0; 254 mac->basic_rates = 0xff0;
256 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE, 255 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
257 (u8 *) (&mac->basic_rates)); 256 (u8 *)(&mac->basic_rates));
258 257
259 break; 258 break;
260 case NL80211_IFTYPE_P2P_GO: 259 case NL80211_IFTYPE_P2P_GO:
@@ -271,7 +270,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
271 else 270 else
272 mac->basic_rates = 0xff0; 271 mac->basic_rates = 0xff0;
273 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE, 272 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
274 (u8 *) (&mac->basic_rates)); 273 (u8 *)(&mac->basic_rates));
275 break; 274 break;
276 case NL80211_IFTYPE_MESH_POINT: 275 case NL80211_IFTYPE_MESH_POINT:
277 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 276 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
@@ -288,7 +287,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
288 break; 287 break;
289 default: 288 default:
290 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 289 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
291 "operation mode %d is not supported!\n", vif->type); 290 "operation mode %d is not support!\n", vif->type);
292 err = -EOPNOTSUPP; 291 err = -EOPNOTSUPP;
293 goto out; 292 goto out;
294 } 293 }
@@ -326,8 +325,7 @@ static void rtl_op_remove_interface(struct ieee80211_hw *hw,
326 if (mac->beacon_enabled == 1) { 325 if (mac->beacon_enabled == 1) {
327 mac->beacon_enabled = 0; 326 mac->beacon_enabled = 0;
328 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0, 327 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
329 rtlpriv->cfg->maps 328 rtlpriv->cfg->maps[RTL_IBSS_INT_MASKS]);
330 [RTL_IBSS_INT_MASKS]);
331 } 329 }
332 } 330 }
333 331
@@ -342,12 +340,12 @@ static void rtl_op_remove_interface(struct ieee80211_hw *hw,
342 mac->vendor = PEER_UNKNOWN; 340 mac->vendor = PEER_UNKNOWN;
343 mac->opmode = NL80211_IFTYPE_UNSPECIFIED; 341 mac->opmode = NL80211_IFTYPE_UNSPECIFIED;
344 rtlpriv->cfg->ops->set_network_type(hw, mac->opmode); 342 rtlpriv->cfg->ops->set_network_type(hw, mac->opmode);
343
345 mutex_unlock(&rtlpriv->locks.conf_mutex); 344 mutex_unlock(&rtlpriv->locks.conf_mutex);
346} 345}
347
348static int rtl_op_change_interface(struct ieee80211_hw *hw, 346static int rtl_op_change_interface(struct ieee80211_hw *hw,
349 struct ieee80211_vif *vif, 347 struct ieee80211_vif *vif,
350 enum nl80211_iftype new_type, bool p2p) 348 enum nl80211_iftype new_type, bool p2p)
351{ 349{
352 struct rtl_priv *rtlpriv = rtl_priv(hw); 350 struct rtl_priv *rtlpriv = rtl_priv(hw);
353 int ret; 351 int ret;
@@ -357,10 +355,221 @@ static int rtl_op_change_interface(struct ieee80211_hw *hw,
357 vif->p2p = p2p; 355 vif->p2p = p2p;
358 ret = rtl_op_add_interface(hw, vif); 356 ret = rtl_op_add_interface(hw, vif);
359 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 357 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
360 "p2p %x\n", p2p); 358 "p2p %x\n", p2p);
361 return ret; 359 return ret;
362} 360}
363 361
362#ifdef CONFIG_PM
363static u16 crc16_ccitt(u8 data, u16 crc)
364{
365 u8 shift_in, data_bit, crc_bit11, crc_bit4, crc_bit15;
366 u8 i;
367 u16 result;
368
369 for (i = 0; i < 8; i++) {
370 crc_bit15 = ((crc & BIT(15)) ? 1 : 0);
371 data_bit = (data & (BIT(0) << i) ? 1 : 0);
372 shift_in = crc_bit15 ^ data_bit;
373
374 result = crc << 1;
375 if (shift_in == 0)
376 result &= (~BIT(0));
377 else
378 result |= BIT(0);
379
380 crc_bit11 = ((crc & BIT(11)) ? 1 : 0) ^ shift_in;
381 if (crc_bit11 == 0)
382 result &= (~BIT(12));
383 else
384 result |= BIT(12);
385
386 crc_bit4 = ((crc & BIT(4)) ? 1 : 0) ^ shift_in;
387 if (crc_bit4 == 0)
388 result &= (~BIT(5));
389 else
390 result |= BIT(5);
391
392 crc = result;
393 }
394
395 return crc;
396}
397
398static u16 _calculate_wol_pattern_crc(u8 *pattern, u16 len)
399{
400 u16 crc = 0xffff;
401 u32 i;
402
403 for (i = 0; i < len; i++)
404 crc = crc16_ccitt(pattern[i], crc);
405
406 crc = ~crc;
407
408 return crc;
409}
410
411static void _rtl_add_wowlan_patterns(struct ieee80211_hw *hw,
412 struct cfg80211_wowlan *wow)
413{
414 struct rtl_priv *rtlpriv = rtl_priv(hw);
415 struct rtl_mac *mac = &rtlpriv->mac80211;
416 struct cfg80211_pkt_pattern *patterns = wow->patterns;
417 struct rtl_wow_pattern rtl_pattern;
418 const u8 *pattern_os, *mask_os;
419 u8 mask[MAX_WOL_BIT_MASK_SIZE] = {0};
420 u8 content[MAX_WOL_PATTERN_SIZE] = {0};
421 u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
422 u8 multicast_addr1[2] = {0x33, 0x33};
423 u8 multicast_addr2[3] = {0x01, 0x00, 0x5e};
424 u8 i, mask_len;
425 u16 j, len;
426
427 for (i = 0; i < wow->n_patterns; i++) {
428 memset(&rtl_pattern, 0, sizeof(struct rtl_wow_pattern));
429 memset(mask, 0, MAX_WOL_BIT_MASK_SIZE);
430 if (patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) {
431 RT_TRACE(rtlpriv, COMP_POWER, DBG_WARNING,
432 "Pattern[%d] is too long\n", i);
433 continue;
434 }
435 pattern_os = patterns[i].pattern;
436 mask_len = DIV_ROUND_UP(patterns[i].pattern_len, 8);
437 mask_os = patterns[i].mask;
438 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
439 "pattern content\n", pattern_os,
440 patterns[i].pattern_len);
441 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
442 "mask content\n", mask_os, mask_len);
443 /* 1. unicast? multicast? or broadcast? */
444 if (memcmp(pattern_os, broadcast_addr, 6) == 0)
445 rtl_pattern.type = BROADCAST_PATTERN;
446 else if (memcmp(pattern_os, multicast_addr1, 2) == 0 ||
447 memcmp(pattern_os, multicast_addr2, 3) == 0)
448 rtl_pattern.type = MULTICAST_PATTERN;
449 else if (memcmp(pattern_os, mac->mac_addr, 6) == 0)
450 rtl_pattern.type = UNICAST_PATTERN;
451 else
452 rtl_pattern.type = UNKNOWN_TYPE;
453
454 /* 2. translate mask_from_os to mask_for_hw */
455
456/******************************************************************************
457 * pattern from OS uses 'ethenet frame', like this:
458
459 | 6 | 6 | 2 | 20 | Variable | 4 |
460 |--------+--------+------+-----------+------------+-----|
461 | 802.3 Mac Header | IP Header | TCP Packet | FCS |
462 | DA | SA | Type |
463
464 * BUT, packet catched by our HW is in '802.11 frame', begin from LLC,
465
466 | 24 or 30 | 6 | 2 | 20 | Variable | 4 |
467 |-------------------+--------+------+-----------+------------+-----|
468 | 802.11 MAC Header | LLC | IP Header | TCP Packet | FCS |
469 | Others | Tpye |
470
471 * Therefore, we need translate mask_from_OS to mask_to_hw.
472 * We should left-shift mask by 6 bits, then set the new bit[0~5] = 0,
473 * because new mask[0~5] means 'SA', but our HW packet begins from LLC,
474 * bit[0~5] corresponds to first 6 Bytes in LLC, they just don't match.
475 ******************************************************************************/
476
477 /* Shift 6 bits */
478 for (j = 0; j < mask_len - 1; j++) {
479 mask[j] = mask_os[j] >> 6;
480 mask[j] |= (mask_os[j + 1] & 0x3F) << 2;
481 }
482 mask[j] = (mask_os[j] >> 6) & 0x3F;
483 /* Set bit 0-5 to zero */
484 mask[0] &= 0xC0;
485
486 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
487 "mask to hw\n", mask, mask_len);
488 for (j = 0; j < (MAX_WOL_BIT_MASK_SIZE + 1) / 4; j++) {
489 rtl_pattern.mask[j] = mask[j * 4];
490 rtl_pattern.mask[j] |= (mask[j * 4 + 1] << 8);
491 rtl_pattern.mask[j] |= (mask[j * 4 + 2] << 16);
492 rtl_pattern.mask[j] |= (mask[j * 4 + 3] << 24);
493 }
494
495 /* To get the wake up pattern from the mask.
496 * We do not count first 12 bits which means
497 * DA[6] and SA[6] in the pattern to match HW design.
498 */
499 len = 0;
500 for (j = 12; j < patterns[i].pattern_len; j++) {
501 if ((mask_os[j / 8] >> (j % 8)) & 0x01) {
502 content[len] = pattern_os[j];
503 len++;
504 }
505 }
506
507 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
508 "pattern to hw\n", content, len);
509 /* 3. calculate crc */
510 rtl_pattern.crc = _calculate_wol_pattern_crc(content, len);
511 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE,
512 "CRC_Remainder = 0x%x", rtl_pattern.crc);
513
514 /* 4. write crc & mask_for_hw to hw */
515 rtlpriv->cfg->ops->add_wowlan_pattern(hw, &rtl_pattern, i);
516 }
517 rtl_write_byte(rtlpriv, 0x698, wow->n_patterns);
518}
519
520static int rtl_op_suspend(struct ieee80211_hw *hw,
521 struct cfg80211_wowlan *wow)
522{
523 struct rtl_priv *rtlpriv = rtl_priv(hw);
524 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
525 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
526 struct timeval ts;
527
528 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n");
529 if (WARN_ON(!wow))
530 return -EINVAL;
531
532 /* to resolve s4 can not wake up*/
533 do_gettimeofday(&ts);
534 rtlhal->last_suspend_sec = ts.tv_sec;
535
536 if ((ppsc->wo_wlan_mode & WAKE_ON_PATTERN_MATCH) && wow->n_patterns)
537 _rtl_add_wowlan_patterns(hw, wow);
538
539 rtlhal->driver_is_goingto_unload = true;
540 rtlhal->enter_pnp_sleep = true;
541
542 rtl_lps_leave(hw);
543 rtl_op_stop(hw);
544 device_set_wakeup_enable(wiphy_dev(hw->wiphy), true);
545 return 0;
546}
547
548static int rtl_op_resume(struct ieee80211_hw *hw)
549{
550 struct rtl_priv *rtlpriv = rtl_priv(hw);
551 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
552 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
553 struct timeval ts;
554
555 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n");
556 rtlhal->driver_is_goingto_unload = false;
557 rtlhal->enter_pnp_sleep = false;
558 rtlhal->wake_from_pnp_sleep = true;
559
560 /* to resovle s4 can not wake up*/
561 do_gettimeofday(&ts);
562 if (ts.tv_sec - rtlhal->last_suspend_sec < 5)
563 return -1;
564
565 rtl_op_start(hw);
566 device_set_wakeup_enable(wiphy_dev(hw->wiphy), false);
567 ieee80211_resume_disconnect(mac->vif);
568 rtlhal->wake_from_pnp_sleep = false;
569 return 0;
570}
571#endif
572
364static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) 573static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
365{ 574{
366 struct rtl_priv *rtlpriv = rtl_priv(hw); 575 struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -373,7 +582,7 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
373 return 1; 582 return 1;
374 583
375 mutex_lock(&rtlpriv->locks.conf_mutex); 584 mutex_lock(&rtlpriv->locks.conf_mutex);
376 if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { /*BIT(2)*/ 585 if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { /* BIT(2)*/
377 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 586 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
378 "IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n"); 587 "IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n");
379 } 588 }
@@ -408,8 +617,8 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
408 * is worked very well */ 617 * is worked very well */
409 if (!rtlpriv->psc.multi_buffered) 618 if (!rtlpriv->psc.multi_buffered)
410 queue_delayed_work(rtlpriv->works.rtl_wq, 619 queue_delayed_work(rtlpriv->works.rtl_wq,
411 &rtlpriv->works.ps_work, 620 &rtlpriv->works.ps_work,
412 MSECS(5)); 621 MSECS(5));
413 } else { 622 } else {
414 rtl_swlps_rf_awake(hw); 623 rtl_swlps_rf_awake(hw);
415 rtlpriv->psc.sw_ps_enabled = false; 624 rtlpriv->psc.sw_ps_enabled = false;
@@ -423,20 +632,26 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
423 mac->retry_long = hw->conf.long_frame_max_tx_count; 632 mac->retry_long = hw->conf.long_frame_max_tx_count;
424 mac->retry_short = hw->conf.long_frame_max_tx_count; 633 mac->retry_short = hw->conf.long_frame_max_tx_count;
425 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT, 634 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
426 (u8 *) (&hw->conf. 635 (u8 *)(&hw->conf.long_frame_max_tx_count));
427 long_frame_max_tx_count));
428 } 636 }
429 637
430 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { 638 if (changed & IEEE80211_CONF_CHANGE_CHANNEL &&
639 !rtlpriv->proximity.proxim_on) {
431 struct ieee80211_channel *channel = hw->conf.chandef.chan; 640 struct ieee80211_channel *channel = hw->conf.chandef.chan;
641 enum nl80211_chan_width width = hw->conf.chandef.width;
642 enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT;
432 u8 wide_chan = (u8) channel->hw_value; 643 u8 wide_chan = (u8) channel->hw_value;
433 644
645 /* channel_type is for 20&40M */
646 if (width < NL80211_CHAN_WIDTH_80)
647 channel_type =
648 cfg80211_get_chandef_type(&hw->conf.chandef);
434 if (mac->act_scanning) 649 if (mac->act_scanning)
435 mac->n_channels++; 650 mac->n_channels++;
436 651
437 if (rtlpriv->dm.supp_phymode_switch && 652 if (rtlpriv->dm.supp_phymode_switch &&
438 mac->link_state < MAC80211_LINKED && 653 mac->link_state < MAC80211_LINKED &&
439 !mac->act_scanning) { 654 !mac->act_scanning) {
440 if (rtlpriv->cfg->ops->chk_switch_dmdp) 655 if (rtlpriv->cfg->ops->chk_switch_dmdp)
441 rtlpriv->cfg->ops->chk_switch_dmdp(hw); 656 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
442 } 657 }
@@ -450,48 +665,98 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
450 *info for cisco1253 bw20, so we modify 665 *info for cisco1253 bw20, so we modify
451 *it here based on UPPER & LOWER 666 *it here based on UPPER & LOWER
452 */ 667 */
453 switch (cfg80211_get_chandef_type(&hw->conf.chandef)) { 668
454 case NL80211_CHAN_HT20: 669 if (width >= NL80211_CHAN_WIDTH_80) {
455 case NL80211_CHAN_NO_HT: 670 if (width == NL80211_CHAN_WIDTH_80) {
456 /* SC */ 671 u32 center = hw->conf.chandef.center_freq1;
457 mac->cur_40_prime_sc = 672 u32 primary =
458 PRIME_CHNL_OFFSET_DONT_CARE; 673 (u32)hw->conf.chandef.chan->center_freq;
459 rtlphy->current_chan_bw = HT_CHANNEL_WIDTH_20; 674
460 mac->bw_40 = false; 675 rtlphy->current_chan_bw =
461 break; 676 HT_CHANNEL_WIDTH_80;
462 case NL80211_CHAN_HT40MINUS: 677 mac->bw_80 = true;
463 /* SC */ 678 mac->bw_40 = true;
464 mac->cur_40_prime_sc = PRIME_CHNL_OFFSET_UPPER; 679 if (center > primary) {
465 rtlphy->current_chan_bw = 680 mac->cur_80_prime_sc =
466 HT_CHANNEL_WIDTH_20_40; 681 PRIME_CHNL_OFFSET_LOWER;
467 mac->bw_40 = true; 682 if (center - primary == 10) {
468 683 mac->cur_40_prime_sc =
469 /*wide channel */ 684 PRIME_CHNL_OFFSET_UPPER;
470 wide_chan -= 2; 685
471 686 wide_chan += 2;
472 break; 687 } else if (center - primary == 30) {
473 case NL80211_CHAN_HT40PLUS: 688 mac->cur_40_prime_sc =
474 /* SC */ 689 PRIME_CHNL_OFFSET_LOWER;
475 mac->cur_40_prime_sc = PRIME_CHNL_OFFSET_LOWER; 690
476 rtlphy->current_chan_bw = 691 wide_chan += 6;
477 HT_CHANNEL_WIDTH_20_40; 692 }
478 mac->bw_40 = true; 693 } else {
479 694 mac->cur_80_prime_sc =
480 /*wide channel */ 695 PRIME_CHNL_OFFSET_UPPER;
481 wide_chan += 2; 696 if (primary - center == 10) {
482 697 mac->cur_40_prime_sc =
483 break; 698 PRIME_CHNL_OFFSET_LOWER;
484 default: 699
485 mac->bw_40 = false; 700 wide_chan -= 2;
486 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 701 } else if (primary - center == 30) {
487 "switch case not processed\n"); 702 mac->cur_40_prime_sc =
488 break; 703 PRIME_CHNL_OFFSET_UPPER;
704
705 wide_chan -= 6;
706 }
707 }
708 }
709 } else {
710 switch (channel_type) {
711 case NL80211_CHAN_HT20:
712 case NL80211_CHAN_NO_HT:
713 /* SC */
714 mac->cur_40_prime_sc =
715 PRIME_CHNL_OFFSET_DONT_CARE;
716 rtlphy->current_chan_bw =
717 HT_CHANNEL_WIDTH_20;
718 mac->bw_40 = false;
719 mac->bw_80 = false;
720 break;
721 case NL80211_CHAN_HT40MINUS:
722 /* SC */
723 mac->cur_40_prime_sc =
724 PRIME_CHNL_OFFSET_UPPER;
725 rtlphy->current_chan_bw =
726 HT_CHANNEL_WIDTH_20_40;
727 mac->bw_40 = true;
728 mac->bw_80 = false;
729
730 /*wide channel */
731 wide_chan -= 2;
732
733 break;
734 case NL80211_CHAN_HT40PLUS:
735 /* SC */
736 mac->cur_40_prime_sc =
737 PRIME_CHNL_OFFSET_LOWER;
738 rtlphy->current_chan_bw =
739 HT_CHANNEL_WIDTH_20_40;
740 mac->bw_40 = true;
741 mac->bw_80 = false;
742
743 /*wide channel */
744 wide_chan += 2;
745
746 break;
747 default:
748 mac->bw_40 = false;
749 mac->bw_80 = false;
750 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
751 "switch case not processed\n");
752 break;
753 }
489 } 754 }
490 755
491 if (wide_chan <= 0) 756 if (wide_chan <= 0)
492 wide_chan = 1; 757 wide_chan = 1;
493 758
494 /* In scanning, before we go offchannel we may send a ps = 1 759 /* In scanning, when before we offchannel we may send a ps=1
495 * null to AP, and then we may send a ps = 0 null to AP quickly, 760 * null to AP, and then we may send a ps = 0 null to AP quickly,
496 * but first null may have caused AP to put lots of packet to 761 * but first null may have caused AP to put lots of packet to
497 * hw tx buffer. These packets must be tx'd before we go off 762 * hw tx buffer. These packets must be tx'd before we go off
@@ -503,12 +768,12 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
503 rtlpriv->mac80211.offchan_delay = false; 768 rtlpriv->mac80211.offchan_delay = false;
504 mdelay(50); 769 mdelay(50);
505 } 770 }
771
506 rtlphy->current_channel = wide_chan; 772 rtlphy->current_channel = wide_chan;
507 773
508 rtlpriv->cfg->ops->switch_channel(hw); 774 rtlpriv->cfg->ops->switch_channel(hw);
509 rtlpriv->cfg->ops->set_channel_access(hw); 775 rtlpriv->cfg->ops->set_channel_access(hw);
510 rtlpriv->cfg->ops->set_bw_mode(hw, 776 rtlpriv->cfg->ops->set_bw_mode(hw, channel_type);
511 cfg80211_get_chandef_type(&hw->conf.chandef));
512 } 777 }
513 778
514 mutex_unlock(&rtlpriv->locks.conf_mutex); 779 mutex_unlock(&rtlpriv->locks.conf_mutex);
@@ -517,45 +782,25 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
517} 782}
518 783
519static void rtl_op_configure_filter(struct ieee80211_hw *hw, 784static void rtl_op_configure_filter(struct ieee80211_hw *hw,
520 unsigned int changed_flags, 785 unsigned int changed_flags,
521 unsigned int *new_flags, u64 multicast) 786 unsigned int *new_flags, u64 multicast)
522{ 787{
523 struct rtl_priv *rtlpriv = rtl_priv(hw); 788 struct rtl_priv *rtlpriv = rtl_priv(hw);
524 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 789 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
525 u32 rx_conf;
526 790
527 *new_flags &= RTL_SUPPORTED_FILTERS; 791 *new_flags &= RTL_SUPPORTED_FILTERS;
528 if (!changed_flags) 792 if (0 == changed_flags)
529 return; 793 return;
530 794
531 /* if ssid not set to hw don't check bssid
532 * here just used for linked scanning, & linked
533 * and nolink check bssid is set in set network_type */
534 if ((changed_flags & FIF_BCN_PRBRESP_PROMISC) &&
535 (mac->link_state >= MAC80211_LINKED)) {
536 if (mac->opmode != NL80211_IFTYPE_AP &&
537 mac->opmode != NL80211_IFTYPE_MESH_POINT) {
538 if (*new_flags & FIF_BCN_PRBRESP_PROMISC) {
539 rtlpriv->cfg->ops->set_chk_bssid(hw, false);
540 } else {
541 rtlpriv->cfg->ops->set_chk_bssid(hw, true);
542 }
543 }
544 }
545
546 /* must be called after set_chk_bssid since that function modifies the
547 * RCR register too. */
548 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *)(&rx_conf));
549
550 /*TODO: we disable broadcase now, so enable here */ 795 /*TODO: we disable broadcase now, so enable here */
551 if (changed_flags & FIF_ALLMULTI) { 796 if (changed_flags & FIF_ALLMULTI) {
552 if (*new_flags & FIF_ALLMULTI) { 797 if (*new_flags & FIF_ALLMULTI) {
553 rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AM] | 798 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AM] |
554 rtlpriv->cfg->maps[MAC_RCR_AB]; 799 rtlpriv->cfg->maps[MAC_RCR_AB];
555 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 800 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
556 "Enable receive multicast frame\n"); 801 "Enable receive multicast frame\n");
557 } else { 802 } else {
558 rx_conf &= ~(rtlpriv->cfg->maps[MAC_RCR_AM] | 803 mac->rx_conf &= ~(rtlpriv->cfg->maps[MAC_RCR_AM] |
559 rtlpriv->cfg->maps[MAC_RCR_AB]); 804 rtlpriv->cfg->maps[MAC_RCR_AB]);
560 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 805 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
561 "Disable receive multicast frame\n"); 806 "Disable receive multicast frame\n");
@@ -564,43 +809,55 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
564 809
565 if (changed_flags & FIF_FCSFAIL) { 810 if (changed_flags & FIF_FCSFAIL) {
566 if (*new_flags & FIF_FCSFAIL) { 811 if (*new_flags & FIF_FCSFAIL) {
567 rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACRC32]; 812 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACRC32];
568 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 813 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
569 "Enable receive FCS error frame\n"); 814 "Enable receive FCS error frame\n");
570 } else { 815 } else {
571 rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACRC32]; 816 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACRC32];
572 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 817 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
573 "Disable receive FCS error frame\n"); 818 "Disable receive FCS error frame\n");
574 } 819 }
575 } 820 }
576 821
822 /* if ssid not set to hw don't check bssid
823 * here just used for linked scanning, & linked
824 * and nolink check bssid is set in set network_type
825 */
826 if ((changed_flags & FIF_BCN_PRBRESP_PROMISC) &&
827 (mac->link_state >= MAC80211_LINKED)) {
828 if (mac->opmode != NL80211_IFTYPE_AP &&
829 mac->opmode != NL80211_IFTYPE_MESH_POINT) {
830 if (*new_flags & FIF_BCN_PRBRESP_PROMISC)
831 rtlpriv->cfg->ops->set_chk_bssid(hw, false);
832 else
833 rtlpriv->cfg->ops->set_chk_bssid(hw, true);
834 }
835 }
577 836
578 if (changed_flags & FIF_CONTROL) { 837 if (changed_flags & FIF_CONTROL) {
579 if (*new_flags & FIF_CONTROL) { 838 if (*new_flags & FIF_CONTROL) {
580 rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACF]; 839 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACF];
581 840
582 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 841 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
583 "Enable receive control frame\n"); 842 "Enable receive control frame.\n");
584 } else { 843 } else {
585 rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACF]; 844 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACF];
586 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 845 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
587 "Disable receive control frame\n"); 846 "Disable receive control frame.\n");
588 } 847 }
589 } 848 }
590 849
591 if (changed_flags & FIF_OTHER_BSS) { 850 if (changed_flags & FIF_OTHER_BSS) {
592 if (*new_flags & FIF_OTHER_BSS) { 851 if (*new_flags & FIF_OTHER_BSS) {
593 rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AAP]; 852 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AAP];
594 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 853 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
595 "Enable receive other BSS's frame\n"); 854 "Enable receive other BSS's frame.\n");
596 } else { 855 } else {
597 rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_AAP]; 856 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_AAP];
598 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 857 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
599 "Disable receive other BSS's frame\n"); 858 "Disable receive other BSS's frame.\n");
600 } 859 }
601 } 860 }
602
603 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, (u8 *)(&rx_conf));
604} 861}
605static int rtl_op_sta_add(struct ieee80211_hw *hw, 862static int rtl_op_sta_add(struct ieee80211_hw *hw,
606 struct ieee80211_vif *vif, 863 struct ieee80211_vif *vif,
@@ -612,7 +869,7 @@ static int rtl_op_sta_add(struct ieee80211_hw *hw,
612 struct rtl_sta_info *sta_entry; 869 struct rtl_sta_info *sta_entry;
613 870
614 if (sta) { 871 if (sta) {
615 sta_entry = (struct rtl_sta_info *) sta->drv_priv; 872 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
616 spin_lock_bh(&rtlpriv->locks.entry_list_lock); 873 spin_lock_bh(&rtlpriv->locks.entry_list_lock);
617 list_add_tail(&sta_entry->list, &rtlpriv->entry_list); 874 list_add_tail(&sta_entry->list, &rtlpriv->entry_list);
618 spin_unlock_bh(&rtlpriv->locks.entry_list_lock); 875 spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
@@ -620,15 +877,17 @@ static int rtl_op_sta_add(struct ieee80211_hw *hw,
620 sta_entry->wireless_mode = WIRELESS_MODE_G; 877 sta_entry->wireless_mode = WIRELESS_MODE_G;
621 if (sta->supp_rates[0] <= 0xf) 878 if (sta->supp_rates[0] <= 0xf)
622 sta_entry->wireless_mode = WIRELESS_MODE_B; 879 sta_entry->wireless_mode = WIRELESS_MODE_B;
623 if (sta->ht_cap.ht_supported == true) 880 if (sta->ht_cap.ht_supported)
624 sta_entry->wireless_mode = WIRELESS_MODE_N_24G; 881 sta_entry->wireless_mode = WIRELESS_MODE_N_24G;
625 882
626 if (vif->type == NL80211_IFTYPE_ADHOC) 883 if (vif->type == NL80211_IFTYPE_ADHOC)
627 sta_entry->wireless_mode = WIRELESS_MODE_G; 884 sta_entry->wireless_mode = WIRELESS_MODE_G;
628 } else if (rtlhal->current_bandtype == BAND_ON_5G) { 885 } else if (rtlhal->current_bandtype == BAND_ON_5G) {
629 sta_entry->wireless_mode = WIRELESS_MODE_A; 886 sta_entry->wireless_mode = WIRELESS_MODE_A;
630 if (sta->ht_cap.ht_supported == true) 887 if (sta->ht_cap.ht_supported)
631 sta_entry->wireless_mode = WIRELESS_MODE_N_24G; 888 sta_entry->wireless_mode = WIRELESS_MODE_N_5G;
889 if (sta->vht_cap.vht_supported)
890 sta_entry->wireless_mode = WIRELESS_MODE_AC_5G;
632 891
633 if (vif->type == NL80211_IFTYPE_ADHOC) 892 if (vif->type == NL80211_IFTYPE_ADHOC)
634 sta_entry->wireless_mode = WIRELESS_MODE_A; 893 sta_entry->wireless_mode = WIRELESS_MODE_A;
@@ -639,9 +898,10 @@ static int rtl_op_sta_add(struct ieee80211_hw *hw,
639 898
640 memcpy(sta_entry->mac_addr, sta->addr, ETH_ALEN); 899 memcpy(sta_entry->mac_addr, sta->addr, ETH_ALEN);
641 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 900 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
642 "Add sta addr is %pM\n", sta->addr); 901 "Add sta addr is %pM\n", sta->addr);
643 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); 902 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0);
644 } 903 }
904
645 return 0; 905 return 0;
646} 906}
647 907
@@ -654,17 +914,15 @@ static int rtl_op_sta_remove(struct ieee80211_hw *hw,
654 if (sta) { 914 if (sta) {
655 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 915 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
656 "Remove sta addr is %pM\n", sta->addr); 916 "Remove sta addr is %pM\n", sta->addr);
657 sta_entry = (struct rtl_sta_info *) sta->drv_priv; 917 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
658 sta_entry->wireless_mode = 0; 918 sta_entry->wireless_mode = 0;
659 sta_entry->ratr_index = 0; 919 sta_entry->ratr_index = 0;
660
661 spin_lock_bh(&rtlpriv->locks.entry_list_lock); 920 spin_lock_bh(&rtlpriv->locks.entry_list_lock);
662 list_del(&sta_entry->list); 921 list_del(&sta_entry->list);
663 spin_unlock_bh(&rtlpriv->locks.entry_list_lock); 922 spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
664 } 923 }
665 return 0; 924 return 0;
666} 925}
667
668static int _rtl_get_hal_qnum(u16 queue) 926static int _rtl_get_hal_qnum(u16 queue)
669{ 927{
670 int qnum; 928 int qnum;
@@ -694,8 +952,8 @@ static int _rtl_get_hal_qnum(u16 queue)
694 *for rtl819x BE = 0, BK = 1, VI = 2, VO = 3 952 *for rtl819x BE = 0, BK = 1, VI = 2, VO = 3
695 */ 953 */
696static int rtl_op_conf_tx(struct ieee80211_hw *hw, 954static int rtl_op_conf_tx(struct ieee80211_hw *hw,
697 struct ieee80211_vif *vif, u16 queue, 955 struct ieee80211_vif *vif, u16 queue,
698 const struct ieee80211_tx_queue_params *param) 956 const struct ieee80211_tx_queue_params *param)
699{ 957{
700 struct rtl_priv *rtlpriv = rtl_priv(hw); 958 struct rtl_priv *rtlpriv = rtl_priv(hw);
701 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 959 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
@@ -718,14 +976,14 @@ static int rtl_op_conf_tx(struct ieee80211_hw *hw,
718} 976}
719 977
720static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, 978static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
721 struct ieee80211_vif *vif, 979 struct ieee80211_vif *vif,
722 struct ieee80211_bss_conf *bss_conf, u32 changed) 980 struct ieee80211_bss_conf *bss_conf,
981 u32 changed)
723{ 982{
724 struct rtl_priv *rtlpriv = rtl_priv(hw); 983 struct rtl_priv *rtlpriv = rtl_priv(hw);
725 struct rtl_hal *rtlhal = rtl_hal(rtlpriv); 984 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
726 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 985 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
727 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 986 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
728 struct ieee80211_sta *sta = NULL;
729 987
730 mutex_lock(&rtlpriv->locks.conf_mutex); 988 mutex_lock(&rtlpriv->locks.conf_mutex);
731 if ((vif->type == NL80211_IFTYPE_ADHOC) || 989 if ((vif->type == NL80211_IFTYPE_ADHOC) ||
@@ -743,15 +1001,14 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
743 mac->beacon_enabled = 1; 1001 mac->beacon_enabled = 1;
744 rtlpriv->cfg->ops->update_interrupt_mask(hw, 1002 rtlpriv->cfg->ops->update_interrupt_mask(hw,
745 rtlpriv->cfg->maps 1003 rtlpriv->cfg->maps
746 [RTL_IBSS_INT_MASKS], 1004 [RTL_IBSS_INT_MASKS], 0);
747 0);
748 1005
749 if (rtlpriv->cfg->ops->linked_set_reg) 1006 if (rtlpriv->cfg->ops->linked_set_reg)
750 rtlpriv->cfg->ops->linked_set_reg(hw); 1007 rtlpriv->cfg->ops->linked_set_reg(hw);
751 } 1008 }
752 } 1009 }
753 if ((changed & BSS_CHANGED_BEACON_ENABLED && 1010 if ((changed & BSS_CHANGED_BEACON_ENABLED &&
754 !bss_conf->enable_beacon)) { 1011 !bss_conf->enable_beacon)) {
755 if (mac->beacon_enabled == 1) { 1012 if (mac->beacon_enabled == 1) {
756 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 1013 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
757 "ADHOC DISABLE BEACON\n"); 1014 "ADHOC DISABLE BEACON\n");
@@ -772,8 +1029,12 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
772 1029
773 /*TODO: reference to enum ieee80211_bss_change */ 1030 /*TODO: reference to enum ieee80211_bss_change */
774 if (changed & BSS_CHANGED_ASSOC) { 1031 if (changed & BSS_CHANGED_ASSOC) {
1032 u8 mstatus;
775 if (bss_conf->assoc) { 1033 if (bss_conf->assoc) {
776 struct ieee80211_sta *sta = NULL; 1034 struct ieee80211_sta *sta = NULL;
1035 u8 keep_alive = 10;
1036
1037 mstatus = RT_MEDIA_CONNECT;
777 /* we should reset all sec info & cam 1038 /* we should reset all sec info & cam
778 * before set cam after linked, we should not 1039 * before set cam after linked, we should not
779 * reset in disassoc, that will cause tkip->wep 1040 * reset in disassoc, that will cause tkip->wep
@@ -791,47 +1052,89 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
791 1052
792 if (rtlpriv->cfg->ops->linked_set_reg) 1053 if (rtlpriv->cfg->ops->linked_set_reg)
793 rtlpriv->cfg->ops->linked_set_reg(hw); 1054 rtlpriv->cfg->ops->linked_set_reg(hw);
1055
794 rcu_read_lock(); 1056 rcu_read_lock();
795 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid); 1057 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
796 if (!sta) { 1058 if (!sta) {
797 pr_err("ieee80211_find_sta returned NULL\n");
798 rcu_read_unlock(); 1059 rcu_read_unlock();
799 goto out; 1060 goto out;
800 } 1061 }
801
802 if (vif->type == NL80211_IFTYPE_STATION && sta)
803 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0);
804 RT_TRACE(rtlpriv, COMP_EASY_CONCURRENT, DBG_LOUD, 1062 RT_TRACE(rtlpriv, COMP_EASY_CONCURRENT, DBG_LOUD,
805 "send PS STATIC frame\n"); 1063 "send PS STATIC frame\n");
806 if (rtlpriv->dm.supp_phymode_switch) { 1064 if (rtlpriv->dm.supp_phymode_switch) {
807 if (sta->ht_cap.ht_supported) 1065 if (sta->ht_cap.ht_supported)
808 rtl_send_smps_action(hw, sta, 1066 rtl_send_smps_action(hw, sta,
809 IEEE80211_SMPS_STATIC); 1067 IEEE80211_SMPS_STATIC);
810 } 1068 }
1069
1070 if (rtlhal->current_bandtype == BAND_ON_5G) {
1071 mac->mode = WIRELESS_MODE_A;
1072 } else {
1073 if (sta->supp_rates[0] <= 0xf)
1074 mac->mode = WIRELESS_MODE_B;
1075 else
1076 mac->mode = WIRELESS_MODE_G;
1077 }
1078
1079 if (sta->ht_cap.ht_supported) {
1080 if (rtlhal->current_bandtype == BAND_ON_2_4G)
1081 mac->mode = WIRELESS_MODE_N_24G;
1082 else
1083 mac->mode = WIRELESS_MODE_N_5G;
1084 }
1085
1086 if (sta->vht_cap.vht_supported) {
1087 if (rtlhal->current_bandtype == BAND_ON_5G)
1088 mac->mode = WIRELESS_MODE_AC_5G;
1089 else
1090 mac->mode = WIRELESS_MODE_AC_24G;
1091 }
1092
1093 if (vif->type == NL80211_IFTYPE_STATION && sta)
1094 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0);
811 rcu_read_unlock(); 1095 rcu_read_unlock();
812 1096
1097 /* to avoid AP Disassociation caused by inactivity */
1098 rtlpriv->cfg->ops->set_hw_reg(hw,
1099 HW_VAR_KEEP_ALIVE,
1100 (u8 *)(&keep_alive));
1101
813 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 1102 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
814 "BSS_CHANGED_ASSOC\n"); 1103 "BSS_CHANGED_ASSOC\n");
815 } else { 1104 } else {
1105 mstatus = RT_MEDIA_DISCONNECT;
1106
816 if (mac->link_state == MAC80211_LINKED) { 1107 if (mac->link_state == MAC80211_LINKED) {
817 rtlpriv->enter_ps = false; 1108 rtlpriv->enter_ps = false;
818 schedule_work(&rtlpriv->works.lps_change_work); 1109 schedule_work(&rtlpriv->works.lps_change_work);
819 } 1110 }
820
821 if (ppsc->p2p_ps_info.p2p_ps_mode > P2P_PS_NONE) 1111 if (ppsc->p2p_ps_info.p2p_ps_mode > P2P_PS_NONE)
822 rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE); 1112 rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE);
823 mac->link_state = MAC80211_NOLINK; 1113 mac->link_state = MAC80211_NOLINK;
824 memset(mac->bssid, 0, ETH_ALEN); 1114 memset(mac->bssid, 0, ETH_ALEN);
825 mac->vendor = PEER_UNKNOWN; 1115 mac->vendor = PEER_UNKNOWN;
1116 mac->mode = 0;
826 1117
827 if (rtlpriv->dm.supp_phymode_switch) { 1118 if (rtlpriv->dm.supp_phymode_switch) {
828 if (rtlpriv->cfg->ops->chk_switch_dmdp) 1119 if (rtlpriv->cfg->ops->chk_switch_dmdp)
829 rtlpriv->cfg->ops->chk_switch_dmdp(hw); 1120 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
830 } 1121 }
831
832 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 1122 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
833 "BSS_CHANGED_UN_ASSOC\n"); 1123 "BSS_CHANGED_UN_ASSOC\n");
834 } 1124 }
1125 rtlpriv->cfg->ops->set_network_type(hw, vif->type);
1126 /* For FW LPS:
1127 * To tell firmware we have connected or disconnected
1128 */
1129 rtlpriv->cfg->ops->set_hw_reg(hw,
1130 HW_VAR_H2C_FW_JOINBSSRPT,
1131 (u8 *)(&mstatus));
1132 ppsc->report_linked = (mstatus == RT_MEDIA_CONNECT) ?
1133 true : false;
1134
1135 if (rtlpriv->cfg->ops->get_btc_status())
1136 rtlpriv->btcoexist.btc_ops->btc_mediastatus_notify(
1137 rtlpriv, mstatus);
835 } 1138 }
836 1139
837 if (changed & BSS_CHANGED_ERP_CTS_PROT) { 1140 if (changed & BSS_CHANGED_ERP_CTS_PROT) {
@@ -843,11 +1146,11 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
843 if (changed & BSS_CHANGED_ERP_PREAMBLE) { 1146 if (changed & BSS_CHANGED_ERP_PREAMBLE) {
844 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 1147 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
845 "BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n", 1148 "BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n",
846 bss_conf->use_short_preamble); 1149 bss_conf->use_short_preamble);
847 1150
848 mac->short_preamble = bss_conf->use_short_preamble; 1151 mac->short_preamble = bss_conf->use_short_preamble;
849 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACK_PREAMBLE, 1152 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACK_PREAMBLE,
850 &mac->short_preamble); 1153 (u8 *)(&mac->short_preamble));
851 } 1154 }
852 1155
853 if (changed & BSS_CHANGED_ERP_SLOT) { 1156 if (changed & BSS_CHANGED_ERP_SLOT) {
@@ -860,13 +1163,17 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
860 mac->slot_time = RTL_SLOT_TIME_20; 1163 mac->slot_time = RTL_SLOT_TIME_20;
861 1164
862 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME, 1165 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME,
863 &mac->slot_time); 1166 (u8 *)(&mac->slot_time));
864 } 1167 }
865 1168
866 if (changed & BSS_CHANGED_HT) { 1169 if (changed & BSS_CHANGED_HT) {
867 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, "BSS_CHANGED_HT\n"); 1170 struct ieee80211_sta *sta = NULL;
1171
1172 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1173 "BSS_CHANGED_HT\n");
1174
868 rcu_read_lock(); 1175 rcu_read_lock();
869 sta = get_sta(hw, vif, bss_conf->bssid); 1176 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
870 if (sta) { 1177 if (sta) {
871 if (sta->ht_cap.ampdu_density > 1178 if (sta->ht_cap.ampdu_density >
872 mac->current_ampdu_density) 1179 mac->current_ampdu_density)
@@ -880,7 +1187,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
880 rcu_read_unlock(); 1187 rcu_read_unlock();
881 1188
882 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SHORTGI_DENSITY, 1189 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SHORTGI_DENSITY,
883 &mac->max_mss_density); 1190 (u8 *)(&mac->max_mss_density));
884 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_FACTOR, 1191 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_FACTOR,
885 &mac->current_ampdu_factor); 1192 &mac->current_ampdu_factor);
886 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_MIN_SPACE, 1193 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_MIN_SPACE,
@@ -889,19 +1196,19 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
889 1196
890 if (changed & BSS_CHANGED_BSSID) { 1197 if (changed & BSS_CHANGED_BSSID) {
891 u32 basic_rates; 1198 u32 basic_rates;
1199 struct ieee80211_sta *sta = NULL;
892 1200
893 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BSSID, 1201 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BSSID,
894 (u8 *) bss_conf->bssid); 1202 (u8 *)bss_conf->bssid);
895 1203
896 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, "%pM\n", 1204 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
897 bss_conf->bssid); 1205 "bssid: %pM\n", bss_conf->bssid);
898 1206
899 mac->vendor = PEER_UNKNOWN; 1207 mac->vendor = PEER_UNKNOWN;
900 memcpy(mac->bssid, bss_conf->bssid, ETH_ALEN); 1208 memcpy(mac->bssid, bss_conf->bssid, ETH_ALEN);
901 rtlpriv->cfg->ops->set_network_type(hw, vif->type);
902 1209
903 rcu_read_lock(); 1210 rcu_read_lock();
904 sta = get_sta(hw, vif, bss_conf->bssid); 1211 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
905 if (!sta) { 1212 if (!sta) {
906 rcu_read_unlock(); 1213 rcu_read_unlock();
907 goto out; 1214 goto out;
@@ -923,11 +1230,18 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
923 mac->mode = WIRELESS_MODE_N_5G; 1230 mac->mode = WIRELESS_MODE_N_5G;
924 } 1231 }
925 1232
1233 if (sta->vht_cap.vht_supported) {
1234 if (rtlhal->current_bandtype == BAND_ON_5G)
1235 mac->mode = WIRELESS_MODE_AC_5G;
1236 else
1237 mac->mode = WIRELESS_MODE_AC_24G;
1238 }
1239
926 /* just station need it, because ibss & ap mode will 1240 /* just station need it, because ibss & ap mode will
927 * set in sta_add, and will be NULL here */ 1241 * set in sta_add, and will be NULL here */
928 if (mac->opmode == NL80211_IFTYPE_STATION) { 1242 if (vif->type == NL80211_IFTYPE_STATION) {
929 struct rtl_sta_info *sta_entry; 1243 struct rtl_sta_info *sta_entry;
930 sta_entry = (struct rtl_sta_info *) sta->drv_priv; 1244 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
931 sta_entry->wireless_mode = mac->mode; 1245 sta_entry->wireless_mode = mac->mode;
932 } 1246 }
933 1247
@@ -942,6 +1256,9 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
942 * */ 1256 * */
943 } 1257 }
944 1258
1259 if (sta->vht_cap.vht_supported)
1260 mac->vht_enable = true;
1261
945 if (changed & BSS_CHANGED_BASIC_RATES) { 1262 if (changed & BSS_CHANGED_BASIC_RATES) {
946 /* for 5G must << RATE_6M_INDEX = 4, 1263 /* for 5G must << RATE_6M_INDEX = 4,
947 * because 5G have no cck rate*/ 1264 * because 5G have no cck rate*/
@@ -956,40 +1273,6 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
956 } 1273 }
957 rcu_read_unlock(); 1274 rcu_read_unlock();
958 } 1275 }
959
960 /*
961 * For FW LPS:
962 * To tell firmware we have connected
963 * to an AP. For 92SE/CE power save v2.
964 */
965 if (changed & BSS_CHANGED_ASSOC) {
966 if (bss_conf->assoc) {
967 if (ppsc->fwctrl_lps) {
968 u8 mstatus = RT_MEDIA_CONNECT;
969 u8 keep_alive = 10;
970 rtlpriv->cfg->ops->set_hw_reg(hw,
971 HW_VAR_KEEP_ALIVE,
972 &keep_alive);
973
974 rtlpriv->cfg->ops->set_hw_reg(hw,
975 HW_VAR_H2C_FW_JOINBSSRPT,
976 &mstatus);
977 ppsc->report_linked = true;
978 }
979 } else {
980 if (ppsc->fwctrl_lps) {
981 u8 mstatus = RT_MEDIA_DISCONNECT;
982 rtlpriv->cfg->ops->set_hw_reg(hw,
983 HW_VAR_H2C_FW_JOINBSSRPT,
984 &mstatus);
985 ppsc->report_linked = false;
986 }
987 }
988 if (rtlpriv->cfg->ops->bt_wifi_media_status_notify)
989 rtlpriv->cfg->ops->bt_wifi_media_status_notify(hw,
990 ppsc->report_linked);
991 }
992
993out: 1276out:
994 mutex_unlock(&rtlpriv->locks.conf_mutex); 1277 mutex_unlock(&rtlpriv->locks.conf_mutex);
995} 1278}
@@ -999,28 +1282,27 @@ static u64 rtl_op_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
999 struct rtl_priv *rtlpriv = rtl_priv(hw); 1282 struct rtl_priv *rtlpriv = rtl_priv(hw);
1000 u64 tsf; 1283 u64 tsf;
1001 1284
1002 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *) (&tsf)); 1285 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *)(&tsf));
1003 return tsf; 1286 return tsf;
1004} 1287}
1005 1288
1006static void rtl_op_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1289static void rtl_op_set_tsf(struct ieee80211_hw *hw,
1007 u64 tsf) 1290 struct ieee80211_vif *vif, u64 tsf)
1008{ 1291{
1009 struct rtl_priv *rtlpriv = rtl_priv(hw); 1292 struct rtl_priv *rtlpriv = rtl_priv(hw);
1010 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 1293 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1011 u8 bibss = (mac->opmode == NL80211_IFTYPE_ADHOC) ? 1 : 0; 1294 u8 bibss = (mac->opmode == NL80211_IFTYPE_ADHOC) ? 1 : 0;
1012 1295
1013 mac->tsf = tsf; 1296 mac->tsf = tsf;
1014 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_CORRECT_TSF, &bibss); 1297 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *)(&bibss));
1015} 1298}
1016 1299
1017static void rtl_op_reset_tsf(struct ieee80211_hw *hw, 1300static void rtl_op_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1018 struct ieee80211_vif *vif)
1019{ 1301{
1020 struct rtl_priv *rtlpriv = rtl_priv(hw); 1302 struct rtl_priv *rtlpriv = rtl_priv(hw);
1021 u8 tmp = 0; 1303 u8 tmp = 0;
1022 1304
1023 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_DUAL_TSF_RST, &tmp); 1305 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_DUAL_TSF_RST, (u8 *)(&tmp));
1024} 1306}
1025 1307
1026static void rtl_op_sta_notify(struct ieee80211_hw *hw, 1308static void rtl_op_sta_notify(struct ieee80211_hw *hw,
@@ -1050,13 +1332,13 @@ static int rtl_op_ampdu_action(struct ieee80211_hw *hw,
1050 case IEEE80211_AMPDU_TX_START: 1332 case IEEE80211_AMPDU_TX_START:
1051 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, 1333 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1052 "IEEE80211_AMPDU_TX_START: TID:%d\n", tid); 1334 "IEEE80211_AMPDU_TX_START: TID:%d\n", tid);
1053 return rtl_tx_agg_start(hw, sta, tid, ssn); 1335 return rtl_tx_agg_start(hw, vif, sta, tid, ssn);
1054 case IEEE80211_AMPDU_TX_STOP_CONT: 1336 case IEEE80211_AMPDU_TX_STOP_CONT:
1055 case IEEE80211_AMPDU_TX_STOP_FLUSH: 1337 case IEEE80211_AMPDU_TX_STOP_FLUSH:
1056 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: 1338 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
1057 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, 1339 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1058 "IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid); 1340 "IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid);
1059 return rtl_tx_agg_stop(hw, sta, tid); 1341 return rtl_tx_agg_stop(hw, vif, sta, tid);
1060 case IEEE80211_AMPDU_TX_OPERATIONAL: 1342 case IEEE80211_AMPDU_TX_OPERATIONAL:
1061 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, 1343 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1062 "IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid); 1344 "IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid);
@@ -1090,10 +1372,14 @@ static void rtl_op_sw_scan_start(struct ieee80211_hw *hw)
1090 return; 1372 return;
1091 } 1373 }
1092 1374
1375 if (rtlpriv->cfg->ops->get_btc_status())
1376 rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 1);
1377
1093 if (rtlpriv->dm.supp_phymode_switch) { 1378 if (rtlpriv->dm.supp_phymode_switch) {
1094 if (rtlpriv->cfg->ops->chk_switch_dmdp) 1379 if (rtlpriv->cfg->ops->chk_switch_dmdp)
1095 rtlpriv->cfg->ops->chk_switch_dmdp(hw); 1380 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
1096 } 1381 }
1382
1097 if (mac->link_state == MAC80211_LINKED) { 1383 if (mac->link_state == MAC80211_LINKED) {
1098 rtlpriv->enter_ps = false; 1384 rtlpriv->enter_ps = false;
1099 schedule_work(&rtlpriv->works.lps_change_work); 1385 schedule_work(&rtlpriv->works.lps_change_work);
@@ -1102,11 +1388,11 @@ static void rtl_op_sw_scan_start(struct ieee80211_hw *hw)
1102 rtl_ips_nic_on(hw); 1388 rtl_ips_nic_on(hw);
1103 } 1389 }
1104 1390
1105 /* Dual mac */ 1391 /* Dul mac */
1106 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false; 1392 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false;
1107 1393
1108 rtlpriv->cfg->ops->led_control(hw, LED_CTL_SITE_SURVEY); 1394 rtlpriv->cfg->ops->led_control(hw, LED_CTL_SITE_SURVEY);
1109 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_BACKUP); 1395 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_BACKUP_BAND0);
1110} 1396}
1111 1397
1112static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw) 1398static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw)
@@ -1120,13 +1406,13 @@ static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw)
1120 if (rtlpriv->link_info.higher_busytraffic) 1406 if (rtlpriv->link_info.higher_busytraffic)
1121 return; 1407 return;
1122 1408
1123 /*p2p will use 1/6/11 to scan */ 1409 /* p2p will use 1/6/11 to scan */
1124 if (mac->n_channels == 3) 1410 if (mac->n_channels == 3)
1125 mac->p2p_in_use = true; 1411 mac->p2p_in_use = true;
1126 else 1412 else
1127 mac->p2p_in_use = false; 1413 mac->p2p_in_use = false;
1128 mac->n_channels = 0; 1414 mac->n_channels = 0;
1129 /* Dual mac */ 1415 /* Dul mac */
1130 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false; 1416 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false;
1131 1417
1132 if (mac->link_state == MAC80211_LINKED_SCANNING) { 1418 if (mac->link_state == MAC80211_LINKED_SCANNING) {
@@ -1138,6 +1424,8 @@ static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw)
1138 } 1424 }
1139 1425
1140 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_RESTORE); 1426 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_RESTORE);
1427 if (rtlpriv->cfg->ops->get_btc_status())
1428 rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 0);
1141} 1429}
1142 1430
1143static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 1431static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
@@ -1145,7 +1433,6 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1145 struct ieee80211_key_conf *key) 1433 struct ieee80211_key_conf *key)
1146{ 1434{
1147 struct rtl_priv *rtlpriv = rtl_priv(hw); 1435 struct rtl_priv *rtlpriv = rtl_priv(hw);
1148 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1149 u8 key_type = NO_ENCRYPTION; 1436 u8 key_type = NO_ENCRYPTION;
1150 u8 key_idx; 1437 u8 key_idx;
1151 bool group_key = false; 1438 bool group_key = false;
@@ -1161,13 +1448,13 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1161 } 1448 }
1162 /* To support IBSS, use sw-crypto for GTK */ 1449 /* To support IBSS, use sw-crypto for GTK */
1163 if (((vif->type == NL80211_IFTYPE_ADHOC) || 1450 if (((vif->type == NL80211_IFTYPE_ADHOC) ||
1164 (vif->type == NL80211_IFTYPE_MESH_POINT)) && 1451 (vif->type == NL80211_IFTYPE_MESH_POINT)) &&
1165 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) 1452 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
1166 return -ENOSPC; 1453 return -ENOSPC;
1167 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 1454 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1168 "%s hardware based encryption for keyidx: %d, mac: %pM\n", 1455 "%s hardware based encryption for keyidx: %d, mac: %pM\n",
1169 cmd == SET_KEY ? "Using" : "Disabling", key->keyidx, 1456 cmd == SET_KEY ? "Using" : "Disabling", key->keyidx,
1170 sta ? sta->addr : bcast_addr); 1457 sta ? sta->addr : bcast_addr);
1171 rtlpriv->sec.being_setkey = true; 1458 rtlpriv->sec.being_setkey = true;
1172 rtl_ips_nic_on(hw); 1459 rtl_ips_nic_on(hw);
1173 mutex_lock(&rtlpriv->locks.conf_mutex); 1460 mutex_lock(&rtlpriv->locks.conf_mutex);
@@ -1191,21 +1478,23 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1191 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CCMP\n"); 1478 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CCMP\n");
1192 break; 1479 break;
1193 case WLAN_CIPHER_SUITE_AES_CMAC: 1480 case WLAN_CIPHER_SUITE_AES_CMAC:
1194 /*HW doesn't support CMAC encryption, use software CMAC */ 1481 /* HW don't support CMAC encryption,
1482 * use software CMAC encryption
1483 */
1195 key_type = AESCMAC_ENCRYPTION; 1484 key_type = AESCMAC_ENCRYPTION;
1196 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CMAC\n"); 1485 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CMAC\n");
1197 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 1486 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1198 "HW don't support CMAC encryption, use software CMAC\n"); 1487 "HW don't support CMAC encrypiton, use software CMAC encrypiton\n");
1199 err = -EOPNOTSUPP; 1488 err = -EOPNOTSUPP;
1200 goto out_unlock; 1489 goto out_unlock;
1201 default: 1490 default:
1202 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "alg_err:%x!!!!\n", 1491 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1203 key->cipher); 1492 "alg_err:%x!!!!:\n", key->cipher);
1204 goto out_unlock; 1493 goto out_unlock;
1205 } 1494 }
1206 if (key_type == WEP40_ENCRYPTION || 1495 if (key_type == WEP40_ENCRYPTION ||
1207 key_type == WEP104_ENCRYPTION || 1496 key_type == WEP104_ENCRYPTION ||
1208 mac->opmode == NL80211_IFTYPE_ADHOC) 1497 vif->type == NL80211_IFTYPE_ADHOC)
1209 rtlpriv->sec.use_defaultkey = true; 1498 rtlpriv->sec.use_defaultkey = true;
1210 1499
1211 /* <2> get key_idx */ 1500 /* <2> get key_idx */
@@ -1219,14 +1508,14 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1219 * 1) wep only: is just for wep enc, in this condition 1508 * 1) wep only: is just for wep enc, in this condition
1220 * rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION 1509 * rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION
1221 * will be true & enable_hw_sec will be set when wep 1510 * will be true & enable_hw_sec will be set when wep
1222 * key setting. 1511 * ke setting.
1223 * 2) wep(group) + AES(pairwise): some AP like cisco 1512 * 2) wep(group) + AES(pairwise): some AP like cisco
1224 * may use it, in this condition enable_hw_sec will not 1513 * may use it, in this condition enable_hw_sec will not
1225 * be set when wep key setting */ 1514 * be set when wep key setting */
1226 /* we must reset sec_info after lingked before set key, 1515 /* we must reset sec_info after lingked before set key,
1227 * or some flag will be wrong*/ 1516 * or some flag will be wrong*/
1228 if (vif->type == NL80211_IFTYPE_AP || 1517 if (vif->type == NL80211_IFTYPE_AP ||
1229 vif->type == NL80211_IFTYPE_MESH_POINT) { 1518 vif->type == NL80211_IFTYPE_MESH_POINT) {
1230 if (!group_key || key_type == WEP40_ENCRYPTION || 1519 if (!group_key || key_type == WEP40_ENCRYPTION ||
1231 key_type == WEP104_ENCRYPTION) { 1520 key_type == WEP104_ENCRYPTION) {
1232 if (group_key) 1521 if (group_key)
@@ -1234,11 +1523,11 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1234 rtlpriv->cfg->ops->enable_hw_sec(hw); 1523 rtlpriv->cfg->ops->enable_hw_sec(hw);
1235 } 1524 }
1236 } else { 1525 } else {
1237 if ((!group_key) || (mac->opmode == NL80211_IFTYPE_ADHOC) || 1526 if ((!group_key) || (vif->type == NL80211_IFTYPE_ADHOC) ||
1238 rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION) { 1527 rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION) {
1239 if (rtlpriv->sec.pairwise_enc_algorithm == 1528 if (rtlpriv->sec.pairwise_enc_algorithm ==
1240 NO_ENCRYPTION && 1529 NO_ENCRYPTION &&
1241 (key_type == WEP40_ENCRYPTION || 1530 (key_type == WEP40_ENCRYPTION ||
1242 key_type == WEP104_ENCRYPTION)) 1531 key_type == WEP104_ENCRYPTION))
1243 wep_only = true; 1532 wep_only = true;
1244 rtlpriv->sec.pairwise_enc_algorithm = key_type; 1533 rtlpriv->sec.pairwise_enc_algorithm = key_type;
@@ -1310,7 +1599,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1310 "disable key delete one entry\n"); 1599 "disable key delete one entry\n");
1311 /*set local buf about wep key. */ 1600 /*set local buf about wep key. */
1312 if (vif->type == NL80211_IFTYPE_AP || 1601 if (vif->type == NL80211_IFTYPE_AP ||
1313 vif->type == NL80211_IFTYPE_MESH_POINT) { 1602 vif->type == NL80211_IFTYPE_MESH_POINT) {
1314 if (sta) 1603 if (sta)
1315 rtl_cam_del_entry(hw, sta->addr); 1604 rtl_cam_del_entry(hw, sta->addr);
1316 } 1605 }
@@ -1323,13 +1612,10 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1323 *or clear all entry here. 1612 *or clear all entry here.
1324 */ 1613 */
1325 rtl_cam_delete_one_entry(hw, mac_addr, key_idx); 1614 rtl_cam_delete_one_entry(hw, mac_addr, key_idx);
1326
1327 rtl_cam_reset_sec_info(hw);
1328
1329 break; 1615 break;
1330 default: 1616 default:
1331 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1617 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1332 "cmd_err:%x!!!!\n", cmd); 1618 "cmd_err:%x!!!!:\n", cmd);
1333 } 1619 }
1334out_unlock: 1620out_unlock:
1335 mutex_unlock(&rtlpriv->locks.conf_mutex); 1621 mutex_unlock(&rtlpriv->locks.conf_mutex);
@@ -1359,7 +1645,7 @@ static void rtl_op_rfkill_poll(struct ieee80211_hw *hw)
1359 1645
1360 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 1646 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
1361 "wireless radio switch turned %s\n", 1647 "wireless radio switch turned %s\n",
1362 radio_state ? "on" : "off"); 1648 radio_state ? "on" : "off");
1363 1649
1364 blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1; 1650 blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1;
1365 wiphy_rfkill_set_hw_state(hw->wiphy, blocked); 1651 wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
@@ -1370,11 +1656,13 @@ static void rtl_op_rfkill_poll(struct ieee80211_hw *hw)
1370} 1656}
1371 1657
1372/* this function is called by mac80211 to flush tx buffer 1658/* this function is called by mac80211 to flush tx buffer
1373 * before switch channel or power save, or tx buffer packet 1659 * before switch channle or power save, or tx buffer packet
1374 * maybe send after offchannel or rf sleep, this may cause 1660 * maybe send after offchannel or rf sleep, this may cause
1375 * dis-association by AP */ 1661 * dis-association by AP */
1376static void rtl_op_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1662static void rtl_op_flush(struct ieee80211_hw *hw,
1377 u32 queues, bool drop) 1663 struct ieee80211_vif *vif,
1664 u32 queues,
1665 bool drop)
1378{ 1666{
1379 struct rtl_priv *rtlpriv = rtl_priv(hw); 1667 struct rtl_priv *rtlpriv = rtl_priv(hw);
1380 1668
@@ -1389,10 +1677,12 @@ const struct ieee80211_ops rtl_ops = {
1389 .add_interface = rtl_op_add_interface, 1677 .add_interface = rtl_op_add_interface,
1390 .remove_interface = rtl_op_remove_interface, 1678 .remove_interface = rtl_op_remove_interface,
1391 .change_interface = rtl_op_change_interface, 1679 .change_interface = rtl_op_change_interface,
1680#ifdef CONFIG_PM
1681 .suspend = rtl_op_suspend,
1682 .resume = rtl_op_resume,
1683#endif
1392 .config = rtl_op_config, 1684 .config = rtl_op_config,
1393 .configure_filter = rtl_op_configure_filter, 1685 .configure_filter = rtl_op_configure_filter,
1394 .sta_add = rtl_op_sta_add,
1395 .sta_remove = rtl_op_sta_remove,
1396 .set_key = rtl_op_set_key, 1686 .set_key = rtl_op_set_key,
1397 .conf_tx = rtl_op_conf_tx, 1687 .conf_tx = rtl_op_conf_tx,
1398 .bss_info_changed = rtl_op_bss_info_changed, 1688 .bss_info_changed = rtl_op_bss_info_changed,
@@ -1404,6 +1694,8 @@ const struct ieee80211_ops rtl_ops = {
1404 .sw_scan_start = rtl_op_sw_scan_start, 1694 .sw_scan_start = rtl_op_sw_scan_start,
1405 .sw_scan_complete = rtl_op_sw_scan_complete, 1695 .sw_scan_complete = rtl_op_sw_scan_complete,
1406 .rfkill_poll = rtl_op_rfkill_poll, 1696 .rfkill_poll = rtl_op_rfkill_poll,
1697 .sta_add = rtl_op_sta_add,
1698 .sta_remove = rtl_op_sta_remove,
1407 .flush = rtl_op_flush, 1699 .flush = rtl_op_flush,
1408}; 1700};
1409EXPORT_SYMBOL_GPL(rtl_ops); 1701EXPORT_SYMBOL_GPL(rtl_ops);