cfg.c (aa489f0f268595bd33d9649030bd1a43c28927a0) cfg.c (d1e33e654ef6bb3dee766353ed9dd31e7dcb8a94)
1/*
2 * mac80211 configuration hooks for cfg80211
3 *
4 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
5 *
6 * This file is GPLv2 as found in COPYING.
7 */
8

--- 119 unchanged lines hidden (view full) ---

128 return 0;
129}
130
131static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
132 u8 key_idx, bool pairwise, const u8 *mac_addr,
133 struct key_params *params)
134{
135 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1/*
2 * mac80211 configuration hooks for cfg80211
3 *
4 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
5 *
6 * This file is GPLv2 as found in COPYING.
7 */
8

--- 119 unchanged lines hidden (view full) ---

128 return 0;
129}
130
131static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
132 u8 key_idx, bool pairwise, const u8 *mac_addr,
133 struct key_params *params)
134{
135 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
136 struct ieee80211_local *local = sdata->local;
136 struct sta_info *sta = NULL;
137 struct sta_info *sta = NULL;
138 const struct ieee80211_cipher_scheme *cs = NULL;
137 struct ieee80211_key *key;
138 int err;
139
140 if (!ieee80211_sdata_running(sdata))
141 return -ENETDOWN;
142
143 /* reject WEP and TKIP keys if WEP failed to initialize */
144 switch (params->cipher) {
145 case WLAN_CIPHER_SUITE_WEP40:
146 case WLAN_CIPHER_SUITE_TKIP:
147 case WLAN_CIPHER_SUITE_WEP104:
139 struct ieee80211_key *key;
140 int err;
141
142 if (!ieee80211_sdata_running(sdata))
143 return -ENETDOWN;
144
145 /* reject WEP and TKIP keys if WEP failed to initialize */
146 switch (params->cipher) {
147 case WLAN_CIPHER_SUITE_WEP40:
148 case WLAN_CIPHER_SUITE_TKIP:
149 case WLAN_CIPHER_SUITE_WEP104:
148 if (IS_ERR(sdata->local->wep_tx_tfm))
150 if (IS_ERR(local->wep_tx_tfm))
149 return -EINVAL;
150 break;
151 return -EINVAL;
152 break;
153 case WLAN_CIPHER_SUITE_CCMP:
154 case WLAN_CIPHER_SUITE_AES_CMAC:
155 case WLAN_CIPHER_SUITE_GCMP:
156 break;
151 default:
157 default:
158 cs = ieee80211_cs_get(local, params->cipher, sdata->vif.type);
152 break;
153 }
154
155 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
159 break;
160 }
161
162 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
156 params->key, params->seq_len, params->seq);
163 params->key, params->seq_len, params->seq,
164 cs);
157 if (IS_ERR(key))
158 return PTR_ERR(key);
159
160 if (pairwise)
161 key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
162
165 if (IS_ERR(key))
166 return PTR_ERR(key);
167
168 if (pairwise)
169 key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
170
163 mutex_lock(&sdata->local->sta_mtx);
171 mutex_lock(&local->sta_mtx);
164
165 if (mac_addr) {
166 if (ieee80211_vif_is_mesh(&sdata->vif))
167 sta = sta_info_get(sdata, mac_addr);
168 else
169 sta = sta_info_get_bss(sdata, mac_addr);
170 /*
171 * The ASSOC test makes sure the driver is ready to

--- 39 unchanged lines hidden (view full) ---

211 case NUM_NL80211_IFTYPES:
212 case NL80211_IFTYPE_P2P_CLIENT:
213 case NL80211_IFTYPE_P2P_GO:
214 /* shouldn't happen */
215 WARN_ON_ONCE(1);
216 break;
217 }
218
172
173 if (mac_addr) {
174 if (ieee80211_vif_is_mesh(&sdata->vif))
175 sta = sta_info_get(sdata, mac_addr);
176 else
177 sta = sta_info_get_bss(sdata, mac_addr);
178 /*
179 * The ASSOC test makes sure the driver is ready to

--- 39 unchanged lines hidden (view full) ---

219 case NUM_NL80211_IFTYPES:
220 case NL80211_IFTYPE_P2P_CLIENT:
221 case NL80211_IFTYPE_P2P_GO:
222 /* shouldn't happen */
223 WARN_ON_ONCE(1);
224 break;
225 }
226
227 if (sta)
228 sta->cipher_scheme = cs;
229
219 err = ieee80211_key_link(key, sdata, sta);
220
221 out_unlock:
230 err = ieee80211_key_link(key, sdata, sta);
231
232 out_unlock:
222 mutex_unlock(&sdata->local->sta_mtx);
233 mutex_unlock(&local->sta_mtx);
223
224 return err;
225}
226
227static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
228 u8 key_idx, bool pairwise, const u8 *mac_addr)
229{
230 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);

--- 8 unchanged lines hidden (view full) ---

239 if (mac_addr) {
240 ret = -ENOENT;
241
242 sta = sta_info_get_bss(sdata, mac_addr);
243 if (!sta)
244 goto out_unlock;
245
246 if (pairwise)
234
235 return err;
236}
237
238static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
239 u8 key_idx, bool pairwise, const u8 *mac_addr)
240{
241 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);

