2007-12-29 09:43:01

by Chris Clayton

[permalink] [raw]
Subject: Warning emited by 2.6.24-rc6-git5

Hi,

Please cc me on any reply - I'm not subscribed.

I've just built and installed 2.6.24-rc6-git5 and noticed the following
warning when I rebooted.

WARNING: at net/mac80211/rx.c:1486 __ieee80211_rx()
Pid: 0, comm: swapper Not tainted 2.6.24-rc6-git5 #11
[<dc916f6a>] __ieee80211_rx+0x4da/0x4f0 [mac80211]
[<c0115021>] enqueue_task_fair+0x21/0x30
[<c0114dfd>] enqueue_entity+0x3d/0x70
[<dc908072>] ieee80211_tasklet_handler+0xb2/0xe0 [mac80211]
[<c01171e2>] enqueue_task+0x12/0x30
[<c012c32c>] rcu_do_batch+0x1c/0x80
[<c0120778>] tasklet_action+0x38/0x60
[<c0120584>] __do_softirq+0x74/0x90
[<c0105ef6>] do_softirq+0x46/0xc0
[<c0141db0>] handle_level_irq+0x0/0x100
[<c0120635>] irq_exit+0x65/0x70
[<c0105daf>] do_IRQ+0x6f/0xc0
[<c011440a>] __update_rq_clock+0x1a/0xf0
[<c01042e3>] common_interrupt+0x23/0x28
[<c014007b>] do_acct_process+0x16b/0x2f0
[<c011007b>] acpi_copy_wakeup_routine+0x2b/0x9c
[<c0219d53>] acpi_processor_idle+0x25b/0x36e
[<c01020dc>] cpu_idle+0x5c/0x80
[<c041181b>] start_kernel+0x18b/0x1d0
[<c0411360>] unknown_bootoption+0x0/0x150


lspci shows my wireless card to be RaLink RT2561/RT61 802.11g PCI. It's a
Belkin F5D7010. The driver (rt61pci) is built as a module. Despite the
warning, networking sees to be working OK.

In case it helps, the complete output from dmesg follows (The odd-looking mac
address for my AP is my alteration)

