History log of /drivers/net/wireless/rt2x00/rt2x00dev.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
e2bc7c5f3cb8756865aa0ab140d2288f61599dda 29-Mar-2012 Chen, Chien-Chia <machen@suse.com> rt2x00: Fix rfkill_polling register function.

Move rt2x00rfkill_register(rt2x00dev) to rt2x00lib_probe_dev
function. It fixes of starting rfkill_poll function at the
right time if sets hard rfkill block and reboot. rt2x00mac_rfkill_poll
should be starting before bringing up the wireless interface.

Signed-off-by: Chen, Chien-Chia <machen@suse.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
CC: Kevin Chou <kevin.chou@mediatek.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
4da0bd736552e6377b407b3c3d3ae518ebbdd269 19-Mar-2012 David S. Miller <davem@davemloft.net> Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
f421111b5e69020c047eb3ff057e50f446c3c7a2 14-Mar-2012 Stanislaw Gruszka <sgruszka@redhat.com> rt2x00: rt2800usb: rework txstatus code

Currently we read tx status register after each urb data transfer. As
callback procedure also trigger reading, that causing we have many
"threads" of reading status. To prevent that introduce TX_STATUS_READING
flags, and check if we are already in process of sequential reading
TX_STA_FIFO, before requesting new reads.

Change timer to hrtimer, that make TX_STA_FIFO overruns less possible.
Use 200 us for initial timeout, and then reschedule in 100 us period,
this values probably have to be tuned.

Make changes on txdone work. Schedule it from
rt2800usb_tx_sta_fifo_read_completed() callback when first valid status
show up. Check in callback if tx status timeout happens, and schedule
work on that condition too. That make possible to remove tx status
timeout from generic watchdog. I moved that to rt2800usb.

Loop in txdone work, that should prevent situation when we queue work,
which is already processed, and after finish work is not rescheduled
again.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
3780d038fdf4b5ef26ead10b0604ab1f46dd9510 09-Mar-2012 Stanislaw Gruszka <sgruszka@redhat.com> rt2x00: fix random stalls

Is possible that we stop queue and then do not wake up it again,
especially when packets are transmitted fast. That can be easily
reproduced with modified tx queue entry_num to some small value e.g. 16.

If mac80211 already hold local->queue_stop_reason_lock, then we can wait
on that lock in both rt2x00queue_pause_queue() and
rt2x00queue_unpause_queue(). After drooping ->queue_stop_reason_lock
is possible that __ieee80211_wake_queue() will be performed before
__ieee80211_stop_queue(), hence we stop queue and newer wake up it
again.

Another race condition is possible when between rt2x00queue_threshold()
check and rt2x00queue_pause_queue() we will process all pending tx
buffers on different cpu. This might happen if for example interrupt
will be triggered on cpu performing rt2x00mac_tx().

To prevent race conditions serialize pause/unpause by queue->tx_lock.

Cc: stable@vger.kernel.org
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
8701ff0a88bcfc8c7dced3842919ad8d016a6835 29-Feb-2012 John W. Linville <linville@tuxdriver.com> Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless
2e9c43dd45ced5bd77c94d4216f96b4a49448d73 16-Feb-2012 John Li <chen-yang.li@mediatek.com> rt2x00:Add VCO recalibration

Signed-off-by: John Li <chen-yang.li@mediatek.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
7be081539e540517d5e1fcbf96b8080074afbf08 16-Feb-2012 Gabor Juhos <juhosg@openwrt.org> rt2x00: fix a possible NULL pointer dereference

The 'rt2x00lib_probe_dev' function tries to
allocate the workqueue. If the allocation
fails, 'rt2x00_lib_remove_dev' is called on
the error path. Because 'rt2x00dev->workqueue'
is NULL in this case, the 'destroy_workqueue'
call will cause a NULL pointer dereference.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
1ebbc48520a0853cd4d812d8342f9886b2b07b92 06-Feb-2012 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Introduce concept of driver data in struct rt2x00_dev.

We are getting more and more fields in struct rt2x00_dev that are
specific to one or two of the low-level drivers. Instead of putting
these fields inside the main structure and thus clobbering all low-level
drivers with these fields, introduce the concept of driver data inside
struct rt2x00_dev, whose size is indicated by the low-level driver and
which can be populated by the low-level driver.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
839fafbe0dc35fabeb9bd3be9727fd74d12c0b9d 29-Nov-2011 Thomas Meyer <thomas@m3y3r.de> rt2x00: Use kcalloc instead of kzalloc to allocate array

The advantage of kcalloc is, that will prevent integer overflows which could
result from the multiplication of number of elements and size and it is also
a bit nicer to read.

The semantic patch that makes this change is available
in https://lkml.org/lkml/2011/11/25/107

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
ed66ba472a742cd8df37d7072804b2111cdb1014 12-Nov-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Fix sleep-while-atomic bug in powersaving code.

The generic powersaving code that determines after reception of a frame
whether the device should go back to sleep or whether is could stay
awake was calling rt2x00lib_config directly from RX tasklet context.
On a number of the devices this call can actually sleep, due to having
to confirm that the sleeping commands have been executed successfully.

Fix this by moving the call to rt2x00lib_config to a workqueue call.

This fixes bug https://bugzilla.redhat.com/show_bug.cgi?id=731672

Tested-by: Tomas Trnka <tomastrnka@gmx.com>
Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Cc: <stable@vger.kernel.org>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
b4943d8113500ee783072ba2ba7506ad76df3726 08-Sep-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Introduce sta_add/remove callbacks

This implements a basic sta_add and sta_remove callback. Introduce a new
structure rt2x00_sta and ask mac80211 to allocate it as private part of
its ieee80211_sta. rt2x00_sta only contains the WCID for now.

The sta_add callback allows the driver to assign a WCID to a station
that is currently being added. The same wcid is also passed to the
sta_remove callback one mac80211 removes this STA.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
183255235aadefd5a987021346e7aee2cbe721eb 08-Sep-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Move bssidx calculation into its own function

This will be used by a later patch. No functional changes.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
abc11994112bf7441519e35f51c29ff5de5b0d4d 06-Aug-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Fix PCI interrupt processing race on SMP systems

When toggle_irq is called for PCI devices to disable device interrupts
it used tasklet_disable to wait for a possibly running tasklet to finish.
However, on SMP systems the tasklet might still be scheduled on another CPU.
Instead, use tasklet_kill to ensure that all scheduled tasklets are finished
before returning from toggle_irq.

Furthermore, it was possible that a tasklet reenabled its interrupt even
though interrupts have been disabled already. Fix this by checking the
DEVICE_STATE_ENABLED_RADIO flag before reenabling single interrupts
during tasklet processing.

While at it also enable/kill the TBTT and PRETBTT tasklets in the
toggle_irq callback and only use tasklet_kill in stop_queue to wait
for a currently scheduled beacon update before returning.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
7f503fc49f144bb509dbd33daf3426df3f176e6b 19-Jun-2011 Stanislaw Gruszka <stf_xl@wp.pl> rt2x00: fix possible memory corruption in case of invalid rxdesc.size

Sometimes rxdesc descriptor provided by hardware contains invalid
(random) data. For example rxdesc.size can be bigger than actual
size of the buffer. When this happen rt2x00crypto_rx_insert_iv()
corrupt memory doing memmove outside of buffer boundaries.

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
3bb42a64960253353278876ca8da6b0a7d3bea87 04-Jun-2011 Stanislaw Gruszka <stf_xl@wp.pl> rt2x00: fix rmmod crash

Avoid queue and run autowakeup_work when device is not present anymore.
That prevent rmmod and device remove crash introduced by:

commit 1c0bcf89d85cc97a0d9ce4cd909351a81fa4fdde
Author: Ivo van Doorn <ivdoorn@gmail.com>
Date: Sat Apr 30 17:18:18 2011 +0200

rt2x00: Add autowake support for USB hardware

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
9a24af1136e6d08c73010205caa282f46223aed5 07-May-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Fix rmmod hang of rt2800pci

txstatus_timer should only be deleted for USB devices, as it is only
initialized for USB devices.

Reported-by: Andreas Hartmann <andihartmann@01019freenet.de>
Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
1c0bcf89d85cc97a0d9ce4cd909351a81fa4fdde 30-Apr-2011 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Add autowake support for USB hardware

The USB drivers don't support automatically waking up when in powersaving mode,
add a work object which will wakeup the device in time to receive the next beacon.
Based on that beacon, we either go back into powersaving mode, or we remain awake
to receive the buffered frames for our station.

Some part of the code, especially rt2x00lib_find_ie and rt2x00lib_rxdone_check_ps
are inspired on the code from carl9170.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
f0187a1987ed6524518ff2a533eaf8394ac1a500 18-Apr-2011 Johannes Stezenbach <js@sig21.net> rt2800usb: add timer to handle TX_STA_FIFO

TX status is reported by the hardware when a packet has been
sent (or after TX failed after possible retries), which is some
time after the DMA completion. Since the rt2800usb hardware can
not signal interrupts we have to use a timer, otherwise the
TX status would only be read by the next packet's TX DMA
completion, or by the watchdog thread.

Signed-off-by: Johannes Stezenbach <js@sig21.net>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
75256f0348d38f414b7ac50ac78d4a4532bb6762 18-Apr-2011 Johannes Stezenbach <js@sig21.net> rt2x00: fix queue timeout checks

Add a timestamp to each queue entry which is updated whenever
the status of the entry changes, and remove the per-queue
timestamps. The previous check was incorrect and caused both
false positives and false negatives.

With the corrected check it comes apparent that the TX status
usually times out on rt2800usb unless there is sufficient traffic
(i.e. the next TX will complete the previous TX status).

Signed-off-by: Johannes Stezenbach <js@sig21.net>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
7dab73b37f5e8885cb73efd25e73861f9b4f0246 18-Apr-2011 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Split rt2x00dev->flags

The number of flags defined for the rt2x00dev->flags field,
has been growing over the years. Currently we are approaching
the maximum number of bits which are available in the field.

A secondary problem, is that one part of the field are initialized only
during boot, because the driver requirements are initialized or device
requirements are loaded from the EEPROM. In both cases, the flags are
fixed and will not change during device operation. The other flags are
the device state, and will change frequently. So far this resulted in the fact
that for some flags, the atomic bit accessors are used, while for the others
the non-atomic variants are used.

By splitting the flags up into a "flags" and "cap_flags" we can put all flags
which are fixed inside "cap_flags". This field can then be read non-atomically.
In the "flags" field we keep the device state, which is going to be read atomically.

This adds more room for more flags in the future, and sanitizes the field access methods.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
b37e3b6d64358604960b35e8ecbb7aed22e0926e 07-Apr-2011 John W. Linville <linville@tuxdriver.com> Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6

Conflicts:
drivers/net/wireless/rtlwifi/efuse.c
drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c
net/bluetooth/mgmt.c
f16d2db704b873d34cec54f992637f3579e10e08 28-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Fix tx aggregation problems with some clients

Some clients seem to rely upon the reception of BlockAckReqs to flush
their rx reorder buffer. In order to fix aggregation for these clients
rt2x00 should send a BlockAckReq if the transmission of an AMPDU
subframe fails.

Introduce a new flag TXDONE_AMPDU to indicate that this is an AMPDU
subframe and pass IEEE80211_TX_STAT_AMPDU_NO_BACK to mac80211 if an
AMPDU subframe failed during transmission.

This fixes aggregation problems with Intel 5100 Windows STAs (and maybe
others as well).

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
9e33a3553821418b2c4f53d09311476c55176b13 28-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Implement tx power temperature compensation

rt2800 devices should adjust their tx power in accordance with the
eeproms temperature calibration values. Add a new driver callback
gain_calibration that is called every 4 seconds.

The rt2800 gain calibration routine simply runs the tx power
configuration that takes care of calculating the temperature
compensation delta.

We don't need to synchronize the calls to rt2800_config_txpower
as they should all happen from mac80211's single threaded workqueue.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
2f2bb7e8bdc977c94cdaaf84328526555eba89b1 28-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Remove obsolete rt2x00queue_align_payload

Since commit d1c3a37ceeb1a5ea02991a0476355f1a1d3b3e83 ("mac80211:
clarify alignment docs, fix up alignment") removed the requirement
for a 4-byte aligned payload rt2x00queue_align_payload is obsolete
as mac80211 will align the payload when it passes the frame to the
net stack.

As a result we can remove the call to rt2x00queue_align_payload in the
rx path and since that's the last user we can remove
rt2x00queue_align_payload altogether.

One advantage is that we save some alignment operations for frames
that don't need to be aligned (for example beause they are not passed
to the net stack).

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
f78987cf8bb740b7a3636c08e003f1976f860cfc 28-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Calculate tx status fifo size instead of hardcoding it

Instead of hardcoding the tx status fifo size as 512 calculate it based
on the number of tx queues and the number of entries per queue. Also
round the size up to a power of 2 as kfifo would otherwise round it
down.

On rt2800pci this will increase the kfifo size from 512 bytes to 1024
bytes which is then able to hold the tx status for all entries in all
tx queues.

Furthermore, if the number of tx queues or tx entries changes in the
future (use of the MGMT queue for example) the kfifo size doesn't need
to be updated.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
37f4ee0b6b39640828dac5937a482c20e8ac794f 04-Apr-2011 Stanislaw Gruszka <sgruszka@redhat.com> rt2x00: fix cancelling uninitialized work

{rx,tx}done_work's are only initialized for usb devices.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: stable@kernel.org
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
0439f5367c8d8bb2ebaca8d7329f51f3148b2fb2 30-Jan-2011 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Move TX/RX work into dedicated workqueue

The TX/RX work structures must be able to run independently
of other workqueues. This is because mac80211 might use
the flush() callback function from various context, which depends
on the TX/RX work to complete while the main thread is blocked
(until the the TX queues are empty).

This should reduce the number of 'Queue %d failed to flush' warnings.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
e1f4e808bb7a884d6563553c2c94cbdd901a16c7 30-Jan-2011 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Kill all tasklets during device removal

During device removal all pending work and tasklets must
be guaranteed to be halted. So far only the txstatus_tasklet
was killed.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
c8e15a1e2c93880160f31ed2e6b02c1322f7f48d 30-Jan-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Disable txstatus tasklet by default

Enable the txstatus tasklet when interrupts are enabled and disable it
together with the interrupts. Also make the txstatus tasklet useful even
without the tx status FIFO and make use of the generic rt2x00 tasklet
initialization macro.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
c5c65761839e3d85cc620cc1c85db8d4a7173f53 30-Jan-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Introduce tasklets for interrupt handling

