From patchwork Tue Dec 17 16:15:23 2019 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: 1211511 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=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; 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.b="XzR/bIzE"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47cjwN4Mbcz9sNH for ; Wed, 18 Dec 2019 03:17:40 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729325AbfLQQRj (ORCPT ); Tue, 17 Dec 2019 11:17:39 -0500 Received: from mail-bn7nam10on2081.outbound.protection.outlook.com ([40.107.92.81]:6496 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729004AbfLQQP6 (ORCPT ); Tue, 17 Dec 2019 11:15:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gC545bVdgq9SuPEUe/m8h/QniYh7FeciN3ko3gli6ZftD1IYggek7zR1p1QU0sgiYTOxrht5wEp0RGI91HKv/p7zzFl3VA9rFD0EUjPnCEzCfk6lQn+pOReeXVMTI8xmGPJTVJacNs7D0MKYf0k1XSY6qu2pNymZwiewGk8XJJ2TQJ76ih7cGuqBlY51gziGfDYs2zUujIpkhnlaRfk4YcWiFCEcaiLvpFsHV9el/NMYiaT2FxsppRpxsT2fJk7faxwj74l82zWUjXqvEGGva/tLNHCz/yb5wbh8dphYHbyEQrQR6qREGlVyIz5TU3zRqcv4GYXv0THxN7EWhkg5Xg== 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=UZ+/IhbadXELF0xffX7LphSKuGR1MBVq/x6o+jcQSlY=; b=QuL5LobGa5ABEY6xTmyPxGow4hH2Lxdg0hoFTSF3tXmHuQhkNyd4VWiGfH44ukKRJaEX65ymg4gnzblgChI39TGvmrAEP9Du8s5r3CtnnL2puv2FH8sPWJG9JJEWdDWy+DU1uGy2ZwNCuBWcGMeKO8+PtSjDEPmK6Ejm3UcFhpWm+CoysBYd97sbgAFlYHcPTlMwlQU03aIt26Xm4DK1cOCZHKRJL3XOtspwoJSp3Pv0nDZgIh3jyuITHb8ZTHTQpt/wAd9+6LJJErDSxiO+R/2MA9zvo1Or32Sx5wyWYjYoahtxeYlE7PSFAy9kH7duMV/zbKc9WQuTOO6sFrkOAg== 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=UZ+/IhbadXELF0xffX7LphSKuGR1MBVq/x6o+jcQSlY=; b=XzR/bIzEDptyAGTEdDJNxpBu1JSnRw2Y1aZ/Y5DagTMs5aHbhgOFw1A1MzXMiiQXy2hqZpOEn0FiFOB6dqDGhr40fXXEVDf9pVsfPvTthLofZm+MDUWKRIjSL1LotdPgQlzBN1ZiY2BSGILatooTzmopxM7M8+4sysfwTACFwE0= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (10.255.180.22) by MN2PR11MB4208.namprd11.prod.outlook.com (52.135.36.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2538.20; Tue, 17 Dec 2019 16:15:45 +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.2538.019; Tue, 17 Dec 2019 16:15:45 +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 v2 40/55] staging: wfx: simplify hif_set_pm() usage Thread-Topic: [PATCH v2 40/55] staging: wfx: simplify hif_set_pm() usage Thread-Index: AQHVtPUvEUamb7q6X02OnND4ftWuCw== Date: Tue, 17 Dec 2019 16:15:23 +0000 Message-ID: <20191217161318.31402-41-Jerome.Pouiller@silabs.com> References: <20191217161318.31402-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20191217161318.31402-1-Jerome.Pouiller@silabs.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR0P264CA0174.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1c::18) 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.24.0 x-originating-ip: [37.71.187.125] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 88c2fab3-f616-4839-7186-08d7830c51b0 x-ms-traffictypediagnostic: MN2PR11MB4208: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 02543CD7CD x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39850400004)(396003)(366004)(136003)(376002)(346002)(199004)(189003)(5660300002)(316002)(6506007)(85182001)(478600001)(71200400001)(2906002)(36756003)(186003)(26005)(81166006)(54906003)(1076003)(110136005)(66574012)(4326008)(8676002)(86362001)(6486002)(6666004)(52116002)(6512007)(64756008)(85202003)(66946007)(66476007)(66446008)(66556008)(8936002)(107886003)(2616005)(81156014); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4208; 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: MwzzO59ORnjWkAZwlrN2PioEJY8SkxeScTYJCHeOuHHdLtPgxF34eAr7MBcg6lhNNDD+/YlHkuq6y3c+fx9X1IEuXiqPKdIklsOlZK8aCYyqcTJrVJPxgikiyry/s/kh0ZPTBKWUvi5HHCPleWLz1JwBnZNMKNHzijMClWeAsZrB339p2RSjZt1tvaoftba7KUf/ggEXZH4t7EN8tx1wZ++acGu1lgInsewmDFUXjCgvPM/spdag0Ry2r33aloSZQHn0qajRMTY4P9d7sgGYY38/nAMgXP3LBllMvuMxVBqUbPXiBaFeE6FRIXN5cK3WGB6ZnKR2SwOR0b4zfgxiCPLlmFIat+uoTy+Gznc5W8aGtsOickxB8WvCWJcKBqHEsZ4xt5LYVawZHKORB3VmNK+xCl8vrsUUIV/ScwQs69AdPEZIf5qgkZYZ8oMFQDMv Content-ID: <6F331650ADDD674097206FC493A9F806@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88c2fab3-f616-4839-7186-08d7830c51b0 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2019 16:15:23.1447 (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: xiidfCcFSLF3x8pNe6y5CuqQ9JplV0Fx9UbOeDmr0r4EPHgUEE89fC+8nerx4E75bxPCoB6lJFowW75aJAupRw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4208 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller The struct hif_req_set_pm_mode comes from hardware API. It is not intended to be manipulated in upper layers of the driver. So, this patch relocate the handling of this struct to hif_set_pm() (the low level function). Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/hif_tx.c | 10 ++++++++-- drivers/staging/wfx/hif_tx.h | 2 +- drivers/staging/wfx/sta.c | 25 +++++++++---------------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c index 6fb98ddbc0e2..9cbf9d916f5f 100644 --- a/drivers/staging/wfx/hif_tx.c +++ b/drivers/staging/wfx/hif_tx.c @@ -360,13 +360,19 @@ int hif_set_edca_queue_params(struct wfx_vif *wvif, return ret; } -int hif_set_pm(struct wfx_vif *wvif, const struct hif_req_set_pm_mode *arg) +int hif_set_pm(struct wfx_vif *wvif, bool ps, int dynamic_ps_timeout) { int ret; struct hif_msg *hif; struct hif_req_set_pm_mode *body = wfx_alloc_hif(sizeof(*body), &hif); - memcpy(body, arg, sizeof(*body)); + if (ps) { + body->pm_mode.enter_psm = 1; + // Firmware does not support more than 128ms + body->fast_psm_idle_period = min(dynamic_ps_timeout * 2, 255); + if (body->fast_psm_idle_period) + body->pm_mode.fast_psm = 1; + } wfx_fill_header(hif, wvif->id, HIF_REQ_ID_SET_PM_MODE, sizeof(*body)); ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); kfree(hif); diff --git a/drivers/staging/wfx/hif_tx.h b/drivers/staging/wfx/hif_tx.h index f61ae7b0d41c..bb5860ee6542 100644 --- a/drivers/staging/wfx/hif_tx.h +++ b/drivers/staging/wfx/hif_tx.h @@ -47,7 +47,7 @@ int hif_write_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, int hif_scan(struct wfx_vif *wvif, const struct wfx_scan_params *arg); int hif_stop_scan(struct wfx_vif *wvif); int hif_join(struct wfx_vif *wvif, const struct hif_req_join *arg); -int hif_set_pm(struct wfx_vif *wvif, const struct hif_req_set_pm_mode *arg); +int hif_set_pm(struct wfx_vif *wvif, bool ps, int dynamic_ps_timeout); int hif_set_bss_params(struct wfx_vif *wvif, const struct hif_req_set_bss_params *arg); int hif_add_key(struct wfx_dev *wdev, const struct hif_req_add_key *arg); diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 9eca35d91ad3..b4007afcd0c6 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -291,37 +291,30 @@ void wfx_configure_filter(struct ieee80211_hw *hw, static int wfx_update_pm(struct wfx_vif *wvif) { struct ieee80211_conf *conf = &wvif->wdev->hw->conf; - struct hif_req_set_pm_mode pm; + bool ps = conf->flags & IEEE80211_CONF_PS; + int ps_timeout = conf->dynamic_ps_timeout; + WARN_ON(conf->dynamic_ps_timeout < 0); if (wvif->state != WFX_STATE_STA || !wvif->bss_params.aid) return 0; - - memset(&pm, 0, sizeof(pm)); - if (conf->flags & IEEE80211_CONF_PS) { - pm.pm_mode.enter_psm = 1; - // Firmware does not support more than 128ms - pm.fast_psm_idle_period = - min(conf->dynamic_ps_timeout * 2, 255); - if (pm.fast_psm_idle_period) - pm.pm_mode.fast_psm = 1; - } - + if (!ps) + ps_timeout = 0; if (wvif->edca.uapsd_mask) - pm.pm_mode.fast_psm = 0; + ps_timeout = 0; // Kernel disable PowerSave when multiple vifs are in use. In contrary, // it is absolutly necessary to enable PowerSave for WF200 // FIXME: only if channel vif0 != channel vif1 if (wvif_count(wvif->wdev) > 1) { - pm.pm_mode.enter_psm = 1; - pm.pm_mode.fast_psm = 0; + ps = true; + ps_timeout = 0; } if (!wait_for_completion_timeout(&wvif->set_pm_mode_complete, TU_TO_JIFFIES(512))) dev_warn(wvif->wdev->dev, "timeout while waiting of set_pm_mode_complete\n"); - return hif_set_pm(wvif, &pm); + return hif_set_pm(wvif, ps, ps_timeout); } int wfx_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,