xref: /openbmc/linux/drivers/net/wireless/quantenna/qtnfmac/qlink.h (revision 7b73a9c8e26ce5769c41d4b787767c10fe7269db)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
3 
4 #ifndef _QTN_QLINK_H_
5 #define _QTN_QLINK_H_
6 
7 #include <linux/ieee80211.h>
8 
9 #define QLINK_PROTO_VER		15
10 
11 #define QLINK_MACID_RSVD		0xFF
12 #define QLINK_VIFID_RSVD		0xFF
13 
14 /* Common QLINK protocol messages definitions.
15  */
16 
17 /**
18  * enum qlink_msg_type - QLINK message types
19  *
20  * Used to distinguish between message types of QLINK protocol.
21  *
22  * @QLINK_MSG_TYPE_CMD: Message is carrying data of a command sent from
23  *	driver to wireless hardware.
24  * @QLINK_MSG_TYPE_CMDRSP: Message is carrying data of a response to a command.
25  *	Sent from wireless HW to driver in reply to previously issued command.
26  * @QLINK_MSG_TYPE_EVENT: Data for an event originated in wireless hardware and
27  *	sent asynchronously to driver.
28  */
29 enum qlink_msg_type {
30 	QLINK_MSG_TYPE_CMD	= 1,
31 	QLINK_MSG_TYPE_CMDRSP	= 2,
32 	QLINK_MSG_TYPE_EVENT	= 3
33 };
34 
35 /**
36  * struct qlink_msg_header - common QLINK protocol message header
37  *
38  * Portion of QLINK protocol header common for all message types.
39  *
40  * @type: Message type, one of &enum qlink_msg_type.
41  * @len: Total length of message including all headers.
42  */
43 struct qlink_msg_header {
44 	__le16 type;
45 	__le16 len;
46 } __packed;
47 
48 /* Generic definitions of data and information carried in QLINK messages
49  */
50 
51 /**
52  * enum qlink_hw_capab - device capabilities.
53  *
54  * @QLINK_HW_CAPAB_REG_UPDATE: device can update it's regulatory region.
55  * @QLINK_HW_CAPAB_STA_INACT_TIMEOUT: device implements a logic to kick-out
56  *	associated STAs due to inactivity. Inactivity timeout period is taken
57  *	from QLINK_CMD_START_AP parameters.
58  * @QLINK_HW_CAPAB_DFS_OFFLOAD: device implements DFS offload functionality
59  * @QLINK_HW_CAPAB_SCAN_RANDOM_MAC_ADDR: device supports MAC Address
60  *	Randomization in probe requests.
61  * @QLINK_HW_CAPAB_OBSS_SCAN: device can perform OBSS scanning.
62  * @QLINK_HW_CAPAB_HW_BRIDGE: device has hardware switch capabilities.
63  */
64 enum qlink_hw_capab {
65 	QLINK_HW_CAPAB_REG_UPDATE		= BIT(0),
66 	QLINK_HW_CAPAB_STA_INACT_TIMEOUT	= BIT(1),
67 	QLINK_HW_CAPAB_DFS_OFFLOAD		= BIT(2),
68 	QLINK_HW_CAPAB_SCAN_RANDOM_MAC_ADDR	= BIT(3),
69 	QLINK_HW_CAPAB_PWR_MGMT			= BIT(4),
70 	QLINK_HW_CAPAB_OBSS_SCAN		= BIT(5),
71 	QLINK_HW_CAPAB_SCAN_DWELL		= BIT(6),
72 	QLINK_HW_CAPAB_SAE			= BIT(8),
73 	QLINK_HW_CAPAB_HW_BRIDGE		= BIT(9),
74 };
75 
76 enum qlink_iface_type {
77 	QLINK_IFTYPE_AP		= 1,
78 	QLINK_IFTYPE_STATION	= 2,
79 	QLINK_IFTYPE_ADHOC	= 3,
80 	QLINK_IFTYPE_MONITOR	= 4,
81 	QLINK_IFTYPE_WDS	= 5,
82 	QLINK_IFTYPE_AP_VLAN	= 6,
83 };
84 
85 /**
86  * struct qlink_intf_info - information on virtual interface.
87  *
88  * Data describing a single virtual interface.
89  *
90  * @if_type: Mode of interface operation, one of &enum qlink_iface_type
91  * @vlanid: VLAN ID for AP_VLAN interface type
92  * @mac_addr: MAC address of virtual interface.
93  */
94 struct qlink_intf_info {
95 	__le16 if_type;
96 	__le16 vlanid;
97 	u8 mac_addr[ETH_ALEN];
98 	u8 use4addr;
99 	u8 rsvd[1];
100 } __packed;
101 
102 enum qlink_sta_flags {
103 	QLINK_STA_FLAG_INVALID		= 0,
104 	QLINK_STA_FLAG_AUTHORIZED		= BIT(0),
105 	QLINK_STA_FLAG_SHORT_PREAMBLE	= BIT(1),
106 	QLINK_STA_FLAG_WME			= BIT(2),
107 	QLINK_STA_FLAG_MFP			= BIT(3),
108 	QLINK_STA_FLAG_AUTHENTICATED		= BIT(4),
109 	QLINK_STA_FLAG_TDLS_PEER		= BIT(5),
110 	QLINK_STA_FLAG_ASSOCIATED		= BIT(6),
111 };
112 
113 enum qlink_channel_width {
114 	QLINK_CHAN_WIDTH_5 = 0,
115 	QLINK_CHAN_WIDTH_10,
116 	QLINK_CHAN_WIDTH_20_NOHT,
117 	QLINK_CHAN_WIDTH_20,
118 	QLINK_CHAN_WIDTH_40,
119 	QLINK_CHAN_WIDTH_80,
120 	QLINK_CHAN_WIDTH_80P80,
121 	QLINK_CHAN_WIDTH_160,
122 };
123 
124 /**
125  * struct qlink_channel - qlink control channel definition
126  *
127  * @hw_value: hardware-specific value for the channel
128  * @center_freq: center frequency in MHz
129  * @flags: channel flags from &enum qlink_channel_flags
130  * @band: band this channel belongs to
131  * @max_antenna_gain: maximum antenna gain in dBi
132  * @max_power: maximum transmission power (in dBm)
133  * @max_reg_power: maximum regulatory transmission power (in dBm)
134  * @dfs_state: current state of this channel.
135  *      Only relevant if radar is required on this channel.
136  * @beacon_found: helper to regulatory code to indicate when a beacon
137  *	has been found on this channel. Use regulatory_hint_found_beacon()
138  *	to enable this, this is useful only on 5 GHz band.
139  */
140 struct qlink_channel {
141 	__le16 hw_value;
142 	__le16 center_freq;
143 	__le32 flags;
144 	u8 band;
145 	u8 max_antenna_gain;
146 	u8 max_power;
147 	u8 max_reg_power;
148 	__le32 dfs_cac_ms;
149 	u8 dfs_state;
150 	u8 beacon_found;
151 	u8 rsvd[2];
152 } __packed;
153 
154 /**
155  * struct qlink_chandef - qlink channel definition
156  *
157  * @chan: primary channel definition
158  * @center_freq1: center frequency of first segment
159  * @center_freq2: center frequency of second segment (80+80 only)
160  * @width: channel width, one of @enum qlink_channel_width
161  */
162 struct qlink_chandef {
163 	struct qlink_channel chan;
164 	__le16 center_freq1;
165 	__le16 center_freq2;
166 	u8 width;
167 	u8 rsvd;
168 } __packed;
169 
170 #define QLINK_MAX_NR_CIPHER_SUITES            5
171 #define QLINK_MAX_NR_AKM_SUITES               2
172 
173 struct qlink_auth_encr {
174 	__le32 wpa_versions;
175 	__le32 cipher_group;
176 	__le32 n_ciphers_pairwise;
177 	__le32 ciphers_pairwise[QLINK_MAX_NR_CIPHER_SUITES];
178 	__le32 n_akm_suites;
179 	__le32 akm_suites[QLINK_MAX_NR_AKM_SUITES];
180 	__le16 control_port_ethertype;
181 	u8 auth_type;
182 	u8 privacy;
183 	u8 control_port;
184 	u8 control_port_no_encrypt;
185 	u8 rsvd[2];
186 } __packed;
187 
188 /**
189  * struct qlink_sta_info_state - station flags mask/value
190  *
191  * @mask: STA flags mask, bitmap of &enum qlink_sta_flags
192  * @value: STA flags values, bitmap of &enum qlink_sta_flags
193  */
194 struct qlink_sta_info_state {
195 	__le32 mask;
196 	__le32 value;
197 } __packed;
198 
199 /* QLINK Command messages related definitions
200  */
201 
202 /**
203  * enum qlink_cmd_type - list of supported commands
204  *
205  * Commands are QLINK messages of type @QLINK_MSG_TYPE_CMD, sent by driver to
206  * wireless network device for processing. Device is expected to send back a
207  * reply message of type &QLINK_MSG_TYPE_CMDRSP, containing at least command
208  * execution status (one of &enum qlink_cmd_result). Reply message
209  * may also contain data payload specific to the command type.
210  *
211  * @QLINK_CMD_SEND_FRAME: send specified frame over the air; firmware will
212  *	encapsulate 802.3 packet into 802.11 frame automatically.
213  * @QLINK_CMD_BAND_INFO_GET: for the specified MAC and specified band, get
214  *	the band's description including number of operational channels and
215  *	info on each channel, HT/VHT capabilities, supported rates etc.
216  *	This command is generic to a specified MAC, interface index must be set
217  *	to QLINK_VIFID_RSVD in command header.
218  * @QLINK_CMD_REG_NOTIFY: notify device about regulatory domain change. This
219  *	command is supported only if device reports QLINK_HW_SUPPORTS_REG_UPDATE
220  *	capability.
221  * @QLINK_CMD_START_CAC: start radar detection procedure on a specified channel.
222  * @QLINK_CMD_TXPWR: get or set current channel transmit power for
223  *	the specified MAC.
224  * @QLINK_CMD_NDEV_EVENT: signalizes changes made with a corresponding network
225  *	device.
226  */
227 enum qlink_cmd_type {
228 	QLINK_CMD_FW_INIT		= 0x0001,
229 	QLINK_CMD_FW_DEINIT		= 0x0002,
230 	QLINK_CMD_REGISTER_MGMT		= 0x0003,
231 	QLINK_CMD_SEND_FRAME		= 0x0004,
232 	QLINK_CMD_MGMT_SET_APPIE	= 0x0005,
233 	QLINK_CMD_PHY_PARAMS_GET	= 0x0011,
234 	QLINK_CMD_PHY_PARAMS_SET	= 0x0012,
235 	QLINK_CMD_GET_HW_INFO		= 0x0013,
236 	QLINK_CMD_MAC_INFO		= 0x0014,
237 	QLINK_CMD_ADD_INTF		= 0x0015,
238 	QLINK_CMD_DEL_INTF		= 0x0016,
239 	QLINK_CMD_CHANGE_INTF		= 0x0017,
240 	QLINK_CMD_UPDOWN_INTF		= 0x0018,
241 	QLINK_CMD_REG_NOTIFY		= 0x0019,
242 	QLINK_CMD_BAND_INFO_GET		= 0x001A,
243 	QLINK_CMD_CHAN_SWITCH		= 0x001B,
244 	QLINK_CMD_CHAN_GET		= 0x001C,
245 	QLINK_CMD_START_CAC		= 0x001D,
246 	QLINK_CMD_START_AP		= 0x0021,
247 	QLINK_CMD_STOP_AP		= 0x0022,
248 	QLINK_CMD_SET_MAC_ACL		= 0x0023,
249 	QLINK_CMD_GET_STA_INFO		= 0x0030,
250 	QLINK_CMD_ADD_KEY		= 0x0040,
251 	QLINK_CMD_DEL_KEY		= 0x0041,
252 	QLINK_CMD_SET_DEFAULT_KEY	= 0x0042,
253 	QLINK_CMD_SET_DEFAULT_MGMT_KEY	= 0x0043,
254 	QLINK_CMD_CHANGE_STA		= 0x0051,
255 	QLINK_CMD_DEL_STA		= 0x0052,
256 	QLINK_CMD_SCAN			= 0x0053,
257 	QLINK_CMD_CHAN_STATS		= 0x0054,
258 	QLINK_CMD_NDEV_EVENT		= 0x0055,
259 	QLINK_CMD_CONNECT		= 0x0060,
260 	QLINK_CMD_DISCONNECT		= 0x0061,
261 	QLINK_CMD_PM_SET		= 0x0062,
262 	QLINK_CMD_WOWLAN_SET		= 0x0063,
263 	QLINK_CMD_EXTERNAL_AUTH		= 0x0066,
264 	QLINK_CMD_TXPWR			= 0x0067,
265 };
266 
267 /**
268  * struct qlink_cmd - QLINK command message header
269  *
270  * Header used for QLINK messages of QLINK_MSG_TYPE_CMD type.
271  *
272  * @mhdr: Common QLINK message header.
273  * @cmd_id: command id, one of &enum qlink_cmd_type.
274  * @seq_num: sequence number of command message, used for matching with
275  *	response message.
276  * @macid: index of physical radio device the command is destined to or
277  *	QLINK_MACID_RSVD if not applicable.
278  * @vifid: index of virtual wireless interface on specified @macid the command
279  *	is destined to or QLINK_VIFID_RSVD if not applicable.
280  */
281 struct qlink_cmd {
282 	struct qlink_msg_header mhdr;
283 	__le16 cmd_id;
284 	__le16 seq_num;
285 	u8 rsvd[2];
286 	u8 macid;
287 	u8 vifid;
288 } __packed;
289 
290 /**
291  * struct qlink_cmd_manage_intf - interface management command
292  *
293  * Data for interface management commands QLINK_CMD_ADD_INTF, QLINK_CMD_DEL_INTF
294  * and QLINK_CMD_CHANGE_INTF.
295  *
296  * @intf_info: interface description.
297  */
298 struct qlink_cmd_manage_intf {
299 	struct qlink_cmd chdr;
300 	struct qlink_intf_info intf_info;
301 } __packed;
302 
303 enum qlink_mgmt_frame_type {
304 	QLINK_MGMT_FRAME_ASSOC_REQ	= 0x00,
305 	QLINK_MGMT_FRAME_ASSOC_RESP	= 0x01,
306 	QLINK_MGMT_FRAME_REASSOC_REQ	= 0x02,
307 	QLINK_MGMT_FRAME_REASSOC_RESP	= 0x03,
308 	QLINK_MGMT_FRAME_PROBE_REQ	= 0x04,
309 	QLINK_MGMT_FRAME_PROBE_RESP	= 0x05,
310 	QLINK_MGMT_FRAME_BEACON		= 0x06,
311 	QLINK_MGMT_FRAME_ATIM		= 0x07,
312 	QLINK_MGMT_FRAME_DISASSOC	= 0x08,
313 	QLINK_MGMT_FRAME_AUTH		= 0x09,
314 	QLINK_MGMT_FRAME_DEAUTH		= 0x0A,
315 	QLINK_MGMT_FRAME_ACTION		= 0x0B,
316 
317 	QLINK_MGMT_FRAME_TYPE_COUNT
318 };
319 
320 /**
321  * struct qlink_cmd_mgmt_frame_register - data for QLINK_CMD_REGISTER_MGMT
322  *
323  * @frame_type: MGMT frame type the registration request describes, one of
324  *	&enum qlink_mgmt_frame_type.
325  * @do_register: 0 - unregister, otherwise register for reception of specified
326  *	MGMT frame type.
327  */
328 struct qlink_cmd_mgmt_frame_register {
329 	struct qlink_cmd chdr;
330 	__le16 frame_type;
331 	u8 do_register;
332 } __packed;
333 
334 /**
335  * @QLINK_FRAME_TX_FLAG_8023: frame has a 802.3 header; if not set, frame
336  *	is a 802.11 encapsulated.
337  */
338 enum qlink_frame_tx_flags {
339 	QLINK_FRAME_TX_FLAG_OFFCHAN	= BIT(0),
340 	QLINK_FRAME_TX_FLAG_NO_CCK	= BIT(1),
341 	QLINK_FRAME_TX_FLAG_ACK_NOWAIT	= BIT(2),
342 	QLINK_FRAME_TX_FLAG_8023	= BIT(3),
343 };
344 
345 /**
346  * struct qlink_cmd_frame_tx - data for QLINK_CMD_SEND_FRAME command
347  *
348  * @cookie: opaque request identifier.
349  * @freq: Frequency to use for frame transmission.
350  * @flags: Transmission flags, one of &enum qlink_frame_tx_flags.
351  * @frame_data: frame to transmit.
352  */
353 struct qlink_cmd_frame_tx {
354 	struct qlink_cmd chdr;
355 	__le32 cookie;
356 	__le16 freq;
357 	__le16 flags;
358 	u8 frame_data[0];
359 } __packed;
360 
361 /**
362  * struct qlink_cmd_get_sta_info - data for QLINK_CMD_GET_STA_INFO command
363  *
364  * @sta_addr: MAC address of the STA statistics is requested for.
365  */
366 struct qlink_cmd_get_sta_info {
367 	struct qlink_cmd chdr;
368 	u8 sta_addr[ETH_ALEN];
369 } __packed;
370 
371 /**
372  * struct qlink_cmd_add_key - data for QLINK_CMD_ADD_KEY command.
373  *
374  * @key_index: index of the key being installed.
375  * @pairwise: whether to use pairwise key.
376  * @addr: MAC address of a STA key is being installed to.
377  * @cipher: cipher suite.
378  * @vlanid: VLAN ID for AP_VLAN interface type
379  * @key_data: key data itself.
380  */
381 struct qlink_cmd_add_key {
382 	struct qlink_cmd chdr;
383 	u8 key_index;
384 	u8 pairwise;
385 	u8 addr[ETH_ALEN];
386 	__le32 cipher;
387 	__le16 vlanid;
388 	u8 key_data[0];
389 } __packed;
390 
391 /**
392  * struct qlink_cmd_del_key_req - data for QLINK_CMD_DEL_KEY command
393  *
394  * @key_index: index of the key being removed.
395  * @pairwise: whether to use pairwise key.
396  * @addr: MAC address of a STA for which a key is removed.
397  */
398 struct qlink_cmd_del_key {
399 	struct qlink_cmd chdr;
400 	u8 key_index;
401 	u8 pairwise;
402 	u8 addr[ETH_ALEN];
403 } __packed;
404 
405 /**
406  * struct qlink_cmd_set_def_key - data for QLINK_CMD_SET_DEFAULT_KEY command
407  *
408  * @key_index: index of the key to be set as default one.
409  * @unicast: key is unicast.
410  * @multicast: key is multicast.
411  */
412 struct qlink_cmd_set_def_key {
413 	struct qlink_cmd chdr;
414 	u8 key_index;
415 	u8 unicast;
416 	u8 multicast;
417 } __packed;
418 
419 /**
420  * struct qlink_cmd_set_def_mgmt_key - data for QLINK_CMD_SET_DEFAULT_MGMT_KEY
421  *
422  * @key_index: index of the key to be set as default MGMT key.
423  */
424 struct qlink_cmd_set_def_mgmt_key {
425 	struct qlink_cmd chdr;
426 	u8 key_index;
427 } __packed;
428 
429 /**
430  * struct qlink_cmd_change_sta - data for QLINK_CMD_CHANGE_STA command
431  *
432  * @flag_update: STA flags to update
433  * @if_type: Mode of interface operation, one of &enum qlink_iface_type
434  * @vlanid: VLAN ID to assign to specific STA
435  * @sta_addr: address of the STA for which parameters are set.
436  */
437 struct qlink_cmd_change_sta {
438 	struct qlink_cmd chdr;
439 	struct qlink_sta_info_state flag_update;
440 	__le16 if_type;
441 	__le16 vlanid;
442 	u8 sta_addr[ETH_ALEN];
443 } __packed;
444 
445 /**
446  * struct qlink_cmd_del_sta - data for QLINK_CMD_DEL_STA command.
447  *
448  * See &struct station_del_parameters
449  */
450 struct qlink_cmd_del_sta {
451 	struct qlink_cmd chdr;
452 	__le16 reason_code;
453 	u8 subtype;
454 	u8 sta_addr[ETH_ALEN];
455 } __packed;
456 
457 enum qlink_sta_connect_flags {
458 	QLINK_STA_CONNECT_DISABLE_HT	= BIT(0),
459 	QLINK_STA_CONNECT_DISABLE_VHT	= BIT(1),
460 	QLINK_STA_CONNECT_USE_RRM	= BIT(2),
461 };
462 
463 /**
464  * struct qlink_cmd_connect - data for QLINK_CMD_CONNECT command
465  *
466  * @bssid: BSSID of the BSS to connect to.
467  * @bssid_hint: recommended AP BSSID for initial connection to the BSS or
468  *	00:00:00:00:00:00 if not specified.
469  * @prev_bssid: previous BSSID, if specified (not 00:00:00:00:00:00) indicates
470  *	a request to reassociate.
471  * @bg_scan_period: period of background scan.
472  * @flags: one of &enum qlink_sta_connect_flags.
473  * @ht_capa: HT Capabilities overrides.
474  * @ht_capa_mask: The bits of ht_capa which are to be used.
475  * @vht_capa: VHT Capability overrides
476  * @vht_capa_mask: The bits of vht_capa which are to be used.
477  * @aen: authentication information.
478  * @mfp: whether to use management frame protection.
479  * @payload: variable portion of connection request.
480  */
481 struct qlink_cmd_connect {
482 	struct qlink_cmd chdr;
483 	u8 bssid[ETH_ALEN];
484 	u8 bssid_hint[ETH_ALEN];
485 	u8 prev_bssid[ETH_ALEN];
486 	__le16 bg_scan_period;
487 	__le32 flags;
488 	struct ieee80211_ht_cap ht_capa;
489 	struct ieee80211_ht_cap ht_capa_mask;
490 	struct ieee80211_vht_cap vht_capa;
491 	struct ieee80211_vht_cap vht_capa_mask;
492 	struct qlink_auth_encr aen;
493 	u8 mfp;
494 	u8 pbss;
495 	u8 rsvd[2];
496 	u8 payload[0];
497 } __packed;
498 
499 /**
500  * struct qlink_cmd_external_auth - data for QLINK_CMD_EXTERNAL_AUTH command
501  *
502  * @bssid: BSSID of the BSS to connect to
503  * @status: authentication status code
504  * @payload: variable portion of connection request.
505  */
506 struct qlink_cmd_external_auth {
507 	struct qlink_cmd chdr;
508 	u8 bssid[ETH_ALEN];
509 	__le16 status;
510 	u8 payload[0];
511 } __packed;
512 
513 /**
514  * struct qlink_cmd_disconnect - data for QLINK_CMD_DISCONNECT command
515  *
516  * @reason: code of the reason of disconnect, see &enum ieee80211_reasoncode.
517  */
518 struct qlink_cmd_disconnect {
519 	struct qlink_cmd chdr;
520 	__le16 reason;
521 } __packed;
522 
523 /**
524  * struct qlink_cmd_updown - data for QLINK_CMD_UPDOWN_INTF command
525  *
526  * @if_up: bring specified interface DOWN (if_up==0) or UP (otherwise).
527  *	Interface is specified in common command header @chdr.
528  */
529 struct qlink_cmd_updown {
530 	struct qlink_cmd chdr;
531 	u8 if_up;
532 } __packed;
533 
534 /**
535  * enum qlink_band - a list of frequency bands
536  *
537  * @QLINK_BAND_2GHZ: 2.4GHz band
538  * @QLINK_BAND_5GHZ: 5GHz band
539  * @QLINK_BAND_60GHZ: 60GHz band
540  */
541 enum qlink_band {
542 	QLINK_BAND_2GHZ = BIT(0),
543 	QLINK_BAND_5GHZ = BIT(1),
544 	QLINK_BAND_60GHZ = BIT(2),
545 };
546 
547 /**
548  * struct qlink_cmd_band_info_get - data for QLINK_CMD_BAND_INFO_GET command
549  *
550  * @band: a PHY band for which information is queried, one of @enum qlink_band
551  */
552 struct qlink_cmd_band_info_get {
553 	struct qlink_cmd chdr;
554 	u8 band;
555 } __packed;
556 
557 /**
558  * struct qlink_cmd_get_chan_stats - data for QLINK_CMD_CHAN_STATS command
559  *
560  * @channel: channel number according to 802.11 17.3.8.3.2 and Annex J
561  */
562 struct qlink_cmd_get_chan_stats {
563 	struct qlink_cmd chdr;
564 	__le16 channel;
565 } __packed;
566 
567 /**
568  * enum qlink_reg_initiator - Indicates the initiator of a reg domain request
569  *
570  * See &enum nl80211_reg_initiator for more info.
571  */
572 enum qlink_reg_initiator {
573 	QLINK_REGDOM_SET_BY_CORE,
574 	QLINK_REGDOM_SET_BY_USER,
575 	QLINK_REGDOM_SET_BY_DRIVER,
576 	QLINK_REGDOM_SET_BY_COUNTRY_IE,
577 };
578 
579 /**
580  * enum qlink_user_reg_hint_type - type of user regulatory hint
581  *
582  * See &enum nl80211_user_reg_hint_type for more info.
583  */
584 enum qlink_user_reg_hint_type {
585 	QLINK_USER_REG_HINT_USER	= 0,
586 	QLINK_USER_REG_HINT_CELL_BASE	= 1,
587 	QLINK_USER_REG_HINT_INDOOR	= 2,
588 };
589 
590 /**
591  * struct qlink_cmd_reg_notify - data for QLINK_CMD_REG_NOTIFY command
592  *
593  * @alpha2: the ISO / IEC 3166 alpha2 country code.
594  * @initiator: which entity sent the request, one of &enum qlink_reg_initiator.
595  * @user_reg_hint_type: type of hint for QLINK_REGDOM_SET_BY_USER request, one
596  *	of &enum qlink_user_reg_hint_type.
597  * @num_channels: number of &struct qlink_tlv_channel in a variable portion of a
598  *	payload.
599  * @slave_radar: whether slave device should enable radar detection.
600  * @dfs_region: one of &enum qlink_dfs_regions.
601  * @info: variable portion of regulatory notifier callback.
602  */
603 struct qlink_cmd_reg_notify {
604 	struct qlink_cmd chdr;
605 	u8 alpha2[2];
606 	u8 initiator;
607 	u8 user_reg_hint_type;
608 	u8 num_channels;
609 	u8 dfs_region;
610 	u8 slave_radar;
611 	u8 rsvd[1];
612 	u8 info[0];
613 } __packed;
614 
615 /**
616  * struct qlink_cmd_chan_switch - data for QLINK_CMD_CHAN_SWITCH command
617  *
618  * @channel: channel number according to 802.11 17.3.8.3.2 and Annex J
619  * @radar_required: whether radar detection is required on the new channel
620  * @block_tx: whether transmissions should be blocked while changing
621  * @beacon_count: number of beacons until switch
622  */
623 struct qlink_cmd_chan_switch {
624 	struct qlink_cmd chdr;
625 	__le16 channel;
626 	u8 radar_required;
627 	u8 block_tx;
628 	u8 beacon_count;
629 } __packed;
630 
631 /**
632  * enum qlink_hidden_ssid - values for %NL80211_ATTR_HIDDEN_SSID
633  *
634  * Refer to &enum nl80211_hidden_ssid
635  */
636 enum qlink_hidden_ssid {
637 	QLINK_HIDDEN_SSID_NOT_IN_USE,
638 	QLINK_HIDDEN_SSID_ZERO_LEN,
639 	QLINK_HIDDEN_SSID_ZERO_CONTENTS
640 };
641 
642 /**
643  * struct qlink_cmd_start_ap - data for QLINK_CMD_START_AP command
644  *
645  * @beacon_interval: beacon interval
646  * @inactivity_timeout: station's inactivity period in seconds
647  * @dtim_period: DTIM period
648  * @hidden_ssid: whether to hide the SSID, one of &enum qlink_hidden_ssid
649  * @smps_mode: SMPS mode
650  * @ht_required: stations must support HT
651  * @vht_required: stations must support VHT
652  * @aen: encryption info
653  * @info: variable configurations
654  */
655 struct qlink_cmd_start_ap {
656 	struct qlink_cmd chdr;
657 	__le16 beacon_interval;
658 	__le16 inactivity_timeout;
659 	u8 dtim_period;
660 	u8 hidden_ssid;
661 	u8 smps_mode;
662 	u8 p2p_ctwindow;
663 	u8 p2p_opp_ps;
664 	u8 pbss;
665 	u8 ht_required;
666 	u8 vht_required;
667 	struct qlink_auth_encr aen;
668 	u8 info[0];
669 } __packed;
670 
671 /**
672  * struct qlink_cmd_start_cac - data for QLINK_CMD_START_CAC command
673  *
674  * @chan: a channel to start a radar detection procedure on.
675  * @cac_time_ms: CAC time.
676  */
677 struct qlink_cmd_start_cac {
678 	struct qlink_cmd chdr;
679 	struct qlink_chandef chan;
680 	__le32 cac_time_ms;
681 } __packed;
682 
683 enum qlink_acl_policy {
684 	QLINK_ACL_POLICY_ACCEPT_UNLESS_LISTED,
685 	QLINK_ACL_POLICY_DENY_UNLESS_LISTED,
686 };
687 
688 struct qlink_mac_address {
689 	u8 addr[ETH_ALEN];
690 } __packed;
691 
692 /**
693  * struct qlink_acl_data - ACL data
694  *
695  * @policy: filter policy, one of &enum qlink_acl_policy.
696  * @num_entries: number of MAC addresses in array.
697  * @mac_address: MAC addresses array.
698  */
699 struct qlink_acl_data {
700 	__le32 policy;
701 	__le32 num_entries;
702 	struct qlink_mac_address mac_addrs[0];
703 } __packed;
704 
705 /**
706  * enum qlink_pm_mode - Power Management mode
707  *
708  * @QLINK_PM_OFF: normal mode, no power saving enabled
709  * @QLINK_PM_AUTO_STANDBY: enable auto power save mode
710  */
711 enum qlink_pm_mode {
712 	QLINK_PM_OFF		= 0,
713 	QLINK_PM_AUTO_STANDBY	= 1,
714 };
715 
716 /**
717  * struct qlink_cmd_pm_set - data for QLINK_CMD_PM_SET command
718  *
719  * @pm_standby timer: period of network inactivity in seconds before
720  *	putting a radio in power save mode
721  * @pm_mode: power management mode
722  */
723 struct qlink_cmd_pm_set {
724 	struct qlink_cmd chdr;
725 	__le32 pm_standby_timer;
726 	u8 pm_mode;
727 } __packed;
728 
729 /**
730  * enum qlink_txpwr_op - transmit power operation type
731  * @QLINK_TXPWR_SET: set tx power
732  * @QLINK_TXPWR_GET: get current tx power setting
733  */
734 enum qlink_txpwr_op {
735 	QLINK_TXPWR_SET,
736 	QLINK_TXPWR_GET
737 };
738 
739 /**
740  * struct qlink_cmd_txpwr - get or set current transmit power
741  *
742  * @txpwr: new transmit power setting, in mBm
743  * @txpwr_setting: transmit power setting type, one of
744  *	&enum nl80211_tx_power_setting
745  * @op_type: type of operation, one of &enum qlink_txpwr_op
746  */
747 struct qlink_cmd_txpwr {
748 	struct qlink_cmd chdr;
749 	__le32 txpwr;
750 	u8 txpwr_setting;
751 	u8 op_type;
752 	u8 rsvd[2];
753 } __packed;
754 
755 /**
756  * enum qlink_wowlan_trigger
757  *
758  * @QLINK_WOWLAN_TRIG_DISCONNECT: wakeup on disconnect
759  * @QLINK_WOWLAN_TRIG_MAGIC_PKT: wakeup on magic packet
760  * @QLINK_WOWLAN_TRIG_PATTERN_PKT: wakeup on user-defined packet
761  */
762 enum qlink_wowlan_trigger {
763 	QLINK_WOWLAN_TRIG_DISCONNECT	= BIT(0),
764 	QLINK_WOWLAN_TRIG_MAGIC_PKT	= BIT(1),
765 	QLINK_WOWLAN_TRIG_PATTERN_PKT	= BIT(2),
766 };
767 
768 /**
769  * struct qlink_cmd_wowlan_set - data for QLINK_CMD_WOWLAN_SET command
770  *
771  * @triggers: requested bitmask of WoWLAN triggers
772  */
773 struct qlink_cmd_wowlan_set {
774 	struct qlink_cmd chdr;
775 	__le32 triggers;
776 	u8 data[0];
777 } __packed;
778 
779 enum qlink_ndev_event_type {
780 	QLINK_NDEV_EVENT_CHANGEUPPER,
781 };
782 
783 /**
784  * struct qlink_cmd_ndev_event - data for QLINK_CMD_NDEV_EVENT command
785  *
786  * @event: type of event, one of &enum qlink_ndev_event_type
787  */
788 struct qlink_cmd_ndev_event {
789 	struct qlink_cmd chdr;
790 	__le16 event;
791 	u8 rsvd[2];
792 } __packed;
793 
794 enum qlink_ndev_upper_type {
795 	QLINK_NDEV_UPPER_TYPE_NONE,
796 	QLINK_NDEV_UPPER_TYPE_BRIDGE,
797 };
798 
799 /**
800  * struct qlink_cmd_ndev_changeupper - data for QLINK_NDEV_EVENT_CHANGEUPPER
801  *
802  * @br_domain: layer 2 broadcast domain ID that ndev is a member of
803  * @upper_type: type of upper device, one of &enum qlink_ndev_upper_type
804  */
805 struct qlink_cmd_ndev_changeupper {
806 	struct qlink_cmd_ndev_event nehdr;
807 	__le64 flags;
808 	__le32 br_domain;
809 	__le32 netspace_id;
810 	__le16 vlanid;
811 	u8 upper_type;
812 	u8 rsvd[1];
813 } __packed;
814 
815 /* QLINK Command Responses messages related definitions
816  */
817 
818 enum qlink_cmd_result {
819 	QLINK_CMD_RESULT_OK = 0,
820 	QLINK_CMD_RESULT_INVALID,
821 	QLINK_CMD_RESULT_ENOTSUPP,
822 	QLINK_CMD_RESULT_ENOTFOUND,
823 	QLINK_CMD_RESULT_EALREADY,
824 	QLINK_CMD_RESULT_EADDRINUSE,
825 	QLINK_CMD_RESULT_EADDRNOTAVAIL,
826 	QLINK_CMD_RESULT_EBUSY,
827 };
828 
829 /**
830  * struct qlink_resp - QLINK command response message header
831  *
832  * Header used for QLINK messages of QLINK_MSG_TYPE_CMDRSP type.
833  *
834  * @mhdr: see &struct qlink_msg_header.
835  * @cmd_id: command ID the response corresponds to, one of &enum qlink_cmd_type.
836  * @seq_num: sequence number of command message, used for matching with
837  *	response message.
838  * @result: result of the command execution, one of &enum qlink_cmd_result.
839  * @macid: index of physical radio device the response is sent from or
840  *	QLINK_MACID_RSVD if not applicable.
841  * @vifid: index of virtual wireless interface on specified @macid the response
842  *	is sent from or QLINK_VIFID_RSVD if not applicable.
843  */
844 struct qlink_resp {
845 	struct qlink_msg_header mhdr;
846 	__le16 cmd_id;
847 	__le16 seq_num;
848 	__le16 result;
849 	u8 macid;
850 	u8 vifid;
851 } __packed;
852 
853 /**
854  * enum qlink_dfs_regions - regulatory DFS regions
855  *
856  * Corresponds to &enum nl80211_dfs_regions.
857  */
858 enum qlink_dfs_regions {
859 	QLINK_DFS_UNSET	= 0,
860 	QLINK_DFS_FCC	= 1,
861 	QLINK_DFS_ETSI	= 2,
862 	QLINK_DFS_JP	= 3,
863 };
864 
865 /**
866  * struct qlink_resp_get_mac_info - response for QLINK_CMD_MAC_INFO command
867  *
868  * Data describing specific physical device providing wireless MAC
869  * functionality.
870  *
871  * @dev_mac: MAC address of physical WMAC device (used for first BSS on
872  *	specified WMAC).
873  * @num_tx_chain: Number of transmit chains used by WMAC.
874  * @num_rx_chain: Number of receive chains used by WMAC.
875  * @vht_cap_mod_mask: mask specifying which VHT capabilities can be altered.
876  * @ht_cap_mod_mask: mask specifying which HT capabilities can be altered.
877  * @bands_cap: wireless bands WMAC can operate in, bitmap of &enum qlink_band.
878  * @max_ap_assoc_sta: Maximum number of associations supported by WMAC.
879  * @radar_detect_widths: bitmask of channels BW for which WMAC can detect radar.
880  * @alpha2: country code ID firmware is configured to.
881  * @n_reg_rules: number of regulatory rules TLVs in variable portion of the
882  *	message.
883  * @dfs_region: regulatory DFS region, one of &enum qlink_dfs_regions.
884  * @var_info: variable-length WMAC info data.
885  */
886 struct qlink_resp_get_mac_info {
887 	struct qlink_resp rhdr;
888 	u8 dev_mac[ETH_ALEN];
889 	u8 num_tx_chain;
890 	u8 num_rx_chain;
891 	struct ieee80211_vht_cap vht_cap_mod_mask;
892 	struct ieee80211_ht_cap ht_cap_mod_mask;
893 	__le16 max_ap_assoc_sta;
894 	__le16 radar_detect_widths;
895 	__le32 max_acl_mac_addrs;
896 	u8 bands_cap;
897 	u8 alpha2[2];
898 	u8 n_reg_rules;
899 	u8 dfs_region;
900 	u8 rsvd[1];
901 	u8 var_info[0];
902 } __packed;
903 
904 /**
905  * struct qlink_resp_get_hw_info - response for QLINK_CMD_GET_HW_INFO command
906  *
907  * Description of wireless hardware capabilities and features.
908  *
909  * @fw_ver: wireless hardware firmware version.
910  * @hw_capab: Bitmap of capabilities supported by firmware.
911  * @ql_proto_ver: Version of QLINK protocol used by firmware.
912  * @num_mac: Number of separate physical radio devices provided by hardware.
913  * @mac_bitmap: Bitmap of MAC IDs that are active and can be used in firmware.
914  * @total_tx_chains: total number of transmit chains used by device.
915  * @total_rx_chains: total number of receive chains.
916  * @info: variable-length HW info.
917  */
918 struct qlink_resp_get_hw_info {
919 	struct qlink_resp rhdr;
920 	__le32 fw_ver;
921 	__le32 hw_capab;
922 	__le32 bld_tmstamp;
923 	__le32 plat_id;
924 	__le32 hw_ver;
925 	__le16 ql_proto_ver;
926 	u8 num_mac;
927 	u8 mac_bitmap;
928 	u8 total_tx_chain;
929 	u8 total_rx_chain;
930 	u8 info[0];
931 } __packed;
932 
933 /**
934  * struct qlink_resp_manage_intf - response for interface management commands
935  *
936  * Response data for QLINK_CMD_ADD_INTF and QLINK_CMD_CHANGE_INTF commands.
937  *
938  * @rhdr: Common Command Response message header.
939  * @intf_info: interface description.
940  */
941 struct qlink_resp_manage_intf {
942 	struct qlink_resp rhdr;
943 	struct qlink_intf_info intf_info;
944 } __packed;
945 
946 enum qlink_sta_info_rate_flags {
947 	QLINK_STA_INFO_RATE_FLAG_HT_MCS		= BIT(0),
948 	QLINK_STA_INFO_RATE_FLAG_VHT_MCS	= BIT(1),
949 	QLINK_STA_INFO_RATE_FLAG_SHORT_GI	= BIT(2),
950 	QLINK_STA_INFO_RATE_FLAG_60G		= BIT(3),
951 };
952 
953 /**
954  * struct qlink_resp_get_sta_info - response for QLINK_CMD_GET_STA_INFO command
955  *
956  * Response data containing statistics for specified STA.
957  *
958  * @filled: a bitmask of &enum qlink_sta_info, specifies which info in response
959  *	is valid.
960  * @sta_addr: MAC address of STA the response carries statistic for.
961  * @info: variable statistics for specified STA.
962  */
963 struct qlink_resp_get_sta_info {
964 	struct qlink_resp rhdr;
965 	u8 sta_addr[ETH_ALEN];
966 	u8 rsvd[2];
967 	u8 info[0];
968 } __packed;
969 
970 /**
971  * struct qlink_resp_band_info_get - response for QLINK_CMD_BAND_INFO_GET cmd
972  *
973  * @band: frequency band that the response describes, one of @enum qlink_band.
974  * @num_chans: total number of channels info TLVs contained in reply.
975  * @num_bitrates: total number of bitrate TLVs contained in reply.
976  * @info: variable-length info portion.
977  */
978 struct qlink_resp_band_info_get {
979 	struct qlink_resp rhdr;
980 	u8 band;
981 	u8 num_chans;
982 	u8 num_bitrates;
983 	u8 rsvd[1];
984 	u8 info[0];
985 } __packed;
986 
987 /**
988  * struct qlink_resp_phy_params - response for QLINK_CMD_PHY_PARAMS_GET command
989  *
990  * @info: variable-length array of PHY params.
991  */
992 struct qlink_resp_phy_params {
993 	struct qlink_resp rhdr;
994 	u8 info[0];
995 } __packed;
996 
997 /**
998  * struct qlink_resp_get_chan_stats - response for QLINK_CMD_CHAN_STATS cmd
999  *
1000  * @info: variable-length channel info.
1001  */
1002 struct qlink_resp_get_chan_stats {
1003 	struct qlink_cmd rhdr;
1004 	u8 info[0];
1005 } __packed;
1006 
1007 /**
1008  * struct qlink_resp_channel_get - response for QLINK_CMD_CHAN_GET command
1009  *
1010  * @chan: definition of current operating channel.
1011  */
1012 struct qlink_resp_channel_get {
1013 	struct qlink_resp rhdr;
1014 	struct qlink_chandef chan;
1015 } __packed;
1016 
1017 /**
1018  * struct qlink_resp_txpwr - response for QLINK_CMD_TXPWR command
1019  *
1020  * This response is intended for QLINK_TXPWR_GET operation and does not
1021  * contain any meaningful information in case of QLINK_TXPWR_SET operation.
1022  *
1023  * @txpwr: current transmit power setting, in mBm
1024  */
1025 struct qlink_resp_txpwr {
1026 	struct qlink_resp rhdr;
1027 	__le32 txpwr;
1028 } __packed;
1029 
1030 /* QLINK Events messages related definitions
1031  */
1032 
1033 enum qlink_event_type {
1034 	QLINK_EVENT_STA_ASSOCIATED	= 0x0021,
1035 	QLINK_EVENT_STA_DEAUTH		= 0x0022,
1036 	QLINK_EVENT_MGMT_RECEIVED	= 0x0023,
1037 	QLINK_EVENT_SCAN_RESULTS	= 0x0024,
1038 	QLINK_EVENT_SCAN_COMPLETE	= 0x0025,
1039 	QLINK_EVENT_BSS_JOIN		= 0x0026,
1040 	QLINK_EVENT_BSS_LEAVE		= 0x0027,
1041 	QLINK_EVENT_FREQ_CHANGE		= 0x0028,
1042 	QLINK_EVENT_RADAR		= 0x0029,
1043 	QLINK_EVENT_EXTERNAL_AUTH	= 0x0030,
1044 	QLINK_EVENT_MIC_FAILURE		= 0x0031,
1045 };
1046 
1047 /**
1048  * struct qlink_event - QLINK event message header
1049  *
1050  * Header used for QLINK messages of QLINK_MSG_TYPE_EVENT type.
1051  *
1052  * @mhdr: Common QLINK message header.
1053  * @event_id: Specifies specific event ID, one of &enum qlink_event_type.
1054  * @macid: index of physical radio device the event was generated on or
1055  *	QLINK_MACID_RSVD if not applicable.
1056  * @vifid: index of virtual wireless interface on specified @macid the event
1057  *	was generated on or QLINK_VIFID_RSVD if not applicable.
1058  */
1059 struct qlink_event {
1060 	struct qlink_msg_header mhdr;
1061 	__le16 event_id;
1062 	u8 macid;
1063 	u8 vifid;
1064 } __packed;
1065 
1066 /**
1067  * struct qlink_event_sta_assoc - data for QLINK_EVENT_STA_ASSOCIATED event
1068  *
1069  * @sta_addr: Address of a STA for which new association event was generated
1070  * @frame_control: control bits from 802.11 ASSOC_REQUEST header.
1071  * @payload: IEs from association request.
1072  */
1073 struct qlink_event_sta_assoc {
1074 	struct qlink_event ehdr;
1075 	u8 sta_addr[ETH_ALEN];
1076 	__le16 frame_control;
1077 	u8 ies[0];
1078 } __packed;
1079 
1080 /**
1081  * struct qlink_event_sta_deauth - data for QLINK_EVENT_STA_DEAUTH event
1082  *
1083  * @sta_addr: Address of a deauthenticated STA.
1084  * @reason: reason for deauthentication.
1085  */
1086 struct qlink_event_sta_deauth {
1087 	struct qlink_event ehdr;
1088 	u8 sta_addr[ETH_ALEN];
1089 	__le16 reason;
1090 } __packed;
1091 
1092 /**
1093  * struct qlink_event_bss_join - data for QLINK_EVENT_BSS_JOIN event
1094  *
1095  * @chan: new operating channel definition
1096  * @bssid: BSSID of a BSS which interface tried to joined.
1097  * @status: status of joining attempt, see &enum ieee80211_statuscode.
1098  */
1099 struct qlink_event_bss_join {
1100 	struct qlink_event ehdr;
1101 	struct qlink_chandef chan;
1102 	u8 bssid[ETH_ALEN];
1103 	__le16 status;
1104 	u8 ies[0];
1105 } __packed;
1106 
1107 /**
1108  * struct qlink_event_bss_leave - data for QLINK_EVENT_BSS_LEAVE event
1109  *
1110  * @reason: reason of disconnecting from BSS.
1111  */
1112 struct qlink_event_bss_leave {
1113 	struct qlink_event ehdr;
1114 	__le16 reason;
1115 } __packed;
1116 
1117 /**
1118  * struct qlink_event_freq_change - data for QLINK_EVENT_FREQ_CHANGE event
1119  *
1120  * @chan: new operating channel definition
1121  */
1122 struct qlink_event_freq_change {
1123 	struct qlink_event ehdr;
1124 	struct qlink_chandef chan;
1125 } __packed;
1126 
1127 enum qlink_rxmgmt_flags {
1128 	QLINK_RXMGMT_FLAG_ANSWERED = 1 << 0,
1129 };
1130 
1131 /**
1132  * struct qlink_event_rxmgmt - data for QLINK_EVENT_MGMT_RECEIVED event
1133  *
1134  * @freq: Frequency on which the frame was received in MHz.
1135  * @flags: bitmap of &enum qlink_rxmgmt_flags.
1136  * @sig_dbm: signal strength in dBm.
1137  * @frame_data: data of Rx'd frame itself.
1138  */
1139 struct qlink_event_rxmgmt {
1140 	struct qlink_event ehdr;
1141 	__le32 freq;
1142 	__le32 flags;
1143 	s8 sig_dbm;
1144 	u8 rsvd[3];
1145 	u8 frame_data[0];
1146 } __packed;
1147 
1148 /**
1149  * struct qlink_event_scan_result - data for QLINK_EVENT_SCAN_RESULTS event
1150  *
1151  * @tsf: TSF timestamp indicating when scan results were generated.
1152  * @freq: Center frequency of the channel where BSS for which the scan result
1153  *	event was generated was discovered.
1154  * @capab: capabilities field.
1155  * @bintval: beacon interval announced by discovered BSS.
1156  * @sig_dbm: signal strength in dBm.
1157  * @bssid: BSSID announced by discovered BSS.
1158  * @ssid_len: length of SSID announced by BSS.
1159  * @ssid: SSID announced by discovered BSS.
1160  * @payload: IEs that are announced by discovered BSS in its MGMt frames.
1161  */
1162 struct qlink_event_scan_result {
1163 	struct qlink_event ehdr;
1164 	__le64 tsf;
1165 	__le16 freq;
1166 	__le16 capab;
1167 	__le16 bintval;
1168 	s8 sig_dbm;
1169 	u8 ssid_len;
1170 	u8 ssid[IEEE80211_MAX_SSID_LEN];
1171 	u8 bssid[ETH_ALEN];
1172 	u8 rsvd[2];
1173 	u8 payload[0];
1174 } __packed;
1175 
1176 /**
1177  * enum qlink_scan_complete_flags - indicates result of scan request.
1178  *
1179  * @QLINK_SCAN_NONE: Scan request was processed.
1180  * @QLINK_SCAN_ABORTED: Scan was aborted.
1181  */
1182 enum qlink_scan_complete_flags {
1183 	QLINK_SCAN_NONE		= 0,
1184 	QLINK_SCAN_ABORTED	= BIT(0),
1185 };
1186 
1187 /**
1188  * struct qlink_event_scan_complete - data for QLINK_EVENT_SCAN_COMPLETE event
1189  *
1190  * @flags: flags indicating the status of pending scan request,
1191  *	see &enum qlink_scan_complete_flags.
1192  */
1193 struct qlink_event_scan_complete {
1194 	struct qlink_event ehdr;
1195 	__le32 flags;
1196 } __packed;
1197 
1198 enum qlink_radar_event {
1199 	QLINK_RADAR_DETECTED,
1200 	QLINK_RADAR_CAC_FINISHED,
1201 	QLINK_RADAR_CAC_ABORTED,
1202 	QLINK_RADAR_NOP_FINISHED,
1203 	QLINK_RADAR_PRE_CAC_EXPIRED,
1204 	QLINK_RADAR_CAC_STARTED,
1205 };
1206 
1207 /**
1208  * struct qlink_event_radar - data for QLINK_EVENT_RADAR event
1209  *
1210  * @chan: channel on which radar event happened.
1211  * @event: radar event type, one of &enum qlink_radar_event.
1212  */
1213 struct qlink_event_radar {
1214 	struct qlink_event ehdr;
1215 	struct qlink_chandef chan;
1216 	u8 event;
1217 	u8 rsvd[3];
1218 } __packed;
1219 
1220 /**
1221  * struct qlink_event_external_auth - data for QLINK_EVENT_EXTERNAL_AUTH event
1222  *
1223  * @ssid: SSID announced by BSS
1224  * @ssid_len: SSID length
1225  * @bssid: BSSID of the BSS to connect to
1226  * @akm_suite: AKM suite for external authentication
1227  * @action: action type/trigger for external authentication
1228  */
1229 struct qlink_event_external_auth {
1230 	struct qlink_event ehdr;
1231 	u8 ssid[IEEE80211_MAX_SSID_LEN];
1232 	u8 ssid_len;
1233 	u8 bssid[ETH_ALEN];
1234 	__le32 akm_suite;
1235 	u8 action;
1236 } __packed;
1237 
1238 /**
1239  * struct qlink_event_mic_failure - data for QLINK_EVENT_MIC_FAILURE event
1240  *
1241  * @src: source MAC address of the frame
1242  * @key_index: index of the key being reported
1243  * @pairwise: whether the key is pairwise or group
1244  */
1245 struct qlink_event_mic_failure {
1246 	struct qlink_event ehdr;
1247 	u8 src[ETH_ALEN];
1248 	u8 key_index;
1249 	u8 pairwise;
1250 } __packed;
1251 
1252 /* QLINK TLVs (Type-Length Values) definitions
1253  */
1254 
1255 /**
1256  * enum qlink_tlv_id - list of TLVs that Qlink messages can carry
1257  *
1258  * @QTN_TLV_ID_STA_STATS_MAP: a bitmap of &enum qlink_sta_info, used to
1259  *	indicate which statistic carried in QTN_TLV_ID_STA_STATS is valid.
1260  * @QTN_TLV_ID_STA_STATS: per-STA statistics as defined by
1261  *	&struct qlink_sta_stats. Valid values are marked as such in a bitmap
1262  *	carried by QTN_TLV_ID_STA_STATS_MAP.
1263  * @QTN_TLV_ID_MAX_SCAN_SSIDS: maximum number of SSIDs the device can scan
1264  *	for in any given scan.
1265  * @QTN_TLV_ID_SCAN_DWELL_ACTIVE: time spent on a single channel for an active
1266  *	scan.
1267  * @QTN_TLV_ID_SCAN_DWELL_PASSIVE: time spent on a single channel for a passive
1268  *	scan.
1269  * @QTN_TLV_ID_SCAN_SAMPLE_DURATION: total duration of sampling a single channel
1270  *	during a scan including off-channel dwell time and operating channel
1271  *	time.
1272  * @QTN_TLV_ID_IFTYPE_DATA: supported band data.
1273  */
1274 enum qlink_tlv_id {
1275 	QTN_TLV_ID_FRAG_THRESH		= 0x0201,
1276 	QTN_TLV_ID_RTS_THRESH		= 0x0202,
1277 	QTN_TLV_ID_SRETRY_LIMIT		= 0x0203,
1278 	QTN_TLV_ID_LRETRY_LIMIT		= 0x0204,
1279 	QTN_TLV_ID_REG_RULE		= 0x0207,
1280 	QTN_TLV_ID_CHANNEL		= 0x020F,
1281 	QTN_TLV_ID_CHANDEF		= 0x0210,
1282 	QTN_TLV_ID_STA_STATS_MAP	= 0x0211,
1283 	QTN_TLV_ID_STA_STATS		= 0x0212,
1284 	QTN_TLV_ID_COVERAGE_CLASS	= 0x0213,
1285 	QTN_TLV_ID_IFACE_LIMIT		= 0x0214,
1286 	QTN_TLV_ID_NUM_IFACE_COMB	= 0x0215,
1287 	QTN_TLV_ID_CHANNEL_STATS	= 0x0216,
1288 	QTN_TLV_ID_KEY			= 0x0302,
1289 	QTN_TLV_ID_SEQ			= 0x0303,
1290 	QTN_TLV_ID_IE_SET		= 0x0305,
1291 	QTN_TLV_ID_EXT_CAPABILITY_MASK	= 0x0306,
1292 	QTN_TLV_ID_ACL_DATA		= 0x0307,
1293 	QTN_TLV_ID_BUILD_NAME		= 0x0401,
1294 	QTN_TLV_ID_BUILD_REV		= 0x0402,
1295 	QTN_TLV_ID_BUILD_TYPE		= 0x0403,
1296 	QTN_TLV_ID_BUILD_LABEL		= 0x0404,
1297 	QTN_TLV_ID_HW_ID		= 0x0405,
1298 	QTN_TLV_ID_CALIBRATION_VER	= 0x0406,
1299 	QTN_TLV_ID_UBOOT_VER		= 0x0407,
1300 	QTN_TLV_ID_RANDOM_MAC_ADDR	= 0x0408,
1301 	QTN_TLV_ID_MAX_SCAN_SSIDS	= 0x0409,
1302 	QTN_TLV_ID_WOWLAN_CAPAB		= 0x0410,
1303 	QTN_TLV_ID_WOWLAN_PATTERN	= 0x0411,
1304 	QTN_TLV_ID_SCAN_FLUSH		= 0x0412,
1305 	QTN_TLV_ID_SCAN_DWELL_ACTIVE	= 0x0413,
1306 	QTN_TLV_ID_SCAN_DWELL_PASSIVE	= 0x0416,
1307 	QTN_TLV_ID_SCAN_SAMPLE_DURATION	= 0x0417,
1308 	QTN_TLV_ID_IFTYPE_DATA		= 0x0418,
1309 };
1310 
1311 struct qlink_tlv_hdr {
1312 	__le16 type;
1313 	__le16 len;
1314 	u8 val[0];
1315 } __packed;
1316 
1317 struct qlink_iface_comb_num {
1318 	__le32 iface_comb_num;
1319 } __packed;
1320 
1321 struct qlink_iface_limit {
1322 	__le16 max_num;
1323 	__le16 type;
1324 } __packed;
1325 
1326 struct qlink_iface_limit_record {
1327 	__le16 max_interfaces;
1328 	u8 num_different_channels;
1329 	u8 n_limits;
1330 	struct qlink_iface_limit limits[0];
1331 } __packed;
1332 
1333 #define QLINK_RSSI_OFFSET	120
1334 
1335 struct qlink_tlv_frag_rts_thr {
1336 	struct qlink_tlv_hdr hdr;
1337 	__le32 thr;
1338 } __packed;
1339 
1340 struct qlink_tlv_rlimit {
1341 	struct qlink_tlv_hdr hdr;
1342 	u8 rlimit;
1343 } __packed;
1344 
1345 struct qlink_tlv_cclass {
1346 	struct qlink_tlv_hdr hdr;
1347 	u8 cclass;
1348 } __packed;
1349 
1350 /**
1351  * enum qlink_reg_rule_flags - regulatory rule flags
1352  *
1353  * See description of &enum nl80211_reg_rule_flags
1354  */
1355 enum qlink_reg_rule_flags {
1356 	QLINK_RRF_NO_OFDM	= BIT(0),
1357 	QLINK_RRF_NO_CCK	= BIT(1),
1358 	QLINK_RRF_NO_INDOOR	= BIT(2),
1359 	QLINK_RRF_NO_OUTDOOR	= BIT(3),
1360 	QLINK_RRF_DFS		= BIT(4),
1361 	QLINK_RRF_PTP_ONLY	= BIT(5),
1362 	QLINK_RRF_PTMP_ONLY	= BIT(6),
1363 	QLINK_RRF_NO_IR		= BIT(7),
1364 	QLINK_RRF_AUTO_BW	= BIT(8),
1365 	QLINK_RRF_IR_CONCURRENT	= BIT(9),
1366 	QLINK_RRF_NO_HT40MINUS	= BIT(10),
1367 	QLINK_RRF_NO_HT40PLUS	= BIT(11),
1368 	QLINK_RRF_NO_80MHZ	= BIT(12),
1369 	QLINK_RRF_NO_160MHZ	= BIT(13),
1370 };
1371 
1372 /**
1373  * struct qlink_tlv_reg_rule - data for QTN_TLV_ID_REG_RULE TLV
1374  *
1375  * Regulatory rule description.
1376  *
1377  * @start_freq_khz: start frequency of the range the rule is attributed to.
1378  * @end_freq_khz: end frequency of the range the rule is attributed to.
1379  * @max_bandwidth_khz: max bandwidth that channels in specified range can be
1380  *	configured to.
1381  * @max_antenna_gain: max antenna gain that can be used in the specified
1382  *	frequency range, dBi.
1383  * @max_eirp: maximum EIRP.
1384  * @flags: regulatory rule flags in &enum qlink_reg_rule_flags.
1385  * @dfs_cac_ms: DFS CAC period.
1386  */
1387 struct qlink_tlv_reg_rule {
1388 	struct qlink_tlv_hdr hdr;
1389 	__le32 start_freq_khz;
1390 	__le32 end_freq_khz;
1391 	__le32 max_bandwidth_khz;
1392 	__le32 max_antenna_gain;
1393 	__le32 max_eirp;
1394 	__le32 flags;
1395 	__le32 dfs_cac_ms;
1396 } __packed;
1397 
1398 enum qlink_channel_flags {
1399 	QLINK_CHAN_DISABLED		= BIT(0),
1400 	QLINK_CHAN_NO_IR		= BIT(1),
1401 	QLINK_CHAN_RADAR		= BIT(3),
1402 	QLINK_CHAN_NO_HT40PLUS		= BIT(4),
1403 	QLINK_CHAN_NO_HT40MINUS		= BIT(5),
1404 	QLINK_CHAN_NO_OFDM		= BIT(6),
1405 	QLINK_CHAN_NO_80MHZ		= BIT(7),
1406 	QLINK_CHAN_NO_160MHZ		= BIT(8),
1407 	QLINK_CHAN_INDOOR_ONLY		= BIT(9),
1408 	QLINK_CHAN_IR_CONCURRENT	= BIT(10),
1409 	QLINK_CHAN_NO_20MHZ		= BIT(11),
1410 	QLINK_CHAN_NO_10MHZ		= BIT(12),
1411 };
1412 
1413 enum qlink_dfs_state {
1414 	QLINK_DFS_USABLE,
1415 	QLINK_DFS_UNAVAILABLE,
1416 	QLINK_DFS_AVAILABLE,
1417 };
1418 
1419 /**
1420  * struct qlink_tlv_channel - data for QTN_TLV_ID_CHANNEL TLV
1421  *
1422  * Channel settings.
1423  *
1424  * @channel: ieee80211 channel settings.
1425  */
1426 struct qlink_tlv_channel {
1427 	struct qlink_tlv_hdr hdr;
1428 	struct qlink_channel chan;
1429 } __packed;
1430 
1431 /**
1432  * struct qlink_tlv_chandef - data for QTN_TLV_ID_CHANDEF TLV
1433  *
1434  * Channel definition.
1435  *
1436  * @chan: channel definition data.
1437  */
1438 struct qlink_tlv_chandef {
1439 	struct qlink_tlv_hdr hdr;
1440 	struct qlink_chandef chdef;
1441 } __packed;
1442 
1443 enum qlink_ie_set_type {
1444 	QLINK_IE_SET_UNKNOWN,
1445 	QLINK_IE_SET_ASSOC_REQ,
1446 	QLINK_IE_SET_ASSOC_RESP,
1447 	QLINK_IE_SET_PROBE_REQ,
1448 	QLINK_IE_SET_SCAN,
1449 	QLINK_IE_SET_BEACON_HEAD,
1450 	QLINK_IE_SET_BEACON_TAIL,
1451 	QLINK_IE_SET_BEACON_IES,
1452 	QLINK_IE_SET_PROBE_RESP,
1453 	QLINK_IE_SET_PROBE_RESP_IES,
1454 };
1455 
1456 /**
1457  * struct qlink_tlv_ie_set - data for QTN_TLV_ID_IE_SET
1458  *
1459  * @type: type of MGMT frame IEs belong to, one of &enum qlink_ie_set_type.
1460  * @flags: for future use.
1461  * @ie_data: IEs data.
1462  */
1463 struct qlink_tlv_ie_set {
1464 	struct qlink_tlv_hdr hdr;
1465 	u8 type;
1466 	u8 flags;
1467 	u8 ie_data[0];
1468 } __packed;
1469 
1470 /**
1471  * struct qlink_tlv_ext_ie - extension IE
1472  *
1473  * @eid_ext: element ID extension, one of &enum ieee80211_eid_ext.
1474  * @ie_data: IEs data.
1475  */
1476 struct qlink_tlv_ext_ie {
1477 	struct qlink_tlv_hdr hdr;
1478 	u8 eid_ext;
1479 	u8 ie_data[0];
1480 } __packed;
1481 
1482 #define IEEE80211_HE_PPE_THRES_MAX_LEN		25
1483 struct qlink_sband_iftype_data {
1484 	__le16 types_mask;
1485 	struct ieee80211_he_cap_elem he_cap_elem;
1486 	struct ieee80211_he_mcs_nss_supp he_mcs_nss_supp;
1487 	u8 ppe_thres[IEEE80211_HE_PPE_THRES_MAX_LEN];
1488 } __packed;
1489 
1490 /**
1491  * struct qlink_tlv_iftype_data - data for QTN_TLV_ID_IFTYPE_DATA
1492  *
1493  * @n_iftype_data: number of entries in iftype_data.
1494  * @iftype_data: interface type data entries.
1495  */
1496 struct qlink_tlv_iftype_data {
1497 	struct qlink_tlv_hdr hdr;
1498 	u8 n_iftype_data;
1499 	u8 rsvd[3];
1500 	struct qlink_sband_iftype_data iftype_data[0];
1501 } __packed;
1502 
1503 struct qlink_chan_stats {
1504 	__le32 chan_num;
1505 	__le32 cca_tx;
1506 	__le32 cca_rx;
1507 	__le32 cca_busy;
1508 	__le32 cca_try;
1509 	s8 chan_noise;
1510 } __packed;
1511 
1512 /**
1513  * enum qlink_sta_info - station information bitmap
1514  *
1515  * Used to indicate which statistics values in &struct qlink_sta_stats
1516  * are valid. Individual values are used to fill a bitmap carried in a
1517  * payload of QTN_TLV_ID_STA_STATS_MAP.
1518  *
1519  * @QLINK_STA_INFO_CONNECTED_TIME: connected_time value is valid.
1520  * @QLINK_STA_INFO_INACTIVE_TIME: inactive_time value is valid.
1521  * @QLINK_STA_INFO_RX_BYTES: lower 32 bits of rx_bytes value are valid.
1522  * @QLINK_STA_INFO_TX_BYTES: lower 32 bits of tx_bytes value are valid.
1523  * @QLINK_STA_INFO_RX_BYTES64: rx_bytes value is valid.
1524  * @QLINK_STA_INFO_TX_BYTES64: tx_bytes value is valid.
1525  * @QLINK_STA_INFO_RX_DROP_MISC: rx_dropped_misc value is valid.
1526  * @QLINK_STA_INFO_BEACON_RX: rx_beacon value is valid.
1527  * @QLINK_STA_INFO_SIGNAL: signal value is valid.
1528  * @QLINK_STA_INFO_SIGNAL_AVG: signal_avg value is valid.
1529  * @QLINK_STA_INFO_RX_BITRATE: rxrate value is valid.
1530  * @QLINK_STA_INFO_TX_BITRATE: txrate value is valid.
1531  * @QLINK_STA_INFO_RX_PACKETS: rx_packets value is valid.
1532  * @QLINK_STA_INFO_TX_PACKETS: tx_packets value is valid.
1533  * @QLINK_STA_INFO_TX_RETRIES: tx_retries value is valid.
1534  * @QLINK_STA_INFO_TX_FAILED: tx_failed value is valid.
1535  * @QLINK_STA_INFO_STA_FLAGS: sta_flags value is valid.
1536  */
1537 enum qlink_sta_info {
1538 	QLINK_STA_INFO_CONNECTED_TIME,
1539 	QLINK_STA_INFO_INACTIVE_TIME,
1540 	QLINK_STA_INFO_RX_BYTES,
1541 	QLINK_STA_INFO_TX_BYTES,
1542 	QLINK_STA_INFO_RX_BYTES64,
1543 	QLINK_STA_INFO_TX_BYTES64,
1544 	QLINK_STA_INFO_RX_DROP_MISC,
1545 	QLINK_STA_INFO_BEACON_RX,
1546 	QLINK_STA_INFO_SIGNAL,
1547 	QLINK_STA_INFO_SIGNAL_AVG,
1548 	QLINK_STA_INFO_RX_BITRATE,
1549 	QLINK_STA_INFO_TX_BITRATE,
1550 	QLINK_STA_INFO_RX_PACKETS,
1551 	QLINK_STA_INFO_TX_PACKETS,
1552 	QLINK_STA_INFO_TX_RETRIES,
1553 	QLINK_STA_INFO_TX_FAILED,
1554 	QLINK_STA_INFO_STA_FLAGS,
1555 	QLINK_STA_INFO_NUM,
1556 };
1557 
1558 /**
1559  * struct qlink_sta_info_rate - STA rate statistics
1560  *
1561  * @rate: data rate in Mbps.
1562  * @flags: bitmap of &enum qlink_sta_info_rate_flags.
1563  * @mcs: 802.11-defined MCS index.
1564  * nss: Number of Spatial Streams.
1565  * @bw: bandwidth, one of &enum qlink_channel_width.
1566  */
1567 struct qlink_sta_info_rate {
1568 	__le16 rate;
1569 	u8 flags;
1570 	u8 mcs;
1571 	u8 nss;
1572 	u8 bw;
1573 } __packed;
1574 
1575 /**
1576  * struct qlink_sta_stats - data for QTN_TLV_ID_STA_STATS
1577  *
1578  * Carries statistics of a STA. Not all fields may be filled with
1579  * valid values. Valid fields should be indicated as such using a bitmap of
1580  * &enum qlink_sta_info. Bitmap is carried separately in a payload of
1581  * QTN_TLV_ID_STA_STATS_MAP.
1582  */
1583 struct qlink_sta_stats {
1584 	__le64 rx_bytes;
1585 	__le64 tx_bytes;
1586 	__le64 rx_beacon;
1587 	__le64 rx_duration;
1588 	__le64 t_offset;
1589 	__le32 connected_time;
1590 	__le32 inactive_time;
1591 	__le32 rx_packets;
1592 	__le32 tx_packets;
1593 	__le32 tx_retries;
1594 	__le32 tx_failed;
1595 	__le32 rx_dropped_misc;
1596 	__le32 beacon_loss_count;
1597 	__le32 expected_throughput;
1598 	struct qlink_sta_info_state sta_flags;
1599 	struct qlink_sta_info_rate txrate;
1600 	struct qlink_sta_info_rate rxrate;
1601 	__le16 llid;
1602 	__le16 plid;
1603 	u8 local_pm;
1604 	u8 peer_pm;
1605 	u8 nonpeer_pm;
1606 	u8 rx_beacon_signal_avg;
1607 	u8 plink_state;
1608 	u8 signal;
1609 	u8 signal_avg;
1610 	u8 rsvd[1];
1611 };
1612 
1613 /**
1614  * struct qlink_random_mac_addr - data for QTN_TLV_ID_RANDOM_MAC_ADDR TLV
1615  *
1616  * Specifies MAC address mask/value for generation random MAC address
1617  * during scan.
1618  *
1619  * @mac_addr: MAC address used with randomisation
1620  * @mac_addr_mask: MAC address mask used with randomisation, bits that
1621  *	are 0 in the mask should be randomised, bits that are 1 should
1622  *	be taken from the @mac_addr
1623  */
1624 struct qlink_random_mac_addr {
1625 	u8 mac_addr[ETH_ALEN];
1626 	u8 mac_addr_mask[ETH_ALEN];
1627 } __packed;
1628 
1629 /**
1630  * struct qlink_wowlan_capab_data - data for QTN_TLV_ID_WOWLAN_CAPAB TLV
1631  *
1632  * WoWLAN capabilities supported by cards.
1633  *
1634  * @version: version of WoWLAN data structure, to ensure backward
1635  *	compatibility for firmwares with limited WoWLAN support
1636  * @len: Total length of WoWLAN data
1637  * @data: supported WoWLAN features
1638  */
1639 struct qlink_wowlan_capab_data {
1640 	__le16 version;
1641 	__le16 len;
1642 	u8 data[0];
1643 } __packed;
1644 
1645 /**
1646  * struct qlink_wowlan_support - supported WoWLAN capabilities
1647  *
1648  * @n_patterns: number of supported wakeup patterns
1649  * @pattern_max_len: maximum length of each pattern
1650  * @pattern_min_len: minimum length of each pattern
1651  */
1652 struct qlink_wowlan_support {
1653 	__le32 n_patterns;
1654 	__le32 pattern_max_len;
1655 	__le32 pattern_min_len;
1656 } __packed;
1657 
1658 #endif /* _QTN_QLINK_H_ */
1659