xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/ssv6xxx/smac/ssv_rc_common.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (c) 2015 South Silicon Valley Microelectronics Inc.
3  * Copyright (c) 2015 iComm Corporation
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * See the GNU General Public License for more details.
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef _SSV_RC_COM_H_
18 #define _SSV_RC_COM_H_
19 #define SSV_RC_MAX_STA 8
20 #define MCS_GROUP_RATES 8
21 #define SSV_HT_RATE_MAX 8
22 #define TDIFS 34
23 #define TSLOT 9
24 #define SSV_RC_MAX_HARDWARE_SUPPORT 2
25 #define RC_FIRMWARE_REPORT_FLAG 0x80
26 #define RC_FLAG_INVALID 0x00000001
27 #define RC_FLAG_LEGACY 0x00000002
28 #define RC_FLAG_HT 0x00000004
29 #define RC_FLAG_HT_SGI 0x00000008
30 #define RC_FLAG_HT_GF 0x00000010
31 #define RC_FLAG_SHORT_PREAMBLE 0x00000020
32 enum ssv6xxx_rc_phy_type {
33     WLAN_RC_PHY_CCK,
34     WLAN_RC_PHY_OFDM,
35     WLAN_RC_PHY_HT_20_SS_LGI,
36     WLAN_RC_PHY_HT_20_SS_SGI,
37     WLAN_RC_PHY_HT_20_SS_GF,
38 };
39 #define RATE_TABLE_SIZE 39
40 #define RC_STA_VALID 0x00000001
41 #define RC_STA_CAP_HT 0x00000002
42 #define RC_STA_CAP_GF 0x00000004
43 #define RC_STA_CAP_SGI_20 0x00000008
44 #define RC_STA_CAP_SHORT_PREAMBLE 0x00000010
45 #define SSV62XX_G_RATE_INDEX 7
46 #define SSV62XX_RATE_MCS_INDEX 15
47 #define SSV62XX_RATE_MCS_LGI_INDEX 15
48 #define SSV62XX_RATE_MCS_SGI_INDEX 23
49 #define SSV62XX_RATE_MCS_GREENFIELD_INDEX 31
50 enum ssv_rc_rate_type {
51     RC_TYPE_B_ONLY=0,
52     RC_TYPE_LEGACY_GB,
53     RC_TYPE_SGI_20,
54     RC_TYPE_LGI_20,
55     RC_TYPE_HT_SGI_20,
56     RC_TYPE_HT_LGI_20,
57     RC_TYPE_HT_GF,
58     RC_TYPE_MAX,
59 };
60 struct ssv_rate_info {
61     int crate_kbps;
62     int crate_hw_idx;
63     int drate_kbps;
64     int drate_hw_idx;
65     u32 d_flags;
66     u32 c_flags;
67 };
68 struct ssv_rc_rate {
69     u32 rc_flags;
70     u16 phy_type;
71     u32 rate_kbps;
72     u8 dot11_rate_idx;
73     u8 ctrl_rate_idx;
74     u8 hw_rate_idx;
75     u8 arith_shift;
76     u8 target_pf;
77 };
78 struct rc_pid_sta_info {
79     unsigned long last_sample;
80     unsigned long last_report;
81     u16 tx_num_failed;
82     u16 tx_num_xmit;
83     u8 probe_report_flag;
84     u8 probe_wating_times;
85     u8 real_hw_index;
86     int txrate_idx;
87     u8 last_pf;
88     s32 err_avg_sc;
89     int last_dlr;
90     u8 feedback_probes;
91     u8 monitoring;
92     u8 oldrate;
93     u8 tmp_rate_idx;
94     u8 probe_cnt;
95 };
96 struct rc_pid_rateinfo {
97     u16 rc_index;
98     u16 index;
99  s32 diff;
100  u16 perfect_tx_time;
101  u32 throughput;
102  unsigned long this_attempt;
103  unsigned long this_success;
104  unsigned long this_fail;
105  u64 attempt;
106  u64 success;
107  u64 fail;
108 };
109 struct rc_pid_info {
110  unsigned int target;
111 #if 0
112  u8 coeff_p;
113  u8 coeff_i;
114  u8 coeff_d;
115  u8 smoothing_shift;
116  u8 sharpen_factor;
117  u8 sharpen_duration;
118  u8 norm_offset;
119 #endif
120  int oldrate;
121  struct rc_pid_rateinfo rinfo[12];
122 };
123 struct mcs_group {
124     unsigned int duration[MCS_GROUP_RATES];
125 };
126 struct minstrel_rate_stats {
127     u16 rc_index;
128     unsigned int attempts, last_attempts;
129     unsigned int success, last_success;
130     u64 att_hist, succ_hist;
131     unsigned int cur_tp;
132     unsigned int cur_prob, probability;
133     unsigned int retry_count;
134     unsigned int retry_count_rtscts;
135     u8 sample_skipped;
136 };
137 struct minstrel_mcs_group_data {
138     u8 index;
139     u8 column;
140     unsigned int max_tp_rate;
141     unsigned int max_tp_rate2;
142     unsigned int max_prob_rate;
143     struct minstrel_rate_stats rates[MCS_GROUP_RATES];
144 };
145 struct ssv62xx_ht {
146     unsigned int ampdu_len;
147     unsigned int ampdu_packets;
148     unsigned int avg_ampdu_len;
149     unsigned int max_tp_rate;
150     unsigned int max_tp_rate2;
151     unsigned int max_prob_rate;
152     int first_try_count;
153     int second_try_count;
154     int other_try_count;
155     unsigned long stats_update;
156     unsigned int overhead;
157     unsigned int overhead_rtscts;
158     unsigned int total_packets;
159     unsigned int sample_packets;
160     u8 sample_wait;
161     u8 sample_tries;
162     u8 sample_count;
163     u8 sample_slow;
164     struct minstrel_mcs_group_data groups;
165 };
166 struct ssv_sta_rc_info {
167     u8 rc_valid;
168     u8 rc_type;
169     u8 rc_num_rate;
170     s8 rc_wsid;
171     u8 ht_rc_type;
172     u8 is_ht;
173     u32 rc_supp_rates;
174     u32 ht_supp_rates;
175     struct rc_pid_info pinfo;
176     struct rc_pid_sta_info spinfo;
177     struct ssv62xx_ht ht;
178 };
179 struct ssv_rate_ctrl {
180     struct ssv_rc_rate *rc_table;
181     struct ssv_sta_rc_info sta_rc_info[SSV_RC_MAX_STA];
182 };
183 #define HT_RC_UPDATE_INTERVAL 1000
184 #endif
185