--- 8 unchanged lines hidden (view full) ---

250 if (mac_addr) {
251 ret = -ENOENT;
252
253 sta = sta_info_get_bss(sdata, mac_addr);
254 if (!sta)
255 goto out_unlock;
256
257 if (pairwise)
247 key = key_mtx_dereference(local, sta->ptk);
258 key = key_mtx_dereference(local, sta->ptk[key_idx]);
248 else
249 key = key_mtx_dereference(local, sta->gtk[key_idx]);
250 } else
251 key = key_mtx_dereference(local, sdata->keys[key_idx]);
252
253 if (!key) {
254 ret = -ENOENT;
255 goto out_unlock;

--- 30 unchanged lines hidden (view full) ---

286 rcu_read_lock();
287
288 if (mac_addr) {
289 sta = sta_info_get_bss(sdata, mac_addr);
290 if (!sta)
291 goto out;
292
293 if (pairwise)
259 else
260 key = key_mtx_dereference(local, sta->gtk[key_idx]);
261 } else
262 key = key_mtx_dereference(local, sdata->keys[key_idx]);
263
264 if (!key) {
265 ret = -ENOENT;
266 goto out_unlock;

--- 30 unchanged lines hidden (view full) ---

297 rcu_read_lock();
298
299 if (mac_addr) {
300 sta = sta_info_get_bss(sdata, mac_addr);
301 if (!sta)
302 goto out;
303
304 if (pairwise)
294 key = rcu_dereference(sta->ptk);
305 key = rcu_dereference(sta->ptk[key_idx]);
295 else if (key_idx < NUM_DEFAULT_KEYS)
296 key = rcu_dereference(sta->gtk[key_idx]);
297 } else
298 key = rcu_dereference(sdata->keys[key_idx]);
299
300 if (!key)
301 goto out;
302

--- 213 unchanged lines hidden (view full) ---

516#ifdef CONFIG_MAC80211_MESH
517 sinfo->filled |= STATION_INFO_LLID |
518 STATION_INFO_PLID |
519 STATION_INFO_PLINK_STATE |
520 STATION_INFO_LOCAL_PM |
521 STATION_INFO_PEER_PM |
522 STATION_INFO_NONPEER_PM;
523
306 else if (key_idx < NUM_DEFAULT_KEYS)
307 key = rcu_dereference(sta->gtk[key_idx]);
308 } else
309 key = rcu_dereference(sdata->keys[key_idx]);
310
311 if (!key)
312 goto out;
313

--- 213 unchanged lines hidden (view full) ---

527#ifdef CONFIG_MAC80211_MESH
528 sinfo->filled |= STATION_INFO_LLID |
529 STATION_INFO_PLID |
530 STATION_INFO_PLINK_STATE |
531 STATION_INFO_LOCAL_PM |
532 STATION_INFO_PEER_PM |
533 STATION_INFO_NONPEER_PM;
534
524 sinfo->llid = le16_to_cpu(sta->llid);
525 sinfo->plid = le16_to_cpu(sta->plid);
535 sinfo->llid = sta->llid;
536 sinfo->plid = sta->plid;
526 sinfo->plink_state = sta->plink_state;
527 if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
528 sinfo->filled |= STATION_INFO_T_OFFSET;
529 sinfo->t_offset = sta->t_offset;
530 }
531 sinfo->local_pm = sta->local_pm;
532 sinfo->peer_pm = sta->peer_pm;
533 sinfo->nonpeer_pm = sta->nonpeer_pm;

--- 307 unchanged lines hidden (view full) ---

841static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
842 const u8 *resp, size_t resp_len)
843{
844 struct probe_resp *new, *old;
845
846 if (!resp || !resp_len)
847 return 1;
848
537 sinfo->plink_state = sta->plink_state;
538 if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
539 sinfo->filled |= STATION_INFO_T_OFFSET;
540 sinfo->t_offset = sta->t_offset;
541 }
542 sinfo->local_pm = sta->local_pm;
543 sinfo->peer_pm = sta->peer_pm;
544 sinfo->nonpeer_pm = sta->nonpeer_pm;

--- 307 unchanged lines hidden (view full) ---

