History log of /drivers/net/wireless/rt2x00/rt2800lib.c
Revision Date Author Comments
9d4f09b80fb69985eca86aaf4df195b80e3d02a8 14-Mar-2012 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Set IEEE80211_HW_REPORTS_TX_ACK_STATUS in rt2800

rt2800 already reports the tx ack status of each frame back to mac80211.
Advertise this by setting IEEE80211_HW_REPORTS_TX_ACK_STATUS for rt2800.
This allows some mac80211 features like frame loss notifications to work
with rt2800.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2ed7188447fd48336f296ce2dfbd35785768d28c 17-Feb-2012 John Li <chen-yang.li@mediatek.com> rt2x00:Add RT5372 chipset support

Signed-off-by: John Li <chen-yang.li@mediatek.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2e9c43dd45ced5bd77c94d4216f96b4a49448d73 16-Feb-2012 John Li <chen-yang.li@mediatek.com> rt2x00:Add VCO recalibration

Signed-off-by: John Li <chen-yang.li@mediatek.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
b6df7f1d3b0513529c496b7ef70f0f14b5177407 08-Feb-2012 John Li <chen-yang.li@mediatek.com> rt2x00:Add debug message for new chipset

Signed-off-by: John Li <chen-yang.li@mediatek.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
77c06c2cb44fe68295efdd33939153c7d56de004 06-Feb-2012 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Correctly set txmixer_gain in RT3572 channel switching.

Align with the v2.5.0.0 Ralink RT3572 driver.

Save the EEPROM txmixer_gain values inside the rt2800 driver data structure
and use it throughout the code.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
58b8ae14d58319bff63a30a9e1c0ebb9c07f2243 06-Feb-2012 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Fix RT3572 channel switch RFCSR 7 programming.

Align with the v2.5.0.0 Ralink RT3572 driver.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0cd461efcc1df6763b86b29ef4d6ee1cb923aa47 06-Feb-2012 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Align RT3572 channel switch RFCSR 1 programming with Ralink driver.

Align with the v2.5.0.0 Ralink RT3572 driver.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
569ffa56344e7e2a1d635a9c620215196f5c7298 06-Feb-2012 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Fix RFCSR 12 & 13 programming on RT3572 channel switching.

Align with v2.5.0.0 Ralink RT3572 driver for 2.4GHz band channel switch.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5d137dff36dce1eda0617a00eb87b57e48300045 06-Feb-2012 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Use saved BBP 25 and 26 values when configuring channel on RT3572.

This brings the rt2800 channel switching code for RT3572 closer to the
v2.5.0.0 Ralink RT3572 driver.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3a1c01288e5596fb70ca48ec9d9d8b561121c544 06-Feb-2012 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Use struct rt2x00_dev driver data in rt2800{pci,usb}.

Start using the struct rt2x00_dev driver data in rt2800 for the calibration
data.

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>
f1f12f9894c48dc8284762bc71e4a3ed5caf546f 30-Jan-2012 Stanislaw Gruszka <sgruszka@redhat.com> rt2800: radio 3xxxx: channel switch RX/TX calibration fixes

Synchronize code with Ralink driver:
2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO
Based on functions:
RT30xx_ChipSwitchChannel
RT33xx_ChipSwitchChannel
NICInitRT3370RFRegisters
and defines from:
include/chip/rt33xx.h

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
3e0c7643c561c7052430f5c033d5b1b1289c962e 30-Jan-2012 Stanislaw Gruszka <sgruszka@redhat.com> rt2800: radio 3xxx: add channel switch calibration routines

Synchronize code with Ralink driver:
2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO
Based on functions:
RT33xx_ChipSwitchChannel
RT30xx_ChipSwitchChannel

Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e3bab197622276faac83eac3dfb993967d8d47e3 30-Jan-2012 Stanislaw Gruszka <sgruszka@redhat.com> rt2800: radio 3xxx: program RF_R1 during channel switch

Synchronize code with Ralink driver:
2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO
Based on functions:
RT33xx_ChipSwitchChannel
RT30xx_ChipSwitchChannel
RT33xx_Init

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7f4666ab3fd656513bffd449410a4d7c189081ec 30-Jan-2012 Stanislaw Gruszka <sgruszka@redhat.com> rt2800: radio 3xxx: reprogram only lower bits of RF_R3

Synchronize code with Ralink driver:
2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO
(functions: RT33xx_ChipSwitchChannel() and RT30xx_ChipSwitchChannel())

Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
7fc417556473f15efac269523c17eb92103c6484 31-Jan-2012 Luigi Tarenga <luigi.tarenga@gmail.com> rt2800lib: fix wrong -128dBm when signal is stronger than -12dBm

This patch correct the type of variables containing the rssi
values read from the rxwi.

In function rt2800_agc_to_rssi() 3 variables (rssi0, rssi1, rss2)
defined as int was assigned a 16bit signed values as unsigned.
From a test with a hi-gain antenna I verified that the rxwi
contains signed rssi values in the range -13/+81 (inclusive)
with 0 as an error condition. In case of negative values a
condition is triggered and the function return -128dBm while
the signal is at its maximum. This patch correct the cast so
negative values are not treated as very high positive values
(ex. -13 does not become 243).

Signed-off-by: Luigi Tarenga <luigi.tarenga@gmail.com>
Reviewed-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4ed1dd2a7ec880b301beb61cbc1e08811ec340e4 24-Jan-2012 Stanislaw Gruszka <sgruszka@redhat.com> rt2800: disable DMA after firmware load

We can receive frames just after firmware load with current code, so
disable DMA just after firmware is loaded, not before.

Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0c17cf962d716ea7557d18679cc98b3a43efb46d 24-Jan-2012 Stanislaw Gruszka <sgruszka@redhat.com> rt2800usb: initialize H2M_INT_SRC register

Ralink USB driver initialize H2M_INT_SRC to 0 after firmware load, and
never touch this register later. It is not touched at all by Ralink PCI
driver.

Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5aa570159090b8bcf1357ef92386c24ff32d76d2 28-Dec-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Convert big if-statements to switch-statements.

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>
9931df2692ddb7db092550ce063e674730176ecf 22-Dec-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Mark active channel's survey data as "in use"

This is just a cosmetical fix since we only return survey data for the
active channel but it allows iw to show that the survey data is
for the currently used channel.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4883993841638963fbae2f334899f29309466152 24-Nov-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Pass BlockAck and BlackAckReq frames to mac80211 in monitor mode

Previously BlockAcks were always dropped by the rt2800 hardware while
BlockAckReqs were always accepted. However, both are only useful on
monitor interfaces at the moment and both are control frames. So
pass them up when mac80211 sets FIF_CONTROL.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
68fa64ef606bcee688fce46d07aa68f175070156 16-Nov-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Fix efuse EEPROM reading on PPC32.

Fix __le32 to __le16 conversion of the first word of an 8-word block
of EEPROM read via the efuse method.

Reported-and-tested-by: Ingvar Hagelund <ingvar@redpill-linpro.com>
Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
CC: <stable@vger.kernel.org>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.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>
daabead1c32f331edcfb255fd973411c667977e8 14-Sep-2011 Larry Finger <Larry.Finger@lwfinger.net> rtl2800usb: Fix incorrect storage of MAC address on big-endian platforms

The eeprom data is stored in little-endian order in the rt2x00 library.
As it was converted to cpu order in the read routines, the data need to
be converted to LE on a big-endian platform.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Stable <stable@kernel.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d331eb51e4d4190b2178c30fcafea54a94a577e8 14-Sep-2011 Larry Finger <Larry.Finger@lwfinger.net> rt2800pci: Fix compiler error on PowerPC

Using gcc 4.4.5 on a Powerbook G4 with a PPC cpu, a complicated
if statement results in incorrect flow, whereas the equivalent switch
statement works correctly.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: stable <stable@kernel.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d7d259d3a5e5975b8d0b67759f2632fbd0d508d2 08-Sep-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Use the available helper functions to initialize the WCID table

