History log of /drivers/net/wireless/rt2x00/rt2400pci.c
Revision Date Author Comments
6cccccafe9e8b88adb1800940ded6ad76c587e1b 22-Nov-2011 John W. Linville <linville@tuxdriver.com> Revert "rt2x00: handle spurious pci interrupts"

This reverts commit 23085d5796561625db4143a671f1de081f66ef08.

The original patch was a misguided attempt to improve performance on
some hardware that is apparently prone to spurious interrupt generation.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
23085d5796561625db4143a671f1de081f66ef08 16-Nov-2011 Stanislaw Gruszka <sgruszka@redhat.com> rt2x00: handle spurious pci interrupts

We have documented case of very bad performance issue on rt2800pci
device, because it generate spurious interrupt, what cause irq line
is disabled: https://bugzilla.redhat.com/show_bug.cgi?id=658451

We already address that problem in separate patch by returning
IRQ_HANDLED from interrupt handler. We think similar fix is needed for
other rt2x00 PCI devices, because users report performance problems on
these devices too.

Cc: stable@vger.kernel.org
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8a3a3c85e44d58f5af0adac74a0b866ba89a1978 02-Oct-2011 Eliad Peller <eliad@wizery.com> mac80211: pass vif param to conf_tx() callback

tx params should be configured per interface.
add ieee80211_vif param to the conf_tx callback,
and change all the drivers that use this callback.

The following spatch was used:
@rule1@
struct ieee80211_ops ops;
identifier conf_tx_op;
@@
ops.conf_tx = conf_tx_op;

@rule2@
identifier rule1.conf_tx_op;
identifier hw, queue, params;
@@
conf_tx_op (
- struct ieee80211_hw *hw,
+ struct ieee80211_hw *hw, struct ieee80211_vif *vif,
u16 queue,
const struct ieee80211_tx_queue_params *params) {...}

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
37a41b4affa33bb237d3692bf51f1b5ebcaf29d8 21-Sep-2011 Eliad Peller <eliad@wizery.com> mac80211: add ieee80211_vif param to tsf functions

TSF can be kept per vif.
Add ieee80211_vif param to set/get/reset_tsf, and move
the debugfs entries to the per-vif directory.

Update all the drivers that implement these callbacks.

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
5f0dd296a01c8173fcc05a8b262a1168ae90bc74 06-Jul-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Implement tx_frames_pending mac80211 callback function.

Implementing this callback function will cause mac80211 refrain from
going to powersave state when there are still untransmitted TX frames
in the queues.
This would exactly mimic the behaviour of the legacy vendor driver which
also doesn't go in powersave mode if there are still TX frames that are not
transmitted.
This should make powersaving and rt2x00 a better couple.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-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>
0ed7b3c04434788ef03d267190c5e9e6e3f8e9ce 18-Apr-2011 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Implement get_antenna and set_antenna callback functions

Implement the get_antenna and set_antenna callback functions, which will
allow clients to control the antenna for all non-11n hardware (Antenna handling
in rt2800 is still a bit magical, so we can't use the set_antenna for those drivers
yet).

To best support the set_antenna callback some modifications are needed in the
diversity handling. We should never look at the default antenna settings to determine
if software diversity is enabled. Instead we should set the diversity flag when
possible, which will allow the link_tuner to automatically pick up the tuning.

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>
e7dee444263a103a9a2ac5fd5d0b5e9dc177d57c 18-Apr-2011 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Implement get_ringparam callback function

With the get_ringparam callback function we can export ring parameters
to ethtool through the mac80211 interface.

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>
e01ae27f8ce6bd3ee26ef33c704f62449ce8233b 18-Apr-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Allow dynamic addition of PCI/USB IDs.

Both USB and PCI drivers allow a system administrator to dynamically add
USB/PCI IDs to the device table that a driver supports via the
/sys/bus/{usb,pci,pci_express}/drivers/<driver-name>/new_id files.

However, for the rt2x00 drivers using this method currently crashes the
system with a NULL pointer failure.

This is due to the set-up of rt2x00 where the probe functions require a
rt2x00_ops structure in the driver_info field of the probed device. As
this field is empty for the dynamically added devices this fails for
these devices.

Fix this by introducing driver-specific probe wrappers that do nothing
but calling the bus-specific probe functions with the rt2x00_ops structure
as an argument, rather than depending on the driver_info field.

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>
7a5a681a7df7d844b52f82a4388e078071eb883e 18-Apr-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Always inline rt2x00pci_enable_interrupt

This allows the compiler to perform the necessary bitfield calculations
during compile time instead of run time and thus reduces the number of
instructions to run during each tasklet invocation. This should improve
performance in the RX hotpath.

This comes at the cost of a slight increase in the module size (for
example rt2800pci):

Before:
text data bss dec hex filename
14133 832 4 14969 3a79 drivers/net/wireless/rt2x00/rt2800pci.ko

After:
text data bss dec hex filename
14149 832 4 14985 3a89 drivers/net/wireless/rt2x00/rt2800pci.ko

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>
152a599274b15028604e24ae2d9c9d7f49853977 18-Apr-2011 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Decrease association time for USB devices

When powersaving is enabled, assocaition times are very high
(for WPA2 networks, the time can easily be around the 3 seconds).

This is caused, because the flushing of the queues takes
too much time. Without the flushing callback mac80211 assumes
a timeout of 100ms while scanning. Limit all flush waiting
loops to the same maximum.

