From patchwork Tue Jul 5 14:35:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 945272 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p65EcwA6025793 for ; Tue, 5 Jul 2011 14:38:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752847Ab1GEOi4 (ORCPT ); Tue, 5 Jul 2011 10:38:56 -0400 Received: from he.sipsolutions.net ([78.46.109.217]:40866 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752259Ab1GEOi4 (ORCPT ); Tue, 5 Jul 2011 10:38:56 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1Qe6m7-0003jB-AD; Tue, 05 Jul 2011 16:38:55 +0200 Message-Id: <20110705143810.101506240@sipsolutions.net> User-Agent: quilt/0.48-1 Date: Tue, 05 Jul 2011 16:35:39 +0200 From: Johannes Berg To: John Linville Cc: linux-wireless@vger.kernel.org Subject: [PATCH 1/3] mac80211: allow driver to iterate keys References: <20110705143538.696899280@sipsolutions.net> Content-Disposition: inline; filename=006-mac80211-key-info.patch Mime-Version: 1.0 X-Mailer: Evolution 2.32.3 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 05 Jul 2011 14:38:58 +0000 (UTC) From: Johannes Berg 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 --- include/net/mac80211.h | 23 +++++++++++++++++++++++ net/mac80211/key.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/include/net/mac80211.h 2011-07-02 00:08:12.000000000 +0200 +++ b/include/net/mac80211.h 2011-07-02 00:08:13.000000000 +0200 @@ -2850,6 +2850,29 @@ void ieee80211_sta_block_awake(struct ie struct ieee80211_sta *pubsta, bool block); /** + * ieee80211_iter_keys - iterate keys programmed into the device + * @hw: pointer obtained from ieee80211_alloc_hw() + * @vif: virtual interface to iterate, may be %NULL for all + * @iter: iterator function that will be called for each key + * @iter_data: custom data to pass to the iterator function + * + * This function can be used to iterate all the keys known to + * mac80211, even those that weren't previously programmed into + * the device. This is intended for use in WoWLAN if the device + * needs reprogramming of the keys during suspend. Note that due + * to locking reasons, it is also only safe to call this at few + * spots since it must hold the RTNL and be able to sleep. + */ +void ieee80211_iter_keys(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + void (*iter)(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + struct ieee80211_key_conf *key, + void *data), + void *iter_data); + +/** * ieee80211_ap_probereq_get - retrieve a Probe Request template * @hw: pointer obtained from ieee80211_alloc_hw(). * @vif: &struct ieee80211_vif pointer from the add_interface callback. --- a/net/mac80211/key.c 2011-07-02 00:07:58.000000000 +0200 +++ b/net/mac80211/key.c 2011-07-02 00:08:13.000000000 +0200 @@ -504,6 +504,39 @@ void ieee80211_enable_keys(struct ieee80 mutex_unlock(&sdata->local->key_mtx); } +void ieee80211_iter_keys(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + void (*iter)(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + struct ieee80211_key_conf *key, + void *data), + void *iter_data) +{ + struct ieee80211_local *local = hw_to_local(hw); + struct ieee80211_key *key; + struct ieee80211_sub_if_data *sdata; + + ASSERT_RTNL(); + + mutex_lock(&local->key_mtx); + if (vif) { + sdata = vif_to_sdata(vif); + list_for_each_entry(key, &sdata->key_list, list) + iter(hw, &sdata->vif, + key->sta ? &key->sta->sta : NULL, + &key->conf, iter_data); + } else { + list_for_each_entry(sdata, &local->interfaces, list) + list_for_each_entry(key, &sdata->key_list, list) + iter(hw, &sdata->vif, + key->sta ? &key->sta->sta : NULL, + &key->conf, iter_data); + } + mutex_unlock(&local->key_mtx); +} +EXPORT_SYMBOL(ieee80211_iter_keys); + void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata) { struct ieee80211_key *key;