mac80211_hwsim.h 13 KB

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