No functional changes, just preparation for moving interrupt handling to
tasklets. The tasklets are disabled by default. Drivers making use of
them need to enable the tasklets when the device state is set to IRQ_ON.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
8d59c4e993427df37fb8bfc3470c298194a68e7a 30-Jan-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Make periodic beacon updates for PCI devices atomic

Allow the beacondone and pretbtt functions to update the beacon from
atomic context by using the beacon update functions with caller locking.

This is a preparation for moving the periodic beacon handling into
tasklets that require atomic context.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
69cf36a4523be026bc16743c5c989c5e82edb7d9 30-Jan-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Refactor beacon code to make use of start- and stop_queue

This patch allows to dynamically remove beaconing interfaces without
shutting beaconing down on all interfaces.

The only place to start and stop beaconing are now the start- and
stop_queue callbacks. Hence, we can remove some register writes during
interface bring up (config_intf) and only write the correct sync mode
to the register there.

When multiple beaconing interfaces are present we should enable
beaconing as soon as mac80211 enables beaconing on at least one of
them. The beacon queue gets stopped when the last beaconing
interface was stopped by mac80211. Therefore, introduce another
interface counter to keep track ot the number of enabled beaconing
interfaces and start or stop the beacon queue accordingly.

To allow single interfaces to stop beaconing, add a new driver
callback clear_beacon to clear a single interface's beacon without
affecting the other interfaces. Don't overload the clear_entry callback
for clearing beacons as that would introduce additional overhead
(check for each TX queue) into the clear_entry callback which is used
on the drivers TX/RX hotpaths.

Furthermore, the write beacon callback doesn't need to enable beaconing
anymore but since beaconing should be disabled while a new beacon is
written or cleared we still disable beacon generation and enable it
afterwards again in the driver specific callbacks. However, beacon
related interrupts should not be disabled/enabled here, that's solely
done from the start- and stop queue callbacks. It would be nice to stop
the beacon queue just before the beacon update and enable it afterwards
in rt2x00queue itself instead of the current implementation that relies
on the driver doing the right thing. However, since start- and
stop_queue are mutex protected we cannot use them for atomic beacon
updates.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
59eb21a6504731fc16db4cf9463065dd61093e08 17-Jan-2011 Bruno Randolf <br1@einfach.org> cfg80211: Extend channel to frequency mapping for 802.11j

Extend channel to frequency mapping for 802.11j Japan 4.9GHz band, according to
IEEE802.11 section 17.3.8.3.2 and Annex J. Because there are now overlapping
channel numbers in the 2GHz and 5GHz band we can't map from channel to
frequency without knowing the band. This is no problem as in most contexts we
know the band. In places where we don't know the band (and WEXT compatibility)
we assume the 2GHz band for channels below 14.

This patch does not implement all channel to frequency mappings defined in
802.11, it's just an extension for 802.11j 20MHz channels. 5MHz and 10MHz
channels as well as 802.11y channels have been omitted.

The following drivers have been updated to reflect the API changes:
iwl-3945, iwl-agn, iwmc3200wifi, libertas, mwl8k, rt2x00, wl1251, wl12xx.
The drivers have been compile-tested only.

Signed-off-by: Bruno Randolf <br1@einfach.org>
Signed-off-by: Brian Prodoehl <bprodoehl@gmail.com>
Acked-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
bfe6a15d60671993eb3d4ac396b1f442ae08581c 27-Dec-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Simplify intf->delayed_flags locking

Instead of protecting delayed_flags with a spinlock use atomic bitops to
make the code more readable.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
5235189c8edddf2eb32982f814bc858b55e6350a 27-Dec-2010 Johannes Stezenbach <js@sig21.net> rt2x00: allow txstatus_fifo w/o txstatus_tasklet

When DRIVER_REQUIRE_TXSTATUS_FIFO is set, intialize the
txstatus_fifo, but initialize rt2x00dev->txstatus_tasklet
only when both DRIVER_REQUIRE_TXSTATUS_FIFO and
rt2x00dev->ops->lib->txstatus_tasklet are set.

This allows the txstatus_fifo to be used by rt2800usb which
does not use txstatus_tasklet.

Signed-off-by: Johannes Stezenbach <js@sig21.net>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
dba5dc1ae9764902f46d5225c9ff40e4f7b614c7 13-Dec-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Introduce extra queue entry sanity flag

Add a queue entry flag ENTRY_DATA_STATUS_PENDING,
which can be used to indicate a queue entry has
returned from the hardware and is waiting for
status processing. Using this flag we can add
some extra sanity checks to prevent queue corruption.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
64e7d72384c2ecef5a892b2243623af265dd83cc 13-Dec-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Cleanup RX index counting

Add the rt2x00_dmastart function to rt2x00lib which
marks the queue_entry as "owned by device", and increased
the Q_INDEX number.

This cleanups up the index handling by rt2x00lib which
at until so far used hackish approaches to keep the
RX queue index numbering sane.

The rt2x00pci.c changes are from Helmut Schaa

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
5be65609fec2e331c7d804471be3d59089a30d98 13-Dec-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Add "flush" queue command

Add a new command to the queue handlers: "flush",
this moves the flush() callback from mac80211
into rt2x00queue and adds support for flushing
the RX queue as well.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
0b7fde54f94979edc67bbf86b5adba702ebfefe8 13-Dec-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Protect queue control with mutex

Add wrapper functions in rt2x00queue.c to
start & stop queues. This control must be protected
using a mutex.

Queues can also be paused which will halt the flow
of packets between the driver and mac80211. This doesn't
require a mutex protection.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
dbba306f2ae574450a7a5133d6637fe6f5fafc72 13-Dec-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Reorganize queue callback functions

As part of the queue refactoring, change the queue callback
function names to have 3 different actions: start, kick & stop.

We can now also remove the STATE_RADIO_RX_ON/STATE_RADIO_RX_OFF
device_state flags, and replace the usage with using the
start_queue/stop_queue callback functions.
This streamlines the RX queue handling to the
similar approach as all other queues.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
20ed3166c84d145589a89d8cde12aa32cf2d17f4 30-Nov-2010 Johannes Stezenbach <js@sig21.net> mac80211/rt2x00: add ieee80211_tx_status_ni()

All rt2x00 drivers except rt2800pci call ieee80211_tx_status() from
a workqueue, which causes "NOHZ: local_softirq_pending 08" messages.

To fix it, add ieee80211_tx_status_ni() similar to ieee80211_rx_ni()
which can be called from process context, and call it from
rt2x00lib_txdone(). For the rt2800pci special case a driver
flag is introduced.

Signed-off-by: Johannes Stezenbach <js@sig21.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
f8eaec659f8a7a4e0086fca7c5d5c5e0fbc76d1a 13-Nov-2010 RA-Jay Hung <Jay_Hung@ralinktech.com> rt2x00: Fix header_length in rt2x00lib_txdone

Put the assignment of header_length after pull out extra tx headroom

Signed-off-by: RA-Jay Hung <jay_hung@ralinktech.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
ea175ee26268370ca07aff91cf6ba1e0f1a3bd36 06-Nov-2010 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Remove rt2x00lib_toggle_rx

As part of the queue refactoring, the rt2x00lib_toggle_rx
can be removed and replaced with the call directly to
the set_device_state callback function.

We can remove the STATE_RADIO_RX_ON_LINK and
STATE_RADIO_RX_OFF_LINK, as it was only used for
special behavior inside rt2x00lib rather then the
drivers.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
c2361baec100c6f373107346e3fd98e9b267ac6c 06-Nov-2010 Mark Einon <mark.einon@gmail.com> rt2x00: checkpatch.pl error fixes for rt2x00dev.c

rt2x00dev.c:689: ERROR: spaces required around that '=' (ctx:WxV)

Signed-off-by: Mark Einon <mark.einon@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
070192dd2975c0e97bbdeac7623b755235c6db7d 04-Nov-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix crash on USB unplug

By not scheduling the TX/RX completion worker threads
when Radio is disabled, or hardware has been unplugged,
the queues cannot be completely cleaned.

This causes crashes when the hardware has been unplugged while
the radio is still enabled.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
a13c8f3133b250e732c383b1c390d625e755db03 11-Oct-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix URB error handling

kill_urb guarentees that when the function returns, the URB has
been fully killed. This means we don't need the extra sleeping
after the call to kill_urb.

kill_urb can however also guarentee the submit_urb to fail, as
a result, we must catch the return value from submit_urb an
correctly mark the entry as owned by the driver, and the
status as broken.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
1550c8ef835af17df322045e92541561afa0f017 11-Oct-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix dead queue when skb allocation failed

When the RX skb allocation failed, we should recycle
the previously allocated skbuffer. By calling return
we would kill the RX queue completely since the
entry would be invalidated.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
3590eea41815679e268c90d30795a13a732b8413 11-Oct-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Validate MCS on RX path

Similar to the PLCP signal and bitrates values,
we should validate the MCS value from the RX descriptor
before sending it to mac80211.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
fa69560f317d961c56e29dea788b346d2b34fb87 11-Oct-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Simplify Queue function arguments

A lot of functions accept a struct rt2x00_dev combined with
either a struct queue_entry or struct data_queue argument.
This can be simplified by only passing on the queue/entry
argument.

In cases where rt2x00_dev and a sk_buff are send together,
we can send the queue_entry instead.

rt2x00usb_alloc_urb and rt2x00usb_free_urb have a bit
of vague naming. Instead they allocate all the data which
belongs to a rt2x00 data queue entry.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
1f0280cb35ae252d6db3ce8f56b7a1dc174460e5 02-Oct-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Fix oops caused by error path in rt2x00lib_start

When rt2x00lib_enable_radio fails to enable the radio, rt2x00lib_start
will call rt2x00queue_uninitialize to uninitialize the queues. Since,
the queues are not initialized here but already in rt2x00lib_initialize
we shouldn't uninitialize the queues here. Otherwise, a consecutive call
to rt2x00lib_start will oops (see below) because it assumes the queues
are already initialized.