852static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
853 const u8 *resp, size_t resp_len)
854{
855 struct probe_resp *new, *old;
856
857 if (!resp || !resp_len)
858 return 1;
859
849 old = rtnl_dereference(sdata->u.ap.probe_resp);
860 old = sdata_dereference(sdata->u.ap.probe_resp, sdata);
850
851 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
852 if (!new)
853 return -ENOMEM;
854
855 new->len = resp_len;
856 memcpy(new->data, resp, resp_len);
857

--- 7 unchanged lines hidden (view full) ---

865int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
866 struct cfg80211_beacon_data *params)
867{
868 struct beacon_data *new, *old;
869 int new_head_len, new_tail_len;
870 int size, err;
871 u32 changed = BSS_CHANGED_BEACON;
872
861
862 new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
863 if (!new)
864 return -ENOMEM;
865
866 new->len = resp_len;
867 memcpy(new->data, resp, resp_len);
868

--- 7 unchanged lines hidden (view full) ---

876int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
877 struct cfg80211_beacon_data *params)
878{
879 struct beacon_data *new, *old;
880 int new_head_len, new_tail_len;
881 int size, err;
882 u32 changed = BSS_CHANGED_BEACON;
883
873 old = rtnl_dereference(sdata->u.ap.beacon);
884 old = sdata_dereference(sdata->u.ap.beacon, sdata);
874
885
886
875 /* Need to have a beacon head if we don't have one yet */
876 if (!params->head && !old)
877 return -EINVAL;
878
879 /* new or old head? */
880 if (params->head)
881 new_head_len = params->head_len;
882 else

--- 59 unchanged lines hidden (view full) ---

942 struct ieee80211_sub_if_data *vlan;
943 u32 changed = BSS_CHANGED_BEACON_INT |
944 BSS_CHANGED_BEACON_ENABLED |
945 BSS_CHANGED_BEACON |
946 BSS_CHANGED_SSID |
947 BSS_CHANGED_P2P_PS;
948 int err;
949
887 /* Need to have a beacon head if we don't have one yet */
888 if (!params->head && !old)
889 return -EINVAL;
890
891 /* new or old head? */
892 if (params->head)
893 new_head_len = params->head_len;
894 else

--- 59 unchanged lines hidden (view full) ---

954 struct ieee80211_sub_if_data *vlan;
955 u32 changed = BSS_CHANGED_BEACON_INT |
956 BSS_CHANGED_BEACON_ENABLED |
957 BSS_CHANGED_BEACON |
958 BSS_CHANGED_SSID |
959 BSS_CHANGED_P2P_PS;
960 int err;
961
950 old = rtnl_dereference(sdata->u.ap.beacon);
962 old = sdata_dereference(sdata->u.ap.beacon, sdata);
951 if (old)
952 return -EALREADY;
953
954 /* TODO: make hostapd tell us what it wants */
955 sdata->smps_mode = IEEE80211_SMPS_OFF;
956 sdata->needed_rx_chains = sdata->local->rx_chains;
957 sdata->radar_required = params->radar_required;
958

--- 4 unchanged lines hidden (view full) ---

963 ieee80211_vif_copy_chanctx_to_vlans(sdata, false);
964
965 /*
966 * Apply control port protocol, this allows us to
967 * not encrypt dynamic WEP control frames.
968 */
969 sdata->control_port_protocol = params->crypto.control_port_ethertype;
970 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
963 if (old)
964 return -EALREADY;
965
966 /* TODO: make hostapd tell us what it wants */
967 sdata->smps_mode = IEEE80211_SMPS_OFF;
968 sdata->needed_rx_chains = sdata->local->rx_chains;
969 sdata->radar_required = params->radar_required;
970

--- 4 unchanged lines hidden (view full) ---

975 ieee80211_vif_copy_chanctx_to_vlans(sdata, false);
976
977 /*
978 * Apply control port protocol, this allows us to
979 * not encrypt dynamic WEP control frames.
980 */
981 sdata->control_port_protocol = params->crypto.control_port_ethertype;
982 sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
983 sdata->encrypt_headroom = ieee80211_cs_headroom(sdata->local,
984 &params->crypto,
985 sdata->vif.type);
986
971 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
972 vlan->control_port_protocol =
973 params->crypto.control_port_ethertype;
974 vlan->control_port_no_encrypt =
975 params->crypto.control_port_no_encrypt;
987 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
988 vlan->control_port_protocol =
989 params->crypto.control_port_ethertype;
990 vlan->control_port_no_encrypt =
991 params->crypto.control_port_no_encrypt;
992 vlan->encrypt_headroom =
993 ieee80211_cs_headroom(sdata->local,
994 &params->crypto,
995 vlan->vif.type);
976 }
977
978 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
979 sdata->vif.bss_conf.dtim_period = params->dtim_period;
980 sdata->vif.bss_conf.enable_beacon = true;
981
982 sdata->vif.bss_conf.ssid_len = params->ssid_len;
983 if (params->ssid_len)

--- 12 unchanged lines hidden (view full) ---

996
997 err = ieee80211_assign_beacon(sdata, &params->beacon);
998 if (err < 0)
999 return err;
1000 changed |= err;
1001
1002 err = drv_start_ap(sdata->local, sdata);
1003 if (err) {
996 }
997
998 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
999 sdata->vif.bss_conf.dtim_period = params->dtim_period;
1000 sdata->vif.bss_conf.enable_beacon = true;
1001
1002 sdata->vif.bss_conf.ssid_len = params->ssid_len;
1003 if (params->ssid_len)

--- 12 unchanged lines hidden (view full) ---

