Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu
[linux-2.6-block.git] / drivers / net / wireless / mac80211_hwsim.h
CommitLineData
d2912cb1 1/* SPDX-License-Identifier: GPL-2.0-only */
7882513b
JL
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>
5d44fe7c 6 * Copyright (C) 2020 Intel Corporation
7882513b
JL
7 */
8
9#ifndef __MAC80211_HWSIM_H
10#define __MAC80211_HWSIM_H
11
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 */
23enum 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/**
30 * DOC: Frame transmission/registration support
31 *
32 * Frame transmission and registration support exists to allow userspace
33 * entities such as wmediumd to receive and process all broadcasted
34 * frames from a mac80211_hwsim radio device.
35 *
36 * This allow user space applications to decide if the frame should be
37 * dropped or not and implement a wireless medium simulator at user space.
38 *
39 * Registration is done by sending a register message to the driver and
40 * will be automatically unregistered if the user application doesn't
41 * responds to sent frames.
42 * Once registered the user application has to take responsibility of
43 * broadcasting the frames to all listening mac80211_hwsim radio
44 * interfaces.
45 *
46 * For more technical details, see the corresponding command descriptions
47 * below.
48 */
49
50/**
51 * enum hwsim_commands - supported hwsim commands
52 *
53 * @HWSIM_CMD_UNSPEC: unspecified command to catch errors
54 *
55 * @HWSIM_CMD_REGISTER: request to register and received all broadcasted
56 * frames by any mac80211_hwsim radio device.
57 * @HWSIM_CMD_FRAME: send/receive a broadcasted frame from/to kernel/user
03765195 58 * space, uses:
7882513b
JL
59 * %HWSIM_ATTR_ADDR_TRANSMITTER, %HWSIM_ATTR_ADDR_RECEIVER,
60 * %HWSIM_ATTR_FRAME, %HWSIM_ATTR_FLAGS, %HWSIM_ATTR_RX_RATE,
4f86ed8f 61 * %HWSIM_ATTR_SIGNAL, %HWSIM_ATTR_COOKIE, %HWSIM_ATTR_FREQ (optional)
7882513b 62 * @HWSIM_CMD_TX_INFO_FRAME: Transmission info report from user space to
03765195 63 * kernel, uses:
7882513b 64 * %HWSIM_ATTR_ADDR_TRANSMITTER, %HWSIM_ATTR_FLAGS,
6e3d6ca1
BB
65 * %HWSIM_ATTR_TX_INFO, %WSIM_ATTR_TX_INFO_FLAGS,
66 * %HWSIM_ATTR_SIGNAL, %HWSIM_ATTR_COOKIE
5940c3e4
JR
67 * @HWSIM_CMD_NEW_RADIO: create a new radio with the given parameters,
68 * returns the radio ID (>= 0) or negative on errors, if successful
cb1a5bae
BB
69 * then multicast the result, uses optional parameter:
70 * %HWSIM_ATTR_REG_STRICT_REG, %HWSIM_ATTR_SUPPORT_P2P_DEVICE,
71 * %HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE, %HWSIM_ATTR_CHANNELS,
72 * %HWSIM_ATTR_NO_VIF, %HWSIM_ATTR_RADIO_NAME, %HWSIM_ATTR_USE_CHANCTX,
73 * %HWSIM_ATTR_REG_HINT_ALPHA2, %HWSIM_ATTR_REG_CUSTOM_REG,
74 * %HWSIM_ATTR_PERM_ADDR
5940c3e4 75 * @HWSIM_CMD_DEL_RADIO: destroy a radio, reply is multicasted
93d638d4
PF
76 * @HWSIM_CMD_GET_RADIO: fetch information about existing radios, uses:
77 * %HWSIM_ATTR_RADIO_ID
7882513b
JL
78 * @__HWSIM_CMD_MAX: enum limit
79 */
80enum {
81 HWSIM_CMD_UNSPEC,
82 HWSIM_CMD_REGISTER,
83 HWSIM_CMD_FRAME,
84 HWSIM_CMD_TX_INFO_FRAME,
5940c3e4
JR
85 HWSIM_CMD_NEW_RADIO,
86 HWSIM_CMD_DEL_RADIO,
93d638d4 87 HWSIM_CMD_GET_RADIO,
7882513b
JL
88 __HWSIM_CMD_MAX,
89};
90#define HWSIM_CMD_MAX (_HWSIM_CMD_MAX - 1)
91
5940c3e4
JR
92#define HWSIM_CMD_CREATE_RADIO HWSIM_CMD_NEW_RADIO
93#define HWSIM_CMD_DESTROY_RADIO HWSIM_CMD_DEL_RADIO
94
7882513b
JL
95/**
96 * enum hwsim_attrs - hwsim netlink attributes
97 *
98 * @HWSIM_ATTR_UNSPEC: unspecified attribute to catch errors
99 *
100 * @HWSIM_ATTR_ADDR_RECEIVER: MAC address of the radio device that
101 * the frame is broadcasted to
102 * @HWSIM_ATTR_ADDR_TRANSMITTER: MAC address of the radio device that
103 * the frame was broadcasted from
104 * @HWSIM_ATTR_FRAME: Data array
105 * @HWSIM_ATTR_FLAGS: mac80211 transmission flags, used to process
106 properly the frame at user space
107 * @HWSIM_ATTR_RX_RATE: estimated rx rate index for this frame at user
108 space
109 * @HWSIM_ATTR_SIGNAL: estimated RX signal for this frame at user
110 space
111 * @HWSIM_ATTR_TX_INFO: ieee80211_tx_rate array
112 * @HWSIM_ATTR_COOKIE: sk_buff cookie to identify the frame
bc791098
JB
113 * @HWSIM_ATTR_CHANNELS: u32 attribute used with the %HWSIM_CMD_CREATE_RADIO
114 * command giving the number of channels supported by the new radio
115 * @HWSIM_ATTR_RADIO_ID: u32 attribute used with %HWSIM_CMD_DESTROY_RADIO
116 * only to destroy a radio
26b0e411
JB
117 * @HWSIM_ATTR_REG_HINT_ALPHA2: alpha2 for regulatoro driver hint
118 * (nla string, length 2)
119 * @HWSIM_ATTR_REG_CUSTOM_REG: custom regulatory domain index (u32 attribute)
120 * @HWSIM_ATTR_REG_STRICT_REG: request REGULATORY_STRICT_REG (flag attribute)
8c66a3d9 121 * @HWSIM_ATTR_SUPPORT_P2P_DEVICE: support P2P Device virtual interface (flag)
361c3e04
LC
122 * @HWSIM_ATTR_USE_CHANCTX: used with the %HWSIM_CMD_CREATE_RADIO
123 * command to force use of channel contexts even when only a
124 * single channel is supported
e9ed49bf
JR
125 * @HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE: used with the %HWSIM_CMD_CREATE_RADIO
126 * command to force radio removal when process that created the radio dies
8cdd9e1c 127 * @HWSIM_ATTR_RADIO_NAME: Name of radio, e.g. phy666
9a0cb89a 128 * @HWSIM_ATTR_NO_VIF: Do not create vif (wlanX) when creating radio.
4f86ed8f 129 * @HWSIM_ATTR_FREQ: Frequency at which packet is transmitted or received.
6e3d6ca1
BB
130 * @HWSIM_ATTR_TX_INFO_FLAGS: additional flags for corresponding
131 * rates of %HWSIM_ATTR_TX_INFO
cb1a5bae 132 * @HWSIM_ATTR_PERM_ADDR: permanent mac address of new radio
99e3a44b 133 * @HWSIM_ATTR_IFTYPE_SUPPORT: u32 attribute of supported interface types bits
c0a0189d 134 * @HWSIM_ATTR_CIPHER_SUPPORT: u32 array of supported cipher types
7882513b
JL
135 * @__HWSIM_ATTR_MAX: enum limit
136 */
137
138
139enum {
140 HWSIM_ATTR_UNSPEC,
141 HWSIM_ATTR_ADDR_RECEIVER,
142 HWSIM_ATTR_ADDR_TRANSMITTER,
143 HWSIM_ATTR_FRAME,
144 HWSIM_ATTR_FLAGS,
145 HWSIM_ATTR_RX_RATE,
146 HWSIM_ATTR_SIGNAL,
147 HWSIM_ATTR_TX_INFO,
148 HWSIM_ATTR_COOKIE,
bc791098
JB
149 HWSIM_ATTR_CHANNELS,
150 HWSIM_ATTR_RADIO_ID,
26b0e411
JB
151 HWSIM_ATTR_REG_HINT_ALPHA2,
152 HWSIM_ATTR_REG_CUSTOM_REG,
153 HWSIM_ATTR_REG_STRICT_REG,
8c66a3d9 154 HWSIM_ATTR_SUPPORT_P2P_DEVICE,
361c3e04 155 HWSIM_ATTR_USE_CHANCTX,
e9ed49bf 156 HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE,
8cdd9e1c 157 HWSIM_ATTR_RADIO_NAME,
9a0cb89a 158 HWSIM_ATTR_NO_VIF,
4f86ed8f 159 HWSIM_ATTR_FREQ,
08f4cbb8 160 HWSIM_ATTR_PAD,
6e3d6ca1 161 HWSIM_ATTR_TX_INFO_FLAGS,
cb1a5bae 162 HWSIM_ATTR_PERM_ADDR,
99e3a44b 163 HWSIM_ATTR_IFTYPE_SUPPORT,
c0a0189d 164 HWSIM_ATTR_CIPHER_SUPPORT,
7882513b
JL
165 __HWSIM_ATTR_MAX,
166};
167#define HWSIM_ATTR_MAX (__HWSIM_ATTR_MAX - 1)
168
169/**
170 * struct hwsim_tx_rate - rate selection/status
171 *
172 * @idx: rate index to attempt to send with
173 * @count: number of tries in this rate before going to the next rate
174 *
175 * A value of -1 for @idx indicates an invalid rate and, if used
176 * in an array of retry rates, that no more rates should be tried.
177 *
178 * When used for transmit status reporting, the driver should
179 * always report the rate and number of retries used.
180 *
181 */
182struct hwsim_tx_rate {
183 s8 idx;
184 u8 count;
185} __packed;
186
6e3d6ca1
BB
187/**
188 * enum hwsim_tx_rate_flags - per-rate flags set by the rate control algorithm.
189 * Inspired by structure mac80211_rate_control_flags. New flags may be
190 * appended, but old flags not deleted, to keep compatibility for
191 * userspace.
192 *
193 * These flags are set by the Rate control algorithm for each rate during tx,
194 * in the @flags member of struct ieee80211_tx_rate.
195 *
196 * @MAC80211_HWSIM_TX_RC_USE_RTS_CTS: Use RTS/CTS exchange for this rate.
197 * @MAC80211_HWSIM_TX_RC_USE_CTS_PROTECT: CTS-to-self protection is required.
198 * This is set if the current BSS requires ERP protection.
199 * @MAC80211_HWSIM_TX_RC_USE_SHORT_PREAMBLE: Use short preamble.
200 * @MAC80211_HWSIM_TX_RC_MCS: HT rate.
201 * @MAC80211_HWSIM_TX_RC_VHT_MCS: VHT MCS rate, in this case the idx field is
202 * split into a higher 4 bits (Nss) and lower 4 bits (MCS number)
203 * @MAC80211_HWSIM_TX_RC_GREEN_FIELD: Indicates whether this rate should be used
204 * in Greenfield mode.
205 * @MAC80211_HWSIM_TX_RC_40_MHZ_WIDTH: Indicates if the Channel Width should be
206 * 40 MHz.
207 * @MAC80211_HWSIM_TX_RC_80_MHZ_WIDTH: Indicates 80 MHz transmission
208 * @MAC80211_HWSIM_TX_RC_160_MHZ_WIDTH: Indicates 160 MHz transmission
209 * (80+80 isn't supported yet)
210 * @MAC80211_HWSIM_TX_RC_DUP_DATA: The frame should be transmitted on both of
211 * the adjacent 20 MHz channels, if the current channel type is
212 * NL80211_CHAN_HT40MINUS or NL80211_CHAN_HT40PLUS.
213 * @MAC80211_HWSIM_TX_RC_SHORT_GI: Short Guard interval should be used for this
214 * rate.
215 */
216enum hwsim_tx_rate_flags {
217 MAC80211_HWSIM_TX_RC_USE_RTS_CTS = BIT(0),
218 MAC80211_HWSIM_TX_RC_USE_CTS_PROTECT = BIT(1),
219 MAC80211_HWSIM_TX_RC_USE_SHORT_PREAMBLE = BIT(2),
220
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/**
233 * struct hwsim_tx_rate - rate selection/status
234 *
235 * @idx: rate index to attempt to send with
236 * @count: number of tries in this rate before going to the next rate
237 *
238 * A value of -1 for @idx indicates an invalid rate and, if used
239 * in an array of retry rates, that no more rates should be tried.
240 *
241 * When used for transmit status reporting, the driver should
242 * always report the rate and number of retries used.
243 *
244 */
245struct hwsim_tx_rate_flag {
246 s8 idx;
247 u16 flags;
248} __packed;
5d44fe7c
EG
249
250/**
251 * DOC: Frame transmission support over virtio
252 *
253 * Frame transmission is also supported over virtio to allow communication
254 * with external entities.
255 */
256
257/**
258 * enum hwsim_vqs - queues for virtio frame transmission
259 *
260 * @HWSIM_VQ_TX: send frames to external entity
261 * @HWSIM_VQ_RX: receive frames and transmission info reports
262 * @HWSIM_NUM_VQS: enum limit
263 */
264enum {
265 HWSIM_VQ_TX,
266 HWSIM_VQ_RX,
267 HWSIM_NUM_VQS,
268};
7882513b 269#endif /* __MAC80211_HWSIM_H */