Linux version 2.6.24-rc6-git5 (chris@linlap) (gcc version 3.3.6) #11 PREEMPT
Sat Dec 29 09:04:49 UTC 2007
BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 - 000000001bff0000 (usable)
BIOS-e820: 000000001bff0000 - 000000001bff3800 (reserved)
BIOS-e820: 000000001bff3800 - 000000001c000000 (ACPI NVS)
447MB LOWMEM available.
Entering add_active_range(0, 0, 114672) 0 entries of 256 used
Zone PFN ranges:
DMA 0 -> 4096
Normal 4096 -> 114672
Movable zone start PFN for each node
early_node_map[1] active PFN ranges
0: 0 -> 114672
On node 0 totalpages: 114672
DMA zone: 32 pages used for memmap
DMA zone: 0 pages reserved
DMA zone: 4064 pages, LIFO batch:0
Normal zone: 863 pages used for memmap
Normal zone: 109713 pages, LIFO batch:31
Movable zone: 0 pages used for memmap
DMI 2.3 present.
ACPI: RSDP 000F9970, 0014 (r0 COMPAQ)
ACPI: RSDT 1BFF4800, 0028 (r1 COMPAQ RSDB130 1 CPQ 1)
ACPI: FACP 1BFF4828, 0074 (r1 COMPAQ CPQB10F 20010122 CPQ 1)
ACPI: DSDT 1BFF48A0, 8812 (r1 COMPAQ ARMADAE7 10000 MSFT 100000C)
ACPI: FACS 1BFFFE80, 0040
ACPI: PM-Timer IO Port: 0x5008
Allocating PCI resources starting at 20000000 (gap: 1c000000:e4000000)
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 113777
Kernel command line: root=/dev/hda3 ro pci=routeirq noirda
Enabling fast FPU save and restore... done.
Enabling unmasked SIMD FPU exception support... done.
Initializing CPU#0
CPU 0 irqstacks, hard=c043e000 soft=c043d000
PID hash table entries: 2048 (order: 11, 8192 bytes)
Detected 846.322 MHz processor.
Console: colour VGA+ 80x25
console [tty0] enabled
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 450696k/458688k available (2260k kernel code, 7432k reserved, 872k
data, 164k init, 0k highmem)
virtual kernel memory layout:
fixmap : 0xffff6000 - 0xfffff000 ( 36 kB)
vmalloc : 0xdc800000 - 0xffff4000 ( 567 MB)
lowmem : 0xc0000000 - 0xdbff0000 ( 447 MB)
.init : 0xc0411000 - 0xc043a000 ( 164 kB)
.data : 0xc0335115 - 0xc040f1e0 ( 872 kB)
.text : 0xc0100000 - 0xc0335115 (2260 kB)
Checking if this processor honours the WP bit even in supervisor mode... Ok.
Calibrating delay using timer specific routine.. 1693.85 BogoMIPS
(lpj=3387703)
Mount-cache hash table entries: 512
CPU: After generic identify, caps: 0383f9ff 00000000 00000000 00000000
00000000 00000000 00000000 00000000
CPU: L1 I cache: 16K, L1 D cache: 16K
CPU: L2 cache: 256K
CPU: After all inits, caps: 0383f9ff 00000000 00000000 00000040 00000000
00000000 00000000 00000000
Intel machine check architecture supported.
Intel machine check reporting enabled on CPU#0.
Compat vDSO mapped to ffffe000.
CPU: Intel Pentium III (Coppermine) stepping 0a
Checking 'hlt' instruction... OK.
Freeing SMP alternatives: 0k freed
ACPI: Core revision 20070126
ACPI: setting ELCR to 0200 (from 0800)
net_namespace: 64 bytes
NET: Registered protocol family 16
ACPI: bus type pci registered
PCI: PCI BIOS revision 2.10 entry at 0xf0478, last bus=1
PCI: Using configuration type 1
Setting up standard PCI resources
ACPI: EC: Look up EC in DSDT
ACPI: Interpreter enabled
ACPI: (supports S0 S1 S3 S5)
ACPI: Using PIC for interrupt routing
ACPI: PCI Root Bridge [C005] (0000:00)
PCI quirk: region 5000-503f claimed by PIIX4 ACPI
PCI quirk: region 4000-400f claimed by PIIX4 SMB
PIIX4 devres C PIO at 0100-0107
PIIX4 devres I PIO at 00e0-00e3
PIIX4 devres J PIO at 00f8-00fb
ACPI: PCI Interrupt Routing Table [\_SB_.C005._PRT]
ACPI: PCI Interrupt Routing Table [\_SB_.C005.C012._PRT]
ACPI: PCI Interrupt Link [C17E] (IRQs *11)
ACPI: PCI Interrupt Link [C184] (IRQs 11) *0, disabled.
ACPI: PCI Interrupt Link [C185] (IRQs *11)
ACPI: PCI Interrupt Link [C186] (IRQs *11)
ACPI: Power Resource [C133] (on)
ACPI: Power Resource [C0E5] (on)
ACPI: Power Resource [C19B] (off)
ACPI: Power Resource [C19D] (off)
ACPI: Power Resource [C19F] (off)
Linux Plug and Play Support v0.97 (c) Adam Belay
pnp: PnP ACPI init
ACPI: bus type pnp registered
pnp: PnP ACPI: found 15 devices
ACPI: ACPI bus type pnp unregistered
SCSI subsystem initialized
PCI: Using ACPI for IRQ routing
PCI: Routing PCI interrupts for all devices because "pci=routeirq" specified
ACPI: PCI Interrupt Link [C17E] enabled at IRQ 11
PCI: setting IRQ 11 as level-triggered
ACPI: PCI Interrupt 0000:00:04.0[A] -> Link [C17E] -> GSI 11 (level, low) ->
IRQ 11
ACPI: PCI Interrupt 0000:00:04.1[A] -> Link [C17E] -> GSI 11 (level, low) ->
IRQ 11
ACPI: PCI Interrupt Link [C186] enabled at IRQ 11
ACPI: PCI Interrupt 0000:00:07.2[D] -> Link [C186] -> GSI 11 (level, low) ->
IRQ 11
ACPI: PCI Interrupt Link [C185] enabled at IRQ 11
ACPI: PCI Interrupt 0000:00:08.0[A] -> Link [C185] -> GSI 11 (level, low) ->
IRQ 11
ACPI: PCI Interrupt 0000:00:09.0[A] -> Link [C185] -> GSI 11 (level, low) ->
IRQ 11
ACPI: PCI Interrupt 0000:00:09.1[A] -> Link [C185] -> GSI 11 (level, low) ->
IRQ 11
ACPI: PCI Interrupt 0000:01:00.0[A] -> Link [C17E] -> GSI 11 (level, low) ->
IRQ 11
Time: tsc clocksource has been installed.
system 00:0c: ioport range 0x4d0-0x4d1 has been reserved
system 00:0c: ioport range 0x800-0x87f has been reserved
system 00:0c: ioport range 0x4000-0x400f has been reserved
system 00:0c: ioport range 0x5000-0x5063 could not be reserved
system 00:0c: ioport range 0x6004-0x6005 has been reserved
system 00:0c: ioport range 0xf000-0xf0cf has been reserved
system 00:0d: iomem range 0xd1800-0xd3fff has been reserved
system 00:0d: iomem range 0xfff80000-0xffffffff has been reserved
system 00:0e: iomem range 0x0-0x9ffff could not be reserved
system 00:0e: iomem range 0xf0000-0xfffff could not be reserved
system 00:0e: iomem range 0x100000-0x1bffffff could not be reserved
PCI: Bridge: 0000:00:01.0
IO window: 2000-2fff
MEM window: 40000000-410fffff
PREFETCH window: 30000000-300fffff
PCI: Bus 2, cardbus bridge: 0000:00:04.0
IO window: 00001000-000010ff
IO window: 00001400-000014ff
PREFETCH window: 20000000-23ffffff
MEM window: 24000000-27ffffff
PCI: Bus 6, cardbus bridge: 0000:00:04.1
IO window: 00001800-000018ff
IO window: 00001c00-00001cff
PREFETCH window: 28000000-2bffffff
MEM window: 2c000000-2fffffff
ACPI: PCI Interrupt 0000:00:04.0[A] -> Link [C17E] -> GSI 11 (level, low) ->
IRQ 11
ACPI: PCI Interrupt 0000:00:04.1[A] -> Link [C17E] -> GSI 11 (level, low) ->
IRQ 11
NET: Registered protocol family 2
IP route cache hash table entries: 4096 (order: 2, 16384 bytes)
TCP established hash table entries: 16384 (order: 5, 131072 bytes)
TCP bind hash table entries: 16384 (order: 4, 65536 bytes)
TCP: Hash tables configured (established 16384 bind 16384)
TCP reno registered
io scheduler noop registered
io scheduler cfq registered (default)
Limiting direct PCI/PCI transfers.
PCI: Firmware left 0000:00:09.0 e100 interrupts enabled, disabling
Boot video device is 0000:01:00.0
ACPI: AC Adapter [C105] (on-line)
ACPI: Battery Slot [C10D] (battery present)
ACPI: Battery Slot [C10E] (battery absent)
input: Power Button (FF) as /devices/virtual/input/input0
ACPI: Power Button (FF) [PWRF]
input: Sleep Button (CM) as /devices/virtual/input/input1
ACPI: Sleep Button (CM) [C057]
input: Lid Switch as /devices/virtual/input/input2
ACPI: Lid Switch [C1A5]
ACPI: Fan [C199] (off)
ACPI: Fan [C19C] (off)
ACPI: Fan [C19E] (off)
ACPI: CPU0 (power states: C1[C1] C2[C2])
ACPI: Processor [C0BE] (supports 8 throttling states)
ACPI: Thermal Zone [C19A] (49 C)
isapnp: Scanning for PnP cards...
isapnp: No Plug & Play device found
Switched to NOHz mode on CPU #0
Real Time Clock Driver v1.12ac
Linux agpgart interface v0.102
agpgart: Detected an Intel 440BX Chipset.
agpgart: AGP aperture is 64M @ 0x50000000
[drm] Initialized drm 1.1.0 20060810
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled
serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
serial8250: ttyS2 at I/O 0x3e8 (irq = 4) is a 16550A
00:01: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
ACPI: PCI Interrupt 0000:00:09.1[A] -> Link [C185] -> GSI 11 (level, low) ->
IRQ 11
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
PIIX4: IDE controller (0x8086:0x7111 rev 0x01) at PCI slot 0000:00:07.1
PIIX4: not 100% native mode: will probe irqs later
ide0: BM-DMA at 0x3460-0x3467, BIOS settings: hda:DMA, hdb:DMA
ide1: BM-DMA at 0x3468-0x346f, BIOS settings: hdc:pio, hdd:pio
Probing IDE interface ide0...
Marking TSC unstable due to: possible TSC halt in C2.
Time: acpi_pm clocksource has been installed.
hdb: Compaq DVD-ROM SD-C2402, ATAPI CD/DVD-ROM drive
Clocksource tsc unstable (delta = -3173924566 ns)
hda: HITACHI_DK23BA-20, ATA DISK drive
hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
hda: UDMA/33 mode selected
hdb: host max PIO4 wanted PIO255(auto-tune) selected PIO4
hdb: MWDMA2 mode selected
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
Probing IDE interface ide1...
Probing IDE interface ide1...
hda: max request size: 128KiB
hda: 39070080 sectors (20003 MB) w/2048KiB Cache, CHS=38760/16/63
hda: cache flushes not supported
hda: hda1 hda2 hda3 hda4
hdb: ATAPI 24X DVD-ROM drive, 128kB Cache
Uniform CD-ROM driver Revision: 3.20
PNP: PS/2 Controller [PNP0303:C0E2,PNP0f0e:C0E3] at 0x60,0x64 irq 1,12
i8042.c: Detected active multiplexing controller, rev 1.0.
serio: i8042 KBD port at 0x60,0x64 irq 1
serio: i8042 AUX0 port at 0x60,0x64 irq 12
serio: i8042 AUX1 port at 0x60,0x64 irq 12
serio: i8042 AUX2 port at 0x60,0x64 irq 12
serio: i8042 AUX3 port at 0x60,0x64 irq 12
mice: PS/2 mouse device common for all mice
input: PC Speaker as /devices/platform/pcspkr/input/input3
Advanced Linux Sound Architecture Driver Version 1.0.15 (Tue Nov 20 19:16:42
2007 UTC).
ACPI: PCI Interrupt 0000:00:08.0[A] -> Link [C185] -> GSI 11 (level, low) ->
IRQ 11
IBM TrackPoint firmware: 0x0b, buttons: 3/3
input: TPPS/2 IBM TrackPoint as /devices/platform/i8042/serio4/input/input4
input: AT Translated Set 2 keyboard
as /devices/platform/i8042/serio0/input/input5
es1968: clocking to 48000
ALSA device list:
#0: ESS ES1978 (Maestro 2E) at 0x3000, irq 11
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 15
Using IPI Shortcut mode
kjournald starting. Commit interval 5 seconds
EXT3-fs: mounted filesystem with ordered data mode.
VFS: Mounted root (ext3 filesystem) readonly.
Freeing unused kernel memory: 164k freed
EXT3 FS on hda3, internal journal
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
USB Universal Host Controller Interface driver v3.0
ACPI: PCI Interrupt 0000:00:07.2[D] -> Link [C186] -> GSI 11 (level, low) ->
IRQ 11
uhci_hcd 0000:00:07.2: UHCI Host Controller
uhci_hcd 0000:00:07.2: new USB bus registered, assigned bus number 1
uhci_hcd 0000:00:07.2: irq 11, io base 0x00003440
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
parport_pc 00:04: reported by Plug and Play ACPI
parport0: PC-style at 0x378, irq 7 [PCSPP,TRISTATE,EPP]
e100: Intel(R) PRO/100 Network Driver, 3.5.23-k4-NAPI
e100: Copyright(c) 1999-2006 Intel Corporation
NET: Registered protocol family 23
Yenta: CardBus bridge found at 0000:00:04.0 [0e11:b113]
Yenta: Using CSCINT to route CSC interrupts to PCI
Yenta: Routing CardBus interrupts to PCI
Yenta TI: socket 0000:00:04.0, mfunc 0x00000001, devctl 0x64
found SMC SuperIO Chip (devid=0x0a rev=00 base=0x00e0): FDC37N971
smsc_ircc_present: can't get sir_base of 0x3e8
Yenta: ISA IRQ mask 0x0478, PCI irq 11
Socket status: 30000006
Yenta: CardBus bridge found at 0000:00:04.1 [0e11:b113]
Yenta: Using CSCINT to route CSC interrupts to PCI
Yenta: Routing CardBus interrupts to PCI
Yenta TI: socket 0000:00:04.1, mfunc 0x00000001, devctl 0x64
Yenta: ISA IRQ mask 0x0478, PCI irq 11
Socket status: 30000020
ACPI: PCI Interrupt 0000:00:09.0[A] -> Link [C185] -> GSI 11 (level, low) ->
IRQ 11
e100: eth0: e100_probe: addr 0x41280000, irq 11, MAC addr 00:d0:59:37:5c:f9
pccard: CardBus card inserted into slot 1
PCI: Enabling device 0000:06:00.0 (0000 -> 0002)
ACPI: PCI Interrupt 0000:06:00.0[A] -> Link [C17E] -> GSI 11 (level, low) ->
IRQ 11
PCI: Setting latency timer of device 0000:06:00.0 to 64
phy0: Selected rate control algorithm 'simple'
cs: IO port probe 0xc00-0xcff: clean.
cs: IO port probe 0x800-0x8ff: clean.
cs: IO port probe 0x100-0x4ff: excluding 0x100-0x107
cs: IO port probe 0xa00-0xaff: clean.
cs: IO port probe 0xc00-0xcff: clean.
cs: IO port probe 0x800-0x8ff: clean.
cs: IO port probe 0x100-0x4ff: excluding 0x100-0x107
cs: IO port probe 0xa00-0xaff: clean.
WARNING: at net/mac80211/rx.c:1486 __ieee80211_rx()
Pid: 0, comm: swapper Not tainted 2.6.24-rc6-git5 #11
[<dc916f6a>] __ieee80211_rx+0x4da/0x4f0 [mac80211]
[<c0115021>] enqueue_task_fair+0x21/0x30
[<c0114dfd>] enqueue_entity+0x3d/0x70
[<dc908072>] ieee80211_tasklet_handler+0xb2/0xe0 [mac80211]
[<c01171e2>] enqueue_task+0x12/0x30
[<c012c32c>] rcu_do_batch+0x1c/0x80
[<c0120778>] tasklet_action+0x38/0x60
[<c0120584>] __do_softirq+0x74/0x90
[<c0105ef6>] do_softirq+0x46/0xc0
[<c0141db0>] handle_level_irq+0x0/0x100
[<c0120635>] irq_exit+0x65/0x70
[<c0105daf>] do_IRQ+0x6f/0xc0
[<c011440a>] __update_rq_clock+0x1a/0xf0
[<c01042e3>] common_interrupt+0x23/0x28
[<c014007b>] do_acct_process+0x16b/0x2f0
[<c011007b>] acpi_copy_wakeup_routine+0x2b/0x9c
[<c0219d53>] acpi_processor_idle+0x25b/0x36e
[<c01020dc>] cpu_idle+0x5c/0x80
[<c041181b>] start_kernel+0x18b/0x1d0
[<c0411360>] unknown_bootoption+0x0/0x150
=======================
Adding 498952k swap on /dev/hda4. Priority:-1 extents:1 across:498952k
wlan0: Initial auth_alg=0
wlan0: authenticate with AP XX:XX:XX:XX:XX:XX
wlan0: RX authentication from XX:XX:XX:XX:XX:XX (alg=0 transaction=2 status=0)
wlan0: authenticated
wlan0: associate with AP XX:XX:XX:XX:XX:XX
wlan0: RX AssocResp from XX:XX:XX:XX:XX:XX (capab=0x1 status=0 aid=1)
wlan0: associated
cpufreq: change failed with new_state 0 and result 2
ip_tables: (C) 2000-2006 Netfilter Core Team
nf_conntrack version 0.5.0 (7168 buckets, 28672 max)
NET: Unregistered protocol family 23
parport_pc 00:04: disabled
ACPI: PCI interrupt for device 0000:00:09.0 disabled
cpufreq: change failed with new_state 0 and result 2

