OMAPDSS: VENC: fix NULL pointer dereference in DSS2 VENC sysfs debug attr on OMAP4
[zen-stable.git] / drivers / net / wireless / rtlwifi / core.c
blob79b7b16e449241317ad2dafc7a638c883bc56084
1 /******************************************************************************
3 * Copyright(c) 2009-2010 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
12 * more details.
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 *****************************************************************************/
30 #include "wifi.h"
31 #include "core.h"
32 #include "cam.h"
33 #include "base.h"
34 #include "pci.h"
35 #include "ps.h"
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);
43 int err;
45 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
46 ("Firmware callback routine entered!\n"));
47 complete(&rtlpriv->firmware_loading_complete);
48 if (!firmware) {
49 pr_err("Firmware %s not available\n", rtlpriv->cfg->fw_name);
50 rtlpriv->max_fw_size = 0;
51 return;
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);
57 return;
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);
64 if (err) {
65 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
66 ("Can't register mac80211 hw\n"));
67 return;
68 } else {
69 rtlpriv->mac80211.mac80211_registered = 1;
71 set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status);
73 /*init rfkill */
74 rtl_init_rfkill(hw);
76 EXPORT_SYMBOL(rtl_fw_cb);
78 /*mutex for start & stop is must here. */
79 static int rtl_op_start(struct ieee80211_hw *hw)
81 int err;
82 struct rtl_priv *rtlpriv = rtl_priv(hw);
83 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
85 if (!is_hal_stop(rtlhal))
86 return 0;
87 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
88 return 0;
89 mutex_lock(&rtlpriv->locks.conf_mutex);
90 err = rtlpriv->intf_ops->adapter_start(hw);
91 if (!err)
92 rtl_watch_dog_timer_callback((unsigned long)hw);
93 mutex_unlock(&rtlpriv->locks.conf_mutex);
94 return err;
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))
105 return;
107 if (unlikely(ppsc->rfpwr_state == ERFOFF)) {
108 rtl_ips_nic_on(hw);
109 mdelay(1);
112 mutex_lock(&rtlpriv->locks.conf_mutex);
114 mac->link_state = MAC80211_NOLINK;
115 memset(mac->bssid, 0, 6);
116 mac->vendor = PEER_UNKNOWN;
118 /*reset sec info */
119 rtl_cam_reset_sec_info(hw);
121 rtl_deinit_deferred_work(hw);
122 rtlpriv->intf_ops->adapter_stop(hw);
124 mutex_unlock(&rtlpriv->locks.conf_mutex);
127 static void rtl_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
129 struct rtl_priv *rtlpriv = rtl_priv(hw);
130 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
131 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
132 struct rtl_tcb_desc tcb_desc;
133 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
135 if (unlikely(is_hal_stop(rtlhal) || ppsc->rfpwr_state != ERFON))
136 goto err_free;
138 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
139 goto err_free;
141 if (!rtlpriv->intf_ops->waitq_insert(hw, skb))
142 rtlpriv->intf_ops->adapter_tx(hw, skb, &tcb_desc);
144 return;
146 err_free:
147 dev_kfree_skb_any(skb);
150 static int rtl_op_add_interface(struct ieee80211_hw *hw,
151 struct ieee80211_vif *vif)
153 struct rtl_priv *rtlpriv = rtl_priv(hw);
154 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
155 int err = 0;
157 if (mac->vif) {
158 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
159 ("vif has been set!! mac->vif = 0x%p\n", mac->vif));
160 return -EOPNOTSUPP;
163 rtl_ips_nic_on(hw);
165 mutex_lock(&rtlpriv->locks.conf_mutex);
166 switch (vif->type) {
167 case NL80211_IFTYPE_STATION:
168 if (mac->beacon_enabled == 1) {
169 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
170 ("NL80211_IFTYPE_STATION\n"));
171 mac->beacon_enabled = 0;
172 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
173 rtlpriv->cfg->maps
174 [RTL_IBSS_INT_MASKS]);
176 break;
177 case NL80211_IFTYPE_ADHOC:
178 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
179 ("NL80211_IFTYPE_ADHOC\n"));
181 mac->link_state = MAC80211_LINKED;
182 rtlpriv->cfg->ops->set_bcn_reg(hw);
183 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
184 mac->basic_rates = 0xfff;
185 else
186 mac->basic_rates = 0xff0;
187 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
188 (u8 *) (&mac->basic_rates));
190 break;
191 case NL80211_IFTYPE_AP:
192 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
193 ("NL80211_IFTYPE_AP\n"));
195 mac->link_state = MAC80211_LINKED;
196 rtlpriv->cfg->ops->set_bcn_reg(hw);
197 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G)
198 mac->basic_rates = 0xfff;
199 else
200 mac->basic_rates = 0xff0;
201 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
202 (u8 *) (&mac->basic_rates));
203 break;
204 default:
205 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
206 ("operation mode %d is not support!\n", vif->type));
207 err = -EOPNOTSUPP;
208 goto out;
211 mac->vif = vif;
212 mac->opmode = vif->type;
213 rtlpriv->cfg->ops->set_network_type(hw, vif->type);
214 memcpy(mac->mac_addr, vif->addr, ETH_ALEN);
215 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, mac->mac_addr);
217 out:
218 mutex_unlock(&rtlpriv->locks.conf_mutex);
219 return err;
222 static void rtl_op_remove_interface(struct ieee80211_hw *hw,
223 struct ieee80211_vif *vif)
225 struct rtl_priv *rtlpriv = rtl_priv(hw);
226 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
228 mutex_lock(&rtlpriv->locks.conf_mutex);
230 /* Free beacon resources */
231 if ((mac->opmode == NL80211_IFTYPE_AP) ||
232 (mac->opmode == NL80211_IFTYPE_ADHOC) ||
233 (mac->opmode == NL80211_IFTYPE_MESH_POINT)) {
234 if (mac->beacon_enabled == 1) {
235 mac->beacon_enabled = 0;
236 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
237 rtlpriv->cfg->maps
238 [RTL_IBSS_INT_MASKS]);
243 *Note: We assume NL80211_IFTYPE_UNSPECIFIED as
244 *NO LINK for our hardware.
246 mac->vif = NULL;
247 mac->link_state = MAC80211_NOLINK;
248 memset(mac->bssid, 0, 6);
249 mac->vendor = PEER_UNKNOWN;
250 mac->opmode = NL80211_IFTYPE_UNSPECIFIED;
251 rtlpriv->cfg->ops->set_network_type(hw, mac->opmode);
252 mutex_unlock(&rtlpriv->locks.conf_mutex);
255 static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
257 struct rtl_priv *rtlpriv = rtl_priv(hw);
258 struct rtl_phy *rtlphy = &(rtlpriv->phy);
259 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
260 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
261 struct ieee80211_conf *conf = &hw->conf;
263 mutex_lock(&rtlpriv->locks.conf_mutex);
264 if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { /*BIT(2)*/
265 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
266 ("IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n"));
269 /*For IPS */
270 if (changed & IEEE80211_CONF_CHANGE_IDLE) {
271 if (hw->conf.flags & IEEE80211_CONF_IDLE)
272 rtl_ips_nic_off(hw);
273 else
274 rtl_ips_nic_on(hw);
275 } else {
277 *although rfoff may not cause by ips, but we will
278 *check the reason in set_rf_power_state function
280 if (unlikely(ppsc->rfpwr_state == ERFOFF))
281 rtl_ips_nic_on(hw);
284 /*For LPS */
285 if (changed & IEEE80211_CONF_CHANGE_PS) {
286 cancel_delayed_work(&rtlpriv->works.ps_work);
287 cancel_delayed_work(&rtlpriv->works.ps_rfon_wq);
288 if (conf->flags & IEEE80211_CONF_PS) {
289 rtlpriv->psc.sw_ps_enabled = true;
290 /* sleep here is must, or we may recv the beacon and
291 * cause mac80211 into wrong ps state, this will cause
292 * power save nullfunc send fail, and further cause
293 * pkt loss, So sleep must quickly but not immediatly
294 * because that will cause nullfunc send by mac80211
295 * fail, and cause pkt loss, we have tested that 5mA
296 * is worked very well */
297 if (!rtlpriv->psc.multi_buffered)
298 queue_delayed_work(rtlpriv->works.rtl_wq,
299 &rtlpriv->works.ps_work,
300 MSECS(5));
301 } else {
302 rtl_swlps_rf_awake(hw);
303 rtlpriv->psc.sw_ps_enabled = false;
307 if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) {
308 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
309 ("IEEE80211_CONF_CHANGE_RETRY_LIMITS %x\n",
310 hw->conf.long_frame_max_tx_count));
311 mac->retry_long = hw->conf.long_frame_max_tx_count;
312 mac->retry_short = hw->conf.long_frame_max_tx_count;
313 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
314 (u8 *) (&hw->conf.
315 long_frame_max_tx_count));
318 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
319 struct ieee80211_channel *channel = hw->conf.channel;
320 u8 wide_chan = (u8) channel->hw_value;
323 *because we should back channel to
324 *current_network.chan in in scanning,
325 *So if set_chan == current_network.chan
326 *we should set it.
327 *because mac80211 tell us wrong bw40
328 *info for cisco1253 bw20, so we modify
329 *it here based on UPPER & LOWER
331 switch (hw->conf.channel_type) {
332 case NL80211_CHAN_HT20:
333 case NL80211_CHAN_NO_HT:
334 /* SC */
335 mac->cur_40_prime_sc =
336 PRIME_CHNL_OFFSET_DONT_CARE;
337 rtlphy->current_chan_bw = HT_CHANNEL_WIDTH_20;
338 mac->bw_40 = false;
339 break;
340 case NL80211_CHAN_HT40MINUS:
341 /* SC */
342 mac->cur_40_prime_sc = PRIME_CHNL_OFFSET_UPPER;
343 rtlphy->current_chan_bw =
344 HT_CHANNEL_WIDTH_20_40;
345 mac->bw_40 = true;
347 /*wide channel */
348 wide_chan -= 2;
350 break;
351 case NL80211_CHAN_HT40PLUS:
352 /* SC */
353 mac->cur_40_prime_sc = PRIME_CHNL_OFFSET_LOWER;
354 rtlphy->current_chan_bw =
355 HT_CHANNEL_WIDTH_20_40;
356 mac->bw_40 = true;
358 /*wide channel */
359 wide_chan += 2;
361 break;
362 default:
363 mac->bw_40 = false;
364 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
365 ("switch case not processed\n"));
366 break;
369 if (wide_chan <= 0)
370 wide_chan = 1;
372 /* In scanning, before we go offchannel we may send a ps=1 null
373 * to AP, and then we may send a ps = 0 null to AP quickly, but
374 * first null may have caused AP to put lots of packet to hw tx
375 * buffer. These packets must be tx'd before we go off channel
376 * so we must delay more time to let AP flush these packets
377 * before going offchannel, or dis-association or delete BA will
378 * happen by AP
380 if (rtlpriv->mac80211.offchan_delay) {
381 rtlpriv->mac80211.offchan_delay = false;
382 mdelay(50);
384 rtlphy->current_channel = wide_chan;
386 rtlpriv->cfg->ops->switch_channel(hw);
387 rtlpriv->cfg->ops->set_channel_access(hw);
388 rtlpriv->cfg->ops->set_bw_mode(hw,
389 hw->conf.channel_type);
392 mutex_unlock(&rtlpriv->locks.conf_mutex);
394 return 0;
397 static void rtl_op_configure_filter(struct ieee80211_hw *hw,
398 unsigned int changed_flags,
399 unsigned int *new_flags, u64 multicast)
401 struct rtl_priv *rtlpriv = rtl_priv(hw);
402 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
404 *new_flags &= RTL_SUPPORTED_FILTERS;
405 if (!changed_flags)
406 return;
408 /*TODO: we disable broadcase now, so enable here */
409 if (changed_flags & FIF_ALLMULTI) {
410 if (*new_flags & FIF_ALLMULTI) {
411 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AM] |
412 rtlpriv->cfg->maps[MAC_RCR_AB];
413 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
414 ("Enable receive multicast frame.\n"));
415 } else {
416 mac->rx_conf &= ~(rtlpriv->cfg->maps[MAC_RCR_AM] |
417 rtlpriv->cfg->maps[MAC_RCR_AB]);
418 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
419 ("Disable receive multicast frame.\n"));
423 if (changed_flags & FIF_FCSFAIL) {
424 if (*new_flags & FIF_FCSFAIL) {
425 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACRC32];
426 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
427 ("Enable receive FCS error frame.\n"));
428 } else {
429 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACRC32];
430 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
431 ("Disable receive FCS error frame.\n"));
435 /* if ssid not set to hw don't check bssid
436 * here just used for linked scanning, & linked
437 * and nolink check bssid is set in set network_type */
438 if ((changed_flags & FIF_BCN_PRBRESP_PROMISC) &&
439 (mac->link_state >= MAC80211_LINKED)) {
440 if (mac->opmode != NL80211_IFTYPE_AP) {
441 if (*new_flags & FIF_BCN_PRBRESP_PROMISC) {
442 rtlpriv->cfg->ops->set_chk_bssid(hw, false);
443 } else {
444 rtlpriv->cfg->ops->set_chk_bssid(hw, true);
449 if (changed_flags & FIF_CONTROL) {
450 if (*new_flags & FIF_CONTROL) {
451 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACF];
453 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
454 ("Enable receive control frame.\n"));
455 } else {
456 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACF];
457 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
458 ("Disable receive control frame.\n"));
462 if (changed_flags & FIF_OTHER_BSS) {
463 if (*new_flags & FIF_OTHER_BSS) {
464 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AAP];
465 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
466 ("Enable receive other BSS's frame.\n"));
467 } else {
468 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_AAP];
469 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
470 ("Disable receive other BSS's frame.\n"));
474 static int rtl_op_sta_add(struct ieee80211_hw *hw,
475 struct ieee80211_vif *vif,
476 struct ieee80211_sta *sta)
478 struct rtl_priv *rtlpriv = rtl_priv(hw);
479 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
480 struct rtl_sta_info *sta_entry;
482 if (sta) {
483 sta_entry = (struct rtl_sta_info *) sta->drv_priv;
484 if (rtlhal->current_bandtype == BAND_ON_2_4G) {
485 sta_entry->wireless_mode = WIRELESS_MODE_G;
486 if (sta->supp_rates[0] <= 0xf)
487 sta_entry->wireless_mode = WIRELESS_MODE_B;
488 if (sta->ht_cap.ht_supported)
489 sta_entry->wireless_mode = WIRELESS_MODE_N_24G;
490 } else if (rtlhal->current_bandtype == BAND_ON_5G) {
491 sta_entry->wireless_mode = WIRELESS_MODE_A;
492 if (sta->ht_cap.ht_supported)
493 sta_entry->wireless_mode = WIRELESS_MODE_N_24G;
496 /* I found some times mac80211 give wrong supp_rates for adhoc*/
497 if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_ADHOC)
498 sta_entry->wireless_mode = WIRELESS_MODE_G;
500 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
501 ("Add sta addr is %pM\n", sta->addr));
502 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0);
504 return 0;
506 static int rtl_op_sta_remove(struct ieee80211_hw *hw,
507 struct ieee80211_vif *vif,
508 struct ieee80211_sta *sta)
510 struct rtl_priv *rtlpriv = rtl_priv(hw);
511 struct rtl_sta_info *sta_entry;
512 if (sta) {
513 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
514 ("Remove sta addr is %pM\n", sta->addr));
515 sta_entry = (struct rtl_sta_info *) sta->drv_priv;
516 sta_entry->wireless_mode = 0;
517 sta_entry->ratr_index = 0;
519 return 0;
521 static int _rtl_get_hal_qnum(u16 queue)
523 int qnum;
525 switch (queue) {
526 case 0:
527 qnum = AC3_VO;
528 break;
529 case 1:
530 qnum = AC2_VI;
531 break;
532 case 2:
533 qnum = AC0_BE;
534 break;
535 case 3:
536 qnum = AC1_BK;
537 break;
538 default:
539 qnum = AC0_BE;
540 break;
542 return qnum;
546 *for mac80211 VO=0, VI=1, BE=2, BK=3
547 *for rtl819x BE=0, BK=1, VI=2, VO=3
549 static int rtl_op_conf_tx(struct ieee80211_hw *hw,
550 struct ieee80211_vif *vif, u16 queue,
551 const struct ieee80211_tx_queue_params *param)
553 struct rtl_priv *rtlpriv = rtl_priv(hw);
554 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
555 int aci;
557 if (queue >= AC_MAX) {
558 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
559 ("queue number %d is incorrect!\n", queue));
560 return -EINVAL;
563 aci = _rtl_get_hal_qnum(queue);
564 mac->ac[aci].aifs = param->aifs;
565 mac->ac[aci].cw_min = cpu_to_le16(param->cw_min);
566 mac->ac[aci].cw_max = cpu_to_le16(param->cw_max);
567 mac->ac[aci].tx_op = cpu_to_le16(param->txop);
568 memcpy(&mac->edca_param[aci], param, sizeof(*param));
569 rtlpriv->cfg->ops->set_qos(hw, aci);
570 return 0;
573 static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
574 struct ieee80211_vif *vif,
575 struct ieee80211_bss_conf *bss_conf, u32 changed)
577 struct rtl_priv *rtlpriv = rtl_priv(hw);
578 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
579 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
580 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
581 struct ieee80211_sta *sta = NULL;
583 mutex_lock(&rtlpriv->locks.conf_mutex);
584 if ((vif->type == NL80211_IFTYPE_ADHOC) ||
585 (vif->type == NL80211_IFTYPE_AP) ||
586 (vif->type == NL80211_IFTYPE_MESH_POINT)) {
587 if ((changed & BSS_CHANGED_BEACON) ||
588 (changed & BSS_CHANGED_BEACON_ENABLED &&
589 bss_conf->enable_beacon)) {
590 if (mac->beacon_enabled == 0) {
591 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
592 ("BSS_CHANGED_BEACON_ENABLED\n"));
594 /*start hw beacon interrupt. */
595 /*rtlpriv->cfg->ops->set_bcn_reg(hw); */
596 mac->beacon_enabled = 1;
597 rtlpriv->cfg->ops->update_interrupt_mask(hw,
598 rtlpriv->cfg->maps
599 [RTL_IBSS_INT_MASKS],
602 if (rtlpriv->cfg->ops->linked_set_reg)
603 rtlpriv->cfg->ops->linked_set_reg(hw);
606 if ((changed & BSS_CHANGED_BEACON_ENABLED &&
607 !bss_conf->enable_beacon)) {
608 if (mac->beacon_enabled == 1) {
609 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
610 ("ADHOC DISABLE BEACON\n"));
612 mac->beacon_enabled = 0;
613 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
614 rtlpriv->cfg->maps
615 [RTL_IBSS_INT_MASKS]);
618 if (changed & BSS_CHANGED_BEACON_INT) {
619 RT_TRACE(rtlpriv, COMP_BEACON, DBG_TRACE,
620 ("BSS_CHANGED_BEACON_INT\n"));
621 mac->beacon_interval = bss_conf->beacon_int;
622 rtlpriv->cfg->ops->set_bcn_intv(hw);
626 /*TODO: reference to enum ieee80211_bss_change */
627 if (changed & BSS_CHANGED_ASSOC) {
628 if (bss_conf->assoc) {
629 /* we should reset all sec info & cam
630 * before set cam after linked, we should not
631 * reset in disassoc, that will cause tkip->wep
632 * fail because some flag will be wrong */
633 /* reset sec info */
634 rtl_cam_reset_sec_info(hw);
635 /* reset cam to fix wep fail issue
636 * when change from wpa to wep */
637 rtl_cam_reset_all_entry(hw);
639 mac->link_state = MAC80211_LINKED;
640 mac->cnt_after_linked = 0;
641 mac->assoc_id = bss_conf->aid;
642 memcpy(mac->bssid, bss_conf->bssid, 6);
644 if (rtlpriv->cfg->ops->linked_set_reg)
645 rtlpriv->cfg->ops->linked_set_reg(hw);
646 if (mac->opmode == NL80211_IFTYPE_STATION && sta)
647 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0);
648 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
649 ("BSS_CHANGED_ASSOC\n"));
650 } else {
651 if (mac->link_state == MAC80211_LINKED)
652 rtl_lps_leave(hw);
654 mac->link_state = MAC80211_NOLINK;
655 memset(mac->bssid, 0, 6);
657 /* reset sec info */
658 rtl_cam_reset_sec_info(hw);
660 rtl_cam_reset_all_entry(hw);
661 mac->vendor = PEER_UNKNOWN;
663 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
664 ("BSS_CHANGED_UN_ASSOC\n"));
668 if (changed & BSS_CHANGED_ERP_CTS_PROT) {
669 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
670 ("BSS_CHANGED_ERP_CTS_PROT\n"));
671 mac->use_cts_protect = bss_conf->use_cts_prot;
674 if (changed & BSS_CHANGED_ERP_PREAMBLE) {
675 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
676 ("BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n",
677 bss_conf->use_short_preamble));
679 mac->short_preamble = bss_conf->use_short_preamble;
680 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACK_PREAMBLE,
681 (u8 *) (&mac->short_preamble));
684 if (changed & BSS_CHANGED_ERP_SLOT) {
685 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
686 ("BSS_CHANGED_ERP_SLOT\n"));
688 if (bss_conf->use_short_slot)
689 mac->slot_time = RTL_SLOT_TIME_9;
690 else
691 mac->slot_time = RTL_SLOT_TIME_20;
693 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME,
694 (u8 *) (&mac->slot_time));
697 if (changed & BSS_CHANGED_HT) {
698 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
699 ("BSS_CHANGED_HT\n"));
700 rcu_read_lock();
701 sta = get_sta(hw, vif, bss_conf->bssid);
702 if (sta) {
703 if (sta->ht_cap.ampdu_density >
704 mac->current_ampdu_density)
705 mac->current_ampdu_density =
706 sta->ht_cap.ampdu_density;
707 if (sta->ht_cap.ampdu_factor <
708 mac->current_ampdu_factor)
709 mac->current_ampdu_factor =
710 sta->ht_cap.ampdu_factor;
712 rcu_read_unlock();
714 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SHORTGI_DENSITY,
715 (u8 *) (&mac->max_mss_density));
716 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_FACTOR,
717 &mac->current_ampdu_factor);
718 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_MIN_SPACE,
719 &mac->current_ampdu_density);
722 if (changed & BSS_CHANGED_BSSID) {
723 u32 basic_rates;
725 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BSSID,
726 (u8 *) bss_conf->bssid);
728 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
729 ("%pM\n", bss_conf->bssid));
731 mac->vendor = PEER_UNKNOWN;
732 memcpy(mac->bssid, bss_conf->bssid, 6);
733 rtlpriv->cfg->ops->set_network_type(hw, vif->type);
735 rcu_read_lock();
736 sta = get_sta(hw, vif, bss_conf->bssid);
737 if (!sta) {
738 rcu_read_unlock();
739 goto out;
742 if (rtlhal->current_bandtype == BAND_ON_5G) {
743 mac->mode = WIRELESS_MODE_A;
744 } else {
745 if (sta->supp_rates[0] <= 0xf)
746 mac->mode = WIRELESS_MODE_B;
747 else
748 mac->mode = WIRELESS_MODE_G;
751 if (sta->ht_cap.ht_supported) {
752 if (rtlhal->current_bandtype == BAND_ON_2_4G)
753 mac->mode = WIRELESS_MODE_N_24G;
754 else
755 mac->mode = WIRELESS_MODE_N_5G;
758 /* just station need it, because ibss & ap mode will
759 * set in sta_add, and will be NULL here */
760 if (mac->opmode == NL80211_IFTYPE_STATION) {
761 struct rtl_sta_info *sta_entry;
762 sta_entry = (struct rtl_sta_info *) sta->drv_priv;
763 sta_entry->wireless_mode = mac->mode;
766 if (sta->ht_cap.ht_supported) {
767 mac->ht_enable = true;
770 * for cisco 1252 bw20 it's wrong
771 * if (ht_cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
772 * mac->bw_40 = true;
774 * */
777 if (changed & BSS_CHANGED_BASIC_RATES) {
778 /* for 5G must << RATE_6M_INDEX=4,
779 * because 5G have no cck rate*/
780 if (rtlhal->current_bandtype == BAND_ON_5G)
781 basic_rates = sta->supp_rates[1] << 4;
782 else
783 basic_rates = sta->supp_rates[0];
785 mac->basic_rates = basic_rates;
786 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE,
787 (u8 *) (&basic_rates));
789 rcu_read_unlock();
793 * For FW LPS:
794 * To tell firmware we have connected
795 * to an AP. For 92SE/CE power save v2.
797 if (changed & BSS_CHANGED_ASSOC) {
798 if (bss_conf->assoc) {
799 if (ppsc->fwctrl_lps) {
800 u8 mstatus = RT_MEDIA_CONNECT;
801 rtlpriv->cfg->ops->set_hw_reg(hw,
802 HW_VAR_H2C_FW_JOINBSSRPT,
803 (u8 *) (&mstatus));
804 ppsc->report_linked = true;
806 } else {
807 if (ppsc->fwctrl_lps) {
808 u8 mstatus = RT_MEDIA_DISCONNECT;
809 rtlpriv->cfg->ops->set_hw_reg(hw,
810 HW_VAR_H2C_FW_JOINBSSRPT,
811 (u8 *)(&mstatus));
812 ppsc->report_linked = false;
817 out:
818 mutex_unlock(&rtlpriv->locks.conf_mutex);
821 static u64 rtl_op_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
823 struct rtl_priv *rtlpriv = rtl_priv(hw);
824 u64 tsf;
826 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *) (&tsf));
827 return tsf;
830 static void rtl_op_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
831 u64 tsf)
833 struct rtl_priv *rtlpriv = rtl_priv(hw);
834 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
835 u8 bibss = (mac->opmode == NL80211_IFTYPE_ADHOC) ? 1 : 0;
837 mac->tsf = tsf;
838 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *) (&bibss));
841 static void rtl_op_reset_tsf(struct ieee80211_hw *hw,
842 struct ieee80211_vif *vif)
844 struct rtl_priv *rtlpriv = rtl_priv(hw);
845 u8 tmp = 0;
847 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_DUAL_TSF_RST, (u8 *) (&tmp));
850 static void rtl_op_sta_notify(struct ieee80211_hw *hw,
851 struct ieee80211_vif *vif,
852 enum sta_notify_cmd cmd,
853 struct ieee80211_sta *sta)
855 switch (cmd) {
856 case STA_NOTIFY_SLEEP:
857 break;
858 case STA_NOTIFY_AWAKE:
859 break;
860 default:
861 break;
865 static int rtl_op_ampdu_action(struct ieee80211_hw *hw,
866 struct ieee80211_vif *vif,
867 enum ieee80211_ampdu_mlme_action action,
868 struct ieee80211_sta *sta, u16 tid, u16 *ssn,
869 u8 buf_size)
871 struct rtl_priv *rtlpriv = rtl_priv(hw);
873 switch (action) {
874 case IEEE80211_AMPDU_TX_START:
875 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
876 ("IEEE80211_AMPDU_TX_START: TID:%d\n", tid));
877 return rtl_tx_agg_start(hw, sta, tid, ssn);
878 break;
879 case IEEE80211_AMPDU_TX_STOP:
880 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
881 ("IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid));
882 return rtl_tx_agg_stop(hw, sta, tid);
883 break;
884 case IEEE80211_AMPDU_TX_OPERATIONAL:
885 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
886 ("IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid));
887 rtl_tx_agg_oper(hw, sta, tid);
888 break;
889 case IEEE80211_AMPDU_RX_START:
890 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
891 ("IEEE80211_AMPDU_RX_START:TID:%d\n", tid));
892 break;
893 case IEEE80211_AMPDU_RX_STOP:
894 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
895 ("IEEE80211_AMPDU_RX_STOP:TID:%d\n", tid));
896 break;
897 default:
898 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
899 ("IEEE80211_AMPDU_ERR!!!!:\n"));
900 return -EOPNOTSUPP;
902 return 0;
905 static void rtl_op_sw_scan_start(struct ieee80211_hw *hw)
907 struct rtl_priv *rtlpriv = rtl_priv(hw);
908 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
910 mac->act_scanning = true;
912 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("\n"));
914 if (mac->link_state == MAC80211_LINKED) {
915 rtl_lps_leave(hw);
916 mac->link_state = MAC80211_LINKED_SCANNING;
917 } else {
918 rtl_ips_nic_on(hw);
921 /* Dual mac */
922 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false;
924 rtlpriv->cfg->ops->led_control(hw, LED_CTL_SITE_SURVEY);
925 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_BACKUP);
928 static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw)
930 struct rtl_priv *rtlpriv = rtl_priv(hw);
931 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
933 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("\n"));
934 mac->act_scanning = false;
935 /* Dual mac */
936 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false;
938 if (mac->link_state == MAC80211_LINKED_SCANNING) {
939 mac->link_state = MAC80211_LINKED;
940 if (mac->opmode == NL80211_IFTYPE_STATION) {
941 /* fix fwlps issue */
942 rtlpriv->cfg->ops->set_network_type(hw, mac->opmode);
946 rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_RESTORE);
949 static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
950 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
951 struct ieee80211_key_conf *key)
953 struct rtl_priv *rtlpriv = rtl_priv(hw);
954 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
955 u8 key_type = NO_ENCRYPTION;
956 u8 key_idx;
957 bool group_key = false;
958 bool wep_only = false;
959 int err = 0;
960 u8 mac_addr[ETH_ALEN];
961 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
962 u8 zero_addr[ETH_ALEN] = { 0 };
964 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) {
965 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
966 ("not open hw encryption\n"));
967 return -ENOSPC; /*User disabled HW-crypto */
969 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
970 ("%s hardware based encryption for keyidx: %d, mac: %pM\n",
971 cmd == SET_KEY ? "Using" : "Disabling", key->keyidx,
972 sta ? sta->addr : bcast_addr));
973 rtlpriv->sec.being_setkey = true;
974 rtl_ips_nic_on(hw);
975 mutex_lock(&rtlpriv->locks.conf_mutex);
976 /* <1> get encryption alg */
978 switch (key->cipher) {
979 case WLAN_CIPHER_SUITE_WEP40:
980 key_type = WEP40_ENCRYPTION;
981 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("alg:WEP40\n"));
982 break;
983 case WLAN_CIPHER_SUITE_WEP104:
984 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
985 ("alg:WEP104\n"));
986 key_type = WEP104_ENCRYPTION;
987 break;
988 case WLAN_CIPHER_SUITE_TKIP:
989 key_type = TKIP_ENCRYPTION;
990 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("alg:TKIP\n"));
991 break;
992 case WLAN_CIPHER_SUITE_CCMP:
993 key_type = AESCCMP_ENCRYPTION;
994 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("alg:CCMP\n"));
995 break;
996 default:
997 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
998 ("alg_err:%x!!!!:\n", key->cipher));
999 goto out_unlock;
1001 if (key_type == WEP40_ENCRYPTION ||
1002 key_type == WEP104_ENCRYPTION ||
1003 mac->opmode == NL80211_IFTYPE_ADHOC)
1004 rtlpriv->sec.use_defaultkey = true;
1006 /* <2> get key_idx */
1007 key_idx = (u8) (key->keyidx);
1008 if (key_idx > 3)
1009 goto out_unlock;
1010 /* <3> if pairwise key enable_hw_sec */
1011 group_key = !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE);
1013 /* wep always be group key, but there are two conditions:
1014 * 1) wep only: is just for wep enc, in this condition
1015 * rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION
1016 * will be true & enable_hw_sec will be set when wep
1017 * ke setting.
1018 * 2) wep(group) + AES(pairwise): some AP like cisco
1019 * may use it, in this condition enable_hw_sec will not
1020 * be set when wep key setting */
1021 /* we must reset sec_info after lingked before set key,
1022 * or some flag will be wrong*/
1023 if (mac->opmode == NL80211_IFTYPE_AP) {
1024 if (!group_key || key_type == WEP40_ENCRYPTION ||
1025 key_type == WEP104_ENCRYPTION) {
1026 if (group_key)
1027 wep_only = true;
1028 rtlpriv->cfg->ops->enable_hw_sec(hw);
1030 } else {
1031 if ((!group_key) || (mac->opmode == NL80211_IFTYPE_ADHOC) ||
1032 rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION) {
1033 if (rtlpriv->sec.pairwise_enc_algorithm ==
1034 NO_ENCRYPTION &&
1035 (key_type == WEP40_ENCRYPTION ||
1036 key_type == WEP104_ENCRYPTION))
1037 wep_only = true;
1038 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1039 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1040 ("set enable_hw_sec, key_type:%x(OPEN:0 WEP40:1"
1041 " TKIP:2 AES:4 WEP104:5)\n", key_type));
1042 rtlpriv->cfg->ops->enable_hw_sec(hw);
1045 /* <4> set key based on cmd */
1046 switch (cmd) {
1047 case SET_KEY:
1048 if (wep_only) {
1049 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1050 ("set WEP(group/pairwise) key\n"));
1051 /* Pairwise key with an assigned MAC address. */
1052 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1053 rtlpriv->sec.group_enc_algorithm = key_type;
1054 /*set local buf about wep key. */
1055 memcpy(rtlpriv->sec.key_buf[key_idx],
1056 key->key, key->keylen);
1057 rtlpriv->sec.key_len[key_idx] = key->keylen;
1058 memcpy(mac_addr, zero_addr, ETH_ALEN);
1059 } else if (group_key) { /* group key */
1060 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1061 ("set group key\n"));
1062 /* group key */
1063 rtlpriv->sec.group_enc_algorithm = key_type;
1064 /*set local buf about group key. */
1065 memcpy(rtlpriv->sec.key_buf[key_idx],
1066 key->key, key->keylen);
1067 rtlpriv->sec.key_len[key_idx] = key->keylen;
1068 memcpy(mac_addr, bcast_addr, ETH_ALEN);
1069 } else { /* pairwise key */
1070 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1071 ("set pairwise key\n"));
1072 if (!sta) {
1073 RT_ASSERT(false, ("pairwise key withnot"
1074 "mac_addr\n"));
1076 err = -EOPNOTSUPP;
1077 goto out_unlock;
1079 /* Pairwise key with an assigned MAC address. */
1080 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1081 /*set local buf about pairwise key. */
1082 memcpy(rtlpriv->sec.key_buf[PAIRWISE_KEYIDX],
1083 key->key, key->keylen);
1084 rtlpriv->sec.key_len[PAIRWISE_KEYIDX] = key->keylen;
1085 rtlpriv->sec.pairwise_key =
1086 rtlpriv->sec.key_buf[PAIRWISE_KEYIDX];
1087 memcpy(mac_addr, sta->addr, ETH_ALEN);
1089 rtlpriv->cfg->ops->set_key(hw, key_idx, mac_addr,
1090 group_key, key_type, wep_only,
1091 false);
1092 /* <5> tell mac80211 do something: */
1093 /*must use sw generate IV, or can not work !!!!. */
1094 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
1095 key->hw_key_idx = key_idx;
1096 if (key_type == TKIP_ENCRYPTION)
1097 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
1098 break;
1099 case DISABLE_KEY:
1100 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1101 ("disable key delete one entry\n"));
1102 /*set local buf about wep key. */
1103 if (mac->opmode == NL80211_IFTYPE_AP) {
1104 if (sta)
1105 rtl_cam_del_entry(hw, sta->addr);
1107 memset(rtlpriv->sec.key_buf[key_idx], 0, key->keylen);
1108 rtlpriv->sec.key_len[key_idx] = 0;
1109 memcpy(mac_addr, zero_addr, ETH_ALEN);
1111 *mac80211 will delete entrys one by one,
1112 *so don't use rtl_cam_reset_all_entry
1113 *or clear all entry here.
1115 rtl_cam_delete_one_entry(hw, mac_addr, key_idx);
1117 rtl_cam_reset_sec_info(hw);
1119 break;
1120 default:
1121 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1122 ("cmd_err:%x!!!!:\n", cmd));
1124 out_unlock:
1125 mutex_unlock(&rtlpriv->locks.conf_mutex);
1126 rtlpriv->sec.being_setkey = false;
1127 return err;
1130 static void rtl_op_rfkill_poll(struct ieee80211_hw *hw)
1132 struct rtl_priv *rtlpriv = rtl_priv(hw);
1134 bool radio_state;
1135 bool blocked;
1136 u8 valid = 0;
1138 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
1139 return;
1141 mutex_lock(&rtlpriv->locks.conf_mutex);
1143 /*if Radio On return true here */
1144 radio_state = rtlpriv->cfg->ops->radio_onoff_checking(hw, &valid);
1146 if (valid) {
1147 if (unlikely(radio_state != rtlpriv->rfkill.rfkill_state)) {
1148 rtlpriv->rfkill.rfkill_state = radio_state;
1150 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
1151 (KERN_INFO "wireless radio switch turned %s\n",
1152 radio_state ? "on" : "off"));
1154 blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1;
1155 wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
1159 mutex_unlock(&rtlpriv->locks.conf_mutex);
1162 /* this function is called by mac80211 to flush tx buffer
1163 * before switch channle or power save, or tx buffer packet
1164 * maybe send after offchannel or rf sleep, this may cause
1165 * dis-association by AP */
1166 static void rtl_op_flush(struct ieee80211_hw *hw, bool drop)
1168 struct rtl_priv *rtlpriv = rtl_priv(hw);
1170 if (rtlpriv->intf_ops->flush)
1171 rtlpriv->intf_ops->flush(hw, drop);
1174 const struct ieee80211_ops rtl_ops = {
1175 .start = rtl_op_start,
1176 .stop = rtl_op_stop,
1177 .tx = rtl_op_tx,
1178 .add_interface = rtl_op_add_interface,
1179 .remove_interface = rtl_op_remove_interface,
1180 .config = rtl_op_config,
1181 .configure_filter = rtl_op_configure_filter,
1182 .sta_add = rtl_op_sta_add,
1183 .sta_remove = rtl_op_sta_remove,
1184 .set_key = rtl_op_set_key,
1185 .conf_tx = rtl_op_conf_tx,
1186 .bss_info_changed = rtl_op_bss_info_changed,
1187 .get_tsf = rtl_op_get_tsf,
1188 .set_tsf = rtl_op_set_tsf,
1189 .reset_tsf = rtl_op_reset_tsf,
1190 .sta_notify = rtl_op_sta_notify,
1191 .ampdu_action = rtl_op_ampdu_action,
1192 .sw_scan_start = rtl_op_sw_scan_start,
1193 .sw_scan_complete = rtl_op_sw_scan_complete,
1194 .rfkill_poll = rtl_op_rfkill_poll,
1195 .flush = rtl_op_flush,