Lines Matching +full:switch +full:- +full:freq
1 // SPDX-License-Identifier: GPL-2.0
3 * cfg80211 - wext compat code
9 * Copyright 2008-2009 Johannes Berg <johannes@sipsolutions.net>
21 #include <net/cfg80211-wext.h>
22 #include "wext-compat.h"
24 #include "rdev-ops.h"
38 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwmode()
43 rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwmode()
45 switch (*mode) { in cfg80211_wext_siwmode()
59 return -EINVAL; in cfg80211_wext_siwmode()
62 if (type == wdev->iftype) in cfg80211_wext_siwmode()
74 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwmode()
77 return -EOPNOTSUPP; in cfg80211_wext_giwmode()
79 switch (wdev->iftype) { in cfg80211_wext_giwmode()
111 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwrange()
117 return -EOPNOTSUPP; in cfg80211_wext_giwrange()
119 data->length = sizeof(struct iw_range); in cfg80211_wext_giwrange()
122 range->we_version_compiled = WIRELESS_EXT; in cfg80211_wext_giwrange()
123 range->we_version_source = 21; in cfg80211_wext_giwrange()
124 range->retry_capa = IW_RETRY_LIMIT; in cfg80211_wext_giwrange()
125 range->retry_flags = IW_RETRY_LIMIT; in cfg80211_wext_giwrange()
126 range->min_retry = 0; in cfg80211_wext_giwrange()
127 range->max_retry = 255; in cfg80211_wext_giwrange()
128 range->min_rts = 0; in cfg80211_wext_giwrange()
129 range->max_rts = 2347; in cfg80211_wext_giwrange()
130 range->min_frag = 256; in cfg80211_wext_giwrange()
131 range->max_frag = 2346; in cfg80211_wext_giwrange()
133 range->max_encoding_tokens = 4; in cfg80211_wext_giwrange()
135 range->max_qual.updated = IW_QUAL_NOISE_INVALID; in cfg80211_wext_giwrange()
137 switch (wdev->wiphy->signal_type) { in cfg80211_wext_giwrange()
141 range->max_qual.level = (u8)-110; in cfg80211_wext_giwrange()
142 range->max_qual.qual = 70; in cfg80211_wext_giwrange()
143 range->avg_qual.qual = 35; in cfg80211_wext_giwrange()
144 range->max_qual.updated |= IW_QUAL_DBM; in cfg80211_wext_giwrange()
145 range->max_qual.updated |= IW_QUAL_QUAL_UPDATED; in cfg80211_wext_giwrange()
146 range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED; in cfg80211_wext_giwrange()
149 range->max_qual.level = 100; in cfg80211_wext_giwrange()
150 range->max_qual.qual = 100; in cfg80211_wext_giwrange()
151 range->avg_qual.qual = 50; in cfg80211_wext_giwrange()
152 range->max_qual.updated |= IW_QUAL_QUAL_UPDATED; in cfg80211_wext_giwrange()
153 range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED; in cfg80211_wext_giwrange()
157 range->avg_qual.level = range->max_qual.level / 2; in cfg80211_wext_giwrange()
158 range->avg_qual.noise = range->max_qual.noise / 2; in cfg80211_wext_giwrange()
159 range->avg_qual.updated = range->max_qual.updated; in cfg80211_wext_giwrange()
161 for (i = 0; i < wdev->wiphy->n_cipher_suites; i++) { in cfg80211_wext_giwrange()
162 switch (wdev->wiphy->cipher_suites[i]) { in cfg80211_wext_giwrange()
164 range->enc_capa |= (IW_ENC_CAPA_CIPHER_TKIP | in cfg80211_wext_giwrange()
169 range->enc_capa |= (IW_ENC_CAPA_CIPHER_CCMP | in cfg80211_wext_giwrange()
174 range->encoding_size[range->num_encoding_sizes++] = in cfg80211_wext_giwrange()
179 range->encoding_size[range->num_encoding_sizes++] = in cfg80211_wext_giwrange()
188 sband = wdev->wiphy->bands[band]; in cfg80211_wext_giwrange()
193 for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) { in cfg80211_wext_giwrange()
194 struct ieee80211_channel *chan = &sband->channels[i]; in cfg80211_wext_giwrange()
196 if (!(chan->flags & IEEE80211_CHAN_DISABLED)) { in cfg80211_wext_giwrange()
197 range->freq[c].i = in cfg80211_wext_giwrange()
199 chan->center_freq); in cfg80211_wext_giwrange()
200 range->freq[c].m = chan->center_freq; in cfg80211_wext_giwrange()
201 range->freq[c].e = 6; in cfg80211_wext_giwrange()
206 range->num_channels = c; in cfg80211_wext_giwrange()
207 range->num_frequency = c; in cfg80211_wext_giwrange()
209 IW_EVENT_CAPA_SET_KERNEL(range->event_capa); in cfg80211_wext_giwrange()
210 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP); in cfg80211_wext_giwrange()
211 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN); in cfg80211_wext_giwrange()
213 if (wdev->wiphy->max_scan_ssids > 0) in cfg80211_wext_giwrange()
214 range->scan_capa |= IW_SCAN_CAPA_ESSID; in cfg80211_wext_giwrange()
222 * cfg80211_wext_freq - get wext frequency for non-"auto"
223 * @freq: the wext freq encoding
227 int cfg80211_wext_freq(struct iw_freq *freq) in cfg80211_wext_freq() argument
230 * Parse frequency - return 0 for auto and in cfg80211_wext_freq()
231 * -EINVAL for impossible things. in cfg80211_wext_freq()
233 if (freq->e == 0) { in cfg80211_wext_freq()
235 if (freq->m < 0) in cfg80211_wext_freq()
237 if (freq->m > 14) in cfg80211_wext_freq()
239 return ieee80211_channel_to_frequency(freq->m, band); in cfg80211_wext_freq()
242 for (i = 0; i < freq->e; i++) in cfg80211_wext_freq()
245 return -EINVAL; in cfg80211_wext_freq()
246 return freq->m / div; in cfg80211_wext_freq()
254 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwrts()
255 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwrts()
256 u32 orts = wdev->wiphy->rts_threshold; in cfg80211_wext_siwrts()
259 if (rts->disabled || !rts->fixed) in cfg80211_wext_siwrts()
260 wdev->wiphy->rts_threshold = (u32) -1; in cfg80211_wext_siwrts()
261 else if (rts->value < 0) in cfg80211_wext_siwrts()
262 return -EINVAL; in cfg80211_wext_siwrts()
264 wdev->wiphy->rts_threshold = rts->value; in cfg80211_wext_siwrts()
268 wdev->wiphy->rts_threshold = orts; in cfg80211_wext_siwrts()
278 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwrts()
280 rts->value = wdev->wiphy->rts_threshold; in cfg80211_wext_giwrts()
281 rts->disabled = rts->value == (u32) -1; in cfg80211_wext_giwrts()
282 rts->fixed = 1; in cfg80211_wext_giwrts()
292 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwfrag()
293 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwfrag()
294 u32 ofrag = wdev->wiphy->frag_threshold; in cfg80211_wext_siwfrag()
297 if (frag->disabled || !frag->fixed) in cfg80211_wext_siwfrag()
298 wdev->wiphy->frag_threshold = (u32) -1; in cfg80211_wext_siwfrag()
299 else if (frag->value < 256) in cfg80211_wext_siwfrag()
300 return -EINVAL; in cfg80211_wext_siwfrag()
303 wdev->wiphy->frag_threshold = frag->value & ~0x1; in cfg80211_wext_siwfrag()
308 wdev->wiphy->frag_threshold = ofrag; in cfg80211_wext_siwfrag()
318 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwfrag()
320 frag->value = wdev->wiphy->frag_threshold; in cfg80211_wext_giwfrag()
321 frag->disabled = frag->value == (u32) -1; in cfg80211_wext_giwfrag()
322 frag->fixed = 1; in cfg80211_wext_giwfrag()
332 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwretry()
333 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwretry()
335 u8 olong = wdev->wiphy->retry_long; in cfg80211_wext_siwretry()
336 u8 oshort = wdev->wiphy->retry_short; in cfg80211_wext_siwretry()
339 if (retry->disabled || retry->value < 1 || retry->value > 255 || in cfg80211_wext_siwretry()
340 (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT) in cfg80211_wext_siwretry()
341 return -EINVAL; in cfg80211_wext_siwretry()
343 if (retry->flags & IW_RETRY_LONG) { in cfg80211_wext_siwretry()
344 wdev->wiphy->retry_long = retry->value; in cfg80211_wext_siwretry()
346 } else if (retry->flags & IW_RETRY_SHORT) { in cfg80211_wext_siwretry()
347 wdev->wiphy->retry_short = retry->value; in cfg80211_wext_siwretry()
350 wdev->wiphy->retry_short = retry->value; in cfg80211_wext_siwretry()
351 wdev->wiphy->retry_long = retry->value; in cfg80211_wext_siwretry()
358 wdev->wiphy->retry_short = oshort; in cfg80211_wext_siwretry()
359 wdev->wiphy->retry_long = olong; in cfg80211_wext_siwretry()
369 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwretry()
371 retry->disabled = 0; in cfg80211_wext_giwretry()
373 if (retry->flags == 0 || (retry->flags & IW_RETRY_SHORT)) { in cfg80211_wext_giwretry()
378 retry->flags |= IW_RETRY_LIMIT | IW_RETRY_SHORT; in cfg80211_wext_giwretry()
379 retry->value = wdev->wiphy->retry_short; in cfg80211_wext_giwretry()
380 if (wdev->wiphy->retry_long == wdev->wiphy->retry_short) in cfg80211_wext_giwretry()
381 retry->flags |= IW_RETRY_LONG; in cfg80211_wext_giwretry()
386 if (retry->flags & IW_RETRY_LONG) { in cfg80211_wext_giwretry()
387 retry->flags = IW_RETRY_LIMIT | IW_RETRY_LONG; in cfg80211_wext_giwretry()
388 retry->value = wdev->wiphy->retry_long; in cfg80211_wext_giwretry()
400 struct wireless_dev *wdev = dev->ieee80211_ptr; in __cfg80211_set_encryption()
405 return -EINVAL; in __cfg80211_set_encryption()
411 if (!wdev->wext.keys) { in __cfg80211_set_encryption()
412 wdev->wext.keys = kzalloc(sizeof(*wdev->wext.keys), in __cfg80211_set_encryption()
414 if (!wdev->wext.keys) in __cfg80211_set_encryption()
415 return -ENOMEM; in __cfg80211_set_encryption()
417 wdev->wext.keys->params[i].key = in __cfg80211_set_encryption()
418 wdev->wext.keys->data[i]; in __cfg80211_set_encryption()
421 if (wdev->iftype != NL80211_IFTYPE_ADHOC && in __cfg80211_set_encryption()
422 wdev->iftype != NL80211_IFTYPE_STATION) in __cfg80211_set_encryption()
423 return -EOPNOTSUPP; in __cfg80211_set_encryption()
425 if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC) { in __cfg80211_set_encryption()
426 if (!wdev->current_bss) in __cfg80211_set_encryption()
427 return -ENOLINK; in __cfg80211_set_encryption()
429 if (!rdev->ops->set_default_mgmt_key) in __cfg80211_set_encryption()
430 return -EOPNOTSUPP; in __cfg80211_set_encryption()
433 return -EINVAL; in __cfg80211_set_encryption()
435 return -EINVAL; in __cfg80211_set_encryption()
439 if (wdev->current_bss) { in __cfg80211_set_encryption()
444 if (idx == wdev->wext.default_key && in __cfg80211_set_encryption()
445 wdev->iftype == NL80211_IFTYPE_ADHOC) { in __cfg80211_set_encryption()
446 __cfg80211_leave_ibss(rdev, wdev->netdev, true); in __cfg80211_set_encryption()
451 !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) in __cfg80211_set_encryption()
452 err = -ENOENT; in __cfg80211_set_encryption()
457 wdev->wext.connect.privacy = false; in __cfg80211_set_encryption()
462 if (err == -ENOENT) in __cfg80211_set_encryption()
466 memset(wdev->wext.keys->data[idx], 0, in __cfg80211_set_encryption()
467 sizeof(wdev->wext.keys->data[idx])); in __cfg80211_set_encryption()
468 wdev->wext.keys->params[idx].key_len = 0; in __cfg80211_set_encryption()
469 wdev->wext.keys->params[idx].cipher = 0; in __cfg80211_set_encryption()
471 if (idx == wdev->wext.default_key) in __cfg80211_set_encryption()
472 wdev->wext.default_key = -1; in __cfg80211_set_encryption()
473 else if (idx == wdev->wext.default_mgmt_key) in __cfg80211_set_encryption()
474 wdev->wext.default_mgmt_key = -1; in __cfg80211_set_encryption()
487 return -EINVAL; in __cfg80211_set_encryption()
490 if (wdev->current_bss) in __cfg80211_set_encryption()
492 else if (params->cipher != WLAN_CIPHER_SUITE_WEP40 && in __cfg80211_set_encryption()
493 params->cipher != WLAN_CIPHER_SUITE_WEP104) in __cfg80211_set_encryption()
494 return -EINVAL; in __cfg80211_set_encryption()
503 if (!addr && (params->cipher == WLAN_CIPHER_SUITE_WEP40 || in __cfg80211_set_encryption()
504 params->cipher == WLAN_CIPHER_SUITE_WEP104)) { in __cfg80211_set_encryption()
505 wdev->wext.keys->params[idx] = *params; in __cfg80211_set_encryption()
506 memcpy(wdev->wext.keys->data[idx], in __cfg80211_set_encryption()
507 params->key, params->key_len); in __cfg80211_set_encryption()
508 wdev->wext.keys->params[idx].key = in __cfg80211_set_encryption()
509 wdev->wext.keys->data[idx]; in __cfg80211_set_encryption()
512 if ((params->cipher == WLAN_CIPHER_SUITE_WEP40 || in __cfg80211_set_encryption()
513 params->cipher == WLAN_CIPHER_SUITE_WEP104) && in __cfg80211_set_encryption()
514 (tx_key || (!addr && wdev->wext.default_key == -1))) { in __cfg80211_set_encryption()
515 if (wdev->current_bss) { in __cfg80211_set_encryption()
521 if (wdev->iftype == NL80211_IFTYPE_ADHOC && in __cfg80211_set_encryption()
522 wdev->wext.default_key == -1) { in __cfg80211_set_encryption()
523 __cfg80211_leave_ibss(rdev, wdev->netdev, true); in __cfg80211_set_encryption()
529 wdev->wext.default_key = idx; in __cfg80211_set_encryption()
536 if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC && in __cfg80211_set_encryption()
537 (tx_key || (!addr && wdev->wext.default_mgmt_key == -1))) { in __cfg80211_set_encryption()
538 if (wdev->current_bss) in __cfg80211_set_encryption()
541 wdev->wext.default_mgmt_key = idx; in __cfg80211_set_encryption()
555 wdev_lock(dev->ieee80211_ptr); in cfg80211_set_encryption()
558 wdev_unlock(dev->ieee80211_ptr); in cfg80211_set_encryption()
567 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwencode()
568 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwencode()
573 if (wdev->iftype != NL80211_IFTYPE_STATION && in cfg80211_wext_siwencode()
574 wdev->iftype != NL80211_IFTYPE_ADHOC) in cfg80211_wext_siwencode()
575 return -EOPNOTSUPP; in cfg80211_wext_siwencode()
577 /* no use -- only MFP (set_default_mgmt_key) is optional */ in cfg80211_wext_siwencode()
578 if (!rdev->ops->del_key || in cfg80211_wext_siwencode()
579 !rdev->ops->add_key || in cfg80211_wext_siwencode()
580 !rdev->ops->set_default_key) in cfg80211_wext_siwencode()
581 return -EOPNOTSUPP; in cfg80211_wext_siwencode()
583 idx = erq->flags & IW_ENCODE_INDEX; in cfg80211_wext_siwencode()
585 idx = wdev->wext.default_key; in cfg80211_wext_siwencode()
589 return -EINVAL; in cfg80211_wext_siwencode()
591 idx--; in cfg80211_wext_siwencode()
593 if (erq->flags & IW_ENCODE_DISABLED) in cfg80211_wext_siwencode()
595 else if (erq->length == 0) { in cfg80211_wext_siwencode()
596 /* No key data - just set the default TX key index */ in cfg80211_wext_siwencode()
599 if (wdev->current_bss) in cfg80211_wext_siwencode()
603 wdev->wext.default_key = idx; in cfg80211_wext_siwencode()
610 params.key_len = erq->length; in cfg80211_wext_siwencode()
611 if (erq->length == 5) in cfg80211_wext_siwencode()
613 else if (erq->length == 13) in cfg80211_wext_siwencode()
616 return -EINVAL; in cfg80211_wext_siwencode()
619 wdev->wext.default_key == -1, in cfg80211_wext_siwencode()
627 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwencodeext()
628 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwencodeext()
636 if (wdev->iftype != NL80211_IFTYPE_STATION && in cfg80211_wext_siwencodeext()
637 wdev->iftype != NL80211_IFTYPE_ADHOC) in cfg80211_wext_siwencodeext()
638 return -EOPNOTSUPP; in cfg80211_wext_siwencodeext()
640 /* no use -- only MFP (set_default_mgmt_key) is optional */ in cfg80211_wext_siwencodeext()
641 if (!rdev->ops->del_key || in cfg80211_wext_siwencodeext()
642 !rdev->ops->add_key || in cfg80211_wext_siwencodeext()
643 !rdev->ops->set_default_key) in cfg80211_wext_siwencodeext()
644 return -EOPNOTSUPP; in cfg80211_wext_siwencodeext()
646 switch (ext->alg) { in cfg80211_wext_siwencodeext()
652 if (ext->key_len == 5) in cfg80211_wext_siwencodeext()
654 else if (ext->key_len == 13) in cfg80211_wext_siwencodeext()
657 return -EINVAL; in cfg80211_wext_siwencodeext()
669 return -EOPNOTSUPP; in cfg80211_wext_siwencodeext()
672 if (erq->flags & IW_ENCODE_DISABLED) in cfg80211_wext_siwencodeext()
675 idx = erq->flags & IW_ENCODE_INDEX; in cfg80211_wext_siwencodeext()
678 idx = wdev->wext.default_mgmt_key; in cfg80211_wext_siwencodeext()
680 return -EINVAL; in cfg80211_wext_siwencodeext()
682 idx--; in cfg80211_wext_siwencodeext()
685 idx = wdev->wext.default_key; in cfg80211_wext_siwencodeext()
687 return -EINVAL; in cfg80211_wext_siwencodeext()
689 idx--; in cfg80211_wext_siwencodeext()
692 addr = ext->addr.sa_data; in cfg80211_wext_siwencodeext()
697 params.key = ext->key; in cfg80211_wext_siwencodeext()
698 params.key_len = ext->key_len; in cfg80211_wext_siwencodeext()
701 if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) { in cfg80211_wext_siwencodeext()
702 params.seq = ext->rx_seq; in cfg80211_wext_siwencodeext()
708 !(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY), in cfg80211_wext_siwencodeext()
710 ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY, in cfg80211_wext_siwencodeext()
718 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwencode()
721 if (wdev->iftype != NL80211_IFTYPE_STATION && in cfg80211_wext_giwencode()
722 wdev->iftype != NL80211_IFTYPE_ADHOC) in cfg80211_wext_giwencode()
723 return -EOPNOTSUPP; in cfg80211_wext_giwencode()
725 idx = erq->flags & IW_ENCODE_INDEX; in cfg80211_wext_giwencode()
727 idx = wdev->wext.default_key; in cfg80211_wext_giwencode()
731 return -EINVAL; in cfg80211_wext_giwencode()
733 idx--; in cfg80211_wext_giwencode()
735 erq->flags = idx + 1; in cfg80211_wext_giwencode()
737 if (!wdev->wext.keys || !wdev->wext.keys->params[idx].cipher) { in cfg80211_wext_giwencode()
738 erq->flags |= IW_ENCODE_DISABLED; in cfg80211_wext_giwencode()
739 erq->length = 0; in cfg80211_wext_giwencode()
743 erq->length = min_t(size_t, erq->length, in cfg80211_wext_giwencode()
744 wdev->wext.keys->params[idx].key_len); in cfg80211_wext_giwencode()
745 memcpy(keybuf, wdev->wext.keys->params[idx].key, erq->length); in cfg80211_wext_giwencode()
746 erq->flags |= IW_ENCODE_ENABLED; in cfg80211_wext_giwencode()
755 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwfreq()
756 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwfreq()
760 int freq; in cfg80211_wext_siwfreq() local
762 switch (wdev->iftype) { in cfg80211_wext_siwfreq()
768 freq = cfg80211_wext_freq(wextfreq); in cfg80211_wext_siwfreq()
769 if (freq < 0) in cfg80211_wext_siwfreq()
770 return freq; in cfg80211_wext_siwfreq()
771 if (freq == 0) in cfg80211_wext_siwfreq()
772 return -EINVAL; in cfg80211_wext_siwfreq()
773 chandef.center_freq1 = freq; in cfg80211_wext_siwfreq()
774 chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq); in cfg80211_wext_siwfreq()
776 return -EINVAL; in cfg80211_wext_siwfreq()
779 freq = cfg80211_wext_freq(wextfreq); in cfg80211_wext_siwfreq()
780 if (freq < 0) in cfg80211_wext_siwfreq()
781 return freq; in cfg80211_wext_siwfreq()
782 if (freq == 0) in cfg80211_wext_siwfreq()
783 return -EINVAL; in cfg80211_wext_siwfreq()
784 chandef.center_freq1 = freq; in cfg80211_wext_siwfreq()
785 chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq); in cfg80211_wext_siwfreq()
787 return -EINVAL; in cfg80211_wext_siwfreq()
790 return -EOPNOTSUPP; in cfg80211_wext_siwfreq()
796 struct iw_freq *freq, char *extra) in cfg80211_wext_giwfreq() argument
798 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwfreq()
799 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwfreq()
803 switch (wdev->iftype) { in cfg80211_wext_giwfreq()
805 return cfg80211_mgd_wext_giwfreq(dev, info, freq, extra); in cfg80211_wext_giwfreq()
807 return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra); in cfg80211_wext_giwfreq()
809 if (!rdev->ops->get_channel) in cfg80211_wext_giwfreq()
810 return -EINVAL; in cfg80211_wext_giwfreq()
815 freq->m = chandef.chan->center_freq; in cfg80211_wext_giwfreq()
816 freq->e = 6; in cfg80211_wext_giwfreq()
819 return -EINVAL; in cfg80211_wext_giwfreq()
827 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwtxpower()
828 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwtxpower()
832 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) in cfg80211_wext_siwtxpower()
833 return -EINVAL; in cfg80211_wext_siwtxpower()
834 if (data->txpower.flags & IW_TXPOW_RANGE) in cfg80211_wext_siwtxpower()
835 return -EINVAL; in cfg80211_wext_siwtxpower()
837 if (!rdev->ops->set_tx_power) in cfg80211_wext_siwtxpower()
838 return -EOPNOTSUPP; in cfg80211_wext_siwtxpower()
841 if (!data->txpower.disabled) { in cfg80211_wext_siwtxpower()
842 rfkill_set_sw_state(rdev->rfkill, false); in cfg80211_wext_siwtxpower()
844 if (data->txpower.fixed) { in cfg80211_wext_siwtxpower()
849 if (data->txpower.value < 0) in cfg80211_wext_siwtxpower()
850 return -EINVAL; in cfg80211_wext_siwtxpower()
851 dbm = data->txpower.value; in cfg80211_wext_siwtxpower()
859 if (data->txpower.value < 0) { in cfg80211_wext_siwtxpower()
862 dbm = data->txpower.value; in cfg80211_wext_siwtxpower()
867 if (rfkill_set_sw_state(rdev->rfkill, true)) in cfg80211_wext_siwtxpower()
868 schedule_work(&rdev->rfkill_block); in cfg80211_wext_siwtxpower()
879 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwtxpower()
880 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwtxpower()
883 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) in cfg80211_wext_giwtxpower()
884 return -EINVAL; in cfg80211_wext_giwtxpower()
885 if (data->txpower.flags & IW_TXPOW_RANGE) in cfg80211_wext_giwtxpower()
886 return -EINVAL; in cfg80211_wext_giwtxpower()
888 if (!rdev->ops->get_tx_power) in cfg80211_wext_giwtxpower()
889 return -EOPNOTSUPP; in cfg80211_wext_giwtxpower()
896 data->txpower.fixed = 1; in cfg80211_wext_giwtxpower()
897 data->txpower.disabled = rfkill_blocked(rdev->rfkill); in cfg80211_wext_giwtxpower()
898 data->txpower.value = val; in cfg80211_wext_giwtxpower()
899 data->txpower.flags = IW_TXPOW_DBM; in cfg80211_wext_giwtxpower()
910 return -EINVAL; in cfg80211_set_auth_alg()
915 return -EINVAL; in cfg80211_set_auth_alg()
919 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM; in cfg80211_set_auth_alg()
924 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_SHARED_KEY; in cfg80211_set_auth_alg()
929 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_NETWORK_EAP; in cfg80211_set_auth_alg()
933 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; in cfg80211_set_auth_alg()
943 return -EINVAL; in cfg80211_set_wpa_version()
948 return -EINVAL; in cfg80211_set_wpa_version()
951 wdev->wext.connect.crypto.wpa_versions &= in cfg80211_set_wpa_version()
955 wdev->wext.connect.crypto.wpa_versions |= in cfg80211_set_wpa_version()
959 wdev->wext.connect.crypto.wpa_versions |= in cfg80211_set_wpa_version()
968 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
971 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
974 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
977 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
980 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
983 wdev->wext.connect.crypto.cipher_group = 0; in cfg80211_set_cipher_group()
985 return -EINVAL; in cfg80211_set_cipher_group()
993 u32 *ciphers_pairwise = wdev->wext.connect.crypto.ciphers_pairwise; in cfg80211_set_cipher_pairwise()
1022 wdev->wext.connect.crypto.n_ciphers_pairwise = nr_ciphers; in cfg80211_set_cipher_pairwise()
1034 return -EINVAL; in cfg80211_set_key_mgt()
1037 wdev->wext.connect.crypto.akm_suites[nr_akm_suites] = in cfg80211_set_key_mgt()
1043 wdev->wext.connect.crypto.akm_suites[nr_akm_suites] = in cfg80211_set_key_mgt()
1048 wdev->wext.connect.crypto.n_akm_suites = nr_akm_suites; in cfg80211_set_key_mgt()
1057 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwauth()
1059 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_siwauth()
1060 return -EOPNOTSUPP; in cfg80211_wext_siwauth()
1062 switch (data->flags & IW_AUTH_INDEX) { in cfg80211_wext_siwauth()
1064 wdev->wext.connect.privacy = data->value; in cfg80211_wext_siwauth()
1067 return cfg80211_set_wpa_version(wdev, data->value); in cfg80211_wext_siwauth()
1069 return cfg80211_set_cipher_group(wdev, data->value); in cfg80211_wext_siwauth()
1071 return cfg80211_set_key_mgt(wdev, data->value); in cfg80211_wext_siwauth()
1073 return cfg80211_set_cipher_pairwise(wdev, data->value); in cfg80211_wext_siwauth()
1075 return cfg80211_set_auth_alg(wdev, data->value); in cfg80211_wext_siwauth()
1082 return -EOPNOTSUPP; in cfg80211_wext_siwauth()
1092 return -EOPNOTSUPP; in cfg80211_wext_giwauth()
1099 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwpower()
1100 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwpower()
1101 bool ps = wdev->ps; in cfg80211_wext_siwpower()
1102 int timeout = wdev->ps_timeout; in cfg80211_wext_siwpower()
1105 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_siwpower()
1106 return -EINVAL; in cfg80211_wext_siwpower()
1108 if (!rdev->ops->set_power_mgmt) in cfg80211_wext_siwpower()
1109 return -EOPNOTSUPP; in cfg80211_wext_siwpower()
1111 if (wrq->disabled) { in cfg80211_wext_siwpower()
1114 switch (wrq->flags & IW_POWER_MODE) { in cfg80211_wext_siwpower()
1121 return -EINVAL; in cfg80211_wext_siwpower()
1124 if (wrq->flags & ~(IW_POWER_MODE | IW_POWER_TIMEOUT)) in cfg80211_wext_siwpower()
1125 return -EINVAL; in cfg80211_wext_siwpower()
1127 if (wrq->flags & IW_POWER_TIMEOUT) in cfg80211_wext_siwpower()
1128 timeout = wrq->value / 1000; in cfg80211_wext_siwpower()
1135 wdev->ps = ps; in cfg80211_wext_siwpower()
1136 wdev->ps_timeout = timeout; in cfg80211_wext_siwpower()
1146 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwpower()
1148 wrq->disabled = !wdev->ps; in cfg80211_wext_giwpower()
1157 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wds_wext_siwap()
1158 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wds_wext_siwap()
1161 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_WDS)) in cfg80211_wds_wext_siwap()
1162 return -EINVAL; in cfg80211_wds_wext_siwap()
1164 if (addr->sa_family != ARPHRD_ETHER) in cfg80211_wds_wext_siwap()
1165 return -EINVAL; in cfg80211_wds_wext_siwap()
1168 return -EBUSY; in cfg80211_wds_wext_siwap()
1170 if (!rdev->ops->set_wds_peer) in cfg80211_wds_wext_siwap()
1171 return -EOPNOTSUPP; in cfg80211_wds_wext_siwap()
1173 err = rdev_set_wds_peer(rdev, dev, (u8 *)&addr->sa_data); in cfg80211_wds_wext_siwap()
1177 memcpy(&wdev->wext.bssid, (u8 *) &addr->sa_data, ETH_ALEN); in cfg80211_wds_wext_siwap()
1186 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wds_wext_giwap()
1188 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_WDS)) in cfg80211_wds_wext_giwap()
1189 return -EINVAL; in cfg80211_wds_wext_giwap()
1191 addr->sa_family = ARPHRD_ETHER; in cfg80211_wds_wext_giwap()
1192 memcpy(&addr->sa_data, wdev->wext.bssid, ETH_ALEN); in cfg80211_wds_wext_giwap()
1201 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwrate()
1202 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwrate()
1209 if (!rdev->ops->set_bitrate_mask) in cfg80211_wext_siwrate()
1210 return -EOPNOTSUPP; in cfg80211_wext_siwrate()
1214 maxrate = (u32)-1; in cfg80211_wext_siwrate()
1216 if (rate->value < 0) { in cfg80211_wext_siwrate()
1218 } else if (rate->fixed) { in cfg80211_wext_siwrate()
1219 fixed = rate->value / 100000; in cfg80211_wext_siwrate()
1221 maxrate = rate->value / 100000; in cfg80211_wext_siwrate()
1225 sband = wdev->wiphy->bands[band]; in cfg80211_wext_siwrate()
1228 for (ridx = 0; ridx < sband->n_bitrates; ridx++) { in cfg80211_wext_siwrate()
1229 struct ieee80211_rate *srate = &sband->bitrates[ridx]; in cfg80211_wext_siwrate()
1230 if (fixed == srate->bitrate) { in cfg80211_wext_siwrate()
1235 if (srate->bitrate <= maxrate) { in cfg80211_wext_siwrate()
1243 return -EINVAL; in cfg80211_wext_siwrate()
1252 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwrate()
1253 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwrate()
1258 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_giwrate()
1259 return -EOPNOTSUPP; in cfg80211_wext_giwrate()
1261 if (!rdev->ops->get_station) in cfg80211_wext_giwrate()
1262 return -EOPNOTSUPP; in cfg80211_wext_giwrate()
1266 if (wdev->current_bss) in cfg80211_wext_giwrate()
1267 memcpy(addr, wdev->current_bss->pub.bssid, ETH_ALEN); in cfg80211_wext_giwrate()
1269 err = -EOPNOTSUPP; in cfg80211_wext_giwrate()
1279 err = -EOPNOTSUPP; in cfg80211_wext_giwrate()
1283 rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate); in cfg80211_wext_giwrate()
1293 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wireless_stats()
1294 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wireless_stats()
1295 /* we are under RTNL - globally locked - so can use static structs */ in cfg80211_wireless_stats()
1300 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION) in cfg80211_wireless_stats()
1303 if (!rdev->ops->get_station) in cfg80211_wireless_stats()
1308 if (!wdev->current_bss) { in cfg80211_wireless_stats()
1312 memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN); in cfg80211_wireless_stats()
1322 switch (rdev->wiphy.signal_type) { in cfg80211_wireless_stats()
1330 if (sig < -110) in cfg80211_wireless_stats()
1331 sig = -110; in cfg80211_wireless_stats()
1332 else if (sig > -40) in cfg80211_wireless_stats()
1333 sig = -40; in cfg80211_wireless_stats()
1367 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwap()
1369 switch (wdev->iftype) { in cfg80211_wext_siwap()
1377 return -EOPNOTSUPP; in cfg80211_wext_siwap()
1385 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwap()
1387 switch (wdev->iftype) { in cfg80211_wext_giwap()
1395 return -EOPNOTSUPP; in cfg80211_wext_giwap()
1403 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwessid()
1405 switch (wdev->iftype) { in cfg80211_wext_siwessid()
1411 return -EOPNOTSUPP; in cfg80211_wext_siwessid()
1419 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwessid()
1421 data->flags = 0; in cfg80211_wext_giwessid()
1422 data->length = 0; in cfg80211_wext_giwessid()
1424 switch (wdev->iftype) { in cfg80211_wext_giwessid()
1430 return -EOPNOTSUPP; in cfg80211_wext_giwessid()
1438 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwpmksa()
1439 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwpmksa()
1445 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_siwpmksa()
1446 return -EINVAL; in cfg80211_wext_siwpmksa()
1448 cfg_pmksa.bssid = pmksa->bssid.sa_data; in cfg80211_wext_siwpmksa()
1449 cfg_pmksa.pmkid = pmksa->pmkid; in cfg80211_wext_siwpmksa()
1451 switch (pmksa->cmd) { in cfg80211_wext_siwpmksa()
1453 if (!rdev->ops->set_pmksa) in cfg80211_wext_siwpmksa()
1454 return -EOPNOTSUPP; in cfg80211_wext_siwpmksa()
1459 if (!rdev->ops->del_pmksa) in cfg80211_wext_siwpmksa()
1460 return -EOPNOTSUPP; in cfg80211_wext_siwpmksa()
1465 if (!rdev->ops->flush_pmksa) in cfg80211_wext_siwpmksa()
1466 return -EOPNOTSUPP; in cfg80211_wext_siwpmksa()
1471 return -EOPNOTSUPP; in cfg80211_wext_siwpmksa()