diff options
Diffstat (limited to 'drivers/net/wireless/rtlwifi/core.c')
-rw-r--r-- | drivers/net/wireless/rtlwifi/core.c | 888 |
1 files changed, 648 insertions, 240 deletions
diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c index 56e218e0469c..f6179bc06086 100644 --- a/drivers/net/wireless/rtlwifi/core.c +++ b/drivers/net/wireless/rtlwifi/core.c | |||
@@ -11,10 +11,6 @@ | |||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
12 | * more details. | 12 | * more details. |
13 | * | 13 | * |
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 | ||
17 | * | ||
18 | * The full GNU General Public License is included in this distribution in the | 14 | * The full GNU General Public License is included in this distribution in the |
19 | * file called LICENSE. | 15 | * file called LICENSE. |
20 | * | 16 | * |
@@ -31,10 +27,13 @@ | |||
31 | #include "core.h" | 27 | #include "core.h" |
32 | #include "cam.h" | 28 | #include "cam.h" |
33 | #include "base.h" | 29 | #include "base.h" |
34 | #include "pci.h" | ||
35 | #include "ps.h" | 30 | #include "ps.h" |
31 | #include "pwrseqcmd.h" | ||
36 | 32 | ||
33 | #include "btcoexist/rtl_btc.h" | ||
34 | #include <linux/firmware.h> | ||
37 | #include <linux/export.h> | 35 | #include <linux/export.h> |
36 | #include <net/cfg80211.h> | ||
38 | 37 | ||
39 | void rtl_addr_delay(u32 addr) | 38 | void rtl_addr_delay(u32 addr) |
40 | { | 39 | { |
@@ -103,7 +102,7 @@ void rtl_fw_cb(const struct firmware *firmware, void *context) | |||
103 | int err; | 102 | int err; |
104 | 103 | ||
105 | RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, | 104 | RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, |
106 | "Firmware callback routine entered!\n"); | 105 | "Firmware callback routine entered!\n"); |
107 | complete(&rtlpriv->firmware_loading_complete); | 106 | complete(&rtlpriv->firmware_loading_complete); |
108 | if (!firmware) { | 107 | if (!firmware) { |
109 | if (rtlpriv->cfg->alt_fw_name) { | 108 | if (rtlpriv->cfg->alt_fw_name) { |
@@ -129,26 +128,13 @@ found_alt: | |||
129 | memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size); | 128 | memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size); |
130 | rtlpriv->rtlhal.fwsize = firmware->size; | 129 | rtlpriv->rtlhal.fwsize = firmware->size; |
131 | release_firmware(firmware); | 130 | release_firmware(firmware); |
132 | |||
133 | err = ieee80211_register_hw(hw); | ||
134 | if (err) { | ||
135 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | ||
136 | "Can't register mac80211 hw\n"); | ||
137 | return; | ||
138 | } else { | ||
139 | rtlpriv->mac80211.mac80211_registered = 1; | ||
140 | } | ||
141 | set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status); | ||
142 | |||
143 | /*init rfkill */ | ||
144 | rtl_init_rfkill(hw); | ||
145 | } | 131 | } |
146 | EXPORT_SYMBOL(rtl_fw_cb); | 132 | EXPORT_SYMBOL(rtl_fw_cb); |
147 | 133 | ||
148 | /*mutex for start & stop is must here. */ | 134 | /*mutex for start & stop is must here. */ |
149 | static int rtl_op_start(struct ieee80211_hw *hw) | 135 | static int rtl_op_start(struct ieee80211_hw *hw) |
150 | { | 136 | { |
151 | int err; | 137 | int err = 0; |
152 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 138 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
153 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | 139 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); |
154 | 140 | ||
@@ -170,28 +156,33 @@ static void rtl_op_stop(struct ieee80211_hw *hw) | |||
170 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | 156 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
171 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | 157 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); |
172 | struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); | 158 | struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); |
159 | bool support_remote_wakeup = false; | ||
173 | 160 | ||
174 | if (is_hal_stop(rtlhal)) | 161 | if (is_hal_stop(rtlhal)) |
175 | return; | 162 | return; |
176 | 163 | ||
164 | rtlpriv->cfg->ops->get_hw_reg(hw, HAL_DEF_WOWLAN, | ||
165 | (u8 *)(&support_remote_wakeup)); | ||
177 | /* here is must, because adhoc do stop and start, | 166 | /* here is must, because adhoc do stop and start, |
178 | * but stop with RFOFF may cause something wrong, | 167 | * but stop with RFOFF may cause something wrong, |
179 | * like adhoc TP | 168 | * like adhoc TP |
180 | */ | 169 | */ |
181 | if (unlikely(ppsc->rfpwr_state == ERFOFF)) { | 170 | if (unlikely(ppsc->rfpwr_state == ERFOFF)) |
182 | rtl_ips_nic_on(hw); | 171 | rtl_ips_nic_on(hw); |
183 | } | ||
184 | 172 | ||
185 | mutex_lock(&rtlpriv->locks.conf_mutex); | 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; | ||
186 | 180 | ||
187 | mac->link_state = MAC80211_NOLINK; | 181 | /* reset sec info */ |
188 | memset(mac->bssid, 0, ETH_ALEN); | 182 | rtl_cam_reset_sec_info(hw); |
189 | mac->vendor = PEER_UNKNOWN; | ||
190 | |||
191 | /*reset sec info */ | ||
192 | rtl_cam_reset_sec_info(hw); | ||
193 | 183 | ||
194 | rtl_deinit_deferred_work(hw); | 184 | rtl_deinit_deferred_work(hw); |
185 | } | ||
195 | rtlpriv->intf_ops->adapter_stop(hw); | 186 | rtlpriv->intf_ops->adapter_stop(hw); |
196 | 187 | ||
197 | mutex_unlock(&rtlpriv->locks.conf_mutex); | 188 | mutex_unlock(&rtlpriv->locks.conf_mutex); |
@@ -215,7 +206,6 @@ static void rtl_op_tx(struct ieee80211_hw *hw, | |||
215 | 206 | ||
216 | if (!rtlpriv->intf_ops->waitq_insert(hw, control->sta, skb)) | 207 | if (!rtlpriv->intf_ops->waitq_insert(hw, control->sta, skb)) |
217 | rtlpriv->intf_ops->adapter_tx(hw, control->sta, skb, &tcb_desc); | 208 | rtlpriv->intf_ops->adapter_tx(hw, control->sta, skb, &tcb_desc); |
218 | |||
219 | return; | 209 | return; |
220 | 210 | ||
221 | err_free: | 211 | err_free: |
@@ -229,18 +219,17 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw, | |||
229 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | 219 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
230 | int err = 0; | 220 | int err = 0; |
231 | 221 | ||
232 | vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; | ||
233 | |||
234 | if (mac->vif) { | 222 | if (mac->vif) { |
235 | RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, | 223 | RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, |
236 | "vif has been set!! mac->vif = 0x%p\n", mac->vif); | 224 | "vif has been set!! mac->vif = 0x%p\n", mac->vif); |
237 | return -EOPNOTSUPP; | 225 | return -EOPNOTSUPP; |
238 | } | 226 | } |
239 | 227 | ||
228 | vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; | ||
229 | |||
240 | rtl_ips_nic_on(hw); | 230 | rtl_ips_nic_on(hw); |
241 | 231 | ||
242 | mutex_lock(&rtlpriv->locks.conf_mutex); | 232 | mutex_lock(&rtlpriv->locks.conf_mutex); |
243 | |||
244 | switch (ieee80211_vif_type_p2p(vif)) { | 233 | switch (ieee80211_vif_type_p2p(vif)) { |
245 | case NL80211_IFTYPE_P2P_CLIENT: | 234 | case NL80211_IFTYPE_P2P_CLIENT: |
246 | mac->p2p = P2P_ROLE_CLIENT; | 235 | mac->p2p = P2P_ROLE_CLIENT; |
@@ -251,10 +240,8 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw, | |||
251 | "NL80211_IFTYPE_STATION\n"); | 240 | "NL80211_IFTYPE_STATION\n"); |
252 | mac->beacon_enabled = 0; | 241 | mac->beacon_enabled = 0; |
253 | rtlpriv->cfg->ops->update_interrupt_mask(hw, 0, | 242 | rtlpriv->cfg->ops->update_interrupt_mask(hw, 0, |
254 | rtlpriv->cfg->maps | 243 | rtlpriv->cfg->maps[RTL_IBSS_INT_MASKS]); |
255 | [RTL_IBSS_INT_MASKS]); | ||
256 | } | 244 | } |
257 | mac->link_state = MAC80211_LINKED; | ||
258 | break; | 245 | break; |
259 | case NL80211_IFTYPE_ADHOC: | 246 | case NL80211_IFTYPE_ADHOC: |
260 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, | 247 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, |
@@ -267,7 +254,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw, | |||
267 | else | 254 | else |
268 | mac->basic_rates = 0xff0; | 255 | mac->basic_rates = 0xff0; |
269 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE, | 256 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE, |
270 | (u8 *) (&mac->basic_rates)); | 257 | (u8 *)(&mac->basic_rates)); |
271 | 258 | ||
272 | break; | 259 | break; |
273 | case NL80211_IFTYPE_P2P_GO: | 260 | case NL80211_IFTYPE_P2P_GO: |
@@ -284,7 +271,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw, | |||
284 | else | 271 | else |
285 | mac->basic_rates = 0xff0; | 272 | mac->basic_rates = 0xff0; |
286 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE, | 273 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE, |
287 | (u8 *) (&mac->basic_rates)); | 274 | (u8 *)(&mac->basic_rates)); |
288 | break; | 275 | break; |
289 | case NL80211_IFTYPE_MESH_POINT: | 276 | case NL80211_IFTYPE_MESH_POINT: |
290 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, | 277 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, |
@@ -301,7 +288,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw, | |||
301 | break; | 288 | break; |
302 | default: | 289 | default: |
303 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | 290 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, |
304 | "operation mode %d is not supported!\n", vif->type); | 291 | "operation mode %d is not support!\n", vif->type); |
305 | err = -EOPNOTSUPP; | 292 | err = -EOPNOTSUPP; |
306 | goto out; | 293 | goto out; |
307 | } | 294 | } |
@@ -339,8 +326,7 @@ static void rtl_op_remove_interface(struct ieee80211_hw *hw, | |||
339 | if (mac->beacon_enabled == 1) { | 326 | if (mac->beacon_enabled == 1) { |
340 | mac->beacon_enabled = 0; | 327 | mac->beacon_enabled = 0; |
341 | rtlpriv->cfg->ops->update_interrupt_mask(hw, 0, | 328 | rtlpriv->cfg->ops->update_interrupt_mask(hw, 0, |
342 | rtlpriv->cfg->maps | 329 | rtlpriv->cfg->maps[RTL_IBSS_INT_MASKS]); |
343 | [RTL_IBSS_INT_MASKS]); | ||
344 | } | 330 | } |
345 | } | 331 | } |
346 | 332 | ||
@@ -355,12 +341,12 @@ static void rtl_op_remove_interface(struct ieee80211_hw *hw, | |||
355 | mac->vendor = PEER_UNKNOWN; | 341 | mac->vendor = PEER_UNKNOWN; |
356 | mac->opmode = NL80211_IFTYPE_UNSPECIFIED; | 342 | mac->opmode = NL80211_IFTYPE_UNSPECIFIED; |
357 | rtlpriv->cfg->ops->set_network_type(hw, mac->opmode); | 343 | rtlpriv->cfg->ops->set_network_type(hw, mac->opmode); |
344 | |||
358 | mutex_unlock(&rtlpriv->locks.conf_mutex); | 345 | mutex_unlock(&rtlpriv->locks.conf_mutex); |
359 | } | 346 | } |
360 | |||
361 | static int rtl_op_change_interface(struct ieee80211_hw *hw, | 347 | static int rtl_op_change_interface(struct ieee80211_hw *hw, |
362 | struct ieee80211_vif *vif, | 348 | struct ieee80211_vif *vif, |
363 | enum nl80211_iftype new_type, bool p2p) | 349 | enum nl80211_iftype new_type, bool p2p) |
364 | { | 350 | { |
365 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 351 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
366 | int ret; | 352 | int ret; |
@@ -370,10 +356,221 @@ static int rtl_op_change_interface(struct ieee80211_hw *hw, | |||
370 | vif->p2p = p2p; | 356 | vif->p2p = p2p; |
371 | ret = rtl_op_add_interface(hw, vif); | 357 | ret = rtl_op_add_interface(hw, vif); |
372 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, | 358 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, |
373 | "p2p %x\n", p2p); | 359 | "p2p %x\n", p2p); |
374 | return ret; | 360 | return ret; |
375 | } | 361 | } |
376 | 362 | ||
363 | #ifdef CONFIG_PM | ||
364 | static u16 crc16_ccitt(u8 data, u16 crc) | ||
365 | { | ||
366 | u8 shift_in, data_bit, crc_bit11, crc_bit4, crc_bit15; | ||
367 | u8 i; | ||
368 | u16 result; | ||
369 | |||
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; | ||
374 | |||
375 | result = crc << 1; | ||
376 | if (shift_in == 0) | ||
377 | result &= (~BIT(0)); | ||
378 | else | ||
379 | result |= BIT(0); | ||
380 | |||
381 | crc_bit11 = ((crc & BIT(11)) ? 1 : 0) ^ shift_in; | ||
382 | if (crc_bit11 == 0) | ||
383 | result &= (~BIT(12)); | ||
384 | else | ||
385 | result |= BIT(12); | ||
386 | |||
387 | crc_bit4 = ((crc & BIT(4)) ? 1 : 0) ^ shift_in; | ||
388 | if (crc_bit4 == 0) | ||
389 | result &= (~BIT(5)); | ||
390 | else | ||
391 | result |= BIT(5); | ||
392 | |||
393 | crc = result; | ||
394 | } | ||
395 | |||
396 | return crc; | ||
397 | } | ||
398 | |||
399 | static u16 _calculate_wol_pattern_crc(u8 *pattern, u16 len) | ||
400 | { | ||
401 | u16 crc = 0xffff; | ||
402 | u32 i; | ||
403 | |||
404 | for (i = 0; i < len; i++) | ||
405 | crc = crc16_ccitt(pattern[i], crc); | ||
406 | |||
407 | crc = ~crc; | ||
408 | |||
409 | return crc; | ||
410 | } | ||
411 | |||
412 | static void _rtl_add_wowlan_patterns(struct ieee80211_hw *hw, | ||
413 | struct cfg80211_wowlan *wow) | ||
414 | { | ||
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}; | ||
425 | u8 i, mask_len; | ||
426 | u16 j, len; | ||
427 | |||
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); | ||
434 | continue; | ||
435 | } | ||
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; | ||
452 | else | ||
453 | rtl_pattern.type = UNKNOWN_TYPE; | ||
454 | |||
455 | /* 2. translate mask_from_os to mask_for_hw */ | ||
456 | |||
457 | /****************************************************************************** | ||
458 | * pattern from OS uses 'ethenet frame', like this: | ||
459 | |||
460 | | 6 | 6 | 2 | 20 | Variable | 4 | | ||
461 | |--------+--------+------+-----------+------------+-----| | ||
462 | | 802.3 Mac Header | IP Header | TCP Packet | FCS | | ||
463 | | DA | SA | Type | | ||
464 | |||
465 | * BUT, packet catched by our HW is in '802.11 frame', begin from LLC, | ||
466 | |||
467 | | 24 or 30 | 6 | 2 | 20 | Variable | 4 | | ||
468 | |-------------------+--------+------+-----------+------------+-----| | ||
469 | | 802.11 MAC Header | LLC | IP Header | TCP Packet | FCS | | ||
470 | | Others | Tpye | | ||
471 | |||
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 | ******************************************************************************/ | ||
477 | |||
478 | /* Shift 6 bits */ | ||
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; | ||
482 | } | ||
483 | mask[j] = (mask_os[j] >> 6) & 0x3F; | ||
484 | /* Set bit 0-5 to zero */ | ||
485 | mask[0] &= 0xC0; | ||
486 | |||
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); | ||
494 | } | ||
495 | |||
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. | ||
499 | */ | ||
500 | len = 0; | ||
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]; | ||
504 | len++; | ||
505 | } | ||
506 | } | ||
507 | |||
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); | ||
514 | |||
515 | /* 4. write crc & mask_for_hw to hw */ | ||
516 | rtlpriv->cfg->ops->add_wowlan_pattern(hw, &rtl_pattern, i); | ||
517 | } | ||
518 | rtl_write_byte(rtlpriv, 0x698, wow->n_patterns); | ||
519 | } | ||
520 | |||
521 | static int rtl_op_suspend(struct ieee80211_hw *hw, | ||
522 | struct cfg80211_wowlan *wow) | ||
523 | { | ||
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)); | ||
527 | struct timeval ts; | ||
528 | |||
529 | RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n"); | ||
530 | if (WARN_ON(!wow)) | ||
531 | return -EINVAL; | ||
532 | |||
533 | /* to resolve s4 can not wake up*/ | ||
534 | do_gettimeofday(&ts); | ||
535 | rtlhal->last_suspend_sec = ts.tv_sec; | ||
536 | |||
537 | if ((ppsc->wo_wlan_mode & WAKE_ON_PATTERN_MATCH) && wow->n_patterns) | ||
538 | _rtl_add_wowlan_patterns(hw, wow); | ||
539 | |||
540 | rtlhal->driver_is_goingto_unload = true; | ||
541 | rtlhal->enter_pnp_sleep = true; | ||
542 | |||
543 | rtl_lps_leave(hw); | ||
544 | rtl_op_stop(hw); | ||
545 | device_set_wakeup_enable(wiphy_dev(hw->wiphy), true); | ||
546 | return 0; | ||
547 | } | ||
548 | |||
549 | static int rtl_op_resume(struct ieee80211_hw *hw) | ||
550 | { | ||
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)); | ||
554 | struct timeval ts; | ||
555 | |||
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; | ||
560 | |||
561 | /* to resovle s4 can not wake up*/ | ||
562 | do_gettimeofday(&ts); | ||
563 | if (ts.tv_sec - rtlhal->last_suspend_sec < 5) | ||
564 | return -1; | ||
565 | |||
566 | rtl_op_start(hw); | ||
567 | device_set_wakeup_enable(wiphy_dev(hw->wiphy), false); | ||
568 | ieee80211_resume_disconnect(mac->vif); | ||
569 | rtlhal->wake_from_pnp_sleep = false; | ||
570 | return 0; | ||
571 | } | ||
572 | #endif | ||
573 | |||
377 | static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) | 574 | static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) |
378 | { | 575 | { |
379 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 576 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
@@ -386,7 +583,7 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) | |||
386 | return 1; | 583 | return 1; |
387 | 584 | ||
388 | mutex_lock(&rtlpriv->locks.conf_mutex); | 585 | mutex_lock(&rtlpriv->locks.conf_mutex); |
389 | if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { /*BIT(2)*/ | 586 | if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { /* BIT(2)*/ |
390 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, | 587 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, |
391 | "IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n"); | 588 | "IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n"); |
392 | } | 589 | } |
@@ -421,8 +618,8 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) | |||
421 | * is worked very well */ | 618 | * is worked very well */ |
422 | if (!rtlpriv->psc.multi_buffered) | 619 | if (!rtlpriv->psc.multi_buffered) |
423 | queue_delayed_work(rtlpriv->works.rtl_wq, | 620 | queue_delayed_work(rtlpriv->works.rtl_wq, |
424 | &rtlpriv->works.ps_work, | 621 | &rtlpriv->works.ps_work, |
425 | MSECS(5)); | 622 | MSECS(5)); |
426 | } else { | 623 | } else { |
427 | rtl_swlps_rf_awake(hw); | 624 | rtl_swlps_rf_awake(hw); |
428 | rtlpriv->psc.sw_ps_enabled = false; | 625 | rtlpriv->psc.sw_ps_enabled = false; |
@@ -436,20 +633,26 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) | |||
436 | mac->retry_long = hw->conf.long_frame_max_tx_count; | 633 | mac->retry_long = hw->conf.long_frame_max_tx_count; |
437 | mac->retry_short = hw->conf.long_frame_max_tx_count; | 634 | mac->retry_short = hw->conf.long_frame_max_tx_count; |
438 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT, | 635 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT, |
439 | (u8 *) (&hw->conf. | 636 | (u8 *)(&hw->conf.long_frame_max_tx_count)); |
440 | long_frame_max_tx_count)); | ||
441 | } | 637 | } |
442 | 638 | ||
443 | if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { | 639 | if (changed & IEEE80211_CONF_CHANGE_CHANNEL && |
640 | !rtlpriv->proximity.proxim_on) { | ||
444 | struct ieee80211_channel *channel = hw->conf.chandef.chan; | 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; | ||
445 | u8 wide_chan = (u8) channel->hw_value; | 644 | u8 wide_chan = (u8) channel->hw_value; |
446 | 645 | ||
646 | /* channel_type is for 20&40M */ | ||
647 | if (width < NL80211_CHAN_WIDTH_80) | ||
648 | channel_type = | ||
649 | cfg80211_get_chandef_type(&hw->conf.chandef); | ||
447 | if (mac->act_scanning) | 650 | if (mac->act_scanning) |
448 | mac->n_channels++; | 651 | mac->n_channels++; |
449 | 652 | ||
450 | if (rtlpriv->dm.supp_phymode_switch && | 653 | if (rtlpriv->dm.supp_phymode_switch && |
451 | mac->link_state < MAC80211_LINKED && | 654 | mac->link_state < MAC80211_LINKED && |
452 | !mac->act_scanning) { | 655 | !mac->act_scanning) { |
453 | if (rtlpriv->cfg->ops->chk_switch_dmdp) | 656 | if (rtlpriv->cfg->ops->chk_switch_dmdp) |
454 | rtlpriv->cfg->ops->chk_switch_dmdp(hw); | 657 | rtlpriv->cfg->ops->chk_switch_dmdp(hw); |
455 | } | 658 | } |
@@ -463,48 +666,98 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) | |||
463 | *info for cisco1253 bw20, so we modify | 666 | *info for cisco1253 bw20, so we modify |
464 | *it here based on UPPER & LOWER | 667 | *it here based on UPPER & LOWER |
465 | */ | 668 | */ |
466 | switch (cfg80211_get_chandef_type(&hw->conf.chandef)) { | 669 | |
467 | case NL80211_CHAN_HT20: | 670 | if (width >= NL80211_CHAN_WIDTH_80) { |
468 | case NL80211_CHAN_NO_HT: | 671 | if (width == NL80211_CHAN_WIDTH_80) { |
469 | /* SC */ | 672 | u32 center = hw->conf.chandef.center_freq1; |
470 | mac->cur_40_prime_sc = | 673 | u32 primary = |
471 | PRIME_CHNL_OFFSET_DONT_CARE; | 674 | (u32)hw->conf.chandef.chan->center_freq; |
472 | rtlphy->current_chan_bw = HT_CHANNEL_WIDTH_20; | 675 | |
473 | mac->bw_40 = false; | 676 | rtlphy->current_chan_bw = |
474 | break; | 677 | HT_CHANNEL_WIDTH_80; |
475 | case NL80211_CHAN_HT40MINUS: | 678 | mac->bw_80 = true; |
476 | /* SC */ | 679 | mac->bw_40 = true; |
477 | mac->cur_40_prime_sc = PRIME_CHNL_OFFSET_UPPER; | 680 | if (center > primary) { |
478 | rtlphy->current_chan_bw = | 681 | mac->cur_80_prime_sc = |
479 | HT_CHANNEL_WIDTH_20_40; | 682 | PRIME_CHNL_OFFSET_LOWER; |
480 | mac->bw_40 = true; | 683 | if (center - primary == 10) { |
481 | 684 | mac->cur_40_prime_sc = | |
482 | /*wide channel */ | 685 | PRIME_CHNL_OFFSET_UPPER; |
483 | wide_chan -= 2; | 686 | |
484 | 687 | wide_chan += 2; | |
485 | break; | 688 | } else if (center - primary == 30) { |
486 | case NL80211_CHAN_HT40PLUS: | 689 | mac->cur_40_prime_sc = |
487 | /* SC */ | 690 | PRIME_CHNL_OFFSET_LOWER; |
488 | mac->cur_40_prime_sc = PRIME_CHNL_OFFSET_LOWER; | 691 | |
489 | rtlphy->current_chan_bw = | 692 | wide_chan += 6; |
490 | HT_CHANNEL_WIDTH_20_40; | 693 | } |
491 | mac->bw_40 = true; | 694 | } else { |
492 | 695 | mac->cur_80_prime_sc = | |
493 | /*wide channel */ | 696 | PRIME_CHNL_OFFSET_UPPER; |
494 | wide_chan += 2; | 697 | if (primary - center == 10) { |
495 | 698 | mac->cur_40_prime_sc = | |
496 | break; | 699 | PRIME_CHNL_OFFSET_LOWER; |
497 | default: | 700 | |
498 | mac->bw_40 = false; | 701 | wide_chan -= 2; |
499 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | 702 | } else if (primary - center == 30) { |
500 | "switch case not processed\n"); | 703 | mac->cur_40_prime_sc = |
501 | break; | 704 | PRIME_CHNL_OFFSET_UPPER; |
705 | |||
706 | wide_chan -= 6; | ||
707 | } | ||
708 | } | ||
709 | } | ||
710 | } else { | ||
711 | switch (channel_type) { | ||
712 | case NL80211_CHAN_HT20: | ||
713 | case NL80211_CHAN_NO_HT: | ||
714 | /* SC */ | ||
715 | mac->cur_40_prime_sc = | ||
716 | PRIME_CHNL_OFFSET_DONT_CARE; | ||
717 | rtlphy->current_chan_bw = | ||
718 | HT_CHANNEL_WIDTH_20; | ||
719 | mac->bw_40 = false; | ||
720 | mac->bw_80 = false; | ||
721 | break; | ||
722 | case NL80211_CHAN_HT40MINUS: | ||
723 | /* SC */ | ||
724 | mac->cur_40_prime_sc = | ||
725 | PRIME_CHNL_OFFSET_UPPER; | ||
726 | rtlphy->current_chan_bw = | ||
727 | HT_CHANNEL_WIDTH_20_40; | ||
728 | mac->bw_40 = true; | ||
729 | mac->bw_80 = false; | ||
730 | |||
731 | /*wide channel */ | ||
732 | wide_chan -= 2; | ||
733 | |||
734 | break; | ||
735 | case NL80211_CHAN_HT40PLUS: | ||
736 | /* SC */ | ||
737 | mac->cur_40_prime_sc = | ||
738 | PRIME_CHNL_OFFSET_LOWER; | ||
739 | rtlphy->current_chan_bw = | ||
740 | HT_CHANNEL_WIDTH_20_40; | ||
741 | mac->bw_40 = true; | ||
742 | mac->bw_80 = false; | ||
743 | |||
744 | /*wide channel */ | ||
745 | wide_chan += 2; | ||
746 | |||
747 | break; | ||
748 | default: | ||
749 | mac->bw_40 = false; | ||
750 | mac->bw_80 = false; | ||
751 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | ||
752 | "switch case not processed\n"); | ||
753 | break; | ||
754 | } | ||
502 | } | 755 | } |
503 | 756 | ||
504 | if (wide_chan <= 0) | 757 | if (wide_chan <= 0) |
505 | wide_chan = 1; | 758 | wide_chan = 1; |
506 | 759 | ||
507 | /* In scanning, before we go offchannel we may send a ps = 1 | 760 | /* In scanning, when before we offchannel we may send a ps=1 |
508 | * null to AP, and then we may send a ps = 0 null to AP quickly, | 761 | * null to AP, and then we may send a ps = 0 null to AP quickly, |
509 | * but first null may have caused AP to put lots of packet to | 762 | * but first null may have caused AP to put lots of packet to |
510 | * hw tx buffer. These packets must be tx'd before we go off | 763 | * hw tx buffer. These packets must be tx'd before we go off |
@@ -516,12 +769,12 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) | |||
516 | rtlpriv->mac80211.offchan_delay = false; | 769 | rtlpriv->mac80211.offchan_delay = false; |
517 | mdelay(50); | 770 | mdelay(50); |
518 | } | 771 | } |
772 | |||
519 | rtlphy->current_channel = wide_chan; | 773 | rtlphy->current_channel = wide_chan; |
520 | 774 | ||
521 | rtlpriv->cfg->ops->switch_channel(hw); | 775 | rtlpriv->cfg->ops->switch_channel(hw); |
522 | rtlpriv->cfg->ops->set_channel_access(hw); | 776 | rtlpriv->cfg->ops->set_channel_access(hw); |
523 | rtlpriv->cfg->ops->set_bw_mode(hw, | 777 | rtlpriv->cfg->ops->set_bw_mode(hw, channel_type); |
524 | cfg80211_get_chandef_type(&hw->conf.chandef)); | ||
525 | } | 778 | } |
526 | 779 | ||
527 | mutex_unlock(&rtlpriv->locks.conf_mutex); | 780 | mutex_unlock(&rtlpriv->locks.conf_mutex); |
@@ -530,45 +783,25 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) | |||
530 | } | 783 | } |
531 | 784 | ||
532 | static void rtl_op_configure_filter(struct ieee80211_hw *hw, | 785 | static void rtl_op_configure_filter(struct ieee80211_hw *hw, |
533 | unsigned int changed_flags, | 786 | unsigned int changed_flags, |
534 | unsigned int *new_flags, u64 multicast) | 787 | unsigned int *new_flags, u64 multicast) |
535 | { | 788 | { |
536 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 789 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
537 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | 790 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
538 | u32 rx_conf; | ||
539 | 791 | ||
540 | *new_flags &= RTL_SUPPORTED_FILTERS; | 792 | *new_flags &= RTL_SUPPORTED_FILTERS; |
541 | if (!changed_flags) | 793 | if (0 == changed_flags) |
542 | return; | 794 | return; |
543 | 795 | ||
544 | /* if ssid not set to hw don't check bssid | ||
545 | * here just used for linked scanning, & linked | ||
546 | * and nolink check bssid is set in set network_type */ | ||
547 | if ((changed_flags & FIF_BCN_PRBRESP_PROMISC) && | ||
548 | (mac->link_state >= MAC80211_LINKED)) { | ||
549 | if (mac->opmode != NL80211_IFTYPE_AP && | ||
550 | mac->opmode != NL80211_IFTYPE_MESH_POINT) { | ||
551 | if (*new_flags & FIF_BCN_PRBRESP_PROMISC) { | ||
552 | rtlpriv->cfg->ops->set_chk_bssid(hw, false); | ||
553 | } else { | ||
554 | rtlpriv->cfg->ops->set_chk_bssid(hw, true); | ||
555 | } | ||
556 | } | ||
557 | } | ||
558 | |||
559 | /* must be called after set_chk_bssid since that function modifies the | ||
560 | * RCR register too. */ | ||
561 | rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *)(&rx_conf)); | ||
562 | |||
563 | /*TODO: we disable broadcase now, so enable here */ | 796 | /*TODO: we disable broadcase now, so enable here */ |
564 | if (changed_flags & FIF_ALLMULTI) { | 797 | if (changed_flags & FIF_ALLMULTI) { |
565 | if (*new_flags & FIF_ALLMULTI) { | 798 | if (*new_flags & FIF_ALLMULTI) { |
566 | rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AM] | | 799 | mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AM] | |
567 | rtlpriv->cfg->maps[MAC_RCR_AB]; | 800 | rtlpriv->cfg->maps[MAC_RCR_AB]; |
568 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, | 801 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, |
569 | "Enable receive multicast frame\n"); | 802 | "Enable receive multicast frame\n"); |
570 | } else { | 803 | } else { |
571 | rx_conf &= ~(rtlpriv->cfg->maps[MAC_RCR_AM] | | 804 | mac->rx_conf &= ~(rtlpriv->cfg->maps[MAC_RCR_AM] | |
572 | rtlpriv->cfg->maps[MAC_RCR_AB]); | 805 | rtlpriv->cfg->maps[MAC_RCR_AB]); |
573 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, | 806 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, |
574 | "Disable receive multicast frame\n"); | 807 | "Disable receive multicast frame\n"); |
@@ -577,43 +810,55 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw, | |||
577 | 810 | ||
578 | if (changed_flags & FIF_FCSFAIL) { | 811 | if (changed_flags & FIF_FCSFAIL) { |
579 | if (*new_flags & FIF_FCSFAIL) { | 812 | if (*new_flags & FIF_FCSFAIL) { |
580 | rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACRC32]; | 813 | mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACRC32]; |
581 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, | 814 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, |
582 | "Enable receive FCS error frame\n"); | 815 | "Enable receive FCS error frame\n"); |
583 | } else { | 816 | } else { |
584 | rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACRC32]; | 817 | mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACRC32]; |
585 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, | 818 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, |
586 | "Disable receive FCS error frame\n"); | 819 | "Disable receive FCS error frame\n"); |
587 | } | 820 | } |
588 | } | 821 | } |
589 | 822 | ||
823 | /* if ssid not set to hw don't check bssid | ||
824 | * here just used for linked scanning, & linked | ||
825 | * and nolink check bssid is set in set network_type | ||
826 | */ | ||
827 | if ((changed_flags & FIF_BCN_PRBRESP_PROMISC) && | ||
828 | (mac->link_state >= MAC80211_LINKED)) { | ||
829 | if (mac->opmode != NL80211_IFTYPE_AP && | ||
830 | mac->opmode != NL80211_IFTYPE_MESH_POINT) { | ||
831 | if (*new_flags & FIF_BCN_PRBRESP_PROMISC) | ||
832 | rtlpriv->cfg->ops->set_chk_bssid(hw, false); | ||
833 | else | ||
834 | rtlpriv->cfg->ops->set_chk_bssid(hw, true); | ||
835 | } | ||
836 | } | ||
590 | 837 | ||
591 | if (changed_flags & FIF_CONTROL) { | 838 | if (changed_flags & FIF_CONTROL) { |
592 | if (*new_flags & FIF_CONTROL) { | 839 | if (*new_flags & FIF_CONTROL) { |
593 | rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACF]; | 840 | mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACF]; |
594 | 841 | ||
595 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, | 842 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, |
596 | "Enable receive control frame\n"); | 843 | "Enable receive control frame.\n"); |
597 | } else { | 844 | } else { |
598 | rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACF]; | 845 | mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACF]; |
599 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, | 846 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, |
600 | "Disable receive control frame\n"); | 847 | "Disable receive control frame.\n"); |
601 | } | 848 | } |
602 | } | 849 | } |
603 | 850 | ||
604 | if (changed_flags & FIF_OTHER_BSS) { | 851 | if (changed_flags & FIF_OTHER_BSS) { |
605 | if (*new_flags & FIF_OTHER_BSS) { | 852 | if (*new_flags & FIF_OTHER_BSS) { |
606 | rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AAP]; | 853 | mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AAP]; |
607 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, | 854 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, |
608 | "Enable receive other BSS's frame\n"); | 855 | "Enable receive other BSS's frame.\n"); |
609 | } else { | 856 | } else { |
610 | rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_AAP]; | 857 | mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_AAP]; |
611 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, | 858 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, |
612 | "Disable receive other BSS's frame\n"); | 859 | "Disable receive other BSS's frame.\n"); |
613 | } | 860 | } |
614 | } | 861 | } |
615 | |||
616 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, (u8 *)(&rx_conf)); | ||
617 | } | 862 | } |
618 | static int rtl_op_sta_add(struct ieee80211_hw *hw, | 863 | static int rtl_op_sta_add(struct ieee80211_hw *hw, |
619 | struct ieee80211_vif *vif, | 864 | struct ieee80211_vif *vif, |
@@ -625,7 +870,7 @@ static int rtl_op_sta_add(struct ieee80211_hw *hw, | |||
625 | struct rtl_sta_info *sta_entry; | 870 | struct rtl_sta_info *sta_entry; |
626 | 871 | ||
627 | if (sta) { | 872 | if (sta) { |
628 | sta_entry = (struct rtl_sta_info *) sta->drv_priv; | 873 | sta_entry = (struct rtl_sta_info *)sta->drv_priv; |
629 | spin_lock_bh(&rtlpriv->locks.entry_list_lock); | 874 | spin_lock_bh(&rtlpriv->locks.entry_list_lock); |
630 | list_add_tail(&sta_entry->list, &rtlpriv->entry_list); | 875 | list_add_tail(&sta_entry->list, &rtlpriv->entry_list); |
631 | spin_unlock_bh(&rtlpriv->locks.entry_list_lock); | 876 | spin_unlock_bh(&rtlpriv->locks.entry_list_lock); |
@@ -633,15 +878,17 @@ static int rtl_op_sta_add(struct ieee80211_hw *hw, | |||
633 | sta_entry->wireless_mode = WIRELESS_MODE_G; | 878 | sta_entry->wireless_mode = WIRELESS_MODE_G; |
634 | if (sta->supp_rates[0] <= 0xf) | 879 | if (sta->supp_rates[0] <= 0xf) |
635 | sta_entry->wireless_mode = WIRELESS_MODE_B; | 880 | sta_entry->wireless_mode = WIRELESS_MODE_B; |
636 | if (sta->ht_cap.ht_supported == true) | 881 | if (sta->ht_cap.ht_supported) |
637 | sta_entry->wireless_mode = WIRELESS_MODE_N_24G; | 882 | sta_entry->wireless_mode = WIRELESS_MODE_N_24G; |
638 | 883 | ||
639 | if (vif->type == NL80211_IFTYPE_ADHOC) | 884 | if (vif->type == NL80211_IFTYPE_ADHOC) |
640 | sta_entry->wireless_mode = WIRELESS_MODE_G; | 885 | sta_entry->wireless_mode = WIRELESS_MODE_G; |
641 | } else if (rtlhal->current_bandtype == BAND_ON_5G) { | 886 | } else if (rtlhal->current_bandtype == BAND_ON_5G) { |
642 | sta_entry->wireless_mode = WIRELESS_MODE_A; | 887 | sta_entry->wireless_mode = WIRELESS_MODE_A; |
643 | if (sta->ht_cap.ht_supported == true) | 888 | if (sta->ht_cap.ht_supported) |
644 | sta_entry->wireless_mode = WIRELESS_MODE_N_24G; | 889 | sta_entry->wireless_mode = WIRELESS_MODE_N_5G; |
890 | if (sta->vht_cap.vht_supported) | ||
891 | sta_entry->wireless_mode = WIRELESS_MODE_AC_5G; | ||
645 | 892 | ||
646 | if (vif->type == NL80211_IFTYPE_ADHOC) | 893 | if (vif->type == NL80211_IFTYPE_ADHOC) |
647 | sta_entry->wireless_mode = WIRELESS_MODE_A; | 894 | sta_entry->wireless_mode = WIRELESS_MODE_A; |
@@ -652,9 +899,10 @@ static int rtl_op_sta_add(struct ieee80211_hw *hw, | |||
652 | 899 | ||
653 | memcpy(sta_entry->mac_addr, sta->addr, ETH_ALEN); | 900 | memcpy(sta_entry->mac_addr, sta->addr, ETH_ALEN); |
654 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, | 901 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, |
655 | "Add sta addr is %pM\n", sta->addr); | 902 | "Add sta addr is %pM\n", sta->addr); |
656 | rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); | 903 | rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); |
657 | } | 904 | } |
905 | |||
658 | return 0; | 906 | return 0; |
659 | } | 907 | } |
660 | 908 | ||
@@ -667,17 +915,15 @@ static int rtl_op_sta_remove(struct ieee80211_hw *hw, | |||
667 | if (sta) { | 915 | if (sta) { |
668 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, | 916 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, |
669 | "Remove sta addr is %pM\n", sta->addr); | 917 | "Remove sta addr is %pM\n", sta->addr); |
670 | sta_entry = (struct rtl_sta_info *) sta->drv_priv; | 918 | sta_entry = (struct rtl_sta_info *)sta->drv_priv; |
671 | sta_entry->wireless_mode = 0; | 919 | sta_entry->wireless_mode = 0; |
672 | sta_entry->ratr_index = 0; | 920 | sta_entry->ratr_index = 0; |
673 | |||
674 | spin_lock_bh(&rtlpriv->locks.entry_list_lock); | 921 | spin_lock_bh(&rtlpriv->locks.entry_list_lock); |
675 | list_del(&sta_entry->list); | 922 | list_del(&sta_entry->list); |
676 | spin_unlock_bh(&rtlpriv->locks.entry_list_lock); | 923 | spin_unlock_bh(&rtlpriv->locks.entry_list_lock); |
677 | } | 924 | } |
678 | return 0; | 925 | return 0; |
679 | } | 926 | } |
680 | |||
681 | static int _rtl_get_hal_qnum(u16 queue) | 927 | static int _rtl_get_hal_qnum(u16 queue) |
682 | { | 928 | { |
683 | int qnum; | 929 | int qnum; |
@@ -707,8 +953,8 @@ static int _rtl_get_hal_qnum(u16 queue) | |||
707 | *for rtl819x BE = 0, BK = 1, VI = 2, VO = 3 | 953 | *for rtl819x BE = 0, BK = 1, VI = 2, VO = 3 |
708 | */ | 954 | */ |
709 | static int rtl_op_conf_tx(struct ieee80211_hw *hw, | 955 | static int rtl_op_conf_tx(struct ieee80211_hw *hw, |
710 | struct ieee80211_vif *vif, u16 queue, | 956 | struct ieee80211_vif *vif, u16 queue, |
711 | const struct ieee80211_tx_queue_params *param) | 957 | const struct ieee80211_tx_queue_params *param) |
712 | { | 958 | { |
713 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 959 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
714 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | 960 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
@@ -731,14 +977,14 @@ static int rtl_op_conf_tx(struct ieee80211_hw *hw, | |||
731 | } | 977 | } |
732 | 978 | ||
733 | static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, | 979 | static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, |
734 | struct ieee80211_vif *vif, | 980 | struct ieee80211_vif *vif, |
735 | struct ieee80211_bss_conf *bss_conf, u32 changed) | 981 | struct ieee80211_bss_conf *bss_conf, |
982 | u32 changed) | ||
736 | { | 983 | { |
737 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 984 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
738 | struct rtl_hal *rtlhal = rtl_hal(rtlpriv); | 985 | struct rtl_hal *rtlhal = rtl_hal(rtlpriv); |
739 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | 986 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
740 | struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); | 987 | struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); |
741 | struct ieee80211_sta *sta = NULL; | ||
742 | 988 | ||
743 | mutex_lock(&rtlpriv->locks.conf_mutex); | 989 | mutex_lock(&rtlpriv->locks.conf_mutex); |
744 | if ((vif->type == NL80211_IFTYPE_ADHOC) || | 990 | if ((vif->type == NL80211_IFTYPE_ADHOC) || |
@@ -756,15 +1002,14 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, | |||
756 | mac->beacon_enabled = 1; | 1002 | mac->beacon_enabled = 1; |
757 | rtlpriv->cfg->ops->update_interrupt_mask(hw, | 1003 | rtlpriv->cfg->ops->update_interrupt_mask(hw, |
758 | rtlpriv->cfg->maps | 1004 | rtlpriv->cfg->maps |
759 | [RTL_IBSS_INT_MASKS], | 1005 | [RTL_IBSS_INT_MASKS], 0); |
760 | 0); | ||
761 | 1006 | ||
762 | if (rtlpriv->cfg->ops->linked_set_reg) | 1007 | if (rtlpriv->cfg->ops->linked_set_reg) |
763 | rtlpriv->cfg->ops->linked_set_reg(hw); | 1008 | rtlpriv->cfg->ops->linked_set_reg(hw); |
764 | } | 1009 | } |
765 | } | 1010 | } |
766 | if ((changed & BSS_CHANGED_BEACON_ENABLED && | 1011 | if ((changed & BSS_CHANGED_BEACON_ENABLED && |
767 | !bss_conf->enable_beacon)) { | 1012 | !bss_conf->enable_beacon)) { |
768 | if (mac->beacon_enabled == 1) { | 1013 | if (mac->beacon_enabled == 1) { |
769 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, | 1014 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, |
770 | "ADHOC DISABLE BEACON\n"); | 1015 | "ADHOC DISABLE BEACON\n"); |
@@ -785,8 +1030,12 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, | |||
785 | 1030 | ||
786 | /*TODO: reference to enum ieee80211_bss_change */ | 1031 | /*TODO: reference to enum ieee80211_bss_change */ |
787 | if (changed & BSS_CHANGED_ASSOC) { | 1032 | if (changed & BSS_CHANGED_ASSOC) { |
1033 | u8 mstatus; | ||
788 | if (bss_conf->assoc) { | 1034 | if (bss_conf->assoc) { |
789 | struct ieee80211_sta *sta = NULL; | 1035 | struct ieee80211_sta *sta = NULL; |
1036 | u8 keep_alive = 10; | ||
1037 | |||
1038 | mstatus = RT_MEDIA_CONNECT; | ||
790 | /* we should reset all sec info & cam | 1039 | /* we should reset all sec info & cam |
791 | * before set cam after linked, we should not | 1040 | * before set cam after linked, we should not |
792 | * reset in disassoc, that will cause tkip->wep | 1041 | * reset in disassoc, that will cause tkip->wep |
@@ -804,47 +1053,89 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, | |||
804 | 1053 | ||
805 | if (rtlpriv->cfg->ops->linked_set_reg) | 1054 | if (rtlpriv->cfg->ops->linked_set_reg) |
806 | rtlpriv->cfg->ops->linked_set_reg(hw); | 1055 | rtlpriv->cfg->ops->linked_set_reg(hw); |
1056 | |||
807 | rcu_read_lock(); | 1057 | rcu_read_lock(); |
808 | sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid); | 1058 | sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid); |
809 | if (!sta) { | 1059 | if (!sta) { |
810 | pr_err("ieee80211_find_sta returned NULL\n"); | ||
811 | rcu_read_unlock(); | 1060 | rcu_read_unlock(); |
812 | goto out; | 1061 | goto out; |
813 | } | 1062 | } |
814 | |||
815 | if (vif->type == NL80211_IFTYPE_STATION && sta) | ||
816 | rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); | ||
817 | RT_TRACE(rtlpriv, COMP_EASY_CONCURRENT, DBG_LOUD, | 1063 | RT_TRACE(rtlpriv, COMP_EASY_CONCURRENT, DBG_LOUD, |
818 | "send PS STATIC frame\n"); | 1064 | "send PS STATIC frame\n"); |
819 | if (rtlpriv->dm.supp_phymode_switch) { | 1065 | if (rtlpriv->dm.supp_phymode_switch) { |
820 | if (sta->ht_cap.ht_supported) | 1066 | if (sta->ht_cap.ht_supported) |
821 | rtl_send_smps_action(hw, sta, | 1067 | rtl_send_smps_action(hw, sta, |
822 | IEEE80211_SMPS_STATIC); | 1068 | IEEE80211_SMPS_STATIC); |
1069 | } | ||
1070 | |||
1071 | if (rtlhal->current_bandtype == BAND_ON_5G) { | ||
1072 | mac->mode = WIRELESS_MODE_A; | ||
1073 | } else { | ||
1074 | if (sta->supp_rates[0] <= 0xf) | ||
1075 | mac->mode = WIRELESS_MODE_B; | ||
1076 | else | ||
1077 | mac->mode = WIRELESS_MODE_G; | ||
1078 | } | ||
1079 | |||
1080 | if (sta->ht_cap.ht_supported) { | ||
1081 | if (rtlhal->current_bandtype == BAND_ON_2_4G) | ||
1082 | mac->mode = WIRELESS_MODE_N_24G; | ||
1083 | else | ||
1084 | mac->mode = WIRELESS_MODE_N_5G; | ||
823 | } | 1085 | } |
1086 | |||
1087 | if (sta->vht_cap.vht_supported) { | ||
1088 | if (rtlhal->current_bandtype == BAND_ON_5G) | ||
1089 | mac->mode = WIRELESS_MODE_AC_5G; | ||
1090 | else | ||
1091 | mac->mode = WIRELESS_MODE_AC_24G; | ||
1092 | } | ||
1093 | |||
1094 | if (vif->type == NL80211_IFTYPE_STATION && sta) | ||
1095 | rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); | ||
824 | rcu_read_unlock(); | 1096 | rcu_read_unlock(); |
825 | 1097 | ||
1098 | /* to avoid AP Disassociation caused by inactivity */ | ||
1099 | rtlpriv->cfg->ops->set_hw_reg(hw, | ||
1100 | HW_VAR_KEEP_ALIVE, | ||
1101 | (u8 *)(&keep_alive)); | ||
1102 | |||
826 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, | 1103 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, |
827 | "BSS_CHANGED_ASSOC\n"); | 1104 | "BSS_CHANGED_ASSOC\n"); |
828 | } else { | 1105 | } else { |
1106 | mstatus = RT_MEDIA_DISCONNECT; | ||
1107 | |||
829 | if (mac->link_state == MAC80211_LINKED) { | 1108 | if (mac->link_state == MAC80211_LINKED) { |
830 | rtlpriv->enter_ps = false; | 1109 | rtlpriv->enter_ps = false; |
831 | schedule_work(&rtlpriv->works.lps_change_work); | 1110 | schedule_work(&rtlpriv->works.lps_change_work); |
832 | } | 1111 | } |
833 | |||
834 | if (ppsc->p2p_ps_info.p2p_ps_mode > P2P_PS_NONE) | 1112 | if (ppsc->p2p_ps_info.p2p_ps_mode > P2P_PS_NONE) |
835 | rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE); | 1113 | rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE); |
836 | mac->link_state = MAC80211_NOLINK; | 1114 | mac->link_state = MAC80211_NOLINK; |
837 | memset(mac->bssid, 0, ETH_ALEN); | 1115 | memset(mac->bssid, 0, ETH_ALEN); |
838 | mac->vendor = PEER_UNKNOWN; | 1116 | mac->vendor = PEER_UNKNOWN; |
1117 | mac->mode = 0; | ||
839 | 1118 | ||
840 | if (rtlpriv->dm.supp_phymode_switch) { | 1119 | if (rtlpriv->dm.supp_phymode_switch) { |
841 | if (rtlpriv->cfg->ops->chk_switch_dmdp) | 1120 | if (rtlpriv->cfg->ops->chk_switch_dmdp) |
842 | rtlpriv->cfg->ops->chk_switch_dmdp(hw); | 1121 | rtlpriv->cfg->ops->chk_switch_dmdp(hw); |
843 | } | 1122 | } |
844 | |||
845 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, | 1123 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, |
846 | "BSS_CHANGED_UN_ASSOC\n"); | 1124 | "BSS_CHANGED_UN_ASSOC\n"); |
847 | } | 1125 | } |
1126 | rtlpriv->cfg->ops->set_network_type(hw, vif->type); | ||
1127 | /* For FW LPS: | ||
1128 | * To tell firmware we have connected or disconnected | ||
1129 | */ | ||
1130 | rtlpriv->cfg->ops->set_hw_reg(hw, | ||
1131 | HW_VAR_H2C_FW_JOINBSSRPT, | ||
1132 | (u8 *)(&mstatus)); | ||
1133 | ppsc->report_linked = (mstatus == RT_MEDIA_CONNECT) ? | ||
1134 | true : false; | ||
1135 | |||
1136 | if (rtlpriv->cfg->ops->get_btc_status()) | ||
1137 | rtlpriv->btcoexist.btc_ops->btc_mediastatus_notify( | ||
1138 | rtlpriv, mstatus); | ||
848 | } | 1139 | } |
849 | 1140 | ||
850 | if (changed & BSS_CHANGED_ERP_CTS_PROT) { | 1141 | if (changed & BSS_CHANGED_ERP_CTS_PROT) { |
@@ -856,11 +1147,11 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, | |||
856 | if (changed & BSS_CHANGED_ERP_PREAMBLE) { | 1147 | if (changed & BSS_CHANGED_ERP_PREAMBLE) { |
857 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, | 1148 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, |
858 | "BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n", | 1149 | "BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n", |
859 | bss_conf->use_short_preamble); | 1150 | bss_conf->use_short_preamble); |
860 | 1151 | ||
861 | mac->short_preamble = bss_conf->use_short_preamble; | 1152 | mac->short_preamble = bss_conf->use_short_preamble; |
862 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACK_PREAMBLE, | 1153 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACK_PREAMBLE, |
863 | &mac->short_preamble); | 1154 | (u8 *)(&mac->short_preamble)); |
864 | } | 1155 | } |
865 | 1156 | ||
866 | if (changed & BSS_CHANGED_ERP_SLOT) { | 1157 | if (changed & BSS_CHANGED_ERP_SLOT) { |
@@ -873,13 +1164,17 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, | |||
873 | mac->slot_time = RTL_SLOT_TIME_20; | 1164 | mac->slot_time = RTL_SLOT_TIME_20; |
874 | 1165 | ||
875 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME, | 1166 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME, |
876 | &mac->slot_time); | 1167 | (u8 *)(&mac->slot_time)); |
877 | } | 1168 | } |
878 | 1169 | ||
879 | if (changed & BSS_CHANGED_HT) { | 1170 | if (changed & BSS_CHANGED_HT) { |
880 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, "BSS_CHANGED_HT\n"); | 1171 | struct ieee80211_sta *sta = NULL; |
1172 | |||
1173 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, | ||
1174 | "BSS_CHANGED_HT\n"); | ||
1175 | |||
881 | rcu_read_lock(); | 1176 | rcu_read_lock(); |
882 | sta = get_sta(hw, vif, bss_conf->bssid); | 1177 | sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid); |
883 | if (sta) { | 1178 | if (sta) { |
884 | if (sta->ht_cap.ampdu_density > | 1179 | if (sta->ht_cap.ampdu_density > |
885 | mac->current_ampdu_density) | 1180 | mac->current_ampdu_density) |
@@ -893,7 +1188,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, | |||
893 | rcu_read_unlock(); | 1188 | rcu_read_unlock(); |
894 | 1189 | ||
895 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SHORTGI_DENSITY, | 1190 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SHORTGI_DENSITY, |
896 | &mac->max_mss_density); | 1191 | (u8 *)(&mac->max_mss_density)); |
897 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_FACTOR, | 1192 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_FACTOR, |
898 | &mac->current_ampdu_factor); | 1193 | &mac->current_ampdu_factor); |
899 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_MIN_SPACE, | 1194 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_MIN_SPACE, |
@@ -902,19 +1197,19 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, | |||
902 | 1197 | ||
903 | if (changed & BSS_CHANGED_BSSID) { | 1198 | if (changed & BSS_CHANGED_BSSID) { |
904 | u32 basic_rates; | 1199 | u32 basic_rates; |
1200 | struct ieee80211_sta *sta = NULL; | ||
905 | 1201 | ||
906 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BSSID, | 1202 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BSSID, |
907 | (u8 *) bss_conf->bssid); | 1203 | (u8 *)bss_conf->bssid); |
908 | 1204 | ||
909 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, "%pM\n", | 1205 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, |
910 | bss_conf->bssid); | 1206 | "bssid: %pM\n", bss_conf->bssid); |
911 | 1207 | ||
912 | mac->vendor = PEER_UNKNOWN; | 1208 | mac->vendor = PEER_UNKNOWN; |
913 | memcpy(mac->bssid, bss_conf->bssid, ETH_ALEN); | 1209 | memcpy(mac->bssid, bss_conf->bssid, ETH_ALEN); |
914 | rtlpriv->cfg->ops->set_network_type(hw, vif->type); | ||
915 | 1210 | ||
916 | rcu_read_lock(); | 1211 | rcu_read_lock(); |
917 | sta = get_sta(hw, vif, bss_conf->bssid); | 1212 | sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid); |
918 | if (!sta) { | 1213 | if (!sta) { |
919 | rcu_read_unlock(); | 1214 | rcu_read_unlock(); |
920 | goto out; | 1215 | goto out; |
@@ -936,11 +1231,18 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, | |||
936 | mac->mode = WIRELESS_MODE_N_5G; | 1231 | mac->mode = WIRELESS_MODE_N_5G; |
937 | } | 1232 | } |
938 | 1233 | ||
1234 | if (sta->vht_cap.vht_supported) { | ||
1235 | if (rtlhal->current_bandtype == BAND_ON_5G) | ||
1236 | mac->mode = WIRELESS_MODE_AC_5G; | ||
1237 | else | ||
1238 | mac->mode = WIRELESS_MODE_AC_24G; | ||
1239 | } | ||
1240 | |||
939 | /* just station need it, because ibss & ap mode will | 1241 | /* just station need it, because ibss & ap mode will |
940 | * set in sta_add, and will be NULL here */ | 1242 | * set in sta_add, and will be NULL here */ |
941 | if (mac->opmode == NL80211_IFTYPE_STATION) { | 1243 | if (vif->type == NL80211_IFTYPE_STATION) { |
942 | struct rtl_sta_info *sta_entry; | 1244 | struct rtl_sta_info *sta_entry; |
943 | sta_entry = (struct rtl_sta_info *) sta->drv_priv; | 1245 | sta_entry = (struct rtl_sta_info *)sta->drv_priv; |
944 | sta_entry->wireless_mode = mac->mode; | 1246 | sta_entry->wireless_mode = mac->mode; |
945 | } | 1247 | } |
946 | 1248 | ||
@@ -955,6 +1257,9 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, | |||
955 | * */ | 1257 | * */ |
956 | } | 1258 | } |
957 | 1259 | ||
1260 | if (sta->vht_cap.vht_supported) | ||
1261 | mac->vht_enable = true; | ||
1262 | |||
958 | if (changed & BSS_CHANGED_BASIC_RATES) { | 1263 | if (changed & BSS_CHANGED_BASIC_RATES) { |
959 | /* for 5G must << RATE_6M_INDEX = 4, | 1264 | /* for 5G must << RATE_6M_INDEX = 4, |
960 | * because 5G have no cck rate*/ | 1265 | * because 5G have no cck rate*/ |
@@ -969,40 +1274,6 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, | |||
969 | } | 1274 | } |
970 | rcu_read_unlock(); | 1275 | rcu_read_unlock(); |
971 | } | 1276 | } |
972 | |||
973 | /* | ||
974 | * For FW LPS: | ||
975 | * To tell firmware we have connected | ||
976 | * to an AP. For 92SE/CE power save v2. | ||
977 | */ | ||
978 | if (changed & BSS_CHANGED_ASSOC) { | ||
979 | if (bss_conf->assoc) { | ||
980 | if (ppsc->fwctrl_lps) { | ||
981 | u8 mstatus = RT_MEDIA_CONNECT; | ||
982 | u8 keep_alive = 10; | ||
983 | rtlpriv->cfg->ops->set_hw_reg(hw, | ||
984 | HW_VAR_KEEP_ALIVE, | ||
985 | &keep_alive); | ||
986 | |||
987 | rtlpriv->cfg->ops->set_hw_reg(hw, | ||
988 | HW_VAR_H2C_FW_JOINBSSRPT, | ||
989 | &mstatus); | ||
990 | ppsc->report_linked = true; | ||
991 | } | ||
992 | } else { | ||
993 | if (ppsc->fwctrl_lps) { | ||
994 | u8 mstatus = RT_MEDIA_DISCONNECT; | ||
995 | rtlpriv->cfg->ops->set_hw_reg(hw, | ||
996 | HW_VAR_H2C_FW_JOINBSSRPT, | ||
997 | &mstatus); | ||
998 | ppsc->report_linked = false; | ||
999 | } | ||
1000 | } | ||
1001 | if (rtlpriv->cfg->ops->bt_wifi_media_status_notify) | ||
1002 | rtlpriv->cfg->ops->bt_wifi_media_status_notify(hw, | ||
1003 | ppsc->report_linked); | ||
1004 | } | ||
1005 | |||
1006 | out: | 1277 | out: |
1007 | mutex_unlock(&rtlpriv->locks.conf_mutex); | 1278 | mutex_unlock(&rtlpriv->locks.conf_mutex); |
1008 | } | 1279 | } |
@@ -1012,28 +1283,27 @@ static u64 rtl_op_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) | |||
1012 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 1283 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
1013 | u64 tsf; | 1284 | u64 tsf; |
1014 | 1285 | ||
1015 | rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *) (&tsf)); | 1286 | rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *)(&tsf)); |
1016 | return tsf; | 1287 | return tsf; |
1017 | } | 1288 | } |
1018 | 1289 | ||
1019 | static void rtl_op_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | 1290 | static void rtl_op_set_tsf(struct ieee80211_hw *hw, |
1020 | u64 tsf) | 1291 | struct ieee80211_vif *vif, u64 tsf) |
1021 | { | 1292 | { |
1022 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 1293 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
1023 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | 1294 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
1024 | u8 bibss = (mac->opmode == NL80211_IFTYPE_ADHOC) ? 1 : 0; | 1295 | u8 bibss = (mac->opmode == NL80211_IFTYPE_ADHOC) ? 1 : 0; |
1025 | 1296 | ||
1026 | mac->tsf = tsf; | 1297 | mac->tsf = tsf; |
1027 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_CORRECT_TSF, &bibss); | 1298 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *)(&bibss)); |
1028 | } | 1299 | } |
1029 | 1300 | ||
1030 | static void rtl_op_reset_tsf(struct ieee80211_hw *hw, | 1301 | static void rtl_op_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
1031 | struct ieee80211_vif *vif) | ||
1032 | { | 1302 | { |
1033 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 1303 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
1034 | u8 tmp = 0; | 1304 | u8 tmp = 0; |
1035 | 1305 | ||
1036 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_DUAL_TSF_RST, &tmp); | 1306 | rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_DUAL_TSF_RST, (u8 *)(&tmp)); |
1037 | } | 1307 | } |
1038 | 1308 | ||
1039 | static void rtl_op_sta_notify(struct ieee80211_hw *hw, | 1309 | static void rtl_op_sta_notify(struct ieee80211_hw *hw, |
@@ -1063,13 +1333,13 @@ static int rtl_op_ampdu_action(struct ieee80211_hw *hw, | |||
1063 | case IEEE80211_AMPDU_TX_START: | 1333 | case IEEE80211_AMPDU_TX_START: |
1064 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, | 1334 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, |
1065 | "IEEE80211_AMPDU_TX_START: TID:%d\n", tid); | 1335 | "IEEE80211_AMPDU_TX_START: TID:%d\n", tid); |
1066 | return rtl_tx_agg_start(hw, sta, tid, ssn); | 1336 | return rtl_tx_agg_start(hw, vif, sta, tid, ssn); |
1067 | case IEEE80211_AMPDU_TX_STOP_CONT: | 1337 | case IEEE80211_AMPDU_TX_STOP_CONT: |
1068 | case IEEE80211_AMPDU_TX_STOP_FLUSH: | 1338 | case IEEE80211_AMPDU_TX_STOP_FLUSH: |
1069 | case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: | 1339 | case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: |
1070 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, | 1340 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, |
1071 | "IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid); | 1341 | "IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid); |
1072 | return rtl_tx_agg_stop(hw, sta, tid); | 1342 | return rtl_tx_agg_stop(hw, vif, sta, tid); |
1073 | case IEEE80211_AMPDU_TX_OPERATIONAL: | 1343 | case IEEE80211_AMPDU_TX_OPERATIONAL: |
1074 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, | 1344 | RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, |
1075 | "IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid); | 1345 | "IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid); |
@@ -1103,10 +1373,14 @@ static void rtl_op_sw_scan_start(struct ieee80211_hw *hw) | |||
1103 | return; | 1373 | return; |
1104 | } | 1374 | } |
1105 | 1375 | ||
1376 | if (rtlpriv->cfg->ops->get_btc_status()) | ||
1377 | rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 1); | ||
1378 | |||
1106 | if (rtlpriv->dm.supp_phymode_switch) { | 1379 | if (rtlpriv->dm.supp_phymode_switch) { |
1107 | if (rtlpriv->cfg->ops->chk_switch_dmdp) | 1380 | if (rtlpriv->cfg->ops->chk_switch_dmdp) |
1108 | rtlpriv->cfg->ops->chk_switch_dmdp(hw); | 1381 | rtlpriv->cfg->ops->chk_switch_dmdp(hw); |
1109 | } | 1382 | } |
1383 | |||
1110 | if (mac->link_state == MAC80211_LINKED) { | 1384 | if (mac->link_state == MAC80211_LINKED) { |
1111 | rtlpriv->enter_ps = false; | 1385 | rtlpriv->enter_ps = false; |
1112 | schedule_work(&rtlpriv->works.lps_change_work); | 1386 | schedule_work(&rtlpriv->works.lps_change_work); |
@@ -1115,11 +1389,11 @@ static void rtl_op_sw_scan_start(struct ieee80211_hw *hw) | |||
1115 | rtl_ips_nic_on(hw); | 1389 | rtl_ips_nic_on(hw); |
1116 | } | 1390 | } |
1117 | 1391 | ||
1118 | /* Dual mac */ | 1392 | /* Dul mac */ |
1119 | rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false; | 1393 | rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false; |
1120 | 1394 | ||
1121 | rtlpriv->cfg->ops->led_control(hw, LED_CTL_SITE_SURVEY); | 1395 | rtlpriv->cfg->ops->led_control(hw, LED_CTL_SITE_SURVEY); |
1122 | rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_BACKUP); | 1396 | rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_BACKUP_BAND0); |
1123 | } | 1397 | } |
1124 | 1398 | ||
1125 | static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw) | 1399 | static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw) |
@@ -1133,13 +1407,13 @@ static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw) | |||
1133 | if (rtlpriv->link_info.higher_busytraffic) | 1407 | if (rtlpriv->link_info.higher_busytraffic) |
1134 | return; | 1408 | return; |
1135 | 1409 | ||
1136 | /*p2p will use 1/6/11 to scan */ | 1410 | /* p2p will use 1/6/11 to scan */ |
1137 | if (mac->n_channels == 3) | 1411 | if (mac->n_channels == 3) |
1138 | mac->p2p_in_use = true; | 1412 | mac->p2p_in_use = true; |
1139 | else | 1413 | else |
1140 | mac->p2p_in_use = false; | 1414 | mac->p2p_in_use = false; |
1141 | mac->n_channels = 0; | 1415 | mac->n_channels = 0; |
1142 | /* Dual mac */ | 1416 | /* Dul mac */ |
1143 | rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false; | 1417 | rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false; |
1144 | 1418 | ||
1145 | if (mac->link_state == MAC80211_LINKED_SCANNING) { | 1419 | if (mac->link_state == MAC80211_LINKED_SCANNING) { |
@@ -1151,6 +1425,8 @@ static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw) | |||
1151 | } | 1425 | } |
1152 | 1426 | ||
1153 | rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_RESTORE); | 1427 | rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_RESTORE); |
1428 | if (rtlpriv->cfg->ops->get_btc_status()) | ||
1429 | rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 0); | ||
1154 | } | 1430 | } |
1155 | 1431 | ||
1156 | static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | 1432 | static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
@@ -1158,7 +1434,6 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
1158 | struct ieee80211_key_conf *key) | 1434 | struct ieee80211_key_conf *key) |
1159 | { | 1435 | { |
1160 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 1436 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
1161 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||
1162 | u8 key_type = NO_ENCRYPTION; | 1437 | u8 key_type = NO_ENCRYPTION; |
1163 | u8 key_idx; | 1438 | u8 key_idx; |
1164 | bool group_key = false; | 1439 | bool group_key = false; |
@@ -1174,13 +1449,13 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
1174 | } | 1449 | } |
1175 | /* To support IBSS, use sw-crypto for GTK */ | 1450 | /* To support IBSS, use sw-crypto for GTK */ |
1176 | if (((vif->type == NL80211_IFTYPE_ADHOC) || | 1451 | if (((vif->type == NL80211_IFTYPE_ADHOC) || |
1177 | (vif->type == NL80211_IFTYPE_MESH_POINT)) && | 1452 | (vif->type == NL80211_IFTYPE_MESH_POINT)) && |
1178 | !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) | 1453 | !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) |
1179 | return -ENOSPC; | 1454 | return -ENOSPC; |
1180 | RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, | 1455 | RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, |
1181 | "%s hardware based encryption for keyidx: %d, mac: %pM\n", | 1456 | "%s hardware based encryption for keyidx: %d, mac: %pM\n", |
1182 | cmd == SET_KEY ? "Using" : "Disabling", key->keyidx, | 1457 | cmd == SET_KEY ? "Using" : "Disabling", key->keyidx, |
1183 | sta ? sta->addr : bcast_addr); | 1458 | sta ? sta->addr : bcast_addr); |
1184 | rtlpriv->sec.being_setkey = true; | 1459 | rtlpriv->sec.being_setkey = true; |
1185 | rtl_ips_nic_on(hw); | 1460 | rtl_ips_nic_on(hw); |
1186 | mutex_lock(&rtlpriv->locks.conf_mutex); | 1461 | mutex_lock(&rtlpriv->locks.conf_mutex); |
@@ -1204,21 +1479,23 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
1204 | RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CCMP\n"); | 1479 | RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CCMP\n"); |
1205 | break; | 1480 | break; |
1206 | case WLAN_CIPHER_SUITE_AES_CMAC: | 1481 | case WLAN_CIPHER_SUITE_AES_CMAC: |
1207 | /*HW doesn't support CMAC encryption, use software CMAC */ | 1482 | /* HW don't support CMAC encryption, |
1483 | * use software CMAC encryption | ||
1484 | */ | ||
1208 | key_type = AESCMAC_ENCRYPTION; | 1485 | key_type = AESCMAC_ENCRYPTION; |
1209 | RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CMAC\n"); | 1486 | RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CMAC\n"); |
1210 | RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, | 1487 | RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, |
1211 | "HW don't support CMAC encryption, use software CMAC\n"); | 1488 | "HW don't support CMAC encrypiton, use software CMAC encrypiton\n"); |
1212 | err = -EOPNOTSUPP; | 1489 | err = -EOPNOTSUPP; |
1213 | goto out_unlock; | 1490 | goto out_unlock; |
1214 | default: | 1491 | default: |
1215 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "alg_err:%x!!!!\n", | 1492 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, |
1216 | key->cipher); | 1493 | "alg_err:%x!!!!:\n", key->cipher); |
1217 | goto out_unlock; | 1494 | goto out_unlock; |
1218 | } | 1495 | } |
1219 | if (key_type == WEP40_ENCRYPTION || | 1496 | if (key_type == WEP40_ENCRYPTION || |
1220 | key_type == WEP104_ENCRYPTION || | 1497 | key_type == WEP104_ENCRYPTION || |
1221 | mac->opmode == NL80211_IFTYPE_ADHOC) | 1498 | vif->type == NL80211_IFTYPE_ADHOC) |
1222 | rtlpriv->sec.use_defaultkey = true; | 1499 | rtlpriv->sec.use_defaultkey = true; |
1223 | 1500 | ||
1224 | /* <2> get key_idx */ | 1501 | /* <2> get key_idx */ |
@@ -1232,14 +1509,14 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
1232 | * 1) wep only: is just for wep enc, in this condition | 1509 | * 1) wep only: is just for wep enc, in this condition |
1233 | * rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION | 1510 | * rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION |
1234 | * will be true & enable_hw_sec will be set when wep | 1511 | * will be true & enable_hw_sec will be set when wep |
1235 | * key setting. | 1512 | * ke setting. |
1236 | * 2) wep(group) + AES(pairwise): some AP like cisco | 1513 | * 2) wep(group) + AES(pairwise): some AP like cisco |
1237 | * may use it, in this condition enable_hw_sec will not | 1514 | * may use it, in this condition enable_hw_sec will not |
1238 | * be set when wep key setting */ | 1515 | * be set when wep key setting */ |
1239 | /* we must reset sec_info after lingked before set key, | 1516 | /* we must reset sec_info after lingked before set key, |
1240 | * or some flag will be wrong*/ | 1517 | * or some flag will be wrong*/ |
1241 | if (vif->type == NL80211_IFTYPE_AP || | 1518 | if (vif->type == NL80211_IFTYPE_AP || |
1242 | vif->type == NL80211_IFTYPE_MESH_POINT) { | 1519 | vif->type == NL80211_IFTYPE_MESH_POINT) { |
1243 | if (!group_key || key_type == WEP40_ENCRYPTION || | 1520 | if (!group_key || key_type == WEP40_ENCRYPTION || |
1244 | key_type == WEP104_ENCRYPTION) { | 1521 | key_type == WEP104_ENCRYPTION) { |
1245 | if (group_key) | 1522 | if (group_key) |
@@ -1247,11 +1524,11 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
1247 | rtlpriv->cfg->ops->enable_hw_sec(hw); | 1524 | rtlpriv->cfg->ops->enable_hw_sec(hw); |
1248 | } | 1525 | } |
1249 | } else { | 1526 | } else { |
1250 | if ((!group_key) || (mac->opmode == NL80211_IFTYPE_ADHOC) || | 1527 | if ((!group_key) || (vif->type == NL80211_IFTYPE_ADHOC) || |
1251 | rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION) { | 1528 | rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION) { |
1252 | if (rtlpriv->sec.pairwise_enc_algorithm == | 1529 | if (rtlpriv->sec.pairwise_enc_algorithm == |
1253 | NO_ENCRYPTION && | 1530 | NO_ENCRYPTION && |
1254 | (key_type == WEP40_ENCRYPTION || | 1531 | (key_type == WEP40_ENCRYPTION || |
1255 | key_type == WEP104_ENCRYPTION)) | 1532 | key_type == WEP104_ENCRYPTION)) |
1256 | wep_only = true; | 1533 | wep_only = true; |
1257 | rtlpriv->sec.pairwise_enc_algorithm = key_type; | 1534 | rtlpriv->sec.pairwise_enc_algorithm = key_type; |
@@ -1323,7 +1600,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
1323 | "disable key delete one entry\n"); | 1600 | "disable key delete one entry\n"); |
1324 | /*set local buf about wep key. */ | 1601 | /*set local buf about wep key. */ |
1325 | if (vif->type == NL80211_IFTYPE_AP || | 1602 | if (vif->type == NL80211_IFTYPE_AP || |
1326 | vif->type == NL80211_IFTYPE_MESH_POINT) { | 1603 | vif->type == NL80211_IFTYPE_MESH_POINT) { |
1327 | if (sta) | 1604 | if (sta) |
1328 | rtl_cam_del_entry(hw, sta->addr); | 1605 | rtl_cam_del_entry(hw, sta->addr); |
1329 | } | 1606 | } |
@@ -1336,13 +1613,10 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
1336 | *or clear all entry here. | 1613 | *or clear all entry here. |
1337 | */ | 1614 | */ |
1338 | rtl_cam_delete_one_entry(hw, mac_addr, key_idx); | 1615 | rtl_cam_delete_one_entry(hw, mac_addr, key_idx); |
1339 | |||
1340 | rtl_cam_reset_sec_info(hw); | ||
1341 | |||
1342 | break; | 1616 | break; |
1343 | default: | 1617 | default: |
1344 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | 1618 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, |
1345 | "cmd_err:%x!!!!\n", cmd); | 1619 | "cmd_err:%x!!!!:\n", cmd); |
1346 | } | 1620 | } |
1347 | out_unlock: | 1621 | out_unlock: |
1348 | mutex_unlock(&rtlpriv->locks.conf_mutex); | 1622 | mutex_unlock(&rtlpriv->locks.conf_mutex); |
@@ -1372,7 +1646,7 @@ static void rtl_op_rfkill_poll(struct ieee80211_hw *hw) | |||
1372 | 1646 | ||
1373 | RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, | 1647 | RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, |
1374 | "wireless radio switch turned %s\n", | 1648 | "wireless radio switch turned %s\n", |
1375 | radio_state ? "on" : "off"); | 1649 | radio_state ? "on" : "off"); |
1376 | 1650 | ||
1377 | blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1; | 1651 | blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1; |
1378 | wiphy_rfkill_set_hw_state(hw->wiphy, blocked); | 1652 | wiphy_rfkill_set_hw_state(hw->wiphy, blocked); |
@@ -1383,18 +1657,148 @@ static void rtl_op_rfkill_poll(struct ieee80211_hw *hw) | |||
1383 | } | 1657 | } |
1384 | 1658 | ||
1385 | /* this function is called by mac80211 to flush tx buffer | 1659 | /* this function is called by mac80211 to flush tx buffer |
1386 | * before switch channel or power save, or tx buffer packet | 1660 | * before switch channle or power save, or tx buffer packet |
1387 | * maybe send after offchannel or rf sleep, this may cause | 1661 | * maybe send after offchannel or rf sleep, this may cause |
1388 | * dis-association by AP */ | 1662 | * dis-association by AP */ |
1389 | static void rtl_op_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | 1663 | static void rtl_op_flush(struct ieee80211_hw *hw, |
1390 | u32 queues, bool drop) | 1664 | struct ieee80211_vif *vif, |
1665 | u32 queues, | ||
1666 | bool drop) | ||
1391 | { | 1667 | { |
1392 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 1668 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
1393 | 1669 | ||
1394 | if (rtlpriv->intf_ops->flush) | 1670 | if (rtlpriv->intf_ops->flush) |
1395 | rtlpriv->intf_ops->flush(hw, drop); | 1671 | rtlpriv->intf_ops->flush(hw, queues, drop); |
1396 | } | 1672 | } |
1397 | 1673 | ||
1674 | /* Description: | ||
1675 | * This routine deals with the Power Configuration CMD | ||
1676 | * parsing for RTL8723/RTL8188E Series IC. | ||
1677 | * Assumption: | ||
1678 | * We should follow specific format that was released from HW SD. | ||
1679 | */ | ||
1680 | bool rtl_hal_pwrseqcmdparsing(struct rtl_priv *rtlpriv, u8 cut_version, | ||
1681 | u8 faversion, u8 interface_type, | ||
1682 | struct wlan_pwr_cfg pwrcfgcmd[]) | ||
1683 | { | ||
1684 | struct wlan_pwr_cfg cfg_cmd = {0}; | ||
1685 | bool polling_bit = false; | ||
1686 | u32 ary_idx = 0; | ||
1687 | u8 value = 0; | ||
1688 | u32 offset = 0; | ||
1689 | u32 polling_count = 0; | ||
1690 | u32 max_polling_cnt = 5000; | ||
1691 | |||
1692 | do { | ||
1693 | cfg_cmd = pwrcfgcmd[ary_idx]; | ||
1694 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
1695 | "rtl_hal_pwrseqcmdparsing(): offset(%#x),cut_msk(%#x), famsk(%#x), interface_msk(%#x), base(%#x), cmd(%#x), msk(%#x), value(%#x)\n", | ||
1696 | GET_PWR_CFG_OFFSET(cfg_cmd), | ||
1697 | GET_PWR_CFG_CUT_MASK(cfg_cmd), | ||
1698 | GET_PWR_CFG_FAB_MASK(cfg_cmd), | ||
1699 | GET_PWR_CFG_INTF_MASK(cfg_cmd), | ||
1700 | GET_PWR_CFG_BASE(cfg_cmd), GET_PWR_CFG_CMD(cfg_cmd), | ||
1701 | GET_PWR_CFG_MASK(cfg_cmd), GET_PWR_CFG_VALUE(cfg_cmd)); | ||
1702 | |||
1703 | if ((GET_PWR_CFG_FAB_MASK(cfg_cmd)&faversion) && | ||
1704 | (GET_PWR_CFG_CUT_MASK(cfg_cmd)&cut_version) && | ||
1705 | (GET_PWR_CFG_INTF_MASK(cfg_cmd)&interface_type)) { | ||
1706 | switch (GET_PWR_CFG_CMD(cfg_cmd)) { | ||
1707 | case PWR_CMD_READ: | ||
1708 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
1709 | "rtl_hal_pwrseqcmdparsing(): PWR_CMD_READ\n"); | ||
1710 | break; | ||
1711 | case PWR_CMD_WRITE: | ||
1712 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
1713 | "rtl_hal_pwrseqcmdparsing(): PWR_CMD_WRITE\n"); | ||
1714 | offset = GET_PWR_CFG_OFFSET(cfg_cmd); | ||
1715 | |||
1716 | /*Read the value from system register*/ | ||
1717 | value = rtl_read_byte(rtlpriv, offset); | ||
1718 | value &= (~(GET_PWR_CFG_MASK(cfg_cmd))); | ||
1719 | value |= (GET_PWR_CFG_VALUE(cfg_cmd) & | ||
1720 | GET_PWR_CFG_MASK(cfg_cmd)); | ||
1721 | |||
1722 | /*Write the value back to sytem register*/ | ||
1723 | rtl_write_byte(rtlpriv, offset, value); | ||
1724 | break; | ||
1725 | case PWR_CMD_POLLING: | ||
1726 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
1727 | "rtl_hal_pwrseqcmdparsing(): PWR_CMD_POLLING\n"); | ||
1728 | polling_bit = false; | ||
1729 | offset = GET_PWR_CFG_OFFSET(cfg_cmd); | ||
1730 | |||
1731 | do { | ||
1732 | value = rtl_read_byte(rtlpriv, offset); | ||
1733 | |||
1734 | value &= GET_PWR_CFG_MASK(cfg_cmd); | ||
1735 | if (value == | ||
1736 | (GET_PWR_CFG_VALUE(cfg_cmd) & | ||
1737 | GET_PWR_CFG_MASK(cfg_cmd))) | ||
1738 | polling_bit = true; | ||
1739 | else | ||
1740 | udelay(10); | ||
1741 | |||
1742 | if (polling_count++ > max_polling_cnt) | ||
1743 | return false; | ||
1744 | } while (!polling_bit); | ||
1745 | break; | ||
1746 | case PWR_CMD_DELAY: | ||
1747 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
1748 | "rtl_hal_pwrseqcmdparsing(): PWR_CMD_DELAY\n"); | ||
1749 | if (GET_PWR_CFG_VALUE(cfg_cmd) == | ||
1750 | PWRSEQ_DELAY_US) | ||
1751 | udelay(GET_PWR_CFG_OFFSET(cfg_cmd)); | ||
1752 | else | ||
1753 | mdelay(GET_PWR_CFG_OFFSET(cfg_cmd)); | ||
1754 | break; | ||
1755 | case PWR_CMD_END: | ||
1756 | RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||
1757 | "rtl_hal_pwrseqcmdparsing(): PWR_CMD_END\n"); | ||
1758 | return true; | ||
1759 | default: | ||
1760 | RT_ASSERT(false, | ||
1761 | "rtl_hal_pwrseqcmdparsing(): Unknown CMD!!\n"); | ||
1762 | break; | ||
1763 | } | ||
1764 | } | ||
1765 | ary_idx++; | ||
1766 | } while (1); | ||
1767 | |||
1768 | return true; | ||
1769 | } | ||
1770 | EXPORT_SYMBOL(rtl_hal_pwrseqcmdparsing); | ||
1771 | |||
1772 | bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb) | ||
1773 | { | ||
1774 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
1775 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | ||
1776 | struct rtl8192_tx_ring *ring; | ||
1777 | struct rtl_tx_desc *pdesc; | ||
1778 | unsigned long flags; | ||
1779 | struct sk_buff *pskb = NULL; | ||
1780 | |||
1781 | ring = &rtlpci->tx_ring[BEACON_QUEUE]; | ||
1782 | |||
1783 | spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); | ||
1784 | pskb = __skb_dequeue(&ring->queue); | ||
1785 | if (pskb) | ||
1786 | kfree_skb(pskb); | ||
1787 | |||
1788 | /*this is wrong, fill_tx_cmddesc needs update*/ | ||
1789 | pdesc = &ring->desc[0]; | ||
1790 | |||
1791 | rtlpriv->cfg->ops->fill_tx_cmddesc(hw, (u8 *)pdesc, 1, 1, skb); | ||
1792 | |||
1793 | __skb_queue_tail(&ring->queue, skb); | ||
1794 | |||
1795 | spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); | ||
1796 | |||
1797 | rtlpriv->cfg->ops->tx_polling(hw, BEACON_QUEUE); | ||
1798 | |||
1799 | return true; | ||
1800 | } | ||
1801 | EXPORT_SYMBOL(rtl_cmd_send_packet); | ||
1398 | const struct ieee80211_ops rtl_ops = { | 1802 | const struct ieee80211_ops rtl_ops = { |
1399 | .start = rtl_op_start, | 1803 | .start = rtl_op_start, |
1400 | .stop = rtl_op_stop, | 1804 | .stop = rtl_op_stop, |
@@ -1402,10 +1806,12 @@ const struct ieee80211_ops rtl_ops = { | |||
1402 | .add_interface = rtl_op_add_interface, | 1806 | .add_interface = rtl_op_add_interface, |
1403 | .remove_interface = rtl_op_remove_interface, | 1807 | .remove_interface = rtl_op_remove_interface, |
1404 | .change_interface = rtl_op_change_interface, | 1808 | .change_interface = rtl_op_change_interface, |
1809 | #ifdef CONFIG_PM | ||
1810 | .suspend = rtl_op_suspend, | ||
1811 | .resume = rtl_op_resume, | ||
1812 | #endif | ||
1405 | .config = rtl_op_config, | 1813 | .config = rtl_op_config, |
1406 | .configure_filter = rtl_op_configure_filter, | 1814 | .configure_filter = rtl_op_configure_filter, |
1407 | .sta_add = rtl_op_sta_add, | ||
1408 | .sta_remove = rtl_op_sta_remove, | ||
1409 | .set_key = rtl_op_set_key, | 1815 | .set_key = rtl_op_set_key, |
1410 | .conf_tx = rtl_op_conf_tx, | 1816 | .conf_tx = rtl_op_conf_tx, |
1411 | .bss_info_changed = rtl_op_bss_info_changed, | 1817 | .bss_info_changed = rtl_op_bss_info_changed, |
@@ -1417,6 +1823,8 @@ const struct ieee80211_ops rtl_ops = { | |||
1417 | .sw_scan_start = rtl_op_sw_scan_start, | 1823 | .sw_scan_start = rtl_op_sw_scan_start, |
1418 | .sw_scan_complete = rtl_op_sw_scan_complete, | 1824 | .sw_scan_complete = rtl_op_sw_scan_complete, |
1419 | .rfkill_poll = rtl_op_rfkill_poll, | 1825 | .rfkill_poll = rtl_op_rfkill_poll, |
1826 | .sta_add = rtl_op_sta_add, | ||
1827 | .sta_remove = rtl_op_sta_remove, | ||
1420 | .flush = rtl_op_flush, | 1828 | .flush = rtl_op_flush, |
1421 | }; | 1829 | }; |
1422 | EXPORT_SYMBOL_GPL(rtl_ops); | 1830 | EXPORT_SYMBOL_GPL(rtl_ops); |