mac80211_hwsim.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. */
  7. #ifndef __MAC80211_HWSIM_H
  8. #define __MAC80211_HWSIM_H
  9. /**
  10. * enum hwsim_tx_control_flags - flags to describe transmission info/status
  11. *
  12. * These flags are used to give the wmediumd extra information in order to
  13. * modify its behavior for each frame
  14. *
  15. * @HWSIM_TX_CTL_REQ_TX_STATUS: require TX status callback for this frame.
  16. * @HWSIM_TX_CTL_NO_ACK: tell the wmediumd not to wait for an ack
  17. * @HWSIM_TX_STAT_ACK: Frame was acknowledged
  18. *
  19. */
  20. enum hwsim_tx_control_flags {
  21. HWSIM_TX_CTL_REQ_TX_STATUS = BIT(0),
  22. HWSIM_TX_CTL_NO_ACK = BIT(1),
  23. HWSIM_TX_STAT_ACK = BIT(2),
  24. };
  25. /**
  26. * DOC: Frame transmission/registration support
  27. *
  28. * Frame transmission and registration support exists to allow userspace
  29. * entities such as wmediumd to receive and process all broadcasted
  30. * frames from a mac80211_hwsim radio device.
  31. *
  32. * This allow user space applications to decide if the frame should be
  33. * dropped or not and implement a wireless medium simulator at user space.
  34. *
  35. * Registration is done by sending a register message to the driver and
  36. * will be automatically unregistered if the user application doesn't
  37. * responds to sent frames.
  38. * Once registered the user application has to take responsibility of
  39. * broadcasting the frames to all listening mac80211_hwsim radio
  40. * interfaces.
  41. *
  42. * For more technical details, see the corresponding command descriptions
  43. * below.
  44. */
  45. /**
  46. * enum hwsim_commands - supported hwsim commands
  47. *
  48. * @HWSIM_CMD_UNSPEC: unspecified command to catch errors
  49. *
  50. * @HWSIM_CMD_REGISTER: request to register and received all broadcasted
  51. * frames by any mac80211_hwsim radio device.
  52. * @HWSIM_CMD_FRAME: send/receive a broadcasted frame from/to kernel/user
  53. * space, uses:
  54. * %HWSIM_ATTR_ADDR_TRANSMITTER, %HWSIM_ATTR_ADDR_RECEIVER,
  55. * %HWSIM_ATTR_FRAME, %HWSIM_ATTR_FLAGS, %HWSIM_ATTR_RX_RATE,
  56. * %HWSIM_ATTR_SIGNAL, %HWSIM_ATTR_COOKIE, %HWSIM_ATTR_FREQ (optional)
  57. * @HWSIM_CMD_TX_INFO_FRAME: Transmission info report from user space to
  58. * kernel, uses:
  59. * %HWSIM_ATTR_ADDR_TRANSMITTER, %HWSIM_ATTR_FLAGS,
  60. * %HWSIM_ATTR_TX_INFO, %WSIM_ATTR_TX_INFO_FLAGS,
  61. * %HWSIM_ATTR_SIGNAL, %HWSIM_ATTR_COOKIE
  62. * @HWSIM_CMD_NEW_RADIO: create a new radio with the given parameters,
  63. * returns the radio ID (>= 0) or negative on errors, if successful
  64. * then multicast the result, uses optional parameter:
  65. * %HWSIM_ATTR_REG_STRICT_REG, %HWSIM_ATTR_SUPPORT_P2P_DEVICE,
  66. * %HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE, %HWSIM_ATTR_CHANNELS,
  67. * %HWSIM_ATTR_NO_VIF, %HWSIM_ATTR_RADIO_NAME, %HWSIM_ATTR_USE_CHANCTX,
  68. * %HWSIM_ATTR_REG_HINT_ALPHA2, %HWSIM_ATTR_REG_CUSTOM_REG,
  69. * %HWSIM_ATTR_PERM_ADDR
  70. * @HWSIM_CMD_DEL_RADIO: destroy a radio, reply is multicasted
  71. * @HWSIM_CMD_GET_RADIO: fetch information about existing radios, uses:
  72. * %HWSIM_ATTR_RADIO_ID
  73. * @__HWSIM_CMD_MAX: enum limit
  74. */
  75. enum {
  76. HWSIM_CMD_UNSPEC,
  77. HWSIM_CMD_REGISTER,
  78. HWSIM_CMD_FRAME,
  79. HWSIM_CMD_TX_INFO_FRAME,
  80. HWSIM_CMD_NEW_RADIO,
  81. HWSIM_CMD_DEL_RADIO,
  82. HWSIM_CMD_GET_RADIO,
  83. __HWSIM_CMD_MAX,
  84. };
  85. #define HWSIM_CMD_MAX (_HWSIM_CMD_MAX - 1)
  86. #define HWSIM_CMD_CREATE_RADIO HWSIM_CMD_NEW_RADIO
  87. #define HWSIM_CMD_DESTROY_RADIO HWSIM_CMD_DEL_RADIO
  88. /**
  89. * enum hwsim_attrs - hwsim netlink attributes
  90. *
  91. * @HWSIM_ATTR_UNSPEC: unspecified attribute to catch errors
  92. *
  93. * @HWSIM_ATTR_ADDR_RECEIVER: MAC address of the radio device that
  94. * the frame is broadcasted to
  95. * @HWSIM_ATTR_ADDR_TRANSMITTER: MAC address of the radio device that
  96. * the frame was broadcasted from
  97. * @HWSIM_ATTR_FRAME: Data array
  98. * @HWSIM_ATTR_FLAGS: mac80211 transmission flags, used to process
  99. properly the frame at user space
  100. * @HWSIM_ATTR_RX_RATE: estimated rx rate index for this frame at user
  101. space
  102. * @HWSIM_ATTR_SIGNAL: estimated RX signal for this frame at user
  103. space
  104. * @HWSIM_ATTR_TX_INFO: ieee80211_tx_rate array
  105. * @HWSIM_ATTR_COOKIE: sk_buff cookie to identify the frame
  106. * @HWSIM_ATTR_CHANNELS: u32 attribute used with the %HWSIM_CMD_CREATE_RADIO
  107. * command giving the number of channels supported by the new radio
  108. * @HWSIM_ATTR_RADIO_ID: u32 attribute used with %HWSIM_CMD_DESTROY_RADIO
  109. * only to destroy a radio
  110. * @HWSIM_ATTR_REG_HINT_ALPHA2: alpha2 for regulatoro driver hint
  111. * (nla string, length 2)
  112. * @HWSIM_ATTR_REG_CUSTOM_REG: custom regulatory domain index (u32 attribute)
  113. * @HWSIM_ATTR_REG_STRICT_REG: request REGULATORY_STRICT_REG (flag attribute)
  114. * @HWSIM_ATTR_SUPPORT_P2P_DEVICE: support P2P Device virtual interface (flag)
  115. * @HWSIM_ATTR_USE_CHANCTX: used with the %HWSIM_CMD_CREATE_RADIO
  116. * command to force use of channel contexts even when only a
  117. * single channel is supported
  118. * @HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE: used with the %HWSIM_CMD_CREATE_RADIO
  119. * command to force radio removal when process that created the radio dies
  120. * @HWSIM_ATTR_RADIO_NAME: Name of radio, e.g. phy666
  121. * @HWSIM_ATTR_NO_VIF: Do not create vif (wlanX) when creating radio.
  122. * @HWSIM_ATTR_FREQ: Frequency at which packet is transmitted or received.
  123. * @HWSIM_ATTR_TX_INFO_FLAGS: additional flags for corresponding
  124. * rates of %HWSIM_ATTR_TX_INFO
  125. * @HWSIM_ATTR_PERM_ADDR: permanent mac address of new radio
  126. * @HWSIM_ATTR_IFTYPE_SUPPORT: u32 attribute of supported interface types bits
  127. * @HWSIM_ATTR_CIPHER_SUPPORT: u32 array of supported cipher types
  128. * @__HWSIM_ATTR_MAX: enum limit
  129. */
  130. enum {
  131. HWSIM_ATTR_UNSPEC,
  132. HWSIM_ATTR_ADDR_RECEIVER,
  133. HWSIM_ATTR_ADDR_TRANSMITTER,
  134. HWSIM_ATTR_FRAME,
  135. HWSIM_ATTR_FLAGS,
  136. HWSIM_ATTR_RX_RATE,
  137. HWSIM_ATTR_SIGNAL,
  138. HWSIM_ATTR_TX_INFO,
  139. HWSIM_ATTR_COOKIE,
  140. HWSIM_ATTR_CHANNELS,
  141. HWSIM_ATTR_RADIO_ID,
  142. HWSIM_ATTR_REG_HINT_ALPHA2,
  143. HWSIM_ATTR_REG_CUSTOM_REG,
  144. HWSIM_ATTR_REG_STRICT_REG,
  145. HWSIM_ATTR_SUPPORT_P2P_DEVICE,
  146. HWSIM_ATTR_USE_CHANCTX,
  147. HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE,
  148. HWSIM_ATTR_RADIO_NAME,
  149. HWSIM_ATTR_NO_VIF,
  150. HWSIM_ATTR_FREQ,
  151. HWSIM_ATTR_PAD,
  152. HWSIM_ATTR_TX_INFO_FLAGS,
  153. HWSIM_ATTR_PERM_ADDR,
  154. HWSIM_ATTR_IFTYPE_SUPPORT,
  155. HWSIM_ATTR_CIPHER_SUPPORT,
  156. __HWSIM_ATTR_MAX,
  157. };
  158. #define HWSIM_ATTR_MAX (__HWSIM_ATTR_MAX - 1)
  159. /**
  160. * struct hwsim_tx_rate - rate selection/status
  161. *
  162. * @idx: rate index to attempt to send with
  163. * @count: number of tries in this rate before going to the next rate
  164. *
  165. * A value of -1 for @idx indicates an invalid rate and, if used
  166. * in an array of retry rates, that no more rates should be tried.
  167. *
  168. * When used for transmit status reporting, the driver should
  169. * always report the rate and number of retries used.
  170. *
  171. */
  172. struct hwsim_tx_rate {
  173. s8 idx;
  174. u8 count;
  175. } __packed;
  176. /**
  177. * enum hwsim_tx_rate_flags - per-rate flags set by the rate control algorithm.
  178. * Inspired by structure mac80211_rate_control_flags. New flags may be
  179. * appended, but old flags not deleted, to keep compatibility for
  180. * userspace.
  181. *
  182. * These flags are set by the Rate control algorithm for each rate during tx,
  183. * in the @flags member of struct ieee80211_tx_rate.
  184. *
  185. * @MAC80211_HWSIM_TX_RC_USE_RTS_CTS: Use RTS/CTS exchange for this rate.
  186. * @MAC80211_HWSIM_TX_RC_USE_CTS_PROTECT: CTS-to-self protection is required.
  187. * This is set if the current BSS requires ERP protection.
  188. * @MAC80211_HWSIM_TX_RC_USE_SHORT_PREAMBLE: Use short preamble.
  189. * @MAC80211_HWSIM_TX_RC_MCS: HT rate.
  190. * @MAC80211_HWSIM_TX_RC_VHT_MCS: VHT MCS rate, in this case the idx field is
  191. * split into a higher 4 bits (Nss) and lower 4 bits (MCS number)
  192. * @MAC80211_HWSIM_TX_RC_GREEN_FIELD: Indicates whether this rate should be used
  193. * in Greenfield mode.
  194. * @MAC80211_HWSIM_TX_RC_40_MHZ_WIDTH: Indicates if the Channel Width should be
  195. * 40 MHz.
  196. * @MAC80211_HWSIM_TX_RC_80_MHZ_WIDTH: Indicates 80 MHz transmission
  197. * @MAC80211_HWSIM_TX_RC_160_MHZ_WIDTH: Indicates 160 MHz transmission
  198. * (80+80 isn't supported yet)
  199. * @MAC80211_HWSIM_TX_RC_DUP_DATA: The frame should be transmitted on both of
  200. * the adjacent 20 MHz channels, if the current channel type is
  201. * NL80211_CHAN_HT40MINUS or NL80211_CHAN_HT40PLUS.
  202. * @MAC80211_HWSIM_TX_RC_SHORT_GI: Short Guard interval should be used for this
  203. * rate.
  204. */
  205. enum hwsim_tx_rate_flags {
  206. MAC80211_HWSIM_TX_RC_USE_RTS_CTS = BIT(0),
  207. MAC80211_HWSIM_TX_RC_USE_CTS_PROTECT = BIT(1),
  208. MAC80211_HWSIM_TX_RC_USE_SHORT_PREAMBLE = BIT(2),
  209. /* rate index is an HT/VHT MCS instead of an index */
  210. MAC80211_HWSIM_TX_RC_MCS = BIT(3),
  211. MAC80211_HWSIM_TX_RC_GREEN_FIELD = BIT(4),
  212. MAC80211_HWSIM_TX_RC_40_MHZ_WIDTH = BIT(5),
  213. MAC80211_HWSIM_TX_RC_DUP_DATA = BIT(6),
  214. MAC80211_HWSIM_TX_RC_SHORT_GI = BIT(7),
  215. MAC80211_HWSIM_TX_RC_VHT_MCS = BIT(8),
  216. MAC80211_HWSIM_TX_RC_80_MHZ_WIDTH = BIT(9),
  217. MAC80211_HWSIM_TX_RC_160_MHZ_WIDTH = BIT(10),
  218. };
  219. /**
  220. * struct hwsim_tx_rate - rate selection/status
  221. *
  222. * @idx: rate index to attempt to send with
  223. * @count: number of tries in this rate before going to the next rate
  224. *
  225. * A value of -1 for @idx indicates an invalid rate and, if used
  226. * in an array of retry rates, that no more rates should be tried.
  227. *
  228. * When used for transmit status reporting, the driver should
  229. * always report the rate and number of retries used.
  230. *
  231. */
  232. struct hwsim_tx_rate_flag {
  233. s8 idx;
  234. u16 flags;
  235. } __packed;
  236. #endif /* __MAC80211_HWSIM_H */