Commit 5314526b authored by Thomas Pedersen's avatar Thomas Pedersen Committed by John W. Linville

cfg80211: add channel switch notify event

The firmware may decide to switch channels while already beaconing, e.g.
in response to a cfg80211 connect request on a different vif. Add this
event to notify userspace when an AP or GO interface has successfully
migrated to a new channel, so it can update its configuration
accordingly.
Signed-off-by: default avatarThomas Pedersen <c_tpeder@qca.qualcomm.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 14dc7852
...@@ -548,6 +548,11 @@ ...@@ -548,6 +548,11 @@
* @NL80211_CMD_SET_NOACK_MAP: sets a bitmap for the individual TIDs whether * @NL80211_CMD_SET_NOACK_MAP: sets a bitmap for the individual TIDs whether
* No Acknowledgement Policy should be applied. * No Acknowledgement Policy should be applied.
* *
* @NL80211_CMD_CH_SWITCH_NOTIFY: An AP or GO may decide to switch channels
* independently of the userspace SME, send this event indicating
* %NL80211_ATTR_IFINDEX is now on %NL80211_ATTR_WIPHY_FREQ with
* %NL80211_ATTR_WIPHY_CHANNEL_TYPE.
*
* @NL80211_CMD_MAX: highest used command number * @NL80211_CMD_MAX: highest used command number
* @__NL80211_CMD_AFTER_LAST: internal use * @__NL80211_CMD_AFTER_LAST: internal use
*/ */
...@@ -689,6 +694,8 @@ enum nl80211_commands { ...@@ -689,6 +694,8 @@ enum nl80211_commands {
NL80211_CMD_SET_NOACK_MAP, NL80211_CMD_SET_NOACK_MAP,
NL80211_CMD_CH_SWITCH_NOTIFY,
/* add new commands above here */ /* add new commands above here */
/* used to define NL80211_CMD_MAX below */ /* used to define NL80211_CMD_MAX below */
......
...@@ -3354,6 +3354,17 @@ int cfg80211_can_beacon_sec_chan(struct wiphy *wiphy, ...@@ -3354,6 +3354,17 @@ int cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
struct ieee80211_channel *chan, struct ieee80211_channel *chan,
enum nl80211_channel_type channel_type); enum nl80211_channel_type channel_type);
/*
* cfg80211_ch_switch_notify - update wdev channel and notify userspace
* @dev: the device which switched channels
* @freq: new channel frequency (in MHz)
* @type: channel type
*
* Acquires wdev_lock, so must only be called from sleepable driver context!
*/
void cfg80211_ch_switch_notify(struct net_device *dev, int freq,
enum nl80211_channel_type type);
/* /*
* cfg80211_calculate_bitrate - calculate actual bitrate (in 100Kbps units) * cfg80211_calculate_bitrate - calculate actual bitrate (in 100Kbps units)
* @rate: given rate_info to calculate bitrate from * @rate: given rate_info to calculate bitrate from
......
...@@ -930,6 +930,33 @@ void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index, ...@@ -930,6 +930,33 @@ void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index,
} }
EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify); EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify);
void cfg80211_ch_switch_notify(struct net_device *dev, int freq,
enum nl80211_channel_type type)
{
struct wireless_dev *wdev = dev->ieee80211_ptr;
struct wiphy *wiphy = wdev->wiphy;
struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
struct ieee80211_channel *chan;
wdev_lock(wdev);
if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
wdev->iftype != NL80211_IFTYPE_P2P_GO))
goto out;
chan = rdev_freq_to_chan(rdev, freq, type);
if (WARN_ON(!chan))
goto out;
wdev->channel = chan;
nl80211_ch_switch_notify(rdev, dev, freq, type, GFP_KERNEL);
out:
wdev_unlock(wdev);
return;
}
EXPORT_SYMBOL(cfg80211_ch_switch_notify);
bool cfg80211_rx_spurious_frame(struct net_device *dev, bool cfg80211_rx_spurious_frame(struct net_device *dev,
const u8 *addr, gfp_t gfp) const u8 *addr, gfp_t gfp)
{ {
......
...@@ -7922,6 +7922,38 @@ void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev, ...@@ -7922,6 +7922,38 @@ void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev,
nlmsg_free(msg); nlmsg_free(msg);
} }
void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev,
struct net_device *netdev, int freq,
enum nl80211_channel_type type, gfp_t gfp)
{
struct sk_buff *msg;
void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, gfp);
if (!msg)
return;
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_CH_SWITCH_NOTIFY);
if (!hdr) {
nlmsg_free(msg);
return;
}
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex);
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq);
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, type);
genlmsg_end(msg, hdr);
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
nl80211_mlme_mcgrp.id, gfp);
return;
nla_put_failure:
genlmsg_cancel(msg, hdr);
nlmsg_free(msg);
}
void void
nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev, nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev,
struct net_device *netdev, const u8 *peer, struct net_device *netdev, const u8 *peer,
......
...@@ -118,6 +118,10 @@ void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev, ...@@ -118,6 +118,10 @@ void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev,
struct net_device *netdev, int index, struct net_device *netdev, int index,
const u8 *bssid, bool preauth, gfp_t gfp); const u8 *bssid, bool preauth, gfp_t gfp);
void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev,
struct net_device *dev, int freq,
enum nl80211_channel_type type, gfp_t gfp);
bool nl80211_unexpected_frame(struct net_device *dev, bool nl80211_unexpected_frame(struct net_device *dev,
const u8 *addr, gfp_t gfp); const u8 *addr, gfp_t gfp);
bool nl80211_unexpected_4addr_frame(struct net_device *dev, bool nl80211_unexpected_4addr_frame(struct net_device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment