Drivers may wish to report the RX frequency in units of KHz. Provide cfg80211_rx_mgmt_khz() and wrap it with cfg80211_rx_mgmt() so exisiting drivers which can't report KHz anyway don't need to change. Add a similar wrapper for cfg80211_report_obss_beacon() so the frequency units stay somewhat consistent. This doesn't actually change the nl80211 API yet.
Unified · Split
| @@ -3333,6 +3333,8 @@ static inline int ieee80211_get_tdls_action(struct sk_buff *skb, u32 hdr_size) · 3332 unmodified lines | ||
| 3333 | 3333 | /* convert frequencies */ |
| 3334 | 3334 | #define MHZ_TO_KHZ(freq) ((freq) * 1000) |
| 3335 | 3335 | #define KHZ_TO_MHZ(freq) ((freq) / 1000) |
| 3336 | +#define PR_KHZ(f) KHZ_TO_MHZ(f), f % 1000 | |
| 3337 | +#define KHZ_F "%d.%03d" | |
| 3336 | 3338 | |
| 3337 | 3339 | /* convert powers */ |
| 3338 | 3340 | #define DBI_TO_MBI(gain) ((gain) * 100) |
| @@ -6988,6 +6988,26 @@ void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr, · 6987 unmodified lines | ||
| 6988 | 6988 | enum nl80211_connect_failed_reason reason, |
| 6989 | 6989 | gfp_t gfp); |
| 6990 | 6990 | |
| 6991 | +/** | |
| 6992 | + * cfg80211_rx_mgmt_khz - notification of received, unprocessed management frame | |
| 6993 | + * @wdev: wireless device receiving the frame | |
| 6994 | + * @freq: Frequency on which the frame was received in KHz | |
| 6995 | + * @sig_dbm: signal strength in dBm, or 0 if unknown | |
| 6996 | + * @buf: Management frame (header + body) | |
| 6997 | + * @len: length of the frame data | |
| 6998 | + * @flags: flags, as defined in enum nl80211_rxmgmt_flags | |
| 6999 | + * | |
| 7000 | + * This function is called whenever an Action frame is received for a station | |
| 7001 | + * mode interface, but is not processed in kernel. | |
| 7002 | + * | |
| 7003 | + * Return: %true if a user space application has registered for this frame. | |
| 7004 | + * For action frames, that makes it responsible for rejecting unrecognized | |
| 7005 | + * action frames; %false otherwise, in which case for action frames the | |
| 7006 | + * driver is responsible for rejecting the frame. | |
| 7007 | + */ | |
| 7008 | +bool cfg80211_rx_mgmt_khz(struct wireless_dev *wdev, int freq, int sig_dbm, | |
| 7009 | + const u8 *buf, size_t len, u32 flags); | |
| 7010 | + | |
| 6991 | 7011 | /** |
| 6992 | 7012 | * cfg80211_rx_mgmt - notification of received, unprocessed management frame |
| 6993 | 7013 | * @wdev: wireless device receiving the frame |
| @@ -7005,8 +7025,13 @@ void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr, · 11 unmodified lines | ||
| 7005 | 7025 | * action frames; %false otherwise, in which case for action frames the |
| 7006 | 7026 | * driver is responsible for rejecting the frame. |
| 7007 | 7027 | */ |
| 7008 | −bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_dbm, | |
| 7009 | − const u8 *buf, size_t len, u32 flags); | |
| 7028 | +static inline bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, | |
| 7029 | + int sig_dbm, const u8 *buf, size_t len, | |
| 7030 | + u32 flags) | |
| 7031 | +{ | |
| 7032 | + return cfg80211_rx_mgmt_khz(wdev, MHZ_TO_KHZ(freq), sig_dbm, buf, len, | |
| 7033 | + flags); | |
| 7034 | +} | |
| 7010 | 7035 | |
| 7011 | 7036 | /** |
| 7012 | 7037 | * cfg80211_mgmt_tx_status - notification of TX status for management frame |
| @@ -7204,6 +7229,21 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr, · 191 unmodified lines | ||
| 7204 | 7229 | u64 cookie, bool acked, s32 ack_signal, |
| 7205 | 7230 | bool is_valid_ack_signal, gfp_t gfp); |
| 7206 | 7231 | |
| 7232 | +/** | |
| 7233 | + * cfg80211_report_obss_beacon_khz - report beacon from other APs | |
| 7234 | + * @wiphy: The wiphy that received the beacon | |
| 7235 | + * @frame: the frame | |
| 7236 | + * @len: length of the frame | |
| 7237 | + * @freq: frequency the frame was received on in KHz | |
| 7238 | + * @sig_dbm: signal strength in dBm, or 0 if unknown | |
| 7239 | + * | |
| 7240 | + * Use this function to report to userspace when a beacon was | |
| 7241 | + * received. It is not useful to call this when there is no | |
| 7242 | + * netdev that is in AP/GO mode. | |
| 7243 | + */ | |
| 7244 | +void cfg80211_report_obss_beacon_khz(struct wiphy *wiphy, const u8 *frame, | |
| 7245 | + size_t len, int freq, int sig_dbm); | |
| 7246 | + | |
| 7207 | 7247 | /** |
| 7208 | 7248 | * cfg80211_report_obss_beacon - report beacon from other APs |
| 7209 | 7249 | * @wiphy: The wiphy that received the beacon |
| @@ -7216,9 +7256,13 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr, · 6 unmodified lines | ||
| 7216 | 7256 | * received. It is not useful to call this when there is no |
| 7217 | 7257 | * netdev that is in AP/GO mode. |
| 7218 | 7258 | */ |
| 7219 | −void cfg80211_report_obss_beacon(struct wiphy *wiphy, | |
| 7220 | − const u8 *frame, size_t len, | |
| 7221 | − int freq, int sig_dbm); | |
| 7259 | +static inline void cfg80211_report_obss_beacon(struct wiphy *wiphy, | |
| 7260 | + const u8 *frame, size_t len, | |
| 7261 | + int freq, int sig_dbm) | |
| 7262 | +{ | |
| 7263 | + cfg80211_report_obss_beacon_khz(wiphy, frame, len, MHZ_TO_KHZ(freq), | |
| 7264 | + sig_dbm); | |
| 7265 | +} | |
| 7222 | 7266 | |
| 7223 | 7267 | /** |
| 7224 | 7268 | * cfg80211_reg_can_beacon - check if beaconing is allowed |
| @@ -3095,9 +3095,10 @@ ieee80211_rx_h_mgmt_check(struct ieee80211_rx_data *rx) · 3094 unmodified lines | ||
| 3095 | 3095 | !(status->flag & RX_FLAG_NO_SIGNAL_VAL)) |
| 3096 | 3096 | sig = status->signal; |
| 3097 | 3097 | |
| 3098 | − cfg80211_report_obss_beacon(rx->local->hw.wiphy, | |
| 3099 | − rx->skb->data, rx->skb->len, | |
| 3100 | − status->freq, sig); | |
| 3098 | + cfg80211_report_obss_beacon_khz(rx->local->hw.wiphy, | |
| 3099 | + rx->skb->data, rx->skb->len, | |
| 3100 | + ieee80211_rx_status_to_khz(status), | |
| 3101 | + sig); | |
| 3101 | 3102 | rx->flags |= IEEE80211_RX_BEACON_REPORTED; |
| 3102 | 3103 | } |
| 3103 | 3104 | |
| @@ -3443,8 +3444,9 @@ ieee80211_rx_h_userspace_mgmt(struct ieee80211_rx_data *rx) · 339 unmodified lines | ||
| 3443 | 3444 | !(status->flag & RX_FLAG_NO_SIGNAL_VAL)) |
| 3444 | 3445 | sig = status->signal; |
| 3445 | 3446 | |
| 3446 | − if (cfg80211_rx_mgmt(&rx->sdata->wdev, status->freq, sig, | |
| 3447 | − rx->skb->data, rx->skb->len, 0)) { | |
| 3447 | + if (cfg80211_rx_mgmt_khz(&rx->sdata->wdev, | |
| 3448 | + ieee80211_rx_status_to_khz(status), sig, | |
| 3449 | + rx->skb->data, rx->skb->len, 0)) { | |
| 3448 | 3450 | if (rx->sta) |
| 3449 | 3451 | rx->sta->rx_stats.packets++; |
| 3450 | 3452 | dev_kfree_skb(rx->skb); |
| @@ -729,8 +729,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, · 728 unmodified lines | ||
| 729 | 729 | return rdev_mgmt_tx(rdev, wdev, params, cookie); |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | −bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_dbm, | |
| 733 | − const u8 *buf, size_t len, u32 flags) | |
| 732 | +bool cfg80211_rx_mgmt_khz(struct wireless_dev *wdev, int freq, int sig_dbm, | |
| 733 | + const u8 *buf, size_t len, u32 flags) | |
| 734 | 734 | { |
| 735 | 735 | struct wiphy *wiphy = wdev->wiphy; |
| 736 | 736 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); |
| @@ -785,7 +785,7 @@ bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_dbm, · 48 unmodified lines | ||
| 785 | 785 | trace_cfg80211_return_bool(result); |
| 786 | 786 | return result; |
| 787 | 787 | } |
| 788 | −EXPORT_SYMBOL(cfg80211_rx_mgmt); | |
| 788 | +EXPORT_SYMBOL(cfg80211_rx_mgmt_khz); | |
| 789 | 789 | |
| 790 | 790 | void cfg80211_sched_dfs_chan_update(struct cfg80211_registered_device *rdev) |
| 791 | 791 | { |
| @@ -16214,7 +16214,7 @@ int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, · 16213 unmodified lines | ||
| 16214 | 16214 | netdev->ifindex)) || |
| 16215 | 16215 | nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev), |
| 16216 | 16216 | NL80211_ATTR_PAD) || |
| 16217 | − nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq) || | |
| 16217 | + nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, KHZ_TO_MHZ(freq)) || | |
| 16218 | 16218 | (sig_dbm && |
| 16219 | 16219 | nla_put_u32(msg, NL80211_ATTR_RX_SIGNAL_DBM, sig_dbm)) || |
| 16220 | 16220 | nla_put(msg, NL80211_ATTR_FRAME, len, buf) || |
| @@ -16840,9 +16840,8 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr, · 619 unmodified lines | ||
| 16840 | 16840 | } |
| 16841 | 16841 | EXPORT_SYMBOL(cfg80211_probe_status); |
| 16842 | 16842 | |
| 16843 | −void cfg80211_report_obss_beacon(struct wiphy *wiphy, | |
| 16844 | − const u8 *frame, size_t len, | |
| 16845 | − int freq, int sig_dbm) | |
| 16843 | +void cfg80211_report_obss_beacon_khz(struct wiphy *wiphy, const u8 *frame, | |
| 16844 | + size_t len, int freq, int sig_dbm) | |
| 16846 | 16845 | { |
| 16847 | 16846 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); |
| 16848 | 16847 | struct sk_buff *msg; |
| @@ -16865,7 +16864,8 @@ void cfg80211_report_obss_beacon(struct wiphy *wiphy, · 16 unmodified lines | ||
| 16865 | 16864 | |
| 16866 | 16865 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || |
| 16867 | 16866 | (freq && |
| 16868 | − nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq)) || | |
| 16867 | + nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, | |
| 16868 | + KHZ_TO_MHZ(freq))) || | |
| 16869 | 16869 | (sig_dbm && |
| 16870 | 16870 | nla_put_u32(msg, NL80211_ATTR_RX_SIGNAL_DBM, sig_dbm)) || |
| 16871 | 16871 | nla_put(msg, NL80211_ATTR_FRAME, len, frame)) |
| @@ -16882,7 +16882,7 @@ void cfg80211_report_obss_beacon(struct wiphy *wiphy, · 10 unmodified lines | ||
| 16882 | 16882 | spin_unlock_bh(&rdev->beacon_registrations_lock); |
| 16883 | 16883 | nlmsg_free(msg); |
| 16884 | 16884 | } |
| 16885 | −EXPORT_SYMBOL(cfg80211_report_obss_beacon); | |
| 16885 | +EXPORT_SYMBOL(cfg80211_report_obss_beacon_khz); | |
| 16886 | 16886 | |
| 16887 | 16887 | #ifdef CONFIG_PM |
| 16888 | 16888 | static int cfg80211_net_detect_results(struct sk_buff *msg, |
| @@ -2840,8 +2840,8 @@ TRACE_EVENT(cfg80211_rx_mgmt, · 2839 unmodified lines | ||
| 2840 | 2840 | __entry->freq = freq; |
| 2841 | 2841 | __entry->sig_dbm = sig_dbm; |
| 2842 | 2842 | ), |
| 2843 | − TP_printk(WDEV_PR_FMT ", freq: %d, sig dbm: %d", | |
| 2844 | − WDEV_PR_ARG, __entry->freq, __entry->sig_dbm) | |
| 2843 | + TP_printk(WDEV_PR_FMT ", freq: "KHZ_F", sig dbm: %d", | |
| 2844 | + WDEV_PR_ARG, PR_KHZ(__entry->freq), __entry->sig_dbm) | |
| 2845 | 2845 | ); |
| 2846 | 2846 | |
| 2847 | 2847 | TRACE_EVENT(cfg80211_mgmt_tx_status, |
| @@ -3121,8 +3121,8 @@ TRACE_EVENT(cfg80211_report_obss_beacon, · 273 unmodified lines | ||
| 3121 | 3121 | __entry->freq = freq; |
| 3122 | 3122 | __entry->sig_dbm = sig_dbm; |
| 3123 | 3123 | ), |
| 3124 | − TP_printk(WIPHY_PR_FMT ", freq: %d, sig_dbm: %d", | |
| 3125 | − WIPHY_PR_ARG, __entry->freq, __entry->sig_dbm) | |
| 3124 | + TP_printk(WIPHY_PR_FMT ", freq: "KHZ_F", sig_dbm: %d", | |
| 3125 | + WIPHY_PR_ARG, PR_KHZ(__entry->freq), __entry->sig_dbm) | |
| 3126 | 3126 | ); |
| 3127 | 3127 | |
| 3128 | 3128 | TRACE_EVENT(cfg80211_tdls_oper_request, |