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