hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/******************************************************************************
 *
 * Copyright(c) 2007 - 2020  Realtek Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
 * Contact Information:
 * wlanfae <wlanfae@realtek.com>
 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
 * Hsinchu 300, Taiwan.
 *
 * Larry Finger <Larry.Finger@lwfinger.net>
 *
 *****************************************************************************/
#ifndef __HALBB_EDCCA_H__
#define __HALBB_EDCCA_H__
 
/*@--------------------------[Define] ---------------------------------------*/
#define EDCCA_HL_DIFF_ADPTVTY 7
#define EDCCA_HL_DIFF_NORMAL 8
 
// EDCCA
#define CBP_6G                         53 /*@-68 dB to avoid cross-band loss*/
#define EDCCA_5G                         63 /*@-62 dBm -3 dB margin*/
#define EDCCA_2G                        68 /*@-57 dBm -3 dB margin*/
#define CARRIER_SENSE                        75 /*@-50dBm -3 dB margin*/
#define EDCCA_MAX                        249 /*@ 127dBm for normal mode*/
#define EDCCA_TH_L2H_LB                  66 /*@ -62 dBm from IEEE*/
#define EDCCA_PWDB_EXCLU_TX        128 /*128 - 256 = -128dBm when Tx*/
#define EDCCA_PWDB_TO_RSSI(pwdb)        ((pwdb + 110) < 0 ? 0 : (pwdb + 110))
#define EDCCA_PWROFST_DEFAULT 18 /*2dB is phyUD default value. Note that the loss from adc to snd is actually 0.5dB*/
#define EDCCA_TH_REF    3
 
// Collision T2R/R2T TH
#define COLLOSION_TH_LOW                  0
#define COLLOSION_TH_HIGH                 31
#define COLLOSION_TH_RSSI2VAL                 50
#define COLLOSION_TH_OFST                 0
 
// FW EDCCA
#define EDCCA_5G_TH                         70 // -62
#define EDCCA_2p4G_TH                        65// -57
#define CARRIER_SENSE_TH                        58 // -50
 
/*@--------------------------[Enum]------------------------------------------*/
/*@--------------------------[Structure]-------------------------------------*/
struct bb_h2c_fw_edcca {
   u8 mode;
   u8 band;
   u8 pwr_th_5g;
   u8 pwr_th_2p4;
   u8 pwr_th_cs;
   u8 enable;
   u8 rsvd1;
   u8 rsvd2;
};
 
