1 /******************************************************************************
3 * Copyright(c) 2009-2012 Realtek Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * The full GNU General Public License is included in this distribution in the
15 * file called LICENSE.
17 * Contact Information:
18 * wlanfae <wlanfae@realtek.com>
19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20 * Hsinchu 300, Taiwan.
22 * Larry Finger <Larry.Finger@lwfinger.net>
24 *****************************************************************************/
31 #include "pwrseqcmd.h"
33 #include "btcoexist/rtl_btc.h"
34 #include <linux/firmware.h>
35 #include <linux/export.h>
36 #include <net/cfg80211.h>
38 u8 channel5g[CHANNEL_MAX_NUMBER_5G] = {
39 36, 38, 40, 42, 44, 46, 48, /* Band 1 */
40 52, 54, 56, 58, 60, 62, 64, /* Band 2 */
41 100, 102, 104, 106, 108, 110, 112, /* Band 3 */
42 116, 118, 120, 122, 124, 126, 128, /* Band 3 */
43 132, 134, 136, 138, 140, 142, 144, /* Band 3 */
44 149, 151, 153, 155, 157, 159, 161, /* Band 4 */
45 165, 167, 169, 171, 173, 175, 177 /* Band 4 */
47 EXPORT_SYMBOL(channel5g);
49 u8 channel5g_80m[CHANNEL_MAX_NUMBER_5G_80M] = {
50 42, 58, 106, 122, 138, 155, 171
52 EXPORT_SYMBOL(channel5g_80m);
54 void rtl_addr_delay(u32 addr)
58 else if (addr == 0xfd)
60 else if (addr == 0xfc)
62 else if (addr == 0xfb)
63 usleep_range(50, 100);
64 else if (addr == 0xfa)
66 else if (addr == 0xf9)
69 EXPORT_SYMBOL(rtl_addr_delay);
71 void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr,
74 if (addr >= 0xf9 && addr <= 0xfe) {
77 rtl_set_rfreg(hw, rfpath, addr, mask, data);
81 EXPORT_SYMBOL(rtl_rfreg_delay);
83 void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data)
85 if (addr >= 0xf9 && addr <= 0xfe) {
88 rtl_set_bbreg(hw, addr, MASKDWORD, data);
92 EXPORT_SYMBOL(rtl_bb_delay);
94 static void rtl_fw_do_work(const struct firmware *firmware, void *context,
97 struct ieee80211_hw *hw = context;
98 struct rtl_priv *rtlpriv = rtl_priv(hw);
101 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
102 "Firmware callback routine entered!\n");
103 complete(&rtlpriv->firmware_loading_complete);
105 if (rtlpriv->cfg->alt_fw_name) {
106 err = request_firmware(&firmware,
107 rtlpriv->cfg->alt_fw_name,
109 pr_info("Loading alternative firmware %s\n",
110 rtlpriv->cfg->alt_fw_name);
114 pr_err("Selected firmware is not available\n");
115 rtlpriv->max_fw_size = 0;
119 if (firmware->size > rtlpriv->max_fw_size) {
120 pr_err("Firmware is too big!\n");
121 release_firmware(firmware);
125 memcpy(rtlpriv->rtlhal.pfirmware, firmware->data,
127 rtlpriv->rtlhal.fwsize = firmware->size;
129 memcpy(rtlpriv->rtlhal.wowlan_firmware, firmware->data,
131 rtlpriv->rtlhal.wowlan_fwsize = firmware->size;
133 rtlpriv->rtlhal.fwsize = firmware->size;
134 release_firmware(firmware);
137 void rtl_fw_cb(const struct firmware *firmware, void *context)
139 rtl_fw_do_work(firmware, context, false);
141 EXPORT_SYMBOL(rtl_fw_cb);
143 void rtl_wowlan_fw_cb(const struct firmware *firmware, void *context)
145 rtl_fw_do_work(firmware, context, true);
147 EXPORT_SYMBOL(rtl_wowlan_fw_cb);
149 /*mutex for start & stop is must here. */
150 static int rtl_op_start(struct ieee80211_hw *hw)
153 struct rtl_priv *rtlpriv = rtl_priv(hw);
154 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
156 if (!is_hal_stop(rtlhal))
158 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
160 mutex_lock(&rtlpriv->locks.conf_mutex);
161 err = rtlpriv->intf_ops->adapter_start(hw);
163 rtl_watch_dog_timer_callback((unsigned long)hw);
164 mutex_unlock(&rtlpriv->locks.conf_mutex);
168 static void rtl_op_stop(struct ieee80211_hw *hw)
170 struct rtl_priv *rtlpriv = rtl_priv(hw);
171 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
172 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
173 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
174 bool support_remote_wakeup = false;
176 if (is_hal_stop(rtlhal))
179 rtlpriv->cfg->ops->get_hw_reg(hw, HAL_DEF_WOWLAN,
180 (u8 *)(&support_remote_wakeup));
181 /* here is must, because adhoc do stop and start,
182 * but stop with RFOFF may cause something wrong,
185 if (unlikely(ppsc->rfpwr_state == ERFOFF))
188 mutex_lock(&rtlpriv->locks.conf_mutex);
189 /* if wowlan supported, DON'T clear connected info */
190 if (!(support_remote_wakeup &&
191 rtlhal->enter_pnp_sleep)) {
192 mac->link_state = MAC80211_NOLINK;
193 eth_zero_addr(mac->bssid);
194 mac->vendor = PEER_UNKNOWN;
197 rtl_cam_reset_sec_info(hw);
199 rtl_deinit_deferred_work(hw);
201 rtlpriv->intf_ops->adapter_stop(hw);
203 mutex_unlock(&rtlpriv->locks.conf_mutex);
206 static void rtl_op_tx(struct ieee80211_hw *hw,
207 struct ieee80211_tx_control *control,
210 struct rtl_priv *rtlpriv = rtl_priv(hw);
211 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
212 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
213 struct rtl_tcb_desc tcb_desc;
214 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
216 if (unlikely(is_hal_stop(rtlhal) || ppsc->rfpwr_state != ERFON))
219 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
222 if (!rtlpriv->intf_ops->waitq_insert(hw, control->sta, skb))
223 rtlpriv->intf_ops->adapter_tx(hw, control->sta, skb, &tcb_desc);
227 dev_kfree_skb_any(skb);
230 static int rtl_op_add_interface(struct ieee80211_hw *hw,
231 struct ieee80211_vif *vif)
233 struct rtl_priv *rtlpriv = rtl_priv(hw);
234 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
238 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
239 "vif has been set!! mac->vif = 0x%p\n", mac->vif);
243 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
247 mutex_lock(&rtlpriv->locks.conf_mutex);
248 switch (ieee80211_vif_type_p2p(vif)) {
249 case NL80211_IFTYPE_P2P_CLIENT:
250 mac->p2p = P2P_ROLE_CLIENT;
252 case NL80211_IFTYPE_STATION:
253 if (mac->beacon_enabled == 1) {
254 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
255 "NL80211_IFTYPE_STATION\n");
256 mac->beacon_enabled = 0;
257 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
258 rtlpriv->cfg->maps[RTL_IBSS_INT_MASKS]);
261 case NL80211_IFTYPE_ADHOC:
262 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
263 "NL80211_IFTYPE_ADHOC\n");
265 mac->link_state = MAC80211_LINKED;
266 rtlpriv->cfg->ops->set_bcn_reg(hw);
267 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
268 mac->basic_rates = 0xfff;
270 mac->basic_rates = 0xff0;
271 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
272 (u8 *)(&mac->basic_rates));
275 case NL80211_IFTYPE_P2P_GO:
276 mac->p2p = P2P_ROLE_GO;
278 case NL80211_IFTYPE_AP:
279 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
280 "NL80211_IFTYPE_AP\n");
282 mac->link_state = MAC80211_LINKED;
283 rtlpriv->cfg->ops->set_bcn_reg(hw);
284 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
285 mac->basic_rates = 0xfff;
287 mac->basic_rates = 0xff0;
288 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
289 (u8 *)(&mac->basic_rates));
291 case NL80211_IFTYPE_MESH_POINT:
292 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
293 "NL80211_IFTYPE_MESH_POINT\n");
295 mac->link_state = MAC80211_LINKED;
296 rtlpriv->cfg->ops->set_bcn_reg(hw);
297 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
298 mac->basic_rates = 0xfff;
300 mac->basic_rates = 0xff0;
301 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
302 (u8 *)(&mac->basic_rates));
305 pr_err("operation mode %d is not supported!\n",
312 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
313 "p2p role %x\n", vif->type);
314 mac->basic_rates = 0xff0;/*disable cck rate for p2p*/
315 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
316 (u8 *)(&mac->basic_rates));
319 mac->opmode = vif->type;
320 rtlpriv->cfg->ops->set_network_type(hw, vif->type);
321 memcpy(mac->mac_addr, vif->addr, ETH_ALEN);
322 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, mac->mac_addr);
325 mutex_unlock(&rtlpriv->locks.conf_mutex);
329 static void rtl_op_remove_interface(struct ieee80211_hw *hw,
330 struct ieee80211_vif *vif)
332 struct rtl_priv *rtlpriv = rtl_priv(hw);
333 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
335 mutex_lock(&rtlpriv->locks.conf_mutex);
337 /* Free beacon resources */
338 if ((vif->type == NL80211_IFTYPE_AP) ||
339 (vif->type == NL80211_IFTYPE_ADHOC) ||
340 (vif->type == NL80211_IFTYPE_MESH_POINT)) {
341 if (mac->beacon_enabled == 1) {
342 mac->beacon_enabled = 0;
343 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
344 rtlpriv->cfg->maps[RTL_IBSS_INT_MASKS]);
349 *Note: We assume NL80211_IFTYPE_UNSPECIFIED as
350 *NO LINK for our hardware.
354 mac->link_state = MAC80211_NOLINK;
355 eth_zero_addr(mac->bssid);
356 mac->vendor = PEER_UNKNOWN;
357 mac->opmode = NL80211_IFTYPE_UNSPECIFIED;
358 rtlpriv->cfg->ops->set_network_type(hw, mac->opmode);
360 mutex_unlock(&rtlpriv->locks.conf_mutex);
362 static int rtl_op_change_interface(struct ieee80211_hw *hw,
363 struct ieee80211_vif *vif,
364 enum nl80211_iftype new_type, bool p2p)
366 struct rtl_priv *rtlpriv = rtl_priv(hw);
368 rtl_op_remove_interface(hw, vif);
370 vif->type = new_type;
372 ret = rtl_op_add_interface(hw, vif);
373 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
379 static u16 crc16_ccitt(u8 data, u16 crc)
381 u8 shift_in, data_bit, crc_bit11, crc_bit4, crc_bit15;
385 for (i = 0; i < 8; i++) {
386 crc_bit15 = ((crc & BIT(15)) ? 1 : 0);
387 data_bit = (data & (BIT(0) << i) ? 1 : 0);
388 shift_in = crc_bit15 ^ data_bit;
396 crc_bit11 = ((crc & BIT(11)) ? 1 : 0) ^ shift_in;
398 result &= (~BIT(12));
402 crc_bit4 = ((crc & BIT(4)) ? 1 : 0) ^ shift_in;
414 static u16 _calculate_wol_pattern_crc(u8 *pattern, u16 len)
419 for (i = 0; i < len; i++)
420 crc = crc16_ccitt(pattern[i], crc);
427 static void _rtl_add_wowlan_patterns(struct ieee80211_hw *hw,
428 struct cfg80211_wowlan *wow)
430 struct rtl_priv *rtlpriv = rtl_priv(hw);
431 struct rtl_mac *mac = &rtlpriv->mac80211;
432 struct cfg80211_pkt_pattern *patterns = wow->patterns;
433 struct rtl_wow_pattern rtl_pattern;
434 const u8 *pattern_os, *mask_os;
435 u8 mask[MAX_WOL_BIT_MASK_SIZE] = {0};
436 u8 content[MAX_WOL_PATTERN_SIZE] = {0};
437 u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
438 u8 multicast_addr1[2] = {0x33, 0x33};
439 u8 multicast_addr2[3] = {0x01, 0x00, 0x5e};
443 for (i = 0; i < wow->n_patterns; i++) {
444 memset(&rtl_pattern, 0, sizeof(struct rtl_wow_pattern));
445 memset(mask, 0, MAX_WOL_BIT_MASK_SIZE);
446 if (patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) {
447 RT_TRACE(rtlpriv, COMP_POWER, DBG_WARNING,
448 "Pattern[%d] is too long\n", i);
451 pattern_os = patterns[i].pattern;
452 mask_len = DIV_ROUND_UP(patterns[i].pattern_len, 8);
453 mask_os = patterns[i].mask;
454 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
455 "pattern content\n", pattern_os,
456 patterns[i].pattern_len);
457 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
458 "mask content\n", mask_os, mask_len);
459 /* 1. unicast? multicast? or broadcast? */
460 if (memcmp(pattern_os, broadcast_addr, 6) == 0)
461 rtl_pattern.type = BROADCAST_PATTERN;
462 else if (memcmp(pattern_os, multicast_addr1, 2) == 0 ||
463 memcmp(pattern_os, multicast_addr2, 3) == 0)
464 rtl_pattern.type = MULTICAST_PATTERN;
465 else if (memcmp(pattern_os, mac->mac_addr, 6) == 0)
466 rtl_pattern.type = UNICAST_PATTERN;
468 rtl_pattern.type = UNKNOWN_TYPE;
470 /* 2. translate mask_from_os to mask_for_hw */
472 /******************************************************************************
473 * pattern from OS uses 'ethenet frame', like this:
475 | 6 | 6 | 2 | 20 | Variable | 4 |
476 |--------+--------+------+-----------+------------+-----|
477 | 802.3 Mac Header | IP Header | TCP Packet | FCS |
480 * BUT, packet catched by our HW is in '802.11 frame', begin from LLC,
482 | 24 or 30 | 6 | 2 | 20 | Variable | 4 |
483 |-------------------+--------+------+-----------+------------+-----|
484 | 802.11 MAC Header | LLC | IP Header | TCP Packet | FCS |
487 * Therefore, we need translate mask_from_OS to mask_to_hw.
488 * We should left-shift mask by 6 bits, then set the new bit[0~5] = 0,
489 * because new mask[0~5] means 'SA', but our HW packet begins from LLC,
490 * bit[0~5] corresponds to first 6 Bytes in LLC, they just don't match.
491 ******************************************************************************/
494 for (j = 0; j < mask_len - 1; j++) {
495 mask[j] = mask_os[j] >> 6;
496 mask[j] |= (mask_os[j + 1] & 0x3F) << 2;
498 mask[j] = (mask_os[j] >> 6) & 0x3F;
499 /* Set bit 0-5 to zero */
502 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
503 "mask to hw\n", mask, mask_len);
504 for (j = 0; j < (MAX_WOL_BIT_MASK_SIZE + 1) / 4; j++) {
505 rtl_pattern.mask[j] = mask[j * 4];
506 rtl_pattern.mask[j] |= (mask[j * 4 + 1] << 8);
507 rtl_pattern.mask[j] |= (mask[j * 4 + 2] << 16);
508 rtl_pattern.mask[j] |= (mask[j * 4 + 3] << 24);
511 /* To get the wake up pattern from the mask.
512 * We do not count first 12 bits which means
513 * DA[6] and SA[6] in the pattern to match HW design.
516 for (j = 12; j < patterns[i].pattern_len; j++) {
517 if ((mask_os[j / 8] >> (j % 8)) & 0x01) {
518 content[len] = pattern_os[j];
523 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
524 "pattern to hw\n", content, len);
525 /* 3. calculate crc */
526 rtl_pattern.crc = _calculate_wol_pattern_crc(content, len);
527 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE,
528 "CRC_Remainder = 0x%x\n", rtl_pattern.crc);
530 /* 4. write crc & mask_for_hw to hw */
531 rtlpriv->cfg->ops->add_wowlan_pattern(hw, &rtl_pattern, i);
533 rtl_write_byte(rtlpriv, 0x698, wow->n_patterns);
536 static int rtl_op_suspend(struct ieee80211_hw *hw,
537 struct cfg80211_wowlan *wow)
539 struct rtl_priv *rtlpriv = rtl_priv(hw);
540 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
541 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
544 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n");
548 /* to resolve s4 can not wake up*/
549 do_gettimeofday(&ts);
550 rtlhal->last_suspend_sec = ts.tv_sec;
552 if ((ppsc->wo_wlan_mode & WAKE_ON_PATTERN_MATCH) && wow->n_patterns)
553 _rtl_add_wowlan_patterns(hw, wow);
555 rtlhal->driver_is_goingto_unload = true;
556 rtlhal->enter_pnp_sleep = true;
560 device_set_wakeup_enable(wiphy_dev(hw->wiphy), true);
564 static int rtl_op_resume(struct ieee80211_hw *hw)
566 struct rtl_priv *rtlpriv = rtl_priv(hw);
567 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
568 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
571 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n");
572 rtlhal->driver_is_goingto_unload = false;
573 rtlhal->enter_pnp_sleep = false;
574 rtlhal->wake_from_pnp_sleep = true;
576 /* to resovle s4 can not wake up*/
577 do_gettimeofday(&ts);
578 if (ts.tv_sec - rtlhal->last_suspend_sec < 5)
582 device_set_wakeup_enable(wiphy_dev(hw->wiphy), false);
583 ieee80211_resume_disconnect(mac->vif);
584 rtlhal->wake_from_pnp_sleep = false;
589 static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
591 struct rtl_priv *rtlpriv = rtl_priv(hw);
592 struct rtl_phy *rtlphy = &(rtlpriv->phy);
593 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
594 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
595 struct ieee80211_conf *conf = &hw->conf;
600 mutex_lock(&rtlpriv->locks.conf_mutex);
601 if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { /* BIT(2)*/
602 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
603 "IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n");
607 if (changed & IEEE80211_CONF_CHANGE_IDLE) {
608 if (hw->conf.flags & IEEE80211_CONF_IDLE)
614 *although rfoff may not cause by ips, but we will
615 *check the reason in set_rf_power_state function
617 if (unlikely(ppsc->rfpwr_state == ERFOFF))
622 if (changed & IEEE80211_CONF_CHANGE_PS) {
623 cancel_delayed_work(&rtlpriv->works.ps_work);
624 cancel_delayed_work(&rtlpriv->works.ps_rfon_wq);
625 if (conf->flags & IEEE80211_CONF_PS) {
626 rtlpriv->psc.sw_ps_enabled = true;
627 /* sleep here is must, or we may recv the beacon and
628 * cause mac80211 into wrong ps state, this will cause
629 * power save nullfunc send fail, and further cause
630 * pkt loss, So sleep must quickly but not immediatly
631 * because that will cause nullfunc send by mac80211
632 * fail, and cause pkt loss, we have tested that 5mA
633 * is worked very well */
634 if (!rtlpriv->psc.multi_buffered)
635 queue_delayed_work(rtlpriv->works.rtl_wq,
636 &rtlpriv->works.ps_work,
639 rtl_swlps_rf_awake(hw);
640 rtlpriv->psc.sw_ps_enabled = false;
644 if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) {
645 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
646 "IEEE80211_CONF_CHANGE_RETRY_LIMITS %x\n",
647 hw->conf.long_frame_max_tx_count);
648 mac->retry_long = hw->conf.long_frame_max_tx_count;
649 mac->retry_short = hw->conf.long_frame_max_tx_count;
650 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
651 (u8 *)(&hw->conf.long_frame_max_tx_count));
654 if (changed & IEEE80211_CONF_CHANGE_CHANNEL &&
655 !rtlpriv->proximity.proxim_on) {
656 struct ieee80211_channel *channel = hw->conf.chandef.chan;
657 enum nl80211_chan_width width = hw->conf.chandef.width;
658 enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT;
659 u8 wide_chan = (u8) channel->hw_value;
661 /* channel_type is for 20&40M */
662 if (width < NL80211_CHAN_WIDTH_80)
664 cfg80211_get_chandef_type(&hw->conf.chandef);
665 if (mac->act_scanning)
668 if (rtlpriv->dm.supp_phymode_switch &&
669 mac->link_state < MAC80211_LINKED &&
670 !mac->act_scanning) {
671 if (rtlpriv->cfg->ops->chk_switch_dmdp)
672 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
676 *because we should back channel to
677 *current_network.chan in in scanning,
678 *So if set_chan == current_network.chan
680 *because mac80211 tell us wrong bw40
681 *info for cisco1253 bw20, so we modify
682 *it here based on UPPER & LOWER
685 if (width >= NL80211_CHAN_WIDTH_80) {
686 if (width == NL80211_CHAN_WIDTH_80) {
687 u32 center = hw->conf.chandef.center_freq1;
689 (u32)hw->conf.chandef.chan->center_freq;
691 rtlphy->current_chan_bw =
695 if (center > primary) {
696 mac->cur_80_prime_sc =
697 PRIME_CHNL_OFFSET_LOWER;
698 if (center - primary == 10) {
699 mac->cur_40_prime_sc =
700 PRIME_CHNL_OFFSET_UPPER;
703 } else if (center - primary == 30) {
704 mac->cur_40_prime_sc =
705 PRIME_CHNL_OFFSET_LOWER;
710 mac->cur_80_prime_sc =
711 PRIME_CHNL_OFFSET_UPPER;
712 if (primary - center == 10) {
713 mac->cur_40_prime_sc =
714 PRIME_CHNL_OFFSET_LOWER;
717 } else if (primary - center == 30) {
718 mac->cur_40_prime_sc =
719 PRIME_CHNL_OFFSET_UPPER;
726 switch (channel_type) {
727 case NL80211_CHAN_HT20:
728 case NL80211_CHAN_NO_HT:
730 mac->cur_40_prime_sc =
731 PRIME_CHNL_OFFSET_DONT_CARE;
732 rtlphy->current_chan_bw =
737 case NL80211_CHAN_HT40MINUS:
739 mac->cur_40_prime_sc =
740 PRIME_CHNL_OFFSET_UPPER;
741 rtlphy->current_chan_bw =
742 HT_CHANNEL_WIDTH_20_40;
750 case NL80211_CHAN_HT40PLUS:
752 mac->cur_40_prime_sc =
753 PRIME_CHNL_OFFSET_LOWER;
754 rtlphy->current_chan_bw =
755 HT_CHANNEL_WIDTH_20_40;
766 pr_err("switch case %#x not processed\n",
775 /* In scanning, when before we offchannel we may send a ps=1
776 * null to AP, and then we may send a ps = 0 null to AP quickly,
777 * but first null may have caused AP to put lots of packet to
778 * hw tx buffer. These packets must be tx'd before we go off
779 * channel so we must delay more time to let AP flush these
780 * packets before going offchannel, or dis-association or
781 * delete BA will be caused by AP
783 if (rtlpriv->mac80211.offchan_delay) {
784 rtlpriv->mac80211.offchan_delay = false;
788 rtlphy->current_channel = wide_chan;
790 rtlpriv->cfg->ops->switch_channel(hw);
791 rtlpriv->cfg->ops->set_channel_access(hw);
792 rtlpriv->cfg->ops->set_bw_mode(hw, channel_type);
795 mutex_unlock(&rtlpriv->locks.conf_mutex);
800 static void rtl_op_configure_filter(struct ieee80211_hw *hw,
801 unsigned int changed_flags,
802 unsigned int *new_flags, u64 multicast)
804 bool update_rcr = false;
805 struct rtl_priv *rtlpriv = rtl_priv(hw);
806 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
808 *new_flags &= RTL_SUPPORTED_FILTERS;
809 if (0 == changed_flags)
812 /*TODO: we disable broadcase now, so enable here */
813 if (changed_flags & FIF_ALLMULTI) {
814 if (*new_flags & FIF_ALLMULTI) {
815 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AM] |
816 rtlpriv->cfg->maps[MAC_RCR_AB];
817 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
818 "Enable receive multicast frame\n");
820 mac->rx_conf &= ~(rtlpriv->cfg->maps[MAC_RCR_AM] |
821 rtlpriv->cfg->maps[MAC_RCR_AB]);
822 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
823 "Disable receive multicast frame\n");
828 if (changed_flags & FIF_FCSFAIL) {
829 if (*new_flags & FIF_FCSFAIL) {
830 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACRC32];
831 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
832 "Enable receive FCS error frame\n");
834 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACRC32];
835 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
836 "Disable receive FCS error frame\n");
842 /* if ssid not set to hw don't check bssid
843 * here just used for linked scanning, & linked
844 * and nolink check bssid is set in set network_type
846 if ((changed_flags & FIF_BCN_PRBRESP_PROMISC) &&
847 (mac->link_state >= MAC80211_LINKED)) {
848 if (mac->opmode != NL80211_IFTYPE_AP &&
849 mac->opmode != NL80211_IFTYPE_MESH_POINT) {
850 if (*new_flags & FIF_BCN_PRBRESP_PROMISC)
851 rtlpriv->cfg->ops->set_chk_bssid(hw, false);
853 rtlpriv->cfg->ops->set_chk_bssid(hw, true);
859 if (changed_flags & FIF_CONTROL) {
860 if (*new_flags & FIF_CONTROL) {
861 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACF];
863 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
864 "Enable receive control frame.\n");
866 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACF];
867 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
868 "Disable receive control frame.\n");
874 if (changed_flags & FIF_OTHER_BSS) {
875 if (*new_flags & FIF_OTHER_BSS) {
876 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AAP];
877 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
878 "Enable receive other BSS's frame.\n");
880 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_AAP];
881 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
882 "Disable receive other BSS's frame.\n");
889 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR,
890 (u8 *)(&mac->rx_conf));
892 static int rtl_op_sta_add(struct ieee80211_hw *hw,
893 struct ieee80211_vif *vif,
894 struct ieee80211_sta *sta)
896 struct rtl_priv *rtlpriv = rtl_priv(hw);
897 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
898 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
899 struct rtl_sta_info *sta_entry;
902 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
903 spin_lock_bh(&rtlpriv->locks.entry_list_lock);
904 list_add_tail(&sta_entry->list, &rtlpriv->entry_list);
905 spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
906 if (rtlhal->current_bandtype == BAND_ON_2_4G) {
907 sta_entry->wireless_mode = WIRELESS_MODE_G;
908 if (sta->supp_rates[0] <= 0xf)
909 sta_entry->wireless_mode = WIRELESS_MODE_B;
910 if (sta->ht_cap.ht_supported)
911 sta_entry->wireless_mode = WIRELESS_MODE_N_24G;
913 if (vif->type == NL80211_IFTYPE_ADHOC)
914 sta_entry->wireless_mode = WIRELESS_MODE_G;
915 } else if (rtlhal->current_bandtype == BAND_ON_5G) {
916 sta_entry->wireless_mode = WIRELESS_MODE_A;
917 if (sta->ht_cap.ht_supported)
918 sta_entry->wireless_mode = WIRELESS_MODE_N_5G;
919 if (sta->vht_cap.vht_supported)
920 sta_entry->wireless_mode = WIRELESS_MODE_AC_5G;
922 if (vif->type == NL80211_IFTYPE_ADHOC)
923 sta_entry->wireless_mode = WIRELESS_MODE_A;
925 /*disable cck rate for p2p*/
927 sta->supp_rates[0] &= 0xfffffff0;
929 memcpy(sta_entry->mac_addr, sta->addr, ETH_ALEN);
930 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
931 "Add sta addr is %pM\n", sta->addr);
932 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0);
938 static int rtl_op_sta_remove(struct ieee80211_hw *hw,
939 struct ieee80211_vif *vif,
940 struct ieee80211_sta *sta)
942 struct rtl_priv *rtlpriv = rtl_priv(hw);
943 struct rtl_sta_info *sta_entry;
945 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
946 "Remove sta addr is %pM\n", sta->addr);
947 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
948 sta_entry->wireless_mode = 0;
949 sta_entry->ratr_index = 0;
950 spin_lock_bh(&rtlpriv->locks.entry_list_lock);
951 list_del(&sta_entry->list);
952 spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
956 static int _rtl_get_hal_qnum(u16 queue)
981 *for mac80211 VO = 0, VI = 1, BE = 2, BK = 3
982 *for rtl819x BE = 0, BK = 1, VI = 2, VO = 3
984 static int rtl_op_conf_tx(struct ieee80211_hw *hw,
985 struct ieee80211_vif *vif, u16 queue,
986 const struct ieee80211_tx_queue_params *param)
988 struct rtl_priv *rtlpriv = rtl_priv(hw);
989 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
992 if (queue >= AC_MAX) {
993 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
994 "queue number %d is incorrect!\n", queue);
998 aci = _rtl_get_hal_qnum(queue);
999 mac->ac[aci].aifs = param->aifs;
1000 mac->ac[aci].cw_min = cpu_to_le16(param->cw_min);
1001 mac->ac[aci].cw_max = cpu_to_le16(param->cw_max);
1002 mac->ac[aci].tx_op = cpu_to_le16(param->txop);
1003 memcpy(&mac->edca_param[aci], param, sizeof(*param));
1004 rtlpriv->cfg->ops->set_qos(hw, aci);
1008 static void send_beacon_frame(struct ieee80211_hw *hw,
1009 struct ieee80211_vif *vif)
1011 struct rtl_priv *rtlpriv = rtl_priv(hw);
1012 struct sk_buff *skb = ieee80211_beacon_get(hw, vif);
1013 struct rtl_tcb_desc tcb_desc;
1016 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
1017 rtlpriv->intf_ops->adapter_tx(hw, NULL, skb, &tcb_desc);
1021 static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
1022 struct ieee80211_vif *vif,
1023 struct ieee80211_bss_conf *bss_conf,
1026 struct rtl_priv *rtlpriv = rtl_priv(hw);
1027 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
1028 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1029 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
1031 mutex_lock(&rtlpriv->locks.conf_mutex);
1032 if ((vif->type == NL80211_IFTYPE_ADHOC) ||
1033 (vif->type == NL80211_IFTYPE_AP) ||
1034 (vif->type == NL80211_IFTYPE_MESH_POINT)) {
1035 if ((changed & BSS_CHANGED_BEACON) ||
1036 (changed & BSS_CHANGED_BEACON_ENABLED &&
1037 bss_conf->enable_beacon)) {
1038 if (mac->beacon_enabled == 0) {
1039 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1040 "BSS_CHANGED_BEACON_ENABLED\n");
1042 /*start hw beacon interrupt. */
1043 /*rtlpriv->cfg->ops->set_bcn_reg(hw); */
1044 mac->beacon_enabled = 1;
1045 rtlpriv->cfg->ops->update_interrupt_mask(hw,
1047 [RTL_IBSS_INT_MASKS], 0);
1049 if (rtlpriv->cfg->ops->linked_set_reg)
1050 rtlpriv->cfg->ops->linked_set_reg(hw);
1051 send_beacon_frame(hw, vif);
1054 if ((changed & BSS_CHANGED_BEACON_ENABLED &&
1055 !bss_conf->enable_beacon)) {
1056 if (mac->beacon_enabled == 1) {
1057 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1058 "ADHOC DISABLE BEACON\n");
1060 mac->beacon_enabled = 0;
1061 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
1063 [RTL_IBSS_INT_MASKS]);
1066 if (changed & BSS_CHANGED_BEACON_INT) {
1067 RT_TRACE(rtlpriv, COMP_BEACON, DBG_TRACE,
1068 "BSS_CHANGED_BEACON_INT\n");
1069 mac->beacon_interval = bss_conf->beacon_int;
1070 rtlpriv->cfg->ops->set_bcn_intv(hw);
1074 /*TODO: reference to enum ieee80211_bss_change */
1075 if (changed & BSS_CHANGED_ASSOC) {
1077 if (bss_conf->assoc) {
1078 struct ieee80211_sta *sta = NULL;
1081 mstatus = RT_MEDIA_CONNECT;
1082 /* we should reset all sec info & cam
1083 * before set cam after linked, we should not
1084 * reset in disassoc, that will cause tkip->wep
1085 * fail because some flag will be wrong */
1086 /* reset sec info */
1087 rtl_cam_reset_sec_info(hw);
1088 /* reset cam to fix wep fail issue
1089 * when change from wpa to wep */
1090 rtl_cam_reset_all_entry(hw);
1092 mac->link_state = MAC80211_LINKED;
1093 mac->cnt_after_linked = 0;
1094 mac->assoc_id = bss_conf->aid;
1095 memcpy(mac->bssid, bss_conf->bssid, ETH_ALEN);
1097 if (rtlpriv->cfg->ops->linked_set_reg)
1098 rtlpriv->cfg->ops->linked_set_reg(hw);
1101 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
1106 RT_TRACE(rtlpriv, COMP_EASY_CONCURRENT, DBG_LOUD,
1107 "send PS STATIC frame\n");
1108 if (rtlpriv->dm.supp_phymode_switch) {
1109 if (sta->ht_cap.ht_supported)
1110 rtl_send_smps_action(hw, sta,
1111 IEEE80211_SMPS_STATIC);
1114 if (rtlhal->current_bandtype == BAND_ON_5G) {
1115 mac->mode = WIRELESS_MODE_A;
1117 if (sta->supp_rates[0] <= 0xf)
1118 mac->mode = WIRELESS_MODE_B;
1120 mac->mode = WIRELESS_MODE_G;
1123 if (sta->ht_cap.ht_supported) {
1124 if (rtlhal->current_bandtype == BAND_ON_2_4G)
1125 mac->mode = WIRELESS_MODE_N_24G;
1127 mac->mode = WIRELESS_MODE_N_5G;
1130 if (sta->vht_cap.vht_supported) {
1131 if (rtlhal->current_bandtype == BAND_ON_5G)
1132 mac->mode = WIRELESS_MODE_AC_5G;
1134 mac->mode = WIRELESS_MODE_AC_24G;
1137 if (vif->type == NL80211_IFTYPE_STATION)
1138 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0);
1141 /* to avoid AP Disassociation caused by inactivity */
1142 rtlpriv->cfg->ops->set_hw_reg(hw,
1144 (u8 *)(&keep_alive));
1146 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1147 "BSS_CHANGED_ASSOC\n");
1149 mstatus = RT_MEDIA_DISCONNECT;
1151 if (mac->link_state == MAC80211_LINKED)
1153 if (ppsc->p2p_ps_info.p2p_ps_mode > P2P_PS_NONE)
1154 rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE);
1155 mac->link_state = MAC80211_NOLINK;
1156 eth_zero_addr(mac->bssid);
1157 mac->vendor = PEER_UNKNOWN;
1160 if (rtlpriv->dm.supp_phymode_switch) {
1161 if (rtlpriv->cfg->ops->chk_switch_dmdp)
1162 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
1164 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1165 "BSS_CHANGED_UN_ASSOC\n");
1167 rtlpriv->cfg->ops->set_network_type(hw, vif->type);
1169 * To tell firmware we have connected or disconnected
1171 rtlpriv->cfg->ops->set_hw_reg(hw,
1172 HW_VAR_H2C_FW_JOINBSSRPT,
1174 ppsc->report_linked = (mstatus == RT_MEDIA_CONNECT) ?
1177 if (rtlpriv->cfg->ops->get_btc_status())
1178 rtlpriv->btcoexist.btc_ops->btc_mediastatus_notify(
1182 if (changed & BSS_CHANGED_ERP_CTS_PROT) {
1183 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1184 "BSS_CHANGED_ERP_CTS_PROT\n");
1185 mac->use_cts_protect = bss_conf->use_cts_prot;
1188 if (changed & BSS_CHANGED_ERP_PREAMBLE) {
1189 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
1190 "BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n",
1191 bss_conf->use_short_preamble);
1193 mac->short_preamble = bss_conf->use_short_preamble;
1194 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACK_PREAMBLE,
1195 (u8 *)(&mac->short_preamble));
1198 if (changed & BSS_CHANGED_ERP_SLOT) {
1199 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1200 "BSS_CHANGED_ERP_SLOT\n");
1202 if (bss_conf->use_short_slot)
1203 mac->slot_time = RTL_SLOT_TIME_9;
1205 mac->slot_time = RTL_SLOT_TIME_20;
1207 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME,
1208 (u8 *)(&mac->slot_time));
1211 if (changed & BSS_CHANGED_HT) {
1212 struct ieee80211_sta *sta = NULL;
1214 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1215 "BSS_CHANGED_HT\n");
1218 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
1220 if (sta->ht_cap.ampdu_density >
1221 mac->current_ampdu_density)
1222 mac->current_ampdu_density =
1223 sta->ht_cap.ampdu_density;
1224 if (sta->ht_cap.ampdu_factor <
1225 mac->current_ampdu_factor)
1226 mac->current_ampdu_factor =
1227 sta->ht_cap.ampdu_factor;
1231 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SHORTGI_DENSITY,
1232 (u8 *)(&mac->max_mss_density));
1233 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_FACTOR,
1234 &mac->current_ampdu_factor);
1235 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_MIN_SPACE,
1236 &mac->current_ampdu_density);
1239 if (changed & BSS_CHANGED_BSSID) {
1241 struct ieee80211_sta *sta = NULL;
1243 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BSSID,
1244 (u8 *)bss_conf->bssid);
1246 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1247 "bssid: %pM\n", bss_conf->bssid);
1249 mac->vendor = PEER_UNKNOWN;
1250 memcpy(mac->bssid, bss_conf->bssid, ETH_ALEN);
1253 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
1259 if (rtlhal->current_bandtype == BAND_ON_5G) {
1260 mac->mode = WIRELESS_MODE_A;
1262 if (sta->supp_rates[0] <= 0xf)
1263 mac->mode = WIRELESS_MODE_B;
1265 mac->mode = WIRELESS_MODE_G;
1268 if (sta->ht_cap.ht_supported) {
1269 if (rtlhal->current_bandtype == BAND_ON_2_4G)
1270 mac->mode = WIRELESS_MODE_N_24G;
1272 mac->mode = WIRELESS_MODE_N_5G;
1275 if (sta->vht_cap.vht_supported) {
1276 if (rtlhal->current_bandtype == BAND_ON_5G)
1277 mac->mode = WIRELESS_MODE_AC_5G;
1279 mac->mode = WIRELESS_MODE_AC_24G;
1282 /* just station need it, because ibss & ap mode will
1283 * set in sta_add, and will be NULL here */
1284 if (vif->type == NL80211_IFTYPE_STATION) {
1285 struct rtl_sta_info *sta_entry;
1286 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
1287 sta_entry->wireless_mode = mac->mode;
1290 if (sta->ht_cap.ht_supported) {
1291 mac->ht_enable = true;
1294 * for cisco 1252 bw20 it's wrong
1295 * if (ht_cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
1296 * mac->bw_40 = true;
1301 if (sta->vht_cap.vht_supported)
1302 mac->vht_enable = true;
1304 if (changed & BSS_CHANGED_BASIC_RATES) {
1305 /* for 5G must << RATE_6M_INDEX = 4,
1306 * because 5G have no cck rate*/
1307 if (rtlhal->current_bandtype == BAND_ON_5G)
1308 basic_rates = sta->supp_rates[1] << 4;
1310 basic_rates = sta->supp_rates[0];
1312 mac->basic_rates = basic_rates;
1313 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
1314 (u8 *)(&basic_rates));
1319 mutex_unlock(&rtlpriv->locks.conf_mutex);
1322 static u64 rtl_op_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1324 struct rtl_priv *rtlpriv = rtl_priv(hw);
1327 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *)(&tsf));
1331 static void rtl_op_set_tsf(struct ieee80211_hw *hw,
1332 struct ieee80211_vif *vif, u64 tsf)
1334 struct rtl_priv *rtlpriv = rtl_priv(hw);
1335 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1336 u8 bibss = (mac->opmode == NL80211_IFTYPE_ADHOC) ? 1 : 0;
1339 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *)(&bibss));
1342 static void rtl_op_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1344 struct rtl_priv *rtlpriv = rtl_priv(hw);
1347 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_DUAL_TSF_RST, (u8 *)(&tmp));
1350 static void rtl_op_sta_notify(struct ieee80211_hw *hw,
1351 struct ieee80211_vif *vif,
1352 enum sta_notify_cmd cmd,
1353 struct ieee80211_sta *sta)
1356 case STA_NOTIFY_SLEEP:
1358 case STA_NOTIFY_AWAKE:
1365 static int rtl_op_ampdu_action(struct ieee80211_hw *hw,
1366 struct ieee80211_vif *vif,
1367 struct ieee80211_ampdu_params *params)
1369 struct rtl_priv *rtlpriv = rtl_priv(hw);
1370 struct ieee80211_sta *sta = params->sta;
1371 enum ieee80211_ampdu_mlme_action action = params->action;
1372 u16 tid = params->tid;
1373 u16 *ssn = ¶ms->ssn;
1376 case IEEE80211_AMPDU_TX_START:
1377 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1378 "IEEE80211_AMPDU_TX_START: TID:%d\n", tid);
1379 return rtl_tx_agg_start(hw, vif, sta, tid, ssn);
1380 case IEEE80211_AMPDU_TX_STOP_CONT:
1381 case IEEE80211_AMPDU_TX_STOP_FLUSH:
1382 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
1383 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1384 "IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid);
1385 return rtl_tx_agg_stop(hw, vif, sta, tid);
1386 case IEEE80211_AMPDU_TX_OPERATIONAL:
1387 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1388 "IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid);
1389 rtl_tx_agg_oper(hw, sta, tid);
1391 case IEEE80211_AMPDU_RX_START:
1392 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1393 "IEEE80211_AMPDU_RX_START:TID:%d\n", tid);
1394 return rtl_rx_agg_start(hw, sta, tid);
1395 case IEEE80211_AMPDU_RX_STOP:
1396 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1397 "IEEE80211_AMPDU_RX_STOP:TID:%d\n", tid);
1398 return rtl_rx_agg_stop(hw, sta, tid);
1400 pr_err("IEEE80211_AMPDU_ERR!!!!:\n");
1406 static void rtl_op_sw_scan_start(struct ieee80211_hw *hw,
1407 struct ieee80211_vif *vif,
1410 struct rtl_priv *rtlpriv = rtl_priv(hw);
1411 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1413 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
1414 mac->act_scanning = true;
1415 if (rtlpriv->link_info.higher_busytraffic) {
1416 mac->skip_scan = true;
1420 if (rtlpriv->cfg->ops->get_btc_status())
1421 rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 1);
1423 if (rtlpriv->dm.supp_phymode_switch) {
1424 if (rtlpriv->cfg->ops->chk_switch_dmdp)
1425 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
1428 if (mac->link_state == MAC80211_LINKED) {
1430 mac->link_state = MAC80211_LINKED_SCANNING;
1436 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false;
1438 rtlpriv->cfg->ops->led_control(hw, LED_CTL_SITE_SURVEY);
1439 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_BACKUP_BAND0);
1442 static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw,
1443 struct ieee80211_vif *vif)
1445 struct rtl_priv *rtlpriv = rtl_priv(hw);
1446 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1448 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
1449 mac->act_scanning = false;
1450 mac->skip_scan = false;
1451 if (rtlpriv->link_info.higher_busytraffic)
1454 /* p2p will use 1/6/11 to scan */
1455 if (mac->n_channels == 3)
1456 mac->p2p_in_use = true;
1458 mac->p2p_in_use = false;
1459 mac->n_channels = 0;
1461 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false;
1463 if (mac->link_state == MAC80211_LINKED_SCANNING) {
1464 mac->link_state = MAC80211_LINKED;
1465 if (mac->opmode == NL80211_IFTYPE_STATION) {
1466 /* fix fwlps issue */
1467 rtlpriv->cfg->ops->set_network_type(hw, mac->opmode);
1471 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_RESTORE);
1472 if (rtlpriv->cfg->ops->get_btc_status())
1473 rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 0);
1476 static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1477 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
1478 struct ieee80211_key_conf *key)
1480 struct rtl_priv *rtlpriv = rtl_priv(hw);
1481 u8 key_type = NO_ENCRYPTION;
1483 bool group_key = false;
1484 bool wep_only = false;
1486 u8 mac_addr[ETH_ALEN];
1487 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1489 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) {
1490 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1491 "not open hw encryption\n");
1492 return -ENOSPC; /*User disabled HW-crypto */
1494 /* To support IBSS, use sw-crypto for GTK */
1495 if (((vif->type == NL80211_IFTYPE_ADHOC) ||
1496 (vif->type == NL80211_IFTYPE_MESH_POINT)) &&
1497 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
1499 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1500 "%s hardware based encryption for keyidx: %d, mac: %pM\n",
1501 cmd == SET_KEY ? "Using" : "Disabling", key->keyidx,
1502 sta ? sta->addr : bcast_addr);
1503 rtlpriv->sec.being_setkey = true;
1505 mutex_lock(&rtlpriv->locks.conf_mutex);
1506 /* <1> get encryption alg */
1508 switch (key->cipher) {
1509 case WLAN_CIPHER_SUITE_WEP40:
1510 key_type = WEP40_ENCRYPTION;
1511 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:WEP40\n");
1513 case WLAN_CIPHER_SUITE_WEP104:
1514 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:WEP104\n");
1515 key_type = WEP104_ENCRYPTION;
1517 case WLAN_CIPHER_SUITE_TKIP:
1518 key_type = TKIP_ENCRYPTION;
1519 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:TKIP\n");
1521 case WLAN_CIPHER_SUITE_CCMP:
1522 key_type = AESCCMP_ENCRYPTION;
1523 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CCMP\n");
1525 case WLAN_CIPHER_SUITE_AES_CMAC:
1526 /* HW don't support CMAC encryption,
1527 * use software CMAC encryption
1529 key_type = AESCMAC_ENCRYPTION;
1530 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CMAC\n");
1531 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1532 "HW don't support CMAC encryption, use software CMAC encryption\n");
1536 pr_err("alg_err:%x!!!!:\n", key->cipher);
1539 if (key_type == WEP40_ENCRYPTION ||
1540 key_type == WEP104_ENCRYPTION ||
1541 vif->type == NL80211_IFTYPE_ADHOC)
1542 rtlpriv->sec.use_defaultkey = true;
1544 /* <2> get key_idx */
1545 key_idx = (u8) (key->keyidx);
1548 /* <3> if pairwise key enable_hw_sec */
1549 group_key = !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE);
1551 /* wep always be group key, but there are two conditions:
1552 * 1) wep only: is just for wep enc, in this condition
1553 * rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION
1554 * will be true & enable_hw_sec will be set when wep
1556 * 2) wep(group) + AES(pairwise): some AP like cisco
1557 * may use it, in this condition enable_hw_sec will not
1558 * be set when wep key setting */
1559 /* we must reset sec_info after lingked before set key,
1560 * or some flag will be wrong*/
1561 if (vif->type == NL80211_IFTYPE_AP ||
1562 vif->type == NL80211_IFTYPE_MESH_POINT) {
1563 if (!group_key || key_type == WEP40_ENCRYPTION ||
1564 key_type == WEP104_ENCRYPTION) {
1567 rtlpriv->cfg->ops->enable_hw_sec(hw);
1570 if ((!group_key) || (vif->type == NL80211_IFTYPE_ADHOC) ||
1571 rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION) {
1572 if (rtlpriv->sec.pairwise_enc_algorithm ==
1574 (key_type == WEP40_ENCRYPTION ||
1575 key_type == WEP104_ENCRYPTION))
1577 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1578 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1579 "set enable_hw_sec, key_type:%x(OPEN:0 WEP40:1 TKIP:2 AES:4 WEP104:5)\n",
1581 rtlpriv->cfg->ops->enable_hw_sec(hw);
1584 /* <4> set key based on cmd */
1588 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1589 "set WEP(group/pairwise) key\n");
1590 /* Pairwise key with an assigned MAC address. */
1591 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1592 rtlpriv->sec.group_enc_algorithm = key_type;
1593 /*set local buf about wep key. */
1594 memcpy(rtlpriv->sec.key_buf[key_idx],
1595 key->key, key->keylen);
1596 rtlpriv->sec.key_len[key_idx] = key->keylen;
1597 eth_zero_addr(mac_addr);
1598 } else if (group_key) { /* group key */
1599 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1602 rtlpriv->sec.group_enc_algorithm = key_type;
1603 /*set local buf about group key. */
1604 memcpy(rtlpriv->sec.key_buf[key_idx],
1605 key->key, key->keylen);
1606 rtlpriv->sec.key_len[key_idx] = key->keylen;
1607 memcpy(mac_addr, bcast_addr, ETH_ALEN);
1608 } else { /* pairwise key */
1609 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1610 "set pairwise key\n");
1613 "rtlwifi: pairwise key without mac_addr\n");
1618 /* Pairwise key with an assigned MAC address. */
1619 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1620 /*set local buf about pairwise key. */
1621 memcpy(rtlpriv->sec.key_buf[PAIRWISE_KEYIDX],
1622 key->key, key->keylen);
1623 rtlpriv->sec.key_len[PAIRWISE_KEYIDX] = key->keylen;
1624 rtlpriv->sec.pairwise_key =
1625 rtlpriv->sec.key_buf[PAIRWISE_KEYIDX];
1626 memcpy(mac_addr, sta->addr, ETH_ALEN);
1628 rtlpriv->cfg->ops->set_key(hw, key_idx, mac_addr,
1629 group_key, key_type, wep_only,
1631 /* <5> tell mac80211 do something: */
1632 /*must use sw generate IV, or can not work !!!!. */
1633 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
1634 key->hw_key_idx = key_idx;
1635 if (key_type == TKIP_ENCRYPTION)
1636 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
1637 /*use software CCMP encryption for management frames (MFP) */
1638 if (key_type == AESCCMP_ENCRYPTION)
1639 key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX;
1642 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1643 "disable key delete one entry\n");
1644 /*set local buf about wep key. */
1645 if (vif->type == NL80211_IFTYPE_AP ||
1646 vif->type == NL80211_IFTYPE_MESH_POINT) {
1648 rtl_cam_del_entry(hw, sta->addr);
1650 memset(rtlpriv->sec.key_buf[key_idx], 0, key->keylen);
1651 rtlpriv->sec.key_len[key_idx] = 0;
1652 eth_zero_addr(mac_addr);
1654 *mac80211 will delete entrys one by one,
1655 *so don't use rtl_cam_reset_all_entry
1656 *or clear all entry here.
1658 rtl_cam_delete_one_entry(hw, mac_addr, key_idx);
1661 pr_err("cmd_err:%x!!!!:\n", cmd);
1664 mutex_unlock(&rtlpriv->locks.conf_mutex);
1665 rtlpriv->sec.being_setkey = false;
1669 static void rtl_op_rfkill_poll(struct ieee80211_hw *hw)
1671 struct rtl_priv *rtlpriv = rtl_priv(hw);
1677 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
1680 mutex_lock(&rtlpriv->locks.conf_mutex);
1682 /*if Radio On return true here */
1683 radio_state = rtlpriv->cfg->ops->radio_onoff_checking(hw, &valid);
1686 if (unlikely(radio_state != rtlpriv->rfkill.rfkill_state)) {
1687 rtlpriv->rfkill.rfkill_state = radio_state;
1689 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
1690 "wireless radio switch turned %s\n",
1691 radio_state ? "on" : "off");
1693 blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1;
1694 wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
1698 mutex_unlock(&rtlpriv->locks.conf_mutex);
1701 /* this function is called by mac80211 to flush tx buffer
1702 * before switch channle or power save, or tx buffer packet
1703 * maybe send after offchannel or rf sleep, this may cause
1704 * dis-association by AP */
1705 static void rtl_op_flush(struct ieee80211_hw *hw,
1706 struct ieee80211_vif *vif,
1710 struct rtl_priv *rtlpriv = rtl_priv(hw);
1712 if (rtlpriv->intf_ops->flush)
1713 rtlpriv->intf_ops->flush(hw, queues, drop);
1717 * This routine deals with the Power Configuration CMD
1718 * parsing for RTL8723/RTL8188E Series IC.
1720 * We should follow specific format that was released from HW SD.
1722 bool rtl_hal_pwrseqcmdparsing(struct rtl_priv *rtlpriv, u8 cut_version,
1723 u8 faversion, u8 interface_type,
1724 struct wlan_pwr_cfg pwrcfgcmd[])
1726 struct wlan_pwr_cfg cfg_cmd = {0};
1727 bool polling_bit = false;
1731 u32 polling_count = 0;
1732 u32 max_polling_cnt = 5000;
1735 cfg_cmd = pwrcfgcmd[ary_idx];
1736 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1737 "rtl_hal_pwrseqcmdparsing(): offset(%#x),cut_msk(%#x), famsk(%#x), interface_msk(%#x), base(%#x), cmd(%#x), msk(%#x), value(%#x)\n",
1738 GET_PWR_CFG_OFFSET(cfg_cmd),
1739 GET_PWR_CFG_CUT_MASK(cfg_cmd),
1740 GET_PWR_CFG_FAB_MASK(cfg_cmd),
1741 GET_PWR_CFG_INTF_MASK(cfg_cmd),
1742 GET_PWR_CFG_BASE(cfg_cmd), GET_PWR_CFG_CMD(cfg_cmd),
1743 GET_PWR_CFG_MASK(cfg_cmd), GET_PWR_CFG_VALUE(cfg_cmd));
1745 if ((GET_PWR_CFG_FAB_MASK(cfg_cmd)&faversion) &&
1746 (GET_PWR_CFG_CUT_MASK(cfg_cmd)&cut_version) &&
1747 (GET_PWR_CFG_INTF_MASK(cfg_cmd)&interface_type)) {
1748 switch (GET_PWR_CFG_CMD(cfg_cmd)) {
1750 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1751 "rtl_hal_pwrseqcmdparsing(): PWR_CMD_READ\n");
1754 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1755 "rtl_hal_pwrseqcmdparsing(): PWR_CMD_WRITE\n");
1756 offset = GET_PWR_CFG_OFFSET(cfg_cmd);
1758 /*Read the value from system register*/
1759 value = rtl_read_byte(rtlpriv, offset);
1760 value &= (~(GET_PWR_CFG_MASK(cfg_cmd)));
1761 value |= (GET_PWR_CFG_VALUE(cfg_cmd) &
1762 GET_PWR_CFG_MASK(cfg_cmd));
1764 /*Write the value back to sytem register*/
1765 rtl_write_byte(rtlpriv, offset, value);
1767 case PWR_CMD_POLLING:
1768 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1769 "rtl_hal_pwrseqcmdparsing(): PWR_CMD_POLLING\n");
1770 polling_bit = false;
1771 offset = GET_PWR_CFG_OFFSET(cfg_cmd);
1774 value = rtl_read_byte(rtlpriv, offset);
1776 value &= GET_PWR_CFG_MASK(cfg_cmd);
1778 (GET_PWR_CFG_VALUE(cfg_cmd) &
1779 GET_PWR_CFG_MASK(cfg_cmd)))
1784 if (polling_count++ > max_polling_cnt)
1786 } while (!polling_bit);
1789 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1790 "rtl_hal_pwrseqcmdparsing(): PWR_CMD_DELAY\n");
1791 if (GET_PWR_CFG_VALUE(cfg_cmd) ==
1793 udelay(GET_PWR_CFG_OFFSET(cfg_cmd));
1795 mdelay(GET_PWR_CFG_OFFSET(cfg_cmd));
1798 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1799 "rtl_hal_pwrseqcmdparsing(): PWR_CMD_END\n");
1803 "rtlwifi: rtl_hal_pwrseqcmdparsing(): Unknown CMD!!\n");
1812 EXPORT_SYMBOL(rtl_hal_pwrseqcmdparsing);
1814 bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)
1816 struct rtl_priv *rtlpriv = rtl_priv(hw);
1817 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1818 struct rtl8192_tx_ring *ring;
1819 struct rtl_tx_desc *pdesc;
1820 unsigned long flags;
1821 struct sk_buff *pskb = NULL;
1823 ring = &rtlpci->tx_ring[BEACON_QUEUE];
1825 spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags);
1826 pskb = __skb_dequeue(&ring->queue);
1827 dev_kfree_skb_irq(pskb);
1829 /*this is wrong, fill_tx_cmddesc needs update*/
1830 pdesc = &ring->desc[0];
1832 rtlpriv->cfg->ops->fill_tx_cmddesc(hw, (u8 *)pdesc, 1, 1, skb);
1834 __skb_queue_tail(&ring->queue, skb);
1836 spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags);
1838 rtlpriv->cfg->ops->tx_polling(hw, BEACON_QUEUE);
1842 EXPORT_SYMBOL(rtl_cmd_send_packet);
1843 const struct ieee80211_ops rtl_ops = {
1844 .start = rtl_op_start,
1845 .stop = rtl_op_stop,
1847 .add_interface = rtl_op_add_interface,
1848 .remove_interface = rtl_op_remove_interface,
1849 .change_interface = rtl_op_change_interface,
1851 .suspend = rtl_op_suspend,
1852 .resume = rtl_op_resume,
1854 .config = rtl_op_config,
1855 .configure_filter = rtl_op_configure_filter,
1856 .set_key = rtl_op_set_key,
1857 .conf_tx = rtl_op_conf_tx,
1858 .bss_info_changed = rtl_op_bss_info_changed,
1859 .get_tsf = rtl_op_get_tsf,
1860 .set_tsf = rtl_op_set_tsf,
1861 .reset_tsf = rtl_op_reset_tsf,
1862 .sta_notify = rtl_op_sta_notify,
1863 .ampdu_action = rtl_op_ampdu_action,
1864 .sw_scan_start = rtl_op_sw_scan_start,
1865 .sw_scan_complete = rtl_op_sw_scan_complete,
1866 .rfkill_poll = rtl_op_rfkill_poll,
1867 .sta_add = rtl_op_sta_add,
1868 .sta_remove = rtl_op_sta_remove,
1869 .flush = rtl_op_flush,
1871 EXPORT_SYMBOL_GPL(rtl_ops);
1873 bool rtl_btc_status_false(void)
1877 EXPORT_SYMBOL_GPL(rtl_btc_status_false);
1879 void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igvalue)
1881 struct rtl_priv *rtlpriv = rtl_priv(hw);
1882 struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
1884 dm_digtable->dig_enable_flag = true;
1885 dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
1886 dm_digtable->cur_igvalue = cur_igvalue;
1887 dm_digtable->pre_igvalue = 0;
1888 dm_digtable->cur_sta_cstate = DIG_STA_DISCONNECT;
1889 dm_digtable->presta_cstate = DIG_STA_DISCONNECT;
1890 dm_digtable->curmultista_cstate = DIG_MULTISTA_DISCONNECT;
1891 dm_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
1892 dm_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
1893 dm_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
1894 dm_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
1895 dm_digtable->rx_gain_max = DM_DIG_MAX;
1896 dm_digtable->rx_gain_min = DM_DIG_MIN;
1897 dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
1898 dm_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
1899 dm_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
1900 dm_digtable->pre_cck_cca_thres = 0xff;
1901 dm_digtable->cur_cck_cca_thres = 0x83;
1902 dm_digtable->forbidden_igi = DM_DIG_MIN;
1903 dm_digtable->large_fa_hit = 0;
1904 dm_digtable->recover_cnt = 0;
1905 dm_digtable->dig_min_0 = 0x25;
1906 dm_digtable->dig_min_1 = 0x25;
1907 dm_digtable->media_connect_0 = false;
1908 dm_digtable->media_connect_1 = false;
1909 rtlpriv->dm.dm_initialgain_enable = true;
1910 dm_digtable->bt30_cur_igi = 0x32;
1911 dm_digtable->pre_cck_pd_state = CCK_PD_STAGE_MAX;
1912 dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_LOWRSSI;
1914 EXPORT_SYMBOL(rtl_dm_diginit);