net:wireless:Support eswin usb wifi ECR6600U
[platform/kernel/linux-starfive.git] / drivers / net / wireless / eswin / fullmac / ecrnx_defs.h
1 /**
2  ******************************************************************************
3  *
4  * @file ecrnx_defs.h
5  *
6  * @brief Main driver structure declarations for fullmac driver
7  *
8  * Copyright (C) ESWIN 2015-2020
9  *
10  ******************************************************************************
11  */
12
13 #ifndef _ECRNX_DEFS_H_
14 #define _ECRNX_DEFS_H_
15
16 #include <linux/interrupt.h>
17 #include <linux/device.h>
18 #include <linux/dmapool.h>
19 #include <linux/skbuff.h>
20 #include <net/cfg80211.h>
21 #include <linux/slab.h>
22 #include <linux/sched.h>
23 #include <linux/version.h>
24 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0))
25 #include <linux/vmalloc.h>
26 #include <linux/module.h>
27 #endif
28 #include "ecrnx_mod_params.h"
29 #include "ecrnx_debugfs.h"
30 #include "ecrnx_tx.h"
31 #include "ecrnx_rx.h"
32 #include "ecrnx_radar.h"
33 #include "ecrnx_utils.h"
34 #include "ecrnx_mu_group.h"
35 #include "ecrnx_platform.h"
36 #include "ecrnx_cmds.h"
37
38 #include "ecrnx_p2p.h"
39 #include "ecrnx_debug.h"
40 #include "ecrnx_cfgfile.h"
41
42
43 #define WPI_HDR_LEN    18
44 #define WPI_PN_LEN     16
45 #define WPI_PN_OFST     2
46 #define WPI_MIC_LEN    16
47 #define WPI_KEY_LEN    32
48 #define WPI_SUBKEY_LEN 16 // WPI key is actually two 16bytes key
49
50 #define LEGACY_PS_ID   0
51 #define UAPSD_ID       1
52
53 #define PS_SP_INTERRUPTED  255
54 #define ECRNX_RXSIZE       1024
55
56 #define CONFIG_ESWIN_RX_REORDER        1
57
58 #if defined(CONFIG_ECRNX_HE)
59 extern struct ieee80211_sta_he_cap ecrnx_he_cap;
60 #endif
61
62 /**
63  * struct ecrnx_bcn - Information of the beacon in used (AP mode)
64  *
65  * @head: head portion of beacon (before TIM IE)
66  * @tail: tail portion of beacon (after TIM IE)
67  * @ies: extra IEs (not used ?)
68  * @head_len: length of head data
69  * @tail_len: length of tail data
70  * @ies_len: length of extra IEs data
71  * @tim_len: length of TIM IE
72  * @len: Total beacon len (head + tim + tail + extra)
73  * @dtim: dtim period
74  */
75 struct ecrnx_bcn {
76     u8 *head;
77     u8 *tail;
78     u8 *ies;
79     size_t head_len;
80     size_t tail_len;
81     size_t ies_len;
82     size_t tim_len;
83     size_t len;
84     u8 dtim;
85 };
86
87 /**
88  * struct ecrnx_key - Key information
89  *
90  * @hw_idx: Idx of the key from hardware point of view
91  */
92 struct ecrnx_key {
93     u8 hw_idx;
94 };
95
96 /**
97  * Structure containing information about a Mesh Path
98  */
99 struct ecrnx_mesh_path {
100     struct list_head list;          /* For ecrnx_vif.mesh_paths */
101     u8 path_idx;                    /* Path Index */
102     struct mac_addr tgt_mac_addr;   /* Target MAC Address */
103     struct ecrnx_sta *nhop_sta;      /* Pointer to the Next Hop STA */
104 };
105
106 struct ecrnx_mesh_proxy {
107     struct list_head list;          /* For ecrnx_vif.mesh_proxy */
108     struct mac_addr ext_sta_addr;   /* Address of the External STA */
109     struct mac_addr proxy_addr;     /* Proxy MAC Address */
110     bool local;                     /* Indicate if interface is a proxy for the device */
111 };
112
113 /**
114  * struct ecrnx_csa - Information for CSA (Channel Switch Announcement)
115  *
116  * @vif: Pointer to the vif doing the CSA
117  * @bcn: Beacon to use after CSA
118  * @elem: IPC buffer to send the new beacon to the fw
119  * @chandef: defines the channel to use after the switch
120  * @count: Current csa counter
121  * @status: Status of the CSA at fw level
122  * @ch_idx: Index of the new channel context
123  * @work: work scheduled at the end of CSA
124  */
125 struct ecrnx_csa {
126     struct ecrnx_vif *vif;
127     struct ecrnx_bcn bcn;
128     struct ecrnx_ipc_elem_var elem;
129     struct cfg80211_chan_def chandef;
130     int count;
131     int status;
132     int ch_idx;
133     struct work_struct work;
134 };
135
136 /// Possible States of the TDLS link.
137 enum tdls_status_tag {
138         /// TDLS link is not active (no TDLS peer connected)
139         TDLS_LINK_IDLE,
140         /// TDLS Setup Request transmitted
141         TDLS_SETUP_REQ_TX,
142         /// TDLS Setup Response transmitted
143         TDLS_SETUP_RSP_TX,
144         /// TDLS link is active (TDLS peer connected)
145         TDLS_LINK_ACTIVE,
146         /// TDLS Max Number of states.
147         TDLS_STATE_MAX
148 };
149
150 /*
151  * Structure used to save information relative to the TDLS peer.
152  * This is also linked within the ecrnx_hw vifs list.
153  *
154  */
155 struct ecrnx_tdls {
156     bool active;                /* Indicate if TDLS link is active */
157     bool initiator;             /* Indicate if TDLS peer is the TDLS initiator */
158     bool chsw_en;               /* Indicate if channel switch is enabled */
159     u8 last_tid;                /* TID of the latest MPDU transmitted over the
160                                    TDLS direct link to the TDLS STA */
161     u16 last_sn;                /* Sequence number of the latest MPDU transmitted
162                                    over the TDLS direct link to the TDLS STA */
163     bool ps_on;                 /* Indicate if the power save is enabled on the
164                                    TDLS STA */
165     bool chsw_allowed;          /* Indicate if TDLS channel switch is allowed */
166 };
167
168
169 /**
170  * enum ecrnx_ap_flags - AP flags
171  *
172  * @ECRNX_AP_ISOLATE Isolate clients (i.e. Don't brige packets transmitted by
173  *                                   one client for another one)
174  */
175 enum ecrnx_ap_flags {
176     ECRNX_AP_ISOLATE = BIT(0),
177     ECRNX_AP_USER_MESH_PM = BIT(1),
178     ECRNX_AP_CREATE_MESH_PATH = BIT(2),
179 };
180
181 /**
182  * enum ecrnx_sta_flags - STATION flags
183  *
184  * @ECRNX_STA_EXT_AUTH: External authentication is in progress
185  */
186 enum ecrnx_sta_flags {
187     ECRNX_STA_EXT_AUTH = BIT(0),
188     ECRNX_STA_FT_OVER_DS = BIT(1),
189     ECRNX_STA_FT_OVER_AIR = BIT(2),
190 };
191
192 #ifdef CONFIG_ECRNX_WIFO_CAIL
193 /**
194  * struct ecrnx_iwpriv_amt_vif - iwpriv amt VIF information
195  *
196  * @ndev: Pointer to the associated net device
197  */
198 struct ecrnx_iwpriv_amt_vif {
199     struct net_device *ndev;
200
201     unsigned char   rxdata[ECRNX_RXSIZE];
202     int             rxlen;
203     wait_queue_head_t   rxdataq;
204     int                 rxdatas;
205 };
206 #endif
207
208 #define ECRNX_REORD_RX_MSDU_CNT      (256)
209 #define ECRNX_REORD_TIMEOUT          (50)
210 #define ECRNX_REORD_WINSIZE          (64)
211 #define SN_LESS(a, b)           (((a-b)&0x800)!=0)
212 #define SN_EQUAL(a, b)          (a == b)
213
214
215 struct reord_cntrl {
216     bool active;
217     bool valid;
218     u16 win_size;
219     u16 win_start;
220     struct ecrnx_hw *ecrnx_hw;
221     struct ecrnx_vif *ecrnx_vif;
222     spinlock_t reord_list_lock;
223     struct list_head reord_list;
224     struct timer_list reord_timer;
225     struct work_struct reord_timer_work;
226 };
227
228 struct reord_msdu_info {
229     struct sk_buff *skb;
230     u8 tid;
231     u8 need_pn_check;
232     u8 is_ga;
233     u16 sn;
234     struct hw_rxhdr *hw_rxhdr;
235     struct list_head reord_pending_list;
236     struct list_head rx_msdu_list;
237     struct reord_cntrl *preorder_ctrl;
238 };
239
240 /**
241  * struct ecrnx_vif - VIF information
242  *
243  * @list: List element for ecrnx_hw->vifs
244  * @ecrnx_hw: Pointer to driver main data
245  * @wdev: Wireless device
246  * @ndev: Pointer to the associated net device
247  * @net_stats: Stats structure for the net device
248  * @key: Conversion table between protocol key index and MACHW key index
249  * @drv_vif_index: VIF index at driver level (only use to identify active
250  * vifs in ecrnx_hw->avail_idx_map)
251  * @vif_index: VIF index at fw level (used to index ecrnx_hw->vif_table, and
252  * ecrnx_sta->vif_idx)
253  * @ch_index: Channel context index (within ecrnx_hw->chanctx_table)
254  * @up: Indicate if associated netdev is up (i.e. Interface is created at fw level)
255  * @use_4addr: Whether 4address mode should be use or not
256  * @is_resending: Whether a frame is being resent on this interface
257  * @roc_tdls: Indicate if the ROC has been called by a TDLS station
258  * @tdls_status: Status of the TDLS link
259  * @tdls_chsw_prohibited: Whether TDLS Channel Switch is prohibited or not
260  * @generation: Generation ID. Increased each time a sta is added/removed
261  *
262  * STA / P2P_CLIENT interfaces
263  * @flags: see ecrnx_sta_flags
264  * @ap: Pointer to the peer STA entry allocated for the AP
265  * @tdls_sta: Pointer to the TDLS station
266  * @ft_assoc_ies: Association Request Elements (only allocated for FT connection)
267  * @ft_assoc_ies_len: Size, in bytes, of the Association request elements.
268  * @ft_target_ap: Target AP for a BSS transition for FT over DS
269  *
270  * AP/P2P GO/ MESH POINT interfaces
271  * @flags: see ecrnx_ap_flags
272  * @sta_list: List of station connected to the interface
273  * @bcn: Beacon data
274  * @bcn_interval: beacon interval in TU
275  * @bcmc_index: Index of the BroadCast/MultiCast station
276  * @csa: Information about current Channel Switch Announcement (NULL if no CSA)
277  * @mpath_list: List of Mesh Paths (MESH Point only)
278  * @proxy_list: List of Proxies Information (MESH Point only)
279  * @mesh_pm: Mesh power save mode currently set in firmware
280  * @next_mesh_pm: Mesh power save mode for next peer
281  *
282  * AP_VLAN interfaces
283  * @mater: Pointer to the master interface
284  * @sta_4a: When AP_VLAN interface are used for WDS (i.e. wireless connection
285  * between several APs) this is the 'gateway' sta to 'master' AP
286  */
287 struct ecrnx_vif {
288     struct list_head list;
289     struct ecrnx_hw *ecrnx_hw;
290     struct wireless_dev wdev;
291     struct net_device *ndev;
292     struct net_device_stats net_stats;
293     struct ecrnx_key key[6];
294     u8 drv_vif_index;           /* Identifier of the VIF in driver */
295     u8 vif_index;               /* Identifier of the station in FW */
296     u8 ch_index;                /* Channel context identifier */
297     bool up;                    /* Indicate if associated netdev is up
298                                    (i.e. Interface is created at fw level) */
299     bool use_4addr;             /* Should we use 4addresses mode */
300     bool is_resending;          /* Indicate if a frame is being resent on this interface */
301     bool roc_tdls;              /* Indicate if the ROC has been called by a
302                                    TDLS station */
303     u8 tdls_status;             /* Status of the TDLS link */
304     bool tdls_chsw_prohibited;  /* Indicate if TDLS Channel Switch is prohibited */
305     int generation;
306
307     unsigned char   rxdata[ECRNX_RXSIZE];
308     int             rxlen;
309     wait_queue_head_t   rxdataq;
310     int                 rxdatas;
311
312         u32 mgmt_reg_stypes;    //GavinGao
313
314     union
315     {
316         struct
317         {
318             u32 flags;
319             struct ecrnx_sta *ap; /* Pointer to the peer STA entry allocated for
320                                     the AP */
321             struct ecrnx_sta *tdls_sta; /* Pointer to the TDLS station */
322             u8 *ft_assoc_ies;
323             int ft_assoc_ies_len;
324             u8 ft_target_ap[ETH_ALEN];
325         } sta;
326         struct
327         {
328             u32 flags;
329             struct list_head sta_list; /* List of STA connected to the AP */
330             struct ecrnx_bcn bcn;       /* beacon */
331             int bcn_interval;
332             u8 bcmc_index;             /* Index of the BCMC sta to use */
333             struct ecrnx_csa *csa;
334
335             struct list_head mpath_list; /* List of Mesh Paths used on this interface */
336             struct list_head proxy_list; /* List of Proxies Information used on this interface */
337
338 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
339             enum nl80211_mesh_power_mode mesh_pm; /* mesh power save mode currently set in firmware */
340             enum nl80211_mesh_power_mode next_mesh_pm; /* mesh power save mode for next peer */
341 #endif
342         } ap;
343         struct
344         {
345             struct ecrnx_vif *master;   /* pointer on master interface */
346             struct ecrnx_sta *sta_4a;
347         } ap_vlan;
348     };
349     uint64_t rx_pn[TID_MAX];
350 };
351
352 #define ECRNX_INVALID_VIF 0xFF
353 #define ECRNX_VIF_TYPE(vif) (vif->wdev.iftype)
354
355 /**
356  * Structure used to store information relative to PS mode.
357  *
358  * @active: True when the sta is in PS mode.
359  *          If false, other values should be ignored
360  * @pkt_ready: Number of packets buffered for the sta in drv's txq
361  *             (1 counter for Legacy PS and 1 for U-APSD)
362  * @sp_cnt: Number of packets that remain to be pushed in the service period.
363  *          0 means that no service period is in progress
364  *          (1 counter for Legacy PS and 1 for U-APSD)
365  */
366 struct ecrnx_sta_ps {
367     bool active;
368     u16 pkt_ready[2];
369     u16 sp_cnt[2];
370 };
371
372 /**
373  * struct ecrnx_rx_rate_stats - Store statistics for RX rates
374  *
375  * @table: Table indicating how many frame has been receive which each
376  * rate index. Rate index is the same as the one used by RC algo for TX
377  * @size: Size of the table array
378  * @cpt: number of frames received
379  */
380 struct ecrnx_rx_rate_stats {
381     int *table;
382     int size;
383     int cpt;
384     int rate_cnt;
385 };
386
387 /**
388  * struct ecrnx_sta_stats - Structure Used to store statistics specific to a STA
389  *
390  * @last_rx: Hardware vector of the last received frame
391  * @rx_rate: Statistics of the received rates
392  */
393 struct ecrnx_sta_stats {
394     u32 rx_pkts;
395     u32 tx_pkts;
396     u64 rx_bytes;
397     u64 tx_bytes;
398     unsigned long last_act;
399     struct hw_vect last_rx;
400 #ifdef CONFIG_ECRNX_DEBUGFS
401     struct ecrnx_rx_rate_stats rx_rate;
402 #endif
403 };
404
405 /*
406  * Structure used to save information relative to the managed stations.
407  */
408 struct ecrnx_sta {
409     struct list_head list;
410     bool valid;
411     u8 mac_addr[ETH_ALEN];
412     u16 aid;                /* association ID */
413     u8 sta_idx;             /* Identifier of the station */
414     u8 vif_idx;             /* Identifier of the VIF (fw id) the station
415                                belongs to */
416     u8 vlan_idx;            /* Identifier of the VLAN VIF (fw id) the station
417                                belongs to (= vif_idx if no vlan in used) */
418     enum nl80211_band band; /* Band */
419     enum nl80211_chan_width width; /* Channel width */
420     u16 center_freq;        /* Center frequency */
421     u32 center_freq1;       /* Center frequency 1 */
422     u32 center_freq2;       /* Center frequency 2 */
423     u8 ch_idx;              /* Identifier of the channel
424                                context the station belongs to */
425     bool qos;               /* Flag indicating if the station
426                                supports QoS */
427     u8 acm;                 /* Bitfield indicating which queues
428                                have AC mandatory */
429     u16 uapsd_tids;         /* Bitfield indicating which tids are subject to
430                                UAPSD */
431     struct ecrnx_key key;
432     struct ecrnx_sta_ps ps;  /* Information when STA is in PS (AP only) */
433 #ifdef CONFIG_ECRNX_BFMER
434     struct ecrnx_bfmer_report *bfm_report;     /* Beamforming report to be used for
435                                                  VHT TX Beamforming */
436 #ifdef CONFIG_ECRNX_MUMIMO_TX
437     struct ecrnx_sta_group_info group_info; /* MU grouping information for the STA */
438 #endif /* CONFIG_ECRNX_MUMIMO_TX */
439 #endif /* CONFIG_ECRNX_BFMER */
440
441     bool ht;               /* Flag indicating if the station
442                                supports HT */
443     bool vht;               /* Flag indicating if the station
444                                supports VHT */
445     u32 ac_param[AC_MAX];  /* EDCA parameters */
446     struct ecrnx_tdls tdls; /* TDLS station information */
447     struct ecrnx_sta_stats stats;
448 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
449     enum nl80211_mesh_power_mode mesh_pm; /*  link-specific mesh power save mode */
450 #endif
451     int listen_interval;
452     struct twt_setup_ind twt_ind; /*TWT Setup indication*/
453     uint64_t rx_pn[TID_MAX];
454     struct reord_cntrl reord_cntrl[TID_MAX];
455 };
456
457 #define ECRNX_INVALID_STA 0xFF
458 static inline const u8 *ecrnx_sta_addr(struct ecrnx_sta *sta) {
459     return sta->mac_addr;
460 }
461
462 #ifdef CONFIG_ECRNX_SPLIT_TX_BUF
463 struct ecrnx_amsdu_stats {
464     int done;
465     int failed;
466 };
467 #endif
468
469 struct ecrnx_stats {
470     int cfm_balance[NX_TXQ_CNT];
471     unsigned long last_rx, last_tx; /* jiffies */
472     int ampdus_tx[IEEE80211_MAX_AMPDU_BUF];
473     int ampdus_rx[IEEE80211_MAX_AMPDU_BUF];
474     int ampdus_rx_map[4];
475     int ampdus_rx_miss;
476     int ampdus_rx_last;
477 #ifdef CONFIG_ECRNX_SPLIT_TX_BUF
478     struct ecrnx_amsdu_stats amsdus[NX_TX_PAYLOAD_MAX];
479 #endif
480     int amsdus_rx[64];
481 };
482
483 /**
484  * struct ecrnx_roc - Remain On Channel information
485  *
486
487  Structure that will contains all RoC information received from cfg80211 */
488 struct ecrnx_roc {
489     struct ecrnx_vif *vif;
490     struct ieee80211_channel *chan;
491     unsigned int duration;
492     /* Used to avoid call of CFG80211 callback upon expiration of RoC */
493     bool internal;
494     /* Indicate if we have switch on the RoC channel */
495     bool on_chan;
496 };
497
498 /* Structure containing channel survey information received from MAC */
499 struct ecrnx_survey_info {
500     // Filled
501     u32 filled;
502     // Amount of time in ms the radio spent on the channel
503     u32 chan_time_ms;
504     // Amount of time the primary channel was sensed busy
505     u32 chan_time_busy_ms;
506     // Noise in dbm
507     s8 noise_dbm;
508 };
509
510
511 /* Structure containing channel context information */
512 struct ecrnx_chanctx {
513     struct cfg80211_chan_def chan_def; /* channel description */
514     u8 count;                          /* number of vif using this ctxt */
515 };
516
517 #define ECRNX_CH_NOT_SET 0xFF
518 /**
519  * ecrnx_phy_info - Phy information
520  *
521  * @phy_cnt: Number of phy interface
522  * @cfg: Configuration send to firmware
523  * @sec_chan: Channel configuration of the second phy interface (if phy_cnt > 1)
524  * @limit_bw: Set to true to limit BW on requested channel. Only set to use
525  * VHT with old radio that don't support 80MHz (deprecated)
526  */
527 struct ecrnx_phy_info {
528     u8 cnt;
529     struct phy_cfg_tag cfg;
530     struct mac_chan_op sec_chan;
531     bool limit_bw;
532 };
533
534 struct ecrnx_hw {
535     struct device *dev;
536          // Hardware info
537
538 #ifdef CONFIG_ECRNX_ESWIN
539     void *plat;
540 #else
541     struct ecrnx_plat *plat;
542 #endif
543
544     struct ecrnx_phy_info phy;
545     struct mm_version_cfm version_cfm;
546     int machw_type;
547     struct ecrnx_mod_params *mod_params;
548     unsigned long flags;
549     struct wiphy *wiphy;
550     u8 ext_capa[10];
551     struct list_head vifs;
552     struct ecrnx_vif *vif_table[NX_VIRT_DEV_MAX + NX_REMOTE_STA_MAX]; /* indexed with fw id */
553     u8 vif_started;
554     u8 avail_idx_map;
555     u8 monitor_vif;
556     struct ecrnx_sta sta_table[NX_REMOTE_STA_MAX + NX_VIRT_DEV_MAX];
557
558     // Channels
559     struct ecrnx_chanctx chanctx_table[NX_CHAN_CTXT_CNT];
560     u8 cur_chanctx;
561     struct ecrnx_survey_info survey[SCAN_CHANNEL_MAX];
562
563     /* RoC Management */
564     struct ecrnx_roc *roc;
565     u32 roc_cookie;
566     struct cfg80211_scan_request *scan_request;
567     spinlock_t scan_req_lock;
568     spinlock_t connect_req_lock;
569     struct ecrnx_radar radar;
570         
571 #ifdef CONFIG_ECRNX_P2P
572         struct ecrnx_p2p_listen p2p_listen;
573 #endif
574
575     // TX path
576     spinlock_t tx_lock;
577     struct ecrnx_txq txq[NX_NB_TXQ];
578     struct ecrnx_hwq hwq[NX_TXQ_CNT];
579     struct timer_list txq_cleanup;
580     struct kmem_cache *sw_txhdr_cache;
581     u32 tcp_pacing_shift;
582 #ifdef CONFIG_ECRNX_MUMIMO_TX
583     struct ecrnx_mu_info mu;
584 #endif
585
586     // RX path
587     struct ecrnx_defer_rx defer_rx;
588     spinlock_t rx_lock;
589
590     struct tasklet_struct task;
591
592
593     /* IPC */
594     struct ipc_host_env_tag *ipc_env;
595     struct ecrnx_cmd_mgr cmd_mgr;
596     spinlock_t cb_lock;
597     struct ecrnx_ipc_elem_pool e2amsgs_pool;
598     struct ecrnx_ipc_elem_pool dbgmsgs_pool;
599     struct ecrnx_ipc_elem_pool e2aradars_pool;
600     struct ecrnx_ipc_elem_var pattern_elem;
601     struct ecrnx_ipc_dbgdump_elem dbgdump_elem;
602     struct ecrnx_ipc_elem_pool e2arxdesc_pool;
603     struct ecrnx_ipc_skb_elem *e2aunsuprxvec_elems;
604     struct ecrnx_ipc_rxbuf_elems rxbuf_elems;
605     struct ecrnx_ipc_elem_var scan_ie;
606     
607 #ifdef CONFIG_ECRNX_DEBUGFS
608     struct ecrnx_debugfs     debugfs;
609 #endif
610
611     struct ecrnx_stats       stats;
612     struct ecrnx_conf_file   conf_param;
613
614 #ifdef CONFIG_ECRNX_ESWIN
615         struct list_head agg_rx_list;
616         struct list_head defrag_rx_list;
617 #endif
618 #ifdef CONFIG_ESWIN_RX_REORDER
619     spinlock_t rx_msdu_free_lock;
620     struct list_head rx_msdu_free_list;
621     struct list_head rx_reord_list;
622     spinlock_t rx_reord_lock;
623     struct reord_msdu_info * rx_reord_buf;
624 #endif
625
626     /* extended capabilities supported */
627 #if defined(CONFIG_ECRNX_DEBUGFS_CUSTOM)
628         struct list_head debugfs_survey_info_tbl_ptr;
629 #endif
630     u32 msg_tx;
631     u32 msg_tx_done;
632     u32 data_tx;
633     u32 data_tx_done;
634     u32 usb_rx;
635     u32 msg_rx;
636     u32 data_rx;
637 };
638
639 u8 *ecrnx_build_bcn(struct ecrnx_bcn *bcn, struct cfg80211_beacon_data *new);
640
641 void ecrnx_chanctx_link(struct ecrnx_vif *vif, u8 idx,
642                         struct cfg80211_chan_def *chandef);
643 void ecrnx_chanctx_unlink(struct ecrnx_vif *vif);
644 int  ecrnx_chanctx_valid(struct ecrnx_hw *ecrnx_hw, u8 idx);
645
646 static inline bool is_multicast_sta(int sta_idx)
647 {
648     return (sta_idx >= NX_REMOTE_STA_MAX);
649 }
650 struct ecrnx_sta *ecrnx_get_sta(struct ecrnx_hw *ecrnx_hw, const u8 *mac_addr);
651
652 static inline uint8_t master_vif_idx(struct ecrnx_vif *vif)
653 {
654     if (unlikely(vif->wdev.iftype == NL80211_IFTYPE_AP_VLAN)) {
655         return vif->ap_vlan.master->vif_index;
656     } else {
657         return vif->vif_index;
658     }
659 }
660
661 static inline void *ecrnx_get_shared_trace_buf(struct ecrnx_hw *ecrnx_hw)
662 {
663 #ifdef CONFIG_ECRNX_DEBUGFS
664     return (void *)&(ecrnx_hw->debugfs.fw_trace.buf);
665 #else
666     return NULL;
667 #endif
668 }
669
670 void ecrnx_external_auth_enable(struct ecrnx_vif *vif);
671 void ecrnx_external_auth_disable(struct ecrnx_vif *vif);
672
673
674 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0)
675 /* 802.11ax HE MAC capabilities */
676 #define IEEE80211_HE_MAC_CAP0_HTC_HE                            0x01
677 #define IEEE80211_HE_MAC_CAP0_TWT_REQ                           0x02
678 #define IEEE80211_HE_MAC_CAP0_TWT_RES                           0x04
679 #define IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_NOT_SUPP             0x00
680 #define IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_LEVEL_1              0x08
681 #define IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_LEVEL_2              0x10
682 #define IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_LEVEL_3              0x18
683 #define IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_MASK                 0x18
684 #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_1               0x00
685 #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_2               0x20
686 #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_4               0x40
687 #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_8               0x60
688 #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_16              0x80
689 #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_32              0xa0
690 #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_64              0xc0
691 #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_UNLIMITED       0xe0
692 #define IEEE80211_HE_MAC_CAP0_MAX_NUM_FRAG_MSDU_MASK            0xe0
693
694 #define IEEE80211_HE_MAC_CAP1_MIN_FRAG_SIZE_UNLIMITED           0x00
695 #define IEEE80211_HE_MAC_CAP1_MIN_FRAG_SIZE_128                 0x01
696 #define IEEE80211_HE_MAC_CAP1_MIN_FRAG_SIZE_256                 0x02
697 #define IEEE80211_HE_MAC_CAP1_MIN_FRAG_SIZE_512                 0x03
698 #define IEEE80211_HE_MAC_CAP1_MIN_FRAG_SIZE_MASK                0x03
699 #define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_0US                0x00
700 #define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_8US                0x04
701 #define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US               0x08
702 #define IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_MASK               0x0c
703 #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_1            0x00
704 #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_2            0x10
705 #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_3            0x20
706 #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_4            0x30
707 #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_5            0x40
708 #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_6            0x50
709 #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_7            0x60
710 #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_8            0x70
711 #define IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_MASK         0x70
712
713 /* Link adaptation is split between byte HE_MAC_CAP1 and
714  * HE_MAC_CAP2. It should be set only if IEEE80211_HE_MAC_CAP0_HTC_HE
715  * in which case the following values apply:
716  * 0 = No feedback.
717  * 1 = reserved.
718  * 2 = Unsolicited feedback.
719  * 3 = both
720  */
721 #define IEEE80211_HE_MAC_CAP1_LINK_ADAPTATION                   0x80
722
723 #define IEEE80211_HE_MAC_CAP2_LINK_ADAPTATION                   0x01
724 #define IEEE80211_HE_MAC_CAP2_ALL_ACK                           0x02
725 #define IEEE80211_HE_MAC_CAP2_TRS                               0x04
726 #define IEEE80211_HE_MAC_CAP2_BSR                               0x08
727 #define IEEE80211_HE_MAC_CAP2_BCAST_TWT                         0x10
728 #define IEEE80211_HE_MAC_CAP2_32BIT_BA_BITMAP                   0x20
729 #define IEEE80211_HE_MAC_CAP2_MU_CASCADING                      0x40
730 #define IEEE80211_HE_MAC_CAP2_ACK_EN                            0x80
731
732 #define IEEE80211_HE_MAC_CAP3_OMI_CONTROL                       0x02
733 #define IEEE80211_HE_MAC_CAP3_OFDMA_RA                          0x04
734
735 /* The maximum length of an A-MDPU is defined by the combination of the Maximum
736  * A-MDPU Length Exponent field in the HT capabilities, VHT capabilities and the
737  * same field in the HE capabilities.
738  */
739 #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_USE_VHT 0x00
740 #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_VHT_1           0x08
741 #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_VHT_2           0x10
742 #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_RESERVED        0x18
743 #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_MASK            0x18
744 #define IEEE80211_HE_MAC_CAP3_AMSDU_FRAG                        0x20
745 #define IEEE80211_HE_MAC_CAP3_FLEX_TWT_SCHED                    0x40
746 #define IEEE80211_HE_MAC_CAP3_RX_CTRL_FRAME_TO_MULTIBSS         0x80
747
748 #define IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_SHIFT           3
749
750 #define IEEE80211_HE_MAC_CAP4_BSRP_BQRP_A_MPDU_AGG              0x01
751 #define IEEE80211_HE_MAC_CAP4_QTP                               0x02
752 #define IEEE80211_HE_MAC_CAP4_BQR                               0x04
753 #define IEEE80211_HE_MAC_CAP4_SRP_RESP                          0x08
754 #define IEEE80211_HE_MAC_CAP4_NDP_FB_REP                        0x10
755 #define IEEE80211_HE_MAC_CAP4_OPS                               0x20
756 #define IEEE80211_HE_MAC_CAP4_AMDSU_IN_AMPDU                    0x40
757 /* Multi TID agg TX is split between byte #4 and #5
758  * The value is a combination of B39,B40,B41
759  */
760 #define IEEE80211_HE_MAC_CAP4_MULTI_TID_AGG_TX_QOS_B39          0x80
761
762 #define IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B40          0x01
763 #define IEEE80211_HE_MAC_CAP5_MULTI_TID_AGG_TX_QOS_B41          0x02
764 #define IEEE80211_HE_MAC_CAP5_SUBCHAN_SELECVITE_TRANSMISSION    0x04
765 #define IEEE80211_HE_MAC_CAP5_UL_2x996_TONE_RU                  0x08
766 #define IEEE80211_HE_MAC_CAP5_OM_CTRL_UL_MU_DATA_DIS_RX         0x10
767 #define IEEE80211_HE_MAC_CAP5_HE_DYNAMIC_SM_PS                  0x20
768 #define IEEE80211_HE_MAC_CAP5_PUNCTURED_SOUNDING                0x40
769 #define IEEE80211_HE_MAC_CAP5_HT_VHT_TRIG_FRAME_RX              0x80
770
771 #define IEEE80211_HE_VHT_MAX_AMPDU_FACTOR       20
772 #define IEEE80211_HE_HT_MAX_AMPDU_FACTOR        16
773
774 /* 802.11ax HE PHY capabilities */
775 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G             0x02
776 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G       0x04
777 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G            0x08
778 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G      0x10
779 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_2G        0x20
780 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G        0x40
781 #define IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_MASK                    0xfe
782
783 #define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_80MHZ_ONLY_SECOND_20MHZ  0x01
784 #define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_80MHZ_ONLY_SECOND_40MHZ  0x02
785 #define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_160MHZ_ONLY_SECOND_20MHZ 0x04
786 #define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_160MHZ_ONLY_SECOND_40MHZ 0x08
787 #define IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_MASK                     0x0f
788 #define IEEE80211_HE_PHY_CAP1_DEVICE_CLASS_A                            0x10
789 #define IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD                    0x20
790 #define IEEE80211_HE_PHY_CAP1_HE_LTF_AND_GI_FOR_HE_PPDUS_0_8US          0x40
791 /* Midamble RX/TX Max NSTS is split between byte #2 and byte #3 */
792 #define IEEE80211_HE_PHY_CAP1_MIDAMBLE_RX_TX_MAX_NSTS                   0x80
793
794 #define IEEE80211_HE_PHY_CAP2_MIDAMBLE_RX_TX_MAX_NSTS                   0x01
795 #define IEEE80211_HE_PHY_CAP2_NDP_4x_LTF_AND_3_2US                      0x02
796 #define IEEE80211_HE_PHY_CAP2_STBC_TX_UNDER_80MHZ                       0x04
797 #define IEEE80211_HE_PHY_CAP2_STBC_RX_UNDER_80MHZ                       0x08
798 #define IEEE80211_HE_PHY_CAP2_DOPPLER_TX                                0x10
799 #define IEEE80211_HE_PHY_CAP2_DOPPLER_RX                                0x20
800
801 /* Note that the meaning of UL MU below is different between an AP and a non-AP
802  * sta, where in the AP case it indicates support for Rx and in the non-AP sta
803  * case it indicates support for Tx.
804  */
805 #define IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO                        0x40
806 #define IEEE80211_HE_PHY_CAP2_UL_MU_PARTIAL_MU_MIMO                     0x80
807
808 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_NO_DCM                   0x00
809 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_BPSK                     0x01
810 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_QPSK                     0x02
811 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_16_QAM                   0x03
812 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_MASK                     0x03
813 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_1                          0x00
814 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_TX_NSS_2                          0x04
815 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_NO_DCM                   0x00
816 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_BPSK                     0x08
817 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_QPSK                     0x10
818 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_16_QAM                   0x18
819 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_MASK                     0x18
820 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_1                          0x00
821 #define IEEE80211_HE_PHY_CAP3_DCM_MAX_RX_NSS_2                          0x20
822 #define IEEE80211_HE_PHY_CAP3_RX_HE_MU_PPDU_FROM_NON_AP_STA             0x40
823 #define IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER                             0x80
824
825 #define IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE                             0x01
826 #define IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER                             0x02
827
828 /* Minimal allowed value of Max STS under 80MHz is 3 */
829 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_4          0x0c
830 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_5          0x10
831 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_6          0x14
832 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_7          0x18
833 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_8          0x1c
834 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_UNDER_80MHZ_MASK       0x1c
835
836 /* Minimal allowed value of Max STS above 80MHz is 3 */
837 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_4          0x60
838 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_5          0x80
839 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_6          0xa0
840 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_7          0xc0
841 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_8          0xe0
842 #define IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_MASK       0xe0
843
844 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_1      0x00
845 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_2      0x01
846 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_3      0x02
847 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_4      0x03
848 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_5      0x04
849 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_6      0x05
850 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_7      0x06
851 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_8      0x07
852 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK   0x07
853
854 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_1      0x00
855 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_2      0x08
856 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_3      0x10
857 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_4      0x18
858 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_5      0x20
859 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_6      0x28
860 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_7      0x30
861 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_8      0x38
862 #define IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_MASK   0x38
863
864 #define IEEE80211_HE_PHY_CAP5_NG16_SU_FEEDBACK                          0x40
865 #define IEEE80211_HE_PHY_CAP5_NG16_MU_FEEDBACK                          0x80
866
867 #define IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_42_SU                       0x01
868 #define IEEE80211_HE_PHY_CAP6_CODEBOOK_SIZE_75_MU                       0x02
869 #define IEEE80211_HE_PHY_CAP6_TRIG_SU_BEAMFORMER_FB                     0x04
870 #define IEEE80211_HE_PHY_CAP6_TRIG_MU_BEAMFORMER_FB                     0x08
871 #define IEEE80211_HE_PHY_CAP6_TRIG_CQI_FB                               0x10
872 #define IEEE80211_HE_PHY_CAP6_PARTIAL_BW_EXT_RANGE                      0x20
873 #define IEEE80211_HE_PHY_CAP6_PARTIAL_BANDWIDTH_DL_MUMIMO               0x40
874 #define IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT                     0x80
875
876 #define IEEE80211_HE_PHY_CAP7_SRP_BASED_SR                              0x01
877 #define IEEE80211_HE_PHY_CAP7_POWER_BOOST_FACTOR_AR                     0x02
878 #define IEEE80211_HE_PHY_CAP7_HE_SU_MU_PPDU_4XLTF_AND_08_US_GI          0x04
879 #define IEEE80211_HE_PHY_CAP7_MAX_NC_1                                  0x08
880 #define IEEE80211_HE_PHY_CAP7_MAX_NC_2                                  0x10
881 #define IEEE80211_HE_PHY_CAP7_MAX_NC_3                                  0x18
882 #define IEEE80211_HE_PHY_CAP7_MAX_NC_4                                  0x20
883 #define IEEE80211_HE_PHY_CAP7_MAX_NC_5                                  0x28
884 #define IEEE80211_HE_PHY_CAP7_MAX_NC_6                                  0x30
885 #define IEEE80211_HE_PHY_CAP7_MAX_NC_7                                  0x38
886 #define IEEE80211_HE_PHY_CAP7_MAX_NC_MASK                               0x38
887 #define IEEE80211_HE_PHY_CAP7_STBC_TX_ABOVE_80MHZ                       0x40
888 #define IEEE80211_HE_PHY_CAP7_STBC_RX_ABOVE_80MHZ                       0x80
889
890 #define IEEE80211_HE_PHY_CAP8_HE_ER_SU_PPDU_4XLTF_AND_08_US_GI          0x01
891 #define IEEE80211_HE_PHY_CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G              0x02
892 #define IEEE80211_HE_PHY_CAP8_20MHZ_IN_160MHZ_HE_PPDU                   0x04
893 #define IEEE80211_HE_PHY_CAP8_80MHZ_IN_160MHZ_HE_PPDU                   0x08
894 #define IEEE80211_HE_PHY_CAP8_HE_ER_SU_1XLTF_AND_08_US_GI               0x10
895 #define IEEE80211_HE_PHY_CAP8_MIDAMBLE_RX_TX_2X_AND_1XLTF               0x20
896 #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_242                            0x00
897 #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_484                            0x40
898 #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_996                            0x80
899 #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_2x996                          0xc0
900 #define IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK                           0xc0
901
902 #define IEEE80211_HE_PHY_CAP9_LONGER_THAN_16_SIGB_OFDM_SYM              0x01
903 #define IEEE80211_HE_PHY_CAP9_NON_TRIGGERED_CQI_FEEDBACK                0x02
904 #define IEEE80211_HE_PHY_CAP9_TX_1024_QAM_LESS_THAN_242_TONE_RU         0x04
905 #define IEEE80211_HE_PHY_CAP9_RX_1024_QAM_LESS_THAN_242_TONE_RU         0x08
906
907 /* 802.11ax HE TX/RX MCS NSS Support  */
908 #define IEEE80211_TX_RX_MCS_NSS_SUPP_HIGHEST_MCS_POS                    (3)
909 #define IEEE80211_TX_RX_MCS_NSS_SUPP_TX_BITMAP_POS                      (6)
910 #define IEEE80211_TX_RX_MCS_NSS_SUPP_RX_BITMAP_POS                      (11)
911 #define IEEE80211_TX_RX_MCS_NSS_SUPP_TX_BITMAP_MASK                     0x07c0
912 #define IEEE80211_TX_RX_MCS_NSS_SUPP_RX_BITMAP_MASK                     0xf800
913
914
915 /* TX/RX HE MCS Support field Highest MCS subfield encoding */
916 enum ieee80211_he_highest_mcs_supported_subfield_enc {
917         HIGHEST_MCS_SUPPORTED_MCS7 = 0,
918         HIGHEST_MCS_SUPPORTED_MCS8,
919         HIGHEST_MCS_SUPPORTED_MCS9,
920         HIGHEST_MCS_SUPPORTED_MCS10,
921         HIGHEST_MCS_SUPPORTED_MCS11,
922 };
923
924 #define IEEE80211_HE_PPE_THRES_MAX_LEN          25
925
926 /**
927  * struct ieee80211_he_mcs_nss_supp - HE Tx/Rx HE MCS NSS Support Field
928  *
929  * This structure holds the data required for the Tx/Rx HE MCS NSS Support Field
930  * described in P802.11ax_D2.0 section 9.4.2.237.4
931  *
932  * @rx_mcs_80: Rx MCS map 2 bits for each stream, total 8 streams, for channel
933  *     widths less than 80MHz.
934  * @tx_mcs_80: Tx MCS map 2 bits for each stream, total 8 streams, for channel
935  *     widths less than 80MHz.
936  * @rx_mcs_160: Rx MCS map 2 bits for each stream, total 8 streams, for channel
937  *     width 160MHz.
938  * @tx_mcs_160: Tx MCS map 2 bits for each stream, total 8 streams, for channel
939  *     width 160MHz.
940  * @rx_mcs_80p80: Rx MCS map 2 bits for each stream, total 8 streams, for
941  *     channel width 80p80MHz.
942  * @tx_mcs_80p80: Tx MCS map 2 bits for each stream, total 8 streams, for
943  *     channel width 80p80MHz.
944  */
945 struct ieee80211_he_mcs_nss_supp {
946         __le16 rx_mcs_80;
947         __le16 tx_mcs_80;
948         __le16 rx_mcs_160;
949         __le16 tx_mcs_160;
950         __le16 rx_mcs_80p80;
951         __le16 tx_mcs_80p80;
952 } __packed;
953
954 /**
955  * struct ieee80211_he_cap_elem - HE capabilities element
956  *
957  * This structure is the "HE capabilities element" fixed fields as
958  * described in P802.11ax_D2.0 section 9.4.2.237.2 and 9.4.2.237.3
959  */
960 struct ieee80211_he_cap_elem {
961         u8 mac_cap_info[6];
962         u8 phy_cap_info[11];
963 } __packed;
964
965 /**
966  * struct ieee80211_sta_he_cap - STA's HE capabilities
967  *
968  * This structure describes most essential parameters needed
969  * to describe 802.11ax HE capabilities for a STA.
970  *
971  * @has_he: true iff HE data is valid.
972  * @he_cap_elem: Fixed portion of the HE capabilities element.
973  * @he_mcs_nss_supp: The supported NSS/MCS combinations.
974  * @ppe_thres: Holds the PPE Thresholds data.
975  */
976 struct ieee80211_sta_he_cap {
977         bool has_he;
978         struct ieee80211_he_cap_elem he_cap_elem;
979         struct ieee80211_he_mcs_nss_supp he_mcs_nss_supp;
980         u8 ppe_thres[IEEE80211_HE_PPE_THRES_MAX_LEN];
981 };
982
983 #endif
984
985 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
986 #define IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_COMP_SIGB     0x10
987 #define IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_NON_COMP_SIGB 0x20
988 #define IEEE80211_HE_PHY_CAP9_NOMIMAL_PKT_PADDING_0US                   0x00
989 #define IEEE80211_HE_PHY_CAP9_NOMIMAL_PKT_PADDING_8US                   0x40
990 #define IEEE80211_HE_PHY_CAP9_NOMIMAL_PKT_PADDING_16US                  0x80
991 #define IEEE80211_HE_PHY_CAP9_NOMIMAL_PKT_PADDING_RESERVED              0xc0
992 #define IEEE80211_HE_PHY_CAP9_NOMIMAL_PKT_PADDING_MASK                  0xc0
993 #endif
994
995
996 #if defined(CONFIG_ECRNX_HE)
997 extern struct ieee80211_sta_he_cap ecrnx_he_cap;
998 #endif
999
1000 #define RW_DRV_DESCRIPTION  "ESWIN 11nac driver for Linux cfg80211"
1001 #define RW_DRV_COPYRIGHT    "Copyright(c) 2015-2017 ESWIN"
1002 #define RW_DRV_AUTHOR       "ESWIN S.A.S"
1003
1004 #define ECRNX_PRINT_CFM_ERR(req) \
1005         printk(KERN_CRIT "%s: Status Error(%d)\n", #req, (&req##_cfm)->status)
1006
1007 #define ECRNX_HT_CAPABILITIES                                    \
1008 {                                                               \
1009     .ht_supported   = true,                                     \
1010     .cap            = 0,                                        \
1011     .ampdu_factor   = IEEE80211_HT_MAX_AMPDU_64K,               \
1012     .ampdu_density  = IEEE80211_HT_MPDU_DENSITY_16,             \
1013     .mcs        = {                                             \
1014         .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },        \
1015         .rx_highest = cpu_to_le16(65),                          \
1016         .tx_params = IEEE80211_HT_MCS_TX_DEFINED,               \
1017     },                                                          \
1018 }
1019
1020 #define ECRNX_VHT_CAPABILITIES                                   \
1021 {                                                               \
1022     .vht_supported = false,                                     \
1023     .cap       =                                                \
1024       (7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT),\
1025     .vht_mcs       = {                                          \
1026         .rx_mcs_map = cpu_to_le16(                              \
1027                       IEEE80211_VHT_MCS_SUPPORT_0_9    << 0  |  \
1028                       IEEE80211_VHT_MCS_NOT_SUPPORTED  << 2  |  \
1029                       IEEE80211_VHT_MCS_NOT_SUPPORTED  << 4  |  \
1030                       IEEE80211_VHT_MCS_NOT_SUPPORTED  << 6  |  \
1031                       IEEE80211_VHT_MCS_NOT_SUPPORTED  << 8  |  \
1032                       IEEE80211_VHT_MCS_NOT_SUPPORTED  << 10 |  \
1033                       IEEE80211_VHT_MCS_NOT_SUPPORTED  << 12 |  \
1034                       IEEE80211_VHT_MCS_NOT_SUPPORTED  << 14),  \
1035         .tx_mcs_map = cpu_to_le16(                              \
1036                       IEEE80211_VHT_MCS_SUPPORT_0_9    << 0  |  \
1037                       IEEE80211_VHT_MCS_NOT_SUPPORTED  << 2  |  \
1038                       IEEE80211_VHT_MCS_NOT_SUPPORTED  << 4  |  \
1039                       IEEE80211_VHT_MCS_NOT_SUPPORTED  << 6  |  \
1040                       IEEE80211_VHT_MCS_NOT_SUPPORTED  << 8  |  \
1041                       IEEE80211_VHT_MCS_NOT_SUPPORTED  << 10 |  \
1042                       IEEE80211_VHT_MCS_NOT_SUPPORTED  << 12 |  \
1043                       IEEE80211_VHT_MCS_NOT_SUPPORTED  << 14),  \
1044     }                                                           \
1045 }
1046
1047 #if CONFIG_ECRNX_HE
1048 #define ECRNX_HE_CAPABILITIES                                    \
1049 {                                                               \
1050     .has_he = false,                                            \
1051     .he_cap_elem = {                                            \
1052         .mac_cap_info[0] = 0,                                   \
1053         .mac_cap_info[1] = 0,                                   \
1054         .mac_cap_info[2] = 0,                                   \
1055         .mac_cap_info[3] = 0,                                   \
1056         .mac_cap_info[4] = 0,                                   \
1057         .mac_cap_info[5] = 0,                                   \
1058         .phy_cap_info[0] = 0,                                   \
1059         .phy_cap_info[1] = 0,                                   \
1060         .phy_cap_info[2] = 0,                                   \
1061         .phy_cap_info[3] = 0,                                   \
1062         .phy_cap_info[4] = 0,                                   \
1063         .phy_cap_info[5] = 0,                                   \
1064         .phy_cap_info[6] = 0,                                   \
1065         .phy_cap_info[7] = 0,                                   \
1066         .phy_cap_info[8] = 0,                                   \
1067         .phy_cap_info[9] = 0,                                   \
1068         .phy_cap_info[10] = 0,                                  \
1069     },                                                          \
1070     .he_mcs_nss_supp = {                                        \
1071         .rx_mcs_80 = cpu_to_le16(0xfffa),                       \
1072         .tx_mcs_80 = cpu_to_le16(0xfffa),                       \
1073         .rx_mcs_160 = cpu_to_le16(0xffff),                      \
1074         .tx_mcs_160 = cpu_to_le16(0xffff),                      \
1075         .rx_mcs_80p80 = cpu_to_le16(0xffff),                    \
1076         .tx_mcs_80p80 = cpu_to_le16(0xffff),                    \
1077     },                                                          \
1078     .ppe_thres = {0x00},                                        \
1079 }
1080 #endif
1081
1082 #define RATE(_bitrate, _hw_rate, _flags) {      \
1083     .bitrate    = (_bitrate),                   \
1084     .flags      = (_flags),                     \
1085     .hw_value   = (_hw_rate),                   \
1086 }
1087
1088 #define CHAN(_freq) {                           \
1089     .center_freq    = (_freq),                  \
1090     .max_power  = 30, /* FIXME */               \
1091 }
1092
1093 #endif /* _ECRNX_DEFS_H_*/