From patchwork Fri Sep 17 15:13: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: 12502535 X-Patchwork-Delegate: kuba@kernel.org 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=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 15B0AC433FE for ; Fri, 17 Sep 2021 15:15:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F17F861244 for ; Fri, 17 Sep 2021 15:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241360AbhIQPQz (ORCPT ); Fri, 17 Sep 2021 11:16:55 -0400 Received: from mail-bn7nam10on2088.outbound.protection.outlook.com ([40.107.92.88]:46465 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S245045AbhIQPQD (ORCPT ); Fri, 17 Sep 2021 11:16:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lOcuVOiwjtiCqbuZILN6FDm2Jpz5dHLE8y59fYW0cL21PBphKm4Ei0xtLyfjofykF03hutE2QimhZ2Bi1Z0hqz+vveruoOemgSfRvMT6gkq5vWvyh9RtYejfKSeW9zpJLllq629HoOqL8yNcQcX7E5pMhpeNgqoomPftf1ZDT+0W6qOCleE+XnpclIoFMGLtYxzB0uelSa/IQqfCeFchACh2eXT7y/jupccpRnhMXA72Blws8f2u0Qdf2yLfIewnaQXC9TZQupqSbXh19sXxSe0PiCjQAuOtCqGQ1Rmyc2gRqKNiBS1DUnzUg++K/0X9x1SOvE3AxvgDdVgD7T6D/A== 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; bh=YReMQuBIPzwL0X2SQqdaw4bILayGeux92jRvC6HO64U=; b=mkb3/A5wTwqxcSQU5ZHNh6sZN9+nxDlgoDBqf1ayG9M9111C14MHp3jK2cXTiuQ14VL01pMfO80DbyflYXBy1Gzk4nmnZ3gh0uyob59ezK8xWOWwWCcGSWVqzOR9Ngq57HSr17EzHvmK0cbWlLNt7///QxtP92pzapTdQddIG7J7urCli7h/QkdA3Eo39bqjsJcNB5L7NKZ1vmncVMu3UVisjmsnATq9naCaJL7WJHXs7fsyxBOs7ywbl6Gs2ABqzvCJlI6Zl22SNkhdgr+vhd7MtexuL+WtntSZUOTNbbSY2qE1VkKO3FyC4QpVIJFycc9kAA5KOIdPGBYEdyx6Vg== 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=YReMQuBIPzwL0X2SQqdaw4bILayGeux92jRvC6HO64U=; b=NsHvOY1HIJ9gMpzeLRPvj0UtsU59YcQanLgkCXYs9TNTokDKGncgnlQIjInirenJrIFQY50xJWUtUdVcl7+kpHh+aak0IXexKiE0edu1sPYD8G1lX9G1ilw0mS+XTwLR7ouJTkre0RBkTp1xqgTFixkDMF/jJainTo3XvO7gu00= 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 SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) by SA0PR11MB4574.namprd11.prod.outlook.com (2603:10b6:806:71::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Fri, 17 Sep 2021 15:14:28 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::7050:a0a:415:2ccd]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::7050:a0a:415:2ccd%7]) with mapi id 15.20.4500.017; Fri, 17 Sep 2021 15:14:28 +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 v6 04/24] wfx: add wfx.h Date: Fri, 17 Sep 2021 17:13:40 +0200 Message-Id: <20210917151401.2274772-5-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210917151401.2274772-1-Jerome.Pouiller@silabs.com> References: <20210917151401.2274772-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: SA9PR03CA0029.namprd03.prod.outlook.com (2603:10b6:806:20::34) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 Received: from pc-42.silabs.com (2a01:e34:ecb5:66a0:9876:e1d7:65be:d294) by SA9PR03CA0029.namprd03.prod.outlook.com (2603:10b6:806:20::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 15:14:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4391df48-e124-4af0-f603-08d979edd798 X-MS-TrafficTypeDiagnostic: SA0PR11MB4574: 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: DJ2pg5ynumYgttNLk4FrtgduIu/PJzZyN1024eKuKVoBRkt1U2mewg3HG5qeK9dQl7Imr2eCU7KzdXtueyDkSu8vy4nkA/e1eoVLEg6X4V3SnUfxlKgY7pMsc1uDPmCKjSSMTjbOoehl4BI/JMbHLVr8BHXjl03jGgoeW/QtNkg9WX4D5NrQVsVVhm4nCkecjdhna+yH7dvJzZx7bNFvI6W8OdA5ErdmSszcREbcqcfhmC8cZHmZpu4cRH6J9MZW4oTK4WtCVPNjfxuAftiMGkDb97BN7yv5W1wiBJ7R2x/hxApooW7aQ1hHV0M2hqlugU26YdkoNUAQkHLUCOl9x7QDYKjUWGWLJXX6Rud+JoEo+qoi+nvbUSNZpj3UWNmAe8ybBQtWU9jyVfkR0u7/Cq6stdpotI9No2VKi4aeo22HK8g54srtiPgBAn7TO/Bozoz3M7QhS1VZNKoeEPq6fMQVqSRcC7Jn/BXK1uDsP9Y2LkSy/JHwV/DtEFrOQSh6VfRT1mh36FNaOdUCAtQzsMlORnP5oZ5iFmorVgRjQFtSntmmY2ediRzqKOwD+L15SsVM1GXJnsgEtJ+8zq0QxXNIjKEjYRp7DeJk2inWqiKdDGKDwjR8Ccu600qyBWyC1wuAZ21mjhbCFQ0ArAwKiA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR11MB2718.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(346002)(376002)(39850400004)(396003)(366004)(52116002)(6666004)(38100700002)(8936002)(7696005)(478600001)(6486002)(186003)(7416002)(86362001)(5660300002)(54906003)(66556008)(66476007)(4326008)(1076003)(66946007)(2616005)(107886003)(6916009)(316002)(36756003)(8676002)(66574015)(2906002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?e1awcGpH9dxYJEhL+GsgX5WfRKOs?= =?utf-8?q?Oq9OHLsZH07tPf/Y+Ly17drA4H65X8LGW0e3c7WVvhb6mbHYf+G8VelmbKcL+5zrw?= =?utf-8?q?O9ySrGI+EfUriRNC5lAW8Imm3yW95zV0K/7jyzE3n+BvCowCrnzWDliJvAGxj1KfV?= =?utf-8?q?bJsxPZgyQC7Zlr7nibPmdCyuQhJCLpD1SnWzCM3Fa8Csi6uojYbAWelvO89nYMvyE?= =?utf-8?q?OfgGklEwiiXINt5CNDavkrkCKzP7Qzn/SORSdCgxD4/a/m5uvZTfXVVN3hBky8tGQ?= =?utf-8?q?yiDWe1x99zC3ldX4ftVHxhuWSpU1F2oPTALuuFzyJZB/2krpOdUM5Ti5BNxJwAMNK?= =?utf-8?q?//1aWBMWfa6LLgRkeSJznWI/xBVdqrM8o48zXW/JOw9lkGBlY3xwd5gsixAeTnIJM?= =?utf-8?q?UL0gSLNs3uu+AGNKoW1hLAwke+0voduCYiN9Gb96cyJLFCsCEfvFIzvGVpRH8eP+/?= =?utf-8?q?plNNQjrx53XRBSK/eHndKilAr0Fy2UWFvUP6/ZjD0KuuPOEdTNHCyd3KM6s6Hm7tF?= =?utf-8?q?Wwgn4bUN2JAHGYAwslr4v03BClqtRSYI2w4qQWOgOitCkRAfzL0rr9HZjuNF8HYny?= =?utf-8?q?4uhu/yf9bef6duNrf4F75Qreimxj+96gOo4P2Qiwe8r91TdplrPNuHLmxxN8xptgN?= =?utf-8?q?DTG6phaboK//FnLjbzZBAIQp7+6GapdBGCu1nRLvPf4EEDJ7S8jUxgG6LBNoN9ucT?= =?utf-8?q?4+umeMqV6NMQAtjN+oVjgrIb2VvjPyXjIj2555ZItplUUBL1IAf/S3ew9+NHgTMLe?= =?utf-8?q?YBEMYsCe28MNsggG6pp/wdTbnzH+ZhgsIjiKyZ4ifePQ1Eg05/ywGUby7q+iJ9Y2q?= =?utf-8?q?D0AD3yUnAOqcVgKQOtCm3i2v6QstRFnq583+OLnjwmgp6z2YJIeMS0p8TzzVl3YSg?= =?utf-8?q?0wsc8G/70kI+FVOMb1i9QLfRTVJ25uFK5/ueicja81iGqS9mJZez9klZzMXbzUhpH?= =?utf-8?q?2iDUKX6IMklNUPW81IRH2B1hkFxmPwt5IoWsknv+h8TkA6bY48/y3u8uEYnFXUUM+?= =?utf-8?q?0Q3gihKnR3G7WB/WAOBIrgEPn7LqyZF+92oaCXepSqgGkggXvzMRgcbMp73I53iar?= =?utf-8?q?roUVO+NpNRgcBWqLmvVLm8VlwLvJ0+0MiR021P+uE1Q//wNrVWha8wOyqnN/GxKE4?= =?utf-8?q?b1jpVINi7i+LNu3jw5FoF2McpUjSgivmEXDFBM2n+xg4NDpOevTAx1hat2ZKQr2nX?= =?utf-8?q?qyF4dnaMfz/r4lDhTKwdYM4UfmOp6XtP8FBPWUree+h8GrGgfvRCgf9Vl29XUykL3?= =?utf-8?q?hIIcV8IRo5oHUsJY+cGCySjQogyRQMng9+04hb48u3tzDRKKJkJdjAxEm2/j0Rgg3?= =?utf-8?q?cGlAfsXcEzknxhx?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4391df48-e124-4af0-f603-08d979edd798 X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 15:14:28.3580 (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: eZF/A0juVblIkSoPdUu8EDeKXCaWYhZRbFqkuFMqOuIBWMr4KwarRzR4ZnxsNweRkOWOP8tmOtppxOILnU4C8A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR11MB4574 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller Signed-off-by: Jérôme Pouiller --- drivers/net/wireless/silabs/wfx/wfx.h | 164 ++++++++++++++++++++++++++ 1 file changed, 164 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..f8df59ad1639 --- /dev/null +++ b/drivers/net/wireless/silabs/wfx/wfx.h @@ -0,0 +1,164 @@ +/* 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 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 hwbus_ops *hwbus_ops; + void *hwbus_priv; + + u8 keyset; + struct completion firmware_ready; + struct 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 hif_rx_stats rx_stats; + struct mutex rx_stats_lock; + struct hif_tx_power_loop_info tx_power_loop_info; + struct mutex tx_power_loop_info_lock; + int force_ps_timeout; +}; + +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 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