BUG: unable to handle kernel NULL pointer dereference at 00000010
IP: [<f8d2d901>] :rt2800pci:rt2800pci_clear_entry+0x1/0x40
*pde = 00000000
Oops: 0000 [#1] SMP
Modules linked in: ... rt2800pci ...

Pid: 5995, comm: hostapd Not tainted (2.6.27.8 #1)
EIP: 0060:[<f8d2d901>] EFLAGS: 00210246 CPU: 3
EIP is at rt2800pci_clear_entry+0x1/0x40 [rt2800pci]
EAX: 00000000 EBX: f698863c ECX: 00200296 EDX: f8d2dee0
ESI: f6988600 EDI: f5b6f000 EBP: 00000000 ESP: f6d75e4c
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process hostapd (pid: 5995, ti=f6d74000 task=f6ce2300 task.ti=f6d74000)
Stack: f698863c fa00eaec 00000000 f5b6f000 00000000 f7b67000 f5b6e280 fa00c629
f5b6f000 00000000 fa00ca3d f7b67480 00000001 fa177d4c 01b6e890 f7b67000
00000000 f7b67000 00000001 00001003 00001002 c066c366 f7b67000 c0668ad0
Call Trace:
[<fa00eaec>] rt2x00queue_init_queues+0x5c/0x90 [rt2x00lib]
[<fa00c629>] rt2x00lib_enable_radio+0x29/0xa0 [rt2x00lib]
[<fa00ca3d>] rt2x00lib_start+0x5d/0xd0 [rt2x00lib]
[<fa177d4c>] ieee80211_do_open+0x21c/0x510 [mac80211]
[<c066c366>] dev_open+0x56/0xb0
[<c0668ad0>] dev_set_rx_mode+0x20/0x40
[<c066a67f>] dev_change_flags+0x7f/0x190
[<c06b1495>] devinet_ioctl+0x515/0x690
[<c0668d24>] __dev_get_by_name+0x74/0x90
[<c065d3f0>] sock_ioctl+0xd0/0x240
[<c065d320>] sock_ioctl+0x0/0x240
[<c018179b>] vfs_ioctl+0x2b/0x90
[<c0181a5b>] do_vfs_ioctl+0x25b/0x2a0
[<c0181af6>] sys_ioctl+0x56/0x70
[<c0103262>] syscall_call+0x7/0xb
[<c0700000>] add_card+0xad0/0xba0
=======================
Code: 83 78 08 0e 74 14 8b 02 8b 48 04 85 c9 0f 99 c0 0f b6 c0 c3 8d b6
00 00 00 00 8b 02 8b 40 04 85 c0 0f 99 c0 0f b6 c0 c3 66 90 53 <8b>
48 10 8b 58 08 8b 40 04 83 78 08 0e 74 15 8b 11 83 c2 04 8b
EIP: [<f8d2d901>] rt2800pci_clear_entry+0x1/0x40 [rt2800pci] SS:ESP 0068:f6d75e4c
---[ end trace cff9a5c094bb8837 ]---

Reported-by: Joshua Smith <jesmith@kaon.com>
Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
96c3da7d7d7c37ee308ad6813947f48a71cca573 02-Oct-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: rework tx status handling in rt2800pci

This patch changes the way tx status reports are handled by rt2800pci.
Previously rt2800pci would sometimes lose tx status reports as the
TX_STA_FIFO register is a fifo of 16 entries that can overflow in case
we don't read it often/fast enough. Since interrupts are disabled in the
device during the execution of the interrupt thread it happend sometimes
under high network and CPU load that processing took too long and a few
tx status reports were dropped by the hw.

To fix this issue the TX_STA_FIFO register is read directly in the
interrupt handler and stored in a kfifo which is large enough to hold
all status reports of all used tx queues.

To process the status reports a new tasklet txstatus_tasklet is used.
Using the already used interrupt thread is not possible since we don't
want to disable the TX_FIFO_STATUS interrupt while processing them and
it is not possible to schedule the interrupt thread multiple times for
execution. A tasklet instead can be scheduled multiple times which
allows to leave the TX_FIFO_STATUS interrupt enabled while a previously
scheduled tasklet is still executing.

In short: All other interrupts are handled in the interrupt thread as
before. Only the TX_FIFO_STATUS interrupt is partly handled in the
interrupt handler and finished in the according tasklet.

One drawback of this patch is that it duplicates some code from
rt2800lib. However, that can be cleaned up in the future once the
rt2800usb and rt2800pci tx status handling converge more.

Using this patch on a Ralink RT3052 embedded board gives me a reliable
wireless connection even under high CPU and network load. I've
transferred several gigabytes without any queue lockups.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
652a9dd2a0c07251e328519cc23f1316ab13ed51 30-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Split watchdog check into a DMA and STATUS timeout

The watchdog for rt2800usb triggers frequently causing all URB's
to be canceled often enough to interrupt the normal TX flow.
More research indicated that not the URB upload to the USB host
were hanging, but instead the TX status reports.

To correctly detect what is going on, we introduce Q_INDEX_DMA_DONE
which is an index counter between Q_INDEX_DONE and Q_INDEX and indicates
if the frame has been transfered to the device.

This also requires the rt2x00queue timeout functions to be updated
to differentiate between a DMA timeout (time between Q_INDEX and
Q_INDEX_DMA_DONE timeout) and a STATUS timeout (time between
Q_INDEX_DMA_DONE and Q_INDEX_DONE timeout)

All Q_INDEX_DMA_DONE code was taken from the RFC from
Helmut Schaa <helmut.schaa@googlemail.com> for the implementation
for watchdog for rt2800pci.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
8d1331b37d5b656a7a8e561f8e9d7661dd00c910 23-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix max TX power settings

During initialization each driver reads the default TX power
for each individual channel. However mac80211 only accepts the
maximum value (which is also handled as default value).

As a result, the TX power of the device was being limited to
the default value, which is often quite low compared to the
real maximum acceptable value.

This patch allows each driver to set the maximum value on a
per-channel basis which is forwarded to mac80211. The default
value will be preserved for now, in case we want to update
mac80211 to differentiate between the maximum and default txpower.

This fixes bug complaining about limited TX power values like:
https://bugzilla.kernel.org/show_bug.cgi?id=16358

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
e5ef5bad345f97f1fef7ccdc01a88c298629a5d9 06-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove ieee80211_rx_status from rt2x00_dev

rt2x00 was keeping a copy of ieee80211_rx_status embedded
into the rt2x00_dev structure. For each RX frame, this structure
was copied into the skb->cb where mac80211 would handle it further.

However at the moment only the fields current band, and frequency
were updated. Whereas the band was already provided directly within
the rt2x00_dev structure. Save a memcpy action, and reduce memory
a bit, by adding a curr_freq field to rt2x00_dev, and completely
remove the ieee80211_rx_status structure from rt2x00_dev.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
3392beced38f67615b7fc88374940cecec6a0e4f 06-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Add helper function for reporting tx status

At some points, some drivers can't report the full TX status
information. This can happen for the UNKNOWN state, or the
FAILURE state (in case the URB failed).
Add a wrapper function to simplify reporting the
empty TX information.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
7e613e1666d59b5364f7918b3427bf328ac5f9ca 06-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Move USB tx/rx done handling to workqueue

Move all TX and RX completion handling into a work structure,
which is handeled on the mac80211 workqueue. This simplifies
the code in rt2x00lib since it no longer needs to check if the
device is USB or PCI to decide which mac80211 function should be used.

In the watchdog some changes are needed since it can no longer rely
on the TX completion function to be run while looping through the
entries. (Both functions now work on the same workqueue, so this
would deadlock). So the watchdog now waits for the URB to return,
and handle the TX status report directly.

As a side-effect, the debugfs entry for the RX queue now correctly
displays the positions of the INDEX and INDEX_DONE counters. This
also implies that it is not possible to perform checks like queue_empty()
and queue_full() on the RX queue.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
11fe883936980fe242869d671092a466cf1db3e3 21-Jul-2010 David S. Miller <davem@davemloft.net> Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6

Conflicts:
drivers/vhost/net.c
net/bridge/br_device.c

Fix merge conflict in drivers/vhost/net.c with guidance from
Stephen Rothwell.

Revert the effects of net-2.6 commit 573201f36fd9c7c6d5218cdcd9948cee700b277d
since net-next-2.6 has fixes that make bridge netpoll work properly thus
we don't need it disabled.

Signed-off-by: David S. Miller <davem@davemloft.net>
9acd56d3f2a05191ee369cbdd8c37dd547aa19b8 16-Jul-2010 Stephen Boyd <bebarino@gmail.com> rt2x00: Fix lockdep warning in rt2x00lib_probe_dev()

The rt2x00dev->intf_work workqueue is never initialized when a driver is
probed for a non-existent device (in this case rt2500usb). On such a
path we call rt2x00lib_remove_dev() to free any resources initialized
during the probe before we use INIT_WORK to initialize the workqueue.
This causes lockdep to get confused since the lock used in the workqueue
hasn't been initialized yet but is now being acquired during
cancel_work_sync() called by rt2x00lib_remove_dev().

Fix this by initializing the workqueue first before we attempt to probe
the device. This should make lockdep happy and avoid breaking any
assumptions about how the library cleans up after a probe fails.

phy0 -> rt2x00lib_probe_dev: Error - Failed to allocate device.
INFO: trying to register non-static key.
the code is fine but needs lockdep annotation.
turning off the locking correctness validator.
Pid: 2027, comm: modprobe Not tainted 2.6.35-rc5+ #60
Call Trace:
[<ffffffff8105fe59>] register_lock_class+0x152/0x31f
[<ffffffff81344a00>] ? usb_control_msg+0xd5/0x111
[<ffffffff81061bde>] __lock_acquire+0xce/0xcf4
[<ffffffff8105f6fd>] ? trace_hardirqs_off+0xd/0xf
[<ffffffff81492aef>] ? _raw_spin_unlock_irqrestore+0x33/0x41
[<ffffffff810628d5>] lock_acquire+0xd1/0xf7
[<ffffffff8104f037>] ? __cancel_work_timer+0x99/0x17e
[<ffffffff8104f06e>] __cancel_work_timer+0xd0/0x17e
[<ffffffff8104f037>] ? __cancel_work_timer+0x99/0x17e
[<ffffffff8104f136>] cancel_work_sync+0xb/0xd
[<ffffffffa0096675>] rt2x00lib_remove_dev+0x25/0xb0 [rt2x00lib]
[<ffffffffa0096bf7>] rt2x00lib_probe_dev+0x380/0x3ed [rt2x00lib]
[<ffffffff811d78a7>] ? __raw_spin_lock_init+0x31/0x52
[<ffffffffa00bbd2c>] ? T.676+0xe/0x10 [rt2x00usb]
[<ffffffffa00bbe4f>] rt2x00usb_probe+0x121/0x15e [rt2x00usb]
[<ffffffff813468bd>] usb_probe_interface+0x151/0x19e
[<ffffffff812ea08e>] driver_probe_device+0xa7/0x136
[<ffffffff812ea167>] __driver_attach+0x4a/0x66
[<ffffffff812ea11d>] ? __driver_attach+0x0/0x66
[<ffffffff812e96ca>] bus_for_each_dev+0x54/0x89
[<ffffffff812e9efd>] driver_attach+0x19/0x1b
[<ffffffff812e9b64>] bus_add_driver+0xb4/0x204
[<ffffffff812ea41b>] driver_register+0x98/0x109
[<ffffffff813465dd>] usb_register_driver+0xb2/0x173
[<ffffffffa00ca000>] ? rt2500usb_init+0x0/0x20 [rt2500usb]
[<ffffffffa00ca01e>] rt2500usb_init+0x1e/0x20 [rt2500usb]
[<ffffffff81000203>] do_one_initcall+0x6d/0x17a
[<ffffffff8106cae8>] sys_init_module+0x9c/0x1e0
[<ffffffff8100296b>] system_call_fastpath+0x16/0x1b

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
9f926fb57a2eb14d58ea6d6699544f9ccd0df8c7 11-Jul-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Use pretbtt irq for fetching beacons on rt2800pci

Updating the beacon on pre tbtt instead of beacondone allows much lower
latency in regard to TIM updates. Hence, use the pre tbtt interrupt for
updating the beacon in rt2800pci (older devices don't provide a pre tbtt
interrupt).

Also, add a new driver flag to indicate if a driver has pre tbtt support
or not and implement the according behavior in rt2x00lib.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
07896fe2f4df3802a224a2ee1aad1c7345d2513c 11-Jul-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Implement broad- and multicast buffering

Although mac80211 buffers broad- and mutlicast frames for us in AP mode
we still have to send them out after a DTIM beacon. Implement this
behavior by sending out the buffered frames when the beacondone
interrupt is processed.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
4dee32f51b0beba25a70e8011652858c6e55f792 11-Jul-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Allow beacon update without scheduling a work

Since all rt2x00 PCI drivers use threaded interrupts now we don't need
to schedule a work just to update the beacon. The only place where the
beacon still gets updated in atomic context is from the set_tim
callback. Hence, move the work scheduling there.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
78e256c9a3717bcae2e9ed05c9ec7bed7bf2c55d 11-Jul-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Convert rt2x00 to use threaded interrupts

Use threaded interrupts for all rt2x00 PCI devices.

This has several generic advantages:
- Reduce the time we spend in hard irq context
- Use non-atmic mac80211 functions for rx/tx

Furthermore implementing broad- and multicast buffering will be
much easier in process context while maintaining low latency and
updating the beacon just before transmission (pre tbtt interrupt)
can also be done in process context.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
c965c74bbc650e5466d2f3e32bd28112ebcdd00c 11-Jul-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Implement watchdog monitoring

Implement watchdog monitoring for USB devices (PCI support can
be added later). This will determine if URBs being uploaded to
the hardware are actually returning. Both rt2500usb and rt2800usb
have shown that URBs being uploaded can remain hanging without
being released by the hardware.
By using this watchdog, a queue can be reset when this occurs.
For rt2800usb it has been tested that the connection is preserved
even though this interruption.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
e513a0b6f1bf8e1b59b0e1382d4e7ef3d344d535 29-Jun-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Move common txdone handling to rt2x00lib_txdone.

Now that the write_tx_data functions are merged, also merge the relevant
parts of the txdone handling into common code, rather than {usb,pci}
specific code.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
1df90809f79b765fd4e8868c2b182d948f198a17 29-Jun-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Implement tx mpdu aggregation

In order to implement tx mpdu aggregation we only have to implement
the ampdu_action callback such that mac80211 allows negotiation of
blockack sessions.

The hardware will handle everything on its own as long as the ampdu
flag in the TXWI struct is set up correctly and we translate the tx
status correctly.

For now, refuse requests to start rx aggregation.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
3d2bc1036a64bc015671283833430035f7dbbed0 14-Jun-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Fix tx status reporting when falling back to the lowest rate

In some corner cases the reported tx rates/retries didn't match the really
used ones.

The hardware lowers the tx rate on each consecutive retry by 1 (but won't
fall back from MCS to legacy rates) _until_ it reaches the lowest one.

In case the frame wasn't sent succesful the number of retries is 7 and if
a rate index <7 was used the previous code reported negative rate indexes
which were then ignored by the rate control algorithm and mac80211.

Instead, report the remaining number of retries to have happened with
the lowest rate (index 0). This should give the rate control algorithm
slightly more accurate information about the used tx rates/retries.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
fd6dcb883a0e34de90c64a9352c5225066ee7d72 14-Jun-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: don't use TXDONE_FALLBACK as success indicator

TXDONE_FALLBACK doesn't express if the frame was sent successful or not. It
only tells us that the hw used fallback rates for retries. Hence, don't use
TXDONE_FALLBACK as success indicator.

Before this patch we reported success to the rate control algorithm which
was wrong in a number of cases and might have lead to improper tx rate
selections.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
0b8004aa12d13ec750d102ba4082a95f0107c649 03-Jun-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Properly reserve room for descriptors in skbs.

Instead of fiddling with the skb->data pointer and thereby risking
out of bounds accesses, properly reserve the space needed in an
skb for descriptors.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
77c2061d10a408d0220c2b0e7faefe52d9c41008 18-May-2010 Walter Goldens <goldenstranger@yahoo.com> wireless: fix several minor description typos

Signed-off-by: Walter Goldens <goldenstranger@yahoo.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
83163244f845c296a118ce85c653872dbff6abfe 05-May-2010 John W. Linville <linville@tuxdriver.com> Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6 into for-davem

Conflicts:
drivers/net/wireless/libertas_tf/cmd.c
drivers/net/wireless/libertas_tf/main.c
6ca4fed3d4ec9887208ea955861fecde4b7a02a1 26-Apr-2010 John W. Linville <linville@tuxdriver.com> rt2x00: remove usage of deprecated noise value

Signed-off-by: John W. Linville <linville@tuxdriver.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
5a0e3ad6af8660be21ca98a971cd00f331318c05 24-Mar-2010 Tejun Heo <tj@kernel.org> include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
318ae2edc3b29216abd8a2510f3f80b764f06858 08-Mar-2010 Jiri Kosina <jkosina@suse.cz> Merge branch 'for-next' into for-linus

Conflicts:
Documentation/filesystems/proc.txt
arch/arm/mach-u300/include/mach/debug-macro.S
drivers/net/qlge/qlge_ethtool.c
drivers/net/qlge/qlge_main.c
drivers/net/typhoon.c
3ad2f3fbb961429d2aa627465ae4829758bc7e07 03-Feb-2010 Daniel Mack <daniel@caiaq.de> tree-wide: Assorted spelling fixes

In particular, several occurances of funny versions of 'success',
'unknown', 'therefore', 'acknowledge', 'argument', 'achieve', 'address',
'beginning', 'desirable', 'separate' and 'necessary' are fixed.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Joe Perches <joe@perches.com>
Cc: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
/drivers/net/wireless/rt2x00/rt2x00dev.c
4f9b2a7dea2bf1dd81f280aa5e8a40ed910d2f0a 05-Jan-2010 John W. Linville <linville@tuxdriver.com> Merge git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6

Conflicts:
net/mac80211/iface.c
7a4a77b7771164d61ce702a588067d1e1d66db7c 30-Dec-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Properly request tx headroom for alignment operations.

Current rt2x00 drivers may result in a "ieee80211_tx_status: headroom too
small" error message when a frame needs to be properly aligned before
transmitting it.
This is because the space needed to ensure proper alignment isn't
requested from mac80211.
Fix this by adding sufficient amount of alignment space to the amount
of headroom requested for TX frames.

Reported-by: David Ellingsworth <david@identd.dyndns.org>
Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <ivdoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
b734083349d1f1aab1edc810cef02e8046251b48 04-Dec-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Only remove L2 padding in received frames if there is payload.

L2 padding will only be present when there is actual payload present.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <ivdoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
1398d4580eff2656f3a808ec24744ce5a842db35 04-Dec-2009 Alban Browaeys <prahal@yahoo.com> rt2x00 : trim the skb after having the l2pad removed.

Otherwise we end up truncating the skb before removing the l2pad
thus we might have the truncated part become garbage while getting
it back in remove_l2pad.
For the same issue: remove the skb_trim from the rt2800 fill_rxdone
(it is done after l2pad removal in rt2x00lib_rxdone).

Signed-off-by: Alban Browaeys <prahal@yahoo.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <ivdoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
e6218cc47bd54710dc523e8c983ceddba625e3ae 23-Nov-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Centralize setting of extra TX headroom requested by rt2x00.

Set the value of extra_tx_headroom in a central place, rather than in each
of the drivers. This is preparatory for taking alignment space into account
in the TX headroom requested by rt2x00.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
7351c6bd482712e5e3ec9dffc547de0e0863efb0 19-Nov-2009 Johannes Berg <johannes@sipsolutions.net> mac80211: request TX status where needed

Right now all frames mac80211 hands to the driver
have the IEEE80211_TX_CTL_REQ_TX_STATUS flag set to
request TX status. This isn't really necessary, only
the injected frames need TX status (the latter for
hostapd) so move setting this flag.

The rate control algorithms also need TX status, but
they don't require it.

Also, rt2x00 uses that bit for its own purposes and
seems to require it being set for all frames, but
that can be fixed in rt2x00.

This doesn't really change anything for any drivers
but in the future drivers using hw-rate control may
opt to not report TX status for frames that don't
have the IEEE80211_TX_CTL_REQ_TX_STATUS flag set.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com> [rt2x00 bits]
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
9c9a0d145fee73b5e821bb460732ac2a66c680b3 08-Nov-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Update copyright statements.

As mentioned on the linux-wireless mailing list, the current copyright
statements in the rt2x00 are meaningless, as the rt2x00 project is
not even a formal legal entity. Therefore it is better to replace
the existing copyright statements with copyright statements for the
people that actually wrote the code.

Note: Updated to the best of my knowledge with respect to who
contributed considerable amounts of code.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
CC: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
863cc978a73bc07f1de0e9a9bd9889bed6e618da 08-Nov-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove deprecated ieee80211_rx_status->qual usage

ieee80211_rx_status->qual has been marked deprecated.
This allows us to remove several functions and fields which
were used to calculate a reasonable value for it.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
66f84d6594729c866c0c03fe97159a987dad7d84 05-Nov-2009 Sean Cross <sean@chumby.com> rt2x00: Don't queue ieee80211 work after USB removal

This prevents the rt2x00 driver from queueing ieee80211 work after the  
USB card has been removed, preventing a kernel panic.

Signed-off-by: Sean Cross <sean@chumby.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
daee6c092aa49ea090612738253ef0d11d120344 29-Aug-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Reorganize padding & L2 padding

The old function rt2x00queue_payload_align() handled
both adding and removing L2 padding and some basic
frame alignment. The entire function was being abused
because it had multiple functions and the header length
argument was somtimes used to align the header instead
of the payload.

Additionally there was a bug when inserting L2 padding
that only the payload was aligned but not the header. This
happens when the header wasn't aligned properly by mac80211,
but rt2x00lib only moves the payload.

A secondary problem was that when removing L2 padding during
TXdone or RX the skb wasn't resized to the proper size.

Split the function into seperate functions each handling
its task as it should.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
2e27cff871dec9371e41022aaaebb3452ec069c0 29-Aug-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix TX status reporting

Not all values of the TX status enumeration were
covered during updating of the TX statistics. This
could lead to wrong bitrate tuning but also wrong
behavior in tools like hostapd.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
d904dc17495581254442b7fd054e267f2605c8ec 18-Aug-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: bss_info_changed() callback is allowed to sleep

The bss_info_changed() callback function no longer needs
to be atomic. Remove the scheduled work structure and
call into the driver directly.

Additionaly this makes the DRIVER_REQUIRE_SCHEDULED
flag redundant so it can be removed.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
afa620429ac6a636246f85d97cf205d6533e7fcb 18-Aug-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: configure_filter() callback is allowed to sleep

The configure_filter() callback function no longer needs
to be atomic. Remove the scheduled work structure and
call into the driver configure_filter() directly.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
92ed48e5230e8f5906dda0cc31715b3b7e3fe303 17-Aug-2009 Benoit PAPILLAULT <benoit.papillault@free.fr> rt2x00: Add support for retry rates

rt2800pci can handle different retry rates,
it will always step 1 rate down after a failed
transmission so creating the retry rate list
for mac80211 is quite simple.

Signed-off-by: Benoit PAPILLAULT <benoit.papillault@free.fr>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
17512dc3b7fc9ff1a60d3748ce87c323df507c3d 08-Aug-2009 Igor Perminov <igor.perminov@inbox.ru> rt2x00: Fix for race condition while update beacon

The patch "Implement set_tim callback for all drivers" can cause kernel
oops in rt73usb_write_beacon. The oops is caused by one of the following
race conditions:
* In case of two near calls to set_tim: rt2x00lib_beacondone_iter is
cleaning the beacon skb, whereas rt73usb_write_beacon is still using it.
* In case of two near updates of beacon: first as the result of set_tim
and second as the result of a call from an application (e.g. hostapd).
This patch fixes the race condition by rearranging the update logic and
guarding rt2x00_intf->beacon->skb with a mutex.

Signed-off-by: Igor Perminov <igor.perminov@inbox.ru>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
bdfa500b8b8ca87dfe7a311f569fe8b39746c299 08-Aug-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove usage of deprecated radio_enabled & IEEE80211_CONF_CHANGE_RADIO_ENABLED

In the config() callback function the fields radio_enabled and
the change flag IEEE80211_CONF_CHANGE_RADIO_ENABLED have been
deprecated. This removes the usage of those fields by improving
antenna change detection in the antenna configuration function.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
d8cc8926e9b4dc2ce513ee3325bf16b4ea6d94e8 02-Aug-2009 Pavel Roskin <proski@gnu.org> rt2x00: cancel all work on disconnect

Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
42935ecaf4e784d0815afa9a7e5fe7e141157ca3 30-Jul-2009 Luis R. Rodriguez <lrodriguez@atheros.com> mac80211: redefine usage of the mac80211 workqueue

The mac80211 workqueue exists to enable mac80211 and drivers
to queue their own work on a single threaded workqueue. mac80211
takes care to flush the workqueue during suspend but we never
really had requirements on drivers for how they should use
the workqueue in consideration for suspend.

We extend mac80211 to document how the mac80211 workqueue should
be used, how it should not be used and finally move raw access to
the workqueue to mac80211 only. Drivers and mac80211 use helpers
to queue work onto the mac80211 workqueue:

* ieee80211_queue_work()
* ieee80211_queue_delayed_work()

These helpers will now warn if mac80211 already completed its
suspend cycle and someone is trying to queue work. mac80211
flushes the mac80211 workqueue prior to suspend a few times,
but we haven't taken the care to ensure drivers won't add more
work after suspend. To help with this we add a warning when
someone tries to add work and mac80211 already completed the
suspend cycle.

Drivers should ensure they cancel any work or delayed work
in the mac80211 stop() callback.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
4b9631a4734e25e37c83e72c3e0ffcbb08de5791 11-Jul-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove DEVICE_STATE_DISABLED_RADIO_HW

The DEVICE_STATE_DISABLED_RADIO_HW flag is only read but never set,
it is an ancient part of one of the many versions of the rfkill implementations
in rt2x00. It is about time is disappears.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
e47a5cddf893815e7da16e3226b959af785d8aaf 01-Jul-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: use wiphy rfkill interface

Remove the input_polldev from rt2x00 and replace it with
the rfkill interface offered by the wiphy structure. This
simplifies the entire rfkill handling in rt2x00 and allows
us to remove the CONFIG_RT2X00_LIB_RFKILL option and always
enables rfkill capabilities.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
f1d58c2521eb160178b2151d6326d8dc5d7c8560 17-Jun-2009 Johannes Berg <johannes@sipsolutions.net> mac80211: push rx status into skb->cb

Within mac80211, we often need to copy the rx status into
skb->cb. This is wasteful, as drivers could be building it
in there to start with. This patch changes the API so that
drivers are expected to pass the RX status in skb->cb, now
accessible as IEEE80211_SKB_RXCB(skb). It also updates all
drivers to pass the rx status in there, but only by making
them memcpy() it into place before the call to the receive
function (ieee80211_rx(_irqsafe)). Each driver can now be
optimised on its own schedule.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
ce4c45e099a81b2bc820b6e145aa9058c5acf0bd 19-May-2009 Alexandre Becholey <alexandre.becholey@epfl.ch> rt73usb: fix for master mode

Report status unknown as if there were successfully transmitted.
This will avoid hostapd to disassociate because it doesn't understand what a status unknown is.

Signed-off-by: Alexandre Becholey <alexandre.becholey@epfl.ch>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
35f00cfcc06bb85e0659f9847400518008d78145 26-Apr-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Implement support for 802.11n

Extend rt2x00lib capabilities to support 802.11n,
it still lacks aggregation support, but that can
be added in the future.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
9f1661718c7fcf82e25c6aed20b729ee372d9d65 26-Apr-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Add support for L2 padding during TX/RX

Some hardware require L2 padding between header and payload
because both must be aligned to a 4-byte boundary. This hardware
also is easier during the RX path since we no longer need to
move the entire payload but rather only the header to remove
the padding (mac80211 only wants the payload to be 4-byte aligned).

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
f05faa31c387fb07f4c561350f00ba12cf673c9f 10-Apr-2009 Herton Ronaldo Krzesinski <herton@mandriva.com.br> rt2x00: prevent double kfree when failing to register hardware

In a scenario where there isn't any firmware available, we will have a
double kfree of rt2x00dev->spec.channels_info when ieee80211_register_hw
returns an error status inside rt2x00lib_probe_hw.

The problem is that if ieee80211_register_hw fails, we call
rt2x00lib_remove_hw twice:
* first inside rt2x00lib_probe_hw upon failure of ieee80211_register_hw
* error status is returned to rt2x00lib_probe_dev, which then sees it and
calls in this case rt2x00lib_remove_dev that will again run
rt2x00lib_remove_hw

Prevent this avoiding calling rt2x00lib_remove_hw inside
rt2x00lib_probe_hw

Problem was detected with CONFIG_DEBUG_PAGEALLOC=y, CONFIG_SLUB_DEBUG=y,
CONFIG_SLUB_DEBUG_ON=y, that dumps this with no firmware available:

rt61pci 0000:00:07.0: PCI INT A -> GSI 19 (level, low) -> IRQ 19
wmaster0 (rt61pci): not using net_device_ops yet
phy0: Selected rate control algorithm 'pid'
phy0: Failed to initialize wep: -2
phy0 -> rt2x00lib_probe_dev: Error - Failed to initialize hw.
=============================================================================
BUG kmalloc-128: Object already free
-----------------------------------------------------------------------------

INFO: Allocated in rt61pci_probe_hw+0x3e5/0x6e0 [rt61pci] age=340 cpu=0 pid=21
INFO: Freed in rt2x00lib_remove_hw+0x59/0x70 [rt2x00lib] age=0 cpu=0 pid=21
INFO: Slab 0xc13ac3e0 objects=23 used=10 fp=0xdd59f6e0 flags=0x400000c3
INFO: Object 0xdd59f6e0 @offset=1760 fp=0xdd59f790

Bytes b4 0xdd59f6d0: 15 00 00 00 b2 8a fb ff 5a 5a 5a 5a 5a 5a 5a 5a ....².ûÿZZZZZZZZ
Object 0xdd59f6e0: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk
Object 0xdd59f6f0: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk
Object 0xdd59f700: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk
Object 0xdd59f710: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk
Object 0xdd59f720: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk
Object 0xdd59f730: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk
Object 0xdd59f740: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk
Object 0xdd59f750: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5 kkkkkkkkkkkkkkk¥
Redzone 0xdd59f760: bb bb bb bb »»»»
Padding 0xdd59f788: 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ
Pid: 21, comm: stage1 Not tainted 2.6.29.1-desktop-1.1mnb #1
Call Trace:
[<c01abbb3>] print_trailer+0xd3/0x120
[<c01abd37>] object_err+0x37/0x50
[<c01acf57>] __slab_free+0xe7/0x2f0
[<c01ad1de>] kfree+0x7e/0xd0
[<e0e4a239>] ? rt2x00lib_remove_hw+0x59/0x70 [rt2x00lib]
[<e0e4a239>] ? rt2x00lib_remove_hw+0x59/0x70 [rt2x00lib]
[<e0e4a239>] rt2x00lib_remove_hw+0x59/0x70 [rt2x00lib]
[<e0e4acc7>] rt2x00lib_remove_dev+0x37/0x50 [rt2x00lib]
[<e0e4b087>] rt2x00lib_probe_dev+0x1a7/0x3b0 [rt2x00lib]
[<e0eb288f>] rt2x00pci_probe+0xdf/0x1ee [rt2x00pci]
[<c026b9ee>] local_pci_probe+0xe/0x10
[<c026c750>] pci_device_probe+0x60/0x80
[<c02d5c2a>] driver_probe_device+0x9a/0x2e0
[<c02d5ef9>] __driver_attach+0x89/0x90
[<c02d541b>] bus_for_each_dev+0x4b/0x70
[<c026c690>] ? pci_device_remove+0x0/0x40
[<c02d59d9>] driver_attach+0x19/0x20
[<c02d5e70>] ? __driver_attach+0x0/0x90
[<c02d4cef>] bus_add_driver+0x1cf/0x2a0
[<c026c690>] ? pci_device_remove+0x0/0x40
[<c02d60c9>] driver_register+0x69/0x140
[<c026c9b0>] __pci_register_driver+0x40/0x80
[<e0ecc000>] ? rt61pci_init+0x0/0x19 [rt61pci]
[<e0ecc017>] rt61pci_init+0x17/0x19 [rt61pci]
[<c0101116>] do_one_initcall+0x26/0x1c0
[<c01ab90c>] ? slab_pad_check+0x3c/0x120
[<c01ab90c>] ? slab_pad_check+0x3c/0x120
[<c01ac8da>] ? check_object+0xda/0x210
[<c01b0026>] ? percpu_free+0x46/0x50
[<c01ad09e>] ? __slab_free+0x22e/0x2f0
[<c01b0026>] ? percpu_free+0x46/0x50
[<c01b0026>] ? percpu_free+0x46/0x50
[<c01b0026>] ? percpu_free+0x46/0x50
[<c01687ec>] ? stop_machine_destroy+0x3c/0x40
[<c015e515>] ? load_module+0xa5/0x1c50
[<e0ec5000>] ? rt61pci_eepromregister_read+0x0/0x40 [rt61pci]
[<e0eb2000>] ? rt2x00pci_write_tx_data+0x0/0x90 [rt2x00pci]
[<c03ac2fb>] ? mutex_lock+0xb/0x20
[<c03ac2fb>] ? mutex_lock+0xb/0x20
[<c017ad16>] ? tracepoint_update_probe_range+0x76/0xa0
[<c017ad6f>] ? tracepoint_module_notify+0x2f/0x40
[<c03b02ed>] ? notifier_call_chain+0x2d/0x70
[<c014f0ed>] ? __blocking_notifier_call_chain+0x4d/0x60
[<c014f11a>] ? blocking_notifier_call_chain+0x1a/0x20
[<c0160156>] sys_init_module+0x96/0x1d0
[<c019dad6>] ? sys_munmap+0x46/0x60
[<c0105546>] syscall_call+0x7/0xb
FIX kmalloc-128: Object at 0xdd59f6e0 not freed
rt61pci 0000:00:07.0: PCI INT A disabled
rt61pci: probe of 0000:00:07.0 failed with error -2

Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
a2c9b652a12a550d3d8509e9bae43bac396c5076 28-Jan-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Add kill_tx_queue callback function

provide rt2x00lib the possibility to kill a particular TX queue.
This can be useful when disabling the radio, but more importantly
will allow beaconing to be disabled when mac80211 requests this
(during scanning for example)

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
382fe0f2da78db7833c6a7278e33e694e6e2a6f3 28-Jan-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Move intf_work to mac82011 workqueue

ieee80211_iterate_active_interfaces() no longer acquires the
RTNL lock which means the intf_work handler can be safely
used from the mac80211 workqueue again.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
0712612741e1dccf10353c70ebe90ba8cc60d5fb 23-Jan-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Simplify suspend/resume handling

With mac80211 handling all open interfaces during
suspend and resume we can simplify suspend/resume
within rt2x00lib.

The only thing rt2x00 needs to do is free up memory
during suspend and bring back the minimal required
components during resume.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
4e54c711b42c3cc8da8a3fdcde3407b86d67ebcc 17-Jan-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Update copyright year to 2009

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
b30dd5c043eda4b3d23659ef550c16ce4f6ecb47 20-Dec-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Introduce RXDONE_SIGNAL_MASK mask

Improve error message reporting when a frame was received
with unknown rate. Instead of using the boolean check if
the frame is supposed to be a PLCP value or not, we should
add a new mask (RXDONE_SIGNAL_MASK) which returns the type
identification for a signal value (i.e. PLCP). At the moment
we only have 2 different types, but more will arrive when
support for 11n is added.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
2bdb35c7ffb61f4b9d963dd447a2c54add5f02c5 20-Dec-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Allow drivers to pass the noise value during rxdone

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
ce292a640228fded0d2e232216a19cba33e2cd0f 20-Dec-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Implement WDS support

WDS support should be very easy to handle, mac80211 handles
everything for us, so all that is needed is to set the
support flags and handle it in the add_interface() callback.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
a07dbea210e146aedf8929cdabe082b58696260c 20-Dec-2008 Andrey Yurovsky <andrey@cozybit.com> rt2x00: Add mesh support

This adds initial support for Mesh Point mode. For this we tell mac80211 that
we support NL80211_IFTYPE_MESH_POINT. We also need to send beacons. mac80211
will configure our RX filter accordingly.

Signed-off-by: Andrey Yurovsky <andrey@cozybit.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
84e3196ff867c623056eea02c11a45e046490d89 20-Dec-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Move link tuning into seperate file

Move link and antenna tuning into a seperate file named rt2x00link.c,
this makes the interface to the link tuner a lot cleaner.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
3ea96463156123cbfd09ac412012a87fef068830 04-Jan-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix TX short preamble detection

The short preamble mode was not correctly detected during TX,
rt2x00 used the rate->hw_value_short field but mac80211 is not
using this field that way.
Instead the flag IEEE80211_TX_RC_USE_SHORT_PREAMBLE should be
used to determine if the frame should be send out using
short preamble or not.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
74415edb042ef9f3b1291f978763687f35aadbb3 02-Dec-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Add RXDONE_CRYPTO_IV/ICV flags

Drivers should notify rt2x00lib when they provide
the IV/ICV data. This adds some flexibility to drivers
which can't provide all information.
* rt2500usb provides ICV inside the frame
* rt2800pci doesn't provide IV/ICV
* rt2800usb doesn't provide IV/ICV

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
8ff48a8bbe4a1ba29dea2836dfce74660f97c1be 09-Nov-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix race condition when using inderect registers

Indirect registers require multiple calls to the CSR
register in order to access the indirect registers.
This must be protected under a lock to prevent race
conditions which could cause invalid data to
be returned when reading from the indirect register or silent
failures when writing data to the indirect register.

USB drivers where already protected under a mutex,
so rename the mutex and make PCI drivers use the mutex
as well.
This now means that BBP and RF registers are no longer
accessible in interrupt context. That is not a bad
situation since the slow behavior of accessing
those registers means we don't _want_ to access them
in interrupt context either.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
798b7adb4ed3533ab1282f51d16892034cfd8aae 08-Nov-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Cleanup TX/RX entry handling

Merge the callback functions init_txentry() and
init_rxentry(). This makes life in rt2x00lib a
lot simpler and we can cleanup several functions.

rt2x00pci contained "fake" FIELD definitions for
descriptor words. This is not flexible since it
assumes the driver will always have the same field
to indicate if a driver is available or not.
This should be dependent on the driver, and we
should add a callback function for this.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
6d64360ac56cda95243f15738a06f2a123c663e5 02-Nov-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix BUG_ON() with antenna handling

With the new configuration handling, and more specifically
splitting the configuration of the antenna from the normal
configuration steps allowed a BUG_ON() to be triggered
in the driver because the SW_DIVERSITY was send to the
driver. This fixes that by catching the value early in
rt2x00config.c and replacing it with a sensible value.

This also fixes a problem where the antenna is not being
initialized at all when the radio is enabled. Since it
no longer is part of the mac80211 configuration the
only place where rt2x00 configured it was the SW diversity
handler. Obviously this is broken for all non-diversity
hardware and breaks SW diversity due to a broken initialization.

When the radio is enabled the antenna will be configured
once as soon as the config() callback function is called.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
3d8606a680529d41ad8985f36ecf83a7b393ecaf 02-Nov-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove RATE_BASIC flag

mac80211 is in charge of determining the basic rates,
so we are not using the RATE_BASIC flag anymore.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
3514a441265c6788d85e8222dcca10cd66433123 29-Oct-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Improve interface_modes initialization

All operating modes which require beaconing should
depend on the availability of beacon entries from
the hardware.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
c3fd7b41cae2fa213858d6501e6065f24097c0a8 29-Oct-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove ieee80211_bss_conf from rt2x00_intf

We can safely remove ieee80211_bss_conf from rt2x00_intf,
it is provided by mac80211 in ieee80211_vif as well.
(rt2x00_intf is the drv_priv field of ieee80211_vif).

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
e6a9854b05c1a6af1308fe2b8c68f35abf28a3ee 21-Oct-2008 Johannes Berg <johannes@sipsolutions.net> mac80211/drivers: rewrite the rate control API

So after the previous changes we were still unhappy with how
convoluted the API is and decided to make things simpler for
everybody. This completely changes the rate control API, now
taking into account 802.11n with MCS rates and more control,
most drivers don't support that though.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
e8975581f63870be42ff4662b293d1b0c8c21350 09-Oct-2008 Johannes Berg <johannes@sipsolutions.net> mac80211: introduce hw config change flags

This makes mac80211 notify the driver which configuration
actually changed, e.g. channel etc.

No driver changes, this is just plumbing, driver authors are
expected to act on this if they want to.

Also remove the HW CONFIG debug printk, it's incorrect, often
we configure something else.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
0f4ac38b5999c3d51adad52d61c56c1b99c247ec 09-Oct-2008 Johannes Berg <johannes@sipsolutions.net> mac80211: kill hw.conf.antenna_sel_{rx,tx}

Never actually used.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
05c914fe330fa8e1cc67870dc0d3809dfd96c107 11-Sep-2008 Johannes Berg <johannes@sipsolutions.net> mac80211: use nl80211 interface types

There's really no reason for mac80211 to be using its
own interface type defines. Use the nl80211 types and
simplify the configuration code a bit: there's no need
to translate them any more now.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
f59ac0481660e66cec67f1d6b024e78b9dc715fe 30-Aug-2008 Luis R. Rodriguez <lrodriguez@atheros.com> cfg80211: keep track of supported interface modes

It is obviously good for userspace to know up front which
interface modes a given piece of hardware might support (even
if adding such an interface might fail later because of
concurrency issues), so let's make cfg80211 aware of that.
For good measure, disallow adding interfaces in all other
modes so drivers don't forget to announce support for one mode
when they add it.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Stephen Blackheath <tramp.enshrine.stephen@blacksapphire.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
6c6aa3c004e702532cb0f549a96eb2f75636bd3b 29-Aug-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Add Signal type flag

Instead of using the PLCP flag to indicate if the
signal value is plcp or the bitrate we should add
a new flag to mark the bitrate type explicitely.
This is usefull when new types are added later for
rt2800.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
2575c11d6ee7266f0f035e55c5056b36597cd336 29-Aug-2008 Mattias Nissler <mattias.nissler@gmx.de> rt2x00: Only configure hardware when radio is enabled

Some hardware configuration registers such as antenna and channel configuration
can only be written when the radio is enabled. Previously, we didn't consider
this, so some configuration items could be set inconsistently after reenabling
the radio. This patch changes the config() handler to only reprogram the
hardware when the radio is enabled. Configuration changes that are made while
the radio is off are postponed until the radio is switched back on. We also
leave the radio turned off during initialization and only enable it when
requested by mac80211. This allows us to get rid of the DIRTY_CONFIG flag,
because the device is now guaranteed to be completely initialized when brought
up by mac80211.

Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
0262ab0df64a67d4c0ed7577a29b7d866819cc68 29-Aug-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix race conditions in flag handling

Some of the flags should be accessed atomically to
prevent race conditions. The flags that are most important
are those that can change often and indicate the actual
state of the device, queue or queue entry.

The big flag rename was done to move all state flags to
the same naming type as the other rt2x00dev flags and
made sure all places where the flags were used were changed. ;)

Thanks to Stephen for most of the queue flags updates,
which fixes some of the most obvious consequences of the
race conditions. Among those the notorious:

rt2x00queue_write_tx_frame: Error - Arrived at non-free entry in the non-full queue 0.
rt2x00queue_write_tx_frame: Error - Arrived at non-free entry in the non-full queue 0.
rt2x00queue_write_tx_frame: Error - Arrived at non-free entry in the non-full queue 0.

Signed-off-by: Stephen Blackheath <tramp.enshrine.stephen@blacksapphire.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
8c5e7a5f59f9d11597bd47de28334da318ea0e80 04-Aug-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Gather channel information in structure

Channel information which is read from EEPROM should
be read into an array containing per-channel information.
This removes the requirement of multiple arrays and makes
the channel handling a bit cleaner and easier to expand.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
2bb057d07a0bc17475a7bf897fc41667ab08b73f 04-Aug-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Implement HW encryption

Various rt2x00 devices support hardware encryption.

Most of them require the IV/EIV to be generated by mac80211,
but require it to be provided seperately instead of within
the frame itself. This means that rt2x00lib should extract
the data from the frame and place it in the frame descriptor.
During RX the IV/EIV is provided in the descriptor by the
hardware which means that it should be inserted into the
frame by rt2x00lib.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
74c0ee9b59bdaa81a666d5d58022f847390e4b0c 21-Jul-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Force full register config after start()

rt2x00 will only perform configuration changes from
mac80211 when the configuration option has changed.
This means it keeps track of the current active configuration
and will check these values when the config() callback function
is used.

However this causes breakage when the interface has been
brought down and up again, since all stored active values
aren't reset while the registers might have.
This is for example the case with rt61pci antenna registers which
will jump to invalid values when the interface has been started.

To make sure a full configuration takes place after the start()
callback function, a new flag is added which will be checked
during config() and skips the "what's changed" phase.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
bd88a7812f1afd50549f3789cacb707b983fef54 09-Jul-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Reorganize beacon handling

With the new beacon handling from mac80211 we can
reorganize the beacon handling in rt2x00 as well.
This patch will move the function to the TX handlers,
and move all duplicate code into rt2x00queue.c.

After this change the descriptor helper functions
from rt2x00queue.c no longer need to be exported
outside of rt2x00lib and can be declared static.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
9d139c810a2aa17365cc548d0cd2a189d8433c65 09-Jul-2008 Johannes Berg <johannes@sipsolutions.net> mac80211: revamp beacon configuration

This patch changes mac80211's beacon configuration handling
to never pass skbs to the driver directly but rather always
require the driver to use ieee80211_beacon_get(). Additionally,
it introduces "change flags" on the config_interface() call
to enable drivers to figure out what is changing. Finally, it
removes the beacon_update() driver callback in favour of
having IBSS beacon delivered by ieee80211_beacon_get() as well.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
ae73e58ea64f121b26437a10937330e77ff48f33 04-Jul-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Report RX end time for rt2400pci

rt2400 is the only currently available rt2x00 driver which
supports reporting of the RX end time for frames.
Since mac80211 uses this information for IBSS syncing, it
is important that it is being reported.

v2: Complement 32 bits of RX timestamp with upper 32bits from TSF

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
8e260c22238dd8b57aefb1f5e4bd114486a9c17d 04-Jul-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Use ieee80211_hw->workqueue again

Remove the rt2x00 singlethreaded workqueue and move
the link tuner and packet filter scheduled work to
the ieee80211_hw->workqueue again.
The only exception is the interface scheduled work
handler which uses the mac80211 interface iterator
under the RTNL lock. This work needs to be handled
on the kernel workqueue to prevent lockdep issues.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
50db7875d9dcd89f7624b13535738612faf8db0c 04-Jul-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove input_polldev requirements for rfkill

With the new rfkill interface there is no longer a need
for the input_polldev. Create a delayed_work structure
which we can put on the mac80211 workqueue and poll the
hardware every 1000ms.

v2: Decrease poll frequency from 100ms to 1000ms

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
28f49d8fec19833672a6a813bfde0068fee50bc9 29-Jun-2008 David S. Miller <davem@davemloft.net> Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/linville/wireless-next-2.6
1b63ba8a86c85524a8d7e5953b314ce71ebcb9c9 28-Jun-2008 David S. Miller <davem@davemloft.net> Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6

Conflicts:

drivers/net/wireless/iwlwifi/iwl4965-base.c
980dfcb93232907034a2c92d62d3a7d6ac7bef44 25-Jun-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix lock dependency errror

This fixes a circular locking dependency in the workqueue handling.
The interface work task uses the mac80211 function
ieee80211_iterate_active_interfaces() which grabs the RTNL lock.

However when the interface is brough down, this happens under the RTNL
lock as well, this causes problems because mac80211 will flush the workqueue
during the ifdown event. This causes mac80211 to wait until the driver has
completed all work which can't finish because it is waiting on the RTNL lock.

This is fixed by moving rt2x00 workqueue tasks on a different workqueue,
this workqueue can be flushed when the ieee80211_hw structure is removed
by the driver (when the driver is unloaded) which does not happen under the
RTNL lock.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
d74f5ba473b915e5d4ea1ed391984bb62d9de8b1 16-Jun-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Cleanup symbol exports

With a bit of code moving to rt2x00lib within the
TX and RX paths we can now remove a lot of EXPORT_SYMBOL_GPL()
statements. This cleans up the interface between rt2x00lib
and the drivers and has the additional benefit that rt2x00pci
and rt2x00usb are trimmed down in size as well since they
have less to do.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
c4da004857056e6ee034c4110ccdcba659077b7e 16-Jun-2008 Gertjan van Wingerde <gwingerde@kpnplanet.nl> rt2x00: Replace statically allocated DMA buffers with mapped skb's.

The current PCI drivers require a lot of pre-allocated DMA buffers. Reduce this
by using dynamically mapped skb's (using pci_map_single) instead of the pre-
allocated DMA buffers that are allocated at device start-up time.

At the same time move common RX path code into rt2x00lib from rt2x00pci and
rt2x00usb, as the RX paths now are now almost the same.

Signed-off-by: Gertjan van Wingerde <gwingerde@kpnplanet.nl>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
c95edf5432f097c926dd3f59239ecde80da3b214 16-Jun-2008 Gertjan van Wingerde <gwingerde@kpnplanet.nl> rt2x00: Properly clean up beacon skbs.

The skbs containing the beacons weren't properly cleaned up for rt2400pci, rt2500pci,
rt61pci, and rt73usb. Clean up those skbs in the manner appropriate for each driver.

Signed-off-by: Gertjan van Wingerde <gwingerde@kpnplanet.nl>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
ac1044628d477d655f5f70420c3493119abeb6d3 16-Jun-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Use ieee80211 fc handlers

With the introduction of the ieee80211 fc handlers
we can now remove the rt2x00.h versions to use the
global versions.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Reviewed-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
a9f853ddd352954815a023c4811629ed117df2f8 07-Jun-2008 Gertjan van Wingerde <gwingerde@kpnplanet.nl> rt2x00: Rework alignment check.

Rework the alignment check in rt2x00dev.c to be independent of any
potential alignment measures that may be taken before. Just check
whether the payload is aligned based on the pointer addresses.

Note: This is preparatory for the dynamically mapped skb buffers
for the PCI drivers, as these need 4-byte alignment instead of the
currently enforced offset by 2 bytes.

Signed-off-by: Gertjan van Wingerde <gwingerde@kpnplanet.nl>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
239c249d06b0c68ae06b10d9d6ad1f8e7f39452b 06-Jun-2008 Gertjan van Wingerde <gwingerde@kpnplanet.nl> rt2x00: Centralize RX packet alignment handling in rt2x00lib.

When rt2x00pci will be switched over to dynamically mapped skb's
instead of statically allocated DMA buffers, it no longer can handle
alignment of RX packets in a copy step, and needs to implement the
same scheme as rt2x00usb does.

In order to make the patch on dynamically mapped skb's smaller,
already centralize the alignment handling into rt2x00lib. This allows
us to move more code in rt2x00lib, and thus remove code duplication
between rt2x00usb and rt2x00pci.

Signed-off-by: Gertjan van Wingerde <gwingerde@kpnplanet.nl>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
2b08da3fb595432f87b5206c1c77dcb72300cacf 03-Jun-2008 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Cleanup/optimize set_state() function callback function

* Reduce goto usage
* Mark if-statements which are true on hardware error unlikely()
* Cleanup debug messages

This makes the code look nicer and be better optimized since
the chance of hardware errors should be very small.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
cb14cb791c57b45ba32c92b041420cdc1b1a0283 10-Jun-2008 John W. Linville <linville@tuxdriver.com> rt2x00dev.c: fix-up merge damage

This restores the effects of "rt2x00: Don't count retries as failure".

Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
65b53e4cc90e59936733b3b95b9451d2ca47528d 10-Jun-2008 David S. Miller <davem@davemloft.net> Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6

Conflicts:

drivers/net/tg3.c
drivers/net/wireless/rt2x00/rt2x00dev.c
net/mac80211/ieee80211_i.h
633257d3db547e7553500f05e0aa2692c876d7a5 23-May-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Use atomic interface iteration in irq context

rt2x00lib_beacondone() is called from interrupt context,
this means we cannot use the mac80211 interface iterator
that uses the rtnl lock (since that uses a mutex which can sleep).
Instead we should use the atomic mac80211 interface iterator.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
2088d4174e4292aef892bb7095fc3c3ea5bd117c 23-May-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Don't count retries as failure

Link quality estimation became quite low for all rt2x00 drivers
because the number of retries it took to send the frame were
counted as failure.
This does not correspond to the legacy driver link quality calculation,
by not counting it we will send somewhat more optimistic values to
mac80211.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
e039fa4a4195ac4ee895e6f3d1334beed63256fe 15-May-2008 Johannes Berg <johannes@sipsolutions.net> mac80211: move TX info into skb->cb

This patch converts mac80211 and all drivers to have transmit
information and status in skb->cb rather than allocating extra
memory for it and copying all the data around. To make it fit,
a union is used where only data that is necessary for all steps
is kept outside of the union.

A number of fixes were done by Ivo, as well as the rt2x00 part
of this patch.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
36d6825b91bc492b65b6333c369cd96a2fc8c903 15-May-2008 Johannes Berg <johannes@sipsolutions.net> mac80211: let drivers wake but not start queues

Having drivers start queues is just confusing, their ->start()
callback can block and do whatever is necessary, so let mac80211
start queues and have drivers wake queues when necessary (to get
packets flowing again right away.)

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
7050ec821c52826b63835dde54ee3d71c7db4262 10-May-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Split rt2x00lib_write_tx_desc()

Split rt2x00lib_write_tx_desc() up into a TX descriptor initializor
and TX descriptor writer.

This split is required to properly allow mac80211 to move its
tx_control structure into the skb->cb array.
The rt2x00queue_create_tx_descriptor() function will read all tx control
information and convert it into a rt2x00 TX descriptor information structure.
After that function is complete, we have all information we needed from the
tx control structure and are free to start writing into the skb->cb array
for our own purposes.
rt2x00queue_write_tx_descriptor() will be in charge of really sending
the TX descriptor to the hardware and kicking the TX queue.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
61448f88078e813bbaaa58eb775d650c85e7d407 10-May-2008 Gertjan van Wingerde <gwingerde@kpnplanet.nl> rt2x00: Fix queue related oops in case of deselected mac80211 multi-queue feature.

With the integration of the mac80211 multiqueue patches it has become possible that the
mac80211 layer modifies the number of TX queues that is stored inside the ieee80211_hw
structure, especially when multi-queue is not selected.

The rt2x00 drivers are not well suited to handle that situation, as they allocate the
queue structures before mac80211 has modified the number of queues it is going to use,
and also expect the number of allocated queues to match the hardware implementation.

Hence, ensure that rt2x00 maintains by itself the number of queues that the hardware
supports, and, at the same time, making is not dependent on the preservation of contents
inside a mac80211 structure.

Signed-off-by: Gertjan van Wingerde <gwingerde@kpnplanet.nl>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
61486e0f68d1f8966c09b734566a187d42d65c54 10-May-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove ieee80211_tx_control argument from write_tx_desc()

Move the last remaining information details read from ieee80211_tx_control
in the drivers to the txentry_desc structure. After this we can
remove ieee80211_tx_control from the argument list for the callback function,
which makes it easier when the control information is moved into skb->cb

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
fb55f4d1fa252ba1e479284b79da1049d658c371 10-May-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix TX status reporting

The tx_status enumeration was broken since the introduction
of rt61pci. That driver uses different values to report the
status of the tx action.
This would lead to frames that were reported as success but
actually failed to be send out, or frames that were neither
successfull or failure which were reported as failure.

Fix this by change the TX status reporting and more explicitely
check for failure or success. Note that a third possibility is
added "unknown". Not all hardware (USB) can report the actual
TX status, for rt61pci some frames will receive this status
because the TXdone handler is never called for those frames.
This unknown will now be handled as neither success or failure,
so we no longer increment the failure counter while this conclusion
could not be determined from the real status of the frame.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
5a6e59991b82580c3ca00115603b85762ec76104 10-May-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: trim skb_frame_desc to 32 bytes

Remove frame_type from skb_frame_desc and pass it
as argument to rt2x00debug_dump_frame().

Change data_len and desc_len to unsigned short
to save another 4 bytes in skb_frame_desc. Note that
this was the only location where the data_len and
desc_len was not yet treated as unsigned short.

This trim is required to help mac80211 with adding
the TX control and TX status informtation into the
skb->cb structure. When that happens, drivers will
have approximately 40 bytes left to use freely.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
f42a44494bcdf03fc851c03d438464d59c0ceaf5 15-May-2008 David S. Miller <davem@davemloft.net> Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
63fe46da9c380b3f2bbdf3765044649517cc717c 15-May-2008 David S. Miller <davem@davemloft.net> Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6

Conflicts:

drivers/net/wireless/iwlwifi/iwl-4965-rs.c
drivers/net/wireless/rt2x00/rt61pci.c
566bfe5a8bcde13188a356f77666f8115813cf31 08-May-2008 Bruno Randolf <br1@einfach.org> mac80211: use hardware flags for signal/noise units

trying to clean up the signal/noise code. the previous code in mac80211 had
confusing names for the related variables, did not have much definition of
what units of signal and noise were provided and used implicit mechanisms from
the wireless extensions.

this patch introduces hardware capability flags to let the hardware specify
clearly if it can provide signal and noise level values and which units it can
provide. this also anticipates possible new units like RCPI in the future.

for signal:

IEEE80211_HW_SIGNAL_UNSPEC - unspecified, unknown, hw specific
IEEE80211_HW_SIGNAL_DB - dB difference to unspecified reference point
IEEE80211_HW_SIGNAL_DBM - dBm, difference to 1mW

for noise we currently only have dBm:

IEEE80211_HW_NOISE_DBM - dBm, difference to 1mW

if IEEE80211_HW_SIGNAL_UNSPEC or IEEE80211_HW_SIGNAL_DB is used the driver has
to provide the maximum value (max_signal) it reports in order for applications
to make sense of the signal values.

i tried my best to find out for each driver what it can provide and update it
but i'm not sure (?) for some of them and used the more conservative guess in
doubt. this can be fixed easily after this patch has been merged by changing
the hardware flags of the driver.

DRIVER SIGNAL MAX NOISE QUAL
-----------------------------------------------------------------
adm8211 unspec(?) 100 n/a missing
at76_usb unspec(?) (?) unused missing
ath5k dBm dBm percent rssi
b43legacy dBm dBm percent jssi(?)
b43 dBm dBm percent jssi(?)
iwl-3945 dBm dBm percent snr+more
iwl-4965 dBm dBm percent snr+more
p54 unspec 127 n/a missing
rt2x00 dBm n/a percent rssi+tx/rx frame success
rt2400 dBm n/a
rt2500pci dBm n/a
rt2500usb dBm n/a
rt61pci dBm n/a
rt73usb dBm n/a
rtl8180 unspec(?) 65 n/a (?)
rtl8187 unspec(?) 65 (?) noise(?)
zd1211 dB(?) 100 n/a percent

drivers/net/wireless/ath5k/base.c: Changes-licensed-under: 3-Clause-BSD

Signed-off-by: Bruno Randolf <br1@einfach.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
ed499983b88d138848ec9e4d104fd86a5ef0c183 05-May-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix broken recover-on-error path

During initialization the initialize() callback function
in rt2x00pci and rt2x00usb will cleanup the mess they made.

rt2x00lib shouldn't call uninitialize because the callback function already
cleaned up _and_ the DEVICE_INITIALIZED isn't set which causes the
rt2x00lib_uninitialize() to halt directly anyway. All that is required
to be cleaned up by rt2x00lib is the queue, and that can be done by
calling rt2x00queue_uninitialize() directly.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
36fc6757fe711def63ea3686bf6ed475d714e114 29-Apr-2008 Johannes Berg <johannes@sipsolutions.net> mac80211: remove queue info from ieee80211_tx_status

The queue info in struct ieee80211_tx_status is never used.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
e58c6aca99357d7f85f18e0b661d8c5a87f926a9 21-Apr-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Use rt2x00 queue numbering

Use the rt2x00 queue enumeration as much as possible,
removing the usage of the mac80211 queue numbering
wherever it is possible.

This makes it easier for mac80211 to change it queue
identification scheme without having to deal with
big changes in the rt2x00 code.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
61c2b682b8391f13b67e2d95990a0aba34697d9c 21-Apr-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix quality/activity led handling

There was an obvious typo in LED structure
initialization which caused the radio and quality/activity
leds to be incorrectly initialized which resulted in
the leds not being enabled.

Additionally add the rt2x00led_led_activity() handler
that will enable TX/RX activity leds when the radio
is being enabled.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
171afcd4ba093b50cd2fb33fe2371fbc1f7fd389 09-Apr-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Only free skb when beacon_update fails

In rt2x00lib_intf_scheduled_iter() we use the hw->beacon_update()
callback function. This means that it should behave similarly as mac80211
when that uses the function.

This means that the skb should only be freed when beacon_update() has failed,
otherwise the driver is the owner and is responsible for freeing the buffer.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
133adf08266740cd886d544aa9fe80b9873cf699 04-Apr-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Use lib->config_filter() during scheduled packet filter config

Now rt2x00lib handles the initial configure_filter() command, we can
directly call lib->config_filter() in scheduled context since the
called function will no longer check if anything has changed (which is
now handled in rt2x00lib as well).

This fixes a endless loop with USB drivers where the config_filter
command was scheduled time and time again without sending any command
to the device.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
e1ec1b8ccdf0df6000faa8c2d985ca5f94157e5a 03-Apr-2008 David S. Miller <davem@davemloft.net> Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6

Conflicts:

drivers/net/s2io.c
a2e1d52a32eab53f8ab03c4023310f65aaa054a7 31-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove MAC80211_LEDS dependency

Implement triggers inside rt2x00 itself based
on input from mac80211. This replaces the method
of using the mac80211 trigger events which do
not work for USB drivers due to the scheduling
requirement.

After this patch RT2500USB_LEDS and RT73USB_LEDS
no longer need to be tagged as broken since they
now support LED handling again without having to
check for in_atomic().

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
3480a58a90cd505578b9979d878a5ad9c347d424 28-Mar-2008 John W. Linville <linville@tuxdriver.com> rt2x00: fixup some non-functional merge errors

These small changes restore the rt2x00 sources to the way Ivo intended.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
9896322ae180e3520edec71e2480318e7196119c 27-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Ignore set_state(STATE_SLEEP) failure

Some hardware never seem to accept the "goto sleep" command, since the legacy
drivers don't have suspend and resume handlers the entire code for it was
basically a educated guess (based on the "enable radio" code).
This patch will only print a warning when the "goto sleep" command fails, and
just continues as usual. Perhaps that means the device will not reach a sleep
state and consumes more power then it should, but it is equally possible it
simply needs some seconds longer to sleep. Anyway, by making the command
non-fatal it will not block the rest of the suspend procedure.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
866a05038481d77cac6fc0186250b4c44e691b42 25-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix rate detection for invalid signals

It has been observed on rt2500pci hardware that some
frames received with signal 0x0C do not have the OFDM
flag set.

Signals can have 2 meanings:
1) The PLCP value
2) The bitrate * 10