1016
1017 err = ieee80211_assign_beacon(sdata, &params->beacon);
1018 if (err < 0)
1019 return err;
1020 changed |= err;
1021
1022 err = drv_start_ap(sdata->local, sdata);
1023 if (err) {
1004 old = rtnl_dereference(sdata->u.ap.beacon);
1024 old = sdata_dereference(sdata->u.ap.beacon, sdata);
1025
1005 if (old)
1006 kfree_rcu(old, rcu_head);
1007 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
1008 return err;
1009 }
1010
1011 ieee80211_bss_info_change_notify(sdata, changed);
1012

--- 14 unchanged lines hidden (view full) ---

1027 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1028
1029 /* don't allow changing the beacon while CSA is in place - offset
1030 * of channel switch counter may change
1031 */
1032 if (sdata->vif.csa_active)
1033 return -EBUSY;
1034
1026 if (old)
1027 kfree_rcu(old, rcu_head);
1028 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
1029 return err;
1030 }
1031
1032 ieee80211_bss_info_change_notify(sdata, changed);
1033

--- 14 unchanged lines hidden (view full) ---

1048 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1049
1050 /* don't allow changing the beacon while CSA is in place - offset
1051 * of channel switch counter may change
1052 */
1053 if (sdata->vif.csa_active)
1054 return -EBUSY;
1055
1035 old = rtnl_dereference(sdata->u.ap.beacon);
1056 old = sdata_dereference(sdata->u.ap.beacon, sdata);
1036 if (!old)
1037 return -ENOENT;
1038
1039 err = ieee80211_assign_beacon(sdata, params);
1040 if (err < 0)
1041 return err;
1042 ieee80211_bss_info_change_notify(sdata, err);
1043 return 0;
1044}
1045
1046static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
1047{
1048 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1049 struct ieee80211_sub_if_data *vlan;
1050 struct ieee80211_local *local = sdata->local;
1051 struct beacon_data *old_beacon;
1052 struct probe_resp *old_probe_resp;
1057 if (!old)
1058 return -ENOENT;
1059
1060 err = ieee80211_assign_beacon(sdata, params);
1061 if (err < 0)
1062 return err;
1063 ieee80211_bss_info_change_notify(sdata, err);
1064 return 0;
1065}
1066
1067static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
1068{
1069 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1070 struct ieee80211_sub_if_data *vlan;
1071 struct ieee80211_local *local = sdata->local;
1072 struct beacon_data *old_beacon;
1073 struct probe_resp *old_probe_resp;
1074 struct cfg80211_chan_def chandef;
1053
1075
1054 old_beacon = rtnl_dereference(sdata->u.ap.beacon);
1076 old_beacon = sdata_dereference(sdata->u.ap.beacon, sdata);
1055 if (!old_beacon)
1056 return -ENOENT;
1077 if (!old_beacon)
1078 return -ENOENT;
1057 old_probe_resp = rtnl_dereference(sdata->u.ap.probe_resp);
1079 old_probe_resp = sdata_dereference(sdata->u.ap.probe_resp, sdata);
1058
1059 /* abort any running channel switch */
1060 sdata->vif.csa_active = false;
1080
1081 /* abort any running channel switch */
1082 sdata->vif.csa_active = false;
1061 cancel_work_sync(&sdata->csa_finalize_work);
1083 kfree(sdata->u.ap.next_beacon);
1084 sdata->u.ap.next_beacon = NULL;
1085
1062 cancel_work_sync(&sdata->u.ap.request_smps_work);
1063
1064 /* turn off carrier for this interface and dependent VLANs */
1065 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1066 netif_carrier_off(vlan->dev);
1067 netif_carrier_off(dev);
1068
1069 /* remove beacon and probe response */

--- 16 unchanged lines hidden (view full) ---

1086 ieee80211_free_keys(sdata);
1087
1088 sdata->vif.bss_conf.enable_beacon = false;
1089 sdata->vif.bss_conf.ssid_len = 0;
1090 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1091 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
1092
1093 if (sdata->wdev.cac_started) {
1086 cancel_work_sync(&sdata->u.ap.request_smps_work);
1087
1088 /* turn off carrier for this interface and dependent VLANs */
1089 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1090 netif_carrier_off(vlan->dev);
1091 netif_carrier_off(dev);
1092
1093 /* remove beacon and probe response */

--- 16 unchanged lines hidden (view full) ---

1110 ieee80211_free_keys(sdata);
1111
1112 sdata->vif.bss_conf.enable_beacon = false;
1113 sdata->vif.bss_conf.ssid_len = 0;
1114 clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
1115 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
1116
1117 if (sdata->wdev.cac_started) {
1118 chandef = sdata->vif.bss_conf.chandef;
1094 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
1119 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
1095 cfg80211_cac_event(sdata->dev, NL80211_RADAR_CAC_ABORTED,
1120 cfg80211_cac_event(sdata->dev, &chandef,
1121 NL80211_RADAR_CAC_ABORTED,
1096 GFP_KERNEL);
1097 }
1098
1099 drv_stop_ap(sdata->local, sdata);
1100
1101 /* free all potentially still buffered bcast frames */
1102 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
1103 skb_queue_purge(&sdata->u.ap.ps.bc_buf);

--- 259 unchanged lines hidden (view full) ---

1363 changed |= mesh_plink_block(sta);
1364 break;
1365 }
1366
1367 if (params->local_pm)
1368 changed |=
1369 ieee80211_mps_set_sta_local_pm(sta,
1370 params->local_pm);
1122 GFP_KERNEL);
1123 }
1124
1125 drv_stop_ap(sdata->local, sdata);
1126
1127 /* free all potentially still buffered bcast frames */
1128 local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
1129 skb_queue_purge(&sdata->u.ap.ps.bc_buf);

