1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * mac80211_hwsim - software simulator of 802.11 radio(s) for mac80211 4 * Copyright (c) 2008, Jouni Malinen <j@w1.fi> 5 * Copyright (c) 2011, Javier Lopez <jlopex@gmail.com> 6 * Copyright (c) 2016 - 2017 Intel Deutschland GmbH 7 * Copyright (C) 2018 - 2026 Intel Corporation 8 */ 9 10 #ifndef __MAC80211_HWSIM_I_H 11 #define __MAC80211_HWSIM_I_H 12 13 #include <net/mac80211.h> 14 #include "mac80211_hwsim.h" 15 #include "mac80211_hwsim_nan.h" 16 17 struct hwsim_sta_nan_sched { 18 /* Later members are protected by this lock */ 19 spinlock_t lock; 20 u16 committed_dw; 21 struct { 22 u8 map_id; 23 struct cfg80211_chan_def chans[CFG80211_NAN_SCHED_NUM_TIME_SLOTS]; 24 } maps[CFG80211_NAN_MAX_PEER_MAPS]; 25 }; 26 27 struct hwsim_sta_priv { 28 u32 magic; 29 unsigned int last_link; 30 u16 active_links_rx; 31 32 /* NAN peer schedule - must be accessed under nan_sched.lock */ 33 struct hwsim_sta_nan_sched nan_sched; 34 }; 35 36 #define HWSIM_STA_MAGIC 0x6d537749 37 38 struct mac80211_hwsim_link_data { 39 u32 link_id; 40 u64 beacon_int /* beacon interval in us */; 41 struct hrtimer beacon_timer; 42 }; 43 44 #define HWSIM_NUM_CHANNELS_2GHZ 14 45 #define HWSIM_NUM_CHANNELS_5GHZ 40 46 #define HWSIM_NUM_CHANNELS_6GHZ 59 47 #define HWSIM_NUM_S1G_CHANNELS_US 51 48 #define HWSIM_NUM_RATES 12 49 #define HWSIM_NUM_CIPHERS 11 50 51 struct mac80211_hwsim_data { 52 struct list_head list; 53 struct rhash_head rht; 54 struct ieee80211_hw *hw; 55 struct device *dev; 56 struct ieee80211_supported_band bands[NUM_NL80211_BANDS]; 57 struct ieee80211_channel channels_2ghz[HWSIM_NUM_CHANNELS_2GHZ]; 58 struct ieee80211_channel channels_5ghz[HWSIM_NUM_CHANNELS_5GHZ]; 59 struct ieee80211_channel channels_6ghz[HWSIM_NUM_CHANNELS_6GHZ]; 60 struct ieee80211_channel channels_s1g[HWSIM_NUM_S1G_CHANNELS_US]; 61 struct ieee80211_rate rates[HWSIM_NUM_RATES]; 62 struct ieee80211_iface_combination if_combination; 63 struct ieee80211_iface_limit if_limits[5]; 64 int n_if_limits; 65 /* Storage space for channels, etc. */ 66 struct mac80211_hwsim_phy_data *phy_data; 67 68 struct ieee80211_iface_combination if_combination_radio; 69 struct wiphy_radio_freq_range radio_range[NUM_NL80211_BANDS]; 70 struct wiphy_radio radio[NUM_NL80211_BANDS]; 71 72 u32 ciphers[HWSIM_NUM_CIPHERS]; 73 74 struct mac_address addresses[3]; 75 int channels, idx; 76 bool use_chanctx; 77 bool destroy_on_close; 78 u32 portid; 79 char alpha2[2]; 80 const struct ieee80211_regdomain *regd; 81 82 struct ieee80211_channel *tmp_chan; 83 struct ieee80211_channel *roc_chan; 84 u32 roc_duration; 85 struct delayed_work roc_start; 86 struct delayed_work roc_done; 87 struct delayed_work hw_scan; 88 struct cfg80211_scan_request *hw_scan_request; 89 struct ieee80211_vif *hw_scan_vif; 90 int scan_chan_idx; 91 u8 scan_addr[ETH_ALEN]; 92 struct { 93 struct ieee80211_channel *channel; 94 unsigned long next_start, start, end; 95 } survey_data[HWSIM_NUM_CHANNELS_2GHZ + 96 HWSIM_NUM_CHANNELS_5GHZ + 97 HWSIM_NUM_CHANNELS_6GHZ]; 98 99 struct ieee80211_channel *channel; 100 enum nl80211_chan_width bw; 101 unsigned int rx_filter; 102 bool started, idle, scanning; 103 struct mutex mutex; 104 enum ps_mode { 105 PS_DISABLED, PS_ENABLED, PS_AUTO_POLL, PS_MANUAL_POLL 106 } ps; 107 bool ps_poll_pending; 108 struct dentry *debugfs; 109 struct cfg80211_chan_def radar_background_chandef; 110 111 atomic_t pending_cookie; 112 struct sk_buff_head pending; /* packets pending */ 113 /* 114 * Only radios in the same group can communicate together (the 115 * channel has to match too). Each bit represents a group. A 116 * radio can be in more than one group. 117 */ 118 u64 group; 119 120 /* group shared by radios created in the same netns */ 121 int netgroup; 122 /* wmediumd portid responsible for netgroup of this radio */ 123 u32 wmediumd; 124 125 /* difference between this hw's clock and the real clock, in usecs */ 126 spinlock_t tsf_offset_lock; 127 s64 tsf_offset; 128 129 /* Stats */ 130 u64 tx_pkts; 131 u64 rx_pkts; 132 u64 tx_bytes; 133 u64 rx_bytes; 134 u64 tx_dropped; 135 u64 tx_failed; 136 137 /* RSSI in rx status of the receiver */ 138 int rx_rssi; 139 140 /* only used when pmsr capability is supplied */ 141 struct cfg80211_pmsr_capabilities pmsr_capa; 142 struct cfg80211_pmsr_request *pmsr_request; 143 struct wireless_dev *pmsr_request_wdev; 144 145 struct mac80211_hwsim_link_data link_data[IEEE80211_MLD_MAX_NUM_LINKS]; 146 147 struct mac80211_hwsim_nan_data nan; 148 }; 149 150 extern spinlock_t hwsim_radio_lock; 151 extern struct list_head hwsim_radios; 152 153 ktime_t mac80211_hwsim_tsf_to_boottime(struct mac80211_hwsim_data *data, 154 u64 tsf); 155 u64 mac80211_hwsim_boottime_to_tsf(struct mac80211_hwsim_data *data, 156 ktime_t ts); 157 158 u64 mac80211_hwsim_get_tsf(struct ieee80211_hw *hw, 159 struct ieee80211_vif *vif); 160 161 void mac80211_hwsim_tx_frame(struct ieee80211_hw *hw, 162 struct sk_buff *skb, 163 struct ieee80211_channel *chan); 164 165 void ieee80211_hwsim_wake_tx_queue(struct ieee80211_hw *hw, 166 struct ieee80211_txq *txq); 167 168 #endif /* __MAC80211_HWSIM_I_H */ 169