From patchwork Wed Jan 15 12:12:15 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: 216650 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 7056BC33CB1 for ; Wed, 15 Jan 2020 12:19:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 33335222C3 for ; Wed, 15 Jan 2020 12:19:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="SE8z5CRR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732257AbgAOMTm (ORCPT ); Wed, 15 Jan 2020 07:19:42 -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 S1730408AbgAOMM3 (ORCPT ); Wed, 15 Jan 2020 07:12:29 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hYnnIqhHJHnksMtdod8FEFFEX8TMstlZXSvwaS+76MgfFcjj5Xjg+VzHvsFsSPm+gKOin1JgudhzFGn7NLncE4gZH0nA3U2nhwvEtPbJiFdiFJlrwTRROxCqw8dYuHK8EWQtX3em9lipheZpusGfxvCI6BJ5NHT6k+hZt4d5WF3NrId6Df/UZPIuhzrpR4ssm73kDvre/j8zZ9YSid0CcOSnSbr42E5AKU3hdomOqeOu1k35d1QnCIx6VrOfVk57KKaQFvZydC+M1ecgw8unaZ5h/F5/tvUOjtQoBQpORvSjJOqVJfTCfBQVvQlYw1hNGJ1GYjmz7lZQueLqI1Ffww== 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=VwI3KjAJe6wvPLS63CfYdnAwDrZRt0I+K5mruf2SzxI=; b=l3Y0pPJEFd1Pb+gpab4kIMyuEAuBCKxrHhbUwHC1lTYD6t8SW+C35bDT0e9WHUM2+m9XBsivuiDVphJZx0BbVsAJfHDdPnBQmoijcaXKnz9xgr3H5Pwi1Nus9j3/WcAK3hh0u85PiBF65i94WFD7tfUpuQ3vmO0alvvNNYR+auACH+Q20kFLTxPsAEwNOzMFMeOcEQ5UGVRYdstYZpzzm1Su6leOrF36pTmDDEeilehf6FElbZicAJK+SrEP1WDieQ/mbbaxmgTWGGg+RLJX5GU9dZz9jcjlYMposwBitxqCXjQYHaQjnuPle9fW/FojzX4aWC1wBXU0SQxObwmvLg== 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=VwI3KjAJe6wvPLS63CfYdnAwDrZRt0I+K5mruf2SzxI=; b=SE8z5CRREtQi5DMxVpW4+SFe0jFrijO1Jp7/A7lvU/b1DPuDw8voN/n1UbUlWTt6VD8gP31I8XTY2CRX7WgwdPReUjbditmpOpM5F80MnK1MYWip7MkczLhlupn34dFn8Tr4d4CoWaqcBBEJwU3XuI9t2pMxq5okpuDNOYqE06U= 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:15 +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:15 +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:14 +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 05/65] staging: wfx: simplify hif_set_tx_rate_retry_policy() usage Thread-Topic: [PATCH 05/65] staging: wfx: simplify hif_set_tx_rate_retry_policy() usage Thread-Index: AQHVy50GWkyiLFnTvUOIaynlklVO2w== Date: Wed, 15 Jan 2020 12:12:15 +0000 Message-ID: <20200115121041.10863-6-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: dc86e444-50af-4163-4d28-08d799b42891 x-ms-traffictypediagnostic: MN2PR11MB3934: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; 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)(66574012)(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: m3/FFN0Mx4c7Vzjxl5UeXjqhIIfJ7KYNV4JmGM6PxwdWEJJNEphAmV2sl7k6zpbX96bjnRXpaQXw8Tb6LJl0fKZlgt2rmMVtLyX/roQz8hd54KzKp8Yh5ASfOb7GjfaDzAqt4JP7RKOm0KVyl8wdPWzLwy2XCyxYUq6J69OIVSQgitmftBmtVQmKvQpVDs+g5mynHSQOBlEDWIM6SZu2HRActiyNI4LErApHLM+rI9jpj4eU20Jo+Qj/1FAv/YlsQoflsyQPjWmpJtVn3tiexGKvIKz/DGOTseRwIGYHcOT5FwNwb2xJJKXzQmrTPIIRDymPRo/9xRAfy7r7PeAQNQ+QHE7yobOoCmo/Kxt9FRlEsZogog3t7Kkulk9HnlntVtZIfbGuBtm1lgU8A7chqTtPH5NJpVzZR46UdETap7MSOAKwzSLIS5r2ue3Ki0x4 Content-ID: MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc86e444-50af-4163-4d28-08d799b42891 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 12:12:15.2027 (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: jLKuwobqKv0R/HbenwU3E41e3Ps6FHwyVQvdppvP9avellDnf6pZkWxr3DLHja0iazvtO0ELCcTqQ2VBhyYFZQ== 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_set_tx_rate_retry_policy come from hardware API. It is not intended to be manipulated in upper layers of the driver. So, this patch relocate handling of this structure to hif_set_tx_rate_retry_policy() (the low level function). Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/data_tx.c | 16 +++------------- drivers/staging/wfx/hif_tx_mib.h | 23 ++++++++++++++++++----- drivers/staging/wfx/sta.c | 2 +- drivers/staging/wfx/sta.h | 1 + 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index fb51c5910ace..60459299a3a9 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -217,9 +217,8 @@ static void wfx_tx_policy_put(struct wfx_vif *wvif, int idx) static int wfx_tx_policy_upload(struct wfx_vif *wvif) { - struct hif_mib_set_tx_rate_retry_policy *arg = - kzalloc(struct_size(arg, tx_rate_retry_policy, 1), GFP_KERNEL); struct tx_policy *policies = wvif->tx_policy_cache.cache; + u8 tmp_rates[12]; int i; do { @@ -230,22 +229,13 @@ static int wfx_tx_policy_upload(struct wfx_vif *wvif) break; if (i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES) { policies[i].uploaded = 1; - arg->num_tx_rate_policies = 1; - arg->tx_rate_retry_policy[0].policy_index = i; - arg->tx_rate_retry_policy[0].short_retry_count = 255; - arg->tx_rate_retry_policy[0].long_retry_count = 255; - arg->tx_rate_retry_policy[0].first_rate_sel = 1; - arg->tx_rate_retry_policy[0].terminate = 1; - arg->tx_rate_retry_policy[0].count_init = 1; - memcpy(&arg->tx_rate_retry_policy[0].rates, - policies[i].rates, sizeof(policies[i].rates)); + memcpy(tmp_rates, policies[i].rates, sizeof(tmp_rates)); spin_unlock_bh(&wvif->tx_policy_cache.lock); - hif_set_tx_rate_retry_policy(wvif, arg); + hif_set_tx_rate_retry_policy(wvif, i, tmp_rates); } else { spin_unlock_bh(&wvif->tx_policy_cache.lock); } } while (i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES); - kfree(arg); return 0; } diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h index b1eeda2a3ab3..ef033a409381 100644 --- a/drivers/staging/wfx/hif_tx_mib.h +++ b/drivers/staging/wfx/hif_tx_mib.h @@ -181,13 +181,26 @@ static inline int hif_set_association_mode(struct wfx_vif *wvif, } static inline int hif_set_tx_rate_retry_policy(struct wfx_vif *wvif, - struct hif_mib_set_tx_rate_retry_policy *arg) + int policy_index, uint8_t *rates) { - size_t size = struct_size(arg, tx_rate_retry_policy, - arg->num_tx_rate_policies); + struct hif_mib_set_tx_rate_retry_policy *arg; + size_t size = struct_size(arg, tx_rate_retry_policy, 1); + int ret; - return hif_write_mib(wvif->wdev, wvif->id, - HIF_MIB_ID_SET_TX_RATE_RETRY_POLICY, arg, size); + arg = kzalloc(size, GFP_KERNEL); + arg->num_tx_rate_policies = 1; + arg->tx_rate_retry_policy[0].policy_index = policy_index; + arg->tx_rate_retry_policy[0].short_retry_count = 255; + arg->tx_rate_retry_policy[0].long_retry_count = 255; + arg->tx_rate_retry_policy[0].first_rate_sel = 1; + arg->tx_rate_retry_policy[0].terminate = 1; + arg->tx_rate_retry_policy[0].count_init = 1; + memcpy(&arg->tx_rate_retry_policy[0].rates, rates, + sizeof(arg->tx_rate_retry_policy[0].rates)); + ret = hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_SET_TX_RATE_RETRY_POLICY, arg, size); + kfree(arg); + return ret; } static inline int hif_set_mac_addr_condition(struct wfx_vif *wvif, diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 9011b5d78706..8f53a78d7215 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -19,7 +19,7 @@ #define HIF_MAX_ARP_IP_ADDRTABLE_ENTRIES 2 -static u32 wfx_rate_mask_to_hw(struct wfx_dev *wdev, u32 rates) +u32 wfx_rate_mask_to_hw(struct wfx_dev *wdev, u32 rates) { int i; u32 ret = 0; diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h index 9595e1fc60db..b5d8d6494157 100644 --- a/drivers/staging/wfx/sta.h +++ b/drivers/staging/wfx/sta.h @@ -92,5 +92,6 @@ void wfx_suspend_resume(struct wfx_vif *wvif, void wfx_cqm_bssloss_sm(struct wfx_vif *wvif, int init, int good, int bad); void wfx_update_filtering(struct wfx_vif *wvif); int wfx_fwd_probe_req(struct wfx_vif *wvif, bool enable); +u32 wfx_rate_mask_to_hw(struct wfx_dev *wdev, u32 rates); #endif /* WFX_STA_H */