diff options
author | John W. Linville <linville@tuxdriver.com> | 2014-05-27 13:51:31 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2014-05-27 13:51:31 -0400 |
commit | 9db7cb6901740453a442e598563b576987dd471b (patch) | |
tree | e38911285b5cd9980280a92ea0e0260f6c1ef2ad /net | |
parent | 3bea8eddfebe1c61ea824dd2880d4368791edc1f (diff) | |
parent | 03c4444650969431b3a5effde4995de767e3013a (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next into for-davem
Diffstat (limited to 'net')
46 files changed, 1570 insertions, 653 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index a1e5bb7d06e8..dc4d301d3a72 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -7519,9 +7519,9 @@ int __init l2cap_init(void) | |||
7519 | l2cap_debugfs = debugfs_create_file("l2cap", 0444, bt_debugfs, | 7519 | l2cap_debugfs = debugfs_create_file("l2cap", 0444, bt_debugfs, |
7520 | NULL, &l2cap_debugfs_fops); | 7520 | NULL, &l2cap_debugfs_fops); |
7521 | 7521 | ||
7522 | debugfs_create_u16("l2cap_le_max_credits", 0466, bt_debugfs, | 7522 | debugfs_create_u16("l2cap_le_max_credits", 0644, bt_debugfs, |
7523 | &le_max_credits); | 7523 | &le_max_credits); |
7524 | debugfs_create_u16("l2cap_le_default_mps", 0466, bt_debugfs, | 7524 | debugfs_create_u16("l2cap_le_default_mps", 0644, bt_debugfs, |
7525 | &le_default_mps); | 7525 | &le_default_mps); |
7526 | 7526 | ||
7527 | bt_6lowpan_init(); | 7527 | bt_6lowpan_init(); |
diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile index 9d7d840aac6d..1e46ffa69167 100644 --- a/net/mac80211/Makefile +++ b/net/mac80211/Makefile | |||
@@ -25,7 +25,8 @@ mac80211-y := \ | |||
25 | wme.o \ | 25 | wme.o \ |
26 | event.o \ | 26 | event.o \ |
27 | chan.o \ | 27 | chan.o \ |
28 | trace.o mlme.o | 28 | trace.o mlme.o \ |
29 | tdls.o | ||
29 | 30 | ||
30 | mac80211-$(CONFIG_MAC80211_LEDS) += led.o | 31 | mac80211-$(CONFIG_MAC80211_LEDS) += led.o |
31 | mac80211-$(CONFIG_MAC80211_DEBUGFS) += \ | 32 | mac80211-$(CONFIG_MAC80211_DEBUGFS) += \ |
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 7b8d3cf89574..d7513a503be1 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -472,8 +472,10 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) | |||
472 | { | 472 | { |
473 | struct ieee80211_sub_if_data *sdata = sta->sdata; | 473 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
474 | struct ieee80211_local *local = sdata->local; | 474 | struct ieee80211_local *local = sdata->local; |
475 | struct rate_control_ref *ref = local->rate_ctrl; | ||
475 | struct timespec uptime; | 476 | struct timespec uptime; |
476 | u64 packets = 0; | 477 | u64 packets = 0; |
478 | u32 thr = 0; | ||
477 | int i, ac; | 479 | int i, ac; |
478 | 480 | ||
479 | sinfo->generation = sdata->local->sta_generation; | 481 | sinfo->generation = sdata->local->sta_generation; |
@@ -587,6 +589,17 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) | |||
587 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED); | 589 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED); |
588 | if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) | 590 | if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) |
589 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER); | 591 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER); |
592 | |||
593 | /* check if the driver has a SW RC implementation */ | ||
594 | if (ref && ref->ops->get_expected_throughput) | ||
595 | thr = ref->ops->get_expected_throughput(sta->rate_ctrl_priv); | ||
596 | else | ||
597 | thr = drv_get_expected_throughput(local, &sta->sta); | ||
598 | |||
599 | if (thr != 0) { | ||
600 | sinfo->filled |= STATION_INFO_EXPECTED_THROUGHPUT; | ||
601 | sinfo->expected_throughput = thr; | ||
602 | } | ||
590 | } | 603 | } |
591 | 604 | ||
592 | static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = { | 605 | static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = { |
@@ -777,7 +790,7 @@ static void ieee80211_get_et_strings(struct wiphy *wiphy, | |||
777 | } | 790 | } |
778 | 791 | ||
779 | static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev, | 792 | static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev, |
780 | int idx, u8 *mac, struct station_info *sinfo) | 793 | int idx, u8 *mac, struct station_info *sinfo) |
781 | { | 794 | { |
782 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 795 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
783 | struct ieee80211_local *local = sdata->local; | 796 | struct ieee80211_local *local = sdata->local; |
@@ -807,7 +820,7 @@ static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev, | |||
807 | } | 820 | } |
808 | 821 | ||
809 | static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev, | 822 | static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
810 | u8 *mac, struct station_info *sinfo) | 823 | const u8 *mac, struct station_info *sinfo) |
811 | { | 824 | { |
812 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 825 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
813 | struct ieee80211_local *local = sdata->local; | 826 | struct ieee80211_local *local = sdata->local; |
@@ -1084,6 +1097,31 @@ static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev, | |||
1084 | return 0; | 1097 | return 0; |
1085 | } | 1098 | } |
1086 | 1099 | ||
1100 | bool ieee80211_csa_needs_block_tx(struct ieee80211_local *local) | ||
1101 | { | ||
1102 | struct ieee80211_sub_if_data *sdata; | ||
1103 | |||
1104 | lockdep_assert_held(&local->mtx); | ||
1105 | |||
1106 | rcu_read_lock(); | ||
1107 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | ||
1108 | if (!ieee80211_sdata_running(sdata)) | ||
1109 | continue; | ||
1110 | |||
1111 | if (!sdata->vif.csa_active) | ||
1112 | continue; | ||
1113 | |||
1114 | if (!sdata->csa_block_tx) | ||
1115 | continue; | ||
1116 | |||
1117 | rcu_read_unlock(); | ||
1118 | return true; | ||
1119 | } | ||
1120 | rcu_read_unlock(); | ||
1121 | |||
1122 | return false; | ||
1123 | } | ||
1124 | |||
1087 | static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) | 1125 | static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) |
1088 | { | 1126 | { |
1089 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1127 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
@@ -1101,7 +1139,14 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) | |||
1101 | old_probe_resp = sdata_dereference(sdata->u.ap.probe_resp, sdata); | 1139 | old_probe_resp = sdata_dereference(sdata->u.ap.probe_resp, sdata); |
1102 | 1140 | ||
1103 | /* abort any running channel switch */ | 1141 | /* abort any running channel switch */ |
1142 | mutex_lock(&local->mtx); | ||
1104 | sdata->vif.csa_active = false; | 1143 | sdata->vif.csa_active = false; |
1144 | if (!ieee80211_csa_needs_block_tx(local)) | ||
1145 | ieee80211_wake_queues_by_reason(&local->hw, | ||
1146 | IEEE80211_MAX_QUEUE_MAP, | ||
1147 | IEEE80211_QUEUE_STOP_REASON_CSA); | ||
1148 | mutex_unlock(&local->mtx); | ||
1149 | |||
1105 | kfree(sdata->u.ap.next_beacon); | 1150 | kfree(sdata->u.ap.next_beacon); |
1106 | sdata->u.ap.next_beacon = NULL; | 1151 | sdata->u.ap.next_beacon = NULL; |
1107 | 1152 | ||
@@ -1425,7 +1470,8 @@ static int sta_apply_parameters(struct ieee80211_local *local, | |||
1425 | } | 1470 | } |
1426 | 1471 | ||
1427 | static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, | 1472 | static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, |
1428 | u8 *mac, struct station_parameters *params) | 1473 | const u8 *mac, |
1474 | struct station_parameters *params) | ||
1429 | { | 1475 | { |
1430 | struct ieee80211_local *local = wiphy_priv(wiphy); | 1476 | struct ieee80211_local *local = wiphy_priv(wiphy); |
1431 | struct sta_info *sta; | 1477 | struct sta_info *sta; |
@@ -1459,6 +1505,8 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, | |||
1459 | if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))) { | 1505 | if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))) { |
1460 | sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); | 1506 | sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); |
1461 | sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); | 1507 | sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); |
1508 | } else { | ||
1509 | sta->sta.tdls = true; | ||
1462 | } | 1510 | } |
1463 | 1511 | ||
1464 | err = sta_apply_parameters(local, sta, params); | 1512 | err = sta_apply_parameters(local, sta, params); |
@@ -1492,7 +1540,7 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, | |||
1492 | } | 1540 | } |
1493 | 1541 | ||
1494 | static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, | 1542 | static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, |
1495 | u8 *mac) | 1543 | const u8 *mac) |
1496 | { | 1544 | { |
1497 | struct ieee80211_sub_if_data *sdata; | 1545 | struct ieee80211_sub_if_data *sdata; |
1498 | 1546 | ||
@@ -1506,7 +1554,7 @@ static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, | |||
1506 | } | 1554 | } |
1507 | 1555 | ||
1508 | static int ieee80211_change_station(struct wiphy *wiphy, | 1556 | static int ieee80211_change_station(struct wiphy *wiphy, |
1509 | struct net_device *dev, u8 *mac, | 1557 | struct net_device *dev, const u8 *mac, |
1510 | struct station_parameters *params) | 1558 | struct station_parameters *params) |
1511 | { | 1559 | { |
1512 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1560 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
@@ -1631,7 +1679,7 @@ out_err: | |||
1631 | 1679 | ||
1632 | #ifdef CONFIG_MAC80211_MESH | 1680 | #ifdef CONFIG_MAC80211_MESH |
1633 | static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, | 1681 | static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, |
1634 | u8 *dst, u8 *next_hop) | 1682 | const u8 *dst, const u8 *next_hop) |
1635 | { | 1683 | { |
1636 | struct ieee80211_sub_if_data *sdata; | 1684 | struct ieee80211_sub_if_data *sdata; |
1637 | struct mesh_path *mpath; | 1685 | struct mesh_path *mpath; |
@@ -1659,7 +1707,7 @@ static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, | |||
1659 | } | 1707 | } |
1660 | 1708 | ||
1661 | static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev, | 1709 | static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev, |
1662 | u8 *dst) | 1710 | const u8 *dst) |
1663 | { | 1711 | { |
1664 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1712 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1665 | 1713 | ||
@@ -1670,9 +1718,8 @@ static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev, | |||
1670 | return 0; | 1718 | return 0; |
1671 | } | 1719 | } |
1672 | 1720 | ||
1673 | static int ieee80211_change_mpath(struct wiphy *wiphy, | 1721 | static int ieee80211_change_mpath(struct wiphy *wiphy, struct net_device *dev, |
1674 | struct net_device *dev, | 1722 | const u8 *dst, const u8 *next_hop) |
1675 | u8 *dst, u8 *next_hop) | ||
1676 | { | 1723 | { |
1677 | struct ieee80211_sub_if_data *sdata; | 1724 | struct ieee80211_sub_if_data *sdata; |
1678 | struct mesh_path *mpath; | 1725 | struct mesh_path *mpath; |
@@ -1764,8 +1811,8 @@ static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev, | |||
1764 | } | 1811 | } |
1765 | 1812 | ||
1766 | static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, | 1813 | static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, |
1767 | int idx, u8 *dst, u8 *next_hop, | 1814 | int idx, u8 *dst, u8 *next_hop, |
1768 | struct mpath_info *pinfo) | 1815 | struct mpath_info *pinfo) |
1769 | { | 1816 | { |
1770 | struct ieee80211_sub_if_data *sdata; | 1817 | struct ieee80211_sub_if_data *sdata; |
1771 | struct mesh_path *mpath; | 1818 | struct mesh_path *mpath; |
@@ -3019,26 +3066,11 @@ void ieee80211_csa_finish(struct ieee80211_vif *vif) | |||
3019 | } | 3066 | } |
3020 | EXPORT_SYMBOL(ieee80211_csa_finish); | 3067 | EXPORT_SYMBOL(ieee80211_csa_finish); |
3021 | 3068 | ||
3022 | static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata) | 3069 | static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data *sdata, |
3070 | u32 *changed) | ||
3023 | { | 3071 | { |
3024 | struct ieee80211_local *local = sdata->local; | 3072 | int err; |
3025 | int err, changed = 0; | ||
3026 | |||
3027 | sdata_assert_lock(sdata); | ||
3028 | |||
3029 | mutex_lock(&local->mtx); | ||
3030 | sdata->radar_required = sdata->csa_radar_required; | ||
3031 | err = ieee80211_vif_change_channel(sdata, &changed); | ||
3032 | mutex_unlock(&local->mtx); | ||
3033 | if (WARN_ON(err < 0)) | ||
3034 | return; | ||
3035 | |||
3036 | if (!local->use_chanctx) { | ||
3037 | local->_oper_chandef = sdata->csa_chandef; | ||
3038 | ieee80211_hw_config(local, 0); | ||
3039 | } | ||
3040 | 3073 | ||
3041 | sdata->vif.csa_active = false; | ||
3042 | switch (sdata->vif.type) { | 3074 | switch (sdata->vif.type) { |
3043 | case NL80211_IFTYPE_AP: | 3075 | case NL80211_IFTYPE_AP: |
3044 | err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon); | 3076 | err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon); |
@@ -3046,35 +3078,74 @@ static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata) | |||
3046 | sdata->u.ap.next_beacon = NULL; | 3078 | sdata->u.ap.next_beacon = NULL; |
3047 | 3079 | ||
3048 | if (err < 0) | 3080 | if (err < 0) |
3049 | return; | 3081 | return err; |
3050 | changed |= err; | 3082 | *changed |= err; |
3051 | break; | 3083 | break; |
3052 | case NL80211_IFTYPE_ADHOC: | 3084 | case NL80211_IFTYPE_ADHOC: |
3053 | err = ieee80211_ibss_finish_csa(sdata); | 3085 | err = ieee80211_ibss_finish_csa(sdata); |
3054 | if (err < 0) | 3086 | if (err < 0) |
3055 | return; | 3087 | return err; |
3056 | changed |= err; | 3088 | *changed |= err; |
3057 | break; | 3089 | break; |
3058 | #ifdef CONFIG_MAC80211_MESH | 3090 | #ifdef CONFIG_MAC80211_MESH |
3059 | case NL80211_IFTYPE_MESH_POINT: | 3091 | case NL80211_IFTYPE_MESH_POINT: |
3060 | err = ieee80211_mesh_finish_csa(sdata); | 3092 | err = ieee80211_mesh_finish_csa(sdata); |
3061 | if (err < 0) | 3093 | if (err < 0) |
3062 | return; | 3094 | return err; |
3063 | changed |= err; | 3095 | *changed |= err; |
3064 | break; | 3096 | break; |
3065 | #endif | 3097 | #endif |
3066 | default: | 3098 | default: |
3067 | WARN_ON(1); | 3099 | WARN_ON(1); |
3068 | return; | 3100 | return -EINVAL; |
3101 | } | ||
3102 | |||
3103 | return 0; | ||
3104 | } | ||
3105 | |||
3106 | static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata) | ||
3107 | { | ||
3108 | struct ieee80211_local *local = sdata->local; | ||
3109 | u32 changed = 0; | ||
3110 | int err; | ||
3111 | |||
3112 | sdata_assert_lock(sdata); | ||
3113 | lockdep_assert_held(&local->mtx); | ||
3114 | |||
3115 | sdata->radar_required = sdata->csa_radar_required; | ||
3116 | err = ieee80211_vif_change_channel(sdata, &changed); | ||
3117 | if (err < 0) | ||
3118 | return err; | ||
3119 | |||
3120 | if (!local->use_chanctx) { | ||
3121 | local->_oper_chandef = sdata->csa_chandef; | ||
3122 | ieee80211_hw_config(local, 0); | ||
3069 | } | 3123 | } |
3070 | 3124 | ||
3125 | sdata->vif.csa_active = false; | ||
3126 | |||
3127 | err = ieee80211_set_after_csa_beacon(sdata, &changed); | ||
3128 | if (err) | ||
3129 | return err; | ||
3130 | |||
3071 | ieee80211_bss_info_change_notify(sdata, changed); | 3131 | ieee80211_bss_info_change_notify(sdata, changed); |
3132 | cfg80211_ch_switch_notify(sdata->dev, &sdata->csa_chandef); | ||
3072 | 3133 | ||
3073 | ieee80211_wake_queues_by_reason(&sdata->local->hw, | 3134 | if (!ieee80211_csa_needs_block_tx(local)) |
3135 | ieee80211_wake_queues_by_reason(&local->hw, | ||
3074 | IEEE80211_MAX_QUEUE_MAP, | 3136 | IEEE80211_MAX_QUEUE_MAP, |
3075 | IEEE80211_QUEUE_STOP_REASON_CSA); | 3137 | IEEE80211_QUEUE_STOP_REASON_CSA); |
3076 | 3138 | ||
3077 | cfg80211_ch_switch_notify(sdata->dev, &sdata->csa_chandef); | 3139 | return 0; |
3140 | } | ||
3141 | |||
3142 | static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata) | ||
3143 | { | ||
3144 | if (__ieee80211_csa_finalize(sdata)) { | ||
3145 | sdata_info(sdata, "failed to finalize CSA, disconnecting\n"); | ||
3146 | cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev, | ||
3147 | GFP_KERNEL); | ||
3148 | } | ||
3078 | } | 3149 | } |
3079 | 3150 | ||
3080 | void ieee80211_csa_finalize_work(struct work_struct *work) | 3151 | void ieee80211_csa_finalize_work(struct work_struct *work) |
@@ -3082,8 +3153,11 @@ void ieee80211_csa_finalize_work(struct work_struct *work) | |||
3082 | struct ieee80211_sub_if_data *sdata = | 3153 | struct ieee80211_sub_if_data *sdata = |
3083 | container_of(work, struct ieee80211_sub_if_data, | 3154 | container_of(work, struct ieee80211_sub_if_data, |
3084 | csa_finalize_work); | 3155 | csa_finalize_work); |
3156 | struct ieee80211_local *local = sdata->local; | ||
3085 | 3157 | ||
3086 | sdata_lock(sdata); | 3158 | sdata_lock(sdata); |
3159 | mutex_lock(&local->mtx); | ||
3160 | |||
3087 | /* AP might have been stopped while waiting for the lock. */ | 3161 | /* AP might have been stopped while waiting for the lock. */ |
3088 | if (!sdata->vif.csa_active) | 3162 | if (!sdata->vif.csa_active) |
3089 | goto unlock; | 3163 | goto unlock; |
@@ -3094,6 +3168,7 @@ void ieee80211_csa_finalize_work(struct work_struct *work) | |||
3094 | ieee80211_csa_finalize(sdata); | 3168 | ieee80211_csa_finalize(sdata); |
3095 | 3169 | ||
3096 | unlock: | 3170 | unlock: |
3171 | mutex_unlock(&local->mtx); | ||
3097 | sdata_unlock(sdata); | 3172 | sdata_unlock(sdata); |
3098 | } | 3173 | } |
3099 | 3174 | ||
@@ -3129,9 +3204,25 @@ static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata, | |||
3129 | if (params->count <= 1) | 3204 | if (params->count <= 1) |
3130 | break; | 3205 | break; |
3131 | 3206 | ||
3132 | sdata->csa_counter_offset_beacon = | 3207 | if ((params->n_counter_offsets_beacon > |
3133 | params->counter_offset_beacon; | 3208 | IEEE80211_MAX_CSA_COUNTERS_NUM) || |
3134 | sdata->csa_counter_offset_presp = params->counter_offset_presp; | 3209 | (params->n_counter_offsets_presp > |
3210 | IEEE80211_MAX_CSA_COUNTERS_NUM)) | ||
3211 | return -EINVAL; | ||
3212 | |||
3213 | /* make sure we don't have garbage in other counters */ | ||
3214 | memset(sdata->csa_counter_offset_beacon, 0, | ||
3215 | sizeof(sdata->csa_counter_offset_beacon)); | ||
3216 | memset(sdata->csa_counter_offset_presp, 0, | ||
3217 | sizeof(sdata->csa_counter_offset_presp)); | ||
3218 | |||
3219 | memcpy(sdata->csa_counter_offset_beacon, | ||
3220 | params->counter_offsets_beacon, | ||
3221 | params->n_counter_offsets_beacon * sizeof(u16)); | ||
3222 | memcpy(sdata->csa_counter_offset_presp, | ||
3223 | params->counter_offsets_presp, | ||
3224 | params->n_counter_offsets_presp * sizeof(u16)); | ||
3225 | |||
3135 | err = ieee80211_assign_beacon(sdata, ¶ms->beacon_csa); | 3226 | err = ieee80211_assign_beacon(sdata, ¶ms->beacon_csa); |
3136 | if (err < 0) { | 3227 | if (err < 0) { |
3137 | kfree(sdata->u.ap.next_beacon); | 3228 | kfree(sdata->u.ap.next_beacon); |
@@ -3220,8 +3311,9 @@ static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata, | |||
3220 | return 0; | 3311 | return 0; |
3221 | } | 3312 | } |
3222 | 3313 | ||
3223 | int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, | 3314 | static int |
3224 | struct cfg80211_csa_settings *params) | 3315 | __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, |
3316 | struct cfg80211_csa_settings *params) | ||
3225 | { | 3317 | { |
3226 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 3318 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
3227 | struct ieee80211_local *local = sdata->local; | 3319 | struct ieee80211_local *local = sdata->local; |
@@ -3230,6 +3322,7 @@ int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, | |||
3230 | int err, num_chanctx, changed = 0; | 3322 | int err, num_chanctx, changed = 0; |
3231 | 3323 | ||
3232 | sdata_assert_lock(sdata); | 3324 | sdata_assert_lock(sdata); |
3325 | lockdep_assert_held(&local->mtx); | ||
3233 | 3326 | ||
3234 | if (!list_empty(&local->roc_list) || local->scanning) | 3327 | if (!list_empty(&local->roc_list) || local->scanning) |
3235 | return -EBUSY; | 3328 | return -EBUSY; |
@@ -3272,15 +3365,16 @@ int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, | |||
3272 | return err; | 3365 | return err; |
3273 | 3366 | ||
3274 | sdata->csa_radar_required = params->radar_required; | 3367 | sdata->csa_radar_required = params->radar_required; |
3275 | |||
3276 | if (params->block_tx) | ||
3277 | ieee80211_stop_queues_by_reason(&local->hw, | ||
3278 | IEEE80211_MAX_QUEUE_MAP, | ||
3279 | IEEE80211_QUEUE_STOP_REASON_CSA); | ||
3280 | |||
3281 | sdata->csa_chandef = params->chandef; | 3368 | sdata->csa_chandef = params->chandef; |
3369 | sdata->csa_block_tx = params->block_tx; | ||
3370 | sdata->csa_current_counter = params->count; | ||
3282 | sdata->vif.csa_active = true; | 3371 | sdata->vif.csa_active = true; |
3283 | 3372 | ||
3373 | if (sdata->csa_block_tx) | ||
3374 | ieee80211_stop_queues_by_reason(&local->hw, | ||
3375 | IEEE80211_MAX_QUEUE_MAP, | ||
3376 | IEEE80211_QUEUE_STOP_REASON_CSA); | ||
3377 | |||
3284 | if (changed) { | 3378 | if (changed) { |
3285 | ieee80211_bss_info_change_notify(sdata, changed); | 3379 | ieee80211_bss_info_change_notify(sdata, changed); |
3286 | drv_channel_switch_beacon(sdata, ¶ms->chandef); | 3380 | drv_channel_switch_beacon(sdata, ¶ms->chandef); |
@@ -3292,6 +3386,20 @@ int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, | |||
3292 | return 0; | 3386 | return 0; |
3293 | } | 3387 | } |
3294 | 3388 | ||
3389 | int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, | ||
3390 | struct cfg80211_csa_settings *params) | ||
3391 | { | ||
3392 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
3393 | struct ieee80211_local *local = sdata->local; | ||
3394 | int err; | ||
3395 | |||
3396 | mutex_lock(&local->mtx); | ||
3397 | err = __ieee80211_channel_switch(wiphy, dev, params); | ||
3398 | mutex_unlock(&local->mtx); | ||
3399 | |||
3400 | return err; | ||
3401 | } | ||
3402 | |||
3295 | static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, | 3403 | static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, |
3296 | struct cfg80211_mgmt_tx_params *params, | 3404 | struct cfg80211_mgmt_tx_params *params, |
3297 | u64 *cookie) | 3405 | u64 *cookie) |
@@ -3304,6 +3412,7 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, | |||
3304 | bool need_offchan = false; | 3412 | bool need_offchan = false; |
3305 | u32 flags; | 3413 | u32 flags; |
3306 | int ret; | 3414 | int ret; |
3415 | u8 *data; | ||
3307 | 3416 | ||
3308 | if (params->dont_wait_for_ack) | 3417 | if (params->dont_wait_for_ack) |
3309 | flags = IEEE80211_TX_CTL_NO_ACK; | 3418 | flags = IEEE80211_TX_CTL_NO_ACK; |
@@ -3397,7 +3506,20 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, | |||
3397 | } | 3506 | } |
3398 | skb_reserve(skb, local->hw.extra_tx_headroom); | 3507 | skb_reserve(skb, local->hw.extra_tx_headroom); |
3399 | 3508 | ||
3400 | memcpy(skb_put(skb, params->len), params->buf, params->len); | 3509 | data = skb_put(skb, params->len); |
3510 | memcpy(data, params->buf, params->len); | ||
3511 | |||
3512 | /* Update CSA counters */ | ||
3513 | if (sdata->vif.csa_active && | ||
3514 | (sdata->vif.type == NL80211_IFTYPE_AP || | ||
3515 | sdata->vif.type == NL80211_IFTYPE_ADHOC) && | ||
3516 | params->n_csa_offsets) { | ||
3517 | int i; | ||
3518 | u8 c = sdata->csa_current_counter; | ||
3519 | |||
3520 | for (i = 0; i < params->n_csa_offsets; i++) | ||
3521 | data[params->csa_offsets[i]] = c; | ||
3522 | } | ||
3401 | 3523 | ||
3402 | IEEE80211_SKB_CB(skb)->flags = flags; | 3524 | IEEE80211_SKB_CB(skb)->flags = flags; |
3403 | 3525 | ||
@@ -3506,320 +3628,6 @@ static int ieee80211_set_rekey_data(struct wiphy *wiphy, | |||
3506 | return 0; | 3628 | return 0; |
3507 | } | 3629 | } |
3508 | 3630 | ||
3509 | static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb) | ||
3510 | { | ||
3511 | u8 *pos = (void *)skb_put(skb, 7); | ||
3512 | |||
3513 | *pos++ = WLAN_EID_EXT_CAPABILITY; | ||
3514 | *pos++ = 5; /* len */ | ||
3515 | *pos++ = 0x0; | ||
3516 | *pos++ = 0x0; | ||
3517 | *pos++ = 0x0; | ||
3518 | *pos++ = 0x0; | ||
3519 | *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED; | ||
3520 | } | ||
3521 | |||
3522 | static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata) | ||
3523 | { | ||
3524 | struct ieee80211_local *local = sdata->local; | ||
3525 | u16 capab; | ||
3526 | |||
3527 | capab = 0; | ||
3528 | if (ieee80211_get_sdata_band(sdata) != IEEE80211_BAND_2GHZ) | ||
3529 | return capab; | ||
3530 | |||
3531 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) | ||
3532 | capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME; | ||
3533 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)) | ||
3534 | capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; | ||
3535 | |||
3536 | return capab; | ||
3537 | } | ||
3538 | |||
3539 | static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr, | ||
3540 | u8 *peer, u8 *bssid) | ||
3541 | { | ||
3542 | struct ieee80211_tdls_lnkie *lnkid; | ||
3543 | |||
3544 | lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie)); | ||
3545 | |||
3546 | lnkid->ie_type = WLAN_EID_LINK_ID; | ||
3547 | lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2; | ||
3548 | |||
3549 | memcpy(lnkid->bssid, bssid, ETH_ALEN); | ||
3550 | memcpy(lnkid->init_sta, src_addr, ETH_ALEN); | ||
3551 | memcpy(lnkid->resp_sta, peer, ETH_ALEN); | ||
3552 | } | ||
3553 | |||
3554 | static int | ||
3555 | ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev, | ||
3556 | u8 *peer, u8 action_code, u8 dialog_token, | ||
3557 | u16 status_code, struct sk_buff *skb) | ||
3558 | { | ||
3559 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
3560 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); | ||
3561 | struct ieee80211_tdls_data *tf; | ||
3562 | |||
3563 | tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u)); | ||
3564 | |||
3565 | memcpy(tf->da, peer, ETH_ALEN); | ||
3566 | memcpy(tf->sa, sdata->vif.addr, ETH_ALEN); | ||
3567 | tf->ether_type = cpu_to_be16(ETH_P_TDLS); | ||
3568 | tf->payload_type = WLAN_TDLS_SNAP_RFTYPE; | ||
3569 | |||
3570 | switch (action_code) { | ||
3571 | case WLAN_TDLS_SETUP_REQUEST: | ||
3572 | tf->category = WLAN_CATEGORY_TDLS; | ||
3573 | tf->action_code = WLAN_TDLS_SETUP_REQUEST; | ||
3574 | |||
3575 | skb_put(skb, sizeof(tf->u.setup_req)); | ||
3576 | tf->u.setup_req.dialog_token = dialog_token; | ||
3577 | tf->u.setup_req.capability = | ||
3578 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); | ||
3579 | |||
3580 | ieee80211_add_srates_ie(sdata, skb, false, band); | ||
3581 | ieee80211_add_ext_srates_ie(sdata, skb, false, band); | ||
3582 | ieee80211_tdls_add_ext_capab(skb); | ||
3583 | break; | ||
3584 | case WLAN_TDLS_SETUP_RESPONSE: | ||
3585 | tf->category = WLAN_CATEGORY_TDLS; | ||
3586 | tf->action_code = WLAN_TDLS_SETUP_RESPONSE; | ||
3587 | |||
3588 | skb_put(skb, sizeof(tf->u.setup_resp)); | ||
3589 | tf->u.setup_resp.status_code = cpu_to_le16(status_code); | ||
3590 | tf->u.setup_resp.dialog_token = dialog_token; | ||
3591 | tf->u.setup_resp.capability = | ||
3592 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); | ||
3593 | |||
3594 | ieee80211_add_srates_ie(sdata, skb, false, band); | ||
3595 | ieee80211_add_ext_srates_ie(sdata, skb, false, band); | ||
3596 | ieee80211_tdls_add_ext_capab(skb); | ||
3597 | break; | ||
3598 | case WLAN_TDLS_SETUP_CONFIRM: | ||
3599 | tf->category = WLAN_CATEGORY_TDLS; | ||
3600 | tf->action_code = WLAN_TDLS_SETUP_CONFIRM; | ||
3601 | |||
3602 | skb_put(skb, sizeof(tf->u.setup_cfm)); | ||
3603 | tf->u.setup_cfm.status_code = cpu_to_le16(status_code); | ||
3604 | tf->u.setup_cfm.dialog_token = dialog_token; | ||
3605 | break; | ||
3606 | case WLAN_TDLS_TEARDOWN: | ||
3607 | tf->category = WLAN_CATEGORY_TDLS; | ||
3608 | tf->action_code = WLAN_TDLS_TEARDOWN; | ||
3609 | |||
3610 | skb_put(skb, sizeof(tf->u.teardown)); | ||
3611 | tf->u.teardown.reason_code = cpu_to_le16(status_code); | ||
3612 | break; | ||
3613 | case WLAN_TDLS_DISCOVERY_REQUEST: | ||
3614 | tf->category = WLAN_CATEGORY_TDLS; | ||
3615 | tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST; | ||
3616 | |||
3617 | skb_put(skb, sizeof(tf->u.discover_req)); | ||
3618 | tf->u.discover_req.dialog_token = dialog_token; | ||
3619 | break; | ||
3620 | default: | ||
3621 | return -EINVAL; | ||
3622 | } | ||
3623 | |||
3624 | return 0; | ||
3625 | } | ||
3626 | |||
3627 | static int | ||
3628 | ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev, | ||
3629 | u8 *peer, u8 action_code, u8 dialog_token, | ||
3630 | u16 status_code, struct sk_buff *skb) | ||
3631 | { | ||
3632 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
3633 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); | ||
3634 | struct ieee80211_mgmt *mgmt; | ||
3635 | |||
3636 | mgmt = (void *)skb_put(skb, 24); | ||
3637 | memset(mgmt, 0, 24); | ||
3638 | memcpy(mgmt->da, peer, ETH_ALEN); | ||
3639 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); | ||
3640 | memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); | ||
3641 | |||
3642 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | ||
3643 | IEEE80211_STYPE_ACTION); | ||
3644 | |||
3645 | switch (action_code) { | ||
3646 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: | ||
3647 | skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp)); | ||
3648 | mgmt->u.action.category = WLAN_CATEGORY_PUBLIC; | ||
3649 | mgmt->u.action.u.tdls_discover_resp.action_code = | ||
3650 | WLAN_PUB_ACTION_TDLS_DISCOVER_RES; | ||
3651 | mgmt->u.action.u.tdls_discover_resp.dialog_token = | ||
3652 | dialog_token; | ||
3653 | mgmt->u.action.u.tdls_discover_resp.capability = | ||
3654 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); | ||
3655 | |||
3656 | ieee80211_add_srates_ie(sdata, skb, false, band); | ||
3657 | ieee80211_add_ext_srates_ie(sdata, skb, false, band); | ||
3658 | ieee80211_tdls_add_ext_capab(skb); | ||
3659 | break; | ||
3660 | default: | ||
3661 | return -EINVAL; | ||
3662 | } | ||
3663 | |||
3664 | return 0; | ||
3665 | } | ||
3666 | |||
3667 | static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, | ||
3668 | u8 *peer, u8 action_code, u8 dialog_token, | ||
3669 | u16 status_code, u32 peer_capability, | ||
3670 | const u8 *extra_ies, size_t extra_ies_len) | ||
3671 | { | ||
3672 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
3673 | struct ieee80211_local *local = sdata->local; | ||
3674 | struct sk_buff *skb = NULL; | ||
3675 | bool send_direct; | ||
3676 | int ret; | ||
3677 | |||
3678 | if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS)) | ||
3679 | return -ENOTSUPP; | ||
3680 | |||
3681 | /* make sure we are in managed mode, and associated */ | ||
3682 | if (sdata->vif.type != NL80211_IFTYPE_STATION || | ||
3683 | !sdata->u.mgd.associated) | ||
3684 | return -EINVAL; | ||
3685 | |||
3686 | tdls_dbg(sdata, "TDLS mgmt action %d peer %pM\n", | ||
3687 | action_code, peer); | ||
3688 | |||
3689 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + | ||
3690 | max(sizeof(struct ieee80211_mgmt), | ||
3691 | sizeof(struct ieee80211_tdls_data)) + | ||
3692 | 50 + /* supported rates */ | ||
3693 | 7 + /* ext capab */ | ||
3694 | extra_ies_len + | ||
3695 | sizeof(struct ieee80211_tdls_lnkie)); | ||
3696 | if (!skb) | ||
3697 | return -ENOMEM; | ||
3698 | |||
3699 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
3700 | |||
3701 | switch (action_code) { | ||
3702 | case WLAN_TDLS_SETUP_REQUEST: | ||
3703 | case WLAN_TDLS_SETUP_RESPONSE: | ||
3704 | case WLAN_TDLS_SETUP_CONFIRM: | ||
3705 | case WLAN_TDLS_TEARDOWN: | ||
3706 | case WLAN_TDLS_DISCOVERY_REQUEST: | ||
3707 | ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer, | ||
3708 | action_code, dialog_token, | ||
3709 | status_code, skb); | ||
3710 | send_direct = false; | ||
3711 | break; | ||
3712 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: | ||
3713 | ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code, | ||
3714 | dialog_token, status_code, | ||
3715 | skb); | ||
3716 | send_direct = true; | ||
3717 | break; | ||
3718 | default: | ||
3719 | ret = -ENOTSUPP; | ||
3720 | break; | ||
3721 | } | ||
3722 | |||
3723 | if (ret < 0) | ||
3724 | goto fail; | ||
3725 | |||
3726 | if (extra_ies_len) | ||
3727 | memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len); | ||
3728 | |||
3729 | /* the TDLS link IE is always added last */ | ||
3730 | switch (action_code) { | ||
3731 | case WLAN_TDLS_SETUP_REQUEST: | ||
3732 | case WLAN_TDLS_SETUP_CONFIRM: | ||
3733 | case WLAN_TDLS_TEARDOWN: | ||
3734 | case WLAN_TDLS_DISCOVERY_REQUEST: | ||
3735 | /* we are the initiator */ | ||
3736 | ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer, | ||
3737 | sdata->u.mgd.bssid); | ||
3738 | break; | ||
3739 | case WLAN_TDLS_SETUP_RESPONSE: | ||
3740 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: | ||
3741 | /* we are the responder */ | ||
3742 | ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr, | ||
3743 | sdata->u.mgd.bssid); | ||
3744 | break; | ||
3745 | default: | ||
3746 | ret = -ENOTSUPP; | ||
3747 | goto fail; | ||
3748 | } | ||
3749 | |||
3750 | if (send_direct) { | ||
3751 | ieee80211_tx_skb(sdata, skb); | ||
3752 | return 0; | ||
3753 | } | ||
3754 | |||
3755 | /* | ||
3756 | * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise | ||
3757 | * we should default to AC_VI. | ||
3758 | */ | ||
3759 | switch (action_code) { | ||
3760 | case WLAN_TDLS_SETUP_REQUEST: | ||
3761 | case WLAN_TDLS_SETUP_RESPONSE: | ||
3762 | skb_set_queue_mapping(skb, IEEE80211_AC_BK); | ||
3763 | skb->priority = 2; | ||
3764 | break; | ||
3765 | default: | ||
3766 | skb_set_queue_mapping(skb, IEEE80211_AC_VI); | ||
3767 | skb->priority = 5; | ||
3768 | break; | ||
3769 | } | ||
3770 | |||
3771 | /* disable bottom halves when entering the Tx path */ | ||
3772 | local_bh_disable(); | ||
3773 | ret = ieee80211_subif_start_xmit(skb, dev); | ||
3774 | local_bh_enable(); | ||
3775 | |||
3776 | return ret; | ||
3777 | |||
3778 | fail: | ||
3779 | dev_kfree_skb(skb); | ||
3780 | return ret; | ||
3781 | } | ||
3782 | |||
3783 | static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, | ||
3784 | u8 *peer, enum nl80211_tdls_operation oper) | ||
3785 | { | ||
3786 | struct sta_info *sta; | ||
3787 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
3788 | |||
3789 | if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS)) | ||
3790 | return -ENOTSUPP; | ||
3791 | |||
3792 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | ||
3793 | return -EINVAL; | ||
3794 | |||
3795 | tdls_dbg(sdata, "TDLS oper %d peer %pM\n", oper, peer); | ||
3796 | |||
3797 | switch (oper) { | ||
3798 | case NL80211_TDLS_ENABLE_LINK: | ||
3799 | rcu_read_lock(); | ||
3800 | sta = sta_info_get(sdata, peer); | ||
3801 | if (!sta) { | ||
3802 | rcu_read_unlock(); | ||
3803 | return -ENOLINK; | ||
3804 | } | ||
3805 | |||
3806 | set_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH); | ||
3807 | rcu_read_unlock(); | ||
3808 | break; | ||
3809 | case NL80211_TDLS_DISABLE_LINK: | ||
3810 | return sta_info_destroy_addr(sdata, peer); | ||
3811 | case NL80211_TDLS_TEARDOWN: | ||
3812 | case NL80211_TDLS_SETUP: | ||
3813 | case NL80211_TDLS_DISCOVERY_REQ: | ||
3814 | /* We don't support in-driver setup/teardown/discovery */ | ||
3815 | return -ENOTSUPP; | ||
3816 | default: | ||
3817 | return -ENOTSUPP; | ||
3818 | } | ||
3819 | |||
3820 | return 0; | ||
3821 | } | ||
3822 | |||
3823 | static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev, | 3631 | static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev, |
3824 | const u8 *peer, u64 *cookie) | 3632 | const u8 *peer, u64 *cookie) |
3825 | { | 3633 | { |
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 48e6d6f010cd..a310e33972de 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c | |||
@@ -855,7 +855,7 @@ static void | |||
855 | __ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata, | 855 | __ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata, |
856 | bool clear) | 856 | bool clear) |
857 | { | 857 | { |
858 | struct ieee80211_local *local = sdata->local; | 858 | struct ieee80211_local *local __maybe_unused = sdata->local; |
859 | struct ieee80211_sub_if_data *vlan; | 859 | struct ieee80211_sub_if_data *vlan; |
860 | struct ieee80211_chanctx_conf *conf; | 860 | struct ieee80211_chanctx_conf *conf; |
861 | 861 | ||
@@ -871,7 +871,7 @@ __ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata, | |||
871 | * to a channel context that has already been freed. | 871 | * to a channel context that has already been freed. |
872 | */ | 872 | */ |
873 | conf = rcu_dereference_protected(sdata->vif.chanctx_conf, | 873 | conf = rcu_dereference_protected(sdata->vif.chanctx_conf, |
874 | lockdep_is_held(&local->chanctx_mtx)); | 874 | lockdep_is_held(&local->chanctx_mtx)); |
875 | WARN_ON(!conf); | 875 | WARN_ON(!conf); |
876 | 876 | ||
877 | if (clear) | 877 | if (clear) |
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index 5331582a2c81..696ef78b1fb7 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h | |||
@@ -5,11 +5,11 @@ | |||
5 | #include "ieee80211_i.h" | 5 | #include "ieee80211_i.h" |
6 | #include "trace.h" | 6 | #include "trace.h" |
7 | 7 | ||
8 | static inline void check_sdata_in_driver(struct ieee80211_sub_if_data *sdata) | 8 | static inline bool check_sdata_in_driver(struct ieee80211_sub_if_data *sdata) |
9 | { | 9 | { |
10 | WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER), | 10 | return !WARN(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER), |
11 | "%s: Failed check-sdata-in-driver check, flags: 0x%x\n", | 11 | "%s: Failed check-sdata-in-driver check, flags: 0x%x\n", |
12 | sdata->dev ? sdata->dev->name : sdata->name, sdata->flags); | 12 | sdata->dev ? sdata->dev->name : sdata->name, sdata->flags); |
13 | } | 13 | } |
14 | 14 | ||
15 | static inline struct ieee80211_sub_if_data * | 15 | static inline struct ieee80211_sub_if_data * |
@@ -168,7 +168,8 @@ static inline int drv_change_interface(struct ieee80211_local *local, | |||
168 | 168 | ||
169 | might_sleep(); | 169 | might_sleep(); |
170 | 170 | ||
171 | check_sdata_in_driver(sdata); | 171 | if (!check_sdata_in_driver(sdata)) |
172 | return -EIO; | ||
172 | 173 | ||
173 | trace_drv_change_interface(local, sdata, type, p2p); | 174 | trace_drv_change_interface(local, sdata, type, p2p); |
174 | ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p); | 175 | ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p); |
@@ -181,7 +182,8 @@ static inline void drv_remove_interface(struct ieee80211_local *local, | |||
181 | { | 182 | { |
182 | might_sleep(); | 183 | might_sleep(); |
183 | 184 | ||
184 | check_sdata_in_driver(sdata); | 185 | if (!check_sdata_in_driver(sdata)) |
186 | return; | ||
185 | 187 | ||
186 | trace_drv_remove_interface(local, sdata); | 188 | trace_drv_remove_interface(local, sdata); |
187 | local->ops->remove_interface(&local->hw, &sdata->vif); | 189 | local->ops->remove_interface(&local->hw, &sdata->vif); |
@@ -219,7 +221,8 @@ static inline void drv_bss_info_changed(struct ieee80211_local *local, | |||
219 | sdata->vif.type == NL80211_IFTYPE_MONITOR)) | 221 | sdata->vif.type == NL80211_IFTYPE_MONITOR)) |
220 | return; | 222 | return; |
221 | 223 | ||
222 | check_sdata_in_driver(sdata); | 224 | if (!check_sdata_in_driver(sdata)) |
225 | return; | ||
223 | 226 | ||
224 | trace_drv_bss_info_changed(local, sdata, info, changed); | 227 | trace_drv_bss_info_changed(local, sdata, info, changed); |
225 | if (local->ops->bss_info_changed) | 228 | if (local->ops->bss_info_changed) |
@@ -278,7 +281,8 @@ static inline int drv_set_key(struct ieee80211_local *local, | |||
278 | might_sleep(); | 281 | might_sleep(); |
279 | 282 | ||
280 | sdata = get_bss_sdata(sdata); | 283 | sdata = get_bss_sdata(sdata); |
281 | check_sdata_in_driver(sdata); | 284 | if (!check_sdata_in_driver(sdata)) |
285 | return -EIO; | ||
282 | 286 | ||
283 | trace_drv_set_key(local, cmd, sdata, sta, key); | 287 | trace_drv_set_key(local, cmd, sdata, sta, key); |
284 | ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); | 288 | ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); |
@@ -298,7 +302,8 @@ static inline void drv_update_tkip_key(struct ieee80211_local *local, | |||
298 | ista = &sta->sta; | 302 | ista = &sta->sta; |
299 | 303 | ||
300 | sdata = get_bss_sdata(sdata); | 304 | sdata = get_bss_sdata(sdata); |
301 | check_sdata_in_driver(sdata); | 305 | if (!check_sdata_in_driver(sdata)) |
306 | return; | ||
302 | 307 | ||
303 | trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); | 308 | trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); |
304 | if (local->ops->update_tkip_key) | 309 | if (local->ops->update_tkip_key) |
@@ -315,7 +320,8 @@ static inline int drv_hw_scan(struct ieee80211_local *local, | |||
315 | 320 | ||
316 | might_sleep(); | 321 | might_sleep(); |
317 | 322 | ||
318 | check_sdata_in_driver(sdata); | 323 | if (!check_sdata_in_driver(sdata)) |
324 | return -EIO; | ||
319 | 325 | ||
320 | trace_drv_hw_scan(local, sdata); | 326 | trace_drv_hw_scan(local, sdata); |
321 | ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); | 327 | ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); |
@@ -328,7 +334,8 @@ static inline void drv_cancel_hw_scan(struct ieee80211_local *local, | |||
328 | { | 334 | { |
329 | might_sleep(); | 335 | might_sleep(); |
330 | 336 | ||
331 | check_sdata_in_driver(sdata); | 337 | if (!check_sdata_in_driver(sdata)) |
338 | return; | ||
332 | 339 | ||
333 | trace_drv_cancel_hw_scan(local, sdata); | 340 | trace_drv_cancel_hw_scan(local, sdata); |
334 | local->ops->cancel_hw_scan(&local->hw, &sdata->vif); | 341 | local->ops->cancel_hw_scan(&local->hw, &sdata->vif); |
@@ -345,7 +352,8 @@ drv_sched_scan_start(struct ieee80211_local *local, | |||
345 | 352 | ||
346 | might_sleep(); | 353 | might_sleep(); |
347 | 354 | ||
348 | check_sdata_in_driver(sdata); | 355 | if (!check_sdata_in_driver(sdata)) |
356 | return -EIO; | ||
349 | 357 | ||
350 | trace_drv_sched_scan_start(local, sdata); | 358 | trace_drv_sched_scan_start(local, sdata); |
351 | ret = local->ops->sched_scan_start(&local->hw, &sdata->vif, | 359 | ret = local->ops->sched_scan_start(&local->hw, &sdata->vif, |
@@ -361,7 +369,8 @@ static inline int drv_sched_scan_stop(struct ieee80211_local *local, | |||
361 | 369 | ||
362 | might_sleep(); | 370 | might_sleep(); |
363 | 371 | ||
364 | check_sdata_in_driver(sdata); | 372 | if (!check_sdata_in_driver(sdata)) |
373 | return -EIO; | ||
365 | 374 | ||
366 | trace_drv_sched_scan_stop(local, sdata); | 375 | trace_drv_sched_scan_stop(local, sdata); |
367 | ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif); | 376 | ret = local->ops->sched_scan_stop(&local->hw, &sdata->vif); |
@@ -462,7 +471,8 @@ static inline void drv_sta_notify(struct ieee80211_local *local, | |||
462 | struct ieee80211_sta *sta) | 471 | struct ieee80211_sta *sta) |
463 | { | 472 | { |
464 | sdata = get_bss_sdata(sdata); | 473 | sdata = get_bss_sdata(sdata); |
465 | check_sdata_in_driver(sdata); | 474 | if (!check_sdata_in_driver(sdata)) |
475 | return; | ||
466 | 476 | ||
467 | trace_drv_sta_notify(local, sdata, cmd, sta); | 477 | trace_drv_sta_notify(local, sdata, cmd, sta); |
468 | if (local->ops->sta_notify) | 478 | if (local->ops->sta_notify) |
@@ -479,7 +489,8 @@ static inline int drv_sta_add(struct ieee80211_local *local, | |||
479 | might_sleep(); | 489 | might_sleep(); |
480 | 490 | ||
481 | sdata = get_bss_sdata(sdata); | 491 | sdata = get_bss_sdata(sdata); |
482 | check_sdata_in_driver(sdata); | 492 | if (!check_sdata_in_driver(sdata)) |
493 | return -EIO; | ||
483 | 494 | ||
484 | trace_drv_sta_add(local, sdata, sta); | 495 | trace_drv_sta_add(local, sdata, sta); |
485 | if (local->ops->sta_add) | 496 | if (local->ops->sta_add) |
@@ -497,7 +508,8 @@ static inline void drv_sta_remove(struct ieee80211_local *local, | |||
497 | might_sleep(); | 508 | might_sleep(); |
498 | 509 | ||
499 | sdata = get_bss_sdata(sdata); | 510 | sdata = get_bss_sdata(sdata); |
500 | check_sdata_in_driver(sdata); | 511 | if (!check_sdata_in_driver(sdata)) |
512 | return; | ||
501 | 513 | ||
502 | trace_drv_sta_remove(local, sdata, sta); | 514 | trace_drv_sta_remove(local, sdata, sta); |
503 | if (local->ops->sta_remove) | 515 | if (local->ops->sta_remove) |
@@ -515,7 +527,8 @@ static inline void drv_sta_add_debugfs(struct ieee80211_local *local, | |||
515 | might_sleep(); | 527 | might_sleep(); |
516 | 528 | ||
517 | sdata = get_bss_sdata(sdata); | 529 | sdata = get_bss_sdata(sdata); |
518 | check_sdata_in_driver(sdata); | 530 | if (!check_sdata_in_driver(sdata)) |
531 | return; | ||
519 | 532 | ||
520 | if (local->ops->sta_add_debugfs) | 533 | if (local->ops->sta_add_debugfs) |
521 | local->ops->sta_add_debugfs(&local->hw, &sdata->vif, | 534 | local->ops->sta_add_debugfs(&local->hw, &sdata->vif, |
@@ -545,7 +558,8 @@ static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local, | |||
545 | might_sleep(); | 558 | might_sleep(); |
546 | 559 | ||
547 | sdata = get_bss_sdata(sdata); | 560 | sdata = get_bss_sdata(sdata); |
548 | check_sdata_in_driver(sdata); | 561 | if (!check_sdata_in_driver(sdata)) |
562 | return; | ||
549 | 563 | ||
550 | trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta); | 564 | trace_drv_sta_pre_rcu_remove(local, sdata, &sta->sta); |
551 | if (local->ops->sta_pre_rcu_remove) | 565 | if (local->ops->sta_pre_rcu_remove) |
@@ -566,7 +580,8 @@ int drv_sta_state(struct ieee80211_local *local, | |||
566 | might_sleep(); | 580 | might_sleep(); |
567 | 581 | ||
568 | sdata = get_bss_sdata(sdata); | 582 | sdata = get_bss_sdata(sdata); |
569 | check_sdata_in_driver(sdata); | 583 | if (!check_sdata_in_driver(sdata)) |
584 | return -EIO; | ||
570 | 585 | ||
571 | trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state); | 586 | trace_drv_sta_state(local, sdata, &sta->sta, old_state, new_state); |
572 | if (local->ops->sta_state) { | 587 | if (local->ops->sta_state) { |
@@ -590,7 +605,8 @@ static inline void drv_sta_rc_update(struct ieee80211_local *local, | |||
590 | struct ieee80211_sta *sta, u32 changed) | 605 | struct ieee80211_sta *sta, u32 changed) |
591 | { | 606 | { |
592 | sdata = get_bss_sdata(sdata); | 607 | sdata = get_bss_sdata(sdata); |
593 | check_sdata_in_driver(sdata); | 608 | if (!check_sdata_in_driver(sdata)) |
609 | return; | ||
594 | 610 | ||
595 | WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED && | 611 | WARN_ON(changed & IEEE80211_RC_SUPP_RATES_CHANGED && |
596 | (sdata->vif.type != NL80211_IFTYPE_ADHOC && | 612 | (sdata->vif.type != NL80211_IFTYPE_ADHOC && |
@@ -612,7 +628,8 @@ static inline int drv_conf_tx(struct ieee80211_local *local, | |||
612 | 628 | ||
613 | might_sleep(); | 629 | might_sleep(); |
614 | 630 | ||
615 | check_sdata_in_driver(sdata); | 631 | if (!check_sdata_in_driver(sdata)) |
632 | return -EIO; | ||
616 | 633 | ||
617 | trace_drv_conf_tx(local, sdata, ac, params); | 634 | trace_drv_conf_tx(local, sdata, ac, params); |
618 | if (local->ops->conf_tx) | 635 | if (local->ops->conf_tx) |
@@ -629,7 +646,8 @@ static inline u64 drv_get_tsf(struct ieee80211_local *local, | |||
629 | 646 | ||
630 | might_sleep(); | 647 | might_sleep(); |
631 | 648 | ||
632 | check_sdata_in_driver(sdata); | 649 | if (!check_sdata_in_driver(sdata)) |
650 | return ret; | ||
633 | 651 | ||
634 | trace_drv_get_tsf(local, sdata); | 652 | trace_drv_get_tsf(local, sdata); |
635 | if (local->ops->get_tsf) | 653 | if (local->ops->get_tsf) |
@@ -644,7 +662,8 @@ static inline void drv_set_tsf(struct ieee80211_local *local, | |||
644 | { | 662 | { |
645 | might_sleep(); | 663 | might_sleep(); |
646 | 664 | ||
647 | check_sdata_in_driver(sdata); | 665 | if (!check_sdata_in_driver(sdata)) |
666 | return; | ||
648 | 667 | ||
649 | trace_drv_set_tsf(local, sdata, tsf); | 668 | trace_drv_set_tsf(local, sdata, tsf); |
650 | if (local->ops->set_tsf) | 669 | if (local->ops->set_tsf) |
@@ -657,7 +676,8 @@ static inline void drv_reset_tsf(struct ieee80211_local *local, | |||
657 | { | 676 | { |
658 | might_sleep(); | 677 | might_sleep(); |
659 | 678 | ||
660 | check_sdata_in_driver(sdata); | 679 | if (!check_sdata_in_driver(sdata)) |
680 | return; | ||
661 | 681 | ||
662 | trace_drv_reset_tsf(local, sdata); | 682 | trace_drv_reset_tsf(local, sdata); |
663 | if (local->ops->reset_tsf) | 683 | if (local->ops->reset_tsf) |
@@ -689,7 +709,8 @@ static inline int drv_ampdu_action(struct ieee80211_local *local, | |||
689 | might_sleep(); | 709 | might_sleep(); |
690 | 710 | ||
691 | sdata = get_bss_sdata(sdata); | 711 | sdata = get_bss_sdata(sdata); |
692 | check_sdata_in_driver(sdata); | 712 | if (!check_sdata_in_driver(sdata)) |
713 | return -EIO; | ||
693 | 714 | ||
694 | trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size); | 715 | trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size); |
695 | 716 | ||
@@ -733,8 +754,8 @@ static inline void drv_flush(struct ieee80211_local *local, | |||
733 | 754 | ||
734 | might_sleep(); | 755 | might_sleep(); |
735 | 756 | ||
736 | if (sdata) | 757 | if (sdata && !check_sdata_in_driver(sdata)) |
737 | check_sdata_in_driver(sdata); | 758 | return; |
738 | 759 | ||
739 | trace_drv_flush(local, queues, drop); | 760 | trace_drv_flush(local, queues, drop); |
740 | if (local->ops->flush) | 761 | if (local->ops->flush) |
@@ -854,7 +875,8 @@ static inline int drv_set_bitrate_mask(struct ieee80211_local *local, | |||
854 | 875 | ||
855 | might_sleep(); | 876 | might_sleep(); |
856 | 877 | ||
857 | check_sdata_in_driver(sdata); | 878 | if (!check_sdata_in_driver(sdata)) |
879 | return -EIO; | ||
858 | 880 | ||
859 | trace_drv_set_bitrate_mask(local, sdata, mask); | 881 | trace_drv_set_bitrate_mask(local, sdata, mask); |
860 | if (local->ops->set_bitrate_mask) | 882 | if (local->ops->set_bitrate_mask) |
@@ -869,7 +891,8 @@ static inline void drv_set_rekey_data(struct ieee80211_local *local, | |||
869 | struct ieee80211_sub_if_data *sdata, | 891 | struct ieee80211_sub_if_data *sdata, |
870 | struct cfg80211_gtk_rekey_data *data) | 892 | struct cfg80211_gtk_rekey_data *data) |
871 | { | 893 | { |
872 | check_sdata_in_driver(sdata); | 894 | if (!check_sdata_in_driver(sdata)) |
895 | return; | ||
873 | 896 | ||
874 | trace_drv_set_rekey_data(local, sdata, data); | 897 | trace_drv_set_rekey_data(local, sdata, data); |
875 | if (local->ops->set_rekey_data) | 898 | if (local->ops->set_rekey_data) |
@@ -937,7 +960,8 @@ static inline void drv_mgd_prepare_tx(struct ieee80211_local *local, | |||
937 | { | 960 | { |
938 | might_sleep(); | 961 | might_sleep(); |
939 | 962 | ||
940 | check_sdata_in_driver(sdata); | 963 | if (!check_sdata_in_driver(sdata)) |
964 | return; | ||
941 | WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION); | 965 | WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION); |
942 | 966 | ||
943 | trace_drv_mgd_prepare_tx(local, sdata); | 967 | trace_drv_mgd_prepare_tx(local, sdata); |
@@ -964,6 +988,9 @@ static inline int drv_add_chanctx(struct ieee80211_local *local, | |||
964 | static inline void drv_remove_chanctx(struct ieee80211_local *local, | 988 | static inline void drv_remove_chanctx(struct ieee80211_local *local, |
965 | struct ieee80211_chanctx *ctx) | 989 | struct ieee80211_chanctx *ctx) |
966 | { | 990 | { |
991 | if (WARN_ON(!ctx->driver_present)) | ||
992 | return; | ||
993 | |||
967 | trace_drv_remove_chanctx(local, ctx); | 994 | trace_drv_remove_chanctx(local, ctx); |
968 | if (local->ops->remove_chanctx) | 995 | if (local->ops->remove_chanctx) |
969 | local->ops->remove_chanctx(&local->hw, &ctx->conf); | 996 | local->ops->remove_chanctx(&local->hw, &ctx->conf); |
@@ -989,7 +1016,8 @@ static inline int drv_assign_vif_chanctx(struct ieee80211_local *local, | |||
989 | { | 1016 | { |
990 | int ret = 0; | 1017 | int ret = 0; |
991 | 1018 | ||
992 | check_sdata_in_driver(sdata); | 1019 | if (!check_sdata_in_driver(sdata)) |
1020 | return -EIO; | ||
993 | 1021 | ||
994 | trace_drv_assign_vif_chanctx(local, sdata, ctx); | 1022 | trace_drv_assign_vif_chanctx(local, sdata, ctx); |
995 | if (local->ops->assign_vif_chanctx) { | 1023 | if (local->ops->assign_vif_chanctx) { |
@@ -1007,7 +1035,8 @@ static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local, | |||
1007 | struct ieee80211_sub_if_data *sdata, | 1035 | struct ieee80211_sub_if_data *sdata, |
1008 | struct ieee80211_chanctx *ctx) | 1036 | struct ieee80211_chanctx *ctx) |
1009 | { | 1037 | { |
1010 | check_sdata_in_driver(sdata); | 1038 | if (!check_sdata_in_driver(sdata)) |
1039 | return; | ||
1011 | 1040 | ||
1012 | trace_drv_unassign_vif_chanctx(local, sdata, ctx); | 1041 | trace_drv_unassign_vif_chanctx(local, sdata, ctx); |
1013 | if (local->ops->unassign_vif_chanctx) { | 1042 | if (local->ops->unassign_vif_chanctx) { |
@@ -1024,7 +1053,8 @@ static inline int drv_start_ap(struct ieee80211_local *local, | |||
1024 | { | 1053 | { |
1025 | int ret = 0; | 1054 | int ret = 0; |
1026 | 1055 | ||
1027 | check_sdata_in_driver(sdata); | 1056 | if (!check_sdata_in_driver(sdata)) |
1057 | return -EIO; | ||
1028 | 1058 | ||
1029 | trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf); | 1059 | trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf); |
1030 | if (local->ops->start_ap) | 1060 | if (local->ops->start_ap) |
@@ -1036,7 +1066,8 @@ static inline int drv_start_ap(struct ieee80211_local *local, | |||
1036 | static inline void drv_stop_ap(struct ieee80211_local *local, | 1066 | static inline void drv_stop_ap(struct ieee80211_local *local, |
1037 | struct ieee80211_sub_if_data *sdata) | 1067 | struct ieee80211_sub_if_data *sdata) |
1038 | { | 1068 | { |
1039 | check_sdata_in_driver(sdata); | 1069 | if (!check_sdata_in_driver(sdata)) |
1070 | return; | ||
1040 | 1071 | ||
1041 | trace_drv_stop_ap(local, sdata); | 1072 | trace_drv_stop_ap(local, sdata); |
1042 | if (local->ops->stop_ap) | 1073 | if (local->ops->stop_ap) |
@@ -1059,7 +1090,8 @@ drv_set_default_unicast_key(struct ieee80211_local *local, | |||
1059 | struct ieee80211_sub_if_data *sdata, | 1090 | struct ieee80211_sub_if_data *sdata, |
1060 | int key_idx) | 1091 | int key_idx) |
1061 | { | 1092 | { |
1062 | check_sdata_in_driver(sdata); | 1093 | if (!check_sdata_in_driver(sdata)) |
1094 | return; | ||
1063 | 1095 | ||
1064 | WARN_ON_ONCE(key_idx < -1 || key_idx > 3); | 1096 | WARN_ON_ONCE(key_idx < -1 || key_idx > 3); |
1065 | 1097 | ||
@@ -1101,7 +1133,8 @@ static inline int drv_join_ibss(struct ieee80211_local *local, | |||
1101 | int ret = 0; | 1133 | int ret = 0; |
1102 | 1134 | ||
1103 | might_sleep(); | 1135 | might_sleep(); |
1104 | check_sdata_in_driver(sdata); | 1136 | if (!check_sdata_in_driver(sdata)) |
1137 | return -EIO; | ||
1105 | 1138 | ||
1106 | trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf); | 1139 | trace_drv_join_ibss(local, sdata, &sdata->vif.bss_conf); |
1107 | if (local->ops->join_ibss) | 1140 | if (local->ops->join_ibss) |
@@ -1114,7 +1147,8 @@ static inline void drv_leave_ibss(struct ieee80211_local *local, | |||
1114 | struct ieee80211_sub_if_data *sdata) | 1147 | struct ieee80211_sub_if_data *sdata) |
1115 | { | 1148 | { |
1116 | might_sleep(); | 1149 | might_sleep(); |
1117 | check_sdata_in_driver(sdata); | 1150 | if (!check_sdata_in_driver(sdata)) |
1151 | return; | ||
1118 | 1152 | ||
1119 | trace_drv_leave_ibss(local, sdata); | 1153 | trace_drv_leave_ibss(local, sdata); |
1120 | if (local->ops->leave_ibss) | 1154 | if (local->ops->leave_ibss) |
@@ -1122,4 +1156,17 @@ static inline void drv_leave_ibss(struct ieee80211_local *local, | |||
1122 | trace_drv_return_void(local); | 1156 | trace_drv_return_void(local); |
1123 | } | 1157 | } |
1124 | 1158 | ||
1159 | static inline u32 drv_get_expected_throughput(struct ieee80211_local *local, | ||
1160 | struct ieee80211_sta *sta) | ||
1161 | { | ||
1162 | u32 ret = 0; | ||
1163 | |||
1164 | trace_drv_get_expected_throughput(sta); | ||
1165 | if (local->ops->get_expected_throughput) | ||
1166 | ret = local->ops->get_expected_throughput(sta); | ||
1167 | trace_drv_return_u32(local, ret); | ||
1168 | |||
1169 | return ret; | ||
1170 | } | ||
1171 | |||
1125 | #endif /* __MAC80211_DRIVER_OPS */ | 1172 | #endif /* __MAC80211_DRIVER_OPS */ |
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index ff4d4155a84d..1bbac94da58d 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c | |||
@@ -143,7 +143,7 @@ ieee80211_ibss_build_presp(struct ieee80211_sub_if_data *sdata, | |||
143 | *pos++ = csa_settings->block_tx ? 1 : 0; | 143 | *pos++ = csa_settings->block_tx ? 1 : 0; |
144 | *pos++ = ieee80211_frequency_to_channel( | 144 | *pos++ = ieee80211_frequency_to_channel( |
145 | csa_settings->chandef.chan->center_freq); | 145 | csa_settings->chandef.chan->center_freq); |
146 | sdata->csa_counter_offset_beacon = (pos - presp->head); | 146 | sdata->csa_counter_offset_beacon[0] = (pos - presp->head); |
147 | *pos++ = csa_settings->count; | 147 | *pos++ = csa_settings->count; |
148 | } | 148 | } |
149 | 149 | ||
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 487c2ef0982a..ac9836e0aab3 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -754,9 +754,10 @@ struct ieee80211_sub_if_data { | |||
754 | struct mac80211_qos_map __rcu *qos_map; | 754 | struct mac80211_qos_map __rcu *qos_map; |
755 | 755 | ||
756 | struct work_struct csa_finalize_work; | 756 | struct work_struct csa_finalize_work; |
757 | int csa_counter_offset_beacon; | 757 | u16 csa_counter_offset_beacon[IEEE80211_MAX_CSA_COUNTERS_NUM]; |
758 | int csa_counter_offset_presp; | 758 | u16 csa_counter_offset_presp[IEEE80211_MAX_CSA_COUNTERS_NUM]; |
759 | bool csa_radar_required; | 759 | bool csa_radar_required; |
760 | bool csa_block_tx; /* write-protected by sdata_lock and local->mtx */ | ||
760 | struct cfg80211_chan_def csa_chandef; | 761 | struct cfg80211_chan_def csa_chandef; |
761 | 762 | ||
762 | struct list_head assigned_chanctx_list; /* protected by chanctx_mtx */ | 763 | struct list_head assigned_chanctx_list; /* protected by chanctx_mtx */ |
@@ -766,6 +767,7 @@ struct ieee80211_sub_if_data { | |||
766 | struct ieee80211_chanctx *reserved_chanctx; | 767 | struct ieee80211_chanctx *reserved_chanctx; |
767 | struct cfg80211_chan_def reserved_chandef; | 768 | struct cfg80211_chan_def reserved_chandef; |
768 | bool reserved_radar_required; | 769 | bool reserved_radar_required; |
770 | u8 csa_current_counter; | ||
769 | 771 | ||
770 | /* used to reconfigure hardware SM PS */ | 772 | /* used to reconfigure hardware SM PS */ |
771 | struct work_struct recalc_smps; | 773 | struct work_struct recalc_smps; |
@@ -1459,6 +1461,7 @@ __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata, | |||
1459 | int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata, | 1461 | int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata, |
1460 | struct cfg80211_sched_scan_request *req); | 1462 | struct cfg80211_sched_scan_request *req); |
1461 | int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata); | 1463 | int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata); |
1464 | void ieee80211_sched_scan_end(struct ieee80211_local *local); | ||
1462 | void ieee80211_sched_scan_stopped_work(struct work_struct *work); | 1465 | void ieee80211_sched_scan_stopped_work(struct work_struct *work); |
1463 | 1466 | ||
1464 | /* off-channel helpers */ | 1467 | /* off-channel helpers */ |
@@ -1473,6 +1476,7 @@ void ieee80211_sw_roc_work(struct work_struct *work); | |||
1473 | void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc); | 1476 | void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc); |
1474 | 1477 | ||
1475 | /* channel switch handling */ | 1478 | /* channel switch handling */ |
1479 | bool ieee80211_csa_needs_block_tx(struct ieee80211_local *local); | ||
1476 | void ieee80211_csa_finalize_work(struct work_struct *work); | 1480 | void ieee80211_csa_finalize_work(struct work_struct *work); |
1477 | int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, | 1481 | int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, |
1478 | struct cfg80211_csa_settings *params); | 1482 | struct cfg80211_csa_settings *params); |
@@ -1834,6 +1838,15 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata, | |||
1834 | u8 radar_detect); | 1838 | u8 radar_detect); |
1835 | int ieee80211_max_num_channels(struct ieee80211_local *local); | 1839 | int ieee80211_max_num_channels(struct ieee80211_local *local); |
1836 | 1840 | ||
1841 | /* TDLS */ | ||
1842 | int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, | ||
1843 | const u8 *peer, u8 action_code, u8 dialog_token, | ||
1844 | u16 status_code, u32 peer_capability, | ||
1845 | const u8 *extra_ies, size_t extra_ies_len); | ||
1846 | int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, | ||
1847 | const u8 *peer, enum nl80211_tdls_operation oper); | ||
1848 | |||
1849 | |||
1837 | #ifdef CONFIG_MAC80211_NOINLINE | 1850 | #ifdef CONFIG_MAC80211_NOINLINE |
1838 | #define debug_noinline noinline | 1851 | #define debug_noinline noinline |
1839 | #else | 1852 | #else |
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 7fff3dcaac43..79fc98815da8 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c | |||
@@ -838,8 +838,15 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
838 | 838 | ||
839 | cancel_work_sync(&sdata->recalc_smps); | 839 | cancel_work_sync(&sdata->recalc_smps); |
840 | sdata_lock(sdata); | 840 | sdata_lock(sdata); |
841 | mutex_lock(&local->mtx); | ||
841 | sdata->vif.csa_active = false; | 842 | sdata->vif.csa_active = false; |
843 | if (!ieee80211_csa_needs_block_tx(local)) | ||
844 | ieee80211_wake_queues_by_reason(&local->hw, | ||
845 | IEEE80211_MAX_QUEUE_MAP, | ||
846 | IEEE80211_QUEUE_STOP_REASON_CSA); | ||
847 | mutex_unlock(&local->mtx); | ||
842 | sdata_unlock(sdata); | 848 | sdata_unlock(sdata); |
849 | |||
843 | cancel_work_sync(&sdata->csa_finalize_work); | 850 | cancel_work_sync(&sdata->csa_finalize_work); |
844 | 851 | ||
845 | cancel_delayed_work_sync(&sdata->dfs_cac_timer_work); | 852 | cancel_delayed_work_sync(&sdata->dfs_cac_timer_work); |
diff --git a/net/mac80211/key.c b/net/mac80211/key.c index 6ff65a1ebaa9..16d97f044a20 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c | |||
@@ -325,7 +325,8 @@ ieee80211_key_alloc(u32 cipher, int idx, size_t key_len, | |||
325 | struct ieee80211_key *key; | 325 | struct ieee80211_key *key; |
326 | int i, j, err; | 326 | int i, j, err; |
327 | 327 | ||
328 | BUG_ON(idx < 0 || idx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS); | 328 | if (WARN_ON(idx < 0 || idx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS)) |
329 | return ERR_PTR(-EINVAL); | ||
329 | 330 | ||
330 | key = kzalloc(sizeof(struct ieee80211_key) + key_len, GFP_KERNEL); | 331 | key = kzalloc(sizeof(struct ieee80211_key) + key_len, GFP_KERNEL); |
331 | if (!key) | 332 | if (!key) |
@@ -481,8 +482,8 @@ int ieee80211_key_link(struct ieee80211_key *key, | |||
481 | int idx, ret; | 482 | int idx, ret; |
482 | bool pairwise; | 483 | bool pairwise; |
483 | 484 | ||
484 | BUG_ON(!sdata); | 485 | if (WARN_ON(!sdata || !key)) |
485 | BUG_ON(!key); | 486 | return -EINVAL; |
486 | 487 | ||
487 | pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE; | 488 | pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE; |
488 | idx = key->conf.keyidx; | 489 | idx = key->conf.keyidx; |
diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 27b9364cdf17..d17c26d6e369 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c | |||
@@ -956,6 +956,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
956 | if (local->hw.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) | 956 | if (local->hw.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) |
957 | local->hw.wiphy->flags |= WIPHY_FLAG_TDLS_EXTERNAL_SETUP; | 957 | local->hw.wiphy->flags |= WIPHY_FLAG_TDLS_EXTERNAL_SETUP; |
958 | 958 | ||
959 | local->hw.wiphy->max_num_csa_counters = IEEE80211_MAX_CSA_COUNTERS_NUM; | ||
960 | |||
959 | result = wiphy_register(local->hw.wiphy); | 961 | result = wiphy_register(local->hw.wiphy); |
960 | if (result < 0) | 962 | if (result < 0) |
961 | goto fail_wiphy_register; | 963 | goto fail_wiphy_register; |
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index b06ddc9519ce..6495a3f0428d 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
@@ -679,7 +679,7 @@ ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh) | |||
679 | *pos++ = 0x0; | 679 | *pos++ = 0x0; |
680 | *pos++ = ieee80211_frequency_to_channel( | 680 | *pos++ = ieee80211_frequency_to_channel( |
681 | csa->settings.chandef.chan->center_freq); | 681 | csa->settings.chandef.chan->center_freq); |
682 | sdata->csa_counter_offset_beacon = hdr_len + 6; | 682 | sdata->csa_counter_offset_beacon[0] = hdr_len + 6; |
683 | *pos++ = csa->settings.count; | 683 | *pos++ = csa->settings.count; |
684 | *pos++ = WLAN_EID_CHAN_SWITCH_PARAM; | 684 | *pos++ = WLAN_EID_CHAN_SWITCH_PARAM; |
685 | *pos++ = 6; | 685 | *pos++ = 6; |
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 7d050ed6fe5a..cf032a8db9d7 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c | |||
@@ -287,8 +287,10 @@ static void mesh_path_move_to_queue(struct mesh_path *gate_mpath, | |||
287 | struct sk_buff_head failq; | 287 | struct sk_buff_head failq; |
288 | unsigned long flags; | 288 | unsigned long flags; |
289 | 289 | ||
290 | BUG_ON(gate_mpath == from_mpath); | 290 | if (WARN_ON(gate_mpath == from_mpath)) |
291 | BUG_ON(!gate_mpath->next_hop); | 291 | return; |
292 | if (WARN_ON(!gate_mpath->next_hop)) | ||
293 | return; | ||
292 | 294 | ||
293 | __skb_queue_head_init(&failq); | 295 | __skb_queue_head_init(&failq); |
294 | 296 | ||
diff --git a/net/mac80211/mesh_sync.c b/net/mac80211/mesh_sync.c index 2bc5dc25d5ad..09625d6205c3 100644 --- a/net/mac80211/mesh_sync.c +++ b/net/mac80211/mesh_sync.c | |||
@@ -171,7 +171,7 @@ static void mesh_sync_offset_adjust_tbtt(struct ieee80211_sub_if_data *sdata, | |||
171 | u8 cap; | 171 | u8 cap; |
172 | 172 | ||
173 | WARN_ON(ifmsh->mesh_sp_id != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET); | 173 | WARN_ON(ifmsh->mesh_sp_id != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET); |
174 | BUG_ON(!rcu_read_lock_held()); | 174 | WARN_ON(!rcu_read_lock_held()); |
175 | cap = beacon->meshconf->meshconf_cap; | 175 | cap = beacon->meshconf->meshconf_cap; |
176 | 176 | ||
177 | spin_lock_bh(&ifmsh->sync_offset_lock); | 177 | spin_lock_bh(&ifmsh->sync_offset_lock); |
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index bfb5e20796b6..3345401be1b3 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -975,16 +975,23 @@ static void ieee80211_chswitch_work(struct work_struct *work) | |||
975 | /* XXX: shouldn't really modify cfg80211-owned data! */ | 975 | /* XXX: shouldn't really modify cfg80211-owned data! */ |
976 | ifmgd->associated->channel = sdata->csa_chandef.chan; | 976 | ifmgd->associated->channel = sdata->csa_chandef.chan; |
977 | 977 | ||
978 | ieee80211_bss_info_change_notify(sdata, changed); | ||
979 | |||
980 | mutex_lock(&local->mtx); | ||
981 | sdata->vif.csa_active = false; | ||
978 | /* XXX: wait for a beacon first? */ | 982 | /* XXX: wait for a beacon first? */ |
979 | ieee80211_wake_queues_by_reason(&local->hw, | 983 | if (!ieee80211_csa_needs_block_tx(local)) |
984 | ieee80211_wake_queues_by_reason(&local->hw, | ||
980 | IEEE80211_MAX_QUEUE_MAP, | 985 | IEEE80211_MAX_QUEUE_MAP, |
981 | IEEE80211_QUEUE_STOP_REASON_CSA); | 986 | IEEE80211_QUEUE_STOP_REASON_CSA); |
987 | mutex_unlock(&local->mtx); | ||
982 | 988 | ||
983 | ieee80211_bss_info_change_notify(sdata, changed); | ||
984 | |||
985 | out: | ||
986 | sdata->vif.csa_active = false; | ||
987 | ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED; | 989 | ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED; |
990 | |||
991 | ieee80211_sta_reset_beacon_monitor(sdata); | ||
992 | ieee80211_sta_reset_conn_monitor(sdata); | ||
993 | |||
994 | out: | ||
988 | sdata_unlock(sdata); | 995 | sdata_unlock(sdata); |
989 | } | 996 | } |
990 | 997 | ||
@@ -1100,12 +1107,16 @@ ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, | |||
1100 | mutex_unlock(&local->chanctx_mtx); | 1107 | mutex_unlock(&local->chanctx_mtx); |
1101 | 1108 | ||
1102 | sdata->csa_chandef = csa_ie.chandef; | 1109 | sdata->csa_chandef = csa_ie.chandef; |
1110 | |||
1111 | mutex_lock(&local->mtx); | ||
1103 | sdata->vif.csa_active = true; | 1112 | sdata->vif.csa_active = true; |
1113 | sdata->csa_block_tx = csa_ie.mode; | ||
1104 | 1114 | ||
1105 | if (csa_ie.mode) | 1115 | if (sdata->csa_block_tx) |
1106 | ieee80211_stop_queues_by_reason(&local->hw, | 1116 | ieee80211_stop_queues_by_reason(&local->hw, |
1107 | IEEE80211_MAX_QUEUE_MAP, | 1117 | IEEE80211_MAX_QUEUE_MAP, |
1108 | IEEE80211_QUEUE_STOP_REASON_CSA); | 1118 | IEEE80211_QUEUE_STOP_REASON_CSA); |
1119 | mutex_unlock(&local->mtx); | ||
1109 | 1120 | ||
1110 | if (local->ops->channel_switch) { | 1121 | if (local->ops->channel_switch) { |
1111 | /* use driver's channel switch callback */ | 1122 | /* use driver's channel switch callback */ |
@@ -1817,6 +1828,12 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
1817 | ifmgd->flags = 0; | 1828 | ifmgd->flags = 0; |
1818 | mutex_lock(&local->mtx); | 1829 | mutex_lock(&local->mtx); |
1819 | ieee80211_vif_release_channel(sdata); | 1830 | ieee80211_vif_release_channel(sdata); |
1831 | |||
1832 | sdata->vif.csa_active = false; | ||
1833 | if (!ieee80211_csa_needs_block_tx(local)) | ||
1834 | ieee80211_wake_queues_by_reason(&local->hw, | ||
1835 | IEEE80211_MAX_QUEUE_MAP, | ||
1836 | IEEE80211_QUEUE_STOP_REASON_CSA); | ||
1820 | mutex_unlock(&local->mtx); | 1837 | mutex_unlock(&local->mtx); |
1821 | 1838 | ||
1822 | sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM; | 1839 | sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM; |
@@ -2045,6 +2062,7 @@ EXPORT_SYMBOL(ieee80211_ap_probereq_get); | |||
2045 | 2062 | ||
2046 | static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata) | 2063 | static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata) |
2047 | { | 2064 | { |
2065 | struct ieee80211_local *local = sdata->local; | ||
2048 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 2066 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
2049 | u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN]; | 2067 | u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN]; |
2050 | 2068 | ||
@@ -2058,10 +2076,14 @@ static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata) | |||
2058 | WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, | 2076 | WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, |
2059 | true, frame_buf); | 2077 | true, frame_buf); |
2060 | ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED; | 2078 | ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED; |
2079 | |||
2080 | mutex_lock(&local->mtx); | ||
2061 | sdata->vif.csa_active = false; | 2081 | sdata->vif.csa_active = false; |
2062 | ieee80211_wake_queues_by_reason(&sdata->local->hw, | 2082 | if (!ieee80211_csa_needs_block_tx(local)) |
2083 | ieee80211_wake_queues_by_reason(&local->hw, | ||
2063 | IEEE80211_MAX_QUEUE_MAP, | 2084 | IEEE80211_MAX_QUEUE_MAP, |
2064 | IEEE80211_QUEUE_STOP_REASON_CSA); | 2085 | IEEE80211_QUEUE_STOP_REASON_CSA); |
2086 | mutex_unlock(&local->mtx); | ||
2065 | 2087 | ||
2066 | cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf, | 2088 | cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf, |
2067 | IEEE80211_DEAUTH_FRAME_LEN); | 2089 | IEEE80211_DEAUTH_FRAME_LEN); |
@@ -3546,6 +3568,9 @@ static void ieee80211_sta_bcn_mon_timer(unsigned long data) | |||
3546 | if (local->quiescing) | 3568 | if (local->quiescing) |
3547 | return; | 3569 | return; |
3548 | 3570 | ||
3571 | if (sdata->vif.csa_active) | ||
3572 | return; | ||
3573 | |||
3549 | sdata->u.mgd.connection_loss = false; | 3574 | sdata->u.mgd.connection_loss = false; |
3550 | ieee80211_queue_work(&sdata->local->hw, | 3575 | ieee80211_queue_work(&sdata->local->hw, |
3551 | &sdata->u.mgd.beacon_connection_loss_work); | 3576 | &sdata->u.mgd.beacon_connection_loss_work); |
@@ -3561,6 +3586,9 @@ static void ieee80211_sta_conn_mon_timer(unsigned long data) | |||
3561 | if (local->quiescing) | 3586 | if (local->quiescing) |
3562 | return; | 3587 | return; |
3563 | 3588 | ||
3589 | if (sdata->vif.csa_active) | ||
3590 | return; | ||
3591 | |||
3564 | ieee80211_queue_work(&local->hw, &ifmgd->monitor_work); | 3592 | ieee80211_queue_work(&local->hw, &ifmgd->monitor_work); |
3565 | } | 3593 | } |
3566 | 3594 | ||
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c index 26fd94fa0aed..1c1469c36dca 100644 --- a/net/mac80211/rc80211_minstrel.c +++ b/net/mac80211/rc80211_minstrel.c | |||
@@ -657,6 +657,17 @@ minstrel_free(void *priv) | |||
657 | kfree(priv); | 657 | kfree(priv); |
658 | } | 658 | } |
659 | 659 | ||
660 | static u32 minstrel_get_expected_throughput(void *priv_sta) | ||
661 | { | ||
662 | struct minstrel_sta_info *mi = priv_sta; | ||
663 | int idx = mi->max_tp_rate[0]; | ||
664 | |||
665 | /* convert pkt per sec in kbps (1200 is the average pkt size used for | ||
666 | * computing cur_tp | ||
667 | */ | ||
668 | return MINSTREL_TRUNC(mi->r[idx].cur_tp) * 1200 * 8 / 1024; | ||
669 | } | ||
670 | |||
660 | const struct rate_control_ops mac80211_minstrel = { | 671 | const struct rate_control_ops mac80211_minstrel = { |
661 | .name = "minstrel", | 672 | .name = "minstrel", |
662 | .tx_status = minstrel_tx_status, | 673 | .tx_status = minstrel_tx_status, |
@@ -670,6 +681,7 @@ const struct rate_control_ops mac80211_minstrel = { | |||
670 | .add_sta_debugfs = minstrel_add_sta_debugfs, | 681 | .add_sta_debugfs = minstrel_add_sta_debugfs, |
671 | .remove_sta_debugfs = minstrel_remove_sta_debugfs, | 682 | .remove_sta_debugfs = minstrel_remove_sta_debugfs, |
672 | #endif | 683 | #endif |
684 | .get_expected_throughput = minstrel_get_expected_throughput, | ||
673 | }; | 685 | }; |
674 | 686 | ||
675 | int __init | 687 | int __init |
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c index bccaf854a309..85c1e74b7714 100644 --- a/net/mac80211/rc80211_minstrel_ht.c +++ b/net/mac80211/rc80211_minstrel_ht.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #define MCS_NBITS (AVG_PKT_SIZE << 3) | 22 | #define MCS_NBITS (AVG_PKT_SIZE << 3) |
23 | 23 | ||
24 | /* Number of symbols for a packet with (bps) bits per symbol */ | 24 | /* Number of symbols for a packet with (bps) bits per symbol */ |
25 | #define MCS_NSYMS(bps) ((MCS_NBITS + (bps) - 1) / (bps)) | 25 | #define MCS_NSYMS(bps) DIV_ROUND_UP(MCS_NBITS, (bps)) |
26 | 26 | ||
27 | /* Transmission time (nanoseconds) for a packet containing (syms) symbols */ | 27 | /* Transmission time (nanoseconds) for a packet containing (syms) symbols */ |
28 | #define MCS_SYMBOL_TIME(sgi, syms) \ | 28 | #define MCS_SYMBOL_TIME(sgi, syms) \ |
@@ -226,8 +226,9 @@ minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, int rate) | |||
226 | nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len); | 226 | nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len); |
227 | 227 | ||
228 | nsecs += minstrel_mcs_groups[group].duration[rate]; | 228 | nsecs += minstrel_mcs_groups[group].duration[rate]; |
229 | tp = 1000000 * ((prob * 1000) / nsecs); | ||
230 | 229 | ||
230 | /* prob is scaled - see MINSTREL_FRAC above */ | ||
231 | tp = 1000000 * ((prob * 1000) / nsecs); | ||
231 | mr->cur_tp = MINSTREL_TRUNC(tp); | 232 | mr->cur_tp = MINSTREL_TRUNC(tp); |
232 | } | 233 | } |
233 | 234 | ||
@@ -1031,6 +1032,22 @@ minstrel_ht_free(void *priv) | |||
1031 | mac80211_minstrel.free(priv); | 1032 | mac80211_minstrel.free(priv); |
1032 | } | 1033 | } |
1033 | 1034 | ||
1035 | static u32 minstrel_ht_get_expected_throughput(void *priv_sta) | ||
1036 | { | ||
1037 | struct minstrel_ht_sta_priv *msp = priv_sta; | ||
1038 | struct minstrel_ht_sta *mi = &msp->ht; | ||
1039 | int i, j; | ||
1040 | |||
1041 | if (!msp->is_ht) | ||
1042 | return mac80211_minstrel.get_expected_throughput(priv_sta); | ||
1043 | |||
1044 | i = mi->max_tp_rate / MCS_GROUP_RATES; | ||
1045 | j = mi->max_tp_rate % MCS_GROUP_RATES; | ||
1046 | |||
1047 | /* convert cur_tp from pkt per second in kbps */ | ||
1048 | return mi->groups[i].rates[j].cur_tp * AVG_PKT_SIZE * 8 / 1024; | ||
1049 | } | ||
1050 | |||
1034 | static const struct rate_control_ops mac80211_minstrel_ht = { | 1051 | static const struct rate_control_ops mac80211_minstrel_ht = { |
1035 | .name = "minstrel_ht", | 1052 | .name = "minstrel_ht", |
1036 | .tx_status = minstrel_ht_tx_status, | 1053 | .tx_status = minstrel_ht_tx_status, |
@@ -1045,6 +1062,7 @@ static const struct rate_control_ops mac80211_minstrel_ht = { | |||
1045 | .add_sta_debugfs = minstrel_ht_add_sta_debugfs, | 1062 | .add_sta_debugfs = minstrel_ht_add_sta_debugfs, |
1046 | .remove_sta_debugfs = minstrel_ht_remove_sta_debugfs, | 1063 | .remove_sta_debugfs = minstrel_ht_remove_sta_debugfs, |
1047 | #endif | 1064 | #endif |
1065 | .get_expected_throughput = minstrel_ht_get_expected_throughput, | ||
1048 | }; | 1066 | }; |
1049 | 1067 | ||
1050 | 1068 | ||
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index 28185c8dc19a..f40661eb75b5 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c | |||
@@ -1076,12 +1076,8 @@ void ieee80211_sched_scan_results(struct ieee80211_hw *hw) | |||
1076 | } | 1076 | } |
1077 | EXPORT_SYMBOL(ieee80211_sched_scan_results); | 1077 | EXPORT_SYMBOL(ieee80211_sched_scan_results); |
1078 | 1078 | ||
1079 | void ieee80211_sched_scan_stopped_work(struct work_struct *work) | 1079 | void ieee80211_sched_scan_end(struct ieee80211_local *local) |
1080 | { | 1080 | { |
1081 | struct ieee80211_local *local = | ||
1082 | container_of(work, struct ieee80211_local, | ||
1083 | sched_scan_stopped_work); | ||
1084 | |||
1085 | mutex_lock(&local->mtx); | 1081 | mutex_lock(&local->mtx); |
1086 | 1082 | ||
1087 | if (!rcu_access_pointer(local->sched_scan_sdata)) { | 1083 | if (!rcu_access_pointer(local->sched_scan_sdata)) { |
@@ -1099,6 +1095,15 @@ void ieee80211_sched_scan_stopped_work(struct work_struct *work) | |||
1099 | cfg80211_sched_scan_stopped(local->hw.wiphy); | 1095 | cfg80211_sched_scan_stopped(local->hw.wiphy); |
1100 | } | 1096 | } |
1101 | 1097 | ||
1098 | void ieee80211_sched_scan_stopped_work(struct work_struct *work) | ||
1099 | { | ||
1100 | struct ieee80211_local *local = | ||
1101 | container_of(work, struct ieee80211_local, | ||
1102 | sched_scan_stopped_work); | ||
1103 | |||
1104 | ieee80211_sched_scan_end(local); | ||
1105 | } | ||
1106 | |||
1102 | void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw) | 1107 | void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw) |
1103 | { | 1108 | { |
1104 | struct ieee80211_local *local = hw_to_local(hw); | 1109 | struct ieee80211_local *local = hw_to_local(hw); |
diff --git a/net/mac80211/tdls.c b/net/mac80211/tdls.c new file mode 100644 index 000000000000..652813b2d3df --- /dev/null +++ b/net/mac80211/tdls.c | |||
@@ -0,0 +1,325 @@ | |||
1 | /* | ||
2 | * mac80211 TDLS handling code | ||
3 | * | ||
4 | * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net> | ||
5 | * Copyright 2014, Intel Corporation | ||
6 | * | ||
7 | * This file is GPLv2 as found in COPYING. | ||
8 | */ | ||
9 | |||
10 | #include <linux/ieee80211.h> | ||
11 | #include "ieee80211_i.h" | ||
12 | |||
13 | static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb) | ||
14 | { | ||
15 | u8 *pos = (void *)skb_put(skb, 7); | ||
16 | |||
17 | *pos++ = WLAN_EID_EXT_CAPABILITY; | ||
18 | *pos++ = 5; /* len */ | ||
19 | *pos++ = 0x0; | ||
20 | *pos++ = 0x0; | ||
21 | *pos++ = 0x0; | ||
22 | *pos++ = 0x0; | ||
23 | *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED; | ||
24 | } | ||
25 | |||
26 | static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata) | ||
27 | { | ||
28 | struct ieee80211_local *local = sdata->local; | ||
29 | u16 capab; | ||
30 | |||
31 | capab = 0; | ||
32 | if (ieee80211_get_sdata_band(sdata) != IEEE80211_BAND_2GHZ) | ||
33 | return capab; | ||
34 | |||
35 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) | ||
36 | capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME; | ||
37 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)) | ||
38 | capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; | ||
39 | |||
40 | return capab; | ||
41 | } | ||
42 | |||
43 | static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, const u8 *src_addr, | ||
44 | const u8 *peer, const u8 *bssid) | ||
45 | { | ||
46 | struct ieee80211_tdls_lnkie *lnkid; | ||
47 | |||
48 | lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie)); | ||
49 | |||
50 | lnkid->ie_type = WLAN_EID_LINK_ID; | ||
51 | lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2; | ||
52 | |||
53 | memcpy(lnkid->bssid, bssid, ETH_ALEN); | ||
54 | memcpy(lnkid->init_sta, src_addr, ETH_ALEN); | ||
55 | memcpy(lnkid->resp_sta, peer, ETH_ALEN); | ||
56 | } | ||
57 | |||
58 | static int | ||
59 | ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev, | ||
60 | const u8 *peer, u8 action_code, u8 dialog_token, | ||
61 | u16 status_code, struct sk_buff *skb) | ||
62 | { | ||
63 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
64 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); | ||
65 | struct ieee80211_tdls_data *tf; | ||
66 | |||
67 | tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u)); | ||
68 | |||
69 | memcpy(tf->da, peer, ETH_ALEN); | ||
70 | memcpy(tf->sa, sdata->vif.addr, ETH_ALEN); | ||
71 | tf->ether_type = cpu_to_be16(ETH_P_TDLS); | ||
72 | tf->payload_type = WLAN_TDLS_SNAP_RFTYPE; | ||
73 | |||
74 | switch (action_code) { | ||
75 | case WLAN_TDLS_SETUP_REQUEST: | ||
76 | tf->category = WLAN_CATEGORY_TDLS; | ||
77 | tf->action_code = WLAN_TDLS_SETUP_REQUEST; | ||
78 | |||
79 | skb_put(skb, sizeof(tf->u.setup_req)); | ||
80 | tf->u.setup_req.dialog_token = dialog_token; | ||
81 | tf->u.setup_req.capability = | ||
82 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); | ||
83 | |||
84 | ieee80211_add_srates_ie(sdata, skb, false, band); | ||
85 | ieee80211_add_ext_srates_ie(sdata, skb, false, band); | ||
86 | ieee80211_tdls_add_ext_capab(skb); | ||
87 | break; | ||
88 | case WLAN_TDLS_SETUP_RESPONSE: | ||
89 | tf->category = WLAN_CATEGORY_TDLS; | ||
90 | tf->action_code = WLAN_TDLS_SETUP_RESPONSE; | ||
91 | |||
92 | skb_put(skb, sizeof(tf->u.setup_resp)); | ||
93 | tf->u.setup_resp.status_code = cpu_to_le16(status_code); | ||
94 | tf->u.setup_resp.dialog_token = dialog_token; | ||
95 | tf->u.setup_resp.capability = | ||
96 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); | ||
97 | |||
98 | ieee80211_add_srates_ie(sdata, skb, false, band); | ||
99 | ieee80211_add_ext_srates_ie(sdata, skb, false, band); | ||
100 | ieee80211_tdls_add_ext_capab(skb); | ||
101 | break; | ||
102 | case WLAN_TDLS_SETUP_CONFIRM: | ||
103 | tf->category = WLAN_CATEGORY_TDLS; | ||
104 | tf->action_code = WLAN_TDLS_SETUP_CONFIRM; | ||
105 | |||
106 | skb_put(skb, sizeof(tf->u.setup_cfm)); | ||
107 | tf->u.setup_cfm.status_code = cpu_to_le16(status_code); | ||
108 | tf->u.setup_cfm.dialog_token = dialog_token; | ||
109 | break; | ||
110 | case WLAN_TDLS_TEARDOWN: | ||
111 | tf->category = WLAN_CATEGORY_TDLS; | ||
112 | tf->action_code = WLAN_TDLS_TEARDOWN; | ||
113 | |||
114 | skb_put(skb, sizeof(tf->u.teardown)); | ||
115 | tf->u.teardown.reason_code = cpu_to_le16(status_code); | ||
116 | break; | ||
117 | case WLAN_TDLS_DISCOVERY_REQUEST: | ||
118 | tf->category = WLAN_CATEGORY_TDLS; | ||
119 | tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST; | ||
120 | |||
121 | skb_put(skb, sizeof(tf->u.discover_req)); | ||
122 | tf->u.discover_req.dialog_token = dialog_token; | ||
123 | break; | ||
124 | default: | ||
125 | return -EINVAL; | ||
126 | } | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | static int | ||
132 | ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev, | ||
133 | const u8 *peer, u8 action_code, u8 dialog_token, | ||
134 | u16 status_code, struct sk_buff *skb) | ||
135 | { | ||
136 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
137 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); | ||
138 | struct ieee80211_mgmt *mgmt; | ||
139 | |||
140 | mgmt = (void *)skb_put(skb, 24); | ||
141 | memset(mgmt, 0, 24); | ||
142 | memcpy(mgmt->da, peer, ETH_ALEN); | ||
143 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); | ||
144 | memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); | ||
145 | |||
146 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | ||
147 | IEEE80211_STYPE_ACTION); | ||
148 | |||
149 | switch (action_code) { | ||
150 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: | ||
151 | skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp)); | ||
152 | mgmt->u.action.category = WLAN_CATEGORY_PUBLIC; | ||
153 | mgmt->u.action.u.tdls_discover_resp.action_code = | ||
154 | WLAN_PUB_ACTION_TDLS_DISCOVER_RES; | ||
155 | mgmt->u.action.u.tdls_discover_resp.dialog_token = | ||
156 | dialog_token; | ||
157 | mgmt->u.action.u.tdls_discover_resp.capability = | ||
158 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); | ||
159 | |||
160 | ieee80211_add_srates_ie(sdata, skb, false, band); | ||
161 | ieee80211_add_ext_srates_ie(sdata, skb, false, band); | ||
162 | ieee80211_tdls_add_ext_capab(skb); | ||
163 | break; | ||
164 | default: | ||
165 | return -EINVAL; | ||
166 | } | ||
167 | |||
168 | return 0; | ||
169 | } | ||
170 | |||
171 | int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, | ||
172 | const u8 *peer, u8 action_code, u8 dialog_token, | ||
173 | u16 status_code, u32 peer_capability, | ||
174 | const u8 *extra_ies, size_t extra_ies_len) | ||
175 | { | ||
176 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
177 | struct ieee80211_local *local = sdata->local; | ||
178 | struct sk_buff *skb = NULL; | ||
179 | bool send_direct; | ||
180 | int ret; | ||
181 | |||
182 | if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS)) | ||
183 | return -ENOTSUPP; | ||
184 | |||
185 | /* make sure we are in managed mode, and associated */ | ||
186 | if (sdata->vif.type != NL80211_IFTYPE_STATION || | ||
187 | !sdata->u.mgd.associated) | ||
188 | return -EINVAL; | ||
189 | |||
190 | tdls_dbg(sdata, "TDLS mgmt action %d peer %pM\n", | ||
191 | action_code, peer); | ||
192 | |||
193 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + | ||
194 | max(sizeof(struct ieee80211_mgmt), | ||
195 | sizeof(struct ieee80211_tdls_data)) + | ||
196 | 50 + /* supported rates */ | ||
197 | 7 + /* ext capab */ | ||
198 | extra_ies_len + | ||
199 | sizeof(struct ieee80211_tdls_lnkie)); | ||
200 | if (!skb) | ||
201 | return -ENOMEM; | ||
202 | |||
203 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
204 | |||
205 | switch (action_code) { | ||
206 | case WLAN_TDLS_SETUP_REQUEST: | ||
207 | case WLAN_TDLS_SETUP_RESPONSE: | ||
208 | case WLAN_TDLS_SETUP_CONFIRM: | ||
209 | case WLAN_TDLS_TEARDOWN: | ||
210 | case WLAN_TDLS_DISCOVERY_REQUEST: | ||
211 | ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer, | ||
212 | action_code, dialog_token, | ||
213 | status_code, skb); | ||
214 | send_direct = false; | ||
215 | break; | ||
216 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: | ||
217 | ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code, | ||
218 | dialog_token, status_code, | ||
219 | skb); | ||
220 | send_direct = true; | ||
221 | break; | ||
222 | default: | ||
223 | ret = -ENOTSUPP; | ||
224 | break; | ||
225 | } | ||
226 | |||
227 | if (ret < 0) | ||
228 | goto fail; | ||
229 | |||
230 | if (extra_ies_len) | ||
231 | memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len); | ||
232 | |||
233 | /* the TDLS link IE is always added last */ | ||
234 | switch (action_code) { | ||
235 | case WLAN_TDLS_SETUP_REQUEST: | ||
236 | case WLAN_TDLS_SETUP_CONFIRM: | ||
237 | case WLAN_TDLS_TEARDOWN: | ||
238 | case WLAN_TDLS_DISCOVERY_REQUEST: | ||
239 | /* we are the initiator */ | ||
240 | ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer, | ||
241 | sdata->u.mgd.bssid); | ||
242 | break; | ||
243 | case WLAN_TDLS_SETUP_RESPONSE: | ||
244 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: | ||
245 | /* we are the responder */ | ||
246 | ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr, | ||
247 | sdata->u.mgd.bssid); | ||
248 | break; | ||
249 | default: | ||
250 | ret = -ENOTSUPP; | ||
251 | goto fail; | ||
252 | } | ||
253 | |||
254 | if (send_direct) { | ||
255 | ieee80211_tx_skb(sdata, skb); | ||
256 | return 0; | ||
257 | } | ||
258 | |||
259 | /* | ||
260 | * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise | ||
261 | * we should default to AC_VI. | ||
262 | */ | ||
263 | switch (action_code) { | ||
264 | case WLAN_TDLS_SETUP_REQUEST: | ||
265 | case WLAN_TDLS_SETUP_RESPONSE: | ||
266 | skb_set_queue_mapping(skb, IEEE80211_AC_BK); | ||
267 | skb->priority = 2; | ||
268 | break; | ||
269 | default: | ||
270 | skb_set_queue_mapping(skb, IEEE80211_AC_VI); | ||
271 | skb->priority = 5; | ||
272 | break; | ||
273 | } | ||
274 | |||
275 | /* disable bottom halves when entering the Tx path */ | ||
276 | local_bh_disable(); | ||
277 | ret = ieee80211_subif_start_xmit(skb, dev); | ||
278 | local_bh_enable(); | ||
279 | |||
280 | return ret; | ||
281 | |||
282 | fail: | ||
283 | dev_kfree_skb(skb); | ||
284 | return ret; | ||
285 | } | ||
286 | |||
287 | int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, | ||
288 | const u8 *peer, enum nl80211_tdls_operation oper) | ||
289 | { | ||
290 | struct sta_info *sta; | ||
291 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
292 | |||
293 | if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS)) | ||
294 | return -ENOTSUPP; | ||
295 | |||
296 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | ||
297 | return -EINVAL; | ||
298 | |||
299 | tdls_dbg(sdata, "TDLS oper %d peer %pM\n", oper, peer); | ||
300 | |||
301 | switch (oper) { | ||
302 | case NL80211_TDLS_ENABLE_LINK: | ||
303 | rcu_read_lock(); | ||
304 | sta = sta_info_get(sdata, peer); | ||
305 | if (!sta) { | ||
306 | rcu_read_unlock(); | ||
307 | return -ENOLINK; | ||
308 | } | ||
309 | |||
310 | set_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH); | ||
311 | rcu_read_unlock(); | ||
312 | break; | ||
313 | case NL80211_TDLS_DISABLE_LINK: | ||
314 | return sta_info_destroy_addr(sdata, peer); | ||
315 | case NL80211_TDLS_TEARDOWN: | ||
316 | case NL80211_TDLS_SETUP: | ||
317 | case NL80211_TDLS_DISCOVERY_REQ: | ||
318 | /* We don't support in-driver setup/teardown/discovery */ | ||
319 | return -ENOTSUPP; | ||
320 | default: | ||
321 | return -ENOTSUPP; | ||
322 | } | ||
323 | |||
324 | return 0; | ||
325 | } | ||
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h index cec5b60487a4..762e4cd16386 100644 --- a/net/mac80211/trace.h +++ b/net/mac80211/trace.h | |||
@@ -184,6 +184,20 @@ TRACE_EVENT(drv_return_bool, | |||
184 | "true" : "false") | 184 | "true" : "false") |
185 | ); | 185 | ); |
186 | 186 | ||
187 | TRACE_EVENT(drv_return_u32, | ||
188 | TP_PROTO(struct ieee80211_local *local, u32 ret), | ||
189 | TP_ARGS(local, ret), | ||
190 | TP_STRUCT__entry( | ||
191 | LOCAL_ENTRY | ||
192 | __field(u32, ret) | ||
193 | ), | ||
194 | TP_fast_assign( | ||
195 | LOCAL_ASSIGN; | ||
196 | __entry->ret = ret; | ||
197 | ), | ||
198 | TP_printk(LOCAL_PR_FMT " - %u", LOCAL_PR_ARG, __entry->ret) | ||
199 | ); | ||
200 | |||
187 | TRACE_EVENT(drv_return_u64, | 201 | TRACE_EVENT(drv_return_u64, |
188 | TP_PROTO(struct ieee80211_local *local, u64 ret), | 202 | TP_PROTO(struct ieee80211_local *local, u64 ret), |
189 | TP_ARGS(local, ret), | 203 | TP_ARGS(local, ret), |
@@ -1499,6 +1513,24 @@ DEFINE_EVENT(local_sdata_evt, drv_leave_ibss, | |||
1499 | TP_ARGS(local, sdata) | 1513 | TP_ARGS(local, sdata) |
1500 | ); | 1514 | ); |
1501 | 1515 | ||
1516 | TRACE_EVENT(drv_get_expected_throughput, | ||
1517 | TP_PROTO(struct ieee80211_sta *sta), | ||
1518 | |||
1519 | TP_ARGS(sta), | ||
1520 | |||
1521 | TP_STRUCT__entry( | ||
1522 | STA_ENTRY | ||
1523 | ), | ||
1524 | |||
1525 | TP_fast_assign( | ||
1526 | STA_ASSIGN; | ||
1527 | ), | ||
1528 | |||
1529 | TP_printk( | ||
1530 | STA_PR_FMT, STA_PR_ARG | ||
1531 | ) | ||
1532 | ); | ||
1533 | |||
1502 | /* | 1534 | /* |
1503 | * Tracing for API calls that drivers call. | 1535 | * Tracing for API calls that drivers call. |
1504 | */ | 1536 | */ |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 19d36d4117e0..5214686d9fd1 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -2328,7 +2328,8 @@ void ieee80211_tx_pending(unsigned long data) | |||
2328 | /* functions for drivers to get certain frames */ | 2328 | /* functions for drivers to get certain frames */ |
2329 | 2329 | ||
2330 | static void __ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, | 2330 | static void __ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, |
2331 | struct ps_data *ps, struct sk_buff *skb) | 2331 | struct ps_data *ps, struct sk_buff *skb, |
2332 | bool is_template) | ||
2332 | { | 2333 | { |
2333 | u8 *pos, *tim; | 2334 | u8 *pos, *tim; |
2334 | int aid0 = 0; | 2335 | int aid0 = 0; |
@@ -2341,11 +2342,12 @@ static void __ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, | |||
2341 | * checking byte-for-byte */ | 2342 | * checking byte-for-byte */ |
2342 | have_bits = !bitmap_empty((unsigned long *)ps->tim, | 2343 | have_bits = !bitmap_empty((unsigned long *)ps->tim, |
2343 | IEEE80211_MAX_AID+1); | 2344 | IEEE80211_MAX_AID+1); |
2344 | 2345 | if (!is_template) { | |
2345 | if (ps->dtim_count == 0) | 2346 | if (ps->dtim_count == 0) |
2346 | ps->dtim_count = sdata->vif.bss_conf.dtim_period - 1; | 2347 | ps->dtim_count = sdata->vif.bss_conf.dtim_period - 1; |
2347 | else | 2348 | else |
2348 | ps->dtim_count--; | 2349 | ps->dtim_count--; |
2350 | } | ||
2349 | 2351 | ||
2350 | tim = pos = (u8 *) skb_put(skb, 6); | 2352 | tim = pos = (u8 *) skb_put(skb, 6); |
2351 | *pos++ = WLAN_EID_TIM; | 2353 | *pos++ = WLAN_EID_TIM; |
@@ -2391,7 +2393,8 @@ static void __ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, | |||
2391 | } | 2393 | } |
2392 | 2394 | ||
2393 | static int ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, | 2395 | static int ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, |
2394 | struct ps_data *ps, struct sk_buff *skb) | 2396 | struct ps_data *ps, struct sk_buff *skb, |
2397 | bool is_template) | ||
2395 | { | 2398 | { |
2396 | struct ieee80211_local *local = sdata->local; | 2399 | struct ieee80211_local *local = sdata->local; |
2397 | 2400 | ||
@@ -2403,24 +2406,24 @@ static int ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, | |||
2403 | * of the tim bitmap in mac80211 and the driver. | 2406 | * of the tim bitmap in mac80211 and the driver. |
2404 | */ | 2407 | */ |
2405 | if (local->tim_in_locked_section) { | 2408 | if (local->tim_in_locked_section) { |
2406 | __ieee80211_beacon_add_tim(sdata, ps, skb); | 2409 | __ieee80211_beacon_add_tim(sdata, ps, skb, is_template); |
2407 | } else { | 2410 | } else { |
2408 | spin_lock_bh(&local->tim_lock); | 2411 | spin_lock_bh(&local->tim_lock); |
2409 | __ieee80211_beacon_add_tim(sdata, ps, skb); | 2412 | __ieee80211_beacon_add_tim(sdata, ps, skb, is_template); |
2410 | spin_unlock_bh(&local->tim_lock); | 2413 | spin_unlock_bh(&local->tim_lock); |
2411 | } | 2414 | } |
2412 | 2415 | ||
2413 | return 0; | 2416 | return 0; |
2414 | } | 2417 | } |
2415 | 2418 | ||
2416 | static void ieee80211_update_csa(struct ieee80211_sub_if_data *sdata, | 2419 | static void ieee80211_set_csa(struct ieee80211_sub_if_data *sdata, |
2417 | struct beacon_data *beacon) | 2420 | struct beacon_data *beacon) |
2418 | { | 2421 | { |
2419 | struct probe_resp *resp; | 2422 | struct probe_resp *resp; |
2420 | int counter_offset_beacon = sdata->csa_counter_offset_beacon; | ||
2421 | int counter_offset_presp = sdata->csa_counter_offset_presp; | ||
2422 | u8 *beacon_data; | 2423 | u8 *beacon_data; |
2423 | size_t beacon_data_len; | 2424 | size_t beacon_data_len; |
2425 | int i; | ||
2426 | u8 count = sdata->csa_current_counter; | ||
2424 | 2427 | ||
2425 | switch (sdata->vif.type) { | 2428 | switch (sdata->vif.type) { |
2426 | case NL80211_IFTYPE_AP: | 2429 | case NL80211_IFTYPE_AP: |
@@ -2438,40 +2441,57 @@ static void ieee80211_update_csa(struct ieee80211_sub_if_data *sdata, | |||
2438 | default: | 2441 | default: |
2439 | return; | 2442 | return; |
2440 | } | 2443 | } |
2441 | if (WARN_ON(counter_offset_beacon >= beacon_data_len)) | ||
2442 | return; | ||
2443 | 2444 | ||
2444 | /* Warn if the driver did not check for/react to csa | 2445 | for (i = 0; i < IEEE80211_MAX_CSA_COUNTERS_NUM; ++i) { |
2445 | * completeness. A beacon with CSA counter set to 0 should | 2446 | u16 counter_offset_beacon = |
2446 | * never occur, because a counter of 1 means switch just | 2447 | sdata->csa_counter_offset_beacon[i]; |
2447 | * before the next beacon. | 2448 | u16 counter_offset_presp = sdata->csa_counter_offset_presp[i]; |
2448 | */ | ||
2449 | if (WARN_ON(beacon_data[counter_offset_beacon] == 1)) | ||
2450 | return; | ||
2451 | 2449 | ||
2452 | beacon_data[counter_offset_beacon]--; | 2450 | if (counter_offset_beacon) { |
2451 | if (WARN_ON(counter_offset_beacon >= beacon_data_len)) | ||
2452 | return; | ||
2453 | 2453 | ||
2454 | if (sdata->vif.type == NL80211_IFTYPE_AP && counter_offset_presp) { | 2454 | beacon_data[counter_offset_beacon] = count; |
2455 | rcu_read_lock(); | 2455 | } |
2456 | resp = rcu_dereference(sdata->u.ap.probe_resp); | 2456 | |
2457 | if (sdata->vif.type == NL80211_IFTYPE_AP && | ||
2458 | counter_offset_presp) { | ||
2459 | rcu_read_lock(); | ||
2460 | resp = rcu_dereference(sdata->u.ap.probe_resp); | ||
2457 | 2461 | ||
2458 | /* if nl80211 accepted the offset, this should not happen. */ | 2462 | /* If nl80211 accepted the offset, this should |
2459 | if (WARN_ON(!resp)) { | 2463 | * not happen. |
2464 | */ | ||
2465 | if (WARN_ON(!resp)) { | ||
2466 | rcu_read_unlock(); | ||
2467 | return; | ||
2468 | } | ||
2469 | resp->data[counter_offset_presp] = count; | ||
2460 | rcu_read_unlock(); | 2470 | rcu_read_unlock(); |
2461 | return; | ||
2462 | } | 2471 | } |
2463 | resp->data[counter_offset_presp]--; | ||
2464 | rcu_read_unlock(); | ||
2465 | } | 2472 | } |
2466 | } | 2473 | } |
2467 | 2474 | ||
2475 | u8 ieee80211_csa_update_counter(struct ieee80211_vif *vif) | ||
2476 | { | ||
2477 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); | ||
2478 | |||
2479 | sdata->csa_current_counter--; | ||
2480 | |||
2481 | /* the counter should never reach 0 */ | ||
2482 | WARN_ON(!sdata->csa_current_counter); | ||
2483 | |||
2484 | return sdata->csa_current_counter; | ||
2485 | } | ||
2486 | EXPORT_SYMBOL(ieee80211_csa_update_counter); | ||
2487 | |||
2468 | bool ieee80211_csa_is_complete(struct ieee80211_vif *vif) | 2488 | bool ieee80211_csa_is_complete(struct ieee80211_vif *vif) |
2469 | { | 2489 | { |
2470 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); | 2490 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); |
2471 | struct beacon_data *beacon = NULL; | 2491 | struct beacon_data *beacon = NULL; |
2472 | u8 *beacon_data; | 2492 | u8 *beacon_data; |
2473 | size_t beacon_data_len; | 2493 | size_t beacon_data_len; |
2474 | int counter_beacon = sdata->csa_counter_offset_beacon; | 2494 | int counter_beacon = sdata->csa_counter_offset_beacon[0]; |
2475 | int ret = false; | 2495 | int ret = false; |
2476 | 2496 | ||
2477 | if (!ieee80211_sdata_running(sdata)) | 2497 | if (!ieee80211_sdata_running(sdata)) |
@@ -2521,9 +2541,11 @@ bool ieee80211_csa_is_complete(struct ieee80211_vif *vif) | |||
2521 | } | 2541 | } |
2522 | EXPORT_SYMBOL(ieee80211_csa_is_complete); | 2542 | EXPORT_SYMBOL(ieee80211_csa_is_complete); |
2523 | 2543 | ||
2524 | struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | 2544 | static struct sk_buff * |
2525 | struct ieee80211_vif *vif, | 2545 | __ieee80211_beacon_get(struct ieee80211_hw *hw, |
2526 | u16 *tim_offset, u16 *tim_length) | 2546 | struct ieee80211_vif *vif, |
2547 | struct ieee80211_mutable_offsets *offs, | ||
2548 | bool is_template) | ||
2527 | { | 2549 | { |
2528 | struct ieee80211_local *local = hw_to_local(hw); | 2550 | struct ieee80211_local *local = hw_to_local(hw); |
2529 | struct sk_buff *skb = NULL; | 2551 | struct sk_buff *skb = NULL; |
@@ -2532,6 +2554,7 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2532 | enum ieee80211_band band; | 2554 | enum ieee80211_band band; |
2533 | struct ieee80211_tx_rate_control txrc; | 2555 | struct ieee80211_tx_rate_control txrc; |
2534 | struct ieee80211_chanctx_conf *chanctx_conf; | 2556 | struct ieee80211_chanctx_conf *chanctx_conf; |
2557 | int csa_off_base = 0; | ||
2535 | 2558 | ||
2536 | rcu_read_lock(); | 2559 | rcu_read_lock(); |
2537 | 2560 | ||
@@ -2541,18 +2564,20 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2541 | if (!ieee80211_sdata_running(sdata) || !chanctx_conf) | 2564 | if (!ieee80211_sdata_running(sdata) || !chanctx_conf) |
2542 | goto out; | 2565 | goto out; |
2543 | 2566 | ||
2544 | if (tim_offset) | 2567 | if (offs) |
2545 | *tim_offset = 0; | 2568 | memset(offs, 0, sizeof(*offs)); |
2546 | if (tim_length) | ||
2547 | *tim_length = 0; | ||
2548 | 2569 | ||
2549 | if (sdata->vif.type == NL80211_IFTYPE_AP) { | 2570 | if (sdata->vif.type == NL80211_IFTYPE_AP) { |
2550 | struct ieee80211_if_ap *ap = &sdata->u.ap; | 2571 | struct ieee80211_if_ap *ap = &sdata->u.ap; |
2551 | struct beacon_data *beacon = rcu_dereference(ap->beacon); | 2572 | struct beacon_data *beacon = rcu_dereference(ap->beacon); |
2552 | 2573 | ||
2553 | if (beacon) { | 2574 | if (beacon) { |
2554 | if (sdata->vif.csa_active) | 2575 | if (sdata->vif.csa_active) { |
2555 | ieee80211_update_csa(sdata, beacon); | 2576 | if (!is_template) |
2577 | ieee80211_csa_update_counter(vif); | ||
2578 | |||
2579 | ieee80211_set_csa(sdata, beacon); | ||
2580 | } | ||
2556 | 2581 | ||
2557 | /* | 2582 | /* |
2558 | * headroom, head length, | 2583 | * headroom, head length, |
@@ -2569,12 +2594,16 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2569 | memcpy(skb_put(skb, beacon->head_len), beacon->head, | 2594 | memcpy(skb_put(skb, beacon->head_len), beacon->head, |
2570 | beacon->head_len); | 2595 | beacon->head_len); |
2571 | 2596 | ||
2572 | ieee80211_beacon_add_tim(sdata, &ap->ps, skb); | 2597 | ieee80211_beacon_add_tim(sdata, &ap->ps, skb, |
2598 | is_template); | ||
2573 | 2599 | ||
2574 | if (tim_offset) | 2600 | if (offs) { |
2575 | *tim_offset = beacon->head_len; | 2601 | offs->tim_offset = beacon->head_len; |
2576 | if (tim_length) | 2602 | offs->tim_length = skb->len - beacon->head_len; |
2577 | *tim_length = skb->len - beacon->head_len; | 2603 | |
2604 | /* for AP the csa offsets are from tail */ | ||
2605 | csa_off_base = skb->len; | ||
2606 | } | ||
2578 | 2607 | ||
2579 | if (beacon->tail) | 2608 | if (beacon->tail) |
2580 | memcpy(skb_put(skb, beacon->tail_len), | 2609 | memcpy(skb_put(skb, beacon->tail_len), |
@@ -2589,9 +2618,12 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2589 | if (!presp) | 2618 | if (!presp) |
2590 | goto out; | 2619 | goto out; |
2591 | 2620 | ||
2592 | if (sdata->vif.csa_active) | 2621 | if (sdata->vif.csa_active) { |
2593 | ieee80211_update_csa(sdata, presp); | 2622 | if (!is_template) |
2623 | ieee80211_csa_update_counter(vif); | ||
2594 | 2624 | ||
2625 | ieee80211_set_csa(sdata, presp); | ||
2626 | } | ||
2595 | 2627 | ||
2596 | skb = dev_alloc_skb(local->tx_headroom + presp->head_len + | 2628 | skb = dev_alloc_skb(local->tx_headroom + presp->head_len + |
2597 | local->hw.extra_beacon_tailroom); | 2629 | local->hw.extra_beacon_tailroom); |
@@ -2611,8 +2643,17 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2611 | if (!bcn) | 2643 | if (!bcn) |
2612 | goto out; | 2644 | goto out; |
2613 | 2645 | ||
2614 | if (sdata->vif.csa_active) | 2646 | if (sdata->vif.csa_active) { |
2615 | ieee80211_update_csa(sdata, bcn); | 2647 | if (!is_template) |
2648 | /* TODO: For mesh csa_counter is in TU, so | ||
2649 | * decrementing it by one isn't correct, but | ||
2650 | * for now we leave it consistent with overall | ||
2651 | * mac80211's behavior. | ||
2652 | */ | ||
2653 | ieee80211_csa_update_counter(vif); | ||
2654 | |||
2655 | ieee80211_set_csa(sdata, bcn); | ||
2656 | } | ||
2616 | 2657 | ||
2617 | if (ifmsh->sync_ops) | 2658 | if (ifmsh->sync_ops) |
2618 | ifmsh->sync_ops->adjust_tbtt(sdata, bcn); | 2659 | ifmsh->sync_ops->adjust_tbtt(sdata, bcn); |
@@ -2626,13 +2667,33 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2626 | goto out; | 2667 | goto out; |
2627 | skb_reserve(skb, local->tx_headroom); | 2668 | skb_reserve(skb, local->tx_headroom); |
2628 | memcpy(skb_put(skb, bcn->head_len), bcn->head, bcn->head_len); | 2669 | memcpy(skb_put(skb, bcn->head_len), bcn->head, bcn->head_len); |
2629 | ieee80211_beacon_add_tim(sdata, &ifmsh->ps, skb); | 2670 | ieee80211_beacon_add_tim(sdata, &ifmsh->ps, skb, is_template); |
2671 | |||
2672 | if (offs) { | ||
2673 | offs->tim_offset = bcn->head_len; | ||
2674 | offs->tim_length = skb->len - bcn->head_len; | ||
2675 | } | ||
2676 | |||
2630 | memcpy(skb_put(skb, bcn->tail_len), bcn->tail, bcn->tail_len); | 2677 | memcpy(skb_put(skb, bcn->tail_len), bcn->tail, bcn->tail_len); |
2631 | } else { | 2678 | } else { |
2632 | WARN_ON(1); | 2679 | WARN_ON(1); |
2633 | goto out; | 2680 | goto out; |
2634 | } | 2681 | } |
2635 | 2682 | ||
2683 | /* CSA offsets */ | ||
2684 | if (offs) { | ||
2685 | int i; | ||
2686 | |||
2687 | for (i = 0; i < IEEE80211_MAX_CSA_COUNTERS_NUM; i++) { | ||
2688 | u16 csa_off = sdata->csa_counter_offset_beacon[i]; | ||
2689 | |||
2690 | if (!csa_off) | ||
2691 | continue; | ||
2692 | |||
2693 | offs->csa_counter_offs[i] = csa_off_base + csa_off; | ||
2694 | } | ||
2695 | } | ||
2696 | |||
2636 | band = chanctx_conf->def.chan->band; | 2697 | band = chanctx_conf->def.chan->band; |
2637 | 2698 | ||
2638 | info = IEEE80211_SKB_CB(skb); | 2699 | info = IEEE80211_SKB_CB(skb); |
@@ -2663,6 +2724,32 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2663 | out: | 2724 | out: |
2664 | rcu_read_unlock(); | 2725 | rcu_read_unlock(); |
2665 | return skb; | 2726 | return skb; |
2727 | |||
2728 | } | ||
2729 | |||
2730 | struct sk_buff * | ||
2731 | ieee80211_beacon_get_template(struct ieee80211_hw *hw, | ||
2732 | struct ieee80211_vif *vif, | ||
2733 | struct ieee80211_mutable_offsets *offs) | ||
2734 | { | ||
2735 | return __ieee80211_beacon_get(hw, vif, offs, true); | ||
2736 | } | ||
2737 | EXPORT_SYMBOL(ieee80211_beacon_get_template); | ||
2738 | |||
2739 | struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | ||
2740 | struct ieee80211_vif *vif, | ||
2741 | u16 *tim_offset, u16 *tim_length) | ||
2742 | { | ||
2743 | struct ieee80211_mutable_offsets offs = {}; | ||
2744 | struct sk_buff *bcn = __ieee80211_beacon_get(hw, vif, &offs, false); | ||
2745 | |||
2746 | if (tim_offset) | ||
2747 | *tim_offset = offs.tim_offset; | ||
2748 | |||
2749 | if (tim_length) | ||
2750 | *tim_length = offs.tim_length; | ||
2751 | |||
2752 | return bcn; | ||
2666 | } | 2753 | } |
2667 | EXPORT_SYMBOL(ieee80211_beacon_get_tim); | 2754 | EXPORT_SYMBOL(ieee80211_beacon_get_tim); |
2668 | 2755 | ||
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index c08bd4aca6bb..6886601afe1c 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -1457,6 +1457,44 @@ void ieee80211_stop_device(struct ieee80211_local *local) | |||
1457 | drv_stop(local); | 1457 | drv_stop(local); |
1458 | } | 1458 | } |
1459 | 1459 | ||
1460 | static void ieee80211_handle_reconfig_failure(struct ieee80211_local *local) | ||
1461 | { | ||
1462 | struct ieee80211_sub_if_data *sdata; | ||
1463 | struct ieee80211_chanctx *ctx; | ||
1464 | |||
1465 | /* | ||
1466 | * We get here if during resume the device can't be restarted properly. | ||
1467 | * We might also get here if this happens during HW reset, which is a | ||
1468 | * slightly different situation and we need to drop all connections in | ||
1469 | * the latter case. | ||
1470 | * | ||
1471 | * Ask cfg80211 to turn off all interfaces, this will result in more | ||
1472 | * warnings but at least we'll then get into a clean stopped state. | ||
1473 | */ | ||
1474 | |||
1475 | local->resuming = false; | ||
1476 | local->suspended = false; | ||
1477 | local->started = false; | ||
1478 | |||
1479 | /* scheduled scan clearly can't be running any more, but tell | ||
1480 | * cfg80211 and clear local state | ||
1481 | */ | ||
1482 | ieee80211_sched_scan_end(local); | ||
1483 | |||
1484 | list_for_each_entry(sdata, &local->interfaces, list) | ||
1485 | sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER; | ||
1486 | |||
1487 | /* Mark channel contexts as not being in the driver any more to avoid | ||
1488 | * removing them from the driver during the shutdown process... | ||
1489 | */ | ||
1490 | mutex_lock(&local->chanctx_mtx); | ||
1491 | list_for_each_entry(ctx, &local->chanctx_list, list) | ||
1492 | ctx->driver_present = false; | ||
1493 | mutex_unlock(&local->chanctx_mtx); | ||
1494 | |||
1495 | cfg80211_shutdown_all_interfaces(local->hw.wiphy); | ||
1496 | } | ||
1497 | |||
1460 | static void ieee80211_assign_chanctx(struct ieee80211_local *local, | 1498 | static void ieee80211_assign_chanctx(struct ieee80211_local *local, |
1461 | struct ieee80211_sub_if_data *sdata) | 1499 | struct ieee80211_sub_if_data *sdata) |
1462 | { | 1500 | { |
@@ -1520,9 +1558,11 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1520 | */ | 1558 | */ |
1521 | res = drv_start(local); | 1559 | res = drv_start(local); |
1522 | if (res) { | 1560 | if (res) { |
1523 | WARN(local->suspended, "Hardware became unavailable " | 1561 | if (local->suspended) |
1524 | "upon resume. This could be a software issue " | 1562 | WARN(1, "Hardware became unavailable upon resume. This could be a software issue prior to suspend or a hardware issue.\n"); |
1525 | "prior to suspend or a hardware issue.\n"); | 1563 | else |
1564 | WARN(1, "Hardware became unavailable during restart.\n"); | ||
1565 | ieee80211_handle_reconfig_failure(local); | ||
1526 | return res; | 1566 | return res; |
1527 | } | 1567 | } |
1528 | 1568 | ||
diff --git a/net/nfc/digital.h b/net/nfc/digital.h index 3759add68b1b..71ad7eefddd4 100644 --- a/net/nfc/digital.h +++ b/net/nfc/digital.h | |||
@@ -71,6 +71,7 @@ static inline int digital_in_send_cmd(struct nfc_digital_dev *ddev, | |||
71 | void digital_poll_next_tech(struct nfc_digital_dev *ddev); | 71 | void digital_poll_next_tech(struct nfc_digital_dev *ddev); |
72 | 72 | ||
73 | int digital_in_send_sens_req(struct nfc_digital_dev *ddev, u8 rf_tech); | 73 | int digital_in_send_sens_req(struct nfc_digital_dev *ddev, u8 rf_tech); |
74 | int digital_in_send_sensb_req(struct nfc_digital_dev *ddev, u8 rf_tech); | ||
74 | int digital_in_send_sensf_req(struct nfc_digital_dev *ddev, u8 rf_tech); | 75 | int digital_in_send_sensf_req(struct nfc_digital_dev *ddev, u8 rf_tech); |
75 | int digital_in_send_iso15693_inv_req(struct nfc_digital_dev *ddev, u8 rf_tech); | 76 | int digital_in_send_iso15693_inv_req(struct nfc_digital_dev *ddev, u8 rf_tech); |
76 | 77 | ||
diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c index e01e15dbf1ab..b105cfb00e76 100644 --- a/net/nfc/digital_core.c +++ b/net/nfc/digital_core.c | |||
@@ -22,6 +22,8 @@ | |||
22 | #define DIGITAL_PROTO_NFCA_RF_TECH \ | 22 | #define DIGITAL_PROTO_NFCA_RF_TECH \ |
23 | (NFC_PROTO_JEWEL_MASK | NFC_PROTO_MIFARE_MASK | NFC_PROTO_NFC_DEP_MASK) | 23 | (NFC_PROTO_JEWEL_MASK | NFC_PROTO_MIFARE_MASK | NFC_PROTO_NFC_DEP_MASK) |
24 | 24 | ||
25 | #define DIGITAL_PROTO_NFCB_RF_TECH NFC_PROTO_ISO14443_B_MASK | ||
26 | |||
25 | #define DIGITAL_PROTO_NFCF_RF_TECH \ | 27 | #define DIGITAL_PROTO_NFCF_RF_TECH \ |
26 | (NFC_PROTO_FELICA_MASK | NFC_PROTO_NFC_DEP_MASK) | 28 | (NFC_PROTO_FELICA_MASK | NFC_PROTO_NFC_DEP_MASK) |
27 | 29 | ||
@@ -345,6 +347,12 @@ int digital_target_found(struct nfc_digital_dev *ddev, | |||
345 | add_crc = digital_skb_add_crc_a; | 347 | add_crc = digital_skb_add_crc_a; |
346 | break; | 348 | break; |
347 | 349 | ||
350 | case NFC_PROTO_ISO14443_B: | ||
351 | framing = NFC_DIGITAL_FRAMING_NFCB_T4T; | ||
352 | check_crc = digital_skb_check_crc_b; | ||
353 | add_crc = digital_skb_add_crc_b; | ||
354 | break; | ||
355 | |||
348 | default: | 356 | default: |
349 | pr_err("Invalid protocol %d\n", protocol); | 357 | pr_err("Invalid protocol %d\n", protocol); |
350 | return -EINVAL; | 358 | return -EINVAL; |
@@ -475,6 +483,10 @@ static int digital_start_poll(struct nfc_dev *nfc_dev, __u32 im_protocols, | |||
475 | digital_add_poll_tech(ddev, NFC_DIGITAL_RF_TECH_106A, | 483 | digital_add_poll_tech(ddev, NFC_DIGITAL_RF_TECH_106A, |
476 | digital_in_send_sens_req); | 484 | digital_in_send_sens_req); |
477 | 485 | ||
486 | if (matching_im_protocols & DIGITAL_PROTO_NFCB_RF_TECH) | ||
487 | digital_add_poll_tech(ddev, NFC_DIGITAL_RF_TECH_106B, | ||
488 | digital_in_send_sensb_req); | ||
489 | |||
478 | if (matching_im_protocols & DIGITAL_PROTO_NFCF_RF_TECH) { | 490 | if (matching_im_protocols & DIGITAL_PROTO_NFCF_RF_TECH) { |
479 | digital_add_poll_tech(ddev, NFC_DIGITAL_RF_TECH_212F, | 491 | digital_add_poll_tech(ddev, NFC_DIGITAL_RF_TECH_212F, |
480 | digital_in_send_sensf_req); | 492 | digital_in_send_sensf_req); |
@@ -635,7 +647,8 @@ static void digital_in_send_complete(struct nfc_digital_dev *ddev, void *arg, | |||
635 | goto done; | 647 | goto done; |
636 | } | 648 | } |
637 | 649 | ||
638 | if (ddev->curr_protocol == NFC_PROTO_ISO14443) { | 650 | if ((ddev->curr_protocol == NFC_PROTO_ISO14443) || |
651 | (ddev->curr_protocol == NFC_PROTO_ISO14443_B)) { | ||
639 | rc = digital_in_iso_dep_pull_sod(ddev, resp); | 652 | rc = digital_in_iso_dep_pull_sod(ddev, resp); |
640 | if (rc) | 653 | if (rc) |
641 | goto done; | 654 | goto done; |
@@ -676,7 +689,8 @@ static int digital_in_send(struct nfc_dev *nfc_dev, struct nfc_target *target, | |||
676 | goto exit; | 689 | goto exit; |
677 | } | 690 | } |
678 | 691 | ||
679 | if (ddev->curr_protocol == NFC_PROTO_ISO14443) { | 692 | if ((ddev->curr_protocol == NFC_PROTO_ISO14443) || |
693 | (ddev->curr_protocol == NFC_PROTO_ISO14443_B)) { | ||
680 | rc = digital_in_iso_dep_push_sod(ddev, skb); | 694 | rc = digital_in_iso_dep_push_sod(ddev, skb); |
681 | if (rc) | 695 | if (rc) |
682 | goto exit; | 696 | goto exit; |
@@ -747,6 +761,8 @@ struct nfc_digital_dev *nfc_digital_allocate_device(struct nfc_digital_ops *ops, | |||
747 | ddev->protocols |= NFC_PROTO_ISO15693_MASK; | 761 | ddev->protocols |= NFC_PROTO_ISO15693_MASK; |
748 | if (supported_protocols & NFC_PROTO_ISO14443_MASK) | 762 | if (supported_protocols & NFC_PROTO_ISO14443_MASK) |
749 | ddev->protocols |= NFC_PROTO_ISO14443_MASK; | 763 | ddev->protocols |= NFC_PROTO_ISO14443_MASK; |
764 | if (supported_protocols & NFC_PROTO_ISO14443_B_MASK) | ||
765 | ddev->protocols |= NFC_PROTO_ISO14443_B_MASK; | ||
750 | 766 | ||
751 | ddev->tx_headroom = tx_headroom + DIGITAL_MAX_HEADER_LEN; | 767 | ddev->tx_headroom = tx_headroom + DIGITAL_MAX_HEADER_LEN; |
752 | ddev->tx_tailroom = tx_tailroom + DIGITAL_CRC_LEN; | 768 | ddev->tx_tailroom = tx_tailroom + DIGITAL_CRC_LEN; |
diff --git a/net/nfc/digital_technology.c b/net/nfc/digital_technology.c index 278c3fed27e0..12a233e9ece5 100644 --- a/net/nfc/digital_technology.c +++ b/net/nfc/digital_technology.c | |||
@@ -41,6 +41,24 @@ | |||
41 | #define DIGITAL_MIFARE_READ_RES_LEN 16 | 41 | #define DIGITAL_MIFARE_READ_RES_LEN 16 |
42 | #define DIGITAL_MIFARE_ACK_RES 0x0A | 42 | #define DIGITAL_MIFARE_ACK_RES 0x0A |
43 | 43 | ||
44 | #define DIGITAL_CMD_SENSB_REQ 0x05 | ||
45 | #define DIGITAL_SENSB_ADVANCED BIT(5) | ||
46 | #define DIGITAL_SENSB_EXTENDED BIT(4) | ||
47 | #define DIGITAL_SENSB_ALLB_REQ BIT(3) | ||
48 | #define DIGITAL_SENSB_N(n) ((n) & 0x7) | ||
49 | |||
50 | #define DIGITAL_CMD_SENSB_RES 0x50 | ||
51 | |||
52 | #define DIGITAL_CMD_ATTRIB_REQ 0x1D | ||
53 | #define DIGITAL_ATTRIB_P1_TR0_DEFAULT (0x0 << 6) | ||
54 | #define DIGITAL_ATTRIB_P1_TR1_DEFAULT (0x0 << 4) | ||
55 | #define DIGITAL_ATTRIB_P1_SUPRESS_EOS BIT(3) | ||
56 | #define DIGITAL_ATTRIB_P1_SUPRESS_SOS BIT(2) | ||
57 | #define DIGITAL_ATTRIB_P2_LISTEN_POLL_1 (0x0 << 6) | ||
58 | #define DIGITAL_ATTRIB_P2_POLL_LISTEN_1 (0x0 << 4) | ||
59 | #define DIGITAL_ATTRIB_P2_MAX_FRAME_256 0x8 | ||
60 | #define DIGITAL_ATTRIB_P4_DID(n) ((n) & 0xf) | ||
61 | |||
44 | #define DIGITAL_CMD_SENSF_REQ 0x00 | 62 | #define DIGITAL_CMD_SENSF_REQ 0x00 |
45 | #define DIGITAL_CMD_SENSF_RES 0x01 | 63 | #define DIGITAL_CMD_SENSF_RES 0x01 |
46 | 64 | ||
@@ -75,6 +93,7 @@ static const u8 digital_ats_fsc[] = { | |||
75 | }; | 93 | }; |
76 | 94 | ||
77 | #define DIGITAL_ATS_FSCI(t0) ((t0) & 0x0F) | 95 | #define DIGITAL_ATS_FSCI(t0) ((t0) & 0x0F) |
96 | #define DIGITAL_SENSB_FSCI(pi2) (((pi2) & 0xF0) >> 4) | ||
78 | #define DIGITAL_ATS_MAX_FSC 256 | 97 | #define DIGITAL_ATS_MAX_FSC 256 |
79 | 98 | ||
80 | #define DIGITAL_RATS_BYTE1 0xE0 | 99 | #define DIGITAL_RATS_BYTE1 0xE0 |
@@ -92,6 +111,32 @@ struct digital_sel_req { | |||
92 | u8 bcc; | 111 | u8 bcc; |
93 | } __packed; | 112 | } __packed; |
94 | 113 | ||
114 | struct digital_sensb_req { | ||
115 | u8 cmd; | ||
116 | u8 afi; | ||
117 | u8 param; | ||
118 | } __packed; | ||
119 | |||
120 | struct digital_sensb_res { | ||
121 | u8 cmd; | ||
122 | u8 nfcid0[4]; | ||
123 | u8 app_data[4]; | ||
124 | u8 proto_info[3]; | ||
125 | } __packed; | ||
126 | |||
127 | struct digital_attrib_req { | ||
128 | u8 cmd; | ||
129 | u8 nfcid0[4]; | ||
130 | u8 param1; | ||
131 | u8 param2; | ||
132 | u8 param3; | ||
133 | u8 param4; | ||
134 | } __packed; | ||
135 | |||
136 | struct digital_attrib_res { | ||
137 | u8 mbli_did; | ||
138 | } __packed; | ||
139 | |||
95 | struct digital_sensf_req { | 140 | struct digital_sensf_req { |
96 | u8 cmd; | 141 | u8 cmd; |
97 | u8 sc1; | 142 | u8 sc1; |
@@ -531,6 +576,175 @@ int digital_in_recv_mifare_res(struct sk_buff *resp) | |||
531 | return -EIO; | 576 | return -EIO; |
532 | } | 577 | } |
533 | 578 | ||
579 | static void digital_in_recv_attrib_res(struct nfc_digital_dev *ddev, void *arg, | ||
580 | struct sk_buff *resp) | ||
581 | { | ||
582 | struct nfc_target *target = arg; | ||
583 | struct digital_attrib_res *attrib_res; | ||
584 | int rc; | ||
585 | |||
586 | if (IS_ERR(resp)) { | ||
587 | rc = PTR_ERR(resp); | ||
588 | resp = NULL; | ||
589 | goto exit; | ||
590 | } | ||
591 | |||
592 | if (resp->len < sizeof(*attrib_res)) { | ||
593 | PROTOCOL_ERR("12.6.2"); | ||
594 | rc = -EIO; | ||
595 | goto exit; | ||
596 | } | ||
597 | |||
598 | attrib_res = (struct digital_attrib_res *)resp->data; | ||
599 | |||
600 | if (attrib_res->mbli_did & 0x0f) { | ||
601 | PROTOCOL_ERR("12.6.2.1"); | ||
602 | rc = -EIO; | ||
603 | goto exit; | ||
604 | } | ||
605 | |||
606 | rc = digital_target_found(ddev, target, NFC_PROTO_ISO14443_B); | ||
607 | |||
608 | exit: | ||
609 | dev_kfree_skb(resp); | ||
610 | kfree(target); | ||
611 | |||
612 | if (rc) | ||
613 | digital_poll_next_tech(ddev); | ||
614 | } | ||
615 | |||
616 | int digital_in_send_attrib_req(struct nfc_digital_dev *ddev, | ||
617 | struct nfc_target *target, | ||
618 | struct digital_sensb_res *sensb_res) | ||
619 | { | ||
620 | struct digital_attrib_req *attrib_req; | ||
621 | struct sk_buff *skb; | ||
622 | int rc; | ||
623 | |||
624 | skb = digital_skb_alloc(ddev, sizeof(*attrib_req)); | ||
625 | if (!skb) | ||
626 | return -ENOMEM; | ||
627 | |||
628 | attrib_req = (struct digital_attrib_req *)skb_put(skb, | ||
629 | sizeof(*attrib_req)); | ||
630 | |||
631 | attrib_req->cmd = DIGITAL_CMD_ATTRIB_REQ; | ||
632 | memcpy(attrib_req->nfcid0, sensb_res->nfcid0, | ||
633 | sizeof(attrib_req->nfcid0)); | ||
634 | attrib_req->param1 = DIGITAL_ATTRIB_P1_TR0_DEFAULT | | ||
635 | DIGITAL_ATTRIB_P1_TR1_DEFAULT; | ||
636 | attrib_req->param2 = DIGITAL_ATTRIB_P2_LISTEN_POLL_1 | | ||
637 | DIGITAL_ATTRIB_P2_POLL_LISTEN_1 | | ||
638 | DIGITAL_ATTRIB_P2_MAX_FRAME_256; | ||
639 | attrib_req->param3 = sensb_res->proto_info[1] & 0x07; | ||
640 | attrib_req->param4 = DIGITAL_ATTRIB_P4_DID(0); | ||
641 | |||
642 | rc = digital_in_send_cmd(ddev, skb, 30, digital_in_recv_attrib_res, | ||
643 | target); | ||
644 | if (rc) | ||
645 | kfree_skb(skb); | ||
646 | |||
647 | return rc; | ||
648 | } | ||
649 | |||
650 | static void digital_in_recv_sensb_res(struct nfc_digital_dev *ddev, void *arg, | ||
651 | struct sk_buff *resp) | ||
652 | { | ||
653 | struct nfc_target *target = NULL; | ||
654 | struct digital_sensb_res *sensb_res; | ||
655 | u8 fsci; | ||
656 | int rc; | ||
657 | |||
658 | if (IS_ERR(resp)) { | ||
659 | rc = PTR_ERR(resp); | ||
660 | resp = NULL; | ||
661 | goto exit; | ||
662 | } | ||
663 | |||
664 | if (resp->len != sizeof(*sensb_res)) { | ||
665 | PROTOCOL_ERR("5.6.2.1"); | ||
666 | rc = -EIO; | ||
667 | goto exit; | ||
668 | } | ||
669 | |||
670 | sensb_res = (struct digital_sensb_res *)resp->data; | ||
671 | |||
672 | if (sensb_res->cmd != DIGITAL_CMD_SENSB_RES) { | ||
673 | PROTOCOL_ERR("5.6.2"); | ||
674 | rc = -EIO; | ||
675 | goto exit; | ||
676 | } | ||
677 | |||
678 | if (!(sensb_res->proto_info[1] & BIT(0))) { | ||
679 | PROTOCOL_ERR("5.6.2.12"); | ||
680 | rc = -EIO; | ||
681 | goto exit; | ||
682 | } | ||
683 | |||
684 | if (sensb_res->proto_info[1] & BIT(3)) { | ||
685 | PROTOCOL_ERR("5.6.2.16"); | ||
686 | rc = -EIO; | ||
687 | goto exit; | ||
688 | } | ||
689 | |||
690 | fsci = DIGITAL_SENSB_FSCI(sensb_res->proto_info[1]); | ||
691 | if (fsci >= 8) | ||
692 | ddev->target_fsc = DIGITAL_ATS_MAX_FSC; | ||
693 | else | ||
694 | ddev->target_fsc = digital_ats_fsc[fsci]; | ||
695 | |||
696 | target = kzalloc(sizeof(struct nfc_target), GFP_KERNEL); | ||
697 | if (!target) { | ||
698 | rc = -ENOMEM; | ||
699 | goto exit; | ||
700 | } | ||
701 | |||
702 | rc = digital_in_send_attrib_req(ddev, target, sensb_res); | ||
703 | |||
704 | exit: | ||
705 | dev_kfree_skb(resp); | ||
706 | |||
707 | if (rc) { | ||
708 | kfree(target); | ||
709 | digital_poll_next_tech(ddev); | ||
710 | } | ||
711 | } | ||
712 | |||
713 | int digital_in_send_sensb_req(struct nfc_digital_dev *ddev, u8 rf_tech) | ||
714 | { | ||
715 | struct digital_sensb_req *sensb_req; | ||
716 | struct sk_buff *skb; | ||
717 | int rc; | ||
718 | |||
719 | rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH, | ||
720 | NFC_DIGITAL_RF_TECH_106B); | ||
721 | if (rc) | ||
722 | return rc; | ||
723 | |||
724 | rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING, | ||
725 | NFC_DIGITAL_FRAMING_NFCB); | ||
726 | if (rc) | ||
727 | return rc; | ||
728 | |||
729 | skb = digital_skb_alloc(ddev, sizeof(*sensb_req)); | ||
730 | if (!skb) | ||
731 | return -ENOMEM; | ||
732 | |||
733 | sensb_req = (struct digital_sensb_req *)skb_put(skb, | ||
734 | sizeof(*sensb_req)); | ||
735 | |||
736 | sensb_req->cmd = DIGITAL_CMD_SENSB_REQ; | ||
737 | sensb_req->afi = 0x00; /* All families and sub-families */ | ||
738 | sensb_req->param = DIGITAL_SENSB_N(0); | ||
739 | |||
740 | rc = digital_in_send_cmd(ddev, skb, 30, digital_in_recv_sensb_res, | ||
741 | NULL); | ||
742 | if (rc) | ||
743 | kfree_skb(skb); | ||
744 | |||
745 | return rc; | ||
746 | } | ||
747 | |||
534 | static void digital_in_recv_sensf_res(struct nfc_digital_dev *ddev, void *arg, | 748 | static void digital_in_recv_sensf_res(struct nfc_digital_dev *ddev, void *arg, |
535 | struct sk_buff *resp) | 749 | struct sk_buff *resp) |
536 | { | 750 | { |
@@ -877,6 +1091,18 @@ exit: | |||
877 | dev_kfree_skb(resp); | 1091 | dev_kfree_skb(resp); |
878 | } | 1092 | } |
879 | 1093 | ||
1094 | static void digital_tg_recv_atr_or_sensf_req(struct nfc_digital_dev *ddev, | ||
1095 | void *arg, struct sk_buff *resp) | ||
1096 | { | ||
1097 | if (!IS_ERR(resp) && (resp->len >= 2) && | ||
1098 | (resp->data[1] == DIGITAL_CMD_SENSF_REQ)) | ||
1099 | digital_tg_recv_sensf_req(ddev, arg, resp); | ||
1100 | else | ||
1101 | digital_tg_recv_atr_req(ddev, arg, resp); | ||
1102 | |||
1103 | return; | ||
1104 | } | ||
1105 | |||
880 | static int digital_tg_send_sensf_res(struct nfc_digital_dev *ddev, | 1106 | static int digital_tg_send_sensf_res(struct nfc_digital_dev *ddev, |
881 | struct digital_sensf_req *sensf_req) | 1107 | struct digital_sensf_req *sensf_req) |
882 | { | 1108 | { |
@@ -887,7 +1113,7 @@ static int digital_tg_send_sensf_res(struct nfc_digital_dev *ddev, | |||
887 | 1113 | ||
888 | size = sizeof(struct digital_sensf_res); | 1114 | size = sizeof(struct digital_sensf_res); |
889 | 1115 | ||
890 | if (sensf_req->rc != DIGITAL_SENSF_REQ_RC_NONE) | 1116 | if (sensf_req->rc == DIGITAL_SENSF_REQ_RC_NONE) |
891 | size -= sizeof(sensf_res->rd); | 1117 | size -= sizeof(sensf_res->rd); |
892 | 1118 | ||
893 | skb = digital_skb_alloc(ddev, size); | 1119 | skb = digital_skb_alloc(ddev, size); |
@@ -922,7 +1148,7 @@ static int digital_tg_send_sensf_res(struct nfc_digital_dev *ddev, | |||
922 | digital_skb_add_crc_f(skb); | 1148 | digital_skb_add_crc_f(skb); |
923 | 1149 | ||
924 | rc = digital_tg_send_cmd(ddev, skb, 300, | 1150 | rc = digital_tg_send_cmd(ddev, skb, 300, |
925 | digital_tg_recv_atr_req, NULL); | 1151 | digital_tg_recv_atr_or_sensf_req, NULL); |
926 | if (rc) | 1152 | if (rc) |
927 | kfree_skb(skb); | 1153 | kfree_skb(skb); |
928 | 1154 | ||
diff --git a/net/nfc/hci/command.c b/net/nfc/hci/command.c index a9f4d2e62d8d..677d24bb70f8 100644 --- a/net/nfc/hci/command.c +++ b/net/nfc/hci/command.c | |||
@@ -26,6 +26,8 @@ | |||
26 | 26 | ||
27 | #include "hci.h" | 27 | #include "hci.h" |
28 | 28 | ||
29 | #define MAX_FWI 4949 | ||
30 | |||
29 | static int nfc_hci_execute_cmd_async(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd, | 31 | static int nfc_hci_execute_cmd_async(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd, |
30 | const u8 *param, size_t param_len, | 32 | const u8 *param, size_t param_len, |
31 | data_exchange_cb_t cb, void *cb_context) | 33 | data_exchange_cb_t cb, void *cb_context) |
@@ -37,7 +39,7 @@ static int nfc_hci_execute_cmd_async(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd, | |||
37 | * for all commands? | 39 | * for all commands? |
38 | */ | 40 | */ |
39 | return nfc_hci_hcp_message_tx(hdev, pipe, NFC_HCI_HCP_COMMAND, cmd, | 41 | return nfc_hci_hcp_message_tx(hdev, pipe, NFC_HCI_HCP_COMMAND, cmd, |
40 | param, param_len, cb, cb_context, 3000); | 42 | param, param_len, cb, cb_context, MAX_FWI); |
41 | } | 43 | } |
42 | 44 | ||
43 | /* | 45 | /* |
@@ -82,7 +84,7 @@ static int nfc_hci_execute_cmd(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd, | |||
82 | NFC_HCI_HCP_COMMAND, cmd, | 84 | NFC_HCI_HCP_COMMAND, cmd, |
83 | param, param_len, | 85 | param, param_len, |
84 | nfc_hci_execute_cb, &hcp_ew, | 86 | nfc_hci_execute_cb, &hcp_ew, |
85 | 3000); | 87 | MAX_FWI); |
86 | if (hcp_ew.exec_result < 0) | 88 | if (hcp_ew.exec_result < 0) |
87 | return hcp_ew.exec_result; | 89 | return hcp_ew.exec_result; |
88 | 90 | ||
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c index d45b638e77c7..47403705197e 100644 --- a/net/nfc/hci/core.c +++ b/net/nfc/hci/core.c | |||
@@ -225,7 +225,7 @@ int nfc_hci_target_discovered(struct nfc_hci_dev *hdev, u8 gate) | |||
225 | goto exit; | 225 | goto exit; |
226 | } | 226 | } |
227 | 227 | ||
228 | targets->sens_res = be16_to_cpu(*(u16 *)atqa_skb->data); | 228 | targets->sens_res = be16_to_cpu(*(__be16 *)atqa_skb->data); |
229 | targets->sel_res = sak_skb->data[0]; | 229 | targets->sel_res = sak_skb->data[0]; |
230 | 230 | ||
231 | r = nfc_hci_get_param(hdev, NFC_HCI_RF_READER_A_GATE, | 231 | r = nfc_hci_get_param(hdev, NFC_HCI_RF_READER_A_GATE, |
@@ -380,34 +380,31 @@ static int hci_dev_session_init(struct nfc_hci_dev *hdev) | |||
380 | if (r < 0) | 380 | if (r < 0) |
381 | goto disconnect_all; | 381 | goto disconnect_all; |
382 | 382 | ||
383 | if (skb->len && skb->len == strlen(hdev->init_data.session_id)) | 383 | if (skb->len && skb->len == strlen(hdev->init_data.session_id) && |
384 | if (memcmp(hdev->init_data.session_id, skb->data, | 384 | (memcmp(hdev->init_data.session_id, skb->data, |
385 | skb->len) == 0) { | 385 | skb->len) == 0) && hdev->ops->load_session) { |
386 | /* TODO ELa: restore gate<->pipe table from | 386 | /* Restore gate<->pipe table from some proprietary location. */ |
387 | * some TBD location. | ||
388 | * note: it doesn't seem possible to get the chip | ||
389 | * currently open gate/pipe table. | ||
390 | * It is only possible to obtain the supported | ||
391 | * gate list. | ||
392 | */ | ||
393 | 387 | ||
394 | /* goto exit | 388 | r = hdev->ops->load_session(hdev); |
395 | * For now, always do a full initialization */ | ||
396 | } | ||
397 | 389 | ||
398 | r = nfc_hci_disconnect_all_gates(hdev); | 390 | if (r < 0) |
399 | if (r < 0) | 391 | goto disconnect_all; |
400 | goto exit; | 392 | } else { |
401 | 393 | ||
402 | r = hci_dev_connect_gates(hdev, hdev->init_data.gate_count, | 394 | r = nfc_hci_disconnect_all_gates(hdev); |
403 | hdev->init_data.gates); | 395 | if (r < 0) |
404 | if (r < 0) | 396 | goto exit; |
405 | goto disconnect_all; | ||
406 | 397 | ||
407 | r = nfc_hci_set_param(hdev, NFC_HCI_ADMIN_GATE, | 398 | r = hci_dev_connect_gates(hdev, hdev->init_data.gate_count, |
408 | NFC_HCI_ADMIN_SESSION_IDENTITY, | 399 | hdev->init_data.gates); |
409 | hdev->init_data.session_id, | 400 | if (r < 0) |
410 | strlen(hdev->init_data.session_id)); | 401 | goto disconnect_all; |
402 | |||
403 | r = nfc_hci_set_param(hdev, NFC_HCI_ADMIN_GATE, | ||
404 | NFC_HCI_ADMIN_SESSION_IDENTITY, | ||
405 | hdev->init_data.session_id, | ||
406 | strlen(hdev->init_data.session_id)); | ||
407 | } | ||
411 | if (r == 0) | 408 | if (r == 0) |
412 | goto exit; | 409 | goto exit; |
413 | 410 | ||
diff --git a/net/nfc/llcp_commands.c b/net/nfc/llcp_commands.c index bec6ed15f503..a3ad69a4c648 100644 --- a/net/nfc/llcp_commands.c +++ b/net/nfc/llcp_commands.c | |||
@@ -387,7 +387,7 @@ int nfc_llcp_send_symm(struct nfc_dev *dev) | |||
387 | 387 | ||
388 | __net_timestamp(skb); | 388 | __net_timestamp(skb); |
389 | 389 | ||
390 | nfc_llcp_send_to_raw_sock(local, skb, NFC_LLCP_DIRECTION_TX); | 390 | nfc_llcp_send_to_raw_sock(local, skb, NFC_DIRECTION_TX); |
391 | 391 | ||
392 | return nfc_data_exchange(dev, local->target_idx, skb, | 392 | return nfc_data_exchange(dev, local->target_idx, skb, |
393 | nfc_llcp_recv, local); | 393 | nfc_llcp_recv, local); |
diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c index b4671958fcf9..f6278da68763 100644 --- a/net/nfc/llcp_core.c +++ b/net/nfc/llcp_core.c | |||
@@ -680,16 +680,17 @@ void nfc_llcp_send_to_raw_sock(struct nfc_llcp_local *local, | |||
680 | continue; | 680 | continue; |
681 | 681 | ||
682 | if (skb_copy == NULL) { | 682 | if (skb_copy == NULL) { |
683 | skb_copy = __pskb_copy(skb, NFC_LLCP_RAW_HEADER_SIZE, | 683 | skb_copy = __pskb_copy(skb, NFC_RAW_HEADER_SIZE, |
684 | GFP_ATOMIC); | 684 | GFP_ATOMIC); |
685 | 685 | ||
686 | if (skb_copy == NULL) | 686 | if (skb_copy == NULL) |
687 | continue; | 687 | continue; |
688 | 688 | ||
689 | data = skb_push(skb_copy, NFC_LLCP_RAW_HEADER_SIZE); | 689 | data = skb_push(skb_copy, NFC_RAW_HEADER_SIZE); |
690 | 690 | ||
691 | data[0] = local->dev ? local->dev->idx : 0xFF; | 691 | data[0] = local->dev ? local->dev->idx : 0xFF; |
692 | data[1] = direction; | 692 | data[1] = direction & 0x01; |
693 | data[1] |= (RAW_PAYLOAD_LLCP << 1); | ||
693 | } | 694 | } |
694 | 695 | ||
695 | nskb = skb_clone(skb_copy, GFP_ATOMIC); | 696 | nskb = skb_clone(skb_copy, GFP_ATOMIC); |
@@ -747,7 +748,7 @@ static void nfc_llcp_tx_work(struct work_struct *work) | |||
747 | __net_timestamp(skb); | 748 | __net_timestamp(skb); |
748 | 749 | ||
749 | nfc_llcp_send_to_raw_sock(local, skb, | 750 | nfc_llcp_send_to_raw_sock(local, skb, |
750 | NFC_LLCP_DIRECTION_TX); | 751 | NFC_DIRECTION_TX); |
751 | 752 | ||
752 | ret = nfc_data_exchange(local->dev, local->target_idx, | 753 | ret = nfc_data_exchange(local->dev, local->target_idx, |
753 | skb, nfc_llcp_recv, local); | 754 | skb, nfc_llcp_recv, local); |
@@ -1476,7 +1477,7 @@ static void nfc_llcp_rx_work(struct work_struct *work) | |||
1476 | 1477 | ||
1477 | __net_timestamp(skb); | 1478 | __net_timestamp(skb); |
1478 | 1479 | ||
1479 | nfc_llcp_send_to_raw_sock(local, skb, NFC_LLCP_DIRECTION_RX); | 1480 | nfc_llcp_send_to_raw_sock(local, skb, NFC_DIRECTION_RX); |
1480 | 1481 | ||
1481 | nfc_llcp_rx_skb(local, skb); | 1482 | nfc_llcp_rx_skb(local, skb); |
1482 | 1483 | ||
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 6c34ac978501..2b400e1a8695 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c | |||
@@ -861,6 +861,10 @@ static int nci_send_frame(struct nci_dev *ndev, struct sk_buff *skb) | |||
861 | /* Get rid of skb owner, prior to sending to the driver. */ | 861 | /* Get rid of skb owner, prior to sending to the driver. */ |
862 | skb_orphan(skb); | 862 | skb_orphan(skb); |
863 | 863 | ||
864 | /* Send copy to sniffer */ | ||
865 | nfc_send_to_raw_sock(ndev->nfc_dev, skb, | ||
866 | RAW_PAYLOAD_NCI, NFC_DIRECTION_TX); | ||
867 | |||
864 | return ndev->ops->send(ndev, skb); | 868 | return ndev->ops->send(ndev, skb); |
865 | } | 869 | } |
866 | 870 | ||
@@ -935,6 +939,11 @@ static void nci_rx_work(struct work_struct *work) | |||
935 | struct sk_buff *skb; | 939 | struct sk_buff *skb; |
936 | 940 | ||
937 | while ((skb = skb_dequeue(&ndev->rx_q))) { | 941 | while ((skb = skb_dequeue(&ndev->rx_q))) { |
942 | |||
943 | /* Send copy to sniffer */ | ||
944 | nfc_send_to_raw_sock(ndev->nfc_dev, skb, | ||
945 | RAW_PAYLOAD_NCI, NFC_DIRECTION_RX); | ||
946 | |||
938 | /* Process frame */ | 947 | /* Process frame */ |
939 | switch (nci_mt(skb->data)) { | 948 | switch (nci_mt(skb->data)) { |
940 | case NCI_MT_RSP_PKT: | 949 | case NCI_MT_RSP_PKT: |
diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c index 1e905097456b..f8f6af231381 100644 --- a/net/nfc/nci/ntf.c +++ b/net/nfc/nci/ntf.c | |||
@@ -366,7 +366,6 @@ static int nci_extract_activation_params_nfc_dep(struct nci_dev *ndev, | |||
366 | struct nci_rf_intf_activated_ntf *ntf, __u8 *data) | 366 | struct nci_rf_intf_activated_ntf *ntf, __u8 *data) |
367 | { | 367 | { |
368 | struct activation_params_poll_nfc_dep *poll; | 368 | struct activation_params_poll_nfc_dep *poll; |
369 | int i; | ||
370 | 369 | ||
371 | switch (ntf->activation_rf_tech_and_mode) { | 370 | switch (ntf->activation_rf_tech_and_mode) { |
372 | case NCI_NFC_A_PASSIVE_POLL_MODE: | 371 | case NCI_NFC_A_PASSIVE_POLL_MODE: |
@@ -374,10 +373,8 @@ static int nci_extract_activation_params_nfc_dep(struct nci_dev *ndev, | |||
374 | poll = &ntf->activation_params.poll_nfc_dep; | 373 | poll = &ntf->activation_params.poll_nfc_dep; |
375 | poll->atr_res_len = min_t(__u8, *data++, 63); | 374 | poll->atr_res_len = min_t(__u8, *data++, 63); |
376 | pr_debug("atr_res_len %d\n", poll->atr_res_len); | 375 | pr_debug("atr_res_len %d\n", poll->atr_res_len); |
377 | if (poll->atr_res_len > 0) { | 376 | if (poll->atr_res_len > 0) |
378 | for (i = 0; i < poll->atr_res_len; i++) | 377 | memcpy(poll->atr_res, data, poll->atr_res_len); |
379 | poll->atr_res[poll->atr_res_len-1-i] = data[i]; | ||
380 | } | ||
381 | break; | 378 | break; |
382 | 379 | ||
383 | default: | 380 | default: |
diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h index 9d6e74f7e6b3..88d60064890e 100644 --- a/net/nfc/nfc.h +++ b/net/nfc/nfc.h | |||
@@ -40,6 +40,12 @@ struct nfc_rawsock { | |||
40 | struct work_struct tx_work; | 40 | struct work_struct tx_work; |
41 | bool tx_work_scheduled; | 41 | bool tx_work_scheduled; |
42 | }; | 42 | }; |
43 | |||
44 | struct nfc_sock_list { | ||
45 | struct hlist_head head; | ||
46 | rwlock_t lock; | ||
47 | }; | ||
48 | |||
43 | #define nfc_rawsock(sk) ((struct nfc_rawsock *) sk) | 49 | #define nfc_rawsock(sk) ((struct nfc_rawsock *) sk) |
44 | #define to_rawsock_sk(_tx_work) \ | 50 | #define to_rawsock_sk(_tx_work) \ |
45 | ((struct sock *) container_of(_tx_work, struct nfc_rawsock, tx_work)) | 51 | ((struct sock *) container_of(_tx_work, struct nfc_rawsock, tx_work)) |
diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c index c27a6e86cae4..8627c75063e2 100644 --- a/net/nfc/rawsock.c +++ b/net/nfc/rawsock.c | |||
@@ -27,6 +27,24 @@ | |||
27 | 27 | ||
28 | #include "nfc.h" | 28 | #include "nfc.h" |
29 | 29 | ||
30 | static struct nfc_sock_list raw_sk_list = { | ||
31 | .lock = __RW_LOCK_UNLOCKED(raw_sk_list.lock) | ||
32 | }; | ||
33 | |||
34 | void nfc_sock_link(struct nfc_sock_list *l, struct sock *sk) | ||
35 | { | ||
36 | write_lock(&l->lock); | ||
37 | sk_add_node(sk, &l->head); | ||
38 | write_unlock(&l->lock); | ||
39 | } | ||
40 | |||
41 | void nfc_sock_unlink(struct nfc_sock_list *l, struct sock *sk) | ||
42 | { | ||
43 | write_lock(&l->lock); | ||
44 | sk_del_node_init(sk); | ||
45 | write_unlock(&l->lock); | ||
46 | } | ||
47 | |||
30 | static void rawsock_write_queue_purge(struct sock *sk) | 48 | static void rawsock_write_queue_purge(struct sock *sk) |
31 | { | 49 | { |
32 | pr_debug("sk=%p\n", sk); | 50 | pr_debug("sk=%p\n", sk); |
@@ -57,6 +75,9 @@ static int rawsock_release(struct socket *sock) | |||
57 | if (!sk) | 75 | if (!sk) |
58 | return 0; | 76 | return 0; |
59 | 77 | ||
78 | if (sock->type == SOCK_RAW) | ||
79 | nfc_sock_unlink(&raw_sk_list, sk); | ||
80 | |||
60 | sock_orphan(sk); | 81 | sock_orphan(sk); |
61 | sock_put(sk); | 82 | sock_put(sk); |
62 | 83 | ||
@@ -275,6 +296,26 @@ static const struct proto_ops rawsock_ops = { | |||
275 | .mmap = sock_no_mmap, | 296 | .mmap = sock_no_mmap, |
276 | }; | 297 | }; |
277 | 298 | ||
299 | static const struct proto_ops rawsock_raw_ops = { | ||
300 | .family = PF_NFC, | ||
301 | .owner = THIS_MODULE, | ||
302 | .release = rawsock_release, | ||
303 | .bind = sock_no_bind, | ||
304 | .connect = sock_no_connect, | ||
305 | .socketpair = sock_no_socketpair, | ||
306 | .accept = sock_no_accept, | ||
307 | .getname = sock_no_getname, | ||
308 | .poll = datagram_poll, | ||
309 | .ioctl = sock_no_ioctl, | ||
310 | .listen = sock_no_listen, | ||
311 | .shutdown = sock_no_shutdown, | ||
312 | .setsockopt = sock_no_setsockopt, | ||
313 | .getsockopt = sock_no_getsockopt, | ||
314 | .sendmsg = sock_no_sendmsg, | ||
315 | .recvmsg = rawsock_recvmsg, | ||
316 | .mmap = sock_no_mmap, | ||
317 | }; | ||
318 | |||
278 | static void rawsock_destruct(struct sock *sk) | 319 | static void rawsock_destruct(struct sock *sk) |
279 | { | 320 | { |
280 | pr_debug("sk=%p\n", sk); | 321 | pr_debug("sk=%p\n", sk); |
@@ -300,10 +341,13 @@ static int rawsock_create(struct net *net, struct socket *sock, | |||
300 | 341 | ||
301 | pr_debug("sock=%p\n", sock); | 342 | pr_debug("sock=%p\n", sock); |
302 | 343 | ||
303 | if (sock->type != SOCK_SEQPACKET) | 344 | if ((sock->type != SOCK_SEQPACKET) && (sock->type != SOCK_RAW)) |
304 | return -ESOCKTNOSUPPORT; | 345 | return -ESOCKTNOSUPPORT; |
305 | 346 | ||
306 | sock->ops = &rawsock_ops; | 347 | if (sock->type == SOCK_RAW) |
348 | sock->ops = &rawsock_raw_ops; | ||
349 | else | ||
350 | sock->ops = &rawsock_ops; | ||
307 | 351 | ||
308 | sk = sk_alloc(net, PF_NFC, GFP_ATOMIC, nfc_proto->proto); | 352 | sk = sk_alloc(net, PF_NFC, GFP_ATOMIC, nfc_proto->proto); |
309 | if (!sk) | 353 | if (!sk) |
@@ -313,13 +357,53 @@ static int rawsock_create(struct net *net, struct socket *sock, | |||
313 | sk->sk_protocol = nfc_proto->id; | 357 | sk->sk_protocol = nfc_proto->id; |
314 | sk->sk_destruct = rawsock_destruct; | 358 | sk->sk_destruct = rawsock_destruct; |
315 | sock->state = SS_UNCONNECTED; | 359 | sock->state = SS_UNCONNECTED; |
316 | 360 | if (sock->type == SOCK_RAW) | |
317 | INIT_WORK(&nfc_rawsock(sk)->tx_work, rawsock_tx_work); | 361 | nfc_sock_link(&raw_sk_list, sk); |
318 | nfc_rawsock(sk)->tx_work_scheduled = false; | 362 | else { |
363 | INIT_WORK(&nfc_rawsock(sk)->tx_work, rawsock_tx_work); | ||
364 | nfc_rawsock(sk)->tx_work_scheduled = false; | ||
365 | } | ||
319 | 366 | ||
320 | return 0; | 367 | return 0; |
321 | } | 368 | } |
322 | 369 | ||
370 | void nfc_send_to_raw_sock(struct nfc_dev *dev, struct sk_buff *skb, | ||
371 | u8 payload_type, u8 direction) | ||
372 | { | ||
373 | struct sk_buff *skb_copy = NULL, *nskb; | ||
374 | struct sock *sk; | ||
375 | u8 *data; | ||
376 | |||
377 | read_lock(&raw_sk_list.lock); | ||
378 | |||
379 | sk_for_each(sk, &raw_sk_list.head) { | ||
380 | if (!skb_copy) { | ||
381 | skb_copy = __pskb_copy(skb, NFC_RAW_HEADER_SIZE, | ||
382 | GFP_ATOMIC); | ||
383 | if (!skb_copy) | ||
384 | continue; | ||
385 | |||
386 | data = skb_push(skb_copy, NFC_RAW_HEADER_SIZE); | ||
387 | |||
388 | data[0] = dev ? dev->idx : 0xFF; | ||
389 | data[1] = direction & 0x01; | ||
390 | data[1] |= (payload_type << 1); | ||
391 | } | ||
392 | |||
393 | nskb = skb_clone(skb_copy, GFP_ATOMIC); | ||
394 | if (!nskb) | ||
395 | continue; | ||
396 | |||
397 | if (sock_queue_rcv_skb(sk, nskb)) | ||
398 | kfree_skb(nskb); | ||
399 | } | ||
400 | |||
401 | read_unlock(&raw_sk_list.lock); | ||
402 | |||
403 | kfree_skb(skb_copy); | ||
404 | } | ||
405 | EXPORT_SYMBOL(nfc_send_to_raw_sock); | ||
406 | |||
323 | static struct proto rawsock_proto = { | 407 | static struct proto rawsock_proto = { |
324 | .name = "NFC_RAW", | 408 | .name = "NFC_RAW", |
325 | .owner = THIS_MODULE, | 409 | .owner = THIS_MODULE, |
diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c index bd2a5b90400c..14c98e48f261 100644 --- a/net/rfkill/rfkill-gpio.c +++ b/net/rfkill/rfkill-gpio.c | |||
@@ -36,8 +36,6 @@ struct rfkill_gpio_data { | |||
36 | struct gpio_desc *shutdown_gpio; | 36 | struct gpio_desc *shutdown_gpio; |
37 | 37 | ||
38 | struct rfkill *rfkill_dev; | 38 | struct rfkill *rfkill_dev; |
39 | char *reset_name; | ||
40 | char *shutdown_name; | ||
41 | struct clk *clk; | 39 | struct clk *clk; |
42 | 40 | ||
43 | bool clk_enabled; | 41 | bool clk_enabled; |
@@ -47,17 +45,14 @@ static int rfkill_gpio_set_power(void *data, bool blocked) | |||
47 | { | 45 | { |
48 | struct rfkill_gpio_data *rfkill = data; | 46 | struct rfkill_gpio_data *rfkill = data; |
49 | 47 | ||
50 | if (blocked) { | 48 | if (!blocked && !IS_ERR(rfkill->clk) && !rfkill->clk_enabled) |
51 | gpiod_set_value(rfkill->shutdown_gpio, 0); | 49 | clk_enable(rfkill->clk); |
52 | gpiod_set_value(rfkill->reset_gpio, 0); | 50 | |
53 | if (!IS_ERR(rfkill->clk) && rfkill->clk_enabled) | 51 | gpiod_set_value_cansleep(rfkill->shutdown_gpio, !blocked); |
54 | clk_disable(rfkill->clk); | 52 | gpiod_set_value_cansleep(rfkill->reset_gpio, !blocked); |
55 | } else { | 53 | |
56 | if (!IS_ERR(rfkill->clk) && !rfkill->clk_enabled) | 54 | if (blocked && !IS_ERR(rfkill->clk) && rfkill->clk_enabled) |
57 | clk_enable(rfkill->clk); | 55 | clk_disable(rfkill->clk); |
58 | gpiod_set_value(rfkill->reset_gpio, 1); | ||
59 | gpiod_set_value(rfkill->shutdown_gpio, 1); | ||
60 | } | ||
61 | 56 | ||
62 | rfkill->clk_enabled = blocked; | 57 | rfkill->clk_enabled = blocked; |
63 | 58 | ||
@@ -87,10 +82,8 @@ static int rfkill_gpio_probe(struct platform_device *pdev) | |||
87 | { | 82 | { |
88 | struct rfkill_gpio_platform_data *pdata = pdev->dev.platform_data; | 83 | struct rfkill_gpio_platform_data *pdata = pdev->dev.platform_data; |
89 | struct rfkill_gpio_data *rfkill; | 84 | struct rfkill_gpio_data *rfkill; |
90 | const char *clk_name = NULL; | ||
91 | struct gpio_desc *gpio; | 85 | struct gpio_desc *gpio; |
92 | int ret; | 86 | int ret; |
93 | int len; | ||
94 | 87 | ||
95 | rfkill = devm_kzalloc(&pdev->dev, sizeof(*rfkill), GFP_KERNEL); | 88 | rfkill = devm_kzalloc(&pdev->dev, sizeof(*rfkill), GFP_KERNEL); |
96 | if (!rfkill) | 89 | if (!rfkill) |
@@ -101,28 +94,15 @@ static int rfkill_gpio_probe(struct platform_device *pdev) | |||
101 | if (ret) | 94 | if (ret) |
102 | return ret; | 95 | return ret; |
103 | } else if (pdata) { | 96 | } else if (pdata) { |
104 | clk_name = pdata->power_clk_name; | ||
105 | rfkill->name = pdata->name; | 97 | rfkill->name = pdata->name; |
106 | rfkill->type = pdata->type; | 98 | rfkill->type = pdata->type; |
107 | } else { | 99 | } else { |
108 | return -ENODEV; | 100 | return -ENODEV; |
109 | } | 101 | } |
110 | 102 | ||
111 | len = strlen(rfkill->name); | 103 | rfkill->clk = devm_clk_get(&pdev->dev, NULL); |
112 | rfkill->reset_name = devm_kzalloc(&pdev->dev, len + 7, GFP_KERNEL); | ||
113 | if (!rfkill->reset_name) | ||
114 | return -ENOMEM; | ||
115 | |||
116 | rfkill->shutdown_name = devm_kzalloc(&pdev->dev, len + 10, GFP_KERNEL); | ||
117 | if (!rfkill->shutdown_name) | ||
118 | return -ENOMEM; | ||
119 | 104 | ||
120 | snprintf(rfkill->reset_name, len + 6 , "%s_reset", rfkill->name); | 105 | gpio = devm_gpiod_get_index(&pdev->dev, "reset", 0); |
121 | snprintf(rfkill->shutdown_name, len + 9, "%s_shutdown", rfkill->name); | ||
122 | |||
123 | rfkill->clk = devm_clk_get(&pdev->dev, clk_name); | ||
124 | |||
125 | gpio = devm_gpiod_get_index(&pdev->dev, rfkill->reset_name, 0); | ||
126 | if (!IS_ERR(gpio)) { | 106 | if (!IS_ERR(gpio)) { |
127 | ret = gpiod_direction_output(gpio, 0); | 107 | ret = gpiod_direction_output(gpio, 0); |
128 | if (ret) | 108 | if (ret) |
@@ -130,7 +110,7 @@ static int rfkill_gpio_probe(struct platform_device *pdev) | |||
130 | rfkill->reset_gpio = gpio; | 110 | rfkill->reset_gpio = gpio; |
131 | } | 111 | } |
132 | 112 | ||
133 | gpio = devm_gpiod_get_index(&pdev->dev, rfkill->shutdown_name, 1); | 113 | gpio = devm_gpiod_get_index(&pdev->dev, "shutdown", 1); |
134 | if (!IS_ERR(gpio)) { | 114 | if (!IS_ERR(gpio)) { |
135 | ret = gpiod_direction_output(gpio, 0); | 115 | ret = gpiod_direction_output(gpio, 0); |
136 | if (ret) | 116 | if (ret) |
@@ -146,14 +126,6 @@ static int rfkill_gpio_probe(struct platform_device *pdev) | |||
146 | return -EINVAL; | 126 | return -EINVAL; |
147 | } | 127 | } |
148 | 128 | ||
149 | if (pdata && pdata->gpio_runtime_setup) { | ||
150 | ret = pdata->gpio_runtime_setup(pdev); | ||
151 | if (ret) { | ||
152 | dev_err(&pdev->dev, "can't set up gpio\n"); | ||
153 | return ret; | ||
154 | } | ||
155 | } | ||
156 | |||
157 | rfkill->rfkill_dev = rfkill_alloc(rfkill->name, &pdev->dev, | 129 | rfkill->rfkill_dev = rfkill_alloc(rfkill->name, &pdev->dev, |
158 | rfkill->type, &rfkill_gpio_ops, | 130 | rfkill->type, &rfkill_gpio_ops, |
159 | rfkill); | 131 | rfkill); |
@@ -174,20 +146,23 @@ static int rfkill_gpio_probe(struct platform_device *pdev) | |||
174 | static int rfkill_gpio_remove(struct platform_device *pdev) | 146 | static int rfkill_gpio_remove(struct platform_device *pdev) |
175 | { | 147 | { |
176 | struct rfkill_gpio_data *rfkill = platform_get_drvdata(pdev); | 148 | struct rfkill_gpio_data *rfkill = platform_get_drvdata(pdev); |
177 | struct rfkill_gpio_platform_data *pdata = pdev->dev.platform_data; | ||
178 | 149 | ||
179 | if (pdata && pdata->gpio_runtime_close) | ||
180 | pdata->gpio_runtime_close(pdev); | ||
181 | rfkill_unregister(rfkill->rfkill_dev); | 150 | rfkill_unregister(rfkill->rfkill_dev); |
182 | rfkill_destroy(rfkill->rfkill_dev); | 151 | rfkill_destroy(rfkill->rfkill_dev); |
183 | 152 | ||
184 | return 0; | 153 | return 0; |
185 | } | 154 | } |
186 | 155 | ||
156 | #ifdef CONFIG_ACPI | ||
187 | static const struct acpi_device_id rfkill_acpi_match[] = { | 157 | static const struct acpi_device_id rfkill_acpi_match[] = { |
158 | { "BCM2E1A", RFKILL_TYPE_BLUETOOTH }, | ||
159 | { "BCM2E39", RFKILL_TYPE_BLUETOOTH }, | ||
160 | { "BCM2E3D", RFKILL_TYPE_BLUETOOTH }, | ||
188 | { "BCM4752", RFKILL_TYPE_GPS }, | 161 | { "BCM4752", RFKILL_TYPE_GPS }, |
162 | { "LNV4752", RFKILL_TYPE_GPS }, | ||
189 | { }, | 163 | { }, |
190 | }; | 164 | }; |
165 | #endif | ||
191 | 166 | ||
192 | static struct platform_driver rfkill_gpio_driver = { | 167 | static struct platform_driver rfkill_gpio_driver = { |
193 | .probe = rfkill_gpio_probe, | 168 | .probe = rfkill_gpio_probe, |
diff --git a/net/wireless/ap.c b/net/wireless/ap.c index 3e02ade508d8..bdad1f951561 100644 --- a/net/wireless/ap.c +++ b/net/wireless/ap.c | |||
@@ -6,8 +6,8 @@ | |||
6 | #include "rdev-ops.h" | 6 | #include "rdev-ops.h" |
7 | 7 | ||
8 | 8 | ||
9 | static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, | 9 | int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, |
10 | struct net_device *dev, bool notify) | 10 | struct net_device *dev, bool notify) |
11 | { | 11 | { |
12 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 12 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
13 | int err; | 13 | int err; |
diff --git a/net/wireless/chan.c b/net/wireless/chan.c index 84d686e2dbd0..992b34070bcb 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c | |||
@@ -370,8 +370,8 @@ int cfg80211_chandef_dfs_required(struct wiphy *wiphy, | |||
370 | case NL80211_IFTYPE_AP_VLAN: | 370 | case NL80211_IFTYPE_AP_VLAN: |
371 | case NL80211_IFTYPE_WDS: | 371 | case NL80211_IFTYPE_WDS: |
372 | case NL80211_IFTYPE_P2P_DEVICE: | 372 | case NL80211_IFTYPE_P2P_DEVICE: |
373 | case NL80211_IFTYPE_UNSPECIFIED: | ||
374 | break; | 373 | break; |
374 | case NL80211_IFTYPE_UNSPECIFIED: | ||
375 | case NUM_NL80211_IFTYPES: | 375 | case NUM_NL80211_IFTYPES: |
376 | WARN_ON(1); | 376 | WARN_ON(1); |
377 | } | 377 | } |
@@ -796,8 +796,7 @@ bool cfg80211_reg_can_beacon(struct wiphy *wiphy, | |||
796 | !cfg80211_go_permissive_chan(rdev, chandef->chan)) | 796 | !cfg80211_go_permissive_chan(rdev, chandef->chan)) |
797 | prohibited_flags |= IEEE80211_CHAN_NO_IR; | 797 | prohibited_flags |= IEEE80211_CHAN_NO_IR; |
798 | 798 | ||
799 | if (cfg80211_chandef_dfs_required(wiphy, chandef, | 799 | if (cfg80211_chandef_dfs_required(wiphy, chandef, iftype) > 0 && |
800 | NL80211_IFTYPE_UNSPECIFIED) > 0 && | ||
801 | cfg80211_chandef_dfs_available(wiphy, chandef)) { | 800 | cfg80211_chandef_dfs_available(wiphy, chandef)) { |
802 | /* We can skip IEEE80211_CHAN_NO_IR if chandef dfs available */ | 801 | /* We can skip IEEE80211_CHAN_NO_IR if chandef dfs available */ |
803 | prohibited_flags = IEEE80211_CHAN_DISABLED; | 802 | prohibited_flags = IEEE80211_CHAN_DISABLED; |
diff --git a/net/wireless/core.c b/net/wireless/core.c index b3ff3697239a..d03d8bdb29ca 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c | |||
@@ -210,15 +210,12 @@ void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev, | |||
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||
213 | static int cfg80211_rfkill_set_block(void *data, bool blocked) | 213 | void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy) |
214 | { | 214 | { |
215 | struct cfg80211_registered_device *rdev = data; | 215 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); |
216 | struct wireless_dev *wdev; | 216 | struct wireless_dev *wdev; |
217 | 217 | ||
218 | if (!blocked) | 218 | ASSERT_RTNL(); |
219 | return 0; | ||
220 | |||
221 | rtnl_lock(); | ||
222 | 219 | ||
223 | list_for_each_entry(wdev, &rdev->wdev_list, list) { | 220 | list_for_each_entry(wdev, &rdev->wdev_list, list) { |
224 | if (wdev->netdev) { | 221 | if (wdev->netdev) { |
@@ -234,7 +231,18 @@ static int cfg80211_rfkill_set_block(void *data, bool blocked) | |||
234 | break; | 231 | break; |
235 | } | 232 | } |
236 | } | 233 | } |
234 | } | ||
235 | EXPORT_SYMBOL_GPL(cfg80211_shutdown_all_interfaces); | ||
237 | 236 | ||
237 | static int cfg80211_rfkill_set_block(void *data, bool blocked) | ||
238 | { | ||
239 | struct cfg80211_registered_device *rdev = data; | ||
240 | |||
241 | if (!blocked) | ||
242 | return 0; | ||
243 | |||
244 | rtnl_lock(); | ||
245 | cfg80211_shutdown_all_interfaces(&rdev->wiphy); | ||
238 | rtnl_unlock(); | 246 | rtnl_unlock(); |
239 | 247 | ||
240 | return 0; | 248 | return 0; |
@@ -394,6 +402,8 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv) | |||
394 | rdev->wiphy.rts_threshold = (u32) -1; | 402 | rdev->wiphy.rts_threshold = (u32) -1; |
395 | rdev->wiphy.coverage_class = 0; | 403 | rdev->wiphy.coverage_class = 0; |
396 | 404 | ||
405 | rdev->wiphy.max_num_csa_counters = 1; | ||
406 | |||
397 | return &rdev->wiphy; | 407 | return &rdev->wiphy; |
398 | } | 408 | } |
399 | EXPORT_SYMBOL(wiphy_new); | 409 | EXPORT_SYMBOL(wiphy_new); |
@@ -690,7 +700,7 @@ void wiphy_unregister(struct wiphy *wiphy) | |||
690 | rtnl_lock(); | 700 | rtnl_lock(); |
691 | rdev->wiphy.registered = false; | 701 | rdev->wiphy.registered = false; |
692 | 702 | ||
693 | BUG_ON(!list_empty(&rdev->wdev_list)); | 703 | WARN_ON(!list_empty(&rdev->wdev_list)); |
694 | 704 | ||
695 | /* | 705 | /* |
696 | * First remove the hardware from everywhere, this makes | 706 | * First remove the hardware from everywhere, this makes |
@@ -792,23 +802,23 @@ void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev, | |||
792 | rdev->num_running_monitor_ifaces += num; | 802 | rdev->num_running_monitor_ifaces += num; |
793 | } | 803 | } |
794 | 804 | ||
795 | void cfg80211_leave(struct cfg80211_registered_device *rdev, | 805 | void __cfg80211_leave(struct cfg80211_registered_device *rdev, |
796 | struct wireless_dev *wdev) | 806 | struct wireless_dev *wdev) |
797 | { | 807 | { |
798 | struct net_device *dev = wdev->netdev; | 808 | struct net_device *dev = wdev->netdev; |
799 | 809 | ||
800 | ASSERT_RTNL(); | 810 | ASSERT_RTNL(); |
811 | ASSERT_WDEV_LOCK(wdev); | ||
801 | 812 | ||
802 | switch (wdev->iftype) { | 813 | switch (wdev->iftype) { |
803 | case NL80211_IFTYPE_ADHOC: | 814 | case NL80211_IFTYPE_ADHOC: |
804 | cfg80211_leave_ibss(rdev, dev, true); | 815 | __cfg80211_leave_ibss(rdev, dev, true); |
805 | break; | 816 | break; |
806 | case NL80211_IFTYPE_P2P_CLIENT: | 817 | case NL80211_IFTYPE_P2P_CLIENT: |
807 | case NL80211_IFTYPE_STATION: | 818 | case NL80211_IFTYPE_STATION: |
808 | if (rdev->sched_scan_req && dev == rdev->sched_scan_req->dev) | 819 | if (rdev->sched_scan_req && dev == rdev->sched_scan_req->dev) |
809 | __cfg80211_stop_sched_scan(rdev, false); | 820 | __cfg80211_stop_sched_scan(rdev, false); |
810 | 821 | ||
811 | wdev_lock(wdev); | ||
812 | #ifdef CONFIG_CFG80211_WEXT | 822 | #ifdef CONFIG_CFG80211_WEXT |
813 | kfree(wdev->wext.ie); | 823 | kfree(wdev->wext.ie); |
814 | wdev->wext.ie = NULL; | 824 | wdev->wext.ie = NULL; |
@@ -817,20 +827,49 @@ void cfg80211_leave(struct cfg80211_registered_device *rdev, | |||
817 | #endif | 827 | #endif |
818 | cfg80211_disconnect(rdev, dev, | 828 | cfg80211_disconnect(rdev, dev, |
819 | WLAN_REASON_DEAUTH_LEAVING, true); | 829 | WLAN_REASON_DEAUTH_LEAVING, true); |
820 | wdev_unlock(wdev); | ||
821 | break; | 830 | break; |
822 | case NL80211_IFTYPE_MESH_POINT: | 831 | case NL80211_IFTYPE_MESH_POINT: |
823 | cfg80211_leave_mesh(rdev, dev); | 832 | __cfg80211_leave_mesh(rdev, dev); |
824 | break; | 833 | break; |
825 | case NL80211_IFTYPE_AP: | 834 | case NL80211_IFTYPE_AP: |
826 | case NL80211_IFTYPE_P2P_GO: | 835 | case NL80211_IFTYPE_P2P_GO: |
827 | cfg80211_stop_ap(rdev, dev, true); | 836 | __cfg80211_stop_ap(rdev, dev, true); |
828 | break; | 837 | break; |
829 | default: | 838 | default: |
830 | break; | 839 | break; |
831 | } | 840 | } |
832 | } | 841 | } |
833 | 842 | ||
843 | void cfg80211_leave(struct cfg80211_registered_device *rdev, | ||
844 | struct wireless_dev *wdev) | ||
845 | { | ||
846 | wdev_lock(wdev); | ||
847 | __cfg80211_leave(rdev, wdev); | ||
848 | wdev_unlock(wdev); | ||
849 | } | ||
850 | |||
851 | void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev, | ||
852 | gfp_t gfp) | ||
853 | { | ||
854 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); | ||
855 | struct cfg80211_event *ev; | ||
856 | unsigned long flags; | ||
857 | |||
858 | trace_cfg80211_stop_iface(wiphy, wdev); | ||
859 | |||
860 | ev = kzalloc(sizeof(*ev), gfp); | ||
861 | if (!ev) | ||
862 | return; | ||
863 | |||
864 | ev->type = EVENT_STOPPED; | ||
865 | |||
866 | spin_lock_irqsave(&wdev->event_lock, flags); | ||
867 | list_add_tail(&ev->list, &wdev->event_list); | ||
868 | spin_unlock_irqrestore(&wdev->event_lock, flags); | ||
869 | queue_work(cfg80211_wq, &rdev->event_work); | ||
870 | } | ||
871 | EXPORT_SYMBOL(cfg80211_stop_iface); | ||
872 | |||
834 | static int cfg80211_netdev_notifier_call(struct notifier_block *nb, | 873 | static int cfg80211_netdev_notifier_call(struct notifier_block *nb, |
835 | unsigned long state, void *ptr) | 874 | unsigned long state, void *ptr) |
836 | { | 875 | { |
diff --git a/net/wireless/core.h b/net/wireless/core.h index 681b8fa4355b..e9afbf10e756 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h | |||
@@ -185,6 +185,7 @@ enum cfg80211_event_type { | |||
185 | EVENT_ROAMED, | 185 | EVENT_ROAMED, |
186 | EVENT_DISCONNECTED, | 186 | EVENT_DISCONNECTED, |
187 | EVENT_IBSS_JOINED, | 187 | EVENT_IBSS_JOINED, |
188 | EVENT_STOPPED, | ||
188 | }; | 189 | }; |
189 | 190 | ||
190 | struct cfg80211_event { | 191 | struct cfg80211_event { |
@@ -281,6 +282,8 @@ int cfg80211_join_mesh(struct cfg80211_registered_device *rdev, | |||
281 | struct net_device *dev, | 282 | struct net_device *dev, |
282 | struct mesh_setup *setup, | 283 | struct mesh_setup *setup, |
283 | const struct mesh_config *conf); | 284 | const struct mesh_config *conf); |
285 | int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, | ||
286 | struct net_device *dev); | ||
284 | int cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, | 287 | int cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, |
285 | struct net_device *dev); | 288 | struct net_device *dev); |
286 | int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev, | 289 | int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev, |
@@ -288,6 +291,8 @@ int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev, | |||
288 | struct cfg80211_chan_def *chandef); | 291 | struct cfg80211_chan_def *chandef); |
289 | 292 | ||
290 | /* AP */ | 293 | /* AP */ |
294 | int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, | ||
295 | struct net_device *dev, bool notify); | ||
291 | int cfg80211_stop_ap(struct cfg80211_registered_device *rdev, | 296 | int cfg80211_stop_ap(struct cfg80211_registered_device *rdev, |
292 | struct net_device *dev, bool notify); | 297 | struct net_device *dev, bool notify); |
293 | 298 | ||
@@ -441,6 +446,8 @@ int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, | |||
441 | void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev, | 446 | void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev, |
442 | enum nl80211_iftype iftype, int num); | 447 | enum nl80211_iftype iftype, int num); |
443 | 448 | ||
449 | void __cfg80211_leave(struct cfg80211_registered_device *rdev, | ||
450 | struct wireless_dev *wdev); | ||
444 | void cfg80211_leave(struct cfg80211_registered_device *rdev, | 451 | void cfg80211_leave(struct cfg80211_registered_device *rdev, |
445 | struct wireless_dev *wdev); | 452 | struct wireless_dev *wdev); |
446 | 453 | ||
diff --git a/net/wireless/ibss.c b/net/wireless/ibss.c index 6b50588b709f..8f345da3ea5f 100644 --- a/net/wireless/ibss.c +++ b/net/wireless/ibss.c | |||
@@ -420,8 +420,8 @@ int cfg80211_ibss_wext_siwessid(struct net_device *dev, | |||
420 | if (len > 0 && ssid[len - 1] == '\0') | 420 | if (len > 0 && ssid[len - 1] == '\0') |
421 | len--; | 421 | len--; |
422 | 422 | ||
423 | memcpy(wdev->ssid, ssid, len); | ||
423 | wdev->wext.ibss.ssid = wdev->ssid; | 424 | wdev->wext.ibss.ssid = wdev->ssid; |
424 | memcpy(wdev->wext.ibss.ssid, ssid, len); | ||
425 | wdev->wext.ibss.ssid_len = len; | 425 | wdev->wext.ibss.ssid_len = len; |
426 | 426 | ||
427 | wdev_lock(wdev); | 427 | wdev_lock(wdev); |
diff --git a/net/wireless/mesh.c b/net/wireless/mesh.c index 3ddfb7cd335e..092300b30c37 100644 --- a/net/wireless/mesh.c +++ b/net/wireless/mesh.c | |||
@@ -238,8 +238,8 @@ int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev, | |||
238 | return 0; | 238 | return 0; |
239 | } | 239 | } |
240 | 240 | ||
241 | static int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, | 241 | int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, |
242 | struct net_device *dev) | 242 | struct net_device *dev) |
243 | { | 243 | { |
244 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 244 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
245 | int err; | 245 | int err; |
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 0f1b18f209d6..62bdb1adaa4d 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -371,8 +371,8 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = { | |||
371 | [NL80211_ATTR_CH_SWITCH_COUNT] = { .type = NLA_U32 }, | 371 | [NL80211_ATTR_CH_SWITCH_COUNT] = { .type = NLA_U32 }, |
372 | [NL80211_ATTR_CH_SWITCH_BLOCK_TX] = { .type = NLA_FLAG }, | 372 | [NL80211_ATTR_CH_SWITCH_BLOCK_TX] = { .type = NLA_FLAG }, |
373 | [NL80211_ATTR_CSA_IES] = { .type = NLA_NESTED }, | 373 | [NL80211_ATTR_CSA_IES] = { .type = NLA_NESTED }, |
374 | [NL80211_ATTR_CSA_C_OFF_BEACON] = { .type = NLA_U16 }, | 374 | [NL80211_ATTR_CSA_C_OFF_BEACON] = { .type = NLA_BINARY }, |
375 | [NL80211_ATTR_CSA_C_OFF_PRESP] = { .type = NLA_U16 }, | 375 | [NL80211_ATTR_CSA_C_OFF_PRESP] = { .type = NLA_BINARY }, |
376 | [NL80211_ATTR_STA_SUPPORTED_CHANNELS] = { .type = NLA_BINARY }, | 376 | [NL80211_ATTR_STA_SUPPORTED_CHANNELS] = { .type = NLA_BINARY }, |
377 | [NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES] = { .type = NLA_BINARY }, | 377 | [NL80211_ATTR_STA_SUPPORTED_OPER_CLASSES] = { .type = NLA_BINARY }, |
378 | [NL80211_ATTR_HANDLE_DFS] = { .type = NLA_FLAG }, | 378 | [NL80211_ATTR_HANDLE_DFS] = { .type = NLA_FLAG }, |
@@ -386,6 +386,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = { | |||
386 | [NL80211_ATTR_WIPHY_FREQ_HINT] = { .type = NLA_U32 }, | 386 | [NL80211_ATTR_WIPHY_FREQ_HINT] = { .type = NLA_U32 }, |
387 | [NL80211_ATTR_TDLS_PEER_CAPABILITY] = { .type = NLA_U32 }, | 387 | [NL80211_ATTR_TDLS_PEER_CAPABILITY] = { .type = NLA_U32 }, |
388 | [NL80211_ATTR_IFACE_SOCKET_OWNER] = { .type = NLA_FLAG }, | 388 | [NL80211_ATTR_IFACE_SOCKET_OWNER] = { .type = NLA_FLAG }, |
389 | [NL80211_ATTR_CSA_C_OFFSETS_TX] = { .type = NLA_BINARY }, | ||
389 | }; | 390 | }; |
390 | 391 | ||
391 | /* policy for the key attributes */ | 392 | /* policy for the key attributes */ |
@@ -970,8 +971,10 @@ static int nl80211_put_iface_combinations(struct wiphy *wiphy, | |||
970 | c->max_interfaces)) | 971 | c->max_interfaces)) |
971 | goto nla_put_failure; | 972 | goto nla_put_failure; |
972 | if (large && | 973 | if (large && |
973 | nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS, | 974 | (nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS, |
974 | c->radar_detect_widths)) | 975 | c->radar_detect_widths) || |
976 | nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_REGIONS, | ||
977 | c->radar_detect_regions))) | ||
975 | goto nla_put_failure; | 978 | goto nla_put_failure; |
976 | 979 | ||
977 | nla_nest_end(msg, nl_combi); | 980 | nla_nest_end(msg, nl_combi); |
@@ -1667,6 +1670,13 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, | |||
1667 | } | 1670 | } |
1668 | nla_nest_end(msg, nested); | 1671 | nla_nest_end(msg, nested); |
1669 | } | 1672 | } |
1673 | state->split_start++; | ||
1674 | break; | ||
1675 | case 12: | ||
1676 | if (rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH && | ||
1677 | nla_put_u8(msg, NL80211_ATTR_MAX_CSA_COUNTERS, | ||
1678 | rdev->wiphy.max_num_csa_counters)) | ||
1679 | goto nla_put_failure; | ||
1670 | 1680 | ||
1671 | /* done */ | 1681 | /* done */ |
1672 | state->split_start = 0; | 1682 | state->split_start = 0; |
@@ -3640,6 +3650,10 @@ static int nl80211_send_station(struct sk_buff *msg, u32 portid, u32 seq, | |||
3640 | nla_put_u32(msg, NL80211_STA_INFO_TX_FAILED, | 3650 | nla_put_u32(msg, NL80211_STA_INFO_TX_FAILED, |
3641 | sinfo->tx_failed)) | 3651 | sinfo->tx_failed)) |
3642 | goto nla_put_failure; | 3652 | goto nla_put_failure; |
3653 | if ((sinfo->filled & STATION_INFO_EXPECTED_THROUGHPUT) && | ||
3654 | nla_put_u32(msg, NL80211_STA_INFO_EXPECTED_THROUGHPUT, | ||
3655 | sinfo->expected_throughput)) | ||
3656 | goto nla_put_failure; | ||
3643 | if ((sinfo->filled & STATION_INFO_BEACON_LOSS_COUNT) && | 3657 | if ((sinfo->filled & STATION_INFO_BEACON_LOSS_COUNT) && |
3644 | nla_put_u32(msg, NL80211_STA_INFO_BEACON_LOSS, | 3658 | nla_put_u32(msg, NL80211_STA_INFO_BEACON_LOSS, |
3645 | sinfo->beacon_loss_count)) | 3659 | sinfo->beacon_loss_count)) |
@@ -5820,7 +5834,7 @@ static int nl80211_start_radar_detection(struct sk_buff *skb, | |||
5820 | return -EBUSY; | 5834 | return -EBUSY; |
5821 | 5835 | ||
5822 | err = cfg80211_chandef_dfs_required(wdev->wiphy, &chandef, | 5836 | err = cfg80211_chandef_dfs_required(wdev->wiphy, &chandef, |
5823 | NL80211_IFTYPE_UNSPECIFIED); | 5837 | wdev->iftype); |
5824 | if (err < 0) | 5838 | if (err < 0) |
5825 | return err; | 5839 | return err; |
5826 | 5840 | ||
@@ -5861,6 +5875,7 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info) | |||
5861 | u8 radar_detect_width = 0; | 5875 | u8 radar_detect_width = 0; |
5862 | int err; | 5876 | int err; |
5863 | bool need_new_beacon = false; | 5877 | bool need_new_beacon = false; |
5878 | int len, i; | ||
5864 | 5879 | ||
5865 | if (!rdev->ops->channel_switch || | 5880 | if (!rdev->ops->channel_switch || |
5866 | !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH)) | 5881 | !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH)) |
@@ -5919,26 +5934,55 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info) | |||
5919 | if (!csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON]) | 5934 | if (!csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON]) |
5920 | return -EINVAL; | 5935 | return -EINVAL; |
5921 | 5936 | ||
5922 | params.counter_offset_beacon = | 5937 | len = nla_len(csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON]); |
5923 | nla_get_u16(csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON]); | 5938 | if (!len || (len % sizeof(u16))) |
5924 | if (params.counter_offset_beacon >= params.beacon_csa.tail_len) | ||
5925 | return -EINVAL; | 5939 | return -EINVAL; |
5926 | 5940 | ||
5927 | /* sanity check - counters should be the same */ | 5941 | params.n_counter_offsets_beacon = len / sizeof(u16); |
5928 | if (params.beacon_csa.tail[params.counter_offset_beacon] != | 5942 | if (rdev->wiphy.max_num_csa_counters && |
5929 | params.count) | 5943 | (params.n_counter_offsets_beacon > |
5944 | rdev->wiphy.max_num_csa_counters)) | ||
5930 | return -EINVAL; | 5945 | return -EINVAL; |
5931 | 5946 | ||
5947 | params.counter_offsets_beacon = | ||
5948 | nla_data(csa_attrs[NL80211_ATTR_CSA_C_OFF_BEACON]); | ||
5949 | |||
5950 | /* sanity checks - counters should fit and be the same */ | ||
5951 | for (i = 0; i < params.n_counter_offsets_beacon; i++) { | ||
5952 | u16 offset = params.counter_offsets_beacon[i]; | ||
5953 | |||
5954 | if (offset >= params.beacon_csa.tail_len) | ||
5955 | return -EINVAL; | ||
5956 | |||
5957 | if (params.beacon_csa.tail[offset] != params.count) | ||
5958 | return -EINVAL; | ||
5959 | } | ||
5960 | |||
5932 | if (csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]) { | 5961 | if (csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]) { |
5933 | params.counter_offset_presp = | 5962 | len = nla_len(csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]); |
5934 | nla_get_u16(csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]); | 5963 | if (!len || (len % sizeof(u16))) |
5935 | if (params.counter_offset_presp >= | ||
5936 | params.beacon_csa.probe_resp_len) | ||
5937 | return -EINVAL; | 5964 | return -EINVAL; |
5938 | 5965 | ||
5939 | if (params.beacon_csa.probe_resp[params.counter_offset_presp] != | 5966 | params.n_counter_offsets_presp = len / sizeof(u16); |
5940 | params.count) | 5967 | if (rdev->wiphy.max_num_csa_counters && |
5968 | (params.n_counter_offsets_beacon > | ||
5969 | rdev->wiphy.max_num_csa_counters)) | ||
5941 | return -EINVAL; | 5970 | return -EINVAL; |
5971 | |||
5972 | params.counter_offsets_presp = | ||
5973 | nla_data(csa_attrs[NL80211_ATTR_CSA_C_OFF_PRESP]); | ||
5974 | |||
5975 | /* sanity checks - counters should fit and be the same */ | ||
5976 | for (i = 0; i < params.n_counter_offsets_presp; i++) { | ||
5977 | u16 offset = params.counter_offsets_presp[i]; | ||
5978 | |||
5979 | if (offset >= params.beacon_csa.probe_resp_len) | ||
5980 | return -EINVAL; | ||
5981 | |||
5982 | if (params.beacon_csa.probe_resp[offset] != | ||
5983 | params.count) | ||
5984 | return -EINVAL; | ||
5985 | } | ||
5942 | } | 5986 | } |
5943 | 5987 | ||
5944 | skip_beacons: | 5988 | skip_beacons: |
@@ -7784,6 +7828,27 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) | |||
7784 | if (!chandef.chan && params.offchan) | 7828 | if (!chandef.chan && params.offchan) |
7785 | return -EINVAL; | 7829 | return -EINVAL; |
7786 | 7830 | ||
7831 | params.buf = nla_data(info->attrs[NL80211_ATTR_FRAME]); | ||
7832 | params.len = nla_len(info->attrs[NL80211_ATTR_FRAME]); | ||
7833 | |||
7834 | if (info->attrs[NL80211_ATTR_CSA_C_OFFSETS_TX]) { | ||
7835 | int len = nla_len(info->attrs[NL80211_ATTR_CSA_C_OFFSETS_TX]); | ||
7836 | int i; | ||
7837 | |||
7838 | if (len % sizeof(u16)) | ||
7839 | return -EINVAL; | ||
7840 | |||
7841 | params.n_csa_offsets = len / sizeof(u16); | ||
7842 | params.csa_offsets = | ||
7843 | nla_data(info->attrs[NL80211_ATTR_CSA_C_OFFSETS_TX]); | ||
7844 | |||
7845 | /* check that all the offsets fit the frame */ | ||
7846 | for (i = 0; i < params.n_csa_offsets; i++) { | ||
7847 | if (params.csa_offsets[i] >= params.len) | ||
7848 | return -EINVAL; | ||
7849 | } | ||
7850 | } | ||
7851 | |||
7787 | if (!params.dont_wait_for_ack) { | 7852 | if (!params.dont_wait_for_ack) { |
7788 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | 7853 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); |
7789 | if (!msg) | 7854 | if (!msg) |
@@ -7797,8 +7862,6 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) | |||
7797 | } | 7862 | } |
7798 | } | 7863 | } |
7799 | 7864 | ||
7800 | params.buf = nla_data(info->attrs[NL80211_ATTR_FRAME]); | ||
7801 | params.len = nla_len(info->attrs[NL80211_ATTR_FRAME]); | ||
7802 | params.chan = chandef.chan; | 7865 | params.chan = chandef.chan; |
7803 | err = cfg80211_mlme_mgmt_tx(rdev, wdev, ¶ms, &cookie); | 7866 | err = cfg80211_mlme_mgmt_tx(rdev, wdev, ¶ms, &cookie); |
7804 | if (err) | 7867 | if (err) |
@@ -8495,6 +8558,8 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) | |||
8495 | 8558 | ||
8496 | nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN], | 8559 | nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN], |
8497 | rem) { | 8560 | rem) { |
8561 | u8 *mask_pat; | ||
8562 | |||
8498 | nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), | 8563 | nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), |
8499 | nla_len(pat), NULL); | 8564 | nla_len(pat), NULL); |
8500 | err = -EINVAL; | 8565 | err = -EINVAL; |
@@ -8518,19 +8583,18 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) | |||
8518 | goto error; | 8583 | goto error; |
8519 | new_triggers.patterns[i].pkt_offset = pkt_offset; | 8584 | new_triggers.patterns[i].pkt_offset = pkt_offset; |
8520 | 8585 | ||
8521 | new_triggers.patterns[i].mask = | 8586 | mask_pat = kmalloc(mask_len + pat_len, GFP_KERNEL); |
8522 | kmalloc(mask_len + pat_len, GFP_KERNEL); | 8587 | if (!mask_pat) { |
8523 | if (!new_triggers.patterns[i].mask) { | ||
8524 | err = -ENOMEM; | 8588 | err = -ENOMEM; |
8525 | goto error; | 8589 | goto error; |
8526 | } | 8590 | } |
8527 | new_triggers.patterns[i].pattern = | 8591 | new_triggers.patterns[i].mask = mask_pat; |
8528 | new_triggers.patterns[i].mask + mask_len; | 8592 | memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_MASK]), |
8529 | memcpy(new_triggers.patterns[i].mask, | ||
8530 | nla_data(pat_tb[NL80211_PKTPAT_MASK]), | ||
8531 | mask_len); | 8593 | mask_len); |
8594 | mask_pat += mask_len; | ||
8595 | new_triggers.patterns[i].pattern = mask_pat; | ||
8532 | new_triggers.patterns[i].pattern_len = pat_len; | 8596 | new_triggers.patterns[i].pattern_len = pat_len; |
8533 | memcpy(new_triggers.patterns[i].pattern, | 8597 | memcpy(mask_pat, |
8534 | nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), | 8598 | nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), |
8535 | pat_len); | 8599 | pat_len); |
8536 | i++; | 8600 | i++; |
@@ -8722,6 +8786,8 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev, | |||
8722 | 8786 | ||
8723 | nla_for_each_nested(pat, tb[NL80211_ATTR_COALESCE_RULE_PKT_PATTERN], | 8787 | nla_for_each_nested(pat, tb[NL80211_ATTR_COALESCE_RULE_PKT_PATTERN], |
8724 | rem) { | 8788 | rem) { |
8789 | u8 *mask_pat; | ||
8790 | |||
8725 | nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), | 8791 | nla_parse(pat_tb, MAX_NL80211_PKTPAT, nla_data(pat), |
8726 | nla_len(pat), NULL); | 8792 | nla_len(pat), NULL); |
8727 | if (!pat_tb[NL80211_PKTPAT_MASK] || | 8793 | if (!pat_tb[NL80211_PKTPAT_MASK] || |
@@ -8743,17 +8809,19 @@ static int nl80211_parse_coalesce_rule(struct cfg80211_registered_device *rdev, | |||
8743 | return -EINVAL; | 8809 | return -EINVAL; |
8744 | new_rule->patterns[i].pkt_offset = pkt_offset; | 8810 | new_rule->patterns[i].pkt_offset = pkt_offset; |
8745 | 8811 | ||
8746 | new_rule->patterns[i].mask = | 8812 | mask_pat = kmalloc(mask_len + pat_len, GFP_KERNEL); |
8747 | kmalloc(mask_len + pat_len, GFP_KERNEL); | 8813 | if (!mask_pat) |
8748 | if (!new_rule->patterns[i].mask) | ||
8749 | return -ENOMEM; | 8814 | return -ENOMEM; |
8750 | new_rule->patterns[i].pattern = | 8815 | |
8751 | new_rule->patterns[i].mask + mask_len; | 8816 | new_rule->patterns[i].mask = mask_pat; |
8752 | memcpy(new_rule->patterns[i].mask, | 8817 | memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_MASK]), |
8753 | nla_data(pat_tb[NL80211_PKTPAT_MASK]), mask_len); | 8818 | mask_len); |
8819 | |||
8820 | mask_pat += mask_len; | ||
8821 | new_rule->patterns[i].pattern = mask_pat; | ||
8754 | new_rule->patterns[i].pattern_len = pat_len; | 8822 | new_rule->patterns[i].pattern_len = pat_len; |
8755 | memcpy(new_rule->patterns[i].pattern, | 8823 | memcpy(mask_pat, nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), |
8756 | nla_data(pat_tb[NL80211_PKTPAT_PATTERN]), pat_len); | 8824 | pat_len); |
8757 | i++; | 8825 | i++; |
8758 | } | 8826 | } |
8759 | 8827 | ||
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h index 00cdf73ba6c4..d95bbe348138 100644 --- a/net/wireless/rdev-ops.h +++ b/net/wireless/rdev-ops.h | |||
@@ -199,7 +199,7 @@ static inline int rdev_change_station(struct cfg80211_registered_device *rdev, | |||
199 | } | 199 | } |
200 | 200 | ||
201 | static inline int rdev_get_station(struct cfg80211_registered_device *rdev, | 201 | static inline int rdev_get_station(struct cfg80211_registered_device *rdev, |
202 | struct net_device *dev, u8 *mac, | 202 | struct net_device *dev, const u8 *mac, |
203 | struct station_info *sinfo) | 203 | struct station_info *sinfo) |
204 | { | 204 | { |
205 | int ret; | 205 | int ret; |
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index e78f532aaa5b..558b0e3a02d8 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
@@ -1876,7 +1876,8 @@ static void reg_process_hint(struct regulatory_request *reg_request) | |||
1876 | case NL80211_REGDOM_SET_BY_USER: | 1876 | case NL80211_REGDOM_SET_BY_USER: |
1877 | treatment = reg_process_hint_user(reg_request); | 1877 | treatment = reg_process_hint_user(reg_request); |
1878 | if (treatment == REG_REQ_IGNORE || | 1878 | if (treatment == REG_REQ_IGNORE || |
1879 | treatment == REG_REQ_ALREADY_SET) | 1879 | treatment == REG_REQ_ALREADY_SET || |
1880 | treatment == REG_REQ_USER_HINT_HANDLED) | ||
1880 | return; | 1881 | return; |
1881 | queue_delayed_work(system_power_efficient_wq, | 1882 | queue_delayed_work(system_power_efficient_wq, |
1882 | ®_timeout, msecs_to_jiffies(3142)); | 1883 | ®_timeout, msecs_to_jiffies(3142)); |
diff --git a/net/wireless/scan.c b/net/wireless/scan.c index e7329bb6a323..0798c62e6085 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c | |||
@@ -891,6 +891,7 @@ cfg80211_inform_bss_width(struct wiphy *wiphy, | |||
891 | struct cfg80211_bss_ies *ies; | 891 | struct cfg80211_bss_ies *ies; |
892 | struct ieee80211_channel *channel; | 892 | struct ieee80211_channel *channel; |
893 | struct cfg80211_internal_bss tmp = {}, *res; | 893 | struct cfg80211_internal_bss tmp = {}, *res; |
894 | bool signal_valid; | ||
894 | 895 | ||
895 | if (WARN_ON(!wiphy)) | 896 | if (WARN_ON(!wiphy)) |
896 | return NULL; | 897 | return NULL; |
@@ -927,8 +928,9 @@ cfg80211_inform_bss_width(struct wiphy *wiphy, | |||
927 | rcu_assign_pointer(tmp.pub.beacon_ies, ies); | 928 | rcu_assign_pointer(tmp.pub.beacon_ies, ies); |
928 | rcu_assign_pointer(tmp.pub.ies, ies); | 929 | rcu_assign_pointer(tmp.pub.ies, ies); |
929 | 930 | ||
930 | res = cfg80211_bss_update(wiphy_to_rdev(wiphy), &tmp, | 931 | signal_valid = abs(rx_channel->center_freq - channel->center_freq) <= |
931 | rx_channel == channel); | 932 | wiphy->max_adj_channel_rssi_comp; |
933 | res = cfg80211_bss_update(wiphy_to_rdev(wiphy), &tmp, signal_valid); | ||
932 | if (!res) | 934 | if (!res) |
933 | return NULL; | 935 | return NULL; |
934 | 936 | ||
@@ -952,6 +954,7 @@ cfg80211_inform_bss_width_frame(struct wiphy *wiphy, | |||
952 | struct cfg80211_internal_bss tmp = {}, *res; | 954 | struct cfg80211_internal_bss tmp = {}, *res; |
953 | struct cfg80211_bss_ies *ies; | 955 | struct cfg80211_bss_ies *ies; |
954 | struct ieee80211_channel *channel; | 956 | struct ieee80211_channel *channel; |
957 | bool signal_valid; | ||
955 | size_t ielen = len - offsetof(struct ieee80211_mgmt, | 958 | size_t ielen = len - offsetof(struct ieee80211_mgmt, |
956 | u.probe_resp.variable); | 959 | u.probe_resp.variable); |
957 | 960 | ||
@@ -999,8 +1002,9 @@ cfg80211_inform_bss_width_frame(struct wiphy *wiphy, | |||
999 | tmp.pub.beacon_interval = le16_to_cpu(mgmt->u.probe_resp.beacon_int); | 1002 | tmp.pub.beacon_interval = le16_to_cpu(mgmt->u.probe_resp.beacon_int); |
1000 | tmp.pub.capability = le16_to_cpu(mgmt->u.probe_resp.capab_info); | 1003 | tmp.pub.capability = le16_to_cpu(mgmt->u.probe_resp.capab_info); |
1001 | 1004 | ||
1002 | res = cfg80211_bss_update(wiphy_to_rdev(wiphy), &tmp, | 1005 | signal_valid = abs(rx_channel->center_freq - channel->center_freq) <= |
1003 | rx_channel == channel); | 1006 | wiphy->max_adj_channel_rssi_comp; |
1007 | res = cfg80211_bss_update(wiphy_to_rdev(wiphy), &tmp, signal_valid); | ||
1004 | if (!res) | 1008 | if (!res) |
1005 | return NULL; | 1009 | return NULL; |
1006 | 1010 | ||
diff --git a/net/wireless/sme.c b/net/wireless/sme.c index 0c0844b585d1..8bbeeb302216 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c | |||
@@ -149,7 +149,8 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev) | |||
149 | case CFG80211_CONN_SCAN_AGAIN: | 149 | case CFG80211_CONN_SCAN_AGAIN: |
150 | return cfg80211_conn_scan(wdev); | 150 | return cfg80211_conn_scan(wdev); |
151 | case CFG80211_CONN_AUTHENTICATE_NEXT: | 151 | case CFG80211_CONN_AUTHENTICATE_NEXT: |
152 | BUG_ON(!rdev->ops->auth); | 152 | if (WARN_ON(!rdev->ops->auth)) |
153 | return -EOPNOTSUPP; | ||
153 | wdev->conn->state = CFG80211_CONN_AUTHENTICATING; | 154 | wdev->conn->state = CFG80211_CONN_AUTHENTICATING; |
154 | return cfg80211_mlme_auth(rdev, wdev->netdev, | 155 | return cfg80211_mlme_auth(rdev, wdev->netdev, |
155 | params->channel, params->auth_type, | 156 | params->channel, params->auth_type, |
@@ -161,7 +162,8 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev) | |||
161 | case CFG80211_CONN_AUTH_FAILED: | 162 | case CFG80211_CONN_AUTH_FAILED: |
162 | return -ENOTCONN; | 163 | return -ENOTCONN; |
163 | case CFG80211_CONN_ASSOCIATE_NEXT: | 164 | case CFG80211_CONN_ASSOCIATE_NEXT: |
164 | BUG_ON(!rdev->ops->assoc); | 165 | if (WARN_ON(!rdev->ops->assoc)) |
166 | return -EOPNOTSUPP; | ||
165 | wdev->conn->state = CFG80211_CONN_ASSOCIATING; | 167 | wdev->conn->state = CFG80211_CONN_ASSOCIATING; |
166 | if (wdev->conn->prev_bssid_valid) | 168 | if (wdev->conn->prev_bssid_valid) |
167 | req.prev_bssid = wdev->conn->prev_bssid; | 169 | req.prev_bssid = wdev->conn->prev_bssid; |
@@ -877,7 +879,7 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie, | |||
877 | } | 879 | } |
878 | 880 | ||
879 | void cfg80211_disconnected(struct net_device *dev, u16 reason, | 881 | void cfg80211_disconnected(struct net_device *dev, u16 reason, |
880 | u8 *ie, size_t ie_len, gfp_t gfp) | 882 | const u8 *ie, size_t ie_len, gfp_t gfp) |
881 | { | 883 | { |
882 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 884 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
883 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); | 885 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
diff --git a/net/wireless/trace.h b/net/wireless/trace.h index f3c13ff4d04c..560ed77084e9 100644 --- a/net/wireless/trace.h +++ b/net/wireless/trace.h | |||
@@ -1876,29 +1876,33 @@ TRACE_EVENT(rdev_channel_switch, | |||
1876 | WIPHY_ENTRY | 1876 | WIPHY_ENTRY |
1877 | NETDEV_ENTRY | 1877 | NETDEV_ENTRY |
1878 | CHAN_DEF_ENTRY | 1878 | CHAN_DEF_ENTRY |
1879 | __field(u16, counter_offset_beacon) | ||
1880 | __field(u16, counter_offset_presp) | ||
1881 | __field(bool, radar_required) | 1879 | __field(bool, radar_required) |
1882 | __field(bool, block_tx) | 1880 | __field(bool, block_tx) |
1883 | __field(u8, count) | 1881 | __field(u8, count) |
1882 | __dynamic_array(u16, bcn_ofs, params->n_counter_offsets_beacon) | ||
1883 | __dynamic_array(u16, pres_ofs, params->n_counter_offsets_presp) | ||
1884 | ), | 1884 | ), |
1885 | TP_fast_assign( | 1885 | TP_fast_assign( |
1886 | WIPHY_ASSIGN; | 1886 | WIPHY_ASSIGN; |
1887 | NETDEV_ASSIGN; | 1887 | NETDEV_ASSIGN; |
1888 | CHAN_DEF_ASSIGN(¶ms->chandef); | 1888 | CHAN_DEF_ASSIGN(¶ms->chandef); |
1889 | __entry->counter_offset_beacon = params->counter_offset_beacon; | ||
1890 | __entry->counter_offset_presp = params->counter_offset_presp; | ||
1891 | __entry->radar_required = params->radar_required; | 1889 | __entry->radar_required = params->radar_required; |
1892 | __entry->block_tx = params->block_tx; | 1890 | __entry->block_tx = params->block_tx; |
1893 | __entry->count = params->count; | 1891 | __entry->count = params->count; |
1892 | memcpy(__get_dynamic_array(bcn_ofs), | ||
1893 | params->counter_offsets_beacon, | ||
1894 | params->n_counter_offsets_beacon * sizeof(u16)); | ||
1895 | |||
1896 | /* probe response offsets are optional */ | ||
1897 | if (params->n_counter_offsets_presp) | ||
1898 | memcpy(__get_dynamic_array(pres_ofs), | ||
1899 | params->counter_offsets_presp, | ||
1900 | params->n_counter_offsets_presp * sizeof(u16)); | ||
1894 | ), | 1901 | ), |
1895 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", " CHAN_DEF_PR_FMT | 1902 | TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", " CHAN_DEF_PR_FMT |
1896 | ", block_tx: %d, count: %u, radar_required: %d" | 1903 | ", block_tx: %d, count: %u, radar_required: %d", |
1897 | ", counter offsets (beacon/presp): %u/%u", | ||
1898 | WIPHY_PR_ARG, NETDEV_PR_ARG, CHAN_DEF_PR_ARG, | 1904 | WIPHY_PR_ARG, NETDEV_PR_ARG, CHAN_DEF_PR_ARG, |
1899 | __entry->block_tx, __entry->count, __entry->radar_required, | 1905 | __entry->block_tx, __entry->count, __entry->radar_required) |
1900 | __entry->counter_offset_beacon, | ||
1901 | __entry->counter_offset_presp) | ||
1902 | ); | 1906 | ); |
1903 | 1907 | ||
1904 | TRACE_EVENT(rdev_set_qos_map, | 1908 | TRACE_EVENT(rdev_set_qos_map, |
@@ -2636,6 +2640,21 @@ TRACE_EVENT(cfg80211_ft_event, | |||
2636 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(target_ap)) | 2640 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(target_ap)) |
2637 | ); | 2641 | ); |
2638 | 2642 | ||
2643 | TRACE_EVENT(cfg80211_stop_iface, | ||
2644 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | ||
2645 | TP_ARGS(wiphy, wdev), | ||
2646 | TP_STRUCT__entry( | ||
2647 | WIPHY_ENTRY | ||
2648 | WDEV_ENTRY | ||
2649 | ), | ||
2650 | TP_fast_assign( | ||
2651 | WIPHY_ASSIGN; | ||
2652 | WDEV_ASSIGN; | ||
2653 | ), | ||
2654 | TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT, | ||
2655 | WIPHY_PR_ARG, WDEV_PR_ARG) | ||
2656 | ); | ||
2657 | |||
2639 | #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ | 2658 | #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ |
2640 | 2659 | ||
2641 | #undef TRACE_INCLUDE_PATH | 2660 | #undef TRACE_INCLUDE_PATH |
diff --git a/net/wireless/util.c b/net/wireless/util.c index 7c47fa07b276..728f1c0dc70d 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c | |||
@@ -476,7 +476,8 @@ int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, | |||
476 | EXPORT_SYMBOL(ieee80211_data_to_8023); | 476 | EXPORT_SYMBOL(ieee80211_data_to_8023); |
477 | 477 | ||
478 | int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr, | 478 | int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr, |
479 | enum nl80211_iftype iftype, u8 *bssid, bool qos) | 479 | enum nl80211_iftype iftype, |
480 | const u8 *bssid, bool qos) | ||
480 | { | 481 | { |
481 | struct ieee80211_hdr hdr; | 482 | struct ieee80211_hdr hdr; |
482 | u16 hdrlen, ethertype; | 483 | u16 hdrlen, ethertype; |
@@ -839,6 +840,9 @@ void cfg80211_process_wdev_events(struct wireless_dev *wdev) | |||
839 | __cfg80211_ibss_joined(wdev->netdev, ev->ij.bssid, | 840 | __cfg80211_ibss_joined(wdev->netdev, ev->ij.bssid, |
840 | ev->ij.channel); | 841 | ev->ij.channel); |
841 | break; | 842 | break; |
843 | case EVENT_STOPPED: | ||
844 | __cfg80211_leave(wiphy_to_rdev(wdev->wiphy), wdev); | ||
845 | break; | ||
842 | } | 846 | } |
843 | wdev_unlock(wdev); | 847 | wdev_unlock(wdev); |
844 | 848 | ||
@@ -1271,10 +1275,20 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, | |||
1271 | void *data), | 1275 | void *data), |
1272 | void *data) | 1276 | void *data) |
1273 | { | 1277 | { |
1278 | const struct ieee80211_regdomain *regdom; | ||
1279 | enum nl80211_dfs_regions region = 0; | ||
1274 | int i, j, iftype; | 1280 | int i, j, iftype; |
1275 | int num_interfaces = 0; | 1281 | int num_interfaces = 0; |
1276 | u32 used_iftypes = 0; | 1282 | u32 used_iftypes = 0; |
1277 | 1283 | ||
1284 | if (radar_detect) { | ||
1285 | rcu_read_lock(); | ||
1286 | regdom = rcu_dereference(cfg80211_regdomain); | ||
1287 | if (regdom) | ||
1288 | region = regdom->dfs_region; | ||
1289 | rcu_read_unlock(); | ||
1290 | } | ||
1291 | |||
1278 | for (iftype = 0; iftype < NUM_NL80211_IFTYPES; iftype++) { | 1292 | for (iftype = 0; iftype < NUM_NL80211_IFTYPES; iftype++) { |
1279 | num_interfaces += iftype_num[iftype]; | 1293 | num_interfaces += iftype_num[iftype]; |
1280 | if (iftype_num[iftype] > 0 && | 1294 | if (iftype_num[iftype] > 0 && |
@@ -1315,6 +1329,10 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, | |||
1315 | if (radar_detect != (c->radar_detect_widths & radar_detect)) | 1329 | if (radar_detect != (c->radar_detect_widths & radar_detect)) |
1316 | goto cont; | 1330 | goto cont; |
1317 | 1331 | ||
1332 | if (radar_detect && c->radar_detect_regions && | ||
1333 | !(c->radar_detect_regions & BIT(region))) | ||
1334 | goto cont; | ||
1335 | |||
1318 | /* Finally check that all iftypes that we're currently | 1336 | /* Finally check that all iftypes that we're currently |
1319 | * using are actually part of this combination. If they | 1337 | * using are actually part of this combination. If they |
1320 | * aren't then we can't use this combination and have | 1338 | * aren't then we can't use this combination and have |
@@ -1528,6 +1546,24 @@ unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy) | |||
1528 | } | 1546 | } |
1529 | EXPORT_SYMBOL(ieee80211_get_num_supported_channels); | 1547 | EXPORT_SYMBOL(ieee80211_get_num_supported_channels); |
1530 | 1548 | ||
1549 | int cfg80211_get_station(struct net_device *dev, const u8 *mac_addr, | ||
1550 | struct station_info *sinfo) | ||
1551 | { | ||
1552 | struct cfg80211_registered_device *rdev; | ||
1553 | struct wireless_dev *wdev; | ||
1554 | |||
1555 | wdev = dev->ieee80211_ptr; | ||
1556 | if (!wdev) | ||
1557 | return -EOPNOTSUPP; | ||
1558 | |||
1559 | rdev = wiphy_to_rdev(wdev->wiphy); | ||
1560 | if (!rdev->ops->get_station) | ||
1561 | return -EOPNOTSUPP; | ||
1562 | |||
1563 | return rdev_get_station(rdev, dev, mac_addr, sinfo); | ||
1564 | } | ||
1565 | EXPORT_SYMBOL(cfg80211_get_station); | ||
1566 | |||
1531 | /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ | 1567 | /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ |
1532 | /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ | 1568 | /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ |
1533 | const unsigned char rfc1042_header[] __aligned(2) = | 1569 | const unsigned char rfc1042_header[] __aligned(2) = |