Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH] shaper.c: fix locking
From: jamal @ 2005-06-03  2:36 UTC (permalink / raw)
  To: David S. Miller; +Cc: hch, netdev
In-Reply-To: <20050602.163628.01205145.davem@davemloft.net>

On Thu, 2005-02-06 at 16:36 -0700, David S. Miller wrote:

> Fair enough, patch applied.  If this driver breaks as a result of
> these changes, you get to keep the pieces ok? :-)

The question is anyone really using this driver? ;->

cheers,
jamal

^ permalink raw reply

* RE: Unable to handle kernel paging request at virtual address 04000460
From: raghunathan.venkatesan @ 2005-06-03  2:58 UTC (permalink / raw)
  To: shemminger; +Cc: davem, linux-net, netdev, linux

Hi Stephen,
I appreciate you response. 
We'll get deeper into the problem after turning on these debugs.

Thanks,
Raghu


-----Original Message-----
From: Stephen Hemminger [mailto:shemminger@osdl.org] 
Sent: Thursday, June 02, 2005 11:14 PM
To: Raghunathan Venkatesan (WT01 - EMBEDDED & PRODUCT ENGINEERING
SOLUTIONS)
Cc: davem@davemloft.net; linux-net@vger.kernel.org; netdev@oss.sgi.com;
linux@der-keiler.de
Subject: Re: Unable to handle kernel paging request at virtual address
04000460

On Thu, 2 Jun 2005 09:20:21 +0530
<raghunathan.venkatesan@wipro.com> wrote:

> Hi David,
> I understand that the linux community may not be able to debug it for 
> me. All I require is if people have seen similar problems (the 
> problems we face are w.r.t to kfree_skb and skb_drop_fraglist crashing

> due to some reason, which could be a Memory Management issue or some 
> thing we are not aware of), then let us know the patches, so that we 
> can try them out here.

Turn on Debug memory allocations, spinlock debugging,
sleep-inside-spinlock checking, and preempt, it will help your
debugging.  If you are not building your own kernel from source learn
how.

You are probably freeing memory twice, or not doing ref counting
properly or other locking issues.  Since it is your code, good luck
debugging it, if you want the community help it needs to be open source
code that is available for download or be in the kernel.org kernel.

^ permalink raw reply

* Re: PATCH: ioctl send PID in netlink events
From: jamal @ 2005-06-03  3:32 UTC (permalink / raw)
  To: Thomas Graf; +Cc: David S. Miller, netdev
In-Reply-To: <1117762655.6095.3.camel@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 367 bytes --]

Dave,

If you havent applied that patch to net-2.6.13 heres one that removes
those extrenous printks.

On Thu, 2005-02-06 at 21:37 -0400, jamal wrote:

> The second one could probably use the new macros.
> Maybe i will wait until Dave puts this in his tree and send a small
> change; else you could send it.
> 

Actually cant be done, sorry i lied ;->

cheers,
jamal

[-- Attachment #2: ifconf-2 --]
[-- Type: text/plain, Size: 3020 bytes --]

net/core/rtnetlink.c: needs update
net/ipv4/devinet.c: needs update
net/ipv4/fib_semantics.c: needs update
net/ipv6/addrconf.c: needs update
Index: net/core/rtnetlink.c
===================================================================
--- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/core/rtnetlink.c  (mode:100644)
+++ uncommitted/net/core/rtnetlink.c  (mode:100644)
@@ -452,7 +452,7 @@
 	if (!skb)
 		return;
 
-	if (rtnetlink_fill_ifinfo(skb, dev, type, 0, 0, change, 0) < 0) {
+	if (rtnetlink_fill_ifinfo(skb, dev, type, current->pid, 0, change, 0) < 0) {
 		kfree_skb(skb);
 		return;
 	}
Index: net/ipv4/devinet.c
===================================================================
--- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/ipv4/devinet.c  (mode:100644)
+++ uncommitted/net/ipv4/devinet.c  (mode:100644)
@@ -1112,7 +1112,7 @@
 
 	if (!skb)
 		netlink_set_err(rtnl, 0, RTMGRP_IPV4_IFADDR, ENOBUFS);
-	else if (inet_fill_ifaddr(skb, ifa, 0, 0, event, 0) < 0) {
+	else if (inet_fill_ifaddr(skb, ifa, current->pid, 0, event, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV4_IFADDR, EINVAL);
 	} else {
Index: net/ipv4/fib_semantics.c
===================================================================
--- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/ipv4/fib_semantics.c  (mode:100644)
+++ uncommitted/net/ipv4/fib_semantics.c  (mode:100644)
@@ -276,7 +276,7 @@
 	       struct nlmsghdr *n, struct netlink_skb_parms *req)
 {
 	struct sk_buff *skb;
-	u32 pid = req ? req->pid : 0;
+	u32 pid = req ? req->pid : n->nlmsg_pid;
 	int size = NLMSG_SPACE(sizeof(struct rtmsg)+256);
 
 	skb = alloc_skb(size, GFP_KERNEL);
@@ -1035,7 +1035,7 @@
 	}
 
 	nl->nlmsg_flags = NLM_F_REQUEST;
-	nl->nlmsg_pid = 0;
+	nl->nlmsg_pid = current->pid;
 	nl->nlmsg_seq = 0;
 	nl->nlmsg_len = NLMSG_LENGTH(sizeof(*rtm));
 	if (cmd == SIOCDELRT) {
Index: net/ipv6/addrconf.c
===================================================================
--- e4f7366a04d973a42a948d3b4175d66e9adf143e/net/ipv6/addrconf.c  (mode:100644)
+++ uncommitted/net/ipv6/addrconf.c  (mode:100644)
@@ -2872,7 +2872,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFADDR, ENOBUFS);
 		return;
 	}
-	if (inet6_fill_ifaddr(skb, ifa, 0, 0, event, 0) < 0) {
+	if (inet6_fill_ifaddr(skb, ifa, current->pid, 0, event, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFADDR, EINVAL);
 		return;
@@ -3007,7 +3007,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFINFO, ENOBUFS);
 		return;
 	}
-	if (inet6_fill_ifinfo(skb, idev, 0, 0, event, 0) < 0) {
+	if (inet6_fill_ifinfo(skb, idev, current->pid, 0, event, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFINFO, EINVAL);
 		return;
@@ -3064,7 +3064,7 @@
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_PREFIX, ENOBUFS);
 		return;
 	}
-	if (inet6_fill_prefix(skb, idev, pinfo, 0, 0, event, 0) < 0) {
+	if (inet6_fill_prefix(skb, idev, pinfo, current->pid, 0, event, 0) < 0) {
 		kfree_skb(skb);
 		netlink_set_err(rtnl, 0, RTMGRP_IPV6_PREFIX, EINVAL);
 		return;

^ permalink raw reply

* Re: PATCH: explicit typing WAS(Re: PATCH: rtnetlink explicit flags setting
From: David S. Miller @ 2005-06-03  5:08 UTC (permalink / raw)
  To: hadi; +Cc: tgraf, netdev
In-Reply-To: <1117717493.6050.29.camel@localhost.localdomain>

From: jamal <hadi@cyberus.ca>
Date: Thu, 02 Jun 2005 09:04:52 -0400

> This patch converts "unsigned flags" to use more explict types like u16
> instead and incrementally introduces NLMSG_NEW().
>  
> Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca> 

Applied, thanks Jamal.

^ permalink raw reply

* Re: PATCH: ioctl send PID in netlink events
From: David S. Miller @ 2005-06-03  5:09 UTC (permalink / raw)
  To: hadi; +Cc: tgraf, netdev
In-Reply-To: <1117769575.6095.91.camel@localhost.localdomain>

From: jamal <hadi@cyberus.ca>
Date: Thu, 02 Jun 2005 23:32:55 -0400

> If you havent applied that patch to net-2.6.13 heres one that removes
> those extrenous printks.

Applied, thanks Jamal.

^ permalink raw reply

* Re: [IPV4/IPV6] Replace spin_lock_irq with spin_lock_bh
From: David S. Miller @ 2005-06-03  5:10 UTC (permalink / raw)
  To: herbert; +Cc: netdev
In-Reply-To: <20050602094404.GA10316@gondor.apana.org.au>

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Thu, 2 Jun 2005 19:44:04 +1000

> In light of my recent patch to net/ipv4/udp.c that replaced the
> spin_lock_irq calls on the receive queue lock with spin_lock_bh,
> here is a similar patch for all other occurences of spin_lock_irq
> on receive/error queue locks in IPv4 and IPv6.
> 
> In these stacks, we know that they can only be entered from user
> or softirq context.  Therefore it's safe to disable BH only.
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> 

Applied to net-2.6.13, thanks Herbert.

^ permalink raw reply

* Re: [SCTP] Replace spin_lock_irqsave with spin_lock_bh
From: David S. Miller @ 2005-06-03  5:11 UTC (permalink / raw)
  To: herbert; +Cc: netdev
In-Reply-To: <20050602095459.GA26638@gondor.apana.org.au>

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Thu, 2 Jun 2005 19:54:59 +1000

> The call in question is only called from recvmsg which means that
> IRQs aren't disabled.  Therefore it is safe to replace it with
> spin_lock_bh.
>  
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> 

Also applied to net-2.6.13, thanks.

^ permalink raw reply

* Re: Network card driver problem (znb.o/tulip)
From: Kosta Todorovic @ 2005-06-03  5:45 UTC (permalink / raw)
  To: Ben Greear; +Cc: jgarzik, tulip-users, netdev
In-Reply-To: <428E0B3B.1090507@candelatech.com>

I'm not too concerned with backward compatibility. I see silicom-usa
provide both a Broadcom and Intel based chipsets.
 
Is there any reason in particular that you reccomended Broadcom? And
can standard kernel drivers be used for these cards? I've had bad
expirience with custom manufactorer drivers once they discontinue
development and support for their card.

How reliable is Silicom-usa?

As a management decision, who would you purchase 10 quad port cards
from and which kinds of cards would u get?


Thanks,
K

On 5/20/05, Ben Greear <greearb@candelatech.com> wrote:
> Kosta Todorovic wrote:
> > 2 more questions:
> >
> > 1) Is there anything special I will need to compile in terms of the
> > linux kernel for 64-bit PCI bus mode (PCI-X) ? (Currently I'm using
> > kernel 2.4.x but that is because my current card drivers do not
> > support 2.6.x)
> 
> Nothing special...2.4 and 2.6 kernels since way back will work just fine.
> 
> > 2) The machine actually has a PCI extension with 9 other PCI-X slots.
> > The current cards are 64-bit (pci-x) but as a test i'm planning on
> > replacing them with DLinks DFE-580tx's. Unfortunately these are 32-bit
> > cards (legacy pci). How will these 4 ports work in 32-bit mode? What
> > will the effect be on the speed?
> 
> If you put a 33Mhz NIC in a PCI-X bus it makes the entire bus run at
> 33Mhz speed.
> 
> If you do want full backwards compatibility, get the 'universal' 4-port
> broadcom NIC from silicom-usa.  It works fine in 32-bit PCI busses, and
> though I haven't personally tested it, it should work fine in PCI-X
> busses at high speed as well.
> 
> Ben
> 
> >
> >
> >
> > On 5/19/05, Ben Greear <greearb@candelatech.com> wrote:
> >
> >>Kosta Todorovic wrote:
> >>
> >>>Whats the best 4-port NIC currently available? I'm interested in
> >>>purchasing 10 4-port NICs as a replacement for my current cards.
> >>>
> >>>I am looking for 10/100Mbps and a good driver for linux (2.4.x and
> >>>2.6.x). Preferably a mainstream company but thats not priority.
> >>>
> >>>Could the community please recommend the best card available? Money is
> >>>not an issue since im really interested in the best of the best.
> >>
> >>Get an Intel 4-port GigE NIC.  It will do 10/100/1000, and if you really
> >>want to use all 4 ports at even 100Mbps, you need the 64-bit PCI bus...
> >>
> >>I have been getting mine from silicom-usa.com lately.  They also have
> >>6-port NICs, and 4-port broadcom GigE nics that can be used in 32-bit
> >>PCI slots.  (The Intel 4-port NICs will only work in 64-bit PCI slots.)
> >>
> >>If you really want 10/100 nics, try the p430tx from aei:
> >>http://www.aei-it.com/hardware/fastenet/p430tx.htm
> >>
> >>These are like the old DFE570tx NICs, and use the tulip driver.  They
> >>are almost as expensive as the GigE NICs though...
> >>
> >>Thanks,
> >>Ben
> >>
> >>
> >>>Any suggestions?
> >>>
> >>>Regards,
> >>>Kosta
> >>>
> >>>
> >>>
> >>>On 3/11/05, Kosta Todorovic <kostodo@gmail.com> wrote:
> >>>
> >>>
> >>>>My company has recently purchased several ZNYX ZX274 network cards.
> >>>>These cards are Four Channel, 10/100 PCI Adapters. They use Intel chipsets.
> >>>>
> >>>>Unfortunately there exists no drivers for linux amd64 architecture.
> >>>>There are 32bit drivers found at:
> >>>>http://www.znyx.com/support/drivers/ZX374_drivers.htm but naturally
> >>>>they wont compile under my amd64 system.
> >>>>
> >>>>The driver itself is called znb.o and can be downloaded from ZNYX's
> >>>>website. I spoke to support staff there but they told me they have
> >>>>discontinued support and development for this series of cards.
> >>>>
> >>>>The system I am running gentoo and have tried both 2.4.x and 2.6.x
> >>>>kernels but no luck.
> >>>>
> >>>>Unfortunately there is NO 64bit drivers available for ANY platform. not even MS.
> >>>>
> >>>>Does anyone know of a customised znb.o driver built for amd64?
> >>>>Is there any chance of anyone modifying the source code of the driver
> >>>>to compile under a amd64 system?
> >>>>
> >>>>I've noticed that "tulip" drivers get loaded as a module at boot time.
> >>>>but they dont function correctly. (lets you start the device and
> >>>>attach ips but cant talk through it)
> >>>>
> >>>>Is there any variants of the tulip driver that will work for this?
> >>>>
> >>>>Help much appreciated.
> >>>>
> >>>>
> >>>>/proc/pci extract for network cards:
> >>>>
> >>>> Bus  5, device   5, function  0:
> >>>>   Ethernet controller: Digital Equipment Corporation DECchip
> >>>>21142/43 (#30) (rev 65).
> >>>>     IRQ 30.
> >>>>     Master Capable.  Latency=128.  Min Gnt=20.Max Lat=40.
> >>>>     I/O at 0x0 [0x7f].
> >>>>     Non-prefetchable 32 bit memory at 0xfa1ff400 [0xfa1ff7ff].
> >>>> Bus  5, device   4, function  0:
> >>>>   Ethernet controller: Digital Equipment Corporation DECchip
> >>>>21142/43 (#29) (rev 65).
> >>>>     IRQ 29.
> >>>>     Master Capable.  No bursts.  Min Gnt=20.Max Lat=40.
> >>>>     I/O at 0x0 [0x7f].
> >>>>     Non-prefetchable 32 bit memory at 0xf9f00000 [0xf9f003ff].
> >>>>
> >>>
> >>>
> >>
> >>--
> >>Ben Greear <greearb@candelatech.com>
> >>Candela Technologies Inc  http://www.candelatech.com
> >>
> >>
> >
> >
> 
> 
> --
> Ben Greear <greearb@candelatech.com>
> Candela Technologies Inc  http://www.candelatech.com
> 
>

^ permalink raw reply

* Re: Network card driver problem (znb.o/tulip)
From: Ben Greear @ 2005-06-03  5:53 UTC (permalink / raw)
  To: Kosta Todorovic; +Cc: jgarzik, tulip-users, netdev
In-Reply-To: <efe3b00605060222452675d8fc@mail.gmail.com>

Kosta Todorovic wrote:
> I'm not too concerned with backward compatibility. I see silicom-usa
> provide both a Broadcom and Intel based chipsets.
>  
> Is there any reason in particular that you reccomended Broadcom? And
> can standard kernel drivers be used for these cards? I've had bad
> expirience with custom manufactorer drivers once they discontinue
> development and support for their card.

The BCM NICs will work in a normal 32-bit PCI bus..the 4-port Intels will
not.  If you have 64-bit PCI-X, then I'd get Intel..but that's just because
I've used them longer...I have no reason to believe the BCM is inferior at
this time.

> How reliable is Silicom-usa?
> 
> As a management decision, who would you purchase 10 quad port cards
> from and which kinds of cards would u get?

Heh, I've already purchased more than 10 from silicom, and have shipped
them all over the world.  So far...no complaints!  But, if you don't
need the BCM, you can get good ole Intel quad GigE NICs from www.newegg.com
and a million other places.

Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

^ permalink raw reply

* Re: Network card driver problem (znb.o/tulip)
From: Kosta Todorovic @ 2005-06-03  5:58 UTC (permalink / raw)
  To: Ben Greear; +Cc: jgarzik, tulip-users, netdev
In-Reply-To: <429FF071.8040707@candelatech.com>

So intel gigE nics use standard tulip linux drivers that come shipped
with a vanilla kernel?

On 6/3/05, Ben Greear <greearb@candelatech.com> wrote:
> Kosta Todorovic wrote:
> > I'm not too concerned with backward compatibility. I see silicom-usa
> > provide both a Broadcom and Intel based chipsets.
> >
> > Is there any reason in particular that you reccomended Broadcom? And
> > can standard kernel drivers be used for these cards? I've had bad
> > expirience with custom manufactorer drivers once they discontinue
> > development and support for their card.
> 
> The BCM NICs will work in a normal 32-bit PCI bus..the 4-port Intels will
> not.  If you have 64-bit PCI-X, then I'd get Intel..but that's just because
> I've used them longer...I have no reason to believe the BCM is inferior at
> this time.
> 
> > How reliable is Silicom-usa?
> >
> > As a management decision, who would you purchase 10 quad port cards
> > from and which kinds of cards would u get?
> 
> Heh, I've already purchased more than 10 from silicom, and have shipped
> them all over the world.  So far...no complaints!  But, if you don't
> need the BCM, you can get good ole Intel quad GigE NICs from www.newegg.com
> and a million other places.
> 
> Ben
> 
> --
> Ben Greear <greearb@candelatech.com>
> Candela Technologies Inc  http://www.candelatech.com
> 
>

^ permalink raw reply

* Re: Network card driver problem (znb.o/tulip)
From: Ben Greear @ 2005-06-03  6:25 UTC (permalink / raw)
  To: Kosta Todorovic; +Cc: jgarzik, tulip-users, netdev
In-Reply-To: <efe3b0060506022258519aa826@mail.gmail.com>

Kosta Todorovic wrote:
> So intel gigE nics use standard tulip linux drivers that come shipped
> with a vanilla kernel?

No..forget about tulip.  It uses standard e1000 driver shipped with
vanilla kernel.  The BCM chipsets use standard drivers in the kernel
as well.

Ben


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

^ permalink raw reply

* Re: [PATCH] ieee80211: Update generic definitions to latest specs.
From: Jiri Benc @ 2005-06-03  9:33 UTC (permalink / raw)
  To: gwingerde; +Cc: netdev, jbohac
In-Reply-To: <20050602190232.340996282D7@mail.suse.cz>

On Thu, 2 Jun 2005 21:02:24 +0200, gwingerde@home.nl wrote:
> I was thinking about that too, but couldn't find a proper shorter
> version without losing the descriptive meaning.
> 
> Do you have any suggestions to shorten them?

Maybe we can lose a bit of descriptiveness and put comments above
definitions instead?

I can imagine names such as WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM,
WLAN_STATUS_ASSOC_DENIED_BAD_POWER,
WLAN_STATUS_ASSOC_DENIED_BAD_SUPPCHANNS, WLAN_REASON_DISASSOC_BAD_POWER,
and so on. Also WLAN_STATUS_ASSOC_DENIED_NOSHORT seems to be acceptable
for me.

More often used identifiers probably could have even shorter name - what
about renaming IEEE80211_FCTL_PROTECTEDFRAME to
IEEE80211_FCTL_PROTECTED?

Thanks,

-- 
Jiri Benc
SUSE Labs

^ permalink raw reply

* Re: Comparison of several congestion control algorithms
From: Baruch Even @ 2005-06-03 13:42 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, shemminger, doug.leith
In-Reply-To: <20050602.165341.63126720.davem@davemloft.net>

David S. Miller wrote:
> From: Baruch Even <baruch@ev-en.org>
> Date: Fri, 03 Jun 2005 00:50:07 +0100
> 
> 
>>This is in part because of the start of the work that was based on 2.4
>>kernels and even as far as the 2.6.6 kernel which had disabled TSO once
>>it saw SACKs. This made TSO unusable for our needs.
>>
>>AFAIK, the tests reported in that document used kernel 2.6.6.
> 
> 
> Sure SACKs turn off TSO currently,  but you'll have them enabled
> at the beginning until the first loss and this affects how fast
> the cwnd will grow.
> 
> If you have e1000 cards, for example, you're getting TSO enabled
> by default.
> 
> You really need to look into this, as it has a real and very
> non-trivial effect on all of the results you obtained.

I checked that now and ethtool -k shows TSO to be disabled after boot.
Since all the test scripts are not playing with ethtool I can be sure
that TSO was off during all of our tests.

Baruch

^ permalink raw reply

* [0/9] ieee80211: Improvements to the layer
From: Jiri Benc @ 2005-06-03 16:26 UTC (permalink / raw)
  To: NetDev; +Cc: Jeff Garzik, Jirka Bohac

Following patches are nearly the same as were sent couple of days ago.
However, they are against current netdev-2.6 tree and they contain some
more fixes (TKIP compilation, new file for protocol layer functions).

The HH_DATA_OFF bugfix is needed too
(http://oss.sgi.com/projects/netdev/archive/2005-05/msg00962.html), it's
not included here as it is in Linus' tree already.

Also there are two patches from Adrian Bunk included.


-- 
Jiri Benc
SUSE Labs

^ permalink raw reply

* [1/9] ieee80211: remove pci.h #include's
From: Jiri Benc @ 2005-06-03 16:28 UTC (permalink / raw)
  To: NetDev; +Cc: Jeff Garzik, Jirka Bohac
In-Reply-To: <20050603182625.64d33be3@griffin.suse.cz>

From: Adrian Bunk <bunk@stusta.de>

I was wondering why editing pci.h triggered the rebuild of three files 
under net/, and as far as I can see, there's no reason for these three 
files to #include pci.h .

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Jiri Benc <jbenc@suse.cz>

--- linux-2.6.12-rc3-mm1-full/net/ieee80211/ieee80211_module.c.old	2005-04-30 23:23:14.000000000 +0200
+++ linux-2.6.12-rc3-mm1-full/net/ieee80211/ieee80211_module.c	2005-04-30 23:23:18.000000000 +0200
@@ -40,7 +40,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
-#include <linux/pci.h>
 #include <linux/proc_fs.h>
 #include <linux/skbuff.h>
 #include <linux/slab.h>
--- linux-2.6.12-rc3-mm1-full/net/ieee80211/ieee80211_tx.c.old	2005-04-30 23:23:25.000000000 +0200
+++ linux-2.6.12-rc3-mm1-full/net/ieee80211/ieee80211_tx.c	2005-04-30 23:23:32.000000000 +0200
@@ -33,7 +33,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
-#include <linux/pci.h>
 #include <linux/proc_fs.h>
 #include <linux/skbuff.h>
 #include <linux/slab.h>
--- linux-2.6.12-rc3-mm1-full/net/ieee80211/ieee80211_rx.c.old	2005-04-30 23:23:42.000000000 +0200
+++ linux-2.6.12-rc3-mm1-full/net/ieee80211/ieee80211_rx.c	2005-04-30 23:23:46.000000000 +0200
@@ -23,7 +23,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
-#include <linux/pci.h>
 #include <linux/proc_fs.h>
 #include <linux/skbuff.h>
 #include <linux/slab.h>


-- 
Jiri Benc
SUSE Labs

^ permalink raw reply

* [2/9] ieee80211: fix recursive ipw2200 dependencies
From: Jiri Benc @ 2005-06-03 16:29 UTC (permalink / raw)
  To: NetDev; +Cc: Jeff Garzik, Jirka Bohac
In-Reply-To: <20050603182625.64d33be3@griffin.suse.cz>

From: Adrian Bunk <bunk@stusta.de>

This results in recursive dependencies:
- IPW2200 depends on NET_RADIO
- IPW2200 selects IEEE80211
- IEEE80211 selects NET_RADIO


This patch fixes the IPW2200 dependencies in a way that they are similar 
to the IPW2100 dependencies.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Jiri Benc <jbenc@suse.cz>

--- linux-2.6.12-rc5-mm2-full/drivers/net/wireless/Kconfig.old	2005-06-02 22:04:02.000000000 +0200
+++ linux-2.6.12-rc5-mm2-full/drivers/net/wireless/Kconfig	2005-06-02 22:04:40.000000000 +0200
@@ -192,9 +192,8 @@
 
 config IPW2200
 	tristate "Intel PRO/Wireless 2200BG and 2915ABG Network Connection"
-	depends on NET_RADIO && PCI
+	depends on IEEE80211 && PCI
 	select FW_LOADER
-	select IEEE80211
 	---help---
           A driver for the Intel PRO/Wireless 2200BG and 2915ABG Network
 	  Connection adapters. 


-- 
Jiri Benc
SUSE Labs

^ permalink raw reply

* [3/9] ieee80211: fix ipw 64bit compilation warnings
From: Jiri Benc @ 2005-06-03 16:30 UTC (permalink / raw)
  To: NetDev; +Cc: Jeff Garzik, Jirka Bohac
In-Reply-To: <20050603182625.64d33be3@griffin.suse.cz>

This patch fixes warnings when compiling ipw2100 and ipw2200 on x86_64.


Signed-off-by: Jiri Benc <jbenc@suse.cz>
Signed-off-by: Jirka Bohac <jbohac@suse.cz>

Index: netdev/drivers/net/wireless/ipw2200.c
===================================================================
--- netdev.orig/drivers/net/wireless/ipw2200.c	2005-06-01 11:03:37.000000000 +0200
+++ netdev/drivers/net/wireless/ipw2200.c	2005-06-03 15:46:31.000000000 +0200
@@ -241,8 +241,8 @@
 	IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg, value);
 	_ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK);
 	_ipw_write8(priv, CX2_INDIRECT_DATA, value);
-	IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", 
-		     (unsigned)(priv->hw_base + CX2_INDIRECT_DATA),
+	IPW_DEBUG_IO(" reg = 0x%8lX : value = 0x%8X\n", 
+		     (unsigned long)(priv->hw_base + CX2_INDIRECT_DATA),
 		     value);
 }
 
@@ -508,7 +508,7 @@
 		/* verify we have enough room to store the value */
 		if (*len < sizeof(u32)) {
 			IPW_DEBUG_ORD("ordinal buffer length too small, "
-				      "need %d\n", sizeof(u32));
+				      "need %d\n", (int)sizeof(u32));
 			return -EINVAL;
 		}
 
@@ -541,7 +541,7 @@
 		/* verify we have enough room to store the value */
 		if (*len < sizeof(u32)) {
 			IPW_DEBUG_ORD("ordinal buffer length too small, "
-				      "need %d\n", sizeof(u32));
+				      "need %d\n", (int)sizeof(u32));
 			return -EINVAL;
 		}
 
@@ -1740,7 +1740,7 @@
 	u32 address = CX2_SHARED_SRAM_DMA_CONTROL + (sizeof(struct command_block) * index); 
 	IPW_DEBUG_FW(">> :\n");
 
-	ipw_write_indirect(priv, address, (u8*)cb, sizeof(struct command_block));
+	ipw_write_indirect(priv, address, (u8*)cb, (int)sizeof(struct command_block));
 
 	IPW_DEBUG_FW("<< :\n");
 	return 0;
@@ -2342,11 +2342,11 @@
 		return -EINVAL;
 	}
 
