aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/orinoco
diff options
context:
space:
mode:
authorDavid Kilroy <kilroyd@googlemail.com>2009-06-18 18:21:32 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-07-10 15:01:46 -0400
commit5217c571c898371c540e49671600d54346b2e123 (patch)
tree6a43660fb5669c02a0ba11f7a53404790638c7a3 /drivers/net/wireless/orinoco
parent721aa2f75b00399074eb443fdf16d797b4504a36 (diff)
orinoco: convert mode setting to cfg80211
Signed-off-by: David Kilroy <kilroyd@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/orinoco')
-rw-r--r--drivers/net/wireless/orinoco/cfg.c46
-rw-r--r--drivers/net/wireless/orinoco/hw.c12
-rw-r--r--drivers/net/wireless/orinoco/main.c15
-rw-r--r--drivers/net/wireless/orinoco/orinoco.h2
-rw-r--r--drivers/net/wireless/orinoco/wext.c75
5 files changed, 70 insertions, 80 deletions
diff --git a/drivers/net/wireless/orinoco/cfg.c b/drivers/net/wireless/orinoco/cfg.c
index 9a616ddac091..9e59d90b32e4 100644
--- a/drivers/net/wireless/orinoco/cfg.c
+++ b/drivers/net/wireless/orinoco/cfg.c
@@ -93,6 +93,50 @@ int orinoco_wiphy_register(struct wiphy *wiphy)
93 return wiphy_register(wiphy); 93 return wiphy_register(wiphy);
94} 94}
95 95
96const struct cfg80211_ops orinoco_cfg_ops = { 96static int orinoco_change_vif(struct wiphy *wiphy, struct net_device *dev,
97 enum nl80211_iftype type, u32 *flags,
98 struct vif_params *params)
99{
100 struct orinoco_private *priv = wiphy_priv(wiphy);
101 int err = 0;
102 unsigned long lock;
103
104 if (orinoco_lock(priv, &lock) != 0)
105 return -EBUSY;
106
107 switch (type) {
108 case NL80211_IFTYPE_ADHOC:
109 if (!priv->has_ibss && !priv->has_port3)
110 err = -EINVAL;
111 break;
112
113 case NL80211_IFTYPE_STATION:
114 break;
115
116 case NL80211_IFTYPE_MONITOR:
117 if (priv->broken_monitor && !force_monitor) {
118 printk(KERN_WARNING "%s: Monitor mode support is "
119 "buggy in this firmware, not enabling\n",
120 wiphy_name(wiphy));
121 err = -EINVAL;
122 }
123 break;
124
125 default:
126 err = -EINVAL;
127 }
97 128
129 if (!err) {
130 priv->iw_mode = type;
131 set_port_type(priv);
132 err = orinoco_commit(priv);
133 }
134
135 orinoco_unlock(priv, &lock);
136
137 return err;
138}
139
140const struct cfg80211_ops orinoco_cfg_ops = {
141 .change_virtual_intf = orinoco_change_vif,
98}; 142};
diff --git a/drivers/net/wireless/orinoco/hw.c b/drivers/net/wireless/orinoco/hw.c
index 56627d91aa70..4600fe4a7e1c 100644
--- a/drivers/net/wireless/orinoco/hw.c
+++ b/drivers/net/wireless/orinoco/hw.c
@@ -7,7 +7,7 @@
7#include <linux/if_arp.h> 7#include <linux/if_arp.h>
8#include <linux/ieee80211.h> 8#include <linux/ieee80211.h>
9#include <linux/wireless.h> 9#include <linux/wireless.h>
10 10#include <net/cfg80211.h>
11#include "hermes.h" 11#include "hermes.h"
12#include "hermes_rid.h" 12#include "hermes_rid.h"
13#include "orinoco.h" 13#include "orinoco.h"
@@ -409,6 +409,7 @@ void orinoco_get_ratemode_cfg(int ratemode, int *bitrate, int *automatic)
409int orinoco_hw_program_rids(struct orinoco_private *priv) 409int orinoco_hw_program_rids(struct orinoco_private *priv)
410{ 410{
411 struct net_device *dev = priv->ndev; 411 struct net_device *dev = priv->ndev;
412 struct wireless_dev *wdev = netdev_priv(dev);
412 hermes_t *hw = &priv->hw; 413 hermes_t *hw = &priv->hw;
413 int err; 414 int err;
414 struct hermes_idstring idbuf; 415 struct hermes_idstring idbuf;
@@ -431,7 +432,7 @@ int orinoco_hw_program_rids(struct orinoco_private *priv)
431 return err; 432 return err;
432 } 433 }
433 /* Set the channel/frequency */ 434 /* Set the channel/frequency */
434 if (priv->channel != 0 && priv->iw_mode != IW_MODE_INFRA) { 435 if (priv->channel != 0 && priv->iw_mode != NL80211_IFTYPE_STATION) {
435 err = hermes_write_wordrec(hw, USER_BAP, 436 err = hermes_write_wordrec(hw, USER_BAP,
436 HERMES_RID_CNFOWNCHANNEL, 437 HERMES_RID_CNFOWNCHANNEL,
437 priv->channel); 438 priv->channel);
@@ -612,7 +613,7 @@ int orinoco_hw_program_rids(struct orinoco_private *priv)
612 } 613 }
613 } 614 }
614 615
615 if (priv->iw_mode == IW_MODE_MONITOR) { 616 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
616 /* Enable monitor mode */ 617 /* Enable monitor mode */
617 dev->type = ARPHRD_IEEE80211; 618 dev->type = ARPHRD_IEEE80211;
618 err = hermes_docmd_wait(hw, HERMES_CMD_TEST | 619 err = hermes_docmd_wait(hw, HERMES_CMD_TEST |
@@ -630,6 +631,9 @@ int orinoco_hw_program_rids(struct orinoco_private *priv)
630 priv->promiscuous = 0; 631 priv->promiscuous = 0;
631 priv->mc_count = 0; 632 priv->mc_count = 0;
632 633
634 /* Record mode change */
635 wdev->iftype = priv->iw_mode;
636
633 return 0; 637 return 0;
634} 638}
635 639
@@ -884,7 +888,7 @@ int __orinoco_hw_setup_enc(struct orinoco_private *priv)
884 } else 888 } else
885 master_wep_flag = 0; 889 master_wep_flag = 0;
886 890
887 if (priv->iw_mode == IW_MODE_MONITOR) 891 if (priv->iw_mode == NL80211_IFTYPE_MONITOR)
888 master_wep_flag |= HERMES_WEP_HOST_DECRYPT; 892 master_wep_flag |= HERMES_WEP_HOST_DECRYPT;
889 893
890 /* Master WEP setting : on/off */ 894 /* Master WEP setting : on/off */
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c
index dab6649ad0cb..ebf92ae6e365 100644
--- a/drivers/net/wireless/orinoco/main.c
+++ b/drivers/net/wireless/orinoco/main.c
@@ -222,11 +222,11 @@ static int __orinoco_commit(struct orinoco_private *priv);
222void set_port_type(struct orinoco_private *priv) 222void set_port_type(struct orinoco_private *priv)
223{ 223{
224 switch (priv->iw_mode) { 224 switch (priv->iw_mode) {
225 case IW_MODE_INFRA: 225 case NL80211_IFTYPE_STATION:
226 priv->port_type = 1; 226 priv->port_type = 1;
227 priv->createibss = 0; 227 priv->createibss = 0;
228 break; 228 break;
229 case IW_MODE_ADHOC: 229 case NL80211_IFTYPE_ADHOC:
230 if (priv->prefer_port3) { 230 if (priv->prefer_port3) {
231 priv->port_type = 3; 231 priv->port_type = 3;
232 priv->createibss = 0; 232 priv->createibss = 0;
@@ -235,7 +235,7 @@ void set_port_type(struct orinoco_private *priv)
235 priv->createibss = 1; 235 priv->createibss = 1;
236 } 236 }
237 break; 237 break;
238 case IW_MODE_MONITOR: 238 case NL80211_IFTYPE_MONITOR:
239 priv->port_type = 3; 239 priv->port_type = 3;
240 priv->createibss = 0; 240 priv->createibss = 0;
241 break; 241 break;
@@ -359,7 +359,8 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
359 return NETDEV_TX_BUSY; 359 return NETDEV_TX_BUSY;
360 } 360 }
361 361
362 if (!netif_carrier_ok(dev) || (priv->iw_mode == IW_MODE_MONITOR)) { 362 if (!netif_carrier_ok(dev) ||
363 (priv->iw_mode == NL80211_IFTYPE_MONITOR)) {
363 /* Oops, the firmware hasn't established a connection, 364 /* Oops, the firmware hasn't established a connection,
364 silently drop the packet (this seems to be the 365 silently drop the packet (this seems to be the
365 safest approach). */ 366 safest approach). */
@@ -820,7 +821,7 @@ static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
820 } 821 }
821 822
822 /* Handle frames in monitor mode */ 823 /* Handle frames in monitor mode */
823 if (priv->iw_mode == IW_MODE_MONITOR) { 824 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
824 orinoco_rx_monitor(dev, rxfid, desc); 825 orinoco_rx_monitor(dev, rxfid, desc);
825 goto out; 826 goto out;
826 } 827 }
@@ -1331,7 +1332,7 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1331 u16 newstatus; 1332 u16 newstatus;
1332 int connected; 1333 int connected;
1333 1334
1334 if (priv->iw_mode == IW_MODE_MONITOR) 1335 if (priv->iw_mode == NL80211_IFTYPE_MONITOR)
1335 break; 1336 break;
1336 1337
1337 if (len != sizeof(linkstatus)) { 1338 if (len != sizeof(linkstatus)) {
@@ -1981,7 +1982,7 @@ int orinoco_init(struct orinoco_private *priv)
1981 } 1982 }
1982 1983
1983 /* Set up the default configuration */ 1984 /* Set up the default configuration */
1984 priv->iw_mode = IW_MODE_INFRA; 1985 priv->iw_mode = NL80211_IFTYPE_STATION;
1985 /* By default use IEEE/IBSS ad-hoc mode if we have it */ 1986 /* By default use IEEE/IBSS ad-hoc mode if we have it */
1986 priv->prefer_port3 = priv->has_port3 && (!priv->has_ibss); 1987 priv->prefer_port3 = priv->has_port3 && (!priv->has_ibss);
1987 set_port_type(priv); 1988 set_port_type(priv);
diff --git a/drivers/net/wireless/orinoco/orinoco.h b/drivers/net/wireless/orinoco/orinoco.h
index 4ee85f8f6bc7..0c89c281e3e2 100644
--- a/drivers/net/wireless/orinoco/orinoco.h
+++ b/drivers/net/wireless/orinoco/orinoco.h
@@ -121,7 +121,7 @@ struct orinoco_private {
121 unsigned int broken_monitor:1; 121 unsigned int broken_monitor:1;
122 122
123 /* Configuration paramaters */ 123 /* Configuration paramaters */
124 u32 iw_mode; 124 enum nl80211_iftype iw_mode;
125 int prefer_port3; 125 int prefer_port3;
126 u16 encode_alg, wep_restrict, tx_key; 126 u16 encode_alg, wep_restrict, tx_key;
127 struct orinoco_key keys[ORINOCO_MAX_KEYS]; 127 struct orinoco_key keys[ORINOCO_MAX_KEYS];
diff --git a/drivers/net/wireless/orinoco/wext.c b/drivers/net/wireless/orinoco/wext.c
index 4c20b1d5c2a2..9cd991a41ad4 100644
--- a/drivers/net/wireless/orinoco/wext.c
+++ b/drivers/net/wireless/orinoco/wext.c
@@ -52,7 +52,7 @@ static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev)
52 * here so we're not safe to sleep here. */ 52 * here so we're not safe to sleep here. */
53 hermes_inquire(hw, HERMES_INQ_TALLIES); 53 hermes_inquire(hw, HERMES_INQ_TALLIES);
54 54
55 if (priv->iw_mode == IW_MODE_ADHOC) { 55 if (priv->iw_mode == NL80211_IFTYPE_ADHOC) {
56 memset(&wstats->qual, 0, sizeof(wstats->qual)); 56 memset(&wstats->qual, 0, sizeof(wstats->qual));
57 /* If a spy address is defined, we report stats of the 57 /* If a spy address is defined, we report stats of the
58 * first spy address - Jean II */ 58 * first spy address - Jean II */
@@ -124,7 +124,7 @@ static int orinoco_ioctl_setwap(struct net_device *dev,
124 goto out; 124 goto out;
125 } 125 }
126 126
127 if (priv->iw_mode != IW_MODE_INFRA) { 127 if (priv->iw_mode != NL80211_IFTYPE_STATION) {
128 printk(KERN_WARNING "%s: Manual roaming supported only in " 128 printk(KERN_WARNING "%s: Manual roaming supported only in "
129 "managed mode\n", dev->name); 129 "managed mode\n", dev->name);
130 err = -EOPNOTSUPP; 130 err = -EOPNOTSUPP;
@@ -172,65 +172,6 @@ static int orinoco_ioctl_getwap(struct net_device *dev,
172 return err; 172 return err;
173} 173}
174 174
175static int orinoco_ioctl_setmode(struct net_device *dev,
176 struct iw_request_info *info,
177 u32 *mode,
178 char *extra)
179{
180 struct orinoco_private *priv = ndev_priv(dev);
181 int err = -EINPROGRESS; /* Call commit handler */
182 unsigned long flags;
183
184 if (priv->iw_mode == *mode)
185 return 0;
186
187 if (orinoco_lock(priv, &flags) != 0)
188 return -EBUSY;
189
190 switch (*mode) {
191 case IW_MODE_ADHOC:
192 if (!priv->has_ibss && !priv->has_port3)
193 err = -EOPNOTSUPP;
194 break;
195
196 case IW_MODE_INFRA:
197 break;
198
199 case IW_MODE_MONITOR:
200 if (priv->broken_monitor && !force_monitor) {
201 printk(KERN_WARNING "%s: Monitor mode support is "
202 "buggy in this firmware, not enabling\n",
203 dev->name);
204 err = -EOPNOTSUPP;
205 }
206 break;
207
208 default:
209 err = -EOPNOTSUPP;
210 break;
211 }
212
213 if (err == -EINPROGRESS) {
214 priv->iw_mode = *mode;
215 set_port_type(priv);
216 }
217
218 orinoco_unlock(priv, &flags);
219
220 return err;
221}
222
223static int orinoco_ioctl_getmode(struct net_device *dev,
224 struct iw_request_info *info,
225 u32 *mode,
226 char *extra)
227{
228 struct orinoco_private *priv = ndev_priv(dev);
229
230 *mode = priv->iw_mode;
231 return 0;
232}
233
234static int orinoco_ioctl_getiwrange(struct net_device *dev, 175static int orinoco_ioctl_getiwrange(struct net_device *dev,
235 struct iw_request_info *info, 176 struct iw_request_info *info,
236 struct iw_point *rrq, 177 struct iw_point *rrq,
@@ -280,7 +221,7 @@ static int orinoco_ioctl_getiwrange(struct net_device *dev,
280 if (priv->has_wpa) 221 if (priv->has_wpa)
281 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_CIPHER_TKIP; 222 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_CIPHER_TKIP;
282 223
283 if ((priv->iw_mode == IW_MODE_ADHOC) && (!SPY_NUMBER(priv))) { 224 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) && (!SPY_NUMBER(priv))) {
284 /* Quality stats meaningless in ad-hoc mode */ 225 /* Quality stats meaningless in ad-hoc mode */
285 } else { 226 } else {
286 range->max_qual.qual = 0x8b - 0x2f; 227 range->max_qual.qual = 0x8b - 0x2f;
@@ -596,7 +537,7 @@ static int orinoco_ioctl_setfreq(struct net_device *dev,
596 int err = -EINPROGRESS; /* Call commit handler */ 537 int err = -EINPROGRESS; /* Call commit handler */
597 538
598 /* In infrastructure mode the AP sets the channel */ 539 /* In infrastructure mode the AP sets the channel */
599 if (priv->iw_mode == IW_MODE_INFRA) 540 if (priv->iw_mode == NL80211_IFTYPE_STATION)
600 return -EBUSY; 541 return -EBUSY;
601 542
602 if ((frq->e == 0) && (frq->m <= 1000)) { 543 if ((frq->e == 0) && (frq->m <= 1000)) {
@@ -622,7 +563,7 @@ static int orinoco_ioctl_setfreq(struct net_device *dev,
622 return -EBUSY; 563 return -EBUSY;
623 564
624 priv->channel = chan; 565 priv->channel = chan;
625 if (priv->iw_mode == IW_MODE_MONITOR) { 566 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
626 /* Fast channel change - no commit if successful */ 567 /* Fast channel change - no commit if successful */
627 hermes_t *hw = &priv->hw; 568 hermes_t *hw = &priv->hw;
628 err = hermes_docmd_wait(hw, HERMES_CMD_TEST | 569 err = hermes_docmd_wait(hw, HERMES_CMD_TEST |
@@ -1673,7 +1614,7 @@ static int orinoco_ioctl_setscan(struct net_device *dev,
1673 /* In monitor mode, the scan results are always empty. 1614 /* In monitor mode, the scan results are always empty.
1674 * Probe responses are passed to the driver as received 1615 * Probe responses are passed to the driver as received
1675 * frames and could be processed in software. */ 1616 * frames and could be processed in software. */
1676 if (priv->iw_mode == IW_MODE_MONITOR) { 1617 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
1677 err = -EOPNOTSUPP; 1618 err = -EOPNOTSUPP;
1678 goto out; 1619 goto out;
1679 } 1620 }
@@ -2209,8 +2150,8 @@ static const iw_handler orinoco_handler[] = {
2209 STD_IW_HANDLER(SIOCGIWNAME, cfg80211_wext_giwname), 2150 STD_IW_HANDLER(SIOCGIWNAME, cfg80211_wext_giwname),
2210 STD_IW_HANDLER(SIOCSIWFREQ, orinoco_ioctl_setfreq), 2151 STD_IW_HANDLER(SIOCSIWFREQ, orinoco_ioctl_setfreq),
2211 STD_IW_HANDLER(SIOCGIWFREQ, orinoco_ioctl_getfreq), 2152 STD_IW_HANDLER(SIOCGIWFREQ, orinoco_ioctl_getfreq),
2212 STD_IW_HANDLER(SIOCSIWMODE, orinoco_ioctl_setmode), 2153 STD_IW_HANDLER(SIOCSIWMODE, cfg80211_wext_siwmode),
2213 STD_IW_HANDLER(SIOCGIWMODE, orinoco_ioctl_getmode), 2154 STD_IW_HANDLER(SIOCGIWMODE, cfg80211_wext_giwmode),
2214 STD_IW_HANDLER(SIOCSIWSENS, orinoco_ioctl_setsens), 2155 STD_IW_HANDLER(SIOCSIWSENS, orinoco_ioctl_setsens),
2215 STD_IW_HANDLER(SIOCGIWSENS, orinoco_ioctl_getsens), 2156 STD_IW_HANDLER(SIOCGIWSENS, orinoco_ioctl_getsens),
2216 STD_IW_HANDLER(SIOCGIWRANGE, orinoco_ioctl_getiwrange), 2157 STD_IW_HANDLER(SIOCGIWRANGE, orinoco_ioctl_getiwrange),