Use rt2800_config_wcid and rt2800_delete_wcid_attr to initialize the
WCID table instead of writing to the registers directly.

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>
af35323db6a177514ef6c77b961bf9db31648cd9 08-Sep-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Forbid aggregation for STAs not programmed into the hw

If a STA is not known by the hw (i.e. has no WCID assigned) don't allow
aggregation since this might mess up tx status reports and we won't be
able to distinguish the reports of multiple WCID-less STAs.

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>
a2b1328a23c57fbb9c51e6660a11049c35d151f9 08-Sep-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Make use of sta_add/remove callbacks in rt2800

This allows us to assign a WCID to each STA even for STAs without
crypto key.

To achieve this search for an unused WCID in the HW WCID table and
assign it to the according STA. When configuring a pairwise key for this
STA we don't need to write the MAC address and BSSIDX anymore but just
update the crypto related fields in the WCID_ATTR table.

This has two advantages:

1) Setting a new key for an already available STA (PTK rekeying) is
slightly less expensive and should improve performance in situations
where a lot of rekeying happens (e.g. a huge number of stations and/or
a small rekeying interval)

2) The TXWI now gets a WCID assigned for unencrypted frames which will
be reflected in the corresponding tx status report. This should make tx
status reports in unencrypted AP mode more reliable as we can
distinguish between multiple key-less STAs.

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>
550245b56c4a3746fdcbe051b4a75b60303cb531 07-Sep-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Remove incorrect led blink

rt2800 devices are not capable of configuring arbitrary LED on/off
periods. The LED_CFG register fields ON_PERIOD and OFF_PERIOD are only
used by the hw when the LED mode is set to "blink upon TX".

Hence, remove the blink callback. This will result in software emulation
for LED blinking.

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>
31937c423ed3a13613b3aa7459e7405dd428f2d8 07-Sep-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Minor optimizazion in txdone path

We can save an indirect function call + some instructions for fetching
the actual function pointer by passing the driver specific txwi pointer
directly from rt2800pci/rt2800usb to rt2800lib instead of using the
rt2800_drv_get_txwi callback.

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>
b52398b6e4522176dd125722c72c301015d24520 30-Jul-2011 Stanislaw Gruszka <sgruszka@redhat.com> rt2x00: rt2800: fix zeroing skb structure

We should clear skb->data not skb itself. Bug was introduced by:
commit 0b8004aa12d13ec750d102ba4082a95f0107c649 "rt2x00: Properly
reserve room for descriptors in skbs".

Cc: stable@kernel.org # 2.6.36+
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6403eab143205a45a5493166ff8bf7e3646f4a77 03-Jun-2011 Joe Perches <joe@perches.com> drivers/net: Remove unnecessary semicolons

Semicolons are not necessary after switch/while/for/if braces
so remove them.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8f66bbb5248c59b69b521b35e097ffa6cad07f01 18-May-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Move rt2800_txdone and rt2800_txdone_entry_check to rt2800usb.

These two functions are only used by rt2800usb so they don't have to be
in rt2800lib.

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>
872834dfb38edc6f72cfc783a5ce78f2a9f36ec5 18-May-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Add support for RT3572/RT3592/RT3592+Bluetooth combo card

(based on an earlier patch submitted by Shiang)

Add support for RT3572/RT3592/RT3592+Bluetooth combo card

Signed-off-by: Shiang Tu <shiang_tu@ralinktech.com>
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>
8f96e91fa53761fd63dceedac6bbe4b39e5c5072 18-May-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Don't disable G0 PA_PE bit in case of BT coexistence.

(split off from the earlier RT35xx patch submitted by Shiang)

Signed-off-by: Shiang Tu <shiang_tu@ralinktech.com>
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>
65f31b5e7029e55d4f7020a1d0b0658a50ea73cb 18-May-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Enable PA_PE bits in TX_PIN_CFG according to active band.

(split off from the earlier RT35xx patch submitted by Shiang)

There's no point in enabling the PA_PE bits for the bands that we are
not active on.

Signed-off-by: Shiang Tu <shiang_tu@ralinktech.com>
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>
aca355b9784fbc960c9caa6b30f953a965296420 04-May-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Initial support for RT5370 USB devices.

Add necessary RF chipset define and basic support for these devices.

Tested-by: Juan Carlos Garza <juancarlosgarza@gmail.com>
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>
fdbc7b0a262e24a3ee00f1f9acb5a97309a173d5 30-Apr-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Introduce capability flag for Bluetooth co-existence.

Use flag instead of re-reading the eeprom every time.

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>
9328fdac499b969ec57a195845f168e7c5168ccd 30-Apr-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Streamline rt2800 eeprom initialisations.

In rt2800lib.c the rt2800_init_eeprom function the same eeprom
words were read multiple times, due to inefficient ordering of the
eeprom checks.

Reorder the checks so that each EEPROM word only has to be read once.

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>
0e0d39e5f3a3e59c8513b59d4feeeadcb93b707d 18-Apr-2011 Johannes Stezenbach <js@sig21.net> rt2800usb: read TX_STA_FIFO asynchronously

Trying to fix the "TX status report missed" warnings
by reading the TX_STA_FIFO entries as quickly as possible.
The TX_STA_FIFO is too small in hardware, thus reading
it only from the workqueue is too slow and entries get lost.

Start an asynchronous read of the TX_STA_FIFO directly from
the TX URB completion callback (atomic context, thus it cannot
use the blocking rt2800_register_read()). If the async
read returns a valid FIFO entry, it is pushed into a larger
FIFO inside struct rt2x00_dev, until rt2800_txdone() picks
it up.

A .tx_dma_done callback is added to struct rt2x00lib_ops
to trigger the async read from the URB completion callback.

Signed-off-by: Johannes Stezenbach <js@sig21.net>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
961636ba17fa45b27ee4674430e1e775b8966b0e 18-Apr-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Update TX_SW_CFG2 init value

Bring the TX_SW_CFG2 initialisation for rt305x devices in sync with the
ralink legacy drivers.

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>
15a533c47f9ebb8dec8e440275136cbf9c493a1f 18-Apr-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Use correct TBTT_SYNC config in AP mode

This seems to fix problems with some powersaving clients since a
positive value in TBTT_SYNC_CFG_TBTT_ADJUST introduces beacon skew,
which is not wanted in AP mode.

Also update the rest of the TBTT_SYNC config according to the
legacy drivers in AP mode.

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>
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>
44704e5d7d56625ff93d5a119ca846ae4de9061c 18-Apr-2011 Layne Edwards <ledwards@astrumtech.net> rt2x00: Enable WLAN LED on Ralink SoC (rt305x) devices

This patch adds WLAN LED support to the mac80211 rt2x00 driver for
Ralink SoC (rt305x) devices. The current WLAN LED drivers in
rt2800lib.c set the LED brightness via an MCU request, but do nothing
for SoC. This patch checks for SoC and sets the register to enable the
WLAN LED (instead of an MCU request). This enables the WLAN LED for
RT305x devices.

Signed-off-by: Layne Edwards <ledwards@astrumtech.net>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f16d2db704b873d34cec54f992637f3579e10e08 28-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Fix tx aggregation problems with some clients

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

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

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

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

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

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

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

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
fa71a160272c0eec9c04102ab2a82befb7cb107f 28-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Indention cleanup in rt2800lib

Fix the indention in rt2800_compesate_txpower and also fix a typo in
the function name rt2800_compesate_txpower -> rt2800_compensate_txpower.

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>
2af242e19f06cfaade7ac8608c9df8af1e0fbb34 28-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Don't recalculate HT40 compensation for each rate

Previously the HT40 tx power compensation value was calculated for each
rate. However, the calculation is independent of the tx rate and as such
can be precalculated and just passed in for each rate.

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>
75faae8b80171b447bfc4bac448308676fb8a663 28-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Restructure bw_comp calculation