--
Beer is proof that God loves us and wants us to be happy - Benjamin Franklin


2007-12-29 14:28:57

by Ivo Van Doorn

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Saturday 29 December 2007, Johannes Berg wrote:
>
> > but since the payload should be aligned to a 4 byte boundrary anyway
>
> That's not true. The "payload" in terms of "802.11 frame" shouldn't be
> aligned on a four-byte boundary for QoS or 4-addr frames.
>
> > can't predict what header length the frame will contain. :(
>
> Well, good hardware inserts padding, cf.
> http://bcm-v4.sipsolutions.net/802.11/RX
>
> > Although it would safe the initial allocation of the DMA buffer...
> > I'll look into it to see if it would be useful.
>
> More importantly, it'd save you the copy if your hardware is decent and
> inserts two bytes padding for QoS/WDS frames.

Well Ralink doesn't seem to add this padding since this bug appeared,
remember all bytes from the DMA was copied to the skb buffer so if there
was any padding included it would have been copied as well. ;)

Anyway, I have worked on a fix for the padding and I'll commit it to
rt2x00.git first to see if anybody reports any problems with it before
sending it to wireless-dev.

Same goes for letting the device copy the data into the skb buffer directly. :)

Ivo

2007-12-30 11:50:01

by Chris Clayton

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Saturday 29 December 2007, Ivo van Doorn wrote:
> On Saturday 29 December 2007, Johannes Berg wrote:
> > > Well Ralink doesn't seem to add this padding since this bug appeared,
> > > remember all bytes from the DMA was copied to the skb buffer so if
> > > there was any padding included it would have been copied as well. ;)
> >
> > Not necessarily, Broadcom hardware adds the padding in front of the
> > 802.11 header so if you'd start copying with the 802.11 header you'd run
> > into the same thing. A quick look at the rt2x00pci.c file doesn't
> > suggest that there's anything variable about the RX header though so I
> > guess that indeed this may be a problem.
> >
> > > Anyway, I have worked on a fix for the padding and I'll commit it to
> > > rt2x00.git first to see if anybody reports any problems with it before
> > > sending it to wireless-dev.
> >

