From patchwork Tue Oct 5 13:53:40 2021 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: 12536789 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 069DCC43217 for ; Tue, 5 Oct 2021 13:56:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E4F7B615E3 for ; Tue, 5 Oct 2021 13:56:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235714AbhJEN6F (ORCPT ); Tue, 5 Oct 2021 09:58:05 -0400 Received: from mail-dm3nam07on2073.outbound.protection.outlook.com ([40.107.95.73]:28128 "EHLO NAM02-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235482AbhJEN5R (ORCPT ); Tue, 5 Oct 2021 09:57:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aY4aAuEbOUnPW9g7ZStgncAM08S1x1IeCTTJpf7pftRA9/CFSolJ+Z8XhdIYfp6TG3CWhml70eBx/SsG+Wg6LKBZ2x77uAIV1lqKriMLxEY8ETDxfts37zGCanQ3dVJSb9oV9SlU8aeDmc2zHjxVPYIOyWUe4vRGLM8deLy5MOu+9e0kZ+QD4hDq3emyrietWPowQKJhZE29LvD+WkKIhHvILulg4VT0ah2NPgiuA/J2Se3PxItMPqiu8nZBUVjTxWAf7vo+y1LVdQjEURoRCUiirebaYtb1yWeHsfvrB2RCt2VfI1El7d6vsB3HZpEXiA86uyXKj/TuhABVb0qsnw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/KGviaj5T1/EBEmLeuCf3Aukxd3aMsZE1V3/7dfMSrI=; b=TCvOPMuo17geQ1PlQoQWnKGoCuMUvK9lN7jL6RApSYqbtfAh7YQTQ77eGpmdp5afPVM8mJUGwJCZ3l/aG6mRy8lQ5P+7LH/9i2Zkj+oB6biISw0KSYPrSkSuLzFovlsm9IxgtNZC1zrxqmGPxnmxXUV2M4fW5p14HsjC/IP8xqyZSqD3xDjMQgQF0KphaOvPTJv86OEJwprz06E5UsNO8GGC8RcomznS3M2x3NPp2eRwS2UYdtKwQcSvlhPoqu4hzjPA/Ot9vNlcULD0Lh9kkTVJxvNf6aV4aPzCOY5VUfATmDSxhex71UyLOsp8YNO2sX4dN/Xlgq98Xzi6SvzLhw== 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=/KGviaj5T1/EBEmLeuCf3Aukxd3aMsZE1V3/7dfMSrI=; b=E436rg7ORNLLlmXNqFxZc/FM4K+DBzOw1oWWfX9+SUz5kgENvPvTLBDGf8V8mYu5lyHl1T5TY7ig+UAIW4Eksha1zxVpZ53dA7b1dvkQD+Eh8GDrdi6GLVCGA1jlp0AhrQS0teUzbf2q8mH7Vn2wVgAx0xLYFLCE5inLt2LLs8c= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=silabs.com; Received: from PH0PR11MB5657.namprd11.prod.outlook.com (2603:10b6:510:ee::19) by PH0PR11MB5643.namprd11.prod.outlook.com (2603:10b6:510:d5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Tue, 5 Oct 2021 13:54:31 +0000 Received: from PH0PR11MB5657.namprd11.prod.outlook.com ([fe80::31cb:3b13:b0e8:d8f4]) by PH0PR11MB5657.namprd11.prod.outlook.com ([fe80::31cb:3b13:b0e8:d8f4%9]) with mapi id 15.20.4566.022; Tue, 5 Oct 2021 13:54:31 +0000 From: Jerome Pouiller To: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Kalle Valo Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "David S . Miller" , devicetree@vger.kernel.org, Rob Herring , linux-mmc@vger.kernel.org, =?utf-8?q?Pali?= =?utf-8?q?_Roh=C3=A1r?= , Ulf Hansson , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH v8 04/24] wfx: add wfx.h Date: Tue, 5 Oct 2021 15:53:40 +0200 Message-Id: <20211005135400.788058-5-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211005135400.788058-1-Jerome.Pouiller@silabs.com> References: <20211005135400.788058-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: PR3P189CA0084.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::29) To PH0PR11MB5657.namprd11.prod.outlook.com (2603:10b6:510:ee::19) MIME-Version: 1.0 Received: from pc-42.silabs.com (37.71.187.125) by PR3P189CA0084.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:b4::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Tue, 5 Oct 2021 13:54:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ce365ae1-1d6e-4971-341e-08d98807a7d7 X-MS-TrafficTypeDiagnostic: PH0PR11MB5643: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:773; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LtCFKTCv11pqj7HDlUEZg5LGfK3iqsCqeP+/HlMQ9oNR6nGaICo+Fwzl9aSvebXRmOMiCiUl3h+PokLQoRWdGEqwkQJ7nyBz7GlU2TTLb2n2tuFxXJedKiyjTOy7HaAyCJcURRdtuZlu35nAKe5VNpO6KVTWAhZSI+5cJhQe9c2GCrJ7pqrjDSyLOW8ugJoOKBmFvdhGtQedifWgv9//NE/MtZ/I3U1KlLsWarIIMOdUiUdK+zL1ZlbHn3/GcZ0Dw6J7SNyvzdGTnhzmudZ967seCvK/p2+Zsf1i8SyP19Xq85AmPkoK9Z+qJFHV5v7rXGtLRCCxu1xqnPmzV6ocpCWqrXpw+sxs57sP3Rr6s0uLqy2qYMkUxplQt+a960/r4RWimXv9ct4xqvGvYGeSTii5/AmSeEDwZqW0N+xMEhkwjkB+t19lHkMY41JL0HxZNQKOOhU2xsCgm4i4lyNrR8AY4HYXwHMBS9PaLx8XJ38zl7nNpgv4UsTE/QGvluTtmScd02pIF6mp75PuqBxnSTPAvqHhMcvHuAVoIXL2dlQq1DG//Qb93Q9iH+PhNtBs2AKcO5f/QqzaIDBVLbMYeZPbKL03zbaTROOfQl3WJqY3mmrkJGbrREmE3xibjdugjS6kLe56XQynE7GfHdQNQVJdKJCD5DZUvoHyw35KjkpDq/Ol9T2hJRbDJut8VI9M1kGJhq8Eam/7FEy2nVN4xA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR11MB5657.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(7416002)(2616005)(956004)(54906003)(8936002)(66574015)(36756003)(1076003)(186003)(38100700002)(86362001)(6486002)(83380400001)(6916009)(5660300002)(38350700002)(66946007)(66476007)(66556008)(52116002)(7696005)(508600001)(6666004)(2906002)(316002)(4326008)(26005)(107886003)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?+sdoTNi7a/kl/n0zgjxZnHg7V3xa?= =?utf-8?q?IOz0tcyq/rmRhBcLYuVWPbmlZm6ITut0xTfbkNnAzZA9fVOv3dB0dyb6XxyKv9sAZ?= =?utf-8?q?iYHtwQqiakmMJuTHenM1/mfZ/xPtj+0PDfd4gRY0WVqRQqdq0fEV+QHS+U0Jl703n?= =?utf-8?q?maQG7p6vdvAwDry9K7AvJlyXr/VPVJIZZxwG72vRWSW93W0UAL2mjZ/2WvPc5nnU2?= =?utf-8?q?Y073DGAqqLCooxp7uX/WHe9FS6l4jw/kbcHNC/519aMdv/sM/lWG/nybz82KP7H8b?= =?utf-8?q?h1RfTq4xZNKCKjeqHVyvP940QsaoxMjpA5/xazY2WXHwTGUOFt3bsDF1OVwselb42?= =?utf-8?q?7lEndk8HFXx/jTCe0uy3FFZ9B4h5p4glUlbxDrS54Bykl0NE7J0CInff9i1ULlzYg?= =?utf-8?q?UWarGuYZf2gsZIbwXITm59MnAYVQB2iOJSWPE5/Ztz0iA1UDactNsYjqSyiPHen3i?= =?utf-8?q?1Gl531vXBtqSiZzGd3L2ZsLoJzI8tgoN+IjgWGZSNk0orXx3fQvI63heVB8yd/e5o?= =?utf-8?q?kiIssv24V6RGrstYIwVpxI87IRznMNOvs8MMWxA1iQwbqkwQnLt/fT9k6KrgjDi1E?= =?utf-8?q?zDZ1oAut695dq1R+RGvdL02rZhK9uR+eM2GyzPpGai7REdsFZRxcsDEVBNGVLLd3G?= =?utf-8?q?rgWPiT8P+nOk0STHQ7CzHZdsjIxOdKEHEpeT29j37qB3s8jcHhMJ9FBsyZttONDWB?= =?utf-8?q?G832RC7nwFy7q32tRfHA4+5wd/oeC08ALSXGZlRE2Uj7UgonIYiTUAyiLV0ISNQs9?= =?utf-8?q?I9QJl/4L2DUBT38my5IEwKoUeFpWOA19Awob6XFdsyzjUSGPWL39zBkqhuoaVfgvD?= =?utf-8?q?NMroXQaxHe4r+eMc1ZEsi0MIsXVDyjb9qhXMpRKYsJXHz7u0kH57YezcVFqWqejdl?= =?utf-8?q?uU7Xg0I5dIIQbSRr98Dn9FPsdelll7e6QYNoPpN2OBJQJ9bM/P2ZpW7k5dM4xZ6KO?= =?utf-8?q?kO75MoX4iwNu51fjWCWxINGkjOfveqUfurgRcjz3OPS2OL9L9uMFrBpmyFVk2anV1?= =?utf-8?q?JarLjhi2ScTJEk6318eRUCXMDkYArDofKaZ6X9hZT8zdQeNnithoTBXb6z2Bnw3HB?= =?utf-8?q?rAXD1zgUyAc6DUaHMmaNTpVpPAx8Kqcl4WCwVO4DmVi2UgMxsLuItDAJI15RKf+W9?= =?utf-8?q?R0LUTuodvmkDNMHlhy5VE094YQ62XoOQg3dINEIOObtzHtvaWirkT4DyZSRlJ28bS?= =?utf-8?q?D4l2EFdE0Fla54D7aPN9NlKw1Gs74QxWyz2hedXYxOKyHMu7dCYxoZTjxzcdW7dft?= =?utf-8?q?6Z5sKIaGjS44s2hG?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce365ae1-1d6e-4971-341e-08d98807a7d7 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5657.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2021 13:54:31.3037 (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: rl9bsCKlfooKmRzG+mPYVc5QOkQs0WFs7GcrtbY61xbSu5sOE0SkCiRSSHshQhLvkGRzmfjx0wMn+t6B5iKmGQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5643 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller Signed-off-by: Jérôme Pouiller --- drivers/net/wireless/silabs/wfx/wfx.h | 163 ++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 drivers/net/wireless/silabs/wfx/wfx.h diff --git a/drivers/net/wireless/silabs/wfx/wfx.h b/drivers/net/wireless/silabs/wfx/wfx.h new file mode 100644 index 000000000000..84f5ef8ed068 --- /dev/null +++ b/drivers/net/wireless/silabs/wfx/wfx.h @@ -0,0 +1,163 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Common private data. + * + * Copyright (c) 2017-2020, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + * Copyright (c) 2006, Michael Wu + * Copyright 2004-2006 Jean-Baptiste Note , et al. + */ +#ifndef WFX_H +#define WFX_H + +#include +#include +#include +#include +#include + +#include "bh.h" +#include "data_tx.h" +#include "main.h" +#include "queue.h" +#include "hif_tx.h" + +#define USEC_PER_TXOP 32 /* see struct ieee80211_tx_queue_params */ +#define USEC_PER_TU 1024 + +struct wfx_hwbus_ops; + +struct wfx_dev { + struct wfx_platform_data pdata; + struct device *dev; + struct ieee80211_hw *hw; + struct ieee80211_vif *vif[2]; + struct mac_address addresses[2]; + const struct wfx_hwbus_ops *hwbus_ops; + void *hwbus_priv; + + u8 keyset; + struct completion firmware_ready; + struct wfx_hif_ind_startup hw_caps; + struct wfx_hif hif; + struct delayed_work cooling_timeout_work; + bool poll_irq; + bool chip_frozen; + struct mutex conf_mutex; + + struct wfx_hif_cmd hif_cmd; + struct sk_buff_head tx_pending; + wait_queue_head_t tx_dequeue; + atomic_t tx_lock; + + atomic_t packet_id; + u32 key_map; + + struct wfx_hif_rx_stats rx_stats; + struct mutex rx_stats_lock; + struct wfx_hif_tx_power_loop_info tx_power_loop_info; + struct mutex tx_power_loop_info_lock; +}; + +struct wfx_vif { + struct wfx_dev *wdev; + struct ieee80211_vif *vif; + struct ieee80211_channel *channel; + int id; + + u32 link_id_map; + + bool after_dtim_tx_allowed; + bool join_in_progress; + + struct delayed_work beacon_loss_work; + + struct wfx_queue tx_queue[4]; + struct wfx_tx_policy_cache tx_policy_cache; + struct work_struct tx_policy_upload_work; + + struct work_struct update_tim_work; + + unsigned long uapsd_mask; + + /* avoid some operations in parallel with scan */ + struct mutex scan_lock; + struct work_struct scan_work; + struct completion scan_complete; + int scan_nb_chan_done; + bool scan_abort; + struct ieee80211_scan_request *scan_req; + + struct completion set_pm_mode_complete; +}; + +static inline struct wfx_vif *wdev_to_wvif(struct wfx_dev *wdev, int vif_id) +{ + if (vif_id >= ARRAY_SIZE(wdev->vif)) { + dev_dbg(wdev->dev, "requesting non-existent vif: %d\n", vif_id); + return NULL; + } + vif_id = array_index_nospec(vif_id, ARRAY_SIZE(wdev->vif)); + if (!wdev->vif[vif_id]) + return NULL; + return (struct wfx_vif *)wdev->vif[vif_id]->drv_priv; +} + +static inline struct wfx_vif *wvif_iterate(struct wfx_dev *wdev, + struct wfx_vif *cur) +{ + int i; + int mark = 0; + struct wfx_vif *tmp; + + if (!cur) + mark = 1; + for (i = 0; i < ARRAY_SIZE(wdev->vif); i++) { + tmp = wdev_to_wvif(wdev, i); + if (mark && tmp) + return tmp; + if (tmp == cur) + mark = 1; + } + return NULL; +} + +static inline int wvif_count(struct wfx_dev *wdev) +{ + int i; + int ret = 0; + struct wfx_vif *wvif; + + for (i = 0; i < ARRAY_SIZE(wdev->vif); i++) { + wvif = wdev_to_wvif(wdev, i); + if (wvif) + ret++; + } + return ret; +} + +static inline void memreverse(u8 *src, u8 length) +{ + u8 *lo = src; + u8 *hi = src + length - 1; + u8 swap; + + while (lo < hi) { + swap = *lo; + *lo++ = *hi; + *hi-- = swap; + } +} + +static inline int memzcmp(void *src, unsigned int size) +{ + u8 *buf = src; + + if (!size) + return 0; + if (*buf) + return 1; + return memcmp(buf, buf + 1, size - 1); +} + +#endif