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