Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Michal Kazior | 6077178 | 2012-06-29 12:46:56 +0200 | [diff] [blame] | 2 | #include <linux/ieee80211.h> |
| 3 | #include <linux/export.h> |
| 4 | #include <net/cfg80211.h> |
| 5 | #include "nl80211.h" |
| 6 | #include "core.h" |
Hila Gonen | e35e4d2 | 2012-06-27 17:19:42 +0300 | [diff] [blame] | 7 | #include "rdev-ops.h" |
Michal Kazior | 6077178 | 2012-06-29 12:46:56 +0200 | [diff] [blame] | 8 | |
| 9 | |
Michal Kazior | f04c220 | 2014-04-09 15:11:01 +0200 | [diff] [blame] | 10 | int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, |
| 11 | struct net_device *dev, bool notify) |
Michal Kazior | 6077178 | 2012-06-29 12:46:56 +0200 | [diff] [blame] | 12 | { |
| 13 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 14 | int err; |
| 15 | |
| 16 | ASSERT_WDEV_LOCK(wdev); |
| 17 | |
| 18 | if (!rdev->ops->stop_ap) |
| 19 | return -EOPNOTSUPP; |
| 20 | |
| 21 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && |
| 22 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) |
| 23 | return -EOPNOTSUPP; |
| 24 | |
| 25 | if (!wdev->beacon_interval) |
| 26 | return -ENOENT; |
| 27 | |
Hila Gonen | e35e4d2 | 2012-06-27 17:19:42 +0300 | [diff] [blame] | 28 | err = rdev_stop_ap(rdev, dev); |
Michal Kazior | f4489eb | 2012-06-29 12:46:58 +0200 | [diff] [blame] | 29 | if (!err) { |
Denis Kenzior | 466a306 | 2018-03-26 12:52:47 -0500 | [diff] [blame] | 30 | wdev->conn_owner_nlportid = 0; |
Michal Kazior | 6077178 | 2012-06-29 12:46:56 +0200 | [diff] [blame] | 31 | wdev->beacon_interval = 0; |
Michal Kazior | 9e0e296 | 2014-01-29 14:22:27 +0100 | [diff] [blame] | 32 | memset(&wdev->chandef, 0, sizeof(wdev->chandef)); |
Antonio Quartulli | 06e191e | 2012-11-07 12:52:19 +0100 | [diff] [blame] | 33 | wdev->ssid_len = 0; |
Kyeyoon Park | fa9ffc7 | 2013-12-16 23:01:30 -0800 | [diff] [blame] | 34 | rdev_set_qos_map(rdev, dev, NULL); |
Ilan Peer | 7c8d5e0 | 2014-02-25 15:33:38 +0200 | [diff] [blame] | 35 | if (notify) |
| 36 | nl80211_send_ap_stopped(wdev); |
Vasanthakumar Thiagarajan | b35a51c | 2017-02-27 17:04:33 +0530 | [diff] [blame] | 37 | |
| 38 | /* Should we apply the grace period during beaconing interface |
| 39 | * shutdown also? |
| 40 | */ |
| 41 | cfg80211_sched_dfs_chan_update(rdev); |
Michal Kazior | f4489eb | 2012-06-29 12:46:58 +0200 | [diff] [blame] | 42 | } |
Michal Kazior | 6077178 | 2012-06-29 12:46:56 +0200 | [diff] [blame] | 43 | |
| 44 | return err; |
| 45 | } |
| 46 | |
| 47 | int cfg80211_stop_ap(struct cfg80211_registered_device *rdev, |
Ilan Peer | 7c8d5e0 | 2014-02-25 15:33:38 +0200 | [diff] [blame] | 48 | struct net_device *dev, bool notify) |
Michal Kazior | 6077178 | 2012-06-29 12:46:56 +0200 | [diff] [blame] | 49 | { |
| 50 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 51 | int err; |
| 52 | |
| 53 | wdev_lock(wdev); |
Ilan Peer | 7c8d5e0 | 2014-02-25 15:33:38 +0200 | [diff] [blame] | 54 | err = __cfg80211_stop_ap(rdev, dev, notify); |
Michal Kazior | 6077178 | 2012-06-29 12:46:56 +0200 | [diff] [blame] | 55 | wdev_unlock(wdev); |
| 56 | |
| 57 | return err; |
| 58 | } |