Lines Matching +full:key +full:- +full:enable
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2 /* Copyright(c) 2019-2022 Realtek Corporation
17 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data; in rtw89_wow_parse_akm()
18 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_parse_akm()
19 const u8 *rsn, *ies = mgmt->u.assoc_req.variable; in rtw89_wow_parse_akm()
22 rsn = cfg80211_find_ie(WLAN_EID_RSN, ies, skb->len); in rtw89_wow_parse_akm()
27 rtw_wow->akm = rsn_ie->akm_cipher_suite.type; in rtw89_wow_parse_akm()
55 if (cipher_info_defs->cipher == cipher) in rtw89_cipher_alg_recognize()
62 static int _pn_to_iv(struct rtw89_dev *rtwdev, struct ieee80211_key_conf *key, in _pn_to_iv() argument
65 switch (key->cipher) { in _pn_to_iv()
80 return -EINVAL; in _pn_to_iv()
93 struct ieee80211_key_conf *key, in rtw89_rx_pn_to_iv() argument
100 ieee80211_get_key_rx_seq(key, 0, &seq); in rtw89_rx_pn_to_iv()
110 err = _pn_to_iv(rtwdev, key, iv, pn, key->keyidx); in rtw89_rx_pn_to_iv()
114 rtw89_debug(rtwdev, RTW89_DBG_WOW, "%s key %d pn-%llx to iv-%*ph\n", in rtw89_rx_pn_to_iv()
115 __func__, key->keyidx, pn, 8, iv); in rtw89_rx_pn_to_iv()
121 struct ieee80211_key_conf *key, in rtw89_tx_pn_to_iv() argument
127 pn = atomic64_inc_return(&key->tx_pn); in rtw89_tx_pn_to_iv()
128 err = _pn_to_iv(rtwdev, key, iv, pn, key->keyidx); in rtw89_tx_pn_to_iv()
132 rtw89_debug(rtwdev, RTW89_DBG_WOW, "%s key %d pn-%llx to iv-%*ph\n", in rtw89_tx_pn_to_iv()
133 __func__, key->keyidx, pn, 8, iv); in rtw89_tx_pn_to_iv()
139 struct ieee80211_key_conf *key) in _iv_to_pn() argument
141 switch (key->cipher) { in _iv_to_pn()
154 return -EINVAL; in _iv_to_pn()
169 struct ieee80211_key_conf *key, in rtw89_rx_iv_to_pn() argument
176 err = _iv_to_pn(rtwdev, iv, &pn, NULL, key); in rtw89_rx_iv_to_pn()
188 ieee80211_set_key_rx_seq(key, 0, &seq); in rtw89_rx_iv_to_pn()
189 rtw89_debug(rtwdev, RTW89_DBG_WOW, "%s key %d iv-%*ph to pn-%*ph\n", in rtw89_rx_iv_to_pn()
190 __func__, key->keyidx, 8, iv, 6, seq.ccmp.pn); in rtw89_rx_iv_to_pn()
196 struct ieee80211_key_conf *key, in rtw89_tx_iv_to_pn() argument
202 err = _iv_to_pn(rtwdev, iv, &pn, NULL, key); in rtw89_tx_iv_to_pn()
206 atomic64_set(&key->tx_pn, pn); in rtw89_tx_iv_to_pn()
207 rtw89_debug(rtwdev, RTW89_DBG_WOW, "%s key %d iv-%*ph to pn-%llx\n", in rtw89_tx_iv_to_pn()
208 __func__, key->keyidx, 8, iv, pn); in rtw89_tx_iv_to_pn()
214 struct ieee80211_key_conf *key, in rtw89_rx_pn_get_pmf() argument
220 if (key->keyidx == 4) in rtw89_rx_pn_get_pmf()
221 memcpy(gtk_info->igtk[0], key->key, key->keylen); in rtw89_rx_pn_get_pmf()
222 else if (key->keyidx == 5) in rtw89_rx_pn_get_pmf()
223 memcpy(gtk_info->igtk[1], key->key, key->keylen); in rtw89_rx_pn_get_pmf()
225 return -EINVAL; in rtw89_rx_pn_get_pmf()
227 ieee80211_get_key_rx_seq(key, 0, &seq); in rtw89_rx_pn_get_pmf()
236 gtk_info->ipn = cpu_to_le64(pn); in rtw89_rx_pn_get_pmf()
237 gtk_info->igtk_keyid = cpu_to_le32(key->keyidx); in rtw89_rx_pn_get_pmf()
238 rtw89_debug(rtwdev, RTW89_DBG_WOW, "%s key %d pn-%llx\n", in rtw89_rx_pn_get_pmf()
239 __func__, key->keyidx, pn); in rtw89_rx_pn_get_pmf()
245 struct ieee80211_key_conf *key, in rtw89_rx_pn_set_pmf() argument
248 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_rx_pn_set_pmf()
249 struct rtw89_wow_aoac_report *aoac_rpt = &rtw_wow->aoac_rpt; in rtw89_rx_pn_set_pmf()
252 if (key->keyidx != aoac_rpt->igtk_key_id) in rtw89_rx_pn_set_pmf()
263 ieee80211_set_key_rx_seq(key, 0, &seq); in rtw89_rx_pn_set_pmf()
264 rtw89_debug(rtwdev, RTW89_DBG_WOW, "%s key %d pn-%*ph\n", in rtw89_rx_pn_set_pmf()
265 __func__, key->keyidx, 6, seq.ccmp.pn); in rtw89_rx_pn_set_pmf()
273 struct ieee80211_key_conf *key, in rtw89_wow_get_key_info_iter() argument
276 struct rtw89_dev *rtwdev = hw->priv; in rtw89_wow_get_key_info_iter()
277 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_get_key_info_iter()
278 struct rtw89_wow_key_info *key_info = &rtw_wow->key_info; in rtw89_wow_get_key_info_iter()
279 struct rtw89_wow_gtk_info *gtk_info = &rtw_wow->gtk_info; in rtw89_wow_get_key_info_iter()
284 cipher_info = rtw89_cipher_alg_recognize(key->cipher); in rtw89_wow_get_key_info_iter()
286 switch (key->cipher) { in rtw89_wow_get_key_info_iter()
293 ret = rtw89_tx_pn_to_iv(rtwdev, key, in rtw89_wow_get_key_info_iter()
294 key_info->ptk_tx_iv); in rtw89_wow_get_key_info_iter()
297 ret = rtw89_rx_pn_to_iv(rtwdev, key, in rtw89_wow_get_key_info_iter()
298 key_info->ptk_rx_iv); in rtw89_wow_get_key_info_iter()
302 rtw_wow->ptk_alg = cipher_info->fw_alg; in rtw89_wow_get_key_info_iter()
303 rtw_wow->ptk_keyidx = key->keyidx; in rtw89_wow_get_key_info_iter()
305 ret = rtw89_rx_pn_to_iv(rtwdev, key, in rtw89_wow_get_key_info_iter()
306 key_info->gtk_rx_iv[key->keyidx]); in rtw89_wow_get_key_info_iter()
310 rtw_wow->gtk_alg = cipher_info->fw_alg; in rtw89_wow_get_key_info_iter()
311 key_info->gtk_keyidx = key->keyidx; in rtw89_wow_get_key_info_iter()
315 ret = rtw89_rx_pn_get_pmf(rtwdev, key, gtk_info); in rtw89_wow_get_key_info_iter()
321 /* WEP only set group key in mac80211, but fw need to set in rtw89_wow_get_key_info_iter()
322 * both of pairwise key and group key. in rtw89_wow_get_key_info_iter()
324 rtw_wow->ptk_alg = cipher_info->fw_alg; in rtw89_wow_get_key_info_iter()
325 rtw_wow->ptk_keyidx = key->keyidx; in rtw89_wow_get_key_info_iter()
326 rtw_wow->gtk_alg = cipher_info->fw_alg; in rtw89_wow_get_key_info_iter()
327 key_info->gtk_keyidx = key->keyidx; in rtw89_wow_get_key_info_iter()
331 key->cipher); in rtw89_wow_get_key_info_iter()
343 struct ieee80211_key_conf *key, in rtw89_wow_set_key_info_iter() argument
346 struct rtw89_dev *rtwdev = hw->priv; in rtw89_wow_set_key_info_iter()
347 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_set_key_info_iter()
348 struct rtw89_wow_aoac_report *aoac_rpt = &rtw_wow->aoac_rpt; in rtw89_wow_set_key_info_iter()
350 bool update_tx_key_info = iter_data->rx_ready; in rtw89_wow_set_key_info_iter()
353 switch (key->cipher) { in rtw89_wow_set_key_info_iter()
360 ret = rtw89_rx_iv_to_pn(rtwdev, key, in rtw89_wow_set_key_info_iter()
361 aoac_rpt->ptk_rx_iv); in rtw89_wow_set_key_info_iter()
367 ret = rtw89_tx_iv_to_pn(rtwdev, key, in rtw89_wow_set_key_info_iter()
368 aoac_rpt->ptk_tx_iv); in rtw89_wow_set_key_info_iter()
374 ret = rtw89_rx_iv_to_pn(rtwdev, key, in rtw89_wow_set_key_info_iter()
375 aoac_rpt->gtk_rx_iv[key->keyidx]); in rtw89_wow_set_key_info_iter()
380 if (!sta && update_tx_key_info && aoac_rpt->rekey_ok) in rtw89_wow_set_key_info_iter()
381 iter_data->gtk_cipher = key->cipher; in rtw89_wow_set_key_info_iter()
385 if (aoac_rpt->rekey_ok) in rtw89_wow_set_key_info_iter()
386 iter_data->igtk_cipher = key->cipher; in rtw89_wow_set_key_info_iter()
388 ret = rtw89_rx_pn_set_pmf(rtwdev, key, in rtw89_wow_set_key_info_iter()
389 aoac_rpt->igtk_ipn); in rtw89_wow_set_key_info_iter()
399 key->cipher); in rtw89_wow_set_key_info_iter()
406 iter_data->error = true; in rtw89_wow_set_key_info_iter()
411 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_key_clear()
413 memset(&rtw_wow->aoac_rpt, 0, sizeof(rtw_wow->aoac_rpt)); in rtw89_wow_key_clear()
414 memset(&rtw_wow->gtk_info, 0, sizeof(rtw_wow->gtk_info)); in rtw89_wow_key_clear()
415 memset(&rtw_wow->key_info, 0, sizeof(rtw_wow->key_info)); in rtw89_wow_key_clear()
416 rtw_wow->ptk_alg = 0; in rtw89_wow_key_clear()
417 rtw_wow->gtk_alg = 0; in rtw89_wow_key_clear()
422 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_construct_key_info()
423 struct rtw89_wow_key_info *key_info = &rtw_wow->key_info; in rtw89_wow_construct_key_info()
424 struct ieee80211_vif *wow_vif = rtwdev->wow.wow_vif; in rtw89_wow_construct_key_info()
428 ieee80211_iter_keys_rcu(rtwdev->hw, wow_vif, in rtw89_wow_construct_key_info()
437 key_info->valid_check = RTW89_WOW_VALID_CHECK; in rtw89_wow_construct_key_info()
438 key_info->symbol_check_en = RTW89_WOW_SYMBOL_CHK_PTK | in rtw89_wow_construct_key_info()
444 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_debug_aoac_rpt()
445 struct rtw89_wow_aoac_report *aoac_rpt = &rtw_wow->aoac_rpt; in rtw89_wow_debug_aoac_rpt()
451 aoac_rpt->rpt_ver); in rtw89_wow_debug_aoac_rpt()
453 aoac_rpt->sec_type); in rtw89_wow_debug_aoac_rpt()
455 aoac_rpt->key_idx); in rtw89_wow_debug_aoac_rpt()
457 aoac_rpt->pattern_idx); in rtw89_wow_debug_aoac_rpt()
459 aoac_rpt->rekey_ok); in rtw89_wow_debug_aoac_rpt()
461 8, aoac_rpt->ptk_tx_iv); in rtw89_wow_debug_aoac_rpt()
464 8, aoac_rpt->eapol_key_replay_count); in rtw89_wow_debug_aoac_rpt()
466 8, aoac_rpt->ptk_rx_iv); in rtw89_wow_debug_aoac_rpt()
468 8, aoac_rpt->gtk_rx_iv[0]); in rtw89_wow_debug_aoac_rpt()
470 8, aoac_rpt->gtk_rx_iv[1]); in rtw89_wow_debug_aoac_rpt()
472 8, aoac_rpt->gtk_rx_iv[2]); in rtw89_wow_debug_aoac_rpt()
474 8, aoac_rpt->gtk_rx_iv[3]); in rtw89_wow_debug_aoac_rpt()
476 aoac_rpt->igtk_key_id); in rtw89_wow_debug_aoac_rpt()
478 aoac_rpt->igtk_ipn); in rtw89_wow_debug_aoac_rpt()
480 32, aoac_rpt->igtk); in rtw89_wow_debug_aoac_rpt()
485 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_get_aoac_rpt_reg()
486 struct rtw89_wow_aoac_report *aoac_rpt = &rtw_wow->aoac_rpt; in rtw89_wow_get_aoac_rpt_reg()
499 aoac_rpt->key_idx = in rtw89_wow_get_aoac_rpt_reg()
501 key_idx = aoac_rpt->key_idx; in rtw89_wow_get_aoac_rpt_reg()
502 aoac_rpt->gtk_rx_iv[key_idx][0] = in rtw89_wow_get_aoac_rpt_reg()
504 aoac_rpt->gtk_rx_iv[key_idx][1] = in rtw89_wow_get_aoac_rpt_reg()
506 aoac_rpt->gtk_rx_iv[key_idx][2] = in rtw89_wow_get_aoac_rpt_reg()
508 aoac_rpt->gtk_rx_iv[key_idx][3] = in rtw89_wow_get_aoac_rpt_reg()
510 aoac_rpt->gtk_rx_iv[key_idx][4] = in rtw89_wow_get_aoac_rpt_reg()
512 aoac_rpt->gtk_rx_iv[key_idx][5] = in rtw89_wow_get_aoac_rpt_reg()
514 aoac_rpt->gtk_rx_iv[key_idx][6] = in rtw89_wow_get_aoac_rpt_reg()
516 aoac_rpt->gtk_rx_iv[key_idx][7] = in rtw89_wow_get_aoac_rpt_reg()
518 aoac_rpt->ptk_rx_iv[0] = in rtw89_wow_get_aoac_rpt_reg()
520 aoac_rpt->ptk_rx_iv[1] = in rtw89_wow_get_aoac_rpt_reg()
522 aoac_rpt->ptk_rx_iv[2] = in rtw89_wow_get_aoac_rpt_reg()
524 aoac_rpt->ptk_rx_iv[3] = in rtw89_wow_get_aoac_rpt_reg()
533 aoac_rpt->ptk_rx_iv[4] = in rtw89_wow_get_aoac_rpt_reg()
535 aoac_rpt->ptk_rx_iv[5] = in rtw89_wow_get_aoac_rpt_reg()
537 aoac_rpt->ptk_rx_iv[6] = in rtw89_wow_get_aoac_rpt_reg()
539 aoac_rpt->ptk_rx_iv[7] = in rtw89_wow_get_aoac_rpt_reg()
557 aoac_rpt->igtk_ipn = u64_encode_bits(igtk_ipn[0], RTW89_IGTK_IPN_0) | in rtw89_wow_get_aoac_rpt_reg()
571 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_get_aoac_rpt()
574 if (!rtw_wow->ptk_alg) in rtw89_wow_get_aoac_rpt()
575 return -EPERM; in rtw89_wow_get_aoac_rpt()
599 struct ieee80211_vif *wow_vif = rtwdev->wow.wow_vif; in rtw89_wow_gtk_rekey()
602 struct ieee80211_key_conf *key; in rtw89_wow_gtk_rekey() local
606 sz = struct_size(rekey_conf, key, cipher_info->len); in rtw89_wow_gtk_rekey()
611 rekey_conf->cipher = cipher; in rtw89_wow_gtk_rekey()
612 rekey_conf->keyidx = keyidx; in rtw89_wow_gtk_rekey()
613 rekey_conf->keylen = cipher_info->len; in rtw89_wow_gtk_rekey()
614 memcpy(rekey_conf->key, gtk, in rtw89_wow_gtk_rekey()
615 flex_array_size(rekey_conf, key, cipher_info->len)); in rtw89_wow_gtk_rekey()
620 mutex_unlock(&rtwdev->mutex); in rtw89_wow_gtk_rekey()
621 key = ieee80211_gtk_rekey_add(wow_vif, rekey_conf, -1); in rtw89_wow_gtk_rekey()
622 mutex_lock(&rtwdev->mutex); in rtw89_wow_gtk_rekey()
625 if (IS_ERR(key)) { in rtw89_wow_gtk_rekey()
630 return key; in rtw89_wow_gtk_rekey()
635 struct ieee80211_vif *wow_vif = rtwdev->wow.wow_vif; in rtw89_wow_update_key_info()
636 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_update_key_info()
637 struct rtw89_wow_aoac_report *aoac_rpt = &rtw_wow->aoac_rpt; in rtw89_wow_update_key_info()
640 struct ieee80211_key_conf *key; in rtw89_wow_update_key_info() local
643 ieee80211_iter_keys_rcu(rtwdev->hw, wow_vif, in rtw89_wow_update_key_info()
655 key = rtw89_wow_gtk_rekey(rtwdev, data.gtk_cipher, aoac_rpt->key_idx, in rtw89_wow_update_key_info()
656 aoac_rpt->gtk); in rtw89_wow_update_key_info()
657 if (!key) in rtw89_wow_update_key_info()
660 rtw89_rx_iv_to_pn(rtwdev, key, in rtw89_wow_update_key_info()
661 aoac_rpt->gtk_rx_iv[key->keyidx]); in rtw89_wow_update_key_info()
666 key = rtw89_wow_gtk_rekey(rtwdev, data.igtk_cipher, aoac_rpt->igtk_key_id, in rtw89_wow_update_key_info()
667 aoac_rpt->igtk); in rtw89_wow_update_key_info()
668 if (!key) in rtw89_wow_update_key_info()
671 rtw89_rx_pn_set_pmf(rtwdev, key, aoac_rpt->igtk_ipn); in rtw89_wow_update_key_info()
672 ieee80211_gtk_rekey_notify(wow_vif, wow_vif->bss_conf.bssid, in rtw89_wow_update_key_info()
673 aoac_rpt->eapol_key_replay_count, in rtw89_wow_update_key_info()
684 struct ieee80211_vif *wow_vif = rtwdev->wow.wow_vif; in rtw89_wow_enter_deep_ps()
685 struct rtw89_vif *rtwvif = (struct rtw89_vif *)wow_vif->drv_priv; in rtw89_wow_enter_deep_ps()
692 struct ieee80211_vif *wow_vif = rtwdev->wow.wow_vif; in rtw89_wow_enter_ps()
693 struct rtw89_vif *rtwvif = (struct rtw89_vif *)wow_vif->drv_priv; in rtw89_wow_enter_ps()
703 struct ieee80211_vif *wow_vif = rtwdev->wow.wow_vif; in rtw89_wow_leave_ps()
704 struct rtw89_vif *rtwvif = (struct rtw89_vif *)wow_vif->drv_priv; in rtw89_wow_leave_ps()
718 const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def; in rtw89_wow_config_mac()
720 return mac->wow_config_mac(rtwdev, enable_wow); in rtw89_wow_config_mac()
723 static void rtw89_wow_set_rx_filter(struct rtw89_dev *rtwdev, bool enable) in rtw89_wow_set_rx_filter() argument
725 const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def; in rtw89_wow_set_rx_filter()
726 enum rtw89_mac_fwd_target fwd_target = enable ? in rtw89_wow_set_rx_filter()
730 mac->typ_fltr_opt(rtwdev, RTW89_MGNT, fwd_target, RTW89_MAC_0); in rtw89_wow_set_rx_filter()
731 mac->typ_fltr_opt(rtwdev, RTW89_CTRL, fwd_target, RTW89_MAC_0); in rtw89_wow_set_rx_filter()
732 mac->typ_fltr_opt(rtwdev, RTW89_DATA, fwd_target, RTW89_MAC_0); in rtw89_wow_set_rx_filter()
737 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_show_wakeup_reason()
738 struct rtw89_wow_aoac_report *aoac_rpt = &rtw_wow->aoac_rpt; in rtw89_wow_show_wakeup_reason()
741 .pattern_idx = -1, in rtw89_wow_show_wakeup_reason()
746 if (RTW89_CHK_FW_FEATURE(WOW_REASON_V1, &rtwdev->fw)) in rtw89_wow_show_wakeup_reason()
747 wow_reason_reg = rtwdev->chip->wow_reason_reg[RTW89_WOW_REASON_V1]; in rtw89_wow_show_wakeup_reason()
749 wow_reason_reg = rtwdev->chip->wow_reason_reg[RTW89_WOW_REASON_V0]; in rtw89_wow_show_wakeup_reason()
770 wakeup.pattern_idx = aoac_rpt->pattern_idx; in rtw89_wow_show_wakeup_reason()
783 ieee80211_report_wowlan_wakeup(rtwdev->wow.wow_vif, NULL, in rtw89_wow_show_wakeup_reason()
788 ieee80211_report_wowlan_wakeup(rtwdev->wow.wow_vif, &wakeup, in rtw89_wow_show_wakeup_reason()
794 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_vif_iter()
801 if (rtw_wow->wow_vif || vif->type != NL80211_IFTYPE_STATION) in rtw89_wow_vif_iter()
804 switch (rtwvif->net_type) { in rtw89_wow_vif_iter()
807 rtw_wow->wow_vif = vif; in rtw89_wow_vif_iter()
810 if (rtw_wow->pno_inited) in rtw89_wow_vif_iter()
811 rtw_wow->wow_vif = vif; in rtw89_wow_vif_iter()
885 rtw_pattern->bc = true; in rtw89_wow_pattern_get_type()
887 rtw_pattern->mc = true; in rtw89_wow_pattern_get_type()
888 else if (ether_addr_equal(da, rtwvif->mac_addr) && in rtw89_wow_pattern_get_type()
890 rtw_pattern->uc = true; in rtw89_wow_pattern_get_type()
894 return -EPERM; in rtw89_wow_pattern_get_type()
913 pattern = pkt_pattern->pattern; in rtw89_wow_pattern_generate()
914 len = pkt_pattern->pattern_len; in rtw89_wow_pattern_generate()
915 mask = pkt_pattern->mask; in rtw89_wow_pattern_generate()
927 * |--------+--------+------+-----------+------------+-----| in rtw89_wow_pattern_generate()
933 * |-------------------+--------+------+-----------+------------+-----| in rtw89_wow_pattern_generate()
938 * We should left-shift mask by 6 bits, then set the new bit[0~5] = 0, in rtw89_wow_pattern_generate()
944 for (i = 0; i < mask_len - 1; i++) { in rtw89_wow_pattern_generate()
950 /* Set bit 0-5 to zero */ in rtw89_wow_pattern_generate()
953 memcpy(rtw_pattern->mask, mask_hw, sizeof(rtw_pattern->mask)); in rtw89_wow_pattern_generate()
967 rtw_pattern->crc = rtw89_calc_crc(content, count); in rtw89_wow_pattern_generate()
976 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_parse_patterns()
977 struct rtw89_wow_cam_info *rtw_pattern = rtw_wow->patterns; in rtw89_wow_parse_patterns()
981 if (!wowlan->n_patterns || !wowlan->patterns) in rtw89_wow_parse_patterns()
984 for (i = 0; i < wowlan->n_patterns; i++) { in rtw89_wow_parse_patterns()
985 rtw_pattern = &rtw_wow->patterns[i]; in rtw89_wow_parse_patterns()
987 &wowlan->patterns[i], in rtw89_wow_parse_patterns()
991 rtw_wow->pattern_cnt = 0; in rtw89_wow_parse_patterns()
995 rtw_pattern->r_w = true; in rtw89_wow_parse_patterns()
996 rtw_pattern->idx = i; in rtw89_wow_parse_patterns()
997 rtw_pattern->negative_pattern_match = false; in rtw89_wow_parse_patterns()
998 rtw_pattern->skip_mac_hdr = true; in rtw89_wow_parse_patterns()
999 rtw_pattern->valid = true; in rtw89_wow_parse_patterns()
1001 rtw_wow->pattern_cnt = wowlan->n_patterns; in rtw89_wow_parse_patterns()
1008 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_pattern_clear_cam()
1009 struct rtw89_wow_cam_info *rtw_pattern = rtw_wow->patterns; in rtw89_wow_pattern_clear_cam()
1012 for (i = 0; i < rtw_wow->pattern_cnt; i++) { in rtw89_wow_pattern_clear_cam()
1013 rtw_pattern = &rtw_wow->patterns[i]; in rtw89_wow_pattern_clear_cam()
1014 rtw_pattern->valid = false; in rtw89_wow_pattern_clear_cam()
1021 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_pattern_write()
1022 struct rtw89_wow_cam_info *rtw_pattern = rtw_wow->patterns; in rtw89_wow_pattern_write()
1025 for (i = 0; i < rtw_wow->pattern_cnt; i++) in rtw89_wow_pattern_write()
1031 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_pattern_clear()
1035 rtw_wow->pattern_cnt = 0; in rtw89_wow_pattern_clear()
1036 memset(rtw_wow->patterns, 0, sizeof(rtw_wow->patterns)); in rtw89_wow_pattern_clear()
1041 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_clear_wakeups()
1043 rtw_wow->wow_vif = NULL; in rtw89_wow_clear_wakeups()
1044 rtw89_core_release_all_bits_map(rtw_wow->flags, RTW89_WOW_FLAG_NUM); in rtw89_wow_clear_wakeups()
1045 rtw_wow->pattern_cnt = 0; in rtw89_wow_clear_wakeups()
1046 rtw_wow->pno_inited = false; in rtw89_wow_clear_wakeups()
1052 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_init_pno()
1054 if (!nd_config->n_match_sets || !nd_config->n_channels) in rtw89_wow_init_pno()
1057 rtw_wow->nd_config = nd_config; in rtw89_wow_init_pno()
1058 rtw_wow->pno_inited = true; in rtw89_wow_init_pno()
1060 INIT_LIST_HEAD(&rtw_wow->pno_pkt_list); in rtw89_wow_init_pno()
1062 rtw89_debug(rtwdev, RTW89_DBG_WOW, "WOW: net-detect is enabled\n"); in rtw89_wow_init_pno()
1068 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_set_wakeups()
1071 if (wowlan->disconnect) in rtw89_wow_set_wakeups()
1072 set_bit(RTW89_WOW_FLAG_EN_DISCONNECT, rtw_wow->flags); in rtw89_wow_set_wakeups()
1073 if (wowlan->magic_pkt) in rtw89_wow_set_wakeups()
1074 set_bit(RTW89_WOW_FLAG_EN_MAGIC_PKT, rtw_wow->flags); in rtw89_wow_set_wakeups()
1075 if (wowlan->n_patterns && wowlan->patterns) in rtw89_wow_set_wakeups()
1076 set_bit(RTW89_WOW_FLAG_EN_PATTERN, rtw_wow->flags); in rtw89_wow_set_wakeups()
1078 if (wowlan->nd_config) in rtw89_wow_set_wakeups()
1079 rtw89_wow_init_pno(rtwdev, wowlan->nd_config); in rtw89_wow_set_wakeups()
1084 if (!rtw_wow->wow_vif) in rtw89_wow_set_wakeups()
1085 return -EPERM; in rtw89_wow_set_wakeups()
1087 rtwvif = (struct rtw89_vif *)rtw_wow->wow_vif->drv_priv; in rtw89_wow_set_wakeups()
1093 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_cfg_wake_pno()
1094 struct ieee80211_vif *wow_vif = rtw_wow->wow_vif; in rtw89_wow_cfg_wake_pno()
1095 struct rtw89_vif *rtwvif = (struct rtw89_vif *)wow_vif->drv_priv; in rtw89_wow_cfg_wake_pno()
1121 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_cfg_wake()
1122 struct ieee80211_vif *wow_vif = rtw_wow->wow_vif; in rtw89_wow_cfg_wake()
1123 struct rtw89_vif *rtwvif = (struct rtw89_vif *)wow_vif->drv_priv; in rtw89_wow_cfg_wake()
1128 wow_sta = ieee80211_find_sta(wow_vif, rtwvif->bssid); in rtw89_wow_cfg_wake()
1130 rtwsta = (struct rtw89_sta *)wow_sta->drv_priv; in rtw89_wow_cfg_wake()
1133 if (rtw_wow->pattern_cnt) in rtw89_wow_cfg_wake()
1134 rtwvif->wowlan_pattern = true; in rtw89_wow_cfg_wake()
1135 if (test_bit(RTW89_WOW_FLAG_EN_MAGIC_PKT, rtw_wow->flags)) in rtw89_wow_cfg_wake()
1136 rtwvif->wowlan_magic = true; in rtw89_wow_cfg_wake()
1138 rtwvif->wowlan_pattern = false; in rtw89_wow_cfg_wake()
1139 rtwvif->wowlan_magic = false; in rtw89_wow_cfg_wake()
1174 const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def; in rtw89_wow_check_fw_status()
1181 mac->wow_ctrl.addr, mac->wow_ctrl.mask); in rtw89_wow_check_fw_status()
1191 enum rtw89_chip_gen chip_gen = rtwdev->chip->chip_gen; in rtw89_wow_swap_fw()
1192 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_swap_fw()
1193 struct ieee80211_vif *wow_vif = rtw_wow->wow_vif; in rtw89_wow_swap_fw()
1194 struct rtw89_vif *rtwvif = (struct rtw89_vif *)wow_vif->drv_priv; in rtw89_wow_swap_fw()
1195 enum rtw89_core_chip_id chip_id = rtwdev->chip->chip_id; in rtw89_wow_swap_fw()
1196 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_wow_swap_fw()
1197 bool include_bb = !!chip->bbmcu_nr; in rtw89_wow_swap_fw()
1207 wow_sta = ieee80211_find_sta(wow_vif, rtwvif->bssid); in rtw89_wow_swap_fw()
1209 rtwsta = (struct rtw89_sta *)wow_sta->drv_priv; in rtw89_wow_swap_fw()
1256 ret = rtw89_fw_h2c_general_pkt(rtwdev, rtwvif, rtwsta->mac_id); in rtw89_wow_swap_fw()
1366 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_disable_trx_post()
1367 struct ieee80211_vif *vif = rtw_wow->wow_vif; in rtw89_wow_disable_trx_post()
1382 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_fw_release_pno_pkt_list()
1383 struct list_head *pkt_list = &rtw_wow->pno_pkt_list; in rtw89_fw_release_pno_pkt_list()
1387 rtw89_fw_h2c_del_pkt_offload(rtwdev, info->id); in rtw89_fw_release_pno_pkt_list()
1388 list_del(&info->list); in rtw89_fw_release_pno_pkt_list()
1396 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_pno_scan_update_probe_req()
1397 struct cfg80211_sched_scan_request *nd_config = rtw_wow->nd_config; in rtw89_pno_scan_update_probe_req()
1398 u8 num = nd_config->n_match_sets, i; in rtw89_pno_scan_update_probe_req()
1404 skb = ieee80211_probereq_get(rtwdev->hw, rtwvif->mac_addr, in rtw89_pno_scan_update_probe_req()
1405 nd_config->match_sets[i].ssid.ssid, in rtw89_pno_scan_update_probe_req()
1406 nd_config->match_sets[i].ssid.ssid_len, in rtw89_pno_scan_update_probe_req()
1407 nd_config->ie_len); in rtw89_pno_scan_update_probe_req()
1409 return -ENOMEM; in rtw89_pno_scan_update_probe_req()
1411 skb_put_data(skb, nd_config->ie, nd_config->ie_len); in rtw89_pno_scan_update_probe_req()
1417 return -ENOMEM; in rtw89_pno_scan_update_probe_req()
1420 ret = rtw89_fw_h2c_add_pkt_offload(rtwdev, &info->id, skb); in rtw89_pno_scan_update_probe_req()
1428 list_add_tail(&info->list, &rtw_wow->pno_pkt_list); in rtw89_pno_scan_update_probe_req()
1435 static int rtw89_pno_scan_offload(struct rtw89_dev *rtwdev, bool enable) in rtw89_pno_scan_offload() argument
1437 const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def; in rtw89_pno_scan_offload()
1438 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_pno_scan_offload()
1439 struct ieee80211_vif *wow_vif = rtw_wow->wow_vif; in rtw89_pno_scan_offload()
1440 struct rtw89_vif *rtwvif = (struct rtw89_vif *)wow_vif->drv_priv; in rtw89_pno_scan_offload()
1441 int interval = rtw_wow->nd_config->scan_plans[0].interval; in rtw89_pno_scan_offload()
1445 if (enable) { in rtw89_pno_scan_offload()
1452 ret = mac->add_chan_list_pno(rtwdev, rtwvif); in rtw89_pno_scan_offload()
1459 opt.enable = enable; in rtw89_pno_scan_offload()
1462 opt.delay = max(rtw_wow->nd_config->delay, 1); in rtw89_pno_scan_offload()
1464 if (rtwdev->chip->chip_gen == RTW89_CHIP_BE) { in rtw89_pno_scan_offload()
1465 opt.operation = enable ? RTW89_SCAN_OP_START : RTW89_SCAN_OP_STOP; in rtw89_pno_scan_offload()
1469 opt.mlo_mode = rtwdev->mlo_dbcc_mode; in rtw89_pno_scan_offload()
1474 mac->scan_offload(rtwdev, &opt, rtwvif, true); in rtw89_pno_scan_offload()
1481 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_fw_start()
1482 struct ieee80211_vif *wow_vif = rtw_wow->wow_vif; in rtw89_wow_fw_start()
1483 struct rtw89_vif *rtwvif = (struct rtw89_vif *)wow_vif->drv_priv; in rtw89_wow_fw_start()
1495 rtw89_err(rtwdev, "wow: failed to enable pno scan offload\n"); in rtw89_wow_fw_start()
1504 rtw89_err(rtwdev, "wow: failed to enable keep alive\n"); in rtw89_wow_fw_start()
1510 rtw89_err(rtwdev, "wow: failed to enable disconnect detect\n"); in rtw89_wow_fw_start()
1516 rtw89_err(rtwdev, "wow: failed to enable GTK offload\n"); in rtw89_wow_fw_start()
1522 rtw89_warn(rtwdev, "wow: failed to enable arp offload\n"); in rtw89_wow_fw_start()
1541 rtw89_err(rtwdev, "wow: failed to check enable fw ready\n"); in rtw89_wow_fw_start()
1550 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_wow_fw_stop()
1551 struct ieee80211_vif *wow_vif = rtw_wow->wow_vif; in rtw89_wow_fw_stop()
1552 struct rtw89_vif *rtwvif = (struct rtw89_vif *)wow_vif->drv_priv; in rtw89_wow_fw_stop()
1618 set_bit(RTW89_FLAG_WOWLAN, rtwdev->flags); in rtw89_wow_enable()
1622 rtw89_err(rtwdev, "wow: failed to enable trx_pre\n"); in rtw89_wow_enable()
1644 rtw89_err(rtwdev, "wow: failed to enable trx_post\n"); in rtw89_wow_enable()
1651 clear_bit(RTW89_FLAG_WOWLAN, rtwdev->flags); in rtw89_wow_enable()
1686 clear_bit(RTW89_FLAG_WOWLAN, rtwdev->flags); in rtw89_wow_disable()
1700 if (!test_bit(RTW89_FLAG_WOWLAN, rtwdev->flags)) { in rtw89_wow_resume()
1702 ret = -EPERM; in rtw89_wow_resume()
1708 ret = -EPERM; in rtw89_wow_resume()
1740 rtw89_err(rtwdev, "failed to enable wow\n"); in rtw89_wow_suspend()