From patchwork Mon Mar 15 13:24:41 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: 12139399 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.8 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, 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 7CF6FC4361A for ; Mon, 15 Mar 2021 13:26:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 55E4064EF3 for ; Mon, 15 Mar 2021 13:26:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230354AbhCONZp (ORCPT ); Mon, 15 Mar 2021 09:25:45 -0400 Received: from mail-eopbgr700069.outbound.protection.outlook.com ([40.107.70.69]:1217 "EHLO NAM04-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229746AbhCONZe (ORCPT ); Mon, 15 Mar 2021 09:25:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jHFc7rqTc//REprj2arqRyNZEydWHmTlVP3b1jd1P4db5n3BT46SGv3TrltNFcW/dMS/+CJqCWU8nEYeJeK9lUQTVMFVscU0fc3HbDvOZEYHr0sBCTokPkhBP198aSRSDjvAnF+mcDVAMLHwIWRkpi3zYEeKqF8MVUFmogYqxbGO2pHQ2j8PiX/vIEsQ/ww2hYkO+lOjpEGjbMD6fynXfoSJzyoqJcakcoYAa/1t/z1js39ocRg1w6EylufO4EkHccOhaWkB+IMGQbcZLGwUIcJ8nk+ZKsZiY2iu6OoOYAgRs+REdRSZPO59ZgD+aVeWJhZhvLmkpcwtpGMGn/PmeA== 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=2ADRqIU5wHdazPyKRxcztrHu28gHVw/I3NqJUDoR3lc=; b=XTgwLVsP+mILw3pPy87D6q5vgLPHxLrIWgXT4OxGKtMoGE9k+/VeIeQGcdi3DIvkVX40FbpObH/H0FMPliDovNQ4E7E8PE73Wskzf4dG2rqLBDhtse+saGR24svLv6lV/dQYe9DM858b3BRUcxfEYzaruzumtbp9FL0C9KWuGeMFGblqYy6S27eL6EB1E7HLVZdVu2S1LmK7eimNIsz14Pne8JmH5cR314+Puj3SU3KNQDFDk6Uv9fIyBQtOOidKCXHrhDr22Hr1uGbvt/vlmtM+Qw5h16SQWmvBhekaUe/6LcHpuslrUBBXpTBTgLXL0lTAfrUTjSd3U+w4r1A2jw== 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=2ADRqIU5wHdazPyKRxcztrHu28gHVw/I3NqJUDoR3lc=; b=FEFVVqel8NNuovQkGNRW7s7iVC8Nk8illeAoyn/6APy4t6CXt65A5D6TYaGu8t92yVN/YkAq6eHiLa8CpJvj5E/S8GAhdBoOoFiRI94Eq3dMNzQTgYKXbJ/e4szNdzjkSVfeDpEx6fxPNoDo7cWeQecAYBJE/slCzTcGBi+M9C4= 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 SA2PR11MB5099.namprd11.prod.outlook.com (2603:10b6:806:f9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.32; Mon, 15 Mar 2021 13:25:33 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::41bc:5ce:dfa0:9701]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::41bc:5ce:dfa0:9701%7]) with mapi id 15.20.3933.032; Mon, 15 Mar 2021 13:25:33 +0000 From: Jerome Pouiller To: linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , devicetree@vger.kernel.org, Rob Herring , linux-mmc@vger.kernel.org, =?utf-8?q?Pali_Roh=C3=A1r?= , Ulf Hansson , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH v5 04/24] wfx: add wfx.h Date: Mon, 15 Mar 2021 14:24:41 +0100 Message-Id: <20210315132501.441681-5-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315132501.441681-1-Jerome.Pouiller@silabs.com> References: <20210315132501.441681-1-Jerome.Pouiller@silabs.com> X-Originating-IP: [2a01:e35:2435:66a0:544b:f17b:7ae8:fb7] X-ClientProxiedBy: SN4PR0801CA0014.namprd08.prod.outlook.com (2603:10b6:803:29::24) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (2a01:e35:2435:66a0:544b:f17b:7ae8:fb7) by SN4PR0801CA0014.namprd08.prod.outlook.com (2603:10b6:803:29::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.32 via Frontend Transport; Mon, 15 Mar 2021 13:25:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 06d03887-c193-470b-fc99-08d8e7b5cf8d X-MS-TrafficTypeDiagnostic: SA2PR11MB5099: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:773; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HydE3vzJVWrmmskyd+IZ5PTeTPsQsJbPX7zGnYSPnXmf0U+Nirw84q6xbIoL+qFNcWkeu7u3fYQmc3qKEpl9ty/YIAb8ZMadcE7gwzoTiILQhsuCX1WUi9KetXIsWo4xUaiDbOGPmFj98hsBlip0gdHYyEAkjykQRUXa+gVcMBCyDlvRZ6HuLY4uM0xS+t5M+fk6YG/O/V2BJ1sGXf0uSJ5iKO51V7Rnxu90GmeO/vwKujGeASjy/hOpPWnTcvvKUzX2Z1vdFOBtW1sMzO2O7Xe728A8+6g7NuJWfjXUiFqzfGwIx7uy1chkeLyHg02oCCxrgPQ8oYiZGhnxwdDcT/urbo/GUdK6q0oQ4qr94XED9Yb0+OrllckHFtbXpNBZD5paPawzngydI33OG9dc4ao5hCstopcpOX79wYuQHKwFArHNqUwJfR2mrInSuQwVact55vfWSAg/Swer+6javzM4M28S7F1z/jdkHVComQuphbsMgsB4rEkbtD/kUiO35ce6jKU65E/XWPuD8dTWdVHSMIif+rrAvTjZYLkeFxZbW5UEqzMp5zrYzIMkm4/J 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:(346002)(136003)(396003)(39850400004)(376002)(366004)(186003)(7416002)(2616005)(107886003)(4326008)(478600001)(83380400001)(16526019)(66476007)(86362001)(66946007)(54906003)(66556008)(8936002)(316002)(5660300002)(66574015)(8676002)(1076003)(52116002)(7696005)(6666004)(36756003)(2906002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?ZVx11Qcm80KkpzMG1+rguONKwIea22?= =?utf-8?q?yTBdtOTkAZR8trqKvA6ExTR6I6abyoSZcUXH8fJPKLy2YW6vcyRf+O1Q4GRvnhkT4?= =?utf-8?q?iOGP8EDcBRPb2YTVBrCGoMd5sIEJQ55gBXqlavel9DA4MAXxXQeZM7mF86vhTIgcJ?= =?utf-8?q?VpthatvN8w5AZmhJ2HHDZZufXAG7XaJpF6Wa2U8j4rmZvfFgMg5BPlGZJuXZEEjcJ?= =?utf-8?q?BX8tmz/0NUcYcUmLQEL2QbAf0gD3bxxZx384vyE1xHM6vkWPHukXl+FMcyc5TBCEC?= =?utf-8?q?MJZh9Fvkpqx7HY6A74RRHTJugnhVQYp3+Mz0cLx4ZxzfkwTeFCcrwpXd49rxHbWGe?= =?utf-8?q?lhfnkaqfLww4A3ijr8w+g9XNZqEXmssj3fJMougRdwggEWiMw79Fcp/Xu7I19B1PD?= =?utf-8?q?Y9Y2Dst8Lq1Y1mzeIMkkH4dRkZdF3mkF22VhKt8w62cxPEtAQ7y6r27CtAtBy8xuk?= =?utf-8?q?pAw7d803PGQ05w8VMVTWRtTDrCzROFS7GjNCvmDVAmZ86A/D44C5ei6enQKr9is0p?= =?utf-8?q?LD2OHpSDgXuuNfRTilO1O0YQJjRMUE4oJNk+yJf13OdQ6Zy5EzG6un+GSgsz1N2M5?= =?utf-8?q?JAKg+rZJ3Zon/oZpyLm2L3ob8/M5pFc4xBjzMMtgEaTwhzvJYo+dSMWGD2ShzqncI?= =?utf-8?q?5JAfSYobSzCCEzs5zNWkMv7z8XVOlbdyMWdWFED+8CL9mrpA9XDx4T/wOdx8lYCEv?= =?utf-8?q?vjRV7R3+QHrGj91LI1JJoGQvpeq5h+366egsS6G/hSpK14MtWeTJisjqbyFbbHb2e?= =?utf-8?q?zKeqPeo5koU0v1UBMwcBIetAPd3b+hMnlu6Ja5W6jgVpj5v6H2kpdACjUUP6cHc1m?= =?utf-8?q?Fg7ToDFXL30S92PD1qLJ30vsQoFEpWOYuTpf3+/PcKeI4a3S2Y7rl1W49qSVSVAjH?= =?utf-8?q?BcV+BjQQRy1YHomQG8lH9wfByOLPItukA3m4JsYb780SBGMzxTJORO14P3LIian8j?= =?utf-8?q?ThLMsMwg5Ti8+4/V9qp7JAhrHCn1bus38uLwEGflF+zD3L6vZ29V0y/91ruBNoaLX?= =?utf-8?q?ggCHHbpmhxzbgb/4TkOR7nKqYNBoJANH4uzzZRdMwGWpUA3ioTV+NgK7M6Zbk3gGm?= =?utf-8?q?jvM/n30VjGm6BoxqTVWgYGnkFi/8kMAIF0PVSRmaLwYH4YIOrM3vI+2SAMuEZQg1j?= =?utf-8?q?NYXB+7nmv64PJuem78V0SYt86ZjEZlgpv2gyAvpHECYY2S0ILtBpa7yBYjsxxjhxr?= =?utf-8?q?gGt+p1YMJhMHegcH2ldCKNoykCq5aH0CcA5Nm1bVMgKL//KSMAwljrV9qVxhujUv7?= =?utf-8?q?8U1I+GhgUpEQzcDHBII/qi10/sMkmbRwppLnGy2gUIG4PYmmA+LcelSUu7LNPI+sI?= =?utf-8?q?LQ1L2TT/FTCND?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06d03887-c193-470b-fc99-08d8e7b5cf8d X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2021 13:25:33.2659 (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: UomSnkgcdqLr+fW4ewqzkTDuUA7FZ0V50FzGh9py2wLY+r2VDU08o2IaUknXMgEPmtzhcaD0fyFWSSAxj4qQWQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5099 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 | 166 ++++++++++++++++++++++++++ 1 file changed, 166 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..ba18bbfacd2b --- /dev/null +++ b/drivers/net/wireless/silabs/wfx/wfx.h @@ -0,0 +1,166 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Common private data for Silicon Labs WFx chips. + * + * 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; + 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]) { + dev_dbg(wdev->dev, "requesting non-allocated vif: %d\n", + 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