wlcore: check wl->state before setting default key

wl1271_op_set_default_key_idx() lacks a check
of wl->state, causing the driver to try writing
to a powered-off device in some cases (e.g.
during recovery)

Signed-off-by: Eliad Peller <eliad@wizery.com>
nl80211: update definitions from newest wpa_s

added channel switch related commands

Signed-off-by: Arik Nemtsov <arik@wizery.com>
wlcore: fwlog dynamic mem_block control

number of fwlog mem_blocks can be configured using module param.
this is a fw debug feature: in case a large fw log data is busrted during
a short period of time, the memory get filled and data is lost.
this allows us to dynamicly set the fw log mem_block usage, although
configuring more mem_block for logger comes at the expense of TP.

Signed-off-by: Yair Shapira <yair.shapira@ti.com>
Signed-off-by: Ido Reis <idor@ti.com>
wl18xx: FDSP Clock (FDSP Code RAM Corruption fix)

In PG2.0 there is an issue where PHY's FDSP Code RAM sometimes gets
corrupted when exiting from ELP mode. This issue is related to FDSP
Code RAM clock implementation.

PG2.1 introduces a HW fix for this issue that requires the driver to
change the FDSP Code Ram clock settings (mux it to ATGP clock instead
of its own clock).

This workaround uses PHY_FPGA_SPARE_1 register and is relevant to WL8
PG2.1 devices.

The fix is also backward compatible with older PG2.0 devices where the
register PHY_FPGA_SPARE_1 is not used and not connected.

The fix is done in the wl18xx_pre_upload function (must be performed
before uploading the FW code) and includes the following steps:

1. Disable FDSP clock
2. Set ATPG clock toward FDSP Code RAM rather than its own clock.
3. Re-enable FDSP clock

Signed-off-by: Yair Shapira <yair.shapira@ti.com>
Signed-off-by: Ido Reis <idor@ti.com>
wl12xx/wl18xx: update default fw logger's settings

update the fw logger mode to continuous, and output to dbgpins (uart).

Signed-off-by: Ido Reis <idor@ti.com>
wlcore/wl18xx/wl12xx: FW log params per chip arch

FW memory block size and FW log end marker parameters
are added to wl structure and are initialized per
chip architecture. convert_hwaddr hw operation is added
to convert chip dependent FW internal address.
Copy from FW log is also simplified to copy the entire
memory block as FW logger utility is repsponsible
for parsing of FW log content.

Signed-off-by: Igal Chernobelsky <igalc@ti.com>
mac80211: count started vifs

count the started roles by simply counting the non-idle vifs.
(Based on Arik's patch from R5)

Signed-off-by: Eyal Shapira <eyal@wizery.com>
wlcore: add new plt power-mode: CHIP_AWAKE

Under this mode the chip is powered on including sdio
but no FW is downloaded and run, interrupts are not enabled, etc...

This mode is intended to allow RTTT to bridge sdio as a transport
to the chip.

Driver only provides sdio access using the dev_mem debugfs file.

Some fixes done to the code that ensures that PLT mode and normal
driver power mode (ifconfig/add_interface) are mutually excluded.

Signed-off-by: Yair Shapira <yair.shapira@ti.com>
wlcore: disable elp sleep while in plt mode

We now disable elp sleep during plt mode to allow normal operation of
plt tools such as calibrator.

Having elp_sleep enabled during plt mode is actually not required and
in fact it disrupt plt operations such as rx statistics etc...

This is based on wl12xx (R5) commit 5cf0fe31ab

Signed-off-by: Yair Shapira <yair.shapira@ti.com>
mac80211: reject BA action frames if sent fron non HT STA

The FW doesn't work well with BA sessions started from non 802.11n
STAs. Reject these as a work around until the FW issue is fixed.

Signed-off-by: Eyal Shapira <eyal@wizery.com>
Signed-off-by: Igal Chernobelsky <igalc@ti.com>
wlcore: re-enable idle handling

We need some stuff done on idle change, most notably we have to stop
sched-scanning. Take care of this be reintroducing idle handling.
While at it, fix a bug where we would send sched_scan_stopped() up
before getting an event about stopping it from FW.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
wlcore: disable Tx BA on TIDs 6 and 7

These TIDs are used for VO and we don't want
BA to be used in VO where we prefer lower latency
over higher throughput.

Signed-off-by: Eyal Shapira <eyal@wizery.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>
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>
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>
mac80211: fix delayed ADDBA response

Block frame processing during scan might delay the
ADDBA response, which eventually timeouts and
significantly reduces the device throughput.
Remove this constrain as it's not required for the
HW scan.

Signed-off-by: Victor Goldenshtein <victorg@ti.com>
wlcore: add missing wake_lock_destroy (ANDROID)

destroy wake_locks when failing allocation after
they have been already initialized

Signed-off-by: Nadim Zubidat <nadimz@ti.com>
wl18xx: allow using 40Mhz AP in 2.4Ghz for testing

Print a more modest error and avoid the WARN_ON. It should be enough to
detect this on a user setup.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
wl18xx: set default mac for untrimmed devices

Some 18xx untrimmed devises doesn't have a saved
oui and nic addresses on the chip registers, use
default oui addr in this case.

As a result the default mac address will be:
 addr 0: 08:00:28:00:00:01
 addr 1: 08:00:28:00:00:02
 addr 2: 08:00:28:00:00:03

Signed-off-by: Victor Goldenshtein <victorg@ti.com>
wlcore: fix zeroing out of tx aggr stats (DEBUG)

Before only a pointer was zeroed, giving little effect.

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