aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-01-22 06:34:29 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-01-31 08:00:21 -0500
commitcd8f7cb4e6dfa4ea08fc250a814240b883ef7911 (patch)
tree2bcb8f04f01ee9768e5524799b0d429e51fb583d /net/wireless
parent3b144658bc7be5f7fa68d13ba24afb4c24489965 (diff)
cfg80211/mac80211: support reporting wakeup reason
When waking up from WoWLAN, it is useful to know what triggered the wakeup. Support reporting the wakeup reason(s) in cfg80211 (and a pass-through in mac80211) to allow userspace to know. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/nl80211.c97
-rw-r--r--net/wireless/trace.h35
2 files changed, 132 insertions, 0 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index b5978ab4ad7a..d359734b6972 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -9323,6 +9323,103 @@ void cfg80211_report_obss_beacon(struct wiphy *wiphy,
9323} 9323}
9324EXPORT_SYMBOL(cfg80211_report_obss_beacon); 9324EXPORT_SYMBOL(cfg80211_report_obss_beacon);
9325 9325
9326#ifdef CONFIG_PM
9327void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,
9328 struct cfg80211_wowlan_wakeup *wakeup,
9329 gfp_t gfp)
9330{
9331 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
9332 struct sk_buff *msg;
9333 void *hdr;
9334 int err, size = 200;
9335
9336 trace_cfg80211_report_wowlan_wakeup(wdev->wiphy, wdev, wakeup);
9337
9338 if (wakeup)
9339 size += wakeup->packet_present_len;
9340
9341 msg = nlmsg_new(size, gfp);
9342 if (!msg)
9343 return;
9344
9345 hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_SET_WOWLAN);
9346 if (!hdr)
9347 goto free_msg;
9348
9349 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
9350 nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
9351 goto free_msg;
9352
9353 if (wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX,
9354 wdev->netdev->ifindex))
9355 goto free_msg;
9356
9357 if (wakeup) {
9358 struct nlattr *reasons;
9359
9360 reasons = nla_nest_start(msg, NL80211_ATTR_WOWLAN_TRIGGERS);
9361
9362 if (wakeup->disconnect &&
9363 nla_put_flag(msg, NL80211_WOWLAN_TRIG_DISCONNECT))
9364 goto free_msg;
9365 if (wakeup->magic_pkt &&
9366 nla_put_flag(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT))
9367 goto free_msg;
9368 if (wakeup->gtk_rekey_failure &&
9369 nla_put_flag(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE))
9370 goto free_msg;
9371 if (wakeup->eap_identity_req &&
9372 nla_put_flag(msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST))
9373 goto free_msg;
9374 if (wakeup->four_way_handshake &&
9375 nla_put_flag(msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE))
9376 goto free_msg;
9377 if (wakeup->rfkill_release &&
9378 nla_put_flag(msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE))
9379 goto free_msg;
9380
9381 if (wakeup->pattern_idx >= 0 &&
9382 nla_put_u32(msg, NL80211_WOWLAN_TRIG_PKT_PATTERN,
9383 wakeup->pattern_idx))
9384 goto free_msg;
9385
9386 if (wakeup->packet) {
9387 u32 pkt_attr = NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211;
9388 u32 len_attr = NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211_LEN;
9389
9390 if (!wakeup->packet_80211) {
9391 pkt_attr =
9392 NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023;
9393 len_attr =
9394 NL80211_WOWLAN_TRIG_WAKEUP_PKT_8023_LEN;
9395 }
9396
9397 if (wakeup->packet_len &&
9398 nla_put_u32(msg, len_attr, wakeup->packet_len))
9399 goto free_msg;
9400
9401 if (nla_put(msg, pkt_attr, wakeup->packet_present_len,
9402 wakeup->packet))
9403 goto free_msg;
9404 }
9405
9406 nla_nest_end(msg, reasons);
9407 }
9408
9409 err = genlmsg_end(msg, hdr);
9410 if (err < 0)
9411 goto free_msg;
9412
9413 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
9414 nl80211_mlme_mcgrp.id, gfp);
9415 return;
9416
9417 free_msg:
9418 nlmsg_free(msg);
9419}
9420EXPORT_SYMBOL(cfg80211_report_wowlan_wakeup);
9421#endif
9422
9326void cfg80211_tdls_oper_request(struct net_device *dev, const u8 *peer, 9423void cfg80211_tdls_oper_request(struct net_device *dev, const u8 *peer,
9327 enum nl80211_tdls_operation oper, 9424 enum nl80211_tdls_operation oper,
9328 u16 reason_code, gfp_t gfp) 9425 u16 reason_code, gfp_t gfp)
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 8bc553199686..c9cafb0ea95f 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -2333,6 +2333,41 @@ TRACE_EVENT(cfg80211_return_u32,
2333 TP_printk("ret: %u", __entry->ret) 2333 TP_printk("ret: %u", __entry->ret)
2334); 2334);
2335 2335
2336TRACE_EVENT(cfg80211_report_wowlan_wakeup,
2337 TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
2338 struct cfg80211_wowlan_wakeup *wakeup),
2339 TP_ARGS(wiphy, wdev, wakeup),
2340 TP_STRUCT__entry(
2341 WIPHY_ENTRY
2342 WDEV_ENTRY
2343 __field(bool, disconnect)
2344 __field(bool, magic_pkt)
2345 __field(bool, gtk_rekey_failure)
2346 __field(bool, eap_identity_req)
2347 __field(bool, four_way_handshake)
2348 __field(bool, rfkill_release)
2349 __field(s32, pattern_idx)
2350 __field(u32, packet_len)
2351 __dynamic_array(u8, packet, wakeup->packet_present_len)
2352 ),
2353 TP_fast_assign(
2354 WIPHY_ASSIGN;
2355 WDEV_ASSIGN;
2356 __entry->disconnect = wakeup->disconnect;
2357 __entry->magic_pkt = wakeup->magic_pkt;
2358 __entry->gtk_rekey_failure = wakeup->gtk_rekey_failure;
2359 __entry->eap_identity_req = wakeup->eap_identity_req;
2360 __entry->four_way_handshake = wakeup->four_way_handshake;
2361 __entry->rfkill_release = wakeup->rfkill_release;
2362 __entry->pattern_idx = wakeup->pattern_idx;
2363 __entry->packet_len = wakeup->packet_len;
2364 if (wakeup->packet && wakeup->packet_present_len)
2365 memcpy(__get_dynamic_array(packet), wakeup->packet,
2366 wakeup->packet_present_len);
2367 ),
2368 TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT, WIPHY_PR_ARG, WDEV_PR_ARG)
2369);
2370
2336#endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ 2371#endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */
2337 2372
2338#undef TRACE_INCLUDE_PATH 2373#undef TRACE_INCLUDE_PATH