Move the HT40 check inside the calculation function to make it easier
for a later cleanup.

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>
25985edcedea6396277003854657b5f3cb31a628 31-Mar-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Fix common misspellings

Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
1ed3811c33d525be1c657261db1713f294c40c60 03-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Fix rt2800 key assignment in multi bssid setups

When setting up multiple BSSIDs in AP mode on an rt2800pci device we
previously used the STAs AID to select an appropriate key slot. But
since the AID is per VIF we can end up with two STAs having the same AID
and thus using the same key index. This resulted in one STA overwriting
the key information of another STA.

Fix this by simply searching for the next unused entry in the pairwise
key table.

Also bring the key table init in sync with deleting keys by initializing
the key table entries to 0 instead of 1.

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>
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>
5356d963304638735b4b53dfbded7a1c4ae0818d 03-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Add unlikely macro to special case tx status handling

This special case shouldn't happen very often. Only if a frame that
is not intended to be aggregated ends up in an AMPDU _and_ was intended
to be sent at a different MCS rate as the aggregate. Hence, using
unlikely is justified.

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>
11f818e0eb50864c7e6f8af38d8f8822f992906a 03-Mar-2011 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Optimize calls to rt2x00queue_get_queue

In some cases (tx path for example) we don't need to check for non-tx
queues in rt2x00queue_get_queue. Hence, introduce a new method
rt2x00queue_get_tx_queue that is only valid for tx queues and use it in
places where only tx queues are valid.

Furthermore, this new method is quite short and as such can be inlined
to avoid the function call overhead.

This only converts the txdone functions of drivers that don't use an ATIM
queue and the generic tx path.

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>
adde5882bc6c21de7ee80ee15dfd58c7e9a472ac 03-Mar-2011 Gabor Juhos <juhosg@openwrt.org> rt2x00: fix whitespace damage in the rt2800 specific code

The rt2800 specific code contains a lots of whitespace damage caused by
the commit 'rt2x00: Add support for RT5390 chip'.

This patch fixes those whitespace errors.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
60687ba710359f32343b7630dc05d3811ef5bf4c 20-Feb-2011 RA-Shiang Tu <Shiang_Tu@ralinktech.com> rt2x00: Add support for RT5390 chip

Add new RT5390 chip support

Signed-off-by: Shiang Tu <shiang_tu@ralinktech.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
fe59147c4f42a491a77b788571c37f0a0be6f41d 20-Feb-2011 Shiang Tu <shiang_tu@ralinktech.com> rt2x00: Add/Modify the GPIO register definition

Revise/Add GPIO register related definitions

Signed-off-by: Shiang Tu <shiang_tu@ralinktech.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
6f492b6d38e18f8d023137231c5d717068deb28d 20-Feb-2011 Shiang Tu <shiang_tu@ralinktech.com> rt2x00: Add/Modify protection related register definitions

Make the definition of protection related registers more precisely

Signed-off-by: Shiang Tu <shiang_tu@ralinktech.com>
Acked-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>
e90c54b2358559bd305ff08096e077d2a7f02bf3 20-Feb-2011 RA-Jay Hung <Jay_Hung@ralinktech.com> rt2x00: Fix rt2800 txpower setting to correct value

TX_PWR_CFG_* setting need to consider below cases
-compesate 20M/40M tx power delta for 2.4/5GHZ band
-limit maximum EIRP tx power to power_level of
regulatory requirement

Signed-off-by: RA-Jay Hung <jay_hung@ralinktech.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d96aa640967ab10641a0a389a4a1569efa54ac72 20-Feb-2011 RA-Jay Hung <Jay_Hung@ralinktech.com> rt2x00: Add antenna setting for RT3070/RT3090/RT3390 with RX antenna diversity support

For RT3070/RT3090/RT3390 with RX antenna diversity support, we must select
default antenna using gpio control way even if we do not turn on
antenna diversity feature.

Seperate the meaning of TX/RX chain and antenna. Some chips use
2x2 TX/RX chain but may have 3 RX antennas or 1x1 TX/RX chain
but may have 2 RX antennas to do antenna diversity.

Signed-off-by: RA-Jay Hung <jay_hung@ralinktech.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d76dfc612b40b6a9de0a3fe57fe1fa3db7a1ae3b 14-Feb-2011 Seth Forshee <seth.forshee@canonical.com> rt2x00: Check for errors from skb_pad() calls

Commit 739fd94 ("rt2x00: Pad beacon to multiple of 32 bits")
added calls to skb_pad() without checking the return value,
which could cause problems if any of those calls does happen
to fail. Add checks to prevent this from happening.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
10026f77b3555af13e43b8de0a91ad94cd2119d7 30-Jan-2011 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Copy the MAC address to the WCID entry properly.

Use the specific mac field of the wcid_entry structure to copy the MAC
address to, instead of just overwriting the structure.
Previous code resulted in the same, but this form is cleaner.

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>
c6fcc0e5f72ef6ad61e1d58cf99e27661ee206e4 30-Jan-2011 RA-Jay Hung <jay_hung@ralinktech.com> rt2x00: Correct initial value of US_CYC_CNT register for pcie interface

CLOCK CYCLE: Clock cycle count in 1us
PCI:0x21, PCIE:0x7d, USB:0x1e

Signed-off-by: RA-Jay Hung <jay_hung@ralinktech.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>
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>
0b01f030d38e00650e2db42da083d8647aad40a5 18-Jan-2011 Johannes Berg <johannes.berg@intel.com> mac80211: track receiver's aggregation reorder buffer size

The aggregation code currently doesn't implement the
buffer size negotiation. It will always request a max
buffer size (which is fine, if a little pointless, as
the mac80211 code doesn't know and might just use 0
instead), but if the peer requests a smaller size it
isn't possible to honour this request.

In order to fix this, look at the buffer size in the
addBA response frame, keep track of it and pass it to
the driver in the ampdu_action callback when called
with the IEEE80211_AMPDU_TX_OPERATIONAL action. That
way the driver can limit the number of subframes in
aggregates appropriately.

Note that this doesn't fix any drivers apart from the
addition of the new argument -- they all need to be
updated separately to use this variable!

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
80d184e6cfb1ba7371152c4c91652d770c9caddb 10-Jan-2011 RA-Jay Hung <jay_hung@ralinktech.com> rt2x00: Fix and fine-tune rf registers for RT3070/RT3071/RT3090

Basically fix and fine-tune RT3070/RT3071/RT3090 chip RF initial value
when call rt2800_init_rfcsr

Signed-off-by: RA-Jay Hung <jay_hung@ralinktech.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>
7f6e144fb99a4a70d3c5ad5f074204c5b89a6f65 10-Jan-2011 RA-Jay Hung <jay_hung@ralinktech.com> rt2x00: Fix radio off hang issue for PCIE interface

PCI/PCIE radio off behavior is different from SOC/USB.
They mainly use MCU command to disable DMA, TX/RX and enter power saving mode.

Signed-off-by: RA-Jay Hung <jay_hung@ralinktech.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
739fd9405416e22732e46a9226a8cac379bd57fc 13-Dec-2010 Wolfgang Kufner <wolfgang.kufner@gmail.com> rt2x00: Pad beacon to multiple of 32 bits.

Pad beacon to a multiple of 32 bits in preparation for the change
from memcpy_toio() to __iowrite32_copy() in register_multiwrite().

Signed-off-by: Wolfgang Kufner <wolfgang.kufner@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>
977206d79fdc9fc1b153e0b52c56e0be59586f37 13-Dec-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Implement get_survey callback for rt2800

Implement the get_survey callback to allow user space to read statistics
about the current channel condition.

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>
38c8a566fcfe080c910bb6b348d40121df2b8e88 13-Dec-2010 RA-Jay Hung <Jay_Hung@ralinktech.com> rt2x00: Add rt2800 EEPROM definition