We can apply this maximum by passing the drop status to the
driver, which makes sure the driver performs extra actions
during the waiting for the queue to become empty.

After these changes, association times fall within the
healthy range of ~0.6 seconds with powersaving enabled.
The difference between association time between powersaving
enabled and disabled is now only ~0.1 second (which can also
be due to the measuring method).

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>
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>
166389375d5a3894aa00a9c2e490ac4b9af2a891 28-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Limit rt2x00pci rxdone processing to 16 entries at once

Instead of receiving an unlimited number of frames, stop after 16
entries and reschedule the rxdone tasklet. This allows other tasklets
to be run inbetween.

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>
61c6e4893f3070b6473ca4ec3176c7471d44278b 03-Mar-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Include ATIM queue support in rt2x00queue_get_tx_queue.

The ATIM queue is considered to be a TX queue by the drivers that support
the queue. Therefore include support for the ATIM queue to the
rt2x00queue_get_tx_queue function so that the drivers that support the ATIM
queue can also use that function.

Add the support in such a way that drivers that do not support the ATIM
queue are not penalized in their efficiency.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-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>
e74df4a7562da56a7e4dbf41ff167b2f44e84a50 03-Mar-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Don't treat ATIM queue as second beacon queue.

Current code for the atim queue is strange, as it is considered in the
rt2x00_dev structure as a second beacon queue.
Normalize this by letting the atim queue have its own struct data_queue
pointer in the rt2x00_dev structure.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-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>
0aa13b2e06fbb8327c7acb4ccf684b2b65c302ce 03-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Revise irqmask locking for PCI devices

The PCI device irqmask is locked by a spin_lock. Currently
spin_lock_irqsave is used everywhere. To reduce the locking overhead
replace spin_lock_irqsave in hard irq context with spin_lock and in
soft irq context with spin_lock_irq.

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>
2517794b702cf62bb049e57c0825fc4573f8a6a3 03-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Move TX descriptor field "ifs" into plcp substruct

"ifs" is only used by no-HT devices. Move it into the plcp substruct and
fill in the value only for no-HT devices.

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>
26a1d07f4176099a7b6f45009dad054e6ad5b7e4 03-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Optimize TX descriptor handling

HT and no-HT rt2x00 devices use a partly different TX descriptor.
Optimize the tx desciptor memory layout by putting the PLCP and HT
substructs into a union and introduce a new driver flag to decide which
TX desciptor format is used by the device.

This saves us the expensive PLCP calculation fOr HT devices and the HT
descriptor setup on no-HT devices.

Acked-by: Gertjan van Wingerde <gwingerde@gmail.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>
7fe7ee77765161217f60ec9facabd9d2b38d98fe 03-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Generate sw sequence numbers only for devices that need it

Newer devices like rt2800* own a hardware sequence counter and thus
don't need to use a software sequence counter at all. Add a new driver
flag to shortcut the software sequence number generation on devices that
don't need it.

rt61pci, rt73usb and rt2800* seem to make use of a hw sequence counter
while rt2400pci and rt2500* need to do it in software.

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>
f5a9987dfbe219ffc361ebf126e1797db4abbcfe 30-Jan-2011 Mark Einon <mark.einon@gmail.com> Trivial typo fix in comment

Fixing a trivial comment typo.

Signed-off-by: Mark Einon <mark.einon@gmail.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>
b550911abc0db069bb157f9769ffb7cf22c6c868 30-Jan-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Remove STATE_RADIO_IRQ_OFF_ISR and STATE_RADIO_IRQ_ON_ISR

Remove STATE_RADIO_IRQ_OFF_ISR and STATE_RADIO_IRQ_ON_ISR as they are
not used anymore.

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>
bcf3cfd047d599cd0e6758c422bd7a4835c00d4a 30-Jan-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Convert rt2400pci interrupt handling to use tasklets

Fix interrupt processing on slow machines by using individual tasklets
for each different device interrupt. This ensures that while a RX or TX
status tasklet is scheduled only the according device interrupt is
masked and other interrupts such as TBTT can still be processed.

Also, this allows us to use tasklet_hi_schedule for TBTT processing
which is required to not send out beacons with a wrong DTIM count (due
to delayed periodic beacon updates). Furthermore, this improves the
latency between the TBTT and sending out buffered multi- and broadcast
traffic.

As a nice bonus, the interrupt handling overhead should be much lower.

Compile-tested only.

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>
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>
f615e9a38a8e6239d35891a05f2ac1159088780a 13-Dec-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix WMM Queue naming

The Queue names were incorrectly copied from the legacy drivers,
as a result the queue names were inversed to what was expected.

This renames the queues using this mapping:
QID_AC_BK -> QID_AC_VO (priority 0)
QID_AC_BE -> QID_AC_VI (priority 1)
QID_AC_VI -> QID_AC_BE (priority 2)
QID_AC_VO -> QID_AC_BK (priority 3)

Note that this was a naming problem only, which didn't affect
the assignment of frames to their respective queues.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
5450b7e2f0b47e52175b31399d8186a74ef3c46d 13-Dec-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Introduce 3 queue commands in drivers (start, kick, stop).

As part of the queue refactoring, we now introduce
3 queue commands: start, kick, stop.

