aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/orinoco/main.c
diff options
context:
space:
mode:
authorDavid Kilroy <kilroyd@googlemail.com>2009-06-18 18:21:26 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-07-10 15:01:44 -0400
commitea60a6aaf55984a13a7150568cc103d006e86ab2 (patch)
tree1c6b80d7d6a2129fe33591508ac125b65100fa09 /drivers/net/wireless/orinoco/main.c
parent98e5f404485d5d11b15e8351535a0e064a37647c (diff)
orinoco: initiate cfg80211 conversion
Initialise and register a wiphy. Store the orinoco_private structure in the new wiphy, and use the net_device private area to store the wireless_dev. This results in a change to the way we navigate from a net_device to the driver private orinoco_private, which we encapsulate in the inline function ndev_priv. Most of the remaining calls to netdev_priv are thus replaced by ndev_priv. We can immediately rely on cfg80211 to handle SIOCGIWNAME, so orinoco_ioctl_getname is removed. Signed-off-by: David Kilroy <kilroyd@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/orinoco/main.c')
-rw-r--r--drivers/net/wireless/orinoco/main.c108
1 files changed, 84 insertions, 24 deletions
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c
index ff869a25024d..5c1cf648002a 100644
--- a/drivers/net/wireless/orinoco/main.c
+++ b/drivers/net/wireless/orinoco/main.c
@@ -89,6 +89,7 @@
89#include <linux/wireless.h> 89#include <linux/wireless.h>
90#include <linux/ieee80211.h> 90#include <linux/ieee80211.h>
91#include <net/iw_handler.h> 91#include <net/iw_handler.h>
92#include <net/cfg80211.h>
92 93
93#include "hermes_rid.h" 94#include "hermes_rid.h"
94#include "hermes_dld.h" 95#include "hermes_dld.h"
@@ -97,6 +98,7 @@
97#include "mic.h" 98#include "mic.h"
98#include "fw.h" 99#include "fw.h"
99#include "wext.h" 100#include "wext.h"
101#include "cfg.h"
100#include "main.h" 102#include "main.h"
101 103
102#include "orinoco.h" 104#include "orinoco.h"
@@ -246,7 +248,7 @@ void set_port_type(struct orinoco_private *priv)
246 248
247static int orinoco_open(struct net_device *dev) 249static int orinoco_open(struct net_device *dev)
248{ 250{
249 struct orinoco_private *priv = netdev_priv(dev); 251 struct orinoco_private *priv = ndev_priv(dev);
250 unsigned long flags; 252 unsigned long flags;
251 int err; 253 int err;
252 254
@@ -265,7 +267,7 @@ static int orinoco_open(struct net_device *dev)
265 267
266static int orinoco_stop(struct net_device *dev) 268static int orinoco_stop(struct net_device *dev)
267{ 269{
268 struct orinoco_private *priv = netdev_priv(dev); 270 struct orinoco_private *priv = ndev_priv(dev);
269 int err = 0; 271 int err = 0;
270 272
271 /* We mustn't use orinoco_lock() here, because we need to be 273 /* We mustn't use orinoco_lock() here, because we need to be
@@ -284,14 +286,14 @@ static int orinoco_stop(struct net_device *dev)
284 286
285static struct net_device_stats *orinoco_get_stats(struct net_device *dev) 287static struct net_device_stats *orinoco_get_stats(struct net_device *dev)
286{ 288{
287 struct orinoco_private *priv = netdev_priv(dev); 289 struct orinoco_private *priv = ndev_priv(dev);
288 290
289 return &priv->stats; 291 return &priv->stats;
290} 292}
291 293
292static void orinoco_set_multicast_list(struct net_device *dev) 294static void orinoco_set_multicast_list(struct net_device *dev)
293{ 295{
294 struct orinoco_private *priv = netdev_priv(dev); 296 struct orinoco_private *priv = ndev_priv(dev);
295 unsigned long flags; 297 unsigned long flags;
296 298
297 if (orinoco_lock(priv, &flags) != 0) { 299 if (orinoco_lock(priv, &flags) != 0) {
@@ -306,7 +308,7 @@ static void orinoco_set_multicast_list(struct net_device *dev)
306 308
307static int orinoco_change_mtu(struct net_device *dev, int new_mtu) 309static int orinoco_change_mtu(struct net_device *dev, int new_mtu)
308{ 310{
309 struct orinoco_private *priv = netdev_priv(dev); 311 struct orinoco_private *priv = ndev_priv(dev);
310 312
311 if ((new_mtu < ORINOCO_MIN_MTU) || (new_mtu > ORINOCO_MAX_MTU)) 313 if ((new_mtu < ORINOCO_MIN_MTU) || (new_mtu > ORINOCO_MAX_MTU))
312 return -EINVAL; 314 return -EINVAL;
@@ -327,7 +329,7 @@ static int orinoco_change_mtu(struct net_device *dev, int new_mtu)
327 329
328static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev) 330static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
329{ 331{
330 struct orinoco_private *priv = netdev_priv(dev); 332 struct orinoco_private *priv = ndev_priv(dev);
331 struct net_device_stats *stats = &priv->stats; 333 struct net_device_stats *stats = &priv->stats;
332 hermes_t *hw = &priv->hw; 334 hermes_t *hw = &priv->hw;
333 int err = 0; 335 int err = 0;
@@ -517,7 +519,7 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
517 519
518static void __orinoco_ev_alloc(struct net_device *dev, hermes_t *hw) 520static void __orinoco_ev_alloc(struct net_device *dev, hermes_t *hw)
519{ 521{
520 struct orinoco_private *priv = netdev_priv(dev); 522 struct orinoco_private *priv = ndev_priv(dev);
521 u16 fid = hermes_read_regn(hw, ALLOCFID); 523 u16 fid = hermes_read_regn(hw, ALLOCFID);
522 524
523 if (fid != priv->txfid) { 525 if (fid != priv->txfid) {
@@ -532,7 +534,7 @@ static void __orinoco_ev_alloc(struct net_device *dev, hermes_t *hw)
532 534
533static void __orinoco_ev_tx(struct net_device *dev, hermes_t *hw) 535static void __orinoco_ev_tx(struct net_device *dev, hermes_t *hw)
534{ 536{
535 struct orinoco_private *priv = netdev_priv(dev); 537 struct orinoco_private *priv = ndev_priv(dev);
536 struct net_device_stats *stats = &priv->stats; 538 struct net_device_stats *stats = &priv->stats;
537 539
538 stats->tx_packets++; 540 stats->tx_packets++;
@@ -544,7 +546,7 @@ static void __orinoco_ev_tx(struct net_device *dev, hermes_t *hw)
544 546
545static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw) 547static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw)
546{ 548{
547 struct orinoco_private *priv = netdev_priv(dev); 549 struct orinoco_private *priv = ndev_priv(dev);
548 struct net_device_stats *stats = &priv->stats; 550 struct net_device_stats *stats = &priv->stats;
549 u16 fid = hermes_read_regn(hw, TXCOMPLFID); 551 u16 fid = hermes_read_regn(hw, TXCOMPLFID);
550 u16 status; 552 u16 status;
@@ -600,7 +602,7 @@ static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw)
600 602
601static void orinoco_tx_timeout(struct net_device *dev) 603static void orinoco_tx_timeout(struct net_device *dev)
602{ 604{
603 struct orinoco_private *priv = netdev_priv(dev); 605 struct orinoco_private *priv = ndev_priv(dev);
604 struct net_device_stats *stats = &priv->stats; 606 struct net_device_stats *stats = &priv->stats;
605 struct hermes *hw = &priv->hw; 607 struct hermes *hw = &priv->hw;
606 608
@@ -649,7 +651,7 @@ static void orinoco_stat_gather(struct net_device *dev,
649 struct sk_buff *skb, 651 struct sk_buff *skb,
650 struct hermes_rx_descriptor *desc) 652 struct hermes_rx_descriptor *desc)
651{ 653{
652 struct orinoco_private *priv = netdev_priv(dev); 654 struct orinoco_private *priv = ndev_priv(dev);
653 655
654 /* Using spy support with lots of Rx packets, like in an 656 /* Using spy support with lots of Rx packets, like in an
655 * infrastructure (AP), will really slow down everything, because 657 * infrastructure (AP), will really slow down everything, because
@@ -686,7 +688,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
686 int err; 688 int err;
687 int len; 689 int len;
688 struct sk_buff *skb; 690 struct sk_buff *skb;
689 struct orinoco_private *priv = netdev_priv(dev); 691 struct orinoco_private *priv = ndev_priv(dev);
690 struct net_device_stats *stats = &priv->stats; 692 struct net_device_stats *stats = &priv->stats;
691 hermes_t *hw = &priv->hw; 693 hermes_t *hw = &priv->hw;
692 694
@@ -777,7 +779,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
777 779
778static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw) 780static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
779{ 781{
780 struct orinoco_private *priv = netdev_priv(dev); 782 struct orinoco_private *priv = ndev_priv(dev);
781 struct net_device_stats *stats = &priv->stats; 783 struct net_device_stats *stats = &priv->stats;
782 struct iw_statistics *wstats = &priv->wstats; 784 struct iw_statistics *wstats = &priv->wstats;
783 struct sk_buff *skb = NULL; 785 struct sk_buff *skb = NULL;
@@ -901,7 +903,7 @@ static void orinoco_rx(struct net_device *dev,
901 struct hermes_rx_descriptor *desc, 903 struct hermes_rx_descriptor *desc,
902 struct sk_buff *skb) 904 struct sk_buff *skb)
903{ 905{
904 struct orinoco_private *priv = netdev_priv(dev); 906 struct orinoco_private *priv = ndev_priv(dev);
905 struct net_device_stats *stats = &priv->stats; 907 struct net_device_stats *stats = &priv->stats;
906 u16 status, fc; 908 u16 status, fc;
907 int length; 909 int length;
@@ -1016,7 +1018,7 @@ static void orinoco_rx(struct net_device *dev,
1016static void orinoco_rx_isr_tasklet(unsigned long data) 1018static void orinoco_rx_isr_tasklet(unsigned long data)
1017{ 1019{
1018 struct net_device *dev = (struct net_device *) data; 1020 struct net_device *dev = (struct net_device *) data;
1019 struct orinoco_private *priv = netdev_priv(dev); 1021 struct orinoco_private *priv = ndev_priv(dev);
1020 struct orinoco_rx_data *rx_data, *temp; 1022 struct orinoco_rx_data *rx_data, *temp;
1021 struct hermes_rx_descriptor *desc; 1023 struct hermes_rx_descriptor *desc;
1022 struct sk_buff *skb; 1024 struct sk_buff *skb;
@@ -1261,7 +1263,7 @@ static void orinoco_send_wevents(struct work_struct *work)
1261 1263
1262static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw) 1264static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1263{ 1265{
1264 struct orinoco_private *priv = netdev_priv(dev); 1266 struct orinoco_private *priv = ndev_priv(dev);
1265 u16 infofid; 1267 u16 infofid;
1266 struct { 1268 struct {
1267 __le16 len; 1269 __le16 len;
@@ -1594,7 +1596,7 @@ EXPORT_SYMBOL(orinoco_reinit_firmware);
1594 1596
1595int __orinoco_program_rids(struct net_device *dev) 1597int __orinoco_program_rids(struct net_device *dev)
1596{ 1598{
1597 struct orinoco_private *priv = netdev_priv(dev); 1599 struct orinoco_private *priv = ndev_priv(dev);
1598 hermes_t *hw = &priv->hw; 1600 hermes_t *hw = &priv->hw;
1599 int err; 1601 int err;
1600 struct hermes_idstring idbuf; 1602 struct hermes_idstring idbuf;
@@ -1825,7 +1827,7 @@ int __orinoco_program_rids(struct net_device *dev)
1825static void 1827static void
1826__orinoco_set_multicast_list(struct net_device *dev) 1828__orinoco_set_multicast_list(struct net_device *dev)
1827{ 1829{
1828 struct orinoco_private *priv = netdev_priv(dev); 1830 struct orinoco_private *priv = ndev_priv(dev);
1829 int err = 0; 1831 int err = 0;
1830 int promisc, mc_count; 1832 int promisc, mc_count;
1831 1833
@@ -2077,6 +2079,7 @@ static void orinoco_unregister_pm_notifier(struct orinoco_private *priv)
2077int orinoco_init(struct orinoco_private *priv) 2079int orinoco_init(struct orinoco_private *priv)
2078{ 2080{
2079 struct device *dev = priv->dev; 2081 struct device *dev = priv->dev;
2082 struct wiphy *wiphy = priv_to_wiphy(priv);
2080 hermes_t *hw = &priv->hw; 2083 hermes_t *hw = &priv->hw;
2081 int err = 0; 2084 int err = 0;
2082 2085
@@ -2137,10 +2140,10 @@ int orinoco_init(struct orinoco_private *priv)
2137 goto out; 2140 goto out;
2138 orinoco_bss_data_init(priv); 2141 orinoco_bss_data_init(priv);
2139 2142
2140 /* Netdev has not initialised, but we have allocated the buffer. */ 2143 err = orinoco_hw_read_card_settings(priv, wiphy->perm_addr);
2141 err = orinoco_hw_read_card_settings(priv, priv->ndev->dev_addr);
2142 if (err) 2144 if (err)
2143 goto out; 2145 goto out;
2146 memcpy(priv->ndev->dev_addr, wiphy->perm_addr, ETH_ALEN);
2144 2147
2145 err = orinoco_hw_allocate_fid(priv); 2148 err = orinoco_hw_allocate_fid(priv);
2146 if (err) { 2149 if (err) {
@@ -2164,6 +2167,11 @@ int orinoco_init(struct orinoco_private *priv)
2164 priv->wpa_ie_len = 0; 2167 priv->wpa_ie_len = 0;
2165 priv->wpa_ie = NULL; 2168 priv->wpa_ie = NULL;
2166 2169
2170 if (orinoco_wiphy_register(wiphy)) {
2171 err = -ENODEV;
2172 goto out;
2173 }
2174
2167 /* Make the hardware available, as long as it hasn't been 2175 /* Make the hardware available, as long as it hasn't been
2168 * removed elsewhere (e.g. by PCMCIA hot unplug) */ 2176 * removed elsewhere (e.g. by PCMCIA hot unplug) */
2169 spin_lock_irq(&priv->lock); 2177 spin_lock_irq(&priv->lock);
@@ -2187,6 +2195,31 @@ static const struct net_device_ops orinoco_netdev_ops = {
2187 .ndo_get_stats = orinoco_get_stats, 2195 .ndo_get_stats = orinoco_get_stats,
2188}; 2196};
2189 2197
2198/* Allocate private data.
2199 *
2200 * This driver has a number of structures associated with it
2201 * netdev - Net device structure for each network interface
2202 * wiphy - structure associated with wireless phy
2203 * wireless_dev (wdev) - structure for each wireless interface
2204 * hw - structure for hermes chip info
2205 * card - card specific structure for use by the card driver
2206 * (airport, orinoco_cs)
2207 * priv - orinoco private data
2208 * device - generic linux device structure
2209 *
2210 * +---------+ +---------+
2211 * | wiphy | | netdev |
2212 * | +-------+ | +-------+
2213 * | | priv | | | wdev |
2214 * | | +-----+ +-+-------+
2215 * | | | hw |
2216 * | +-+-----+
2217 * | | card |
2218 * +-+-------+
2219 *
2220 * priv has a link to netdev and device
2221 * wdev has a link to wiphy
2222 */
2190struct orinoco_private 2223struct orinoco_private
2191*alloc_orinocodev(int sizeof_card, 2224*alloc_orinocodev(int sizeof_card,
2192 struct device *device, 2225 struct device *device,
@@ -2195,12 +2228,27 @@ struct orinoco_private
2195{ 2228{
2196 struct net_device *dev; 2229 struct net_device *dev;
2197 struct orinoco_private *priv; 2230 struct orinoco_private *priv;
2231 struct wireless_dev *wdev;
2232 struct wiphy *wiphy;
2233
2234 /* allocate wiphy
2235 * NOTE: We only support a single virtual interface
2236 * but this may change when monitor mode is added
2237 */
2238 wiphy = wiphy_new(&orinoco_cfg_ops,
2239 sizeof(struct orinoco_private) + sizeof_card);
2240 if (!wiphy)
2241 return NULL;
2198 2242
2199 dev = alloc_etherdev(sizeof(struct orinoco_private) + sizeof_card); 2243 dev = alloc_etherdev(sizeof(struct wireless_dev));
2200 if (!dev) 2244 if (!dev) {
2245 wiphy_free(wiphy);
2201 return NULL; 2246 return NULL;
2202 priv = netdev_priv(dev); 2247 }
2248
2249 priv = wiphy_priv(wiphy);
2203 priv->ndev = dev; 2250 priv->ndev = dev;
2251
2204 if (sizeof_card) 2252 if (sizeof_card)
2205 priv->card = (void *)((unsigned long)priv 2253 priv->card = (void *)((unsigned long)priv
2206 + sizeof(struct orinoco_private)); 2254 + sizeof(struct orinoco_private));
@@ -2208,7 +2256,15 @@ struct orinoco_private
2208 priv->card = NULL; 2256 priv->card = NULL;
2209 priv->dev = device; 2257 priv->dev = device;
2210 2258
2259 orinoco_wiphy_init(wiphy);
2260
2261 /* Initialise wireless_dev */
2262 wdev = netdev_priv(dev);
2263 wdev->wiphy = wiphy;
2264 wdev->iftype = NL80211_IFTYPE_STATION;
2265
2211 /* Setup / override net_device fields */ 2266 /* Setup / override net_device fields */
2267 dev->ieee80211_ptr = wdev;
2212 dev->netdev_ops = &orinoco_netdev_ops; 2268 dev->netdev_ops = &orinoco_netdev_ops;
2213 dev->watchdog_timeo = HZ; /* 1 second timeout */ 2269 dev->watchdog_timeo = HZ; /* 1 second timeout */
2214 dev->ethtool_ops = &orinoco_ethtool_ops; 2270 dev->ethtool_ops = &orinoco_ethtool_ops;
@@ -2257,8 +2313,11 @@ EXPORT_SYMBOL(alloc_orinocodev);
2257void free_orinocodev(struct orinoco_private *priv) 2313void free_orinocodev(struct orinoco_private *priv)
2258{ 2314{
2259 struct net_device *dev = priv->ndev; 2315 struct net_device *dev = priv->ndev;
2316 struct wiphy *wiphy = priv_to_wiphy(priv);
2260 struct orinoco_rx_data *rx_data, *temp; 2317 struct orinoco_rx_data *rx_data, *temp;
2261 2318
2319 wiphy_unregister(wiphy);
2320
2262 /* If the tasklet is scheduled when we call tasklet_kill it 2321 /* If the tasklet is scheduled when we call tasklet_kill it
2263 * will run one final time. However the tasklet will only 2322 * will run one final time. However the tasklet will only
2264 * drain priv->rx_list if the hw is still available. */ 2323 * drain priv->rx_list if the hw is still available. */
@@ -2281,13 +2340,14 @@ void free_orinocodev(struct orinoco_private *priv)
2281 orinoco_mic_free(priv); 2340 orinoco_mic_free(priv);
2282 orinoco_bss_data_free(priv); 2341 orinoco_bss_data_free(priv);
2283 free_netdev(dev); 2342 free_netdev(dev);
2343 wiphy_free(wiphy);
2284} 2344}
2285EXPORT_SYMBOL(free_orinocodev); 2345EXPORT_SYMBOL(free_orinocodev);
2286 2346
2287static void orinoco_get_drvinfo(struct net_device *dev, 2347static void orinoco_get_drvinfo(struct net_device *dev,
2288 struct ethtool_drvinfo *info) 2348 struct ethtool_drvinfo *info)
2289{ 2349{
2290 struct orinoco_private *priv = netdev_priv(dev); 2350 struct orinoco_private *priv = ndev_priv(dev);
2291 2351
2292 strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1); 2352 strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1);
2293 strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1); 2353 strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1);