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 */
48 u8 channel5g_80m[CHANNEL_MAX_NUMBER_5G_80M] = {
49 42, 58, 106, 122, 138, 155, 171
52 void rtl_addr_delay(u32 addr)
56 else if (addr == 0xfd)
58 else if (addr == 0xfc)
60 else if (addr == 0xfb)
61 usleep_range(50, 100);
62 else if (addr == 0xfa)
64 else if (addr == 0xf9)
68 void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr,
71 if (addr >= 0xf9 && addr <= 0xfe) {
74 rtl_set_rfreg(hw, rfpath, addr, mask, data);
79 void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data)
81 if (addr >= 0xf9 && addr <= 0xfe) {
84 rtl_set_bbreg(hw, addr, MASKDWORD, data);
89 static void rtl_fw_do_work(const struct firmware *firmware, void *context,
92 struct ieee80211_hw *hw = context;
93 struct rtl_priv *rtlpriv = rtl_priv(hw);
96 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
97 "Firmware callback routine entered!\n");
98 complete(&rtlpriv->firmware_loading_complete);
100 if (rtlpriv->cfg->alt_fw_name) {
101 err = reject_firmware(&firmware,
102 rtlpriv->cfg->alt_fw_name,
104 pr_info("Loading alternative firmware %s\n",
105 rtlpriv->cfg->alt_fw_name);
109 pr_err("Selected firmware is not available\n");
110 rtlpriv->max_fw_size = 0;
114 if (firmware->size > rtlpriv->max_fw_size) {
115 pr_err("Firmware is too big!\n");
116 release_firmware(firmware);
120 memcpy(rtlpriv->rtlhal.pfirmware, firmware->data,
122 rtlpriv->rtlhal.fwsize = firmware->size;
124 memcpy(rtlpriv->rtlhal.wowlan_firmware, firmware->data,
126 rtlpriv->rtlhal.wowlan_fwsize = firmware->size;
128 rtlpriv->rtlhal.fwsize = firmware->size;
129 release_firmware(firmware);
132 void rtl_fw_cb(const struct firmware *firmware, void *context)
134 rtl_fw_do_work(firmware, context, false);
137 void rtl_wowlan_fw_cb(const struct firmware *firmware, void *context)
139 rtl_fw_do_work(firmware, context, true);
142 /*mutex for start & stop is must here. */
143 static int rtl_op_start(struct ieee80211_hw *hw)
146 struct rtl_priv *rtlpriv = rtl_priv(hw);
147 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
149 if (!is_hal_stop(rtlhal))
151 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
153 mutex_lock(&rtlpriv->locks.conf_mutex);
154 err = rtlpriv->intf_ops->adapter_start(hw);
156 rtl_watch_dog_timer_callback((unsigned long)hw);
157 mutex_unlock(&rtlpriv->locks.conf_mutex);
161 static void rtl_op_stop(struct ieee80211_hw *hw)
163 struct rtl_priv *rtlpriv = rtl_priv(hw);
164 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
165 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
166 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
167 bool support_remote_wakeup = false;
169 if (is_hal_stop(rtlhal))
172 rtlpriv->cfg->ops->get_hw_reg(hw, HAL_DEF_WOWLAN,
173 (u8 *)(&support_remote_wakeup));
174 /* here is must, because adhoc do stop and start,
175 * but stop with RFOFF may cause something wrong,
178 if (unlikely(ppsc->rfpwr_state == ERFOFF))
181 mutex_lock(&rtlpriv->locks.conf_mutex);
182 /* if wowlan supported, DON'T clear connected info */
183 if (!(support_remote_wakeup &&
184 rtlhal->enter_pnp_sleep)) {
185 mac->link_state = MAC80211_NOLINK;
186 eth_zero_addr(mac->bssid);
187 mac->vendor = PEER_UNKNOWN;
190 rtl_cam_reset_sec_info(hw);
192 rtl_deinit_deferred_work(hw);
194 rtlpriv->intf_ops->adapter_stop(hw);
196 mutex_unlock(&rtlpriv->locks.conf_mutex);
199 static void rtl_op_tx(struct ieee80211_hw *hw,
200 struct ieee80211_tx_control *control,
203 struct rtl_priv *rtlpriv = rtl_priv(hw);
204 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
205 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
206 struct rtl_tcb_desc tcb_desc;
208 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
210 if (unlikely(is_hal_stop(rtlhal) || ppsc->rfpwr_state != ERFON))
213 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
216 if (!rtlpriv->intf_ops->waitq_insert(hw, control->sta, skb))
217 rtlpriv->intf_ops->adapter_tx(hw, control->sta, skb, &tcb_desc);
221 dev_kfree_skb_any(skb);
224 static int rtl_op_add_interface(struct ieee80211_hw *hw,
225 struct ieee80211_vif *vif)
227 struct rtl_priv *rtlpriv = rtl_priv(hw);
228 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
230 u8 retry_limit = 0x30;
233 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
234 "vif has been set!! mac->vif = 0x%p\n", mac->vif);
238 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
242 mutex_lock(&rtlpriv->locks.conf_mutex);
243 switch (ieee80211_vif_type_p2p(vif)) {
244 case NL80211_IFTYPE_P2P_CLIENT:
245 mac->p2p = P2P_ROLE_CLIENT;
247 case NL80211_IFTYPE_STATION:
248 if (mac->beacon_enabled == 1) {
249 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
250 "NL80211_IFTYPE_STATION\n");
251 mac->beacon_enabled = 0;
252 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
253 rtlpriv->cfg->maps[RTL_IBSS_INT_MASKS]);
256 case NL80211_IFTYPE_ADHOC:
257 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
258 "NL80211_IFTYPE_ADHOC\n");
260 mac->link_state = MAC80211_LINKED;
261 rtlpriv->cfg->ops->set_bcn_reg(hw);
262 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
263 mac->basic_rates = 0xfff;
265 mac->basic_rates = 0xff0;
266 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
267 (u8 *)(&mac->basic_rates));
271 case NL80211_IFTYPE_P2P_GO:
272 mac->p2p = P2P_ROLE_GO;
274 case NL80211_IFTYPE_AP:
275 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
276 "NL80211_IFTYPE_AP\n");
278 mac->link_state = MAC80211_LINKED;
279 rtlpriv->cfg->ops->set_bcn_reg(hw);
280 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
281 mac->basic_rates = 0xfff;
283 mac->basic_rates = 0xff0;
284 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
285 (u8 *)(&mac->basic_rates));
289 case NL80211_IFTYPE_MESH_POINT:
290 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
291 "NL80211_IFTYPE_MESH_POINT\n");
293 mac->link_state = MAC80211_LINKED;
294 rtlpriv->cfg->ops->set_bcn_reg(hw);
295 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
296 mac->basic_rates = 0xfff;
298 mac->basic_rates = 0xff0;
299 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
300 (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);
324 mac->retry_long = retry_limit;
325 mac->retry_short = retry_limit;
326 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
327 (u8 *)(&retry_limit));
329 mutex_unlock(&rtlpriv->locks.conf_mutex);
333 static void rtl_op_remove_interface(struct ieee80211_hw *hw,
334 struct ieee80211_vif *vif)
336 struct rtl_priv *rtlpriv = rtl_priv(hw);
337 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
339 mutex_lock(&rtlpriv->locks.conf_mutex);
341 /* Free beacon resources */
342 if ((vif->type == NL80211_IFTYPE_AP) ||
343 (vif->type == NL80211_IFTYPE_ADHOC) ||
344 (vif->type == NL80211_IFTYPE_MESH_POINT)) {
345 if (mac->beacon_enabled == 1) {
346 mac->beacon_enabled = 0;
347 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
348 rtlpriv->cfg->maps[RTL_IBSS_INT_MASKS]);
353 *Note: We assume NL80211_IFTYPE_UNSPECIFIED as
354 *NO LINK for our hardware.
358 mac->link_state = MAC80211_NOLINK;
359 eth_zero_addr(mac->bssid);
360 mac->vendor = PEER_UNKNOWN;
361 mac->opmode = NL80211_IFTYPE_UNSPECIFIED;
362 rtlpriv->cfg->ops->set_network_type(hw, mac->opmode);
364 mutex_unlock(&rtlpriv->locks.conf_mutex);
367 static int rtl_op_change_interface(struct ieee80211_hw *hw,
368 struct ieee80211_vif *vif,
369 enum nl80211_iftype new_type, bool p2p)
371 struct rtl_priv *rtlpriv = rtl_priv(hw);
374 rtl_op_remove_interface(hw, vif);
376 vif->type = new_type;
378 ret = rtl_op_add_interface(hw, vif);
379 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
385 static u16 crc16_ccitt(u8 data, u16 crc)
387 u8 shift_in, data_bit, crc_bit11, crc_bit4, crc_bit15;
391 for (i = 0; i < 8; i++) {
392 crc_bit15 = ((crc & BIT(15)) ? 1 : 0);
393 data_bit = (data & (BIT(0) << i) ? 1 : 0);
394 shift_in = crc_bit15 ^ data_bit;
402 crc_bit11 = ((crc & BIT(11)) ? 1 : 0) ^ shift_in;
404 result &= (~BIT(12));
408 crc_bit4 = ((crc & BIT(4)) ? 1 : 0) ^ shift_in;
420 static u16 _calculate_wol_pattern_crc(u8 *pattern, u16 len)
425 for (i = 0; i < len; i++)
426 crc = crc16_ccitt(pattern[i], crc);
433 static void _rtl_add_wowlan_patterns(struct ieee80211_hw *hw,
434 struct cfg80211_wowlan *wow)
436 struct rtl_priv *rtlpriv = rtl_priv(hw);
437 struct rtl_mac *mac = &rtlpriv->mac80211;
438 struct cfg80211_pkt_pattern *patterns = wow->patterns;
439 struct rtl_wow_pattern rtl_pattern;
440 const u8 *pattern_os, *mask_os;
441 u8 mask[MAX_WOL_BIT_MASK_SIZE] = {0};
442 u8 content[MAX_WOL_PATTERN_SIZE] = {0};
443 u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
444 u8 multicast_addr1[2] = {0x33, 0x33};
445 u8 multicast_addr2[3] = {0x01, 0x00, 0x5e};
449 for (i = 0; i < wow->n_patterns; i++) {
450 memset(&rtl_pattern, 0, sizeof(struct rtl_wow_pattern));
451 memset(mask, 0, MAX_WOL_BIT_MASK_SIZE);
452 if (patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) {
453 RT_TRACE(rtlpriv, COMP_POWER, DBG_WARNING,
454 "Pattern[%d] is too long\n", i);
457 pattern_os = patterns[i].pattern;
458 mask_len = DIV_ROUND_UP(patterns[i].pattern_len, 8);
459 mask_os = patterns[i].mask;
460 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
461 "pattern content\n", pattern_os,
462 patterns[i].pattern_len);
463 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
464 "mask content\n", mask_os, mask_len);
465 /* 1. unicast? multicast? or broadcast? */
466 if (memcmp(pattern_os, broadcast_addr, 6) == 0)
467 rtl_pattern.type = BROADCAST_PATTERN;
468 else if (memcmp(pattern_os, multicast_addr1, 2) == 0 ||
469 memcmp(pattern_os, multicast_addr2, 3) == 0)
470 rtl_pattern.type = MULTICAST_PATTERN;
471 else if (memcmp(pattern_os, mac->mac_addr, 6) == 0)
472 rtl_pattern.type = UNICAST_PATTERN;
474 rtl_pattern.type = UNKNOWN_TYPE;
476 /* 2. translate mask_from_os to mask_for_hw */
478 /******************************************************************************
479 * pattern from OS uses 'ethenet frame', like this:
481 | 6 | 6 | 2 | 20 | Variable | 4 |
482 |--------+--------+------+-----------+------------+-----|
483 | 802.3 Mac Header | IP Header | TCP Packet | FCS |
486 * BUT, packet catched by our HW is in '802.11 frame', begin from LLC,
488 | 24 or 30 | 6 | 2 | 20 | Variable | 4 |
489 |-------------------+--------+------+-----------+------------+-----|
490 | 802.11 MAC Header | LLC | IP Header | TCP Packet | FCS |
493 * Therefore, we need translate mask_from_OS to mask_to_hw.
494 * We should left-shift mask by 6 bits, then set the new bit[0~5] = 0,
495 * because new mask[0~5] means 'SA', but our HW packet begins from LLC,
496 * bit[0~5] corresponds to first 6 Bytes in LLC, they just don't match.
497 ******************************************************************************/
500 for (j = 0; j < mask_len - 1; j++) {
501 mask[j] = mask_os[j] >> 6;
502 mask[j] |= (mask_os[j + 1] & 0x3F) << 2;
504 mask[j] = (mask_os[j] >> 6) & 0x3F;
505 /* Set bit 0-5 to zero */
508 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
509 "mask to hw\n", mask, mask_len);
510 for (j = 0; j < (MAX_WOL_BIT_MASK_SIZE + 1) / 4; j++) {
511 rtl_pattern.mask[j] = mask[j * 4];
512 rtl_pattern.mask[j] |= (mask[j * 4 + 1] << 8);
513 rtl_pattern.mask[j] |= (mask[j * 4 + 2] << 16);
514 rtl_pattern.mask[j] |= (mask[j * 4 + 3] << 24);
517 /* To get the wake up pattern from the mask.
518 * We do not count first 12 bits which means
519 * DA[6] and SA[6] in the pattern to match HW design.
522 for (j = 12; j < patterns[i].pattern_len; j++) {
523 if ((mask_os[j / 8] >> (j % 8)) & 0x01) {
524 content[len] = pattern_os[j];
529 RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE,
530 "pattern to hw\n", content, len);
531 /* 3. calculate crc */
532 rtl_pattern.crc = _calculate_wol_pattern_crc(content, len);
533 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE,
534 "CRC_Remainder = 0x%x\n", rtl_pattern.crc);
536 /* 4. write crc & mask_for_hw to hw */
537 rtlpriv->cfg->ops->add_wowlan_pattern(hw, &rtl_pattern, i);
539 rtl_write_byte(rtlpriv, 0x698, wow->n_patterns);
542 static int rtl_op_suspend(struct ieee80211_hw *hw,
543 struct cfg80211_wowlan *wow)
545 struct rtl_priv *rtlpriv = rtl_priv(hw);
546 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
547 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
550 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n");
554 /* to resolve s4 can not wake up*/
555 do_gettimeofday(&ts);
556 rtlhal->last_suspend_sec = ts.tv_sec;
558 if ((ppsc->wo_wlan_mode & WAKE_ON_PATTERN_MATCH) && wow->n_patterns)
559 _rtl_add_wowlan_patterns(hw, wow);
561 rtlhal->driver_is_goingto_unload = true;
562 rtlhal->enter_pnp_sleep = true;
566 device_set_wakeup_enable(wiphy_dev(hw->wiphy), true);
570 static int rtl_op_resume(struct ieee80211_hw *hw)
572 struct rtl_priv *rtlpriv = rtl_priv(hw);
573 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
574 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
577 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n");
578 rtlhal->driver_is_goingto_unload = false;
579 rtlhal->enter_pnp_sleep = false;
580 rtlhal->wake_from_pnp_sleep = true;
582 /* to resovle s4 can not wake up*/
583 do_gettimeofday(&ts);
584 if (ts.tv_sec - rtlhal->last_suspend_sec < 5)
588 device_set_wakeup_enable(wiphy_dev(hw->wiphy), false);
589 ieee80211_resume_disconnect(mac->vif);
590 rtlhal->wake_from_pnp_sleep = false;
595 static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
597 struct rtl_priv *rtlpriv = rtl_priv(hw);
598 struct rtl_phy *rtlphy = &rtlpriv->phy;
599 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
600 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
601 struct ieee80211_conf *conf = &hw->conf;
606 mutex_lock(&rtlpriv->locks.conf_mutex);
607 if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { /* BIT(2)*/
608 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
609 "IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n");
613 if (changed & IEEE80211_CONF_CHANGE_IDLE) {
614 if (hw->conf.flags & IEEE80211_CONF_IDLE)
620 *although rfoff may not cause by ips, but we will
621 *check the reason in set_rf_power_state function
623 if (unlikely(ppsc->rfpwr_state == ERFOFF))
628 if ((changed & IEEE80211_CONF_CHANGE_PS) &&
629 rtlpriv->psc.swctrl_lps && !rtlpriv->psc.fwctrl_lps) {
630 cancel_delayed_work(&rtlpriv->works.ps_work);
631 cancel_delayed_work(&rtlpriv->works.ps_rfon_wq);
632 if (conf->flags & IEEE80211_CONF_PS) {
633 rtlpriv->psc.sw_ps_enabled = true;
634 /* sleep here is must, or we may recv the beacon and
635 * cause mac80211 into wrong ps state, this will cause
636 * power save nullfunc send fail, and further cause
637 * pkt loss, So sleep must quickly but not immediately
638 * because that will cause nullfunc send by mac80211
639 * fail, and cause pkt loss, we have tested that 5mA
642 if (!rtlpriv->psc.multi_buffered)
643 queue_delayed_work(rtlpriv->works.rtl_wq,
644 &rtlpriv->works.ps_work,
647 rtl_swlps_rf_awake(hw);
648 rtlpriv->psc.sw_ps_enabled = false;
652 if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) {
653 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
654 "IEEE80211_CONF_CHANGE_RETRY_LIMITS %x\n",
655 hw->conf.long_frame_max_tx_count);
656 /* brought up everything changes (changed == ~0) indicates first
657 * open, so use our default value instead of that of wiphy.
660 mac->retry_long = hw->conf.long_frame_max_tx_count;
661 mac->retry_short = hw->conf.long_frame_max_tx_count;
662 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
663 (u8 *)(&hw->conf.long_frame_max_tx_count));
667 if (changed & IEEE80211_CONF_CHANGE_CHANNEL &&
668 !rtlpriv->proximity.proxim_on) {
669 struct ieee80211_channel *channel = hw->conf.chandef.chan;
670 enum nl80211_chan_width width = hw->conf.chandef.width;
671 enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT;
672 u8 wide_chan = (u8)channel->hw_value;
674 /* channel_type is for 20&40M */
675 if (width < NL80211_CHAN_WIDTH_80)
677 cfg80211_get_chandef_type(&hw->conf.chandef);
678 if (mac->act_scanning)
681 if (rtlpriv->dm.supp_phymode_switch &&
682 mac->link_state < MAC80211_LINKED &&
683 !mac->act_scanning) {
684 if (rtlpriv->cfg->ops->chk_switch_dmdp)
685 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
689 *because we should back channel to
690 *current_network.chan in in scanning,
691 *So if set_chan == current_network.chan
693 *because mac80211 tell us wrong bw40
694 *info for cisco1253 bw20, so we modify
695 *it here based on UPPER & LOWER
698 if (width >= NL80211_CHAN_WIDTH_80) {
699 if (width == NL80211_CHAN_WIDTH_80) {
700 u32 center = hw->conf.chandef.center_freq1;
702 (u32)hw->conf.chandef.chan->center_freq;
704 rtlphy->current_chan_bw =
708 if (center > primary) {
709 mac->cur_80_prime_sc =
710 PRIME_CHNL_OFFSET_LOWER;
711 if (center - primary == 10) {
712 mac->cur_40_prime_sc =
713 PRIME_CHNL_OFFSET_UPPER;
716 } else if (center - primary == 30) {
717 mac->cur_40_prime_sc =
718 PRIME_CHNL_OFFSET_LOWER;
723 mac->cur_80_prime_sc =
724 PRIME_CHNL_OFFSET_UPPER;
725 if (primary - center == 10) {
726 mac->cur_40_prime_sc =
727 PRIME_CHNL_OFFSET_LOWER;
730 } else if (primary - center == 30) {
731 mac->cur_40_prime_sc =
732 PRIME_CHNL_OFFSET_UPPER;
739 switch (channel_type) {
740 case NL80211_CHAN_HT20:
741 case NL80211_CHAN_NO_HT:
743 mac->cur_40_prime_sc =
744 PRIME_CHNL_OFFSET_DONT_CARE;
745 rtlphy->current_chan_bw =
750 case NL80211_CHAN_HT40MINUS:
752 mac->cur_40_prime_sc =
753 PRIME_CHNL_OFFSET_UPPER;
754 rtlphy->current_chan_bw =
755 HT_CHANNEL_WIDTH_20_40;
763 case NL80211_CHAN_HT40PLUS:
765 mac->cur_40_prime_sc =
766 PRIME_CHNL_OFFSET_LOWER;
767 rtlphy->current_chan_bw =
768 HT_CHANNEL_WIDTH_20_40;
779 pr_err("switch case %#x not processed\n",
788 /* In scanning, when before we offchannel we may send a ps=1
789 * null to AP, and then we may send a ps = 0 null to AP quickly,
790 * but first null may have caused AP to put lots of packet to
791 * hw tx buffer. These packets must be tx'd before we go off
792 * channel so we must delay more time to let AP flush these
793 * packets before going offchannel, or dis-association or
794 * delete BA will be caused by AP
796 if (rtlpriv->mac80211.offchan_delay) {
797 rtlpriv->mac80211.offchan_delay = false;
801 rtlphy->current_channel = wide_chan;
803 rtlpriv->cfg->ops->switch_channel(hw);
804 rtlpriv->cfg->ops->set_channel_access(hw);
805 rtlpriv->cfg->ops->set_bw_mode(hw, channel_type);
808 mutex_unlock(&rtlpriv->locks.conf_mutex);
813 static void rtl_op_configure_filter(struct ieee80211_hw *hw,
814 unsigned int changed_flags,
815 unsigned int *new_flags, u64 multicast)
817 bool update_rcr = false;
818 struct rtl_priv *rtlpriv = rtl_priv(hw);
819 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
821 *new_flags &= RTL_SUPPORTED_FILTERS;
822 if (changed_flags == 0)
825 /*TODO: we disable broadcase now, so enable here */
826 if (changed_flags & FIF_ALLMULTI) {
827 if (*new_flags & FIF_ALLMULTI) {
828 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AM] |
829 rtlpriv->cfg->maps[MAC_RCR_AB];
830 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
831 "Enable receive multicast frame\n");
833 mac->rx_conf &= ~(rtlpriv->cfg->maps[MAC_RCR_AM] |
834 rtlpriv->cfg->maps[MAC_RCR_AB]);
835 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
836 "Disable receive multicast frame\n");
841 if (changed_flags & FIF_FCSFAIL) {
842 if (*new_flags & FIF_FCSFAIL) {
843 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACRC32];
844 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
845 "Enable receive FCS error frame\n");
847 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACRC32];
848 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
849 "Disable receive FCS error frame\n");
855 /* if ssid not set to hw don't check bssid
856 * here just used for linked scanning, & linked
857 * and nolink check bssid is set in set network_type
859 if ((changed_flags & FIF_BCN_PRBRESP_PROMISC) &&
860 (mac->link_state >= MAC80211_LINKED)) {
861 if (mac->opmode != NL80211_IFTYPE_AP &&
862 mac->opmode != NL80211_IFTYPE_MESH_POINT) {
863 if (*new_flags & FIF_BCN_PRBRESP_PROMISC)
864 rtlpriv->cfg->ops->set_chk_bssid(hw, false);
866 rtlpriv->cfg->ops->set_chk_bssid(hw, true);
872 if (changed_flags & FIF_CONTROL) {
873 if (*new_flags & FIF_CONTROL) {
874 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACF];
876 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
877 "Enable receive control frame.\n");
879 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACF];
880 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
881 "Disable receive control frame.\n");
887 if (changed_flags & FIF_OTHER_BSS) {
888 if (*new_flags & FIF_OTHER_BSS) {
889 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AAP];
890 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
891 "Enable receive other BSS's frame.\n");
893 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_AAP];
894 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
895 "Disable receive other BSS's frame.\n");
902 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR,
903 (u8 *)(&mac->rx_conf));
906 static int rtl_op_sta_add(struct ieee80211_hw *hw,
907 struct ieee80211_vif *vif,
908 struct ieee80211_sta *sta)
910 struct rtl_priv *rtlpriv = rtl_priv(hw);
911 struct rtl_phy *rtlphy = &rtlpriv->phy;
912 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
913 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
914 struct rtl_sta_info *sta_entry;
917 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
918 spin_lock_bh(&rtlpriv->locks.entry_list_lock);
919 list_add_tail(&sta_entry->list, &rtlpriv->entry_list);
920 spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
921 if (rtlhal->current_bandtype == BAND_ON_2_4G) {
922 sta_entry->wireless_mode = WIRELESS_MODE_G;
923 if (sta->supp_rates[0] <= 0xf)
924 sta_entry->wireless_mode = WIRELESS_MODE_B;
925 if (sta->ht_cap.ht_supported)
926 sta_entry->wireless_mode = WIRELESS_MODE_N_24G;
928 if (vif->type == NL80211_IFTYPE_ADHOC)
929 sta_entry->wireless_mode = WIRELESS_MODE_G;
930 } else if (rtlhal->current_bandtype == BAND_ON_5G) {
931 sta_entry->wireless_mode = WIRELESS_MODE_A;
932 if (sta->ht_cap.ht_supported)
933 sta_entry->wireless_mode = WIRELESS_MODE_N_5G;
934 if (sta->vht_cap.vht_supported)
935 sta_entry->wireless_mode = WIRELESS_MODE_AC_5G;
937 if (vif->type == NL80211_IFTYPE_ADHOC)
938 sta_entry->wireless_mode = WIRELESS_MODE_A;
940 /*disable cck rate for p2p*/
942 sta->supp_rates[0] &= 0xfffffff0;
944 if (sta->ht_cap.ht_supported) {
945 if (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)
946 rtlphy->max_ht_chan_bw = HT_CHANNEL_WIDTH_20_40;
948 rtlphy->max_ht_chan_bw = HT_CHANNEL_WIDTH_20;
951 if (sta->vht_cap.vht_supported)
952 rtlphy->max_vht_chan_bw = HT_CHANNEL_WIDTH_80;
954 memcpy(sta_entry->mac_addr, sta->addr, ETH_ALEN);
955 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
956 "Add sta addr is %pM\n", sta->addr);
957 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0, true);
959 if (rtlpriv->phydm.ops)
960 rtlpriv->phydm.ops->phydm_add_sta(rtlpriv, sta);
966 static int rtl_op_sta_remove(struct ieee80211_hw *hw,
967 struct ieee80211_vif *vif,
968 struct ieee80211_sta *sta)
970 struct rtl_priv *rtlpriv = rtl_priv(hw);
971 struct rtl_sta_info *sta_entry;
974 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
975 "Remove sta addr is %pM\n", sta->addr);
977 if (rtlpriv->phydm.ops)
978 rtlpriv->phydm.ops->phydm_del_sta(rtlpriv, sta);
980 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
981 sta_entry->wireless_mode = 0;
982 sta_entry->ratr_index = 0;
983 spin_lock_bh(&rtlpriv->locks.entry_list_lock);
984 list_del(&sta_entry->list);
985 spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
990 static int _rtl_get_hal_qnum(u16 queue)
1014 static void rtl_op_sta_statistics(struct ieee80211_hw *hw,
1015 struct ieee80211_vif *vif,
1016 struct ieee80211_sta *sta,
1017 struct station_info *sinfo)
1019 /* nothing filled by driver, so mac80211 will update all info */
1023 static int rtl_op_set_frag_threshold(struct ieee80211_hw *hw, u32 value)
1029 *for mac80211 VO = 0, VI = 1, BE = 2, BK = 3
1030 *for rtl819x BE = 0, BK = 1, VI = 2, VO = 3
1032 static int rtl_op_conf_tx(struct ieee80211_hw *hw,
1033 struct ieee80211_vif *vif, u16 queue,
1034 const struct ieee80211_tx_queue_params *param)
1036 struct rtl_priv *rtlpriv = rtl_priv(hw);
1037 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1040 if (queue >= AC_MAX) {
1041 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1042 "queue number %d is incorrect!\n", queue);
1046 aci = _rtl_get_hal_qnum(queue);
1047 mac->ac[aci].aifs = param->aifs;
1048 mac->ac[aci].cw_min = cpu_to_le16(param->cw_min);
1049 mac->ac[aci].cw_max = cpu_to_le16(param->cw_max);
1050 mac->ac[aci].tx_op = cpu_to_le16(param->txop);
1051 memcpy(&mac->edca_param[aci], param, sizeof(*param));
1052 rtlpriv->cfg->ops->set_qos(hw, aci);
1056 static void send_beacon_frame(struct ieee80211_hw *hw,
1057 struct ieee80211_vif *vif)
1059 struct rtl_priv *rtlpriv = rtl_priv(hw);
1060 struct sk_buff *skb = ieee80211_beacon_get(hw, vif);
1061 struct rtl_tcb_desc tcb_desc;
1064 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
1065 rtlpriv->intf_ops->adapter_tx(hw, NULL, skb, &tcb_desc);
1069 static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
1070 struct ieee80211_vif *vif,
1071 struct ieee80211_bss_conf *bss_conf,
1074 struct rtl_priv *rtlpriv = rtl_priv(hw);
1075 struct rtl_phy *rtlphy = &rtlpriv->phy;
1076 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
1077 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1078 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
1080 mutex_lock(&rtlpriv->locks.conf_mutex);
1081 if ((vif->type == NL80211_IFTYPE_ADHOC) ||
1082 (vif->type == NL80211_IFTYPE_AP) ||
1083 (vif->type == NL80211_IFTYPE_MESH_POINT)) {
1084 if ((changed & BSS_CHANGED_BEACON) ||
1085 (changed & BSS_CHANGED_BEACON_ENABLED &&
1086 bss_conf->enable_beacon)) {
1087 if (mac->beacon_enabled == 0) {
1088 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1089 "BSS_CHANGED_BEACON_ENABLED\n");
1091 /*start hw beacon interrupt. */
1092 /*rtlpriv->cfg->ops->set_bcn_reg(hw); */
1093 mac->beacon_enabled = 1;
1094 rtlpriv->cfg->ops->update_interrupt_mask(hw,
1096 [RTL_IBSS_INT_MASKS], 0);
1098 if (rtlpriv->cfg->ops->linked_set_reg)
1099 rtlpriv->cfg->ops->linked_set_reg(hw);
1100 send_beacon_frame(hw, vif);
1103 if ((changed & BSS_CHANGED_BEACON_ENABLED &&
1104 !bss_conf->enable_beacon)) {
1105 if (mac->beacon_enabled == 1) {
1106 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1107 "ADHOC DISABLE BEACON\n");
1109 mac->beacon_enabled = 0;
1110 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
1112 [RTL_IBSS_INT_MASKS]);
1115 if (changed & BSS_CHANGED_BEACON_INT) {
1116 RT_TRACE(rtlpriv, COMP_BEACON, DBG_TRACE,
1117 "BSS_CHANGED_BEACON_INT\n");
1118 mac->beacon_interval = bss_conf->beacon_int;
1119 rtlpriv->cfg->ops->set_bcn_intv(hw);
1123 /*TODO: reference to enum ieee80211_bss_change */
1124 if (changed & BSS_CHANGED_ASSOC) {
1127 if (bss_conf->assoc) {
1128 struct ieee80211_sta *sta = NULL;
1131 mstatus = RT_MEDIA_CONNECT;
1132 /* we should reset all sec info & cam
1133 * before set cam after linked, we should not
1134 * reset in disassoc, that will cause tkip->wep
1135 * fail because some flag will be wrong
1138 rtl_cam_reset_sec_info(hw);
1139 /* reset cam to fix wep fail issue
1140 * when change from wpa to wep
1142 rtl_cam_reset_all_entry(hw);
1144 mac->link_state = MAC80211_LINKED;
1145 mac->cnt_after_linked = 0;
1146 mac->assoc_id = bss_conf->aid;
1147 memcpy(mac->bssid, bss_conf->bssid, ETH_ALEN);
1149 if (rtlpriv->cfg->ops->linked_set_reg)
1150 rtlpriv->cfg->ops->linked_set_reg(hw);
1153 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
1158 RT_TRACE(rtlpriv, COMP_EASY_CONCURRENT, DBG_LOUD,
1159 "send PS STATIC frame\n");
1160 if (rtlpriv->dm.supp_phymode_switch) {
1161 if (sta->ht_cap.ht_supported)
1162 rtl_send_smps_action(hw, sta,
1163 IEEE80211_SMPS_STATIC);
1166 if (rtlhal->current_bandtype == BAND_ON_5G) {
1167 mac->mode = WIRELESS_MODE_A;
1169 if (sta->supp_rates[0] <= 0xf)
1170 mac->mode = WIRELESS_MODE_B;
1172 mac->mode = WIRELESS_MODE_G;
1175 if (sta->ht_cap.ht_supported) {
1176 if (rtlhal->current_bandtype == BAND_ON_2_4G)
1177 mac->mode = WIRELESS_MODE_N_24G;
1179 mac->mode = WIRELESS_MODE_N_5G;
1182 if (sta->vht_cap.vht_supported) {
1183 if (rtlhal->current_bandtype == BAND_ON_5G)
1184 mac->mode = WIRELESS_MODE_AC_5G;
1186 mac->mode = WIRELESS_MODE_AC_24G;
1189 if (vif->type == NL80211_IFTYPE_STATION)
1190 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0,
1194 /* to avoid AP Disassociation caused by inactivity */
1195 rtlpriv->cfg->ops->set_hw_reg(hw,
1197 (u8 *)(&keep_alive));
1199 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1200 "BSS_CHANGED_ASSOC\n");
1202 struct cfg80211_bss *bss = NULL;
1204 mstatus = RT_MEDIA_DISCONNECT;
1206 if (mac->link_state == MAC80211_LINKED)
1208 if (ppsc->p2p_ps_info.p2p_ps_mode > P2P_PS_NONE)
1209 rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE);
1210 mac->link_state = MAC80211_NOLINK;
1212 bss = cfg80211_get_bss(hw->wiphy, NULL,
1213 (u8 *)mac->bssid, NULL, 0,
1214 IEEE80211_BSS_TYPE_ESS,
1215 IEEE80211_PRIVACY_OFF);
1217 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1218 "bssid = %x-%x-%x-%x-%x-%x\n",
1219 mac->bssid[0], mac->bssid[1],
1220 mac->bssid[2], mac->bssid[3],
1221 mac->bssid[4], mac->bssid[5]);
1224 cfg80211_unlink_bss(hw->wiphy, bss);
1225 cfg80211_put_bss(hw->wiphy, bss);
1226 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1227 "cfg80211_unlink !!\n");
1230 eth_zero_addr(mac->bssid);
1231 mac->vendor = PEER_UNKNOWN;
1234 if (rtlpriv->dm.supp_phymode_switch) {
1235 if (rtlpriv->cfg->ops->chk_switch_dmdp)
1236 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
1238 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1239 "BSS_CHANGED_UN_ASSOC\n");
1241 rtlpriv->cfg->ops->set_network_type(hw, vif->type);
1243 * To tell firmware we have connected or disconnected
1245 rtlpriv->cfg->ops->set_hw_reg(hw,
1246 HW_VAR_H2C_FW_JOINBSSRPT,
1248 ppsc->report_linked = (mstatus == RT_MEDIA_CONNECT) ?
1251 if (rtlpriv->cfg->ops->get_btc_status())
1252 rtlpriv->btcoexist.btc_ops->btc_mediastatus_notify(
1256 if (changed & BSS_CHANGED_ERP_CTS_PROT) {
1257 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1258 "BSS_CHANGED_ERP_CTS_PROT\n");
1259 mac->use_cts_protect = bss_conf->use_cts_prot;
1262 if (changed & BSS_CHANGED_ERP_PREAMBLE) {
1263 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
1264 "BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n",
1265 bss_conf->use_short_preamble);
1267 mac->short_preamble = bss_conf->use_short_preamble;
1268 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACK_PREAMBLE,
1269 (u8 *)(&mac->short_preamble));
1272 if (changed & BSS_CHANGED_ERP_SLOT) {
1273 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1274 "BSS_CHANGED_ERP_SLOT\n");
1276 if (bss_conf->use_short_slot)
1277 mac->slot_time = RTL_SLOT_TIME_9;
1279 mac->slot_time = RTL_SLOT_TIME_20;
1281 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME,
1282 (u8 *)(&mac->slot_time));
1285 if (changed & BSS_CHANGED_HT) {
1286 struct ieee80211_sta *sta = NULL;
1288 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1289 "BSS_CHANGED_HT\n");
1292 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
1294 if (sta->ht_cap.ampdu_density >
1295 mac->current_ampdu_density)
1296 mac->current_ampdu_density =
1297 sta->ht_cap.ampdu_density;
1298 if (sta->ht_cap.ampdu_factor <
1299 mac->current_ampdu_factor)
1300 mac->current_ampdu_factor =
1301 sta->ht_cap.ampdu_factor;
1303 if (sta->ht_cap.ht_supported) {
1304 if (sta->ht_cap.cap &
1305 IEEE80211_HT_CAP_SUP_WIDTH_20_40)
1306 rtlphy->max_ht_chan_bw =
1307 HT_CHANNEL_WIDTH_20_40;
1309 rtlphy->max_ht_chan_bw =
1310 HT_CHANNEL_WIDTH_20;
1315 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SHORTGI_DENSITY,
1316 (u8 *)(&mac->max_mss_density));
1317 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_FACTOR,
1318 &mac->current_ampdu_factor);
1319 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_MIN_SPACE,
1320 &mac->current_ampdu_density);
1323 if (changed & BSS_CHANGED_BANDWIDTH) {
1324 struct ieee80211_sta *sta = NULL;
1326 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1327 "BSS_CHANGED_BANDWIDTH\n");
1330 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
1333 if (sta->ht_cap.ht_supported) {
1334 if (sta->ht_cap.cap &
1335 IEEE80211_HT_CAP_SUP_WIDTH_20_40)
1336 rtlphy->max_ht_chan_bw =
1337 HT_CHANNEL_WIDTH_20_40;
1339 rtlphy->max_ht_chan_bw =
1340 HT_CHANNEL_WIDTH_20;
1343 if (sta->vht_cap.vht_supported)
1344 rtlphy->max_vht_chan_bw = HT_CHANNEL_WIDTH_80;
1349 if (changed & BSS_CHANGED_BSSID) {
1351 struct ieee80211_sta *sta = NULL;
1353 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BSSID,
1354 (u8 *)bss_conf->bssid);
1356 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
1357 "bssid: %pM\n", bss_conf->bssid);
1359 mac->vendor = PEER_UNKNOWN;
1360 memcpy(mac->bssid, bss_conf->bssid, ETH_ALEN);
1363 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
1369 if (rtlhal->current_bandtype == BAND_ON_5G) {
1370 mac->mode = WIRELESS_MODE_A;
1372 if (sta->supp_rates[0] <= 0xf)
1373 mac->mode = WIRELESS_MODE_B;
1375 mac->mode = WIRELESS_MODE_G;
1378 if (sta->ht_cap.ht_supported) {
1379 if (rtlhal->current_bandtype == BAND_ON_2_4G)
1380 mac->mode = WIRELESS_MODE_N_24G;
1382 mac->mode = WIRELESS_MODE_N_5G;
1385 if (sta->vht_cap.vht_supported) {
1386 if (rtlhal->current_bandtype == BAND_ON_5G)
1387 mac->mode = WIRELESS_MODE_AC_5G;
1389 mac->mode = WIRELESS_MODE_AC_24G;
1392 /* just station need it, because ibss & ap mode will
1393 * set in sta_add, and will be NULL here
1395 if (vif->type == NL80211_IFTYPE_STATION) {
1396 struct rtl_sta_info *sta_entry;
1398 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
1399 sta_entry->wireless_mode = mac->mode;
1402 if (sta->ht_cap.ht_supported) {
1403 mac->ht_enable = true;
1405 /* for cisco 1252 bw20 it's wrong
1406 * if (ht_cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
1407 * mac->bw_40 = true;
1412 if (sta->vht_cap.vht_supported)
1413 mac->vht_enable = true;
1415 if (changed & BSS_CHANGED_BASIC_RATES) {
1416 /* for 5G must << RATE_6M_INDEX = 4,
1417 * because 5G have no cck rate
1419 if (rtlhal->current_bandtype == BAND_ON_5G)
1420 basic_rates = sta->supp_rates[1] << 4;
1422 basic_rates = sta->supp_rates[0];
1424 mac->basic_rates = basic_rates;
1425 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
1426 (u8 *)(&basic_rates));
1431 mutex_unlock(&rtlpriv->locks.conf_mutex);
1434 static u64 rtl_op_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1436 struct rtl_priv *rtlpriv = rtl_priv(hw);
1439 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *)(&tsf));
1443 static void rtl_op_set_tsf(struct ieee80211_hw *hw,
1444 struct ieee80211_vif *vif, u64 tsf)
1446 struct rtl_priv *rtlpriv = rtl_priv(hw);
1447 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1448 u8 bibss = (mac->opmode == NL80211_IFTYPE_ADHOC) ? 1 : 0;
1451 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *)(&bibss));
1454 static void rtl_op_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1456 struct rtl_priv *rtlpriv = rtl_priv(hw);
1459 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_DUAL_TSF_RST, (u8 *)(&tmp));
1462 static void rtl_op_sta_notify(struct ieee80211_hw *hw,
1463 struct ieee80211_vif *vif,
1464 enum sta_notify_cmd cmd,
1465 struct ieee80211_sta *sta)
1468 case STA_NOTIFY_SLEEP:
1470 case STA_NOTIFY_AWAKE:
1477 static int rtl_op_ampdu_action(struct ieee80211_hw *hw,
1478 struct ieee80211_vif *vif,
1479 struct ieee80211_ampdu_params *params)
1481 struct rtl_priv *rtlpriv = rtl_priv(hw);
1482 struct ieee80211_sta *sta = params->sta;
1483 enum ieee80211_ampdu_mlme_action action = params->action;
1484 u16 tid = params->tid;
1485 u16 *ssn = ¶ms->ssn;
1488 case IEEE80211_AMPDU_TX_START:
1489 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1490 "IEEE80211_AMPDU_TX_START: TID:%d\n", tid);
1491 return rtl_tx_agg_start(hw, vif, sta, tid, ssn);
1492 case IEEE80211_AMPDU_TX_STOP_CONT:
1493 case IEEE80211_AMPDU_TX_STOP_FLUSH:
1494 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
1495 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1496 "IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid);
1497 return rtl_tx_agg_stop(hw, vif, sta, tid);
1498 case IEEE80211_AMPDU_TX_OPERATIONAL:
1499 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1500 "IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid);
1501 rtl_tx_agg_oper(hw, sta, tid);
1503 case IEEE80211_AMPDU_RX_START:
1504 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1505 "IEEE80211_AMPDU_RX_START:TID:%d\n", tid);
1506 return rtl_rx_agg_start(hw, sta, tid);
1507 case IEEE80211_AMPDU_RX_STOP:
1508 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
1509 "IEEE80211_AMPDU_RX_STOP:TID:%d\n", tid);
1510 return rtl_rx_agg_stop(hw, sta, tid);
1512 pr_err("IEEE80211_AMPDU_ERR!!!!:\n");
1518 static void rtl_op_sw_scan_start(struct ieee80211_hw *hw,
1519 struct ieee80211_vif *vif,
1522 struct rtl_priv *rtlpriv = rtl_priv(hw);
1523 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1525 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
1526 mac->act_scanning = true;
1527 if (rtlpriv->link_info.higher_busytraffic) {
1528 mac->skip_scan = true;
1532 if (rtlpriv->phydm.ops)
1533 rtlpriv->phydm.ops->phydm_pause_dig(rtlpriv, 1);
1535 if (rtlpriv->cfg->ops->get_btc_status())
1536 rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 1);
1537 else if (rtlpriv->btcoexist.btc_ops)
1538 rtlpriv->btcoexist.btc_ops->btc_scan_notify_wifi_only(rtlpriv,
1541 if (rtlpriv->dm.supp_phymode_switch) {
1542 if (rtlpriv->cfg->ops->chk_switch_dmdp)
1543 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
1546 if (mac->link_state == MAC80211_LINKED) {
1548 mac->link_state = MAC80211_LINKED_SCANNING;
1554 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false;
1556 rtlpriv->cfg->ops->led_control(hw, LED_CTL_SITE_SURVEY);
1557 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_BACKUP_BAND0);
1560 static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw,
1561 struct ieee80211_vif *vif)
1563 struct rtl_priv *rtlpriv = rtl_priv(hw);
1564 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1566 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
1567 mac->act_scanning = false;
1568 mac->skip_scan = false;
1570 rtlpriv->btcoexist.btc_info.ap_num = rtlpriv->scan_list.num;
1572 if (rtlpriv->link_info.higher_busytraffic)
1575 /* p2p will use 1/6/11 to scan */
1576 if (mac->n_channels == 3)
1577 mac->p2p_in_use = true;
1579 mac->p2p_in_use = false;
1580 mac->n_channels = 0;
1582 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false;
1584 if (mac->link_state == MAC80211_LINKED_SCANNING) {
1585 mac->link_state = MAC80211_LINKED;
1586 if (mac->opmode == NL80211_IFTYPE_STATION) {
1587 /* fix fwlps issue */
1588 rtlpriv->cfg->ops->set_network_type(hw, mac->opmode);
1592 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_RESTORE);
1593 if (rtlpriv->cfg->ops->get_btc_status())
1594 rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 0);
1595 else if (rtlpriv->btcoexist.btc_ops)
1596 rtlpriv->btcoexist.btc_ops->btc_scan_notify_wifi_only(rtlpriv,
1599 if (rtlpriv->phydm.ops)
1600 rtlpriv->phydm.ops->phydm_pause_dig(rtlpriv, 0);
1603 static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1604 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
1605 struct ieee80211_key_conf *key)
1607 struct rtl_priv *rtlpriv = rtl_priv(hw);
1608 u8 key_type = NO_ENCRYPTION;
1610 bool group_key = false;
1611 bool wep_only = false;
1613 u8 mac_addr[ETH_ALEN];
1614 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1616 rtlpriv->btcoexist.btc_info.in_4way = false;
1618 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) {
1619 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1620 "not open hw encryption\n");
1621 return -ENOSPC; /*User disabled HW-crypto */
1623 /* To support IBSS, use sw-crypto for GTK */
1624 if (((vif->type == NL80211_IFTYPE_ADHOC) ||
1625 (vif->type == NL80211_IFTYPE_MESH_POINT)) &&
1626 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
1628 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1629 "%s hardware based encryption for keyidx: %d, mac: %pM\n",
1630 cmd == SET_KEY ? "Using" : "Disabling", key->keyidx,
1631 sta ? sta->addr : bcast_addr);
1632 rtlpriv->sec.being_setkey = true;
1634 mutex_lock(&rtlpriv->locks.conf_mutex);
1635 /* <1> get encryption alg */
1637 switch (key->cipher) {
1638 case WLAN_CIPHER_SUITE_WEP40:
1639 key_type = WEP40_ENCRYPTION;
1640 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:WEP40\n");
1642 case WLAN_CIPHER_SUITE_WEP104:
1643 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:WEP104\n");
1644 key_type = WEP104_ENCRYPTION;
1646 case WLAN_CIPHER_SUITE_TKIP:
1647 key_type = TKIP_ENCRYPTION;
1648 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:TKIP\n");
1650 case WLAN_CIPHER_SUITE_CCMP:
1651 key_type = AESCCMP_ENCRYPTION;
1652 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CCMP\n");
1654 case WLAN_CIPHER_SUITE_AES_CMAC:
1655 /* HW don't support CMAC encryption,
1656 * use software CMAC encryption
1658 key_type = AESCMAC_ENCRYPTION;
1659 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CMAC\n");
1660 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1661 "HW don't support CMAC encryption, use software CMAC encryption\n");
1665 pr_err("alg_err:%x!!!!:\n", key->cipher);
1668 if (key_type == WEP40_ENCRYPTION ||
1669 key_type == WEP104_ENCRYPTION ||
1670 vif->type == NL80211_IFTYPE_ADHOC)
1671 rtlpriv->sec.use_defaultkey = true;
1673 /* <2> get key_idx */
1674 key_idx = (u8)(key->keyidx);
1677 /* <3> if pairwise key enable_hw_sec */
1678 group_key = !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE);
1680 /* wep always be group key, but there are two conditions:
1681 * 1) wep only: is just for wep enc, in this condition
1682 * rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION
1683 * will be true & enable_hw_sec will be set when wep
1685 * 2) wep(group) + AES(pairwise): some AP like cisco
1686 * may use it, in this condition enable_hw_sec will not
1687 * be set when wep key setting.
1688 * we must reset sec_info after lingked before set key,
1689 * or some flag will be wrong
1691 if (vif->type == NL80211_IFTYPE_AP ||
1692 vif->type == NL80211_IFTYPE_MESH_POINT) {
1693 if (!group_key || key_type == WEP40_ENCRYPTION ||
1694 key_type == WEP104_ENCRYPTION) {
1697 rtlpriv->cfg->ops->enable_hw_sec(hw);
1700 if ((!group_key) || (vif->type == NL80211_IFTYPE_ADHOC) ||
1701 rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION) {
1702 if (rtlpriv->sec.pairwise_enc_algorithm ==
1704 (key_type == WEP40_ENCRYPTION ||
1705 key_type == WEP104_ENCRYPTION))
1707 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1708 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1709 "set enable_hw_sec, key_type:%x(OPEN:0 WEP40:1 TKIP:2 AES:4 WEP104:5)\n",
1711 rtlpriv->cfg->ops->enable_hw_sec(hw);
1714 /* <4> set key based on cmd */
1718 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1719 "set WEP(group/pairwise) key\n");
1720 /* Pairwise key with an assigned MAC address. */
1721 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1722 rtlpriv->sec.group_enc_algorithm = key_type;
1723 /*set local buf about wep key. */
1724 memcpy(rtlpriv->sec.key_buf[key_idx],
1725 key->key, key->keylen);
1726 rtlpriv->sec.key_len[key_idx] = key->keylen;
1727 eth_zero_addr(mac_addr);
1728 } else if (group_key) { /* group key */
1729 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1732 rtlpriv->sec.group_enc_algorithm = key_type;
1733 /*set local buf about group key. */
1734 memcpy(rtlpriv->sec.key_buf[key_idx],
1735 key->key, key->keylen);
1736 rtlpriv->sec.key_len[key_idx] = key->keylen;
1737 memcpy(mac_addr, bcast_addr, ETH_ALEN);
1738 } else { /* pairwise key */
1739 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1740 "set pairwise key\n");
1743 "rtlwifi: pairwise key without mac_addr\n");
1748 /* Pairwise key with an assigned MAC address. */
1749 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1750 /*set local buf about pairwise key. */
1751 memcpy(rtlpriv->sec.key_buf[PAIRWISE_KEYIDX],
1752 key->key, key->keylen);
1753 rtlpriv->sec.key_len[PAIRWISE_KEYIDX] = key->keylen;
1754 rtlpriv->sec.pairwise_key =
1755 rtlpriv->sec.key_buf[PAIRWISE_KEYIDX];
1756 memcpy(mac_addr, sta->addr, ETH_ALEN);
1758 rtlpriv->cfg->ops->set_key(hw, key_idx, mac_addr,
1759 group_key, key_type, wep_only,
1761 /* <5> tell mac80211 do something: */
1762 /*must use sw generate IV, or can not work !!!!. */
1763 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
1764 key->hw_key_idx = key_idx;
1765 if (key_type == TKIP_ENCRYPTION)
1766 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
1767 /*use software CCMP encryption for management frames (MFP) */
1768 if (key_type == AESCCMP_ENCRYPTION)
1769 key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX;
1772 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1773 "disable key delete one entry\n");
1774 /*set local buf about wep key. */
1775 if (vif->type == NL80211_IFTYPE_AP ||
1776 vif->type == NL80211_IFTYPE_MESH_POINT) {
1778 rtl_cam_del_entry(hw, sta->addr);
1780 memset(rtlpriv->sec.key_buf[key_idx], 0, key->keylen);
1781 rtlpriv->sec.key_len[key_idx] = 0;
1782 eth_zero_addr(mac_addr);
1784 *mac80211 will delete entries one by one,
1785 *so don't use rtl_cam_reset_all_entry
1786 *or clear all entries here.
1788 rtl_wait_tx_report_acked(hw, 500); /* wait 500ms for TX ack */
1790 rtl_cam_delete_one_entry(hw, mac_addr, key_idx);
1793 pr_err("cmd_err:%x!!!!:\n", cmd);
1796 mutex_unlock(&rtlpriv->locks.conf_mutex);
1797 rtlpriv->sec.being_setkey = false;
1801 static void rtl_op_rfkill_poll(struct ieee80211_hw *hw)
1803 struct rtl_priv *rtlpriv = rtl_priv(hw);
1809 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
1812 mutex_lock(&rtlpriv->locks.conf_mutex);
1814 /*if Radio On return true here */
1815 radio_state = rtlpriv->cfg->ops->radio_onoff_checking(hw, &valid);
1818 if (unlikely(radio_state != rtlpriv->rfkill.rfkill_state)) {
1819 rtlpriv->rfkill.rfkill_state = radio_state;
1821 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
1822 "wireless radio switch turned %s\n",
1823 radio_state ? "on" : "off");
1825 blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1;
1826 wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
1830 mutex_unlock(&rtlpriv->locks.conf_mutex);
1833 /* this function is called by mac80211 to flush tx buffer
1834 * before switch channel or power save, or tx buffer packet
1835 * maybe send after offchannel or rf sleep, this may cause
1836 * dis-association by AP
1838 static void rtl_op_flush(struct ieee80211_hw *hw,
1839 struct ieee80211_vif *vif,
1843 struct rtl_priv *rtlpriv = rtl_priv(hw);
1845 if (rtlpriv->intf_ops->flush)
1846 rtlpriv->intf_ops->flush(hw, queues, drop);
1850 * This routine deals with the Power Configuration CMD
1851 * parsing for RTL8723/RTL8188E Series IC.
1853 * We should follow specific format that was released from HW SD.
1855 bool rtl_hal_pwrseqcmdparsing(struct rtl_priv *rtlpriv, u8 cut_version,
1856 u8 faversion, u8 interface_type,
1857 struct wlan_pwr_cfg pwrcfgcmd[])
1859 struct wlan_pwr_cfg cfg_cmd = {0};
1860 bool polling_bit = false;
1864 u32 polling_count = 0;
1865 u32 max_polling_cnt = 5000;
1868 cfg_cmd = pwrcfgcmd[ary_idx];
1869 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1870 "%s(): offset(%#x),cut_msk(%#x), famsk(%#x), interface_msk(%#x), base(%#x), cmd(%#x), msk(%#x), value(%#x)\n",
1871 __func__, GET_PWR_CFG_OFFSET(cfg_cmd),
1872 GET_PWR_CFG_CUT_MASK(cfg_cmd),
1873 GET_PWR_CFG_FAB_MASK(cfg_cmd),
1874 GET_PWR_CFG_INTF_MASK(cfg_cmd),
1875 GET_PWR_CFG_BASE(cfg_cmd), GET_PWR_CFG_CMD(cfg_cmd),
1876 GET_PWR_CFG_MASK(cfg_cmd), GET_PWR_CFG_VALUE(cfg_cmd));
1878 if ((GET_PWR_CFG_FAB_MASK(cfg_cmd) & faversion) &&
1879 (GET_PWR_CFG_CUT_MASK(cfg_cmd) & cut_version) &&
1880 (GET_PWR_CFG_INTF_MASK(cfg_cmd) & interface_type)) {
1881 switch (GET_PWR_CFG_CMD(cfg_cmd)) {
1883 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1884 "%s(): PWR_CMD_READ\n", __func__);
1887 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1888 "%s(): PWR_CMD_WRITE\n", __func__);
1889 offset = GET_PWR_CFG_OFFSET(cfg_cmd);
1891 /*Read the value from system register*/
1892 value = rtl_read_byte(rtlpriv, offset);
1893 value &= (~(GET_PWR_CFG_MASK(cfg_cmd)));
1894 value |= (GET_PWR_CFG_VALUE(cfg_cmd) &
1895 GET_PWR_CFG_MASK(cfg_cmd));
1897 /*Write the value back to system register*/
1898 rtl_write_byte(rtlpriv, offset, value);
1900 case PWR_CMD_POLLING:
1901 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1902 "%s(): PWR_CMD_POLLING\n", __func__);
1903 polling_bit = false;
1904 offset = GET_PWR_CFG_OFFSET(cfg_cmd);
1907 value = rtl_read_byte(rtlpriv, offset);
1909 value &= GET_PWR_CFG_MASK(cfg_cmd);
1911 (GET_PWR_CFG_VALUE(cfg_cmd) &
1912 GET_PWR_CFG_MASK(cfg_cmd)))
1917 if (polling_count++ > max_polling_cnt)
1919 } while (!polling_bit);
1922 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1923 "%s(): PWR_CMD_DELAY\n", __func__);
1924 if (GET_PWR_CFG_VALUE(cfg_cmd) ==
1926 udelay(GET_PWR_CFG_OFFSET(cfg_cmd));
1928 mdelay(GET_PWR_CFG_OFFSET(cfg_cmd));
1931 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1932 "%s(): PWR_CMD_END\n", __func__);
1936 "rtlwifi: %s(): Unknown CMD!!\n", __func__);
1946 bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)
1948 struct rtl_priv *rtlpriv = rtl_priv(hw);
1949 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1950 struct rtl8192_tx_ring *ring;
1951 struct rtl_tx_desc *pdesc;
1952 unsigned long flags;
1953 struct sk_buff *pskb = NULL;
1955 ring = &rtlpci->tx_ring[BEACON_QUEUE];
1957 spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags);
1958 pskb = __skb_dequeue(&ring->queue);
1960 dev_kfree_skb_irq(pskb);
1962 /*this is wrong, fill_tx_cmddesc needs update*/
1963 pdesc = &ring->desc[0];
1965 rtlpriv->cfg->ops->fill_tx_cmddesc(hw, (u8 *)pdesc, 1, 1, skb);
1967 __skb_queue_tail(&ring->queue, skb);
1969 spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags);
1971 rtlpriv->cfg->ops->tx_polling(hw, BEACON_QUEUE);
1976 const struct ieee80211_ops rtl_ops = {
1977 .start = rtl_op_start,
1978 .stop = rtl_op_stop,
1980 .add_interface = rtl_op_add_interface,
1981 .remove_interface = rtl_op_remove_interface,
1982 .change_interface = rtl_op_change_interface,
1984 .suspend = rtl_op_suspend,
1985 .resume = rtl_op_resume,
1987 .config = rtl_op_config,
1988 .configure_filter = rtl_op_configure_filter,
1989 .set_key = rtl_op_set_key,
1990 .sta_statistics = rtl_op_sta_statistics,
1991 .set_frag_threshold = rtl_op_set_frag_threshold,
1992 .conf_tx = rtl_op_conf_tx,
1993 .bss_info_changed = rtl_op_bss_info_changed,
1994 .get_tsf = rtl_op_get_tsf,
1995 .set_tsf = rtl_op_set_tsf,
1996 .reset_tsf = rtl_op_reset_tsf,
1997 .sta_notify = rtl_op_sta_notify,
1998 .ampdu_action = rtl_op_ampdu_action,
1999 .sw_scan_start = rtl_op_sw_scan_start,
2000 .sw_scan_complete = rtl_op_sw_scan_complete,
2001 .rfkill_poll = rtl_op_rfkill_poll,
2002 .sta_add = rtl_op_sta_add,
2003 .sta_remove = rtl_op_sta_remove,
2004 .flush = rtl_op_flush,
2007 bool rtl_btc_status_false(void)
2012 void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igvalue)
2014 struct rtl_priv *rtlpriv = rtl_priv(hw);
2015 struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
2017 dm_digtable->dig_enable_flag = true;
2018 dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
2019 dm_digtable->cur_igvalue = cur_igvalue;
2020 dm_digtable->pre_igvalue = 0;
2021 dm_digtable->cur_sta_cstate = DIG_STA_DISCONNECT;
2022 dm_digtable->presta_cstate = DIG_STA_DISCONNECT;
2023 dm_digtable->curmultista_cstate = DIG_MULTISTA_DISCONNECT;
2024 dm_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
2025 dm_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
2026 dm_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
2027 dm_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
2028 dm_digtable->rx_gain_max = DM_DIG_MAX;
2029 dm_digtable->rx_gain_min = DM_DIG_MIN;
2030 dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
2031 dm_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
2032 dm_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
2033 dm_digtable->pre_cck_cca_thres = 0xff;
2034 dm_digtable->cur_cck_cca_thres = 0x83;
2035 dm_digtable->forbidden_igi = DM_DIG_MIN;
2036 dm_digtable->large_fa_hit = 0;
2037 dm_digtable->recover_cnt = 0;
2038 dm_digtable->dig_min_0 = 0x25;
2039 dm_digtable->dig_min_1 = 0x25;
2040 dm_digtable->media_connect_0 = false;
2041 dm_digtable->media_connect_1 = false;
2042 rtlpriv->dm.dm_initialgain_enable = true;
2043 dm_digtable->bt30_cur_igi = 0x32;
2044 dm_digtable->pre_cck_pd_state = CCK_PD_STAGE_MAX;
2045 dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_LOWRSSI;