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