mac80211_hwsim.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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 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_MAX: enum limit
  81. */
  82. enum {
  83. HWSIM_CMD_UNSPEC,
  84. HWSIM_CMD_REGISTER,
  85. HWSIM_CMD_FRAME,
  86. HWSIM_CMD_TX_INFO_FRAME,
  87. HWSIM_CMD_NEW_RADIO,
  88. HWSIM_CMD_DEL_RADIO,
  89. HWSIM_CMD_GET_RADIO,
  90. HWSIM_CMD_ADD_MAC_ADDR,
  91. HWSIM_CMD_DEL_MAC_ADDR,
  92. __HWSIM_CMD_MAX,
  93. };
  94. #define HWSIM_CMD_MAX (_HWSIM_CMD_MAX - 1)
  95. #define HWSIM_CMD_CREATE_RADIO HWSIM_CMD_NEW_RADIO
  96. #define HWSIM_CMD_DESTROY_RADIO HWSIM_CMD_DEL_RADIO
  97. /**
  98. * enum hwsim_attrs - hwsim netlink attributes
  99. *
  100. * @HWSIM_ATTR_UNSPEC: unspecified attribute to catch errors
  101. *
  102. * @HWSIM_ATTR_ADDR_RECEIVER: MAC address of the radio device that
  103. * the frame is broadcasted to
  104. * @HWSIM_ATTR_ADDR_TRANSMITTER: MAC address of the radio device that
  105. * the frame was broadcasted from
  106. * @HWSIM_ATTR_FRAME: Data array
  107. * @HWSIM_ATTR_FLAGS: mac80211 transmission flags, used to process
  108. properly the frame at user space
  109. * @HWSIM_ATTR_RX_RATE: estimated rx rate index for this frame at user
  110. space
  111. * @HWSIM_ATTR_SIGNAL: estimated RX signal for this frame at user
  112. space
  113. * @HWSIM_ATTR_TX_INFO: ieee80211_tx_rate array
  114. * @HWSIM_ATTR_COOKIE: sk_buff cookie to identify the frame
  115. * @HWSIM_ATTR_CHANNELS: u32 attribute used with the %HWSIM_CMD_CREATE_RADIO
  116. * command giving the number of channels supported by the new radio
  117. * @HWSIM_ATTR_RADIO_ID: u32 attribute used with %HWSIM_CMD_DESTROY_RADIO
  118. * only to destroy a radio
  119. * @HWSIM_ATTR_REG_HINT_ALPHA2: alpha2 for regulatoro driver hint
  120. * (nla string, length 2)
  121. * @HWSIM_ATTR_REG_CUSTOM_REG: custom regulatory domain index (u32 attribute)
  122. * @HWSIM_ATTR_REG_STRICT_REG: request REGULATORY_STRICT_REG (flag attribute)
  123. * @HWSIM_ATTR_SUPPORT_P2P_DEVICE: support P2P Device virtual interface (flag)
  124. * @HWSIM_ATTR_USE_CHANCTX: used with the %HWSIM_CMD_CREATE_RADIO
  125. * command to force use of channel contexts even when only a
  126. * single channel is supported
  127. * @HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE: used with the %HWSIM_CMD_CREATE_RADIO
  128. * command to force radio removal when process that created the radio dies
  129. * @HWSIM_ATTR_RADIO_NAME: Name of radio, e.g. phy666
  130. * @HWSIM_ATTR_NO_VIF: Do not create vif (wlanX) when creating radio.
  131. * @HWSIM_ATTR_FREQ: Frequency at which packet is transmitted or received.
  132. * @HWSIM_ATTR_TX_INFO_FLAGS: additional flags for corresponding
  133. * rates of %HWSIM_ATTR_TX_INFO
  134. * @HWSIM_ATTR_PERM_ADDR: permanent mac address of new radio
  135. * @HWSIM_ATTR_IFTYPE_SUPPORT: u32 attribute of supported interface types bits
  136. * @HWSIM_ATTR_CIPHER_SUPPORT: u32 array of supported cipher types
  137. * @HWSIM_ATTR_MLO_SUPPORT: claim MLO support (exact parameters TBD) for
  138. * the new radio
  139. * @__HWSIM_ATTR_MAX: enum limit
  140. */
  141. enum {
  142. HWSIM_ATTR_UNSPEC,
  143. HWSIM_ATTR_ADDR_RECEIVER,
  144. HWSIM_ATTR_ADDR_TRANSMITTER,
  145. HWSIM_ATTR_FRAME,
  146. HWSIM_ATTR_FLAGS,
  147. HWSIM_ATTR_RX_RATE,
  148. HWSIM_ATTR_SIGNAL,
  149. HWSIM_ATTR_TX_INFO,
  150. HWSIM_ATTR_COOKIE,
  151. HWSIM_ATTR_CHANNELS,
  152. HWSIM_ATTR_RADIO_ID,
  153. HWSIM_ATTR_REG_HINT_ALPHA2,
  154. HWSIM_ATTR_REG_CUSTOM_REG,
  155. HWSIM_ATTR_REG_STRICT_REG,
  156. HWSIM_ATTR_SUPPORT_P2P_DEVICE,
  157. HWSIM_ATTR_USE_CHANCTX,
  158. HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE,
  159. HWSIM_ATTR_RADIO_NAME,
  160. HWSIM_ATTR_NO_VIF,
  161. HWSIM_ATTR_FREQ,
  162. HWSIM_ATTR_PAD,
  163. HWSIM_ATTR_TX_INFO_FLAGS,
  164. HWSIM_ATTR_PERM_ADDR,
  165. HWSIM_ATTR_IFTYPE_SUPPORT,
  166. HWSIM_ATTR_CIPHER_SUPPORT,
  167. HWSIM_ATTR_MLO_SUPPORT,
  168. __HWSIM_ATTR_MAX,
  169. };
  170. #define HWSIM_ATTR_MAX (__HWSIM_ATTR_MAX - 1)
  171. /**
  172. * struct hwsim_tx_rate - rate selection/status
  173. *
  174. * @idx: rate index to attempt to send with
  175. * @count: number of tries in this rate before going to the next rate
  176. *
  177. * A value of -1 for @idx indicates an invalid rate and, if used
  178. * in an array of retry rates, that no more rates should be tried.
  179. *
  180. * When used for transmit status reporting, the driver should
  181. * always report the rate and number of retries used.
  182. *
  183. */
  184. struct hwsim_tx_rate {
  185. s8 idx;
  186. u8 count;
  187. } __packed;
  188. /**
  189. * enum hwsim_tx_rate_flags - per-rate flags set by the rate control algorithm.
  190. * Inspired by structure mac80211_rate_control_flags. New flags may be
  191. * appended, but old flags not deleted, to keep compatibility for
  192. * userspace.
  193. *
  194. * These flags are set by the Rate control algorithm for each rate during tx,
  195. * in the @flags member of struct ieee80211_tx_rate.
  196. *
  197. * @MAC80211_HWSIM_TX_RC_USE_RTS_CTS: Use RTS/CTS exchange for this rate.
  198. * @MAC80211_HWSIM_TX_RC_USE_CTS_PROTECT: CTS-to-self protection is required.
  199. * This is set if the current BSS requires ERP protection.
  200. * @MAC80211_HWSIM_TX_RC_USE_SHORT_PREAMBLE: Use short preamble.
  201. * @MAC80211_HWSIM_TX_RC_MCS: HT rate.
  202. * @MAC80211_HWSIM_TX_RC_VHT_MCS: VHT MCS rate, in this case the idx field is
  203. * split into a higher 4 bits (Nss) and lower 4 bits (MCS number)
  204. * @MAC80211_HWSIM_TX_RC_GREEN_FIELD: Indicates whether this rate should be used
  205. * in Greenfield mode.
  206. * @MAC80211_HWSIM_TX_RC_40_MHZ_WIDTH: Indicates if the Channel Width should be
  207. * 40 MHz.
  208. * @MAC80211_HWSIM_TX_RC_80_MHZ_WIDTH: Indicates 80 MHz transmission
  209. * @MAC80211_HWSIM_TX_RC_160_MHZ_WIDTH: Indicates 160 MHz transmission
  210. * (80+80 isn't supported yet)
  211. * @MAC80211_HWSIM_TX_RC_DUP_DATA: The frame should be transmitted on both of
  212. * the adjacent 20 MHz channels, if the current channel type is
  213. * NL80211_CHAN_HT40MINUS or NL80211_CHAN_HT40PLUS.
  214. * @MAC80211_HWSIM_TX_RC_SHORT_GI: Short Guard interval should be used for this
  215. * rate.
  216. */
  217. enum hwsim_tx_rate_flags {
  218. MAC80211_HWSIM_TX_RC_USE_RTS_CTS = BIT(0),
  219. MAC80211_HWSIM_TX_RC_USE_CTS_PROTECT = BIT(1),
  220. MAC80211_HWSIM_TX_RC_USE_SHORT_PREAMBLE = BIT(2),
  221. /* rate index is an HT/VHT MCS instead of an index */
  222. MAC80211_HWSIM_TX_RC_MCS = BIT(3),
  223. MAC80211_HWSIM_TX_RC_GREEN_FIELD = BIT(4),
  224. MAC80211_HWSIM_TX_RC_40_MHZ_WIDTH = BIT(5),
  225. MAC80211_HWSIM_TX_RC_DUP_DATA = BIT(6),
  226. MAC80211_HWSIM_TX_RC_SHORT_GI = BIT(7),
  227. MAC80211_HWSIM_TX_RC_VHT_MCS = BIT(8),
  228. MAC80211_HWSIM_TX_RC_80_MHZ_WIDTH = BIT(9),
  229. MAC80211_HWSIM_TX_RC_160_MHZ_WIDTH = BIT(10),
  230. };
  231. /**
  232. * struct hwsim_tx_rate - rate selection/status
  233. *
  234. * @idx: rate index to attempt to send with
  235. * @count: number of tries in this rate before going to the next rate
  236. *
  237. * A value of -1 for @idx indicates an invalid rate and, if used
  238. * in an array of retry rates, that no more rates should be tried.
  239. *
  240. * When used for transmit status reporting, the driver should
  241. * always report the rate and number of retries used.
  242. *
  243. */
  244. struct hwsim_tx_rate_flag {
  245. s8 idx;
  246. u16 flags;
  247. } __packed;
  248. /**
  249. * DOC: Frame transmission support over virtio
  250. *
  251. * Frame transmission is also supported over virtio to allow communication
  252. * with external entities.
  253. */
  254. /**
  255. * enum hwsim_vqs - queues for virtio frame transmission
  256. *
  257. * @HWSIM_VQ_TX: send frames to external entity
  258. * @HWSIM_VQ_RX: receive frames and transmission info reports
  259. * @HWSIM_NUM_VQS: enum limit
  260. */
  261. enum {
  262. HWSIM_VQ_TX,
  263. HWSIM_VQ_RX,
  264. HWSIM_NUM_VQS,
  265. };
  266. #endif /* __MAC80211_HWSIM_H */