// SPDX-License-Identifier: ISC /* * Copyright (c) 2015-2017 Qualcomm Atheros, Inc. * Copyright (c) 2018, The Linux Foundation. All rights reserved. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*/
staticint ath10k_wow_vif_cleanup(struct ath10k_vif *arvif)
{ struct ath10k *ar = arvif->ar; int i, ret;
for (i = 0; i < WOW_EVENT_MAX; i++) {
ret = ath10k_wmi_wow_add_wakeup_event(ar, arvif->vdev_id, i, 0); if (ret) {
ath10k_warn(ar, "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 = ath10k_wmi_wow_del_pattern(ar, arvif->vdev_id, i); if (ret) {
ath10k_warn(ar, "failed to delete wow pattern %d for vdev %i: %d\n",
i, arvif->vdev_id, ret); return ret;
}
}
return 0;
}
staticint ath10k_wow_cleanup(struct ath10k *ar)
{ struct ath10k_vif *arvif; int ret;
lockdep_assert_held(&ar->conf_mutex);
list_for_each_entry(arvif, &ar->arvifs, list) {
ret = ath10k_wow_vif_cleanup(arvif); if (ret) {
ath10k_warn(ar, "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++) {
j = 0; while (j < pno->uc_networks_count) { if (__le32_to_cpu(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,
__le32_to_cpu(pno->a_networks[j].ssid.ssid_len)) == 0)) {
pno->a_networks[j].bcast_nw_type = BCAST_HIDDEN; break;
}
j++;
}
}
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 ret;
}
for (i = 0; i < WOW_EVENT_MAX; i++) { if (!test_bit(i, &wow_mask)) continue;
ret = ath10k_wmi_wow_add_wakeup_event(ar, arvif->vdev_id, i, 1); if (ret) {
ath10k_warn(ar, "failed to enable wakeup event %s on vdev %i: %d\n",
wow_wakeup_event(i), arvif->vdev_id, ret); return ret;
}
}
staticint ath10k_wow_nlo_cleanup(struct ath10k *ar)
{ struct ath10k_vif *arvif; int ret = 0;
lockdep_assert_held(&ar->conf_mutex);
list_for_each_entry(arvif, &ar->arvifs, list) {
ret = ath10k_vif_wow_clean_nlo(arvif); if (ret) {
ath10k_warn(ar, "failed to clean nlo settings on vdev %i: %d\n",
arvif->vdev_id, ret); return ret;
}
}
return 0;
}
staticint ath10k_wow_enable(struct ath10k *ar)
{ int ret;
lockdep_assert_held(&ar->conf_mutex);
reinit_completion(&ar->target_suspend);
ret = ath10k_wmi_wow_enable(ar); if (ret) {
ath10k_warn(ar, "failed to issue wow enable: %d\n", ret); return ret;
}
ret = wait_for_completion_timeout(&ar->target_suspend, 3 * HZ); if (ret == 0) {
ath10k_warn(ar, "timed out while waiting for suspend completion\n"); return -ETIMEDOUT;
}
return 0;
}
staticint ath10k_wow_wakeup(struct ath10k *ar)
{ int ret;
lockdep_assert_held(&ar->conf_mutex);
reinit_completion(&ar->wow.wakeup_completed);
ret = ath10k_wmi_wow_host_wakeup_ind(ar); if (ret) {
ath10k_warn(ar, "failed to send wow wakeup indication: %d\n",
ret); return ret;
}
ret = wait_for_completion_timeout(&ar->wow.wakeup_completed, 3 * HZ); if (ret == 0) {
ath10k_warn(ar, "timed out while waiting for wow wakeup completion\n"); return -ETIMEDOUT;
}
return 0;
}
int ath10k_wow_op_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
{ struct ath10k *ar = hw->priv; int ret;
mutex_lock(&ar->conf_mutex);
if (WARN_ON(!test_bit(ATH10K_FW_FEATURE_WOWLAN_SUPPORT,
ar->running_fw->fw_file.fw_features))) {
ret = 1; gotoexit;
}
ret = ath10k_wow_cleanup(ar); if (ret) {
ath10k_warn(ar, "failed to clear wow wakeup events: %d\n",
ret); gotoexit;
}
ret = ath10k_wow_set_wakeups(ar, wowlan); if (ret) {
ath10k_warn(ar, "failed to set wow wakeup events: %d\n",
ret); goto cleanup;
}
ath10k_mac_wait_tx_complete(ar);
ret = ath10k_wow_enable(ar); if (ret) {
ath10k_warn(ar, "failed to start wow: %d\n", ret); goto cleanup;
}
ret = ath10k_hif_suspend(ar); if (ret) {
ath10k_warn(ar, "failed to suspend hif: %d\n", ret); goto wakeup;
}
gotoexit;
wakeup:
ath10k_wow_wakeup(ar);
cleanup:
ath10k_wow_cleanup(ar);
exit:
mutex_unlock(&ar->conf_mutex); return ret ? 1 : 0;
}
mutex_lock(&ar->conf_mutex); if (test_bit(ATH10K_FW_FEATURE_WOWLAN_SUPPORT,
ar->running_fw->fw_file.fw_features)) {
device_set_wakeup_enable(ar->dev, enabled);
}
mutex_unlock(&ar->conf_mutex);
}
int ath10k_wow_op_resume(struct ieee80211_hw *hw)
{ struct ath10k *ar = hw->priv; int ret;
mutex_lock(&ar->conf_mutex);
if (WARN_ON(!test_bit(ATH10K_FW_FEATURE_WOWLAN_SUPPORT,
ar->running_fw->fw_file.fw_features))) {
ret = 1; gotoexit;
}
ret = ath10k_hif_resume(ar); if (ret) {
ath10k_warn(ar, "failed to resume hif: %d\n", ret); gotoexit;
}
ret = ath10k_wow_wakeup(ar); if (ret)
ath10k_warn(ar, "failed to wakeup from wow: %d\n", ret);
ret = ath10k_wow_nlo_cleanup(ar); if (ret)
ath10k_warn(ar, "failed to cleanup nlo: %d\n", ret);
exit: if (ret) { switch (ar->state) { case ATH10K_STATE_ON:
ar->state = ATH10K_STATE_RESTARTING;
ret = 1; break; case ATH10K_STATE_OFF: case ATH10K_STATE_RESTARTING: case ATH10K_STATE_RESTARTED: case ATH10K_STATE_UTF: case ATH10K_STATE_WEDGED:
ath10k_warn(ar, "encountered unexpected device state %d on resume, cannot recover\n",
ar->state);
ret = -EIO; break;
}
}
mutex_unlock(&ar->conf_mutex); return ret;
}
int ath10k_wow_init(struct ath10k *ar)
{ if (!test_bit(ATH10K_FW_FEATURE_WOWLAN_SUPPORT,
ar->running_fw->fw_file.fw_features)) return 0;
if (WARN_ON(!test_bit(WMI_SERVICE_WOW, ar->wmi.svc_map))) return -EINVAL;
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.