aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rtl8180_dev.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/rtl8180_dev.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/rtl8180_dev.c')
-rw-r--r--drivers/net/wireless/rtl8180_dev.c93
1 files changed, 62 insertions, 31 deletions
diff --git a/drivers/net/wireless/rtl8180_dev.c b/drivers/net/wireless/rtl8180_dev.c
index 5e9a8ace0d81..d0928c91c21c 100644
--- a/drivers/net/wireless/rtl8180_dev.c
+++ b/drivers/net/wireless/rtl8180_dev.c
@@ -49,6 +49,41 @@ static struct pci_device_id rtl8180_table[] __devinitdata = {
49 49
50MODULE_DEVICE_TABLE(pci, rtl8180_table); 50MODULE_DEVICE_TABLE(pci, rtl8180_table);
51 51
52static const struct ieee80211_rate rtl818x_rates[] = {
53 { .bitrate = 10, .hw_value = 0, },
54 { .bitrate = 20, .hw_value = 1, },
55 { .bitrate = 55, .hw_value = 2, },
56 { .bitrate = 110, .hw_value = 3, },
57 { .bitrate = 60, .hw_value = 4, },
58 { .bitrate = 90, .hw_value = 5, },
59 { .bitrate = 120, .hw_value = 6, },
60 { .bitrate = 180, .hw_value = 7, },
61 { .bitrate = 240, .hw_value = 8, },
62 { .bitrate = 360, .hw_value = 9, },
63 { .bitrate = 480, .hw_value = 10, },
64 { .bitrate = 540, .hw_value = 11, },
65};
66
67static const struct ieee80211_channel rtl818x_channels[] = {
68 { .center_freq = 2412 },
69 { .center_freq = 2417 },
70 { .center_freq = 2422 },
71 { .center_freq = 2427 },
72 { .center_freq = 2432 },
73 { .center_freq = 2437 },
74 { .center_freq = 2442 },
75 { .center_freq = 2447 },
76 { .center_freq = 2452 },
77 { .center_freq = 2457 },
78 { .center_freq = 2462 },
79 { .center_freq = 2467 },
80 { .center_freq = 2472 },
81 { .center_freq = 2484 },
82};
83
84
85
86
52void rtl8180_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data) 87void rtl8180_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data)
53{ 88{
54 struct rtl8180_priv *priv = dev->priv; 89 struct rtl8180_priv *priv = dev->priv;
@@ -99,10 +134,10 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev)
99 /* TODO: improve signal/rssi reporting */ 134 /* TODO: improve signal/rssi reporting */
100 rx_status.signal = flags2 & 0xFF; 135 rx_status.signal = flags2 & 0xFF;
101 rx_status.ssi = (flags2 >> 8) & 0x7F; 136 rx_status.ssi = (flags2 >> 8) & 0x7F;
102 rx_status.rate = (flags >> 20) & 0xF; 137 /* XXX: is this correct? */
103 rx_status.freq = dev->conf.freq; 138 rx_status.rate_idx = (flags >> 20) & 0xF;
104 rx_status.channel = dev->conf.channel; 139 rx_status.freq = dev->conf.channel->center_freq;
105 rx_status.phymode = dev->conf.phymode; 140 rx_status.band = dev->conf.channel->band;
106 rx_status.mactime = le64_to_cpu(entry->tsft); 141 rx_status.mactime = le64_to_cpu(entry->tsft);
107 rx_status.flag |= RX_FLAG_TSFT; 142 rx_status.flag |= RX_FLAG_TSFT;
108 if (flags & RTL8180_RX_DESC_FLAG_CRC32_ERR) 143 if (flags & RTL8180_RX_DESC_FLAG_CRC32_ERR)
@@ -223,8 +258,9 @@ static int rtl8180_tx(struct ieee80211_hw *dev, struct sk_buff *skb,
223 skb->len, PCI_DMA_TODEVICE); 258 skb->len, PCI_DMA_TODEVICE);
224 259
225 tx_flags = RTL8180_TX_DESC_FLAG_OWN | RTL8180_TX_DESC_FLAG_FS | 260 tx_flags = RTL8180_TX_DESC_FLAG_OWN | RTL8180_TX_DESC_FLAG_FS |
226 RTL8180_TX_DESC_FLAG_LS | (control->tx_rate << 24) | 261 RTL8180_TX_DESC_FLAG_LS |
227 (control->rts_cts_rate << 19) | skb->len; 262 (control->tx_rate->hw_value << 24) |
263 (control->rts_cts_rate->hw_value << 19) | skb->len;
228 264
229 if (priv->r8185) 265 if (priv->r8185)
230 tx_flags |= RTL8180_TX_DESC_FLAG_DMA | 266 tx_flags |= RTL8180_TX_DESC_FLAG_DMA |
@@ -246,9 +282,9 @@ static int rtl8180_tx(struct ieee80211_hw *dev, struct sk_buff *skb,
246 unsigned int remainder; 282 unsigned int remainder;
247 283
248 plcp_len = DIV_ROUND_UP(16 * (skb->len + 4), 284 plcp_len = DIV_ROUND_UP(16 * (skb->len + 4),
249 (control->rate->rate * 2) / 10); 285 (control->tx_rate->bitrate * 2) / 10);
250 remainder = (16 * (skb->len + 4)) % 286 remainder = (16 * (skb->len + 4)) %
251 ((control->rate->rate * 2) / 10); 287 ((control->tx_rate->bitrate * 2) / 10);
252 if (remainder > 0 && remainder <= 6) 288 if (remainder > 0 && remainder <= 6)
253 plcp_len |= 1 << 15; 289 plcp_len |= 1 << 15;
254 } 290 }
@@ -261,8 +297,8 @@ static int rtl8180_tx(struct ieee80211_hw *dev, struct sk_buff *skb,
261 entry->plcp_len = cpu_to_le16(plcp_len); 297 entry->plcp_len = cpu_to_le16(plcp_len);
262 entry->tx_buf = cpu_to_le32(mapping); 298 entry->tx_buf = cpu_to_le32(mapping);
263 entry->frame_len = cpu_to_le32(skb->len); 299 entry->frame_len = cpu_to_le32(skb->len);
264 entry->flags2 = control->alt_retry_rate != -1 ? 300 entry->flags2 = control->alt_retry_rate != NULL ?
265 control->alt_retry_rate << 4 : 0; 301 control->alt_retry_rate->bitrate << 4 : 0;
266 entry->retry_limit = control->retry_limit; 302 entry->retry_limit = control->retry_limit;
267 entry->flags = cpu_to_le32(tx_flags); 303 entry->flags = cpu_to_le32(tx_flags);
268 __skb_queue_tail(&ring->queue, skb); 304 __skb_queue_tail(&ring->queue, skb);
@@ -838,19 +874,19 @@ static int __devinit rtl8180_probe(struct pci_dev *pdev,
838 goto err_free_dev; 874 goto err_free_dev;
839 } 875 }
840 876
877 BUILD_BUG_ON(sizeof(priv->channels) != sizeof(rtl818x_channels));
878 BUILD_BUG_ON(sizeof(priv->rates) != sizeof(rtl818x_rates));
879
841 memcpy(priv->channels, rtl818x_channels, sizeof(rtl818x_channels)); 880 memcpy(priv->channels, rtl818x_channels, sizeof(rtl818x_channels));
842 memcpy(priv->rates, rtl818x_rates, sizeof(rtl818x_rates)); 881 memcpy(priv->rates, rtl818x_rates, sizeof(rtl818x_rates));
843 priv->modes[0].mode = MODE_IEEE80211G; 882
844 priv->modes[0].num_rates = ARRAY_SIZE(rtl818x_rates); 883 priv->band.band = IEEE80211_BAND_2GHZ;
845 priv->modes[0].rates = priv->rates; 884 priv->band.channels = priv->channels;
846 priv->modes[0].num_channels = ARRAY_SIZE(rtl818x_channels); 885 priv->band.n_channels = ARRAY_SIZE(rtl818x_channels);
847 priv->modes[0].channels = priv->channels; 886 priv->band.bitrates = priv->rates;
848 priv->modes[1].mode = MODE_IEEE80211B; 887 priv->band.n_bitrates = 4;
849 priv->modes[1].num_rates = 4; 888 dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band;
850 priv->modes[1].rates = priv->rates; 889
851 priv->modes[1].num_channels = ARRAY_SIZE(rtl818x_channels);
852 priv->modes[1].channels = priv->channels;
853 priv->mode = IEEE80211_IF_TYPE_INVALID;
854 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 890 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
855 IEEE80211_HW_RX_INCLUDES_FCS; 891 IEEE80211_HW_RX_INCLUDES_FCS;
856 dev->queues = 1; 892 dev->queues = 1;
@@ -879,15 +915,10 @@ static int __devinit rtl8180_probe(struct pci_dev *pdev,
879 915
880 priv->r8185 = reg & RTL818X_TX_CONF_R8185_ABC; 916 priv->r8185 = reg & RTL818X_TX_CONF_R8185_ABC;
881 if (priv->r8185) { 917 if (priv->r8185) {
882 if ((err = ieee80211_register_hwmode(dev, &priv->modes[0]))) 918 priv->band.n_bitrates = ARRAY_SIZE(rtl818x_rates);
883 goto err_iounmap;
884
885 pci_try_set_mwi(pdev); 919 pci_try_set_mwi(pdev);
886 } 920 }
887 921
888 if ((err = ieee80211_register_hwmode(dev, &priv->modes[1])))
889 goto err_iounmap;
890
891 eeprom.data = dev; 922 eeprom.data = dev;
892 eeprom.register_read = rtl8180_eeprom_register_read; 923 eeprom.register_read = rtl8180_eeprom_register_read;
893 eeprom.register_write = rtl8180_eeprom_register_write; 924 eeprom.register_write = rtl8180_eeprom_register_write;
@@ -950,8 +981,8 @@ static int __devinit rtl8180_probe(struct pci_dev *pdev,
950 for (i = 0; i < 14; i += 2) { 981 for (i = 0; i < 14; i += 2) {
951 u16 txpwr; 982 u16 txpwr;
952 eeprom_93cx6_read(&eeprom, 0x10 + (i >> 1), &txpwr); 983 eeprom_93cx6_read(&eeprom, 0x10 + (i >> 1), &txpwr);
953 priv->channels[i].val = txpwr & 0xFF; 984 priv->channels[i].hw_value = txpwr & 0xFF;
954 priv->channels[i + 1].val = txpwr >> 8; 985 priv->channels[i + 1].hw_value = txpwr >> 8;
955 } 986 }
956 987
957 /* OFDM TX power */ 988 /* OFDM TX power */
@@ -959,8 +990,8 @@ static int __devinit rtl8180_probe(struct pci_dev *pdev,
959 for (i = 0; i < 14; i += 2) { 990 for (i = 0; i < 14; i += 2) {
960 u16 txpwr; 991 u16 txpwr;
961 eeprom_93cx6_read(&eeprom, 0x20 + (i >> 1), &txpwr); 992 eeprom_93cx6_read(&eeprom, 0x20 + (i >> 1), &txpwr);
962 priv->channels[i].val |= (txpwr & 0xFF) << 8; 993 priv->channels[i].hw_value |= (txpwr & 0xFF) << 8;
963 priv->channels[i + 1].val |= txpwr & 0xFF00; 994 priv->channels[i + 1].hw_value |= txpwr & 0xFF00;
964 } 995 }
965 } 996 }
966 997