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