1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 260771780SMichal Kazior #include <linux/ieee80211.h> 360771780SMichal Kazior #include <linux/export.h> 460771780SMichal Kazior #include <net/cfg80211.h> 560771780SMichal Kazior #include "nl80211.h" 660771780SMichal Kazior #include "core.h" 7e35e4d28SHila Gonen #include "rdev-ops.h" 860771780SMichal Kazior 960771780SMichal Kazior 10f04c2203SMichal Kazior int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, 117c8d5e03SIlan Peer struct net_device *dev, bool notify) 1260771780SMichal Kazior { 1360771780SMichal Kazior struct wireless_dev *wdev = dev->ieee80211_ptr; 1460771780SMichal Kazior int err; 1560771780SMichal Kazior 1660771780SMichal Kazior ASSERT_WDEV_LOCK(wdev); 1760771780SMichal Kazior 1860771780SMichal Kazior if (!rdev->ops->stop_ap) 1960771780SMichal Kazior return -EOPNOTSUPP; 2060771780SMichal Kazior 2160771780SMichal Kazior if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && 2260771780SMichal Kazior dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) 2360771780SMichal Kazior return -EOPNOTSUPP; 2460771780SMichal Kazior 2560771780SMichal Kazior if (!wdev->beacon_interval) 2660771780SMichal Kazior return -ENOENT; 2760771780SMichal Kazior 28e35e4d28SHila Gonen err = rdev_stop_ap(rdev, dev); 29f4489ebeSMichal Kazior if (!err) { 3060771780SMichal Kazior wdev->beacon_interval = 0; 319e0e2961SMichal Kazior memset(&wdev->chandef, 0, sizeof(wdev->chandef)); 3206e191e2SAntonio Quartulli wdev->ssid_len = 0; 33fa9ffc74SKyeyoon Park rdev_set_qos_map(rdev, dev, NULL); 347c8d5e03SIlan Peer if (notify) 35348baf0eSJohannes Berg nl80211_send_ap_stopped(wdev); 36b35a51c7SVasanthakumar Thiagarajan 37b35a51c7SVasanthakumar Thiagarajan /* Should we apply the grace period during beaconing interface 38b35a51c7SVasanthakumar Thiagarajan * shutdown also? 39b35a51c7SVasanthakumar Thiagarajan */ 40b35a51c7SVasanthakumar Thiagarajan cfg80211_sched_dfs_chan_update(rdev); 41f4489ebeSMichal Kazior } 4260771780SMichal Kazior 4360771780SMichal Kazior return err; 4460771780SMichal Kazior } 4560771780SMichal Kazior 4660771780SMichal Kazior int cfg80211_stop_ap(struct cfg80211_registered_device *rdev, 477c8d5e03SIlan Peer struct net_device *dev, bool notify) 4860771780SMichal Kazior { 4960771780SMichal Kazior struct wireless_dev *wdev = dev->ieee80211_ptr; 5060771780SMichal Kazior int err; 5160771780SMichal Kazior 5260771780SMichal Kazior wdev_lock(wdev); 537c8d5e03SIlan Peer err = __cfg80211_stop_ap(rdev, dev, notify); 5460771780SMichal Kazior wdev_unlock(wdev); 5560771780SMichal Kazior 5660771780SMichal Kazior return err; 5760771780SMichal Kazior } 58