diff options
author | Christian Lamparter <chunkeey@googlemail.com> | 2011-08-19 19:53:59 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-08-24 14:57:13 -0400 |
commit | 0d78156eef1d8869ea4e56f8a257252a8f262f04 (patch) | |
tree | bfd4db22b84225b3f5ae777c6503eb30af37ff07 /drivers/net/wireless | |
parent | 6423d30f030b560ef1b701bb1f205c3817efe380 (diff) |
p54: improve site survey
The firmware keeps track of channel usage. This data can
be used by the automatic channel selection to find the best
channel.
Survey data from wlan4
frequency: 5200 MHz [in use]
noise: -91 dBm
channel active time: 811909 ms
channel busy time: 63395 ms
channel transmit time: 59636 ms
Survey data from wlan4
frequency: 5210 MHz
noise: -91 dBm
channel active time: 121 ms
channel busy time: 119 ms
channel transmit time: 0 ms
Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/p54/eeprom.c | 26 | ||||
-rw-r--r-- | drivers/net/wireless/p54/fwio.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/p54/main.c | 113 | ||||
-rw-r--r-- | drivers/net/wireless/p54/p54.h | 18 | ||||
-rw-r--r-- | drivers/net/wireless/p54/txrx.c | 66 |
5 files changed, 211 insertions, 14 deletions
diff --git a/drivers/net/wireless/p54/eeprom.c b/drivers/net/wireless/p54/eeprom.c index 54cc0bba66b9..8b6f363b3f7d 100644 --- a/drivers/net/wireless/p54/eeprom.c +++ b/drivers/net/wireless/p54/eeprom.c | |||
@@ -145,6 +145,7 @@ static int p54_fill_band_bitrates(struct ieee80211_hw *dev, | |||
145 | 145 | ||
146 | static int p54_generate_band(struct ieee80211_hw *dev, | 146 | static int p54_generate_band(struct ieee80211_hw *dev, |
147 | struct p54_channel_list *list, | 147 | struct p54_channel_list *list, |
148 | unsigned int *chan_num, | ||
148 | enum ieee80211_band band) | 149 | enum ieee80211_band band) |
149 | { | 150 | { |
150 | struct p54_common *priv = dev->priv; | 151 | struct p54_common *priv = dev->priv; |
@@ -190,7 +191,14 @@ static int p54_generate_band(struct ieee80211_hw *dev, | |||
190 | 191 | ||
191 | tmp->channels[j].band = chan->band; | 192 | tmp->channels[j].band = chan->band; |
192 | tmp->channels[j].center_freq = chan->freq; | 193 | tmp->channels[j].center_freq = chan->freq; |
194 | priv->survey[*chan_num].channel = &tmp->channels[j]; | ||
195 | priv->survey[*chan_num].filled = SURVEY_INFO_NOISE_DBM | | ||
196 | SURVEY_INFO_CHANNEL_TIME | | ||
197 | SURVEY_INFO_CHANNEL_TIME_BUSY | | ||
198 | SURVEY_INFO_CHANNEL_TIME_TX; | ||
199 | tmp->channels[j].hw_value = (*chan_num); | ||
193 | j++; | 200 | j++; |
201 | (*chan_num)++; | ||
194 | } | 202 | } |
195 | 203 | ||
196 | if (j == 0) { | 204 | if (j == 0) { |
@@ -263,7 +271,7 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev) | |||
263 | { | 271 | { |
264 | struct p54_common *priv = dev->priv; | 272 | struct p54_common *priv = dev->priv; |
265 | struct p54_channel_list *list; | 273 | struct p54_channel_list *list; |
266 | unsigned int i, j, max_channel_num; | 274 | unsigned int i, j, k, max_channel_num; |
267 | int ret = 0; | 275 | int ret = 0; |
268 | u16 freq; | 276 | u16 freq; |
269 | 277 | ||
@@ -283,6 +291,13 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev) | |||
283 | ret = -ENOMEM; | 291 | ret = -ENOMEM; |
284 | goto free; | 292 | goto free; |
285 | } | 293 | } |
294 | priv->chan_num = max_channel_num; | ||
295 | priv->survey = kzalloc(sizeof(struct survey_info) * max_channel_num, | ||
296 | GFP_KERNEL); | ||
297 | if (!priv->survey) { | ||
298 | ret = -ENOMEM; | ||
299 | goto free; | ||
300 | } | ||
286 | 301 | ||
287 | list->max_entries = max_channel_num; | 302 | list->max_entries = max_channel_num; |
288 | list->channels = kzalloc(sizeof(struct p54_channel_entry) * | 303 | list->channels = kzalloc(sizeof(struct p54_channel_entry) * |
@@ -321,8 +336,9 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev) | |||
321 | sort(list->channels, list->entries, sizeof(struct p54_channel_entry), | 336 | sort(list->channels, list->entries, sizeof(struct p54_channel_entry), |
322 | p54_compare_channels, NULL); | 337 | p54_compare_channels, NULL); |
323 | 338 | ||
339 | k = 0; | ||
324 | for (i = 0, j = 0; i < IEEE80211_NUM_BANDS; i++) { | 340 | for (i = 0, j = 0; i < IEEE80211_NUM_BANDS; i++) { |
325 | if (p54_generate_band(dev, list, i) == 0) | 341 | if (p54_generate_band(dev, list, &k, i) == 0) |
326 | j++; | 342 | j++; |
327 | } | 343 | } |
328 | if (j == 0) { | 344 | if (j == 0) { |
@@ -335,6 +351,10 @@ free: | |||
335 | kfree(list->channels); | 351 | kfree(list->channels); |
336 | kfree(list); | 352 | kfree(list); |
337 | } | 353 | } |
354 | if (ret) { | ||
355 | kfree(priv->survey); | ||
356 | priv->survey = NULL; | ||
357 | } | ||
338 | 358 | ||
339 | return ret; | 359 | return ret; |
340 | } | 360 | } |
@@ -853,10 +873,12 @@ err: | |||
853 | kfree(priv->output_limit); | 873 | kfree(priv->output_limit); |
854 | kfree(priv->curve_data); | 874 | kfree(priv->curve_data); |
855 | kfree(priv->rssi_db); | 875 | kfree(priv->rssi_db); |
876 | kfree(priv->survey); | ||
856 | priv->iq_autocal = NULL; | 877 | priv->iq_autocal = NULL; |
857 | priv->output_limit = NULL; | 878 | priv->output_limit = NULL; |
858 | priv->curve_data = NULL; | 879 | priv->curve_data = NULL; |
859 | priv->rssi_db = NULL; | 880 | priv->rssi_db = NULL; |
881 | priv->survey = NULL; | ||
860 | 882 | ||
861 | wiphy_err(dev->wiphy, "eeprom parse failed!\n"); | 883 | wiphy_err(dev->wiphy, "eeprom parse failed!\n"); |
862 | return err; | 884 | return err; |
diff --git a/drivers/net/wireless/p54/fwio.c b/drivers/net/wireless/p54/fwio.c index b6a061cbbdec..53a3408931be 100644 --- a/drivers/net/wireless/p54/fwio.c +++ b/drivers/net/wireless/p54/fwio.c | |||
@@ -385,6 +385,7 @@ int p54_setup_mac(struct p54_common *priv) | |||
385 | setup->v2.osc_start_delay = cpu_to_le16(65535); | 385 | setup->v2.osc_start_delay = cpu_to_le16(65535); |
386 | } | 386 | } |
387 | p54_tx(priv, skb); | 387 | p54_tx(priv, skb); |
388 | priv->phy_idle = mode == P54_FILTER_TYPE_HIBERNATE; | ||
388 | return 0; | 389 | return 0; |
389 | } | 390 | } |
390 | 391 | ||
@@ -626,6 +627,7 @@ int p54_set_ps(struct p54_common *priv) | |||
626 | psm->exclude[0] = WLAN_EID_TIM; | 627 | psm->exclude[0] = WLAN_EID_TIM; |
627 | 628 | ||
628 | p54_tx(priv, skb); | 629 | p54_tx(priv, skb); |
630 | priv->phy_ps = mode != P54_PSM_CAM; | ||
629 | return 0; | 631 | return 0; |
630 | } | 632 | } |
631 | 633 | ||
diff --git a/drivers/net/wireless/p54/main.c b/drivers/net/wireless/p54/main.c index a5a6d9e647bb..726a9343f514 100644 --- a/drivers/net/wireless/p54/main.c +++ b/drivers/net/wireless/p54/main.c | |||
@@ -204,13 +204,11 @@ static void p54_stop(struct ieee80211_hw *dev) | |||
204 | struct p54_common *priv = dev->priv; | 204 | struct p54_common *priv = dev->priv; |
205 | int i; | 205 | int i; |
206 | 206 | ||
207 | mutex_lock(&priv->conf_mutex); | ||
208 | priv->mode = NL80211_IFTYPE_UNSPECIFIED; | 207 | priv->mode = NL80211_IFTYPE_UNSPECIFIED; |
209 | priv->softled_state = 0; | 208 | priv->softled_state = 0; |
210 | p54_set_leds(priv); | ||
211 | |||
212 | cancel_delayed_work_sync(&priv->work); | 209 | cancel_delayed_work_sync(&priv->work); |
213 | 210 | mutex_lock(&priv->conf_mutex); | |
211 | p54_set_leds(priv); | ||
214 | priv->stop(dev); | 212 | priv->stop(dev); |
215 | skb_queue_purge(&priv->tx_pending); | 213 | skb_queue_purge(&priv->tx_pending); |
216 | skb_queue_purge(&priv->tx_queue); | 214 | skb_queue_purge(&priv->tx_queue); |
@@ -278,6 +276,42 @@ static void p54_remove_interface(struct ieee80211_hw *dev, | |||
278 | mutex_unlock(&priv->conf_mutex); | 276 | mutex_unlock(&priv->conf_mutex); |
279 | } | 277 | } |
280 | 278 | ||
279 | static int p54_wait_for_stats(struct ieee80211_hw *dev) | ||
280 | { | ||
281 | struct p54_common *priv = dev->priv; | ||
282 | int ret; | ||
283 | |||
284 | priv->update_stats = true; | ||
285 | ret = p54_fetch_statistics(priv); | ||
286 | if (ret) | ||
287 | return ret; | ||
288 | |||
289 | ret = wait_for_completion_interruptible_timeout(&priv->stat_comp, HZ); | ||
290 | if (ret == 0) | ||
291 | return -ETIMEDOUT; | ||
292 | |||
293 | return 0; | ||
294 | } | ||
295 | |||
296 | static void p54_reset_stats(struct p54_common *priv) | ||
297 | { | ||
298 | struct ieee80211_channel *chan = priv->curchan; | ||
299 | |||
300 | if (chan) { | ||
301 | struct survey_info *info = &priv->survey[chan->hw_value]; | ||
302 | |||
303 | /* only reset channel statistics, don't touch .filled, etc. */ | ||
304 | info->channel_time = 0; | ||
305 | info->channel_time_busy = 0; | ||
306 | info->channel_time_tx = 0; | ||
307 | } | ||
308 | |||
309 | priv->update_stats = true; | ||
310 | priv->survey_raw.active = 0; | ||
311 | priv->survey_raw.cca = 0; | ||
312 | priv->survey_raw.tx = 0; | ||
313 | } | ||
314 | |||
281 | static int p54_config(struct ieee80211_hw *dev, u32 changed) | 315 | static int p54_config(struct ieee80211_hw *dev, u32 changed) |
282 | { | 316 | { |
283 | int ret = 0; | 317 | int ret = 0; |
@@ -288,19 +322,36 @@ static int p54_config(struct ieee80211_hw *dev, u32 changed) | |||
288 | if (changed & IEEE80211_CONF_CHANGE_POWER) | 322 | if (changed & IEEE80211_CONF_CHANGE_POWER) |
289 | priv->output_power = conf->power_level << 2; | 323 | priv->output_power = conf->power_level << 2; |
290 | if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { | 324 | if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { |
325 | struct ieee80211_channel *oldchan; | ||
326 | WARN_ON(p54_wait_for_stats(dev)); | ||
327 | oldchan = priv->curchan; | ||
328 | priv->curchan = NULL; | ||
291 | ret = p54_scan(priv, P54_SCAN_EXIT, 0); | 329 | ret = p54_scan(priv, P54_SCAN_EXIT, 0); |
292 | if (ret) | 330 | if (ret) { |
331 | priv->curchan = oldchan; | ||
293 | goto out; | 332 | goto out; |
333 | } | ||
334 | /* | ||
335 | * TODO: Use the LM_SCAN_TRAP to determine the current | ||
336 | * operating channel. | ||
337 | */ | ||
338 | priv->curchan = priv->hw->conf.channel; | ||
339 | p54_reset_stats(priv); | ||
340 | WARN_ON(p54_fetch_statistics(priv)); | ||
294 | } | 341 | } |
295 | if (changed & IEEE80211_CONF_CHANGE_PS) { | 342 | if (changed & IEEE80211_CONF_CHANGE_PS) { |
343 | WARN_ON(p54_wait_for_stats(dev)); | ||
296 | ret = p54_set_ps(priv); | 344 | ret = p54_set_ps(priv); |
297 | if (ret) | 345 | if (ret) |
298 | goto out; | 346 | goto out; |
347 | WARN_ON(p54_wait_for_stats(dev)); | ||
299 | } | 348 | } |
300 | if (changed & IEEE80211_CONF_CHANGE_IDLE) { | 349 | if (changed & IEEE80211_CONF_CHANGE_IDLE) { |
350 | WARN_ON(p54_wait_for_stats(dev)); | ||
301 | ret = p54_setup_mac(priv); | 351 | ret = p54_setup_mac(priv); |
302 | if (ret) | 352 | if (ret) |
303 | goto out; | 353 | goto out; |
354 | WARN_ON(p54_wait_for_stats(dev)); | ||
304 | } | 355 | } |
305 | 356 | ||
306 | out: | 357 | out: |
@@ -384,7 +435,9 @@ static void p54_work(struct work_struct *work) | |||
384 | * 2. cancel stuck frames / reset the device if necessary. | 435 | * 2. cancel stuck frames / reset the device if necessary. |
385 | */ | 436 | */ |
386 | 437 | ||
387 | p54_fetch_statistics(priv); | 438 | mutex_lock(&priv->conf_mutex); |
439 | WARN_ON_ONCE(p54_fetch_statistics(priv)); | ||
440 | mutex_unlock(&priv->conf_mutex); | ||
388 | } | 441 | } |
389 | 442 | ||
390 | static int p54_get_stats(struct ieee80211_hw *dev, | 443 | static int p54_get_stats(struct ieee80211_hw *dev, |
@@ -541,16 +594,47 @@ static int p54_get_survey(struct ieee80211_hw *dev, int idx, | |||
541 | struct survey_info *survey) | 594 | struct survey_info *survey) |
542 | { | 595 | { |
543 | struct p54_common *priv = dev->priv; | 596 | struct p54_common *priv = dev->priv; |
544 | struct ieee80211_conf *conf = &dev->conf; | 597 | struct ieee80211_channel *chan; |
598 | int err, tries; | ||
599 | bool in_use = false; | ||
545 | 600 | ||
546 | if (idx != 0) | 601 | if (idx >= priv->chan_num) |
547 | return -ENOENT; | 602 | return -ENOENT; |
548 | 603 | ||
549 | survey->channel = conf->channel; | 604 | #define MAX_TRIES 1 |
550 | survey->filled = SURVEY_INFO_NOISE_DBM; | 605 | for (tries = 0; tries < MAX_TRIES; tries++) { |
551 | survey->noise = clamp_t(s8, priv->noise, -128, 127); | 606 | chan = priv->curchan; |
607 | if (chan && chan->hw_value == idx) { | ||
608 | mutex_lock(&priv->conf_mutex); | ||
609 | err = p54_wait_for_stats(dev); | ||
610 | mutex_unlock(&priv->conf_mutex); | ||
611 | if (err) | ||
612 | return err; | ||
613 | |||
614 | in_use = true; | ||
615 | } | ||
552 | 616 | ||
553 | return 0; | 617 | memcpy(survey, &priv->survey[idx], sizeof(*survey)); |
618 | |||
619 | if (in_use) { | ||
620 | /* test if the reported statistics are valid. */ | ||
621 | if (survey->channel_time != 0) { | ||
622 | survey->filled |= SURVEY_INFO_IN_USE; | ||
623 | } else { | ||
624 | /* | ||
625 | * hw/fw has not accumulated enough sample sets. | ||
626 | * Wait for 100ms, this ought to be enough to | ||
627 | * to get at least one non-null set of channel | ||
628 | * usage statistics. | ||
629 | */ | ||
630 | msleep(100); | ||
631 | continue; | ||
632 | } | ||
633 | } | ||
634 | return 0; | ||
635 | } | ||
636 | return -ETIMEDOUT; | ||
637 | #undef MAX_TRIES | ||
554 | } | 638 | } |
555 | 639 | ||
556 | static unsigned int p54_flush_count(struct p54_common *priv) | 640 | static unsigned int p54_flush_count(struct p54_common *priv) |
@@ -686,11 +770,14 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len) | |||
686 | 770 | ||
687 | mutex_init(&priv->conf_mutex); | 771 | mutex_init(&priv->conf_mutex); |
688 | mutex_init(&priv->eeprom_mutex); | 772 | mutex_init(&priv->eeprom_mutex); |
773 | init_completion(&priv->stat_comp); | ||
689 | init_completion(&priv->eeprom_comp); | 774 | init_completion(&priv->eeprom_comp); |
690 | init_completion(&priv->beacon_comp); | 775 | init_completion(&priv->beacon_comp); |
691 | INIT_DELAYED_WORK(&priv->work, p54_work); | 776 | INIT_DELAYED_WORK(&priv->work, p54_work); |
692 | 777 | ||
693 | memset(&priv->mc_maclist[0], ~0, ETH_ALEN); | 778 | memset(&priv->mc_maclist[0], ~0, ETH_ALEN); |
779 | priv->curchan = NULL; | ||
780 | p54_reset_stats(priv); | ||
694 | return dev; | 781 | return dev; |
695 | } | 782 | } |
696 | EXPORT_SYMBOL_GPL(p54_init_common); | 783 | EXPORT_SYMBOL_GPL(p54_init_common); |
@@ -730,11 +817,13 @@ void p54_free_common(struct ieee80211_hw *dev) | |||
730 | kfree(priv->curve_data); | 817 | kfree(priv->curve_data); |
731 | kfree(priv->rssi_db); | 818 | kfree(priv->rssi_db); |
732 | kfree(priv->used_rxkeys); | 819 | kfree(priv->used_rxkeys); |
820 | kfree(priv->survey); | ||
733 | priv->iq_autocal = NULL; | 821 | priv->iq_autocal = NULL; |
734 | priv->output_limit = NULL; | 822 | priv->output_limit = NULL; |
735 | priv->curve_data = NULL; | 823 | priv->curve_data = NULL; |
736 | priv->rssi_db = NULL; | 824 | priv->rssi_db = NULL; |
737 | priv->used_rxkeys = NULL; | 825 | priv->used_rxkeys = NULL; |
826 | priv->survey = NULL; | ||
738 | ieee80211_free_hw(dev); | 827 | ieee80211_free_hw(dev); |
739 | } | 828 | } |
740 | EXPORT_SYMBOL_GPL(p54_free_common); | 829 | EXPORT_SYMBOL_GPL(p54_free_common); |
diff --git a/drivers/net/wireless/p54/p54.h b/drivers/net/wireless/p54/p54.h index 799d05e12595..452fa3a64aa1 100644 --- a/drivers/net/wireless/p54/p54.h +++ b/drivers/net/wireless/p54/p54.h | |||
@@ -199,6 +199,22 @@ struct p54_common { | |||
199 | u8 tx_diversity_mask; | 199 | u8 tx_diversity_mask; |
200 | unsigned int output_power; | 200 | unsigned int output_power; |
201 | struct p54_rssi_db_entry *cur_rssi; | 201 | struct p54_rssi_db_entry *cur_rssi; |
202 | struct ieee80211_channel *curchan; | ||
203 | struct survey_info *survey; | ||
204 | unsigned int chan_num; | ||
205 | struct completion stat_comp; | ||
206 | bool update_stats; | ||
207 | struct { | ||
208 | unsigned int timestamp; | ||
209 | unsigned int cached_cca; | ||
210 | unsigned int cached_tx; | ||
211 | unsigned int cached_rssi; | ||
212 | u64 active; | ||
213 | u64 cca; | ||
214 | u64 tx; | ||
215 | u64 rssi; | ||
216 | } survey_raw; | ||
217 | |||
202 | int noise; | 218 | int noise; |
203 | /* calibration, output power limit and rssi<->dBm conversation data */ | 219 | /* calibration, output power limit and rssi<->dBm conversation data */ |
204 | struct pda_iq_autocal_entry *iq_autocal; | 220 | struct pda_iq_autocal_entry *iq_autocal; |
@@ -220,6 +236,8 @@ struct p54_common { | |||
220 | u32 basic_rate_mask; | 236 | u32 basic_rate_mask; |
221 | u16 aid; | 237 | u16 aid; |
222 | u8 coverage_class; | 238 | u8 coverage_class; |
239 | bool phy_idle; | ||
240 | bool phy_ps; | ||
223 | bool powersave_override; | 241 | bool powersave_override; |
224 | __le32 beacon_req_id; | 242 | __le32 beacon_req_id; |
225 | struct completion beacon_comp; | 243 | struct completion beacon_comp; |
diff --git a/drivers/net/wireless/p54/txrx.c b/drivers/net/wireless/p54/txrx.c index 042842e704de..44a3bd4b0f43 100644 --- a/drivers/net/wireless/p54/txrx.c +++ b/drivers/net/wireless/p54/txrx.c | |||
@@ -507,6 +507,8 @@ static void p54_rx_stats(struct p54_common *priv, struct sk_buff *skb) | |||
507 | struct p54_hdr *hdr = (struct p54_hdr *) skb->data; | 507 | struct p54_hdr *hdr = (struct p54_hdr *) skb->data; |
508 | struct p54_statistics *stats = (struct p54_statistics *) hdr->data; | 508 | struct p54_statistics *stats = (struct p54_statistics *) hdr->data; |
509 | struct sk_buff *tmp; | 509 | struct sk_buff *tmp; |
510 | struct ieee80211_channel *chan; | ||
511 | unsigned int i, rssi, tx, cca, dtime, dtotal, dcca, dtx, drssi, unit; | ||
510 | u32 tsf32; | 512 | u32 tsf32; |
511 | 513 | ||
512 | if (unlikely(priv->mode == NL80211_IFTYPE_UNSPECIFIED)) | 514 | if (unlikely(priv->mode == NL80211_IFTYPE_UNSPECIFIED)) |
@@ -523,8 +525,72 @@ static void p54_rx_stats(struct p54_common *priv, struct sk_buff *skb) | |||
523 | 525 | ||
524 | priv->noise = p54_rssi_to_dbm(priv, le32_to_cpu(stats->noise)); | 526 | priv->noise = p54_rssi_to_dbm(priv, le32_to_cpu(stats->noise)); |
525 | 527 | ||
528 | /* | ||
529 | * STSW450X LMAC API page 26 - 3.8 Statistics | ||
530 | * "The exact measurement period can be derived from the | ||
531 | * timestamp member". | ||
532 | */ | ||
533 | dtime = tsf32 - priv->survey_raw.timestamp; | ||
534 | |||
535 | /* | ||
536 | * STSW450X LMAC API page 26 - 3.8.1 Noise histogram | ||
537 | * The LMAC samples RSSI, CCA and transmit state at regular | ||
538 | * periods (typically 8 times per 1k [as in 1024] usec). | ||
539 | */ | ||
540 | cca = le32_to_cpu(stats->sample_cca); | ||
541 | tx = le32_to_cpu(stats->sample_tx); | ||
542 | rssi = 0; | ||
543 | for (i = 0; i < ARRAY_SIZE(stats->sample_noise); i++) | ||
544 | rssi += le32_to_cpu(stats->sample_noise[i]); | ||
545 | |||
546 | dcca = cca - priv->survey_raw.cached_cca; | ||
547 | drssi = rssi - priv->survey_raw.cached_rssi; | ||
548 | dtx = tx - priv->survey_raw.cached_tx; | ||
549 | dtotal = dcca + drssi + dtx; | ||
550 | |||
551 | /* | ||
552 | * update statistics when more than a second is over since the | ||
553 | * last call, or when a update is badly needed. | ||
554 | */ | ||
555 | if (dtotal && (priv->update_stats || dtime >= USEC_PER_SEC) && | ||
556 | dtime >= dtotal) { | ||
557 | priv->survey_raw.timestamp = tsf32; | ||
558 | priv->update_stats = false; | ||
559 | unit = dtime / dtotal; | ||
560 | |||
561 | if (dcca) { | ||
562 | priv->survey_raw.cca += dcca * unit; | ||
563 | priv->survey_raw.cached_cca = cca; | ||
564 | } | ||
565 | if (dtx) { | ||
566 | priv->survey_raw.tx += dtx * unit; | ||
567 | priv->survey_raw.cached_tx = tx; | ||
568 | } | ||
569 | if (drssi) { | ||
570 | priv->survey_raw.rssi += drssi * unit; | ||
571 | priv->survey_raw.cached_rssi = rssi; | ||
572 | } | ||
573 | |||
574 | /* 1024 usec / 8 times = 128 usec / time */ | ||
575 | if (!(priv->phy_ps || priv->phy_idle)) | ||
576 | priv->survey_raw.active += dtotal * unit; | ||
577 | else | ||
578 | priv->survey_raw.active += (dcca + dtx) * unit; | ||
579 | } | ||
580 | |||
581 | chan = priv->curchan; | ||
582 | if (chan) { | ||
583 | struct survey_info *survey = &priv->survey[chan->hw_value]; | ||
584 | survey->noise = clamp_t(s8, priv->noise, -128, 127); | ||
585 | survey->channel_time = priv->survey_raw.active / 1024; | ||
586 | survey->channel_time_tx = priv->survey_raw.tx / 1024; | ||
587 | survey->channel_time_busy = priv->survey_raw.cca / 1024 + | ||
588 | survey->channel_time_tx; | ||
589 | } | ||
590 | |||
526 | tmp = p54_find_and_unlink_skb(priv, hdr->req_id); | 591 | tmp = p54_find_and_unlink_skb(priv, hdr->req_id); |
527 | dev_kfree_skb_any(tmp); | 592 | dev_kfree_skb_any(tmp); |
593 | complete(&priv->stat_comp); | ||
528 | } | 594 | } |
529 | 595 | ||
530 | static void p54_rx_trap(struct p54_common *priv, struct sk_buff *skb) | 596 | static void p54_rx_trap(struct p54_common *priv, struct sk_buff *skb) |