For rt2500pci (1) is for frames received with a OFDM rate,
and (2) is for frames received with a CCK rate.
But 0x0C is a invalid bitrate value but is a valid PLCP
value for 54Mbs (obvious OFDM rate).
This means that it is possible that the hardware does not
set the OFDM bit correctly under all circumstances.
This results in rt2x00 failing to detect the rate and
mac80211 triggering a WARN_ON() and dropping the frame.

To bypass this, print a warning when such a frame is received,
and reset the rate to the lowest supported rate for the current band.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
19d30e02998ef1eb9f82a7d3ce9b4a97dba5aa13 15-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Add dev_flags to rx descriptor

The rxdone_entry_desc structure contains 3 fields
which are always 1 or 0. We can safe 8 bytes by
replacing them with a single dev_flags fields which
contain the flags for those settings.

Additionally we can remove the OFDM flag since it
is no longer used since the introduction of the
SIGNAL_PLCP flag.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
247df4548fdbb0f263aaa0386bbaf52bc359a972 19-Mar-2008 Andrew Morton <akpm@linux-foundation.org> [RT2X00] drivers/net/wireless/rt2x00/rt2x00dev.c: remove dead code, fix warning

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/wireless/rt2x00/rt2x00dev.c
577f99c1d08cf9cbdafd4e858dd13ff04d855090 18-Mar-2008 David S. Miller <davem@davemloft.net> Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6

