aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00dev.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-01-24 13:38:38 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-02-29 15:19:32 -0500
commit8318d78a44d49ac1edf2bdec7299de3617c4232e (patch)
treed434634418edd7399737801615d247be06616fdd /drivers/net/wireless/rt2x00/rt2x00dev.c
parent10b6b80145cc93887dd8aab99bfffa375e9add31 (diff)
cfg80211 API for channels/bitrates, mac80211 and driver conversion
This patch creates new cfg80211 wiphy API for channel and bitrate registration and converts mac80211 and drivers to the new API. The old mac80211 API is completely ripped out. All drivers (except ath5k) are updated to the new API, in many cases I expect that optimisations can be done. Along with the regulatory code I've also ripped out the IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED flag, I believe it to be unnecessary if the hardware simply gives us whatever channels it wants to support and we then enable/disable them as required, which is pretty much required for travelling. Additionally, the patch adds proper "basic" rate handling for STA mode interface, AP mode interface will have to have new API added to allow userspace to set the basic rate set, currently it'll be empty... However, the basic rate handling will need to be moved to the BSS conf stuff. I do expect there to be bugs in this, especially wrt. transmit power handling where I'm basically clueless about how it should work. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00dev.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c149
1 files changed, 59 insertions, 90 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 0df8062b1a8e..83a72ae36638 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -550,19 +550,19 @@ void rt2x00lib_rxdone(struct queue_entry *entry,
550{ 550{
551 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 551 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
552 struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status; 552 struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status;
553 struct ieee80211_hw_mode *mode; 553 struct ieee80211_supported_band *sband;
554 struct ieee80211_rate *rate; 554 struct ieee80211_rate *rate;
555 struct ieee80211_hdr *hdr; 555 struct ieee80211_hdr *hdr;
556 unsigned int i; 556 unsigned int i;
557 int val = 0; 557 int val = 0, idx = -1;
558 u16 fc; 558 u16 fc;
559 559
560 /* 560 /*
561 * Update RX statistics. 561 * Update RX statistics.
562 */ 562 */
563 mode = &rt2x00dev->hwmodes[rt2x00dev->curr_hwmode]; 563 sband = &rt2x00dev->bands[rt2x00dev->curr_band];
564 for (i = 0; i < mode->num_rates; i++) { 564 for (i = 0; i < sband->n_bitrates; i++) {
565 rate = &mode->rates[i]; 565 rate = &sband->bitrates[i];
566 566
567 /* 567 /*
568 * When frame was received with an OFDM bitrate, 568 * When frame was received with an OFDM bitrate,
@@ -570,12 +570,12 @@ void rt2x00lib_rxdone(struct queue_entry *entry,
570 * a CCK bitrate the signal is the rate in 0.5kbit/s. 570 * a CCK bitrate the signal is the rate in 0.5kbit/s.
571 */ 571 */
572 if (!rxdesc->ofdm) 572 if (!rxdesc->ofdm)
573 val = DEVICE_GET_RATE_FIELD(rate->val, RATE); 573 val = DEVICE_GET_RATE_FIELD(rate->hw_value, RATE);
574 else 574 else
575 val = DEVICE_GET_RATE_FIELD(rate->val, PLCP); 575 val = DEVICE_GET_RATE_FIELD(rate->hw_value, PLCP);
576 576
577 if (val == rxdesc->signal) { 577 if (val == rxdesc->signal) {
578 val = rate->val; 578 idx = i;
579 break; 579 break;
580 } 580 }
581 } 581 }
@@ -590,7 +590,7 @@ void rt2x00lib_rxdone(struct queue_entry *entry,
590 590
591 rt2x00dev->link.qual.rx_success++; 591 rt2x00dev->link.qual.rx_success++;
592 592
593 rx_status->rate = val; 593 rx_status->rate_idx = idx;
594 rx_status->signal = 594 rx_status->signal =
595 rt2x00lib_calculate_link_signal(rt2x00dev, rxdesc->rssi); 595 rt2x00lib_calculate_link_signal(rt2x00dev, rxdesc->rssi);
596 rx_status->ssi = rxdesc->rssi; 596 rx_status->ssi = rxdesc->rssi;
@@ -639,7 +639,7 @@ void rt2x00lib_write_tx_desc(struct rt2x00_dev *rt2x00dev,
639 frame_control = le16_to_cpu(ieee80211hdr->frame_control); 639 frame_control = le16_to_cpu(ieee80211hdr->frame_control);
640 seq_ctrl = le16_to_cpu(ieee80211hdr->seq_ctrl); 640 seq_ctrl = le16_to_cpu(ieee80211hdr->seq_ctrl);
641 641
642 tx_rate = control->tx_rate; 642 tx_rate = control->tx_rate->hw_value;
643 643
644 /* 644 /*
645 * Check whether this frame is to be acked 645 * Check whether this frame is to be acked
@@ -658,7 +658,7 @@ void rt2x00lib_write_tx_desc(struct rt2x00_dev *rt2x00dev,
658 } else 658 } else
659 __clear_bit(ENTRY_TXD_ACK, &txdesc.flags); 659 __clear_bit(ENTRY_TXD_ACK, &txdesc.flags);
660 if (control->rts_cts_rate) 660 if (control->rts_cts_rate)
661 tx_rate = control->rts_cts_rate; 661 tx_rate = control->rts_cts_rate->hw_value;
662 } 662 }
663 663
664 /* 664 /*
@@ -760,54 +760,45 @@ static void rt2x00lib_channel(struct ieee80211_channel *entry,
760 const int channel, const int tx_power, 760 const int channel, const int tx_power,
761 const int value) 761 const int value)
762{ 762{
763 entry->chan = channel;
764 if (channel <= 14) 763 if (channel <= 14)
765 entry->freq = 2407 + (5 * channel); 764 entry->center_freq = 2407 + (5 * channel);
766 else 765 else
767 entry->freq = 5000 + (5 * channel); 766 entry->center_freq = 5000 + (5 * channel);
768 entry->val = value; 767 entry->hw_value = value;
769 entry->flag = 768 entry->max_power = tx_power;
770 IEEE80211_CHAN_W_IBSS | 769 entry->max_antenna_gain = 0xff;
771 IEEE80211_CHAN_W_ACTIVE_SCAN |
772 IEEE80211_CHAN_W_SCAN;
773 entry->power_level = tx_power;
774 entry->antenna_max = 0xff;
775} 770}
776 771
777static void rt2x00lib_rate(struct ieee80211_rate *entry, 772static void rt2x00lib_rate(struct ieee80211_rate *entry,
778 const int rate, const int mask, 773 const int rate, const int mask,
779 const int plcp, const int flags) 774 const int plcp, const int flags)
780{ 775{
781 entry->rate = rate; 776 entry->bitrate = rate;
782 entry->val = 777 entry->hw_value =
783 DEVICE_SET_RATE_FIELD(rate, RATE) | 778 DEVICE_SET_RATE_FIELD(rate, RATE) |
784 DEVICE_SET_RATE_FIELD(mask, RATEMASK) | 779 DEVICE_SET_RATE_FIELD(mask, RATEMASK) |
785 DEVICE_SET_RATE_FIELD(plcp, PLCP); 780 DEVICE_SET_RATE_FIELD(plcp, PLCP);
786 entry->flags = flags; 781 entry->flags = flags;
787 entry->val2 = entry->val; 782 entry->hw_value_short = entry->hw_value;
788 if (entry->flags & IEEE80211_RATE_PREAMBLE2) 783 if (entry->flags & IEEE80211_RATE_SHORT_PREAMBLE)
789 entry->val2 |= DEVICE_SET_RATE_FIELD(1, PREAMBLE); 784 entry->hw_value_short |= DEVICE_SET_RATE_FIELD(1, PREAMBLE);
790 entry->min_rssi_ack = 0;
791 entry->min_rssi_ack_delta = 0;
792} 785}
793 786
794static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev, 787static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
795 struct hw_mode_spec *spec) 788 struct hw_mode_spec *spec)
796{ 789{
797 struct ieee80211_hw *hw = rt2x00dev->hw; 790 struct ieee80211_hw *hw = rt2x00dev->hw;
798 struct ieee80211_hw_mode *hwmodes; 791 struct ieee80211_supported_band *sbands;
799 struct ieee80211_channel *channels; 792 struct ieee80211_channel *channels;
800 struct ieee80211_rate *rates; 793 struct ieee80211_rate *rates;
801 unsigned int i; 794 unsigned int i;
802 unsigned char tx_power; 795 unsigned char tx_power;
803 796
804 hwmodes = kzalloc(sizeof(*hwmodes) * spec->num_modes, GFP_KERNEL); 797 sbands = &rt2x00dev->bands[0];
805 if (!hwmodes)
806 goto exit;
807 798
808 channels = kzalloc(sizeof(*channels) * spec->num_channels, GFP_KERNEL); 799 channels = kzalloc(sizeof(*channels) * spec->num_channels, GFP_KERNEL);
809 if (!channels) 800 if (!channels)
810 goto exit_free_modes; 801 return -ENOMEM;
811 802
812 rates = kzalloc(sizeof(*rates) * spec->num_rates, GFP_KERNEL); 803 rates = kzalloc(sizeof(*rates) * spec->num_rates, GFP_KERNEL);
813 if (!rates) 804 if (!rates)
@@ -817,31 +808,31 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
817 * Initialize Rate list. 808 * Initialize Rate list.
818 */ 809 */
819 rt2x00lib_rate(&rates[0], 10, DEV_RATEMASK_1MB, 810 rt2x00lib_rate(&rates[0], 10, DEV_RATEMASK_1MB,
820 0x00, IEEE80211_RATE_CCK); 811 0x00, 0);
821 rt2x00lib_rate(&rates[1], 20, DEV_RATEMASK_2MB, 812 rt2x00lib_rate(&rates[1], 20, DEV_RATEMASK_2MB,
822 0x01, IEEE80211_RATE_CCK_2); 813 0x01, IEEE80211_RATE_SHORT_PREAMBLE);
823 rt2x00lib_rate(&rates[2], 55, DEV_RATEMASK_5_5MB, 814 rt2x00lib_rate(&rates[2], 55, DEV_RATEMASK_5_5MB,
824 0x02, IEEE80211_RATE_CCK_2); 815 0x02, IEEE80211_RATE_SHORT_PREAMBLE);
825 rt2x00lib_rate(&rates[3], 110, DEV_RATEMASK_11MB, 816 rt2x00lib_rate(&rates[3], 110, DEV_RATEMASK_11MB,
826 0x03, IEEE80211_RATE_CCK_2); 817 0x03, IEEE80211_RATE_SHORT_PREAMBLE);
827 818
828 if (spec->num_rates > 4) { 819 if (spec->num_rates > 4) {
829 rt2x00lib_rate(&rates[4], 60, DEV_RATEMASK_6MB, 820 rt2x00lib_rate(&rates[4], 60, DEV_RATEMASK_6MB,
830 0x0b, IEEE80211_RATE_OFDM); 821 0x0b, 0);
831 rt2x00lib_rate(&rates[5], 90, DEV_RATEMASK_9MB, 822 rt2x00lib_rate(&rates[5], 90, DEV_RATEMASK_9MB,
832 0x0f, IEEE80211_RATE_OFDM); 823 0x0f, 0);
833 rt2x00lib_rate(&rates[6], 120, DEV_RATEMASK_12MB, 824 rt2x00lib_rate(&rates[6], 120, DEV_RATEMASK_12MB,
834 0x0a, IEEE80211_RATE_OFDM); 825 0x0a, 0);
835 rt2x00lib_rate(&rates[7], 180, DEV_RATEMASK_18MB, 826 rt2x00lib_rate(&rates[7], 180, DEV_RATEMASK_18MB,
836 0x0e, IEEE80211_RATE_OFDM); 827 0x0e, 0);
837 rt2x00lib_rate(&rates[8], 240, DEV_RATEMASK_24MB, 828 rt2x00lib_rate(&rates[8], 240, DEV_RATEMASK_24MB,
838 0x09, IEEE80211_RATE_OFDM); 829 0x09, 0);
839 rt2x00lib_rate(&rates[9], 360, DEV_RATEMASK_36MB, 830 rt2x00lib_rate(&rates[9], 360, DEV_RATEMASK_36MB,
840 0x0d, IEEE80211_RATE_OFDM); 831 0x0d, 0);
841 rt2x00lib_rate(&rates[10], 480, DEV_RATEMASK_48MB, 832 rt2x00lib_rate(&rates[10], 480, DEV_RATEMASK_48MB,
842 0x08, IEEE80211_RATE_OFDM); 833 0x08, 0);
843 rt2x00lib_rate(&rates[11], 540, DEV_RATEMASK_54MB, 834 rt2x00lib_rate(&rates[11], 540, DEV_RATEMASK_54MB,
844 0x0c, IEEE80211_RATE_OFDM); 835 0x0c, 0);
845 } 836 }
846 837
847 /* 838 /*
@@ -862,27 +853,27 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
862 /* 853 /*
863 * Intitialize 802.11b 854 * Intitialize 802.11b
864 * Rates: CCK. 855 * Rates: CCK.
865 * Channels: OFDM. 856 * Channels: 2.4 GHz
866 */ 857 */
867 if (spec->num_modes > HWMODE_B) { 858 if (spec->num_modes > HWMODE_B) {
868 hwmodes[HWMODE_B].mode = MODE_IEEE80211B; 859 sbands[IEEE80211_BAND_2GHZ].n_channels = 14;
869 hwmodes[HWMODE_B].num_channels = 14; 860 sbands[IEEE80211_BAND_2GHZ].n_bitrates = 4;
870 hwmodes[HWMODE_B].num_rates = 4; 861 sbands[IEEE80211_BAND_2GHZ].channels = channels;
871 hwmodes[HWMODE_B].channels = channels; 862 sbands[IEEE80211_BAND_2GHZ].bitrates = rates;
872 hwmodes[HWMODE_B].rates = rates; 863 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &rt2x00dev->bands[IEEE80211_BAND_2GHZ];
873 } 864 }
874 865
875 /* 866 /*
876 * Intitialize 802.11g 867 * Intitialize 802.11g
877 * Rates: CCK, OFDM. 868 * Rates: CCK, OFDM.
878 * Channels: OFDM. 869 * Channels: 2.4 GHz
879 */ 870 */
880 if (spec->num_modes > HWMODE_G) { 871 if (spec->num_modes > HWMODE_G) {
881 hwmodes[HWMODE_G].mode = MODE_IEEE80211G; 872 sbands[IEEE80211_BAND_2GHZ].n_channels = 14;
882 hwmodes[HWMODE_G].num_channels = 14; 873 sbands[IEEE80211_BAND_2GHZ].n_bitrates = spec->num_rates;
883 hwmodes[HWMODE_G].num_rates = spec->num_rates; 874 sbands[IEEE80211_BAND_2GHZ].channels = channels;
884 hwmodes[HWMODE_G].channels = channels; 875 sbands[IEEE80211_BAND_2GHZ].bitrates = rates;
885 hwmodes[HWMODE_G].rates = rates; 876 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &rt2x00dev->bands[IEEE80211_BAND_2GHZ];
886 } 877 }
887 878
888 /* 879 /*
@@ -891,39 +882,17 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
891 * Channels: OFDM, UNII, HiperLAN2. 882 * Channels: OFDM, UNII, HiperLAN2.
892 */ 883 */
893 if (spec->num_modes > HWMODE_A) { 884 if (spec->num_modes > HWMODE_A) {
894 hwmodes[HWMODE_A].mode = MODE_IEEE80211A; 885 sbands[IEEE80211_BAND_5GHZ].n_channels = spec->num_channels - 14;
895 hwmodes[HWMODE_A].num_channels = spec->num_channels - 14; 886 sbands[IEEE80211_BAND_5GHZ].n_bitrates = spec->num_rates - 4;
896 hwmodes[HWMODE_A].num_rates = spec->num_rates - 4; 887 sbands[IEEE80211_BAND_5GHZ].channels = &channels[14];
897 hwmodes[HWMODE_A].channels = &channels[14]; 888 sbands[IEEE80211_BAND_5GHZ].bitrates = &rates[4];
898 hwmodes[HWMODE_A].rates = &rates[4]; 889 hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &rt2x00dev->bands[IEEE80211_BAND_5GHZ];
899 } 890 }
900 891
901 if (spec->num_modes > HWMODE_G &&
902 ieee80211_register_hwmode(hw, &hwmodes[HWMODE_G]))
903 goto exit_free_rates;
904
905 if (spec->num_modes > HWMODE_B &&
906 ieee80211_register_hwmode(hw, &hwmodes[HWMODE_B]))
907 goto exit_free_rates;
908
909 if (spec->num_modes > HWMODE_A &&
910 ieee80211_register_hwmode(hw, &hwmodes[HWMODE_A]))
911 goto exit_free_rates;
912
913 rt2x00dev->hwmodes = hwmodes;
914
915 return 0; 892 return 0;
916 893
917exit_free_rates: 894 exit_free_channels:
918 kfree(rates);
919
920exit_free_channels:
921 kfree(channels); 895 kfree(channels);
922
923exit_free_modes:
924 kfree(hwmodes);
925
926exit:
927 ERROR(rt2x00dev, "Allocation ieee80211 modes failed.\n"); 896 ERROR(rt2x00dev, "Allocation ieee80211 modes failed.\n");
928 return -ENOMEM; 897 return -ENOMEM;
929} 898}
@@ -933,11 +902,11 @@ static void rt2x00lib_remove_hw(struct rt2x00_dev *rt2x00dev)
933 if (test_bit(DEVICE_REGISTERED_HW, &rt2x00dev->flags)) 902 if (test_bit(DEVICE_REGISTERED_HW, &rt2x00dev->flags))
934 ieee80211_unregister_hw(rt2x00dev->hw); 903 ieee80211_unregister_hw(rt2x00dev->hw);
935 904
936 if (likely(rt2x00dev->hwmodes)) { 905 if (likely(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ])) {
937 kfree(rt2x00dev->hwmodes->channels); 906 kfree(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->channels);
938 kfree(rt2x00dev->hwmodes->rates); 907 kfree(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->bitrates);
939 kfree(rt2x00dev->hwmodes); 908 rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL;
940 rt2x00dev->hwmodes = NULL; 909 rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL;
941 } 910 }
942} 911}
943 912