Add and modify NIC Configuration and LED definition of EEPROM

Signed-off-by: RA-Jay Hung <jay_hung@ralinktech.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>
f4e16e41d62ddc75704a0344567a807ebb41a929 21-Nov-2010 Joe Perches <joe@perches.com> rt2x00: Use static const

Using static const generally increases object text and decreases data size.
It also generally decreases overall object size.

text data bss dec hex filename
40197 56 8336 48589 bdcd drivers/net/wireless/rt2x00/rt2800lib.o.new
40205 56 8336 48597 bdd5 drivers/net/wireless/rt2x00/rt2800lib.o.old

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f93bc9b3ce379800b30b3c2f4fc945ae35a80039 13-Nov-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Add initial support for RT3370/RT3390 devices.

Modified from Eddy's patch by adding the RT3370 USB support as well.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Cc: Eddy Tsai <Eddy_Tsai@ralinktech.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
bf1b15125e2aa245ddd9348f80d041d4f1fd13a9 06-Nov-2010 Mark Einon <mark.einon@gmail.com> rt2x00: checkpatch.pl error fixes for rt2800lib.c

rt2800lib.c:831: ERROR: inline keyword should sit between storage class and type

Signed-off-by: Mark Einon <mark.einon@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
fa8b4b22d543b4052602b0c86065150613ed19e8 04-Nov-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Fix hw crypto in AP mode for some devices

The BSSID register shouldn't be set in AP mode on some older devices (like
rt73usb) as it breaks hw crypto on these. However, rt2800 devices explicitly
need the BSSID register set to the same value as our own MAC address (only
in AP mode).

Hence, don't set the BSSID from rt2x00lib but move it down into rt2800 to
avoid problems on older devices.

This fixes a regression (at least for rt73usb) and avoids a new regression
for rt2800 devices in 2.6.36.

Reported-by: Johannes Stezenbach <js@sig21.net>
Reported-by: Lee <lee-in-berlin@web.de>
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>
2b23cdaa3b0e9567597563e5a7a5103ecda447f0 04-Nov-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Reduce tx descriptor size

The tx descriptor values qid, cw_min, cw_max and aifs are directly
accessible through the tx entry struct. So there's no need to copy
them into the tx descriptor and passing them to the indiviual drivers.
Instead we can just get the correct value from the tx entry.

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>
08e5310028359de2daaa39cd10e9ca493c51792b 04-Nov-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Wait up to one second on rt2800 for WPDMA to be ready

At least some devices need such a long time to inititalize WPDMA. This
only increases the maximum wait time and shouldn't affect devices that
have been working before.

Reported-by: Joshua Smith <jesmith@kaon.com>
Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
961621abee08fde2328daf6f8000e1059e5205e9 04-Nov-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Add TXOP_CTRL_CFG register definition

Remove the magic value initialisation of the TXOP_CTRL_CFG register by
defining its fields and using them during intialisation. The field
RESERVED_TRUN_EN is referred to as reserved, however it is set to 1 by
the legacy drivers. Hence, do the same.

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>
ff6133becae9ae1657fcff339a160a21448fa11c 09-Oct-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Use proper type for rxwi_w2 in rt2800_agc_to_rssi

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>
b34793ee27aa547fc9b4213f89036c9a0ecaad5d 02-Oct-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Work around hw aggregation oddity in rt2800

If a frame is not meant to be sent as AMPDU or part of it the hw might
still decide to aggregate this frame if a previous frame started an
AMPDU. However, this will limit the usefulness of the reported tx rate
since the reported rate will be the one specified in the TXWI of the
first frame and thus it is not possible to reliably caculate the
number of retrys by substracting the reported tx rate from the tx rate
in the TXWI.

To fix this issue, only report the successful rate for frames that were
not meant to be aggregated but ended up in an aggregate.

Example:
Frame A (MCS7, AMPDU=1) B (MCS7, AMPDU=1) C (MCS12, AMDPU=0, PROBE_RATE)

Although frame C shoudn't be aggregated the hw might sill put it
into an AMPDU together with A and B. If the transmission succeeds the tx
status will contain MCS7 for all three frames. In that case we should
only report MCS7 as success rate and avoid reporting MCS12-MCS8 as
failed tx attempts as this will affect the future rate control
decisions.

This oddity might strike us in other scenarious as well but the most
common "wrong" report happened for frames used to probe a different tx
rate.

This improves the rate control decisions notable.

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>
58ed826e5fb6db429c688284623ca62cb45b9d5c 02-Oct-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Enable rx aggregation in rt2800

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>
bc8a979e2d85c2bdd507a8b6b09fdafc11ebd73a 02-Oct-2010 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Improve TX status entry validation

The TX_STA_FIFO contains some information for identifying
a outgoing frame, however matching by WCID and ACK status is
not sufficient to 100% identify the macthing queue_entry structure
(containing the SKB buffer) which belongs to the status report.

Within TX_STA_FIFO we have a 4-bit field named PACKETID, which is
currently used to encode the queue id. The queue ID is however
limited to values from 0 to 3, which means 2 bits are sufficient
to encode the value. With the remaining 2 bits we can encode a
partial queue_entry index number. The value of PACKETID is not
allowed to become 0, with the queue ID ranging from 0 to 3, at least
one of the bits for the entry identification must be 1.

That leaves us with 3 possible values we can still encode in the
bits. Altough this doesn't allow 100% accurate matching of the
TX_STA_FIFO queue to a queue_entry structure, it at least improves
the accuracy. This allows us to better detect if we have missed the
TX_STA_FIFO report, which in turn reduces the number of watchdog
warnings regarding the TX status timeout.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ba3b9e5e8c7a12d8ea46cb4a8217c2e9b0720e9c 02-Oct-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: correctly set max_report_rates in rt61pci and rt2800

rt61pci and rt2800 devices can use up to 7 different rates per tx frame.
However, the device uses a global fallback table. Hence, the rc
algortihm cannot specify multiple rates to try but the device is able to
report multiple rates (based on the retry table). Specify that behavior
by correctly setting max_report_rates and max_rates.

This makes rt2x00 and minstrel play nicer together.

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>
5a5b6ed6ce46be128f2a5a9e56f47193c3ac3e32 02-Oct-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Don't enable broad- and multicast buffering on USB devices

Since rt2x00 USB devices have no chance to know when a beacon was sent
out in AP mode currently all broad- and multicast traffic is buffered in
mac80211 but never sent out at all.

Unfortunately we have no chance in sending the traffic out after a
DTIM beacon due to hw limitations. Hence, instead of never sending the
buffered traffic out better send it out immediately.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Reported-by: Lauri Hintsala <lauri.hintsala@bluegiga.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
d13a97f07d86f462096007dbf0f2e0338692abc0 02-Oct-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Don't initialize MM40 HT protection to RTS/CTS on PCI devices

Since HT protection is now configurable via mac80211 we don't need this
special case for PCI devices anymore. The HT protection config will be
overwritten as soon as mac80211 sends us a HT operation mode. Hence,
bring the HT MM40 protection config in sync with the other HT protection
registers and initialize it to no protection.

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>
87c1915d2c271a8998a79f16bcf5353e2c28db45 02-Oct-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Implement HT protection for rt2800

Update the HT operation mode when mac80211 sends it to us and set
the different HT protection modes and rates accordingly. For now
only use CTS-to-self with OFDM 24M or CCK 11M when protection is
required.

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>
144333313b156a9e99d80e39e034a3cba00adeaf 02-Oct-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Split out parts of the rt2800_txdone function for easier reuse

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>
2a0cfeb826df6751933fd95a797ac18371992c3b 02-Oct-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Don't overwrite beacon buffers in pairwise key setup

