aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-3945-rs.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.c102
1 files changed, 28 insertions, 74 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index cbb0585083a9..dc81e19674f7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -42,38 +42,6 @@
42 42
43#define RS_NAME "iwl-3945-rs" 43#define RS_NAME "iwl-3945-rs"
44 44
45struct iwl3945_rate_scale_data {
46 u64 data;
47 s32 success_counter;
48 s32 success_ratio;
49 s32 counter;
50 s32 average_tpt;
51 unsigned long stamp;
52};
53
54struct iwl3945_rs_sta {
55 spinlock_t lock;
56 struct iwl_priv *priv;
57 s32 *expected_tpt;
58 unsigned long last_partial_flush;
59 unsigned long last_flush;
60 u32 flush_time;
61 u32 last_tx_packets;
62 u32 tx_packets;
63 u8 tgg;
64 u8 flush_pending;
65 u8 start_rate;
66 u8 ibss_sta_added;
67 struct timer_list rate_scale_flush;
68 struct iwl3945_rate_scale_data win[IWL_RATE_COUNT_3945];
69#ifdef CONFIG_MAC80211_DEBUGFS
70 struct dentry *rs_sta_dbgfs_stats_table_file;
71#endif
72
73 /* used to be in sta_info */
74 int last_txrate_idx;
75};
76
77static s32 iwl3945_expected_tpt_g[IWL_RATE_COUNT_3945] = { 45static s32 iwl3945_expected_tpt_g[IWL_RATE_COUNT_3945] = {
78 7, 13, 35, 58, 0, 0, 76, 104, 130, 168, 191, 202 46 7, 13, 35, 58, 0, 0, 76, 104, 130, 168, 191, 202
79}; 47};
@@ -370,6 +338,28 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband,
370 338
371 IWL_DEBUG_RATE(priv, "enter\n"); 339 IWL_DEBUG_RATE(priv, "enter\n");
372 340
341 spin_lock_init(&rs_sta->lock);
342
343 rs_sta->priv = priv;
344
345 rs_sta->start_rate = IWL_RATE_INVALID;
346
347 /* default to just 802.11b */
348 rs_sta->expected_tpt = iwl3945_expected_tpt_b;
349
350 rs_sta->last_partial_flush = jiffies;
351 rs_sta->last_flush = jiffies;
352 rs_sta->flush_time = IWL_RATE_FLUSH;
353 rs_sta->last_tx_packets = 0;
354 rs_sta->ibss_sta_added = 0;
355
356 init_timer(&rs_sta->rate_scale_flush);
357 rs_sta->rate_scale_flush.data = (unsigned long)rs_sta;
358 rs_sta->rate_scale_flush.function = &iwl3945_bg_rate_scale_flush;
359
360 for (i = 0; i < IWL_RATE_COUNT_3945; i++)
361 iwl3945_clear_window(&rs_sta->win[i]);
362
373 /* TODO: what is a good starting rate for STA? About middle? Maybe not 363 /* TODO: what is a good starting rate for STA? About middle? Maybe not
374 * the lowest or the highest rate.. Could consider using RSSI from 364 * the lowest or the highest rate.. Could consider using RSSI from
375 * previous packets? Need to have IEEE 802.1X auth succeed immediately 365 * previous packets? Need to have IEEE 802.1X auth succeed immediately
@@ -409,45 +399,11 @@ static void *rs_alloc_sta(void *iwl_priv, struct ieee80211_sta *sta, gfp_t gfp)
409{ 399{
410 struct iwl3945_rs_sta *rs_sta; 400 struct iwl3945_rs_sta *rs_sta;
411 struct iwl3945_sta_priv *psta = (void *) sta->drv_priv; 401 struct iwl3945_sta_priv *psta = (void *) sta->drv_priv;
412 struct iwl_priv *priv = iwl_priv; 402 struct iwl_priv *priv __maybe_unused = iwl_priv;
413 int i;
414
415 /*
416 * XXX: If it's using sta->drv_priv anyway, it might
417 * as well just put all the information there.
418 */
419 403
420 IWL_DEBUG_RATE(priv, "enter\n"); 404 IWL_DEBUG_RATE(priv, "enter\n");
421 405
422 rs_sta = kzalloc(sizeof(struct iwl3945_rs_sta), gfp); 406 rs_sta = &psta->rs_sta;
423 if (!rs_sta) {
424 IWL_DEBUG_RATE(priv, "leave: ENOMEM\n");
425 return NULL;
426 }
427
428 psta->rs_sta = rs_sta;
429
430 spin_lock_init(&rs_sta->lock);
431
432 rs_sta->priv = priv;
433
434 rs_sta->start_rate = IWL_RATE_INVALID;
435
436 /* default to just 802.11b */
437 rs_sta->expected_tpt = iwl3945_expected_tpt_b;
438
439 rs_sta->last_partial_flush = jiffies;
440 rs_sta->last_flush = jiffies;
441 rs_sta->flush_time = IWL_RATE_FLUSH;
442 rs_sta->last_tx_packets = 0;
443 rs_sta->ibss_sta_added = 0;
444
445 init_timer(&rs_sta->rate_scale_flush);
446 rs_sta->rate_scale_flush.data = (unsigned long)rs_sta;
447 rs_sta->rate_scale_flush.function = &iwl3945_bg_rate_scale_flush;
448
449 for (i = 0; i < IWL_RATE_COUNT_3945; i++)
450 iwl3945_clear_window(&rs_sta->win[i]);
451 407
452 IWL_DEBUG_RATE(priv, "leave\n"); 408 IWL_DEBUG_RATE(priv, "leave\n");
453 409
@@ -458,14 +414,11 @@ static void rs_free_sta(void *iwl_priv, struct ieee80211_sta *sta,
458 void *priv_sta) 414 void *priv_sta)
459{ 415{
460 struct iwl3945_sta_priv *psta = (void *) sta->drv_priv; 416 struct iwl3945_sta_priv *psta = (void *) sta->drv_priv;
461 struct iwl3945_rs_sta *rs_sta = priv_sta; 417 struct iwl3945_rs_sta *rs_sta = &psta->rs_sta;
462 struct iwl_priv *priv __maybe_unused = rs_sta->priv; 418 struct iwl_priv *priv __maybe_unused = rs_sta->priv;
463 419
464 psta->rs_sta = NULL;
465
466 IWL_DEBUG_RATE(priv, "enter\n"); 420 IWL_DEBUG_RATE(priv, "enter\n");
467 del_timer_sync(&rs_sta->rate_scale_flush); 421 del_timer_sync(&rs_sta->rate_scale_flush);
468 kfree(rs_sta);
469 IWL_DEBUG_RATE(priv, "leave\n"); 422 IWL_DEBUG_RATE(priv, "leave\n");
470} 423}
471 424
@@ -960,14 +913,15 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
960 913
961 rcu_read_lock(); 914 rcu_read_lock();
962 915
963 sta = ieee80211_find_sta(hw, priv->stations[sta_id].sta.sta.addr); 916 sta = ieee80211_find_sta(priv->vif,
917 priv->stations[sta_id].sta.sta.addr);
964 if (!sta) { 918 if (!sta) {
965 rcu_read_unlock(); 919 rcu_read_unlock();
966 return; 920 return;
967 } 921 }
968 922
969 psta = (void *) sta->drv_priv; 923 psta = (void *) sta->drv_priv;
970 rs_sta = psta->rs_sta; 924 rs_sta = &psta->rs_sta;
971 925
972 spin_lock_irqsave(&rs_sta->lock, flags); 926 spin_lock_irqsave(&rs_sta->lock, flags);
973 927