aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2007-10-13 10:26:12 -0400
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:02:49 -0500
commitebcf26dae9f10e247ea41ef66f89b336ba456097 (patch)
tree27913a0d00a754d37702ec29a979c3ce5d358524 /drivers/net/wireless/rt2x00
parent191df5737e3047de8b7d8ea4e17df241cf8eefca (diff)
[PATCH] rt2x00: Move quality statistics into seperate structure
Move all link quality statistics variables into the link_qual structure. This cleans up the link structure and allows us to use it for more then just statistics. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wireless/rt2x00')
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c11
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c11
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c12
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h61
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c46
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c12
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c13
7 files changed, 92 insertions, 74 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 31c1dd271627..31bbb44611e5 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -542,7 +542,8 @@ static void rt2400pci_disable_led(struct rt2x00_dev *rt2x00dev)
542/* 542/*
543 * Link tuning 543 * Link tuning
544 */ 544 */
545static void rt2400pci_link_stats(struct rt2x00_dev *rt2x00dev) 545static void rt2400pci_link_stats(struct rt2x00_dev *rt2x00dev,
546 struct link_qual *qual)
546{ 547{
547 u32 reg; 548 u32 reg;
548 u8 bbp; 549 u8 bbp;
@@ -551,13 +552,13 @@ static void rt2400pci_link_stats(struct rt2x00_dev *rt2x00dev)
551 * Update FCS error count from register. 552 * Update FCS error count from register.
552 */ 553 */
553 rt2x00pci_register_read(rt2x00dev, CNT0, &reg); 554 rt2x00pci_register_read(rt2x00dev, CNT0, &reg);
554 rt2x00dev->link.rx_failed = rt2x00_get_field32(reg, CNT0_FCS_ERROR); 555 qual->rx_failed = rt2x00_get_field32(reg, CNT0_FCS_ERROR);
555 556
556 /* 557 /*
557 * Update False CCA count from register. 558 * Update False CCA count from register.
558 */ 559 */
559 rt2400pci_bbp_read(rt2x00dev, 39, &bbp); 560 rt2400pci_bbp_read(rt2x00dev, 39, &bbp);
560 rt2x00dev->link.false_cca = bbp; 561 qual->false_cca = bbp;
561} 562}
562 563
563static void rt2400pci_reset_tuner(struct rt2x00_dev *rt2x00dev) 564static void rt2400pci_reset_tuner(struct rt2x00_dev *rt2x00dev)
@@ -582,10 +583,10 @@ static void rt2400pci_link_tuner(struct rt2x00_dev *rt2x00dev)
582 */ 583 */
583 rt2400pci_bbp_read(rt2x00dev, 13, &reg); 584 rt2400pci_bbp_read(rt2x00dev, 13, &reg);
584 585
585 if (rt2x00dev->link.false_cca > 512 && reg < 0x20) { 586 if (rt2x00dev->link.qual.false_cca > 512 && reg < 0x20) {
586 rt2400pci_bbp_write(rt2x00dev, 13, ++reg); 587 rt2400pci_bbp_write(rt2x00dev, 13, ++reg);
587 rt2x00dev->link.vgc_level = reg; 588 rt2x00dev->link.vgc_level = reg;
588 } else if (rt2x00dev->link.false_cca < 100 && reg > 0x08) { 589 } else if (rt2x00dev->link.qual.false_cca < 100 && reg > 0x08) {
589 rt2400pci_bbp_write(rt2x00dev, 13, --reg); 590 rt2400pci_bbp_write(rt2x00dev, 13, --reg);
590 rt2x00dev->link.vgc_level = reg; 591 rt2x00dev->link.vgc_level = reg;
591 } 592 }
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 702321c30164..e66a9429fd48 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -587,7 +587,8 @@ static void rt2500pci_disable_led(struct rt2x00_dev *rt2x00dev)
587/* 587/*
588 * Link tuning 588 * Link tuning
589 */ 589 */
590static void rt2500pci_link_stats(struct rt2x00_dev *rt2x00dev) 590static void rt2500pci_link_stats(struct rt2x00_dev *rt2x00dev,
591 struct link_qual *qual)
591{ 592{
592 u32 reg; 593 u32 reg;
593 594
@@ -595,13 +596,13 @@ static void rt2500pci_link_stats(struct rt2x00_dev *rt2x00dev)
595 * Update FCS error count from register. 596 * Update FCS error count from register.
596 */ 597 */
597 rt2x00pci_register_read(rt2x00dev, CNT0, &reg); 598 rt2x00pci_register_read(rt2x00dev, CNT0, &reg);
598 rt2x00dev->link.rx_failed = rt2x00_get_field32(reg, CNT0_FCS_ERROR); 599 qual->rx_failed = rt2x00_get_field32(reg, CNT0_FCS_ERROR);
599 600
600 /* 601 /*
601 * Update False CCA count from register. 602 * Update False CCA count from register.
602 */ 603 */
603 rt2x00pci_register_read(rt2x00dev, CNT3, &reg); 604 rt2x00pci_register_read(rt2x00dev, CNT3, &reg);
604 rt2x00dev->link.false_cca = rt2x00_get_field32(reg, CNT3_FALSE_CCA); 605 qual->false_cca = rt2x00_get_field32(reg, CNT3_FALSE_CCA);
605} 606}
606 607
607static void rt2500pci_reset_tuner(struct rt2x00_dev *rt2x00dev) 608static void rt2500pci_reset_tuner(struct rt2x00_dev *rt2x00dev)
@@ -679,10 +680,10 @@ dynamic_cca_tune:
679 * R17 is inside the dynamic tuning range, 680 * R17 is inside the dynamic tuning range,
680 * start tuning the link based on the false cca counter. 681 * start tuning the link based on the false cca counter.
681 */ 682 */
682 if (rt2x00dev->link.false_cca > 512 && r17 < 0x40) { 683 if (rt2x00dev->link.qual.false_cca > 512 && r17 < 0x40) {
683 rt2500pci_bbp_write(rt2x00dev, 17, ++r17); 684 rt2500pci_bbp_write(rt2x00dev, 17, ++r17);
684 rt2x00dev->link.vgc_level = r17; 685 rt2x00dev->link.vgc_level = r17;
685 } else if (rt2x00dev->link.false_cca < 100 && r17 > 0x32) { 686 } else if (rt2x00dev->link.qual.false_cca < 100 && r17 > 0x32) {
686 rt2500pci_bbp_write(rt2x00dev, 17, --r17); 687 rt2500pci_bbp_write(rt2x00dev, 17, --r17);
687 rt2x00dev->link.vgc_level = r17; 688 rt2x00dev->link.vgc_level = r17;
688 } 689 }
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 18b1f9145389..7d3e2828747a 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -535,7 +535,8 @@ static void rt2500usb_disable_led(struct rt2x00_dev *rt2x00dev)
535/* 535/*
536 * Link tuning 536 * Link tuning
537 */ 537 */
538static void rt2500usb_link_stats(struct rt2x00_dev *rt2x00dev) 538static void rt2500usb_link_stats(struct rt2x00_dev *rt2x00dev,
539 struct link_qual *qual)
539{ 540{
540 u16 reg; 541 u16 reg;
541 542
@@ -543,14 +544,13 @@ static void rt2500usb_link_stats(struct rt2x00_dev *rt2x00dev)
543 * Update FCS error count from register. 544 * Update FCS error count from register.
544 */ 545 */
545 rt2500usb_register_read(rt2x00dev, STA_CSR0, &reg); 546 rt2500usb_register_read(rt2x00dev, STA_CSR0, &reg);
546 rt2x00dev->link.rx_failed = rt2x00_get_field16(reg, STA_CSR0_FCS_ERROR); 547 qual->rx_failed = rt2x00_get_field16(reg, STA_CSR0_FCS_ERROR);
547 548
548 /* 549 /*
549 * Update False CCA count from register. 550 * Update False CCA count from register.
550 */ 551 */
551 rt2500usb_register_read(rt2x00dev, STA_CSR3, &reg); 552 rt2500usb_register_read(rt2x00dev, STA_CSR3, &reg);
552 rt2x00dev->link.false_cca = 553 qual->false_cca = rt2x00_get_field16(reg, STA_CSR3_FALSE_CCA_ERROR);
553 rt2x00_get_field16(reg, STA_CSR3_FALSE_CCA_ERROR);
554} 554}
555 555
556static void rt2500usb_reset_tuner(struct rt2x00_dev *rt2x00dev) 556static void rt2500usb_reset_tuner(struct rt2x00_dev *rt2x00dev)
@@ -673,10 +673,10 @@ static void rt2500usb_link_tuner(struct rt2x00_dev *rt2x00dev)
673 if (r17 > up_bound) { 673 if (r17 > up_bound) {
674 rt2500usb_bbp_write(rt2x00dev, 17, up_bound); 674 rt2500usb_bbp_write(rt2x00dev, 17, up_bound);
675 rt2x00dev->link.vgc_level = up_bound; 675 rt2x00dev->link.vgc_level = up_bound;
676 } else if (rt2x00dev->link.false_cca > 512 && r17 < up_bound) { 676 } else if (rt2x00dev->link.qual.false_cca > 512 && r17 < up_bound) {
677 rt2500usb_bbp_write(rt2x00dev, 17, ++r17); 677 rt2500usb_bbp_write(rt2x00dev, 17, ++r17);
678 rt2x00dev->link.vgc_level = r17; 678 rt2x00dev->link.vgc_level = r17;
679 } else if (rt2x00dev->link.false_cca < 100 && r17 > low_bound) { 679 } else if (rt2x00dev->link.qual.false_cca < 100 && r17 > low_bound) {
680 rt2500usb_bbp_write(rt2x00dev, 17, --r17); 680 rt2500usb_bbp_write(rt2x00dev, 17, --r17);
681 rt2x00dev->link.vgc_level = r17; 681 rt2x00dev->link.vgc_level = r17;
682 } 682 }
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index c8f16f161c28..cec604b1b093 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -180,18 +180,9 @@ struct rf_channel {
180}; 180};
181 181
182/* 182/*
183 * To optimize the quality of the link we need to store 183 * Quality statistics about the currently active link.
184 * the quality of received frames and periodically
185 * optimize the link.
186 */ 184 */
187struct link { 185struct link_qual {
188 /*
189 * Link tuner counter
190 * The number of times the link has been tuned
191 * since the radio has been switched on.
192 */
193 u32 count;
194
195 /* 186 /*
196 * Statistics required for Link tuning. 187 * Statistics required for Link tuning.
197 * For the average RSSI value we use the "Walking average" approach. 188 * For the average RSSI value we use the "Walking average" approach.
@@ -211,7 +202,6 @@ struct link {
211 * the new values correctly allowing a effective link tuning. 202 * the new values correctly allowing a effective link tuning.
212 */ 203 */
213 int avg_rssi; 204 int avg_rssi;
214 int vgc_level;
215 int false_cca; 205 int false_cca;
216 206
217 /* 207 /*
@@ -240,6 +230,30 @@ struct link {
240#define WEIGHT_RSSI 20 230#define WEIGHT_RSSI 20
241#define WEIGHT_RX 40 231#define WEIGHT_RX 40
242#define WEIGHT_TX 40 232#define WEIGHT_TX 40
233};
234
235/*
236 * To optimize the quality of the link we need to store
237 * the quality of received frames and periodically
238 * optimize the link.
239 */
240struct link {
241 /*
242 * Link tuner counter
243 * The number of times the link has been tuned
244 * since the radio has been switched on.
245 */
246 u32 count;
247
248 /*
249 * Quality measurement values.
250 */
251 struct link_qual qual;
252
253 /*
254 * Active VGC level
255 */
256 int vgc_level;
243 257
244 /* 258 /*
245 * Work structure for scheduling periodic link tuning. 259 * Work structure for scheduling periodic link tuning.
@@ -249,25 +263,25 @@ struct link {
249 263
250/* 264/*
251 * Clear all counters inside the link structure. 265 * Clear all counters inside the link structure.
252 * This can be easiest achieved by memsetting everything
253 * except for the work structure at the end.
254 */ 266 */
255static inline void rt2x00_clear_link(struct link *link) 267static inline void rt2x00_clear_link(struct link *link)
256{ 268{
257 memset(link, 0x00, sizeof(*link) - sizeof(link->work)); 269 link->count = 0;
258 link->rx_percentage = 50; 270 memset(&link->qual, 0, sizeof(link->qual));
259 link->tx_percentage = 50; 271 link->qual.rx_percentage = 50;
272 link->qual.tx_percentage = 50;
260} 273}
261 274
275
262/* 276/*
263 * Update the rssi using the walking average approach. 277 * Update the rssi using the walking average approach.
264 */ 278 */
265static inline void rt2x00_update_link_rssi(struct link *link, int rssi) 279static inline void rt2x00_update_link_rssi(struct link *link, int rssi)
266{ 280{
267 if (!link->avg_rssi) 281 if (!link->qual.avg_rssi)
268 link->avg_rssi = rssi; 282 link->qual.avg_rssi = rssi;
269 else 283 else
270 link->avg_rssi = ((link->avg_rssi * 7) + rssi) / 8; 284 link->qual.avg_rssi = ((link->qual.avg_rssi * 7) + rssi) / 8;
271} 285}
272 286
273/* 287/*
@@ -277,7 +291,9 @@ static inline void rt2x00_update_link_rssi(struct link *link, int rssi)
277 */ 291 */
278static inline int rt2x00_get_link_rssi(struct link *link) 292static inline int rt2x00_get_link_rssi(struct link *link)
279{ 293{
280 return (link->avg_rssi && link->rx_success) ? link->avg_rssi : -128; 294 if (link->qual.avg_rssi && link->qual.rx_success)
295 return link->qual.avg_rssi;
296 return -128;
281} 297}
282 298
283/* 299/*
@@ -402,7 +418,8 @@ struct rt2x00lib_ops {
402 int (*set_device_state) (struct rt2x00_dev *rt2x00dev, 418 int (*set_device_state) (struct rt2x00_dev *rt2x00dev,
403 enum dev_state state); 419 enum dev_state state);
404 int (*rfkill_poll) (struct rt2x00_dev *rt2x00dev); 420 int (*rfkill_poll) (struct rt2x00_dev *rt2x00dev);
405 void (*link_stats) (struct rt2x00_dev *rt2x00dev); 421 void (*link_stats) (struct rt2x00_dev *rt2x00dev,
422 struct link_qual *qual);
406 void (*reset_tuner) (struct rt2x00_dev *rt2x00dev); 423 void (*reset_tuner) (struct rt2x00_dev *rt2x00dev);
407 void (*link_tuner) (struct rt2x00_dev *rt2x00dev); 424 void (*link_tuner) (struct rt2x00_dev *rt2x00dev);
408 425
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index ff399f8083e9..5d32e098696e 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -179,26 +179,26 @@ void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, enum dev_state state)
179 rt2x00lib_start_link_tuner(rt2x00dev); 179 rt2x00lib_start_link_tuner(rt2x00dev);
180} 180}
181 181
182static void rt2x00lib_precalculate_link_signal(struct link *link) 182static void rt2x00lib_precalculate_link_signal(struct link_qual *qual)
183{ 183{
184 if (link->rx_failed || link->rx_success) 184 if (qual->rx_failed || qual->rx_success)
185 link->rx_percentage = 185 qual->rx_percentage =
186 (link->rx_success * 100) / 186 (qual->rx_success * 100) /
187 (link->rx_failed + link->rx_success); 187 (qual->rx_failed + qual->rx_success);
188 else 188 else
189 link->rx_percentage = 50; 189 qual->rx_percentage = 50;
190 190
191 if (link->tx_failed || link->tx_success) 191 if (qual->tx_failed || qual->tx_success)
192 link->tx_percentage = 192 qual->tx_percentage =
193 (link->tx_success * 100) / 193 (qual->tx_success * 100) /
194 (link->tx_failed + link->tx_success); 194 (qual->tx_failed + qual->tx_success);
195 else 195 else
196 link->tx_percentage = 50; 196 qual->tx_percentage = 50;
197 197
198 link->rx_success = 0; 198 qual->rx_success = 0;
199 link->rx_failed = 0; 199 qual->rx_failed = 0;
200 link->tx_success = 0; 200 qual->tx_success = 0;
201 link->tx_failed = 0; 201 qual->tx_failed = 0;
202} 202}
203 203
204static int rt2x00lib_calculate_link_signal(struct rt2x00_dev *rt2x00dev, 204static int rt2x00lib_calculate_link_signal(struct rt2x00_dev *rt2x00dev,
@@ -225,8 +225,8 @@ static int rt2x00lib_calculate_link_signal(struct rt2x00_dev *rt2x00dev,
225 * defines to calculate the current link signal. 225 * defines to calculate the current link signal.
226 */ 226 */
227 signal = ((WEIGHT_RSSI * rssi_percentage) + 227 signal = ((WEIGHT_RSSI * rssi_percentage) +
228 (WEIGHT_TX * rt2x00dev->link.tx_percentage) + 228 (WEIGHT_TX * rt2x00dev->link.qual.tx_percentage) +
229 (WEIGHT_RX * rt2x00dev->link.rx_percentage)) / 100; 229 (WEIGHT_RX * rt2x00dev->link.qual.rx_percentage)) / 100;
230 230
231 return (signal > 100) ? 100 : signal; 231 return (signal > 100) ? 100 : signal;
232} 232}
@@ -246,10 +246,10 @@ static void rt2x00lib_link_tuner(struct work_struct *work)
246 /* 246 /*
247 * Update statistics. 247 * Update statistics.
248 */ 248 */
249 rt2x00dev->ops->lib->link_stats(rt2x00dev); 249 rt2x00dev->ops->lib->link_stats(rt2x00dev, &rt2x00dev->link.qual);
250 250
251 rt2x00dev->low_level_stats.dot11FCSErrorCount += 251 rt2x00dev->low_level_stats.dot11FCSErrorCount +=
252 rt2x00dev->link.rx_failed; 252 rt2x00dev->link.qual.rx_failed;
253 253
254 /* 254 /*
255 * Only perform the link tuning when Link tuning 255 * Only perform the link tuning when Link tuning
@@ -262,7 +262,7 @@ static void rt2x00lib_link_tuner(struct work_struct *work)
262 * Precalculate a portion of the link signal which is 262 * Precalculate a portion of the link signal which is
263 * in based on the tx/rx success/failure counters. 263 * in based on the tx/rx success/failure counters.
264 */ 264 */
265 rt2x00lib_precalculate_link_signal(&rt2x00dev->link); 265 rt2x00lib_precalculate_link_signal(&rt2x00dev->link.qual);
266 266
267 /* 267 /*
268 * Increase tuner counter, and reschedule the next link tuner run. 268 * Increase tuner counter, and reschedule the next link tuner run.
@@ -350,8 +350,8 @@ void rt2x00lib_txdone(struct data_entry *entry,
350 tx_status->ack_signal = 0; 350 tx_status->ack_signal = 0;
351 tx_status->excessive_retries = (status == TX_FAIL_RETRY); 351 tx_status->excessive_retries = (status == TX_FAIL_RETRY);
352 tx_status->retry_count = retry; 352 tx_status->retry_count = retry;
353 rt2x00dev->link.tx_success += success; 353 rt2x00dev->link.qual.tx_success += success;
354 rt2x00dev->link.tx_failed += retry + fail; 354 rt2x00dev->link.qual.tx_failed += retry + fail;
355 355
356 if (!(tx_status->control.flags & IEEE80211_TXCTL_NO_ACK)) { 356 if (!(tx_status->control.flags & IEEE80211_TXCTL_NO_ACK)) {
357 if (success) 357 if (success)
@@ -413,7 +413,7 @@ void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb,
413 } 413 }
414 414
415 rt2x00_update_link_rssi(&rt2x00dev->link, desc->rssi); 415 rt2x00_update_link_rssi(&rt2x00dev->link, desc->rssi);
416 rt2x00dev->link.rx_success++; 416 rt2x00dev->link.qual.rx_success++;
417 rx_status->rate = val; 417 rx_status->rate = val;
418 rx_status->signal = 418 rx_status->signal =
419 rt2x00lib_calculate_link_signal(rt2x00dev, desc->rssi); 419 rt2x00lib_calculate_link_signal(rt2x00dev, desc->rssi);
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index ecae968ce091..f893825ce6dd 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -792,7 +792,8 @@ static void rt61pci_activity_led(struct rt2x00_dev *rt2x00dev, int rssi)
792/* 792/*
793 * Link tuning 793 * Link tuning
794 */ 794 */
795static void rt61pci_link_stats(struct rt2x00_dev *rt2x00dev) 795static void rt61pci_link_stats(struct rt2x00_dev *rt2x00dev,
796 struct link_qual *qual)
796{ 797{
797 u32 reg; 798 u32 reg;
798 799
@@ -800,14 +801,13 @@ static void rt61pci_link_stats(struct rt2x00_dev *rt2x00dev)
800 * Update FCS error count from register. 801 * Update FCS error count from register.
801 */ 802 */
802 rt2x00pci_register_read(rt2x00dev, STA_CSR0, &reg); 803 rt2x00pci_register_read(rt2x00dev, STA_CSR0, &reg);
803 rt2x00dev->link.rx_failed = rt2x00_get_field32(reg, STA_CSR0_FCS_ERROR); 804 qual->rx_failed = rt2x00_get_field32(reg, STA_CSR0_FCS_ERROR);
804 805
805 /* 806 /*
806 * Update False CCA count from register. 807 * Update False CCA count from register.
807 */ 808 */
808 rt2x00pci_register_read(rt2x00dev, STA_CSR1, &reg); 809 rt2x00pci_register_read(rt2x00dev, STA_CSR1, &reg);
809 rt2x00dev->link.false_cca = 810 qual->false_cca = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR);
810 rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR);
811} 811}
812 812
813static void rt61pci_reset_tuner(struct rt2x00_dev *rt2x00dev) 813static void rt61pci_reset_tuner(struct rt2x00_dev *rt2x00dev)
@@ -904,11 +904,11 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
904 * r17 does not yet exceed upper limit, continue and base 904 * r17 does not yet exceed upper limit, continue and base
905 * the r17 tuning on the false CCA count. 905 * the r17 tuning on the false CCA count.
906 */ 906 */
907 if (rt2x00dev->link.false_cca > 512 && r17 < up_bound) { 907 if (rt2x00dev->link.qual.false_cca > 512 && r17 < up_bound) {
908 if (++r17 > up_bound) 908 if (++r17 > up_bound)
909 r17 = up_bound; 909 r17 = up_bound;
910 rt61pci_bbp_write(rt2x00dev, 17, r17); 910 rt61pci_bbp_write(rt2x00dev, 17, r17);
911 } else if (rt2x00dev->link.false_cca < 100 && r17 > low_bound) { 911 } else if (rt2x00dev->link.qual.false_cca < 100 && r17 > low_bound) {
912 if (--r17 < low_bound) 912 if (--r17 < low_bound)
913 r17 = low_bound; 913 r17 = low_bound;
914 rt61pci_bbp_write(rt2x00dev, 17, r17); 914 rt61pci_bbp_write(rt2x00dev, 17, r17);
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index c0671c2e6e73..e4ff106f588e 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -659,7 +659,8 @@ static void rt73usb_activity_led(struct rt2x00_dev *rt2x00dev, int rssi)
659/* 659/*
660 * Link tuning 660 * Link tuning
661 */ 661 */
662static void rt73usb_link_stats(struct rt2x00_dev *rt2x00dev) 662static void rt73usb_link_stats(struct rt2x00_dev *rt2x00dev,
663 struct link_qual *qual)
663{ 664{
664 u32 reg; 665 u32 reg;
665 666
@@ -667,15 +668,13 @@ static void rt73usb_link_stats(struct rt2x00_dev *rt2x00dev)
667 * Update FCS error count from register. 668 * Update FCS error count from register.
668 */ 669 */
669 rt73usb_register_read(rt2x00dev, STA_CSR0, &reg); 670 rt73usb_register_read(rt2x00dev, STA_CSR0, &reg);
670 rt2x00dev->link.rx_failed = rt2x00_get_field32(reg, STA_CSR0_FCS_ERROR); 671 qual->rx_failed = rt2x00_get_field32(reg, STA_CSR0_FCS_ERROR);
671 672
672 /* 673 /*
673 * Update False CCA count from register. 674 * Update False CCA count from register.
674 */ 675 */
675 rt73usb_register_read(rt2x00dev, STA_CSR1, &reg); 676 rt73usb_register_read(rt2x00dev, STA_CSR1, &reg);
676 reg = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR); 677 qual->false_cca = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR);
677 rt2x00dev->link.false_cca =
678 rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR);
679} 678}
680 679
681static void rt73usb_reset_tuner(struct rt2x00_dev *rt2x00dev) 680static void rt73usb_reset_tuner(struct rt2x00_dev *rt2x00dev)
@@ -781,12 +780,12 @@ static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev)
781 * r17 does not yet exceed upper limit, continue and base 780 * r17 does not yet exceed upper limit, continue and base
782 * the r17 tuning on the false CCA count. 781 * the r17 tuning on the false CCA count.
783 */ 782 */
784 if (rt2x00dev->link.false_cca > 512 && r17 < up_bound) { 783 if (rt2x00dev->link.qual.false_cca > 512 && r17 < up_bound) {
785 r17 += 4; 784 r17 += 4;
786 if (r17 > up_bound) 785 if (r17 > up_bound)
787 r17 = up_bound; 786 r17 = up_bound;
788 rt73usb_bbp_write(rt2x00dev, 17, r17); 787 rt73usb_bbp_write(rt2x00dev, 17, r17);
789 } else if (rt2x00dev->link.false_cca < 100 && r17 > low_bound) { 788 } else if (rt2x00dev->link.qual.false_cca < 100 && r17 > low_bound) {
790 r17 -= 4; 789 r17 -= 4;
791 if (r17 < low_bound) 790 if (r17 < low_bound)
792 r17 = low_bound; 791 r17 = low_bound;