struct bb_edcca_cr_info {
   u32 r_snd_en;
   u32 r_snd_en_m;
   u32 r_snd_en_s80_1;
   u32 r_snd_en_s80_1_m;
   u32 r_snd_en_s80_2;
   u32 r_snd_en_s80_2_m;
   u32 r_snd_en_s80_3;
   u32 r_snd_en_s80_3_m;
   u32 r_dwn_level;
   u32 r_dwn_level_m;
   u32 r_dwn_level_s80_1;
   u32 r_dwn_level_s80_1_m;
   u32 r_dwn_level_s80_2;
   u32 r_dwn_level_s80_2_m;
   u32 r_dwn_level_s80_3;
   u32 r_dwn_level_s80_3_m;
   u32 r_edcca_level;
   u32 r_edcca_level_m;
   u32 r_edcca_level_p;
   u32 r_edcca_level_p_m;
   u32 r_edcca_level_s80_1;
   u32 r_edcca_level_s80_1_m;
   u32 r_edcca_level_s80_1_p;
   u32 r_edcca_level_s80_1_p_m;
   u32 r_edcca_level_s80_2;
   u32 r_edcca_level_s80_2_m;
   u32 r_edcca_level_s80_2_p;
   u32 r_edcca_level_s80_2_p_m;
   u32 r_edcca_level_s80_3;
   u32 r_edcca_level_s80_3_m;
   u32 r_edcca_level_s80_3_p;
   u32 r_edcca_level_s80_3_p_m;
   u32 r_edcca_rpt_a;
   u32 r_edcca_rpt_a_m;
   u32 r_edcca_rpt_b;
   u32 r_edcca_rpt_b_m;
   u32 r_edcca_rpt_a_p1;
   u32 r_edcca_rpt_a_p1_m;
   u32 r_edcca_rpt_b_p1;
   u32 r_edcca_rpt_b_p1_m;
   u32 r_edcca_rpt_sel;
   u32 r_edcca_rpt_sel_m;
   u32 r_edcca_rpt_sel_p1;
   u32 r_edcca_rpt_sel_p1_m;
   u32 r_edcca_rptreg_sel_be_dd;
   u32 r_edcca_rptreg_sel_be_dd_m;
   u32 r_ppdu_level;
   u32 r_ppdu_level_m;
   u32 r_ppdu_level_p;
   u32 r_ppdu_level_p_m;
   u32 r_obss_level;
   u32 r_obss_level_m;
   u32 collision_r2t_th;
   u32 collision_r2t_th_m;
   u32 collision_t2r_th_mcs0;
   u32 collision_t2r_th_mcs0_m;
   u32 collision_t2r_th_mcs1;
   u32 collision_t2r_th_mcs1_m;
   u32 collision_t2r_th_mcs2;
   u32 collision_t2r_th_mcs2_m;
   u32 collision_t2r_th_mcs3;
   u32 collision_t2r_th_mcs3_m;
   u32 collision_t2r_th_mcs4;
   u32 collision_t2r_th_mcs4_m;
   u32 collision_t2r_th_mcs5;
   u32 collision_t2r_th_mcs5_m;
   u32 collision_t2r_th_mcs6;
   u32 collision_t2r_th_mcs6_m;
   u32 collision_t2r_th_mcs7;
   u32 collision_t2r_th_mcs7_m;
   u32 collision_t2r_th_mcs8;
   u32 collision_t2r_th_mcs8_m;
   u32 collision_t2r_th_mcs9;
   u32 collision_t2r_th_mcs9_m;
   u32 collision_t2r_th_mcs10;
   u32 collision_t2r_th_mcs10_m;
   u32 collision_t2r_th_mcs11;
   u32 collision_t2r_th_mcs11_m;
   u32 collision_t2r_th_mcs12;
   u32 collision_t2r_th_mcs12_m;
   u32 collision_t2r_th_mcs13;
   u32 collision_t2r_th_mcs13_m;
   u32 collision_t2r_th_cck;
   u32 collision_t2r_th_cck_m;
   u32 collision_t2r_th_cck_1M;
   u32 collision_t2r_th_cck_1M_m;
   u32 collision_t2r_th_cck_2M;
   u32 collision_t2r_th_cck_2M_m;
   u32 collision_t2r_th_cck_5p5M;
   u32 collision_t2r_th_cck_5p5M_m;
   u32 collision_t2r_th_cck_11M;
   u32 collision_t2r_th_cck_11M_m;
   u32 collision_map2dbm;
   u32 collision_map2dbm_m;
   u32 collision_t2r_th_he_dcm_mcs0;
   u32 collision_t2r_th_he_dcm_mcs0_m;
   u32 collision_t2r_th_he_dcm_mcs1;
   u32 collision_t2r_th_he_dcm_mcs1_m;
   u32 collision_t2r_th_he_dcm_mcs2;
   u32 collision_t2r_th_he_dcm_mcs2_m;
   u32 collision_t2r_th_he_dcm_mcs3;
   u32 collision_t2r_th_he_dcm_mcs3_m;
   u32 collision_t2r_th_he_dcm_mcs4;
   u32 collision_t2r_th_he_dcm_mcs4_m;
   u32 collision_t2r_th_eht_dcm_mcs14;
   u32 collision_t2r_th_eht_dcm_mcs14_m;
   u32 collision_t2r_th_eht_dcm_mcs15;
   u32 collision_t2r_th_eht_dcm_mcs15_m;
   u32 collision_t2r_th_legacy_6M;
   u32 collision_t2r_th_legacy_6M_m;
   u32 collision_t2r_th_legacy_9M;
   u32 collision_t2r_th_legacy_9M_m;
   u32 collision_t2r_th_legacy_12M;
   u32 collision_t2r_th_legacy_12M_m;
   u32 collision_t2r_th_legacy_18M;
   u32 collision_t2r_th_legacy_18M_m;
   u32 collision_t2r_th_legacy_24M;
   u32 collision_t2r_th_legacy_24M_m;
   u32 collision_t2r_th_legacy_36M;
   u32 collision_t2r_th_legacy_36M_m;
   u32 collision_t2r_th_legacy_48M;
   u32 collision_t2r_th_legacy_48M_m;
   u32 collision_t2r_th_legacy_54M;
   u32 collision_t2r_th_legacy_54M_m;
   u32 r_collision_t2r_state;
   u32 r_collision_t2r_state_m;
   u32 r_pwrofst;
   u32 r_pwrofst_m;
   u32 r_dc_remove;
   u32 r_dc_remove_m;
};
 
