Skip to content

Commit 830af02

Browse files
jmberg-intellinvjw
authored andcommitted
mac80211: allow driver to iterate keys
When in suspend/wowlan, devices might implement crypto offload differently (more features), and might require reprogramming keys for the WoWLAN (as it is the case for Intel devices that use another uCode image). Thus allow the driver to iterate all keys in this context. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 68dd49e commit 830af02

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

include/net/mac80211.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,6 +2849,29 @@ struct ieee80211_sta *ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw,
28492849
void ieee80211_sta_block_awake(struct ieee80211_hw *hw,
28502850
struct ieee80211_sta *pubsta, bool block);
28512851

2852+
/**
2853+
* ieee80211_iter_keys - iterate keys programmed into the device
2854+
* @hw: pointer obtained from ieee80211_alloc_hw()
2855+
* @vif: virtual interface to iterate, may be %NULL for all
2856+
* @iter: iterator function that will be called for each key
2857+
* @iter_data: custom data to pass to the iterator function
2858+
*
2859+
* This function can be used to iterate all the keys known to
2860+
* mac80211, even those that weren't previously programmed into
2861+
* the device. This is intended for use in WoWLAN if the device
2862+
* needs reprogramming of the keys during suspend. Note that due
2863+
* to locking reasons, it is also only safe to call this at few
2864+
* spots since it must hold the RTNL and be able to sleep.
2865+
*/
2866+
void ieee80211_iter_keys(struct ieee80211_hw *hw,
2867+
struct ieee80211_vif *vif,
2868+
void (*iter)(struct ieee80211_hw *hw,
2869+
struct ieee80211_vif *vif,
2870+
struct ieee80211_sta *sta,
2871+
struct ieee80211_key_conf *key,
2872+
void *data),
2873+
void *iter_data);
2874+
28522875
/**
28532876
* ieee80211_ap_probereq_get - retrieve a Probe Request template
28542877
* @hw: pointer obtained from ieee80211_alloc_hw().

net/mac80211/key.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,39 @@ void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata)
551551
mutex_unlock(&sdata->local->key_mtx);
552552
}
553553

554+
void ieee80211_iter_keys(struct ieee80211_hw *hw,
555+
struct ieee80211_vif *vif,
556+
void (*iter)(struct ieee80211_hw *hw,
557+
struct ieee80211_vif *vif,
558+
struct ieee80211_sta *sta,
559+
struct ieee80211_key_conf *key,
560+
void *data),
561+
void *iter_data)
562+
{
563+
struct ieee80211_local *local = hw_to_local(hw);
564+
struct ieee80211_key *key;
565+
struct ieee80211_sub_if_data *sdata;
566+
567+
ASSERT_RTNL();
568+
569+
mutex_lock(&local->key_mtx);
570+
if (vif) {
571+
sdata = vif_to_sdata(vif);
572+
list_for_each_entry(key, &sdata->key_list, list)
573+
iter(hw, &sdata->vif,
574+
key->sta ? &key->sta->sta : NULL,
575+
&key->conf, iter_data);
576+
} else {
577+
list_for_each_entry(sdata, &local->interfaces, list)
578+
list_for_each_entry(key, &sdata->key_list, list)
579+
iter(hw, &sdata->vif,
580+
key->sta ? &key->sta->sta : NULL,
581+
&key->conf, iter_data);
582+
}
583+
mutex_unlock(&local->key_mtx);
584+
}
585+
EXPORT_SYMBOL(ieee80211_iter_keys);
586+
554587
void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata)
555588
{
556589
struct ieee80211_key *key;

0 commit comments

Comments
 (0)