Conflicts:

drivers/net/wireless/rt2x00/rt2x00dev.c
net/8021q/vlan_dev.c
8ed09854073ae0a19556d4d93cf79cf368c23673 10-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Only strip preamble bit in rt2400pci

Only rt2400pci can have the preamble bit set in the PLCP value,
for all other drivers it should not be cleared since that will
conflict with the plcp values for OFDM rates.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
89993890aeb8fe58b2d49b2661965524802ab73c 09-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix rt2400pci signal

After sampling hundreds of RX frame descriptors,
the results were conclusive:
- The Ralink documentation regarding the SIGNAL and RSSI are wrong.

It turns out that of the 5 BBR registers, we should not use BBR0 and BBR1
for SIGNAL and RSSI respectively, but actually BBR1 and BBR2.
BBR0 does show values, but the exact meaning remains unclear,
but they cannot be translated into a SIGNAL or RSSI field.
BBR3, BBR4 and BBR5 are always 0, so their meaning is unknown.

As it turns out, the reported SIGNAL is the PLCP value, this
in contradiction to what was expected looking at rt2500pci which
only reported the PLCP values for OFDM rates and bitrate values
for CCK rates.

This means we should let the driver raise the flag about the contents
of the SIGNAL field so rt2x00lib can always do the right thing based
on what the driver reports.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
aa776721b472e343a8db7f3c0673b1fa24e6c7f7 09-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix basic rate initialization

