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