-	IPW_DEBUG_INFO("Loading firmware '%s' file v%d.%d (%d bytes)\n",
+	IPW_DEBUG_INFO("Loading firmware '%s' file v%d.%d (%ld bytes)\n",
 		       name,
 		       IPW_FW_MAJOR(header->version),
 		       IPW_FW_MINOR(header->version),
-		       (*fw)->size - sizeof(struct fw_header));
+		       (long)(*fw)->size - sizeof(struct fw_header));
 	return 0;
 }
 
@@ -2698,7 +2698,7 @@
 	q->bd = pci_alloc_consistent(dev,sizeof(q->bd[0])*count, &q->q.dma_addr);
 	if (!q->bd) {
 		IPW_ERROR("pci_alloc_consistent(%d) failed\n",
-				sizeof(q->bd[0]) * count);
+				(int)sizeof(q->bd[0]) * count);
 		kfree(q->txb);
 		q->txb = NULL;
 		return -ENOMEM;
@@ -3467,7 +3467,7 @@
 		} else {
 			IPW_DEBUG_SCAN("Scan result of wrong size %d "
 				       "(should be %d)\n",
-				       notif->size,sizeof(*x));
+				       notif->size, (int)sizeof(*x));
 		}
 		break;
 	}
@@ -3483,7 +3483,7 @@
 		} else {
 			IPW_ERROR("Scan completed of wrong size %d "
 				  "(should be %d)\n",
-				  notif->size,sizeof(*x));
+				  notif->size, (int)sizeof(*x));
 		}
 	
 		priv->status &= ~(STATUS_SCANNING | STATUS_SCAN_ABORTING);
@@ -3516,7 +3516,7 @@
 		} else {
 			IPW_ERROR("Frag length of wrong size %d "
 				  "(should be %d)\n",
-				  notif->size, sizeof(*x));
+				  notif->size, (int)sizeof(*x));
 		}
 		break;
 	}
@@ -3533,7 +3533,7 @@
 		} else {
 			IPW_ERROR("Link Deterioration of wrong size %d "
 				  "(should be %d)\n",
-				  notif->size,sizeof(*x));
+				  notif->size, (int)sizeof(*x));
 		}
 		break;
 	}
@@ -3552,7 +3552,7 @@
 		struct notif_beacon_state *x = &notif->u.beacon_state;
 		if (notif->size != sizeof(*x)) {
 			IPW_ERROR("Beacon state of wrong size %d (should "
-				  "be %d)\n", notif->size, sizeof(*x));
+				  "be %d)\n", notif->size, (int)sizeof(*x));
 			break;
 		}
 
@@ -3603,7 +3603,7 @@
 		} 
 
 		IPW_ERROR("TGi Tx Key of wrong size %d (should be %d)\n",
-			  notif->size,sizeof(*x));
+			  notif->size, (int)sizeof(*x));
 		break;
 	}
 
@@ -3617,7 +3617,7 @@
 		} 
 		
 		IPW_ERROR("Calibration of wrong size %d (should be %d)\n",
-			  notif->size,sizeof(*x));
+			  notif->size, (int)sizeof(*x));
 		break;
 	}
 
@@ -3629,7 +3629,7 @@
 		}
 
 		IPW_ERROR("Noise stat is wrong size %d (should be %d)\n",
-			  notif->size, sizeof(u32));
+			  notif->size, (int)sizeof(u32));
 		break;
 	}
 
@@ -4823,7 +4823,7 @@
 	}
 
 	/* Advance skb->data to the start of the actual payload */
-	skb_reserve(rxb->skb, (u32)&pkt->u.frame.data[0] - (u32)pkt);
+	skb_reserve(rxb->skb, offsetof(struct ipw_rx_packet, u.frame.data));
 
 	/* Set the size of the skb to the size of the frame */
 	skb_put(rxb->skb, pkt->u.frame.length);
Index: netdev/drivers/net/wireless/ipw2100.c
===================================================================
--- netdev.orig/drivers/net/wireless/ipw2100.c	2005-06-01 11:03:37.000000000 +0200
+++ netdev/drivers/net/wireless/ipw2100.c	2005-06-03 15:43:53.000000000 +0200
@@ -494,7 +494,7 @@
 
 			IPW_DEBUG_WARNING(DRV_NAME
 			       ": ordinal buffer length too small, need %d\n",
-			       IPW_ORD_TAB_1_ENTRY_SIZE);
+			       (int)IPW_ORD_TAB_1_ENTRY_SIZE);
 
 			return -EINVAL;
 		}
@@ -2302,7 +2302,7 @@
 #endif
 
 	IPW_DEBUG_INFO(DRV_NAME ": PCI latency error detected at "
-		       "0x%04X.\n", i * sizeof(struct ipw2100_status));
+		       "0x%04X.\n", i * (int)sizeof(struct ipw2100_status));
 
 #ifdef ACPI_CSTATE_LIMIT_DEFINED
 	IPW_DEBUG_INFO(DRV_NAME ": Disabling C3 transitions.\n");
@@ -2398,7 +2398,7 @@
 	/* Make a copy of the frame so we can dump it to the logs if
 	 * ieee80211_rx fails */
 	memcpy(packet_data, packet->skb->data,
-	       min(status->frame_size, IPW_RX_NIC_BUFFER_LENGTH));
+	       min_t(u32, status->frame_size, IPW_RX_NIC_BUFFER_LENGTH));
 #endif
 
 	if (!ieee80211_rx(priv->ieee, packet->skb, stats)) {
@@ -2730,21 +2730,21 @@
 	{
 		int i = txq->oldest;
 		IPW_DEBUG_TX(
-			"TX%d V=%p P=%p T=%p L=%d\n", i,
+			"TX%d V=%p P=%04X T=%04X L=%d\n", i,
 			&txq->drv[i],
-			(void*)txq->nic + i * sizeof(struct ipw2100_bd),
-			(void*)txq->drv[i].host_addr,
+			(u32)(txq->nic + i * sizeof(struct ipw2100_bd)),
+			txq->drv[i].host_addr,
 			txq->drv[i].buf_length);
 
 		if (packet->type == DATA) {
 			i = (i + 1) % txq->entries;
 
 			IPW_DEBUG_TX(
-				"TX%d V=%p P=%p T=%p L=%d\n", i,
+				"TX%d V=%p P=%04X T=%04X L=%d\n", i,
 				&txq->drv[i],
-				(void*)txq->nic + i *
-				sizeof(struct ipw2100_bd),
-				(void*)txq->drv[i].host_addr,
+				(u32)(txq->nic + i *
+				sizeof(struct ipw2100_bd)),
+				(u32)txq->drv[i].host_addr,
 				txq->drv[i].buf_length);
 		}
 	}
@@ -4212,7 +4212,7 @@
 {
 	IPW_DEBUG_INFO("enter\n");
 
-	IPW_DEBUG_INFO("initializing bd queue at virt=%p, phys=%08x\n", q->drv, q->nic);
+	IPW_DEBUG_INFO("initializing bd queue at virt=%p, phys=%08x\n", q->drv, (u32)q->nic);
 
 	write_register(priv->net_dev, base, q->nic);
 	write_register(priv->net_dev, size, q->entries);
@@ -8431,8 +8431,8 @@
 		       priv->net_dev->name, fw_name);
 		return rc;
 	}