If it would help, I'd be happy to test your fix, but I'm not a git user, so
you would need to post a patch that I could use...

> > Great. I just posted a similar fix in the other thread for zd1211, does
> > that look similar to yours as well? Should we have a static inline with
> > this code "ieee80211_needs_padding()" or something?
>
> My code looks more like:
>
> header_size = ieee80211_get_hdrlen_from_skb(entry->skb);
> if (header_size % 4 == 2) {
> /*
> * Move entire frame 2 bytes to the front.
> */
> skb_push(entry->skb, 2);
> memmove(entry->skb->data, entry->skb->data + 2,
> entry->skb->len - 2);
> }
>
> Ivo

Chris

--
Beer is proof that God loves us and wants us to be happy - Benjamin Franklin

2007-12-30 22:01:44

by Ivo Van Doorn

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

Hi,

> > Here is the patch against the latest vanilla kernel,
> > the previous piece of code was bugged since the header size check was
> > incorrect, but that is fixed in this one.
> >
>
> Thanks. You'll be pleased to here that with this patch, the warning has gone
> away and laptop's connection to my wireless network is still fine. I'll be
> using it over the New Year holiday. If anything negative happens I'll let you
> know.

excellent news, I have a few other patches currently under testing,
and if no big problems are reported with them rt2x00 2.6.14 will be
released at the end of this week.

Ivo

2007-12-29 09:54:30

by Johannes Berg

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

I didn't think that many drivers had this problem... The warning is
harmless on machines that are ok with unaligned memory accesses.

> WARNING: at net/mac80211/rx.c:1486 __ieee80211_rx()
> Pid: 0, comm: swapper Not tainted 2.6.24-rc6-git5 #11

comes from
/*
* Drivers are required to align the payload data to a four-byte
* boundary, so the last two bits of the address where it starts
* may not be set. The header is required to be directly before
* the payload data, padding like atheros hardware adds which is
* inbetween the 802.11 header and the payload is not supported,
* the driver is required to move the 802.11 header further back
* in that case.
*/
hdrlen = ieee80211_get_hdrlen(rx.fc);
WARN_ON_ONCE(((unsigned long)(skb->data + hdrlen)) & 3);


Although I'm starting to doubt my own sanity here with this sanity check
if so many drivers can trigger it.

johannes


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

2007-12-29 10:26:14

by Johannes Berg

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5


> If it helps as reference, rt2x00 allocates and initializes the data as follows:
>
> skb_reserve(skb, NET_IP_ALIGN);
> skb_put(skb, desc.size); /* Always a multiple of 4 bytes */
> memcpy(skb->data, entry->data_addr, desc.size);
>
> Should there have done more for the aligning of the data?

Well, typically, an RX buffer is comprised of the following elements:

* device-specific RX header [typically fixed length]
(* sometimes padding)
* 802.11 header
(* sometimes padding)
* 802.11 payload

The problem is that the 802.11 header has variable length. I explained
that previously, please see
http://article.gmane.org/gmane.linux.network/78792

Maybe the reporter here has received WDS or QoS (but not combined)
frames for some reason in which case the hardware has to insert padding
somewhere to make it work.

johannes


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

2007-12-29 12:01:19

by Johannes Berg

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5


On Sat, 2007-12-29 at 12:59 +0100, Johannes Berg wrote:
> > but since the payload should be aligned to a 4 byte boundrary anyway
>
> That's not true. The "payload" in terms of "802.11 frame" shouldn't be
> aligned on a four-byte boundary for QoS or 4-addr frames.

Eh, sorry. The start of the 802.11 header must be aligned on a four-byte
boundary for non-QoS/non-WDS/QoS+WDS frames and on +2 mod 4 for QoS/WDS
frames.

johannes


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

2007-12-29 11:59:44

by Johannes Berg

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5


> but since the payload should be aligned to a 4 byte boundrary anyway

That's not true. The "payload" in terms of "802.11 frame" shouldn't be
aligned on a four-byte boundary for QoS or 4-addr frames.

> can't predict what header length the frame will contain. :(

Well, good hardware inserts padding, cf.
http://bcm-v4.sipsolutions.net/802.11/RX

> Although it would safe the initial allocation of the DMA buffer...
> I'll look into it to see if it would be useful.

More importantly, it'd save you the copy if your hardware is decent and
inserts two bytes padding for QoS/WDS frames.

johannes


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

2007-12-29 10:36:57

by Johannes Berg

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5


> If it helps as reference, rt2x00 allocates and initializes the data as follows:
>
> skb_reserve(skb, NET_IP_ALIGN);
> skb_put(skb, desc.size); /* Always a multiple of 4 bytes */
> memcpy(skb->data, entry->data_addr, desc.size);

