aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00.h')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h145
1 files changed, 47 insertions, 98 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 39ecf3b82ca1..d0a825638188 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -1,5 +1,5 @@
1/* 1/*
2 Copyright (C) 2004 - 2008 rt2x00 SourceForge Project 2 Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com> 3 <http://rt2x00.serialmonkey.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
@@ -33,6 +33,7 @@
33#include <linux/leds.h> 33#include <linux/leds.h>
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/etherdevice.h> 35#include <linux/etherdevice.h>
36#include <linux/input-polldev.h>
36 37
37#include <net/mac80211.h> 38#include <net/mac80211.h>
38 39
@@ -44,7 +45,7 @@
44/* 45/*
45 * Module information. 46 * Module information.
46 */ 47 */
47#define DRV_VERSION "2.2.3" 48#define DRV_VERSION "2.3.0"
48#define DRV_PROJECT "http://rt2x00.serialmonkey.com" 49#define DRV_PROJECT "http://rt2x00.serialmonkey.com"
49 50
50/* 51/*
@@ -177,52 +178,41 @@ struct antenna_setup {
177 */ 178 */
178struct link_qual { 179struct link_qual {
179 /* 180 /*
180 * Statistics required for Link tuning. 181 * Statistics required for Link tuning by driver
181 * For the average RSSI value we use the "Walking average" approach. 182 * The rssi value is provided by rt2x00lib during the
182 * When adding RSSI to the average value the following calculation 183 * link_tuner() callback function.
183 * is needed: 184 * The false_cca field is filled during the link_stats()
184 * 185 * callback function and could be used during the
185 * avg_rssi = ((avg_rssi * 7) + rssi) / 8; 186 * link_tuner() callback function.
186 *
187 * The advantage of this approach is that we only need 1 variable
188 * to store the average in (No need for a count and a total).
189 * But more importantly, normal average values will over time
190 * move less and less towards newly added values this results
191 * that with link tuning, the device can have a very good RSSI
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 */ 187 */
197 int avg_rssi; 188 int rssi;
198 int false_cca; 189 int false_cca;
199 190
200 /* 191 /*
201 * Statistics required for Signal quality calculation. 192 * VGC levels
202 * For calculating the Signal quality we have to determine 193 * Hardware driver will tune the VGC level during each call
203 * the total number of success and failed RX and TX frames. 194 * to the link_tuner() callback function. This vgc_level is
204 * After that we also use the average RSSI value to help 195 * is determined based on the link quality statistics like
205 * determining the signal quality. 196 * average RSSI and the false CCA count.
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 * 197 *
215 * This value should then be checked to not be greated then 100. 198 * In some cases the drivers need to differentiate between
199 * the currently "desired" VGC level and the level configured
200 * in the hardware. The latter is important to reduce the
201 * number of BBP register reads to reduce register access
202 * overhead. For this reason we store both values here.
203 */
204 u8 vgc_level;
205 u8 vgc_level_reg;
206
207 /*
208 * Statistics required for Signal quality calculation.
209 * These fields might be changed during the link_stats()
210 * callback function.
216 */ 211 */
217 int rx_percentage;
218 int rx_success; 212 int rx_success;
219 int rx_failed; 213 int rx_failed;
220 int tx_percentage;
221 int tx_success; 214 int tx_success;
222 int tx_failed; 215 int tx_failed;
223#define WEIGHT_RSSI 20
224#define WEIGHT_RX 40
225#define WEIGHT_TX 40
226}; 216};
227 217
228/* 218/*
@@ -286,9 +276,16 @@ struct link {
286 struct link_ant ant; 276 struct link_ant ant;
287 277
288 /* 278 /*
289 * Active VGC level 279 * Currently active average RSSI value
280 */
281 int avg_rssi;
282
283 /*
284 * Currently precalculated percentages of successful
285 * TX and RX frames.
290 */ 286 */
291 int vgc_level; 287 int rx_percentage;
288 int tx_percentage;
292 289
293 /* 290 /*
294 * Work structure for scheduling periodic link tuning. 291 * Work structure for scheduling periodic link tuning.
@@ -297,55 +294,6 @@ struct link {
297}; 294};
298 295
299/* 296/*
300 * Small helper macro to work with moving/walking averages.
301 */
302#define MOVING_AVERAGE(__avg, __val, __samples) \
303 ( (((__avg) * ((__samples) - 1)) + (__val)) / (__samples) )
304
305/*
306 * When we lack RSSI information return something less then -80 to
307 * tell the driver to tune the device to maximum sensitivity.
308 */
309#define DEFAULT_RSSI ( -128 )
310
311/*
312 * Link quality access functions.
313 */
314static inline int rt2x00_get_link_rssi(struct link *link)
315{
316 if (link->qual.avg_rssi && link->qual.rx_success)
317 return link->qual.avg_rssi;
318 return DEFAULT_RSSI;
319}
320
321static inline int rt2x00_get_link_ant_rssi(struct link *link)
322{
323 if (link->ant.rssi_ant && link->qual.rx_success)
324 return link->ant.rssi_ant;
325 return DEFAULT_RSSI;
326}
327
328static inline void rt2x00_reset_link_ant_rssi(struct link *link)
329{
330 link->ant.rssi_ant = 0;
331}
332
333static inline int rt2x00_get_link_ant_rssi_history(struct link *link,
334 enum antenna ant)
335{
336 if (link->ant.rssi_history[ant - ANTENNA_A])
337 return link->ant.rssi_history[ant - ANTENNA_A];
338 return DEFAULT_RSSI;
339}
340
341static inline int rt2x00_update_ant_rssi(struct link *link, int rssi)
342{
343 int old_rssi = link->ant.rssi_history[link->ant.active.rx - ANTENNA_A];
344 link->ant.rssi_history[link->ant.active.rx - ANTENNA_A] = rssi;
345 return old_rssi;
346}
347
348/*
349 * Interface structure 297 * Interface structure
350 * Per interface configuration details, this structure 298 * Per interface configuration details, this structure
351 * is allocated as the private data for ieee80211_vif. 299 * is allocated as the private data for ieee80211_vif.
@@ -448,7 +396,7 @@ struct rt2x00lib_erp {
448 int ack_timeout; 396 int ack_timeout;
449 int ack_consume_time; 397 int ack_consume_time;
450 398
451 u64 basic_rates; 399 u32 basic_rates;
452 400
453 int slot_time; 401 int slot_time;
454 402
@@ -544,8 +492,10 @@ struct rt2x00lib_ops {
544 int (*rfkill_poll) (struct rt2x00_dev *rt2x00dev); 492 int (*rfkill_poll) (struct rt2x00_dev *rt2x00dev);
545 void (*link_stats) (struct rt2x00_dev *rt2x00dev, 493 void (*link_stats) (struct rt2x00_dev *rt2x00dev,
546 struct link_qual *qual); 494 struct link_qual *qual);
547 void (*reset_tuner) (struct rt2x00_dev *rt2x00dev); 495 void (*reset_tuner) (struct rt2x00_dev *rt2x00dev,
548 void (*link_tuner) (struct rt2x00_dev *rt2x00dev); 496 struct link_qual *qual);
497 void (*link_tuner) (struct rt2x00_dev *rt2x00dev,
498 struct link_qual *qual, const u32 count);
549 499
550 /* 500 /*
551 * TX control handlers 501 * TX control handlers
@@ -625,7 +575,6 @@ enum rt2x00_flags {
625 DEVICE_STATE_REGISTERED_HW, 575 DEVICE_STATE_REGISTERED_HW,
626 DEVICE_STATE_INITIALIZED, 576 DEVICE_STATE_INITIALIZED,
627 DEVICE_STATE_STARTED, 577 DEVICE_STATE_STARTED,
628 DEVICE_STATE_STARTED_SUSPEND,
629 DEVICE_STATE_ENABLED_RADIO, 578 DEVICE_STATE_ENABLED_RADIO,
630 DEVICE_STATE_DISABLED_RADIO_HW, 579 DEVICE_STATE_DISABLED_RADIO_HW,
631 580
@@ -637,6 +586,7 @@ enum rt2x00_flags {
637 DRIVER_REQUIRE_ATIM_QUEUE, 586 DRIVER_REQUIRE_ATIM_QUEUE,
638 DRIVER_REQUIRE_SCHEDULED, 587 DRIVER_REQUIRE_SCHEDULED,
639 DRIVER_REQUIRE_DMA, 588 DRIVER_REQUIRE_DMA,
589 DRIVER_REQUIRE_COPY_IV,
640 590
641 /* 591 /*
642 * Driver features 592 * Driver features
@@ -653,7 +603,6 @@ enum rt2x00_flags {
653 CONFIG_EXTERNAL_LNA_BG, 603 CONFIG_EXTERNAL_LNA_BG,
654 CONFIG_DOUBLE_ANTENNA, 604 CONFIG_DOUBLE_ANTENNA,
655 CONFIG_DISABLE_LINK_TUNING, 605 CONFIG_DISABLE_LINK_TUNING,
656 CONFIG_CRYPTO_COPY_IV,
657}; 606};
658 607
659/* 608/*
@@ -689,8 +638,8 @@ struct rt2x00_dev {
689 unsigned long rfkill_state; 638 unsigned long rfkill_state;
690#define RFKILL_STATE_ALLOCATED 1 639#define RFKILL_STATE_ALLOCATED 1
691#define RFKILL_STATE_REGISTERED 2 640#define RFKILL_STATE_REGISTERED 2
692 struct rfkill *rfkill; 641#define RFKILL_STATE_BLOCKED 3
693 struct delayed_work rfkill_work; 642 struct input_polled_dev *rfkill_poll_dev;
694#endif /* CONFIG_RT2X00_LIB_RFKILL */ 643#endif /* CONFIG_RT2X00_LIB_RFKILL */
695 644
696 /* 645 /*
@@ -918,7 +867,7 @@ static inline char rt2x00_rf(const struct rt2x00_chip *chipset, const u16 chip)
918 return (chipset->rf == chip); 867 return (chipset->rf == chip);
919} 868}
920 869
921static inline u16 rt2x00_rev(const struct rt2x00_chip *chipset) 870static inline u32 rt2x00_rev(const struct rt2x00_chip *chipset)
922{ 871{
923 return chipset->rev; 872 return chipset->rev;
924} 873}
@@ -982,7 +931,7 @@ void rt2x00mac_configure_filter(struct ieee80211_hw *hw,
982 int mc_count, struct dev_addr_list *mc_list); 931 int mc_count, struct dev_addr_list *mc_list);
983#ifdef CONFIG_RT2X00_LIB_CRYPTO 932#ifdef CONFIG_RT2X00_LIB_CRYPTO
984int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 933int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
985 const u8 *local_address, const u8 *address, 934 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
986 struct ieee80211_key_conf *key); 935 struct ieee80211_key_conf *key);
987#else 936#else
988#define rt2x00mac_set_key NULL 937#define rt2x00mac_set_key NULL