mac80211: handle auth failure returned with unmatching auth algo

Some Netgear APs like WNAP210 have a quirk behavior when
configured for WEP Shared. They send an auth response with algo
SHARED and status code NOT_SUPPORTED_AUTH_ALG (13) when being
sent a request made with auth algo OPEN. Enable such response to
propagate to userspace instead of discarding it so wpa_s can
reattempt to auth with SHARED.

Reported-by: Noam Shaked <noams@ti.com>
Signed-off-by: Eyal Shapira <eyal@wizery.com>

Conflicts:
	net/mac80211/mlme.c

Signed-off-by: Luciano Coelho <coelho@ti.com>
mac80211: use legacy mode for all ACs

AVM FritzBox 7390 has a weird behaviour where once we enable
U-APSD only on the VO AC it limits the rate of the packets
it sends to 39Mbps and doesn't do AMPDU aggregation.
This causes a big degradation in throughput obviously.
It's important to note that this isn't related to PS and happens
also when ACTIVE is forced. The traffic affected is sent in BE AC.
Once legacy mode for all ACs is used the AP begins using higher rates
as well as AMPDU aggregation which improves throughput significantly.

In order to deal with this AP and potentially others switch to
using legacy mode for all ACs by default.

Signed-off-by: Eyal Shapira <eyal@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
mac80211: deny ADDBA on VO AC TIDs

Avoid Rx BA on TID 6 and 7 to prefer lower latency
on VO AC instead of higher throughput.

Signed-off-by: Eyal Shapira <eyal@wizery.com>
Signed-off-by: Igal Chernobelsky <igalc@ti.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
mac80211: extract basic rates on start_ap

On ap start, the beacon is configured while
the basic rates were not set yet (they are
set only later by userspace).

Since sometimes it's important to know
the supported rates before we start
beaconing (e.g. 11a, p2p), parse the beacon
and configure the bss_conf with the correct
basic rates, according to the supported_rates
and ext_supported_rates ies.

Signed-off-by: Eliad Peller <eliad@wizery.com>

Conflicts:
	net/mac80211/cfg.c

Signed-off-by: Luciano Coelho <coelho@ti.com>
mac80211: fix NULL dereference in ieee80211_sta_process_chanswitch

