From patchwork Tue May 26 17:18:17 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: 218500 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.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 B4892C433DF for ; Tue, 26 May 2020 17:19:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D7CA207FB for ; Tue, 26 May 2020 17:19:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="B+Gpilbk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388997AbgEZRTI (ORCPT ); Tue, 26 May 2020 13:19:08 -0400 Received: from mail-bn8nam11on2083.outbound.protection.outlook.com ([40.107.236.83]:48578 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388898AbgEZRTB (ORCPT ); Tue, 26 May 2020 13:19:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eq++fMwcJ7YPJTbGcz/FRaXrhFJ/xXLQJnTmMymXJGvSc89Xoj2nxsjX8Ffm86b726EfxvoKuGhgt+wTm9Rr2mt249A0gcSLfrQqtoj1Y/ZB33TgTit8w3qrTUKseoeQYf6sFEzH/VYhxhPFU+aEGKkC/bz/iGzjCWYjK3eTrXzZxfvoeodqUCIAsrIQxeBu7iMkFeBFsKA5TBKig6oFv+us+es2dZJEm/klkAzJtDvwC8TdOVZu7CiTf+fn0+2ObnD1KRM8W8skw6MOR18q2qCbp0bXkB4WqqNJzY88oYzuCA3B+v6nBPbaW2GxQ+zefwgsPfv8KtHse/7xVUzcvw== 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=wXGHy+DOkIwG3kemaOa8KHPH2RZ2MpmCkltH0RA9COE=; b=FVGVyJ6eNnxBbHRepdirCKVN1mcpfHvMLjZSPUTjIWorlNQ6ynZFqHjwq2WwbdkBXeMkO3Gqou+2BIhqHxZiJiKrW1nZQYT1k+vAcqOr0T4/ku/IOM5DugyY5PWocP5XlLrhAjqIySwZbLq1iE7MVUfTisAWc8LZh7xFxEUg58ckHm5wCbEFJx9+ayStl6pMBy8xzKGJvUVSSRzSPLQeSfb5s4gA3vbrY+XCprXzKNKEoXcQpddpt3lODoSdvFunveIiMuwyYelKIRfjf3sIXxd7k1BB/ws0+FwdcuWk2g4tubbTXagS2/aMtBwkyVcPLwrO3CKLjsyturphEU2N0w== 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=wXGHy+DOkIwG3kemaOa8KHPH2RZ2MpmCkltH0RA9COE=; b=B+GpilbkkULrsxzj5IRbHwhjJDGzl+GBX9d9vG1lnlfnObiXagfPWYqP6hu+MH7kpMq7dVQyk0PLIvQp1lDmHZvGPZp0RF9Vzra9ogGPdyTclxDVGBc3bv6SNplnhSk68m2wEWJn2NdxX/P40NzWRhkmIb6tg7fEsYNT1JrbSSU= Authentication-Results: driverdev.osuosl.org; dkim=none (message not signed) header.d=none; driverdev.osuosl.org; dmarc=none action=none header.from=silabs.com; Received: from SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) by SN6PR11MB2750.namprd11.prod.outlook.com (2603:10b6:805:54::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.25; Tue, 26 May 2020 17:18:50 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::c504:2d66:a8f7:2336]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::c504:2d66:a8f7:2336%7]) with mapi id 15.20.3021.029; Tue, 26 May 2020 17:18:50 +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 06/10] staging: wfx: split wfx_get_ps_timeout() from wfx_update_pm() Date: Tue, 26 May 2020 19:18:17 +0200 Message-Id: <20200526171821.934581-7-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526171821.934581-1-Jerome.Pouiller@silabs.com> References: <20200526171821.934581-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: PR1PR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:102::20) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.home (2a01:e35:2435:66a0:544b:f17b:7ae8:fb7) by PR1PR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:102::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.17 via Frontend Transport; Tue, 26 May 2020 17:18:49 +0000 X-Mailer: git-send-email 2.26.2 X-Originating-IP: [2a01:e35:2435:66a0:544b:f17b:7ae8:fb7] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 783d39ca-549f-4436-f0a8-08d80198db9a X-MS-TrafficTypeDiagnostic: SN6PR11MB2750: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:935; X-Forefront-PRVS: 041517DFAB X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B4f6ysuaScRbETCTzEAHlgSWdKMdgX1UVcI6ha2y9XkXi9hyD0JHXuxizEXRibTLWcGga7K6TS0tgzxZ/BZsUnsgU9lyH9iSKdn5xmg2m16FogdL+DVF01vTwPQpKp0SUKuo2kMpX6EeQFG4VhEAwz49q4t41ePZvZDghvjoA4kyn7YDMSYpul4wLCZ6ClVtBCZ4FuA1jrjP3V4V9ns+QTXMJM7/06kEC8c173jZ5v1SCs+5f0/NT3d0T35zoSO5QrMfCCXgupTGijbHZ/9EVTthkkbGUOFLy0mngkAJjiSAuBMx6RRMkDN/TSPDvwcdVuH8TWR+Ik4qpYvTR8TF5g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB2718.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(396003)(376002)(366004)(39860400002)(136003)(346002)(4326008)(6512007)(316002)(8676002)(8936002)(2616005)(6486002)(2906002)(107886003)(1076003)(86362001)(6666004)(186003)(16526019)(5660300002)(66574014)(36756003)(54906003)(66556008)(478600001)(8886007)(6506007)(66946007)(66476007)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: /ZZ59/K/2AV8Nm6I65rxVU9T6b130UO4lQJOOWcEpeU29nK7HqQrIW7K0g3OyFYuZKl15ncebK8omLWLIW5+4yJpC9vZ2yO3ZRfNluT0ZtXFnbvwpLXT1maSFWv6Qnyavur31qgSY7qaVxOhEJFoPpUEbqowtPDuSBUVoYAR5gzF01R0v+ttDFZcK0MbhuIUILVMW+Jpnk2G6G4mmJ5EFErWfbgePMEFZBFfM/JIQSvfH6y4hMsd/tzFtGnsshe7jmUTEx+ZFT5TlhWZe1sZ5yb6AD+xAe/19js6RaDw10jOr2lIpPU4/vveGkX04MCdnIgQzwcrrUuhsln0MtO7xNYKoDGolIpewN15uORX+g6GQyKkEipH5QOl5ht4ObPb66TQq6475PIxqgbwyO4Ps5VLclgbzuzhtu4y6TTySM2x1oIwxo8gd387j7YFJAJQ8mu7yltgGh/nCVo1xgOAH/008sKQDmOMLbemAdlKB4CUjEaoLzjbzmMCNdzXp8BZNsuSpL+0sHbdmrOmkK/6RAeYhUDPa4gu8PpagK6wSBE= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 783d39ca-549f-4436-f0a8-08d80198db9a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 May 2020 17:18:50.5265 (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: MkErhpNs69lg1cd2oxQCgctMBsfDJzgUqE/eg9cSPKA450ctqfLK9dxpKkGUFtnk0HOq9DYeFm0z6wXWGY6rIw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB2750 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller In the next commit, we will have to compute the PS timeout without changing the power save status of the device. This patch introduces wfx_get_ps_timeout() for that job and make wfx_update_pm() relies on it. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/sta.c | 49 +++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index d0ab0b8dc404e..12e8a5b638f11 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -200,36 +200,49 @@ void wfx_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, mutex_unlock(&wdev->conf_mutex); } -static int wfx_update_pm(struct wfx_vif *wvif) +int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps) { - struct ieee80211_conf *conf = &wvif->wdev->hw->conf; - bool ps = wvif->vif->bss_conf.ps; - int ps_timeout = conf->dynamic_ps_timeout; struct ieee80211_channel *chan0 = NULL, *chan1 = NULL; + struct ieee80211_conf *conf = &wvif->wdev->hw->conf; - WARN_ON(conf->dynamic_ps_timeout < 0); - if (!wvif->vif->bss_conf.assoc) - return 0; - if (!ps) - ps_timeout = 0; - if (wvif->uapsd_mask) - ps_timeout = 0; - - // Kernel disable powersave when an AP is in use. In contrary, it is - // absolutely necessary to enable legacy powersave for WF200 if channels - // are differents. + WARN(!wvif->vif->bss_conf.assoc && enable_ps, + "enable_ps is reliable only if associated"); if (wdev_to_wvif(wvif->wdev, 0)) chan0 = wdev_to_wvif(wvif->wdev, 0)->vif->bss_conf.chandef.chan; if (wdev_to_wvif(wvif->wdev, 1)) chan1 = wdev_to_wvif(wvif->wdev, 1)->vif->bss_conf.chandef.chan; if (chan0 && chan1 && chan0->hw_value != chan1->hw_value && wvif->vif->type != NL80211_IFTYPE_AP) { - ps = true; + // It is necessary to enable powersave if channels + // are differents. + if (enable_ps) + *enable_ps = true; if (wvif->bss_not_support_ps_poll) - ps_timeout = 30; + return 30; else - ps_timeout = 0; + return 0; } + if (enable_ps) + *enable_ps = wvif->vif->bss_conf.ps; + if (wvif->vif->bss_conf.assoc && wvif->vif->bss_conf.ps) + return conf->dynamic_ps_timeout; + else + return -1; +} + +int wfx_update_pm(struct wfx_vif *wvif) +{ + int ps_timeout; + bool ps; + + if (!wvif->vif->bss_conf.assoc) + return 0; + ps_timeout = wfx_get_ps_timeout(wvif, &ps); + if (!ps) + ps_timeout = 0; + WARN_ON(ps_timeout < 0); + if (wvif->uapsd_mask) + ps_timeout = 0; if (!wait_for_completion_timeout(&wvif->set_pm_mode_complete, TU_TO_JIFFIES(512)))