2009-05-16 12:09:51

by Dave Kilroy

[permalink] [raw]
Subject: [RFC 0/3] orinoco: initiate cfg80211 conversion

The interesting bit of this series is in patch 3, which shamelessly
cribs from Johns rndis_wlan conversion.

I'm interested in hearing if there's a better way to organise the
wiphy/wdev/net_device/orinoco_private structures for orinoco. Also
whether I'm registering with netdev and cfg80211 in the right places.

The driver appears to runs fine. iw list shows the card on phy0. iwconfig
still gets 'IEEE802.11b' for GIWNAME. However the device is still eth1 -
is that expected?

The first two patches are only there because I started marking things
const, and found a couple cfg80211 interfaces wouldn't let me. I couldn't
see anything in the code that needs to modify ops and privid, so I've
marked them const. A build coverring (almost?) all drivers still works,
and I couldn't see any extra sparse complaints. Anyway, I've no particular
attachment to these two patches, so dropping them is fine by me.


Regards,

Dave.
---

David Kilroy (3):
cfg80211: mark ops as pointer to const
cfg80211: mark wiphy->privid as pointer to const
orinoco: initiate cfg80211 conversion

drivers/net/wireless/orinoco/Kconfig | 1 +
drivers/net/wireless/orinoco/Makefile | 2 +-
drivers/net/wireless/orinoco/cfg.c | 82 ++++++++++++++++++++++++++++++++
drivers/net/wireless/orinoco/cfg.h | 18 +++++++
drivers/net/wireless/orinoco/main.c | 28 ++++++++++-
drivers/net/wireless/orinoco/orinoco.h | 7 +++
drivers/net/wireless/orinoco/wext.c | 22 +--------
include/net/cfg80211.h | 4 +-
net/wireless/core.c | 2 +-
net/wireless/core.h | 2 +-
10 files changed, 142 insertions(+), 26 deletions(-)
create mode 100644 drivers/net/wireless/orinoco/cfg.c
create mode 100644 drivers/net/wireless/orinoco/cfg.h



2009-05-16 12:10:01

by Dave Kilroy

[permalink] [raw]
Subject: [RFC 3/3] orinoco: initiate cfg80211 conversion

Initialise and register a wiphy. We can immediately rely on cfg80211 to
handle SIOCGIWNAME.

Signed-off by: David Kilroy <[email protected]>
---
drivers/net/wireless/orinoco/Kconfig | 1 +
drivers/net/wireless/orinoco/Makefile | 2 +-
drivers/net/wireless/orinoco/cfg.c | 82 ++++++++++++++++++++++++++++++++
drivers/net/wireless/orinoco/cfg.h | 18 +++++++
drivers/net/wireless/orinoco/main.c | 28 ++++++++++-
drivers/net/wireless/orinoco/orinoco.h | 7 +++
drivers/net/wireless/orinoco/wext.c | 22 +--------
7 files changed, 138 insertions(+), 22 deletions(-)
create mode 100644 drivers/net/wireless/orinoco/cfg.c
create mode 100644 drivers/net/wireless/orinoco/cfg.h

diff --git a/drivers/net/wireless/orinoco/Kconfig b/drivers/net/wireless/orinoco/Kconfig
index 44411eb..9f8e96e 100644
--- a/drivers/net/wireless/orinoco/Kconfig
+++ b/drivers/net/wireless/orinoco/Kconfig
@@ -5,6 +5,7 @@ config HERMES
select FW_LOADER
select CRYPTO
select CRYPTO_MICHAEL_MIC
+ select CFG80211
---help---
A driver for 802.11b wireless cards based on the "Hermes" or
Intersil HFA384x (Prism 2) MAC controller. This includes the vast
diff --git a/drivers/net/wireless/orinoco/Makefile b/drivers/net/wireless/orinoco/Makefile
index 1fc7409..9abd632 100644
--- a/drivers/net/wireless/orinoco/Makefile
+++ b/drivers/net/wireless/orinoco/Makefile
@@ -1,7 +1,7 @@
#
# Makefile for the orinoco wireless device drivers.
#
-orinoco-objs := main.o fw.o hw.o mic.o scan.o wext.o hermes_dld.o hermes.o
+orinoco-objs := main.o fw.o hw.o mic.o scan.o wext.o hermes_dld.o hermes.o cfg.o

