aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-07-27 06:01:53 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-07-29 15:46:20 -0400
commita9a11622c5c742c115fad371c0397ae86dd3bb67 (patch)
tree747d04a77d4411886befb5701322fa06da90a0fb
parent1f9298f96082692bdfe73af6fc2167f627f21647 (diff)
cfg80211: self-contained wext handling where possible
Finally! This is what you've all been waiting for! This patch makes cfg80211 take care of wext emulation _completely_ by itself, drivers that don't need things cfg80211 doesn't do yet don't even need to be aware of wireless extensions. This means we can also clean up mac80211's and iwm's Kconfig and make it possible to build them w/o wext now! RIP wext. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/iwmc3200wifi/Kconfig1
-rw-r--r--drivers/net/wireless/iwmc3200wifi/Makefile2
-rw-r--r--drivers/net/wireless/iwmc3200wifi/iwm.h2
-rw-r--r--drivers/net/wireless/iwmc3200wifi/netdev.c1
-rw-r--r--drivers/net/wireless/iwmc3200wifi/wext.c95
-rw-r--r--net/mac80211/Kconfig1
-rw-r--r--net/mac80211/Makefile1
-rw-r--r--net/mac80211/ieee80211_i.h4
-rw-r--r--net/mac80211/iface.c1
-rw-r--r--net/mac80211/scan.c1
-rw-r--r--net/mac80211/wext.c98
-rw-r--r--net/wireless/core.c3
-rw-r--r--net/wireless/mlme.c2
-rw-r--r--net/wireless/scan.c1
-rw-r--r--net/wireless/sme.c2
-rw-r--r--net/wireless/wext-compat.c40
-rw-r--r--net/wireless/wext-compat.h5
17 files changed, 54 insertions, 206 deletions
diff --git a/drivers/net/wireless/iwmc3200wifi/Kconfig b/drivers/net/wireless/iwmc3200wifi/Kconfig
index 030401d367d3..c62da435285a 100644
--- a/drivers/net/wireless/iwmc3200wifi/Kconfig
+++ b/drivers/net/wireless/iwmc3200wifi/Kconfig
@@ -2,7 +2,6 @@ config IWM
2 tristate "Intel Wireless Multicomm 3200 WiFi driver" 2 tristate "Intel Wireless Multicomm 3200 WiFi driver"
3 depends on MMC && WLAN_80211 && EXPERIMENTAL 3 depends on MMC && WLAN_80211 && EXPERIMENTAL
4 depends on CFG80211 4 depends on CFG80211
5 select WIRELESS_EXT
6 select FW_LOADER 5 select FW_LOADER
7 help 6 help
8 The Intel Wireless Multicomm 3200 hardware is a combo 7 The Intel Wireless Multicomm 3200 hardware is a combo
diff --git a/drivers/net/wireless/iwmc3200wifi/Makefile b/drivers/net/wireless/iwmc3200wifi/Makefile
index 927f022545c1..d34291b652d3 100644
--- a/drivers/net/wireless/iwmc3200wifi/Makefile
+++ b/drivers/net/wireless/iwmc3200wifi/Makefile
@@ -1,5 +1,5 @@
1obj-$(CONFIG_IWM) := iwmc3200wifi.o 1obj-$(CONFIG_IWM) := iwmc3200wifi.o
2iwmc3200wifi-objs += main.o netdev.o rx.o tx.o sdio.o hal.o fw.o 2iwmc3200wifi-objs += main.o netdev.o rx.o tx.o sdio.o hal.o fw.o
3iwmc3200wifi-objs += commands.o wext.o cfg80211.o eeprom.o 3iwmc3200wifi-objs += commands.o cfg80211.o eeprom.o
4 4
5iwmc3200wifi-$(CONFIG_IWM_DEBUG) += debugfs.o 5iwmc3200wifi-$(CONFIG_IWM_DEBUG) += debugfs.o
diff --git a/drivers/net/wireless/iwmc3200wifi/iwm.h b/drivers/net/wireless/iwmc3200wifi/iwm.h
index 2175a481d2f4..7a51bc340fda 100644
--- a/drivers/net/wireless/iwmc3200wifi/iwm.h
+++ b/drivers/net/wireless/iwmc3200wifi/iwm.h
@@ -306,8 +306,6 @@ static inline void *iwm_private(struct iwm_priv *iwm)
306#define skb_to_rx_info(s) ((struct iwm_rx_info *)(s->cb)) 306#define skb_to_rx_info(s) ((struct iwm_rx_info *)(s->cb))
307#define skb_to_tx_info(s) ((struct iwm_tx_info *)s->cb) 307#define skb_to_tx_info(s) ((struct iwm_tx_info *)s->cb)
308 308
309extern const struct iw_handler_def iwm_iw_handler_def;
310
311void *iwm_if_alloc(int sizeof_bus, struct device *dev, 309void *iwm_if_alloc(int sizeof_bus, struct device *dev,
312 struct iwm_if_ops *if_ops); 310 struct iwm_if_ops *if_ops);
313void iwm_if_free(struct iwm_priv *iwm); 311void iwm_if_free(struct iwm_priv *iwm);
diff --git a/drivers/net/wireless/iwmc3200wifi/netdev.c b/drivers/net/wireless/iwmc3200wifi/netdev.c
index 092d28ae56a0..30116d1b4489 100644
--- a/drivers/net/wireless/iwmc3200wifi/netdev.c
+++ b/drivers/net/wireless/iwmc3200wifi/netdev.c
@@ -123,7 +123,6 @@ void *iwm_if_alloc(int sizeof_bus, struct device *dev,
123 } 123 }
124 124
125 ndev->netdev_ops = &iwm_netdev_ops; 125 ndev->netdev_ops = &iwm_netdev_ops;
126 ndev->wireless_handlers = &iwm_iw_handler_def;
127 ndev->ieee80211_ptr = wdev; 126 ndev->ieee80211_ptr = wdev;
128 SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy)); 127 SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy));
129 wdev->netdev = ndev; 128 wdev->netdev = ndev;
diff --git a/drivers/net/wireless/iwmc3200wifi/wext.c b/drivers/net/wireless/iwmc3200wifi/wext.c
deleted file mode 100644
index 9196024a2890..000000000000
--- a/drivers/net/wireless/iwmc3200wifi/wext.c
+++ /dev/null
@@ -1,95 +0,0 @@
1/*
2 * Intel Wireless Multicomm 3200 WiFi driver
3 *
4 * Copyright (C) 2009 Intel Corporation <ilw@linux.intel.com>
5 * Samuel Ortiz <samuel.ortiz@intel.com>
6 * Zhu Yi <yi.zhu@intel.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 */
23
24#include <linux/wireless.h>
25#include <net/cfg80211.h>
26
27#include "iwm.h"
28#include "commands.h"
29
30static const iw_handler iwm_handlers[] =
31{
32 (iw_handler) NULL, /* SIOCSIWCOMMIT */
33 (iw_handler) cfg80211_wext_giwname, /* SIOCGIWNAME */
34 (iw_handler) NULL, /* SIOCSIWNWID */
35 (iw_handler) NULL, /* SIOCGIWNWID */
36 (iw_handler) cfg80211_wext_siwfreq, /* SIOCSIWFREQ */
37 (iw_handler) cfg80211_wext_giwfreq, /* SIOCGIWFREQ */
38 (iw_handler) cfg80211_wext_siwmode, /* SIOCSIWMODE */
39 (iw_handler) cfg80211_wext_giwmode, /* SIOCGIWMODE */
40 (iw_handler) NULL, /* SIOCSIWSENS */
41 (iw_handler) NULL, /* SIOCGIWSENS */
42 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
43 (iw_handler) cfg80211_wext_giwrange, /* SIOCGIWRANGE */
44 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
45 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
46 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
47 (iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */
48 (iw_handler) NULL, /* SIOCSIWSPY */
49 (iw_handler) NULL, /* SIOCGIWSPY */
50 (iw_handler) NULL, /* SIOCSIWTHRSPY */
51 (iw_handler) NULL, /* SIOCGIWTHRSPY */
52 (iw_handler) cfg80211_wext_siwap, /* SIOCSIWAP */
53 (iw_handler) cfg80211_wext_giwap, /* SIOCGIWAP */
54 (iw_handler) NULL, /* SIOCSIWMLME */
55 (iw_handler) NULL, /* SIOCGIWAPLIST */
56 (iw_handler) cfg80211_wext_siwscan, /* SIOCSIWSCAN */
57 (iw_handler) cfg80211_wext_giwscan, /* SIOCGIWSCAN */
58 (iw_handler) cfg80211_wext_siwessid, /* SIOCSIWESSID */
59 (iw_handler) cfg80211_wext_giwessid, /* SIOCGIWESSID */
60 (iw_handler) NULL, /* SIOCSIWNICKN */
61 (iw_handler) NULL, /* SIOCGIWNICKN */
62 (iw_handler) NULL, /* -- hole -- */
63 (iw_handler) NULL, /* -- hole -- */
64 (iw_handler) NULL, /* SIOCSIWRATE */
65 (iw_handler) cfg80211_wext_giwrate, /* SIOCGIWRATE */
66 (iw_handler) cfg80211_wext_siwrts, /* SIOCSIWRTS */
67 (iw_handler) cfg80211_wext_giwrts, /* SIOCGIWRTS */
68 (iw_handler) cfg80211_wext_siwfrag, /* SIOCSIWFRAG */
69 (iw_handler) cfg80211_wext_giwfrag, /* SIOCGIWFRAG */
70 (iw_handler) cfg80211_wext_siwtxpower, /* SIOCSIWTXPOW */
71 (iw_handler) cfg80211_wext_giwtxpower, /* SIOCGIWTXPOW */
72 (iw_handler) NULL, /* SIOCSIWRETRY */
73 (iw_handler) NULL, /* SIOCGIWRETRY */
74 (iw_handler) cfg80211_wext_siwencode, /* SIOCSIWENCODE */
75 (iw_handler) cfg80211_wext_giwencode, /* SIOCGIWENCODE */
76 (iw_handler) cfg80211_wext_siwpower, /* SIOCSIWPOWER */
77 (iw_handler) cfg80211_wext_giwpower, /* SIOCGIWPOWER */
78 (iw_handler) NULL, /* -- hole -- */
79 (iw_handler) NULL, /* -- hole -- */
80 (iw_handler) cfg80211_wext_siwgenie, /* SIOCSIWGENIE */
81 (iw_handler) NULL, /* SIOCGIWGENIE */
82 (iw_handler) cfg80211_wext_siwauth, /* SIOCSIWAUTH */
83 (iw_handler) cfg80211_wext_giwauth, /* SIOCGIWAUTH */
84 (iw_handler) cfg80211_wext_siwencodeext, /* SIOCSIWENCODEEXT */
85 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
86 (iw_handler) NULL, /* SIOCSIWPMKSA */
87 (iw_handler) NULL, /* -- hole -- */
88};
89
90const struct iw_handler_def iwm_iw_handler_def = {
91 .num_standard = ARRAY_SIZE(iwm_handlers),
92 .standard = (iw_handler *) iwm_handlers,
93 .get_wireless_stats = cfg80211_wireless_stats,
94};
95
diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig
index 19a4c66e143e..7dd77b6d4c9a 100644
--- a/net/mac80211/Kconfig
+++ b/net/mac80211/Kconfig
@@ -6,7 +6,6 @@ config MAC80211
6 select CRYPTO_ARC4 6 select CRYPTO_ARC4
7 select CRYPTO_AES 7 select CRYPTO_AES
8 select CRC32 8 select CRC32
9 select WIRELESS_EXT
10 ---help--- 9 ---help---
11 This option enables the hardware independent IEEE 802.11 10 This option enables the hardware independent IEEE 802.11
12 networking stack. 11 networking stack.
diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile
index 91284a74ff91..9f3cf7129324 100644
--- a/net/mac80211/Makefile
+++ b/net/mac80211/Makefile
@@ -3,7 +3,6 @@ obj-$(CONFIG_MAC80211) += mac80211.o
3# mac80211 objects 3# mac80211 objects
4mac80211-y := \ 4mac80211-y := \
5 main.o \ 5 main.o \
6 wext.o \
7 sta_info.o \ 6 sta_info.o \
8 wep.o \ 7 wep.o \
9 wpa.o \ 8 wpa.o \
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index c6b25cb73284..aec6853cb435 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -24,7 +24,6 @@
24#include <linux/spinlock.h> 24#include <linux/spinlock.h>
25#include <linux/etherdevice.h> 25#include <linux/etherdevice.h>
26#include <net/cfg80211.h> 26#include <net/cfg80211.h>
27#include <net/iw_handler.h>
28#include <net/mac80211.h> 27#include <net/mac80211.h>
29#include "key.h" 28#include "key.h"
30#include "sta_info.h" 29#include "sta_info.h"
@@ -951,9 +950,6 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
951void ieee80211_configure_filter(struct ieee80211_local *local); 950void ieee80211_configure_filter(struct ieee80211_local *local);
952u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata); 951u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
953 952
954/* wireless extensions */
955extern const struct iw_handler_def ieee80211_iw_handler_def;
956
957/* STA code */ 953/* STA code */
958void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata); 954void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata);
959int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, 955int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index d79a21105042..6c655b6547fb 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -684,7 +684,6 @@ static void ieee80211_if_setup(struct net_device *dev)
684{ 684{
685 ether_setup(dev); 685 ether_setup(dev);
686 dev->netdev_ops = &ieee80211_dataif_ops; 686 dev->netdev_ops = &ieee80211_dataif_ops;
687 dev->wireless_handlers = &ieee80211_iw_handler_def;
688 dev->destructor = free_netdev; 687 dev->destructor = free_netdev;
689} 688}
690 689
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 147772a2977c..45731000eb8d 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -18,7 +18,6 @@
18#include <linux/if_arp.h> 18#include <linux/if_arp.h>
19#include <linux/rtnetlink.h> 19#include <linux/rtnetlink.h>
20#include <net/mac80211.h> 20#include <net/mac80211.h>
21#include <net/iw_handler.h>
22 21
23#include "ieee80211_i.h" 22#include "ieee80211_i.h"
24#include "driver-ops.h" 23#include "driver-ops.h"
diff --git a/net/mac80211/wext.c b/net/mac80211/wext.c
deleted file mode 100644
index aa250c3e8fda..000000000000
--- a/net/mac80211/wext.c
+++ /dev/null
@@ -1,98 +0,0 @@
1/*
2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005-2006, Devicescape Software, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#include <linux/module.h>
11#include <linux/init.h>
12#include <linux/netdevice.h>
13#include <linux/types.h>
14#include <linux/slab.h>
15#include <linux/skbuff.h>
16#include <linux/etherdevice.h>
17#include <linux/if_arp.h>
18#include <linux/wireless.h>
19#include <net/iw_handler.h>
20#include <asm/uaccess.h>
21
22#include <net/mac80211.h>
23#include "ieee80211_i.h"
24#include "led.h"
25#include "rate.h"
26#include "wpa.h"
27#include "aes_ccm.h"
28
29
30
31/* Structures to export the Wireless Handlers */
32
33static const iw_handler ieee80211_handler[] =
34{
35 (iw_handler) NULL, /* SIOCSIWCOMMIT */
36 (iw_handler) cfg80211_wext_giwname, /* SIOCGIWNAME */
37 (iw_handler) NULL, /* SIOCSIWNWID */
38 (iw_handler) NULL, /* SIOCGIWNWID */
39 (iw_handler) cfg80211_wext_siwfreq, /* SIOCSIWFREQ */
40 (iw_handler) cfg80211_wext_giwfreq, /* SIOCGIWFREQ */
41 (iw_handler) cfg80211_wext_siwmode, /* SIOCSIWMODE */
42 (iw_handler) cfg80211_wext_giwmode, /* SIOCGIWMODE */
43 (iw_handler) NULL, /* SIOCSIWSENS */
44 (iw_handler) NULL, /* SIOCGIWSENS */
45 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
46 (iw_handler) cfg80211_wext_giwrange, /* SIOCGIWRANGE */
47 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
48 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
49 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
50 (iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */
51 (iw_handler) NULL, /* SIOCSIWSPY */
52 (iw_handler) NULL, /* SIOCGIWSPY */
53 (iw_handler) NULL, /* SIOCSIWTHRSPY */
54 (iw_handler) NULL, /* SIOCGIWTHRSPY */
55 (iw_handler) cfg80211_wext_siwap, /* SIOCSIWAP */
56 (iw_handler) cfg80211_wext_giwap, /* SIOCGIWAP */
57 (iw_handler) cfg80211_wext_siwmlme, /* SIOCSIWMLME */
58 (iw_handler) NULL, /* SIOCGIWAPLIST */
59 (iw_handler) cfg80211_wext_siwscan, /* SIOCSIWSCAN */
60 (iw_handler) cfg80211_wext_giwscan, /* SIOCGIWSCAN */
61 (iw_handler) cfg80211_wext_siwessid, /* SIOCSIWESSID */
62 (iw_handler) cfg80211_wext_giwessid, /* SIOCGIWESSID */
63 (iw_handler) NULL, /* SIOCSIWNICKN */
64 (iw_handler) NULL, /* SIOCGIWNICKN */
65 (iw_handler) NULL, /* -- hole -- */
66 (iw_handler) NULL, /* -- hole -- */
67 (iw_handler) cfg80211_wext_siwrate, /* SIOCSIWRATE */
68 (iw_handler) cfg80211_wext_giwrate, /* SIOCGIWRATE */
69 (iw_handler) cfg80211_wext_siwrts, /* SIOCSIWRTS */
70 (iw_handler) cfg80211_wext_giwrts, /* SIOCGIWRTS */
71 (iw_handler) cfg80211_wext_siwfrag, /* SIOCSIWFRAG */
72 (iw_handler) cfg80211_wext_giwfrag, /* SIOCGIWFRAG */
73 (iw_handler) cfg80211_wext_siwtxpower, /* SIOCSIWTXPOW */
74 (iw_handler) cfg80211_wext_giwtxpower, /* SIOCGIWTXPOW */
75 (iw_handler) cfg80211_wext_siwretry, /* SIOCSIWRETRY */
76 (iw_handler) cfg80211_wext_giwretry, /* SIOCGIWRETRY */
77 (iw_handler) cfg80211_wext_siwencode, /* SIOCSIWENCODE */
78 (iw_handler) cfg80211_wext_giwencode, /* SIOCGIWENCODE */
79 (iw_handler) cfg80211_wext_siwpower, /* SIOCSIWPOWER */
80 (iw_handler) cfg80211_wext_giwpower, /* SIOCGIWPOWER */
81 (iw_handler) NULL, /* -- hole -- */
82 (iw_handler) NULL, /* -- hole -- */
83 (iw_handler) cfg80211_wext_siwgenie, /* SIOCSIWGENIE */
84 (iw_handler) NULL, /* SIOCGIWGENIE */
85 (iw_handler) cfg80211_wext_siwauth, /* SIOCSIWAUTH */
86 (iw_handler) cfg80211_wext_giwauth, /* SIOCGIWAUTH */
87 (iw_handler) cfg80211_wext_siwencodeext, /* SIOCSIWENCODEEXT */
88 (iw_handler) NULL, /* SIOCGIWENCODEEXT */
89 (iw_handler) NULL, /* SIOCSIWPMKSA */
90 (iw_handler) NULL, /* -- hole -- */
91};
92
93const struct iw_handler_def ieee80211_iw_handler_def =
94{
95 .num_standard = ARRAY_SIZE(ieee80211_handler),
96 .standard = (iw_handler *) ieee80211_handler,
97 .get_wireless_stats = cfg80211_wireless_stats,
98};
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 442c9f389799..f9fee65dc06a 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -19,6 +19,7 @@
19#include "core.h" 19#include "core.h"
20#include "sysfs.h" 20#include "sysfs.h"
21#include "debugfs.h" 21#include "debugfs.h"
22#include "wext-compat.h"
22 23
23/* name for sysfs, %d is appended */ 24/* name for sysfs, %d is appended */
24#define PHY_NAME "phy" 25#define PHY_NAME "phy"
@@ -665,6 +666,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
665 wdev->sme_state = CFG80211_SME_IDLE; 666 wdev->sme_state = CFG80211_SME_IDLE;
666 mutex_unlock(&rdev->devlist_mtx); 667 mutex_unlock(&rdev->devlist_mtx);
667#ifdef CONFIG_WIRELESS_EXT 668#ifdef CONFIG_WIRELESS_EXT
669 if (!dev->wireless_handlers)
670 dev->wireless_handlers = &cfg80211_wext_handler;
668 wdev->wext.default_key = -1; 671 wdev->wext.default_key = -1;
669 wdev->wext.default_mgmt_key = -1; 672 wdev->wext.default_mgmt_key = -1;
670 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; 673 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index 30058a80d7af..097a87d7bae1 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -8,7 +8,9 @@
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/netdevice.h> 9#include <linux/netdevice.h>
10#include <linux/nl80211.h> 10#include <linux/nl80211.h>
11#include <linux/wireless.h>
11#include <net/cfg80211.h> 12#include <net/cfg80211.h>
13#include <net/iw_handler.h>
12#include "core.h" 14#include "core.h"
13#include "nl80211.h" 15#include "nl80211.h"
14 16
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 2a2683f6c04a..67714d7ed5b4 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -14,6 +14,7 @@
14#include <net/iw_handler.h> 14#include <net/iw_handler.h>
15#include "core.h" 15#include "core.h"
16#include "nl80211.h" 16#include "nl80211.h"
17#include "wext-compat.h"
17 18
18#define IEEE80211_SCAN_RESULT_EXPIRE (15 * HZ) 19#define IEEE80211_SCAN_RESULT_EXPIRE (15 * HZ)
19 20
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index a19741097989..d2b5d4ce0a00 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -8,6 +8,8 @@
8#include <linux/etherdevice.h> 8#include <linux/etherdevice.h>
9#include <linux/if_arp.h> 9#include <linux/if_arp.h>
10#include <linux/workqueue.h> 10#include <linux/workqueue.h>
11#include <linux/wireless.h>
12#include <net/iw_handler.h>
11#include <net/cfg80211.h> 13#include <net/cfg80211.h>
12#include <net/rtnetlink.h> 14#include <net/rtnetlink.h>
13#include "nl80211.h" 15#include "nl80211.h"
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index 083e4c33d95d..e4e90e249bab 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -1397,3 +1397,43 @@ int cfg80211_wext_giwessid(struct net_device *dev,
1397 } 1397 }
1398} 1398}
1399EXPORT_SYMBOL_GPL(cfg80211_wext_giwessid); 1399EXPORT_SYMBOL_GPL(cfg80211_wext_giwessid);
1400
1401static const iw_handler cfg80211_handlers[] = {
1402 [IW_IOCTL_IDX(SIOCGIWNAME)] = (iw_handler) cfg80211_wext_giwname,
1403 [IW_IOCTL_IDX(SIOCSIWFREQ)] = (iw_handler) cfg80211_wext_siwfreq,
1404 [IW_IOCTL_IDX(SIOCGIWFREQ)] = (iw_handler) cfg80211_wext_giwfreq,
1405 [IW_IOCTL_IDX(SIOCSIWMODE)] = (iw_handler) cfg80211_wext_siwmode,
1406 [IW_IOCTL_IDX(SIOCGIWMODE)] = (iw_handler) cfg80211_wext_giwmode,
1407 [IW_IOCTL_IDX(SIOCGIWRANGE)] = (iw_handler) cfg80211_wext_giwrange,
1408 [IW_IOCTL_IDX(SIOCSIWAP)] = (iw_handler) cfg80211_wext_siwap,
1409 [IW_IOCTL_IDX(SIOCGIWAP)] = (iw_handler) cfg80211_wext_giwap,
1410 [IW_IOCTL_IDX(SIOCSIWMLME)] = (iw_handler) cfg80211_wext_siwmlme,
1411 [IW_IOCTL_IDX(SIOCSIWSCAN)] = (iw_handler) cfg80211_wext_siwscan,
1412 [IW_IOCTL_IDX(SIOCGIWSCAN)] = (iw_handler) cfg80211_wext_giwscan,
1413 [IW_IOCTL_IDX(SIOCSIWESSID)] = (iw_handler) cfg80211_wext_siwessid,
1414 [IW_IOCTL_IDX(SIOCGIWESSID)] = (iw_handler) cfg80211_wext_giwessid,
1415 [IW_IOCTL_IDX(SIOCSIWRATE)] = (iw_handler) cfg80211_wext_siwrate,
1416 [IW_IOCTL_IDX(SIOCGIWRATE)] = (iw_handler) cfg80211_wext_giwrate,
1417 [IW_IOCTL_IDX(SIOCSIWRTS)] = (iw_handler) cfg80211_wext_siwrts,
1418 [IW_IOCTL_IDX(SIOCGIWRTS)] = (iw_handler) cfg80211_wext_giwrts,
1419 [IW_IOCTL_IDX(SIOCSIWFRAG)] = (iw_handler) cfg80211_wext_siwfrag,
1420 [IW_IOCTL_IDX(SIOCGIWFRAG)] = (iw_handler) cfg80211_wext_giwfrag,
1421 [IW_IOCTL_IDX(SIOCSIWTXPOW)] = (iw_handler) cfg80211_wext_siwtxpower,
1422 [IW_IOCTL_IDX(SIOCGIWTXPOW)] = (iw_handler) cfg80211_wext_giwtxpower,
1423 [IW_IOCTL_IDX(SIOCSIWRETRY)] = (iw_handler) cfg80211_wext_siwretry,
1424 [IW_IOCTL_IDX(SIOCGIWRETRY)] = (iw_handler) cfg80211_wext_giwretry,
1425 [IW_IOCTL_IDX(SIOCSIWENCODE)] = (iw_handler) cfg80211_wext_siwencode,
1426 [IW_IOCTL_IDX(SIOCGIWENCODE)] = (iw_handler) cfg80211_wext_giwencode,
1427 [IW_IOCTL_IDX(SIOCSIWPOWER)] = (iw_handler) cfg80211_wext_siwpower,
1428 [IW_IOCTL_IDX(SIOCGIWPOWER)] = (iw_handler) cfg80211_wext_giwpower,
1429 [IW_IOCTL_IDX(SIOCSIWGENIE)] = (iw_handler) cfg80211_wext_siwgenie,
1430 [IW_IOCTL_IDX(SIOCSIWAUTH)] = (iw_handler) cfg80211_wext_siwauth,
1431 [IW_IOCTL_IDX(SIOCGIWAUTH)] = (iw_handler) cfg80211_wext_giwauth,
1432 [IW_IOCTL_IDX(SIOCSIWENCODEEXT)]= (iw_handler) cfg80211_wext_siwencodeext,
1433};
1434
1435const struct iw_handler_def cfg80211_wext_handler = {
1436 .num_standard = ARRAY_SIZE(cfg80211_handlers),
1437 .standard = cfg80211_handlers,
1438 .get_wireless_stats = cfg80211_wireless_stats,
1439};
diff --git a/net/wireless/wext-compat.h b/net/wireless/wext-compat.h
index c0310d93c2e5..9a3774749589 100644
--- a/net/wireless/wext-compat.h
+++ b/net/wireless/wext-compat.h
@@ -1,6 +1,9 @@
1#ifndef __WEXT_COMPAT 1#ifndef __WEXT_COMPAT
2#define __WEXT_COMPAT 2#define __WEXT_COMPAT
3 3
4#include <net/iw_handler.h>
5#include <linux/wireless.h>
6
4int cfg80211_ibss_wext_siwfreq(struct net_device *dev, 7int cfg80211_ibss_wext_siwfreq(struct net_device *dev,
5 struct iw_request_info *info, 8 struct iw_request_info *info,
6 struct iw_freq *freq, char *extra); 9 struct iw_freq *freq, char *extra);
@@ -42,4 +45,6 @@ int cfg80211_mgd_wext_giwessid(struct net_device *dev,
42struct ieee80211_channel *cfg80211_wext_freq(struct wiphy *wiphy, 45struct ieee80211_channel *cfg80211_wext_freq(struct wiphy *wiphy,
43 struct iw_freq *freq); 46 struct iw_freq *freq);
44 47
48
49extern const struct iw_handler_def cfg80211_wext_handler;
45#endif /* __WEXT_COMPAT */ 50#endif /* __WEXT_COMPAT */
="hl num">10)) { unsigned long flags, f; printk(KERN_ERR "%s: DMA %s timed out, %d bytes left\n", dev->name, adapter->current_dma.direction ? "download" : "upload", get_dma_residue(dev->dma)); spin_lock_irqsave(&adapter->lock, flags); adapter->dmaing = 0; adapter->busy = 0; f=claim_dma_lock(); disable_dma(dev->dma); release_dma_lock(f); if (adapter->rx_active) adapter->rx_active--; outb_control(adapter->hcr_val & ~(DMAE | TCEN | DIR), dev); spin_unlock_irqrestore(&adapter->lock, flags); } } /* Primitive functions used by send_pcb() */ static inline bool send_pcb_slow(unsigned int base_addr, unsigned char byte) { unsigned long timeout; outb_command(byte, base_addr); for (timeout = jiffies + 5*HZ/100; time_before(jiffies, timeout);) { if (inb_status(base_addr) & HCRE) return false; } printk(KERN_WARNING "3c505: send_pcb_slow timed out\n"); return true; } static inline bool send_pcb_fast(unsigned int base_addr, unsigned char byte) { unsigned int timeout; outb_command(byte, base_addr); for (timeout = 0; timeout < 40000; timeout++) { if (inb_status(base_addr) & HCRE) return false; } printk(KERN_WARNING "3c505: send_pcb_fast timed out\n"); return true; } /* Check to see if the receiver needs restarting, and kick it if so */ static inline void prime_rx(struct net_device *dev) { elp_device *adapter = dev->priv; while (adapter->rx_active < ELP_RX_PCBS && netif_running(dev)) { if (!start_receive(dev, &adapter->itx_pcb)) break; } } /***************************************************************** * * send_pcb * Send a PCB to the adapter. * * output byte to command reg --<--+ * wait until HCRE is non zero | * loop until all bytes sent -->--+ * set HSF1 and HSF2 to 1 * output pcb length * wait until ASF give ACK or NAK * set HSF1 and HSF2 to 0 * *****************************************************************/ /* This can be quite slow -- the adapter is allowed to take up to 40ms * to respond to the initial interrupt. * * We run initially with interrupts turned on, but with a semaphore set * so that nobody tries to re-enter this code. Once the first byte has * gone through, we turn interrupts off and then send the others (the * timeout is reduced to 500us). */ static bool send_pcb(struct net_device *dev, pcb_struct * pcb) { int i; unsigned long timeout; elp_device *adapter = dev->priv; unsigned long flags; check_3c505_dma(dev); if (adapter->dmaing && adapter->current_dma.direction == 0) return false; /* Avoid contention */ if (test_and_set_bit(1, &adapter->send_pcb_semaphore)) { if (elp_debug >= 3) { printk(KERN_DEBUG "%s: send_pcb entered while threaded\n", dev->name); } return false; } /* * load each byte into the command register and * wait for the HCRE bit to indicate the adapter * had read the byte */ set_hsf(dev, 0); if (send_pcb_slow(dev->base_addr, pcb->command)) goto abort; spin_lock_irqsave(&adapter->lock, flags); if (send_pcb_fast(dev->base_addr, pcb->length)) goto sti_abort; for (i = 0; i < pcb->length; i++) { if (send_pcb_fast(dev->base_addr, pcb->data.raw[i])) goto sti_abort; } outb_control(adapter->hcr_val | 3, dev); /* signal end of PCB */ outb_command(2 + pcb->length, dev->base_addr); /* now wait for the acknowledgement */ spin_unlock_irqrestore(&adapter->lock, flags); for (timeout = jiffies + 5*HZ/100; time_before(jiffies, timeout);) { switch (GET_ASF(dev->base_addr)) { case ASF_PCB_ACK: adapter->send_pcb_semaphore = 0; return true; case ASF_PCB_NAK: #ifdef ELP_DEBUG printk(KERN_DEBUG "%s: send_pcb got NAK\n", dev->name); #endif goto abort; } } if (elp_debug >= 1) printk(KERN_DEBUG "%s: timeout waiting for PCB acknowledge (status %02x)\n", dev->name, inb_status(dev->base_addr)); goto abort; sti_abort: spin_unlock_irqrestore(&adapter->lock, flags); abort: adapter->send_pcb_semaphore = 0; return false; } /***************************************************************** * * receive_pcb * Read a PCB from the adapter * * wait for ACRF to be non-zero ---<---+ * input a byte | * if ASF1 and ASF2 were not both one | * before byte was read, loop --->---+ * set HSF1 and HSF2 for ack * *****************************************************************/ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb) { int i, j; int total_length; int stat; unsigned long timeout; unsigned long flags; elp_device *adapter = dev->priv; set_hsf(dev, 0); /* get the command code */ timeout = jiffies + 2*HZ/100; while (((stat = get_status(dev->base_addr)) & ACRF) == 0 && time_before(jiffies, timeout)); if (time_after_eq(jiffies, timeout)) { TIMEOUT_MSG(__LINE__); return false; } pcb->command = inb_command(dev->base_addr); /* read the data length */ timeout = jiffies + 3*HZ/100; while (((stat = get_status(dev->base_addr)) & ACRF) == 0 && time_before(jiffies, timeout)); if (time_after_eq(jiffies, timeout)) { TIMEOUT_MSG(__LINE__); printk(KERN_INFO "%s: status %02x\n", dev->name, stat); return false; } pcb->length = inb_command(dev->base_addr); if (pcb->length > MAX_PCB_DATA) { INVALID_PCB_MSG(pcb->length); adapter_reset(dev); return false; } /* read the data */ spin_lock_irqsave(&adapter->lock, flags); i = 0; do { j = 0; while (((stat = get_status(dev->base_addr)) & ACRF) == 0 && j++ < 20000); pcb->data.raw[i++] = inb_command(dev->base_addr); if (i > MAX_PCB_DATA) INVALID_PCB_MSG(i); } while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j < 20000); spin_unlock_irqrestore(&adapter->lock, flags); if (j >= 20000) { TIMEOUT_MSG(__LINE__); return false; } /* woops, the last "data" byte was really the length! */ total_length = pcb->data.raw[--i]; /* safety check total length vs data length */ if (total_length != (pcb->length + 2)) { if (elp_debug >= 2) printk(KERN_WARNING "%s: mangled PCB received\n", dev->name); set_hsf(dev, HSF_PCB_NAK); return false; } if (pcb->command == CMD_RECEIVE_PACKET_COMPLETE) { if (test_and_set_bit(0, (void *) &adapter->busy)) { if (backlog_next(adapter->rx_backlog.in) == adapter->rx_backlog.out) { set_hsf(dev, HSF_PCB_NAK); printk(KERN_WARNING "%s: PCB rejected, transfer in progress and backlog full\n", dev->name); pcb->command = 0; return true; } else { pcb->command = 0xff; } } } set_hsf(dev, HSF_PCB_ACK); return true; } /****************************************************** * * queue a receive command on the adapter so we will get an * interrupt when a packet is received. * ******************************************************/ static bool start_receive(struct net_device *dev, pcb_struct * tx_pcb) { bool status; elp_device *adapter = dev->priv; if (elp_debug >= 3) printk(KERN_DEBUG "%s: restarting receiver\n", dev->name); tx_pcb->command = CMD_RECEIVE_PACKET; tx_pcb->length = sizeof(struct Rcv_pkt); tx_pcb->data.rcv_pkt.buf_seg = tx_pcb->data.rcv_pkt.buf_ofs = 0; /* Unused */ tx_pcb->data.rcv_pkt.buf_len = 1600; tx_pcb->data.rcv_pkt.timeout = 0; /* set timeout to zero */ status = send_pcb(dev, tx_pcb); if (status) adapter->rx_active++; return status; } /****************************************************** * * extract a packet from the adapter * this routine is only called from within the interrupt * service routine, so no cli/sti calls are needed * note that the length is always assumed to be even * ******************************************************/ static void receive_packet(struct net_device *dev, int len) { int rlen; elp_device *adapter = dev->priv; void *target; struct sk_buff *skb; unsigned long flags; rlen = (len + 1) & ~1; skb = dev_alloc_skb(rlen + 2); if (!skb) { printk(KERN_WARNING "%s: memory squeeze, dropping packet\n", dev->name); target = adapter->dma_buffer; adapter->current_dma.target = NULL; /* FIXME: stats */ return; } skb_reserve(skb, 2); target = skb_put(skb, rlen); if ((unsigned long)(target + rlen) >= MAX_DMA_ADDRESS) { adapter->current_dma.target = target; target = adapter->dma_buffer; } else { adapter->current_dma.target = NULL; } /* if this happens, we die */ if (test_and_set_bit(0, (void *) &adapter->dmaing)) printk(KERN_ERR "%s: rx blocked, DMA in progress, dir %d\n", dev->name, adapter->current_dma.direction); adapter->current_dma.direction = 0; adapter->current_dma.length = rlen; adapter->current_dma.skb = skb; adapter->current_dma.start_time = jiffies; outb_control(adapter->hcr_val | DIR | TCEN | DMAE, dev); flags=claim_dma_lock(); disable_dma(dev->dma); clear_dma_ff(dev->dma); set_dma_mode(dev->dma, 0x04); /* dma read */ set_dma_addr(dev->dma, isa_virt_to_bus(target)); set_dma_count(dev->dma, rlen); enable_dma(dev->dma); release_dma_lock(flags); if (elp_debug >= 3) { printk(KERN_DEBUG "%s: rx DMA transfer started\n", dev->name); } if (adapter->rx_active) adapter->rx_active--; if (!adapter->busy) printk(KERN_WARNING "%s: receive_packet called, busy not set.\n", dev->name); } /****************************************************** * * interrupt handler * ******************************************************/ static irqreturn_t elp_interrupt(int irq, void *dev_id) { int len; int dlen; int icount = 0; struct net_device *dev; elp_device *adapter; unsigned long timeout; dev = dev_id; adapter = (elp_device *) dev->priv; spin_lock(&adapter->lock); do { /* * has a DMA transfer finished? */ if (inb_status(dev->base_addr) & DONE) { if (!adapter->dmaing) { printk(KERN_WARNING "%s: phantom DMA completed\n", dev->name); } if (elp_debug >= 3) { printk(KERN_DEBUG "%s: %s DMA complete, status %02x\n", dev->name, adapter->current_dma.direction ? "tx" : "rx", inb_status(dev->base_addr)); } outb_control(adapter->hcr_val & ~(DMAE | TCEN | DIR), dev); if (adapter->current_dma.direction) { dev_kfree_skb_irq(adapter->current_dma.skb); } else { struct sk_buff *skb = adapter->current_dma.skb; if (skb) { if (adapter->current_dma.target) { /* have already done the skb_put() */ memcpy(adapter->current_dma.target, adapter->dma_buffer, adapter->current_dma.length); } skb->protocol = eth_type_trans(skb,dev); adapter->stats.rx_bytes += skb->len; netif_rx(skb); dev->last_rx = jiffies; } } adapter->dmaing = 0; if (adapter->rx_backlog.in != adapter->rx_backlog.out) { int t = adapter->rx_backlog.length[adapter->rx_backlog.out]; adapter->rx_backlog.out = backlog_next(adapter->rx_backlog.out); if (elp_debug >= 2) printk(KERN_DEBUG "%s: receiving backlogged packet (%d)\n", dev->name, t); receive_packet(dev, t); } else { adapter->busy = 0; } } else { /* has one timed out? */ check_3c505_dma(dev); } /* * receive a PCB from the adapter */ timeout = jiffies + 3*HZ/100; while ((inb_status(dev->base_addr) & ACRF) != 0 && time_before(jiffies, timeout)) { if (receive_pcb(dev, &adapter->irx_pcb)) { switch (adapter->irx_pcb.command) { case 0: break; /* * received a packet - this must be handled fast */ case 0xff: case CMD_RECEIVE_PACKET_COMPLETE: /* if the device isn't open, don't pass packets up the stack */ if (!netif_running(dev)) break; len = adapter->irx_pcb.data.rcv_resp.pkt_len; dlen = adapter->irx_pcb.data.rcv_resp.buf_len; if (adapter->irx_pcb.data.rcv_resp.timeout != 0) { printk(KERN_ERR "%s: interrupt - packet not received correctly\n", dev->name); } else { if (elp_debug >= 3) { printk(KERN_DEBUG "%s: interrupt - packet received of length %i (%i)\n", dev->name, len, dlen); } if (adapter->irx_pcb.command == 0xff) { if (elp_debug >= 2) printk(KERN_DEBUG "%s: adding packet to backlog (len = %d)\n", dev->name, dlen); adapter->rx_backlog.length[adapter->rx_backlog.in] = dlen; adapter->rx_backlog.in = backlog_next(adapter->rx_backlog.in); } else { receive_packet(dev, dlen); } if (elp_debug >= 3) printk(KERN_DEBUG "%s: packet received\n", dev->name); } break; /* * 82586 configured correctly */ case CMD_CONFIGURE_82586_RESPONSE: adapter->got[CMD_CONFIGURE_82586] = 1; if (elp_debug >= 3) printk(KERN_DEBUG "%s: interrupt - configure response received\n", dev->name); break; /* * Adapter memory configuration */ case CMD_CONFIGURE_ADAPTER_RESPONSE: adapter->got[CMD_CONFIGURE_ADAPTER_MEMORY] = 1; if (elp_debug >= 3) printk(KERN_DEBUG "%s: Adapter memory configuration %s.\n", dev->name, adapter->irx_pcb.data.failed ? "failed" : "succeeded"); break; /* * Multicast list loading */ case CMD_LOAD_MULTICAST_RESPONSE: adapter->got[CMD_LOAD_MULTICAST_LIST] = 1; if (elp_debug >= 3) printk(KERN_DEBUG "%s: Multicast address list loading %s.\n", dev->name, adapter->irx_pcb.data.failed ? "failed" : "succeeded"); break; /* * Station address setting */ case CMD_SET_ADDRESS_RESPONSE: adapter->got[CMD_SET_STATION_ADDRESS] = 1; if (elp_debug >= 3) printk(KERN_DEBUG "%s: Ethernet address setting %s.\n", dev->name, adapter->irx_pcb.data.failed ? "failed" : "succeeded"); break; /* * received board statistics */ case CMD_NETWORK_STATISTICS_RESPONSE: adapter->stats.rx_packets += adapter->irx_pcb.data.netstat.tot_recv; adapter->stats.tx_packets += adapter->irx_pcb.data.netstat.tot_xmit; adapter->stats.rx_crc_errors += adapter->irx_pcb.data.netstat.err_CRC; adapter->stats.rx_frame_errors += adapter->irx_pcb.data.netstat.err_align; adapter->stats.rx_fifo_errors += adapter->irx_pcb.data.netstat.err_ovrrun; adapter->stats.rx_over_errors += adapter->irx_pcb.data.netstat.err_res; adapter->got[CMD_NETWORK_STATISTICS] = 1; if (elp_debug >= 3) printk(KERN_DEBUG "%s: interrupt - statistics response received\n", dev->name); break; /* * sent a packet */ case CMD_TRANSMIT_PACKET_COMPLETE: if (elp_debug >= 3) printk(KERN_DEBUG "%s: interrupt - packet sent\n", dev->name); if (!netif_running(dev)) break; switch (adapter->irx_pcb.data.xmit_resp.c_stat) { case 0xffff: adapter->stats.tx_aborted_errors++; printk(KERN_INFO "%s: transmit timed out, network cable problem?\n", dev->name); break; case 0xfffe: adapter->stats.tx_fifo_errors++; printk(KERN_INFO "%s: transmit timed out, FIFO underrun\n", dev->name); break; } netif_wake_queue(dev); break; /* * some unknown PCB */ default: printk(KERN_DEBUG "%s: unknown PCB received - %2.2x\n", dev->name, adapter->irx_pcb.command); break; } } else { printk(KERN_WARNING "%s: failed to read PCB on interrupt\n", dev->name); adapter_reset(dev); } } } while (icount++ < 5 && (inb_status(dev->base_addr) & (ACRF | DONE))); prime_rx(dev); /* * indicate no longer in interrupt routine */ spin_unlock(&adapter->lock); return IRQ_HANDLED; } /****************************************************** * * open the board * ******************************************************/ static int elp_open(struct net_device *dev) { elp_device *adapter; int retval; adapter = dev->priv; if (elp_debug >= 3) printk(KERN_DEBUG "%s: request to open device\n", dev->name); /* * make sure we actually found the device */ if (adapter == NULL) { printk(KERN_ERR "%s: Opening a non-existent physical device\n", dev->name); return -EAGAIN; } /* * disable interrupts on the board */ outb_control(0, dev); /* * clear any pending interrupts */ inb_command(dev->base_addr); adapter_reset(dev); /* * no receive PCBs active */ adapter->rx_active = 0; adapter->busy = 0; adapter->send_pcb_semaphore = 0; adapter->rx_backlog.in = 0; adapter->rx_backlog.out = 0; spin_lock_init(&adapter->lock); /* * install our interrupt service routine */ if ((retval = request_irq(dev->irq, &elp_interrupt, 0, dev->name, dev))) { printk(KERN_ERR "%s: could not allocate IRQ%d\n", dev->name, dev->irq); return retval; } if ((retval = request_dma(dev->dma, dev->name))) { free_irq(dev->irq, dev); printk(KERN_ERR "%s: could not allocate DMA%d channel\n", dev->name, dev->dma); return retval; } adapter->dma_buffer = (void *) dma_mem_alloc(DMA_BUFFER_SIZE); if (!adapter->dma_buffer) { printk(KERN_ERR "%s: could not allocate DMA buffer\n", dev->name); free_dma(dev->dma); free_irq(dev->irq, dev); return -ENOMEM; } adapter->dmaing = 0; /* * enable interrupts on the board */ outb_control(CMDE, dev); /* * configure adapter memory: we need 10 multicast addresses, default==0 */ if (elp_debug >= 3) printk(KERN_DEBUG "%s: sending 3c505 memory configuration command\n", dev->name); adapter->tx_pcb.command = CMD_CONFIGURE_ADAPTER_MEMORY; adapter->tx_pcb.data.memconf.cmd_q = 10; adapter->tx_pcb.data.memconf.rcv_q = 20; adapter->tx_pcb.data.memconf.mcast = 10; adapter->tx_pcb.data.memconf.frame = 20; adapter->tx_pcb.data.memconf.rcv_b = 20; adapter->tx_pcb.data.memconf.progs = 0; adapter->tx_pcb.length = sizeof(struct Memconf); adapter->got[CMD_CONFIGURE_ADAPTER_MEMORY] = 0; if (!send_pcb(dev, &adapter->tx_pcb)) printk(KERN_ERR "%s: couldn't send memory configuration command\n", dev->name); else { unsigned long timeout = jiffies + TIMEOUT; while (adapter->got[CMD_CONFIGURE_ADAPTER_MEMORY] == 0 && time_before(jiffies, timeout)); if (time_after_eq(jiffies, timeout)) TIMEOUT_MSG(__LINE__); } /* * configure adapter to receive broadcast messages and wait for response */ if (elp_debug >= 3) printk(KERN_DEBUG "%s: sending 82586 configure command\n", dev->name); adapter->tx_pcb.command = CMD_CONFIGURE_82586; adapter->tx_pcb.data.configure = NO_LOOPBACK | RECV_BROAD; adapter->tx_pcb.length = 2; adapter->got[CMD_CONFIGURE_82586] = 0; if (!send_pcb(dev, &adapter->tx_pcb)) printk(KERN_ERR "%s: couldn't send 82586 configure command\n", dev->name); else { unsigned long timeout = jiffies + TIMEOUT; while (adapter->got[CMD_CONFIGURE_82586] == 0 && time_before(jiffies, timeout)); if (time_after_eq(jiffies, timeout)) TIMEOUT_MSG(__LINE__); } /* enable burst-mode DMA */ /* outb(0x1, dev->base_addr + PORT_AUXDMA); */ /* * queue receive commands to provide buffering */ prime_rx(dev); if (elp_debug >= 3) printk(KERN_DEBUG "%s: %d receive PCBs active\n", dev->name, adapter->rx_active); /* * device is now officially open! */ netif_start_queue(dev); return 0; } /****************************************************** * * send a packet to the adapter * ******************************************************/ static bool send_packet(struct net_device *dev, struct sk_buff *skb) { elp_device *adapter = dev->priv; unsigned long target; unsigned long flags; /* * make sure the length is even and no shorter than 60 bytes */ unsigned int nlen = (((skb->len < 60) ? 60 : skb->len) + 1) & (~1); if (test_and_set_bit(0, (void *) &adapter->busy)) { if (elp_debug >= 2) printk(KERN_DEBUG "%s: transmit blocked\n", dev->name); return false; } adapter->stats.tx_bytes += nlen; /* * send the adapter a transmit packet command. Ignore segment and offset * and make sure the length is even */ adapter->tx_pcb.command = CMD_TRANSMIT_PACKET; adapter->tx_pcb.length = sizeof(struct Xmit_pkt); adapter->tx_pcb.data.xmit_pkt.buf_ofs = adapter->tx_pcb.data.xmit_pkt.buf_seg = 0; /* Unused */ adapter->tx_pcb.data.xmit_pkt.pkt_len = nlen; if (!send_pcb(dev, &adapter->tx_pcb)) { adapter->busy = 0; return false; } /* if this happens, we die */ if (test_and_set_bit(0, (void *) &adapter->dmaing)) printk(KERN_DEBUG "%s: tx: DMA %d in progress\n", dev->name, adapter->current_dma.direction); adapter->current_dma.direction = 1; adapter->current_dma.start_time = jiffies; if ((unsigned long)(skb->data + nlen) >= MAX_DMA_ADDRESS || nlen != skb->len) { skb_copy_from_linear_data(skb, adapter->dma_buffer, nlen); memset(adapter->dma_buffer+skb->len, 0, nlen-skb->len); target = isa_virt_to_bus(adapter->dma_buffer); } else { target = isa_virt_to_bus(skb->data); } adapter->current_dma.skb = skb; flags=claim_dma_lock(); disable_dma(dev->dma); clear_dma_ff(dev->dma); set_dma_mode(dev->dma, 0x48); /* dma memory -> io */ set_dma_addr(dev->dma, target); set_dma_count(dev->dma, nlen); outb_control(adapter->hcr_val | DMAE | TCEN, dev); enable_dma(dev->dma); release_dma_lock(flags); if (elp_debug >= 3) printk(KERN_DEBUG "%s: DMA transfer started\n", dev->name); return true; } /* * The upper layer thinks we timed out */ static void elp_timeout(struct net_device *dev) { elp_device *adapter = dev->priv; int stat; stat = inb_status(dev->base_addr); printk(KERN_WARNING "%s: transmit timed out, lost %s?\n", dev->name, (stat & ACRF) ? "interrupt" : "command"); if (elp_debug >= 1) printk(KERN_DEBUG "%s: status %#02x\n", dev->name, stat); dev->trans_start = jiffies; adapter->stats.tx_dropped++; netif_wake_queue(dev); } /****************************************************** * * start the transmitter * return 0 if sent OK, else return 1 * ******************************************************/ static int elp_start_xmit(struct sk_buff *skb, struct net_device *dev) { unsigned long flags; elp_device *adapter = dev->priv; spin_lock_irqsave(&adapter->lock, flags); check_3c505_dma(dev); if (elp_debug >= 3) printk(KERN_DEBUG "%s: request to send packet of length %d\n", dev->name, (int) skb->len); netif_stop_queue(dev); /* * send the packet at skb->data for skb->len */ if (!send_packet(dev, skb)) { if (elp_debug >= 2) { printk(KERN_DEBUG "%s: failed to transmit packet\n", dev->name); } spin_unlock_irqrestore(&adapter->lock, flags); return 1; } if (elp_debug >= 3) printk(KERN_DEBUG "%s: packet of length %d sent\n", dev->name, (int) skb->len); /* * start the transmit timeout */ dev->trans_start = jiffies; prime_rx(dev); spin_unlock_irqrestore(&adapter->lock, flags); netif_start_queue(dev); return 0; } /****************************************************** * * return statistics on the board * ******************************************************/ static struct net_device_stats *elp_get_stats(struct net_device *dev) { elp_device *adapter = (elp_device *) dev->priv; if (elp_debug >= 3) printk(KERN_DEBUG "%s: request for stats\n", dev->name); /* If the device is closed, just return the latest stats we have, - we cannot ask from the adapter without interrupts */ if (!netif_running(dev)) return &adapter->stats; /* send a get statistics command to the board */ adapter->tx_pcb.command = CMD_NETWORK_STATISTICS; adapter->tx_pcb.length = 0; adapter->got[CMD_NETWORK_STATISTICS] = 0; if (!send_pcb(dev, &adapter->tx_pcb)) printk(KERN_ERR "%s: couldn't send get statistics command\n", dev->name); else { unsigned long timeout = jiffies + TIMEOUT; while (adapter->got[CMD_NETWORK_STATISTICS] == 0 && time_before(jiffies, timeout)); if (time_after_eq(jiffies, timeout)) { TIMEOUT_MSG(__LINE__); return &adapter->stats; } } /* statistics are now up to date */ return &adapter->stats; } static void netdev_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { strcpy(info->driver, DRV_NAME); strcpy(info->version, DRV_VERSION); sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr); } static u32 netdev_get_msglevel(struct net_device *dev) { return debug; } static void netdev_set_msglevel(struct net_device *dev, u32 level) { debug = level; } static const struct ethtool_ops netdev_ethtool_ops = { .get_drvinfo = netdev_get_drvinfo, .get_msglevel = netdev_get_msglevel, .set_msglevel = netdev_set_msglevel, }; /****************************************************** * * close the board * ******************************************************/ static int elp_close(struct net_device *dev) { elp_device *adapter; adapter = dev->priv; if (elp_debug >= 3) printk(KERN_DEBUG "%s: request to close device\n", dev->name); netif_stop_queue(dev); /* Someone may request the device statistic information even when * the interface is closed. The following will update the statistics * structure in the driver, so we'll be able to give current statistics. */ (void) elp_get_stats(dev); /* * disable interrupts on the board */ outb_control(0, dev); /* * release the IRQ */ free_irq(dev->irq, dev); free_dma(dev->dma); free_pages((unsigned long) adapter->dma_buffer, get_order(DMA_BUFFER_SIZE)); return 0; } /************************************************************ * * Set multicast list * num_addrs==0: clear mc_list * num_addrs==-1: set promiscuous mode * num_addrs>0: set mc_list * ************************************************************/ static void elp_set_mc_list(struct net_device *dev) { elp_device *adapter = (elp_device *) dev->priv; struct dev_mc_list *dmi = dev->mc_list; int i; unsigned long flags; if (elp_debug >= 3) printk(KERN_DEBUG "%s: request to set multicast list\n", dev->name); spin_lock_irqsave(&adapter->lock, flags); if (!(dev->flags & (IFF_PROMISC | IFF_ALLMULTI))) { /* send a "load multicast list" command to the board, max 10 addrs/cmd */ /* if num_addrs==0 the list will be cleared */ adapter->tx_pcb.command = CMD_LOAD_MULTICAST_LIST; adapter->tx_pcb.length = 6 * dev->mc_count; for (i = 0; i < dev->mc_count; i++) { memcpy(adapter->tx_pcb.data.multicast[i], dmi->dmi_addr, 6); dmi = dmi->next; } adapter->got[CMD_LOAD_MULTICAST_LIST] = 0; if (!send_pcb(dev, &adapter->tx_pcb)) printk(KERN_ERR "%s: couldn't send set_multicast command\n", dev->name); else { unsigned long timeout = jiffies + TIMEOUT; while (adapter->got[CMD_LOAD_MULTICAST_LIST] == 0 && time_before(jiffies, timeout)); if (time_after_eq(jiffies, timeout)) { TIMEOUT_MSG(__LINE__); } } if (dev->mc_count) adapter->tx_pcb.data.configure = NO_LOOPBACK | RECV_BROAD | RECV_MULTI; else /* num_addrs == 0 */ adapter->tx_pcb.data.configure = NO_LOOPBACK | RECV_BROAD; } else adapter->tx_pcb.data.configure = NO_LOOPBACK | RECV_PROMISC; /* * configure adapter to receive messages (as specified above) * and wait for response */ if (elp_debug >= 3) printk(KERN_DEBUG "%s: sending 82586 configure command\n", dev->name); adapter->tx_pcb.command = CMD_CONFIGURE_82586; adapter->tx_pcb.length = 2; adapter->got[CMD_CONFIGURE_82586] = 0; if (!send_pcb(dev, &adapter->tx_pcb)) { spin_unlock_irqrestore(&adapter->lock, flags); printk(KERN_ERR "%s: couldn't send 82586 configure command\n", dev->name); } else { unsigned long timeout = jiffies + TIMEOUT; spin_unlock_irqrestore(&adapter->lock, flags); while (adapter->got[CMD_CONFIGURE_82586] == 0 && time_before(jiffies, timeout)); if (time_after_eq(jiffies, timeout)) TIMEOUT_MSG(__LINE__); } } /************************************************************ * * A couple of tests to see if there's 3C505 or not * Called only by elp_autodetect ************************************************************/ static int __init elp_sense(struct net_device *dev) { int addr = dev->base_addr; const char *name = dev->name; byte orig_HSR; if (!request_region(addr, ELP_IO_EXTENT, "3c505")) return -ENODEV; orig_HSR = inb_status(addr); if (elp_debug > 0) printk(search_msg, name, addr); if (orig_HSR == 0xff) { if (elp_debug > 0) printk(notfound_msg, 1); goto out; } /* Wait for a while; the adapter may still be booting up */ if (elp_debug > 0) printk(stilllooking_msg); if (orig_HSR & DIR) { /* If HCR.DIR is up, we pull it down. HSR.DIR should follow. */ outb(0, dev->base_addr + PORT_CONTROL); msleep(300); if (inb_status(addr) & DIR) { if (elp_debug > 0) printk(notfound_msg, 2); goto out; } } else { /* If HCR.DIR is down, we pull it up. HSR.DIR should follow. */ outb(DIR, dev->base_addr + PORT_CONTROL); msleep(300); if (!(inb_status(addr) & DIR)) { if (elp_debug > 0) printk(notfound_msg, 3); goto out; } } /* * It certainly looks like a 3c505. */ if (elp_debug > 0) printk(found_msg); return 0; out: release_region(addr, ELP_IO_EXTENT); return -ENODEV; } /************************************************************* * * Search through addr_list[] and try to find a 3C505 * Called only by eplus_probe *************************************************************/ static int __init elp_autodetect(struct net_device *dev) { int idx = 0; /* if base address set, then only check that address otherwise, run through the table */ if (dev->base_addr != 0) { /* dev->base_addr == 0 ==> plain autodetect */ if (elp_sense(dev) == 0) return dev->base_addr; } else while ((dev->base_addr = addr_list[idx++])) { if (elp_sense(dev) == 0) return dev->base_addr; } /* could not find an adapter */ if (elp_debug > 0) printk(couldnot_msg, dev->name); return 0; /* Because of this, the layer above will return -ENODEV */ } /****************************************************** * * probe for an Etherlink Plus board at the specified address * ******************************************************/ /* There are three situations we need to be able to detect here: * a) the card is idle * b) the card is still booting up * c) the card is stuck in a strange state (some DOS drivers do this) * * In case (a), all is well. In case (b), we wait 10 seconds to see if the * card finishes booting, and carry on if so. In case (c), we do a hard reset, * loop round, and hope for the best. * * This is all very unpleasant, but hopefully avoids the problems with the old * probe code (which had a 15-second delay if the card was idle, and didn't * work at all if it was in a weird state). */ static int __init elplus_setup(struct net_device *dev) { elp_device *adapter = dev->priv; int i, tries, tries1, okay; unsigned long timeout; unsigned long cookie = 0; int err = -ENODEV; /* * setup adapter structure */ dev->base_addr = elp_autodetect(dev); if (!dev->base_addr) return -ENODEV; adapter->send_pcb_semaphore = 0; for (tries1 = 0; tries1 < 3; tries1++) { outb_control((adapter->hcr_val | CMDE) & ~DIR, dev); /* First try to write just one byte, to see if the card is * responding at all normally. */ timeout = jiffies + 5*HZ/100; okay = 0; while (time_before(jiffies, timeout) && !(inb_status(dev->base_addr) & HCRE)); if ((inb_status(dev->base_addr) & HCRE)) { outb_command(0, dev->base_addr); /* send a spurious byte */ timeout = jiffies + 5*HZ/100; while (time_before(jiffies, timeout) && !(inb_status(dev->base_addr) & HCRE)); if (inb_status(dev->base_addr) & HCRE) okay = 1; } if (!okay) { /* Nope, it's ignoring the command register. This means that * either it's still booting up, or it's died. */ printk(KERN_ERR "%s: command register wouldn't drain, ", dev->name); if ((inb_status(dev->base_addr) & 7) == 3) { /* If the adapter status is 3, it *could* still be booting. * Give it the benefit of the doubt for 10 seconds. */ printk("assuming 3c505 still starting\n"); timeout = jiffies + 10*HZ; while (time_before(jiffies, timeout) && (inb_status(dev->base_addr) & 7)); if (inb_status(dev->base_addr) & 7) { printk(KERN_ERR "%s: 3c505 failed to start\n", dev->name); } else { okay = 1; /* It started */ } } else { /* Otherwise, it must just be in a strange * state. We probably need to kick it. */ printk("3c505 is sulking\n"); } } for (tries = 0; tries < 5 && okay; tries++) { /* * Try to set the Ethernet address, to make sure that the board * is working. */ adapter->tx_pcb.command = CMD_STATION_ADDRESS; adapter->tx_pcb.length = 0; cookie = probe_irq_on(); if (!send_pcb(dev, &adapter->tx_pcb)) { printk(KERN_ERR "%s: could not send first PCB\n", dev->name); probe_irq_off(cookie); continue; } if (!receive_pcb(dev, &adapter->rx_pcb)) { printk(KERN_ERR "%s: could not read first PCB\n", dev->name); probe_irq_off(cookie); continue; } if ((adapter->rx_pcb.command != CMD_ADDRESS_RESPONSE) || (adapter->rx_pcb.length != 6)) { printk(KERN_ERR "%s: first PCB wrong (%d, %d)\n", dev->name, adapter->rx_pcb.command, adapter->rx_pcb.length); probe_irq_off(cookie); continue; } goto okay; } /* It's broken. Do a hard reset to re-initialise the board, * and try again. */ printk(KERN_INFO "%s: resetting adapter\n", dev->name); outb_control(adapter->hcr_val | FLSH | ATTN, dev); outb_control(adapter->hcr_val & ~(FLSH | ATTN), dev); } printk(KERN_ERR "%s: failed to initialise 3c505\n", dev->name); goto out; okay: if (dev->irq) { /* Is there a preset IRQ? */ int rpt = probe_irq_off(cookie); if (dev->irq != rpt) { printk(KERN_WARNING "%s: warning, irq %d configured but %d detected\n", dev->name, dev->irq, rpt); } /* if dev->irq == probe_irq_off(cookie), all is well */ } else /* No preset IRQ; just use what we can detect */ dev->irq = probe_irq_off(cookie); switch (dev->irq) { /* Legal, sane? */ case 0: printk(KERN_ERR "%s: IRQ probe failed: check 3c505 jumpers.\n", dev->name); goto out; case 1: case 6: case 8: case 13: printk(KERN_ERR "%s: Impossible IRQ %d reported by probe_irq_off().\n", dev->name, dev->irq); goto out; } /* * Now we have the IRQ number so we can disable the interrupts from * the board until the board is opened. */ outb_control(adapter->hcr_val & ~CMDE, dev); /* * copy Ethernet address into structure */ for (i = 0; i < 6; i++) dev->dev_addr[i] = adapter->rx_pcb.data.eth_addr[i]; /* find a DMA channel */ if (!dev->dma) { if (dev->mem_start) { dev->dma = dev->mem_start & 7; } else { printk(KERN_WARNING "%s: warning, DMA channel not specified, using default\n", dev->name); dev->dma = ELP_DMA; } } /* * print remainder of startup message */ printk(KERN_INFO "%s: 3c505 at %#lx, irq %d, dma %d, ", dev->name, dev->base_addr, dev->irq, dev->dma); printk("addr %02x:%02x:%02x:%02x:%02x:%02x, ", dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); /* * read more information from the adapter */ adapter->tx_pcb.command = CMD_ADAPTER_INFO; adapter->tx_pcb.length = 0; if (!send_pcb(dev, &adapter->tx_pcb) || !receive_pcb(dev, &adapter->rx_pcb) || (adapter->rx_pcb.command != CMD_ADAPTER_INFO_RESPONSE) || (adapter->rx_pcb.length != 10)) { printk("not responding to second PCB\n"); } printk("rev %d.%d, %dk\n", adapter->rx_pcb.data.info.major_vers, adapter->rx_pcb.data.info.minor_vers, adapter->rx_pcb.data.info.RAM_sz); /* * reconfigure the adapter memory to better suit our purposes */ adapter->tx_pcb.command = CMD_CONFIGURE_ADAPTER_MEMORY; adapter->tx_pcb.length = 12; adapter->tx_pcb.data.memconf.cmd_q = 8; adapter->tx_pcb.data.memconf.rcv_q = 8; adapter->tx_pcb.data.memconf.mcast = 10; adapter->tx_pcb.data.memconf.frame = 10; adapter->tx_pcb.data.memconf.rcv_b = 10; adapter->tx_pcb.data.memconf.progs = 0; if (!send_pcb(dev, &adapter->tx_pcb) || !receive_pcb(dev, &adapter->rx_pcb) || (adapter->rx_pcb.command != CMD_CONFIGURE_ADAPTER_RESPONSE) || (adapter->rx_pcb.length != 2)) { printk(KERN_ERR "%s: could not configure adapter memory\n", dev->name); } if (adapter->rx_pcb.data.configure) { printk(KERN_ERR "%s: adapter configuration failed\n", dev->name); } dev->open = elp_open; /* local */ dev->stop = elp_close; /* local */ dev->get_stats = elp_get_stats; /* local */ dev->hard_start_xmit = elp_start_xmit; /* local */ dev->tx_timeout = elp_timeout; /* local */ dev->watchdog_timeo = 10*HZ; dev->set_multicast_list = elp_set_mc_list; /* local */ dev->ethtool_ops = &netdev_ethtool_ops; /* local */ memset(&(adapter->stats), 0, sizeof(struct net_device_stats)); dev->mem_start = dev->mem_end = 0; err = register_netdev(dev); if (err) goto out; return 0; out: release_region(dev->base_addr, ELP_IO_EXTENT); return err; } #ifndef MODULE struct net_device * __init elplus_probe(int unit) { struct net_device *dev = alloc_etherdev(sizeof(elp_device)); int err; if (!dev) return ERR_PTR(-ENOMEM); sprintf(dev->name, "eth%d", unit); netdev_boot_setup_check(dev); err = elplus_setup(dev); if (err) { free_netdev(dev); return ERR_PTR(err); } return dev; } #else static struct net_device *dev_3c505[ELP_MAX_CARDS]; static int io[ELP_MAX_CARDS]; static int irq[ELP_MAX_CARDS]; static int dma[ELP_MAX_CARDS]; module_param_array(io, int, NULL, 0); module_param_array(irq, int, NULL, 0); module_param_array(dma, int, NULL, 0); MODULE_PARM_DESC(io, "EtherLink Plus I/O base address(es)"); MODULE_PARM_DESC(irq, "EtherLink Plus IRQ number(s) (assigned)"); MODULE_PARM_DESC(dma, "EtherLink Plus DMA channel(s)"); int __init init_module(void) { int this_dev, found = 0; for (this_dev = 0; this_dev < ELP_MAX_CARDS; this_dev++) { struct net_device *dev = alloc_etherdev(sizeof(elp_device)); if (!dev) break; dev->irq = irq[this_dev]; dev->base_addr = io[this_dev]; if (dma[this_dev]) { dev->dma = dma[this_dev]; } else { dev->dma = ELP_DMA; printk(KERN_WARNING "3c505.c: warning, using default DMA channel,\n"); } if (io[this_dev] == 0) { if (this_dev) { free_netdev(dev); break; } printk(KERN_NOTICE "3c505.c: module autoprobe not recommended, give io=xx.\n"); } if (elplus_setup(dev) != 0) { printk(KERN_WARNING "3c505.c: Failed to register card at 0x%x.\n", io[this_dev]); free_netdev(dev); break; } dev_3c505[this_dev] = dev; found++; } if (!found) return -ENODEV; return 0; } void __exit cleanup_module(void) { int this_dev; for (this_dev = 0; this_dev < ELP_MAX_CARDS; this_dev++) { struct net_device *dev = dev_3c505[this_dev]; if (dev) { unregister_netdev(dev); release_region(dev->base_addr, ELP_IO_EXTENT); free_netdev(dev); } } } #endif /* MODULE */ MODULE_LICENSE("GPL");