From patchwork Wed Jan 15 12:13:10 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: 216665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0F6FC33CB1 for ; Wed, 15 Jan 2020 12:15:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A929C207FF for ; Wed, 15 Jan 2020 12:15:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="loWejBgf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731736AbgAOMPn (ORCPT ); Wed, 15 Jan 2020 07:15:43 -0500 Received: from mail-bn7nam10on2085.outbound.protection.outlook.com ([40.107.92.85]:6101 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731575AbgAOMNk (ORCPT ); Wed, 15 Jan 2020 07:13:40 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ggxraxOI1OMjINjkuWjebk69nYB+QiBSJgycxNSC2Dt09WfW95R+0+LK4HxBUaplmx3i0zcG12rnedjtZdMP/AhQsk2pPE10baM6WP60HFixiSajeX7T7QDGMFsAAR3Kgj+HhQKgUmEFpDp36QugXLagd0rIYXOndqzowGRUsyHgyATdU3A7Ia1Sn6U/a4hzTfGquaPnAazDn3+LHqJPqz7c1OcuzMmqj+htEsecK7XjKnq1f5iXw4K2haMbEaoxZB8pqKjeriJQORiDNDPbh70kKvOQju2KGzp769SJVp6WGC8tHuw+FYujjvwNoadXPxMaPzvGldPBTvoDT2KwWQ== 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=Bwh7lWsf/cwWs0AEW/3avuQIgItjw4kHtgAkBvBt6+k=; b=L6zMtreKOzVaNQB5qFuvcLPIi3tOt5b78A79PTy34Qf33CHKsbVJIP3Fw98hSeJGYbBB1LHw73HEhN1c2AZnlrd1WDMomlp+WRwhW/rpFvEaUWzI9X2O7/B46J+40Gmb+nl43Zmw0iIH0bnKuInYSVsxN3gwU3Ay+TRXCT+qUqf5Mv+Qd0HxOZpt4dsQ47jgkjIEUctwBCORMyDoYyDxXkZrAiAaYwRjM5gmfm4NsyQ2ccmwxfROGlygwqNJUlO60Iq/ZhLR+LaMqdfdMFzTWztSMBl7JlKD75tT2E6T3CxsGCTET6B7Q74K2LqDlt7eVfB9nfkruTZd8D9PFnex/A== 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=Bwh7lWsf/cwWs0AEW/3avuQIgItjw4kHtgAkBvBt6+k=; b=loWejBgfNvra6ax5zN/EEMgefsrE0ZNNIvrTlctaAaX3gqGQl9yPwVaZ5RyDo4XQqJzKKVqzShQ3I/SKoGJLRwDH/7J4PBXhppeePqyG5P0mxbeKrJM4qCKcv+FLbvUToesElWgFNlIIlw6kltJKKo1rcBnS2VQbp7b3T/pFFpg= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (10.255.180.22) by MN2PR11MB3934.namprd11.prod.outlook.com (10.255.180.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.20; Wed, 15 Jan 2020 12:13:29 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::f46c:e5b4:2a85:f0bf]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::f46c:e5b4:2a85:f0bf%4]) with mapi id 15.20.2623.018; Wed, 15 Jan 2020 12:13:29 +0000 Received: from pc-42.silabs.com (37.71.187.125) by PR2PR09CA0009.eurprd09.prod.outlook.com (2603:10a6:101:16::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.18 via Frontend Transport; Wed, 15 Jan 2020 12:13:09 +0000 From: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= 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?SsOpcsO0bWUgUG91?= =?utf-8?q?iller?= Subject: [PATCH 46/65] staging: wfx: relocate "buffered" information to sta_priv Thread-Topic: [PATCH 46/65] staging: wfx: relocate "buffered" information to sta_priv Thread-Index: AQHVy50niFufYYhXXUi7ur01UA/VBg== Date: Wed, 15 Jan 2020 12:13:10 +0000 Message-ID: <20200115121041.10863-47-Jerome.Pouiller@silabs.com> References: <20200115121041.10863-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20200115121041.10863-1-Jerome.Pouiller@silabs.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR2PR09CA0009.eurprd09.prod.outlook.com (2603:10a6:101:16::21) To MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.25.0 x-originating-ip: [37.71.187.125] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 00a05abf-aa9a-40c5-1d03-08d799b44977 x-ms-traffictypediagnostic: MN2PR11MB3934: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 02830F0362 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(376002)(366004)(346002)(199004)(189003)(54906003)(110136005)(86362001)(956004)(107886003)(2616005)(316002)(36756003)(71200400001)(52116002)(7696005)(478600001)(8936002)(81156014)(8676002)(4326008)(81166006)(6486002)(2906002)(26005)(66946007)(16526019)(186003)(5660300002)(66574012)(1076003)(66556008)(64756008)(66446008)(6666004)(85182001)(66476007)(85202003); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3934; H:MN2PR11MB4063.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; 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: ugP1FkdkT4V8cz6cnMyIEh24Ju9StnQbwvTHfcm0lOfnYgJm7kvR99GUooFJ0SNc4vIhQYGnvdkR//dEGQFcHJLeuN2UNUIKmfqA+YmJXXJ1BkLbFA81UjfTGyPsevmPTIIMuPW4N7+Z+Za2qD7QkQtYIZPe9ErJX/Eeg0AfNh0y+hzD3IrshQzpBNPN/w9s+0Rav55zLvXjzPko/Q2nZ+4uY9sKtEK0p8OKnZV9Vviy9Z/A6Umri95hMnFZqYbi7ikeaaoPt/+kN8ylGyaiZhQeNEV+qvMDxLa9dKkFagYLV8Jg1Tb5TWL+0Dv1ieAMPOUsmYKoL42FO2WJTRVal8vAm7G+6T3CyO8GzLZXRiCh5y9v8z38klzBsv1RNBFekzdW5MBdLHpyM1wYqZiSvM0AaH7IL1lLZykIYFaYMEuWHOOaNfsEAort8Xrt17Va Content-ID: <55EF408303BCF94AAF076682E458552B@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00a05abf-aa9a-40c5-1d03-08d799b44977 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 12:13:10.3719 (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: kDcftgAokO2QqtXl6ZP5OklzBIlLLfjmqNQ002C4mxVc16ztoisKrmBPkjgEIeQLR6tH2WD3LPFNpsbmkUKtKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3934 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller It simplify the code if field buffered is hosted in the struct sta_priv instead of in the struct wfx_link_entry. More globally, struct wfx_link_entry has no real reasons to exist and should be dropped soon. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/data_tx.c | 50 ++++++++++++++++------------------- drivers/staging/wfx/data_tx.h | 4 --- drivers/staging/wfx/sta.c | 1 + drivers/staging/wfx/sta.h | 6 +++++ 4 files changed, 30 insertions(+), 31 deletions(-) diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index e669fc4485e6..9313c8f5d4d8 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -291,7 +291,6 @@ static int wfx_alloc_link_id(struct wfx_vif *wvif, const u8 *mac) entry->status = WFX_LINK_RESERVE; ether_addr_copy(entry->mac, mac); - memset(&entry->buffered, 0, WFX_MAX_TID); wfx_tx_lock(wvif->wdev); if (!schedule_work(&wvif->link_id_work)) @@ -434,6 +433,7 @@ static void wfx_tx_manage_pm(struct wfx_vif *wvif, struct ieee80211_hdr *hdr, struct ieee80211_sta *sta) { u32 mask = ~BIT(tx_priv->raw_link_id); + struct wfx_sta_priv *sta_priv; spin_lock_bh(&wvif->ps_state_lock); if (ieee80211_is_auth(hdr->frame_control)) { @@ -448,15 +448,17 @@ static void wfx_tx_manage_pm(struct wfx_vif *wvif, struct ieee80211_hdr *hdr, schedule_work(&wvif->mcast_start_work); } - if (tx_priv->raw_link_id) { + if (tx_priv->raw_link_id) wvif->link_id_db[tx_priv->raw_link_id - 1].timestamp = jiffies; - if (tx_priv->tid < WFX_MAX_TID) - wvif->link_id_db[tx_priv->raw_link_id - 1].buffered[tx_priv->tid]++; - } spin_unlock_bh(&wvif->ps_state_lock); - if (sta) + if (sta && tx_priv->tid < WFX_MAX_TID) { + sta_priv = (struct wfx_sta_priv *)&sta->drv_priv; + spin_lock_bh(&sta_priv->lock); + sta_priv->buffered[tx_priv->tid]++; ieee80211_sta_set_buffered(sta, tx_priv->tid, true); + spin_unlock_bh(&sta_priv->lock); + } } static u8 wfx_tx_get_raw_link_id(struct wfx_vif *wvif, @@ -789,31 +791,25 @@ void wfx_tx_confirm_cb(struct wfx_vif *wvif, const struct hif_cnf_tx *arg) wfx_pending_remove(wvif->wdev, skb); } -static void wfx_notify_buffered_tx(struct wfx_vif *wvif, struct sk_buff *skb, - struct hif_req_tx *req) +static void wfx_notify_buffered_tx(struct wfx_vif *wvif, struct sk_buff *skb) { + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_sta *sta; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct wfx_sta_priv *sta_priv; int tid = wfx_tx_get_tid(hdr); - int raw_link_id = req->queue_id.peer_sta_id; - u8 *buffered; - if (raw_link_id && tid < WFX_MAX_TID) { - buffered = wvif->link_id_db[raw_link_id - 1].buffered; - - spin_lock_bh(&wvif->ps_state_lock); - WARN(!buffered[tid], "inconsistent notification"); - buffered[tid]--; - spin_unlock_bh(&wvif->ps_state_lock); - - if (!buffered[tid]) { - rcu_read_lock(); - sta = ieee80211_find_sta(wvif->vif, hdr->addr1); - if (sta) - ieee80211_sta_set_buffered(sta, tid, false); - rcu_read_unlock(); - } + rcu_read_lock(); // protect sta + sta = ieee80211_find_sta(wvif->vif, hdr->addr1); + if (sta && tid < WFX_MAX_TID) { + sta_priv = (struct wfx_sta_priv *)&sta->drv_priv; + spin_lock_bh(&sta_priv->lock); + WARN(!sta_priv->buffered[tid], "inconsistent notification"); + sta_priv->buffered[tid]--; + if (!sta_priv->buffered[tid]) + ieee80211_sta_set_buffered(sta, tid, false); + spin_unlock_bh(&sta_priv->lock); } + rcu_read_unlock(); } void wfx_skb_dtor(struct wfx_dev *wdev, struct sk_buff *skb) @@ -827,7 +823,7 @@ void wfx_skb_dtor(struct wfx_dev *wdev, struct sk_buff *skb) WARN_ON(!wvif); skb_pull(skb, offset); - wfx_notify_buffered_tx(wvif, skb, req); + wfx_notify_buffered_tx(wvif, skb); wfx_tx_policy_put(wvif, req->tx_flags.retry_policy_index); ieee80211_tx_status_irqsafe(wdev->hw, skb); } diff --git a/drivers/staging/wfx/data_tx.h b/drivers/staging/wfx/data_tx.h index 54738c2e3eac..d02a7b325b27 100644 --- a/drivers/staging/wfx/data_tx.h +++ b/drivers/staging/wfx/data_tx.h @@ -14,9 +14,6 @@ #include "hif_api_cmd.h" #include "hif_api_mib.h" -// FIXME: use IEEE80211_NUM_TIDS -#define WFX_MAX_TID 8 - struct wfx_tx_priv; struct wfx_dev; struct wfx_vif; @@ -33,7 +30,6 @@ struct wfx_link_entry { enum wfx_link_status status; u8 mac[ETH_ALEN]; u8 old_mac[ETH_ALEN]; - u8 buffered[WFX_MAX_TID]; }; struct tx_policy { diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 4a44d72f0db1..aebce96dcd4a 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -572,6 +572,7 @@ int wfx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct wfx_sta_priv *sta_priv = (struct wfx_sta_priv *) &sta->drv_priv; struct wfx_link_entry *entry; + spin_lock_init(&sta_priv->lock); if (wvif->vif->type != NL80211_IFTYPE_AP) return 0; diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h index e0b54332e98a..47d94d6b8590 100644 --- a/drivers/staging/wfx/sta.h +++ b/drivers/staging/wfx/sta.h @@ -12,6 +12,9 @@ #include "hif_api_cmd.h" +// FIXME: use IEEE80211_NUM_TIDS +#define WFX_MAX_TID 8 + struct wfx_dev; struct wfx_vif; @@ -37,6 +40,9 @@ struct wfx_grp_addr_table { struct wfx_sta_priv { int link_id; int vif_id; + u8 buffered[WFX_MAX_TID]; + // Ensure atomicity of "buffered" and calls to ieee80211_sta_set_buffered() + spinlock_t lock; }; // mac80211 interface