From patchwork Mon Apr 6 11:17:48 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: 221415 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, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 19054C2BA19 for ; Mon, 6 Apr 2020 11:18:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D00562072A for ; Mon, 6 Apr 2020 11:18:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="VG5vcKRm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727696AbgDFLSe (ORCPT ); Mon, 6 Apr 2020 07:18:34 -0400 Received: from mail-dm6nam11on2071.outbound.protection.outlook.com ([40.107.223.71]:6126 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727125AbgDFLSc (ORCPT ); Mon, 6 Apr 2020 07:18:32 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lkhwnJYimYKxLrdhVU7Kbs+ZVkUWjYgBi3V6HehT73iJx8zPVsLD2xlnsTdZfrUOe8UTvW5jBJOqMtJJhlCMrpM+VOjBotcG9inpkIsuVHiVqNYZxRUS4U+y43n4igAPVLMkMVL3nRYsbLYRVTJWaObDUg5f8e3Uk4sJKldfV/g+gjbJ5l32NGmxiqvo7H+HRRe2ZPlEysOs508pe0QeS+Dif7yO1nKCGq5mrVEeeqTZKiR54wXC3mHBM39pSijrmrLw6a7EgZNyZcInuqv0faLsJGXMEzy5+/46V4cA2Sgl/IOucCkdF+NFdeqmsHkPpHR3xS34ifDVT+L1EY+jMQ== 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=epV5OE2uRpefDLHUseHqf8jRskPj/AAkhm53GUx3fGA=; b=Fu44F45isGvOyci/rknDxt4Gat2Jfh7BhOQawf2NAcnmkWp1BLnBg0Co2sTS8tWHmaP38LVehJ9N6QYqYs0ALM2+OFrBYGHlGCLqpvF+GtVE3QjY2Vg4XF9OZX5ekWq0H9/7I0kQp4tqjyfVH4rPKwK4rUNDxkFmg2NALW17QTmoH1z0EZbgecuuN5PVFyOcyG8QPPUeZx+RU0HoOx8mpQd/fIiPHqFbHMe5ecXmlXwPJ9n1Go5MkD57Rz49g7Vmacw02/6v4VtJeVPZwZRpY4tirwsSDmyUih/sjbD4ARZB7VcWEKy4ZBNwrI//vrD6lNncVvtyE5iSTm1Dn0CJ8w== 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=epV5OE2uRpefDLHUseHqf8jRskPj/AAkhm53GUx3fGA=; b=VG5vcKRmxZqnC4ymbhfPy6ILsX3NyNTJeJt4eh0MtQA0bwjNue7ckIFdJoSjR1lE9umHertZ4kwTsc4CVAGizIgSffOyJZYXt1qcerp+Eg0FMNXv7bJU5QK6rIdnBYeuHTPlMEH3Fi0QoAdX1qNnY3Ct4gPvxYrgHBT0PcVXTTQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; Received: from BN6PR11MB4052.namprd11.prod.outlook.com (2603:10b6:405:7a::37) by BN6PR11MB3860.namprd11.prod.outlook.com (2603:10b6:405:77::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.15; Mon, 6 Apr 2020 11:18:20 +0000 Received: from BN6PR11MB4052.namprd11.prod.outlook.com ([fe80::e0af:e9de:ffce:7376]) by BN6PR11MB4052.namprd11.prod.outlook.com ([fe80::e0af:e9de:ffce:7376%3]) with mapi id 15.20.2878.018; Mon, 6 Apr 2020 11:18:20 +0000 From: Jerome Pouiller 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 03/11] staging: wfx: relocate TX_RETRY_POLICY_MAX and TX_RETRY_POLICY_INVALID to hif API Date: Mon, 6 Apr 2020 13:17:48 +0200 Message-Id: <20200406111756.154086-4-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200406111756.154086-1-Jerome.Pouiller@silabs.com> References: <20200406111756.154086-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: DM5PR05CA0010.namprd05.prod.outlook.com (2603:10b6:3:d4::20) To BN6PR11MB4052.namprd11.prod.outlook.com (2603:10b6:405:7a::37) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (2a01:e35:2435:66a0:544b:f17b:7ae8:fb7) by DM5PR05CA0010.namprd05.prod.outlook.com (2603:10b6:3:d4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.13 via Frontend Transport; Mon, 6 Apr 2020 11:18:18 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [2a01:e35:2435:66a0:544b:f17b:7ae8:fb7] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 52b18c32-aeca-4802-8428-08d7da1c3645 X-MS-TrafficTypeDiagnostic: BN6PR11MB3860: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-Forefront-PRVS: 0365C0E14B X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR11MB4052.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(396003)(39850400004)(346002)(366004)(136003)(376002)(186003)(16526019)(7696005)(52116002)(36756003)(5660300002)(107886003)(316002)(54906003)(66946007)(66476007)(4326008)(2616005)(66556008)(1076003)(66574012)(81166006)(6666004)(6486002)(8936002)(2906002)(86362001)(81156014)(8676002)(478600001); DIR:OUT; SFP:1101; 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: yBiG+2DwAznJMg4JwcgoRKRYqfHALRFkv/rJYCA+cotJuwPLPBRhqABlk0glOMT6iT4yCShT2FTyC4p+dsnvHJqXVmGukrmpShNcJyXOziiXheUkFegZrHLRZS22Xa7bFbs9Eo0WWnlSTZYQXhgNNyMv1GqV060R7Cb0smuNhhP0iihlhIBSbHTW07dGjJbxTvc0FjyvmpxFbAQUsAvkPrR700s7EFp7NfRja7jUKDYO4zygMioa0UJ0ECWMeby8gAafEsgtsWBryLC10KlMQ03AXarfEiFkvCNjvp28uE75BROVAkBvXzTY5XKr125q7af4lGeI1MPhiflJ887xOe1xkuyqasLOFtSalHcsjQEHZ4NMxFkS5ltoSGcI/6BnuPcbc7Fj1SV9zAYNZelMnxwUs+3fGWkJx/xcZq56D3rEf1yDrFpnfAxFMHm0NVjY X-MS-Exchange-AntiSpam-MessageData: hgoKtisI+FU/YsYh3vUv1tCIPWhUGwWIq+paIoIqMV+QvP2IBscabQJyS1WXwThcqBeT7jRcRCM2RLCdd/zyFJqFSVRgf9kIkFs35qr1xE/IX1FxPXeDIFgceFToP9nXfvMWujQfPyg9mNdfQosqClgGQEiGYbZ3jD1kbw4Al8eHsqKsb8Zp/VIFt0PWXmJ0lrLHslbzC6oYO+weunIuOA== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 52b18c32-aeca-4802-8428-08d7da1c3645 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2020 11:18:20.3917 (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: Q9TDWmFhpjmGPKQMRHnvXzTjj5YoiDQ7csdFP1RMzF+7o6Sw1JJDblZf4rqj3OXgFZnOnQrr8C1TyZL6CQlP5g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB3860 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller The definitions TX_RETRY_POLICY_MAX and TX_RETRY_POLICY_INVALID are imposed by the hardware. Therefore, they should be located in the hardware interface API. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/data_tx.c | 16 +++++++--------- drivers/staging/wfx/data_tx.h | 2 +- drivers/staging/wfx/hif_api_mib.h | 3 ++- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index 757e37454391..a34f6231b878 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -16,8 +16,6 @@ #include "traces.h" #include "hif_tx_mib.h" -#define WFX_INVALID_RATE_ID 15 - static int wfx_get_hw_rate(struct wfx_dev *wdev, const struct ieee80211_tx_rate *rate) { @@ -117,7 +115,7 @@ static int wfx_tx_policy_get(struct wfx_vif *wvif, if (list_empty(&cache->free)) { WARN(1, "unable to get a valid Tx policy"); spin_unlock_bh(&cache->lock); - return WFX_INVALID_RATE_ID; + return HIF_TX_RETRY_POLICY_INVALID; } idx = wfx_tx_policy_find(cache, &wanted); if (idx >= 0) { @@ -146,7 +144,7 @@ static void wfx_tx_policy_put(struct wfx_vif *wvif, int idx) int usage, locked; struct tx_policy_cache *cache = &wvif->tx_policy_cache; - if (idx == WFX_INVALID_RATE_ID) + if (idx == HIF_TX_RETRY_POLICY_INVALID) return; spin_lock_bh(&cache->lock); locked = list_empty(&cache->free); @@ -164,11 +162,11 @@ static int wfx_tx_policy_upload(struct wfx_vif *wvif) do { spin_lock_bh(&wvif->tx_policy_cache.lock); - for (i = 0; i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES; ++i) + for (i = 0; i < HIF_TX_RETRY_POLICY_MAX; ++i) if (!policies[i].uploaded && memzcmp(policies[i].rates, sizeof(policies[i].rates))) break; - if (i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES) { + if (i < HIF_TX_RETRY_POLICY_MAX) { policies[i].uploaded = true; memcpy(tmp_rates, policies[i].rates, sizeof(tmp_rates)); spin_unlock_bh(&wvif->tx_policy_cache.lock); @@ -176,7 +174,7 @@ static int wfx_tx_policy_upload(struct wfx_vif *wvif) } else { spin_unlock_bh(&wvif->tx_policy_cache.lock); } - } while (i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES); + } while (i < HIF_TX_RETRY_POLICY_MAX); return 0; } @@ -200,7 +198,7 @@ void wfx_tx_policy_init(struct wfx_vif *wvif) INIT_LIST_HEAD(&cache->used); INIT_LIST_HEAD(&cache->free); - for (i = 0; i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES; ++i) + for (i = 0; i < HIF_TX_RETRY_POLICY_MAX; ++i) list_add(&cache->cache[i].link, &cache->free); } @@ -308,7 +306,7 @@ static u8 wfx_tx_get_rate_id(struct wfx_vif *wvif, rate_id = wfx_tx_policy_get(wvif, tx_info->driver_rates, &tx_policy_renew); - if (rate_id == WFX_INVALID_RATE_ID) + if (rate_id == HIF_TX_RETRY_POLICY_INVALID) dev_warn(wvif->wdev->dev, "unable to get a valid Tx policy"); if (tx_policy_renew) { diff --git a/drivers/staging/wfx/data_tx.h b/drivers/staging/wfx/data_tx.h index 7f201f626410..a308af3d68ad 100644 --- a/drivers/staging/wfx/data_tx.h +++ b/drivers/staging/wfx/data_tx.h @@ -26,7 +26,7 @@ struct tx_policy { }; struct tx_policy_cache { - struct tx_policy cache[HIF_MIB_NUM_TX_RATE_RETRY_POLICIES]; + struct tx_policy cache[HIF_TX_RETRY_POLICY_MAX]; // FIXME: use a trees and drop hash from tx_policy struct list_head used; struct list_head free; diff --git a/drivers/staging/wfx/hif_api_mib.h b/drivers/staging/wfx/hif_api_mib.h index 0c67cd4c1593..36c9152785c4 100644 --- a/drivers/staging/wfx/hif_api_mib.h +++ b/drivers/staging/wfx/hif_api_mib.h @@ -500,7 +500,8 @@ struct hif_mib_tx_rate_retry_policy { u8 rates[12]; } __packed; -#define HIF_MIB_NUM_TX_RATE_RETRY_POLICIES 15 +#define HIF_TX_RETRY_POLICY_MAX 15 +#define HIF_TX_RETRY_POLICY_INVALID HIF_TX_RETRY_POLICY_MAX struct hif_mib_set_tx_rate_retry_policy { u8 num_tx_rate_policies;