Path: blob/master/ALFA-W1F1/RTL8814AU/hal/phydm/phydm_dig.h
1307 views
/******************************************************************************1*2* Copyright(c) 2007 - 2017 Realtek Corporation.3*4* This program is free software; you can redistribute it and/or modify it5* under the terms of version 2 of the GNU General Public License as6* published by the Free Software Foundation.7*8* This program is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for11* more details.12*13* The full GNU General Public License is included in this distribution in the14* file called LICENSE.15*16* Contact Information:17* wlanfae <[email protected]>18* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,19* Hsinchu 300, Taiwan.20*21* Larry Finger <[email protected]>22*23*****************************************************************************/2425#ifndef __PHYDMDIG_H__26#define __PHYDMDIG_H__2728#define DIG_VERSION "2.5" /* @Add new fa_cnt for VHT-SIGA/VHT-SIGB*/2930#define DIG_HW 031#define DIG_LIMIT_PERIOD 60 /*@60 sec*/3233/*@--------------------Define ---------------------------------------*/3435/*@=== [DIG Boundary] ========================================*/36/*@DIG coverage mode*/37#define DIG_MAX_COVERAGR 0x2638#define DIG_MIN_COVERAGE 0x1c39#define DIG_MAX_OF_MIN_COVERAGE 0x224041/*@[DIG Balance mode]*/42#if (DIG_HW == 1)43#define DIG_MAX_BALANCE_MODE 0x3244#else45#define DIG_MAX_BALANCE_MODE 0x3e46#endif47#define DIG_MAX_OF_MIN_BALANCE_MODE 0x2a4849/*@[DIG Performance mode]*/50#define DIG_MAX_PERFORMANCE_MODE 0x5a51#define DIG_MAX_OF_MIN_PERFORMANCE_MODE 0x40 /*@[WLANBB-871]*/52#define DIG_MIN_PERFORMANCE 0x205354/*@DIG DFS function*/55#define DIG_MAX_DFS 0x2856#define DIG_MIN_DFS 0x205758/*@DIG LPS function*/59#define DIG_MAX_LPS 0x3e60#define DIG_MIN_LPS 0x206162#ifdef PHYDM_TDMA_DIG_SUPPORT63#define DIG_NUM_OF_TDMA_STATES 2 /*@L, H state*/64#define DIG_TIMER_MS 25065#define ONE_SEC_MS 100066#endif6768/*@=== [DIG FA Threshold] ======================================*/6970/*Normal*/71#define DM_DIG_FA_TH0 50072#define DM_DIG_FA_TH1 7507374/*@LPS*/75#define DM_DIG_FA_TH0_LPS 4 /* @-> 4 lps */76#define DM_DIG_FA_TH1_LPS 15 /* @-> 15 lps */77#define DM_DIG_FA_TH2_LPS 30 /* @-> 30 lps */7879#define RSSI_OFFSET_DIG_LPS 580#define DIG_RECORD_NUM 48182/*@--------------------Enum-----------------------------------*/83enum dig_goupcheck_level {84DIG_GOUPCHECK_LEVEL_0,85DIG_GOUPCHECK_LEVEL_1,86DIG_GOUPCHECK_LEVEL_287};8889enum phydm_dig_mode {90PHYDM_DIG_PERFORAMNCE_MODE = 0,91PHYDM_DIG_COVERAGE_MODE = 1,92};9394#ifdef PHYDM_TDMA_DIG_SUPPORT95enum upd_type {96ENABLE_TDMA,97MODE_DECISION98};99100enum tdma_opmode {101MODE_PERFORMANCE = 1,102MODE_COVERAGE = 2103};104105#ifdef IS_USE_NEW_TDMA106enum tdma_dig_timer {107INIT_TDMA_DIG_TIMMER,108CANCEL_TDMA_DIG_TIMMER,109RELEASE_TDMA_DIG_TIMMER110};111112enum tdma_dig_state {113TDMA_DIG_LOW_STATE = 0,114TDMA_DIG_HIGH_STATE = 1,115NORMAL_DIG = 2116};117#endif118#endif119120/*@--------------------Define Struct-----------------------------------*/121#ifdef CFG_DIG_DAMPING_CHK122struct phydm_dig_recorder_strcut {123u8 igi_bitmap; /*@Don't add any new parameter before this*/124u8 igi_history[DIG_RECORD_NUM];125u32 fa_history[DIG_RECORD_NUM];126u8 damping_limit_en;127u8 damping_limit_val; /*@Limit IGI_dyn_min*/128u32 limit_time;129u8 limit_rssi;130};131#endif132133struct phydm_mcc_dig {134u8 mcc_rssi_A;135u8 mcc_rssi_B;136};137138struct phydm_dig_struct {139#ifdef CFG_DIG_DAMPING_CHK140struct phydm_dig_recorder_strcut dig_recorder_t;141u8 dig_dl_en; /*@damping limit function enable*/142#endif143boolean is_dbg_fa_th;144u8 cur_ig_value;145u32 rvrt_val; /*all rvrt_val for pause API must set to u32*/146u8 igi_backup;147u8 rx_gain_range_max; /*@dig_dynamic_max*/148u8 rx_gain_range_min; /*@dig_dynamic_min*/149u8 dm_dig_max; /*@Absolutly upper bound*/150u8 dm_dig_min; /*@Absolutly lower bound*/151u8 dig_max_of_min; /*@Absolutly max of min*/152u32 ant_div_rssi_max;153u8 *is_p2p_in_process;154enum dig_goupcheck_level go_up_chk_lv;155u16 fa_th[3];156#if (RTL8822B_SUPPORT || RTL8197F_SUPPORT || RTL8821C_SUPPORT ||\157RTL8198F_SUPPORT || RTL8192F_SUPPORT || RTL8195B_SUPPORT ||\158RTL8822C_SUPPORT || RTL8814B_SUPPORT || RTL8721D_SUPPORT ||\159RTL8710C_SUPPORT || RTL8812F_SUPPORT || RTL8197G_SUPPORT)160u8 rf_gain_idx;161u8 agc_table_idx;162u8 big_jump_lmt[16];163u8 enable_adjust_big_jump:1;164u8 big_jump_step1:3;165u8 big_jump_step2:2;166u8 big_jump_step3:2;167#endif168u8 upcheck_init_val;169u8 lv0_ratio_reciprocal;170u8 lv1_ratio_reciprocal;171#ifdef PHYDM_TDMA_DIG_SUPPORT172u8 cur_ig_value_tdma;173u8 low_ig_value;174u8 tdma_dig_state; /*@To distinguish which state is now.(L-sate or H-state)*/175u32 tdma_dig_cnt; /*@for phydm_tdma_dig_timer_check use*/176u8 pre_tdma_dig_cnt;177u8 sec_factor;178u32 cur_timestamp;179u32 pre_timestamp;180u32 fa_start_timestamp;181u32 fa_end_timestamp;182u32 fa_acc_1sec_timestamp;183#ifdef IS_USE_NEW_TDMA184u8 tdma_dig_block_cnt;/*@for 1 second dump indicator use*/185/*@dynamic upper bound for L/H state*/186u8 tdma_rx_gain_max[DIG_NUM_OF_TDMA_STATES];187/*@dynamic lower bound for L/H state*/188u8 tdma_rx_gain_min[DIG_NUM_OF_TDMA_STATES];189/*To distinguish current state(L-sate or H-state)*/190#endif191#endif192};193194struct phydm_fa_struct {195u32 cnt_parity_fail;196u32 cnt_rate_illegal;197u32 cnt_crc8_fail;198u32 cnt_crc8_fail_vhta;199u32 cnt_crc8_fail_vhtb;200u32 cnt_mcs_fail;201u32 cnt_mcs_fail_vht;202u32 cnt_ofdm_fail;203u32 cnt_ofdm_fail_pre; /* @For RTL8881A */204u32 cnt_cck_fail;205u32 cnt_all;206u32 cnt_all_accumulated;207u32 cnt_all_pre;208u32 cnt_fast_fsync;209u32 cnt_sb_search_fail;210u32 cnt_ofdm_cca;211u32 cnt_cck_cca;212u32 cnt_cca_all;213u32 cnt_bw_usc;214u32 cnt_bw_lsc;215u32 cnt_cck_crc32_error;216u32 cnt_cck_crc32_ok;217u32 cnt_ofdm_crc32_error;218u32 cnt_ofdm_crc32_ok;219u32 cnt_ht_crc32_error;220u32 cnt_ht_crc32_ok;221u32 cnt_ht_crc32_error_agg;222u32 cnt_ht_crc32_ok_agg;223u32 cnt_vht_crc32_error;224u32 cnt_vht_crc32_ok;225u32 cnt_crc32_error_all;226u32 cnt_crc32_ok_all;227u32 time_fa_all;228boolean cck_block_enable;229boolean ofdm_block_enable;230u32 dbg_port0;231boolean edcca_flag;232};233234#ifdef PHYDM_TDMA_DIG_SUPPORT235struct phydm_fa_acc_struct {236u32 cnt_parity_fail;237u32 cnt_rate_illegal;238u32 cnt_crc8_fail;239u32 cnt_mcs_fail;240u32 cnt_ofdm_fail;241u32 cnt_ofdm_fail_pre; /*@For RTL8881A*/242u32 cnt_cck_fail;243u32 cnt_all;244u32 cnt_all_pre;245u32 cnt_fast_fsync;246u32 cnt_sb_search_fail;247u32 cnt_ofdm_cca;248u32 cnt_cck_cca;249u32 cnt_cca_all;250u32 cnt_cck_crc32_error;251u32 cnt_cck_crc32_ok;252u32 cnt_ofdm_crc32_error;253u32 cnt_ofdm_crc32_ok;254u32 cnt_ht_crc32_error;255u32 cnt_ht_crc32_ok;256u32 cnt_vht_crc32_error;257u32 cnt_vht_crc32_ok;258u32 cnt_crc32_error_all;259u32 cnt_crc32_ok_all;260u32 cnt_all_1sec;261u32 cnt_cca_all_1sec;262u32 cnt_cck_fail_1sec;263};264265#endif /*@#ifdef PHYDM_TDMA_DIG_SUPPORT*/266267/*@--------------------Function declaration-----------------------------*/268void phydm_write_dig_reg(void *dm_void, u8 igi);269270void odm_write_dig(void *dm_void, u8 current_igi);271272u8 phydm_get_igi(void *dm_void, enum bb_path path);273274void phydm_set_dig_val(void *dm_void, u32 *val_buf, u8 val_len);275276void odm_pause_dig(void *dm_void, enum phydm_pause_type pause_type,277enum phydm_pause_level pause_level, u8 igi_value);278279void phydm_dig_init(void *dm_void);280281void phydm_dig(void *dm_void);282283void phydm_dig_lps_32k(void *dm_void);284285void phydm_dig_by_rssi_lps(void *dm_void);286287void phydm_false_alarm_counter_statistics(void *dm_void);288289#ifdef PHYDM_TDMA_DIG_SUPPORT290void phydm_set_tdma_dig_timer(void *dm_void);291292void phydm_tdma_dig_timer_check(void *dm_void);293294void phydm_tdma_dig(void *dm_void);295296void phydm_tdma_false_alarm_counter_check(void *dm_void);297298void phydm_tdma_dig_add_interrupt_mask_handler(void *dm_void);299300void phydm_false_alarm_counter_reset(void *dm_void);301302void phydm_false_alarm_counter_acc(void *dm_void, boolean rssi_dump_en);303304void phydm_false_alarm_counter_acc_reset(void *dm_void);305306void phydm_tdma_dig_para_upd(void *dm_void, enum upd_type type, u8 input);307308#ifdef IS_USE_NEW_TDMA309void phydm_tdma_dig_timers(void *dm_void, u8 state);310311void phydm_tdma_dig_cbk(void *dm_void);312313void phydm_tdma_dig_workitem_callback(void *dm_void);314315void phydm_tdma_fa_cnt_chk(void *dm_void);316317void phydm_tdma_low_dig(void *dm_void);318319void phydm_tdma_high_dig(void *dm_void);320321void phydm_fa_cnt_acc(void *dm_void, boolean rssi_dump_en,322u8 cur_tdma_dig_state);323#endif /*@#ifdef IS_USE_NEW_TDMA*/324#endif /*@#ifdef PHYDM_TDMA_DIG_SUPPORT*/325326void phydm_set_ofdm_agc_tab(void *dm_void, u8 tab_sel);327328void phydm_dig_debug(void *dm_void, char input[][16], u32 *_used, char *output,329u32 *_out_len);330331#ifdef CONFIG_MCC_DM332void phydm_mcc_igi_cal(void *dm_void);333#endif334335336#endif337338339