So why do you copy all the data anyway? You have DMA queues and no need
to not have the hardware dump the data into the frame to start with, no?

In any case, with wireless NET_IP_ALIGN is pretty useless unless you
want to add two to it and then align the result. Maybe the mac80211
warning should be relaxed to take NET_IP_ALIGN into account.

johannes


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

2007-12-29 11:47:39

by Ivo Van Doorn

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Saturday 29 December 2007, Johannes Berg wrote:
>
> > If it helps as reference, rt2x00 allocates and initializes the data as follows:
> >
> > skb_reserve(skb, NET_IP_ALIGN);
> > skb_put(skb, desc.size); /* Always a multiple of 4 bytes */
> > memcpy(skb->data, entry->data_addr, desc.size);
>
> So why do you copy all the data anyway? You have DMA queues and no need
> to not have the hardware dump the data into the frame to start with, no?

True, if no further aligning would be required that would be true,
but since the payload should be aligned to a 4 byte boundrary anyway
this would mean we must use memcpy() in all cases anyway since we
can't predict what header length the frame will contain. :(

Although it would safe the initial allocation of the DMA buffer...
I'll look into it to see if it would be useful.

> In any case, with wireless NET_IP_ALIGN is pretty useless unless you
> want to add two to it and then align the result. Maybe the mac80211
> warning should be relaxed to take NET_IP_ALIGN into account.

Ok, I'll look into better aligning of the skb buffer then.

Ivo

2007-12-30 19:27:06

by Chris Clayton

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Sunday 30 December 2007, Ivo van Doorn wrote:
> On Sunday 30 December 2007, Chris Clayton wrote:
> > On Saturday 29 December 2007, Ivo van Doorn wrote:
> > > On Saturday 29 December 2007, Johannes Berg wrote:
> > > > > Well Ralink doesn't seem to add this padding since this bug
> > > > > appeared, remember all bytes from the DMA was copied to the skb
> > > > > buffer so if there was any padding included it would have been
> > > > > copied as well. ;)
> > > >
> > > > Not necessarily, Broadcom hardware adds the padding in front of the
> > > > 802.11 header so if you'd start copying with the 802.11 header you'd
> > > > run into the same thing. A quick look at the rt2x00pci.c file doesn't
> > > > suggest that there's anything variable about the RX header though so
> > > > I guess that indeed this may be a problem.
> > > >
> > > > > Anyway, I have worked on a fix for the padding and I'll commit it
> > > > > to rt2x00.git first to see if anybody reports any problems with it
> > > > > before sending it to wireless-dev.
> >
> > If it would help, I'd be happy to test your fix, but I'm not a git user,
> > so you would need to post a patch that I could use...
>
> Here is the patch against the latest vanilla kernel,
> the previous piece of code was bugged since the header size check was
> incorrect, but that is fixed in this one.
>

Thanks. You'll be pleased to here that with this patch, the warning has gone
away and laptop's connection to my wireless network is still fine. I'll be
using it over the New Year holiday. If anything negative happens I'll let you
know.

Thanks again.

Chris

> ----
>
> diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c
> b/drivers/net/wireless/rt2x00/rt2x00dev.c index ff399f8..4f8a37b 100644
> --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
> +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
> @@ -386,6 +386,7 @@ void rt2x00lib_rxdone(struct data_entry *entry, struct
> sk_buff *skb, struct ieee80211_rx_status *rx_status =
> &rt2x00dev->rx_status;
> struct ieee80211_hw_mode *mode;
> struct ieee80211_rate *rate;
> + unsigned int header_size;
> unsigned int i;
> int val = 0;
>
> @@ -412,6 +413,26 @@ void rt2x00lib_rxdone(struct data_entry *entry, struct
> sk_buff *skb, }
> }
>
> + /*
> + * Properly align the ieee80211 frame and make sure the
> + * data behind the ieee80211 header is on a 4 byte boundrary.
> + */
> + header_size = ieee80211_get_hdrlen_from_skb(skb);
> + if (!header_size) {
> + /*
> + * Frame is too short to contain a valid header,
> + * drop the entire frame since it is useless.
> + */
> + kfree_skb(skb);
> + return;
> + } else if (header_size % 4 == 0) {
> + /*
> + * Move entire frame 2 bytes to the front.
> + */
> + skb_push(skb, 2);
> + memmove(skb->data, skb->data + 2, skb->len - 2);
> + }
> +
> rt2x00_update_link_rssi(&rt2x00dev->link, desc->rssi);
> rt2x00dev->link.rx_success++;
> rx_status->rate = val;



--
Beer is proof that God loves us and wants us to be happy - Benjamin Franklin

2007-12-29 10:21:16

by Ivo Van Doorn

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Saturday 29 December 2007, Johannes Berg wrote:
> I didn't think that many drivers had this problem... The warning is
> harmless on machines that are ok with unaligned memory accesses.
>
> > WARNING: at net/mac80211/rx.c:1486 __ieee80211_rx()
> > Pid: 0, comm: swapper Not tainted 2.6.24-rc6-git5 #11
>
> comes from
> /*
> * Drivers are required to align the payload data to a four-byte
> * boundary, so the last two bits of the address where it starts
> * may not be set. The header is required to be directly before
> * the payload data, padding like atheros hardware adds which is
> * inbetween the 802.11 header and the payload is not supported,
> * the driver is required to move the 802.11 header further back
> * in that case.
> */
> hdrlen = ieee80211_get_hdrlen(rx.fc);
> WARN_ON_ONCE(((unsigned long)(skb->data + hdrlen)) & 3);
>
>
> Although I'm starting to doubt my own sanity here with this sanity check
> if so many drivers can trigger it.

If it helps as reference, rt2x00 allocates and initializes the data as follows:

skb_reserve(skb, NET_IP_ALIGN);
skb_put(skb, desc.size); /* Always a multiple of 4 bytes */
memcpy(skb->data, entry->data_addr, desc.size);

Should there have done more for the aligning of the data?

Ivo

2007-12-29 14:40:22

by Johannes Berg

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5


> Well Ralink doesn't seem to add this padding since this bug appeared,
> remember all bytes from the DMA was copied to the skb buffer so if there
> was any padding included it would have been copied as well. ;)

Not necessarily, Broadcom hardware adds the padding in front of the
802.11 header so if you'd start copying with the 802.11 header you'd run
into the same thing. A quick look at the rt2x00pci.c file doesn't
suggest that there's anything variable about the RX header though so I
guess that indeed this may be a problem.

> Anyway, I have worked on a fix for the padding and I'll commit it to
> rt2x00.git first to see if anybody reports any problems with it before
> sending it to wireless-dev.

Great. I just posted a similar fix in the other thread for zd1211, does
that look similar to yours as well? Should we have a static inline with
this code "ieee80211_needs_padding()" or something?

johannes


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

2007-12-29 15:14:40