-	IPW_DEBUG_INFO("firmware data %p size %d\n", fw->fw_entry->data,
-			   fw->fw_entry->size);
+	IPW_DEBUG_INFO("firmware data %p size %ld\n", fw->fw_entry->data,
+			   (long)fw->fw_entry->size);
 
 	ipw2100_mod_firmware_load(fw);
 


-- 
Jiri Benc
SUSE Labs

^ permalink raw reply

* [4/9] ieee80211: ieee80211_device alignment fix and cleanup
From: Jiri Benc @ 2005-06-03 16:31 UTC (permalink / raw)
  To: NetDev; +Cc: Jeff Garzik, Jirka Bohac
In-Reply-To: <20050603182625.64d33be3@griffin.suse.cz>

Changes to the ieee80211 layer:
- fixes a serious alignment problem of the driver's private data
- makes the drivers use the ieee80211_device instead of the net_device where
  appropriate (will ease further development of ieee80211 as a self-contained
  layer)


Signed-off-by: Jiri Benc <jbenc@suse.cz>
Signed-off-by: Jirka Bohac <jbohac@suse.cz>

Index: netdev/include/net/ieee80211.h
===================================================================
--- netdev.orig/include/net/ieee80211.h	2005-06-01 11:05:06.000000000 +0200
+++ netdev/include/net/ieee80211.h	2005-06-03 13:20:46.000000000 +0200
@@ -704,15 +704,13 @@
 	int abg_ture;   /* ABG flag              */
 
 	/* Callback functions */
-	void (*set_security)(struct net_device *dev,
+	void (*set_security)(struct ieee80211_device *ieee,
 			     struct ieee80211_security *sec);
 	int (*hard_start_xmit)(struct ieee80211_txb *txb,
-			       struct net_device *dev);
-	int (*reset_port)(struct net_device *dev);
+			       struct ieee80211_device *ieee);
+	int (*reset_port)(struct ieee80211_device *ieee);
 
-	/* This must be the last item so that it points to the data
-	 * allocated beyond this structure by alloc_ieee80211 */
-	u8 priv[0];
+	void *priv;
 };
 
 #define IEEE_A            (1<<0)
@@ -720,9 +718,27 @@
 #define IEEE_G            (1<<2)
 #define IEEE_MODE_MASK    (IEEE_A|IEEE_B|IEEE_G)
 
-extern inline void *ieee80211_priv(struct net_device *dev)
+static inline void *ieee80211_priv(struct ieee80211_device *ieee)
 {
-	return ((struct ieee80211_device *)netdev_priv(dev))->priv;
+	 return (char *)ieee + 
+	 	((sizeof(struct ieee80211_device) + NETDEV_ALIGN_CONST)
+			& ~NETDEV_ALIGN_CONST);
+}
+
+static inline void *ieee80211_dev_to_priv(struct net_device *dev)
+{
+	return (char *)dev +
+		((sizeof(struct net_device) + NETDEV_ALIGN_CONST)
+			& ~NETDEV_ALIGN_CONST) +
+		((sizeof(struct ieee80211_device) + NETDEV_ALIGN_CONST)
+			& ~NETDEV_ALIGN_CONST);
+}
+
+static inline struct net_device *ieee80211_dev(struct ieee80211_device *ieee)
+{
+	 return (struct net_device *)((char *)ieee - 
+	 	((sizeof(struct net_device) + NETDEV_ALIGN_CONST)
+			& ~NETDEV_ALIGN_CONST));
 }
 
 extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
@@ -795,8 +811,8 @@
 
 
 /* ieee80211.c */
-extern void free_ieee80211(struct net_device *dev);
-extern struct net_device *alloc_ieee80211(int sizeof_priv);
+extern void free_ieee80211(struct ieee80211_device *ieee);
+extern struct ieee80211_device *alloc_ieee80211(int sizeof_priv);
 
 extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
 
Index: netdev/net/ieee80211/ieee80211_module.c
===================================================================
--- netdev.orig/net/ieee80211/ieee80211_module.c	2005-06-03 13:20:40.000000000 +0200
+++ netdev/net/ieee80211/ieee80211_module.c	2005-06-03 13:20:46.000000000 +0200
@@ -69,7 +69,7 @@
 		GFP_KERNEL);
 	if (!ieee->networks) {
 		printk(KERN_WARNING "%s: Out of memory allocating beacons\n",
-		       ieee->dev->name);
+		       ieee80211_dev(ieee)->name);
 		return -ENOMEM;
 	}
 
@@ -98,23 +98,28 @@
 }
 
 
-struct net_device *alloc_ieee80211(int sizeof_priv)
+struct ieee80211_device *alloc_ieee80211(int sizeof_priv)
 {
 	struct ieee80211_device *ieee;
 	struct net_device *dev;
+	int alloc_size;
 	int err;
 
 	IEEE80211_DEBUG_INFO("Initializing...\n");
 
-	dev = alloc_etherdev(sizeof(struct ieee80211_device) + sizeof_priv);
+	alloc_size = ((sizeof(struct ieee80211_device) + NETDEV_ALIGN_CONST) 
+			& ~NETDEV_ALIGN_CONST) 
+			+ sizeof_priv;
+	dev = alloc_etherdev(alloc_size);
 	if (!dev) {
 		IEEE80211_ERROR("Unable to network device.\n");
 		goto failed;
 	}
 	ieee = netdev_priv(dev);
-	dev->hard_start_xmit = ieee80211_xmit;
-
 	ieee->dev = dev;
+	ieee->priv = ieee80211_priv(ieee);
+	
+	dev->hard_start_xmit = ieee80211_xmit;
 
 	err = ieee80211_networks_allocate(ieee);
 	if (err) {
@@ -147,7 +152,7 @@
  	ieee->privacy_invoked = 0;
  	ieee->ieee802_1x = 1;
 
-	return dev;
+	return ieee;
 
  failed:
 	if (dev)
@@ -156,10 +161,8 @@
 }
 
 
-void free_ieee80211(struct net_device *dev)
+void free_ieee80211(struct ieee80211_device *ieee)
 {
-	struct ieee80211_device *ieee = netdev_priv(dev);
-
 	int i;
 
 	del_timer_sync(&ieee->crypt_deinit_timer);
@@ -178,7 +181,7 @@
 	}
 
 	ieee80211_networks_free(ieee);
-	free_netdev(dev);
+	free_netdev(ieee80211_dev(ieee));
 }
 
 #ifdef CONFIG_IEEE80211_DEBUG
Index: netdev/net/ieee80211/ieee80211_rx.c
===================================================================
--- netdev.orig/net/ieee80211/ieee80211_rx.c	2005-06-03 13:20:40.000000000 +0200
+++ netdev/net/ieee80211/ieee80211_rx.c	2005-06-03 13:20:46.000000000 +0200
@@ -99,7 +99,7 @@
 
 	if (frag == 0) {
 		/* Reserve enough space to fit maximum frame length */
-		skb = dev_alloc_skb(ieee->dev->mtu +
+		skb = dev_alloc_skb(ieee80211_dev(ieee)->mtu +
 				    sizeof(struct ieee80211_hdr) +
 				    8 /* LLC */ +
 				    2 /* alignment */ +
@@ -175,7 +175,7 @@
 {
 	if (ieee->iw_mode == IW_MODE_MASTER) {
 		printk(KERN_DEBUG "%s: Master mode not yet suppported.\n",
-		       ieee->dev->name);
+		       ieee80211_dev(ieee)->name);
 		return 0;
 /*
   hostap_update_sta_ps(ieee, (struct hostap_ieee80211_hdr *)
@@ -233,7 +233,7 @@
 static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
 				    struct sk_buff *skb)
 {
-	struct net_device *dev = ieee->dev;
+	struct net_device *dev = ieee80211_dev(ieee);
 	u16 fc, ethertype;
 	struct ieee80211_hdr *hdr;
 	u8 *pos;
@@ -289,7 +289,7 @@
 		if (net_ratelimit()) {
 			printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
 			       "received packet from " MAC_FMT "\n",
-			       ieee->dev->name, MAC_ARG(hdr->addr2));
+			       ieee80211_dev(ieee)->name, MAC_ARG(hdr->addr2));
 		}
 		return -1;
 	}
@@ -334,7 +334,7 @@
 	if (res < 0) {
 		printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
 		       " (SA=" MAC_FMT " keyidx=%d)\n",
-		       ieee->dev->name, MAC_ARG(hdr->addr2), keyidx);
+		       ieee80211_dev(ieee)->name, MAC_ARG(hdr->addr2), keyidx);
 		return -1;
 	}
 
@@ -348,7 +348,7 @@
 int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
 		 struct ieee80211_rx_stats *rx_stats)
 {
-	struct net_device *dev = ieee->dev;
+	struct net_device *dev = ieee80211_dev(ieee);
 	struct ieee80211_hdr *hdr;
 	size_t hdrlen;
 	u16 fc, type, stype, sc;
@@ -1194,7 +1194,7 @@
 		IEEE80211_DEBUG_MGMT("received UNKNOWN (%d)\n",
 				     WLAN_FC_GET_STYPE(header->frame_ctl));
 		IEEE80211_WARNING("%s: Unknown management packet: %d\n",
-				  ieee->dev->name,
+				  ieee80211_dev(ieee)->name,
 				  WLAN_FC_GET_STYPE(header->frame_ctl));
 		break;
 	}
Index: netdev/net/ieee80211/ieee80211_tx.c
===================================================================
--- netdev.orig/net/ieee80211/ieee80211_tx.c	2005-06-03 13:20:40.000000000 +0200
+++ netdev/net/ieee80211/ieee80211_tx.c	2005-06-03 13:20:46.000000000 +0200
@@ -171,7 +171,7 @@
 		if (net_ratelimit()) {
 			printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
 			       "TX packet to " MAC_FMT "\n",
-			       ieee->dev->name, MAC_ARG(header->addr1));
+			       ieee80211_dev(ieee)->name, MAC_ARG(header->addr1));
 		}
 		return -1;
 	}
@@ -192,7 +192,7 @@
 	atomic_dec(&crypt->refcnt);
 	if (res < 0) {
 		printk(KERN_INFO "%s: Encryption failed: len=%d.\n",
-		       ieee->dev->name, frag->len);
+		       ieee80211_dev(ieee)->name, frag->len);
 		ieee->ieee_stats.tx_discards++;
 		return -1;
 	}
@@ -269,13 +269,13 @@
 	 * creating it... */
 	if (!ieee->hard_start_xmit) {
 		printk(KERN_WARNING "%s: No xmit handler.\n",
-		       ieee->dev->name);
+		       dev->name);
 		goto success;
 	}
 
 	if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) {
 		printk(KERN_WARNING "%s: skb too small (%d).\n",
-		       ieee->dev->name, skb->len);
+		       dev->name, skb->len);
 		goto success;
 	}
 
@@ -371,7 +371,7 @@
 	txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC);
 	if (unlikely(!txb)) {
 		printk(KERN_WARNING "%s: Could not allocate TXB\n",
-		       ieee->dev->name);
+		       dev->name);
 		goto failed;
 	}
 	txb->encrypted = encrypt;
@@ -426,7 +426,7 @@
 	dev_kfree_skb_any(skb);
 
 	if (txb) {
-		if ((*ieee->hard_start_xmit)(txb, dev) == 0) {
+		if ((*ieee->hard_start_xmit)(txb, ieee) == 0) {
 			stats->tx_packets++;
 			stats->tx_bytes += txb->payload_size;
 			return 0;
Index: netdev/net/ieee80211/ieee80211_wx.c
===================================================================
--- netdev.orig/net/ieee80211/ieee80211_wx.c	2005-06-01 11:05:14.000000000 +0200
+++ netdev/net/ieee80211/ieee80211_wx.c	2005-06-03 13:20:46.000000000 +0200
@@ -252,7 +252,7 @@
 			    union iwreq_data *wrqu, char *keybuf)
 {
 	struct iw_point *erq = &(wrqu->encoding);
-	struct net_device *dev = ieee->dev;
+	struct net_device *dev = ieee80211_dev(ieee);
 	struct ieee80211_security sec = {
 		.flags = 0
 	};
@@ -402,7 +402,7 @@
 	sec.level = SEC_LEVEL_1; /* 40 and 104 bit WEP */
 
 	if (ieee->set_security)
-		ieee->set_security(dev, &sec);
+		ieee->set_security(ieee, &sec);
 
 	/* Do not reset port if card is in Managed mode since resetting will
 	 * generate new IEEE 802.11 authentication which may end up in looping
@@ -411,7 +411,7 @@
 	 * the callbacks structures used to initialize the 802.11 stack. */
 	if (ieee->reset_on_keychange &&
 	    ieee->iw_mode != IW_MODE_INFRA &&
-	    ieee->reset_port && ieee->reset_port(dev)) {
+	    ieee->reset_port && ieee->reset_port(ieee)) {
 		printk(KERN_DEBUG "%s: reset_port failed\n", dev->name);
 		return -EINVAL;
 	}


-- 
Jiri Benc
SUSE Labs

^ permalink raw reply

* [5/9] ipw: fix after "ieee80211_device alignment fix"
From: Jiri Benc @ 2005-06-03 16:32 UTC (permalink / raw)
  To: NetDev; +Cc: Jeff Garzik, Jirka Bohac
In-Reply-To: <20050603182625.64d33be3@griffin.suse.cz>

Fixes ipw2100 and ipw2200 after the API change (alignment,
struct iee80211_device).

Signed-off-by: Jiri Benc <jbenc@suse.cz>
Signed-off-by: Jirka Bohac <jbohac@suse.cz>

Index: netdev/drivers/net/wireless/ipw2100.c
===================================================================
--- netdev.orig/drivers/net/wireless/ipw2100.c	2005-06-01 11:03:37.000000000 +0200
+++ netdev/drivers/net/wireless/ipw2100.c	2005-06-03 11:57:33.000000000 +0200
@@ -1772,7 +1772,7 @@
 /* Called by register_netdev() */
 static int ipw2100_net_init(struct net_device *dev)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	return ipw2100_up(priv, 1);
 }
 
@@ -3248,9 +3248,9 @@
 	return IRQ_NONE;
 }
 
-static int ipw2100_tx(struct ieee80211_txb *txb, struct net_device *dev)
+static int ipw2100_tx(struct ieee80211_txb *txb, struct ieee80211_device *ieee)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_priv(ieee);
 	struct list_head *element;
 	struct ipw2100_tx_packet *packet;
 	unsigned long flags;
@@ -3260,7 +3260,7 @@
 	if (!(priv->status & STATUS_ASSOCIATED)) {
 		IPW_DEBUG_INFO("Can not transmit when not connected.\n");
 		priv->ieee->stats.tx_carrier_errors++;
-		netif_stop_queue(dev);
+		netif_stop_queue(ieee80211_dev(ieee));
 		goto fail_unlock;
 	}
 
@@ -3291,7 +3291,7 @@
 	return 0;
 
  fail_unlock:
-	netif_stop_queue(dev);
+	netif_stop_queue(ieee80211_dev(ieee));
 	spin_unlock_irqrestore(&priv->low_lock, flags);
 	return 1;
 }
@@ -5418,10 +5418,10 @@
 		ipw2100_configure_security(priv, 0);
 }
 
-static void shim__set_security(struct net_device *dev,
+static void shim__set_security(struct ieee80211_device *ieee,
 			       struct ieee80211_security *sec)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_priv(ieee);
 	int i, force_update = 0;
 
 	down(&priv->action_sem);
@@ -5609,7 +5609,7 @@
  * method as well) to talk to the firmware */
 static int ipw2100_set_address(struct net_device *dev, void *p)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	struct sockaddr *addr = p;
 	int err = 0;
 
@@ -5637,7 +5637,7 @@
 
 static int ipw2100_open(struct net_device *dev)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	unsigned long flags;
 	IPW_DEBUG_INFO("dev->open\n");
 
@@ -5651,7 +5651,7 @@
 
 static int ipw2100_close(struct net_device *dev)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	unsigned long flags;
 	struct list_head *element;
 	struct ipw2100_tx_packet *packet;
@@ -5692,7 +5692,7 @@
  */
 static void ipw2100_tx_timeout(struct net_device *dev)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 
 	priv->ieee->stats.tx_errors++;
 
@@ -5715,7 +5715,7 @@
  */
 static struct net_device_stats *ipw2100_stats(struct net_device *dev)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 
 	return &priv->ieee->stats;
 }
@@ -5802,7 +5802,7 @@
 	}
 
 	if (ieee->set_security)
-		ieee->set_security(ieee->dev, &sec);
+		ieee->set_security(ieee, &sec);
 	else
 		ret = -EOPNOTSUPP;
 
@@ -5829,7 +5829,7 @@
 	}
 
 	if (ieee->set_security)
-		ieee->set_security(ieee->dev, &sec);
+		ieee->set_security(ieee, &sec);
 	else
 		ret = -EOPNOTSUPP;
 
