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