From patchwork Tue Dec 2 18:11:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emmanuel Grumbach X-Patchwork-Id: 5422491 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1902B9F319 for ; Tue, 2 Dec 2014 18:11:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2819220253 for ; Tue, 2 Dec 2014 18:11:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 34B77202F2 for ; Tue, 2 Dec 2014 18:11:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932763AbaLBSLm (ORCPT ); Tue, 2 Dec 2014 13:11:42 -0500 Received: from mail-wg0-f49.google.com ([74.125.82.49]:36924 "EHLO mail-wg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932756AbaLBSLk (ORCPT ); Tue, 2 Dec 2014 13:11:40 -0500 Received: by mail-wg0-f49.google.com with SMTP id n12so9540745wgh.36 for ; Tue, 02 Dec 2014 10:11:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Oip00RxW0vE6vvP9V2MXM6zymwQ1qPgbo9DvI4PvA00=; b=a2VLd5YLiQZtCGmU5Pb75heLgGOSyt6LNYG0Si+TbKpezFJoWmGD8gpNz7q9Et4LEF UAtKgc5HOZWfkh52mjrTsFVGIj9jszz5jMx/hDoV0HI0uhkNS1emfoKPzXOB9FGwA3bh xCGlBNYlSvCi1A8M02h315t920Emmced8IXq8RjwbY7MiUyDzygUDzVGs9XvP1AUpOGj RAeoFZP8QmFJYLdX3ToVyVgYyoGNbjIeBw+NDa5Utl1bzAzbnolQAOJpavZLyFFQCtC+ peJLEvQvmPp7bRl9zQu4cySAnIjFse8YGyEKExrKeOJ6ikbS9KjgBw6nagwLzJJIG6cK EceA== X-Received: by 10.180.11.140 with SMTP id q12mr7259633wib.45.1417543896836; Tue, 02 Dec 2014 10:11:36 -0800 (PST) Received: from localhost.localdomain (46-116-157-79.bb.netvision.net.il. [46.116.157.79]) by mx.google.com with ESMTPSA id j2sm32914384wjs.28.2014.12.02.10.11.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Dec 2014 10:11:36 -0800 (PST) From: Emmanuel Grumbach To: linux-wireless@vger.kernel.org Cc: Luciano Coelho , Emmanuel Grumbach Subject: [PATCH 10/26] iwlwifi: mvm: add SSID match information for net-detect Date: Tue, 2 Dec 2014 20:11:01 +0200 Message-Id: <1417543877-24193-10-git-send-email-egrumbach@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <0BA3FCBA62E2DC44AF3030971E174FB31B5A7D27@hasmsx107.ger.corp.intel.com> References: <0BA3FCBA62E2DC44AF3030971E174FB31B5A7D27@hasmsx107.ger.corp.intel.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Luciano Coelho Add SSID information to the net-detect indication to userspace. Fetch the matched profiles from the firmware in order to find the correct SSIDs in the profiles that matched. Since the net-detect information is stored in cfg80211, and in theory it could change while we are waking up and reading the matched profiles, we need to save it when we enter D3 so it is available during resume. Signed-off-by: Luciano Coelho Reviewed-by: Johannes Berg Signed-off-by: Emmanuel Grumbach --- drivers/net/wireless/iwlwifi/mvm/d3.c | 71 +++++++++++++++++++++++++++++++--- drivers/net/wireless/iwlwifi/mvm/mvm.h | 2 + 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/mvm/d3.c b/drivers/net/wireless/iwlwifi/mvm/d3.c index c7297c5..c20d8de 100644 --- a/drivers/net/wireless/iwlwifi/mvm/d3.c +++ b/drivers/net/wireless/iwlwifi/mvm/d3.c @@ -979,8 +979,30 @@ iwl_mvm_netdetect_config(struct iwl_mvm *mvm, return ret; ret = iwl_mvm_scan_offload_start(mvm, vif, nd_config, &mvm->nd_ies); + if (ret) + return ret; - return ret; + if (WARN_ON(mvm->nd_match_sets)) + return -EBUSY; + + /* save the sched scan matchsets for later reporting */ + if (nd_config->n_match_sets) { + mvm->nd_match_sets = kmemdup(nd_config->match_sets, + sizeof(*nd_config->match_sets) * + nd_config->n_match_sets, + GFP_KERNEL); + if (mvm->nd_match_sets) + mvm->n_nd_match_sets = nd_config->n_match_sets; + } + + return 0; +} + +static void iwl_mvm_free_nd(struct iwl_mvm *mvm) +{ + kfree(mvm->nd_match_sets); + mvm->nd_match_sets = NULL; + mvm->n_nd_match_sets = 0; } static int __iwl_mvm_suspend(struct ieee80211_hw *hw, @@ -1094,8 +1116,10 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw, iwl_trans_d3_suspend(mvm->trans, test); out: - if (ret < 0) + if (ret < 0) { ieee80211_restart_hw(mvm->hw); + iwl_mvm_free_nd(mvm); + } out_noreset: mutex_unlock(&mvm->mutex); @@ -1653,14 +1677,15 @@ out_free_resp: static void iwl_mvm_query_netdetect_reasons(struct iwl_mvm *mvm, struct ieee80211_vif *vif) { - struct cfg80211_wowlan_nd_info net_detect = {}; + struct cfg80211_wowlan_nd_info *net_detect = NULL; struct cfg80211_wowlan_wakeup wakeup = { .pattern_idx = -1, }; struct cfg80211_wowlan_wakeup *wakeup_report = &wakeup; struct iwl_wowlan_status *fw_status; - u32 matched_profiles; + unsigned long matched_profiles; u32 reasons = 0; + int i, n_matches; fw_status = iwl_mvm_get_wakeup_status(mvm, vif); if (!IS_ERR_OR_NULL(fw_status)) @@ -1678,10 +1703,46 @@ static void iwl_mvm_query_netdetect_reasons(struct iwl_mvm *mvm, goto out; } - wakeup.net_detect = &net_detect; + if (mvm->n_nd_match_sets) { + n_matches = hweight_long(matched_profiles); + } else { + IWL_ERR(mvm, "no net detect match information available\n"); + n_matches = 0; + } + + net_detect = kzalloc(sizeof(*net_detect) + + (n_matches * sizeof(net_detect->matches[0])), + GFP_KERNEL); + if (!net_detect || !n_matches) + goto out_report_nd; + + for_each_set_bit(i, &matched_profiles, mvm->n_nd_match_sets) { + struct cfg80211_wowlan_nd_match *match; + + match = kzalloc(sizeof(*match), GFP_KERNEL); + if (!match) + goto out_report_nd; + + match->ssid.ssid_len = mvm->nd_match_sets[i].ssid.ssid_len; + memcpy(match->ssid.ssid, mvm->nd_match_sets[i].ssid.ssid, + match->ssid.ssid_len); + + net_detect->matches[net_detect->n_matches++] = match; + } + +out_report_nd: + wakeup.net_detect = net_detect; out: + iwl_mvm_free_nd(mvm); + mutex_unlock(&mvm->mutex); ieee80211_report_wowlan_wakeup(vif, wakeup_report, GFP_KERNEL); + + if (net_detect) { + for (i = 0; i < net_detect->n_matches; i++) + kfree(net_detect->matches[i]); + kfree(net_detect); + } } static void iwl_mvm_read_d3_sram(struct iwl_mvm *mvm) diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h index 09d4833..d69cc86 100644 --- a/drivers/net/wireless/iwlwifi/mvm/mvm.h +++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h @@ -685,6 +685,8 @@ struct iwl_mvm { /* sched scan settings for net detect */ struct cfg80211_sched_scan_request *nd_config; struct ieee80211_scan_ies nd_ies; + struct cfg80211_match_set *nd_match_sets; + int n_nd_match_sets; bool net_detect; #ifdef CONFIG_IWLWIFI_DEBUGFS u32 d3_wake_sysassert; /* must be u32 for debugfs_create_bool */