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 void rtl_addr_delay(u32 addr
)
42 else if (addr
== 0xfd)
44 else if (addr
== 0xfc)
46 else if (addr
== 0xfb)
48 else if (addr
== 0xfa)
50 else if (addr
== 0xf9)
53 EXPORT_SYMBOL(rtl_addr_delay
);
55 void rtl_rfreg_delay(struct ieee80211_hw
*hw
, enum radio_path rfpath
, u32 addr
,
60 } else if (addr
== 0xfd) {
62 } else if (addr
== 0xfc) {
64 } else if (addr
== 0xfb) {
66 } else if (addr
== 0xfa) {
68 } else if (addr
== 0xf9) {
71 rtl_set_rfreg(hw
, rfpath
, addr
, mask
, data
);
75 EXPORT_SYMBOL(rtl_rfreg_delay
);
77 void rtl_bb_delay(struct ieee80211_hw
*hw
, u32 addr
, u32 data
)
81 } else if (addr
== 0xfd) {
83 } else if (addr
== 0xfc) {
85 } else if (addr
== 0xfb) {
87 } else if (addr
== 0xfa) {
89 } else if (addr
== 0xf9) {
92 rtl_set_bbreg(hw
, addr
, MASKDWORD
, data
);
96 EXPORT_SYMBOL(rtl_bb_delay
);
98 void rtl_fw_cb(const struct firmware
*firmware
, void *context
)
100 struct ieee80211_hw
*hw
= context
;
101 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
104 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_LOUD
,
105 "Firmware callback routine entered!\n");
106 complete(&rtlpriv
->firmware_loading_complete
);
108 if (rtlpriv
->cfg
->alt_fw_name
) {
109 err
= request_firmware(&firmware
,
110 rtlpriv
->cfg
->alt_fw_name
,
112 pr_info("Loading alternative firmware %s\n",
113 rtlpriv
->cfg
->alt_fw_name
);
117 pr_err("Firmware %s not available\n", rtlpriv
->cfg
->fw_name
);
118 rtlpriv
->max_fw_size
= 0;
122 if (firmware
->size
> rtlpriv
->max_fw_size
) {
123 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
124 "Firmware is too big!\n");
125 release_firmware(firmware
);
128 memcpy(rtlpriv
->rtlhal
.pfirmware
, firmware
->data
, firmware
->size
);
129 rtlpriv
->rtlhal
.fwsize
= firmware
->size
;
130 release_firmware(firmware
);
132 EXPORT_SYMBOL(rtl_fw_cb
);
134 /*mutex for start & stop is must here. */
135 static int rtl_op_start(struct ieee80211_hw
*hw
)
138 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
139 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
141 if (!is_hal_stop(rtlhal
))
143 if (!test_bit(RTL_STATUS_INTERFACE_START
, &rtlpriv
->status
))
145 mutex_lock(&rtlpriv
->locks
.conf_mutex
);
146 err
= rtlpriv
->intf_ops
->adapter_start(hw
);
148 rtl_watch_dog_timer_callback((unsigned long)hw
);
149 mutex_unlock(&rtlpriv
->locks
.conf_mutex
);
153 static void rtl_op_stop(struct ieee80211_hw
*hw
)
155 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
156 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
157 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
158 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
159 bool support_remote_wakeup
= false;
161 if (is_hal_stop(rtlhal
))
164 rtlpriv
->cfg
->ops
->get_hw_reg(hw
, HAL_DEF_WOWLAN
,
165 (u8
*)(&support_remote_wakeup
));
166 /* here is must, because adhoc do stop and start,
167 * but stop with RFOFF may cause something wrong,
170 if (unlikely(ppsc
->rfpwr_state
== ERFOFF
))
173 mutex_lock(&rtlpriv
->locks
.conf_mutex
);
174 /* if wowlan supported, DON'T clear connected info */
175 if (!(support_remote_wakeup
&&
176 rtlhal
->enter_pnp_sleep
)) {
177 mac
->link_state
= MAC80211_NOLINK
;
178 memset(mac
->bssid
, 0, 6);
179 mac
->vendor
= PEER_UNKNOWN
;
182 rtl_cam_reset_sec_info(hw
);
184 rtl_deinit_deferred_work(hw
);
186 rtlpriv
->intf_ops
->adapter_stop(hw
);
188 mutex_unlock(&rtlpriv
->locks
.conf_mutex
);
191 static void rtl_op_tx(struct ieee80211_hw
*hw
,
192 struct ieee80211_tx_control
*control
,
195 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
196 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
197 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
198 struct rtl_tcb_desc tcb_desc
;
199 memset(&tcb_desc
, 0, sizeof(struct rtl_tcb_desc
));
201 if (unlikely(is_hal_stop(rtlhal
) || ppsc
->rfpwr_state
!= ERFON
))
204 if (!test_bit(RTL_STATUS_INTERFACE_START
, &rtlpriv
->status
))
207 if (!rtlpriv
->intf_ops
->waitq_insert(hw
, control
->sta
, skb
))
208 rtlpriv
->intf_ops
->adapter_tx(hw
, control
->sta
, skb
, &tcb_desc
);
212 dev_kfree_skb_any(skb
);
215 static int rtl_op_add_interface(struct ieee80211_hw
*hw
,
216 struct ieee80211_vif
*vif
)
218 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
219 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
223 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
224 "vif has been set!! mac->vif = 0x%p\n", mac
->vif
);
228 vif
->driver_flags
|= IEEE80211_VIF_BEACON_FILTER
;
232 mutex_lock(&rtlpriv
->locks
.conf_mutex
);
233 switch (ieee80211_vif_type_p2p(vif
)) {
234 case NL80211_IFTYPE_P2P_CLIENT
:
235 mac
->p2p
= P2P_ROLE_CLIENT
;
237 case NL80211_IFTYPE_STATION
:
238 if (mac
->beacon_enabled
== 1) {
239 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
240 "NL80211_IFTYPE_STATION\n");
241 mac
->beacon_enabled
= 0;
242 rtlpriv
->cfg
->ops
->update_interrupt_mask(hw
, 0,
243 rtlpriv
->cfg
->maps
[RTL_IBSS_INT_MASKS
]);
246 case NL80211_IFTYPE_ADHOC
:
247 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
248 "NL80211_IFTYPE_ADHOC\n");
250 mac
->link_state
= MAC80211_LINKED
;
251 rtlpriv
->cfg
->ops
->set_bcn_reg(hw
);
252 if (rtlpriv
->rtlhal
.current_bandtype
== BAND_ON_2_4G
)
253 mac
->basic_rates
= 0xfff;
255 mac
->basic_rates
= 0xff0;
256 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_BASIC_RATE
,
257 (u8
*)(&mac
->basic_rates
));
260 case NL80211_IFTYPE_P2P_GO
:
261 mac
->p2p
= P2P_ROLE_GO
;
263 case NL80211_IFTYPE_AP
:
264 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
265 "NL80211_IFTYPE_AP\n");
267 mac
->link_state
= MAC80211_LINKED
;
268 rtlpriv
->cfg
->ops
->set_bcn_reg(hw
);
269 if (rtlpriv
->rtlhal
.current_bandtype
== BAND_ON_2_4G
)
270 mac
->basic_rates
= 0xfff;
272 mac
->basic_rates
= 0xff0;
273 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_BASIC_RATE
,
274 (u8
*)(&mac
->basic_rates
));
276 case NL80211_IFTYPE_MESH_POINT
:
277 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
278 "NL80211_IFTYPE_MESH_POINT\n");
280 mac
->link_state
= MAC80211_LINKED
;
281 rtlpriv
->cfg
->ops
->set_bcn_reg(hw
);
282 if (rtlpriv
->rtlhal
.current_bandtype
== BAND_ON_2_4G
)
283 mac
->basic_rates
= 0xfff;
285 mac
->basic_rates
= 0xff0;
286 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_BASIC_RATE
,
287 (u8
*)(&mac
->basic_rates
));
290 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
291 "operation mode %d is not support!\n", vif
->type
);
297 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
298 "p2p role %x\n", vif
->type
);
299 mac
->basic_rates
= 0xff0;/*disable cck rate for p2p*/
300 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_BASIC_RATE
,
301 (u8
*)(&mac
->basic_rates
));
304 mac
->opmode
= vif
->type
;
305 rtlpriv
->cfg
->ops
->set_network_type(hw
, vif
->type
);
306 memcpy(mac
->mac_addr
, vif
->addr
, ETH_ALEN
);
307 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_ETHER_ADDR
, mac
->mac_addr
);
310 mutex_unlock(&rtlpriv
->locks
.conf_mutex
);
314 static void rtl_op_remove_interface(struct ieee80211_hw
*hw
,
315 struct ieee80211_vif
*vif
)
317 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
318 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
320 mutex_lock(&rtlpriv
->locks
.conf_mutex
);
322 /* Free beacon resources */
323 if ((vif
->type
== NL80211_IFTYPE_AP
) ||
324 (vif
->type
== NL80211_IFTYPE_ADHOC
) ||
325 (vif
->type
== NL80211_IFTYPE_MESH_POINT
)) {
326 if (mac
->beacon_enabled
== 1) {
327 mac
->beacon_enabled
= 0;
328 rtlpriv
->cfg
->ops
->update_interrupt_mask(hw
, 0,
329 rtlpriv
->cfg
->maps
[RTL_IBSS_INT_MASKS
]);
334 *Note: We assume NL80211_IFTYPE_UNSPECIFIED as
335 *NO LINK for our hardware.
339 mac
->link_state
= MAC80211_NOLINK
;
340 memset(mac
->bssid
, 0, ETH_ALEN
);
341 mac
->vendor
= PEER_UNKNOWN
;
342 mac
->opmode
= NL80211_IFTYPE_UNSPECIFIED
;
343 rtlpriv
->cfg
->ops
->set_network_type(hw
, mac
->opmode
);
345 mutex_unlock(&rtlpriv
->locks
.conf_mutex
);
347 static int rtl_op_change_interface(struct ieee80211_hw
*hw
,
348 struct ieee80211_vif
*vif
,
349 enum nl80211_iftype new_type
, bool p2p
)
351 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
353 rtl_op_remove_interface(hw
, vif
);
355 vif
->type
= new_type
;
357 ret
= rtl_op_add_interface(hw
, vif
);
358 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
364 static u16
crc16_ccitt(u8 data
, u16 crc
)
366 u8 shift_in
, data_bit
, crc_bit11
, crc_bit4
, crc_bit15
;
370 for (i
= 0; i
< 8; i
++) {
371 crc_bit15
= ((crc
& BIT(15)) ? 1 : 0);
372 data_bit
= (data
& (BIT(0) << i
) ? 1 : 0);
373 shift_in
= crc_bit15
^ data_bit
;
381 crc_bit11
= ((crc
& BIT(11)) ? 1 : 0) ^ shift_in
;
383 result
&= (~BIT(12));
387 crc_bit4
= ((crc
& BIT(4)) ? 1 : 0) ^ shift_in
;
399 static u16
_calculate_wol_pattern_crc(u8
*pattern
, u16 len
)
404 for (i
= 0; i
< len
; i
++)
405 crc
= crc16_ccitt(pattern
[i
], crc
);
412 static void _rtl_add_wowlan_patterns(struct ieee80211_hw
*hw
,
413 struct cfg80211_wowlan
*wow
)
415 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
416 struct rtl_mac
*mac
= &rtlpriv
->mac80211
;
417 struct cfg80211_pkt_pattern
*patterns
= wow
->patterns
;
418 struct rtl_wow_pattern rtl_pattern
;
419 const u8
*pattern_os
, *mask_os
;
420 u8 mask
[MAX_WOL_BIT_MASK_SIZE
] = {0};
421 u8 content
[MAX_WOL_PATTERN_SIZE
] = {0};
422 u8 broadcast_addr
[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
423 u8 multicast_addr1
[2] = {0x33, 0x33};
424 u8 multicast_addr2
[3] = {0x01, 0x00, 0x5e};
428 for (i
= 0; i
< wow
->n_patterns
; i
++) {
429 memset(&rtl_pattern
, 0, sizeof(struct rtl_wow_pattern
));
430 memset(mask
, 0, MAX_WOL_BIT_MASK_SIZE
);
431 if (patterns
[i
].pattern_len
> MAX_WOL_PATTERN_SIZE
) {
432 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_WARNING
,
433 "Pattern[%d] is too long\n", i
);
436 pattern_os
= patterns
[i
].pattern
;
437 mask_len
= DIV_ROUND_UP(patterns
[i
].pattern_len
, 8);
438 mask_os
= patterns
[i
].mask
;
439 RT_PRINT_DATA(rtlpriv
, COMP_POWER
, DBG_TRACE
,
440 "pattern content\n", pattern_os
,
441 patterns
[i
].pattern_len
);
442 RT_PRINT_DATA(rtlpriv
, COMP_POWER
, DBG_TRACE
,
443 "mask content\n", mask_os
, mask_len
);
444 /* 1. unicast? multicast? or broadcast? */
445 if (memcmp(pattern_os
, broadcast_addr
, 6) == 0)
446 rtl_pattern
.type
= BROADCAST_PATTERN
;
447 else if (memcmp(pattern_os
, multicast_addr1
, 2) == 0 ||
448 memcmp(pattern_os
, multicast_addr2
, 3) == 0)
449 rtl_pattern
.type
= MULTICAST_PATTERN
;
450 else if (memcmp(pattern_os
, mac
->mac_addr
, 6) == 0)
451 rtl_pattern
.type
= UNICAST_PATTERN
;
453 rtl_pattern
.type
= UNKNOWN_TYPE
;
455 /* 2. translate mask_from_os to mask_for_hw */
457 /******************************************************************************
458 * pattern from OS uses 'ethenet frame', like this:
460 | 6 | 6 | 2 | 20 | Variable | 4 |
461 |--------+--------+------+-----------+------------+-----|
462 | 802.3 Mac Header | IP Header | TCP Packet | FCS |
465 * BUT, packet catched by our HW is in '802.11 frame', begin from LLC,
467 | 24 or 30 | 6 | 2 | 20 | Variable | 4 |
468 |-------------------+--------+------+-----------+------------+-----|
469 | 802.11 MAC Header | LLC | IP Header | TCP Packet | FCS |
472 * Therefore, we need translate mask_from_OS to mask_to_hw.
473 * We should left-shift mask by 6 bits, then set the new bit[0~5] = 0,
474 * because new mask[0~5] means 'SA', but our HW packet begins from LLC,
475 * bit[0~5] corresponds to first 6 Bytes in LLC, they just don't match.
476 ******************************************************************************/
479 for (j
= 0; j
< mask_len
- 1; j
++) {
480 mask
[j
] = mask_os
[j
] >> 6;
481 mask
[j
] |= (mask_os
[j
+ 1] & 0x3F) << 2;
483 mask
[j
] = (mask_os
[j
] >> 6) & 0x3F;
484 /* Set bit 0-5 to zero */
487 RT_PRINT_DATA(rtlpriv
, COMP_POWER
, DBG_TRACE
,
488 "mask to hw\n", mask
, mask_len
);
489 for (j
= 0; j
< (MAX_WOL_BIT_MASK_SIZE
+ 1) / 4; j
++) {
490 rtl_pattern
.mask
[j
] = mask
[j
* 4];
491 rtl_pattern
.mask
[j
] |= (mask
[j
* 4 + 1] << 8);
492 rtl_pattern
.mask
[j
] |= (mask
[j
* 4 + 2] << 16);
493 rtl_pattern
.mask
[j
] |= (mask
[j
* 4 + 3] << 24);
496 /* To get the wake up pattern from the mask.
497 * We do not count first 12 bits which means
498 * DA[6] and SA[6] in the pattern to match HW design.
501 for (j
= 12; j
< patterns
[i
].pattern_len
; j
++) {
502 if ((mask_os
[j
/ 8] >> (j
% 8)) & 0x01) {
503 content
[len
] = pattern_os
[j
];
508 RT_PRINT_DATA(rtlpriv
, COMP_POWER
, DBG_TRACE
,
509 "pattern to hw\n", content
, len
);
510 /* 3. calculate crc */
511 rtl_pattern
.crc
= _calculate_wol_pattern_crc(content
, len
);
512 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_TRACE
,
513 "CRC_Remainder = 0x%x", rtl_pattern
.crc
);
515 /* 4. write crc & mask_for_hw to hw */
516 rtlpriv
->cfg
->ops
->add_wowlan_pattern(hw
, &rtl_pattern
, i
);
518 rtl_write_byte(rtlpriv
, 0x698, wow
->n_patterns
);
521 static int rtl_op_suspend(struct ieee80211_hw
*hw
,
522 struct cfg80211_wowlan
*wow
)
524 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
525 struct rtl_hal
*rtlhal
= rtl_hal(rtlpriv
);
526 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
529 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_DMESG
, "\n");
533 /* to resolve s4 can not wake up*/
534 do_gettimeofday(&ts
);
535 rtlhal
->last_suspend_sec
= ts
.tv_sec
;
537 if ((ppsc
->wo_wlan_mode
& WAKE_ON_PATTERN_MATCH
) && wow
->n_patterns
)
538 _rtl_add_wowlan_patterns(hw
, wow
);
540 rtlhal
->driver_is_goingto_unload
= true;
541 rtlhal
->enter_pnp_sleep
= true;
545 device_set_wakeup_enable(wiphy_dev(hw
->wiphy
), true);
549 static int rtl_op_resume(struct ieee80211_hw
*hw
)
551 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
552 struct rtl_hal
*rtlhal
= rtl_hal(rtlpriv
);
553 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
556 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_DMESG
, "\n");
557 rtlhal
->driver_is_goingto_unload
= false;
558 rtlhal
->enter_pnp_sleep
= false;
559 rtlhal
->wake_from_pnp_sleep
= true;
561 /* to resovle s4 can not wake up*/
562 do_gettimeofday(&ts
);
563 if (ts
.tv_sec
- rtlhal
->last_suspend_sec
< 5)
567 device_set_wakeup_enable(wiphy_dev(hw
->wiphy
), false);
568 ieee80211_resume_disconnect(mac
->vif
);
569 rtlhal
->wake_from_pnp_sleep
= false;
574 static int rtl_op_config(struct ieee80211_hw
*hw
, u32 changed
)
576 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
577 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
578 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
579 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
580 struct ieee80211_conf
*conf
= &hw
->conf
;
585 mutex_lock(&rtlpriv
->locks
.conf_mutex
);
586 if (changed
& IEEE80211_CONF_CHANGE_LISTEN_INTERVAL
) { /* BIT(2)*/
587 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
588 "IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n");
592 if (changed
& IEEE80211_CONF_CHANGE_IDLE
) {
593 if (hw
->conf
.flags
& IEEE80211_CONF_IDLE
)
599 *although rfoff may not cause by ips, but we will
600 *check the reason in set_rf_power_state function
602 if (unlikely(ppsc
->rfpwr_state
== ERFOFF
))
607 if (changed
& IEEE80211_CONF_CHANGE_PS
) {
608 cancel_delayed_work(&rtlpriv
->works
.ps_work
);
609 cancel_delayed_work(&rtlpriv
->works
.ps_rfon_wq
);
610 if (conf
->flags
& IEEE80211_CONF_PS
) {
611 rtlpriv
->psc
.sw_ps_enabled
= true;
612 /* sleep here is must, or we may recv the beacon and
613 * cause mac80211 into wrong ps state, this will cause
614 * power save nullfunc send fail, and further cause
615 * pkt loss, So sleep must quickly but not immediatly
616 * because that will cause nullfunc send by mac80211
617 * fail, and cause pkt loss, we have tested that 5mA
618 * is worked very well */
619 if (!rtlpriv
->psc
.multi_buffered
)
620 queue_delayed_work(rtlpriv
->works
.rtl_wq
,
621 &rtlpriv
->works
.ps_work
,
624 rtl_swlps_rf_awake(hw
);
625 rtlpriv
->psc
.sw_ps_enabled
= false;
629 if (changed
& IEEE80211_CONF_CHANGE_RETRY_LIMITS
) {
630 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
631 "IEEE80211_CONF_CHANGE_RETRY_LIMITS %x\n",
632 hw
->conf
.long_frame_max_tx_count
);
633 mac
->retry_long
= hw
->conf
.long_frame_max_tx_count
;
634 mac
->retry_short
= hw
->conf
.long_frame_max_tx_count
;
635 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_RETRY_LIMIT
,
636 (u8
*)(&hw
->conf
.long_frame_max_tx_count
));
639 if (changed
& IEEE80211_CONF_CHANGE_CHANNEL
&&
640 !rtlpriv
->proximity
.proxim_on
) {
641 struct ieee80211_channel
*channel
= hw
->conf
.chandef
.chan
;
642 enum nl80211_chan_width width
= hw
->conf
.chandef
.width
;
643 enum nl80211_channel_type channel_type
= NL80211_CHAN_NO_HT
;
644 u8 wide_chan
= (u8
) channel
->hw_value
;
646 /* channel_type is for 20&40M */
647 if (width
< NL80211_CHAN_WIDTH_80
)
649 cfg80211_get_chandef_type(&hw
->conf
.chandef
);
650 if (mac
->act_scanning
)
653 if (rtlpriv
->dm
.supp_phymode_switch
&&
654 mac
->link_state
< MAC80211_LINKED
&&
655 !mac
->act_scanning
) {
656 if (rtlpriv
->cfg
->ops
->chk_switch_dmdp
)
657 rtlpriv
->cfg
->ops
->chk_switch_dmdp(hw
);
661 *because we should back channel to
662 *current_network.chan in in scanning,
663 *So if set_chan == current_network.chan
665 *because mac80211 tell us wrong bw40
666 *info for cisco1253 bw20, so we modify
667 *it here based on UPPER & LOWER
670 if (width
>= NL80211_CHAN_WIDTH_80
) {
671 if (width
== NL80211_CHAN_WIDTH_80
) {
672 u32 center
= hw
->conf
.chandef
.center_freq1
;
674 (u32
)hw
->conf
.chandef
.chan
->center_freq
;
676 rtlphy
->current_chan_bw
=
680 if (center
> primary
) {
681 mac
->cur_80_prime_sc
=
682 PRIME_CHNL_OFFSET_LOWER
;
683 if (center
- primary
== 10) {
684 mac
->cur_40_prime_sc
=
685 PRIME_CHNL_OFFSET_UPPER
;
688 } else if (center
- primary
== 30) {
689 mac
->cur_40_prime_sc
=
690 PRIME_CHNL_OFFSET_LOWER
;
695 mac
->cur_80_prime_sc
=
696 PRIME_CHNL_OFFSET_UPPER
;
697 if (primary
- center
== 10) {
698 mac
->cur_40_prime_sc
=
699 PRIME_CHNL_OFFSET_LOWER
;
702 } else if (primary
- center
== 30) {
703 mac
->cur_40_prime_sc
=
704 PRIME_CHNL_OFFSET_UPPER
;
711 switch (channel_type
) {
712 case NL80211_CHAN_HT20
:
713 case NL80211_CHAN_NO_HT
:
715 mac
->cur_40_prime_sc
=
716 PRIME_CHNL_OFFSET_DONT_CARE
;
717 rtlphy
->current_chan_bw
=
722 case NL80211_CHAN_HT40MINUS
:
724 mac
->cur_40_prime_sc
=
725 PRIME_CHNL_OFFSET_UPPER
;
726 rtlphy
->current_chan_bw
=
727 HT_CHANNEL_WIDTH_20_40
;
735 case NL80211_CHAN_HT40PLUS
:
737 mac
->cur_40_prime_sc
=
738 PRIME_CHNL_OFFSET_LOWER
;
739 rtlphy
->current_chan_bw
=
740 HT_CHANNEL_WIDTH_20_40
;
751 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
752 "switch case not processed\n");
760 /* In scanning, when before we offchannel we may send a ps=1
761 * null to AP, and then we may send a ps = 0 null to AP quickly,
762 * but first null may have caused AP to put lots of packet to
763 * hw tx buffer. These packets must be tx'd before we go off
764 * channel so we must delay more time to let AP flush these
765 * packets before going offchannel, or dis-association or
766 * delete BA will be caused by AP
768 if (rtlpriv
->mac80211
.offchan_delay
) {
769 rtlpriv
->mac80211
.offchan_delay
= false;
773 rtlphy
->current_channel
= wide_chan
;
775 rtlpriv
->cfg
->ops
->switch_channel(hw
);
776 rtlpriv
->cfg
->ops
->set_channel_access(hw
);
777 rtlpriv
->cfg
->ops
->set_bw_mode(hw
, channel_type
);
780 mutex_unlock(&rtlpriv
->locks
.conf_mutex
);
785 static void rtl_op_configure_filter(struct ieee80211_hw
*hw
,
786 unsigned int changed_flags
,
787 unsigned int *new_flags
, u64 multicast
)
789 bool update_rcr
= false;
790 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
791 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
793 *new_flags
&= RTL_SUPPORTED_FILTERS
;
794 if (0 == changed_flags
)
797 /*TODO: we disable broadcase now, so enable here */
798 if (changed_flags
& FIF_ALLMULTI
) {
799 if (*new_flags
& FIF_ALLMULTI
) {
800 mac
->rx_conf
|= rtlpriv
->cfg
->maps
[MAC_RCR_AM
] |
801 rtlpriv
->cfg
->maps
[MAC_RCR_AB
];
802 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
803 "Enable receive multicast frame\n");
805 mac
->rx_conf
&= ~(rtlpriv
->cfg
->maps
[MAC_RCR_AM
] |
806 rtlpriv
->cfg
->maps
[MAC_RCR_AB
]);
807 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
808 "Disable receive multicast frame\n");
813 if (changed_flags
& FIF_FCSFAIL
) {
814 if (*new_flags
& FIF_FCSFAIL
) {
815 mac
->rx_conf
|= rtlpriv
->cfg
->maps
[MAC_RCR_ACRC32
];
816 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
817 "Enable receive FCS error frame\n");
819 mac
->rx_conf
&= ~rtlpriv
->cfg
->maps
[MAC_RCR_ACRC32
];
820 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
821 "Disable receive FCS error frame\n");
827 /* if ssid not set to hw don't check bssid
828 * here just used for linked scanning, & linked
829 * and nolink check bssid is set in set network_type
831 if ((changed_flags
& FIF_BCN_PRBRESP_PROMISC
) &&
832 (mac
->link_state
>= MAC80211_LINKED
)) {
833 if (mac
->opmode
!= NL80211_IFTYPE_AP
&&
834 mac
->opmode
!= NL80211_IFTYPE_MESH_POINT
) {
835 if (*new_flags
& FIF_BCN_PRBRESP_PROMISC
)
836 rtlpriv
->cfg
->ops
->set_chk_bssid(hw
, false);
838 rtlpriv
->cfg
->ops
->set_chk_bssid(hw
, true);
844 if (changed_flags
& FIF_CONTROL
) {
845 if (*new_flags
& FIF_CONTROL
) {
846 mac
->rx_conf
|= rtlpriv
->cfg
->maps
[MAC_RCR_ACF
];
848 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
849 "Enable receive control frame.\n");
851 mac
->rx_conf
&= ~rtlpriv
->cfg
->maps
[MAC_RCR_ACF
];
852 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
853 "Disable receive control frame.\n");
859 if (changed_flags
& FIF_OTHER_BSS
) {
860 if (*new_flags
& FIF_OTHER_BSS
) {
861 mac
->rx_conf
|= rtlpriv
->cfg
->maps
[MAC_RCR_AAP
];
862 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
863 "Enable receive other BSS's frame.\n");
865 mac
->rx_conf
&= ~rtlpriv
->cfg
->maps
[MAC_RCR_AAP
];
866 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
867 "Disable receive other BSS's frame.\n");
874 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_RCR
,
875 (u8
*)(&mac
->rx_conf
));
877 static int rtl_op_sta_add(struct ieee80211_hw
*hw
,
878 struct ieee80211_vif
*vif
,
879 struct ieee80211_sta
*sta
)
881 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
882 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
883 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
884 struct rtl_sta_info
*sta_entry
;
887 sta_entry
= (struct rtl_sta_info
*)sta
->drv_priv
;
888 spin_lock_bh(&rtlpriv
->locks
.entry_list_lock
);
889 list_add_tail(&sta_entry
->list
, &rtlpriv
->entry_list
);
890 spin_unlock_bh(&rtlpriv
->locks
.entry_list_lock
);
891 if (rtlhal
->current_bandtype
== BAND_ON_2_4G
) {
892 sta_entry
->wireless_mode
= WIRELESS_MODE_G
;
893 if (sta
->supp_rates
[0] <= 0xf)
894 sta_entry
->wireless_mode
= WIRELESS_MODE_B
;
895 if (sta
->ht_cap
.ht_supported
)
896 sta_entry
->wireless_mode
= WIRELESS_MODE_N_24G
;
898 if (vif
->type
== NL80211_IFTYPE_ADHOC
)
899 sta_entry
->wireless_mode
= WIRELESS_MODE_G
;
900 } else if (rtlhal
->current_bandtype
== BAND_ON_5G
) {
901 sta_entry
->wireless_mode
= WIRELESS_MODE_A
;
902 if (sta
->ht_cap
.ht_supported
)
903 sta_entry
->wireless_mode
= WIRELESS_MODE_N_5G
;
904 if (sta
->vht_cap
.vht_supported
)
905 sta_entry
->wireless_mode
= WIRELESS_MODE_AC_5G
;
907 if (vif
->type
== NL80211_IFTYPE_ADHOC
)
908 sta_entry
->wireless_mode
= WIRELESS_MODE_A
;
910 /*disable cck rate for p2p*/
912 sta
->supp_rates
[0] &= 0xfffffff0;
914 memcpy(sta_entry
->mac_addr
, sta
->addr
, ETH_ALEN
);
915 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_DMESG
,
916 "Add sta addr is %pM\n", sta
->addr
);
917 rtlpriv
->cfg
->ops
->update_rate_tbl(hw
, sta
, 0);
923 static int rtl_op_sta_remove(struct ieee80211_hw
*hw
,
924 struct ieee80211_vif
*vif
,
925 struct ieee80211_sta
*sta
)
927 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
928 struct rtl_sta_info
*sta_entry
;
930 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_DMESG
,
931 "Remove sta addr is %pM\n", sta
->addr
);
932 sta_entry
= (struct rtl_sta_info
*)sta
->drv_priv
;
933 sta_entry
->wireless_mode
= 0;
934 sta_entry
->ratr_index
= 0;
935 spin_lock_bh(&rtlpriv
->locks
.entry_list_lock
);
936 list_del(&sta_entry
->list
);
937 spin_unlock_bh(&rtlpriv
->locks
.entry_list_lock
);
941 static int _rtl_get_hal_qnum(u16 queue
)
966 *for mac80211 VO = 0, VI = 1, BE = 2, BK = 3
967 *for rtl819x BE = 0, BK = 1, VI = 2, VO = 3
969 static int rtl_op_conf_tx(struct ieee80211_hw
*hw
,
970 struct ieee80211_vif
*vif
, u16 queue
,
971 const struct ieee80211_tx_queue_params
*param
)
973 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
974 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
977 if (queue
>= AC_MAX
) {
978 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
979 "queue number %d is incorrect!\n", queue
);
983 aci
= _rtl_get_hal_qnum(queue
);
984 mac
->ac
[aci
].aifs
= param
->aifs
;
985 mac
->ac
[aci
].cw_min
= cpu_to_le16(param
->cw_min
);
986 mac
->ac
[aci
].cw_max
= cpu_to_le16(param
->cw_max
);
987 mac
->ac
[aci
].tx_op
= cpu_to_le16(param
->txop
);
988 memcpy(&mac
->edca_param
[aci
], param
, sizeof(*param
));
989 rtlpriv
->cfg
->ops
->set_qos(hw
, aci
);
993 static void rtl_op_bss_info_changed(struct ieee80211_hw
*hw
,
994 struct ieee80211_vif
*vif
,
995 struct ieee80211_bss_conf
*bss_conf
,
998 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
999 struct rtl_hal
*rtlhal
= rtl_hal(rtlpriv
);
1000 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1001 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
1003 mutex_lock(&rtlpriv
->locks
.conf_mutex
);
1004 if ((vif
->type
== NL80211_IFTYPE_ADHOC
) ||
1005 (vif
->type
== NL80211_IFTYPE_AP
) ||
1006 (vif
->type
== NL80211_IFTYPE_MESH_POINT
)) {
1007 if ((changed
& BSS_CHANGED_BEACON
) ||
1008 (changed
& BSS_CHANGED_BEACON_ENABLED
&&
1009 bss_conf
->enable_beacon
)) {
1010 if (mac
->beacon_enabled
== 0) {
1011 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_DMESG
,
1012 "BSS_CHANGED_BEACON_ENABLED\n");
1014 /*start hw beacon interrupt. */
1015 /*rtlpriv->cfg->ops->set_bcn_reg(hw); */
1016 mac
->beacon_enabled
= 1;
1017 rtlpriv
->cfg
->ops
->update_interrupt_mask(hw
,
1019 [RTL_IBSS_INT_MASKS
], 0);
1021 if (rtlpriv
->cfg
->ops
->linked_set_reg
)
1022 rtlpriv
->cfg
->ops
->linked_set_reg(hw
);
1025 if ((changed
& BSS_CHANGED_BEACON_ENABLED
&&
1026 !bss_conf
->enable_beacon
)) {
1027 if (mac
->beacon_enabled
== 1) {
1028 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_DMESG
,
1029 "ADHOC DISABLE BEACON\n");
1031 mac
->beacon_enabled
= 0;
1032 rtlpriv
->cfg
->ops
->update_interrupt_mask(hw
, 0,
1034 [RTL_IBSS_INT_MASKS
]);
1037 if (changed
& BSS_CHANGED_BEACON_INT
) {
1038 RT_TRACE(rtlpriv
, COMP_BEACON
, DBG_TRACE
,
1039 "BSS_CHANGED_BEACON_INT\n");
1040 mac
->beacon_interval
= bss_conf
->beacon_int
;
1041 rtlpriv
->cfg
->ops
->set_bcn_intv(hw
);
1045 /*TODO: reference to enum ieee80211_bss_change */
1046 if (changed
& BSS_CHANGED_ASSOC
) {
1048 if (bss_conf
->assoc
) {
1049 struct ieee80211_sta
*sta
= NULL
;
1052 mstatus
= RT_MEDIA_CONNECT
;
1053 /* we should reset all sec info & cam
1054 * before set cam after linked, we should not
1055 * reset in disassoc, that will cause tkip->wep
1056 * fail because some flag will be wrong */
1057 /* reset sec info */
1058 rtl_cam_reset_sec_info(hw
);
1059 /* reset cam to fix wep fail issue
1060 * when change from wpa to wep */
1061 rtl_cam_reset_all_entry(hw
);
1063 mac
->link_state
= MAC80211_LINKED
;
1064 mac
->cnt_after_linked
= 0;
1065 mac
->assoc_id
= bss_conf
->aid
;
1066 memcpy(mac
->bssid
, bss_conf
->bssid
, ETH_ALEN
);
1068 if (rtlpriv
->cfg
->ops
->linked_set_reg
)
1069 rtlpriv
->cfg
->ops
->linked_set_reg(hw
);
1072 sta
= ieee80211_find_sta(vif
, (u8
*)bss_conf
->bssid
);
1077 RT_TRACE(rtlpriv
, COMP_EASY_CONCURRENT
, DBG_LOUD
,
1078 "send PS STATIC frame\n");
1079 if (rtlpriv
->dm
.supp_phymode_switch
) {
1080 if (sta
->ht_cap
.ht_supported
)
1081 rtl_send_smps_action(hw
, sta
,
1082 IEEE80211_SMPS_STATIC
);
1085 if (rtlhal
->current_bandtype
== BAND_ON_5G
) {
1086 mac
->mode
= WIRELESS_MODE_A
;
1088 if (sta
->supp_rates
[0] <= 0xf)
1089 mac
->mode
= WIRELESS_MODE_B
;
1091 mac
->mode
= WIRELESS_MODE_G
;
1094 if (sta
->ht_cap
.ht_supported
) {
1095 if (rtlhal
->current_bandtype
== BAND_ON_2_4G
)
1096 mac
->mode
= WIRELESS_MODE_N_24G
;
1098 mac
->mode
= WIRELESS_MODE_N_5G
;
1101 if (sta
->vht_cap
.vht_supported
) {
1102 if (rtlhal
->current_bandtype
== BAND_ON_5G
)
1103 mac
->mode
= WIRELESS_MODE_AC_5G
;
1105 mac
->mode
= WIRELESS_MODE_AC_24G
;
1108 if (vif
->type
== NL80211_IFTYPE_STATION
&& sta
)
1109 rtlpriv
->cfg
->ops
->update_rate_tbl(hw
, sta
, 0);
1112 /* to avoid AP Disassociation caused by inactivity */
1113 rtlpriv
->cfg
->ops
->set_hw_reg(hw
,
1115 (u8
*)(&keep_alive
));
1117 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_DMESG
,
1118 "BSS_CHANGED_ASSOC\n");
1120 mstatus
= RT_MEDIA_DISCONNECT
;
1122 if (mac
->link_state
== MAC80211_LINKED
) {
1123 rtlpriv
->enter_ps
= false;
1124 schedule_work(&rtlpriv
->works
.lps_change_work
);
1126 if (ppsc
->p2p_ps_info
.p2p_ps_mode
> P2P_PS_NONE
)
1127 rtl_p2p_ps_cmd(hw
, P2P_PS_DISABLE
);
1128 mac
->link_state
= MAC80211_NOLINK
;
1129 memset(mac
->bssid
, 0, ETH_ALEN
);
1130 mac
->vendor
= PEER_UNKNOWN
;
1133 if (rtlpriv
->dm
.supp_phymode_switch
) {
1134 if (rtlpriv
->cfg
->ops
->chk_switch_dmdp
)
1135 rtlpriv
->cfg
->ops
->chk_switch_dmdp(hw
);
1137 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_DMESG
,
1138 "BSS_CHANGED_UN_ASSOC\n");
1140 rtlpriv
->cfg
->ops
->set_network_type(hw
, vif
->type
);
1142 * To tell firmware we have connected or disconnected
1144 rtlpriv
->cfg
->ops
->set_hw_reg(hw
,
1145 HW_VAR_H2C_FW_JOINBSSRPT
,
1147 ppsc
->report_linked
= (mstatus
== RT_MEDIA_CONNECT
) ?
1150 if (rtlpriv
->cfg
->ops
->get_btc_status())
1151 rtlpriv
->btcoexist
.btc_ops
->btc_mediastatus_notify(
1155 if (changed
& BSS_CHANGED_ERP_CTS_PROT
) {
1156 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_TRACE
,
1157 "BSS_CHANGED_ERP_CTS_PROT\n");
1158 mac
->use_cts_protect
= bss_conf
->use_cts_prot
;
1161 if (changed
& BSS_CHANGED_ERP_PREAMBLE
) {
1162 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
,
1163 "BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n",
1164 bss_conf
->use_short_preamble
);
1166 mac
->short_preamble
= bss_conf
->use_short_preamble
;
1167 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_ACK_PREAMBLE
,
1168 (u8
*)(&mac
->short_preamble
));
1171 if (changed
& BSS_CHANGED_ERP_SLOT
) {
1172 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_TRACE
,
1173 "BSS_CHANGED_ERP_SLOT\n");
1175 if (bss_conf
->use_short_slot
)
1176 mac
->slot_time
= RTL_SLOT_TIME_9
;
1178 mac
->slot_time
= RTL_SLOT_TIME_20
;
1180 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_SLOT_TIME
,
1181 (u8
*)(&mac
->slot_time
));
1184 if (changed
& BSS_CHANGED_HT
) {
1185 struct ieee80211_sta
*sta
= NULL
;
1187 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_TRACE
,
1188 "BSS_CHANGED_HT\n");
1191 sta
= ieee80211_find_sta(vif
, (u8
*)bss_conf
->bssid
);
1193 if (sta
->ht_cap
.ampdu_density
>
1194 mac
->current_ampdu_density
)
1195 mac
->current_ampdu_density
=
1196 sta
->ht_cap
.ampdu_density
;
1197 if (sta
->ht_cap
.ampdu_factor
<
1198 mac
->current_ampdu_factor
)
1199 mac
->current_ampdu_factor
=
1200 sta
->ht_cap
.ampdu_factor
;
1204 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_SHORTGI_DENSITY
,
1205 (u8
*)(&mac
->max_mss_density
));
1206 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_AMPDU_FACTOR
,
1207 &mac
->current_ampdu_factor
);
1208 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_AMPDU_MIN_SPACE
,
1209 &mac
->current_ampdu_density
);
1212 if (changed
& BSS_CHANGED_BSSID
) {
1214 struct ieee80211_sta
*sta
= NULL
;
1216 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_BSSID
,
1217 (u8
*)bss_conf
->bssid
);
1219 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_DMESG
,
1220 "bssid: %pM\n", bss_conf
->bssid
);
1222 mac
->vendor
= PEER_UNKNOWN
;
1223 memcpy(mac
->bssid
, bss_conf
->bssid
, ETH_ALEN
);
1226 sta
= ieee80211_find_sta(vif
, (u8
*)bss_conf
->bssid
);
1232 if (rtlhal
->current_bandtype
== BAND_ON_5G
) {
1233 mac
->mode
= WIRELESS_MODE_A
;
1235 if (sta
->supp_rates
[0] <= 0xf)
1236 mac
->mode
= WIRELESS_MODE_B
;
1238 mac
->mode
= WIRELESS_MODE_G
;
1241 if (sta
->ht_cap
.ht_supported
) {
1242 if (rtlhal
->current_bandtype
== BAND_ON_2_4G
)
1243 mac
->mode
= WIRELESS_MODE_N_24G
;
1245 mac
->mode
= WIRELESS_MODE_N_5G
;
1248 if (sta
->vht_cap
.vht_supported
) {
1249 if (rtlhal
->current_bandtype
== BAND_ON_5G
)
1250 mac
->mode
= WIRELESS_MODE_AC_5G
;
1252 mac
->mode
= WIRELESS_MODE_AC_24G
;
1255 /* just station need it, because ibss & ap mode will
1256 * set in sta_add, and will be NULL here */
1257 if (vif
->type
== NL80211_IFTYPE_STATION
) {
1258 struct rtl_sta_info
*sta_entry
;
1259 sta_entry
= (struct rtl_sta_info
*)sta
->drv_priv
;
1260 sta_entry
->wireless_mode
= mac
->mode
;
1263 if (sta
->ht_cap
.ht_supported
) {
1264 mac
->ht_enable
= true;
1267 * for cisco 1252 bw20 it's wrong
1268 * if (ht_cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
1269 * mac->bw_40 = true;
1274 if (sta
->vht_cap
.vht_supported
)
1275 mac
->vht_enable
= true;
1277 if (changed
& BSS_CHANGED_BASIC_RATES
) {
1278 /* for 5G must << RATE_6M_INDEX = 4,
1279 * because 5G have no cck rate*/
1280 if (rtlhal
->current_bandtype
== BAND_ON_5G
)
1281 basic_rates
= sta
->supp_rates
[1] << 4;
1283 basic_rates
= sta
->supp_rates
[0];
1285 mac
->basic_rates
= basic_rates
;
1286 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_BASIC_RATE
,
1287 (u8
*)(&basic_rates
));
1292 mutex_unlock(&rtlpriv
->locks
.conf_mutex
);
1295 static u64
rtl_op_get_tsf(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
)
1297 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1300 rtlpriv
->cfg
->ops
->get_hw_reg(hw
, HW_VAR_CORRECT_TSF
, (u8
*)(&tsf
));
1304 static void rtl_op_set_tsf(struct ieee80211_hw
*hw
,
1305 struct ieee80211_vif
*vif
, u64 tsf
)
1307 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1308 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1309 u8 bibss
= (mac
->opmode
== NL80211_IFTYPE_ADHOC
) ? 1 : 0;
1312 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_CORRECT_TSF
, (u8
*)(&bibss
));
1315 static void rtl_op_reset_tsf(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
)
1317 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1320 rtlpriv
->cfg
->ops
->set_hw_reg(hw
, HW_VAR_DUAL_TSF_RST
, (u8
*)(&tmp
));
1323 static void rtl_op_sta_notify(struct ieee80211_hw
*hw
,
1324 struct ieee80211_vif
*vif
,
1325 enum sta_notify_cmd cmd
,
1326 struct ieee80211_sta
*sta
)
1329 case STA_NOTIFY_SLEEP
:
1331 case STA_NOTIFY_AWAKE
:
1338 static int rtl_op_ampdu_action(struct ieee80211_hw
*hw
,
1339 struct ieee80211_vif
*vif
,
1340 enum ieee80211_ampdu_mlme_action action
,
1341 struct ieee80211_sta
*sta
, u16 tid
, u16
*ssn
,
1344 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1347 case IEEE80211_AMPDU_TX_START
:
1348 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_TRACE
,
1349 "IEEE80211_AMPDU_TX_START: TID:%d\n", tid
);
1350 return rtl_tx_agg_start(hw
, vif
, sta
, tid
, ssn
);
1351 case IEEE80211_AMPDU_TX_STOP_CONT
:
1352 case IEEE80211_AMPDU_TX_STOP_FLUSH
:
1353 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT
:
1354 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_TRACE
,
1355 "IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid
);
1356 return rtl_tx_agg_stop(hw
, vif
, sta
, tid
);
1357 case IEEE80211_AMPDU_TX_OPERATIONAL
:
1358 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_TRACE
,
1359 "IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid
);
1360 rtl_tx_agg_oper(hw
, sta
, tid
);
1362 case IEEE80211_AMPDU_RX_START
:
1363 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_TRACE
,
1364 "IEEE80211_AMPDU_RX_START:TID:%d\n", tid
);
1365 return rtl_rx_agg_start(hw
, sta
, tid
);
1366 case IEEE80211_AMPDU_RX_STOP
:
1367 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_TRACE
,
1368 "IEEE80211_AMPDU_RX_STOP:TID:%d\n", tid
);
1369 return rtl_rx_agg_stop(hw
, sta
, tid
);
1371 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
1372 "IEEE80211_AMPDU_ERR!!!!:\n");
1378 static void rtl_op_sw_scan_start(struct ieee80211_hw
*hw
,
1379 struct ieee80211_vif
*vif
,
1382 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1383 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1385 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
, "\n");
1386 mac
->act_scanning
= true;
1387 if (rtlpriv
->link_info
.higher_busytraffic
) {
1388 mac
->skip_scan
= true;
1392 if (rtlpriv
->cfg
->ops
->get_btc_status())
1393 rtlpriv
->btcoexist
.btc_ops
->btc_scan_notify(rtlpriv
, 1);
1395 if (rtlpriv
->dm
.supp_phymode_switch
) {
1396 if (rtlpriv
->cfg
->ops
->chk_switch_dmdp
)
1397 rtlpriv
->cfg
->ops
->chk_switch_dmdp(hw
);
1400 if (mac
->link_state
== MAC80211_LINKED
) {
1401 rtlpriv
->enter_ps
= false;
1402 schedule_work(&rtlpriv
->works
.lps_change_work
);
1403 mac
->link_state
= MAC80211_LINKED_SCANNING
;
1409 rtlpriv
->rtlhal
.load_imrandiqk_setting_for2g
= false;
1411 rtlpriv
->cfg
->ops
->led_control(hw
, LED_CTL_SITE_SURVEY
);
1412 rtlpriv
->cfg
->ops
->scan_operation_backup(hw
, SCAN_OPT_BACKUP_BAND0
);
1415 static void rtl_op_sw_scan_complete(struct ieee80211_hw
*hw
,
1416 struct ieee80211_vif
*vif
)
1418 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1419 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1421 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
, "\n");
1422 mac
->act_scanning
= false;
1423 mac
->skip_scan
= false;
1424 if (rtlpriv
->link_info
.higher_busytraffic
)
1427 /* p2p will use 1/6/11 to scan */
1428 if (mac
->n_channels
== 3)
1429 mac
->p2p_in_use
= true;
1431 mac
->p2p_in_use
= false;
1432 mac
->n_channels
= 0;
1434 rtlpriv
->rtlhal
.load_imrandiqk_setting_for2g
= false;
1436 if (mac
->link_state
== MAC80211_LINKED_SCANNING
) {
1437 mac
->link_state
= MAC80211_LINKED
;
1438 if (mac
->opmode
== NL80211_IFTYPE_STATION
) {
1439 /* fix fwlps issue */
1440 rtlpriv
->cfg
->ops
->set_network_type(hw
, mac
->opmode
);
1444 rtlpriv
->cfg
->ops
->scan_operation_backup(hw
, SCAN_OPT_RESTORE
);
1445 if (rtlpriv
->cfg
->ops
->get_btc_status())
1446 rtlpriv
->btcoexist
.btc_ops
->btc_scan_notify(rtlpriv
, 0);
1449 static int rtl_op_set_key(struct ieee80211_hw
*hw
, enum set_key_cmd cmd
,
1450 struct ieee80211_vif
*vif
, struct ieee80211_sta
*sta
,
1451 struct ieee80211_key_conf
*key
)
1453 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1454 u8 key_type
= NO_ENCRYPTION
;
1456 bool group_key
= false;
1457 bool wep_only
= false;
1459 u8 mac_addr
[ETH_ALEN
];
1460 u8 bcast_addr
[ETH_ALEN
] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1462 if (rtlpriv
->cfg
->mod_params
->sw_crypto
|| rtlpriv
->sec
.use_sw_sec
) {
1463 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
1464 "not open hw encryption\n");
1465 return -ENOSPC
; /*User disabled HW-crypto */
1467 /* To support IBSS, use sw-crypto for GTK */
1468 if (((vif
->type
== NL80211_IFTYPE_ADHOC
) ||
1469 (vif
->type
== NL80211_IFTYPE_MESH_POINT
)) &&
1470 !(key
->flags
& IEEE80211_KEY_FLAG_PAIRWISE
))
1472 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
1473 "%s hardware based encryption for keyidx: %d, mac: %pM\n",
1474 cmd
== SET_KEY
? "Using" : "Disabling", key
->keyidx
,
1475 sta
? sta
->addr
: bcast_addr
);
1476 rtlpriv
->sec
.being_setkey
= true;
1478 mutex_lock(&rtlpriv
->locks
.conf_mutex
);
1479 /* <1> get encryption alg */
1481 switch (key
->cipher
) {
1482 case WLAN_CIPHER_SUITE_WEP40
:
1483 key_type
= WEP40_ENCRYPTION
;
1484 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
, "alg:WEP40\n");
1486 case WLAN_CIPHER_SUITE_WEP104
:
1487 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
, "alg:WEP104\n");
1488 key_type
= WEP104_ENCRYPTION
;
1490 case WLAN_CIPHER_SUITE_TKIP
:
1491 key_type
= TKIP_ENCRYPTION
;
1492 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
, "alg:TKIP\n");
1494 case WLAN_CIPHER_SUITE_CCMP
:
1495 key_type
= AESCCMP_ENCRYPTION
;
1496 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
, "alg:CCMP\n");
1498 case WLAN_CIPHER_SUITE_AES_CMAC
:
1499 /* HW don't support CMAC encryption,
1500 * use software CMAC encryption
1502 key_type
= AESCMAC_ENCRYPTION
;
1503 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
, "alg:CMAC\n");
1504 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
1505 "HW don't support CMAC encrypiton, use software CMAC encrypiton\n");
1509 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
1510 "alg_err:%x!!!!:\n", key
->cipher
);
1513 if (key_type
== WEP40_ENCRYPTION
||
1514 key_type
== WEP104_ENCRYPTION
||
1515 vif
->type
== NL80211_IFTYPE_ADHOC
)
1516 rtlpriv
->sec
.use_defaultkey
= true;
1518 /* <2> get key_idx */
1519 key_idx
= (u8
) (key
->keyidx
);
1522 /* <3> if pairwise key enable_hw_sec */
1523 group_key
= !(key
->flags
& IEEE80211_KEY_FLAG_PAIRWISE
);
1525 /* wep always be group key, but there are two conditions:
1526 * 1) wep only: is just for wep enc, in this condition
1527 * rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION
1528 * will be true & enable_hw_sec will be set when wep
1530 * 2) wep(group) + AES(pairwise): some AP like cisco
1531 * may use it, in this condition enable_hw_sec will not
1532 * be set when wep key setting */
1533 /* we must reset sec_info after lingked before set key,
1534 * or some flag will be wrong*/
1535 if (vif
->type
== NL80211_IFTYPE_AP
||
1536 vif
->type
== NL80211_IFTYPE_MESH_POINT
) {
1537 if (!group_key
|| key_type
== WEP40_ENCRYPTION
||
1538 key_type
== WEP104_ENCRYPTION
) {
1541 rtlpriv
->cfg
->ops
->enable_hw_sec(hw
);
1544 if ((!group_key
) || (vif
->type
== NL80211_IFTYPE_ADHOC
) ||
1545 rtlpriv
->sec
.pairwise_enc_algorithm
== NO_ENCRYPTION
) {
1546 if (rtlpriv
->sec
.pairwise_enc_algorithm
==
1548 (key_type
== WEP40_ENCRYPTION
||
1549 key_type
== WEP104_ENCRYPTION
))
1551 rtlpriv
->sec
.pairwise_enc_algorithm
= key_type
;
1552 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
1553 "set enable_hw_sec, key_type:%x(OPEN:0 WEP40:1 TKIP:2 AES:4 WEP104:5)\n",
1555 rtlpriv
->cfg
->ops
->enable_hw_sec(hw
);
1558 /* <4> set key based on cmd */
1562 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
1563 "set WEP(group/pairwise) key\n");
1564 /* Pairwise key with an assigned MAC address. */
1565 rtlpriv
->sec
.pairwise_enc_algorithm
= key_type
;
1566 rtlpriv
->sec
.group_enc_algorithm
= key_type
;
1567 /*set local buf about wep key. */
1568 memcpy(rtlpriv
->sec
.key_buf
[key_idx
],
1569 key
->key
, key
->keylen
);
1570 rtlpriv
->sec
.key_len
[key_idx
] = key
->keylen
;
1571 eth_zero_addr(mac_addr
);
1572 } else if (group_key
) { /* group key */
1573 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
1576 rtlpriv
->sec
.group_enc_algorithm
= key_type
;
1577 /*set local buf about group key. */
1578 memcpy(rtlpriv
->sec
.key_buf
[key_idx
],
1579 key
->key
, key
->keylen
);
1580 rtlpriv
->sec
.key_len
[key_idx
] = key
->keylen
;
1581 memcpy(mac_addr
, bcast_addr
, ETH_ALEN
);
1582 } else { /* pairwise key */
1583 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
1584 "set pairwise key\n");
1587 "pairwise key without mac_addr\n");
1592 /* Pairwise key with an assigned MAC address. */
1593 rtlpriv
->sec
.pairwise_enc_algorithm
= key_type
;
1594 /*set local buf about pairwise key. */
1595 memcpy(rtlpriv
->sec
.key_buf
[PAIRWISE_KEYIDX
],
1596 key
->key
, key
->keylen
);
1597 rtlpriv
->sec
.key_len
[PAIRWISE_KEYIDX
] = key
->keylen
;
1598 rtlpriv
->sec
.pairwise_key
=
1599 rtlpriv
->sec
.key_buf
[PAIRWISE_KEYIDX
];
1600 memcpy(mac_addr
, sta
->addr
, ETH_ALEN
);
1602 rtlpriv
->cfg
->ops
->set_key(hw
, key_idx
, mac_addr
,
1603 group_key
, key_type
, wep_only
,
1605 /* <5> tell mac80211 do something: */
1606 /*must use sw generate IV, or can not work !!!!. */
1607 key
->flags
|= IEEE80211_KEY_FLAG_GENERATE_IV
;
1608 key
->hw_key_idx
= key_idx
;
1609 if (key_type
== TKIP_ENCRYPTION
)
1610 key
->flags
|= IEEE80211_KEY_FLAG_GENERATE_MMIC
;
1611 /*use software CCMP encryption for management frames (MFP) */
1612 if (key_type
== AESCCMP_ENCRYPTION
)
1613 key
->flags
|= IEEE80211_KEY_FLAG_SW_MGMT_TX
;
1616 RT_TRACE(rtlpriv
, COMP_SEC
, DBG_DMESG
,
1617 "disable key delete one entry\n");
1618 /*set local buf about wep key. */
1619 if (vif
->type
== NL80211_IFTYPE_AP
||
1620 vif
->type
== NL80211_IFTYPE_MESH_POINT
) {
1622 rtl_cam_del_entry(hw
, sta
->addr
);
1624 memset(rtlpriv
->sec
.key_buf
[key_idx
], 0, key
->keylen
);
1625 rtlpriv
->sec
.key_len
[key_idx
] = 0;
1626 eth_zero_addr(mac_addr
);
1628 *mac80211 will delete entrys one by one,
1629 *so don't use rtl_cam_reset_all_entry
1630 *or clear all entry here.
1632 rtl_cam_delete_one_entry(hw
, mac_addr
, key_idx
);
1635 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
1636 "cmd_err:%x!!!!:\n", cmd
);
1639 mutex_unlock(&rtlpriv
->locks
.conf_mutex
);
1640 rtlpriv
->sec
.being_setkey
= false;
1644 static void rtl_op_rfkill_poll(struct ieee80211_hw
*hw
)
1646 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1652 if (!test_bit(RTL_STATUS_INTERFACE_START
, &rtlpriv
->status
))
1655 mutex_lock(&rtlpriv
->locks
.conf_mutex
);
1657 /*if Radio On return true here */
1658 radio_state
= rtlpriv
->cfg
->ops
->radio_onoff_checking(hw
, &valid
);
1661 if (unlikely(radio_state
!= rtlpriv
->rfkill
.rfkill_state
)) {
1662 rtlpriv
->rfkill
.rfkill_state
= radio_state
;
1664 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
1665 "wireless radio switch turned %s\n",
1666 radio_state
? "on" : "off");
1668 blocked
= (rtlpriv
->rfkill
.rfkill_state
== 1) ? 0 : 1;
1669 wiphy_rfkill_set_hw_state(hw
->wiphy
, blocked
);
1673 mutex_unlock(&rtlpriv
->locks
.conf_mutex
);
1676 /* this function is called by mac80211 to flush tx buffer
1677 * before switch channle or power save, or tx buffer packet
1678 * maybe send after offchannel or rf sleep, this may cause
1679 * dis-association by AP */
1680 static void rtl_op_flush(struct ieee80211_hw
*hw
,
1681 struct ieee80211_vif
*vif
,
1685 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1687 if (rtlpriv
->intf_ops
->flush
)
1688 rtlpriv
->intf_ops
->flush(hw
, queues
, drop
);
1692 * This routine deals with the Power Configuration CMD
1693 * parsing for RTL8723/RTL8188E Series IC.
1695 * We should follow specific format that was released from HW SD.
1697 bool rtl_hal_pwrseqcmdparsing(struct rtl_priv
*rtlpriv
, u8 cut_version
,
1698 u8 faversion
, u8 interface_type
,
1699 struct wlan_pwr_cfg pwrcfgcmd
[])
1701 struct wlan_pwr_cfg cfg_cmd
= {0};
1702 bool polling_bit
= false;
1706 u32 polling_count
= 0;
1707 u32 max_polling_cnt
= 5000;
1710 cfg_cmd
= pwrcfgcmd
[ary_idx
];
1711 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1712 "rtl_hal_pwrseqcmdparsing(): offset(%#x),cut_msk(%#x), famsk(%#x), interface_msk(%#x), base(%#x), cmd(%#x), msk(%#x), value(%#x)\n",
1713 GET_PWR_CFG_OFFSET(cfg_cmd
),
1714 GET_PWR_CFG_CUT_MASK(cfg_cmd
),
1715 GET_PWR_CFG_FAB_MASK(cfg_cmd
),
1716 GET_PWR_CFG_INTF_MASK(cfg_cmd
),
1717 GET_PWR_CFG_BASE(cfg_cmd
), GET_PWR_CFG_CMD(cfg_cmd
),
1718 GET_PWR_CFG_MASK(cfg_cmd
), GET_PWR_CFG_VALUE(cfg_cmd
));
1720 if ((GET_PWR_CFG_FAB_MASK(cfg_cmd
)&faversion
) &&
1721 (GET_PWR_CFG_CUT_MASK(cfg_cmd
)&cut_version
) &&
1722 (GET_PWR_CFG_INTF_MASK(cfg_cmd
)&interface_type
)) {
1723 switch (GET_PWR_CFG_CMD(cfg_cmd
)) {
1725 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1726 "rtl_hal_pwrseqcmdparsing(): PWR_CMD_READ\n");
1729 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1730 "rtl_hal_pwrseqcmdparsing(): PWR_CMD_WRITE\n");
1731 offset
= GET_PWR_CFG_OFFSET(cfg_cmd
);
1733 /*Read the value from system register*/
1734 value
= rtl_read_byte(rtlpriv
, offset
);
1735 value
&= (~(GET_PWR_CFG_MASK(cfg_cmd
)));
1736 value
|= (GET_PWR_CFG_VALUE(cfg_cmd
) &
1737 GET_PWR_CFG_MASK(cfg_cmd
));
1739 /*Write the value back to sytem register*/
1740 rtl_write_byte(rtlpriv
, offset
, value
);
1742 case PWR_CMD_POLLING
:
1743 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1744 "rtl_hal_pwrseqcmdparsing(): PWR_CMD_POLLING\n");
1745 polling_bit
= false;
1746 offset
= GET_PWR_CFG_OFFSET(cfg_cmd
);
1749 value
= rtl_read_byte(rtlpriv
, offset
);
1751 value
&= GET_PWR_CFG_MASK(cfg_cmd
);
1753 (GET_PWR_CFG_VALUE(cfg_cmd
) &
1754 GET_PWR_CFG_MASK(cfg_cmd
)))
1759 if (polling_count
++ > max_polling_cnt
)
1761 } while (!polling_bit
);
1764 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1765 "rtl_hal_pwrseqcmdparsing(): PWR_CMD_DELAY\n");
1766 if (GET_PWR_CFG_VALUE(cfg_cmd
) ==
1768 udelay(GET_PWR_CFG_OFFSET(cfg_cmd
));
1770 mdelay(GET_PWR_CFG_OFFSET(cfg_cmd
));
1773 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
1774 "rtl_hal_pwrseqcmdparsing(): PWR_CMD_END\n");
1778 "rtl_hal_pwrseqcmdparsing(): Unknown CMD!!\n");
1787 EXPORT_SYMBOL(rtl_hal_pwrseqcmdparsing
);
1789 bool rtl_cmd_send_packet(struct ieee80211_hw
*hw
, struct sk_buff
*skb
)
1791 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1792 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
1793 struct rtl8192_tx_ring
*ring
;
1794 struct rtl_tx_desc
*pdesc
;
1795 unsigned long flags
;
1796 struct sk_buff
*pskb
= NULL
;
1798 ring
= &rtlpci
->tx_ring
[BEACON_QUEUE
];
1800 spin_lock_irqsave(&rtlpriv
->locks
.irq_th_lock
, flags
);
1801 pskb
= __skb_dequeue(&ring
->queue
);
1805 /*this is wrong, fill_tx_cmddesc needs update*/
1806 pdesc
= &ring
->desc
[0];
1808 rtlpriv
->cfg
->ops
->fill_tx_cmddesc(hw
, (u8
*)pdesc
, 1, 1, skb
);
1810 __skb_queue_tail(&ring
->queue
, skb
);
1812 spin_unlock_irqrestore(&rtlpriv
->locks
.irq_th_lock
, flags
);
1814 rtlpriv
->cfg
->ops
->tx_polling(hw
, BEACON_QUEUE
);
1818 EXPORT_SYMBOL(rtl_cmd_send_packet
);
1819 const struct ieee80211_ops rtl_ops
= {
1820 .start
= rtl_op_start
,
1821 .stop
= rtl_op_stop
,
1823 .add_interface
= rtl_op_add_interface
,
1824 .remove_interface
= rtl_op_remove_interface
,
1825 .change_interface
= rtl_op_change_interface
,
1827 .suspend
= rtl_op_suspend
,
1828 .resume
= rtl_op_resume
,
1830 .config
= rtl_op_config
,
1831 .configure_filter
= rtl_op_configure_filter
,
1832 .set_key
= rtl_op_set_key
,
1833 .conf_tx
= rtl_op_conf_tx
,
1834 .bss_info_changed
= rtl_op_bss_info_changed
,
1835 .get_tsf
= rtl_op_get_tsf
,
1836 .set_tsf
= rtl_op_set_tsf
,
1837 .reset_tsf
= rtl_op_reset_tsf
,
1838 .sta_notify
= rtl_op_sta_notify
,
1839 .ampdu_action
= rtl_op_ampdu_action
,
1840 .sw_scan_start
= rtl_op_sw_scan_start
,
1841 .sw_scan_complete
= rtl_op_sw_scan_complete
,
1842 .rfkill_poll
= rtl_op_rfkill_poll
,
1843 .sta_add
= rtl_op_sta_add
,
1844 .sta_remove
= rtl_op_sta_remove
,
1845 .flush
= rtl_op_flush
,
1847 EXPORT_SYMBOL_GPL(rtl_ops
);
1849 bool rtl_btc_status_false(void)
1853 EXPORT_SYMBOL_GPL(rtl_btc_status_false
);