@@ -5839,7 +5839,7 @@
 
 static int ipw2100_wpa_set_param(struct net_device *dev, u8 name, u32 value){
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	int ret=0;
 
 	switch(name){
@@ -5878,7 +5878,7 @@
 
 static int ipw2100_wpa_mlme(struct net_device *dev, int command, int reason){
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	int ret=0;
 
 	switch(command){
@@ -5920,8 +5920,8 @@
 static int ipw2100_wpa_set_wpa_ie(struct net_device *dev,
 				struct ipw2100_param *param, int plen){
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
-	struct ieee80211_device *ieee = priv->ieee;
+	struct ieee80211_device *ieee = netdev_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_priv(ieee);
 	u8 *buf;
 
 	if (! ieee->wpa_enabled)
@@ -5960,8 +5960,8 @@
 				struct ipw2100_param *param, int param_len){
 
 	int ret = 0;
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
-	struct ieee80211_device *ieee = priv->ieee;
+	struct ieee80211_device *ieee = netdev_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_priv(ieee);
 	struct ieee80211_crypto_ops *ops;
 	struct ieee80211_crypt_data **crypt;
 
@@ -6081,7 +6081,7 @@
 	}
  done:
 	if (ieee->set_security)
-		ieee->set_security(ieee->dev, &sec);
+		ieee->set_security(ieee, &sec);
 
 	/* Do not reset port if card is in Managed mode since resetting will
 	 * generate new IEEE 802.11 authentication which may end up in looping
@@ -6178,7 +6178,7 @@
 static void ipw_ethtool_get_drvinfo(struct net_device *dev,
 				    struct ethtool_drvinfo *info)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	char fw_ver[64], ucode_ver[64];
 
 	strcpy(info->driver, DRV_NAME);
@@ -6195,7 +6195,7 @@
 
 static u32 ipw2100_ethtool_get_link(struct net_device *dev)
 {
-    struct ipw2100_priv *priv = ieee80211_priv(dev);
+    struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
     return (priv->status & STATUS_ASSOCIATED) ? 1 : 0;
 }
 
@@ -6288,12 +6288,14 @@
 {
 	struct ipw2100_priv *priv;
 	struct net_device *dev;
+	struct ieee80211_device *ieee;
 
-	dev = alloc_ieee80211(sizeof(struct ipw2100_priv));
-	if (!dev)
+	ieee = alloc_ieee80211(sizeof(struct ipw2100_priv));
+	if (!ieee)
 		return NULL;
-	priv = ieee80211_priv(dev);
-	priv->ieee = netdev_priv(dev);
+	dev = ieee80211_dev(ieee);
+	priv = ieee80211_priv(ieee);
+	priv->ieee = ieee;
 	priv->pci_dev = pci_dev;
 	priv->net_dev = dev;
 
@@ -6477,7 +6479,7 @@
 		return err;
 	}
 
-	priv = ieee80211_priv(dev);
+	priv = ieee80211_dev_to_priv(dev);
 
 	pci_set_master(pci_dev);
 	pci_set_drvdata(pci_dev, priv);
@@ -6618,7 +6620,7 @@
 		ipw2100_queues_free(priv);
 		sysfs_remove_group(&pci_dev->dev.kobj, &ipw2100_attribute_group);
 
-		free_ieee80211(dev);
+		free_ieee80211(netdev_priv(dev));
 		pci_set_drvdata(pci_dev, NULL);
 	}
 
@@ -6675,7 +6677,7 @@
 		if (dev->base_addr)
 			iounmap((unsigned char *)dev->base_addr);
 
-		free_ieee80211(dev);
+		free_ieee80211(netdev_priv(dev));
 	}
 
 	pci_release_regions(pci_dev);
@@ -6918,7 +6920,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	if (!(priv->status & STATUS_ASSOCIATED))
 		strcpy(wrqu->name, "unassociated");
 	else
@@ -6933,7 +6935,7 @@
 			       struct iw_request_info *info,
 			       union iwreq_data *wrqu, char *extra)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	struct iw_freq *fwrq = &wrqu->freq;
 	int err = 0;
 
@@ -6984,7 +6986,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 
 	wrqu->freq.e = 0;
 
@@ -7005,7 +7007,7 @@
 			       struct iw_request_info *info,
 			       union iwreq_data *wrqu, char *extra)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	int err = 0;
 
 	IPW_DEBUG_WX("SET Mode -> %d \n", wrqu->mode);
@@ -7048,7 +7050,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 
 	wrqu->mode = priv->ieee->iw_mode;
 	IPW_DEBUG_WX("GET Mode -> %d\n", wrqu->mode);
@@ -7084,7 +7086,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	struct iw_range *range = (struct iw_range *)extra;
 	u16 val;
 	int i, level;
@@ -7196,7 +7198,7 @@
 			      struct iw_request_info *info,
 			      union iwreq_data *wrqu, char *extra)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	int err = 0;
 
 	static const unsigned char any[] = {
@@ -7251,7 +7253,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 
 	/* If we are associated, trying to associate, or have a statically
 	 * configured BSSID then return that; otherwise return ANY */
@@ -7271,7 +7273,7 @@
 				struct iw_request_info *info,
 				union iwreq_data *wrqu, char *extra)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	char *essid = ""; /* ANY */
 	int length = 0;
 	int err = 0;
@@ -7325,7 +7327,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 
 	/* If we are associated, trying to associate, or have a statically
 	 * configured ESSID then return that; otherwise return ANY */
@@ -7353,7 +7355,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 
 	if (wrqu->data.length > IW_ESSID_MAX_SIZE)
 		return -E2BIG;
@@ -7375,7 +7377,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 
 	wrqu->data.length = strlen(priv->nick) + 1;
 	memcpy(extra, priv->nick, wrqu->data.length);
@@ -7390,7 +7392,7 @@
 			       struct iw_request_info *info,
 			       union iwreq_data *wrqu, char *extra)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	u32 target_rate = wrqu->bitrate.value;
 	u32 rate;
 	int err = 0;
@@ -7431,7 +7433,7 @@
 			       struct iw_request_info *info,
 			       union iwreq_data *wrqu, char *extra)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	int val;
 	int len = sizeof(val);
 	int err = 0;
@@ -7483,7 +7485,7 @@
 			      struct iw_request_info *info,
 			      union iwreq_data *wrqu, char *extra)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	int value, err;
 
 	/* Auto RTS not yet supported */
@@ -7523,7 +7525,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 
 	wrqu->rts.value = priv->rts_threshold & ~RTS_DISABLED;
 	wrqu->rts.fixed = 1; /* no auto select */
@@ -7540,7 +7542,7 @@
 				struct iw_request_info *info,
 				union iwreq_data *wrqu, char *extra)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	int err = 0, value;
 
 	if (priv->ieee->iw_mode != IW_MODE_ADHOC)
@@ -7580,7 +7582,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 
 	if (priv->ieee->iw_mode != IW_MODE_ADHOC) {
 		wrqu->power.disabled = 1;
@@ -7616,7 +7618,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 
 	if (!wrqu->frag.fixed)
 		return -EINVAL;
@@ -7646,7 +7648,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	wrqu->frag.value = priv->frag_threshold & ~FRAG_DISABLED;
 	wrqu->frag.fixed = 0;	/* no auto select */
 	wrqu->frag.disabled = (priv->frag_threshold & FRAG_DISABLED) ? 1 : 0;
@@ -7660,7 +7662,7 @@
 				struct iw_request_info *info,
 				union iwreq_data *wrqu, char *extra)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	int err = 0;
 
 	if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
@@ -7709,7 +7711,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 
 	wrqu->retry.disabled = 0; /* can't be disabled */
 
@@ -7738,7 +7740,7 @@
 			       struct iw_request_info *info,
 			       union iwreq_data *wrqu, char *extra)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	int err = 0;
 
 	down(&priv->action_sem);
@@ -7769,7 +7771,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	return ieee80211_wx_get_scan(priv->ieee, info, wrqu, extra);
 }
 
@@ -7785,7 +7787,7 @@
 	 * No check of STATUS_INITIALIZED required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	return ieee80211_wx_set_encode(priv->ieee, info, wrqu, key);
 }
 
@@ -7797,7 +7799,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	return ieee80211_wx_get_encode(priv->ieee, info, wrqu, key);
 }
 
@@ -7805,7 +7807,7 @@
 			        struct iw_request_info *info,
 			        union iwreq_data *wrqu, char *extra)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	int err = 0;
 
 	down(&priv->action_sem);
@@ -7855,7 +7857,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 
 	if (!(priv->power_mode & IPW_POWER_ENABLED)) {
 		wrqu->power.disabled = 1;
@@ -7880,7 +7882,7 @@
 				  struct iw_request_info *info,
 				  union iwreq_data *wrqu, char *extra)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	int *parms = (int *)extra;
 	int enable = (parms[0] > 0);
 	int err = 0;
@@ -7911,7 +7913,7 @@
 			    struct iw_request_info *info,
 			    union iwreq_data *wrqu, char *extra)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	if (priv->status & STATUS_INITIALIZED)
 		schedule_reset(priv);
 	return 0;
@@ -7923,7 +7925,7 @@
 				    struct iw_request_info *info,
 				    union iwreq_data *wrqu, char *extra)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	int err = 0, mode = *(int *)extra;
 
 	down(&priv->action_sem);
@@ -7951,7 +7953,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	int level = IPW_POWER_LEVEL(priv->power_mode);
 	s32 timeout, period;
 
@@ -7988,7 +7990,7 @@
 				   struct iw_request_info *info,
 				   union iwreq_data *wrqu, char *extra)
 {
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	int err, mode = *(int *)extra;
 
 	down(&priv->action_sem);
@@ -8021,7 +8023,7 @@
 	 * This can be called at any time.  No action lock required
 	 */
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 
 	if (priv->config & CFG_LONG_PREAMBLE)
 		snprintf(wrqu->name, IFNAMSIZ, "long (1)");
@@ -8163,7 +8165,7 @@
 	int tx_qual;
 	int beacon_qual;
 
-	struct ipw2100_priv *priv = ieee80211_priv(dev);
+	struct ipw2100_priv *priv = ieee80211_dev_to_priv(dev);
 	struct iw_statistics *wstats;
 	u32 rssi, quality, tx_retries, missed_beacons, tx_failures;
 	u32 ord_len = sizeof(u32);
Index: netdev/drivers/net/wireless/ipw2200.c
===================================================================
--- netdev.orig/drivers/net/wireless/ipw2200.c	2005-06-01 11:03:37.000000000 +0200
+++ netdev/drivers/net/wireless/ipw2200.c	2005-06-03 11:57:33.000000000 +0200
@@ -5157,7 +5157,7 @@
 			   struct iw_request_info *info, 
 			   union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	if (!(priv->status & STATUS_ASSOCIATED))
 		strcpy(wrqu->name, "unassociated");
 	else 
@@ -5210,7 +5210,7 @@
 			   struct iw_request_info *info, 
 			   union iwreq_data *wrqu, char *extra) 
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	struct iw_freq *fwrq = &wrqu->freq;
 	
 	/* if setting by freq convert to channel */
@@ -5244,7 +5244,7 @@
 			   struct iw_request_info *info, 
 			   union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 
 	wrqu->freq.e = 0;
 
@@ -5264,7 +5264,7 @@
 			   struct iw_request_info *info, 
 			   union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	int err = 0;
 
 	IPW_DEBUG_WX("Set MODE: %d\n", wrqu->mode);
@@ -5317,7 +5317,7 @@
 			       struct iw_request_info *info, 
 			       union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 
 	wrqu->mode = priv->ieee->iw_mode;
 	IPW_DEBUG_WX("Get MODE -> %d\n", wrqu->mode);
@@ -5354,7 +5354,7 @@
 			    struct iw_request_info *info, 
 			    union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	struct iw_range *range = (struct iw_range *)extra;
 	u16 val;
 	int i;
@@ -5418,7 +5418,7 @@
 			  struct iw_request_info *info, 
 			  union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 
 	static const unsigned char any[] = {
 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff
@@ -5472,7 +5472,7 @@
 			  struct iw_request_info *info, 
 			  union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	/* If we are associated, trying to associate, or have a statically
 	 * configured BSSID then return that; otherwise return ANY */
 	if (priv->config & CFG_STATIC_BSSID || 
@@ -5491,7 +5491,7 @@
 			    struct iw_request_info *info, 
 			    union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	char *essid = ""; /* ANY */
 	int length = 0;
   
@@ -5543,7 +5543,7 @@
 			    struct iw_request_info *info, 
 			    union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 
 	/* If we are associated, trying to associate, or have a statically
 	 * configured ESSID then return that; otherwise return ANY */
@@ -5567,7 +5567,7 @@
 			   struct iw_request_info *info, 
 			   union iwreq_data *wrqu, char *extra)
 { 
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 
 	IPW_DEBUG_WX("Setting nick to '%s'\n", extra);
 	if (wrqu->data.length > IW_ESSID_MAX_SIZE)
@@ -5586,7 +5586,7 @@
 			   struct iw_request_info *info, 
 			   union iwreq_data *wrqu, char *extra)
 { 
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	IPW_DEBUG_WX("Getting nick\n");
 	wrqu->data.length = strlen(priv->nick) + 1;
 	memcpy(extra, priv->nick, wrqu->data.length);
@@ -5607,7 +5607,7 @@
 			   struct iw_request_info *info, 
 			   union iwreq_data *wrqu, char *extra)
 { 
-	struct ipw_priv * priv = ieee80211_priv(dev);
+	struct ipw_priv * priv = ieee80211_dev_to_priv(dev);
 	wrqu->bitrate.value = priv->last_rate;
 
 	IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value);
@@ -5619,7 +5619,7 @@
 			  struct iw_request_info *info, 
 			  union iwreq_data *wrqu, char *extra)
 { 
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 
 	if (wrqu->rts.disabled)
 		priv->rts_threshold = DEFAULT_RTS_THRESHOLD;
@@ -5640,7 +5640,7 @@
 			  struct iw_request_info *info, 
 			  union iwreq_data *wrqu, char *extra)
 { 
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	wrqu->rts.value = priv->rts_threshold;
 	wrqu->rts.fixed = 0;	/* no auto select */
 	wrqu->rts.disabled = 
@@ -5655,7 +5655,7 @@
 			    struct iw_request_info *info, 
 			    union iwreq_data *wrqu, char *extra)
 { 
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	struct ipw_tx_power tx_power;
 	int i;
 
@@ -5699,7 +5699,7 @@
 			    struct iw_request_info *info, 
 			    union iwreq_data *wrqu, char *extra)
 { 
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 
 	wrqu->power.value = priv->tx_power;
 	wrqu->power.fixed = 1;
@@ -5717,7 +5717,7 @@
 			       struct iw_request_info *info, 
 			       union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 
 	if (wrqu->frag.disabled)
 		priv->ieee->fts = DEFAULT_FTS;
@@ -5738,7 +5738,7 @@
 			       struct iw_request_info *info, 
 			       union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	wrqu->frag.value = priv->ieee->fts;
 	wrqu->frag.fixed = 0;	/* no auto select */
 	wrqu->frag.disabled = 
@@ -5771,7 +5771,7 @@
 			   struct iw_request_info *info, 
 			   union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	IPW_DEBUG_WX("Start scan\n");
 	if (ipw_request_scan(priv))
 		return -EIO;
@@ -5782,7 +5782,7 @@
 			   struct iw_request_info *info, 
 			   union iwreq_data *wrqu, char *extra)
 { 
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	return ieee80211_wx_get_scan(priv->ieee, info, wrqu, extra);
 }
 
@@ -5790,7 +5790,7 @@
 				 struct iw_request_info *info, 
 				 union iwreq_data *wrqu, char *key)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	return ieee80211_wx_set_encode(priv->ieee, info, wrqu, key);
 }
 
@@ -5798,7 +5798,7 @@
 				 struct iw_request_info *info, 
 				 union iwreq_data *wrqu, char *key)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	return ieee80211_wx_get_encode(priv->ieee, info, wrqu, key);
 }
 
