From patchwork Mon Oct 12 10:46:28 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: 11832129 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 10391C43457 for ; Mon, 12 Oct 2020 10:47:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B08A921741 for ; Mon, 12 Oct 2020 10:47:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="LUT3PuVC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387830AbgJLKrj (ORCPT ); Mon, 12 Oct 2020 06:47:39 -0400 Received: from mail-bn8nam11on2052.outbound.protection.outlook.com ([40.107.236.52]:61696 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387594AbgJLKrZ (ORCPT ); Mon, 12 Oct 2020 06:47:25 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BRiz8a5COdsywSViBcSIyRuELqJGfaXJyWOKPIkgK2OP/tycz3b3oRUnV47T8FqnoSmQvR5k1x/OWSoknmhkSWPwwYU186J1O+kZRZsCb3ourPlGkHBsp/PicoohX8acaxVk2vKa8k/LfhSPTJ3XNcbRRD2t36Yg9oIoEwOovrOKjs7H6bHr+K2zY9T2nH94Orog9aJvuUGME1WFMAQFe+HHRbg/ExG80B/Tuyl2ebGrBgf7DCfZ9JtXdfwPZ0QQJQvP00t46HxxyyEPCZjSnJaVA6yDqhjbb9t90iQFg4OMaAoMdaKiZIgoG5k6IbsyywOLA+JIwQmrzGCpPEIGfA== 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=d2ARdbMymwYz/zH519ug5MqD1tw7TOrveT3l3JXOvhWbOi3TuJG5vwzWUVeBjXpgAEnS0s4+aXoedPwRcAcGtIuCZ0xIUaDfmItzoCxKH5jPYsp3WluRvWbOhVzyIS3p3GoLwvmNF00U5AS+3sEZxh5iy2icIr5XBIoxAKHfol56I1EAtCDQLu2pOEDYtIux0spJ6P7epZzj8WKe1Wim+MZy4Q266Xl+93LvbzvoheBN18vWTF6XV9Xmcv5hzzTbaER0x/NGwh0VLdb/sgTQYcqajbeC0mSnfpQZ0nLwu8Csg+0q/eaMI5FCZGlzpdk3bvJI1eXA23aXnOZtcASvSw== 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=LUT3PuVCf1A3dR2EtqjFvMi2QqO+H4jDdVXYFMtxi46RysmtoQbP1VD8anEKB/sB3YDH3R5RX1CwMYWWUoGiBXLX+TC7BoSiGKbXOJrWzx4Km+iXqZaCfFlwtT7NO9oDmPX7zvbnr3iiF3ZmU38M115FQaokVebhmYV5d6GaRGg= 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 SA0PR11MB4734.namprd11.prod.outlook.com (2603:10b6:806:99::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.23; Mon, 12 Oct 2020 10:47:11 +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.3455.029; Mon, 12 Oct 2020 10:47:11 +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 , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH 03/23] wfx: add wfx.h Date: Mon, 12 Oct 2020 12:46:28 +0200 Message-Id: <20201012104648.985256-4-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012104648.985256-1-Jerome.Pouiller@silabs.com> References: <20201012104648.985256-1-Jerome.Pouiller@silabs.com> X-Originating-IP: [82.67.86.106] X-ClientProxiedBy: PR3P189CA0005.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:52::10) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.home (82.67.86.106) by PR3P189CA0005.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:52::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21 via Frontend Transport; Mon, 12 Oct 2020 10:47:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9d36537c-6f12-483e-b6f9-08d86e9c2c9c X-MS-TrafficTypeDiagnostic: SA0PR11MB4734: 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: U/L7BHOnLKTzogHYuy8UlA9iF1ujYEei3d60AKfyFiWjOVAEXyZYbknXBt5MrymU1MHPjK0IedicZUCgwaFhMbQps7uCTAOSJxLLSGxIPoq5yx+rBC5pAvGBPW8+DGIMq7++Stn743dkQfG9M67SIPWBJvAjZh3u+2SQQv9qRAaU5I1AXtKkcJ+9JKZzdBiTDrk7bkmnJ29e4l/uxYa+jy0Z7ygGUgAH3fJL+Hr9iv9eWpD1SCbWotJzBFavT5+xjgIzR1unTKmtnshWFlFMMBF4wxIfKmBjxOFZ6/O3xZHKxuFKJzdZ8Q/vyYVn1c9ouVTO6WwBmyz1Nljrc84FaA== 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:(39850400004)(396003)(366004)(136003)(346002)(376002)(66556008)(66476007)(6512007)(26005)(36756003)(66946007)(16526019)(186003)(316002)(4326008)(2616005)(956004)(1076003)(5660300002)(107886003)(6486002)(54906003)(86362001)(8676002)(83380400001)(8936002)(66574015)(52116002)(2906002)(6506007)(8886007)(6666004)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: bQrgpirEcfBwfR59B1QLgqiTwveAfBuo/Qwb4b7QrIYCXIIxMapbQ1FE7WCYaJt9l5gp8PtWQM1NsNWbObpl5TBssCHeWaRqayOJu3qQGWubMraNMEqBx4EX+rM26SRu37yi3RUoASaXGvperBmMusVXHF4h1RA0fWvHhKioxdclfFe0XY6iIXJ+LmQOd7PgbKCeNWA1vVywfoMbeq3VBMvN9rcDB1W/pRTYqPOcXDlY/Hga/+wPMf+iXZXC3/ZYjB3wUsBawpQi6Ydg2d98Ye4du4y/6zGrqerbuczYcIK4YPljkWM0TmF90TugrmW0XLXnx0Ak1L9GyJS87qmDhiA1NEv4dzn6RkegB8iXKPITHxa6Thlg4eGC1LCqY6QA5+7dZzYVVDzMD21Stsp7N+glpWDBV+3Y0jUdHtqN6swJIAcBZTbUuy0Z8f3TVfCag4O/Jiqk1lLDnO/AjjYYXPpmSrhLbmx9fZvVspWjip+3h1nafJEzKzg5B0RZcov2LK/rsN5QNvbNlUXWWV13EgljY9N0kPw1srClevn5moglzt3nTZmvII0c7XaX7AOJfDBP2A2VuNaQyT/hx9+TOmbtgdjpgHd4U5Pkm4Q/4UmEKZdDrl5aIZu7+W0L/JeiokubT4u1+aYxzDxONv+Dbw== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d36537c-6f12-483e-b6f9-08d86e9c2c9c X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2718.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2020 10:47:11.6825 (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: WxQXTiU9vHbsG40/wFYyB9kdRx5mv8T+dbP1j6yh+udfSdVqZGFkMk+6nnef15uTAqLLdhWc/A/ZdeB6ghAWBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR11MB4734 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 */