by Ivo Van Doorn

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Saturday 29 December 2007, Johannes Berg wrote:
>
> > Well Ralink doesn't seem to add this padding since this bug appeared,
> > remember all bytes from the DMA was copied to the skb buffer so if there
> > was any padding included it would have been copied as well. ;)
>
> Not necessarily, Broadcom hardware adds the padding in front of the
> 802.11 header so if you'd start copying with the 802.11 header you'd run
> into the same thing. A quick look at the rt2x00pci.c file doesn't
> suggest that there's anything variable about the RX header though so I
> guess that indeed this may be a problem.
>
> > Anyway, I have worked on a fix for the padding and I'll commit it to
> > rt2x00.git first to see if anybody reports any problems with it before
> > sending it to wireless-dev.
>
> Great. I just posted a similar fix in the other thread for zd1211, does
> that look similar to yours as well? Should we have a static inline with
> this code "ieee80211_needs_padding()" or something?

My code looks more like:

header_size = ieee80211_get_hdrlen_from_skb(entry->skb);
if (header_size % 4 == 2) {
/*
* Move entire frame 2 bytes to the front.
*/
skb_push(entry->skb, 2);
memmove(entry->skb->data, entry->skb->data + 2,
entry->skb->len - 2);
}

Ivo

2007-12-31 07:56:18

by Ivo Van Doorn

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Dec 31, 2007 8:27 AM, Kalle Valo <[email protected]> wrote:
> Ivo van Doorn <[email protected]> writes:
>
> > + /*
> > + * Move entire frame 2 bytes to the front.
> > + */
> > + skb_push(skb, 2);
> > + memmove(skb->data, skb->data + 2, skb->len - 2);
>
> No skb_trim()? Shoudn't there be skb_trim(skb, 2) after memmove()?

Good point, I completely forgot about that. :S
Thanks. :)

Ivo

2007-12-30 12:11:50

by Ivo Van Doorn

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Sunday 30 December 2007, Chris Clayton wrote:
> On Saturday 29 December 2007, Ivo van Doorn wrote:
> > On Saturday 29 December 2007, Johannes Berg wrote:
> > > > Well Ralink doesn't seem to add this padding since this bug appeared,
> > > > remember all bytes from the DMA was copied to the skb buffer so if
> > > > there was any padding included it would have been copied as well. ;)
> > >
> > > Not necessarily, Broadcom hardware adds the padding in front of the
> > > 802.11 header so if you'd start copying with the 802.11 header you'd run
> > > into the same thing. A quick look at the rt2x00pci.c file doesn't
> > > suggest that there's anything variable about the RX header though so I
> > > guess that indeed this may be a problem.
> > >
> > > > Anyway, I have worked on a fix for the padding and I'll commit it to
> > > > rt2x00.git first to see if anybody reports any problems with it before
> > > > sending it to wireless-dev.
> > >
>
> If it would help, I'd be happy to test your fix, but I'm not a git user, so
> you would need to post a patch that I could use...

Here is the patch against the latest vanilla kernel,
the previous piece of code was bugged since the header size check was incorrect,
but that is fixed in this one.

----

diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index ff399f8..4f8a37b 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -386,6 +386,7 @@ void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb,
struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status;
struct ieee80211_hw_mode *mode;
struct ieee80211_rate *rate;
+ unsigned int header_size;
unsigned int i;
int val = 0;

@@ -412,6 +413,26 @@ void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb,
}
}

+ /*
+ * Properly align the ieee80211 frame and make sure the
+ * data behind the ieee80211 header is on a 4 byte boundrary.
+ */
+ header_size = ieee80211_get_hdrlen_from_skb(skb);
+ if (!header_size) {
+ /*
+ * Frame is too short to contain a valid header,
+ * drop the entire frame since it is useless.
+ */
+ kfree_skb(skb);
+ return;
+ } else if (header_size % 4 == 0) {
+ /*
+ * Move entire frame 2 bytes to the front.
+ */
+ skb_push(skb, 2);
+ memmove(skb->data, skb->data + 2, skb->len - 2);
+ }
+
rt2x00_update_link_rssi(&rt2x00dev->link, desc->rssi);
rt2x00dev->link.rx_success++;
rx_status->rate = val;


2007-12-31 07:28:17

by Kalle Valo

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

Ivo van Doorn <[email protected]> writes:

> + /*
> + * Move entire frame 2 bytes to the front.
> + */
> + skb_push(skb, 2);
> + memmove(skb->data, skb->data + 2, skb->len - 2);

No skb_trim()? Shoudn't there be skb_trim(skb, 2) after memmove()?

--
Kalle Valo

2008-01-08 23:18:21

by Tomas Winkler

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Jan 8, 2008 10:02 PM, Michael Buesch <[email protected]> wrote:
> On Tuesday 08 January 2008 20:43:53 Tomas Winkler wrote:
> > On Jan 8, 2008 7:22 PM, Johannes Berg <[email protected]> wrote:
> > >
> > > On Tue, 2008-01-08 at 18:09 +0100, Johannes Berg wrote:
> > > > > I didn't test the copy solution yet but in 11n rates I see as a show
> > > > > stopper. All 11n packets are QoS packets.
> > > >
> > > > Really, go fix your firmware.
> > >
> >
> > I don't think it is really broken. The packet it self is aligned. I'm
> > not sure who has to be responsible for payload alignment you may have
> > 10 other protocols packed into it, each with variable length
> > unaligned header.
>
> Yeah sure. You can move data around in the kernel and waste CPU,
> or you can be clever and let the NIC firmware do it. Whatever you want
> at intel. It's up to you. ;)

You are twisting my answer please read it again.
Frankly I will try to fix it in FW but if not I rather fail on 2
platforms then making 11n useless on 4 others.
Maybe we should ask some company to fix ther CPU to support unaligned
access. Or ask the guys that 'saved' two bytes in QoS field to change
the spec. Same goes for designers of 4965 that never dreamed someone
will stick it to SPARC machine. And I can bet the same goes for other
wireless HW companies.

Cheers, please don't replay to me I''m really going to try fix it :)

Tomas


> --
> Greetings Michael.
>

2008-01-02 19:13:03

by Ivo Van Doorn

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

Hi,

> Happy New Year!

You too. :)

> I was out since Saturday just before you sent your
> message, sorry for the late reply.
>
> > header_size = ieee80211_get_hdrlen_from_skb(entry->skb);
> > if (header_size % 4 == 2) {
> > /*
> > * Move entire frame 2 bytes to the front.
> > */
> > skb_push(entry->skb, 2);
> > memmove(entry->skb->data, entry->skb->data + 2,
> > entry->skb->len - 2);
> > }
>
> That doesn't really look right, I'd think the skb will be two bytes too
> long after this.

Yeah, fixed this in rt2x00.git :)

> It's probably more efficient to decide where to copy
> the frame and do the realignment while you're copying it anyway rather
> than doing a copy and then a memmove.
>
> I guess you should also try talk to Ralink to get firmware to do it
> (where possible), it's probably not too hard to insert padding before
> the frame.

