public inbox for ath12k@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] wifi: ath12k: enable 802.11 power save mode in station mode
@ 2024-02-01  3:58 Baochen Qiang
  2024-02-01 17:48 ` Jeff Johnson
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Baochen Qiang @ 2024-02-01  3:58 UTC (permalink / raw)
  To: ath12k; +Cc: linux-wireless, quic_bqiang

To reduce power consumption enable 802.11 power save mode in
station mode. This allows both radio and CPU to sleep more.

Only enable the mode on WCN7850, other chips don't support it
for now.

To test that power save mode is running, run below command and
check there is no NULL Data frame seen by a sniffer:
        iw dev <inf> set power_save off

And run below command, then check there is a NULL Data frame
in sniffer:
        iw dev <inf> set power_save on

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4

Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com>
---
 drivers/net/wireless/ath/ath12k/core.h |  1 +
 drivers/net/wireless/ath/ath12k/hw.c   |  8 +++-
 drivers/net/wireless/ath/ath12k/hw.h   |  4 +-
 drivers/net/wireless/ath/ath12k/mac.c  | 54 ++++++++++++++++++++++++++
 4 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
index 5c6c1e2eddb6..6843ec91780d 100644
--- a/drivers/net/wireless/ath/ath12k/core.h
+++ b/drivers/net/wireless/ath/ath12k/core.h
@@ -264,6 +264,7 @@ struct ath12k_vif {
 	u8 tx_encap_type;
 	u8 vdev_stats_id;
 	u32 punct_bitmap;
+	bool ps;
 };
 
 struct ath12k_vif_iter {
diff --git a/drivers/net/wireless/ath/ath12k/hw.c b/drivers/net/wireless/ath/ath12k/hw.c
index cbb6e2b6d826..6070064a25c7 100644
--- a/drivers/net/wireless/ath/ath12k/hw.c
+++ b/drivers/net/wireless/ath/ath12k/hw.c
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: BSD-3-Clause-Clear
 /*
  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/types.h>
@@ -917,6 +917,8 @@ static const struct ath12k_hw_params ath12k_hw_params[] = {
 
 		.def_num_link = 0,
 		.max_mlo_peer = 256,
+
+		.supports_sta_ps = false,
 	},
 	{
 		.name = "wcn7850 hw2.0",
@@ -984,6 +986,8 @@ static const struct ath12k_hw_params ath12k_hw_params[] = {
 
 		.def_num_link = 2,
 		.max_mlo_peer = 32,
+
+		.supports_sta_ps = true,
 	},
 	{
 		.name = "qcn9274 hw2.0",
@@ -1049,6 +1053,8 @@ static const struct ath12k_hw_params ath12k_hw_params[] = {
 
 		.def_num_link = 0,
 		.max_mlo_peer = 256,
+
+		.supports_sta_ps = false,
 	},
 };
 
diff --git a/drivers/net/wireless/ath/ath12k/hw.h b/drivers/net/wireless/ath/ath12k/hw.h
index 0c3b416ae150..6a85ddbb34e4 100644
--- a/drivers/net/wireless/ath/ath12k/hw.h
+++ b/drivers/net/wireless/ath/ath12k/hw.h
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
 /*
  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #ifndef ATH12K_HW_H
@@ -195,6 +195,8 @@ struct ath12k_hw_params {
 
 	u8 def_num_link;
 	u16 max_mlo_peer;
+
+	bool supports_sta_ps;
 };
 
 struct ath12k_hw_ops {
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index a27480a69b27..465480f52903 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -2509,12 +2509,60 @@ static int ath12k_mac_fils_discovery(struct ath12k_vif *arvif,
 	return ret;
 }
 
+static void ath12k_mac_vif_setup_ps(struct ath12k_vif *arvif)
+{
+	struct ath12k *ar = arvif->ar;
+	struct ieee80211_vif *vif = arvif->vif;
+	struct ieee80211_conf *conf = &ath12k_ar_to_hw(ar)->conf;
+	enum wmi_sta_powersave_param param;
+	enum wmi_sta_ps_mode psmode;
+	int ret;
+	int timeout;
+	bool enable_ps;
+
+	lockdep_assert_held(&ar->conf_mutex);
+
+	if (vif->type != NL80211_IFTYPE_STATION)
+		return;
+
+	enable_ps = arvif->ps;
+	if (enable_ps) {
+		psmode = WMI_STA_PS_MODE_ENABLED;
+		param = WMI_STA_PS_PARAM_INACTIVITY_TIME;
+
+		timeout = conf->dynamic_ps_timeout;
+		if (timeout == 0) {
+			/* firmware doesn't like 0 */
+			timeout = ieee80211_tu_to_usec(vif->bss_conf.beacon_int) / 1000;
+		}
+
+		ret = ath12k_wmi_set_sta_ps_param(ar, arvif->vdev_id, param,
+						  timeout);
+		if (ret) {
+			ath12k_warn(ar->ab, "failed to set inactivity time for vdev %d: %i\n",
+				    arvif->vdev_id, ret);
+			return;
+		}
+	} else {
+		psmode = WMI_STA_PS_MODE_DISABLED;
+	}
+
+	ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev %d psmode %s\n",
+		   arvif->vdev_id, psmode ? "enable" : "disable");
+
+	ret = ath12k_wmi_pdev_set_ps_mode(ar, arvif->vdev_id, psmode);
+	if (ret)
+		ath12k_warn(ar->ab, "failed to set sta power save mode %d for vdev %d: %d\n",
+			    psmode, arvif->vdev_id, ret);
+}
+
 static void ath12k_mac_bss_info_changed(struct ath12k *ar,
 					struct ath12k_vif *arvif,
 					struct ieee80211_bss_conf *info,
 					u64 changed)
 {
 	struct ieee80211_vif *vif = arvif->vif;
+	struct ieee80211_vif_cfg *vif_cfg = &vif->cfg;
 	struct cfg80211_chan_def def;
 	u32 param_id, param_value;
 	enum nl80211_band band;
@@ -2787,6 +2835,12 @@ static void ath12k_mac_bss_info_changed(struct ath12k *ar,
 
 	if (changed & BSS_CHANGED_EHT_PUNCTURING)
 		arvif->punct_bitmap = info->eht_puncturing;
+
+	if (changed & BSS_CHANGED_PS &&
+	    ar->ab->hw_params->supports_sta_ps) {
+		arvif->ps = vif_cfg->ps;
+		ath12k_mac_vif_setup_ps(arvif);
+	}
 }
 
 static void ath12k_mac_op_bss_info_changed(struct ieee80211_hw *hw,

base-commit: d4d13947306ab3c98c84389d9397563b550b71b8
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] wifi: ath12k: enable 802.11 power save mode in station mode
  2024-02-01  3:58 [PATCH] wifi: ath12k: enable 802.11 power save mode in station mode Baochen Qiang
@ 2024-02-01 17:48 ` Jeff Johnson
  2024-02-02 13:51 ` Kalle Valo
  2024-02-05 16:59 ` Kalle Valo
  2 siblings, 0 replies; 6+ messages in thread
