From patchwork Mon Sep 20 16:11:16 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: 12505861 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, 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 8D1CAC433F5 for ; Mon, 20 Sep 2021 16:12:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78A9261166 for ; Mon, 20 Sep 2021 16:12:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242575AbhITQNk (ORCPT ); Mon, 20 Sep 2021 12:13:40 -0400 Received: from mail-dm6nam12on2042.outbound.protection.outlook.com ([40.107.243.42]:26081 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S242440AbhITQNb (ORCPT ); Mon, 20 Sep 2021 12:13:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E2B4OgqDzFXlnjg/RMBCseCgMNt+FJ4P0DYHDH/re/8Rii1tkBpFGY2Eh54i+lF05u/PjsDW+NEaxfnpihseo8t2Sc0iZDlAt8K8zn3eRp7DKWEMymtTZ8zdMhoJP3L0nFZSayJmJIzmwk4HHQMG9eYlyRu8e9zcbxW6Gi23FzKtPTmJqBzZSqTmS6Fgl77C8OYDjTBQcpVX6zoOzqW1rEpe1rcqGDQ3NJ/9dxgBXP3RaY4pYMtEeQTqIWx6YVecAhTfH5hakLv5/obBvjFwF7haztxnMDnDoaNUSvkl2SSlAh8c+8HLWic/xM3SVh5+/B7kDgVXqSHk9+VRBfF3Sw== 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=Ezzkeu1J8qzJ6wmRIuWgdud74yeVVA3xY4ilmT0N2ipcl++OcM+ii7G+snYLNx7WJnK1UEwuhRAYEVfAGXffRVTL0vsyHHzEPN58+iLpsrjEHEK+DJh+GV8ZMDEOvneeK+UMfXuxoJ+B9gPpgQesu4eY43zGXXgVUH3v9FfNavfX21W4FZwMsvGbR+f8Q2Ryt1imQruMI2vwwqiFr0nqZMoToPRuXZdBG5rOCJWpTMY+RwWsBP3gaxcuXWD7fJytjofVjr7bsK/T+auXAOii1SndYS8xZGIBl+hr0v3YgF02jia4bLZAvqV03pGpGFd2ic7f09ev5O5052X/CzjZ/g== 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=Fh5mG9r1bRvj+c5vVCAKKUDHgXqDsKyVGN2MiBOQNAbIt86U2umNPjCf+SBk/YQ3z2cOnvbt/oxr0nqLhrTXpADStKRv6VXN1aonbLA+39ftfHjxuoaaGM75XtyveFtIYXaoJaC1DAaoms6Nd1vkPjeTpTAIZhcOLoHVocNmGrU= 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 SA2PR11MB5002.namprd11.prod.outlook.com (2603:10b6:806:fb::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16; Mon, 20 Sep 2021 16:12:03 +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.4523.018; Mon, 20 Sep 2021 16:12:03 +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 v7 04/24] wfx: add wfx.h Date: Mon, 20 Sep 2021 18:11:16 +0200 Message-Id: <20210920161136.2398632-5-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920161136.2398632-1-Jerome.Pouiller@silabs.com> References: <20210920161136.2398632-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: SA0PR11CA0064.namprd11.prod.outlook.com (2603:10b6:806:d2::9) 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 SA0PR11CA0064.namprd11.prod.outlook.com (2603:10b6:806:d2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Mon, 20 Sep 2021 16:12:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 816aa8d7-db5e-495f-cd1d-08d97c516203 X-MS-TrafficTypeDiagnostic: SA2PR11MB5002: 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: 6qvBmaFrqJ+i9YvPmPZOtNzzoydLBzEhfRN6Qs1jcQC3agHNS441a374Dd1POiGcbrPlgC9eIjFNlNqu3OUimc+Jr+iaS8qQIa4Vl9eb+51rue67FqgsX4sNd0zl7h/O+lr2ybTroVTk4Td3SsGZcHAeRtTXvtlrbqfIRa4ud/UKHRShgKk0zx+BvUNapnDRRUEAjRZT4p/IlE1jroIg8zoaP5X7nb+fmkGMob3qz6jkwrO0VQRAI25kON1Jgh0Rzc10rR3qhJfmlbTEYHZBHXKoJVGG4XRUEyzH9FvlgdQ165kUwsZ5JZjCV//Z8oRwWwWx1Gh9Usv0KdIZAQ/b9TR1TBQkhOjYCGWQ+NRXzRnvs0d8+F87JbwWS/beRykZ1Xd17jvrfUV3DZ7M/nweCxxxcXkmCzpcY9a/8G7sY5eKinQL8hACAh0H34mW+k4KPjQw403An231CG7IN35I5Lisps8Et5RszXB34DbgR3hLzaBzGgRlUxJ/Fv5oqtaQGAINu4AOn3MuMU1MX5o+Hen7dZ6J6dNUokwe87AUl8uFt+xhyq5DDwb8sWRarp5haOp5LZ/XnBvMGSOkUEXhdyUaBenhOWJ+X6gui7SrLpzTlgS0BK9L34OYZ15Pp1uf3LXDPA6BaaBJnjxBk6mf1w== 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:(366004)(66476007)(36756003)(2616005)(66556008)(107886003)(186003)(54906003)(5660300002)(6486002)(66574015)(66946007)(52116002)(38100700002)(83380400001)(7696005)(6916009)(2906002)(1076003)(4326008)(8936002)(316002)(8676002)(508600001)(86362001)(6666004)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5AlCFuwwkm56xHhgsvTn7gOFv4dRXqsawEYPnF9gdPLP34FgKKsAQeLsS2HgtdpXopaNVOoFChkZ4U6fV7pr9xCzTe9clOJfPRaxpmGjF4RwpLFfg7RnnCXZp2AMtQ9HUl2DX60RG8GtjdMGCLH5JUZY29mzjr2TcHO7jxPQLFBho9vx3r6LOkVCK4zcPJ6dTENysNS2OYqiwI70Hazt5wnt1/IEBxodtX3nDVIOD8WGUfsfdeaMkym+vUJZKD9WWfsUFSj+gbvfzkH7wW8jnB4IyhiXLhHc2UoEnwTA+JVScc0AphdMElX6ZpzORzn0cMl6ZNFrdXg5rWwwg9T1aQucSeFxNFgfUoFqC0b7qLvYEA7DrXC/VkIOeoaqd2uVDtQDhn5H7fRwSu4PyiRgzrte6Y60zJlkwlTWnI13baAbYUFXvuS1XkEzPv3PpGE2Dz5SOErXGy1miTkmXBncbEeIXdKKqffdpiOFqSqO/ZnfPfdO49xt5lHMlK6b/6ENywuOS5ccxRqlYP9a90FkJ5U1uDGlH4tGnB4yOsnQMdWU7MQRkYlB/rora9dTzvRXGduQ/En58DxLAPduZndp5nG8fVNow5trfWPZL2hTX9Yr1IPuk87BBNR8so29/QeFpga+xehRdyE0GYP+YpOQ1XXLOEDsDSh3fW5vop2XUj8jzUQkMrv22okX8Rk7463HV+qzv7Ku+QIJKrjdNgc4ZiK6WUfzHy41ztmgRjYTcbteutkftq2D+aE8/TYDKxez9+U2xBocisUHppKhZDBqQj4xvHJuPI95v9WKnTesp4maIRlGAu2Zd8LLgTsLCMi0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 816aa8d7-db5e-495f-cd1d-08d97c516203 X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2021 16:12:03.1055 (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: /7pU1F51IwzlBlrLv8Zuj3D1DC0OwsMj3jZiHwIB1b1PgTWY2yolztj4J2daXO2UXXV4QGEw0SyQn8wDtWyipA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5002 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