1 /******************************************************************************
3 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
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.
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
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
19 ******************************************************************************/
20 /*-------------------------------------------------------------------------------
22 For type defines and data structure defines
24 --------------------------------------------------------------------------------*/
27 #ifndef __DRV_TYPES_H__
28 #define __DRV_TYPES_H__
31 #include <basic_types.h>
32 #include <osdep_service.h>
33 #include <rtw_byteorder.h>
34 #include <wlan_bssdef.h>
36 #include <ieee80211.h>
37 #ifdef CONFIG_ARP_KEEP_ALIVE
38 #include <net/neighbour.h>
43 #include <drv_types_xp.h>
47 #include <drv_types_ce.h>
51 #include <drv_types_linux.h>
63 typedef struct _ADAPTER _adapter, ADAPTER, *PADAPTER;
65 #include <rtw_debug.h>
68 #ifdef CONFIG_80211N_HT
72 #ifdef CONFIG_80211AC_VHT
76 #ifdef CONFIG_INTEL_WIDI
77 #include <rtw_intel_widi.h>
81 #include <cmd_osdep.h>
82 #include <rtw_security.h>
84 #include <xmit_osdep.h>
87 #ifdef CONFIG_BEAMFORMING
88 #include <rtw_beamforming.h>
91 #include <recv_osdep.h>
92 #include <rtw_efuse.h>
93 #include <rtw_sreset.h>
96 #include<hal_com_h2c.h>
97 #include <hal_com_led.h>
98 #include "../hal/hal_dm.h"
100 #include <rtw_pwrctrl.h>
101 #include <rtw_mlme.h>
102 #include <mlme_osdep.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>
115 #include <rtw_efuse.h>
116 #include <rtw_version.h>
119 #ifdef CONFIG_PREALLOC_RX_SKB_BUFFER
126 #include <rtw_tdls.h>
127 #endif /* CONFIG_TDLS */
129 #ifdef CONFIG_WAPI_SUPPORT
130 #include <rtw_wapi.h>
131 #endif /* CONFIG_WAPI_SUPPORT */
133 #ifdef CONFIG_DRVEXT_MODULE
134 #include <drvext_api.h>
135 #endif /* CONFIG_DRVEXT_MODULE */
137 #ifdef CONFIG_MP_INCLUDED
139 #endif /* CONFIG_MP_INCLUDED */
142 #include <rtw_br_ext.h>
143 #endif /* CONFIG_BR_EXT */
147 #endif /* CONFIG_IOL */
150 #include <if_ether.h>
151 #include <ethernet.h>
152 #include <circ_buf.h>
154 #include <rtw_android.h>
156 #ifdef CONFIG_BT_COEXIST
157 #include <rtw_btcoex.h>
158 #endif /* CONFIG_BT_COEXIST */
160 #ifdef CONFIG_MCC_MODE
162 #endif /*CONFIG_MCC_MODE */
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)
171 struct specific_device_id {
180 struct registry_priv {
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 */
191 u8 preamble;/* long, short, auto */
192 u8 vrtl_carrier_sense;/* Enable, Disable, Auto */
193 u8 vcs_type;/* RTS/CTS, CTS-to-self */
210 #ifdef CONFIG_TX_EARLY_MODE
223 WLAN_BSSID_EX dev_network;
225 #ifdef CONFIG_80211N_HT
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 */
231 u8 ampdu_enable;/* for tx */
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 */
240 /* BIT0: Enable VHT LDPC Rx, BIT1: Enable VHT LDPC Tx, BIT4: Enable HT LDPC Rx, BIT5: Enable HT LDPC Tx */
242 /* BIT0: Enable VHT STBC Rx, BIT1: Enable VHT STBC Tx, BIT4: Enable HT STBC Rx, BIT5: Enable HT STBC Tx */
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
253 u8 beamformer_rf_num;
254 u8 beamformee_rf_num;
255 #endif /* CONFIG_80211N_HT */
257 #ifdef CONFIG_80211AC_VHT
258 u8 vht_enable; /* 0:disable, 1:enable, 2:auto */
261 #endif /* CONFIG_80211AC_VHT */
268 u8 wifi_spec;/* !turbo_mode */
269 u8 special_rf_path; /* 0: 2T2R ,1: only turn on path A 1T1R */
272 u8 excl_chs[MAX_CHANNEL_NUM];
273 u8 full_ch_in_p2p_handshake; /* 0: reply only softap channel, 1: reply full channel list*/
275 #ifdef CONFIG_BT_COEXIST
282 BOOLEAN bAcceptAddbaReq;
286 u8 drv_ant_band_switch;
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 */
294 u8 hw_wps_pbc;/* 0:disable,1:enable */
296 #ifdef CONFIG_ADAPTOR_INFO_CACHING_FILE
297 char adaptor_info_caching_file_path[PATH_LENGTH_MAX];
300 #ifdef CONFIG_LAYER2_ROAMING
301 u8 max_roaming_times; /* the max number driver will try to roaming */
305 u8 fw_iol; /* enable iol without other concern */
317 #ifdef CONFIG_SPECIAL_SETTING_FOR_FUNAI_TV
318 u8 force_ant;/* 0 normal,1 main,2 aux */
319 u8 force_igi;/* 0 normal */
324 /* for pll reference clock selction */
327 /* define for tx power adjust */
328 u8 RegEnableTxPowerLimit;
329 u8 RegEnableTxPowerByRate;
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];
345 u8 PowerTracking_Type;
350 #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
352 u8 RegDecryptCustomFile;
354 #ifdef CONFIG_CONCURRENT_MODE
355 u8 virtual_iface_num;
363 u8 adaptivity_dc_backoff;
364 s8 adaptivity_th_l2h_ini;
365 s8 adaptivity_th_edcca_hl_diff;
368 BOOLEAN bFileMaskEfuse;
369 #ifdef CONFIG_AUTO_CHNL_SEL_NHM
373 u32 reg_rxgain_offset_2g;
374 u32 reg_rxgain_offset_5gl;
375 u32 reg_rxgain_offset_5gm;
376 u32 reg_rxgain_offset_5gh;
378 #ifdef CONFIG_DFS_MASTER
379 u8 dfs_region_domain;
387 #ifdef CONFIG_MCC_MODE
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 */
398 bool default_patterns_en;
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)
406 #define GetRegAmplifierType2G(_Adapter) (_Adapter->registrypriv.AmplifierType_2G)
407 #define GetRegAmplifierType5G(_Adapter) (_Adapter->registrypriv.AmplifierType_5G)
409 #define GetRegTxBBSwing_2G(_Adapter) (_Adapter->registrypriv.TxBBSwing_2G)
410 #define GetRegTxBBSwing_5G(_Adapter) (_Adapter->registrypriv.TxBBSwing_5G)
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)
417 #define BSSID_OFT(field) ((ULONG)FIELD_OFFSET(WLAN_BSSID_EX, field))
418 #define BSSID_SZ(field) sizeof(((PWLAN_BSSID_EX) 0)->field)
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))
425 #define REGSTY_IS_11AC_ENABLE(regsty) ((regsty)->vht_enable != 0)
426 #define REGSTY_IS_11AC_AUTO(regsty) ((regsty)->vht_enable == 2)
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;
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>
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)
451 #define is_primary_adapter(adapter) (1)
452 #define is_vir_adapter(adapter) (0)
453 #define get_hw_port(adapter) (HW_PORT0)
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])
459 #define GetDefaultAdapter(padapter) padapter
462 IFACE_ID0, /*PRIMARY_ADAPTER*/
473 #define VIF_START_ID 1
475 #ifdef CONFIG_DBG_COUNTER
479 u32 intf_rx_err_recvframe;
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;
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;
515 u32 os_indicate_ap_mcast;
516 u32 os_indicate_ap_forward;
517 u32 os_indicate_ap_self;
528 u32 os_tx_m2u_ignore_fw_linked;
529 u32 os_tx_m2u_ignore_self;
531 u32 os_tx_m2u_entry_err_xmit;
532 u32 os_tx_m2u_entry_err_skb;
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;
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;
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;
570 u32 intf_tx_direct_err_coalesce;
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;
598 #endif /* CONFIG_DBG_COUNTER */
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;
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;
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;
641 struct rtw_traffic_statistics {
648 u32 cur_tx_tp; /* Tx throughput in MBps. */
656 u32 cur_rx_tp; /* Rx throughput in MBps. */
659 #define SEC_CAP_CHK_BMC BIT0
661 #define SEC_STATUS_STA_PK_GK_CONFLICT_DIS_BMC_SEARCH BIT0
665 #if (SEC_CAM_ENT_NUM_SW_LIMIT > 32)
668 #if (SEC_CAM_ENT_NUM_SW_LIMIT > 64)
671 #if (SEC_CAM_ENT_NUM_SW_LIMIT > 96)
683 struct sec_cam_bmp used;
685 _mutex sec_cam_access_mutex;
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]
701 #if (MACID_NUM_SW_LIMIT > 32)
704 #if (MACID_NUM_SW_LIMIT > 64)
707 #if (MACID_NUM_SW_LIMIT > 96)
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];
725 #ifdef CONFIG_DFS_MASTER
726 bool radar_detect_by_others;
727 u8 dfs_master_enabled;
732 u8 radar_detect_offset;
737 u8 dfs_ch_sel_d_flags;
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;
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))
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*/
764 #ifdef CONFIG_MBSSID_CAM
765 #define TOTAL_MBID_CAM_NUM 8
766 #define INVALID_CAM_ID 0xFF
767 struct mbid_cam_ctl_t {
770 ATOMIC_T mbid_entry_num;
772 struct mbid_cam_cache {
774 /*u8 role;*/ /*WIFI_STATION_STATE or WIFI_AP_STATE*/
775 u8 mac_addr[ETH_ALEN];
777 #endif /*CONFIG_MBSSID_CAM*/
780 struct halmac_indicator {
781 struct submit_ctx *sctx;
792 * 0: no need to call halmac_send_general_info()
793 * 1: need to call halmac_send_general_info()
795 u8 send_general_info;
797 /* For asynchronous functions */
798 struct halmac_indicator *indicator;
800 #ifdef CONFIG_SDIO_HCI
801 /* Store hardware tx queue page number setting */
802 u16 txpage[HW_QUEUE_ENTRY];
803 #endif /* CONFIG_SDIO_HCI */
805 #endif /* RTW_HALMAC */
808 /*-------- below is common data --------*/
811 u8 interface_type;/*USB,SDIO,SPI,PCI*/
813 ATOMIC_T bSurpriseRemoved;
814 ATOMIC_T bDriverStopped;
816 s32 processing_dev_remove;
818 struct debug_priv drv_dbg;
820 _mutex hw_init_mutex;
821 _mutex h2c_fwcmd_mutex;
824 _mutex rf_read_reg_mutex;
825 #ifdef CONFIG_SDIO_INDIRECT_ACCESS
826 _mutex sd_indirect_access_mutex;
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 */
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;
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 */
844 struct macid_ctl_t macid_ctl;
846 struct cam_ctl_t cam_ctl;
847 struct sec_cam_ent cam_cache[SEC_CAM_ENT_NUM_SW_LIMIT];
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];
854 struct rf_ctl_t rf_ctl;
856 /* For 92D, DMDP have 2 interface. */
860 /* In /Out Pipe information */
863 u8 Queue2Pipe[HW_QUEUE_ENTRY];/* for out pipe mapping */
866 ATOMIC_T continual_io_error;
868 ATOMIC_T disable_func;
870 struct pwrctrl_priv pwrctl_priv;
872 struct rtw_traffic_statistics traffic_stat;
874 #if defined(CONFIG_IOCTL_CFG80211) && defined(RTW_SINGLE_WIPHY)
878 #ifdef CONFIG_SWTIMER_BASED_TXBCN
884 struct halmacpriv hmpriv;
885 #endif /* RTW_HALMAC */
887 /*-------- below is for SDIO INTERFACE --------*/
896 /*-------- below is for USB INTERFACE --------*/
898 #ifdef CONFIG_USB_HCI
900 u8 usb_speed; /* 1.1, 2.0 or 3.0 */
904 int ep_num[6]; /* endpoint number */
908 _sema usb_suspend_sema;
910 #ifdef CONFIG_USB_VENDOR_REQ_MUTEX
911 _mutex usb_vendor_req_mutex;
914 #ifdef CONFIG_USB_VENDOR_REQ_BUFFER_PREALLOC
915 u8 *usb_alloc_vendor_req_buf;
916 u8 *usb_vendor_req_buf;
919 #ifdef PLATFORM_WINDOWS
920 /* related device objects */
921 PDEVICE_OBJECT pphysdevobj;/* pPhysDevObj; */
922 PDEVICE_OBJECT pfuncdevobj;/* pFuncDevObj; */
923 PDEVICE_OBJECT pnextdevobj;/* pNextDevObj; */
925 u8 nextdevstacksz;/* unsigned char NextDeviceStackSize; */ /* = (CHAR)CEdevice->pUsbDevObj->StackSize + 1; */
927 /* urb for control diescriptor request */
929 #ifdef PLATFORM_OS_XP
930 struct _URB_CONTROL_DESCRIPTOR_REQUEST descriptor_urb;
931 PUSB_CONFIGURATION_DESCRIPTOR pconfig_descriptor;/* UsbConfigurationDescriptor; */
934 #ifdef PLATFORM_OS_CE
935 WCHAR active_path[MAX_ACTIVE_REG_PATH]; /* adapter regpath */
936 USB_EXTENSION usb_extension;
938 _nic_hdl pipehdls_r8192c[0x10];
941 u32 config_descriptor_len;/* ULONG UsbConfigurationDescriptorLength; */
942 #endif/* PLATFORM_WINDOWS */
944 #ifdef PLATFORM_LINUX
945 struct usb_interface *pusbintf;
946 struct usb_device *pusbdev;
947 #endif/* PLATFORM_LINUX */
949 #ifdef PLATFORM_FREEBSD
950 struct usb_interface *pusbintf;
951 struct usb_device *pusbdev;
952 #endif/* PLATFORM_FREEBSD */
954 #endif/* CONFIG_USB_HCI */
956 /*-------- below is for PCIE INTERFACE --------*/
958 #ifdef CONFIG_PCI_HCI
960 #ifdef PLATFORM_LINUX
961 struct pci_dev *ppcidev;
964 unsigned long pci_mem_end; /* shared mem end */
965 unsigned long pci_mem_start; /* shared mem start */
968 unsigned long pci_base_addr; /* device I/O address */
970 #ifdef RTK_129X_PLATFORM
971 unsigned long ctrl_start;
973 unsigned long mask_addr;
975 /* PCI TRANSLATE addr */
976 unsigned long tran_addr;
982 struct pci_priv pcipriv;
984 unsigned int irq; /* get from pci_dev.irq, store to net_device.irq */
987 RT_ISR_CONTENT isr_content;
992 u8 const_amdpci_aspm;
993 u8 const_hwsw_rfoff_d3;
994 u8 const_support_pciaspm;
996 u8 const_hostpci_aspm_setting;
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;
1002 #endif/* PLATFORM_LINUX */
1004 #endif/* CONFIG_PCI_HCI */
1006 #ifdef CONFIG_MCC_MODE
1007 struct mcc_obj_priv mcc_objpriv;
1008 #endif /*CONFIG_MCC_MODE */
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)
1019 #define dvobj_to_rfctl(dvobj) (&(dvobj->rf_ctl))
1020 #define rfctl_to_dvobj(rfctl) container_of((rfctl), struct dvobj_priv, rf_ctl)
1022 #ifdef PLATFORM_LINUX
1023 static struct device *dvobj_to_dev(struct dvobj_priv *dvobj)
1025 /* todo: get interface type from dvobj and the return the dev accordingly */
1026 #ifdef RTW_DVOBJ_CHIP_HW_TYPE
1029 #ifdef CONFIG_USB_HCI
1030 return &dvobj->pusbintf->dev;
1032 #ifdef CONFIG_SDIO_HCI
1033 return &dvobj->intf_data.func->dev;
1035 #ifdef CONFIG_GSPI_HCI
1036 return &dvobj->intf_data.func->dev;
1038 #ifdef CONFIG_PCI_HCI
1039 return &dvobj->ppcidev->dev;
1044 _adapter *dvobj_get_port0_adapter(struct dvobj_priv *dvobj);
1045 #define dvobj_get_primary_adapter(dvobj) ((dvobj)->padapters[IFACE_ID0])
1056 enum _ADAPTER_TYPE {
1062 typedef enum _DRIVER_STATE {
1064 DRIVER_DISAPPEAR = 1,
1065 DRIVER_REPLACE_DONGLE = 2,
1068 #ifdef CONFIG_INTEL_PROXIM
1070 bool proxim_support;
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);
1078 #endif /* CONFIG_INTEL_PROXIM */
1080 #ifdef CONFIG_MAC_LOOPBACK_DRIVER
1081 typedef struct loopbackdata {
1083 _thread_hdl_ lbkthread;
1093 } LOOPBACKDATA, *PLOOPBACKDATA;
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 */
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;
1117 struct led_priv ledpriv;
1119 #ifdef CONFIG_MP_INCLUDED
1120 struct mp_priv mppriv;
1123 #ifdef CONFIG_DRVEXT_MODULE
1124 struct drvext_priv drvextpriv;
1127 #ifdef CONFIG_AP_MODE
1128 struct hostapd_priv *phostapdpriv;
1131 #ifdef CONFIG_IOCTL_CFG80211
1133 struct cfg80211_wifidirect_info cfg80211_wdinfo;
1134 #endif /* CONFIG_P2P */
1135 #endif /* CONFIG_IOCTL_CFG80211 */
1140 struct wifidirect_info wdinfo;
1141 #endif /* CONFIG_P2P */
1144 struct tdls_info tdlsinfo;
1145 #endif /* CONFIG_TDLS */
1147 #ifdef CONFIG_WAPI_SUPPORT
1154 struct wifi_display_info wfd_info;
1155 #endif /* CONFIG_WFD */
1157 #ifdef CONFIG_BT_COEXIST_SOCKET_TRX
1158 struct bt_coex_info coex_info;
1159 #endif /* CONFIG_BT_COEXIST_SOCKET_TRX */
1161 ERROR_CODE LastError; /* <20130613, Kordan> Only the functions associated with MP records the error code by now. */
1165 struct hal_ops HalFunc;
1170 u8 EepromAddressSize;
1171 u8 bDriverIsGoingToUnload;
1172 u8 init_adpt_in_progress;
1174 #ifdef CONFIG_GPIO_API
1176 struct gpio_int_priv {
1178 u8 interrupt_enable_mask;
1179 void (*callback[8])(u8 level);
1182 _thread_hdl_ cmdThread;
1183 _thread_hdl_ evtThread;
1184 _thread_hdl_ xmitThread;
1185 _thread_hdl_ recvThread;
1187 #ifndef PLATFORM_LINUX
1188 NDIS_STATUS(*dvobj_init)(struct dvobj_priv *dvobj);
1189 void (*dvobj_deinit)(struct dvobj_priv *dvobj);
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);
1198 void (*intf_start)(_adapter *adapter);
1199 void (*intf_stop)(_adapter *adapter);
1201 #ifdef PLATFORM_WINDOWS
1202 _nic_hdl hndis_adapter;/* hNdisAdapter(NDISMiniportAdapterHandle); */
1203 _nic_hdl hndis_config;/* hNdisConfiguration; */
1206 u32 NdisPacketFilter;
1207 u8 MCList[MAX_MCAST_LIST_NUM][6];
1209 #endif /* end of PLATFORM_WINDOWS */
1212 #ifdef PLATFORM_LINUX
1214 char old_ifname[IFNAMSIZ];
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];
1222 } rereg_nd_name_priv;
1224 u8 ndev_unregistering;
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;
1231 #ifdef CONFIG_MCC_MODE
1232 struct proc_dir_entry *dir_mcc;
1233 #endif /* CONFIG_MCC_MODE */
1235 #ifdef CONFIG_IOCTL_CFG80211
1236 struct wireless_dev *rtw_wdev;
1237 struct rtw_wdev_priv wdev_data;
1239 #if !defined(RTW_SINGLE_WIPHY)
1240 struct wiphy *wiphy;
1243 #endif /* CONFIG_IOCTL_CFG80211 */
1246 struct napi_struct napi;
1247 #endif /* CONFIG_NAPI */
1249 #endif /* PLATFORM_LINUX */
1251 #ifdef PLATFORM_FREEBSD
1255 #endif /* PLATFORM_FREEBSD */
1256 u8 mac_addr[ETH_ALEN];
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;
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;
1273 #ifdef CONFIG_AUTOSUSPEND
1274 u8 bDisableAutosuspend;
1277 u8 isprimary; /* is primary adapter or not */
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 */
1286 /*extend to support multi interface*/
1287 /*IFACE_ID0 is equals to PRIMARY_ADAPTER
1288 IFACE_ID1 is equals to VIRTUAL_ADAPTER*/
1291 #ifdef CONFIG_BR_EXT
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];
1303 struct br_ext_info ethBrExtInfo;
1304 #endif /* CONFIG_BR_EXT */
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 */
1313 #ifdef CONFIG_MAC_LOOPBACK_DRIVER
1314 PLOOPBACKDATA ploopback;
1317 /* for debug purpose */
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 */
1330 unsigned char in_cta_test;
1331 #ifdef DBG_RX_COUNTER_DUMP
1332 u8 dump_rx_cnt_mode;/*BIT0:drv,BIT1:mac,BIT2:phy*/
1334 u32 drv_rx_cnt_crcerror;
1335 u32 drv_rx_cnt_drop;
1338 #ifdef CONFIG_DBG_COUNTER
1339 struct rx_logs rx_logs;
1340 struct tx_logs tx_logs;
1341 struct int_logs int_logs;
1344 #ifdef CONFIG_MCC_MODE
1345 struct mcc_adapter_priv mcc_adapterpriv;
1346 #endif /* CONFIG_MCC_MODE */
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))
1356 #define adapter_to_wiphy(adapter) ((adapter)->wiphy)
1359 #define adapter_to_rfctl(adapter) dvobj_to_rfctl(adapter_to_dvobj((adapter)))
1361 #define adapter_mac_addr(adapter) (adapter->mac_addr)
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)
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)
1370 #define rtw_get_mi_nums(adapter) (((PADAPTER)adapter)->dvobj->iface_nums)
1372 static inline void rtw_set_surprise_removed(_adapter *padapter)
1374 ATOMIC_SET(&adapter_to_dvobj(padapter)->bSurpriseRemoved, _TRUE);
1376 static inline void rtw_clr_surprise_removed(_adapter *padapter)
1378 ATOMIC_SET(&adapter_to_dvobj(padapter)->bSurpriseRemoved, _FALSE);
1380 static inline void rtw_set_drv_stopped(_adapter *padapter)
1382 ATOMIC_SET(&adapter_to_dvobj(padapter)->bDriverStopped, _TRUE);
1384 static inline void rtw_clr_drv_stopped(_adapter *padapter)
1386 ATOMIC_SET(&adapter_to_dvobj(padapter)->bDriverStopped, _FALSE);
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)
1392 * Function disabled.
1394 #define DF_TX_BIT BIT0 /*write_port_cancel*/
1395 #define DF_RX_BIT BIT1 /*read_port_cancel*/
1396 #define DF_IO_BIT BIT2
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)
1402 int df = ATOMIC_READ(&adapter_to_dvobj(padapter)->disable_func);
1404 ATOMIC_SET(&adapter_to_dvobj(padapter)->disable_func, df);
1407 __inline static void RTW_ENABLE_FUNC(_adapter *padapter, int func_bit)
1409 int df = ATOMIC_READ(&adapter_to_dvobj(padapter)->disable_func);
1411 ATOMIC_SET(&adapter_to_dvobj(padapter)->disable_func, df);
1414 #define RTW_CANNOT_RUN(padapter) \
1415 (rtw_is_surprise_removed(padapter) || \
1416 rtw_is_drv_stopped(padapter))
1418 #define RTW_IS_FUNC_DISABLED(padapter, func_bit) (ATOMIC_READ(&adapter_to_dvobj(padapter)->disable_func) & (func_bit))
1420 #define RTW_CANNOT_IO(padapter) \
1421 (rtw_is_surprise_removed(padapter) || \
1422 RTW_IS_FUNC_DISABLED((padapter), DF_IO_BIT))
1424 #define RTW_CANNOT_RX(padapter) \
1425 (RTW_CANNOT_RUN(padapter) || \
1426 RTW_IS_FUNC_DISABLED((padapter), DF_RX_BIT))
1428 #define RTW_CANNOT_TX(padapter) \
1429 (RTW_CANNOT_RUN(padapter) || \
1430 RTW_IS_FUNC_DISABLED((padapter), DF_TX_BIT))
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 */
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);
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>
1454 #ifdef CONFIG_SDIO_HCI
1455 #include <sdio_osintf.h>
1456 #include <sdio_ops.h>
1457 #include <sdio_hal.h>
1460 #ifdef CONFIG_GSPI_HCI
1461 #include <gspi_osintf.h>
1462 #include <gspi_ops.h>
1463 #include <gspi_hal.h>
1466 #ifdef CONFIG_PCI_HCI
1467 #include <pci_osintf.h>
1468 #include <pci_ops.h>
1469 #include <pci_hal.h>
1472 #endif /* __DRV_TYPES_H__ */