struct edcca_hw_rpt {
   s8 pwdb_fb; /*52A/52B is 0 when BW=40, 92XB would fix*/
   s8 pwdb_p20;
   s8 pwdb_s20;
   s8 pwdb_s40;
   s8 pwdb_s80;
   bool flag_fb;
   bool flag_p20;
   bool flag_s20;
   bool flag_s40;
   bool flag_s80;
   s8 pwdb_0;
   s8 pwdb_1;
   s8 pwdb_2;
   s8 pwdb_3;
   s8 pwdb_4;
   s8 pwdb_5;
   s8 pwdb_6;
   s8 pwdb_7;
   s8 pwdb_8;
   u8 path;
   s8 per20_bitmap_0;
   s8 per20_bitmap_1;
   s8 per20_bitmap_2;
   s8 per20_bitmap_3;
   s8 per20_bitmap_4;
   s8 per20_bitmap_5;
   s8 per20_bitmap_6;
   s8 per20_bitmap_7;
};
 
struct bb_edcca_info {
   struct bb_edcca_cr_info bb_edcca_cr_i;
   u8 th_l;
   u8 th_h;
   u8 th_hl_diff;
   u8 edcca_mode;
   u8 th_h_lb;
   u8 th_h_6g;
   u8 th_h_5g;
   u8 th_h_2p4g;
   u8 th_h_cs;
   u8 colli_th;
   u8 colli_ofst;
   struct edcca_hw_rpt edcca_rpt;
   u8 pwrofst; /*max(ext_loss, 2), 0~31=>[-16:1:15]*/
   u32 rvrt_val; /*all rvrt_val for pause API must set to u32*/
};
#ifdef HALBB_DYN_L2H_SUPPORT
struct bb_dyn_l2h_info {
   bool en_dyn_l2h;
   u32 low_rate_rty_cnt;
   u32 drop_cnt;
   u8 l2h_th;
};
#endif
 
struct bb_info;
/*@--------------------------[Prptotype]-------------------------------------*/
void halbb_edcca_get_result(struct bb_info *bb);
void halbb_edcca(struct bb_info *bb);
void halbb_edcca_thre_calc(struct bb_info * bb);
void halbb_set_collision_th(struct bb_info *bb);
void halbb_set_collision_thre(struct bb_info *bb);
void halbb_set_edcca_pause_val(struct bb_info *bb, u32 *val_buf, u8 val_len);
void halbb_edcca_event_nofity(struct bb_info * bb, u8 pause_type);
void halbb_edcca_dev_hw_cap(struct bb_info * bb);
void halbb_edcca_init(struct bb_info *bb);
void halbb_cr_cfg_edcca_init(struct bb_info *bb);
void halbb_edcca_dbg(struct bb_info *bb, char input[][16], u32 *_used,
                 char *output, u32 *_out_len);
void halbb_edcca_cmn_log(struct bb_info *bb);
#endif