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