From patchwork Tue Jan 11 17:14:04 2022 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: 12710073 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F03B3C433EF for ; Tue, 11 Jan 2022 17:15:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343978AbiAKRPD (ORCPT ); Tue, 11 Jan 2022 12:15:03 -0500 Received: from mail-dm3nam07on2065.outbound.protection.outlook.com ([40.107.95.65]:38465 "EHLO NAM02-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S244420AbiAKRPA (ORCPT ); Tue, 11 Jan 2022 12:15:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MWfWDxISWtlrfIW0z+D/qWU9WPagvFBtJzO1jmwOCAN8s3EgT6NR/kjnXOrQrC05BQGBM8VieGftRk9AuvbqGwXZuJKYwCiefv4c5XsQt2AMYXjUPzdqD3ilhys5lKp+6oCxt8jdsAG37YQrXpfgfgOgw9d+YG+UuxQAEzaj6RYvQbvYwsslomsP/m8YX7sVUOyFeNIVDBUsL+A3xL2fRKPVb2H7/kd9lNHuu/tToCWHP7fYbynitLai5apUDflZUlaphn0cv+Dr/MV1UswS3pmUaEZarNmHCuSkZWcyO/lCXPv0Z+Ip5yHyf9lTtPwAeDD7shvS05Zy2I4CNVx/1Q== 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=Z0O8ZYm9/LLeMIfjQcqCR+frdbEDBWQSPLLPo26qcg4=; b=nisOJkMHlSEMQ+2rJntdtDBUZDWgRYKWtLHCL1+MFT5KTlcereAjQn7Jmd1/I9iiI6uRuJxw+WnIaT5fUeXdDPNvYhzhv614YcRJL97HnQLqelWAJCNh+8rAbO4P66y2jIdUkDRIuTVV71QPEeN/ErjUGvcTUqZpsVXkZE+B2jFTyq8oYNARY9NClluQW7vW+KwMfytKTTBpmg/bva9gDCdwPHqA0cqUW1VxTHcUOtzeEwmED//PcptVWtrBdb6Eg3OSSToXTa1KK+z3JwHIh9htNzLCWUmagYCkC15TeMrS198RK9BPTO7MdKmmibh/fqf2IiqQVG6oaJbAT3KFRQ== 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=Z0O8ZYm9/LLeMIfjQcqCR+frdbEDBWQSPLLPo26qcg4=; b=odIyTqr3gz9suLOre1OfJu31osfHEQdGpJls6xNPMfdoorI/ClVzp1pJRKRd/nywUaax9jJAPWrHpXi06fwC32QZIX2Cs/qxw5s+a9odj/saYlDgAFsX77bUen9ktqRIPKEPJt0tYwtt953rcGH2rv4wpyJ4Z3MaX61u9hhMw/U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=silabs.com; Received: from PH0PR11MB5657.namprd11.prod.outlook.com (2603:10b6:510:ee::19) by PH0PR11MB5674.namprd11.prod.outlook.com (2603:10b6:510:ec::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.11; Tue, 11 Jan 2022 17:14:56 +0000 Received: from PH0PR11MB5657.namprd11.prod.outlook.com ([fe80::d031:da9e:71a:73e4]) by PH0PR11MB5657.namprd11.prod.outlook.com ([fe80::d031:da9e:71a:73e4%6]) with mapi id 15.20.4867.012; Tue, 11 Jan 2022 17:14:56 +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 v9 04/24] wfx: add wfx.h Date: Tue, 11 Jan 2022 18:14:04 +0100 Message-Id: <20220111171424.862764-5-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220111171424.862764-1-Jerome.Pouiller@silabs.com> References: <20220111171424.862764-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: SN1PR12CA0099.namprd12.prod.outlook.com (2603:10b6:802:21::34) To PH0PR11MB5657.namprd11.prod.outlook.com (2603:10b6:510:ee::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5f0fb3d2-8af9-4a3c-4342-08d9d525e3db X-MS-TrafficTypeDiagnostic: PH0PR11MB5674:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2150; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gUjlRX3hZW0ehZstBdtSPAF2wJ6gHfRBBVGlW5goe/nRAs4bQmVDtvfrHYUh/giUvI74ItOVUTrkJQiP/BNShN5sScCQGOLU9MBa7joORMcGItaQxScOWAZkPy+/rpN6mBVnQ/aUf7oDS0X/e7l+6x/jiWn5Em5hXALJjG4txe0xXZIfcwMWrQwCEpOl40gsOmRJ0GPGYeEz6r24PgI2ieUXTrjJCg/XiXzGWJFmEje5hW2sbZi5uiozwxG+DjQSgV2TQEbbzZ/uyQciezUAe5S7FXuRdfxmWyZnmOUErhGRw837bpa8zCwVZv0n7I/po2t9vUHIzfM8UZUmWp95UC4f4RhrNaXoI1p+QA4iy72CfX7GvkHHmgHbjL5XPY16JdGpgo0fxBvbDoSA7iLfWPQP2UdruijaoRNmpmMz/AAXGQmI8mt7TilSfHHaMox1GLWzs1klP6HFv88YLf6JnpI3aHp+hEbvSmlfmhFFMkT0rj0hQLRh3rakdfNgonuZh5JeN3OMO5pBurHYvAFcRng5x1nQt8gTiAmiS6Ck1LzezRR7mFsAaBIRWsXQylEGTSpldUTUgM8rHNWD1prhDrX5fYD0H/wpCgEphQt8eqmO8tvMU8Lm1iWUd4TMd4ruxOt5YIe/OukrqsjOP9rtKw== 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)(6506007)(66946007)(66574015)(8936002)(107886003)(4326008)(66476007)(508600001)(36756003)(7416002)(8676002)(86362001)(6916009)(83380400001)(52116002)(316002)(6512007)(2906002)(6666004)(6486002)(1076003)(186003)(66556008)(54906003)(38100700002)(2616005)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?DGBaPPgAcP35c3tDdojmkv9UD+og?= =?utf-8?q?NcOmfxEaxStukZMbqotPwTz5h0sBIz4M2ZLIJpIsCc7HTELXmsbtl4nUbIOMyUMdm?= =?utf-8?q?rXLPWLU5xLjdmiwxEucMKmE3x9+fd+J0O31clJ1rCSW2p+7QZdEgfrbzBjquKI2On?= =?utf-8?q?iZZTI+JaI6Tmvugz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0pzYY/oHa/5qNryaiWTjWn30dG4mJdszCEEeMPxPB8eWIuRGyrtr?= =?utf-8?q?Y3ImVrN0nm7MRP9E1SYLte4DfolGtSm6TDw3RgZDXTfN2iaMV9nkFAkN2K5olu6uj?= =?utf-8?q?WEysVtmzJDR6qvb/MxIVZ2tkLwN7PB4quG3q1Qt6DzvUGaTMmjKOVPU1AH7tgHUYV?= =?utf-8?q?SXf41WfTMPzdgmLuRbo0xfsHNh2rJ2MmU/19/ae/ihTW0Zl18zHdeY/Ol1VQ+XM8I?= =?utf-8?q?cN7t7DBKDo+V+ej4p8rEb9d5IFT5GI+fUM6UzR0qrzrD8DelAvnrq+5NlU3HyRsrf?= =?utf-8?q?zPtsB5FdYQ04x6Rt7xQfv8RCaTjUJvLGB5z0oeS+APBA4hYY9l5ikCfIcvZ85cviM?= =?utf-8?q?p0ptQqlIXdxjpxMQwTQ2MHlbVP1BSdvHNnNGU2rKKqaFkd+uuFez3t6ds1M3xMEPX?= =?utf-8?q?oEQnolSHzVmtln3lv8ZblKhSK2tx4UevlRY0GdI9R7nzUMUhMujOKaoakh6ifVxda?= =?utf-8?q?q5GJVJoUW2GVqhtNpy0kCd/jc5rerKgMJThzRn1cejkcvy1jhgmitgKpxLK/jyJWt?= =?utf-8?q?qBn/pi629Ld+OWgvwiyaiwUfD+aEwA9oILGmVdHrB2cA59bQiF4FMY=3D?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f0fb3d2-8af9-4a3c-4342-08d9d525e3db X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5657.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2022 17:14:56.4970 (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: 9Mv/HOwZaWCtPNw7913LZ+RgqM+I+YxCZeZ9sZ+RIP5TNwELOYqE8b0170OnlnWqB6TMq+2whpWELYgzjOkrQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5674 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..0e2ce112f16f --- /dev/null +++ b/drivers/net/wireless/silabs/wfx/wfx.h @@ -0,0 +1,166 @@ +/* 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; + /* protect all the members above */ + 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; + + /* rx_stats is accessed from several contexts */ + struct mutex rx_stats_lock; + struct wfx_hif_rx_stats rx_stats; + + /* tx_power_loop_info is accessed from several contexts */ + struct mutex tx_power_loop_info_lock; + struct wfx_hif_tx_power_loop_info tx_power_loop_info; +}; + +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