Dereference "ifmgd->associated" while not being associated
will cause a kernel panic:

  Unable to handle kernel NULL pointer dereference at virtual address 00000000
  pgd = c0004000
  [00000000] *pgd=00000000
  Internal error: Oops: 5 [#1] PREEMPT SMP
  Modules linked in: wlcore_sdio fmdrv_chr(C) gps_drv wl18xx wl12xx wlcore mac80211 cfg80211 ..

  CPU: 0    Tainted: G        WC   (3.0.31 #1)
  PC is at ieee80211_sta_process_chanswitch+0x10/0x28c [mac80211]
  LR is at ieee80211_sta_rx_queued_mgmt+0x220/0x5a4 [mac80211]
  ...

Verify that the ifmgd->associated != NULL before processing
with ieee80211_sta_process_chanswitch().

Signed-off-by: Victor Goldenshtein <victorg@ti.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
wlcore: enter elp in force ps mode in 5ms

It is requiered to enter sleep mode with smaller delay in forced PS mode.
This fixes issue of testing force PS mode during VoIP traffic where packets
are sent every 20ms. Chip never enters ps mode with default 30 ms delay
in such test.

Signed-off-by: Igal Chernobelsky <igalc@ti.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
wlcore: set max num of Rx BA sessions per chip

Maximum number of supported RX BA sessions depends on chip type.
wl18xx supports 5 RX BA sessions while wl12xx supports 3.

Signed-off-by: Igal Chernobelsky <igalc@ti.com>

Conflicts:
	drivers/net/wireless/ti/wl12xx/main.c
	drivers/net/wireless/ti/wl18xx/main.c
	drivers/net/wireless/ti/wl18xx/wl18xx.h

Signed-off-by: Luciano Coelho <coelho@ti.com>
wlcore: fix link count in single-link-PSM optimization

commit 144614f3eebd7d only allowed a single active link when
turning on the optimization, ignoring the fact that an AP has two
additional global links.
Use 3 links as an indication for a single active link. Use the
FW PSM bits to verify the extra active link belongs to the AP role.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
wlcore: don't risk using stale HLID during .sta_state callback

The HLID of a STA can change, particularly during recovery. Don't cache
the HLID before it was potentially allocated.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
wlcore: consolidate tx_seq handling on recovery

Accumulate the total number of sent packets per-link to find out how far
the encryption sequence number has progressed. Use this number as the
initial security sequence number after recovery.

This consolidates security sequence handling for both chip families, as
we no longer have to rely on 12xx specific Tx completion.

A fortunate side effect of this is correct management of seq numbers for
AP roles and multi-role scenarios.

When a link is removed we save the last seq number on a persistent part
of the wlvif. This helps the data survive through recoveries/suspends,
which also entail changes in the hlid of the link.

This functionality is STA only currently.

Signed-off-by: Arik Nemtsov <arik@wizery.com>

Conflicts:
	drivers/net/wireless/ti/wlcore/main.c

Signed-off-by: Luciano Coelho <coelho@ti.com>
wlcore: report rssi from roaming statistics

report the average beacon rssi which is calculated
by firmware for roaming statistics instead of the
last rx packet rssi. this results a more accurate
rssi reporting

Signed-off-by: Nadim Zubidat <nadimz@ti.com>

Conflicts:
	drivers/net/wireless/ti/wlcore/acx.c
	drivers/net/wireless/ti/wlcore/acx.h

Signed-off-by: Luciano Coelho <coelho@ti.com>
wlcore: change warn on missing lock in wlcore_queue_xx funcs

On !CONFIG_SMP builds spin_is_locked always returns 0. Assert the
locking using assert_spin_locked, which is written to behave correctly
in all cases.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
wlcore: don't attempt to roam in case of p2p

For STA we report beacon loss to higher levels so that wpa_s
can attempt to roam without disconnecting. In case of P2P CLI
we don't want to attempt roaming and instead disconnect immediately
upon beacon loss.

Signed-off-by: Eyal Shapira <eyal@wizery.com>

Conflicts:
	drivers/net/wireless/ti/wlcore/event.c

Signed-off-by: Luciano Coelho <coelho@ti.com>
wl18xx: print chip info during boot

Print board type, PG with metal and ROM versions.
This might help debugging HW related issues.

Signed-off-by: Victor Goldenshtein <victorg@ti.com>

Conflicts:
	drivers/net/wireless/ti/wl18xx/reg.h

Signed-off-by: Luciano Coelho <coelho@ti.com>
wlcore: free AP global links properly on recovery

Dont use free_sta() on AP global links. It would fail an internal check
within the function and various structures within the link struct would
not be reset.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
wlcore: AP-mode - recover security seq num for stations

Save the sequence number of the broadcast AP link in the wlvif. For each
connected station, save the sequence number in the drv_priv part of
ieee80211_sta. Use the saved numbers on recovery/resume, with the
obligatory increment on recovery.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
wlcore: correctly check state before regdomain conf

The wlcore state was checked without the mutex being taken. This leads
to WARN_ONs sometimes if a notification arrives when the driver
is on, but the mutex is only taken after it is off. This usually
happens if stopping the driver while connected to a network.

Signed-off-by: Arik Nemtsov <arik@wizery.com>

Conflicts:
	drivers/net/wireless/ti/wlcore/main.c

Signed-off-by: Luciano Coelho <coelho@ti.com>
wlcore: consider dummy packets when tx queues are empty

Don't ignore dummy packets when our queues are empty. This causes dummy
packets never to be sent when traffic is not suspended by FW thresholds,
which happens only in high Tx throughput situations. This may hurt Rx
performance.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>