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("Firmware %s not available\n", rtlpriv->cfg->fw_name);
115 rtlpriv->max_fw_size = 0;
119 if (firmware->size > rtlpriv->max_fw_size) {
120 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
121 "Firmware is too big!\n");
122 release_firmware(firmware);
126 memcpy(rtlpriv->rtlhal.pfirmware, firmware->data,
128 rtlpriv->rtlhal.fwsize = firmware->size;
130 memcpy(rtlpriv->rtlhal.wowlan_firmware, firmware->data,
132 rtlpriv->rtlhal.wowlan_fwsize = firmware->size;
134 rtlpriv->rtlhal.fwsize = firmware->size;
135 release_firmware(firmware);
138 void rtl_fw_cb(const struct firmware *firmware, void *context)
140 rtl_fw_do_work(firmware, context, false);
142 EXPORT_SYMBOL(rtl_fw_cb);
144 void rtl_wowlan_fw_cb(const struct firmware *firmware, void *context)
146 rtl_fw_do_work(firmware, context, true);
148 EXPORT_SYMBOL(rtl_wowlan_fw_cb);
150 /*mutex for start & stop is must here. */
151 static int rtl_op_start(struct ieee80211_hw *hw)
154 struct rtl_priv *rtlpriv = rtl_priv(hw);
155 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
157 if (!is_hal_stop(rtlhal))
159 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
161 mutex_lock(&rtlpriv->locks.conf_mutex);
162 err = rtlpriv->intf_ops->adapter_start(hw);
164 rtl_watch_dog_timer_callback((unsigned long)hw);
165 mutex_unlock(&rtlpriv->locks.conf_mutex);
169 static void rtl_op_stop(struct ieee80211_hw *hw)
171 struct rtl_priv *rtlpriv = rtl_priv(hw);
172 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
173 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
174 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
175 bool support_remote_wakeup = false;
177 if (is_hal_stop(rtlhal))
180 rtlpriv->cfg->ops->get_hw_reg(hw, HAL_DEF_WOWLAN,
181 (u8 *)(&support_remote_wakeup));
182 /* here is must, because adhoc do stop and start,
183 * but stop with RFOFF may cause something wrong,
186 if (unlikely(ppsc->rfpwr_state == ERFOFF))
189 mutex_lock(&rtlpriv->locks.conf_mutex);
190 /* if wowlan supported, DON'T clear connected info */
191 if (!(support_remote_wakeup &&
192 rtlhal->enter_pnp_sleep)) {
193 mac->link_state = MAC80211_NOLINK;
194 eth_zero_addr(mac->bssid);
195 mac->vendor = PEER_UNKNOWN;
198 rtl_cam_reset_sec_info(hw);
200 rtl_deinit_deferred_work(hw);
202 rtlpriv->intf_ops->adapter_stop(hw);
204 mutex_unlock(&rtlpriv->locks.conf_mutex);
207 static void rtl_op_tx(struct ieee80211_hw *hw,
208 struct ieee80211_tx_control *control,
211 struct rtl_priv *rtlpriv = rtl_priv(hw);
212 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
213 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
214 struct rtl_tcb_desc tcb_desc;
215 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
217 if (unlikely(is_hal_stop(rtlhal) || ppsc->rfpwr_state != ERFON))
220 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
223 if (!rtlpriv->intf_ops->waitq_insert(hw, control->sta, skb))
224 rtlpriv->intf_ops->adapter_tx(hw, control->sta, skb, &tcb_desc);
228 dev_kfree_skb_any(skb);
231 static int rtl_op_add_interface(struct ieee80211_hw *hw,
232 struct ieee80211_vif *vif)
234 struct rtl_priv *rtlpriv = rtl_priv(hw);
235 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
239 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
240 "vif has been set!! mac->vif = 0x%p\n", mac->vif);
244 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
248 mutex_lock(&rtlpriv->locks.conf_mutex);
249 switch (ieee80211_vif_type_p2p(vif)) {
250 case NL80211_IFTYPE_P2P_CLIENT:
251 mac->p2p = P2P_ROLE_CLIENT;
253 case NL80211_IFTYPE_STATION:
254 if (mac->beacon_enabled == 1) {
255 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
256 "NL80211_IFTYPE_STATION\n");
257 mac->beacon_enabled = 0;
258 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
259 rtlpriv->cfg->maps[RTL_IBSS_INT_MASKS]);
262 case NL80211_IFTYPE_ADHOC:
263 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
264 "NL80211_IFTYPE_ADHOC\n");
266 mac->link_state = MAC80211_LINKED;
267 rtlpriv->cfg->ops->set_bcn_reg(hw);
268 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
269 mac->basic_rates = 0xfff;
271 mac->basic_rates = 0xff0;
272 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
273 (u8 *)(&mac->basic_rates));
276 case NL80211_IFTYPE_P2P_GO:
277 mac->p2p = P2P_ROLE_GO;
279 case NL80211_IFTYPE_AP:
280 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
281 "NL80211_IFTYPE_AP\n");
283 mac->link_state = MAC80211_LINKED;
284 rtlpriv->cfg->ops->set_bcn_reg(hw);
285 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
286 mac->basic_rates = 0xfff;
288 mac->basic_rates = 0xff0;
289 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
290 (u8 *)(&mac->basic_rates));
292 case NL80211_IFTYPE_MESH_POINT:
293 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
294 "NL80211_IFTYPE_MESH_POINT\n");
296 mac->link_state = MAC80211_LINKED;
297 rtlpriv->cfg->ops->set_bcn_reg(hw);
298 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
299 mac->basic_rates = 0xfff;
301 mac->basic_rates = 0xff0;
302 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
303 (u8 *)(&mac->basic_rates));
306 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
307 "operation mode %d is not support!\n", vif->type);
313 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
314 "p2p role %x\n", vif->type);
315 mac->basic_rates = 0xff0;/*disable cck rate for p2p*/
316 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
317 (u8 *)(&mac->basic_rates));
320 mac->opmode = vif->type;
321 rtlpriv->cfg->ops->set_network_type(hw, vif->type);
322 memcpy(mac->mac_addr, vif->addr, ETH_ALEN);
323 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, mac->mac_addr);
326 mutex_unlock(&rtlpriv->locks.conf_mutex);
330 static void rtl_op_remove_interface(struct ieee80211_hw *hw,
331 struct ieee80211_vif *vif)
333 struct rtl_priv *rtlpriv = rtl_priv(hw);
334 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
336 mutex_lock(&rtlpriv->locks.conf_mutex);
338 /* Free beacon resources */
339 if ((vif->type == NL80211_IFTYPE_AP) ||
340 (vif->type == NL80211_IFTYPE_ADHOC) ||
341 (vif->type == NL80211_IFTYPE_MESH_POINT)) {
342 if (mac->beacon_enabled == 1) {
343 mac->beacon_enabled = 0;
344 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
345 rtlpriv->cfg->maps[RTL_IBSS_INT_MASKS]);
350 *Note: We assume NL80211_IFTYPE_UNSPECIFIED as
351 *NO LINK for our hardware.
355 mac->link_state = MAC80211_NOLINK;
356 eth_zero_addr(mac->bssid);
357 mac->vendor = PEER_UNKNOWN;
358 mac->opmode = NL80211_IFTYPE_UNSPECIFIED;
359 rtlpriv->cfg->ops->set_network_type(hw, mac->opmode);
361 mutex_unlock(&rtlpriv->locks.conf_mutex);
363 static int rtl_op_change_interface(struct ieee80211_hw *hw,
364 struct ieee80211_vif *vif,
365 enum nl80211_iftype new_type, bool p2p)
367 struct rtl_priv *rtlpriv = rtl_priv(hw);
369 rtl_op_remove_interface(hw, vif);
371 vif->type = new_type;
373 ret = rtl_op_add_interface(hw, vif);
374 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
380 static u16 crc16_ccitt(u8 data, u16 crc)
382 u8 shift_in, data_bit, crc_bit11, crc_bit4, crc_bit15;
386 for (i = 0; i < 8; i++) {
387 crc_bit15 = ((crc & BIT(15)) ? 1 : 0);
388 data_bit = (data & (BIT(0) << i) ? 1 : 0);
389 shift_in = crc_bit15 ^ data_bit;
397 crc_bit11 = ((crc & BIT(11)) ? 1 : 0) ^ shift_in;
399 result &= (~BIT(12));
403 crc_bit4 = ((crc & BIT(4)) ? 1 : 0) ^ shift_in;
415 static u16 _calculate_wol_pattern_crc(u8 *pattern, u16 len)
420 for (i = 0; i < len; i++)
421 crc = crc16_ccitt(pattern[i], crc);
428 static void _rtl_add_wowlan_patterns(struct ieee80211_hw *hw,
429 struct cfg80211_wowlan *wow)
431 struct rtl_priv *rtlpriv = rtl_priv(hw);
432 struct rtl_mac *mac = &rtlpriv->mac80211;
433 struct cfg80211_pkt_pattern *patterns = wow->patterns;
434 struct rtl_wow_pattern rtl_pattern;
435 const u8 *pattern_os, *mask_os;
436 u8 mask[MAX_WOL_BIT_MASK_SIZE] = {0};
437 u8 content[MAX_WOL_PATTERN_SIZE] = {0};
438 u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
439 u8 multicast_addr1[2] = {0x33, 0x33};
440 u8 multicast_addr2[3] = {0x01, 0x00, 0x5e};
444 for (i = 0; i < wow->n_patterns; i++) {
445 memset(&rtl_pattern, 0, sizeof(struct rtl_wow_pattern));
446 memset(mask, 0, MAX_WOL_BIT_MASK_SIZE);
447 if (patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) {
448 RT_TRACE(rtlpriv, COMP_POWER, DBG_WARNING,
449 "Pattern[%d] is too long\n", i);
452 pattern_os = patterns[i].pattern;
453 mask_len = DIV_ROUND_UP(patterns[i].pattern_len, 8);
454 mask_os = patterns[i].mask;
455 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
456 "pattern content\n", pattern_os,
457 patterns[i].pattern_len);
458 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
459 "mask content\n", mask_os, mask_len);
460 /* 1. unicast? multicast? or broadcast? */
461 if (memcmp(pattern_os, broadcast_addr, 6) == 0)
462 rtl_pattern.type = BROADCAST_PATTERN;
463 else if (memcmp(pattern_os, multicast_addr1, 2) == 0 ||
464 memcmp(pattern_os, multicast_addr2, 3) == 0)
465 rtl_pattern.type = MULTICAST_PATTERN;
466 else if (memcmp(pattern_os, mac->mac_addr, 6) == 0)
467 rtl_pattern.type = UNICAST_PATTERN;
469 rtl_pattern.type = UNKNOWN_TYPE;
471 /* 2. translate mask_from_os to mask_for_hw */
473 /******************************************************************************
474 * pattern from OS uses 'ethenet frame', like this:
476 | 6 | 6 | 2 | 20 | Variable | 4 |
477 |--------+--------+------+-----------+------------+-----|
478 | 802.3 Mac Header | IP Header | TCP Packet | FCS |
481 * BUT, packet catched by our HW is in '802.11 frame', begin from LLC,
483 | 24 or 30 | 6 | 2 | 20 | Variable | 4 |
484 |-------------------+--------+------+-----------+------------+-----|
485 | 802.11 MAC Header | LLC | IP Header | TCP Packet | FCS |
488 * Therefore, we need translate mask_from_OS to mask_to_hw.
489 * We should left-shift mask by 6 bits, then set the new bit[0~5] = 0,
490 * because new mask[0~5] means 'SA', but our HW packet begins from LLC,
491 * bit[0~5] corresponds to first 6 Bytes in LLC, they just don't match.
492 ******************************************************************************/
495 for (j = 0; j < mask_len - 1; j++) {
496 mask[j] = mask_os[j] >> 6;
497 mask[j] |= (mask_os[j + 1] & 0x3F) << 2;
499 mask[j] = (mask_os[j] >> 6) & 0x3F;
500 /* Set bit 0-5 to zero */
503 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
504 "mask to hw\n", mask, mask_len);
505 for (j = 0; j < (MAX_WOL_BIT_MASK_SIZE + 1) / 4; j++) {
506 rtl_pattern.mask[j] = mask[j * 4];
507 rtl_pattern.mask[j] |= (mask[j * 4 + 1] << 8);
508 rtl_pattern.mask[j] |= (mask[j * 4 + 2] << 16);
509 rtl_pattern.mask[j] |= (mask[j * 4 + 3] << 24);
512 /* To get the wake up pattern from the mask.
513 * We do not count first 12 bits which means
514 * DA[6] and SA[6] in the pattern to match HW design.
517 for (j = 12; j < patterns[i].pattern_len; j++) {
518 if ((mask_os[j / 8] >> (j % 8)) & 0x01) {
519 content[len] = pattern_os[j];
524 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
525 "pattern to hw\n", content, len);
526 /* 3. calculate crc */
527 rtl_pattern.crc = _calculate_wol_pattern_crc(content, len);
528 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE,
529 "CRC_Remainder = 0x%x\n", rtl_pattern.crc);
531 /* 4. write crc & mask_for_hw to hw */
532 rtlpriv->cfg->ops->add_wowlan_pattern(hw, &rtl_pattern, i);
534 rtl_write_byte(rtlpriv, 0x698, wow->n_patterns);
537 static int rtl_op_suspend(struct ieee80211_hw *hw,
538 struct cfg80211_wowlan *wow)
540 struct rtl_priv *rtlpriv = rtl_priv(hw);
541 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
542 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
545 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n");
549 /* to resolve s4 can not wake up*/
550 do_gettimeofday(&ts);
551 rtlhal->last_suspend_sec = ts.tv_sec;
553 if ((ppsc->wo_wlan_mode & WAKE_ON_PATTERN_MATCH) && wow->n_patterns)
554 _rtl_add_wowlan_patterns(hw, wow);
556 rtlhal->driver_is_goingto_unload = true;
557 rtlhal->enter_pnp_sleep = true;
561 device_set_wakeup_enable(wiphy_dev(hw->wiphy), true);
565 static int rtl_op_resume(struct ieee80211_hw *hw)
567 struct rtl_priv *rtlpriv = rtl_priv(hw);
568 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
569 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
572 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n");
573 rtlhal->driver_is_goingto_unload = false;
574 rtlhal->enter_pnp_sleep = false;
575 rtlhal->wake_from_pnp_sleep = true;
577 /* to resovle s4 can not wake up*/
578 do_gettimeofday(&ts);
579 if (ts.tv_sec - rtlhal->last_suspend_sec < 5)
583 device_set_wakeup_enable(wiphy_dev(hw->wiphy), false);
584 ieee80211_resume_disconnect(mac->vif);
585 rtlhal->wake_from_pnp_sleep = false;
590 static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
592 struct rtl_priv *rtlpriv = rtl_priv(hw);
593 struct rtl_phy *rtlphy = &(rtlpriv->phy);
594 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
595 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
596 struct ieee80211_conf *conf = &hw->conf;
601 mutex_lock(&rtlpriv->locks.conf_mutex);
602 if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { /* BIT(2)*/
603 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
604 "IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n");
608 if (changed & IEEE80211_CONF_CHANGE_IDLE) {
609 if (hw->conf.flags & IEEE80211_CONF_IDLE)
615 *although rfoff may not cause by ips, but we will
616 *check the reason in set_rf_power_state function
618 if (unlikely(ppsc->rfpwr_state == ERFOFF))
623 if (changed & IEEE80211_CONF_CHANGE_PS) {
624 cancel_delayed_work(&rtlpriv->works.ps_work);
625 cancel_delayed_work(&rtlpriv->works.ps_rfon_wq);
626 if (conf->flags & IEEE80211_CONF_PS) {
627 rtlpriv->psc.sw_ps_enabled = true;
628 /* sleep here is must, or we may recv the beacon and
629 * cause mac80211 into wrong ps state, this will cause
630 * power save nullfunc send fail, and further cause
631 * pkt loss, So sleep must quickly but not immediatly
632 * because that will cause nullfunc send by mac80211
633 * fail, and cause pkt loss, we have tested that 5mA
634 * is worked very well */
635 if (!rtlpriv->psc.multi_buffered)
636 queue_delayed_work(rtlpriv->works.rtl_wq,
637 &rtlpriv->works.ps_work,
640 rtl_swlps_rf_awake(hw);
641 rtlpriv->psc.sw_ps_enabled = false;
645 if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) {
646 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
647 "IEEE80211_CONF_CHANGE_RETRY_LIMITS %x\n",
648 hw->conf.long_frame_max_tx_count);
649 mac->retry_long = hw->conf.long_frame_max_tx_count;
650 mac->retry_short = hw->conf.long_frame_max_tx_count;
651 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
652 (u8 *)(&hw->conf.long_frame_max_tx_count));
655 if (changed & IEEE80211_CONF_CHANGE_CHANNEL &&
656 !rtlpriv->proximity.proxim_on) {
657 struct ieee80211_channel *channel = hw->conf.chandef.chan;
658 enum nl80211_chan_width width = hw->conf.chandef.width;
659 enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT;
660 u8 wide_chan = (u8) channel->hw_value;
662 /* channel_type is for 20&40M */
663 if (width < NL80211_CHAN_WIDTH_80)
665 cfg80211_get_chandef_type(&hw->conf.chandef);
666 if (mac->act_scanning)
669 if (rtlpriv->dm.supp_phymode_switch &&
670 mac->link_state < MAC80211_LINKED &&
671 !mac->act_scanning) {
672 if (rtlpriv->cfg->ops->chk_switch_dmdp)
673 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
677 *because we should back channel to
678 *current_network.chan in in scanning,
679 *So if set_chan == current_network.chan
681 *because mac80211 tell us wrong bw40
682 *info for cisco1253 bw20, so we modify
683 *it here based on UPPER & LOWER
686 if (width >= NL80211_CHAN_WIDTH_80) {
687 if (width == NL80211_CHAN_WIDTH_80) {
688 u32 center = hw->conf.chandef.center_freq1;
690 (u32)hw->conf.chandef.chan->center_freq;
692 rtlphy->current_chan_bw =
696 if (center > primary) {
697 mac->cur_80_prime_sc =
698 PRIME_CHNL_OFFSET_LOWER;
699 if (center - primary == 10) {
700 mac->cur_40_prime_sc =
701 PRIME_CHNL_OFFSET_UPPER;
704 } else if (center - primary == 30) {
705 mac->cur_40_prime_sc =
706 PRIME_CHNL_OFFSET_LOWER;
711 mac->cur_80_prime_sc =
712 PRIME_CHNL_OFFSET_UPPER;
713 if (primary - center == 10) {
714 mac->cur_40_prime_sc =
715 PRIME_CHNL_OFFSET_LOWER;
718 } else if (primary - center == 30) {
719 mac->cur_40_prime_sc =
720 PRIME_CHNL_OFFSET_UPPER;
727 switch (channel_type) {
728 case NL80211_CHAN_HT20:
729 case NL80211_CHAN_NO_HT:
731 mac->cur_40_prime_sc =
732 PRIME_CHNL_OFFSET_DONT_CARE;
733 rtlphy->current_chan_bw =
738 case NL80211_CHAN_HT40MINUS:
740 mac->cur_40_prime_sc =
741 PRIME_CHNL_OFFSET_UPPER;
742 rtlphy->current_chan_bw =
743 HT_CHANNEL_WIDTH_20_40;
751 case NL80211_CHAN_HT40PLUS:
753 mac->cur_40_prime_sc =
754 PRIME_CHNL_OFFSET_LOWER;
755 rtlphy->current_chan_bw =
756 HT_CHANNEL_WIDTH_20_40;
767 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
768 "switch case %#x not processed\n",
777 /* In scanning, when before we offchannel we may send a ps=1
778 * null to AP, and then we may send a ps = 0 null to AP quickly,
779 * but first null may have caused AP to put lots of packet to
780 * hw tx buffer. These packets must be tx'd before we go off
781 * channel so we must delay more time to let AP flush these
782 * packets before going offchannel, or dis-association or
783 * delete BA will be caused by AP
785 if (rtlpriv->mac80211.offchan_delay) {
786 rtlpriv->mac80211.offchan_delay = false;
790 rtlphy->current_channel = wide_chan;
792 rtlpriv->cfg->ops->switch_channel(hw);
793 rtlpriv->cfg->ops->set_channel_access(hw);
794 rtlpriv->cfg->ops->set_bw_mode(hw, channel_type);
797 mutex_unlock(&rtlpriv->locks.conf_mutex);
802 static void rtl_op_configure_filter(struct ieee80211_hw *hw,
803 unsigned int changed_flags,
804 unsigned int *new_flags, u64 multicast)
806 bool update_rcr = false;
807 struct rtl_priv *rtlpriv = rtl_priv(hw);
808 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
810 *new_flags &= RTL_SUPPORTED_FILTERS;
811 if (0 == changed_flags)
814 /*TODO: we disable broadcase now, so enable here */
815 if (changed_flags & FIF_ALLMULTI) {
816 if (*new_flags & FIF_ALLMULTI) {
817 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AM] |
818 rtlpriv->cfg->maps[MAC_RCR_AB];
819 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
820 "Enable receive multicast frame\n");
822 mac->rx_conf &= ~(rtlpriv->cfg->maps[MAC_RCR_AM] |
823 rtlpriv->cfg->maps[MAC_RCR_AB]);
824 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
825 "Disable receive multicast frame\n");
830 if (changed_flags & FIF_FCSFAIL) {
831 if (*new_flags & FIF_FCSFAIL) {
832 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACRC32];
833 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
834 "Enable receive FCS error frame\n");
836 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACRC32];
837 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
838 "Disable receive FCS error frame\n");
844 /* if ssid not set to hw don't check bssid
845 * here just used for linked scanning, & linked
846 * and nolink check bssid is set in set network_type
848 if ((changed_flags & FIF_BCN_PRBRESP_PROMISC) &&
849 (mac->link_state >= MAC80211_LINKED)) {
850 if (mac->opmode != NL80211_IFTYPE_AP &&
851 mac->opmode != NL80211_IFTYPE_MESH_POINT) {
852 if (*new_flags & FIF_BCN_PRBRESP_PROMISC)
853 rtlpriv->cfg->ops->set_chk_bssid(hw, false);
855 rtlpriv->cfg->ops->set_chk_bssid(hw, true);
861 if (changed_flags & FIF_CONTROL) {
862 if (*new_flags & FIF_CONTROL) {
863 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACF];
865 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
866 "Enable receive control frame.\n");
868 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACF];
869 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
870 "Disable receive control frame.\n");
876 if (changed_flags & FIF_OTHER_BSS) {
877 if (*new_flags & FIF_OTHER_BSS) {
878 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AAP];
879 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
880 "Enable receive other BSS's frame.\n");
882 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_AAP];
883 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
884 "Disable receive other BSS's frame.\n");
891 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR,
892 (u8 *)(&mac->rx_conf));
894 static int rtl_op_sta_add(struct ieee80211_hw *hw,
895 struct ieee80211_vif *vif,
896 struct ieee80211_sta *sta)
898 struct rtl_priv *rtlpriv = rtl_priv(hw);
899 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
900 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
901 struct rtl_sta_info *sta_entry;
904 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
905 spin_lock_bh(&rtlpriv->locks.entry_list_lock);
906 list_add_tail(&sta_entry->list, &rtlpriv->entry_list);
907 spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
908 if (rtlhal->current_bandtype == BAND_ON_2_4G) {
909 sta_entry->wireless_mode = WIRELESS_MODE_G;
910 if (sta->supp_rates[0] <= 0xf)
911 sta_entry->wireless_mode = WIRELESS_MODE_B;
912 if (sta->ht_cap.ht_supported)
913 sta_entry->wireless_mode = WIRELESS_MODE_N_24G;
915 if (vif->type == NL80211_IFTYPE_ADHOC)
916 sta_entry->wireless_mode = WIRELESS_MODE_G;
917 } else if (rtlhal->current_bandtype == BAND_ON_5G) {
918 sta_entry->wireless_mode = WIRELESS_MODE_A;
919 if (sta->ht_cap.ht_supported)
920 sta_entry->wireless_mode = WIRELESS_MODE_N_5G;
921 if (sta->vht_cap.vht_supported)
922 sta_entry->wireless_mode = WIRELESS_MODE_AC_5G;
924 if (vif->type == NL80211_IFTYPE_ADHOC)
925 sta_entry->wireless_mode = WIRELESS_MODE_A;
927 /*disable cck rate for p2p*/
929 sta->supp_rates[0] &= 0xfffffff0;
931 memcpy(sta_entry->mac_addr, sta->addr, ETH_ALEN);
932 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
933 "Add sta addr is %pM\n", sta->addr);
934 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0);
940 static int rtl_op_sta_remove(struct ieee80211_hw *hw,
941 struct ieee80211_vif *vif,
942 struct ieee80211_sta *sta)
944 struct rtl_priv *rtlpriv = rtl_priv(hw);
945 struct rtl_sta_info *sta_entry;
947 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
948 "Remove sta addr is %pM\n", sta->addr);
949 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
950 sta_entry->wireless_mode = 0;
951 sta_entry->ratr_index = 0;
952 spin_lock_bh(&rtlpriv->locks.entry_list_lock);
953 list_del(&sta_entry->list);
954 spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
958 static int _rtl_get_hal_qnum(u16 queue)
983 *for mac80211 VO = 0, VI = 1, BE = 2, BK = 3
984 *for rtl819x BE = 0, BK = 1, VI = 2, VO = 3
986 static int rtl_op_conf_tx(struct ieee80211_hw *hw,
987 struct ieee80211_vif *vif, u16 queue,
988 const struct ieee80211_tx_queue_params *param)
990 struct rtl_priv *rtlpriv = rtl_priv(hw);
991 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
994 if (queue >= AC_MAX) {
995 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
996 "queue number %d is incorrect!\n", queue);
1000 aci = _rtl_get_hal_qnum(queue);
1001 mac->ac[aci].aifs = param->aifs;
1002 mac->ac[aci].cw_min = cpu_to_le16(param->cw_min);
1003 mac->ac[aci].cw_max = cpu_to_le16(param->cw_max);
1004 mac->ac[aci].tx_op = cpu_to_le16(param->txop);
1005 memcpy(&mac->edca_param[aci], param, sizeof(*param));
1006 rtlpriv->cfg->ops->set_qos(hw, aci);
1010 static void send_beacon_frame(struct ieee80211_hw *hw,
1011 struct ieee80211_vif *vif)
1013 struct rtl_priv *rtlpriv = rtl_priv(hw);
1014 struct sk_buff *skb = ieee80211_beacon_get(hw, vif);
1015 struct rtl_tcb_desc tcb_desc;
1018 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
1019 rtlpriv->intf_ops->adapter_tx(hw, NULL, skb, &tcb_desc);
1023 static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
1024 struct ieee80211_vif *vif,
1025 struct ieee80211_bss_conf *bss_conf,
1028 struct rtl_priv *rtlpriv = rtl_priv(hw);
1029 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
1030 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1031 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
1033 mutex_lock(&rtlpriv->locks.conf_mutex);
1034 if ((vif->type == NL80211_IFTYPE_ADHOC) ||
1035 (vif->type == NL80211_IFTYPE_AP) ||
1036 (vif->type == NL80211_IFTYPE_MESH_POINT)) {
1037 if ((changed & BSS_CHANGED_BEACON) ||
1038 (changed & BSS_CHANGED_BEACON_ENABLED &&
1039 bss_conf->enable_beacon)) {
1040 if (mac->beacon_enabled == 0) {
1041 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1042 "BSS_CHANGED_BEACON_ENABLED\n");
1044 /*start hw beacon interrupt. */
1045 /*rtlpriv->cfg->ops->set_bcn_reg(hw); */
1046 mac->beacon_enabled = 1;
1047 rtlpriv->cfg->ops->update_interrupt_mask(hw,
1049 [RTL_IBSS_INT_MASKS], 0);
1051 if (rtlpriv->cfg->ops->linked_set_reg)
1052 rtlpriv->cfg->ops->linked_set_reg(hw);
1053 send_beacon_frame(hw, vif);
1056 if ((changed & BSS_CHANGED_BEACON_ENABLED &&
1057 !bss_conf->enable_beacon)) {
1058 if (mac->beacon_enabled == 1) {
1059 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1060 "ADHOC DISABLE BEACON\n");
1062 mac->beacon_enabled = 0;
1063 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
1065 [RTL_IBSS_INT_MASKS]);
1068 if (changed & BSS_CHANGED_BEACON_INT) {
1069 RT_TRACE(rtlpriv, COMP_BEACON, DBG_TRACE,
1070 "BSS_CHANGED_BEACON_INT\n");
1071 mac->beacon_interval = bss_conf->beacon_int;
1072 rtlpriv->cfg->ops->set_bcn_intv(hw);
1076 /*TODO: reference to enum ieee80211_bss_change */
1077 if (changed & BSS_CHANGED_ASSOC) {
1079 if (bss_conf->assoc) {
1080 struct ieee80211_sta *sta = NULL;
1083 mstatus = RT_MEDIA_CONNECT;
1084 /* we should reset all sec info & cam
1085 * before set cam after linked, we should not
1086 * reset in disassoc, that will cause tkip->wep
1087 * fail because some flag will be wrong */
1088 /* reset sec info */
1089 rtl_cam_reset_sec_info(hw);
1090 /* reset cam to fix wep fail issue
1091 * when change from wpa to wep */
1092 rtl_cam_reset_all_entry(hw);
1094 mac->link_state = MAC80211_LINKED;
1095 mac->cnt_after_linked = 0;
1096 mac->assoc_id = bss_conf->aid;
1097 memcpy(mac->bssid, bss_conf->bssid, ETH_ALEN);
1099 if (rtlpriv->cfg->ops->linked_set_reg)
1100 rtlpriv->cfg->ops->linked_set_reg(hw);
1103 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
1108 RT_TRACE(rtlpriv, COMP_EASY_CONCURRENT, DBG_LOUD,
1109 "send PS STATIC frame\n");
1110 if (rtlpriv->dm.supp_phymode_switch) {
1111 if (sta->ht_cap.ht_supported)
1112 rtl_send_smps_action(hw, sta,
1113 IEEE80211_SMPS_STATIC);
1116 if (rtlhal->current_bandtype == BAND_ON_5G) {
1117 mac->mode = WIRELESS_MODE_A;
1119 if (sta->supp_rates[0] <= 0xf)
1120 mac->mode = WIRELESS_MODE_B;
1122 mac->mode = WIRELESS_MODE_G;
1125 if (sta->ht_cap.ht_supported) {
1126 if (rtlhal->current_bandtype == BAND_ON_2_4G)
1127 mac->mode = WIRELESS_MODE_N_24G;
1129 mac->mode = WIRELESS_MODE_N_5G;
1132 if (sta->vht_cap.vht_supported) {
1133 if (rtlhal->current_bandtype == BAND_ON_5G)
1134 mac->mode = WIRELESS_MODE_AC_5G;
1136 mac->mode = WIRELESS_MODE_AC_24G;
1139 if (vif->type == NL80211_IFTYPE_STATION)
1140 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 mstatus = RT_MEDIA_DISCONNECT;
1153 if (mac->link_state == MAC80211_LINKED) {
1154 rtlpriv->enter_ps = false;
1155 schedule_work(&rtlpriv->works.lps_change_work);
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;
1160 eth_zero_addr(mac->bssid);
1161 mac->vendor = PEER_UNKNOWN;
1164 if (rtlpriv->dm.supp_phymode_switch) {
1165 if (rtlpriv->cfg->ops->chk_switch_dmdp)
1166 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
1168 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1169 "BSS_CHANGED_UN_ASSOC\n");
1171 rtlpriv->cfg->ops->set_network_type(hw, vif->type);
1173 * To tell firmware we have connected or disconnected
1175 rtlpriv->cfg->ops->set_hw_reg(hw,
1176 HW_VAR_H2C_FW_JOINBSSRPT,
1178 ppsc->report_linked = (mstatus == RT_MEDIA_CONNECT) ?
1181 if (rtlpriv->cfg->ops->get_btc_status())
1182 rtlpriv->btcoexist.btc_ops->btc_mediastatus_notify(
1186 if (changed & BSS_CHANGED_ERP_CTS_PROT) {
1187 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1188 "BSS_CHANGED_ERP_CTS_PROT\n");
1189 mac->use_cts_protect = bss_conf->use_cts_prot;
1192 if (changed & BSS_CHANGED_ERP_PREAMBLE) {
1193 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
1194 "BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n",
1195 bss_conf->use_short_preamble);
1197 mac->short_preamble = bss_conf->use_short_preamble;
1198 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACK_PREAMBLE,
1199 (u8 *)(&mac->short_preamble));
1202 if (changed & BSS_CHANGED_ERP_SLOT) {
1203 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1204 "BSS_CHANGED_ERP_SLOT\n");
1206 if (bss_conf->use_short_slot)
1207 mac->slot_time = RTL_SLOT_TIME_9;
1209 mac->slot_time = RTL_SLOT_TIME_20;
1211 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME,
1212 (u8 *)(&mac->slot_time));
1215 if (changed & BSS_CHANGED_HT) {
1216 struct ieee80211_sta *sta = NULL;
1218 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1219 "BSS_CHANGED_HT\n");
1222 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
1224 if (sta->ht_cap.ampdu_density >
1225 mac->current_ampdu_density)
1226 mac->current_ampdu_density =
1227 sta->ht_cap.ampdu_density;
1228 if (sta->ht_cap.ampdu_factor <
1229 mac->current_ampdu_factor)
1230 mac->current_ampdu_factor =
1231 sta->ht_cap.ampdu_factor;
1235 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SHORTGI_DENSITY,
1236 (u8 *)(&mac->max_mss_density));
1237 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_FACTOR,
1238 &mac->current_ampdu_factor);
1239 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_MIN_SPACE,
1240 &mac->current_ampdu_density);
1243 if (changed & BSS_CHANGED_BSSID) {
1245 struct ieee80211_sta *sta = NULL;
1247 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BSSID,
1248 (u8 *)bss_conf->bssid);
1250 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1251 "bssid: %pM\n", bss_conf->bssid);
1253 mac->vendor = PEER_UNKNOWN;
1254 memcpy(mac->bssid, bss_conf->bssid, ETH_ALEN);
1257 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
1263 if (rtlhal->current_bandtype == BAND_ON_5G) {
1264 mac->mode = WIRELESS_MODE_A;
1266 if (sta->supp_rates[0] <= 0xf)
1267 mac->mode = WIRELESS_MODE_B;
1269 mac->mode = WIRELESS_MODE_G;
1272 if (sta->ht_cap.ht_supported) {
1273 if (rtlhal->current_bandtype == BAND_ON_2_4G)
1274 mac->mode = WIRELESS_MODE_N_24G;
1276 mac->mode = WIRELESS_MODE_N_5G;
1279 if (sta->vht_cap.vht_supported) {
1280 if (rtlhal->current_bandtype == BAND_ON_5G)
1281 mac->mode = WIRELESS_MODE_AC_5G;
1283 mac->mode = WIRELESS_MODE_AC_24G;
1286 /* just station need it, because ibss & ap mode will
1287 * set in sta_add, and will be NULL here */
1288 if (vif->type == NL80211_IFTYPE_STATION) {
1289 struct rtl_sta_info *sta_entry;
1290 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
1291 sta_entry->wireless_mode = mac->mode;
1294 if (sta->ht_cap.ht_supported) {
1295 mac->ht_enable = true;
1298 * for cisco 1252 bw20 it's wrong
1299 * if (ht_cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
1300 * mac->bw_40 = true;
1305 if (sta->vht_cap.vht_supported)
1306 mac->vht_enable = true;
1308 if (changed & BSS_CHANGED_BASIC_RATES) {
1309 /* for 5G must << RATE_6M_INDEX = 4,
1310 * because 5G have no cck rate*/
1311 if (rtlhal->current_bandtype == BAND_ON_5G)
1312 basic_rates = sta->supp_rates[1] << 4;
1314 basic_rates = sta->supp_rates[0];
1316 mac->basic_rates = basic_rates;
1317 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
1318 (u8 *)(&basic_rates));
1323 mutex_unlock(&rtlpriv->locks.conf_mutex);
1326 static u64 rtl_op_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1328 struct rtl_priv *rtlpriv = rtl_priv(hw);
1331 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *)(&tsf));
1335 static void rtl_op_set_tsf(struct ieee80211_hw *hw,
1336 struct ieee80211_vif *vif, u64 tsf)
1338 struct rtl_priv *rtlpriv = rtl_priv(hw);
1339 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1340 u8 bibss = (mac->opmode == NL80211_IFTYPE_ADHOC) ? 1 : 0;
1343 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *)(&bibss));
1346 static void rtl_op_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1348 struct rtl_priv *rtlpriv = rtl_priv(hw);
1351 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_DUAL_TSF_RST, (u8 *)(&tmp));
1354 static void rtl_op_sta_notify(struct ieee80211_hw *hw,
1355 struct ieee80211_vif *vif,
1356 enum sta_notify_cmd cmd,
1357 struct ieee80211_sta *sta)
1360 case STA_NOTIFY_SLEEP:
1362 case STA_NOTIFY_AWAKE:
1369 static int rtl_op_ampdu_action(struct ieee80211_hw *hw,
1370 struct ieee80211_vif *vif,
1371 struct ieee80211_ampdu_params *params)
1373 struct rtl_priv *rtlpriv = rtl_priv(hw);
1374 struct ieee80211_sta *sta = params->sta;
1375 enum ieee80211_ampdu_mlme_action action = params->action;
1376 u16 tid = params->tid;
1377 u16 *ssn = ¶ms->ssn;
1380 case IEEE80211_AMPDU_TX_START:
1381 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1382 "IEEE80211_AMPDU_TX_START: TID:%d\n", tid);
1383 return rtl_tx_agg_start(hw, vif, sta, tid, ssn);
1384 case IEEE80211_AMPDU_TX_STOP_CONT:
1385 case IEEE80211_AMPDU_TX_STOP_FLUSH:
1386 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
1387 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1388 "IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid);
1389 return rtl_tx_agg_stop(hw, vif, sta, tid);
1390 case IEEE80211_AMPDU_TX_OPERATIONAL:
1391 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1392 "IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid);
1393 rtl_tx_agg_oper(hw, sta, tid);
1395 case IEEE80211_AMPDU_RX_START:
1396 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1397 "IEEE80211_AMPDU_RX_START:TID:%d\n", tid);
1398 return rtl_rx_agg_start(hw, sta, tid);
1399 case IEEE80211_AMPDU_RX_STOP:
1400 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1401 "IEEE80211_AMPDU_RX_STOP:TID:%d\n", tid);
1402 return rtl_rx_agg_stop(hw, sta, tid);
1404 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1405 "IEEE80211_AMPDU_ERR!!!!:\n");
1411 static void rtl_op_sw_scan_start(struct ieee80211_hw *hw,
1412 struct ieee80211_vif *vif,
1415 struct rtl_priv *rtlpriv = rtl_priv(hw);
1416 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1418 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
1419 mac->act_scanning = true;
1420 if (rtlpriv->link_info.higher_busytraffic) {
1421 mac->skip_scan = true;
1425 if (rtlpriv->cfg->ops->get_btc_status())
1426 rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 1);
1428 if (rtlpriv->dm.supp_phymode_switch) {
1429 if (rtlpriv->cfg->ops->chk_switch_dmdp)
1430 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
1433 if (mac->link_state == MAC80211_LINKED) {
1434 rtlpriv->enter_ps = false;
1435 schedule_work(&rtlpriv->works.lps_change_work);
1436 mac->link_state = MAC80211_LINKED_SCANNING;
1442 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false;
1444 rtlpriv->cfg->ops->led_control(hw, LED_CTL_SITE_SURVEY);
1445 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_BACKUP_BAND0);
1448 static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw,
1449 struct ieee80211_vif *vif)
1451 struct rtl_priv *rtlpriv = rtl_priv(hw);
1452 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1454 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
1455 mac->act_scanning = false;
1456 mac->skip_scan = false;
1457 if (rtlpriv->link_info.higher_busytraffic)
1460 /* p2p will use 1/6/11 to scan */
1461 if (mac->n_channels == 3)
1462 mac->p2p_in_use = true;
1464 mac->p2p_in_use = false;
1465 mac->n_channels = 0;
1467 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false;
1469 if (mac->link_state == MAC80211_LINKED_SCANNING) {
1470 mac->link_state = MAC80211_LINKED;
1471 if (mac->opmode == NL80211_IFTYPE_STATION) {
1472 /* fix fwlps issue */
1473 rtlpriv->cfg->ops->set_network_type(hw, mac->opmode);
1477 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_RESTORE);
1478 if (rtlpriv->cfg->ops->get_btc_status())
1479 rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 0);
1482 static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1483 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
1484 struct ieee80211_key_conf *key)
1486 struct rtl_priv *rtlpriv = rtl_priv(hw);
1487 u8 key_type = NO_ENCRYPTION;
1489 bool group_key = false;
1490 bool wep_only = false;
1492 u8 mac_addr[ETH_ALEN];
1493 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1495 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) {
1496 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1497 "not open hw encryption\n");
1498 return -ENOSPC; /*User disabled HW-crypto */
1500 /* To support IBSS, use sw-crypto for GTK */
1501 if (((vif->type == NL80211_IFTYPE_ADHOC) ||
1502 (vif->type == NL80211_IFTYPE_MESH_POINT)) &&
1503 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
1505 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1506 "%s hardware based encryption for keyidx: %d, mac: %pM\n",
1507 cmd == SET_KEY ? "Using" : "Disabling", key->keyidx,
1508 sta ? sta->addr : bcast_addr);
1509 rtlpriv->sec.being_setkey = true;
1511 mutex_lock(&rtlpriv->locks.conf_mutex);
1512 /* <1> get encryption alg */
1514 switch (key->cipher) {
1515 case WLAN_CIPHER_SUITE_WEP40:
1516 key_type = WEP40_ENCRYPTION;
1517 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:WEP40\n");
1519 case WLAN_CIPHER_SUITE_WEP104:
1520 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:WEP104\n");
1521 key_type = WEP104_ENCRYPTION;
1523 case WLAN_CIPHER_SUITE_TKIP:
1524 key_type = TKIP_ENCRYPTION;
1525 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:TKIP\n");
1527 case WLAN_CIPHER_SUITE_CCMP:
1528 key_type = AESCCMP_ENCRYPTION;
1529 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CCMP\n");
1531 case WLAN_CIPHER_SUITE_AES_CMAC:
1532 /* HW don't support CMAC encryption,
1533 * use software CMAC encryption
1535 key_type = AESCMAC_ENCRYPTION;
1536 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CMAC\n");
1537 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1538 "HW don't support CMAC encrypiton, use software CMAC encrypiton\n");
1542 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1543 "alg_err:%x!!!!:\n", key->cipher);
1546 if (key_type == WEP40_ENCRYPTION ||
1547 key_type == WEP104_ENCRYPTION ||
1548 vif->type == NL80211_IFTYPE_ADHOC)
1549 rtlpriv->sec.use_defaultkey = true;
1551 /* <2> get key_idx */
1552 key_idx = (u8) (key->keyidx);
1555 /* <3> if pairwise key enable_hw_sec */
1556 group_key = !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE);
1558 /* wep always be group key, but there are two conditions:
1559 * 1) wep only: is just for wep enc, in this condition
1560 * rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION
1561 * will be true & enable_hw_sec will be set when wep
1563 * 2) wep(group) + AES(pairwise): some AP like cisco
1564 * may use it, in this condition enable_hw_sec will not
1565 * be set when wep key setting */
1566 /* we must reset sec_info after lingked before set key,
1567 * or some flag will be wrong*/
1568 if (vif->type == NL80211_IFTYPE_AP ||
1569 vif->type == NL80211_IFTYPE_MESH_POINT) {
1570 if (!group_key || key_type == WEP40_ENCRYPTION ||
1571 key_type == WEP104_ENCRYPTION) {
1574 rtlpriv->cfg->ops->enable_hw_sec(hw);
1577 if ((!group_key) || (vif->type == NL80211_IFTYPE_ADHOC) ||
1578 rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION) {
1579 if (rtlpriv->sec.pairwise_enc_algorithm ==
1581 (key_type == WEP40_ENCRYPTION ||
1582 key_type == WEP104_ENCRYPTION))
1584 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1585 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1586 "set enable_hw_sec, key_type:%x(OPEN:0 WEP40:1 TKIP:2 AES:4 WEP104:5)\n",
1588 rtlpriv->cfg->ops->enable_hw_sec(hw);
1591 /* <4> set key based on cmd */
1595 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1596 "set WEP(group/pairwise) key\n");
1597 /* Pairwise key with an assigned MAC address. */
1598 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1599 rtlpriv->sec.group_enc_algorithm = key_type;
1600 /*set local buf about wep key. */
1601 memcpy(rtlpriv->sec.key_buf[key_idx],
1602 key->key, key->keylen);
1603 rtlpriv->sec.key_len[key_idx] = key->keylen;
1604 eth_zero_addr(mac_addr);
1605 } else if (group_key) { /* group key */
1606 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1609 rtlpriv->sec.group_enc_algorithm = key_type;
1610 /*set local buf about group key. */
1611 memcpy(rtlpriv->sec.key_buf[key_idx],
1612 key->key, key->keylen);
1613 rtlpriv->sec.key_len[key_idx] = key->keylen;
1614 memcpy(mac_addr, bcast_addr, ETH_ALEN);
1615 } else { /* pairwise key */
1616 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1617 "set pairwise key\n");
1620 "pairwise key without mac_addr\n");
1625 /* Pairwise key with an assigned MAC address. */
1626 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1627 /*set local buf about pairwise key. */
1628 memcpy(rtlpriv->sec.key_buf[PAIRWISE_KEYIDX],
1629 key->key, key->keylen);
1630 rtlpriv->sec.key_len[PAIRWISE_KEYIDX] = key->keylen;
1631 rtlpriv->sec.pairwise_key =
1632 rtlpriv->sec.key_buf[PAIRWISE_KEYIDX];
1633 memcpy(mac_addr, sta->addr, ETH_ALEN);
1635 rtlpriv->cfg->ops->set_key(hw, key_idx, mac_addr,
1636 group_key, key_type, wep_only,
1638 /* <5> tell mac80211 do something: */
1639 /*must use sw generate IV, or can not work !!!!. */
1640 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
1641 key->hw_key_idx = key_idx;
1642 if (key_type == TKIP_ENCRYPTION)
1643 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
1644 /*use software CCMP encryption for management frames (MFP) */
1645 if (key_type == AESCCMP_ENCRYPTION)
1646 key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX;
1649 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1650 "disable key delete one entry\n");
1651 /*set local buf about wep key. */
1652 if (vif->type == NL80211_IFTYPE_AP ||
1653 vif->type == NL80211_IFTYPE_MESH_POINT) {
1655 rtl_cam_del_entry(hw, sta->addr);
1657 memset(rtlpriv->sec.key_buf[key_idx], 0, key->keylen);
1658 rtlpriv->sec.key_len[key_idx] = 0;
1659 eth_zero_addr(mac_addr);
1661 *mac80211 will delete entrys one by one,
1662 *so don't use rtl_cam_reset_all_entry
1663 *or clear all entry here.
1665 rtl_cam_delete_one_entry(hw, mac_addr, key_idx);
1668 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1669 "cmd_err:%x!!!!:\n", cmd);
1672 mutex_unlock(&rtlpriv->locks.conf_mutex);
1673 rtlpriv->sec.being_setkey = false;
1677 static void rtl_op_rfkill_poll(struct ieee80211_hw *hw)
1679 struct rtl_priv *rtlpriv = rtl_priv(hw);
1685 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
1688 mutex_lock(&rtlpriv->locks.conf_mutex);
1690 /*if Radio On return true here */
1691 radio_state = rtlpriv->cfg->ops->radio_onoff_checking(hw, &valid);
1694 if (unlikely(radio_state != rtlpriv->rfkill.rfkill_state)) {
1695 rtlpriv->rfkill.rfkill_state = radio_state;
1697 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
1698 "wireless radio switch turned %s\n",
1699 radio_state ? "on" : "off");
1701 blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1;
1702 wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
1706 mutex_unlock(&rtlpriv->locks.conf_mutex);
1709 /* this function is called by mac80211 to flush tx buffer
1710 * before switch channle or power save, or tx buffer packet
1711 * maybe send after offchannel or rf sleep, this may cause
1712 * dis-association by AP */
1713 static void rtl_op_flush(struct ieee80211_hw *hw,
1714 struct ieee80211_vif *vif,
1718 struct rtl_priv *rtlpriv = rtl_priv(hw);
1720 if (rtlpriv->intf_ops->flush)
1721 rtlpriv->intf_ops->flush(hw, queues, drop);
1725 * This routine deals with the Power Configuration CMD
1726 * parsing for RTL8723/RTL8188E Series IC.
1728 * We should follow specific format that was released from HW SD.
1730 bool rtl_hal_pwrseqcmdparsing(struct rtl_priv *rtlpriv, u8 cut_version,
1731 u8 faversion, u8 interface_type,
1732 struct wlan_pwr_cfg pwrcfgcmd[])
1734 struct wlan_pwr_cfg cfg_cmd = {0};
1735 bool polling_bit = false;
1739 u32 polling_count = 0;
1740 u32 max_polling_cnt = 5000;
1743 cfg_cmd = pwrcfgcmd[ary_idx];
1744 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1745 "rtl_hal_pwrseqcmdparsing(): offset(%#x),cut_msk(%#x), famsk(%#x), interface_msk(%#x), base(%#x), cmd(%#x), msk(%#x), value(%#x)\n",
1746 GET_PWR_CFG_OFFSET(cfg_cmd),
1747 GET_PWR_CFG_CUT_MASK(cfg_cmd),
1748 GET_PWR_CFG_FAB_MASK(cfg_cmd),
1749 GET_PWR_CFG_INTF_MASK(cfg_cmd),
1750 GET_PWR_CFG_BASE(cfg_cmd), GET_PWR_CFG_CMD(cfg_cmd),
1751 GET_PWR_CFG_MASK(cfg_cmd), GET_PWR_CFG_VALUE(cfg_cmd));
1753 if ((GET_PWR_CFG_FAB_MASK(cfg_cmd)&faversion) &&
1754 (GET_PWR_CFG_CUT_MASK(cfg_cmd)&cut_version) &&
1755 (GET_PWR_CFG_INTF_MASK(cfg_cmd)&interface_type)) {
1756 switch (GET_PWR_CFG_CMD(cfg_cmd)) {
1758 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1759 "rtl_hal_pwrseqcmdparsing(): PWR_CMD_READ\n");
1762 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1763 "rtl_hal_pwrseqcmdparsing(): PWR_CMD_WRITE\n");
1764 offset = GET_PWR_CFG_OFFSET(cfg_cmd);
1766 /*Read the value from system register*/
1767 value = rtl_read_byte(rtlpriv, offset);
1768 value &= (~(GET_PWR_CFG_MASK(cfg_cmd)));
1769 value |= (GET_PWR_CFG_VALUE(cfg_cmd) &
1770 GET_PWR_CFG_MASK(cfg_cmd));
1772 /*Write the value back to sytem register*/
1773 rtl_write_byte(rtlpriv, offset, value);
1775 case PWR_CMD_POLLING:
1776 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1777 "rtl_hal_pwrseqcmdparsing(): PWR_CMD_POLLING\n");
1778 polling_bit = false;
1779 offset = GET_PWR_CFG_OFFSET(cfg_cmd);
1782 value = rtl_read_byte(rtlpriv, offset);
1784 value &= GET_PWR_CFG_MASK(cfg_cmd);
1786 (GET_PWR_CFG_VALUE(cfg_cmd) &
1787 GET_PWR_CFG_MASK(cfg_cmd)))
1792 if (polling_count++ > max_polling_cnt)
1794 } while (!polling_bit);
1797 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1798 "rtl_hal_pwrseqcmdparsing(): PWR_CMD_DELAY\n");
1799 if (GET_PWR_CFG_VALUE(cfg_cmd) ==
1801 udelay(GET_PWR_CFG_OFFSET(cfg_cmd));
1803 mdelay(GET_PWR_CFG_OFFSET(cfg_cmd));
1806 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1807 "rtl_hal_pwrseqcmdparsing(): PWR_CMD_END\n");
1811 "rtl_hal_pwrseqcmdparsing(): Unknown CMD!!\n");
1820 EXPORT_SYMBOL(rtl_hal_pwrseqcmdparsing);
1822 bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)
1824 struct rtl_priv *rtlpriv = rtl_priv(hw);
1825 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1826 struct rtl8192_tx_ring *ring;
1827 struct rtl_tx_desc *pdesc;
1828 unsigned long flags;
1829 struct sk_buff *pskb = NULL;
1831 ring = &rtlpci->tx_ring[BEACON_QUEUE];
1833 spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags);
1834 pskb = __skb_dequeue(&ring->queue);
1837 /*this is wrong, fill_tx_cmddesc needs update*/
1838 pdesc = &ring->desc[0];
1840 rtlpriv->cfg->ops->fill_tx_cmddesc(hw, (u8 *)pdesc, 1, 1, skb);
1842 __skb_queue_tail(&ring->queue, skb);
1844 spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags);
1846 rtlpriv->cfg->ops->tx_polling(hw, BEACON_QUEUE);
1850 EXPORT_SYMBOL(rtl_cmd_send_packet);
1851 const struct ieee80211_ops rtl_ops = {
1852 .start = rtl_op_start,
1853 .stop = rtl_op_stop,
1855 .add_interface = rtl_op_add_interface,
1856 .remove_interface = rtl_op_remove_interface,
1857 .change_interface = rtl_op_change_interface,
1859 .suspend = rtl_op_suspend,
1860 .resume = rtl_op_resume,
1862 .config = rtl_op_config,
1863 .configure_filter = rtl_op_configure_filter,
1864 .set_key = rtl_op_set_key,
1865 .conf_tx = rtl_op_conf_tx,
1866 .bss_info_changed = rtl_op_bss_info_changed,
1867 .get_tsf = rtl_op_get_tsf,
1868 .set_tsf = rtl_op_set_tsf,
1869 .reset_tsf = rtl_op_reset_tsf,
1870 .sta_notify = rtl_op_sta_notify,
1871 .ampdu_action = rtl_op_ampdu_action,
1872 .sw_scan_start = rtl_op_sw_scan_start,
1873 .sw_scan_complete = rtl_op_sw_scan_complete,
1874 .rfkill_poll = rtl_op_rfkill_poll,
1875 .sta_add = rtl_op_sta_add,
1876 .sta_remove = rtl_op_sta_remove,
1877 .flush = rtl_op_flush,
1879 EXPORT_SYMBOL_GPL(rtl_ops);
1881 bool rtl_btc_status_false(void)
1885 EXPORT_SYMBOL_GPL(rtl_btc_status_false);
1887 void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igvalue)
1889 struct rtl_priv *rtlpriv = rtl_priv(hw);
1890 struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
1892 dm_digtable->dig_enable_flag = true;
1893 dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
1894 dm_digtable->cur_igvalue = cur_igvalue;
1895 dm_digtable->pre_igvalue = 0;
1896 dm_digtable->cur_sta_cstate = DIG_STA_DISCONNECT;
1897 dm_digtable->presta_cstate = DIG_STA_DISCONNECT;
1898 dm_digtable->curmultista_cstate = DIG_MULTISTA_DISCONNECT;
1899 dm_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
1900 dm_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
1901 dm_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
1902 dm_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
1903 dm_digtable->rx_gain_max = DM_DIG_MAX;
1904 dm_digtable->rx_gain_min = DM_DIG_MIN;
1905 dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
1906 dm_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
1907 dm_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
1908 dm_digtable->pre_cck_cca_thres = 0xff;
1909 dm_digtable->cur_cck_cca_thres = 0x83;
1910 dm_digtable->forbidden_igi = DM_DIG_MIN;
1911 dm_digtable->large_fa_hit = 0;
1912 dm_digtable->recover_cnt = 0;
1913 dm_digtable->dig_min_0 = 0x25;
1914 dm_digtable->dig_min_1 = 0x25;
1915 dm_digtable->media_connect_0 = false;
1916 dm_digtable->media_connect_1 = false;
1917 rtlpriv->dm.dm_initialgain_enable = true;
1918 dm_digtable->bt30_cur_igi = 0x32;
1919 dm_digtable->pre_cck_pd_state = CCK_PD_STAGE_MAX;
1920 dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_LOWRSSI;
1922 EXPORT_SYMBOL(rtl_dm_diginit);