- Start: will enable a queue, for TX this will
not mean anything, while for beacons and RX
this will update the registers to enable the queue.
- Kick: This will kick all pending frames to
the hardware. This is needed for the TX queue
to push all frames to the HW after the queue
has been started
- Stop: This will stop the queue in the hardware,
and cancel any pending work (So this doesn't
mean the queue is empty after a stop!).

Move all code from the drivers into the appropriate
functions, and link those calls to the old rt2x00lib
callback functions (we will fix this later when we
refactor the queue control inside rt2x00lib).

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>
89b25f60e08180d7e00e6239398b467142aaec01 13-Dec-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Don't frequently reset beacon interval in AdHoc mode

Commit 0204464329c17ba6d293e1899f71223599a0e582 "Check for specific changed
flags when updating the erp config" changed the way in which a new beacon
interval gets handled. However, due to a bug in rt2800usb and rt2800pci the
beacon interval was reset during each scan, thus causing problems in AdHoc
mode.

Fix this by not cleaning up the beacon interval when killing the beacon queue
but just prevent the device from sending out beacons.

Reported-by: Wolfgang Kufner <wolfgang.kufner@gmail.com>
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>
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>
f44df18c58d4debe3ec0bb76a490aa2f3929fd8b 04-Nov-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Implement flush callback

Implement a basic flush callback function, which simply loops
over all TX queues and waits until all frames have been transmitted
and the status reports have been gathered.

At this moment we don't support dropping any frames during the
flush, but mac80211 will only send 'false' for this argument anyway,
so this is not important at this time.

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>
efd2f271e44c7ea011cdb0363d38f40338ab80d2 04-Nov-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Sync Tx and RX ring sizes with legacy drivers

All rt2x00 devices used the same Tx and Rx ring size (24 entries) till
now. Newer devices (like rt2800) can however make use of a larger TX and
RX ring due to 11n capabilities (AMPDUs of size 64 for example).

Hence, bring rt2x00 in sync with the legacy drivers and use the same TX
and RX ring sizes. Also remove the global defines RX_ENTRIES, TX_ENTRIES,
BEACON_ENTRIES and ATIM_ENTRIES and use per driver values.

That is 24 entries for rt2400pci, 32 entries for rt2500pci, rt2500usb,
rt61pci and rt73usb and 128 (RX) and 64 (TX) for rt2800pci and rt2800usb.

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>
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>
0204464329c17ba6d293e1899f71223599a0e582 08-Sep-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Check for specific changed flags when updating the erp config

Previously rt2x00 was always updating all erp related config variables
even though mac80211 might only have changed one. Hence, pass the
changed flags to the config_erp driver callback so that the driver
can limit the changes to the correct values.

This fixes an issue in AP mode where the beacon interval is not
initialized (and thus zero) but still sent to the hardware causing an
interrupt storm on rt2800pci hanging the system.

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>
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>
933314582ee5db00123683cf4c4d713ec9add306 23-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Simplify arguments to rt2x00 driver callback functions

write_tx_desc shouldn't pass a rt2x00dev and skb pointer,
instead it should use the same format as other TX frame
callback functions, which is passing the data_entry pointer
which contains all the information which is needed to work
on a TX frame.

Most callers of the kick_tx_queue and kill_tx_queue already
have the data_queue pointer, so rather then sending the QID
with the given function, when the driver requests a new
pointer to the data_queue, it is more efficient to just
send the data_queue pointer directly.

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>
baeb2ffab4e67bb9174e6166e070a9a8ec94b0f6 11-Aug-2010 Joe Perches <joe@perches.com> drivers/net: Convert unbounded kzalloc calls to kcalloc

These changes may be slightly safer in some instances.

There are other kzalloc calls with a multiply, but those
calls are typically "small fixed #" * sizeof(some pointer)"
and those are not converted.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Luciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
ab0ed4aba80f430fafd842cee8d74f6b40493483 11-Jul-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Remove set_tim callback from PCI drivers

Using the set_tim callback without managing the DTIM count and the
broad- and multicast buffering in hw, fw or the driver results in wrong
DTIM count values being sent out in beacons. Since all PCI drivers
fetch new beacons periodically and hence get an updated TIM we can just
remove the set_tim callback from these.

The rt2x00 USB drivers don't update the beacon periodically and thus
rely on the set_tim callback to get a correct TIM for beacon
transmission. USB devices still suffer from the DTIM count being wrong
under some circumstances but removing the set_tim callback from these
would cause more harm then good.

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>
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>
223dcc26591aa8e4a6bf623164b775b5bd89c9e1 11-Jul-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix vgc_level_reg handling

Currently vgc_level_reg and vgc_level are equal to eachother,
while the purpose of vgc_level_reg is the value last written
to the register and is remembered through link tuning resets.
The vgc_level is the currently active level, which is
reset during link tuning resets.

The usage of these variables depends on the drivers, some drivers
need both, while others need only one of the two.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d8147f9d9ed6abfa105234a21f05af4a4839eb80 11-Jul-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Disable link tuning while scanning

While scanning the link tuner must be disabled. Otherwise
it will interfere with receiving all beacons for each channel
due to changing sensitivity levels.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
27df2a9ce9ea6a77b9959cf5cc03ee85324aced9 11-Jul-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Rename CONFIG_DISABLE_LINK_TUNING

Rename CONFIG_DISABLE_LINK_TUNING to DRIVER_SUPPORT_LINK_TUNING
Link tuning support is not only based on EEPROM decisions, but
also if the device actually supports it.

