c7e6fdf183b129efc1b66c051469099529ab90d4
[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_ssid_def {
117         __le32 ssid_length;
118         u8     ssid[HIF_API_SSID_SIZE];
119 } __packed;
120
121 #define HIF_API_MAX_NB_SSIDS                           2
122 #define HIF_API_MAX_NB_CHANNELS                       14
123
124 struct hif_req_start_scan_alt {
125         u8     band;
126         u8     maintain_current_bss:1;
127         u8     periodic:1;
128         u8     reserved1:6;
129         u8     disallow_ps:1;
130         u8     reserved2:1;
131         u8     short_preamble:1;
132         u8     reserved3:5;
133         u8     max_transmit_rate;
134         __le16 periodic_interval;
135         u8     reserved4;
136         s8     periodic_rssi_thr;
137         u8     num_of_probe_requests;
138         u8     probe_delay;
139         u8     num_of_ssids;
140         u8     num_of_channels;
141         __le32 min_channel_time;
142         __le32 max_channel_time;
143         __le32 tx_power_level; // signed value
144         struct hif_ssid_def ssid_def[HIF_API_MAX_NB_SSIDS];
145         u8     channel_list[];
146 } __packed;
147
148 struct hif_cnf_start_scan {
149         __le32 status;
150 } __packed;
151
152 struct hif_cnf_stop_scan {
153         __le32 status;
154 } __packed;
155
156 enum hif_pm_mode_status {
157         HIF_PM_MODE_ACTIVE                         = 0x0,
158         HIF_PM_MODE_PS                             = 0x1,
159         HIF_PM_MODE_UNDETERMINED                   = 0x2
160 };
161
162 struct hif_ind_scan_cmpl {
163         __le32 status;
164         u8     pm_mode;
165         u8     num_channels_completed;
166         __le16 reserved;
167 } __packed;
168
169 enum hif_queue_id {
170         HIF_QUEUE_ID_BACKGROUND                    = 0x0,
171         HIF_QUEUE_ID_BESTEFFORT                    = 0x1,
172         HIF_QUEUE_ID_VIDEO                         = 0x2,
173         HIF_QUEUE_ID_VOICE                         = 0x3
174 };
175
176 enum hif_frame_format {
177         HIF_FRAME_FORMAT_NON_HT                    = 0x0,
178         HIF_FRAME_FORMAT_MIXED_FORMAT_HT           = 0x1,
179         HIF_FRAME_FORMAT_GF_HT_11N                 = 0x2
180 };
181
182 struct hif_req_tx {
183         // packet_id is not interpreted by the device, so it is not necessary to
184         // declare it little endian
185         u32    packet_id;
186         u8     max_tx_rate;
187         u8     queue_id:2;
188         u8     peer_sta_id:4;
189         u8     reserved1:2;
190         u8     more:1;
191         u8     fc_offset:3;
192         u8     after_dtim:1;
193         u8     reserved2:3;
194         u8     start_exp:1;
195         u8     reserved3:3;
196         u8     retry_policy_index:4;
197         __le32 reserved4;
198         __le32 expire_time;
199         u8     frame_format:4;
200         u8     fec_coding:1;
201         u8     short_gi:1;
202         u8     reserved5:1;
203         u8     stbc:1;
204         u8     reserved6;
205         u8     aggregation:1;
206         u8     reserved7:7;
207         u8     reserved8;
208         u8     frame[];
209 } __packed;
210
211 enum hif_qos_ackplcy {
212         HIF_QOS_ACKPLCY_NORMAL                         = 0x0,
213         HIF_QOS_ACKPLCY_TXNOACK                        = 0x1,
214         HIF_QOS_ACKPLCY_NOEXPACK                       = 0x2,
215         HIF_QOS_ACKPLCY_BLCKACK                        = 0x3
216 };
217
218 struct hif_cnf_tx {
219         __le32 status;
220         // packet_id is copied from struct hif_req_tx without been interpreted
221         // by the device, so it is not necessary to declare it little endian
222         u32    packet_id;
223         u8     txed_rate;
224         u8     ack_failures;
225         u8     aggr:1;
226         u8     requeue:1;
227         u8     ack_policy:2;
228         u8     txop_limit:1;
229         u8     reserved1:3;
230         u8     reserved2;
231         __le32 media_delay;
232         __le32 tx_queue_delay;
233 } __packed;
234
235 struct hif_cnf_multi_transmit {
236         u8     num_tx_confs;
237         u8     reserved[3];
238         struct hif_cnf_tx   tx_conf_payload[];
239 } __packed;
240
241 enum hif_ri_flags_encrypt {
242         HIF_RI_FLAGS_UNENCRYPTED                   = 0x0,
243         HIF_RI_FLAGS_WEP_ENCRYPTED                 = 0x1,
244         HIF_RI_FLAGS_TKIP_ENCRYPTED                = 0x2,
245         HIF_RI_FLAGS_AES_ENCRYPTED                 = 0x3,
246         HIF_RI_FLAGS_WAPI_ENCRYPTED                = 0x4
247 };
248
249 struct hif_ind_rx {
250         __le32 status;
251         u8     channel_number;
252         u8     reserved1;
253         u8     rxed_rate;
254         u8     rcpi_rssi;
255         u8     encryp:3;
256         u8     in_aggr:1;
257         u8     first_aggr:1;
258         u8     last_aggr:1;
259         u8     defrag:1;
260         u8     beacon:1;
261         u8     tim:1;
262         u8     bitmap:1;
263         u8     match_ssid:1;
264         u8     match_bssid:1;
265         u8     more:1;
266         u8     reserved2:1;
267         u8     ht:1;
268         u8     stbc:1;
269         u8     match_uc_addr:1;
270         u8     match_mc_addr:1;
271         u8     match_bc_addr:1;
272         u8     key_type:1;
273         u8     key_index:4;
274         u8     reserved3:1;
275         u8     peer_sta_id:4;
276         u8     reserved4:2;
277         u8     reserved5:1;
278         u8     frame[];
279 } __packed;
280
281 struct hif_req_edca_queue_params {
282         u8     queue_id;
283         u8     reserved1;
284         u8     aifsn;
285         u8     reserved2;
286         __le16 cw_min;
287         __le16 cw_max;
288         __le16 tx_op_limit;
289         __le16 allowed_medium_time;
290         __le32 reserved3;
291 } __packed;
292
293 struct hif_cnf_edca_queue_params {
294         __le32 status;
295 } __packed;
296
297 struct hif_req_join {
298         u8     infrastructure_bss_mode:1;
299         u8     reserved1:7;
300         u8     band;
301         u8     channel_number;
302         u8     reserved2;
303         u8     bssid[ETH_ALEN];
304         __le16 atim_window;
305         u8     short_preamble:1;
306         u8     reserved3:7;
307         u8     probe_for_join;
308         u8     reserved4;
309         u8     reserved5:2;
310         u8     force_no_beacon:1;
311         u8     force_with_ind:1;
312         u8     reserved6:4;
313         __le32 ssid_length;
314         u8     ssid[HIF_API_SSID_SIZE];
315         __le32 beacon_interval;
316         __le32 basic_rate_set;
317 } __packed;
318
319 struct hif_cnf_join {
320         __le32 status;
321 } __packed;
322
323 struct hif_ind_join_complete {
324         __le32 status;
325 } __packed;
326
327 struct hif_req_set_bss_params {
328         u8     lost_count_only:1;
329         u8     reserved:7;
330         u8     beacon_lost_count;
331         __le16 aid;
332         __le32 operational_rate_set;
333 } __packed;
334
335 struct hif_cnf_set_bss_params {
336         __le32 status;
337 } __packed;
338
339 struct hif_req_set_pm_mode {
340         u8     enter_psm:1;
341         u8     reserved:6;
342         u8     fast_psm:1;
343         u8     fast_psm_idle_period;
344         u8     ap_psm_change_period;
345         u8     min_auto_ps_poll_period;
346 } __packed;
347
348 struct hif_cnf_set_pm_mode {
349         __le32 status;
350 } __packed;
351
352 struct hif_ind_set_pm_mode_cmpl {
353         __le32 status;
354         u8     pm_mode;
355         u8     reserved[3];
356 } __packed;
357
358
359 struct hif_req_start {
360         u8     mode;
361         u8     band;
362         u8     channel_number;
363         u8     reserved1;
364         __le32 reserved2;
365         __le32 beacon_interval;
366         u8     dtim_period;
367         u8     short_preamble:1;
368         u8     reserved3:7;
369         u8     reserved4;
370         u8     ssid_length;
371         u8     ssid[HIF_API_SSID_SIZE];
372         __le32 basic_rate_set;
373 } __packed;
374
375 struct hif_cnf_start {
376         __le32 status;
377 } __packed;
378
379 struct hif_req_beacon_transmit {
380         u8     enable_beaconing;
381         u8     reserved[3];
382 } __packed;
383
384 struct hif_cnf_beacon_transmit {
385         __le32 status;
386 } __packed;
387
388 #define HIF_LINK_ID_MAX            14
389 #define HIF_LINK_ID_NOT_ASSOCIATED (HIF_LINK_ID_MAX + 1)
390
391 struct hif_req_map_link {
392         u8     mac_addr[ETH_ALEN];
393         u8     unmap:1;
394         u8     mfpc:1;
395         u8     reserved:6;
396         u8     peer_sta_id;
397 } __packed;
398
399 struct hif_cnf_map_link {
400         __le32 status;
401 } __packed;
402
403 struct hif_ind_suspend_resume_tx {
404         u8     resume:1;
405         u8     reserved1:2;
406         u8     bc_mc_only:1;
407         u8     reserved2:4;
408         u8     reserved3;
409         __le16 peer_sta_set;
410 } __packed;
411
412
413 #define MAX_KEY_ENTRIES         24
414 #define HIF_API_WEP_KEY_DATA_SIZE                       16
415 #define HIF_API_TKIP_KEY_DATA_SIZE                      16
416 #define HIF_API_RX_MIC_KEY_SIZE                         8
417 #define HIF_API_TX_MIC_KEY_SIZE                         8
418 #define HIF_API_AES_KEY_DATA_SIZE                       16
419 #define HIF_API_WAPI_KEY_DATA_SIZE                      16
420 #define HIF_API_MIC_KEY_DATA_SIZE                       16
421 #define HIF_API_IGTK_KEY_DATA_SIZE                      16
422 #define HIF_API_RX_SEQUENCE_COUNTER_SIZE                8
423 #define HIF_API_IPN_SIZE                                8
424
425 enum hif_key_type {
426         HIF_KEY_TYPE_WEP_DEFAULT                   = 0x0,
427         HIF_KEY_TYPE_WEP_PAIRWISE                  = 0x1,
428         HIF_KEY_TYPE_TKIP_GROUP                    = 0x2,
429         HIF_KEY_TYPE_TKIP_PAIRWISE                 = 0x3,
430         HIF_KEY_TYPE_AES_GROUP                     = 0x4,
431         HIF_KEY_TYPE_AES_PAIRWISE                  = 0x5,
432         HIF_KEY_TYPE_WAPI_GROUP                    = 0x6,
433         HIF_KEY_TYPE_WAPI_PAIRWISE                 = 0x7,
434         HIF_KEY_TYPE_IGTK_GROUP                    = 0x8,
435         HIF_KEY_TYPE_NONE                          = 0x9
436 };
437
438 struct hif_wep_pairwise_key {
439         u8     peer_address[ETH_ALEN];
440         u8     reserved;
441         u8     key_length;
442         u8     key_data[HIF_API_WEP_KEY_DATA_SIZE];
443 } __packed;
444
445 struct hif_wep_group_key {
446         u8     key_id;
447         u8     key_length;
448         u8     reserved[2];
449         u8     key_data[HIF_API_WEP_KEY_DATA_SIZE];
450 } __packed;
451
452 struct hif_tkip_pairwise_key {
453         u8     peer_address[ETH_ALEN];
454         u8     reserved[2];
455         u8     tkip_key_data[HIF_API_TKIP_KEY_DATA_SIZE];
456         u8     rx_mic_key[HIF_API_RX_MIC_KEY_SIZE];
457         u8     tx_mic_key[HIF_API_TX_MIC_KEY_SIZE];
458 } __packed;
459
460 struct hif_tkip_group_key {
461         u8     tkip_key_data[HIF_API_TKIP_KEY_DATA_SIZE];
462         u8     rx_mic_key[HIF_API_RX_MIC_KEY_SIZE];
463         u8     key_id;
464         u8     reserved[3];
465         u8     rx_sequence_counter[HIF_API_RX_SEQUENCE_COUNTER_SIZE];
466 } __packed;
467
468 struct hif_aes_pairwise_key {
469         u8     peer_address[ETH_ALEN];
470         u8     reserved[2];
471         u8     aes_key_data[HIF_API_AES_KEY_DATA_SIZE];
472 } __packed;
473
474 struct hif_aes_group_key {
475         u8     aes_key_data[HIF_API_AES_KEY_DATA_SIZE];
476         u8     key_id;
477         u8     reserved[3];
478         u8     rx_sequence_counter[HIF_API_RX_SEQUENCE_COUNTER_SIZE];
479 } __packed;
480
481 struct hif_wapi_pairwise_key {
482         u8     peer_address[ETH_ALEN];
483         u8     key_id;
484         u8     reserved;
485         u8     wapi_key_data[HIF_API_WAPI_KEY_DATA_SIZE];
486         u8     mic_key_data[HIF_API_MIC_KEY_DATA_SIZE];
487 } __packed;
488
489 struct hif_wapi_group_key {
490         u8     wapi_key_data[HIF_API_WAPI_KEY_DATA_SIZE];
491         u8     mic_key_data[HIF_API_MIC_KEY_DATA_SIZE];
492         u8     key_id;
493         u8     reserved[3];
494 } __packed;
495
496 struct hif_igtk_group_key {
497         u8     igtk_key_data[HIF_API_IGTK_KEY_DATA_SIZE];
498         u8     key_id;
499         u8     reserved[3];
500         u8     ipn[HIF_API_IPN_SIZE];
501 } __packed;
502
503 union hif_privacy_key_data {
504         struct hif_wep_pairwise_key  wep_pairwise_key;
505         struct hif_wep_group_key     wep_group_key;
506         struct hif_tkip_pairwise_key tkip_pairwise_key;
507         struct hif_tkip_group_key    tkip_group_key;
508         struct hif_aes_pairwise_key  aes_pairwise_key;
509         struct hif_aes_group_key     aes_group_key;
510         struct hif_wapi_pairwise_key wapi_pairwise_key;
511         struct hif_wapi_group_key    wapi_group_key;
512         struct hif_igtk_group_key    igtk_group_key;
513 };
514
515 struct hif_req_add_key {
516         u8     type;
517         u8     entry_index;
518         u8     int_id:2;
519         u8     reserved1:6;
520         u8     reserved2;
521         union hif_privacy_key_data key;
522 } __packed;
523
524 struct hif_cnf_add_key {
525         __le32 status;
526 } __packed;
527
528 struct hif_req_remove_key {
529         u8     entry_index;
530         u8     reserved[3];
531 } __packed;
532
533 struct hif_cnf_remove_key {
534         __le32 status;
535 } __packed;
536
537 enum hif_event_ind {
538         HIF_EVENT_IND_BSSLOST                      = 0x1,
539         HIF_EVENT_IND_BSSREGAINED                  = 0x2,
540         HIF_EVENT_IND_RCPI_RSSI                    = 0x3,
541         HIF_EVENT_IND_PS_MODE_ERROR                = 0x4,
542         HIF_EVENT_IND_INACTIVITY                   = 0x5
543 };
544
545 enum hif_ps_mode_error {
546         HIF_PS_ERROR_NO_ERROR                      = 0,
547         HIF_PS_ERROR_AP_NOT_RESP_TO_POLL           = 1,
548         HIF_PS_ERROR_AP_NOT_RESP_TO_UAPSD_TRIGGER  = 2,
549         HIF_PS_ERROR_AP_SENT_UNICAST_IN_DOZE       = 3,
550         HIF_PS_ERROR_AP_NO_DATA_AFTER_TIM          = 4
551 };
552
553 union hif_event_data {
554         u8     rcpi_rssi;
555         __le32 ps_mode_error;
556         __le32 peer_sta_set;
557 };
558
559 struct hif_ind_event {
560         __le32 event_id;
561         union hif_event_data event_data;
562 } __packed;
563
564
565 #endif