rt2800 devices use parts of the pariwise key table to store the beacon
frames for beacon 6 and 7. To not overwrite the beacon frame buffers
limit the number of entries we store in the pairwise key table to 222.

Also add some descriptive comments about this shared memory usage.

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>
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>
47ee3eb1359a5444efd9f529e3d28c02e8e405e7 08-Sep-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Initialize AMPDU_BA_WINSIZE register

Since we're not using the AMPDU_BA_WINSIZE register to force the BlockAck
window size (we specify it in every TXWI) we should initialize it to 0.

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>
c600c826a6f4e35512955a5e9a22b0baa741b455 30-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Don't set unicast/BSSID masks when clearning MAC or BSSID

When configuring the MAC_ADDR or MAC_BSSID with an empty address,
the UNICAST_TO_ME_MASK and BSS_ID_MASK must also be reset to prevent
invalid interpretation of the addresses.

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>
b9eca24209a59ef0a8c3cbbbb94b8c76d4b3aae3 30-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Wakeup hardware before loading firmware

According to the legacy drivers the AUTOWAKEUP_CFG
register must be reset to 0 before loading the firmware.

Instead of during rt2800{pci,usb}_write_firmware it
must actually be done in rt2800_load_firmware() before
resetting the WPDMA_GLO_CFG and PWR_PIN_CFG registers.

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>
3613884d96b186f58a77af05122f84167604aad9 30-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Validate TX status results with current data entry

Instead of printing a warning when the PID, ACK, or WCID of
an entry don't match the TX status report, we should skip the
entry to search for the entry which actually does match
the TX status data.

This reduces the number of watchdog errors on the TX queues
for rt2800usb, and seems to improve the reliability of the
TX flow a bit.

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>
5ffddc498c700bb45ea55efc37746cb28d601766 30-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Add rt2800_wait_csr_ready

Similar to rt2800_wait_wpdma_ready() we can add a
function to waiting until the CSR is ready. This
centralizes some additional code into rt2800lib.

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>
a908a743822d2eed2d8394bb607bb9db5934dcfc 30-Aug-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Rename txentry_desc.queue -> txentry_desc.qid

Variables containing queue ids are called qid everywhere else, hence
rename the queue field in txentry_desc to qid as well.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
46323e112ce2a0fdaf2dd5389f95b248576b8fda 23-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix channel configuration for RF3052

We missed a check for RF3052 in the config_channel
configuration function. As a result the channel is not
properly configured for RF3052 devices. This also
requires rt2800_config_channel_rf3xxx to support 5GHz
channels, so we must apply the TXPOWER_A_TO_DEV and
TXPOWER_G_TO_DEV conversions during rt2800_config_channel()

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>
b9a07ae9d9e09662013992088fd58ffbcb2f9a30 23-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Merge rt2800{pci/usb} radio enabling/disabling code to rt2800lib

The functions rt2800pci_enable_radio and rt2800usb_disable_radio are
almost equal and can be merged into rt2800lib. This reduces the number
of functions which must be exported from rt2800lib to the drivers at
the same time.

Also rt2800pci_disable_radio and rt2800usb_disable_radio are almost
equal and can be merged into rt2800lib in a similar fashion.

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>
21595bd50dd1ef16cf0dce33835caaf5ab458d4c 23-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix rt2800 retry calculation

The retry count for a frame is calculated by the realized MCS rate
subtracting of the requested MCS rate. However during TX done reporting
we accidently override the requested MCS rate with the realized MCS
rate. This causes the retry count to be reset to 0 always, and feeding
invalid rate information into minstrel_ht.

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>
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>
e5ef5bad345f97f1fef7ccdc01a88c298629a5d9 06-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Remove ieee80211_rx_status from rt2x00_dev

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

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

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
96481b20f4d6df7021867ae9a9deaa989ec32e40 06-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Implement TX status reporting for rt2800usb

The TX_STA_FIFO register which is used for per-frame TX frame
status reporting is also valid on rt2800usb. We can move the
rt2800pci_txdone function into rt2800lib where it can also
be used by rt2800usb.

rt2800usb needs to overwrite the txdone work handler to
a different function.

Both rt2800usb as rt2800_txdone need to take into account
that IO failures can occur while uploading the URB, which
means that when obtaining the new entry the IO status must
be checked.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
0c5879bc62f9b8eb31520a86213466f3a68ec794 06-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Request TXWI pointer from driver

The only reason why the write_tx_data callback function
is needed inside the driver, is because the location of
the TXWI descriptor is different on PCI and USB hardware.
Except for the beacon, where the TXWI is always at the
start of the SKB buffer.

In both cases the drivers write_tx_data function only
wrap around the function rt2800_write_txwi. Move write_tx_data
completely into the rt2800lib library, and add a callback
function to obtain the TXWI pointer.

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>
84804cdca043e2315bf5eae60807ac105929073f 06-Aug-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Set MIMO PS flag in tx descriptor for STAs in dynamic SMPS mode

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>
f31c9a8c1380e20e95d06925f2e42baf61af4db7 11-Jul-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Move common firmware loading into rt2800lib

Large parts of the firmware initialization are shared
between rt2800pci and rt2800usb. Move this code into
rt2800lib.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ab8966ddc2f7fa3e631efa7478ea2c76d6c9942f 11-Jul-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Add missing TSF sync mode for AP operation

Currently rt2x00 uses the TSF_SYNC_BEACON mode for all beaconing
interface types. However, TSF_SYNC_BEACON is meant for IBSS networks and
thus implements TSF merging in the hardware. Rename TSF_SYNC_BEACON to
TSF_SYNC_ADHOC to better express its purpose and introduce the missing
TSF sync mode TSF_SYNC_AP_NONE which should be used for beaconing modes
that don't need TSF merging.

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>
8544df327c4c1c2bc6f2f6bf2997980d0d9a29f0 11-Jul-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Don't initialize beacon interval to 0 on rt2800 devices

Activating the TBTT interrupt when a beacon interval of 0 is configured
results in an interrupt storm causing the machine to hang. Hence,
initialize the beacon interval to a reasonable default of 100TUs.

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>
e783619ea8f1fb9fccec4931b0cf956de0ed1019 11-Jul-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Use separate mac80211_ops for rt2800pci and rt2800usb

Use separate mac80211_ops for rt2800pci and rt2800usb in preparation
for further fixes. This shouldn't introduce functional changes.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9f926fb57a2eb14d58ea6d6699544f9ccd0df8c7 11-Jul-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Use pretbtt irq for fetching beacons on rt2800pci

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

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

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
50e888eae23dc062cb52a7538e85a5960ce1d91c 11-Jul-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Make rt2800_write_beacon only export to GPL

rt2800_write_beacon is the only function which uses
EXPORT_SYMBOL instead of EXPORT_SYMBOL_GPL. All symbols
in rt2x00 should however use the GPL restricted export.

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>
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>
748619220651a33c260ed6c0a7648e69324edd74 11-Jul-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Convert AGC value from descriptor to RSSI (dBm)

The RSSI values in the RXWI descriptor aren't true RSSI
values. Instead they are more like the AGC values similar
to rt61pci. And as such, it needs the same conversion
before it can be passed to rt2x00lib/mac80211.

This requires the struct queue_entry to be passed to
rt2800_process_rxwi rather then the skb structure which
is contained in the queue_entry. This is required to
obtain the lna_gain information from the rt2x00_dev structure.

This fixes connection problems when using wpa_supplicant
which would try to connect to the worst AP's rather then the
best ones.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5e846004914d2295e020edd48a828b653323f93e 11-Jul-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Limit txpower by eeprom values

Limit the txpower per rate by the approriate values in the eeprom.
This avoids too high txpower values resulting in bad tx performance.

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>
4e9e58c6bf6512a1812556188b67bada6a09c0e8 29-Jun-2010 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Fix compile warning when debug disabled

