xref: /aosp_15_r20/tools/netsim/pdl/mac80211_hwsim.pdl (revision cf78ab8cffb8fc9207af348f23af247fb04370a6)
1// PDL grammar file for mac80211_hwsim packet format.
2//
3// See
4//   - mac80211_hwsim.h
5
6
7// Host byte order
8little_endian_packets
9
10// Netlink Message Header
11
12// TODO: use include from netlink.pdl
13
14struct NlMsgHdr {
15    nlmsg_len : 32,             // Length of message including header
16    nlmsg_type : 16,            // Message type identifier
17    nlmsg_flags : 16,           // Flags (NLM_F_)
18    nlmsg_seq : 32,             // Sequence number
19    nlmsg_pid : 32,             // Sending process port ID
20}
21
22// mac80211_hwsim definitions
23
24/**
25 * enum hwsim_commands - supported hwsim commands
26 *
27 * @HWSIM_CMD_UNSPEC: unspecified command to catch errors
28 *
29 * @HWSIM_CMD_REGISTER: request to register and received all broadcasted
30 *	frames by any mac80211_hwsim radio device.
31 * @HWSIM_CMD_FRAME: send/receive a broadcasted frame from/to kernel/user
32 *	space, uses:
33 *	%HWSIM_ATTR_ADDR_TRANSMITTER,
34 *      %HWSIM_ATTR_ADDR_RECEIVER,
35 *	%HWSIM_ATTR_FRAME,
36 *      %HWSIM_ATTR_FLAGS,
37 *      %HWSIM_ATTR_RX_RATE,
38 *	%HWSIM_ATTR_SIGNAL,
39 *      %HWSIM_ATTR_COOKIE,
40 *      %HWSIM_ATTR_FREQ (optional)
41 * @HWSIM_CMD_TX_INFO_FRAME: Transmission info report from user space to
42 *	kernel, uses:
43 *	%HWSIM_ATTR_ADDR_TRANSMITTER, %HWSIM_ATTR_FLAGS,
44 *	%HWSIM_ATTR_TX_INFO, %WSIM_ATTR_TX_INFO_FLAGS,
45 *	%HWSIM_ATTR_SIGNAL, %HWSIM_ATTR_COOKIE
46 * @HWSIM_CMD_NEW_RADIO: create a new radio with the given parameters,
47 *	returns the radio ID (>= 0) or negative on errors, if successful
48 *	then multicast the result, uses optional parameter:
49 *	%HWSIM_ATTR_REG_STRICT_REG, %HWSIM_ATTR_SUPPORT_P2P_DEVICE,
50 *	%HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE, %HWSIM_ATTR_CHANNELS,
51 *	%HWSIM_ATTR_NO_VIF, %HWSIM_ATTR_RADIO_NAME, %HWSIM_ATTR_USE_CHANCTX,
52 *	%HWSIM_ATTR_REG_HINT_ALPHA2, %HWSIM_ATTR_REG_CUSTOM_REG,
53 *	%HWSIM_ATTR_PERM_ADDR
54 * @HWSIM_CMD_DEL_RADIO: destroy a radio, reply is multicasted
55 * @HWSIM_CMD_GET_RADIO: fetch information about existing radios, uses:
56 *	%HWSIM_ATTR_RADIO_ID
57 * @HWSIM_CMD_ADD_MAC_ADDR: add a receive MAC address (given in the
58 *	%HWSIM_ATTR_ADDR_RECEIVER attribute) to a device identified by
59 *	%HWSIM_ATTR_ADDR_TRANSMITTER. This lets wmediumd forward frames
60 *	to this receiver address for a given station.
61 * @HWSIM_CMD_DEL_MAC_ADDR: remove the MAC address again, the attributes
62 *	are the same as to @HWSIM_CMD_ADD_MAC_ADDR.
63 */
64
65enum HwsimCmd : 8 {
66    UNSPEC = 0,
67    REGISTER = 1,
68    FRAME = 2,
69    TX_INFO_FRAME = 3,
70    NEW_RADIO = 4,
71    DEL_RADIO = 5,
72    GET_RADIO = 6,
73    ADD_MAC_ADDR = 7,
74    DEL_MAC_ADDR = 8,
75}
76
77/**
78 * enum hwsim_attrs - hwsim netlink attributes
79 *
80 * @HWSIM_ATTR_UNSPEC: unspecified attribute to catch errors
81 *
82 * @HWSIM_ATTR_ADDR_RECEIVER: MAC address of the radio device that
83 *	the frame is broadcasted to
84 * @HWSIM_ATTR_ADDR_TRANSMITTER: MAC address of the radio device that
85 *	the frame was broadcasted from
86 * @HWSIM_ATTR_FRAME: Data array
87 * @HWSIM_ATTR_FLAGS: mac80211 transmission flags, used to process
88        properly the frame at user space
89 * @HWSIM_ATTR_RX_RATE: estimated rx rate index for this frame at user
90        space
91 * @HWSIM_ATTR_SIGNAL: estimated RX signal for this frame at user
92        space
93 * @HWSIM_ATTR_TX_INFO: ieee80211_tx_rate array
94 * @HWSIM_ATTR_COOKIE: sk_buff cookie to identify the frame
95 * @HWSIM_ATTR_CHANNELS: u32 attribute used with the %HWSIM_CMD_CREATE_RADIO
96 *	command giving the number of channels supported by the new radio
97 * @HWSIM_ATTR_RADIO_ID: u32 attribute used with %HWSIM_CMD_DESTROY_RADIO
98 *	only to destroy a radio
99 * @HWSIM_ATTR_REG_HINT_ALPHA2: alpha2 for regulatoro driver hint
100 *	(nla string, length 2)
101 * @HWSIM_ATTR_REG_CUSTOM_REG: custom regulatory domain index (u32 attribute)
102 * @HWSIM_ATTR_REG_STRICT_REG: request REGULATORY_STRICT_REG (flag attribute)
103 * @HWSIM_ATTR_SUPPORT_P2P_DEVICE: support P2P Device virtual interface (flag)
104 * @HWSIM_ATTR_USE_CHANCTX: used with the %HWSIM_CMD_CREATE_RADIO
105 *	command to force use of channel contexts even when only a
106 *	single channel is supported
107 * @HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE: used with the %HWSIM_CMD_CREATE_RADIO
108 *	command to force radio removal when process that created the radio dies
109 * @HWSIM_ATTR_RADIO_NAME: Name of radio, e.g. phy666
110 * @HWSIM_ATTR_NO_VIF:  Do not create vif (wlanX) when creating radio.
111 * @HWSIM_ATTR_FREQ: Frequency at which packet is transmitted or received.
112 * @HWSIM_ATTR_TX_INFO_FLAGS: additional flags for corresponding
113 *	rates of %HWSIM_ATTR_TX_INFO
114 * @HWSIM_ATTR_PERM_ADDR: permanent mac address of new radio
115 * @HWSIM_ATTR_IFTYPE_SUPPORT: u32 attribute of supported interface types bits
116 * @HWSIM_ATTR_CIPHER_SUPPORT: u32 array of supported cipher types
117 */
118
119enum HwsimAttrEnum : 14 {
120    UNSPEC = 0,
121    ADDR_RECEIVER = 1,
122    ADDR_TRANSMITTER = 2,
123    FRAME = 3,
124    FLAGS = 4,
125    RX_RATE = 5,
126    SIGNAL = 6,
127    TX_INFO = 7,
128    COOKIE = 8,
129    CHANNELS = 9,
130    RADIO_ID = 10,
131    REG_HINT_ALPHA2 = 11,
132    REG_CUSTOM_REG = 12,
133    REG_STRICT_REG = 13,
134    SUPPORT_P2P_DEVICE = 14,
135    USE_CHANCTX = 15,
136    DESTROY_RADIO_ON_CLOSE = 16,
137    RADIO_NAME = 17,
138    NO_VIF = 18,
139    FREQ = 19,
140    PAD = 20,
141    TX_INFO_FLAGS = 21,
142    PERM_ADDR = 22,
143    IFTYPE_SUPPORT = 23,
144    CIPHER_SUPPORT = 24,
145}
146
147// Hwsim attribute base packet.
148//
149// This is a variant of NlAttrHdr with hwsim attribute types.
150
151packet HwsimAttr {
152    _size_(_payload_): 16,      // nla_len, the attribute length
153    nla_type: HwsimAttrEnum,
154    nla_m : 1,
155    nla_o : 1,
156    _payload_: [+4],
157}
158
159// ATTR_ADDR_RECEIVER: MAC address of the radio device that the frame
160// is broadcasted to
161
162packet HwsimAttrAddrReceiver : HwsimAttr(nla_type = ADDR_RECEIVER) {
163    address : 8[6],
164}
165
166// ATTR_ADDR_TRANSMITTER: MAC address of the radio device that
167// the frame was broadcasted from
168
169packet HwsimAttrAddrTransmitter : HwsimAttr(nla_type = ADDR_TRANSMITTER) {
170    address : 8[6],
171}
172
173// ATTR_FRAME: Data array
174
175packet HwsimAttrFrame : HwsimAttr(nla_type = FRAME) {
176    data: 8[]
177}
178
179// ATTR_FLAGS
180packet HwsimAttrFlags : HwsimAttr(nla_type = FLAGS) {
181    flags : 32,
182}
183
184// ATTR_RX_RATE
185packet HwsimAttrRxRate : HwsimAttr(nla_type = RX_RATE) {
186    rx_rate_idx : 32,
187}
188
189// ATTR_SIGNAL
190packet HwsimAttrSignal : HwsimAttr(nla_type = SIGNAL) {
191    signal : 32,
192}
193
194// ATTR_FREQ
195packet HwsimAttrFreq : HwsimAttr(nla_type = FREQ) {
196    freq : 32,
197}
198
199// ATTR_COOKIE
200packet HwsimAttrCookie : HwsimAttr(nla_type = COOKIE) {
201    cookie : 64,
202}
203
204struct TxRate {
205    idx : 8,
206    count: 8,
207}
208
209// ATTR_TX_INFO
210packet HwsimAttrTxInfo : HwsimAttr(nla_type = TX_INFO) {
211    tx_rates : TxRate[],
212}
213
214enum HwsimTxRateFlags : 16 {
215    MAC80211_HWSIM_TX_RC_USE_RTS_CTS = 0x01,
216    MAC80211_HWSIM_TX_RC_USE_CTS_PROTECT = 0x02,
217    MAC80211_HWSIM_TX_RC_USE_SHORT_PREAMBLE = 0x04,
218    /* rate index is an HT/VHT MCS instead of an index */
219    MAC80211_HWSIM_TX_RC_MCS = 0x08,
220    MAC80211_HWSIM_TX_RC_GREEN_FIELD = 0x0f,
221    MAC80211_HWSIM_TX_RC_40_MHZ_WIDTH = 0x10,
222    MAC80211_HWSIM_TX_RC_DUP_DATA = 0x20,
223    MAC80211_HWSIM_TX_RC_SHORT_GI = 0x40,
224    MAC80211_HWSIM_TX_RC_VHT_MCS = 0x80,
225    MAC80211_HWSIM_TX_RC_80_MHZ_WIDTH = 0xf0,
226    MAC80211_HWSIM_TX_RC_160_MHZ_WIDTH = 0x100,
227}
228
229struct TxRateFlag {
230    idx : 8,
231    flags : 16, // HwsimTxRateFlags,
232}
233
234// ATTR_TX_INFO_FLAGS
235packet HwsimAttrTxInfoFlags : HwsimAttr(nla_type = TX_INFO_FLAGS) {
236    tx_rate_flags : TxRateFlag[],
237}
238
239struct HwsimMsgHdr {
240    hwsim_cmd : HwsimCmd,
241    hwsim_version: 8,
242    reserved: 16,
243}
244
245packet HwsimMsg {
246    nl_hdr: NlMsgHdr,
247    hwsim_hdr: HwsimMsgHdr,
248    // user header
249    attributes: 8[],
250}
251