ath10k: don't advertise IBSS iftype for 10.x

The 10.x firmware does not support IBSS mode at
all. It can't beacon and it crashes when trying to
scan.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: improve 'hard' simulate fw crash.

Different firmware may support different numbers of
vdevs.  Use value that is always out of range for all
firmware.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: introduce a stricter scan state machine

This aims at fixing some rare scan bugs related to
firmware reporting unexpected scan event
sequences.

One such bug was if spectral scan phyerr reporting
prevented firmware from properly propagating scan
events to host. This leadsl to scan timeout. After
that next scan would trigger scan completed event
first (before scan started event) leading to
ar->scan.in_progress and timeout timer states to
be overwritten incorrectly and making the very
next scan to hang forever.

Reported-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: simplify scan debug prints

This also reduces the cruft of printing scan event
names in capitals.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k:  provide firmware crash info via debugfs.

Store the firmware crash registers and last 128 or so
firmware debug-log ids and present them to user-space
via debugfs.

Should help with figuring out why the firmware crashed.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k:  save firmware debug log messages.

They may be dumped through the firmware dump debugfs
file.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k:  save firmware stack upon firmware crash.

Should help debug firmware crashes, and give users a way
to provide some useful debug reports to firmware developers.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: Dump exception stack contents on firmware crash.

Firmware developers can decode this and maybe figure out
why the firmware crashed.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: save firmware RAM and ROM BSS sections on crash.

This can be used to get a useful back trace out of a firmware
crash that involves an interrupt handler.  For instance, a
null-pointer-exception would be this kind of trace.  A user-space
tool can read the debugfs file and decode things as wished.

This requires a packaged firmware with a new IE to describe the
BSS section starts and length.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath: Move spectral debugfs structs to shared header

The ath9k and ath10k will share the definitions of the debugfs spectral
structures and enums. Having them in the same place helps to avoid conflicts.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: add spectral scan feature

Adds the spectral scan feature for ath10k. The spectral scan is triggered by
configuring a mode through a debugfs control file. Samples can be gathered via
another relay debugfs file.

Essentially, to try it out:

ip link set dev wlan0 up
echo background > /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_scan_ctl
echo trigger > /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_scan_ctl
iw dev wlan0 scan
echo disable > /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_scan_ctl
cat /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_scan0 > samples

This feature is still experimental. Based on the original RFC patch of
Sven Eckelmann.

Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de>
--
PATCHv3-ath-resend:
 * based on ath/master

PATCHv3:
 * fix compilation with debugfs disabled (Thanks Kalle)
 * add trigger command to commit message (Thanks Chun-Yeow)
 * change error message capitalization (Thanks Michal)
 * don't send WMI on core halt (Thanks Michal)
 * various style changes: indetation, empty lines before comments, moved
   initialization into separate function, create substruct for spectral
   parameters (Thanks Kalle)

PATCHv2:
 * fixed usage example in commit message (Thanks Chun-Yeow Yeoh)
 * adding lockdep asserts and comment (Thanks Michal)
 * debug message cleanups (Michal)
 * disable spectral on firmware crash (Michal)

PATCH:
 * change the tlv format to a variable-length format, depending on the
   number of bins
 * perform dc interpolation and max_exp calculation in the driver (as
   for ath9k)
 * make fft_size configurable
 * background scan will only start after beeing trigger, like in ath9k
 * document at least some spectral configuration members (thanks Kathy)
 * fix sparse problems
 * sample bandwidth appears to be 110% of what is reported by the
   hardware according to the plotter (e.g. 20->22, 40->44 MHz etc),
   so fix that in the driver.
 * disable spectral for a vif when it's beeing deleted and still active
   (Michals comment)
 * modify ath_ prefix of function/struct/enum to ath10k_ (Michal)
 * changed variable ret to res (Michal)
 * added ath10k_warn messages (Michal)
 * renamed wmi functions (Michal)
 * use ar->conf_mutex for locking (Michal)
 * renamed mhz to chan_width_mhz (Michal)
 * only enable spectral scan files when ATH10K_DEBUGFS is enabled
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>