From patchwork Wed Jan 15 12:12:13 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: 11334153 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 7D2F2138D for ; Wed, 15 Jan 2020 12:20:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 46DCD222C3 for ; Wed, 15 Jan 2020 12:20:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="T0REsEuy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731081AbgAOMTy (ORCPT ); Wed, 15 Jan 2020 07:19:54 -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 S1730377AbgAOMM1 (ORCPT ); Wed, 15 Jan 2020 07:12:27 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j9wpfxaAiOXZ91com0JRYfo2TJTc/2yr2tV09oRxTwJ+zSR763ssXOVAzhC2hI0Eq+EnPGovTH/+YgMj7C3QtDTHQzOpzcz7Q7n9rDerqcXI+/V/V9Bw+/GsHamhkWmVb/daOujzmNp/PAzlaI3rLTeucZAIS3wy+2jS8USBC/kjBbNhENf5Sr+bGFzrW+/2zBtCX4zceeEcT/SoUMt8lCNxNHcKbon+0oVroG9vcCqi8GFWW637O+apY6O92P8Yu1BKXzxJqYWCN8ef64w84gTADCWNzB7w4r0fhKl1ojHTWm8LekrjzCEl3SGK0O/hdQ7WPUF1Xya1LXrlUWRDsg== 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=gq5Umz4L0UlsXSSwPFNYQaPHeYPTP/zJciKYxMzYSus=; b=m7dbZqn0D7dlWLZ5GXR13YS8Y4CDCVJUN06raEjRWD+3G3figgAps5hEWDJGLOtR5fxbApZDZFNWGhd4uitCKl2rwKUXExHEQi/zPv57cT6KWnwHaSEx7YpoIqB+LlgxOp71DHalztCU96pSsVVqcjRW9XRxPClK6MHDwn0WK/Lmt91GnyQKVLgpf/UzKdrCrcPZxcq5NfQuh2r0b15S2AwBjnpeXr21IZaP6R1yumPtWCIzT9sTPoLEyoYgtUoD6prFadY/fUA8To3s8DEeVjw/IcIN5vVwny49k1soE4shbrRwvUub1Xn4NWgQCjahKTT+sDkHXU3Px/kVoeL3NQ== 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=gq5Umz4L0UlsXSSwPFNYQaPHeYPTP/zJciKYxMzYSus=; b=T0REsEuy4t4G/THNFMEZDTBaymDOaqeW9H927EPW39hyIfmwQVBN1SP4hwlZRDav6Q4IWVQkqc8TfSjRflmRVqIZKsbbipuNqMEBJejInZb2u4mJLIz8+YDS3G/Z8WsrbmGcekvSK7t1GNxkpY2w0eI4aeTLGDr63OCWeRukl1w= 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:13 +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:13 +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:12 +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 04/65] staging: wfx: send rate policies one by one Thread-Topic: [PATCH 04/65] staging: wfx: send rate policies one by one Thread-Index: AQHVy50FiohjPBflH0qwFWQsKYtkXg== Date: Wed, 15 Jan 2020 12:12:13 +0000 Message-ID: <20200115121041.10863-5-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: c519b72a-dffb-433e-d577-08d799b427c0 x-ms-traffictypediagnostic: MN2PR11MB3934: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; 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: RayMog2P/VQWW2SKnNavntS+/FSFLglEakJR8/5hJde0QgIHp3ZBAS/gmiI00Nvi8DM5jevouFk+fca9ClbtcrikT22wQwaiYEcXKMAVBPFdLa6P7i76dfY2RRNDWEKY+ntVMVwnvGOItA0IAPWkn5EhOorW4SKWtFdycFMj3rA5MVSmTU6hfdAMJ9FhNAkwGZoT8WQ8evRkhDONA+oLjF8m1lyruQ9/hNB/Gc3Fz8eW98HqR7OuUVlNUFBjUP4aXSLDb/qv46JlvJUNeaN5usngLEU9ag+8lQR9BJlySG760EoOAkAzImFAZJpMYMM1laji0cQnV8+xEcp2epbx9/ONMkyIlN5JcR8JZDFGoAKhrj7Hw7kJbv3+aTReqiK1QcLP1MFHO/eXJt7dpl9ObkE9EWU68w5A36hw6Mi24rocWB8M3YkYUiuHbvaqHduv Content-ID: MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: c519b72a-dffb-433e-d577-08d799b427c0 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 12:12:13.8345 (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: nWCFg0ovRvWPSMB9KLB28n0p4s0f5R9J4L9xbWXdwgd/Bc1iW1Byu2ovLmWQZbjLHB3Zb/DEMKSg71AL7PX04Q== 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 Rate policies (aka. tx_rate_retry_policy in hardware API) are sent to device asynchronously from tx requests. So, the device maintains a list of active rate policies and the tx requests only reference an existent rate policy. The device API allows to send multiple rate policies at once. However, this property is very rarely used. We prefer to send rate policies one by one and simplify the architecture. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/data_tx.c | 53 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index b2a325c47b2d..fb51c5910ace 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -217,37 +217,34 @@ static void wfx_tx_policy_put(struct wfx_vif *wvif, int idx) static int wfx_tx_policy_upload(struct wfx_vif *wvif) { - int i; - struct tx_policy_cache *cache = &wvif->tx_policy_cache; struct hif_mib_set_tx_rate_retry_policy *arg = - kzalloc(struct_size(arg, - tx_rate_retry_policy, - HIF_MIB_NUM_TX_RATE_RETRY_POLICIES), - GFP_KERNEL); - struct hif_mib_tx_rate_retry_policy *dst; + kzalloc(struct_size(arg, tx_rate_retry_policy, 1), GFP_KERNEL); + struct tx_policy *policies = wvif->tx_policy_cache.cache; + int i; - spin_lock_bh(&cache->lock); - /* Upload only modified entries. */ - for (i = 0; i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES; ++i) { - struct tx_policy *src = &cache->cache[i]; - - if (!src->uploaded && memzcmp(src->rates, sizeof(src->rates))) { - dst = arg->tx_rate_retry_policy + - arg->num_tx_rate_policies; - - dst->policy_index = i; - dst->short_retry_count = 255; - dst->long_retry_count = 255; - dst->first_rate_sel = 1; - dst->terminate = 1; - dst->count_init = 1; - memcpy(&dst->rates, src->rates, sizeof(src->rates)); - src->uploaded = true; - arg->num_tx_rate_policies++; + do { + spin_lock_bh(&wvif->tx_policy_cache.lock); + for (i = 0; i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES; ++i) + if (!policies[i].uploaded && + memzcmp(policies[i].rates, sizeof(policies[i].rates))) + 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)); + spin_unlock_bh(&wvif->tx_policy_cache.lock); + hif_set_tx_rate_retry_policy(wvif, arg); + } else { + spin_unlock_bh(&wvif->tx_policy_cache.lock); } - } - spin_unlock_bh(&cache->lock); - hif_set_tx_rate_retry_policy(wvif, arg); + } while (i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES); kfree(arg); return 0; }