The basic rate which is configured in the register
should not match all supported rates, but only the _basic_ rates.

Fix this by adding a new flag to the rt2x00_rate structure
and whenever the mode is changed, loop over all available rates
for that band to get the basic rate mask.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
728103794316f7ff8d98bc2ce044aff7a260ee21 09-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Rename config_preamble() to config_erp()

Rename config_preamble() to config_erp() and cleanup argument
list by putting it all into a single structure.
This will make the function more meaningful and easier to
expand later. This second option is mostly intended to make
the patch "mac80211: proper short-slot handling" from Johannes Berg
easier to apply for rt2x00.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
3976ae6c2b09608cd6a13663737a6b219245b651 09-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Use skbdesc fields for descriptor initialization

In rt2x00lib_write_tx_desc() the skb->data and skb->len fields
were incorrectly used. For USB drivers both of those values
contain invalid data (skb->data points to the device descriptor,
skb->len contains the frame _and_ descriptor length).

Instead of using the skbuffer fields we should use the skbdesc
fields which are correctly initialized and contain all the data
that we need.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
95db4d4d5f00cc9b2aa703a05a70902776d8c2f2 09-Mar-2008 Mattias Nissler <mattias.nissler@gmx.de> rt2x00: Use the correct size when copying the control info in txdone

