From patchwork Wed Jan 15 13:54:12 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: 216619 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 53386C33CB1 for ; Wed, 15 Jan 2020 14:01:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 141AC24656 for ; Wed, 15 Jan 2020 14:01:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="TylJzHLQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729833AbgAOOA6 (ORCPT ); Wed, 15 Jan 2020 09:00:58 -0500 Received: from mail-dm6nam11on2085.outbound.protection.outlook.com ([40.107.223.85]:14113 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728884AbgAONyd (ORCPT ); Wed, 15 Jan 2020 08:54:33 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g2yaBI3FlAr2xivUwicVrJGBv6vWv0fXws9hjTg8lpSfm5EK1cD/VjzKzhaVHRNOyHm9ZoNkFe/AQIr9YNyCa4HLbdGctWCH6VidkBZhXaKTxUmrsaZzxMEvGyyFvgyEgJAhLENSCdfsQnIxJEu7XSzyGRNZRxvFhGLWAoixPfb2WixF8GSuIaU6nRhYt1Fy1jAvs7IZQquhlTguqL80/xTTjQvSSj5hzNUOJnwc3iKiVkC1hxxGKp1MWlxtTSei29+XI94sSQAxyr0vnZGB8sO4Ir6LGsAgzmk5LbhGLVAY1ouNVsaDZtB+BPdq3+kpy63zkVxo6MR0it66pDnZ5A== 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=c3Az/5wUAr/QpF550qgEqD9Jlr1E6EPmGwQATCxAwAAQ01fQHTdxb11E20cRicdN2NJwhaHusSEnQ/dqUsYpTmVk1jpirtXPVYPwbNXEHzrBPCHxmXVdhP9HuwaFqIRkpUC6OFH01yzXHi5puFiHC3Z++VLN68HaTupqlZxVe/vlXs0wO4vsmmaknvqiuTyw4mA8VSWv1dMhVuCJIcd2/Tx5umgwXTRieaNef6ERAx+PjDepq+TzzwDhYGOcle37yhpmZVQy6ABebKPX5YXVtT2PIJPjS4ydwVykt5PfrXhQ7/67D3ToJBRuvMW3GFQZD+hQ0ef7peZ+rCEeyq7qjQ== 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=TylJzHLQlQ5rQIuCH85tGRG62er7/CsF69MvTXLRG0CuN5rTlDuiwb69BzyeZxxzdoKdc4aBztNd1O56B2vYVjjAnKcY988L3VVHzvGRpDivwlwlhi5hpJoM6KhHsfnUjZWRKS8I8110nksLZ2LN/DrefHuZZviSxvQl20L2PNg= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (10.255.180.22) by MN2PR11MB4094.namprd11.prod.outlook.com (10.255.180.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.19; Wed, 15 Jan 2020 13:54:12 +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 13:54:12 +0000 Received: from pc-42.home (2a01:e35:8bf5:66a0:3dbe:4cb5:6059:a948) by PR2P264CA0008.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101::20) 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 13:54:11 +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 07/65] staging: wfx: simplify hif_set_rcpi_rssi_threshold() usage Thread-Topic: [PATCH v2 07/65] staging: wfx: simplify hif_set_rcpi_rssi_threshold() usage Thread-Index: AQHVy6tEZVLrPPl2cUSAlMb2bQPJ/g== Date: Wed, 15 Jan 2020 13:54:12 +0000 Message-ID: <20200115135338.14374-8-Jerome.Pouiller@silabs.com> References: <20200115135338.14374-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20200115135338.14374-1-Jerome.Pouiller@silabs.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR2P264CA0008.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101::20) 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: [2a01:e35:8bf5:66a0:3dbe:4cb5:6059:a948] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: feb40c88-1772-439d-f220-08d799c26688 x-ms-traffictypediagnostic: MN2PR11MB4094: 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)(366004)(396003)(346002)(136003)(376002)(189003)(199004)(316002)(110136005)(54906003)(85202003)(81156014)(5660300002)(8676002)(71200400001)(8936002)(81166006)(186003)(6506007)(86362001)(66946007)(66446008)(66476007)(66556008)(2906002)(64756008)(478600001)(6512007)(52116002)(6486002)(1076003)(16526019)(4326008)(85182001)(107886003)(36756003)(8886007)(2616005); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB4094; H:MN2PR11MB4063.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: 00o9vDEIH5I7c2fbwwiuI+qBr1917nKaxC2DXOTUPMaa3/FMKKWdpLeusPOgx2Di1vJKvSfVd1/N9OxvvnnmYRoSVjYm/PNpDaxXoY61Zgz+6BovHjV+k5QyFmR8J73QiocZcGYe9ayev7TAYB74kJMTTg0XYrQtd1AXQInB5k4x38XlqNlbWBjELHtyBqvrCCYDLn2JTY8rbV2q8y7XFrtD76cZKWGdN8GwKNlnY7QdUU+XcbMYyIuMzZfheZo2gFhM7ewhrmWF0JqZtBLMpa1/RxHS39fK6+5fCRRosI8D/t7fRB4N9Ve2by1yCecUFpnAi348EW/t6SW6FtBarSREyX0BPWor6ETl+qn1B8/5T+lCUbwE/fAQ0zWj9IHLfKu5RRoviRSuKyN/jduBQhKKAG+jDRlQgg2IwiuGbckBoncLfQGEXxylKYZ1u3Bc Content-ID: <100D41C3DAA1E24A9CD8AF345F137BB4@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: feb40c88-1772-439d-f220-08d799c26688 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 13:54:12.0919 (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: 210EfQM7F/uvSJnvGkiwNuUUWlm4TuMvawMLZjNQVY3kHy2p36qWtS2jLd1bspi8ZJQtLImgeo9zEMThnNc1KQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4094 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 &&