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 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
21 * Contact Information:
22 * wlanfae <wlanfae@realtek.com>
23 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
24 * Hsinchu 300, Taiwan.
26 * Larry Finger <Larry.Finger@lwfinger.net>
28 *****************************************************************************/
37 #include <linux/export.h>
39 void rtl_fw_cb(const struct firmware *firmware, void *context)
41 struct ieee80211_hw *hw = context;
42 struct rtl_priv *rtlpriv = rtl_priv(hw);
45 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
46 "Firmware callback routine entered!\n");
47 complete(&rtlpriv->firmware_loading_complete);
49 pr_err("Firmware %s not available\n", rtlpriv->cfg->fw_name);
50 rtlpriv->max_fw_size = 0;
53 if (firmware->size > rtlpriv->max_fw_size) {
54 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
55 "Firmware is too big!\n");
56 release_firmware(firmware);
59 memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size);
60 rtlpriv->rtlhal.fwsize = firmware->size;
61 release_firmware(firmware);
63 err = ieee80211_register_hw(hw);
65 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
66 "Can't register mac80211 hw\n");
69 rtlpriv->mac80211.mac80211_registered = 1;
71 set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status);
76 EXPORT_SYMBOL(rtl_fw_cb);
78 /*mutex for start & stop is must here. */
79 static int rtl_op_start(struct ieee80211_hw *hw)
82 struct rtl_priv *rtlpriv = rtl_priv(hw);
83 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
85 if (!is_hal_stop(rtlhal))
87 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
89 mutex_lock(&rtlpriv->locks.conf_mutex);
90 err = rtlpriv->intf_ops->adapter_start(hw);
92 rtl_watch_dog_timer_callback((unsigned long)hw);
93 mutex_unlock(&rtlpriv->locks.conf_mutex);
97 static void rtl_op_stop(struct ieee80211_hw *hw)
99 struct rtl_priv *rtlpriv = rtl_priv(hw);
100 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
101 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
102 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
104 if (is_hal_stop(rtlhal))
107 /* here is must, because adhoc do stop and start,
108 * but stop with RFOFF may cause something wrong,
111 if (unlikely(ppsc->rfpwr_state == ERFOFF)) {
115 mutex_lock(&rtlpriv->locks.conf_mutex);
117 mac->link_state = MAC80211_NOLINK;
118 memset(mac->bssid, 0, 6);
119 mac->vendor = PEER_UNKNOWN;
122 rtl_cam_reset_sec_info(hw);
124 rtl_deinit_deferred_work(hw);
125 rtlpriv->intf_ops->adapter_stop(hw);
127 mutex_unlock(&rtlpriv->locks.conf_mutex);
130 static void rtl_op_tx(struct ieee80211_hw *hw,
131 struct ieee80211_tx_control *control,
134 struct rtl_priv *rtlpriv = rtl_priv(hw);
135 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
136 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
137 struct rtl_tcb_desc tcb_desc;
138 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
140 if (unlikely(is_hal_stop(rtlhal) || ppsc->rfpwr_state != ERFON))
143 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
146 if (!rtlpriv->intf_ops->waitq_insert(hw, control->sta, skb))
147 rtlpriv->intf_ops->adapter_tx(hw, control->sta, skb, &tcb_desc);
152 dev_kfree_skb_any(skb);
155 static int rtl_op_add_interface(struct ieee80211_hw *hw,
156 struct ieee80211_vif *vif)
158 struct rtl_priv *rtlpriv = rtl_priv(hw);
159 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
162 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
165 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
166 "vif has been set!! mac->vif = 0x%p\n", mac->vif);
172 mutex_lock(&rtlpriv->locks.conf_mutex);
174 switch (ieee80211_vif_type_p2p(vif)) {
175 case NL80211_IFTYPE_P2P_CLIENT:
176 mac->p2p = P2P_ROLE_CLIENT;
178 case NL80211_IFTYPE_STATION:
179 if (mac->beacon_enabled == 1) {
180 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
181 "NL80211_IFTYPE_STATION\n");
182 mac->beacon_enabled = 0;
183 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
185 [RTL_IBSS_INT_MASKS]);
188 case NL80211_IFTYPE_ADHOC:
189 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
190 "NL80211_IFTYPE_ADHOC\n");
192 mac->link_state = MAC80211_LINKED;
193 rtlpriv->cfg->ops->set_bcn_reg(hw);
194 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
195 mac->basic_rates = 0xfff;
197 mac->basic_rates = 0xff0;
198 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
199 (u8 *) (&mac->basic_rates));
202 case NL80211_IFTYPE_P2P_GO:
203 mac->p2p = P2P_ROLE_GO;
205 case NL80211_IFTYPE_AP:
206 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
207 "NL80211_IFTYPE_AP\n");
209 mac->link_state = MAC80211_LINKED;
210 rtlpriv->cfg->ops->set_bcn_reg(hw);
211 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
212 mac->basic_rates = 0xfff;
214 mac->basic_rates = 0xff0;
215 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
216 (u8 *) (&mac->basic_rates));
218 case NL80211_IFTYPE_MESH_POINT:
219 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
220 "NL80211_IFTYPE_MESH_POINT\n");
222 mac->link_state = MAC80211_LINKED;
223 rtlpriv->cfg->ops->set_bcn_reg(hw);
224 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
225 mac->basic_rates = 0xfff;
227 mac->basic_rates = 0xff0;
228 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
229 (u8 *)(&mac->basic_rates));
232 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
233 "operation mode %d is not supported!\n", vif->type);
239 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
240 "p2p role %x\n", vif->type);
241 mac->basic_rates = 0xff0;/*disable cck rate for p2p*/
242 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
243 (u8 *)(&mac->basic_rates));
246 mac->opmode = vif->type;
247 rtlpriv->cfg->ops->set_network_type(hw, vif->type);
248 memcpy(mac->mac_addr, vif->addr, ETH_ALEN);
249 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, mac->mac_addr);
252 mutex_unlock(&rtlpriv->locks.conf_mutex);
256 static void rtl_op_remove_interface(struct ieee80211_hw *hw,
257 struct ieee80211_vif *vif)
259 struct rtl_priv *rtlpriv = rtl_priv(hw);
260 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
262 mutex_lock(&rtlpriv->locks.conf_mutex);
264 /* Free beacon resources */
265 if ((vif->type == NL80211_IFTYPE_AP) ||
266 (vif->type == NL80211_IFTYPE_ADHOC) ||
267 (vif->type == NL80211_IFTYPE_MESH_POINT)) {
268 if (mac->beacon_enabled == 1) {
269 mac->beacon_enabled = 0;
270 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
272 [RTL_IBSS_INT_MASKS]);
277 *Note: We assume NL80211_IFTYPE_UNSPECIFIED as
278 *NO LINK for our hardware.
282 mac->link_state = MAC80211_NOLINK;
283 memset(mac->bssid, 0, 6);
284 mac->vendor = PEER_UNKNOWN;
285 mac->opmode = NL80211_IFTYPE_UNSPECIFIED;
286 rtlpriv->cfg->ops->set_network_type(hw, mac->opmode);
287 mutex_unlock(&rtlpriv->locks.conf_mutex);
290 static int rtl_op_change_interface(struct ieee80211_hw *hw,
291 struct ieee80211_vif *vif,
292 enum nl80211_iftype new_type, bool p2p)
294 struct rtl_priv *rtlpriv = rtl_priv(hw);
296 rtl_op_remove_interface(hw, vif);
298 vif->type = new_type;
300 ret = rtl_op_add_interface(hw, vif);
301 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
306 static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
308 struct rtl_priv *rtlpriv = rtl_priv(hw);
309 struct rtl_phy *rtlphy = &(rtlpriv->phy);
310 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
311 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
312 struct ieee80211_conf *conf = &hw->conf;
317 mutex_lock(&rtlpriv->locks.conf_mutex);
318 if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { /*BIT(2)*/
319 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
320 "IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n");
324 if (changed & IEEE80211_CONF_CHANGE_IDLE) {
325 if (hw->conf.flags & IEEE80211_CONF_IDLE)
331 *although rfoff may not cause by ips, but we will
332 *check the reason in set_rf_power_state function
334 if (unlikely(ppsc->rfpwr_state == ERFOFF))
339 if (changed & IEEE80211_CONF_CHANGE_PS) {
340 cancel_delayed_work(&rtlpriv->works.ps_work);
341 cancel_delayed_work(&rtlpriv->works.ps_rfon_wq);
342 if (conf->flags & IEEE80211_CONF_PS) {
343 rtlpriv->psc.sw_ps_enabled = true;
344 /* sleep here is must, or we may recv the beacon and
345 * cause mac80211 into wrong ps state, this will cause
346 * power save nullfunc send fail, and further cause
347 * pkt loss, So sleep must quickly but not immediatly
348 * because that will cause nullfunc send by mac80211
349 * fail, and cause pkt loss, we have tested that 5mA
350 * is worked very well */
351 if (!rtlpriv->psc.multi_buffered)
352 queue_delayed_work(rtlpriv->works.rtl_wq,
353 &rtlpriv->works.ps_work,
356 rtl_swlps_rf_awake(hw);
357 rtlpriv->psc.sw_ps_enabled = false;
361 if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) {
362 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
363 "IEEE80211_CONF_CHANGE_RETRY_LIMITS %x\n",
364 hw->conf.long_frame_max_tx_count);
365 mac->retry_long = hw->conf.long_frame_max_tx_count;
366 mac->retry_short = hw->conf.long_frame_max_tx_count;
367 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
369 long_frame_max_tx_count));
372 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
373 struct ieee80211_channel *channel = hw->conf.channel;
374 u8 wide_chan = (u8) channel->hw_value;
376 if (mac->act_scanning)
379 if (rtlpriv->dm.supp_phymode_switch &&
380 mac->link_state < MAC80211_LINKED &&
381 !mac->act_scanning) {
382 if (rtlpriv->cfg->ops->chk_switch_dmdp)
383 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
387 *because we should back channel to
388 *current_network.chan in in scanning,
389 *So if set_chan == current_network.chan
391 *because mac80211 tell us wrong bw40
392 *info for cisco1253 bw20, so we modify
393 *it here based on UPPER & LOWER
395 switch (hw->conf.channel_type) {
396 case NL80211_CHAN_HT20:
397 case NL80211_CHAN_NO_HT:
399 mac->cur_40_prime_sc =
400 PRIME_CHNL_OFFSET_DONT_CARE;
401 rtlphy->current_chan_bw = HT_CHANNEL_WIDTH_20;
404 case NL80211_CHAN_HT40MINUS:
406 mac->cur_40_prime_sc = PRIME_CHNL_OFFSET_UPPER;
407 rtlphy->current_chan_bw =
408 HT_CHANNEL_WIDTH_20_40;
415 case NL80211_CHAN_HT40PLUS:
417 mac->cur_40_prime_sc = PRIME_CHNL_OFFSET_LOWER;
418 rtlphy->current_chan_bw =
419 HT_CHANNEL_WIDTH_20_40;
428 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
429 "switch case not processed\n");
436 /* In scanning, before we go offchannel we may send a ps = 1
437 * null to AP, and then we may send a ps = 0 null to AP quickly,
438 * but first null may have caused AP to put lots of packet to
439 * hw tx buffer. These packets must be tx'd before we go off
440 * channel so we must delay more time to let AP flush these
441 * packets before going offchannel, or dis-association or
442 * delete BA will be caused by AP
444 if (rtlpriv->mac80211.offchan_delay) {
445 rtlpriv->mac80211.offchan_delay = false;
448 rtlphy->current_channel = wide_chan;
450 rtlpriv->cfg->ops->switch_channel(hw);
451 rtlpriv->cfg->ops->set_channel_access(hw);
452 rtlpriv->cfg->ops->set_bw_mode(hw,
453 hw->conf.channel_type);
456 mutex_unlock(&rtlpriv->locks.conf_mutex);
461 static void rtl_op_configure_filter(struct ieee80211_hw *hw,
462 unsigned int changed_flags,
463 unsigned int *new_flags, u64 multicast)
465 struct rtl_priv *rtlpriv = rtl_priv(hw);
466 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
468 *new_flags &= RTL_SUPPORTED_FILTERS;
472 /*TODO: we disable broadcase now, so enable here */
473 if (changed_flags & FIF_ALLMULTI) {
474 if (*new_flags & FIF_ALLMULTI) {
475 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AM] |
476 rtlpriv->cfg->maps[MAC_RCR_AB];
477 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
478 "Enable receive multicast frame\n");
480 mac->rx_conf &= ~(rtlpriv->cfg->maps[MAC_RCR_AM] |
481 rtlpriv->cfg->maps[MAC_RCR_AB]);
482 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
483 "Disable receive multicast frame\n");
487 if (changed_flags & FIF_FCSFAIL) {
488 if (*new_flags & FIF_FCSFAIL) {
489 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACRC32];
490 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
491 "Enable receive FCS error frame\n");
493 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACRC32];
494 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
495 "Disable receive FCS error frame\n");
499 /* if ssid not set to hw don't check bssid
500 * here just used for linked scanning, & linked
501 * and nolink check bssid is set in set network_type */
502 if ((changed_flags & FIF_BCN_PRBRESP_PROMISC) &&
503 (mac->link_state >= MAC80211_LINKED)) {
504 if (mac->opmode != NL80211_IFTYPE_AP &&
505 mac->opmode != NL80211_IFTYPE_MESH_POINT) {
506 if (*new_flags & FIF_BCN_PRBRESP_PROMISC) {
507 rtlpriv->cfg->ops->set_chk_bssid(hw, false);
509 rtlpriv->cfg->ops->set_chk_bssid(hw, true);
514 if (changed_flags & FIF_CONTROL) {
515 if (*new_flags & FIF_CONTROL) {
516 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACF];
518 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
519 "Enable receive control frame\n");
521 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACF];
522 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
523 "Disable receive control frame\n");
527 if (changed_flags & FIF_OTHER_BSS) {
528 if (*new_flags & FIF_OTHER_BSS) {
529 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AAP];
530 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
531 "Enable receive other BSS's frame\n");
533 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_AAP];
534 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
535 "Disable receive other BSS's frame\n");
539 static int rtl_op_sta_add(struct ieee80211_hw *hw,
540 struct ieee80211_vif *vif,
541 struct ieee80211_sta *sta)
543 struct rtl_priv *rtlpriv = rtl_priv(hw);
544 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
545 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
546 struct rtl_sta_info *sta_entry;
549 sta_entry = (struct rtl_sta_info *) sta->drv_priv;
550 spin_lock_bh(&rtlpriv->locks.entry_list_lock);
551 list_add_tail(&sta_entry->list, &rtlpriv->entry_list);
552 spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
553 if (rtlhal->current_bandtype == BAND_ON_2_4G) {
554 sta_entry->wireless_mode = WIRELESS_MODE_G;
555 if (sta->supp_rates[0] <= 0xf)
556 sta_entry->wireless_mode = WIRELESS_MODE_B;
557 if (sta->ht_cap.ht_supported == true)
558 sta_entry->wireless_mode = WIRELESS_MODE_N_24G;
560 if (vif->type == NL80211_IFTYPE_ADHOC)
561 sta_entry->wireless_mode = WIRELESS_MODE_G;
562 } else if (rtlhal->current_bandtype == BAND_ON_5G) {
563 sta_entry->wireless_mode = WIRELESS_MODE_A;
564 if (sta->ht_cap.ht_supported == true)
565 sta_entry->wireless_mode = WIRELESS_MODE_N_24G;
567 if (vif->type == NL80211_IFTYPE_ADHOC)
568 sta_entry->wireless_mode = WIRELESS_MODE_A;
570 /*disable cck rate for p2p*/
572 sta->supp_rates[0] &= 0xfffffff0;
574 memcpy(sta_entry->mac_addr, sta->addr, ETH_ALEN);
575 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
576 "Add sta addr is %pM\n", sta->addr);
577 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0);
582 static int rtl_op_sta_remove(struct ieee80211_hw *hw,
583 struct ieee80211_vif *vif,
584 struct ieee80211_sta *sta)
586 struct rtl_priv *rtlpriv = rtl_priv(hw);
587 struct rtl_sta_info *sta_entry;
589 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
590 "Remove sta addr is %pM\n", sta->addr);
591 sta_entry = (struct rtl_sta_info *) sta->drv_priv;
592 sta_entry->wireless_mode = 0;
593 sta_entry->ratr_index = 0;
595 spin_lock_bh(&rtlpriv->locks.entry_list_lock);
596 list_del(&sta_entry->list);
597 spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
602 static int _rtl_get_hal_qnum(u16 queue)
627 *for mac80211 VO = 0, VI = 1, BE = 2, BK = 3
628 *for rtl819x BE = 0, BK = 1, VI = 2, VO = 3
630 static int rtl_op_conf_tx(struct ieee80211_hw *hw,
631 struct ieee80211_vif *vif, u16 queue,
632 const struct ieee80211_tx_queue_params *param)
634 struct rtl_priv *rtlpriv = rtl_priv(hw);
635 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
638 if (queue >= AC_MAX) {
639 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
640 "queue number %d is incorrect!\n", queue);
644 aci = _rtl_get_hal_qnum(queue);
645 mac->ac[aci].aifs = param->aifs;
646 mac->ac[aci].cw_min = cpu_to_le16(param->cw_min);
647 mac->ac[aci].cw_max = cpu_to_le16(param->cw_max);
648 mac->ac[aci].tx_op = cpu_to_le16(param->txop);
649 memcpy(&mac->edca_param[aci], param, sizeof(*param));
650 rtlpriv->cfg->ops->set_qos(hw, aci);
654 static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
655 struct ieee80211_vif *vif,
656 struct ieee80211_bss_conf *bss_conf, u32 changed)
658 struct rtl_priv *rtlpriv = rtl_priv(hw);
659 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
660 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
661 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
662 struct ieee80211_sta *sta = NULL;
664 mutex_lock(&rtlpriv->locks.conf_mutex);
665 if ((vif->type == NL80211_IFTYPE_ADHOC) ||
666 (vif->type == NL80211_IFTYPE_AP) ||
667 (vif->type == NL80211_IFTYPE_MESH_POINT)) {
668 if ((changed & BSS_CHANGED_BEACON) ||
669 (changed & BSS_CHANGED_BEACON_ENABLED &&
670 bss_conf->enable_beacon)) {
671 if (mac->beacon_enabled == 0) {
672 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
673 "BSS_CHANGED_BEACON_ENABLED\n");
675 /*start hw beacon interrupt. */
676 /*rtlpriv->cfg->ops->set_bcn_reg(hw); */
677 mac->beacon_enabled = 1;
678 rtlpriv->cfg->ops->update_interrupt_mask(hw,
680 [RTL_IBSS_INT_MASKS],
683 if (rtlpriv->cfg->ops->linked_set_reg)
684 rtlpriv->cfg->ops->linked_set_reg(hw);
687 if ((changed & BSS_CHANGED_BEACON_ENABLED &&
688 !bss_conf->enable_beacon)) {
689 if (mac->beacon_enabled == 1) {
690 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
691 "ADHOC DISABLE BEACON\n");
693 mac->beacon_enabled = 0;
694 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
696 [RTL_IBSS_INT_MASKS]);
699 if (changed & BSS_CHANGED_BEACON_INT) {
700 RT_TRACE(rtlpriv, COMP_BEACON, DBG_TRACE,
701 "BSS_CHANGED_BEACON_INT\n");
702 mac->beacon_interval = bss_conf->beacon_int;
703 rtlpriv->cfg->ops->set_bcn_intv(hw);
707 /*TODO: reference to enum ieee80211_bss_change */
708 if (changed & BSS_CHANGED_ASSOC) {
709 if (bss_conf->assoc) {
710 struct ieee80211_sta *sta = NULL;
711 /* we should reset all sec info & cam
712 * before set cam after linked, we should not
713 * reset in disassoc, that will cause tkip->wep
714 * fail because some flag will be wrong */
716 rtl_cam_reset_sec_info(hw);
717 /* reset cam to fix wep fail issue
718 * when change from wpa to wep */
719 rtl_cam_reset_all_entry(hw);
721 mac->link_state = MAC80211_LINKED;
722 mac->cnt_after_linked = 0;
723 mac->assoc_id = bss_conf->aid;
724 memcpy(mac->bssid, bss_conf->bssid, 6);
726 if (rtlpriv->cfg->ops->linked_set_reg)
727 rtlpriv->cfg->ops->linked_set_reg(hw);
729 sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid);
731 if (vif->type == NL80211_IFTYPE_STATION && sta)
732 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0);
733 RT_TRACE(rtlpriv, COMP_EASY_CONCURRENT, DBG_LOUD,
734 "send PS STATIC frame\n");
735 if (rtlpriv->dm.supp_phymode_switch) {
736 if (sta->ht_cap.ht_supported)
737 rtl_send_smps_action(hw, sta,
738 IEEE80211_SMPS_STATIC);
742 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
743 "BSS_CHANGED_ASSOC\n");
745 if (mac->link_state == MAC80211_LINKED)
746 schedule_work(&rtlpriv->works.lps_leave_work);
748 if (ppsc->p2p_ps_info.p2p_ps_mode > P2P_PS_NONE)
749 rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE);
750 mac->link_state = MAC80211_NOLINK;
751 memset(mac->bssid, 0, 6);
752 mac->vendor = PEER_UNKNOWN;
754 if (rtlpriv->dm.supp_phymode_switch) {
755 if (rtlpriv->cfg->ops->chk_switch_dmdp)
756 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
759 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
760 "BSS_CHANGED_UN_ASSOC\n");
764 if (changed & BSS_CHANGED_ERP_CTS_PROT) {
765 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
766 "BSS_CHANGED_ERP_CTS_PROT\n");
767 mac->use_cts_protect = bss_conf->use_cts_prot;
770 if (changed & BSS_CHANGED_ERP_PREAMBLE) {
771 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
772 "BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n",
773 bss_conf->use_short_preamble);
775 mac->short_preamble = bss_conf->use_short_preamble;
776 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACK_PREAMBLE,
777 &mac->short_preamble);
780 if (changed & BSS_CHANGED_ERP_SLOT) {
781 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
782 "BSS_CHANGED_ERP_SLOT\n");
784 if (bss_conf->use_short_slot)
785 mac->slot_time = RTL_SLOT_TIME_9;
787 mac->slot_time = RTL_SLOT_TIME_20;
789 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME,
793 if (changed & BSS_CHANGED_HT) {
794 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, "BSS_CHANGED_HT\n");
796 sta = get_sta(hw, vif, bss_conf->bssid);
798 if (sta->ht_cap.ampdu_density >
799 mac->current_ampdu_density)
800 mac->current_ampdu_density =
801 sta->ht_cap.ampdu_density;
802 if (sta->ht_cap.ampdu_factor <
803 mac->current_ampdu_factor)
804 mac->current_ampdu_factor =
805 sta->ht_cap.ampdu_factor;
809 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SHORTGI_DENSITY,
810 &mac->max_mss_density);
811 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_FACTOR,
812 &mac->current_ampdu_factor);
813 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_MIN_SPACE,
814 &mac->current_ampdu_density);
817 if (changed & BSS_CHANGED_BSSID) {
820 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BSSID,
821 (u8 *) bss_conf->bssid);
823 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, "%pM\n",
826 mac->vendor = PEER_UNKNOWN;
827 memcpy(mac->bssid, bss_conf->bssid, 6);
828 rtlpriv->cfg->ops->set_network_type(hw, vif->type);
831 sta = get_sta(hw, vif, bss_conf->bssid);
837 if (rtlhal->current_bandtype == BAND_ON_5G) {
838 mac->mode = WIRELESS_MODE_A;
840 if (sta->supp_rates[0] <= 0xf)
841 mac->mode = WIRELESS_MODE_B;
843 mac->mode = WIRELESS_MODE_G;
846 if (sta->ht_cap.ht_supported) {
847 if (rtlhal->current_bandtype == BAND_ON_2_4G)
848 mac->mode = WIRELESS_MODE_N_24G;
850 mac->mode = WIRELESS_MODE_N_5G;
853 /* just station need it, because ibss & ap mode will
854 * set in sta_add, and will be NULL here */
855 if (mac->opmode == NL80211_IFTYPE_STATION) {
856 struct rtl_sta_info *sta_entry;
857 sta_entry = (struct rtl_sta_info *) sta->drv_priv;
858 sta_entry->wireless_mode = mac->mode;
861 if (sta->ht_cap.ht_supported) {
862 mac->ht_enable = true;
865 * for cisco 1252 bw20 it's wrong
866 * if (ht_cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
872 if (changed & BSS_CHANGED_BASIC_RATES) {
873 /* for 5G must << RATE_6M_INDEX = 4,
874 * because 5G have no cck rate*/
875 if (rtlhal->current_bandtype == BAND_ON_5G)
876 basic_rates = sta->supp_rates[1] << 4;
878 basic_rates = sta->supp_rates[0];
880 mac->basic_rates = basic_rates;
881 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
882 (u8 *) (&basic_rates));
889 * To tell firmware we have connected
890 * to an AP. For 92SE/CE power save v2.
892 if (changed & BSS_CHANGED_ASSOC) {
893 if (bss_conf->assoc) {
894 if (ppsc->fwctrl_lps) {
895 u8 mstatus = RT_MEDIA_CONNECT;
896 rtlpriv->cfg->ops->set_hw_reg(hw,
897 HW_VAR_H2C_FW_JOINBSSRPT,
899 ppsc->report_linked = true;
902 if (ppsc->fwctrl_lps) {
903 u8 mstatus = RT_MEDIA_DISCONNECT;
904 rtlpriv->cfg->ops->set_hw_reg(hw,
905 HW_VAR_H2C_FW_JOINBSSRPT,
907 ppsc->report_linked = false;
910 if (rtlpriv->cfg->ops->bt_wifi_media_status_notify)
911 rtlpriv->cfg->ops->bt_wifi_media_status_notify(hw,
912 ppsc->report_linked);
916 mutex_unlock(&rtlpriv->locks.conf_mutex);
919 static u64 rtl_op_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
921 struct rtl_priv *rtlpriv = rtl_priv(hw);
924 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *) (&tsf));
928 static void rtl_op_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
931 struct rtl_priv *rtlpriv = rtl_priv(hw);
932 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
933 u8 bibss = (mac->opmode == NL80211_IFTYPE_ADHOC) ? 1 : 0;
936 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_CORRECT_TSF, &bibss);
939 static void rtl_op_reset_tsf(struct ieee80211_hw *hw,
940 struct ieee80211_vif *vif)
942 struct rtl_priv *rtlpriv = rtl_priv(hw);
945 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_DUAL_TSF_RST, &tmp);
948 static void rtl_op_sta_notify(struct ieee80211_hw *hw,
949 struct ieee80211_vif *vif,
950 enum sta_notify_cmd cmd,
951 struct ieee80211_sta *sta)
954 case STA_NOTIFY_SLEEP:
956 case STA_NOTIFY_AWAKE:
963 static int rtl_op_ampdu_action(struct ieee80211_hw *hw,
964 struct ieee80211_vif *vif,
965 enum ieee80211_ampdu_mlme_action action,
966 struct ieee80211_sta *sta, u16 tid, u16 *ssn,
969 struct rtl_priv *rtlpriv = rtl_priv(hw);
972 case IEEE80211_AMPDU_TX_START:
973 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
974 "IEEE80211_AMPDU_TX_START: TID:%d\n", tid);
975 return rtl_tx_agg_start(hw, sta, tid, ssn);
977 case IEEE80211_AMPDU_TX_STOP_CONT:
978 case IEEE80211_AMPDU_TX_STOP_FLUSH:
979 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
980 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
981 "IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid);
982 return rtl_tx_agg_stop(hw, sta, tid);
983 case IEEE80211_AMPDU_TX_OPERATIONAL:
984 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
985 "IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid);
986 rtl_tx_agg_oper(hw, sta, tid);
988 case IEEE80211_AMPDU_RX_START:
989 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
990 "IEEE80211_AMPDU_RX_START:TID:%d\n", tid);
991 return rtl_rx_agg_start(hw, sta, tid);
992 case IEEE80211_AMPDU_RX_STOP:
993 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
994 "IEEE80211_AMPDU_RX_STOP:TID:%d\n", tid);
995 return rtl_rx_agg_stop(hw, sta, tid);
997 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
998 "IEEE80211_AMPDU_ERR!!!!:\n");
1004 static void rtl_op_sw_scan_start(struct ieee80211_hw *hw)
1006 struct rtl_priv *rtlpriv = rtl_priv(hw);
1007 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1009 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
1010 mac->act_scanning = true;
1011 if (rtlpriv->link_info.higher_busytraffic) {
1012 mac->skip_scan = true;
1016 if (rtlpriv->dm.supp_phymode_switch) {
1017 if (rtlpriv->cfg->ops->chk_switch_dmdp)
1018 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
1020 if (mac->link_state == MAC80211_LINKED) {
1021 schedule_work(&rtlpriv->works.lps_leave_work);
1022 mac->link_state = MAC80211_LINKED_SCANNING;
1028 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false;
1030 rtlpriv->cfg->ops->led_control(hw, LED_CTL_SITE_SURVEY);
1031 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_BACKUP);
1034 static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw)
1036 struct rtl_priv *rtlpriv = rtl_priv(hw);
1037 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1039 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
1040 mac->act_scanning = false;
1041 mac->skip_scan = false;
1042 if (rtlpriv->link_info.higher_busytraffic)
1045 /*p2p will use 1/6/11 to scan */
1046 if (mac->n_channels == 3)
1047 mac->p2p_in_use = true;
1049 mac->p2p_in_use = false;
1050 mac->n_channels = 0;
1052 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false;
1054 if (mac->link_state == MAC80211_LINKED_SCANNING) {
1055 mac->link_state = MAC80211_LINKED;
1056 if (mac->opmode == NL80211_IFTYPE_STATION) {
1057 /* fix fwlps issue */
1058 rtlpriv->cfg->ops->set_network_type(hw, mac->opmode);
1062 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_RESTORE);
1065 static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1066 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
1067 struct ieee80211_key_conf *key)
1069 struct rtl_priv *rtlpriv = rtl_priv(hw);
1070 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1071 u8 key_type = NO_ENCRYPTION;
1073 bool group_key = false;
1074 bool wep_only = false;
1076 u8 mac_addr[ETH_ALEN];
1077 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1079 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) {
1080 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1081 "not open hw encryption\n");
1082 return -ENOSPC; /*User disabled HW-crypto */
1084 /* To support IBSS, use sw-crypto for GTK */
1085 if (((vif->type == NL80211_IFTYPE_ADHOC) ||
1086 (vif->type == NL80211_IFTYPE_MESH_POINT)) &&
1087 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
1089 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1090 "%s hardware based encryption for keyidx: %d, mac: %pM\n",
1091 cmd == SET_KEY ? "Using" : "Disabling", key->keyidx,
1092 sta ? sta->addr : bcast_addr);
1093 rtlpriv->sec.being_setkey = true;
1095 mutex_lock(&rtlpriv->locks.conf_mutex);
1096 /* <1> get encryption alg */
1098 switch (key->cipher) {
1099 case WLAN_CIPHER_SUITE_WEP40:
1100 key_type = WEP40_ENCRYPTION;
1101 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:WEP40\n");
1103 case WLAN_CIPHER_SUITE_WEP104:
1104 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:WEP104\n");
1105 key_type = WEP104_ENCRYPTION;
1107 case WLAN_CIPHER_SUITE_TKIP:
1108 key_type = TKIP_ENCRYPTION;
1109 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:TKIP\n");
1111 case WLAN_CIPHER_SUITE_CCMP:
1112 key_type = AESCCMP_ENCRYPTION;
1113 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CCMP\n");
1115 case WLAN_CIPHER_SUITE_AES_CMAC:
1116 /*HW doesn't support CMAC encryption, use software CMAC */
1117 key_type = AESCMAC_ENCRYPTION;
1118 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CMAC\n");
1119 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1120 "HW don't support CMAC encryption, use software CMAC\n");
1124 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "alg_err:%x!!!!\n",
1128 if (key_type == WEP40_ENCRYPTION ||
1129 key_type == WEP104_ENCRYPTION ||
1130 mac->opmode == NL80211_IFTYPE_ADHOC)
1131 rtlpriv->sec.use_defaultkey = true;
1133 /* <2> get key_idx */
1134 key_idx = (u8) (key->keyidx);
1137 /* <3> if pairwise key enable_hw_sec */
1138 group_key = !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE);
1140 /* wep always be group key, but there are two conditions:
1141 * 1) wep only: is just for wep enc, in this condition
1142 * rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION
1143 * will be true & enable_hw_sec will be set when wep
1145 * 2) wep(group) + AES(pairwise): some AP like cisco
1146 * may use it, in this condition enable_hw_sec will not
1147 * be set when wep key setting */
1148 /* we must reset sec_info after lingked before set key,
1149 * or some flag will be wrong*/
1150 if (vif->type == NL80211_IFTYPE_AP ||
1151 vif->type == NL80211_IFTYPE_MESH_POINT) {
1152 if (!group_key || key_type == WEP40_ENCRYPTION ||
1153 key_type == WEP104_ENCRYPTION) {
1156 rtlpriv->cfg->ops->enable_hw_sec(hw);
1159 if ((!group_key) || (mac->opmode == NL80211_IFTYPE_ADHOC) ||
1160 rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION) {
1161 if (rtlpriv->sec.pairwise_enc_algorithm ==
1163 (key_type == WEP40_ENCRYPTION ||
1164 key_type == WEP104_ENCRYPTION))
1166 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1167 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1168 "set enable_hw_sec, key_type:%x(OPEN:0 WEP40:1 TKIP:2 AES:4 WEP104:5)\n",
1170 rtlpriv->cfg->ops->enable_hw_sec(hw);
1173 /* <4> set key based on cmd */
1177 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1178 "set WEP(group/pairwise) key\n");
1179 /* Pairwise key with an assigned MAC address. */
1180 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1181 rtlpriv->sec.group_enc_algorithm = key_type;
1182 /*set local buf about wep key. */
1183 memcpy(rtlpriv->sec.key_buf[key_idx],
1184 key->key, key->keylen);
1185 rtlpriv->sec.key_len[key_idx] = key->keylen;
1186 eth_zero_addr(mac_addr);
1187 } else if (group_key) { /* group key */
1188 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1191 rtlpriv->sec.group_enc_algorithm = key_type;
1192 /*set local buf about group key. */
1193 memcpy(rtlpriv->sec.key_buf[key_idx],
1194 key->key, key->keylen);
1195 rtlpriv->sec.key_len[key_idx] = key->keylen;
1196 memcpy(mac_addr, bcast_addr, ETH_ALEN);
1197 } else { /* pairwise key */
1198 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1199 "set pairwise key\n");
1202 "pairwise key without mac_addr\n");
1207 /* Pairwise key with an assigned MAC address. */
1208 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1209 /*set local buf about pairwise key. */
1210 memcpy(rtlpriv->sec.key_buf[PAIRWISE_KEYIDX],
1211 key->key, key->keylen);
1212 rtlpriv->sec.key_len[PAIRWISE_KEYIDX] = key->keylen;
1213 rtlpriv->sec.pairwise_key =
1214 rtlpriv->sec.key_buf[PAIRWISE_KEYIDX];
1215 memcpy(mac_addr, sta->addr, ETH_ALEN);
1217 rtlpriv->cfg->ops->set_key(hw, key_idx, mac_addr,
1218 group_key, key_type, wep_only,
1220 /* <5> tell mac80211 do something: */
1221 /*must use sw generate IV, or can not work !!!!. */
1222 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
1223 key->hw_key_idx = key_idx;
1224 if (key_type == TKIP_ENCRYPTION)
1225 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
1226 /*use software CCMP encryption for management frames (MFP) */
1227 if (key_type == AESCCMP_ENCRYPTION)
1228 key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX;
1231 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1232 "disable key delete one entry\n");
1233 /*set local buf about wep key. */
1234 if (vif->type == NL80211_IFTYPE_AP ||
1235 vif->type == NL80211_IFTYPE_MESH_POINT) {
1237 rtl_cam_del_entry(hw, sta->addr);
1239 memset(rtlpriv->sec.key_buf[key_idx], 0, key->keylen);
1240 rtlpriv->sec.key_len[key_idx] = 0;
1241 eth_zero_addr(mac_addr);
1243 *mac80211 will delete entrys one by one,
1244 *so don't use rtl_cam_reset_all_entry
1245 *or clear all entry here.
1247 rtl_cam_delete_one_entry(hw, mac_addr, key_idx);
1249 rtl_cam_reset_sec_info(hw);
1253 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1254 "cmd_err:%x!!!!\n", cmd);
1257 mutex_unlock(&rtlpriv->locks.conf_mutex);
1258 rtlpriv->sec.being_setkey = false;
1262 static void rtl_op_rfkill_poll(struct ieee80211_hw *hw)
1264 struct rtl_priv *rtlpriv = rtl_priv(hw);
1270 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
1273 mutex_lock(&rtlpriv->locks.conf_mutex);
1275 /*if Radio On return true here */
1276 radio_state = rtlpriv->cfg->ops->radio_onoff_checking(hw, &valid);
1279 if (unlikely(radio_state != rtlpriv->rfkill.rfkill_state)) {
1280 rtlpriv->rfkill.rfkill_state = radio_state;
1282 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
1283 "wireless radio switch turned %s\n",
1284 radio_state ? "on" : "off");
1286 blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1;
1287 wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
1291 mutex_unlock(&rtlpriv->locks.conf_mutex);
1294 /* this function is called by mac80211 to flush tx buffer
1295 * before switch channel or power save, or tx buffer packet
1296 * maybe send after offchannel or rf sleep, this may cause
1297 * dis-association by AP */
1298 static void rtl_op_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
1300 struct rtl_priv *rtlpriv = rtl_priv(hw);
1302 if (rtlpriv->intf_ops->flush)
1303 rtlpriv->intf_ops->flush(hw, drop);
1306 const struct ieee80211_ops rtl_ops = {
1307 .start = rtl_op_start,
1308 .stop = rtl_op_stop,
1310 .add_interface = rtl_op_add_interface,
1311 .remove_interface = rtl_op_remove_interface,
1312 .change_interface = rtl_op_change_interface,
1313 .config = rtl_op_config,
1314 .configure_filter = rtl_op_configure_filter,
1315 .sta_add = rtl_op_sta_add,
1316 .sta_remove = rtl_op_sta_remove,
1317 .set_key = rtl_op_set_key,
1318 .conf_tx = rtl_op_conf_tx,
1319 .bss_info_changed = rtl_op_bss_info_changed,
1320 .get_tsf = rtl_op_get_tsf,
1321 .set_tsf = rtl_op_set_tsf,
1322 .reset_tsf = rtl_op_reset_tsf,
1323 .sta_notify = rtl_op_sta_notify,
1324 .ampdu_action = rtl_op_ampdu_action,
1325 .sw_scan_start = rtl_op_sw_scan_start,
1326 .sw_scan_complete = rtl_op_sw_scan_complete,
1327 .rfkill_poll = rtl_op_rfkill_poll,
1328 .flush = rtl_op_flush,