The sizeof() operator was incorrectly applied to the pointer, not the struct.

Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
1682fe6de206bd1e937529cbb393915e5ea40b2c 13-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Add suspend/resume handlers to rt2x00rfkill

Add suspend/resume handlers to rt2x00rfkill to have it stop
the input-polldev and prevent it from calling rt2x00 during
suspend period. This could lead to a NULL pointer fault when
rt2x00 suspended, but polldev send a request, because
the csr_addr is NULL.

Also don't let the rfkill allocation/registration block
the initialization of the entire device. Just print a warning
and continue as if nothing happened.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
47ac26833663da51e7ac801db4badc2880c682c3 17-Feb-2008 Gertjan van Wingerde <gwingerde@kpnplanet.nl> rt2x00: Fix hw mode registration with mac80211.

The supported_bands field of struct hw_mode_spec now represents a bitfield,
so bitfield operators need to be tested with when setting the band data.

The current code generates the following warning:

[176624.986244] WARNING: at /usr/local/src/incoming/compat-wireless-2.6/net/wireless/core.c:269 wiphy_register()
[176624.986249] Pid: 12548, comm: modprobe Tainted: P 2.6.24.2#4
[176624.986251]
[176624.986251] Call Trace:
[176624.986277] [<ffffffff881c56bf>] :cfg80211:wiphy_register+0x17f/0x1a0
[176624.986282] [<ffffffff881ddf80>] :rt61pci:rt61pci_eepromregister_write+0x0/0x80
[176624.986302] [<ffffffff88b7e4bc>] :mac80211:ieee80211_register_hw+0x2c/0x2b0
[176624.986310] [<ffffffff881cdc80>] :rt2x00lib:rt2x00lib_probe_dev+0x350/0x3f0
[176624.986318] [<ffffffff881d74b9>] :rt2x00pci:rt2x00pci_probe+0x149/0x200
[176624.986325] [<ffffffff8030c858>] pci_device_probe+0xf8/0x170
[176624.986331] [<ffffffff803594fc>] driver_probe_device+0x9c/0x1c0
[176624.986335] [<ffffffff80359700>] __driver_attach+0x0/0xb0
[176624.986337] [<ffffffff803597a5>] __driver_attach+0xa5/0xb0
[176624.986341] [<ffffffff8035877d>] bus_for_each_dev+0x4d/0x80
[176624.986347] [<ffffffff80358b8c>] bus_add_driver+0xac/0x210
[176624.986351] [<ffffffff8030cad3>] __pci_register_driver+0x73/0xc0
[176624.986357] [<ffffffff8025689e>] sys_init_module+0x18e/0x1a20
[176624.986374] [<ffffffff8020c42e>] system_call+0x7e/0x83

Signed-off-by: Gertjan van Wingerde <gwingerde@kpnplanet.nl>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
31562e802a72caf0757f351fff563d558d48d087 17-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Cleanup mode registration

Don't wildly pass any number for num_rates to rt2x00lib,
instead pass which type of rates are supported (CCK, OFDM).
Same for num_modes but then for the 2GHZ and 5GHZ band.

This makes the interface look much nicer and makes
extending it later easier.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
baf26a7eae3b05d25dd967b92eb2e09406ed9cf4 17-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Don't report driver generated frames to tx_status()

This adds a new flag for the skb_frame_desc structure which is used to tag
rts/cts frames that are generated by the driver. Through the tag we can
recognize frames we have generated ourselves, so we don't report their tx
status to mac80211.

This patch is based on the original patch by
Mattias Nissler <mattias.nissler@gmx.de>.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
8f5fa7f04484e933b3ac8dfe77995d3f1cedde5f 03-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix rate initialization

Fix typo in rate initialization. This fixes the WARN_ON()
in net/wireless/util.cpp:83

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
a9450b70a755abf093600035ef5361c53343fe9a 03-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Make use of MAC80211_LED_TRIGGERS

Make use of the led triggers provided by mac80211 to control
the led status. This can be enabled through a per-driver
configuration option which will automatically enable the
generic handler in rt2x00lib.

This has been enabled for rt2500usb and rt73usb for the moment
since the led class will call set_brightness in irq context which
will not work correctly with the usb drivers who need to sleep.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
f2a3c7f5c8e3c1356dbbce1e9ac2e7f4d5365ba9 03-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Use ieee80211_channel_to_frequency()

No need to perform the calculation ourselves when
wireless provides a helper function for it.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
f5507ce90be4e00a84b5bb4c7b4324455aa6ee21 03-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove HWMODE_{A,B,G}

rt2500usb initialized the SIFS and EIFS without using the
values coming from rt2x000lib. After this is fixed HWMODE_{A,B,G}
is now unused and can be removed in favour of the ieee80211_band
enumeration which could still be usefull later.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
70e2fed4ec14df84ed72554d573794714b15a078 03-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Rate structure overhaul

Recent changes to the rate structure registration broke rt2x00,
the hw_value was reduced from 32bits to 16bits while rt2x00 used
the full 32bits. However the way rt2x00 used the value was inflexible
and needed to be changed anyway.

This patch creates a array containing information for each rate,
the hw_value passed to mac80211 is the index value for that array
including a field to indicate if short preamble should be enabled.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
8318d78a44d49ac1edf2bdec7299de3617c4232e 24-Jan-2008 Johannes Berg <johannes@sipsolutions.net> cfg80211 API for channels/bitrates, mac80211 and driver conversion

This patch creates new cfg80211 wiphy API for channel and bitrate
registration and converts mac80211 and drivers to the new API. The
old mac80211 API is completely ripped out. All drivers (except ath5k)
are updated to the new API, in many cases I expect that optimisations
can be done.

Along with the regulatory code I've also ripped out the
IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED flag, I believe it to be
unnecessary if the hardware simply gives us whatever channels it wants
to support and we then enable/disable them as required, which is pretty
much required for travelling.

Additionally, the patch adds proper "basic" rate handling for STA
mode interface, AP mode interface will have to have new API added
to allow userspace to set the basic rate set, currently it'll be
empty... However, the basic rate handling will need to be moved to
the BSS conf stuff.

I do expect there to be bugs in this, especially wrt. transmit
power handling where I'm basically clueless about how it should work.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
5957da4c6e67a5447e75c2ad65252fdd5e22f9d0 03-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Move beacon and atim queue defines into rt2x00

As Johannes Berg indicated the BEACON and AFTER_BEACON
queue indeces in mac80211 should be removed because they
are too hardware specific. This patch adds the queue index
defines into rt2x00queue.h and removes the dependency of
the defines inside mac80211.h.

Also move rt2x00pci_beacon_update() into rt2400pci and
rt2500pci individually since it is no longer a generic
function since rt61 and rt2800 no longer use that.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
091ed315ef77a4949a6ce22e43af15a504ada348 03-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Initialize QID from queue->qid

The QID_MGMT is assigned to the beacon and atim queue
during initialization. This means we don't need a seperate
check in write_tx_desc()..

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
6bb40dd13b458beb55f5c60dba1cb28e814bd640 03-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Add per-interface structure

Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.

Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.

Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces

At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.

Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.

The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
9404ef34e4747228717d6e22ce3827ed366ccf41 03-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Driver requiring firmware should select crc algo

The driver should select what CRC algorithm is required
when performing a checksum on the firmware.

rt61pci & rt73usb require crc-itu-t
rt2800pci & rt2800usb require crc-ccitt

Legacy 2800pci/usb driver uses crc-itu-t + bit order reversion,
but that is just inefficient especially since the end result is
the same as a different algorithm which is also available as library. ;)

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
181d6902b6bad978d157e69479c95cc0ff213a76 05-Feb-2008 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Queue handling overhaul

This introduces a big queue handling overhaul, this also
renames "ring" to "queues".

Move queue handling into rt2x00queue.c and the matching header,
use Kerneldoc to improve rt2x00 library documentation.

Access to the queues is now protected under a spinlock, this
to prevent race conditions which could corrupt the indexing
system of the queue.

Each queue entry allocates x bytes for driver/device specific data,
this cleans up the queue structure significantly and improves
code readability.

rt2500usb no longer needs 2 entries in the beacon queue to correctly
send out the guardian byte. This is now handled in the entry specific
structure.

rt61 and rt73 now use the correct descriptor size for beacon frames,
since this data is written into the registers not the entire TXD
descriptor was used but instead of a subset of it named TXINFO.

Finally this also fixes numerous other bugs related to incorrect
beacon handling or beacon related code.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
811aa9cad1bd927999888ab56ed9592519d2fef6 03-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Update copyright notice

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
53b3f8e47a38f39836da1c9f9d2ea9a9c164c8f4 25-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix rt2x00lib_reset_link_tuner()

rt2x00lib_reset_link_tuner() can be called from within
the link tuner itself. This means that it should
_not_ call rt2x00lib_stop_link_tuner() since that will
cause the thread to hang.

Reorder the things that should be done during a
link tuner reset and during a link tuner start.

Also make antenna tuning the last step of the link
tuner since it could possibly reset some statistical
information which we need for average calculation.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
05253c93feb40901d80a0d6f239a0bc78860c679 25-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Don't switch to antenna with low rssi

When rssi_a > rssi_b is true and the current antenna
was already antenna A, then rt2x00 incorrectly jumped
to antenna B.

Also don't configure the antenna when there has been
no change in the antenna setup.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
b290d433618aa7122f6e6c4a62ddc79412a48d4d 25-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix antenna diversity

Fix 2 issues in antenna diversity selection.

1) the following statement will always return true.
if ((rssi_curr - rssi_old) > -5 || (rssi_curr - rssi_old) < 5)
It is cleaner to check if the absolute value is smaller then 5.

2) Only enable software diversity when default antenna setup
indicates support for it. Don't select it when the hardware
does not indicate support for it...

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
89539ebe2f2eb3a0d77b92884b092f2eb2575bd9 10-Jan-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix queue_idx initialization

