| 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 <[email protected]> |
| 5 |
* Copyright (c) 2011, Javier Lopez <[email protected]> |
| 6 |
* Copyright (C) 2020, 2022-2025 Intel Corporation |
| 7 |
*/ |
| 8 |
|
| 9 |
#ifndef __MAC80211_HWSIM_H |
| 10 |
#define __MAC80211_HWSIM_H |
| 11 |
|
| 12 |
/** |
| 13 |
* enum hwsim_tx_control_flags - flags to describe transmission info/status |
| 14 |
* |
| 15 |
* These flags are used to give the wmediumd extra information in order to |
| 16 |
* modify its behavior for each frame |
| 17 |
* |
| 18 |
* @HWSIM_TX_CTL_REQ_TX_STATUS: require TX status callback for this frame. |
| 19 |
* @HWSIM_TX_CTL_NO_ACK: tell the wmediumd not to wait for an ack |
| 20 |
* @HWSIM_TX_STAT_ACK: Frame was acknowledged |
| 21 |
* |
| 22 |
*/ |
| 23 |
enum hwsim_tx_control_flags { |
| 24 |
HWSIM_TX_CTL_REQ_TX_STATUS = BIT(0), |
| 25 |
HWSIM_TX_CTL_NO_ACK = BIT(1), |
| 26 |
HWSIM_TX_STAT_ACK = BIT(2), |
| 27 |
}; |
| 28 |
|
| 29 |
/** |
| 30 |
* DOC: Frame transmission/registration support |
| 31 |
* |
| 32 |
* Frame transmission and registration support exists to allow userspace |
| 33 |
* entities such as wmediumd to receive and process all broadcasted |
| 34 |
* frames from a mac80211_hwsim radio device. |
| 35 |
* |
| 36 |
* This allow user space applications to decide if the frame should be |
| 37 |
* dropped or not and implement a wireless medium simulator at user space. |
| 38 |
* |
| 39 |
* Registration is done by sending a register message to the driver and |
| 40 |
* will be automatically unregistered if the user application doesn't |
| 41 |
* responds to sent frames. |
| 42 |
* Once registered the user application has to take responsibility of |
| 43 |
* broadcasting the frames to all listening mac80211_hwsim radio |
| 44 |
* interfaces. |
| 45 |
* |
| 46 |
* For more technical details, see the corresponding command descriptions |
| 47 |
* below. |
| 48 |
*/ |
| 49 |
|
| 50 |
/** |
| 51 |
* enum hwsim_commands - supported hwsim commands |
| 52 |
* |
| 53 |
* @HWSIM_CMD_UNSPEC: unspecified command to catch errors |
| 54 |
* |
| 55 |
* @HWSIM_CMD_REGISTER: request to register and received all broadcasted |
| 56 |
* frames by any mac80211_hwsim radio device. |
| 57 |
* @HWSIM_CMD_FRAME: send/receive a broadcasted frame from/to kernel/user |
| 58 |
* space, uses: |
| 59 |
* %HWSIM_ATTR_ADDR_TRANSMITTER, %HWSIM_ATTR_ADDR_RECEIVER, |
| 60 |
* %HWSIM_ATTR_FRAME, %HWSIM_ATTR_FLAGS, %HWSIM_ATTR_RX_RATE, |
| 61 |
* %HWSIM_ATTR_SIGNAL, %HWSIM_ATTR_COOKIE, %HWSIM_ATTR_FREQ (optional) |
| 62 |
* @HWSIM_CMD_TX_INFO_FRAME: Transmission info report from user space to |
| 63 |
* kernel, uses: |
| 64 |
* %HWSIM_ATTR_ADDR_TRANSMITTER, %HWSIM_ATTR_FLAGS, |
| 65 |
* %HWSIM_ATTR_TX_INFO, %HWSIM_ATTR_TX_INFO_FLAGS, |
| 66 |
* %HWSIM_ATTR_SIGNAL, %HWSIM_ATTR_COOKIE |
| 67 |
* @HWSIM_CMD_NEW_RADIO: create a new radio with the given parameters, |
| 68 |
* returns the radio ID (>= 0) or negative on errors, if successful |
| 69 |
* then multicast the result, uses optional parameter: |
| 70 |
* %HWSIM_ATTR_REG_STRICT_REG, %HWSIM_ATTR_SUPPORT_P2P_DEVICE, |
| 71 |
* %HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE, %HWSIM_ATTR_CHANNELS, |
| 72 |
* %HWSIM_ATTR_NO_VIF, %HWSIM_ATTR_RADIO_NAME, %HWSIM_ATTR_USE_CHANCTX, |
| 73 |
* %HWSIM_ATTR_REG_HINT_ALPHA2, %HWSIM_ATTR_REG_CUSTOM_REG, |
| 74 |
* %HWSIM_ATTR_PERM_ADDR |
| 75 |
* @HWSIM_CMD_DEL_RADIO: destroy a radio, reply is multicasted |
| 76 |
* @HWSIM_CMD_GET_RADIO: fetch information about existing radios, uses: |
| 77 |
* %HWSIM_ATTR_RADIO_ID |
| 78 |
* @HWSIM_CMD_ADD_MAC_ADDR: add a receive MAC address (given in the |
| 79 |
* %HWSIM_ATTR_ADDR_RECEIVER attribute) to a device identified by |
| 80 |
* %HWSIM_ATTR_ADDR_TRANSMITTER. This lets wmediumd forward frames |
| 81 |
* to this receiver address for a given station. |
| 82 |
* @HWSIM_CMD_DEL_MAC_ADDR: remove the MAC address again, the attributes |
| 83 |
* are the same as to @HWSIM_CMD_ADD_MAC_ADDR. |
| 84 |
* @HWSIM_CMD_START_PMSR: request to start peer measurement with the |
| 85 |
* %HWSIM_ATTR_PMSR_REQUEST. Result will be sent back asynchronously |
| 86 |
* with %HWSIM_CMD_REPORT_PMSR. |
| 87 |
* @HWSIM_CMD_ABORT_PMSR: Abort previously started peer measurement. |
| 88 |
* @HWSIM_CMD_REPORT_PMSR: Report peer measurement data. |
| 89 |
* @__HWSIM_CMD_MAX: enum limit |
| 90 |
*/ |
| 91 |
enum hwsim_commands { |
| 92 |
HWSIM_CMD_UNSPEC, |
| 93 |
HWSIM_CMD_REGISTER, |
| 94 |
HWSIM_CMD_FRAME, |
| 95 |
HWSIM_CMD_TX_INFO_FRAME, |
| 96 |
HWSIM_CMD_NEW_RADIO, |
| 97 |
HWSIM_CMD_DEL_RADIO, |
| 98 |
HWSIM_CMD_GET_RADIO, |
| 99 |
HWSIM_CMD_ADD_MAC_ADDR, |
| 100 |
HWSIM_CMD_DEL_MAC_ADDR, |
| 101 |
HWSIM_CMD_START_PMSR, |
| 102 |
HWSIM_CMD_ABORT_PMSR, |
| 103 |
HWSIM_CMD_REPORT_PMSR, |
| 104 |
__HWSIM_CMD_MAX, |
| 105 |
}; |
| 106 |
#define HWSIM_CMD_MAX (_HWSIM_CMD_MAX - 1) |
| 107 |
|
| 108 |
#define HWSIM_CMD_CREATE_RADIO HWSIM_CMD_NEW_RADIO |
| 109 |
#define HWSIM_CMD_DESTROY_RADIO HWSIM_CMD_DEL_RADIO |
| 110 |
|
| 111 |
/** |
| 112 |
* enum hwsim_attrs - hwsim netlink attributes |
| 113 |
* |
| 114 |
* @HWSIM_ATTR_UNSPEC: unspecified attribute to catch errors |
| 115 |
* |
| 116 |
* @HWSIM_ATTR_ADDR_RECEIVER: MAC address of the radio device that |
| 117 |
* the frame is broadcasted to |
| 118 |
* @HWSIM_ATTR_ADDR_TRANSMITTER: MAC address of the radio device that |
| 119 |
* the frame was broadcasted from |
| 120 |
* @HWSIM_ATTR_FRAME: Data array |
| 121 |
* @HWSIM_ATTR_FLAGS: mac80211 transmission flags, used to process |
| 122 |
* properly the frame at user space |
| 123 |
* @HWSIM_ATTR_RX_RATE: estimated rx rate index for this frame at user |
| 124 |
* space |
| 125 |
* @HWSIM_ATTR_SIGNAL: estimated RX signal for this frame at user |
| 126 |
* space |
| 127 |
* @HWSIM_ATTR_TX_INFO: ieee80211_tx_rate array |
| 128 |
* @HWSIM_ATTR_COOKIE: sk_buff cookie to identify the frame |
| 129 |
* @HWSIM_ATTR_CHANNELS: u32 attribute used with the %HWSIM_CMD_NEW_RADIO |
| 130 |
* command giving the number of channels supported by the new radio |
| 131 |
* @HWSIM_ATTR_RADIO_ID: u32 attribute used with %HWSIM_CMD_DESTROY_RADIO |
| 132 |
* only to destroy a radio |
| 133 |
* @HWSIM_ATTR_REG_HINT_ALPHA2: alpha2 for regulatory driver hint |
| 134 |
* (nla string, length 2) |
| 135 |
* @HWSIM_ATTR_REG_CUSTOM_REG: custom regulatory domain index (u32 attribute) |
| 136 |
* @HWSIM_ATTR_REG_STRICT_REG: request REGULATORY_STRICT_REG (flag attribute) |
| 137 |
* @HWSIM_ATTR_SUPPORT_P2P_DEVICE: support P2P Device virtual interface (flag) |
| 138 |
* @HWSIM_ATTR_USE_CHANCTX: used with the %HWSIM_CMD_NEW_RADIO |
| 139 |
* command to force use of channel contexts even when only a |
| 140 |
* single channel is supported |
| 141 |
* @HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE: used with the %HWSIM_CMD_NEW_RADIO |
| 142 |
* command to force radio removal when process that created the radio dies |
| 143 |
* @HWSIM_ATTR_RADIO_NAME: Name of radio, e.g. phy666 |
| 144 |
* @HWSIM_ATTR_NO_VIF: Do not create vif (wlanX) when creating radio. |
| 145 |
* @HWSIM_ATTR_FREQ: Frequency at which packet is transmitted or received. |
| 146 |
* @HWSIM_ATTR_PAD: padding attribute for 64-bit values, ignore |
| 147 |
* @HWSIM_ATTR_TX_INFO_FLAGS: additional flags for corresponding |
| 148 |
* rates of %HWSIM_ATTR_TX_INFO |
| 149 |
* @HWSIM_ATTR_PERM_ADDR: permanent mac address of new radio |
| 150 |
* @HWSIM_ATTR_IFTYPE_SUPPORT: u32 attribute of supported interface types bits |
| 151 |
* @HWSIM_ATTR_CIPHER_SUPPORT: u32 array of supported cipher types |
| 152 |
* @HWSIM_ATTR_MLO_SUPPORT: claim MLO support (exact parameters TBD) for |
| 153 |
* the new radio |
| 154 |
* @HWSIM_ATTR_PMSR_SUPPORT: nested attribute used with %HWSIM_CMD_NEW_RADIO |
| 155 |
* to provide peer measurement capabilities. (nl80211_peer_measurement_attrs) |
| 156 |
* @HWSIM_ATTR_PMSR_REQUEST: nested attribute used with %HWSIM_CMD_START_PMSR |
| 157 |
* to provide details about peer measurement request (nl80211_peer_measurement_attrs) |
| 158 |
* @HWSIM_ATTR_PMSR_RESULT: nested attributed used with %HWSIM_CMD_REPORT_PMSR |
| 159 |
* to provide peer measurement result (nl80211_peer_measurement_attrs) |
| 160 |
* @HWSIM_ATTR_MULTI_RADIO: Register multiple wiphy radios (flag). |
| 161 |
* Adds one radio for each band. Number of supported channels will be set for |
| 162 |
* each radio instead of for the wiphy. |
| 163 |
* @HWSIM_ATTR_SUPPORT_NAN_DEVICE: support NAN Device virtual interface (flag) |
| 164 |
* @__HWSIM_ATTR_MAX: enum limit |
| 165 |
*/ |
| 166 |
enum hwsim_attrs { |
| 167 |
HWSIM_ATTR_UNSPEC, |
| 168 |
HWSIM_ATTR_ADDR_RECEIVER, |
| 169 |
HWSIM_ATTR_ADDR_TRANSMITTER, |
| 170 |
HWSIM_ATTR_FRAME, |
| 171 |
HWSIM_ATTR_FLAGS, |
| 172 |
HWSIM_ATTR_RX_RATE, |
| 173 |
HWSIM_ATTR_SIGNAL, |
| 174 |
HWSIM_ATTR_TX_INFO, |
| 175 |
HWSIM_ATTR_COOKIE, |
| 176 |
HWSIM_ATTR_CHANNELS, |
| 177 |
HWSIM_ATTR_RADIO_ID, |
| 178 |
HWSIM_ATTR_REG_HINT_ALPHA2, |
| 179 |
HWSIM_ATTR_REG_CUSTOM_REG, |
| 180 |
HWSIM_ATTR_REG_STRICT_REG, |
| 181 |
HWSIM_ATTR_SUPPORT_P2P_DEVICE, |
| 182 |
HWSIM_ATTR_USE_CHANCTX, |
| 183 |
HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE, |
| 184 |
HWSIM_ATTR_RADIO_NAME, |
| 185 |
HWSIM_ATTR_NO_VIF, |
| 186 |
HWSIM_ATTR_FREQ, |
| 187 |
HWSIM_ATTR_PAD, |
| 188 |
HWSIM_ATTR_TX_INFO_FLAGS, |
| 189 |
HWSIM_ATTR_PERM_ADDR, |
| 190 |
HWSIM_ATTR_IFTYPE_SUPPORT, |
| 191 |
HWSIM_ATTR_CIPHER_SUPPORT, |
| 192 |
HWSIM_ATTR_MLO_SUPPORT, |
| 193 |
HWSIM_ATTR_PMSR_SUPPORT, |
| 194 |
HWSIM_ATTR_PMSR_REQUEST, |
| 195 |
HWSIM_ATTR_PMSR_RESULT, |
| 196 |
HWSIM_ATTR_MULTI_RADIO, |
| 197 |
HWSIM_ATTR_SUPPORT_NAN_DEVICE, |
| 198 |
__HWSIM_ATTR_MAX, |
| 199 |
}; |
| 200 |
#define HWSIM_ATTR_MAX (__HWSIM_ATTR_MAX - 1) |
| 201 |
|
| 202 |
/** |
| 203 |
* struct hwsim_tx_rate - rate selection/status |
| 204 |
* |
| 205 |
* @idx: rate index to attempt to send with |
| 206 |
* @count: number of tries in this rate before going to the next rate |
| 207 |
* |
| 208 |
* A value of -1 for @idx indicates an invalid rate and, if used |
| 209 |
* in an array of retry rates, that no more rates should be tried. |
| 210 |
* |
| 211 |
* When used for transmit status reporting, the driver should |
| 212 |
* always report the rate and number of retries used. |
| 213 |
* |
| 214 |
*/ |
| 215 |
struct hwsim_tx_rate { |
| 216 |
s8 idx; |
| 217 |
u8 count; |
| 218 |
} __packed; |
| 219 |
|
| 220 |
/** |
| 221 |
* enum hwsim_tx_rate_flags - per-rate flags set by the rate control algorithm. |
| 222 |
* Inspired by structure mac80211_rate_control_flags. New flags may be |
| 223 |
* appended, but old flags not deleted, to keep compatibility for |
| 224 |
* userspace. |
| 225 |
* |
| 226 |
* These flags are set by the Rate control algorithm for each rate during tx, |
| 227 |
* in the @flags member of struct ieee80211_tx_rate. |
| 228 |
* |
| 229 |
* @MAC80211_HWSIM_TX_RC_USE_RTS_CTS: Use RTS/CTS exchange for this rate. |
| 230 |
* @MAC80211_HWSIM_TX_RC_USE_CTS_PROTECT: CTS-to-self protection is required. |
| 231 |
* This is set if the current BSS requires ERP protection. |
| 232 |
* @MAC80211_HWSIM_TX_RC_USE_SHORT_PREAMBLE: Use short preamble. |
| 233 |
* @MAC80211_HWSIM_TX_RC_MCS: HT rate. |
| 234 |
* @MAC80211_HWSIM_TX_RC_VHT_MCS: VHT MCS rate, in this case the idx field is |
| 235 |
* split into a higher 4 bits (Nss) and lower 4 bits (MCS number) |
| 236 |
* @MAC80211_HWSIM_TX_RC_GREEN_FIELD: Indicates whether this rate should be used |
| 237 |
* in Greenfield mode. |
| 238 |
* @MAC80211_HWSIM_TX_RC_40_MHZ_WIDTH: Indicates if the Channel Width should be |
| 239 |
* 40 MHz. |
| 240 |
* @MAC80211_HWSIM_TX_RC_80_MHZ_WIDTH: Indicates 80 MHz transmission |
| 241 |
* @MAC80211_HWSIM_TX_RC_160_MHZ_WIDTH: Indicates 160 MHz transmission |
| 242 |
* (80+80 isn't supported yet) |
| 243 |
* @MAC80211_HWSIM_TX_RC_DUP_DATA: The frame should be transmitted on both of |
| 244 |
* the adjacent 20 MHz channels, if the current channel type is |
| 245 |
* NL80211_CHAN_HT40MINUS or NL80211_CHAN_HT40PLUS. |
| 246 |
* @MAC80211_HWSIM_TX_RC_SHORT_GI: Short Guard interval should be used for this |
| 247 |
* rate. |
| 248 |
*/ |
| 249 |
enum hwsim_tx_rate_flags { |
| 250 |
MAC80211_HWSIM_TX_RC_USE_RTS_CTS = BIT(0), |
| 251 |
MAC80211_HWSIM_TX_RC_USE_CTS_PROTECT = BIT(1), |
| 252 |
MAC80211_HWSIM_TX_RC_USE_SHORT_PREAMBLE = BIT(2), |
| 253 |
|
| 254 |
/* rate index is an HT/VHT MCS instead of an index */ |
| 255 |
MAC80211_HWSIM_TX_RC_MCS = BIT(3), |
| 256 |
MAC80211_HWSIM_TX_RC_GREEN_FIELD = BIT(4), |
| 257 |
MAC80211_HWSIM_TX_RC_40_MHZ_WIDTH = BIT(5), |
| 258 |
MAC80211_HWSIM_TX_RC_DUP_DATA = BIT(6), |
| 259 |
MAC80211_HWSIM_TX_RC_SHORT_GI = BIT(7), |
| 260 |
MAC80211_HWSIM_TX_RC_VHT_MCS = BIT(8), |
| 261 |
MAC80211_HWSIM_TX_RC_80_MHZ_WIDTH = BIT(9), |
| 262 |
MAC80211_HWSIM_TX_RC_160_MHZ_WIDTH = BIT(10), |
| 263 |
}; |
| 264 |
|
| 265 |
/** |
| 266 |
* struct hwsim_tx_rate_flag - rate selection/status |
| 267 |
* |
| 268 |
* @idx: rate index to attempt to send with |
| 269 |
* @flags: the rate flags according to &enum hwsim_tx_rate_flags |
| 270 |
* |
| 271 |
* A value of -1 for @idx indicates an invalid rate and, if used |
| 272 |
* in an array of retry rates, that no more rates should be tried. |
| 273 |
* |
| 274 |
* When used for transmit status reporting, the driver should |
| 275 |
* always report the rate and number of retries used. |
| 276 |
* |
| 277 |
*/ |
| 278 |
struct hwsim_tx_rate_flag { |
| 279 |
s8 idx; |
| 280 |
u16 flags; |
| 281 |
} __packed; |
| 282 |
|
| 283 |
/** |
| 284 |
* DOC: Frame transmission support over virtio |
| 285 |
* |
| 286 |
* Frame transmission is also supported over virtio to allow communication |
| 287 |
* with external entities. |
| 288 |
*/ |
| 289 |
|
| 290 |
/** |
| 291 |
* enum hwsim_vqs - queues for virtio frame transmission |
| 292 |
* |
| 293 |
* @HWSIM_VQ_TX: send frames to external entity |
| 294 |
* @HWSIM_VQ_RX: receive frames and transmission info reports |
| 295 |
* @HWSIM_NUM_VQS: enum limit |
| 296 |
*/ |
| 297 |
enum hwsim_vqs { |
| 298 |
HWSIM_VQ_TX, |
| 299 |
HWSIM_VQ_RX, |
| 300 |
HWSIM_NUM_VQS, |
| 301 |
}; |
| 302 |
|
| 303 |
/** |
| 304 |
* enum hwsim_rate_info_attributes - bitrate information. |
| 305 |
* |
| 306 |
* Information about a receiving or transmitting bitrate |
| 307 |
* that can be mapped to struct rate_info |
| 308 |
* |
| 309 |
* @__HWSIM_RATE_INFO_ATTR_INVALID: reserved, netlink attribute 0 is invalid |
| 310 |
* @HWSIM_RATE_INFO_ATTR_FLAGS: bitflag of flags from &enum rate_info_flags |
| 311 |
* @HWSIM_RATE_INFO_ATTR_MCS: mcs index if struct describes an HT/VHT/HE rate |
| 312 |
* @HWSIM_RATE_INFO_ATTR_LEGACY: bitrate in 100kbit/s for 802.11abg |
| 313 |
* @HWSIM_RATE_INFO_ATTR_NSS: number of streams (VHT & HE only) |
| 314 |
* @HWSIM_RATE_INFO_ATTR_BW: bandwidth (from &enum rate_info_bw) |
| 315 |
* @HWSIM_RATE_INFO_ATTR_HE_GI: HE guard interval (from &enum nl80211_he_gi) |
| 316 |
* @HWSIM_RATE_INFO_ATTR_HE_DCM: HE DCM value |
| 317 |
* @HWSIM_RATE_INFO_ATTR_HE_RU_ALLOC: HE RU allocation (from &enum nl80211_he_ru_alloc, |
| 318 |
* only valid if bw is %RATE_INFO_BW_HE_RU) |
| 319 |
* @HWSIM_RATE_INFO_ATTR_N_BOUNDED_CH: In case of EDMG the number of bonded channels (1-4) |
| 320 |
* @HWSIM_RATE_INFO_ATTR_EHT_GI: EHT guard interval (from &enum nl80211_eht_gi) |
| 321 |
* @HWSIM_RATE_INFO_ATTR_EHT_RU_ALLOC: EHT RU allocation (from &enum nl80211_eht_ru_alloc, |
| 322 |
* only valid if bw is %RATE_INFO_BW_EHT_RU) |
| 323 |
* @NUM_HWSIM_RATE_INFO_ATTRS: internal |
| 324 |
* @HWSIM_RATE_INFO_ATTR_MAX: highest attribute number |
| 325 |
*/ |
| 326 |
enum hwsim_rate_info_attributes { |
| 327 |
__HWSIM_RATE_INFO_ATTR_INVALID, |
| 328 |
|
| 329 |
HWSIM_RATE_INFO_ATTR_FLAGS, |
| 330 |
HWSIM_RATE_INFO_ATTR_MCS, |
| 331 |
HWSIM_RATE_INFO_ATTR_LEGACY, |
| 332 |
HWSIM_RATE_INFO_ATTR_NSS, |
| 333 |
HWSIM_RATE_INFO_ATTR_BW, |
| 334 |
HWSIM_RATE_INFO_ATTR_HE_GI, |
| 335 |
HWSIM_RATE_INFO_ATTR_HE_DCM, |
| 336 |
HWSIM_RATE_INFO_ATTR_HE_RU_ALLOC, |
| 337 |
HWSIM_RATE_INFO_ATTR_N_BOUNDED_CH, |
| 338 |
HWSIM_RATE_INFO_ATTR_EHT_GI, |
| 339 |
HWSIM_RATE_INFO_ATTR_EHT_RU_ALLOC, |
| 340 |
|
| 341 |
/* keep last */ |
| 342 |
NUM_HWSIM_RATE_INFO_ATTRS, |
| 343 |
HWSIM_RATE_INFO_ATTR_MAX = NUM_HWSIM_RATE_INFO_ATTRS - 1 |
| 344 |
}; |
| 345 |
|
| 346 |
#endif /* __MAC80211_HWSIM_H */ |