From patchwork Mon Dec 16 17:03:54 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: 11294741 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44BC3930 for ; Mon, 16 Dec 2019 17:06:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1830A206E0 for ; Mon, 16 Dec 2019 17:06:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="EMrdFqYP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727864AbfLPRG5 (ORCPT ); Mon, 16 Dec 2019 12:06:57 -0500 Received: from mail-eopbgr690050.outbound.protection.outlook.com ([40.107.69.50]:60371 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727774AbfLPRG4 (ORCPT ); Mon, 16 Dec 2019 12:06:56 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mIylNfA9W0enxysUhvGnGeIObo+cxvmU5hCsnngSZECdlkdborgOzQvpUoCxWlsG0vbJqNo9AggQiL1lkTHzJ/pozR29DQeXRGyOh+poqd9y4MKs3NlUN2Boj5tty/gt6g018PHXfyB12fXTxQj1+CJDFYaSpEPyMRh0gTJojNDUNIkQMDgn8w5bCFO0s1oQ5EC7w7Uo+AVtLugaDnwQ9O119oAfTz3tvYAEBM1xXk9kl60SbObPBFUvuttHWjrVzbxdnA+9NLiyADb3JwAYl2fcJl8DvvR972RTcIgnKLu3TeYcQw+UB9Mmctx8m0GjqOdiqITJwayGsWq3UlgXwQ== 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=Z2osYXM3Y9A9fpoiGejPayy+vna5q00UyahRps2uw60=; b=EEr/F35tQ+lsNw2at4Sjj+yQFBDBcG/1+RLVZZ7hhIt/0j2xP30w2oxL1pQ6iGVZnUYPAIvsZ7oBSEo7xds32c1bv+RulFpFLcXPAzu5DnJAoHmS67+Ryh1z7tuO5WiA2jncKMvLQkv9ispslm7XobPyl7HaQC9PjQZQauhcfCxNlwrld7s7jdGVue4lfVMdkiuoLwPX60cT4n78N7ycDxLMk7cGojnbiN/V/Kpy57YMxXHT9u3uxoqxv6bixyEdQu9/eMWBd0/+bXtNqX8ndDgIqhAS3TG2G2l5dGNFbNVyJU3zrsahpMbud2wEMT0iYtZh6+TnSWa06GoADgQ6sg== 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=Z2osYXM3Y9A9fpoiGejPayy+vna5q00UyahRps2uw60=; b=EMrdFqYPrMZAoWXZ4iiezSuZsWSnqZCwR1bw7Zlf/IZB/JtJjM1O/PVtPsXRJY6K+pseImPY5i5I3Zzwg1bKm8IRpDhOWJGDUWlrufJGLrvqQnZ1VPZYo0yD0pBgeUBBj3KtYQ9o4zBrVzW8aTkJnwNM8rt75RkPAEb5sKqDZGU= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (10.255.180.22) by MN2PR11MB4142.namprd11.prod.outlook.com (20.179.149.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2538.15; Mon, 16 Dec 2019 17:06:42 +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; Mon, 16 Dec 2019 17:06:42 +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?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH 40/55] staging: wfx: simplify hif_set_pm() usage Thread-Topic: [PATCH 40/55] staging: wfx: simplify hif_set_pm() usage Thread-Index: AQHVtDLLKj0eVOD3Z0e3Cl4CiRrkvA== Date: Mon, 16 Dec 2019 17:03:54 +0000 Message-ID: <20191216170302.29543-41-Jerome.Pouiller@silabs.com> References: <20191216170302.29543-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20191216170302.29543-1-Jerome.Pouiller@silabs.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; x-originating-ip: [37.71.187.125] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: cc67edd7-b838-4a6c-2f6d-08d7824a52e0 x-ms-traffictypediagnostic: MN2PR11MB4142: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 02530BD3AA x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(396003)(346002)(136003)(376002)(39850400004)(199004)(189003)(6512007)(71200400001)(91956017)(6486002)(8676002)(2906002)(54906003)(81166006)(81156014)(186003)(76116006)(478600001)(36756003)(85182001)(85202003)(6666004)(66556008)(66476007)(66446008)(64756008)(1076003)(66574012)(316002)(2616005)(4326008)(6506007)(26005)(8936002)(110136005)(5660300002)(107886003)(66946007)(86362001);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR11MB4142;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: wg4iPSDU5XPcGREJEYpDuyvGL5njPwOKtzZhKyWfKGLNtuOX7mxeFYASxHgoHRHYOaKMcEWMFVJFqcBVqpTiz/nwVFE3d+DAuHxIMWnDOTALf56d8bLteHKU1Jtlu510SjckjrBqHUzKVQnoPxotcDS2ccG1Yr9T/RSZ4AXlnZe++qfVUFsV37S7kD06kDJWuUgMJ5whkYH2f/v2jyqVtiS+w+2CwzUKcTplA2Axw2M/QRSlRNaHYh4p7R99rRB3n12RHUoxSZZVN+iKrxrm4mmZYC3tt+d7lG/q+ZNr6sn9pXCzEBq4nQcDJOVpYlEUi1P84g0xc8AkSU3Xm5nYvpi57ugc6/NrTdE4tFPZpiIa5PLznAPmOuK9V6DlFMZt32m65GRvudFHugriAPc4HUfzBCRaoKvXjiyQKYYEOoTDmr802y7R9JItSAjAADKh Content-ID: <74F8233353A04642A0C23A172A04380B@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc67edd7-b838-4a6c-2f6d-08d7824a52e0 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Dec 2019 17:03:54.1093 (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: hu6dm+0GRb5s61aEnG53Q8jLsd45gE+Sr9eK0KWAG0Ow2KVHA9HEgulkC6UDVcNfWBlGZJEAuiICTfaaVlkoRQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4142 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@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,