CC [M] drivers/net/wireless/rt2x00/rt2800lib.o
drivers/net/wireless/rt2x00/rt2800lib.c: In function 'rt2800_ampdu_action':
drivers/net/wireless/rt2x00/rt2800lib.c:2821: warning: unused variable 'rt2x00dev'

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>
efc7d36f0d100eb2f2db33bc287fa17646bdcd7d 29-Jun-2010 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Always set BBP_CSR_CFG_BBP_RW_MODE to 1

Latest rt2870 legacy driver also sets BBP_CSR_CFG_BBP_RW_MODE to 1
when reading or writing the EEPROM. This means we can make the
BBP reading and writing completely equal on all platforms.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e22557f2e3bdf0b56c2592c9aeb50f17945f71b0 29-Jun-2010 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Fix antenna initialization

Legacy driver indicates that BBP1_TX_ANTENNA must be set
to 0 for TXPATH values of 1 and 3. So the previous statement
that nothing should be done for TXPATH = 3, is false.

Furthermore, remove the false BBP3_RX_ANTENNA initialization
when TXPATH is 1 for PCI and SOC devices. This field will always
be overridden in the next switch statement, making this initialization
bogus. History of this line indicates it was there from the beginning,
and was once caught as typo. Instead of replacing the line with the
correct line, the correct line was added...

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>
aa674631efabfb21f573137da9b84ff905ba66d8 29-Jun-2010 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Fix IEEE80211_HT_CAP_RX_STBC assignment

IEEE80211_HT_CAP_RX_STBC is a 2 bit flag, and should thus
never be set as normal flag. Instead we must read the number
of RX paths from the EEPROM and set the IEEE80211_HT_CAP_RX_STBC
with the correct value (using the same logic as the number of TX
streams).

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
fdb87251229be046b2b61fd15320320f7b66853b 29-Jun-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: fix beacon reset on rt2800

When an interface is removed the according beacon entry should be reset.
The current approach to only clear the first word is not enough to stop
the device from sending out the beacon, hence resulting in beacons being
sent out for already removed interfaces.

Fix this by invalidating the entire TXWI in front of the beacon instead
of only the first word.

Also clear all beacons during startup in the same way.

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>
d440cb9eb1c9c44a811f0b23dff684347d1016e0 29-Jun-2010 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Enable multiBSS in rt2800

MAC_BSSID_DW1_BSS_ID_MASK must be set to the mask 3, to
enable 8 BSSID's. The MAC_BSSID_DW1_BSS_BCN_NUM is initialized
to 7 to enable the 8 beacons.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Tested-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
ec2d1791a04e6f25cc55f87ddf6eaa51b2a811f7 29-Jun-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Align rt2800 EEPROM validation to Ralink vendor driver.

Align with the latest versions of the Ralink legacy driver(s).

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>
1df90809f79b765fd4e8868c2b182d948f198a17 29-Jun-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Implement tx mpdu aggregation

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

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

For now, refuse requests to start rx aggregation.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
e4a0ab3487d847ce8044a2d49f82391ea7d6489e 14-Jun-2010 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Synchronize WCID initialization with legacy driver

Legacy rt2870 driver handles WCID differently then we expected,
the BSSID and Cipher value are 3 bit values, while the 4th bit
should be set elsewhere in an extended field.

After this, rt2800usb reports frames have been decrypted
successfully, indicating that the Hardware decryption now is
working correctly.

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>
a5ea2f0255fe48af4864b41385fc28b4bc785ba6 14-Jun-2010 Ivo van Doorn <IvDoorn@gmail.com> rt2x00: Update author rt2800lib

rt2800lib has been under development of the rt2x00 project,
so add it to the author string for the module information.

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>
3f2bee249926194313f7001bdfedb9c9634a48fc 14-Jun-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: provide mac80211 a suitable max_rates value

Set up max_rates and max_rate_tries with suitable values even if we do not
support the whole functionality.

As rt2800 has a global fallback table we cannot specify more then one tx rate
per frame but since the hw will try several different rates (based on the
fallback table) we should still initialize max_rates to the maximum number of
rates we are going to try. Otherwise mac80211 will truncate our reported tx
rates and the rc algortihm will end up with incorrect data choosing unsuitable
rates for tx.

This improves throughput on rt2800 devices considerable.

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>
a3f84ca4b8dc31d0034a8b23194a4470766c938c 14-Jun-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Fix typo in rt2800_config_txpower

Fix typo in rt2800_config_txpower.

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>
6e387aa420bb8cd2bde522352c7930a1bfc24b0c 03-Jun-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Remove suspicious register write

Remove suspicious register write as the reg variable is never filled
with an TX_SW_CFG2 associated value before.

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>
c295a81d0553ab91b196f392ff2c7378ab9d94c4 03-Jun-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: Update TX_SW_CFG initvals for 305x SoC

Update TX_SW_CFG initvals for 305x SoC to match with the appropriate
legacy driver.

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>
22cabaa6b84dc617dda096641c359eebfb32b6cc 03-Jun-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: rt2800: disable TX STBC for 1 stream devices

Disable TX STBC for 1 stream devices as a minimum of 2 streams is needed for TX STBC.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
06443e46c65915d74b03fe1de10c00748e4706ee 03-Jun-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Fix HT40 operation in rt2800.

Closer inspection of the legacy Ralink driver reveals that in case of HT40+
or HT40- we must adjust the frequency settings that we program to the device.
Implement the same adjustment in the rt2x00 code.

With this HT40 seems to work for all devices supported by rt2800pci and
rt2800usb.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
e3a896b9924d6dcd88ad16186d7ec77f32d12ef8 03-Jun-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Move PCI/USB specific register initializations to rt2800{pci,usb}.

This prevents us having common code depend on PCI or USB specific code.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
8440c292798a6a7dc70356df80de84e0082bd99d 03-Jun-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Simplify check for external LNA in rt2800_init_rfcsr.

Instead of parsing the EEPROM information, use the flag that was set during
device initialization.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
785c3c06fb8f4bc3a8bb6ff39e8f6a70f889bde9 03-Jun-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Move all register definitions for rt2800 to rt2800.h.

There is no point on having them separated across 3 files.
At the same time rename USB_CYC_CFG to its proper name US_CYC_CNT
(as per the datasheet).

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
5ed8f4582ae70cea53a86196411bd675e28e6a76 03-Jun-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Remove RT2870 chipset identification.

There is no evidence, either in adapters or in the Ralink code, that such
a device actually exists. All so-call RT2870 adapter identify themselves
as RT2860.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
f0194b2d5d01b99555fd8a6e42281809086f1ab1 03-Jun-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Centralize rt2800 beacon writing.

The beacon writing functions of rt2800pci and rt2800usb are now identical.
Move them to rt2800lib to only have one central function.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.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>
2de64dd22d0390688b853788dcadee3c0ad9e518 08-May-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Factor out RXWI processing to common rt2800 code.

RXWI processing is exactly the same for rt2800pci and rt2800usb, so
make it common code.

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>
59679b91d1d33ebe90b72ffded9a57dba788fa6b 08-May-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Factor out TXWI writing to common rt2800 code.

TXWI writing is exactly the same for rt2800pci and rt2800usb, so
make it common code.

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>
55f9321a024a2d03f71a23b74003792692ca1a38 06-May-2010 Ivo van Doorn <ivdoorn@gmail.com> rt2x00: Fix RF3052 channel initialization

Update channel initialization for the RF3052 chipset.
According to the Ralink drivers, the rt3x array must be
used for this chipset, rather then the rt2x array.

Furthermore RF3052 supports the 5GHz band, extend
the rt3x array with the 5GHz channels, and use them
for the RF3052 chip.

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>
809bfe81ce225d1f5a111840c3d9e30704d98478 06-May-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: rt2800: don't overwrite SIFS values on erp changes

