1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2016  Realtek Corporation.
5  *
6  * Contact Information:
7  * wlanfae <wlanfae@realtek.com>
8  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
9  * Hsinchu 300, Taiwan.
10  *
11  * Larry Finger <Larry.Finger@lwfinger.net>
12  *
13  *****************************************************************************/
14 
15 #ifndef __PHYDMADAPTIVITY_H__
16 #define __PHYDMADAPTIVITY_H__
17 
18 /*20160902 changed by Kevin, refine method for searching pwdb lower bound*/
19 #define ADAPTIVITY_VERSION "9.3.5"
20 
21 #define pwdb_upper_bound 7
22 #define dfir_loss 5
23 
24 enum phydm_adapinfo {
25 	PHYDM_ADAPINFO_CARRIER_SENSE_ENABLE = 0,
26 	PHYDM_ADAPINFO_DCBACKOFF,
27 	PHYDM_ADAPINFO_DYNAMICLINKADAPTIVITY,
28 	PHYDM_ADAPINFO_TH_L2H_INI,
29 	PHYDM_ADAPINFO_TH_EDCCA_HL_DIFF,
30 	PHYDM_ADAPINFO_AP_NUM_TH
31 
32 };
33 
34 enum phydm_set_lna {
35 	phydm_disable_lna = 0,
36 	phydm_enable_lna = 1,
37 };
38 
39 enum phydm_trx_mux_type {
40 	phydm_shutdown = 0,
41 	phydm_standby_mode = 1,
42 	phydm_tx_mode = 2,
43 	phydm_rx_mode = 3
44 };
45 
46 enum phydm_mac_edcca_type {
47 	phydm_ignore_edcca = 0,
48 	phydm_dont_ignore_edcca = 1
49 };
50 
51 struct adaptivity_statistics {
52 	s8 th_l2h_ini_backup;
53 	s8 th_edcca_hl_diff_backup;
54 	s8 igi_base;
55 	u8 igi_target;
56 	u8 nhm_wait;
57 	s8 h2l_lb;
58 	s8 l2h_lb;
59 	bool is_first_link;
60 	bool is_check;
61 	bool dynamic_link_adaptivity;
62 	u8 ap_num_th;
63 	u8 adajust_igi_level;
64 	bool acs_for_adaptivity;
65 	s8 backup_l2h;
66 	s8 backup_h2l;
67 	bool is_stop_edcca;
68 };
69 
70 void phydm_pause_edcca(void *dm_void, bool is_pasue_edcca);
71 
72 void phydm_check_adaptivity(void *dm_void);
73 
74 void phydm_check_environment(void *dm_void);
75 
76 void phydm_nhm_counter_statistics_init(void *dm_void);
77 
78 void phydm_nhm_counter_statistics(void *dm_void);
79 
80 void phydm_nhm_counter_statistics_reset(void *dm_void);
81 
82 void phydm_get_nhm_counter_statistics(void *dm_void);
83 
84 void phydm_mac_edcca_state(void *dm_void, enum phydm_mac_edcca_type state);
85 
86 void phydm_set_edcca_threshold(void *dm_void, s8 H2L, s8 L2H);
87 
88 void phydm_set_trx_mux(void *dm_void, enum phydm_trx_mux_type tx_mode,
89 		       enum phydm_trx_mux_type rx_mode);
90 
91 bool phydm_cal_nhm_cnt(void *dm_void);
92 
93 void phydm_search_pwdb_lower_bound(void *dm_void);
94 
95 void phydm_adaptivity_info_init(void *dm_void, enum phydm_adapinfo cmn_info,
96 				u32 value);
97 
98 void phydm_adaptivity_init(void *dm_void);
99 
100 void phydm_adaptivity(void *dm_void);
101 
102 void phydm_set_edcca_threshold_api(void *dm_void, u8 IGI);
103 
104 void phydm_pause_edcca_work_item_callback(void *dm_void);
105 
106 void phydm_resume_edcca_work_item_callback(void *dm_void);
107 
108 #endif
109