f86f6d491fb24c181d5696502bd1ee6750274178
[platform/kernel/linux-starfive.git] / drivers / staging / wfx / hif_api_cmd.h
1 /* SPDX-License-Identifier: Apache-2.0 */
2 /*
3  * WFx hardware interface definitions
4  *
5  * Copyright (c) 2018-2019, Silicon Laboratories Inc.
6  */
7
8 #ifndef WFX_HIF_API_CMD_H
9 #define WFX_HIF_API_CMD_H
10
11 #include "hif_api_general.h"
12
13 #define HIF_API_SSID_SIZE                      API_SSID_SIZE
14
15 enum hif_requests_ids {
16         HIF_REQ_ID_RESET                = 0x0a,
17         HIF_REQ_ID_READ_MIB             = 0x05,
18         HIF_REQ_ID_WRITE_MIB            = 0x06,
19         HIF_REQ_ID_START_SCAN           = 0x07,
20         HIF_REQ_ID_STOP_SCAN            = 0x08,
21         HIF_REQ_ID_TX                   = 0x04,
22         HIF_REQ_ID_JOIN                 = 0x0b,
23         HIF_REQ_ID_SET_PM_MODE          = 0x10,
24         HIF_REQ_ID_SET_BSS_PARAMS       = 0x11,
25         HIF_REQ_ID_ADD_KEY              = 0x0c,
26         HIF_REQ_ID_REMOVE_KEY           = 0x0d,
27         HIF_REQ_ID_EDCA_QUEUE_PARAMS    = 0x13,
28         HIF_REQ_ID_START                = 0x17,
29         HIF_REQ_ID_BEACON_TRANSMIT      = 0x18,
30         HIF_REQ_ID_UPDATE_IE            = 0x1b,
31         HIF_REQ_ID_MAP_LINK             = 0x1c,
32 };
33
34 enum hif_confirmations_ids {
35         HIF_CNF_ID_RESET                = 0x0a,
36         HIF_CNF_ID_READ_MIB             = 0x05,
37         HIF_CNF_ID_WRITE_MIB            = 0x06,
38         HIF_CNF_ID_START_SCAN           = 0x07,
39         HIF_CNF_ID_STOP_SCAN            = 0x08,
40         HIF_CNF_ID_TX                   = 0x04,
41         HIF_CNF_ID_MULTI_TRANSMIT       = 0x1e,
42         HIF_CNF_ID_JOIN                 = 0x0b,
43         HIF_CNF_ID_SET_PM_MODE          = 0x10,
44         HIF_CNF_ID_SET_BSS_PARAMS       = 0x11,
45         HIF_CNF_ID_ADD_KEY              = 0x0c,
46         HIF_CNF_ID_REMOVE_KEY           = 0x0d,
47         HIF_CNF_ID_EDCA_QUEUE_PARAMS    = 0x13,
48         HIF_CNF_ID_START                = 0x17,
49         HIF_CNF_ID_BEACON_TRANSMIT      = 0x18,
50         HIF_CNF_ID_UPDATE_IE            = 0x1b,
51         HIF_CNF_ID_MAP_LINK             = 0x1c,
52 };
53
54 enum hif_indications_ids {
55         HIF_IND_ID_RX                   = 0x84,
56         HIF_IND_ID_SCAN_CMPL            = 0x86,
57         HIF_IND_ID_JOIN_COMPLETE        = 0x8f,
58         HIF_IND_ID_SET_PM_MODE_CMPL     = 0x89,
59         HIF_IND_ID_SUSPEND_RESUME_TX    = 0x8c,
60         HIF_IND_ID_EVENT                = 0x85
61 };
62
63 struct hif_req_reset {
64         u8     reset_stat:1;
65         u8     reset_all_int:1;
66         u8     reserved1:6;
67         u8     reserved2[3];
68 } __packed;
69
70 struct hif_cnf_reset {
71         __le32 status;
72 } __packed;
73
74 struct hif_req_read_mib {
75         __le16 mib_id;
76         __le16 reserved;
77 } __packed;
78
79 struct hif_cnf_read_mib {
80         __le32 status;
81         __le16 mib_id;
82         __le16 length;
83         u8     mib_data[];
84 } __packed;
85
86 struct hif_req_write_mib {
87         __le16 mib_id;
88         __le16 length;
89         u8     mib_data[];
90 } __packed;
91
92 struct hif_cnf_write_mib {
93         __le32 status;
94 } __packed;
95
96 struct hif_ie_tlv {
97         u8     type;
98         u8     length;
99         u8     data[];
100 } __packed;
101
102 struct hif_req_update_ie {
103         u8     beacon:1;
104         u8     probe_resp:1;
105         u8     probe_req:1;
106         u8     reserved1:5;
107         u8     reserved2;
108         __le16 num_ies;
109         struct hif_ie_tlv ie[];
110 } __packed;
111
112 struct hif_cnf_update_ie {
113         __le32 status;
114 } __packed;
115
116 struct hif_scan_type {
117         u8     type:1;
118         u8     mode:1;
119         u8     reserved:6;
120 } __packed;
121
122 struct hif_scan_flags {
123         u8     fbg:1;
124         u8     reserved1:1;
125         u8     pre:1;
126         u8     reserved2:5;
127 } __packed;
128
129 struct hif_auto_scan_param {
130         __le16 interval;
131         u8     reserved;
132         s8     rssi_thr;
133 } __packed;
134
135 struct hif_ssid_def {
136         __le32 ssid_length;
137         u8     ssid[HIF_API_SSID_SIZE];
138 } __packed;
139
140 #define HIF_API_MAX_NB_SSIDS                           2
141 #define HIF_API_MAX_NB_CHANNELS                       14
142
143 struct hif_req_start_scan_alt {
144         u8     band;
145         struct hif_scan_type scan_type;
146         struct hif_scan_flags scan_flags;
147         u8     max_transmit_rate;
148         struct hif_auto_scan_param auto_scan_param;
149         u8     num_of_probe_requests;
150         u8     probe_delay;
151         u8     num_of_ssids;
152         u8     num_of_channels;
153         __le32 min_channel_time;
154         __le32 max_channel_time;
155         __le32 tx_power_level; // signed value
156         struct hif_ssid_def ssid_def[HIF_API_MAX_NB_SSIDS];
157         u8     channel_list[];
158 } __packed;
159
160 struct hif_cnf_start_scan {
161         __le32 status;
162 } __packed;
163
164 struct hif_cnf_stop_scan {
165         __le32 status;
166 } __packed;
167
168 enum hif_pm_mode_status {
169         HIF_PM_MODE_ACTIVE                         = 0x0,
170         HIF_PM_MODE_PS                             = 0x1,
171         HIF_PM_MODE_UNDETERMINED                   = 0x2
172 };
173
174 struct hif_ind_scan_cmpl {
175         __le32 status;
176         u8     pm_mode;
177         u8     num_channels_completed;
178         __le16 reserved;
179 } __packed;
180
181 enum hif_queue_id {
182         HIF_QUEUE_ID_BACKGROUND                    = 0x0,
183         HIF_QUEUE_ID_BESTEFFORT                    = 0x1,
184         HIF_QUEUE_ID_VIDEO                         = 0x2,
185         HIF_QUEUE_ID_VOICE                         = 0x3
186 };
187
188 enum hif_frame_format {
189         HIF_FRAME_FORMAT_NON_HT                    = 0x0,
190         HIF_FRAME_FORMAT_MIXED_FORMAT_HT           = 0x1,
191         HIF_FRAME_FORMAT_GF_HT_11N                 = 0x2
192 };
193
194 enum hif_stbc {
195         HIF_STBC_NOT_ALLOWED                       = 0x0,
196         HIF_STBC_ALLOWED                           = 0x1
197 };
198
199 struct hif_queue {
200         u8     queue_id:2;
201         u8     peer_sta_id:4;
202         u8     reserved:2;
203 } __packed;
204
205 struct hif_data_flags {
206         u8     more:1;
207         u8     fc_offset:3;
208         u8     after_dtim:1;
209         u8     reserved:3;
210 } __packed;
211
212 struct hif_tx_flags {
213         u8     start_exp:1;
214         u8     reserved:3;
215         u8     retry_policy_index:4;
216 } __packed;
217
218 struct hif_ht_tx_parameters {
219         u8     frame_format:4;
220         u8     fec_coding:1;
221         u8     short_gi:1;
222         u8     reserved1:1;
223         u8     stbc:1;
224         u8     reserved2;
225         u8     aggregation:1;
226         u8     reserved3:7;
227         u8     reserved4;
228 } __packed;
229
230 struct hif_req_tx {
231         // packet_id is not interpreted by the device, so it is not necessary to
232         // declare it little endian
233         u32    packet_id;
234         u8     max_tx_rate;
235         struct hif_queue queue_id;
236         struct hif_data_flags data_flags;
237         struct hif_tx_flags tx_flags;
238         __le32 reserved;
239         __le32 expire_time;
240         struct hif_ht_tx_parameters ht_tx_parameters;
241         u8     frame[];
242 } __packed;
243
244 enum hif_qos_ackplcy {
245         HIF_QOS_ACKPLCY_NORMAL                         = 0x0,
246         HIF_QOS_ACKPLCY_TXNOACK                        = 0x1,
247         HIF_QOS_ACKPLCY_NOEXPACK                       = 0x2,
248         HIF_QOS_ACKPLCY_BLCKACK                        = 0x3
249 };
250
251 struct hif_tx_result_flags {
252         u8     aggr:1;
253         u8     requeue:1;
254         u8     ack_policy:2;
255         u8     txop_limit:1;
256         u8     reserved1:3;
257         u8     reserved2;
258 } __packed;
259
260 struct hif_cnf_tx {
261         __le32 status;
262         // packet_id is copied from struct hif_req_tx without been interpreted
263         // by the device, so it is not necessary to declare it little endian
264         u32    packet_id;
265         u8     txed_rate;
266         u8     ack_failures;
267         struct hif_tx_result_flags tx_result_flags;
268         __le32 media_delay;
269         __le32 tx_queue_delay;
270 } __packed;
271
272 struct hif_cnf_multi_transmit {
273         u8     num_tx_confs;
274         u8     reserved[3];
275         struct hif_cnf_tx   tx_conf_payload[];
276 } __packed;
277
278 enum hif_ri_flags_encrypt {
279         HIF_RI_FLAGS_UNENCRYPTED                   = 0x0,
280         HIF_RI_FLAGS_WEP_ENCRYPTED                 = 0x1,
281         HIF_RI_FLAGS_TKIP_ENCRYPTED                = 0x2,
282         HIF_RI_FLAGS_AES_ENCRYPTED                 = 0x3,
283         HIF_RI_FLAGS_WAPI_ENCRYPTED                = 0x4
284 };
285
286 struct hif_rx_flags {
287         u8     encryp:3;
288         u8     in_aggr:1;
289         u8     first_aggr:1;
290         u8     last_aggr:1;
291         u8     defrag:1;
292         u8     beacon:1;
293         u8     tim:1;
294         u8     bitmap:1;
295         u8     match_ssid:1;
296         u8     match_bssid:1;
297         u8     more:1;
298         u8     reserved1:1;
299         u8     ht:1;
300         u8     stbc:1;
301         u8     match_uc_addr:1;
302         u8     match_mc_addr:1;
303         u8     match_bc_addr:1;
304         u8     key_type:1;
305         u8     key_index:4;
306         u8     reserved2:1;
307         u8     peer_sta_id:4;
308         u8     reserved3:2;
309         u8     reserved4:1;
310 } __packed;
311
312 struct hif_ind_rx {
313         __le32 status;
314         u8     channel_number;
315         u8     reserved;
316         u8     rxed_rate;
317         u8     rcpi_rssi;
318         struct hif_rx_flags rx_flags;
319         u8     frame[];
320 } __packed;
321
322
323 struct hif_req_edca_queue_params {
324         u8     queue_id;
325         u8     reserved1;
326         u8     aifsn;
327         u8     reserved2;
328         __le16 cw_min;
329         __le16 cw_max;
330         __le16 tx_op_limit;
331         __le16 allowed_medium_time;
332         __le32 reserved3;
333 } __packed;
334
335 struct hif_cnf_edca_queue_params {
336         __le32 status;
337 } __packed;
338
339 struct hif_req_join {
340         u8     infrastructure_bss_mode:1;
341         u8     reserved1:7;
342         u8     band;
343         u8     channel_number;
344         u8     reserved2;
345         u8     bssid[ETH_ALEN];
346         __le16 atim_window;
347         u8     short_preamble:1;
348         u8     reserved3:7;
349         u8     probe_for_join;
350         u8     reserved4;
351         u8     reserved5:2;
352         u8     force_no_beacon:1;
353         u8     force_with_ind:1;
354         u8     reserved6:4;
355         __le32 ssid_length;
356         u8     ssid[HIF_API_SSID_SIZE];
357         __le32 beacon_interval;
358         __le32 basic_rate_set;
359 } __packed;
360
361 struct hif_cnf_join {
362         __le32 status;
363 } __packed;
364
365 struct hif_ind_join_complete {
366         __le32 status;
367 } __packed;
368
369 struct hif_req_set_bss_params {
370         u8     lost_count_only:1;
371         u8     reserved:7;
372         u8     beacon_lost_count;
373         __le16 aid;
374         __le32 operational_rate_set;
375 } __packed;
376
377 struct hif_cnf_set_bss_params {
378         __le32 status;
379 } __packed;
380
381 struct hif_pm_mode {
382         u8     enter_psm:1;
383         u8     reserved:6;
384         u8     fast_psm:1;
385 } __packed;
386
387 struct hif_req_set_pm_mode {
388         struct hif_pm_mode pm_mode;
389         u8     fast_psm_idle_period;
390         u8     ap_psm_change_period;
391         u8     min_auto_ps_poll_period;
392 } __packed;
393
394 struct hif_cnf_set_pm_mode {
395         __le32 status;
396 } __packed;
397
398 struct hif_ind_set_pm_mode_cmpl {
399         __le32 status;
400         u8     pm_mode;
401         u8     reserved[3];
402 } __packed;
403
404
405 struct hif_req_start {
406         u8     mode;
407         u8     band;
408         u8     channel_number;
409         u8     reserved1;
410         __le32 reserved2;
411         __le32 beacon_interval;
412         u8     dtim_period;
413         u8     short_preamble:1;
414         u8     reserved3:7;
415         u8     reserved4;
416         u8     ssid_length;
417         u8     ssid[HIF_API_SSID_SIZE];
418         __le32 basic_rate_set;
419 } __packed;
420
421 struct hif_cnf_start {
422         __le32 status;
423 } __packed;
424
425 struct hif_req_beacon_transmit {
426         u8     enable_beaconing;
427         u8     reserved[3];
428 } __packed;
429
430 struct hif_cnf_beacon_transmit {
431         __le32 status;
432 } __packed;
433
434 #define HIF_LINK_ID_MAX            14
435 #define HIF_LINK_ID_NOT_ASSOCIATED (HIF_LINK_ID_MAX + 1)
436
437 struct hif_req_map_link {
438         u8     mac_addr[ETH_ALEN];
439         u8     unmap:1;
440         u8     mfpc:1;
441         u8     reserved:6;
442         u8     peer_sta_id;
443 } __packed;
444
445 struct hif_cnf_map_link {
446         __le32 status;
447 } __packed;
448
449 struct hif_suspend_resume_flags {
450         u8     resume:1;
451         u8     reserved1:2;
452         u8     bc_mc_only:1;
453         u8     reserved2:4;
454         u8     reserved3;
455 } __packed;
456
457 struct hif_ind_suspend_resume_tx {
458         struct hif_suspend_resume_flags suspend_resume_flags;
459         __le16 peer_sta_set;
460 } __packed;
461
462
463 #define MAX_KEY_ENTRIES         24
464 #define HIF_API_WEP_KEY_DATA_SIZE                       16
465 #define HIF_API_TKIP_KEY_DATA_SIZE                      16
466 #define HIF_API_RX_MIC_KEY_SIZE                         8
467 #define HIF_API_TX_MIC_KEY_SIZE                         8
468 #define HIF_API_AES_KEY_DATA_SIZE                       16
469 #define HIF_API_WAPI_KEY_DATA_SIZE                      16
470 #define HIF_API_MIC_KEY_DATA_SIZE                       16
471 #define HIF_API_IGTK_KEY_DATA_SIZE                      16
472 #define HIF_API_RX_SEQUENCE_COUNTER_SIZE                8
473 #define HIF_API_IPN_SIZE                                8
474
475 enum hif_key_type {
476         HIF_KEY_TYPE_WEP_DEFAULT                   = 0x0,
477         HIF_KEY_TYPE_WEP_PAIRWISE                  = 0x1,
478         HIF_KEY_TYPE_TKIP_GROUP                    = 0x2,
479         HIF_KEY_TYPE_TKIP_PAIRWISE                 = 0x3,
480         HIF_KEY_TYPE_AES_GROUP                     = 0x4,
481         HIF_KEY_TYPE_AES_PAIRWISE                  = 0x5,
482         HIF_KEY_TYPE_WAPI_GROUP                    = 0x6,
483         HIF_KEY_TYPE_WAPI_PAIRWISE                 = 0x7,
484         HIF_KEY_TYPE_IGTK_GROUP                    = 0x8,
485         HIF_KEY_TYPE_NONE                          = 0x9
486 };
487
488 struct hif_wep_pairwise_key {
489         u8     peer_address[ETH_ALEN];
490         u8     reserved;
491         u8     key_length;
492         u8     key_data[HIF_API_WEP_KEY_DATA_SIZE];
493 } __packed;
494
495 struct hif_wep_group_key {
496         u8     key_id;
497         u8     key_length;
498         u8     reserved[2];
499         u8     key_data[HIF_API_WEP_KEY_DATA_SIZE];
500 } __packed;
501
502 struct hif_tkip_pairwise_key {
503         u8     peer_address[ETH_ALEN];
504         u8     reserved[2];
505         u8     tkip_key_data[HIF_API_TKIP_KEY_DATA_SIZE];
506         u8     rx_mic_key[HIF_API_RX_MIC_KEY_SIZE];
507         u8     tx_mic_key[HIF_API_TX_MIC_KEY_SIZE];
508 } __packed;
509
510 struct hif_tkip_group_key {
511         u8     tkip_key_data[HIF_API_TKIP_KEY_DATA_SIZE];
512         u8     rx_mic_key[HIF_API_RX_MIC_KEY_SIZE];
513         u8     key_id;
514         u8     reserved[3];
515         u8     rx_sequence_counter[HIF_API_RX_SEQUENCE_COUNTER_SIZE];
516 } __packed;
517
518 struct hif_aes_pairwise_key {
519         u8     peer_address[ETH_ALEN];
520         u8     reserved[2];
521         u8     aes_key_data[HIF_API_AES_KEY_DATA_SIZE];
522 } __packed;
523
524 struct hif_aes_group_key {
525         u8     aes_key_data[HIF_API_AES_KEY_DATA_SIZE];
526         u8     key_id;
527         u8     reserved[3];
528         u8     rx_sequence_counter[HIF_API_RX_SEQUENCE_COUNTER_SIZE];
529 } __packed;
530
531 struct hif_wapi_pairwise_key {
532         u8     peer_address[ETH_ALEN];
533         u8     key_id;
534         u8     reserved;
535         u8     wapi_key_data[HIF_API_WAPI_KEY_DATA_SIZE];
536         u8     mic_key_data[HIF_API_MIC_KEY_DATA_SIZE];
537 } __packed;
538
539 struct hif_wapi_group_key {
540         u8     wapi_key_data[HIF_API_WAPI_KEY_DATA_SIZE];
541         u8     mic_key_data[HIF_API_MIC_KEY_DATA_SIZE];
542         u8     key_id;
543         u8     reserved[3];
544 } __packed;
545
546 struct hif_igtk_group_key {
547         u8     igtk_key_data[HIF_API_IGTK_KEY_DATA_SIZE];
548         u8     key_id;
549         u8     reserved[3];
550         u8     ipn[HIF_API_IPN_SIZE];
551 } __packed;
552
553 union hif_privacy_key_data {
554         struct hif_wep_pairwise_key  wep_pairwise_key;
555         struct hif_wep_group_key     wep_group_key;
556         struct hif_tkip_pairwise_key tkip_pairwise_key;
557         struct hif_tkip_group_key    tkip_group_key;
558         struct hif_aes_pairwise_key  aes_pairwise_key;
559         struct hif_aes_group_key     aes_group_key;
560         struct hif_wapi_pairwise_key wapi_pairwise_key;
561         struct hif_wapi_group_key    wapi_group_key;
562         struct hif_igtk_group_key    igtk_group_key;
563 };
564
565 struct hif_req_add_key {
566         u8     type;
567         u8     entry_index;
568         u8     int_id:2;
569         u8     reserved1:6;
570         u8     reserved2;
571         union hif_privacy_key_data key;
572 } __packed;
573
574 struct hif_cnf_add_key {
575         __le32 status;
576 } __packed;
577
578 struct hif_req_remove_key {
579         u8     entry_index;
580         u8     reserved[3];
581 } __packed;
582
583 struct hif_cnf_remove_key {
584         __le32 status;
585 } __packed;
586
587 enum hif_event_ind {
588         HIF_EVENT_IND_BSSLOST                      = 0x1,
589         HIF_EVENT_IND_BSSREGAINED                  = 0x2,
590         HIF_EVENT_IND_RCPI_RSSI                    = 0x3,
591         HIF_EVENT_IND_PS_MODE_ERROR                = 0x4,
592         HIF_EVENT_IND_INACTIVITY                   = 0x5
593 };
594
595 enum hif_ps_mode_error {
596         HIF_PS_ERROR_NO_ERROR                      = 0,
597         HIF_PS_ERROR_AP_NOT_RESP_TO_POLL           = 1,
598         HIF_PS_ERROR_AP_NOT_RESP_TO_UAPSD_TRIGGER  = 2,
599         HIF_PS_ERROR_AP_SENT_UNICAST_IN_DOZE       = 3,
600         HIF_PS_ERROR_AP_NO_DATA_AFTER_TIM          = 4
601 };
602
603 union hif_event_data {
604         u8     rcpi_rssi;
605         __le32 ps_mode_error;
606         __le32 peer_sta_set;
607 };
608
609 struct hif_ind_event {
610         __le32 event_id;
611         union hif_event_data event_data;
612 } __packed;
613
614
615 #endif