diff options
author | Ivo van Doorn <ivdoorn@gmail.com> | 2008-10-29 12:17:57 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-11-10 15:17:33 -0500 |
commit | e4ea1c403acece78c271bf9cd6f797d1cb093df9 (patch) | |
tree | 4356693a16f2596de08f6afee76490f1ebe6b066 /drivers/net/wireless/rt2x00/rt2500pci.c | |
parent | 3f64b435ab76e79bfb3b4d36f043e6f892093b71 (diff) |
rt2x00: Optimize configuration handling
Implement latest changed from mac80211 configuration
handling to optmize configuration handling in rt2x00.
* Remove set_retry_limit callback function, handled
through config()
* Move config_antenna to its own callback function,
it isn't handled by mac80211 anymore
* Use IEEE80211_CONF_CHANGED_* flags and remove manual
checks
* Removed deprecated short slot setting through config()
and put it in config_erp() through which mac80211 now
configures it
* Remove config_phymode() and move contents to config_erp()
since it only managed the basic rates which is now
determined by mac80211 through config_erp().
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/rt2500pci.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2500pci.c | 206 |
1 files changed, 100 insertions, 106 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c index 85b0387f46eb..66a94c2f1b3c 100644 --- a/drivers/net/wireless/rt2x00/rt2500pci.c +++ b/drivers/net/wireless/rt2x00/rt2500pci.c | |||
@@ -402,12 +402,94 @@ static void rt2500pci_config_erp(struct rt2x00_dev *rt2x00dev, | |||
402 | rt2x00_set_field32(®, ARCSR5_SERVICE, 0x84); | 402 | rt2x00_set_field32(®, ARCSR5_SERVICE, 0x84); |
403 | rt2x00_set_field32(®, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110)); | 403 | rt2x00_set_field32(®, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110)); |
404 | rt2x00pci_register_write(rt2x00dev, ARCSR5, reg); | 404 | rt2x00pci_register_write(rt2x00dev, ARCSR5, reg); |
405 | |||
406 | rt2x00pci_register_write(rt2x00dev, ARCSR1, erp->basic_rates); | ||
407 | |||
408 | rt2x00pci_register_read(rt2x00dev, CSR11, ®); | ||
409 | rt2x00_set_field32(®, CSR11_SLOT_TIME, erp->slot_time); | ||
410 | rt2x00pci_register_write(rt2x00dev, CSR11, reg); | ||
411 | |||
412 | rt2x00pci_register_read(rt2x00dev, CSR18, ®); | ||
413 | rt2x00_set_field32(®, CSR18_SIFS, erp->sifs); | ||
414 | rt2x00_set_field32(®, CSR18_PIFS, erp->pifs); | ||
415 | rt2x00pci_register_write(rt2x00dev, CSR18, reg); | ||
416 | |||
417 | rt2x00pci_register_read(rt2x00dev, CSR19, ®); | ||
418 | rt2x00_set_field32(®, CSR19_DIFS, erp->difs); | ||
419 | rt2x00_set_field32(®, CSR19_EIFS, erp->eifs); | ||
420 | rt2x00pci_register_write(rt2x00dev, CSR19, reg); | ||
405 | } | 421 | } |
406 | 422 | ||
407 | static void rt2500pci_config_phymode(struct rt2x00_dev *rt2x00dev, | 423 | static void rt2500pci_config_ant(struct rt2x00_dev *rt2x00dev, |
408 | const int basic_rate_mask) | 424 | struct antenna_setup *ant) |
409 | { | 425 | { |
410 | rt2x00pci_register_write(rt2x00dev, ARCSR1, basic_rate_mask); | 426 | u32 reg; |
427 | u8 r14; | ||
428 | u8 r2; | ||
429 | |||
430 | /* | ||
431 | * We should never come here because rt2x00lib is supposed | ||
432 | * to catch this and send us the correct antenna explicitely. | ||
433 | */ | ||
434 | BUG_ON(ant->rx == ANTENNA_SW_DIVERSITY || | ||
435 | ant->tx == ANTENNA_SW_DIVERSITY); | ||
436 | |||
437 | rt2x00pci_register_read(rt2x00dev, BBPCSR1, ®); | ||
438 | rt2500pci_bbp_read(rt2x00dev, 14, &r14); | ||
439 | rt2500pci_bbp_read(rt2x00dev, 2, &r2); | ||
440 | |||
441 | /* | ||
442 | * Configure the TX antenna. | ||
443 | */ | ||
444 | switch (ant->tx) { | ||
445 | case ANTENNA_A: | ||
446 | rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 0); | ||
447 | rt2x00_set_field32(®, BBPCSR1_CCK, 0); | ||
448 | rt2x00_set_field32(®, BBPCSR1_OFDM, 0); | ||
449 | break; | ||
450 | case ANTENNA_B: | ||
451 | default: | ||
452 | rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 2); | ||
453 | rt2x00_set_field32(®, BBPCSR1_CCK, 2); | ||
454 | rt2x00_set_field32(®, BBPCSR1_OFDM, 2); | ||
455 | break; | ||
456 | } | ||
457 | |||
458 | /* | ||
459 | * Configure the RX antenna. | ||
460 | */ | ||
461 | switch (ant->rx) { | ||
462 | case ANTENNA_A: | ||
463 | rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 0); | ||
464 | break; | ||
465 | case ANTENNA_B: | ||
466 | default: | ||
467 | rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 2); | ||
468 | break; | ||
469 | } | ||
470 | |||
471 | /* | ||
472 | * RT2525E and RT5222 need to flip TX I/Q | ||
473 | */ | ||
474 | if (rt2x00_rf(&rt2x00dev->chip, RF2525E) || | ||
475 | rt2x00_rf(&rt2x00dev->chip, RF5222)) { | ||
476 | rt2x00_set_field8(&r2, BBP_R2_TX_IQ_FLIP, 1); | ||
477 | rt2x00_set_field32(®, BBPCSR1_CCK_FLIP, 1); | ||
478 | rt2x00_set_field32(®, BBPCSR1_OFDM_FLIP, 1); | ||
479 | |||
480 | /* | ||
481 | * RT2525E does not need RX I/Q Flip. | ||
482 | */ | ||
483 | if (rt2x00_rf(&rt2x00dev->chip, RF2525E)) | ||
484 | rt2x00_set_field8(&r14, BBP_R14_RX_IQ_FLIP, 0); | ||
485 | } else { | ||
486 | rt2x00_set_field32(®, BBPCSR1_CCK_FLIP, 0); | ||
487 | rt2x00_set_field32(®, BBPCSR1_OFDM_FLIP, 0); | ||
488 | } | ||
489 | |||
490 | rt2x00pci_register_write(rt2x00dev, BBPCSR1, reg); | ||
491 | rt2500pci_bbp_write(rt2x00dev, 14, r14); | ||
492 | rt2500pci_bbp_write(rt2x00dev, 2, r2); | ||
411 | } | 493 | } |
412 | 494 | ||
413 | static void rt2500pci_config_channel(struct rt2x00_dev *rt2x00dev, | 495 | static void rt2500pci_config_channel(struct rt2x00_dev *rt2x00dev, |
@@ -489,76 +571,17 @@ static void rt2500pci_config_txpower(struct rt2x00_dev *rt2x00dev, | |||
489 | rt2500pci_rf_write(rt2x00dev, 3, rf3); | 571 | rt2500pci_rf_write(rt2x00dev, 3, rf3); |
490 | } | 572 | } |
491 | 573 | ||
492 | static void rt2500pci_config_antenna(struct rt2x00_dev *rt2x00dev, | 574 | static void rt2500pci_config_retry_limit(struct rt2x00_dev *rt2x00dev, |
493 | struct antenna_setup *ant) | 575 | struct rt2x00lib_conf *libconf) |
494 | { | 576 | { |
495 | u32 reg; | 577 | u32 reg; |
496 | u8 r14; | ||
497 | u8 r2; | ||
498 | 578 | ||
499 | /* | 579 | rt2x00pci_register_read(rt2x00dev, CSR11, ®); |
500 | * We should never come here because rt2x00lib is supposed | 580 | rt2x00_set_field32(®, CSR11_LONG_RETRY, |
501 | * to catch this and send us the correct antenna explicitely. | 581 | libconf->conf->long_frame_max_tx_count); |
502 | */ | 582 | rt2x00_set_field32(®, CSR11_SHORT_RETRY, |
503 | BUG_ON(ant->rx == ANTENNA_SW_DIVERSITY || | 583 | libconf->conf->short_frame_max_tx_count); |
504 | ant->tx == ANTENNA_SW_DIVERSITY); | 584 | rt2x00pci_register_write(rt2x00dev, CSR11, reg); |
505 | |||
506 | rt2x00pci_register_read(rt2x00dev, BBPCSR1, ®); | ||
507 | rt2500pci_bbp_read(rt2x00dev, 14, &r14); | ||
508 | rt2500pci_bbp_read(rt2x00dev, 2, &r2); | ||
509 | |||
510 | /* | ||
511 | * Configure the TX antenna. | ||
512 | */ | ||
513 | switch (ant->tx) { | ||
514 | case ANTENNA_A: | ||
515 | rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 0); | ||
516 | rt2x00_set_field32(®, BBPCSR1_CCK, 0); | ||
517 | rt2x00_set_field32(®, BBPCSR1_OFDM, 0); | ||
518 | break; | ||
519 | case ANTENNA_B: | ||
520 | default: | ||
521 | rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 2); | ||
522 | rt2x00_set_field32(®, BBPCSR1_CCK, 2); | ||
523 | rt2x00_set_field32(®, BBPCSR1_OFDM, 2); | ||
524 | break; | ||
525 | } | ||
526 | |||
527 | /* | ||
528 | * Configure the RX antenna. | ||
529 | */ | ||
530 | switch (ant->rx) { | ||
531 | case ANTENNA_A: | ||
532 | rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 0); | ||
533 | break; | ||
534 | case ANTENNA_B: | ||
535 | default: | ||
536 | rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 2); | ||
537 | break; | ||
538 | } | ||
539 | |||
540 | /* | ||
541 | * RT2525E and RT5222 need to flip TX I/Q | ||
542 | */ | ||
543 | if (rt2x00_rf(&rt2x00dev->chip, RF2525E) || | ||
544 | rt2x00_rf(&rt2x00dev->chip, RF5222)) { | ||
545 | rt2x00_set_field8(&r2, BBP_R2_TX_IQ_FLIP, 1); | ||
546 | rt2x00_set_field32(®, BBPCSR1_CCK_FLIP, 1); | ||
547 | rt2x00_set_field32(®, BBPCSR1_OFDM_FLIP, 1); | ||
548 | |||
549 | /* | ||
550 | * RT2525E does not need RX I/Q Flip. | ||
551 | */ | ||
552 | if (rt2x00_rf(&rt2x00dev->chip, RF2525E)) | ||
553 | rt2x00_set_field8(&r14, BBP_R14_RX_IQ_FLIP, 0); | ||
554 | } else { | ||
555 | rt2x00_set_field32(®, BBPCSR1_CCK_FLIP, 0); | ||
556 | rt2x00_set_field32(®, BBPCSR1_OFDM_FLIP, 0); | ||
557 | } | ||
558 | |||
559 | rt2x00pci_register_write(rt2x00dev, BBPCSR1, reg); | ||
560 | rt2500pci_bbp_write(rt2x00dev, 14, r14); | ||
561 | rt2500pci_bbp_write(rt2x00dev, 2, r2); | ||
562 | } | 585 | } |
563 | 586 | ||
564 | static void rt2500pci_config_duration(struct rt2x00_dev *rt2x00dev, | 587 | static void rt2500pci_config_duration(struct rt2x00_dev *rt2x00dev, |
@@ -566,20 +589,6 @@ static void rt2500pci_config_duration(struct rt2x00_dev *rt2x00dev, | |||
566 | { | 589 | { |
567 | u32 reg; | 590 | u32 reg; |
568 | 591 | ||
569 | rt2x00pci_register_read(rt2x00dev, CSR11, ®); | ||
570 | rt2x00_set_field32(®, CSR11_SLOT_TIME, libconf->slot_time); | ||
571 | rt2x00pci_register_write(rt2x00dev, CSR11, reg); | ||
572 | |||
573 | rt2x00pci_register_read(rt2x00dev, CSR18, ®); | ||
574 | rt2x00_set_field32(®, CSR18_SIFS, libconf->sifs); | ||
575 | rt2x00_set_field32(®, CSR18_PIFS, libconf->pifs); | ||
576 | rt2x00pci_register_write(rt2x00dev, CSR18, reg); | ||
577 | |||
578 | rt2x00pci_register_read(rt2x00dev, CSR19, ®); | ||
579 | rt2x00_set_field32(®, CSR19_DIFS, libconf->difs); | ||
580 | rt2x00_set_field32(®, CSR19_EIFS, libconf->eifs); | ||
581 | rt2x00pci_register_write(rt2x00dev, CSR19, reg); | ||
582 | |||
583 | rt2x00pci_register_read(rt2x00dev, TXCSR1, ®); | 592 | rt2x00pci_register_read(rt2x00dev, TXCSR1, ®); |
584 | rt2x00_set_field32(®, TXCSR1_TSF_OFFSET, IEEE80211_HEADER); | 593 | rt2x00_set_field32(®, TXCSR1_TSF_OFFSET, IEEE80211_HEADER); |
585 | rt2x00_set_field32(®, TXCSR1_AUTORESPONDER, 1); | 594 | rt2x00_set_field32(®, TXCSR1_AUTORESPONDER, 1); |
@@ -597,17 +606,16 @@ static void rt2500pci_config(struct rt2x00_dev *rt2x00dev, | |||
597 | struct rt2x00lib_conf *libconf, | 606 | struct rt2x00lib_conf *libconf, |
598 | const unsigned int flags) | 607 | const unsigned int flags) |
599 | { | 608 | { |
600 | if (flags & CONFIG_UPDATE_PHYMODE) | 609 | if (flags & IEEE80211_CONF_CHANGE_CHANNEL) |
601 | rt2500pci_config_phymode(rt2x00dev, libconf->basic_rates); | ||
602 | if (flags & CONFIG_UPDATE_CHANNEL) | ||
603 | rt2500pci_config_channel(rt2x00dev, &libconf->rf, | 610 | rt2500pci_config_channel(rt2x00dev, &libconf->rf, |
604 | libconf->conf->power_level); | 611 | libconf->conf->power_level); |
605 | if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL)) | 612 | if ((flags & IEEE80211_CONF_CHANGE_POWER) && |
613 | !(flags & IEEE80211_CONF_CHANGE_CHANNEL)) | ||
606 | rt2500pci_config_txpower(rt2x00dev, | 614 | rt2500pci_config_txpower(rt2x00dev, |
607 | libconf->conf->power_level); | 615 | libconf->conf->power_level); |
608 | if (flags & CONFIG_UPDATE_ANTENNA) | 616 | if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS) |
609 | rt2500pci_config_antenna(rt2x00dev, &libconf->ant); | 617 | rt2500pci_config_retry_limit(rt2x00dev, libconf); |
610 | if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) | 618 | if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL) |
611 | rt2500pci_config_duration(rt2x00dev, libconf); | 619 | rt2500pci_config_duration(rt2x00dev, libconf); |
612 | } | 620 | } |
613 | 621 | ||
@@ -1827,20 +1835,6 @@ static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev) | |||
1827 | /* | 1835 | /* |
1828 | * IEEE80211 stack callback functions. | 1836 | * IEEE80211 stack callback functions. |
1829 | */ | 1837 | */ |
1830 | static int rt2500pci_set_retry_limit(struct ieee80211_hw *hw, | ||
1831 | u32 short_retry, u32 long_retry) | ||
1832 | { | ||
1833 | struct rt2x00_dev *rt2x00dev = hw->priv; | ||
1834 | u32 reg; | ||
1835 | |||
1836 | rt2x00pci_register_read(rt2x00dev, CSR11, ®); | ||
1837 | rt2x00_set_field32(®, CSR11_LONG_RETRY, long_retry); | ||
1838 | rt2x00_set_field32(®, CSR11_SHORT_RETRY, short_retry); | ||
1839 | rt2x00pci_register_write(rt2x00dev, CSR11, reg); | ||
1840 | |||
1841 | return 0; | ||
1842 | } | ||
1843 | |||
1844 | static u64 rt2500pci_get_tsf(struct ieee80211_hw *hw) | 1838 | static u64 rt2500pci_get_tsf(struct ieee80211_hw *hw) |
1845 | { | 1839 | { |
1846 | struct rt2x00_dev *rt2x00dev = hw->priv; | 1840 | struct rt2x00_dev *rt2x00dev = hw->priv; |
@@ -1901,8 +1895,8 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = { | |||
1901 | .config_filter = rt2500pci_config_filter, | 1895 | .config_filter = rt2500pci_config_filter, |
1902 | .config_intf = rt2500pci_config_intf, | 1896 | .config_intf = rt2500pci_config_intf, |
1903 | .config_erp = rt2500pci_config_erp, | 1897 | .config_erp = rt2500pci_config_erp, |
1898 | .config_ant = rt2500pci_config_ant, | ||
1904 | .config = rt2500pci_config, | 1899 | .config = rt2500pci_config, |
1905 | .set_retry_limit = rt2500pci_set_retry_limit, | ||
1906 | }; | 1900 | }; |
1907 | 1901 | ||
1908 | static const struct data_queue_desc rt2500pci_queue_rx = { | 1902 | static const struct data_queue_desc rt2500pci_queue_rx = { |