Well the problem is a bit bigger than this, the bug is reported very rarely,
so I can't say for sure which drivers are affected by this. But since most
Ralink chipsets look alike, I think the safest assumption is that all are
affected.

rt2400pci, rt2500pci and rt2500usb don't have firmware, for rt61pci and
rt73usb there is, but looking at how the TX and RX registers are working
I *assume* the firmware isn't doing much in this area. (My personal
guess for the firmware is that it only handles the hardware encryption
and perhaps beaconing & virtual interfaces)
Additionally firmware for rt61 and rt73 have been discontinued,
all their work is currently going to rt2860 and rt2870. (Porting these to
rt2x00 has already begun, but I haven't arrived at the header alignment yet)

For PCI drivers I could indeed optimize the code by making the memcpy
perform the operation on the 4 byte aligned code. But for this I need
to check what is better, RX directly into a skbuff and use memmove
or RX into DMA and use memcpy to a skbuff.
But for USB this is not possible, since it directly performs the RX into
the skbuff already, so I either have to change that or perform memmove anyway.

> If you absolutely can't get the hardware to do it and would otherwise do
> DMA right into the skb we should try to evaluate the performance hit on
> platforms where unaligned access *is* possible to be able to balance it
> against the performance hit caused by the memmove(). Ultimately, though,
> I value correctness on all platforms over performance on some, hence the
> warning when unaligned packets are handed up to mac80211.

Overall correctness sounds as the best solution to me too.

Ivo


2008-01-06 07:55:38

by Andrew Price

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On 04/01/08 17:09, Chris Clayton wrote:
> On Wednesday 02 January 2008, Ivo van Doorn wrote:
>> On Wednesday 02 January 2008, Chris Clayton wrote:
>>> Ah, does the patch I have applied and am running need enhancement,
>>> please?
>> ---
>>
>> diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c
>> b/drivers/net/wireless/rt2x00/rt2x00dev.c index ff399f8..3c10a68 100644
>> --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
>> +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
>
> <snip>

I was seeing the same warning so I've applied the patch to the latest
mainline git tree. It's cured the warning and everything seems to be ok
so far. I'll let you know if I see any side effects. In case you're
interested I've got one of these:

02:00.0 Network controller: RaLink RT2500 802.11g Cardbus/mini-PCI (rev 01)
Subsystem: Belkin F5D7010 Wireless G Notebook Network Card
Flags: bus master, slow devsel, latency 64, IRQ 16
Memory at 54000000 (32-bit, non-prefetchable) [size=8K]
Capabilities: [40] Power Management version 2

Regards,

--
Andy Price


2008-01-02 06:32:55

by Chris Clayton

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Monday 31 December 2007, Ivo Van Doorn wrote:
> On Dec 31, 2007 8:27 AM, Kalle Valo <[email protected]> wrote:
> > Ivo van Doorn <[email protected]> writes:
> > > + /*
> > > + * Move entire frame 2 bytes to the front.
> > > + */
> > > + skb_push(skb, 2);
> > > + memmove(skb->data, skb->data + 2, skb->len - 2);
> >
> > No skb_trim()? Shoudn't there be skb_trim(skb, 2) after memmove()?
>
> Good point, I completely forgot about that. :S
> Thanks. :)
>
> Ivo

Ah, does the patch I have applied and am running need enhancement, please?

Thanks

--
Beer is proof that God loves us and wants us to be happy - Benjamin Franklin

2008-01-08 17:14:29

by Johannes Berg

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5


> I didn't test the copy solution yet but in 11n rates I see as a show
> stopper. All 11n packets are QoS packets.

Really, go fix your firmware.

> I haven't encounter a problems in net stack yet so I think this
> solution is a bit drastic.

You're not running on arm or sparc I guess. But the fact that pretty
much *nobody* was aware of this problem until now tells me that I did
the right thing and this solution is not "a bit drastic" *at all*.

johannes


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

2008-01-08 17:23:11

by Johannes Berg

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5


On Tue, 2008-01-08 at 18:09 +0100, Johannes Berg wrote:
> > I didn't test the copy solution yet but in 11n rates I see as a show
> > stopper. All 11n packets are QoS packets.
>
> Really, go fix your firmware.

I meant to write more here but accidentally deleted parts when
restructuring. The firmware should insert padding to make sure the
payload is aligned on a four-byte boundary at all times when the start
of the DMA area is aligned that way.

johannes


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

2008-01-08 19:43:54

by Tomas Winkler

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Jan 8, 2008 7:22 PM, Johannes Berg <[email protected]> wrote:
>
> On Tue, 2008-01-08 at 18:09 +0100, Johannes Berg wrote:
> > > I didn't test the copy solution yet but in 11n rates I see as a show
> > > stopper. All 11n packets are QoS packets.
> >
> > Really, go fix your firmware.
>

I don't think it is really broken. The packet it self is aligned. I'm
not sure who has to be responsible for payload alignment you may have
10 other protocols packed into it, each with variable length
unaligned header.

> I meant to write more here but accidentally deleted parts when
> restructuring. The firmware should insert padding to make sure the
> payload is aligned on a four-byte boundary at all times when the start
> of the DMA area is aligned that way.
>
I understand that I'll see what can be done, yet I don't like it

Tomas


> johannes
>

2008-01-02 19:02:43

by Ivo Van Doorn

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Wednesday 02 January 2008, Chris Clayton wrote:
> On Monday 31 December 2007, Ivo Van Doorn wrote:
> > On Dec 31, 2007 8:27 AM, Kalle Valo <[email protected]> wrote:
> > > Ivo van Doorn <[email protected]> writes:
> > > > + /*
> > > > + * Move entire frame 2 bytes to the front.
> > > > + */
> > > > + skb_push(skb, 2);
> > > > + memmove(skb->data, skb->data + 2, skb->len - 2);
> > >
> > > No skb_trim()? Shoudn't there be skb_trim(skb, 2) after memmove()?
> >
> > Good point, I completely forgot about that. :S
> > Thanks. :)
> >
> > Ivo
>
> Ah, does the patch I have applied and am running need enhancement, please?

---

diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index ff399f8..3c10a68 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -386,6 +386,7 @@ void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb,
struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status;
struct ieee80211_hw_mode *mode;
struct ieee80211_rate *rate;
+ unsigned int header_size;
unsigned int i;
int val = 0;

@@ -412,6 +413,27 @@ void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb,
}
}

+ /*
+ * Properly align the ieee80211 frame and make sure the
+ * data behind the ieee80211 header is on a 4 byte boundrary.
+ */
+ header_size = ieee80211_get_hdrlen_from_skb(skb);
+ if (!header_size) {
+ /*
+ * Frame is too short to contain a valid header,
+ * drop the entire frame since it is useless.
+ */
+ kfree_skb(skb);
+ return;
+ } else if (header_size % 4 == 0) {
+ /*
+ * Move entire frame 2 bytes to the front.
+ */
+ skb_push(skb, 2);
+ memmove(skb->data, skb->data + 2, skb->len - 2);
+ skb_trim(skb, skb->len - 2);
+ }
+
rt2x00_update_link_rssi(&rt2x00dev->link, desc->rssi);
rt2x00dev->link.rx_success++;
rx_status->rate = val;

