xref: /openbmc/linux/drivers/net/wireless/quantenna/qtnfmac/qlink.h (revision 2eb3ed33e55d003d721d4d1a5e72fe323c12b4c0)
1 /*
2  * Copyright (c) 2015-2016 Quantenna Communications, Inc.
3  * All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  */
16 
17 #ifndef _QTN_QLINK_H_
18 #define _QTN_QLINK_H_
19 
20 #include <linux/ieee80211.h>
21 
22 #define QLINK_PROTO_VER		5
23 
24 #define QLINK_MACID_RSVD		0xFF
25 #define QLINK_VIFID_RSVD		0xFF
26 
27 /* Common QLINK protocol messages definitions.
28  */
29 
30 /**
31  * enum qlink_msg_type - QLINK message types
32  *
33  * Used to distinguish between message types of QLINK protocol.
34  *
35  * @QLINK_MSG_TYPE_CMD: Message is carrying data of a command sent from
36  *	driver to wireless hardware.
37  * @QLINK_MSG_TYPE_CMDRSP: Message is carrying data of a response to a command.
38  *	Sent from wireless HW to driver in reply to previously issued command.
39  * @QLINK_MSG_TYPE_EVENT: Data for an event originated in wireless hardware and
40  *	sent asynchronously to driver.
41  */
42 enum qlink_msg_type {
43 	QLINK_MSG_TYPE_CMD	= 1,
44 	QLINK_MSG_TYPE_CMDRSP	= 2,
45 	QLINK_MSG_TYPE_EVENT	= 3
46 };
47 
48 /**
49  * struct qlink_msg_header - common QLINK protocol message header
50  *
51  * Portion of QLINK protocol header common for all message types.
52  *
53  * @type: Message type, one of &enum qlink_msg_type.
54  * @len: Total length of message including all headers.
55  */
56 struct qlink_msg_header {
57 	__le16 type;
58 	__le16 len;
59 } __packed;
60 
61 /* Generic definitions of data and information carried in QLINK messages
62  */
63 
64 /**
65  * enum qlink_hw_capab - device capabilities.
66  *
67  * @QLINK_HW_CAPAB_REG_UPDATE: device can update it's regulatory region.
68  * @QLINK_HW_CAPAB_STA_INACT_TIMEOUT: device implements a logic to kick-out
69  *	associated STAs due to inactivity. Inactivity timeout period is taken
70  *	from QLINK_CMD_START_AP parameters.
71  */
72 enum qlink_hw_capab {
73 	QLINK_HW_CAPAB_REG_UPDATE = BIT(0),
74 	QLINK_HW_CAPAB_STA_INACT_TIMEOUT = BIT(1),
75 };
76 
77 enum qlink_phy_mode {
78 	QLINK_PHYMODE_BGN	= BIT(0),
79 	QLINK_PHYMODE_AN	= BIT(1),
80 	QLINK_PHYMODE_AC	= BIT(2),
81 };
82 
83 enum qlink_iface_type {
84 	QLINK_IFTYPE_AP		= 1,
85 	QLINK_IFTYPE_STATION	= 2,
86 	QLINK_IFTYPE_ADHOC	= 3,
87 	QLINK_IFTYPE_MONITOR	= 4,
88 	QLINK_IFTYPE_WDS	= 5,
89 	QLINK_IFTYPE_AP_VLAN	= 6,
90 };
91 
92 /**
93  * struct qlink_intf_info - information on virtual interface.
94  *
95  * Data describing a single virtual interface.
96  *
97  * @if_type: Mode of interface operation, one of &enum qlink_iface_type
98  * @vlanid: VLAN ID for AP_VLAN interface type
99  * @mac_addr: MAC address of virtual interface.
100  */
101 struct qlink_intf_info {
102 	__le16 if_type;
103 	__le16 vlanid;
104 	u8 mac_addr[ETH_ALEN];
105 	u8 rsvd[2];
106 } __packed;
107 
108 enum qlink_sta_flags {
109 	QLINK_STA_FLAG_INVALID		= 0,
110 	QLINK_STA_FLAG_AUTHORIZED		= BIT(0),
111 	QLINK_STA_FLAG_SHORT_PREAMBLE	= BIT(1),
112 	QLINK_STA_FLAG_WME			= BIT(2),
113 	QLINK_STA_FLAG_MFP			= BIT(3),
114 	QLINK_STA_FLAG_AUTHENTICATED		= BIT(4),
115 	QLINK_STA_FLAG_TDLS_PEER		= BIT(5),
116 	QLINK_STA_FLAG_ASSOCIATED		= BIT(6),
117 };
118 
119 enum qlink_channel_width {
120 	QLINK_CHAN_WIDTH_5 = 0,
121 	QLINK_CHAN_WIDTH_10,
122 	QLINK_CHAN_WIDTH_20_NOHT,
123 	QLINK_CHAN_WIDTH_20,
124 	QLINK_CHAN_WIDTH_40,
125 	QLINK_CHAN_WIDTH_80,
126 	QLINK_CHAN_WIDTH_80P80,
127 	QLINK_CHAN_WIDTH_160,
128 };
129 
130 /**
131  * struct qlink_chandef - qlink channel definition
132  *
133  * @center_freq1: center frequency of first segment
134  * @center_freq2: center frequency of second segment (80+80 only)
135  * @width: channel width, one of @enum qlink_channel_width
136  */
137 struct qlink_chandef {
138 	__le16 center_freq1;
139 	__le16 center_freq2;
140 	u8 width;
141 	u8 rsvd[3];
142 } __packed;
143 
144 #define QLINK_MAX_NR_CIPHER_SUITES            5
145 #define QLINK_MAX_NR_AKM_SUITES               2
146 
147 struct qlink_auth_encr {
148 	__le32 wpa_versions;
149 	__le32 cipher_group;
150 	__le32 n_ciphers_pairwise;
151 	__le32 ciphers_pairwise[QLINK_MAX_NR_CIPHER_SUITES];
152 	__le32 n_akm_suites;
153 	__le32 akm_suites[QLINK_MAX_NR_AKM_SUITES];
154 	__le16 control_port_ethertype;
155 	u8 auth_type;
156 	u8 privacy;
157 	u8 mfp;
158 	u8 control_port;
159 	u8 control_port_no_encrypt;
160 } __packed;
161 
162 /* QLINK Command messages related definitions
163  */
164 
165 /**
166  * enum qlink_cmd_type - list of supported commands
167  *
168  * Commands are QLINK messages of type @QLINK_MSG_TYPE_CMD, sent by driver to
169  * wireless network device for processing. Device is expected to send back a
170  * reply message of type &QLINK_MSG_TYPE_CMDRSP, containing at least command
171  * execution status (one of &enum qlink_cmd_result) at least. Reply message
172  * may also contain data payload specific to the command type.
173  *
174  * @QLINK_CMD_CHANS_INFO_GET: for the specified MAC and specified band, get
175  *	number of operational channels and information on each of the channel.
176  *	This command is generic to a specified MAC, interface index must be set
177  *	to QLINK_VIFID_RSVD in command header.
178  * @QLINK_CMD_REG_NOTIFY: notify device about regulatory domain change. This
179  *	command is supported only if device reports QLINK_HW_SUPPORTS_REG_UPDATE
180  *	capability.
181  */
182 enum qlink_cmd_type {
183 	QLINK_CMD_FW_INIT		= 0x0001,
184 	QLINK_CMD_FW_DEINIT		= 0x0002,
185 	QLINK_CMD_REGISTER_MGMT		= 0x0003,
186 	QLINK_CMD_SEND_MGMT_FRAME	= 0x0004,
187 	QLINK_CMD_MGMT_SET_APPIE	= 0x0005,
188 	QLINK_CMD_PHY_PARAMS_GET	= 0x0011,
189 	QLINK_CMD_PHY_PARAMS_SET	= 0x0012,
190 	QLINK_CMD_GET_HW_INFO		= 0x0013,
191 	QLINK_CMD_MAC_INFO		= 0x0014,
192 	QLINK_CMD_ADD_INTF		= 0x0015,
193 	QLINK_CMD_DEL_INTF		= 0x0016,
194 	QLINK_CMD_CHANGE_INTF		= 0x0017,
195 	QLINK_CMD_UPDOWN_INTF		= 0x0018,
196 	QLINK_CMD_REG_NOTIFY		= 0x0019,
197 	QLINK_CMD_CHANS_INFO_GET	= 0x001A,
198 	QLINK_CMD_CHAN_SWITCH		= 0x001B,
199 	QLINK_CMD_CHAN_GET		= 0x001C,
200 	QLINK_CMD_CONFIG_AP		= 0x0020,
201 	QLINK_CMD_START_AP		= 0x0021,
202 	QLINK_CMD_STOP_AP		= 0x0022,
203 	QLINK_CMD_GET_STA_INFO		= 0x0030,
204 	QLINK_CMD_ADD_KEY		= 0x0040,
205 	QLINK_CMD_DEL_KEY		= 0x0041,
206 	QLINK_CMD_SET_DEFAULT_KEY	= 0x0042,
207 	QLINK_CMD_SET_DEFAULT_MGMT_KEY	= 0x0043,
208 	QLINK_CMD_CHANGE_STA		= 0x0051,
209 	QLINK_CMD_DEL_STA		= 0x0052,
210 	QLINK_CMD_SCAN			= 0x0053,
211 	QLINK_CMD_CHAN_STATS		= 0x0054,
212 	QLINK_CMD_CONNECT		= 0x0060,
213 	QLINK_CMD_DISCONNECT		= 0x0061,
214 };
215 
216 /**
217  * struct qlink_cmd - QLINK command message header
218  *
219  * Header used for QLINK messages of QLINK_MSG_TYPE_CMD type.
220  *
221  * @mhdr: Common QLINK message header.
222  * @cmd_id: command id, one of &enum qlink_cmd_type.
223  * @seq_num: sequence number of command message, used for matching with
224  *	response message.
225  * @macid: index of physical radio device the command is destined to or
226  *	QLINK_MACID_RSVD if not applicable.
227  * @vifid: index of virtual wireless interface on specified @macid the command
228  *	is destined to or QLINK_VIFID_RSVD if not applicable.
229  */
230 struct qlink_cmd {
231 	struct qlink_msg_header mhdr;
232 	__le16 cmd_id;
233 	__le16 seq_num;
234 	u8 rsvd[2];
235 	u8 macid;
236 	u8 vifid;
237 } __packed;
238 
239 /**
240  * struct qlink_cmd_manage_intf - interface management command
241  *
242  * Data for interface management commands QLINK_CMD_ADD_INTF, QLINK_CMD_DEL_INTF
243  * and QLINK_CMD_CHANGE_INTF.
244  *
245  * @intf_info: interface description.
246  */
247 struct qlink_cmd_manage_intf {
248 	struct qlink_cmd chdr;
249 	struct qlink_intf_info intf_info;
250 } __packed;
251 
252 enum qlink_mgmt_frame_type {
253 	QLINK_MGMT_FRAME_ASSOC_REQ	= 0x00,
254 	QLINK_MGMT_FRAME_ASSOC_RESP	= 0x01,
255 	QLINK_MGMT_FRAME_REASSOC_REQ	= 0x02,
256 	QLINK_MGMT_FRAME_REASSOC_RESP	= 0x03,
257 	QLINK_MGMT_FRAME_PROBE_REQ	= 0x04,
258 	QLINK_MGMT_FRAME_PROBE_RESP	= 0x05,
259 	QLINK_MGMT_FRAME_BEACON		= 0x06,
260 	QLINK_MGMT_FRAME_ATIM		= 0x07,
261 	QLINK_MGMT_FRAME_DISASSOC	= 0x08,
262 	QLINK_MGMT_FRAME_AUTH		= 0x09,
263 	QLINK_MGMT_FRAME_DEAUTH		= 0x0A,
264 	QLINK_MGMT_FRAME_ACTION		= 0x0B,
265 
266 	QLINK_MGMT_FRAME_TYPE_COUNT
267 };
268 
269 /**
270  * struct qlink_cmd_mgmt_frame_register - data for QLINK_CMD_REGISTER_MGMT
271  *
272  * @frame_type: MGMT frame type the registration request describes, one of
273  *	&enum qlink_mgmt_frame_type.
274  * @do_register: 0 - unregister, otherwise register for reception of specified
275  *	MGMT frame type.
276  */
277 struct qlink_cmd_mgmt_frame_register {
278 	struct qlink_cmd chdr;
279 	__le16 frame_type;
280 	u8 do_register;
281 } __packed;
282 
283 enum qlink_mgmt_frame_tx_flags {
284 	QLINK_MGMT_FRAME_TX_FLAG_NONE		= 0,
285 	QLINK_MGMT_FRAME_TX_FLAG_OFFCHAN	= BIT(0),
286 	QLINK_MGMT_FRAME_TX_FLAG_NO_CCK		= BIT(1),
287 	QLINK_MGMT_FRAME_TX_FLAG_ACK_NOWAIT	= BIT(2),
288 };
289 
290 /**
291  * struct qlink_cmd_mgmt_frame_tx - data for QLINK_CMD_SEND_MGMT_FRAME command
292  *
293  * @cookie: opaque request identifier.
294  * @freq: Frequency to use for frame transmission.
295  * @flags: Transmission flags, one of &enum qlink_mgmt_frame_tx_flags.
296  * @frame_data: frame to transmit.
297  */
298 struct qlink_cmd_mgmt_frame_tx {
299 	struct qlink_cmd chdr;
300 	__le32 cookie;
301 	__le16 freq;
302 	__le16 flags;
303 	u8 frame_data[0];
304 } __packed;
305 
306 /**
307  * struct qlink_cmd_mgmt_append_ie - data for QLINK_CMD_MGMT_SET_APPIE command
308  *
309  * @type: type of MGMT frame to appent requested IEs to, one of
310  *	&enum qlink_mgmt_frame_type.
311  * @flags: for future use.
312  * @ie_data: IEs data to append.
313  */
314 struct qlink_cmd_mgmt_append_ie {
315 	struct qlink_cmd chdr;
316 	u8 type;
317 	u8 flags;
318 	u8 ie_data[0];
319 } __packed;
320 
321 /**
322  * struct qlink_cmd_get_sta_info - data for QLINK_CMD_GET_STA_INFO command
323  *
324  * @sta_addr: MAC address of the STA statistics is requested for.
325  */
326 struct qlink_cmd_get_sta_info {
327 	struct qlink_cmd chdr;
328 	u8 sta_addr[ETH_ALEN];
329 } __packed;
330 
331 /**
332  * struct qlink_cmd_add_key - data for QLINK_CMD_ADD_KEY command.
333  *
334  * @key_index: index of the key being installed.
335  * @pairwise: whether to use pairwise key.
336  * @addr: MAC address of a STA key is being installed to.
337  * @cipher: cipher suite.
338  * @vlanid: VLAN ID for AP_VLAN interface type
339  * @key_data: key data itself.
340  */
341 struct qlink_cmd_add_key {
342 	struct qlink_cmd chdr;
343 	u8 key_index;
344 	u8 pairwise;
345 	u8 addr[ETH_ALEN];
346 	__le32 cipher;
347 	__le16 vlanid;
348 	u8 key_data[0];
349 } __packed;
350 
351 /**
352  * struct qlink_cmd_del_key_req - data for QLINK_CMD_DEL_KEY command
353  *
354  * @key_index: index of the key being removed.
355  * @pairwise: whether to use pairwise key.
356  * @addr: MAC address of a STA for which a key is removed.
357  */
358 struct qlink_cmd_del_key {
359 	struct qlink_cmd chdr;
360 	u8 key_index;
361 	u8 pairwise;
362 	u8 addr[ETH_ALEN];
363 } __packed;
364 
365 /**
366  * struct qlink_cmd_set_def_key - data for QLINK_CMD_SET_DEFAULT_KEY command
367  *
368  * @key_index: index of the key to be set as default one.
369  * @unicast: key is unicast.
370  * @multicast: key is multicast.
371  */
372 struct qlink_cmd_set_def_key {
373 	struct qlink_cmd chdr;
374 	u8 key_index;
375 	u8 unicast;
376 	u8 multicast;
377 } __packed;
378 
379 /**
380  * struct qlink_cmd_set_def_mgmt_key - data for QLINK_CMD_SET_DEFAULT_MGMT_KEY
381  *
382  * @key_index: index of the key to be set as default MGMT key.
383  */
384 struct qlink_cmd_set_def_mgmt_key {
385 	struct qlink_cmd chdr;
386 	u8 key_index;
387 } __packed;
388 
389 /**
390  * struct qlink_cmd_change_sta - data for QLINK_CMD_CHANGE_STA command
391  *
392  * @sta_flags_mask: STA flags mask, bitmap of &enum qlink_sta_flags
393  * @sta_flags_set: STA flags values, bitmap of &enum qlink_sta_flags
394  * @if_type: Mode of interface operation, one of &enum qlink_iface_type
395  * @vlanid: VLAN ID to assign to specific STA
396  * @sta_addr: address of the STA for which parameters are set.
397  */
398 struct qlink_cmd_change_sta {
399 	struct qlink_cmd chdr;
400 	__le32 sta_flags_mask;
401 	__le32 sta_flags_set;
402 	__le16 if_type;
403 	__le16 vlanid;
404 	u8 sta_addr[ETH_ALEN];
405 } __packed;
406 
407 /**
408  * struct qlink_cmd_del_sta - data for QLINK_CMD_DEL_STA command.
409  *
410  * See &struct station_del_parameters
411  */
412 struct qlink_cmd_del_sta {
413 	struct qlink_cmd chdr;
414 	__le16 reason_code;
415 	u8 subtype;
416 	u8 sta_addr[ETH_ALEN];
417 } __packed;
418 
419 enum qlink_sta_connect_flags {
420 	QLINK_STA_CONNECT_DISABLE_HT	= BIT(0),
421 	QLINK_STA_CONNECT_DISABLE_VHT	= BIT(1),
422 	QLINK_STA_CONNECT_USE_RRM	= BIT(2),
423 };
424 
425 /**
426  * struct qlink_cmd_connect - data for QLINK_CMD_CONNECT command
427  *
428  * @flags: for future use.
429  * @channel: channel which should be used to connect.
430  * @bg_scan_period: period of background scan.
431  * @aen: authentication information.
432  * @bssid: BSSID of the BSS to connect to.
433  * @payload: variable portion of connection request.
434  */
435 struct qlink_cmd_connect {
436 	struct qlink_cmd chdr;
437 	__le32 flags;
438 	__le16 channel;
439 	__le16 bg_scan_period;
440 	struct qlink_auth_encr aen;
441 	u8 bssid[ETH_ALEN];
442 	u8 payload[0];
443 } __packed;
444 
445 /**
446  * struct qlink_cmd_disconnect - data for QLINK_CMD_DISCONNECT command
447  *
448  * @reason: code of the reason of disconnect, see &enum ieee80211_reasoncode.
449  */
450 struct qlink_cmd_disconnect {
451 	struct qlink_cmd chdr;
452 	__le16 reason;
453 } __packed;
454 
455 /**
456  * struct qlink_cmd_updown - data for QLINK_CMD_UPDOWN_INTF command
457  *
458  * @if_up: bring specified interface DOWN (if_up==0) or UP (otherwise).
459  *	Interface is specified in common command header @chdr.
460  */
461 struct qlink_cmd_updown {
462 	struct qlink_cmd chdr;
463 	u8 if_up;
464 } __packed;
465 
466 /**
467  * enum qlink_band - a list of frequency bands
468  *
469  * @QLINK_BAND_2GHZ: 2.4GHz band
470  * @QLINK_BAND_5GHZ: 5GHz band
471  * @QLINK_BAND_60GHZ: 60GHz band
472  */
473 enum qlink_band {
474 	QLINK_BAND_2GHZ = BIT(0),
475 	QLINK_BAND_5GHZ = BIT(1),
476 	QLINK_BAND_60GHZ = BIT(2),
477 };
478 
479 /**
480  * struct qlink_cmd_chans_info_get - data for QLINK_CMD_CHANS_INFO_GET command
481  *
482  * @band: a PHY band for which channels info is needed, one of @enum qlink_band
483  */
484 struct qlink_cmd_chans_info_get {
485 	struct qlink_cmd chdr;
486 	u8 band;
487 } __packed;
488 
489 /**
490  * struct qlink_cmd_get_chan_stats - data for QLINK_CMD_CHAN_STATS command
491  *
492  * @channel: channel number according to 802.11 17.3.8.3.2 and Annex J
493  */
494 struct qlink_cmd_get_chan_stats {
495 	struct qlink_cmd chdr;
496 	__le16 channel;
497 } __packed;
498 
499 /**
500  * enum qlink_reg_initiator - Indicates the initiator of a reg domain request
501  *
502  * See &enum nl80211_reg_initiator for more info.
503  */
504 enum qlink_reg_initiator {
505 	QLINK_REGDOM_SET_BY_CORE,
506 	QLINK_REGDOM_SET_BY_USER,
507 	QLINK_REGDOM_SET_BY_DRIVER,
508 	QLINK_REGDOM_SET_BY_COUNTRY_IE,
509 };
510 
511 /**
512  * enum qlink_user_reg_hint_type - type of user regulatory hint
513  *
514  * See &enum nl80211_user_reg_hint_type for more info.
515  */
516 enum qlink_user_reg_hint_type {
517 	QLINK_USER_REG_HINT_USER	= 0,
518 	QLINK_USER_REG_HINT_CELL_BASE	= 1,
519 	QLINK_USER_REG_HINT_INDOOR	= 2,
520 };
521 
522 /**
523  * struct qlink_cmd_reg_notify - data for QLINK_CMD_REG_NOTIFY command
524  *
525  * @alpha2: the ISO / IEC 3166 alpha2 country code.
526  * @initiator: which entity sent the request, one of &enum qlink_reg_initiator.
527  * @user_reg_hint_type: type of hint for QLINK_REGDOM_SET_BY_USER request, one
528  *	of &enum qlink_user_reg_hint_type.
529  */
530 struct qlink_cmd_reg_notify {
531 	struct qlink_cmd chdr;
532 	u8 alpha2[2];
533 	u8 initiator;
534 	u8 user_reg_hint_type;
535 } __packed;
536 
537 /**
538  * struct qlink_cmd_chan_switch - data for QLINK_CMD_CHAN_SWITCH command
539  *
540  * @channel: channel number according to 802.11 17.3.8.3.2 and Annex J
541  * @radar_required: whether radar detection is required on the new channel
542  * @block_tx: whether transmissions should be blocked while changing
543  * @beacon_count: number of beacons until switch
544  */
545 struct qlink_cmd_chan_switch {
546 	struct qlink_cmd chdr;
547 	__le16 channel;
548 	u8 radar_required;
549 	u8 block_tx;
550 	u8 beacon_count;
551 } __packed;
552 
553 /**
554  * enum qlink_hidden_ssid - values for %NL80211_ATTR_HIDDEN_SSID
555  *
556  * Refer to &enum nl80211_hidden_ssid
557  */
558 enum qlink_hidden_ssid {
559 	QLINK_HIDDEN_SSID_NOT_IN_USE,
560 	QLINK_HIDDEN_SSID_ZERO_LEN,
561 	QLINK_HIDDEN_SSID_ZERO_CONTENTS
562 };
563 
564 /**
565  * struct qlink_cmd_config_ap - data for QLINK_CMD_CONFIG_AP command
566  *
567  * @beacon_interval: beacon interval
568  * @inactivity_timeout: station's inactivity period in seconds
569  * @dtim_period: DTIM period
570  * @hidden_ssid: whether to hide the SSID, one of &enum qlink_hidden_ssid
571  * @smps_mode: SMPS mode
572  * @ht_required: stations must support HT
573  * @vht_required: stations must support VHT
574  * @aen: encryption info
575  * @info: variable configurations
576  */
577 struct qlink_cmd_config_ap {
578 	struct qlink_cmd chdr;
579 	__le16 beacon_interval;
580 	__le16 inactivity_timeout;
581 	u8 dtim_period;
582 	u8 hidden_ssid;
583 	u8 smps_mode;
584 	u8 p2p_ctwindow;
585 	u8 p2p_opp_ps;
586 	u8 pbss;
587 	u8 ht_required;
588 	u8 vht_required;
589 	struct qlink_auth_encr aen;
590 	u8 info[0];
591 } __packed;
592 
593 /* QLINK Command Responses messages related definitions
594  */
595 
596 enum qlink_cmd_result {
597 	QLINK_CMD_RESULT_OK = 0,
598 	QLINK_CMD_RESULT_INVALID,
599 	QLINK_CMD_RESULT_ENOTSUPP,
600 	QLINK_CMD_RESULT_ENOTFOUND,
601 	QLINK_CMD_RESULT_EALREADY,
602 };
603 
604 /**
605  * struct qlink_resp - QLINK command response message header
606  *
607  * Header used for QLINK messages of QLINK_MSG_TYPE_CMDRSP type.
608  *
609  * @mhdr: see &struct qlink_msg_header.
610  * @cmd_id: command ID the response corresponds to, one of &enum qlink_cmd_type.
611  * @seq_num: sequence number of command message, used for matching with
612  *	response message.
613  * @result: result of the command execution, one of &enum qlink_cmd_result.
614  * @macid: index of physical radio device the response is sent from or
615  *	QLINK_MACID_RSVD if not applicable.
616  * @vifid: index of virtual wireless interface on specified @macid the response
617  *	is sent from or QLINK_VIFID_RSVD if not applicable.
618  */
619 struct qlink_resp {
620 	struct qlink_msg_header mhdr;
621 	__le16 cmd_id;
622 	__le16 seq_num;
623 	__le16 result;
624 	u8 macid;
625 	u8 vifid;
626 } __packed;
627 
628 /**
629  * struct qlink_resp_get_mac_info - response for QLINK_CMD_MAC_INFO command
630  *
631  * Data describing specific physical device providing wireless MAC
632  * functionality.
633  *
634  * @dev_mac: MAC address of physical WMAC device (used for first BSS on
635  *	specified WMAC).
636  * @num_tx_chain: Number of transmit chains used by WMAC.
637  * @num_rx_chain: Number of receive chains used by WMAC.
638  * @vht_cap: VHT capabilities.
639  * @ht_cap: HT capabilities.
640  * @bands_cap: wireless bands WMAC can operate in, bitmap of &enum qlink_band.
641  * @phymode_cap: PHY modes WMAC can operate in, bitmap of &enum qlink_phy_mode.
642  * @max_ap_assoc_sta: Maximum number of associations supported by WMAC.
643  * @radar_detect_widths: bitmask of channels BW for which WMAC can detect radar.
644  * @var_info: variable-length WMAC info data.
645  */
646 struct qlink_resp_get_mac_info {
647 	struct qlink_resp rhdr;
648 	u8 dev_mac[ETH_ALEN];
649 	u8 num_tx_chain;
650 	u8 num_rx_chain;
651 	struct ieee80211_vht_cap vht_cap;
652 	struct ieee80211_ht_cap ht_cap;
653 	u8 bands_cap;
654 	u8 phymode_cap;
655 	__le16 max_ap_assoc_sta;
656 	__le16 radar_detect_widths;
657 	u8 var_info[0];
658 } __packed;
659 
660 /**
661  * enum qlink_dfs_regions - regulatory DFS regions
662  *
663  * Corresponds to &enum nl80211_dfs_regions.
664  */
665 enum qlink_dfs_regions {
666 	QLINK_DFS_UNSET	= 0,
667 	QLINK_DFS_FCC	= 1,
668 	QLINK_DFS_ETSI	= 2,
669 	QLINK_DFS_JP	= 3,
670 };
671 
672 /**
673  * struct qlink_resp_get_hw_info - response for QLINK_CMD_GET_HW_INFO command
674  *
675  * Description of wireless hardware capabilities and features.
676  *
677  * @fw_ver: wireless hardware firmware version.
678  * @hw_capab: Bitmap of capabilities supported by firmware.
679  * @ql_proto_ver: Version of QLINK protocol used by firmware.
680  * @num_mac: Number of separate physical radio devices provided by hardware.
681  * @mac_bitmap: Bitmap of MAC IDs that are active and can be used in firmware.
682  * @total_tx_chains: total number of transmit chains used by device.
683  * @total_rx_chains: total number of receive chains.
684  * @alpha2: country code ID firmware is configured to.
685  * @n_reg_rules: number of regulatory rules TLVs in variable portion of the
686  *	message.
687  * @dfs_region: regulatory DFS region, one of @enum qlink_dfs_region.
688  * @info: variable-length HW info, can contain QTN_TLV_ID_REG_RULE.
689  */
690 struct qlink_resp_get_hw_info {
691 	struct qlink_resp rhdr;
692 	__le32 fw_ver;
693 	__le32 hw_capab;
694 	__le16 ql_proto_ver;
695 	u8 num_mac;
696 	u8 mac_bitmap;
697 	u8 total_tx_chain;
698 	u8 total_rx_chain;
699 	u8 alpha2[2];
700 	u8 n_reg_rules;
701 	u8 dfs_region;
702 	u8 info[0];
703 } __packed;
704 
705 /**
706  * struct qlink_resp_manage_intf - response for interface management commands
707  *
708  * Response data for QLINK_CMD_ADD_INTF and QLINK_CMD_CHANGE_INTF commands.
709  *
710  * @rhdr: Common Command Response message header.
711  * @intf_info: interface description.
712  */
713 struct qlink_resp_manage_intf {
714 	struct qlink_resp rhdr;
715 	struct qlink_intf_info intf_info;
716 } __packed;
717 
718 /**
719  * struct qlink_resp_get_sta_info - response for QLINK_CMD_GET_STA_INFO command
720  *
721  * Response data containing statistics for specified STA.
722  *
723  * @sta_addr: MAC address of STA the response carries statistic for.
724  * @info: statistics for specified STA.
725  */
726 struct qlink_resp_get_sta_info {
727 	struct qlink_resp rhdr;
728 	u8 sta_addr[ETH_ALEN];
729 	u8 info[0];
730 } __packed;
731 
732 /**
733  * struct qlink_resp_get_chan_info - response for QLINK_CMD_CHANS_INFO_GET cmd
734  *
735  * @band: frequency band to which channels belong to, one of @enum qlink_band.
736  * @num_chans: total number of channels info data contained in reply data.
737  * @info: variable-length channels info.
738  */
739 struct qlink_resp_get_chan_info {
740 	struct qlink_resp rhdr;
741 	u8 band;
742 	u8 num_chans;
743 	u8 rsvd[2];
744 	u8 info[0];
745 } __packed;
746 
747 /**
748  * struct qlink_resp_phy_params - response for QLINK_CMD_PHY_PARAMS_GET command
749  *
750  * @info: variable-length array of PHY params.
751  */
752 struct qlink_resp_phy_params {
753 	struct qlink_resp rhdr;
754 	u8 info[0];
755 } __packed;
756 
757 /**
758  * struct qlink_resp_get_chan_stats - response for QLINK_CMD_CHAN_STATS cmd
759  *
760  * @info: variable-length channel info.
761  */
762 struct qlink_resp_get_chan_stats {
763 	struct qlink_cmd rhdr;
764 	u8 info[0];
765 } __packed;
766 
767 /**
768  * struct qlink_resp_channel_get - response for QLINK_CMD_CHAN_GET command
769  *
770  * @chan: definition of current operating channel.
771  */
772 struct qlink_resp_channel_get {
773 	struct qlink_resp rhdr;
774 	struct qlink_chandef chan;
775 } __packed;
776 
777 /* QLINK Events messages related definitions
778  */
779 
780 enum qlink_event_type {
781 	QLINK_EVENT_STA_ASSOCIATED	= 0x0021,
782 	QLINK_EVENT_STA_DEAUTH		= 0x0022,
783 	QLINK_EVENT_MGMT_RECEIVED	= 0x0023,
784 	QLINK_EVENT_SCAN_RESULTS	= 0x0024,
785 	QLINK_EVENT_SCAN_COMPLETE	= 0x0025,
786 	QLINK_EVENT_BSS_JOIN		= 0x0026,
787 	QLINK_EVENT_BSS_LEAVE		= 0x0027,
788 	QLINK_EVENT_FREQ_CHANGE		= 0x0028,
789 };
790 
791 /**
792  * struct qlink_event - QLINK event message header
793  *
794  * Header used for QLINK messages of QLINK_MSG_TYPE_EVENT type.
795  *
796  * @mhdr: Common QLINK message header.
797  * @event_id: Specifies specific event ID, one of &enum qlink_event_type.
798  * @macid: index of physical radio device the event was generated on or
799  *	QLINK_MACID_RSVD if not applicable.
800  * @vifid: index of virtual wireless interface on specified @macid the event
801  *	was generated on or QLINK_VIFID_RSVD if not applicable.
802  */
803 struct qlink_event {
804 	struct qlink_msg_header mhdr;
805 	__le16 event_id;
806 	u8 macid;
807 	u8 vifid;
808 } __packed;
809 
810 /**
811  * struct qlink_event_sta_assoc - data for QLINK_EVENT_STA_ASSOCIATED event
812  *
813  * @sta_addr: Address of a STA for which new association event was generated
814  * @frame_control: control bits from 802.11 ASSOC_REQUEST header.
815  * @payload: IEs from association request.
816  */
817 struct qlink_event_sta_assoc {
818 	struct qlink_event ehdr;
819 	u8 sta_addr[ETH_ALEN];
820 	__le16 frame_control;
821 	u8 ies[0];
822 } __packed;
823 
824 /**
825  * struct qlink_event_sta_deauth - data for QLINK_EVENT_STA_DEAUTH event
826  *
827  * @sta_addr: Address of a deauthenticated STA.
828  * @reason: reason for deauthentication.
829  */
830 struct qlink_event_sta_deauth {
831 	struct qlink_event ehdr;
832 	u8 sta_addr[ETH_ALEN];
833 	__le16 reason;
834 } __packed;
835 
836 /**
837  * struct qlink_event_bss_join - data for QLINK_EVENT_BSS_JOIN event
838  *
839  * @bssid: BSSID of a BSS which interface tried to joined.
840  * @status: status of joining attempt, see &enum ieee80211_statuscode.
841  */
842 struct qlink_event_bss_join {
843 	struct qlink_event ehdr;
844 	u8 bssid[ETH_ALEN];
845 	__le16 status;
846 } __packed;
847 
848 /**
849  * struct qlink_event_bss_leave - data for QLINK_EVENT_BSS_LEAVE event
850  *
851  * @reason: reason of disconnecting from BSS.
852  */
853 struct qlink_event_bss_leave {
854 	struct qlink_event ehdr;
855 	__le16 reason;
856 } __packed;
857 
858 /**
859  * struct qlink_event_freq_change - data for QLINK_EVENT_FREQ_CHANGE event
860  *
861  * @chan: new operating channel definition
862  */
863 struct qlink_event_freq_change {
864 	struct qlink_event ehdr;
865 	struct qlink_chandef chan;
866 } __packed;
867 
868 enum qlink_rxmgmt_flags {
869 	QLINK_RXMGMT_FLAG_ANSWERED = 1 << 0,
870 };
871 
872 /**
873  * struct qlink_event_rxmgmt - data for QLINK_EVENT_MGMT_RECEIVED event
874  *
875  * @freq: Frequency on which the frame was received in MHz.
876  * @sig_dbm: signal strength in dBm.
877  * @flags: bitmap of &enum qlink_rxmgmt_flags.
878  * @frame_data: data of Rx'd frame itself.
879  */
880 struct qlink_event_rxmgmt {
881 	struct qlink_event ehdr;
882 	__le32 freq;
883 	__le32 sig_dbm;
884 	__le32 flags;
885 	u8 frame_data[0];
886 } __packed;
887 
888 enum qlink_frame_type {
889 	QLINK_BSS_FTYPE_UNKNOWN,
890 	QLINK_BSS_FTYPE_BEACON,
891 	QLINK_BSS_FTYPE_PRESP,
892 };
893 
894 /**
895  * struct qlink_event_scan_result - data for QLINK_EVENT_SCAN_RESULTS event
896  *
897  * @tsf: TSF timestamp indicating when scan results were generated.
898  * @freq: Center frequency of the channel where BSS for which the scan result
899  *	event was generated was discovered.
900  * @capab: capabilities field.
901  * @bintval: beacon interval announced by discovered BSS.
902  * @signal: signal strength.
903  * @frame_type: frame type used to get scan result, see &enum qlink_frame_type.
904  * @bssid: BSSID announced by discovered BSS.
905  * @ssid_len: length of SSID announced by BSS.
906  * @ssid: SSID announced by discovered BSS.
907  * @payload: IEs that are announced by discovered BSS in its MGMt frames.
908  */
909 struct qlink_event_scan_result {
910 	struct qlink_event ehdr;
911 	__le64 tsf;
912 	__le16 freq;
913 	__le16 capab;
914 	__le16 bintval;
915 	s8 signal;
916 	u8 frame_type;
917 	u8 bssid[ETH_ALEN];
918 	u8 ssid_len;
919 	u8 ssid[IEEE80211_MAX_SSID_LEN];
920 	u8 payload[0];
921 } __packed;
922 
923 /**
924  * enum qlink_scan_complete_flags - indicates result of scan request.
925  *
926  * @QLINK_SCAN_NONE: Scan request was processed.
927  * @QLINK_SCAN_ABORTED: Scan was aborted.
928  */
929 enum qlink_scan_complete_flags {
930 	QLINK_SCAN_NONE		= 0,
931 	QLINK_SCAN_ABORTED	= BIT(0),
932 };
933 
934 /**
935  * struct qlink_event_scan_complete - data for QLINK_EVENT_SCAN_COMPLETE event
936  *
937  * @flags: flags indicating the status of pending scan request,
938  *	see &enum qlink_scan_complete_flags.
939  */
940 struct qlink_event_scan_complete {
941 	struct qlink_event ehdr;
942 	__le32 flags;
943 } __packed;
944 
945 /* QLINK TLVs (Type-Length Values) definitions
946  */
947 
948 enum qlink_tlv_id {
949 	QTN_TLV_ID_FRAG_THRESH		= 0x0201,
950 	QTN_TLV_ID_RTS_THRESH		= 0x0202,
951 	QTN_TLV_ID_SRETRY_LIMIT		= 0x0203,
952 	QTN_TLV_ID_LRETRY_LIMIT		= 0x0204,
953 	QTN_TLV_ID_REG_RULE		= 0x0207,
954 	QTN_TLV_ID_CHANNEL		= 0x020F,
955 	QTN_TLV_ID_CHANDEF		= 0x0210,
956 	QTN_TLV_ID_COVERAGE_CLASS	= 0x0213,
957 	QTN_TLV_ID_IFACE_LIMIT		= 0x0214,
958 	QTN_TLV_ID_NUM_IFACE_COMB	= 0x0215,
959 	QTN_TLV_ID_CHANNEL_STATS	= 0x0216,
960 	QTN_TLV_ID_STA_BASIC_COUNTERS	= 0x0300,
961 	QTN_TLV_ID_STA_GENERIC_INFO	= 0x0301,
962 	QTN_TLV_ID_KEY			= 0x0302,
963 	QTN_TLV_ID_SEQ			= 0x0303,
964 	QTN_TLV_ID_IE_SET		= 0x0305,
965 };
966 
967 struct qlink_tlv_hdr {
968 	__le16 type;
969 	__le16 len;
970 	u8 val[0];
971 } __packed;
972 
973 struct qlink_iface_limit {
974 	__le16 max_num;
975 	__le16 type;
976 } __packed;
977 
978 struct qlink_iface_comb_num {
979 	__le16 iface_comb_num;
980 } __packed;
981 
982 struct qlink_sta_stat_basic_counters {
983 	__le64 rx_bytes;
984 	__le64 tx_bytes;
985 	__le64 rx_beacons;
986 	__le32 rx_packets;
987 	__le32 tx_packets;
988 	__le32 rx_dropped;
989 	__le32 tx_failed;
990 } __packed;
991 
992 enum qlink_sta_info_rate_flags {
993 	QLINK_STA_INFO_RATE_FLAG_INVALID	= 0,
994 	QLINK_STA_INFO_RATE_FLAG_HT_MCS		= BIT(0),
995 	QLINK_STA_INFO_RATE_FLAG_VHT_MCS	= BIT(1),
996 	QLINK_STA_INFO_RATE_FLAG_SHORT_GI	= BIT(2),
997 	QLINK_STA_INFO_RATE_FLAG_60G		= BIT(3),
998 };
999 
1000 enum qlink_sta_info_rate_bw {
1001 	QLINK_STA_INFO_RATE_BW_5		= 0,
1002 	QLINK_STA_INFO_RATE_BW_10		= 1,
1003 	QLINK_STA_INFO_RATE_BW_20		= 2,
1004 	QLINK_STA_INFO_RATE_BW_40		= 3,
1005 	QLINK_STA_INFO_RATE_BW_80		= 4,
1006 	QLINK_STA_INFO_RATE_BW_160		= 5,
1007 };
1008 
1009 /**
1010  * struct qlink_sta_info_rate - STA rate statistics
1011  *
1012  * @rate: data rate in Mbps.
1013  * @flags: bitmap of &enum qlink_sta_flags.
1014  * @mcs: 802.11-defined MCS index.
1015  * nss: Number of Spatial Streams.
1016  * @bw: bandwidth, one of &enum qlink_sta_info_rate_bw.
1017  */
1018 struct qlink_sta_info_rate {
1019 	__le16 rate;
1020 	u8 flags;
1021 	u8 mcs;
1022 	u8 nss;
1023 	u8 bw;
1024 } __packed;
1025 
1026 struct qlink_sta_info_state {
1027 	__le32 mask;
1028 	__le32 value;
1029 } __packed;
1030 
1031 #define QLINK_RSSI_OFFSET	120
1032 
1033 struct qlink_sta_info_generic {
1034 	struct qlink_sta_info_state state;
1035 	__le32 connected_time;
1036 	__le32 inactive_time;
1037 	struct qlink_sta_info_rate rx_rate;
1038 	struct qlink_sta_info_rate tx_rate;
1039 	u8 rssi;
1040 	u8 rssi_avg;
1041 } __packed;
1042 
1043 struct qlink_tlv_frag_rts_thr {
1044 	struct qlink_tlv_hdr hdr;
1045 	__le16 thr;
1046 } __packed;
1047 
1048 struct qlink_tlv_rlimit {
1049 	struct qlink_tlv_hdr hdr;
1050 	u8 rlimit;
1051 } __packed;
1052 
1053 struct qlink_tlv_cclass {
1054 	struct qlink_tlv_hdr hdr;
1055 	u8 cclass;
1056 } __packed;
1057 
1058 /**
1059  * enum qlink_reg_rule_flags - regulatory rule flags
1060  *
1061  * See description of &enum nl80211_reg_rule_flags
1062  */
1063 enum qlink_reg_rule_flags {
1064 	QLINK_RRF_NO_OFDM	= BIT(0),
1065 	QLINK_RRF_NO_CCK	= BIT(1),
1066 	QLINK_RRF_NO_INDOOR	= BIT(2),
1067 	QLINK_RRF_NO_OUTDOOR	= BIT(3),
1068 	QLINK_RRF_DFS		= BIT(4),
1069 	QLINK_RRF_PTP_ONLY	= BIT(5),
1070 	QLINK_RRF_PTMP_ONLY	= BIT(6),
1071 	QLINK_RRF_NO_IR		= BIT(7),
1072 	QLINK_RRF_AUTO_BW	= BIT(8),
1073 	QLINK_RRF_IR_CONCURRENT	= BIT(9),
1074 	QLINK_RRF_NO_HT40MINUS	= BIT(10),
1075 	QLINK_RRF_NO_HT40PLUS	= BIT(11),
1076 	QLINK_RRF_NO_80MHZ	= BIT(12),
1077 	QLINK_RRF_NO_160MHZ	= BIT(13),
1078 };
1079 
1080 /**
1081  * struct qlink_tlv_reg_rule - data for QTN_TLV_ID_REG_RULE TLV
1082  *
1083  * Regulatory rule description.
1084  *
1085  * @start_freq_khz: start frequency of the range the rule is attributed to.
1086  * @end_freq_khz: end frequency of the range the rule is attributed to.
1087  * @max_bandwidth_khz: max bandwidth that channels in specified range can be
1088  *	configured to.
1089  * @max_antenna_gain: max antenna gain that can be used in the specified
1090  *	frequency range, dBi.
1091  * @max_eirp: maximum EIRP.
1092  * @flags: regulatory rule flags in &enum qlink_reg_rule_flags.
1093  * @dfs_cac_ms: DFS CAC period.
1094  */
1095 struct qlink_tlv_reg_rule {
1096 	struct qlink_tlv_hdr hdr;
1097 	__le32 start_freq_khz;
1098 	__le32 end_freq_khz;
1099 	__le32 max_bandwidth_khz;
1100 	__le32 max_antenna_gain;
1101 	__le32 max_eirp;
1102 	__le32 flags;
1103 	__le32 dfs_cac_ms;
1104 } __packed;
1105 
1106 enum qlink_channel_flags {
1107 	QLINK_CHAN_DISABLED		= BIT(0),
1108 	QLINK_CHAN_NO_IR		= BIT(1),
1109 	QLINK_CHAN_RADAR		= BIT(3),
1110 	QLINK_CHAN_NO_HT40PLUS		= BIT(4),
1111 	QLINK_CHAN_NO_HT40MINUS		= BIT(5),
1112 	QLINK_CHAN_NO_OFDM		= BIT(6),
1113 	QLINK_CHAN_NO_80MHZ		= BIT(7),
1114 	QLINK_CHAN_NO_160MHZ		= BIT(8),
1115 	QLINK_CHAN_INDOOR_ONLY		= BIT(9),
1116 	QLINK_CHAN_IR_CONCURRENT	= BIT(10),
1117 	QLINK_CHAN_NO_20MHZ		= BIT(11),
1118 	QLINK_CHAN_NO_10MHZ		= BIT(12),
1119 };
1120 
1121 enum qlink_dfs_state {
1122 	QLINK_DFS_USABLE,
1123 	QLINK_DFS_UNAVAILABLE,
1124 	QLINK_DFS_AVAILABLE,
1125 };
1126 
1127 struct qlink_tlv_channel {
1128 	struct qlink_tlv_hdr hdr;
1129 	__le16 hw_value;
1130 	__le16 center_freq;
1131 	__le32 flags;
1132 	u8 band;
1133 	u8 max_antenna_gain;
1134 	u8 max_power;
1135 	u8 max_reg_power;
1136 	__le32 dfs_cac_ms;
1137 	u8 dfs_state;
1138 	u8 beacon_found;
1139 	u8 rsvd[2];
1140 } __packed;
1141 
1142 /**
1143  * struct qlink_tlv_chandef - data for QTN_TLV_ID_CHANDEF TLV
1144  *
1145  * Channel definition.
1146  *
1147  * @chan: channel definition data.
1148  */
1149 struct qlink_tlv_chandef {
1150 	struct qlink_tlv_hdr hdr;
1151 	struct qlink_chandef chan;
1152 } __packed;
1153 
1154 struct qlink_chan_stats {
1155 	__le32 chan_num;
1156 	__le32 cca_tx;
1157 	__le32 cca_rx;
1158 	__le32 cca_busy;
1159 	__le32 cca_try;
1160 	s8 chan_noise;
1161 } __packed;
1162 
1163 #endif /* _QTN_QLINK_H_ */
1164