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