--- 259 unchanged lines hidden (view full) ---

1389 changed |= mesh_plink_block(sta);
1390 break;
1391 }
1392
1393 if (params->local_pm)
1394 changed |=
1395 ieee80211_mps_set_sta_local_pm(sta,
1396 params->local_pm);
1371 ieee80211_mbss_info_change_notify(sdata, changed);
1397 ieee80211_bss_info_change_notify(sdata, changed);
1372#endif
1373 }
1374
1375 return 0;
1376}
1377
1378static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1379 u8 *mac, struct station_parameters *params)

--- 568 unchanged lines hidden (view full) ---

1948static int ieee80211_change_bss(struct wiphy *wiphy,
1949 struct net_device *dev,
1950 struct bss_parameters *params)
1951{
1952 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1953 enum ieee80211_band band;
1954 u32 changed = 0;
1955
1398#endif
1399 }
1400
1401 return 0;
1402}
1403
1404static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
1405 u8 *mac, struct station_parameters *params)

--- 568 unchanged lines hidden (view full) ---

1974static int ieee80211_change_bss(struct wiphy *wiphy,
1975 struct net_device *dev,
1976 struct bss_parameters *params)
1977{
1978 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1979 enum ieee80211_band band;
1980 u32 changed = 0;
1981
1956 if (!rtnl_dereference(sdata->u.ap.beacon))
1982 if (!sdata_dereference(sdata->u.ap.beacon, sdata))
1957 return -ENOENT;
1958
1959 band = ieee80211_get_sdata_band(sdata);
1960
1961 if (params->use_cts_prot >= 0) {
1962 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
1963 changed |= BSS_CHANGED_ERP_CTS_PROT;
1964 }

--- 518 unchanged lines hidden (view full) ---

2483}
2484
2485static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2486 bool enabled, int timeout)
2487{
2488 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2489 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2490
1983 return -ENOENT;
1984
1985 band = ieee80211_get_sdata_band(sdata);
1986
1987 if (params->use_cts_prot >= 0) {
1988 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
1989 changed |= BSS_CHANGED_ERP_CTS_PROT;
1990 }

--- 518 unchanged lines hidden (view full) ---

2509}
2510
2511static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2512 bool enabled, int timeout)
2513{
2514 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2515 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2516
2491 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2517 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
2518 sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
2492 return -EOPNOTSUPP;
2493
2494 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
2495 return -EOPNOTSUPP;
2496
2497 if (enabled == sdata->u.mgd.powersave &&
2498 timeout == local->dynamic_ps_forced_timeout)
2499 return 0;

--- 56 unchanged lines hidden (view full) ---

2556 return ret;
2557 }
2558
2559 for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
2560 struct ieee80211_supported_band *sband = wiphy->bands[i];
2561 int j;
2562
2563 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
2519 return -EOPNOTSUPP;
2520
2521 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
2522 return -EOPNOTSUPP;
2523
2524 if (enabled == sdata->u.mgd.powersave &&
2525 timeout == local->dynamic_ps_forced_timeout)
2526 return 0;

--- 56 unchanged lines hidden (view full) ---

