From patchwork Wed Sep 27 16:32:54 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: 727062 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 66911E82CAE for ; Wed, 27 Sep 2023 16:33:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232018AbjI0Qdr (ORCPT ); Wed, 27 Sep 2023 12:33:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231975AbjI0Qdl (ORCPT ); Wed, 27 Sep 2023 12:33:41 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2088.outbound.protection.outlook.com [40.107.237.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1304310A; Wed, 27 Sep 2023 09:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IaOiMBDvYckOVxPr1Hla+orERKqURHWZC5nWLsv98YMqdoUYS7/gz9qQ2y5VoBx564yECGtFn1DP2rtDVyQXr0xTCNN1jA5e24tz7aFKtC9dWuei8YN5GHxnmnwG8zLYjEb/YFWdSIc35s0WEBzobxSOa2NYLX4KSiOdpKujNI9IBAcYDA3r6UjqVHiedEZbiN6kbyq6iLkwXUlGM6GEYcuXn943NRK73WOn3wniyvv3pFIqir9Ju5YJHBeeodWFFnTxC04oJX/DHv6K4+0+/rKDijvSP4VZE+5Kj5sdCBe8gh7jJPBkO6etzYvIPxhJYxduPBBlGyoYfcKYlVYASw== 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=iEeZTFKIH/xeImm70sYbyeuFRuutq8ymyWu0/ZJegaI=; b=WPW3uW70y0SVLIsEznsuICMnweOSicHWNzU9JbiQvMb9ViYgXt3dgtO8Fr4btWqll4uoYINYsjhckHncJbYz8CgUvwXuh+0N6uOxJTS9MmrCXhR1xBgPFh81fyn/iOmAdVIlIVFAUcyfpR6TIks+jlzni1PnH6tOBjhYSkj9a4Xra0N/IXRPJgPMCcSyTMR1jPVbmdFcEulLClNLUZTdGaru4cOmNzOo35FFtE4xKvEwKDSjiUVrBIojIMo1IkLxvqgQXLj0aA5rVR82YEH3WJQid2sBzhXd+gtfSlhSulkQxYoYkbTwCd07AGmIbzQntfqoILQJsO+Af+NSAemdVg== 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=iEeZTFKIH/xeImm70sYbyeuFRuutq8ymyWu0/ZJegaI=; b=fda/Ik9IfkYGLt0Et9jOztRJQQRTlutH0D/ml6f09djFqianiZuR92UySzSnd70kZggGlPt6e99E23w1LipeYz0HmkZx8YEU3XXuFoHF9fTmPILoIBqiPdzV/rLaZgBY/BR6ZuYXKC6EEHRuR9w6PJ4inx/EELHfljjPL5GCZyE= 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 CO1PR11MB5041.namprd11.prod.outlook.com (2603:10b6:303:90::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Wed, 27 Sep 2023 16:33:25 +0000 Received: from IA1PR11MB7773.namprd11.prod.outlook.com ([fe80::d6c8:4cb6:2594:d8f3]) by IA1PR11MB7773.namprd11.prod.outlook.com ([fe80::d6c8:4cb6:2594:d8f3%4]) with mapi id 15.20.6813.027; Wed, 27 Sep 2023 16:33:25 +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 v2 6/9] wifi: wfx: implement wfx_remain_on_channel() Date: Wed, 27 Sep 2023 18:32:54 +0200 Message-Id: <20230927163257.568496-7-jerome.pouiller@silabs.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927163257.568496-1-jerome.pouiller@silabs.com> References: <20230927163257.568496-1-jerome.pouiller@silabs.com> X-ClientProxiedBy: DS7PR06CA0052.namprd06.prod.outlook.com (2603:10b6:8:54::30) To IA1PR11MB7773.namprd11.prod.outlook.com (2603:10b6:208:3f0::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR11MB7773:EE_|CO1PR11MB5041:EE_ X-MS-Office365-Filtering-Correlation-Id: df86e403-c273-459e-e310-08dbbf7778a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: psEKFvqlgqj6D4cS6qe0J8z72okMKj4lVDIsEs5aDKIjDgBEAZToemheGobdfmayAKIIqCHiEDlpe+wgDTkUqXhCI1Byh7ltMx7NsN7a5Tg9ezRdzABrGGMhiGCBFwOOGI7tuD7dwDltSgXZVpAcWAodUBfbi36Y+vO7q78ScCxPqwovsrPrtAUth6O0jVaUxOtBG+QvWhE6PDVD+wOyCKO37JxD7D2/yHW/B7INz+PttFeFwQNloo3Kuh4winYIK7+z8zIFfYFg5UCLCp2+2HHkw/m12TB7yOIF2ZLzPHNFYWS53x9uJEZLxTPX/RSy/UoXoLNvP5iRuP0gaoW3Vy69O1Hx5s9A3MjDaGuoenocKJezR9nOOxnZsKaFQ/l0BAa7dcw1tp0dcRtwOvIiuER6LhFYXZlMa4n+zlLnvY1xjMADPBLhmCgqeThK0NvAJwa1K9dv2kyAISrRqXnFvUSG3fRLWakMtr1+z8y/6rnUx3S+T5a0zRNNGC1Z7/PEzrqE4qDUrvVbQsAHjGj4DKsZ9z8SfVrOb8bmO6XwNjEvifrXlerAFZLUEOUpXaHY 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:(13230031)(376002)(136003)(346002)(39850400004)(396003)(366004)(230922051799003)(1800799009)(186009)(451199024)(6506007)(107886003)(66574015)(66556008)(66476007)(6666004)(1076003)(86362001)(6486002)(52116002)(6512007)(478600001)(38100700002)(2906002)(83380400001)(5660300002)(316002)(6916009)(36756003)(8936002)(8676002)(2616005)(66946007)(4326008)(41300700001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?6lf7CZgkpzDJzo31dvK1yZJ4aR2H?= =?utf-8?q?0sJoWI0f+U3bqQhnSjKOEsuKvTGXxOsl2z5wy6JhqTQyOIbFTq5tmKnH4ODzpqfpG?= =?utf-8?q?hEEc24sf7fXC8sO/yu7K1+3pGVT8JmuVsijz7LDtJ5td3WAhI86a++xpaarCNgBWH?= =?utf-8?q?rFjUxJ3gxxmIL61XCBMkDtB2R9D5YGebiGHMOdV2Z8Z0667vtxsh1sMzBL6YV4MC1?= =?utf-8?q?T8ET+3RXlen2z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tiGbW+GYQr8maQMH7nU6bWYY1qhXm4tVXRg9b?= =?utf-8?q?oJeGH1KMamikAtYJz4a5oEZ0sh0lxqWZkQ6yCemBJvCUWj2lcZDttRer/ztsoa5wq?= =?utf-8?q?D+SJMKtzbsAC6HUHvDs3Gacf9tZVs1XtYwhyx9kUNrCg/fGfWG+8Q/SBosnwYSKm6?= =?utf-8?q?RbIdoRqgnuYcQ0ybWtz4uIY/LBcKCs0G/0g0QllOwTcPgXqZ3mdz/Q7aSD3hfTP+H?= =?utf-8?q?s5cIx3OfffIUPuEFNa5+190+WQBVbBTUTRNl1vk7L+GSZk9oUJp1n1weljBCCjg+L?= =?utf-8?q?owuU4WVXaEBIThggaheUlwfEfH8lTTmlV43Ka2wBXQXp9C7xgAQBdYfMusX8fMlx1?= =?utf-8?q?3DB/xm7gOGQzdyHh5vY01RwrsbHm8k8xZg+38kshOXP4Dqss6XKaKBEVLvvF45jvC?= =?utf-8?q?DyOpfNTFZ+rOsp7zcyLsCLn5JkFSetv8NUeep18txiM6C+H57y1C6fY0au20THgcf?= =?utf-8?q?gB/WJMLTGnU?= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: df86e403-c273-459e-e310-08dbbf7778a4 X-MS-Exchange-CrossTenant-AuthSource: IA1PR11MB7773.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 16:33:25.1534 (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: +EtFPXgzDBtIXhWii7FtMesjF4B5f+da96sPJQmjxipf8SE4wHoLh9Wg93dQKfUOin76Ni6w9ApAJnnZCuIT9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR11MB5041 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org With 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)