aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rtl8187_dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rtl8187_dev.c')
-rw-r--r--drivers/net/wireless/rtl8187_dev.c92
1 files changed, 64 insertions, 28 deletions
diff --git a/drivers/net/wireless/rtl8187_dev.c b/drivers/net/wireless/rtl8187_dev.c
index 133b3f39eeb6..d5787b37e1fb 100644
--- a/drivers/net/wireless/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl8187_dev.c
@@ -45,6 +45,38 @@ static struct usb_device_id rtl8187_table[] __devinitdata = {
45 45
46MODULE_DEVICE_TABLE(usb, rtl8187_table); 46MODULE_DEVICE_TABLE(usb, rtl8187_table);
47 47
48static const struct ieee80211_rate rtl818x_rates[] = {
49 { .bitrate = 10, .hw_value = 0, },
50 { .bitrate = 20, .hw_value = 1, },
51 { .bitrate = 55, .hw_value = 2, },
52 { .bitrate = 110, .hw_value = 3, },
53 { .bitrate = 60, .hw_value = 4, },
54 { .bitrate = 90, .hw_value = 5, },
55 { .bitrate = 120, .hw_value = 6, },
56 { .bitrate = 180, .hw_value = 7, },
57 { .bitrate = 240, .hw_value = 8, },
58 { .bitrate = 360, .hw_value = 9, },
59 { .bitrate = 480, .hw_value = 10, },
60 { .bitrate = 540, .hw_value = 11, },
61};
62
63static const struct ieee80211_channel rtl818x_channels[] = {
64 { .center_freq = 2412 },
65 { .center_freq = 2417 },
66 { .center_freq = 2422 },
67 { .center_freq = 2427 },
68 { .center_freq = 2432 },
69 { .center_freq = 2437 },
70 { .center_freq = 2442 },
71 { .center_freq = 2447 },
72 { .center_freq = 2452 },
73 { .center_freq = 2457 },
74 { .center_freq = 2462 },
75 { .center_freq = 2467 },
76 { .center_freq = 2472 },
77 { .center_freq = 2484 },
78};
79
48static void rtl8187_iowrite_async_cb(struct urb *urb) 80static void rtl8187_iowrite_async_cb(struct urb *urb)
49{ 81{
50 kfree(urb->context); 82 kfree(urb->context);
@@ -146,17 +178,23 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb,
146 178
147 flags = skb->len; 179 flags = skb->len;
148 flags |= RTL8187_TX_FLAG_NO_ENCRYPT; 180 flags |= RTL8187_TX_FLAG_NO_ENCRYPT;
149 flags |= control->rts_cts_rate << 19; 181
150 flags |= control->tx_rate << 24; 182 BUG_ON(!control->tx_rate);
183
184 flags |= control->tx_rate->hw_value << 24;
151 if (ieee80211_get_morefrag((struct ieee80211_hdr *)skb->data)) 185 if (ieee80211_get_morefrag((struct ieee80211_hdr *)skb->data))
152 flags |= RTL8187_TX_FLAG_MORE_FRAG; 186 flags |= RTL8187_TX_FLAG_MORE_FRAG;
153 if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) { 187 if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) {
188 BUG_ON(!control->rts_cts_rate);
154 flags |= RTL8187_TX_FLAG_RTS; 189 flags |= RTL8187_TX_FLAG_RTS;
190 flags |= control->rts_cts_rate->hw_value << 19;
155 rts_dur = ieee80211_rts_duration(dev, priv->vif, 191 rts_dur = ieee80211_rts_duration(dev, priv->vif,
156 skb->len, control); 192 skb->len, control);
157 } 193 } else if (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) {
158 if (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) 194 BUG_ON(!control->rts_cts_rate);
159 flags |= RTL8187_TX_FLAG_CTS; 195 flags |= RTL8187_TX_FLAG_CTS;
196 flags |= control->rts_cts_rate->hw_value << 19;
197 }
160 198
161 hdr = (struct rtl8187_tx_hdr *)skb_push(skb, sizeof(*hdr)); 199 hdr = (struct rtl8187_tx_hdr *)skb_push(skb, sizeof(*hdr));
162 hdr->flags = cpu_to_le32(flags); 200 hdr->flags = cpu_to_le32(flags);
@@ -225,10 +263,9 @@ static void rtl8187_rx_cb(struct urb *urb)
225 rx_status.antenna = (hdr->signal >> 7) & 1; 263 rx_status.antenna = (hdr->signal >> 7) & 1;
226 rx_status.signal = 64 - min(hdr->noise, (u8)64); 264 rx_status.signal = 64 - min(hdr->noise, (u8)64);
227 rx_status.ssi = signal; 265 rx_status.ssi = signal;
228 rx_status.rate = rate; 266 rx_status.rate_idx = rate;
229 rx_status.freq = dev->conf.freq; 267 rx_status.freq = dev->conf.channel->center_freq;
230 rx_status.channel = dev->conf.channel; 268 rx_status.band = dev->conf.channel->band;
231 rx_status.phymode = dev->conf.phymode;
232 rx_status.mactime = le64_to_cpu(hdr->mac_time); 269 rx_status.mactime = le64_to_cpu(hdr->mac_time);
233 rx_status.flag |= RX_FLAG_TSFT; 270 rx_status.flag |= RX_FLAG_TSFT;
234 if (flags & (1 << 13)) 271 if (flags & (1 << 13))
@@ -685,19 +722,22 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
685 usb_get_dev(udev); 722 usb_get_dev(udev);
686 723
687 skb_queue_head_init(&priv->rx_queue); 724 skb_queue_head_init(&priv->rx_queue);
725
726 BUILD_BUG_ON(sizeof(priv->channels) != sizeof(rtl818x_channels));
727 BUILD_BUG_ON(sizeof(priv->rates) != sizeof(rtl818x_rates));
728
688 memcpy(priv->channels, rtl818x_channels, sizeof(rtl818x_channels)); 729 memcpy(priv->channels, rtl818x_channels, sizeof(rtl818x_channels));
689 memcpy(priv->rates, rtl818x_rates, sizeof(rtl818x_rates)); 730 memcpy(priv->rates, rtl818x_rates, sizeof(rtl818x_rates));
690 priv->map = (struct rtl818x_csr *)0xFF00; 731 priv->map = (struct rtl818x_csr *)0xFF00;
691 priv->modes[0].mode = MODE_IEEE80211G; 732
692 priv->modes[0].num_rates = ARRAY_SIZE(rtl818x_rates); 733 priv->band.band = IEEE80211_BAND_2GHZ;
693 priv->modes[0].rates = priv->rates; 734 priv->band.channels = priv->channels;
694 priv->modes[0].num_channels = ARRAY_SIZE(rtl818x_channels); 735 priv->band.n_channels = ARRAY_SIZE(rtl818x_channels);
695 priv->modes[0].channels = priv->channels; 736 priv->band.bitrates = priv->rates;
696 priv->modes[1].mode = MODE_IEEE80211B; 737 priv->band.n_bitrates = ARRAY_SIZE(rtl818x_rates);
697 priv->modes[1].num_rates = 4; 738 dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band;
698 priv->modes[1].rates = priv->rates; 739
699 priv->modes[1].num_channels = ARRAY_SIZE(rtl818x_channels); 740
700 priv->modes[1].channels = priv->channels;
701 priv->mode = IEEE80211_IF_TYPE_MNTR; 741 priv->mode = IEEE80211_IF_TYPE_MNTR;
702 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 742 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
703 IEEE80211_HW_RX_INCLUDES_FCS; 743 IEEE80211_HW_RX_INCLUDES_FCS;
@@ -706,10 +746,6 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
706 dev->max_rssi = 65; 746 dev->max_rssi = 65;
707 dev->max_signal = 64; 747 dev->max_signal = 64;
708 748
709 for (i = 0; i < 2; i++)
710 if ((err = ieee80211_register_hwmode(dev, &priv->modes[i])))
711 goto err_free_dev;
712
713 eeprom.data = dev; 749 eeprom.data = dev;
714 eeprom.register_read = rtl8187_eeprom_register_read; 750 eeprom.register_read = rtl8187_eeprom_register_read;
715 eeprom.register_write = rtl8187_eeprom_register_write; 751 eeprom.register_write = rtl8187_eeprom_register_write;
@@ -733,20 +769,20 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
733 for (i = 0; i < 3; i++) { 769 for (i = 0; i < 3; i++) {
734 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_CHAN_1 + i, 770 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_CHAN_1 + i,
735 &txpwr); 771 &txpwr);
736 (*channel++).val = txpwr & 0xFF; 772 (*channel++).hw_value = txpwr & 0xFF;
737 (*channel++).val = txpwr >> 8; 773 (*channel++).hw_value = txpwr >> 8;
738 } 774 }
739 for (i = 0; i < 2; i++) { 775 for (i = 0; i < 2; i++) {
740 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_CHAN_4 + i, 776 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_CHAN_4 + i,
741 &txpwr); 777 &txpwr);
742 (*channel++).val = txpwr & 0xFF; 778 (*channel++).hw_value = txpwr & 0xFF;
743 (*channel++).val = txpwr >> 8; 779 (*channel++).hw_value = txpwr >> 8;
744 } 780 }
745 for (i = 0; i < 2; i++) { 781 for (i = 0; i < 2; i++) {
746 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_CHAN_6 + i, 782 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_CHAN_6 + i,
747 &txpwr); 783 &txpwr);
748 (*channel++).val = txpwr & 0xFF; 784 (*channel++).hw_value = txpwr & 0xFF;
749 (*channel++).val = txpwr >> 8; 785 (*channel++).hw_value = txpwr >> 8;
750 } 786 }
751 787
752 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_BASE, 788 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_BASE,