The SIFS value is a constant and doesn't need to be updated on erp changes.
Furthermore the code used 10us for both, the OFDM SIFS and CCK SIFS time
which broke CTS protected 11g connections (see patch "rt2x00: rt2800: update
initial SIFS values" for details).

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a21c2ab4210a89a71a0a99685acf16ae126b2eee 06-May-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: rt2800: update initial SIFS values

Currently the CCK and OFDM SIFS value is set to 32us. This value is neither
used by the Ralink driver nor specified in 802.11.

Instead of using 10us for CCK SIFS (as defined in 802.11) use 16us like in the
Ralink drivers. And indeed using a SIFS value of 10us breaks connectivity with
11g + CTS protected connections. Add a comment to the code why we don't use 10us
for CCK SIFS value.

The OFDM SIFS value is set to 16us (as defined in 802.11 and also used by the
Ralink drivers).

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
a21ee724034b21d51d74eec8e426702a627eb465 03-May-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Fix HT40+/HT40- setting in rt2800.

Inspection of the Ralink vendor driver shows that the TX_BAND_CFG register
and BBP register 3 are about HT40- indication, not about HT40+ indication.
Inverse the meaning of these fields in the code.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
c2661486ebacc9c2a86757d8ff1d40b3efe8a08b 03-May-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Remove rt2x00pci.h include from rt2800lib.

PCI specific code has been remove quite some time ago.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
baff8006b58bb7fca5d1ea1825bc8c6486900303 28-Apr-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: rt2800lib: update rfcsr & bbp init code for SoC devices

Update the rfcsr and bbp init code for SoC devices to match with the
latest Ralink driver.

To have better control over which values are used for the register
initialization create a new function rt2800_is_305x_soc which checks
for SoC interface type, the correct RT chipset and the correct RF
chipset. This is based on the assumption that all rt305x SoC devices
use a rt2872 and rf3020/rf3021/rf3022.

In case an unknown RF chipset is found on a SoC device with a rt2872
don't treat it as rt305x and just print a message.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9a8b424ea8b64da83b6868423dcd0f3c259fdde0 26-Apr-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: rt2800lib: Remove redundant check for RT2872

Remove redundant check for RT2872.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
23812383c6b03afef44c4aa642500f8235c3d079 26-Apr-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: rt2800lib: Fix rx path on SoC devices

Restore the rfcsr initialization for RT305x SoC devices which was removed
by "rt2x00: Finish rt3070 support in rt2800 register initialization.".

This fixes the rx path on SoC devices.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
5a673964266438784b4ebf65ee07970cde61ab5e 23-Apr-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: rt2800: use tx_power2 in rt2800_config_channel_rf3xxx

Get closer to what the ralink driver does by setting the rf register 13
to tx_power2 during channel switch.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2caaa5d36ee210919bd0ecc7b2e6648171544e95 23-Apr-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: rt2800lib: disable HT40 for now as it causes reception problems

Disable HT40 support for now as it causes rx problems with HT40 capable
11n APs (when mac80211 enables HT40, rx is completely disfunctional).

Once the rt2800 HT code is capable of using HT40 we should enable the
flag again.

I only tested this patch with a rt305x SoC device, nevertheless the
patch disables HT40 also on PCI and USB rt2800 devices.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
cc78e904bd960196233e2cd6a49068bba8787527 11-Apr-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Add rt3390 support in rt2800 register initialization.

Add RT3390 specific register initializations to rt2x00, based on the latest
Ralink rt3390 vendor driver.

Untested as I don't actually own an RT3390 based device, but given experiences
on rt3070/rt3071 very hopeful that this will actually work..

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>
64522957ce35df995dfd73bee548304f2a39cc3e 11-Apr-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Add rt3090 support in rt2800 register initialization.

Add RT3090 specific register initializations to rt2x00, based on the latest
Ralink rt3090 vendor driver.

Untested as I don't actually own an RT3090 based device, but given experiences
on rt3070/rt3071 very hopeful that this will actually work..

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>
d5385bfc59c737d1eae77cc48d662daf4ddddae8 11-Apr-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Add rt3071 support in rt2800 register initialization.

Add RT3071 specific register initializations to rt2x00, based on the latest
Ralink rt3070 vendor driver.

With this patch my RT3071 based devices start showing a sign of life.

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>
8cdd15e0063edbe002945ba93faf80e79c947610 11-Apr-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Finish rt3070 support in rt2800 register initialization.

rt2x00 had preliminary support for RT3070 based devices, but the support was
incomplete.
Update the RT3070 register initialization to be similar to the latest Ralink
vendor driver.

With this patch my rt3070 based devices start showing a sign of life.

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>
a9dce1494af33534867b8c7fab7351274fd651ca 11-Apr-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Align rt2800 register initialization with vendor driver.

Align the rt2800 register initializations with the latest versions of the
Ralink vendor driver.
This patch is also preparation for the addition of support for RT3070 /
RT3071 / RT3090 / RT3390 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>
8d0c9b65c904c6943566ccd2919c6a5ee6292c6b 11-Apr-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Refactor rt2800 version constants.

The rt2800 version constants are inconsistent, and the version number don't
mean a lot of things anyway. Refactor the constants to have some more
meaningful names, and introduce and use some new helpers to check these
chipset revisions. At the same time rename to revision, as they are more
revision numbers rather than version numbers.

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>
e148b4c82a6269aa19476e4865afe8aa84360c8f 11-Apr-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Align RT chipset definitions with vendor driver.

Only include definitions for RT chipsets that are also used inside the
Ralink vendor drivers.

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>
fab799c3b275a207215dfef91c0ac716f12c8727 11-Apr-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Update rt2800 register definitions towards latest definitions.

Definitions taken from the latest rt2860 / rt2870 / rt3070 / rt3090 Ralink
vendor drivers.

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>
06855ef4c8cf3d86d831c6317ca6a3563d271350 11-Apr-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Let RF chipset decide the RF channel switch method to use in rt2800.

It seems that the distinction between RF channel switch method is solely based
on the RF chipset that is used.
Refactor the channel switch decision to just take the RF chipset into account,
thereby greatly simplifying the check.

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>
403820edc4ba1f2fb2514c022f2662c498ce0d11 07-Apr-2010 Helmut Schaa <helmut.schaa@googlemail.com> rt2x00: use rt2800_config_channel_rt3x for rt2872

rt2872 needs the same rf register setup as rt3070 and rt3090, hence
use rt2800_config_channel_rt3x instead of rt2800_config_channel_rt2x.
This change allows me to actually switch channels and hence scan all
configured channels on the RT305x SoC platform (which uses a rt2872)
here.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Tested-by: Luis Correia <luis.f.correia@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>
71976907842abb71a0e6fda081e1d16e00420849 24-Mar-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Fix typo in RF register programming of rt2800.

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>
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>
cea90e55969ff70b970d64d564076a5469331527 13-Feb-2010 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Introduce SoC interface type.

Introduce the SoC interface type to detect SoC devices, instead of having
them mimic being PCI devices.
This allows for easier detection of SoC 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>
b3579d6adcf7b24464274967a96d12467cfb11a7 30-Dec-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Make rt2800_init_led static and don't export it.

It is only used within the rt2800lib module itself.

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>
67a4c1e24d58e0d88ed88539641631f6fc8a0cfd 30-Dec-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Unify rt2800 WPDMA ready waiting functions.

The rt2800pci_wait_wpdma_ready and rt2800usb_wait_wpdma_ready functions are
exactly the same, so unify them into rt200lib.

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>
6c0fe26581406bff3d15fd6051453e80cfe70fd6 30-Dec-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: RF3052 is a valid RF chipset for USB devices as well.

The RF3052 chipset is now also being integrated onto USB devices, so
allow the RF chipset and don't treat it as PCI/SOC only.

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>
301a8234ea81938f0f083ae4e274d9c9296f3c86 30-Dec-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Fix LED configuration setting for rt2800.

rt2800_blink_set uses an illegal value to set the LED_CFG_G_LED_MODE
field of the LED_CFG register. This field is only 2 bits large, so
should be initialized with value that fits. Use default value from
the vendor driver.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
ac394917f5138f9bb2774718312dec179164f3dc 23-Dec-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Let rt2800lib check CONFIG_RT2X00_LIB_USB instead of CONFIG_RT2800USB

rt2800lib currently checks whether RT2800USB is enabled in the configuration.
Strictly speaking this is not necessary, it only needs to know whether the
generic rt2x00usb library functions are available. Therefore check for
RT2X00_LIB_USB instead.

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>
9a418af5df03ad133cd8c8f6742b75e542db6392 17-Dec-2009 Johannes Berg <johannes@sipsolutions.net> mac80211: fix peer HT capabilities

I noticed yesterday, because Jeff had noticed
a speed regression, cf. bug
http://bugzilla.intellinuxwireless.org/show_bug.cgi?id=2138
that the SM PS settings for peers were wrong.
Instead of overwriting the SM PS settings with
the local bits, we need to keep the remote bits.

The bug was part of the original HT code from
over two years ago, but unfortunately nobody
noticed that it makes no sense -- we shouldn't
be overwriting the peer's setting with our own
but rather keep it intact when masking the peer
capabilities with our own.

While fixing that, I noticed that the masking of
capabilities is completely useless for most of
the bits, so also fix those other bits.

Finally, I also noticed that PSMP_SUPPORT no
longer exists in the final 802.11n version, so
also remove that.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
93b6bd26b74efe46b4579592560f9f1cb7b61994 14-Dec-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Disable powersaving for rt61pci and rt2800pci.

We've had many reports of rt61pci failures with powersaving enabled.
Therefore, as a stop-gap measure, disable powersaving of the rt61pci
until we have found a proper solution.
Also disable powersaving on rt2800pci as it most probably will show
the same problem.

Cc: stable@kernel.org
Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
855da5e07ef4dba5f23d8f6f31004116ba16c52a 13-Dec-2009 Julia Lawall <julia@diku.dk> drivers/net/wireless: Correct code taking the size of a pointer

sizeof(iv16) and sizeof(iv32) are the sizes of pointers. Change them to
the size of the copied data.

Furthermore, iveiv_entry is a local structure that has just been
initialized and is not visible outside this function. Thus, there would
seem to be no point to copy data into it. The order of the arguments is
thus changed to copy the data into the parameters, which are provided as
pointers, suggesting in this case that they should be used to return values.

A simplified version of the semantic patch that finds the first problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression *x;
expression f;
type T;
@@

*f(...,(T)x,...)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
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>
b2ec153a637409bd87952d44409905b7d98418b8 14-Dec-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Fix rt2800usb detection in rt2800lib.

rt2800lib incorrectly detected whether RT2800USB was enabled because
it didn't account for a modularized RT2800USB driver.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
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>
ee303e543e7d5f0d38197298adf0c4fb079094e9 23-Nov-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Clean up use of rt2x00_intf_is_pci.

RT chipsets are unique across both PCI and USB busses, and don't overlap.
Therefore there is no need to test for bus type when only checking for
chipset type. Remove the redundant checks.

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>
38a522e6bc0fcd9848b91366ec899f1c2cb23609 23-Nov-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Only initialize HT on rt2800 devices that support it.

Some RT28xx/RT30xx devices don't support 802.11n, when they are combined with
the RF2020 chipset. Ensure that HT is disabled for these 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>
6a62e5ef94f754892734f99e87ca3dedd3cef277 16-Nov-2009 Josef Bacik <josef@redhat.com> rt2800: do not enable tbtt unless we are in a beacon mode

Please be gentle, I'm a fs developer and this is my first foray into drivers, as
I'm tired of building ralinks driver everytime I update my kernel. Whenever I
load the rt2800pci driver my box bogs down, and a few printk's later I
discovered its because I was getting 10's of thousands of TBTT interrupts a
second. I discovered this was because we were setting the beacon timer to 0,
which is apparently what TBTT keys off of. It seems to me that we should only
be enabling TBTT when we are in a beacon transmitting mode, which from what I
can tell is in AD-HOC and other such modes where the mac80211 layer would have
given us a proper beacon_int to set the beacon timer to instead of 0. So this
is my fix, only enable TBTT if our sync mode is for beacon. This makes it so my
box doesn't die everytime I load the rt2800pci driver. Let me know if this is
acceptable, I just learned all these terms about 15 minutes ago via wikipedia,
so I really am not familiar with how this stuff is supposed to work. Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
31a4cf1f22677ba1ea90be055bc20aac25b8e7c4 14-Nov-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Fix BUG on rt2800usb when trying to read eFuse EEPROM.

Current tree hits a BUG_ON in rt2x00_regbusy_read, because the eFuse EEPROM
reading code of rt2800lib uses the function without the csr_mutex locked.

Fix this by locking the csr_mutex for the of the EEPROM reading cycly and
using the _lock variants of the register reading and writing functions.

This also introcudes the register_read_lock function pointer in the
rt2800_ops structure.

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>
cce5fc45f9e9570f320009431d033d5a8f6144cc 10-Nov-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Initialize rf302x RF values properly for rt2800pci.

Ensure RF302x and RF2020 chipsets are handled properly in rt2800lib
for the rt3090 chipset.

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>
fa6f632fba300f92d21962ef6e58411345465241 09-Nov-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Fix rt2800lib RF chip programming selection.

Mirror the legacy Ralink driver with respect to rt2800 RF register
programming. Execute rt2800_config_channel_rt3x for all RF2020,
RF3020, RF3021 & RF3022 chipsets when operating on RT3070 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>
235faf9b41b7b090be15b483bf900c0b9a8da4ea 12-Nov-2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com> rt2800lib: fix some typos and punctuation in comments

fix some typos and punctuation in comments

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
[bart: ported the change from the older patch for rt2800usb & rt61pci]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f273fe55e3f3f0b66b7624c0102d3ef44bbdfe6a 10-Nov-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Properly detect Ralink RT3070 devices.

Allow rt2800usb to properly detect RT307X based devices, and set the appropriate chipset values.

Signed-off-by: Gertjan van Wingede <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
41a2617064a8458178ccdf31ed2be2b4eade4a2a 09-Nov-2009 Gertjan van Wingerde <gwingerde@gmail.com> rt2x00: Fix typo in rf programming of rt2800lib.

Fix a type in rt2800_config_channel_rt3x. The second write to RF
register 2 should be to RF register 3. This is confirmed by the
legacy Ralink code.

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>
30e840346c516ad4e36f710fa485933ccc7afa66 08-Nov-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> rt2800: add eFuse EEPROM support code to rt2800lib

eFuse EEPROM is used also by USB chips (i.e. RT3070)
so move the needed code from rt2800pci to rt2800lib.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
4da2933fe1f2d3d9ed548660f5c02a9b0608a8c7 08-Nov-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> rt2800: unify rt2800*_probe_hw_mode()

Add rf_vals tables and rt2800_probe_hw_mode() to rt2800lib.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
38bd7b8a0f485ba5ad514fcd621a1842ebadf9e6 08-Nov-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> rt2800: unify EEPROM support code

Add rt2800_validate_eeprom() and rt2800_init_eeprom() to rt2800lib.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2ce33995216a088fc11e1f85768375580324174c 04-Nov-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> rt2800: add rt2800lib (part four)

Code unification.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
fcf5154118849cca3cdf424e83f863225d8173e7 04-Nov-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> rt2800: add rt2800lib (part three)

Code unification.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
f445061630c7a4a85193fdef006234f94f71c366 04-Nov-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> rt2800: add rt2800lib (part two)

Code unification.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
89297425c2104b187c25d6260a41345c491c8f18 04-Nov-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> rt2800: add rt2800lib (part one)

Code unification.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>