ath6kl: handle probe response from P2P device in P2P GO mode

When the device is in P2P GO mode and in listen state, the correct behavior is
to see two different probe response frames - one from P2P device and the other
from GO. wpa_supplicant uses the same mechanism to send the frame in both cases
(ath6kl_mgmt_tx). For GO probe response, ath6kl needs to call
ath6kl_send_go_probe_resp (this will add only WSC/P2P IEs and the rest of the
IEs are filled in by the firmware). That was done based on the nw_type ==
AP_NETWORK which would work if P2P Device role were in a separate netdev. When
P2P Device and GO use the same netdev, ath6kl needs to use the special GO probe
response case only if SSID is longer than P2P wildcard SSID.

Signed-off-by: Aarthi Thiruvengadam <athiruve@qca.qualcomm.com>
Reviewed-by: Jouni Malinen <jouni@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: add debug log for AP MLME operations

This is useful during debugging to check if disconnect commands were issued by
the host.

Signed-off-by: Aarthi Thiruvengadam <athiruve@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Add ARP offload related statistic info in tgt_stats

Firmware reports the below ARP offload related information
while sending the target statistic event to the host.

     * Number of ARP packets received.
     * Number of packets matched with the device IP addr.
     * Number of ARP response packet sent to the remote.

This patch adds the additional debug prints in debugfs
entry tgt_stats. It will be useful to know the ARP offload
execution status.

Signed-off-by: Raja Mani <rmani@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Add __printf verification to ath6kl_printk

Make sure printf formats and arguments match.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: abort normal scan when scheduled scan is started

If the device disconnects from an AP when it is in suspending state. You will
get the following message from wpa_supplicant after waking the device up and
sending scan request:

"Scan trigger failed: ret=-16 (Device or resource busy)"

Fix the issue by sending a scan complete event before starting scheduled
scan.

kvalo: cosmetic changes to commit log

Signed-off-by: Isaac.li <shonmou@gmail.com>
Tested-by: Raja Mani <rmani@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Dump htc header when invalid Rx frame length is detected

Dump htc header along with the warning message when the request
to Rx with invalid frame length is detected.

kvalo: fix open parenthesis alignment

Signed-off-by: Vasanthakumar Thiagarajan <vthiagar@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Isolate host sleep mode config part from ath6kl_wow_suspend

The piece of code used in ath6kk_wow_suspend function
to configure the host sleep mode is needed in deep sleep
case also.

Moving that portion to a separate function called
ath6kl_update_host_mode() would be helpful to avoid
the duplication of the same code in deep sleep path.

There is no functional change.

kvalo: move inline functions to cfg80211.c and fix a long line

Signed-off-by: Raja Mani <rmani@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Optimize target power in deep sleep suspend

Adding below steps helps to get good power numbers
in deep sleep suspend path,

    * Disable WOW mode.
    * Flush data packets and wait for all control packets.
      to be cleared in TX path before deep sleep suspend.
    * Set host sleep mode to SLEEP.

Below steps are added to perform the recovery action
while the system resume from deep sleep,

     * Set host sleep mode to AWAKE.
     * Reset scan parameters to default value.

In addition, Debug prints are added to track deep sleep
suspend/resume state.

Signed-off-by: Raja Mani <rmani@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Merge remote branch 'wireless-next/master' into ath6kl-next
ath6kl: Configure inactivity timeout in fw

Configure the inactivity timeout passed in start_ap() to
firmware. This capability is advertised only when fw supports
it, there is a new bit (ATH6KL_FW_CAPABILITY_INACTIVITY_TIMEOUT)
in firmware capability ie for driver to learn fw's capability.
After the fw finds out the station is inactive, it will probe
the station with null func frames. By default, the timeout is
10 secs.

Signed-off-by: Vasanthakumar Thiagarajan <vthiagar@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: set ram reserved size only for ar6003

Ram reserved size is not needed with ar6004.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Add tx_complete() to struct htc_ep_callbacks

This is needed by the USB code. Also while at it replace one void pointer
with a properly typed pointer.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: add tx_comp_multi() to struct htc_ep_callbacks

It's also needed by the USB code.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: add pointer to the skb in htc_packet

Needed by the USB code.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: add rx data padding support

Needed when using USB.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: remove void pointer from ath6kl_credit_setup()

Void pointers are bad.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: add htc ops

In preparation for adding HTC pipe implementation add htc-ops.h to make
it possible dynamically choose which HTC type is used.

Needed for full USB support.

Based on the code by Ray Chen <raychen@qca.qualcomm.com>.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Signed-off-by: Ray Chen <raychen@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Add HTC pipe implementation

This is needed for USB.

Based on code by Kevin Fang.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: add full USB support

Now, with HTC pipe, it's possible to fully support USB version of AR6004.

Based on code by Kevin Fang.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Store scan request info in-advance before sending SCAN request

In current code, Scan request info is recorded in vif->scan_req
after sending SCAN request to the firmware in ath6kl_cfg80211_scan().

In some corner cases, firmware sends SCAN_COMPLETE event immediately
when it receives SCAN request, which internally executes scan
complete event handler ath6kl_cfg80211_scan_complete_event() first.
So, Scan completion handler will a get a chance to executed even
before storing scan request info in ath6kl_cfg80211_scan().

Scan completion handler never report SCAN_COMPLETE event to
cfg80211 if scan request info(vif->scan_req) is NULL. This leads
to scan failure issue ("Device or resource busy error") during
next SCAN request from the user space. This patch ensures that scan
request info is stored before sending SCAN request.

Signed-off-by: Raja Mani <rmani@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>