From: Jeff Johnson @ 2024-02-01 17:48 UTC (permalink / raw)
  To: Baochen Qiang, ath12k; +Cc: linux-wireless

On 1/31/2024 7:58 PM, Baochen Qiang wrote:
> To reduce power consumption enable 802.11 power save mode in
> station mode. This allows both radio and CPU to sleep more.
> 
> Only enable the mode on WCN7850, other chips don't support it
> for now.
> 
> To test that power save mode is running, run below command and
> check there is no NULL Data frame seen by a sniffer:
>         iw dev <inf> set power_save off
> 
> And run below command, then check there is a NULL Data frame
> in sniffer:
>         iw dev <inf> set power_save on
> 
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
> 
> Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] wifi: ath12k: enable 802.11 power save mode in station mode
  2024-02-01  3:58 [PATCH] wifi: ath12k: enable 802.11 power save mode in station mode Baochen Qiang
  2024-02-01 17:48 ` Jeff Johnson
@ 2024-02-02 13:51 ` Kalle Valo
  2024-02-02 16:17   ` Jeff Johnson
  2024-02-03  3:54   ` Baochen Qiang
  2024-02-05 16:59 ` Kalle Valo
  2 siblings, 2 replies; 6+ messages in thread
From: Kalle Valo @ 2024-02-02 13:51 UTC (permalink / raw)
  To: Baochen Qiang; +Cc: ath12k, linux-wireless

Baochen Qiang <quic_bqiang@quicinc.com> writes:

> To reduce power consumption enable 802.11 power save mode in
> station mode. This allows both radio and CPU to sleep more.
>
> Only enable the mode on WCN7850, other chips don't support it
> for now.
>
> To test that power save mode is running, run below command and
> check there is no NULL Data frame seen by a sniffer:
>         iw dev <inf> set power_save off
>
> And run below command, then check there is a NULL Data frame
> in sniffer:
>         iw dev <inf> set power_save on
>
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
>
> Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com>

This had simple conflicts in hw_params, please check:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=f776fd9ccb6561c4e4fdf05552a8b57a06686a90

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] wifi: ath12k: enable 802.11 power save mode in station mode
  2024-02-02 13:51 ` Kalle Valo
