From patchwork Wed Jan 15 13:54:07 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: 216618 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 B692FC33CB3 for ; Wed, 15 Jan 2020 14:01:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 815E624656 for ; Wed, 15 Jan 2020 14:01:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="LrJrHfZl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729281AbgAONyb (ORCPT ); Wed, 15 Jan 2020 08:54:31 -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 S1726132AbgAONya (ORCPT ); Wed, 15 Jan 2020 08:54:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b8n1bWbiLN/i/SPN8a1Ir38ooRWypl/NFvJH5J/s8ydWr+LBmaPwcPVDwF9HDDWiemGQ1rj8i5TpxV9qGgSSMOq2ENWhzWQpGldK5nc8JsnGNsVa9QyowQcY+FRCLGHjw1Gp+vcbcIFBRfzcVrALa+3DfShBiNtMtfQj5f7pSsKAo7VZ8lzlY3+r0tdIS7RAdO3xm9fFVoH6vNB9z0lPd23FS2hsDKvH7OGSvb5Pny62Ug2VBgAH3YQYuk3+KCHDFvqWClIEhNQrn6CYHXIYPkr3ZMYPQTw5vQKth+VgSuxp6WN5+AHiHRztZJJQpS7UHr6Zure4ea5Ts52PJHrQSw== 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=lKTgUjcY50apjdeWmFbHo9zAuvpOQ767iycDA6aBkGSg2x4yTfxpeAB0PtFiYDxV+5QqqmSfYLBl+Lkb9QrS5BDnaYPsGdCSpKznm/ATgQW2yOVlCyoksK6J52oL7XK3ZnQ6+ZbR+2Yw42Q0Q+k1o92/a6Zo3oirmJwvOp78WWi/LYvucf4ZdqzlaHOC/XQEEoQA9IBRke8KA4utF0ytNF4uFz9RczeTedEGTmHzSpe6R5gy9FFrHZHaP3t490lcI7MZPOrzNU+eJQ6PFC5jwLqg8k5FOKfABRGwzuqpDc3hXRzqz9cw+939Q03Phn1SKyXsTchuKnem3y35A/8Onw== 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=LrJrHfZlD6icf+ghekWIpHqS2sGmPC6uxRPKW/qdxieUORD7i3cghC4V2nnFbir+kz8XiWPY32pJHdH5wzhDdCsYVi80E4ApL+9/VCP+lfKyo01rr9wWTKREN9vC12WuvzoS+ZX3ungIKQmZuHl3f3nS8Vx9EqEPY4jUWk+MgBc= 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:08 +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:07 +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:06 +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 04/65] staging: wfx: send rate policies one by one Thread-Topic: [PATCH v2 04/65] staging: wfx: send rate policies one by one Thread-Index: AQHVy6tBNYloxuW2g0u7z8Y0M1pzeQ== Date: Wed, 15 Jan 2020 13:54:07 +0000 Message-ID: <20200115135338.14374-5-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: 7c04c141-eeff-4233-7ff9-08d799c263f9 x-ms-traffictypediagnostic: MN2PR11MB4094: 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)(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)(66574012)(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: NZn5rv8acWB6vOa2v61ehRPCz2Te75RYCXrVJl5JueQtn9NcQvmsh/WCweUUOJdb9S3Cn9Ekz1pAkeQLkGxY+lwU6VgkQA4Nf1fZLFJKBQ1g3AverqYLAPHR61Nlw7+AWar1bq0bQbBQ79nzAoVfTtPkOk0z6zn987w3QSRRBEY7QX++0qHhIYCYakXTPGEBar82zoCHZkVVmAOAnqUhZrhdM7IJfoHje9Ymnf8DQH+kKu7ySaw/47jWSUp1NfMdiXRXRXkVc1moueIka6BsR9ZZpDwnEDZsDsL9r91y+Hho/+MMig0IotBh7hejjnkfu0MH/BhuJEx0R3mtShBaqyiL+AmZF54DI1dtaGY+jY8kIrtA5amdYK8NCvLP2SkA1bkPgJe8UXznczedQwBUyV9V1lnHfgkfuQg+bs8y2GBMqqM+poPmdlrbtxikYHST Content-ID: MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c04c141-eeff-4233-7ff9-08d799c263f9 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 13:54:07.8194 (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: sgsntgN+GNn3wAtv1tKPdEJKdojwnfMXZwdbrpzhhYl63JEk/Yf6nsOCh2+Nn8/LsjXpEUgUe6KoFQCP3dvMwg== 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 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; }