diff options
author | John W. Linville <linville@tuxdriver.com> | 2014-01-13 14:40:59 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2014-01-13 14:40:59 -0500 |
commit | f13352519ee8c4b22b87fc1a47743d1f53ea193e (patch) | |
tree | 48c18144f3e5e530ec61d5eadbb5a34675a69fe8 | |
parent | 559c33d84da71e07816e692bfd73ad92675256a6 (diff) | |
parent | 26b0e411d37a2ca5992d02884dc3fa4e1907e598 (diff) |
Merge branch 'for-john' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next
39 files changed, 1047 insertions, 866 deletions
diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c index e888f1893179..84e57230b31a 100644 --- a/drivers/net/wireless/adm8211.c +++ b/drivers/net/wireless/adm8211.c | |||
@@ -1865,7 +1865,6 @@ static int adm8211_probe(struct pci_dev *pdev, | |||
1865 | dev->flags = IEEE80211_HW_SIGNAL_UNSPEC; | 1865 | dev->flags = IEEE80211_HW_SIGNAL_UNSPEC; |
1866 | dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); | 1866 | dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); |
1867 | 1867 | ||
1868 | dev->channel_change_time = 1000; | ||
1869 | dev->max_signal = 100; /* FIXME: find better value */ | 1868 | dev->max_signal = 100; /* FIXME: find better value */ |
1870 | 1869 | ||
1871 | dev->queues = 1; /* ADM8211C supports more, maybe ADM8211B too */ | 1870 | dev->queues = 1; /* ADM8211C supports more, maybe ADM8211B too */ |
diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c index 031d4ec64779..99b3bfa717d5 100644 --- a/drivers/net/wireless/at76c50x-usb.c +++ b/drivers/net/wireless/at76c50x-usb.c | |||
@@ -2112,7 +2112,6 @@ static struct at76_priv *at76_alloc_new_device(struct usb_device *udev) | |||
2112 | priv->pm_period = 0; | 2112 | priv->pm_period = 0; |
2113 | 2113 | ||
2114 | /* unit us */ | 2114 | /* unit us */ |
2115 | priv->hw->channel_change_time = 100000; | ||
2116 | 2115 | ||
2117 | return priv; | 2116 | return priv; |
2118 | } | 2117 | } |
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 7aa6c4d702d6..776e364eadcd 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c | |||
@@ -4039,7 +4039,6 @@ int ath10k_mac_register(struct ath10k *ar) | |||
4039 | 4039 | ||
4040 | ar->hw->vif_data_size = sizeof(struct ath10k_vif); | 4040 | ar->hw->vif_data_size = sizeof(struct ath10k_vif); |
4041 | 4041 | ||
4042 | ar->hw->channel_change_time = 5000; | ||
4043 | ar->hw->max_listen_interval = ATH10K_MAX_HW_LISTEN_INTERVAL; | 4042 | ar->hw->max_listen_interval = ATH10K_MAX_HW_LISTEN_INTERVAL; |
4044 | 4043 | ||
4045 | ar->hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; | 4044 | ar->hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; |
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index 6396ad4bce67..d85c312170bc 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c | |||
@@ -2549,7 +2549,6 @@ ath5k_init_ah(struct ath5k_hw *ah, const struct ath_bus_ops *bus_ops) | |||
2549 | hw->wiphy->available_antennas_rx = 0x3; | 2549 | hw->wiphy->available_antennas_rx = 0x3; |
2550 | 2550 | ||
2551 | hw->extra_tx_headroom = 2; | 2551 | hw->extra_tx_headroom = 2; |
2552 | hw->channel_change_time = 5000; | ||
2553 | 2552 | ||
2554 | /* | 2553 | /* |
2555 | * Mark the device as detached to avoid processing | 2554 | * Mark the device as detached to avoid processing |
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c index b576c44bb314..f4e1de20d99c 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c | |||
@@ -748,7 +748,6 @@ static void ath9k_set_hw_capab(struct ath9k_htc_priv *priv, | |||
748 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; | 748 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; |
749 | 749 | ||
750 | hw->queues = 4; | 750 | hw->queues = 4; |
751 | hw->channel_change_time = 5000; | ||
752 | hw->max_listen_interval = 1; | 751 | hw->max_listen_interval = 1; |
753 | 752 | ||
754 | hw->vif_data_size = sizeof(struct ath9k_htc_vif); | 753 | hw->vif_data_size = sizeof(struct ath9k_htc_vif); |
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index f2a17fcf1ae4..c36de303c8f3 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c | |||
@@ -946,7 +946,6 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) | |||
946 | 946 | ||
947 | hw->queues = 4; | 947 | hw->queues = 4; |
948 | hw->max_rates = 4; | 948 | hw->max_rates = 4; |
949 | hw->channel_change_time = 5000; | ||
950 | hw->max_listen_interval = 1; | 949 | hw->max_listen_interval = 1; |
951 | hw->max_rate_tries = 10; | 950 | hw->max_rate_tries = 10; |
952 | hw->sta_data_size = sizeof(struct ath_node); | 951 | hw->sta_data_size = sizeof(struct ath_node); |
diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c index 4c3f576c3144..4c8cdb097b65 100644 --- a/drivers/net/wireless/ath/carl9170/main.c +++ b/drivers/net/wireless/ath/carl9170/main.c | |||
@@ -1967,18 +1967,6 @@ static int carl9170_parse_eeprom(struct ar9170 *ar) | |||
1967 | return -ENOMEM; | 1967 | return -ENOMEM; |
1968 | ar->num_channels = chans; | 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 | regulatory->current_rd = le16_to_cpu(ar->eeprom.reg_domain[0]); | 1970 | regulatory->current_rd = le16_to_cpu(ar->eeprom.reg_domain[0]); |
1983 | 1971 | ||
1984 | /* second part of wiphy init */ | 1972 | /* second part of wiphy init */ |
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index e71ce8c842a2..925034b80e9c 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c | |||
@@ -1071,7 +1071,6 @@ static int ieee_hw_init(struct ieee80211_hw *hw) | |||
1071 | hw->max_rates = 2; /* Primary rate and 1 fallback rate */ | 1071 | hw->max_rates = 2; /* Primary rate and 1 fallback rate */ |
1072 | 1072 | ||
1073 | /* channel change time is dependent on chip and band */ | 1073 | /* channel change time is dependent on chip and band */ |
1074 | hw->channel_change_time = 7 * 1000; | ||
1075 | hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | | 1074 | hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | |
1076 | BIT(NL80211_IFTYPE_AP) | | 1075 | BIT(NL80211_IFTYPE_AP) | |
1077 | BIT(NL80211_IFTYPE_ADHOC); | 1076 | BIT(NL80211_IFTYPE_ADHOC); |
diff --git a/drivers/net/wireless/cw1200/main.c b/drivers/net/wireless/cw1200/main.c index d1270da4dfea..3e78cc3ccb78 100644 --- a/drivers/net/wireless/cw1200/main.c +++ b/drivers/net/wireless/cw1200/main.c | |||
@@ -301,7 +301,6 @@ static struct ieee80211_hw *cw1200_init_common(const u8 *macaddr, | |||
301 | 301 | ||
302 | hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; | 302 | hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; |
303 | 303 | ||
304 | hw->channel_change_time = 1000; /* TODO: find actual value */ | ||
305 | hw->queues = 4; | 304 | hw->queues = 4; |
306 | 305 | ||
307 | priv->rts_threshold = -1; | 306 | priv->rts_threshold = -1; |
diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c index 116f4aba08d6..32f75007a825 100644 --- a/drivers/net/wireless/libertas/cfg.c +++ b/drivers/net/wireless/libertas/cfg.c | |||
@@ -1268,14 +1268,9 @@ static struct cfg80211_scan_request * | |||
1268 | _new_connect_scan_req(struct wiphy *wiphy, struct cfg80211_connect_params *sme) | 1268 | _new_connect_scan_req(struct wiphy *wiphy, struct cfg80211_connect_params *sme) |
1269 | { | 1269 | { |
1270 | struct cfg80211_scan_request *creq = NULL; | 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 | enum ieee80211_band band; | 1272 | enum ieee80211_band band; |
1273 | 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 | |||
1279 | creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) + | 1274 | creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) + |
1280 | n_channels * sizeof(void *), | 1275 | n_channels * sizeof(void *), |
1281 | GFP_ATOMIC); | 1276 | GFP_ATOMIC); |
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 9c0cc8ded021..dc7f72e3a4e7 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c | |||
@@ -163,6 +163,11 @@ static const struct ieee80211_regdomain hwsim_world_regdom_custom_02 = { | |||
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 | struct hwsim_vif_priv { | 171 | struct hwsim_vif_priv { |
167 | u32 magic; | 172 | u32 magic; |
168 | u8 bssid[ETH_ALEN]; | 173 | u8 bssid[ETH_ALEN]; |
@@ -321,8 +326,52 @@ static const struct ieee80211_rate hwsim_rates[] = { | |||
321 | { .bitrate = 540 } | 326 | { .bitrate = 540 } |
322 | }; | 327 | }; |
323 | 328 | ||
329 | static const struct ieee80211_iface_limit hwsim_if_limits[] = { | ||
330 | { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) }, | ||
331 | { .max = 2048, .types = BIT(NL80211_IFTYPE_STATION) | | ||
332 | BIT(NL80211_IFTYPE_P2P_CLIENT) | | ||
333 | #ifdef CONFIG_MAC80211_MESH | ||
334 | BIT(NL80211_IFTYPE_MESH_POINT) | | ||
335 | #endif | ||
336 | BIT(NL80211_IFTYPE_AP) | | ||
337 | BIT(NL80211_IFTYPE_P2P_GO) }, | ||
338 | { .max = 1, .types = BIT(NL80211_IFTYPE_P2P_DEVICE) }, | ||
339 | }; | ||
340 | |||
341 | static const struct ieee80211_iface_limit hwsim_if_dfs_limits[] = { | ||
342 | { .max = 8, .types = BIT(NL80211_IFTYPE_AP) }, | ||
343 | }; | ||
344 | |||
345 | static const struct ieee80211_iface_combination hwsim_if_comb[] = { | ||
346 | { | ||
347 | .limits = hwsim_if_limits, | ||
348 | .n_limits = ARRAY_SIZE(hwsim_if_limits), | ||
349 | .max_interfaces = 2048, | ||
350 | .num_different_channels = 1, | ||
351 | }, | ||
352 | { | ||
353 | .limits = hwsim_if_dfs_limits, | ||
354 | .n_limits = ARRAY_SIZE(hwsim_if_dfs_limits), | ||
355 | .max_interfaces = 8, | ||
356 | .num_different_channels = 1, | ||
357 | .radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) | | ||
358 | BIT(NL80211_CHAN_WIDTH_20) | | ||
359 | BIT(NL80211_CHAN_WIDTH_40) | | ||
360 | BIT(NL80211_CHAN_WIDTH_80) | | ||
361 | BIT(NL80211_CHAN_WIDTH_160), | ||
362 | } | ||
363 | }; | ||
364 | |||
324 | static spinlock_t hwsim_radio_lock; | 365 | static spinlock_t hwsim_radio_lock; |
325 | static struct list_head hwsim_radios; | 366 | static struct list_head hwsim_radios; |
367 | static int hwsim_radio_idx; | ||
368 | |||
369 | static struct platform_driver mac80211_hwsim_driver = { | ||
370 | .driver = { | ||
371 | .name = "mac80211_hwsim", | ||
372 | .owner = THIS_MODULE, | ||
373 | }, | ||
374 | }; | ||
326 | 375 | ||
327 | struct mac80211_hwsim_data { | 376 | struct mac80211_hwsim_data { |
328 | struct list_head list; | 377 | struct list_head list; |
@@ -332,8 +381,10 @@ struct mac80211_hwsim_data { | |||
332 | struct ieee80211_channel channels_2ghz[ARRAY_SIZE(hwsim_channels_2ghz)]; | 381 | struct ieee80211_channel channels_2ghz[ARRAY_SIZE(hwsim_channels_2ghz)]; |
333 | struct ieee80211_channel channels_5ghz[ARRAY_SIZE(hwsim_channels_5ghz)]; | 382 | struct ieee80211_channel channels_5ghz[ARRAY_SIZE(hwsim_channels_5ghz)]; |
334 | struct ieee80211_rate rates[ARRAY_SIZE(hwsim_rates)]; | 383 | struct ieee80211_rate rates[ARRAY_SIZE(hwsim_rates)]; |
384 | struct ieee80211_iface_combination if_combination; | ||
335 | 385 | ||
336 | struct mac_address addresses[2]; | 386 | struct mac_address addresses[2]; |
387 | int channels, idx; | ||
337 | 388 | ||
338 | struct ieee80211_channel *tmp_chan; | 389 | struct ieee80211_channel *tmp_chan; |
339 | struct delayed_work roc_done; | 390 | struct delayed_work roc_done; |
@@ -401,21 +452,179 @@ static struct genl_family hwsim_genl_family = { | |||
401 | /* MAC80211_HWSIM netlink policy */ | 452 | /* MAC80211_HWSIM netlink policy */ |
402 | 453 | ||
403 | static struct nla_policy hwsim_genl_policy[HWSIM_ATTR_MAX + 1] = { | 454 | static struct nla_policy hwsim_genl_policy[HWSIM_ATTR_MAX + 1] = { |
404 | [HWSIM_ATTR_ADDR_RECEIVER] = { .type = NLA_UNSPEC, | 455 | [HWSIM_ATTR_ADDR_RECEIVER] = { .type = NLA_UNSPEC, .len = ETH_ALEN }, |
405 | .len = 6*sizeof(u8) }, | 456 | [HWSIM_ATTR_ADDR_TRANSMITTER] = { .type = NLA_UNSPEC, .len = ETH_ALEN }, |
406 | [HWSIM_ATTR_ADDR_TRANSMITTER] = { .type = NLA_UNSPEC, | ||
407 | .len = 6*sizeof(u8) }, | ||
408 | [HWSIM_ATTR_FRAME] = { .type = NLA_BINARY, | 457 | [HWSIM_ATTR_FRAME] = { .type = NLA_BINARY, |
409 | .len = IEEE80211_MAX_DATA_LEN }, | 458 | .len = IEEE80211_MAX_DATA_LEN }, |
410 | [HWSIM_ATTR_FLAGS] = { .type = NLA_U32 }, | 459 | [HWSIM_ATTR_FLAGS] = { .type = NLA_U32 }, |
411 | [HWSIM_ATTR_RX_RATE] = { .type = NLA_U32 }, | 460 | [HWSIM_ATTR_RX_RATE] = { .type = NLA_U32 }, |
412 | [HWSIM_ATTR_SIGNAL] = { .type = NLA_U32 }, | 461 | [HWSIM_ATTR_SIGNAL] = { .type = NLA_U32 }, |
413 | [HWSIM_ATTR_TX_INFO] = { .type = NLA_UNSPEC, | 462 | [HWSIM_ATTR_TX_INFO] = { .type = NLA_UNSPEC, |
414 | .len = IEEE80211_TX_MAX_RATES*sizeof( | 463 | .len = IEEE80211_TX_MAX_RATES * |
415 | struct hwsim_tx_rate)}, | 464 | sizeof(struct hwsim_tx_rate)}, |
416 | [HWSIM_ATTR_COOKIE] = { .type = NLA_U64 }, | 465 | [HWSIM_ATTR_COOKIE] = { .type = NLA_U64 }, |
466 | [HWSIM_ATTR_CHANNELS] = { .type = NLA_U32 }, | ||
467 | [HWSIM_ATTR_RADIO_ID] = { .type = NLA_U32 }, | ||
468 | [HWSIM_ATTR_REG_HINT_ALPHA2] = { .type = NLA_STRING, .len = 2 }, | ||
469 | [HWSIM_ATTR_REG_CUSTOM_REG] = { .type = NLA_U32 }, | ||
470 | [HWSIM_ATTR_REG_STRICT_REG] = { .type = NLA_FLAG }, | ||
417 | }; | 471 | }; |
418 | 472 | ||
473 | static void mac80211_hwsim_tx_frame(struct ieee80211_hw *hw, | ||
474 | struct sk_buff *skb, | ||
475 | struct ieee80211_channel *chan); | ||
476 | |||
477 | /* sysfs attributes */ | ||
478 | static void hwsim_send_ps_poll(void *dat, u8 *mac, struct ieee80211_vif *vif) | ||
479 | { | ||
480 | struct mac80211_hwsim_data *data = dat; | ||
481 | struct hwsim_vif_priv *vp = (void *)vif->drv_priv; | ||
482 | struct sk_buff *skb; | ||
483 | struct ieee80211_pspoll *pspoll; | ||
484 | |||
485 | if (!vp->assoc) | ||
486 | return; | ||
487 | |||
488 | wiphy_debug(data->hw->wiphy, | ||
489 | "%s: send PS-Poll to %pM for aid %d\n", | ||
490 | __func__, vp->bssid, vp->aid); | ||
491 | |||
492 | skb = dev_alloc_skb(sizeof(*pspoll)); | ||
493 | if (!skb) | ||
494 | return; | ||
495 | pspoll = (void *) skb_put(skb, sizeof(*pspoll)); | ||
496 | pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | | ||
497 | IEEE80211_STYPE_PSPOLL | | ||
498 | IEEE80211_FCTL_PM); | ||
499 | pspoll->aid = cpu_to_le16(0xc000 | vp->aid); | ||
500 | memcpy(pspoll->bssid, vp->bssid, ETH_ALEN); | ||
501 | memcpy(pspoll->ta, mac, ETH_ALEN); | ||
502 | |||
503 | rcu_read_lock(); | ||
504 | mac80211_hwsim_tx_frame(data->hw, skb, | ||
505 | rcu_dereference(vif->chanctx_conf)->def.chan); | ||
506 | rcu_read_unlock(); | ||
507 | } | ||
508 | |||
509 | static void hwsim_send_nullfunc(struct mac80211_hwsim_data *data, u8 *mac, | ||
510 | struct ieee80211_vif *vif, int ps) | ||
511 | { | ||
512 | struct hwsim_vif_priv *vp = (void *)vif->drv_priv; | ||
513 | struct sk_buff *skb; | ||
514 | struct ieee80211_hdr *hdr; | ||
515 | |||
516 | if (!vp->assoc) | ||
517 | return; | ||
518 | |||
519 | wiphy_debug(data->hw->wiphy, | ||
520 | "%s: send data::nullfunc to %pM ps=%d\n", | ||
521 | __func__, vp->bssid, ps); | ||
522 | |||
523 | skb = dev_alloc_skb(sizeof(*hdr)); | ||
524 | if (!skb) | ||
525 | return; | ||
526 | hdr = (void *) skb_put(skb, sizeof(*hdr) - ETH_ALEN); | ||
527 | hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | | ||
528 | IEEE80211_STYPE_NULLFUNC | | ||
529 | (ps ? IEEE80211_FCTL_PM : 0)); | ||
530 | hdr->duration_id = cpu_to_le16(0); | ||
531 | memcpy(hdr->addr1, vp->bssid, ETH_ALEN); | ||
532 | memcpy(hdr->addr2, mac, ETH_ALEN); | ||
533 | memcpy(hdr->addr3, vp->bssid, ETH_ALEN); | ||
534 | |||
535 | rcu_read_lock(); | ||
536 | mac80211_hwsim_tx_frame(data->hw, skb, | ||
537 | rcu_dereference(vif->chanctx_conf)->def.chan); | ||
538 | rcu_read_unlock(); | ||
539 | } | ||
540 | |||
541 | |||
542 | static void hwsim_send_nullfunc_ps(void *dat, u8 *mac, | ||
543 | struct ieee80211_vif *vif) | ||
544 | { | ||
545 | struct mac80211_hwsim_data *data = dat; | ||
546 | hwsim_send_nullfunc(data, mac, vif, 1); | ||
547 | } | ||
548 | |||
549 | static void hwsim_send_nullfunc_no_ps(void *dat, u8 *mac, | ||
550 | struct ieee80211_vif *vif) | ||
551 | { | ||
552 | struct mac80211_hwsim_data *data = dat; | ||
553 | hwsim_send_nullfunc(data, mac, vif, 0); | ||
554 | } | ||
555 | |||
556 | static int hwsim_fops_ps_read(void *dat, u64 *val) | ||
557 | { | ||
558 | struct mac80211_hwsim_data *data = dat; | ||
559 | *val = data->ps; | ||
560 | return 0; | ||
561 | } | ||
562 | |||
563 | static int hwsim_fops_ps_write(void *dat, u64 val) | ||
564 | { | ||
565 | struct mac80211_hwsim_data *data = dat; | ||
566 | enum ps_mode old_ps; | ||
567 | |||
568 | if (val != PS_DISABLED && val != PS_ENABLED && val != PS_AUTO_POLL && | ||
569 | val != PS_MANUAL_POLL) | ||
570 | return -EINVAL; | ||
571 | |||
572 | old_ps = data->ps; | ||
573 | data->ps = val; | ||
574 | |||
575 | if (val == PS_MANUAL_POLL) { | ||
576 | ieee80211_iterate_active_interfaces(data->hw, | ||
577 | IEEE80211_IFACE_ITER_NORMAL, | ||
578 | hwsim_send_ps_poll, data); | ||
579 | data->ps_poll_pending = true; | ||
580 | } else if (old_ps == PS_DISABLED && val != PS_DISABLED) { | ||
581 | ieee80211_iterate_active_interfaces(data->hw, | ||
582 | IEEE80211_IFACE_ITER_NORMAL, | ||
583 | hwsim_send_nullfunc_ps, | ||
584 | data); | ||
585 | } else if (old_ps != PS_DISABLED && val == PS_DISABLED) { | ||
586 | ieee80211_iterate_active_interfaces(data->hw, | ||
587 | IEEE80211_IFACE_ITER_NORMAL, | ||
588 | hwsim_send_nullfunc_no_ps, | ||
589 | data); | ||
590 | } | ||
591 | |||
592 | return 0; | ||
593 | } | ||
594 | |||
595 | DEFINE_SIMPLE_ATTRIBUTE(hwsim_fops_ps, hwsim_fops_ps_read, hwsim_fops_ps_write, | ||
596 | "%llu\n"); | ||
597 | |||
598 | static int hwsim_write_simulate_radar(void *dat, u64 val) | ||
599 | { | ||
600 | struct mac80211_hwsim_data *data = dat; | ||
601 | |||
602 | ieee80211_radar_detected(data->hw); | ||
603 | |||
604 | return 0; | ||
605 | } | ||
606 | |||
607 | DEFINE_SIMPLE_ATTRIBUTE(hwsim_simulate_radar, NULL, | ||
608 | hwsim_write_simulate_radar, "%llu\n"); | ||
609 | |||
610 | static int hwsim_fops_group_read(void *dat, u64 *val) | ||
611 | { | ||
612 | struct mac80211_hwsim_data *data = dat; | ||
613 | *val = data->group; | ||
614 | return 0; | ||
615 | } | ||
616 | |||
617 | static int hwsim_fops_group_write(void *dat, u64 val) | ||
618 | { | ||
619 | struct mac80211_hwsim_data *data = dat; | ||
620 | data->group = val; | ||
621 | return 0; | ||
622 | } | ||
623 | |||
624 | DEFINE_SIMPLE_ATTRIBUTE(hwsim_fops_group, | ||
625 | hwsim_fops_group_read, hwsim_fops_group_write, | ||
626 | "%llx\n"); | ||
627 | |||
419 | static netdev_tx_t hwsim_mon_xmit(struct sk_buff *skb, | 628 | static netdev_tx_t hwsim_mon_xmit(struct sk_buff *skb, |
420 | struct net_device *dev) | 629 | struct net_device *dev) |
421 | { | 630 | { |
@@ -639,7 +848,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, | |||
639 | } | 848 | } |
640 | 849 | ||
641 | if (nla_put(skb, HWSIM_ATTR_ADDR_TRANSMITTER, | 850 | if (nla_put(skb, HWSIM_ATTR_ADDR_TRANSMITTER, |
642 | sizeof(struct mac_address), data->addresses[1].addr)) | 851 | ETH_ALEN, data->addresses[1].addr)) |
643 | goto nla_put_failure; | 852 | goto nla_put_failure; |
644 | 853 | ||
645 | /* We get the skb->data */ | 854 | /* We get the skb->data */ |
@@ -878,7 +1087,7 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw, | |||
878 | return; | 1087 | return; |
879 | } | 1088 | } |
880 | 1089 | ||
881 | if (channels == 1) { | 1090 | if (data->channels == 1) { |
882 | channel = data->channel; | 1091 | channel = data->channel; |
883 | } else if (txi->hw_queue == 4) { | 1092 | } else if (txi->hw_queue == 4) { |
884 | channel = data->tmp_chan; | 1093 | channel = data->tmp_chan; |
@@ -906,7 +1115,7 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw, | |||
906 | if (control->sta) | 1115 | if (control->sta) |
907 | hwsim_check_sta_magic(control->sta); | 1116 | hwsim_check_sta_magic(control->sta); |
908 | 1117 | ||
909 | if (rctbl) | 1118 | if (hw->flags & IEEE80211_HW_SUPPORTS_RC_TABLE) |
910 | ieee80211_get_tx_rates(txi->control.vif, control->sta, skb, | 1119 | ieee80211_get_tx_rates(txi->control.vif, control->sta, skb, |
911 | txi->control.rates, | 1120 | txi->control.rates, |
912 | ARRAY_SIZE(txi->control.rates)); | 1121 | ARRAY_SIZE(txi->control.rates)); |
@@ -1013,7 +1222,7 @@ static void mac80211_hwsim_tx_frame(struct ieee80211_hw *hw, | |||
1013 | { | 1222 | { |
1014 | u32 _pid = ACCESS_ONCE(wmediumd_portid); | 1223 | u32 _pid = ACCESS_ONCE(wmediumd_portid); |
1015 | 1224 | ||
1016 | if (rctbl) { | 1225 | if (hw->flags & IEEE80211_HW_SUPPORTS_RC_TABLE) { |
1017 | struct ieee80211_tx_info *txi = IEEE80211_SKB_CB(skb); | 1226 | struct ieee80211_tx_info *txi = IEEE80211_SKB_CB(skb); |
1018 | ieee80211_get_tx_rates(txi->control.vif, NULL, skb, | 1227 | ieee80211_get_tx_rates(txi->control.vif, NULL, skb, |
1019 | txi->control.rates, | 1228 | txi->control.rates, |
@@ -1050,7 +1259,7 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac, | |||
1050 | if (skb == NULL) | 1259 | if (skb == NULL) |
1051 | return; | 1260 | return; |
1052 | info = IEEE80211_SKB_CB(skb); | 1261 | info = IEEE80211_SKB_CB(skb); |
1053 | if (rctbl) | 1262 | if (hw->flags & IEEE80211_HW_SUPPORTS_RC_TABLE) |
1054 | ieee80211_get_tx_rates(vif, NULL, skb, | 1263 | ieee80211_get_tx_rates(vif, NULL, skb, |
1055 | info->control.rates, | 1264 | info->control.rates, |
1056 | ARRAY_SIZE(info->control.rates)); | 1265 | ARRAY_SIZE(info->control.rates)); |
@@ -1141,7 +1350,7 @@ static int mac80211_hwsim_config(struct ieee80211_hw *hw, u32 changed) | |||
1141 | 1350 | ||
1142 | data->channel = conf->chandef.chan; | 1351 | data->channel = conf->chandef.chan; |
1143 | 1352 | ||
1144 | WARN_ON(data->channel && channels > 1); | 1353 | WARN_ON(data->channel && data->channels > 1); |
1145 | 1354 | ||
1146 | data->power_level = conf->power_level; | 1355 | data->power_level = conf->power_level; |
1147 | if (!data->started || !data->beacon_int) | 1356 | if (!data->started || !data->beacon_int) |
@@ -1388,8 +1597,6 @@ static const struct nla_policy hwsim_testmode_policy[HWSIM_TM_ATTR_MAX + 1] = { | |||
1388 | [HWSIM_TM_ATTR_PS] = { .type = NLA_U32 }, | 1597 | [HWSIM_TM_ATTR_PS] = { .type = NLA_U32 }, |
1389 | }; | 1598 | }; |
1390 | 1599 | ||
1391 | static int hwsim_fops_ps_write(void *dat, u64 val); | ||
1392 | |||
1393 | static int mac80211_hwsim_testmode_cmd(struct ieee80211_hw *hw, | 1600 | static int mac80211_hwsim_testmode_cmd(struct ieee80211_hw *hw, |
1394 | struct ieee80211_vif *vif, | 1601 | struct ieee80211_vif *vif, |
1395 | void *data, int len) | 1602 | void *data, int len) |
@@ -1700,8 +1907,7 @@ static void mac80211_hwsim_unassign_vif_chanctx(struct ieee80211_hw *hw, | |||
1700 | hwsim_check_chanctx_magic(ctx); | 1907 | hwsim_check_chanctx_magic(ctx); |
1701 | } | 1908 | } |
1702 | 1909 | ||
1703 | static struct ieee80211_ops mac80211_hwsim_ops = | 1910 | static const struct ieee80211_ops mac80211_hwsim_ops = { |
1704 | { | ||
1705 | .tx = mac80211_hwsim_tx, | 1911 | .tx = mac80211_hwsim_tx, |
1706 | .start = mac80211_hwsim_start, | 1912 | .start = mac80211_hwsim_start, |
1707 | .stop = mac80211_hwsim_stop, | 1913 | .stop = mac80211_hwsim_stop, |
@@ -1726,217 +1932,290 @@ static struct ieee80211_ops mac80211_hwsim_ops = | |||
1726 | .set_tsf = mac80211_hwsim_set_tsf, | 1932 | .set_tsf = mac80211_hwsim_set_tsf, |
1727 | }; | 1933 | }; |
1728 | 1934 | ||
1935 | static struct ieee80211_ops mac80211_hwsim_mchan_ops; | ||
1729 | 1936 | ||
1730 | static void mac80211_hwsim_free(void) | 1937 | static int mac80211_hwsim_create_radio(int channels, const char *reg_alpha2, |
1938 | const struct ieee80211_regdomain *regd, | ||
1939 | bool reg_strict) | ||
1731 | { | 1940 | { |
1732 | struct list_head tmplist, *i, *tmp; | 1941 | int err; |
1733 | struct mac80211_hwsim_data *data, *tmpdata; | 1942 | u8 addr[ETH_ALEN]; |
1734 | 1943 | struct mac80211_hwsim_data *data; | |
1735 | INIT_LIST_HEAD(&tmplist); | 1944 | struct ieee80211_hw *hw; |
1945 | enum ieee80211_band band; | ||
1946 | const struct ieee80211_ops *ops = &mac80211_hwsim_ops; | ||
1947 | int idx; | ||
1736 | 1948 | ||
1737 | spin_lock_bh(&hwsim_radio_lock); | 1949 | spin_lock_bh(&hwsim_radio_lock); |
1738 | list_for_each_safe(i, tmp, &hwsim_radios) | 1950 | idx = hwsim_radio_idx++; |
1739 | list_move(i, &tmplist); | ||
1740 | spin_unlock_bh(&hwsim_radio_lock); | 1951 | spin_unlock_bh(&hwsim_radio_lock); |
1741 | 1952 | ||
1742 | list_for_each_entry_safe(data, tmpdata, &tmplist, list) { | 1953 | if (channels > 1) |
1743 | debugfs_remove_recursive(data->debugfs); | 1954 | ops = &mac80211_hwsim_mchan_ops; |
1744 | ieee80211_unregister_hw(data->hw); | 1955 | hw = ieee80211_alloc_hw(sizeof(*data), ops); |
1745 | device_release_driver(data->dev); | 1956 | if (!hw) { |
1746 | device_unregister(data->dev); | 1957 | printk(KERN_DEBUG "mac80211_hwsim: ieee80211_alloc_hw failed\n"); |
1747 | ieee80211_free_hw(data->hw); | 1958 | err = -ENOMEM; |
1959 | goto failed; | ||
1960 | } | ||
1961 | data = hw->priv; | ||
1962 | data->hw = hw; | ||
1963 | |||
1964 | data->dev = device_create(hwsim_class, NULL, 0, hw, "hwsim%d", idx); | ||
1965 | if (IS_ERR(data->dev)) { | ||
1966 | printk(KERN_DEBUG | ||
1967 | "mac80211_hwsim: device_create failed (%ld)\n", | ||
1968 | PTR_ERR(data->dev)); | ||
1969 | err = -ENOMEM; | ||
1970 | goto failed_drvdata; | ||
1971 | } | ||
1972 | data->dev->driver = &mac80211_hwsim_driver.driver; | ||
1973 | err = device_bind_driver(data->dev); | ||
1974 | if (err != 0) { | ||
1975 | printk(KERN_DEBUG "mac80211_hwsim: device_bind_driver failed (%d)\n", | ||
1976 | err); | ||
1977 | goto failed_hw; | ||
1748 | } | 1978 | } |
1749 | class_destroy(hwsim_class); | ||
1750 | } | ||
1751 | |||
1752 | static struct platform_driver mac80211_hwsim_driver = { | ||
1753 | .driver = { | ||
1754 | .name = "mac80211_hwsim", | ||
1755 | .owner = THIS_MODULE, | ||
1756 | }, | ||
1757 | }; | ||
1758 | |||
1759 | static const struct net_device_ops hwsim_netdev_ops = { | ||
1760 | .ndo_start_xmit = hwsim_mon_xmit, | ||
1761 | .ndo_change_mtu = eth_change_mtu, | ||
1762 | .ndo_set_mac_address = eth_mac_addr, | ||
1763 | .ndo_validate_addr = eth_validate_addr, | ||
1764 | }; | ||
1765 | |||
1766 | static void hwsim_mon_setup(struct net_device *dev) | ||
1767 | { | ||
1768 | dev->netdev_ops = &hwsim_netdev_ops; | ||
1769 | dev->destructor = free_netdev; | ||
1770 | ether_setup(dev); | ||
1771 | dev->tx_queue_len = 0; | ||
1772 | dev->type = ARPHRD_IEEE80211_RADIOTAP; | ||
1773 | memset(dev->dev_addr, 0, ETH_ALEN); | ||
1774 | dev->dev_addr[0] = 0x12; | ||
1775 | } | ||
1776 | 1979 | ||
1980 | skb_queue_head_init(&data->pending); | ||
1777 | 1981 | ||
1778 | static void hwsim_send_ps_poll(void *dat, u8 *mac, struct ieee80211_vif *vif) | 1982 | SET_IEEE80211_DEV(hw, data->dev); |
1779 | { | 1983 | memset(addr, 0, ETH_ALEN); |
1780 | struct mac80211_hwsim_data *data = dat; | 1984 | addr[0] = 0x02; |
1781 | struct hwsim_vif_priv *vp = (void *)vif->drv_priv; | 1985 | addr[3] = idx >> 8; |
1782 | struct sk_buff *skb; | 1986 | addr[4] = idx; |
1783 | struct ieee80211_pspoll *pspoll; | 1987 | memcpy(data->addresses[0].addr, addr, ETH_ALEN); |
1988 | memcpy(data->addresses[1].addr, addr, ETH_ALEN); | ||
1989 | data->addresses[1].addr[0] |= 0x40; | ||
1990 | hw->wiphy->n_addresses = 2; | ||
1991 | hw->wiphy->addresses = data->addresses; | ||
1992 | |||
1993 | data->channels = channels; | ||
1994 | data->idx = idx; | ||
1995 | |||
1996 | if (data->channels > 1) { | ||
1997 | hw->wiphy->max_scan_ssids = 255; | ||
1998 | hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; | ||
1999 | hw->wiphy->max_remain_on_channel_duration = 1000; | ||
2000 | /* For channels > 1 DFS is not allowed */ | ||
2001 | hw->wiphy->n_iface_combinations = 1; | ||
2002 | hw->wiphy->iface_combinations = &data->if_combination; | ||
2003 | data->if_combination = hwsim_if_comb[0]; | ||
2004 | data->if_combination.num_different_channels = data->channels; | ||
2005 | } else { | ||
2006 | hw->wiphy->iface_combinations = hwsim_if_comb; | ||
2007 | hw->wiphy->n_iface_combinations = ARRAY_SIZE(hwsim_if_comb); | ||
2008 | } | ||
1784 | 2009 | ||
1785 | if (!vp->assoc) | 2010 | INIT_DELAYED_WORK(&data->roc_done, hw_roc_done); |
1786 | return; | 2011 | INIT_DELAYED_WORK(&data->hw_scan, hw_scan_work); |
2012 | |||
2013 | hw->queues = 5; | ||
2014 | hw->offchannel_tx_hw_queue = 4; | ||
2015 | hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | | ||
2016 | BIT(NL80211_IFTYPE_AP) | | ||
2017 | BIT(NL80211_IFTYPE_P2P_CLIENT) | | ||
2018 | BIT(NL80211_IFTYPE_P2P_GO) | | ||
2019 | BIT(NL80211_IFTYPE_ADHOC) | | ||
2020 | BIT(NL80211_IFTYPE_MESH_POINT) | | ||
2021 | BIT(NL80211_IFTYPE_P2P_DEVICE); | ||
2022 | |||
2023 | hw->flags = IEEE80211_HW_MFP_CAPABLE | | ||
2024 | IEEE80211_HW_SIGNAL_DBM | | ||
2025 | IEEE80211_HW_SUPPORTS_STATIC_SMPS | | ||
2026 | IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | | ||
2027 | IEEE80211_HW_AMPDU_AGGREGATION | | ||
2028 | IEEE80211_HW_WANT_MONITOR_VIF | | ||
2029 | IEEE80211_HW_QUEUE_CONTROL | | ||
2030 | IEEE80211_HW_SUPPORTS_HT_CCK_RATES; | ||
2031 | if (rctbl) | ||
2032 | hw->flags |= IEEE80211_HW_SUPPORTS_RC_TABLE; | ||
2033 | |||
2034 | hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS | | ||
2035 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL | | ||
2036 | WIPHY_FLAG_AP_UAPSD; | ||
2037 | hw->wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR; | ||
2038 | |||
2039 | /* ask mac80211 to reserve space for magic */ | ||
2040 | hw->vif_data_size = sizeof(struct hwsim_vif_priv); | ||
2041 | hw->sta_data_size = sizeof(struct hwsim_sta_priv); | ||
2042 | hw->chanctx_data_size = sizeof(struct hwsim_chanctx_priv); | ||
2043 | |||
2044 | memcpy(data->channels_2ghz, hwsim_channels_2ghz, | ||
2045 | sizeof(hwsim_channels_2ghz)); | ||
2046 | memcpy(data->channels_5ghz, hwsim_channels_5ghz, | ||
2047 | sizeof(hwsim_channels_5ghz)); | ||
2048 | memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates)); | ||
2049 | |||
2050 | for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) { | ||
2051 | struct ieee80211_supported_band *sband = &data->bands[band]; | ||
2052 | switch (band) { | ||
2053 | case IEEE80211_BAND_2GHZ: | ||
2054 | sband->channels = data->channels_2ghz; | ||
2055 | sband->n_channels = ARRAY_SIZE(hwsim_channels_2ghz); | ||
2056 | sband->bitrates = data->rates; | ||
2057 | sband->n_bitrates = ARRAY_SIZE(hwsim_rates); | ||
2058 | break; | ||
2059 | case IEEE80211_BAND_5GHZ: | ||
2060 | sband->channels = data->channels_5ghz; | ||
2061 | sband->n_channels = ARRAY_SIZE(hwsim_channels_5ghz); | ||
2062 | sband->bitrates = data->rates + 4; | ||
2063 | sband->n_bitrates = ARRAY_SIZE(hwsim_rates) - 4; | ||
2064 | break; | ||
2065 | default: | ||
2066 | continue; | ||
2067 | } | ||
1787 | 2068 | ||
1788 | wiphy_debug(data->hw->wiphy, | 2069 | sband->ht_cap.ht_supported = true; |
1789 | "%s: send PS-Poll to %pM for aid %d\n", | 2070 | sband->ht_cap.cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | |
1790 | __func__, vp->bssid, vp->aid); | 2071 | IEEE80211_HT_CAP_GRN_FLD | |
2072 | IEEE80211_HT_CAP_SGI_40 | | ||
2073 | IEEE80211_HT_CAP_DSSSCCK40; | ||
2074 | sband->ht_cap.ampdu_factor = 0x3; | ||
2075 | sband->ht_cap.ampdu_density = 0x6; | ||
2076 | memset(&sband->ht_cap.mcs, 0, | ||
2077 | sizeof(sband->ht_cap.mcs)); | ||
2078 | sband->ht_cap.mcs.rx_mask[0] = 0xff; | ||
2079 | sband->ht_cap.mcs.rx_mask[1] = 0xff; | ||
2080 | sband->ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; | ||
2081 | |||
2082 | hw->wiphy->bands[band] = sband; | ||
2083 | |||
2084 | sband->vht_cap.vht_supported = true; | ||
2085 | sband->vht_cap.cap = | ||
2086 | IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 | | ||
2087 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ | | ||
2088 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ | | ||
2089 | IEEE80211_VHT_CAP_RXLDPC | | ||
2090 | IEEE80211_VHT_CAP_SHORT_GI_80 | | ||
2091 | IEEE80211_VHT_CAP_SHORT_GI_160 | | ||
2092 | IEEE80211_VHT_CAP_TXSTBC | | ||
2093 | IEEE80211_VHT_CAP_RXSTBC_1 | | ||
2094 | IEEE80211_VHT_CAP_RXSTBC_2 | | ||
2095 | IEEE80211_VHT_CAP_RXSTBC_3 | | ||
2096 | IEEE80211_VHT_CAP_RXSTBC_4 | | ||
2097 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK; | ||
2098 | sband->vht_cap.vht_mcs.rx_mcs_map = | ||
2099 | cpu_to_le16(IEEE80211_VHT_MCS_SUPPORT_0_8 << 0 | | ||
2100 | IEEE80211_VHT_MCS_SUPPORT_0_8 << 2 | | ||
2101 | IEEE80211_VHT_MCS_SUPPORT_0_9 << 4 | | ||
2102 | IEEE80211_VHT_MCS_SUPPORT_0_8 << 6 | | ||
2103 | IEEE80211_VHT_MCS_SUPPORT_0_8 << 8 | | ||
2104 | IEEE80211_VHT_MCS_SUPPORT_0_9 << 10 | | ||
2105 | IEEE80211_VHT_MCS_SUPPORT_0_9 << 12 | | ||
2106 | IEEE80211_VHT_MCS_SUPPORT_0_8 << 14); | ||
2107 | sband->vht_cap.vht_mcs.tx_mcs_map = | ||
2108 | sband->vht_cap.vht_mcs.rx_mcs_map; | ||
2109 | } | ||
1791 | 2110 | ||
1792 | skb = dev_alloc_skb(sizeof(*pspoll)); | 2111 | /* By default all radios belong to the first group */ |
1793 | if (!skb) | 2112 | data->group = 1; |
1794 | return; | 2113 | mutex_init(&data->mutex); |
1795 | pspoll = (void *) skb_put(skb, sizeof(*pspoll)); | ||
1796 | pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | | ||
1797 | IEEE80211_STYPE_PSPOLL | | ||
1798 | IEEE80211_FCTL_PM); | ||
1799 | pspoll->aid = cpu_to_le16(0xc000 | vp->aid); | ||
1800 | memcpy(pspoll->bssid, vp->bssid, ETH_ALEN); | ||
1801 | memcpy(pspoll->ta, mac, ETH_ALEN); | ||
1802 | 2114 | ||
1803 | rcu_read_lock(); | 2115 | /* Enable frame retransmissions for lossy channels */ |
1804 | mac80211_hwsim_tx_frame(data->hw, skb, | 2116 | hw->max_rates = 4; |
1805 | rcu_dereference(vif->chanctx_conf)->def.chan); | 2117 | hw->max_rate_tries = 11; |
1806 | rcu_read_unlock(); | ||
1807 | } | ||
1808 | 2118 | ||
1809 | static void hwsim_send_nullfunc(struct mac80211_hwsim_data *data, u8 *mac, | 2119 | if (reg_strict) |
1810 | struct ieee80211_vif *vif, int ps) | 2120 | hw->wiphy->regulatory_flags |= REGULATORY_STRICT_REG; |
1811 | { | 2121 | if (regd) { |
1812 | struct hwsim_vif_priv *vp = (void *)vif->drv_priv; | 2122 | hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; |
1813 | struct sk_buff *skb; | 2123 | wiphy_apply_custom_regulatory(hw->wiphy, regd); |
1814 | struct ieee80211_hdr *hdr; | 2124 | /* give the regulatory workqueue a chance to run */ |
2125 | schedule_timeout_interruptible(1); | ||
2126 | } | ||
1815 | 2127 | ||
1816 | if (!vp->assoc) | 2128 | err = ieee80211_register_hw(hw); |
1817 | return; | 2129 | if (err < 0) { |
2130 | printk(KERN_DEBUG "mac80211_hwsim: ieee80211_register_hw failed (%d)\n", | ||
2131 | err); | ||
2132 | goto failed_hw; | ||
2133 | } | ||
1818 | 2134 | ||
1819 | wiphy_debug(data->hw->wiphy, | 2135 | wiphy_debug(hw->wiphy, "hwaddr %pM registered\n", hw->wiphy->perm_addr); |
1820 | "%s: send data::nullfunc to %pM ps=%d\n", | ||
1821 | __func__, vp->bssid, ps); | ||
1822 | 2136 | ||
1823 | skb = dev_alloc_skb(sizeof(*hdr)); | 2137 | if (reg_alpha2) |
1824 | if (!skb) | 2138 | regulatory_hint(hw->wiphy, reg_alpha2); |
1825 | return; | ||
1826 | hdr = (void *) skb_put(skb, sizeof(*hdr) - ETH_ALEN); | ||
1827 | hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | | ||
1828 | IEEE80211_STYPE_NULLFUNC | | ||
1829 | (ps ? IEEE80211_FCTL_PM : 0)); | ||
1830 | hdr->duration_id = cpu_to_le16(0); | ||
1831 | memcpy(hdr->addr1, vp->bssid, ETH_ALEN); | ||
1832 | memcpy(hdr->addr2, mac, ETH_ALEN); | ||
1833 | memcpy(hdr->addr3, vp->bssid, ETH_ALEN); | ||
1834 | 2139 | ||
1835 | rcu_read_lock(); | 2140 | data->debugfs = debugfs_create_dir("hwsim", hw->wiphy->debugfsdir); |
1836 | mac80211_hwsim_tx_frame(data->hw, skb, | 2141 | debugfs_create_file("ps", 0666, data->debugfs, data, &hwsim_fops_ps); |
1837 | rcu_dereference(vif->chanctx_conf)->def.chan); | 2142 | debugfs_create_file("group", 0666, data->debugfs, data, |
1838 | rcu_read_unlock(); | 2143 | &hwsim_fops_group); |
1839 | } | 2144 | if (data->channels == 1) |
2145 | debugfs_create_file("dfs_simulate_radar", 0222, | ||
2146 | data->debugfs, | ||
2147 | data, &hwsim_simulate_radar); | ||
1840 | 2148 | ||
2149 | tasklet_hrtimer_init(&data->beacon_timer, | ||
2150 | mac80211_hwsim_beacon, | ||
2151 | CLOCK_MONOTONIC_RAW, HRTIMER_MODE_ABS); | ||
1841 | 2152 | ||
1842 | static void hwsim_send_nullfunc_ps(void *dat, u8 *mac, | 2153 | spin_lock_bh(&hwsim_radio_lock); |
1843 | struct ieee80211_vif *vif) | 2154 | list_add_tail(&data->list, &hwsim_radios); |
1844 | { | 2155 | spin_unlock_bh(&hwsim_radio_lock); |
1845 | struct mac80211_hwsim_data *data = dat; | ||
1846 | hwsim_send_nullfunc(data, mac, vif, 1); | ||
1847 | } | ||
1848 | 2156 | ||
2157 | return idx; | ||
1849 | 2158 | ||
1850 | static void hwsim_send_nullfunc_no_ps(void *dat, u8 *mac, | 2159 | failed_hw: |
1851 | struct ieee80211_vif *vif) | 2160 | device_unregister(data->dev); |
1852 | { | 2161 | failed_drvdata: |
1853 | struct mac80211_hwsim_data *data = dat; | 2162 | ieee80211_free_hw(hw); |
1854 | hwsim_send_nullfunc(data, mac, vif, 0); | 2163 | failed: |
2164 | return err; | ||
1855 | } | 2165 | } |
1856 | 2166 | ||
1857 | 2167 | static void mac80211_hwsim_destroy_radio(struct mac80211_hwsim_data *data) | |
1858 | static int hwsim_fops_ps_read(void *dat, u64 *val) | ||
1859 | { | 2168 | { |
1860 | struct mac80211_hwsim_data *data = dat; | 2169 | debugfs_remove_recursive(data->debugfs); |
1861 | *val = data->ps; | 2170 | ieee80211_unregister_hw(data->hw); |
1862 | return 0; | 2171 | device_release_driver(data->dev); |
2172 | device_unregister(data->dev); | ||
2173 | ieee80211_free_hw(data->hw); | ||
1863 | } | 2174 | } |
1864 | 2175 | ||
1865 | static int hwsim_fops_ps_write(void *dat, u64 val) | 2176 | static void mac80211_hwsim_free(void) |
1866 | { | 2177 | { |
1867 | struct mac80211_hwsim_data *data = dat; | 2178 | struct mac80211_hwsim_data *data; |
1868 | enum ps_mode old_ps; | ||
1869 | |||
1870 | if (val != PS_DISABLED && val != PS_ENABLED && val != PS_AUTO_POLL && | ||
1871 | val != PS_MANUAL_POLL) | ||
1872 | return -EINVAL; | ||
1873 | |||
1874 | old_ps = data->ps; | ||
1875 | data->ps = val; | ||
1876 | 2179 | ||
1877 | if (val == PS_MANUAL_POLL) { | 2180 | spin_lock_bh(&hwsim_radio_lock); |
1878 | ieee80211_iterate_active_interfaces(data->hw, | 2181 | while ((data = list_first_entry_or_null(&hwsim_radios, |
1879 | IEEE80211_IFACE_ITER_NORMAL, | 2182 | struct mac80211_hwsim_data, |
1880 | hwsim_send_ps_poll, data); | 2183 | list))) { |
1881 | data->ps_poll_pending = true; | 2184 | list_del(&data->list); |
1882 | } else if (old_ps == PS_DISABLED && val != PS_DISABLED) { | 2185 | spin_unlock_bh(&hwsim_radio_lock); |
1883 | ieee80211_iterate_active_interfaces(data->hw, | 2186 | mac80211_hwsim_destroy_radio(data); |
1884 | IEEE80211_IFACE_ITER_NORMAL, | 2187 | spin_lock_bh(&hwsim_radio_lock); |
1885 | hwsim_send_nullfunc_ps, | ||
1886 | data); | ||
1887 | } else if (old_ps != PS_DISABLED && val == PS_DISABLED) { | ||
1888 | ieee80211_iterate_active_interfaces(data->hw, | ||
1889 | IEEE80211_IFACE_ITER_NORMAL, | ||
1890 | hwsim_send_nullfunc_no_ps, | ||
1891 | data); | ||
1892 | } | 2188 | } |
1893 | 2189 | spin_unlock_bh(&hwsim_radio_lock); | |
1894 | return 0; | 2190 | class_destroy(hwsim_class); |
1895 | } | ||
1896 | |||
1897 | DEFINE_SIMPLE_ATTRIBUTE(hwsim_fops_ps, hwsim_fops_ps_read, hwsim_fops_ps_write, | ||
1898 | "%llu\n"); | ||
1899 | |||
1900 | static int hwsim_write_simulate_radar(void *dat, u64 val) | ||
1901 | { | ||
1902 | struct mac80211_hwsim_data *data = dat; | ||
1903 | |||
1904 | ieee80211_radar_detected(data->hw); | ||
1905 | |||
1906 | return 0; | ||
1907 | } | 2191 | } |
1908 | 2192 | ||
1909 | DEFINE_SIMPLE_ATTRIBUTE(hwsim_simulate_radar, NULL, | 2193 | static const struct net_device_ops hwsim_netdev_ops = { |
1910 | hwsim_write_simulate_radar, "%llu\n"); | 2194 | .ndo_start_xmit = hwsim_mon_xmit, |
1911 | 2195 | .ndo_change_mtu = eth_change_mtu, | |
1912 | static int hwsim_fops_group_read(void *dat, u64 *val) | 2196 | .ndo_set_mac_address = eth_mac_addr, |
1913 | { | 2197 | .ndo_validate_addr = eth_validate_addr, |
1914 | struct mac80211_hwsim_data *data = dat; | 2198 | }; |
1915 | *val = data->group; | ||
1916 | return 0; | ||
1917 | } | ||
1918 | 2199 | ||
1919 | static int hwsim_fops_group_write(void *dat, u64 val) | 2200 | static void hwsim_mon_setup(struct net_device *dev) |
1920 | { | 2201 | { |
1921 | struct mac80211_hwsim_data *data = dat; | 2202 | dev->netdev_ops = &hwsim_netdev_ops; |
1922 | data->group = val; | 2203 | dev->destructor = free_netdev; |
1923 | return 0; | 2204 | ether_setup(dev); |
2205 | dev->tx_queue_len = 0; | ||
2206 | dev->type = ARPHRD_IEEE80211_RADIOTAP; | ||
2207 | memset(dev->dev_addr, 0, ETH_ALEN); | ||
2208 | dev->dev_addr[0] = 0x12; | ||
1924 | } | 2209 | } |
1925 | 2210 | ||
1926 | DEFINE_SIMPLE_ATTRIBUTE(hwsim_fops_group, | 2211 | static struct mac80211_hwsim_data *get_hwsim_data_ref_from_addr(const u8 *addr) |
1927 | hwsim_fops_group_read, hwsim_fops_group_write, | ||
1928 | "%llx\n"); | ||
1929 | |||
1930 | static struct mac80211_hwsim_data *get_hwsim_data_ref_from_addr( | ||
1931 | struct mac_address *addr) | ||
1932 | { | 2212 | { |
1933 | struct mac80211_hwsim_data *data; | 2213 | struct mac80211_hwsim_data *data; |
1934 | bool _found = false; | 2214 | bool _found = false; |
1935 | 2215 | ||
1936 | spin_lock_bh(&hwsim_radio_lock); | 2216 | spin_lock_bh(&hwsim_radio_lock); |
1937 | list_for_each_entry(data, &hwsim_radios, list) { | 2217 | list_for_each_entry(data, &hwsim_radios, list) { |
1938 | if (memcmp(data->addresses[1].addr, addr, | 2218 | if (memcmp(data->addresses[1].addr, addr, ETH_ALEN) == 0) { |
1939 | sizeof(struct mac_address)) == 0) { | ||
1940 | _found = true; | 2219 | _found = true; |
1941 | break; | 2220 | break; |
1942 | } | 2221 | } |
@@ -1959,27 +2238,26 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, | |||
1959 | struct hwsim_tx_rate *tx_attempts; | 2238 | struct hwsim_tx_rate *tx_attempts; |
1960 | unsigned long ret_skb_ptr; | 2239 | unsigned long ret_skb_ptr; |
1961 | struct sk_buff *skb, *tmp; | 2240 | struct sk_buff *skb, *tmp; |
1962 | struct mac_address *src; | 2241 | const u8 *src; |
1963 | unsigned int hwsim_flags; | 2242 | unsigned int hwsim_flags; |
1964 | |||
1965 | int i; | 2243 | int i; |
1966 | bool found = false; | 2244 | bool found = false; |
1967 | 2245 | ||
2246 | if (info->snd_portid != wmediumd_portid) | ||
2247 | return -EINVAL; | ||
2248 | |||
1968 | if (!info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER] || | 2249 | if (!info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER] || |
1969 | !info->attrs[HWSIM_ATTR_FLAGS] || | 2250 | !info->attrs[HWSIM_ATTR_FLAGS] || |
1970 | !info->attrs[HWSIM_ATTR_COOKIE] || | 2251 | !info->attrs[HWSIM_ATTR_COOKIE] || |
1971 | !info->attrs[HWSIM_ATTR_TX_INFO]) | 2252 | !info->attrs[HWSIM_ATTR_TX_INFO]) |
1972 | goto out; | 2253 | goto out; |
1973 | 2254 | ||
1974 | src = (struct mac_address *)nla_data( | 2255 | src = (void *)nla_data(info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER]); |
1975 | info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER]); | ||
1976 | hwsim_flags = nla_get_u32(info->attrs[HWSIM_ATTR_FLAGS]); | 2256 | hwsim_flags = nla_get_u32(info->attrs[HWSIM_ATTR_FLAGS]); |
1977 | |||
1978 | ret_skb_ptr = nla_get_u64(info->attrs[HWSIM_ATTR_COOKIE]); | 2257 | ret_skb_ptr = nla_get_u64(info->attrs[HWSIM_ATTR_COOKIE]); |
1979 | 2258 | ||
1980 | data2 = get_hwsim_data_ref_from_addr(src); | 2259 | data2 = get_hwsim_data_ref_from_addr(src); |
1981 | 2260 | if (!data2) | |
1982 | if (data2 == NULL) | ||
1983 | goto out; | 2261 | goto out; |
1984 | 2262 | ||
1985 | /* look for the skb matching the cookie passed back from user */ | 2263 | /* look for the skb matching the cookie passed back from user */ |
@@ -2036,38 +2314,37 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2, | |||
2036 | 2314 | ||
2037 | struct mac80211_hwsim_data *data2; | 2315 | struct mac80211_hwsim_data *data2; |
2038 | struct ieee80211_rx_status rx_status; | 2316 | struct ieee80211_rx_status rx_status; |
2039 | struct mac_address *dst; | 2317 | const u8 *dst; |
2040 | int frame_data_len; | 2318 | int frame_data_len; |
2041 | char *frame_data; | 2319 | void *frame_data; |
2042 | struct sk_buff *skb = NULL; | 2320 | struct sk_buff *skb = NULL; |
2043 | 2321 | ||
2322 | if (info->snd_portid != wmediumd_portid) | ||
2323 | return -EINVAL; | ||
2324 | |||
2044 | if (!info->attrs[HWSIM_ATTR_ADDR_RECEIVER] || | 2325 | if (!info->attrs[HWSIM_ATTR_ADDR_RECEIVER] || |
2045 | !info->attrs[HWSIM_ATTR_FRAME] || | 2326 | !info->attrs[HWSIM_ATTR_FRAME] || |
2046 | !info->attrs[HWSIM_ATTR_RX_RATE] || | 2327 | !info->attrs[HWSIM_ATTR_RX_RATE] || |
2047 | !info->attrs[HWSIM_ATTR_SIGNAL]) | 2328 | !info->attrs[HWSIM_ATTR_SIGNAL]) |
2048 | goto out; | 2329 | goto out; |
2049 | 2330 | ||
2050 | dst = (struct mac_address *)nla_data( | 2331 | dst = (void *)nla_data(info->attrs[HWSIM_ATTR_ADDR_RECEIVER]); |
2051 | info->attrs[HWSIM_ATTR_ADDR_RECEIVER]); | ||
2052 | |||
2053 | frame_data_len = nla_len(info->attrs[HWSIM_ATTR_FRAME]); | 2332 | frame_data_len = nla_len(info->attrs[HWSIM_ATTR_FRAME]); |
2054 | frame_data = (char *)nla_data(info->attrs[HWSIM_ATTR_FRAME]); | 2333 | frame_data = (void *)nla_data(info->attrs[HWSIM_ATTR_FRAME]); |
2055 | 2334 | ||
2056 | /* Allocate new skb here */ | 2335 | /* Allocate new skb here */ |
2057 | skb = alloc_skb(frame_data_len, GFP_KERNEL); | 2336 | skb = alloc_skb(frame_data_len, GFP_KERNEL); |
2058 | if (skb == NULL) | 2337 | if (skb == NULL) |
2059 | goto err; | 2338 | goto err; |
2060 | 2339 | ||
2061 | if (frame_data_len <= IEEE80211_MAX_DATA_LEN) { | 2340 | if (frame_data_len > IEEE80211_MAX_DATA_LEN) |
2062 | /* Copy the data */ | ||
2063 | memcpy(skb_put(skb, frame_data_len), frame_data, | ||
2064 | frame_data_len); | ||
2065 | } else | ||
2066 | goto err; | 2341 | goto err; |
2067 | 2342 | ||
2068 | data2 = get_hwsim_data_ref_from_addr(dst); | 2343 | /* Copy the data */ |
2344 | memcpy(skb_put(skb, frame_data_len), frame_data, frame_data_len); | ||
2069 | 2345 | ||
2070 | if (data2 == NULL) | 2346 | data2 = get_hwsim_data_ref_from_addr(dst); |
2347 | if (!data2) | ||
2071 | goto out; | 2348 | goto out; |
2072 | 2349 | ||
2073 | /* check if radio is configured properly */ | 2350 | /* check if radio is configured properly */ |
@@ -2075,7 +2352,7 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2, | |||
2075 | if (data2->idle || !data2->started) | 2352 | if (data2->idle || !data2->started) |
2076 | goto out; | 2353 | goto out; |
2077 | 2354 | ||
2078 | /*A frame is received from user space*/ | 2355 | /* A frame is received from user space */ |
2079 | memset(&rx_status, 0, sizeof(rx_status)); | 2356 | memset(&rx_status, 0, sizeof(rx_status)); |
2080 | rx_status.freq = data2->channel->center_freq; | 2357 | rx_status.freq = data2->channel->center_freq; |
2081 | rx_status.band = data2->channel->band; | 2358 | rx_status.band = data2->channel->band; |
@@ -2097,8 +2374,24 @@ out: | |||
2097 | static int hwsim_register_received_nl(struct sk_buff *skb_2, | 2374 | static int hwsim_register_received_nl(struct sk_buff *skb_2, |
2098 | struct genl_info *info) | 2375 | struct genl_info *info) |
2099 | { | 2376 | { |
2100 | if (info == NULL) | 2377 | struct mac80211_hwsim_data *data; |
2101 | goto out; | 2378 | int chans = 1; |
2379 | |||
2380 | spin_lock_bh(&hwsim_radio_lock); | ||
2381 | list_for_each_entry(data, &hwsim_radios, list) | ||
2382 | chans = max(chans, data->channels); | ||
2383 | spin_unlock_bh(&hwsim_radio_lock); | ||
2384 | |||
2385 | /* In the future we should revise the userspace API and allow it | ||
2386 | * to set a flag that it does support multi-channel, then we can | ||
2387 | * let this pass conditionally on the flag. | ||
2388 | * For current userspace, prohibit it since it won't work right. | ||
2389 | */ | ||
2390 | if (chans > 1) | ||
2391 | return -EOPNOTSUPP; | ||
2392 | |||
2393 | if (wmediumd_portid) | ||
2394 | return -EBUSY; | ||
2102 | 2395 | ||
2103 | wmediumd_portid = info->snd_portid; | 2396 | wmediumd_portid = info->snd_portid; |
2104 | 2397 | ||
@@ -2106,9 +2399,53 @@ static int hwsim_register_received_nl(struct sk_buff *skb_2, | |||
2106 | "switching to wmediumd mode with pid %d\n", info->snd_portid); | 2399 | "switching to wmediumd mode with pid %d\n", info->snd_portid); |
2107 | 2400 | ||
2108 | return 0; | 2401 | return 0; |
2109 | out: | 2402 | } |
2110 | printk(KERN_DEBUG "mac80211_hwsim: error occurred in %s\n", __func__); | 2403 | |
2111 | return -EINVAL; | 2404 | static int hwsim_create_radio_nl(struct sk_buff *msg, struct genl_info *info) |
2405 | { | ||
2406 | unsigned int chans = channels; | ||
2407 | const char *alpha2 = NULL; | ||
2408 | const struct ieee80211_regdomain *regd = NULL; | ||
2409 | bool reg_strict = info->attrs[HWSIM_ATTR_REG_STRICT_REG]; | ||
2410 | |||
2411 | if (info->attrs[HWSIM_ATTR_CHANNELS]) | ||
2412 | chans = nla_get_u32(info->attrs[HWSIM_ATTR_CHANNELS]); | ||
2413 | |||
2414 | if (info->attrs[HWSIM_ATTR_REG_HINT_ALPHA2]) | ||
2415 | alpha2 = nla_data(info->attrs[HWSIM_ATTR_REG_HINT_ALPHA2]); | ||
2416 | |||
2417 | if (info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]) { | ||
2418 | u32 idx = nla_get_u32(info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]); | ||
2419 | |||
2420 | if (idx >= ARRAY_SIZE(hwsim_world_regdom_custom)) | ||
2421 | return -EINVAL; | ||
2422 | regd = hwsim_world_regdom_custom[idx]; | ||
2423 | } | ||
2424 | |||
2425 | return mac80211_hwsim_create_radio(chans, alpha2, regd, reg_strict); | ||
2426 | } | ||
2427 | |||
2428 | static int hwsim_destroy_radio_nl(struct sk_buff *msg, struct genl_info *info) | ||
2429 | { | ||
2430 | struct mac80211_hwsim_data *data; | ||
2431 | int idx; | ||
2432 | |||
2433 | if (!info->attrs[HWSIM_ATTR_RADIO_ID]) | ||
2434 | return -EINVAL; | ||
2435 | idx = nla_get_u32(info->attrs[HWSIM_ATTR_RADIO_ID]); | ||
2436 | |||
2437 | spin_lock_bh(&hwsim_radio_lock); | ||
2438 | list_for_each_entry(data, &hwsim_radios, list) { | ||
2439 | if (data->idx != idx) | ||
2440 | continue; | ||
2441 | list_del(&data->list); | ||
2442 | spin_unlock_bh(&hwsim_radio_lock); | ||
2443 | mac80211_hwsim_destroy_radio(data); | ||
2444 | return 0; | ||
2445 | } | ||
2446 | spin_unlock_bh(&hwsim_radio_lock); | ||
2447 | |||
2448 | return -ENODEV; | ||
2112 | } | 2449 | } |
2113 | 2450 | ||
2114 | /* Generic Netlink operations array */ | 2451 | /* Generic Netlink operations array */ |
@@ -2129,6 +2466,18 @@ static const struct genl_ops hwsim_ops[] = { | |||
2129 | .policy = hwsim_genl_policy, | 2466 | .policy = hwsim_genl_policy, |
2130 | .doit = hwsim_tx_info_frame_received_nl, | 2467 | .doit = hwsim_tx_info_frame_received_nl, |
2131 | }, | 2468 | }, |
2469 | { | ||
2470 | .cmd = HWSIM_CMD_CREATE_RADIO, | ||
2471 | .policy = hwsim_genl_policy, | ||
2472 | .doit = hwsim_create_radio_nl, | ||
2473 | .flags = GENL_ADMIN_PERM, | ||
2474 | }, | ||
2475 | { | ||
2476 | .cmd = HWSIM_CMD_DESTROY_RADIO, | ||
2477 | .policy = hwsim_genl_policy, | ||
2478 | .doit = hwsim_destroy_radio_nl, | ||
2479 | .flags = GENL_ADMIN_PERM, | ||
2480 | }, | ||
2132 | }; | 2481 | }; |
2133 | 2482 | ||
2134 | static int mac80211_hwsim_netlink_notify(struct notifier_block *nb, | 2483 | static int mac80211_hwsim_netlink_notify(struct notifier_block *nb, |
@@ -2157,10 +2506,6 @@ static int hwsim_init_netlink(void) | |||
2157 | { | 2506 | { |
2158 | int rc; | 2507 | int rc; |
2159 | 2508 | ||
2160 | /* userspace test API hasn't been adjusted for multi-channel */ | ||
2161 | if (channels > 1) | ||
2162 | return 0; | ||
2163 | |||
2164 | printk(KERN_INFO "mac80211_hwsim: initializing netlink\n"); | 2509 | printk(KERN_INFO "mac80211_hwsim: initializing netlink\n"); |
2165 | 2510 | ||
2166 | rc = genl_register_family_with_ops(&hwsim_genl_family, hwsim_ops); | 2511 | rc = genl_register_family_with_ops(&hwsim_genl_family, hwsim_ops); |
@@ -2180,94 +2525,36 @@ failure: | |||
2180 | 2525 | ||
2181 | static void hwsim_exit_netlink(void) | 2526 | static void hwsim_exit_netlink(void) |
2182 | { | 2527 | { |
2183 | int ret; | ||
2184 | |||
2185 | /* userspace test API hasn't been adjusted for multi-channel */ | ||
2186 | if (channels > 1) | ||
2187 | return; | ||
2188 | |||
2189 | printk(KERN_INFO "mac80211_hwsim: closing netlink\n"); | ||
2190 | /* unregister the notifier */ | 2528 | /* unregister the notifier */ |
2191 | netlink_unregister_notifier(&hwsim_netlink_notifier); | 2529 | netlink_unregister_notifier(&hwsim_netlink_notifier); |
2192 | /* unregister the family */ | 2530 | /* unregister the family */ |
2193 | ret = genl_unregister_family(&hwsim_genl_family); | 2531 | genl_unregister_family(&hwsim_genl_family); |
2194 | if (ret) | ||
2195 | printk(KERN_DEBUG "mac80211_hwsim: " | ||
2196 | "unregister family %i\n", ret); | ||
2197 | } | 2532 | } |
2198 | 2533 | ||
2199 | static const struct ieee80211_iface_limit hwsim_if_limits[] = { | ||
2200 | { .max = 1, .types = BIT(NL80211_IFTYPE_ADHOC) }, | ||
2201 | { .max = 2048, .types = BIT(NL80211_IFTYPE_STATION) | | ||
2202 | BIT(NL80211_IFTYPE_P2P_CLIENT) | | ||
2203 | #ifdef CONFIG_MAC80211_MESH | ||
2204 | BIT(NL80211_IFTYPE_MESH_POINT) | | ||
2205 | #endif | ||
2206 | BIT(NL80211_IFTYPE_AP) | | ||
2207 | BIT(NL80211_IFTYPE_P2P_GO) }, | ||
2208 | { .max = 1, .types = BIT(NL80211_IFTYPE_P2P_DEVICE) }, | ||
2209 | }; | ||
2210 | |||
2211 | static const struct ieee80211_iface_limit hwsim_if_dfs_limits[] = { | ||
2212 | { .max = 8, .types = BIT(NL80211_IFTYPE_AP) }, | ||
2213 | }; | ||
2214 | |||
2215 | static struct ieee80211_iface_combination hwsim_if_comb[] = { | ||
2216 | { | ||
2217 | .limits = hwsim_if_limits, | ||
2218 | .n_limits = ARRAY_SIZE(hwsim_if_limits), | ||
2219 | .max_interfaces = 2048, | ||
2220 | .num_different_channels = 1, | ||
2221 | }, | ||
2222 | { | ||
2223 | .limits = hwsim_if_dfs_limits, | ||
2224 | .n_limits = ARRAY_SIZE(hwsim_if_dfs_limits), | ||
2225 | .max_interfaces = 8, | ||
2226 | .num_different_channels = 1, | ||
2227 | .radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) | | ||
2228 | BIT(NL80211_CHAN_WIDTH_20) | | ||
2229 | BIT(NL80211_CHAN_WIDTH_40) | | ||
2230 | BIT(NL80211_CHAN_WIDTH_80) | | ||
2231 | BIT(NL80211_CHAN_WIDTH_160), | ||
2232 | } | ||
2233 | }; | ||
2234 | |||
2235 | static int __init init_mac80211_hwsim(void) | 2534 | static int __init init_mac80211_hwsim(void) |
2236 | { | 2535 | { |
2237 | int i, err = 0; | 2536 | int i, err; |
2238 | u8 addr[ETH_ALEN]; | ||
2239 | struct mac80211_hwsim_data *data; | ||
2240 | struct ieee80211_hw *hw; | ||
2241 | enum ieee80211_band band; | ||
2242 | 2537 | ||
2243 | if (radios < 1 || radios > 100) | 2538 | if (radios < 0 || radios > 100) |
2244 | return -EINVAL; | 2539 | return -EINVAL; |
2245 | 2540 | ||
2246 | if (channels < 1) | 2541 | if (channels < 1) |
2247 | return -EINVAL; | 2542 | return -EINVAL; |
2248 | 2543 | ||
2249 | if (channels > 1) { | 2544 | mac80211_hwsim_mchan_ops = mac80211_hwsim_ops; |
2250 | hwsim_if_comb[0].num_different_channels = channels; | 2545 | mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan; |
2251 | mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan; | 2546 | mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan; |
2252 | mac80211_hwsim_ops.cancel_hw_scan = | 2547 | mac80211_hwsim_mchan_ops.sw_scan_start = NULL; |
2253 | mac80211_hwsim_cancel_hw_scan; | 2548 | mac80211_hwsim_mchan_ops.sw_scan_complete = NULL; |
2254 | mac80211_hwsim_ops.sw_scan_start = NULL; | 2549 | mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc; |
2255 | mac80211_hwsim_ops.sw_scan_complete = NULL; | 2550 | mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc; |
2256 | mac80211_hwsim_ops.remain_on_channel = | 2551 | mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx; |
2257 | mac80211_hwsim_roc; | 2552 | mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx; |
2258 | mac80211_hwsim_ops.cancel_remain_on_channel = | 2553 | mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx; |
2259 | mac80211_hwsim_croc; | 2554 | mac80211_hwsim_mchan_ops.assign_vif_chanctx = |
2260 | mac80211_hwsim_ops.add_chanctx = | 2555 | mac80211_hwsim_assign_vif_chanctx; |
2261 | mac80211_hwsim_add_chanctx; | 2556 | mac80211_hwsim_mchan_ops.unassign_vif_chanctx = |
2262 | mac80211_hwsim_ops.remove_chanctx = | 2557 | mac80211_hwsim_unassign_vif_chanctx; |
2263 | mac80211_hwsim_remove_chanctx; | ||
2264 | mac80211_hwsim_ops.change_chanctx = | ||
2265 | mac80211_hwsim_change_chanctx; | ||
2266 | mac80211_hwsim_ops.assign_vif_chanctx = | ||
2267 | mac80211_hwsim_assign_vif_chanctx; | ||
2268 | mac80211_hwsim_ops.unassign_vif_chanctx = | ||
2269 | mac80211_hwsim_unassign_vif_chanctx; | ||
2270 | } | ||
2271 | 2558 | ||
2272 | spin_lock_init(&hwsim_radio_lock); | 2559 | spin_lock_init(&hwsim_radio_lock); |
2273 | INIT_LIST_HEAD(&hwsim_radios); | 2560 | INIT_LIST_HEAD(&hwsim_radios); |
@@ -2279,361 +2566,116 @@ static int __init init_mac80211_hwsim(void) | |||
2279 | hwsim_class = class_create(THIS_MODULE, "mac80211_hwsim"); | 2566 | hwsim_class = class_create(THIS_MODULE, "mac80211_hwsim"); |
2280 | if (IS_ERR(hwsim_class)) { | 2567 | if (IS_ERR(hwsim_class)) { |
2281 | err = PTR_ERR(hwsim_class); | 2568 | err = PTR_ERR(hwsim_class); |
2282 | goto failed_unregister_driver; | 2569 | goto out_unregister_driver; |
2283 | } | 2570 | } |
2284 | 2571 | ||
2285 | memset(addr, 0, ETH_ALEN); | ||
2286 | addr[0] = 0x02; | ||
2287 | |||
2288 | for (i = 0; i < radios; i++) { | 2572 | for (i = 0; i < radios; i++) { |
2289 | printk(KERN_DEBUG "mac80211_hwsim: Initializing radio %d\n", | 2573 | const char *reg_alpha2 = NULL; |
2290 | i); | 2574 | const struct ieee80211_regdomain *regd = NULL; |
2291 | hw = ieee80211_alloc_hw(sizeof(*data), &mac80211_hwsim_ops); | 2575 | bool reg_strict = false; |
2292 | if (!hw) { | ||
2293 | printk(KERN_DEBUG "mac80211_hwsim: ieee80211_alloc_hw " | ||
2294 | "failed\n"); | ||
2295 | err = -ENOMEM; | ||
2296 | goto failed; | ||
2297 | } | ||
2298 | data = hw->priv; | ||
2299 | data->hw = hw; | ||
2300 | |||
2301 | data->dev = device_create(hwsim_class, NULL, 0, hw, | ||
2302 | "hwsim%d", i); | ||
2303 | if (IS_ERR(data->dev)) { | ||
2304 | printk(KERN_DEBUG | ||
2305 | "mac80211_hwsim: device_create failed (%ld)\n", | ||
2306 | PTR_ERR(data->dev)); | ||
2307 | err = -ENOMEM; | ||
2308 | goto failed_drvdata; | ||
2309 | } | ||
2310 | data->dev->driver = &mac80211_hwsim_driver.driver; | ||
2311 | err = device_bind_driver(data->dev); | ||
2312 | if (err != 0) { | ||
2313 | printk(KERN_DEBUG | ||
2314 | "mac80211_hwsim: device_bind_driver failed (%d)\n", | ||
2315 | err); | ||
2316 | goto failed_hw; | ||
2317 | } | ||
2318 | |||
2319 | skb_queue_head_init(&data->pending); | ||
2320 | |||
2321 | SET_IEEE80211_DEV(hw, data->dev); | ||
2322 | addr[3] = i >> 8; | ||
2323 | addr[4] = i; | ||
2324 | memcpy(data->addresses[0].addr, addr, ETH_ALEN); | ||
2325 | memcpy(data->addresses[1].addr, addr, ETH_ALEN); | ||
2326 | data->addresses[1].addr[0] |= 0x40; | ||
2327 | hw->wiphy->n_addresses = 2; | ||
2328 | hw->wiphy->addresses = data->addresses; | ||
2329 | |||
2330 | hw->wiphy->iface_combinations = hwsim_if_comb; | ||
2331 | hw->wiphy->n_iface_combinations = ARRAY_SIZE(hwsim_if_comb); | ||
2332 | |||
2333 | if (channels > 1) { | ||
2334 | hw->wiphy->max_scan_ssids = 255; | ||
2335 | hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; | ||
2336 | hw->wiphy->max_remain_on_channel_duration = 1000; | ||
2337 | /* For channels > 1 DFS is not allowed */ | ||
2338 | hw->wiphy->n_iface_combinations = 1; | ||
2339 | } | ||
2340 | |||
2341 | INIT_DELAYED_WORK(&data->roc_done, hw_roc_done); | ||
2342 | INIT_DELAYED_WORK(&data->hw_scan, hw_scan_work); | ||
2343 | |||
2344 | hw->channel_change_time = 1; | ||
2345 | hw->queues = 5; | ||
2346 | hw->offchannel_tx_hw_queue = 4; | ||
2347 | hw->wiphy->interface_modes = | ||
2348 | BIT(NL80211_IFTYPE_STATION) | | ||
2349 | BIT(NL80211_IFTYPE_AP) | | ||
2350 | BIT(NL80211_IFTYPE_P2P_CLIENT) | | ||
2351 | BIT(NL80211_IFTYPE_P2P_GO) | | ||
2352 | BIT(NL80211_IFTYPE_ADHOC) | | ||
2353 | BIT(NL80211_IFTYPE_MESH_POINT) | | ||
2354 | BIT(NL80211_IFTYPE_P2P_DEVICE); | ||
2355 | |||
2356 | hw->flags = IEEE80211_HW_MFP_CAPABLE | | ||
2357 | IEEE80211_HW_SIGNAL_DBM | | ||
2358 | IEEE80211_HW_SUPPORTS_STATIC_SMPS | | ||
2359 | IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | | ||
2360 | IEEE80211_HW_AMPDU_AGGREGATION | | ||
2361 | IEEE80211_HW_WANT_MONITOR_VIF | | ||
2362 | IEEE80211_HW_QUEUE_CONTROL | | ||
2363 | IEEE80211_HW_SUPPORTS_HT_CCK_RATES; | ||
2364 | if (rctbl) | ||
2365 | hw->flags |= IEEE80211_HW_SUPPORTS_RC_TABLE; | ||
2366 | |||
2367 | hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS | | ||
2368 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL | | ||
2369 | WIPHY_FLAG_AP_UAPSD; | ||
2370 | hw->wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR; | ||
2371 | |||
2372 | /* ask mac80211 to reserve space for magic */ | ||
2373 | hw->vif_data_size = sizeof(struct hwsim_vif_priv); | ||
2374 | hw->sta_data_size = sizeof(struct hwsim_sta_priv); | ||
2375 | hw->chanctx_data_size = sizeof(struct hwsim_chanctx_priv); | ||
2376 | |||
2377 | memcpy(data->channels_2ghz, hwsim_channels_2ghz, | ||
2378 | sizeof(hwsim_channels_2ghz)); | ||
2379 | memcpy(data->channels_5ghz, hwsim_channels_5ghz, | ||
2380 | sizeof(hwsim_channels_5ghz)); | ||
2381 | memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates)); | ||
2382 | |||
2383 | for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) { | ||
2384 | struct ieee80211_supported_band *sband = &data->bands[band]; | ||
2385 | switch (band) { | ||
2386 | case IEEE80211_BAND_2GHZ: | ||
2387 | sband->channels = data->channels_2ghz; | ||
2388 | sband->n_channels = | ||
2389 | ARRAY_SIZE(hwsim_channels_2ghz); | ||
2390 | sband->bitrates = data->rates; | ||
2391 | sband->n_bitrates = ARRAY_SIZE(hwsim_rates); | ||
2392 | break; | ||
2393 | case IEEE80211_BAND_5GHZ: | ||
2394 | sband->channels = data->channels_5ghz; | ||
2395 | sband->n_channels = | ||
2396 | ARRAY_SIZE(hwsim_channels_5ghz); | ||
2397 | sband->bitrates = data->rates + 4; | ||
2398 | sband->n_bitrates = ARRAY_SIZE(hwsim_rates) - 4; | ||
2399 | break; | ||
2400 | default: | ||
2401 | continue; | ||
2402 | } | ||
2403 | |||
2404 | sband->ht_cap.ht_supported = true; | ||
2405 | sband->ht_cap.cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | | ||
2406 | IEEE80211_HT_CAP_GRN_FLD | | ||
2407 | IEEE80211_HT_CAP_SGI_40 | | ||
2408 | IEEE80211_HT_CAP_DSSSCCK40; | ||
2409 | sband->ht_cap.ampdu_factor = 0x3; | ||
2410 | sband->ht_cap.ampdu_density = 0x6; | ||
2411 | memset(&sband->ht_cap.mcs, 0, | ||
2412 | sizeof(sband->ht_cap.mcs)); | ||
2413 | sband->ht_cap.mcs.rx_mask[0] = 0xff; | ||
2414 | sband->ht_cap.mcs.rx_mask[1] = 0xff; | ||
2415 | sband->ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; | ||
2416 | |||
2417 | hw->wiphy->bands[band] = sband; | ||
2418 | |||
2419 | sband->vht_cap.vht_supported = true; | ||
2420 | sband->vht_cap.cap = | ||
2421 | IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 | | ||
2422 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ | | ||
2423 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ | | ||
2424 | IEEE80211_VHT_CAP_RXLDPC | | ||
2425 | IEEE80211_VHT_CAP_SHORT_GI_80 | | ||
2426 | IEEE80211_VHT_CAP_SHORT_GI_160 | | ||
2427 | IEEE80211_VHT_CAP_TXSTBC | | ||
2428 | IEEE80211_VHT_CAP_RXSTBC_1 | | ||
2429 | IEEE80211_VHT_CAP_RXSTBC_2 | | ||
2430 | IEEE80211_VHT_CAP_RXSTBC_3 | | ||
2431 | IEEE80211_VHT_CAP_RXSTBC_4 | | ||
2432 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK; | ||
2433 | sband->vht_cap.vht_mcs.rx_mcs_map = | ||
2434 | cpu_to_le16(IEEE80211_VHT_MCS_SUPPORT_0_8 << 0 | | ||
2435 | IEEE80211_VHT_MCS_SUPPORT_0_8 << 2 | | ||
2436 | IEEE80211_VHT_MCS_SUPPORT_0_9 << 4 | | ||
2437 | IEEE80211_VHT_MCS_SUPPORT_0_8 << 6 | | ||
2438 | IEEE80211_VHT_MCS_SUPPORT_0_8 << 8 | | ||
2439 | IEEE80211_VHT_MCS_SUPPORT_0_9 << 10 | | ||
2440 | IEEE80211_VHT_MCS_SUPPORT_0_9 << 12 | | ||
2441 | IEEE80211_VHT_MCS_SUPPORT_0_8 << 14); | ||
2442 | sband->vht_cap.vht_mcs.tx_mcs_map = | ||
2443 | sband->vht_cap.vht_mcs.rx_mcs_map; | ||
2444 | } | ||
2445 | /* By default all radios are belonging to the first group */ | ||
2446 | data->group = 1; | ||
2447 | mutex_init(&data->mutex); | ||
2448 | |||
2449 | /* Enable frame retransmissions for lossy channels */ | ||
2450 | hw->max_rates = 4; | ||
2451 | hw->max_rate_tries = 11; | ||
2452 | 2576 | ||
2453 | /* Work to be done prior to ieee80211_register_hw() */ | ||
2454 | switch (regtest) { | 2577 | switch (regtest) { |
2455 | case HWSIM_REGTEST_DISABLED: | ||
2456 | case HWSIM_REGTEST_DRIVER_REG_FOLLOW: | ||
2457 | case HWSIM_REGTEST_DRIVER_REG_ALL: | ||
2458 | case HWSIM_REGTEST_DIFF_COUNTRY: | 2578 | case HWSIM_REGTEST_DIFF_COUNTRY: |
2459 | /* | 2579 | if (i < ARRAY_SIZE(hwsim_alpha2s)) |
2460 | * Nothing to be done for driver regulatory domain | 2580 | reg_alpha2 = hwsim_alpha2s[i]; |
2461 | * hints prior to ieee80211_register_hw() | ||
2462 | */ | ||
2463 | break; | ||
2464 | case HWSIM_REGTEST_WORLD_ROAM: | ||
2465 | if (i == 0) { | ||
2466 | hw->wiphy->regulatory_flags |= | ||
2467 | REGULATORY_CUSTOM_REG; | ||
2468 | wiphy_apply_custom_regulatory(hw->wiphy, | ||
2469 | &hwsim_world_regdom_custom_01); | ||
2470 | } | ||
2471 | break; | ||
2472 | case HWSIM_REGTEST_CUSTOM_WORLD: | ||
2473 | hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; | ||
2474 | wiphy_apply_custom_regulatory(hw->wiphy, | ||
2475 | &hwsim_world_regdom_custom_01); | ||
2476 | break; | ||
2477 | case HWSIM_REGTEST_CUSTOM_WORLD_2: | ||
2478 | if (i == 0) { | ||
2479 | hw->wiphy->regulatory_flags |= | ||
2480 | REGULATORY_CUSTOM_REG; | ||
2481 | wiphy_apply_custom_regulatory(hw->wiphy, | ||
2482 | &hwsim_world_regdom_custom_01); | ||
2483 | } else if (i == 1) { | ||
2484 | hw->wiphy->regulatory_flags |= | ||
2485 | REGULATORY_CUSTOM_REG; | ||
2486 | wiphy_apply_custom_regulatory(hw->wiphy, | ||
2487 | &hwsim_world_regdom_custom_02); | ||
2488 | } | ||
2489 | break; | ||
2490 | case HWSIM_REGTEST_STRICT_ALL: | ||
2491 | hw->wiphy->regulatory_flags |= REGULATORY_STRICT_REG; | ||
2492 | break; | ||
2493 | case HWSIM_REGTEST_STRICT_FOLLOW: | ||
2494 | case HWSIM_REGTEST_STRICT_AND_DRIVER_REG: | ||
2495 | if (i == 0) | ||
2496 | hw->wiphy->regulatory_flags |= | ||
2497 | REGULATORY_STRICT_REG; | ||
2498 | break; | ||
2499 | case HWSIM_REGTEST_ALL: | ||
2500 | if (i == 0) { | ||
2501 | hw->wiphy->regulatory_flags |= | ||
2502 | REGULATORY_CUSTOM_REG; | ||
2503 | wiphy_apply_custom_regulatory(hw->wiphy, | ||
2504 | &hwsim_world_regdom_custom_01); | ||
2505 | } else if (i == 1) { | ||
2506 | hw->wiphy->regulatory_flags |= | ||
2507 | REGULATORY_CUSTOM_REG; | ||
2508 | wiphy_apply_custom_regulatory(hw->wiphy, | ||
2509 | &hwsim_world_regdom_custom_02); | ||
2510 | } else if (i == 4) | ||
2511 | hw->wiphy->regulatory_flags |= | ||
2512 | REGULATORY_STRICT_REG; | ||
2513 | break; | ||
2514 | default: | ||
2515 | break; | ||
2516 | } | ||
2517 | |||
2518 | /* give the regulatory workqueue a chance to run */ | ||
2519 | if (regtest) | ||
2520 | schedule_timeout_interruptible(1); | ||
2521 | err = ieee80211_register_hw(hw); | ||
2522 | if (err < 0) { | ||
2523 | printk(KERN_DEBUG "mac80211_hwsim: " | ||
2524 | "ieee80211_register_hw failed (%d)\n", err); | ||
2525 | goto failed_hw; | ||
2526 | } | ||
2527 | |||
2528 | /* Work to be done after to ieee80211_register_hw() */ | ||
2529 | switch (regtest) { | ||
2530 | case HWSIM_REGTEST_WORLD_ROAM: | ||
2531 | case HWSIM_REGTEST_DISABLED: | ||
2532 | break; | 2581 | break; |
2533 | case HWSIM_REGTEST_DRIVER_REG_FOLLOW: | 2582 | case HWSIM_REGTEST_DRIVER_REG_FOLLOW: |
2534 | if (!i) | 2583 | if (!i) |
2535 | regulatory_hint(hw->wiphy, hwsim_alpha2s[0]); | 2584 | reg_alpha2 = hwsim_alpha2s[0]; |
2536 | break; | 2585 | break; |
2537 | case HWSIM_REGTEST_DRIVER_REG_ALL: | ||
2538 | case HWSIM_REGTEST_STRICT_ALL: | 2586 | case HWSIM_REGTEST_STRICT_ALL: |
2539 | regulatory_hint(hw->wiphy, hwsim_alpha2s[0]); | 2587 | reg_strict = true; |
2588 | case HWSIM_REGTEST_DRIVER_REG_ALL: | ||
2589 | reg_alpha2 = hwsim_alpha2s[0]; | ||
2540 | break; | 2590 | break; |
2541 | case HWSIM_REGTEST_DIFF_COUNTRY: | 2591 | case HWSIM_REGTEST_WORLD_ROAM: |
2542 | if (i < ARRAY_SIZE(hwsim_alpha2s)) | 2592 | if (i == 0) |
2543 | regulatory_hint(hw->wiphy, hwsim_alpha2s[i]); | 2593 | regd = &hwsim_world_regdom_custom_01; |
2544 | break; | 2594 | break; |
2545 | case HWSIM_REGTEST_CUSTOM_WORLD: | 2595 | case HWSIM_REGTEST_CUSTOM_WORLD: |
2596 | regd = &hwsim_world_regdom_custom_01; | ||
2597 | break; | ||
2546 | case HWSIM_REGTEST_CUSTOM_WORLD_2: | 2598 | case HWSIM_REGTEST_CUSTOM_WORLD_2: |
2547 | /* | 2599 | if (i == 0) |
2548 | * Nothing to be done for custom world regulatory | 2600 | regd = &hwsim_world_regdom_custom_01; |
2549 | * domains after to ieee80211_register_hw | 2601 | else if (i == 1) |
2550 | */ | 2602 | regd = &hwsim_world_regdom_custom_02; |
2551 | break; | 2603 | break; |
2552 | case HWSIM_REGTEST_STRICT_FOLLOW: | 2604 | case HWSIM_REGTEST_STRICT_FOLLOW: |
2553 | if (i == 0) | 2605 | if (i == 0) { |
2554 | regulatory_hint(hw->wiphy, hwsim_alpha2s[0]); | 2606 | reg_strict = true; |
2607 | reg_alpha2 = hwsim_alpha2s[0]; | ||
2608 | } | ||
2555 | break; | 2609 | break; |
2556 | case HWSIM_REGTEST_STRICT_AND_DRIVER_REG: | 2610 | case HWSIM_REGTEST_STRICT_AND_DRIVER_REG: |
2557 | if (i == 0) | 2611 | if (i == 0) { |
2558 | regulatory_hint(hw->wiphy, hwsim_alpha2s[0]); | 2612 | reg_strict = true; |
2559 | else if (i == 1) | 2613 | reg_alpha2 = hwsim_alpha2s[0]; |
2560 | regulatory_hint(hw->wiphy, hwsim_alpha2s[1]); | 2614 | } else if (i == 1) { |
2615 | reg_alpha2 = hwsim_alpha2s[1]; | ||
2616 | } | ||
2561 | break; | 2617 | break; |
2562 | case HWSIM_REGTEST_ALL: | 2618 | case HWSIM_REGTEST_ALL: |
2563 | if (i == 2) | 2619 | switch (i) { |
2564 | regulatory_hint(hw->wiphy, hwsim_alpha2s[0]); | 2620 | case 0: |
2565 | else if (i == 3) | 2621 | regd = &hwsim_world_regdom_custom_01; |
2566 | regulatory_hint(hw->wiphy, hwsim_alpha2s[1]); | 2622 | break; |
2567 | else if (i == 4) | 2623 | case 1: |
2568 | regulatory_hint(hw->wiphy, hwsim_alpha2s[2]); | 2624 | regd = &hwsim_world_regdom_custom_02; |
2625 | break; | ||
2626 | case 2: | ||
2627 | reg_alpha2 = hwsim_alpha2s[0]; | ||
2628 | break; | ||
2629 | case 3: | ||
2630 | reg_alpha2 = hwsim_alpha2s[1]; | ||
2631 | break; | ||
2632 | case 4: | ||
2633 | reg_strict = true; | ||
2634 | reg_alpha2 = hwsim_alpha2s[2]; | ||
2635 | break; | ||
2636 | } | ||
2569 | break; | 2637 | break; |
2570 | default: | 2638 | default: |
2571 | break; | 2639 | break; |
2572 | } | 2640 | } |
2573 | 2641 | ||
2574 | wiphy_debug(hw->wiphy, "hwaddr %pm registered\n", | 2642 | err = mac80211_hwsim_create_radio(channels, reg_alpha2, |
2575 | hw->wiphy->perm_addr); | 2643 | regd, reg_strict); |
2576 | 2644 | if (err < 0) | |
2577 | data->debugfs = debugfs_create_dir("hwsim", | 2645 | goto out_free_radios; |
2578 | hw->wiphy->debugfsdir); | ||
2579 | debugfs_create_file("ps", 0666, data->debugfs, data, | ||
2580 | &hwsim_fops_ps); | ||
2581 | debugfs_create_file("group", 0666, data->debugfs, data, | ||
2582 | &hwsim_fops_group); | ||
2583 | if (channels == 1) | ||
2584 | debugfs_create_file("dfs_simulate_radar", 0222, | ||
2585 | data->debugfs, | ||
2586 | data, &hwsim_simulate_radar); | ||
2587 | |||
2588 | tasklet_hrtimer_init(&data->beacon_timer, | ||
2589 | mac80211_hwsim_beacon, | ||
2590 | CLOCK_MONOTONIC_RAW, HRTIMER_MODE_ABS); | ||
2591 | |||
2592 | list_add_tail(&data->list, &hwsim_radios); | ||
2593 | } | 2646 | } |
2594 | 2647 | ||
2595 | hwsim_mon = alloc_netdev(0, "hwsim%d", hwsim_mon_setup); | 2648 | hwsim_mon = alloc_netdev(0, "hwsim%d", hwsim_mon_setup); |
2596 | if (hwsim_mon == NULL) { | 2649 | if (hwsim_mon == NULL) { |
2597 | err = -ENOMEM; | 2650 | err = -ENOMEM; |
2598 | goto failed; | 2651 | goto out_free_radios; |
2599 | } | 2652 | } |
2600 | 2653 | ||
2601 | rtnl_lock(); | 2654 | rtnl_lock(); |
2602 | |||
2603 | err = dev_alloc_name(hwsim_mon, hwsim_mon->name); | 2655 | err = dev_alloc_name(hwsim_mon, hwsim_mon->name); |
2604 | if (err < 0) | 2656 | if (err < 0) { |
2605 | goto failed_mon; | 2657 | rtnl_unlock(); |
2606 | 2658 | goto out_free_radios; | |
2659 | } | ||
2607 | 2660 | ||
2608 | err = register_netdevice(hwsim_mon); | 2661 | err = register_netdevice(hwsim_mon); |
2609 | if (err < 0) | 2662 | if (err < 0) { |
2610 | goto failed_mon; | 2663 | rtnl_unlock(); |
2611 | 2664 | goto out_free_mon; | |
2665 | } | ||
2612 | rtnl_unlock(); | 2666 | rtnl_unlock(); |
2613 | 2667 | ||
2614 | err = hwsim_init_netlink(); | 2668 | err = hwsim_init_netlink(); |
2615 | if (err < 0) | 2669 | if (err < 0) |
2616 | goto failed_nl; | 2670 | goto out_free_mon; |
2617 | 2671 | ||
2618 | return 0; | 2672 | return 0; |
2619 | 2673 | ||
2620 | failed_nl: | 2674 | out_free_mon: |
2621 | printk(KERN_DEBUG "mac_80211_hwsim: failed initializing netlink\n"); | ||
2622 | return err; | ||
2623 | |||
2624 | failed_mon: | ||
2625 | rtnl_unlock(); | ||
2626 | free_netdev(hwsim_mon); | 2675 | free_netdev(hwsim_mon); |
2676 | out_free_radios: | ||
2627 | mac80211_hwsim_free(); | 2677 | mac80211_hwsim_free(); |
2628 | return err; | 2678 | out_unregister_driver: |
2629 | |||
2630 | failed_hw: | ||
2631 | device_unregister(data->dev); | ||
2632 | failed_drvdata: | ||
2633 | ieee80211_free_hw(hw); | ||
2634 | failed: | ||
2635 | mac80211_hwsim_free(); | ||
2636 | failed_unregister_driver: | ||
2637 | platform_driver_unregister(&mac80211_hwsim_driver); | 2679 | platform_driver_unregister(&mac80211_hwsim_driver); |
2638 | return err; | 2680 | return err; |
2639 | } | 2681 | } |
diff --git a/drivers/net/wireless/mac80211_hwsim.h b/drivers/net/wireless/mac80211_hwsim.h index afaad5a443b6..2747cce5a269 100644 --- a/drivers/net/wireless/mac80211_hwsim.h +++ b/drivers/net/wireless/mac80211_hwsim.h | |||
@@ -65,6 +65,9 @@ enum hwsim_tx_control_flags { | |||
65 | * kernel, uses: | 65 | * kernel, uses: |
66 | * %HWSIM_ATTR_ADDR_TRANSMITTER, %HWSIM_ATTR_FLAGS, | 66 | * %HWSIM_ATTR_ADDR_TRANSMITTER, %HWSIM_ATTR_FLAGS, |
67 | * %HWSIM_ATTR_TX_INFO, %HWSIM_ATTR_SIGNAL, %HWSIM_ATTR_COOKIE | 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 | * @__HWSIM_CMD_MAX: enum limit | 71 | * @__HWSIM_CMD_MAX: enum limit |
69 | */ | 72 | */ |
70 | enum { | 73 | enum { |
@@ -72,6 +75,8 @@ enum { | |||
72 | HWSIM_CMD_REGISTER, | 75 | HWSIM_CMD_REGISTER, |
73 | HWSIM_CMD_FRAME, | 76 | HWSIM_CMD_FRAME, |
74 | HWSIM_CMD_TX_INFO_FRAME, | 77 | HWSIM_CMD_TX_INFO_FRAME, |
78 | HWSIM_CMD_CREATE_RADIO, | ||
79 | HWSIM_CMD_DESTROY_RADIO, | ||
75 | __HWSIM_CMD_MAX, | 80 | __HWSIM_CMD_MAX, |
76 | }; | 81 | }; |
77 | #define HWSIM_CMD_MAX (_HWSIM_CMD_MAX - 1) | 82 | #define HWSIM_CMD_MAX (_HWSIM_CMD_MAX - 1) |
@@ -94,6 +99,14 @@ enum { | |||
94 | space | 99 | space |
95 | * @HWSIM_ATTR_TX_INFO: ieee80211_tx_rate array | 100 | * @HWSIM_ATTR_TX_INFO: ieee80211_tx_rate array |
96 | * @HWSIM_ATTR_COOKIE: sk_buff cookie to identify the frame | 101 | * @HWSIM_ATTR_COOKIE: sk_buff cookie to identify the frame |
102 | * @HWSIM_ATTR_CHANNELS: u32 attribute used with the %HWSIM_CMD_CREATE_RADIO | ||
103 | * command giving the number of channels supported by the new radio | ||
104 | * @HWSIM_ATTR_RADIO_ID: u32 attribute used with %HWSIM_CMD_DESTROY_RADIO | ||
105 | * only to destroy a radio | ||
106 | * @HWSIM_ATTR_REG_HINT_ALPHA2: alpha2 for regulatoro driver hint | ||
107 | * (nla string, length 2) | ||
108 | * @HWSIM_ATTR_REG_CUSTOM_REG: custom regulatory domain index (u32 attribute) | ||
109 | * @HWSIM_ATTR_REG_STRICT_REG: request REGULATORY_STRICT_REG (flag attribute) | ||
97 | * @__HWSIM_ATTR_MAX: enum limit | 110 | * @__HWSIM_ATTR_MAX: enum limit |
98 | */ | 111 | */ |
99 | 112 | ||
@@ -108,6 +121,11 @@ enum { | |||
108 | HWSIM_ATTR_SIGNAL, | 121 | HWSIM_ATTR_SIGNAL, |
109 | HWSIM_ATTR_TX_INFO, | 122 | HWSIM_ATTR_TX_INFO, |
110 | HWSIM_ATTR_COOKIE, | 123 | HWSIM_ATTR_COOKIE, |
124 | HWSIM_ATTR_CHANNELS, | ||
125 | HWSIM_ATTR_RADIO_ID, | ||
126 | HWSIM_ATTR_REG_HINT_ALPHA2, | ||
127 | HWSIM_ATTR_REG_CUSTOM_REG, | ||
128 | HWSIM_ATTR_REG_STRICT_REG, | ||
111 | __HWSIM_ATTR_MAX, | 129 | __HWSIM_ATTR_MAX, |
112 | }; | 130 | }; |
113 | #define HWSIM_ATTR_MAX (__HWSIM_ATTR_MAX - 1) | 131 | #define HWSIM_ATTR_MAX (__HWSIM_ATTR_MAX - 1) |
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c index 63dbde5c3713..4987c3f942ce 100644 --- a/drivers/net/wireless/mwl8k.c +++ b/drivers/net/wireless/mwl8k.c | |||
@@ -5892,8 +5892,6 @@ static int mwl8k_firmware_load_success(struct mwl8k_priv *priv) | |||
5892 | 5892 | ||
5893 | hw->extra_tx_headroom -= priv->ap_fw ? REDUCED_TX_HEADROOM : 0; | 5893 | hw->extra_tx_headroom -= priv->ap_fw ? REDUCED_TX_HEADROOM : 0; |
5894 | 5894 | ||
5895 | hw->channel_change_time = 10; | ||
5896 | |||
5897 | hw->queues = MWL8K_TX_WMM_QUEUES; | 5895 | hw->queues = MWL8K_TX_WMM_QUEUES; |
5898 | 5896 | ||
5899 | /* Set rssi values to dBm */ | 5897 | /* Set rssi values to dBm */ |
diff --git a/drivers/net/wireless/p54/main.c b/drivers/net/wireless/p54/main.c index 80d93cba5150..eede90b63f84 100644 --- a/drivers/net/wireless/p54/main.c +++ b/drivers/net/wireless/p54/main.c | |||
@@ -756,7 +756,6 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len) | |||
756 | BIT(NL80211_IFTYPE_AP) | | 756 | BIT(NL80211_IFTYPE_AP) | |
757 | BIT(NL80211_IFTYPE_MESH_POINT); | 757 | BIT(NL80211_IFTYPE_MESH_POINT); |
758 | 758 | ||
759 | dev->channel_change_time = 1000; /* TODO: find actual value */ | ||
760 | priv->beacon_req_id = cpu_to_le32(0); | 759 | priv->beacon_req_id = cpu_to_le32(0); |
761 | priv->tx_stats[P54_QUEUE_BEACON].limit = 1; | 760 | priv->tx_stats[P54_QUEUE_BEACON].limit = 1; |
762 | priv->tx_stats[P54_QUEUE_FWSCAN].limit = 1; | 761 | priv->tx_stats[P54_QUEUE_FWSCAN].limit = 1; |
diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c index d63a12cc5de8..93bb384eb001 100644 --- a/drivers/net/wireless/rtlwifi/base.c +++ b/drivers/net/wireless/rtlwifi/base.c | |||
@@ -353,7 +353,6 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw) | |||
353 | 353 | ||
354 | /* TODO: Correct this value for our hw */ | 354 | /* TODO: Correct this value for our hw */ |
355 | /* TODO: define these hard code value */ | 355 | /* TODO: define these hard code value */ |
356 | hw->channel_change_time = 100; | ||
357 | hw->max_listen_interval = 10; | 356 | hw->max_listen_interval = 10; |
358 | hw->max_rate_tries = 4; | 357 | hw->max_rate_tries = 4; |
359 | /* hw->max_rates = 1; */ | 358 | /* hw->max_rates = 1; */ |
diff --git a/drivers/net/wireless/ti/wl1251/main.c b/drivers/net/wireless/ti/wl1251/main.c index 80f92110a3bf..fa3909a72ad6 100644 --- a/drivers/net/wireless/ti/wl1251/main.c +++ b/drivers/net/wireless/ti/wl1251/main.c | |||
@@ -1468,7 +1468,6 @@ int wl1251_init_ieee80211(struct wl1251 *wl) | |||
1468 | 1468 | ||
1469 | /* unit us */ | 1469 | /* unit us */ |
1470 | /* FIXME: find a proper value */ | 1470 | /* FIXME: find a proper value */ |
1471 | wl->hw->channel_change_time = 10000; | ||
1472 | 1471 | ||
1473 | wl->hw->flags = IEEE80211_HW_SIGNAL_DBM | | 1472 | wl->hw->flags = IEEE80211_HW_SIGNAL_DBM | |
1474 | IEEE80211_HW_SUPPORTS_PS | | 1473 | IEEE80211_HW_SUPPORTS_PS | |
diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c index e9da47cead58..18a009e593c7 100644 --- a/drivers/net/wireless/ti/wlcore/main.c +++ b/drivers/net/wireless/ti/wlcore/main.c | |||
@@ -5710,7 +5710,6 @@ static int wl1271_init_ieee80211(struct wl1271 *wl) | |||
5710 | 5710 | ||
5711 | /* unit us */ | 5711 | /* unit us */ |
5712 | /* FIXME: find a proper value */ | 5712 | /* FIXME: find a proper value */ |
5713 | wl->hw->channel_change_time = 10000; | ||
5714 | wl->hw->max_listen_interval = wl->conf.conn.max_listen_interval; | 5713 | wl->hw->max_listen_interval = wl->conf.conn.max_listen_interval; |
5715 | 5714 | ||
5716 | wl->hw->flags = IEEE80211_HW_SIGNAL_DBM | | 5715 | wl->hw->flags = IEEE80211_HW_SIGNAL_DBM | |
diff --git a/drivers/staging/winbond/wbusb.c b/drivers/staging/winbond/wbusb.c index 07891a3e316e..0d29624416c3 100644 --- a/drivers/staging/winbond/wbusb.c +++ b/drivers/staging/winbond/wbusb.c | |||
@@ -788,7 +788,6 @@ static int wb35_probe(struct usb_interface *intf, | |||
788 | dev->flags = IEEE80211_HW_SIGNAL_UNSPEC; | 788 | dev->flags = IEEE80211_HW_SIGNAL_UNSPEC; |
789 | dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); | 789 | dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); |
790 | 790 | ||
791 | dev->channel_change_time = 1000; | ||
792 | dev->max_signal = 100; | 791 | dev->max_signal = 100; |
793 | dev->queues = 1; | 792 | dev->queues = 1; |
794 | 793 | ||
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index 776cbb80d098..e526a8cecb70 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h | |||
@@ -1857,6 +1857,7 @@ enum ieee80211_key_len { | |||
1857 | WLAN_KEY_LEN_CCMP = 16, | 1857 | WLAN_KEY_LEN_CCMP = 16, |
1858 | WLAN_KEY_LEN_TKIP = 32, | 1858 | WLAN_KEY_LEN_TKIP = 32, |
1859 | WLAN_KEY_LEN_AES_CMAC = 16, | 1859 | WLAN_KEY_LEN_AES_CMAC = 16, |
1860 | WLAN_KEY_LEN_SMS4 = 32, | ||
1860 | }; | 1861 | }; |
1861 | 1862 | ||
1862 | #define IEEE80211_WEP_IV_LEN 4 | 1863 | #define IEEE80211_WEP_IV_LEN 4 |
@@ -1902,6 +1903,7 @@ enum ieee80211_tdls_actioncode { | |||
1902 | #define WLAN_EXT_CAPA5_TDLS_PROHIBITED BIT(6) | 1903 | #define WLAN_EXT_CAPA5_TDLS_PROHIBITED BIT(6) |
1903 | 1904 | ||
1904 | #define WLAN_EXT_CAPA8_OPMODE_NOTIF BIT(6) | 1905 | #define WLAN_EXT_CAPA8_OPMODE_NOTIF BIT(6) |
1906 | #define WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED BIT(7) | ||
1905 | 1907 | ||
1906 | /* TDLS specific payload type in the LLC/SNAP header */ | 1908 | /* TDLS specific payload type in the LLC/SNAP header */ |
1907 | #define WLAN_TDLS_SNAP_RFTYPE 0x2 | 1909 | #define WLAN_TDLS_SNAP_RFTYPE 0x2 |
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 56c597793d6d..b1f84b05c67e 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h | |||
@@ -4640,6 +4640,14 @@ void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev, | |||
4640 | */ | 4640 | */ |
4641 | void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp); | 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 | /* Logging, debugging and troubleshooting/diagnostic helpers. */ | 4651 | /* Logging, debugging and troubleshooting/diagnostic helpers. */ |
4644 | 4652 | ||
4645 | /* wiphy_printk helpers, similar to dev_printk */ | 4653 | /* wiphy_printk helpers, similar to dev_printk */ |
diff --git a/include/net/mac80211.h b/include/net/mac80211.h index f838af816b56..f4ab2fb4d50c 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h | |||
@@ -1616,8 +1616,6 @@ enum ieee80211_hw_flags { | |||
1616 | * @extra_beacon_tailroom: tailroom to reserve in each beacon tx skb. | 1616 | * @extra_beacon_tailroom: tailroom to reserve in each beacon tx skb. |
1617 | * Can be used by drivers to add extra IEs. | 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 | * @max_signal: Maximum value for signal (rssi) in RX information, used | 1619 | * @max_signal: Maximum value for signal (rssi) in RX information, used |
1622 | * only when @IEEE80211_HW_SIGNAL_UNSPEC or @IEEE80211_HW_SIGNAL_DB | 1620 | * only when @IEEE80211_HW_SIGNAL_UNSPEC or @IEEE80211_HW_SIGNAL_DB |
1623 | * | 1621 | * |
@@ -1699,7 +1697,6 @@ struct ieee80211_hw { | |||
1699 | u32 flags; | 1697 | u32 flags; |
1700 | unsigned int extra_tx_headroom; | 1698 | unsigned int extra_tx_headroom; |
1701 | unsigned int extra_beacon_tailroom; | 1699 | unsigned int extra_beacon_tailroom; |
1702 | int channel_change_time; | ||
1703 | int vif_data_size; | 1700 | int vif_data_size; |
1704 | int sta_data_size; | 1701 | int sta_data_size; |
1705 | int chanctx_data_size; | 1702 | int chanctx_data_size; |
@@ -2122,6 +2119,11 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb); | |||
2122 | * appropriately (only the last frame may have %IEEE80211_TX_STATUS_EOSP) | 2119 | * appropriately (only the last frame may have %IEEE80211_TX_STATUS_EOSP) |
2123 | * and also take care of the EOSP and MORE_DATA bits in the frame. | 2120 | * and also take care of the EOSP and MORE_DATA bits in the frame. |
2124 | * The driver may also use ieee80211_sta_eosp() in this case. | 2121 | * The driver may also use ieee80211_sta_eosp() in this case. |
2122 | * | ||
2123 | * Note that if the driver ever buffers frames other than QoS-data | ||
2124 | * frames, it must take care to never send a non-QoS-data frame as | ||
2125 | * the last frame in a service period, adding a QoS-nulldata frame | ||
2126 | * after a non-QoS-data frame if needed. | ||
2125 | */ | 2127 | */ |
2126 | 2128 | ||
2127 | /** | 2129 | /** |
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 09d2e58a2ba7..f9ae9b85d4c1 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -1035,6 +1035,7 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev, | |||
1035 | return err; | 1035 | return err; |
1036 | } | 1036 | } |
1037 | 1037 | ||
1038 | ieee80211_recalc_dtim(local, sdata); | ||
1038 | ieee80211_bss_info_change_notify(sdata, changed); | 1039 | ieee80211_bss_info_change_notify(sdata, changed); |
1039 | 1040 | ||
1040 | netif_carrier_on(dev); | 1041 | netif_carrier_on(dev); |
@@ -3854,7 +3855,7 @@ static int ieee80211_set_qos_map(struct wiphy *wiphy, | |||
3854 | new_qos_map = NULL; | 3855 | new_qos_map = NULL; |
3855 | } | 3856 | } |
3856 | 3857 | ||
3857 | old_qos_map = rtnl_dereference(sdata->qos_map); | 3858 | old_qos_map = sdata_dereference(sdata->qos_map, sdata); |
3858 | rcu_assign_pointer(sdata->qos_map, new_qos_map); | 3859 | rcu_assign_pointer(sdata->qos_map, new_qos_map); |
3859 | if (old_qos_map) | 3860 | if (old_qos_map) |
3860 | kfree_rcu(old_qos_map, rcu_head); | 3861 | kfree_rcu(old_qos_map, rcu_head); |
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index 04b5a14c8a05..ebf80f3abd83 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c | |||
@@ -133,7 +133,15 @@ static ssize_t ieee80211_if_fmt_##name( \ | |||
133 | jiffies_to_msecs(sdata->field)); \ | 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 | static ssize_t ieee80211_if_read_##name(struct file *file, \ | 145 | static ssize_t ieee80211_if_read_##name(struct file *file, \ |
138 | char __user *userbuf, \ | 146 | char __user *userbuf, \ |
139 | size_t count, loff_t *ppos) \ | 147 | size_t count, loff_t *ppos) \ |
@@ -141,28 +149,34 @@ static ssize_t ieee80211_if_read_##name(struct file *file, \ | |||
141 | return ieee80211_if_read(file->private_data, \ | 149 | return ieee80211_if_read(file->private_data, \ |
142 | userbuf, count, ppos, \ | 150 | userbuf, count, ppos, \ |
143 | ieee80211_if_fmt_##name); \ | 151 | ieee80211_if_fmt_##name); \ |
144 | } \ | ||
145 | static const struct file_operations name##_ops = { \ | ||
146 | .read = ieee80211_if_read_##name, \ | ||
147 | .write = (_write), \ | ||
148 | .open = simple_open, \ | ||
149 | .llseek = generic_file_llseek, \ | ||
150 | } | 152 | } |
151 | 153 | ||
152 | #define __IEEE80211_IF_FILE_W(name) \ | 154 | #define _IEEE80211_IF_FILE_W_FN(name) \ |
153 | static ssize_t ieee80211_if_write_##name(struct file *file, \ | 155 | static ssize_t ieee80211_if_write_##name(struct file *file, \ |
154 | const char __user *userbuf, \ | 156 | const char __user *userbuf, \ |
155 | size_t count, loff_t *ppos) \ | 157 | size_t count, loff_t *ppos) \ |
156 | { \ | 158 | { \ |
157 | return ieee80211_if_write(file->private_data, userbuf, count, \ | 159 | return ieee80211_if_write(file->private_data, userbuf, count, \ |
158 | ppos, ieee80211_if_parse_##name); \ | 160 | ppos, ieee80211_if_parse_##name); \ |
159 | } \ | 161 | } |
160 | __IEEE80211_IF_FILE(name, ieee80211_if_write_##name) | 162 | |
163 | #define IEEE80211_IF_FILE_R(name) \ | ||
164 | _IEEE80211_IF_FILE_R_FN(name) \ | ||
165 | _IEEE80211_IF_FILE_OPS(name, ieee80211_if_read_##name, NULL) | ||
166 | |||
167 | #define IEEE80211_IF_FILE_W(name) \ | ||
168 | _IEEE80211_IF_FILE_W_FN(name) \ | ||
169 | _IEEE80211_IF_FILE_OPS(name, NULL, ieee80211_if_write_##name) | ||
161 | 170 | ||
171 | #define IEEE80211_IF_FILE_RW(name) \ | ||
172 | _IEEE80211_IF_FILE_R_FN(name) \ | ||
173 | _IEEE80211_IF_FILE_W_FN(name) \ | ||
174 | _IEEE80211_IF_FILE_OPS(name, ieee80211_if_read_##name, \ | ||
175 | ieee80211_if_write_##name) | ||
162 | 176 | ||
163 | #define IEEE80211_IF_FILE(name, field, format) \ | 177 | #define IEEE80211_IF_FILE(name, field, format) \ |
164 | IEEE80211_IF_FMT_##format(name, field) \ | 178 | IEEE80211_IF_FMT_##format(name, field) \ |
165 | __IEEE80211_IF_FILE(name, NULL) | 179 | IEEE80211_IF_FILE_R(name) |
166 | 180 | ||
167 | /* common attributes */ | 181 | /* common attributes */ |
168 | IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC); | 182 | IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC); |
@@ -199,7 +213,7 @@ ieee80211_if_fmt_hw_queues(const struct ieee80211_sub_if_data *sdata, | |||
199 | 213 | ||
200 | return len; | 214 | return len; |
201 | } | 215 | } |
202 | __IEEE80211_IF_FILE(hw_queues, NULL); | 216 | IEEE80211_IF_FILE_R(hw_queues); |
203 | 217 | ||
204 | /* STA attributes */ | 218 | /* STA attributes */ |
205 | IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC); | 219 | IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC); |
@@ -275,14 +289,7 @@ static ssize_t ieee80211_if_parse_smps(struct ieee80211_sub_if_data *sdata, | |||
275 | 289 | ||
276 | return -EINVAL; | 290 | return -EINVAL; |
277 | } | 291 | } |
278 | 292 | IEEE80211_IF_FILE_RW(smps); | |
279 | __IEEE80211_IF_FILE_W(smps); | ||
280 | |||
281 | static ssize_t ieee80211_if_fmt_tkip_mic_test( | ||
282 | const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) | ||
283 | { | ||
284 | return -EOPNOTSUPP; | ||
285 | } | ||
286 | 293 | ||
287 | static ssize_t ieee80211_if_parse_tkip_mic_test( | 294 | static ssize_t ieee80211_if_parse_tkip_mic_test( |
288 | struct ieee80211_sub_if_data *sdata, const char *buf, int buflen) | 295 | struct ieee80211_sub_if_data *sdata, const char *buf, int buflen) |
@@ -349,8 +356,7 @@ static ssize_t ieee80211_if_parse_tkip_mic_test( | |||
349 | 356 | ||
350 | return buflen; | 357 | return buflen; |
351 | } | 358 | } |
352 | 359 | IEEE80211_IF_FILE_W(tkip_mic_test); | |
353 | __IEEE80211_IF_FILE_W(tkip_mic_test); | ||
354 | 360 | ||
355 | static ssize_t ieee80211_if_fmt_uapsd_queues( | 361 | static ssize_t ieee80211_if_fmt_uapsd_queues( |
356 | const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) | 362 | const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) |
@@ -378,7 +384,7 @@ static ssize_t ieee80211_if_parse_uapsd_queues( | |||
378 | 384 | ||
379 | return buflen; | 385 | return buflen; |
380 | } | 386 | } |
381 | __IEEE80211_IF_FILE_W(uapsd_queues); | 387 | IEEE80211_IF_FILE_RW(uapsd_queues); |
382 | 388 | ||
383 | static ssize_t ieee80211_if_fmt_uapsd_max_sp_len( | 389 | static ssize_t ieee80211_if_fmt_uapsd_max_sp_len( |
384 | const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) | 390 | const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) |
@@ -406,7 +412,7 @@ static ssize_t ieee80211_if_parse_uapsd_max_sp_len( | |||
406 | 412 | ||
407 | return buflen; | 413 | return buflen; |
408 | } | 414 | } |
409 | __IEEE80211_IF_FILE_W(uapsd_max_sp_len); | 415 | IEEE80211_IF_FILE_RW(uapsd_max_sp_len); |
410 | 416 | ||
411 | /* AP attributes */ | 417 | /* AP attributes */ |
412 | IEEE80211_IF_FILE(num_mcast_sta, u.ap.num_mcast_sta, ATOMIC); | 418 | IEEE80211_IF_FILE(num_mcast_sta, u.ap.num_mcast_sta, ATOMIC); |
@@ -419,7 +425,7 @@ static ssize_t ieee80211_if_fmt_num_buffered_multicast( | |||
419 | return scnprintf(buf, buflen, "%u\n", | 425 | return scnprintf(buf, buflen, "%u\n", |
420 | skb_queue_len(&sdata->u.ap.ps.bc_buf)); | 426 | skb_queue_len(&sdata->u.ap.ps.bc_buf)); |
421 | } | 427 | } |
422 | __IEEE80211_IF_FILE(num_buffered_multicast, NULL); | 428 | IEEE80211_IF_FILE_R(num_buffered_multicast); |
423 | 429 | ||
424 | /* IBSS attributes */ | 430 | /* IBSS attributes */ |
425 | static ssize_t ieee80211_if_fmt_tsf( | 431 | static ssize_t ieee80211_if_fmt_tsf( |
@@ -468,9 +474,10 @@ static ssize_t ieee80211_if_parse_tsf( | |||
468 | } | 474 | } |
469 | } | 475 | } |
470 | 476 | ||
477 | ieee80211_recalc_dtim(local, sdata); | ||
471 | return buflen; | 478 | return buflen; |
472 | } | 479 | } |
473 | __IEEE80211_IF_FILE_W(tsf); | 480 | IEEE80211_IF_FILE_RW(tsf); |
474 | 481 | ||
475 | 482 | ||
476 | /* WDS attributes */ | 483 | /* WDS attributes */ |
diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c index 9a8be8f69224..fab7b91923e0 100644 --- a/net/mac80211/ht.c +++ b/net/mac80211/ht.c | |||
@@ -479,10 +479,9 @@ void ieee80211_request_smps(struct ieee80211_vif *vif, | |||
479 | vif->type != NL80211_IFTYPE_AP)) | 479 | vif->type != NL80211_IFTYPE_AP)) |
480 | return; | 480 | return; |
481 | 481 | ||
482 | if (WARN_ON(smps_mode == IEEE80211_SMPS_OFF)) | ||
483 | smps_mode = IEEE80211_SMPS_AUTOMATIC; | ||
484 | |||
485 | if (vif->type == NL80211_IFTYPE_STATION) { | 482 | if (vif->type == NL80211_IFTYPE_STATION) { |
483 | if (WARN_ON(smps_mode == IEEE80211_SMPS_OFF)) | ||
484 | smps_mode = IEEE80211_SMPS_AUTOMATIC; | ||
486 | if (sdata->u.mgd.driver_smps_mode == smps_mode) | 485 | if (sdata->u.mgd.driver_smps_mode == smps_mode) |
487 | return; | 486 | return; |
488 | sdata->u.mgd.driver_smps_mode = smps_mode; | 487 | sdata->u.mgd.driver_smps_mode = smps_mode; |
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 953b9e294547..3701930c6649 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -1800,6 +1800,8 @@ ieee80211_cs_get(struct ieee80211_local *local, u32 cipher, | |||
1800 | int ieee80211_cs_headroom(struct ieee80211_local *local, | 1800 | int ieee80211_cs_headroom(struct ieee80211_local *local, |
1801 | struct cfg80211_crypto_settings *crypto, | 1801 | struct cfg80211_crypto_settings *crypto, |
1802 | enum nl80211_iftype iftype); | 1802 | enum nl80211_iftype iftype); |
1803 | void ieee80211_recalc_dtim(struct ieee80211_local *local, | ||
1804 | struct ieee80211_sub_if_data *sdata); | ||
1803 | 1805 | ||
1804 | #ifdef CONFIG_MAC80211_NOINLINE | 1806 | #ifdef CONFIG_MAC80211_NOINLINE |
1805 | #define debug_noinline noinline | 1807 | #define debug_noinline noinline |
diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 2bd5b552b2f6..d767cfb9b45f 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c | |||
@@ -846,17 +846,6 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
846 | /* TODO: consider VHT for RX chains, hopefully it's the same */ | 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 | /* if low-level driver supports AP, we also support VLAN */ | 849 | /* if low-level driver supports AP, we also support VLAN */ |
861 | if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) { | 850 | if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) { |
862 | hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_AP_VLAN); | 851 | hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_AP_VLAN); |
@@ -880,6 +869,17 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
880 | return -EINVAL; | 869 | return -EINVAL; |
881 | } | 870 | } |
882 | 871 | ||
872 | local->int_scan_req = kzalloc(sizeof(*local->int_scan_req) + | ||
873 | sizeof(void *) * channels, GFP_KERNEL); | ||
874 | if (!local->int_scan_req) | ||
875 | return -ENOMEM; | ||
876 | |||
877 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { | ||
878 | if (!local->hw.wiphy->bands[band]) | ||
879 | continue; | ||
880 | local->int_scan_req->rates[band] = (u32) -1; | ||
881 | } | ||
882 | |||
883 | #ifndef CONFIG_MAC80211_MESH | 883 | #ifndef CONFIG_MAC80211_MESH |
884 | /* mesh depends on Kconfig, but drivers should set it if they want */ | 884 | /* mesh depends on Kconfig, but drivers should set it if they want */ |
885 | local->hw.wiphy->interface_modes &= ~BIT(NL80211_IFTYPE_MESH_POINT); | 885 | local->hw.wiphy->interface_modes &= ~BIT(NL80211_IFTYPE_MESH_POINT); |
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index 5a74b249ba35..5b919cab1de0 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
@@ -807,6 +807,7 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata) | |||
807 | return -ENOMEM; | 807 | return -ENOMEM; |
808 | } | 808 | } |
809 | 809 | ||
810 | ieee80211_recalc_dtim(local, sdata); | ||
810 | ieee80211_bss_info_change_notify(sdata, changed); | 811 | ieee80211_bss_info_change_notify(sdata, changed); |
811 | 812 | ||
812 | netif_carrier_on(sdata->dev); | 813 | netif_carrier_on(sdata->dev); |
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index cf83217103f9..e8f60aa2e848 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c | |||
@@ -437,6 +437,7 @@ __mesh_sta_info_alloc(struct ieee80211_sub_if_data *sdata, u8 *hw_addr) | |||
437 | sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED); | 437 | sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED); |
438 | 438 | ||
439 | set_sta_flag(sta, WLAN_STA_WME); | 439 | set_sta_flag(sta, WLAN_STA_WME); |
440 | sta->sta.wme = true; | ||
440 | 441 | ||
441 | return sta; | 442 | return sta; |
442 | } | 443 | } |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 5a2afe9583a8..c24ca0d0f469 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -3076,8 +3076,8 @@ void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid) | |||
3076 | 3076 | ||
3077 | /* main receive path */ | 3077 | /* main receive path */ |
3078 | 3078 | ||
3079 | static int prepare_for_handlers(struct ieee80211_rx_data *rx, | 3079 | static bool prepare_for_handlers(struct ieee80211_rx_data *rx, |
3080 | struct ieee80211_hdr *hdr) | 3080 | struct ieee80211_hdr *hdr) |
3081 | { | 3081 | { |
3082 | struct ieee80211_sub_if_data *sdata = rx->sdata; | 3082 | struct ieee80211_sub_if_data *sdata = rx->sdata; |
3083 | struct sk_buff *skb = rx->skb; | 3083 | struct sk_buff *skb = rx->skb; |
@@ -3088,29 +3088,29 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx, | |||
3088 | switch (sdata->vif.type) { | 3088 | switch (sdata->vif.type) { |
3089 | case NL80211_IFTYPE_STATION: | 3089 | case NL80211_IFTYPE_STATION: |
3090 | if (!bssid && !sdata->u.mgd.use_4addr) | 3090 | if (!bssid && !sdata->u.mgd.use_4addr) |
3091 | return 0; | 3091 | return false; |
3092 | if (!multicast && | 3092 | if (!multicast && |
3093 | !ether_addr_equal(sdata->vif.addr, hdr->addr1)) { | 3093 | !ether_addr_equal(sdata->vif.addr, hdr->addr1)) { |
3094 | if (!(sdata->dev->flags & IFF_PROMISC) || | 3094 | if (!(sdata->dev->flags & IFF_PROMISC) || |
3095 | sdata->u.mgd.use_4addr) | 3095 | sdata->u.mgd.use_4addr) |
3096 | return 0; | 3096 | return false; |
3097 | status->rx_flags &= ~IEEE80211_RX_RA_MATCH; | 3097 | status->rx_flags &= ~IEEE80211_RX_RA_MATCH; |
3098 | } | 3098 | } |
3099 | break; | 3099 | break; |
3100 | case NL80211_IFTYPE_ADHOC: | 3100 | case NL80211_IFTYPE_ADHOC: |
3101 | if (!bssid) | 3101 | if (!bssid) |
3102 | return 0; | 3102 | return false; |
3103 | if (ether_addr_equal(sdata->vif.addr, hdr->addr2) || | 3103 | if (ether_addr_equal(sdata->vif.addr, hdr->addr2) || |
3104 | ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2)) | 3104 | ether_addr_equal(sdata->u.ibss.bssid, hdr->addr2)) |
3105 | return 0; | 3105 | return false; |
3106 | if (ieee80211_is_beacon(hdr->frame_control)) { | 3106 | if (ieee80211_is_beacon(hdr->frame_control)) { |
3107 | return 1; | 3107 | return true; |
3108 | } else if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid)) { | 3108 | } else if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid)) { |
3109 | return 0; | 3109 | return false; |
3110 | } else if (!multicast && | 3110 | } else if (!multicast && |
3111 | !ether_addr_equal(sdata->vif.addr, hdr->addr1)) { | 3111 | !ether_addr_equal(sdata->vif.addr, hdr->addr1)) { |
3112 | if (!(sdata->dev->flags & IFF_PROMISC)) | 3112 | if (!(sdata->dev->flags & IFF_PROMISC)) |
3113 | return 0; | 3113 | return false; |
3114 | status->rx_flags &= ~IEEE80211_RX_RA_MATCH; | 3114 | status->rx_flags &= ~IEEE80211_RX_RA_MATCH; |
3115 | } else if (!rx->sta) { | 3115 | } else if (!rx->sta) { |
3116 | int rate_idx; | 3116 | int rate_idx; |
@@ -3126,7 +3126,7 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx, | |||
3126 | if (!multicast && | 3126 | if (!multicast && |
3127 | !ether_addr_equal(sdata->vif.addr, hdr->addr1)) { | 3127 | !ether_addr_equal(sdata->vif.addr, hdr->addr1)) { |
3128 | if (!(sdata->dev->flags & IFF_PROMISC)) | 3128 | if (!(sdata->dev->flags & IFF_PROMISC)) |
3129 | return 0; | 3129 | return false; |
3130 | 3130 | ||
3131 | status->rx_flags &= ~IEEE80211_RX_RA_MATCH; | 3131 | status->rx_flags &= ~IEEE80211_RX_RA_MATCH; |
3132 | } | 3132 | } |
@@ -3135,7 +3135,7 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx, | |||
3135 | case NL80211_IFTYPE_AP: | 3135 | case NL80211_IFTYPE_AP: |
3136 | if (!bssid) { | 3136 | if (!bssid) { |
3137 | if (!ether_addr_equal(sdata->vif.addr, hdr->addr1)) | 3137 | if (!ether_addr_equal(sdata->vif.addr, hdr->addr1)) |
3138 | return 0; | 3138 | return false; |
3139 | } else if (!ieee80211_bssid_match(bssid, sdata->vif.addr)) { | 3139 | } else if (!ieee80211_bssid_match(bssid, sdata->vif.addr)) { |
3140 | /* | 3140 | /* |
3141 | * Accept public action frames even when the | 3141 | * Accept public action frames even when the |
@@ -3145,26 +3145,26 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx, | |||
3145 | */ | 3145 | */ |
3146 | if (!multicast && | 3146 | if (!multicast && |
3147 | !ether_addr_equal(sdata->vif.addr, hdr->addr1)) | 3147 | !ether_addr_equal(sdata->vif.addr, hdr->addr1)) |
3148 | return 0; | 3148 | return false; |
3149 | if (ieee80211_is_public_action(hdr, skb->len)) | 3149 | if (ieee80211_is_public_action(hdr, skb->len)) |
3150 | return 1; | 3150 | return true; |
3151 | if (!ieee80211_is_beacon(hdr->frame_control)) | 3151 | if (!ieee80211_is_beacon(hdr->frame_control)) |
3152 | return 0; | 3152 | return false; |
3153 | status->rx_flags &= ~IEEE80211_RX_RA_MATCH; | 3153 | status->rx_flags &= ~IEEE80211_RX_RA_MATCH; |
3154 | } | 3154 | } |
3155 | break; | 3155 | break; |
3156 | case NL80211_IFTYPE_WDS: | 3156 | case NL80211_IFTYPE_WDS: |
3157 | if (bssid || !ieee80211_is_data(hdr->frame_control)) | 3157 | if (bssid || !ieee80211_is_data(hdr->frame_control)) |
3158 | return 0; | 3158 | return false; |
3159 | if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2)) | 3159 | if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2)) |
3160 | return 0; | 3160 | return false; |
3161 | break; | 3161 | break; |
3162 | case NL80211_IFTYPE_P2P_DEVICE: | 3162 | case NL80211_IFTYPE_P2P_DEVICE: |
3163 | if (!ieee80211_is_public_action(hdr, skb->len) && | 3163 | if (!ieee80211_is_public_action(hdr, skb->len) && |
3164 | !ieee80211_is_probe_req(hdr->frame_control) && | 3164 | !ieee80211_is_probe_req(hdr->frame_control) && |
3165 | !ieee80211_is_probe_resp(hdr->frame_control) && | 3165 | !ieee80211_is_probe_resp(hdr->frame_control) && |
3166 | !ieee80211_is_beacon(hdr->frame_control)) | 3166 | !ieee80211_is_beacon(hdr->frame_control)) |
3167 | return 0; | 3167 | return false; |
3168 | if (!ether_addr_equal(sdata->vif.addr, hdr->addr1) && | 3168 | if (!ether_addr_equal(sdata->vif.addr, hdr->addr1) && |
3169 | !multicast) | 3169 | !multicast) |
3170 | status->rx_flags &= ~IEEE80211_RX_RA_MATCH; | 3170 | status->rx_flags &= ~IEEE80211_RX_RA_MATCH; |
@@ -3175,7 +3175,7 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx, | |||
3175 | break; | 3175 | break; |
3176 | } | 3176 | } |
3177 | 3177 | ||
3178 | return 1; | 3178 | return true; |
3179 | } | 3179 | } |
3180 | 3180 | ||
3181 | /* | 3181 | /* |
@@ -3191,13 +3191,11 @@ static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx, | |||
3191 | struct ieee80211_sub_if_data *sdata = rx->sdata; | 3191 | struct ieee80211_sub_if_data *sdata = rx->sdata; |
3192 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); | 3192 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); |
3193 | struct ieee80211_hdr *hdr = (void *)skb->data; | 3193 | struct ieee80211_hdr *hdr = (void *)skb->data; |
3194 | int prepares; | ||
3195 | 3194 | ||
3196 | rx->skb = skb; | 3195 | rx->skb = skb; |
3197 | status->rx_flags |= IEEE80211_RX_RA_MATCH; | 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 | return false; | 3199 | return false; |
3202 | 3200 | ||
3203 | if (!consume) { | 3201 | if (!consume) { |
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 4576ba0ff221..decd30c1e290 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c | |||
@@ -300,6 +300,35 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata, | |||
300 | if (!sta) | 300 | if (!sta) |
301 | return NULL; | 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 | spin_lock_init(&sta->lock); | 332 | spin_lock_init(&sta->lock); |
304 | INIT_WORK(&sta->drv_unblock_wk, sta_unblock); | 333 | INIT_WORK(&sta->drv_unblock_wk, sta_unblock); |
305 | INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work); | 334 | INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work); |
@@ -324,10 +353,8 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata, | |||
324 | for (i = 0; i < ARRAY_SIZE(sta->chain_signal_avg); i++) | 353 | for (i = 0; i < ARRAY_SIZE(sta->chain_signal_avg); i++) |
325 | ewma_init(&sta->chain_signal_avg[i], 1024, 8); | 354 | ewma_init(&sta->chain_signal_avg[i], 1024, 8); |
326 | 355 | ||
327 | if (sta_prepare_rate_control(local, sta, gfp)) { | 356 | if (sta_prepare_rate_control(local, sta, gfp)) |
328 | kfree(sta); | 357 | goto free; |
329 | return NULL; | ||
330 | } | ||
331 | 358 | ||
332 | for (i = 0; i < IEEE80211_NUM_TIDS; i++) { | 359 | for (i = 0; i < IEEE80211_NUM_TIDS; i++) { |
333 | /* | 360 | /* |
@@ -371,34 +398,17 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata, | |||
371 | } | 398 | } |
372 | } | 399 | } |
373 | 400 | ||
374 | rcu_read_lock(); | ||
375 | |||
376 | tx_latency = rcu_dereference(local->tx_latency); | ||
377 | /* init stations Tx latency statistics && TID bins */ | ||
378 | if (tx_latency) | ||
379 | sta->tx_lat = kzalloc(IEEE80211_NUM_TIDS * | ||
380 | sizeof(struct ieee80211_tx_latency_stat), | ||
381 | GFP_ATOMIC); | ||
382 | |||
383 | /* | ||
384 | * if Tx latency and bins are enabled and the previous allocation | ||
385 | * succeeded | ||
386 | */ | ||
387 | if (tx_latency && tx_latency->n_ranges && sta->tx_lat) | ||
388 | for (i = 0; i < IEEE80211_NUM_TIDS; i++) { | ||
389 | /* size of bins is size of the ranges +1 */ | ||
390 | sta->tx_lat[i].bin_count = | ||
391 | tx_latency->n_ranges + 1; | ||
392 | sta->tx_lat[i].bins = kcalloc(sta->tx_lat[i].bin_count, | ||
393 | sizeof(u32), | ||
394 | GFP_ATOMIC); | ||
395 | } | ||
396 | |||
397 | rcu_read_unlock(); | ||
398 | |||
399 | sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr); | 401 | sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr); |
400 | |||
401 | return sta; | 402 | return sta; |
403 | |||
404 | free: | ||
405 | if (sta->tx_lat) { | ||
406 | for (i = 0; i < IEEE80211_NUM_TIDS; i++) | ||
407 | kfree(sta->tx_lat[i].bins); | ||
408 | kfree(sta->tx_lat); | ||
409 | } | ||
410 | kfree(sta); | ||
411 | return NULL; | ||
402 | } | 412 | } |
403 | 413 | ||
404 | static int sta_info_insert_check(struct sta_info *sta) | 414 | static int sta_info_insert_check(struct sta_info *sta) |
@@ -1143,7 +1153,8 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta) | |||
1143 | 1153 | ||
1144 | static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata, | 1154 | static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata, |
1145 | struct sta_info *sta, int tid, | 1155 | struct sta_info *sta, int tid, |
1146 | enum ieee80211_frame_release_type reason) | 1156 | enum ieee80211_frame_release_type reason, |
1157 | bool call_driver) | ||
1147 | { | 1158 | { |
1148 | struct ieee80211_local *local = sdata->local; | 1159 | struct ieee80211_local *local = sdata->local; |
1149 | struct ieee80211_qos_hdr *nullfunc; | 1160 | struct ieee80211_qos_hdr *nullfunc; |
@@ -1201,7 +1212,9 @@ static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata, | |||
1201 | IEEE80211_TX_STATUS_EOSP | | 1212 | IEEE80211_TX_STATUS_EOSP | |
1202 | IEEE80211_TX_CTL_REQ_TX_STATUS; | 1213 | IEEE80211_TX_CTL_REQ_TX_STATUS; |
1203 | 1214 | ||
1204 | drv_allow_buffered_frames(local, sta, BIT(tid), 1, reason, false); | 1215 | if (call_driver) |
1216 | drv_allow_buffered_frames(local, sta, BIT(tid), 1, | ||
1217 | reason, false); | ||
1205 | 1218 | ||
1206 | skb->dev = sdata->dev; | 1219 | skb->dev = sdata->dev; |
1207 | 1220 | ||
@@ -1217,6 +1230,17 @@ static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata, | |||
1217 | rcu_read_unlock(); | 1230 | rcu_read_unlock(); |
1218 | } | 1231 | } |
1219 | 1232 | ||
1233 | static int find_highest_prio_tid(unsigned long tids) | ||
1234 | { | ||
1235 | /* lower 3 TIDs aren't ordered perfectly */ | ||
1236 | if (tids & 0xF8) | ||
1237 | return fls(tids) - 1; | ||
1238 | /* TID 0 is BE just like TID 3 */ | ||
1239 | if (tids & BIT(0)) | ||
1240 | return 0; | ||
1241 | return fls(tids) - 1; | ||
1242 | } | ||
1243 | |||
1220 | static void | 1244 | static void |
1221 | ieee80211_sta_ps_deliver_response(struct sta_info *sta, | 1245 | ieee80211_sta_ps_deliver_response(struct sta_info *sta, |
1222 | int n_frames, u8 ignored_acs, | 1246 | int n_frames, u8 ignored_acs, |
@@ -1224,7 +1248,6 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta, | |||
1224 | { | 1248 | { |
1225 | struct ieee80211_sub_if_data *sdata = sta->sdata; | 1249 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
1226 | struct ieee80211_local *local = sdata->local; | 1250 | struct ieee80211_local *local = sdata->local; |
1227 | bool found = false; | ||
1228 | bool more_data = false; | 1251 | bool more_data = false; |
1229 | int ac; | 1252 | int ac; |
1230 | unsigned long driver_release_tids = 0; | 1253 | unsigned long driver_release_tids = 0; |
@@ -1235,9 +1258,7 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta, | |||
1235 | 1258 | ||
1236 | __skb_queue_head_init(&frames); | 1259 | __skb_queue_head_init(&frames); |
1237 | 1260 | ||
1238 | /* | 1261 | /* Get response frame(s) and more data bit for the last one. */ |
1239 | * Get response frame(s) and more data bit for it. | ||
1240 | */ | ||
1241 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { | 1262 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { |
1242 | unsigned long tids; | 1263 | unsigned long tids; |
1243 | 1264 | ||
@@ -1246,43 +1267,48 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta, | |||
1246 | 1267 | ||
1247 | tids = ieee80211_tids_for_ac(ac); | 1268 | tids = ieee80211_tids_for_ac(ac); |
1248 | 1269 | ||
1249 | if (!found) { | 1270 | /* if we already have frames from software, then we can't also |
1250 | driver_release_tids = sta->driver_buffered_tids & tids; | 1271 | * release from hardware queues |
1251 | if (driver_release_tids) { | 1272 | */ |
1252 | found = true; | 1273 | if (skb_queue_empty(&frames)) |
1253 | } else { | 1274 | driver_release_tids |= sta->driver_buffered_tids & tids; |
1254 | struct sk_buff *skb; | ||
1255 | |||
1256 | while (n_frames > 0) { | ||
1257 | skb = skb_dequeue(&sta->tx_filtered[ac]); | ||
1258 | if (!skb) { | ||
1259 | skb = skb_dequeue( | ||
1260 | &sta->ps_tx_buf[ac]); | ||
1261 | if (skb) | ||
1262 | local->total_ps_buffered--; | ||
1263 | } | ||
1264 | if (!skb) | ||
1265 | break; | ||
1266 | n_frames--; | ||
1267 | found = true; | ||
1268 | __skb_queue_tail(&frames, skb); | ||
1269 | } | ||
1270 | } | ||
1271 | 1275 | ||
1272 | /* | 1276 | if (driver_release_tids) { |
1273 | * If the driver has data on more than one TID then | 1277 | /* If the driver has data on more than one TID then |
1274 | * certainly there's more data if we release just a | 1278 | * certainly there's more data if we release just a |
1275 | * single frame now (from a single TID). | 1279 | * single frame now (from a single TID). This will |
1280 | * only happen for PS-Poll. | ||
1276 | */ | 1281 | */ |
1277 | if (reason == IEEE80211_FRAME_RELEASE_PSPOLL && | 1282 | if (reason == IEEE80211_FRAME_RELEASE_PSPOLL && |
1278 | hweight16(driver_release_tids) > 1) { | 1283 | hweight16(driver_release_tids) > 1) { |
1279 | more_data = true; | 1284 | more_data = true; |
1280 | driver_release_tids = | 1285 | driver_release_tids = |
1281 | BIT(ffs(driver_release_tids) - 1); | 1286 | BIT(find_highest_prio_tid( |
1287 | driver_release_tids)); | ||
1282 | break; | 1288 | break; |
1283 | } | 1289 | } |
1290 | } else { | ||
1291 | struct sk_buff *skb; | ||
1292 | |||
1293 | while (n_frames > 0) { | ||
1294 | skb = skb_dequeue(&sta->tx_filtered[ac]); | ||
1295 | if (!skb) { | ||
1296 | skb = skb_dequeue( | ||
1297 | &sta->ps_tx_buf[ac]); | ||
1298 | if (skb) | ||
1299 | local->total_ps_buffered--; | ||
1300 | } | ||
1301 | if (!skb) | ||
1302 | break; | ||
1303 | n_frames--; | ||
1304 | __skb_queue_tail(&frames, skb); | ||
1305 | } | ||
1284 | } | 1306 | } |
1285 | 1307 | ||
1308 | /* If we have more frames buffered on this AC, then set the | ||
1309 | * more-data bit and abort the loop since we can't send more | ||
1310 | * data from other ACs before the buffered frames from this. | ||
1311 | */ | ||
1286 | if (!skb_queue_empty(&sta->tx_filtered[ac]) || | 1312 | if (!skb_queue_empty(&sta->tx_filtered[ac]) || |
1287 | !skb_queue_empty(&sta->ps_tx_buf[ac])) { | 1313 | !skb_queue_empty(&sta->ps_tx_buf[ac])) { |
1288 | more_data = true; | 1314 | more_data = true; |
@@ -1290,7 +1316,7 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta, | |||
1290 | } | 1316 | } |
1291 | } | 1317 | } |
1292 | 1318 | ||
1293 | if (!found) { | 1319 | if (skb_queue_empty(&frames) && !driver_release_tids) { |
1294 | int tid; | 1320 | int tid; |
1295 | 1321 | ||
1296 | /* | 1322 | /* |
@@ -1311,15 +1337,13 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta, | |||
1311 | /* This will evaluate to 1, 3, 5 or 7. */ | 1337 | /* This will evaluate to 1, 3, 5 or 7. */ |
1312 | tid = 7 - ((ffs(~ignored_acs) - 1) << 1); | 1338 | tid = 7 - ((ffs(~ignored_acs) - 1) << 1); |
1313 | 1339 | ||
1314 | ieee80211_send_null_response(sdata, sta, tid, reason); | 1340 | ieee80211_send_null_response(sdata, sta, tid, reason, true); |
1315 | return; | 1341 | } else if (!driver_release_tids) { |
1316 | } | ||
1317 | |||
1318 | if (!driver_release_tids) { | ||
1319 | struct sk_buff_head pending; | 1342 | struct sk_buff_head pending; |
1320 | struct sk_buff *skb; | 1343 | struct sk_buff *skb; |
1321 | int num = 0; | 1344 | int num = 0; |
1322 | u16 tids = 0; | 1345 | u16 tids = 0; |
1346 | bool need_null = false; | ||
1323 | 1347 | ||
1324 | skb_queue_head_init(&pending); | 1348 | skb_queue_head_init(&pending); |
1325 | 1349 | ||
@@ -1353,22 +1377,57 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta, | |||
1353 | ieee80211_is_qos_nullfunc(hdr->frame_control)) | 1377 | ieee80211_is_qos_nullfunc(hdr->frame_control)) |
1354 | qoshdr = ieee80211_get_qos_ctl(hdr); | 1378 | qoshdr = ieee80211_get_qos_ctl(hdr); |
1355 | 1379 | ||
1356 | /* end service period after last frame */ | 1380 | tids |= BIT(skb->priority); |
1357 | if (skb_queue_empty(&frames)) { | 1381 | |
1358 | if (reason == IEEE80211_FRAME_RELEASE_UAPSD && | 1382 | __skb_queue_tail(&pending, skb); |
1359 | qoshdr) | 1383 | |
1360 | *qoshdr |= IEEE80211_QOS_CTL_EOSP; | 1384 | /* end service period after last frame or add one */ |
1385 | if (!skb_queue_empty(&frames)) | ||
1386 | continue; | ||
1361 | 1387 | ||
1388 | if (reason != IEEE80211_FRAME_RELEASE_UAPSD) { | ||
1389 | /* for PS-Poll, there's only one frame */ | ||
1362 | info->flags |= IEEE80211_TX_STATUS_EOSP | | 1390 | info->flags |= IEEE80211_TX_STATUS_EOSP | |
1363 | IEEE80211_TX_CTL_REQ_TX_STATUS; | 1391 | IEEE80211_TX_CTL_REQ_TX_STATUS; |
1392 | break; | ||
1364 | } | 1393 | } |
1365 | 1394 | ||
1366 | if (qoshdr) | 1395 | /* For uAPSD, things are a bit more complicated. If the |
1367 | tids |= BIT(*qoshdr & IEEE80211_QOS_CTL_TID_MASK); | 1396 | * last frame has a QoS header (i.e. is a QoS-data or |
1368 | else | 1397 | * QoS-nulldata frame) then just set the EOSP bit there |
1369 | tids |= BIT(0); | 1398 | * and be done. |
1399 | * If the frame doesn't have a QoS header (which means | ||
1400 | * it should be a bufferable MMPDU) then we can't set | ||
1401 | * the EOSP bit in the QoS header; add a QoS-nulldata | ||
1402 | * frame to the list to send it after the MMPDU. | ||
1403 | * | ||
1404 | * Note that this code is only in the mac80211-release | ||
1405 | * code path, we assume that the driver will not buffer | ||
1406 | * anything but QoS-data frames, or if it does, will | ||
1407 | * create the QoS-nulldata frame by itself if needed. | ||
1408 | * | ||
1409 | * Cf. 802.11-2012 10.2.1.10 (c). | ||
1410 | */ | ||
1411 | if (qoshdr) { | ||
1412 | *qoshdr |= IEEE80211_QOS_CTL_EOSP; | ||
1370 | 1413 | ||
1371 | __skb_queue_tail(&pending, skb); | 1414 | info->flags |= IEEE80211_TX_STATUS_EOSP | |
1415 | IEEE80211_TX_CTL_REQ_TX_STATUS; | ||
1416 | } else { | ||
1417 | /* The standard isn't completely clear on this | ||
1418 | * as it says the more-data bit should be set | ||
1419 | * if there are more BUs. The QoS-Null frame | ||
1420 | * we're about to send isn't buffered yet, we | ||
1421 | * only create it below, but let's pretend it | ||
1422 | * was buffered just in case some clients only | ||
1423 | * expect more-data=0 when eosp=1. | ||
1424 | */ | ||
1425 | hdr->frame_control |= | ||
1426 | cpu_to_le16(IEEE80211_FCTL_MOREDATA); | ||
1427 | need_null = true; | ||
1428 | num++; | ||
1429 | } | ||
1430 | break; | ||
1372 | } | 1431 | } |
1373 | 1432 | ||
1374 | drv_allow_buffered_frames(local, sta, tids, num, | 1433 | drv_allow_buffered_frames(local, sta, tids, num, |
@@ -1376,17 +1435,22 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta, | |||
1376 | 1435 | ||
1377 | ieee80211_add_pending_skbs(local, &pending); | 1436 | ieee80211_add_pending_skbs(local, &pending); |
1378 | 1437 | ||
1438 | if (need_null) | ||
1439 | ieee80211_send_null_response( | ||
1440 | sdata, sta, find_highest_prio_tid(tids), | ||
1441 | reason, false); | ||
1442 | |||
1379 | sta_info_recalc_tim(sta); | 1443 | sta_info_recalc_tim(sta); |
1380 | } else { | 1444 | } else { |
1381 | /* | 1445 | /* |
1382 | * We need to release a frame that is buffered somewhere in the | 1446 | * We need to release a frame that is buffered somewhere in the |
1383 | * driver ... it'll have to handle that. | 1447 | * driver ... it'll have to handle that. |
1384 | * Note that, as per the comment above, it'll also have to see | 1448 | * Note that the driver also has to check the number of frames |
1385 | * if there is more than just one frame on the specific TID that | 1449 | * on the TIDs we're releasing from - if there are more than |
1386 | * we're releasing from, and it needs to set the more-data bit | 1450 | * n_frames it has to set the more-data bit (if we didn't ask |
1387 | * accordingly if we tell it that there's no more data. If we do | 1451 | * it to set it anyway due to other buffered frames); if there |
1388 | * tell it there's more data, then of course the more-data bit | 1452 | * are fewer than n_frames it has to make sure to adjust that |
1389 | * needs to be set anyway. | 1453 | * to allow the service period to end properly. |
1390 | */ | 1454 | */ |
1391 | drv_release_buffered_frames(local, sta, driver_release_tids, | 1455 | drv_release_buffered_frames(local, sta, driver_release_tids, |
1392 | n_frames, reason, more_data); | 1456 | n_frames, reason, more_data); |
@@ -1394,9 +1458,9 @@ ieee80211_sta_ps_deliver_response(struct sta_info *sta, | |||
1394 | /* | 1458 | /* |
1395 | * Note that we don't recalculate the TIM bit here as it would | 1459 | * Note that we don't recalculate the TIM bit here as it would |
1396 | * most likely have no effect at all unless the driver told us | 1460 | * most likely have no effect at all unless the driver told us |
1397 | * that the TID became empty before returning here from the | 1461 | * that the TID(s) became empty before returning here from the |
1398 | * release function. | 1462 | * release function. |
1399 | * Either way, however, when the driver tells us that the TID | 1463 | * Either way, however, when the driver tells us that the TID(s) |
1400 | * became empty we'll do the TIM recalculation. | 1464 | * became empty we'll do the TIM recalculation. |
1401 | */ | 1465 | */ |
1402 | } | 1466 | } |
@@ -1485,6 +1549,8 @@ void ieee80211_sta_set_buffered(struct ieee80211_sta *pubsta, | |||
1485 | if (WARN_ON(tid >= IEEE80211_NUM_TIDS)) | 1549 | if (WARN_ON(tid >= IEEE80211_NUM_TIDS)) |
1486 | return; | 1550 | return; |
1487 | 1551 | ||
1552 | trace_api_sta_set_buffered(sta->local, pubsta, tid, buffered); | ||
1553 | |||
1488 | if (buffered) | 1554 | if (buffered) |
1489 | set_bit(tid, &sta->driver_buffered_tids); | 1555 | set_bit(tid, &sta->driver_buffered_tids); |
1490 | else | 1556 | else |
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h index da9366632f37..a0b0aea76525 100644 --- a/net/mac80211/trace.h +++ b/net/mac80211/trace.h | |||
@@ -1835,6 +1835,33 @@ TRACE_EVENT(api_eosp, | |||
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 | * Tracing for internal functions | 1866 | * Tracing for internal functions |
1840 | * (which may also be called in response to driver calls) | 1867 | * (which may also be called in response to driver calls) |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 377cf974d97d..9f3cbf14989b 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -500,6 +500,7 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) | |||
500 | info->control.jiffies = jiffies; | 500 | info->control.jiffies = jiffies; |
501 | info->control.vif = &tx->sdata->vif; | 501 | info->control.vif = &tx->sdata->vif; |
502 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; | 502 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; |
503 | info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; | ||
503 | skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb); | 504 | skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb); |
504 | 505 | ||
505 | if (!timer_pending(&local->sta_cleanup)) | 506 | if (!timer_pending(&local->sta_cleanup)) |
@@ -1073,6 +1074,7 @@ static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx, | |||
1073 | queued = true; | 1074 | queued = true; |
1074 | info->control.vif = &tx->sdata->vif; | 1075 | info->control.vif = &tx->sdata->vif; |
1075 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; | 1076 | info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; |
1077 | info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; | ||
1076 | __skb_queue_tail(&tid_tx->pending, skb); | 1078 | __skb_queue_tail(&tid_tx->pending, skb); |
1077 | if (skb_queue_len(&tid_tx->pending) > STA_MAX_TX_BUFFER) | 1079 | if (skb_queue_len(&tid_tx->pending) > STA_MAX_TX_BUFFER) |
1078 | purge_skb = __skb_dequeue(&tid_tx->pending); | 1080 | purge_skb = __skb_dequeue(&tid_tx->pending); |
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index df00f1978a77..676dc0967f37 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -2734,3 +2734,44 @@ int ieee80211_parse_p2p_noa(const struct ieee80211_p2p_noa_attr *attr, | |||
2734 | return ret; | 2734 | return ret; |
2735 | } | 2735 | } |
2736 | EXPORT_SYMBOL(ieee80211_parse_p2p_noa); | 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 | } | ||
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c index 7313d379c0d3..21448d629b15 100644 --- a/net/mac80211/wpa.c +++ b/net/mac80211/wpa.c | |||
@@ -127,7 +127,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx) | |||
127 | * APs with pairwise keys should never receive Michael MIC | 127 | * APs with pairwise keys should never receive Michael MIC |
128 | * errors for non-zero keyidx because these are reserved for | 128 | * errors for non-zero keyidx because these are reserved for |
129 | * group keys and only the AP is sending real multicast | 129 | * group keys and only the AP is sending real multicast |
130 | * frames in the BSS. ( | 130 | * frames in the BSS. |
131 | */ | 131 | */ |
132 | return RX_DROP_UNUSABLE; | 132 | return RX_DROP_UNUSABLE; |
133 | } | 133 | } |
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index b4f40fe84a01..d0afd82ebd77 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -5285,12 +5285,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) | |||
5285 | goto unlock; | 5285 | goto unlock; |
5286 | } | 5286 | } |
5287 | } else { | 5287 | } else { |
5288 | enum ieee80211_band band; | 5288 | n_channels = ieee80211_get_num_supported_channels(wiphy); |
5289 | n_channels = 0; | ||
5290 | |||
5291 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) | ||
5292 | if (wiphy->bands[band]) | ||
5293 | n_channels += wiphy->bands[band]->n_channels; | ||
5294 | } | 5289 | } |
5295 | 5290 | ||
5296 | if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) | 5291 | if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) |
@@ -5498,11 +5493,7 @@ static int nl80211_start_sched_scan(struct sk_buff *skb, | |||
5498 | if (!n_channels) | 5493 | if (!n_channels) |
5499 | return -EINVAL; | 5494 | return -EINVAL; |
5500 | } else { | 5495 | } else { |
5501 | n_channels = 0; | 5496 | n_channels = ieee80211_get_num_supported_channels(wiphy); |
5502 | |||
5503 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) | ||
5504 | if (wiphy->bands[band]) | ||
5505 | n_channels += wiphy->bands[band]->n_channels; | ||
5506 | } | 5497 | } |
5507 | 5498 | ||
5508 | if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) | 5499 | if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) |
@@ -6795,6 +6786,55 @@ __cfg80211_alloc_vendor_skb(struct cfg80211_registered_device *rdev, | |||
6795 | return NULL; | 6786 | return NULL; |
6796 | } | 6787 | } |
6797 | 6788 | ||
6789 | struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy, | ||
6790 | enum nl80211_commands cmd, | ||
6791 | enum nl80211_attrs attr, | ||
6792 | int vendor_event_idx, | ||
6793 | int approxlen, gfp_t gfp) | ||
6794 | { | ||
6795 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | ||
6796 | const struct nl80211_vendor_cmd_info *info; | ||
6797 | |||
6798 | switch (cmd) { | ||
6799 | case NL80211_CMD_TESTMODE: | ||
6800 | if (WARN_ON(vendor_event_idx != -1)) | ||
6801 | return NULL; | ||
6802 | info = NULL; | ||
6803 | break; | ||
6804 | case NL80211_CMD_VENDOR: | ||
6805 | if (WARN_ON(vendor_event_idx < 0 || | ||
6806 | vendor_event_idx >= wiphy->n_vendor_events)) | ||
6807 | return NULL; | ||
6808 | info = &wiphy->vendor_events[vendor_event_idx]; | ||
6809 | break; | ||
6810 | default: | ||
6811 | WARN_ON(1); | ||
6812 | return NULL; | ||
6813 | } | ||
6814 | |||
6815 | return __cfg80211_alloc_vendor_skb(rdev, approxlen, 0, 0, | ||
6816 | cmd, attr, info, gfp); | ||
6817 | } | ||
6818 | EXPORT_SYMBOL(__cfg80211_alloc_event_skb); | ||
6819 | |||
6820 | void __cfg80211_send_event_skb(struct sk_buff *skb, gfp_t gfp) | ||
6821 | { | ||
6822 | struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0]; | ||
6823 | void *hdr = ((void **)skb->cb)[1]; | ||
6824 | struct nlattr *data = ((void **)skb->cb)[2]; | ||
6825 | enum nl80211_multicast_groups mcgrp = NL80211_MCGRP_TESTMODE; | ||
6826 | |||
6827 | nla_nest_end(skb, data); | ||
6828 | genlmsg_end(skb, hdr); | ||
6829 | |||
6830 | if (data->nla_type == NL80211_ATTR_VENDOR_DATA) | ||
6831 | mcgrp = NL80211_MCGRP_VENDOR; | ||
6832 | |||
6833 | genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), skb, 0, | ||
6834 | mcgrp, gfp); | ||
6835 | } | ||
6836 | EXPORT_SYMBOL(__cfg80211_send_event_skb); | ||
6837 | |||
6798 | #ifdef CONFIG_NL80211_TESTMODE | 6838 | #ifdef CONFIG_NL80211_TESTMODE |
6799 | static int nl80211_testmode_do(struct sk_buff *skb, struct genl_info *info) | 6839 | static int nl80211_testmode_do(struct sk_buff *skb, struct genl_info *info) |
6800 | { | 6840 | { |
@@ -6921,55 +6961,6 @@ static int nl80211_testmode_dump(struct sk_buff *skb, | |||
6921 | rtnl_unlock(); | 6961 | rtnl_unlock(); |
6922 | return err; | 6962 | return err; |
6923 | } | 6963 | } |
6924 | |||
6925 | struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy, | ||
6926 | enum nl80211_commands cmd, | ||
6927 | enum nl80211_attrs attr, | ||
6928 | int vendor_event_idx, | ||
6929 | int approxlen, gfp_t gfp) | ||
6930 | { | ||
6931 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | ||
6932 | const struct nl80211_vendor_cmd_info *info; | ||
6933 | |||
6934 | switch (cmd) { | ||
6935 | case NL80211_CMD_TESTMODE: | ||
6936 | if (WARN_ON(vendor_event_idx != -1)) | ||
6937 | return NULL; | ||
6938 | info = NULL; | ||
6939 | break; | ||
6940 | case NL80211_CMD_VENDOR: | ||
6941 | if (WARN_ON(vendor_event_idx < 0 || | ||
6942 | vendor_event_idx >= wiphy->n_vendor_events)) | ||
6943 | return NULL; | ||
6944 | info = &wiphy->vendor_events[vendor_event_idx]; | ||
6945 | break; | ||
6946 | default: | ||
6947 | WARN_ON(1); | ||
6948 | return NULL; | ||
6949 | } | ||
6950 | |||
6951 | return __cfg80211_alloc_vendor_skb(rdev, approxlen, 0, 0, | ||
6952 | cmd, attr, info, gfp); | ||
6953 | } | ||
6954 | EXPORT_SYMBOL(__cfg80211_alloc_event_skb); | ||
6955 | |||
6956 | void __cfg80211_send_event_skb(struct sk_buff *skb, gfp_t gfp) | ||
6957 | { | ||
6958 | struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0]; | ||
6959 | void *hdr = ((void **)skb->cb)[1]; | ||
6960 | struct nlattr *data = ((void **)skb->cb)[2]; | ||
6961 | enum nl80211_multicast_groups mcgrp = NL80211_MCGRP_TESTMODE; | ||
6962 | |||
6963 | nla_nest_end(skb, data); | ||
6964 | genlmsg_end(skb, hdr); | ||
6965 | |||
6966 | if (data->nla_type == NL80211_ATTR_VENDOR_DATA) | ||
6967 | mcgrp = NL80211_MCGRP_VENDOR; | ||
6968 | |||
6969 | genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), skb, 0, | ||
6970 | mcgrp, gfp); | ||
6971 | } | ||
6972 | EXPORT_SYMBOL(__cfg80211_send_event_skb); | ||
6973 | #endif | 6964 | #endif |
6974 | 6965 | ||
6975 | static int nl80211_connect(struct sk_buff *skb, struct genl_info *info) | 6966 | static int nl80211_connect(struct sk_buff *skb, struct genl_info *info) |
diff --git a/net/wireless/scan.c b/net/wireless/scan.c index a32d52a04c27..b528e31da2cf 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c | |||
@@ -1089,11 +1089,8 @@ int cfg80211_wext_siwscan(struct net_device *dev, | |||
1089 | /* Determine number of channels, needed to allocate creq */ | 1089 | /* Determine number of channels, needed to allocate creq */ |
1090 | if (wreq && wreq->num_channels) | 1090 | if (wreq && wreq->num_channels) |
1091 | n_channels = wreq->num_channels; | 1091 | n_channels = wreq->num_channels; |
1092 | else { | 1092 | else |
1093 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) | 1093 | n_channels = ieee80211_get_num_supported_channels(wiphy); |
1094 | if (wiphy->bands[band]) | ||
1095 | n_channels += wiphy->bands[band]->n_channels; | ||
1096 | } | ||
1097 | 1094 | ||
1098 | creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) + | 1095 | creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) + |
1099 | n_channels * sizeof(void *), | 1096 | n_channels * sizeof(void *), |
diff --git a/net/wireless/sme.c b/net/wireless/sme.c index 5d6e7bb2fc89..a63509118508 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c | |||
@@ -70,18 +70,11 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev) | |||
70 | if (rdev->scan_req) | 70 | if (rdev->scan_req) |
71 | return -EBUSY; | 71 | return -EBUSY; |
72 | 72 | ||
73 | if (wdev->conn->params.channel) { | 73 | if (wdev->conn->params.channel) |
74 | n_channels = 1; | 74 | n_channels = 1; |
75 | } else { | 75 | else |
76 | enum ieee80211_band band; | 76 | n_channels = ieee80211_get_num_supported_channels(wdev->wiphy); |
77 | n_channels = 0; | ||
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 | request = kzalloc(sizeof(*request) + sizeof(request->ssids[0]) + | 78 | request = kzalloc(sizeof(*request) + sizeof(request->ssids[0]) + |
86 | sizeof(request->channels[0]) * n_channels, | 79 | sizeof(request->channels[0]) * n_channels, |
87 | GFP_KERNEL); | 80 | GFP_KERNEL); |
diff --git a/net/wireless/util.c b/net/wireless/util.c index 5618888853b2..d39c37104ae2 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c | |||
@@ -879,7 +879,9 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev, | |||
879 | 879 | ||
880 | dev->ieee80211_ptr->use_4addr = false; | 880 | dev->ieee80211_ptr->use_4addr = false; |
881 | dev->ieee80211_ptr->mesh_id_up_len = 0; | 881 | dev->ieee80211_ptr->mesh_id_up_len = 0; |
882 | wdev_lock(dev->ieee80211_ptr); | ||
882 | rdev_set_qos_map(rdev, dev, NULL); | 883 | rdev_set_qos_map(rdev, dev, NULL); |
884 | wdev_unlock(dev->ieee80211_ptr); | ||
883 | 885 | ||
884 | switch (otype) { | 886 | switch (otype) { |
885 | case NL80211_IFTYPE_AP: | 887 | case NL80211_IFTYPE_AP: |
@@ -1479,6 +1481,19 @@ int ieee80211_get_ratemask(struct ieee80211_supported_band *sband, | |||
1479 | return 0; | 1481 | return 0; |
1480 | } | 1482 | } |
1481 | 1483 | ||
1484 | unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy) | ||
1485 | { | ||
1486 | enum ieee80211_band band; | ||
1487 | unsigned int n_channels = 0; | ||
1488 | |||
1489 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) | ||
1490 | if (wiphy->bands[band]) | ||
1491 | n_channels += wiphy->bands[band]->n_channels; | ||
1492 | |||
1493 | return n_channels; | ||
1494 | } | ||
1495 | EXPORT_SYMBOL(ieee80211_get_num_supported_channels); | ||
1496 | |||
1482 | /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ | 1497 | /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ |
1483 | /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ | 1498 | /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ |
1484 | const unsigned char rfc1042_header[] __aligned(2) = | 1499 | const unsigned char rfc1042_header[] __aligned(2) = |
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c index e7c6e862580d..5661a54ac7ee 100644 --- a/net/wireless/wext-compat.c +++ b/net/wireless/wext-compat.c | |||
@@ -370,7 +370,7 @@ static int cfg80211_wext_siwretry(struct net_device *dev, | |||
370 | u8 oshort = wdev->wiphy->retry_short; | 370 | u8 oshort = wdev->wiphy->retry_short; |
371 | int err; | 371 | int err; |
372 | 372 | ||
373 | if (retry->disabled || | 373 | if (retry->disabled || retry->value < 1 || retry->value > 255 || |
374 | (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT) | 374 | (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT) |
375 | return -EINVAL; | 375 | return -EINVAL; |
376 | 376 | ||
@@ -412,9 +412,9 @@ int cfg80211_wext_giwretry(struct net_device *dev, | |||
412 | * First return short value, iwconfig will ask long value | 412 | * First return short value, iwconfig will ask long value |
413 | * later if needed | 413 | * later if needed |
414 | */ | 414 | */ |
415 | retry->flags |= IW_RETRY_LIMIT; | 415 | retry->flags |= IW_RETRY_LIMIT | IW_RETRY_SHORT; |
416 | retry->value = wdev->wiphy->retry_short; | 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 | retry->flags |= IW_RETRY_LONG; | 418 | retry->flags |= IW_RETRY_LONG; |
419 | 419 | ||
420 | return 0; | 420 | return 0; |