2008-01-08 15:44:10

by Tomas Winkler

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Jan 2, 2008 9:12 PM, Ivo van Doorn <[email protected]> wrote:
> Hi,
>
> > Happy New Year!
>
> You too. :)
>
> > I was out since Saturday just before you sent your
> > message, sorry for the late reply.
> >
> > > header_size = ieee80211_get_hdrlen_from_skb(entry->skb);
> > > if (header_size % 4 == 2) {
> > > /*
> > > * Move entire frame 2 bytes to the front.
> > > */
> > > skb_push(entry->skb, 2);
> > > memmove(entry->skb->data, entry->skb->data + 2,
> > > entry->skb->len - 2);
> > > }
> >
> > That doesn't really look right, I'd think the skb will be two bytes too
> > long after this.

> For PCI drivers I could indeed optimize the code by making the memcpy
> perform the operation on the 4 byte aligned code. But for this I need
> to check what is better, RX directly into a skbuff and use memmove
> or RX into DMA and use memcpy to a skbuff.
> But for USB this is not possible, since it directly performs the RX into
> the skbuff already, so I either have to change that or perform memmove anyway.
>
> > If you absolutely can't get the hardware to do it and would otherwise do
> > DMA right into the skb we should try to evaluate the performance hit on
> > platforms where unaligned access *is* possible to be able to balance it
> > against the performance hit caused by the memmove(). Ultimately, though,
> > I value correctness on all platforms over performance on some, hence the
> > warning when unaligned packets are handed up to mac80211.
>
> Overall correctness sounds as the best solution to me too.

I see it now happening in iw4965
I didn't test the copy solution yet but in 11n rates I see as a show
stopper. All 11n packets are QoS packets.
I haven't encounter a problems in net stack yet so I think this
solution is a bit drastic.

Thanks
Tomas

Tomas


> Ivo

2008-01-08 20:03:53

by Michael Büsch

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Tuesday 08 January 2008 20:43:53 Tomas Winkler wrote:
> On Jan 8, 2008 7:22 PM, Johannes Berg <[email protected]> wrote:
> >
> > On Tue, 2008-01-08 at 18:09 +0100, Johannes Berg wrote:
> > > > I didn't test the copy solution yet but in 11n rates I see as a show
> > > > stopper. All 11n packets are QoS packets.
> > >
> > > Really, go fix your firmware.
> >
>
> I don't think it is really broken. The packet it self is aligned. I'm
> not sure who has to be responsible for payload alignment you may have
> 10 other protocols packed into it, each with variable length
> unaligned header.

Yeah sure. You can move data around in the kernel and waste CPU,
or you can be clever and let the NIC firmware do it. Whatever you want
at intel. It's up to you. ;)

--
Greetings Michael.

2008-01-04 17:09:38

by Chris Clayton

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Wednesday 02 January 2008, Ivo van Doorn wrote:

<snip>

> On Wednesday 02 January 2008, Chris Clayton wrote:
> >
> > Ah, does the patch I have applied and am running need enhancement,
> > please?
>

Thanks, I'll run 2.6.24-rc6-git10 with this patch over the weekend and let you
know if there are any problems

Chris
> ---
>
> diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c
> b/drivers/net/wireless/rt2x00/rt2x00dev.c index ff399f8..3c10a68 100644
> --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
> +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c

<snip>

--
Beer is proof that God loves us and wants us to be happy - Benjamin Franklin

2008-01-02 08:38:14

by Johannes Berg

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

Hi,

Happy New Year! I was out since Saturday just before you sent your
message, sorry for the late reply.

> header_size = ieee80211_get_hdrlen_from_skb(entry->skb);
> if (header_size % 4 == 2) {
> /*
> * Move entire frame 2 bytes to the front.
> */
> skb_push(entry->skb, 2);
> memmove(entry->skb->data, entry->skb->data + 2,
> entry->skb->len - 2);
> }

That doesn't really look right, I'd think the skb will be two bytes too
long after this. It's probably more efficient to decide where to copy
the frame and do the realignment while you're copying it anyway rather
than doing a copy and then a memmove.

I guess you should also try talk to Ralink to get firmware to do it
(where possible), it's probably not too hard to insert padding before
the frame.

If you absolutely can't get the hardware to do it and would otherwise do
DMA right into the skb we should try to evaluate the performance hit on
platforms where unaligned access *is* possible to be able to balance it
against the performance hit caused by the memmove(). Ultimately, though,
I value correctness on all platforms over performance on some, hence the
warning when unaligned packets are handed up to mac80211.

johannes


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

2008-01-08 06:03:41

by Chris Clayton

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5

On Friday 04 January 2008, Chris Clayton wrote:
> On Wednesday 02 January 2008, Ivo van Doorn wrote:
>
> <snip>
>
> > On Wednesday 02 January 2008, Chris Clayton wrote:
> > > Ah, does the patch I have applied and am running need enhancement,
> > > please?
>
> Thanks, I'll run 2.6.24-rc6-git10 with this patch over the weekend and let
> you know if there are any problems

OK, I've been running 2.6.24-rc6-git kernels (rc7 last night) with the patch
applied and my wireless connection has been fine. So here's my

Tested-by: Chris Clayton <[email protected]>

Thanks

>
> Chris
>
> > ---
> >
> > diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c
> > b/drivers/net/wireless/rt2x00/rt2x00dev.c index ff399f8..3c10a68 100644
> > --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
> > +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
>
> <snip>



--
Beer is proof that God loves us and wants us to be happy - Benjamin Franklin

2008-01-09 12:50:12

by Johannes Berg

[permalink] [raw]
Subject: Re: Warning emited by 2.6.24-rc6-git5


> I don't think it is really broken. The packet it self is aligned. I'm
> not sure who has to be responsible for payload alignment you may have
> 10 other protocols packed into it, each with variable length
> unaligned header.

That doesn't actually happen though, or it becomes the responsibility of
the unwrapper to handle it. The only thing 802.11 really wraps into the
payload is the protocol, with possibly an 8-byte rfc1042 header (that
doesn't break 4-byte alignment). If there's something like VPN
encapsulated it obviously becomes the responsibility of the VPN code to
align the packet properly before passing it off to the IP stack. But
where we do have IP right in our packet we need to make sure we give it
properly aligned packets.

> I understand that I'll see what can be done, yet I don't like it

Not sure what there is to like about. I know Intel and powerpc hardware
handles unaligned loads (though at a price), but I also know that there
will be somebody sticking cards into a sparc64 or arm machine where it
fails. Aligning the packets in firmware, before they're DMA'ed into
memory, is simply the cheapest option.

johannes


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