aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00.h
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-12-20 04:54:54 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 15:58:35 -0500
commit5352ff6510422d9a9bf13b7272f865eb53247f4d (patch)
treeec85fd9933b3d79cf4ae844c36f0803168203f06 /drivers/net/wireless/rt2x00/rt2x00.h
parenteb20b4e8a6998ca68d9ac0963ee36a1a36fe241d (diff)
rt2x00: Restrict interface between rt2x00link and drivers
Restrict drivers to only access link_qual structure during link tuning. The contents of these fields are for the drivers and all fields are allowed to be changed to values the driver considers correct. This means that some fields need to be moved outside of this structure to restrict access only to rt2x00link itself. This allows some code to be moved outside of the rt2x00.h header and into rt2x00link.c. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00.h')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h99
1 files changed, 35 insertions, 64 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 8935f2c005c..dea502234cf 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -177,52 +177,41 @@ struct antenna_setup {
177 */ 177 */
178struct link_qual { 178struct link_qual {
179 /* 179 /*
180 * Statistics required for Link tuning. 180 * Statistics required for Link tuning by driver
181 * For the average RSSI value we use the "Walking average" approach. 181 * The rssi value is provided by rt2x00lib during the
182 * When adding RSSI to the average value the following calculation 182 * link_tuner() callback function.
183 * is needed: 183 * The false_cca field is filled during the link_stats()
184 * 184 * callback function and could be used during the
185 * avg_rssi = ((avg_rssi * 7) + rssi) / 8; 185 * link_tuner() callback function.
186 */
187 int rssi;
188 int false_cca;
189
190 /*
191 * VGC levels
192 * Hardware driver will tune the VGC level during each call
193 * to the link_tuner() callback function. This vgc_level is
194 * is determined based on the link quality statistics like
195 * average RSSI and the false CCA count.
186 * 196 *
187 * The advantage of this approach is that we only need 1 variable 197 * In some cases the drivers need to differentiate between
188 * to store the average in (No need for a count and a total). 198 * the currently "desired" VGC level and the level configured
189 * But more importantly, normal average values will over time 199 * in the hardware. The latter is important to reduce the
190 * move less and less towards newly added values this results 200 * number of BBP register reads to reduce register access
191 * that with link tuning, the device can have a very good RSSI 201 * overhead. For this reason we store both values here.
192 * for a few minutes but when the device is moved away from the AP
193 * the average will not decrease fast enough to compensate.
194 * The walking average compensates this and will move towards
195 * the new values correctly allowing a effective link tuning.
196 */ 202 */
197 int avg_rssi; 203 u8 vgc_level;
198 int false_cca; 204 u8 vgc_level_reg;
199 205
200 /* 206 /*
201 * Statistics required for Signal quality calculation. 207 * Statistics required for Signal quality calculation.
202 * For calculating the Signal quality we have to determine 208 * These fields might be changed during the link_stats()
203 * the total number of success and failed RX and TX frames. 209 * callback function.
204 * After that we also use the average RSSI value to help
205 * determining the signal quality.
206 * For the calculation we will use the following algorithm:
207 *
208 * rssi_percentage = (avg_rssi * 100) / rssi_offset
209 * rx_percentage = (rx_success * 100) / rx_total
210 * tx_percentage = (tx_success * 100) / tx_total
211 * avg_signal = ((WEIGHT_RSSI * avg_rssi) +
212 * (WEIGHT_TX * tx_percentage) +
213 * (WEIGHT_RX * rx_percentage)) / 100
214 *
215 * This value should then be checked to not be greater then 100.
216 */ 210 */
217 int rx_percentage;
218 int rx_success; 211 int rx_success;
219 int rx_failed; 212 int rx_failed;
220 int tx_percentage;
221 int tx_success; 213 int tx_success;
222 int tx_failed; 214 int tx_failed;
223#define WEIGHT_RSSI 20
224#define WEIGHT_RX 40
225#define WEIGHT_TX 40
226}; 215};
227 216
228/* 217/*
@@ -286,14 +275,16 @@ struct link {
286 struct link_ant ant; 275 struct link_ant ant;
287 276
288 /* 277 /*
289 * Active VGC level (for false cca tuning) 278 * Currently active average RSSI value
290 */ 279 */
291 u8 vgc_level; 280 int avg_rssi;
292 281
293 /* 282 /*
294 * VGC level as configured in register 283 * Currently precalculated percentages of successful
284 * TX and RX frames.
295 */ 285 */
296 u8 vgc_level_reg; 286 int rx_percentage;
287 int tx_percentage;
297 288
298 /* 289 /*
299 * Work structure for scheduling periodic link tuning. 290 * Work structure for scheduling periodic link tuning.
@@ -302,28 +293,6 @@ struct link {
302}; 293};
303 294
304/* 295/*
305 * Small helper macro to work with moving/walking averages.
306 */
307#define MOVING_AVERAGE(__avg, __val, __samples) \
308 ( (((__avg) * ((__samples) - 1)) + (__val)) / (__samples) )
309
310/*
311 * When we lack RSSI information return something less then -80 to
312 * tell the driver to tune the device to maximum sensitivity.
313 */
314#define DEFAULT_RSSI ( -128 )
315
316/*
317 * Link quality access functions.
318 */
319static inline int rt2x00_get_link_rssi(struct link *link)
320{
321 if (link->qual.avg_rssi && link->qual.rx_success)
322 return link->qual.avg_rssi;
323 return DEFAULT_RSSI;
324}
325
326/*
327 * Interface structure 296 * Interface structure
328 * Per interface configuration details, this structure 297 * Per interface configuration details, this structure
329 * is allocated as the private data for ieee80211_vif. 298 * is allocated as the private data for ieee80211_vif.
@@ -522,8 +491,10 @@ struct rt2x00lib_ops {
522 int (*rfkill_poll) (struct rt2x00_dev *rt2x00dev); 491 int (*rfkill_poll) (struct rt2x00_dev *rt2x00dev);
523 void (*link_stats) (struct rt2x00_dev *rt2x00dev, 492 void (*link_stats) (struct rt2x00_dev *rt2x00dev,
524 struct link_qual *qual); 493 struct link_qual *qual);
525 void (*reset_tuner) (struct rt2x00_dev *rt2x00dev); 494 void (*reset_tuner) (struct rt2x00_dev *rt2x00dev,
526 void (*link_tuner) (struct rt2x00_dev *rt2x00dev); 495 struct link_qual *qual);
496 void (*link_tuner) (struct rt2x00_dev *rt2x00dev,
497 struct link_qual *qual, const u32 count);
527 498
528 /* 499 /*
529 * TX control handlers 500 * TX control handlers