mac80211_hwsim.h 9.0 KB

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