For TX rings the queue_idx should start at
IEEE80211_TX_QUEUE_DATA0 and for each followup
ring this index needs to be increased.

For the RX ring the queue_idx should be set
to 0. We don't need to initialize the tx_params.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
471b3efdfccc257591331724145f8ccf8b3217e1 28-Dec-2007 Johannes Berg <johannes@sipsolutions.net> mac80211: add unified BSS configuration

This patch (based on Ron Rindjunsky's) creates a framework for
a unified way to pass BSS configuration to drivers that require
the information, e.g. for implementing power save mode.

This patch introduces new ieee80211_bss_conf structure that is
passed to the driver via the new bss_info_changed() callback
when the BSS configuration changes.

This new BSS configuration infrastructure adds the following
new features:
* drivers are notified of their association AID
* drivers are notified of association status

and replaces the erp_ie_changed() callback. The patch also does
the relevant driver updates for the latter change.

Signed-off-by: Ron Rindjunsky <ron.rindjunsky@intel.com>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
837e7f247a8ed3f5577462655f8099a81b360422 06-Jan-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Move init_txring and init_rxring into rt2x00lib

Prior to enabling the radio rt2x00lib should go through all
rings and for each entry should call the callback function
init_txentry() and init_rxentry().

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
7e56d38d5d0bda89228821902af297a46b5fdb80 06-Jan-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Determine MY_BSS from descriptor

Use the MY_BSS descriptor field to determine if the
received frame belongs to the same BSS as the interface.
This can be used by rxdone to determine if the frame
should be updated or not.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
dd3193e1c25ffbc66b684edb52273ae10695909d 06-Jan-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Cleanup write_tx_desc() arguments

Send the skb structure with write_tx_desc() and use
the skbdesc structure to read all information about
the frame. This saves several arguments in the function
definition and it is easier to send more information
later as well.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
3c4f2085e5d82639004406795653e1e4dd6720e0 06-Jan-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Move packet filter flags

The packet filter flags don't belong in the interface structure
because they are device based instead of interface based.
So move the filter fields out of struct interface and into rt2x00_dev.

Additionally we shouldn't change the filter based on the working
mode, if such a thing is needed than mac80211 should have done that.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
e37ea2135be080dd25f1a2644c9132c109fa77d1 06-Jan-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Move start() and stop() handlers into rt2x00lib.c

suspend & resume was broken since it called rt2x00mac_start()
and rt2x00mac_stop() which would fail to execute because the
DEVICE_PRESENT flag was not set.

Move the start and stop handlers into rt2x00lib.c which are called
from rt2x00mac_start() and rt2x00mac_stop() after they have checked
the DEVICE_PRESENT flag, while suspend and resume handlers can
directly call those functions.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
042671040db95a896c5ca960b9b656692a787892 06-Jan-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Store queue idx and entry idx in data_ring and data_entry

Store the queue idx inside structure data_ring
Store the entry idx inside structure data_entry
This saves us a few calls to ARRAY_INDEX() which is now unused.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
61af43c56bef2cfcb8f1d9aab4e766e0f7bdd893 27-Nov-2007 Mattias Nissler <mattias.nissler@gmx.de> rt2x00: Only update rssi average approximation on receiving beacon frames.

Restrict rssi average updating to beacon frames of the bssid the
interface is
associated with. Without this restriction, strong signals belonging to other
BSS, e.g. beacon frames coming from a nearby AP, would cause incorrectly high
rssi approximation values. This would then cause the link tuner to reduce
sensitivity, resulting in transmissions from the BSS associated to to be
missed.

Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
d28c2561fb09dcc0b47ae0ba12083cf0d988495f 27-Nov-2007 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Use IEEE80211_IF_TYPE_INVALID directly

No need to use a seperate define INVALID_INTERFACE while
we can use IEEE80211_IF_TYPE_INVALID directly.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
4d8dd66c1659ba0d1b110ed0488f4f6ffbc90e71 27-Nov-2007 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Add TX/RX frame dumping facility

This adds TX/RX frame dumping capabilities through debugfs.
The intention is that with this approach debugging of rt2x00 is
simplified since _all_ frames going in and out of the device
are send to debugfs as well along with additional information
like the hardware descriptor.

Based on the patch by Mattias Nissler.
Mattias also has some tools that will make the dumped frames
available to wireshark: http://www-user.rhrk.uni-kl.de/~nissler/rt2x00/

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
08992f7fb139c7dbaf593402312ee5a055352f05 24-Jan-2008 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Add skb descriptor

Use the skb->cb field to add a frame description that can be used
to transfer information passed each rt2x00 layer. This reduces the
required arguments for rt2x00lib_write_tx_desc().

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/wireless/rt2x00/rt2x00dev.c
2360157c413b06fe2958a051daeab7bac68f6588 27-Nov-2007 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Replace DRV_NAME with KBUILD_MODNAME

DRV_NAME was always set to the KBUILD_MODNAME value,
lets clean everything up by removing DRV_NAME and just
use KBUILD_MODNAME directly.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
2700f8b0489e00cb6eead31e58f5461812dd31a6 27-Oct-2007 Mattias Nissler <mattias.nissler@gmx.de> rt2x00: Correctly set ACK bit in tx descriptors

Add a flag to struct txdata_entry_desc that specifies whether an ack for the
frame is to be expected. Use this flag to set the ACK bit in the tx descriptor.
Previously, the ACK bit could be set incorrectly on CTS-to-self frames, so they
caused retries and were reported to be failed in the txdone handlers.

Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/wireless/rt2x00/rt2x00dev.c
4bd7c452a468af30bb3c4d9c3adcdaf3f3c6048c 24-Jan-2008 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Remove data_desc structure

Coverty indicated that data_desc with a single
element array is bad coding style. This removes
the structure and forces everybody to use __le32.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/wireless/rt2x00/rt2x00dev.c
69f81a2cac860cf183eb9ef7787525c3552d4612 13-Oct-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Implement SW diversity

When mac80211 indicates that the default antenna setup
should be used _and_ that this default setup is SW_DIVERSITY.

This requires sampling and storing the RSSI per antenna
and check once every 2 seconds to determine if the RSSI
has changed significantly. Once this is the case we should sample
the other antenna for a short period and evaluate if
we need to swap antenna or not.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/wireless/rt2x00/rt2x00dev.c
8de8c5162b157884aa4855564cbfd9ec9119c819 13-Oct-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Remove rt2x00_clear_link

rt2x00_clear_link() was becoming too large for statically inline,
also it was used on a single location and shouldn't really be
used anywhere else. So move the entire code into the function
rt2x00lib_start_link_tuner()

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/wireless/rt2x00/rt2x00dev.c
addc81bd428f9eb29ed2ab64ad4039c6aed55aea 13-Oct-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Correctly translate mac80211 antenna setup to rt2x00

mac80211 has 3 values for the antenna setup:
0 - default
1 - use antenna 1
2 - use antenna 2

This means that rt2x00 should store the default value
from the EEPROM somwhere and use that when mac80211 indicates
that the antenna setup is 0.
This also implies that rt2x00 should no longer write the
hw->config.antenna_sel_* values based on the EEPROM input.

This also adds the basis in rt2x00lib for correct software
diversity handling. By default rt2x00lib will now configure
antenna B instead of hardware diversity.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/wireless/rt2x00/rt2x00dev.c
ebcf26dae9f10e247ea41ef66f89b336ba456097 13-Oct-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Move quality statistics into seperate structure

Move all link quality statistics variables into
the link_qual structure. This cleans up the link
structure and allows us to use it for more then
just statistics.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/wireless/rt2x00/rt2x00dev.c
db15178755f823d1fa8c242210cf04c26fca1483 13-Oct-2007 Mattias Nissler <mattias.nissler@gmx.de> [PATCH] rt2x00: Fix residual check in PLCP calculations.

Because rt2x00 implements the residual calculation different from what the
legacy code does (i.e. scaled values), we need to adjust the residual check.
Again, we are only mimicking the behaviour of the ralink driver without
actually knowing what we do :-(

Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
5c58ee51ff8c0aca74c225e0263bc5dd2b917781 06-Oct-2007 Ivo van Doorn <IvDoorn@gmail.com> [PATCH] rt2x00: Reorganize configuration handler

Reorganize configuration handling by creating a extra
structure which contains precalculated values based
on the mac80211 values which are usefull for all
individual drivers.

This also fixes the preamble configuration problem,
up untill now preamble was never configured since
by default the rate->val value was used when changing
the mode.
Now rate->val will only be used to set the basic rate mask.
The preamble configuration will now be done correctly
through the erp_ie_changed callback function.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
5cbf830e137d1b6057cb6b553a8ebbb7d1b9343f 06-Oct-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Pass dev_state to rt2x00lib_toggle_rx

Directly pass a value from the enum dev_state with rt2x00lib_toggle_rx,
this will save us a ? : statement, and it is clearer then passing a 1 0
argument.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
81873e9ccd5731ca77027bdb32b34904e7af25d0 06-Oct-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Fix rfkill handling

As reported by Modestas Vainius, enabling rkfill in 1 driver and
disabling it in a second could cause a NULL pointer exception when
the rfkill-disabled driver still sets the CONFIG_SUPPORT_HW_BUTTON flag.

Furthermore, rfkill expects the timeout as a value in milliseconds
instead of jiffies. Also increase the timeout to a second,
since this 250ms would be overkill.

Also the flag DEVICE_ENABLED_RADIO_HW is causing problems
for devices which do not support the hardware button
while rfkill is enabled in the driver.

To remidy this we should inverse the flag and its meaning,
rename the flag to DEVICE_DISABLED_RADIO_HW this means that
by default the radio is enabled by the hardware button (if present)
and can only be disabled explicitely.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
5886d0dbf5b4226c6b6c8c44c555c5dd83c67b02 06-Oct-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Don't use changed_flags inside configure_packet_filter

We shouldn't use changed_flags when configuring the packet filter,
we work directly with the total_flags which is safe enough since
we already check if something has changed after we applied our
packet filtering flag rules.
Also make sure that when the packet filter is scheduled, the
rt2x00dev->interface.filter is cleared to make sure the drivers
will update the packet filter instead of failing at the check:
*total_flags == rt2x00dev->interface.filter

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
6d7f9877a66a3abe0b04b63d1de4659919e21a92 06-Oct-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Store "STARTED" state during suspend

Store the started state into a new flag DEVICE_STARTED_SUSPEND
and set this when suspending while the device was started.
We can't check for is_interface_present() since only mac80211
knows if there are monitor interfaces present.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
3a84732a5c9758a4bd59088787cac23508ef8b62 06-Oct-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Remove radio check from rt2x00lib_toggle_rx

Don't check if the radio is enabled in rt2x00lib_toggle_rx,
this is required since the link tuner should be disabled
when shutting down the device. The remaining calls inside the
rt2x00lib_toggle_rx handler should deliver no problems when
called while the radio is done.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
fdd0abc8175dc43a14fe414a09fd7e6a162757bd 25-Sep-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Fix panic on rmmod with rfkill enabled

When ieee80211_hw.config indicates that the radio
is enabled and is configuring options that require
the link tuner to be restarted the link tuner will
cause a kernel panic when rfkill has indicated the
radio was in fact disabled.

Signed-off-by: Modestas Vainius <modestas@vainius.eu>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
25ab002f94c73d9f214130fe0e0a8065e7b55841 25-Sep-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Stop link tuning when radio is down

As pointed out by Modestas Vainius the link tuner
could continue working while the radio is already
down. This because at the start of disable_radio
the ENABLED_RADIO flag is cleared and causes the
toggle_rx to skip the stop_link_tuner() call.
This will add a check to the start of the link tuner
which will automatically stop the link tuner when the
radio is disabled.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
3e30968e55e43ef08ee08c71258711a79c550f25 25-Sep-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: make rt2x00lib_stop_link_tuner() reentrant with link_tuner work

Calling cancel_delayed_work_sync() unconditionally won't hurt
and it will avoid race conditions when another CPU is already
executing link_tuner work.

Signed-off-by: Modestas Vainius <modestas@vainius.eu>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
066cb637b1b562bebd09d237bfaaca6724f247e5 25-Sep-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Reorganize rt2x00dev->flags

The rt2x00dev->flags has become a chaos over time,
this will reorganize the flags by renaming, deleting, adding
and properly implement the flags.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
725d99d4660fcd9abe37d7b733c9412a58465d13 25-Sep-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Correct error in calculating rssi for link tuner

The call to rt2x00lib_precalculate_link_signal resets link.rx_success
which is needed when calculating the average rssi for the link
tuner. Change the call order so the link tuner runs first as it
doesn't need the result of the precalculate.

Signed-off-by: Adam Baker <linux@baker-net.org.uk>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
4150c57212ad134765dd78c654a4b9906252b66d 17-Sep-2007 Johannes Berg <johannes@sipsolutions.net> [PATCH] mac80211: revamp interface and filter configuration

Drivers are currently supposed to keep track of monitor
interfaces if they allow so-called "hard" monitor, and
they are also supposed to keep track of multicast etc.

This patch changes that, replaces the set_multicast_list()
callback with a new configure_filter() callback that takes
filter flags (FIF_*) instead of interface flags (IFF_*).
For a driver, this means it should open the filter as much
as necessary to get all frames requested by the filter flags.
Accordingly, the filter flags are named "positively", e.g.
FIF_ALLMULTI.

Multicast filtering is a bit special in that drivers that
have no multicast address filters need to allow multicast
frames through when either the FIF_ALLMULTI flag is set or
when the mc_count value is positive.

At the same time, drivers are no longer notified about
monitor interfaces at all, this means they now need to
implement the start() and stop() callbacks and the new
change_filter_flags() callback. Also, the start()/stop()
ordering changed, start() is now called *before* any
add_interface() as it really should be, and stop() after
any remove_interface().

The patch also changes the behaviour of setting the bssid
to multicast for scanning when IEEE80211_HW_NO_PROBE_FILTERING
is set; the IEEE80211_HW_NO_PROBE_FILTERING flag is removed
and the filter flag FIF_BCN_PRBRESP_PROMISC introduced.
This is a lot more efficient for hardware like b43 that
supports it and other hardware can still set the BSSID
to all-ones.

Driver modifications by Johannes Berg (b43 & iwlwifi), Michael Wu
(rtl8187, adm8211, and p54), Larry Finger (b43legacy), and
Ivo van Doorn (rt2x00).

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Michael Wu <flamingice@sourmilk.net>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
/drivers/net/wireless/rt2x00/rt2x00dev.c
95ea36275f3c9a1d3d04c217b4b576c657c4e70e 26-Sep-2007 Ivo van Doorn <IvDoorn@gmail.com> [RT2x00]: add driver for Ralink wireless hardware

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/wireless/rt2x00/rt2x00dev.c