obj-$(CONFIG_HERMES) += orinoco.o
obj-$(CONFIG_PCMCIA_HERMES) += orinoco_cs.o
diff --git a/drivers/net/wireless/orinoco/cfg.c b/drivers/net/wireless/orinoco/cfg.c
new file mode 100644
index 0000000..9cb426a
--- /dev/null
+++ b/drivers/net/wireless/orinoco/cfg.c
@@ -0,0 +1,82 @@
+/* cfg80211 support
+ *
+ * See copyright notice in main.c
+ */
+#include <linux/ieee80211.h>
+#include <net/cfg80211.h>
+#include "orinoco.h"
+
+#include "cfg.h"
+
+/* Get a pointer to orinoco private data from the wiphy */
+#define ophy_priv(wiphy) (*((struct orinoco_private **) wiphy_priv(wiphy)))
+
+/* Supported bitrates. Must agree with hw.c
+ * TODO: are the flags correct? */
+static const struct ieee80211_rate orinoco_rates[] = {
+ { .bitrate = 10 },
+ { .bitrate = 20, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+ { .bitrate = 55, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+ { .bitrate = 110, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+};
+
+static const void * const orinoco_wiphy_privid = &orinoco_wiphy_privid;
+
+/* Called after orinoco_private is allocated.
+ * Which must we do now? Which do we put off until we have firmware?
+ */
+void orinoco_wiphy_init(struct wiphy *wiphy, struct orinoco_private *priv)
+{
+ /* Setup so that we can recover orinoco_private from wiphy */
+ ophy_priv(wiphy) = priv;
+
+ wiphy->privid = orinoco_wiphy_privid;
+
+ priv->wdev.wiphy = wiphy;
+ priv->wdev.iftype = NL80211_IFTYPE_STATION;
+
+ set_wiphy_dev(wiphy, priv->dev);
+}
+
+/* Called after firmware is initialised */
+int orinoco_wiphy_register(struct wiphy *wiphy)
+{
+ struct orinoco_private *priv = ophy_priv(wiphy);
+ int i, channels = 0;
+
+ memcpy(wiphy->perm_addr, priv->ndev->dev_addr, ETH_ALEN);
+
+ wiphy->max_scan_ssids = 1;
+
+ wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
+
+ /* TODO: should we set if we only have demo ad-hoc?
+ * (priv->has_port3)
+ */
+ if (priv->has_ibss)
+ wiphy->interface_modes |= BIT(NL80211_IFTYPE_ADHOC);
+
+ memcpy(priv->rates, orinoco_rates, sizeof(orinoco_rates));
+ priv->band.bitrates = priv->rates;
+ priv->band.n_bitrates = ARRAY_SIZE(orinoco_rates);
+
+ /* Only support channels allowed by the card EEPROM */
+ for (i = 0; i < 14; i++) {
+ if (priv->channel_mask & (1 << i)) {
+ priv->channels[i].center_freq =
+ ieee80211_dsss_chan_to_freq(i+1);
+ channels++;
+ }
+ }
+ priv->band.channels = priv->channels;
+ priv->band.n_channels = channels;
+
+ wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band;
+ wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
+
+ return wiphy_register(wiphy);
+}
+
+const struct cfg80211_ops orinoco_cfg_ops = {
+
+};
diff --git a/drivers/net/wireless/orinoco/cfg.h b/drivers/net/wireless/orinoco/cfg.h
new file mode 100644
index 0000000..6bd3071
--- /dev/null
+++ b/drivers/net/wireless/orinoco/cfg.h
@@ -0,0 +1,18 @@
+/* cfg80211 support.
+ *
+ * See copyright notice in main.c
+ */
+#ifndef ORINOCO_CFG_H
+#define ORINOCO_CFG_H
+
+#include <net/cfg80211.h>
+
+/* Forward declaration */
+struct orinoco_private;
+
+extern const struct cfg80211_ops orinoco_cfg_ops;
+
+void orinoco_wiphy_init(struct wiphy *wiphy, struct orinoco_private *priv);
+int orinoco_wiphy_register(struct wiphy *wiphy);
+
+#endif /* ORINOCO_CFG_H */
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c
index 345593c..d062307 100644
--- a/drivers/net/wireless/orinoco/main.c
+++ b/drivers/net/wireless/orinoco/main.c
@@ -88,6 +88,7 @@
#include <linux/wireless.h>
#include <linux/ieee80211.h>
#include <net/iw_handler.h>
+#include <net/cfg80211.h>

#include "hermes_rid.h"
#include "hermes_dld.h"
@@ -96,6 +97,7 @@
#include "mic.h"
#include "fw.h"
#include "wext.h"
+#include "cfg.h"
#include "main.h"

#include "orinoco.h"
@@ -2502,6 +2504,11 @@ static int orinoco_init(struct net_device *dev)
priv->wpa_ie_len = 0;
priv->wpa_ie = NULL;

+ if (orinoco_wiphy_register(priv->wdev.wiphy)) {
+ err = -ENODEV;
+ goto out;
+ }
+
/* Make the hardware available, as long as it hasn't been
* removed elsewhere (e.g. by PCMCIA hot unplug) */
spin_lock_irq(&priv->lock);
@@ -2533,12 +2540,26 @@ struct net_device
{
struct net_device *dev;
struct orinoco_private *priv;
+ struct wiphy *wiphy;
+
+ /* allocate wiphy
+ * NOTE: We only support a single virtual interface, so wiphy
+ * and wireless_dev are somewhat synonymous for this device.
+ */
+ wiphy = wiphy_new(&orinoco_cfg_ops,
+ sizeof(struct orinoco_private *));
+ if (!wiphy)
+ return NULL;

dev = alloc_etherdev(sizeof(struct orinoco_private) + sizeof_card);
- if (!dev)
+ if (!dev) {
+ wiphy_free(wiphy);
return NULL;
+ }
+
priv = netdev_priv(dev);
priv->ndev = dev;
+
if (sizeof_card)
priv->card = (void *)((unsigned long)priv
+ sizeof(struct orinoco_private));
@@ -2547,6 +2568,7 @@ struct net_device
priv->dev = device;

/* Setup / override net_device fields */
+ dev->ieee80211_ptr = &priv->wdev;
dev->netdev_ops = &orinoco_netdev_ops;
dev->watchdog_timeo = HZ; /* 1 second timeout */
dev->ethtool_ops = &orinoco_ethtool_ops;
@@ -2588,6 +2610,8 @@ struct net_device
/* Register PM notifiers */
orinoco_register_pm_notifier(priv);

+ orinoco_wiphy_init(wiphy, priv);
+
return dev;
}
EXPORT_SYMBOL(alloc_orinocodev);
@@ -2618,7 +2642,9 @@ void free_orinocodev(struct net_device *dev)
kfree(priv->wpa_ie);
orinoco_mic_free(priv);
orinoco_bss_data_free(priv);
+ wiphy_unregister(priv->wdev.wiphy);
free_netdev(dev);
+ wiphy_free(priv->wdev.wiphy);
}
EXPORT_SYMBOL(free_orinocodev);

diff --git a/drivers/net/wireless/orinoco/orinoco.h b/drivers/net/wireless/orinoco/orinoco.h
index 8e5a72c..afc0f6b 100644
--- a/drivers/net/wireless/orinoco/orinoco.h
+++ b/drivers/net/wireless/orinoco/orinoco.h
@@ -14,6 +14,7 @@
#include <linux/netdevice.h>
#include <linux/wireless.h>
#include <net/iw_handler.h>
+#include <net/cfg80211.h>

#include "hermes.h"

@@ -64,9 +65,15 @@ struct firmware;
struct orinoco_private {
void *card; /* Pointer to card dependent structure */
struct device *dev;
+ struct wireless_dev wdev;
int (*hard_reset)(struct orinoco_private *);
int (*stop_fw)(struct orinoco_private *, int);

+ /* cfg80211 */
+ struct ieee80211_supported_band band;
+ struct ieee80211_channel channels[14];
+ struct ieee80211_rate rates[4];
+
/* Synchronisation stuff */
spinlock_t lock;
int hw_unavailable;
diff --git a/drivers/net/wireless/orinoco/wext.c b/drivers/net/wireless/orinoco/wext.c
index 3f08142..7ce471a 100644
--- a/drivers/net/wireless/orinoco/wext.c
+++ b/drivers/net/wireless/orinoco/wext.c
@@ -7,6 +7,7 @@
#include <linux/wireless.h>
#include <linux/ieee80211.h>
#include <net/iw_handler.h>
+#include <net/cfg80211.h>

#include "hermes.h"
#include "hermes_rid.h"
@@ -87,25 +88,6 @@ static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev)
/* Wireless extensions */
/********************************************************************/

-static int orinoco_ioctl_getname(struct net_device *dev,
- struct iw_request_info *info,
- char *name,
- char *extra)
-{
- struct orinoco_private *priv = netdev_priv(dev);
- int numrates;
- int err;
-
- err = orinoco_hw_get_bitratelist(priv, &numrates, NULL, 0);
-
- if (!err && (numrates > 2))
- strcpy(name, "IEEE 802.11b");
- else
- strcpy(name, "IEEE 802.11-DS");
-
- return 0;
-}
-
static int orinoco_ioctl_setwap(struct net_device *dev,
struct iw_request_info *info,
struct sockaddr *ap_addr,
@@ -2258,7 +2240,7 @@ static const struct iw_priv_args orinoco_privtab[] = {
[IW_IOCTL_IDX(id)] = (iw_handler) func
static const iw_handler orinoco_handler[] = {
STD_IW_HANDLER(SIOCSIWCOMMIT, orinoco_ioctl_commit),
- STD_IW_HANDLER(SIOCGIWNAME, orinoco_ioctl_getname),
+ STD_IW_HANDLER(SIOCGIWNAME, cfg80211_wext_giwname),
STD_IW_HANDLER(SIOCSIWFREQ, orinoco_ioctl_setfreq),
STD_IW_HANDLER(SIOCGIWFREQ, orinoco_ioctl_getfreq),
STD_IW_HANDLER(SIOCSIWMODE, orinoco_ioctl_setmode),
--
1.6.0.6


2009-05-16 12:09:53

by Dave Kilroy

[permalink] [raw]
Subject: [RFC 1/3] cfg80211: mark ops as pointer to const

This allows drivers to mark their cfg80211_ops tables const.

Signed-off by: David Kilroy <[email protected]>
---
include/net/cfg80211.h | 2 +-
net/wireless/core.c | 2 +-
net/wireless/core.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 9e17a83..7702715 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1070,7 +1070,7 @@ static inline const char *wiphy_name(struct wiphy *wiphy)
* The returned pointer must be assigned to each netdev's
* ieee80211_ptr for proper operation.
*/
-struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv);
+struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv);

/**
* wiphy_register - register a wiphy with cfg80211
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 47c20eb..98bfd4d 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -228,7 +228,7 @@ int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,

/* exported functions */

-struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv)
+struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv)
{
static int wiphy_counter;

diff --git a/net/wireless/core.h b/net/wireless/core.h
index f14b6c5..725c22e 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -15,7 +15,7 @@
#include "reg.h"

struct cfg80211_registered_device {
- struct cfg80211_ops *ops;
+ const struct cfg80211_ops *ops;
struct list_head list;
/* we hold this mutex during any call so that
* we cannot do multiple calls at once, and also
--
1.6.0.6


2009-05-16 13:41:43

by Dave Kilroy

[permalink] [raw]
Subject: Re: [RFC 3/3] orinoco: initiate cfg80211 conversion

Johannes Berg wrote:
> On Sat, 2009-05-16 at 13:22 +0100, David Kilroy wrote:
>> +/* Supported bitrates. Must agree with hw.c
>> + * TODO: are the flags correct? */
>> +static const struct ieee80211_rate orinoco_rates[] = {
>> + { .bitrate = 10 },
>> + { .bitrate = 20, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
>> + { .bitrate = 55, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
>> + { .bitrate = 110, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
>> +};
>
> Flags look fine from a protocol POV, I don't know whether your hw
> supports short preamble. On the other hand, this is only reported to
> userspace, we don't do anything with it in cfg80211.

I thought that might be the case. I think I'll remove the flags, as
there's some code that indicates only some of the cards support short
preamble.

>> + memcpy(priv->rates, orinoco_rates, sizeof(orinoco_rates));
>> + priv->band.bitrates = priv->rates;
>> + priv->band.n_bitrates = ARRAY_SIZE(orinoco_rates);
>
> Is there a need to copy the rates? Normally you should be able to just
> do
> priv->band.bitrates = orinoco_rates;

I just copied what rndis was doing. I'll do as you recommend.

> When do you load firmware? We try to only load it when the first
> interface is brought up, but that's sometimes problematic because then
> we don't have enough information.

Firmware is loaded when netdev calls ndo_init. I think netdev is
registerred by the hardware modules (airport, _cs etc) shortly after
allocating orinoco_priv.

>> + /* allocate wiphy
>> + * NOTE: We only support a single virtual interface, so wiphy
>> + * and wireless_dev are somewhat synonymous for this device.
>> + */
>> + wiphy = wiphy_new(&orinoco_cfg_ops,
>> + sizeof(struct orinoco_private *));
>> + if (!wiphy)
>> + return NULL;
>
> You could with little effort, support virtual monitor interfaces by just
> passing all frames the firmware gives you to those. Probably not worth
> bothering with though.

Yep. I'll look at supporting monitor interfaces later on.

> Other notes:
> * you could easily migrate over orinoco_ioctl_setmode/getmode
> * if we improve the cfg80211 iwrange implementation a little
> and you register which ciphers you support, you can migrate
> over orinoco_ioctl_getiwrange
> * iwencode(ext) should be fairly easy too
> * just get rid of iwnick
> * rts/frag/retry should be easy to migrate
> * what are ibss ports?
> * scan should be easy to port too
> * iwpriv isn't supported by cfg80211

Yep. I wanted to get the structure layout right before tackling those.

Hermes has different types of 'ports'. We configure the port as either
type 1 or type 3. In addition the port can have what seems to be an ibss
attribute, which allows us to do IEEE ad-hoc. Apparently type 3 allows
us to do a demo ad-hoc mode. Different firmwares need to use different
port settings for different modes of operation (see determine_firmware).

> Anyway looks good for a start, though I would maybe build the structures
> a little different and not put the wdev into priv since priv is per
> hardware.
>
> Generally the layout I recommend would be like this:
>
> +-------------+
> | wiphy |
> +-------------+
> | priv | == wiphy_priv()
> +-------------+
>
> and
>
> +-------------+
> | netdev |
> +-------------+
> | wdev | == netdev_priv()
> +-------------+
>
> For you it doesn't really matter since you can only have one virtual
> interface (well in monitor mode you could have multiple but that seems
> pointless) -- it's still more in line with what other drivers are doing
> though.

That makes a bit more sense. I'll try restructure things this way to be
consistent.


Thanks for the feedback!


Dave.

2009-05-16 12:21:14

by Johannes Berg

[permalink] [raw]
Subject: Re: [RFC 2/3] cfg80211: mark wiphy->privid as pointer to const

On Sat, 2009-05-16 at 13:22 +0100, David Kilroy wrote:
> This allows drivers to use a const pointer as the privid without a cast.

Same here.

> Signed-off by: David Kilroy <[email protected]>

Acked-by: Johannes Berg <[email protected]>

> ---
> include/net/cfg80211.h | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
> index 7702715..0639962 100644
> --- a/include/net/cfg80211.h
> +++ b/include/net/cfg80211.h
> @@ -994,7 +994,7 @@ struct wiphy {
> * know whether it points to a wiphy your driver has registered
> * or not. Assign this to something global to your driver to
> * help determine whether you own this wiphy or not. */
> - void *privid;
> + const void *privid;
>
> struct ieee80211_supported_band *bands[IEEE80211_NUM_BANDS];
>


Attachments:
signature.asc (801.00 B)
This is a digitally signed message part

2009-05-16 12:09:57

by Dave Kilroy

[permalink] [raw]
Subject: [RFC 2/3] cfg80211: mark wiphy->privid as pointer to const

This allows drivers to use a const pointer as the privid without a cast.

Signed-off by: David Kilroy <[email protected]>
---
include/net/cfg80211.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 7702715..0639962 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -994,7 +994,7 @@ struct wiphy {
* know whether it points to a wiphy your driver has registered
* or not. Assign this to something global to your driver to
* help determine whether you own this wiphy or not. */
- void *privid;
+ const void *privid;

struct ieee80211_supported_band *bands[IEEE80211_NUM_BANDS];

--
1.6.0.6


2009-05-16 12:20:31

by Johannes Berg

[permalink] [raw]
Subject: Re: [RFC 1/3] cfg80211: mark ops as pointer to const

On Sat, 2009-05-16 at 13:22 +0100, David Kilroy wrote:
> This allows drivers to mark their cfg80211_ops tables const.

Seems fine to me. Somehow I forgot to mark lots of things const in
cfg80211...

> Signed-off by: David Kilroy <[email protected]>

Acked-by: Johannes Berg <[email protected]>

> ---
> include/net/cfg80211.h | 2 +-
> net/wireless/core.c | 2 +-
> net/wireless/core.h | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
> index 9e17a83..7702715 100644
> --- a/include/net/cfg80211.h
> +++ b/include/net/cfg80211.h
> @@ -1070,7 +1070,7 @@ static inline const char *wiphy_name(struct wiphy *wiphy)
> * The returned pointer must be assigned to each netdev's
> * ieee80211_ptr for proper operation.
> */
> -struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv);
> +struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv);
>
> /**
> * wiphy_register - register a wiphy with cfg80211
> diff --git a/net/wireless/core.c b/net/wireless/core.c
> index 47c20eb..98bfd4d 100644
> --- a/net/wireless/core.c
> +++ b/net/wireless/core.c
> @@ -228,7 +228,7 @@ int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,
>
> /* exported functions */
>
> -struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv)
> +struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv)
> {
> static int wiphy_counter;
>
> diff --git a/net/wireless/core.h b/net/wireless/core.h
> index f14b6c5..725c22e 100644
> --- a/net/wireless/core.h
> +++ b/net/wireless/core.h
> @@ -15,7 +15,7 @@
> #include "reg.h"
>
> struct cfg80211_registered_device {
> - struct cfg80211_ops *ops;
> + const struct cfg80211_ops *ops;
> struct list_head list;
> /* we hold this mutex during any call so that
> * we cannot do multiple calls at once, and also


Attachments:
signature.asc (801.00 B)
This is a digitally signed message part

2009-05-16 12:46:02

by Johannes Berg

[permalink] [raw]
Subject: Re: [RFC 3/3] orinoco: initiate cfg80211 conversion

On Sat, 2009-05-16 at 13:22 +0100, David Kilroy wrote:

> +/* Supported bitrates. Must agree with hw.c
> + * TODO: are the flags correct? */
> +static const struct ieee80211_rate orinoco_rates[] = {
> + { .bitrate = 10 },
> + { .bitrate = 20, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
> + { .bitrate = 55, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
> + { .bitrate = 110, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
> +};

Flags look fine from a protocol POV, I don't know whether your hw
supports short preamble. On the other hand, this is only reported to
userspace, we don't do anything with it in cfg80211.

> +/* Called after orinoco_private is allocated.
> + * Which must we do now? Which do we put off until we have firmware?
> + */

Generally, try to do things as early as possible.

> +void orinoco_wiphy_init(struct wiphy *wiphy, struct orinoco_private *priv)
> +{
> + /* Setup so that we can recover orinoco_private from wiphy */
> + ophy_priv(wiphy) = priv;
> +
> + wiphy->privid = orinoco_wiphy_privid;
> +
> + priv->wdev.wiphy = wiphy;
> + priv->wdev.iftype = NL80211_IFTYPE_STATION;
> +
> + set_wiphy_dev(wiphy, priv->dev);
> +}
> +
> +/* Called after firmware is initialised */
> +int orinoco_wiphy_register(struct wiphy *wiphy)
> +{
> + struct orinoco_private *priv = ophy_priv(wiphy);
> + int i, channels = 0;
> +
> + memcpy(wiphy->perm_addr, priv->ndev->dev_addr, ETH_ALEN);
> +
> + wiphy->max_scan_ssids = 1;
> +
> + wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
> +
> + /* TODO: should we set if we only have demo ad-hoc?
> + * (priv->has_port3)
> + */
> + if (priv->has_ibss)
> + wiphy->interface_modes |= BIT(NL80211_IFTYPE_ADHOC);
> +
> + memcpy(priv->rates, orinoco_rates, sizeof(orinoco_rates));
> + priv->band.bitrates = priv->rates;
> + priv->band.n_bitrates = ARRAY_SIZE(orinoco_rates);

Is there a need to copy the rates? Normally you should be able to just
do
priv->band.bitrates = orinoco_rates;

> + /* Only support channels allowed by the card EEPROM */
> + for (i = 0; i < 14; i++) {
> + if (priv->channel_mask & (1 << i)) {
> + priv->channels[i].center_freq =
> + ieee80211_dsss_chan_to_freq(i+1);
> + channels++;
> + }
> + }
> + priv->band.channels = priv->channels;
> + priv->band.n_channels = channels;
> +
> + wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band;
> + wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
> +
> + return wiphy_register(wiphy);
> +}

When do you load firmware? We try to only load it when the first
interface is brought up, but that's sometimes problematic because then
we don't have enough information.

> +const struct cfg80211_ops orinoco_cfg_ops = {
> +
> +};

Heh.

> #include "orinoco.h"
> @@ -2502,6 +2504,11 @@ static int orinoco_init(struct net_device *dev)
> priv->wpa_ie_len = 0;
> priv->wpa_ie = NULL;
>
> + if (orinoco_wiphy_register(priv->wdev.wiphy)) {
> + err = -ENODEV;
> + goto out;
> + }
> +
> /* Make the hardware available, as long as it hasn't been
> * removed elsewhere (e.g. by PCMCIA hot unplug) */
> spin_lock_irq(&priv->lock);
> @@ -2533,12 +2540,26 @@ struct net_device
> {
> struct net_device *dev;
> struct orinoco_private *priv;
> + struct wiphy *wiphy;
> +
> + /* allocate wiphy
> + * NOTE: We only support a single virtual interface, so wiphy
> + * and wireless_dev are somewhat synonymous for this device.
> + */
> + wiphy = wiphy_new(&orinoco_cfg_ops,
> + sizeof(struct orinoco_private *));
> + if (!wiphy)
> + return NULL;

You could with little effort, support virtual monitor interfaces by just
passing all frames the firmware gives you to those. Probably not worth
bothering with though.

Other notes:
* you could easily migrate over orinoco_ioctl_setmode/getmode
* if we improve the cfg80211 iwrange implementation a little
and you register which ciphers you support, you can migrate
over orinoco_ioctl_getiwrange
* iwencode(ext) should be fairly easy too
* just get rid of iwnick
* rts/frag/retry should be easy to migrate
* what are ibss ports?
* scan should be easy to port too
* iwpriv isn't supported by cfg80211

Anyway looks good for a start, though I would maybe build the structures
a little different and not put the wdev into priv since priv is per
hardware.

Generally the layout I recommend would be like this:

+-------------+
| wiphy |
+-------------+
| priv | == wiphy_priv()
+-------------+

and

+-------------+
| netdev |
+-------------+
| wdev | == netdev_priv()
+-------------+

For you it doesn't really matter since you can only have one virtual
interface (well in monitor mode you could have multiple but that seems
pointless) -- it's still more in line with what other drivers are doing
though.

johannes


Attachments:
signature.asc (801.00 B)
This is a digitally signed message part

2009-05-16 22:22:10

by Dave Kilroy

[permalink] [raw]
Subject: [RFC 3/3] orinoco: initiate cfg80211 conversion

Initialise and register a wiphy.

Move the driver private structure from net_device to the new wiphy, and
store a wireless_dev structure in the net_device private area. 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. Almost all 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 <[email protected]>
---
The big change from the last post is the move of orinoco_private to the
wiphy, and placing wdev in net_device. Many more files are touched, but
they're all s/netdev_priv/ndev_priv/. Things still seem to work.

Also:
* removed the short preamble flags on the bitrates. These are only
supported on Symbol and Intersil firmwares, and the flag only affects
display.
* point band bitrates at the static local array, rather than memcpy.
* unregister the wiphy slightly earlier
---
drivers/net/wireless/orinoco/Kconfig | 1 +
drivers/net/wireless/orinoco/Makefile | 2 +-
drivers/net/wireless/orinoco/airport.c | 8 +-
drivers/net/wireless/orinoco/cfg.c | 71 +++++++++++++++
drivers/net/wireless/orinoco/cfg.h | 15 +++
drivers/net/wireless/orinoco/main.c | 121 +++++++++++++++++++------
drivers/net/wireless/orinoco/orinoco.h | 10 ++
drivers/net/wireless/orinoco/orinoco_cs.c | 10 +-
drivers/net/wireless/orinoco/orinoco_nortel.c | 4 +-
drivers/net/wireless/orinoco/orinoco_pci.c | 4 +-
drivers/net/wireless/orinoco/orinoco_pci.h | 4 +-
drivers/net/wireless/orinoco/orinoco_plx.c | 4 +-
drivers/net/wireless/orinoco/orinoco_tmd.c | 4 +-
drivers/net/wireless/orinoco/spectrum_cs.c | 10 +-
drivers/net/wireless/orinoco/wext.c | 110 ++++++++++-------------
15 files changed, 259 insertions(+), 119 deletions(-)
create mode 100644 drivers/net/wireless/orinoco/cfg.c
create mode 100644 drivers/net/wireless/orinoco/cfg.h

diff --git a/drivers/net/wireless/orinoco/Kconfig b/drivers/net/wireless/orinoco/Kconfig
index 44411eb..9f8e96e 100644
--- a/drivers/net/wireless/orinoco/Kconfig
+++ b/drivers/net/wireless/orinoco/Kconfig
@@ -5,6 +5,7 @@ config HERMES
select FW_LOADER
select CRYPTO
select CRYPTO_MICHAEL_MIC
+ select CFG80211
---help---
A driver for 802.11b wireless cards based on the "Hermes" or
Intersil HFA384x (Prism 2) MAC controller. This includes the vast
diff --git a/drivers/net/wireless/orinoco/Makefile b/drivers/net/wireless/orinoco/Makefile
index 1fc7409..9abd632 100644
--- a/drivers/net/wireless/orinoco/Makefile
+++ b/drivers/net/wireless/orinoco/Makefile
@@ -1,7 +1,7 @@
#
# Makefile for the orinoco wireless device drivers.
#
-orinoco-objs := main.o fw.o hw.o mic.o scan.o wext.o hermes_dld.o hermes.o
+orinoco-objs := main.o fw.o hw.o mic.o scan.o wext.o hermes_dld.o hermes.o cfg.o

obj-$(CONFIG_HERMES) += orinoco.o
obj-$(CONFIG_PCMCIA_HERMES) += orinoco_cs.o
diff --git a/drivers/net/wireless/orinoco/airport.c b/drivers/net/wireless/orinoco/airport.c
index 8c4065f..66f816e 100644
--- a/drivers/net/wireless/orinoco/airport.c
+++ b/drivers/net/wireless/orinoco/airport.c
@@ -35,7 +35,7 @@ static int
airport_suspend(struct macio_dev *mdev, pm_message_t state)
{
struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
unsigned long flags;
int err;

@@ -70,7 +70,7 @@ static int
airport_resume(struct macio_dev *mdev)
{
struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
unsigned long flags;
int err;

@@ -112,7 +112,7 @@ static int
airport_detach(struct macio_dev *mdev)
{
struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev);
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct airport *card = priv->card;

if (card->ndev_registered)
@@ -191,7 +191,7 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
printk(KERN_ERR PFX "Cannot allocate network device\n");
return -ENODEV;
}
- priv = netdev_priv(dev);
+ priv = ndev_priv(dev);
card = priv->card;

hw = &priv->hw;
diff --git a/drivers/net/wireless/orinoco/cfg.c b/drivers/net/wireless/orinoco/cfg.c
new file mode 100644
index 0000000..9aacaa1
--- /dev/null
+++ b/drivers/net/wireless/orinoco/cfg.c
@@ -0,0 +1,71 @@
+/* cfg80211 support
+ *
+ * See copyright notice in main.c
+ */
+#include <linux/ieee80211.h>
+#include <net/cfg80211.h>
+#include "orinoco.h"
+
+#include "cfg.h"
+
+/* Supported bitrates. Must agree with hw.c */
+static struct ieee80211_rate orinoco_rates[] = {
+ { .bitrate = 10 },
+ { .bitrate = 20 },
+ { .bitrate = 55 },
+ { .bitrate = 110 },
+};
+
+static const void * const orinoco_wiphy_privid = &orinoco_wiphy_privid;
+
+/* Called after orinoco_private is allocated. */
+void orinoco_wiphy_init(struct wiphy *wiphy)
+{
+ struct orinoco_private *priv = wiphy_priv(wiphy);
+
+ wiphy->privid = orinoco_wiphy_privid;
+
+ set_wiphy_dev(wiphy, priv->dev);
+}
+
+/* Called after firmware is initialised */
+int orinoco_wiphy_register(struct wiphy *wiphy)
+{
+ struct orinoco_private *priv = wiphy_priv(wiphy);
+ int i, channels = 0;
+
+ memcpy(wiphy->perm_addr, priv->ndev->dev_addr, ETH_ALEN);
+
+ wiphy->max_scan_ssids = 1;
+
+ wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
+
+ /* TODO: should we set if we only have demo ad-hoc?
+ * (priv->has_port3)
+ */
+ if (priv->has_ibss)
+ wiphy->interface_modes |= BIT(NL80211_IFTYPE_ADHOC);
+
+ priv->band.bitrates = orinoco_rates;
+ priv->band.n_bitrates = ARRAY_SIZE(orinoco_rates);
+
+ /* Only support channels allowed by the card EEPROM */
+ for (i = 0; i < 14; i++) {
+ if (priv->channel_mask & (1 << i)) {
+ priv->channels[i].center_freq =
+ ieee80211_dsss_chan_to_freq(i+1);
+ channels++;
+ }
+ }
+ priv->band.channels = priv->channels;
+ priv->band.n_channels = channels;
+
+ wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band;
+ wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
+
+ return wiphy_register(wiphy);
+}
+
+const struct cfg80211_ops orinoco_cfg_ops = {
+
+};
diff --git a/drivers/net/wireless/orinoco/cfg.h b/drivers/net/wireless/orinoco/cfg.h
new file mode 100644
index 0000000..3ddc96a
--- /dev/null
+++ b/drivers/net/wireless/orinoco/cfg.h
@@ -0,0 +1,15 @@
+/* cfg80211 support.
+ *
+ * See copyright notice in main.c
+ */
+#ifndef ORINOCO_CFG_H
+#define ORINOCO_CFG_H
+
+#include <net/cfg80211.h>
+
+extern const struct cfg80211_ops orinoco_cfg_ops;
+
+void orinoco_wiphy_init(struct wiphy *wiphy);
+int orinoco_wiphy_register(struct wiphy *wiphy);
+
+#endif /* ORINOCO_CFG_H */
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c
index 345593c..53c53dd 100644
--- a/drivers/net/wireless/orinoco/main.c
+++ b/drivers/net/wireless/orinoco/main.c
@@ -88,6 +88,7 @@
#include <linux/wireless.h>
#include <linux/ieee80211.h>
#include <net/iw_handler.h>
+#include <net/cfg80211.h>

#include "hermes_rid.h"
#include "hermes_dld.h"
@@ -96,6 +97,7 @@
#include "mic.h"
#include "fw.h"
#include "wext.h"
+#include "cfg.h"
#include "main.h"

#include "orinoco.h"
@@ -247,7 +249,7 @@ void set_port_type(struct orinoco_private *priv)

static int orinoco_open(struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
unsigned long flags;
int err;

@@ -266,7 +268,7 @@ static int orinoco_open(struct net_device *dev)

static int orinoco_stop(struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int err = 0;

/* We mustn't use orinoco_lock() here, because we need to be
@@ -285,14 +287,14 @@ static int orinoco_stop(struct net_device *dev)

static struct net_device_stats *orinoco_get_stats(struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);

return &priv->stats;
}

static void orinoco_set_multicast_list(struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
unsigned long flags;

if (orinoco_lock(priv, &flags) != 0) {
@@ -307,7 +309,7 @@ static void orinoco_set_multicast_list(struct net_device *dev)

static int orinoco_change_mtu(struct net_device *dev, int new_mtu)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);

if ((new_mtu < ORINOCO_MIN_MTU) || (new_mtu > ORINOCO_MAX_MTU))
return -EINVAL;
@@ -328,7 +330,7 @@ static int orinoco_change_mtu(struct net_device *dev, int new_mtu)

static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct net_device_stats *stats = &priv->stats;
hermes_t *hw = &priv->hw;
int err = 0;
@@ -518,7 +520,7 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)

static void __orinoco_ev_alloc(struct net_device *dev, hermes_t *hw)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
u16 fid = hermes_read_regn(hw, ALLOCFID);

if (fid != priv->txfid) {
@@ -533,7 +535,7 @@ static void __orinoco_ev_alloc(struct net_device *dev, hermes_t *hw)

static void __orinoco_ev_tx(struct net_device *dev, hermes_t *hw)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct net_device_stats *stats = &priv->stats;

stats->tx_packets++;
@@ -545,7 +547,7 @@ static void __orinoco_ev_tx(struct net_device *dev, hermes_t *hw)

static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct net_device_stats *stats = &priv->stats;
u16 fid = hermes_read_regn(hw, TXCOMPLFID);
u16 status;
@@ -601,7 +603,7 @@ static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw)

static void orinoco_tx_timeout(struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct net_device_stats *stats = &priv->stats;
struct hermes *hw = &priv->hw;

@@ -650,7 +652,7 @@ static void orinoco_stat_gather(struct net_device *dev,
struct sk_buff *skb,
struct hermes_rx_descriptor *desc)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);

/* Using spy support with lots of Rx packets, like in an
* infrastructure (AP), will really slow down everything, because
@@ -687,7 +689,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
int err;
int len;
struct sk_buff *skb;
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct net_device_stats *stats = &priv->stats;
hermes_t *hw = &priv->hw;

@@ -778,7 +780,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,

static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct net_device_stats *stats = &priv->stats;
struct iw_statistics *wstats = &priv->wstats;
struct sk_buff *skb = NULL;
@@ -902,7 +904,7 @@ static void orinoco_rx(struct net_device *dev,
struct hermes_rx_descriptor *desc,
struct sk_buff *skb)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct net_device_stats *stats = &priv->stats;
u16 status, fc;
int length;
@@ -1017,7 +1019,7 @@ static void orinoco_rx(struct net_device *dev,
static void orinoco_rx_isr_tasklet(unsigned long data)
{
struct net_device *dev = (struct net_device *) data;
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct orinoco_rx_data *rx_data, *temp;
struct hermes_rx_descriptor *desc;
struct sk_buff *skb;
@@ -1262,7 +1264,7 @@ static void orinoco_send_wevents(struct work_struct *work)

static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
u16 infofid;
struct {
__le16 len;
@@ -1515,7 +1517,7 @@ static void __orinoco_ev_infdrop(struct net_device *dev, hermes_t *hw)

int __orinoco_up(struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct hermes *hw = &priv->hw;
int err;

@@ -1545,7 +1547,7 @@ EXPORT_SYMBOL(__orinoco_up);

int __orinoco_down(struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct hermes *hw = &priv->hw;
int err;

@@ -1577,7 +1579,7 @@ EXPORT_SYMBOL(__orinoco_down);

static int orinoco_allocate_fid(struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct hermes *hw = &priv->hw;
int err;

@@ -1597,7 +1599,7 @@ static int orinoco_allocate_fid(struct net_device *dev)

int orinoco_reinit_firmware(struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct hermes *hw = &priv->hw;
int err;

@@ -1616,7 +1618,7 @@ EXPORT_SYMBOL(orinoco_reinit_firmware);

int __orinoco_program_rids(struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
hermes_t *hw = &priv->hw;
int err;
struct hermes_idstring idbuf;
@@ -1847,7 +1849,7 @@ int __orinoco_program_rids(struct net_device *dev)
static void
__orinoco_set_multicast_list(struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int err = 0;
int promisc, mc_count;

@@ -1961,7 +1963,7 @@ static void __orinoco_ev_wterr(struct net_device *dev, hermes_t *hw)
irqreturn_t orinoco_interrupt(int irq, void *dev_id)
{
struct net_device *dev = dev_id;
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
hermes_t *hw = &priv->hw;
int count = MAX_IRQLOOPS_PER_IRQ;
u16 evstat, events;
@@ -2113,7 +2115,7 @@ static inline fwtype_t determine_firmware_type(struct comp_id *nic_id)
/* Set priv->firmware type, determine firmware properties */
static int determine_firmware(struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
hermes_t *hw = &priv->hw;
int err;
struct comp_id nic_id, sta_id;
@@ -2311,7 +2313,8 @@ static int determine_firmware(struct net_device *dev)

static int orinoco_init(struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct wireless_dev *wdev = netdev_priv(dev);
+ struct orinoco_private *priv = wdev_priv(wdev);
hermes_t *hw = &priv->hw;
int err = 0;
struct hermes_idstring nickbuf;
@@ -2502,6 +2505,11 @@ static int orinoco_init(struct net_device *dev)
priv->wpa_ie_len = 0;
priv->wpa_ie = NULL;

+ if (orinoco_wiphy_register(wdev->wiphy)) {
+ err = -ENODEV;
+ goto out;
+ }
+
/* Make the hardware available, as long as it hasn't been
* removed elsewhere (e.g. by PCMCIA hot unplug) */
spin_lock_irq(&priv->lock);
@@ -2525,6 +2533,31 @@ static const struct net_device_ops orinoco_netdev_ops = {
.ndo_get_stats = orinoco_get_stats,
};

+/* Allocate private data.
+ *
+ * This driver has a number of structures associated with it
+ * netdev - Net device structure for each network interface
+ * wiphy - structure associated with wireless phy
+ * wireless_dev (wdev) - structure for each wireless interface
+ * hw - structure for hermes chip info
+ * card - card specific structure for use by the card driver
+ * (airport, orinoco_cs)
+ * priv - orinoco private data
+ * device - generic linux device structure
+ *
+ * +---------+ +---------+
+ * | wiphy | | netdev |
+ * | +-------+ | +-------+
+ * | | priv | | | wdev |
+ * | | +-----+ +-+-------+
+ * | | | hw |
+ * | +-+-----+
+ * | | card |
+ * +-+-------+
+ *
+ * priv has a link to netdev and device
+ * wdev has a link to wiphy
+ */
struct net_device
*alloc_orinocodev(int sizeof_card,
struct device *device,
@@ -2533,12 +2566,27 @@ struct net_device
{
struct net_device *dev;
struct orinoco_private *priv;
+ struct wireless_dev *wdev;
+ struct wiphy *wiphy;
+
+ /* allocate wiphy
+ * NOTE: We only support a single virtual interface
+ * but this may change when monitor mode is added
+ */
+ wiphy = wiphy_new(&orinoco_cfg_ops,
+ sizeof(struct orinoco_private) + sizeof_card);
+ if (!wiphy)
+ return NULL;

- dev = alloc_etherdev(sizeof(struct orinoco_private) + sizeof_card);
- if (!dev)
+ dev = alloc_etherdev(sizeof(struct wireless_dev));
+ if (!dev) {
+ wiphy_free(wiphy);
return NULL;
- priv = netdev_priv(dev);
+ }
+
+ priv = wiphy_priv(wiphy);
priv->ndev = dev;
+
if (sizeof_card)
priv->card = (void *)((unsigned long)priv
+ sizeof(struct orinoco_private));
@@ -2546,7 +2594,15 @@ struct net_device
priv->card = NULL;
priv->dev = device;

+ orinoco_wiphy_init(wiphy);
+
+ /* Initialise wireless_dev */
+ wdev = netdev_priv(dev);
+ wdev->wiphy = wiphy;
+ wdev->iftype = NL80211_IFTYPE_STATION;
+
/* Setup / override net_device fields */
+ dev->ieee80211_ptr = wdev;
dev->netdev_ops = &orinoco_netdev_ops;
dev->watchdog_timeo = HZ; /* 1 second timeout */
dev->ethtool_ops = &orinoco_ethtool_ops;
@@ -2594,9 +2650,13 @@ EXPORT_SYMBOL(alloc_orinocodev);

void free_orinocodev(struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct wireless_dev *wdev = netdev_priv(dev);
+ struct orinoco_private *priv = wdev_priv(wdev);
+ struct wiphy *wiphy = wdev->wiphy;
struct orinoco_rx_data *rx_data, *temp;

+ wiphy_unregister(wiphy);
+
/* If the tasklet is scheduled when we call tasklet_kill it
* will run one final time. However the tasklet will only
* drain priv->rx_list if the hw is still available. */
@@ -2619,13 +2679,14 @@ void free_orinocodev(struct net_device *dev)
orinoco_mic_free(priv);
orinoco_bss_data_free(priv);
free_netdev(dev);
+ wiphy_free(wiphy);
}
EXPORT_SYMBOL(free_orinocodev);

static void orinoco_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);

strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1);
strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1);
diff --git a/drivers/net/wireless/orinoco/orinoco.h b/drivers/net/wireless/orinoco/orinoco.h
index 8e5a72c..34f956a 100644
--- a/drivers/net/wireless/orinoco/orinoco.h
+++ b/drivers/net/wireless/orinoco/orinoco.h
@@ -14,6 +14,7 @@
#include <linux/netdevice.h>
#include <linux/wireless.h>
#include <net/iw_handler.h>
+#include <net/cfg80211.h>

#include "hermes.h"

@@ -67,6 +68,9 @@ struct orinoco_private {
int (*hard_reset)(struct orinoco_private *);
int (*stop_fw)(struct orinoco_private *, int);

+ struct ieee80211_supported_band band;
+ struct ieee80211_channel channels[14];
+
/* Synchronisation stuff */
spinlock_t lock;
int hw_unavailable;
@@ -215,4 +219,10 @@ static inline void orinoco_unlock(struct orinoco_private *priv,
spin_unlock_irqrestore(&priv->lock, *flags);
}

+/*** Navigate from net_device to orinoco_private ***/
+static inline struct orinoco_private *ndev_priv(struct net_device *dev)
+{
+ struct wireless_dev *wdev = netdev_priv(dev);
+ return wdev_priv(wdev);
+}
#endif /* _ORINOCO_H */
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c
index b381aed..4edec8f 100644
--- a/drivers/net/wireless/orinoco/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco/orinoco_cs.c
@@ -114,7 +114,7 @@ orinoco_cs_probe(struct pcmcia_device *link)
orinoco_cs_hard_reset, NULL);
if (!dev)
return -ENOMEM;
- priv = netdev_priv(dev);
+ priv = ndev_priv(dev);
card = priv->card;

/* Link both structures together */
@@ -240,7 +240,7 @@ static int
orinoco_cs_config(struct pcmcia_device *link)
{
struct net_device *dev = link->priv;
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct orinoco_pccard *card = priv->card;
hermes_t *hw = &priv->hw;
int last_fn, last_ret;
@@ -337,7 +337,7 @@ static void
orinoco_cs_release(struct pcmcia_device *link)
{
struct net_device *dev = link->priv;
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
unsigned long flags;

/* We're committed to taking the device away now, so mark the
@@ -354,7 +354,7 @@ orinoco_cs_release(struct pcmcia_device *link)
static int orinoco_cs_suspend(struct pcmcia_device *link)
{
struct net_device *dev = link->priv;
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct orinoco_pccard *card = priv->card;
int err = 0;
unsigned long flags;
@@ -382,7 +382,7 @@ static int orinoco_cs_suspend(struct pcmcia_device *link)
static int orinoco_cs_resume(struct pcmcia_device *link)
{
struct net_device *dev = link->priv;
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct orinoco_pccard *card = priv->card;
int err = 0;
unsigned long flags;
diff --git a/drivers/net/wireless/orinoco/orinoco_nortel.c b/drivers/net/wireless/orinoco/orinoco_nortel.c
index b017262..75ed160 100644
--- a/drivers/net/wireless/orinoco/orinoco_nortel.c
+++ b/drivers/net/wireless/orinoco/orinoco_nortel.c
@@ -189,7 +189,7 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev,
goto fail_alloc;
}

- priv = netdev_priv(dev);
+ priv = ndev_priv(dev);
card = priv->card;
card->bridge_io = bridge_io;
card->attr_io = attr_io;
@@ -257,7 +257,7 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev,
static void __devexit orinoco_nortel_remove_one(struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct orinoco_pci_card *card = priv->card;

/* Clear LEDs */
diff --git a/drivers/net/wireless/orinoco/orinoco_pci.c b/drivers/net/wireless/orinoco/orinoco_pci.c
index 78cafff..43094ed 100644
--- a/drivers/net/wireless/orinoco/orinoco_pci.c
+++ b/drivers/net/wireless/orinoco/orinoco_pci.c
@@ -147,7 +147,7 @@ static int orinoco_pci_init_one(struct pci_dev *pdev,
goto fail_alloc;
}

- priv = netdev_priv(dev);
+ priv = ndev_priv(dev);
card = priv->card;
SET_NETDEV_DEV(dev, &pdev->dev);

@@ -201,7 +201,7 @@ static int orinoco_pci_init_one(struct pci_dev *pdev,
static void __devexit orinoco_pci_remove_one(struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);

unregister_netdev(dev);
free_irq(pdev->irq, dev);
diff --git a/drivers/net/wireless/orinoco/orinoco_pci.h b/drivers/net/wireless/orinoco/orinoco_pci.h
index c655b4a..382dc4b 100644
--- a/drivers/net/wireless/orinoco/orinoco_pci.h
+++ b/drivers/net/wireless/orinoco/orinoco_pci.h
@@ -22,7 +22,7 @@ struct orinoco_pci_card {
static int orinoco_pci_suspend(struct pci_dev *pdev, pm_message_t state)
{
struct net_device *dev = pci_get_drvdata(pdev);
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
unsigned long flags;
int err;

@@ -55,7 +55,7 @@ static int orinoco_pci_suspend(struct pci_dev *pdev, pm_message_t state)
static int orinoco_pci_resume(struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
unsigned long flags;
int err;

diff --git a/drivers/net/wireless/orinoco/orinoco_plx.c b/drivers/net/wireless/orinoco/orinoco_plx.c
index a2a4471..2b9074a 100644
--- a/drivers/net/wireless/orinoco/orinoco_plx.c
+++ b/drivers/net/wireless/orinoco/orinoco_plx.c
@@ -228,7 +228,7 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
goto fail_alloc;
}

- priv = netdev_priv(dev);
+ priv = ndev_priv(dev);
card = priv->card;
card->bridge_io = bridge_io;
card->attr_io = attr_io;
@@ -296,7 +296,7 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
static void __devexit orinoco_plx_remove_one(struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct orinoco_pci_card *card = priv->card;

unregister_netdev(dev);
diff --git a/drivers/net/wireless/orinoco/orinoco_tmd.c b/drivers/net/wireless/orinoco/orinoco_tmd.c
index cda0e6e..477fe1e 100644
--- a/drivers/net/wireless/orinoco/orinoco_tmd.c
+++ b/drivers/net/wireless/orinoco/orinoco_tmd.c
@@ -132,7 +132,7 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
goto fail_alloc;
}

- priv = netdev_priv(dev);
+ priv = ndev_priv(dev);
card = priv->card;
card->bridge_io = bridge_io;
SET_NETDEV_DEV(dev, &pdev->dev);
@@ -190,7 +190,7 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
static void __devexit orinoco_tmd_remove_one(struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct orinoco_pci_card *card = priv->card;

unregister_netdev(dev);
diff --git a/drivers/net/wireless/orinoco/spectrum_cs.c b/drivers/net/wireless/orinoco/spectrum_cs.c
index 38e5198..c3702d4 100644
--- a/drivers/net/wireless/orinoco/spectrum_cs.c
+++ b/drivers/net/wireless/orinoco/spectrum_cs.c
@@ -187,7 +187,7 @@ spectrum_cs_probe(struct pcmcia_device *link)
spectrum_cs_stop_firmware);
if (!dev)
return -ENOMEM;
- priv = netdev_priv(dev);
+ priv = ndev_priv(dev);
card = priv->card;

/* Link both structures together */
@@ -307,7 +307,7 @@ static int
spectrum_cs_config(struct pcmcia_device *link)
{
struct net_device *dev = link->priv;
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct orinoco_pccard *card = priv->card;
hermes_t *hw = &priv->hw;
int last_fn, last_ret;
@@ -409,7 +409,7 @@ static void
spectrum_cs_release(struct pcmcia_device *link)
{
struct net_device *dev = link->priv;
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
unsigned long flags;

/* We're committed to taking the device away now, so mark the
@@ -428,7 +428,7 @@ static int
spectrum_cs_suspend(struct pcmcia_device *link)
{
struct net_device *dev = link->priv;
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
unsigned long flags;
int err = 0;

@@ -452,7 +452,7 @@ static int
spectrum_cs_resume(struct pcmcia_device *link)
{
struct net_device *dev = link->priv;
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
unsigned long flags;
int err;

diff --git a/drivers/net/wireless/orinoco/wext.c b/drivers/net/wireless/orinoco/wext.c
index 3f08142..da82e67 100644
--- a/drivers/net/wireless/orinoco/wext.c
+++ b/drivers/net/wireless/orinoco/wext.c
@@ -7,6 +7,7 @@
#include <linux/wireless.h>
#include <linux/ieee80211.h>
#include <net/iw_handler.h>
+#include <net/cfg80211.h>

#include "hermes.h"
#include "hermes_rid.h"
@@ -23,7 +24,7 @@

static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
hermes_t *hw = &priv->hw;
struct iw_statistics *wstats = &priv->wstats;
int err;
@@ -87,31 +88,12 @@ static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev)
/* Wireless extensions */
/********************************************************************/

-static int orinoco_ioctl_getname(struct net_device *dev,
- struct iw_request_info *info,
- char *name,
- char *extra)
-{
- struct orinoco_private *priv = netdev_priv(dev);
- int numrates;
- int err;
-
- err = orinoco_hw_get_bitratelist(priv, &numrates, NULL, 0);
-
- if (!err && (numrates > 2))
- strcpy(name, "IEEE 802.11b");
- else
- strcpy(name, "IEEE 802.11-DS");
-
- return 0;
-}
-
static int orinoco_ioctl_setwap(struct net_device *dev,
struct iw_request_info *info,
struct sockaddr *ap_addr,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int err = -EINPROGRESS; /* Call commit handler */
unsigned long flags;
static const u8 off_addr[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
@@ -172,7 +154,7 @@ static int orinoco_ioctl_getwap(struct net_device *dev,
struct sockaddr *ap_addr,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);

hermes_t *hw = &priv->hw;
int err = 0;
@@ -195,7 +177,7 @@ static int orinoco_ioctl_setmode(struct net_device *dev,
u32 *mode,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int err = -EINPROGRESS; /* Call commit handler */
unsigned long flags;

@@ -243,7 +225,7 @@ static int orinoco_ioctl_getmode(struct net_device *dev,
u32 *mode,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);

*mode = priv->iw_mode;
return 0;
@@ -254,7 +236,7 @@ static int orinoco_ioctl_getiwrange(struct net_device *dev,
struct iw_point *rrq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int err = 0;
struct iw_range *range = (struct iw_range *) extra;
int numrates;
@@ -367,7 +349,7 @@ static int orinoco_ioctl_setiwencode(struct net_device *dev,
struct iw_point *erq,
char *keybuf)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int index = (erq->flags & IW_ENCODE_INDEX) - 1;
int setindex = priv->tx_key;
int encode_alg = priv->encode_alg;
@@ -469,7 +451,7 @@ static int orinoco_ioctl_getiwencode(struct net_device *dev,
struct iw_point *erq,
char *keybuf)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int index = (erq->flags & IW_ENCODE_INDEX) - 1;
u16 xlen = 0;
unsigned long flags;
@@ -508,7 +490,7 @@ static int orinoco_ioctl_setessid(struct net_device *dev,
struct iw_point *erq,
char *essidbuf)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
unsigned long flags;

/* Note : ESSID is ignored in Ad-Hoc demo mode, but we can set it
@@ -539,7 +521,7 @@ static int orinoco_ioctl_getessid(struct net_device *dev,
struct iw_point *erq,
char *essidbuf)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int active;
int err = 0;
unsigned long flags;
@@ -567,7 +549,7 @@ static int orinoco_ioctl_setnick(struct net_device *dev,
struct iw_point *nrq,
char *nickbuf)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
unsigned long flags;

if (nrq->length > IW_ESSID_MAX_SIZE)
@@ -589,7 +571,7 @@ static int orinoco_ioctl_getnick(struct net_device *dev,
struct iw_point *nrq,
char *nickbuf)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
unsigned long flags;

if (orinoco_lock(priv, &flags) != 0)
@@ -608,7 +590,7 @@ static int orinoco_ioctl_setfreq(struct net_device *dev,
struct iw_freq *frq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int chan = -1;
unsigned long flags;
int err = -EINPROGRESS; /* Call commit handler */
@@ -657,7 +639,7 @@ static int orinoco_ioctl_getfreq(struct net_device *dev,
struct iw_freq *frq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int tmp;

/* Locking done in there */
@@ -676,7 +658,7 @@ static int orinoco_ioctl_getsens(struct net_device *dev,
struct iw_param *srq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
hermes_t *hw = &priv->hw;
u16 val;
int err;
@@ -705,7 +687,7 @@ static int orinoco_ioctl_setsens(struct net_device *dev,
struct iw_param *srq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int val = srq->value;
unsigned long flags;

@@ -728,7 +710,7 @@ static int orinoco_ioctl_setrts(struct net_device *dev,
struct iw_param *rrq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int val = rrq->value;
unsigned long flags;

@@ -752,7 +734,7 @@ static int orinoco_ioctl_getrts(struct net_device *dev,
struct iw_param *rrq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);

rrq->value = priv->rts_thresh;
rrq->disabled = (rrq->value == 2347);
@@ -766,7 +748,7 @@ static int orinoco_ioctl_setfrag(struct net_device *dev,
struct iw_param *frq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int err = -EINPROGRESS; /* Call commit handler */
unsigned long flags;

@@ -806,7 +788,7 @@ static int orinoco_ioctl_getfrag(struct net_device *dev,
struct iw_param *frq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
hermes_t *hw = &priv->hw;
int err;
u16 val;
@@ -847,7 +829,7 @@ static int orinoco_ioctl_setrate(struct net_device *dev,
struct iw_param *rrq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int ratemode;
int bitrate; /* 100s of kilobits */
unsigned long flags;
@@ -881,7 +863,7 @@ static int orinoco_ioctl_getrate(struct net_device *dev,
struct iw_param *rrq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int err = 0;
int bitrate, automatic;
unsigned long flags;
@@ -910,7 +892,7 @@ static int orinoco_ioctl_setpower(struct net_device *dev,
struct iw_param *prq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int err = -EINPROGRESS; /* Call commit handler */
unsigned long flags;

@@ -964,7 +946,7 @@ static int orinoco_ioctl_getpower(struct net_device *dev,
struct iw_param *prq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
hermes_t *hw = &priv->hw;
int err = 0;
u16 enable, period, timeout, mcast;
@@ -1018,7 +1000,7 @@ static int orinoco_ioctl_set_encodeext(struct net_device *dev,
union iwreq_data *wrqu,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct iw_point *encoding = &wrqu->encoding;
struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
int idx, alg = ext->alg, set_key = 1;
@@ -1120,7 +1102,7 @@ static int orinoco_ioctl_get_encodeext(struct net_device *dev,
union iwreq_data *wrqu,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct iw_point *encoding = &wrqu->encoding;
struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
int idx, max_key_len;
@@ -1177,7 +1159,7 @@ static int orinoco_ioctl_set_auth(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
hermes_t *hw = &priv->hw;
struct iw_param *param = &wrqu->param;
unsigned long flags;
@@ -1255,7 +1237,7 @@ static int orinoco_ioctl_get_auth(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct iw_param *param = &wrqu->param;
unsigned long flags;
int ret = 0;
@@ -1295,7 +1277,7 @@ static int orinoco_ioctl_set_genie(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
u8 *buf;
unsigned long flags;

@@ -1338,7 +1320,7 @@ static int orinoco_ioctl_get_genie(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
unsigned long flags;
int err = 0;

@@ -1367,7 +1349,7 @@ static int orinoco_ioctl_set_mlme(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
hermes_t *hw = &priv->hw;
struct iw_mlme *mlme = (struct iw_mlme *)extra;
unsigned long flags;
@@ -1408,7 +1390,7 @@ static int orinoco_ioctl_getretry(struct net_device *dev,
struct iw_param *rrq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
hermes_t *hw = &priv->hw;
int err = 0;
u16 short_limit, long_limit, lifetime;
@@ -1462,7 +1444,7 @@ static int orinoco_ioctl_reset(struct net_device *dev,
void *wrqu,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);

if (!capable(CAP_NET_ADMIN))
return -EPERM;
@@ -1487,7 +1469,7 @@ static int orinoco_ioctl_setibssport(struct net_device *dev,
char *extra)

{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int val = *((int *) extra);
unsigned long flags;

@@ -1508,7 +1490,7 @@ static int orinoco_ioctl_getibssport(struct net_device *dev,
void *wrqu,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int *val = (int *) extra;

*val = priv->ibss_port;
@@ -1520,7 +1502,7 @@ static int orinoco_ioctl_setport3(struct net_device *dev,
void *wrqu,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int val = *((int *) extra);
int err = 0;
unsigned long flags;
@@ -1566,7 +1548,7 @@ static int orinoco_ioctl_getport3(struct net_device *dev,
void *wrqu,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int *val = (int *) extra;

*val = priv->prefer_port3;
@@ -1578,7 +1560,7 @@ static int orinoco_ioctl_setpreamble(struct net_device *dev,
void *wrqu,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
unsigned long flags;
int val;

@@ -1610,7 +1592,7 @@ static int orinoco_ioctl_getpreamble(struct net_device *dev,
void *wrqu,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int *val = (int *) extra;

if (!priv->has_preamble)
@@ -1630,7 +1612,7 @@ static int orinoco_ioctl_getrid(struct net_device *dev,
struct iw_point *data,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
hermes_t *hw = &priv->hw;
int rid = data->flags;
u16 length;
@@ -1667,7 +1649,7 @@ static int orinoco_ioctl_setscan(struct net_device *dev,
struct iw_point *srq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
hermes_t *hw = &priv->hw;
struct iw_scan_req *si = (struct iw_scan_req *) extra;
int err = 0;
@@ -1792,7 +1774,7 @@ static inline char *orinoco_translate_scan(struct net_device *dev,
union hermes_scan_info *bss,
unsigned long last_scanned)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
u16 capabilities;
u16 channel;
struct iw_event iwe; /* Temporary buffer */
@@ -2103,7 +2085,7 @@ static int orinoco_ioctl_getscan(struct net_device *dev,
struct iw_point *srq,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
int err = 0;
unsigned long flags;
char *current_ev = extra;
@@ -2181,7 +2163,7 @@ static int orinoco_ioctl_commit(struct net_device *dev,
void *wrqu,
char *extra)
{
- struct orinoco_private *priv = netdev_priv(dev);
+ struct orinoco_private *priv = ndev_priv(dev);
struct hermes *hw = &priv->hw;
unsigned long flags;
int err = 0;
@@ -2258,7 +2240,7 @@ static const struct iw_priv_args orinoco_privtab[] = {
[IW_IOCTL_IDX(id)] = (iw_handler) func
static const iw_handler orinoco_handler[] = {
STD_IW_HANDLER(SIOCSIWCOMMIT, orinoco_ioctl_commit),
- STD_IW_HANDLER(SIOCGIWNAME, orinoco_ioctl_getname),
+ STD_IW_HANDLER(SIOCGIWNAME, cfg80211_wext_giwname),
STD_IW_HANDLER(SIOCSIWFREQ, orinoco_ioctl_setfreq),
STD_IW_HANDLER(SIOCGIWFREQ, orinoco_ioctl_getfreq),
STD_IW_HANDLER(SIOCSIWMODE, orinoco_ioctl_setmode),
--
1.6.0.6