From patchwork Mon Apr 20 16:03:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 1273539 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=silabs.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-silabs-onmicrosoft-com header.b=jqKRLVgf; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 495WjC6rX6z9sSw for ; Tue, 21 Apr 2020 02:04:15 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729516AbgDTQEO (ORCPT ); Mon, 20 Apr 2020 12:04:14 -0400 Received: from mail-bn8nam11on2081.outbound.protection.outlook.com ([40.107.236.81]:58834 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729560AbgDTQEM (ORCPT ); Mon, 20 Apr 2020 12:04:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RZszcZIIx8I2QkUkcwoySS0mENpMkMTX5m5+YdfMmOFo3AlNNakNlxLYql1u9EXxAcuJnPHoNvyhtWiOMkgvrnqBYnJoJ8i6XfGON/56CK82TozKHb45c9+LhK1d939xTm55ZqsKPUwFj4yacptkA6vBxAGAAa7xYHfybTzGcDnUsCTbBMIdbyPpTzJGQNEeEQ0diyTUJ5JXHsx8tYtvoI6TffMoeZ3/eR6uzMtON4dP3B/V4nARnLaMfiFtKFnDjkjoC77MhbPUF93HAHXUC/oWKL+rR7YxlduZLgcaXFkXxy1SmHy2aRjxLf+G0ExVdXCQdVxO7hbNVo5GZl/cjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zgj9KciY36gDdOd6LfRP0caBqffdEytAjzLmH8AipTI=; b=R5Wl7eeG5BvyeCplluJF4aydBqwfTUzJU9BF+RXiLc08Wizf4ye7rlxCSUTsN9aJyHwv5CxstsOIToM1Po3hZeKiU/Plcucgjru0zaiKEtt0KwFyTITMJB+p2/MnW/XbFAslUB+IyHk1yJcJ9mbRSm/2dSDp/X61SBr4pUwUYGWOBEOD29zPHITCSPSMd+8S6QEwJoZWUoSvHaFG9YVEJRkrhZj2XtcihhveyHItVCQ3TvNhX857rJVmHun9bQP+aKqSzlrasjx0T8BHBxgvqZ4wKDPqQAAZXHKFjueaV6ZpREgVNCLjB07ws6IBEq8Mvs/CPMXMHX30gY8B2yocNw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zgj9KciY36gDdOd6LfRP0caBqffdEytAjzLmH8AipTI=; b=jqKRLVgfh1kwAADaqFiYh3rJ3H1snw4NA/wvDmKYqyPoV/hOjpWnUZOSGvf/S9Z1AWxn1hWERicQtqBd1s1yCdALaoy440odSisCiBWdRvkO9jjAbUTYaIF7gIv0cwT5/lZj6dBpdgad7ftdtc62Sm1Ak24wgcEQ2xqE+URodwM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; Received: from MWHPR11MB1775.namprd11.prod.outlook.com (2603:10b6:300:10e::14) by MWHPR11MB1792.namprd11.prod.outlook.com (2603:10b6:300:10b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.29; Mon, 20 Apr 2020 16:03:52 +0000 Received: from MWHPR11MB1775.namprd11.prod.outlook.com ([fe80::81d5:b62b:3770:ffbe]) by MWHPR11MB1775.namprd11.prod.outlook.com ([fe80::81d5:b62b:3770:ffbe%10]) with mapi id 15.20.2921.030; Mon, 20 Apr 2020 16:03:52 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH 11/16] staging: wfx: keys are kept during whole firmware life Date: Mon, 20 Apr 2020 18:03:06 +0200 Message-Id: <20200420160311.57323-12-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200420160311.57323-1-Jerome.Pouiller@silabs.com> References: <20200420160311.57323-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: DM6PR07CA0065.namprd07.prod.outlook.com (2603:10b6:5:74::42) To MWHPR11MB1775.namprd11.prod.outlook.com (2603:10b6:300:10e::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (2a01:e35:2435:66a0:544b:f17b:7ae8:fb7) by DM6PR07CA0065.namprd07.prod.outlook.com (2603:10b6:5:74::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.26 via Frontend Transport; Mon, 20 Apr 2020 16:03:50 +0000 X-Mailer: git-send-email 2.26.1 X-Originating-IP: [2a01:e35:2435:66a0:544b:f17b:7ae8:fb7] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a9e3429-8d3a-43ad-3da0-08d7e5446bc2 X-MS-TrafficTypeDiagnostic: MWHPR11MB1792: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-Forefront-PRVS: 03793408BA X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR11MB1775.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(10009020)(39850400004)(346002)(376002)(366004)(396003)(136003)(66476007)(66556008)(186003)(66946007)(4326008)(86362001)(16526019)(107886003)(6666004)(81156014)(7696005)(478600001)(52116002)(8676002)(66574012)(54906003)(316002)(6486002)(1076003)(2616005)(36756003)(8936002)(5660300002)(2906002);DIR:OUT;SFP:1101; Received-SPF: None (protection.outlook.com: silabs.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fE+W/bdx/6e5gFmJ+kiJuDM6iLKojK7xKo6WC6g3xVyswAiz7KNLx6DgNhWjCLgKl4BEnV3gPT/dXMKuBQ3T67XtXcNlztgWxkOdzNG3Ku1sfIwkEmJg6zQJRzDcVNL3FbtwXDJRuYZBEZC40FPSq6JiDp0GzywSQCg/r4b9oddiT4vBa2w7PLMiKcU35mdW3Y0PnrANY+6yMRXiwXffaDDRopV3gBH5TD7iGUU/gj5qu9xsXagd2hOtBSc7/lMXuQr+hTz7JO09UYgvZfocyZadRdwZ4/EuCIc+9+jTS9fI9y1Ko3F8n5goT5aZppE61oUnCyjFvKfHB0K/WwfXkvSezSgoABFtIjROIp4uOx9XkdNDgbXowuUmL/Ek7QvbIQczf+hqpK5Nz/K6vsGfJ1kYzDQ8IwkqrKOFe/i97MwVvEbOL7QcpQmB+/ewDd3Q X-MS-Exchange-AntiSpam-MessageData: jPZPQoIXxktmsib8ZOEnUutIIWODlfRtu3bcx6HqrR7xwkG/KbuKlB4WwEfA78Z6nxbbXZRHd3+lmaskg6KkStyhP24GELJWvv2oAEJt5vdSgeRYOuAnOl97Zo6TrjLDZWf7egqsPAtcSO99efWJyAJHuY7//40PrTwzBO77AssHnmAoWEKKHDOYOHk+z70v/25JeQglM5lO8tbQzNxAMLcphIvJHuKk/prwafgju9HhRoqGVMxQeZbJmUozwWhblDB95rMR/oqT9oKPXBz4LqN6WyEUBok9uJw9Y9brz37ROfvvnPok3vfvRQFwqlV+tqIUJX5lt2QzhanWxSABzWSX6XZw0eVpr1xDFQYg9KdUA9txlOqiu8qb1M3dqmOgnhe3JWan8O8HwTgI9Rx4uWR5snWtg8zPKetkiayLr/aPgJvEumyvp/PQPI9ASEftGsFw230F0HI/YJwuc+WTgdIlarGQ6IStq01/dmeH2BpaRoQ3XZ0L7rDJ71a1JLYLhRzhhXcbiUOyXHVkXU6McmPKuGdL8n0gPoSoHLO++8+kSEshsV6pRkgRfWqsRlSb4QxOP38Kxt7tdFQOH2HJIdMwqgs6qP/5yJgSWLvI981lXTSdn/M7ndMLxbVLZg+mrmqbWlt89sHEUiPn9woSVfIPcy3w1aOSFoyr2FciLNtPZhG3n3tUTSybp/m/49VZkR+uSrl0X/R4oX7md93k/QoUL+ixAHpSyYc/DXtmumzkL9po0xpDV2MrcLZ8cZ0nEkuG+wIfQcjD5rKuKj/Wc4ABdmCFGs+HWiDiZ9auy9ohEz7G08GFTY7lVAQq6EVei7iBbAjKInYG82hxjx71CE45Bkq6T8Klf+TYuhUXCbQ= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a9e3429-8d3a-43ad-3da0-08d7e5446bc2 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2020 16:03:52.8101 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OVjOdoCVMVxJ+cOEwa8XPOT2YZ1R9yX8V05vp8AgCKIUAjGoQcURF5+TfpsChJccptXOTIg19Y7atih95JsP5w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1792 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller Keys sent to the firmware are never reset. So, it is not necessary to re-upload them after hif_reset(). Thus, it is no more necessary to keep a copy of the keys in struct wfx_dev. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/key.c | 58 ++++++++++++++------------------------- drivers/staging/wfx/key.h | 1 - drivers/staging/wfx/sta.c | 4 --- drivers/staging/wfx/wfx.h | 1 - 4 files changed, 20 insertions(+), 44 deletions(-) diff --git a/drivers/staging/wfx/key.c b/drivers/staging/wfx/key.c index e3853cbf431c..ceb57cbdfefd 100644 --- a/drivers/staging/wfx/key.c +++ b/drivers/staging/wfx/key.c @@ -21,14 +21,12 @@ static int wfx_alloc_key(struct wfx_dev *wdev) return -1; wdev->key_map |= BIT(idx); - wdev->keys[idx].entry_index = idx; return idx; } static void wfx_free_key(struct wfx_dev *wdev, int idx) { WARN(!(wdev->key_map & BIT(idx)), "inconsistent key allocation"); - memset(&wdev->keys[idx], 0, sizeof(wdev->keys[idx])); wdev->key_map &= ~BIT(idx); } @@ -160,7 +158,7 @@ static int wfx_add_key(struct wfx_vif *wvif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key) { int ret; - struct hif_req_add_key *k; + struct hif_req_add_key k = { }; struct ieee80211_key_seq seq; struct wfx_dev *wdev = wvif->wdev; int idx = wfx_alloc_key(wvif->wdev); @@ -170,44 +168,44 @@ static int wfx_add_key(struct wfx_vif *wvif, struct ieee80211_sta *sta, ieee80211_get_key_rx_seq(key, 0, &seq); if (idx < 0) return -EINVAL; - k = &wdev->keys[idx]; - k->int_id = wvif->id; + k.int_id = wvif->id; + k.entry_index = idx; if (key->cipher == WLAN_CIPHER_SUITE_WEP40 || key->cipher == WLAN_CIPHER_SUITE_WEP104) { if (pairwise) - k->type = fill_wep_pair(&k->key.wep_pairwise_key, key, - sta->addr); + k.type = fill_wep_pair(&k.key.wep_pairwise_key, key, + sta->addr); else - k->type = fill_wep_group(&k->key.wep_group_key, key); + k.type = fill_wep_group(&k.key.wep_group_key, key); } else if (key->cipher == WLAN_CIPHER_SUITE_TKIP) { if (pairwise) - k->type = fill_tkip_pair(&k->key.tkip_pairwise_key, key, - sta->addr); + k.type = fill_tkip_pair(&k.key.tkip_pairwise_key, key, + sta->addr); else - k->type = fill_tkip_group(&k->key.tkip_group_key, key, - &seq, wvif->vif->type); + k.type = fill_tkip_group(&k.key.tkip_group_key, key, + &seq, wvif->vif->type); } else if (key->cipher == WLAN_CIPHER_SUITE_CCMP) { if (pairwise) - k->type = fill_ccmp_pair(&k->key.aes_pairwise_key, key, - sta->addr); + k.type = fill_ccmp_pair(&k.key.aes_pairwise_key, key, + sta->addr); else - k->type = fill_ccmp_group(&k->key.aes_group_key, key, - &seq); + k.type = fill_ccmp_group(&k.key.aes_group_key, key, + &seq); } else if (key->cipher == WLAN_CIPHER_SUITE_SMS4) { if (pairwise) - k->type = fill_sms4_pair(&k->key.wapi_pairwise_key, key, - sta->addr); + k.type = fill_sms4_pair(&k.key.wapi_pairwise_key, key, + sta->addr); else - k->type = fill_sms4_group(&k->key.wapi_group_key, key); + k.type = fill_sms4_group(&k.key.wapi_group_key, key); } else if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC) { - k->type = fill_aes_cmac_group(&k->key.igtk_group_key, key, - &seq); + k.type = fill_aes_cmac_group(&k.key.igtk_group_key, key, + &seq); } else { dev_warn(wdev->dev, "unsupported key type %d\n", key->cipher); wfx_free_key(wdev, idx); return -EOPNOTSUPP; } - ret = hif_add_key(wdev, k); + ret = hif_add_key(wdev, &k); if (ret) { wfx_free_key(wdev, idx); return -EOPNOTSUPP; @@ -241,19 +239,3 @@ int wfx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, return ret; } -int wfx_upload_keys(struct wfx_vif *wvif) -{ - int i; - struct hif_req_add_key *key; - struct wfx_dev *wdev = wvif->wdev; - - for (i = 0; i < ARRAY_SIZE(wdev->keys); i++) { - if (wdev->key_map & BIT(i)) { - key = &wdev->keys[i]; - if (key->int_id == wvif->id) - hif_add_key(wdev, key); - } - } - return 0; -} - diff --git a/drivers/staging/wfx/key.h b/drivers/staging/wfx/key.h index 2c334f9fb2a8..ff31fc9c565a 100644 --- a/drivers/staging/wfx/key.h +++ b/drivers/staging/wfx/key.h @@ -16,6 +16,5 @@ struct wfx_vif; int wfx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key); -int wfx_upload_keys(struct wfx_vif *wvif); #endif /* WFX_STA_H */ diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 876952f39fc9..56cb6fff4a06 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -378,9 +378,6 @@ static void wfx_do_join(struct wfx_vif *wvif) else wvif->state = WFX_STATE_PRE_STA; - /* Upload keys */ - wfx_upload_keys(wvif); - /* Due to beacon filtering it is possible that the * AP's beacon is not known for the mac80211 stack. * Disable filtering temporary to make sure the stack @@ -457,7 +454,6 @@ int wfx_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv; - wfx_upload_keys(wvif); wvif->state = WFX_STATE_AP; wfx_upload_ap_templates(wvif); hif_start(wvif, &vif->bss_conf, wvif->channel); diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 0fa88de64907..354a62394db0 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -56,7 +56,6 @@ struct wfx_dev { atomic_t packet_id; u32 key_map; - struct hif_req_add_key keys[MAX_KEY_ENTRIES]; struct hif_rx_stats rx_stats; struct mutex rx_stats_lock;