From patchwork Wed Jan 15 12:12: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: 11334139 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 7767A139A for ; Wed, 15 Jan 2020 12:19:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 41A58222C3 for ; Wed, 15 Jan 2020 12:19:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="Lw8ZwO60" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730588AbgAOMMg (ORCPT ); Wed, 15 Jan 2020 07:12:36 -0500 Received: from mail-co1nam11on2084.outbound.protection.outlook.com ([40.107.220.84]:24056 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730514AbgAOMMc (ORCPT ); Wed, 15 Jan 2020 07:12:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UtjXnOTQoFtXGcJBowkj24VUUclcILk3p9DbpuApxggJVIUJVopXTMwZnt/BlotJ3cSAS0xBlNx5rPMNkbnWO86ZU8iAvuYVomuhuicjxos28CnXOJacF4+tjZH5Rckt/AMowi9XiP2MmtRl8vlFP0L7lfqFB4g0NCZ3IMkjU1tWZeiGGlkxEt03yxZVOo3iXm5x9Pw6O9n/EfOah8V91OXI3ESNkRfc4soII4tqkxIq8vFERsvU6hEg/sLsgc4ANNZVo+l5W4ZK8+3dPiCE6/oim22Igb+TYpjlJgVu8JOE0ccV8ME9KSKD2GDEPqDn8mrZEAlFRB5QK6FlCN7rpg== 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=+AJrNR5x6OaUELuP4bcANVom55NGF0XSik/Lq5n/m4E=; b=gw1K1ghqvUdqvK2fH5ymcgUO4ad8pzrgk4fY5HoD6PVJJJMxyg+CsSPU+0tgbSRQ/oHthEoQOEKGIxRYOOiMc1O71tmJ8kaSA8qe1keH76ON2nV33RRU91T8LX/PWzFr0zuAweeE5SZb9YogV8f2r3Pm9s79iN26jCGbGMg24SbgEPyyHYJryiXSOhcAFAV26Xd54wdVMCVof+pmMrIiNN5J7tNYidadiABA5GDJKjRgIGSf983rK7zZhy5WpnLEHscjvDQf1gOTskrUG8jEFU1ovtPTr9II/jJQeoqmWVt3vYSlwVIzzpmIkWgnK88M1VuZUYYhVFyYfqEIMUre1w== 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=+AJrNR5x6OaUELuP4bcANVom55NGF0XSik/Lq5n/m4E=; b=Lw8ZwO60VuF/tmMuhjPN93J3CEeIjVPq47vlKgR7iUiqXIJbplkgpnREdwOLxvGHIbDGJxqbB/+OBxPIzrmA7DlJMX4BWWJELn+i665Jf+WjgD1w36+TLURI9GUwWj6v3cTUOxInER05REGFuF/5gd2dm7OI5gRBnIEgWImkRzc= 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:12:18 +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:12:18 +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:12:16 +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 07/65] staging: wfx: simplify hif_set_rcpi_rssi_threshold() usage Thread-Topic: [PATCH 07/65] staging: wfx: simplify hif_set_rcpi_rssi_threshold() usage Thread-Index: AQHVy50H7H/1251ZlUKOU4Y3OcPyWQ== Date: Wed, 15 Jan 2020 12:12:17 +0000 Message-ID: <20200115121041.10863-8-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: f39b3520-71b1-40cf-40f4-08d799b42a30 x-ms-traffictypediagnostic: MN2PR11MB3934: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4502; x-forefront-prvs: 02830F0362 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39850400004)(396003)(136003)(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)(1076003)(66556008)(64756008)(66446008)(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: +1oqiJqvm/0YbLrkEZCBQGN9hSD0qUQUaPQUMas2rud6xkvNtXT+wGPi4++WUN101HRdxFL8tKozYPMaij00iSShzMmaoVMtA7p2d6VLN1MkwHNDV3b6jlufMGo9PGwiQtUrcZaRJ8qytHk2TMZJL8ImTFPX2iN9wpo5Z9YBwqu86HCc7lRUxdU674y96sOGxMtoWApQmXDKb2jtPoUS1AoWUP8ttoYqPtYWJEATVINh4G23AgaZI4EaV4GnCYdjnk8bhjIaycII4N85qxsbPRbEfaWMA5W+RAV4zz23ZSrTq1ZH/M2mmcas/GiwpvNGAbCNPTyy4+yc1MA4dSxBVQc+nNiZiiXflVmzSLQ+4nhwY/w0FCbW1I53z+QBfU/P0zVngLlTbXWPVwTo3RZn7d6nkqd2AEuIQamKorIKgFAZ80NXVS0jsO0M/19dSh7p Content-ID: <847D589BD2517D49AE50D05C091C3662@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: f39b3520-71b1-40cf-40f4-08d799b42a30 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 12:12:17.8951 (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: U4SjGGdD7UkGar3y3XOMX2gOjBw6j6R9Jo8vXvtQBwMXUGovOTqJWP4SCC7E5o7qccFJf12DdKwKAMipvv5jUA== 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 The structure hif_mib_rcpi_rssi_threshold come from hardware API. It is not intended to be manipulated in upper layers of the driver. In add, current code for hif_set_rcpi_rssi_threshold() is dumb. It should pack data using the hardware representation instead of leaving all work to the caller. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/hif_tx_mib.h | 19 +++++++++++++++++-- drivers/staging/wfx/sta.c | 26 ++------------------------ 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h index 749df67131c3..a8082508fbfd 100644 --- a/drivers/staging/wfx/hif_tx_mib.h +++ b/drivers/staging/wfx/hif_tx_mib.h @@ -44,10 +44,25 @@ static inline int hif_set_beacon_wakeup_period(struct wfx_vif *wvif, } static inline int hif_set_rcpi_rssi_threshold(struct wfx_vif *wvif, - struct hif_mib_rcpi_rssi_threshold *arg) + int rssi_thold, int rssi_hyst) { + struct hif_mib_rcpi_rssi_threshold arg = { + .rolling_average_count = 8, + .detection = 1, + }; + + if (!rssi_thold && !rssi_hyst) { + arg.upperthresh = 1; + arg.lowerthresh = 1; + } else { + arg.upper_threshold = rssi_thold + rssi_hyst; + arg.upper_threshold = (arg.upper_threshold + 110) * 2; + arg.lower_threshold = rssi_thold; + arg.lower_threshold = (arg.lower_threshold + 110) * 2; + } + return hif_write_mib(wvif->wdev, wvif->id, - HIF_MIB_ID_RCPI_RSSI_THRESHOLD, arg, sizeof(*arg)); + HIF_MIB_ID_RCPI_RSSI_THRESHOLD, &arg, sizeof(arg)); } static inline int hif_get_counters_table(struct wfx_dev *wdev, diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 11e33a6d5bb5..339acbce96fb 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -1033,31 +1033,9 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw, hif_slot_time(wvif, info->use_short_slot ? 9 : 20); if (changed & BSS_CHANGED_ASSOC || changed & BSS_CHANGED_CQM) { - struct hif_mib_rcpi_rssi_threshold th = { - .rolling_average_count = 8, - .detection = 1, - }; - wvif->cqm_rssi_thold = info->cqm_rssi_thold; - - if (!info->cqm_rssi_thold && !info->cqm_rssi_hyst) { - th.upperthresh = 1; - th.lowerthresh = 1; - } else { - /* FIXME It's not a correct way of setting threshold. - * Upper and lower must be set equal here and adjusted - * in callback. However current implementation is much - * more reliable and stable. - */ - /* RSSI: signed Q8.0, RCPI: unsigned Q7.1 - * RSSI = RCPI / 2 - 110 - */ - th.upper_threshold = info->cqm_rssi_thold + info->cqm_rssi_hyst; - th.upper_threshold = (th.upper_threshold + 110) * 2; - th.lower_threshold = info->cqm_rssi_thold; - th.lower_threshold = (th.lower_threshold + 110) * 2; - } - hif_set_rcpi_rssi_threshold(wvif, &th); + hif_set_rcpi_rssi_threshold(wvif, info->cqm_rssi_thold, + info->cqm_rssi_hyst); } if (changed & BSS_CHANGED_TXPOWER &&