2583 return ret;
2584 }
2585
2586 for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
2587 struct ieee80211_supported_band *sband = wiphy->bands[i];
2588 int j;
2589
2590 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
2564 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs,
2565 sizeof(mask->control[i].mcs));
2591 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs,
2592 sizeof(mask->control[i].ht_mcs));
2566
2567 sdata->rc_has_mcs_mask[i] = false;
2568 if (!sband)
2569 continue;
2570
2571 for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++)
2572 if (~sdata->rc_rateidx_mcs_mask[i][j]) {
2573 sdata->rc_has_mcs_mask[i] = true;

--- 384 unchanged lines hidden (view full) ---

2958void ieee80211_csa_finalize_work(struct work_struct *work)
2959{
2960 struct ieee80211_sub_if_data *sdata =
2961 container_of(work, struct ieee80211_sub_if_data,
2962 csa_finalize_work);
2963 struct ieee80211_local *local = sdata->local;
2964 int err, changed = 0;
2965
2593
2594 sdata->rc_has_mcs_mask[i] = false;
2595 if (!sband)
2596 continue;
2597
2598 for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++)
2599 if (~sdata->rc_rateidx_mcs_mask[i][j]) {
2600 sdata->rc_has_mcs_mask[i] = true;

--- 384 unchanged lines hidden (view full) ---

2985void ieee80211_csa_finalize_work(struct work_struct *work)
2986{
2987 struct ieee80211_sub_if_data *sdata =
2988 container_of(work, struct ieee80211_sub_if_data,
2989 csa_finalize_work);
2990 struct ieee80211_local *local = sdata->local;
2991 int err, changed = 0;
2992
2993 sdata_lock(sdata);
2994 /* AP might have been stopped while waiting for the lock. */
2995 if (!sdata->vif.csa_active)
2996 goto unlock;
2997
2966 if (!ieee80211_sdata_running(sdata))
2998 if (!ieee80211_sdata_running(sdata))
2967 return;
2999 goto unlock;
2968
2969 sdata->radar_required = sdata->csa_radar_required;
3000
3001 sdata->radar_required = sdata->csa_radar_required;
2970 err = ieee80211_vif_change_channel(sdata, &local->csa_chandef,
2971 &changed);
3002 err = ieee80211_vif_change_channel(sdata, &changed);
2972 if (WARN_ON(err < 0))
3003 if (WARN_ON(err < 0))
2973 return;
3004 goto unlock;
2974
2975 if (!local->use_chanctx) {
3005
3006 if (!local->use_chanctx) {
2976 local->_oper_chandef = local->csa_chandef;
3007 local->_oper_chandef = sdata->csa_chandef;
2977 ieee80211_hw_config(local, 0);
2978 }
2979
2980 ieee80211_bss_info_change_notify(sdata, changed);
2981
3008 ieee80211_hw_config(local, 0);
3009 }
3010
3011 ieee80211_bss_info_change_notify(sdata, changed);
3012
3013 sdata->vif.csa_active = false;
2982 switch (sdata->vif.type) {
2983 case NL80211_IFTYPE_AP:
2984 err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon);
2985 if (err < 0)
3014 switch (sdata->vif.type) {
3015 case NL80211_IFTYPE_AP:
3016 err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon);
3017 if (err < 0)
2986 return;
3018 goto unlock;
3019
2987 changed |= err;
2988 kfree(sdata->u.ap.next_beacon);
2989 sdata->u.ap.next_beacon = NULL;
2990
2991 ieee80211_bss_info_change_notify(sdata, err);
2992 break;
2993 case NL80211_IFTYPE_ADHOC:
2994 ieee80211_ibss_finish_csa(sdata);
2995 break;
2996#ifdef CONFIG_MAC80211_MESH
2997 case NL80211_IFTYPE_MESH_POINT:
2998 err = ieee80211_mesh_finish_csa(sdata);
2999 if (err < 0)
3020 changed |= err;
3021 kfree(sdata->u.ap.next_beacon);
3022 sdata->u.ap.next_beacon = NULL;
3023
3024 ieee80211_bss_info_change_notify(sdata, err);
3025 break;
3026 case NL80211_IFTYPE_ADHOC:
3027 ieee80211_ibss_finish_csa(sdata);
3028 break;
3029#ifdef CONFIG_MAC80211_MESH
3030 case NL80211_IFTYPE_MESH_POINT:
3031 err = ieee80211_mesh_finish_csa(sdata);
3032 if (err < 0)
3000 return;
3033 goto unlock;
3001 break;
3002#endif
3003 default:
3004 WARN_ON(1);
3034 break;
3035#endif
3036 default:
3037 WARN_ON(1);
3005 return;
3038 goto unlock;
3006 }
3039 }
3007 sdata->vif.csa_active = false;
3008
3009 ieee80211_wake_queues_by_reason(&sdata->local->hw,
3010 IEEE80211_MAX_QUEUE_MAP,
3011 IEEE80211_QUEUE_STOP_REASON_CSA);
3012
3040
3041 ieee80211_wake_queues_by_reason(&sdata->local->hw,
3042 IEEE80211_MAX_QUEUE_MAP,
3043 IEEE80211_QUEUE_STOP_REASON_CSA);
3044
3013 cfg80211_ch_switch_notify(sdata->dev, &local->csa_chandef);
3045 cfg80211_ch_switch_notify(sdata->dev, &sdata->csa_chandef);
3046
3047unlock:
3048 sdata_unlock(sdata);
3014}
3015
3016static int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3017 struct cfg80211_csa_settings *params)
3018{
3019 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3020 struct ieee80211_local *local = sdata->local;
3021 struct ieee80211_chanctx_conf *chanctx_conf;
3022 struct ieee80211_chanctx *chanctx;
3023 struct ieee80211_if_mesh __maybe_unused *ifmsh;
3024 int err, num_chanctx;
3025
3049}
3050
3051static int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3052 struct cfg80211_csa_settings *params)
3053{
3054 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
3055 struct ieee80211_local *local = sdata->local;
3056 struct ieee80211_chanctx_conf *chanctx_conf;
3057 struct ieee80211_chanctx *chanctx;
3058 struct ieee80211_if_mesh __maybe_unused *ifmsh;
3059 int err, num_chanctx;
3060
3061 lockdep_assert_held(&sdata->wdev.mtx);
3062
3026 if (!list_empty(&local->roc_list) || local->scanning)
3027 return -EBUSY;
3028
3029 if (sdata->wdev.cac_started)
3030 return -EBUSY;
3031
3032 if (cfg80211_chandef_identical(&params->chandef,
3033 &sdata->vif.bss_conf.chandef))

--- 80 unchanged lines hidden (view full) ---

3114 if (params->chandef.width != sdata->vif.bss_conf.chandef.width)
3115 return -EINVAL;
3116
3117 /* changes into another band are not supported */
3118 if (sdata->vif.bss_conf.chandef.chan->band !=
3119 params->chandef.chan->band)
3120 return -EINVAL;
3121
3063 if (!list_empty(&local->roc_list) || local->scanning)
3064 return -EBUSY;
3065
3066 if (sdata->wdev.cac_started)
3067 return -EBUSY;
3068
3069 if (cfg80211_chandef_identical(&params->chandef,
3070 &sdata->vif.bss_conf.chandef))

--- 80 unchanged lines hidden (view full) ---

3151 if (params->chandef.width != sdata->vif.bss_conf.chandef.width)
3152 return -EINVAL;
3153
3154 /* changes into another band are not supported */
3155 if (sdata->vif.bss_conf.chandef.chan->band !=
3156 params->chandef.chan->band)
3157 return -EINVAL;
3158
3122 ifmsh->chsw_init = true;
3123 if (!ifmsh->pre_value)
3124 ifmsh->pre_value = 1;
3125 else
3126 ifmsh->pre_value++;
3127
3128 err = ieee80211_mesh_csa_beacon(sdata, params, true);
3159 err = ieee80211_mesh_csa_beacon(sdata, params, true);
3129 if (err < 0) {
3130 ifmsh->chsw_init = false;
3160 if (err < 0)
3131 return err;
3161 return err;
3132 }
3133 break;
3134#endif
3135 default:
3136 return -EOPNOTSUPP;
3137 }
3138
3139 sdata->csa_radar_required = params->radar_required;
3140
3141 if (params->block_tx)
3142 ieee80211_stop_queues_by_reason(&local->hw,
3143 IEEE80211_MAX_QUEUE_MAP,
3144 IEEE80211_QUEUE_STOP_REASON_CSA);
3145
3162 break;
3163#endif
3164 default:
3165 return -EOPNOTSUPP;
3166 }
3167
3168 sdata->csa_radar_required = params->radar_required;
3169
3170 if (params->block_tx)
3171 ieee80211_stop_queues_by_reason(&local->hw,
3172 IEEE80211_MAX_QUEUE_MAP,
3173 IEEE80211_QUEUE_STOP_REASON_CSA);
3174
3146 local->csa_chandef = params->chandef;
3175 sdata->csa_chandef = params->chandef;
3147 sdata->vif.csa_active = true;
3148
3149 ieee80211_bss_info_change_notify(sdata, err);
3150 drv_channel_switch_beacon(sdata, &params->chandef);
3151
3152 return 0;
3153}
3154
3155static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
3176 sdata->vif.csa_active = true;
3177
3178 ieee80211_bss_info_change_notify(sdata, err);
3179 drv_channel_switch_beacon(sdata, &params->chandef);
3180
3181 return 0;
3182}
3183
3184static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
3156 struct ieee80211_channel *chan, bool offchan,
3157 unsigned int wait, const u8 *buf, size_t len,
3158 bool no_cck, bool dont_wait_for_ack, u64 *cookie)
3185 struct cfg80211_mgmt_tx_params *params,
3186 u64 *cookie)
3159{
3160 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3161 struct ieee80211_local *local = sdata->local;
3162 struct sk_buff *skb;
3163 struct sta_info *sta;
3187{
3188 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
3189 struct ieee80211_local *local = sdata->local;
3190 struct sk_buff *skb;
3191 struct sta_info *sta;
3164 const struct ieee80211_mgmt *mgmt = (void *)buf;
3192 const struct ieee80211_mgmt *mgmt = (void *)params->buf;
3165 bool need_offchan = false;
3166 u32 flags;
3167 int ret;
3168
3193 bool need_offchan = false;
3194 u32 flags;
3195 int ret;
3196
3169 if (dont_wait_for_ack)
3197 if (params->dont_wait_for_ack)
3170 flags = IEEE80211_TX_CTL_NO_ACK;
3171 else
3172 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX |
3173 IEEE80211_TX_CTL_REQ_TX_STATUS;
3174
3198 flags = IEEE80211_TX_CTL_NO_ACK;
3199 else
3200 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX |
3201 IEEE80211_TX_CTL_REQ_TX_STATUS;
3202
3175 if (no_cck)
3203 if (params->no_cck)
3176 flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
3177
3178 switch (sdata->vif.type) {
3179 case NL80211_IFTYPE_ADHOC:
3180 if (!sdata->vif.bss_conf.ibss_joined)
3181 need_offchan = true;
3182 /* fall through */
3183#ifdef CONFIG_MAC80211_MESH

--- 31 unchanged lines hidden (view full) ---

3215 break;
3216 default:
3217 return -EOPNOTSUPP;
3218 }
3219
3220 /* configurations requiring offchan cannot work if no channel has been
3221 * specified
3222 */
3204 flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
3205
3206 switch (sdata->vif.type) {
3207 case NL80211_IFTYPE_ADHOC:
3208 if (!sdata->vif.bss_conf.ibss_joined)
3209 need_offchan = true;
3210 /* fall through */
3211#ifdef CONFIG_MAC80211_MESH

--- 31 unchanged lines hidden (view full) ---

3243 break;
3244 default:
3245 return -EOPNOTSUPP;
3246 }
3247
3248 /* configurations requiring offchan cannot work if no channel has been
3249 * specified
3250 */
3223 if (need_offchan && !chan)
3251 if (need_offchan && !params->chan)
3224 return -EINVAL;
3225
3226 mutex_lock(&local->mtx);
3227
3228 /* Check if the operating channel is the requested channel */
3229 if (!need_offchan) {
3230 struct ieee80211_chanctx_conf *chanctx_conf;
3231
3232 rcu_read_lock();
3233 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3234
3235 if (chanctx_conf) {
3252 return -EINVAL;
3253
3254 mutex_lock(&local->mtx);
3255
3256 /* Check if the operating channel is the requested channel */
3257 if (!need_offchan) {
3258 struct ieee80211_chanctx_conf *chanctx_conf;
3259
3260 rcu_read_lock();
3261 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3262
3263 if (chanctx_conf) {
3236 need_offchan = chan && (chan != chanctx_conf->def.chan);
3237 } else if (!chan) {
3264 need_offchan = params->chan &&
3265 (params->chan !=
3266 chanctx_conf->def.chan);
3267 } else if (!params->chan) {
3238 ret = -EINVAL;
3239 rcu_read_unlock();
3240 goto out_unlock;
3241 } else {
3242 need_offchan = true;
3243 }
3244 rcu_read_unlock();
3245 }
3246
3268 ret = -EINVAL;
3269 rcu_read_unlock();
3270 goto out_unlock;
3271 } else {
3272 need_offchan = true;
3273 }
3274 rcu_read_unlock();
3275 }
3276
3247 if (need_offchan && !offchan) {
3277 if (need_offchan && !params->offchan) {
3248 ret = -EBUSY;
3249 goto out_unlock;
3250 }
3251
3278 ret = -EBUSY;
3279 goto out_unlock;
3280 }
3281
3252 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len);
3282 skb = dev_alloc_skb(local->hw.extra_tx_headroom + params->len);
3253 if (!skb) {
3254 ret = -ENOMEM;
3255 goto out_unlock;
3256 }
3257 skb_reserve(skb, local->hw.extra_tx_headroom);
3258
3283 if (!skb) {
3284 ret = -ENOMEM;
3285 goto out_unlock;
3286 }
3287 skb_reserve(skb, local->hw.extra_tx_headroom);
3288
3259 memcpy(skb_put(skb, len), buf, len);
3289 memcpy(skb_put(skb, params->len), params->buf, params->len);
3260
3261 IEEE80211_SKB_CB(skb)->flags = flags;
3262
3263 skb->dev = sdata->dev;
3264
3265 if (!need_offchan) {
3266 *cookie = (unsigned long) skb;
3267 ieee80211_tx_skb(sdata, skb);
3268 ret = 0;
3269 goto out_unlock;
3270 }
3271
3272 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN |
3273 IEEE80211_TX_INTFL_OFFCHAN_TX_OK;
3274 if (local->hw.flags & IEEE80211_HW_QUEUE_CONTROL)
3275 IEEE80211_SKB_CB(skb)->hw_queue =
3276 local->hw.offchannel_tx_hw_queue;
3277
3278 /* This will handle all kinds of coalescing and immediate TX */
3290
3291 IEEE80211_SKB_CB(skb)->flags = flags;
3292
3293 skb->dev = sdata->dev;
3294
3295 if (!need_offchan) {
3296 *cookie = (unsigned long) skb;
3297 ieee80211_tx_skb(sdata, skb);
3298 ret = 0;
3299 goto out_unlock;
3300 }
3301
3302 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN |
3303 IEEE80211_TX_INTFL_OFFCHAN_TX_OK;
3304 if (local->hw.flags & IEEE80211_HW_QUEUE_CONTROL)
3305 IEEE80211_SKB_CB(skb)->hw_queue =
3306 local->hw.offchannel_tx_hw_queue;
3307
3308 /* This will handle all kinds of coalescing and immediate TX */
3279 ret = ieee80211_start_roc_work(local, sdata, chan,
3280 wait, cookie, skb,
3309 ret = ieee80211_start_roc_work(local, sdata, params->chan,
3310 params->wait, cookie, skb,
3281 IEEE80211_ROC_TYPE_MGMT_TX);
3282 if (ret)
3283 kfree_skb(skb);
3284 out_unlock:
3285 mutex_unlock(&local->mtx);
3286 return ret;
3287}
3288

--- 586 unchanged lines hidden ---
3311 IEEE80211_ROC_TYPE_MGMT_TX);
3312 if (ret)
3313 kfree_skb(skb);
3314 out_unlock:
3315 mutex_unlock(&local->mtx);
3316 return ret;
3317}
3318

--- 586 unchanged lines hidden ---