Lines Matching refs:wdev
50 static void cfg80211_sme_free(struct wireless_dev *wdev)
52 if (!wdev->conn)
55 kfree(wdev->conn->ie);
56 kfree(wdev->conn);
57 wdev->conn = NULL;
60 static int cfg80211_conn_scan(struct wireless_dev *wdev)
62 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
67 ASSERT_WDEV_LOCK(wdev);
72 if (wdev->conn->params.channel)
75 n_channels = ieee80211_get_num_supported_channels(wdev->wiphy);
83 if (wdev->conn->params.channel)
84 request->channels[0] = wdev->conn->params.channel;
92 bands = wdev->wiphy->bands[band];
109 memcpy(request->ssids[0].ssid, wdev->conn->params.ssid,
110 wdev->conn->params.ssid_len);
111 request->ssids[0].ssid_len = wdev->conn->params.ssid_len;
113 request->wdev = wdev;
121 wdev->conn->state = CFG80211_CONN_SCANNING;
122 nl80211_send_scan_start(rdev, wdev);
123 dev_hold(wdev->netdev);
131 static int cfg80211_conn_do_work(struct wireless_dev *wdev)
133 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
138 ASSERT_WDEV_LOCK(wdev);
140 if (!wdev->conn)
143 params = &wdev->conn->params;
145 switch (wdev->conn->state) {
150 return cfg80211_conn_scan(wdev);
154 wdev->conn->state = CFG80211_CONN_AUTHENTICATING;
155 return cfg80211_mlme_auth(rdev, wdev->netdev,
167 wdev->conn->state = CFG80211_CONN_ASSOCIATING;
168 if (wdev->conn->prev_bssid_valid)
169 req.prev_bssid = wdev->conn->prev_bssid;
180 err = cfg80211_mlme_assoc(rdev, wdev->netdev, params->channel,
184 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
190 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
195 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
199 cfg80211_sme_free(wdev);
210 struct wireless_dev *wdev;
215 list_for_each_entry(wdev, &rdev->wdev_list, list) {
216 if (!wdev->netdev)
219 wdev_lock(wdev);
220 if (!netif_running(wdev->netdev)) {
221 wdev_unlock(wdev);
224 if (!wdev->conn ||
225 wdev->conn->state == CFG80211_CONN_CONNECTED) {
226 wdev_unlock(wdev);
229 if (wdev->conn->params.bssid) {
230 memcpy(bssid_buf, wdev->conn->params.bssid, ETH_ALEN);
233 if (cfg80211_conn_do_work(wdev)) {
235 wdev->netdev, bssid,
240 wdev_unlock(wdev);
247 static struct cfg80211_bss *cfg80211_get_conn_bss(struct wireless_dev *wdev)
249 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
253 ASSERT_WDEV_LOCK(wdev);
255 if (wdev->conn->params.privacy)
258 bss = cfg80211_get_bss(wdev->wiphy, wdev->conn->params.channel,
259 wdev->conn->params.bssid,
260 wdev->conn->params.ssid,
261 wdev->conn->params.ssid_len,
267 memcpy(wdev->conn->bssid, bss->bssid, ETH_ALEN);
268 wdev->conn->params.bssid = wdev->conn->bssid;
269 wdev->conn->params.channel = bss->channel;
270 wdev->conn->state = CFG80211_CONN_AUTHENTICATE_NEXT;
278 struct wireless_dev *wdev = dev->ieee80211_ptr;
279 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
282 ASSERT_WDEV_LOCK(wdev);
284 if (!wdev->conn)
287 if (wdev->conn->state != CFG80211_CONN_SCANNING &&
288 wdev->conn->state != CFG80211_CONN_SCAN_AGAIN)
291 bss = cfg80211_get_conn_bss(wdev);
300 struct wireless_dev *wdev = dev->ieee80211_ptr;
302 wdev_lock(wdev);
304 wdev_unlock(wdev);
307 void cfg80211_sme_rx_auth(struct wireless_dev *wdev, const u8 *buf, size_t len)
309 struct wiphy *wiphy = wdev->wiphy;
314 ASSERT_WDEV_LOCK(wdev);
316 if (!wdev->conn || wdev->conn->state == CFG80211_CONN_CONNECTED)
320 wdev->conn->auto_auth &&
321 wdev->conn->params.auth_type != NL80211_AUTHTYPE_NETWORK_EAP) {
323 switch (wdev->conn->params.auth_type) {
325 if (wdev->connect_keys)
326 wdev->conn->params.auth_type =
329 wdev->conn->params.auth_type =
333 wdev->conn->params.auth_type =
338 wdev->conn->params.auth_type =
342 wdev->conn->state = CFG80211_CONN_AUTHENTICATE_NEXT;
345 __cfg80211_connect_result(wdev->netdev, mgmt->bssid,
348 } else if (wdev->conn->state == CFG80211_CONN_AUTHENTICATING) {
349 wdev->conn->state = CFG80211_CONN_ASSOCIATE_NEXT;
354 bool cfg80211_sme_rx_assoc_resp(struct wireless_dev *wdev, u16 status)
356 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
358 if (!wdev->conn)
362 wdev->conn->state = CFG80211_CONN_CONNECTED;
366 if (wdev->conn->prev_bssid_valid) {
372 wdev->conn->prev_bssid_valid = false;
373 wdev->conn->state = CFG80211_CONN_ASSOCIATE_NEXT;
378 wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
383 void cfg80211_sme_deauth(struct wireless_dev *wdev)
385 cfg80211_sme_free(wdev);
388 void cfg80211_sme_auth_timeout(struct wireless_dev *wdev)
390 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
392 if (!wdev->conn)
395 wdev->conn->state = CFG80211_CONN_AUTH_FAILED;
399 void cfg80211_sme_disassoc(struct wireless_dev *wdev)
401 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
403 if (!wdev->conn)
406 wdev->conn->state = CFG80211_CONN_DEAUTH;
410 void cfg80211_sme_assoc_timeout(struct wireless_dev *wdev)
412 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
414 if (!wdev->conn)
417 wdev->conn->state = CFG80211_CONN_ASSOC_FAILED;
421 static int cfg80211_sme_connect(struct wireless_dev *wdev,
425 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
432 if (wdev->current_bss)
435 if (WARN_ON(wdev->conn))
438 wdev->conn = kzalloc(sizeof(*wdev->conn), GFP_KERNEL);
439 if (!wdev->conn)
445 memcpy(&wdev->conn->params, connect, sizeof(*connect));
447 wdev->conn->params.bssid = wdev->conn->bssid;
448 memcpy(wdev->conn->bssid, connect->bssid, ETH_ALEN);
452 wdev->conn->ie = kmemdup(connect->ie, connect->ie_len,
454 wdev->conn->params.ie = wdev->conn->ie;
455 if (!wdev->conn->ie) {
456 kfree(wdev->conn);
457 wdev->conn = NULL;
463 wdev->conn->auto_auth = true;
465 wdev->conn->params.auth_type =
468 wdev->conn->auto_auth = false;
471 wdev->conn->params.ssid = wdev->ssid;
472 wdev->conn->params.ssid_len = wdev->ssid_len;
475 bss = cfg80211_get_conn_bss(wdev);
478 memcpy(wdev->conn->prev_bssid, prev_bssid, ETH_ALEN);
479 wdev->conn->prev_bssid_valid = true;
484 err = cfg80211_conn_do_work(wdev);
485 cfg80211_put_bss(wdev->wiphy, bss);
488 err = cfg80211_conn_scan(wdev);
497 wdev->conn->state = CFG80211_CONN_SCAN_AGAIN;
502 cfg80211_sme_free(wdev);
507 static int cfg80211_sme_disconnect(struct wireless_dev *wdev, u16 reason)
509 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
512 if (!wdev->conn)
518 if (wdev->conn->state == CFG80211_CONN_SCANNING ||
519 wdev->conn->state == CFG80211_CONN_SCAN_AGAIN) {
524 /* wdev->conn->params.bssid must be set if > SCANNING */
525 err = cfg80211_mlme_deauth(rdev, wdev->netdev,
526 wdev->conn->params.bssid,
529 cfg80211_sme_free(wdev);
540 struct wireless_dev *wdev;
549 list_for_each_entry(wdev, &rdev->wdev_list, list) {
550 wdev_lock(wdev);
551 if (wdev->conn || wdev->current_bss)
553 wdev_unlock(wdev);
583 struct wireless_dev *wdev = dev->ieee80211_ptr;
589 ASSERT_WDEV_LOCK(wdev);
591 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION &&
592 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) {
593 cfg80211_put_bss(wdev->wiphy, bss);
597 nl80211_send_connect_result(wiphy_to_rdev(wdev->wiphy), dev,
620 memcpy(wdev->wext.prev_bssid, bssid, ETH_ALEN);
621 wdev->wext.prev_bssid_valid = true;
628 WARN_ON_ONCE(!wiphy_to_rdev(wdev->wiphy)->ops->connect);
629 bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid,
630 wdev->ssid, wdev->ssid_len,
637 if (wdev->current_bss) {
638 cfg80211_unhold_bss(wdev->current_bss);
639 cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub);
640 wdev->current_bss = NULL;
644 kzfree(wdev->connect_keys);
645 wdev->connect_keys = NULL;
646 wdev->ssid_len = 0;
649 cfg80211_put_bss(wdev->wiphy, bss);
651 cfg80211_sme_free(wdev);
658 wdev->current_bss = bss_from_pub(bss);
660 cfg80211_upload_connect_keys(wdev);
680 regulatory_hint_country_ie(wdev->wiphy, bss->channel->band,
690 struct wireless_dev *wdev = dev->ieee80211_ptr;
691 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
714 spin_lock_irqsave(&wdev->event_lock, flags);
715 list_add_tail(&ev->list, &wdev->event_list);
716 spin_unlock_irqrestore(&wdev->event_lock, flags);
722 void __cfg80211_roamed(struct wireless_dev *wdev,
730 ASSERT_WDEV_LOCK(wdev);
732 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION &&
733 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT))
736 if (WARN_ON(!wdev->current_bss))
739 cfg80211_unhold_bss(wdev->current_bss);
740 cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub);
741 wdev->current_bss = NULL;
744 wdev->current_bss = bss_from_pub(bss);
746 nl80211_send_roamed(wiphy_to_rdev(wdev->wiphy),
747 wdev->netdev, bss->bssid,
755 wireless_send_event(wdev->netdev, IWEVASSOCREQIE,
762 wireless_send_event(wdev->netdev, IWEVASSOCRESPIE,
769 memcpy(wdev->wext.prev_bssid, bss->bssid, ETH_ALEN);
770 wdev->wext.prev_bssid_valid = true;
771 wireless_send_event(wdev->netdev, SIOCGIWAP, &wrqu, NULL);
776 cfg80211_put_bss(wdev->wiphy, bss);
785 struct wireless_dev *wdev = dev->ieee80211_ptr;
788 bss = cfg80211_get_bss(wdev->wiphy, channel, bssid, wdev->ssid,
789 wdev->ssid_len, WLAN_CAPABILITY_ESS,
805 struct wireless_dev *wdev = dev->ieee80211_ptr;
806 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
815 cfg80211_put_bss(wdev->wiphy, bss);
828 spin_lock_irqsave(&wdev->event_lock, flags);
829 list_add_tail(&ev->list, &wdev->event_list);
830 spin_unlock_irqrestore(&wdev->event_lock, flags);
838 struct wireless_dev *wdev = dev->ieee80211_ptr;
839 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
845 ASSERT_WDEV_LOCK(wdev);
847 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION &&
848 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT))
851 if (wdev->current_bss) {
852 cfg80211_unhold_bss(wdev->current_bss);
853 cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub);
856 wdev->current_bss = NULL;
857 wdev->ssid_len = 0;
875 wdev->wext.connect.ssid_len = 0;
884 struct wireless_dev *wdev = dev->ieee80211_ptr;
885 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
899 spin_lock_irqsave(&wdev->event_lock, flags);
900 list_add_tail(&ev->list, &wdev->event_list);
901 spin_unlock_irqrestore(&wdev->event_lock, flags);
915 struct wireless_dev *wdev = dev->ieee80211_ptr;
918 ASSERT_WDEV_LOCK(wdev);
920 if (WARN_ON(wdev->connect_keys)) {
921 kzfree(wdev->connect_keys);
922 wdev->connect_keys = NULL;
955 wdev->connect_keys = connkeys;
956 memcpy(wdev->ssid, connect->ssid, connect->ssid_len);
957 wdev->ssid_len = connect->ssid_len;
960 err = cfg80211_sme_connect(wdev, connect, prev_bssid);
965 wdev->connect_keys = NULL;
966 wdev->ssid_len = 0;
976 struct wireless_dev *wdev = dev->ieee80211_ptr;
979 ASSERT_WDEV_LOCK(wdev);
981 kzfree(wdev->connect_keys);
982 wdev->connect_keys = NULL;
984 if (wdev->conn)
985 err = cfg80211_sme_disconnect(wdev, reason);
988 else if (wdev->current_bss)