wifi: ath10k: Fix WoW wakeups on WCN3990
cover wifi: ath10k: Fix WoW wakeups on WCN3990
With WoWLAN enabled, WCN3990 firmware wakes the host on action frames right after every WoW entry, so the system hardly stays suspended. And when the firmware does wake the host for a real reason, user space cannot see that it was a network wakeup.
Patch 1 sets the action frame wakeup filter that Qualcomm's own host drivers set. Patch 2 reports WoW wakeups to the PM core.
Both are in daily use on a OnePlus 6 (sdm845) since late September, with an sdm845-mainline 7.1-rc1 based kernel. On ath-next they were only build tested (W=1). I could not test QCA6174 or QCA9377. qcacld-2.0, the vendor driver for QCA6174, sends the same command, so I expect their firmware to know it.
Tool use: the analysis, the code and the commit messages were written with an LLM coding assistant (Claude Code). I reviewed all of it and tested it on my phone as described above.
Michael Auer (2):
wifi: ath10k: configure the WoW action frame wakeup filter
wifi: ath10k: report WoW wakeups to the PM core
drivers/net/wireless/ath/ath10k/wmi-ops.h | 19 +++++++++ drivers/net/wireless/ath/ath10k/wmi-tlv.c | 47 +++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/wmi-tlv.h | 32 +++++++++++++++ drivers/net/wireless/ath/ath10k/wmi.c | 8 +++- drivers/net/wireless/ath/ath10k/wmi.h | 23 +++++++++++ drivers/net/wireless/ath/ath10k/wow.c | 10 +++++ 6 files changed, 137 insertions(+), 2 deletions(-)
base-commit: 1983b40acfcb3c3464b291c85977290a785bcfdc
Signature · 1 line
2.43.0
PATCH 1/2 wifi: ath10k: configure the WoW action frame wakeup filter
On WCN3990 almost every system suspend with WoWLAN enabled ends within a second. The firmware wakes the host with wake reason 38, which is WOW_REASON_ACTION_FRAME_RECV in Qualcomm's fw-api. ath10k's wake reason enum stops at 27, so the debug log shows "wow wakeup host reason (null)".
Qualcomm's own host drivers (qcacld-2.0 and qcacld-3.0) send WMI_WOW_SET_ACTION_WAKE_UP_CMDID, which sets the action frame categories that may wake the host. ath10k never sends it, so the firmware default applies.
Send it for station vdevs in ath10k_vif_wow_set_wakeups() with the values of qcacld-3.0: allow spectrum management, QoS, public, SA query, protected dual of public, WNM, WME, FST and VHT action frames, and ignore spectrum management Measurement and TPC Requests. A failure is logged and does not abort the suspend.
Also add wake reasons 28 to 38 and print the reason number, so unknown reasons are visible.
On a OnePlus 6, 3 of 3 WoW suspends were woken within 1 s with reason 38 before this change. With it, suspends last until a real wakeup (magic packet, pattern match or RTC). In a one hour idle test with a push connection the phone was suspended 87.6 % of the time.
Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.2.0.c8-00050-QCAHLSWMTPLZ-1
---
The per-category array has 32 words, like the 2018 qcacld-3.0 for sdm845. qcacld-2.0 and newer qcacld-3.0 send 256. The fw-api defines it as a variable length array, and all allowed categories are below
32. I only tested 32.
drivers/net/wireless/ath/ath10k/wmi-ops.h | 19 +++++++++ drivers/net/wireless/ath/ath10k/wmi-tlv.c | 47 +++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/wmi-tlv.h | 32 +++++++++++++++ drivers/net/wireless/ath/ath10k/wmi.c | 4 +- drivers/net/wireless/ath/ath10k/wmi.h | 23 +++++++++++ drivers/net/wireless/ath/ath10k/wow.c | 10 +++++ 6 files changed, 133 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/wmi-ops.h +19 -0
@@ -179,6 +179,8 @@ struct wmi_ops {enum wmi_wow_wakeup_event event, u32 enable);struct sk_buff *(*gen_wow_host_wakeup_ind)(struct ath10k *ar); +struct sk_buff *(*gen_wow_set_action_wake_up)(struct ath10k *ar, +u32 vdev_id); struct sk_buff *(*gen_wow_add_pattern)(struct ath10k *ar, u32 vdev_id, u32 pattern_id, const u8 *pattern,
@@ -1422,6 +1424,23 @@ ath10k_wmi_wow_host_wakeup_ind(struct ath10k *ar)return ath10k_wmi_cmd_send (ar, skb, cmd_id); } +static inline int +ath10k_wmi_wow_set_action_wake_up (struct ath10k *ar,u32 vdev_id) +{ +struct sk_buff *skb; +u32 cmd_id; + +if (!ar->wmi.ops->gen_wow_set_action_wake_up) +return -EOPNOTSUPP ; + + skb = ar->wmi.ops->gen_wow_set_action_wake_up (ar, vdev_id); +if (IS_ERR (skb)) +return PTR_ERR (skb); + + cmd_id = ar->wmi.cmd->wow_set_action_wake_up_cmdid; +return ath10k_wmi_cmd_send (ar, skb, cmd_id); +} + static inline int ath10k_wmi_wow_add_pattern(struct ath10k *ar, u32 vdev_id, u32 pattern_id, const u8 *pattern, const u8 *mask,
drivers/net/wireless/ath/ath10k/wmi-tlv.c +47 -0
65 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/wmi-tlv.h +32 -0
@@ -189,6 +189,10 @@ enum wmi_tlv_cmd_id {WMI_TLV_EXTWOW_ENABLE_CMDID ,WMI_TLV_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID ,WMI_TLV_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID , +WMI_TLV_WOW_ENABLE_ICMPV6_NA_FLT_CMDID , +WMI_TLV_WOW_UDP_SVC_OFLD_CMDID , +WMI_TLV_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID , +WMI_TLV_WOW_SET_ACTION_WAKE_UP_CMDID ,WMI_TLV_RTT_MEASREQ_CMDID =WMI_TLV_CMD (WMI_TLV_GRP_RTT ),WMI_TLV_RTT_TSF_CMDID , WMI_TLV_SPECTRAL_SCAN_CONF_CMDID = WMI_TLV_CMD(WMI_TLV_GRP_SPECTRAL),
@@ -2202,6 +2206,34 @@ struct wmi_tlv_wow_add_del_event_cmd {__le32 event_bitmap; } __packed; +/* Action frame categories that may wake the host from WoW, as in +* qcacld-3.0: spectrum management (0), QoS (1), public (4), SA query (8), +* protected dual of public (9), WNM (10), WME (17), FST (18), VHT (21). +*/ +#define WMI_TLV_WOW_ACTION_WAKE_UP_CATEGORY_MAP0 0x00260713 + +/* Per-category bitmaps of action codes to ignore (1 = ignore). Like +* qcacld-3.0, ignore Measurement Request (0) and TPC Request (2). +*/ +#define WMI_TLV_WOW_ACTION_WAKE_UP_NUM_CATEGORIES 32 +#define WMI_TLV_WOW_ACTION_WAKE_UP_SPECTRUM_MGMT_IGNORE (BIT(0) | BIT(2)) + +enum wmi_tlv_wow_action_wake_up_op { +WMI_TLV_WOW_ACTION_WAKE_UP_OP_RESET =0 , +WMI_TLV_WOW_ACTION_WAKE_UP_OP_SET =1 , +WMI_TLV_WOW_ACTION_WAKE_UP_OP_ADD_SET =2 , +WMI_TLV_WOW_ACTION_WAKE_UP_OP_DELETE_SET =3 , +}; + +/* WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param, followed by a +* WMI_TLV_TAG_ARRAY_UINT32 of per-category action code bitmaps. +*/ +struct wmi_tlv_wow_set_action_wake_up_cmd { +__le32 vdev_id; +__le32 operation; +__le32 action_category_map[8 ]; +} __packed; +struct wmi_tlv_request_peer_stats_info {__le32 request_type;__le32 vdev_id;
drivers/net/wireless/ath/ath10k/wmi.c +2 -2
@@ -4673,8 +4673,8 @@ void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, struct sk_buff *skb)return ; } -ath10k_dbg (ar,ATH10K_DBG_WMI ,"wow wakeup host reason %s\n" , -wow_reason (ev.wake_reason)); +ath10k_dbg (ar,ATH10K_DBG_WMI ,"wow wakeup host reason %d %s\n" , + ev.wake_reason,wow_reason (ev.wake_reason)); }void ath10k_wmi_event_dcs_interference (struct ath10k *ar,struct sk_buff *skb)
drivers/net/wireless/ath/ath10k/wmi.h +23 -0
@@ -944,6 +944,7 @@ struct wmi_cmd_map {u32 wow_enable_disable_wake_event_cmdid;u32 wow_enable_cmdid;u32 wow_hostwakeup_from_sleep_cmdid; +u32 wow_set_action_wake_up_cmdid;u32 rtt_measreq_cmdid;u32 rtt_tsf_cmdid;u32 vdev_spectral_scan_configure_cmdid;
@@ -7060,6 +7061,17 @@ enum wmi_wow_wake_reason {WOW_REASON_DFS_PHYERR_RADADR_EVENT ,WOW_REASON_BEACON_RECV ,WOW_REASON_CLIENT_KICKOUT_EVENT , +WOW_REASON_NAN_EVENT , +WOW_REASON_EXTSCAN , +WOW_REASON_RSSI_BREACH_EVENT , +WOW_REASON_IOAC_REV_KA_FAIL_EVENT , +WOW_REASON_IOAC_SOCK_EVENT , +WOW_REASON_NLO_SCAN_COMPLETE , +WOW_REASON_PACKET_FILTER_MATCH , +WOW_REASON_ASSOC_RES_RECV , +WOW_REASON_REASSOC_REQ_RECV , +WOW_REASON_REASSOC_RES_RECV , +WOW_REASON_ACTION_FRAME_RECV , WOW_REASON_DEBUG_TEST = 0xFF, };
@@ -7095,6 +7107,17 @@ static inline const char *wow_reason(enum wmi_wow_wake_reason reason)C2S (WOW_REASON_DFS_PHYERR_RADADR_EVENT );C2S (WOW_REASON_BEACON_RECV );C2S (WOW_REASON_CLIENT_KICKOUT_EVENT ); +C2S (WOW_REASON_NAN_EVENT ); +C2S (WOW_REASON_EXTSCAN ); +C2S (WOW_REASON_RSSI_BREACH_EVENT ); +C2S (WOW_REASON_IOAC_REV_KA_FAIL_EVENT ); +C2S (WOW_REASON_IOAC_SOCK_EVENT ); +C2S (WOW_REASON_NLO_SCAN_COMPLETE ); +C2S (WOW_REASON_PACKET_FILTER_MATCH ); +C2S (WOW_REASON_ASSOC_RES_RECV ); +C2S (WOW_REASON_REASSOC_REQ_RECV ); +C2S (WOW_REASON_REASSOC_RES_RECV ); +C2S (WOW_REASON_ACTION_FRAME_RECV );C2S (WOW_REASON_DEBUG_TEST );default :return NULL ;
drivers/net/wireless/ath/ath10k/wow.c +10 -0
@@ -380,6 +380,16 @@ static int ath10k_vif_wow_set_wakeups(struct ath10k_vif *arvif, } } +if (arvif->vdev_type ==WMI_VDEV_TYPE_STA ) { +/* Without this filter WCN3990 wakes the host on action +* frames right after WoW is enabled. +*/ + ret =ath10k_wmi_wow_set_action_wake_up (ar, arvif->vdev_id); +if (ret && ret != -EOPNOTSUPP ) +ath10k_warn (ar,"failed to set action frame wakeup filter on vdev %i: %d\n" , + arvif->vdev_id, ret); + } +return 0 ; }
Signature · 1 line
2.43.0
Re: [PATCH 1/2] wifi: ath10k: configure the WoW action frame wakeup filter
Hi Michael,
Quoted 167 lines · Michael Auer
On WCN3990 almost every system suspend with WoWLAN enabled ends within a second. The firmware wakes the host with wake reason 38, which is
WOW_REASON_ACTION_FRAME_RECVin Qualcomm's fw-api. ath10k's wake reason enum stops at 27, so the debug log shows "wow wakeup host reason (null)".Qualcomm's own host drivers (qcacld-2.0 and qcacld-3.0) send
WMI_WOW_SET_ACTION_WAKE_UP_CMDID, which sets the action frame categories that may wake the host. ath10k never sends it, so the firmware default applies.Send it for station vdevs in
ath10k_vif_wow_set_wakeups()with the values of qcacld-3.0: allow spectrum management, QoS, public, SA query, protected dual of public, WNM, WME, FST and VHT action frames, and ignore spectrum management Measurement and TPC Requests. A failure is logged and does not abort the suspend.Also add wake reasons 28 to 38 and print the reason number, so unknown reasons are visible.
On a OnePlus 6, 3 of 3 WoW suspends were woken within 1 s with reason 38 before this change. With it, suspends last until a real wakeup (magic packet, pattern match or RTC). In a one hour idle test with a push connection the phone was suspended 87.6 % of the time.
Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.2.0.c8-00050-QCAHLSWMTPLZ-1
Signed-off-by Michael Auer <[email protected]>---
The per-category array has 32 words, like the 2018 qcacld-3.0 for sdm845. qcacld-2.0 and newer qcacld-3.0 send 256. The fw-api defines it as a variable length array, and all allowed categories are below
32. I only tested 32.drivers/net/wireless/ath/ath10k/wmi-ops.h | 19 +++++++++ drivers/net/wireless/ath/ath10k/wmi-tlv.c | 47 +++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/wmi-tlv.h | 32 +++++++++++++++ drivers/net/wireless/ath/ath10k/wmi.c | 4 +- drivers/net/wireless/ath/ath10k/wmi.h | 23 +++++++++++ drivers/net/wireless/ath/ath10k/wow.c | 10 +++++ 6 files changed, 133 insertions(+), 2 deletions(-)drivers/net/wireless/ath/ath10k/wmi-ops.h +19
-0@@ -179,6 +179,8 @@ struct wmi_ops {enum wmi_wow_wakeup_event event, u32 enable);struct sk_buff *(*gen_wow_host_wakeup_ind)(struct ath10k *ar); +struct sk_buff *(*gen_wow_set_action_wake_up)(struct ath10k *ar, +u32 vdev_id); struct sk_buff *(*gen_wow_add_pattern)(struct ath10k *ar, u32 vdev_id, u32 pattern_id, const u8 *pattern,@@ -1422,6 +1424,23 @@ ath10k_wmi_wow_host_wakeup_ind(struct ath10k *ar)return ath10k_wmi_cmd_send (ar, skb, cmd_id); } +static inline int +ath10k_wmi_wow_set_action_wake_up (struct ath10k *ar,u32 vdev_id) +{ +struct sk_buff *skb; +u32 cmd_id; + +if (!ar->wmi.ops->gen_wow_set_action_wake_up) +return -EOPNOTSUPP ; + + skb = ar->wmi.ops->gen_wow_set_action_wake_up (ar, vdev_id); +if (IS_ERR (skb)) +return PTR_ERR (skb); + + cmd_id = ar->wmi.cmd->wow_set_action_wake_up_cmdid; +return ath10k_wmi_cmd_send (ar, skb, cmd_id); +} + static inline int ath10k_wmi_wow_add_pattern(struct ath10k *ar, u32 vdev_id, u32 pattern_id, const u8 *pattern, const u8 *mask,drivers/net/wireless/ath/ath10k/wmi-tlv.c +47
-0@@ -3713,6 +3713,51 @@ ath10k_wmi_tlv_op_gen_wow_add_wakeup_event(struct ath10k *ar,return skb; } +static struct sk_buff * +ath10k_wmi_tlv_op_gen_wow_set_action_wake_up (struct ath10k *ar,u32 vdev_id) +{ +struct wmi_tlv_wow_set_action_wake_up_cmd *cmd; +struct wmi_tlv *tlv; +struct sk_buff *skb; +__le32 *bitmaps; +void *ptr; +size_t len; + + len =sizeof (*tlv) +sizeof (*cmd) + +sizeof (*tlv) + +WMI_TLV_WOW_ACTION_WAKE_UP_NUM_CATEGORIES *sizeof (__le32); + skb =ath10k_wmi_alloc_skb (ar, len); +if (!skb) +return ERR_PTR (-ENOMEM ); + + ptr = (void *)skb->data; + tlv = ptr; + tlv->tag =__cpu_to_le16 (WMI_TLV_TAG_STRUCT_WOW_SET_ACTION_WAKE_UP_CMD ); + tlv->len =__cpu_to_le16 (sizeof (*cmd)); + cmd = (void *)tlv->value; + + cmd->vdev_id =__cpu_to_le32 (vdev_id); + cmd->operation =__cpu_to_le32 (WMI_TLV_WOW_ACTION_WAKE_UP_OP_SET ); + cmd->action_category_map[0 ] = +__cpu_to_le32 (WMI_TLV_WOW_ACTION_WAKE_UP_CATEGORY_MAP0 ); + + ptr +=sizeof (*tlv); + ptr +=sizeof (*cmd); + + tlv = ptr; + tlv->tag =__cpu_to_le16 (WMI_TLV_TAG_ARRAY_UINT32 ); + tlv->len =__cpu_to_le16 (WMI_TLV_WOW_ACTION_WAKE_UP_NUM_CATEGORIES * +sizeof (__le32)); + bitmaps = (void *)tlv->value; + bitmaps[WLAN_CATEGORY_SPECTRUM_MGMT ] = +__cpu_to_le32 (WMI_TLV_WOW_ACTION_WAKE_UP_SPECTRUM_MGMT_IGNORE ); + +ath10k_dbg (ar,ATH10K_DBG_WMI , +"wmi tlv wow set action wake up vdev_id %d category map 0x%08x\n" , + vdev_id,WMI_TLV_WOW_ACTION_WAKE_UP_CATEGORY_MAP0 ); +return skb; +} +static struct sk_buff *ath10k_wmi_tlv_gen_wow_host_wakeup_ind (struct ath10k *ar) {@@ -4272,6 +4317,7 @@ static struct wmi_cmd_map wmi_tlv_cmd_map = { .wow_enable_cmdid = WMI_TLV_WOW_ENABLE_CMDID, .wow_hostwakeup_from_sleep_cmdid = WMI_TLV_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID, + .wow_set_action_wake_up_cmdid = WMI_TLV_WOW_SET_ACTION_WAKE_UP_CMDID, .rtt_measreq_cmdid = WMI_TLV_RTT_MEASREQ_CMDID, .rtt_tsf_cmdid = WMI_TLV_RTT_TSF_CMDID, .vdev_spectral_scan_configure_cmdid = WMI_TLV_SPECTRAL_SCAN_CONF_CMDID,@@ -4604,6 +4650,7 @@ static const struct wmi_ops wmi_tlv_ops = { .gen_wow_enable = ath10k_wmi_tlv_op_gen_wow_enable, .gen_wow_add_wakeup_event = ath10k_wmi_tlv_op_gen_wow_add_wakeup_event, .gen_wow_host_wakeup_ind = ath10k_wmi_tlv_gen_wow_host_wakeup_ind, + .gen_wow_set_action_wake_up = ath10k_wmi_tlv_op_gen_wow_set_action_wake_up, .gen_wow_add_pattern = ath10k_wmi_tlv_op_gen_wow_add_pattern, .gen_wow_del_pattern = ath10k_wmi_tlv_op_gen_wow_del_pattern, .gen_wow_config_pno = ath10k_wmi_tlv_op_gen_config_pno,drivers/net/wireless/ath/ath10k/wmi-tlv.h +4
-0@@ -189,6 +189,10 @@ enum wmi_tlv_cmd_id {WMI_TLV_EXTWOW_ENABLE_CMDID ,WMI_TLV_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID ,WMI_TLV_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID , +WMI_TLV_WOW_ENABLE_ICMPV6_NA_FLT_CMDID , +WMI_TLV_WOW_UDP_SVC_OFLD_CMDID , +WMI_TLV_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID , +WMI_TLV_WOW_SET_ACTION_WAKE_UP_CMDID ,WMI_TLV_RTT_MEASREQ_CMDID =WMI_TLV_CMD (WMI_TLV_GRP_RTT ),WMI_TLV_RTT_TSF_CMDID , WMI_TLV_SPECTRAL_SCAN_CONF_CMDID = WMI_TLV_CMD(WMI_TLV_GRP_SPECTRAL),
drivers/net/wireless/ath/ath10k/wmi-tlv.h struct wmi_tlv_wow_add_del_event_cmd { · line 2213
Quoted 8 lines
drivers/net/wireless/ath/ath10k/wmi-tlv.h +5
-0@@ -2202,6 +2206,34 @@ struct wmi_tlv_wow_add_del_event_cmd {__le32 event_bitmap; } __packed; +/* Action frame categories that may wake the host from WoW, as in +* qcacld-3.0: spectrum management (0), QoS (1), public (4), SA query (8), +* protected dual of public (9), WNM (10), WME (17), FST (18), VHT (21). +*/ +#define WMI_TLV_WOW_ACTION_WAKE_UP_CATEGORY_MAP0 0x00260713
You describe the bitfield above, so please add defines for the categories.
drivers/net/wireless/ath/ath10k/wmi-tlv.h struct wmi_tlv_wow_add_del_event_cmd { · line 2219
Quoted 6 lines
drivers/net/wireless/ath/ath10k/wmi-tlv.h +6
-0+ +/* Per-category bitmaps of action codes to ignore (1 = ignore). Like +* qcacld-3.0, ignore Measurement Request (0) and TPC Request (2). +*/ +#define WMI_TLV_WOW_ACTION_WAKE_UP_NUM_CATEGORIES 32 +#define WMI_TLV_WOW_ACTION_WAKE_UP_SPECTRUM_MGMT_IGNORE (BIT(0) | BIT(2))
Same as above.
Quoted 52 lines
drivers/net/wireless/ath/ath10k/wmi-tlv.h +17
-0+ +enum wmi_tlv_wow_action_wake_up_op { +WMI_TLV_WOW_ACTION_WAKE_UP_OP_RESET =0 , +WMI_TLV_WOW_ACTION_WAKE_UP_OP_SET =1 , +WMI_TLV_WOW_ACTION_WAKE_UP_OP_ADD_SET =2 , +WMI_TLV_WOW_ACTION_WAKE_UP_OP_DELETE_SET =3 , +}; + +/* WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param, followed by a +* WMI_TLV_TAG_ARRAY_UINT32 of per-category action code bitmaps. +*/ +struct wmi_tlv_wow_set_action_wake_up_cmd { +__le32 vdev_id; +__le32 operation; +__le32 action_category_map[8 ]; +} __packed; +struct wmi_tlv_request_peer_stats_info {__le32 request_type;__le32 vdev_id;drivers/net/wireless/ath/ath10k/wmi.c +2
-2@@ -4673,8 +4673,8 @@ void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, struct sk_buff *skb)return ; } -ath10k_dbg (ar,ATH10K_DBG_WMI ,"wow wakeup host reason %s\n" , -wow_reason (ev.wake_reason)); +ath10k_dbg (ar,ATH10K_DBG_WMI ,"wow wakeup host reason %d %s\n" , + ev.wake_reason,wow_reason (ev.wake_reason)); }void ath10k_wmi_event_dcs_interference (struct ath10k *ar,struct sk_buff *skb)drivers/net/wireless/ath/ath10k/wmi.h +2
-0@@ -944,6 +944,7 @@ struct wmi_cmd_map {u32 wow_enable_disable_wake_event_cmdid;u32 wow_enable_cmdid;u32 wow_hostwakeup_from_sleep_cmdid; +u32 wow_set_action_wake_up_cmdid;u32 rtt_measreq_cmdid;u32 rtt_tsf_cmdid;u32 vdev_spectral_scan_configure_cmdid;@@ -7060,6 +7061,17 @@ enum wmi_wow_wake_reason {WOW_REASON_DFS_PHYERR_RADADR_EVENT ,WOW_REASON_BEACON_RECV ,WOW_REASON_CLIENT_KICKOUT_EVENT , + WOW_REASON_NAN_EVENT,
drivers/net/wireless/ath/ath10k/wmi.h enum wmi_wow_wake_reason { · line 7074
Quoted 10 lines
drivers/net/wireless/ath/ath10k/wmi.h +10
-0+WOW_REASON_EXTSCAN , +WOW_REASON_RSSI_BREACH_EVENT , +WOW_REASON_IOAC_REV_KA_FAIL_EVENT , +WOW_REASON_IOAC_SOCK_EVENT , +WOW_REASON_NLO_SCAN_COMPLETE , +WOW_REASON_PACKET_FILTER_MATCH , +WOW_REASON_ASSOC_RES_RECV , +WOW_REASON_REASSOC_REQ_RECV , +WOW_REASON_REASSOC_RES_RECV , + WOW_REASON_ACTION_FRAME_RECV,
I think addition of the new reason and above debug message change should be split in another patch/commit.
Quoted 45 lines
drivers/net/wireless/ath/ath10k/wmi.h +11
-0WOW_REASON_DEBUG_TEST = 0xFF, };@@ -7095,6 +7107,17 @@ static inline const char *wow_reason(enum wmi_wow_wake_reason reason)C2S (WOW_REASON_DFS_PHYERR_RADADR_EVENT );C2S (WOW_REASON_BEACON_RECV );C2S (WOW_REASON_CLIENT_KICKOUT_EVENT ); +C2S (WOW_REASON_NAN_EVENT ); +C2S (WOW_REASON_EXTSCAN ); +C2S (WOW_REASON_RSSI_BREACH_EVENT ); +C2S (WOW_REASON_IOAC_REV_KA_FAIL_EVENT ); +C2S (WOW_REASON_IOAC_SOCK_EVENT ); +C2S (WOW_REASON_NLO_SCAN_COMPLETE ); +C2S (WOW_REASON_PACKET_FILTER_MATCH ); +C2S (WOW_REASON_ASSOC_RES_RECV ); +C2S (WOW_REASON_REASSOC_REQ_RECV ); +C2S (WOW_REASON_REASSOC_RES_RECV ); +C2S (WOW_REASON_ACTION_FRAME_RECV );C2S (WOW_REASON_DEBUG_TEST );default :return NULL ;drivers/net/wireless/ath/ath10k/wow.c +10
-1@@ -380,6 +380,16 @@ static int ath10k_vif_wow_set_wakeups(struct ath10k_vif *arvif, } } +if (arvif->vdev_type ==WMI_VDEV_TYPE_STA ) { +/* Without this filter WCN3990 wakes the host on action +* frames right after WoW is enabled. +*/ + ret =ath10k_wmi_wow_set_action_wake_up (ar, arvif->vdev_id); +if (ret && ret != -EOPNOTSUPP ) +ath10k_warn (ar,"failed to set action frame wakeup filter on vdev %i: %d\n" , + arvif->vdev_id, ret); + } +return 0 ; } --2.43.0
Re: [PATCH 1/2] wifi: ath10k: configure the WoW action frame wakeup filter
Hi Loic,
Thanks for the review! I had already sent a v2 before your mail, for a fix in patch 2, with patch 1 unchanged, so all three points go into v3:
- build the category map and the spectrum management ignore bitmap from the WLAN_CATEGORY_* and WLAN_ACTION_SPCT_* values in include/linux/ieee80211.h instead of the hex constants
- move the new wake reasons and the debug message change into their own patch
Michael
Quoted 297 lines · Loic Poulain
Hi Michael,
Quoted 166 lines · Michael Auer
On WCN3990 almost every system suspend with WoWLAN enabled ends within a second. The firmware wakes the host with wake reason 38, which is
WOW_REASON_ACTION_FRAME_RECVin Qualcomm's fw-api. ath10k's wake reason enum stops at 27, so the debug log shows "wow wakeup host reason (null)".Qualcomm's own host drivers (qcacld-2.0 and qcacld-3.0) send
WMI_WOW_SET_ACTION_WAKE_UP_CMDID, which sets the action frame categories that may wake the host. ath10k never sends it, so the firmware default applies.Send it for station vdevs in
ath10k_vif_wow_set_wakeups()with the values of qcacld-3.0: allow spectrum management, QoS, public, SA query, protected dual of public, WNM, WME, FST and VHT action frames, and ignore spectrum management Measurement and TPC Requests. A failure is logged and does not abort the suspend.Also add wake reasons 28 to 38 and print the reason number, so unknown reasons are visible.
On a OnePlus 6, 3 of 3 WoW suspends were woken within 1 s with reason 38 before this change. With it, suspends last until a real wakeup (magic packet, pattern match or RTC). In a one hour idle test with a push connection the phone was suspended 87.6 % of the time.
Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.2.0.c8-00050-QCAHLSWMTPLZ-1
Signed-off-by Michael Auer <[email protected]>---
The per-category array has 32 words, like the 2018 qcacld-3.0 for sdm845. qcacld-2.0 and newer qcacld-3.0 send 256. The fw-api defines it as a variable length array, and all allowed categories are below
32. I only tested 32.drivers/net/wireless/ath/ath10k/wmi-ops.h | 19 +++++++++ drivers/net/wireless/ath/ath10k/wmi-tlv.c | 47 +++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/wmi-tlv.h | 32 +++++++++++++++ drivers/net/wireless/ath/ath10k/wmi.c | 4 +- drivers/net/wireless/ath/ath10k/wmi.h | 23 +++++++++++ drivers/net/wireless/ath/ath10k/wow.c | 10 +++++ 6 files changed, 133 insertions(+), 2 deletions(-)drivers/net/wireless/ath/ath10k/wmi-ops.h +19
-0@@ -179,6 +179,8 @@ struct wmi_ops {enum wmi_wow_wakeup_event event, u32 enable);struct sk_buff *(*gen_wow_host_wakeup_ind)(struct ath10k *ar); +struct sk_buff *(*gen_wow_set_action_wake_up)(struct ath10k *ar, +u32 vdev_id); struct sk_buff *(*gen_wow_add_pattern)(struct ath10k *ar, u32 vdev_id, u32 pattern_id, const u8 *pattern,@@ -1422,6 +1424,23 @@ ath10k_wmi_wow_host_wakeup_ind(struct ath10k *ar)return ath10k_wmi_cmd_send (ar, skb, cmd_id); } +static inline int +ath10k_wmi_wow_set_action_wake_up (struct ath10k *ar,u32 vdev_id) +{ +struct sk_buff *skb; +u32 cmd_id; + +if (!ar->wmi.ops->gen_wow_set_action_wake_up) +return -EOPNOTSUPP ; + + skb = ar->wmi.ops->gen_wow_set_action_wake_up (ar, vdev_id); +if (IS_ERR (skb)) +return PTR_ERR (skb); + + cmd_id = ar->wmi.cmd->wow_set_action_wake_up_cmdid; +return ath10k_wmi_cmd_send (ar, skb, cmd_id); +} + static inline int ath10k_wmi_wow_add_pattern(struct ath10k *ar, u32 vdev_id, u32 pattern_id, const u8 *pattern, const u8 *mask,drivers/net/wireless/ath/ath10k/wmi-tlv.c +47
-0@@ -3713,6 +3713,51 @@ ath10k_wmi_tlv_op_gen_wow_add_wakeup_event(struct ath10k *ar,return skb; } +static struct sk_buff * +ath10k_wmi_tlv_op_gen_wow_set_action_wake_up (struct ath10k *ar,u32 vdev_id) +{ +struct wmi_tlv_wow_set_action_wake_up_cmd *cmd; +struct wmi_tlv *tlv; +struct sk_buff *skb; +__le32 *bitmaps; +void *ptr; +size_t len; + + len =sizeof (*tlv) +sizeof (*cmd) + +sizeof (*tlv) + +WMI_TLV_WOW_ACTION_WAKE_UP_NUM_CATEGORIES *sizeof (__le32); + skb =ath10k_wmi_alloc_skb (ar, len); +if (!skb) +return ERR_PTR (-ENOMEM ); + + ptr = (void *)skb->data; + tlv = ptr; + tlv->tag =__cpu_to_le16 (WMI_TLV_TAG_STRUCT_WOW_SET_ACTION_WAKE_UP_CMD ); + tlv->len =__cpu_to_le16 (sizeof (*cmd)); + cmd = (void *)tlv->value; + + cmd->vdev_id =__cpu_to_le32 (vdev_id); + cmd->operation =__cpu_to_le32 (WMI_TLV_WOW_ACTION_WAKE_UP_OP_SET ); + cmd->action_category_map[0 ] = +__cpu_to_le32 (WMI_TLV_WOW_ACTION_WAKE_UP_CATEGORY_MAP0 ); + + ptr +=sizeof (*tlv); + ptr +=sizeof (*cmd); + + tlv = ptr; + tlv->tag =__cpu_to_le16 (WMI_TLV_TAG_ARRAY_UINT32 ); + tlv->len =__cpu_to_le16 (WMI_TLV_WOW_ACTION_WAKE_UP_NUM_CATEGORIES * +sizeof (__le32)); + bitmaps = (void *)tlv->value; + bitmaps[WLAN_CATEGORY_SPECTRUM_MGMT ] = +__cpu_to_le32 (WMI_TLV_WOW_ACTION_WAKE_UP_SPECTRUM_MGMT_IGNORE ); + +ath10k_dbg (ar,ATH10K_DBG_WMI , +"wmi tlv wow set action wake up vdev_id %d category map 0x%08x\n" , + vdev_id,WMI_TLV_WOW_ACTION_WAKE_UP_CATEGORY_MAP0 ); +return skb; +} +static struct sk_buff *ath10k_wmi_tlv_gen_wow_host_wakeup_ind (struct ath10k *ar) {@@ -4272,6 +4317,7 @@ static struct wmi_cmd_map wmi_tlv_cmd_map = { .wow_enable_cmdid = WMI_TLV_WOW_ENABLE_CMDID, .wow_hostwakeup_from_sleep_cmdid = WMI_TLV_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID, + .wow_set_action_wake_up_cmdid = WMI_TLV_WOW_SET_ACTION_WAKE_UP_CMDID, .rtt_measreq_cmdid = WMI_TLV_RTT_MEASREQ_CMDID, .rtt_tsf_cmdid = WMI_TLV_RTT_TSF_CMDID, .vdev_spectral_scan_configure_cmdid = WMI_TLV_SPECTRAL_SCAN_CONF_CMDID,@@ -4604,6 +4650,7 @@ static const struct wmi_ops wmi_tlv_ops = { .gen_wow_enable = ath10k_wmi_tlv_op_gen_wow_enable, .gen_wow_add_wakeup_event = ath10k_wmi_tlv_op_gen_wow_add_wakeup_event, .gen_wow_host_wakeup_ind = ath10k_wmi_tlv_gen_wow_host_wakeup_ind, + .gen_wow_set_action_wake_up = ath10k_wmi_tlv_op_gen_wow_set_action_wake_up, .gen_wow_add_pattern = ath10k_wmi_tlv_op_gen_wow_add_pattern, .gen_wow_del_pattern = ath10k_wmi_tlv_op_gen_wow_del_pattern, .gen_wow_config_pno = ath10k_wmi_tlv_op_gen_config_pno,drivers/net/wireless/ath/ath10k/wmi-tlv.h +4
-0@@ -189,6 +189,10 @@ enum wmi_tlv_cmd_id {WMI_TLV_EXTWOW_ENABLE_CMDID ,WMI_TLV_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID ,WMI_TLV_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID , +WMI_TLV_WOW_ENABLE_ICMPV6_NA_FLT_CMDID , +WMI_TLV_WOW_UDP_SVC_OFLD_CMDID , +WMI_TLV_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID , +WMI_TLV_WOW_SET_ACTION_WAKE_UP_CMDID ,WMI_TLV_RTT_MEASREQ_CMDID =WMI_TLV_CMD (WMI_TLV_GRP_RTT ),WMI_TLV_RTT_TSF_CMDID , WMI_TLV_SPECTRAL_SCAN_CONF_CMDID = WMI_TLV_CMD(WMI_TLV_GRP_SPECTRAL),drivers/net/wireless/ath/ath10k/wmi-tlv.h struct wmi_tlv_wow_add_del_event_cmd { · line 2213
Quoted 8 lines
drivers/net/wireless/ath/ath10k/wmi-tlv.h +5
-0@@ -2202,6 +2206,34 @@ struct wmi_tlv_wow_add_del_event_cmd {__le32 event_bitmap; } __packed; +/* Action frame categories that may wake the host from WoW, as in +* qcacld-3.0: spectrum management (0), QoS (1), public (4), SA query (8), +* protected dual of public (9), WNM (10), WME (17), FST (18), VHT (21). +*/ +#define WMI_TLV_WOW_ACTION_WAKE_UP_CATEGORY_MAP0 0x00260713You describe the bitfield above, so please add defines for the categories.
drivers/net/wireless/ath/ath10k/wmi-tlv.h struct wmi_tlv_wow_add_del_event_cmd { · line 2219
Quoted 6 lines
drivers/net/wireless/ath/ath10k/wmi-tlv.h +6
-0+ +/* Per-category bitmaps of action codes to ignore (1 = ignore). Like +* qcacld-3.0, ignore Measurement Request (0) and TPC Request (2). +*/ +#define WMI_TLV_WOW_ACTION_WAKE_UP_NUM_CATEGORIES 32 +#define WMI_TLV_WOW_ACTION_WAKE_UP_SPECTRUM_MGMT_IGNORE (BIT(0) | BIT(2))Same as above.
Quoted 52 lines
drivers/net/wireless/ath/ath10k/wmi-tlv.h +17
-0+ +enum wmi_tlv_wow_action_wake_up_op { +WMI_TLV_WOW_ACTION_WAKE_UP_OP_RESET =0 , +WMI_TLV_WOW_ACTION_WAKE_UP_OP_SET =1 , +WMI_TLV_WOW_ACTION_WAKE_UP_OP_ADD_SET =2 , +WMI_TLV_WOW_ACTION_WAKE_UP_OP_DELETE_SET =3 , +}; + +/* WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param, followed by a +* WMI_TLV_TAG_ARRAY_UINT32 of per-category action code bitmaps. +*/ +struct wmi_tlv_wow_set_action_wake_up_cmd { +__le32 vdev_id; +__le32 operation; +__le32 action_category_map[8 ]; +} __packed; +struct wmi_tlv_request_peer_stats_info {__le32 request_type;__le32 vdev_id;drivers/net/wireless/ath/ath10k/wmi.c +2
-2@@ -4673,8 +4673,8 @@ void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, struct sk_buff *skb)return ; } -ath10k_dbg (ar,ATH10K_DBG_WMI ,"wow wakeup host reason %s\n" , -wow_reason (ev.wake_reason)); +ath10k_dbg (ar,ATH10K_DBG_WMI ,"wow wakeup host reason %d %s\n" , + ev.wake_reason,wow_reason (ev.wake_reason)); }void ath10k_wmi_event_dcs_interference (struct ath10k *ar,struct sk_buff *skb)drivers/net/wireless/ath/ath10k/wmi.h +2
-0@@ -944,6 +944,7 @@ struct wmi_cmd_map {u32 wow_enable_disable_wake_event_cmdid;u32 wow_enable_cmdid;u32 wow_hostwakeup_from_sleep_cmdid; +u32 wow_set_action_wake_up_cmdid;u32 rtt_measreq_cmdid;u32 rtt_tsf_cmdid;u32 vdev_spectral_scan_configure_cmdid;@@ -7060,6 +7061,17 @@ enum wmi_wow_wake_reason {WOW_REASON_DFS_PHYERR_RADADR_EVENT ,WOW_REASON_BEACON_RECV ,WOW_REASON_CLIENT_KICKOUT_EVENT , + WOW_REASON_NAN_EVENT,drivers/net/wireless/ath/ath10k/wmi.h enum wmi_wow_wake_reason { · line 7074
Quoted 10 lines
drivers/net/wireless/ath/ath10k/wmi.h +10
-0+WOW_REASON_EXTSCAN , +WOW_REASON_RSSI_BREACH_EVENT , +WOW_REASON_IOAC_REV_KA_FAIL_EVENT , +WOW_REASON_IOAC_SOCK_EVENT , +WOW_REASON_NLO_SCAN_COMPLETE , +WOW_REASON_PACKET_FILTER_MATCH , +WOW_REASON_ASSOC_RES_RECV , +WOW_REASON_REASSOC_REQ_RECV , +WOW_REASON_REASSOC_RES_RECV , + WOW_REASON_ACTION_FRAME_RECV,I think addition of the new reason and above debug message change should be split in another patch/commit.
Quoted 45 lines
drivers/net/wireless/ath/ath10k/wmi.h +11
-0WOW_REASON_DEBUG_TEST = 0xFF, };@@ -7095,6 +7107,17 @@ static inline const char *wow_reason(enum wmi_wow_wake_reason reason)C2S (WOW_REASON_DFS_PHYERR_RADADR_EVENT );C2S (WOW_REASON_BEACON_RECV );C2S (WOW_REASON_CLIENT_KICKOUT_EVENT ); +C2S (WOW_REASON_NAN_EVENT ); +C2S (WOW_REASON_EXTSCAN ); +C2S (WOW_REASON_RSSI_BREACH_EVENT ); +C2S (WOW_REASON_IOAC_REV_KA_FAIL_EVENT ); +C2S (WOW_REASON_IOAC_SOCK_EVENT ); +C2S (WOW_REASON_NLO_SCAN_COMPLETE ); +C2S (WOW_REASON_PACKET_FILTER_MATCH ); +C2S (WOW_REASON_ASSOC_RES_RECV ); +C2S (WOW_REASON_REASSOC_REQ_RECV ); +C2S (WOW_REASON_REASSOC_RES_RECV ); +C2S (WOW_REASON_ACTION_FRAME_RECV );C2S (WOW_REASON_DEBUG_TEST );default :return NULL ;drivers/net/wireless/ath/ath10k/wow.c +10
-1@@ -380,6 +380,16 @@ static int ath10k_vif_wow_set_wakeups(struct ath10k_vif *arvif, } } +if (arvif->vdev_type ==WMI_VDEV_TYPE_STA ) { +/* Without this filter WCN3990 wakes the host on action +* frames right after WoW is enabled. +*/ + ret =ath10k_wmi_wow_set_action_wake_up (ar, arvif->vdev_id); +if (ret && ret != -EOPNOTSUPP ) +ath10k_warn (ar,"failed to set action frame wakeup filter on vdev %i: %d\n" , + arvif->vdev_id, ret); + } +return 0 ; } --2.43.0
PATCH 2/2 wifi: ath10k: report WoW wakeups to the PM core
In reply to Michael Auerath10k does not report a WoW wakeup to the PM core, so the wakeup source of the device never counts it, and user space cannot tell a network wakeup from other resumes. Plasma's powerdevil, for example, checks the wakeup_count of each wakeup source after resume. It keeps the display off after a network wakeup and turns it on otherwise.
Call pm_wakeup_event() when the firmware reports a wake reason other than WOW_REASON_UNSPECIFIED, which it uses when the host resumed for another reason. iwlwifi does the same since commit 06ae2ad413d2 ("iwlwifi: mvm: report wakeup for wowlan").
On a OnePlus 6 the wakeup source of the WLAN device now counts WoW wakeups, and powerdevil keeps the display off for them.
Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.2.0.c8-00050-QCAHLSWMTPLZ-1
--- drivers/net/wireless/ath/ath10k/wmi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath10k/wmi.c +4 -0
@@ -4675,6 +4675,10 @@ void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, struct sk_buff *skb)ath10k_dbg (ar,ATH10K_DBG_WMI ,"wow wakeup host reason %d %s\n" , ev.wake_reason,wow_reason (ev.wake_reason)); + +/* UNSPECIFIED: the host resumed for another reason */ +if (ev.wake_reason !=WOW_REASON_UNSPECIFIED ) +pm_wakeup_event (ar->dev,0 ); }void ath10k_wmi_event_dcs_interference (struct ath10k *ar,struct sk_buff *skb)
Signature · 1 line
2.43.0