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>
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 counters with reasons for aggr packet sending (DEBUG)

Count the reasons that triggered us to send the buffer to the firmware
for transmission.  Count buffer_full, fw_buffer_full, other reasons
and no_data left to send.

This is useful when debugging throughput issues.

To have a better understanding of what is going on in the TX data
path, we can count the number of times we sent n packets.  For
example, if we sent 10 times aggregations of 2 packets, we print [2] =
10.

Instead of counting the reasons as an overall value, we count the
reasons for each number of packets used in the aggregation.

Signed-off-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Luciano Coelho <coelho@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: ROC on AP channel before auth reply

Start a ROC on the AP channel beforing sending the authentication reply
to a connecting STA. This ROC is held up to 1 second via a timer. If the
station is authorized and added by mac80211, the ROC is extended until
the station is fully authorized.
We make sure not to ROC twice when several stations are connecting in
parallel and to only release the ROC when both the pending-reply timer
and the STA-state callbacks do not require it.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
wlcore: cancel channel switch work on interface removal

Otherwise, if the work is pending, we might get a bad dereference after
the interface is removed.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
wlcore: hold jiffies in unsigned long

u32 can be incorrect (too small) for some architectures.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
wlcore: fix occasional AP TX stop after recovery

The fw_status wasn't zeroed during allocation, this caused to
occasional AP traffic stops after recovery. The wrong value in
the "wl->fw_status_2->counters.tx_lnk_free_pkts" led to a bad
"lnk->allocated_pkts" calculation in the wlcore_fw_status()
causing the wl18xx_lnk_low_prio() to return FALSE
(lnk->allocated_pkts > thold).
This eventually blocked the link in the wlcore_tx_work_locked()
as the wl1271_skb_dequeue() continuously return NULL.

Fix this by zeroing the wl->fw_status_1/2 during allocation.

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