Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cfg80211: clean up beacon loss CQM event

Having it as a sub-event for RSSI thresholds is very ugly,
but luckily no userspace actually uses the events yet.

Move the event to its own function call internally and to
its own event attribute in nl80211.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>

+62 -10
+1 -4
drivers/net/wireless/ti/wlcore/event.c
··· 259 259 &wlvif->connection_loss_work, 260 260 msecs_to_jiffies(delay)); 261 261 262 - ieee80211_cqm_rssi_notify( 263 - vif, 264 - NL80211_CQM_RSSI_BEACON_LOSS_EVENT, 265 - GFP_KERNEL); 262 + ieee80211_cqm_beacon_loss_notify(vif, GFP_KERNEL); 266 263 } 267 264 } 268 265 EXPORT_SYMBOL_GPL(wlcore_event_beacon_loss);
+9
include/net/cfg80211.h
··· 4670 4670 u32 num_packets, u32 rate, u32 intvl, gfp_t gfp); 4671 4671 4672 4672 /** 4673 + * cfg80211_cqm_beacon_loss_notify - beacon loss event 4674 + * @dev: network device 4675 + * @gfp: context flags 4676 + * 4677 + * Notify userspace about beacon loss from the connected AP. 4678 + */ 4679 + void cfg80211_cqm_beacon_loss_notify(struct net_device *dev, gfp_t gfp); 4680 + 4681 + /** 4673 4682 * cfg80211_radar_event - radar detection event 4674 4683 * @wiphy: the wiphy 4675 4684 * @chandef: chandef for the current channel
+8
include/net/mac80211.h
··· 4672 4672 gfp_t gfp); 4673 4673 4674 4674 /** 4675 + * ieee80211_cqm_beacon_loss_notify - inform CQM of beacon loss 4676 + * 4677 + * @vif: &struct ieee80211_vif pointer from the add_interface callback. 4678 + * @gfp: context flags 4679 + */ 4680 + void ieee80211_cqm_beacon_loss_notify(struct ieee80211_vif *vif, gfp_t gfp); 4681 + 4682 + /** 4675 4683 * ieee80211_radar_detected - inform that a radar was detected 4676 4684 * 4677 4685 * @hw: pointer as obtained from ieee80211_alloc_hw()
+4 -3
include/uapi/linux/nl80211.h
··· 3451 3451 * interval in which %NL80211_ATTR_CQM_TXE_PKTS and 3452 3452 * %NL80211_ATTR_CQM_TXE_RATE must be satisfied before generating an 3453 3453 * %NL80211_CMD_NOTIFY_CQM. Set to 0 to turn off TX error reporting. 3454 + * @NL80211_ATTR_CQM_BEACON_LOSS_EVENT: flag attribute that's set in a beacon 3455 + * loss event 3454 3456 * @__NL80211_ATTR_CQM_AFTER_LAST: internal 3455 3457 * @NL80211_ATTR_CQM_MAX: highest key attribute 3456 3458 */ ··· 3465 3463 NL80211_ATTR_CQM_TXE_RATE, 3466 3464 NL80211_ATTR_CQM_TXE_PKTS, 3467 3465 NL80211_ATTR_CQM_TXE_INTVL, 3466 + NL80211_ATTR_CQM_BEACON_LOSS_EVENT, 3468 3467 3469 3468 /* keep last */ 3470 3469 __NL80211_ATTR_CQM_AFTER_LAST, ··· 3478 3475 * configured threshold 3479 3476 * @NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH: The RSSI is higher than the 3480 3477 * configured threshold 3481 - * @NL80211_CQM_RSSI_BEACON_LOSS_EVENT: The device experienced beacon loss. 3482 - * (Note that deauth/disassoc will still follow if the AP is not 3483 - * available. This event might get used as roaming event, etc.) 3478 + * @NL80211_CQM_RSSI_BEACON_LOSS_EVENT: (reserved, never sent) 3484 3479 */ 3485 3480 enum nl80211_cqm_rssi_threshold_event { 3486 3481 NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
+11 -3
net/mac80211/mlme.c
··· 2266 2266 "detected beacon loss from AP (missed %d beacons) - probing\n", 2267 2267 beacon_loss_count); 2268 2268 2269 - ieee80211_cqm_rssi_notify(&sdata->vif, 2270 - NL80211_CQM_RSSI_BEACON_LOSS_EVENT, 2271 - GFP_KERNEL); 2269 + ieee80211_cqm_beacon_loss_notify(&sdata->vif, GFP_KERNEL); 2272 2270 } 2273 2271 2274 2272 /* ··· 4899 4901 cfg80211_cqm_rssi_notify(sdata->dev, rssi_event, gfp); 4900 4902 } 4901 4903 EXPORT_SYMBOL(ieee80211_cqm_rssi_notify); 4904 + 4905 + void ieee80211_cqm_beacon_loss_notify(struct ieee80211_vif *vif, gfp_t gfp) 4906 + { 4907 + struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); 4908 + 4909 + trace_api_cqm_beacon_loss_notify(sdata->local, sdata); 4910 + 4911 + cfg80211_cqm_beacon_loss_notify(sdata->dev, gfp); 4912 + } 4913 + EXPORT_SYMBOL(ieee80211_cqm_beacon_loss_notify);
+6
net/mac80211/trace.h
··· 1829 1829 ) 1830 1830 ); 1831 1831 1832 + DEFINE_EVENT(local_sdata_evt, api_cqm_beacon_loss_notify, 1833 + TP_PROTO(struct ieee80211_local *local, 1834 + struct ieee80211_sub_if_data *sdata), 1835 + TP_ARGS(local, sdata) 1836 + ); 1837 + 1832 1838 TRACE_EVENT(api_scan_completed, 1833 1839 TP_PROTO(struct ieee80211_local *local, bool aborted), 1834 1840
+23
net/wireless/nl80211.c
··· 11826 11826 11827 11827 trace_cfg80211_cqm_rssi_notify(dev, rssi_event); 11828 11828 11829 + if (WARN_ON(rssi_event != NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW && 11830 + rssi_event != NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH)) 11831 + return; 11832 + 11829 11833 msg = cfg80211_prepare_cqm(dev, NULL, gfp); 11830 11834 if (!msg) 11831 11835 return; ··· 11895 11891 nlmsg_free(msg); 11896 11892 } 11897 11893 EXPORT_SYMBOL(cfg80211_cqm_pktloss_notify); 11894 + 11895 + void cfg80211_cqm_beacon_loss_notify(struct net_device *dev, gfp_t gfp) 11896 + { 11897 + struct sk_buff *msg; 11898 + 11899 + msg = cfg80211_prepare_cqm(dev, NULL, gfp); 11900 + if (!msg) 11901 + return; 11902 + 11903 + if (nla_put_flag(msg, NL80211_ATTR_CQM_BEACON_LOSS_EVENT)) 11904 + goto nla_put_failure; 11905 + 11906 + cfg80211_send_cqm(msg, gfp); 11907 + return; 11908 + 11909 + nla_put_failure: 11910 + nlmsg_free(msg); 11911 + } 11912 + EXPORT_SYMBOL(cfg80211_cqm_beacon_loss_notify); 11898 11913 11899 11914 static void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev, 11900 11915 struct net_device *netdev, const u8 *bssid,