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