@ 2024-02-02 16:17   ` Jeff Johnson
  2024-02-03  3:54   ` Baochen Qiang
  1 sibling, 0 replies; 6+ messages in thread
From: Jeff Johnson @ 2024-02-02 16:17 UTC (permalink / raw)
  To: Kalle Valo, Baochen Qiang; +Cc: ath12k, linux-wireless

On 2/2/2024 5:51 AM, Kalle Valo wrote:
> Baochen Qiang <quic_bqiang@quicinc.com> writes:
> 
>> To reduce power consumption enable 802.11 power save mode in
>> station mode. This allows both radio and CPU to sleep more.
>>
>> Only enable the mode on WCN7850, other chips don't support it
>> for now.
>>
>> To test that power save mode is running, run below command and
>> check there is no NULL Data frame seen by a sniffer:
>>         iw dev <inf> set power_save off
>>
>> And run below command, then check there is a NULL Data frame
>> in sniffer:
>>         iw dev <inf> set power_save on
>>
>> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
>>
>> Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com>
> 
> This had simple conflicts in hw_params, please check:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=f776fd9ccb6561c4e4fdf05552a8b57a06686a90
> 
LGTM


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] wifi: ath12k: enable 802.11 power save mode in station mode
  2024-02-02 13:51 ` Kalle Valo
  2024-02-02 16:17   ` Jeff Johnson
@ 2024-02-03  3:54   ` Baochen Qiang
  1 sibling, 0 replies; 6+ messages in thread
From: Baochen Qiang @ 2024-02-03  3:54 UTC (permalink / raw)
  To: Kalle Valo; +Cc: ath12k, linux-wireless



On 2/2/2024 9:51 PM, Kalle Valo wrote:
> Baochen Qiang <quic_bqiang@quicinc.com> writes:
> 
>> To reduce power consumption enable 802.11 power save mode in
>> station mode. This allows both radio and CPU to sleep more.
>>
>> Only enable the mode on WCN7850, other chips don't support it
>> for now.
>>
>> To test that power save mode is running, run below command and
>> check there is no NULL Data frame seen by a sniffer:
>>          iw dev <inf> set power_save off
>>
>> And run below command, then check there is a NULL Data frame
>> in sniffer:
>>          iw dev <inf> set power_save on
>>
>> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
>>
>> Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com>
> 
> This had simple conflicts in hw_params, please check:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=f776fd9ccb6561c4e4fdf05552a8b57a06686a90
> 
LGTM


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] wifi: ath12k: enable 802.11 power save mode in station mode
  2024-02-01  3:58 [PATCH] wifi: ath12k: enable 802.11 power save mode in station mode Baochen Qiang
  2024-02-01 17:48 ` Jeff Johnson
  2024-02-02 13:51 ` Kalle Valo
@ 2024-02-05 16:59 ` Kalle Valo
  2 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2024-02-05 16:59 UTC (permalink / raw)
  To: Baochen Qiang; +Cc: ath12k, linux-wireless, quic_bqiang

Baochen Qiang <quic_bqiang@quicinc.com> wrote:

> To reduce power consumption enable 802.11 power save mode in
> station mode. This allows both radio and CPU to sleep more.
> 
> Only enable the mode on WCN7850, other chips don't support it
> for now.
> 
> To test that power save mode is running, run below command and
> check there is no NULL Data frame seen by a sniffer:
>         iw dev <inf> set power_save off
> 
> And run below command, then check there is a NULL Data frame
> in sniffer:
>         iw dev <inf> set power_save on
> 
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
> 
> Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com>
> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>

Patch applied to ath-next branch of ath.git, thanks.

54ca3308a23c wifi: ath12k: enable 802.11 power save mode in station mode

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20240201035830.2534-1-quic_bqiang@quicinc.com/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-02-05 17:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-01  3:58 [PATCH] wifi: ath12k: enable 802.11 power save mode in station mode Baochen Qiang
2024-02-01 17:48 ` Jeff Johnson
2024-02-02 13:51 ` Kalle Valo
2024-02-02 16:17   ` Jeff Johnson
2024-02-03  3:54   ` Baochen Qiang
2024-02-05 16:59 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox