#ifndef __iwl_mld_iface_h__
#define __iwl_mld_iface_h__
#include <net/mac80211.h>
#include "link.h"
#include "nan.h"
#include "session-protect.h"
#include "d3.h"
#include "fw/api/time-event.h"
enum iwl_mld_cca_40mhz_wa_status {
CCA_40_MHZ_WA_NONE,
CCA_40_MHZ_WA_RESET,
CCA_40_MHZ_WA_RECONNECT,
};
enum iwl_mld_emlsr_blocked {
IWL_MLD_EMLSR_BLOCKED_PREVENTION = 0x1,
IWL_MLD_EMLSR_BLOCKED_WOWLAN = 0x2,
IWL_MLD_EMLSR_BLOCKED_ROC = 0x4,
IWL_MLD_EMLSR_BLOCKED_NON_BSS = 0x8,
IWL_MLD_EMLSR_BLOCKED_TMP_NON_BSS = 0x10,
IWL_MLD_EMLSR_BLOCKED_TPT = 0x20,
IWL_MLD_EMLSR_BLOCKED_NAN = 0x40,
IWL_MLD_EMLSR_BLOCKED_TDLS = 0x80,
};
enum iwl_mld_emlsr_exit {
IWL_MLD_EMLSR_EXIT_BLOCK = 0x1,
IWL_MLD_EMLSR_EXIT_MISSED_BEACON = 0x2,
IWL_MLD_EMLSR_EXIT_FAIL_ENTRY = 0x4,
IWL_MLD_EMLSR_EXIT_CSA = 0x8,
IWL_MLD_EMLSR_EXIT_EQUAL_BAND = 0x10,
IWL_MLD_EMLSR_EXIT_LOW_RSSI = 0x20,
IWL_MLD_EMLSR_EXIT_LINK_USAGE = 0x40,
IWL_MLD_EMLSR_EXIT_BT_COEX = 0x80,
IWL_MLD_EMLSR_EXIT_CHAN_LOAD = 0x100,
IWL_MLD_EMLSR_EXIT_RFI = 0x200,
IWL_MLD_EMLSR_EXIT_FW_REQUEST = 0x400,
IWL_MLD_EMLSR_EXIT_INVALID = 0x800,
};
struct iwl_mld_emlsr {
struct_group(zeroed_on_not_authorized,
u8 primary;
u8 selected_primary;
u16 selected_links;
enum iwl_mld_emlsr_blocked blocked_reasons;
enum iwl_mld_emlsr_exit last_exit_reason;
unsigned long last_exit_ts;
u8 exit_repeat_count;
unsigned long last_entry_ts;
);
struct wiphy_work unblock_tpt_wk;
struct wiphy_delayed_work check_tpt_wk;
struct wiphy_delayed_work prevent_done_wk;
struct wiphy_delayed_work tmp_non_bss_done_wk;
};
struct iwl_mld_vif {
struct_group(zeroed_on_hw_restart,
u8 fw_id;
struct iwl_mld_session_protect session_protect;
struct ieee80211_sta *ap_sta;
bool authorized;
u8 num_associated_stas;
bool ap_ibss_active;
enum iwl_mld_cca_40mhz_wa_status cca_40mhz_workaround;
#ifdef CONFIG_IWLWIFI_DEBUGFS
bool beacon_inject_active;
#endif
u8 low_latency_causes;
time64_t last_link_activation_time;
);
struct iwl_mld *mld;
struct iwl_mld_link deflink;
struct iwl_mld_link __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS];
struct {
struct iwl_mld_nan_link links[IWL_FW_MAX_LINKS];
bool mac_added;
struct iwl_mld_int_sta bcast_sta;
struct iwl_mld_int_sta mgmt_sta;
struct iwl_mld_int_sta mcast_data_sta;
struct ieee80211_key_conf *tx_igtk;
} nan;
struct iwl_mld_emlsr emlsr;
#ifdef CONFIG_PM_SLEEP
struct iwl_mld_wowlan_data wowlan_data;
#endif
#ifdef CONFIG_IWLWIFI_DEBUGFS
bool use_ps_poll;
bool disable_bf;
struct dentry *dbgfs_slink;
#endif
enum iwl_roc_activity roc_activity;
struct iwl_mld_int_sta aux_sta;
struct wiphy_delayed_work mlo_scan_start_wk;
};
static inline struct iwl_mld_vif *
iwl_mld_vif_from_mac80211(struct ieee80211_vif *vif)
{
return (void *)vif->drv_priv;
}
static inline struct ieee80211_vif *
iwl_mld_vif_to_mac80211(struct iwl_mld_vif *mld_vif)
{
return container_of((void *)mld_vif, struct ieee80211_vif, drv_priv);
}
static inline bool iwl_mld_vif_fw_id_valid(struct iwl_mld_vif *mld_vif)
{
struct ieee80211_vif *vif = iwl_mld_vif_to_mac80211(mld_vif);
switch (vif->type) {
case NL80211_IFTYPE_NAN_DATA:
return false;
case NL80211_IFTYPE_NAN:
if (!mld_vif->nan.mac_added)
return false;
break;
default:
break;
}
if (WARN_ON(mld_vif->fw_id >= ARRAY_SIZE(mld_vif->mld->fw_id_to_vif)))
return false;
return true;
}
#define iwl_mld_link_dereference_check(mld_vif, link_id) \
rcu_dereference_check((mld_vif)->link[link_id], \
lockdep_is_held(&mld_vif->mld->wiphy->mtx))
#define for_each_mld_vif_valid_link(mld_vif, mld_link) \
for (int link_id = 0; link_id < ARRAY_SIZE((mld_vif)->link); \
link_id++) \
if ((mld_link = iwl_mld_link_dereference_check(mld_vif, link_id)))
#define for_each_mld_nan_valid_link(mld_vif, nan_link) \
for (nan_link = &(mld_vif)->nan.links[0]; \
nan_link < &(mld_vif)->nan.links[ARRAY_SIZE((mld_vif)->nan.links)]; \
nan_link++) \
if (nan_link->fw_id != FW_CTXT_ID_INVALID)
static inline struct iwl_mld_link *
iwl_mld_link_from_mac80211(struct ieee80211_bss_conf *bss_conf)
{
struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(bss_conf->vif);
return iwl_mld_link_dereference_check(mld_vif, bss_conf->link_id);
}
void iwl_mld_cleanup_vif(void *data, u8 *mac, struct ieee80211_vif *vif);
int iwl_mld_mac_fw_action(struct iwl_mld *mld, struct ieee80211_vif *vif,
u32 action);
int iwl_mld_add_vif(struct iwl_mld *mld, struct ieee80211_vif *vif);
int iwl_mld_add_nan_vif(struct iwl_mld *mld, struct ieee80211_vif *vif);
void iwl_mld_rm_vif(struct iwl_mld *mld, struct ieee80211_vif *vif);
void iwl_mld_set_vif_associated(struct iwl_mld *mld,
struct ieee80211_vif *vif);
u8 iwl_mld_get_fw_bss_vifs_ids(struct iwl_mld *mld);
void iwl_mld_handle_probe_resp_data_notif(struct iwl_mld *mld,
struct iwl_rx_packet *pkt);
void iwl_mld_handle_datapath_monitor_notif(struct iwl_mld *mld,
struct iwl_rx_packet *pkt);
void iwl_mld_reset_cca_40mhz_workaround(struct iwl_mld *mld,
struct ieee80211_vif *vif);
static inline bool iwl_mld_vif_low_latency(const struct iwl_mld_vif *mld_vif)
{
return !!mld_vif->low_latency_causes;
}
struct ieee80211_vif *iwl_mld_get_bss_vif(struct iwl_mld *mld);
static inline struct iwl_mld_link_sta *
iwl_mld_get_ap_link_sta(struct ieee80211_vif *vif, int link_id)
{
struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(vif);
struct ieee80211_sta *ap_sta = mld_vif->ap_sta;
struct iwl_mld_sta *mld_ap_sta;
if (!ap_sta)
return NULL;
mld_ap_sta = iwl_mld_sta_from_mac80211(ap_sta);
return iwl_mld_link_sta_dereference_check(mld_ap_sta, link_id);
}
#endif /* __iwl_mld_iface_h__ */