Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-davem' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next

John W. Linville says:

====================
Please pull this batch of updates for the 3.14 stream!

For the mac80211 bits, Johannes says:

"This time I have uAPSD fixes since I was working on that, hwsim
improvements to make dynamic radios possible for the test suite, the
evidently long-overdue channel_change_time removal and a few other small
collected fix and improvements."

For the iwlwifi bits, Emmanuel says:

"Besides a few trivial patches, I have an important workaround for a HW
issue that has kept me busy for a long time. Along with it, a fix that
prevents an error from being printed.
Eyal fixes our behavior against SISO APs and Ilan fixes an issue with
multiple interface scenarios.
Eliad fixes an error path in our init flow.
We also have a few 'static analyzers' fix."

For the NFC bits, Samuel says:

"It includes:

* A new NFC driver for Marvell's 8897, and a few NCI fixes and
improvements needed to support this chipset.

* An LLCP fix for how we were setting the default MIU on a p2p link. If
there is no explicit MIU extension announced at connection time, we
must use the default one and not the one announced at LLCP link
establishement time.

* A pn544 EEPROM config update. Some of the currently EEPROM configured
values are overwriting the firmware ones while other should not be set
by the driver itself.

* Some NFC digital stack fixes and improvements. Asynchronous functions
are better documented, RF technologies and CRC functions are set upon
PSL_REQ reception, and a few minor bugs are fixed.

* Minor and miscelaneous pn533, mei_phy and port100 fixes."

For the ath bits, Kalle says:

"Janusz added Kconfig option for DFS. The DFS code was there already, but
after fixes to mac80211 we can now enable it.

Bartosz added a runtime firmware feature flag to disable P2P. Our 10.1
firmware branch doesn't support P2P and ath10k can now disable that. He
also added a limit for how many clients can connect to ath10k AP.

Michal fixed WEP shared authentication, in case someone still uses it.
And I added firmware debug log to help the firmware engineers."

Along with that is a small batch of ath9k updates and a few other bits
here and there.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+3817 -1803
-1
drivers/net/wireless/adm8211.c
··· 1865 1865 dev->flags = IEEE80211_HW_SIGNAL_UNSPEC; 1866 1866 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); 1867 1867 1868 - dev->channel_change_time = 1000; 1869 1868 dev->max_signal = 100; /* FIXME: find better value */ 1870 1869 1871 1870 dev->queues = 1; /* ADM8211C supports more, maybe ADM8211B too */
-1
drivers/net/wireless/at76c50x-usb.c
··· 2112 2112 priv->pm_period = 0; 2113 2113 2114 2114 /* unit us */ 2115 - priv->hw->channel_change_time = 100000; 2116 2115 2117 2116 return priv; 2118 2117 }
+2
drivers/net/wireless/ath/ath.h
··· 17 17 #ifndef ATH_H 18 18 #define ATH_H 19 19 20 + #include <linux/etherdevice.h> 20 21 #include <linux/skbuff.h> 21 22 #include <linux/if_ether.h> 22 23 #include <linux/spinlock.h> ··· 166 165 struct sk_buff *ath_rxbuf_alloc(struct ath_common *common, 167 166 u32 len, 168 167 gfp_t gfp_mask); 168 + bool ath_is_mybeacon(struct ath_common *common, struct ieee80211_hdr *hdr); 169 169 170 170 void ath_hw_setbssidmask(struct ath_common *common); 171 171 void ath_key_delete(struct ath_common *common, struct ieee80211_key_conf *key);
+7
drivers/net/wireless/ath/ath10k/Kconfig
··· 37 37 ---help--- 38 38 Select this to ath10k use tracing infrastructure. 39 39 40 + config ATH10K_DFS_CERTIFIED 41 + bool "Atheros DFS support for certified platforms" 42 + depends on ATH10K && CFG80211_CERTIFICATION_ONUS 43 + default n 44 + ---help--- 45 + This option enables DFS support for initiating radiation on 46 + ath10k.
+11
drivers/net/wireless/ath/ath10k/core.h
··· 253 253 u8 bssid[ETH_ALEN]; 254 254 } ibss; 255 255 } u; 256 + 257 + u8 fixed_rate; 258 + u8 fixed_nss; 256 259 }; 257 260 258 261 struct ath10k_vif_iter { ··· 275 272 struct delayed_work htt_stats_dwork; 276 273 struct ath10k_dfs_stats dfs_stats; 277 274 struct ath_dfs_pool_stats dfs_pool_stats; 275 + 276 + u32 fw_dbglog_mask; 278 277 }; 279 278 280 279 enum ath10k_state { ··· 310 305 311 306 /* firmware support tx frame management over WMI, otherwise it's HTT */ 312 307 ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX = 2, 308 + 309 + /* Firmware does not support P2P */ 310 + ATH10K_FW_FEATURE_NO_P2P = 3, 313 311 314 312 /* keep last */ 315 313 ATH10K_FW_FEATURE_COUNT, ··· 436 428 struct list_head arvifs; 437 429 struct list_head peers; 438 430 wait_queue_head_t peer_mapping_wq; 431 + 432 + /* number of created peers; protected by data_lock */ 433 + int num_peers; 439 434 440 435 struct work_struct offchan_tx_work; 441 436 struct sk_buff_head offchan_tx_queue;
+66
drivers/net/wireless/ath/ath10k/debug.c
··· 614 614 .llseek = default_llseek, 615 615 }; 616 616 617 + static ssize_t ath10k_read_fw_dbglog(struct file *file, 618 + char __user *user_buf, 619 + size_t count, loff_t *ppos) 620 + { 621 + struct ath10k *ar = file->private_data; 622 + unsigned int len; 623 + char buf[32]; 624 + 625 + len = scnprintf(buf, sizeof(buf), "0x%08x\n", 626 + ar->debug.fw_dbglog_mask); 627 + 628 + return simple_read_from_buffer(user_buf, count, ppos, buf, len); 629 + } 630 + 631 + static ssize_t ath10k_write_fw_dbglog(struct file *file, 632 + const char __user *user_buf, 633 + size_t count, loff_t *ppos) 634 + { 635 + struct ath10k *ar = file->private_data; 636 + unsigned long mask; 637 + int ret; 638 + 639 + ret = kstrtoul_from_user(user_buf, count, 0, &mask); 640 + if (ret) 641 + return ret; 642 + 643 + mutex_lock(&ar->conf_mutex); 644 + 645 + ar->debug.fw_dbglog_mask = mask; 646 + 647 + if (ar->state == ATH10K_STATE_ON) { 648 + ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask); 649 + if (ret) { 650 + ath10k_warn("dbglog cfg failed from debugfs: %d\n", 651 + ret); 652 + goto exit; 653 + } 654 + } 655 + 656 + ret = count; 657 + 658 + exit: 659 + mutex_unlock(&ar->conf_mutex); 660 + 661 + return ret; 662 + } 663 + 664 + static const struct file_operations fops_fw_dbglog = { 665 + .read = ath10k_read_fw_dbglog, 666 + .write = ath10k_write_fw_dbglog, 667 + .open = simple_open, 668 + .owner = THIS_MODULE, 669 + .llseek = default_llseek, 670 + }; 671 + 617 672 int ath10k_debug_start(struct ath10k *ar) 618 673 { 619 674 int ret; ··· 679 624 if (ret) 680 625 /* continue normally anyway, this isn't serious */ 681 626 ath10k_warn("failed to start htt stats workqueue: %d\n", ret); 627 + 628 + if (ar->debug.fw_dbglog_mask) { 629 + ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask); 630 + if (ret) 631 + /* not serious */ 632 + ath10k_warn("failed to enable dbglog during start: %d", 633 + ret); 634 + } 682 635 683 636 return 0; 684 637 } ··· 809 746 810 747 debugfs_create_file("htt_stats_mask", S_IRUSR, ar->debug.debugfs_phy, 811 748 ar, &fops_htt_stats_mask); 749 + 750 + debugfs_create_file("fw_dbglog", S_IRUSR, ar->debug.debugfs_phy, 751 + ar, &fops_fw_dbglog); 812 752 813 753 if (config_enabled(CONFIG_ATH10K_DFS_CERTIFIED)) { 814 754 debugfs_create_file("dfs_simulate_radar", S_IWUSR,
+1
drivers/net/wireless/ath/ath10k/htt.h
··· 1183 1183 } rate; 1184 1184 bool fcs_err; 1185 1185 bool amsdu_more; 1186 + bool mic_err; 1186 1187 }; 1187 1188 1188 1189 struct ath10k_htt {
+15
drivers/net/wireless/ath/ath10k/htt_rx.c
··· 838 838 return false; 839 839 } 840 840 841 + static bool ath10k_htt_rx_has_mic_err(struct sk_buff *skb) 842 + { 843 + struct htt_rx_desc *rxd; 844 + u32 flags; 845 + 846 + rxd = (void *)skb->data - sizeof(*rxd); 847 + flags = __le32_to_cpu(rxd->attention.flags); 848 + 849 + if (flags & RX_ATTENTION_FLAGS_TKIP_MIC_ERR) 850 + return true; 851 + 852 + return false; 853 + } 854 + 841 855 static int ath10k_htt_rx_get_csum_state(struct sk_buff *skb) 842 856 { 843 857 struct htt_rx_desc *rxd; ··· 974 960 975 961 info.skb = msdu_head; 976 962 info.fcs_err = ath10k_htt_rx_has_fcs_err(msdu_head); 963 + info.mic_err = ath10k_htt_rx_has_mic_err(msdu_head); 977 964 info.signal = ATH10K_DEFAULT_NOISE_FLOOR; 978 965 info.signal += rx->ppdu.combined_rssi; 979 966
+1
drivers/net/wireless/ath/ath10k/hw.h
··· 115 115 #define TARGET_10X_MAC_AGGR_DELIM 0 116 116 #define TARGET_10X_AST_SKID_LIMIT 16 117 117 #define TARGET_10X_NUM_PEERS (128 + (TARGET_10X_NUM_VDEVS)) 118 + #define TARGET_10X_NUM_PEERS_MAX 128 118 119 #define TARGET_10X_NUM_OFFLOAD_PEERS 0 119 120 #define TARGET_10X_NUM_OFFLOAD_REORDER_BUFS 0 120 121 #define TARGET_10X_NUM_PEER_KEYS 2
+358 -17
drivers/net/wireless/ath/ath10k/mac.c
··· 332 332 ath10k_warn("Failed to wait for created wmi peer: %i\n", ret); 333 333 return ret; 334 334 } 335 + spin_lock_bh(&ar->data_lock); 336 + ar->num_peers++; 337 + spin_unlock_bh(&ar->data_lock); 335 338 336 339 return 0; 337 340 } ··· 380 377 if (ret) 381 378 return ret; 382 379 380 + spin_lock_bh(&ar->data_lock); 381 + ar->num_peers--; 382 + spin_unlock_bh(&ar->data_lock); 383 + 383 384 return 0; 384 385 } 385 386 ··· 403 396 404 397 list_del(&peer->list); 405 398 kfree(peer); 399 + ar->num_peers--; 406 400 } 407 401 spin_unlock_bh(&ar->data_lock); 408 402 } ··· 419 411 list_del(&peer->list); 420 412 kfree(peer); 421 413 } 414 + ar->num_peers = 0; 422 415 spin_unlock_bh(&ar->data_lock); 423 416 } 424 417 ··· 2214 2205 struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif); 2215 2206 enum wmi_sta_powersave_param param; 2216 2207 int ret = 0; 2217 - u32 value; 2208 + u32 value, param_id; 2218 2209 int bit; 2219 2210 u32 vdev_param; 2220 2211 ··· 2306 2297 ath10k_warn("Failed to create peer for AP: %d\n", ret); 2307 2298 goto err_vdev_delete; 2308 2299 } 2300 + 2301 + param_id = ar->wmi.pdev_param->sta_kickout_th; 2302 + 2303 + /* Disable STA KICKOUT functionality in FW */ 2304 + ret = ath10k_wmi_pdev_set_param(ar, param_id, 0); 2305 + if (ret) 2306 + ath10k_warn("Failed to disable STA KICKOUT\n"); 2309 2307 } 2310 2308 2311 2309 if (arvif->vdev_type == WMI_VDEV_TYPE_STA) { ··· 2858 2842 { 2859 2843 struct ath10k *ar = hw->priv; 2860 2844 struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif); 2845 + int max_num_peers; 2861 2846 int ret = 0; 2862 2847 2863 2848 mutex_lock(&ar->conf_mutex); ··· 2869 2852 /* 2870 2853 * New station addition. 2871 2854 */ 2855 + if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) 2856 + max_num_peers = TARGET_10X_NUM_PEERS_MAX - 1; 2857 + else 2858 + max_num_peers = TARGET_NUM_PEERS; 2859 + 2860 + if (ar->num_peers >= max_num_peers) { 2861 + ath10k_warn("Number of peers exceeded: peers number %d (max peers %d)\n", 2862 + ar->num_peers, max_num_peers); 2863 + ret = -ENOBUFS; 2864 + goto exit; 2865 + } 2866 + 2872 2867 ath10k_dbg(ATH10K_DBG_MAC, 2873 - "mac vdev %d peer create %pM (new sta)\n", 2874 - arvif->vdev_id, sta->addr); 2868 + "mac vdev %d peer create %pM (new sta) num_peers %d\n", 2869 + arvif->vdev_id, sta->addr, ar->num_peers); 2875 2870 2876 2871 ret = ath10k_peer_create(ar, arvif->vdev_id, sta->addr); 2877 2872 if (ret) ··· 2933 2904 ath10k_warn("Failed to disassociate station: %pM\n", 2934 2905 sta->addr); 2935 2906 } 2936 - 2907 + exit: 2937 2908 mutex_unlock(&ar->conf_mutex); 2938 2909 return ret; 2939 2910 } ··· 3339 3310 return ret; 3340 3311 } 3341 3312 3313 + /* Helper table for legacy fixed_rate/bitrate_mask */ 3314 + static const u8 cck_ofdm_rate[] = { 3315 + /* CCK */ 3316 + 3, /* 1Mbps */ 3317 + 2, /* 2Mbps */ 3318 + 1, /* 5.5Mbps */ 3319 + 0, /* 11Mbps */ 3320 + /* OFDM */ 3321 + 3, /* 6Mbps */ 3322 + 7, /* 9Mbps */ 3323 + 2, /* 12Mbps */ 3324 + 6, /* 18Mbps */ 3325 + 1, /* 24Mbps */ 3326 + 5, /* 36Mbps */ 3327 + 0, /* 48Mbps */ 3328 + 4, /* 54Mbps */ 3329 + }; 3330 + 3331 + /* Check if only one bit set */ 3332 + static int ath10k_check_single_mask(u32 mask) 3333 + { 3334 + int bit; 3335 + 3336 + bit = ffs(mask); 3337 + if (!bit) 3338 + return 0; 3339 + 3340 + mask &= ~BIT(bit - 1); 3341 + if (mask) 3342 + return 2; 3343 + 3344 + return 1; 3345 + } 3346 + 3347 + static bool 3348 + ath10k_default_bitrate_mask(struct ath10k *ar, 3349 + enum ieee80211_band band, 3350 + const struct cfg80211_bitrate_mask *mask) 3351 + { 3352 + u32 legacy = 0x00ff; 3353 + u8 ht = 0xff, i; 3354 + u16 vht = 0x3ff; 3355 + 3356 + switch (band) { 3357 + case IEEE80211_BAND_2GHZ: 3358 + legacy = 0x00fff; 3359 + vht = 0; 3360 + break; 3361 + case IEEE80211_BAND_5GHZ: 3362 + break; 3363 + default: 3364 + return false; 3365 + } 3366 + 3367 + if (mask->control[band].legacy != legacy) 3368 + return false; 3369 + 3370 + for (i = 0; i < ar->num_rf_chains; i++) 3371 + if (mask->control[band].ht_mcs[i] != ht) 3372 + return false; 3373 + 3374 + for (i = 0; i < ar->num_rf_chains; i++) 3375 + if (mask->control[band].vht_mcs[i] != vht) 3376 + return false; 3377 + 3378 + return true; 3379 + } 3380 + 3381 + static bool 3382 + ath10k_bitrate_mask_nss(const struct cfg80211_bitrate_mask *mask, 3383 + enum ieee80211_band band, 3384 + u8 *fixed_nss) 3385 + { 3386 + int ht_nss = 0, vht_nss = 0, i; 3387 + 3388 + /* check legacy */ 3389 + if (ath10k_check_single_mask(mask->control[band].legacy)) 3390 + return false; 3391 + 3392 + /* check HT */ 3393 + for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) { 3394 + if (mask->control[band].ht_mcs[i] == 0xff) 3395 + continue; 3396 + else if (mask->control[band].ht_mcs[i] == 0x00) 3397 + break; 3398 + else 3399 + return false; 3400 + } 3401 + 3402 + ht_nss = i; 3403 + 3404 + /* check VHT */ 3405 + for (i = 0; i < NL80211_VHT_NSS_MAX; i++) { 3406 + if (mask->control[band].vht_mcs[i] == 0x03ff) 3407 + continue; 3408 + else if (mask->control[band].vht_mcs[i] == 0x0000) 3409 + break; 3410 + else 3411 + return false; 3412 + } 3413 + 3414 + vht_nss = i; 3415 + 3416 + if (ht_nss > 0 && vht_nss > 0) 3417 + return false; 3418 + 3419 + if (ht_nss) 3420 + *fixed_nss = ht_nss; 3421 + else if (vht_nss) 3422 + *fixed_nss = vht_nss; 3423 + else 3424 + return false; 3425 + 3426 + return true; 3427 + } 3428 + 3429 + static bool 3430 + ath10k_bitrate_mask_correct(const struct cfg80211_bitrate_mask *mask, 3431 + enum ieee80211_band band, 3432 + enum wmi_rate_preamble *preamble) 3433 + { 3434 + int legacy = 0, ht = 0, vht = 0, i; 3435 + 3436 + *preamble = WMI_RATE_PREAMBLE_OFDM; 3437 + 3438 + /* check legacy */ 3439 + legacy = ath10k_check_single_mask(mask->control[band].legacy); 3440 + if (legacy > 1) 3441 + return false; 3442 + 3443 + /* check HT */ 3444 + for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) 3445 + ht += ath10k_check_single_mask(mask->control[band].ht_mcs[i]); 3446 + if (ht > 1) 3447 + return false; 3448 + 3449 + /* check VHT */ 3450 + for (i = 0; i < NL80211_VHT_NSS_MAX; i++) 3451 + vht += ath10k_check_single_mask(mask->control[band].vht_mcs[i]); 3452 + if (vht > 1) 3453 + return false; 3454 + 3455 + /* Currently we support only one fixed_rate */ 3456 + if ((legacy + ht + vht) != 1) 3457 + return false; 3458 + 3459 + if (ht) 3460 + *preamble = WMI_RATE_PREAMBLE_HT; 3461 + else if (vht) 3462 + *preamble = WMI_RATE_PREAMBLE_VHT; 3463 + 3464 + return true; 3465 + } 3466 + 3467 + static bool 3468 + ath10k_bitrate_mask_rate(const struct cfg80211_bitrate_mask *mask, 3469 + enum ieee80211_band band, 3470 + u8 *fixed_rate, 3471 + u8 *fixed_nss) 3472 + { 3473 + u8 rate = 0, pream = 0, nss = 0, i; 3474 + enum wmi_rate_preamble preamble; 3475 + 3476 + /* Check if single rate correct */ 3477 + if (!ath10k_bitrate_mask_correct(mask, band, &preamble)) 3478 + return false; 3479 + 3480 + pream = preamble; 3481 + 3482 + switch (preamble) { 3483 + case WMI_RATE_PREAMBLE_CCK: 3484 + case WMI_RATE_PREAMBLE_OFDM: 3485 + i = ffs(mask->control[band].legacy) - 1; 3486 + 3487 + if (band == IEEE80211_BAND_2GHZ && i < 4) 3488 + pream = WMI_RATE_PREAMBLE_CCK; 3489 + 3490 + if (band == IEEE80211_BAND_5GHZ) 3491 + i += 4; 3492 + 3493 + if (i >= ARRAY_SIZE(cck_ofdm_rate)) 3494 + return false; 3495 + 3496 + rate = cck_ofdm_rate[i]; 3497 + break; 3498 + case WMI_RATE_PREAMBLE_HT: 3499 + for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) 3500 + if (mask->control[band].ht_mcs[i]) 3501 + break; 3502 + 3503 + if (i == IEEE80211_HT_MCS_MASK_LEN) 3504 + return false; 3505 + 3506 + rate = ffs(mask->control[band].ht_mcs[i]) - 1; 3507 + nss = i; 3508 + break; 3509 + case WMI_RATE_PREAMBLE_VHT: 3510 + for (i = 0; i < NL80211_VHT_NSS_MAX; i++) 3511 + if (mask->control[band].vht_mcs[i]) 3512 + break; 3513 + 3514 + if (i == NL80211_VHT_NSS_MAX) 3515 + return false; 3516 + 3517 + rate = ffs(mask->control[band].vht_mcs[i]) - 1; 3518 + nss = i; 3519 + break; 3520 + } 3521 + 3522 + *fixed_nss = nss + 1; 3523 + nss <<= 4; 3524 + pream <<= 6; 3525 + 3526 + ath10k_dbg(ATH10K_DBG_MAC, "mac fixed rate pream 0x%02x nss 0x%02x rate 0x%02x\n", 3527 + pream, nss, rate); 3528 + 3529 + *fixed_rate = pream | nss | rate; 3530 + 3531 + return true; 3532 + } 3533 + 3534 + static bool ath10k_get_fixed_rate_nss(const struct cfg80211_bitrate_mask *mask, 3535 + enum ieee80211_band band, 3536 + u8 *fixed_rate, 3537 + u8 *fixed_nss) 3538 + { 3539 + /* First check full NSS mask, if we can simply limit NSS */ 3540 + if (ath10k_bitrate_mask_nss(mask, band, fixed_nss)) 3541 + return true; 3542 + 3543 + /* Next Check single rate is set */ 3544 + return ath10k_bitrate_mask_rate(mask, band, fixed_rate, fixed_nss); 3545 + } 3546 + 3547 + static int ath10k_set_fixed_rate_param(struct ath10k_vif *arvif, 3548 + u8 fixed_rate, 3549 + u8 fixed_nss) 3550 + { 3551 + struct ath10k *ar = arvif->ar; 3552 + u32 vdev_param; 3553 + int ret = 0; 3554 + 3555 + mutex_lock(&ar->conf_mutex); 3556 + 3557 + if (arvif->fixed_rate == fixed_rate && 3558 + arvif->fixed_nss == fixed_nss) 3559 + goto exit; 3560 + 3561 + if (fixed_rate == WMI_FIXED_RATE_NONE) 3562 + ath10k_dbg(ATH10K_DBG_MAC, "mac disable fixed bitrate mask\n"); 3563 + 3564 + vdev_param = ar->wmi.vdev_param->fixed_rate; 3565 + ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, 3566 + vdev_param, fixed_rate); 3567 + if (ret) { 3568 + ath10k_warn("Could not set fixed_rate param 0x%02x: %d\n", 3569 + fixed_rate, ret); 3570 + ret = -EINVAL; 3571 + goto exit; 3572 + } 3573 + 3574 + arvif->fixed_rate = fixed_rate; 3575 + 3576 + vdev_param = ar->wmi.vdev_param->nss; 3577 + ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, 3578 + vdev_param, fixed_nss); 3579 + 3580 + if (ret) { 3581 + ath10k_warn("Could not set fixed_nss param %d: %d\n", 3582 + fixed_nss, ret); 3583 + ret = -EINVAL; 3584 + goto exit; 3585 + } 3586 + 3587 + arvif->fixed_nss = fixed_nss; 3588 + 3589 + exit: 3590 + mutex_unlock(&ar->conf_mutex); 3591 + return ret; 3592 + } 3593 + 3594 + static int ath10k_set_bitrate_mask(struct ieee80211_hw *hw, 3595 + struct ieee80211_vif *vif, 3596 + const struct cfg80211_bitrate_mask *mask) 3597 + { 3598 + struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif); 3599 + struct ath10k *ar = arvif->ar; 3600 + enum ieee80211_band band = ar->hw->conf.chandef.chan->band; 3601 + u8 fixed_rate = WMI_FIXED_RATE_NONE; 3602 + u8 fixed_nss = ar->num_rf_chains; 3603 + 3604 + if (!ath10k_default_bitrate_mask(ar, band, mask)) { 3605 + if (!ath10k_get_fixed_rate_nss(mask, band, 3606 + &fixed_rate, 3607 + &fixed_nss)) 3608 + return -EINVAL; 3609 + } 3610 + 3611 + return ath10k_set_fixed_rate_param(arvif, fixed_rate, fixed_nss); 3612 + } 3613 + 3342 3614 static const struct ieee80211_ops ath10k_ops = { 3343 3615 .tx = ath10k_tx, 3344 3616 .start = ath10k_start, ··· 3662 3332 .tx_last_beacon = ath10k_tx_last_beacon, 3663 3333 .restart_complete = ath10k_restart_complete, 3664 3334 .get_survey = ath10k_get_survey, 3335 + .set_bitrate_mask = ath10k_set_bitrate_mask, 3665 3336 #ifdef CONFIG_PM 3666 3337 .suspend = ath10k_suspend, 3667 3338 .resume = ath10k_resume, ··· 3795 3464 }, 3796 3465 }; 3797 3466 3798 - #ifdef CONFIG_ATH10K_DFS_CERTIFIED 3799 - static const struct ieee80211_iface_limit ath10k_if_dfs_limits[] = { 3467 + static const struct ieee80211_iface_limit ath10k_10x_if_limits[] = { 3800 3468 { 3801 3469 .max = 8, 3802 3470 .types = BIT(NL80211_IFTYPE_AP) 3803 3471 }, 3804 3472 }; 3805 - #endif 3806 3473 3807 3474 static const struct ieee80211_iface_combination ath10k_if_comb[] = { 3808 3475 { ··· 3810 3481 .num_different_channels = 1, 3811 3482 .beacon_int_infra_match = true, 3812 3483 }, 3813 - #ifdef CONFIG_ATH10K_DFS_CERTIFIED 3484 + }; 3485 + 3486 + static const struct ieee80211_iface_combination ath10k_10x_if_comb[] = { 3814 3487 { 3815 - .limits = ath10k_if_dfs_limits, 3816 - .n_limits = ARRAY_SIZE(ath10k_if_dfs_limits), 3488 + .limits = ath10k_10x_if_limits, 3489 + .n_limits = ARRAY_SIZE(ath10k_10x_if_limits), 3817 3490 .max_interfaces = 8, 3818 3491 .num_different_channels = 1, 3819 3492 .beacon_int_infra_match = true, 3493 + #ifdef CONFIG_ATH10K_DFS_CERTIFIED 3820 3494 .radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) | 3821 3495 BIT(NL80211_CHAN_WIDTH_20) | 3822 3496 BIT(NL80211_CHAN_WIDTH_40) | 3823 3497 BIT(NL80211_CHAN_WIDTH_80), 3824 - } 3825 3498 #endif 3499 + }, 3826 3500 }; 3827 3501 3828 3502 static struct ieee80211_sta_vht_cap ath10k_create_vht_cap(struct ath10k *ar) ··· 4004 3672 ar->hw->wiphy->interface_modes = 4005 3673 BIT(NL80211_IFTYPE_STATION) | 4006 3674 BIT(NL80211_IFTYPE_ADHOC) | 4007 - BIT(NL80211_IFTYPE_AP) | 4008 - BIT(NL80211_IFTYPE_P2P_CLIENT) | 4009 - BIT(NL80211_IFTYPE_P2P_GO); 3675 + BIT(NL80211_IFTYPE_AP); 3676 + 3677 + if (!test_bit(ATH10K_FW_FEATURE_NO_P2P, ar->fw_features)) 3678 + ar->hw->wiphy->interface_modes |= 3679 + BIT(NL80211_IFTYPE_P2P_CLIENT) | 3680 + BIT(NL80211_IFTYPE_P2P_GO); 4010 3681 4011 3682 ar->hw->flags = IEEE80211_HW_SIGNAL_DBM | 4012 3683 IEEE80211_HW_SUPPORTS_PS | ··· 4039 3704 4040 3705 ar->hw->vif_data_size = sizeof(struct ath10k_vif); 4041 3706 4042 - ar->hw->channel_change_time = 5000; 4043 3707 ar->hw->max_listen_interval = ATH10K_MAX_HW_LISTEN_INTERVAL; 4044 3708 4045 3709 ar->hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; ··· 4051 3717 */ 4052 3718 ar->hw->queues = 4; 4053 3719 4054 - ar->hw->wiphy->iface_combinations = ath10k_if_comb; 4055 - ar->hw->wiphy->n_iface_combinations = ARRAY_SIZE(ath10k_if_comb); 3720 + if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) { 3721 + ar->hw->wiphy->iface_combinations = ath10k_10x_if_comb; 3722 + ar->hw->wiphy->n_iface_combinations = 3723 + ARRAY_SIZE(ath10k_10x_if_comb); 3724 + } else { 3725 + ar->hw->wiphy->iface_combinations = ath10k_if_comb; 3726 + ar->hw->wiphy->n_iface_combinations = 3727 + ARRAY_SIZE(ath10k_if_comb); 3728 + } 4056 3729 4057 3730 ar->hw->netdev_features = NETIF_F_HW_CSUM; 4058 3731
+21
drivers/net/wireless/ath/ath10k/trace.h
··· 182 182 ) 183 183 ); 184 184 185 + TRACE_EVENT(ath10k_wmi_dbglog, 186 + TP_PROTO(void *buf, size_t buf_len), 187 + 188 + TP_ARGS(buf, buf_len), 189 + 190 + TP_STRUCT__entry( 191 + __field(size_t, buf_len) 192 + __dynamic_array(u8, buf, buf_len) 193 + ), 194 + 195 + TP_fast_assign( 196 + __entry->buf_len = buf_len; 197 + memcpy(__get_dynamic_array(buf), buf, buf_len); 198 + ), 199 + 200 + TP_printk( 201 + "len %zu", 202 + __entry->buf_len 203 + ) 204 + ); 205 + 185 206 #endif /* _TRACE_H_ || TRACE_HEADER_MULTI_READ*/ 186 207 187 208 /* we don't want to use include/trace/events */
+1 -1
drivers/net/wireless/ath/ath10k/txrx.c
··· 231 231 ~IEEE80211_FCTL_PROTECTED); 232 232 } 233 233 234 - if (info->status == HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR) 234 + if (info->mic_err) 235 235 status->flag |= RX_FLAG_MMIC_ERROR; 236 236 237 237 if (info->fcs_err)
+100 -6
drivers/net/wireless/ath/ath10k/wmi.c
··· 16 16 */ 17 17 18 18 #include <linux/skbuff.h> 19 + #include <linux/ctype.h> 19 20 20 21 #include "core.h" 21 22 #include "htc.h" ··· 876 875 struct wmi_mgmt_rx_event_v2 *ev_v2; 877 876 struct wmi_mgmt_rx_hdr_v1 *ev_hdr; 878 877 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); 878 + struct ieee80211_channel *ch; 879 879 struct ieee80211_hdr *hdr; 880 880 u32 rx_status; 881 881 u32 channel; ··· 929 927 if (rx_status & WMI_RX_STATUS_ERR_MIC) 930 928 status->flag |= RX_FLAG_MMIC_ERROR; 931 929 932 - status->band = phy_mode_to_band(phy_mode); 930 + /* HW can Rx CCK rates on 5GHz. In that case phy_mode is set to 931 + * MODE_11B. This means phy_mode is not a reliable source for the band 932 + * of mgmt rx. */ 933 + 934 + ch = ar->scan_channel; 935 + if (!ch) 936 + ch = ar->rx_channel; 937 + 938 + if (ch) { 939 + status->band = ch->band; 940 + 941 + if (phy_mode == MODE_11B && 942 + status->band == IEEE80211_BAND_5GHZ) 943 + ath10k_dbg(ATH10K_DBG_MGMT, "wmi mgmt rx 11b (CCK) on 5GHz\n"); 944 + } else { 945 + ath10k_warn("using (unreliable) phy_mode to extract band for mgmt rx\n"); 946 + status->band = phy_mode_to_band(phy_mode); 947 + } 948 + 933 949 status->freq = ieee80211_channel_to_frequency(channel, status->band); 934 950 status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR; 935 951 status->rate_idx = get_rate_idx(rate, status->band); ··· 957 937 hdr = (struct ieee80211_hdr *)skb->data; 958 938 fc = le16_to_cpu(hdr->frame_control); 959 939 960 - if (fc & IEEE80211_FCTL_PROTECTED) { 940 + /* FW delivers WEP Shared Auth frame with Protected Bit set and 941 + * encrypted payload. However in case of PMF it delivers decrypted 942 + * frames with Protected Bit set. */ 943 + if (ieee80211_has_protected(hdr->frame_control) && 944 + !ieee80211_is_auth(hdr->frame_control)) { 961 945 status->flag |= RX_FLAG_DECRYPTED | RX_FLAG_IV_STRIPPED | 962 946 RX_FLAG_MMIC_STRIPPED; 963 947 hdr->frame_control = __cpu_to_le16(fc & ··· 1071 1047 ath10k_dbg(ATH10K_DBG_WMI, "WMI_ECHO_EVENTID\n"); 1072 1048 } 1073 1049 1074 - static void ath10k_wmi_event_debug_mesg(struct ath10k *ar, struct sk_buff *skb) 1050 + static int ath10k_wmi_event_debug_mesg(struct ath10k *ar, struct sk_buff *skb) 1075 1051 { 1076 - ath10k_dbg(ATH10K_DBG_WMI, "WMI_DEBUG_MESG_EVENTID\n"); 1052 + ath10k_dbg(ATH10K_DBG_WMI, "wmi event debug mesg len %d\n", 1053 + skb->len); 1054 + 1055 + trace_ath10k_wmi_dbglog(skb->data, skb->len); 1056 + 1057 + return 0; 1077 1058 } 1078 1059 1079 1060 static void ath10k_wmi_event_update_stats(struct ath10k *ar, ··· 1682 1653 } 1683 1654 1684 1655 static void ath10k_wmi_event_debug_print(struct ath10k *ar, 1685 - struct sk_buff *skb) 1656 + struct sk_buff *skb) 1686 1657 { 1687 - ath10k_dbg(ATH10K_DBG_WMI, "WMI_DEBUG_PRINT_EVENTID\n"); 1658 + char buf[101], c; 1659 + int i; 1660 + 1661 + for (i = 0; i < sizeof(buf) - 1; i++) { 1662 + if (i >= skb->len) 1663 + break; 1664 + 1665 + c = skb->data[i]; 1666 + 1667 + if (c == '\0') 1668 + break; 1669 + 1670 + if (isascii(c) && isprint(c)) 1671 + buf[i] = c; 1672 + else 1673 + buf[i] = '.'; 1674 + } 1675 + 1676 + if (i == sizeof(buf) - 1) 1677 + ath10k_warn("wmi debug print truncated: %d\n", skb->len); 1678 + 1679 + /* for some reason the debug prints end with \n, remove that */ 1680 + if (skb->data[i - 1] == '\n') 1681 + i--; 1682 + 1683 + /* the last byte is always reserved for the null character */ 1684 + buf[i] = '\0'; 1685 + 1686 + ath10k_dbg(ATH10K_DBG_WMI, "wmi event debug print '%s'\n", buf); 1688 1687 } 1689 1688 1690 1689 static void ath10k_wmi_event_pdev_qvit(struct ath10k *ar, struct sk_buff *skb) ··· 3501 3444 ath10k_dbg(ATH10K_DBG_WMI, "wmi force fw hang %d delay %d\n", 3502 3445 type, delay_ms); 3503 3446 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->force_fw_hang_cmdid); 3447 + } 3448 + 3449 + int ath10k_wmi_dbglog_cfg(struct ath10k *ar, u32 module_enable) 3450 + { 3451 + struct wmi_dbglog_cfg_cmd *cmd; 3452 + struct sk_buff *skb; 3453 + u32 cfg; 3454 + 3455 + skb = ath10k_wmi_alloc_skb(sizeof(*cmd)); 3456 + if (!skb) 3457 + return -ENOMEM; 3458 + 3459 + cmd = (struct wmi_dbglog_cfg_cmd *)skb->data; 3460 + 3461 + if (module_enable) { 3462 + cfg = SM(ATH10K_DBGLOG_LEVEL_VERBOSE, 3463 + ATH10K_DBGLOG_CFG_LOG_LVL); 3464 + } else { 3465 + /* set back defaults, all modules with WARN level */ 3466 + cfg = SM(ATH10K_DBGLOG_LEVEL_WARN, 3467 + ATH10K_DBGLOG_CFG_LOG_LVL); 3468 + module_enable = ~0; 3469 + } 3470 + 3471 + cmd->module_enable = __cpu_to_le32(module_enable); 3472 + cmd->module_valid = __cpu_to_le32(~0); 3473 + cmd->config_enable = __cpu_to_le32(cfg); 3474 + cmd->config_valid = __cpu_to_le32(ATH10K_DBGLOG_CFG_LOG_LVL_MASK); 3475 + 3476 + ath10k_dbg(ATH10K_DBG_WMI, 3477 + "wmi dbglog cfg modules %08x %08x config %08x %08x\n", 3478 + __le32_to_cpu(cmd->module_enable), 3479 + __le32_to_cpu(cmd->module_valid), 3480 + __le32_to_cpu(cmd->config_enable), 3481 + __le32_to_cpu(cmd->config_valid)); 3482 + 3483 + return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->dbglog_cfg_cmdid); 3504 3484 }
+61
drivers/net/wireless/ath/ath10k/wmi.h
··· 3003 3003 const void *key_data; 3004 3004 }; 3005 3005 3006 + /* 3007 + * vdev fixed rate format: 3008 + * - preamble - b7:b6 - see WMI_RATE_PREMABLE_ 3009 + * - nss - b5:b4 - ss number (0 mean 1ss) 3010 + * - rate_mcs - b3:b0 - as below 3011 + * CCK: 0 - 11Mbps, 1 - 5,5Mbps, 2 - 2Mbps, 3 - 1Mbps, 3012 + * 4 - 11Mbps (s), 5 - 5,5Mbps (s), 6 - 2Mbps (s) 3013 + * OFDM: 0 - 48Mbps, 1 - 24Mbps, 2 - 12Mbps, 3 - 6Mbps, 3014 + * 4 - 54Mbps, 5 - 36Mbps, 6 - 18Mbps, 7 - 9Mbps 3015 + * HT/VHT: MCS index 3016 + */ 3017 + 3006 3018 /* Preamble types to be used with VDEV fixed rate configuration */ 3007 3019 enum wmi_rate_preamble { 3008 3020 WMI_RATE_PREAMBLE_OFDM, ··· 4102 4090 __le32 delay_ms; 4103 4091 } __packed; 4104 4092 4093 + enum ath10k_dbglog_level { 4094 + ATH10K_DBGLOG_LEVEL_VERBOSE = 0, 4095 + ATH10K_DBGLOG_LEVEL_INFO = 1, 4096 + ATH10K_DBGLOG_LEVEL_WARN = 2, 4097 + ATH10K_DBGLOG_LEVEL_ERR = 3, 4098 + }; 4099 + 4100 + /* VAP ids to enable dbglog */ 4101 + #define ATH10K_DBGLOG_CFG_VAP_LOG_LSB 0 4102 + #define ATH10K_DBGLOG_CFG_VAP_LOG_MASK 0x0000ffff 4103 + 4104 + /* to enable dbglog in the firmware */ 4105 + #define ATH10K_DBGLOG_CFG_REPORTING_ENABLE_LSB 16 4106 + #define ATH10K_DBGLOG_CFG_REPORTING_ENABLE_MASK 0x00010000 4107 + 4108 + /* timestamp resolution */ 4109 + #define ATH10K_DBGLOG_CFG_RESOLUTION_LSB 17 4110 + #define ATH10K_DBGLOG_CFG_RESOLUTION_MASK 0x000E0000 4111 + 4112 + /* number of queued messages before sending them to the host */ 4113 + #define ATH10K_DBGLOG_CFG_REPORT_SIZE_LSB 20 4114 + #define ATH10K_DBGLOG_CFG_REPORT_SIZE_MASK 0x0ff00000 4115 + 4116 + /* 4117 + * Log levels to enable. This defines the minimum level to enable, this is 4118 + * not a bitmask. See enum ath10k_dbglog_level for the values. 4119 + */ 4120 + #define ATH10K_DBGLOG_CFG_LOG_LVL_LSB 28 4121 + #define ATH10K_DBGLOG_CFG_LOG_LVL_MASK 0x70000000 4122 + 4123 + /* 4124 + * Note: this is a cleaned up version of a struct firmware uses. For 4125 + * example, config_valid was hidden inside an array. 4126 + */ 4127 + struct wmi_dbglog_cfg_cmd { 4128 + /* bitmask to hold mod id config*/ 4129 + __le32 module_enable; 4130 + 4131 + /* see ATH10K_DBGLOG_CFG_ */ 4132 + __le32 config_enable; 4133 + 4134 + /* mask of module id bits to be changed */ 4135 + __le32 module_valid; 4136 + 4137 + /* mask of config bits to be changed, see ATH10K_DBGLOG_CFG_ */ 4138 + __le32 config_valid; 4139 + } __packed; 4140 + 4105 4141 #define ATH10K_RTS_MAX 2347 4106 4142 #define ATH10K_FRAGMT_THRESHOLD_MIN 540 4107 4143 #define ATH10K_FRAGMT_THRESHOLD_MAX 2346 ··· 4227 4167 int ath10k_wmi_force_fw_hang(struct ath10k *ar, 4228 4168 enum wmi_force_fw_hang_type type, u32 delay_ms); 4229 4169 int ath10k_wmi_mgmt_tx(struct ath10k *ar, struct sk_buff *skb); 4170 + int ath10k_wmi_dbglog_cfg(struct ath10k *ar, u32 module_enable); 4230 4171 4231 4172 #endif /* _WMI_H_ */
+8 -26
drivers/net/wireless/ath/ath5k/base.c
··· 1238 1238 ath5k_check_ibss_tsf(struct ath5k_hw *ah, struct sk_buff *skb, 1239 1239 struct ieee80211_rx_status *rxs) 1240 1240 { 1241 - struct ath_common *common = ath5k_hw_common(ah); 1242 1241 u64 tsf, bc_tstamp; 1243 1242 u32 hw_tu; 1244 1243 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data; 1245 1244 1246 - if (ieee80211_is_beacon(mgmt->frame_control) && 1247 - le16_to_cpu(mgmt->u.beacon.capab_info) & WLAN_CAPABILITY_IBSS && 1248 - ether_addr_equal_64bits(mgmt->bssid, common->curbssid)) { 1245 + if (le16_to_cpu(mgmt->u.beacon.capab_info) & WLAN_CAPABILITY_IBSS) { 1249 1246 /* 1250 1247 * Received an IBSS beacon with the same BSSID. Hardware *must* 1251 1248 * have updated the local TSF. We have to work around various ··· 1296 1299 "fixed beacon timers after beacon receive\n"); 1297 1300 } 1298 1301 } 1299 - } 1300 - 1301 - static void 1302 - ath5k_update_beacon_rssi(struct ath5k_hw *ah, struct sk_buff *skb, int rssi) 1303 - { 1304 - struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data; 1305 - struct ath_common *common = ath5k_hw_common(ah); 1306 - 1307 - /* only beacons from our BSSID */ 1308 - if (!ieee80211_is_beacon(mgmt->frame_control) || 1309 - !ether_addr_equal_64bits(mgmt->bssid, common->curbssid)) 1310 - return; 1311 - 1312 - ewma_add(&ah->ah_beacon_rssi_avg, rssi); 1313 - 1314 - /* in IBSS mode we should keep RSSI statistics per neighbour */ 1315 - /* le16_to_cpu(mgmt->u.beacon.capab_info) & WLAN_CAPABILITY_IBSS */ 1316 1302 } 1317 1303 1318 1304 /* ··· 1370 1390 struct ath5k_rx_status *rs) 1371 1391 { 1372 1392 struct ieee80211_rx_status *rxs; 1393 + struct ath_common *common = ath5k_hw_common(ah); 1373 1394 1374 1395 ath5k_remove_padding(skb); 1375 1396 ··· 1423 1442 1424 1443 trace_ath5k_rx(ah, skb); 1425 1444 1426 - ath5k_update_beacon_rssi(ah, skb, rs->rs_rssi); 1445 + if (ath_is_mybeacon(common, (struct ieee80211_hdr *)skb->data)) { 1446 + ewma_add(&ah->ah_beacon_rssi_avg, rs->rs_rssi); 1427 1447 1428 - /* check beacons in IBSS mode */ 1429 - if (ah->opmode == NL80211_IFTYPE_ADHOC) 1430 - ath5k_check_ibss_tsf(ah, skb, rxs); 1448 + /* check beacons in IBSS mode */ 1449 + if (ah->opmode == NL80211_IFTYPE_ADHOC) 1450 + ath5k_check_ibss_tsf(ah, skb, rxs); 1451 + } 1431 1452 1432 1453 ieee80211_rx(ah->hw, skb); 1433 1454 } ··· 2532 2549 hw->wiphy->available_antennas_rx = 0x3; 2533 2550 2534 2551 hw->extra_tx_headroom = 2; 2535 - hw->channel_change_time = 5000; 2536 2552 2537 2553 /* 2538 2554 * Mark the device as detached to avoid processing
+8
drivers/net/wireless/ath/ath9k/Kconfig
··· 65 65 66 66 Also required for changing debug message flags at run time. 67 67 68 + config ATH9K_STATION_STATISTICS 69 + bool "Detailed station statistics" 70 + depends on ATH9K && ATH9K_DEBUGFS && DEBUG_FS 71 + select MAC80211_DEBUGFS 72 + default n 73 + ---help--- 74 + This option enables detailed statistics for association stations. 75 + 68 76 config ATH9K_DFS_CERTIFIED 69 77 bool "Atheros DFS support for certified platforms" 70 78 depends on ATH9K && CFG80211_CERTIFICATION_ONUS
+2
drivers/net/wireless/ath/ath9k/Makefile
··· 19 19 ath9k-$(CONFIG_ATH9K_DEBUGFS) += debug.o \ 20 20 spectral.o 21 21 22 + ath9k-$(CONFIG_ATH9K_STATION_STATISTICS) += debug_sta.o 23 + 22 24 obj-$(CONFIG_ATH9K) += ath9k.o 23 25 24 26 ath9k_hw-y:= \
+16 -3
drivers/net/wireless/ath/ath9k/ar9003_calib.c
··· 565 565 const s32 result_shift = 1 << 15; 566 566 struct ath_common *common = ath9k_hw_common(ah); 567 567 568 - f2 = (f1 * f1 + f3 * f3) / result_shift; 568 + f2 = ((f1 >> 3) * (f1 >> 3) + (f3 >> 3) * (f3 >> 3)) >> 9; 569 569 570 570 if (!f2) { 571 571 ath_dbg(common, CALIBRATE, "Divide by 0\n"); ··· 655 655 if (i2_m_q2_a0_d1 > 0x800) 656 656 i2_m_q2_a0_d1 = -((0xfff - i2_m_q2_a0_d1) + 1); 657 657 658 - if (i2_p_q2_a0_d1 > 0x800) 659 - i2_p_q2_a0_d1 = -((0xfff - i2_p_q2_a0_d1) + 1); 658 + if (i2_p_q2_a0_d1 > 0x1000) 659 + i2_p_q2_a0_d1 = -((0x1fff - i2_p_q2_a0_d1) + 1); 660 660 661 661 if (iq_corr_a0_d1 > 0x800) 662 662 iq_corr_a0_d1 = -((0xfff - iq_corr_a0_d1) + 1); ··· 697 697 "a1_d1=%d\n", 698 698 i2_p_q2_a0_d0, i2_p_q2_a0_d1, 699 699 i2_p_q2_a1_d0, i2_p_q2_a1_d1); 700 + return false; 701 + } 702 + 703 + if ((i2_p_q2_a0_d0 < 1024) || (i2_p_q2_a0_d0 > 2047) || 704 + (i2_p_q2_a1_d0 < 0) || (i2_p_q2_a1_d1 < 0) || 705 + (i2_p_q2_a0_d0 <= i2_m_q2_a0_d0) || 706 + (i2_p_q2_a0_d0 <= iq_corr_a0_d0) || 707 + (i2_p_q2_a0_d1 <= i2_m_q2_a0_d1) || 708 + (i2_p_q2_a0_d1 <= iq_corr_a0_d1) || 709 + (i2_p_q2_a1_d0 <= i2_m_q2_a1_d0) || 710 + (i2_p_q2_a1_d0 <= iq_corr_a1_d0) || 711 + (i2_p_q2_a1_d1 <= i2_m_q2_a1_d1) || 712 + (i2_p_q2_a1_d1 <= iq_corr_a1_d1)) { 700 713 return false; 701 714 } 702 715
+9 -1
drivers/net/wireless/ath/ath9k/ath9k.h
··· 146 146 147 147 #define ATH_AN_2_TID(_an, _tidno) (&(_an)->tid[(_tidno)]) 148 148 149 - #define IS_CCK_RATE(rate) ((rate >= 0x18) && (rate <= 0x1e)) 149 + #define IS_HT_RATE(rate) (rate & 0x80) 150 + #define IS_CCK_RATE(rate) ((rate >= 0x18) && (rate <= 0x1e)) 151 + #define IS_OFDM_RATE(rate) ((rate >= 0x8) && (rate <= 0xf)) 150 152 151 153 struct ath_txq { 152 154 int mac80211_qnum; /* mac80211 queue number, -1 means not mac80211 Q */ ··· 264 262 265 263 bool sleeping; 266 264 bool no_ps_filter; 265 + 266 + #ifdef CONFIG_ATH9K_STATION_STATISTICS 267 + struct ath_rx_rate_stats rx_rate_stats; 268 + #endif 267 269 }; 268 270 269 271 struct ath_tx_control { ··· 691 685 #define DEFAULT_CACHELINE 32 692 686 #define ATH_CABQ_READY_TIME 80 /* % of beacon interval */ 693 687 #define ATH_TXPOWER_MAX 100 /* .5 dBm units */ 688 + #define MAX_GTT_CNT 5 694 689 695 690 enum sc_op_flags { 696 691 SC_OP_INVALID, ··· 734 727 unsigned long sc_flags; 735 728 unsigned long driver_data; 736 729 730 + u8 gtt_cnt; 737 731 u32 intrstatus; 738 732 u16 ps_flags; /* PS_* */ 739 733 u16 curtxpow;
+74 -123
drivers/net/wireless/ath/ath9k/debug.c
··· 943 943 static ssize_t read_file_recv(struct file *file, char __user *user_buf, 944 944 size_t count, loff_t *ppos) 945 945 { 946 - #define PHY_ERR(s, p) \ 947 - len += scnprintf(buf + len, size - len, "%22s : %10u\n", s, \ 948 - sc->debug.stats.rxstats.phy_err_stats[p]); 949 - 950 946 #define RXS_ERR(s, e) \ 951 947 do { \ 952 948 len += scnprintf(buf + len, size - len, \ 953 - "%22s : %10u\n", s, \ 949 + "%18s : %10u\n", s, \ 954 950 sc->debug.stats.rxstats.e);\ 955 951 } while (0) 956 952 ··· 959 963 if (buf == NULL) 960 964 return -ENOMEM; 961 965 966 + RXS_ERR("PKTS-ALL", rx_pkts_all); 967 + RXS_ERR("BYTES-ALL", rx_bytes_all); 968 + RXS_ERR("BEACONS", rx_beacons); 969 + RXS_ERR("FRAGS", rx_frags); 970 + RXS_ERR("SPECTRAL", rx_spectral); 971 + 962 972 RXS_ERR("CRC ERR", crc_err); 963 973 RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err); 964 974 RXS_ERR("PHY ERR", phy_err); ··· 972 970 RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err); 973 971 RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err); 974 972 RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err); 975 - RXS_ERR("RX-LENGTH-ERR", rx_len_err); 976 - RXS_ERR("RX-OOM-ERR", rx_oom_err); 977 - RXS_ERR("RX-RATE-ERR", rx_rate_err); 978 - RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err); 979 - 980 - PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN); 981 - PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING); 982 - PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY); 983 - PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE); 984 - PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH); 985 - PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR); 986 - PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE); 987 - PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR); 988 - PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING); 989 - PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); 990 - PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); 991 - PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); 992 - PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP); 993 - PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE); 994 - PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART); 995 - PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT); 996 - PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING); 997 - PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC); 998 - PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL); 999 - PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE); 1000 - PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART); 1001 - PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); 1002 - PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP); 1003 - PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR); 1004 - PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); 1005 - PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL); 1006 - 1007 - RXS_ERR("RX-Pkts-All", rx_pkts_all); 1008 - RXS_ERR("RX-Bytes-All", rx_bytes_all); 1009 - RXS_ERR("RX-Beacons", rx_beacons); 1010 - RXS_ERR("RX-Frags", rx_frags); 1011 - RXS_ERR("RX-Spectral", rx_spectral); 973 + RXS_ERR("LENGTH-ERR", rx_len_err); 974 + RXS_ERR("OOM-ERR", rx_oom_err); 975 + RXS_ERR("RATE-ERR", rx_rate_err); 976 + RXS_ERR("TOO-MANY-FRAGS", rx_too_many_frags_err); 1012 977 1013 978 if (len > size) 1014 979 len = size; ··· 986 1017 return retval; 987 1018 988 1019 #undef RXS_ERR 989 - #undef PHY_ERR 990 1020 } 991 1021 992 1022 void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) ··· 1019 1051 1020 1052 static const struct file_operations fops_recv = { 1021 1053 .read = read_file_recv, 1054 + .open = simple_open, 1055 + .owner = THIS_MODULE, 1056 + .llseek = default_llseek, 1057 + }; 1058 + 1059 + static ssize_t read_file_phy_err(struct file *file, char __user *user_buf, 1060 + size_t count, loff_t *ppos) 1061 + { 1062 + #define PHY_ERR(s, p) \ 1063 + len += scnprintf(buf + len, size - len, "%22s : %10u\n", s, \ 1064 + sc->debug.stats.rxstats.phy_err_stats[p]); 1065 + 1066 + struct ath_softc *sc = file->private_data; 1067 + char *buf; 1068 + unsigned int len = 0, size = 1600; 1069 + ssize_t retval = 0; 1070 + 1071 + buf = kzalloc(size, GFP_KERNEL); 1072 + if (buf == NULL) 1073 + return -ENOMEM; 1074 + 1075 + PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN); 1076 + PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING); 1077 + PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY); 1078 + PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE); 1079 + PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH); 1080 + PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR); 1081 + PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE); 1082 + PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR); 1083 + PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING); 1084 + PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY); 1085 + PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL); 1086 + PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL); 1087 + PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP); 1088 + PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE); 1089 + PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART); 1090 + PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT); 1091 + PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING); 1092 + PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC); 1093 + PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL); 1094 + PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE); 1095 + PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART); 1096 + PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL); 1097 + PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP); 1098 + PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR); 1099 + PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); 1100 + PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL); 1101 + 1102 + if (len > size) 1103 + len = size; 1104 + 1105 + retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1106 + kfree(buf); 1107 + 1108 + return retval; 1109 + 1110 + #undef PHY_ERR 1111 + } 1112 + 1113 + static const struct file_operations fops_phy_err = { 1114 + .read = read_file_phy_err, 1022 1115 .open = simple_open, 1023 1116 .owner = THIS_MODULE, 1024 1117 .llseek = default_llseek, ··· 1351 1322 }; 1352 1323 #endif 1353 1324 1354 - static ssize_t read_file_node_stat(struct file *file, char __user *user_buf, 1355 - size_t count, loff_t *ppos) 1356 - { 1357 - struct ath_node *an = file->private_data; 1358 - struct ath_softc *sc = an->sc; 1359 - struct ath_atx_tid *tid; 1360 - struct ath_atx_ac *ac; 1361 - struct ath_txq *txq; 1362 - u32 len = 0, size = 4096; 1363 - char *buf; 1364 - size_t retval; 1365 - int tidno, acno; 1366 - 1367 - buf = kzalloc(size, GFP_KERNEL); 1368 - if (buf == NULL) 1369 - return -ENOMEM; 1370 - 1371 - if (!an->sta->ht_cap.ht_supported) { 1372 - len = scnprintf(buf, size, "%s\n", 1373 - "HT not supported"); 1374 - goto exit; 1375 - } 1376 - 1377 - len = scnprintf(buf, size, "Max-AMPDU: %d\n", 1378 - an->maxampdu); 1379 - len += scnprintf(buf + len, size - len, "MPDU Density: %d\n\n", 1380 - an->mpdudensity); 1381 - 1382 - len += scnprintf(buf + len, size - len, 1383 - "%2s%7s\n", "AC", "SCHED"); 1384 - 1385 - for (acno = 0, ac = &an->ac[acno]; 1386 - acno < IEEE80211_NUM_ACS; acno++, ac++) { 1387 - txq = ac->txq; 1388 - ath_txq_lock(sc, txq); 1389 - len += scnprintf(buf + len, size - len, 1390 - "%2d%7d\n", 1391 - acno, ac->sched); 1392 - ath_txq_unlock(sc, txq); 1393 - } 1394 - 1395 - len += scnprintf(buf + len, size - len, 1396 - "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n", 1397 - "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE", 1398 - "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED"); 1399 - 1400 - for (tidno = 0, tid = &an->tid[tidno]; 1401 - tidno < IEEE80211_NUM_TIDS; tidno++, tid++) { 1402 - txq = tid->ac->txq; 1403 - ath_txq_lock(sc, txq); 1404 - len += scnprintf(buf + len, size - len, 1405 - "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n", 1406 - tid->tidno, tid->seq_start, tid->seq_next, 1407 - tid->baw_size, tid->baw_head, tid->baw_tail, 1408 - tid->bar_index, tid->sched, tid->paused); 1409 - ath_txq_unlock(sc, txq); 1410 - } 1411 - exit: 1412 - retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 1413 - kfree(buf); 1414 - 1415 - return retval; 1416 - } 1417 - 1418 - static const struct file_operations fops_node_stat = { 1419 - .read = read_file_node_stat, 1420 - .open = simple_open, 1421 - .owner = THIS_MODULE, 1422 - .llseek = default_llseek, 1423 - }; 1424 - 1425 - void ath9k_sta_add_debugfs(struct ieee80211_hw *hw, 1426 - struct ieee80211_vif *vif, 1427 - struct ieee80211_sta *sta, 1428 - struct dentry *dir) 1429 - { 1430 - struct ath_node *an = (struct ath_node *)sta->drv_priv; 1431 - debugfs_create_file("node_stat", S_IRUGO, dir, an, &fops_node_stat); 1432 - } 1433 - 1434 1325 /* Ethtool support for get-stats */ 1435 1326 1436 1327 #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO" ··· 1518 1569 &fops_reset); 1519 1570 debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, 1520 1571 &fops_recv); 1572 + debugfs_create_file("phy_err", S_IRUSR, sc->debug.debugfs_phy, sc, 1573 + &fops_phy_err); 1521 1574 debugfs_create_u8("rx_chainmask", S_IRUSR, sc->debug.debugfs_phy, 1522 1575 &ah->rxchainmask); 1523 1576 debugfs_create_u8("tx_chainmask", S_IRUSR, sc->debug.debugfs_phy,
+32 -3
drivers/net/wireless/ath/ath9k/debug.h
··· 27 27 28 28 #ifdef CONFIG_ATH9K_DEBUGFS 29 29 #define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++ 30 + #define RX_STAT_INC(c) (sc->debug.stats.rxstats.c++) 30 31 #define RESET_STAT_INC(sc, type) sc->debug.stats.reset[type]++ 31 32 #define ANT_STAT_INC(i, c) sc->debug.stats.ant_stats[i].c++ 32 33 #define ANT_LNA_INC(i, c) sc->debug.stats.ant_stats[i].lna_recv_cnt[c]++; 33 34 #else 34 35 #define TX_STAT_INC(q, c) do { } while (0) 36 + #define RX_STAT_INC(c) 35 37 #define RESET_STAT_INC(sc, type) do { } while (0) 36 38 #define ANT_STAT_INC(i, c) do { } while (0) 37 39 #define ANT_LNA_INC(i, c) do { } while (0) ··· 44 42 RESET_TYPE_BB_WATCHDOG, 45 43 RESET_TYPE_FATAL_INT, 46 44 RESET_TYPE_TX_ERROR, 45 + RESET_TYPE_TX_GTT, 47 46 RESET_TYPE_TX_HANG, 48 47 RESET_TYPE_PLL_HANG, 49 48 RESET_TYPE_MAC_HANG, ··· 204 201 TXSTATS[PR_QNUM(IEEE80211_AC_VO)].elem); \ 205 202 } while(0) 206 203 207 - #define RX_STAT_INC(c) (sc->debug.stats.rxstats.c++) 204 + struct ath_rx_rate_stats { 205 + struct { 206 + u32 ht20_cnt; 207 + u32 ht40_cnt; 208 + u32 sgi_cnt; 209 + u32 lgi_cnt; 210 + } ht_stats[24]; 211 + 212 + struct { 213 + u32 ofdm_cnt; 214 + } ofdm_stats[8]; 215 + 216 + struct { 217 + u32 cck_lp_cnt; 218 + u32 cck_sp_cnt; 219 + } cck_stats[4]; 220 + }; 208 221 209 222 /** 210 223 * struct ath_rx_stats - RX Statistics ··· 318 299 319 300 #else 320 301 321 - #define RX_STAT_INC(c) /* NOP */ 322 - 323 302 static inline int ath9k_init_debug(struct ath_hw *ah) 324 303 { 325 304 return 0; ··· 354 337 } 355 338 356 339 #endif /* CONFIG_ATH9K_DEBUGFS */ 340 + 341 + #ifdef CONFIG_ATH9K_STATION_STATISTICS 342 + void ath_debug_rate_stats(struct ath_softc *sc, 343 + struct ath_rx_status *rs, 344 + struct sk_buff *skb); 345 + #else 346 + static inline void ath_debug_rate_stats(struct ath_softc *sc, 347 + struct ath_rx_status *rs, 348 + struct sk_buff *skb) 349 + { 350 + } 351 + #endif /* CONFIG_ATH9K_STATION_STATISTICS */ 357 352 358 353 #endif /* DEBUG_H */
+269
drivers/net/wireless/ath/ath9k/debug_sta.c
··· 1 + /* 2 + * Copyright (c) 2013 Qualcomm Atheros, Inc. 3 + * 4 + * Permission to use, copy, modify, and/or distribute this software for any 5 + * purpose with or without fee is hereby granted, provided that the above 6 + * copyright notice and this permission notice appear in all copies. 7 + * 8 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 + */ 16 + 17 + #include "ath9k.h" 18 + 19 + /*************/ 20 + /* node_aggr */ 21 + /*************/ 22 + 23 + static ssize_t read_file_node_aggr(struct file *file, char __user *user_buf, 24 + size_t count, loff_t *ppos) 25 + { 26 + struct ath_node *an = file->private_data; 27 + struct ath_softc *sc = an->sc; 28 + struct ath_atx_tid *tid; 29 + struct ath_atx_ac *ac; 30 + struct ath_txq *txq; 31 + u32 len = 0, size = 4096; 32 + char *buf; 33 + size_t retval; 34 + int tidno, acno; 35 + 36 + buf = kzalloc(size, GFP_KERNEL); 37 + if (buf == NULL) 38 + return -ENOMEM; 39 + 40 + if (!an->sta->ht_cap.ht_supported) { 41 + len = scnprintf(buf, size, "%s\n", 42 + "HT not supported"); 43 + goto exit; 44 + } 45 + 46 + len = scnprintf(buf, size, "Max-AMPDU: %d\n", 47 + an->maxampdu); 48 + len += scnprintf(buf + len, size - len, "MPDU Density: %d\n\n", 49 + an->mpdudensity); 50 + 51 + len += scnprintf(buf + len, size - len, 52 + "%2s%7s\n", "AC", "SCHED"); 53 + 54 + for (acno = 0, ac = &an->ac[acno]; 55 + acno < IEEE80211_NUM_ACS; acno++, ac++) { 56 + txq = ac->txq; 57 + ath_txq_lock(sc, txq); 58 + len += scnprintf(buf + len, size - len, 59 + "%2d%7d\n", 60 + acno, ac->sched); 61 + ath_txq_unlock(sc, txq); 62 + } 63 + 64 + len += scnprintf(buf + len, size - len, 65 + "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n", 66 + "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE", 67 + "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED"); 68 + 69 + for (tidno = 0, tid = &an->tid[tidno]; 70 + tidno < IEEE80211_NUM_TIDS; tidno++, tid++) { 71 + txq = tid->ac->txq; 72 + ath_txq_lock(sc, txq); 73 + if (tid->active) { 74 + len += scnprintf(buf + len, size - len, 75 + "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n", 76 + tid->tidno, 77 + tid->seq_start, 78 + tid->seq_next, 79 + tid->baw_size, 80 + tid->baw_head, 81 + tid->baw_tail, 82 + tid->bar_index, 83 + tid->sched, 84 + tid->paused); 85 + } 86 + ath_txq_unlock(sc, txq); 87 + } 88 + exit: 89 + retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 90 + kfree(buf); 91 + 92 + return retval; 93 + } 94 + 95 + static const struct file_operations fops_node_aggr = { 96 + .read = read_file_node_aggr, 97 + .open = simple_open, 98 + .owner = THIS_MODULE, 99 + .llseek = default_llseek, 100 + }; 101 + 102 + /*************/ 103 + /* node_recv */ 104 + /*************/ 105 + 106 + void ath_debug_rate_stats(struct ath_softc *sc, 107 + struct ath_rx_status *rs, 108 + struct sk_buff *skb) 109 + { 110 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 111 + struct ath_hw *ah = sc->sc_ah; 112 + struct ieee80211_rx_status *rxs; 113 + struct ath_rx_rate_stats *rstats; 114 + struct ieee80211_sta *sta; 115 + struct ath_node *an; 116 + 117 + if (!ieee80211_is_data(hdr->frame_control)) 118 + return; 119 + 120 + rcu_read_lock(); 121 + 122 + sta = ieee80211_find_sta_by_ifaddr(sc->hw, hdr->addr2, NULL); 123 + if (!sta) 124 + goto exit; 125 + 126 + an = (struct ath_node *) sta->drv_priv; 127 + rstats = &an->rx_rate_stats; 128 + rxs = IEEE80211_SKB_RXCB(skb); 129 + 130 + if (IS_HT_RATE(rs->rs_rate)) { 131 + if (rxs->rate_idx >= ARRAY_SIZE(rstats->ht_stats)) 132 + goto exit; 133 + 134 + if (rxs->flag & RX_FLAG_40MHZ) 135 + rstats->ht_stats[rxs->rate_idx].ht40_cnt++; 136 + else 137 + rstats->ht_stats[rxs->rate_idx].ht20_cnt++; 138 + 139 + if (rxs->flag & RX_FLAG_SHORT_GI) 140 + rstats->ht_stats[rxs->rate_idx].sgi_cnt++; 141 + else 142 + rstats->ht_stats[rxs->rate_idx].lgi_cnt++; 143 + 144 + goto exit; 145 + } 146 + 147 + if (IS_CCK_RATE(rs->rs_rate)) { 148 + if (rxs->flag & RX_FLAG_SHORTPRE) 149 + rstats->cck_stats[rxs->rate_idx].cck_sp_cnt++; 150 + else 151 + rstats->cck_stats[rxs->rate_idx].cck_lp_cnt++; 152 + 153 + goto exit; 154 + } 155 + 156 + if (IS_OFDM_RATE(rs->rs_rate)) { 157 + if (ah->curchan->chan->band == IEEE80211_BAND_2GHZ) 158 + rstats->ofdm_stats[rxs->rate_idx - 4].ofdm_cnt++; 159 + else 160 + rstats->ofdm_stats[rxs->rate_idx].ofdm_cnt++; 161 + } 162 + exit: 163 + rcu_read_unlock(); 164 + } 165 + 166 + #define PRINT_CCK_RATE(str, i, sp) \ 167 + do { \ 168 + len += scnprintf(buf + len, size - len, \ 169 + "%11s : %10u\n", \ 170 + str, \ 171 + (sp) ? rstats->cck_stats[i].cck_sp_cnt : \ 172 + rstats->cck_stats[i].cck_lp_cnt); \ 173 + } while (0) 174 + 175 + #define PRINT_OFDM_RATE(str, i) \ 176 + do { \ 177 + len += scnprintf(buf + len, size - len, \ 178 + "%11s : %10u\n", \ 179 + str, \ 180 + rstats->ofdm_stats[i].ofdm_cnt); \ 181 + } while (0) 182 + 183 + static ssize_t read_file_node_recv(struct file *file, char __user *user_buf, 184 + size_t count, loff_t *ppos) 185 + { 186 + struct ath_node *an = file->private_data; 187 + struct ath_softc *sc = an->sc; 188 + struct ath_hw *ah = sc->sc_ah; 189 + struct ath_rx_rate_stats *rstats; 190 + struct ieee80211_sta *sta = an->sta; 191 + enum ieee80211_band band; 192 + u32 len = 0, size = 4096; 193 + char *buf; 194 + size_t retval; 195 + int i; 196 + 197 + buf = kzalloc(size, GFP_KERNEL); 198 + if (buf == NULL) 199 + return -ENOMEM; 200 + 201 + band = ah->curchan->chan->band; 202 + rstats = &an->rx_rate_stats; 203 + 204 + if (!sta->ht_cap.ht_supported) 205 + goto legacy; 206 + 207 + len += scnprintf(buf + len, size - len, 208 + "%24s%10s%10s%10s\n", 209 + "HT20", "HT40", "SGI", "LGI"); 210 + 211 + for (i = 0; i < 24; i++) { 212 + len += scnprintf(buf + len, size - len, 213 + "%8s%3u : %10u%10u%10u%10u\n", 214 + "MCS", i, 215 + rstats->ht_stats[i].ht20_cnt, 216 + rstats->ht_stats[i].ht40_cnt, 217 + rstats->ht_stats[i].sgi_cnt, 218 + rstats->ht_stats[i].lgi_cnt); 219 + } 220 + 221 + len += scnprintf(buf + len, size - len, "\n"); 222 + 223 + legacy: 224 + if (band == IEEE80211_BAND_2GHZ) { 225 + PRINT_CCK_RATE("CCK-1M/LP", 0, false); 226 + PRINT_CCK_RATE("CCK-2M/LP", 1, false); 227 + PRINT_CCK_RATE("CCK-5.5M/LP", 2, false); 228 + PRINT_CCK_RATE("CCK-11M/LP", 3, false); 229 + 230 + PRINT_CCK_RATE("CCK-2M/SP", 1, true); 231 + PRINT_CCK_RATE("CCK-5.5M/SP", 2, true); 232 + PRINT_CCK_RATE("CCK-11M/SP", 3, true); 233 + } 234 + 235 + PRINT_OFDM_RATE("OFDM-6M", 0); 236 + PRINT_OFDM_RATE("OFDM-9M", 1); 237 + PRINT_OFDM_RATE("OFDM-12M", 2); 238 + PRINT_OFDM_RATE("OFDM-18M", 3); 239 + PRINT_OFDM_RATE("OFDM-24M", 4); 240 + PRINT_OFDM_RATE("OFDM-36M", 5); 241 + PRINT_OFDM_RATE("OFDM-48M", 6); 242 + PRINT_OFDM_RATE("OFDM-54M", 7); 243 + 244 + retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); 245 + kfree(buf); 246 + 247 + return retval; 248 + } 249 + 250 + #undef PRINT_OFDM_RATE 251 + #undef PRINT_CCK_RATE 252 + 253 + static const struct file_operations fops_node_recv = { 254 + .read = read_file_node_recv, 255 + .open = simple_open, 256 + .owner = THIS_MODULE, 257 + .llseek = default_llseek, 258 + }; 259 + 260 + void ath9k_sta_add_debugfs(struct ieee80211_hw *hw, 261 + struct ieee80211_vif *vif, 262 + struct ieee80211_sta *sta, 263 + struct dentry *dir) 264 + { 265 + struct ath_node *an = (struct ath_node *)sta->drv_priv; 266 + 267 + debugfs_create_file("node_aggr", S_IRUGO, dir, an, &fops_node_aggr); 268 + debugfs_create_file("node_recv", S_IRUGO, dir, an, &fops_node_recv); 269 + }
-1
drivers/net/wireless/ath/ath9k/htc_drv_init.c
··· 748 748 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; 749 749 750 750 hw->queues = 4; 751 - hw->channel_change_time = 5000; 752 751 hw->max_listen_interval = 1; 753 752 754 753 hw->vif_data_size = sizeof(struct ath9k_htc_vif);
+1 -3
drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
··· 1075 1075 1076 1076 last_rssi = priv->rx.last_rssi; 1077 1077 1078 - if (ieee80211_is_beacon(hdr->frame_control) && 1079 - !is_zero_ether_addr(common->curbssid) && 1080 - ether_addr_equal_64bits(hdr->addr3, common->curbssid)) { 1078 + if (ath_is_mybeacon(common, hdr)) { 1081 1079 s8 rssi = rxbuf->rxstatus.rs_rssi; 1082 1080 1083 1081 if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
-1
drivers/net/wireless/ath/ath9k/init.c
··· 946 946 947 947 hw->queues = 4; 948 948 hw->max_rates = 4; 949 - hw->channel_change_time = 5000; 950 949 hw->max_listen_interval = 1; 951 950 hw->max_rate_tries = 10; 952 951 hw->sta_data_size = sizeof(struct ath_node);
+33 -7
drivers/net/wireless/ath/ath9k/main.c
··· 258 258 } 259 259 } 260 260 261 + sc->gtt_cnt = 0; 261 262 ieee80211_wake_queues(sc->hw); 262 263 263 264 return true; ··· 477 476 } 478 477 } 479 478 479 + if (status & ATH9K_INT_GTT) { 480 + sc->gtt_cnt++; 481 + 482 + if ((sc->gtt_cnt >= MAX_GTT_CNT) && !ath9k_hw_check_alive(ah)) { 483 + type = RESET_TYPE_TX_GTT; 484 + ath9k_queue_reset(sc, type); 485 + atomic_inc(&ah->intr_ref_cnt); 486 + ath_dbg(common, ANY, 487 + "GTT: Skipping interrupts\n"); 488 + goto out; 489 + } 490 + } 491 + 480 492 spin_lock_irqsave(&sc->sc_pm_lock, flags); 481 493 if ((status & ATH9K_INT_TSFOOR) && sc->ps_enabled) { 482 494 /* ··· 517 503 } 518 504 519 505 if (status & ATH9K_INT_TX) { 520 - if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) 506 + if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { 507 + /* 508 + * For EDMA chips, TX completion is enabled for the 509 + * beacon queue, so if a beacon has been transmitted 510 + * successfully after a GTT interrupt, the GTT counter 511 + * gets reset to zero here. 512 + */ 513 + /* sc->gtt_cnt = 0; */ 514 + 521 515 ath_tx_edma_tasklet(sc); 522 - else 516 + } else { 523 517 ath_tx_tasklet(sc); 518 + } 524 519 525 520 wake_up(&sc->tx_wait); 526 521 } ··· 559 536 ATH9K_INT_TX | \ 560 537 ATH9K_INT_BMISS | \ 561 538 ATH9K_INT_CST | \ 539 + ATH9K_INT_GTT | \ 562 540 ATH9K_INT_TSFOOR | \ 563 541 ATH9K_INT_GENTIMER | \ 564 542 ATH9K_INT_MCI) 565 543 566 544 struct ath_softc *sc = dev; 567 545 struct ath_hw *ah = sc->sc_ah; 568 - struct ath_common *common = ath9k_hw_common(ah); 569 546 enum ath9k_int status; 570 547 u32 sync_cause = 0; 571 548 bool sched = false; ··· 626 603 #ifdef CONFIG_ATH9K_WOW 627 604 if (status & ATH9K_INT_BMISS) { 628 605 if (atomic_read(&sc->wow_sleep_proc_intr) == 0) { 629 - ath_dbg(common, ANY, "during WoW we got a BMISS\n"); 630 606 atomic_inc(&sc->wow_got_bmiss_intr); 631 607 atomic_dec(&sc->wow_sleep_proc_intr); 632 608 } 633 609 } 634 610 #endif 635 - 636 611 637 612 if (status & ATH9K_INT_SWBA) 638 613 tasklet_schedule(&sc->bcon_tasklet); ··· 756 735 if (ah->config.hw_hang_checks & HW_BB_WATCHDOG) 757 736 ah->imask |= ATH9K_INT_BB_WATCHDOG; 758 737 759 - ah->imask |= ATH9K_INT_GTT; 738 + /* 739 + * Enable GTT interrupts only for AR9003/AR9004 chips 740 + * for now. 741 + */ 742 + if (AR_SREV_9300_20_OR_LATER(ah)) 743 + ah->imask |= ATH9K_INT_GTT; 760 744 761 745 if (ah->caps.hw_caps & ATH9K_HW_CAP_HT) 762 746 ah->imask |= ATH9K_INT_CST; ··· 2137 2111 .get_et_strings = ath9k_get_et_strings, 2138 2112 #endif 2139 2113 2140 - #if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_ATH9K_DEBUGFS) 2114 + #if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_ATH9K_STATION_STATISTICS) 2141 2115 .sta_add_debugfs = ath9k_sta_add_debugfs, 2142 2116 #endif 2143 2117 .sw_scan_start = ath9k_sw_scan_start,
+5 -17
drivers/net/wireless/ath/ath9k/recv.c
··· 969 969 rxs->mactime += 0x100000000ULL; 970 970 } 971 971 972 - static bool ath9k_is_mybeacon(struct ath_softc *sc, struct ieee80211_hdr *hdr) 973 - { 974 - struct ath_hw *ah = sc->sc_ah; 975 - struct ath_common *common = ath9k_hw_common(ah); 976 - 977 - if (ieee80211_is_beacon(hdr->frame_control)) { 978 - RX_STAT_INC(rx_beacons); 979 - if (!is_zero_ether_addr(common->curbssid) && 980 - ether_addr_equal_64bits(hdr->addr3, common->curbssid)) 981 - return true; 982 - } 983 - 984 - return false; 985 - } 986 - 987 972 /* 988 973 * For Decrypt or Demic errors, we only mark packet status here and always push 989 974 * up the frame up to let mac80211 handle the actual error case, be it no ··· 1056 1071 goto exit; 1057 1072 } 1058 1073 1059 - rx_stats->is_mybeacon = ath9k_is_mybeacon(sc, hdr); 1074 + if (ath_is_mybeacon(common, hdr)) { 1075 + RX_STAT_INC(rx_beacons); 1076 + rx_stats->is_mybeacon = true; 1077 + } 1060 1078 1061 1079 /* 1062 1080 * This shouldn't happen, but have a safety check anyway. ··· 1342 1354 spin_unlock_irqrestore(&sc->sc_pm_lock, flags); 1343 1355 1344 1356 ath9k_antenna_check(sc, &rs); 1345 - 1346 1357 ath9k_apply_ampdu_details(sc, &rs, rxs); 1358 + ath_debug_rate_stats(sc, &rs, skb); 1347 1359 1348 1360 ieee80211_rx(hw, skb); 1349 1361
-2
drivers/net/wireless/ath/ath9k/xmit.c
··· 47 47 { 260, 540 }, /* 7: 64-QAM 5/6 */ 48 48 }; 49 49 50 - #define IS_HT_RATE(_rate) ((_rate) & 0x80) 51 - 52 50 static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq, 53 51 struct ath_atx_tid *tid, struct sk_buff *skb); 54 52 static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
-12
drivers/net/wireless/ath/carl9170/main.c
··· 1967 1967 return -ENOMEM; 1968 1968 ar->num_channels = chans; 1969 1969 1970 - /* 1971 - * I measured this, a bandswitch takes roughly 1972 - * 135 ms and a frequency switch about 80. 1973 - * 1974 - * FIXME: measure these values again once EEPROM settings 1975 - * are used, that will influence them! 1976 - */ 1977 - if (bands == 2) 1978 - ar->hw->channel_change_time = 135 * 1000; 1979 - else 1980 - ar->hw->channel_change_time = 80 * 1000; 1981 - 1982 1970 regulatory->current_rd = le16_to_cpu(ar->eeprom.reg_domain[0]); 1983 1971 1984 1972 /* second part of wiphy init */
+3 -6
drivers/net/wireless/ath/carl9170/rx.c
··· 519 519 { 520 520 struct ieee80211_hdr *hdr = data; 521 521 struct ieee80211_tim_ie *tim_ie; 522 + struct ath_common *common = &ar->common; 522 523 u8 *tim; 523 524 u8 tim_len; 524 525 bool cam; ··· 527 526 if (likely(!(ar->hw->conf.flags & IEEE80211_CONF_PS))) 528 527 return; 529 528 530 - /* check if this really is a beacon */ 531 - if (!ieee80211_is_beacon(hdr->frame_control)) 532 - return; 533 - 534 529 /* min. beacon length + FCS_LEN */ 535 530 if (len <= 40 + FCS_LEN) 536 531 return; 537 532 533 + /* check if this really is a beacon */ 538 534 /* and only beacons from the associated BSSID, please */ 539 - if (!ether_addr_equal_64bits(hdr->addr3, ar->common.curbssid) || 540 - !ar->common.curaid) 535 + if (!ath_is_mybeacon(common, hdr) || !common->curaid) 541 536 return; 542 537 543 538 ar->ps.last_beacon = jiffies;
+8
drivers/net/wireless/ath/main.c
··· 59 59 } 60 60 EXPORT_SYMBOL(ath_rxbuf_alloc); 61 61 62 + bool ath_is_mybeacon(struct ath_common *common, struct ieee80211_hdr *hdr) 63 + { 64 + return ieee80211_is_beacon(hdr->frame_control) && 65 + !is_zero_ether_addr(common->curbssid) && 66 + ether_addr_equal_64bits(hdr->addr3, common->curbssid); 67 + } 68 + EXPORT_SYMBOL(ath_is_mybeacon); 69 + 62 70 void ath_printk(const char *level, const struct ath_common* common, 63 71 const char *fmt, ...) 64 72 {
+4 -3
drivers/net/wireless/ath/regd.c
··· 632 632 const struct ieee80211_regdomain *regd; 633 633 634 634 wiphy->reg_notifier = reg_notifier; 635 - wiphy->regulatory_flags |= REGULATORY_STRICT_REG; 635 + wiphy->regulatory_flags |= REGULATORY_STRICT_REG | 636 + REGULATORY_CUSTOM_REG; 636 637 637 638 if (ath_is_world_regd(reg)) { 638 639 /* ··· 641 640 * saved on the wiphy orig_* parameters 642 641 */ 643 642 regd = ath_world_regdomain(reg); 644 - wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG | 645 - REGULATORY_COUNTRY_IE_FOLLOW_POWER; 643 + wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_FOLLOW_POWER; 646 644 } else { 647 645 /* 648 646 * This gets applied in the case of the absence of CRDA, ··· 650 650 */ 651 651 regd = ath_default_world_regdomain(); 652 652 } 653 + 653 654 wiphy_apply_custom_regulatory(wiphy, regd); 654 655 ath_reg_apply_radar_flags(wiphy); 655 656 ath_reg_apply_world_flags(wiphy, NL80211_REGDOM_SET_BY_DRIVER, reg);
+1 -1
drivers/net/wireless/ath/wil6210/txrx.c
··· 21 21 #include <linux/ip.h> 22 22 #include <linux/ipv6.h> 23 23 #include <net/ipv6.h> 24 - #include <asm/processor.h> 24 + #include <linux/prefetch.h> 25 25 26 26 #include "wil6210.h" 27 27 #include "wmi.h"
+2 -2
drivers/net/wireless/b43/b43.h
··· 731 731 struct b43_request_fw_context { 732 732 /* The device we are requesting the fw for. */ 733 733 struct b43_wldev *dev; 734 - /* a completion event structure needed if this call is asynchronous */ 735 - struct completion fw_load_complete; 736 734 /* a pointer to the firmware object */ 737 735 const struct firmware *blob; 738 736 /* The type of firmware to request. */ ··· 807 809 struct b43_wldev { 808 810 struct b43_bus_dev *dev; 809 811 struct b43_wl *wl; 812 + /* a completion event structure needed if this call is asynchronous */ 813 + struct completion fw_load_complete; 810 814 811 815 /* The device initialization status. 812 816 * Use b43_status() to query. */
+16 -11
drivers/net/wireless/b43/main.c
··· 2070 2070 2071 2071 static void b43_release_firmware(struct b43_wldev *dev) 2072 2072 { 2073 + complete(&dev->fw_load_complete); 2073 2074 b43_do_release_fw(&dev->fw.ucode); 2074 2075 b43_do_release_fw(&dev->fw.pcm); 2075 2076 b43_do_release_fw(&dev->fw.initvals); ··· 2096 2095 struct b43_request_fw_context *ctx = context; 2097 2096 2098 2097 ctx->blob = firmware; 2099 - complete(&ctx->fw_load_complete); 2098 + complete(&ctx->dev->fw_load_complete); 2100 2099 } 2101 2100 2102 2101 int b43_do_request_fw(struct b43_request_fw_context *ctx, ··· 2143 2142 } 2144 2143 if (async) { 2145 2144 /* do this part asynchronously */ 2146 - init_completion(&ctx->fw_load_complete); 2145 + init_completion(&ctx->dev->fw_load_complete); 2147 2146 err = request_firmware_nowait(THIS_MODULE, 1, ctx->fwname, 2148 2147 ctx->dev->dev->dev, GFP_KERNEL, 2149 2148 ctx, b43_fw_cb); ··· 2151 2150 pr_err("Unable to load firmware\n"); 2152 2151 return err; 2153 2152 } 2154 - /* stall here until fw ready */ 2155 - wait_for_completion(&ctx->fw_load_complete); 2153 + wait_for_completion(&ctx->dev->fw_load_complete); 2156 2154 if (ctx->blob) 2157 2155 goto fw_ready; 2158 2156 /* On some ARM systems, the async request will fail, but the next sync 2159 - * request works. For this reason, we dall through here 2157 + * request works. For this reason, we fall through here 2160 2158 */ 2161 2159 } 2162 2160 err = request_firmware(&ctx->blob, ctx->fwname, ··· 2424 2424 2425 2425 static int b43_one_core_attach(struct b43_bus_dev *dev, struct b43_wl *wl); 2426 2426 static void b43_one_core_detach(struct b43_bus_dev *dev); 2427 + static int b43_rng_init(struct b43_wl *wl); 2427 2428 2428 2429 static void b43_request_firmware(struct work_struct *work) 2429 2430 { ··· 2476 2475 goto err_one_core_detach; 2477 2476 wl->hw_registred = true; 2478 2477 b43_leds_register(wl->current_dev); 2478 + 2479 + /* Register HW RNG driver */ 2480 + b43_rng_init(wl); 2481 + 2479 2482 goto out; 2480 2483 2481 2484 err_one_core_detach: ··· 4641 4636 if (!dev || b43_status(dev) != B43_STAT_INITIALIZED) 4642 4637 return; 4643 4638 4644 - /* Unregister HW RNG driver */ 4645 - b43_rng_exit(dev->wl); 4646 - 4647 4639 b43_set_status(dev, B43_STAT_UNINIT); 4648 4640 4649 4641 /* Stop the microcode PSM. */ ··· 4796 4794 ieee80211_wake_queues(dev->wl->hw); 4797 4795 4798 4796 b43_set_status(dev, B43_STAT_INITIALIZED); 4799 - 4800 - /* Register HW RNG driver */ 4801 - b43_rng_init(dev->wl); 4802 4797 4803 4798 out: 4804 4799 return err; ··· 5463 5464 5464 5465 b43_one_core_detach(wldev->dev); 5465 5466 5467 + /* Unregister HW RNG driver */ 5468 + b43_rng_exit(wl); 5469 + 5466 5470 b43_leds_unregister(wl); 5467 5471 5468 5472 ieee80211_free_hw(wl->hw); ··· 5542 5540 } 5543 5541 5544 5542 b43_one_core_detach(dev); 5543 + 5544 + /* Unregister HW RNG driver */ 5545 + b43_rng_exit(wl); 5545 5546 5546 5547 if (list_empty(&wl->devlist)) { 5547 5548 b43_leds_unregister(wl);
+1
drivers/net/wireless/b43legacy/main.c
··· 3919 3919 * as the ieee80211 unreg will destroy the workqueue. */ 3920 3920 cancel_work_sync(&wldev->restart_work); 3921 3921 cancel_work_sync(&wl->firmware_load); 3922 + complete(&wldev->fw_load_complete); 3922 3923 3923 3924 B43legacy_WARN_ON(!wl); 3924 3925 if (!wldev->fw.ucode)
+1
drivers/net/wireless/brcm80211/brcmfmac/Makefile
··· 32 32 bcdc.o \ 33 33 dhd_common.o \ 34 34 dhd_linux.o \ 35 + nvram.o \ 35 36 btcoex.o 36 37 brcmfmac-$(CONFIG_BRCMFMAC_SDIO) += \ 37 38 dhd_sdio.o \
+26 -14
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
··· 287 287 s32 retry = 0; 288 288 int ret; 289 289 290 + if (sdiodev->bus_if->state == BRCMF_BUS_NOMEDIUM) 291 + return -ENOMEDIUM; 292 + 290 293 /* 291 294 * figure out how to read the register based on address range 292 295 * 0x00 ~ 0x7FF: function 0 CCCR and FBR ··· 309 306 usleep_range(1000, 2000); 310 307 ret = brcmf_sdiod_request_data(sdiodev, func_num, addr, regsz, 311 308 data, write); 312 - } while (ret != 0 && retry++ < SDIOH_API_ACCESS_RETRY_LIMIT); 309 + } while (ret != 0 && ret != -ENOMEDIUM && 310 + retry++ < SDIOH_API_ACCESS_RETRY_LIMIT); 313 311 314 - if (ret != 0) 312 + if (ret == -ENOMEDIUM) 313 + brcmf_bus_change_state(sdiodev->bus_if, BRCMF_BUS_NOMEDIUM); 314 + else if (ret != 0) 315 315 brcmf_err("failed with %d\n", ret); 316 316 317 317 return ret; ··· 325 319 { 326 320 int err = 0, i; 327 321 u8 addr[3]; 322 + 323 + if (sdiodev->bus_if->state == BRCMF_BUS_NOMEDIUM) 324 + return -ENOMEDIUM; 328 325 329 326 addr[0] = (address >> 8) & SBSDIO_SBADDRLOW_MASK; 330 327 addr[1] = (address >> 16) & SBSDIO_SBADDRMID_MASK; ··· 438 429 bool write, u32 addr, struct sk_buff *pkt) 439 430 { 440 431 unsigned int req_sz; 432 + int err; 441 433 442 434 brcmf_sdiod_pm_resume_wait(sdiodev, &sdiodev->request_buffer_wait); 443 435 if (brcmf_sdiod_pm_resume_error(sdiodev)) ··· 449 439 req_sz &= (uint)~3; 450 440 451 441 if (write) 452 - return sdio_memcpy_toio(sdiodev->func[fn], addr, 453 - ((u8 *)(pkt->data)), 454 - req_sz); 442 + err = sdio_memcpy_toio(sdiodev->func[fn], addr, 443 + ((u8 *)(pkt->data)), req_sz); 455 444 else if (fn == 1) 456 - return sdio_memcpy_fromio(sdiodev->func[fn], 457 - ((u8 *)(pkt->data)), 458 - addr, req_sz); 445 + err = sdio_memcpy_fromio(sdiodev->func[fn], ((u8 *)(pkt->data)), 446 + addr, req_sz); 459 447 else 460 448 /* function 2 read is FIFO operation */ 461 - return sdio_readsb(sdiodev->func[fn], 462 - ((u8 *)(pkt->data)), addr, 463 - req_sz); 449 + err = sdio_readsb(sdiodev->func[fn], ((u8 *)(pkt->data)), addr, 450 + req_sz); 451 + if (err == -ENOMEDIUM) 452 + brcmf_bus_change_state(sdiodev->bus_if, BRCMF_BUS_NOMEDIUM); 453 + return err; 464 454 } 465 455 466 456 /** ··· 603 593 mmc_wait_for_req(sdiodev->func[fn]->card->host, &mmc_req); 604 594 605 595 ret = mmc_cmd.error ? mmc_cmd.error : mmc_dat.error; 606 - if (ret != 0) { 596 + if (ret == -ENOMEDIUM) { 597 + brcmf_bus_change_state(sdiodev->bus_if, 598 + BRCMF_BUS_NOMEDIUM); 599 + break; 600 + } else if (ret != 0) { 607 601 brcmf_err("CMD53 sg block %s failed %d\n", 608 602 write ? "write" : "read", ret); 609 603 ret = -EIO; ··· 866 852 867 853 static int brcmf_sdiod_remove(struct brcmf_sdio_dev *sdiodev) 868 854 { 869 - sdiodev->bus_if->state = BRCMF_BUS_DOWN; 870 - 871 855 if (sdiodev->bus) { 872 856 brcmf_sdio_remove(sdiodev->bus); 873 857 sdiodev->bus = NULL;
+21
drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h
··· 17 17 #ifndef _BRCMF_BUS_H_ 18 18 #define _BRCMF_BUS_H_ 19 19 20 + #include "dhd_dbg.h" 21 + 20 22 /* The level of bus communication with the dongle */ 21 23 enum brcmf_bus_state { 24 + BRCMF_BUS_UNKNOWN, /* Not determined yet */ 25 + BRCMF_BUS_NOMEDIUM, /* No medium access to dongle */ 22 26 BRCMF_BUS_DOWN, /* Not ready for frame transfers */ 23 27 BRCMF_BUS_LOAD, /* Download access only (CPU reset) */ 24 28 BRCMF_BUS_DATA /* Ready for frame transfers */ ··· 148 144 149 145 return bus->ops->gettxq(bus->dev); 150 146 } 147 + 148 + static inline bool brcmf_bus_ready(struct brcmf_bus *bus) 149 + { 150 + return bus->state == BRCMF_BUS_LOAD || bus->state == BRCMF_BUS_DATA; 151 + } 152 + 153 + static inline void brcmf_bus_change_state(struct brcmf_bus *bus, 154 + enum brcmf_bus_state new_state) 155 + { 156 + /* NOMEDIUM is permanent */ 157 + if (bus->state == BRCMF_BUS_NOMEDIUM) 158 + return; 159 + 160 + brcmf_dbg(TRACE, "%d -> %d\n", bus->state, new_state); 161 + bus->state = new_state; 162 + } 163 + 151 164 /* 152 165 * interface functions from common layer 153 166 */
+3 -1
drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
··· 934 934 p2p_ifp = NULL; 935 935 936 936 /* signal bus ready */ 937 - bus_if->state = BRCMF_BUS_DATA; 937 + brcmf_bus_change_state(bus_if, BRCMF_BUS_DATA); 938 938 939 939 /* Bus is ready, do any initialization */ 940 940 ret = brcmf_c_preinit_dcmds(ifp); ··· 1028 1028 1029 1029 /* stop firmware event handling */ 1030 1030 brcmf_fweh_detach(drvr); 1031 + 1032 + brcmf_bus_change_state(bus_if, BRCMF_BUS_DOWN); 1031 1033 1032 1034 /* make sure primary interface removed last */ 1033 1035 for (i = BRCMF_MAX_IFS-1; i > -1; i--)
+150 -187
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
··· 41 41 #include <soc.h> 42 42 #include "sdio_host.h" 43 43 #include "sdio_chip.h" 44 + #include "nvram.h" 44 45 45 46 #define DCMD_RESP_TIMEOUT 2000 /* In milli second */ 46 47 ··· 369 368 /* Private data for SDIO bus interaction */ 370 369 struct brcmf_sdio { 371 370 struct brcmf_sdio_dev *sdiodev; /* sdio device handler */ 372 - struct chip_info *ci; /* Chip info struct */ 373 - char *vars; /* Variables (from CIS and/or other) */ 374 - uint varsz; /* Size of variables buffer */ 371 + struct brcmf_chip *ci; /* Chip info struct */ 375 372 376 373 u32 ramsize; /* Size of RAM in SOCRAM (bytes) */ 377 374 ··· 1082 1083 1083 1084 /* Clear partial in any case */ 1084 1085 bus->cur_read.len = 0; 1085 - 1086 - /* If we can't reach the device, signal failure */ 1087 - if (err) 1088 - bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN; 1089 1086 } 1090 1087 1091 1088 /* return total length of buffer chain */ ··· 1678 1683 bus->rxpending = true; 1679 1684 1680 1685 for (rd->seq_num = bus->rx_seq, rxleft = maxframes; 1681 - !bus->rxskip && rxleft && 1682 - bus->sdiodev->bus_if->state != BRCMF_BUS_DOWN; 1686 + !bus->rxskip && rxleft && brcmf_bus_ready(bus->sdiodev->bus_if); 1683 1687 rd->seq_num++, rxleft--) { 1684 1688 1685 1689 /* Handle glomming separately */ ··· 2227 2233 bus->watchdog_tsk = NULL; 2228 2234 } 2229 2235 2230 - sdio_claim_host(bus->sdiodev->func[1]); 2236 + if (bus_if->state == BRCMF_BUS_DOWN) { 2237 + sdio_claim_host(sdiodev->func[1]); 2231 2238 2232 - /* Enable clock for device interrupts */ 2233 - brcmf_sdio_bus_sleep(bus, false, false); 2239 + /* Enable clock for device interrupts */ 2240 + brcmf_sdio_bus_sleep(bus, false, false); 2234 2241 2235 - /* Disable and clear interrupts at the chip level also */ 2236 - w_sdreg32(bus, 0, offsetof(struct sdpcmd_regs, hostintmask)); 2237 - local_hostintmask = bus->hostintmask; 2238 - bus->hostintmask = 0; 2242 + /* Disable and clear interrupts at the chip level also */ 2243 + w_sdreg32(bus, 0, offsetof(struct sdpcmd_regs, hostintmask)); 2244 + local_hostintmask = bus->hostintmask; 2245 + bus->hostintmask = 0; 2239 2246 2240 - /* Change our idea of bus state */ 2241 - bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN; 2247 + /* Force backplane clocks to assure F2 interrupt propagates */ 2248 + saveclk = brcmf_sdiod_regrb(sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, 2249 + &err); 2250 + if (!err) 2251 + brcmf_sdiod_regwb(sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, 2252 + (saveclk | SBSDIO_FORCE_HT), &err); 2253 + if (err) 2254 + brcmf_err("Failed to force clock for F2: err %d\n", 2255 + err); 2242 2256 2243 - /* Force clocks on backplane to be sure F2 interrupt propagates */ 2244 - saveclk = brcmf_sdiod_regrb(bus->sdiodev, 2245 - SBSDIO_FUNC1_CHIPCLKCSR, &err); 2246 - if (!err) { 2247 - brcmf_sdiod_regwb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, 2248 - (saveclk | SBSDIO_FORCE_HT), &err); 2257 + /* Turn off the bus (F2), free any pending packets */ 2258 + brcmf_dbg(INTR, "disable SDIO interrupts\n"); 2259 + sdio_disable_func(sdiodev->func[SDIO_FUNC_2]); 2260 + 2261 + /* Clear any pending interrupts now that F2 is disabled */ 2262 + w_sdreg32(bus, local_hostintmask, 2263 + offsetof(struct sdpcmd_regs, intstatus)); 2264 + 2265 + sdio_release_host(sdiodev->func[1]); 2249 2266 } 2250 - if (err) 2251 - brcmf_err("Failed to force clock for F2: err %d\n", err); 2252 - 2253 - /* Turn off the bus (F2), free any pending packets */ 2254 - brcmf_dbg(INTR, "disable SDIO interrupts\n"); 2255 - sdio_disable_func(bus->sdiodev->func[SDIO_FUNC_2]); 2256 - 2257 - /* Clear any pending interrupts now that F2 is disabled */ 2258 - w_sdreg32(bus, local_hostintmask, 2259 - offsetof(struct sdpcmd_regs, intstatus)); 2260 - 2261 - /* Turn off the backplane clock (only) */ 2262 - brcmf_sdio_clkctl(bus, CLK_SDONLY, false); 2263 - sdio_release_host(bus->sdiodev->func[1]); 2264 - 2265 2267 /* Clear the data packet queues */ 2266 2268 brcmu_pktq_flush(&bus->txq, true, NULL, NULL); 2267 2269 ··· 2347 2357 /* Check for inconsistent device control */ 2348 2358 devctl = brcmf_sdiod_regrb(bus->sdiodev, 2349 2359 SBSDIO_DEVICE_CTL, &err); 2350 - if (err) { 2351 - brcmf_err("error reading DEVCTL: %d\n", err); 2352 - bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN; 2353 - } 2354 2360 #endif /* DEBUG */ 2355 2361 2356 2362 /* Read CSR, if clock on switch to AVAIL, else ignore */ 2357 2363 clkctl = brcmf_sdiod_regrb(bus->sdiodev, 2358 2364 SBSDIO_FUNC1_CHIPCLKCSR, &err); 2359 - if (err) { 2360 - brcmf_err("error reading CSR: %d\n", 2361 - err); 2362 - bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN; 2363 - } 2364 2365 2365 2366 brcmf_dbg(SDIO, "DPC: PENDING, devctl 0x%02x clkctl 0x%02x\n", 2366 2367 devctl, clkctl); ··· 2359 2378 if (SBSDIO_HTAV(clkctl)) { 2360 2379 devctl = brcmf_sdiod_regrb(bus->sdiodev, 2361 2380 SBSDIO_DEVICE_CTL, &err); 2362 - if (err) { 2363 - brcmf_err("error reading DEVCTL: %d\n", 2364 - err); 2365 - bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN; 2366 - } 2367 2381 devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY; 2368 2382 brcmf_sdiod_regwb(bus->sdiodev, SBSDIO_DEVICE_CTL, 2369 2383 devctl, &err); 2370 - if (err) { 2371 - brcmf_err("error writing DEVCTL: %d\n", 2372 - err); 2373 - bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN; 2374 - } 2375 2384 bus->clkstate = CLK_AVAIL; 2376 2385 } 2377 2386 } ··· 2496 2525 txlimit -= framecnt; 2497 2526 } 2498 2527 2499 - if ((bus->sdiodev->bus_if->state == BRCMF_BUS_DOWN) || (err != 0)) { 2528 + if (!brcmf_bus_ready(bus->sdiodev->bus_if) || (err != 0)) { 2500 2529 brcmf_err("failed backplane access over SDIO, halting operation\n"); 2501 - bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN; 2502 2530 atomic_set(&bus->intstatus, 0); 2503 2531 } else if (atomic_read(&bus->intstatus) || 2504 2532 atomic_read(&bus->ipend) > 0 || ··· 3165 3195 return rxlen ? (int)rxlen : -ETIMEDOUT; 3166 3196 } 3167 3197 3168 - static bool brcmf_sdio_download_state(struct brcmf_sdio *bus, bool enter) 3198 + #ifdef DEBUG 3199 + static bool 3200 + brcmf_sdio_verifymemory(struct brcmf_sdio_dev *sdiodev, u32 ram_addr, 3201 + u8 *ram_data, uint ram_sz) 3169 3202 { 3170 - struct chip_info *ci = bus->ci; 3203 + char *ram_cmp; 3204 + int err; 3205 + bool ret = true; 3206 + int address; 3207 + int offset; 3208 + int len; 3171 3209 3172 - /* To enter download state, disable ARM and reset SOCRAM. 3173 - * To exit download state, simply reset ARM (default is RAM boot). 3174 - */ 3175 - if (enter) { 3176 - bus->alp_only = true; 3210 + /* read back and verify */ 3211 + brcmf_dbg(INFO, "Compare RAM dl & ul at 0x%08x; size=%d\n", ram_addr, 3212 + ram_sz); 3213 + ram_cmp = kmalloc(MEMBLOCK, GFP_KERNEL); 3214 + /* do not proceed while no memory but */ 3215 + if (!ram_cmp) 3216 + return true; 3177 3217 3178 - brcmf_sdio_chip_enter_download(bus->sdiodev, ci); 3179 - } else { 3180 - if (!brcmf_sdio_chip_exit_download(bus->sdiodev, ci, bus->vars, 3181 - bus->varsz)) 3182 - return false; 3183 - 3184 - /* Allow HT Clock now that the ARM is running. */ 3185 - bus->alp_only = false; 3186 - 3187 - bus->sdiodev->bus_if->state = BRCMF_BUS_LOAD; 3218 + address = ram_addr; 3219 + offset = 0; 3220 + while (offset < ram_sz) { 3221 + len = ((offset + MEMBLOCK) < ram_sz) ? MEMBLOCK : 3222 + ram_sz - offset; 3223 + err = brcmf_sdiod_ramrw(sdiodev, false, address, ram_cmp, len); 3224 + if (err) { 3225 + brcmf_err("error %d on reading %d membytes at 0x%08x\n", 3226 + err, len, address); 3227 + ret = false; 3228 + break; 3229 + } else if (memcmp(ram_cmp, &ram_data[offset], len)) { 3230 + brcmf_err("Downloaded RAM image is corrupted, block offset is %d, len is %d\n", 3231 + offset, len); 3232 + ret = false; 3233 + break; 3234 + } 3235 + offset += len; 3236 + address += len; 3188 3237 } 3189 3238 3239 + kfree(ram_cmp); 3240 + 3241 + return ret; 3242 + } 3243 + #else /* DEBUG */ 3244 + static bool 3245 + brcmf_sdio_verifymemory(struct brcmf_sdio_dev *sdiodev, u32 ram_addr, 3246 + u8 *ram_data, uint ram_sz) 3247 + { 3190 3248 return true; 3191 3249 } 3250 + #endif /* DEBUG */ 3192 3251 3193 - static int brcmf_sdio_download_code_file(struct brcmf_sdio *bus) 3252 + static int brcmf_sdio_download_code_file(struct brcmf_sdio *bus, 3253 + const struct firmware *fw) 3194 3254 { 3195 - const struct firmware *fw; 3196 3255 int err; 3197 3256 int offset; 3198 3257 int address; 3199 3258 int len; 3200 3259 3201 - fw = brcmf_sdio_get_fw(bus, BRCMF_FIRMWARE_BIN); 3202 - if (fw == NULL) 3203 - return -ENOENT; 3204 - 3205 - if (brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_ARM_CR4) != 3206 - BRCMF_MAX_CORENUM) 3207 - memcpy(&bus->ci->rst_vec, fw->data, sizeof(bus->ci->rst_vec)); 3260 + brcmf_dbg(TRACE, "Enter\n"); 3208 3261 3209 3262 err = 0; 3210 3263 offset = 0; ··· 3240 3247 if (err) { 3241 3248 brcmf_err("error %d on writing %d membytes at 0x%08x\n", 3242 3249 err, len, address); 3243 - goto failure; 3250 + return err; 3244 3251 } 3245 3252 offset += len; 3246 3253 address += len; 3247 3254 } 3248 - 3249 - failure: 3250 - release_firmware(fw); 3255 + if (!err) 3256 + if (!brcmf_sdio_verifymemory(bus->sdiodev, bus->ci->rambase, 3257 + (u8 *)fw->data, fw->size)) 3258 + err = -EIO; 3251 3259 3252 3260 return err; 3253 3261 } 3254 3262 3255 - /* 3256 - * ProcessVars:Takes a buffer of "<var>=<value>\n" lines read from a file 3257 - * and ending in a NUL. 3258 - * Removes carriage returns, empty lines, comment lines, and converts 3259 - * newlines to NULs. 3260 - * Shortens buffer as needed and pads with NULs. End of buffer is marked 3261 - * by two NULs. 3262 - */ 3263 - 3264 - static int brcmf_sdio_strip_nvram(struct brcmf_sdio *bus, 3265 - const struct firmware *nv) 3263 + static int brcmf_sdio_download_nvram(struct brcmf_sdio *bus, 3264 + const struct firmware *nv) 3266 3265 { 3267 - char *varbuf; 3268 - char *dp; 3269 - bool findNewline; 3270 - int column; 3271 - int ret = 0; 3272 - uint buf_len, n, len; 3266 + void *vars; 3267 + u32 varsz; 3268 + int address; 3269 + int err; 3273 3270 3274 - len = nv->size; 3275 - varbuf = vmalloc(len); 3276 - if (!varbuf) 3277 - return -ENOMEM; 3271 + brcmf_dbg(TRACE, "Enter\n"); 3278 3272 3279 - memcpy(varbuf, nv->data, len); 3280 - dp = varbuf; 3273 + vars = brcmf_nvram_strip(nv, &varsz); 3281 3274 3282 - findNewline = false; 3283 - column = 0; 3275 + if (vars == NULL) 3276 + return -EINVAL; 3284 3277 3285 - for (n = 0; n < len; n++) { 3286 - if (varbuf[n] == 0) 3287 - break; 3288 - if (varbuf[n] == '\r') 3289 - continue; 3290 - if (findNewline && varbuf[n] != '\n') 3291 - continue; 3292 - findNewline = false; 3293 - if (varbuf[n] == '#') { 3294 - findNewline = true; 3295 - continue; 3296 - } 3297 - if (varbuf[n] == '\n') { 3298 - if (column == 0) 3299 - continue; 3300 - *dp++ = 0; 3301 - column = 0; 3302 - continue; 3303 - } 3304 - *dp++ = varbuf[n]; 3305 - column++; 3306 - } 3307 - buf_len = dp - varbuf; 3308 - while (dp < varbuf + n) 3309 - *dp++ = 0; 3278 + address = bus->ci->ramsize - varsz + bus->ci->rambase; 3279 + err = brcmf_sdiod_ramrw(bus->sdiodev, true, address, vars, varsz); 3280 + if (err) 3281 + brcmf_err("error %d on writing %d nvram bytes at 0x%08x\n", 3282 + err, varsz, address); 3283 + else if (!brcmf_sdio_verifymemory(bus->sdiodev, address, vars, varsz)) 3284 + err = -EIO; 3310 3285 3311 - kfree(bus->vars); 3312 - /* roundup needed for download to device */ 3313 - bus->varsz = roundup(buf_len + 1, 4); 3314 - bus->vars = kmalloc(bus->varsz, GFP_KERNEL); 3315 - if (bus->vars == NULL) { 3316 - bus->varsz = 0; 3317 - ret = -ENOMEM; 3318 - goto err; 3319 - } 3286 + brcmf_nvram_free(vars); 3320 3287 3321 - /* copy the processed variables and add null termination */ 3322 - memcpy(bus->vars, varbuf, buf_len); 3323 - bus->vars[buf_len] = 0; 3324 - err: 3325 - vfree(varbuf); 3326 - return ret; 3327 - } 3328 - 3329 - static int brcmf_sdio_download_nvram(struct brcmf_sdio *bus) 3330 - { 3331 - const struct firmware *nv; 3332 - int ret; 3333 - 3334 - nv = brcmf_sdio_get_fw(bus, BRCMF_FIRMWARE_NVRAM); 3335 - if (nv == NULL) 3336 - return -ENOENT; 3337 - 3338 - ret = brcmf_sdio_strip_nvram(bus, nv); 3339 - 3340 - release_firmware(nv); 3341 - 3342 - return ret; 3288 + return err; 3343 3289 } 3344 3290 3345 3291 static int brcmf_sdio_download_firmware(struct brcmf_sdio *bus) 3346 3292 { 3347 3293 int bcmerror = -EFAULT; 3348 - 3294 + const struct firmware *fw; 3295 + u32 rstvec; 3349 3296 3350 3297 sdio_claim_host(bus->sdiodev->func[1]); 3351 3298 brcmf_sdio_clkctl(bus, CLK_AVAIL, false); 3352 3299 3353 3300 /* Keep arm in reset */ 3354 - if (!brcmf_sdio_download_state(bus, true)) { 3355 - brcmf_err("error placing ARM core in reset\n"); 3301 + brcmf_sdio_chip_enter_download(bus->sdiodev, bus->ci); 3302 + 3303 + fw = brcmf_sdio_get_fw(bus, BRCMF_FIRMWARE_BIN); 3304 + if (fw == NULL) { 3305 + bcmerror = -ENOENT; 3356 3306 goto err; 3357 3307 } 3358 3308 3359 - if (brcmf_sdio_download_code_file(bus)) { 3309 + rstvec = get_unaligned_le32(fw->data); 3310 + brcmf_dbg(SDIO, "firmware rstvec: %x\n", rstvec); 3311 + 3312 + bcmerror = brcmf_sdio_download_code_file(bus, fw); 3313 + release_firmware(fw); 3314 + if (bcmerror) { 3360 3315 brcmf_err("dongle image file download failed\n"); 3361 3316 goto err; 3362 3317 } 3363 3318 3364 - if (brcmf_sdio_download_nvram(bus)) { 3319 + fw = brcmf_sdio_get_fw(bus, BRCMF_FIRMWARE_NVRAM); 3320 + if (fw == NULL) { 3321 + bcmerror = -ENOENT; 3322 + goto err; 3323 + } 3324 + 3325 + bcmerror = brcmf_sdio_download_nvram(bus, fw); 3326 + release_firmware(fw); 3327 + if (bcmerror) { 3365 3328 brcmf_err("dongle nvram file download failed\n"); 3366 3329 goto err; 3367 3330 } 3368 3331 3369 3332 /* Take arm out of reset */ 3370 - if (!brcmf_sdio_download_state(bus, false)) { 3333 + if (!brcmf_sdio_chip_exit_download(bus->sdiodev, bus->ci, rstvec)) { 3371 3334 brcmf_err("error getting out of ARM core reset\n"); 3372 3335 goto err; 3373 3336 } 3374 3337 3338 + /* Allow HT Clock now that the ARM is running. */ 3339 + brcmf_bus_change_state(bus->sdiodev->bus_if, BRCMF_BUS_LOAD); 3375 3340 bcmerror = 0; 3376 3341 3377 3342 err: ··· 3518 3567 3519 3568 /* try to download image and nvram to the dongle */ 3520 3569 if (bus_if->state == BRCMF_BUS_DOWN) { 3570 + bus->alp_only = true; 3521 3571 err = brcmf_sdio_download_firmware(bus); 3522 3572 if (err) 3523 3573 return err; 3574 + bus->alp_only = false; 3524 3575 } 3525 3576 3526 3577 if (!bus->sdiodev->bus_if->drvr) ··· 3606 3653 return; 3607 3654 } 3608 3655 3609 - if (bus->sdiodev->bus_if->state == BRCMF_BUS_DOWN) { 3656 + if (!brcmf_bus_ready(bus->sdiodev->bus_if)) { 3610 3657 brcmf_err("bus is down. we have nothing to do\n"); 3611 3658 return; 3612 3659 } ··· 3617 3664 else 3618 3665 if (brcmf_sdio_intr_rstatus(bus)) { 3619 3666 brcmf_err("failed backplane access\n"); 3620 - bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN; 3621 3667 } 3622 3668 3623 3669 /* Disable additional interrupts (is this needed now)? */ ··· 3731 3779 u32 reg_val; 3732 3780 u32 drivestrength; 3733 3781 3734 - bus->alp_only = true; 3735 - 3736 3782 sdio_claim_host(bus->sdiodev->func[1]); 3737 3783 3738 3784 pr_debug("F1 signature read @0x18000000=0x%4x\n", ··· 3752 3802 err, BRCMF_INIT_CLKCTL1, clkctl); 3753 3803 goto fail; 3754 3804 } 3805 + 3806 + /* SDIO register access works so moving 3807 + * state from UNKNOWN to DOWN. 3808 + */ 3809 + brcmf_bus_change_state(bus->sdiodev->bus_if, BRCMF_BUS_DOWN); 3755 3810 3756 3811 if (brcmf_sdio_chip_attach(bus->sdiodev, &bus->ci)) { 3757 3812 brcmf_err("brcmf_sdio_chip_attach failed!\n"); ··· 3981 4026 /* Disable F2 to clear any intermediate frame state on the dongle */ 3982 4027 sdio_disable_func(bus->sdiodev->func[SDIO_FUNC_2]); 3983 4028 3984 - bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN; 3985 4029 bus->rxflow = false; 3986 4030 3987 4031 /* Done with backplane-dependent accesses, can drop clock... */ ··· 4036 4082 } 4037 4083 4038 4084 if (bus->ci) { 4039 - sdio_claim_host(bus->sdiodev->func[1]); 4040 - brcmf_sdio_clkctl(bus, CLK_AVAIL, false); 4041 - brcmf_sdio_clkctl(bus, CLK_NONE, false); 4042 - sdio_release_host(bus->sdiodev->func[1]); 4085 + if (bus->sdiodev->bus_if->state == BRCMF_BUS_DOWN) { 4086 + sdio_claim_host(bus->sdiodev->func[1]); 4087 + brcmf_sdio_clkctl(bus, CLK_AVAIL, false); 4088 + /* Leave the device in state where it is 4089 + * 'quiet'. This is done by putting it in 4090 + * download_state which essentially resets 4091 + * all necessary cores. 4092 + */ 4093 + msleep(20); 4094 + brcmf_sdio_chip_enter_download(bus->sdiodev, 4095 + bus->ci); 4096 + brcmf_sdio_clkctl(bus, CLK_NONE, false); 4097 + sdio_release_host(bus->sdiodev->func[1]); 4098 + } 4043 4099 brcmf_sdio_chip_detach(&bus->ci); 4044 4100 } 4045 4101 4046 4102 brcmu_pkt_buf_free_skb(bus->txglom_sgpad); 4047 4103 kfree(bus->rxbuf); 4048 4104 kfree(bus->hdrbuf); 4049 - kfree(bus->vars); 4050 4105 kfree(bus); 4051 4106 } 4052 4107
+94
drivers/net/wireless/brcm80211/brcmfmac/nvram.c
··· 1 + /* 2 + * Copyright (c) 2013 Broadcom Corporation 3 + * 4 + * Permission to use, copy, modify, and/or distribute this software for any 5 + * purpose with or without fee is hereby granted, provided that the above 6 + * copyright notice and this permission notice appear in all copies. 7 + * 8 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 11 + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 13 + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 14 + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 + */ 16 + 17 + #include <linux/kernel.h> 18 + #include <linux/slab.h> 19 + #include <linux/firmware.h> 20 + 21 + #include "nvram.h" 22 + 23 + /* brcmf_nvram_strip :Takes a buffer of "<var>=<value>\n" lines read from a file 24 + * and ending in a NUL. Removes carriage returns, empty lines, comment lines, 25 + * and converts newlines to NULs. Shortens buffer as needed and pads with NULs. 26 + * End of buffer is completed with token identifying length of buffer. 27 + */ 28 + void *brcmf_nvram_strip(const struct firmware *nv, u32 *new_length) 29 + { 30 + u8 *nvram; 31 + u32 i; 32 + u32 len; 33 + u32 column; 34 + u8 val; 35 + bool comment; 36 + u32 token; 37 + __le32 token_le; 38 + 39 + /* Alloc for extra 0 byte + roundup by 4 + length field */ 40 + nvram = kmalloc(nv->size + 1 + 3 + sizeof(token_le), GFP_KERNEL); 41 + if (!nvram) 42 + return NULL; 43 + 44 + len = 0; 45 + column = 0; 46 + comment = false; 47 + for (i = 0; i < nv->size; i++) { 48 + val = nv->data[i]; 49 + if (val == 0) 50 + break; 51 + if (val == '\r') 52 + continue; 53 + if (comment && (val != '\n')) 54 + continue; 55 + comment = false; 56 + if (val == '#') { 57 + comment = true; 58 + continue; 59 + } 60 + if (val == '\n') { 61 + if (column == 0) 62 + continue; 63 + nvram[len] = 0; 64 + len++; 65 + column = 0; 66 + continue; 67 + } 68 + nvram[len] = val; 69 + len++; 70 + column++; 71 + } 72 + column = len; 73 + *new_length = roundup(len + 1, 4); 74 + while (column != *new_length) { 75 + nvram[column] = 0; 76 + column++; 77 + } 78 + 79 + token = *new_length / 4; 80 + token = (~token << 16) | (token & 0x0000FFFF); 81 + token_le = cpu_to_le32(token); 82 + 83 + memcpy(&nvram[*new_length], &token_le, sizeof(token_le)); 84 + *new_length += sizeof(token_le); 85 + 86 + return nvram; 87 + } 88 + 89 + void brcmf_nvram_free(void *nvram) 90 + { 91 + kfree(nvram); 92 + } 93 + 94 +
+24
drivers/net/wireless/brcm80211/brcmfmac/nvram.h
··· 1 + /* 2 + * Copyright (c) 2013 Broadcom Corporation 3 + * 4 + * Permission to use, copy, modify, and/or distribute this software for any 5 + * purpose with or without fee is hereby granted, provided that the above 6 + * copyright notice and this permission notice appear in all copies. 7 + * 8 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 11 + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 13 + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 14 + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 + */ 16 + #ifndef BRCMFMAC_NVRAM_H 17 + #define BRCMFMAC_NVRAM_H 18 + 19 + 20 + void *brcmf_nvram_strip(const struct firmware *nv, u32 *new_length); 21 + void brcmf_nvram_free(void *nvram); 22 + 23 + 24 + #endif /* BRCMFMAC_NVRAM_H */
+268 -325
drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c
··· 51 51 #define BCM43143_CORE_ARM_BASE 0x18003000 52 52 #define BCM43143_RAMSIZE 0x70000 53 53 54 + /* All D11 cores, ID 0x812 */ 55 + #define BCM43xx_CORE_D11_BASE 0x18001000 56 + 54 57 #define SBCOREREV(sbidh) \ 55 58 ((((sbidh) & SSB_IDHIGH_RCHI) >> SSB_IDHIGH_RCHI_SHIFT) | \ 56 59 ((sbidh) & SSB_IDHIGH_RCLO)) ··· 68 65 69 66 /* ARM CR4 core specific control flag bits */ 70 67 #define ARMCR4_BCMA_IOCTL_CPUHALT 0x0020 68 + 69 + /* D11 core specific control flag bits */ 70 + #define D11_BCMA_IOCTL_PHYCLOCKEN 0x0004 71 + #define D11_BCMA_IOCTL_PHYRESET 0x0008 71 72 72 73 #define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu)) 73 74 /* SDIO Pad drive strength to select value mappings */ ··· 118 111 }; 119 112 120 113 u8 121 - brcmf_sdio_chip_getinfidx(struct chip_info *ci, u16 coreid) 114 + brcmf_sdio_chip_getinfidx(struct brcmf_chip *ci, u16 coreid) 122 115 { 123 116 u8 idx; 124 117 ··· 131 124 132 125 static u32 133 126 brcmf_sdio_sb_corerev(struct brcmf_sdio_dev *sdiodev, 134 - struct chip_info *ci, u16 coreid) 127 + struct brcmf_chip *ci, u16 coreid) 135 128 { 136 129 u32 regdata; 137 130 u8 idx; ··· 146 139 147 140 static u32 148 141 brcmf_sdio_ai_corerev(struct brcmf_sdio_dev *sdiodev, 149 - struct chip_info *ci, u16 coreid) 142 + struct brcmf_chip *ci, u16 coreid) 150 143 { 151 144 u8 idx; 152 145 ··· 157 150 158 151 static bool 159 152 brcmf_sdio_sb_iscoreup(struct brcmf_sdio_dev *sdiodev, 160 - struct chip_info *ci, u16 coreid) 153 + struct brcmf_chip *ci, u16 coreid) 161 154 { 162 155 u32 regdata; 163 156 u8 idx; ··· 176 169 177 170 static bool 178 171 brcmf_sdio_ai_iscoreup(struct brcmf_sdio_dev *sdiodev, 179 - struct chip_info *ci, u16 coreid) 172 + struct brcmf_chip *ci, u16 coreid) 180 173 { 181 174 u32 regdata; 182 175 u8 idx; ··· 200 193 201 194 static void 202 195 brcmf_sdio_sb_coredisable(struct brcmf_sdio_dev *sdiodev, 203 - struct chip_info *ci, u16 coreid, u32 core_bits) 196 + struct brcmf_chip *ci, u16 coreid, u32 pre_resetbits, 197 + u32 in_resetbits) 204 198 { 205 199 u32 regdata, base; 206 200 u8 idx; ··· 287 279 288 280 static void 289 281 brcmf_sdio_ai_coredisable(struct brcmf_sdio_dev *sdiodev, 290 - struct chip_info *ci, u16 coreid, u32 core_bits) 282 + struct brcmf_chip *ci, u16 coreid, u32 pre_resetbits, 283 + u32 in_resetbits) 291 284 { 292 285 u8 idx; 293 286 u32 regdata; 287 + u32 wrapbase; 294 288 295 289 idx = brcmf_sdio_chip_getinfidx(ci, coreid); 296 290 if (idx == BRCMF_MAX_CORENUM) 297 291 return; 298 292 293 + wrapbase = ci->c_inf[idx].wrapbase; 294 + 299 295 /* if core is already in reset, just return */ 300 - regdata = brcmf_sdiod_regrl(sdiodev, 301 - ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, 302 - NULL); 296 + regdata = brcmf_sdiod_regrl(sdiodev, wrapbase + BCMA_RESET_CTL, NULL); 303 297 if ((regdata & BCMA_RESET_CTL_RESET) != 0) 304 298 return; 305 299 306 - /* ensure no pending backplane operation 307 - * 300uc should be sufficient for backplane ops to be finish 308 - * extra 10ms is taken into account for firmware load stage 309 - * after 10300us carry on disabling the core anyway 310 - */ 311 - SPINWAIT(brcmf_sdiod_regrl(sdiodev, 312 - ci->c_inf[idx].wrapbase+BCMA_RESET_ST, 313 - NULL), 10300); 314 - regdata = brcmf_sdiod_regrl(sdiodev, 315 - ci->c_inf[idx].wrapbase+BCMA_RESET_ST, 316 - NULL); 317 - if (regdata) 318 - brcmf_err("disabling core 0x%x with reset status %x\n", 319 - coreid, regdata); 300 + /* configure reset */ 301 + brcmf_sdiod_regwl(sdiodev, wrapbase + BCMA_IOCTL, pre_resetbits | 302 + BCMA_IOCTL_FGC | BCMA_IOCTL_CLK, NULL); 303 + regdata = brcmf_sdiod_regrl(sdiodev, wrapbase + BCMA_IOCTL, NULL); 320 304 321 - brcmf_sdiod_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, 305 + /* put in reset */ 306 + brcmf_sdiod_regwl(sdiodev, wrapbase + BCMA_RESET_CTL, 322 307 BCMA_RESET_CTL_RESET, NULL); 323 - udelay(1); 324 - 325 - brcmf_sdiod_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 326 - core_bits, NULL); 327 - regdata = brcmf_sdiod_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 328 - NULL); 329 308 usleep_range(10, 20); 330 309 310 + /* wait till reset is 1 */ 311 + SPINWAIT(brcmf_sdiod_regrl(sdiodev, wrapbase + BCMA_RESET_CTL, NULL) != 312 + BCMA_RESET_CTL_RESET, 300); 313 + 314 + /* post reset configure */ 315 + brcmf_sdiod_regwl(sdiodev, wrapbase + BCMA_IOCTL, pre_resetbits | 316 + BCMA_IOCTL_FGC | BCMA_IOCTL_CLK, NULL); 317 + regdata = brcmf_sdiod_regrl(sdiodev, wrapbase + BCMA_IOCTL, NULL); 331 318 } 332 319 333 320 static void 334 321 brcmf_sdio_sb_resetcore(struct brcmf_sdio_dev *sdiodev, 335 - struct chip_info *ci, u16 coreid, u32 core_bits) 322 + struct brcmf_chip *ci, u16 coreid, u32 pre_resetbits, 323 + u32 in_resetbits, u32 post_resetbits) 336 324 { 337 325 u32 regdata; 338 326 u8 idx; ··· 341 337 * Must do the disable sequence first to work for 342 338 * arbitrary current core state. 343 339 */ 344 - brcmf_sdio_sb_coredisable(sdiodev, ci, coreid, 0); 340 + brcmf_sdio_sb_coredisable(sdiodev, ci, coreid, pre_resetbits, 341 + in_resetbits); 345 342 346 343 /* 347 344 * Now do the initialization sequence. ··· 395 390 396 391 static void 397 392 brcmf_sdio_ai_resetcore(struct brcmf_sdio_dev *sdiodev, 398 - struct chip_info *ci, u16 coreid, u32 core_bits) 393 + struct brcmf_chip *ci, u16 coreid, u32 pre_resetbits, 394 + u32 in_resetbits, u32 post_resetbits) 399 395 { 400 396 u8 idx; 401 397 u32 regdata; 398 + u32 wrapbase; 402 399 403 400 idx = brcmf_sdio_chip_getinfidx(ci, coreid); 404 401 if (idx == BRCMF_MAX_CORENUM) 405 402 return; 406 403 404 + wrapbase = ci->c_inf[idx].wrapbase; 405 + 407 406 /* must disable first to work for arbitrary current core state */ 408 - brcmf_sdio_ai_coredisable(sdiodev, ci, coreid, core_bits); 407 + brcmf_sdio_ai_coredisable(sdiodev, ci, coreid, pre_resetbits, 408 + in_resetbits); 409 409 410 - /* now do initialization sequence */ 411 - brcmf_sdiod_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 412 - core_bits | BCMA_IOCTL_FGC | BCMA_IOCTL_CLK, NULL); 413 - regdata = brcmf_sdiod_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 414 - NULL); 415 - brcmf_sdiod_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, 416 - 0, NULL); 417 - regdata = brcmf_sdiod_regrl(sdiodev, 418 - ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, 419 - NULL); 420 - udelay(1); 410 + while (brcmf_sdiod_regrl(sdiodev, wrapbase + BCMA_RESET_CTL, NULL) & 411 + BCMA_RESET_CTL_RESET) { 412 + brcmf_sdiod_regwl(sdiodev, wrapbase + BCMA_RESET_CTL, 0, NULL); 413 + usleep_range(40, 60); 414 + } 421 415 422 - brcmf_sdiod_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 423 - core_bits | BCMA_IOCTL_CLK, NULL); 424 - regdata = brcmf_sdiod_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 425 - NULL); 426 - udelay(1); 416 + brcmf_sdiod_regwl(sdiodev, wrapbase + BCMA_IOCTL, post_resetbits | 417 + BCMA_IOCTL_CLK, NULL); 418 + regdata = brcmf_sdiod_regrl(sdiodev, wrapbase + BCMA_IOCTL, NULL); 427 419 } 428 420 429 421 #ifdef DEBUG 430 422 /* safety check for chipinfo */ 431 - static int brcmf_sdio_chip_cichk(struct chip_info *ci) 423 + static int brcmf_sdio_chip_cichk(struct brcmf_chip *ci) 432 424 { 433 425 u8 core_idx; 434 426 ··· 452 450 return 0; 453 451 } 454 452 #else /* DEBUG */ 455 - static inline int brcmf_sdio_chip_cichk(struct chip_info *ci) 453 + static inline int brcmf_sdio_chip_cichk(struct brcmf_chip *ci) 456 454 { 457 455 return 0; 458 456 } 459 457 #endif 460 458 461 459 static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, 462 - struct chip_info *ci) 460 + struct brcmf_chip *ci) 463 461 { 464 462 u32 regdata; 465 - int ret; 463 + u32 socitype; 466 464 467 465 /* Get CC core rev 468 - * Chipid is assume to be at offset 0 from regs arg 466 + * Chipid is assume to be at offset 0 from SI_ENUM_BASE 469 467 * For different chiptypes or old sdio hosts w/o chipcommon, 470 468 * other ways of recognition should be added here. 471 469 */ 472 - ci->c_inf[0].id = BCMA_CORE_CHIPCOMMON; 473 - ci->c_inf[0].base = SI_ENUM_BASE; 474 470 regdata = brcmf_sdiod_regrl(sdiodev, 475 - CORE_CC_REG(ci->c_inf[0].base, chipid), 471 + CORE_CC_REG(SI_ENUM_BASE, chipid), 476 472 NULL); 477 473 ci->chip = regdata & CID_ID_MASK; 478 474 ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; 479 475 if (sdiodev->func[0]->device == SDIO_DEVICE_ID_BROADCOM_4335_4339 && 480 476 ci->chiprev >= 2) 481 477 ci->chip = BCM4339_CHIP_ID; 482 - ci->socitype = (regdata & CID_TYPE_MASK) >> CID_TYPE_SHIFT; 478 + socitype = (regdata & CID_TYPE_MASK) >> CID_TYPE_SHIFT; 483 479 484 - brcmf_dbg(INFO, "chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev); 480 + brcmf_dbg(INFO, "found %s chip: id=0x%x, rev=%d\n", 481 + socitype == SOCI_SB ? "SB" : "AXI", ci->chip, ci->chiprev); 485 482 486 - /* Address of cores for new chips should be added here */ 487 - switch (ci->chip) { 488 - case BCM43143_CHIP_ID: 489 - ci->c_inf[0].wrapbase = ci->c_inf[0].base + 0x00100000; 490 - ci->c_inf[0].cib = 0x2b000000; 491 - ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 492 - ci->c_inf[1].base = BCM43143_CORE_BUS_BASE; 493 - ci->c_inf[1].wrapbase = ci->c_inf[1].base + 0x00100000; 494 - ci->c_inf[1].cib = 0x18000000; 495 - ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM; 496 - ci->c_inf[2].base = BCM43143_CORE_SOCRAM_BASE; 497 - ci->c_inf[2].wrapbase = ci->c_inf[2].base + 0x00100000; 498 - ci->c_inf[2].cib = 0x14000000; 499 - ci->c_inf[3].id = BCMA_CORE_ARM_CM3; 500 - ci->c_inf[3].base = BCM43143_CORE_ARM_BASE; 501 - ci->c_inf[3].wrapbase = ci->c_inf[3].base + 0x00100000; 502 - ci->c_inf[3].cib = 0x07000000; 503 - ci->ramsize = BCM43143_RAMSIZE; 504 - break; 505 - case BCM43241_CHIP_ID: 506 - ci->c_inf[0].wrapbase = 0x18100000; 507 - ci->c_inf[0].cib = 0x2a084411; 508 - ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 509 - ci->c_inf[1].base = 0x18002000; 510 - ci->c_inf[1].wrapbase = 0x18102000; 511 - ci->c_inf[1].cib = 0x0e004211; 512 - ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM; 513 - ci->c_inf[2].base = 0x18004000; 514 - ci->c_inf[2].wrapbase = 0x18104000; 515 - ci->c_inf[2].cib = 0x14080401; 516 - ci->c_inf[3].id = BCMA_CORE_ARM_CM3; 517 - ci->c_inf[3].base = 0x18003000; 518 - ci->c_inf[3].wrapbase = 0x18103000; 519 - ci->c_inf[3].cib = 0x07004211; 520 - ci->ramsize = 0x90000; 521 - break; 522 - case BCM4329_CHIP_ID: 483 + if (socitype == SOCI_SB) { 484 + if (ci->chip != BCM4329_CHIP_ID) { 485 + brcmf_err("SB chip is not supported\n"); 486 + return -ENODEV; 487 + } 488 + ci->iscoreup = brcmf_sdio_sb_iscoreup; 489 + ci->corerev = brcmf_sdio_sb_corerev; 490 + ci->coredisable = brcmf_sdio_sb_coredisable; 491 + ci->resetcore = brcmf_sdio_sb_resetcore; 492 + 493 + ci->c_inf[0].id = BCMA_CORE_CHIPCOMMON; 494 + ci->c_inf[0].base = SI_ENUM_BASE; 523 495 ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 524 496 ci->c_inf[1].base = BCM4329_CORE_BUS_BASE; 525 497 ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM; 526 498 ci->c_inf[2].base = BCM4329_CORE_SOCRAM_BASE; 527 499 ci->c_inf[3].id = BCMA_CORE_ARM_CM3; 528 500 ci->c_inf[3].base = BCM4329_CORE_ARM_BASE; 501 + ci->c_inf[4].id = BCMA_CORE_80211; 502 + ci->c_inf[4].base = BCM43xx_CORE_D11_BASE; 529 503 ci->ramsize = BCM4329_RAMSIZE; 530 - break; 531 - case BCM4330_CHIP_ID: 532 - ci->c_inf[0].wrapbase = 0x18100000; 533 - ci->c_inf[0].cib = 0x27004211; 534 - ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 535 - ci->c_inf[1].base = 0x18002000; 536 - ci->c_inf[1].wrapbase = 0x18102000; 537 - ci->c_inf[1].cib = 0x07004211; 538 - ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM; 539 - ci->c_inf[2].base = 0x18004000; 540 - ci->c_inf[2].wrapbase = 0x18104000; 541 - ci->c_inf[2].cib = 0x0d080401; 542 - ci->c_inf[3].id = BCMA_CORE_ARM_CM3; 543 - ci->c_inf[3].base = 0x18003000; 544 - ci->c_inf[3].wrapbase = 0x18103000; 545 - ci->c_inf[3].cib = 0x03004211; 546 - ci->ramsize = 0x48000; 547 - break; 548 - case BCM4334_CHIP_ID: 549 - ci->c_inf[0].wrapbase = 0x18100000; 550 - ci->c_inf[0].cib = 0x29004211; 551 - ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 552 - ci->c_inf[1].base = 0x18002000; 553 - ci->c_inf[1].wrapbase = 0x18102000; 554 - ci->c_inf[1].cib = 0x0d004211; 555 - ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM; 556 - ci->c_inf[2].base = 0x18004000; 557 - ci->c_inf[2].wrapbase = 0x18104000; 558 - ci->c_inf[2].cib = 0x13080401; 559 - ci->c_inf[3].id = BCMA_CORE_ARM_CM3; 560 - ci->c_inf[3].base = 0x18003000; 561 - ci->c_inf[3].wrapbase = 0x18103000; 562 - ci->c_inf[3].cib = 0x07004211; 563 - ci->ramsize = 0x80000; 564 - break; 565 - case BCM4335_CHIP_ID: 566 - ci->c_inf[0].wrapbase = 0x18100000; 567 - ci->c_inf[0].cib = 0x2b084411; 568 - ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 569 - ci->c_inf[1].base = 0x18005000; 570 - ci->c_inf[1].wrapbase = 0x18105000; 571 - ci->c_inf[1].cib = 0x0f004211; 572 - ci->c_inf[2].id = BCMA_CORE_ARM_CR4; 573 - ci->c_inf[2].base = 0x18002000; 574 - ci->c_inf[2].wrapbase = 0x18102000; 575 - ci->c_inf[2].cib = 0x01084411; 576 - ci->ramsize = 0xc0000; 577 - ci->rambase = 0x180000; 578 - break; 579 - case BCM4339_CHIP_ID: 580 - ci->c_inf[0].wrapbase = 0x18100000; 581 - ci->c_inf[0].cib = 0x2e084411; 582 - ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 583 - ci->c_inf[1].base = 0x18005000; 584 - ci->c_inf[1].wrapbase = 0x18105000; 585 - ci->c_inf[1].cib = 0x15004211; 586 - ci->c_inf[2].id = BCMA_CORE_ARM_CR4; 587 - ci->c_inf[2].base = 0x18002000; 588 - ci->c_inf[2].wrapbase = 0x18102000; 589 - ci->c_inf[2].cib = 0x04084411; 590 - ci->ramsize = 0xc0000; 591 - ci->rambase = 0x180000; 592 - break; 593 - case BCM43362_CHIP_ID: 594 - ci->c_inf[0].wrapbase = 0x18100000; 595 - ci->c_inf[0].cib = 0x27004211; 596 - ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 597 - ci->c_inf[1].base = 0x18002000; 598 - ci->c_inf[1].wrapbase = 0x18102000; 599 - ci->c_inf[1].cib = 0x0a004211; 600 - ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM; 601 - ci->c_inf[2].base = 0x18004000; 602 - ci->c_inf[2].wrapbase = 0x18104000; 603 - ci->c_inf[2].cib = 0x08080401; 604 - ci->c_inf[3].id = BCMA_CORE_ARM_CM3; 605 - ci->c_inf[3].base = 0x18003000; 606 - ci->c_inf[3].wrapbase = 0x18103000; 607 - ci->c_inf[3].cib = 0x03004211; 608 - ci->ramsize = 0x3C000; 609 - break; 610 - default: 611 - brcmf_err("chipid 0x%x is not supported\n", ci->chip); 612 - return -ENODEV; 613 - } 614 - 615 - ret = brcmf_sdio_chip_cichk(ci); 616 - if (ret) 617 - return ret; 618 - 619 - switch (ci->socitype) { 620 - case SOCI_SB: 621 - ci->iscoreup = brcmf_sdio_sb_iscoreup; 622 - ci->corerev = brcmf_sdio_sb_corerev; 623 - ci->coredisable = brcmf_sdio_sb_coredisable; 624 - ci->resetcore = brcmf_sdio_sb_resetcore; 625 - break; 626 - case SOCI_AI: 504 + } else if (socitype == SOCI_AI) { 627 505 ci->iscoreup = brcmf_sdio_ai_iscoreup; 628 506 ci->corerev = brcmf_sdio_ai_corerev; 629 507 ci->coredisable = brcmf_sdio_ai_coredisable; 630 508 ci->resetcore = brcmf_sdio_ai_resetcore; 631 - break; 632 - default: 633 - brcmf_err("socitype %u not supported\n", ci->socitype); 509 + 510 + ci->c_inf[0].id = BCMA_CORE_CHIPCOMMON; 511 + ci->c_inf[0].base = SI_ENUM_BASE; 512 + 513 + /* Address of cores for new chips should be added here */ 514 + switch (ci->chip) { 515 + case BCM43143_CHIP_ID: 516 + ci->c_inf[0].wrapbase = ci->c_inf[0].base + 0x00100000; 517 + ci->c_inf[0].cib = 0x2b000000; 518 + ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 519 + ci->c_inf[1].base = BCM43143_CORE_BUS_BASE; 520 + ci->c_inf[1].wrapbase = ci->c_inf[1].base + 0x00100000; 521 + ci->c_inf[1].cib = 0x18000000; 522 + ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM; 523 + ci->c_inf[2].base = BCM43143_CORE_SOCRAM_BASE; 524 + ci->c_inf[2].wrapbase = ci->c_inf[2].base + 0x00100000; 525 + ci->c_inf[2].cib = 0x14000000; 526 + ci->c_inf[3].id = BCMA_CORE_ARM_CM3; 527 + ci->c_inf[3].base = BCM43143_CORE_ARM_BASE; 528 + ci->c_inf[3].wrapbase = ci->c_inf[3].base + 0x00100000; 529 + ci->c_inf[3].cib = 0x07000000; 530 + ci->c_inf[4].id = BCMA_CORE_80211; 531 + ci->c_inf[4].base = BCM43xx_CORE_D11_BASE; 532 + ci->c_inf[4].wrapbase = ci->c_inf[4].base + 0x00100000; 533 + ci->ramsize = BCM43143_RAMSIZE; 534 + break; 535 + case BCM43241_CHIP_ID: 536 + ci->c_inf[0].wrapbase = 0x18100000; 537 + ci->c_inf[0].cib = 0x2a084411; 538 + ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 539 + ci->c_inf[1].base = 0x18002000; 540 + ci->c_inf[1].wrapbase = 0x18102000; 541 + ci->c_inf[1].cib = 0x0e004211; 542 + ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM; 543 + ci->c_inf[2].base = 0x18004000; 544 + ci->c_inf[2].wrapbase = 0x18104000; 545 + ci->c_inf[2].cib = 0x14080401; 546 + ci->c_inf[3].id = BCMA_CORE_ARM_CM3; 547 + ci->c_inf[3].base = 0x18003000; 548 + ci->c_inf[3].wrapbase = 0x18103000; 549 + ci->c_inf[3].cib = 0x07004211; 550 + ci->c_inf[4].id = BCMA_CORE_80211; 551 + ci->c_inf[4].base = BCM43xx_CORE_D11_BASE; 552 + ci->c_inf[4].wrapbase = ci->c_inf[4].base + 0x00100000; 553 + ci->ramsize = 0x90000; 554 + break; 555 + case BCM4330_CHIP_ID: 556 + ci->c_inf[0].wrapbase = 0x18100000; 557 + ci->c_inf[0].cib = 0x27004211; 558 + ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 559 + ci->c_inf[1].base = 0x18002000; 560 + ci->c_inf[1].wrapbase = 0x18102000; 561 + ci->c_inf[1].cib = 0x07004211; 562 + ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM; 563 + ci->c_inf[2].base = 0x18004000; 564 + ci->c_inf[2].wrapbase = 0x18104000; 565 + ci->c_inf[2].cib = 0x0d080401; 566 + ci->c_inf[3].id = BCMA_CORE_ARM_CM3; 567 + ci->c_inf[3].base = 0x18003000; 568 + ci->c_inf[3].wrapbase = 0x18103000; 569 + ci->c_inf[3].cib = 0x03004211; 570 + ci->c_inf[4].id = BCMA_CORE_80211; 571 + ci->c_inf[4].base = BCM43xx_CORE_D11_BASE; 572 + ci->c_inf[4].wrapbase = ci->c_inf[4].base + 0x00100000; 573 + ci->ramsize = 0x48000; 574 + break; 575 + case BCM4334_CHIP_ID: 576 + ci->c_inf[0].wrapbase = 0x18100000; 577 + ci->c_inf[0].cib = 0x29004211; 578 + ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 579 + ci->c_inf[1].base = 0x18002000; 580 + ci->c_inf[1].wrapbase = 0x18102000; 581 + ci->c_inf[1].cib = 0x0d004211; 582 + ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM; 583 + ci->c_inf[2].base = 0x18004000; 584 + ci->c_inf[2].wrapbase = 0x18104000; 585 + ci->c_inf[2].cib = 0x13080401; 586 + ci->c_inf[3].id = BCMA_CORE_ARM_CM3; 587 + ci->c_inf[3].base = 0x18003000; 588 + ci->c_inf[3].wrapbase = 0x18103000; 589 + ci->c_inf[3].cib = 0x07004211; 590 + ci->c_inf[4].id = BCMA_CORE_80211; 591 + ci->c_inf[4].base = BCM43xx_CORE_D11_BASE; 592 + ci->c_inf[4].wrapbase = ci->c_inf[4].base + 0x00100000; 593 + ci->ramsize = 0x80000; 594 + break; 595 + case BCM4335_CHIP_ID: 596 + ci->c_inf[0].wrapbase = 0x18100000; 597 + ci->c_inf[0].cib = 0x2b084411; 598 + ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 599 + ci->c_inf[1].base = 0x18005000; 600 + ci->c_inf[1].wrapbase = 0x18105000; 601 + ci->c_inf[1].cib = 0x0f004211; 602 + ci->c_inf[2].id = BCMA_CORE_ARM_CR4; 603 + ci->c_inf[2].base = 0x18002000; 604 + ci->c_inf[2].wrapbase = 0x18102000; 605 + ci->c_inf[2].cib = 0x01084411; 606 + ci->c_inf[3].id = BCMA_CORE_80211; 607 + ci->c_inf[3].base = BCM43xx_CORE_D11_BASE; 608 + ci->c_inf[3].wrapbase = ci->c_inf[3].base + 0x00100000; 609 + ci->ramsize = 0xc0000; 610 + ci->rambase = 0x180000; 611 + break; 612 + case BCM43362_CHIP_ID: 613 + ci->c_inf[0].wrapbase = 0x18100000; 614 + ci->c_inf[0].cib = 0x27004211; 615 + ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 616 + ci->c_inf[1].base = 0x18002000; 617 + ci->c_inf[1].wrapbase = 0x18102000; 618 + ci->c_inf[1].cib = 0x0a004211; 619 + ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM; 620 + ci->c_inf[2].base = 0x18004000; 621 + ci->c_inf[2].wrapbase = 0x18104000; 622 + ci->c_inf[2].cib = 0x08080401; 623 + ci->c_inf[3].id = BCMA_CORE_ARM_CM3; 624 + ci->c_inf[3].base = 0x18003000; 625 + ci->c_inf[3].wrapbase = 0x18103000; 626 + ci->c_inf[3].cib = 0x03004211; 627 + ci->c_inf[4].id = BCMA_CORE_80211; 628 + ci->c_inf[4].base = BCM43xx_CORE_D11_BASE; 629 + ci->c_inf[4].wrapbase = ci->c_inf[4].base + 0x00100000; 630 + ci->ramsize = 0x3C000; 631 + break; 632 + case BCM4339_CHIP_ID: 633 + ci->c_inf[0].wrapbase = 0x18100000; 634 + ci->c_inf[0].cib = 0x2e084411; 635 + ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 636 + ci->c_inf[1].base = 0x18005000; 637 + ci->c_inf[1].wrapbase = 0x18105000; 638 + ci->c_inf[1].cib = 0x15004211; 639 + ci->c_inf[2].id = BCMA_CORE_ARM_CR4; 640 + ci->c_inf[2].base = 0x18002000; 641 + ci->c_inf[2].wrapbase = 0x18102000; 642 + ci->c_inf[2].cib = 0x04084411; 643 + ci->c_inf[3].id = BCMA_CORE_80211; 644 + ci->c_inf[3].base = BCM43xx_CORE_D11_BASE; 645 + ci->c_inf[3].wrapbase = ci->c_inf[3].base + 0x00100000; 646 + ci->ramsize = 0xc0000; 647 + ci->rambase = 0x180000; 648 + break; 649 + default: 650 + brcmf_err("AXI chip is not supported\n"); 651 + return -ENODEV; 652 + } 653 + } else { 654 + brcmf_err("chip backplane type %u is not supported\n", 655 + socitype); 634 656 return -ENODEV; 635 657 } 636 658 637 - return 0; 659 + return brcmf_sdio_chip_cichk(ci); 638 660 } 639 661 640 662 static int ··· 708 682 709 683 static void 710 684 brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, 711 - struct chip_info *ci) 685 + struct brcmf_chip *ci) 712 686 { 713 687 u32 base = ci->c_inf[0].base; 714 688 ··· 739 713 * Make sure any on-chip ARM is off (in case strapping is wrong), 740 714 * or downloaded code was already running. 741 715 */ 742 - ci->coredisable(sdiodev, ci, BCMA_CORE_ARM_CM3, 0); 716 + ci->coredisable(sdiodev, ci, BCMA_CORE_ARM_CM3, 0, 0); 743 717 } 744 718 745 719 int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, 746 - struct chip_info **ci_ptr) 720 + struct brcmf_chip **ci_ptr) 747 721 { 748 722 int ret; 749 - struct chip_info *ci; 723 + struct brcmf_chip *ci; 750 724 751 725 brcmf_dbg(TRACE, "Enter\n"); 752 726 753 - /* alloc chip_info_t */ 754 - ci = kzalloc(sizeof(struct chip_info), GFP_ATOMIC); 727 + ci = kzalloc(sizeof(*ci), GFP_ATOMIC); 755 728 if (!ci) 756 729 return -ENOMEM; 757 730 ··· 778 753 } 779 754 780 755 void 781 - brcmf_sdio_chip_detach(struct chip_info **ci_ptr) 756 + brcmf_sdio_chip_detach(struct brcmf_chip **ci_ptr) 782 757 { 783 758 brcmf_dbg(TRACE, "Enter\n"); 784 759 ··· 797 772 798 773 void 799 774 brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev, 800 - struct chip_info *ci, u32 drivestrength) 775 + struct brcmf_chip *ci, u32 drivestrength) 801 776 { 802 777 const struct sdiod_drive_str *str_tab = NULL; 803 778 u32 str_mask; ··· 867 842 } 868 843 } 869 844 870 - #ifdef DEBUG 871 - static bool 872 - brcmf_sdio_chip_verifynvram(struct brcmf_sdio_dev *sdiodev, u32 nvram_addr, 873 - char *nvram_dat, uint nvram_sz) 874 - { 875 - char *nvram_ularray; 876 - int err; 877 - bool ret = true; 878 - 879 - /* read back and verify */ 880 - brcmf_dbg(INFO, "Compare NVRAM dl & ul; size=%d\n", nvram_sz); 881 - nvram_ularray = kmalloc(nvram_sz, GFP_KERNEL); 882 - /* do not proceed while no memory but */ 883 - if (!nvram_ularray) 884 - return true; 885 - 886 - /* Upload image to verify downloaded contents. */ 887 - memset(nvram_ularray, 0xaa, nvram_sz); 888 - 889 - /* Read the vars list to temp buffer for comparison */ 890 - err = brcmf_sdiod_ramrw(sdiodev, false, nvram_addr, nvram_ularray, 891 - nvram_sz); 892 - if (err) { 893 - brcmf_err("error %d on reading %d nvram bytes at 0x%08x\n", 894 - err, nvram_sz, nvram_addr); 895 - } else if (memcmp(nvram_dat, nvram_ularray, nvram_sz)) { 896 - brcmf_err("Downloaded NVRAM image is corrupted\n"); 897 - ret = false; 898 - } 899 - kfree(nvram_ularray); 900 - 901 - return ret; 902 - } 903 - #else /* DEBUG */ 904 - static inline bool 905 - brcmf_sdio_chip_verifynvram(struct brcmf_sdio_dev *sdiodev, u32 nvram_addr, 906 - char *nvram_dat, uint nvram_sz) 907 - { 908 - return true; 909 - } 910 - #endif /* DEBUG */ 911 - 912 - static bool brcmf_sdio_chip_writenvram(struct brcmf_sdio_dev *sdiodev, 913 - struct chip_info *ci, 914 - char *nvram_dat, uint nvram_sz) 915 - { 916 - int err; 917 - u32 nvram_addr; 918 - u32 token; 919 - __le32 token_le; 920 - 921 - nvram_addr = (ci->ramsize - 4) - nvram_sz + ci->rambase; 922 - 923 - /* Write the vars list */ 924 - err = brcmf_sdiod_ramrw(sdiodev, true, nvram_addr, nvram_dat, nvram_sz); 925 - if (err) { 926 - brcmf_err("error %d on writing %d nvram bytes at 0x%08x\n", 927 - err, nvram_sz, nvram_addr); 928 - return false; 929 - } 930 - 931 - if (!brcmf_sdio_chip_verifynvram(sdiodev, nvram_addr, 932 - nvram_dat, nvram_sz)) 933 - return false; 934 - 935 - /* generate token: 936 - * nvram size, converted to words, in lower 16-bits, checksum 937 - * in upper 16-bits. 938 - */ 939 - token = nvram_sz / 4; 940 - token = (~token << 16) | (token & 0x0000FFFF); 941 - token_le = cpu_to_le32(token); 942 - 943 - brcmf_dbg(INFO, "RAM size: %d\n", ci->ramsize); 944 - brcmf_dbg(INFO, "nvram is placed at %d, size %d, token=0x%08x\n", 945 - nvram_addr, nvram_sz, token); 946 - 947 - /* Write the length token to the last word */ 948 - if (brcmf_sdiod_ramrw(sdiodev, true, (ci->ramsize - 4 + ci->rambase), 949 - (u8 *)&token_le, 4)) 950 - return false; 951 - 952 - return true; 953 - } 954 - 955 845 static void 956 846 brcmf_sdio_chip_cm3_enterdl(struct brcmf_sdio_dev *sdiodev, 957 - struct chip_info *ci) 847 + struct brcmf_chip *ci) 958 848 { 959 - u32 zeros = 0; 960 - 961 - ci->coredisable(sdiodev, ci, BCMA_CORE_ARM_CM3, 0); 962 - ci->resetcore(sdiodev, ci, BCMA_CORE_INTERNAL_MEM, 0); 963 - 964 - /* clear length token */ 965 - brcmf_sdiod_ramrw(sdiodev, true, ci->ramsize - 4, (u8 *)&zeros, 4); 849 + ci->coredisable(sdiodev, ci, BCMA_CORE_ARM_CM3, 0, 0); 850 + ci->resetcore(sdiodev, ci, BCMA_CORE_80211, 851 + D11_BCMA_IOCTL_PHYRESET | D11_BCMA_IOCTL_PHYCLOCKEN, 852 + D11_BCMA_IOCTL_PHYCLOCKEN, D11_BCMA_IOCTL_PHYCLOCKEN); 853 + ci->resetcore(sdiodev, ci, BCMA_CORE_INTERNAL_MEM, 0, 0, 0); 966 854 } 967 855 968 - static bool 969 - brcmf_sdio_chip_cm3_exitdl(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, 970 - char *nvram_dat, uint nvram_sz) 856 + static bool brcmf_sdio_chip_cm3_exitdl(struct brcmf_sdio_dev *sdiodev, 857 + struct brcmf_chip *ci) 971 858 { 972 859 u8 core_idx; 973 860 u32 reg_addr; ··· 889 952 return false; 890 953 } 891 954 892 - if (!brcmf_sdio_chip_writenvram(sdiodev, ci, nvram_dat, nvram_sz)) 893 - return false; 894 - 895 955 /* clear all interrupts */ 896 956 core_idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_SDIO_DEV); 897 957 reg_addr = ci->c_inf[core_idx].base; 898 958 reg_addr += offsetof(struct sdpcmd_regs, intstatus); 899 959 brcmf_sdiod_regwl(sdiodev, reg_addr, 0xFFFFFFFF, NULL); 900 960 901 - ci->resetcore(sdiodev, ci, BCMA_CORE_ARM_CM3, 0); 961 + ci->resetcore(sdiodev, ci, BCMA_CORE_ARM_CM3, 0, 0, 0); 902 962 903 963 return true; 904 964 } 905 965 906 966 static inline void 907 967 brcmf_sdio_chip_cr4_enterdl(struct brcmf_sdio_dev *sdiodev, 908 - struct chip_info *ci) 968 + struct brcmf_chip *ci) 909 969 { 910 - ci->resetcore(sdiodev, ci, BCMA_CORE_ARM_CR4, 911 - ARMCR4_BCMA_IOCTL_CPUHALT); 970 + u8 idx; 971 + u32 regdata; 972 + u32 wrapbase; 973 + idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_ARM_CR4); 974 + 975 + if (idx == BRCMF_MAX_CORENUM) 976 + return; 977 + 978 + wrapbase = ci->c_inf[idx].wrapbase; 979 + regdata = brcmf_sdiod_regrl(sdiodev, wrapbase + BCMA_IOCTL, NULL); 980 + regdata &= ARMCR4_BCMA_IOCTL_CPUHALT; 981 + ci->resetcore(sdiodev, ci, BCMA_CORE_ARM_CR4, regdata, 982 + ARMCR4_BCMA_IOCTL_CPUHALT, ARMCR4_BCMA_IOCTL_CPUHALT); 983 + ci->resetcore(sdiodev, ci, BCMA_CORE_80211, 984 + D11_BCMA_IOCTL_PHYRESET | D11_BCMA_IOCTL_PHYCLOCKEN, 985 + D11_BCMA_IOCTL_PHYCLOCKEN, D11_BCMA_IOCTL_PHYCLOCKEN); 912 986 } 913 987 914 - static bool 915 - brcmf_sdio_chip_cr4_exitdl(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, 916 - char *nvram_dat, uint nvram_sz) 988 + static bool brcmf_sdio_chip_cr4_exitdl(struct brcmf_sdio_dev *sdiodev, 989 + struct brcmf_chip *ci, u32 rstvec) 917 990 { 918 991 u8 core_idx; 919 992 u32 reg_addr; 920 - 921 - if (!brcmf_sdio_chip_writenvram(sdiodev, ci, nvram_dat, nvram_sz)) 922 - return false; 923 993 924 994 /* clear all interrupts */ 925 995 core_idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_SDIO_DEV); ··· 935 991 brcmf_sdiod_regwl(sdiodev, reg_addr, 0xFFFFFFFF, NULL); 936 992 937 993 /* Write reset vector to address 0 */ 938 - brcmf_sdiod_ramrw(sdiodev, true, 0, (void *)&ci->rst_vec, 939 - sizeof(ci->rst_vec)); 994 + brcmf_sdiod_ramrw(sdiodev, true, 0, (void *)&rstvec, 995 + sizeof(rstvec)); 940 996 941 997 /* restore ARM */ 942 - ci->resetcore(sdiodev, ci, BCMA_CORE_ARM_CR4, 0); 998 + ci->resetcore(sdiodev, ci, BCMA_CORE_ARM_CR4, ARMCR4_BCMA_IOCTL_CPUHALT, 999 + 0, 0); 943 1000 944 1001 return true; 945 1002 } 946 1003 947 1004 void brcmf_sdio_chip_enter_download(struct brcmf_sdio_dev *sdiodev, 948 - struct chip_info *ci) 1005 + struct brcmf_chip *ci) 949 1006 { 950 1007 u8 arm_core_idx; 951 1008 ··· 960 1015 } 961 1016 962 1017 bool brcmf_sdio_chip_exit_download(struct brcmf_sdio_dev *sdiodev, 963 - struct chip_info *ci, char *nvram_dat, 964 - uint nvram_sz) 1018 + struct brcmf_chip *ci, u32 rstvec) 965 1019 { 966 1020 u8 arm_core_idx; 967 1021 968 1022 arm_core_idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_ARM_CM3); 969 1023 if (BRCMF_MAX_CORENUM != arm_core_idx) 970 - return brcmf_sdio_chip_cm3_exitdl(sdiodev, ci, nvram_dat, 971 - nvram_sz); 1024 + return brcmf_sdio_chip_cm3_exitdl(sdiodev, ci); 972 1025 973 - return brcmf_sdio_chip_cr4_exitdl(sdiodev, ci, nvram_dat, nvram_sz); 1026 + return brcmf_sdio_chip_cr4_exitdl(sdiodev, ci, rstvec); 974 1027 }
+16 -15
drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h
··· 54 54 55 55 #define BRCMF_MAX_CORENUM 6 56 56 57 - struct chip_core_info { 57 + struct brcmf_core { 58 58 u16 id; 59 59 u16 rev; 60 60 u32 base; ··· 63 63 u32 cib; 64 64 }; 65 65 66 - struct chip_info { 66 + struct brcmf_chip { 67 67 u32 chip; 68 68 u32 chiprev; 69 - u32 socitype; 70 69 /* core info */ 71 70 /* always put chipcommon core at 0, bus core at 1 */ 72 - struct chip_core_info c_inf[BRCMF_MAX_CORENUM]; 71 + struct brcmf_core c_inf[BRCMF_MAX_CORENUM]; 73 72 u32 pmurev; 74 73 u32 pmucaps; 75 74 u32 ramsize; 76 75 u32 rambase; 77 76 u32 rst_vec; /* reset vertor for ARM CR4 core */ 78 77 79 - bool (*iscoreup)(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, 78 + bool (*iscoreup)(struct brcmf_sdio_dev *sdiodev, struct brcmf_chip *ci, 80 79 u16 coreid); 81 - u32 (*corerev)(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, 80 + u32 (*corerev)(struct brcmf_sdio_dev *sdiodev, struct brcmf_chip *ci, 82 81 u16 coreid); 83 82 void (*coredisable)(struct brcmf_sdio_dev *sdiodev, 84 - struct chip_info *ci, u16 coreid, u32 core_bits); 83 + struct brcmf_chip *ci, u16 coreid, u32 pre_resetbits, 84 + u32 in_resetbits); 85 85 void (*resetcore)(struct brcmf_sdio_dev *sdiodev, 86 - struct chip_info *ci, u16 coreid, u32 core_bits); 86 + struct brcmf_chip *ci, u16 coreid, u32 pre_resetbits, 87 + u32 in_resetbits, u32 post_resetbits); 87 88 }; 88 89 89 90 struct sbconfig { ··· 217 216 }; 218 217 219 218 int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, 220 - struct chip_info **ci_ptr); 221 - void brcmf_sdio_chip_detach(struct chip_info **ci_ptr); 219 + struct brcmf_chip **ci_ptr); 220 + void brcmf_sdio_chip_detach(struct brcmf_chip **ci_ptr); 222 221 void brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev, 223 - struct chip_info *ci, u32 drivestrength); 224 - u8 brcmf_sdio_chip_getinfidx(struct chip_info *ci, u16 coreid); 222 + struct brcmf_chip *ci, 223 + u32 drivestrength); 224 + u8 brcmf_sdio_chip_getinfidx(struct brcmf_chip *ci, u16 coreid); 225 225 void brcmf_sdio_chip_enter_download(struct brcmf_sdio_dev *sdiodev, 226 - struct chip_info *ci); 226 + struct brcmf_chip *ci); 227 227 bool brcmf_sdio_chip_exit_download(struct brcmf_sdio_dev *sdiodev, 228 - struct chip_info *ci, char *nvram_dat, 229 - uint nvram_sz); 228 + struct brcmf_chip *ci, u32 rstvec); 230 229 231 230 #endif /* _BRCMFMAC_SDIO_CHIP_H_ */
+2 -2
drivers/net/wireless/brcm80211/brcmfmac/usb.c
··· 522 522 /* update state of upper layer */ 523 523 if (state == BRCMFMAC_USB_STATE_DOWN) { 524 524 brcmf_dbg(USB, "DBUS is down\n"); 525 - bcmf_bus->state = BRCMF_BUS_DOWN; 525 + brcmf_bus_change_state(bcmf_bus, BRCMF_BUS_DOWN); 526 526 } else if (state == BRCMFMAC_USB_STATE_UP) { 527 527 brcmf_dbg(USB, "DBUS is up\n"); 528 - bcmf_bus->state = BRCMF_BUS_DATA; 528 + brcmf_bus_change_state(bcmf_bus, BRCMF_BUS_DATA); 529 529 } else { 530 530 brcmf_dbg(USB, "DBUS current state=%d\n", state); 531 531 }
+1
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
··· 2989 2989 } 2990 2990 2991 2991 set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status); 2992 + cfg->escan_info.run = brcmf_run_escan; 2992 2993 err = brcmf_do_escan(cfg, wiphy, ifp, request); 2993 2994 if (err) { 2994 2995 clear_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
-1
drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
··· 1071 1071 hw->max_rates = 2; /* Primary rate and 1 fallback rate */ 1072 1072 1073 1073 /* channel change time is dependent on chip and band */ 1074 - hw->channel_change_time = 7 * 1000; 1075 1074 hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | 1076 1075 BIT(NL80211_IFTYPE_AP) | 1077 1076 BIT(NL80211_IFTYPE_ADHOC);
-2
drivers/net/wireless/brcm80211/brcmsmac/main.c
··· 7108 7108 struct sk_buff *p, 7109 7109 struct ieee80211_rx_status *rx_status) 7110 7110 { 7111 - int preamble; 7112 7111 int channel; 7113 7112 u32 rspec; 7114 7113 unsigned char *plcp; ··· 7190 7191 rx_status->rate_idx -= BRCMS_LEGACY_5G_RATE_OFFSET; 7191 7192 7192 7193 /* Determine short preamble and rate_idx */ 7193 - preamble = 0; 7194 7194 if (is_cck_rate(rspec)) { 7195 7195 if (rxh->PhyRxStatus_0 & PRXS0_SHORTH) 7196 7196 rx_status->flag |= RX_FLAG_SHORTPRE;
-1
drivers/net/wireless/cw1200/main.c
··· 301 301 302 302 hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; 303 303 304 - hw->channel_change_time = 1000; /* TODO: find actual value */ 305 304 hw->queues = 4; 306 305 307 306 priv->rts_threshold = -1;
+1 -2
drivers/net/wireless/iwlwifi/dvm/mac80211.c
··· 406 406 { 407 407 struct iwl_resume_data *resume_data = data; 408 408 struct iwl_priv *priv = resume_data->priv; 409 - u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; 410 409 411 - if (len - 4 != sizeof(*resume_data->cmd)) { 410 + if (iwl_rx_packet_payload_len(pkt) != sizeof(*resume_data->cmd)) { 412 411 IWL_ERR(priv, "rx wrong size data\n"); 413 412 return true; 414 413 }
+2 -5
drivers/net/wireless/iwlwifi/dvm/rx.c
··· 205 205 struct iwl_device_cmd *cmd) 206 206 { 207 207 struct iwl_rx_packet *pkt = rxb_addr(rxb); 208 - u32 __maybe_unused len = 209 - le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; 208 + u32 __maybe_unused len = iwl_rx_packet_len(pkt); 210 209 IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled " 211 210 "notification for PM_DEBUG_STATISTIC_NOTIFIC:\n", len); 212 211 iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->data, len); ··· 456 457 const int reg_recalib_period = 60; 457 458 int change; 458 459 struct iwl_rx_packet *pkt = rxb_addr(rxb); 459 - u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; 460 + u32 len = iwl_rx_packet_payload_len(pkt); 460 461 __le32 *flag; 461 462 struct statistics_general_common *common; 462 463 struct statistics_rx_non_phy *rx_non_phy; ··· 465 466 struct statistics_rx_phy *rx_cck; 466 467 struct statistics_tx *tx; 467 468 struct statistics_bt_activity *bt_activity; 468 - 469 - len -= sizeof(struct iwl_cmd_header); /* skip header */ 470 469 471 470 IWL_DEBUG_RX(priv, "Statistics notification received (%d bytes).\n", 472 471 len);
+1 -6
drivers/net/wireless/iwlwifi/dvm/ucode.c
··· 388 388 { 389 389 struct iwl_priv *priv = data; 390 390 struct iwl_calib_hdr *hdr; 391 - int len; 392 391 393 392 if (pkt->hdr.cmd != CALIBRATION_RES_NOTIFICATION) { 394 393 WARN_ON(pkt->hdr.cmd != CALIBRATION_COMPLETE_NOTIFICATION); ··· 395 396 } 396 397 397 398 hdr = (struct iwl_calib_hdr *)pkt->data; 398 - len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; 399 399 400 - /* reduce the size by the length field itself */ 401 - len -= sizeof(__le32); 402 - 403 - if (iwl_calib_set(priv, hdr, len)) 400 + if (iwl_calib_set(priv, hdr, iwl_rx_packet_payload_len(pkt))) 404 401 IWL_ERR(priv, "Failed to record calibration data %d\n", 405 402 hdr->op_code); 406 403
+1 -8
drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
··· 264 264 struct ieee80211_sta_vht_cap *vht_cap) 265 265 { 266 266 int num_ants = num_of_ant(data->valid_rx_ant); 267 - int bf_sts_cap = num_ants - 1; 268 267 269 268 vht_cap->vht_supported = true; 270 269 271 270 vht_cap->cap = IEEE80211_VHT_CAP_SHORT_GI_80 | 272 271 IEEE80211_VHT_CAP_RXSTBC_1 | 273 272 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE | 274 - bf_sts_cap << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT | 273 + 3 << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT | 275 274 7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT; 276 275 277 276 if (num_ants > 1) ··· 289 290 IEEE80211_VHT_MCS_NOT_SUPPORTED << 12 | 290 291 IEEE80211_VHT_MCS_NOT_SUPPORTED << 14); 291 292 292 - /* Max rate for Long GI NSS=2 80Mhz is 780Mbps */ 293 - vht_cap->vht_mcs.rx_highest = cpu_to_le16(780); 294 - 295 293 if (num_ants == 1 || 296 294 cfg->rx_with_siso_diversity) { 297 295 vht_cap->cap |= IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN | ··· 296 300 /* this works because NOT_SUPPORTED == 3 */ 297 301 vht_cap->vht_mcs.rx_mcs_map |= 298 302 cpu_to_le16(IEEE80211_VHT_MCS_NOT_SUPPORTED << 2); 299 - /* Max rate for Long GI NSS=1 80Mhz is 390Mbps */ 300 - vht_cap->vht_mcs.rx_highest = cpu_to_le16(390); 301 303 } 302 304 303 305 vht_cap->vht_mcs.tx_mcs_map = vht_cap->vht_mcs.rx_mcs_map; 304 - vht_cap->vht_mcs.tx_highest = vht_cap->vht_mcs.rx_highest; 305 306 } 306 307 307 308 static void iwl_init_sbands(struct device *dev, const struct iwl_cfg *cfg,
+4
drivers/net/wireless/iwlwifi/iwl-prph.h
··· 277 277 278 278 /*********************** END TX SCHEDULER *************************************/ 279 279 280 + /* Oscillator clock */ 281 + #define OSC_CLK (0xa04068) 282 + #define OSC_CLK_FORCE_CONTROL (0x8) 283 + 280 284 #endif /* __iwl_prph_h__ */
+10
drivers/net/wireless/iwlwifi/iwl-trans.h
··· 176 176 u8 data[]; 177 177 } __packed; 178 178 179 + static inline u32 iwl_rx_packet_len(const struct iwl_rx_packet *pkt) 180 + { 181 + return le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; 182 + } 183 + 184 + static inline u32 iwl_rx_packet_payload_len(const struct iwl_rx_packet *pkt) 185 + { 186 + return iwl_rx_packet_len(pkt) - sizeof(pkt->hdr); 187 + } 188 + 179 189 /** 180 190 * enum CMD_MODE - how to send the host commands ? 181 191 *
+6 -9
drivers/net/wireless/iwlwifi/mvm/d3.c
··· 886 886 if (err) 887 887 return err; 888 888 889 - size = le32_to_cpu(cmd.resp_pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; 890 - size -= sizeof(cmd.resp_pkt->hdr); 889 + size = iwl_rx_packet_payload_len(cmd.resp_pkt); 891 890 if (size < sizeof(__le16)) { 892 891 err = -EINVAL; 893 892 } else { ··· 1210 1211 if (ret) 1211 1212 goto out; 1212 1213 #ifdef CONFIG_IWLWIFI_DEBUGFS 1213 - len = le32_to_cpu(d3_cfg_cmd.resp_pkt->len_n_flags) & 1214 - FH_RSCSR_FRAME_SIZE_MSK; 1215 - if (len >= sizeof(u32) * 2) { 1214 + len = iwl_rx_packet_payload_len(d3_cfg_cmd.resp_pkt); 1215 + if (len >= sizeof(u32)) { 1216 1216 mvm->d3_test_pme_ptr = 1217 1217 le32_to_cpup((__le32 *)d3_cfg_cmd.resp_pkt->data); 1218 1218 } ··· 1666 1668 else 1667 1669 status_size = sizeof(struct iwl_wowlan_status_v4); 1668 1670 1669 - len = le32_to_cpu(cmd.resp_pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; 1670 - if (len - sizeof(struct iwl_cmd_header) < status_size) { 1671 + len = iwl_rx_packet_payload_len(cmd.resp_pkt); 1672 + if (len < status_size) { 1671 1673 IWL_ERR(mvm, "Invalid WoWLAN status response!\n"); 1672 1674 goto out_free_resp; 1673 1675 } ··· 1702 1704 status.wake_packet = status_v4->wake_packet; 1703 1705 } 1704 1706 1705 - if (len - sizeof(struct iwl_cmd_header) != 1706 - status_size + ALIGN(status.wake_packet_bufsize, 4)) { 1707 + if (len != status_size + ALIGN(status.wake_packet_bufsize, 4)) { 1707 1708 IWL_ERR(mvm, "Invalid WoWLAN status response!\n"); 1708 1709 goto out_free_resp; 1709 1710 }
+1 -1
drivers/net/wireless/iwlwifi/mvm/debugfs.c
··· 135 135 ofs = img->sec[IWL_UCODE_SECTION_DATA].offset; 136 136 len = img->sec[IWL_UCODE_SECTION_DATA].len; 137 137 138 - if (!mvm->dbgfs_sram_offset && !mvm->dbgfs_sram_len) { 138 + if (mvm->dbgfs_sram_len) { 139 139 ofs = mvm->dbgfs_sram_offset; 140 140 len = mvm->dbgfs_sram_len; 141 141 }
-3
drivers/net/wireless/iwlwifi/mvm/fw-api-sta.h
··· 97 97 STA_FLG_FLG_ANT_B), 98 98 99 99 STA_FLG_PS = BIT(8), 100 - STA_FLG_INVALID = BIT(9), 101 - STA_FLG_DLP_EN = BIT(10), 102 - STA_FLG_SET_ALL_KEYS = BIT(11), 103 100 STA_FLG_DRAIN_FLOW = BIT(12), 104 101 STA_FLG_PAN = BIT(13), 105 102 STA_FLG_CLASS_AUTH = BIT(14),
+22 -6
drivers/net/wireless/iwlwifi/mvm/mac80211.c
··· 262 262 mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; 263 263 264 264 /* currently FW API supports only one optional cipher scheme */ 265 - if (mvm->fw->cs->cipher) { 265 + if (mvm->fw->cs[0].cipher) { 266 266 mvm->hw->n_cipher_schemes = 1; 267 - mvm->hw->cipher_schemes = mvm->fw->cs; 267 + mvm->hw->cipher_schemes = &mvm->fw->cs[0]; 268 268 } 269 269 270 270 #ifdef CONFIG_PM_SLEEP ··· 944 944 IWL_ERR(mvm, "failed to update power mode\n"); 945 945 } 946 946 iwl_mvm_bt_coex_vif_change(mvm); 947 + iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_TT, 948 + IEEE80211_SMPS_AUTOMATIC); 947 949 } else if (changes & BSS_CHANGED_BEACON_INFO) { 948 950 /* 949 951 * We received a beacon _after_ association so ··· 1014 1012 if (ret) 1015 1013 goto out_unbind; 1016 1014 1015 + /* must be set before quota calculations */ 1016 + mvmvif->ap_ibss_active = true; 1017 + 1018 + /* power updated needs to be done before quotas */ 1019 + mvm->bound_vif_cnt++; 1020 + iwl_mvm_power_update_binding(mvm, vif, true); 1021 + 1017 1022 ret = iwl_mvm_update_quotas(mvm, vif); 1018 1023 if (ret) 1019 - goto out_rm_bcast; 1024 + goto out_quota_failed; 1020 1025 1021 1026 /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */ 1022 1027 if (vif->p2p && mvm->p2p_device_vif) ··· 1034 1025 mutex_unlock(&mvm->mutex); 1035 1026 return 0; 1036 1027 1037 - out_rm_bcast: 1028 + out_quota_failed: 1029 + mvm->bound_vif_cnt--; 1030 + iwl_mvm_power_update_binding(mvm, vif, false); 1031 + mvmvif->ap_ibss_active = false; 1038 1032 iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta); 1039 1033 out_unbind: 1040 1034 iwl_mvm_binding_remove_vif(mvm, vif); ··· 1069 1057 iwl_mvm_update_quotas(mvm, NULL); 1070 1058 iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta); 1071 1059 iwl_mvm_binding_remove_vif(mvm, vif); 1060 + 1061 + mvm->bound_vif_cnt--; 1062 + iwl_mvm_power_update_binding(mvm, vif, false); 1063 + 1072 1064 iwl_mvm_mac_ctxt_remove(mvm, vif); 1073 1065 1074 1066 mutex_unlock(&mvm->mutex); ··· 1806 1790 } 1807 1791 1808 1792 iwl_mvm_binding_remove_vif(mvm, vif); 1809 - out_unlock: 1810 - mvmvif->phy_ctxt = NULL; 1811 1793 mvm->bound_vif_cnt--; 1812 1794 iwl_mvm_power_update_binding(mvm, vif, false); 1813 1795 1796 + out_unlock: 1797 + mvmvif->phy_ctxt = NULL; 1814 1798 mutex_unlock(&mvm->mutex); 1815 1799 } 1816 1800
+6 -7
drivers/net/wireless/iwlwifi/mvm/nvm.c
··· 392 392 /* Loads the NVM data stored in mvm->nvm_sections into the NIC */ 393 393 int iwl_mvm_load_nvm_to_nic(struct iwl_mvm *mvm) 394 394 { 395 - int i, ret; 396 - u16 section_id; 395 + int i, ret = 0; 397 396 struct iwl_nvm_section *sections = mvm->nvm_sections; 398 397 399 398 IWL_DEBUG_EEPROM(mvm->trans->dev, "'Write to NVM\n"); 400 399 401 - for (i = 0; i < ARRAY_SIZE(nvm_to_read); i++) { 402 - section_id = nvm_to_read[i]; 403 - ret = iwl_nvm_write_section(mvm, section_id, 404 - sections[section_id].data, 405 - sections[section_id].length); 400 + for (i = 0; i < ARRAY_SIZE(mvm->nvm_sections); i++) { 401 + if (!mvm->nvm_sections[i].data || !mvm->nvm_sections[i].length) 402 + continue; 403 + ret = iwl_nvm_write_section(mvm, i, sections[i].data, 404 + sections[i].length); 406 405 if (ret < 0) { 407 406 IWL_ERR(mvm, "iwl_mvm_send_cmd failed: %d\n", ret); 408 407 break;
+2
drivers/net/wireless/iwlwifi/mvm/ops.c
··· 309 309 CMD(BT_PROFILE_NOTIFICATION), 310 310 CMD(BT_CONFIG), 311 311 CMD(MCAST_FILTER_CMD), 312 + CMD(REPLY_SF_CFG_CMD), 312 313 CMD(REPLY_BEACON_FILTERING_CMD), 313 314 CMD(REPLY_THERMAL_MNG_BACKOFF), 314 315 CMD(MAC_PM_POWER_TABLE), ··· 473 472 474 473 out_unregister: 475 474 ieee80211_unregister_hw(mvm->hw); 475 + iwl_mvm_leds_exit(mvm); 476 476 out_free: 477 477 iwl_phy_db_free(mvm->phy_db); 478 478 kfree(mvm->scan_cmd);
+7 -6
drivers/net/wireless/iwlwifi/mvm/rs.c
··· 356 356 return idx; 357 357 } 358 358 359 - return -1; 359 + return IWL_RATE_INVALID; 360 360 } 361 361 362 362 static void rs_rate_scale_perform(struct iwl_mvm *mvm, ··· 702 702 memset(rate, 0, sizeof(*rate)); 703 703 rate->index = iwl_hwrate_to_plcp_idx(ucode_rate); 704 704 705 - if (rate->index == IWL_RATE_INVALID) { 706 - rate->index = -1; 705 + if (rate->index == IWL_RATE_INVALID) 707 706 return -EINVAL; 708 - } 709 707 710 708 rate->ant = (ant_msk >> RATE_MCS_ANT_POS); 711 709 ··· 1588 1590 search_tbl->column = col_id; 1589 1591 rs_set_expected_tpt_table(lq_sta, search_tbl); 1590 1592 1593 + lq_sta->visited_columns |= BIT(col_id); 1594 + 1591 1595 /* Get the best matching rate if we're changing modes. e.g. 1592 1596 * SISO->MIMO, LEGACY->SISO, MIMO->SISO 1593 1597 */ ··· 1613 1613 IWL_DEBUG_RATE(mvm, "Switched to column %d: Index %d\n", 1614 1614 col_id, rate->index); 1615 1615 1616 - lq_sta->visited_columns |= BIT(col_id); 1617 1616 return 0; 1618 1617 1619 1618 err: ··· 2559 2560 int index = iwl_hwrate_to_plcp_idx(rate); 2560 2561 2561 2562 return sprintf(buf, "Legacy | ANT: %s Rate: %s Mbps\n", 2562 - rs_pretty_ant(ant), iwl_rate_mcs[index].mbps); 2563 + rs_pretty_ant(ant), 2564 + index == IWL_RATE_INVALID ? "BAD" : 2565 + iwl_rate_mcs[index].mbps); 2563 2566 } 2564 2567 2565 2568 if (rate & RATE_MCS_VHT_MSK) {
+2 -2
drivers/net/wireless/iwlwifi/mvm/time-event.c
··· 249 249 container_of(notif_wait, struct iwl_mvm, notif_wait); 250 250 struct iwl_mvm_time_event_data *te_data = data; 251 251 struct iwl_time_event_resp *resp; 252 - int resp_len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; 252 + int resp_len = iwl_rx_packet_payload_len(pkt); 253 253 254 254 if (WARN_ON(pkt->hdr.cmd != TIME_EVENT_CMD)) 255 255 return true; 256 256 257 - if (WARN_ON_ONCE(resp_len != sizeof(pkt->hdr) + sizeof(*resp))) { 257 + if (WARN_ON_ONCE(resp_len != sizeof(*resp))) { 258 258 IWL_ERR(mvm, "Invalid TIME_EVENT_CMD response\n"); 259 259 return true; 260 260 }
+4 -5
drivers/net/wireless/iwlwifi/mvm/tx.c
··· 390 390 seq_number &= IEEE80211_SCTL_SEQ; 391 391 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); 392 392 hdr->seq_ctrl |= cpu_to_le16(seq_number); 393 - seq_number += 0x10; 394 393 is_data_qos = true; 395 394 is_ampdu = info->flags & IEEE80211_TX_CTL_AMPDU; 396 395 } ··· 406 407 } 407 408 408 409 IWL_DEBUG_TX(mvm, "TX to [%d|%d] Q:%d - seq: 0x%x\n", mvmsta->sta_id, 409 - tid, txq_id, seq_number); 410 + tid, txq_id, IEEE80211_SEQ_TO_SN(seq_number)); 410 411 411 412 if (iwl_trans_tx(mvm->trans, skb, dev_cmd, txq_id)) 412 413 goto drop_unlock_sta; 413 414 414 415 if (is_data_qos && !ieee80211_has_morefrags(fc)) 415 - mvmsta->tid_data[tid].seq_number = seq_number; 416 + mvmsta->tid_data[tid].seq_number = seq_number + 0x10; 416 417 417 418 spin_unlock(&mvmsta->lock); 418 419 ··· 703 704 */ 704 705 spin_lock_bh(&mvmsta->lock); 705 706 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); 706 - if (IS_ERR_OR_NULL(sta)) { 707 + if (!sta || PTR_ERR(sta) == -EBUSY) { 707 708 /* 708 709 * Station disappeared in the meantime: 709 710 * so we are draining. ··· 712 713 schedule_work(&mvm->sta_drained_wk); 713 714 } 714 715 spin_unlock_bh(&mvmsta->lock); 715 - } else if (!mvmsta) { 716 + } else if (!mvmsta && PTR_ERR(sta) == -EBUSY) { 716 717 /* Tx response without STA, so we are draining */ 717 718 set_bit(sta_id, mvm->sta_drained); 718 719 schedule_work(&mvm->sta_drained_wk);
+2 -2
drivers/net/wireless/iwlwifi/mvm/utils.c
··· 168 168 goto out_free_resp; 169 169 } 170 170 171 - resp_len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; 172 - if (WARN_ON_ONCE(resp_len != sizeof(pkt->hdr) + sizeof(*resp))) { 171 + resp_len = iwl_rx_packet_payload_len(pkt); 172 + if (WARN_ON_ONCE(resp_len != sizeof(*resp))) { 173 173 ret = -EIO; 174 174 goto out_free_resp; 175 175 }
+1 -1
drivers/net/wireless/iwlwifi/pcie/rx.c
··· 615 615 rxcb._offset, get_cmd_string(trans_pcie, pkt->hdr.cmd), 616 616 pkt->hdr.cmd); 617 617 618 - len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; 618 + len = iwl_rx_packet_len(pkt); 619 619 len += sizeof(u32); /* account for status word */ 620 620 trace_iwlwifi_dev_rx(trans->dev, trans, pkt, len); 621 621 trace_iwlwifi_dev_rx_data(trans->dev, trans, pkt, len);
+22
drivers/net/wireless/iwlwifi/pcie/trans.c
··· 178 178 goto out; 179 179 } 180 180 181 + if (trans->cfg->host_interrupt_operation_mode) { 182 + /* 183 + * This is a bit of an abuse - This is needed for 7260 / 3160 184 + * only check host_interrupt_operation_mode even if this is 185 + * not related to host_interrupt_operation_mode. 186 + * 187 + * Enable the oscillator to count wake up time for L1 exit. This 188 + * consumes slightly more power (100uA) - but allows to be sure 189 + * that we wake up from L1 on time. 190 + * 191 + * This looks weird: read twice the same register, discard the 192 + * value, set a bit, and yet again, read that same register 193 + * just to discard the value. But that's the way the hardware 194 + * seems to like it. 195 + */ 196 + iwl_read_prph(trans, OSC_CLK); 197 + iwl_read_prph(trans, OSC_CLK); 198 + iwl_set_bits_prph(trans, OSC_CLK, OSC_CLK_FORCE_CONTROL); 199 + iwl_read_prph(trans, OSC_CLK); 200 + iwl_read_prph(trans, OSC_CLK); 201 + } 202 + 181 203 /* 182 204 * Enable DMA clock and wait for it to stabilize. 183 205 *
+1 -6
drivers/net/wireless/libertas/cfg.c
··· 1268 1268 _new_connect_scan_req(struct wiphy *wiphy, struct cfg80211_connect_params *sme) 1269 1269 { 1270 1270 struct cfg80211_scan_request *creq = NULL; 1271 - int i, n_channels = 0; 1271 + int i, n_channels = ieee80211_get_num_supported_channels(wiphy); 1272 1272 enum ieee80211_band band; 1273 - 1274 - for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 1275 - if (wiphy->bands[band]) 1276 - n_channels += wiphy->bands[band]->n_channels; 1277 - } 1278 1273 1279 1274 creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) + 1280 1275 n_channels * sizeof(void *),
+653 -611
drivers/net/wireless/mac80211_hwsim.c
··· 163 163 } 164 164 }; 165 165 166 + static const struct ieee80211_regdomain *hwsim_world_regdom_custom[] = { 167 + &hwsim_world_regdom_custom_01, 168 + &hwsim_world_regdom_custom_02, 169 + }; 170 + 166 171 struct hwsim_vif_priv { 167 172 u32 magic; 168 173 u8 bssid[ETH_ALEN]; ··· 326 321 { .bitrate = 540 } 327 322 }; 328 323 324 + static const struct ieee80211_iface_limit hwsim_if_limits[] = { 325 + { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) }, 326 + { .max = 2048, .types = BIT(NL80211_IFTYPE_STATION) | 327 + BIT(NL80211_IFTYPE_P2P_CLIENT) | 328 + #ifdef CONFIG_MAC80211_MESH 329 + BIT(NL80211_IFTYPE_MESH_POINT) | 330 + #endif 331 + BIT(NL80211_IFTYPE_AP) | 332 + BIT(NL80211_IFTYPE_P2P_GO) }, 333 + { .max = 1, .types = BIT(NL80211_IFTYPE_P2P_DEVICE) }, 334 + }; 335 + 336 + static const struct ieee80211_iface_limit hwsim_if_dfs_limits[] = { 337 + { .max = 8, .types = BIT(NL80211_IFTYPE_AP) }, 338 + }; 339 + 340 + static const struct ieee80211_iface_combination hwsim_if_comb[] = { 341 + { 342 + .limits = hwsim_if_limits, 343 + .n_limits = ARRAY_SIZE(hwsim_if_limits), 344 + .max_interfaces = 2048, 345 + .num_different_channels = 1, 346 + }, 347 + { 348 + .limits = hwsim_if_dfs_limits, 349 + .n_limits = ARRAY_SIZE(hwsim_if_dfs_limits), 350 + .max_interfaces = 8, 351 + .num_different_channels = 1, 352 + .radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) | 353 + BIT(NL80211_CHAN_WIDTH_20) | 354 + BIT(NL80211_CHAN_WIDTH_40) | 355 + BIT(NL80211_CHAN_WIDTH_80) | 356 + BIT(NL80211_CHAN_WIDTH_160), 357 + } 358 + }; 359 + 329 360 static spinlock_t hwsim_radio_lock; 330 361 static struct list_head hwsim_radios; 362 + static int hwsim_radio_idx; 363 + 364 + static struct platform_driver mac80211_hwsim_driver = { 365 + .driver = { 366 + .name = "mac80211_hwsim", 367 + .owner = THIS_MODULE, 368 + }, 369 + }; 331 370 332 371 struct mac80211_hwsim_data { 333 372 struct list_head list; ··· 381 332 struct ieee80211_channel channels_2ghz[ARRAY_SIZE(hwsim_channels_2ghz)]; 382 333 struct ieee80211_channel channels_5ghz[ARRAY_SIZE(hwsim_channels_5ghz)]; 383 334 struct ieee80211_rate rates[ARRAY_SIZE(hwsim_rates)]; 335 + struct ieee80211_iface_combination if_combination; 384 336 385 337 struct mac_address addresses[2]; 338 + int channels, idx; 386 339 387 340 struct ieee80211_channel *tmp_chan; 388 341 struct delayed_work roc_done; ··· 452 401 /* MAC80211_HWSIM netlink policy */ 453 402 454 403 static struct nla_policy hwsim_genl_policy[HWSIM_ATTR_MAX + 1] = { 455 - [HWSIM_ATTR_ADDR_RECEIVER] = { .type = NLA_UNSPEC, 456 - .len = 6*sizeof(u8) }, 457 - [HWSIM_ATTR_ADDR_TRANSMITTER] = { .type = NLA_UNSPEC, 458 - .len = 6*sizeof(u8) }, 404 + [HWSIM_ATTR_ADDR_RECEIVER] = { .type = NLA_UNSPEC, .len = ETH_ALEN }, 405 + [HWSIM_ATTR_ADDR_TRANSMITTER] = { .type = NLA_UNSPEC, .len = ETH_ALEN }, 459 406 [HWSIM_ATTR_FRAME] = { .type = NLA_BINARY, 460 407 .len = IEEE80211_MAX_DATA_LEN }, 461 408 [HWSIM_ATTR_FLAGS] = { .type = NLA_U32 }, 462 409 [HWSIM_ATTR_RX_RATE] = { .type = NLA_U32 }, 463 410 [HWSIM_ATTR_SIGNAL] = { .type = NLA_U32 }, 464 411 [HWSIM_ATTR_TX_INFO] = { .type = NLA_UNSPEC, 465 - .len = IEEE80211_TX_MAX_RATES*sizeof( 466 - struct hwsim_tx_rate)}, 412 + .len = IEEE80211_TX_MAX_RATES * 413 + sizeof(struct hwsim_tx_rate)}, 467 414 [HWSIM_ATTR_COOKIE] = { .type = NLA_U64 }, 415 + [HWSIM_ATTR_CHANNELS] = { .type = NLA_U32 }, 416 + [HWSIM_ATTR_RADIO_ID] = { .type = NLA_U32 }, 417 + [HWSIM_ATTR_REG_HINT_ALPHA2] = { .type = NLA_STRING, .len = 2 }, 418 + [HWSIM_ATTR_REG_CUSTOM_REG] = { .type = NLA_U32 }, 419 + [HWSIM_ATTR_REG_STRICT_REG] = { .type = NLA_FLAG }, 468 420 }; 421 + 422 + static void mac80211_hwsim_tx_frame(struct ieee80211_hw *hw, 423 + struct sk_buff *skb, 424 + struct ieee80211_channel *chan); 425 + 426 + /* sysfs attributes */ 427 + static void hwsim_send_ps_poll(void *dat, u8 *mac, struct ieee80211_vif *vif) 428 + { 429 + struct mac80211_hwsim_data *data = dat; 430 + struct hwsim_vif_priv *vp = (void *)vif->drv_priv; 431 + struct sk_buff *skb; 432 + struct ieee80211_pspoll *pspoll; 433 + 434 + if (!vp->assoc) 435 + return; 436 + 437 + wiphy_debug(data->hw->wiphy, 438 + "%s: send PS-Poll to %pM for aid %d\n", 439 + __func__, vp->bssid, vp->aid); 440 + 441 + skb = dev_alloc_skb(sizeof(*pspoll)); 442 + if (!skb) 443 + return; 444 + pspoll = (void *) skb_put(skb, sizeof(*pspoll)); 445 + pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | 446 + IEEE80211_STYPE_PSPOLL | 447 + IEEE80211_FCTL_PM); 448 + pspoll->aid = cpu_to_le16(0xc000 | vp->aid); 449 + memcpy(pspoll->bssid, vp->bssid, ETH_ALEN); 450 + memcpy(pspoll->ta, mac, ETH_ALEN); 451 + 452 + rcu_read_lock(); 453 + mac80211_hwsim_tx_frame(data->hw, skb, 454 + rcu_dereference(vif->chanctx_conf)->def.chan); 455 + rcu_read_unlock(); 456 + } 457 + 458 + static void hwsim_send_nullfunc(struct mac80211_hwsim_data *data, u8 *mac, 459 + struct ieee80211_vif *vif, int ps) 460 + { 461 + struct hwsim_vif_priv *vp = (void *)vif->drv_priv; 462 + struct sk_buff *skb; 463 + struct ieee80211_hdr *hdr; 464 + 465 + if (!vp->assoc) 466 + return; 467 + 468 + wiphy_debug(data->hw->wiphy, 469 + "%s: send data::nullfunc to %pM ps=%d\n", 470 + __func__, vp->bssid, ps); 471 + 472 + skb = dev_alloc_skb(sizeof(*hdr)); 473 + if (!skb) 474 + return; 475 + hdr = (void *) skb_put(skb, sizeof(*hdr) - ETH_ALEN); 476 + hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | 477 + IEEE80211_STYPE_NULLFUNC | 478 + (ps ? IEEE80211_FCTL_PM : 0)); 479 + hdr->duration_id = cpu_to_le16(0); 480 + memcpy(hdr->addr1, vp->bssid, ETH_ALEN); 481 + memcpy(hdr->addr2, mac, ETH_ALEN); 482 + memcpy(hdr->addr3, vp->bssid, ETH_ALEN); 483 + 484 + rcu_read_lock(); 485 + mac80211_hwsim_tx_frame(data->hw, skb, 486 + rcu_dereference(vif->chanctx_conf)->def.chan); 487 + rcu_read_unlock(); 488 + } 489 + 490 + 491 + static void hwsim_send_nullfunc_ps(void *dat, u8 *mac, 492 + struct ieee80211_vif *vif) 493 + { 494 + struct mac80211_hwsim_data *data = dat; 495 + hwsim_send_nullfunc(data, mac, vif, 1); 496 + } 497 + 498 + static void hwsim_send_nullfunc_no_ps(void *dat, u8 *mac, 499 + struct ieee80211_vif *vif) 500 + { 501 + struct mac80211_hwsim_data *data = dat; 502 + hwsim_send_nullfunc(data, mac, vif, 0); 503 + } 504 + 505 + static int hwsim_fops_ps_read(void *dat, u64 *val) 506 + { 507 + struct mac80211_hwsim_data *data = dat; 508 + *val = data->ps; 509 + return 0; 510 + } 511 + 512 + static int hwsim_fops_ps_write(void *dat, u64 val) 513 + { 514 + struct mac80211_hwsim_data *data = dat; 515 + enum ps_mode old_ps; 516 + 517 + if (val != PS_DISABLED && val != PS_ENABLED && val != PS_AUTO_POLL && 518 + val != PS_MANUAL_POLL) 519 + return -EINVAL; 520 + 521 + old_ps = data->ps; 522 + data->ps = val; 523 + 524 + if (val == PS_MANUAL_POLL) { 525 + ieee80211_iterate_active_interfaces(data->hw, 526 + IEEE80211_IFACE_ITER_NORMAL, 527 + hwsim_send_ps_poll, data); 528 + data->ps_poll_pending = true; 529 + } else if (old_ps == PS_DISABLED && val != PS_DISABLED) { 530 + ieee80211_iterate_active_interfaces(data->hw, 531 + IEEE80211_IFACE_ITER_NORMAL, 532 + hwsim_send_nullfunc_ps, 533 + data); 534 + } else if (old_ps != PS_DISABLED && val == PS_DISABLED) { 535 + ieee80211_iterate_active_interfaces(data->hw, 536 + IEEE80211_IFACE_ITER_NORMAL, 537 + hwsim_send_nullfunc_no_ps, 538 + data); 539 + } 540 + 541 + return 0; 542 + } 543 + 544 + DEFINE_SIMPLE_ATTRIBUTE(hwsim_fops_ps, hwsim_fops_ps_read, hwsim_fops_ps_write, 545 + "%llu\n"); 546 + 547 + static int hwsim_write_simulate_radar(void *dat, u64 val) 548 + { 549 + struct mac80211_hwsim_data *data = dat; 550 + 551 + ieee80211_radar_detected(data->hw); 552 + 553 + return 0; 554 + } 555 + 556 + DEFINE_SIMPLE_ATTRIBUTE(hwsim_simulate_radar, NULL, 557 + hwsim_write_simulate_radar, "%llu\n"); 558 + 559 + static int hwsim_fops_group_read(void *dat, u64 *val) 560 + { 561 + struct mac80211_hwsim_data *data = dat; 562 + *val = data->group; 563 + return 0; 564 + } 565 + 566 + static int hwsim_fops_group_write(void *dat, u64 val) 567 + { 568 + struct mac80211_hwsim_data *data = dat; 569 + data->group = val; 570 + return 0; 571 + } 572 + 573 + DEFINE_SIMPLE_ATTRIBUTE(hwsim_fops_group, 574 + hwsim_fops_group_read, hwsim_fops_group_write, 575 + "%llx\n"); 469 576 470 577 static netdev_tx_t hwsim_mon_xmit(struct sk_buff *skb, 471 578 struct net_device *dev) ··· 848 639 } 849 640 850 641 if (nla_put(skb, HWSIM_ATTR_ADDR_TRANSMITTER, 851 - sizeof(struct mac_address), data->addresses[1].addr)) 642 + ETH_ALEN, data->addresses[1].addr)) 852 643 goto nla_put_failure; 853 644 854 645 /* We get the skb->data */ ··· 1087 878 return; 1088 879 } 1089 880 1090 - if (channels == 1) { 881 + if (data->channels == 1) { 1091 882 channel = data->channel; 1092 883 } else if (txi->hw_queue == 4) { 1093 884 channel = data->tmp_chan; ··· 1115 906 if (control->sta) 1116 907 hwsim_check_sta_magic(control->sta); 1117 908 1118 - if (rctbl) 909 + if (hw->flags & IEEE80211_HW_SUPPORTS_RC_TABLE) 1119 910 ieee80211_get_tx_rates(txi->control.vif, control->sta, skb, 1120 911 txi->control.rates, 1121 912 ARRAY_SIZE(txi->control.rates)); ··· 1222 1013 { 1223 1014 u32 _pid = ACCESS_ONCE(wmediumd_portid); 1224 1015 1225 - if (rctbl) { 1016 + if (hw->flags & IEEE80211_HW_SUPPORTS_RC_TABLE) { 1226 1017 struct ieee80211_tx_info *txi = IEEE80211_SKB_CB(skb); 1227 1018 ieee80211_get_tx_rates(txi->control.vif, NULL, skb, 1228 1019 txi->control.rates, ··· 1259 1050 if (skb == NULL) 1260 1051 return; 1261 1052 info = IEEE80211_SKB_CB(skb); 1262 - if (rctbl) 1053 + if (hw->flags & IEEE80211_HW_SUPPORTS_RC_TABLE) 1263 1054 ieee80211_get_tx_rates(vif, NULL, skb, 1264 1055 info->control.rates, 1265 1056 ARRAY_SIZE(info->control.rates)); ··· 1350 1141 1351 1142 data->channel = conf->chandef.chan; 1352 1143 1353 - WARN_ON(data->channel && channels > 1); 1144 + WARN_ON(data->channel && data->channels > 1); 1354 1145 1355 1146 data->power_level = conf->power_level; 1356 1147 if (!data->started || !data->beacon_int) ··· 1596 1387 [HWSIM_TM_ATTR_CMD] = { .type = NLA_U32 }, 1597 1388 [HWSIM_TM_ATTR_PS] = { .type = NLA_U32 }, 1598 1389 }; 1599 - 1600 - static int hwsim_fops_ps_write(void *dat, u64 val); 1601 1390 1602 1391 static int mac80211_hwsim_testmode_cmd(struct ieee80211_hw *hw, 1603 1392 struct ieee80211_vif *vif, ··· 1907 1700 hwsim_check_chanctx_magic(ctx); 1908 1701 } 1909 1702 1910 - static struct ieee80211_ops mac80211_hwsim_ops = 1911 - { 1703 + static const struct ieee80211_ops mac80211_hwsim_ops = { 1912 1704 .tx = mac80211_hwsim_tx, 1913 1705 .start = mac80211_hwsim_start, 1914 1706 .stop = mac80211_hwsim_stop, ··· 1932 1726 .set_tsf = mac80211_hwsim_set_tsf, 1933 1727 }; 1934 1728 1729 + static struct ieee80211_ops mac80211_hwsim_mchan_ops; 1730 + 1731 + static int mac80211_hwsim_create_radio(int channels, const char *reg_alpha2, 1732 + const struct ieee80211_regdomain *regd, 1733 + bool reg_strict) 1734 + { 1735 + int err; 1736 + u8 addr[ETH_ALEN]; 1737 + struct mac80211_hwsim_data *data; 1738 + struct ieee80211_hw *hw; 1739 + enum ieee80211_band band; 1740 + const struct ieee80211_ops *ops = &mac80211_hwsim_ops; 1741 + int idx; 1742 + 1743 + spin_lock_bh(&hwsim_radio_lock); 1744 + idx = hwsim_radio_idx++; 1745 + spin_unlock_bh(&hwsim_radio_lock); 1746 + 1747 + if (channels > 1) 1748 + ops = &mac80211_hwsim_mchan_ops; 1749 + hw = ieee80211_alloc_hw(sizeof(*data), ops); 1750 + if (!hw) { 1751 + printk(KERN_DEBUG "mac80211_hwsim: ieee80211_alloc_hw failed\n"); 1752 + err = -ENOMEM; 1753 + goto failed; 1754 + } 1755 + data = hw->priv; 1756 + data->hw = hw; 1757 + 1758 + data->dev = device_create(hwsim_class, NULL, 0, hw, "hwsim%d", idx); 1759 + if (IS_ERR(data->dev)) { 1760 + printk(KERN_DEBUG 1761 + "mac80211_hwsim: device_create failed (%ld)\n", 1762 + PTR_ERR(data->dev)); 1763 + err = -ENOMEM; 1764 + goto failed_drvdata; 1765 + } 1766 + data->dev->driver = &mac80211_hwsim_driver.driver; 1767 + err = device_bind_driver(data->dev); 1768 + if (err != 0) { 1769 + printk(KERN_DEBUG "mac80211_hwsim: device_bind_driver failed (%d)\n", 1770 + err); 1771 + goto failed_hw; 1772 + } 1773 + 1774 + skb_queue_head_init(&data->pending); 1775 + 1776 + SET_IEEE80211_DEV(hw, data->dev); 1777 + memset(addr, 0, ETH_ALEN); 1778 + addr[0] = 0x02; 1779 + addr[3] = idx >> 8; 1780 + addr[4] = idx; 1781 + memcpy(data->addresses[0].addr, addr, ETH_ALEN); 1782 + memcpy(data->addresses[1].addr, addr, ETH_ALEN); 1783 + data->addresses[1].addr[0] |= 0x40; 1784 + hw->wiphy->n_addresses = 2; 1785 + hw->wiphy->addresses = data->addresses; 1786 + 1787 + data->channels = channels; 1788 + data->idx = idx; 1789 + 1790 + if (data->channels > 1) { 1791 + hw->wiphy->max_scan_ssids = 255; 1792 + hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; 1793 + hw->wiphy->max_remain_on_channel_duration = 1000; 1794 + /* For channels > 1 DFS is not allowed */ 1795 + hw->wiphy->n_iface_combinations = 1; 1796 + hw->wiphy->iface_combinations = &data->if_combination; 1797 + data->if_combination = hwsim_if_comb[0]; 1798 + data->if_combination.num_different_channels = data->channels; 1799 + } else { 1800 + hw->wiphy->iface_combinations = hwsim_if_comb; 1801 + hw->wiphy->n_iface_combinations = ARRAY_SIZE(hwsim_if_comb); 1802 + } 1803 + 1804 + INIT_DELAYED_WORK(&data->roc_done, hw_roc_done); 1805 + INIT_DELAYED_WORK(&data->hw_scan, hw_scan_work); 1806 + 1807 + hw->queues = 5; 1808 + hw->offchannel_tx_hw_queue = 4; 1809 + hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | 1810 + BIT(NL80211_IFTYPE_AP) | 1811 + BIT(NL80211_IFTYPE_P2P_CLIENT) | 1812 + BIT(NL80211_IFTYPE_P2P_GO) | 1813 + BIT(NL80211_IFTYPE_ADHOC) | 1814 + BIT(NL80211_IFTYPE_MESH_POINT) | 1815 + BIT(NL80211_IFTYPE_P2P_DEVICE); 1816 + 1817 + hw->flags = IEEE80211_HW_MFP_CAPABLE | 1818 + IEEE80211_HW_SIGNAL_DBM | 1819 + IEEE80211_HW_SUPPORTS_STATIC_SMPS | 1820 + IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | 1821 + IEEE80211_HW_AMPDU_AGGREGATION | 1822 + IEEE80211_HW_WANT_MONITOR_VIF | 1823 + IEEE80211_HW_QUEUE_CONTROL | 1824 + IEEE80211_HW_SUPPORTS_HT_CCK_RATES; 1825 + if (rctbl) 1826 + hw->flags |= IEEE80211_HW_SUPPORTS_RC_TABLE; 1827 + 1828 + hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS | 1829 + WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL | 1830 + WIPHY_FLAG_AP_UAPSD; 1831 + hw->wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR; 1832 + 1833 + /* ask mac80211 to reserve space for magic */ 1834 + hw->vif_data_size = sizeof(struct hwsim_vif_priv); 1835 + hw->sta_data_size = sizeof(struct hwsim_sta_priv); 1836 + hw->chanctx_data_size = sizeof(struct hwsim_chanctx_priv); 1837 + 1838 + memcpy(data->channels_2ghz, hwsim_channels_2ghz, 1839 + sizeof(hwsim_channels_2ghz)); 1840 + memcpy(data->channels_5ghz, hwsim_channels_5ghz, 1841 + sizeof(hwsim_channels_5ghz)); 1842 + memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates)); 1843 + 1844 + for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) { 1845 + struct ieee80211_supported_band *sband = &data->bands[band]; 1846 + switch (band) { 1847 + case IEEE80211_BAND_2GHZ: 1848 + sband->channels = data->channels_2ghz; 1849 + sband->n_channels = ARRAY_SIZE(hwsim_channels_2ghz); 1850 + sband->bitrates = data->rates; 1851 + sband->n_bitrates = ARRAY_SIZE(hwsim_rates); 1852 + break; 1853 + case IEEE80211_BAND_5GHZ: 1854 + sband->channels = data->channels_5ghz; 1855 + sband->n_channels = ARRAY_SIZE(hwsim_channels_5ghz); 1856 + sband->bitrates = data->rates + 4; 1857 + sband->n_bitrates = ARRAY_SIZE(hwsim_rates) - 4; 1858 + break; 1859 + default: 1860 + continue; 1861 + } 1862 + 1863 + sband->ht_cap.ht_supported = true; 1864 + sband->ht_cap.cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | 1865 + IEEE80211_HT_CAP_GRN_FLD | 1866 + IEEE80211_HT_CAP_SGI_40 | 1867 + IEEE80211_HT_CAP_DSSSCCK40; 1868 + sband->ht_cap.ampdu_factor = 0x3; 1869 + sband->ht_cap.ampdu_density = 0x6; 1870 + memset(&sband->ht_cap.mcs, 0, 1871 + sizeof(sband->ht_cap.mcs)); 1872 + sband->ht_cap.mcs.rx_mask[0] = 0xff; 1873 + sband->ht_cap.mcs.rx_mask[1] = 0xff; 1874 + sband->ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; 1875 + 1876 + hw->wiphy->bands[band] = sband; 1877 + 1878 + sband->vht_cap.vht_supported = true; 1879 + sband->vht_cap.cap = 1880 + IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 | 1881 + IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ | 1882 + IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ | 1883 + IEEE80211_VHT_CAP_RXLDPC | 1884 + IEEE80211_VHT_CAP_SHORT_GI_80 | 1885 + IEEE80211_VHT_CAP_SHORT_GI_160 | 1886 + IEEE80211_VHT_CAP_TXSTBC | 1887 + IEEE80211_VHT_CAP_RXSTBC_1 | 1888 + IEEE80211_VHT_CAP_RXSTBC_2 | 1889 + IEEE80211_VHT_CAP_RXSTBC_3 | 1890 + IEEE80211_VHT_CAP_RXSTBC_4 | 1891 + IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK; 1892 + sband->vht_cap.vht_mcs.rx_mcs_map = 1893 + cpu_to_le16(IEEE80211_VHT_MCS_SUPPORT_0_8 << 0 | 1894 + IEEE80211_VHT_MCS_SUPPORT_0_8 << 2 | 1895 + IEEE80211_VHT_MCS_SUPPORT_0_9 << 4 | 1896 + IEEE80211_VHT_MCS_SUPPORT_0_8 << 6 | 1897 + IEEE80211_VHT_MCS_SUPPORT_0_8 << 8 | 1898 + IEEE80211_VHT_MCS_SUPPORT_0_9 << 10 | 1899 + IEEE80211_VHT_MCS_SUPPORT_0_9 << 12 | 1900 + IEEE80211_VHT_MCS_SUPPORT_0_8 << 14); 1901 + sband->vht_cap.vht_mcs.tx_mcs_map = 1902 + sband->vht_cap.vht_mcs.rx_mcs_map; 1903 + } 1904 + 1905 + /* By default all radios belong to the first group */ 1906 + data->group = 1; 1907 + mutex_init(&data->mutex); 1908 + 1909 + /* Enable frame retransmissions for lossy channels */ 1910 + hw->max_rates = 4; 1911 + hw->max_rate_tries = 11; 1912 + 1913 + if (reg_strict) 1914 + hw->wiphy->regulatory_flags |= REGULATORY_STRICT_REG; 1915 + if (regd) { 1916 + hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; 1917 + wiphy_apply_custom_regulatory(hw->wiphy, regd); 1918 + /* give the regulatory workqueue a chance to run */ 1919 + schedule_timeout_interruptible(1); 1920 + } 1921 + 1922 + err = ieee80211_register_hw(hw); 1923 + if (err < 0) { 1924 + printk(KERN_DEBUG "mac80211_hwsim: ieee80211_register_hw failed (%d)\n", 1925 + err); 1926 + goto failed_hw; 1927 + } 1928 + 1929 + wiphy_debug(hw->wiphy, "hwaddr %pM registered\n", hw->wiphy->perm_addr); 1930 + 1931 + if (reg_alpha2) 1932 + regulatory_hint(hw->wiphy, reg_alpha2); 1933 + 1934 + data->debugfs = debugfs_create_dir("hwsim", hw->wiphy->debugfsdir); 1935 + debugfs_create_file("ps", 0666, data->debugfs, data, &hwsim_fops_ps); 1936 + debugfs_create_file("group", 0666, data->debugfs, data, 1937 + &hwsim_fops_group); 1938 + if (data->channels == 1) 1939 + debugfs_create_file("dfs_simulate_radar", 0222, 1940 + data->debugfs, 1941 + data, &hwsim_simulate_radar); 1942 + 1943 + tasklet_hrtimer_init(&data->beacon_timer, 1944 + mac80211_hwsim_beacon, 1945 + CLOCK_MONOTONIC_RAW, HRTIMER_MODE_ABS); 1946 + 1947 + spin_lock_bh(&hwsim_radio_lock); 1948 + list_add_tail(&data->list, &hwsim_radios); 1949 + spin_unlock_bh(&hwsim_radio_lock); 1950 + 1951 + return idx; 1952 + 1953 + failed_hw: 1954 + device_unregister(data->dev); 1955 + failed_drvdata: 1956 + ieee80211_free_hw(hw); 1957 + failed: 1958 + return err; 1959 + } 1960 + 1961 + static void mac80211_hwsim_destroy_radio(struct mac80211_hwsim_data *data) 1962 + { 1963 + debugfs_remove_recursive(data->debugfs); 1964 + ieee80211_unregister_hw(data->hw); 1965 + device_release_driver(data->dev); 1966 + device_unregister(data->dev); 1967 + ieee80211_free_hw(data->hw); 1968 + } 1935 1969 1936 1970 static void mac80211_hwsim_free(void) 1937 1971 { 1938 - struct list_head tmplist, *i, *tmp; 1939 - struct mac80211_hwsim_data *data, *tmpdata; 1940 - 1941 - INIT_LIST_HEAD(&tmplist); 1972 + struct mac80211_hwsim_data *data; 1942 1973 1943 1974 spin_lock_bh(&hwsim_radio_lock); 1944 - list_for_each_safe(i, tmp, &hwsim_radios) 1945 - list_move(i, &tmplist); 1946 - spin_unlock_bh(&hwsim_radio_lock); 1947 - 1948 - list_for_each_entry_safe(data, tmpdata, &tmplist, list) { 1949 - debugfs_remove_recursive(data->debugfs); 1950 - ieee80211_unregister_hw(data->hw); 1951 - device_release_driver(data->dev); 1952 - device_unregister(data->dev); 1953 - ieee80211_free_hw(data->hw); 1975 + while ((data = list_first_entry_or_null(&hwsim_radios, 1976 + struct mac80211_hwsim_data, 1977 + list))) { 1978 + list_del(&data->list); 1979 + spin_unlock_bh(&hwsim_radio_lock); 1980 + mac80211_hwsim_destroy_radio(data); 1981 + spin_lock_bh(&hwsim_radio_lock); 1954 1982 } 1983 + spin_unlock_bh(&hwsim_radio_lock); 1955 1984 class_destroy(hwsim_class); 1956 1985 } 1957 - 1958 - static struct platform_driver mac80211_hwsim_driver = { 1959 - .driver = { 1960 - .name = "mac80211_hwsim", 1961 - .owner = THIS_MODULE, 1962 - }, 1963 - }; 1964 1986 1965 1987 static const struct net_device_ops hwsim_netdev_ops = { 1966 1988 .ndo_start_xmit = hwsim_mon_xmit, ··· 2208 1774 dev->dev_addr[0] = 0x12; 2209 1775 } 2210 1776 2211 - 2212 - static void hwsim_send_ps_poll(void *dat, u8 *mac, struct ieee80211_vif *vif) 2213 - { 2214 - struct mac80211_hwsim_data *data = dat; 2215 - struct hwsim_vif_priv *vp = (void *)vif->drv_priv; 2216 - struct sk_buff *skb; 2217 - struct ieee80211_pspoll *pspoll; 2218 - 2219 - if (!vp->assoc) 2220 - return; 2221 - 2222 - wiphy_debug(data->hw->wiphy, 2223 - "%s: send PS-Poll to %pM for aid %d\n", 2224 - __func__, vp->bssid, vp->aid); 2225 - 2226 - skb = dev_alloc_skb(sizeof(*pspoll)); 2227 - if (!skb) 2228 - return; 2229 - pspoll = (void *) skb_put(skb, sizeof(*pspoll)); 2230 - pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | 2231 - IEEE80211_STYPE_PSPOLL | 2232 - IEEE80211_FCTL_PM); 2233 - pspoll->aid = cpu_to_le16(0xc000 | vp->aid); 2234 - memcpy(pspoll->bssid, vp->bssid, ETH_ALEN); 2235 - memcpy(pspoll->ta, mac, ETH_ALEN); 2236 - 2237 - rcu_read_lock(); 2238 - mac80211_hwsim_tx_frame(data->hw, skb, 2239 - rcu_dereference(vif->chanctx_conf)->def.chan); 2240 - rcu_read_unlock(); 2241 - } 2242 - 2243 - static void hwsim_send_nullfunc(struct mac80211_hwsim_data *data, u8 *mac, 2244 - struct ieee80211_vif *vif, int ps) 2245 - { 2246 - struct hwsim_vif_priv *vp = (void *)vif->drv_priv; 2247 - struct sk_buff *skb; 2248 - struct ieee80211_hdr *hdr; 2249 - 2250 - if (!vp->assoc) 2251 - return; 2252 - 2253 - wiphy_debug(data->hw->wiphy, 2254 - "%s: send data::nullfunc to %pM ps=%d\n", 2255 - __func__, vp->bssid, ps); 2256 - 2257 - skb = dev_alloc_skb(sizeof(*hdr)); 2258 - if (!skb) 2259 - return; 2260 - hdr = (void *) skb_put(skb, sizeof(*hdr) - ETH_ALEN); 2261 - hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | 2262 - IEEE80211_STYPE_NULLFUNC | 2263 - (ps ? IEEE80211_FCTL_PM : 0)); 2264 - hdr->duration_id = cpu_to_le16(0); 2265 - memcpy(hdr->addr1, vp->bssid, ETH_ALEN); 2266 - memcpy(hdr->addr2, mac, ETH_ALEN); 2267 - memcpy(hdr->addr3, vp->bssid, ETH_ALEN); 2268 - 2269 - rcu_read_lock(); 2270 - mac80211_hwsim_tx_frame(data->hw, skb, 2271 - rcu_dereference(vif->chanctx_conf)->def.chan); 2272 - rcu_read_unlock(); 2273 - } 2274 - 2275 - 2276 - static void hwsim_send_nullfunc_ps(void *dat, u8 *mac, 2277 - struct ieee80211_vif *vif) 2278 - { 2279 - struct mac80211_hwsim_data *data = dat; 2280 - hwsim_send_nullfunc(data, mac, vif, 1); 2281 - } 2282 - 2283 - 2284 - static void hwsim_send_nullfunc_no_ps(void *dat, u8 *mac, 2285 - struct ieee80211_vif *vif) 2286 - { 2287 - struct mac80211_hwsim_data *data = dat; 2288 - hwsim_send_nullfunc(data, mac, vif, 0); 2289 - } 2290 - 2291 - 2292 - static int hwsim_fops_ps_read(void *dat, u64 *val) 2293 - { 2294 - struct mac80211_hwsim_data *data = dat; 2295 - *val = data->ps; 2296 - return 0; 2297 - } 2298 - 2299 - static int hwsim_fops_ps_write(void *dat, u64 val) 2300 - { 2301 - struct mac80211_hwsim_data *data = dat; 2302 - enum ps_mode old_ps; 2303 - 2304 - if (val != PS_DISABLED && val != PS_ENABLED && val != PS_AUTO_POLL && 2305 - val != PS_MANUAL_POLL) 2306 - return -EINVAL; 2307 - 2308 - old_ps = data->ps; 2309 - data->ps = val; 2310 - 2311 - if (val == PS_MANUAL_POLL) { 2312 - ieee80211_iterate_active_interfaces(data->hw, 2313 - IEEE80211_IFACE_ITER_NORMAL, 2314 - hwsim_send_ps_poll, data); 2315 - data->ps_poll_pending = true; 2316 - } else if (old_ps == PS_DISABLED && val != PS_DISABLED) { 2317 - ieee80211_iterate_active_interfaces(data->hw, 2318 - IEEE80211_IFACE_ITER_NORMAL, 2319 - hwsim_send_nullfunc_ps, 2320 - data); 2321 - } else if (old_ps != PS_DISABLED && val == PS_DISABLED) { 2322 - ieee80211_iterate_active_interfaces(data->hw, 2323 - IEEE80211_IFACE_ITER_NORMAL, 2324 - hwsim_send_nullfunc_no_ps, 2325 - data); 2326 - } 2327 - 2328 - return 0; 2329 - } 2330 - 2331 - DEFINE_SIMPLE_ATTRIBUTE(hwsim_fops_ps, hwsim_fops_ps_read, hwsim_fops_ps_write, 2332 - "%llu\n"); 2333 - 2334 - static int hwsim_write_simulate_radar(void *dat, u64 val) 2335 - { 2336 - struct mac80211_hwsim_data *data = dat; 2337 - 2338 - ieee80211_radar_detected(data->hw); 2339 - 2340 - return 0; 2341 - } 2342 - 2343 - DEFINE_SIMPLE_ATTRIBUTE(hwsim_simulate_radar, NULL, 2344 - hwsim_write_simulate_radar, "%llu\n"); 2345 - 2346 - static int hwsim_fops_group_read(void *dat, u64 *val) 2347 - { 2348 - struct mac80211_hwsim_data *data = dat; 2349 - *val = data->group; 2350 - return 0; 2351 - } 2352 - 2353 - static int hwsim_fops_group_write(void *dat, u64 val) 2354 - { 2355 - struct mac80211_hwsim_data *data = dat; 2356 - data->group = val; 2357 - return 0; 2358 - } 2359 - 2360 - DEFINE_SIMPLE_ATTRIBUTE(hwsim_fops_group, 2361 - hwsim_fops_group_read, hwsim_fops_group_write, 2362 - "%llx\n"); 2363 - 2364 - static struct mac80211_hwsim_data *get_hwsim_data_ref_from_addr( 2365 - struct mac_address *addr) 1777 + static struct mac80211_hwsim_data *get_hwsim_data_ref_from_addr(const u8 *addr) 2366 1778 { 2367 1779 struct mac80211_hwsim_data *data; 2368 1780 bool _found = false; 2369 1781 2370 1782 spin_lock_bh(&hwsim_radio_lock); 2371 1783 list_for_each_entry(data, &hwsim_radios, list) { 2372 - if (memcmp(data->addresses[1].addr, addr, 2373 - sizeof(struct mac_address)) == 0) { 1784 + if (memcmp(data->addresses[1].addr, addr, ETH_ALEN) == 0) { 2374 1785 _found = true; 2375 1786 break; 2376 1787 } ··· 2238 1959 struct hwsim_tx_rate *tx_attempts; 2239 1960 unsigned long ret_skb_ptr; 2240 1961 struct sk_buff *skb, *tmp; 2241 - struct mac_address *src; 1962 + const u8 *src; 2242 1963 unsigned int hwsim_flags; 2243 - 2244 1964 int i; 2245 1965 bool found = false; 2246 1966 1967 + if (info->snd_portid != wmediumd_portid) 1968 + return -EINVAL; 1969 + 2247 1970 if (!info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER] || 2248 - !info->attrs[HWSIM_ATTR_FLAGS] || 2249 - !info->attrs[HWSIM_ATTR_COOKIE] || 2250 - !info->attrs[HWSIM_ATTR_TX_INFO]) 1971 + !info->attrs[HWSIM_ATTR_FLAGS] || 1972 + !info->attrs[HWSIM_ATTR_COOKIE] || 1973 + !info->attrs[HWSIM_ATTR_TX_INFO]) 2251 1974 goto out; 2252 1975 2253 - src = (struct mac_address *)nla_data( 2254 - info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER]); 1976 + src = (void *)nla_data(info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER]); 2255 1977 hwsim_flags = nla_get_u32(info->attrs[HWSIM_ATTR_FLAGS]); 2256 - 2257 1978 ret_skb_ptr = nla_get_u64(info->attrs[HWSIM_ATTR_COOKIE]); 2258 1979 2259 1980 data2 = get_hwsim_data_ref_from_addr(src); 2260 - 2261 - if (data2 == NULL) 1981 + if (!data2) 2262 1982 goto out; 2263 1983 2264 1984 /* look for the skb matching the cookie passed back from user */ ··· 2314 2036 2315 2037 struct mac80211_hwsim_data *data2; 2316 2038 struct ieee80211_rx_status rx_status; 2317 - struct mac_address *dst; 2039 + const u8 *dst; 2318 2040 int frame_data_len; 2319 - char *frame_data; 2041 + void *frame_data; 2320 2042 struct sk_buff *skb = NULL; 2043 + 2044 + if (info->snd_portid != wmediumd_portid) 2045 + return -EINVAL; 2321 2046 2322 2047 if (!info->attrs[HWSIM_ATTR_ADDR_RECEIVER] || 2323 2048 !info->attrs[HWSIM_ATTR_FRAME] || ··· 2328 2047 !info->attrs[HWSIM_ATTR_SIGNAL]) 2329 2048 goto out; 2330 2049 2331 - dst = (struct mac_address *)nla_data( 2332 - info->attrs[HWSIM_ATTR_ADDR_RECEIVER]); 2333 - 2050 + dst = (void *)nla_data(info->attrs[HWSIM_ATTR_ADDR_RECEIVER]); 2334 2051 frame_data_len = nla_len(info->attrs[HWSIM_ATTR_FRAME]); 2335 - frame_data = (char *)nla_data(info->attrs[HWSIM_ATTR_FRAME]); 2052 + frame_data = (void *)nla_data(info->attrs[HWSIM_ATTR_FRAME]); 2336 2053 2337 2054 /* Allocate new skb here */ 2338 2055 skb = alloc_skb(frame_data_len, GFP_KERNEL); 2339 2056 if (skb == NULL) 2340 2057 goto err; 2341 2058 2342 - if (frame_data_len <= IEEE80211_MAX_DATA_LEN) { 2343 - /* Copy the data */ 2344 - memcpy(skb_put(skb, frame_data_len), frame_data, 2345 - frame_data_len); 2346 - } else 2059 + if (frame_data_len > IEEE80211_MAX_DATA_LEN) 2347 2060 goto err; 2348 2061 2349 - data2 = get_hwsim_data_ref_from_addr(dst); 2062 + /* Copy the data */ 2063 + memcpy(skb_put(skb, frame_data_len), frame_data, frame_data_len); 2350 2064 2351 - if (data2 == NULL) 2065 + data2 = get_hwsim_data_ref_from_addr(dst); 2066 + if (!data2) 2352 2067 goto out; 2353 2068 2354 2069 /* check if radio is configured properly */ ··· 2352 2075 if (data2->idle || !data2->started) 2353 2076 goto out; 2354 2077 2355 - /*A frame is received from user space*/ 2078 + /* A frame is received from user space */ 2356 2079 memset(&rx_status, 0, sizeof(rx_status)); 2357 2080 rx_status.freq = data2->channel->center_freq; 2358 2081 rx_status.band = data2->channel->band; ··· 2374 2097 static int hwsim_register_received_nl(struct sk_buff *skb_2, 2375 2098 struct genl_info *info) 2376 2099 { 2377 - if (info == NULL) 2378 - goto out; 2100 + struct mac80211_hwsim_data *data; 2101 + int chans = 1; 2102 + 2103 + spin_lock_bh(&hwsim_radio_lock); 2104 + list_for_each_entry(data, &hwsim_radios, list) 2105 + chans = max(chans, data->channels); 2106 + spin_unlock_bh(&hwsim_radio_lock); 2107 + 2108 + /* In the future we should revise the userspace API and allow it 2109 + * to set a flag that it does support multi-channel, then we can 2110 + * let this pass conditionally on the flag. 2111 + * For current userspace, prohibit it since it won't work right. 2112 + */ 2113 + if (chans > 1) 2114 + return -EOPNOTSUPP; 2115 + 2116 + if (wmediumd_portid) 2117 + return -EBUSY; 2379 2118 2380 2119 wmediumd_portid = info->snd_portid; 2381 2120 ··· 2399 2106 "switching to wmediumd mode with pid %d\n", info->snd_portid); 2400 2107 2401 2108 return 0; 2402 - out: 2403 - printk(KERN_DEBUG "mac80211_hwsim: error occurred in %s\n", __func__); 2404 - return -EINVAL; 2109 + } 2110 + 2111 + static int hwsim_create_radio_nl(struct sk_buff *msg, struct genl_info *info) 2112 + { 2113 + unsigned int chans = channels; 2114 + const char *alpha2 = NULL; 2115 + const struct ieee80211_regdomain *regd = NULL; 2116 + bool reg_strict = info->attrs[HWSIM_ATTR_REG_STRICT_REG]; 2117 + 2118 + if (info->attrs[HWSIM_ATTR_CHANNELS]) 2119 + chans = nla_get_u32(info->attrs[HWSIM_ATTR_CHANNELS]); 2120 + 2121 + if (info->attrs[HWSIM_ATTR_REG_HINT_ALPHA2]) 2122 + alpha2 = nla_data(info->attrs[HWSIM_ATTR_REG_HINT_ALPHA2]); 2123 + 2124 + if (info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]) { 2125 + u32 idx = nla_get_u32(info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]); 2126 + 2127 + if (idx >= ARRAY_SIZE(hwsim_world_regdom_custom)) 2128 + return -EINVAL; 2129 + regd = hwsim_world_regdom_custom[idx]; 2130 + } 2131 + 2132 + return mac80211_hwsim_create_radio(chans, alpha2, regd, reg_strict); 2133 + } 2134 + 2135 + static int hwsim_destroy_radio_nl(struct sk_buff *msg, struct genl_info *info) 2136 + { 2137 + struct mac80211_hwsim_data *data; 2138 + int idx; 2139 + 2140 + if (!info->attrs[HWSIM_ATTR_RADIO_ID]) 2141 + return -EINVAL; 2142 + idx = nla_get_u32(info->attrs[HWSIM_ATTR_RADIO_ID]); 2143 + 2144 + spin_lock_bh(&hwsim_radio_lock); 2145 + list_for_each_entry(data, &hwsim_radios, list) { 2146 + if (data->idx != idx) 2147 + continue; 2148 + list_del(&data->list); 2149 + spin_unlock_bh(&hwsim_radio_lock); 2150 + mac80211_hwsim_destroy_radio(data); 2151 + return 0; 2152 + } 2153 + spin_unlock_bh(&hwsim_radio_lock); 2154 + 2155 + return -ENODEV; 2405 2156 } 2406 2157 2407 2158 /* Generic Netlink operations array */ ··· 2465 2128 .cmd = HWSIM_CMD_TX_INFO_FRAME, 2466 2129 .policy = hwsim_genl_policy, 2467 2130 .doit = hwsim_tx_info_frame_received_nl, 2131 + }, 2132 + { 2133 + .cmd = HWSIM_CMD_CREATE_RADIO, 2134 + .policy = hwsim_genl_policy, 2135 + .doit = hwsim_create_radio_nl, 2136 + .flags = GENL_ADMIN_PERM, 2137 + }, 2138 + { 2139 + .cmd = HWSIM_CMD_DESTROY_RADIO, 2140 + .policy = hwsim_genl_policy, 2141 + .doit = hwsim_destroy_radio_nl, 2142 + .flags = GENL_ADMIN_PERM, 2468 2143 }, 2469 2144 }; 2470 2145 ··· 2506 2157 { 2507 2158 int rc; 2508 2159 2509 - /* userspace test API hasn't been adjusted for multi-channel */ 2510 - if (channels > 1) 2511 - return 0; 2512 - 2513 2160 printk(KERN_INFO "mac80211_hwsim: initializing netlink\n"); 2514 2161 2515 2162 rc = genl_register_family_with_ops(&hwsim_genl_family, hwsim_ops); ··· 2525 2180 2526 2181 static void hwsim_exit_netlink(void) 2527 2182 { 2528 - int ret; 2529 - 2530 - /* userspace test API hasn't been adjusted for multi-channel */ 2531 - if (channels > 1) 2532 - return; 2533 - 2534 - printk(KERN_INFO "mac80211_hwsim: closing netlink\n"); 2535 2183 /* unregister the notifier */ 2536 2184 netlink_unregister_notifier(&hwsim_netlink_notifier); 2537 2185 /* unregister the family */ 2538 - ret = genl_unregister_family(&hwsim_genl_family); 2539 - if (ret) 2540 - printk(KERN_DEBUG "mac80211_hwsim: " 2541 - "unregister family %i\n", ret); 2186 + genl_unregister_family(&hwsim_genl_family); 2542 2187 } 2543 - 2544 - static const struct ieee80211_iface_limit hwsim_if_limits[] = { 2545 - { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) }, 2546 - { .max = 2048, .types = BIT(NL80211_IFTYPE_STATION) | 2547 - BIT(NL80211_IFTYPE_P2P_CLIENT) | 2548 - #ifdef CONFIG_MAC80211_MESH 2549 - BIT(NL80211_IFTYPE_MESH_POINT) | 2550 - #endif 2551 - BIT(NL80211_IFTYPE_AP) | 2552 - BIT(NL80211_IFTYPE_P2P_GO) }, 2553 - { .max = 1, .types = BIT(NL80211_IFTYPE_P2P_DEVICE) }, 2554 - }; 2555 - 2556 - static const struct ieee80211_iface_limit hwsim_if_dfs_limits[] = { 2557 - { .max = 8, .types = BIT(NL80211_IFTYPE_AP) }, 2558 - }; 2559 - 2560 - static struct ieee80211_iface_combination hwsim_if_comb[] = { 2561 - { 2562 - .limits = hwsim_if_limits, 2563 - .n_limits = ARRAY_SIZE(hwsim_if_limits), 2564 - .max_interfaces = 2048, 2565 - .num_different_channels = 1, 2566 - }, 2567 - { 2568 - .limits = hwsim_if_dfs_limits, 2569 - .n_limits = ARRAY_SIZE(hwsim_if_dfs_limits), 2570 - .max_interfaces = 8, 2571 - .num_different_channels = 1, 2572 - .radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) | 2573 - BIT(NL80211_CHAN_WIDTH_20) | 2574 - BIT(NL80211_CHAN_WIDTH_40) | 2575 - BIT(NL80211_CHAN_WIDTH_80) | 2576 - BIT(NL80211_CHAN_WIDTH_160), 2577 - } 2578 - }; 2579 2188 2580 2189 static int __init init_mac80211_hwsim(void) 2581 2190 { 2582 - int i, err = 0; 2583 - u8 addr[ETH_ALEN]; 2584 - struct mac80211_hwsim_data *data; 2585 - struct ieee80211_hw *hw; 2586 - enum ieee80211_band band; 2191 + int i, err; 2587 2192 2588 - if (radios < 1 || radios > 100) 2193 + if (radios < 0 || radios > 100) 2589 2194 return -EINVAL; 2590 2195 2591 2196 if (channels < 1) 2592 2197 return -EINVAL; 2593 2198 2594 - if (channels > 1) { 2595 - hwsim_if_comb[0].num_different_channels = channels; 2596 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan; 2597 - mac80211_hwsim_ops.cancel_hw_scan = 2598 - mac80211_hwsim_cancel_hw_scan; 2599 - mac80211_hwsim_ops.sw_scan_start = NULL; 2600 - mac80211_hwsim_ops.sw_scan_complete = NULL; 2601 - mac80211_hwsim_ops.remain_on_channel = 2602 - mac80211_hwsim_roc; 2603 - mac80211_hwsim_ops.cancel_remain_on_channel = 2604 - mac80211_hwsim_croc; 2605 - mac80211_hwsim_ops.add_chanctx = 2606 - mac80211_hwsim_add_chanctx; 2607 - mac80211_hwsim_ops.remove_chanctx = 2608 - mac80211_hwsim_remove_chanctx; 2609 - mac80211_hwsim_ops.change_chanctx = 2610 - mac80211_hwsim_change_chanctx; 2611 - mac80211_hwsim_ops.assign_vif_chanctx = 2612 - mac80211_hwsim_assign_vif_chanctx; 2613 - mac80211_hwsim_ops.unassign_vif_chanctx = 2614 - mac80211_hwsim_unassign_vif_chanctx; 2615 - } 2199 + mac80211_hwsim_mchan_ops = mac80211_hwsim_ops; 2200 + mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan; 2201 + mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan; 2202 + mac80211_hwsim_mchan_ops.sw_scan_start = NULL; 2203 + mac80211_hwsim_mchan_ops.sw_scan_complete = NULL; 2204 + mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc; 2205 + mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc; 2206 + mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx; 2207 + mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx; 2208 + mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx; 2209 + mac80211_hwsim_mchan_ops.assign_vif_chanctx = 2210 + mac80211_hwsim_assign_vif_chanctx; 2211 + mac80211_hwsim_mchan_ops.unassign_vif_chanctx = 2212 + mac80211_hwsim_unassign_vif_chanctx; 2616 2213 2617 2214 spin_lock_init(&hwsim_radio_lock); 2618 2215 INIT_LIST_HEAD(&hwsim_radios); ··· 2566 2279 hwsim_class = class_create(THIS_MODULE, "mac80211_hwsim"); 2567 2280 if (IS_ERR(hwsim_class)) { 2568 2281 err = PTR_ERR(hwsim_class); 2569 - goto failed_unregister_driver; 2282 + goto out_unregister_driver; 2570 2283 } 2571 2284 2572 - memset(addr, 0, ETH_ALEN); 2573 - addr[0] = 0x02; 2574 - 2575 2285 for (i = 0; i < radios; i++) { 2576 - printk(KERN_DEBUG "mac80211_hwsim: Initializing radio %d\n", 2577 - i); 2578 - hw = ieee80211_alloc_hw(sizeof(*data), &mac80211_hwsim_ops); 2579 - if (!hw) { 2580 - printk(KERN_DEBUG "mac80211_hwsim: ieee80211_alloc_hw " 2581 - "failed\n"); 2582 - err = -ENOMEM; 2583 - goto failed; 2584 - } 2585 - data = hw->priv; 2586 - data->hw = hw; 2286 + const char *reg_alpha2 = NULL; 2287 + const struct ieee80211_regdomain *regd = NULL; 2288 + bool reg_strict = false; 2587 2289 2588 - data->dev = device_create(hwsim_class, NULL, 0, hw, 2589 - "hwsim%d", i); 2590 - if (IS_ERR(data->dev)) { 2591 - printk(KERN_DEBUG 2592 - "mac80211_hwsim: device_create failed (%ld)\n", 2593 - PTR_ERR(data->dev)); 2594 - err = -ENOMEM; 2595 - goto failed_drvdata; 2596 - } 2597 - data->dev->driver = &mac80211_hwsim_driver.driver; 2598 - err = device_bind_driver(data->dev); 2599 - if (err != 0) { 2600 - printk(KERN_DEBUG 2601 - "mac80211_hwsim: device_bind_driver failed (%d)\n", 2602 - err); 2603 - goto failed_hw; 2604 - } 2605 - 2606 - skb_queue_head_init(&data->pending); 2607 - 2608 - SET_IEEE80211_DEV(hw, data->dev); 2609 - addr[3] = i >> 8; 2610 - addr[4] = i; 2611 - memcpy(data->addresses[0].addr, addr, ETH_ALEN); 2612 - memcpy(data->addresses[1].addr, addr, ETH_ALEN); 2613 - data->addresses[1].addr[0] |= 0x40; 2614 - hw->wiphy->n_addresses = 2; 2615 - hw->wiphy->addresses = data->addresses; 2616 - 2617 - hw->wiphy->iface_combinations = hwsim_if_comb; 2618 - hw->wiphy->n_iface_combinations = ARRAY_SIZE(hwsim_if_comb); 2619 - 2620 - if (channels > 1) { 2621 - hw->wiphy->max_scan_ssids = 255; 2622 - hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; 2623 - hw->wiphy->max_remain_on_channel_duration = 1000; 2624 - /* For channels > 1 DFS is not allowed */ 2625 - hw->wiphy->n_iface_combinations = 1; 2626 - } 2627 - 2628 - INIT_DELAYED_WORK(&data->roc_done, hw_roc_done); 2629 - INIT_DELAYED_WORK(&data->hw_scan, hw_scan_work); 2630 - 2631 - hw->channel_change_time = 1; 2632 - hw->queues = 5; 2633 - hw->offchannel_tx_hw_queue = 4; 2634 - hw->wiphy->interface_modes = 2635 - BIT(NL80211_IFTYPE_STATION) | 2636 - BIT(NL80211_IFTYPE_AP) | 2637 - BIT(NL80211_IFTYPE_P2P_CLIENT) | 2638 - BIT(NL80211_IFTYPE_P2P_GO) | 2639 - BIT(NL80211_IFTYPE_ADHOC) | 2640 - BIT(NL80211_IFTYPE_MESH_POINT) | 2641 - BIT(NL80211_IFTYPE_P2P_DEVICE); 2642 - 2643 - hw->flags = IEEE80211_HW_MFP_CAPABLE | 2644 - IEEE80211_HW_SIGNAL_DBM | 2645 - IEEE80211_HW_SUPPORTS_STATIC_SMPS | 2646 - IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | 2647 - IEEE80211_HW_AMPDU_AGGREGATION | 2648 - IEEE80211_HW_WANT_MONITOR_VIF | 2649 - IEEE80211_HW_QUEUE_CONTROL | 2650 - IEEE80211_HW_SUPPORTS_HT_CCK_RATES; 2651 - if (rctbl) 2652 - hw->flags |= IEEE80211_HW_SUPPORTS_RC_TABLE; 2653 - 2654 - hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS | 2655 - WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL | 2656 - WIPHY_FLAG_AP_UAPSD; 2657 - hw->wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR; 2658 - 2659 - /* ask mac80211 to reserve space for magic */ 2660 - hw->vif_data_size = sizeof(struct hwsim_vif_priv); 2661 - hw->sta_data_size = sizeof(struct hwsim_sta_priv); 2662 - hw->chanctx_data_size = sizeof(struct hwsim_chanctx_priv); 2663 - 2664 - memcpy(data->channels_2ghz, hwsim_channels_2ghz, 2665 - sizeof(hwsim_channels_2ghz)); 2666 - memcpy(data->channels_5ghz, hwsim_channels_5ghz, 2667 - sizeof(hwsim_channels_5ghz)); 2668 - memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates)); 2669 - 2670 - for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) { 2671 - struct ieee80211_supported_band *sband = &data->bands[band]; 2672 - switch (band) { 2673 - case IEEE80211_BAND_2GHZ: 2674 - sband->channels = data->channels_2ghz; 2675 - sband->n_channels = 2676 - ARRAY_SIZE(hwsim_channels_2ghz); 2677 - sband->bitrates = data->rates; 2678 - sband->n_bitrates = ARRAY_SIZE(hwsim_rates); 2679 - break; 2680 - case IEEE80211_BAND_5GHZ: 2681 - sband->channels = data->channels_5ghz; 2682 - sband->n_channels = 2683 - ARRAY_SIZE(hwsim_channels_5ghz); 2684 - sband->bitrates = data->rates + 4; 2685 - sband->n_bitrates = ARRAY_SIZE(hwsim_rates) - 4; 2686 - break; 2687 - default: 2688 - continue; 2689 - } 2690 - 2691 - sband->ht_cap.ht_supported = true; 2692 - sband->ht_cap.cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | 2693 - IEEE80211_HT_CAP_GRN_FLD | 2694 - IEEE80211_HT_CAP_SGI_40 | 2695 - IEEE80211_HT_CAP_DSSSCCK40; 2696 - sband->ht_cap.ampdu_factor = 0x3; 2697 - sband->ht_cap.ampdu_density = 0x6; 2698 - memset(&sband->ht_cap.mcs, 0, 2699 - sizeof(sband->ht_cap.mcs)); 2700 - sband->ht_cap.mcs.rx_mask[0] = 0xff; 2701 - sband->ht_cap.mcs.rx_mask[1] = 0xff; 2702 - sband->ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; 2703 - 2704 - hw->wiphy->bands[band] = sband; 2705 - 2706 - sband->vht_cap.vht_supported = true; 2707 - sband->vht_cap.cap = 2708 - IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 | 2709 - IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ | 2710 - IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ | 2711 - IEEE80211_VHT_CAP_RXLDPC | 2712 - IEEE80211_VHT_CAP_SHORT_GI_80 | 2713 - IEEE80211_VHT_CAP_SHORT_GI_160 | 2714 - IEEE80211_VHT_CAP_TXSTBC | 2715 - IEEE80211_VHT_CAP_RXSTBC_1 | 2716 - IEEE80211_VHT_CAP_RXSTBC_2 | 2717 - IEEE80211_VHT_CAP_RXSTBC_3 | 2718 - IEEE80211_VHT_CAP_RXSTBC_4 | 2719 - IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK; 2720 - sband->vht_cap.vht_mcs.rx_mcs_map = 2721 - cpu_to_le16(IEEE80211_VHT_MCS_SUPPORT_0_8 << 0 | 2722 - IEEE80211_VHT_MCS_SUPPORT_0_8 << 2 | 2723 - IEEE80211_VHT_MCS_SUPPORT_0_9 << 4 | 2724 - IEEE80211_VHT_MCS_SUPPORT_0_8 << 6 | 2725 - IEEE80211_VHT_MCS_SUPPORT_0_8 << 8 | 2726 - IEEE80211_VHT_MCS_SUPPORT_0_9 << 10 | 2727 - IEEE80211_VHT_MCS_SUPPORT_0_9 << 12 | 2728 - IEEE80211_VHT_MCS_SUPPORT_0_8 << 14); 2729 - sband->vht_cap.vht_mcs.tx_mcs_map = 2730 - sband->vht_cap.vht_mcs.rx_mcs_map; 2731 - } 2732 - /* By default all radios are belonging to the first group */ 2733 - data->group = 1; 2734 - mutex_init(&data->mutex); 2735 - 2736 - /* Enable frame retransmissions for lossy channels */ 2737 - hw->max_rates = 4; 2738 - hw->max_rate_tries = 11; 2739 - 2740 - /* Work to be done prior to ieee80211_register_hw() */ 2741 2290 switch (regtest) { 2742 - case HWSIM_REGTEST_DISABLED: 2743 - case HWSIM_REGTEST_DRIVER_REG_FOLLOW: 2744 - case HWSIM_REGTEST_DRIVER_REG_ALL: 2745 2291 case HWSIM_REGTEST_DIFF_COUNTRY: 2746 - /* 2747 - * Nothing to be done for driver regulatory domain 2748 - * hints prior to ieee80211_register_hw() 2749 - */ 2750 - break; 2751 - case HWSIM_REGTEST_WORLD_ROAM: 2752 - if (i == 0) { 2753 - hw->wiphy->regulatory_flags |= 2754 - REGULATORY_CUSTOM_REG; 2755 - wiphy_apply_custom_regulatory(hw->wiphy, 2756 - &hwsim_world_regdom_custom_01); 2757 - } 2758 - break; 2759 - case HWSIM_REGTEST_CUSTOM_WORLD: 2760 - hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; 2761 - wiphy_apply_custom_regulatory(hw->wiphy, 2762 - &hwsim_world_regdom_custom_01); 2763 - break; 2764 - case HWSIM_REGTEST_CUSTOM_WORLD_2: 2765 - if (i == 0) { 2766 - hw->wiphy->regulatory_flags |= 2767 - REGULATORY_CUSTOM_REG; 2768 - wiphy_apply_custom_regulatory(hw->wiphy, 2769 - &hwsim_world_regdom_custom_01); 2770 - } else if (i == 1) { 2771 - hw->wiphy->regulatory_flags |= 2772 - REGULATORY_CUSTOM_REG; 2773 - wiphy_apply_custom_regulatory(hw->wiphy, 2774 - &hwsim_world_regdom_custom_02); 2775 - } 2776 - break; 2777 - case HWSIM_REGTEST_STRICT_ALL: 2778 - hw->wiphy->regulatory_flags |= REGULATORY_STRICT_REG; 2779 - break; 2780 - case HWSIM_REGTEST_STRICT_FOLLOW: 2781 - case HWSIM_REGTEST_STRICT_AND_DRIVER_REG: 2782 - if (i == 0) 2783 - hw->wiphy->regulatory_flags |= 2784 - REGULATORY_STRICT_REG; 2785 - break; 2786 - case HWSIM_REGTEST_ALL: 2787 - if (i == 0) { 2788 - hw->wiphy->regulatory_flags |= 2789 - REGULATORY_CUSTOM_REG; 2790 - wiphy_apply_custom_regulatory(hw->wiphy, 2791 - &hwsim_world_regdom_custom_01); 2792 - } else if (i == 1) { 2793 - hw->wiphy->regulatory_flags |= 2794 - REGULATORY_CUSTOM_REG; 2795 - wiphy_apply_custom_regulatory(hw->wiphy, 2796 - &hwsim_world_regdom_custom_02); 2797 - } else if (i == 4) 2798 - hw->wiphy->regulatory_flags |= 2799 - REGULATORY_STRICT_REG; 2800 - break; 2801 - default: 2802 - break; 2803 - } 2804 - 2805 - /* give the regulatory workqueue a chance to run */ 2806 - if (regtest) 2807 - schedule_timeout_interruptible(1); 2808 - err = ieee80211_register_hw(hw); 2809 - if (err < 0) { 2810 - printk(KERN_DEBUG "mac80211_hwsim: " 2811 - "ieee80211_register_hw failed (%d)\n", err); 2812 - goto failed_hw; 2813 - } 2814 - 2815 - /* Work to be done after to ieee80211_register_hw() */ 2816 - switch (regtest) { 2817 - case HWSIM_REGTEST_WORLD_ROAM: 2818 - case HWSIM_REGTEST_DISABLED: 2292 + if (i < ARRAY_SIZE(hwsim_alpha2s)) 2293 + reg_alpha2 = hwsim_alpha2s[i]; 2819 2294 break; 2820 2295 case HWSIM_REGTEST_DRIVER_REG_FOLLOW: 2821 2296 if (!i) 2822 - regulatory_hint(hw->wiphy, hwsim_alpha2s[0]); 2297 + reg_alpha2 = hwsim_alpha2s[0]; 2823 2298 break; 2824 - case HWSIM_REGTEST_DRIVER_REG_ALL: 2825 2299 case HWSIM_REGTEST_STRICT_ALL: 2826 - regulatory_hint(hw->wiphy, hwsim_alpha2s[0]); 2300 + reg_strict = true; 2301 + case HWSIM_REGTEST_DRIVER_REG_ALL: 2302 + reg_alpha2 = hwsim_alpha2s[0]; 2827 2303 break; 2828 - case HWSIM_REGTEST_DIFF_COUNTRY: 2829 - if (i < ARRAY_SIZE(hwsim_alpha2s)) 2830 - regulatory_hint(hw->wiphy, hwsim_alpha2s[i]); 2304 + case HWSIM_REGTEST_WORLD_ROAM: 2305 + if (i == 0) 2306 + regd = &hwsim_world_regdom_custom_01; 2831 2307 break; 2832 2308 case HWSIM_REGTEST_CUSTOM_WORLD: 2309 + regd = &hwsim_world_regdom_custom_01; 2310 + break; 2833 2311 case HWSIM_REGTEST_CUSTOM_WORLD_2: 2834 - /* 2835 - * Nothing to be done for custom world regulatory 2836 - * domains after to ieee80211_register_hw 2837 - */ 2312 + if (i == 0) 2313 + regd = &hwsim_world_regdom_custom_01; 2314 + else if (i == 1) 2315 + regd = &hwsim_world_regdom_custom_02; 2838 2316 break; 2839 2317 case HWSIM_REGTEST_STRICT_FOLLOW: 2840 - if (i == 0) 2841 - regulatory_hint(hw->wiphy, hwsim_alpha2s[0]); 2318 + if (i == 0) { 2319 + reg_strict = true; 2320 + reg_alpha2 = hwsim_alpha2s[0]; 2321 + } 2842 2322 break; 2843 2323 case HWSIM_REGTEST_STRICT_AND_DRIVER_REG: 2844 - if (i == 0) 2845 - regulatory_hint(hw->wiphy, hwsim_alpha2s[0]); 2846 - else if (i == 1) 2847 - regulatory_hint(hw->wiphy, hwsim_alpha2s[1]); 2324 + if (i == 0) { 2325 + reg_strict = true; 2326 + reg_alpha2 = hwsim_alpha2s[0]; 2327 + } else if (i == 1) { 2328 + reg_alpha2 = hwsim_alpha2s[1]; 2329 + } 2848 2330 break; 2849 2331 case HWSIM_REGTEST_ALL: 2850 - if (i == 2) 2851 - regulatory_hint(hw->wiphy, hwsim_alpha2s[0]); 2852 - else if (i == 3) 2853 - regulatory_hint(hw->wiphy, hwsim_alpha2s[1]); 2854 - else if (i == 4) 2855 - regulatory_hint(hw->wiphy, hwsim_alpha2s[2]); 2332 + switch (i) { 2333 + case 0: 2334 + regd = &hwsim_world_regdom_custom_01; 2335 + break; 2336 + case 1: 2337 + regd = &hwsim_world_regdom_custom_02; 2338 + break; 2339 + case 2: 2340 + reg_alpha2 = hwsim_alpha2s[0]; 2341 + break; 2342 + case 3: 2343 + reg_alpha2 = hwsim_alpha2s[1]; 2344 + break; 2345 + case 4: 2346 + reg_strict = true; 2347 + reg_alpha2 = hwsim_alpha2s[2]; 2348 + break; 2349 + } 2856 2350 break; 2857 2351 default: 2858 2352 break; 2859 2353 } 2860 2354 2861 - wiphy_debug(hw->wiphy, "hwaddr %pm registered\n", 2862 - hw->wiphy->perm_addr); 2863 - 2864 - data->debugfs = debugfs_create_dir("hwsim", 2865 - hw->wiphy->debugfsdir); 2866 - debugfs_create_file("ps", 0666, data->debugfs, data, 2867 - &hwsim_fops_ps); 2868 - debugfs_create_file("group", 0666, data->debugfs, data, 2869 - &hwsim_fops_group); 2870 - if (channels == 1) 2871 - debugfs_create_file("dfs_simulate_radar", 0222, 2872 - data->debugfs, 2873 - data, &hwsim_simulate_radar); 2874 - 2875 - tasklet_hrtimer_init(&data->beacon_timer, 2876 - mac80211_hwsim_beacon, 2877 - CLOCK_MONOTONIC_RAW, HRTIMER_MODE_ABS); 2878 - 2879 - list_add_tail(&data->list, &hwsim_radios); 2355 + err = mac80211_hwsim_create_radio(channels, reg_alpha2, 2356 + regd, reg_strict); 2357 + if (err < 0) 2358 + goto out_free_radios; 2880 2359 } 2881 2360 2882 2361 hwsim_mon = alloc_netdev(0, "hwsim%d", hwsim_mon_setup); 2883 2362 if (hwsim_mon == NULL) { 2884 2363 err = -ENOMEM; 2885 - goto failed; 2364 + goto out_free_radios; 2886 2365 } 2887 2366 2888 2367 rtnl_lock(); 2889 - 2890 2368 err = dev_alloc_name(hwsim_mon, hwsim_mon->name); 2891 - if (err < 0) 2892 - goto failed_mon; 2893 - 2369 + if (err < 0) { 2370 + rtnl_unlock(); 2371 + goto out_free_radios; 2372 + } 2894 2373 2895 2374 err = register_netdevice(hwsim_mon); 2896 - if (err < 0) 2897 - goto failed_mon; 2898 - 2375 + if (err < 0) { 2376 + rtnl_unlock(); 2377 + goto out_free_mon; 2378 + } 2899 2379 rtnl_unlock(); 2900 2380 2901 2381 err = hwsim_init_netlink(); 2902 2382 if (err < 0) 2903 - goto failed_nl; 2383 + goto out_free_mon; 2904 2384 2905 2385 return 0; 2906 2386 2907 - failed_nl: 2908 - printk(KERN_DEBUG "mac_80211_hwsim: failed initializing netlink\n"); 2909 - return err; 2910 - 2911 - failed_mon: 2912 - rtnl_unlock(); 2387 + out_free_mon: 2913 2388 free_netdev(hwsim_mon); 2389 + out_free_radios: 2914 2390 mac80211_hwsim_free(); 2915 - return err; 2916 - 2917 - failed_hw: 2918 - device_unregister(data->dev); 2919 - failed_drvdata: 2920 - ieee80211_free_hw(hw); 2921 - failed: 2922 - mac80211_hwsim_free(); 2923 - failed_unregister_driver: 2391 + out_unregister_driver: 2924 2392 platform_driver_unregister(&mac80211_hwsim_driver); 2925 2393 return err; 2926 2394 }
+18
drivers/net/wireless/mac80211_hwsim.h
··· 65 65 * kernel, uses: 66 66 * %HWSIM_ATTR_ADDR_TRANSMITTER, %HWSIM_ATTR_FLAGS, 67 67 * %HWSIM_ATTR_TX_INFO, %HWSIM_ATTR_SIGNAL, %HWSIM_ATTR_COOKIE 68 + * @HWSIM_CMD_CREATE_RADIO: create a new radio with the given parameters, 69 + * returns the radio ID (>= 0) or negative on errors 70 + * @HWSIM_CMD_DESTROY_RADIO: destroy a radio 68 71 * @__HWSIM_CMD_MAX: enum limit 69 72 */ 70 73 enum { ··· 75 72 HWSIM_CMD_REGISTER, 76 73 HWSIM_CMD_FRAME, 77 74 HWSIM_CMD_TX_INFO_FRAME, 75 + HWSIM_CMD_CREATE_RADIO, 76 + HWSIM_CMD_DESTROY_RADIO, 78 77 __HWSIM_CMD_MAX, 79 78 }; 80 79 #define HWSIM_CMD_MAX (_HWSIM_CMD_MAX - 1) ··· 99 94 space 100 95 * @HWSIM_ATTR_TX_INFO: ieee80211_tx_rate array 101 96 * @HWSIM_ATTR_COOKIE: sk_buff cookie to identify the frame 97 + * @HWSIM_ATTR_CHANNELS: u32 attribute used with the %HWSIM_CMD_CREATE_RADIO 98 + * command giving the number of channels supported by the new radio 99 + * @HWSIM_ATTR_RADIO_ID: u32 attribute used with %HWSIM_CMD_DESTROY_RADIO 100 + * only to destroy a radio 101 + * @HWSIM_ATTR_REG_HINT_ALPHA2: alpha2 for regulatoro driver hint 102 + * (nla string, length 2) 103 + * @HWSIM_ATTR_REG_CUSTOM_REG: custom regulatory domain index (u32 attribute) 104 + * @HWSIM_ATTR_REG_STRICT_REG: request REGULATORY_STRICT_REG (flag attribute) 102 105 * @__HWSIM_ATTR_MAX: enum limit 103 106 */ 104 107 ··· 121 108 HWSIM_ATTR_SIGNAL, 122 109 HWSIM_ATTR_TX_INFO, 123 110 HWSIM_ATTR_COOKIE, 111 + HWSIM_ATTR_CHANNELS, 112 + HWSIM_ATTR_RADIO_ID, 113 + HWSIM_ATTR_REG_HINT_ALPHA2, 114 + HWSIM_ATTR_REG_CUSTOM_REG, 115 + HWSIM_ATTR_REG_STRICT_REG, 124 116 __HWSIM_ATTR_MAX, 125 117 }; 126 118 #define HWSIM_ATTR_MAX (__HWSIM_ATTR_MAX - 1)
+2 -2
drivers/net/wireless/mwifiex/Kconfig
··· 31 31 mwifiex_pcie. 32 32 33 33 config MWIFIEX_USB 34 - tristate "Marvell WiFi-Ex Driver for USB8797" 34 + tristate "Marvell WiFi-Ex Driver for USB8797/8897" 35 35 depends on MWIFIEX && USB 36 36 select FW_LOADER 37 37 ---help--- 38 38 This adds support for wireless adapters based on Marvell 39 - Avastar 88W8797 chipset with USB interface. 39 + 8797/8897 chipset with USB interface. 40 40 41 41 If you choose to build it as a module, it will be called 42 42 mwifiex_usb.
+14
drivers/net/wireless/mwifiex/cfg80211.c
··· 2677 2677 struct wiphy *wiphy; 2678 2678 struct mwifiex_private *priv = adapter->priv[MWIFIEX_BSS_TYPE_STA]; 2679 2679 u8 *country_code; 2680 + u32 thr, retry; 2680 2681 2681 2682 /* create a new wiphy for use with cfg80211 */ 2682 2683 wiphy = wiphy_new(&mwifiex_cfg80211_ops, ··· 2766 2765 wiphy_info(wiphy, "ignoring F/W country code %2.2s\n", 2767 2766 country_code); 2768 2767 } 2768 + 2769 + mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB, 2770 + HostCmd_ACT_GEN_GET, FRAG_THRESH_I, &thr); 2771 + wiphy->frag_threshold = thr; 2772 + mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB, 2773 + HostCmd_ACT_GEN_GET, RTS_THRESH_I, &thr); 2774 + wiphy->rts_threshold = thr; 2775 + mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB, 2776 + HostCmd_ACT_GEN_GET, SHORT_RETRY_LIM_I, &retry); 2777 + wiphy->retry_short = (u8) retry; 2778 + mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB, 2779 + HostCmd_ACT_GEN_GET, LONG_RETRY_LIM_I, &retry); 2780 + wiphy->retry_long = (u8) retry; 2769 2781 2770 2782 adapter->wiphy = wiphy; 2771 2783 return ret;
+1 -1
drivers/net/wireless/mwifiex/fw.h
··· 226 226 227 227 /* HW_SPEC fw_cap_info */ 228 228 229 - #define ISSUPP_11ACENABLED(fw_cap_info) (fw_cap_info & (BIT(13)|BIT(14))) 229 + #define ISSUPP_11ACENABLED(fw_cap_info) (fw_cap_info & (BIT(12)|BIT(13))) 230 230 231 231 #define GET_VHTCAP_CHWDSET(vht_cap_info) ((vht_cap_info >> 2) & 0x3) 232 232 #define GET_VHTNSSMCS(mcs_mapset, nss) ((mcs_mapset >> (2 * (nss - 1))) & 0x3)
+2 -2
drivers/net/wireless/mwifiex/scan.c
··· 1681 1681 const u8 *ie_buf; 1682 1682 size_t ie_len; 1683 1683 u16 channel = 0; 1684 - u64 fw_tsf = 0; 1684 + __le64 fw_tsf = 0; 1685 1685 u16 beacon_size = 0; 1686 1686 u32 curr_bcn_bytes; 1687 1687 u32 freq; ··· 1815 1815 ie_buf, ie_len, rssi, GFP_KERNEL); 1816 1816 bss_priv = (struct mwifiex_bss_priv *)bss->priv; 1817 1817 bss_priv->band = band; 1818 - bss_priv->fw_tsf = fw_tsf; 1818 + bss_priv->fw_tsf = le64_to_cpu(fw_tsf); 1819 1819 if (priv->media_connected && 1820 1820 !memcmp(bssid, 1821 1821 priv->curr_bss_params.bss_descriptor
+41 -13
drivers/net/wireless/mwifiex/usb.c
··· 22 22 23 23 #define USB_VERSION "1.0" 24 24 25 - static const char usbdriver_name[] = "usb8797"; 25 + static const char usbdriver_name[] = "usb8xxx"; 26 26 27 27 static struct mwifiex_if_ops usb_ops; 28 28 static struct semaphore add_remove_card_sem; 29 29 static struct usb_card_rec *usb_card; 30 30 31 31 static struct usb_device_id mwifiex_usb_table[] = { 32 - {USB_DEVICE(USB8797_VID, USB8797_PID_1)}, 33 - {USB_DEVICE_AND_INTERFACE_INFO(USB8797_VID, USB8797_PID_2, 32 + /* 8797 */ 33 + {USB_DEVICE(USB8XXX_VID, USB8797_PID_1)}, 34 + {USB_DEVICE_AND_INTERFACE_INFO(USB8XXX_VID, USB8797_PID_2, 35 + USB_CLASS_VENDOR_SPEC, 36 + USB_SUBCLASS_VENDOR_SPEC, 0xff)}, 37 + /* 8897 */ 38 + {USB_DEVICE(USB8XXX_VID, USB8897_PID_1)}, 39 + {USB_DEVICE_AND_INTERFACE_INFO(USB8XXX_VID, USB8897_PID_2, 34 40 USB_CLASS_VENDOR_SPEC, 35 41 USB_SUBCLASS_VENDOR_SPEC, 0xff)}, 36 42 { } /* Terminating entry */ ··· 349 343 id_vendor, id_product, bcd_device); 350 344 351 345 /* PID_1 is used for firmware downloading only */ 352 - if (id_product == USB8797_PID_1) 353 - card->usb_boot_state = USB8797_FW_DNLD; 354 - else 355 - card->usb_boot_state = USB8797_FW_READY; 346 + switch (id_product) { 347 + case USB8797_PID_1: 348 + case USB8897_PID_1: 349 + card->usb_boot_state = USB8XXX_FW_DNLD; 350 + break; 351 + case USB8797_PID_2: 352 + case USB8897_PID_2: 353 + card->usb_boot_state = USB8XXX_FW_READY; 354 + break; 355 + default: 356 + pr_warning("unknown id_product %#x\n", id_product); 357 + card->usb_boot_state = USB8XXX_FW_DNLD; 358 + break; 359 + } 356 360 357 361 card->udev = udev; 358 362 card->intf = intf; ··· 771 755 772 756 card->adapter = adapter; 773 757 adapter->dev = &card->udev->dev; 774 - strcpy(adapter->fw_name, USB8797_DEFAULT_FW_NAME); 775 758 usb_card = card; 759 + 760 + switch (le16_to_cpu(card->udev->descriptor.idProduct)) { 761 + case USB8897_PID_1: 762 + case USB8897_PID_2: 763 + strcpy(adapter->fw_name, USB8897_DEFAULT_FW_NAME); 764 + break; 765 + case USB8797_PID_1: 766 + case USB8797_PID_2: 767 + default: 768 + strcpy(adapter->fw_name, USB8797_DEFAULT_FW_NAME); 769 + break; 770 + } 776 771 777 772 return 0; 778 773 } ··· 800 773 { 801 774 int ret = 0; 802 775 u8 *firmware = fw->fw_buf, *recv_buff; 803 - u32 retries = USB8797_FW_MAX_RETRY, dlen; 776 + u32 retries = USB8XXX_FW_MAX_RETRY, dlen; 804 777 u32 fw_seqnum = 0, tlen = 0, dnld_cmd = 0; 805 778 struct fw_data *fwdata; 806 779 struct fw_sync_header sync_fw; ··· 902 875 continue; 903 876 } 904 877 905 - retries = USB8797_FW_MAX_RETRY; 878 + retries = USB8XXX_FW_MAX_RETRY; 906 879 break; 907 880 } 908 881 fw_seqnum++; ··· 926 899 int ret; 927 900 struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; 928 901 929 - if (card->usb_boot_state == USB8797_FW_DNLD) { 902 + if (card->usb_boot_state == USB8XXX_FW_DNLD) { 930 903 ret = mwifiex_prog_fw_w_helper(adapter, fw); 931 904 if (ret) 932 905 return -1; 933 906 934 907 /* Boot state changes after successful firmware download */ 935 - if (card->usb_boot_state == USB8797_FW_DNLD) 908 + if (card->usb_boot_state == USB8XXX_FW_DNLD) 936 909 return -1; 937 910 } 938 911 ··· 1066 1039 MODULE_DESCRIPTION("Marvell WiFi-Ex USB Driver version" USB_VERSION); 1067 1040 MODULE_VERSION(USB_VERSION); 1068 1041 MODULE_LICENSE("GPL v2"); 1069 - MODULE_FIRMWARE("mrvl/usb8797_uapsta.bin"); 1042 + MODULE_FIRMWARE(USB8797_DEFAULT_FW_NAME); 1043 + MODULE_FIRMWARE(USB8897_DEFAULT_FW_NAME);
+8 -4
drivers/net/wireless/mwifiex/usb.h
··· 22 22 23 23 #include <linux/usb.h> 24 24 25 - #define USB8797_VID 0x1286 25 + #define USB8XXX_VID 0x1286 26 + 26 27 #define USB8797_PID_1 0x2043 27 28 #define USB8797_PID_2 0x2044 29 + #define USB8897_PID_1 0x2045 30 + #define USB8897_PID_2 0x2046 28 31 29 - #define USB8797_FW_DNLD 1 30 - #define USB8797_FW_READY 2 31 - #define USB8797_FW_MAX_RETRY 3 32 + #define USB8XXX_FW_DNLD 1 33 + #define USB8XXX_FW_READY 2 34 + #define USB8XXX_FW_MAX_RETRY 3 32 35 33 36 #define MWIFIEX_TX_DATA_URB 6 34 37 #define MWIFIEX_RX_DATA_URB 6 35 38 #define MWIFIEX_USB_TIMEOUT 100 36 39 37 40 #define USB8797_DEFAULT_FW_NAME "mrvl/usb8797_uapsta.bin" 41 + #define USB8897_DEFAULT_FW_NAME "mrvl/usb8897_uapsta.bin" 38 42 39 43 #define FW_DNLD_TX_BUF_SIZE 620 40 44 #define FW_DNLD_RX_BUF_SIZE 2048
-2
drivers/net/wireless/mwl8k.c
··· 5892 5892 5893 5893 hw->extra_tx_headroom -= priv->ap_fw ? REDUCED_TX_HEADROOM : 0; 5894 5894 5895 - hw->channel_change_time = 10; 5896 - 5897 5895 hw->queues = MWL8K_TX_WMM_QUEUES; 5898 5896 5899 5897 /* Set rssi values to dBm */
-1
drivers/net/wireless/p54/main.c
··· 756 756 BIT(NL80211_IFTYPE_AP) | 757 757 BIT(NL80211_IFTYPE_MESH_POINT); 758 758 759 - dev->channel_change_time = 1000; /* TODO: find actual value */ 760 759 priv->beacon_req_id = cpu_to_le32(0); 761 760 priv->tx_stats[P54_QUEUE_BEACON].limit = 1; 762 761 priv->tx_stats[P54_QUEUE_FWSCAN].limit = 1;
+1 -1
drivers/net/wireless/p54/txrx.c
··· 586 586 chan = priv->curchan; 587 587 if (chan) { 588 588 struct survey_info *survey = &priv->survey[chan->hw_value]; 589 - survey->noise = clamp_t(s8, priv->noise, -128, 127); 589 + survey->noise = clamp(priv->noise, -128, 127); 590 590 survey->channel_time = priv->survey_raw.active; 591 591 survey->channel_time_tx = priv->survey_raw.tx; 592 592 survey->channel_time_busy = priv->survey_raw.tx +
-1
drivers/net/wireless/rtlwifi/base.c
··· 353 353 354 354 /* TODO: Correct this value for our hw */ 355 355 /* TODO: define these hard code value */ 356 - hw->channel_change_time = 100; 357 356 hw->max_listen_interval = 10; 358 357 hw->max_rate_tries = 4; 359 358 /* hw->max_rates = 1; */
+1
drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
··· 317 317 {RTL_USB_DEVICE(0x0bda, 0x5088, rtl92cu_hal_cfg)}, /*Thinkware-CC&C*/ 318 318 {RTL_USB_DEVICE(0x0df6, 0x0052, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/ 319 319 {RTL_USB_DEVICE(0x0df6, 0x005c, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/ 320 + {RTL_USB_DEVICE(0x0df6, 0x0077, rtl92cu_hal_cfg)}, /*Sitecom-WLA2100V2*/ 320 321 {RTL_USB_DEVICE(0x0eb0, 0x9071, rtl92cu_hal_cfg)}, /*NO Brand - Etop*/ 321 322 {RTL_USB_DEVICE(0x4856, 0x0091, rtl92cu_hal_cfg)}, /*NetweeN - Feixun*/ 322 323 /* HP - Lite-On ,8188CUS Slim Combo */
-1
drivers/net/wireless/ti/wl1251/main.c
··· 1468 1468 1469 1469 /* unit us */ 1470 1470 /* FIXME: find a proper value */ 1471 - wl->hw->channel_change_time = 10000; 1472 1471 1473 1472 wl->hw->flags = IEEE80211_HW_SIGNAL_DBM | 1474 1473 IEEE80211_HW_SUPPORTS_PS |
+10 -1
drivers/net/wireless/ti/wlcore/main.c
··· 4457 4457 if (ret < 0) 4458 4458 goto out; 4459 4459 4460 + if ((changed & BSS_CHANGED_TXPOWER) && 4461 + bss_conf->txpower != wlvif->power_level) { 4462 + 4463 + ret = wl1271_acx_tx_power(wl, wlvif, bss_conf->txpower); 4464 + if (ret < 0) 4465 + goto out; 4466 + 4467 + wlvif->power_level = bss_conf->txpower; 4468 + } 4469 + 4460 4470 if (is_ap) 4461 4471 wl1271_bss_info_changed_ap(wl, vif, bss_conf, changed); 4462 4472 else ··· 5720 5710 5721 5711 /* unit us */ 5722 5712 /* FIXME: find a proper value */ 5723 - wl->hw->channel_change_time = 10000; 5724 5713 wl->hw->max_listen_interval = wl->conf.conn.max_listen_interval; 5725 5714 5726 5715 wl->hw->flags = IEEE80211_HW_SIGNAL_DBM |
+1
drivers/nfc/Kconfig
··· 58 58 59 59 source "drivers/nfc/pn544/Kconfig" 60 60 source "drivers/nfc/microread/Kconfig" 61 + source "drivers/nfc/nfcmrvl/Kconfig" 61 62 62 63 endmenu
+1
drivers/nfc/Makefile
··· 9 9 obj-$(CONFIG_NFC_MEI_PHY) += mei_phy.o 10 10 obj-$(CONFIG_NFC_SIM) += nfcsim.o 11 11 obj-$(CONFIG_NFC_PORT100) += port100.o 12 + obj-$(CONFIG_NFC_MRVL) += nfcmrvl/ 12 13 13 14 ccflags-$(CONFIG_NFC_DEBUG) := -DDEBUG
+1 -1
drivers/nfc/mei_phy.c
··· 127 127 128 128 reply_size = mei_cl_recv(device, skb->data, MEI_NFC_MAX_READ); 129 129 if (reply_size < MEI_NFC_HEADER_SIZE) { 130 - kfree(skb); 130 + kfree_skb(skb); 131 131 return; 132 132 } 133 133
+23
drivers/nfc/nfcmrvl/Kconfig
··· 1 + config NFC_MRVL 2 + tristate "Marvell NFC driver support" 3 + depends on NFC_NCI 4 + help 5 + The core driver to support Marvell NFC devices. 6 + 7 + This driver is required if you want to support 8 + Marvell NFC device 8897. 9 + 10 + Say Y here to compile Marvell NFC driver into the kernel or 11 + say M to compile it as module. 12 + 13 + config NFC_MRVL_USB 14 + tristate "Marvell NFC-over-USB driver" 15 + depends on NFC_MRVL && USB 16 + help 17 + Marvell NFC-over-USB driver. 18 + 19 + This driver provides support for Marvell NFC-over-USB devices: 20 + 8897. 21 + 22 + Say Y here to compile support for Marvell NFC-over-USB driver 23 + into the kernel or say M to compile it as module.
+9
drivers/nfc/nfcmrvl/Makefile
··· 1 + # 2 + # Makefile for NFCMRVL NCI based NFC driver 3 + # 4 + 5 + nfcmrvl-y += main.o 6 + obj-$(CONFIG_NFC_MRVL) += nfcmrvl.o 7 + 8 + nfcmrvl_usb-y += usb.o 9 + obj-$(CONFIG_NFC_MRVL_USB) += nfcmrvl_usb.o
+165
drivers/nfc/nfcmrvl/main.c
··· 1 + /* 2 + * Marvell NFC driver: major functions 3 + * 4 + * Copyright (C) 2014, Marvell International Ltd. 5 + * 6 + * This software file (the "File") is distributed by Marvell International 7 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991 8 + * (the "License"). You may use, redistribute and/or modify this File in 9 + * accordance with the terms and conditions of the License, a copy of which 10 + * is available on the worldwide web at 11 + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 12 + * 13 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 14 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 15 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 16 + * this warranty disclaimer. 17 + */ 18 + 19 + #include <linux/module.h> 20 + #include <linux/nfc.h> 21 + #include <net/nfc/nci.h> 22 + #include <net/nfc/nci_core.h> 23 + #include "nfcmrvl.h" 24 + 25 + #define VERSION "1.0" 26 + 27 + static int nfcmrvl_nci_open(struct nci_dev *ndev) 28 + { 29 + struct nfcmrvl_private *priv = nci_get_drvdata(ndev); 30 + int err; 31 + 32 + if (test_and_set_bit(NFCMRVL_NCI_RUNNING, &priv->flags)) 33 + return 0; 34 + 35 + err = priv->if_ops->nci_open(priv); 36 + 37 + if (err) 38 + clear_bit(NFCMRVL_NCI_RUNNING, &priv->flags); 39 + 40 + return err; 41 + } 42 + 43 + static int nfcmrvl_nci_close(struct nci_dev *ndev) 44 + { 45 + struct nfcmrvl_private *priv = nci_get_drvdata(ndev); 46 + 47 + if (!test_and_clear_bit(NFCMRVL_NCI_RUNNING, &priv->flags)) 48 + return 0; 49 + 50 + priv->if_ops->nci_close(priv); 51 + 52 + return 0; 53 + } 54 + 55 + static int nfcmrvl_nci_send(struct nci_dev *ndev, struct sk_buff *skb) 56 + { 57 + struct nfcmrvl_private *priv = nci_get_drvdata(ndev); 58 + 59 + nfc_info(priv->dev, "send entry, len %d\n", skb->len); 60 + 61 + skb->dev = (void *)ndev; 62 + 63 + if (!test_bit(NFCMRVL_NCI_RUNNING, &priv->flags)) 64 + return -EBUSY; 65 + 66 + return priv->if_ops->nci_send(priv, skb); 67 + } 68 + 69 + static int nfcmrvl_nci_setup(struct nci_dev *ndev) 70 + { 71 + __u8 val; 72 + 73 + val = NFCMRVL_GPIO_PIN_NFC_NOT_ALLOWED; 74 + nci_set_config(ndev, NFCMRVL_NOT_ALLOWED_ID, 1, &val); 75 + val = NFCMRVL_GPIO_PIN_NFC_ACTIVE; 76 + nci_set_config(ndev, NFCMRVL_ACTIVE_ID, 1, &val); 77 + val = NFCMRVL_EXT_COEX_ENABLE; 78 + nci_set_config(ndev, NFCMRVL_EXT_COEX_ID, 1, &val); 79 + 80 + return 0; 81 + } 82 + 83 + static struct nci_ops nfcmrvl_nci_ops = { 84 + .open = nfcmrvl_nci_open, 85 + .close = nfcmrvl_nci_close, 86 + .send = nfcmrvl_nci_send, 87 + .setup = nfcmrvl_nci_setup, 88 + }; 89 + 90 + struct nfcmrvl_private *nfcmrvl_nci_register_dev(void *drv_data, 91 + struct nfcmrvl_if_ops *ops, 92 + struct device *dev) 93 + { 94 + struct nfcmrvl_private *priv; 95 + int rc; 96 + u32 protocols; 97 + 98 + priv = kzalloc(sizeof(*priv), GFP_KERNEL); 99 + if (!priv) 100 + return ERR_PTR(-ENOMEM); 101 + 102 + priv->drv_data = drv_data; 103 + priv->if_ops = ops; 104 + priv->dev = dev; 105 + 106 + protocols = NFC_PROTO_JEWEL_MASK 107 + | NFC_PROTO_MIFARE_MASK | NFC_PROTO_FELICA_MASK 108 + | NFC_PROTO_ISO14443_MASK 109 + | NFC_PROTO_ISO14443_B_MASK 110 + | NFC_PROTO_NFC_DEP_MASK; 111 + 112 + priv->ndev = nci_allocate_device(&nfcmrvl_nci_ops, protocols, 0, 0); 113 + if (!priv->ndev) { 114 + nfc_err(dev, "nci_allocate_device failed"); 115 + rc = -ENOMEM; 116 + goto error; 117 + } 118 + 119 + nci_set_drvdata(priv->ndev, priv); 120 + 121 + rc = nci_register_device(priv->ndev); 122 + if (rc) { 123 + nfc_err(dev, "nci_register_device failed %d", rc); 124 + nci_free_device(priv->ndev); 125 + goto error; 126 + } 127 + 128 + nfc_info(dev, "registered with nci successfully\n"); 129 + return priv; 130 + 131 + error: 132 + kfree(priv); 133 + return ERR_PTR(rc); 134 + } 135 + EXPORT_SYMBOL_GPL(nfcmrvl_nci_register_dev); 136 + 137 + void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv) 138 + { 139 + struct nci_dev *ndev = priv->ndev; 140 + 141 + nci_unregister_device(ndev); 142 + nci_free_device(ndev); 143 + kfree(priv); 144 + } 145 + EXPORT_SYMBOL_GPL(nfcmrvl_nci_unregister_dev); 146 + 147 + int nfcmrvl_nci_recv_frame(struct nfcmrvl_private *priv, void *data, int count) 148 + { 149 + struct sk_buff *skb; 150 + 151 + skb = nci_skb_alloc(priv->ndev, count, GFP_ATOMIC); 152 + if (!skb) 153 + return -ENOMEM; 154 + 155 + memcpy(skb_put(skb, count), data, count); 156 + nci_recv_frame(priv->ndev, skb); 157 + 158 + return count; 159 + } 160 + EXPORT_SYMBOL_GPL(nfcmrvl_nci_recv_frame); 161 + 162 + MODULE_AUTHOR("Marvell International Ltd."); 163 + MODULE_DESCRIPTION("Marvell NFC driver ver " VERSION); 164 + MODULE_VERSION(VERSION); 165 + MODULE_LICENSE("GPL v2");
+48
drivers/nfc/nfcmrvl/nfcmrvl.h
··· 1 + /** 2 + * Marvell NFC driver 3 + * 4 + * Copyright (C) 2014, Marvell International Ltd. 5 + * 6 + * This software file (the "File") is distributed by Marvell International 7 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991 8 + * (the "License"). You may use, redistribute and/or modify this File in 9 + * accordance with the terms and conditions of the License, a copy of which 10 + * is available on the worldwide web at 11 + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 12 + * 13 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 14 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 15 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 16 + * this warranty disclaimer. 17 + **/ 18 + 19 + /* Define private flags: */ 20 + #define NFCMRVL_NCI_RUNNING 1 21 + 22 + #define NFCMRVL_EXT_COEX_ID 0xE0 23 + #define NFCMRVL_NOT_ALLOWED_ID 0xE1 24 + #define NFCMRVL_ACTIVE_ID 0xE2 25 + #define NFCMRVL_EXT_COEX_ENABLE 1 26 + #define NFCMRVL_GPIO_PIN_NFC_NOT_ALLOWED 0xA 27 + #define NFCMRVL_GPIO_PIN_NFC_ACTIVE 0xB 28 + #define NFCMRVL_NCI_MAX_EVENT_SIZE 260 29 + 30 + struct nfcmrvl_private { 31 + struct nci_dev *ndev; 32 + unsigned long flags; 33 + void *drv_data; 34 + struct device *dev; 35 + struct nfcmrvl_if_ops *if_ops; 36 + }; 37 + 38 + struct nfcmrvl_if_ops { 39 + int (*nci_open) (struct nfcmrvl_private *priv); 40 + int (*nci_close) (struct nfcmrvl_private *priv); 41 + int (*nci_send) (struct nfcmrvl_private *priv, struct sk_buff *skb); 42 + }; 43 + 44 + void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv); 45 + int nfcmrvl_nci_recv_frame(struct nfcmrvl_private *priv, void *data, int count); 46 + struct nfcmrvl_private *nfcmrvl_nci_register_dev(void *drv_data, 47 + struct nfcmrvl_if_ops *ops, 48 + struct device *dev);
+459
drivers/nfc/nfcmrvl/usb.c
··· 1 + /** 2 + * Marvell NFC-over-USB driver: USB interface related functions 3 + * 4 + * Copyright (C) 2014, Marvell International Ltd. 5 + * 6 + * This software file (the "File") is distributed by Marvell International 7 + * Ltd. under the terms of the GNU General Public License Version 2, June 1991 8 + * (the "License"). You may use, redistribute and/or modify this File in 9 + * accordance with the terms and conditions of the License, a copy of which 10 + * is available on the worldwide web at 11 + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 12 + * 13 + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 14 + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 15 + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 16 + * this warranty disclaimer. 17 + **/ 18 + 19 + #include <linux/module.h> 20 + #include <linux/usb.h> 21 + #include <linux/nfc.h> 22 + #include <net/nfc/nci.h> 23 + #include <net/nfc/nci_core.h> 24 + #include "nfcmrvl.h" 25 + 26 + #define VERSION "1.0" 27 + 28 + static struct usb_device_id nfcmrvl_table[] = { 29 + { USB_DEVICE_INTERFACE_CLASS(0x1286, 0x2046, 0xff) }, 30 + { } /* Terminating entry */ 31 + }; 32 + 33 + MODULE_DEVICE_TABLE(usb, nfcmrvl_table); 34 + 35 + #define NFCMRVL_USB_BULK_RUNNING 1 36 + #define NFCMRVL_USB_SUSPENDING 2 37 + 38 + struct nfcmrvl_usb_drv_data { 39 + struct usb_device *udev; 40 + struct usb_interface *intf; 41 + unsigned long flags; 42 + struct work_struct waker; 43 + struct usb_anchor tx_anchor; 44 + struct usb_anchor bulk_anchor; 45 + struct usb_anchor deferred; 46 + int tx_in_flight; 47 + /* protects tx_in_flight */ 48 + spinlock_t txlock; 49 + struct usb_endpoint_descriptor *bulk_tx_ep; 50 + struct usb_endpoint_descriptor *bulk_rx_ep; 51 + int suspend_count; 52 + struct nfcmrvl_private *priv; 53 + }; 54 + 55 + static int nfcmrvl_inc_tx(struct nfcmrvl_usb_drv_data *drv_data) 56 + { 57 + unsigned long flags; 58 + int rv; 59 + 60 + spin_lock_irqsave(&drv_data->txlock, flags); 61 + rv = test_bit(NFCMRVL_USB_SUSPENDING, &drv_data->flags); 62 + if (!rv) 63 + drv_data->tx_in_flight++; 64 + spin_unlock_irqrestore(&drv_data->txlock, flags); 65 + 66 + return rv; 67 + } 68 + 69 + static void nfcmrvl_bulk_complete(struct urb *urb) 70 + { 71 + struct nfcmrvl_usb_drv_data *drv_data = urb->context; 72 + int err; 73 + 74 + dev_dbg(&drv_data->udev->dev, "urb %p status %d count %d", 75 + urb, urb->status, urb->actual_length); 76 + 77 + if (!test_bit(NFCMRVL_NCI_RUNNING, &drv_data->flags)) 78 + return; 79 + 80 + if (!urb->status) { 81 + if (nfcmrvl_nci_recv_frame(drv_data->priv, urb->transfer_buffer, 82 + urb->actual_length) < 0) 83 + nfc_err(&drv_data->udev->dev, "corrupted Rx packet"); 84 + } 85 + 86 + if (!test_bit(NFCMRVL_USB_BULK_RUNNING, &drv_data->flags)) 87 + return; 88 + 89 + usb_anchor_urb(urb, &drv_data->bulk_anchor); 90 + usb_mark_last_busy(drv_data->udev); 91 + 92 + err = usb_submit_urb(urb, GFP_ATOMIC); 93 + if (err) { 94 + /* -EPERM: urb is being killed; 95 + * -ENODEV: device got disconnected 96 + */ 97 + if (err != -EPERM && err != -ENODEV) 98 + nfc_err(&drv_data->udev->dev, 99 + "urb %p failed to resubmit (%d)", urb, -err); 100 + usb_unanchor_urb(urb); 101 + } 102 + } 103 + 104 + static int 105 + nfcmrvl_submit_bulk_urb(struct nfcmrvl_usb_drv_data *drv_data, gfp_t mem_flags) 106 + { 107 + struct urb *urb; 108 + unsigned char *buf; 109 + unsigned int pipe; 110 + int err, size = NFCMRVL_NCI_MAX_EVENT_SIZE; 111 + 112 + if (!drv_data->bulk_rx_ep) 113 + return -ENODEV; 114 + 115 + urb = usb_alloc_urb(0, mem_flags); 116 + if (!urb) 117 + return -ENOMEM; 118 + 119 + buf = kmalloc(size, mem_flags); 120 + if (!buf) { 121 + usb_free_urb(urb); 122 + return -ENOMEM; 123 + } 124 + 125 + pipe = usb_rcvbulkpipe(drv_data->udev, 126 + drv_data->bulk_rx_ep->bEndpointAddress); 127 + 128 + usb_fill_bulk_urb(urb, drv_data->udev, pipe, buf, size, 129 + nfcmrvl_bulk_complete, drv_data); 130 + 131 + urb->transfer_flags |= URB_FREE_BUFFER; 132 + 133 + usb_mark_last_busy(drv_data->udev); 134 + usb_anchor_urb(urb, &drv_data->bulk_anchor); 135 + 136 + err = usb_submit_urb(urb, mem_flags); 137 + if (err) { 138 + if (err != -EPERM && err != -ENODEV) 139 + nfc_err(&drv_data->udev->dev, 140 + "urb %p submission failed (%d)", urb, -err); 141 + usb_unanchor_urb(urb); 142 + } 143 + 144 + usb_free_urb(urb); 145 + 146 + return err; 147 + } 148 + 149 + static void nfcmrvl_tx_complete(struct urb *urb) 150 + { 151 + struct sk_buff *skb = urb->context; 152 + struct nci_dev *ndev = (struct nci_dev *)skb->dev; 153 + struct nfcmrvl_private *priv = nci_get_drvdata(ndev); 154 + struct nfcmrvl_usb_drv_data *drv_data = priv->drv_data; 155 + 156 + nfc_info(priv->dev, "urb %p status %d count %d", 157 + urb, urb->status, urb->actual_length); 158 + 159 + spin_lock(&drv_data->txlock); 160 + drv_data->tx_in_flight--; 161 + spin_unlock(&drv_data->txlock); 162 + 163 + kfree(urb->setup_packet); 164 + kfree_skb(skb); 165 + } 166 + 167 + static int nfcmrvl_usb_nci_open(struct nfcmrvl_private *priv) 168 + { 169 + struct nfcmrvl_usb_drv_data *drv_data = priv->drv_data; 170 + int err; 171 + 172 + err = usb_autopm_get_interface(drv_data->intf); 173 + if (err) 174 + return err; 175 + 176 + drv_data->intf->needs_remote_wakeup = 1; 177 + 178 + err = nfcmrvl_submit_bulk_urb(drv_data, GFP_KERNEL); 179 + if (err) 180 + goto failed; 181 + 182 + set_bit(NFCMRVL_USB_BULK_RUNNING, &drv_data->flags); 183 + nfcmrvl_submit_bulk_urb(drv_data, GFP_KERNEL); 184 + 185 + usb_autopm_put_interface(drv_data->intf); 186 + return 0; 187 + 188 + failed: 189 + usb_autopm_put_interface(drv_data->intf); 190 + return err; 191 + } 192 + 193 + static void nfcmrvl_usb_stop_traffic(struct nfcmrvl_usb_drv_data *drv_data) 194 + { 195 + usb_kill_anchored_urbs(&drv_data->bulk_anchor); 196 + } 197 + 198 + static int nfcmrvl_usb_nci_close(struct nfcmrvl_private *priv) 199 + { 200 + struct nfcmrvl_usb_drv_data *drv_data = priv->drv_data; 201 + int err; 202 + 203 + cancel_work_sync(&drv_data->waker); 204 + 205 + clear_bit(NFCMRVL_USB_BULK_RUNNING, &drv_data->flags); 206 + 207 + nfcmrvl_usb_stop_traffic(drv_data); 208 + usb_kill_anchored_urbs(&drv_data->tx_anchor); 209 + err = usb_autopm_get_interface(drv_data->intf); 210 + if (err) 211 + goto failed; 212 + 213 + drv_data->intf->needs_remote_wakeup = 0; 214 + usb_autopm_put_interface(drv_data->intf); 215 + 216 + failed: 217 + usb_scuttle_anchored_urbs(&drv_data->deferred); 218 + return 0; 219 + } 220 + 221 + static int nfcmrvl_usb_nci_send(struct nfcmrvl_private *priv, 222 + struct sk_buff *skb) 223 + { 224 + struct nfcmrvl_usb_drv_data *drv_data = priv->drv_data; 225 + struct urb *urb; 226 + unsigned int pipe; 227 + int err; 228 + 229 + if (!drv_data->bulk_tx_ep) 230 + return -ENODEV; 231 + 232 + urb = usb_alloc_urb(0, GFP_ATOMIC); 233 + if (!urb) 234 + return -ENOMEM; 235 + 236 + pipe = usb_sndbulkpipe(drv_data->udev, 237 + drv_data->bulk_tx_ep->bEndpointAddress); 238 + 239 + usb_fill_bulk_urb(urb, drv_data->udev, pipe, skb->data, skb->len, 240 + nfcmrvl_tx_complete, skb); 241 + 242 + err = nfcmrvl_inc_tx(drv_data); 243 + if (err) { 244 + usb_anchor_urb(urb, &drv_data->deferred); 245 + schedule_work(&drv_data->waker); 246 + err = 0; 247 + goto done; 248 + } 249 + 250 + usb_anchor_urb(urb, &drv_data->tx_anchor); 251 + 252 + err = usb_submit_urb(urb, GFP_ATOMIC); 253 + if (err) { 254 + if (err != -EPERM && err != -ENODEV) 255 + nfc_err(&drv_data->udev->dev, 256 + "urb %p submission failed (%d)", urb, -err); 257 + kfree(urb->setup_packet); 258 + usb_unanchor_urb(urb); 259 + } else { 260 + usb_mark_last_busy(drv_data->udev); 261 + } 262 + 263 + done: 264 + usb_free_urb(urb); 265 + return err; 266 + } 267 + 268 + static struct nfcmrvl_if_ops usb_ops = { 269 + .nci_open = nfcmrvl_usb_nci_open, 270 + .nci_close = nfcmrvl_usb_nci_close, 271 + .nci_send = nfcmrvl_usb_nci_send, 272 + }; 273 + 274 + static void nfcmrvl_waker(struct work_struct *work) 275 + { 276 + struct nfcmrvl_usb_drv_data *drv_data = 277 + container_of(work, struct nfcmrvl_usb_drv_data, waker); 278 + int err; 279 + 280 + err = usb_autopm_get_interface(drv_data->intf); 281 + if (err) 282 + return; 283 + 284 + usb_autopm_put_interface(drv_data->intf); 285 + } 286 + 287 + static int nfcmrvl_probe(struct usb_interface *intf, 288 + const struct usb_device_id *id) 289 + { 290 + struct usb_endpoint_descriptor *ep_desc; 291 + struct nfcmrvl_usb_drv_data *drv_data; 292 + struct nfcmrvl_private *priv; 293 + int i; 294 + struct usb_device *udev = interface_to_usbdev(intf); 295 + 296 + nfc_info(&udev->dev, "intf %p id %p", intf, id); 297 + 298 + drv_data = devm_kzalloc(&intf->dev, sizeof(*drv_data), GFP_KERNEL); 299 + if (!drv_data) 300 + return -ENOMEM; 301 + 302 + for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { 303 + ep_desc = &intf->cur_altsetting->endpoint[i].desc; 304 + 305 + if (!drv_data->bulk_tx_ep && 306 + usb_endpoint_is_bulk_out(ep_desc)) { 307 + drv_data->bulk_tx_ep = ep_desc; 308 + continue; 309 + } 310 + 311 + if (!drv_data->bulk_rx_ep && 312 + usb_endpoint_is_bulk_in(ep_desc)) { 313 + drv_data->bulk_rx_ep = ep_desc; 314 + continue; 315 + } 316 + } 317 + 318 + if (!drv_data->bulk_tx_ep || !drv_data->bulk_rx_ep) 319 + return -ENODEV; 320 + 321 + drv_data->udev = udev; 322 + drv_data->intf = intf; 323 + 324 + INIT_WORK(&drv_data->waker, nfcmrvl_waker); 325 + spin_lock_init(&drv_data->txlock); 326 + 327 + init_usb_anchor(&drv_data->tx_anchor); 328 + init_usb_anchor(&drv_data->bulk_anchor); 329 + init_usb_anchor(&drv_data->deferred); 330 + 331 + priv = nfcmrvl_nci_register_dev(drv_data, &usb_ops, 332 + &drv_data->udev->dev); 333 + if (IS_ERR(priv)) 334 + return PTR_ERR(priv); 335 + 336 + drv_data->priv = priv; 337 + priv->dev = &drv_data->udev->dev; 338 + 339 + usb_set_intfdata(intf, drv_data); 340 + 341 + return 0; 342 + } 343 + 344 + static void nfcmrvl_disconnect(struct usb_interface *intf) 345 + { 346 + struct nfcmrvl_usb_drv_data *drv_data = usb_get_intfdata(intf); 347 + 348 + if (!drv_data) 349 + return; 350 + 351 + nfc_info(&drv_data->udev->dev, "intf %p", intf); 352 + 353 + nfcmrvl_nci_unregister_dev(drv_data->priv); 354 + 355 + usb_set_intfdata(drv_data->intf, NULL); 356 + } 357 + 358 + #ifdef CONFIG_PM 359 + static int nfcmrvl_suspend(struct usb_interface *intf, pm_message_t message) 360 + { 361 + struct nfcmrvl_usb_drv_data *drv_data = usb_get_intfdata(intf); 362 + 363 + nfc_info(&drv_data->udev->dev, "intf %p", intf); 364 + 365 + if (drv_data->suspend_count++) 366 + return 0; 367 + 368 + spin_lock_irq(&drv_data->txlock); 369 + if (!(PMSG_IS_AUTO(message) && drv_data->tx_in_flight)) { 370 + set_bit(NFCMRVL_USB_SUSPENDING, &drv_data->flags); 371 + spin_unlock_irq(&drv_data->txlock); 372 + } else { 373 + spin_unlock_irq(&drv_data->txlock); 374 + drv_data->suspend_count--; 375 + return -EBUSY; 376 + } 377 + 378 + nfcmrvl_usb_stop_traffic(drv_data); 379 + usb_kill_anchored_urbs(&drv_data->tx_anchor); 380 + 381 + return 0; 382 + } 383 + 384 + static void nfcmrvl_play_deferred(struct nfcmrvl_usb_drv_data *drv_data) 385 + { 386 + struct urb *urb; 387 + int err; 388 + 389 + while ((urb = usb_get_from_anchor(&drv_data->deferred))) { 390 + err = usb_submit_urb(urb, GFP_ATOMIC); 391 + if (err) 392 + break; 393 + 394 + drv_data->tx_in_flight++; 395 + } 396 + usb_scuttle_anchored_urbs(&drv_data->deferred); 397 + } 398 + 399 + static int nfcmrvl_resume(struct usb_interface *intf) 400 + { 401 + struct nfcmrvl_usb_drv_data *drv_data = usb_get_intfdata(intf); 402 + int err = 0; 403 + 404 + nfc_info(&drv_data->udev->dev, "intf %p", intf); 405 + 406 + if (--drv_data->suspend_count) 407 + return 0; 408 + 409 + if (!test_bit(NFCMRVL_NCI_RUNNING, &drv_data->flags)) 410 + goto done; 411 + 412 + if (test_bit(NFCMRVL_USB_BULK_RUNNING, &drv_data->flags)) { 413 + err = nfcmrvl_submit_bulk_urb(drv_data, GFP_NOIO); 414 + if (err) { 415 + clear_bit(NFCMRVL_USB_BULK_RUNNING, &drv_data->flags); 416 + goto failed; 417 + } 418 + 419 + nfcmrvl_submit_bulk_urb(drv_data, GFP_NOIO); 420 + } 421 + 422 + spin_lock_irq(&drv_data->txlock); 423 + nfcmrvl_play_deferred(drv_data); 424 + clear_bit(NFCMRVL_USB_SUSPENDING, &drv_data->flags); 425 + spin_unlock_irq(&drv_data->txlock); 426 + 427 + return 0; 428 + 429 + failed: 430 + usb_scuttle_anchored_urbs(&drv_data->deferred); 431 + done: 432 + spin_lock_irq(&drv_data->txlock); 433 + clear_bit(NFCMRVL_USB_SUSPENDING, &drv_data->flags); 434 + spin_unlock_irq(&drv_data->txlock); 435 + 436 + return err; 437 + } 438 + #endif 439 + 440 + static struct usb_driver nfcmrvl_usb_driver = { 441 + .name = "nfcmrvl", 442 + .probe = nfcmrvl_probe, 443 + .disconnect = nfcmrvl_disconnect, 444 + #ifdef CONFIG_PM 445 + .suspend = nfcmrvl_suspend, 446 + .resume = nfcmrvl_resume, 447 + .reset_resume = nfcmrvl_resume, 448 + #endif 449 + .id_table = nfcmrvl_table, 450 + .supports_autosuspend = 1, 451 + .disable_hub_initiated_lpm = 1, 452 + .soft_unbind = 1, 453 + }; 454 + module_usb_driver(nfcmrvl_usb_driver); 455 + 456 + MODULE_AUTHOR("Marvell International Ltd."); 457 + MODULE_DESCRIPTION("Marvell NFC-over-USB driver ver " VERSION); 458 + MODULE_VERSION(VERSION); 459 + MODULE_LICENSE("GPL v2");
+3
drivers/nfc/pn533.c
··· 521 521 if (frame->ccid.type != 0x83) 522 522 return false; 523 523 524 + if (!frame->ccid.datalen) 525 + return false; 526 + 524 527 if (frame->data[frame->ccid.datalen - 2] == 0x63) 525 528 return false; 526 529
+23 -23
drivers/nfc/pn544/pn544.c
··· 195 195 196 196 {{0x9e, 0xaa}, 0x01}, 197 197 198 - {{0x9b, 0xd1}, 0x0d}, 199 - {{0x9b, 0xd2}, 0x24}, 200 - {{0x9b, 0xd3}, 0x0a}, 201 - {{0x9b, 0xd4}, 0x22}, 202 - {{0x9b, 0xd5}, 0x08}, 203 - {{0x9b, 0xd6}, 0x1e}, 204 - {{0x9b, 0xdd}, 0x1c}, 198 + {{0x9b, 0xd1}, 0x17}, 199 + {{0x9b, 0xd2}, 0x58}, 200 + {{0x9b, 0xd3}, 0x10}, 201 + {{0x9b, 0xd4}, 0x47}, 202 + {{0x9b, 0xd5}, 0x0c}, 203 + {{0x9b, 0xd6}, 0x37}, 204 + {{0x9b, 0xdd}, 0x33}, 205 205 206 - {{0x9b, 0x84}, 0x13}, 207 - {{0x99, 0x81}, 0x7f}, 208 - {{0x99, 0x31}, 0x70}, 206 + {{0x9b, 0x84}, 0x00}, 207 + {{0x99, 0x81}, 0x79}, 208 + {{0x99, 0x31}, 0x79}, 209 209 210 210 {{0x98, 0x00}, 0x3f}, 211 211 212 - {{0x9f, 0x09}, 0x00}, 212 + {{0x9f, 0x09}, 0x02}, 213 213 214 214 {{0x9f, 0x0a}, 0x05}, 215 215 216 216 {{0x9e, 0xd1}, 0xa1}, 217 - {{0x99, 0x23}, 0x00}, 217 + {{0x99, 0x23}, 0x01}, 218 218 219 - {{0x9e, 0x74}, 0x80}, 220 - 219 + {{0x9e, 0x74}, 0x00}, 220 + {{0x9e, 0x90}, 0x00}, 221 221 {{0x9f, 0x28}, 0x10}, 222 222 223 - {{0x9f, 0x35}, 0x14}, 223 + {{0x9f, 0x35}, 0x04}, 224 224 225 - {{0x9f, 0x36}, 0x60}, 225 + {{0x9f, 0x36}, 0x11}, 226 226 227 227 {{0x9c, 0x31}, 0x00}, 228 228 229 - {{0x9c, 0x32}, 0xc8}, 229 + {{0x9c, 0x32}, 0x00}, 230 230 231 - {{0x9c, 0x19}, 0x40}, 231 + {{0x9c, 0x19}, 0x0a}, 232 232 233 - {{0x9c, 0x1a}, 0x40}, 233 + {{0x9c, 0x1a}, 0x0a}, 234 234 235 235 {{0x9c, 0x0c}, 0x00}, 236 236 ··· 240 240 241 241 {{0x9c, 0x13}, 0x00}, 242 242 243 - {{0x98, 0xa2}, 0x0e}, 243 + {{0x98, 0xa2}, 0x09}, 244 244 245 - {{0x98, 0x93}, 0x40}, 245 + {{0x98, 0x93}, 0x00}, 246 246 247 - {{0x98, 0x7d}, 0x02}, 247 + {{0x98, 0x7d}, 0x08}, 248 248 {{0x98, 0x7e}, 0x00}, 249 - {{0x9f, 0xc8}, 0x01}, 249 + {{0x9f, 0xc8}, 0x00}, 250 250 }; 251 251 struct hw_config *p = hw_config; 252 252 int count = ARRAY_SIZE(hw_config);
+1
drivers/nfc/port100.c
··· 1509 1509 1510 1510 usb_free_urb(dev->in_urb); 1511 1511 usb_free_urb(dev->out_urb); 1512 + usb_put_dev(dev->udev); 1512 1513 1513 1514 kfree(dev->cmd); 1514 1515
-1
drivers/staging/winbond/wbusb.c
··· 788 788 dev->flags = IEEE80211_HW_SIGNAL_UNSPEC; 789 789 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); 790 790 791 - dev->channel_change_time = 1000; 792 791 dev->max_signal = 100; 793 792 dev->queues = 1; 794 793
+2
include/linux/ieee80211.h
··· 1857 1857 WLAN_KEY_LEN_CCMP = 16, 1858 1858 WLAN_KEY_LEN_TKIP = 32, 1859 1859 WLAN_KEY_LEN_AES_CMAC = 16, 1860 + WLAN_KEY_LEN_SMS4 = 32, 1860 1861 }; 1861 1862 1862 1863 #define IEEE80211_WEP_IV_LEN 4 ··· 1903 1902 #define WLAN_EXT_CAPA5_TDLS_PROHIBITED BIT(6) 1904 1903 1905 1904 #define WLAN_EXT_CAPA8_OPMODE_NOTIF BIT(6) 1905 + #define WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED BIT(7) 1906 1906 1907 1907 /* TDLS specific payload type in the LLC/SNAP header */ 1908 1908 #define WLAN_TDLS_SNAP_RFTYPE 0x2
+8
include/net/cfg80211.h
··· 4640 4640 */ 4641 4641 void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp); 4642 4642 4643 + /** 4644 + * ieee80211_get_num_supported_channels - get number of channels device has 4645 + * @wiphy: the wiphy 4646 + * 4647 + * Return: the number of channels supported by the device. 4648 + */ 4649 + unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy); 4650 + 4643 4651 /* Logging, debugging and troubleshooting/diagnostic helpers. */ 4644 4652 4645 4653 /* wiphy_printk helpers, similar to dev_printk */
+5 -3
include/net/mac80211.h
··· 1616 1616 * @extra_beacon_tailroom: tailroom to reserve in each beacon tx skb. 1617 1617 * Can be used by drivers to add extra IEs. 1618 1618 * 1619 - * @channel_change_time: time (in microseconds) it takes to change channels. 1620 - * 1621 1619 * @max_signal: Maximum value for signal (rssi) in RX information, used 1622 1620 * only when @IEEE80211_HW_SIGNAL_UNSPEC or @IEEE80211_HW_SIGNAL_DB 1623 1621 * ··· 1697 1699 u32 flags; 1698 1700 unsigned int extra_tx_headroom; 1699 1701 unsigned int extra_beacon_tailroom; 1700 - int channel_change_time; 1701 1702 int vif_data_size; 1702 1703 int sta_data_size; 1703 1704 int chanctx_data_size; ··· 2119 2122 * appropriately (only the last frame may have %IEEE80211_TX_STATUS_EOSP) 2120 2123 * and also take care of the EOSP and MORE_DATA bits in the frame. 2121 2124 * The driver may also use ieee80211_sta_eosp() in this case. 2125 + * 2126 + * Note that if the driver ever buffers frames other than QoS-data 2127 + * frames, it must take care to never send a non-QoS-data frame as 2128 + * the last frame in a service period, adding a QoS-nulldata frame 2129 + * after a non-QoS-data frame if needed. 2122 2130 */ 2123 2131 2124 2132 /**
+10
include/net/nfc/digital.h
··· 122 122 * switch_rf to turn the radio on. A call to in|tg_configure_hw must turn 123 123 * the device radio on. 124 124 * @abort_cmd: Discard the last sent command. 125 + * 126 + * Notes: Asynchronous functions have a timeout parameter. It is the driver 127 + * responsibility to call the digital stack back through the 128 + * nfc_digital_cmd_complete_t callback when no RF respsonse has been 129 + * received within the specified time (in milliseconds). In that case the 130 + * driver must set the resp sk_buff to ERR_PTR(-ETIMEDOUT). 131 + * Since the digital stack serializes commands to be sent, it's mandatory 132 + * for the driver to handle the timeout correctly. Otherwise the stack 133 + * would not be able to send new commands, waiting for the reply of the 134 + * current one. 125 135 */ 126 136 struct nfc_digital_ops { 127 137 int (*in_configure_hw)(struct nfc_digital_dev *ddev, int type,
+2
include/net/nfc/nci_core.h
··· 67 67 int (*open)(struct nci_dev *ndev); 68 68 int (*close)(struct nci_dev *ndev); 69 69 int (*send)(struct nci_dev *ndev, struct sk_buff *skb); 70 + int (*setup)(struct nci_dev *ndev); 70 71 }; 71 72 72 73 #define NCI_MAX_SUPPORTED_RF_INTERFACES 4 ··· 154 153 int nci_register_device(struct nci_dev *ndev); 155 154 void nci_unregister_device(struct nci_dev *ndev); 156 155 int nci_recv_frame(struct nci_dev *ndev, struct sk_buff *skb); 156 + int nci_set_config(struct nci_dev *ndev, __u8 id, size_t len, __u8 *val); 157 157 158 158 static inline struct sk_buff *nci_skb_alloc(struct nci_dev *ndev, 159 159 unsigned int len,
+4
include/net/regulatory.h
··· 96 96 * initiator is %REGDOM_SET_BY_CORE). Drivers that use 97 97 * wiphy_apply_custom_regulatory() should have this flag set 98 98 * or the regulatory core will set it for the wiphy. 99 + * If you use regulatory_hint() *after* using 100 + * wiphy_apply_custom_regulatory() the wireless core will 101 + * clear the REGULATORY_CUSTOM_REG for your wiphy as it would be 102 + * implied that the device somehow gained knowledge of its region. 99 103 * @REGULATORY_STRICT_REG: tells us that the wiphy for this device 100 104 * has regulatory domain that it wishes to be considered as the 101 105 * superset for regulatory rules. After this device gets its regulatory
+2 -1
net/mac80211/cfg.c
··· 1035 1035 return err; 1036 1036 } 1037 1037 1038 + ieee80211_recalc_dtim(local, sdata); 1038 1039 ieee80211_bss_info_change_notify(sdata, changed); 1039 1040 1040 1041 netif_carrier_on(dev); ··· 3855 3854 new_qos_map = NULL; 3856 3855 } 3857 3856 3858 - old_qos_map = rtnl_dereference(sdata->qos_map); 3857 + old_qos_map = sdata_dereference(sdata->qos_map, sdata); 3859 3858 rcu_assign_pointer(sdata->qos_map, new_qos_map); 3860 3859 if (old_qos_map) 3861 3860 kfree_rcu(old_qos_map, rcu_head);
+34 -27
net/mac80211/debugfs_netdev.c
··· 133 133 jiffies_to_msecs(sdata->field)); \ 134 134 } 135 135 136 - #define __IEEE80211_IF_FILE(name, _write) \ 136 + #define _IEEE80211_IF_FILE_OPS(name, _read, _write) \ 137 + static const struct file_operations name##_ops = { \ 138 + .read = (_read), \ 139 + .write = (_write), \ 140 + .open = simple_open, \ 141 + .llseek = generic_file_llseek, \ 142 + } 143 + 144 + #define _IEEE80211_IF_FILE_R_FN(name) \ 137 145 static ssize_t ieee80211_if_read_##name(struct file *file, \ 138 146 char __user *userbuf, \ 139 147 size_t count, loff_t *ppos) \ ··· 149 141 return ieee80211_if_read(file->private_data, \ 150 142 userbuf, count, ppos, \ 151 143 ieee80211_if_fmt_##name); \ 152 - } \ 153 - static const struct file_operations name##_ops = { \ 154 - .read = ieee80211_if_read_##name, \ 155 - .write = (_write), \ 156 - .open = simple_open, \ 157 - .llseek = generic_file_llseek, \ 158 144 } 159 145 160 - #define __IEEE80211_IF_FILE_W(name) \ 146 + #define _IEEE80211_IF_FILE_W_FN(name) \ 161 147 static ssize_t ieee80211_if_write_##name(struct file *file, \ 162 148 const char __user *userbuf, \ 163 149 size_t count, loff_t *ppos) \ 164 150 { \ 165 151 return ieee80211_if_write(file->private_data, userbuf, count, \ 166 152 ppos, ieee80211_if_parse_##name); \ 167 - } \ 168 - __IEEE80211_IF_FILE(name, ieee80211_if_write_##name) 153 + } 169 154 155 + #define IEEE80211_IF_FILE_R(name) \ 156 + _IEEE80211_IF_FILE_R_FN(name) \ 157 + _IEEE80211_IF_FILE_OPS(name, ieee80211_if_read_##name, NULL) 158 + 159 + #define IEEE80211_IF_FILE_W(name) \ 160 + _IEEE80211_IF_FILE_W_FN(name) \ 161 + _IEEE80211_IF_FILE_OPS(name, NULL, ieee80211_if_write_##name) 162 + 163 + #define IEEE80211_IF_FILE_RW(name) \ 164 + _IEEE80211_IF_FILE_R_FN(name) \ 165 + _IEEE80211_IF_FILE_W_FN(name) \ 166 + _IEEE80211_IF_FILE_OPS(name, ieee80211_if_read_##name, \ 167 + ieee80211_if_write_##name) 170 168 171 169 #define IEEE80211_IF_FILE(name, field, format) \ 172 - IEEE80211_IF_FMT_##format(name, field) \ 173 - __IEEE80211_IF_FILE(name, NULL) 170 + IEEE80211_IF_FMT_##format(name, field) \ 171 + IEEE80211_IF_FILE_R(name) 174 172 175 173 /* common attributes */ 176 174 IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC); ··· 213 199 214 200 return len; 215 201 } 216 - __IEEE80211_IF_FILE(hw_queues, NULL); 202 + IEEE80211_IF_FILE_R(hw_queues); 217 203 218 204 /* STA attributes */ 219 205 IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC); ··· 289 275 290 276 return -EINVAL; 291 277 } 292 - 293 - __IEEE80211_IF_FILE_W(smps); 294 - 295 - static ssize_t ieee80211_if_fmt_tkip_mic_test( 296 - const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) 297 - { 298 - return -EOPNOTSUPP; 299 - } 278 + IEEE80211_IF_FILE_RW(smps); 300 279 301 280 static ssize_t ieee80211_if_parse_tkip_mic_test( 302 281 struct ieee80211_sub_if_data *sdata, const char *buf, int buflen) ··· 356 349 357 350 return buflen; 358 351 } 359 - 360 - __IEEE80211_IF_FILE_W(tkip_mic_test); 352 + IEEE80211_IF_FILE_W(tkip_mic_test); 361 353 362 354 static ssize_t ieee80211_if_fmt_uapsd_queues( 363 355 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) ··· 384 378 385 379 return buflen; 386 380 } 387 - __IEEE80211_IF_FILE_W(uapsd_queues); 381 + IEEE80211_IF_FILE_RW(uapsd_queues); 388 382 389 383 static ssize_t ieee80211_if_fmt_uapsd_max_sp_len( 390 384 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) ··· 412 406 413 407 return buflen; 414 408 } 415 - __IEEE80211_IF_FILE_W(uapsd_max_sp_len); 409 + IEEE80211_IF_FILE_RW(uapsd_max_sp_len); 416 410 417 411 /* AP attributes */ 418 412 IEEE80211_IF_FILE(num_mcast_sta, u.ap.num_mcast_sta, ATOMIC); ··· 425 419 return scnprintf(buf, buflen, "%u\n", 426 420 skb_queue_len(&sdata->u.ap.ps.bc_buf)); 427 421 } 428 - __IEEE80211_IF_FILE(num_buffered_multicast, NULL); 422 + IEEE80211_IF_FILE_R(num_buffered_multicast); 429 423 430 424 /* IBSS attributes */ 431 425 static ssize_t ieee80211_if_fmt_tsf( ··· 474 468 } 475 469 } 476 470 471 + ieee80211_recalc_dtim(local, sdata); 477 472 return buflen; 478 473 } 479 - __IEEE80211_IF_FILE_W(tsf); 474 + IEEE80211_IF_FILE_RW(tsf); 480 475 481 476 482 477 /* WDS attributes */
+2 -3
net/mac80211/ht.c
··· 479 479 vif->type != NL80211_IFTYPE_AP)) 480 480 return; 481 481 482 - if (WARN_ON(smps_mode == IEEE80211_SMPS_OFF)) 483 - smps_mode = IEEE80211_SMPS_AUTOMATIC; 484 - 485 482 if (vif->type == NL80211_IFTYPE_STATION) { 483 + if (WARN_ON(smps_mode == IEEE80211_SMPS_OFF)) 484 + smps_mode = IEEE80211_SMPS_AUTOMATIC; 486 485 if (sdata->u.mgd.driver_smps_mode == smps_mode) 487 486 return; 488 487 sdata->u.mgd.driver_smps_mode = smps_mode;
+2
net/mac80211/ieee80211_i.h
··· 1800 1800 int ieee80211_cs_headroom(struct ieee80211_local *local, 1801 1801 struct cfg80211_crypto_settings *crypto, 1802 1802 enum nl80211_iftype iftype); 1803 + void ieee80211_recalc_dtim(struct ieee80211_local *local, 1804 + struct ieee80211_sub_if_data *sdata); 1803 1805 1804 1806 #ifdef CONFIG_MAC80211_NOINLINE 1805 1807 #define debug_noinline noinline
+11 -11
net/mac80211/main.c
··· 846 846 /* TODO: consider VHT for RX chains, hopefully it's the same */ 847 847 } 848 848 849 - local->int_scan_req = kzalloc(sizeof(*local->int_scan_req) + 850 - sizeof(void *) * channels, GFP_KERNEL); 851 - if (!local->int_scan_req) 852 - return -ENOMEM; 853 - 854 - for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 855 - if (!local->hw.wiphy->bands[band]) 856 - continue; 857 - local->int_scan_req->rates[band] = (u32) -1; 858 - } 859 - 860 849 /* if low-level driver supports AP, we also support VLAN */ 861 850 if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) { 862 851 hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_AP_VLAN); ··· 867 878 if ((c->limits[j].types & BIT(NL80211_IFTYPE_ADHOC)) && 868 879 c->limits[j].max > 1) 869 880 return -EINVAL; 881 + } 882 + 883 + local->int_scan_req = kzalloc(sizeof(*local->int_scan_req) + 884 + sizeof(void *) * channels, GFP_KERNEL); 885 + if (!local->int_scan_req) 886 + return -ENOMEM; 887 + 888 + for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 889 + if (!local->hw.wiphy->bands[band]) 890 + continue; 891 + local->int_scan_req->rates[band] = (u32) -1; 870 892 } 871 893 872 894 #ifndef CONFIG_MAC80211_MESH
+1
net/mac80211/mesh.c
··· 807 807 return -ENOMEM; 808 808 } 809 809 810 + ieee80211_recalc_dtim(local, sdata); 810 811 ieee80211_bss_info_change_notify(sdata, changed); 811 812 812 813 netif_carrier_on(sdata->dev);
+1
net/mac80211/mesh_plink.c
··· 437 437 sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED); 438 438 439 439 set_sta_flag(sta, WLAN_STA_WME); 440 + sta->sta.wme = true; 440 441 441 442 return sta; 442 443 }
+19 -21
net/mac80211/rx.c
··· 3076 3076 3077 3077 /* main receive path */ 3078 3078 3079 - static int prepare_for_handlers(struct ieee80211_rx_data *rx, 3080 - struct ieee80211_hdr *hdr) 3079 + static bool prepare_for_handlers(struct ieee80211_rx_data *rx, 3080 + struct ieee80211_hdr *hdr) 3081 3081 { 3082 3082 struct ieee80211_sub_if_data *sdata = rx->sdata; 3083 3083 struct sk_buff *skb = rx->skb; ··· 3088 3088 switch (sdata->vif.type) { 3089 3089 case NL80211_IFTYPE_STATION: 3090 3090 if (!bssid && !sdata->u.mgd.use_4addr) 3091 - return 0; 3091 + return false; 3092 3092 if (!multicast && 3093 3093 !ether_addr_equal(sdata->vif.addr, hdr->addr1)) { 3094 3094 if (!(sdata->dev->flags & IFF_PROMISC) || 3095 3095 sdata->u.mgd.use_4addr) 3096 - return 0; 3096 + return false; 3097 3097 status->rx_flags &= ~IEEE80211_RX_RA_MATCH; 3098 3098 } 3099 3099 break; 3100 3100 case NL80211_IFTYPE_ADHOC: 3101 3101 if (!bssid) 3102 - return 0; 3102 + return false; 3103 3103 if (ether_addr_equal(sdata->vif.addr, hdr->addr2) || 3104 3104 ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2)) 3105 - return 0; 3105 + return false; 3106 3106 if (ieee80211_is_beacon(hdr->frame_control)) { 3107 - return 1; 3107 + return true; 3108 3108 } else if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid)) { 3109 - return 0; 3109 + return false; 3110 3110 } else if (!multicast && 3111 3111 !ether_addr_equal(sdata->vif.addr, hdr->addr1)) { 3112 3112 if (!(sdata->dev->flags & IFF_PROMISC)) 3113 - return 0; 3113 + return false; 3114 3114 status->rx_flags &= ~IEEE80211_RX_RA_MATCH; 3115 3115 } else if (!rx->sta) { 3116 3116 int rate_idx; ··· 3126 3126 if (!multicast && 3127 3127 !ether_addr_equal(sdata->vif.addr, hdr->addr1)) { 3128 3128 if (!(sdata->dev->flags & IFF_PROMISC)) 3129 - return 0; 3129 + return false; 3130 3130 3131 3131 status->rx_flags &= ~IEEE80211_RX_RA_MATCH; 3132 3132 } ··· 3135 3135 case NL80211_IFTYPE_AP: 3136 3136 if (!bssid) { 3137 3137 if (!ether_addr_equal(sdata->vif.addr, hdr->addr1)) 3138 - return 0; 3138 + return false; 3139 3139 } else if (!ieee80211_bssid_match(bssid, sdata->vif.addr)) { 3140 3140 /* 3141 3141 * Accept public action frames even when the ··· 3145 3145 */ 3146 3146 if (!multicast && 3147 3147 !ether_addr_equal(sdata->vif.addr, hdr->addr1)) 3148 - return 0; 3148 + return false; 3149 3149 if (ieee80211_is_public_action(hdr, skb->len)) 3150 - return 1; 3150 + return true; 3151 3151 if (!ieee80211_is_beacon(hdr->frame_control)) 3152 - return 0; 3152 + return false; 3153 3153 status->rx_flags &= ~IEEE80211_RX_RA_MATCH; 3154 3154 } 3155 3155 break; 3156 3156 case NL80211_IFTYPE_WDS: 3157 3157 if (bssid || !ieee80211_is_data(hdr->frame_control)) 3158 - return 0; 3158 + return false; 3159 3159 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2)) 3160 - return 0; 3160 + return false; 3161 3161 break; 3162 3162 case NL80211_IFTYPE_P2P_DEVICE: 3163 3163 if (!ieee80211_is_public_action(hdr, skb->len) && 3164 3164 !ieee80211_is_probe_req(hdr->frame_control) && 3165 3165 !ieee80211_is_probe_resp(hdr->frame_control) && 3166 3166 !ieee80211_is_beacon(hdr->frame_control)) 3167 - return 0; 3167 + return false; 3168 3168 if (!ether_addr_equal(sdata->vif.addr, hdr->addr1) && 3169 3169 !multicast) 3170 3170 status->rx_flags &= ~IEEE80211_RX_RA_MATCH; ··· 3175 3175 break; 3176 3176 } 3177 3177 3178 - return 1; 3178 + return true; 3179 3179 } 3180 3180 3181 3181 /* ··· 3191 3191 struct ieee80211_sub_if_data *sdata = rx->sdata; 3192 3192 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); 3193 3193 struct ieee80211_hdr *hdr = (void *)skb->data; 3194 - int prepares; 3195 3194 3196 3195 rx->skb = skb; 3197 3196 status->rx_flags |= IEEE80211_RX_RA_MATCH; 3198 - prepares = prepare_for_handlers(rx, hdr); 3199 3197 3200 - if (!prepares) 3198 + if (!prepare_for_handlers(rx, hdr)) 3201 3199 return false; 3202 3200 3203 3201 if (!consume) {
+154 -88
net/mac80211/sta_info.c
··· 300 300 if (!sta) 301 301 return NULL; 302 302 303 + rcu_read_lock(); 304 + tx_latency = rcu_dereference(local->tx_latency); 305 + /* init stations Tx latency statistics && TID bins */ 306 + if (tx_latency) { 307 + sta->tx_lat = kzalloc(IEEE80211_NUM_TIDS * 308 + sizeof(struct ieee80211_tx_latency_stat), 309 + GFP_ATOMIC); 310 + if (!sta->tx_lat) { 311 + rcu_read_unlock(); 312 + goto free; 313 + } 314 + 315 + if (tx_latency->n_ranges) { 316 + for (i = 0; i < IEEE80211_NUM_TIDS; i++) { 317 + /* size of bins is size of the ranges +1 */ 318 + sta->tx_lat[i].bin_count = 319 + tx_latency->n_ranges + 1; 320 + sta->tx_lat[i].bins = 321 + kcalloc(sta->tx_lat[i].bin_count, 322 + sizeof(u32), GFP_ATOMIC); 323 + if (!sta->tx_lat[i].bins) { 324 + rcu_read_unlock(); 325 + goto free; 326 + } 327 + } 328 + } 329 + } 330 + rcu_read_unlock(); 331 + 303 332 spin_lock_init(&sta->lock); 304 333 INIT_WORK(&sta->drv_unblock_wk, sta_unblock); 305 334 INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work); ··· 353 324 for (i = 0; i < ARRAY_SIZE(sta->chain_signal_avg); i++) 354 325 ewma_init(&sta->chain_signal_avg[i], 1024, 8); 355 326 356 - if (sta_prepare_rate_control(local, sta, gfp)) { 357 - kfree(sta); 358 - return NULL; 359 - } 327 + if (sta_prepare_rate_control(local, sta, gfp)) 328 + goto free; 360 329 361 330 for (i = 0; i < IEEE80211_NUM_TIDS; i++) { 362 331 /* ··· 398 371 } 399 372 } 400 373 401 - rcu_read_lock(); 402 - 403 - tx_latency = rcu_dereference(local->tx_latency); 404 - /* init stations Tx latency statistics && TID bins */ 405 - if (tx_latency) 406 - sta->tx_lat = kzalloc(IEEE80211_NUM_TIDS * 407 - sizeof(struct ieee80211_tx_latency_stat), 408 - GFP_ATOMIC); 409 - 410 - /* 411 - * if Tx latency and bins are enabled and the previous allocation 412 - * succeeded 413 - */ 414 - if (tx_latency && tx_latency->n_ranges && sta->tx_lat) 415 - for (i = 0; i < IEEE80211_NUM_TIDS; i++) { 416 - /* size of bins is size of the ranges +1 */ 417 - sta->tx_lat[i].bin_count = 418 - tx_latency->n_ranges + 1; 419 - sta->tx_lat[i].bins = kcalloc(sta->tx_lat[i].bin_count, 420 - sizeof(u32), 421 - GFP_ATOMIC); 422 - } 423 - 424 - rcu_read_unlock(); 425 - 426 374 sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr); 427 - 428 375 return sta; 376 + 377 + free: 378 + if (sta->tx_lat) { 379 + for (i = 0; i < IEEE80211_NUM_TIDS; i++) 380 + kfree(sta->tx_lat[i].bins); 381 + kfree(sta->tx_lat); 382 + } 383 + kfree(sta); 384 + return NULL; 429 385 } 430 386 431 387 static int sta_info_insert_check(struct sta_info *sta) ··· 1153 1143 1154 1144 static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata, 1155 1145 struct sta_info *sta, int tid, 1156 - enum ieee80211_frame_release_type reason) 1146 + enum ieee80211_frame_release_type reason, 1147 + bool call_driver) 1157 1148 { 1158 1149 struct ieee80211_local *local = sdata->local; 1159 1150 struct ieee80211_qos_hdr *nullfunc; ··· 1212 1201 IEEE80211_TX_STATUS_EOSP | 1213 1202 IEEE80211_TX_CTL_REQ_TX_STATUS; 1214 1203 1215 - drv_allow_buffered_frames(local, sta, BIT(tid), 1, reason, false); 1204 + if (call_driver) 1205 + drv_allow_buffered_frames(local, sta, BIT(tid), 1, 1206 + reason, false); 1216 1207 1217 1208 skb->dev = sdata->dev; 1218 1209 ··· 1230 1217 rcu_read_unlock(); 1231 1218 } 1232 1219 1220 + static int find_highest_prio_tid(unsigned long tids) 1221 + { 1222 + /* lower 3 TIDs aren't ordered perfectly */ 1223 + if (tids & 0xF8) 1224 + return fls(tids) - 1; 1225 + /* TID 0 is BE just like TID 3 */ 1226 + if (tids & BIT(0)) 1227 + return 0; 1228 + return fls(tids) - 1; 1229 + } 1230 + 1233 1231 static void 1234 1232 ieee80211_sta_ps_deliver_response(struct sta_info *sta, 1235 1233 int n_frames, u8 ignored_acs, ··· 1248 1224 { 1249 1225 struct ieee80211_sub_if_data *sdata = sta->sdata; 1250 1226 struct ieee80211_local *local = sdata->local; 1251 - bool found = false; 1252 1227 bool more_data = false; 1253 1228 int ac; 1254 1229 unsigned long driver_release_tids = 0; ··· 1258 1235 1259 1236 __skb_queue_head_init(&frames); 1260 1237 1261 - /* 1262 - * Get response frame(s) and more data bit for it. 1263 - */ 1238 + /* Get response frame(s) and more data bit for the last one. */ 1264 1239 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { 1265 1240 unsigned long tids; 1266 1241 ··· 1267 1246 1268 1247 tids = ieee80211_tids_for_ac(ac); 1269 1248 1270 - if (!found) { 1271 - driver_release_tids = sta->driver_buffered_tids & tids; 1272 - if (driver_release_tids) { 1273 - found = true; 1274 - } else { 1275 - struct sk_buff *skb; 1249 + /* if we already have frames from software, then we can't also 1250 + * release from hardware queues 1251 + */ 1252 + if (skb_queue_empty(&frames)) 1253 + driver_release_tids |= sta->driver_buffered_tids & tids; 1276 1254 1277 - while (n_frames > 0) { 1278 - skb = skb_dequeue(&sta->tx_filtered[ac]); 1279 - if (!skb) { 1280 - skb = skb_dequeue( 1281 - &sta->ps_tx_buf[ac]); 1282 - if (skb) 1283 - local->total_ps_buffered--; 1284 - } 1285 - if (!skb) 1286 - break; 1287 - n_frames--; 1288 - found = true; 1289 - __skb_queue_tail(&frames, skb); 1290 - } 1291 - } 1292 - 1293 - /* 1294 - * If the driver has data on more than one TID then 1255 + if (driver_release_tids) { 1256 + /* If the driver has data on more than one TID then 1295 1257 * certainly there's more data if we release just a 1296 - * single frame now (from a single TID). 1258 + * single frame now (from a single TID). This will 1259 + * only happen for PS-Poll. 1297 1260 */ 1298 1261 if (reason == IEEE80211_FRAME_RELEASE_PSPOLL && 1299 1262 hweight16(driver_release_tids) > 1) { 1300 1263 more_data = true; 1301 1264 driver_release_tids = 1302 - BIT(ffs(driver_release_tids) - 1); 1265 + BIT(find_highest_prio_tid( 1266 + driver_release_tids)); 1303 1267 break; 1268 + } 1269 + } else { 1270 + struct sk_buff *skb; 1271 + 1272 + while (n_frames > 0) { 1273 + skb = skb_dequeue(&sta->tx_filtered[ac]); 1274 + if (!skb) { 1275 + skb = skb_dequeue( 1276 + &sta->ps_tx_buf[ac]); 1277 + if (skb) 1278 + local->total_ps_buffered--; 1279 + } 1280 + if (!skb) 1281 + break; 1282 + n_frames--; 1283 + __skb_queue_tail(&frames, skb); 1304 1284 } 1305 1285 } 1306 1286 1287 + /* If we have more frames buffered on this AC, then set the 1288 + * more-data bit and abort the loop since we can't send more 1289 + * data from other ACs before the buffered frames from this. 1290 + */ 1307 1291 if (!skb_queue_empty(&sta->tx_filtered[ac]) || 1308 1292 !skb_queue_empty(&sta->ps_tx_buf[ac])) { 1309 1293 more_data = true; ··· 1316 1290 } 1317 1291 } 1318 1292 1319 - if (!found) { 1293 + if (skb_queue_empty(&frames) && !driver_release_tids) { 1320 1294 int tid; 1321 1295 1322 1296 /* ··· 1337 1311 /* This will evaluate to 1, 3, 5 or 7. */ 1338 1312 tid = 7 - ((ffs(~ignored_acs) - 1) << 1); 1339 1313 1340 - ieee80211_send_null_response(sdata, sta, tid, reason); 1341 - return; 1342 - } 1343 - 1344 - if (!driver_release_tids) { 1314 + ieee80211_send_null_response(sdata, sta, tid, reason, true); 1315 + } else if (!driver_release_tids) { 1345 1316 struct sk_buff_head pending; 1346 1317 struct sk_buff *skb; 1347 1318 int num = 0; 1348 1319 u16 tids = 0; 1320 + bool need_null = false; 1349 1321 1350 1322 skb_queue_head_init(&pending); 1351 1323 ··· 1377 1353 ieee80211_is_qos_nullfunc(hdr->frame_control)) 1378 1354 qoshdr = ieee80211_get_qos_ctl(hdr); 1379 1355 1380 - /* end service period after last frame */ 1381 - if (skb_queue_empty(&frames)) { 1382 - if (reason == IEEE80211_FRAME_RELEASE_UAPSD && 1383 - qoshdr) 1384 - *qoshdr |= IEEE80211_QOS_CTL_EOSP; 1356 + tids |= BIT(skb->priority); 1357 + 1358 + __skb_queue_tail(&pending, skb); 1359 + 1360 + /* end service period after last frame or add one */ 1361 + if (!skb_queue_empty(&frames)) 1362 + continue; 1363 + 1364 + if (reason != IEEE80211_FRAME_RELEASE_UAPSD) { 1365 + /* for PS-Poll, there's only one frame */ 1366 + info->flags |= IEEE80211_TX_STATUS_EOSP | 1367 + IEEE80211_TX_CTL_REQ_TX_STATUS; 1368 + break; 1369 + } 1370 + 1371 + /* For uAPSD, things are a bit more complicated. If the 1372 + * last frame has a QoS header (i.e. is a QoS-data or 1373 + * QoS-nulldata frame) then just set the EOSP bit there 1374 + * and be done. 1375 + * If the frame doesn't have a QoS header (which means 1376 + * it should be a bufferable MMPDU) then we can't set 1377 + * the EOSP bit in the QoS header; add a QoS-nulldata 1378 + * frame to the list to send it after the MMPDU. 1379 + * 1380 + * Note that this code is only in the mac80211-release 1381 + * code path, we assume that the driver will not buffer 1382 + * anything but QoS-data frames, or if it does, will 1383 + * create the QoS-nulldata frame by itself if needed. 1384 + * 1385 + * Cf. 802.11-2012 10.2.1.10 (c). 1386 + */ 1387 + if (qoshdr) { 1388 + *qoshdr |= IEEE80211_QOS_CTL_EOSP; 1385 1389 1386 1390 info->flags |= IEEE80211_TX_STATUS_EOSP | 1387 1391 IEEE80211_TX_CTL_REQ_TX_STATUS; 1392 + } else { 1393 + /* The standard isn't completely clear on this 1394 + * as it says the more-data bit should be set 1395 + * if there are more BUs. The QoS-Null frame 1396 + * we're about to send isn't buffered yet, we 1397 + * only create it below, but let's pretend it 1398 + * was buffered just in case some clients only 1399 + * expect more-data=0 when eosp=1. 1400 + */ 1401 + hdr->frame_control |= 1402 + cpu_to_le16(IEEE80211_FCTL_MOREDATA); 1403 + need_null = true; 1404 + num++; 1388 1405 } 1389 - 1390 - if (qoshdr) 1391 - tids |= BIT(*qoshdr & IEEE80211_QOS_CTL_TID_MASK); 1392 - else 1393 - tids |= BIT(0); 1394 - 1395 - __skb_queue_tail(&pending, skb); 1406 + break; 1396 1407 } 1397 1408 1398 1409 drv_allow_buffered_frames(local, sta, tids, num, ··· 1435 1376 1436 1377 ieee80211_add_pending_skbs(local, &pending); 1437 1378 1379 + if (need_null) 1380 + ieee80211_send_null_response( 1381 + sdata, sta, find_highest_prio_tid(tids), 1382 + reason, false); 1383 + 1438 1384 sta_info_recalc_tim(sta); 1439 1385 } else { 1440 1386 /* 1441 1387 * We need to release a frame that is buffered somewhere in the 1442 1388 * driver ... it'll have to handle that. 1443 - * Note that, as per the comment above, it'll also have to see 1444 - * if there is more than just one frame on the specific TID that 1445 - * we're releasing from, and it needs to set the more-data bit 1446 - * accordingly if we tell it that there's no more data. If we do 1447 - * tell it there's more data, then of course the more-data bit 1448 - * needs to be set anyway. 1389 + * Note that the driver also has to check the number of frames 1390 + * on the TIDs we're releasing from - if there are more than 1391 + * n_frames it has to set the more-data bit (if we didn't ask 1392 + * it to set it anyway due to other buffered frames); if there 1393 + * are fewer than n_frames it has to make sure to adjust that 1394 + * to allow the service period to end properly. 1449 1395 */ 1450 1396 drv_release_buffered_frames(local, sta, driver_release_tids, 1451 1397 n_frames, reason, more_data); ··· 1458 1394 /* 1459 1395 * Note that we don't recalculate the TIM bit here as it would 1460 1396 * most likely have no effect at all unless the driver told us 1461 - * that the TID became empty before returning here from the 1397 + * that the TID(s) became empty before returning here from the 1462 1398 * release function. 1463 - * Either way, however, when the driver tells us that the TID 1399 + * Either way, however, when the driver tells us that the TID(s) 1464 1400 * became empty we'll do the TIM recalculation. 1465 1401 */ 1466 1402 } ··· 1548 1484 1549 1485 if (WARN_ON(tid >= IEEE80211_NUM_TIDS)) 1550 1486 return; 1487 + 1488 + trace_api_sta_set_buffered(sta->local, pubsta, tid, buffered); 1551 1489 1552 1490 if (buffered) 1553 1491 set_bit(tid, &sta->driver_buffered_tids);
+27
net/mac80211/trace.h
··· 1835 1835 ) 1836 1836 ); 1837 1837 1838 + TRACE_EVENT(api_sta_set_buffered, 1839 + TP_PROTO(struct ieee80211_local *local, 1840 + struct ieee80211_sta *sta, 1841 + u8 tid, bool buffered), 1842 + 1843 + TP_ARGS(local, sta, tid, buffered), 1844 + 1845 + TP_STRUCT__entry( 1846 + LOCAL_ENTRY 1847 + STA_ENTRY 1848 + __field(u8, tid) 1849 + __field(bool, buffered) 1850 + ), 1851 + 1852 + TP_fast_assign( 1853 + LOCAL_ASSIGN; 1854 + STA_ASSIGN; 1855 + __entry->tid = tid; 1856 + __entry->buffered = buffered; 1857 + ), 1858 + 1859 + TP_printk( 1860 + LOCAL_PR_FMT STA_PR_FMT " tid:%d buffered:%d", 1861 + LOCAL_PR_ARG, STA_PR_ARG, __entry->tid, __entry->buffered 1862 + ) 1863 + ); 1864 + 1838 1865 /* 1839 1866 * Tracing for internal functions 1840 1867 * (which may also be called in response to driver calls)
+2
net/mac80211/tx.c
··· 490 490 info->control.jiffies = jiffies; 491 491 info->control.vif = &tx->sdata->vif; 492 492 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; 493 + info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; 493 494 skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb); 494 495 495 496 if (!timer_pending(&local->sta_cleanup)) ··· 1077 1076 queued = true; 1078 1077 info->control.vif = &tx->sdata->vif; 1079 1078 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; 1079 + info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; 1080 1080 __skb_queue_tail(&tid_tx->pending, skb); 1081 1081 if (skb_queue_len(&tid_tx->pending) > STA_MAX_TX_BUFFER) 1082 1082 purge_skb = __skb_dequeue(&tid_tx->pending);
+41
net/mac80211/util.c
··· 2734 2734 return ret; 2735 2735 } 2736 2736 EXPORT_SYMBOL(ieee80211_parse_p2p_noa); 2737 + 2738 + void ieee80211_recalc_dtim(struct ieee80211_local *local, 2739 + struct ieee80211_sub_if_data *sdata) 2740 + { 2741 + u64 tsf = drv_get_tsf(local, sdata); 2742 + u64 dtim_count = 0; 2743 + u16 beacon_int = sdata->vif.bss_conf.beacon_int * 1024; 2744 + u8 dtim_period = sdata->vif.bss_conf.dtim_period; 2745 + struct ps_data *ps; 2746 + u8 bcns_from_dtim; 2747 + 2748 + if (tsf == -1ULL || !beacon_int || !dtim_period) 2749 + return; 2750 + 2751 + if (sdata->vif.type == NL80211_IFTYPE_AP || 2752 + sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { 2753 + if (!sdata->bss) 2754 + return; 2755 + 2756 + ps = &sdata->bss->ps; 2757 + } else if (ieee80211_vif_is_mesh(&sdata->vif)) { 2758 + ps = &sdata->u.mesh.ps; 2759 + } else { 2760 + return; 2761 + } 2762 + 2763 + /* 2764 + * actually finds last dtim_count, mac80211 will update in 2765 + * __beacon_add_tim(). 2766 + * dtim_count = dtim_period - (tsf / bcn_int) % dtim_period 2767 + */ 2768 + do_div(tsf, beacon_int); 2769 + bcns_from_dtim = do_div(tsf, dtim_period); 2770 + /* just had a DTIM */ 2771 + if (!bcns_from_dtim) 2772 + dtim_count = 0; 2773 + else 2774 + dtim_count = dtim_period - bcns_from_dtim; 2775 + 2776 + ps->dtim_count = dtim_count; 2777 + }
+1 -1
net/mac80211/wpa.c
··· 127 127 * APs with pairwise keys should never receive Michael MIC 128 128 * errors for non-zero keyidx because these are reserved for 129 129 * group keys and only the AP is sending real multicast 130 - * frames in the BSS. ( 130 + * frames in the BSS. 131 131 */ 132 132 return RX_DROP_UNUSABLE; 133 133 }
+2 -5
net/nfc/core.c
··· 133 133 dev->dev_up = true; 134 134 135 135 /* We have to enable the device before discovering SEs */ 136 - if (dev->ops->discover_se) { 137 - rc = dev->ops->discover_se(dev); 138 - if (rc) 139 - pr_warn("SE discovery failed\n"); 140 - } 136 + if (dev->ops->discover_se && dev->ops->discover_se(dev)) 137 + pr_err("SE discovery failed\n"); 141 138 142 139 error: 143 140 device_unlock(&dev->dev);
+26 -2
net/nfc/digital_core.c
··· 339 339 pr_debug("rf_tech=%d, protocol=%d\n", rf_tech, protocol); 340 340 341 341 ddev->curr_rf_tech = rf_tech; 342 - ddev->curr_protocol = protocol; 343 342 344 343 if (DIGITAL_DRV_CAPS_IN_CRC(ddev)) { 345 344 ddev->skb_add_crc = digital_skb_add_crc_none; ··· 540 541 __u8 comm_mode, __u8 *gb, size_t gb_len) 541 542 { 542 543 struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev); 544 + int rc; 543 545 544 - return digital_in_send_atr_req(ddev, target, comm_mode, gb, gb_len); 546 + rc = digital_in_send_atr_req(ddev, target, comm_mode, gb, gb_len); 547 + 548 + if (!rc) 549 + ddev->curr_protocol = NFC_PROTO_NFC_DEP; 550 + 551 + return rc; 545 552 } 546 553 547 554 static int digital_dep_link_down(struct nfc_dev *nfc_dev) ··· 562 557 static int digital_activate_target(struct nfc_dev *nfc_dev, 563 558 struct nfc_target *target, __u32 protocol) 564 559 { 560 + struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev); 561 + 562 + if (ddev->poll_tech_count) { 563 + pr_err("Can't activate a target while polling\n"); 564 + return -EBUSY; 565 + } 566 + 567 + if (ddev->curr_protocol) { 568 + pr_err("A target is already active\n"); 569 + return -EBUSY; 570 + } 571 + 572 + ddev->curr_protocol = protocol; 573 + 565 574 return 0; 566 575 } 567 576 ··· 583 564 struct nfc_target *target) 584 565 { 585 566 struct nfc_digital_dev *ddev = nfc_get_drvdata(nfc_dev); 567 + 568 + if (!ddev->curr_protocol) { 569 + pr_err("No active target\n"); 570 + return; 571 + } 586 572 587 573 ddev->curr_protocol = 0; 588 574 }
+36 -18
net/nfc/digital_dep.c
··· 32 32 #define DIGITAL_ATR_REQ_MIN_SIZE 16 33 33 #define DIGITAL_ATR_REQ_MAX_SIZE 64 34 34 35 - #define DIGITAL_NFCID3_LEN ((u8)8) 36 35 #define DIGITAL_LR_BITS_PAYLOAD_SIZE_254B 0x30 37 36 #define DIGITAL_GB_BIT 0x02 38 37 ··· 205 206 atr_req->dir = DIGITAL_NFC_DEP_FRAME_DIR_OUT; 206 207 atr_req->cmd = DIGITAL_CMD_ATR_REQ; 207 208 if (target->nfcid2_len) 208 - memcpy(atr_req->nfcid3, target->nfcid2, 209 - max(target->nfcid2_len, DIGITAL_NFCID3_LEN)); 209 + memcpy(atr_req->nfcid3, target->nfcid2, NFC_NFCID2_MAXSIZE); 210 210 else 211 - get_random_bytes(atr_req->nfcid3, DIGITAL_NFCID3_LEN); 211 + get_random_bytes(atr_req->nfcid3, NFC_NFCID3_MAXSIZE); 212 212 213 213 atr_req->did = 0; 214 214 atr_req->bs = 0; ··· 380 382 data_exch); 381 383 } 382 384 385 + static void digital_tg_set_rf_tech(struct nfc_digital_dev *ddev, u8 rf_tech) 386 + { 387 + ddev->curr_rf_tech = rf_tech; 388 + 389 + ddev->skb_add_crc = digital_skb_add_crc_none; 390 + ddev->skb_check_crc = digital_skb_check_crc_none; 391 + 392 + if (DIGITAL_DRV_CAPS_TG_CRC(ddev)) 393 + return; 394 + 395 + switch (ddev->curr_rf_tech) { 396 + case NFC_DIGITAL_RF_TECH_106A: 397 + ddev->skb_add_crc = digital_skb_add_crc_a; 398 + ddev->skb_check_crc = digital_skb_check_crc_a; 399 + break; 400 + 401 + case NFC_DIGITAL_RF_TECH_212F: 402 + case NFC_DIGITAL_RF_TECH_424F: 403 + ddev->skb_add_crc = digital_skb_add_crc_f; 404 + ddev->skb_check_crc = digital_skb_check_crc_f; 405 + break; 406 + 407 + default: 408 + break; 409 + } 410 + } 411 + 383 412 static void digital_tg_recv_dep_req(struct nfc_digital_dev *ddev, void *arg, 384 413 struct sk_buff *resp) 385 414 { ··· 497 472 static void digital_tg_send_psl_res_complete(struct nfc_digital_dev *ddev, 498 473 void *arg, struct sk_buff *resp) 499 474 { 500 - u8 rf_tech = PTR_ERR(arg); 475 + u8 rf_tech = (unsigned long)arg; 501 476 502 477 if (IS_ERR(resp)) 503 478 return; 479 + 480 + digital_tg_set_rf_tech(ddev, rf_tech); 504 481 505 482 digital_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH, rf_tech); 506 483 ··· 535 508 ddev->skb_add_crc(skb); 536 509 537 510 rc = digital_tg_send_cmd(ddev, skb, 0, digital_tg_send_psl_res_complete, 538 - ERR_PTR(rf_tech)); 511 + (void *)(unsigned long)rf_tech); 539 512 540 513 if (rc) 541 514 kfree_skb(skb); ··· 688 661 689 662 if (resp->data[0] == DIGITAL_NFC_DEP_NFCA_SOD_SB) { 690 663 min_size = DIGITAL_ATR_REQ_MIN_SIZE + 2; 691 - 692 - ddev->curr_rf_tech = NFC_DIGITAL_RF_TECH_106A; 693 - ddev->skb_add_crc = digital_skb_add_crc_a; 694 - ddev->skb_check_crc = digital_skb_check_crc_a; 664 + digital_tg_set_rf_tech(ddev, NFC_DIGITAL_RF_TECH_106A); 695 665 } else { 696 666 min_size = DIGITAL_ATR_REQ_MIN_SIZE + 1; 697 - 698 - ddev->curr_rf_tech = NFC_DIGITAL_RF_TECH_212F; 699 - ddev->skb_add_crc = digital_skb_add_crc_f; 700 - ddev->skb_check_crc = digital_skb_check_crc_f; 667 + digital_tg_set_rf_tech(ddev, NFC_DIGITAL_RF_TECH_212F); 701 668 } 702 669 703 670 if (resp->len < min_size) { ··· 699 678 goto exit; 700 679 } 701 680 702 - if (DIGITAL_DRV_CAPS_TG_CRC(ddev)) { 703 - ddev->skb_add_crc = digital_skb_add_crc_none; 704 - ddev->skb_check_crc = digital_skb_check_crc_none; 705 - } 681 + ddev->curr_protocol = NFC_PROTO_NFC_DEP_MASK; 706 682 707 683 rc = ddev->skb_check_crc(resp); 708 684 if (rc) {
+2 -5
net/nfc/hci/core.c
··· 335 335 kfree_skb(skb); 336 336 337 337 exit_noskb: 338 - if (r) { 339 - /* TODO: There was an error dispatching the event, 340 - * how to propagate up to nfc core? 341 - */ 342 - } 338 + if (r) 339 + nfc_hci_driver_failure(hdev, r); 343 340 } 344 341 345 342 static void nfc_hci_cmd_timeout(unsigned long data)
+4 -2
net/nfc/llcp_commands.c
··· 675 675 676 676 do { 677 677 remote_miu = sock->remote_miu > LLCP_MAX_MIU ? 678 - local->remote_miu : sock->remote_miu; 678 + LLCP_DEFAULT_MIU : sock->remote_miu; 679 679 680 680 frag_len = min_t(size_t, remote_miu, remaining_len); 681 681 ··· 684 684 685 685 pdu = llcp_allocate_pdu(sock, LLCP_PDU_I, 686 686 frag_len + LLCP_SEQUENCE_SIZE); 687 - if (pdu == NULL) 687 + if (pdu == NULL) { 688 + kfree(msg_data); 688 689 return -ENOMEM; 690 + } 689 691 690 692 skb_put(pdu, LLCP_SEQUENCE_SIZE); 691 693
-1
net/nfc/llcp_core.c
··· 943 943 new_sock->local = nfc_llcp_local_get(local); 944 944 new_sock->rw = sock->rw; 945 945 new_sock->miux = sock->miux; 946 - new_sock->remote_miu = local->remote_miu; 947 946 new_sock->nfc_protocol = sock->nfc_protocol; 948 947 new_sock->dsap = ssap; 949 948 new_sock->target_idx = local->target_idx;
-1
net/nfc/llcp_sock.c
··· 700 700 701 701 llcp_sock->dev = dev; 702 702 llcp_sock->local = nfc_llcp_local_get(local); 703 - llcp_sock->remote_miu = llcp_sock->local->remote_miu; 704 703 llcp_sock->ssap = nfc_llcp_get_local_ssap(local); 705 704 if (llcp_sock->ssap == LLCP_SAP_MAX) { 706 705 ret = -ENOMEM;
+21 -6
net/nfc/nci/core.c
··· 301 301 rc = __nci_request(ndev, nci_reset_req, 0, 302 302 msecs_to_jiffies(NCI_RESET_TIMEOUT)); 303 303 304 + if (ndev->ops->setup(ndev)) 305 + ndev->ops->setup(ndev); 306 + 304 307 if (!rc) { 305 308 rc = __nci_request(ndev, nci_init_req, 0, 306 309 msecs_to_jiffies(NCI_INIT_TIMEOUT)); ··· 364 361 msecs_to_jiffies(NCI_RESET_TIMEOUT)); 365 362 clear_bit(NCI_INIT, &ndev->flags); 366 363 364 + del_timer_sync(&ndev->cmd_timer); 365 + 367 366 /* Flush cmd wq */ 368 367 flush_workqueue(ndev->cmd_wq); 369 368 ··· 413 408 return nci_close_device(ndev); 414 409 } 415 410 411 + int nci_set_config(struct nci_dev *ndev, __u8 id, size_t len, __u8 *val) 412 + { 413 + struct nci_set_config_param param; 414 + 415 + if (!val || !len) 416 + return 0; 417 + 418 + param.id = id; 419 + param.len = len; 420 + param.val = val; 421 + 422 + return __nci_request(ndev, nci_set_config_req, (unsigned long)&param, 423 + msecs_to_jiffies(NCI_SET_CONFIG_TIMEOUT)); 424 + } 425 + EXPORT_SYMBOL(nci_set_config); 426 + 416 427 static int nci_set_local_general_bytes(struct nfc_dev *nfc_dev) 417 428 { 418 429 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 419 430 struct nci_set_config_param param; 420 - __u8 local_gb[NFC_MAX_GT_LEN]; 421 - int i; 422 431 423 432 param.val = nfc_get_local_general_bytes(nfc_dev, &param.len); 424 433 if ((param.val == NULL) || (param.len == 0)) ··· 441 422 if (param.len > NFC_MAX_GT_LEN) 442 423 return -EINVAL; 443 424 444 - for (i = 0; i < param.len; i++) 445 - local_gb[param.len-1-i] = param.val[i]; 446 - 447 425 param.id = NCI_PN_ATR_REQ_GEN_BYTES; 448 - param.val = local_gb; 449 426 450 427 return nci_request(ndev, nci_set_config_req, (unsigned long)&param, 451 428 msecs_to_jiffies(NCI_SET_CONFIG_TIMEOUT));
+51 -60
net/wireless/nl80211.c
··· 5257 5257 goto unlock; 5258 5258 } 5259 5259 } else { 5260 - enum ieee80211_band band; 5261 - n_channels = 0; 5262 - 5263 - for (band = 0; band < IEEE80211_NUM_BANDS; band++) 5264 - if (wiphy->bands[band]) 5265 - n_channels += wiphy->bands[band]->n_channels; 5260 + n_channels = ieee80211_get_num_supported_channels(wiphy); 5266 5261 } 5267 5262 5268 5263 if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) ··· 5465 5470 if (!n_channels) 5466 5471 return -EINVAL; 5467 5472 } else { 5468 - n_channels = 0; 5469 - 5470 - for (band = 0; band < IEEE80211_NUM_BANDS; band++) 5471 - if (wiphy->bands[band]) 5472 - n_channels += wiphy->bands[band]->n_channels; 5473 + n_channels = ieee80211_get_num_supported_channels(wiphy); 5473 5474 } 5474 5475 5475 5476 if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) ··· 6758 6767 return NULL; 6759 6768 } 6760 6769 6770 + struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy, 6771 + enum nl80211_commands cmd, 6772 + enum nl80211_attrs attr, 6773 + int vendor_event_idx, 6774 + int approxlen, gfp_t gfp) 6775 + { 6776 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 6777 + const struct nl80211_vendor_cmd_info *info; 6778 + 6779 + switch (cmd) { 6780 + case NL80211_CMD_TESTMODE: 6781 + if (WARN_ON(vendor_event_idx != -1)) 6782 + return NULL; 6783 + info = NULL; 6784 + break; 6785 + case NL80211_CMD_VENDOR: 6786 + if (WARN_ON(vendor_event_idx < 0 || 6787 + vendor_event_idx >= wiphy->n_vendor_events)) 6788 + return NULL; 6789 + info = &wiphy->vendor_events[vendor_event_idx]; 6790 + break; 6791 + default: 6792 + WARN_ON(1); 6793 + return NULL; 6794 + } 6795 + 6796 + return __cfg80211_alloc_vendor_skb(rdev, approxlen, 0, 0, 6797 + cmd, attr, info, gfp); 6798 + } 6799 + EXPORT_SYMBOL(__cfg80211_alloc_event_skb); 6800 + 6801 + void __cfg80211_send_event_skb(struct sk_buff *skb, gfp_t gfp) 6802 + { 6803 + struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0]; 6804 + void *hdr = ((void **)skb->cb)[1]; 6805 + struct nlattr *data = ((void **)skb->cb)[2]; 6806 + enum nl80211_multicast_groups mcgrp = NL80211_MCGRP_TESTMODE; 6807 + 6808 + nla_nest_end(skb, data); 6809 + genlmsg_end(skb, hdr); 6810 + 6811 + if (data->nla_type == NL80211_ATTR_VENDOR_DATA) 6812 + mcgrp = NL80211_MCGRP_VENDOR; 6813 + 6814 + genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), skb, 0, 6815 + mcgrp, gfp); 6816 + } 6817 + EXPORT_SYMBOL(__cfg80211_send_event_skb); 6818 + 6761 6819 #ifdef CONFIG_NL80211_TESTMODE 6762 6820 static int nl80211_testmode_do(struct sk_buff *skb, struct genl_info *info) 6763 6821 { ··· 6933 6893 rtnl_unlock(); 6934 6894 return err; 6935 6895 } 6936 - 6937 - struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy, 6938 - enum nl80211_commands cmd, 6939 - enum nl80211_attrs attr, 6940 - int vendor_event_idx, 6941 - int approxlen, gfp_t gfp) 6942 - { 6943 - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 6944 - const struct nl80211_vendor_cmd_info *info; 6945 - 6946 - switch (cmd) { 6947 - case NL80211_CMD_TESTMODE: 6948 - if (WARN_ON(vendor_event_idx != -1)) 6949 - return NULL; 6950 - info = NULL; 6951 - break; 6952 - case NL80211_CMD_VENDOR: 6953 - if (WARN_ON(vendor_event_idx < 0 || 6954 - vendor_event_idx >= wiphy->n_vendor_events)) 6955 - return NULL; 6956 - info = &wiphy->vendor_events[vendor_event_idx]; 6957 - break; 6958 - default: 6959 - WARN_ON(1); 6960 - return NULL; 6961 - } 6962 - 6963 - return __cfg80211_alloc_vendor_skb(rdev, approxlen, 0, 0, 6964 - cmd, attr, info, gfp); 6965 - } 6966 - EXPORT_SYMBOL(__cfg80211_alloc_event_skb); 6967 - 6968 - void __cfg80211_send_event_skb(struct sk_buff *skb, gfp_t gfp) 6969 - { 6970 - struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0]; 6971 - void *hdr = ((void **)skb->cb)[1]; 6972 - struct nlattr *data = ((void **)skb->cb)[2]; 6973 - enum nl80211_multicast_groups mcgrp = NL80211_MCGRP_TESTMODE; 6974 - 6975 - nla_nest_end(skb, data); 6976 - genlmsg_end(skb, hdr); 6977 - 6978 - if (data->nla_type == NL80211_ATTR_VENDOR_DATA) 6979 - mcgrp = NL80211_MCGRP_VENDOR; 6980 - 6981 - genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), skb, 0, 6982 - mcgrp, gfp); 6983 - } 6984 - EXPORT_SYMBOL(__cfg80211_send_event_skb); 6985 6896 #endif 6986 6897 6987 6898 static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
+2
net/wireless/reg.c
··· 1853 1853 if (WARN_ON(!alpha2 || !wiphy)) 1854 1854 return -EINVAL; 1855 1855 1856 + wiphy->regulatory_flags &= ~REGULATORY_CUSTOM_REG; 1857 + 1856 1858 request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL); 1857 1859 if (!request) 1858 1860 return -ENOMEM;
+2 -5
net/wireless/scan.c
··· 1089 1089 /* Determine number of channels, needed to allocate creq */ 1090 1090 if (wreq && wreq->num_channels) 1091 1091 n_channels = wreq->num_channels; 1092 - else { 1093 - for (band = 0; band < IEEE80211_NUM_BANDS; band++) 1094 - if (wiphy->bands[band]) 1095 - n_channels += wiphy->bands[band]->n_channels; 1096 - } 1092 + else 1093 + n_channels = ieee80211_get_num_supported_channels(wiphy); 1097 1094 1098 1095 creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) + 1099 1096 n_channels * sizeof(void *),
+3 -10
net/wireless/sme.c
··· 70 70 if (rdev->scan_req) 71 71 return -EBUSY; 72 72 73 - if (wdev->conn->params.channel) { 73 + if (wdev->conn->params.channel) 74 74 n_channels = 1; 75 - } else { 76 - enum ieee80211_band band; 77 - n_channels = 0; 75 + else 76 + n_channels = ieee80211_get_num_supported_channels(wdev->wiphy); 78 77 79 - for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 80 - if (!wdev->wiphy->bands[band]) 81 - continue; 82 - n_channels += wdev->wiphy->bands[band]->n_channels; 83 - } 84 - } 85 78 request = kzalloc(sizeof(*request) + sizeof(request->ssids[0]) + 86 79 sizeof(request->channels[0]) * n_channels, 87 80 GFP_KERNEL);
+15
net/wireless/util.c
··· 879 879 880 880 dev->ieee80211_ptr->use_4addr = false; 881 881 dev->ieee80211_ptr->mesh_id_up_len = 0; 882 + wdev_lock(dev->ieee80211_ptr); 882 883 rdev_set_qos_map(rdev, dev, NULL); 884 + wdev_unlock(dev->ieee80211_ptr); 883 885 884 886 switch (otype) { 885 887 case NL80211_IFTYPE_AP: ··· 1480 1478 1481 1479 return 0; 1482 1480 } 1481 + 1482 + unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy) 1483 + { 1484 + enum ieee80211_band band; 1485 + unsigned int n_channels = 0; 1486 + 1487 + for (band = 0; band < IEEE80211_NUM_BANDS; band++) 1488 + if (wiphy->bands[band]) 1489 + n_channels += wiphy->bands[band]->n_channels; 1490 + 1491 + return n_channels; 1492 + } 1493 + EXPORT_SYMBOL(ieee80211_get_num_supported_channels); 1483 1494 1484 1495 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ 1485 1496 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
+3 -3
net/wireless/wext-compat.c
··· 370 370 u8 oshort = wdev->wiphy->retry_short; 371 371 int err; 372 372 373 - if (retry->disabled || 373 + if (retry->disabled || retry->value < 1 || retry->value > 255 || 374 374 (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT) 375 375 return -EINVAL; 376 376 ··· 412 412 * First return short value, iwconfig will ask long value 413 413 * later if needed 414 414 */ 415 - retry->flags |= IW_RETRY_LIMIT; 415 + retry->flags |= IW_RETRY_LIMIT | IW_RETRY_SHORT; 416 416 retry->value = wdev->wiphy->retry_short; 417 - if (wdev->wiphy->retry_long != wdev->wiphy->retry_short) 417 + if (wdev->wiphy->retry_long == wdev->wiphy->retry_short) 418 418 retry->flags |= IW_RETRY_LONG; 419 419 420 420 return 0;