From patchwork Wed Nov 4 15:51:47 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: 318383 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 BB285C2D0A3 for ; Wed, 4 Nov 2020 15:56:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D27E204EF for ; Wed, 4 Nov 2020 15:56:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="k5xTDQqQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730945AbgKDPwp (ORCPT ); Wed, 4 Nov 2020 10:52:45 -0500 Received: from mail-eopbgr750080.outbound.protection.outlook.com ([40.107.75.80]:6126 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730902AbgKDPwn (ORCPT ); Wed, 4 Nov 2020 10:52:43 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dz5xtnQY7duxWoJQ3f0MemnwJi0TF6D9BsfUE7tkuSji52AKzSQyyNlOD8QTEhKL/I1XkiLrXB79I9RsKr8vU+EQiulTmh4or62Q49/eNOCtZps2atSI16EpcfDpRFrLlDTM8A9REG4MyRnPN/YbybBTfuRrwOXxH0777z88ZC+RbvlOu2suiUxlxeC06D0zZDvRIuMGsdKIPxjwHrPGvoia3Gsvx8pbVTLNFvulsSrY2KLFYww7ofGbH2uPUr9gIh54AKrCi4+4i5FSAnAKsO2u5ICnlwIXHLUmZMWX+nHaKQDItzDi1YgGu2mVk7Mi44fSAK5rCBZt1y8p+7x2EQ== 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=dKojzDNmS0h61w+Sx7dL0+bbNr2lgYe/Jer942106yocaeubV5qf915GYUgT3aaxSOHiuSXx2Ak1lGvSSBKEqYXmBMBe+Pw5lqa5ACt5kgPqsIgRDZYyj4DZ2U+IqsuORbN3IgDh8ZVgbGEXYq6gC7LQDRGRgRr62EhrXc51oQ3q8Jd5hTKQfxWRcLnQavcI/UnG8CONBVlET1C2SPfzh9tIe9++jwZ8hj8lIsfsYpJ+h6N0GGqxADYg7LtkD81wUIb6J9iJMtIQORuUQ1NPr4pw3v0ho2bYmfrabgncfyHqjW5wOFwsdh6dAFGFWAyob3aMJK8rieZfWT1bzmkiSw== 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=k5xTDQqQKRzTqf09CUZOo3tWiXzFWmVv6HrsphD7lX++WnWD3mFvwzdZuNC4NN1t0PDt+0DnyqxgeypD2Wx7+hCMgm4OEXAAS1qtwkfheGAfD6KC5viMdS0/+3BLMsvlpX4hYHPV5OD+v9vaJyYNYMlIIqrvD+pldHGOUoy/Scc= 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 SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.32; Wed, 4 Nov 2020 15:52:30 +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.3499.032; Wed, 4 Nov 2020 15:52:30 +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 v3 04/24] wfx: add wfx.h Date: Wed, 4 Nov 2020 16:51:47 +0100 Message-Id: <20201104155207.128076-5-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201104155207.128076-1-Jerome.Pouiller@silabs.com> References: <20201104155207.128076-1-Jerome.Pouiller@silabs.com> X-Originating-IP: [82.67.86.106] X-ClientProxiedBy: SN6PR01CA0032.prod.exchangelabs.com (2603:10b6:805:b6::45) 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 (82.67.86.106) by SN6PR01CA0032.prod.exchangelabs.com (2603:10b6:805:b6::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.19 via Frontend Transport; Wed, 4 Nov 2020 15:52:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ccbe006-9698-4641-046a-08d880d9a319 X-MS-TrafficTypeDiagnostic: SN6PR11MB2718: 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: 0EqOFdNV57tC2chAktkH9xgxrYlhl8KA45kkMdwIDrttojIp8rLKcFCcL54+caEDoYFWOXUm3mCVcQXpSnPL+x5GVN9cQyQ6xRSzuDKz2Li3ilA3xM2lcrWPMXVam7MbXidaSYw3ILc0Mxr0TBGmRxnlqJ1Y7OrAu7YZ5T1LYTRxFvSBvyDGuhhc0BBRb+DnNirflXq7UtKd7nRuIP2lY5k/jVJC8zHIqUw4Xm6CFrkHGoS9+1q4Gu/C12w08LqD8Mi5fNVYkgt+x+2KQcyjt6sINxttYXQjqgGoT/hbW+26o7kPr3M4mwn8di6s8kzz1i0gxG1v5RXq3PHzinsTAw== 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)(346002)(376002)(39850400004)(136003)(396003)(8936002)(478600001)(186003)(16526019)(956004)(2616005)(6486002)(8676002)(66574015)(66476007)(66556008)(66946007)(316002)(7696005)(6666004)(83380400001)(26005)(54906003)(107886003)(36756003)(52116002)(7416002)(4326008)(5660300002)(86362001)(1076003)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: niaEZNHaAlb2+hWr39boGlhA8GhTpmKp1eZwKeASDWhIKduNexhAM7oc8udrNcw8NQp75obtbT2prpDsNprYimWW/BXUnhTm+ZtZ4mXcZ50D5zUiO6IDa+V19wG+KRo2Avrs7ArNFJwoyIj2FjN8+HjH2WfJ0mw/jWcA8PvNLJLGoowCoDVYccbK2icsSjbNH88VuAzrn4DM3NSrBWqH9U6yUi+W2gtfrus3pUUm9/w5Zq4k3tLC2EJekEOjU3Gwh7ufT3gEDX7x+R5NSWZx9Bs/Qw5p+qetU7sCg71Q4dOnA8EJU33yQL4YTEWtDv2aJVFLbcziBaZ+xrW6pUUffxupuW6J6NGjsMy25HR9IL1A2LV7zI2HZ7Q5u/OR9/pT5tAbBLWkNnmZFIQC3WYDoKk+6DGSW8lS5xX2Y+wPFm1/FxWYQU7kB1HmzO6k0RiA0noQzBUuBlm+yS7R05p4DZF273qor3O+vn71fBUHTlHwiLjYHNeaILMpX8P33MSwGlLia32d04t68zTGBHmboIZHZkSYy2iW2TDMVnjgd1uT5t7mtsKUIrPC/96q6HJ6PKrszPD8uFYCQyW1kIq22l2rIEa/LzSqD24WK376wAirwRfFzKe3SgHp8AlxvD6DMvQM9vdljpZzjxOTRZ+8OQ== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ccbe006-9698-4641-046a-08d880d9a319 X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2020 15:52:30.7628 (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: JHwR/jmY+tDIlLU2x8pUVvtwEW8B6v2EgDq20KNvgfiUSfRva5Cb6i/yBdJY9hDjItlMOJLoeuba/q0RsbVOyw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB2718 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@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 */