// SPDX-License-Identifier: BSD-3-Clause-Clear /* * Copyright (c) 2020 The Linux Foundation. All rights reserved. * Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights reserved.
*/
/* The firmware might be busy and it can not enter WoW immediately. * In that case firmware notifies host with * ATH12K_HTC_MSG_NACK_SUSPEND message, asking host to try again * later. Per the firmware team there could be up to 10 loops.
*/ for (i = 0; i < ATH12K_WOW_RETRY_NUM; i++) {
reinit_completion(&ab->htc_suspend);
ret = ath12k_wmi_wow_enable(ar); if (ret) {
ath12k_warn(ab, "failed to issue wow enable: %d\n", ret); return ret;
}
ret = wait_for_completion_timeout(&ab->htc_suspend, 3 * HZ); if (ret == 0) {
ath12k_warn(ab, "timed out while waiting for htc suspend completion\n"); return -ETIMEDOUT;
}
if (test_bit(ATH12K_FLAG_HTC_SUSPEND_COMPLETE, &ab->dev_flags)) /* success, suspend complete received */ return 0;
ath12k_warn(ab, "htc suspend not complete, failing after %d tries\n", i);
return -ETIMEDOUT;
}
int ath12k_wow_wakeup(struct ath12k *ar)
{ struct ath12k_base *ab = ar->ab; int ret;
reinit_completion(&ab->wow.wakeup_completed);
ret = ath12k_wmi_wow_host_wakeup_ind(ar); if (ret) {
ath12k_warn(ab, "failed to send wow wakeup indication: %d\n",
ret); return ret;
}
ret = wait_for_completion_timeout(&ab->wow.wakeup_completed, 3 * HZ); if (ret == 0) {
ath12k_warn(ab, "timed out while waiting for wow wakeup completion\n"); return -ETIMEDOUT;
}
return 0;
}
staticint ath12k_wow_vif_cleanup(struct ath12k_link_vif *arvif)
{ struct ath12k *ar = arvif->ar; int i, ret;
for (i = 0; i < WOW_EVENT_MAX; i++) {
ret = ath12k_wmi_wow_add_wakeup_event(ar, arvif->vdev_id, i, 0); if (ret) {
ath12k_warn(ar->ab, "failed to issue wow wakeup for event %s on vdev %i: %d\n",
wow_wakeup_event(i), arvif->vdev_id, ret); return ret;
}
}
for (i = 0; i < ar->wow.max_num_patterns; i++) {
ret = ath12k_wmi_wow_del_pattern(ar, arvif->vdev_id, i); if (ret) {
ath12k_warn(ar->ab, "failed to delete wow pattern %d for vdev %i: %d\n",
i, arvif->vdev_id, ret); return ret;
}
}
return 0;
}
staticint ath12k_wow_cleanup(struct ath12k *ar)
{ struct ath12k_link_vif *arvif; int ret;
lockdep_assert_wiphy(ath12k_ar_to_hw(ar)->wiphy);
list_for_each_entry(arvif, &ar->arvifs, list) {
ret = ath12k_wow_vif_cleanup(arvif); if (ret) {
ath12k_warn(ar->ab, "failed to clean wow wakeups on vdev %i: %d\n",
arvif->vdev_id, ret); return ret;
}
}
/* Copying list of valid channel into request */
pno->a_networks[i].channel_count = nd_config->n_channels;
pno->a_networks[i].rssi_threshold = nd_config->match_sets[i].rssi_thold;
/* set scan to passive if no SSIDs are specified in the request */ if (nd_config->n_ssids == 0)
pno->do_passive_scan = true; else
pno->do_passive_scan = false;
for (i = 0; i < nd_config->n_ssids; i++) { for (j = 0; j < pno->uc_networks_count; j++) { if (pno->a_networks[j].ssid.ssid_len ==
nd_config->ssids[i].ssid_len &&
!memcmp(pno->a_networks[j].ssid.ssid,
nd_config->ssids[i].ssid,
pno->a_networks[j].ssid.ssid_len)) {
pno->a_networks[j].bcast_nw_type = BCAST_HIDDEN; break;
}
}
}
if (nd_config->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) { /* enable mac randomization */
pno->enable_pno_scan_randomization = 1;
memcpy(pno->mac_addr, nd_config->mac_addr, ETH_ALEN);
memcpy(pno->mac_addr_mask, nd_config->mac_addr_mask, ETH_ALEN);
}
pno->delay_start_time = nd_config->delay;
/* Current FW does not support min-max range for dwell time */
pno->active_max_time = WMI_ACTIVE_MAX_CHANNEL_TIME;
pno->passive_max_time = WMI_PASSIVE_MAX_CHANNEL_TIME;
return 0;
}
staticint ath12k_wow_vif_set_wakeups(struct ath12k_link_vif *arvif, struct cfg80211_wowlan *wowlan)
{ conststruct cfg80211_pkt_pattern *patterns = wowlan->patterns; struct ath12k *ar = arvif->ar; unsignedlong wow_mask = 0; int pattern_id = 0; int ret, i, j;
/* Setup requested WOW features */ switch (arvif->ahvif->vdev_type) { case WMI_VDEV_TYPE_IBSS:
__set_bit(WOW_BEACON_EVENT, &wow_mask);
fallthrough; case WMI_VDEV_TYPE_AP:
__set_bit(WOW_DEAUTH_RECVD_EVENT, &wow_mask);
__set_bit(WOW_DISASSOC_RECVD_EVENT, &wow_mask);
__set_bit(WOW_PROBE_REQ_WPS_IE_EVENT, &wow_mask);
__set_bit(WOW_AUTH_REQ_EVENT, &wow_mask);
__set_bit(WOW_ASSOC_REQ_EVENT, &wow_mask);
__set_bit(WOW_HTT_EVENT, &wow_mask);
__set_bit(WOW_RA_MATCH_EVENT, &wow_mask); break; case WMI_VDEV_TYPE_STA: if (wowlan->disconnect) {
__set_bit(WOW_DEAUTH_RECVD_EVENT, &wow_mask);
__set_bit(WOW_DISASSOC_RECVD_EVENT, &wow_mask);
__set_bit(WOW_BMISS_EVENT, &wow_mask);
__set_bit(WOW_CSA_IE_EVENT, &wow_mask);
}
if (wowlan->magic_pkt)
__set_bit(WOW_MAGIC_PKT_RECVD_EVENT, &wow_mask);
if (wowlan->nd_config) { struct wmi_pno_scan_req_arg *pno; int ret;
pno = kzalloc(sizeof(*pno), GFP_KERNEL); if (!pno) return -ENOMEM;
ar->nlo_enabled = true;
ret = ath12k_wow_pno_check_and_convert(ar, arvif->vdev_id,
wowlan->nd_config, pno); if (!ret) {
ath12k_wmi_wow_config_pno(ar, arvif->vdev_id, pno);
__set_bit(WOW_NLO_DETECTED_EVENT, &wow_mask);
}
kfree(pno);
} break; default: break;
}
for (i = 0; i < wowlan->n_patterns; i++) { conststruct cfg80211_pkt_pattern *eth_pattern = &patterns[i]; struct ath12k_pkt_pattern new_pattern = {};
if (WARN_ON(eth_pattern->pattern_len > WOW_MAX_PATTERN_SIZE)) return -EINVAL;
if (ar->ab->wow.wmi_conf_rx_decap_mode ==
ATH12K_HW_TXRX_NATIVE_WIFI) {
ath12k_wow_convert_8023_to_80211(ar, eth_pattern,
&new_pattern);
for (i = 0; i < WOW_EVENT_MAX; i++) { if (!test_bit(i, &wow_mask)) continue;
ret = ath12k_wmi_wow_add_wakeup_event(ar, arvif->vdev_id, i, 1); if (ret) {
ath12k_warn(ar->ab, "failed to enable wakeup event %s on vdev %i: %d\n",
wow_wakeup_event(i), arvif->vdev_id, ret); return ret;
}
}
list_for_each_entry(arvif, &ar->arvifs, list) { if (ath12k_wow_is_p2p_vdev(arvif->ahvif)) continue;
ret = ath12k_wow_vif_set_wakeups(arvif, wowlan); if (ret) {
ath12k_warn(ar->ab, "failed to set wow wakeups on vdev %i: %d\n",
arvif->vdev_id, ret); return ret;
}
}
/* get rekey info before disable rekey offload */ if (!enable) {
ret = ath12k_wmi_gtk_rekey_getinfo(ar, arvif); if (ret) {
ath12k_warn(ar->ab, "failed to request rekey info vdev %i, ret %d\n",
arvif->vdev_id, ret); return ret;
}
}
ret = ath12k_wmi_gtk_rekey_offload(ar, arvif, enable);
if (ret) {
ath12k_warn(ar->ab, "failed to offload gtk reky vdev %i: enable %d, ret %d\n",
arvif->vdev_id, enable, ret); return ret;
}
}
return 0;
}
staticint ath12k_wow_protocol_offload(struct ath12k *ar, bool enable)
{ int ret;
ret = ath12k_wow_arp_ns_offload(ar, enable); if (ret) {
ath12k_warn(ar->ab, "failed to offload ARP and NS %d %d\n",
enable, ret); return ret;
}
ret = ath12k_gtk_rekey_offload(ar, enable); if (ret) {
ath12k_warn(ar->ab, "failed to offload gtk rekey %d %d\n",
enable, ret); return ret;
}
ret = ath12k_wow_wakeup(ar); if (ret) {
ath12k_warn(ar->ab, "failed to wakeup from wow: %d\n", ret); gotoexit;
}
ret = ath12k_wow_nlo_cleanup(ar); if (ret) {
ath12k_warn(ar->ab, "failed to cleanup nlo: %d\n", ret); gotoexit;
}
ret = ath12k_wow_clear_hw_filter(ar); if (ret) {
ath12k_warn(ar->ab, "failed to clear hw filter: %d\n", ret); gotoexit;
}
ret = ath12k_wow_protocol_offload(ar, false); if (ret) {
ath12k_warn(ar->ab, "failed to clear wow protocol offload events: %d\n",
ret); gotoexit;
}
ret = ath12k_wow_set_keepalive(ar,
WMI_STA_KEEPALIVE_METHOD_NULL_FRAME,
WMI_STA_KEEPALIVE_INTERVAL_DISABLE); if (ret) {
ath12k_warn(ar->ab, "failed to disable wow keepalive: %d\n", ret); gotoexit;
}
exit: if (ret) { switch (ah->state) { case ATH12K_HW_STATE_ON:
ah->state = ATH12K_HW_STATE_RESTARTING;
ret = 1; break; case ATH12K_HW_STATE_OFF: case ATH12K_HW_STATE_RESTARTING: case ATH12K_HW_STATE_RESTARTED: case ATH12K_HW_STATE_WEDGED: case ATH12K_HW_STATE_TM:
ath12k_warn(ar->ab, "encountered unexpected device state %d on resume, cannot recover\n",
ah->state);
ret = -EIO; break;
}
}
return ret;
}
int ath12k_wow_init(struct ath12k *ar)
{ if (!test_bit(WMI_TLV_SERVICE_WOW, ar->wmi->wmi_ab->svc_map)) return 0;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.