Path: blob/main/sys/contrib/dev/iwlwifi/mld/iface.h
48287 views
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */1/*2* Copyright (C) 2024-2025 Intel Corporation3*/4#ifndef __iwl_mld_iface_h__5#define __iwl_mld_iface_h__67#include <net/mac80211.h>89#include "link.h"10#include "session-protect.h"11#include "d3.h"12#include "fw/api/time-event.h"1314enum iwl_mld_cca_40mhz_wa_status {15CCA_40_MHZ_WA_NONE,16CCA_40_MHZ_WA_RESET,17CCA_40_MHZ_WA_RECONNECT,18};1920/**21* enum iwl_mld_emlsr_blocked - defines reasons for which EMLSR is blocked22*23* These blocks are applied/stored per-VIF.24*25* @IWL_MLD_EMLSR_BLOCKED_PREVENTION: Prevent repeated EMLSR enter/exit26* @IWL_MLD_EMLSR_BLOCKED_WOWLAN: WOWLAN is preventing EMLSR27* @IWL_MLD_EMLSR_BLOCKED_ROC: remain-on-channel is preventing EMLSR28* @IWL_MLD_EMLSR_BLOCKED_NON_BSS: An active non-BSS interface's link is29* preventing EMLSR30* @IWL_MLD_EMLSR_BLOCKED_TMP_NON_BSS: An expected active non-BSS interface's31* link is preventing EMLSR. This is a temporary blocking that is set when32* there is an indication that a non-BSS interface is to be added.33* @IWL_MLD_EMLSR_BLOCKED_TPT: throughput is too low to make EMLSR worthwhile34*/35enum iwl_mld_emlsr_blocked {36IWL_MLD_EMLSR_BLOCKED_PREVENTION = 0x1,37IWL_MLD_EMLSR_BLOCKED_WOWLAN = 0x2,38IWL_MLD_EMLSR_BLOCKED_ROC = 0x4,39IWL_MLD_EMLSR_BLOCKED_NON_BSS = 0x8,40IWL_MLD_EMLSR_BLOCKED_TMP_NON_BSS = 0x10,41IWL_MLD_EMLSR_BLOCKED_TPT = 0x20,42};4344/**45* enum iwl_mld_emlsr_exit - defines reasons for exiting EMLSR46*47* Reasons to exit EMLSR may be either link specific or even specific to a48* combination of links.49*50* @IWL_MLD_EMLSR_EXIT_BLOCK: Exit due to a block reason being set51* @IWL_MLD_EMLSR_EXIT_MISSED_BEACON: Exit due to missed beacons52* @IWL_MLD_EMLSR_EXIT_FAIL_ENTRY: FW failed to enter EMLSR53* @IWL_MLD_EMLSR_EXIT_CSA: EMLSR prevented due to channel switch on link54* @IWL_MLD_EMLSR_EXIT_EQUAL_BAND: EMLSR prevented as both links share the band55* @IWL_MLD_EMLSR_EXIT_LOW_RSSI: Link RSSI is unsuitable for EMLSR56* @IWL_MLD_EMLSR_EXIT_LINK_USAGE: Exit EMLSR due to low TPT on secondary link57* @IWL_MLD_EMLSR_EXIT_BT_COEX: Exit EMLSR due to BT coexistence58* @IWL_MLD_EMLSR_EXIT_CHAN_LOAD: Exit EMLSR because the primary channel is not59* loaded enough to justify EMLSR.60* @IWL_MLD_EMLSR_EXIT_RFI: Exit EMLSR due to RFI61* @IWL_MLD_EMLSR_EXIT_FW_REQUEST: Exit EMLSR because the FW requested it62* @IWL_MLD_EMLSR_EXIT_INVALID: internal exit reason due to invalid data63*/64enum iwl_mld_emlsr_exit {65IWL_MLD_EMLSR_EXIT_BLOCK = 0x1,66IWL_MLD_EMLSR_EXIT_MISSED_BEACON = 0x2,67IWL_MLD_EMLSR_EXIT_FAIL_ENTRY = 0x4,68IWL_MLD_EMLSR_EXIT_CSA = 0x8,69IWL_MLD_EMLSR_EXIT_EQUAL_BAND = 0x10,70IWL_MLD_EMLSR_EXIT_LOW_RSSI = 0x20,71IWL_MLD_EMLSR_EXIT_LINK_USAGE = 0x40,72IWL_MLD_EMLSR_EXIT_BT_COEX = 0x80,73IWL_MLD_EMLSR_EXIT_CHAN_LOAD = 0x100,74IWL_MLD_EMLSR_EXIT_RFI = 0x200,75IWL_MLD_EMLSR_EXIT_FW_REQUEST = 0x400,76IWL_MLD_EMLSR_EXIT_INVALID = 0x800,77};7879/**80* struct iwl_mld_emlsr - per-VIF data about EMLSR operation81*82* @primary: The current primary link83* @selected_primary: Primary link as selected during the last link selection84* @selected_links: Links as selected during the last link selection85* @blocked_reasons: Reasons preventing EMLSR from being enabled86* @last_exit_reason: Reason for the last EMLSR exit87* @last_exit_ts: Time of the last EMLSR exit (if @last_exit_reason is non-zero)88* @exit_repeat_count: Number of times EMLSR was exited for the same reason89* @last_entry_ts: the time of the last EMLSR entry (if iwl_mld_emlsr_active()90* is true)91* @unblock_tpt_wk: Unblock EMLSR because the throughput limit was reached92* @check_tpt_wk: a worker to check if IWL_MLD_EMLSR_BLOCKED_TPT should be93* added, for example if there is no longer enough traffic.94* @prevent_done_wk: Worker to remove %IWL_MLD_EMLSR_BLOCKED_PREVENTION95* @tmp_non_bss_done_wk: Worker to remove %IWL_MLD_EMLSR_BLOCKED_TMP_NON_BSS96*/97struct iwl_mld_emlsr {98struct_group(zeroed_on_not_authorized,99u8 primary;100101u8 selected_primary;102u16 selected_links;103104enum iwl_mld_emlsr_blocked blocked_reasons;105106enum iwl_mld_emlsr_exit last_exit_reason;107unsigned long last_exit_ts;108u8 exit_repeat_count;109unsigned long last_entry_ts;110);111112struct wiphy_work unblock_tpt_wk;113struct wiphy_delayed_work check_tpt_wk;114115struct wiphy_delayed_work prevent_done_wk;116struct wiphy_delayed_work tmp_non_bss_done_wk;117};118119/**120* struct iwl_mld_vif - virtual interface (MAC context) configuration parameters121*122* @fw_id: fw id of the mac context.123* @session_protect: session protection parameters124* @ap_sta: pointer to AP sta, for easier access to it.125* Relevant only for STA vifs.126* @authorized: indicates the AP station was set to authorized127* @bigtks: BIGTKs of the AP, for beacon protection.128* Only valid for STA. (FIXME: needs to be per link)129* @num_associated_stas: number of associated STAs. Relevant only for AP mode.130* @ap_ibss_active: whether the AP/IBSS was started131* @cca_40mhz_workaround: When we are connected in 2.4 GHz and 40 MHz, and the132* environment is too loaded, we work around this by reconnecting to the133* same AP with 20 MHz. This manages the status of the workaround.134* @beacon_inject_active: indicates an active debugfs beacon ie injection135* @low_latency_causes: bit flags, indicating the causes for low-latency,136* see @iwl_mld_low_latency_cause.137* @ps_disabled: indicates that PS is disabled for this interface138* @last_link_activation_time: last time a link was activated, for139* deferring MLO scans (to make them more reliable)140* @mld: pointer to the mld structure.141* @deflink: default link data, for use in non-MLO,142* @link: reference to link data for each valid link, for use in MLO.143* @emlsr: information related to EMLSR144* @wowlan_data: data used by the wowlan suspend flow145* @use_ps_poll: use ps_poll frames146* @disable_bf: disable beacon filter147* @dbgfs_slink: debugfs symlink for this interface148* @roc_activity: the id of the roc_activity running. Relevant for STA and149* p2p device only. Set to %ROC_NUM_ACTIVITIES when not in use.150* @aux_sta: station used for remain on channel. Used in P2P device.151* @mlo_scan_start_wk: worker to start a deferred MLO scan152*/153struct iwl_mld_vif {154/* Add here fields that need clean up on restart */155struct_group(zeroed_on_hw_restart,156u8 fw_id;157struct iwl_mld_session_protect session_protect;158struct ieee80211_sta *ap_sta;159bool authorized;160struct ieee80211_key_conf __rcu *bigtks[2];161u8 num_associated_stas;162bool ap_ibss_active;163enum iwl_mld_cca_40mhz_wa_status cca_40mhz_workaround;164#ifdef CONFIG_IWLWIFI_DEBUGFS165bool beacon_inject_active;166#endif167u8 low_latency_causes;168bool ps_disabled;169time64_t last_link_activation_time;170);171/* And here fields that survive a fw restart */172struct iwl_mld *mld;173struct iwl_mld_link deflink;174struct iwl_mld_link __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS];175176struct iwl_mld_emlsr emlsr;177178#ifdef CONFIG_PM_SLEEP179struct iwl_mld_wowlan_data wowlan_data;180#endif181#ifdef CONFIG_IWLWIFI_DEBUGFS182bool use_ps_poll;183bool disable_bf;184struct dentry *dbgfs_slink;185#endif186enum iwl_roc_activity roc_activity;187struct iwl_mld_int_sta aux_sta;188189struct wiphy_delayed_work mlo_scan_start_wk;190};191192static inline struct iwl_mld_vif *193iwl_mld_vif_from_mac80211(struct ieee80211_vif *vif)194{195return (void *)vif->drv_priv;196}197198static inline struct ieee80211_vif *199iwl_mld_vif_to_mac80211(struct iwl_mld_vif *mld_vif)200{201return container_of((void *)mld_vif, struct ieee80211_vif, drv_priv);202}203204#define iwl_mld_link_dereference_check(mld_vif, link_id) \205rcu_dereference_check((mld_vif)->link[link_id], \206lockdep_is_held(&mld_vif->mld->wiphy->mtx))207208#define for_each_mld_vif_valid_link(mld_vif, mld_link) \209for (int link_id = 0; link_id < ARRAY_SIZE((mld_vif)->link); \210link_id++) \211if ((mld_link = iwl_mld_link_dereference_check(mld_vif, link_id)))212213/* Retrieve pointer to mld link from mac80211 structures */214static inline struct iwl_mld_link *215iwl_mld_link_from_mac80211(struct ieee80211_bss_conf *bss_conf)216{217struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(bss_conf->vif);218219return iwl_mld_link_dereference_check(mld_vif, bss_conf->link_id);220}221222int iwl_mld_mac80211_iftype_to_fw(const struct ieee80211_vif *vif);223224/* Cleanup function for struct iwl_mld_vif, will be called in restart */225void iwl_mld_cleanup_vif(void *data, u8 *mac, struct ieee80211_vif *vif);226int iwl_mld_mac_fw_action(struct iwl_mld *mld, struct ieee80211_vif *vif,227u32 action);228int iwl_mld_add_vif(struct iwl_mld *mld, struct ieee80211_vif *vif);229int iwl_mld_rm_vif(struct iwl_mld *mld, struct ieee80211_vif *vif);230void iwl_mld_set_vif_associated(struct iwl_mld *mld,231struct ieee80211_vif *vif);232u8 iwl_mld_get_fw_bss_vifs_ids(struct iwl_mld *mld);233void iwl_mld_handle_probe_resp_data_notif(struct iwl_mld *mld,234struct iwl_rx_packet *pkt);235236void iwl_mld_handle_datapath_monitor_notif(struct iwl_mld *mld,237struct iwl_rx_packet *pkt);238239void iwl_mld_handle_uapsd_misbehaving_ap_notif(struct iwl_mld *mld,240struct iwl_rx_packet *pkt);241242void iwl_mld_reset_cca_40mhz_workaround(struct iwl_mld *mld,243struct ieee80211_vif *vif);244245static inline bool iwl_mld_vif_low_latency(const struct iwl_mld_vif *mld_vif)246{247return !!mld_vif->low_latency_causes;248}249250struct ieee80211_vif *iwl_mld_get_bss_vif(struct iwl_mld *mld);251252#endif /* __iwl_mld_iface_h__ */253254255