net: wireless: rockchip: add rtl8822be pcie wifi driver
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8822be / include / drv_types.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 /*-------------------------------------------------------------------------------
21
22         For type defines and data structure defines
23
24 --------------------------------------------------------------------------------*/
25
26
27 #ifndef __DRV_TYPES_H__
28 #define __DRV_TYPES_H__
29
30 #include <drv_conf.h>
31 #include <basic_types.h>
32 #include <osdep_service.h>
33 #include <rtw_byteorder.h>
34 #include <wlan_bssdef.h>
35 #include <wifi.h>
36 #include <ieee80211.h>
37 #ifdef CONFIG_ARP_KEEP_ALIVE
38         #include <net/neighbour.h>
39         #include <net/arp.h>
40 #endif
41
42 #ifdef PLATFORM_OS_XP
43         #include <drv_types_xp.h>
44 #endif
45
46 #ifdef PLATFORM_OS_CE
47         #include <drv_types_ce.h>
48 #endif
49
50 #ifdef PLATFORM_LINUX
51         #include <drv_types_linux.h>
52 #endif
53
54 enum _NIC_VERSION {
55
56         RTL8711_NIC,
57         RTL8712_NIC,
58         RTL8713_NIC,
59         RTL8716_NIC
60
61 };
62
63 typedef struct _ADAPTER _adapter, ADAPTER, *PADAPTER;
64
65 #include <rtw_debug.h>
66 #include <rtw_rf.h>
67
68 #ifdef CONFIG_80211N_HT
69         #include <rtw_ht.h>
70 #endif
71
72 #ifdef CONFIG_80211AC_VHT
73         #include <rtw_vht.h>
74 #endif
75
76 #ifdef CONFIG_INTEL_WIDI
77         #include <rtw_intel_widi.h>
78 #endif
79
80 #include <rtw_cmd.h>
81 #include <cmd_osdep.h>
82 #include <rtw_security.h>
83 #include <rtw_xmit.h>
84 #include <xmit_osdep.h>
85 #include <rtw_recv.h>
86
87 #ifdef CONFIG_BEAMFORMING
88         #include <rtw_beamforming.h>
89 #endif
90
91 #include <recv_osdep.h>
92 #include <rtw_efuse.h>
93 #include <rtw_sreset.h>
94 #include <hal_intf.h>
95 #include <hal_com.h>
96 #include<hal_com_h2c.h>
97 #include <hal_com_led.h>
98 #include "../hal/hal_dm.h"
99 #include <rtw_qos.h>
100 #include <rtw_pwrctrl.h>
101 #include <rtw_mlme.h>
102 #include <mlme_osdep.h>
103 #include <rtw_io.h>
104 #include <rtw_ioctl.h>
105 #include <rtw_ioctl_set.h>
106 #include <rtw_ioctl_query.h>
107 #include <rtw_ioctl_rtl.h>
108 #include <osdep_intf.h>
109 #include <rtw_eeprom.h>
110 #include <sta_info.h>
111 #include <rtw_event.h>
112 #include <rtw_mlme_ext.h>
113 #include <rtw_mi.h>
114 #include <rtw_ap.h>
115 #include <rtw_efuse.h>
116 #include <rtw_version.h>
117 #include <rtw_odm.h>
118
119 #ifdef CONFIG_PREALLOC_RX_SKB_BUFFER
120         #include <rtw_mem.h>
121 #endif
122
123 #include <rtw_p2p.h>
124
125 #ifdef CONFIG_TDLS
126         #include <rtw_tdls.h>
127 #endif /* CONFIG_TDLS */
128
129 #ifdef CONFIG_WAPI_SUPPORT
130         #include <rtw_wapi.h>
131 #endif /* CONFIG_WAPI_SUPPORT */
132
133 #ifdef CONFIG_DRVEXT_MODULE
134         #include <drvext_api.h>
135 #endif /* CONFIG_DRVEXT_MODULE */
136
137 #ifdef CONFIG_MP_INCLUDED
138         #include <rtw_mp.h>
139 #endif /* CONFIG_MP_INCLUDED */
140
141 #ifdef CONFIG_BR_EXT
142         #include <rtw_br_ext.h>
143 #endif /* CONFIG_BR_EXT */
144
145 #ifdef CONFIG_IOL
146         #include <rtw_iol.h>
147 #endif /* CONFIG_IOL */
148
149 #include <ip.h>
150 #include <if_ether.h>
151 #include <ethernet.h>
152 #include <circ_buf.h>
153
154 #include <rtw_android.h>
155
156 #ifdef CONFIG_BT_COEXIST
157         #include <rtw_btcoex.h>
158 #endif /* CONFIG_BT_COEXIST */
159
160 #ifdef CONFIG_MCC_MODE
161         #include <rtw_mcc.h>
162 #endif /*CONFIG_MCC_MODE */
163
164 #define SPEC_DEV_ID_NONE BIT(0)
165 #define SPEC_DEV_ID_DISABLE_HT BIT(1)
166 #define SPEC_DEV_ID_ENABLE_PS BIT(2)
167 #define SPEC_DEV_ID_RF_CONFIG_1T1R BIT(3)
168 #define SPEC_DEV_ID_RF_CONFIG_2T2R BIT(4)
169 #define SPEC_DEV_ID_ASSIGN_IFNAME BIT(5)
170
171 struct specific_device_id {
172
173         u32             flags;
174
175         u16             idVendor;
176         u16             idProduct;
177
178 };
179
180 struct registry_priv {
181         u8      chip_version;
182         u8      rfintfs;
183         u8      lbkmode;
184         u8      hci;
185         NDIS_802_11_SSID        ssid;
186         u8      network_mode;   /* infra, ad-hoc, auto */
187         u8      channel;/* ad-hoc support requirement */
188         u8      wireless_mode;/* A, B, G, auto */
189         u8      scan_mode;/* active, passive */
190         u8      radio_enable;
191         u8      preamble;/* long, short, auto */
192         u8      vrtl_carrier_sense;/* Enable, Disable, Auto */
193         u8      vcs_type;/* RTS/CTS, CTS-to-self */
194         u16     rts_thresh;
195         u16  frag_thresh;
196         u8      adhoc_tx_pwr;
197         u8      soft_ap;
198         u8      power_mgnt;
199         u8      ips_mode;
200         u8      smart_ps;
201         u8   usb_rxagg_mode;
202         u8      long_retry_lmt;
203         u8      short_retry_lmt;
204         u16     busy_thresh;
205         u8      ack_policy;
206         u8      mp_mode;
207         u8  mp_dm;
208         u8      software_encrypt;
209         u8      software_decrypt;
210 #ifdef CONFIG_TX_EARLY_MODE
211         u8   early_mode;
212 #endif
213         u8      acm_method;
214         /* UAPSD */
215         u8      wmm_enable;
216         u8      uapsd_enable;
217         u8      uapsd_max_sp;
218         u8      uapsd_acbk_en;
219         u8      uapsd_acbe_en;
220         u8      uapsd_acvi_en;
221         u8      uapsd_acvo_en;
222
223         WLAN_BSSID_EX    dev_network;
224
225 #ifdef CONFIG_80211N_HT
226         u8      ht_enable;
227         /* 0: 20 MHz, 1: 40 MHz, 2: 80 MHz, 3: 160MHz */
228         /* 2.4G use bit 0 ~ 3, 5G use bit 4 ~ 7 */
229         /* 0x21 means enable 2.4G 40MHz & 5G 80MHz */
230         u8      bw_mode;
231         u8      ampdu_enable;/* for tx */
232         u8      rx_stbc;
233         u8      ampdu_amsdu;/* A-MPDU Supports A-MSDU is permitted */
234         /* Short GI support Bit Map */
235         /* BIT0 - 20MHz, 1: support, 0: non-support */
236         /* BIT1 - 40MHz, 1: support, 0: non-support */
237         /* BIT2 - 80MHz, 1: support, 0: non-support */
238         /* BIT3 - 160MHz, 1: support, 0: non-support */
239         u8      short_gi;
240         /* BIT0: Enable VHT LDPC Rx, BIT1: Enable VHT LDPC Tx, BIT4: Enable HT LDPC Rx, BIT5: Enable HT LDPC Tx */
241         u8      ldpc_cap;
242         /* BIT0: Enable VHT STBC Rx, BIT1: Enable VHT STBC Tx, BIT4: Enable HT STBC Rx, BIT5: Enable HT STBC Tx */
243         u8      stbc_cap;
244         /*
245          * BIT0: Enable VHT SU Beamformer
246          * BIT1: Enable VHT SU Beamformee
247          * BIT2: Enable VHT MU Beamformer, depend on VHT SU Beamformer
248          * BIT3: Enable VHT MU Beamformee, depend on VHT SU Beamformee
249          * BIT4: Enable HT Beamformer
250          * BIT5: Enable HT Beamformee
251          */
252         u8      beamform_cap;
253         u8      beamformer_rf_num;
254         u8      beamformee_rf_num;
255 #endif /* CONFIG_80211N_HT */
256
257 #ifdef CONFIG_80211AC_VHT
258         u8      vht_enable; /* 0:disable, 1:enable, 2:auto */
259         u8      ampdu_factor;
260         u8      vht_rate_sel;
261 #endif /* CONFIG_80211AC_VHT */
262
263         u8      lowrate_two_xmit;
264
265         u8      rf_config ;
266         u8      low_power ;
267
268         u8      wifi_spec;/* !turbo_mode */
269         u8      special_rf_path; /* 0: 2T2R ,1: only turn on path A 1T1R */
270         char alpha2[2];
271         u8      channel_plan;
272         u8      excl_chs[MAX_CHANNEL_NUM];
273         u8      full_ch_in_p2p_handshake; /* 0: reply only softap channel, 1: reply full channel list*/
274
275 #ifdef CONFIG_BT_COEXIST
276         u8      btcoex;
277         u8      bt_iso;
278         u8      bt_sco;
279         u8      bt_ampdu;
280         u8      ant_num;
281 #endif
282         BOOLEAN bAcceptAddbaReq;
283
284         u8      antdiv_cfg;
285         u8      antdiv_type;
286         u8      drv_ant_band_switch;
287
288         u8      switch_usb_mode;
289
290         u8      usbss_enable;/* 0:disable,1:enable */
291         u8      hwpdn_mode;/* 0:disable,1:enable,2:decide by EFUSE config */
292         u8      hwpwrp_detect;/* 0:disable,1:enable */
293
294         u8      hw_wps_pbc;/* 0:disable,1:enable */
295
296 #ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE
297         char    adaptor_info_caching_file_path[PATH_LENGTH_MAX];
298 #endif
299
300 #ifdef CONFIG_LAYER2_ROAMING
301         u8      max_roaming_times; /* the max number driver will try to roaming */
302 #endif
303
304 #ifdef CONFIG_IOL
305         u8 fw_iol; /* enable iol without other concern */
306 #endif
307
308 #ifdef CONFIG_80211D
309         u8 enable80211d;
310 #endif
311
312         u8 ifname[16];
313         u8 if2name[16];
314
315         u8 notch_filter;
316
317 #ifdef CONFIG_SPECIAL_SETTING_FOR_FUNAI_TV
318         u8 force_ant;/* 0 normal,1 main,2 aux */
319         u8 force_igi;/* 0 normal */
320 #endif
321
322         u8 force_igi_lb;
323
324         /* for pll reference clock selction */
325         u8 pll_ref_clk_sel;
326
327         /* define for tx power adjust */
328         u8      RegEnableTxPowerLimit;
329         u8      RegEnableTxPowerByRate;
330         u8      RegPowerBase;
331         u8      RegPwrTblSel;
332
333         u8 target_tx_pwr_valid;
334         s8 target_tx_pwr_2g[RF_PATH_MAX][RATE_SECTION_NUM];
335 #ifdef CONFIG_IEEE80211_BAND_5GHZ
336         s8 target_tx_pwr_5g[RF_PATH_MAX][RATE_SECTION_NUM - 1];
337 #endif
338
339         s8      TxBBSwing_2G;
340         s8      TxBBSwing_5G;
341         u8      AmplifierType_2G;
342         u8      AmplifierType_5G;
343         u8      bEn_RFE;
344         u8      RFE_Type;
345         u8      PowerTracking_Type;
346         u8      GLNA_Type;
347         u8  check_fw_ps;
348         u8      RegPwrTrimEnable;
349
350 #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
351         u8      load_phy_file;
352         u8      RegDecryptCustomFile;
353 #endif
354 #ifdef CONFIG_CONCURRENT_MODE
355         u8 virtual_iface_num;
356 #endif
357         u8 qos_opt_enable;
358
359         u8 hiq_filter;
360         u8 adaptivity_en;
361         u8 adaptivity_mode;
362         u8 adaptivity_dml;
363         u8 adaptivity_dc_backoff;
364         s8 adaptivity_th_l2h_ini;
365         s8 adaptivity_th_edcca_hl_diff;
366
367         u8 boffefusemask;
368         BOOLEAN bFileMaskEfuse;
369 #ifdef CONFIG_AUTO_CHNL_SEL_NHM
370         u8 acs_mode;
371         u8 acs_auto_scan;
372 #endif
373         u32     reg_rxgain_offset_2g;
374         u32     reg_rxgain_offset_5gl;
375         u32     reg_rxgain_offset_5gm;
376         u32     reg_rxgain_offset_5gh;
377
378 #ifdef CONFIG_DFS_MASTER
379         u8 dfs_region_domain;
380 #endif
381
382 #ifdef CONFIG_NAPI
383         u8 napi_debug;
384         u16 napi_weight;
385 #endif
386
387 #ifdef CONFIG_MCC_MODE
388         u8 en_mcc;
389         u32 rtw_mcc_single_tx_cri;
390         u32 rtw_mcc_ap_bw20_target_tx_tp;
391         u32 rtw_mcc_ap_bw40_target_tx_tp;
392         u32 rtw_mcc_ap_bw80_target_tx_tp;
393         u32 rtw_mcc_sta_bw20_target_tx_tp;
394         u32 rtw_mcc_sta_bw40_target_tx_tp;
395         u32 rtw_mcc_sta_bw80_target_tx_tp;
396 #endif /* CONFIG_MCC_MODE */
397
398         bool    default_patterns_en;
399         u8 check_hw_status;
400 };
401
402 /* For registry parameters */
403 #define RGTRY_OFT(field) ((ULONG)FIELD_OFFSET(struct registry_priv, field))
404 #define RGTRY_SZ(field)   sizeof(((struct registry_priv *) 0)->field)
405
406 #define GetRegAmplifierType2G(_Adapter) (_Adapter->registrypriv.AmplifierType_2G)
407 #define GetRegAmplifierType5G(_Adapter) (_Adapter->registrypriv.AmplifierType_5G)
408
409 #define GetRegTxBBSwing_2G(_Adapter)    (_Adapter->registrypriv.TxBBSwing_2G)
410 #define GetRegTxBBSwing_5G(_Adapter)    (_Adapter->registrypriv.TxBBSwing_5G)
411
412 #define GetRegbENRFEType(_Adapter)      (_Adapter->registrypriv.bEn_RFE)
413 #define GetRegRFEType(_Adapter) (_Adapter->registrypriv.RFE_Type)
414 #define GetRegGLNAType(_Adapter)        (_Adapter->registrypriv.GLNA_Type)
415 #define GetRegPowerTrackingType(_Adapter)       (_Adapter->registrypriv.PowerTracking_Type)
416
417 #define BSSID_OFT(field) ((ULONG)FIELD_OFFSET(WLAN_BSSID_EX, field))
418 #define BSSID_SZ(field)   sizeof(((PWLAN_BSSID_EX) 0)->field)
419
420 #define REGSTY_BW_2G(regsty) ((regsty)->bw_mode & 0x0F)
421 #define REGSTY_BW_5G(regsty) (((regsty)->bw_mode) >> 4)
422 #define REGSTY_IS_BW_2G_SUPPORT(regsty, bw) (REGSTY_BW_2G((regsty)) >= (bw))
423 #define REGSTY_IS_BW_5G_SUPPORT(regsty, bw) (REGSTY_BW_5G((regsty)) >= (bw))
424
425 #define REGSTY_IS_11AC_ENABLE(regsty) ((regsty)->vht_enable != 0)
426 #define REGSTY_IS_11AC_AUTO(regsty) ((regsty)->vht_enable == 2)
427
428 typedef struct rtw_if_operations {
429         int __must_check(*read)(struct dvobj_priv *d, int addr, void *buf,
430                                 size_t len, bool fixed);
431         int __must_check(*write)(struct dvobj_priv *d, int addr, void *buf,
432                                  size_t len, bool fixed);
433 } RTW_IF_OPS, *PRTW_IF_OPS;
434
435 #ifdef CONFIG_SDIO_HCI
436         #include <drv_types_sdio.h>
437         #define INTF_DATA       SDIO_DATA
438         #define INTF_OPS        PRTW_IF_OPS
439 #elif defined(CONFIG_GSPI_HCI)
440         #include <drv_types_gspi.h>
441         #define INTF_DATA GSPI_DATA
442 #elif defined(CONFIG_PCI_HCI)
443         #include <drv_types_pci.h>
444 #endif
445
446 #ifdef CONFIG_CONCURRENT_MODE
447         #define is_primary_adapter(adapter) (adapter->adapter_type == PRIMARY_ADAPTER)
448         #define is_vir_adapter(adapter) (adapter->adapter_type == MAX_ADAPTER)
449         #define get_hw_port(adapter) (adapter->hw_port)
450 #else
451         #define is_primary_adapter(adapter) (1)
452         #define is_vir_adapter(adapter) (0)
453         #define get_hw_port(adapter) (HW_PORT0)
454 #endif
455 #define GET_PRIMARY_ADAPTER(padapter) (((_adapter *)padapter)->dvobj->padapters[IFACE_ID0])
456 #define GET_IFACE_NUMS(padapter) (((_adapter *)padapter)->dvobj->iface_nums)
457 #define GET_ADAPTER(padapter, iface_id) (((_adapter *)padapter)->dvobj->padapters[iface_id])
458
459 #define GetDefaultAdapter(padapter)     padapter
460
461 enum _IFACE_ID {
462         IFACE_ID0, /*PRIMARY_ADAPTER*/
463         IFACE_ID1,
464         IFACE_ID2,
465         IFACE_ID3,
466         IFACE_ID4,
467         IFACE_ID5,
468         IFACE_ID6,
469         IFACE_ID7,
470         IFACE_ID_MAX,
471 };
472
473 #define VIF_START_ID    1
474
475 #ifdef CONFIG_DBG_COUNTER
476
477 struct rx_logs {
478         u32 intf_rx;
479         u32 intf_rx_err_recvframe;
480         u32 intf_rx_err_skb;
481         u32 intf_rx_report;
482         u32 core_rx;
483         u32 core_rx_pre;
484         u32 core_rx_pre_ver_err;
485         u32 core_rx_pre_mgmt;
486         u32 core_rx_pre_mgmt_err_80211w;
487         u32 core_rx_pre_mgmt_err;
488         u32 core_rx_pre_ctrl;
489         u32 core_rx_pre_ctrl_err;
490         u32 core_rx_pre_data;
491         u32 core_rx_pre_data_wapi_seq_err;
492         u32 core_rx_pre_data_wapi_key_err;
493         u32 core_rx_pre_data_handled;
494         u32 core_rx_pre_data_err;
495         u32 core_rx_pre_data_unknown;
496         u32 core_rx_pre_unknown;
497         u32 core_rx_enqueue;
498         u32 core_rx_dequeue;
499         u32 core_rx_post;
500         u32 core_rx_post_decrypt;
501         u32 core_rx_post_decrypt_wep;
502         u32 core_rx_post_decrypt_tkip;
503         u32 core_rx_post_decrypt_aes;
504         u32 core_rx_post_decrypt_wapi;
505         u32 core_rx_post_decrypt_hw;
506         u32 core_rx_post_decrypt_unknown;
507         u32 core_rx_post_decrypt_err;
508         u32 core_rx_post_defrag_err;
509         u32 core_rx_post_portctrl_err;
510         u32 core_rx_post_indicate;
511         u32 core_rx_post_indicate_in_oder;
512         u32 core_rx_post_indicate_reoder;
513         u32 core_rx_post_indicate_err;
514         u32 os_indicate;
515         u32 os_indicate_ap_mcast;
516         u32 os_indicate_ap_forward;
517         u32 os_indicate_ap_self;
518         u32 os_indicate_err;
519         u32 os_netif_ok;
520         u32 os_netif_err;
521 };
522
523 struct tx_logs {
524         u32 os_tx;
525         u32 os_tx_err_up;
526         u32 os_tx_err_xmit;
527         u32 os_tx_m2u;
528         u32 os_tx_m2u_ignore_fw_linked;
529         u32 os_tx_m2u_ignore_self;
530         u32 os_tx_m2u_entry;
531         u32 os_tx_m2u_entry_err_xmit;
532         u32 os_tx_m2u_entry_err_skb;
533         u32 os_tx_m2u_stop;
534         u32 core_tx;
535         u32 core_tx_err_pxmitframe;
536         u32 core_tx_err_brtx;
537         u32 core_tx_upd_attrib;
538         u32 core_tx_upd_attrib_adhoc;
539         u32 core_tx_upd_attrib_sta;
540         u32 core_tx_upd_attrib_ap;
541         u32 core_tx_upd_attrib_unknown;
542         u32 core_tx_upd_attrib_dhcp;
543         u32 core_tx_upd_attrib_icmp;
544         u32 core_tx_upd_attrib_active;
545         u32 core_tx_upd_attrib_err_ucast_sta;
546         u32 core_tx_upd_attrib_err_ucast_ap_link;
547         u32 core_tx_upd_attrib_err_sta;
548         u32 core_tx_upd_attrib_err_link;
549         u32 core_tx_upd_attrib_err_sec;
550         u32 core_tx_ap_enqueue_warn_fwstate;
551         u32 core_tx_ap_enqueue_warn_sta;
552         u32 core_tx_ap_enqueue_warn_nosta;
553         u32 core_tx_ap_enqueue_warn_link;
554         u32 core_tx_ap_enqueue_warn_trigger;
555         u32 core_tx_ap_enqueue_mcast;
556         u32 core_tx_ap_enqueue_ucast;
557         u32 core_tx_ap_enqueue;
558         u32 intf_tx;
559         u32 intf_tx_pending_ac;
560         u32 intf_tx_pending_fw_under_survey;
561         u32 intf_tx_pending_fw_under_linking;
562         u32 intf_tx_pending_xmitbuf;
563         u32 intf_tx_enqueue;
564         u32 core_tx_enqueue;
565         u32 core_tx_enqueue_class;
566         u32 core_tx_enqueue_class_err_sta;
567         u32 core_tx_enqueue_class_err_nosta;
568         u32 core_tx_enqueue_class_err_fwlink;
569         u32 intf_tx_direct;
570         u32 intf_tx_direct_err_coalesce;
571         u32 intf_tx_dequeue;
572         u32 intf_tx_dequeue_err_coalesce;
573         u32 intf_tx_dump_xframe;
574         u32 intf_tx_dump_xframe_err_txdesc;
575         u32 intf_tx_dump_xframe_err_port;
576 };
577
578 struct int_logs {
579         u32 all;
580         u32 err;
581         u32 tbdok;
582         u32 tbder;
583         u32 bcnderr;
584         u32 bcndma;
585         u32 bcndma_e;
586         u32 rx;
587         u32 rx_rdu;
588         u32 rx_fovw;
589         u32 txfovw;
590         u32 mgntok;
591         u32 highdok;
592         u32 bkdok;
593         u32 bedok;
594         u32 vidok;
595         u32 vodok;
596 };
597
598 #endif /* CONFIG_DBG_COUNTER */
599
600 struct debug_priv {
601         u32 dbg_sdio_free_irq_error_cnt;
602         u32 dbg_sdio_alloc_irq_error_cnt;
603         u32 dbg_sdio_free_irq_cnt;
604         u32 dbg_sdio_alloc_irq_cnt;
605         u32 dbg_sdio_deinit_error_cnt;
606         u32 dbg_sdio_init_error_cnt;
607         u32 dbg_suspend_error_cnt;
608         u32 dbg_suspend_cnt;
609         u32 dbg_resume_cnt;
610         u32 dbg_resume_error_cnt;
611         u32 dbg_deinit_fail_cnt;
612         u32 dbg_carddisable_cnt;
613         u32 dbg_carddisable_error_cnt;
614         u32 dbg_ps_insuspend_cnt;
615         u32     dbg_dev_unload_inIPS_cnt;
616         u32 dbg_wow_leave_ps_fail_cnt;
617         u32 dbg_scan_pwr_state_cnt;
618         u32 dbg_downloadfw_pwr_state_cnt;
619         u32 dbg_fw_read_ps_state_fail_cnt;
620         u32 dbg_leave_ips_fail_cnt;
621         u32 dbg_leave_lps_fail_cnt;
622         u32 dbg_h2c_leave32k_fail_cnt;
623         u32 dbg_diswow_dload_fw_fail_cnt;
624         u32 dbg_enwow_dload_fw_fail_cnt;
625         u32 dbg_ips_drvopen_fail_cnt;
626         u32 dbg_poll_fail_cnt;
627         u32 dbg_rpwm_toogle_cnt;
628         u32 dbg_rpwm_timeout_fail_cnt;
629         u32 dbg_sreset_cnt;
630         u64 dbg_rx_fifo_last_overflow;
631         u64 dbg_rx_fifo_curr_overflow;
632         u64 dbg_rx_fifo_diff_overflow;
633         u64 dbg_rx_ampdu_drop_count;
634         u64 dbg_rx_ampdu_forced_indicate_count;
635         u64 dbg_rx_ampdu_loss_count;
636         u64 dbg_rx_dup_mgt_frame_drop_count;
637         u64 dbg_rx_ampdu_window_shift_cnt;
638         u64 dbg_rx_conflic_mac_addr_cnt;
639 };
640
641 struct rtw_traffic_statistics {
642         /* tx statistics */
643         u64     tx_bytes;
644         u64     tx_pkts;
645         u64     tx_drop;
646         u64     cur_tx_bytes;
647         u64     last_tx_bytes;
648         u32     cur_tx_tp; /* Tx throughput in MBps. */
649
650         /* rx statistics */
651         u64     rx_bytes;
652         u64     rx_pkts;
653         u64     rx_drop;
654         u64     cur_rx_bytes;
655         u64     last_rx_bytes;
656         u32     cur_rx_tp; /* Rx throughput in MBps. */
657 };
658
659 #define SEC_CAP_CHK_BMC BIT0
660
661 #define SEC_STATUS_STA_PK_GK_CONFLICT_DIS_BMC_SEARCH    BIT0
662
663 struct sec_cam_bmp {
664         u32 m0;
665 #if (SEC_CAM_ENT_NUM_SW_LIMIT > 32)
666         u32 m1;
667 #endif
668 #if (SEC_CAM_ENT_NUM_SW_LIMIT > 64)
669         u32 m2;
670 #endif
671 #if (SEC_CAM_ENT_NUM_SW_LIMIT > 96)
672         u32 m3;
673 #endif
674 };
675
676 struct cam_ctl_t {
677         _lock lock;
678
679         u8 sec_cap;
680         u32 flags;
681
682         u8 num;
683         struct sec_cam_bmp used;
684
685         _mutex sec_cam_access_mutex;
686 };
687
688 struct sec_cam_ent {
689         u16 ctrl;
690         u8 mac[ETH_ALEN];
691         u8 key[16];
692 };
693
694 #define KEY_FMT "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
695 #define KEY_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5], \
696         ((u8 *)(x))[6], ((u8 *)(x))[7], ((u8 *)(x))[8], ((u8 *)(x))[9], ((u8 *)(x))[10], ((u8 *)(x))[11], \
697         ((u8 *)(x))[12], ((u8 *)(x))[13], ((u8 *)(x))[14], ((u8 *)(x))[15]
698
699 struct macid_bmp {
700         u32 m0;
701 #if (MACID_NUM_SW_LIMIT > 32)
702         u32 m1;
703 #endif
704 #if (MACID_NUM_SW_LIMIT > 64)
705         u32 m2;
706 #endif
707 #if (MACID_NUM_SW_LIMIT > 96)
708         u32 m3;
709 #endif
710 };
711
712 struct macid_ctl_t {
713         _lock lock;
714         u8 num;
715         struct macid_bmp used;
716         struct macid_bmp bmc;
717         struct macid_bmp if_g[CONFIG_IFACE_NUMBER];
718         u8 iface_bmc[CONFIG_IFACE_NUMBER];/*for bc-sta of AP or Adhoc mode*/
719         struct macid_bmp ch_g[2]; /* 2 ch concurrency */
720         u8 h2c_msr[MACID_NUM_SW_LIMIT];
721         struct sta_info *sta[MACID_NUM_SW_LIMIT];
722 };
723
724 struct rf_ctl_t {
725 #ifdef CONFIG_DFS_MASTER
726         bool radar_detect_by_others;
727         u8 dfs_master_enabled;
728         bool radar_detected;
729
730         u8 radar_detect_ch;
731         u8 radar_detect_bw;
732         u8 radar_detect_offset;
733
734         u32 cac_start_time;
735         u32 cac_end_time;
736
737         u8 dfs_ch_sel_d_flags;
738
739         u8 dbg_dfs_master_fake_radar_detect_cnt;
740         u8 dbg_dfs_master_radar_detect_trigger_non;
741         u8 dbg_dfs_master_choose_dfs_ch_first;
742 #endif
743 };
744
745 #define RTW_CAC_STOPPED 0
746 #define IS_CAC_STOPPED(rfctl) ((rfctl)->cac_end_time == RTW_CAC_STOPPED)
747 #define IS_CH_WAITING(rfctl) (!IS_CAC_STOPPED(rfctl) && time_after((unsigned long)(rfctl)->cac_end_time, (unsigned long)rtw_get_current_time()))
748 #define IS_UNDER_CAC(rfctl) (IS_CH_WAITING(rfctl) && time_after((unsigned long)rtw_get_current_time(), (unsigned long)(rfctl)->cac_start_time))
749
750 struct mi_state {
751         u8 sta_num;                     /*WIFI_FW_STATION_STATE*/
752         u8 ld_sta_num;          /*WIFI_FW_STATION_STATE |_FW_LINKED*/
753         u8 lg_sta_num;          /*WIFI_FW_STATION_STATE |_FW_UNDER_LINKING*/
754         u8 ap_num;                      /*WIFI_FW_AP_STATE|_FW_LINKED*/
755         u8 ld_ap_num;           /*WIFI_FW_AP_STATE|_FW_LINKED && asoc_sta_count > 2*/
756         u8 adhoc_num;           /* WIFI_FW_ADHOC_STATE */
757         u8 ld_adhoc_num;        /* WIFI_FW_ADHOC_STATE && asoc_sta_count > 2 */
758         u8 uwps_num;            /*WIFI_UNDER_WPS*/
759         u8 union_ch;
760         u8 union_bw;
761         u8 union_offset;
762 };
763
764 #ifdef CONFIG_MBSSID_CAM
765 #define TOTAL_MBID_CAM_NUM      8
766 #define INVALID_CAM_ID                  0xFF
767 struct mbid_cam_ctl_t {
768         _lock lock;
769         u8 bitmap;
770         ATOMIC_T mbid_entry_num;
771 };
772 struct mbid_cam_cache {
773         u8 iface_id;
774         /*u8 role;*/ /*WIFI_STATION_STATE or WIFI_AP_STATE*/
775         u8 mac_addr[ETH_ALEN];
776 };
777 #endif /*CONFIG_MBSSID_CAM*/
778
779 #ifdef RTW_HALMAC
780 struct halmac_indicator {
781         struct submit_ctx *sctx;
782         u8 *buffer;
783         u32 buf_size;
784         u32 ret_size;
785         u32 status;
786 };
787
788 struct halmacpriv {
789         /* flags */
790         /*
791          * send_general_info
792          *      0: no need to call halmac_send_general_info()
793          *      1: need to call halmac_send_general_info()
794          */
795         u8 send_general_info;
796
797         /* For asynchronous functions */
798         struct halmac_indicator *indicator;
799
800 #ifdef CONFIG_SDIO_HCI
801         /* Store hardware tx queue page number setting */
802         u16 txpage[HW_QUEUE_ENTRY];
803 #endif /* CONFIG_SDIO_HCI */
804 };
805 #endif /* RTW_HALMAC */
806
807 struct dvobj_priv {
808         /*-------- below is common data --------*/
809         u8      chip_type;
810         u8      HardwareType;
811         u8      interface_type;/*USB,SDIO,SPI,PCI*/
812
813         ATOMIC_T        bSurpriseRemoved;
814         ATOMIC_T        bDriverStopped;
815
816         s32     processing_dev_remove;
817
818         struct debug_priv drv_dbg;
819
820         _mutex hw_init_mutex;
821         _mutex h2c_fwcmd_mutex;
822         _mutex setch_mutex;
823         _mutex setbw_mutex;
824         _mutex rf_read_reg_mutex;
825 #ifdef CONFIG_SDIO_INDIRECT_ACCESS
826         _mutex sd_indirect_access_mutex;
827 #endif
828
829         unsigned char   oper_channel; /* saved channel info when call set_channel_bw */
830         unsigned char   oper_bwmode;
831         unsigned char   oper_ch_offset;/* PRIME_CHNL_OFFSET */
832         u32 on_oper_ch_time;
833
834         _adapter *padapters[CONFIG_IFACE_NUMBER];/*IFACE_ID_MAX*/
835         u8 iface_nums; /* total number of ifaces used runtime */
836         struct mi_state iface_state;
837
838 #ifdef CONFIG_AP_MODE
839         u8 nr_ap_if; /* total interface s number of ap/go mode. */
840         u32 inter_bcn_space; /* unit:ms */
841         _queue  ap_if_q;
842 #endif
843
844         struct macid_ctl_t macid_ctl;
845
846         struct cam_ctl_t cam_ctl;
847         struct sec_cam_ent cam_cache[SEC_CAM_ENT_NUM_SW_LIMIT];
848
849 #ifdef CONFIG_MBSSID_CAM
850         struct mbid_cam_ctl_t mbid_cam_ctl;
851         struct mbid_cam_cache mbid_cam_cache[TOTAL_MBID_CAM_NUM];
852 #endif
853
854         struct rf_ctl_t rf_ctl;
855
856         /* For 92D, DMDP have 2 interface. */
857         u8      InterfaceNumber;
858         u8      NumInterfaces;
859
860         /* In /Out Pipe information */
861         int     RtInPipe[2];
862         int     RtOutPipe[4];
863         u8      Queue2Pipe[HW_QUEUE_ENTRY];/* for out pipe mapping */
864
865         u8      irq_alloc;
866         ATOMIC_T continual_io_error;
867
868         ATOMIC_T disable_func;
869
870         struct pwrctrl_priv pwrctl_priv;
871
872         struct rtw_traffic_statistics   traffic_stat;
873
874 #if defined(CONFIG_IOCTL_CFG80211) && defined(RTW_SINGLE_WIPHY)
875         struct wiphy *wiphy;
876 #endif
877
878 #ifdef CONFIG_SWTIMER_BASED_TXBCN
879         _timer txbcn_timer;
880 #endif
881
882 #ifdef RTW_HALMAC
883         void *halmac;
884         struct halmacpriv hmpriv;
885 #endif /* RTW_HALMAC */
886
887         /*-------- below is for SDIO INTERFACE --------*/
888
889 #ifdef INTF_DATA
890         INTF_DATA intf_data;
891 #endif
892 #ifdef INTF_OPS
893         INTF_OPS intf_ops;
894 #endif
895
896         /*-------- below is for USB INTERFACE --------*/
897
898 #ifdef CONFIG_USB_HCI
899
900         u8      usb_speed; /* 1.1, 2.0 or 3.0 */
901         u8      nr_endpoint;
902         u8      RtNumInPipes;
903         u8      RtNumOutPipes;
904         int     ep_num[6]; /* endpoint number */
905
906         int     RegUsbSS;
907
908         _sema   usb_suspend_sema;
909
910 #ifdef CONFIG_USB_VENDOR_REQ_MUTEX
911         _mutex  usb_vendor_req_mutex;
912 #endif
913
914 #ifdef CONFIG_USB_VENDOR_REQ_BUFFER_PREALLOC
915         u8 *usb_alloc_vendor_req_buf;
916         u8 *usb_vendor_req_buf;
917 #endif
918
919 #ifdef PLATFORM_WINDOWS
920         /* related device objects */
921         PDEVICE_OBJECT  pphysdevobj;/* pPhysDevObj; */
922         PDEVICE_OBJECT  pfuncdevobj;/* pFuncDevObj; */
923         PDEVICE_OBJECT  pnextdevobj;/* pNextDevObj; */
924
925         u8      nextdevstacksz;/* unsigned char NextDeviceStackSize;     */ /* = (CHAR)CEdevice->pUsbDevObj->StackSize + 1; */
926
927         /* urb for control diescriptor request */
928
929 #ifdef PLATFORM_OS_XP
930         struct _URB_CONTROL_DESCRIPTOR_REQUEST descriptor_urb;
931         PUSB_CONFIGURATION_DESCRIPTOR   pconfig_descriptor;/* UsbConfigurationDescriptor; */
932 #endif
933
934 #ifdef PLATFORM_OS_CE
935         WCHAR                   active_path[MAX_ACTIVE_REG_PATH];       /* adapter regpath */
936         USB_EXTENSION   usb_extension;
937
938         _nic_hdl                pipehdls_r8192c[0x10];
939 #endif
940
941         u32     config_descriptor_len;/* ULONG UsbConfigurationDescriptorLength; */
942 #endif/* PLATFORM_WINDOWS */
943
944 #ifdef PLATFORM_LINUX
945         struct usb_interface *pusbintf;
946         struct usb_device *pusbdev;
947 #endif/* PLATFORM_LINUX */
948
949 #ifdef PLATFORM_FREEBSD
950         struct usb_interface *pusbintf;
951         struct usb_device *pusbdev;
952 #endif/* PLATFORM_FREEBSD */
953
954 #endif/* CONFIG_USB_HCI */
955
956         /*-------- below is for PCIE INTERFACE --------*/
957
958 #ifdef CONFIG_PCI_HCI
959
960 #ifdef PLATFORM_LINUX
961         struct pci_dev *ppcidev;
962
963         /* PCI MEM map */
964         unsigned long   pci_mem_end;    /* shared mem end       */
965         unsigned long   pci_mem_start;  /* shared mem start     */
966
967         /* PCI IO map */
968         unsigned long   pci_base_addr;  /* device I/O address   */
969
970 #ifdef RTK_129X_PLATFORM
971         unsigned long   ctrl_start;
972         /* PCI MASK addr */
973         unsigned long   mask_addr;
974
975         /* PCI TRANSLATE addr */
976         unsigned long   tran_addr;
977
978         _lock   io_reg_lock;
979 #endif
980
981         /* PciBridge */
982         struct pci_priv pcipriv;
983
984         unsigned int irq; /* get from pci_dev.irq, store to net_device.irq */
985         u16     irqline;
986         u8      irq_enabled;
987         RT_ISR_CONTENT  isr_content;
988         _lock   irq_th_lock;
989
990         /* ASPM */
991         u8      const_pci_aspm;
992         u8      const_amdpci_aspm;
993         u8      const_hwsw_rfoff_d3;
994         u8      const_support_pciaspm;
995         /* pci-e bridge */
996         u8      const_hostpci_aspm_setting;
997         /* pci-e device */
998         u8      const_devicepci_aspm_setting;
999         u8      b_support_aspm; /* If it supports ASPM, Offset[560h] = 0x40, otherwise Offset[560h] = 0x00. */
1000         u8      b_support_backdoor;
1001         u8      bdma64;
1002 #endif/* PLATFORM_LINUX */
1003
1004 #endif/* CONFIG_PCI_HCI */
1005
1006 #ifdef CONFIG_MCC_MODE
1007         struct mcc_obj_priv mcc_objpriv;
1008 #endif /*CONFIG_MCC_MODE */
1009 };
1010
1011 #define dvobj_to_pwrctl(dvobj) (&(dvobj->pwrctl_priv))
1012 #define pwrctl_to_dvobj(pwrctl) container_of(pwrctl, struct dvobj_priv, pwrctl_priv)
1013 #define dvobj_to_macidctl(dvobj) (&(dvobj->macid_ctl))
1014 #define dvobj_to_sec_camctl(dvobj) (&(dvobj->cam_ctl))
1015 #define dvobj_to_regsty(dvobj) (&(dvobj->padapters[IFACE_ID0]->registrypriv))
1016 #if defined(CONFIG_IOCTL_CFG80211) && defined(RTW_SINGLE_WIPHY)
1017         #define dvobj_to_wiphy(dvobj) ((dvobj)->wiphy)
1018 #endif
1019 #define dvobj_to_rfctl(dvobj) (&(dvobj->rf_ctl))
1020 #define rfctl_to_dvobj(rfctl) container_of((rfctl), struct dvobj_priv, rf_ctl)
1021
1022 #ifdef PLATFORM_LINUX
1023 static struct device *dvobj_to_dev(struct dvobj_priv *dvobj)
1024 {
1025         /* todo: get interface type from dvobj and the return the dev accordingly */
1026 #ifdef RTW_DVOBJ_CHIP_HW_TYPE
1027 #endif
1028
1029 #ifdef CONFIG_USB_HCI
1030         return &dvobj->pusbintf->dev;
1031 #endif
1032 #ifdef CONFIG_SDIO_HCI
1033         return &dvobj->intf_data.func->dev;
1034 #endif
1035 #ifdef CONFIG_GSPI_HCI
1036         return &dvobj->intf_data.func->dev;
1037 #endif
1038 #ifdef CONFIG_PCI_HCI
1039         return &dvobj->ppcidev->dev;
1040 #endif
1041 }
1042 #endif
1043
1044 _adapter *dvobj_get_port0_adapter(struct dvobj_priv *dvobj);
1045 #define dvobj_get_primary_adapter(dvobj)        ((dvobj)->padapters[IFACE_ID0])
1046
1047 enum _hw_port {
1048         HW_PORT0,
1049         HW_PORT1,
1050         HW_PORT2,
1051         HW_PORT3,
1052         HW_PORT4,
1053         MAX_HW_PORT,
1054 };
1055
1056 enum _ADAPTER_TYPE {
1057         PRIMARY_ADAPTER,
1058         VIRTUAL_ADAPTER,
1059         MAX_ADAPTER = 0xFF,
1060 };
1061
1062 typedef enum _DRIVER_STATE {
1063         DRIVER_NORMAL = 0,
1064         DRIVER_DISAPPEAR = 1,
1065         DRIVER_REPLACE_DONGLE = 2,
1066 } DRIVER_STATE;
1067
1068 #ifdef CONFIG_INTEL_PROXIM
1069 struct proxim {
1070         bool proxim_support;
1071         bool proxim_on;
1072
1073         void *proximity_priv;
1074         int (*proxim_rx)(_adapter *padapter,
1075                          union recv_frame *precv_frame);
1076         u8(*proxim_get_var)(_adapter *padapter, u8 type);
1077 };
1078 #endif /* CONFIG_INTEL_PROXIM */
1079
1080 #ifdef CONFIG_MAC_LOOPBACK_DRIVER
1081 typedef struct loopbackdata {
1082         _sema   sema;
1083         _thread_hdl_ lbkthread;
1084         u8 bstop;
1085         u32 cnt;
1086         u16 size;
1087         u16 txsize;
1088         u8 txbuf[0x8000];
1089         u16 rxsize;
1090         u8 rxbuf[0x8000];
1091         u8 msg[100];
1092
1093 } LOOPBACKDATA, *PLOOPBACKDATA;
1094 #endif
1095
1096 struct _ADAPTER {
1097         int     DriverState;/* for disable driver using module, use dongle to replace module. */
1098         int     pid[3];/* process id from UI, 0:wps, 1:hostapd, 2:dhcpcd */
1099         int     bDongle;/* build-in module or external dongle */
1100
1101         _list   list;
1102
1103         struct dvobj_priv *dvobj;
1104         struct  mlme_priv mlmepriv;
1105         struct  mlme_ext_priv mlmeextpriv;
1106         struct  cmd_priv        cmdpriv;
1107         struct  evt_priv        evtpriv;
1108         /* struct       io_queue        *pio_queue; */
1109         struct  io_priv iopriv;
1110         struct  xmit_priv       xmitpriv;
1111         struct  recv_priv       recvpriv;
1112         struct  sta_priv        stapriv;
1113         struct  security_priv   securitypriv;
1114         _lock   security_key_mutex; /* add for CONFIG_IEEE80211W, none 11w also can use */
1115         struct  registry_priv   registrypriv;
1116
1117         struct  led_priv        ledpriv;
1118
1119 #ifdef CONFIG_MP_INCLUDED
1120         struct  mp_priv mppriv;
1121 #endif
1122
1123 #ifdef CONFIG_DRVEXT_MODULE
1124         struct  drvext_priv     drvextpriv;
1125 #endif
1126
1127 #ifdef CONFIG_AP_MODE
1128         struct  hostapd_priv    *phostapdpriv;
1129 #endif
1130
1131 #ifdef CONFIG_IOCTL_CFG80211
1132 #ifdef CONFIG_P2P
1133         struct cfg80211_wifidirect_info cfg80211_wdinfo;
1134 #endif /* CONFIG_P2P */
1135 #endif /* CONFIG_IOCTL_CFG80211 */
1136         u32     setband;
1137         ATOMIC_T bandskip;
1138
1139 #ifdef CONFIG_P2P
1140         struct wifidirect_info  wdinfo;
1141 #endif /* CONFIG_P2P */
1142
1143 #ifdef CONFIG_TDLS
1144         struct tdls_info        tdlsinfo;
1145 #endif /* CONFIG_TDLS */
1146
1147 #ifdef CONFIG_WAPI_SUPPORT
1148         u8      WapiSupport;
1149         RT_WAPI_T       wapiInfo;
1150 #endif
1151
1152
1153 #ifdef CONFIG_WFD
1154         struct wifi_display_info wfd_info;
1155 #endif /* CONFIG_WFD */
1156
1157 #ifdef CONFIG_BT_COEXIST_SOCKET_TRX
1158         struct bt_coex_info coex_info;
1159 #endif /* CONFIG_BT_COEXIST_SOCKET_TRX */
1160
1161         ERROR_CODE              LastError; /* <20130613, Kordan> Only the functions associated with MP records the error code by now. */
1162
1163         PVOID                   HalData;
1164         u32 hal_data_sz;
1165         struct hal_ops  HalFunc;
1166
1167         u32     IsrContent;
1168         u32     ImrContent;
1169
1170         u8      EepromAddressSize;
1171         u8      bDriverIsGoingToUnload;
1172         u8      init_adpt_in_progress;
1173         u8      bHaltInProgress;
1174 #ifdef CONFIG_GPIO_API
1175         u8      pre_gpio_pin;
1176         struct gpio_int_priv {
1177                 u8 interrupt_mode;
1178                 u8 interrupt_enable_mask;
1179                 void (*callback[8])(u8 level);
1180         } gpiointpriv;
1181 #endif
1182         _thread_hdl_ cmdThread;
1183         _thread_hdl_ evtThread;
1184         _thread_hdl_ xmitThread;
1185         _thread_hdl_ recvThread;
1186
1187 #ifndef PLATFORM_LINUX
1188         NDIS_STATUS(*dvobj_init)(struct dvobj_priv *dvobj);
1189         void (*dvobj_deinit)(struct dvobj_priv *dvobj);
1190 #endif
1191
1192         u32(*intf_init)(struct dvobj_priv *dvobj);
1193         void (*intf_deinit)(struct dvobj_priv *dvobj);
1194         int (*intf_alloc_irq)(struct dvobj_priv *dvobj);
1195         void (*intf_free_irq)(struct dvobj_priv *dvobj);
1196
1197
1198         void (*intf_start)(_adapter *adapter);
1199         void (*intf_stop)(_adapter *adapter);
1200
1201 #ifdef PLATFORM_WINDOWS
1202         _nic_hdl                hndis_adapter;/* hNdisAdapter(NDISMiniportAdapterHandle); */
1203         _nic_hdl                hndis_config;/* hNdisConfiguration; */
1204         NDIS_STRING fw_img;
1205
1206         u32     NdisPacketFilter;
1207         u8      MCList[MAX_MCAST_LIST_NUM][6];
1208         u32     MCAddrCount;
1209 #endif /* end of PLATFORM_WINDOWS */
1210
1211
1212 #ifdef PLATFORM_LINUX
1213         _nic_hdl pnetdev;
1214         char old_ifname[IFNAMSIZ];
1215
1216         /* used by rtw_rereg_nd_name related function */
1217         struct rereg_nd_name_data {
1218                 _nic_hdl old_pnetdev;
1219                 char old_ifname[IFNAMSIZ];
1220                 u8 old_ips_mode;
1221                 u8 old_bRegUseLed;
1222         } rereg_nd_name_priv;
1223
1224         u8 ndev_unregistering;
1225         int bup;
1226         struct net_device_stats stats;
1227         struct iw_statistics iwstats;
1228         struct proc_dir_entry *dir_dev;/* for proc directory */
1229         struct proc_dir_entry *dir_odm;
1230
1231 #ifdef CONFIG_MCC_MODE
1232         struct proc_dir_entry *dir_mcc;
1233 #endif /* CONFIG_MCC_MODE */
1234
1235 #ifdef CONFIG_IOCTL_CFG80211
1236         struct wireless_dev *rtw_wdev;
1237         struct rtw_wdev_priv wdev_data;
1238
1239 #if !defined(RTW_SINGLE_WIPHY)
1240         struct wiphy *wiphy;
1241 #endif
1242
1243 #endif /* CONFIG_IOCTL_CFG80211 */
1244
1245 #ifdef CONFIG_NAPI
1246         struct  napi_struct napi;
1247 #endif /* CONFIG_NAPI */
1248
1249 #endif /* PLATFORM_LINUX */
1250
1251 #ifdef PLATFORM_FREEBSD
1252         _nic_hdl pifp;
1253         int bup;
1254         _lock glock;
1255 #endif /* PLATFORM_FREEBSD */
1256         u8 mac_addr[ETH_ALEN];
1257         int net_closed;
1258
1259         u8 netif_up;
1260
1261         u8 bFWReady;
1262         u8 bBTFWReady;
1263         u8 bLinkInfoDump;
1264         u8 bRxRSSIDisplay;
1265         /*      Added by Albert 2012/10/26 */
1266         /*      The driver will show up the desired channel number when this flag is 1. */
1267         u8 bNotifyChannelChange;
1268 #ifdef CONFIG_P2P
1269         /*      Added by Albert 2012/12/06 */
1270         /*      The driver will show the current P2P status when the upper application reads it. */
1271         u8 bShowGetP2PState;
1272 #endif
1273 #ifdef CONFIG_AUTOSUSPEND
1274         u8      bDisableAutosuspend;
1275 #endif
1276
1277         u8 isprimary; /* is primary adapter or not */
1278         /* notes:
1279         **      if isprimary is true, the adapter_type value is 0, iface_id is IFACE_ID0 for PRIMARY_ADAPTER
1280         **      if isprimary is false, the adapter_type value is 1, iface_id is IFACE_ID1 for VIRTUAL_ADAPTER
1281         **      refer to iface_id if iface_nums>2 and isprimary is false and the adapter_type value is 0xff.*/
1282         u8 adapter_type;/*be used in  Multi-interface to recognize whether is PRIMARY_ADAPTER  or not(PRIMARY_ADAPTER/VIRTUAL_ADAPTER) .*/
1283         u8 hw_port; /*interface port type, it depends on HW port */
1284
1285
1286         /*extend to support multi interface*/
1287         /*IFACE_ID0 is equals to PRIMARY_ADAPTER
1288         IFACE_ID1 is equals to VIRTUAL_ADAPTER*/
1289         u8 iface_id;
1290
1291 #ifdef CONFIG_BR_EXT
1292         _lock                                   br_ext_lock;
1293         /* unsigned int                 macclone_completed; */
1294         struct nat25_network_db_entry   *nethash[NAT25_HASH_SIZE];
1295         int                             pppoe_connection_in_progress;
1296         unsigned char                   pppoe_addr[MACADDRLEN];
1297         unsigned char                   scdb_mac[MACADDRLEN];
1298         unsigned char                   scdb_ip[4];
1299         struct nat25_network_db_entry   *scdb_entry;
1300         unsigned char                   br_mac[MACADDRLEN];
1301         unsigned char                   br_ip[4];
1302
1303         struct br_ext_info              ethBrExtInfo;
1304 #endif /* CONFIG_BR_EXT */
1305
1306 #ifdef CONFIG_INTEL_PROXIM
1307         /* intel Proximity, should be alloc mem
1308          * in intel Proximity module and can only
1309          * be used in intel Proximity mode */
1310         struct proxim proximity;
1311 #endif /* CONFIG_INTEL_PROXIM */
1312
1313 #ifdef CONFIG_MAC_LOOPBACK_DRIVER
1314         PLOOPBACKDATA ploopback;
1315 #endif
1316
1317         /* for debug purpose */
1318         u8 fix_rate;
1319         u8 fix_bw;
1320         u8 data_fb; /* data rate fallback, valid only when fix_rate is not 0xff */
1321         u8 driver_vcs_en; /* Enable=1, Disable=0 driver control vrtl_carrier_sense for tx */
1322         u8 driver_vcs_type;/* force 0:disable VCS, 1:RTS-CTS, 2:CTS-to-self when vcs_en=1. */
1323         u8 driver_ampdu_spacing;/* driver control AMPDU Density for peer sta's rx */
1324         u8 driver_rx_ampdu_factor;/* 0xff: disable drv ctrl, 0:8k, 1:16k, 2:32k, 3:64k; */
1325         u8 driver_rx_ampdu_spacing;  /* driver control Rx AMPDU Density */
1326         u8 fix_rx_ampdu_accept;
1327         u8 fix_rx_ampdu_size; /* 0~127, TODO:consider each sta and each TID */
1328         u8 tx_amsdu;
1329         u16 tx_amsdu_rate;
1330         unsigned char     in_cta_test;
1331 #ifdef DBG_RX_COUNTER_DUMP
1332         u8 dump_rx_cnt_mode;/*BIT0:drv,BIT1:mac,BIT2:phy*/
1333         u32 drv_rx_cnt_ok;
1334         u32 drv_rx_cnt_crcerror;
1335         u32 drv_rx_cnt_drop;
1336 #endif
1337
1338 #ifdef CONFIG_DBG_COUNTER
1339         struct rx_logs rx_logs;
1340         struct tx_logs tx_logs;
1341         struct int_logs int_logs;
1342 #endif
1343
1344 #ifdef CONFIG_MCC_MODE
1345         struct mcc_adapter_priv mcc_adapterpriv;
1346 #endif /* CONFIG_MCC_MODE */
1347 };
1348
1349 #define adapter_to_dvobj(adapter) ((adapter)->dvobj)
1350 #define adapter_to_regsty(adapter) dvobj_to_regsty(adapter_to_dvobj((adapter)))
1351 #define adapter_to_pwrctl(adapter) dvobj_to_pwrctl(adapter_to_dvobj((adapter)))
1352 #define adapter_wdev_data(adapter) (&((adapter)->wdev_data))
1353 #if defined(RTW_SINGLE_WIPHY)
1354         #define adapter_to_wiphy(adapter) dvobj_to_wiphy(adapter_to_dvobj(adapter))
1355 #else
1356         #define adapter_to_wiphy(adapter) ((adapter)->wiphy)
1357 #endif
1358
1359 #define adapter_to_rfctl(adapter) dvobj_to_rfctl(adapter_to_dvobj((adapter)))
1360
1361 #define adapter_mac_addr(adapter) (adapter->mac_addr)
1362
1363 #define mlme_to_adapter(mlme) container_of((mlme), struct _ADAPTER, mlmepriv)
1364 #define tdls_info_to_adapter(tdls) container_of((tdls), struct _ADAPTER, tdlsinfo)
1365
1366 #define rtw_get_chip_type(adapter) (((PADAPTER)adapter)->dvobj->chip_type)
1367 #define rtw_get_hw_type(adapter) (((PADAPTER)adapter)->dvobj->HardwareType)
1368 #define rtw_get_intf_type(adapter) (((PADAPTER)adapter)->dvobj->interface_type)
1369
1370 #define rtw_get_mi_nums(adapter) (((PADAPTER)adapter)->dvobj->iface_nums)
1371
1372 static inline void rtw_set_surprise_removed(_adapter *padapter)
1373 {
1374         ATOMIC_SET(&adapter_to_dvobj(padapter)->bSurpriseRemoved, _TRUE);
1375 }
1376 static inline void rtw_clr_surprise_removed(_adapter *padapter)
1377 {
1378         ATOMIC_SET(&adapter_to_dvobj(padapter)->bSurpriseRemoved, _FALSE);
1379 }
1380 static inline void rtw_set_drv_stopped(_adapter *padapter)
1381 {
1382         ATOMIC_SET(&adapter_to_dvobj(padapter)->bDriverStopped, _TRUE);
1383 }
1384 static inline void rtw_clr_drv_stopped(_adapter *padapter)
1385 {
1386         ATOMIC_SET(&adapter_to_dvobj(padapter)->bDriverStopped, _FALSE);
1387 }
1388 #define rtw_is_surprise_removed(padapter)       (ATOMIC_READ(&adapter_to_dvobj(padapter)->bSurpriseRemoved) == _TRUE)
1389 #define rtw_is_drv_stopped(padapter)            (ATOMIC_READ(&adapter_to_dvobj(padapter)->bDriverStopped) == _TRUE)
1390
1391 /*
1392  * Function disabled.
1393  *   */
1394 #define DF_TX_BIT               BIT0                    /*write_port_cancel*/
1395 #define DF_RX_BIT               BIT1                    /*read_port_cancel*/
1396 #define DF_IO_BIT               BIT2
1397
1398 /* #define RTW_DISABLE_FUNC(padapter, func) (ATOMIC_ADD(&adapter_to_dvobj(padapter)->disable_func, (func))) */
1399 /* #define RTW_ENABLE_FUNC(padapter, func) (ATOMIC_SUB(&adapter_to_dvobj(padapter)->disable_func, (func))) */
1400 __inline static void RTW_DISABLE_FUNC(_adapter *padapter, int func_bit)
1401 {
1402         int     df = ATOMIC_READ(&adapter_to_dvobj(padapter)->disable_func);
1403         df |= func_bit;
1404         ATOMIC_SET(&adapter_to_dvobj(padapter)->disable_func, df);
1405 }
1406
1407 __inline static void RTW_ENABLE_FUNC(_adapter *padapter, int func_bit)
1408 {
1409         int     df = ATOMIC_READ(&adapter_to_dvobj(padapter)->disable_func);
1410         df &= ~(func_bit);
1411         ATOMIC_SET(&adapter_to_dvobj(padapter)->disable_func, df);
1412 }
1413
1414 #define RTW_CANNOT_RUN(padapter) \
1415         (rtw_is_surprise_removed(padapter) || \
1416          rtw_is_drv_stopped(padapter))
1417
1418 #define RTW_IS_FUNC_DISABLED(padapter, func_bit) (ATOMIC_READ(&adapter_to_dvobj(padapter)->disable_func) & (func_bit))
1419
1420 #define RTW_CANNOT_IO(padapter) \
1421         (rtw_is_surprise_removed(padapter) || \
1422          RTW_IS_FUNC_DISABLED((padapter), DF_IO_BIT))
1423
1424 #define RTW_CANNOT_RX(padapter) \
1425         (RTW_CANNOT_RUN(padapter) || \
1426          RTW_IS_FUNC_DISABLED((padapter), DF_RX_BIT))
1427
1428 #define RTW_CANNOT_TX(padapter) \
1429         (RTW_CANNOT_RUN(padapter) || \
1430          RTW_IS_FUNC_DISABLED((padapter), DF_TX_BIT))
1431
1432 #ifdef CONFIG_PNO_SUPPORT
1433 int rtw_parse_ssid_list_tlv(char **list_str, pno_ssid_t *ssid, int max, int *bytes_left);
1434 int rtw_dev_pno_set(struct net_device *net, pno_ssid_t *ssid, int num,
1435                     int pno_time, int pno_repeat, int pno_freq_expo_max);
1436 #ifdef CONFIG_PNO_SET_DEBUG
1437         void rtw_dev_pno_debug(struct net_device *net);
1438 #endif /* CONFIG_PNO_SET_DEBUG */
1439 #endif /* CONFIG_PNO_SUPPORT */
1440
1441 int rtw_suspend_free_assoc_resource(_adapter *padapter);
1442 #ifdef CONFIG_WOWLAN
1443         int rtw_suspend_wow(_adapter *padapter);
1444         int rtw_resume_process_wow(_adapter *padapter);
1445 #endif
1446
1447 /* HCI Related header file */
1448 #ifdef CONFIG_USB_HCI
1449         #include <usb_osintf.h>
1450         #include <usb_ops.h>
1451         #include <usb_hal.h>
1452 #endif
1453
1454 #ifdef CONFIG_SDIO_HCI
1455         #include <sdio_osintf.h>
1456         #include <sdio_ops.h>
1457         #include <sdio_hal.h>
1458 #endif
1459
1460 #ifdef CONFIG_GSPI_HCI
1461         #include <gspi_osintf.h>
1462         #include <gspi_ops.h>
1463         #include <gspi_hal.h>
1464 #endif
1465
1466 #ifdef CONFIG_PCI_HCI
1467         #include <pci_osintf.h>
1468         #include <pci_ops.h>
1469         #include <pci_hal.h>
1470 #endif
1471
1472 #endif /* __DRV_TYPES_H__ */