Currently only rt2500usb doesn't support link tuning because
of hardware problems. But rt2800usb is also suspected of having
problems with link tuning.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
78eea11b0e6ae5771bc19cc46984f1cdcbbb6ba1 29-Jun-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Merge PCI and USB versions of write_tx_data into single function.

Now that rt2x00pci_write_tx_data and rt2x00usb_write_tx_data are similar
we can merge them in a single function in rt2x00queue.c.

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>
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>
5c3b685c79f38ac6b909b3650f3dad3993614cfb 03-Jun-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Push beacon TX descriptor writing to drivers.

Not all the devices require a TX descriptor to be written (i.e. rt2800
device don't require them). Push down the creation of the TX descriptor
to the device drivers so that they can decide for themselves whether
a TX descriptor is to be created.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
9655a6ec19ca656af246fb80817aa337892aefbf 13-May-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Fix failed SLEEP->AWAKE and AWAKE->SLEEP transitions.

(Based on a patch created by Ondrej Zary)

In some circumstances the Ralink devices do not properly go to sleep
or wake up, with timeouts occurring.
Fix this by retrying telling the device that it has to wake up or
sleep.

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>
85b7a8b3871bde7885516fed2a1c8da699913318 11-May-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Simplify TXD handling of beacons.

The handling of tx descriptors for beacons can be simplified by updating
write_tx_desc implementations of each driver to write directly to the
queue entry descriptor instead of to a provided memory area.
This is also a preparation for further clean ups where descriptors are
properly reserved in the skb instead of fiddling with the skb data
pointer.

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>
e01f1ec35ff91c8a3f4a3e48a0c8ab476124b973 11-May-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Re-order tx descriptor writing code in drivers.

Where possible, write the tx descriptor words from start to end, to
follow a logical ordering of words.
Where this is not possible (in rt2400pci, rt2500pci and rt61pci) add
a comment as to why word 0 needs to be written last.

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>
f224f4ef794c4a9146a7fa7303018fecab8c9328 08-May-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: provide beacon's txdesc to write_beacon callback function.

Preparation to fix rt2800 beaconing.

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>
d61cb26696e19494c049297def6c8f37d9e2f534 08-May-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Clean up all driver's kick_tx_queue callback functions.

All of the driver's kick_tx_queue callback functions treat the TX queue
for beacons in a special manner.
Clean this up by integrating the kicking of the beacon queue into the
write_beacon callback function, and let the generic code no longer call
the kick_tx_queue callback function when updating the beacon.

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>
df624ca5413d84b3082246de384823fbe8fed6e4 03-May-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Register frame length in TX entry descriptor instead of L2PAD.

And use it consistently in the chipset drivers.
Preparation for further clean ups.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5731858d0047cad309d334c4cd6ccb6199bf28fe 30-Mar-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Disable auto wakeup before waking up device.

In all drivers ensure that auto wakeup is disabled before waking up the device.
This is needed to prevent connection stability issues and problems in waking up
the device.

Based upon a patch from Ondrej Zary <linux@rainbow-software.org>

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Cc: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
49e721ec6ca74f90ee99089ad2de1c338a95c6d5 13-Feb-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: rework RT chipset and revision determination for PCI an SOC devices.

The recent rt2800 devices are no longer really identified by their PCI
ID's, but rather by the contents of their CSR0 register. Also for the
other chipsets is the contents of this CSR0 register important.
Change the chipset determination logic to be more aligned with the rt2800
model.
Preparation for the support of rt3070 / rt3090 based devices.

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>
714fa6636331d33c6045efe394f36c964a6c14ee 13-Feb-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Reorganize RT chipset setting for PCI/SOC devices.

Don't set the RT chipset for a device from within the generic PCI/SOC code,
but rather from the individual drivers, so that individual drivers have
more control over what RT chipset is set.
Preparation for chip handling updates for rt2800 devices.

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>
00a08eb62f790383bcc8ea309d4afb9ef346ef0b 07-Feb-2010 Kalle Valo <kalle.valo@iki.fi> rt2x00: remove get_tx_stats() mac80211 op

get_tx_stats() will be removed from mac80211.

Compile-tested only.

Signed-off-by: Kalle Valo <kalle.valo@iki.fi>
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>
a3aa18842a5303fc28fcc4d57dbd16618bd830a0 07-Jan-2010 Alexey Dobriyan <adobriyan@gmail.com> drivers/net/: use DEFINE_PCI_DEVICE_TABLE()

Use DEFINE_PCI_DEVICE_TABLE() so we get place PCI ids table into correct section
in every case.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5122d8986232ef2a761f5cf70c31666c4d65c3e4 23-Dec-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Cleanup chip handling helper functions.

Let each of them take a struct rt2x00_dev pointer as argument instead of
a mixture of struct rt2x00_chip and struct rt2x00_dev pointers.
Preparation for further clean ups in the rt2x00 chip handling, especially
for rt2800 devices.

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>
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>
04d0362e2fa9d5f1ab560d0d59d04a535b4f3973 23-Nov-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Whitespace cleanup.

Clean up the use of whitespace in the initialization of the rt2x00_ops
structures. This is preparatory for a later patch that adds members
to that structure, which require different whitespace alignment.

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>
16475b095a9c952f16e626c142b30bc95cfeadb3 14-Nov-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Log RT/RF chipset information correctly.

Some drivers (rt2800* most notably) cannot set the RF and RT chipset in
the correct order to have the information logging in rt2x00_set_chip
be correct.
Fix this by decoupling the setting of the chipset information from the
logging of the chipset information so that drivers can determine
themselves when all information is set.

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>
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>
4789666e13fb0b2d45feb1b4a5119a1b997ec84c 06-Sep-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Hardcode TX ack timeout and consume time

The calculated values for the ACK timeout and ACK
consume time are different then the values as
used by the Legacy drivers.

After testing from James Ledwith it appeared that
the calculated values caused a high amount of TX
failures, and the values from the Legacy drivers
were the most optimal to prevent TX failure due to
excessive retries.

The symptoms of this problem:
- Rate control module always falls back to 1Mbs
- Low throughput when bitrate was fixed

Possible side-effects (not confirmed but highly likely)
- Problems with DHCP
- Broken connections due to lack of probe response

This should fix at least:
Kernel bugzilla reports: [13362], [13009], [9273]
Fedora bugzilla reports: [443203]
but possible some additional bugs as well.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d6756d0dc220c3d12e2c4c06ca97d1dbcb5edf4e 10-Aug-2009 Igor Perminov <igor.perminov@inbox.ru> rt2x00: Fix beacon de-synchronization while update beacon

When beacon is being updated to refresh TIM (AP mode), beacon frames are
de-synchronizing (i.e. two neighbor beacon frames - before and after
update - are being transmitted with a wrong time interval).
That is because xxx_write_beacon should disable beacon generation only
while beacon data are being uploaded to the device, but it should not
disable the beacon clock.

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>
930c06f27120fa8cf0bfb6fa000a701cfaf01ed6 10-Jul-2009 Stefan Steuerwald <salsasepp@googlemail.com> rt2x00: Implement set_tim callback for all drivers

Implement set_tim callback for all rt2x00 drivers, this makes the
device wake up powersaving stations properly while in AP mode.

The only way to update the beacon is by simply calling mac80211 and
requesting the new beacon. This means the set_tim() event is mostly the
same as a beacon_done() event which was already defined in rt2x00lib.

Signed-off-by: Stefan Steuerwald <salsasepp@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
6b347bff145f9a8a0972ca8fc3c44dd1f91b0f16 23-May-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove last usage of beacon_int from ieee80211_config

This removes the last usage of beacon_int inside the iee80211_config
structure from rt2x00. The attempt is a bit hackish, and subject to
change in the future when the entire rt2x00_dev structure is
cleaned up and restructured.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8a566afea0639fc387add782bc799009512a911b 21-May-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove usage of IEEE80211_CONF_CHANGE_BEACON_INTERVAL

IEEE80211_CONF_CHANGE_BEACON_INTERVAL was deprecated a month ago,
it is about time to remove all usage from the rt2x00 drivers and
use the correct beacon interval configuration through the bss_info
structure.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2d0ddec5b2b859f06116f631fc0ffe94fbceb556 23-Apr-2009 Johannes Berg <johannes@sipsolutions.net> mac80211: unify config_interface and bss_info_changed

The config_interface method is a little strange, it contains the
BSSID and beacon updates, while bss_info_changed contains most
other BSS information for each interface. This patch removes
config_interface and rolls all the information it previously
passed to drivers into bss_info_changed.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
440ddadaee6d0d5e8a7ee53ac913f78a8e5570a1 28-Mar-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Move Move pci_dev specific access to rt2x00pci

pci_dev->irq and pci_name(pci_dev) access should be limited
to rt2x00pci only. This is more generic and allows a rt2x00 pci
driver to be controlled as PCI device but also as platform driver
(needed for rt2800pci SoC support).

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
53bc647a1a96189be53b68b9e8c40df0f42fc300 15-Feb-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove check for rf word 0

The only way rf_write() can be called with word 0 is
when the user sends the wrong word index through debugfs.
However the values which are send through debugfs are
validated using the RF_BASE and RF_SIZE macro values,
the most logical solution is to increase RF_BASE with 4
and decrease RF_SIZE with 4 (RF_SIZE has always been
1 word too big)

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
3d3e451ff71b4e951d4b522b460a94f36fb5b276 17-Jan-2009 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Add LED_MODE_ASUS support

When the led mode is asus, the activity led mode must
be registered otherwise the second LED will not be enabled.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
217875a37d4db3354c4c297d07b359abbf52e5e1 10-Jan-2009 Andrew Price <andy@andrewprice.me.uk> rt2400,rt2500: init led_qual for LED_MODE_DEFAULT

Add a check for LED_MODE_DEFAULT so that we use the link LED for rt2400
and rt2500 devices.

Signed-off-by: Andrew Price <andy@andrewprice.me.uk>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4be8c3873e0b88397866d3ede578503e188f9ad2 07-Jan-2009 Johannes Berg <johannes@sipsolutions.net> mac80211: extend/document powersave API

This modifies hardware flags for powersave to support three different
flags:
* IEEE80211_HW_SUPPORTS_PS - indicates general PS support
* IEEE80211_HW_PS_NULLFUNC_STACK - indicates nullfunc sending in software
* IEEE80211_HW_SUPPORTS_DYNAMIC_PS - indicates dynamic PS on the device

It also adds documentation for all this which explains how to set the
various flags.

Additionally, it fixes a few things:
* a spot where && was used to test flags
* enable CONF_PS only when associated again

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5352ff6510422d9a9bf13b7272f865eb53247f4d 20-Dec-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Restrict interface between rt2x00link and drivers

Restrict drivers to only access link_qual structure during
link tuning. The contents of these fields are for the drivers
and all fields are allowed to be changed to values the driver
considers correct.

This means that some fields need to be moved outside of this
structure to restrict access only to rt2x00link itself.
This allows some code to be moved outside of the rt2x00.h header
and into rt2x00link.c.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
eb20b4e8a6998ca68d9ac0963ee36a1a36fe241d 20-Dec-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Reduce calls to bbp_read()

The link_tuner() function will always call bbp_read()
at the start of the function. Because this is an
indirect register access has some costs attached
to it (especially for USB hardware).

We already store the value read from the register
into the vgc_level value inside the link structure.
Instead of reading from the register we can read that
field directly and base the tuner on that value.

This reduces the time the registers are locked with
the csr_mutex and speeds up the link_tuner processing.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7d7f19ccb777946df0a8fb7c83189ba2ae08b02e 20-Dec-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Implement Powersaving

Listen to IEEE80211_CONF_PS to determine if the device
should drop into powersaving mode. This feature depends
on the dynamic power save functionality in mac80211.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c9c3b1a5deac4297503145840fffcd122b253db5 10-Nov-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Cleanup indirect register access

All code which accessed indirect registers was similar
in respect to the for-loop, the given timeout, etc.
Move it into a seperate function, which for PCI drivers
can be moved into rt2x00pci.

This allows us to cleanup the cleanup the code further
by removing the goto statementsand making the codepath
look a bit nicer.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
bad13639a30e1557fbe9d440adc1906673c9de4e 09-Nov-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Optimize get_duration / get_duration_res

We can optimize get_duration and get_duration_res
by making them a macro. They are really simple
calculation handlers so this doesn't matter much.

Often (especially in rt2400pci and rt2500pci,
the arguments are hardcoded, and the result value
is passed into other hardcoded values.

By making the functions a macro GCC can
optimize the entire thing much better.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
743b97caf98036ec8ee4bfc6fc6f85ad94e04783 29-Oct-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove debugfs CSR access wrappers

Move calculation of CSR register offset into rt2x00debug.c
and remove the wrapper functions from each individual driver.
(Except rt2500usb, which still needs to wrap for the
different value type argument).

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e4ea1c403acece78c271bf9cd6f797d1cb093df9 29-Oct-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Optimize configuration handling

Implement latest changed from mac80211 configuration
handling to optmize configuration handling in rt2x00.

* Remove set_retry_limit callback function, handled
through config()
* Move config_antenna to its own callback function,
it isn't handled by mac80211 anymore
* Use IEEE80211_CONF_CHANGED_* flags and remove manual
checks
* Removed deprecated short slot setting through config()
and put it in config_erp() through which mac80211 now
configures it
* Remove config_phymode() and move contents to config_erp()
since it only managed the basic rates which is now
determined by mac80211 through config_erp().

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9124b07740c51cbc6e358dd0c4abc6ee8ded084d 14-Oct-2008 Johannes Berg <johannes@sipsolutions.net> mac80211: make retry limits part of hw config

Instead of having a separate callback, use the HW config callback
with a new flag to change retry limits.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e174961ca1a0b28f7abf0be47973ad57cb74e5f0 27-Oct-2008 Johannes Berg <johannes@sipsolutions.net> net: convert print_mac to %pM

This converts pretty much everything to print_mac. There were
a few things that had conflicts which I have just dropped for
now, no harm done.

I've built an allyesconfig with this and looked at the files
that weren't built very carefully, but it's a huge patch.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
771fd565195727d12f0b75d918b9fcb9f33a5476 08-Sep-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Make rt2x00 LEDS invisible config option

There isn't really a good reason to have the LED
configuration options selectable per driver, lets
make it default 'y' and make it depend on the
NEW_LEDS and LEDS_CLASS interface.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com
Signed-off-by: John W. Linville <linville@tuxdriver.com>
58169529986e81e0d477ce11eb8b91f025f649c1 08-Sep-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Make RFKILL enabled by default

RFKILL should be enabled for _all_ hardware whether
or not they feature a rfkill button or not.

Remove driver specific RFKILL configuration options
and make the rt2x00lib version depend on CONFIG_RFKILL
and defaulting to 'y' to make sure it will always
be enabled when RFKILL was enabled.

This also fixes some bugs where RFKILL wasn't initialized
and didn't respond to RFKILL key presses.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
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>
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>
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>
1f90916264049a7d9e6106fd60d289c9a775d24f 08-Jul-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Disable synchronization during initialization

As soon as init_registers() was called, the rt2400/rt2500
would start raising beacondone interrupts. Since this is highly
premature since no beacons were provided yet, we should
initialize the synchronization register to 0.

This will make all drivers initialize it to 0 regardless
if they are raising beacondone interrupts or not, since it only
makes sense to have it completely disabled.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
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>
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>
14a3bf89212b5c758bd39bb4afc972c4ba6d599f 16-Jun-2008 Gertjan van Wingerde <gwingerde@kpnplanet.nl> rt2x00: Convert rt2x00 to use generic DMA-mapping API

At the same time clean up the device administration a bit, by storing a pointer
to struct device instead of a void pointer that is dependent on the type of
device. The normal PCI and USB subsystem provided macros can be used to convert
the device pointer to the right type.
This makes the rt2x00 driver a bit more type-safe.

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>
d56d453a1dd85aff08fe6965f395049725fdb04e 06-Jun-2008 Gertjan van Wingerde <gwingerde@wingerd.gvw.nl> rt2x00: Cleanup struct skb_frame_desc.

The data and data_len fields aren't really necessary in struct
skb_frame_desc, as they can be deduced from the skb itself.

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>
b869767b6f5049f1d1ede2bb3e48832e0722ca5a 06-Jun-2008 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Don't kick TX queue after each frame

TX queues shouldn't be kicked after each frame that is put into the
queue. This could cause problems during RTS and CTS-to-self as well
as with fragmentation. In all those cases you want all frames to be
send out in a single burst. Off course we shouldn't let the queue fill
up entirely, thus we introduce a 10% threshold which, when reached,
will force the frames to be send out regardless of the frame.

In addition we should prevent queues to become full in such a way
that the tx() handler can fail. Instead of stopping the queue when
it is full, we should stop it when it is below the threshold.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
475433be3d8f4d840e2930eef96671b7f8d11053 03-Jun-2008 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Move led initialization into function

Reduce code duplication by moving led structure initialization
into a per-driver function.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
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>
aade5102c5390280e7ae8a43e09b8995792f66d8 10-May-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove extra +

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b8be63ffa5dc44324e7f507997870fa3e4b17619 10-May-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Merge RX and TX entry private data

With the pending removal of the tx_control structure
we can merge the RX and TX entry private data structure
in advance. This will temporarily increase the required
memory for the queue, but that overhead will only be limited.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
dec13b6bda600c7e7da993e634562873112af50b 10-May-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove redundant flags/dev_flags initializations

the rxdesc structure is properly memsetted before passed to
the driver. This means we don't have to reinitialize the flags
and dev_flags fields in the drivers again.
This will prevent problems when the rxdone handler is adding
flags in a earlier status and will make the code look nicer
when we are adding more read attributes in the rxdone handler
in the driver.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
4de36fe5abe077a4c65bf0b6a309865aa043e055 10-May-2008 Gertjan van Wingerde <gwingerde@kpnplanet.nl> rt2x00: Only initialize the minimum needed fields of PCI TX descriptors.

In preparation of replacing the statically allocated data DMA buffers with DMA-mapped
skb's we need to change the TXD handling of the PCI drivers, by moving the programming
of the buffer address fields to the actual TXD writing at TX time, instead of at start-up
time.

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>
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>
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>
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>
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>
e100bb64bf7cdeae7f742a65ee1985649a7fd1b4 30-Apr-2008 Johannes Berg <johannes@sipsolutions.net> mac80211: QoS related cleanups

This
* makes the queue number passed to drivers a u16
(as it will be with skb_get_queue_mapping)
* removes the useless queue number defines
* splits hw->queues into hw->queues/ampdu_queues
* removes the debugfs files for per-queue counters
* removes some dead QoS code
* removes the beacon queue configuration for IBSS
so that the drivers now never get a queue number
bigger than (hw->queues + hw->ampdu_queues - 1)
for tx and only in the range 0..hw->queues-1 for
conf_tx.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
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>
44a9809b97ec5acd1c549c3120bdd35613897d7c 21-Apr-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Don't enable short preamble for 1MBs

The timing settings for 1MBs should exclude
the short preamble bit since that only applies
to 2MBs, 5.5MBs and 11MBs.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
e0b005fa1479045fe879944036268af3ebcd1835 31-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: TO_DS filter depends on intf_ap_count

The TO_DS filter does not only depend on the FIF_PROMISC_IN_BSS flag
provided by mac80211, but also on the intf_ap_count count.
This makes sense, since when Master mode is active, we should all frames
that are send to the active AP (the device itself).

This means that when an interface is added we should force the
packet filter to be updated during the next mac80211 call of
configure_filter() to make sure the intf_ap_count field is checked.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3a643d244f09fa1fdd25d48a56a073c1a69583ee 25-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix in_atomic() usage

rt73usb and rt2500usb used in_atomic to determine
if a configuration step should be rescheduled or not.
Since in_atomic() is not a valid method to determine
if sleeping is allowed we should fix the way this is handled
by adding a new flag to rt2x00.

In addition mark LED class support for the drivers broken
since that also uses the broken in_atomic() method but
so far no solution exists to have LED triggers work only
in scheduled context.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
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>
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>
dac37d720860bbbc535adc90249184308501c1f0 09-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix RX DMA ring initialization

Due to a terrible typo the RX DMA base address
was initialized to the beacon base address.
Obviously bad things happen with bugs like that....

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
fd3c91c5e57eef8db71cf52e2473832c330bf5db 09-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Always enable TSF ticking

Whatever mode we are in, according to the legacy drivers
we should always enable TSF ticking/counting.
We should also always enable the TBCN/TBTT field,
this field is only disabled during beacon regeneration.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
a4fe07d913096f4573512c9369f8ca824fbc2d8f 09-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Start bugging when rt2x00lib doesn't filter SW diversity

rt2x00lib should filter SW diversity out before sending any configuration
changes to the driver. When rt2x00lib fails to do this, it is important
that such events are reported because it _must_ be fixed.
So upgrading the error level to a BUG_ON() which will make sure
this bug gets noticed whenever it happens.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
8af244ccb14a4367568db11c5e78b45a4c2cf77e 09-Mar-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Only disable beaconing just before beacon update

We should not write 0 to the beacon sync register during
config_intf() since that will clear out the beacon interval
and forces the beacon to be send out at the lowest interval.
(reported by Mattias Nissler).

The side effect of the same bug was that while working with
multiple virtual AP interfaces a change for any of those
interfaces would disable beaconing untill an beacon update
was provided.

This is resolved by only updating the TSF_SYNC value during
config_intf(). In update_beacon() we disable beaconing
temporarily to prevent fake beacons to be transmitted.
Finally kick_tx_queue() will enable beaconing again.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
ef8f66cd1d6f360340a73ee7ed0492ff0f5f42ea 17-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove reset_tsf()

Specifications indicate the TSF registers are read-only,
so there is no point in writing 0 to those registers.

As far as I know there isn't another way to reset the
TSF registers. So removing these callbacks will notify
mac80211 about the lack of support.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
30b3a23c2594e122e7086f97b5252a87eaf8a817 17-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix Descriptor DMA initialization

As Adam Baker reported the DMA address for the
descriptor base was incorrectly initialized in
the PCI drivers.

Instead of the DMA base for the descriptor, the
DMA base for the data was passed resulting in a
broken TX/RX state for PCI drivers.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
25fd893db26e90a1e9cf8ba151395766c70a69b3 10-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Make rt2x00 less verbose

Remove the debug messages regarding initialization from
EEPROM. The values are vendor specific, and are not really
needed for debug purposes. If they ever become usefull we
still have access to them through debugfs which also
prints the exact same values...

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
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>
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>
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>
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>
61667d8d5bf3c3ee09474069eaf4b93a4755ff8b 25-Feb-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Add link tuner safe RX toggle states

This adds 2 new states which both are used to toggle
the RX. These new states are required for usage
inside the link tuner thread, because the normal
RX toggling will stop the link tuner thread.
While it is possible that the link tuner thread itself
is the caller of the RX toggle (when using software
antenna diversity).

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
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>
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>
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>
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>
3867705bb773818b39e0ca8d02ccb71fb4d2ffb8 06-Jan-2008 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Only set the TBCN flag when the interface is configured to send beacons.

These flags used to be fixed to one in rt2500pci_config_type, which
caused the beacon timer interrupt to fire. This would lead to
rt2x00lib_beacondone adding work which called
rt2x00lib_beacondone_scheduled which called ieee80211_beacon_get which
printed an error about not having any beacon data.

With this patch, these interrupts are only generated when the interface
is configured to send beacons.

Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
49da2605e27935835861a118df0671b5f004bfac 27-Nov-2007 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Extend PLCP descriptor definition for rt2400pci

Extend word field definitions for the PLCP words
in the TX descriptor to contain the BBP fields as well.
This will remove rt2400pci_write_tx_desc() from the
checkstack script.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
3957ccb56e17ca839265ccb292c4c6850dcf5d32 12-Nov-2007 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Move duplicate code into rt2x00pci_txdone()

rt2400pci, rt2500pci and rt61 require different
txdone handling, but the code that pushes the frame
upstream and cleans up the entry is identical to
all of them.
This will create the function rt2x00pci_txdone()
to remove the duplicate code.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
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>
0e14f6d3e088473b411d35ff63737e46efb9e6df 27-Oct-2007 Adam Baker <linux@baker-net.org.uk> rt2x00: Unconstify rt2x00dev

Some register accesses need rt2x00dev to be non-const
they all need modifying so the prototype is consistent.

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
ddc827f93a2f2a7dcfda5b691d046af4dfe76427 13-Oct-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Cleanup if-statements

Cleanup if-statements for simple 1/0 register field values.

This also fixes a endian bug in rt2500usb when working
with the PHY_CSR2 initialization. As well as a bug
in the enabling of the LED in rt73usb.

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>
39e75857d08fe35ffad4dd9004580acf0d725b75 13-Oct-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: SW diversity should default to antenna B

Although ANTENNA_SW_DIVERSITY should never be send
to the driver, we should still handle it to prevent bugs.
But instead of defaulting to ANTENNA_HW_DIVERSITY we
should default to ANTENNA_B instead.

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>
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>
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>
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>
a137e202b0e47bca301d2315cca5c08140409ed7 06-Oct-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: get_duration expects values in 100kbs

get_duration expects all speeds to be passed in 100kbs,
this means that passing 2 is incorrect and should be raised to 20

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
feb24691e3e87a740caec4568be1a202db786f20 06-Oct-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Move TSF sync values into rt2x00config

All drivers use the same values for TSF sync,
this will move the value determination into rt2x00config.c,
and the definition for the values to rt2x00reg.h

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
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>
4abee4bbd771ce42b9a0a19be11264721aa0e3ed 06-Oct-2007 Ivo van Doorn <ivdoorn@gmail.com> [PATCH] rt2x00: Remove duplicate code in MAC & BSSID handling

The various drivers contained duplicate code to handle the
MAC and BSSID initialization correctly. This moves the
address copy to little endian variables to rt2x00config.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
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>
0795af5729b18218767fab27c44b1384f72dc9ad 04-Oct-2007 Joe Perches <joe@perches.com> [NET]: Introduce and use print_mac() and DECLARE_MAC_BUF()

This is nicer than the MAC_FMT stuff.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
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>