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