@@ -5806,7 +5806,7 @@
 			        struct iw_request_info *info, 
 			        union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	int err;
 
 	if (wrqu->power.disabled) {
@@ -5855,7 +5855,7 @@
 			        struct iw_request_info *info, 
 			        union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 
 	if (!(priv->power_mode & IPW_POWER_ENABLED)) {
 		wrqu->power.disabled = 1;
@@ -5872,7 +5872,7 @@
 				    struct iw_request_info *info, 
 				    union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	int mode = *(int *)extra;
 	int err;
 	
@@ -5900,7 +5900,7 @@
 				    struct iw_request_info *info, 
 				    union iwreq_data *wrqu, char *extra)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	int level = IPW_POWER_LEVEL(priv->power_mode);
 	char *p = extra;
 
@@ -5932,7 +5932,7 @@
                                     struct iw_request_info *info,
                                     union iwreq_data *wrqu, char *extra)
 {
-        struct ipw_priv *priv = ieee80211_priv(dev);
+        struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	int mode = *(int *)extra;
 	u8 band = 0, modulation = 0;
 
@@ -5998,7 +5998,7 @@
                                     struct iw_request_info *info,
                                     union iwreq_data *wrqu, char *extra)
 {
-        struct ipw_priv *priv = ieee80211_priv(dev);
+        struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 
 	switch (priv->ieee->freq_band) {
 	case IEEE80211_24GHZ_BAND:
@@ -6046,7 +6046,7 @@
 			      struct iw_request_info *info, 
 			      union iwreq_data *wrqu, char *extra)
 { 
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	int *parms = (int *)extra;
 	int enable = (parms[0] > 0);
 
@@ -6072,7 +6072,7 @@
 			struct iw_request_info *info, 
 			union iwreq_data *wrqu, char *extra)
 { 
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	IPW_DEBUG_WX("RESET\n");
 	ipw_adapter_restart(priv);
 	return 0;
@@ -6185,7 +6185,7 @@
  */
 static struct iw_statistics *ipw_get_wireless_stats(struct net_device * dev)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	struct iw_statistics *wstats;
 	
 	wstats = &priv->wstats;
@@ -6248,7 +6248,7 @@
 
 static int ipw_net_open(struct net_device *dev)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	IPW_DEBUG_INFO("dev->open\n");
 	/* we should be verifying the device is ready to be opened */
 	if (!(priv->status & STATUS_RF_KILL_MASK) && 
@@ -6394,9 +6394,9 @@
 }
 
 static int ipw_net_hard_start_xmit(struct ieee80211_txb *txb,
-				   struct net_device *dev)
+				   struct ieee80211_device *ieee)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_priv(ieee);
 	unsigned long flags;
 
 	IPW_DEBUG_TX("dev->xmit(%d bytes)\n", txb->payload_size);
@@ -6406,7 +6406,7 @@
 	if (!(priv->status & STATUS_ASSOCIATED)) {
 		IPW_DEBUG_INFO("Tx attempt while not associated.\n");
 		priv->ieee->stats.tx_carrier_errors++;
-		netif_stop_queue(dev);
+		netif_stop_queue(ieee80211_dev(ieee));
 		goto fail_unlock;
 	}
 
@@ -6422,7 +6422,7 @@
 
 static struct net_device_stats *ipw_net_get_stats(struct net_device *dev)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	
 	priv->ieee->stats.tx_packets = priv->tx_packets;
 	priv->ieee->stats.rx_packets = priv->rx_packets;
@@ -6436,7 +6436,7 @@
 
 static int ipw_net_set_mac_address(struct net_device *dev, void *p)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	struct sockaddr *addr = p;
 	if (!is_valid_ether_addr(addr->sa_data))
 		return -EADDRNOTAVAIL;
@@ -6451,7 +6451,7 @@
 static void ipw_ethtool_get_drvinfo(struct net_device *dev, 
 				    struct ethtool_drvinfo *info)
 {
-	struct ipw_priv *p = ieee80211_priv(dev);
+	struct ipw_priv *p = ieee80211_dev_to_priv(dev);
 	char vers[64];
 	char date[32];
 	u32 len;
@@ -6472,7 +6472,7 @@
 
 static u32 ipw_ethtool_get_link(struct net_device *dev)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 	return (priv->status & STATUS_ASSOCIATED) != 0;
 }
 
@@ -6484,7 +6484,7 @@
 static int ipw_ethtool_get_eeprom(struct net_device *dev,
 				  struct ethtool_eeprom *eeprom, u8 *bytes)
 {
-	struct ipw_priv *p = ieee80211_priv(dev);
+	struct ipw_priv *p = ieee80211_dev_to_priv(dev);
 
 	if (eeprom->offset + eeprom->len > CX2_EEPROM_IMAGE_SIZE)
 		return -EINVAL;
@@ -6496,7 +6496,7 @@
 static int ipw_ethtool_set_eeprom(struct net_device *dev,
 				  struct ethtool_eeprom *eeprom, u8 *bytes)
 {
-	struct ipw_priv *p = ieee80211_priv(dev);
+	struct ipw_priv *p = ieee80211_dev_to_priv(dev);
 	int i;
 
 	if (eeprom->offset + eeprom->len > CX2_EEPROM_IMAGE_SIZE)
@@ -6633,10 +6633,10 @@
 }
 
 
-static void shim__set_security(struct net_device *dev,
+static void shim__set_security(struct ieee80211_device *ieee,
 			       struct ieee80211_security *sec)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_priv(ieee);
 	int i;
 
 	for (i = 0; i < 4; i++) { 
@@ -6874,7 +6874,7 @@
 /* Called by register_netdev() */
 static int ipw_net_init(struct net_device *dev)
 {
-	struct ipw_priv *priv = ieee80211_priv(dev);
+	struct ipw_priv *priv = ieee80211_dev_to_priv(dev);
 
 	if (priv->status & STATUS_RF_KILL_SW) {
 		IPW_WARNING("Radio disabled by module parameter.\n");
@@ -6952,19 +6952,21 @@
 {
 	int err = 0;
 	struct net_device *net_dev;
+	struct ieee80211_device *ieee;
 	void __iomem *base;
 	u32 length, val;
 	struct ipw_priv *priv;
 	int band, modulation;
 
-	net_dev = alloc_ieee80211(sizeof(struct ipw_priv));
-	if (net_dev == NULL) {
+	ieee = alloc_ieee80211(sizeof(struct ipw_priv));
+	if (ieee == NULL) {
 		err = -ENOMEM;
 		goto out;
 	}
+	net_dev = ieee80211_dev(ieee);
 
-	priv = ieee80211_priv(net_dev);
-	priv->ieee = netdev_priv(net_dev);
+	priv = ieee80211_priv(ieee);
+	priv->ieee = ieee;
 	priv->net_dev = net_dev;
 	priv->pci_dev = pdev;
 #ifdef CONFIG_IPW_DEBUG
@@ -7160,7 +7162,7 @@
 	pci_disable_device(pdev);
 	pci_set_drvdata(pdev, NULL);
  out_free_ieee80211:
-	free_ieee80211(priv->net_dev);
+	free_ieee80211(priv->ieee);
  out:
 	return err;
 }
@@ -7202,7 +7204,7 @@
 	pci_release_regions(pdev);
 	pci_disable_device(pdev);
 	pci_set_drvdata(pdev, NULL);
-	free_ieee80211(priv->net_dev);
+	free_ieee80211(priv->ieee);
 
 #ifdef CONFIG_PM
 	if (fw_loaded) {


-- 
Jiri Benc
SUSE Labs

^ permalink raw reply

* [6/9] ieee80211: ethernet independency
From: Jiri Benc @ 2005-06-03 16:34 UTC (permalink / raw)
  To: NetDev; +Cc: Jeff Garzik, Jirka Bohac
In-Reply-To: <20050603182625.64d33be3@griffin.suse.cz>

Makes the 802.11 layer independent of ethernet. (The previous implementation
had the ethernet headers built by the ethernet layer and then parsed them and
rebuilt them into 802.11 headers.)


Signed-off-by: Jiri Benc <jbenc@suse.cz>
Signed-off-by: Jirka Bohac <jbohac@suse.cz>

Index: netdev/include/linux/netdevice.h
===================================================================
--- netdev.orig/include/linux/netdevice.h	2005-06-01 11:05:01.000000000 +0200
+++ netdev/include/linux/netdevice.h	2005-06-03 13:21:00.000000000 +0200
@@ -83,13 +83,18 @@
  *	used.
  */
  
-#if !defined(CONFIG_AX25) && !defined(CONFIG_AX25_MODULE) && !defined(CONFIG_TR)
+#if !defined(CONFIG_AX25) && !defined(CONFIG_AX25_MODULE) && !defined(CONFIG_TR) \
+	&& !defined(CONFIG_IEEE80211)
 #define LL_MAX_HEADER	32
 #else
 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
 #define LL_MAX_HEADER	96
 #else
+#if defined(CONFIG_TR)
 #define LL_MAX_HEADER	48
+#else
+#define LL_MAX_HEADER	38
+#endif
 #endif
 #endif
 
Index: netdev/include/net/ieee80211.h
===================================================================
--- netdev.orig/include/net/ieee80211.h	2005-06-03 13:20:46.000000000 +0200
+++ netdev/include/net/ieee80211.h	2005-06-03 13:21:00.000000000 +0200
@@ -20,7 +20,6 @@
  */
 #ifndef IEEE80211_H
 #define IEEE80211_H
-#include <linux/if_ether.h> /* ETH_ALEN */
 #include <linux/kernel.h>   /* ARRAY_SIZE */
 
 #if WIRELESS_EXT < 17
@@ -42,25 +41,26 @@
    WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
 
 
+#define IEEE80211_ALEN			6
 #define IEEE80211_HLEN			30
 #define IEEE80211_FRAME_LEN		(IEEE80211_DATA_LEN + IEEE80211_HLEN)
 
 struct ieee80211_hdr {
 	u16 frame_ctl;
 	u16 duration_id;
-	u8 addr1[ETH_ALEN];
-	u8 addr2[ETH_ALEN];
-	u8 addr3[ETH_ALEN];
+	u8 addr1[IEEE80211_ALEN];
+	u8 addr2[IEEE80211_ALEN];
+	u8 addr3[IEEE80211_ALEN];
 	u16 seq_ctl;
-	u8 addr4[ETH_ALEN];
+	u8 addr4[IEEE80211_ALEN];
 } __attribute__ ((packed));
 
 struct ieee80211_hdr_3addr {
 	u16 frame_ctl;
 	u16 duration_id;
-	u8 addr1[ETH_ALEN];
-	u8 addr2[ETH_ALEN];
-	u8 addr3[ETH_ALEN];
+	u8 addr1[IEEE80211_ALEN];
+	u8 addr2[IEEE80211_ALEN];
+	u8 addr3[IEEE80211_ALEN];
 	u16 seq_ctl;
 } __attribute__ ((packed));
 
@@ -233,7 +233,7 @@
 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
 
 #ifndef ETH_P_80211_RAW
-#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
+#define ETH_P_80211_RAW 0x0003
 #endif
 
 /* IEEE 802.11 defines */
@@ -246,11 +246,29 @@
         u8    ssap;   /* always 0xAA */
         u8    ctrl;   /* always 0x03 */
         u8    oui[P80211_OUI_LEN];    /* organizational universal id */
+	u16   type;   /* packet type ID field */
 
 } __attribute__ ((packed));
 
 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
 
+#define IEEE80211_SNAP_IS_RFC1042(snap) \
+		((snap)->oui[0] == 0 && (snap)->oui[1] == 0 && (snap)->oui[2] == 0)
+#define IEEE80211_SNAP_IS_BRIDGE_TUNNEL(snap) \
+		((snap)->oui[0] == 0 && (snap)->oui[1] == 0 && (snap)->oui[2] == 0xf8)
+
+#define IEEE80211_FC_GET_TODS(hdr) \
+		((hdr)->frame_ctl & __constant_cpu_to_le16(IEEE80211_FCTL_TODS))
+#define IEEE80211_FC_GET_FROMDS(hdr) \
+		((hdr)->frame_ctl & __constant_cpu_to_le16(IEEE80211_FCTL_FROMDS))
+#define IEEE80211_GET_DADDR(hdr) \
+		(IEEE80211_FC_GET_TODS(hdr) ? (hdr)->addr3 : (hdr)->addr1)
+#define IEEE80211_GET_SADDR(hdr) \
+		(IEEE80211_FC_GET_FROMDS(hdr) ? \
+			(IEEE80211_FC_GET_TODS(hdr) ? (hdr)->addr4 : (hdr)->addr3) \
+			: (hdr)->addr2)
+/* IEEE80211_GET_xADDR do not work when both TODS and FROMDS are set. */
+
 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
 
@@ -395,8 +413,8 @@
 	unsigned int seq;
 	unsigned int last_frag;
 	struct sk_buff *skb;
-	u8 src_addr[ETH_ALEN];
-	u8 dst_addr[ETH_ALEN];
+	u8 src_addr[IEEE80211_ALEN];
+	u8 dst_addr[IEEE80211_ALEN];
 };
 
 struct ieee80211_stats {
@@ -507,7 +525,7 @@
 	u16 auth_sequence;
 	u16 beacon_interval;
 	u16 capability;
-	u8 current_ap[ETH_ALEN];
+	u8 current_ap[IEEE80211_ALEN];
 	u16 listen_interval;
 	struct {
 		u16 association_id:14, reserved:2;
@@ -537,7 +555,7 @@
 struct ieee80211_assoc_request_frame {
 	u16 capability;
 	u16 listen_interval;
-	u8 current_ap[ETH_ALEN];
+	u8 current_ap[IEEE80211_ALEN];
 	struct ieee80211_info_element info_element;
 } __attribute__ ((packed));
 
@@ -581,7 +599,7 @@
 
 struct ieee80211_network {
 	/* These entries are used to identify a unique network */
-	u8 bssid[ETH_ALEN];
+	u8 bssid[IEEE80211_ALEN];
 	u8 channel;
 	/* Ensure null-terminated for any debug msgs */
 	u8 ssid[IW_ESSID_MAX_SIZE + 1];
@@ -625,12 +643,12 @@
 #define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
 
 
-extern inline int is_multicast_ether_addr(const u8 *addr)
+extern inline int is_multicast_ieee80211_addr(const u8 *addr)
 {
 	return ((addr[0] != 0xff) && (0x01 & addr[0]));
 }
 
-extern inline int is_broadcast_ether_addr(const u8 *addr)
+extern inline int is_broadcast_ieee80211_addr(const u8 *addr)
 {
 	return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&   \
 		(addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
@@ -694,7 +712,7 @@
 	u16 fts; /* Fragmentation Threshold */
 
 	/* Association info */
-	u8 bssid[ETH_ALEN];
+	u8 bssid[IEEE80211_ALEN];
 
 	enum ieee80211_state state;
 
@@ -783,7 +801,7 @@
 	return 0;
 }
 
-extern inline int ieee80211_get_hdrlen(u16 fc)
+extern inline int __ieee80211_get_hdrlen(u16 fc)
 {
 	int hdrlen = IEEE80211_3ADDR_LEN;
 
@@ -807,12 +825,29 @@
 
 	return hdrlen;
 }
+#define ieee80211_get_hdrlen(hdr) __ieee80211_get_hdrlen(le16_to_cpu((hdr)->frame_ctl))
 
+#define IEEE80211_GET_DATA_HDR_LEN(hdr) \
+		((((hdr)->frame_ctl & \
+			__constant_cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) \
+		 == __constant_cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) \
+		 ? IEEE80211_4ADDR_LEN : IEEE80211_3ADDR_LEN)
+#define IEEE80211_GET_SNAP(hdr) \
+		((struct ieee80211_snap_hdr *) \
+		((u8 *)(hdr) + IEEE80211_GET_DATA_HDR_LEN(hdr)))
+
+extern inline int ieee80211_get_proto(struct ieee80211_hdr *header)
+{
+	struct ieee80211_snap_hdr *snap = IEEE80211_GET_SNAP(header);
+	return (snap->dsap == 0xaa && snap->ssap == 0xaa ?
+		ntohs(snap->type) : ETH_P_802_2);
+}
 
 
 /* ieee80211.c */
 extern void free_ieee80211(struct ieee80211_device *ieee);
 extern struct ieee80211_device *alloc_ieee80211(int sizeof_priv);
+extern void ieee80211_setup(struct net_device *dev);
 
 extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
 
Index: netdev/net/ieee80211/ieee80211_rx.c
===================================================================
--- netdev.orig/net/ieee80211/ieee80211_rx.c	2005-06-03 13:20:46.000000000 +0200
+++ netdev/net/ieee80211/ieee80211_rx.c	2005-06-03 13:21:00.000000000 +0200
@@ -41,11 +41,10 @@
 					struct ieee80211_rx_stats *rx_stats)
 {
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
-	u16 fc = le16_to_cpu(hdr->frame_ctl);
 
 	skb->dev = ieee->dev;
 	skb->mac.raw = skb->data;
-	skb_pull(skb, ieee80211_get_hdrlen(fc));
+	skb_pull(skb, ieee80211_get_hdrlen(hdr));
 	skb->pkt_type = PACKET_OTHERHOST;
 	skb->protocol = __constant_htons(ETH_P_80211_RAW);
 	memset(skb->cb, 0, sizeof(skb->cb));
@@ -75,8 +74,8 @@
 
 		if (entry->skb != NULL && entry->seq == seq &&
 		    (entry->last_frag + 1 == frag || frag == -1) &&
-		    memcmp(entry->src_addr, src, ETH_ALEN) == 0 &&
-		    memcmp(entry->dst_addr, dst, ETH_ALEN) == 0)
+		    memcmp(entry->src_addr, src, IEEE80211_ALEN) == 0 &&
+		    memcmp(entry->dst_addr, dst, IEEE80211_ALEN) == 0)
 			return entry;
 	}
 
@@ -103,7 +102,7 @@
 				    sizeof(struct ieee80211_hdr) +
 				    8 /* LLC */ +
 				    2 /* alignment */ +
-				    8 /* WEP */ + ETH_ALEN /* WDS */);
+				    8 /* WEP */ + IEEE80211_ALEN /* WDS */);
 		if (skb == NULL)
 			return NULL;
 
@@ -119,8 +118,8 @@
 		entry->seq = seq;
 		entry->last_frag = frag;
 		entry->skb = skb;
-		memcpy(entry->src_addr, hdr->addr2, ETH_ALEN);
-		memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
+		memcpy(entry->src_addr, hdr->addr2, IEEE80211_ALEN);
+		memcpy(entry->dst_addr, hdr->addr1, IEEE80211_ALEN);
 	} else {
 		/* received a fragment of a frame for which the head fragment
 		 * should have already been received */
@@ -220,15 +219,6 @@
 #endif
 
 
-/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
-/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
-static unsigned char rfc1042_header[] =
-{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
-/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
-static unsigned char bridge_tunnel_header[] =
-{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
-/* No encapsulation header if EtherType < 0x600 (=length) */
-
 /* Called by ieee80211_rx_frame_decrypt */
 static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
 				    struct sk_buff *skb)
@@ -236,7 +226,6 @@
 	struct net_device *dev = ieee80211_dev(ieee);
 	u16 fc, ethertype;
 	struct ieee80211_hdr *hdr;
-	u8 *pos;
 
 	if (skb->len < 24)
 		return 0;
@@ -247,12 +236,12 @@
 	/* check that the frame is unicast frame to us */
 	if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
 	    IEEE80211_FCTL_TODS &&
-	    memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0 &&
-	    memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) {
+	    memcmp(hdr->addr1, dev->dev_addr, IEEE80211_ALEN) == 0 &&
+	    memcmp(hdr->addr3, dev->dev_addr, IEEE80211_ALEN) == 0) {
 		/* ToDS frame with own addr BSSID and DA */
 	} else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
 		   IEEE80211_FCTL_FROMDS &&
-		   memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) {
+		   memcmp(hdr->addr1, dev->dev_addr, IEEE80211_ALEN) == 0) {
 		/* FromDS frame with own addr as DA */
 	} else
 		return 0;
@@ -261,8 +250,7 @@
 		return 0;
 
 	/* check for port access entity Ethernet type */
-	pos = skb->data + 24;
-	ethertype = (pos[6] << 8) | pos[7];
+	ethertype = ieee80211_get_proto(hdr);
 	if (ethertype == ETH_P_PAE)
 		return 1;
 
@@ -281,7 +269,7 @@
 		return 0;
 
 	hdr = (struct ieee80211_hdr *) skb->data;
-	hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
+	hdrlen = ieee80211_get_hdrlen(hdr);
 
 #ifdef CONFIG_IEEE80211_CRYPT_TKIP
 	if (ieee->tkip_countermeasures &&
@@ -326,7 +314,7 @@
 		return 0;
 
 	hdr = (struct ieee80211_hdr *) skb->data;
-	hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
+	hdrlen = ieee80211_get_hdrlen(hdr);
 
 	atomic_inc(&crypt->refcnt);
 	res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
@@ -342,6 +330,44 @@
 }
 
 
+unsigned short ieee80211_type_trans(struct sk_buff *skb,
+		struct ieee80211_device *ieee)
+{
+	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+	struct ieee80211_snap_hdr *snap;
+	int hdrlen;
+	u8 *daddr = IEEE80211_GET_DADDR(hdr);
+	unsigned short type;
+
+	skb->mac.raw = skb->data;
+
+	hdrlen = ieee80211_get_hdrlen(hdr);
+	snap = (struct ieee80211_snap_hdr *)(skb->data + hdrlen);
+	if (snap->dsap == 0xaa && snap->ssap == 0xaa &&
+			((IEEE80211_SNAP_IS_RFC1042(snap) &&
+			  snap->type != __constant_htons(ETH_P_AARP) &&
+			  snap->type != __constant_htons(ETH_P_IPX)) ||
+			 IEEE80211_SNAP_IS_BRIDGE_TUNNEL(snap))) {
+		type = snap->type;
+		skb_pull(skb, hdrlen + SNAP_SIZE);
+	}
+	else {
+		type = __constant_htons(ETH_P_802_2);
+		skb_pull(skb, hdrlen);
+	}
+
+	skb->input_dev = ieee->dev;
+	if (is_broadcast_ieee80211_addr(daddr))
+		skb->pkt_type = PACKET_BROADCAST;
+	else if (is_multicast_ieee80211_addr(daddr))
+		skb->pkt_type = PACKET_MULTICAST;
+	else if (memcmp(daddr, ieee->dev->dev_addr, IEEE80211_ALEN))
+		skb->pkt_type = PACKET_OTHERHOST;
+
+	return type;
+}
+
+
 /* All received frames are sent to this function. @skb contains the frame in
  * IEEE 802.11 format, i.e., in the format it was sent over air.
  * This function is called only as a tasklet (software IRQ). */
@@ -354,8 +380,6 @@
 	u16 fc, type, stype, sc;
 	struct net_device_stats *stats;
 	unsigned int frag;
-	u8 *payload;
-	u16 ethertype;
 #ifdef NOT_YET
 	struct net_device *wds = NULL;
 	struct sk_buff *skb2 = NULL;
@@ -364,8 +388,8 @@
 	int from_assoc_ap = 0;
 	void *sta = NULL;
 #endif
-	u8 dst[ETH_ALEN];
-	u8 src[ETH_ALEN];
+	u8 dst[IEEE80211_ALEN];
+	u8 src[IEEE80211_ALEN];
 	struct ieee80211_crypt_data *crypt = NULL;
 	int keyidx = 0;
 
@@ -383,7 +407,7 @@
 	stype = WLAN_FC_GET_STYPE(fc);
 	sc = le16_to_cpu(hdr->seq_ctl);
 	frag = WLAN_GET_SEQ_FRAG(sc);
-	hdrlen = ieee80211_get_hdrlen(fc);
+	hdrlen = __ieee80211_get_hdrlen(fc);
 
 #ifdef NOT_YET
 #if WIRELESS_EXT > 15
@@ -479,22 +503,23 @@
 
 	switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
 	case IEEE80211_FCTL_FROMDS:
-		memcpy(dst, hdr->addr1, ETH_ALEN);
-		memcpy(src, hdr->addr3, ETH_ALEN);
+		memcpy(dst, hdr->addr1, IEEE80211_ALEN);
+		memcpy(src, hdr->addr3, IEEE80211_ALEN);
 		break;
 	case IEEE80211_FCTL_TODS:
-		memcpy(dst, hdr->addr3, ETH_ALEN);
-		memcpy(src, hdr->addr2, ETH_ALEN);
+		memcpy(dst, hdr->addr3, IEEE80211_ALEN);
+		memcpy(src, hdr->addr2, IEEE80211_ALEN);
 		break;
 	case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
 		if (skb->len < IEEE80211_4ADDR_LEN)
 			goto rx_dropped;
-		memcpy(dst, hdr->addr3, ETH_ALEN);
-		memcpy(src, hdr->addr4, ETH_ALEN);
+		memcpy(dst, hdr->addr3, IEEE80211_ALEN);
+		memcpy(src, hdr->addr4, IEEE80211_ALEN);
+		/* FIXME: this is wrong */
 		break;
 	case 0:
-		memcpy(dst, hdr->addr1, ETH_ALEN);
-		memcpy(src, hdr->addr2, ETH_ALEN);
+		memcpy(dst, hdr->addr1, IEEE80211_ALEN);
+		memcpy(src, hdr->addr2, IEEE80211_ALEN);
 		break;
 	}
 
@@ -509,7 +534,7 @@
 	if (ieee->iw_mode == IW_MODE_MASTER && !wds &&
 	    (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS &&
 	    ieee->stadev &&
-	    memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) {
+	    memcmp(hdr->addr2, ieee->assoc_ap_addr, IEEE80211_ALEN) == 0) {
 		/* Frame from BSSID of the AP for which we are a client */
 		skb->dev = dev = ieee->stadev;
 		stats = hostap_get_stats(dev);
@@ -667,9 +692,6 @@
 
 	/* skb: hdr + (possible reassembled) full plaintext payload */
 
-	payload = skb->data + hdrlen;
-	ethertype = (payload[6] << 8) | payload[7];
-
 #ifdef NOT_YET
 	/* If IEEE 802.1X is used, check whether the port is authorized to send
 	 * the received frame. */
@@ -696,38 +718,6 @@
 	}
 #endif
 
-	/* convert hdr + possible LLC headers into Ethernet header */
-	if (skb->len - hdrlen >= 8 &&
-	    ((memcmp(payload, rfc1042_header, SNAP_SIZE) == 0 &&
-	      ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
-	     memcmp(payload, bridge_tunnel_header, SNAP_SIZE) == 0)) {
-		/* remove RFC1042 or Bridge-Tunnel encapsulation and
-		 * replace EtherType */
-		skb_pull(skb, hdrlen + SNAP_SIZE);
-		memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
-		memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
-	} else {
-		u16 len;
-		/* Leave Ethernet header part of hdr and full payload */
-		skb_pull(skb, hdrlen);
-		len = htons(skb->len);
-		memcpy(skb_push(skb, 2), &len, 2);
-		memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
-		memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
-	}
-
-#ifdef NOT_YET
-	if (wds && ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
-		    IEEE80211_FCTL_TODS) &&
-	    skb->len >= ETH_HLEN + ETH_ALEN) {
-		/* Non-standard frame: get addr4 from its bogus location after
-		 * the payload */
-		memcpy(skb->data + ETH_ALEN,
-		       skb->data + skb->len - ETH_ALEN, ETH_ALEN);
-		skb_trim(skb, skb->len - ETH_ALEN);
-	}
-#endif
-
 	stats->rx_packets++;
 	stats->rx_bytes += skb->len;
 
@@ -753,7 +743,7 @@
 
 	if (skb2 != NULL) {
 		/* send to wireless media */
-		skb2->protocol = __constant_htons(ETH_P_802_3);
+		skb2->protocol = ieee80211_type_trans(skb2, ieee);
 		skb2->mac.raw = skb2->nh.raw = skb2->data;
 		/* skb2->nh.raw = skb2->data + ETH_HLEN; */
 		skb2->dev = dev;
@@ -763,7 +753,7 @@
 #endif
 
 	if (skb) {
-		skb->protocol = eth_type_trans(skb, dev);
+		skb->protocol = ieee80211_type_trans(skb, ieee);
 		memset(skb->cb, 0, sizeof(skb->cb));
 		skb->dev = dev;
 		skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
@@ -820,7 +810,7 @@
 	u8 i;
 
 	/* Pull out fixed field data */
-	memcpy(network->bssid, beacon->header.addr3, ETH_ALEN);
+	memcpy(network->bssid, beacon->header.addr3, IEEE80211_ALEN);
 	network->capability = beacon->capability;
 	network->last_scanned = jiffies;
 	network->time_stamp[0] = beacon->time_stamp[0];
@@ -848,7 +838,7 @@
 	while (left >= sizeof(struct ieee80211_info_element_hdr)) {
 		if (sizeof(struct ieee80211_info_element_hdr) + info_element->len > left) {
 			IEEE80211_DEBUG_SCAN("SCAN: parse failed: info_element->len + 2 > left : info_element->len+2=%d left=%d.\n",
-					     info_element->len + sizeof(struct ieee80211_info_element),
+					     info_element->len + (int)sizeof(struct ieee80211_info_element),
 					     left);
 			return 1;
                	}
@@ -1016,7 +1006,7 @@
 	 * as one network */
 	return ((src->ssid_len == dst->ssid_len) &&
 		(src->channel == dst->channel) &&
-		!memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
+		!memcmp(src->bssid, dst->bssid, IEEE80211_ALEN) &&
 		!memcmp(src->ssid, dst->ssid, src->ssid_len));
 }
 
Index: netdev/net/ieee80211/ieee80211_module.c
===================================================================
--- netdev.orig/net/ieee80211/ieee80211_module.c	2005-06-03 13:20:46.000000000 +0200
+++ netdev/net/ieee80211/ieee80211_module.c	2005-06-03 13:21:00.000000000 +0200
@@ -47,7 +47,6 @@
 #include <linux/types.h>
 #include <linux/version.h>
 #include <linux/wireless.h>
-#include <linux/etherdevice.h>
 #include <asm/uaccess.h>
 #include <net/arp.h>
 
@@ -102,24 +101,22 @@
 {
 	struct ieee80211_device *ieee;
 	struct net_device *dev;
-	int alloc_size;
+ 	int alloc_size;
 	int err;
 
 	IEEE80211_DEBUG_INFO("Initializing...\n");
 
-	alloc_size = ((sizeof(struct ieee80211_device) + NETDEV_ALIGN_CONST) 
-			& ~NETDEV_ALIGN_CONST) 
-			+ sizeof_priv;
-	dev = alloc_etherdev(alloc_size);
+ 	alloc_size = ((sizeof(struct ieee80211_device) + NETDEV_ALIGN_CONST) 
+ 			& ~NETDEV_ALIGN_CONST) 
+ 			+ sizeof_priv;
+	dev = alloc_netdev(alloc_size, "wlan%d", ieee80211_setup);
 	if (!dev) {
-		IEEE80211_ERROR("Unable to network device.\n");
+		IEEE80211_ERROR("Unable to allocate network device.\n");
 		goto failed;
 	}
 	ieee = netdev_priv(dev);
 	ieee->dev = dev;
 	ieee->priv = ieee80211_priv(ieee);
-	
-	dev->hard_start_xmit = ieee80211_xmit;
 
 	err = ieee80211_networks_allocate(ieee);
 	if (err) {
Index: netdev/net/ieee80211/ieee80211_tx.c
===================================================================
--- netdev.orig/net/ieee80211/ieee80211_tx.c	2005-06-03 13:20:46.000000000 +0200
+++ netdev/net/ieee80211/ieee80211_tx.c	2005-06-03 13:21:00.000000000 +0200
@@ -83,16 +83,6 @@
 Total: 8 non-data bytes
 
 
-802.3 Ethernet Data Frame
-
-      ,-----------------------------------------.
-Bytes |   6   |   6   |  2   |  Variable |   4  |
-      |-------|-------|------|-----------|------|
-Desc. | Dest. | Source| Type | IP Packet |  fcs |
-      |  MAC  |  MAC  |      |           |      |
-      `-----------------------------------------'
-Total: 18 non-data bytes
-
 In the event that fragmentation is required, the incoming payload is split into
 N parts of size ieee->fts.  The first fragment contains the SNAP header and the
 remaining packets are just data.
@@ -103,56 +93,8 @@
 encryption it will take 3 frames.  With WEP it will take 4 frames as the
 payload of each frame is reduced to 492 bytes.
 
-* SKB visualization
-*
-*  ,- skb->data
-* |
-* |    ETHERNET HEADER        ,-<-- PAYLOAD
-* |                           |     14 bytes from skb->data
-* |  2 bytes for Type --> ,T. |     (sizeof ethhdr)
-* |                       | | |
-* |,-Dest.--. ,--Src.---. | | |
-* |  6 bytes| | 6 bytes | | | |
-* v         | |         | | | |
-* 0         | v       1 | v | v           2
-* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
-*     ^     | ^         | ^ |
-*     |     | |         | | |
-*     |     | |         | `T' <---- 2 bytes for Type
-*     |     | |         |
-*     |     | '---SNAP--' <-------- 6 bytes for SNAP
-*     |     |
-*     `-IV--' <-------------------- 4 bytes for IV (WEP)
-*
-*      SNAP HEADER
-*
 */
 
-static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
-static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
-
-static inline int ieee80211_put_snap(u8 *data, u16 h_proto)
-{
-	struct ieee80211_snap_hdr *snap;
-	u8 *oui;
-
-	snap = (struct ieee80211_snap_hdr *)data;
-	snap->dsap = 0xaa;
-	snap->ssap = 0xaa;
-	snap->ctrl = 0x03;
-
-	if (h_proto == 0x8137 || h_proto == 0x80f3)
-		oui = P802_1H_OUI;
-	else
-		oui = RFC1042_OUI;
-	snap->oui[0] = oui[0];
-	snap->oui[1] = oui[1];
-	snap->oui[2] = oui[2];
-
-	*(u16 *)(data + SNAP_SIZE) = htons(h_proto);
-
-	return SNAP_SIZE + sizeof(u16);
-}
 
 static inline int ieee80211_encrypt_fragment(
 	struct ieee80211_device *ieee,
@@ -247,19 +189,16 @@
 		   struct net_device *dev)
 {
 	struct ieee80211_device *ieee = netdev_priv(dev);
+	struct ieee80211_hdr *header = (struct ieee80211_hdr *)skb->data;
 	struct ieee80211_txb *txb = NULL;
 	struct ieee80211_hdr *frag_hdr;
 	int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size;
 	unsigned long flags;
 	struct net_device_stats *stats = &ieee->stats;
-	int ether_type, encrypt;
+	int type, encrypt;
 	int bytes, fc, hdr_len;
 	struct sk_buff *skb_frag;
-	struct ieee80211_hdr header = { /* Ensure zero initialized */
-		.duration_id = 0,
-		.seq_ctl = 0
-	};
-	u8 dest[ETH_ALEN], src[ETH_ALEN];
+	u8 *dest;
 
 	struct ieee80211_crypt_data* crypt;
 
@@ -268,76 +207,48 @@
 	/* If there is no driver handler to take the TXB, dont' bother
 	 * creating it... */
 	if (!ieee->hard_start_xmit) {
-		printk(KERN_WARNING "%s: No xmit handler.\n",
-		       dev->name);
+		if (printk_ratelimit())
+			printk(KERN_WARNING "%s: No xmit handler.\n",
+				dev->name);
 		goto success;
 	}
 
-	if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) {
-		printk(KERN_WARNING "%s: skb too small (%d).\n",
-		       dev->name, skb->len);
-		goto success;
-	}
-
-	ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto);
+	type = ieee80211_get_proto(header);
+	dest = IEEE80211_GET_DADDR(header);
+	hdr_len = ieee80211_get_hdrlen(header);
 
 	crypt = ieee->crypt[ieee->tx_keyidx];
 
-	encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) &&
+	encrypt = !(type == ETH_P_PAE && ieee->ieee802_1x) &&
 		ieee->host_encrypt && crypt && crypt->ops;
 
 	if (!encrypt && ieee->ieee802_1x &&
-	    ieee->drop_unencrypted && ether_type != ETH_P_PAE) {
+	    ieee->drop_unencrypted && type != ETH_P_PAE) {
 		stats->tx_dropped++;
 		goto success;
 	}
 
 #ifdef CONFIG_IEEE80211_DEBUG
-	if (crypt && !encrypt && ether_type == ETH_P_PAE) {
-		struct eapol *eap = (struct eapol *)(skb->data +
-			sizeof(struct ethhdr) - SNAP_SIZE - sizeof(u16));
+	if (crypt && !encrypt && type == ETH_P_PAE) {
+		struct eapol *eap = (struct eapol *)(skb->data + hdr_len);
 		IEEE80211_DEBUG_EAP("TX: IEEE 802.11 EAPOL frame: %s\n",
 			eap_get_type(eap->type));
 	}
 #endif
 
-	/* Save source and destination addresses */
-	memcpy(&dest, skb->data, ETH_ALEN);
-	memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN);
-
-	/* Advance the SKB to the start of the payload */
-	skb_pull(skb, sizeof(struct ethhdr));
-
 	/* Determine total amount of storage required for TXB packets */
-	bytes = skb->len + SNAP_SIZE + sizeof(u16);
+	bytes = skb->len - hdr_len;
 
+	fc = le16_to_cpu(header->frame_ctl);
 	if (encrypt)
-		fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA |
-			IEEE80211_FCTL_WEP;
-	else
-		fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
+		fc |= IEEE80211_FCTL_WEP;
 
-	if (ieee->iw_mode == IW_MODE_INFRA) {
-		fc |= IEEE80211_FCTL_TODS;
-		/* To DS: Addr1 = BSSID, Addr2 = SA,
-		   Addr3 = DA */
-		memcpy(&header.addr1, ieee->bssid, ETH_ALEN);
-		memcpy(&header.addr2, &src, ETH_ALEN);
-		memcpy(&header.addr3, &dest, ETH_ALEN);
-	} else if (ieee->iw_mode == IW_MODE_ADHOC) {
-		/* not From/To DS: Addr1 = DA, Addr2 = SA,
-		   Addr3 = BSSID */
-		memcpy(&header.addr1, dest, ETH_ALEN);
-		memcpy(&header.addr2, src, ETH_ALEN);
-		memcpy(&header.addr3, ieee->bssid, ETH_ALEN);
-	}
-	header.frame_ctl = cpu_to_le16(fc);
-	hdr_len = IEEE80211_3ADDR_LEN;
+	header->frame_ctl = cpu_to_le16(fc);
 
 	/* Determine fragmentation size based on destination (multicast
 	 * and broadcast are not fragmented) */
-	if (is_multicast_ether_addr(dest) ||
-	    is_broadcast_ether_addr(dest))
+	if (is_multicast_ieee80211_addr(dest) ||
+	    is_broadcast_ieee80211_addr(dest))
 		frag_size = MAX_FRAG_THRESHOLD;
 	else
 		frag_size = ieee->fts;
@@ -346,7 +257,7 @@
 	 * this stack is providing the full 802.11 header, one will
 	 * eventually be affixed to this fragment -- so we must account for
 	 * it when determining the amount of payload space. */
-	bytes_per_frag = frag_size - IEEE80211_3ADDR_LEN;
+	bytes_per_frag = frag_size - hdr_len;
 	if (ieee->config &
 	    (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
 		bytes_per_frag -= IEEE80211_FCS_LEN;
@@ -377,6 +288,8 @@
 	txb->encrypted = encrypt;
 	txb->payload_size = bytes;
 
+	skb_pull(skb, hdr_len);
+
 	for (i = 0; i < nr_frags; i++) {
 		skb_frag = txb->fragments[i];
 
@@ -384,7 +297,7 @@
 			skb_reserve(skb_frag, crypt->ops->extra_prefix_len);
 
 		frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len);
-		memcpy(frag_hdr, &header, hdr_len);
+		memcpy(frag_hdr, header, hdr_len);
 
 		/* If this is not the last fragment, then add the MOREFRAGS
 		 * bit to the frame control */
@@ -397,14 +310,6 @@
 			bytes = bytes_last_frag;
 		}
 
-	       	/* Put a SNAP header on the first fragment */
-		if (i == 0) {
-			ieee80211_put_snap(
-				skb_put(skb_frag, SNAP_SIZE + sizeof(u16)),
-				ether_type);
-			bytes -= SNAP_SIZE + sizeof(u16);
-		}
-
 		memcpy(skb_put(skb_frag, bytes), skb->data, bytes);
 
 		/* Advance the SKB... */
Index: netdev/net/ieee80211/ieee80211_wx.c
===================================================================
--- netdev.orig/net/ieee80211/ieee80211_wx.c	2005-06-03 13:20:46.000000000 +0200
+++ netdev/net/ieee80211/ieee80211_wx.c	2005-06-03 13:21:00.000000000 +0200
@@ -53,7 +53,7 @@
 	/* First entry *MUST* be the AP MAC address */
 	iwe.cmd = SIOCGIWAP;
 	iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
-	memcpy(iwe.u.ap_addr.sa_data, network->bssid, ETH_ALEN);
+	memcpy(iwe.u.ap_addr.sa_data, network->bssid, IEEE80211_ALEN);
 	start = iwe_stream_add_event(start, stop, &iwe, IW_EV_ADDR_LEN);
 
 	/* Remaining entries will be displayed in the order we provide them */
Index: netdev/net/ieee80211/ieee80211_crypt_ccmp.c
===================================================================
--- netdev.orig/net/ieee80211/ieee80211_crypt_ccmp.c	2005-06-01 11:05:14.000000000 +0200
+++ netdev/net/ieee80211/ieee80211_crypt_ccmp.c	2005-06-03 13:21:00.000000000 +0200
@@ -17,7 +17,6 @@
 #include <linux/random.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
-#include <linux/if_ether.h>
 #include <linux/if_arp.h>
 #include <asm/string.h>
 #include <linux/wireless.h>
@@ -156,7 +155,7 @@
 	 * Dlen */
 	b0[0] = 0x59;
 	b0[1] = qc;
-	memcpy(b0 + 2, hdr->addr2, ETH_ALEN);
+	memcpy(b0 + 2, hdr->addr2, IEEE80211_ALEN);
 	memcpy(b0 + 8, pn, CCMP_PN_LEN);
 	b0[14] = (dlen >> 8) & 0xff;
 	b0[15] = dlen & 0xff;
@@ -173,13 +172,13 @@
 	aad[1] = aad_len & 0xff;
 	aad[2] = pos[0] & 0x8f;
 	aad[3] = pos[1] & 0xc7;
-	memcpy(aad + 4, hdr->addr1, 3 * ETH_ALEN);
+	memcpy(aad + 4, hdr->addr1, 3 * IEEE80211_ALEN);
 	pos = (u8 *) &hdr->seq_ctl;
 	aad[22] = pos[0] & 0x0f;
 	aad[23] = 0; /* all bits masked */
 	memset(aad + 24, 0, 8);
 	if (a4_included)
-		memcpy(aad + 24, hdr->addr4, ETH_ALEN);
+		memcpy(aad + 24, hdr->addr4, IEEE80211_ALEN);
 	if (qc_included) {
 		aad[a4_included ? 30 : 24] = qc;
 		/* rest of QC masked */
Index: netdev/net/ieee80211/ieee80211_crypt_tkip.c
===================================================================
--- netdev.orig/net/ieee80211/ieee80211_crypt_tkip.c	2005-06-01 11:05:14.000000000 +0200
+++ netdev/net/ieee80211/ieee80211_crypt_tkip.c	2005-06-03 13:21:00.000000000 +0200
@@ -17,7 +17,6 @@
 #include <linux/random.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
-#include <linux/if_ether.h>
 #include <linux/if_arp.h>
 #include <asm/string.h>
 
@@ -461,20 +460,20 @@
 	switch (le16_to_cpu(hdr11->frame_ctl) &
 		(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
 	case IEEE80211_FCTL_TODS:
-		memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
-		memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+		memcpy(hdr, hdr11->addr3, IEEE80211_ALEN); /* DA */
+		memcpy(hdr + IEEE80211_ALEN, hdr11->addr2, IEEE80211_ALEN); /* SA */
 		break;
 	case IEEE80211_FCTL_FROMDS:
-		memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
-		memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */
+		memcpy(hdr, hdr11->addr1, IEEE80211_ALEN); /* DA */
+		memcpy(hdr + IEEE80211_ALEN, hdr11->addr3, IEEE80211_ALEN); /* SA */
 		break;
 	case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
-		memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
-		memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */
+		memcpy(hdr, hdr11->addr3, IEEE80211_ALEN); /* DA */
+		memcpy(hdr + IEEE80211_ALEN, hdr11->addr4, IEEE80211_ALEN); /* SA */
 		break;
 	case 0:
-		memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
-		memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+		memcpy(hdr, hdr11->addr1, IEEE80211_ALEN); /* DA */
+		memcpy(hdr + IEEE80211_ALEN, hdr11->addr2, IEEE80211_ALEN); /* SA */
 		break;
 	}
 
@@ -521,7 +520,7 @@
 	else
 		ev.flags |= IW_MICFAILURE_PAIRWISE;
 	ev.src_addr.sa_family = ARPHRD_ETHER;
-	memcpy(ev.src_addr.sa_data, hdr->addr2, ETH_ALEN);
+	memcpy(ev.src_addr.sa_data, hdr->addr2, IEEE80211_ALEN);
 	memset(&wrqu, 0, sizeof(wrqu));
 	wrqu.data.length = sizeof(ev);
 	wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);
Index: netdev/net/ieee80211/Makefile
===================================================================
--- netdev.orig/net/ieee80211/Makefile	2005-06-01 11:05:14.000000000 +0200
+++ netdev/net/ieee80211/Makefile	2005-06-03 13:21:00.000000000 +0200
@@ -5,6 +5,7 @@
 obj-$(CONFIG_IEEE80211_CRYPT_TKIP) += ieee80211_crypt_tkip.o
 ieee80211-objs := \
 	ieee80211_module.o \
+	ieee80211_proto.o \
 	ieee80211_tx.o \
 	ieee80211_rx.o \
 	ieee80211_wx.o
Index: netdev/net/ieee80211/ieee80211_proto.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ netdev/net/ieee80211/ieee80211_proto.c	2005-06-03 13:21:00.000000000 +0200
@@ -0,0 +1,239 @@
+/*******************************************************************************
+
+  Copyright (c) 2005 Jiri Benc <jbenc@suse.cz> and Jirka Bohac <jbohac@suse.cz>
+  Copyright (c) 2004 Intel Corporation. All rights reserved.
+	(Contact: James P. Ketrenos <ipw2100-admin@linux.intel.com>)
+
+  Sponsored by SuSE.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms of version 2 of the GNU General Public License as
+  published by the Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc., 59
+  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*******************************************************************************/
+
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <linux/errno.h>
+#include <linux/if_arp.h>
+#include <linux/skbuff.h>
+#include <linux/socket.h>
+#include <linux/ip.h>
+#include <net/arp.h>
+
+#include <net/ieee80211.h>
+
+static int ieee80211_change_mtu(struct net_device *dev, int new_mtu)
+{
+	if ((new_mtu < 68) || (new_mtu > IEEE80211_DATA_LEN - 8 - SNAP_SIZE))
+		return -EINVAL;
+	dev->mtu = new_mtu;
+	return 0;
+}
+
+
+static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
+static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
+
+static inline int __ieee80211_put_snap(u8 *data, u16 h_proto)
+{
+	struct ieee80211_snap_hdr *snap;
+	u8 *oui;
+
+	snap = (struct ieee80211_snap_hdr *)data;
+	snap->dsap = 0xaa;
+	snap->ssap = 0xaa;
+	snap->ctrl = 0x03;
+
+	if (h_proto == __constant_htons(ETH_P_IPX) ||
+			h_proto == __constant_htons(ETH_P_AARP))
+		oui = P802_1H_OUI;
+	else
+		oui = RFC1042_OUI;
+	snap->oui[0] = oui[0];
+	snap->oui[1] = oui[1];
+	snap->oui[2] = oui[2];
+
+	snap->type = h_proto;
+
+	return SNAP_SIZE;
+}
+
+static inline int ieee80211_put_snap(u8 *data, u16 h_proto)
+{
+	return __ieee80211_put_snap(data, htons(h_proto));
+}
+
+/*
+ *       Create the IEEE 802.11 MAC header for an arbitrary protocol layer
+ *
+ *      saddr=NULL      means use device source address
+ *      daddr=NULL      means leave destination address (eg unresolved arp)
+ */
+static int ieee80211_header(struct sk_buff *skb, struct net_device *dev,
+		unsigned short type, void *daddr, void *saddr, unsigned len)
+{
+	struct ieee80211_device *ieee = netdev_priv(dev);
+	struct ieee80211_hdr *header;
+	int fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
+	int hdr_len = IEEE80211_3ADDR_LEN;
+	
+	if (type != ETH_P_802_3 && type != ETH_P_802_2) {
+		ieee80211_put_snap(skb_push(skb, SNAP_SIZE), type);
+		hdr_len += SNAP_SIZE;
+	}
+
+	if (!saddr) saddr = dev->dev_addr;
+	header = (struct ieee80211_hdr *)skb_push(skb, IEEE80211_3ADDR_LEN);
+	header->duration_id = header->seq_ctl = 0;
+	if (ieee->iw_mode == IW_MODE_INFRA) {
+		fc |= IEEE80211_FCTL_TODS;
+		/* To DS: Addr1 = BSSID, Addr2 = SA,
+		   Addr3 = DA */
+		memcpy(header->addr1, ieee->bssid, IEEE80211_ALEN);
+		memcpy(header->addr2, saddr, IEEE80211_ALEN);
+		if (daddr)
+			memcpy(header->addr3, daddr, IEEE80211_ALEN);
+		else
+			memset(header->addr3, 0, IEEE80211_ALEN);
+	} else if (ieee->iw_mode == IW_MODE_ADHOC) {
+		/* not From/To DS: Addr1 = DA, Addr2 = SA,
+		   Addr3 = BSSID */
+		if (daddr)
+			memcpy(header->addr1, daddr, IEEE80211_ALEN);
+		else
+			memset(header->addr1, 0, IEEE80211_ALEN);
+		memcpy(header->addr2, saddr, IEEE80211_ALEN);
+		memcpy(header->addr3, ieee->bssid, IEEE80211_ALEN);
+	}
+	header->frame_ctl = cpu_to_le16(fc);
+
+	if (!daddr || (dev->flags & (IFF_LOOPBACK | IFF_NOARP)))
+		return -hdr_len;
+	return hdr_len;
+}
+
+static int ieee80211_rebuild_header(struct sk_buff *skb)
+{
+	struct ieee80211_hdr *header = (struct ieee80211_hdr *)skb->data;
+	struct net_device *dev = skb->dev;
+	unsigned short type;
+
+	type = ieee80211_get_proto(header);
+
+	switch (type) {
+#ifdef CONFIG_INET
+	case ETH_P_IP:
+		return arp_find(IEEE80211_GET_DADDR(header), skb);
+#endif
+	default:
+		printk(KERN_DEBUG
+			"%s: unable to resolve type %X addresses.\n",
+			dev->name, type);
+		break;
+	}
+	
+	return 0;
+}
+
+static int ieee80211_mac_addr(struct net_device *dev, void *p)
+{
+	struct sockaddr *addr = p;
+
+	if (netif_running(dev))
+		return -EBUSY;
+	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+	return 0;
+}
+
+static int ieee80211_header_cache(struct neighbour *neigh, struct hh_cache *hh)
+{
+	struct net_device *dev = neigh->dev;
+	struct ieee80211_device *ieee = netdev_priv(dev);
+	unsigned short type = hh->hh_type;
+	struct ieee80211_hdr *header;
+	int fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
+
+	if (type == __constant_htons(ETH_P_802_3) ||
+			type == __constant_htons(ETH_P_802_2))
+		return -1;
+
+	header = (struct ieee80211_hdr *)
+		(((u8 *)hh->hh_data) +
+			(HH_DATA_OFF(IEEE80211_3ADDR_LEN + SNAP_SIZE)));
+	__ieee80211_put_snap((u8 *)header + IEEE80211_3ADDR_LEN, type);
+	
+	header->duration_id = header->seq_ctl = 0;
+	if (ieee->iw_mode == IW_MODE_INFRA) {
+		fc |= IEEE80211_FCTL_TODS;
+		/* To DS: Addr1 = BSSID, Addr2 = SA,
+		   Addr3 = DA */
+		memcpy(header->addr1, ieee->bssid, IEEE80211_ALEN);
+		memcpy(header->addr2, dev->dev_addr, IEEE80211_ALEN);
+		memcpy(header->addr3, neigh->ha, IEEE80211_ALEN);
+	} else if (ieee->iw_mode == IW_MODE_ADHOC) {
+		/* not From/To DS: Addr1 = DA, Addr2 = SA,
+		   Addr3 = BSSID */
+		memcpy(header->addr1, neigh->ha, IEEE80211_ALEN);
+		memcpy(header->addr2, dev->dev_addr, IEEE80211_ALEN);
+		memcpy(header->addr3, ieee->bssid, IEEE80211_ALEN);
+	}
+	header->frame_ctl = cpu_to_le16(fc);
+
+	hh->hh_len = IEEE80211_3ADDR_LEN + SNAP_SIZE;
+	return 0;
+}
+
+static void ieee80211_header_cache_update(struct hh_cache *hh,
+		struct net_device *dev, unsigned char *haddr)
+{
+	struct ieee80211_hdr *header;
+
+	header = (struct ieee80211_hdr *)
+		(((u8 *)hh->hh_data) +
+			(HH_DATA_OFF(IEEE80211_3ADDR_LEN + SNAP_SIZE)));
+	memcpy(IEEE80211_GET_DADDR(header), haddr, dev->addr_len);
+}
+
+static int ieee80211_header_parse(struct sk_buff *skb, unsigned char *haddr)
+{
+	struct ieee80211_hdr *header = (struct ieee80211_hdr *)skb->data;
+
+	memcpy(haddr, IEEE80211_GET_SADDR(header), IEEE80211_ALEN);
+	return IEEE80211_ALEN;
+}
+
+
+void ieee80211_setup(struct net_device *dev)
+{
+	dev->change_mtu		 = ieee80211_change_mtu;
+	dev->hard_header	 = ieee80211_header;
+	dev->rebuild_header	 = ieee80211_rebuild_header;
+	dev->set_mac_address	 = ieee80211_mac_addr;
+	dev->hard_header_cache	 = ieee80211_header_cache;
+	dev->header_cache_update = ieee80211_header_cache_update;
+	dev->hard_header_parse	 = ieee80211_header_parse;
+
+	dev->hard_start_xmit     = ieee80211_xmit;
+
+	dev->type		 = ARPHRD_ETHER;
+	dev->hard_header_len	 = IEEE80211_3ADDR_LEN + SNAP_SIZE;
+	dev->mtu		 = IEEE80211_DATA_LEN - 8 - SNAP_SIZE;
+	dev->addr_len		 = IEEE80211_ALEN;
+	dev->tx_queue_len	 = 1000;
+	dev->flags		 = IFF_BROADCAST | IFF_MULTICAST;
+	
+	memset(dev->broadcast, 0xFF, IEEE80211_ALEN);
+}
+
+
+EXPORT_SYMBOL(ieee80211_setup);


-- 
Jiri Benc
SUSE Labs

^ permalink raw reply

* [7/9] ipw: fix after "ieee80211: ethernet independency"
From: Jiri Benc @ 2005-06-03 16:35 UTC (permalink / raw)
  To: NetDev; +Cc: Jeff Garzik, Jirka Bohac
In-Reply-To: <20050603182625.64d33be3@griffin.suse.cz>

Fixes ipw2200 after making the ieee80211 layer independent of ethernet.


Signed-off-by: Jiri Benc <jbenc@suse.cz>
Signed-off-by: Jirka Bohac <jbohac@suse.cz>

Index: netdev/drivers/net/wireless/ipw2200.c
===================================================================
--- netdev.orig/drivers/net/wireless/ipw2200.c	2005-05-31 18:25:53.000000000 +0200
+++ netdev/drivers/net/wireless/ipw2200.c	2005-05-31 18:32:18.000000000 +0200
@@ -4920,8 +4920,8 @@
 						ETH_ALEN) ||
 					!memcmp(header->addr3, 
 						priv->bssid, ETH_ALEN) ||
-					is_broadcast_ether_addr(header->addr1) ||
-					is_multicast_ether_addr(header->addr1);
+					is_broadcast_ieee80211_addr(header->addr1) ||
+					is_multicast_ieee80211_addr(header->addr1);
 				break;
 
 			case IW_MODE_INFRA:
@@ -4932,8 +4932,8 @@
 					!memcmp(header->addr1, 
 						priv->net_dev->dev_addr, 
 						ETH_ALEN) ||
-					is_broadcast_ether_addr(header->addr1) ||
-					is_multicast_ether_addr(header->addr1);
+					is_broadcast_ieee80211_addr(header->addr1) ||
+					is_multicast_ieee80211_addr(header->addr1);
 				break;
 			}
 			
@@ -6285,8 +6285,8 @@
 	switch (priv->ieee->iw_mode) {
 	case IW_MODE_ADHOC:
 		hdr_len = IEEE80211_3ADDR_LEN;
-		unicast = !is_broadcast_ether_addr(hdr->addr1) &&
-			!is_multicast_ether_addr(hdr->addr1);
+		unicast = !is_broadcast_ieee80211_addr(hdr->addr1) &&
+			!is_multicast_ieee80211_addr(hdr->addr1);
 		id = ipw_find_station(priv, hdr->addr1);
 		if (id == IPW_INVALID_STATION) {
 			id = ipw_add_station(priv, hdr->addr1);
@@ -6301,8 +6301,8 @@
 
 	case IW_MODE_INFRA:
 	default:
-		unicast = !is_broadcast_ether_addr(hdr->addr3) &&
-			!is_multicast_ether_addr(hdr->addr3);
+		unicast = !is_broadcast_ieee80211_addr(hdr->addr3) &&
+			!is_multicast_ieee80211_addr(hdr->addr3);
 		hdr_len = IEEE80211_3ADDR_LEN;
 		id = 0;
 		break;


-- 
Jiri Benc
SUSE Labs

^ permalink raw reply

* [8/9] ieee80211: add sequence numbers
From: Jiri Benc @ 2005-06-03 16:36 UTC (permalink / raw)
  To: NetDev; +Cc: Jeff Garzik, Jirka Bohac
In-Reply-To: <20050603182625.64d33be3@griffin.suse.cz>

Adds sequence numbers to IEEE 802.11 headers.


Signed-off-by: Jiri Benc <jbenc@suse.cz>
Signed-off-by: Jirka Bohac <jbohac@suse.cz>

Index: netdev/include/net/ieee80211.h
===================================================================
--- netdev.orig/include/net/ieee80211.h	2005-06-03 13:21:00.000000000 +0200
+++ netdev/include/net/ieee80211.h	2005-06-03 13:21:06.000000000 +0200
@@ -711,6 +711,8 @@
 	unsigned int frag_next_idx;
 	u16 fts; /* Fragmentation Threshold */
 
+	u16 seq_number;	/* sequence number in transmitted frames */
+
 	/* Association info */
 	u8 bssid[IEEE80211_ALEN];
 
Index: netdev/net/ieee80211/ieee80211_module.c
===================================================================
--- netdev.orig/net/ieee80211/ieee80211_module.c	2005-06-03 13:21:00.000000000 +0200
+++ netdev/net/ieee80211/ieee80211_module.c	2005-06-03 13:21:06.000000000 +0200
@@ -128,6 +128,7 @@
 
 	/* Default fragmentation threshold is maximum payload size */
 	ieee->fts = DEFAULT_FTS;
+	ieee->seq_number = 0;
 	ieee->scan_age = DEFAULT_MAX_SCAN_AGE;
 	ieee->open_wep = 1;
 
Index: netdev/net/ieee80211/ieee80211_tx.c
===================================================================
--- netdev.orig/net/ieee80211/ieee80211_tx.c	2005-06-03 13:21:00.000000000 +0200
+++ netdev/net/ieee80211/ieee80211_tx.c	2005-06-03 13:21:06.000000000 +0200
@@ -276,6 +276,13 @@
 	else
 		bytes_last_frag = bytes_per_frag;
 
+	if (nr_frags > 16) {
+		/* Should never happen */
+		printk(KERN_WARNING "%s: Fragmentation threshold too low\n",
+			dev->name);
+		goto failed;
+	}
+
 	/* When we allocate the TXB we allocate enough space for the reserve
 	 * and full fragment bytes (bytes_per_frag doesn't include prefix,
 	 * postfix, header, FCS, etc.) */
@@ -299,6 +306,8 @@
 		frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len);
 		memcpy(frag_hdr, header, hdr_len);
 
+		frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_number | i);
+
 		/* If this is not the last fragment, then add the MOREFRAGS
 		 * bit to the frame control */
 		if (i != nr_frags - 1) {
@@ -323,7 +332,7 @@
 		    (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
 			skb_put(skb_frag, 4);
 	}
-
+	ieee->seq_number += 0x10;
 
  success:
 	spin_unlock_irqrestore(&ieee->lock, flags);


-- 
Jiri Benc
SUSE Labs

^ permalink raw reply

* [9/9] ieee80211: ETH_P_802_11 ethertype
From: Jiri Benc @ 2005-06-03 16:37 UTC (permalink / raw)
  To: NetDev; +Cc: Jeff Garzik, Jirka Bohac
In-Reply-To: <20050603182625.64d33be3@griffin.suse.cz>

Introduced new ETH_P_802_11 ethertype. Fixed ieee80211_type_trans() to
return ETH_P_802_11 in case of non-data frame.


Signed-off-by: Jiri Benc <jbenc@suse.cz>
Signed-off-by: Jirka Bohac <jbohac@suse.cz>

Index: netdev/include/linux/if_ether.h
===================================================================
--- netdev.orig/include/linux/if_ether.h	2005-06-01 11:04:59.000000000 +0200
+++ netdev/include/linux/if_ether.h	2005-06-03 13:21:15.000000000 +0200
@@ -92,6 +92,7 @@
 #define ETH_P_ECONET	0x0018		/* Acorn Econet			*/
 #define ETH_P_HDLC	0x0019		/* HDLC frames			*/
 #define ETH_P_ARCNET	0x001A		/* 1A for ArcNet :-)            */
+#define ETH_P_802_11	0x001B		/* 802.11 frames		*/
 
 /*
  *	This is an Ethernet frame header.
Index: netdev/include/net/ieee80211.h
===================================================================
--- netdev.orig/include/net/ieee80211.h	2005-06-03 13:21:10.000000000 +0200
+++ netdev/include/net/ieee80211.h	2005-06-03 13:21:15.000000000 +0200
@@ -232,10 +232,6 @@
 
 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
 
-#ifndef ETH_P_80211_RAW
-#define ETH_P_80211_RAW 0x0003
-#endif
-
 /* IEEE 802.11 defines */
 
 #define P80211_OUI_LEN 3
Index: netdev/net/ieee80211/ieee80211_rx.c
===================================================================
--- netdev.orig/net/ieee80211/ieee80211_rx.c	2005-06-03 13:21:00.000000000 +0200
+++ netdev/net/ieee80211/ieee80211_rx.c	2005-06-03 13:21:15.000000000 +0200
@@ -46,7 +46,7 @@
 	skb->mac.raw = skb->data;
 	skb_pull(skb, ieee80211_get_hdrlen(hdr));
 	skb->pkt_type = PACKET_OTHERHOST;
-	skb->protocol = __constant_htons(ETH_P_80211_RAW);
+	skb->protocol = __constant_htons(ETH_P_802_11);
 	memset(skb->cb, 0, sizeof(skb->cb));
 	netif_rx(skb);
 }
@@ -338,22 +338,33 @@
 	int hdrlen;
 	u8 *daddr = IEEE80211_GET_DADDR(hdr);
 	unsigned short type;
+	u16 fc;
 
 	skb->mac.raw = skb->data;
 
-	hdrlen = ieee80211_get_hdrlen(hdr);
-	snap = (struct ieee80211_snap_hdr *)(skb->data + hdrlen);
-	if (snap->dsap == 0xaa && snap->ssap == 0xaa &&
-			((IEEE80211_SNAP_IS_RFC1042(snap) &&
-			  snap->type != __constant_htons(ETH_P_AARP) &&
-			  snap->type != __constant_htons(ETH_P_IPX)) ||
-			 IEEE80211_SNAP_IS_BRIDGE_TUNNEL(snap))) {
-		type = snap->type;
-		skb_pull(skb, hdrlen + SNAP_SIZE);
+	fc = le16_to_cpu(hdr->frame_ctl);
+	if (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA &&
+			WLAN_FC_GET_STYPE(fc) == IEEE80211_STYPE_DATA) {
+		hdrlen = __ieee80211_get_hdrlen(fc);
+		snap = (struct ieee80211_snap_hdr *)(skb->data + hdrlen);
+		if (snap->dsap == 0xaa && snap->ssap == 0xaa &&
+				((IEEE80211_SNAP_IS_RFC1042(snap) &&
+				snap->type != __constant_htons(ETH_P_AARP) &&
+				snap->type != __constant_htons(ETH_P_IPX)) ||
+				IEEE80211_SNAP_IS_BRIDGE_TUNNEL(snap))) {
+			type = snap->type;
+			skb_pull(skb, hdrlen + SNAP_SIZE);
+		}
+		else {
+			type = __constant_htons(ETH_P_802_2);
+			skb_pull(skb, hdrlen);
+		}
 	}
 	else {
-		type = __constant_htons(ETH_P_802_2);
-		skb_pull(skb, hdrlen);
+		/* If the type isn't data we want to keep the 802.11 header
+		 * in place.
+		 */
+		type = __constant_htons(ETH_P_802_11);
 	}
 
 	skb->input_dev = ieee->dev;
Index: netdev/net/ieee80211/ieee80211_proto.c
===================================================================
--- netdev.orig/net/ieee80211/ieee80211_proto.c	2005-06-03 13:21:00.000000000 +0200
+++ netdev/net/ieee80211/ieee80211_proto.c	2005-06-03 13:21:15.000000000 +0200
@@ -87,6 +87,8 @@
 	int fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
 	int hdr_len = IEEE80211_3ADDR_LEN;
 	
+	if (type == ETH_P_802_11)
+		return 0;
 	if (type != ETH_P_802_3 && type != ETH_P_802_2) {
 		ieee80211_put_snap(skb_push(skb, SNAP_SIZE), type);
 		hdr_len += SNAP_SIZE;


-- 
Jiri Benc
SUSE Labs

^ permalink raw reply

* RE: RFC: NAPI packet weighting patch
From: Ronciak, John @ 2005-06-03 17:40 UTC (permalink / raw)
  To: David S. Miller
  Cc: jdmason, shemminger, hadi, Williams, Mitch A, netdev,
	Robert.Olsson, Venkatesan, Ganesh, Brandeburg, Jesse

> What more do you need other than checking the statistics counter?  The
> drop statistics (the ones we care about) are incremented in real time
> by the ->poll() code, so it's not like we have to trigger some
> asynchronous event to get a current version of the number.
> 

I think that there is some more confusion here.  I'm talking about
frames dropped by the Ethernet controller at the hardware level (no
descriptor available).  This for example is happening now with our
driver with the weight set to 64.  This is also what started us looking
into what was going on with the weight.  I don't see how the NAPI code
to dynamically adjust the weight could easily get the hardware stats
number to know if frames are being dropped or not.  Sorry if I caused
the confusion here.

Mitch is working on a response to Jamal's last mail trying to level set
what we are seeing and doing.

Cheers,
John

^ permalink raw reply

* Re: RFC: NAPI packet weighting patch
From: Mitch Williams @ 2005-06-03 17:43 UTC (permalink / raw)
  To: jamal
  Cc: David S. Miller, Ronciak, John, jdmason, shemminger, netdev,
	Robert.Olsson, Venkatesan, Ganesh, Brandeburg, Jesse
In-Reply-To: <1117765954.6095.49.camel@localhost.localdomain>



On Thu, 2 Jun 2005, jamal wrote:
>
> Heres what i think i saw as a flow of events:
> Someone posted a theory that if you happen to reduce the weight
> (iirc the reduction was via a shift) then the DRR would give less CPU
> time cycle to the driver - Whats the big suprise there? thats DRR design
> intent.

Well, that was me.  Or at least I was the original poster on this thread.
But my theory (if you can call it that) really wasn't about CPU time.  I
spent several weeks in our lab with the somewhat nebulous task of "look at
Linux performance".  And what I found was, to me, counterintuitive:
reducing weight improved performance, sometimes significantly.

>
> Stephen has a patch which allows people to reduce the weight.
> DRR  provides fairness. If you have 10 NICs coming at different wire
> rates, the weights provide a fairness quota without caring about what
> those speeds are. So it doesnt make any sense IMO to have the weight
> based on what the NIC speed is. Infact i claim it is _nonsense_. You
> dont need to factor speed. And the claim that DRR is not real world
> is blasphemous.

OK, well, call me a blasphemer (against whom?).  I'm not really saying
that the DRR algorithm is not real-world, but rather that NAPI as
currently implemented has some significant performance limitations.

In my mind, there are two major problems with NAPI as it stands today.
First, at Gigabit and higher speeds, the default settings don't allow the
driver to process received packets in a timely manner.  This causes
dropped packets due to lack of receive resources.  Lowering the weight can
fix this, at least in a single-adapter environment.

Second, at 10Mbps and 100Mbps, modern processors are just too fast for the
network.  The NAPI polling loop runs so much quicker than the wire speed
that only one or two packets are processed per softirq -- which
effectively puts the adapter back in interrupt mode.  Because of this, you
can easily bog down a very fast box with relatively slow traffic, just due
to the massive number of interrupts generated.

My original post (and patch) were to address the first issue.  By using
the shift value on the quota, I effectively lowered the weight for every
driver in the system.   Stephen sent out a patch that allowed you to
adjust each driver's weight individually.  My testing has shown that, as
expected, you can achieve the same performance gain either way.

In a multiple-adapter environment, you need to adjust the weight of all
drivers together to fix the dropped packets issue.  Lowering the weight on
one adapter won't help it if the other interfaces are still taking up a
lot of time in their receive loops.

My patch gave you one knob to twiddle that would correct this issue.
Stephen's patch gave you one knob for each adapter, but now you need to
twiddle them all to see any benefit.

The second issue currently has no fix.  What is needed is a way for the
driver to request a delayed poll, possibly based on line speed.  If we
could wait, say, 8 packet times before polling, we could significantly
reduce the number of interrupts the system has to deal with, at the cost
of higher latency.  We haven't had time to investigate this at all, but
the need is clearly present -- we've had customer calls about this issue.

>
> Having said that:
> I have a feeling that issue which is which is being waded around is the
> amount that the softirq chews in the CPU (unfortunately a well known
> issue) and to some extent the packet flow a specific driver chews
> depending on the path it takes.

I fiddled with this concept a little bit, but didn't see much performance
gain by doing so.  But it may be something that we can go back and look
at.

Either way, I think the netdev community needs to look critically at NAPI,
and make some changes.   Network performance in 2.6.12-rcWhatever is
pretty poor.  2.4.30 beats it handily, and it really shouldn't be that
way.


> This, however, does not eradicate the need for DRR and is absolutely not
> driver specific.

Agreed.  All of the changes I've experimented with at the NAPI level have
affected performance similarly on multiple drivers.

-Mitch

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox