From patchwork Tue Oct 20 12:57:57 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: 298752 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=-12.7 required=3.0 tests=BAYES_00,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 E1F28C43467 for ; Tue, 20 Oct 2020 12:59:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B03C22404 for ; Tue, 20 Oct 2020 12:59:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="bDTFZwNp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406840AbgJTM7D (ORCPT ); Tue, 20 Oct 2020 08:59:03 -0400 Received: from mail-dm6nam12on2042.outbound.protection.outlook.com ([40.107.243.42]:21473 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2406822AbgJTM67 (ORCPT ); Tue, 20 Oct 2020 08:58:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pva2+FadhiNrQUOx1o9TdaQuK+Ntweu9BT5uZYXOMz5z1XdJuNaASqwuXTCG7qvtuL4t8SQsYc2cU90pfbNLpVYdk56dXKe/eOyHykPtY6GdnjUuS9kUkOZ7PpxpfIBwoSLX+3zLjlv9E+dc658Om/Z/YjBxJ4q0OXbplXTTEH3VMoN15AKBfHn8YCsEZA3hvs9IhEFsv4GoA5FJvfBORukSwBtO3hL4hVthTio2zoA5o1saQq5E6KzXuMUqOVoT4yvT7HTAE8Nd2EWTmTxPZlakZnmgDSpDWZF/LEhhwdGDgSzZOwzUANooSlRevXo/ouBLfsJklYaYlek6FwjKjA== 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=RqZzTE5IDNzLeiEeh0gtmEhR+vjHmPP5GDL6eBo8e3g=; b=BnaGMEN0rZNsJmDbl/w8vgVr7ECcmhue7n+HB4B/lKMvHSeYM6kgjJd1cZb4doeOZ6M69SebPwfp1OA9onPY6FDWkMVlbdjJ1u5gmGtHRYzH3r8JxZmfK+IoJxVFfc4plEX352QovrkPwkyhsg5L+LS217cQBOgeyVx0hXGXnG50UkoB7RLqjw5wfXJa7iufbz7E7FtMWAffbzF1YWvASsCfTZyW/qCmHT/JAYwRhm98IiHeBmC8m9SkvV2JFicC84CIYSjtJRBNa+se6sxFemM5kWX2iXL/oVFRx/Cq3GRWHA/ALZj4VobVjYSGjG2Eom32Tm7TFGE8Dye9ef7Pow== 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=RqZzTE5IDNzLeiEeh0gtmEhR+vjHmPP5GDL6eBo8e3g=; b=bDTFZwNpVv/QiHt0ve0C21pWE+SptVFsNIh0MF9u8vKIM7GkvF3aWFcxematvy7gmQD9IN8vXKpIMG6yS7jN4NtlxpHc0UTz3uB9hSTiasJF+d9lfFAfwGNEPw2xPjj+ccDrL+Z5HkFcZA8Er9y+mlDZ5EZTDEbHsa6qG9+vG8A= 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 SN6PR11MB2656.namprd11.prod.outlook.com (2603:10b6:805:58::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.28; Tue, 20 Oct 2020 12:58:50 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::4f5:fbe5:44a7:cb8a%5]) with mapi id 15.20.3477.028; Tue, 20 Oct 2020 12:58:50 +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?SsOpcsO0bWUg?= =?utf-8?q?Pouiller?= Subject: [PATCH v2 04/24] wfx: add wfx.h Date: Tue, 20 Oct 2020 14:57:57 +0200 Message-Id: <20201020125817.1632995-5-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201020125817.1632995-1-Jerome.Pouiller@silabs.com> References: <20201020125817.1632995-1-Jerome.Pouiller@silabs.com> X-Originating-IP: [37.71.187.125] X-ClientProxiedBy: PR3P192CA0026.EURP192.PROD.OUTLOOK.COM (2603:10a6:102:56::31) 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 (37.71.187.125) by PR3P192CA0026.EURP192.PROD.OUTLOOK.COM (2603:10a6:102:56::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21 via Frontend Transport; Tue, 20 Oct 2020 12:58:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: abe8dc02-a827-4651-1ba5-08d874f7e3ea X-MS-TrafficTypeDiagnostic: SN6PR11MB2656: 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: F3vWLWBKpVj5+XcIRaD8WXXXWb57A3kJU/uu2W7/AuiUWhWHL+lrBg1UibqKgSp7AgNgYdrHj29uV6t80JhSejp8TOHAGCCLO2Pn0wWthyxeeR72XDtxmzYl8m3NiT3ZAwEM6RIzF2GlJDrTRqGuMygED2ns6obHOqkhkNmxwoZRwZhaQ44i3O/3zNYrSfM5lqF2Cur2I2BbLmUV6oZdOAHXZhc3uXXtBk8gelwc4rKy89y7dqrXoiLhrExeBnWZ2Nn8TvzBybD4HPz3E4nmlSGbsGvCR8LAb5QHPkg7SPZLPSsAmu2qqOVpiWJpH7IZW9BR+yvb8gZxVdSjmZUsEg== 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:(396003)(366004)(136003)(39830400003)(346002)(376002)(186003)(316002)(4326008)(107886003)(8676002)(86362001)(26005)(2906002)(7696005)(478600001)(16526019)(956004)(6486002)(52116002)(36756003)(8936002)(2616005)(54906003)(5660300002)(1076003)(7416002)(66574015)(6666004)(66556008)(66476007)(66946007)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ZwI5MZRso7cIz/VZtR/e2EZXHND4KI0YColOkD3kO4R6/StN5VVbsRjCeLxUjn2e72E/Ay2fRxd3BlBf4SZmho0uPG0rg6EPHnQNeGDdoP0EoOwQvl08REbmFt589VDbkSnPvSQcfXjc9r7M5+LMRxh86UJrm63nwUNxln2ChezQCg5Jna/dRCgGqbu9tokStkwxmb+1da0koiEi5REIh2c9CyfGRLxmR4eI3dRtcilzaEw7xGTvzwNde4NhSe1js82SmMVsI4BGNyShT220KmHmdTL0+C3dD41JZDkNuJd+VN6jnhdyQftShlw53gC3vEWDmtbvE7ucfBVNzhvQlRjf01aK9Se5vVg++Vwabw+/WGXmwE/7X2zW5EnGDwfJtBP4mDqesq8Nw1VplvTPx0rMqAzklylE8zRg06elXG8TAifS9d3ZVuN9Ml+iQVvwamBV+3pfB6tF9QFqzS7LRQA6h9wgIaZ2fVZgYd/xLPZwjGd3EhMQ/e+CLuZex1w5QPHwnp6EvyLdAebcQ26MpZyB+ZoCqw69KTZHELTno/MnpvKa57nCg+deP9LCMNZtFOgZDwagjucV+DXckL+DHyqDIEjlhIO7SALdxzHTbpAlJWCUhJPKS2sxHOaAUdWug7R9yGz6IkoJw+c7pD529w== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: abe8dc02-a827-4651-1ba5-08d874f7e3ea X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2020 12:58:50.3689 (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: tS8UjGPCak1lMpXt8u2IIgkMU2zEzP/ft9VxbMDDVQC7E9DnEQXxwYQkWXkzgGTXR3xUywREphiMg4EX2c56XQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB2656 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..94898680ccde --- /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 /* WFX_H */