1 // SPDX-License-Identifier: GPL-2.0
2 /******************************************************************************
4 * Copyright(c) 2009-2012 Realtek Corporation.
7 * wlanfae <wlanfae@realtek.com>
8 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
11 * Larry Finger <Larry.Finger@lwfinger.net>
13 *****************************************************************************/
20 #include "pwrseqcmd.h"
22 #include "btcoexist/rtl_btc.h"
23 #include <linux/firmware.h>
24 #include <linux/export.h>
25 #include <net/cfg80211.h>
27 u8 channel5g[CHANNEL_MAX_NUMBER_5G] = {
28 36, 38, 40, 42, 44, 46, 48, /* Band 1 */
29 52, 54, 56, 58, 60, 62, 64, /* Band 2 */
30 100, 102, 104, 106, 108, 110, 112, /* Band 3 */
31 116, 118, 120, 122, 124, 126, 128, /* Band 3 */
32 132, 134, 136, 138, 140, 142, 144, /* Band 3 */
33 149, 151, 153, 155, 157, 159, 161, /* Band 4 */
34 165, 167, 169, 171, 173, 175, 177 /* Band 4 */
37 u8 channel5g_80m[CHANNEL_MAX_NUMBER_5G_80M] = {
38 42, 58, 106, 122, 138, 155, 171
41 static void rtl_fw_do_work(const struct firmware *firmware, void *context,
44 struct ieee80211_hw *hw = context;
45 struct rtl_priv *rtlpriv = rtl_priv(hw);
48 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
49 "Firmware callback routine entered!\n");
50 complete(&rtlpriv->firmware_loading_complete);
52 if (rtlpriv->cfg->alt_fw_name) {
53 err = reject_firmware(&firmware,
54 rtlpriv->cfg->alt_fw_name,
56 pr_info("Loading alternative firmware %s\n",
57 rtlpriv->cfg->alt_fw_name);
61 pr_err("Selected firmware is not available\n");
62 rtlpriv->max_fw_size = 0;
66 if (firmware->size > rtlpriv->max_fw_size) {
67 pr_err("Firmware is too big!\n");
68 release_firmware(firmware);
72 memcpy(rtlpriv->rtlhal.pfirmware, firmware->data,
74 rtlpriv->rtlhal.fwsize = firmware->size;
76 memcpy(rtlpriv->rtlhal.wowlan_firmware, firmware->data,
78 rtlpriv->rtlhal.wowlan_fwsize = firmware->size;
80 rtlpriv->rtlhal.fwsize = firmware->size;
81 release_firmware(firmware);
84 void rtl_fw_cb(const struct firmware *firmware, void *context)
86 rtl_fw_do_work(firmware, context, false);
89 void rtl_wowlan_fw_cb(const struct firmware *firmware, void *context)
91 rtl_fw_do_work(firmware, context, true);
94 /*mutex for start & stop is must here. */
95 static int rtl_op_start(struct ieee80211_hw *hw)
98 struct rtl_priv *rtlpriv = rtl_priv(hw);
99 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
101 if (!is_hal_stop(rtlhal))
103 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
105 mutex_lock(&rtlpriv->locks.conf_mutex);
106 err = rtlpriv->intf_ops->adapter_start(hw);
108 rtl_watch_dog_timer_callback(&rtlpriv->works.watchdog_timer);
109 mutex_unlock(&rtlpriv->locks.conf_mutex);
113 static void rtl_op_stop(struct ieee80211_hw *hw)
115 struct rtl_priv *rtlpriv = rtl_priv(hw);
116 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
117 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
118 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
119 bool support_remote_wakeup = false;
121 if (is_hal_stop(rtlhal))
124 rtlpriv->cfg->ops->get_hw_reg(hw, HAL_DEF_WOWLAN,
125 (u8 *)(&support_remote_wakeup));
126 /* here is must, because adhoc do stop and start,
127 * but stop with RFOFF may cause something wrong,
130 if (unlikely(ppsc->rfpwr_state == ERFOFF))
133 mutex_lock(&rtlpriv->locks.conf_mutex);
134 /* if wowlan supported, DON'T clear connected info */
135 if (!(support_remote_wakeup &&
136 rtlhal->enter_pnp_sleep)) {
137 mac->link_state = MAC80211_NOLINK;
138 eth_zero_addr(mac->bssid);
139 mac->vendor = PEER_UNKNOWN;
142 rtl_cam_reset_sec_info(hw);
144 rtl_deinit_deferred_work(hw);
146 rtlpriv->intf_ops->adapter_stop(hw);
148 mutex_unlock(&rtlpriv->locks.conf_mutex);
151 static void rtl_op_tx(struct ieee80211_hw *hw,
152 struct ieee80211_tx_control *control,
155 struct rtl_priv *rtlpriv = rtl_priv(hw);
156 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
157 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
158 struct rtl_tcb_desc tcb_desc;
160 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
162 if (unlikely(is_hal_stop(rtlhal) || ppsc->rfpwr_state != ERFON))
165 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
168 if (!rtlpriv->intf_ops->waitq_insert(hw, control->sta, skb))
169 rtlpriv->intf_ops->adapter_tx(hw, control->sta, skb, &tcb_desc);
173 dev_kfree_skb_any(skb);
176 static int rtl_op_add_interface(struct ieee80211_hw *hw,
177 struct ieee80211_vif *vif)
179 struct rtl_priv *rtlpriv = rtl_priv(hw);
180 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
182 u8 retry_limit = 0x30;
185 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
186 "vif has been set!! mac->vif = 0x%p\n", mac->vif);
190 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
194 mutex_lock(&rtlpriv->locks.conf_mutex);
195 switch (ieee80211_vif_type_p2p(vif)) {
196 case NL80211_IFTYPE_P2P_CLIENT:
197 mac->p2p = P2P_ROLE_CLIENT;
199 case NL80211_IFTYPE_STATION:
200 if (mac->beacon_enabled == 1) {
201 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
202 "NL80211_IFTYPE_STATION\n");
203 mac->beacon_enabled = 0;
204 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
205 rtlpriv->cfg->maps[RTL_IBSS_INT_MASKS]);
208 case NL80211_IFTYPE_ADHOC:
209 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
210 "NL80211_IFTYPE_ADHOC\n");
212 mac->link_state = MAC80211_LINKED;
213 rtlpriv->cfg->ops->set_bcn_reg(hw);
214 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
215 mac->basic_rates = 0xfff;
217 mac->basic_rates = 0xff0;
218 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
219 (u8 *)(&mac->basic_rates));
223 case NL80211_IFTYPE_P2P_GO:
224 mac->p2p = P2P_ROLE_GO;
226 case NL80211_IFTYPE_AP:
227 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
228 "NL80211_IFTYPE_AP\n");
230 mac->link_state = MAC80211_LINKED;
231 rtlpriv->cfg->ops->set_bcn_reg(hw);
232 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
233 mac->basic_rates = 0xfff;
235 mac->basic_rates = 0xff0;
236 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
237 (u8 *)(&mac->basic_rates));
241 case NL80211_IFTYPE_MESH_POINT:
242 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
243 "NL80211_IFTYPE_MESH_POINT\n");
245 mac->link_state = MAC80211_LINKED;
246 rtlpriv->cfg->ops->set_bcn_reg(hw);
247 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
248 mac->basic_rates = 0xfff;
250 mac->basic_rates = 0xff0;
251 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
252 (u8 *)(&mac->basic_rates));
257 pr_err("operation mode %d is not supported!\n",
264 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
265 "p2p role %x\n", vif->type);
266 mac->basic_rates = 0xff0;/*disable cck rate for p2p*/
267 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
268 (u8 *)(&mac->basic_rates));
271 mac->opmode = vif->type;
272 rtlpriv->cfg->ops->set_network_type(hw, vif->type);
273 memcpy(mac->mac_addr, vif->addr, ETH_ALEN);
274 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, mac->mac_addr);
276 mac->retry_long = retry_limit;
277 mac->retry_short = retry_limit;
278 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
279 (u8 *)(&retry_limit));
281 mutex_unlock(&rtlpriv->locks.conf_mutex);
285 static void rtl_op_remove_interface(struct ieee80211_hw *hw,
286 struct ieee80211_vif *vif)
288 struct rtl_priv *rtlpriv = rtl_priv(hw);
289 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
291 mutex_lock(&rtlpriv->locks.conf_mutex);
293 /* Free beacon resources */
294 if (vif->type == NL80211_IFTYPE_AP ||
295 vif->type == NL80211_IFTYPE_ADHOC ||
296 vif->type == NL80211_IFTYPE_MESH_POINT) {
297 if (mac->beacon_enabled == 1) {
298 mac->beacon_enabled = 0;
299 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
300 rtlpriv->cfg->maps[RTL_IBSS_INT_MASKS]);
305 *Note: We assume NL80211_IFTYPE_UNSPECIFIED as
306 *NO LINK for our hardware.
310 mac->link_state = MAC80211_NOLINK;
311 eth_zero_addr(mac->bssid);
312 mac->vendor = PEER_UNKNOWN;
313 mac->opmode = NL80211_IFTYPE_UNSPECIFIED;
314 rtlpriv->cfg->ops->set_network_type(hw, mac->opmode);
316 mutex_unlock(&rtlpriv->locks.conf_mutex);
319 static int rtl_op_change_interface(struct ieee80211_hw *hw,
320 struct ieee80211_vif *vif,
321 enum nl80211_iftype new_type, bool p2p)
323 struct rtl_priv *rtlpriv = rtl_priv(hw);
326 rtl_op_remove_interface(hw, vif);
328 vif->type = new_type;
330 ret = rtl_op_add_interface(hw, vif);
331 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
337 static u16 crc16_ccitt(u8 data, u16 crc)
339 u8 shift_in, data_bit, crc_bit11, crc_bit4, crc_bit15;
343 for (i = 0; i < 8; i++) {
344 crc_bit15 = ((crc & BIT(15)) ? 1 : 0);
345 data_bit = (data & (BIT(0) << i) ? 1 : 0);
346 shift_in = crc_bit15 ^ data_bit;
354 crc_bit11 = ((crc & BIT(11)) ? 1 : 0) ^ shift_in;
356 result &= (~BIT(12));
360 crc_bit4 = ((crc & BIT(4)) ? 1 : 0) ^ shift_in;
372 static u16 _calculate_wol_pattern_crc(u8 *pattern, u16 len)
377 for (i = 0; i < len; i++)
378 crc = crc16_ccitt(pattern[i], crc);
385 static void _rtl_add_wowlan_patterns(struct ieee80211_hw *hw,
386 struct cfg80211_wowlan *wow)
388 struct rtl_priv *rtlpriv = rtl_priv(hw);
389 struct rtl_mac *mac = &rtlpriv->mac80211;
390 struct cfg80211_pkt_pattern *patterns = wow->patterns;
391 struct rtl_wow_pattern rtl_pattern;
392 const u8 *pattern_os, *mask_os;
393 u8 mask[MAX_WOL_BIT_MASK_SIZE] = {0};
394 u8 content[MAX_WOL_PATTERN_SIZE] = {0};
395 u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
396 u8 multicast_addr1[2] = {0x33, 0x33};
397 u8 multicast_addr2[3] = {0x01, 0x00, 0x5e};
401 for (i = 0; i < wow->n_patterns; i++) {
402 memset(&rtl_pattern, 0, sizeof(struct rtl_wow_pattern));
403 memset(mask, 0, MAX_WOL_BIT_MASK_SIZE);
404 if (patterns[i].pattern_len < 0 ||
405 patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) {
406 RT_TRACE(rtlpriv, COMP_POWER, DBG_WARNING,
407 "Pattern[%d] is too long\n", i);
410 pattern_os = patterns[i].pattern;
411 mask_len = DIV_ROUND_UP(patterns[i].pattern_len, 8);
412 mask_os = patterns[i].mask;
413 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
414 "pattern content\n", pattern_os,
415 patterns[i].pattern_len);
416 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
417 "mask content\n", mask_os, mask_len);
418 /* 1. unicast? multicast? or broadcast? */
419 if (memcmp(pattern_os, broadcast_addr, 6) == 0)
420 rtl_pattern.type = BROADCAST_PATTERN;
421 else if (memcmp(pattern_os, multicast_addr1, 2) == 0 ||
422 memcmp(pattern_os, multicast_addr2, 3) == 0)
423 rtl_pattern.type = MULTICAST_PATTERN;
424 else if (memcmp(pattern_os, mac->mac_addr, 6) == 0)
425 rtl_pattern.type = UNICAST_PATTERN;
427 rtl_pattern.type = UNKNOWN_TYPE;
429 /* 2. translate mask_from_os to mask_for_hw */
431 /******************************************************************************
432 * pattern from OS uses 'ethenet frame', like this:
434 | 6 | 6 | 2 | 20 | Variable | 4 |
435 |--------+--------+------+-----------+------------+-----|
436 | 802.3 Mac Header | IP Header | TCP Packet | FCS |
439 * BUT, packet catched by our HW is in '802.11 frame', begin from LLC,
441 | 24 or 30 | 6 | 2 | 20 | Variable | 4 |
442 |-------------------+--------+------+-----------+------------+-----|
443 | 802.11 MAC Header | LLC | IP Header | TCP Packet | FCS |
446 * Therefore, we need translate mask_from_OS to mask_to_hw.
447 * We should left-shift mask by 6 bits, then set the new bit[0~5] = 0,
448 * because new mask[0~5] means 'SA', but our HW packet begins from LLC,
449 * bit[0~5] corresponds to first 6 Bytes in LLC, they just don't match.
450 ******************************************************************************/
453 for (j = 0; j < mask_len - 1; j++) {
454 mask[j] = mask_os[j] >> 6;
455 mask[j] |= (mask_os[j + 1] & 0x3F) << 2;
457 mask[j] = (mask_os[j] >> 6) & 0x3F;
458 /* Set bit 0-5 to zero */
461 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
462 "mask to hw\n", mask, mask_len);
463 for (j = 0; j < (MAX_WOL_BIT_MASK_SIZE + 1) / 4; j++) {
464 rtl_pattern.mask[j] = mask[j * 4];
465 rtl_pattern.mask[j] |= (mask[j * 4 + 1] << 8);
466 rtl_pattern.mask[j] |= (mask[j * 4 + 2] << 16);
467 rtl_pattern.mask[j] |= (mask[j * 4 + 3] << 24);
470 /* To get the wake up pattern from the mask.
471 * We do not count first 12 bits which means
472 * DA[6] and SA[6] in the pattern to match HW design.
475 for (j = 12; j < patterns[i].pattern_len; j++) {
476 if ((mask_os[j / 8] >> (j % 8)) & 0x01) {
477 content[len] = pattern_os[j];
482 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
483 "pattern to hw\n", content, len);
484 /* 3. calculate crc */
485 rtl_pattern.crc = _calculate_wol_pattern_crc(content, len);
486 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE,
487 "CRC_Remainder = 0x%x\n", rtl_pattern.crc);
489 /* 4. write crc & mask_for_hw to hw */
490 rtlpriv->cfg->ops->add_wowlan_pattern(hw, &rtl_pattern, i);
492 rtl_write_byte(rtlpriv, 0x698, wow->n_patterns);
495 static int rtl_op_suspend(struct ieee80211_hw *hw,
496 struct cfg80211_wowlan *wow)
498 struct rtl_priv *rtlpriv = rtl_priv(hw);
499 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
500 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
502 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n");
506 /* to resolve s4 can not wake up*/
507 rtlhal->last_suspend_sec = ktime_get_real_seconds();
509 if ((ppsc->wo_wlan_mode & WAKE_ON_PATTERN_MATCH) && wow->n_patterns)
510 _rtl_add_wowlan_patterns(hw, wow);
512 rtlhal->driver_is_goingto_unload = true;
513 rtlhal->enter_pnp_sleep = true;
517 device_set_wakeup_enable(wiphy_dev(hw->wiphy), true);
521 static int rtl_op_resume(struct ieee80211_hw *hw)
523 struct rtl_priv *rtlpriv = rtl_priv(hw);
524 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
525 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
527 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n");
528 rtlhal->driver_is_goingto_unload = false;
529 rtlhal->enter_pnp_sleep = false;
530 rtlhal->wake_from_pnp_sleep = true;
532 /* to resovle s4 can not wake up*/
533 if (ktime_get_real_seconds() - rtlhal->last_suspend_sec < 5)
537 device_set_wakeup_enable(wiphy_dev(hw->wiphy), false);
538 ieee80211_resume_disconnect(mac->vif);
539 rtlhal->wake_from_pnp_sleep = false;
544 static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
546 struct rtl_priv *rtlpriv = rtl_priv(hw);
547 struct rtl_phy *rtlphy = &rtlpriv->phy;
548 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
549 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
550 struct ieee80211_conf *conf = &hw->conf;
555 mutex_lock(&rtlpriv->locks.conf_mutex);
556 if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { /* BIT(2)*/
557 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
558 "IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n");
562 if (changed & IEEE80211_CONF_CHANGE_IDLE) {
563 if (hw->conf.flags & IEEE80211_CONF_IDLE)
569 *although rfoff may not cause by ips, but we will
570 *check the reason in set_rf_power_state function
572 if (unlikely(ppsc->rfpwr_state == ERFOFF))
577 if ((changed & IEEE80211_CONF_CHANGE_PS) &&
578 rtlpriv->psc.swctrl_lps && !rtlpriv->psc.fwctrl_lps) {
579 cancel_delayed_work(&rtlpriv->works.ps_work);
580 cancel_delayed_work(&rtlpriv->works.ps_rfon_wq);
581 if (conf->flags & IEEE80211_CONF_PS) {
582 rtlpriv->psc.sw_ps_enabled = true;
583 /* sleep here is must, or we may recv the beacon and
584 * cause mac80211 into wrong ps state, this will cause
585 * power save nullfunc send fail, and further cause
586 * pkt loss, So sleep must quickly but not immediately
587 * because that will cause nullfunc send by mac80211
588 * fail, and cause pkt loss, we have tested that 5mA
591 if (!rtlpriv->psc.multi_buffered)
592 queue_delayed_work(rtlpriv->works.rtl_wq,
593 &rtlpriv->works.ps_work,
596 rtl_swlps_rf_awake(hw);
597 rtlpriv->psc.sw_ps_enabled = false;
601 if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) {
602 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
603 "IEEE80211_CONF_CHANGE_RETRY_LIMITS %x\n",
604 hw->conf.long_frame_max_tx_count);
605 /* brought up everything changes (changed == ~0) indicates first
606 * open, so use our default value instead of that of wiphy.
609 mac->retry_long = hw->conf.long_frame_max_tx_count;
610 mac->retry_short = hw->conf.long_frame_max_tx_count;
611 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
612 (u8 *)(&hw->conf.long_frame_max_tx_count));
616 if (changed & IEEE80211_CONF_CHANGE_CHANNEL &&
617 !rtlpriv->proximity.proxim_on) {
618 struct ieee80211_channel *channel = hw->conf.chandef.chan;
619 enum nl80211_chan_width width = hw->conf.chandef.width;
620 enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT;
621 u8 wide_chan = (u8)channel->hw_value;
623 /* channel_type is for 20&40M */
624 if (width < NL80211_CHAN_WIDTH_80)
626 cfg80211_get_chandef_type(&hw->conf.chandef);
627 if (mac->act_scanning)
630 if (rtlpriv->dm.supp_phymode_switch &&
631 mac->link_state < MAC80211_LINKED &&
632 !mac->act_scanning) {
633 if (rtlpriv->cfg->ops->chk_switch_dmdp)
634 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
638 *because we should back channel to
639 *current_network.chan in in scanning,
640 *So if set_chan == current_network.chan
642 *because mac80211 tell us wrong bw40
643 *info for cisco1253 bw20, so we modify
644 *it here based on UPPER & LOWER
647 if (width >= NL80211_CHAN_WIDTH_80) {
648 if (width == NL80211_CHAN_WIDTH_80) {
649 u32 center = hw->conf.chandef.center_freq1;
651 (u32)hw->conf.chandef.chan->center_freq;
653 rtlphy->current_chan_bw =
657 if (center > primary) {
658 mac->cur_80_prime_sc =
659 PRIME_CHNL_OFFSET_LOWER;
660 if (center - primary == 10) {
661 mac->cur_40_prime_sc =
662 PRIME_CHNL_OFFSET_UPPER;
665 } else if (center - primary == 30) {
666 mac->cur_40_prime_sc =
667 PRIME_CHNL_OFFSET_LOWER;
672 mac->cur_80_prime_sc =
673 PRIME_CHNL_OFFSET_UPPER;
674 if (primary - center == 10) {
675 mac->cur_40_prime_sc =
676 PRIME_CHNL_OFFSET_LOWER;
679 } else if (primary - center == 30) {
680 mac->cur_40_prime_sc =
681 PRIME_CHNL_OFFSET_UPPER;
688 switch (channel_type) {
689 case NL80211_CHAN_HT20:
690 case NL80211_CHAN_NO_HT:
692 mac->cur_40_prime_sc =
693 PRIME_CHNL_OFFSET_DONT_CARE;
694 rtlphy->current_chan_bw =
699 case NL80211_CHAN_HT40MINUS:
701 mac->cur_40_prime_sc =
702 PRIME_CHNL_OFFSET_UPPER;
703 rtlphy->current_chan_bw =
704 HT_CHANNEL_WIDTH_20_40;
712 case NL80211_CHAN_HT40PLUS:
714 mac->cur_40_prime_sc =
715 PRIME_CHNL_OFFSET_LOWER;
716 rtlphy->current_chan_bw =
717 HT_CHANNEL_WIDTH_20_40;
728 pr_err("switch case %#x not processed\n",
737 /* In scanning, when before we offchannel we may send a ps=1
738 * null to AP, and then we may send a ps = 0 null to AP quickly,
739 * but first null may have caused AP to put lots of packet to
740 * hw tx buffer. These packets must be tx'd before we go off
741 * channel so we must delay more time to let AP flush these
742 * packets before going offchannel, or dis-association or
743 * delete BA will be caused by AP
745 if (rtlpriv->mac80211.offchan_delay) {
746 rtlpriv->mac80211.offchan_delay = false;
750 rtlphy->current_channel = wide_chan;
752 rtlpriv->cfg->ops->switch_channel(hw);
753 rtlpriv->cfg->ops->set_channel_access(hw);
754 rtlpriv->cfg->ops->set_bw_mode(hw, channel_type);
757 mutex_unlock(&rtlpriv->locks.conf_mutex);
762 static void rtl_op_configure_filter(struct ieee80211_hw *hw,
763 unsigned int changed_flags,
764 unsigned int *new_flags, u64 multicast)
766 bool update_rcr = false;
767 struct rtl_priv *rtlpriv = rtl_priv(hw);
768 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
770 *new_flags &= RTL_SUPPORTED_FILTERS;
771 if (changed_flags == 0)
774 /*TODO: we disable broadcase now, so enable here */
775 if (changed_flags & FIF_ALLMULTI) {
776 if (*new_flags & FIF_ALLMULTI) {
777 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AM] |
778 rtlpriv->cfg->maps[MAC_RCR_AB];
779 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
780 "Enable receive multicast frame\n");
782 mac->rx_conf &= ~(rtlpriv->cfg->maps[MAC_RCR_AM] |
783 rtlpriv->cfg->maps[MAC_RCR_AB]);
784 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
785 "Disable receive multicast frame\n");
790 if (changed_flags & FIF_FCSFAIL) {
791 if (*new_flags & FIF_FCSFAIL) {
792 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACRC32];
793 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
794 "Enable receive FCS error frame\n");
796 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACRC32];
797 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
798 "Disable receive FCS error frame\n");
804 /* if ssid not set to hw don't check bssid
805 * here just used for linked scanning, & linked
806 * and nolink check bssid is set in set network_type
808 if (changed_flags & FIF_BCN_PRBRESP_PROMISC &&
809 mac->link_state >= MAC80211_LINKED) {
810 if (mac->opmode != NL80211_IFTYPE_AP &&
811 mac->opmode != NL80211_IFTYPE_MESH_POINT) {
812 if (*new_flags & FIF_BCN_PRBRESP_PROMISC)
813 rtlpriv->cfg->ops->set_chk_bssid(hw, false);
815 rtlpriv->cfg->ops->set_chk_bssid(hw, true);
821 if (changed_flags & FIF_CONTROL) {
822 if (*new_flags & FIF_CONTROL) {
823 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACF];
825 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
826 "Enable receive control frame.\n");
828 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACF];
829 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
830 "Disable receive control frame.\n");
836 if (changed_flags & FIF_OTHER_BSS) {
837 if (*new_flags & FIF_OTHER_BSS) {
838 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AAP];
839 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
840 "Enable receive other BSS's frame.\n");
842 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_AAP];
843 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
844 "Disable receive other BSS's frame.\n");
851 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR,
852 (u8 *)(&mac->rx_conf));
855 static int rtl_op_sta_add(struct ieee80211_hw *hw,
856 struct ieee80211_vif *vif,
857 struct ieee80211_sta *sta)
859 struct rtl_priv *rtlpriv = rtl_priv(hw);
860 struct rtl_phy *rtlphy = &rtlpriv->phy;
861 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
862 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
863 struct rtl_sta_info *sta_entry;
866 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
867 spin_lock_bh(&rtlpriv->locks.entry_list_lock);
868 list_add_tail(&sta_entry->list, &rtlpriv->entry_list);
869 spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
870 if (rtlhal->current_bandtype == BAND_ON_2_4G) {
871 sta_entry->wireless_mode = WIRELESS_MODE_G;
872 if (sta->supp_rates[0] <= 0xf)
873 sta_entry->wireless_mode = WIRELESS_MODE_B;
874 if (sta->ht_cap.ht_supported)
875 sta_entry->wireless_mode = WIRELESS_MODE_N_24G;
877 if (vif->type == NL80211_IFTYPE_ADHOC)
878 sta_entry->wireless_mode = WIRELESS_MODE_G;
879 } else if (rtlhal->current_bandtype == BAND_ON_5G) {
880 sta_entry->wireless_mode = WIRELESS_MODE_A;
881 if (sta->ht_cap.ht_supported)
882 sta_entry->wireless_mode = WIRELESS_MODE_N_5G;
883 if (sta->vht_cap.vht_supported)
884 sta_entry->wireless_mode = WIRELESS_MODE_AC_5G;
886 if (vif->type == NL80211_IFTYPE_ADHOC)
887 sta_entry->wireless_mode = WIRELESS_MODE_A;
889 /*disable cck rate for p2p*/
891 sta->supp_rates[0] &= 0xfffffff0;
893 if (sta->ht_cap.ht_supported) {
894 if (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)
895 rtlphy->max_ht_chan_bw = HT_CHANNEL_WIDTH_20_40;
897 rtlphy->max_ht_chan_bw = HT_CHANNEL_WIDTH_20;
900 if (sta->vht_cap.vht_supported)
901 rtlphy->max_vht_chan_bw = HT_CHANNEL_WIDTH_80;
903 memcpy(sta_entry->mac_addr, sta->addr, ETH_ALEN);
904 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
905 "Add sta addr is %pM\n", sta->addr);
906 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0, true);
908 if (rtlpriv->phydm.ops)
909 rtlpriv->phydm.ops->phydm_add_sta(rtlpriv, sta);
915 static int rtl_op_sta_remove(struct ieee80211_hw *hw,
916 struct ieee80211_vif *vif,
917 struct ieee80211_sta *sta)
919 struct rtl_priv *rtlpriv = rtl_priv(hw);
920 struct rtl_sta_info *sta_entry;
923 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
924 "Remove sta addr is %pM\n", sta->addr);
926 if (rtlpriv->phydm.ops)
927 rtlpriv->phydm.ops->phydm_del_sta(rtlpriv, sta);
929 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
930 sta_entry->wireless_mode = 0;
931 sta_entry->ratr_index = 0;
932 spin_lock_bh(&rtlpriv->locks.entry_list_lock);
933 list_del(&sta_entry->list);
934 spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
939 static int _rtl_get_hal_qnum(u16 queue)
963 static void rtl_op_sta_statistics(struct ieee80211_hw *hw,
964 struct ieee80211_vif *vif,
965 struct ieee80211_sta *sta,
966 struct station_info *sinfo)
968 /* nothing filled by driver, so mac80211 will update all info */
972 static int rtl_op_set_frag_threshold(struct ieee80211_hw *hw, u32 value)
978 *for mac80211 VO = 0, VI = 1, BE = 2, BK = 3
979 *for rtl819x BE = 0, BK = 1, VI = 2, VO = 3
981 static int rtl_op_conf_tx(struct ieee80211_hw *hw,
982 struct ieee80211_vif *vif, u16 queue,
983 const struct ieee80211_tx_queue_params *param)
985 struct rtl_priv *rtlpriv = rtl_priv(hw);
986 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
989 if (queue >= AC_MAX) {
990 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
991 "queue number %d is incorrect!\n", queue);
995 aci = _rtl_get_hal_qnum(queue);
996 mac->ac[aci].aifs = param->aifs;
997 mac->ac[aci].cw_min = cpu_to_le16(param->cw_min);
998 mac->ac[aci].cw_max = cpu_to_le16(param->cw_max);
999 mac->ac[aci].tx_op = cpu_to_le16(param->txop);
1000 memcpy(&mac->edca_param[aci], param, sizeof(*param));
1001 rtlpriv->cfg->ops->set_qos(hw, aci);
1005 static void send_beacon_frame(struct ieee80211_hw *hw,
1006 struct ieee80211_vif *vif)
1008 struct rtl_priv *rtlpriv = rtl_priv(hw);
1009 struct sk_buff *skb = ieee80211_beacon_get(hw, vif);
1010 struct rtl_tcb_desc tcb_desc;
1013 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
1014 rtlpriv->intf_ops->adapter_tx(hw, NULL, skb, &tcb_desc);
1018 static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
1019 struct ieee80211_vif *vif,
1020 struct ieee80211_bss_conf *bss_conf,
1023 struct rtl_priv *rtlpriv = rtl_priv(hw);
1024 struct rtl_phy *rtlphy = &rtlpriv->phy;
1025 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
1026 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1027 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
1029 mutex_lock(&rtlpriv->locks.conf_mutex);
1030 if (vif->type == NL80211_IFTYPE_ADHOC ||
1031 vif->type == NL80211_IFTYPE_AP ||
1032 vif->type == NL80211_IFTYPE_MESH_POINT) {
1033 if (changed & BSS_CHANGED_BEACON ||
1034 (changed & BSS_CHANGED_BEACON_ENABLED &&
1035 bss_conf->enable_beacon)) {
1036 if (mac->beacon_enabled == 0) {
1037 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1038 "BSS_CHANGED_BEACON_ENABLED\n");
1040 /*start hw beacon interrupt. */
1041 /*rtlpriv->cfg->ops->set_bcn_reg(hw); */
1042 mac->beacon_enabled = 1;
1043 rtlpriv->cfg->ops->update_interrupt_mask(hw,
1045 [RTL_IBSS_INT_MASKS], 0);
1047 if (rtlpriv->cfg->ops->linked_set_reg)
1048 rtlpriv->cfg->ops->linked_set_reg(hw);
1049 send_beacon_frame(hw, vif);
1052 if ((changed & BSS_CHANGED_BEACON_ENABLED &&
1053 !bss_conf->enable_beacon)) {
1054 if (mac->beacon_enabled == 1) {
1055 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1056 "ADHOC DISABLE BEACON\n");
1058 mac->beacon_enabled = 0;
1059 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
1061 [RTL_IBSS_INT_MASKS]);
1064 if (changed & BSS_CHANGED_BEACON_INT) {
1065 RT_TRACE(rtlpriv, COMP_BEACON, DBG_TRACE,
1066 "BSS_CHANGED_BEACON_INT\n");
1067 mac->beacon_interval = bss_conf->beacon_int;
1068 rtlpriv->cfg->ops->set_bcn_intv(hw);
1072 /*TODO: reference to enum ieee80211_bss_change */
1073 if (changed & BSS_CHANGED_ASSOC) {
1076 if (bss_conf->assoc) {
1077 struct ieee80211_sta *sta = NULL;
1080 mstatus = RT_MEDIA_CONNECT;
1081 /* we should reset all sec info & cam
1082 * before set cam after linked, we should not
1083 * reset in disassoc, that will cause tkip->wep
1084 * fail because some flag will be wrong
1087 rtl_cam_reset_sec_info(hw);
1088 /* reset cam to fix wep fail issue
1089 * when change from wpa to wep
1091 rtl_cam_reset_all_entry(hw);
1093 mac->link_state = MAC80211_LINKED;
1094 mac->cnt_after_linked = 0;
1095 mac->assoc_id = bss_conf->aid;
1096 memcpy(mac->bssid, bss_conf->bssid, ETH_ALEN);
1098 if (rtlpriv->cfg->ops->linked_set_reg)
1099 rtlpriv->cfg->ops->linked_set_reg(hw);
1102 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
1107 RT_TRACE(rtlpriv, COMP_EASY_CONCURRENT, DBG_LOUD,
1108 "send PS STATIC frame\n");
1109 if (rtlpriv->dm.supp_phymode_switch) {
1110 if (sta->ht_cap.ht_supported)
1111 rtl_send_smps_action(hw, sta,
1112 IEEE80211_SMPS_STATIC);
1115 if (rtlhal->current_bandtype == BAND_ON_5G) {
1116 mac->mode = WIRELESS_MODE_A;
1118 if (sta->supp_rates[0] <= 0xf)
1119 mac->mode = WIRELESS_MODE_B;
1121 mac->mode = WIRELESS_MODE_G;
1124 if (sta->ht_cap.ht_supported) {
1125 if (rtlhal->current_bandtype == BAND_ON_2_4G)
1126 mac->mode = WIRELESS_MODE_N_24G;
1128 mac->mode = WIRELESS_MODE_N_5G;
1131 if (sta->vht_cap.vht_supported) {
1132 if (rtlhal->current_bandtype == BAND_ON_5G)
1133 mac->mode = WIRELESS_MODE_AC_5G;
1135 mac->mode = WIRELESS_MODE_AC_24G;
1138 if (vif->type == NL80211_IFTYPE_STATION)
1139 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0,
1143 /* to avoid AP Disassociation caused by inactivity */
1144 rtlpriv->cfg->ops->set_hw_reg(hw,
1146 (u8 *)(&keep_alive));
1148 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1149 "BSS_CHANGED_ASSOC\n");
1151 struct cfg80211_bss *bss = NULL;
1153 mstatus = RT_MEDIA_DISCONNECT;
1155 if (mac->link_state == MAC80211_LINKED)
1157 if (ppsc->p2p_ps_info.p2p_ps_mode > P2P_PS_NONE)
1158 rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE);
1159 mac->link_state = MAC80211_NOLINK;
1161 bss = cfg80211_get_bss(hw->wiphy, NULL,
1162 (u8 *)mac->bssid, NULL, 0,
1163 IEEE80211_BSS_TYPE_ESS,
1164 IEEE80211_PRIVACY_OFF);
1166 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1167 "bssid = %x-%x-%x-%x-%x-%x\n",
1168 mac->bssid[0], mac->bssid[1],
1169 mac->bssid[2], mac->bssid[3],
1170 mac->bssid[4], mac->bssid[5]);
1173 cfg80211_unlink_bss(hw->wiphy, bss);
1174 cfg80211_put_bss(hw->wiphy, bss);
1175 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1176 "cfg80211_unlink !!\n");
1179 eth_zero_addr(mac->bssid);
1180 mac->vendor = PEER_UNKNOWN;
1183 if (rtlpriv->dm.supp_phymode_switch) {
1184 if (rtlpriv->cfg->ops->chk_switch_dmdp)
1185 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
1187 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1188 "BSS_CHANGED_UN_ASSOC\n");
1190 rtlpriv->cfg->ops->set_network_type(hw, vif->type);
1192 * To tell firmware we have connected or disconnected
1194 rtlpriv->cfg->ops->set_hw_reg(hw,
1195 HW_VAR_H2C_FW_JOINBSSRPT,
1197 ppsc->report_linked = (mstatus == RT_MEDIA_CONNECT) ?
1200 if (rtlpriv->cfg->ops->get_btc_status())
1201 rtlpriv->btcoexist.btc_ops->btc_mediastatus_notify(
1205 if (changed & BSS_CHANGED_ERP_CTS_PROT) {
1206 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1207 "BSS_CHANGED_ERP_CTS_PROT\n");
1208 mac->use_cts_protect = bss_conf->use_cts_prot;
1211 if (changed & BSS_CHANGED_ERP_PREAMBLE) {
1212 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
1213 "BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n",
1214 bss_conf->use_short_preamble);
1216 mac->short_preamble = bss_conf->use_short_preamble;
1217 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACK_PREAMBLE,
1218 (u8 *)(&mac->short_preamble));
1221 if (changed & BSS_CHANGED_ERP_SLOT) {
1222 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1223 "BSS_CHANGED_ERP_SLOT\n");
1225 if (bss_conf->use_short_slot)
1226 mac->slot_time = RTL_SLOT_TIME_9;
1228 mac->slot_time = RTL_SLOT_TIME_20;
1230 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME,
1231 (u8 *)(&mac->slot_time));
1234 if (changed & BSS_CHANGED_HT) {
1235 struct ieee80211_sta *sta = NULL;
1237 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1238 "BSS_CHANGED_HT\n");
1241 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
1243 if (sta->ht_cap.ampdu_density >
1244 mac->current_ampdu_density)
1245 mac->current_ampdu_density =
1246 sta->ht_cap.ampdu_density;
1247 if (sta->ht_cap.ampdu_factor <
1248 mac->current_ampdu_factor)
1249 mac->current_ampdu_factor =
1250 sta->ht_cap.ampdu_factor;
1252 if (sta->ht_cap.ht_supported) {
1253 if (sta->ht_cap.cap &
1254 IEEE80211_HT_CAP_SUP_WIDTH_20_40)
1255 rtlphy->max_ht_chan_bw =
1256 HT_CHANNEL_WIDTH_20_40;
1258 rtlphy->max_ht_chan_bw =
1259 HT_CHANNEL_WIDTH_20;
1264 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SHORTGI_DENSITY,
1265 (u8 *)(&mac->max_mss_density));
1266 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_FACTOR,
1267 &mac->current_ampdu_factor);
1268 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_MIN_SPACE,
1269 &mac->current_ampdu_density);
1272 if (changed & BSS_CHANGED_BANDWIDTH) {
1273 struct ieee80211_sta *sta = NULL;
1275 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1276 "BSS_CHANGED_BANDWIDTH\n");
1279 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
1282 if (sta->ht_cap.ht_supported) {
1283 if (sta->ht_cap.cap &
1284 IEEE80211_HT_CAP_SUP_WIDTH_20_40)
1285 rtlphy->max_ht_chan_bw =
1286 HT_CHANNEL_WIDTH_20_40;
1288 rtlphy->max_ht_chan_bw =
1289 HT_CHANNEL_WIDTH_20;
1292 if (sta->vht_cap.vht_supported)
1293 rtlphy->max_vht_chan_bw = HT_CHANNEL_WIDTH_80;
1298 if (changed & BSS_CHANGED_BSSID) {
1300 struct ieee80211_sta *sta = NULL;
1302 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BSSID,
1303 (u8 *)bss_conf->bssid);
1305 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1306 "bssid: %pM\n", bss_conf->bssid);
1308 mac->vendor = PEER_UNKNOWN;
1309 memcpy(mac->bssid, bss_conf->bssid, ETH_ALEN);
1312 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
1318 if (rtlhal->current_bandtype == BAND_ON_5G) {
1319 mac->mode = WIRELESS_MODE_A;
1321 if (sta->supp_rates[0] <= 0xf)
1322 mac->mode = WIRELESS_MODE_B;
1324 mac->mode = WIRELESS_MODE_G;
1327 if (sta->ht_cap.ht_supported) {
1328 if (rtlhal->current_bandtype == BAND_ON_2_4G)
1329 mac->mode = WIRELESS_MODE_N_24G;
1331 mac->mode = WIRELESS_MODE_N_5G;
1334 if (sta->vht_cap.vht_supported) {
1335 if (rtlhal->current_bandtype == BAND_ON_5G)
1336 mac->mode = WIRELESS_MODE_AC_5G;
1338 mac->mode = WIRELESS_MODE_AC_24G;
1341 /* just station need it, because ibss & ap mode will
1342 * set in sta_add, and will be NULL here
1344 if (vif->type == NL80211_IFTYPE_STATION) {
1345 struct rtl_sta_info *sta_entry;
1347 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
1348 sta_entry->wireless_mode = mac->mode;
1351 if (sta->ht_cap.ht_supported) {
1352 mac->ht_enable = true;
1354 /* for cisco 1252 bw20 it's wrong
1355 * if (ht_cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
1356 * mac->bw_40 = true;
1361 if (sta->vht_cap.vht_supported)
1362 mac->vht_enable = true;
1364 if (changed & BSS_CHANGED_BASIC_RATES) {
1365 /* for 5G must << RATE_6M_INDEX = 4,
1366 * because 5G have no cck rate
1368 if (rtlhal->current_bandtype == BAND_ON_5G)
1369 basic_rates = sta->supp_rates[1] << 4;
1371 basic_rates = sta->supp_rates[0];
1373 mac->basic_rates = basic_rates;
1374 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
1375 (u8 *)(&basic_rates));
1380 mutex_unlock(&rtlpriv->locks.conf_mutex);
1383 static u64 rtl_op_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1385 struct rtl_priv *rtlpriv = rtl_priv(hw);
1388 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *)(&tsf));
1392 static void rtl_op_set_tsf(struct ieee80211_hw *hw,
1393 struct ieee80211_vif *vif, u64 tsf)
1395 struct rtl_priv *rtlpriv = rtl_priv(hw);
1396 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1397 u8 bibss = (mac->opmode == NL80211_IFTYPE_ADHOC) ? 1 : 0;
1400 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *)(&bibss));
1403 static void rtl_op_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1405 struct rtl_priv *rtlpriv = rtl_priv(hw);
1408 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_DUAL_TSF_RST, (u8 *)(&tmp));
1411 static void rtl_op_sta_notify(struct ieee80211_hw *hw,
1412 struct ieee80211_vif *vif,
1413 enum sta_notify_cmd cmd,
1414 struct ieee80211_sta *sta)
1417 case STA_NOTIFY_SLEEP:
1419 case STA_NOTIFY_AWAKE:
1426 static int rtl_op_ampdu_action(struct ieee80211_hw *hw,
1427 struct ieee80211_vif *vif,
1428 struct ieee80211_ampdu_params *params)
1430 struct rtl_priv *rtlpriv = rtl_priv(hw);
1431 struct ieee80211_sta *sta = params->sta;
1432 enum ieee80211_ampdu_mlme_action action = params->action;
1433 u16 tid = params->tid;
1434 u16 *ssn = ¶ms->ssn;
1437 case IEEE80211_AMPDU_TX_START:
1438 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1439 "IEEE80211_AMPDU_TX_START: TID:%d\n", tid);
1440 return rtl_tx_agg_start(hw, vif, sta, tid, ssn);
1441 case IEEE80211_AMPDU_TX_STOP_CONT:
1442 case IEEE80211_AMPDU_TX_STOP_FLUSH:
1443 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
1444 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1445 "IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid);
1446 return rtl_tx_agg_stop(hw, vif, sta, tid);
1447 case IEEE80211_AMPDU_TX_OPERATIONAL:
1448 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1449 "IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid);
1450 rtl_tx_agg_oper(hw, sta, tid);
1452 case IEEE80211_AMPDU_RX_START:
1453 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1454 "IEEE80211_AMPDU_RX_START:TID:%d\n", tid);
1455 return rtl_rx_agg_start(hw, sta, tid);
1456 case IEEE80211_AMPDU_RX_STOP:
1457 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1458 "IEEE80211_AMPDU_RX_STOP:TID:%d\n", tid);
1459 return rtl_rx_agg_stop(hw, sta, tid);
1461 pr_err("IEEE80211_AMPDU_ERR!!!!:\n");
1467 static void rtl_op_sw_scan_start(struct ieee80211_hw *hw,
1468 struct ieee80211_vif *vif,
1471 struct rtl_priv *rtlpriv = rtl_priv(hw);
1472 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1474 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
1475 mac->act_scanning = true;
1476 if (rtlpriv->link_info.higher_busytraffic) {
1477 mac->skip_scan = true;
1481 if (rtlpriv->phydm.ops)
1482 rtlpriv->phydm.ops->phydm_pause_dig(rtlpriv, 1);
1484 if (rtlpriv->cfg->ops->get_btc_status())
1485 rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 1);
1486 else if (rtlpriv->btcoexist.btc_ops)
1487 rtlpriv->btcoexist.btc_ops->btc_scan_notify_wifi_only(rtlpriv,
1490 if (rtlpriv->dm.supp_phymode_switch) {
1491 if (rtlpriv->cfg->ops->chk_switch_dmdp)
1492 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
1495 if (mac->link_state == MAC80211_LINKED) {
1497 mac->link_state = MAC80211_LINKED_SCANNING;
1503 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false;
1505 rtlpriv->cfg->ops->led_control(hw, LED_CTL_SITE_SURVEY);
1506 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_BACKUP_BAND0);
1509 static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw,
1510 struct ieee80211_vif *vif)
1512 struct rtl_priv *rtlpriv = rtl_priv(hw);
1513 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1515 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
1516 mac->act_scanning = false;
1517 mac->skip_scan = false;
1519 rtlpriv->btcoexist.btc_info.ap_num = rtlpriv->scan_list.num;
1521 if (rtlpriv->link_info.higher_busytraffic)
1524 /* p2p will use 1/6/11 to scan */
1525 if (mac->n_channels == 3)
1526 mac->p2p_in_use = true;
1528 mac->p2p_in_use = false;
1529 mac->n_channels = 0;
1531 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false;
1533 if (mac->link_state == MAC80211_LINKED_SCANNING) {
1534 mac->link_state = MAC80211_LINKED;
1535 if (mac->opmode == NL80211_IFTYPE_STATION) {
1536 /* fix fwlps issue */
1537 rtlpriv->cfg->ops->set_network_type(hw, mac->opmode);
1541 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_RESTORE);
1542 if (rtlpriv->cfg->ops->get_btc_status())
1543 rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 0);
1544 else if (rtlpriv->btcoexist.btc_ops)
1545 rtlpriv->btcoexist.btc_ops->btc_scan_notify_wifi_only(rtlpriv,
1548 if (rtlpriv->phydm.ops)
1549 rtlpriv->phydm.ops->phydm_pause_dig(rtlpriv, 0);
1552 static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1553 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
1554 struct ieee80211_key_conf *key)
1556 struct rtl_priv *rtlpriv = rtl_priv(hw);
1557 u8 key_type = NO_ENCRYPTION;
1559 bool group_key = false;
1560 bool wep_only = false;
1562 u8 mac_addr[ETH_ALEN];
1563 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1565 rtlpriv->btcoexist.btc_info.in_4way = false;
1567 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) {
1568 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1569 "not open hw encryption\n");
1570 return -ENOSPC; /*User disabled HW-crypto */
1572 /* To support IBSS, use sw-crypto for GTK */
1573 if ((vif->type == NL80211_IFTYPE_ADHOC ||
1574 vif->type == NL80211_IFTYPE_MESH_POINT) &&
1575 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
1577 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1578 "%s hardware based encryption for keyidx: %d, mac: %pM\n",
1579 cmd == SET_KEY ? "Using" : "Disabling", key->keyidx,
1580 sta ? sta->addr : bcast_addr);
1581 rtlpriv->sec.being_setkey = true;
1583 mutex_lock(&rtlpriv->locks.conf_mutex);
1584 /* <1> get encryption alg */
1586 switch (key->cipher) {
1587 case WLAN_CIPHER_SUITE_WEP40:
1588 key_type = WEP40_ENCRYPTION;
1589 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:WEP40\n");
1591 case WLAN_CIPHER_SUITE_WEP104:
1592 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:WEP104\n");
1593 key_type = WEP104_ENCRYPTION;
1595 case WLAN_CIPHER_SUITE_TKIP:
1596 key_type = TKIP_ENCRYPTION;
1597 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:TKIP\n");
1599 case WLAN_CIPHER_SUITE_CCMP:
1600 key_type = AESCCMP_ENCRYPTION;
1601 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CCMP\n");
1603 case WLAN_CIPHER_SUITE_AES_CMAC:
1604 /* HW don't support CMAC encryption,
1605 * use software CMAC encryption
1607 key_type = AESCMAC_ENCRYPTION;
1608 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CMAC\n");
1609 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1610 "HW don't support CMAC encryption, use software CMAC encryption\n");
1614 pr_err("alg_err:%x!!!!:\n", key->cipher);
1617 if (key_type == WEP40_ENCRYPTION ||
1618 key_type == WEP104_ENCRYPTION ||
1619 vif->type == NL80211_IFTYPE_ADHOC)
1620 rtlpriv->sec.use_defaultkey = true;
1622 /* <2> get key_idx */
1623 key_idx = (u8)(key->keyidx);
1626 /* <3> if pairwise key enable_hw_sec */
1627 group_key = !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE);
1629 /* wep always be group key, but there are two conditions:
1630 * 1) wep only: is just for wep enc, in this condition
1631 * rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION
1632 * will be true & enable_hw_sec will be set when wep
1634 * 2) wep(group) + AES(pairwise): some AP like cisco
1635 * may use it, in this condition enable_hw_sec will not
1636 * be set when wep key setting.
1637 * we must reset sec_info after lingked before set key,
1638 * or some flag will be wrong
1640 if (vif->type == NL80211_IFTYPE_AP ||
1641 vif->type == NL80211_IFTYPE_MESH_POINT) {
1642 if (!group_key || key_type == WEP40_ENCRYPTION ||
1643 key_type == WEP104_ENCRYPTION) {
1646 rtlpriv->cfg->ops->enable_hw_sec(hw);
1649 if (!group_key || vif->type == NL80211_IFTYPE_ADHOC ||
1650 rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION) {
1651 if (rtlpriv->sec.pairwise_enc_algorithm ==
1653 (key_type == WEP40_ENCRYPTION ||
1654 key_type == WEP104_ENCRYPTION))
1656 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1657 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1658 "set enable_hw_sec, key_type:%x(OPEN:0 WEP40:1 TKIP:2 AES:4 WEP104:5)\n",
1660 rtlpriv->cfg->ops->enable_hw_sec(hw);
1663 /* <4> set key based on cmd */
1667 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1668 "set WEP(group/pairwise) key\n");
1669 /* Pairwise key with an assigned MAC address. */
1670 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1671 rtlpriv->sec.group_enc_algorithm = key_type;
1672 /*set local buf about wep key. */
1673 memcpy(rtlpriv->sec.key_buf[key_idx],
1674 key->key, key->keylen);
1675 rtlpriv->sec.key_len[key_idx] = key->keylen;
1676 eth_zero_addr(mac_addr);
1677 } else if (group_key) { /* group key */
1678 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1681 rtlpriv->sec.group_enc_algorithm = key_type;
1682 /*set local buf about group key. */
1683 memcpy(rtlpriv->sec.key_buf[key_idx],
1684 key->key, key->keylen);
1685 rtlpriv->sec.key_len[key_idx] = key->keylen;
1686 memcpy(mac_addr, bcast_addr, ETH_ALEN);
1687 } else { /* pairwise key */
1688 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1689 "set pairwise key\n");
1692 "rtlwifi: pairwise key without mac_addr\n");
1697 /* Pairwise key with an assigned MAC address. */
1698 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1699 /*set local buf about pairwise key. */
1700 memcpy(rtlpriv->sec.key_buf[PAIRWISE_KEYIDX],
1701 key->key, key->keylen);
1702 rtlpriv->sec.key_len[PAIRWISE_KEYIDX] = key->keylen;
1703 rtlpriv->sec.pairwise_key =
1704 rtlpriv->sec.key_buf[PAIRWISE_KEYIDX];
1705 memcpy(mac_addr, sta->addr, ETH_ALEN);
1707 rtlpriv->cfg->ops->set_key(hw, key_idx, mac_addr,
1708 group_key, key_type, wep_only,
1710 /* <5> tell mac80211 do something: */
1711 /*must use sw generate IV, or can not work !!!!. */
1712 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
1713 key->hw_key_idx = key_idx;
1714 if (key_type == TKIP_ENCRYPTION)
1715 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
1716 /*use software CCMP encryption for management frames (MFP) */
1717 if (key_type == AESCCMP_ENCRYPTION)
1718 key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX;
1721 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1722 "disable key delete one entry\n");
1723 /*set local buf about wep key. */
1724 if (vif->type == NL80211_IFTYPE_AP ||
1725 vif->type == NL80211_IFTYPE_MESH_POINT) {
1727 rtl_cam_del_entry(hw, sta->addr);
1729 memset(rtlpriv->sec.key_buf[key_idx], 0, key->keylen);
1730 rtlpriv->sec.key_len[key_idx] = 0;
1731 eth_zero_addr(mac_addr);
1733 *mac80211 will delete entries one by one,
1734 *so don't use rtl_cam_reset_all_entry
1735 *or clear all entries here.
1737 rtl_wait_tx_report_acked(hw, 500); /* wait 500ms for TX ack */
1739 rtl_cam_delete_one_entry(hw, mac_addr, key_idx);
1742 pr_err("cmd_err:%x!!!!:\n", cmd);
1745 mutex_unlock(&rtlpriv->locks.conf_mutex);
1746 rtlpriv->sec.being_setkey = false;
1750 static void rtl_op_rfkill_poll(struct ieee80211_hw *hw)
1752 struct rtl_priv *rtlpriv = rtl_priv(hw);
1758 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
1761 mutex_lock(&rtlpriv->locks.conf_mutex);
1763 /*if Radio On return true here */
1764 radio_state = rtlpriv->cfg->ops->radio_onoff_checking(hw, &valid);
1767 if (unlikely(radio_state != rtlpriv->rfkill.rfkill_state)) {
1768 rtlpriv->rfkill.rfkill_state = radio_state;
1770 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
1771 "wireless radio switch turned %s\n",
1772 radio_state ? "on" : "off");
1774 blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1;
1775 wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
1779 mutex_unlock(&rtlpriv->locks.conf_mutex);
1782 /* this function is called by mac80211 to flush tx buffer
1783 * before switch channel or power save, or tx buffer packet
1784 * maybe send after offchannel or rf sleep, this may cause
1785 * dis-association by AP
1787 static void rtl_op_flush(struct ieee80211_hw *hw,
1788 struct ieee80211_vif *vif,
1792 struct rtl_priv *rtlpriv = rtl_priv(hw);
1794 if (rtlpriv->intf_ops->flush)
1795 rtlpriv->intf_ops->flush(hw, queues, drop);
1799 * This routine deals with the Power Configuration CMD
1800 * parsing for RTL8723/RTL8188E Series IC.
1802 * We should follow specific format that was released from HW SD.
1804 bool rtl_hal_pwrseqcmdparsing(struct rtl_priv *rtlpriv, u8 cut_version,
1805 u8 faversion, u8 interface_type,
1806 struct wlan_pwr_cfg pwrcfgcmd[])
1808 struct wlan_pwr_cfg cfg_cmd;
1809 bool polling_bit = false;
1813 u32 polling_count = 0;
1814 u32 max_polling_cnt = 5000;
1817 cfg_cmd = pwrcfgcmd[ary_idx];
1818 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1819 "%s(): offset(%#x),cut_msk(%#x), famsk(%#x), interface_msk(%#x), base(%#x), cmd(%#x), msk(%#x), value(%#x)\n",
1820 __func__, GET_PWR_CFG_OFFSET(cfg_cmd),
1821 GET_PWR_CFG_CUT_MASK(cfg_cmd),
1822 GET_PWR_CFG_FAB_MASK(cfg_cmd),
1823 GET_PWR_CFG_INTF_MASK(cfg_cmd),
1824 GET_PWR_CFG_BASE(cfg_cmd), GET_PWR_CFG_CMD(cfg_cmd),
1825 GET_PWR_CFG_MASK(cfg_cmd), GET_PWR_CFG_VALUE(cfg_cmd));
1827 if ((GET_PWR_CFG_FAB_MASK(cfg_cmd) & faversion) &&
1828 (GET_PWR_CFG_CUT_MASK(cfg_cmd) & cut_version) &&
1829 (GET_PWR_CFG_INTF_MASK(cfg_cmd) & interface_type)) {
1830 switch (GET_PWR_CFG_CMD(cfg_cmd)) {
1832 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1833 "%s(): PWR_CMD_READ\n", __func__);
1836 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1837 "%s(): PWR_CMD_WRITE\n", __func__);
1838 offset = GET_PWR_CFG_OFFSET(cfg_cmd);
1840 /*Read the value from system register*/
1841 value = rtl_read_byte(rtlpriv, offset);
1842 value &= (~(GET_PWR_CFG_MASK(cfg_cmd)));
1843 value |= (GET_PWR_CFG_VALUE(cfg_cmd) &
1844 GET_PWR_CFG_MASK(cfg_cmd));
1846 /*Write the value back to system register*/
1847 rtl_write_byte(rtlpriv, offset, value);
1849 case PWR_CMD_POLLING:
1850 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1851 "%s(): PWR_CMD_POLLING\n", __func__);
1852 polling_bit = false;
1853 offset = GET_PWR_CFG_OFFSET(cfg_cmd);
1856 value = rtl_read_byte(rtlpriv, offset);
1858 value &= GET_PWR_CFG_MASK(cfg_cmd);
1860 (GET_PWR_CFG_VALUE(cfg_cmd) &
1861 GET_PWR_CFG_MASK(cfg_cmd)))
1866 if (polling_count++ > max_polling_cnt)
1868 } while (!polling_bit);
1871 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1872 "%s(): PWR_CMD_DELAY\n", __func__);
1873 if (GET_PWR_CFG_VALUE(cfg_cmd) ==
1875 udelay(GET_PWR_CFG_OFFSET(cfg_cmd));
1877 mdelay(GET_PWR_CFG_OFFSET(cfg_cmd));
1880 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1881 "%s(): PWR_CMD_END\n", __func__);
1885 "rtlwifi: %s(): Unknown CMD!!\n", __func__);
1895 bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)
1897 struct rtl_priv *rtlpriv = rtl_priv(hw);
1898 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1899 struct rtl8192_tx_ring *ring;
1900 struct rtl_tx_desc *pdesc;
1901 unsigned long flags;
1902 struct sk_buff *pskb = NULL;
1904 ring = &rtlpci->tx_ring[BEACON_QUEUE];
1906 spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags);
1907 pskb = __skb_dequeue(&ring->queue);
1909 dev_kfree_skb_irq(pskb);
1911 /*this is wrong, fill_tx_cmddesc needs update*/
1912 pdesc = &ring->desc[0];
1914 rtlpriv->cfg->ops->fill_tx_cmddesc(hw, (u8 *)pdesc, 1, 1, skb);
1916 __skb_queue_tail(&ring->queue, skb);
1918 spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags);
1920 rtlpriv->cfg->ops->tx_polling(hw, BEACON_QUEUE);
1925 const struct ieee80211_ops rtl_ops = {
1926 .start = rtl_op_start,
1927 .stop = rtl_op_stop,
1929 .add_interface = rtl_op_add_interface,
1930 .remove_interface = rtl_op_remove_interface,
1931 .change_interface = rtl_op_change_interface,
1933 .suspend = rtl_op_suspend,
1934 .resume = rtl_op_resume,
1936 .config = rtl_op_config,
1937 .configure_filter = rtl_op_configure_filter,
1938 .set_key = rtl_op_set_key,
1939 .sta_statistics = rtl_op_sta_statistics,
1940 .set_frag_threshold = rtl_op_set_frag_threshold,
1941 .conf_tx = rtl_op_conf_tx,
1942 .bss_info_changed = rtl_op_bss_info_changed,
1943 .get_tsf = rtl_op_get_tsf,
1944 .set_tsf = rtl_op_set_tsf,
1945 .reset_tsf = rtl_op_reset_tsf,
1946 .sta_notify = rtl_op_sta_notify,
1947 .ampdu_action = rtl_op_ampdu_action,
1948 .sw_scan_start = rtl_op_sw_scan_start,
1949 .sw_scan_complete = rtl_op_sw_scan_complete,
1950 .rfkill_poll = rtl_op_rfkill_poll,
1951 .sta_add = rtl_op_sta_add,
1952 .sta_remove = rtl_op_sta_remove,
1953 .flush = rtl_op_flush,
1956 bool rtl_btc_status_false(void)
1961 void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igvalue)
1963 struct rtl_priv *rtlpriv = rtl_priv(hw);
1964 struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
1966 dm_digtable->dig_enable_flag = true;
1967 dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
1968 dm_digtable->cur_igvalue = cur_igvalue;
1969 dm_digtable->pre_igvalue = 0;
1970 dm_digtable->cur_sta_cstate = DIG_STA_DISCONNECT;
1971 dm_digtable->presta_cstate = DIG_STA_DISCONNECT;
1972 dm_digtable->curmultista_cstate = DIG_MULTISTA_DISCONNECT;
1973 dm_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
1974 dm_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
1975 dm_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
1976 dm_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
1977 dm_digtable->rx_gain_max = DM_DIG_MAX;
1978 dm_digtable->rx_gain_min = DM_DIG_MIN;
1979 dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
1980 dm_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
1981 dm_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
1982 dm_digtable->pre_cck_cca_thres = 0xff;
1983 dm_digtable->cur_cck_cca_thres = 0x83;
1984 dm_digtable->forbidden_igi = DM_DIG_MIN;
1985 dm_digtable->large_fa_hit = 0;
1986 dm_digtable->recover_cnt = 0;
1987 dm_digtable->dig_min_0 = 0x25;
1988 dm_digtable->dig_min_1 = 0x25;
1989 dm_digtable->media_connect_0 = false;
1990 dm_digtable->media_connect_1 = false;
1991 rtlpriv->dm.dm_initialgain_enable = true;
1992 dm_digtable->bt30_cur_igi = 0x32;
1993 dm_digtable->pre_cck_pd_state = CCK_PD_STAGE_MAX;
1994 dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_LOWRSSI;