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

Merge branch 'for-john' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next

+2536 -1910
+5 -3
drivers/net/wireless/ath/ath6kl/cfg80211.c
··· 2990 2990 { 2991 2991 struct ath6kl *ar = ath6kl_priv(dev); 2992 2992 struct ath6kl_vif *vif = netdev_priv(dev); 2993 + int err; 2993 2994 2994 2995 if (vif->nw_type != AP_NETWORK) 2995 2996 return -EOPNOTSUPP; 2996 2997 2997 - /* Use this only for authorizing/unauthorizing a station */ 2998 - if (!(params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED))) 2999 - return -EOPNOTSUPP; 2998 + err = cfg80211_check_station_change(wiphy, params, 2999 + CFG80211_STA_AP_MLME_CLIENT); 3000 + if (err) 3001 + return err; 3000 3002 3001 3003 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) 3002 3004 return ath6kl_wmi_ap_set_mlme(ar->wmi, vif->fw_vif_idx,
-4
drivers/net/wireless/iwlegacy/3945.h
··· 150 150 struct list_head list; 151 151 }; 152 152 153 - #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) 154 - #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) 155 - #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) 156 - 157 153 #define SUP_RATE_11A_MAX_NUM_CHANNELS 8 158 154 #define SUP_RATE_11B_MAX_NUM_CHANNELS 4 159 155 #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
+7 -6
drivers/net/wireless/iwlegacy/4965-mac.c
··· 2258 2258 2259 2259 spin_lock_irqsave(&il->sta_lock, flags); 2260 2260 tid_data = &il->stations[sta_id].tid[tid]; 2261 - *ssn = SEQ_TO_SN(tid_data->seq_number); 2261 + *ssn = IEEE80211_SEQ_TO_SN(tid_data->seq_number); 2262 2262 tid_data->agg.txq_id = txq_id; 2263 2263 il_set_swq_id(&il->txq[txq_id], il4965_get_ac_from_tid(tid), txq_id); 2264 2264 spin_unlock_irqrestore(&il->sta_lock, flags); ··· 2408 2408 /* aggregated HW queue */ 2409 2409 if (txq_id == tid_data->agg.txq_id && 2410 2410 q->read_ptr == q->write_ptr) { 2411 - u16 ssn = SEQ_TO_SN(tid_data->seq_number); 2411 + u16 ssn = IEEE80211_SEQ_TO_SN(tid_data->seq_number); 2412 2412 int tx_fifo = il4965_get_fifo_from_tid(tid); 2413 2413 D_HT("HW queue empty: continue DELBA flow\n"); 2414 2414 il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo); ··· 2627 2627 static inline u32 2628 2628 il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) 2629 2629 { 2630 - return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN; 2630 + return le32_to_cpup(&tx_resp->u.status + 2631 + tx_resp->frame_count) & IEEE80211_MAX_SN; 2631 2632 } 2632 2633 2633 2634 static inline u32 ··· 2718 2717 hdr = (struct ieee80211_hdr *) skb->data; 2719 2718 2720 2719 sc = le16_to_cpu(hdr->seq_ctrl); 2721 - if (idx != (SEQ_TO_SN(sc) & 0xff)) { 2720 + if (idx != (IEEE80211_SEQ_TO_SN(sc) & 0xff)) { 2722 2721 IL_ERR("BUG_ON idx doesn't match seq control" 2723 2722 " idx=%d, seq_idx=%d, seq=%d\n", idx, 2724 - SEQ_TO_SN(sc), hdr->seq_ctrl); 2723 + IEEE80211_SEQ_TO_SN(sc), hdr->seq_ctrl); 2725 2724 return -1; 2726 2725 } 2727 2726 2728 2727 D_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", i, idx, 2729 - SEQ_TO_SN(sc)); 2728 + IEEE80211_SEQ_TO_SN(sc)); 2730 2729 2731 2730 sh = idx - start; 2732 2731 if (sh > 64) {
-4
drivers/net/wireless/iwlegacy/common.h
··· 541 541 struct list_head list; 542 542 }; 543 543 544 - #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) 545 - #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) 546 - #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) 547 - 548 544 enum { 549 545 CMD_SYNC = 0, 550 546 CMD_SIZE_NORMAL = 0,
+2 -1
drivers/net/wireless/iwlwifi/dvm/mac80211.c
··· 1137 1137 static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw, 1138 1138 struct ieee80211_vif *vif, 1139 1139 struct ieee80211_channel *channel, 1140 - int duration) 1140 + int duration, 1141 + enum ieee80211_roc_type type) 1141 1142 { 1142 1143 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); 1143 1144 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN];
+6 -5
drivers/net/wireless/iwlwifi/dvm/tx.c
··· 418 418 " Tx flags = 0x%08x, agg.state = %d", 419 419 info->flags, tid_data->agg.state); 420 420 IWL_ERR(priv, "sta_id = %d, tid = %d seq_num = %d", 421 - sta_id, tid, SEQ_TO_SN(tid_data->seq_number)); 421 + sta_id, tid, 422 + IEEE80211_SEQ_TO_SN(tid_data->seq_number)); 422 423 goto drop_unlock_sta; 423 424 } 424 425 ··· 570 569 return 0; 571 570 } 572 571 573 - tid_data->agg.ssn = SEQ_TO_SN(tid_data->seq_number); 572 + tid_data->agg.ssn = IEEE80211_SEQ_TO_SN(tid_data->seq_number); 574 573 575 574 /* There are still packets for this RA / TID in the HW */ 576 575 if (!test_bit(txq_id, priv->agg_q_alloc)) { ··· 652 651 653 652 spin_lock_bh(&priv->sta_lock); 654 653 tid_data = &priv->tid_data[sta_id][tid]; 655 - tid_data->agg.ssn = SEQ_TO_SN(tid_data->seq_number); 654 + tid_data->agg.ssn = IEEE80211_SEQ_TO_SN(tid_data->seq_number); 656 655 tid_data->agg.txq_id = txq_id; 657 656 658 657 *ssn = tid_data->agg.ssn; ··· 912 911 static inline u32 iwlagn_get_scd_ssn(struct iwlagn_tx_resp *tx_resp) 913 912 { 914 913 return le32_to_cpup((__le32 *)&tx_resp->status + 915 - tx_resp->frame_count) & MAX_SN; 914 + tx_resp->frame_count) & IEEE80211_MAX_SN; 916 915 } 917 916 918 917 static void iwl_rx_reply_tx_agg(struct iwl_priv *priv, ··· 1149 1148 1150 1149 if (tx_resp->frame_count == 1) { 1151 1150 u16 next_reclaimed = le16_to_cpu(tx_resp->seq_ctl); 1152 - next_reclaimed = SEQ_TO_SN(next_reclaimed + 0x10); 1151 + next_reclaimed = IEEE80211_SEQ_TO_SN(next_reclaimed + 0x10); 1153 1152 1154 1153 if (is_agg) { 1155 1154 /* If this is an aggregation queue, we can rely on the
-3
drivers/net/wireless/iwlwifi/iwl-trans.h
··· 114 114 * completely agnostic to these differences. 115 115 * The transport does provide helper functionnality (i.e. SYNC / ASYNC mode), 116 116 */ 117 - #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) 118 - #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) 119 - #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) 120 117 #define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f) 121 118 #define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8) 122 119 #define SEQ_TO_INDEX(s) ((s) & 0xff)
+4 -3
drivers/net/wireless/iwlwifi/mvm/mac80211.c
··· 1081 1081 static int iwl_mvm_roc(struct ieee80211_hw *hw, 1082 1082 struct ieee80211_vif *vif, 1083 1083 struct ieee80211_channel *channel, 1084 - int duration) 1084 + int duration, 1085 + enum ieee80211_roc_type type) 1085 1086 { 1086 1087 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); 1087 1088 struct cfg80211_chan_def chandef; ··· 1093 1092 return -EINVAL; 1094 1093 } 1095 1094 1096 - IWL_DEBUG_MAC80211(mvm, "enter (%d, %d)\n", channel->hw_value, 1097 - duration); 1095 + IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value, 1096 + duration, type); 1098 1097 1099 1098 mutex_lock(&mvm->mutex); 1100 1099
+2 -2
drivers/net/wireless/iwlwifi/mvm/sta.c
··· 686 686 687 687 spin_lock_bh(&mvmsta->lock); 688 688 tid_data = &mvmsta->tid_data[tid]; 689 - tid_data->ssn = SEQ_TO_SN(tid_data->seq_number); 689 + tid_data->ssn = IEEE80211_SEQ_TO_SN(tid_data->seq_number); 690 690 tid_data->txq_id = txq_id; 691 691 *ssn = tid_data->ssn; 692 692 ··· 779 779 780 780 switch (tid_data->state) { 781 781 case IWL_AGG_ON: 782 - tid_data->ssn = SEQ_TO_SN(tid_data->seq_number); 782 + tid_data->ssn = IEEE80211_SEQ_TO_SN(tid_data->seq_number); 783 783 784 784 IWL_DEBUG_TX_QUEUES(mvm, 785 785 "ssn = %d, next_recl = %d\n",
+1 -1
drivers/net/wireless/iwlwifi/mvm/tx.c
··· 641 641 next_reclaimed = ssn; 642 642 } else { 643 643 /* The next packet to be reclaimed is the one after this one */ 644 - next_reclaimed = SEQ_TO_SN(seq_ctl + 0x10); 644 + next_reclaimed = IEEE80211_SEQ_TO_SN(seq_ctl + 0x10); 645 645 } 646 646 647 647 IWL_DEBUG_TX_REPLY(mvm,
+1 -1
drivers/net/wireless/iwlwifi/pcie/tx.c
··· 1581 1581 * Check here that the packets are in the right place on the ring. 1582 1582 */ 1583 1583 #ifdef CONFIG_IWLWIFI_DEBUG 1584 - wifi_seq = SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); 1584 + wifi_seq = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); 1585 1585 WARN_ONCE((iwl_read_prph(trans, SCD_AGGR_SEL) & BIT(txq_id)) && 1586 1586 ((wifi_seq & 0xff) != q->write_ptr), 1587 1587 "Q: %d WiFi Seq %d tfdNum %d",
+2 -1
drivers/net/wireless/mac80211_hwsim.c
··· 1535 1535 static int mac80211_hwsim_roc(struct ieee80211_hw *hw, 1536 1536 struct ieee80211_vif *vif, 1537 1537 struct ieee80211_channel *chan, 1538 - int duration) 1538 + int duration, 1539 + enum ieee80211_roc_type type) 1539 1540 { 1540 1541 struct mac80211_hwsim_data *hwsim = hw->priv; 1541 1542
-3
drivers/net/wireless/rtlwifi/wifi.h
··· 2127 2127 #define WLAN_FC_GET_TYPE(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_FTYPE) 2128 2128 #define WLAN_FC_GET_STYPE(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_STYPE) 2129 2129 #define WLAN_FC_MORE_DATA(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_MOREDATA) 2130 - #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) 2131 - #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) 2132 - #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) 2133 2130 2134 2131 #define RT_RF_OFF_LEVL_ASPM BIT(0) /*PCI ASPM */ 2135 2132 #define RT_RF_OFF_LEVL_CLK_REQ BIT(1) /*PCI clock request */
+2 -1
drivers/net/wireless/ti/wlcore/main.c
··· 4956 4956 static int wlcore_op_remain_on_channel(struct ieee80211_hw *hw, 4957 4957 struct ieee80211_vif *vif, 4958 4958 struct ieee80211_channel *chan, 4959 - int duration) 4959 + int duration, 4960 + enum ieee80211_roc_type type) 4960 4961 { 4961 4962 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); 4962 4963 struct wl1271 *wl = hw->priv;
+38 -14
include/linux/ieee80211.h
··· 113 113 #define IEEE80211_CTL_EXT_SSW_FBACK 0x9000 114 114 #define IEEE80211_CTL_EXT_SSW_ACK 0xa000 115 115 116 + 117 + #define IEEE80211_SN_MASK ((IEEE80211_SCTL_SEQ) >> 4) 118 + #define IEEE80211_MAX_SN IEEE80211_SN_MASK 119 + #define IEEE80211_SN_MODULO (IEEE80211_MAX_SN + 1) 120 + 121 + static inline int ieee80211_sn_less(u16 sn1, u16 sn2) 122 + { 123 + return ((sn1 - sn2) & IEEE80211_SN_MASK) > (IEEE80211_SN_MODULO >> 1); 124 + } 125 + 126 + static inline u16 ieee80211_sn_add(u16 sn1, u16 sn2) 127 + { 128 + return (sn1 + sn2) & IEEE80211_SN_MASK; 129 + } 130 + 131 + static inline u16 ieee80211_sn_inc(u16 sn) 132 + { 133 + return ieee80211_sn_add(sn, 1); 134 + } 135 + 136 + static inline u16 ieee80211_sn_sub(u16 sn1, u16 sn2) 137 + { 138 + return (sn1 - sn2) & IEEE80211_SN_MASK; 139 + } 140 + 141 + #define IEEE80211_SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) 142 + #define IEEE80211_SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) 143 + 116 144 /* miscellaneous IEEE 802.11 constants */ 117 145 #define IEEE80211_MAX_FRAG_THRESHOLD 2352 118 146 #define IEEE80211_MAX_RTS_THRESHOLD 2353 ··· 213 185 u8 addr3[6]; 214 186 __le16 seq_ctrl; 215 187 u8 addr4[6]; 216 - } __packed; 188 + } __packed __aligned(2); 217 189 218 190 struct ieee80211_hdr_3addr { 219 191 __le16 frame_control; ··· 222 194 u8 addr2[6]; 223 195 u8 addr3[6]; 224 196 __le16 seq_ctrl; 225 - } __packed; 197 + } __packed __aligned(2); 226 198 227 199 struct ieee80211_qos_hdr { 228 200 __le16 frame_control; ··· 232 204 u8 addr3[6]; 233 205 __le16 seq_ctrl; 234 206 __le16 qos_ctrl; 235 - } __packed; 207 + } __packed __aligned(2); 236 208 237 209 /** 238 210 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set ··· 609 581 __le32 seqnum; 610 582 u8 eaddr1[6]; 611 583 u8 eaddr2[6]; 612 - } __packed; 584 + } __packed __aligned(2); 613 585 614 586 /* Mesh flags */ 615 587 #define MESH_FLAGS_AE_A4 0x1 ··· 903 875 } u; 904 876 } __packed action; 905 877 } u; 906 - } __packed; 878 + } __packed __aligned(2); 907 879 908 880 /* Supported Rates value encodings in 802.11n-2009 7.3.2.2 */ 909 881 #define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127 ··· 934 906 __le16 duration; 935 907 u8 ra[6]; 936 908 u8 ta[6]; 937 - } __packed; 909 + } __packed __aligned(2); 938 910 939 911 struct ieee80211_cts { 940 912 __le16 frame_control; 941 913 __le16 duration; 942 914 u8 ra[6]; 943 - } __packed; 915 + } __packed __aligned(2); 944 916 945 917 struct ieee80211_pspoll { 946 918 __le16 frame_control; 947 919 __le16 aid; 948 920 u8 bssid[6]; 949 921 u8 ta[6]; 950 - } __packed; 922 + } __packed __aligned(2); 951 923 952 924 /* TDLS */ 953 925 ··· 1318 1290 } __packed; 1319 1291 1320 1292 1321 - #define IEEE80211_VHT_MCS_ZERO_TO_SEVEN_SUPPORT 0 1322 - #define IEEE80211_VHT_MCS_ZERO_TO_EIGHT_SUPPORT 1 1323 - #define IEEE80211_VHT_MCS_ZERO_TO_NINE_SUPPORT 2 1324 - #define IEEE80211_VHT_MCS_NOT_SUPPORTED 3 1325 - 1326 1293 /* 802.11ac VHT Capabilities */ 1327 1294 #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 0x00000000 1328 1295 #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 0x00000001 ··· 1333 1310 #define IEEE80211_VHT_CAP_RXSTBC_2 0x00000200 1334 1311 #define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300 1335 1312 #define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400 1313 + #define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700 1336 1314 #define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800 1337 1315 #define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000 1338 1316 #define IEEE80211_VHT_CAP_BEAMFORMER_ANTENNAS_MAX 0x00006000 1339 - #define IEEE80211_VHT_CAP_SOUNDING_DIMENTION_MAX 0x00030000 1317 + #define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MAX 0x00030000 1340 1318 #define IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE 0x00080000 1341 1319 #define IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE 0x00100000 1342 1320 #define IEEE80211_VHT_CAP_VHT_TXOP_PS 0x00200000
+106 -20
include/net/cfg80211.h
··· 611 611 }; 612 612 613 613 /** 614 - * enum plink_action - actions to perform in mesh peers 615 - * 616 - * @PLINK_ACTION_INVALID: action 0 is reserved 617 - * @PLINK_ACTION_OPEN: start mesh peer link establishment 618 - * @PLINK_ACTION_BLOCK: block traffic from this mesh peer 619 - */ 620 - enum plink_actions { 621 - PLINK_ACTION_INVALID, 622 - PLINK_ACTION_OPEN, 623 - PLINK_ACTION_BLOCK, 624 - }; 625 - 626 - /** 627 614 * enum station_parameters_apply_mask - station parameter values to apply 628 615 * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, max_sp) 629 616 * @STATION_PARAM_APPLY_CAPABILITY: apply new capability 617 + * @STATION_PARAM_APPLY_PLINK_STATE: apply new plink state 630 618 * 631 619 * Not all station parameters have in-band "no change" signalling, 632 620 * for those that don't these flags will are used. ··· 622 634 enum station_parameters_apply_mask { 623 635 STATION_PARAM_APPLY_UAPSD = BIT(0), 624 636 STATION_PARAM_APPLY_CAPABILITY = BIT(1), 637 + STATION_PARAM_APPLY_PLINK_STATE = BIT(2), 625 638 }; 626 639 627 640 /** ··· 658 669 * @ext_capab_len: number of extended capabilities 659 670 */ 660 671 struct station_parameters { 661 - u8 *supported_rates; 672 + const u8 *supported_rates; 662 673 struct net_device *vlan; 663 674 u32 sta_flags_mask, sta_flags_set; 664 675 u32 sta_modify_mask; ··· 667 678 u8 supported_rates_len; 668 679 u8 plink_action; 669 680 u8 plink_state; 670 - struct ieee80211_ht_cap *ht_capa; 671 - struct ieee80211_vht_cap *vht_capa; 681 + const struct ieee80211_ht_cap *ht_capa; 682 + const struct ieee80211_vht_cap *vht_capa; 672 683 u8 uapsd_queues; 673 684 u8 max_sp; 674 685 enum nl80211_mesh_power_mode local_pm; 675 686 u16 capability; 676 - u8 *ext_capab; 687 + const u8 *ext_capab; 677 688 u8 ext_capab_len; 678 689 }; 690 + 691 + /** 692 + * enum cfg80211_station_type - the type of station being modified 693 + * @CFG80211_STA_AP_CLIENT: client of an AP interface 694 + * @CFG80211_STA_AP_MLME_CLIENT: client of an AP interface that has 695 + * the AP MLME in the device 696 + * @CFG80211_STA_AP_STA: AP station on managed interface 697 + * @CFG80211_STA_IBSS: IBSS station 698 + * @CFG80211_STA_TDLS_PEER_SETUP: TDLS peer on managed interface (dummy entry 699 + * while TDLS setup is in progress, it moves out of this state when 700 + * being marked authorized; use this only if TDLS with external setup is 701 + * supported/used) 702 + * @CFG80211_STA_TDLS_PEER_ACTIVE: TDLS peer on managed interface (active 703 + * entry that is operating, has been marked authorized by userspace) 704 + * @CFG80211_STA_MESH_PEER_KERNEL: peer on mesh interface (kernel managed) 705 + * @CFG80211_STA_MESH_PEER_USER: peer on mesh interface (user managed) 706 + */ 707 + enum cfg80211_station_type { 708 + CFG80211_STA_AP_CLIENT, 709 + CFG80211_STA_AP_MLME_CLIENT, 710 + CFG80211_STA_AP_STA, 711 + CFG80211_STA_IBSS, 712 + CFG80211_STA_TDLS_PEER_SETUP, 713 + CFG80211_STA_TDLS_PEER_ACTIVE, 714 + CFG80211_STA_MESH_PEER_KERNEL, 715 + CFG80211_STA_MESH_PEER_USER, 716 + }; 717 + 718 + /** 719 + * cfg80211_check_station_change - validate parameter changes 720 + * @wiphy: the wiphy this operates on 721 + * @params: the new parameters for a station 722 + * @statype: the type of station being modified 723 + * 724 + * Utility function for the @change_station driver method. Call this function 725 + * with the appropriate station type looking up the station (and checking that 726 + * it exists). It will verify whether the station change is acceptable, and if 727 + * not will return an error code. Note that it may modify the parameters for 728 + * backward compatibility reasons, so don't use them before calling this. 729 + */ 730 + int cfg80211_check_station_change(struct wiphy *wiphy, 731 + struct station_parameters *params, 732 + enum cfg80211_station_type statype); 679 733 680 734 /** 681 735 * enum station_info_flags - station information flags ··· 1151 1119 * @ie_len: length of vendor information elements 1152 1120 * @is_authenticated: this mesh requires authentication 1153 1121 * @is_secure: this mesh uses security 1122 + * @user_mpm: userspace handles all MPM functions 1154 1123 * @dtim_period: DTIM period to use 1155 1124 * @beacon_interval: beacon interval to use 1156 1125 * @mcast_rate: multicat rate for Mesh Node [6Mbps is the default for 802.11a] ··· 1169 1136 u8 ie_len; 1170 1137 bool is_authenticated; 1171 1138 bool is_secure; 1139 + bool user_mpm; 1172 1140 u8 dtim_period; 1173 1141 u16 beacon_interval; 1174 1142 int mcast_rate[IEEE80211_NUM_BANDS]; ··· 1432 1398 * enum cfg80211_assoc_req_flags - Over-ride default behaviour in association. 1433 1399 * 1434 1400 * @ASSOC_REQ_DISABLE_HT: Disable HT (802.11n) 1401 + * @ASSOC_REQ_DISABLE_VHT: Disable VHT 1435 1402 */ 1436 1403 enum cfg80211_assoc_req_flags { 1437 1404 ASSOC_REQ_DISABLE_HT = BIT(0), 1405 + ASSOC_REQ_DISABLE_VHT = BIT(1), 1438 1406 }; 1439 1407 1440 1408 /** ··· 1458 1422 * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask 1459 1423 * will be used in ht_capa. Un-supported values will be ignored. 1460 1424 * @ht_capa_mask: The bits of ht_capa which are to be used. 1425 + * @vht_capa: VHT capability override 1426 + * @vht_capa_mask: VHT capability mask indicating which fields to use 1461 1427 */ 1462 1428 struct cfg80211_assoc_request { 1463 1429 struct cfg80211_bss *bss; ··· 1470 1432 u32 flags; 1471 1433 struct ieee80211_ht_cap ht_capa; 1472 1434 struct ieee80211_ht_cap ht_capa_mask; 1435 + struct ieee80211_vht_cap vht_capa, vht_capa_mask; 1473 1436 }; 1474 1437 1475 1438 /** ··· 1581 1542 * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask 1582 1543 * will be used in ht_capa. Un-supported values will be ignored. 1583 1544 * @ht_capa_mask: The bits of ht_capa which are to be used. 1545 + * @vht_capa: VHT Capability overrides 1546 + * @vht_capa_mask: The bits of vht_capa which are to be used. 1584 1547 */ 1585 1548 struct cfg80211_connect_params { 1586 1549 struct ieee80211_channel *channel; ··· 1601 1560 int bg_scan_period; 1602 1561 struct ieee80211_ht_cap ht_capa; 1603 1562 struct ieee80211_ht_cap ht_capa_mask; 1563 + struct ieee80211_vht_cap vht_capa; 1564 + struct ieee80211_vht_cap vht_capa_mask; 1604 1565 }; 1605 1566 1606 1567 /** ··· 1765 1722 }; 1766 1723 1767 1724 /** 1725 + * struct cfg80211_update_ft_ies_params - FT IE Information 1726 + * 1727 + * This structure provides information needed to update the fast transition IE 1728 + * 1729 + * @md: The Mobility Domain ID, 2 Octet value 1730 + * @ie: Fast Transition IEs 1731 + * @ie_len: Length of ft_ie in octets 1732 + */ 1733 + struct cfg80211_update_ft_ies_params { 1734 + u16 md; 1735 + const u8 *ie; 1736 + size_t ie_len; 1737 + }; 1738 + 1739 + /** 1768 1740 * struct cfg80211_ops - backend description for wireless configuration 1769 1741 * 1770 1742 * This struct is registered by fullmac card drivers and/or wireless stacks ··· 1839 1781 * @change_station: Modify a given station. Note that flags changes are not much 1840 1782 * validated in cfg80211, in particular the auth/assoc/authorized flags 1841 1783 * might come to the driver in invalid combinations -- make sure to check 1842 - * them, also against the existing state! Also, supported_rates changes are 1843 - * not checked in station mode -- drivers need to reject (or ignore) them 1844 - * for anything but TDLS peers. 1784 + * them, also against the existing state! Drivers must call 1785 + * cfg80211_check_station_change() to validate the information. 1845 1786 * @get_station: get station information for the station identified by @mac 1846 1787 * @dump_station: dump station callback -- resume dump at index @idx 1847 1788 * ··· 2225 2168 int (*start_radar_detection)(struct wiphy *wiphy, 2226 2169 struct net_device *dev, 2227 2170 struct cfg80211_chan_def *chandef); 2171 + int (*update_ft_ies)(struct wiphy *wiphy, struct net_device *dev, 2172 + struct cfg80211_update_ft_ies_params *ftie); 2228 2173 }; 2229 2174 2230 2175 /* ··· 2544 2485 * @ap_sme_capa: AP SME capabilities, flags from &enum nl80211_ap_sme_features. 2545 2486 * @ht_capa_mod_mask: Specify what ht_cap values can be over-ridden. 2546 2487 * If null, then none can be over-ridden. 2488 + * @vht_capa_mod_mask: Specify what VHT capabilities can be over-ridden. 2489 + * If null, then none can be over-ridden. 2547 2490 * 2548 2491 * @max_acl_mac_addrs: Maximum number of MAC addresses that the device 2549 2492 * supports for ACL. ··· 2654 2593 struct dentry *debugfsdir; 2655 2594 2656 2595 const struct ieee80211_ht_cap *ht_capa_mod_mask; 2596 + const struct ieee80211_vht_cap *vht_capa_mod_mask; 2657 2597 2658 2598 #ifdef CONFIG_NET_NS 2659 2599 /* the network namespace this phy lives in currently */ ··· 4062 4000 * Requires the RTNL to be held. 4063 4001 */ 4064 4002 void cfg80211_unregister_wdev(struct wireless_dev *wdev); 4003 + 4004 + /** 4005 + * struct cfg80211_ft_event - FT Information Elements 4006 + * @ies: FT IEs 4007 + * @ies_len: length of the FT IE in bytes 4008 + * @target_ap: target AP's MAC address 4009 + * @ric_ies: RIC IE 4010 + * @ric_ies_len: length of the RIC IE in bytes 4011 + */ 4012 + struct cfg80211_ft_event_params { 4013 + const u8 *ies; 4014 + size_t ies_len; 4015 + const u8 *target_ap; 4016 + const u8 *ric_ies; 4017 + size_t ric_ies_len; 4018 + }; 4019 + 4020 + /** 4021 + * cfg80211_ft_event - notify userspace about FT IE and RIC IE 4022 + * @netdev: network device 4023 + * @ft_event: IE information 4024 + */ 4025 + void cfg80211_ft_event(struct net_device *netdev, 4026 + struct cfg80211_ft_event_params *ft_event); 4065 4027 4066 4028 /** 4067 4029 * cfg80211_get_p2p_attr - find and copy a P2P attribute from IE buffer
+22 -7
include/net/mac80211.h
··· 1101 1101 * These flags are used for communication about keys between the driver 1102 1102 * and mac80211, with the @flags parameter of &struct ieee80211_key_conf. 1103 1103 * 1104 - * @IEEE80211_KEY_FLAG_WMM_STA: Set by mac80211, this flag indicates 1105 - * that the STA this key will be used with could be using QoS. 1106 1104 * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the 1107 1105 * driver to indicate that it requires IV generation for this 1108 1106 * particular key. ··· 1125 1127 * %IEEE80211_KEY_FLAG_SW_MGMT_TX flag to encrypt such frames in SW. 1126 1128 */ 1127 1129 enum ieee80211_key_flags { 1128 - IEEE80211_KEY_FLAG_WMM_STA = 1<<0, 1129 1130 IEEE80211_KEY_FLAG_GENERATE_IV = 1<<1, 1130 1131 IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2, 1131 1132 IEEE80211_KEY_FLAG_PAIRWISE = 1<<3, ··· 1228 1231 * @addr: MAC address 1229 1232 * @aid: AID we assigned to the station if we're an AP 1230 1233 * @supp_rates: Bitmap of supported rates (per band) 1231 - * @ht_cap: HT capabilities of this STA; restricted to our own TX capabilities 1232 - * @vht_cap: VHT capabilities of this STA; Not restricting any capabilities 1233 - * of remote STA. Taking as is. 1234 + * @ht_cap: HT capabilities of this STA; restricted to our own capabilities 1235 + * @vht_cap: VHT capabilities of this STA; restricted to our own capabilities 1234 1236 * @wme: indicates whether the STA supports WME. Only valid during AP-mode. 1235 1237 * @drv_priv: data area for driver use, will always be aligned to 1236 1238 * sizeof(void *), size is determined in hw information. ··· 2131 2135 }; 2132 2136 2133 2137 /** 2138 + * enum ieee80211_roc_type - remain on channel type 2139 + * 2140 + * With the support for multi channel contexts and multi channel operations, 2141 + * remain on channel operations might be limited/deferred/aborted by other 2142 + * flows/operations which have higher priority (and vise versa). 2143 + * Specifying the ROC type can be used by devices to prioritize the ROC 2144 + * operations compared to other operations/flows. 2145 + * 2146 + * @IEEE80211_ROC_TYPE_NORMAL: There are no special requirements for this ROC. 2147 + * @IEEE80211_ROC_TYPE_MGMT_TX: The remain on channel request is required 2148 + * for sending managment frames offchannel. 2149 + */ 2150 + enum ieee80211_roc_type { 2151 + IEEE80211_ROC_TYPE_NORMAL = 0, 2152 + IEEE80211_ROC_TYPE_MGMT_TX, 2153 + }; 2154 + 2155 + /** 2134 2156 * struct ieee80211_ops - callbacks from mac80211 to the driver 2135 2157 * 2136 2158 * This structure contains various callbacks that the driver may ··· 2701 2687 int (*remain_on_channel)(struct ieee80211_hw *hw, 2702 2688 struct ieee80211_vif *vif, 2703 2689 struct ieee80211_channel *chan, 2704 - int duration); 2690 + int duration, 2691 + enum ieee80211_roc_type type); 2705 2692 int (*cancel_remain_on_channel)(struct ieee80211_hw *hw); 2706 2693 int (*set_ringparam)(struct ieee80211_hw *hw, u32 tx, u32 rx); 2707 2694 void (*get_ringparam)(struct ieee80211_hw *hw,
+106 -11
include/uapi/linux/nl80211.h
··· 36 36 * The station is still assumed to belong to the AP interface it was added 37 37 * to. 38 38 * 39 - * TODO: need more info? 39 + * Station handling varies per interface type and depending on the driver's 40 + * capabilities. 41 + * 42 + * For drivers supporting TDLS with external setup (WIPHY_FLAG_SUPPORTS_TDLS 43 + * and WIPHY_FLAG_TDLS_EXTERNAL_SETUP), the station lifetime is as follows: 44 + * - a setup station entry is added, not yet authorized, without any rate 45 + * or capability information, this just exists to avoid race conditions 46 + * - when the TDLS setup is done, a single NL80211_CMD_SET_STATION is valid 47 + * to add rate and capability information to the station and at the same 48 + * time mark it authorized. 49 + * - %NL80211_TDLS_ENABLE_LINK is then used 50 + * - after this, the only valid operation is to remove it by tearing down 51 + * the TDLS link (%NL80211_TDLS_DISABLE_LINK) 52 + * 53 + * TODO: need more info for other interface types 40 54 */ 41 55 42 56 /** ··· 513 499 * @NL80211_CMD_NEW_PEER_CANDIDATE: Notification on the reception of a 514 500 * beacon or probe response from a compatible mesh peer. This is only 515 501 * sent while no station information (sta_info) exists for the new peer 516 - * candidate and when @NL80211_MESH_SETUP_USERSPACE_AUTH is set. On 517 - * reception of this notification, userspace may decide to create a new 518 - * station (@NL80211_CMD_NEW_STATION). To stop this notification from 502 + * candidate and when @NL80211_MESH_SETUP_USERSPACE_AUTH, 503 + * @NL80211_MESH_SETUP_USERSPACE_AMPE, or 504 + * @NL80211_MESH_SETUP_USERSPACE_MPM is set. On reception of this 505 + * notification, userspace may decide to create a new station 506 + * (@NL80211_CMD_NEW_STATION). To stop this notification from 519 507 * reoccurring, the userspace authentication daemon may want to create the 520 508 * new station with the AUTHENTICATED flag unset and maybe change it later 521 509 * depending on the authentication result. ··· 626 610 * while operating on this channel. 627 611 * %NL80211_ATTR_RADAR_EVENT is used to inform about the type of the 628 612 * event. 613 + * 614 + * @NL80211_CMD_GET_PROTOCOL_FEATURES: Get global nl80211 protocol features, 615 + * i.e. features for the nl80211 protocol rather than device features. 616 + * Returns the features in the %NL80211_ATTR_PROTOCOL_FEATURES bitmap. 617 + * 618 + * @NL80211_CMD_UPDATE_FT_IES: Pass down the most up-to-date Fast Transition 619 + * Information Element to the WLAN driver 620 + * 621 + * @NL80211_CMD_FT_EVENT: Send a Fast transition event from the WLAN driver 622 + * to the supplicant. This will carry the target AP's MAC address along 623 + * with the relevant Information Elements. This event is used to report 624 + * received FT IEs (MDIE, FTIE, RSN IE, TIE, RICIE). 629 625 * 630 626 * @NL80211_CMD_MAX: highest used command number 631 627 * @__NL80211_CMD_AFTER_LAST: internal use ··· 793 765 794 766 NL80211_CMD_RADAR_DETECT, 795 767 768 + NL80211_CMD_GET_PROTOCOL_FEATURES, 769 + 770 + NL80211_CMD_UPDATE_FT_IES, 771 + NL80211_CMD_FT_EVENT, 772 + 796 773 /* add new commands above here */ 797 774 798 775 /* used to define NL80211_CMD_MAX below */ ··· 917 884 * consisting of a nested array. 918 885 * 919 886 * @NL80211_ATTR_MESH_ID: mesh id (1-32 bytes). 920 - * @NL80211_ATTR_STA_PLINK_ACTION: action to perform on the mesh peer link. 887 + * @NL80211_ATTR_STA_PLINK_ACTION: action to perform on the mesh peer link 888 + * (see &enum nl80211_plink_action). 921 889 * @NL80211_ATTR_MPATH_NEXT_HOP: MAC address of the next hop for a mesh path. 922 890 * @NL80211_ATTR_MPATH_INFO: information about a mesh_path, part of mesh path 923 891 * info given for %NL80211_CMD_GET_MPATH, nested attribute described at ··· 1201 1167 * @NL80211_ATTR_SUPPORT_MESH_AUTH: Currently, this means the underlying driver 1202 1168 * allows auth frames in a mesh to be passed to userspace for processing via 1203 1169 * the @NL80211_MESH_SETUP_USERSPACE_AUTH flag. 1204 - * @NL80211_ATTR_STA_PLINK_STATE: The state of a mesh peer link as 1205 - * defined in &enum nl80211_plink_state. Used when userspace is 1206 - * driving the peer link management state machine. 1207 - * @NL80211_MESH_SETUP_USERSPACE_AMPE must be enabled. 1170 + * @NL80211_ATTR_STA_PLINK_STATE: The state of a mesh peer link as defined in 1171 + * &enum nl80211_plink_state. Used when userspace is driving the peer link 1172 + * management state machine. @NL80211_MESH_SETUP_USERSPACE_AMPE or 1173 + * @NL80211_MESH_SETUP_USERSPACE_MPM must be enabled. 1208 1174 * 1209 1175 * @NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED: indicates, as part of the wiphy 1210 1176 * capabilities, the supported WoWLAN triggers ··· 1401 1367 * @NL80211_ATTR_STA_EXT_CAPABILITY: Station extended capabilities are 1402 1368 * advertised to the driver, e.g., to enable TDLS off channel operations 1403 1369 * and PU-APSD. 1370 + * 1371 + * @NL80211_ATTR_PROTOCOL_FEATURES: global nl80211 feature flags, see 1372 + * &enum nl80211_protocol_features, the attribute is a u32. 1373 + * 1374 + * @NL80211_ATTR_SPLIT_WIPHY_DUMP: flag attribute, userspace supports 1375 + * receiving the data for a single wiphy split across multiple 1376 + * messages, given with wiphy dump message 1377 + * 1378 + * @NL80211_ATTR_MDID: Mobility Domain Identifier 1379 + * 1380 + * @NL80211_ATTR_IE_RIC: Resource Information Container Information 1381 + * Element 1404 1382 * 1405 1383 * @NL80211_ATTR_MAX: highest attribute number currently defined 1406 1384 * @__NL80211_ATTR_AFTER_LAST: internal use ··· 1699 1653 1700 1654 NL80211_ATTR_STA_CAPABILITY, 1701 1655 NL80211_ATTR_STA_EXT_CAPABILITY, 1656 + 1657 + NL80211_ATTR_PROTOCOL_FEATURES, 1658 + NL80211_ATTR_SPLIT_WIPHY_DUMP, 1659 + 1660 + NL80211_ATTR_DISABLE_VHT, 1661 + NL80211_ATTR_VHT_CAPABILITY_MASK, 1662 + 1663 + NL80211_ATTR_MDID, 1664 + NL80211_ATTR_IE_RIC, 1702 1665 1703 1666 /* add attributes here, update the policy in nl80211.c */ 1704 1667 ··· 2467 2412 * @NL80211_MESHCONF_TTL: specifies the value of TTL field set at a source mesh 2468 2413 * point. 2469 2414 * 2470 - * @NL80211_MESHCONF_AUTO_OPEN_PLINKS: whether we should automatically 2471 - * open peer links when we detect compatible mesh peers. 2415 + * @NL80211_MESHCONF_AUTO_OPEN_PLINKS: whether we should automatically open 2416 + * peer links when we detect compatible mesh peers. Disabled if 2417 + * @NL80211_MESH_SETUP_USERSPACE_MPM or @NL80211_MESH_SETUP_USERSPACE_AMPE are 2418 + * set. 2472 2419 * 2473 2420 * @NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES: the number of action frames 2474 2421 * containing a PREQ that an MP can send to a particular destination (path ··· 2616 2559 * vendor specific synchronization method or disable it to use the default 2617 2560 * neighbor offset synchronization 2618 2561 * 2562 + * @NL80211_MESH_SETUP_USERSPACE_MPM: Enable this option if userspace will 2563 + * implement an MPM which handles peer allocation and state. 2564 + * 2619 2565 * @NL80211_MESH_SETUP_ATTR_MAX: highest possible mesh setup attribute number 2620 2566 * 2621 2567 * @__NL80211_MESH_SETUP_ATTR_AFTER_LAST: Internal use ··· 2631 2571 NL80211_MESH_SETUP_USERSPACE_AUTH, 2632 2572 NL80211_MESH_SETUP_USERSPACE_AMPE, 2633 2573 NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC, 2574 + NL80211_MESH_SETUP_USERSPACE_MPM, 2634 2575 2635 2576 /* keep last */ 2636 2577 __NL80211_MESH_SETUP_ATTR_AFTER_LAST, ··· 3368 3307 MAX_NL80211_PLINK_STATES = NUM_NL80211_PLINK_STATES - 1 3369 3308 }; 3370 3309 3310 + /** 3311 + * enum nl80211_plink_action - actions to perform in mesh peers 3312 + * 3313 + * @NL80211_PLINK_ACTION_NO_ACTION: perform no action 3314 + * @NL80211_PLINK_ACTION_OPEN: start mesh peer link establishment 3315 + * @NL80211_PLINK_ACTION_BLOCK: block traffic from this mesh peer 3316 + * @NUM_NL80211_PLINK_ACTIONS: number of possible actions 3317 + */ 3318 + enum plink_actions { 3319 + NL80211_PLINK_ACTION_NO_ACTION, 3320 + NL80211_PLINK_ACTION_OPEN, 3321 + NL80211_PLINK_ACTION_BLOCK, 3322 + 3323 + NUM_NL80211_PLINK_ACTIONS, 3324 + }; 3325 + 3326 + 3371 3327 #define NL80211_KCK_LEN 16 3372 3328 #define NL80211_KEK_LEN 16 3373 3329 #define NL80211_REPLAY_CTR_LEN 8 ··· 3534 3456 * stations the authenticated/associated bits have to be set in the mask. 3535 3457 * @NL80211_FEATURE_ADVERTISE_CHAN_LIMITS: cfg80211 advertises channel limits 3536 3458 * (HT40, VHT 80/160 MHz) if this flag is set 3459 + * @NL80211_FEATURE_USERSPACE_MPM: This driver supports a userspace Mesh 3460 + * Peering Management entity which may be implemented by registering for 3461 + * beacons or NL80211_CMD_NEW_PEER_CANDIDATE events. The mesh beacon is 3462 + * still generated by the driver. 3537 3463 */ 3538 3464 enum nl80211_feature_flags { 3539 3465 NL80211_FEATURE_SK_TX_STATUS = 1 << 0, ··· 3556 3474 /* bit 13 is reserved */ 3557 3475 NL80211_FEATURE_ADVERTISE_CHAN_LIMITS = 1 << 14, 3558 3476 NL80211_FEATURE_FULL_AP_CLIENT_STATE = 1 << 15, 3477 + NL80211_FEATURE_USERSPACE_MPM = 1 << 16, 3559 3478 }; 3560 3479 3561 3480 /** ··· 3668 3585 NL80211_DFS_USABLE, 3669 3586 NL80211_DFS_UNAVAILABLE, 3670 3587 NL80211_DFS_AVAILABLE, 3588 + }; 3589 + 3590 + /** 3591 + * enum enum nl80211_protocol_features - nl80211 protocol features 3592 + * @NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP: nl80211 supports splitting 3593 + * wiphy dumps (if requested by the application with the attribute 3594 + * %NL80211_ATTR_SPLIT_WIPHY_DUMP. Also supported is filtering the 3595 + * wiphy dump by %NL80211_ATTR_WIPHY, %NL80211_ATTR_IFINDEX or 3596 + * %NL80211_ATTR_WDEV. 3597 + */ 3598 + enum nl80211_protocol_features { 3599 + NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP = 1 << 0, 3671 3600 }; 3672 3601 3673 3602 #endif /* __LINUX_NL80211_H */
+114 -48
net/mac80211/cfg.c
··· 254 254 goto out_unlock; 255 255 } 256 256 257 - __ieee80211_key_free(key); 257 + __ieee80211_key_free(key, true); 258 258 259 259 ret = 0; 260 260 out_unlock: ··· 1035 1035 sta_info_flush_defer(vlan); 1036 1036 sta_info_flush_defer(sdata); 1037 1037 rcu_barrier(); 1038 - list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) 1038 + list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) { 1039 1039 sta_info_flush_cleanup(vlan); 1040 + ieee80211_free_keys(vlan); 1041 + } 1040 1042 sta_info_flush_cleanup(sdata); 1043 + ieee80211_free_keys(sdata); 1041 1044 1042 1045 sdata->vif.bss_conf.enable_beacon = false; 1043 1046 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state); ··· 1180 1177 mask |= BIT(NL80211_STA_FLAG_ASSOCIATED); 1181 1178 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) 1182 1179 set |= BIT(NL80211_STA_FLAG_ASSOCIATED); 1180 + } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) { 1181 + /* 1182 + * TDLS -- everything follows authorized, but 1183 + * only becoming authorized is possible, not 1184 + * going back 1185 + */ 1186 + if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) { 1187 + set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) | 1188 + BIT(NL80211_STA_FLAG_ASSOCIATED); 1189 + mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) | 1190 + BIT(NL80211_STA_FLAG_ASSOCIATED); 1191 + } 1183 1192 } 1184 1193 1185 1194 ret = sta_apply_auth_flags(local, sta, mask, set); ··· 1276 1261 if (ieee80211_vif_is_mesh(&sdata->vif)) { 1277 1262 #ifdef CONFIG_MAC80211_MESH 1278 1263 u32 changed = 0; 1279 - if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED) { 1264 + 1265 + if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) { 1280 1266 switch (params->plink_state) { 1281 1267 case NL80211_PLINK_ESTAB: 1282 1268 if (sta->plink_state != NL80211_PLINK_ESTAB) ··· 1308 1292 /* nothing */ 1309 1293 break; 1310 1294 } 1311 - } else { 1312 - switch (params->plink_action) { 1313 - case PLINK_ACTION_OPEN: 1314 - changed |= mesh_plink_open(sta); 1315 - break; 1316 - case PLINK_ACTION_BLOCK: 1317 - changed |= mesh_plink_block(sta); 1318 - break; 1319 - } 1295 + } 1296 + 1297 + switch (params->plink_action) { 1298 + case NL80211_PLINK_ACTION_NO_ACTION: 1299 + /* nothing */ 1300 + break; 1301 + case NL80211_PLINK_ACTION_OPEN: 1302 + changed |= mesh_plink_open(sta); 1303 + break; 1304 + case NL80211_PLINK_ACTION_BLOCK: 1305 + changed |= mesh_plink_block(sta); 1306 + break; 1320 1307 } 1321 1308 1322 1309 if (params->local_pm) ··· 1365 1346 * defaults -- if userspace wants something else we'll 1366 1347 * change it accordingly in sta_apply_parameters() 1367 1348 */ 1368 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); 1369 - sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); 1349 + if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))) { 1350 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); 1351 + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); 1352 + } 1370 1353 1371 1354 err = sta_apply_parameters(local, sta, params); 1372 1355 if (err) { ··· 1377 1356 } 1378 1357 1379 1358 /* 1380 - * for TDLS, rate control should be initialized only when supported 1381 - * rates are known. 1359 + * for TDLS, rate control should be initialized only when 1360 + * rates are known and station is marked authorized 1382 1361 */ 1383 1362 if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) 1384 1363 rate_control_rate_init(sta); ··· 1415 1394 } 1416 1395 1417 1396 static int ieee80211_change_station(struct wiphy *wiphy, 1418 - struct net_device *dev, 1419 - u8 *mac, 1397 + struct net_device *dev, u8 *mac, 1420 1398 struct station_parameters *params) 1421 1399 { 1422 1400 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1423 1401 struct ieee80211_local *local = wiphy_priv(wiphy); 1424 1402 struct sta_info *sta; 1425 1403 struct ieee80211_sub_if_data *vlansdata; 1404 + enum cfg80211_station_type statype; 1426 1405 int err; 1427 1406 1428 1407 mutex_lock(&local->sta_mtx); 1429 1408 1430 1409 sta = sta_info_get_bss(sdata, mac); 1431 1410 if (!sta) { 1432 - mutex_unlock(&local->sta_mtx); 1433 - return -ENOENT; 1411 + err = -ENOENT; 1412 + goto out_err; 1434 1413 } 1435 1414 1436 - /* in station mode, some updates are only valid with TDLS */ 1437 - if (sdata->vif.type == NL80211_IFTYPE_STATION && 1438 - (params->supported_rates || params->ht_capa || params->vht_capa || 1439 - params->sta_modify_mask || 1440 - (params->sta_flags_mask & BIT(NL80211_STA_FLAG_WME))) && 1441 - !test_sta_flag(sta, WLAN_STA_TDLS_PEER)) { 1442 - mutex_unlock(&local->sta_mtx); 1443 - return -EINVAL; 1415 + switch (sdata->vif.type) { 1416 + case NL80211_IFTYPE_MESH_POINT: 1417 + if (sdata->u.mesh.user_mpm) 1418 + statype = CFG80211_STA_MESH_PEER_USER; 1419 + else 1420 + statype = CFG80211_STA_MESH_PEER_KERNEL; 1421 + break; 1422 + case NL80211_IFTYPE_ADHOC: 1423 + statype = CFG80211_STA_IBSS; 1424 + break; 1425 + case NL80211_IFTYPE_STATION: 1426 + if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) { 1427 + statype = CFG80211_STA_AP_STA; 1428 + break; 1429 + } 1430 + if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) 1431 + statype = CFG80211_STA_TDLS_PEER_ACTIVE; 1432 + else 1433 + statype = CFG80211_STA_TDLS_PEER_SETUP; 1434 + break; 1435 + case NL80211_IFTYPE_AP: 1436 + case NL80211_IFTYPE_AP_VLAN: 1437 + statype = CFG80211_STA_AP_CLIENT; 1438 + break; 1439 + default: 1440 + err = -EOPNOTSUPP; 1441 + goto out_err; 1444 1442 } 1443 + 1444 + err = cfg80211_check_station_change(wiphy, params, statype); 1445 + if (err) 1446 + goto out_err; 1445 1447 1446 1448 if (params->vlan && params->vlan != sta->sdata->dev) { 1447 1449 bool prev_4addr = false; ··· 1472 1428 1473 1429 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); 1474 1430 1475 - if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN && 1476 - vlansdata->vif.type != NL80211_IFTYPE_AP) { 1477 - mutex_unlock(&local->sta_mtx); 1478 - return -EINVAL; 1479 - } 1480 - 1481 1431 if (params->vlan->ieee80211_ptr->use_4addr) { 1482 1432 if (vlansdata->u.vlan.sta) { 1483 - mutex_unlock(&local->sta_mtx); 1484 - return -EBUSY; 1433 + err = -EBUSY; 1434 + goto out_err; 1485 1435 } 1486 1436 1487 1437 rcu_assign_pointer(vlansdata->u.vlan.sta, sta); ··· 1502 1464 } 1503 1465 1504 1466 err = sta_apply_parameters(local, sta, params); 1505 - if (err) { 1506 - mutex_unlock(&local->sta_mtx); 1507 - return err; 1508 - } 1467 + if (err) 1468 + goto out_err; 1509 1469 1510 - if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && params->supported_rates) 1470 + /* When peer becomes authorized, init rate control as well */ 1471 + if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && 1472 + test_sta_flag(sta, WLAN_STA_AUTHORIZED)) 1511 1473 rate_control_rate_init(sta); 1512 1474 1513 1475 mutex_unlock(&local->sta_mtx); ··· 1517 1479 ieee80211_recalc_ps(local, -1); 1518 1480 ieee80211_recalc_ps_vif(sdata); 1519 1481 } 1482 + 1520 1483 return 0; 1484 + out_err: 1485 + mutex_unlock(&local->sta_mtx); 1486 + return err; 1521 1487 } 1522 1488 1523 1489 #ifdef CONFIG_MAC80211_MESH ··· 1729 1687 ifmsh->mesh_sp_id = setup->sync_method; 1730 1688 ifmsh->mesh_pp_id = setup->path_sel_proto; 1731 1689 ifmsh->mesh_pm_id = setup->path_metric; 1690 + ifmsh->user_mpm = setup->user_mpm; 1732 1691 ifmsh->security = IEEE80211_MESH_SEC_NONE; 1733 1692 if (setup->is_authenticated) 1734 1693 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED; ··· 1773 1730 conf->dot11MeshTTL = nconf->dot11MeshTTL; 1774 1731 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask)) 1775 1732 conf->element_ttl = nconf->element_ttl; 1776 - if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) 1733 + if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) { 1734 + if (ifmsh->user_mpm) 1735 + return -EBUSY; 1777 1736 conf->auto_open_plinks = nconf->auto_open_plinks; 1737 + } 1778 1738 if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask)) 1779 1739 conf->dot11MeshNbrOffsetMaxNeighbor = 1780 1740 nconf->dot11MeshNbrOffsetMaxNeighbor; ··· 2417 2371 struct ieee80211_sub_if_data *sdata, 2418 2372 struct ieee80211_channel *channel, 2419 2373 unsigned int duration, u64 *cookie, 2420 - struct sk_buff *txskb) 2374 + struct sk_buff *txskb, 2375 + enum ieee80211_roc_type type) 2421 2376 { 2422 2377 struct ieee80211_roc_work *roc, *tmp; 2423 2378 bool queued = false; ··· 2437 2390 roc->duration = duration; 2438 2391 roc->req_duration = duration; 2439 2392 roc->frame = txskb; 2393 + roc->type = type; 2440 2394 roc->mgmt_tx_cookie = (unsigned long)txskb; 2441 2395 roc->sdata = sdata; 2442 2396 INIT_DELAYED_WORK(&roc->work, ieee80211_sw_roc_work); ··· 2468 2420 if (!duration) 2469 2421 duration = 10; 2470 2422 2471 - ret = drv_remain_on_channel(local, sdata, channel, duration); 2423 + ret = drv_remain_on_channel(local, sdata, channel, duration, type); 2472 2424 if (ret) { 2473 2425 kfree(roc); 2474 2426 return ret; ··· 2487 2439 * 2488 2440 * If it hasn't started yet, just increase the duration 2489 2441 * and add the new one to the list of dependents. 2442 + * If the type of the new ROC has higher priority, modify the 2443 + * type of the previous one to match that of the new one. 2490 2444 */ 2491 2445 if (!tmp->started) { 2492 2446 list_add_tail(&roc->list, &tmp->dependents); 2493 2447 tmp->duration = max(tmp->duration, roc->duration); 2448 + tmp->type = max(tmp->type, roc->type); 2494 2449 queued = true; 2495 2450 break; 2496 2451 } ··· 2505 2454 /* 2506 2455 * In the offloaded ROC case, if it hasn't begun, add 2507 2456 * this new one to the dependent list to be handled 2508 - * when the the master one begins. If it has begun, 2457 + * when the master one begins. If it has begun, 2509 2458 * check that there's still a minimum time left and 2510 2459 * if so, start this one, transmitting the frame, but 2511 - * add it to the list directly after this one with a 2460 + * add it to the list directly after this one with 2512 2461 * a reduced time so we'll ask the driver to execute 2513 2462 * it right after finishing the previous one, in the 2514 2463 * hope that it'll also be executed right afterwards, 2515 2464 * effectively extending the old one. 2516 2465 * If there's no minimum time left, just add it to the 2517 2466 * normal list. 2467 + * TODO: the ROC type is ignored here, assuming that it 2468 + * is better to immediately use the current ROC. 2518 2469 */ 2519 2470 if (!tmp->hw_begun) { 2520 2471 list_add_tail(&roc->list, &tmp->dependents); ··· 2610 2557 2611 2558 mutex_lock(&local->mtx); 2612 2559 ret = ieee80211_start_roc_work(local, sdata, chan, 2613 - duration, cookie, NULL); 2560 + duration, cookie, NULL, 2561 + IEEE80211_ROC_TYPE_NORMAL); 2614 2562 mutex_unlock(&local->mtx); 2615 2563 2616 2564 return ret; ··· 2844 2790 2845 2791 /* This will handle all kinds of coalescing and immediate TX */ 2846 2792 ret = ieee80211_start_roc_work(local, sdata, chan, 2847 - wait, cookie, skb); 2793 + wait, cookie, skb, 2794 + IEEE80211_ROC_TYPE_MGMT_TX); 2848 2795 if (ret) 2849 2796 kfree_skb(skb); 2850 2797 out_unlock: ··· 3340 3285 struct cfg80211_chan_def *chandef) 3341 3286 { 3342 3287 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); 3288 + struct ieee80211_local *local = wiphy_priv(wiphy); 3343 3289 struct ieee80211_chanctx_conf *chanctx_conf; 3344 3290 int ret = -ENODATA; 3345 3291 ··· 3348 3292 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); 3349 3293 if (chanctx_conf) { 3350 3294 *chandef = chanctx_conf->def; 3295 + ret = 0; 3296 + } else if (local->open_count > 0 && 3297 + local->open_count == local->monitors && 3298 + sdata->vif.type == NL80211_IFTYPE_MONITOR) { 3299 + if (local->use_chanctx) 3300 + *chandef = local->monitor_chandef; 3301 + else 3302 + cfg80211_chandef_create(chandef, 3303 + local->_oper_channel, 3304 + local->_oper_channel_type); 3351 3305 ret = 0; 3352 3306 } 3353 3307 rcu_read_unlock();
+31
net/mac80211/debugfs_sta.c
··· 325 325 } 326 326 STA_OPS(ht_capa); 327 327 328 + static ssize_t sta_vht_capa_read(struct file *file, char __user *userbuf, 329 + size_t count, loff_t *ppos) 330 + { 331 + char buf[128], *p = buf; 332 + struct sta_info *sta = file->private_data; 333 + struct ieee80211_sta_vht_cap *vhtc = &sta->sta.vht_cap; 334 + 335 + p += scnprintf(p, sizeof(buf) + buf - p, "VHT %ssupported\n", 336 + vhtc->vht_supported ? "" : "not "); 337 + if (vhtc->vht_supported) { 338 + p += scnprintf(p, sizeof(buf)+buf-p, "cap: %#.8x\n", vhtc->cap); 339 + 340 + p += scnprintf(p, sizeof(buf)+buf-p, "RX MCS: %.4x\n", 341 + le16_to_cpu(vhtc->vht_mcs.rx_mcs_map)); 342 + if (vhtc->vht_mcs.rx_highest) 343 + p += scnprintf(p, sizeof(buf)+buf-p, 344 + "MCS RX highest: %d Mbps\n", 345 + le16_to_cpu(vhtc->vht_mcs.rx_highest)); 346 + p += scnprintf(p, sizeof(buf)+buf-p, "TX MCS: %.4x\n", 347 + le16_to_cpu(vhtc->vht_mcs.tx_mcs_map)); 348 + if (vhtc->vht_mcs.tx_highest) 349 + p += scnprintf(p, sizeof(buf)+buf-p, 350 + "MCS TX highest: %d Mbps\n", 351 + le16_to_cpu(vhtc->vht_mcs.tx_highest)); 352 + } 353 + 354 + return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); 355 + } 356 + STA_OPS(vht_capa); 357 + 328 358 static ssize_t sta_current_tx_rate_read(struct file *file, char __user *userbuf, 329 359 size_t count, loff_t *ppos) 330 360 { ··· 435 405 DEBUGFS_ADD(dev); 436 406 DEBUGFS_ADD(last_signal); 437 407 DEBUGFS_ADD(ht_capa); 408 + DEBUGFS_ADD(vht_capa); 438 409 DEBUGFS_ADD(last_ack_signal); 439 410 DEBUGFS_ADD(current_tx_rate); 440 411 DEBUGFS_ADD(last_rx_rate);
+4 -3
net/mac80211/driver-ops.h
··· 787 787 static inline int drv_remain_on_channel(struct ieee80211_local *local, 788 788 struct ieee80211_sub_if_data *sdata, 789 789 struct ieee80211_channel *chan, 790 - unsigned int duration) 790 + unsigned int duration, 791 + enum ieee80211_roc_type type) 791 792 { 792 793 int ret; 793 794 794 795 might_sleep(); 795 796 796 - trace_drv_remain_on_channel(local, sdata, chan, duration); 797 + trace_drv_remain_on_channel(local, sdata, chan, duration, type); 797 798 ret = local->ops->remain_on_channel(&local->hw, &sdata->vif, 798 - chan, duration); 799 + chan, duration, type); 799 800 trace_drv_return_int(local, ret); 800 801 801 802 return ret;
+25 -27
net/mac80211/ht.c
··· 40 40 if (!ht_cap->ht_supported) 41 41 return; 42 42 43 - if (sdata->vif.type != NL80211_IFTYPE_STATION) { 44 - /* AP interfaces call this code when adding new stations, 45 - * so just silently ignore non station interfaces. 46 - */ 47 - return; 48 - } 49 - 50 43 /* NOTE: If you add more over-rides here, update register_hw 51 44 * ht_capa_mod_msk logic in main.c as well. 52 45 * And, if this method can ever change ht_cap.ht_supported, fix ··· 90 97 const struct ieee80211_ht_cap *ht_cap_ie, 91 98 struct sta_info *sta) 92 99 { 93 - struct ieee80211_sta_ht_cap ht_cap; 100 + struct ieee80211_sta_ht_cap ht_cap, own_cap; 94 101 u8 ampdu_info, tx_mcs_set_cap; 95 102 int i, max_tx_streams; 96 103 bool changed; ··· 104 111 105 112 ht_cap.ht_supported = true; 106 113 114 + own_cap = sband->ht_cap; 115 + 116 + /* 117 + * If user has specified capability over-rides, take care 118 + * of that if the station we're setting up is the AP that 119 + * we advertised a restricted capability set to. Override 120 + * our own capabilities and then use those below. 121 + */ 122 + if (sdata->vif.type == NL80211_IFTYPE_STATION && 123 + !test_sta_flag(sta, WLAN_STA_TDLS_PEER)) 124 + ieee80211_apply_htcap_overrides(sdata, &own_cap); 125 + 107 126 /* 108 127 * The bits listed in this expression should be 109 128 * the same for the peer and us, if the station ··· 123 118 * we mask them out. 124 119 */ 125 120 ht_cap.cap = le16_to_cpu(ht_cap_ie->cap_info) & 126 - (sband->ht_cap.cap | 127 - ~(IEEE80211_HT_CAP_LDPC_CODING | 128 - IEEE80211_HT_CAP_SUP_WIDTH_20_40 | 129 - IEEE80211_HT_CAP_GRN_FLD | 130 - IEEE80211_HT_CAP_SGI_20 | 131 - IEEE80211_HT_CAP_SGI_40 | 132 - IEEE80211_HT_CAP_DSSSCCK40)); 121 + (own_cap.cap | ~(IEEE80211_HT_CAP_LDPC_CODING | 122 + IEEE80211_HT_CAP_SUP_WIDTH_20_40 | 123 + IEEE80211_HT_CAP_GRN_FLD | 124 + IEEE80211_HT_CAP_SGI_20 | 125 + IEEE80211_HT_CAP_SGI_40 | 126 + IEEE80211_HT_CAP_DSSSCCK40)); 133 127 134 128 /* 135 129 * The STBC bits are asymmetric -- if we don't have 136 130 * TX then mask out the peer's RX and vice versa. 137 131 */ 138 - if (!(sband->ht_cap.cap & IEEE80211_HT_CAP_TX_STBC)) 132 + if (!(own_cap.cap & IEEE80211_HT_CAP_TX_STBC)) 139 133 ht_cap.cap &= ~IEEE80211_HT_CAP_RX_STBC; 140 - if (!(sband->ht_cap.cap & IEEE80211_HT_CAP_RX_STBC)) 134 + if (!(own_cap.cap & IEEE80211_HT_CAP_RX_STBC)) 141 135 ht_cap.cap &= ~IEEE80211_HT_CAP_TX_STBC; 142 136 143 137 ampdu_info = ht_cap_ie->ampdu_params_info; ··· 146 142 (ampdu_info & IEEE80211_HT_AMPDU_PARM_DENSITY) >> 2; 147 143 148 144 /* own MCS TX capabilities */ 149 - tx_mcs_set_cap = sband->ht_cap.mcs.tx_params; 145 + tx_mcs_set_cap = own_cap.mcs.tx_params; 150 146 151 147 /* Copy peer MCS TX capabilities, the driver might need them. */ 152 148 ht_cap.mcs.tx_params = ht_cap_ie->mcs.tx_params; ··· 172 168 */ 173 169 for (i = 0; i < max_tx_streams; i++) 174 170 ht_cap.mcs.rx_mask[i] = 175 - sband->ht_cap.mcs.rx_mask[i] & ht_cap_ie->mcs.rx_mask[i]; 171 + own_cap.mcs.rx_mask[i] & ht_cap_ie->mcs.rx_mask[i]; 176 172 177 173 if (tx_mcs_set_cap & IEEE80211_HT_MCS_TX_UNEQUAL_MODULATION) 178 174 for (i = IEEE80211_HT_MCS_UNEQUAL_MODULATION_START_BYTE; 179 175 i < IEEE80211_HT_MCS_MASK_LEN; i++) 180 176 ht_cap.mcs.rx_mask[i] = 181 - sband->ht_cap.mcs.rx_mask[i] & 177 + own_cap.mcs.rx_mask[i] & 182 178 ht_cap_ie->mcs.rx_mask[i]; 183 179 184 180 /* handle MCS rate 32 too */ 185 - if (sband->ht_cap.mcs.rx_mask[32/8] & ht_cap_ie->mcs.rx_mask[32/8] & 1) 181 + if (own_cap.mcs.rx_mask[32/8] & ht_cap_ie->mcs.rx_mask[32/8] & 1) 186 182 ht_cap.mcs.rx_mask[32/8] |= 1; 187 183 188 184 apply: 189 - /* 190 - * If user has specified capability over-rides, take care 191 - * of that here. 192 - */ 193 - ieee80211_apply_htcap_overrides(sdata, &ht_cap); 194 - 195 185 changed = memcmp(&sta->sta.ht_cap, &ht_cap, sizeof(ht_cap)); 196 186 197 187 memcpy(&sta->sta.ht_cap, &ht_cap, sizeof(ht_cap));
+1 -28
net/mac80211/ibss.c
··· 985 985 { 986 986 struct ieee80211_sub_if_data *sdata = 987 987 (struct ieee80211_sub_if_data *) data; 988 - struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 989 - struct ieee80211_local *local = sdata->local; 990 988 991 - if (local->quiescing) { 992 - ifibss->timer_running = true; 993 - return; 994 - } 995 - 996 - ieee80211_queue_work(&local->hw, &sdata->work); 989 + ieee80211_queue_work(&sdata->local->hw, &sdata->work); 997 990 } 998 - 999 - #ifdef CONFIG_PM 1000 - void ieee80211_ibss_quiesce(struct ieee80211_sub_if_data *sdata) 1001 - { 1002 - struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 1003 - 1004 - if (del_timer_sync(&ifibss->timer)) 1005 - ifibss->timer_running = true; 1006 - } 1007 - 1008 - void ieee80211_ibss_restart(struct ieee80211_sub_if_data *sdata) 1009 - { 1010 - struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 1011 - 1012 - if (ifibss->timer_running) { 1013 - add_timer(&ifibss->timer); 1014 - ifibss->timer_running = false; 1015 - } 1016 - } 1017 - #endif 1018 991 1019 992 void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata) 1020 993 {
+8 -18
net/mac80211/ieee80211_i.h
··· 315 315 u32 duration, req_duration; 316 316 struct sk_buff *frame; 317 317 u64 cookie, mgmt_tx_cookie; 318 + enum ieee80211_roc_type type; 318 319 }; 319 320 320 321 /* flags used in struct ieee80211_if_managed.flags */ ··· 401 400 402 401 u16 aid; 403 402 404 - unsigned long timers_running; /* used for quiesce/restart */ 405 403 bool powersave; /* powersave requested for this iface */ 406 404 bool broken_ap; /* AP is broken -- turn off powersave */ 407 405 u8 dtim_period; ··· 479 479 480 480 struct ieee80211_ht_cap ht_capa; /* configured ht-cap over-rides */ 481 481 struct ieee80211_ht_cap ht_capa_mask; /* Valid parts of ht_capa */ 482 + struct ieee80211_vht_cap vht_capa; /* configured VHT overrides */ 483 + struct ieee80211_vht_cap vht_capa_mask; /* Valid parts of vht_capa */ 482 484 }; 483 485 484 486 struct ieee80211_if_ibss { ··· 491 489 unsigned long last_scan_completed; 492 490 493 491 u32 basic_rates; 494 - 495 - bool timer_running; 496 492 497 493 bool fixed_bssid; 498 494 bool fixed_channel; ··· 543 543 struct timer_list mesh_path_timer; 544 544 struct timer_list mesh_path_root_timer; 545 545 546 - unsigned long timers_running; 547 - 548 546 unsigned long wrkq_flags; 549 547 550 548 u8 mesh_id[IEEE80211_MAX_MESH_ID_LEN]; ··· 588 590 IEEE80211_MESH_SEC_AUTHED = 0x1, 589 591 IEEE80211_MESH_SEC_SECURED = 0x2, 590 592 } security; 593 + bool user_mpm; 591 594 /* Extensible Synchronization Framework */ 592 595 const struct ieee80211_mesh_sync_ops *sync_ops; 593 596 s64 sync_offset_clockdrift_max; ··· 681 682 682 683 /* count for keys needing tailroom space allocation */ 683 684 int crypto_tx_tailroom_needed_cnt; 685 + int crypto_tx_tailroom_pending_dec; 686 + struct delayed_work dec_tailroom_needed_wk; 684 687 685 688 struct net_device *dev; 686 689 struct ieee80211_local *local; ··· 764 763 struct dentry *default_multicast_key; 765 764 struct dentry *default_mgmt_key; 766 765 } debugfs; 767 - #endif 768 - 769 - #ifdef CONFIG_PM 770 - struct ieee80211_bss_conf suspend_bss_conf; 771 766 #endif 772 767 773 768 /* must be last, dynamically sized area in this! */ ··· 1133 1136 1134 1137 struct ieee80211_sub_if_data __rcu *p2p_sdata; 1135 1138 1136 - /* dummy netdev for use w/ NAPI */ 1137 - struct net_device napi_dev; 1138 - 1139 - struct napi_struct napi; 1140 - 1141 1139 /* virtual monitor interface */ 1142 1140 struct ieee80211_sub_if_data __rcu *monitor_sdata; 1143 1141 struct cfg80211_chan_def monitor_chandef; ··· 1275 1283 ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, 1276 1284 const struct ieee80211_channel_sw_ie *sw_elem, 1277 1285 struct ieee80211_bss *bss, u64 timestamp); 1278 - void ieee80211_sta_quiesce(struct ieee80211_sub_if_data *sdata); 1279 - void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata); 1280 1286 void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata); 1281 1287 void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, 1282 1288 struct sk_buff *skb); ··· 1292 1302 int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, 1293 1303 struct cfg80211_ibss_params *params); 1294 1304 int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata); 1295 - void ieee80211_ibss_quiesce(struct ieee80211_sub_if_data *sdata); 1296 - void ieee80211_ibss_restart(struct ieee80211_sub_if_data *sdata); 1297 1305 void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata); 1298 1306 void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, 1299 1307 struct sk_buff *skb); ··· 1429 1441 void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata, 1430 1442 struct sta_info *sta, u8 opmode, 1431 1443 enum ieee80211_band band, bool nss_only); 1444 + void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata, 1445 + struct ieee80211_sta_vht_cap *vht_cap); 1432 1446 1433 1447 /* Spectrum management */ 1434 1448 void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
+14 -8
net/mac80211/iface.c
··· 107 107 108 108 lockdep_assert_held(&local->mtx); 109 109 110 - active = !list_empty(&local->chanctx_list); 110 + active = !list_empty(&local->chanctx_list) || local->monitors; 111 111 112 112 if (!local->ops->remain_on_channel) { 113 113 list_for_each_entry(roc, &local->roc_list, list) { ··· 485 485 res = drv_start(local); 486 486 if (res) 487 487 goto err_del_bss; 488 - if (local->ops->napi_poll) 489 - napi_enable(&local->napi); 490 488 /* we're brought up, everything changes */ 491 489 hw_reconf_flags = ~0; 492 490 ieee80211_led_radio(local, true); ··· 539 541 540 542 ieee80211_adjust_monitor_flags(sdata, 1); 541 543 ieee80211_configure_filter(local); 544 + mutex_lock(&local->mtx); 545 + ieee80211_recalc_idle(local); 546 + mutex_unlock(&local->mtx); 542 547 543 548 netif_carrier_on(dev); 544 549 break; ··· 813 812 814 813 ieee80211_adjust_monitor_flags(sdata, -1); 815 814 ieee80211_configure_filter(local); 815 + mutex_lock(&local->mtx); 816 + ieee80211_recalc_idle(local); 817 + mutex_unlock(&local->mtx); 816 818 break; 817 819 case NL80211_IFTYPE_P2P_DEVICE: 818 820 /* relies on synchronize_rcu() below */ ··· 836 832 rcu_barrier(); 837 833 sta_info_flush_cleanup(sdata); 838 834 839 - skb_queue_purge(&sdata->skb_queue); 840 - 841 835 /* 842 836 * Free all remaining keys, there shouldn't be any, 843 - * except maybe group keys in AP more or WDS? 837 + * except maybe in WDS mode? 844 838 */ 845 839 ieee80211_free_keys(sdata); 840 + 841 + /* fall through */ 842 + case NL80211_IFTYPE_AP: 843 + skb_queue_purge(&sdata->skb_queue); 846 844 847 845 drv_remove_interface_debugfs(local, sdata); 848 846 ··· 857 851 ieee80211_recalc_ps(local, -1); 858 852 859 853 if (local->open_count == 0) { 860 - if (local->ops->napi_poll) 861 - napi_disable(&local->napi); 862 854 ieee80211_clear_tx_pending(local); 863 855 ieee80211_stop_device(local); 864 856 ··· 1545 1541 INIT_WORK(&sdata->cleanup_stations_wk, ieee80211_cleanup_sdata_stas_wk); 1546 1542 INIT_DELAYED_WORK(&sdata->dfs_cac_timer_work, 1547 1543 ieee80211_dfs_cac_timer_work); 1544 + INIT_DELAYED_WORK(&sdata->dec_tailroom_needed_wk, 1545 + ieee80211_delayed_tailroom_dec); 1548 1546 1549 1547 for (i = 0; i < IEEE80211_NUM_BANDS; i++) { 1550 1548 struct ieee80211_supported_band *sband;
+56 -47
net/mac80211/key.c
··· 397 397 return key; 398 398 } 399 399 400 - static void __ieee80211_key_destroy(struct ieee80211_key *key) 400 + static void __ieee80211_key_destroy(struct ieee80211_key *key, 401 + bool delay_tailroom) 401 402 { 402 403 if (!key) 403 404 return; ··· 417 416 if (key->conf.cipher == WLAN_CIPHER_SUITE_AES_CMAC) 418 417 ieee80211_aes_cmac_key_free(key->u.aes_cmac.tfm); 419 418 if (key->local) { 419 + struct ieee80211_sub_if_data *sdata = key->sdata; 420 + 420 421 ieee80211_debugfs_key_remove(key); 421 - key->sdata->crypto_tx_tailroom_needed_cnt--; 422 + 423 + if (delay_tailroom) { 424 + /* see ieee80211_delayed_tailroom_dec */ 425 + sdata->crypto_tx_tailroom_pending_dec++; 426 + schedule_delayed_work(&sdata->dec_tailroom_needed_wk, 427 + HZ/2); 428 + } else { 429 + sdata->crypto_tx_tailroom_needed_cnt--; 430 + } 422 431 } 423 432 424 433 kfree(key); ··· 451 440 key->sdata = sdata; 452 441 key->sta = sta; 453 442 454 - if (sta) { 455 - /* 456 - * some hardware cannot handle TKIP with QoS, so 457 - * we indicate whether QoS could be in use. 458 - */ 459 - if (test_sta_flag(sta, WLAN_STA_WME)) 460 - key->conf.flags |= IEEE80211_KEY_FLAG_WMM_STA; 461 - } else { 462 - if (sdata->vif.type == NL80211_IFTYPE_STATION) { 463 - struct sta_info *ap; 464 - 465 - /* 466 - * We're getting a sta pointer in, so must be under 467 - * appropriate locking for sta_info_get(). 468 - */ 469 - 470 - /* same here, the AP could be using QoS */ 471 - ap = sta_info_get(key->sdata, key->sdata->u.mgd.bssid); 472 - if (ap) { 473 - if (test_sta_flag(ap, WLAN_STA_WME)) 474 - key->conf.flags |= 475 - IEEE80211_KEY_FLAG_WMM_STA; 476 - } 477 - } 478 - } 479 - 480 443 mutex_lock(&sdata->local->key_mtx); 481 444 482 445 if (sta && pairwise) ··· 463 478 increment_tailroom_need_count(sdata); 464 479 465 480 __ieee80211_key_replace(sdata, sta, pairwise, old_key, key); 466 - __ieee80211_key_destroy(old_key); 481 + __ieee80211_key_destroy(old_key, true); 467 482 468 483 ieee80211_debugfs_key_add(key); 469 484 ··· 474 489 return ret; 475 490 } 476 491 477 - void __ieee80211_key_free(struct ieee80211_key *key) 492 + void __ieee80211_key_free(struct ieee80211_key *key, bool delay_tailroom) 478 493 { 479 494 if (!key) 480 495 return; ··· 486 501 __ieee80211_key_replace(key->sdata, key->sta, 487 502 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, 488 503 key, NULL); 489 - __ieee80211_key_destroy(key); 504 + __ieee80211_key_destroy(key, delay_tailroom); 490 505 } 491 506 492 507 void ieee80211_key_free(struct ieee80211_local *local, 493 508 struct ieee80211_key *key) 494 509 { 495 510 mutex_lock(&local->key_mtx); 496 - __ieee80211_key_free(key); 511 + __ieee80211_key_free(key, true); 497 512 mutex_unlock(&local->key_mtx); 498 513 } 499 514 ··· 551 566 } 552 567 EXPORT_SYMBOL(ieee80211_iter_keys); 553 568 554 - void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata) 555 - { 556 - struct ieee80211_key *key; 557 - 558 - ASSERT_RTNL(); 559 - 560 - mutex_lock(&sdata->local->key_mtx); 561 - 562 - list_for_each_entry(key, &sdata->key_list, list) 563 - ieee80211_key_disable_hw_accel(key); 564 - 565 - mutex_unlock(&sdata->local->key_mtx); 566 - } 567 - 568 569 void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata) 569 570 { 570 571 struct ieee80211_key *key, *tmp; 571 572 573 + cancel_delayed_work_sync(&sdata->dec_tailroom_needed_wk); 574 + 572 575 mutex_lock(&sdata->local->key_mtx); 576 + 577 + sdata->crypto_tx_tailroom_needed_cnt -= 578 + sdata->crypto_tx_tailroom_pending_dec; 579 + sdata->crypto_tx_tailroom_pending_dec = 0; 573 580 574 581 ieee80211_debugfs_key_remove_mgmt_default(sdata); 575 582 576 583 list_for_each_entry_safe(key, tmp, &sdata->key_list, list) 577 - __ieee80211_key_free(key); 584 + __ieee80211_key_free(key, false); 578 585 579 586 ieee80211_debugfs_key_update_default(sdata); 587 + 588 + WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt || 589 + sdata->crypto_tx_tailroom_pending_dec); 580 590 581 591 mutex_unlock(&sdata->local->key_mtx); 582 592 } 583 593 594 + void ieee80211_delayed_tailroom_dec(struct work_struct *wk) 595 + { 596 + struct ieee80211_sub_if_data *sdata; 597 + 598 + sdata = container_of(wk, struct ieee80211_sub_if_data, 599 + dec_tailroom_needed_wk.work); 600 + 601 + /* 602 + * The reason for the delayed tailroom needed decrementing is to 603 + * make roaming faster: during roaming, all keys are first deleted 604 + * and then new keys are installed. The first new key causes the 605 + * crypto_tx_tailroom_needed_cnt to go from 0 to 1, which invokes 606 + * the cost of synchronize_net() (which can be slow). Avoid this 607 + * by deferring the crypto_tx_tailroom_needed_cnt decrementing on 608 + * key removal for a while, so if we roam the value is larger than 609 + * zero and no 0->1 transition happens. 610 + * 611 + * The cost is that if the AP switching was from an AP with keys 612 + * to one without, we still allocate tailroom while it would no 613 + * longer be needed. However, in the typical (fast) roaming case 614 + * within an ESS this usually won't happen. 615 + */ 616 + 617 + mutex_lock(&sdata->local->key_mtx); 618 + sdata->crypto_tx_tailroom_needed_cnt -= 619 + sdata->crypto_tx_tailroom_pending_dec; 620 + sdata->crypto_tx_tailroom_pending_dec = 0; 621 + mutex_unlock(&sdata->local->key_mtx); 622 + } 584 623 585 624 void ieee80211_gtk_rekey_notify(struct ieee80211_vif *vif, const u8 *bssid, 586 625 const u8 *replay_ctr, gfp_t gfp)
+3 -2
net/mac80211/key.h
··· 134 134 int __must_check ieee80211_key_link(struct ieee80211_key *key, 135 135 struct ieee80211_sub_if_data *sdata, 136 136 struct sta_info *sta); 137 - void __ieee80211_key_free(struct ieee80211_key *key); 137 + void __ieee80211_key_free(struct ieee80211_key *key, bool delay_tailroom); 138 138 void ieee80211_key_free(struct ieee80211_local *local, 139 139 struct ieee80211_key *key); 140 140 void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx, ··· 143 143 int idx); 144 144 void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata); 145 145 void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata); 146 - void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata); 147 146 148 147 #define key_mtx_dereference(local, ref) \ 149 148 rcu_dereference_protected(ref, lockdep_is_held(&((local)->key_mtx))) 149 + 150 + void ieee80211_delayed_tailroom_dec(struct work_struct *wk); 150 151 151 152 #endif /* IEEE80211_KEY_H */
+24 -31
net/mac80211/main.c
··· 399 399 } 400 400 #endif 401 401 402 - static int ieee80211_napi_poll(struct napi_struct *napi, int budget) 403 - { 404 - struct ieee80211_local *local = 405 - container_of(napi, struct ieee80211_local, napi); 406 - 407 - return local->ops->napi_poll(&local->hw, budget); 408 - } 409 - 410 - void ieee80211_napi_schedule(struct ieee80211_hw *hw) 411 - { 412 - struct ieee80211_local *local = hw_to_local(hw); 413 - 414 - napi_schedule(&local->napi); 415 - } 416 - EXPORT_SYMBOL(ieee80211_napi_schedule); 417 - 418 - void ieee80211_napi_complete(struct ieee80211_hw *hw) 419 - { 420 - struct ieee80211_local *local = hw_to_local(hw); 421 - 422 - napi_complete(&local->napi); 423 - } 424 - EXPORT_SYMBOL(ieee80211_napi_complete); 425 - 426 402 /* There isn't a lot of sense in it, but you can transmit anything you like */ 427 403 static const struct ieee80211_txrx_stypes 428 404 ieee80211_default_mgmt_stypes[NUM_NL80211_IFTYPES] = { ··· 477 501 }, 478 502 }; 479 503 504 + static const struct ieee80211_vht_cap mac80211_vht_capa_mod_mask = { 505 + .vht_cap_info = 506 + cpu_to_le32(IEEE80211_VHT_CAP_RXLDPC | 507 + IEEE80211_VHT_CAP_SHORT_GI_80 | 508 + IEEE80211_VHT_CAP_SHORT_GI_160 | 509 + IEEE80211_VHT_CAP_RXSTBC_1 | 510 + IEEE80211_VHT_CAP_RXSTBC_2 | 511 + IEEE80211_VHT_CAP_RXSTBC_3 | 512 + IEEE80211_VHT_CAP_RXSTBC_4 | 513 + IEEE80211_VHT_CAP_TXSTBC | 514 + IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE | 515 + IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE | 516 + IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN | 517 + IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN | 518 + IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK), 519 + .supp_mcs = { 520 + .rx_mcs_map = cpu_to_le16(~0), 521 + .tx_mcs_map = cpu_to_le16(~0), 522 + }, 523 + }; 524 + 480 525 static const u8 extended_capabilities[] = { 481 526 0, 0, 0, 0, 0, 0, 0, 482 527 WLAN_EXT_CAPA8_OPMODE_NOTIF, ··· 569 572 wiphy->features |= NL80211_FEATURE_SK_TX_STATUS | 570 573 NL80211_FEATURE_SAE | 571 574 NL80211_FEATURE_HT_IBSS | 572 - NL80211_FEATURE_VIF_TXPOWER; 575 + NL80211_FEATURE_VIF_TXPOWER | 576 + NL80211_FEATURE_USERSPACE_MPM; 573 577 574 578 if (!ops->hw_scan) 575 579 wiphy->features |= NL80211_FEATURE_LOW_PRIORITY_SCAN | ··· 607 609 IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH; 608 610 local->user_power_level = IEEE80211_UNSET_POWER_LEVEL; 609 611 wiphy->ht_capa_mod_mask = &mac80211_ht_capa_mod_mask; 612 + wiphy->vht_capa_mod_mask = &mac80211_vht_capa_mod_mask; 610 613 611 614 INIT_LIST_HEAD(&local->interfaces); 612 615 ··· 662 663 663 664 skb_queue_head_init(&local->skb_queue); 664 665 skb_queue_head_init(&local->skb_queue_unreliable); 665 - 666 - /* init dummy netdev for use w/ NAPI */ 667 - init_dummy_netdev(&local->napi_dev); 668 666 669 667 ieee80211_led_names(local); 670 668 ··· 1016 1020 if (result) 1017 1021 goto fail_ifa6; 1018 1022 #endif 1019 - 1020 - netif_napi_add(&local->napi_dev, &local->napi, ieee80211_napi_poll, 1021 - local->hw.napi_weight); 1022 1023 1023 1024 return 0; 1024 1025
+3 -56
net/mac80211/mesh.c
··· 13 13 #include "ieee80211_i.h" 14 14 #include "mesh.h" 15 15 16 - #define TMR_RUNNING_HK 0 17 - #define TMR_RUNNING_MP 1 18 - #define TMR_RUNNING_MPR 2 19 - 20 16 static int mesh_allocated; 21 17 static struct kmem_cache *rm_cache; 22 18 ··· 45 49 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 46 50 47 51 set_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags); 48 - 49 - if (local->quiescing) { 50 - set_bit(TMR_RUNNING_HK, &ifmsh->timers_running); 51 - return; 52 - } 53 52 54 53 ieee80211_queue_work(&local->hw, &sdata->work); 55 54 } ··· 156 165 * an update. 157 166 */ 158 167 changed = mesh_accept_plinks_update(sdata); 159 - if (sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) { 168 + if (!sdata->u.mesh.user_mpm) { 160 169 changed |= mesh_plink_deactivate(sta); 161 170 del_timer_sync(&sta->plink_timer); 162 171 } ··· 470 479 { 471 480 struct ieee80211_sub_if_data *sdata = 472 481 (struct ieee80211_sub_if_data *) data; 473 - struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 474 - struct ieee80211_local *local = sdata->local; 475 482 476 - if (local->quiescing) { 477 - set_bit(TMR_RUNNING_MP, &ifmsh->timers_running); 478 - return; 479 - } 480 - 481 - ieee80211_queue_work(&local->hw, &sdata->work); 483 + ieee80211_queue_work(&sdata->local->hw, &sdata->work); 482 484 } 483 485 484 486 static void ieee80211_mesh_path_root_timer(unsigned long data) ··· 479 495 struct ieee80211_sub_if_data *sdata = 480 496 (struct ieee80211_sub_if_data *) data; 481 497 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 482 - struct ieee80211_local *local = sdata->local; 483 498 484 499 set_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags); 485 500 486 - if (local->quiescing) { 487 - set_bit(TMR_RUNNING_MPR, &ifmsh->timers_running); 488 - return; 489 - } 490 - 491 - ieee80211_queue_work(&local->hw, &sdata->work); 501 + ieee80211_queue_work(&sdata->local->hw, &sdata->work); 492 502 } 493 503 494 504 void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh) ··· 599 621 mod_timer(&ifmsh->mesh_path_root_timer, 600 622 round_jiffies(TU_TO_EXP_TIME(interval))); 601 623 } 602 - 603 - #ifdef CONFIG_PM 604 - void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata) 605 - { 606 - struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 607 - 608 - /* use atomic bitops in case all timers fire at the same time */ 609 - 610 - if (del_timer_sync(&ifmsh->housekeeping_timer)) 611 - set_bit(TMR_RUNNING_HK, &ifmsh->timers_running); 612 - if (del_timer_sync(&ifmsh->mesh_path_timer)) 613 - set_bit(TMR_RUNNING_MP, &ifmsh->timers_running); 614 - if (del_timer_sync(&ifmsh->mesh_path_root_timer)) 615 - set_bit(TMR_RUNNING_MPR, &ifmsh->timers_running); 616 - } 617 - 618 - void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) 619 - { 620 - struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 621 - 622 - if (test_and_clear_bit(TMR_RUNNING_HK, &ifmsh->timers_running)) 623 - add_timer(&ifmsh->housekeeping_timer); 624 - if (test_and_clear_bit(TMR_RUNNING_MP, &ifmsh->timers_running)) 625 - add_timer(&ifmsh->mesh_path_timer); 626 - if (test_and_clear_bit(TMR_RUNNING_MPR, &ifmsh->timers_running)) 627 - add_timer(&ifmsh->mesh_path_root_timer); 628 - ieee80211_mesh_root_setup(ifmsh); 629 - } 630 - #endif 631 624 632 625 static int 633 626 ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh) ··· 820 871 local->fif_other_bss--; 821 872 atomic_dec(&local->iff_allmultis); 822 873 ieee80211_configure_filter(local); 823 - 824 - sdata->u.mesh.timers_running = 0; 825 874 } 826 875 827 876 static void
-12
net/mac80211/mesh.h
··· 313 313 void mesh_path_flush_by_nexthop(struct sta_info *sta); 314 314 void mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata, 315 315 struct sk_buff *skb); 316 - void mesh_path_quiesce(struct ieee80211_sub_if_data *sdata); 317 - void mesh_path_restart(struct ieee80211_sub_if_data *sdata); 318 316 void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata); 319 317 320 318 bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt); ··· 357 359 358 360 void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local); 359 361 360 - void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata); 361 - void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata); 362 - void mesh_plink_quiesce(struct sta_info *sta); 363 - void mesh_plink_restart(struct sta_info *sta); 364 362 void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata); 365 363 void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata); 366 364 void ieee80211s_stop(void); 367 365 #else 368 366 static inline void 369 367 ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local) {} 370 - static inline void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata) 371 - {} 372 - static inline void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) 373 - {} 374 - static inline void mesh_plink_quiesce(struct sta_info *sta) {} 375 - static inline void mesh_plink_restart(struct sta_info *sta) {} 376 368 static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata) 377 369 { return false; } 378 370 static inline void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata)
+8 -29
net/mac80211/mesh_plink.c
··· 420 420 return NULL; 421 421 422 422 sta->plink_state = NL80211_PLINK_LISTEN; 423 - init_timer(&sta->plink_timer); 424 423 425 424 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); 426 425 sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); ··· 436 437 { 437 438 struct sta_info *sta = NULL; 438 439 439 - /* Userspace handles peer allocation when security is enabled */ 440 - if (sdata->u.mesh.security & IEEE80211_MESH_SEC_AUTHED) 440 + /* Userspace handles station allocation */ 441 + if (sdata->u.mesh.user_mpm || 442 + sdata->u.mesh.security & IEEE80211_MESH_SEC_AUTHED) 441 443 cfg80211_notify_new_peer_candidate(sdata->dev, addr, 442 444 elems->ie_start, 443 445 elems->total_len, ··· 534 534 */ 535 535 sta = (struct sta_info *) data; 536 536 537 - if (sta->sdata->local->quiescing) { 538 - sta->plink_timer_was_running = true; 537 + if (sta->sdata->local->quiescing) 539 538 return; 540 - } 541 539 542 540 spin_lock_bh(&sta->lock); 543 541 if (sta->ignore_plink_timer) { ··· 595 597 break; 596 598 } 597 599 } 598 - 599 - #ifdef CONFIG_PM 600 - void mesh_plink_quiesce(struct sta_info *sta) 601 - { 602 - if (!ieee80211_vif_is_mesh(&sta->sdata->vif)) 603 - return; 604 - 605 - /* no kernel mesh sta timers have been initialized */ 606 - if (sta->sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE) 607 - return; 608 - 609 - if (del_timer_sync(&sta->plink_timer)) 610 - sta->plink_timer_was_running = true; 611 - } 612 - 613 - void mesh_plink_restart(struct sta_info *sta) 614 - { 615 - if (sta->plink_timer_was_running) { 616 - add_timer(&sta->plink_timer); 617 - sta->plink_timer_was_running = false; 618 - } 619 - } 620 - #endif 621 600 622 601 static inline void mesh_plink_timer_set(struct sta_info *sta, int timeout) 623 602 { ··· 668 693 669 694 /* need action_code, aux */ 670 695 if (len < IEEE80211_MIN_ACTION_SIZE + 3) 696 + return; 697 + 698 + if (sdata->u.mesh.user_mpm) 699 + /* userspace must register for these */ 671 700 return; 672 701 673 702 if (is_multicast_ether_addr(mgmt->da)) {
+27 -83
net/mac80211/mlme.c
··· 87 87 */ 88 88 #define IEEE80211_SIGNAL_AVE_MIN_COUNT 4 89 89 90 - #define TMR_RUNNING_TIMER 0 91 - #define TMR_RUNNING_CHANSW 1 92 - 93 90 /* 94 91 * All cfg80211 functions have to be called outside a locked 95 92 * section so that they can acquire a lock themselves... This ··· 606 609 BUILD_BUG_ON(sizeof(vht_cap) != sizeof(sband->vht_cap)); 607 610 608 611 memcpy(&vht_cap, &sband->vht_cap, sizeof(vht_cap)); 612 + ieee80211_apply_vhtcap_overrides(sdata, &vht_cap); 609 613 610 614 /* determine capability flags */ 611 615 cap = vht_cap.cap; ··· 644 646 mask) >> shift; 645 647 our_mcs = (le16_to_cpu(vht_cap.vht_mcs.rx_mcs_map) & 646 648 mask) >> shift; 649 + 650 + if (our_mcs == IEEE80211_VHT_MCS_NOT_SUPPORTED) 651 + continue; 647 652 648 653 switch (ap_mcs) { 649 654 default: ··· 1036 1035 { 1037 1036 struct ieee80211_sub_if_data *sdata = 1038 1037 (struct ieee80211_sub_if_data *) data; 1039 - struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1040 1038 1041 - if (sdata->local->quiescing) { 1042 - set_bit(TMR_RUNNING_CHANSW, &ifmgd->timers_running); 1043 - return; 1044 - } 1045 - 1046 - ieee80211_queue_work(&sdata->local->hw, &ifmgd->chswitch_work); 1039 + ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.chswitch_work); 1047 1040 } 1048 1041 1049 1042 void ··· 1794 1799 sdata->vif.bss_conf.p2p_ctwindow = 0; 1795 1800 sdata->vif.bss_conf.p2p_oppps = false; 1796 1801 1797 - /* on the next assoc, re-program HT parameters */ 1802 + /* on the next assoc, re-program HT/VHT parameters */ 1798 1803 memset(&ifmgd->ht_capa, 0, sizeof(ifmgd->ht_capa)); 1799 1804 memset(&ifmgd->ht_capa_mask, 0, sizeof(ifmgd->ht_capa_mask)); 1805 + memset(&ifmgd->vht_capa, 0, sizeof(ifmgd->vht_capa)); 1806 + memset(&ifmgd->vht_capa_mask, 0, sizeof(ifmgd->vht_capa_mask)); 1800 1807 1801 1808 sdata->ap_power_level = IEEE80211_UNSET_POWER_LEVEL; 1802 1809 ··· 1823 1826 del_timer_sync(&sdata->u.mgd.bcn_mon_timer); 1824 1827 del_timer_sync(&sdata->u.mgd.timer); 1825 1828 del_timer_sync(&sdata->u.mgd.chswitch_timer); 1826 - 1827 - sdata->u.mgd.timers_running = 0; 1828 1829 1829 1830 sdata->vif.bss_conf.dtim_period = 0; 1830 1831 ··· 3132 3137 { 3133 3138 struct ieee80211_sub_if_data *sdata = 3134 3139 (struct ieee80211_sub_if_data *) data; 3135 - struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 3136 - struct ieee80211_local *local = sdata->local; 3137 3140 3138 - if (local->quiescing) { 3139 - set_bit(TMR_RUNNING_TIMER, &ifmgd->timers_running); 3140 - return; 3141 - } 3142 - 3143 - ieee80211_queue_work(&local->hw, &sdata->work); 3141 + ieee80211_queue_work(&sdata->local->hw, &sdata->work); 3144 3142 } 3145 3143 3146 3144 static void ieee80211_sta_connection_lost(struct ieee80211_sub_if_data *sdata, ··· 3484 3496 ieee80211_queue_work(&sdata->local->hw, &sdata->work); 3485 3497 } 3486 3498 } 3487 - 3488 - #ifdef CONFIG_PM 3489 - void ieee80211_sta_quiesce(struct ieee80211_sub_if_data *sdata) 3490 - { 3491 - struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 3492 - 3493 - /* 3494 - * we need to use atomic bitops for the running bits 3495 - * only because both timers might fire at the same 3496 - * time -- the code here is properly synchronised. 3497 - */ 3498 - 3499 - cancel_work_sync(&ifmgd->request_smps_work); 3500 - 3501 - cancel_work_sync(&ifmgd->monitor_work); 3502 - cancel_work_sync(&ifmgd->beacon_connection_loss_work); 3503 - cancel_work_sync(&ifmgd->csa_connection_drop_work); 3504 - if (del_timer_sync(&ifmgd->timer)) 3505 - set_bit(TMR_RUNNING_TIMER, &ifmgd->timers_running); 3506 - 3507 - cancel_work_sync(&ifmgd->chswitch_work); 3508 - if (del_timer_sync(&ifmgd->chswitch_timer)) 3509 - set_bit(TMR_RUNNING_CHANSW, &ifmgd->timers_running); 3510 - 3511 - /* these will just be re-established on connection */ 3512 - del_timer_sync(&ifmgd->conn_mon_timer); 3513 - del_timer_sync(&ifmgd->bcn_mon_timer); 3514 - } 3515 - 3516 - void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata) 3517 - { 3518 - struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 3519 - 3520 - mutex_lock(&ifmgd->mtx); 3521 - if (!ifmgd->associated) { 3522 - mutex_unlock(&ifmgd->mtx); 3523 - return; 3524 - } 3525 - 3526 - if (sdata->flags & IEEE80211_SDATA_DISCONNECT_RESUME) { 3527 - sdata->flags &= ~IEEE80211_SDATA_DISCONNECT_RESUME; 3528 - mlme_dbg(sdata, "driver requested disconnect after resume\n"); 3529 - ieee80211_sta_connection_lost(sdata, 3530 - ifmgd->associated->bssid, 3531 - WLAN_REASON_UNSPECIFIED, 3532 - true); 3533 - mutex_unlock(&ifmgd->mtx); 3534 - return; 3535 - } 3536 - mutex_unlock(&ifmgd->mtx); 3537 - 3538 - if (test_and_clear_bit(TMR_RUNNING_TIMER, &ifmgd->timers_running)) 3539 - add_timer(&ifmgd->timer); 3540 - if (test_and_clear_bit(TMR_RUNNING_CHANSW, &ifmgd->timers_running)) 3541 - add_timer(&ifmgd->chswitch_timer); 3542 - ieee80211_sta_reset_beacon_monitor(sdata); 3543 - 3544 - mutex_lock(&sdata->local->mtx); 3545 - ieee80211_restart_sta_timer(sdata); 3546 - mutex_unlock(&sdata->local->mtx); 3547 - } 3548 - #endif 3549 3499 3550 3500 /* interface setup */ 3551 3501 void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata) ··· 3990 4064 ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; 3991 4065 } 3992 4066 4067 + if (req->flags & ASSOC_REQ_DISABLE_VHT) 4068 + ifmgd->flags |= IEEE80211_STA_DISABLE_VHT; 4069 + 3993 4070 /* Also disable HT if we don't support it or the AP doesn't use WMM */ 3994 4071 sband = local->hw.wiphy->bands[req->bss->channel->band]; 3995 4072 if (!sband->ht_cap.ht_supported || ··· 4015 4086 memcpy(&ifmgd->ht_capa, &req->ht_capa, sizeof(ifmgd->ht_capa)); 4016 4087 memcpy(&ifmgd->ht_capa_mask, &req->ht_capa_mask, 4017 4088 sizeof(ifmgd->ht_capa_mask)); 4089 + 4090 + memcpy(&ifmgd->vht_capa, &req->vht_capa, sizeof(ifmgd->vht_capa)); 4091 + memcpy(&ifmgd->vht_capa_mask, &req->vht_capa_mask, 4092 + sizeof(ifmgd->vht_capa_mask)); 4018 4093 4019 4094 if (req->ie && req->ie_len) { 4020 4095 memcpy(assoc_data->ie, req->ie, req->ie_len); ··· 4247 4314 void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata) 4248 4315 { 4249 4316 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 4317 + 4318 + /* 4319 + * Make sure some work items will not run after this, 4320 + * they will not do anything but might not have been 4321 + * cancelled when disconnecting. 4322 + */ 4323 + cancel_work_sync(&ifmgd->monitor_work); 4324 + cancel_work_sync(&ifmgd->beacon_connection_loss_work); 4325 + cancel_work_sync(&ifmgd->request_smps_work); 4326 + cancel_work_sync(&ifmgd->csa_connection_drop_work); 4327 + cancel_work_sync(&ifmgd->chswitch_work); 4250 4328 4251 4329 mutex_lock(&ifmgd->mtx); 4252 4330 if (ifmgd->assoc_data)
+1 -1
net/mac80211/offchannel.c
··· 277 277 duration = 10; 278 278 279 279 ret = drv_remain_on_channel(local, roc->sdata, roc->chan, 280 - duration); 280 + duration, roc->type); 281 281 282 282 roc->started = true; 283 283
+7 -110
net/mac80211/pm.c
··· 6 6 #include "driver-ops.h" 7 7 #include "led.h" 8 8 9 - /* return value indicates whether the driver should be further notified */ 10 - static void ieee80211_quiesce(struct ieee80211_sub_if_data *sdata) 11 - { 12 - switch (sdata->vif.type) { 13 - case NL80211_IFTYPE_STATION: 14 - ieee80211_sta_quiesce(sdata); 15 - break; 16 - case NL80211_IFTYPE_ADHOC: 17 - ieee80211_ibss_quiesce(sdata); 18 - break; 19 - case NL80211_IFTYPE_MESH_POINT: 20 - ieee80211_mesh_quiesce(sdata); 21 - break; 22 - default: 23 - break; 24 - } 25 - 26 - cancel_work_sync(&sdata->work); 27 - } 28 - 29 9 int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) 30 10 { 31 11 struct ieee80211_local *local = hw_to_local(hw); 32 12 struct ieee80211_sub_if_data *sdata; 33 13 struct sta_info *sta; 34 - struct ieee80211_chanctx *ctx; 35 14 36 15 if (!local->open_count) 37 16 goto suspend; ··· 72 93 return err; 73 94 } else if (err > 0) { 74 95 WARN_ON(err != 1); 75 - local->wowlan = false; 96 + return err; 76 97 } else { 77 - list_for_each_entry(sdata, &local->interfaces, list) 78 - if (ieee80211_sdata_running(sdata)) 79 - ieee80211_quiesce(sdata); 80 98 goto suspend; 81 99 } 82 100 } 83 - 84 - /* disable keys */ 85 - list_for_each_entry(sdata, &local->interfaces, list) 86 - ieee80211_disable_keys(sdata); 87 101 88 102 /* tear down aggregation sessions and remove STAs */ 89 103 mutex_lock(&local->sta_mtx); ··· 89 117 WARN_ON(drv_sta_state(local, sta->sdata, sta, 90 118 state, state - 1)); 91 119 } 92 - 93 - mesh_plink_quiesce(sta); 94 120 } 95 121 mutex_unlock(&local->sta_mtx); 96 122 97 123 /* remove all interfaces */ 98 124 list_for_each_entry(sdata, &local->interfaces, list) { 99 - static u8 zero_addr[ETH_ALEN] = {}; 100 - u32 changed = 0; 101 - 102 125 if (!ieee80211_sdata_running(sdata)) 103 126 continue; 104 - 105 - switch (sdata->vif.type) { 106 - case NL80211_IFTYPE_AP_VLAN: 107 - case NL80211_IFTYPE_MONITOR: 108 - /* skip these */ 109 - continue; 110 - case NL80211_IFTYPE_STATION: 111 - if (sdata->vif.bss_conf.assoc) 112 - changed = BSS_CHANGED_ASSOC | 113 - BSS_CHANGED_BSSID | 114 - BSS_CHANGED_IDLE; 115 - break; 116 - case NL80211_IFTYPE_AP: 117 - case NL80211_IFTYPE_ADHOC: 118 - case NL80211_IFTYPE_MESH_POINT: 119 - if (sdata->vif.bss_conf.enable_beacon) 120 - changed = BSS_CHANGED_BEACON_ENABLED; 121 - break; 122 - default: 123 - break; 124 - } 125 - 126 - ieee80211_quiesce(sdata); 127 - 128 - sdata->suspend_bss_conf = sdata->vif.bss_conf; 129 - memset(&sdata->vif.bss_conf, 0, sizeof(sdata->vif.bss_conf)); 130 - sdata->vif.bss_conf.idle = true; 131 - if (sdata->suspend_bss_conf.bssid) 132 - sdata->vif.bss_conf.bssid = zero_addr; 133 - 134 - /* disable beaconing or remove association */ 135 - ieee80211_bss_info_change_notify(sdata, changed); 136 - 137 - if (sdata->vif.type == NL80211_IFTYPE_AP && 138 - rcu_access_pointer(sdata->u.ap.beacon)) 139 - drv_stop_ap(local, sdata); 140 - 141 - if (local->use_chanctx) { 142 - struct ieee80211_chanctx_conf *conf; 143 - 144 - mutex_lock(&local->chanctx_mtx); 145 - conf = rcu_dereference_protected( 146 - sdata->vif.chanctx_conf, 147 - lockdep_is_held(&local->chanctx_mtx)); 148 - if (conf) { 149 - ctx = container_of(conf, 150 - struct ieee80211_chanctx, 151 - conf); 152 - drv_unassign_vif_chanctx(local, sdata, ctx); 153 - } 154 - 155 - mutex_unlock(&local->chanctx_mtx); 156 - } 157 127 drv_remove_interface(local, sdata); 158 128 } 159 129 160 130 sdata = rtnl_dereference(local->monitor_sdata); 161 - if (sdata) { 162 - if (local->use_chanctx) { 163 - struct ieee80211_chanctx_conf *conf; 164 - 165 - mutex_lock(&local->chanctx_mtx); 166 - conf = rcu_dereference_protected( 167 - sdata->vif.chanctx_conf, 168 - lockdep_is_held(&local->chanctx_mtx)); 169 - if (conf) { 170 - ctx = container_of(conf, 171 - struct ieee80211_chanctx, 172 - conf); 173 - drv_unassign_vif_chanctx(local, sdata, ctx); 174 - } 175 - 176 - mutex_unlock(&local->chanctx_mtx); 177 - } 178 - 131 + if (sdata) 179 132 drv_remove_interface(local, sdata); 180 - } 181 133 182 - mutex_lock(&local->chanctx_mtx); 183 - list_for_each_entry(ctx, &local->chanctx_list, list) 184 - drv_remove_chanctx(local, ctx); 185 - mutex_unlock(&local->chanctx_mtx); 134 + /* 135 + * We disconnected on all interfaces before suspend, all channel 136 + * contexts should be released. 137 + */ 138 + WARN_ON(!list_empty(&local->chanctx_list)); 186 139 187 140 /* stop hardware - this must stop RX */ 188 141 if (local->open_count)
+114 -90
net/mac80211/rc80211_minstrel.c
··· 55 55 #include "rate.h" 56 56 #include "rc80211_minstrel.h" 57 57 58 - #define SAMPLE_COLUMNS 10 59 58 #define SAMPLE_TBL(_mi, _idx, _col) \ 60 59 _mi->sample_table[(_idx * SAMPLE_COLUMNS) + _col] 61 60 ··· 69 70 return i; 70 71 } 71 72 73 + /* find & sort topmost throughput rates */ 74 + static inline void 75 + minstrel_sort_best_tp_rates(struct minstrel_sta_info *mi, int i, u8 *tp_list) 76 + { 77 + int j = MAX_THR_RATES; 78 + 79 + while (j > 0 && mi->r[i].cur_tp > mi->r[tp_list[j - 1]].cur_tp) 80 + j--; 81 + if (j < MAX_THR_RATES - 1) 82 + memmove(&tp_list[j + 1], &tp_list[j], MAX_THR_RATES - (j + 1)); 83 + if (j < MAX_THR_RATES) 84 + tp_list[j] = i; 85 + } 86 + 72 87 static void 73 88 minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi) 74 89 { 75 - u32 max_tp = 0, index_max_tp = 0, index_max_tp2 = 0; 76 - u32 max_prob = 0, index_max_prob = 0; 90 + u8 tmp_tp_rate[MAX_THR_RATES]; 91 + u8 tmp_prob_rate = 0; 77 92 u32 usecs; 78 - u32 p; 79 93 int i; 80 94 81 - mi->stats_update = jiffies; 95 + for (i=0; i < MAX_THR_RATES; i++) 96 + tmp_tp_rate[i] = 0; 97 + 82 98 for (i = 0; i < mi->n_rates; i++) { 83 99 struct minstrel_rate *mr = &mi->r[i]; 84 100 ··· 101 87 if (!usecs) 102 88 usecs = 1000000; 103 89 104 - /* To avoid rounding issues, probabilities scale from 0 (0%) 105 - * to 18000 (100%) */ 106 - if (mr->attempts) { 107 - p = (mr->success * 18000) / mr->attempts; 90 + if (unlikely(mr->attempts > 0)) { 91 + mr->sample_skipped = 0; 92 + mr->cur_prob = MINSTREL_FRAC(mr->success, mr->attempts); 108 93 mr->succ_hist += mr->success; 109 94 mr->att_hist += mr->attempts; 110 - mr->cur_prob = p; 111 - p = ((p * (100 - mp->ewma_level)) + (mr->probability * 112 - mp->ewma_level)) / 100; 113 - mr->probability = p; 114 - mr->cur_tp = p * (1000000 / usecs); 115 - } 95 + mr->probability = minstrel_ewma(mr->probability, 96 + mr->cur_prob, 97 + EWMA_LEVEL); 98 + } else 99 + mr->sample_skipped++; 116 100 117 101 mr->last_success = mr->success; 118 102 mr->last_attempts = mr->attempts; 119 103 mr->success = 0; 120 104 mr->attempts = 0; 121 105 106 + /* Update throughput per rate, reset thr. below 10% success */ 107 + if (mr->probability < MINSTREL_FRAC(10, 100)) 108 + mr->cur_tp = 0; 109 + else 110 + mr->cur_tp = mr->probability * (1000000 / usecs); 111 + 122 112 /* Sample less often below the 10% chance of success. 123 113 * Sample less often above the 95% chance of success. */ 124 - if ((mr->probability > 17100) || (mr->probability < 1800)) { 114 + if (mr->probability > MINSTREL_FRAC(95, 100) || 115 + mr->probability < MINSTREL_FRAC(10, 100)) { 125 116 mr->adjusted_retry_count = mr->retry_count >> 1; 126 117 if (mr->adjusted_retry_count > 2) 127 118 mr->adjusted_retry_count = 2; ··· 137 118 } 138 119 if (!mr->adjusted_retry_count) 139 120 mr->adjusted_retry_count = 2; 140 - } 141 121 142 - for (i = 0; i < mi->n_rates; i++) { 143 - struct minstrel_rate *mr = &mi->r[i]; 144 - if (max_tp < mr->cur_tp) { 145 - index_max_tp = i; 146 - max_tp = mr->cur_tp; 147 - } 148 - if (max_prob < mr->probability) { 149 - index_max_prob = i; 150 - max_prob = mr->probability; 151 - } 152 - } 122 + minstrel_sort_best_tp_rates(mi, i, tmp_tp_rate); 153 123 154 - max_tp = 0; 155 - for (i = 0; i < mi->n_rates; i++) { 156 - struct minstrel_rate *mr = &mi->r[i]; 157 - 158 - if (i == index_max_tp) 159 - continue; 160 - 161 - if (max_tp < mr->cur_tp) { 162 - index_max_tp2 = i; 163 - max_tp = mr->cur_tp; 124 + /* To determine the most robust rate (max_prob_rate) used at 125 + * 3rd mmr stage we distinct between two cases: 126 + * (1) if any success probabilitiy >= 95%, out of those rates 127 + * choose the maximum throughput rate as max_prob_rate 128 + * (2) if all success probabilities < 95%, the rate with 129 + * highest success probability is choosen as max_prob_rate */ 130 + if (mr->probability >= MINSTREL_FRAC(95,100)) { 131 + if (mr->cur_tp >= mi->r[tmp_prob_rate].cur_tp) 132 + tmp_prob_rate = i; 133 + } else { 134 + if (mr->probability >= mi->r[tmp_prob_rate].probability) 135 + tmp_prob_rate = i; 164 136 } 165 137 } 166 - mi->max_tp_rate = index_max_tp; 167 - mi->max_tp_rate2 = index_max_tp2; 168 - mi->max_prob_rate = index_max_prob; 138 + 139 + /* Assign the new rate set */ 140 + memcpy(mi->max_tp_rate, tmp_tp_rate, sizeof(mi->max_tp_rate)); 141 + mi->max_prob_rate = tmp_prob_rate; 142 + 143 + /* Reset update timer */ 144 + mi->stats_update = jiffies; 169 145 } 170 146 171 147 static void ··· 221 207 minstrel_get_next_sample(struct minstrel_sta_info *mi) 222 208 { 223 209 unsigned int sample_ndx; 224 - sample_ndx = SAMPLE_TBL(mi, mi->sample_idx, mi->sample_column); 225 - mi->sample_idx++; 226 - if ((int) mi->sample_idx > (mi->n_rates - 2)) { 227 - mi->sample_idx = 0; 210 + sample_ndx = SAMPLE_TBL(mi, mi->sample_row, mi->sample_column); 211 + mi->sample_row++; 212 + if ((int) mi->sample_row >= mi->n_rates) { 213 + mi->sample_row = 0; 228 214 mi->sample_column++; 229 215 if (mi->sample_column >= SAMPLE_COLUMNS) 230 216 mi->sample_column = 0; ··· 242 228 struct minstrel_priv *mp = priv; 243 229 struct ieee80211_tx_rate *ar = info->control.rates; 244 230 unsigned int ndx, sample_ndx = 0; 245 - bool mrr; 246 - bool sample_slower = false; 247 - bool sample = false; 231 + bool mrr_capable; 232 + bool indirect_rate_sampling = false; 233 + bool rate_sampling = false; 248 234 int i, delta; 249 235 int mrr_ndx[3]; 250 - int sample_rate; 236 + int sampling_ratio; 251 237 238 + /* management/no-ack frames do not use rate control */ 252 239 if (rate_control_send_low(sta, priv_sta, txrc)) 253 240 return; 254 241 255 - mrr = mp->has_mrr && !txrc->rts && !txrc->bss_conf->use_cts_prot; 256 - 257 - ndx = mi->max_tp_rate; 258 - 259 - if (mrr) 260 - sample_rate = mp->lookaround_rate_mrr; 242 + /* check multi-rate-retry capabilities & adjust lookaround_rate */ 243 + mrr_capable = mp->has_mrr && 244 + !txrc->rts && 245 + !txrc->bss_conf->use_cts_prot; 246 + if (mrr_capable) 247 + sampling_ratio = mp->lookaround_rate_mrr; 261 248 else 262 - sample_rate = mp->lookaround_rate; 249 + sampling_ratio = mp->lookaround_rate; 263 250 251 + /* init rateindex [ndx] with max throughput rate */ 252 + ndx = mi->max_tp_rate[0]; 253 + 254 + /* increase sum packet counter */ 264 255 mi->packet_count++; 265 - delta = (mi->packet_count * sample_rate / 100) - 256 + 257 + delta = (mi->packet_count * sampling_ratio / 100) - 266 258 (mi->sample_count + mi->sample_deferred / 2); 267 259 268 260 /* delta > 0: sampling required */ 269 - if ((delta > 0) && (mrr || !mi->prev_sample)) { 261 + if ((delta > 0) && (mrr_capable || !mi->prev_sample)) { 270 262 struct minstrel_rate *msr; 271 263 if (mi->packet_count >= 10000) { 272 264 mi->sample_deferred = 0; ··· 291 271 mi->sample_count += (delta - mi->n_rates * 2); 292 272 } 293 273 274 + /* get next random rate sample */ 294 275 sample_ndx = minstrel_get_next_sample(mi); 295 276 msr = &mi->r[sample_ndx]; 296 - sample = true; 297 - sample_slower = mrr && (msr->perfect_tx_time > 298 - mi->r[ndx].perfect_tx_time); 277 + rate_sampling = true; 299 278 300 - if (!sample_slower) { 279 + /* Decide if direct ( 1st mrr stage) or indirect (2nd mrr stage) 280 + * rate sampling method should be used. 281 + * Respect such rates that are not sampled for 20 interations. 282 + */ 283 + if (mrr_capable && 284 + msr->perfect_tx_time > mi->r[ndx].perfect_tx_time && 285 + msr->sample_skipped < 20) 286 + indirect_rate_sampling = true; 287 + 288 + if (!indirect_rate_sampling) { 301 289 if (msr->sample_limit != 0) { 302 290 ndx = sample_ndx; 303 291 mi->sample_count++; 304 292 if (msr->sample_limit > 0) 305 293 msr->sample_limit--; 306 - } else { 307 - sample = false; 308 - } 294 + } else 295 + rate_sampling = false; 309 296 } else { 310 297 /* Only use IEEE80211_TX_CTL_RATE_CTRL_PROBE to mark 311 298 * packets that have the sampling rate deferred to the ··· 324 297 mi->sample_deferred++; 325 298 } 326 299 } 327 - mi->prev_sample = sample; 300 + mi->prev_sample = rate_sampling; 328 301 329 302 /* If we're not using MRR and the sampling rate already 330 303 * has a probability of >95%, we shouldn't be attempting 331 304 * to use it, as this only wastes precious airtime */ 332 - if (!mrr && sample && (mi->r[ndx].probability > 17100)) 333 - ndx = mi->max_tp_rate; 305 + if (!mrr_capable && rate_sampling && 306 + (mi->r[ndx].probability > MINSTREL_FRAC(95, 100))) 307 + ndx = mi->max_tp_rate[0]; 334 308 309 + /* mrr setup for 1st stage */ 335 310 ar[0].idx = mi->r[ndx].rix; 336 311 ar[0].count = minstrel_get_retry_count(&mi->r[ndx], info); 337 312 338 - if (!mrr) { 339 - if (!sample) 313 + /* non mrr setup for 2nd stage */ 314 + if (!mrr_capable) { 315 + if (!rate_sampling) 340 316 ar[0].count = mp->max_retry; 341 317 ar[1].idx = mi->lowest_rix; 342 318 ar[1].count = mp->max_retry; 343 319 return; 344 320 } 345 321 346 - /* MRR setup */ 347 - if (sample) { 348 - if (sample_slower) 322 + /* mrr setup for 2nd stage */ 323 + if (rate_sampling) { 324 + if (indirect_rate_sampling) 349 325 mrr_ndx[0] = sample_ndx; 350 326 else 351 - mrr_ndx[0] = mi->max_tp_rate; 327 + mrr_ndx[0] = mi->max_tp_rate[0]; 352 328 } else { 353 - mrr_ndx[0] = mi->max_tp_rate2; 329 + mrr_ndx[0] = mi->max_tp_rate[1]; 354 330 } 331 + 332 + /* mrr setup for 3rd & 4th stage */ 355 333 mrr_ndx[1] = mi->max_prob_rate; 356 334 mrr_ndx[2] = 0; 357 335 for (i = 1; i < 4; i++) { ··· 383 351 init_sample_table(struct minstrel_sta_info *mi) 384 352 { 385 353 unsigned int i, col, new_idx; 386 - unsigned int n_srates = mi->n_rates - 1; 387 354 u8 rnd[8]; 388 355 389 356 mi->sample_column = 0; 390 - mi->sample_idx = 0; 391 - memset(mi->sample_table, 0, SAMPLE_COLUMNS * mi->n_rates); 357 + mi->sample_row = 0; 358 + memset(mi->sample_table, 0xff, SAMPLE_COLUMNS * mi->n_rates); 392 359 393 360 for (col = 0; col < SAMPLE_COLUMNS; col++) { 394 - for (i = 0; i < n_srates; i++) { 361 + for (i = 0; i < mi->n_rates; i++) { 395 362 get_random_bytes(rnd, sizeof(rnd)); 396 - new_idx = (i + rnd[i & 7]) % n_srates; 363 + new_idx = (i + rnd[i & 7]) % mi->n_rates; 397 364 398 - while (SAMPLE_TBL(mi, new_idx, col) != 0) 399 - new_idx = (new_idx + 1) % n_srates; 365 + while (SAMPLE_TBL(mi, new_idx, col) != 0xff) 366 + new_idx = (new_idx + 1) % mi->n_rates; 400 367 401 - /* Don't sample the slowest rate (i.e. slowest base 402 - * rate). We must presume that the slowest rate works 403 - * fine, or else other management frames will also be 404 - * failing and the link will break */ 405 - SAMPLE_TBL(mi, new_idx, col) = i + 1; 368 + SAMPLE_TBL(mi, new_idx, col) = i; 406 369 } 407 370 } 408 371 } ··· 568 541 * is much higher than with mrr */ 569 542 mp->lookaround_rate = 5; 570 543 mp->lookaround_rate_mrr = 10; 571 - 572 - /* moving average weight for EWMA */ 573 - mp->ewma_level = 75; 574 544 575 545 /* maximum time that the hw is allowed to stay in one MRR segment */ 576 546 mp->segment_size = 6000;
+26 -5
net/mac80211/rc80211_minstrel.h
··· 9 9 #ifndef __RC_MINSTREL_H 10 10 #define __RC_MINSTREL_H 11 11 12 + #define EWMA_LEVEL 75 /* ewma weighting factor [%] */ 13 + #define SAMPLE_COLUMNS 10 /* number of columns in sample table */ 14 + 15 + 16 + /* scaled fraction values */ 17 + #define MINSTREL_SCALE 16 18 + #define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div) 19 + #define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE) 20 + 21 + /* number of highest throughput rates to consider*/ 22 + #define MAX_THR_RATES 4 23 + 24 + /* 25 + * Perform EWMA (Exponentially Weighted Moving Average) calculation 26 + */ 27 + static inline int 28 + minstrel_ewma(int old, int new, int weight) 29 + { 30 + return (new * (100 - weight) + old * weight) / 100; 31 + } 32 + 33 + 12 34 struct minstrel_rate { 13 35 int bitrate; 14 36 int rix; ··· 48 26 u32 attempts; 49 27 u32 last_attempts; 50 28 u32 last_success; 29 + u8 sample_skipped; 51 30 52 31 /* parts per thousand */ 53 32 u32 cur_prob; ··· 68 45 69 46 unsigned int lowest_rix; 70 47 71 - unsigned int max_tp_rate; 72 - unsigned int max_tp_rate2; 73 - unsigned int max_prob_rate; 48 + u8 max_tp_rate[MAX_THR_RATES]; 49 + u8 max_prob_rate; 74 50 unsigned int packet_count; 75 51 unsigned int sample_count; 76 52 int sample_deferred; 77 53 78 - unsigned int sample_idx; 54 + unsigned int sample_row; 79 55 unsigned int sample_column; 80 56 81 57 int n_rates; ··· 95 73 unsigned int cw_min; 96 74 unsigned int cw_max; 97 75 unsigned int max_retry; 98 - unsigned int ewma_level; 99 76 unsigned int segment_size; 100 77 unsigned int update_interval; 101 78 unsigned int lookaround_rate;
+7 -5
net/mac80211/rc80211_minstrel_debugfs.c
··· 73 73 for (i = 0; i < mi->n_rates; i++) { 74 74 struct minstrel_rate *mr = &mi->r[i]; 75 75 76 - *(p++) = (i == mi->max_tp_rate) ? 'T' : ' '; 77 - *(p++) = (i == mi->max_tp_rate2) ? 't' : ' '; 76 + *(p++) = (i == mi->max_tp_rate[0]) ? 'A' : ' '; 77 + *(p++) = (i == mi->max_tp_rate[1]) ? 'B' : ' '; 78 + *(p++) = (i == mi->max_tp_rate[2]) ? 'C' : ' '; 79 + *(p++) = (i == mi->max_tp_rate[3]) ? 'D' : ' '; 78 80 *(p++) = (i == mi->max_prob_rate) ? 'P' : ' '; 79 81 p += sprintf(p, "%3u%s", mr->bitrate / 2, 80 82 (mr->bitrate & 1 ? ".5" : " ")); 81 83 82 - tp = mr->cur_tp / ((18000 << 10) / 96); 83 - prob = mr->cur_prob / 18; 84 - eprob = mr->probability / 18; 84 + tp = MINSTREL_TRUNC(mr->cur_tp / 10); 85 + prob = MINSTREL_TRUNC(mr->cur_prob * 1000); 86 + eprob = MINSTREL_TRUNC(mr->probability * 1000); 85 87 86 88 p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u " 87 89 "%3u(%3u) %8llu %8llu\n",
+43 -36
net/mac80211/rc80211_minstrel_ht.c
··· 17 17 #include "rc80211_minstrel_ht.h" 18 18 19 19 #define AVG_PKT_SIZE 1200 20 - #define SAMPLE_COLUMNS 10 21 - #define EWMA_LEVEL 75 22 20 23 21 /* Number of bits for an average sized packet */ 24 22 #define MCS_NBITS (AVG_PKT_SIZE << 3) ··· 24 26 /* Number of symbols for a packet with (bps) bits per symbol */ 25 27 #define MCS_NSYMS(bps) ((MCS_NBITS + (bps) - 1) / (bps)) 26 28 27 - /* Transmission time for a packet containing (syms) symbols */ 29 + /* Transmission time (nanoseconds) for a packet containing (syms) symbols */ 28 30 #define MCS_SYMBOL_TIME(sgi, syms) \ 29 31 (sgi ? \ 30 - ((syms) * 18 + 4) / 5 : /* syms * 3.6 us */ \ 31 - (syms) << 2 /* syms * 4 us */ \ 32 + ((syms) * 18000 + 4000) / 5 : /* syms * 3.6 us */ \ 33 + ((syms) * 1000) << 2 /* syms * 4 us */ \ 32 34 ) 33 35 34 36 /* Transmit duration for the raw data part of an average sized packet */ ··· 62 64 } 63 65 64 66 #define CCK_DURATION(_bitrate, _short, _len) \ 65 - (10 /* SIFS */ + \ 67 + (1000 * (10 /* SIFS */ + \ 66 68 (_short ? 72 + 24 : 144 + 48 ) + \ 67 - (8 * (_len + 4) * 10) / (_bitrate)) 69 + (8 * (_len + 4) * 10) / (_bitrate))) 68 70 69 71 #define CCK_ACK_DURATION(_bitrate, _short) \ 70 72 (CCK_DURATION((_bitrate > 10 ? 20 : 10), false, 60) + \ ··· 125 127 #define MINSTREL_CCK_GROUP (ARRAY_SIZE(minstrel_mcs_groups) - 1) 126 128 127 129 static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES]; 128 - 129 - /* 130 - * Perform EWMA (Exponentially Weighted Moving Average) calculation 131 - */ 132 - static int 133 - minstrel_ewma(int old, int new, int weight) 134 - { 135 - return (new * (100 - weight) + old * weight) / 100; 136 - } 137 130 138 131 /* 139 132 * Look up an MCS group index based on mac80211 rate information ··· 200 211 minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, int rate) 201 212 { 202 213 struct minstrel_rate_stats *mr; 203 - unsigned int usecs = 0; 214 + unsigned int nsecs = 0; 215 + unsigned int tp; 204 216 205 217 mr = &mi->groups[group].rates[rate]; 206 218 ··· 211 221 } 212 222 213 223 if (group != MINSTREL_CCK_GROUP) 214 - usecs = mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len); 224 + nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len); 215 225 216 - usecs += minstrel_mcs_groups[group].duration[rate]; 217 - mr->cur_tp = MINSTREL_TRUNC((1000000 / usecs) * mr->probability); 226 + nsecs += minstrel_mcs_groups[group].duration[rate]; 227 + tp = 1000000 * ((mr->probability * 1000) / nsecs); 228 + 229 + mr->cur_tp = MINSTREL_TRUNC(tp); 218 230 } 219 231 220 232 /* ··· 300 308 } 301 309 } 302 310 303 - /* try to sample up to half of the available rates during each interval */ 304 - mi->sample_count *= 4; 311 + /* try to sample all available rates during each interval */ 312 + mi->sample_count *= 8; 305 313 306 314 cur_prob = 0; 307 315 cur_prob_tp = 0; ··· 312 320 if (!mg->supported) 313 321 continue; 314 322 315 - mr = minstrel_get_ratestats(mi, mg->max_prob_rate); 316 - if (cur_prob_tp < mr->cur_tp && 317 - minstrel_mcs_groups[group].streams == 1) { 318 - mi->max_prob_rate = mg->max_prob_rate; 319 - cur_prob = mr->cur_prob; 320 - cur_prob_tp = mr->cur_tp; 321 - } 322 - 323 323 mr = minstrel_get_ratestats(mi, mg->max_tp_rate); 324 324 if (cur_tp < mr->cur_tp) { 325 325 mi->max_tp_rate2 = mi->max_tp_rate; 326 326 cur_tp2 = cur_tp; 327 327 mi->max_tp_rate = mg->max_tp_rate; 328 328 cur_tp = mr->cur_tp; 329 + mi->max_prob_streams = minstrel_mcs_groups[group].streams - 1; 329 330 } 330 331 331 332 mr = minstrel_get_ratestats(mi, mg->max_tp_rate2); ··· 327 342 cur_tp2 = mr->cur_tp; 328 343 } 329 344 } 345 + 346 + if (mi->max_prob_streams < 1) 347 + mi->max_prob_streams = 1; 348 + 349 + for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) { 350 + mg = &mi->groups[group]; 351 + if (!mg->supported) 352 + continue; 353 + mr = minstrel_get_ratestats(mi, mg->max_prob_rate); 354 + if (cur_prob_tp < mr->cur_tp && 355 + minstrel_mcs_groups[group].streams <= mi->max_prob_streams) { 356 + mi->max_prob_rate = mg->max_prob_rate; 357 + cur_prob = mr->cur_prob; 358 + cur_prob_tp = mr->cur_tp; 359 + } 360 + } 361 + 330 362 331 363 mi->stats_update = jiffies; 332 364 } ··· 469 467 470 468 if (!mi->sample_wait && !mi->sample_tries && mi->sample_count > 0) { 471 469 mi->sample_wait = 16 + 2 * MINSTREL_TRUNC(mi->avg_ampdu_len); 472 - mi->sample_tries = 2; 470 + mi->sample_tries = 1; 473 471 mi->sample_count--; 474 472 } 475 473 ··· 538 536 mr->retry_updated = true; 539 537 540 538 group = &minstrel_mcs_groups[index / MCS_GROUP_RATES]; 541 - tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len; 539 + tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len / 1000; 542 540 543 541 /* Contention time for first 2 tries */ 544 542 ctime = (t_slot * cw) >> 1; ··· 618 616 { 619 617 struct minstrel_rate_stats *mr; 620 618 struct minstrel_mcs_group_data *mg; 619 + unsigned int sample_dur, sample_group; 621 620 int sample_idx = 0; 622 621 623 622 if (mi->sample_wait > 0) { ··· 629 626 if (!mi->sample_tries) 630 627 return -1; 631 628 632 - mi->sample_tries--; 633 629 mg = &mi->groups[mi->sample_group]; 634 630 sample_idx = sample_table[mg->column][mg->index]; 635 631 mr = &mg->rates[sample_idx]; 636 - sample_idx += mi->sample_group * MCS_GROUP_RATES; 632 + sample_group = mi->sample_group; 633 + sample_idx += sample_group * MCS_GROUP_RATES; 637 634 minstrel_next_sample_idx(mi); 638 635 639 636 /* ··· 654 651 * Make sure that lower rates get sampled only occasionally, 655 652 * if the link is working perfectly. 656 653 */ 657 - if (minstrel_get_duration(sample_idx) > 658 - minstrel_get_duration(mi->max_tp_rate)) { 654 + sample_dur = minstrel_get_duration(sample_idx); 655 + if (sample_dur >= minstrel_get_duration(mi->max_tp_rate2) && 656 + (mi->max_prob_streams < 657 + minstrel_mcs_groups[sample_group].streams || 658 + sample_dur >= minstrel_get_duration(mi->max_prob_rate))) { 659 659 if (mr->sample_skipped < 20) 660 660 return -1; 661 661 662 662 if (mi->sample_slow++ > 2) 663 663 return -1; 664 664 } 665 + mi->sample_tries--; 665 666 666 667 return sample_idx; 667 668 }
+1 -5
net/mac80211/rc80211_minstrel_ht.h
··· 16 16 #define MINSTREL_MAX_STREAMS 3 17 17 #define MINSTREL_STREAM_GROUPS 4 18 18 19 - /* scaled fraction values */ 20 - #define MINSTREL_SCALE 16 21 - #define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div) 22 - #define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE) 23 - 24 19 #define MCS_GROUP_RATES 8 25 20 26 21 struct mcs_group { ··· 80 85 81 86 /* best probability rate */ 82 87 unsigned int max_prob_rate; 88 + unsigned int max_prob_streams; 83 89 84 90 /* time of last status update */ 85 91 unsigned long stats_update;
+26 -35
net/mac80211/rx.c
··· 648 648 return RX_CONTINUE; 649 649 } 650 650 651 - #define SEQ_MODULO 0x1000 652 - #define SEQ_MASK 0xfff 653 - 654 - static inline int seq_less(u16 sq1, u16 sq2) 655 - { 656 - return ((sq1 - sq2) & SEQ_MASK) > (SEQ_MODULO >> 1); 657 - } 658 - 659 - static inline u16 seq_inc(u16 sq) 660 - { 661 - return (sq + 1) & SEQ_MASK; 662 - } 663 - 664 - static inline u16 seq_sub(u16 sq1, u16 sq2) 665 - { 666 - return (sq1 - sq2) & SEQ_MASK; 667 - } 668 - 669 651 static void ieee80211_release_reorder_frame(struct ieee80211_sub_if_data *sdata, 670 652 struct tid_ampdu_rx *tid_agg_rx, 671 653 int index, ··· 669 687 __skb_queue_tail(frames, skb); 670 688 671 689 no_frame: 672 - tid_agg_rx->head_seq_num = seq_inc(tid_agg_rx->head_seq_num); 690 + tid_agg_rx->head_seq_num = ieee80211_sn_inc(tid_agg_rx->head_seq_num); 673 691 } 674 692 675 693 static void ieee80211_release_reorder_frames(struct ieee80211_sub_if_data *sdata, ··· 681 699 682 700 lockdep_assert_held(&tid_agg_rx->reorder_lock); 683 701 684 - while (seq_less(tid_agg_rx->head_seq_num, head_seq_num)) { 685 - index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) % 702 + while (ieee80211_sn_less(tid_agg_rx->head_seq_num, head_seq_num)) { 703 + index = ieee80211_sn_sub(tid_agg_rx->head_seq_num, 704 + tid_agg_rx->ssn) % 686 705 tid_agg_rx->buf_size; 687 706 ieee80211_release_reorder_frame(sdata, tid_agg_rx, index, 688 707 frames); ··· 710 727 lockdep_assert_held(&tid_agg_rx->reorder_lock); 711 728 712 729 /* release the buffer until next missing frame */ 713 - index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) % 714 - tid_agg_rx->buf_size; 730 + index = ieee80211_sn_sub(tid_agg_rx->head_seq_num, 731 + tid_agg_rx->ssn) % tid_agg_rx->buf_size; 715 732 if (!tid_agg_rx->reorder_buf[index] && 716 733 tid_agg_rx->stored_mpdu_num) { 717 734 /* ··· 739 756 * Increment the head seq# also for the skipped slots. 740 757 */ 741 758 tid_agg_rx->head_seq_num = 742 - (tid_agg_rx->head_seq_num + skipped) & SEQ_MASK; 759 + (tid_agg_rx->head_seq_num + 760 + skipped) & IEEE80211_SN_MASK; 743 761 skipped = 0; 744 762 } 745 763 } else while (tid_agg_rx->reorder_buf[index]) { 746 764 ieee80211_release_reorder_frame(sdata, tid_agg_rx, index, 747 765 frames); 748 - index = seq_sub(tid_agg_rx->head_seq_num, tid_agg_rx->ssn) % 766 + index = ieee80211_sn_sub(tid_agg_rx->head_seq_num, 767 + tid_agg_rx->ssn) % 749 768 tid_agg_rx->buf_size; 750 769 } 751 770 752 771 if (tid_agg_rx->stored_mpdu_num) { 753 - j = index = seq_sub(tid_agg_rx->head_seq_num, 754 - tid_agg_rx->ssn) % tid_agg_rx->buf_size; 772 + j = index = ieee80211_sn_sub(tid_agg_rx->head_seq_num, 773 + tid_agg_rx->ssn) % 774 + tid_agg_rx->buf_size; 755 775 756 776 for (; j != (index - 1) % tid_agg_rx->buf_size; 757 777 j = (j + 1) % tid_agg_rx->buf_size) { ··· 795 809 head_seq_num = tid_agg_rx->head_seq_num; 796 810 797 811 /* frame with out of date sequence number */ 798 - if (seq_less(mpdu_seq_num, head_seq_num)) { 812 + if (ieee80211_sn_less(mpdu_seq_num, head_seq_num)) { 799 813 dev_kfree_skb(skb); 800 814 goto out; 801 815 } ··· 804 818 * If frame the sequence number exceeds our buffering window 805 819 * size release some previous frames to make room for this one. 806 820 */ 807 - if (!seq_less(mpdu_seq_num, head_seq_num + buf_size)) { 808 - head_seq_num = seq_inc(seq_sub(mpdu_seq_num, buf_size)); 821 + if (!ieee80211_sn_less(mpdu_seq_num, head_seq_num + buf_size)) { 822 + head_seq_num = ieee80211_sn_inc( 823 + ieee80211_sn_sub(mpdu_seq_num, buf_size)); 809 824 /* release stored frames up to new head to stack */ 810 825 ieee80211_release_reorder_frames(sdata, tid_agg_rx, 811 826 head_seq_num, frames); ··· 814 827 815 828 /* Now the new frame is always in the range of the reordering buffer */ 816 829 817 - index = seq_sub(mpdu_seq_num, tid_agg_rx->ssn) % tid_agg_rx->buf_size; 830 + index = ieee80211_sn_sub(mpdu_seq_num, 831 + tid_agg_rx->ssn) % tid_agg_rx->buf_size; 818 832 819 833 /* check if we already stored this frame */ 820 834 if (tid_agg_rx->reorder_buf[index]) { ··· 831 843 */ 832 844 if (mpdu_seq_num == tid_agg_rx->head_seq_num && 833 845 tid_agg_rx->stored_mpdu_num == 0) { 834 - tid_agg_rx->head_seq_num = seq_inc(tid_agg_rx->head_seq_num); 846 + tid_agg_rx->head_seq_num = 847 + ieee80211_sn_inc(tid_agg_rx->head_seq_num); 835 848 ret = false; 836 849 goto out; 837 850 } ··· 1883 1894 * 'align' will only take the values 0 or 2 here 1884 1895 * since all frames are required to be aligned 1885 1896 * to 2-byte boundaries when being passed to 1886 - * mac80211. That also explains the __skb_push() 1887 - * below. 1897 + * mac80211; the code here works just as well if 1898 + * that isn't true, but mac80211 assumes it can 1899 + * access fields as 2-byte aligned (e.g. for 1900 + * compare_ether_addr) 1888 1901 */ 1889 1902 align = ((unsigned long)(skb->data + sizeof(struct ethhdr))) & 3; 1890 1903 if (align) { ··· 2543 2552 case WLAN_SP_MESH_PEERING_CONFIRM: 2544 2553 if (!ieee80211_vif_is_mesh(&sdata->vif)) 2545 2554 goto invalid; 2546 - if (sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE) 2555 + if (sdata->u.mesh.user_mpm) 2547 2556 /* userspace handles this frame */ 2548 2557 break; 2549 2558 goto queue;
+9 -2
net/mac80211/sta_info.c
··· 342 342 INIT_WORK(&sta->drv_unblock_wk, sta_unblock); 343 343 INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work); 344 344 mutex_init(&sta->ampdu_mlme.mtx); 345 + #ifdef CONFIG_MAC80211_MESH 346 + if (ieee80211_vif_is_mesh(&sdata->vif) && 347 + !sdata->u.mesh.user_mpm) 348 + init_timer(&sta->plink_timer); 349 + #endif 345 350 346 351 memcpy(sta->sta.addr, addr, ETH_ALEN); 347 352 sta->local = local; ··· 799 794 800 795 mutex_lock(&local->key_mtx); 801 796 for (i = 0; i < NUM_DEFAULT_KEYS; i++) 802 - __ieee80211_key_free(key_mtx_dereference(local, sta->gtk[i])); 797 + __ieee80211_key_free(key_mtx_dereference(local, sta->gtk[i]), 798 + true); 803 799 if (sta->ptk) 804 - __ieee80211_key_free(key_mtx_dereference(local, sta->ptk)); 800 + __ieee80211_key_free(key_mtx_dereference(local, sta->ptk), 801 + true); 805 802 mutex_unlock(&local->key_mtx); 806 803 807 804 sta->dead = true;
-2
net/mac80211/sta_info.h
··· 281 281 * @plink_state: peer link state 282 282 * @plink_timeout: timeout of peer link 283 283 * @plink_timer: peer link watch timer 284 - * @plink_timer_was_running: used by suspend/resume to restore timers 285 284 * @t_offset: timing offset relative to this host 286 285 * @t_offset_setpoint: reference timing offset of this sta to be used when 287 286 * calculating clockdrift ··· 378 379 __le16 reason; 379 380 u8 plink_retries; 380 381 bool ignore_plink_timer; 381 - bool plink_timer_was_running; 382 382 enum nl80211_plink_state plink_state; 383 383 u32 plink_timeout; 384 384 struct timer_list plink_timer;
+7 -4
net/mac80211/trace.h
··· 1042 1042 TP_PROTO(struct ieee80211_local *local, 1043 1043 struct ieee80211_sub_if_data *sdata, 1044 1044 struct ieee80211_channel *chan, 1045 - unsigned int duration), 1045 + unsigned int duration, 1046 + enum ieee80211_roc_type type), 1046 1047 1047 - TP_ARGS(local, sdata, chan, duration), 1048 + TP_ARGS(local, sdata, chan, duration, type), 1048 1049 1049 1050 TP_STRUCT__entry( 1050 1051 LOCAL_ENTRY 1051 1052 VIF_ENTRY 1052 1053 __field(int, center_freq) 1053 1054 __field(unsigned int, duration) 1055 + __field(u32, type) 1054 1056 ), 1055 1057 1056 1058 TP_fast_assign( ··· 1060 1058 VIF_ASSIGN; 1061 1059 __entry->center_freq = chan->center_freq; 1062 1060 __entry->duration = duration; 1061 + __entry->type = type; 1063 1062 ), 1064 1063 1065 1064 TP_printk( 1066 - LOCAL_PR_FMT VIF_PR_FMT " freq:%dMHz duration:%dms", 1065 + LOCAL_PR_FMT VIF_PR_FMT " freq:%dMHz duration:%dms type=%d", 1067 1066 LOCAL_PR_ARG, VIF_PR_ARG, 1068 - __entry->center_freq, __entry->duration 1067 + __entry->center_freq, __entry->duration, __entry->type 1069 1068 ) 1070 1069 ); 1071 1070
+51 -29
net/mac80211/tx.c
··· 1231 1231 if (local->queue_stop_reasons[q] || 1232 1232 (!txpending && !skb_queue_empty(&local->pending[q]))) { 1233 1233 if (unlikely(info->flags & 1234 - IEEE80211_TX_INTFL_OFFCHAN_TX_OK && 1235 - local->queue_stop_reasons[q] & 1236 - ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL))) { 1234 + IEEE80211_TX_INTFL_OFFCHAN_TX_OK)) { 1235 + if (local->queue_stop_reasons[q] & 1236 + ~BIT(IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL)) { 1237 + /* 1238 + * Drop off-channel frames if queues 1239 + * are stopped for any reason other 1240 + * than off-channel operation. Never 1241 + * queue them. 1242 + */ 1243 + spin_unlock_irqrestore( 1244 + &local->queue_stop_reason_lock, 1245 + flags); 1246 + ieee80211_purge_tx_queue(&local->hw, 1247 + skbs); 1248 + return true; 1249 + } 1250 + } else { 1251 + 1237 1252 /* 1238 - * Drop off-channel frames if queues are stopped 1239 - * for any reason other than off-channel 1240 - * operation. Never queue them. 1253 + * Since queue is stopped, queue up frames for 1254 + * later transmission from the tx-pending 1255 + * tasklet when the queue is woken again. 1241 1256 */ 1242 - spin_unlock_irqrestore( 1243 - &local->queue_stop_reason_lock, flags); 1244 - ieee80211_purge_tx_queue(&local->hw, skbs); 1245 - return true; 1257 + if (txpending) 1258 + skb_queue_splice_init(skbs, 1259 + &local->pending[q]); 1260 + else 1261 + skb_queue_splice_tail_init(skbs, 1262 + &local->pending[q]); 1263 + 1264 + spin_unlock_irqrestore(&local->queue_stop_reason_lock, 1265 + flags); 1266 + return false; 1246 1267 } 1247 - 1248 - /* 1249 - * Since queue is stopped, queue up frames for later 1250 - * transmission from the tx-pending tasklet when the 1251 - * queue is woken again. 1252 - */ 1253 - if (txpending) 1254 - skb_queue_splice_init(skbs, &local->pending[q]); 1255 - else 1256 - skb_queue_splice_tail_init(skbs, 1257 - &local->pending[q]); 1258 - 1259 - spin_unlock_irqrestore(&local->queue_stop_reason_lock, 1260 - flags); 1261 - return false; 1262 1268 } 1263 1269 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); 1264 1270 ··· 1850 1844 } 1851 1845 1852 1846 if (!is_multicast_ether_addr(skb->data)) { 1847 + struct sta_info *next_hop; 1848 + bool mpp_lookup = true; 1849 + 1853 1850 mpath = mesh_path_lookup(sdata, skb->data); 1854 - if (!mpath) 1851 + if (mpath) { 1852 + mpp_lookup = false; 1853 + next_hop = rcu_dereference(mpath->next_hop); 1854 + if (!next_hop || 1855 + !(mpath->flags & (MESH_PATH_ACTIVE | 1856 + MESH_PATH_RESOLVING))) 1857 + mpp_lookup = true; 1858 + } 1859 + 1860 + if (mpp_lookup) 1855 1861 mppath = mpp_path_lookup(sdata, skb->data); 1862 + 1863 + if (mppath && mpath) 1864 + mesh_path_del(mpath->sdata, mpath->dst); 1856 1865 } 1857 1866 1858 1867 /* ··· 2371 2350 if (local->tim_in_locked_section) { 2372 2351 __ieee80211_beacon_add_tim(sdata, ps, skb); 2373 2352 } else { 2374 - spin_lock(&local->tim_lock); 2353 + spin_lock_bh(&local->tim_lock); 2375 2354 __ieee80211_beacon_add_tim(sdata, ps, skb); 2376 - spin_unlock(&local->tim_lock); 2355 + spin_unlock_bh(&local->tim_lock); 2377 2356 } 2378 2357 2379 2358 return 0; ··· 2745 2724 cpu_to_le16(IEEE80211_FCTL_MOREDATA); 2746 2725 } 2747 2726 2748 - sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev); 2727 + if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 2728 + sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev); 2749 2729 if (!ieee80211_tx_prepare(sdata, &tx, skb)) 2750 2730 break; 2751 2731 dev_kfree_skb_any(skb);
+22 -51
net/mac80211/util.c
··· 1357 1357 drv_stop(local); 1358 1358 } 1359 1359 1360 + static void ieee80211_assign_chanctx(struct ieee80211_local *local, 1361 + struct ieee80211_sub_if_data *sdata) 1362 + { 1363 + struct ieee80211_chanctx_conf *conf; 1364 + struct ieee80211_chanctx *ctx; 1365 + 1366 + if (!local->use_chanctx) 1367 + return; 1368 + 1369 + mutex_lock(&local->chanctx_mtx); 1370 + conf = rcu_dereference_protected(sdata->vif.chanctx_conf, 1371 + lockdep_is_held(&local->chanctx_mtx)); 1372 + if (conf) { 1373 + ctx = container_of(conf, struct ieee80211_chanctx, conf); 1374 + drv_assign_vif_chanctx(local, sdata, ctx); 1375 + } 1376 + mutex_unlock(&local->chanctx_mtx); 1377 + } 1378 + 1360 1379 int ieee80211_reconfig(struct ieee80211_local *local) 1361 1380 { 1362 1381 struct ieee80211_hw *hw = &local->hw; ··· 1464 1445 } 1465 1446 1466 1447 list_for_each_entry(sdata, &local->interfaces, list) { 1467 - struct ieee80211_chanctx_conf *ctx_conf; 1468 - 1469 1448 if (!ieee80211_sdata_running(sdata)) 1470 1449 continue; 1471 - 1472 - mutex_lock(&local->chanctx_mtx); 1473 - ctx_conf = rcu_dereference_protected(sdata->vif.chanctx_conf, 1474 - lockdep_is_held(&local->chanctx_mtx)); 1475 - if (ctx_conf) { 1476 - ctx = container_of(ctx_conf, struct ieee80211_chanctx, 1477 - conf); 1478 - drv_assign_vif_chanctx(local, sdata, ctx); 1479 - } 1480 - mutex_unlock(&local->chanctx_mtx); 1450 + ieee80211_assign_chanctx(local, sdata); 1481 1451 } 1482 1452 1483 1453 sdata = rtnl_dereference(local->monitor_sdata); 1484 - if (sdata && local->use_chanctx && ieee80211_sdata_running(sdata)) { 1485 - struct ieee80211_chanctx_conf *ctx_conf; 1486 - 1487 - mutex_lock(&local->chanctx_mtx); 1488 - ctx_conf = rcu_dereference_protected(sdata->vif.chanctx_conf, 1489 - lockdep_is_held(&local->chanctx_mtx)); 1490 - if (ctx_conf) { 1491 - ctx = container_of(ctx_conf, struct ieee80211_chanctx, 1492 - conf); 1493 - drv_assign_vif_chanctx(local, sdata, ctx); 1494 - } 1495 - mutex_unlock(&local->chanctx_mtx); 1496 - } 1454 + if (sdata && ieee80211_sdata_running(sdata)) 1455 + ieee80211_assign_chanctx(local, sdata); 1497 1456 1498 1457 /* add STAs back */ 1499 1458 mutex_lock(&local->sta_mtx); ··· 1530 1533 BSS_CHANGED_QOS | 1531 1534 BSS_CHANGED_IDLE | 1532 1535 BSS_CHANGED_TXPOWER; 1533 - 1534 - #ifdef CONFIG_PM 1535 - if (local->resuming && !reconfig_due_to_wowlan) 1536 - sdata->vif.bss_conf = sdata->suspend_bss_conf; 1537 - #endif 1538 1536 1539 1537 switch (sdata->vif.type) { 1540 1538 case NL80211_IFTYPE_STATION: ··· 1670 1678 mb(); 1671 1679 local->resuming = false; 1672 1680 1673 - list_for_each_entry(sdata, &local->interfaces, list) { 1674 - switch(sdata->vif.type) { 1675 - case NL80211_IFTYPE_STATION: 1676 - ieee80211_sta_restart(sdata); 1677 - break; 1678 - case NL80211_IFTYPE_ADHOC: 1679 - ieee80211_ibss_restart(sdata); 1680 - break; 1681 - case NL80211_IFTYPE_MESH_POINT: 1682 - ieee80211_mesh_restart(sdata); 1683 - break; 1684 - default: 1685 - break; 1686 - } 1687 - } 1688 - 1689 1681 mod_timer(&local->sta_cleanup, jiffies + 1); 1690 - 1691 - mutex_lock(&local->sta_mtx); 1692 - list_for_each_entry(sta, &local->sta_list, list) 1693 - mesh_plink_restart(sta); 1694 - mutex_unlock(&local->sta_mtx); 1695 1682 #else 1696 1683 WARN_ON(1); 1697 1684 #endif
+211 -1
net/mac80211/vht.c
··· 13 13 #include "rate.h" 14 14 15 15 16 + static void __check_vhtcap_disable(struct ieee80211_sub_if_data *sdata, 17 + struct ieee80211_sta_vht_cap *vht_cap, 18 + u32 flag) 19 + { 20 + __le32 le_flag = cpu_to_le32(flag); 21 + 22 + if (sdata->u.mgd.vht_capa_mask.vht_cap_info & le_flag && 23 + !(sdata->u.mgd.vht_capa.vht_cap_info & le_flag)) 24 + vht_cap->cap &= ~flag; 25 + } 26 + 27 + void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata, 28 + struct ieee80211_sta_vht_cap *vht_cap) 29 + { 30 + int i; 31 + u16 rxmcs_mask, rxmcs_cap, rxmcs_n, txmcs_mask, txmcs_cap, txmcs_n; 32 + 33 + if (!vht_cap->vht_supported) 34 + return; 35 + 36 + if (sdata->vif.type != NL80211_IFTYPE_STATION) 37 + return; 38 + 39 + __check_vhtcap_disable(sdata, vht_cap, 40 + IEEE80211_VHT_CAP_RXLDPC); 41 + __check_vhtcap_disable(sdata, vht_cap, 42 + IEEE80211_VHT_CAP_SHORT_GI_80); 43 + __check_vhtcap_disable(sdata, vht_cap, 44 + IEEE80211_VHT_CAP_SHORT_GI_160); 45 + __check_vhtcap_disable(sdata, vht_cap, 46 + IEEE80211_VHT_CAP_TXSTBC); 47 + __check_vhtcap_disable(sdata, vht_cap, 48 + IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE); 49 + __check_vhtcap_disable(sdata, vht_cap, 50 + IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE); 51 + __check_vhtcap_disable(sdata, vht_cap, 52 + IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN); 53 + __check_vhtcap_disable(sdata, vht_cap, 54 + IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN); 55 + 56 + /* Allow user to decrease AMPDU length exponent */ 57 + if (sdata->u.mgd.vht_capa_mask.vht_cap_info & 58 + cpu_to_le32(IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK)) { 59 + u32 cap, n; 60 + 61 + n = le32_to_cpu(sdata->u.mgd.vht_capa.vht_cap_info) & 62 + IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK; 63 + n >>= IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT; 64 + cap = vht_cap->cap & IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK; 65 + cap >>= IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT; 66 + 67 + if (n < cap) { 68 + vht_cap->cap &= 69 + ~IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK; 70 + vht_cap->cap |= 71 + n << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT; 72 + } 73 + } 74 + 75 + /* Allow the user to decrease MCSes */ 76 + rxmcs_mask = 77 + le16_to_cpu(sdata->u.mgd.vht_capa_mask.supp_mcs.rx_mcs_map); 78 + rxmcs_n = le16_to_cpu(sdata->u.mgd.vht_capa.supp_mcs.rx_mcs_map); 79 + rxmcs_n &= rxmcs_mask; 80 + rxmcs_cap = le16_to_cpu(vht_cap->vht_mcs.rx_mcs_map); 81 + 82 + txmcs_mask = 83 + le16_to_cpu(sdata->u.mgd.vht_capa_mask.supp_mcs.tx_mcs_map); 84 + txmcs_n = le16_to_cpu(sdata->u.mgd.vht_capa.supp_mcs.tx_mcs_map); 85 + txmcs_n &= txmcs_mask; 86 + txmcs_cap = le16_to_cpu(vht_cap->vht_mcs.tx_mcs_map); 87 + for (i = 0; i < 8; i++) { 88 + u8 m, n, c; 89 + 90 + m = (rxmcs_mask >> 2*i) & IEEE80211_VHT_MCS_NOT_SUPPORTED; 91 + n = (rxmcs_n >> 2*i) & IEEE80211_VHT_MCS_NOT_SUPPORTED; 92 + c = (rxmcs_cap >> 2*i) & IEEE80211_VHT_MCS_NOT_SUPPORTED; 93 + 94 + if (m && ((c != IEEE80211_VHT_MCS_NOT_SUPPORTED && n < c) || 95 + n == IEEE80211_VHT_MCS_NOT_SUPPORTED)) { 96 + rxmcs_cap &= ~(3 << 2*i); 97 + rxmcs_cap |= (rxmcs_n & (3 << 2*i)); 98 + } 99 + 100 + m = (txmcs_mask >> 2*i) & IEEE80211_VHT_MCS_NOT_SUPPORTED; 101 + n = (txmcs_n >> 2*i) & IEEE80211_VHT_MCS_NOT_SUPPORTED; 102 + c = (txmcs_cap >> 2*i) & IEEE80211_VHT_MCS_NOT_SUPPORTED; 103 + 104 + if (m && ((c != IEEE80211_VHT_MCS_NOT_SUPPORTED && n < c) || 105 + n == IEEE80211_VHT_MCS_NOT_SUPPORTED)) { 106 + txmcs_cap &= ~(3 << 2*i); 107 + txmcs_cap |= (txmcs_n & (3 << 2*i)); 108 + } 109 + } 110 + vht_cap->vht_mcs.rx_mcs_map = cpu_to_le16(rxmcs_cap); 111 + vht_cap->vht_mcs.tx_mcs_map = cpu_to_le16(txmcs_cap); 112 + } 113 + 16 114 void 17 115 ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata, 18 116 struct ieee80211_supported_band *sband, ··· 118 20 struct sta_info *sta) 119 21 { 120 22 struct ieee80211_sta_vht_cap *vht_cap = &sta->sta.vht_cap; 23 + struct ieee80211_sta_vht_cap own_cap; 24 + u32 cap_info, i; 121 25 122 26 memset(vht_cap, 0, sizeof(*vht_cap)); 123 27 ··· 135 35 136 36 vht_cap->vht_supported = true; 137 37 138 - vht_cap->cap = le32_to_cpu(vht_cap_ie->vht_cap_info); 38 + own_cap = sband->vht_cap; 39 + /* 40 + * If user has specified capability overrides, take care 41 + * of that if the station we're setting up is the AP that 42 + * we advertised a restricted capability set to. Override 43 + * our own capabilities and then use those below. 44 + */ 45 + if (sdata->vif.type == NL80211_IFTYPE_STATION && 46 + !test_sta_flag(sta, WLAN_STA_TDLS_PEER)) 47 + ieee80211_apply_vhtcap_overrides(sdata, &own_cap); 48 + 49 + /* take some capabilities as-is */ 50 + cap_info = le32_to_cpu(vht_cap_ie->vht_cap_info); 51 + vht_cap->cap = cap_info; 52 + vht_cap->cap &= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 | 53 + IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 | 54 + IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 | 55 + IEEE80211_VHT_CAP_RXLDPC | 56 + IEEE80211_VHT_CAP_VHT_TXOP_PS | 57 + IEEE80211_VHT_CAP_HTC_VHT | 58 + IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK | 59 + IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB | 60 + IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB | 61 + IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN | 62 + IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN; 63 + 64 + /* and some based on our own capabilities */ 65 + switch (own_cap.cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK) { 66 + case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ: 67 + vht_cap->cap |= cap_info & 68 + IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; 69 + break; 70 + case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ: 71 + vht_cap->cap |= cap_info & 72 + IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK; 73 + break; 74 + default: 75 + /* nothing */ 76 + break; 77 + } 78 + 79 + /* symmetric capabilities */ 80 + vht_cap->cap |= cap_info & own_cap.cap & 81 + (IEEE80211_VHT_CAP_SHORT_GI_80 | 82 + IEEE80211_VHT_CAP_SHORT_GI_160); 83 + 84 + /* remaining ones */ 85 + if (own_cap.cap & IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE) { 86 + vht_cap->cap |= cap_info & 87 + (IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE | 88 + IEEE80211_VHT_CAP_BEAMFORMER_ANTENNAS_MAX | 89 + IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MAX); 90 + } 91 + 92 + if (own_cap.cap & IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE) 93 + vht_cap->cap |= cap_info & 94 + IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; 95 + 96 + if (own_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE) 97 + vht_cap->cap |= cap_info & 98 + IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; 99 + 100 + if (own_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE) 101 + vht_cap->cap |= cap_info & 102 + IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; 103 + 104 + if (own_cap.cap & IEEE80211_VHT_CAP_TXSTBC) 105 + vht_cap->cap |= cap_info & IEEE80211_VHT_CAP_RXSTBC_MASK; 106 + 107 + if (own_cap.cap & IEEE80211_VHT_CAP_RXSTBC_MASK) 108 + vht_cap->cap |= cap_info & IEEE80211_VHT_CAP_TXSTBC; 139 109 140 110 /* Copy peer MCS info, the driver might need them. */ 141 111 memcpy(&vht_cap->vht_mcs, &vht_cap_ie->supp_mcs, 142 112 sizeof(struct ieee80211_vht_mcs_info)); 143 113 114 + /* but also restrict MCSes */ 115 + for (i = 0; i < 8; i++) { 116 + u16 own_rx, own_tx, peer_rx, peer_tx; 117 + 118 + own_rx = le16_to_cpu(own_cap.vht_mcs.rx_mcs_map); 119 + own_rx = (own_rx >> i * 2) & IEEE80211_VHT_MCS_NOT_SUPPORTED; 120 + 121 + own_tx = le16_to_cpu(own_cap.vht_mcs.tx_mcs_map); 122 + own_tx = (own_tx >> i * 2) & IEEE80211_VHT_MCS_NOT_SUPPORTED; 123 + 124 + peer_rx = le16_to_cpu(vht_cap->vht_mcs.rx_mcs_map); 125 + peer_rx = (peer_rx >> i * 2) & IEEE80211_VHT_MCS_NOT_SUPPORTED; 126 + 127 + peer_tx = le16_to_cpu(vht_cap->vht_mcs.tx_mcs_map); 128 + peer_tx = (peer_tx >> i * 2) & IEEE80211_VHT_MCS_NOT_SUPPORTED; 129 + 130 + if (peer_tx != IEEE80211_VHT_MCS_NOT_SUPPORTED) { 131 + if (own_rx == IEEE80211_VHT_MCS_NOT_SUPPORTED) 132 + peer_tx = IEEE80211_VHT_MCS_NOT_SUPPORTED; 133 + else if (own_rx < peer_tx) 134 + peer_tx = own_rx; 135 + } 136 + 137 + if (peer_rx != IEEE80211_VHT_MCS_NOT_SUPPORTED) { 138 + if (own_tx == IEEE80211_VHT_MCS_NOT_SUPPORTED) 139 + peer_rx = IEEE80211_VHT_MCS_NOT_SUPPORTED; 140 + else if (own_tx < peer_rx) 141 + peer_rx = own_tx; 142 + } 143 + 144 + vht_cap->vht_mcs.rx_mcs_map &= 145 + ~cpu_to_le16(IEEE80211_VHT_MCS_NOT_SUPPORTED << i * 2); 146 + vht_cap->vht_mcs.rx_mcs_map |= cpu_to_le16(peer_rx << i * 2); 147 + 148 + vht_cap->vht_mcs.tx_mcs_map &= 149 + ~cpu_to_le16(IEEE80211_VHT_MCS_NOT_SUPPORTED << i * 2); 150 + vht_cap->vht_mcs.tx_mcs_map |= cpu_to_le16(peer_tx << i * 2); 151 + } 152 + 153 + /* finally set up the bandwidth */ 144 154 switch (vht_cap->cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK) { 145 155 case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ: 146 156 case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ:
+1 -1
net/rfkill/rfkill-regulator.c
··· 51 51 return 0; 52 52 } 53 53 54 - struct rfkill_ops rfkill_regulator_ops = { 54 + static struct rfkill_ops rfkill_regulator_ops = { 55 55 .set_block = rfkill_regulator_set_block, 56 56 }; 57 57
-62
net/wireless/ap.c
··· 46 46 47 47 return err; 48 48 } 49 - 50 - void cfg80211_ch_switch_notify(struct net_device *dev, 51 - struct cfg80211_chan_def *chandef) 52 - { 53 - struct wireless_dev *wdev = dev->ieee80211_ptr; 54 - struct wiphy *wiphy = wdev->wiphy; 55 - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 56 - 57 - trace_cfg80211_ch_switch_notify(dev, chandef); 58 - 59 - wdev_lock(wdev); 60 - 61 - if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && 62 - wdev->iftype != NL80211_IFTYPE_P2P_GO)) 63 - goto out; 64 - 65 - wdev->channel = chandef->chan; 66 - nl80211_ch_switch_notify(rdev, dev, chandef, GFP_KERNEL); 67 - out: 68 - wdev_unlock(wdev); 69 - return; 70 - } 71 - EXPORT_SYMBOL(cfg80211_ch_switch_notify); 72 - 73 - bool cfg80211_rx_spurious_frame(struct net_device *dev, 74 - const u8 *addr, gfp_t gfp) 75 - { 76 - struct wireless_dev *wdev = dev->ieee80211_ptr; 77 - bool ret; 78 - 79 - trace_cfg80211_rx_spurious_frame(dev, addr); 80 - 81 - if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && 82 - wdev->iftype != NL80211_IFTYPE_P2P_GO)) { 83 - trace_cfg80211_return_bool(false); 84 - return false; 85 - } 86 - ret = nl80211_unexpected_frame(dev, addr, gfp); 87 - trace_cfg80211_return_bool(ret); 88 - return ret; 89 - } 90 - EXPORT_SYMBOL(cfg80211_rx_spurious_frame); 91 - 92 - bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev, 93 - const u8 *addr, gfp_t gfp) 94 - { 95 - struct wireless_dev *wdev = dev->ieee80211_ptr; 96 - bool ret; 97 - 98 - trace_cfg80211_rx_unexpected_4addr_frame(dev, addr); 99 - 100 - if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && 101 - wdev->iftype != NL80211_IFTYPE_P2P_GO && 102 - wdev->iftype != NL80211_IFTYPE_AP_VLAN)) { 103 - trace_cfg80211_return_bool(false); 104 - return false; 105 - } 106 - ret = nl80211_unexpected_4addr_frame(dev, addr, gfp); 107 - trace_cfg80211_return_bool(ret); 108 - return ret; 109 - } 110 - EXPORT_SYMBOL(cfg80211_rx_unexpected_4addr_frame);
+42 -34
net/wireless/core.c
··· 367 367 rdev->wiphy.rts_threshold = (u32) -1; 368 368 rdev->wiphy.coverage_class = 0; 369 369 370 - rdev->wiphy.features = NL80211_FEATURE_SCAN_FLUSH | 371 - NL80211_FEATURE_ADVERTISE_CHAN_LIMITS; 370 + rdev->wiphy.features = NL80211_FEATURE_SCAN_FLUSH; 372 371 373 372 return &rdev->wiphy; 374 373 } ··· 814 815 rdev->num_running_monitor_ifaces += num; 815 816 } 816 817 818 + void cfg80211_leave(struct cfg80211_registered_device *rdev, 819 + struct wireless_dev *wdev) 820 + { 821 + struct net_device *dev = wdev->netdev; 822 + 823 + switch (wdev->iftype) { 824 + case NL80211_IFTYPE_ADHOC: 825 + cfg80211_leave_ibss(rdev, dev, true); 826 + break; 827 + case NL80211_IFTYPE_P2P_CLIENT: 828 + case NL80211_IFTYPE_STATION: 829 + mutex_lock(&rdev->sched_scan_mtx); 830 + __cfg80211_stop_sched_scan(rdev, false); 831 + mutex_unlock(&rdev->sched_scan_mtx); 832 + 833 + wdev_lock(wdev); 834 + #ifdef CONFIG_CFG80211_WEXT 835 + kfree(wdev->wext.ie); 836 + wdev->wext.ie = NULL; 837 + wdev->wext.ie_len = 0; 838 + wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; 839 + #endif 840 + __cfg80211_disconnect(rdev, dev, 841 + WLAN_REASON_DEAUTH_LEAVING, true); 842 + cfg80211_mlme_down(rdev, dev); 843 + wdev_unlock(wdev); 844 + break; 845 + case NL80211_IFTYPE_MESH_POINT: 846 + cfg80211_leave_mesh(rdev, dev); 847 + break; 848 + case NL80211_IFTYPE_AP: 849 + cfg80211_stop_ap(rdev, dev); 850 + break; 851 + default: 852 + break; 853 + } 854 + 855 + wdev->beacon_interval = 0; 856 + } 857 + 817 858 static int cfg80211_netdev_notifier_call(struct notifier_block *nb, 818 859 unsigned long state, 819 860 void *ndev) ··· 922 883 dev->priv_flags |= IFF_DONT_BRIDGE; 923 884 break; 924 885 case NETDEV_GOING_DOWN: 925 - switch (wdev->iftype) { 926 - case NL80211_IFTYPE_ADHOC: 927 - cfg80211_leave_ibss(rdev, dev, true); 928 - break; 929 - case NL80211_IFTYPE_P2P_CLIENT: 930 - case NL80211_IFTYPE_STATION: 931 - mutex_lock(&rdev->sched_scan_mtx); 932 - __cfg80211_stop_sched_scan(rdev, false); 933 - mutex_unlock(&rdev->sched_scan_mtx); 934 - 935 - wdev_lock(wdev); 936 - #ifdef CONFIG_CFG80211_WEXT 937 - kfree(wdev->wext.ie); 938 - wdev->wext.ie = NULL; 939 - wdev->wext.ie_len = 0; 940 - wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; 941 - #endif 942 - __cfg80211_disconnect(rdev, dev, 943 - WLAN_REASON_DEAUTH_LEAVING, true); 944 - cfg80211_mlme_down(rdev, dev); 945 - wdev_unlock(wdev); 946 - break; 947 - case NL80211_IFTYPE_MESH_POINT: 948 - cfg80211_leave_mesh(rdev, dev); 949 - break; 950 - case NL80211_IFTYPE_AP: 951 - cfg80211_stop_ap(rdev, dev); 952 - break; 953 - default: 954 - break; 955 - } 956 - wdev->beacon_interval = 0; 886 + cfg80211_leave(rdev, wdev); 957 887 break; 958 888 case NETDEV_DOWN: 959 889 cfg80211_update_iface_num(rdev, wdev->iftype, -1);
+11 -11
net/wireless/core.h
··· 330 330 int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, 331 331 struct net_device *dev, 332 332 struct ieee80211_channel *chan, 333 - const u8 *bssid, const u8 *prev_bssid, 333 + const u8 *bssid, 334 334 const u8 *ssid, int ssid_len, 335 - const u8 *ie, int ie_len, bool use_mfp, 336 - struct cfg80211_crypto_settings *crypt, 337 - u32 assoc_flags, struct ieee80211_ht_cap *ht_capa, 338 - struct ieee80211_ht_cap *ht_capa_mask); 335 + struct cfg80211_assoc_request *req); 339 336 int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, 340 - struct net_device *dev, struct ieee80211_channel *chan, 341 - const u8 *bssid, const u8 *prev_bssid, 337 + struct net_device *dev, 338 + struct ieee80211_channel *chan, 339 + const u8 *bssid, 342 340 const u8 *ssid, int ssid_len, 343 - const u8 *ie, int ie_len, bool use_mfp, 344 - struct cfg80211_crypto_settings *crypt, 345 - u32 assoc_flags, struct ieee80211_ht_cap *ht_capa, 346 - struct ieee80211_ht_cap *ht_capa_mask); 341 + struct cfg80211_assoc_request *req); 347 342 int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, 348 343 struct net_device *dev, const u8 *bssid, 349 344 const u8 *ie, int ie_len, u16 reason, ··· 370 375 bool no_cck, bool dont_wait_for_ack, u64 *cookie); 371 376 void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa, 372 377 const struct ieee80211_ht_cap *ht_capa_mask); 378 + void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa, 379 + const struct ieee80211_vht_cap *vht_capa_mask); 373 380 374 381 /* SME */ 375 382 int __cfg80211_connect(struct cfg80211_registered_device *rdev, ··· 499 502 500 503 void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev, 501 504 enum nl80211_iftype iftype, int num); 505 + 506 + void cfg80211_leave(struct cfg80211_registered_device *rdev, 507 + struct wireless_dev *wdev); 502 508 503 509 #define CFG80211_MAX_NUM_DIFFERENT_CHANNELS 10 504 510
+1 -14
net/wireless/mesh.c
··· 85 85 .ie = NULL, 86 86 .ie_len = 0, 87 87 .is_secure = false, 88 + .user_mpm = false, 88 89 .beacon_interval = MESH_DEFAULT_BEACON_INTERVAL, 89 90 .dtim_period = MESH_DEFAULT_DTIM_PERIOD, 90 91 }; ··· 233 232 wdev->preset_chandef = *chandef; 234 233 return 0; 235 234 } 236 - 237 - void cfg80211_notify_new_peer_candidate(struct net_device *dev, 238 - const u8 *macaddr, const u8* ie, u8 ie_len, gfp_t gfp) 239 - { 240 - struct wireless_dev *wdev = dev->ieee80211_ptr; 241 - 242 - trace_cfg80211_notify_new_peer_candidate(dev, macaddr); 243 - if (WARN_ON(wdev->iftype != NL80211_IFTYPE_MESH_POINT)) 244 - return; 245 - 246 - nl80211_send_new_peer_candidate(wiphy_to_dev(wdev->wiphy), dev, 247 - macaddr, ie, ie_len, gfp); 248 - } 249 - EXPORT_SYMBOL(cfg80211_notify_new_peer_candidate); 250 235 251 236 static int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, 252 237 struct net_device *dev)
+34 -196
net/wireless/mlme.c
··· 187 187 } 188 188 EXPORT_SYMBOL(cfg80211_send_disassoc); 189 189 190 - void cfg80211_send_unprot_deauth(struct net_device *dev, const u8 *buf, 191 - size_t len) 192 - { 193 - struct wireless_dev *wdev = dev->ieee80211_ptr; 194 - struct wiphy *wiphy = wdev->wiphy; 195 - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 196 - 197 - trace_cfg80211_send_unprot_deauth(dev); 198 - nl80211_send_unprot_deauth(rdev, dev, buf, len, GFP_ATOMIC); 199 - } 200 - EXPORT_SYMBOL(cfg80211_send_unprot_deauth); 201 - 202 - void cfg80211_send_unprot_disassoc(struct net_device *dev, const u8 *buf, 203 - size_t len) 204 - { 205 - struct wireless_dev *wdev = dev->ieee80211_ptr; 206 - struct wiphy *wiphy = wdev->wiphy; 207 - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 208 - 209 - trace_cfg80211_send_unprot_disassoc(dev); 210 - nl80211_send_unprot_disassoc(rdev, dev, buf, len, GFP_ATOMIC); 211 - } 212 - EXPORT_SYMBOL(cfg80211_send_unprot_disassoc); 213 - 214 190 void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr) 215 191 { 216 192 struct wireless_dev *wdev = dev->ieee80211_ptr; ··· 343 367 p1[i] &= p2[i]; 344 368 } 345 369 370 + /* Do a logical ht_capa &= ht_capa_mask. */ 371 + void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa, 372 + const struct ieee80211_vht_cap *vht_capa_mask) 373 + { 374 + int i; 375 + u8 *p1, *p2; 376 + if (!vht_capa_mask) { 377 + memset(vht_capa, 0, sizeof(*vht_capa)); 378 + return; 379 + } 380 + 381 + p1 = (u8*)(vht_capa); 382 + p2 = (u8*)(vht_capa_mask); 383 + for (i = 0; i < sizeof(*vht_capa); i++) 384 + p1[i] &= p2[i]; 385 + } 386 + 346 387 int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, 347 388 struct net_device *dev, 348 389 struct ieee80211_channel *chan, 349 - const u8 *bssid, const u8 *prev_bssid, 390 + const u8 *bssid, 350 391 const u8 *ssid, int ssid_len, 351 - const u8 *ie, int ie_len, bool use_mfp, 352 - struct cfg80211_crypto_settings *crypt, 353 - u32 assoc_flags, struct ieee80211_ht_cap *ht_capa, 354 - struct ieee80211_ht_cap *ht_capa_mask) 392 + struct cfg80211_assoc_request *req) 355 393 { 356 394 struct wireless_dev *wdev = dev->ieee80211_ptr; 357 - struct cfg80211_assoc_request req; 358 395 int err; 359 396 bool was_connected = false; 360 397 361 398 ASSERT_WDEV_LOCK(wdev); 362 399 363 - memset(&req, 0, sizeof(req)); 364 - 365 - if (wdev->current_bss && prev_bssid && 366 - ether_addr_equal(wdev->current_bss->pub.bssid, prev_bssid)) { 400 + if (wdev->current_bss && req->prev_bssid && 401 + ether_addr_equal(wdev->current_bss->pub.bssid, req->prev_bssid)) { 367 402 /* 368 403 * Trying to reassociate: Allow this to proceed and let the old 369 404 * association to be dropped when the new one is completed. ··· 386 399 } else if (wdev->current_bss) 387 400 return -EALREADY; 388 401 389 - req.ie = ie; 390 - req.ie_len = ie_len; 391 - memcpy(&req.crypto, crypt, sizeof(req.crypto)); 392 - req.use_mfp = use_mfp; 393 - req.prev_bssid = prev_bssid; 394 - req.flags = assoc_flags; 395 - if (ht_capa) 396 - memcpy(&req.ht_capa, ht_capa, sizeof(req.ht_capa)); 397 - if (ht_capa_mask) 398 - memcpy(&req.ht_capa_mask, ht_capa_mask, 399 - sizeof(req.ht_capa_mask)); 400 - cfg80211_oper_and_ht_capa(&req.ht_capa_mask, 402 + cfg80211_oper_and_ht_capa(&req->ht_capa_mask, 401 403 rdev->wiphy.ht_capa_mod_mask); 404 + cfg80211_oper_and_vht_capa(&req->vht_capa_mask, 405 + rdev->wiphy.vht_capa_mod_mask); 402 406 403 - req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, 404 - WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); 405 - if (!req.bss) { 407 + req->bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, 408 + WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); 409 + if (!req->bss) { 406 410 if (was_connected) 407 411 wdev->sme_state = CFG80211_SME_CONNECTED; 408 412 return -ENOENT; 409 413 } 410 414 411 - err = cfg80211_can_use_chan(rdev, wdev, req.bss->channel, 412 - CHAN_MODE_SHARED); 415 + err = cfg80211_can_use_chan(rdev, wdev, chan, CHAN_MODE_SHARED); 413 416 if (err) 414 417 goto out; 415 418 416 - err = rdev_assoc(rdev, dev, &req); 419 + err = rdev_assoc(rdev, dev, req); 417 420 418 421 out: 419 422 if (err) { 420 423 if (was_connected) 421 424 wdev->sme_state = CFG80211_SME_CONNECTED; 422 - cfg80211_put_bss(&rdev->wiphy, req.bss); 425 + cfg80211_put_bss(&rdev->wiphy, req->bss); 423 426 } 424 427 425 428 return err; ··· 418 441 int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, 419 442 struct net_device *dev, 420 443 struct ieee80211_channel *chan, 421 - const u8 *bssid, const u8 *prev_bssid, 444 + const u8 *bssid, 422 445 const u8 *ssid, int ssid_len, 423 - const u8 *ie, int ie_len, bool use_mfp, 424 - struct cfg80211_crypto_settings *crypt, 425 - u32 assoc_flags, struct ieee80211_ht_cap *ht_capa, 426 - struct ieee80211_ht_cap *ht_capa_mask) 446 + struct cfg80211_assoc_request *req) 427 447 { 428 448 struct wireless_dev *wdev = dev->ieee80211_ptr; 429 449 int err; 430 450 431 451 mutex_lock(&rdev->devlist_mtx); 432 452 wdev_lock(wdev); 433 - err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid, 434 - ssid, ssid_len, ie, ie_len, use_mfp, crypt, 435 - assoc_flags, ht_capa, ht_capa_mask); 453 + err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid, 454 + ssid, ssid_len, req); 436 455 wdev_unlock(wdev); 437 456 mutex_unlock(&rdev->devlist_mtx); 438 457 ··· 549 576 wdev->current_bss = NULL; 550 577 } 551 578 } 552 - 553 - void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie, 554 - struct ieee80211_channel *chan, 555 - unsigned int duration, gfp_t gfp) 556 - { 557 - struct wiphy *wiphy = wdev->wiphy; 558 - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 559 - 560 - trace_cfg80211_ready_on_channel(wdev, cookie, chan, duration); 561 - nl80211_send_remain_on_channel(rdev, wdev, cookie, chan, duration, gfp); 562 - } 563 - EXPORT_SYMBOL(cfg80211_ready_on_channel); 564 - 565 - void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie, 566 - struct ieee80211_channel *chan, 567 - gfp_t gfp) 568 - { 569 - struct wiphy *wiphy = wdev->wiphy; 570 - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 571 - 572 - trace_cfg80211_ready_on_channel_expired(wdev, cookie, chan); 573 - nl80211_send_remain_on_channel_cancel(rdev, wdev, cookie, chan, gfp); 574 - } 575 - EXPORT_SYMBOL(cfg80211_remain_on_channel_expired); 576 - 577 - void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr, 578 - struct station_info *sinfo, gfp_t gfp) 579 - { 580 - struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; 581 - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 582 - 583 - trace_cfg80211_new_sta(dev, mac_addr, sinfo); 584 - nl80211_send_sta_event(rdev, dev, mac_addr, sinfo, gfp); 585 - } 586 - EXPORT_SYMBOL(cfg80211_new_sta); 587 - 588 - void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp) 589 - { 590 - struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; 591 - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 592 - 593 - trace_cfg80211_del_sta(dev, mac_addr); 594 - nl80211_send_sta_del_event(rdev, dev, mac_addr, gfp); 595 - } 596 - EXPORT_SYMBOL(cfg80211_del_sta); 597 - 598 - void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr, 599 - enum nl80211_connect_failed_reason reason, 600 - gfp_t gfp) 601 - { 602 - struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; 603 - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 604 - 605 - nl80211_send_conn_failed_event(rdev, dev, mac_addr, reason, gfp); 606 - } 607 - EXPORT_SYMBOL(cfg80211_conn_failed); 608 579 609 580 struct cfg80211_mgmt_registration { 610 581 struct list_head list; ··· 825 908 return result; 826 909 } 827 910 EXPORT_SYMBOL(cfg80211_rx_mgmt); 828 - 829 - void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie, 830 - const u8 *buf, size_t len, bool ack, gfp_t gfp) 831 - { 832 - struct wiphy *wiphy = wdev->wiphy; 833 - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 834 - 835 - trace_cfg80211_mgmt_tx_status(wdev, cookie, ack); 836 - 837 - /* Indicate TX status of the Action frame to user space */ 838 - nl80211_send_mgmt_tx_status(rdev, wdev, cookie, buf, len, ack, gfp); 839 - } 840 - EXPORT_SYMBOL(cfg80211_mgmt_tx_status); 841 - 842 - void cfg80211_cqm_rssi_notify(struct net_device *dev, 843 - enum nl80211_cqm_rssi_threshold_event rssi_event, 844 - gfp_t gfp) 845 - { 846 - struct wireless_dev *wdev = dev->ieee80211_ptr; 847 - struct wiphy *wiphy = wdev->wiphy; 848 - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 849 - 850 - trace_cfg80211_cqm_rssi_notify(dev, rssi_event); 851 - 852 - /* Indicate roaming trigger event to user space */ 853 - nl80211_send_cqm_rssi_notify(rdev, dev, rssi_event, gfp); 854 - } 855 - EXPORT_SYMBOL(cfg80211_cqm_rssi_notify); 856 - 857 - void cfg80211_cqm_pktloss_notify(struct net_device *dev, 858 - const u8 *peer, u32 num_packets, gfp_t gfp) 859 - { 860 - struct wireless_dev *wdev = dev->ieee80211_ptr; 861 - struct wiphy *wiphy = wdev->wiphy; 862 - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 863 - 864 - trace_cfg80211_cqm_pktloss_notify(dev, peer, num_packets); 865 - 866 - /* Indicate roaming trigger event to user space */ 867 - nl80211_send_cqm_pktloss_notify(rdev, dev, peer, num_packets, gfp); 868 - } 869 - EXPORT_SYMBOL(cfg80211_cqm_pktloss_notify); 870 - 871 - void cfg80211_cqm_txe_notify(struct net_device *dev, 872 - const u8 *peer, u32 num_packets, 873 - u32 rate, u32 intvl, gfp_t gfp) 874 - { 875 - struct wireless_dev *wdev = dev->ieee80211_ptr; 876 - struct wiphy *wiphy = wdev->wiphy; 877 - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 878 - 879 - nl80211_send_cqm_txe_notify(rdev, dev, peer, num_packets, 880 - rate, intvl, gfp); 881 - } 882 - EXPORT_SYMBOL(cfg80211_cqm_txe_notify); 883 - 884 - void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid, 885 - const u8 *replay_ctr, gfp_t gfp) 886 - { 887 - struct wireless_dev *wdev = dev->ieee80211_ptr; 888 - struct wiphy *wiphy = wdev->wiphy; 889 - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 890 - 891 - trace_cfg80211_gtk_rekey_notify(dev, bssid); 892 - nl80211_gtk_rekey_notify(rdev, dev, bssid, replay_ctr, gfp); 893 - } 894 - EXPORT_SYMBOL(cfg80211_gtk_rekey_notify); 895 - 896 - void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index, 897 - const u8 *bssid, bool preauth, gfp_t gfp) 898 - { 899 - struct wireless_dev *wdev = dev->ieee80211_ptr; 900 - struct wiphy *wiphy = wdev->wiphy; 901 - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 902 - 903 - trace_cfg80211_pmksa_candidate_notify(dev, index, bssid, preauth); 904 - nl80211_pmksa_candidate_notify(rdev, dev, index, bssid, preauth, gfp); 905 - } 906 - EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify); 907 911 908 912 void cfg80211_dfs_channels_update_work(struct work_struct *work) 909 913 {
+1199 -644
net/wireless/nl80211.c
··· 370 370 [NL80211_ATTR_MAC_ADDRS] = { .type = NLA_NESTED }, 371 371 [NL80211_ATTR_STA_CAPABILITY] = { .type = NLA_U16 }, 372 372 [NL80211_ATTR_STA_EXT_CAPABILITY] = { .type = NLA_BINARY, }, 373 + [NL80211_ATTR_SPLIT_WIPHY_DUMP] = { .type = NLA_FLAG, }, 374 + [NL80211_ATTR_DISABLE_VHT] = { .type = NLA_FLAG }, 375 + [NL80211_ATTR_VHT_CAPABILITY_MASK] = { 376 + .len = NL80211_VHT_CAPABILITY_LEN, 377 + }, 378 + [NL80211_ATTR_MDID] = { .type = NLA_U16 }, 379 + [NL80211_ATTR_IE_RIC] = { .type = NLA_BINARY, 380 + .len = IEEE80211_MAX_DATA_LEN }, 373 381 }; 374 382 375 383 /* policy for the key attributes */ ··· 547 539 } 548 540 549 541 static int nl80211_msg_put_channel(struct sk_buff *msg, 550 - struct ieee80211_channel *chan) 542 + struct ieee80211_channel *chan, 543 + bool large) 551 544 { 552 545 if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_FREQ, 553 546 chan->center_freq)) ··· 564 555 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_IBSS)) 565 556 goto nla_put_failure; 566 557 if (chan->flags & IEEE80211_CHAN_RADAR) { 567 - u32 time = elapsed_jiffies_msecs(chan->dfs_state_entered); 568 558 if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR)) 569 559 goto nla_put_failure; 570 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_STATE, 571 - chan->dfs_state)) 560 + if (large) { 561 + u32 time; 562 + 563 + time = elapsed_jiffies_msecs(chan->dfs_state_entered); 564 + 565 + if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_STATE, 566 + chan->dfs_state)) 567 + goto nla_put_failure; 568 + if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_TIME, 569 + time)) 570 + goto nla_put_failure; 571 + } 572 + } 573 + 574 + if (large) { 575 + if ((chan->flags & IEEE80211_CHAN_NO_HT40MINUS) && 576 + nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_HT40_MINUS)) 572 577 goto nla_put_failure; 573 - if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_DFS_TIME, time)) 578 + if ((chan->flags & IEEE80211_CHAN_NO_HT40PLUS) && 579 + nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_HT40_PLUS)) 580 + goto nla_put_failure; 581 + if ((chan->flags & IEEE80211_CHAN_NO_80MHZ) && 582 + nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_80MHZ)) 583 + goto nla_put_failure; 584 + if ((chan->flags & IEEE80211_CHAN_NO_160MHZ) && 585 + nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_160MHZ)) 574 586 goto nla_put_failure; 575 587 } 576 - if ((chan->flags & IEEE80211_CHAN_NO_HT40MINUS) && 577 - nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_HT40_MINUS)) 578 - goto nla_put_failure; 579 - if ((chan->flags & IEEE80211_CHAN_NO_HT40PLUS) && 580 - nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_HT40_PLUS)) 581 - goto nla_put_failure; 582 - if ((chan->flags & IEEE80211_CHAN_NO_80MHZ) && 583 - nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_80MHZ)) 584 - goto nla_put_failure; 585 - if ((chan->flags & IEEE80211_CHAN_NO_160MHZ) && 586 - nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_160MHZ)) 587 - goto nla_put_failure; 588 588 589 589 if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_MAX_TX_POWER, 590 590 DBM_TO_MBM(chan->max_power))) ··· 869 851 } 870 852 871 853 static int nl80211_put_iface_combinations(struct wiphy *wiphy, 872 - struct sk_buff *msg) 854 + struct sk_buff *msg, 855 + bool large) 873 856 { 874 857 struct nlattr *nl_combis; 875 858 int i, j; ··· 919 900 nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM, 920 901 c->max_interfaces)) 921 902 goto nla_put_failure; 922 - if (nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS, 903 + if (large && 904 + nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS, 923 905 c->radar_detect_widths)) 924 906 goto nla_put_failure; 925 907 ··· 974 954 nla_nest_end(msg, nl_tcp); 975 955 return 0; 976 956 } 957 + 958 + static int nl80211_send_wowlan(struct sk_buff *msg, 959 + struct cfg80211_registered_device *dev, 960 + bool large) 961 + { 962 + struct nlattr *nl_wowlan; 963 + 964 + if (!dev->wiphy.wowlan.flags && !dev->wiphy.wowlan.n_patterns) 965 + return 0; 966 + 967 + nl_wowlan = nla_nest_start(msg, NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED); 968 + if (!nl_wowlan) 969 + return -ENOBUFS; 970 + 971 + if (((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_ANY) && 972 + nla_put_flag(msg, NL80211_WOWLAN_TRIG_ANY)) || 973 + ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_DISCONNECT) && 974 + nla_put_flag(msg, NL80211_WOWLAN_TRIG_DISCONNECT)) || 975 + ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_MAGIC_PKT) && 976 + nla_put_flag(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT)) || 977 + ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY) && 978 + nla_put_flag(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED)) || 979 + ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) && 980 + nla_put_flag(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE)) || 981 + ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_EAP_IDENTITY_REQ) && 982 + nla_put_flag(msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST)) || 983 + ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_4WAY_HANDSHAKE) && 984 + nla_put_flag(msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE)) || 985 + ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_RFKILL_RELEASE) && 986 + nla_put_flag(msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE))) 987 + return -ENOBUFS; 988 + 989 + if (dev->wiphy.wowlan.n_patterns) { 990 + struct nl80211_wowlan_pattern_support pat = { 991 + .max_patterns = dev->wiphy.wowlan.n_patterns, 992 + .min_pattern_len = dev->wiphy.wowlan.pattern_min_len, 993 + .max_pattern_len = dev->wiphy.wowlan.pattern_max_len, 994 + .max_pkt_offset = dev->wiphy.wowlan.max_pkt_offset, 995 + }; 996 + 997 + if (nla_put(msg, NL80211_WOWLAN_TRIG_PKT_PATTERN, 998 + sizeof(pat), &pat)) 999 + return -ENOBUFS; 1000 + } 1001 + 1002 + if (large && nl80211_send_wowlan_tcp_caps(dev, msg)) 1003 + return -ENOBUFS; 1004 + 1005 + nla_nest_end(msg, nl_wowlan); 1006 + 1007 + return 0; 1008 + } 977 1009 #endif 978 1010 979 - static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flags, 980 - struct cfg80211_registered_device *dev) 1011 + static int nl80211_send_band_rateinfo(struct sk_buff *msg, 1012 + struct ieee80211_supported_band *sband) 1013 + { 1014 + struct nlattr *nl_rates, *nl_rate; 1015 + struct ieee80211_rate *rate; 1016 + int i; 1017 + 1018 + /* add HT info */ 1019 + if (sband->ht_cap.ht_supported && 1020 + (nla_put(msg, NL80211_BAND_ATTR_HT_MCS_SET, 1021 + sizeof(sband->ht_cap.mcs), 1022 + &sband->ht_cap.mcs) || 1023 + nla_put_u16(msg, NL80211_BAND_ATTR_HT_CAPA, 1024 + sband->ht_cap.cap) || 1025 + nla_put_u8(msg, NL80211_BAND_ATTR_HT_AMPDU_FACTOR, 1026 + sband->ht_cap.ampdu_factor) || 1027 + nla_put_u8(msg, NL80211_BAND_ATTR_HT_AMPDU_DENSITY, 1028 + sband->ht_cap.ampdu_density))) 1029 + return -ENOBUFS; 1030 + 1031 + /* add VHT info */ 1032 + if (sband->vht_cap.vht_supported && 1033 + (nla_put(msg, NL80211_BAND_ATTR_VHT_MCS_SET, 1034 + sizeof(sband->vht_cap.vht_mcs), 1035 + &sband->vht_cap.vht_mcs) || 1036 + nla_put_u32(msg, NL80211_BAND_ATTR_VHT_CAPA, 1037 + sband->vht_cap.cap))) 1038 + return -ENOBUFS; 1039 + 1040 + /* add bitrates */ 1041 + nl_rates = nla_nest_start(msg, NL80211_BAND_ATTR_RATES); 1042 + if (!nl_rates) 1043 + return -ENOBUFS; 1044 + 1045 + for (i = 0; i < sband->n_bitrates; i++) { 1046 + nl_rate = nla_nest_start(msg, i); 1047 + if (!nl_rate) 1048 + return -ENOBUFS; 1049 + 1050 + rate = &sband->bitrates[i]; 1051 + if (nla_put_u32(msg, NL80211_BITRATE_ATTR_RATE, 1052 + rate->bitrate)) 1053 + return -ENOBUFS; 1054 + if ((rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) && 1055 + nla_put_flag(msg, 1056 + NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE)) 1057 + return -ENOBUFS; 1058 + 1059 + nla_nest_end(msg, nl_rate); 1060 + } 1061 + 1062 + nla_nest_end(msg, nl_rates); 1063 + 1064 + return 0; 1065 + } 1066 + 1067 + static int 1068 + nl80211_send_mgmt_stypes(struct sk_buff *msg, 1069 + const struct ieee80211_txrx_stypes *mgmt_stypes) 1070 + { 1071 + u16 stypes; 1072 + struct nlattr *nl_ftypes, *nl_ifs; 1073 + enum nl80211_iftype ift; 1074 + int i; 1075 + 1076 + if (!mgmt_stypes) 1077 + return 0; 1078 + 1079 + nl_ifs = nla_nest_start(msg, NL80211_ATTR_TX_FRAME_TYPES); 1080 + if (!nl_ifs) 1081 + return -ENOBUFS; 1082 + 1083 + for (ift = 0; ift < NUM_NL80211_IFTYPES; ift++) { 1084 + nl_ftypes = nla_nest_start(msg, ift); 1085 + if (!nl_ftypes) 1086 + return -ENOBUFS; 1087 + i = 0; 1088 + stypes = mgmt_stypes[ift].tx; 1089 + while (stypes) { 1090 + if ((stypes & 1) && 1091 + nla_put_u16(msg, NL80211_ATTR_FRAME_TYPE, 1092 + (i << 4) | IEEE80211_FTYPE_MGMT)) 1093 + return -ENOBUFS; 1094 + stypes >>= 1; 1095 + i++; 1096 + } 1097 + nla_nest_end(msg, nl_ftypes); 1098 + } 1099 + 1100 + nla_nest_end(msg, nl_ifs); 1101 + 1102 + nl_ifs = nla_nest_start(msg, NL80211_ATTR_RX_FRAME_TYPES); 1103 + if (!nl_ifs) 1104 + return -ENOBUFS; 1105 + 1106 + for (ift = 0; ift < NUM_NL80211_IFTYPES; ift++) { 1107 + nl_ftypes = nla_nest_start(msg, ift); 1108 + if (!nl_ftypes) 1109 + return -ENOBUFS; 1110 + i = 0; 1111 + stypes = mgmt_stypes[ift].rx; 1112 + while (stypes) { 1113 + if ((stypes & 1) && 1114 + nla_put_u16(msg, NL80211_ATTR_FRAME_TYPE, 1115 + (i << 4) | IEEE80211_FTYPE_MGMT)) 1116 + return -ENOBUFS; 1117 + stypes >>= 1; 1118 + i++; 1119 + } 1120 + nla_nest_end(msg, nl_ftypes); 1121 + } 1122 + nla_nest_end(msg, nl_ifs); 1123 + 1124 + return 0; 1125 + } 1126 + 1127 + static int nl80211_send_wiphy(struct cfg80211_registered_device *dev, 1128 + struct sk_buff *msg, u32 portid, u32 seq, 1129 + int flags, bool split, long *split_start, 1130 + long *band_start, long *chan_start) 981 1131 { 982 1132 void *hdr; 983 1133 struct nlattr *nl_bands, *nl_band; 984 1134 struct nlattr *nl_freqs, *nl_freq; 985 - struct nlattr *nl_rates, *nl_rate; 986 1135 struct nlattr *nl_cmds; 987 1136 enum ieee80211_band band; 988 1137 struct ieee80211_channel *chan; 989 - struct ieee80211_rate *rate; 990 1138 int i; 991 1139 const struct ieee80211_txrx_stypes *mgmt_stypes = 992 1140 dev->wiphy.mgmt_stypes; 1141 + long start = 0, start_chan = 0, start_band = 0; 1142 + u32 features; 993 1143 994 1144 hdr = nl80211hdr_put(msg, portid, seq, flags, NL80211_CMD_NEW_WIPHY); 995 1145 if (!hdr) 996 - return -1; 1146 + return -ENOBUFS; 1147 + 1148 + /* allow always using the variables */ 1149 + if (!split) { 1150 + split_start = &start; 1151 + band_start = &start_band; 1152 + chan_start = &start_chan; 1153 + } 997 1154 998 1155 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, dev->wiphy_idx) || 999 - nla_put_string(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy)) || 1156 + nla_put_string(msg, NL80211_ATTR_WIPHY_NAME, 1157 + wiphy_name(&dev->wiphy)) || 1000 1158 nla_put_u32(msg, NL80211_ATTR_GENERATION, 1001 - cfg80211_rdev_list_generation) || 1002 - nla_put_u8(msg, NL80211_ATTR_WIPHY_RETRY_SHORT, 1003 - dev->wiphy.retry_short) || 1004 - nla_put_u8(msg, NL80211_ATTR_WIPHY_RETRY_LONG, 1005 - dev->wiphy.retry_long) || 1006 - nla_put_u32(msg, NL80211_ATTR_WIPHY_FRAG_THRESHOLD, 1007 - dev->wiphy.frag_threshold) || 1008 - nla_put_u32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD, 1009 - dev->wiphy.rts_threshold) || 1010 - nla_put_u8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS, 1011 - dev->wiphy.coverage_class) || 1012 - nla_put_u8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS, 1013 - dev->wiphy.max_scan_ssids) || 1014 - nla_put_u8(msg, NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS, 1015 - dev->wiphy.max_sched_scan_ssids) || 1016 - nla_put_u16(msg, NL80211_ATTR_MAX_SCAN_IE_LEN, 1017 - dev->wiphy.max_scan_ie_len) || 1018 - nla_put_u16(msg, NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN, 1019 - dev->wiphy.max_sched_scan_ie_len) || 1020 - nla_put_u8(msg, NL80211_ATTR_MAX_MATCH_SETS, 1021 - dev->wiphy.max_match_sets)) 1159 + cfg80211_rdev_list_generation)) 1022 1160 goto nla_put_failure; 1023 1161 1024 - if ((dev->wiphy.flags & WIPHY_FLAG_IBSS_RSN) && 1025 - nla_put_flag(msg, NL80211_ATTR_SUPPORT_IBSS_RSN)) 1026 - goto nla_put_failure; 1027 - if ((dev->wiphy.flags & WIPHY_FLAG_MESH_AUTH) && 1028 - nla_put_flag(msg, NL80211_ATTR_SUPPORT_MESH_AUTH)) 1029 - goto nla_put_failure; 1030 - if ((dev->wiphy.flags & WIPHY_FLAG_AP_UAPSD) && 1031 - nla_put_flag(msg, NL80211_ATTR_SUPPORT_AP_UAPSD)) 1032 - goto nla_put_failure; 1033 - if ((dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_FW_ROAM) && 1034 - nla_put_flag(msg, NL80211_ATTR_ROAM_SUPPORT)) 1035 - goto nla_put_failure; 1036 - if ((dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) && 1037 - nla_put_flag(msg, NL80211_ATTR_TDLS_SUPPORT)) 1038 - goto nla_put_failure; 1039 - if ((dev->wiphy.flags & WIPHY_FLAG_TDLS_EXTERNAL_SETUP) && 1040 - nla_put_flag(msg, NL80211_ATTR_TDLS_EXTERNAL_SETUP)) 1041 - goto nla_put_failure; 1042 - 1043 - if (nla_put(msg, NL80211_ATTR_CIPHER_SUITES, 1044 - sizeof(u32) * dev->wiphy.n_cipher_suites, 1045 - dev->wiphy.cipher_suites)) 1046 - goto nla_put_failure; 1047 - 1048 - if (nla_put_u8(msg, NL80211_ATTR_MAX_NUM_PMKIDS, 1049 - dev->wiphy.max_num_pmkids)) 1050 - goto nla_put_failure; 1051 - 1052 - if ((dev->wiphy.flags & WIPHY_FLAG_CONTROL_PORT_PROTOCOL) && 1053 - nla_put_flag(msg, NL80211_ATTR_CONTROL_PORT_ETHERTYPE)) 1054 - goto nla_put_failure; 1055 - 1056 - if (nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX, 1057 - dev->wiphy.available_antennas_tx) || 1058 - nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX, 1059 - dev->wiphy.available_antennas_rx)) 1060 - goto nla_put_failure; 1061 - 1062 - if ((dev->wiphy.flags & WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD) && 1063 - nla_put_u32(msg, NL80211_ATTR_PROBE_RESP_OFFLOAD, 1064 - dev->wiphy.probe_resp_offload)) 1065 - goto nla_put_failure; 1066 - 1067 - if ((dev->wiphy.available_antennas_tx || 1068 - dev->wiphy.available_antennas_rx) && dev->ops->get_antenna) { 1069 - u32 tx_ant = 0, rx_ant = 0; 1070 - int res; 1071 - res = rdev_get_antenna(dev, &tx_ant, &rx_ant); 1072 - if (!res) { 1073 - if (nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_TX, 1074 - tx_ant) || 1075 - nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_RX, 1076 - rx_ant)) 1077 - goto nla_put_failure; 1078 - } 1079 - } 1080 - 1081 - if (nl80211_put_iftypes(msg, NL80211_ATTR_SUPPORTED_IFTYPES, 1082 - dev->wiphy.interface_modes)) 1083 - goto nla_put_failure; 1084 - 1085 - nl_bands = nla_nest_start(msg, NL80211_ATTR_WIPHY_BANDS); 1086 - if (!nl_bands) 1087 - goto nla_put_failure; 1088 - 1089 - for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 1090 - if (!dev->wiphy.bands[band]) 1091 - continue; 1092 - 1093 - nl_band = nla_nest_start(msg, band); 1094 - if (!nl_band) 1162 + switch (*split_start) { 1163 + case 0: 1164 + if (nla_put_u8(msg, NL80211_ATTR_WIPHY_RETRY_SHORT, 1165 + dev->wiphy.retry_short) || 1166 + nla_put_u8(msg, NL80211_ATTR_WIPHY_RETRY_LONG, 1167 + dev->wiphy.retry_long) || 1168 + nla_put_u32(msg, NL80211_ATTR_WIPHY_FRAG_THRESHOLD, 1169 + dev->wiphy.frag_threshold) || 1170 + nla_put_u32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD, 1171 + dev->wiphy.rts_threshold) || 1172 + nla_put_u8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS, 1173 + dev->wiphy.coverage_class) || 1174 + nla_put_u8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS, 1175 + dev->wiphy.max_scan_ssids) || 1176 + nla_put_u8(msg, NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS, 1177 + dev->wiphy.max_sched_scan_ssids) || 1178 + nla_put_u16(msg, NL80211_ATTR_MAX_SCAN_IE_LEN, 1179 + dev->wiphy.max_scan_ie_len) || 1180 + nla_put_u16(msg, NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN, 1181 + dev->wiphy.max_sched_scan_ie_len) || 1182 + nla_put_u8(msg, NL80211_ATTR_MAX_MATCH_SETS, 1183 + dev->wiphy.max_match_sets)) 1095 1184 goto nla_put_failure; 1096 1185 1097 - /* add HT info */ 1098 - if (dev->wiphy.bands[band]->ht_cap.ht_supported && 1099 - (nla_put(msg, NL80211_BAND_ATTR_HT_MCS_SET, 1100 - sizeof(dev->wiphy.bands[band]->ht_cap.mcs), 1101 - &dev->wiphy.bands[band]->ht_cap.mcs) || 1102 - nla_put_u16(msg, NL80211_BAND_ATTR_HT_CAPA, 1103 - dev->wiphy.bands[band]->ht_cap.cap) || 1104 - nla_put_u8(msg, NL80211_BAND_ATTR_HT_AMPDU_FACTOR, 1105 - dev->wiphy.bands[band]->ht_cap.ampdu_factor) || 1106 - nla_put_u8(msg, NL80211_BAND_ATTR_HT_AMPDU_DENSITY, 1107 - dev->wiphy.bands[band]->ht_cap.ampdu_density))) 1186 + if ((dev->wiphy.flags & WIPHY_FLAG_IBSS_RSN) && 1187 + nla_put_flag(msg, NL80211_ATTR_SUPPORT_IBSS_RSN)) 1188 + goto nla_put_failure; 1189 + if ((dev->wiphy.flags & WIPHY_FLAG_MESH_AUTH) && 1190 + nla_put_flag(msg, NL80211_ATTR_SUPPORT_MESH_AUTH)) 1191 + goto nla_put_failure; 1192 + if ((dev->wiphy.flags & WIPHY_FLAG_AP_UAPSD) && 1193 + nla_put_flag(msg, NL80211_ATTR_SUPPORT_AP_UAPSD)) 1194 + goto nla_put_failure; 1195 + if ((dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_FW_ROAM) && 1196 + nla_put_flag(msg, NL80211_ATTR_ROAM_SUPPORT)) 1197 + goto nla_put_failure; 1198 + if ((dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) && 1199 + nla_put_flag(msg, NL80211_ATTR_TDLS_SUPPORT)) 1200 + goto nla_put_failure; 1201 + if ((dev->wiphy.flags & WIPHY_FLAG_TDLS_EXTERNAL_SETUP) && 1202 + nla_put_flag(msg, NL80211_ATTR_TDLS_EXTERNAL_SETUP)) 1108 1203 goto nla_put_failure; 1109 1204 1110 - /* add VHT info */ 1111 - if (dev->wiphy.bands[band]->vht_cap.vht_supported && 1112 - (nla_put(msg, NL80211_BAND_ATTR_VHT_MCS_SET, 1113 - sizeof(dev->wiphy.bands[band]->vht_cap.vht_mcs), 1114 - &dev->wiphy.bands[band]->vht_cap.vht_mcs) || 1115 - nla_put_u32(msg, NL80211_BAND_ATTR_VHT_CAPA, 1116 - dev->wiphy.bands[band]->vht_cap.cap))) 1205 + (*split_start)++; 1206 + if (split) 1207 + break; 1208 + case 1: 1209 + if (nla_put(msg, NL80211_ATTR_CIPHER_SUITES, 1210 + sizeof(u32) * dev->wiphy.n_cipher_suites, 1211 + dev->wiphy.cipher_suites)) 1117 1212 goto nla_put_failure; 1118 1213 1119 - /* add frequencies */ 1120 - nl_freqs = nla_nest_start(msg, NL80211_BAND_ATTR_FREQS); 1121 - if (!nl_freqs) 1214 + if (nla_put_u8(msg, NL80211_ATTR_MAX_NUM_PMKIDS, 1215 + dev->wiphy.max_num_pmkids)) 1122 1216 goto nla_put_failure; 1123 1217 1124 - for (i = 0; i < dev->wiphy.bands[band]->n_channels; i++) { 1125 - nl_freq = nla_nest_start(msg, i); 1126 - if (!nl_freq) 1127 - goto nla_put_failure; 1218 + if ((dev->wiphy.flags & WIPHY_FLAG_CONTROL_PORT_PROTOCOL) && 1219 + nla_put_flag(msg, NL80211_ATTR_CONTROL_PORT_ETHERTYPE)) 1220 + goto nla_put_failure; 1128 1221 1129 - chan = &dev->wiphy.bands[band]->channels[i]; 1222 + if (nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX, 1223 + dev->wiphy.available_antennas_tx) || 1224 + nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX, 1225 + dev->wiphy.available_antennas_rx)) 1226 + goto nla_put_failure; 1130 1227 1131 - if (nl80211_msg_put_channel(msg, chan)) 1132 - goto nla_put_failure; 1228 + if ((dev->wiphy.flags & WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD) && 1229 + nla_put_u32(msg, NL80211_ATTR_PROBE_RESP_OFFLOAD, 1230 + dev->wiphy.probe_resp_offload)) 1231 + goto nla_put_failure; 1133 1232 1134 - nla_nest_end(msg, nl_freq); 1233 + if ((dev->wiphy.available_antennas_tx || 1234 + dev->wiphy.available_antennas_rx) && 1235 + dev->ops->get_antenna) { 1236 + u32 tx_ant = 0, rx_ant = 0; 1237 + int res; 1238 + res = rdev_get_antenna(dev, &tx_ant, &rx_ant); 1239 + if (!res) { 1240 + if (nla_put_u32(msg, 1241 + NL80211_ATTR_WIPHY_ANTENNA_TX, 1242 + tx_ant) || 1243 + nla_put_u32(msg, 1244 + NL80211_ATTR_WIPHY_ANTENNA_RX, 1245 + rx_ant)) 1246 + goto nla_put_failure; 1247 + } 1135 1248 } 1136 1249 1137 - nla_nest_end(msg, nl_freqs); 1138 - 1139 - /* add bitrates */ 1140 - nl_rates = nla_nest_start(msg, NL80211_BAND_ATTR_RATES); 1141 - if (!nl_rates) 1250 + (*split_start)++; 1251 + if (split) 1252 + break; 1253 + case 2: 1254 + if (nl80211_put_iftypes(msg, NL80211_ATTR_SUPPORTED_IFTYPES, 1255 + dev->wiphy.interface_modes)) 1256 + goto nla_put_failure; 1257 + (*split_start)++; 1258 + if (split) 1259 + break; 1260 + case 3: 1261 + nl_bands = nla_nest_start(msg, NL80211_ATTR_WIPHY_BANDS); 1262 + if (!nl_bands) 1142 1263 goto nla_put_failure; 1143 1264 1144 - for (i = 0; i < dev->wiphy.bands[band]->n_bitrates; i++) { 1145 - nl_rate = nla_nest_start(msg, i); 1146 - if (!nl_rate) 1265 + for (band = *band_start; band < IEEE80211_NUM_BANDS; band++) { 1266 + struct ieee80211_supported_band *sband; 1267 + 1268 + sband = dev->wiphy.bands[band]; 1269 + 1270 + if (!sband) 1271 + continue; 1272 + 1273 + nl_band = nla_nest_start(msg, band); 1274 + if (!nl_band) 1147 1275 goto nla_put_failure; 1148 1276 1149 - rate = &dev->wiphy.bands[band]->bitrates[i]; 1150 - if (nla_put_u32(msg, NL80211_BITRATE_ATTR_RATE, 1151 - rate->bitrate)) 1152 - goto nla_put_failure; 1153 - if ((rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) && 1154 - nla_put_flag(msg, 1155 - NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE)) 1156 - goto nla_put_failure; 1277 + switch (*chan_start) { 1278 + case 0: 1279 + if (nl80211_send_band_rateinfo(msg, sband)) 1280 + goto nla_put_failure; 1281 + (*chan_start)++; 1282 + if (split) 1283 + break; 1284 + default: 1285 + /* add frequencies */ 1286 + nl_freqs = nla_nest_start( 1287 + msg, NL80211_BAND_ATTR_FREQS); 1288 + if (!nl_freqs) 1289 + goto nla_put_failure; 1157 1290 1158 - nla_nest_end(msg, nl_rate); 1291 + for (i = *chan_start - 1; 1292 + i < sband->n_channels; 1293 + i++) { 1294 + nl_freq = nla_nest_start(msg, i); 1295 + if (!nl_freq) 1296 + goto nla_put_failure; 1297 + 1298 + chan = &sband->channels[i]; 1299 + 1300 + if (nl80211_msg_put_channel(msg, chan, 1301 + split)) 1302 + goto nla_put_failure; 1303 + 1304 + nla_nest_end(msg, nl_freq); 1305 + if (split) 1306 + break; 1307 + } 1308 + if (i < sband->n_channels) 1309 + *chan_start = i + 2; 1310 + else 1311 + *chan_start = 0; 1312 + nla_nest_end(msg, nl_freqs); 1313 + } 1314 + 1315 + nla_nest_end(msg, nl_band); 1316 + 1317 + if (split) { 1318 + /* start again here */ 1319 + if (*chan_start) 1320 + band--; 1321 + break; 1322 + } 1159 1323 } 1324 + nla_nest_end(msg, nl_bands); 1160 1325 1161 - nla_nest_end(msg, nl_rates); 1326 + if (band < IEEE80211_NUM_BANDS) 1327 + *band_start = band + 1; 1328 + else 1329 + *band_start = 0; 1162 1330 1163 - nla_nest_end(msg, nl_band); 1164 - } 1165 - nla_nest_end(msg, nl_bands); 1166 - 1167 - nl_cmds = nla_nest_start(msg, NL80211_ATTR_SUPPORTED_COMMANDS); 1168 - if (!nl_cmds) 1169 - goto nla_put_failure; 1170 - 1171 - i = 0; 1172 - #define CMD(op, n) \ 1173 - do { \ 1174 - if (dev->ops->op) { \ 1175 - i++; \ 1176 - if (nla_put_u32(msg, i, NL80211_CMD_ ## n)) \ 1177 - goto nla_put_failure; \ 1178 - } \ 1179 - } while (0) 1180 - 1181 - CMD(add_virtual_intf, NEW_INTERFACE); 1182 - CMD(change_virtual_intf, SET_INTERFACE); 1183 - CMD(add_key, NEW_KEY); 1184 - CMD(start_ap, START_AP); 1185 - CMD(add_station, NEW_STATION); 1186 - CMD(add_mpath, NEW_MPATH); 1187 - CMD(update_mesh_config, SET_MESH_CONFIG); 1188 - CMD(change_bss, SET_BSS); 1189 - CMD(auth, AUTHENTICATE); 1190 - CMD(assoc, ASSOCIATE); 1191 - CMD(deauth, DEAUTHENTICATE); 1192 - CMD(disassoc, DISASSOCIATE); 1193 - CMD(join_ibss, JOIN_IBSS); 1194 - CMD(join_mesh, JOIN_MESH); 1195 - CMD(set_pmksa, SET_PMKSA); 1196 - CMD(del_pmksa, DEL_PMKSA); 1197 - CMD(flush_pmksa, FLUSH_PMKSA); 1198 - if (dev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL) 1199 - CMD(remain_on_channel, REMAIN_ON_CHANNEL); 1200 - CMD(set_bitrate_mask, SET_TX_BITRATE_MASK); 1201 - CMD(mgmt_tx, FRAME); 1202 - CMD(mgmt_tx_cancel_wait, FRAME_WAIT_CANCEL); 1203 - if (dev->wiphy.flags & WIPHY_FLAG_NETNS_OK) { 1204 - i++; 1205 - if (nla_put_u32(msg, i, NL80211_CMD_SET_WIPHY_NETNS)) 1331 + /* if bands & channels are done, continue outside */ 1332 + if (*band_start == 0 && *chan_start == 0) 1333 + (*split_start)++; 1334 + if (split) 1335 + break; 1336 + case 4: 1337 + nl_cmds = nla_nest_start(msg, NL80211_ATTR_SUPPORTED_COMMANDS); 1338 + if (!nl_cmds) 1206 1339 goto nla_put_failure; 1207 - } 1208 - if (dev->ops->set_monitor_channel || dev->ops->start_ap || 1209 - dev->ops->join_mesh) { 1210 - i++; 1211 - if (nla_put_u32(msg, i, NL80211_CMD_SET_CHANNEL)) 1212 - goto nla_put_failure; 1213 - } 1214 - CMD(set_wds_peer, SET_WDS_PEER); 1215 - if (dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) { 1216 - CMD(tdls_mgmt, TDLS_MGMT); 1217 - CMD(tdls_oper, TDLS_OPER); 1218 - } 1219 - if (dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) 1220 - CMD(sched_scan_start, START_SCHED_SCAN); 1221 - CMD(probe_client, PROBE_CLIENT); 1222 - CMD(set_noack_map, SET_NOACK_MAP); 1223 - if (dev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS) { 1224 - i++; 1225 - if (nla_put_u32(msg, i, NL80211_CMD_REGISTER_BEACONS)) 1226 - goto nla_put_failure; 1227 - } 1228 - CMD(start_p2p_device, START_P2P_DEVICE); 1229 - CMD(set_mcast_rate, SET_MCAST_RATE); 1340 + 1341 + i = 0; 1342 + #define CMD(op, n) \ 1343 + do { \ 1344 + if (dev->ops->op) { \ 1345 + i++; \ 1346 + if (nla_put_u32(msg, i, NL80211_CMD_ ## n)) \ 1347 + goto nla_put_failure; \ 1348 + } \ 1349 + } while (0) 1350 + 1351 + CMD(add_virtual_intf, NEW_INTERFACE); 1352 + CMD(change_virtual_intf, SET_INTERFACE); 1353 + CMD(add_key, NEW_KEY); 1354 + CMD(start_ap, START_AP); 1355 + CMD(add_station, NEW_STATION); 1356 + CMD(add_mpath, NEW_MPATH); 1357 + CMD(update_mesh_config, SET_MESH_CONFIG); 1358 + CMD(change_bss, SET_BSS); 1359 + CMD(auth, AUTHENTICATE); 1360 + CMD(assoc, ASSOCIATE); 1361 + CMD(deauth, DEAUTHENTICATE); 1362 + CMD(disassoc, DISASSOCIATE); 1363 + CMD(join_ibss, JOIN_IBSS); 1364 + CMD(join_mesh, JOIN_MESH); 1365 + CMD(set_pmksa, SET_PMKSA); 1366 + CMD(del_pmksa, DEL_PMKSA); 1367 + CMD(flush_pmksa, FLUSH_PMKSA); 1368 + if (dev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL) 1369 + CMD(remain_on_channel, REMAIN_ON_CHANNEL); 1370 + CMD(set_bitrate_mask, SET_TX_BITRATE_MASK); 1371 + CMD(mgmt_tx, FRAME); 1372 + CMD(mgmt_tx_cancel_wait, FRAME_WAIT_CANCEL); 1373 + if (dev->wiphy.flags & WIPHY_FLAG_NETNS_OK) { 1374 + i++; 1375 + if (nla_put_u32(msg, i, NL80211_CMD_SET_WIPHY_NETNS)) 1376 + goto nla_put_failure; 1377 + } 1378 + if (dev->ops->set_monitor_channel || dev->ops->start_ap || 1379 + dev->ops->join_mesh) { 1380 + i++; 1381 + if (nla_put_u32(msg, i, NL80211_CMD_SET_CHANNEL)) 1382 + goto nla_put_failure; 1383 + } 1384 + CMD(set_wds_peer, SET_WDS_PEER); 1385 + if (dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) { 1386 + CMD(tdls_mgmt, TDLS_MGMT); 1387 + CMD(tdls_oper, TDLS_OPER); 1388 + } 1389 + if (dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) 1390 + CMD(sched_scan_start, START_SCHED_SCAN); 1391 + CMD(probe_client, PROBE_CLIENT); 1392 + CMD(set_noack_map, SET_NOACK_MAP); 1393 + if (dev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS) { 1394 + i++; 1395 + if (nla_put_u32(msg, i, NL80211_CMD_REGISTER_BEACONS)) 1396 + goto nla_put_failure; 1397 + } 1398 + CMD(start_p2p_device, START_P2P_DEVICE); 1399 + CMD(set_mcast_rate, SET_MCAST_RATE); 1230 1400 1231 1401 #ifdef CONFIG_NL80211_TESTMODE 1232 - CMD(testmode_cmd, TESTMODE); 1402 + CMD(testmode_cmd, TESTMODE); 1233 1403 #endif 1234 1404 1235 1405 #undef CMD 1236 1406 1237 - if (dev->ops->connect || dev->ops->auth) { 1238 - i++; 1239 - if (nla_put_u32(msg, i, NL80211_CMD_CONNECT)) 1240 - goto nla_put_failure; 1241 - } 1242 - 1243 - if (dev->ops->disconnect || dev->ops->deauth) { 1244 - i++; 1245 - if (nla_put_u32(msg, i, NL80211_CMD_DISCONNECT)) 1246 - goto nla_put_failure; 1247 - } 1248 - 1249 - nla_nest_end(msg, nl_cmds); 1250 - 1251 - if (dev->ops->remain_on_channel && 1252 - (dev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL) && 1253 - nla_put_u32(msg, NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION, 1254 - dev->wiphy.max_remain_on_channel_duration)) 1255 - goto nla_put_failure; 1256 - 1257 - if ((dev->wiphy.flags & WIPHY_FLAG_OFFCHAN_TX) && 1258 - nla_put_flag(msg, NL80211_ATTR_OFFCHANNEL_TX_OK)) 1259 - goto nla_put_failure; 1260 - 1261 - if (mgmt_stypes) { 1262 - u16 stypes; 1263 - struct nlattr *nl_ftypes, *nl_ifs; 1264 - enum nl80211_iftype ift; 1265 - 1266 - nl_ifs = nla_nest_start(msg, NL80211_ATTR_TX_FRAME_TYPES); 1267 - if (!nl_ifs) 1268 - goto nla_put_failure; 1269 - 1270 - for (ift = 0; ift < NUM_NL80211_IFTYPES; ift++) { 1271 - nl_ftypes = nla_nest_start(msg, ift); 1272 - if (!nl_ftypes) 1407 + if (dev->ops->connect || dev->ops->auth) { 1408 + i++; 1409 + if (nla_put_u32(msg, i, NL80211_CMD_CONNECT)) 1273 1410 goto nla_put_failure; 1274 - i = 0; 1275 - stypes = mgmt_stypes[ift].tx; 1276 - while (stypes) { 1277 - if ((stypes & 1) && 1278 - nla_put_u16(msg, NL80211_ATTR_FRAME_TYPE, 1279 - (i << 4) | IEEE80211_FTYPE_MGMT)) 1280 - goto nla_put_failure; 1281 - stypes >>= 1; 1282 - i++; 1283 - } 1284 - nla_nest_end(msg, nl_ftypes); 1285 1411 } 1286 1412 1287 - nla_nest_end(msg, nl_ifs); 1413 + if (dev->ops->disconnect || dev->ops->deauth) { 1414 + i++; 1415 + if (nla_put_u32(msg, i, NL80211_CMD_DISCONNECT)) 1416 + goto nla_put_failure; 1417 + } 1288 1418 1289 - nl_ifs = nla_nest_start(msg, NL80211_ATTR_RX_FRAME_TYPES); 1290 - if (!nl_ifs) 1419 + nla_nest_end(msg, nl_cmds); 1420 + (*split_start)++; 1421 + if (split) 1422 + break; 1423 + case 5: 1424 + if (dev->ops->remain_on_channel && 1425 + (dev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL) && 1426 + nla_put_u32(msg, 1427 + NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION, 1428 + dev->wiphy.max_remain_on_channel_duration)) 1291 1429 goto nla_put_failure; 1292 1430 1293 - for (ift = 0; ift < NUM_NL80211_IFTYPES; ift++) { 1294 - nl_ftypes = nla_nest_start(msg, ift); 1295 - if (!nl_ftypes) 1296 - goto nla_put_failure; 1297 - i = 0; 1298 - stypes = mgmt_stypes[ift].rx; 1299 - while (stypes) { 1300 - if ((stypes & 1) && 1301 - nla_put_u16(msg, NL80211_ATTR_FRAME_TYPE, 1302 - (i << 4) | IEEE80211_FTYPE_MGMT)) 1303 - goto nla_put_failure; 1304 - stypes >>= 1; 1305 - i++; 1306 - } 1307 - nla_nest_end(msg, nl_ftypes); 1308 - } 1309 - nla_nest_end(msg, nl_ifs); 1310 - } 1431 + if ((dev->wiphy.flags & WIPHY_FLAG_OFFCHAN_TX) && 1432 + nla_put_flag(msg, NL80211_ATTR_OFFCHANNEL_TX_OK)) 1433 + goto nla_put_failure; 1311 1434 1435 + if (nl80211_send_mgmt_stypes(msg, mgmt_stypes)) 1436 + goto nla_put_failure; 1437 + (*split_start)++; 1438 + if (split) 1439 + break; 1440 + case 6: 1312 1441 #ifdef CONFIG_PM 1313 - if (dev->wiphy.wowlan.flags || dev->wiphy.wowlan.n_patterns) { 1314 - struct nlattr *nl_wowlan; 1315 - 1316 - nl_wowlan = nla_nest_start(msg, 1317 - NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED); 1318 - if (!nl_wowlan) 1442 + if (nl80211_send_wowlan(msg, dev, split)) 1319 1443 goto nla_put_failure; 1320 - 1321 - if (((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_ANY) && 1322 - nla_put_flag(msg, NL80211_WOWLAN_TRIG_ANY)) || 1323 - ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_DISCONNECT) && 1324 - nla_put_flag(msg, NL80211_WOWLAN_TRIG_DISCONNECT)) || 1325 - ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_MAGIC_PKT) && 1326 - nla_put_flag(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT)) || 1327 - ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY) && 1328 - nla_put_flag(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED)) || 1329 - ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) && 1330 - nla_put_flag(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE)) || 1331 - ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_EAP_IDENTITY_REQ) && 1332 - nla_put_flag(msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST)) || 1333 - ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_4WAY_HANDSHAKE) && 1334 - nla_put_flag(msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE)) || 1335 - ((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_RFKILL_RELEASE) && 1336 - nla_put_flag(msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE))) 1337 - goto nla_put_failure; 1338 - if (dev->wiphy.wowlan.n_patterns) { 1339 - struct nl80211_wowlan_pattern_support pat = { 1340 - .max_patterns = dev->wiphy.wowlan.n_patterns, 1341 - .min_pattern_len = 1342 - dev->wiphy.wowlan.pattern_min_len, 1343 - .max_pattern_len = 1344 - dev->wiphy.wowlan.pattern_max_len, 1345 - .max_pkt_offset = 1346 - dev->wiphy.wowlan.max_pkt_offset, 1347 - }; 1348 - if (nla_put(msg, NL80211_WOWLAN_TRIG_PKT_PATTERN, 1349 - sizeof(pat), &pat)) 1350 - goto nla_put_failure; 1351 - } 1352 - 1353 - if (nl80211_send_wowlan_tcp_caps(dev, msg)) 1354 - goto nla_put_failure; 1355 - 1356 - nla_nest_end(msg, nl_wowlan); 1357 - } 1444 + (*split_start)++; 1445 + if (split) 1446 + break; 1447 + #else 1448 + (*split_start)++; 1358 1449 #endif 1450 + case 7: 1451 + if (nl80211_put_iftypes(msg, NL80211_ATTR_SOFTWARE_IFTYPES, 1452 + dev->wiphy.software_iftypes)) 1453 + goto nla_put_failure; 1359 1454 1360 - if (nl80211_put_iftypes(msg, NL80211_ATTR_SOFTWARE_IFTYPES, 1361 - dev->wiphy.software_iftypes)) 1362 - goto nla_put_failure; 1455 + if (nl80211_put_iface_combinations(&dev->wiphy, msg, split)) 1456 + goto nla_put_failure; 1363 1457 1364 - if (nl80211_put_iface_combinations(&dev->wiphy, msg)) 1365 - goto nla_put_failure; 1458 + (*split_start)++; 1459 + if (split) 1460 + break; 1461 + case 8: 1462 + if ((dev->wiphy.flags & WIPHY_FLAG_HAVE_AP_SME) && 1463 + nla_put_u32(msg, NL80211_ATTR_DEVICE_AP_SME, 1464 + dev->wiphy.ap_sme_capa)) 1465 + goto nla_put_failure; 1366 1466 1367 - if ((dev->wiphy.flags & WIPHY_FLAG_HAVE_AP_SME) && 1368 - nla_put_u32(msg, NL80211_ATTR_DEVICE_AP_SME, 1369 - dev->wiphy.ap_sme_capa)) 1370 - goto nla_put_failure; 1467 + features = dev->wiphy.features; 1468 + /* 1469 + * We can only add the per-channel limit information if the 1470 + * dump is split, otherwise it makes it too big. Therefore 1471 + * only advertise it in that case. 1472 + */ 1473 + if (split) 1474 + features |= NL80211_FEATURE_ADVERTISE_CHAN_LIMITS; 1475 + if (nla_put_u32(msg, NL80211_ATTR_FEATURE_FLAGS, features)) 1476 + goto nla_put_failure; 1371 1477 1372 - if (nla_put_u32(msg, NL80211_ATTR_FEATURE_FLAGS, 1373 - dev->wiphy.features)) 1374 - goto nla_put_failure; 1478 + if (dev->wiphy.ht_capa_mod_mask && 1479 + nla_put(msg, NL80211_ATTR_HT_CAPABILITY_MASK, 1480 + sizeof(*dev->wiphy.ht_capa_mod_mask), 1481 + dev->wiphy.ht_capa_mod_mask)) 1482 + goto nla_put_failure; 1375 1483 1376 - if (dev->wiphy.ht_capa_mod_mask && 1377 - nla_put(msg, NL80211_ATTR_HT_CAPABILITY_MASK, 1378 - sizeof(*dev->wiphy.ht_capa_mod_mask), 1379 - dev->wiphy.ht_capa_mod_mask)) 1380 - goto nla_put_failure; 1484 + if (dev->wiphy.flags & WIPHY_FLAG_HAVE_AP_SME && 1485 + dev->wiphy.max_acl_mac_addrs && 1486 + nla_put_u32(msg, NL80211_ATTR_MAC_ACL_MAX, 1487 + dev->wiphy.max_acl_mac_addrs)) 1488 + goto nla_put_failure; 1381 1489 1382 - if (dev->wiphy.flags & WIPHY_FLAG_HAVE_AP_SME && 1383 - dev->wiphy.max_acl_mac_addrs && 1384 - nla_put_u32(msg, NL80211_ATTR_MAC_ACL_MAX, 1385 - dev->wiphy.max_acl_mac_addrs)) 1386 - goto nla_put_failure; 1490 + /* 1491 + * Any information below this point is only available to 1492 + * applications that can deal with it being split. This 1493 + * helps ensure that newly added capabilities don't break 1494 + * older tools by overrunning their buffers. 1495 + * 1496 + * We still increment split_start so that in the split 1497 + * case we'll continue with more data in the next round, 1498 + * but break unconditionally so unsplit data stops here. 1499 + */ 1500 + (*split_start)++; 1501 + break; 1502 + case 9: 1503 + if (dev->wiphy.extended_capabilities && 1504 + (nla_put(msg, NL80211_ATTR_EXT_CAPA, 1505 + dev->wiphy.extended_capabilities_len, 1506 + dev->wiphy.extended_capabilities) || 1507 + nla_put(msg, NL80211_ATTR_EXT_CAPA_MASK, 1508 + dev->wiphy.extended_capabilities_len, 1509 + dev->wiphy.extended_capabilities_mask))) 1510 + goto nla_put_failure; 1387 1511 1388 - if (dev->wiphy.extended_capabilities && 1389 - (nla_put(msg, NL80211_ATTR_EXT_CAPA, 1390 - dev->wiphy.extended_capabilities_len, 1391 - dev->wiphy.extended_capabilities) || 1392 - nla_put(msg, NL80211_ATTR_EXT_CAPA_MASK, 1393 - dev->wiphy.extended_capabilities_len, 1394 - dev->wiphy.extended_capabilities_mask))) 1395 - goto nla_put_failure; 1512 + if (dev->wiphy.vht_capa_mod_mask && 1513 + nla_put(msg, NL80211_ATTR_VHT_CAPABILITY_MASK, 1514 + sizeof(*dev->wiphy.vht_capa_mod_mask), 1515 + dev->wiphy.vht_capa_mod_mask)) 1516 + goto nla_put_failure; 1396 1517 1518 + /* done */ 1519 + *split_start = 0; 1520 + break; 1521 + } 1397 1522 return genlmsg_end(msg, hdr); 1398 1523 1399 1524 nla_put_failure: ··· 1548 1383 1549 1384 static int nl80211_dump_wiphy(struct sk_buff *skb, struct netlink_callback *cb) 1550 1385 { 1551 - int idx = 0; 1386 + int idx = 0, ret; 1552 1387 int start = cb->args[0]; 1553 1388 struct cfg80211_registered_device *dev; 1389 + s64 filter_wiphy = -1; 1390 + bool split = false; 1391 + struct nlattr **tb = nl80211_fam.attrbuf; 1392 + int res; 1554 1393 1555 1394 mutex_lock(&cfg80211_mutex); 1395 + res = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize, 1396 + tb, nl80211_fam.maxattr, nl80211_policy); 1397 + if (res == 0) { 1398 + split = tb[NL80211_ATTR_SPLIT_WIPHY_DUMP]; 1399 + if (tb[NL80211_ATTR_WIPHY]) 1400 + filter_wiphy = nla_get_u32(tb[NL80211_ATTR_WIPHY]); 1401 + if (tb[NL80211_ATTR_WDEV]) 1402 + filter_wiphy = nla_get_u64(tb[NL80211_ATTR_WDEV]) >> 32; 1403 + if (tb[NL80211_ATTR_IFINDEX]) { 1404 + struct net_device *netdev; 1405 + int ifidx = nla_get_u32(tb[NL80211_ATTR_IFINDEX]); 1406 + 1407 + netdev = dev_get_by_index(sock_net(skb->sk), ifidx); 1408 + if (!netdev) { 1409 + mutex_unlock(&cfg80211_mutex); 1410 + return -ENODEV; 1411 + } 1412 + if (netdev->ieee80211_ptr) { 1413 + dev = wiphy_to_dev( 1414 + netdev->ieee80211_ptr->wiphy); 1415 + filter_wiphy = dev->wiphy_idx; 1416 + } 1417 + dev_put(netdev); 1418 + } 1419 + } 1420 + 1556 1421 list_for_each_entry(dev, &cfg80211_rdev_list, list) { 1557 1422 if (!net_eq(wiphy_net(&dev->wiphy), sock_net(skb->sk))) 1558 1423 continue; 1559 1424 if (++idx <= start) 1560 1425 continue; 1561 - if (nl80211_send_wiphy(skb, NETLINK_CB(cb->skb).portid, 1562 - cb->nlh->nlmsg_seq, NLM_F_MULTI, 1563 - dev) < 0) { 1564 - idx--; 1565 - break; 1566 - } 1426 + if (filter_wiphy != -1 && dev->wiphy_idx != filter_wiphy) 1427 + continue; 1428 + /* attempt to fit multiple wiphy data chunks into the skb */ 1429 + do { 1430 + ret = nl80211_send_wiphy(dev, skb, 1431 + NETLINK_CB(cb->skb).portid, 1432 + cb->nlh->nlmsg_seq, 1433 + NLM_F_MULTI, 1434 + split, &cb->args[1], 1435 + &cb->args[2], 1436 + &cb->args[3]); 1437 + if (ret < 0) { 1438 + /* 1439 + * If sending the wiphy data didn't fit (ENOBUFS 1440 + * or EMSGSIZE returned), this SKB is still 1441 + * empty (so it's not too big because another 1442 + * wiphy dataset is already in the skb) and 1443 + * we've not tried to adjust the dump allocation 1444 + * yet ... then adjust the alloc size to be 1445 + * bigger, and return 1 but with the empty skb. 1446 + * This results in an empty message being RX'ed 1447 + * in userspace, but that is ignored. 1448 + * 1449 + * We can then retry with the larger buffer. 1450 + */ 1451 + if ((ret == -ENOBUFS || ret == -EMSGSIZE) && 1452 + !skb->len && 1453 + cb->min_dump_alloc < 4096) { 1454 + cb->min_dump_alloc = 4096; 1455 + mutex_unlock(&cfg80211_mutex); 1456 + return 1; 1457 + } 1458 + idx--; 1459 + break; 1460 + } 1461 + } while (cb->args[1] > 0); 1462 + break; 1567 1463 } 1568 1464 mutex_unlock(&cfg80211_mutex); 1569 1465 ··· 1638 1412 struct sk_buff *msg; 1639 1413 struct cfg80211_registered_device *dev = info->user_ptr[0]; 1640 1414 1641 - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 1415 + msg = nlmsg_new(4096, GFP_KERNEL); 1642 1416 if (!msg) 1643 1417 return -ENOMEM; 1644 1418 1645 - if (nl80211_send_wiphy(msg, info->snd_portid, info->snd_seq, 0, dev) < 0) { 1419 + if (nl80211_send_wiphy(dev, msg, info->snd_portid, info->snd_seq, 0, 1420 + false, NULL, NULL, NULL) < 0) { 1646 1421 nlmsg_free(msg); 1647 1422 return -ENOBUFS; 1648 1423 } ··· 3250 3023 sta_flags = nla_data(nla); 3251 3024 params->sta_flags_mask = sta_flags->mask; 3252 3025 params->sta_flags_set = sta_flags->set; 3026 + params->sta_flags_set &= params->sta_flags_mask; 3253 3027 if ((params->sta_flags_mask | 3254 3028 params->sta_flags_set) & BIT(__NL80211_STA_FLAG_INVALID)) 3255 3029 return -EINVAL; ··· 3604 3376 return genlmsg_reply(msg, info); 3605 3377 } 3606 3378 3379 + int cfg80211_check_station_change(struct wiphy *wiphy, 3380 + struct station_parameters *params, 3381 + enum cfg80211_station_type statype) 3382 + { 3383 + if (params->listen_interval != -1) 3384 + return -EINVAL; 3385 + if (params->aid) 3386 + return -EINVAL; 3387 + 3388 + /* When you run into this, adjust the code below for the new flag */ 3389 + BUILD_BUG_ON(NL80211_STA_FLAG_MAX != 7); 3390 + 3391 + switch (statype) { 3392 + case CFG80211_STA_MESH_PEER_KERNEL: 3393 + case CFG80211_STA_MESH_PEER_USER: 3394 + /* 3395 + * No ignoring the TDLS flag here -- the userspace mesh 3396 + * code doesn't have the bug of including TDLS in the 3397 + * mask everywhere. 3398 + */ 3399 + if (params->sta_flags_mask & 3400 + ~(BIT(NL80211_STA_FLAG_AUTHENTICATED) | 3401 + BIT(NL80211_STA_FLAG_MFP) | 3402 + BIT(NL80211_STA_FLAG_AUTHORIZED))) 3403 + return -EINVAL; 3404 + break; 3405 + case CFG80211_STA_TDLS_PEER_SETUP: 3406 + case CFG80211_STA_TDLS_PEER_ACTIVE: 3407 + if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))) 3408 + return -EINVAL; 3409 + /* ignore since it can't change */ 3410 + params->sta_flags_mask &= ~BIT(NL80211_STA_FLAG_TDLS_PEER); 3411 + break; 3412 + default: 3413 + /* disallow mesh-specific things */ 3414 + if (params->plink_action != NL80211_PLINK_ACTION_NO_ACTION) 3415 + return -EINVAL; 3416 + if (params->local_pm) 3417 + return -EINVAL; 3418 + if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) 3419 + return -EINVAL; 3420 + } 3421 + 3422 + if (statype != CFG80211_STA_TDLS_PEER_SETUP && 3423 + statype != CFG80211_STA_TDLS_PEER_ACTIVE) { 3424 + /* TDLS can't be set, ... */ 3425 + if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) 3426 + return -EINVAL; 3427 + /* 3428 + * ... but don't bother the driver with it. This works around 3429 + * a hostapd/wpa_supplicant issue -- it always includes the 3430 + * TLDS_PEER flag in the mask even for AP mode. 3431 + */ 3432 + params->sta_flags_mask &= ~BIT(NL80211_STA_FLAG_TDLS_PEER); 3433 + } 3434 + 3435 + if (statype != CFG80211_STA_TDLS_PEER_SETUP) { 3436 + /* reject other things that can't change */ 3437 + if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) 3438 + return -EINVAL; 3439 + if (params->sta_modify_mask & STATION_PARAM_APPLY_CAPABILITY) 3440 + return -EINVAL; 3441 + if (params->supported_rates) 3442 + return -EINVAL; 3443 + if (params->ext_capab || params->ht_capa || params->vht_capa) 3444 + return -EINVAL; 3445 + } 3446 + 3447 + if (statype != CFG80211_STA_AP_CLIENT) { 3448 + if (params->vlan) 3449 + return -EINVAL; 3450 + } 3451 + 3452 + switch (statype) { 3453 + case CFG80211_STA_AP_MLME_CLIENT: 3454 + /* Use this only for authorizing/unauthorizing a station */ 3455 + if (!(params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED))) 3456 + return -EOPNOTSUPP; 3457 + break; 3458 + case CFG80211_STA_AP_CLIENT: 3459 + /* accept only the listed bits */ 3460 + if (params->sta_flags_mask & 3461 + ~(BIT(NL80211_STA_FLAG_AUTHORIZED) | 3462 + BIT(NL80211_STA_FLAG_AUTHENTICATED) | 3463 + BIT(NL80211_STA_FLAG_ASSOCIATED) | 3464 + BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) | 3465 + BIT(NL80211_STA_FLAG_WME) | 3466 + BIT(NL80211_STA_FLAG_MFP))) 3467 + return -EINVAL; 3468 + 3469 + /* but authenticated/associated only if driver handles it */ 3470 + if (!(wiphy->features & NL80211_FEATURE_FULL_AP_CLIENT_STATE) && 3471 + params->sta_flags_mask & 3472 + (BIT(NL80211_STA_FLAG_AUTHENTICATED) | 3473 + BIT(NL80211_STA_FLAG_ASSOCIATED))) 3474 + return -EINVAL; 3475 + break; 3476 + case CFG80211_STA_IBSS: 3477 + case CFG80211_STA_AP_STA: 3478 + /* reject any changes other than AUTHORIZED */ 3479 + if (params->sta_flags_mask & ~BIT(NL80211_STA_FLAG_AUTHORIZED)) 3480 + return -EINVAL; 3481 + break; 3482 + case CFG80211_STA_TDLS_PEER_SETUP: 3483 + /* reject any changes other than AUTHORIZED or WME */ 3484 + if (params->sta_flags_mask & ~(BIT(NL80211_STA_FLAG_AUTHORIZED) | 3485 + BIT(NL80211_STA_FLAG_WME))) 3486 + return -EINVAL; 3487 + /* force (at least) rates when authorizing */ 3488 + if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED) && 3489 + !params->supported_rates) 3490 + return -EINVAL; 3491 + break; 3492 + case CFG80211_STA_TDLS_PEER_ACTIVE: 3493 + /* reject any changes */ 3494 + return -EINVAL; 3495 + case CFG80211_STA_MESH_PEER_KERNEL: 3496 + if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) 3497 + return -EINVAL; 3498 + break; 3499 + case CFG80211_STA_MESH_PEER_USER: 3500 + if (params->plink_action != NL80211_PLINK_ACTION_NO_ACTION) 3501 + return -EINVAL; 3502 + break; 3503 + } 3504 + 3505 + return 0; 3506 + } 3507 + EXPORT_SYMBOL(cfg80211_check_station_change); 3508 + 3607 3509 /* 3608 3510 * Get vlan interface making sure it is running and on the right wiphy. 3609 3511 */ ··· 3756 3398 goto error; 3757 3399 } 3758 3400 3401 + if (v->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN && 3402 + v->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && 3403 + v->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) { 3404 + ret = -EINVAL; 3405 + goto error; 3406 + } 3407 + 3759 3408 if (!netif_running(v)) { 3760 3409 ret = -ENETDOWN; 3761 3410 goto error; ··· 3780 3415 [NL80211_STA_WME_MAX_SP] = { .type = NLA_U8 }, 3781 3416 }; 3782 3417 3783 - static int nl80211_set_station_tdls(struct genl_info *info, 3784 - struct station_parameters *params) 3418 + static int nl80211_parse_sta_wme(struct genl_info *info, 3419 + struct station_parameters *params) 3785 3420 { 3786 3421 struct nlattr *tb[NL80211_STA_WME_MAX + 1]; 3787 3422 struct nlattr *nla; 3788 3423 int err; 3789 - 3790 - /* Dummy STA entry gets updated once the peer capabilities are known */ 3791 - if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) 3792 - params->ht_capa = 3793 - nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); 3794 - if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) 3795 - params->vht_capa = 3796 - nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]); 3797 3424 3798 3425 /* parse WME attributes if present */ 3799 3426 if (!info->attrs[NL80211_ATTR_STA_WME]) ··· 3814 3457 return 0; 3815 3458 } 3816 3459 3460 + static int nl80211_set_station_tdls(struct genl_info *info, 3461 + struct station_parameters *params) 3462 + { 3463 + /* Dummy STA entry gets updated once the peer capabilities are known */ 3464 + if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) 3465 + params->ht_capa = 3466 + nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); 3467 + if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) 3468 + params->vht_capa = 3469 + nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]); 3470 + 3471 + return nl80211_parse_sta_wme(info, params); 3472 + } 3473 + 3817 3474 static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) 3818 3475 { 3819 3476 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 3820 - int err; 3821 3477 struct net_device *dev = info->user_ptr[1]; 3822 3478 struct station_parameters params; 3823 - u8 *mac_addr = NULL; 3479 + u8 *mac_addr; 3480 + int err; 3824 3481 3825 3482 memset(&params, 0, sizeof(params)); 3826 3483 3827 3484 params.listen_interval = -1; 3828 - params.plink_state = -1; 3485 + 3486 + if (!rdev->ops->change_station) 3487 + return -EOPNOTSUPP; 3829 3488 3830 3489 if (info->attrs[NL80211_ATTR_STA_AID]) 3831 3490 return -EINVAL; ··· 3874 3501 if (info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]) 3875 3502 return -EINVAL; 3876 3503 3877 - if (!rdev->ops->change_station) 3878 - return -EOPNOTSUPP; 3879 - 3880 3504 if (parse_station_flags(info, dev->ieee80211_ptr->iftype, &params)) 3881 3505 return -EINVAL; 3882 3506 3883 - if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) 3507 + if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) { 3884 3508 params.plink_action = 3885 - nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); 3509 + nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); 3510 + if (params.plink_action >= NUM_NL80211_PLINK_ACTIONS) 3511 + return -EINVAL; 3512 + } 3886 3513 3887 - if (info->attrs[NL80211_ATTR_STA_PLINK_STATE]) 3514 + if (info->attrs[NL80211_ATTR_STA_PLINK_STATE]) { 3888 3515 params.plink_state = 3889 - nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_STATE]); 3516 + nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_STATE]); 3517 + if (params.plink_state >= NUM_NL80211_PLINK_STATES) 3518 + return -EINVAL; 3519 + params.sta_modify_mask |= STATION_PARAM_APPLY_PLINK_STATE; 3520 + } 3890 3521 3891 3522 if (info->attrs[NL80211_ATTR_LOCAL_MESH_POWER_MODE]) { 3892 3523 enum nl80211_mesh_power_mode pm = nla_get_u32( ··· 3903 3526 params.local_pm = pm; 3904 3527 } 3905 3528 3529 + /* Include parameters for TDLS peer (will check later) */ 3530 + err = nl80211_set_station_tdls(info, &params); 3531 + if (err) 3532 + return err; 3533 + 3534 + params.vlan = get_vlan(info, rdev); 3535 + if (IS_ERR(params.vlan)) 3536 + return PTR_ERR(params.vlan); 3537 + 3906 3538 switch (dev->ieee80211_ptr->iftype) { 3907 3539 case NL80211_IFTYPE_AP: 3908 3540 case NL80211_IFTYPE_AP_VLAN: 3909 3541 case NL80211_IFTYPE_P2P_GO: 3910 - /* disallow mesh-specific things */ 3911 - if (params.plink_action) 3912 - return -EINVAL; 3913 - if (params.local_pm) 3914 - return -EINVAL; 3915 - 3916 - /* TDLS can't be set, ... */ 3917 - if (params.sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) 3918 - return -EINVAL; 3919 - /* 3920 - * ... but don't bother the driver with it. This works around 3921 - * a hostapd/wpa_supplicant issue -- it always includes the 3922 - * TLDS_PEER flag in the mask even for AP mode. 3923 - */ 3924 - params.sta_flags_mask &= ~BIT(NL80211_STA_FLAG_TDLS_PEER); 3925 - 3926 - /* accept only the listed bits */ 3927 - if (params.sta_flags_mask & 3928 - ~(BIT(NL80211_STA_FLAG_AUTHORIZED) | 3929 - BIT(NL80211_STA_FLAG_AUTHENTICATED) | 3930 - BIT(NL80211_STA_FLAG_ASSOCIATED) | 3931 - BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) | 3932 - BIT(NL80211_STA_FLAG_WME) | 3933 - BIT(NL80211_STA_FLAG_MFP))) 3934 - return -EINVAL; 3935 - 3936 - /* but authenticated/associated only if driver handles it */ 3937 - if (!(rdev->wiphy.features & 3938 - NL80211_FEATURE_FULL_AP_CLIENT_STATE) && 3939 - params.sta_flags_mask & 3940 - (BIT(NL80211_STA_FLAG_AUTHENTICATED) | 3941 - BIT(NL80211_STA_FLAG_ASSOCIATED))) 3942 - return -EINVAL; 3943 - 3944 - /* reject other things that can't change */ 3945 - if (params.supported_rates) 3946 - return -EINVAL; 3947 - if (info->attrs[NL80211_ATTR_STA_CAPABILITY]) 3948 - return -EINVAL; 3949 - if (info->attrs[NL80211_ATTR_STA_EXT_CAPABILITY]) 3950 - return -EINVAL; 3951 - if (info->attrs[NL80211_ATTR_HT_CAPABILITY] || 3952 - info->attrs[NL80211_ATTR_VHT_CAPABILITY]) 3953 - return -EINVAL; 3954 - 3955 - /* must be last in here for error handling */ 3956 - params.vlan = get_vlan(info, rdev); 3957 - if (IS_ERR(params.vlan)) 3958 - return PTR_ERR(params.vlan); 3959 - break; 3960 3542 case NL80211_IFTYPE_P2P_CLIENT: 3961 3543 case NL80211_IFTYPE_STATION: 3962 - /* 3963 - * Don't allow userspace to change the TDLS_PEER flag, 3964 - * but silently ignore attempts to change it since we 3965 - * don't have state here to verify that it doesn't try 3966 - * to change the flag. 3967 - */ 3968 - params.sta_flags_mask &= ~BIT(NL80211_STA_FLAG_TDLS_PEER); 3969 - /* Include parameters for TDLS peer (driver will check) */ 3970 - err = nl80211_set_station_tdls(info, &params); 3971 - if (err) 3972 - return err; 3973 - /* disallow things sta doesn't support */ 3974 - if (params.plink_action) 3975 - return -EINVAL; 3976 - if (params.local_pm) 3977 - return -EINVAL; 3978 - /* reject any changes other than AUTHORIZED or WME (for TDLS) */ 3979 - if (params.sta_flags_mask & ~(BIT(NL80211_STA_FLAG_AUTHORIZED) | 3980 - BIT(NL80211_STA_FLAG_WME))) 3981 - return -EINVAL; 3982 - break; 3983 3544 case NL80211_IFTYPE_ADHOC: 3984 - /* disallow things sta doesn't support */ 3985 - if (params.plink_action) 3986 - return -EINVAL; 3987 - if (params.local_pm) 3988 - return -EINVAL; 3989 - if (info->attrs[NL80211_ATTR_HT_CAPABILITY] || 3990 - info->attrs[NL80211_ATTR_VHT_CAPABILITY]) 3991 - return -EINVAL; 3992 - /* reject any changes other than AUTHORIZED */ 3993 - if (params.sta_flags_mask & ~BIT(NL80211_STA_FLAG_AUTHORIZED)) 3994 - return -EINVAL; 3995 - break; 3996 3545 case NL80211_IFTYPE_MESH_POINT: 3997 - /* disallow things mesh doesn't support */ 3998 - if (params.vlan) 3999 - return -EINVAL; 4000 - if (params.supported_rates) 4001 - return -EINVAL; 4002 - if (info->attrs[NL80211_ATTR_STA_CAPABILITY]) 4003 - return -EINVAL; 4004 - if (info->attrs[NL80211_ATTR_STA_EXT_CAPABILITY]) 4005 - return -EINVAL; 4006 - if (info->attrs[NL80211_ATTR_HT_CAPABILITY] || 4007 - info->attrs[NL80211_ATTR_VHT_CAPABILITY]) 4008 - return -EINVAL; 4009 - /* 4010 - * No special handling for TDLS here -- the userspace 4011 - * mesh code doesn't have this bug. 4012 - */ 4013 - if (params.sta_flags_mask & 4014 - ~(BIT(NL80211_STA_FLAG_AUTHENTICATED) | 4015 - BIT(NL80211_STA_FLAG_MFP) | 4016 - BIT(NL80211_STA_FLAG_AUTHORIZED))) 4017 - return -EINVAL; 4018 3546 break; 4019 3547 default: 4020 - return -EOPNOTSUPP; 3548 + err = -EOPNOTSUPP; 3549 + goto out_put_vlan; 4021 3550 } 4022 3551 4023 - /* be aware of params.vlan when changing code here */ 4024 - 3552 + /* driver will call cfg80211_check_station_change() */ 4025 3553 err = rdev_change_station(rdev, dev, mac_addr, &params); 4026 3554 3555 + out_put_vlan: 4027 3556 if (params.vlan) 4028 3557 dev_put(params.vlan); 4029 3558 ··· 3945 3662 u8 *mac_addr = NULL; 3946 3663 3947 3664 memset(&params, 0, sizeof(params)); 3665 + 3666 + if (!rdev->ops->add_station) 3667 + return -EOPNOTSUPP; 3948 3668 3949 3669 if (!info->attrs[NL80211_ATTR_MAC]) 3950 3670 return -EINVAL; ··· 3994 3708 params.vht_capa = 3995 3709 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]); 3996 3710 3997 - if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) 3711 + if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) { 3998 3712 params.plink_action = 3999 - nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); 3713 + nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); 3714 + if (params.plink_action >= NUM_NL80211_PLINK_ACTIONS) 3715 + return -EINVAL; 3716 + } 4000 3717 4001 - if (!rdev->ops->add_station) 4002 - return -EOPNOTSUPP; 3718 + err = nl80211_parse_sta_wme(info, &params); 3719 + if (err) 3720 + return err; 4003 3721 4004 3722 if (parse_station_flags(info, dev->ieee80211_ptr->iftype, &params)) 4005 3723 return -EINVAL; 3724 + 3725 + /* When you run into this, adjust the code below for the new flag */ 3726 + BUILD_BUG_ON(NL80211_STA_FLAG_MAX != 7); 4006 3727 4007 3728 switch (dev->ieee80211_ptr->iftype) { 4008 3729 case NL80211_IFTYPE_AP: 4009 3730 case NL80211_IFTYPE_AP_VLAN: 4010 3731 case NL80211_IFTYPE_P2P_GO: 4011 - /* parse WME attributes if sta is WME capable */ 4012 - if ((rdev->wiphy.flags & WIPHY_FLAG_AP_UAPSD) && 4013 - (params.sta_flags_set & BIT(NL80211_STA_FLAG_WME)) && 4014 - info->attrs[NL80211_ATTR_STA_WME]) { 4015 - struct nlattr *tb[NL80211_STA_WME_MAX + 1]; 4016 - struct nlattr *nla; 3732 + /* ignore WME attributes if iface/sta is not capable */ 3733 + if (!(rdev->wiphy.flags & WIPHY_FLAG_AP_UAPSD) || 3734 + !(params.sta_flags_set & BIT(NL80211_STA_FLAG_WME))) 3735 + params.sta_modify_mask &= ~STATION_PARAM_APPLY_UAPSD; 4017 3736 4018 - nla = info->attrs[NL80211_ATTR_STA_WME]; 4019 - err = nla_parse_nested(tb, NL80211_STA_WME_MAX, nla, 4020 - nl80211_sta_wme_policy); 4021 - if (err) 4022 - return err; 4023 - 4024 - if (tb[NL80211_STA_WME_UAPSD_QUEUES]) 4025 - params.uapsd_queues = 4026 - nla_get_u8(tb[NL80211_STA_WME_UAPSD_QUEUES]); 4027 - if (params.uapsd_queues & 4028 - ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK) 4029 - return -EINVAL; 4030 - 4031 - if (tb[NL80211_STA_WME_MAX_SP]) 4032 - params.max_sp = 4033 - nla_get_u8(tb[NL80211_STA_WME_MAX_SP]); 4034 - 4035 - if (params.max_sp & 4036 - ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK) 4037 - return -EINVAL; 4038 - 4039 - params.sta_modify_mask |= STATION_PARAM_APPLY_UAPSD; 4040 - } 4041 3737 /* TDLS peers cannot be added */ 4042 3738 if (params.sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) 4043 3739 return -EINVAL; ··· 4040 3772 return PTR_ERR(params.vlan); 4041 3773 break; 4042 3774 case NL80211_IFTYPE_MESH_POINT: 3775 + /* ignore uAPSD data */ 3776 + params.sta_modify_mask &= ~STATION_PARAM_APPLY_UAPSD; 3777 + 4043 3778 /* associated is disallowed */ 4044 3779 if (params.sta_flags_mask & BIT(NL80211_STA_FLAG_ASSOCIATED)) 4045 3780 return -EINVAL; ··· 4051 3780 return -EINVAL; 4052 3781 break; 4053 3782 case NL80211_IFTYPE_STATION: 4054 - /* associated is disallowed */ 4055 - if (params.sta_flags_mask & BIT(NL80211_STA_FLAG_ASSOCIATED)) 3783 + case NL80211_IFTYPE_P2P_CLIENT: 3784 + /* ignore uAPSD data */ 3785 + params.sta_modify_mask &= ~STATION_PARAM_APPLY_UAPSD; 3786 + 3787 + /* these are disallowed */ 3788 + if (params.sta_flags_mask & 3789 + (BIT(NL80211_STA_FLAG_ASSOCIATED) | 3790 + BIT(NL80211_STA_FLAG_AUTHENTICATED))) 4056 3791 return -EINVAL; 4057 3792 /* Only TDLS peers can be added */ 4058 3793 if (!(params.sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))) ··· 4069 3792 /* ... with external setup is supported */ 4070 3793 if (!(rdev->wiphy.flags & WIPHY_FLAG_TDLS_EXTERNAL_SETUP)) 4071 3794 return -EOPNOTSUPP; 3795 + /* 3796 + * Older wpa_supplicant versions always mark the TDLS peer 3797 + * as authorized, but it shouldn't yet be. 3798 + */ 3799 + params.sta_flags_mask &= ~BIT(NL80211_STA_FLAG_AUTHORIZED); 4072 3800 break; 4073 3801 default: 4074 3802 return -EOPNOTSUPP; ··· 4618 4336 [NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL] = { .type = NLA_U8 }, 4619 4337 [NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC] = { .type = NLA_U8 }, 4620 4338 [NL80211_MESH_SETUP_USERSPACE_AUTH] = { .type = NLA_FLAG }, 4339 + [NL80211_MESH_SETUP_USERSPACE_MPM] = { .type = NLA_FLAG }, 4621 4340 [NL80211_MESH_SETUP_IE] = { .type = NLA_BINARY, 4622 4341 .len = IEEE80211_MAX_DATA_LEN }, 4623 4342 [NL80211_MESH_SETUP_USERSPACE_AMPE] = { .type = NLA_FLAG }, ··· 4757 4474 static int nl80211_parse_mesh_setup(struct genl_info *info, 4758 4475 struct mesh_setup *setup) 4759 4476 { 4477 + struct cfg80211_registered_device *rdev = info->user_ptr[0]; 4760 4478 struct nlattr *tb[NL80211_MESH_SETUP_ATTR_MAX + 1]; 4761 4479 4762 4480 if (!info->attrs[NL80211_ATTR_MESH_SETUP]) ··· 4794 4510 setup->ie = nla_data(ieattr); 4795 4511 setup->ie_len = nla_len(ieattr); 4796 4512 } 4513 + if (tb[NL80211_MESH_SETUP_USERSPACE_MPM] && 4514 + !(rdev->wiphy.features & NL80211_FEATURE_USERSPACE_MPM)) 4515 + return -EINVAL; 4516 + setup->user_mpm = nla_get_flag(tb[NL80211_MESH_SETUP_USERSPACE_MPM]); 4797 4517 setup->is_authenticated = nla_get_flag(tb[NL80211_MESH_SETUP_USERSPACE_AUTH]); 4798 4518 setup->is_secure = nla_get_flag(tb[NL80211_MESH_SETUP_USERSPACE_AMPE]); 4519 + if (setup->is_secure) 4520 + setup->user_mpm = true; 4799 4521 4800 4522 return 0; 4801 4523 } ··· 5996 5706 { 5997 5707 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 5998 5708 struct net_device *dev = info->user_ptr[1]; 5999 - struct cfg80211_crypto_settings crypto; 6000 5709 struct ieee80211_channel *chan; 6001 - const u8 *bssid, *ssid, *ie = NULL, *prev_bssid = NULL; 6002 - int err, ssid_len, ie_len = 0; 6003 - bool use_mfp = false; 6004 - u32 flags = 0; 6005 - struct ieee80211_ht_cap *ht_capa = NULL; 6006 - struct ieee80211_ht_cap *ht_capa_mask = NULL; 5710 + struct cfg80211_assoc_request req = {}; 5711 + const u8 *bssid, *ssid; 5712 + int err, ssid_len = 0; 6007 5713 6008 5714 if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE])) 6009 5715 return -EINVAL; ··· 6027 5741 ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]); 6028 5742 6029 5743 if (info->attrs[NL80211_ATTR_IE]) { 6030 - ie = nla_data(info->attrs[NL80211_ATTR_IE]); 6031 - ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); 5744 + req.ie = nla_data(info->attrs[NL80211_ATTR_IE]); 5745 + req.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); 6032 5746 } 6033 5747 6034 5748 if (info->attrs[NL80211_ATTR_USE_MFP]) { 6035 5749 enum nl80211_mfp mfp = 6036 5750 nla_get_u32(info->attrs[NL80211_ATTR_USE_MFP]); 6037 5751 if (mfp == NL80211_MFP_REQUIRED) 6038 - use_mfp = true; 5752 + req.use_mfp = true; 6039 5753 else if (mfp != NL80211_MFP_NO) 6040 5754 return -EINVAL; 6041 5755 } 6042 5756 6043 5757 if (info->attrs[NL80211_ATTR_PREV_BSSID]) 6044 - prev_bssid = nla_data(info->attrs[NL80211_ATTR_PREV_BSSID]); 5758 + req.prev_bssid = nla_data(info->attrs[NL80211_ATTR_PREV_BSSID]); 6045 5759 6046 5760 if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HT])) 6047 - flags |= ASSOC_REQ_DISABLE_HT; 5761 + req.flags |= ASSOC_REQ_DISABLE_HT; 6048 5762 6049 5763 if (info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) 6050 - ht_capa_mask = 6051 - nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]); 5764 + memcpy(&req.ht_capa_mask, 5765 + nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]), 5766 + sizeof(req.ht_capa_mask)); 6052 5767 6053 5768 if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) { 6054 - if (!ht_capa_mask) 5769 + if (!info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) 6055 5770 return -EINVAL; 6056 - ht_capa = nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); 5771 + memcpy(&req.ht_capa, 5772 + nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]), 5773 + sizeof(req.ht_capa)); 6057 5774 } 6058 5775 6059 - err = nl80211_crypto_settings(rdev, info, &crypto, 1); 5776 + if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_VHT])) 5777 + req.flags |= ASSOC_REQ_DISABLE_VHT; 5778 + 5779 + if (info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]) 5780 + memcpy(&req.vht_capa_mask, 5781 + nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]), 5782 + sizeof(req.vht_capa_mask)); 5783 + 5784 + if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) { 5785 + if (!info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]) 5786 + return -EINVAL; 5787 + memcpy(&req.vht_capa, 5788 + nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]), 5789 + sizeof(req.vht_capa)); 5790 + } 5791 + 5792 + err = nl80211_crypto_settings(rdev, info, &req.crypto, 1); 6060 5793 if (!err) 6061 - err = cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid, 6062 - ssid, ssid_len, ie, ie_len, use_mfp, 6063 - &crypto, flags, ht_capa, 6064 - ht_capa_mask); 5794 + err = cfg80211_mlme_assoc(rdev, dev, chan, bssid, 5795 + ssid, ssid_len, &req); 6065 5796 6066 5797 return err; 6067 5798 } ··· 6656 6353 memcpy(&connect.ht_capa, 6657 6354 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]), 6658 6355 sizeof(connect.ht_capa)); 6356 + } 6357 + 6358 + if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_VHT])) 6359 + connect.flags |= ASSOC_REQ_DISABLE_VHT; 6360 + 6361 + if (info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]) 6362 + memcpy(&connect.vht_capa_mask, 6363 + nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]), 6364 + sizeof(connect.vht_capa_mask)); 6365 + 6366 + if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) { 6367 + if (!info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]) { 6368 + kfree(connkeys); 6369 + return -EINVAL; 6370 + } 6371 + memcpy(&connect.vht_capa, 6372 + nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]), 6373 + sizeof(connect.vht_capa)); 6659 6374 } 6660 6375 6661 6376 err = cfg80211_connect(rdev, dev, &connect, connkeys); ··· 7449 7128 return err; 7450 7129 } 7451 7130 7131 + if (setup.user_mpm) 7132 + cfg.auto_open_plinks = false; 7133 + 7452 7134 if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { 7453 7135 err = nl80211_parse_chandef(rdev, info, &setup.chandef); 7454 7136 if (err) ··· 7651 7327 return -EINVAL; 7652 7328 7653 7329 if (nla_get_u32(tb[NL80211_WOWLAN_TCP_DATA_INTERVAL]) > 7654 - rdev->wiphy.wowlan.tcp->data_interval_max) 7330 + rdev->wiphy.wowlan.tcp->data_interval_max || 7331 + nla_get_u32(tb[NL80211_WOWLAN_TCP_DATA_INTERVAL]) == 0) 7655 7332 return -EINVAL; 7656 7333 7657 7334 wake_size = nla_len(tb[NL80211_WOWLAN_TCP_WAKE_PAYLOAD]); ··· 8146 7821 } 8147 7822 8148 7823 return 0; 7824 + } 7825 + 7826 + static int nl80211_get_protocol_features(struct sk_buff *skb, 7827 + struct genl_info *info) 7828 + { 7829 + void *hdr; 7830 + struct sk_buff *msg; 7831 + 7832 + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 7833 + if (!msg) 7834 + return -ENOMEM; 7835 + 7836 + hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, 7837 + NL80211_CMD_GET_PROTOCOL_FEATURES); 7838 + if (!hdr) 7839 + goto nla_put_failure; 7840 + 7841 + if (nla_put_u32(msg, NL80211_ATTR_PROTOCOL_FEATURES, 7842 + NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP)) 7843 + goto nla_put_failure; 7844 + 7845 + genlmsg_end(msg, hdr); 7846 + return genlmsg_reply(msg, info); 7847 + 7848 + nla_put_failure: 7849 + kfree_skb(msg); 7850 + return -ENOBUFS; 7851 + } 7852 + 7853 + static int nl80211_update_ft_ies(struct sk_buff *skb, struct genl_info *info) 7854 + { 7855 + struct cfg80211_registered_device *rdev = info->user_ptr[0]; 7856 + struct cfg80211_update_ft_ies_params ft_params; 7857 + struct net_device *dev = info->user_ptr[1]; 7858 + 7859 + if (!rdev->ops->update_ft_ies) 7860 + return -EOPNOTSUPP; 7861 + 7862 + if (!info->attrs[NL80211_ATTR_MDID] || 7863 + !is_valid_ie_attr(info->attrs[NL80211_ATTR_IE])) 7864 + return -EINVAL; 7865 + 7866 + memset(&ft_params, 0, sizeof(ft_params)); 7867 + ft_params.md = nla_get_u16(info->attrs[NL80211_ATTR_MDID]); 7868 + ft_params.ie = nla_data(info->attrs[NL80211_ATTR_IE]); 7869 + ft_params.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); 7870 + 7871 + return rdev_update_ft_ies(rdev, dev, &ft_params); 8149 7872 } 8150 7873 8151 7874 #define NL80211_FLAG_NEED_WIPHY 0x01 ··· 8872 8499 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | 8873 8500 NL80211_FLAG_NEED_RTNL, 8874 8501 }, 8502 + { 8503 + .cmd = NL80211_CMD_GET_PROTOCOL_FEATURES, 8504 + .doit = nl80211_get_protocol_features, 8505 + .policy = nl80211_policy, 8506 + }, 8507 + { 8508 + .cmd = NL80211_CMD_UPDATE_FT_IES, 8509 + .doit = nl80211_update_ft_ies, 8510 + .policy = nl80211_policy, 8511 + .flags = GENL_ADMIN_PERM, 8512 + .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | 8513 + NL80211_FLAG_NEED_RTNL, 8514 + }, 8875 8515 }; 8876 8516 8877 8517 static struct genl_multicast_group nl80211_mlme_mcgrp = { ··· 8912 8526 if (!msg) 8913 8527 return; 8914 8528 8915 - if (nl80211_send_wiphy(msg, 0, 0, 0, rdev) < 0) { 8529 + if (nl80211_send_wiphy(rdev, msg, 0, 0, 0, 8530 + false, NULL, NULL, NULL) < 0) { 8916 8531 nlmsg_free(msg); 8917 8532 return; 8918 8533 } ··· 9237 8850 NL80211_CMD_DISASSOCIATE, gfp); 9238 8851 } 9239 8852 9240 - void nl80211_send_unprot_deauth(struct cfg80211_registered_device *rdev, 9241 - struct net_device *netdev, const u8 *buf, 9242 - size_t len, gfp_t gfp) 8853 + void cfg80211_send_unprot_deauth(struct net_device *dev, const u8 *buf, 8854 + size_t len) 9243 8855 { 9244 - nl80211_send_mlme_event(rdev, netdev, buf, len, 9245 - NL80211_CMD_UNPROT_DEAUTHENTICATE, gfp); 9246 - } 8856 + struct wireless_dev *wdev = dev->ieee80211_ptr; 8857 + struct wiphy *wiphy = wdev->wiphy; 8858 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 9247 8859 9248 - void nl80211_send_unprot_disassoc(struct cfg80211_registered_device *rdev, 9249 - struct net_device *netdev, const u8 *buf, 9250 - size_t len, gfp_t gfp) 9251 - { 9252 - nl80211_send_mlme_event(rdev, netdev, buf, len, 9253 - NL80211_CMD_UNPROT_DISASSOCIATE, gfp); 8860 + trace_cfg80211_send_unprot_deauth(dev); 8861 + nl80211_send_mlme_event(rdev, dev, buf, len, 8862 + NL80211_CMD_UNPROT_DEAUTHENTICATE, GFP_ATOMIC); 9254 8863 } 8864 + EXPORT_SYMBOL(cfg80211_send_unprot_deauth); 8865 + 8866 + void cfg80211_send_unprot_disassoc(struct net_device *dev, const u8 *buf, 8867 + size_t len) 8868 + { 8869 + struct wireless_dev *wdev = dev->ieee80211_ptr; 8870 + struct wiphy *wiphy = wdev->wiphy; 8871 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 8872 + 8873 + trace_cfg80211_send_unprot_disassoc(dev); 8874 + nl80211_send_mlme_event(rdev, dev, buf, len, 8875 + NL80211_CMD_UNPROT_DISASSOCIATE, GFP_ATOMIC); 8876 + } 8877 + EXPORT_SYMBOL(cfg80211_send_unprot_disassoc); 9255 8878 9256 8879 static void nl80211_send_mlme_timeout(struct cfg80211_registered_device *rdev, 9257 8880 struct net_device *netdev, int cmd, ··· 9464 9067 nlmsg_free(msg); 9465 9068 } 9466 9069 9467 - void nl80211_send_new_peer_candidate(struct cfg80211_registered_device *rdev, 9468 - struct net_device *netdev, 9469 - const u8 *macaddr, const u8* ie, u8 ie_len, 9470 - gfp_t gfp) 9070 + void cfg80211_notify_new_peer_candidate(struct net_device *dev, const u8 *addr, 9071 + const u8* ie, u8 ie_len, gfp_t gfp) 9471 9072 { 9073 + struct wireless_dev *wdev = dev->ieee80211_ptr; 9074 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); 9472 9075 struct sk_buff *msg; 9473 9076 void *hdr; 9077 + 9078 + if (WARN_ON(wdev->iftype != NL80211_IFTYPE_MESH_POINT)) 9079 + return; 9080 + 9081 + trace_cfg80211_notify_new_peer_candidate(dev, addr); 9474 9082 9475 9083 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); 9476 9084 if (!msg) ··· 9488 9086 } 9489 9087 9490 9088 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || 9491 - nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || 9492 - nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, macaddr) || 9089 + nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || 9090 + nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr) || 9493 9091 (ie_len && ie && 9494 9092 nla_put(msg, NL80211_ATTR_IE, ie_len , ie))) 9495 9093 goto nla_put_failure; ··· 9504 9102 genlmsg_cancel(msg, hdr); 9505 9103 nlmsg_free(msg); 9506 9104 } 9105 + EXPORT_SYMBOL(cfg80211_notify_new_peer_candidate); 9507 9106 9508 9107 void nl80211_michael_mic_failure(struct cfg80211_registered_device *rdev, 9509 9108 struct net_device *netdev, const u8 *addr, ··· 9573 9170 nl_freq = nla_nest_start(msg, NL80211_ATTR_FREQ_BEFORE); 9574 9171 if (!nl_freq) 9575 9172 goto nla_put_failure; 9576 - if (nl80211_msg_put_channel(msg, channel_before)) 9173 + if (nl80211_msg_put_channel(msg, channel_before, false)) 9577 9174 goto nla_put_failure; 9578 9175 nla_nest_end(msg, nl_freq); 9579 9176 ··· 9581 9178 nl_freq = nla_nest_start(msg, NL80211_ATTR_FREQ_AFTER); 9582 9179 if (!nl_freq) 9583 9180 goto nla_put_failure; 9584 - if (nl80211_msg_put_channel(msg, channel_after)) 9181 + if (nl80211_msg_put_channel(msg, channel_after, false)) 9585 9182 goto nla_put_failure; 9586 9183 nla_nest_end(msg, nl_freq); 9587 9184 ··· 9643 9240 nlmsg_free(msg); 9644 9241 } 9645 9242 9646 - void nl80211_send_remain_on_channel(struct cfg80211_registered_device *rdev, 9647 - struct wireless_dev *wdev, u64 cookie, 9648 - struct ieee80211_channel *chan, 9649 - unsigned int duration, gfp_t gfp) 9243 + void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie, 9244 + struct ieee80211_channel *chan, 9245 + unsigned int duration, gfp_t gfp) 9650 9246 { 9247 + struct wiphy *wiphy = wdev->wiphy; 9248 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 9249 + 9250 + trace_cfg80211_ready_on_channel(wdev, cookie, chan, duration); 9651 9251 nl80211_send_remain_on_chan_event(NL80211_CMD_REMAIN_ON_CHANNEL, 9652 9252 rdev, wdev, cookie, chan, 9653 9253 duration, gfp); 9654 9254 } 9255 + EXPORT_SYMBOL(cfg80211_ready_on_channel); 9655 9256 9656 - void nl80211_send_remain_on_channel_cancel( 9657 - struct cfg80211_registered_device *rdev, 9658 - struct wireless_dev *wdev, 9659 - u64 cookie, struct ieee80211_channel *chan, gfp_t gfp) 9257 + void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie, 9258 + struct ieee80211_channel *chan, 9259 + gfp_t gfp) 9660 9260 { 9261 + struct wiphy *wiphy = wdev->wiphy; 9262 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 9263 + 9264 + trace_cfg80211_ready_on_channel_expired(wdev, cookie, chan); 9661 9265 nl80211_send_remain_on_chan_event(NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL, 9662 9266 rdev, wdev, cookie, chan, 0, gfp); 9663 9267 } 9268 + EXPORT_SYMBOL(cfg80211_remain_on_channel_expired); 9664 9269 9665 - void nl80211_send_sta_event(struct cfg80211_registered_device *rdev, 9666 - struct net_device *dev, const u8 *mac_addr, 9667 - struct station_info *sinfo, gfp_t gfp) 9270 + void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr, 9271 + struct station_info *sinfo, gfp_t gfp) 9668 9272 { 9273 + struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; 9274 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 9669 9275 struct sk_buff *msg; 9276 + 9277 + trace_cfg80211_new_sta(dev, mac_addr, sinfo); 9670 9278 9671 9279 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); 9672 9280 if (!msg) ··· 9692 9278 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 9693 9279 nl80211_mlme_mcgrp.id, gfp); 9694 9280 } 9281 + EXPORT_SYMBOL(cfg80211_new_sta); 9695 9282 9696 - void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev, 9697 - struct net_device *dev, const u8 *mac_addr, 9698 - gfp_t gfp) 9283 + void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp) 9699 9284 { 9285 + struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; 9286 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 9700 9287 struct sk_buff *msg; 9701 9288 void *hdr; 9289 + 9290 + trace_cfg80211_del_sta(dev, mac_addr); 9702 9291 9703 9292 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); 9704 9293 if (!msg) ··· 9727 9310 genlmsg_cancel(msg, hdr); 9728 9311 nlmsg_free(msg); 9729 9312 } 9313 + EXPORT_SYMBOL(cfg80211_del_sta); 9730 9314 9731 - void nl80211_send_conn_failed_event(struct cfg80211_registered_device *rdev, 9732 - struct net_device *dev, const u8 *mac_addr, 9733 - enum nl80211_connect_failed_reason reason, 9734 - gfp_t gfp) 9315 + void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr, 9316 + enum nl80211_connect_failed_reason reason, 9317 + gfp_t gfp) 9735 9318 { 9319 + struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; 9320 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 9736 9321 struct sk_buff *msg; 9737 9322 void *hdr; 9738 9323 ··· 9763 9344 genlmsg_cancel(msg, hdr); 9764 9345 nlmsg_free(msg); 9765 9346 } 9347 + EXPORT_SYMBOL(cfg80211_conn_failed); 9766 9348 9767 9349 static bool __nl80211_unexpected_frame(struct net_device *dev, u8 cmd, 9768 9350 const u8 *addr, gfp_t gfp) ··· 9808 9388 return true; 9809 9389 } 9810 9390 9811 - bool nl80211_unexpected_frame(struct net_device *dev, const u8 *addr, gfp_t gfp) 9391 + bool cfg80211_rx_spurious_frame(struct net_device *dev, 9392 + const u8 *addr, gfp_t gfp) 9812 9393 { 9813 - return __nl80211_unexpected_frame(dev, NL80211_CMD_UNEXPECTED_FRAME, 9814 - addr, gfp); 9815 - } 9394 + struct wireless_dev *wdev = dev->ieee80211_ptr; 9395 + bool ret; 9816 9396 9817 - bool nl80211_unexpected_4addr_frame(struct net_device *dev, 9818 - const u8 *addr, gfp_t gfp) 9819 - { 9820 - return __nl80211_unexpected_frame(dev, 9821 - NL80211_CMD_UNEXPECTED_4ADDR_FRAME, 9822 - addr, gfp); 9397 + trace_cfg80211_rx_spurious_frame(dev, addr); 9398 + 9399 + if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && 9400 + wdev->iftype != NL80211_IFTYPE_P2P_GO)) { 9401 + trace_cfg80211_return_bool(false); 9402 + return false; 9403 + } 9404 + ret = __nl80211_unexpected_frame(dev, NL80211_CMD_UNEXPECTED_FRAME, 9405 + addr, gfp); 9406 + trace_cfg80211_return_bool(ret); 9407 + return ret; 9823 9408 } 9409 + EXPORT_SYMBOL(cfg80211_rx_spurious_frame); 9410 + 9411 + bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev, 9412 + const u8 *addr, gfp_t gfp) 9413 + { 9414 + struct wireless_dev *wdev = dev->ieee80211_ptr; 9415 + bool ret; 9416 + 9417 + trace_cfg80211_rx_unexpected_4addr_frame(dev, addr); 9418 + 9419 + if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && 9420 + wdev->iftype != NL80211_IFTYPE_P2P_GO && 9421 + wdev->iftype != NL80211_IFTYPE_AP_VLAN)) { 9422 + trace_cfg80211_return_bool(false); 9423 + return false; 9424 + } 9425 + ret = __nl80211_unexpected_frame(dev, 9426 + NL80211_CMD_UNEXPECTED_4ADDR_FRAME, 9427 + addr, gfp); 9428 + trace_cfg80211_return_bool(ret); 9429 + return ret; 9430 + } 9431 + EXPORT_SYMBOL(cfg80211_rx_unexpected_4addr_frame); 9824 9432 9825 9433 int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, 9826 9434 struct wireless_dev *wdev, u32 nlportid, ··· 9888 9440 return -ENOBUFS; 9889 9441 } 9890 9442 9891 - void nl80211_send_mgmt_tx_status(struct cfg80211_registered_device *rdev, 9892 - struct wireless_dev *wdev, u64 cookie, 9893 - const u8 *buf, size_t len, bool ack, 9894 - gfp_t gfp) 9443 + void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie, 9444 + const u8 *buf, size_t len, bool ack, gfp_t gfp) 9895 9445 { 9446 + struct wiphy *wiphy = wdev->wiphy; 9447 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 9896 9448 struct net_device *netdev = wdev->netdev; 9897 9449 struct sk_buff *msg; 9898 9450 void *hdr; 9451 + 9452 + trace_cfg80211_mgmt_tx_status(wdev, cookie, ack); 9899 9453 9900 9454 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); 9901 9455 if (!msg) ··· 9926 9476 genlmsg_cancel(msg, hdr); 9927 9477 nlmsg_free(msg); 9928 9478 } 9479 + EXPORT_SYMBOL(cfg80211_mgmt_tx_status); 9929 9480 9930 - void 9931 - nl80211_send_cqm_rssi_notify(struct cfg80211_registered_device *rdev, 9932 - struct net_device *netdev, 9933 - enum nl80211_cqm_rssi_threshold_event rssi_event, 9934 - gfp_t gfp) 9481 + void cfg80211_cqm_rssi_notify(struct net_device *dev, 9482 + enum nl80211_cqm_rssi_threshold_event rssi_event, 9483 + gfp_t gfp) 9935 9484 { 9485 + struct wireless_dev *wdev = dev->ieee80211_ptr; 9486 + struct wiphy *wiphy = wdev->wiphy; 9487 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 9936 9488 struct sk_buff *msg; 9937 9489 struct nlattr *pinfoattr; 9938 9490 void *hdr; 9491 + 9492 + trace_cfg80211_cqm_rssi_notify(dev, rssi_event); 9939 9493 9940 9494 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); 9941 9495 if (!msg) ··· 9952 9498 } 9953 9499 9954 9500 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || 9955 - nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex)) 9501 + nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex)) 9956 9502 goto nla_put_failure; 9957 9503 9958 9504 pinfoattr = nla_nest_start(msg, NL80211_ATTR_CQM); ··· 9975 9521 genlmsg_cancel(msg, hdr); 9976 9522 nlmsg_free(msg); 9977 9523 } 9524 + EXPORT_SYMBOL(cfg80211_cqm_rssi_notify); 9978 9525 9979 - void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev, 9980 - struct net_device *netdev, const u8 *bssid, 9981 - const u8 *replay_ctr, gfp_t gfp) 9526 + static void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev, 9527 + struct net_device *netdev, const u8 *bssid, 9528 + const u8 *replay_ctr, gfp_t gfp) 9982 9529 { 9983 9530 struct sk_buff *msg; 9984 9531 struct nlattr *rekey_attr; ··· 10021 9566 nlmsg_free(msg); 10022 9567 } 10023 9568 10024 - void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev, 10025 - struct net_device *netdev, int index, 10026 - const u8 *bssid, bool preauth, gfp_t gfp) 9569 + void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid, 9570 + const u8 *replay_ctr, gfp_t gfp) 9571 + { 9572 + struct wireless_dev *wdev = dev->ieee80211_ptr; 9573 + struct wiphy *wiphy = wdev->wiphy; 9574 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 9575 + 9576 + trace_cfg80211_gtk_rekey_notify(dev, bssid); 9577 + nl80211_gtk_rekey_notify(rdev, dev, bssid, replay_ctr, gfp); 9578 + } 9579 + EXPORT_SYMBOL(cfg80211_gtk_rekey_notify); 9580 + 9581 + static void 9582 + nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev, 9583 + struct net_device *netdev, int index, 9584 + const u8 *bssid, bool preauth, gfp_t gfp) 10027 9585 { 10028 9586 struct sk_buff *msg; 10029 9587 struct nlattr *attr; ··· 10079 9611 nlmsg_free(msg); 10080 9612 } 10081 9613 10082 - void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev, 10083 - struct net_device *netdev, 10084 - struct cfg80211_chan_def *chandef, gfp_t gfp) 9614 + void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index, 9615 + const u8 *bssid, bool preauth, gfp_t gfp) 9616 + { 9617 + struct wireless_dev *wdev = dev->ieee80211_ptr; 9618 + struct wiphy *wiphy = wdev->wiphy; 9619 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 9620 + 9621 + trace_cfg80211_pmksa_candidate_notify(dev, index, bssid, preauth); 9622 + nl80211_pmksa_candidate_notify(rdev, dev, index, bssid, preauth, gfp); 9623 + } 9624 + EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify); 9625 + 9626 + static void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev, 9627 + struct net_device *netdev, 9628 + struct cfg80211_chan_def *chandef, 9629 + gfp_t gfp) 10085 9630 { 10086 9631 struct sk_buff *msg; 10087 9632 void *hdr; ··· 10126 9645 nlmsg_free(msg); 10127 9646 } 10128 9647 10129 - void 10130 - nl80211_send_cqm_txe_notify(struct cfg80211_registered_device *rdev, 10131 - struct net_device *netdev, const u8 *peer, 10132 - u32 num_packets, u32 rate, u32 intvl, gfp_t gfp) 9648 + void cfg80211_ch_switch_notify(struct net_device *dev, 9649 + struct cfg80211_chan_def *chandef) 10133 9650 { 9651 + struct wireless_dev *wdev = dev->ieee80211_ptr; 9652 + struct wiphy *wiphy = wdev->wiphy; 9653 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 9654 + 9655 + trace_cfg80211_ch_switch_notify(dev, chandef); 9656 + 9657 + wdev_lock(wdev); 9658 + 9659 + if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && 9660 + wdev->iftype != NL80211_IFTYPE_P2P_GO)) 9661 + goto out; 9662 + 9663 + wdev->channel = chandef->chan; 9664 + nl80211_ch_switch_notify(rdev, dev, chandef, GFP_KERNEL); 9665 + out: 9666 + wdev_unlock(wdev); 9667 + return; 9668 + } 9669 + EXPORT_SYMBOL(cfg80211_ch_switch_notify); 9670 + 9671 + void cfg80211_cqm_txe_notify(struct net_device *dev, 9672 + const u8 *peer, u32 num_packets, 9673 + u32 rate, u32 intvl, gfp_t gfp) 9674 + { 9675 + struct wireless_dev *wdev = dev->ieee80211_ptr; 9676 + struct wiphy *wiphy = wdev->wiphy; 9677 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 10134 9678 struct sk_buff *msg; 10135 9679 struct nlattr *pinfoattr; 10136 9680 void *hdr; ··· 10171 9665 } 10172 9666 10173 9667 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || 10174 - nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || 9668 + nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || 10175 9669 nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, peer)) 10176 9670 goto nla_put_failure; 10177 9671 ··· 10200 9694 genlmsg_cancel(msg, hdr); 10201 9695 nlmsg_free(msg); 10202 9696 } 9697 + EXPORT_SYMBOL(cfg80211_cqm_txe_notify); 10203 9698 10204 9699 void 10205 9700 nl80211_radar_notify(struct cfg80211_registered_device *rdev, ··· 10253 9746 nlmsg_free(msg); 10254 9747 } 10255 9748 10256 - void 10257 - nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev, 10258 - struct net_device *netdev, const u8 *peer, 10259 - u32 num_packets, gfp_t gfp) 9749 + void cfg80211_cqm_pktloss_notify(struct net_device *dev, 9750 + const u8 *peer, u32 num_packets, gfp_t gfp) 10260 9751 { 9752 + struct wireless_dev *wdev = dev->ieee80211_ptr; 9753 + struct wiphy *wiphy = wdev->wiphy; 9754 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 10261 9755 struct sk_buff *msg; 10262 9756 struct nlattr *pinfoattr; 10263 9757 void *hdr; 9758 + 9759 + trace_cfg80211_cqm_pktloss_notify(dev, peer, num_packets); 10264 9760 10265 9761 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); 10266 9762 if (!msg) ··· 10276 9766 } 10277 9767 10278 9768 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || 10279 - nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) || 9769 + nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || 10280 9770 nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, peer)) 10281 9771 goto nla_put_failure; 10282 9772 ··· 10299 9789 genlmsg_cancel(msg, hdr); 10300 9790 nlmsg_free(msg); 10301 9791 } 9792 + EXPORT_SYMBOL(cfg80211_cqm_pktloss_notify); 10302 9793 10303 9794 void cfg80211_probe_status(struct net_device *dev, const u8 *addr, 10304 9795 u64 cookie, bool acked, gfp_t gfp) ··· 10585 10074 static struct notifier_block nl80211_netlink_notifier = { 10586 10075 .notifier_call = nl80211_netlink_notify, 10587 10076 }; 10077 + 10078 + void cfg80211_ft_event(struct net_device *netdev, 10079 + struct cfg80211_ft_event_params *ft_event) 10080 + { 10081 + struct wiphy *wiphy = netdev->ieee80211_ptr->wiphy; 10082 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 10083 + struct sk_buff *msg; 10084 + void *hdr; 10085 + int err; 10086 + 10087 + trace_cfg80211_ft_event(wiphy, netdev, ft_event); 10088 + 10089 + if (!ft_event->target_ap) 10090 + return; 10091 + 10092 + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 10093 + if (!msg) 10094 + return; 10095 + 10096 + hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_FT_EVENT); 10097 + if (!hdr) { 10098 + nlmsg_free(msg); 10099 + return; 10100 + } 10101 + 10102 + nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); 10103 + nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); 10104 + nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, ft_event->target_ap); 10105 + if (ft_event->ies) 10106 + nla_put(msg, NL80211_ATTR_IE, ft_event->ies_len, ft_event->ies); 10107 + if (ft_event->ric_ies) 10108 + nla_put(msg, NL80211_ATTR_IE_RIC, ft_event->ric_ies_len, 10109 + ft_event->ric_ies); 10110 + 10111 + err = genlmsg_end(msg, hdr); 10112 + if (err < 0) { 10113 + nlmsg_free(msg); 10114 + return; 10115 + } 10116 + 10117 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 10118 + nl80211_mlme_mcgrp.id, GFP_KERNEL); 10119 + } 10120 + EXPORT_SYMBOL(cfg80211_ft_event); 10588 10121 10589 10122 /* initialisation/exit functions */ 10590 10123
-68
net/wireless/nl80211.h
··· 29 29 void nl80211_send_disassoc(struct cfg80211_registered_device *rdev, 30 30 struct net_device *netdev, 31 31 const u8 *buf, size_t len, gfp_t gfp); 32 - void nl80211_send_unprot_deauth(struct cfg80211_registered_device *rdev, 33 - struct net_device *netdev, 34 - const u8 *buf, size_t len, gfp_t gfp); 35 - void nl80211_send_unprot_disassoc(struct cfg80211_registered_device *rdev, 36 - struct net_device *netdev, 37 - const u8 *buf, size_t len, gfp_t gfp); 38 32 void nl80211_send_auth_timeout(struct cfg80211_registered_device *rdev, 39 33 struct net_device *netdev, 40 34 const u8 *addr, gfp_t gfp); ··· 48 54 struct net_device *netdev, u16 reason, 49 55 const u8 *ie, size_t ie_len, bool from_ap); 50 56 51 - void nl80211_send_new_peer_candidate(struct cfg80211_registered_device *rdev, 52 - struct net_device *netdev, 53 - const u8 *macaddr, const u8* ie, u8 ie_len, 54 - gfp_t gfp); 55 57 void 56 58 nl80211_michael_mic_failure(struct cfg80211_registered_device *rdev, 57 59 struct net_device *netdev, const u8 *addr, ··· 63 73 struct net_device *netdev, const u8 *bssid, 64 74 gfp_t gfp); 65 75 66 - void nl80211_send_remain_on_channel(struct cfg80211_registered_device *rdev, 67 - struct wireless_dev *wdev, u64 cookie, 68 - struct ieee80211_channel *chan, 69 - unsigned int duration, gfp_t gfp); 70 - void nl80211_send_remain_on_channel_cancel( 71 - struct cfg80211_registered_device *rdev, 72 - struct wireless_dev *wdev, 73 - u64 cookie, struct ieee80211_channel *chan, gfp_t gfp); 74 - 75 - void nl80211_send_sta_event(struct cfg80211_registered_device *rdev, 76 - struct net_device *dev, const u8 *mac_addr, 77 - struct station_info *sinfo, gfp_t gfp); 78 - void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev, 79 - struct net_device *dev, const u8 *mac_addr, 80 - gfp_t gfp); 81 - 82 - void nl80211_send_conn_failed_event(struct cfg80211_registered_device *rdev, 83 - struct net_device *dev, const u8 *mac_addr, 84 - enum nl80211_connect_failed_reason reason, 85 - gfp_t gfp); 86 - 87 76 int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, 88 77 struct wireless_dev *wdev, u32 nlpid, 89 78 int freq, int sig_dbm, 90 79 const u8 *buf, size_t len, gfp_t gfp); 91 - void nl80211_send_mgmt_tx_status(struct cfg80211_registered_device *rdev, 92 - struct wireless_dev *wdev, u64 cookie, 93 - const u8 *buf, size_t len, bool ack, 94 - gfp_t gfp); 95 - 96 - void 97 - nl80211_send_cqm_rssi_notify(struct cfg80211_registered_device *rdev, 98 - struct net_device *netdev, 99 - enum nl80211_cqm_rssi_threshold_event rssi_event, 100 - gfp_t gfp); 101 80 102 81 void 103 82 nl80211_radar_notify(struct cfg80211_registered_device *rdev, 104 83 struct cfg80211_chan_def *chandef, 105 84 enum nl80211_radar_event event, 106 85 struct net_device *netdev, gfp_t gfp); 107 - 108 - void 109 - nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev, 110 - struct net_device *netdev, const u8 *peer, 111 - u32 num_packets, gfp_t gfp); 112 - 113 - void 114 - nl80211_send_cqm_txe_notify(struct cfg80211_registered_device *rdev, 115 - struct net_device *netdev, const u8 *peer, 116 - u32 num_packets, u32 rate, u32 intvl, gfp_t gfp); 117 - 118 - void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev, 119 - struct net_device *netdev, const u8 *bssid, 120 - const u8 *replay_ctr, gfp_t gfp); 121 - 122 - void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev, 123 - struct net_device *netdev, int index, 124 - const u8 *bssid, bool preauth, gfp_t gfp); 125 - 126 - void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev, 127 - struct net_device *dev, 128 - struct cfg80211_chan_def *chandef, gfp_t gfp); 129 - 130 - bool nl80211_unexpected_frame(struct net_device *dev, 131 - const u8 *addr, gfp_t gfp); 132 - bool nl80211_unexpected_4addr_frame(struct net_device *dev, 133 - const u8 *addr, gfp_t gfp); 134 86 135 87 #endif /* __NET_WIRELESS_NL80211_H */
+17 -3
net/wireless/rdev-ops.h
··· 6 6 #include "core.h" 7 7 #include "trace.h" 8 8 9 - static inline int rdev_suspend(struct cfg80211_registered_device *rdev) 9 + static inline int rdev_suspend(struct cfg80211_registered_device *rdev, 10 + struct cfg80211_wowlan *wowlan) 10 11 { 11 12 int ret; 12 - trace_rdev_suspend(&rdev->wiphy, rdev->wowlan); 13 - ret = rdev->ops->suspend(&rdev->wiphy, rdev->wowlan); 13 + trace_rdev_suspend(&rdev->wiphy, wowlan); 14 + ret = rdev->ops->suspend(&rdev->wiphy, wowlan); 14 15 trace_rdev_return_int(&rdev->wiphy, ret); 15 16 return ret; 16 17 } ··· 888 887 trace_rdev_return_int(&rdev->wiphy, ret); 889 888 return ret; 890 889 } 890 + 891 + static inline int rdev_update_ft_ies(struct cfg80211_registered_device *rdev, 892 + struct net_device *dev, 893 + struct cfg80211_update_ft_ies_params *ftie) 894 + { 895 + int ret; 896 + 897 + trace_rdev_update_ft_ies(&rdev->wiphy, dev, ftie); 898 + ret = rdev->ops->update_ft_ies(&rdev->wiphy, dev, ftie); 899 + trace_rdev_return_int(&rdev->wiphy, ret); 900 + return ret; 901 + } 902 + 891 903 #endif /* __CFG80211_RDEV_OPS */
+3 -3
net/wireless/reg.c
··· 184 184 NL80211_RRF_NO_IBSS | 185 185 NL80211_RRF_NO_OFDM), 186 186 /* IEEE 802.11a, channel 36..48 */ 187 - REG_RULE(5180-10, 5240+10, 40, 6, 20, 187 + REG_RULE(5180-10, 5240+10, 80, 6, 20, 188 188 NL80211_RRF_PASSIVE_SCAN | 189 189 NL80211_RRF_NO_IBSS), 190 190 191 - /* NB: 5260 MHz - 5700 MHz requies DFS */ 191 + /* NB: 5260 MHz - 5700 MHz requires DFS */ 192 192 193 193 /* IEEE 802.11a, channel 149..165 */ 194 - REG_RULE(5745-10, 5825+10, 40, 6, 20, 194 + REG_RULE(5745-10, 5825+10, 80, 6, 20, 195 195 NL80211_RRF_PASSIVE_SCAN | 196 196 NL80211_RRF_NO_IBSS), 197 197
+15 -11
net/wireless/sme.c
··· 159 159 { 160 160 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); 161 161 struct cfg80211_connect_params *params; 162 - const u8 *prev_bssid = NULL; 162 + struct cfg80211_assoc_request req = {}; 163 163 int err; 164 164 165 165 ASSERT_WDEV_LOCK(wdev); ··· 186 186 BUG_ON(!rdev->ops->assoc); 187 187 wdev->conn->state = CFG80211_CONN_ASSOCIATING; 188 188 if (wdev->conn->prev_bssid_valid) 189 - prev_bssid = wdev->conn->prev_bssid; 190 - err = __cfg80211_mlme_assoc(rdev, wdev->netdev, 191 - params->channel, params->bssid, 192 - prev_bssid, 193 - params->ssid, params->ssid_len, 194 - params->ie, params->ie_len, 195 - params->mfp != NL80211_MFP_NO, 196 - &params->crypto, 197 - params->flags, &params->ht_capa, 198 - &params->ht_capa_mask); 189 + req.prev_bssid = wdev->conn->prev_bssid; 190 + req.ie = params->ie; 191 + req.ie_len = params->ie_len; 192 + req.use_mfp = params->mfp != NL80211_MFP_NO; 193 + req.crypto = params->crypto; 194 + req.flags = params->flags; 195 + req.ht_capa = params->ht_capa; 196 + req.ht_capa_mask = params->ht_capa_mask; 197 + req.vht_capa = params->vht_capa; 198 + req.vht_capa_mask = params->vht_capa_mask; 199 + 200 + err = __cfg80211_mlme_assoc(rdev, wdev->netdev, params->channel, 201 + params->bssid, params->ssid, 202 + params->ssid_len, &req); 199 203 if (err) 200 204 __cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid, 201 205 NULL, 0,
+20 -5
net/wireless/sysfs.c
··· 83 83 return 0; 84 84 } 85 85 86 + static void cfg80211_leave_all(struct cfg80211_registered_device *rdev) 87 + { 88 + struct wireless_dev *wdev; 89 + 90 + list_for_each_entry(wdev, &rdev->wdev_list, list) 91 + cfg80211_leave(rdev, wdev); 92 + } 93 + 86 94 static int wiphy_suspend(struct device *dev, pm_message_t state) 87 95 { 88 96 struct cfg80211_registered_device *rdev = dev_to_rdev(dev); ··· 98 90 99 91 rdev->suspend_at = get_seconds(); 100 92 101 - if (rdev->ops->suspend) { 102 - rtnl_lock(); 103 - if (rdev->wiphy.registered) 104 - ret = rdev_suspend(rdev); 105 - rtnl_unlock(); 93 + rtnl_lock(); 94 + if (rdev->wiphy.registered) { 95 + if (!rdev->wowlan) 96 + cfg80211_leave_all(rdev); 97 + if (rdev->ops->suspend) 98 + ret = rdev_suspend(rdev, rdev->wowlan); 99 + if (ret == 1) { 100 + /* Driver refuse to configure wowlan */ 101 + cfg80211_leave_all(rdev); 102 + ret = rdev_suspend(rdev, NULL); 103 + } 106 104 } 105 + rtnl_unlock(); 107 106 108 107 return ret; 109 108 }
+46
net/wireless/trace.h
··· 1785 1785 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->acl_policy) 1786 1786 ); 1787 1787 1788 + TRACE_EVENT(rdev_update_ft_ies, 1789 + TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, 1790 + struct cfg80211_update_ft_ies_params *ftie), 1791 + TP_ARGS(wiphy, netdev, ftie), 1792 + TP_STRUCT__entry( 1793 + WIPHY_ENTRY 1794 + NETDEV_ENTRY 1795 + __field(u16, md) 1796 + __dynamic_array(u8, ie, ftie->ie_len) 1797 + ), 1798 + TP_fast_assign( 1799 + WIPHY_ASSIGN; 1800 + NETDEV_ASSIGN; 1801 + __entry->md = ftie->md; 1802 + memcpy(__get_dynamic_array(ie), ftie->ie, ftie->ie_len); 1803 + ), 1804 + TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", md: 0x%x", 1805 + WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->md) 1806 + ); 1807 + 1788 1808 /************************************************************* 1789 1809 * cfg80211 exported functions traces * 1790 1810 *************************************************************/ ··· 2431 2411 wakeup->packet_present_len); 2432 2412 ), 2433 2413 TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT, WIPHY_PR_ARG, WDEV_PR_ARG) 2414 + ); 2415 + 2416 + TRACE_EVENT(cfg80211_ft_event, 2417 + TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, 2418 + struct cfg80211_ft_event_params *ft_event), 2419 + TP_ARGS(wiphy, netdev, ft_event), 2420 + TP_STRUCT__entry( 2421 + WIPHY_ENTRY 2422 + NETDEV_ENTRY 2423 + __dynamic_array(u8, ies, ft_event->ies_len) 2424 + MAC_ENTRY(target_ap) 2425 + __dynamic_array(u8, ric_ies, ft_event->ric_ies_len) 2426 + ), 2427 + TP_fast_assign( 2428 + WIPHY_ASSIGN; 2429 + NETDEV_ASSIGN; 2430 + if (ft_event->ies) 2431 + memcpy(__get_dynamic_array(ies), ft_event->ies, 2432 + ft_event->ies_len); 2433 + MAC_ASSIGN(target_ap, ft_event->target_ap); 2434 + if (ft_event->ric_ies) 2435 + memcpy(__get_dynamic_array(ric_ies), ft_event->ric_ies, 2436 + ft_event->ric_ies_len); 2437 + ), 2438 + TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", target_ap: " MAC_PR_FMT, 2439 + WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(target_ap)) 2434 2440 ); 2435 2441 2436 2442 #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */