From patchwork Mon Aug 7 15:05:39 2023 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: 711528 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 DB250C41513 for ; Mon, 7 Aug 2023 15:06:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230074AbjHGPGT (ORCPT ); Mon, 7 Aug 2023 11:06:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjHGPGN (ORCPT ); Mon, 7 Aug 2023 11:06:13 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2041.outbound.protection.outlook.com [40.107.223.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD67510DE; Mon, 7 Aug 2023 08:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l6Pxi1NoX/sePte0ctlIr6F6J8VZ+pp8U9YdoBNDP37aSSmkW4tq/wiVuC3tOLF0218Sx+FvULhTHiGrFvMY5BSEcYzL2M89NzHtA3WEiNX5DZrzJWWLcE7rqZ5G8fHV+vxSQ6KpUqbssJV+SGeEWii03gz/TrEorZ87LgP0WJM1GFNfHk67aGdwjFxwEEFaYUHE//j+tLMaNxAUr1QpouJP84oB9nMKulod/vw3D6/gEvt0H3ygI5CBz5y+HtVk4QsoTKpHfashtGp0gk1UkNkcVyHiwY+HJALRAayGf1UYAlvvmoqgVJ71x8xFuz72dmLwTMoLvNh1ZHPaJiC6SQ== 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=UTH5wIR+R1oRA1WM5IDcLdUhxe6B0hWxMJqCmFDulfc=; b=JThJTvZgxnn7W9tWPwkZNd1GWWd30ST11nD41jfcY/CeFKa73igw5LTzRLzk5lQzK3W/HHBXtDIGFYaKlo3/3LA+FiNAWJpyufaFBNw5Uhgnyj2ZTupnZHTzJlRomgrg+oZpr+UGTMLrSVKTDFrawGLqg9Qfqk0MEOLCaVVOO28khj1bc/IlCJgyD5DFf5+1V17u7D3hRc1etvupHp6ByK2SXRmpnimDGIVsKQ9XxO2k96WCbBzv7EK0MO7dFKnqJuc0h7y2nUan7KISWqWtFkgLErQgE2Ih6bkHRXkhPYerT0NvyVsU8MMNVad9aCDasndBzknGq3yBYwP8vNUqvA== 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=UTH5wIR+R1oRA1WM5IDcLdUhxe6B0hWxMJqCmFDulfc=; b=jX0fJWMgPDgLhlUhN4yG1yTrjgCSgAPSBljFWeWo+KhxAZoqgLu3UViGs6L90Hq10hiuQZRBKWGULi1fgyrsU7mhCcMLvwXr6LF/f2NunOTE1FqJN9AuLt9iLG711hmpJEcbGytftHt0pQZORM3Bkv0/lm+h2NA/oZ1GOxJEYhc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=silabs.com; Received: from IA1PR11MB7773.namprd11.prod.outlook.com (2603:10b6:208:3f0::21) by SN7PR11MB7590.namprd11.prod.outlook.com (2603:10b6:806:348::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.27; Mon, 7 Aug 2023 15:06:09 +0000 Received: from IA1PR11MB7773.namprd11.prod.outlook.com ([fe80::14b1:be6e:19a3:2eca]) by IA1PR11MB7773.namprd11.prod.outlook.com ([fe80::14b1:be6e:19a3:2eca%6]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 15:06:09 +0000 From: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= To: Kalle Valo Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH 6/9] wifi: wfx: implement wfx_remain_on_channel() Date: Mon, 7 Aug 2023 17:05:39 +0200 Message-Id: <20230807150542.247801-7-jerome.pouiller@silabs.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230807150542.247801-1-jerome.pouiller@silabs.com> References: <20230807150542.247801-1-jerome.pouiller@silabs.com> X-ClientProxiedBy: PR0P264CA0252.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100::24) To IA1PR11MB7773.namprd11.prod.outlook.com (2603:10b6:208:3f0::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR11MB7773:EE_|SN7PR11MB7590:EE_ X-MS-Office365-Filtering-Correlation-Id: f833c409-4e72-4aa9-c87d-08db9757d49f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cJ++EnFr0GQiQQmkZ4dW4f6L9trGBrNT2YJ8dHyiAP7RIlU5Z2+GHzQAFeDgMDc5CKVPhcazuXaPmzzW5MsHsKFiNyW8BMoLlEBogsqpXWC8dkPR9Q6yTSbwUgcVsDimAHsQhrTU93ADs0HJFjlwxzXDvfyfalw4KzEyHD0DgMhM7xa7Jght+NfaFaf1//rAKb6moXk+y6BlV8TCaXil/HVWISdPWyjEGvaFDDsBkNvERgfE4CNBIanOE0jC/hUQP9nna0eCmH0MhWRrIjGOe3HfxIVKCKM+Y+9+8XT++r6qGAS38PDOMo0wpNZZ5PKvl74W9CNWyUs30og/SK5iVd/kD2/BAMdeeNq+ik8gL0sOeMf2EC7tbHTSGFXFHJy1KbBXtBLgmZ/3CU3AqxWhsB6C97jihQ9DZw/c41sk4gKuBz4/WVSetThSwR8DO4XdtQXum3xViBAUCXF/y46knV5/uah6LNOiLYomJngKO/2ASIaaj7uhMK9jGOzXUk3ZgMfViKSnFZrbIh0vD0iRpkVM6TkbhvNYDUdMyvdhTZAT6uGI5LBk/v5KcIidds9zoyWoewPeMDmnIwPN84e/xQRsV+edodR9MTiUwous5b7zwFRK63jaTSLPKYMcG2dE X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:IA1PR11MB7773.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(136003)(39850400004)(376002)(346002)(396003)(366004)(451199021)(1800799003)(186006)(2906002)(4326008)(6916009)(66556008)(66476007)(66946007)(6486002)(52116002)(6666004)(66574015)(83380400001)(5660300002)(41300700001)(8936002)(316002)(8676002)(38350700002)(38100700002)(2616005)(478600001)(36756003)(107886003)(26005)(6506007)(1076003)(86362001)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?k4ZxKje/qkyFzkGOtT0FBYlJukVO?= =?utf-8?q?J+0gD3gn/q5waesJV4GqK4w1WsU5f5QJs8hOU9XnPVGSDkM1Ge+wYsDQZwkGmLhOu?= =?utf-8?q?tPkpZkemQZ7w0EE7RO1qoN4quHpQdYiCUXmIBF9PCyQwX/SvchZqM+6lwsk7qs4oK?= =?utf-8?q?a9PvnGu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/LGhpNLjIJi2VWR8JPk4XfsbW8KBxmFGWzm+?= =?utf-8?q?Sqn7rvChrtlybmrQyhZCroGAjLYQkJ0pET4ZaV/P8bMMxBFz4yn9Y5AUoS216tPlp?= =?utf-8?q?W7hCW7FJq7+b8xJbhGiqQxAXHXy+WQy1JArHqSE9aNk8utP65nolBqAzXs9OrqJRG?= =?utf-8?q?unviWOyVdyWHTP1/DT86RuWeLEODzKBk+1mFEnMMcXI2+KgX4djahgw41TPyu8vQB?= =?utf-8?q?5XuX01Yw2Kgm3aDJ1vYUTcP5O6WE1Zk50WGiqqQj8SfC3PKWs+8nDo7CiCnCDlHqK?= =?utf-8?q?A3nHbvR0+lYlMbXd9bENFdV6/G5qBWGIa13+2Qu8Jx58Mo/a8SuQA9DN6BepLkXqz?= =?utf-8?q?48zphEqWqKGNBmP3pO9WqovMOQhrBmOhWyACFyOgZCMI22F9XyHzubAJREqgrod38?= =?utf-8?q?HyBbkx/cqBJINue1EFyROMWsWOB+WeqcZnp6/m5McHxB3WmSK5fuYkEpQE2V0zOJO?= =?utf-8?q?KWN6mVs/8Kom?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: f833c409-4e72-4aa9-c87d-08db9757d49f X-MS-Exchange-CrossTenant-AuthSource: IA1PR11MB7773.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 15:06:08.9535 (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: Cx8GKo0PGKLvApt3+Uqn8W7pWGQSOOqkik/92zeZod1Pbm/mt3mCOa7f41ILD8RCoR5b257B5HSGbzAHBYoWBA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR11MB7590 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org In some conditions, the device is able to send/receive frames during scan operation. So, it is possible to use it implement the "remain on channel" feature: we just ask for a passive scan (without sending any probe request) on one channel. This architecture allows to leverage some interesting features: - if the device is AP, the device switches channel just after the next beacon and the beacons are stopped during the off-channel interval. - if the device is connected, it advertises it is asleep before to switch channel (so the AP should stop to try to send data) Signed-off-by: Jérôme Pouiller --- drivers/net/wireless/silabs/wfx/scan.c | 50 ++++++++++++++++++++++++++ drivers/net/wireless/silabs/wfx/scan.h | 1 + drivers/net/wireless/silabs/wfx/sta.c | 1 + drivers/net/wireless/silabs/wfx/wfx.h | 5 ++- 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/silabs/wfx/scan.c b/drivers/net/wireless/silabs/wfx/scan.c index 51338fd43ae4f..57a2d63dd2a62 100644 --- a/drivers/net/wireless/silabs/wfx/scan.c +++ b/drivers/net/wireless/silabs/wfx/scan.c @@ -146,14 +146,64 @@ void wfx_scan_complete(struct wfx_vif *wvif, int nb_chan_done) complete(&wvif->scan_complete); } +void wfx_remain_on_channel_work(struct work_struct *work) +{ + struct wfx_vif *wvif = container_of(work, struct wfx_vif, remain_on_channel_work); + struct ieee80211_channel *chan = wvif->remain_on_channel_chan; + int duration = wvif->remain_on_channel_duration; + int ret; + + /* Hijack scan request to implement Remain-On-Channel */ + mutex_lock(&wvif->wdev->conf_mutex); + mutex_lock(&wvif->scan_lock); + if (wvif->join_in_progress) { + dev_info(wvif->wdev->dev, "abort in-progress REQ_JOIN"); + wfx_reset(wvif); + } + wfx_tx_lock_flush(wvif->wdev); + + reinit_completion(&wvif->scan_complete); + ret = wfx_hif_scan_uniq(wvif, chan, duration); + if (ret) + goto end; + ieee80211_ready_on_channel(wvif->wdev->hw); + ret = wait_for_completion_timeout(&wvif->scan_complete, + msecs_to_jiffies(duration * 120 / 100)); + if (!ret) { + wfx_hif_stop_scan(wvif); + ret = wait_for_completion_timeout(&wvif->scan_complete, 1 * HZ); + dev_dbg(wvif->wdev->dev, "roc timeout\n"); + } + if (!ret) + dev_err(wvif->wdev->dev, "roc didn't stop\n"); + ieee80211_remain_on_channel_expired(wvif->wdev->hw); +end: + wfx_tx_unlock(wvif->wdev); + mutex_unlock(&wvif->scan_lock); + mutex_unlock(&wvif->wdev->conf_mutex); +} + int wfx_remain_on_channel(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_channel *chan, int duration, enum ieee80211_roc_type type) { + struct wfx_dev *wdev = hw->priv; + struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv; + + if (wfx_api_older_than(wdev, 3, 10)) + return -EOPNOTSUPP; + + wvif->remain_on_channel_duration = duration; + wvif->remain_on_channel_chan = chan; + schedule_work(&wvif->remain_on_channel_work); return 0; } int wfx_cancel_remain_on_channel(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { + struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv; + + wfx_hif_stop_scan(wvif); + flush_work(&wvif->remain_on_channel_work); return 0; } diff --git a/drivers/net/wireless/silabs/wfx/scan.h b/drivers/net/wireless/silabs/wfx/scan.h index 2f8361769303e..995ab8c6cb5ef 100644 --- a/drivers/net/wireless/silabs/wfx/scan.h +++ b/drivers/net/wireless/silabs/wfx/scan.h @@ -19,6 +19,7 @@ int wfx_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, void wfx_cancel_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif); void wfx_scan_complete(struct wfx_vif *wvif, int nb_chan_done); +void wfx_remain_on_channel_work(struct work_struct *work); int wfx_remain_on_channel(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_channel *chan, int duration, enum ieee80211_roc_type type); diff --git a/drivers/net/wireless/silabs/wfx/sta.c b/drivers/net/wireless/silabs/wfx/sta.c index c58db2bcea87b..f42341c2baffb 100644 --- a/drivers/net/wireless/silabs/wfx/sta.c +++ b/drivers/net/wireless/silabs/wfx/sta.c @@ -733,6 +733,7 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mutex_init(&wvif->scan_lock); init_completion(&wvif->scan_complete); INIT_WORK(&wvif->scan_work, wfx_hw_scan_work); + INIT_WORK(&wvif->remain_on_channel_work, wfx_remain_on_channel_work); wfx_tx_queues_init(wvif); wfx_tx_policy_init(wvif); diff --git a/drivers/net/wireless/silabs/wfx/wfx.h b/drivers/net/wireless/silabs/wfx/wfx.h index 13ba84b3b2c33..5fd80c423d6f6 100644 --- a/drivers/net/wireless/silabs/wfx/wfx.h +++ b/drivers/net/wireless/silabs/wfx/wfx.h @@ -69,6 +69,7 @@ struct wfx_vif { bool after_dtim_tx_allowed; bool join_in_progress; + struct completion set_pm_mode_complete; struct delayed_work beacon_loss_work; @@ -88,7 +89,9 @@ struct wfx_vif { bool scan_abort; struct ieee80211_scan_request *scan_req; - struct completion set_pm_mode_complete; + struct ieee80211_channel *remain_on_channel_chan; + int remain_on_channel_duration; + struct work_struct remain_on_channel_work; }; static inline struct ieee80211_vif *wvif_to_vif(struct wfx_vif *wvif)