ath6kl: Fix the byte alignment rule to avoid loss of bytes in a TCP segment

Either first 3 bytes of the first received tcp segment or last one
over MTU size file can be loss due to the byte alignment problem.
Although ATH6KL_HTC_ALIGN_BYTES was defined for 'extra bytes for htc header
alignment' in the patch "Fix buffer alignment for scatter-gather
I/O"(1df94a857), there exists the bytes loss issue which means that it will be
truncated 3 bytes in the transmitted file contents if a file which has over MTU
size is transferred through TCP/IP stack.  It doesn't look like TCP/IP stack
bug of 3.5 or the latest version of kernel but the byte alignment issue.  This
patch is to use the roundup() function for the byte alignment rather than the
predefined ATH6KL_HTC_ALIGN_BYTES.

kvalo: fixed indentation

Signed-off-by: Myoungje Kim <mjei78@gmail.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: remove false check from ath6kl_rx()

Dan found a check from ath6kl_rx() which doesn't make any sense at all:

"  1327          if (status || !(skb->data + HTC_HDR_LENGTH)) {
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
skb->data is a pointer.  This pointer math is always going to be false.
Should it be testing "packet->act_len < HTC_HDR_LENGTH" or something?"

I don't know what the check really was supposed to do, but I think Dan's guess
is right. Fix it accordingly.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Don't advertise HT40 support in 2.4 Ghz

HT40 is not supported in 2.4Ghz.

Signed-off-by: Vasanthakumar Thiagarajan <vthiagar@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Add AR6004 1.2 support for USB and SDIO

Add the necessary change for AR6004 1.2 chip support

Signed-off-by: Ray Chen <raychen@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Normalize use of FW_DIR

kvalo: do the same changes for ar6004 hw1.2 as well

Cc: Kalle Valo <kvalo@qca.qualcomm.com>
Cc: "John W. Linville" <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: change || to &&

The original conditions are always true.  I think && was intended here,
but I don't have the hardware to test.  Could you take a look?

kvalo: Chilam confirmed that the fix is valid

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: fix an indenting issue

This is supposed to be pushed in one indent level.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: unblock fwlog_block_read() on exit

Complete the waiting fwlog_block_read on debugfs cleanup, otherwise
userspace and module unload might softlock.

Signed-off-by: Thomas Pedersen <c_tpeder@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: include in.h explicitly

Do not assume anyone before us includes it for us.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: check for sband existence when creating scan cmd

The patch "ath6kl: support fw reporting phy capabilities" gave the
firmware the ability to disable certain wiphy supported bands. Check if
this is the case in ath6kl_wmi_beginscan_cmd to avoid dereferencing a
NULL pointer.

kvalo: change the patch so that there's no code between declarations

Signed-off-by: Thomas Pedersen <c_tpeder@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Multicast filter support in wow suspend and non-suspend

This patch enables all multicast packets in non suspend mode
and enable multicast filtering in wow suspend mode. This also
fixes a bug in multicast where the driver assumed disable
multicast-all command disabled/filtered all multicast
packets, which was wrong assumption, because firmware will
apply the programmed filter.

Multicast requirements
 - Enable forward all multicast packets(no filtering) in
      non suspend mode.
 - Enable multicast filtering in wow suspend mode for both
      AP and CLIENT.

kvalo: fix a checkpatch warning and drop unrelated newline removal

Signed-off-by: Naveen Gangadharan <ngangadh@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Fix bss filter setting while scanning

bss filter is configured to allow the frames from all the bss other
than the currenly connected one, this is done when a scan is requested
in connected state. There is no reason to filter out the currently
connected bss, configure the filter to allow all the bss. This would
fix the reporting of stale rssi of the current bss while scanning.

Reported-by: Naveen singh <navesing@qca.qualcomm.com>
Signed-off-by: Vasanthakumar Thiagarajan <vthiagar@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: handle background(BK) stream properly on htc mbox layer

When a STA sends huge BK QoS data frame first and then sends BE/VI/VO
QoS data frame, the corresponding throughput becomes much lower than
that without sends BK QoS data frame before.

The root cause is that when station send BK stream, the tx credits of
BK stream don't return back to higher priority QoS stream such as BE,
VI, and VO stream. This patch will handle BK stream properly, when
there is higher priority QoS stream, it will seek tx credits from BK
stream properly.

Signed-off-by: Kevin Fang <kevin.fang@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Update netstats for some of the tx failrues in ath6kl_data_tx()

There are few cases where the tx skb is dropped but netstats is
not updated, fix this.

Signed-off-by: Vasanthakumar Thiagarajan <vthiagar@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Complete failed tx packet in ath6kl_htc_tx_from_queue()

Return status of ath6kl_htc_tx_issue() is ignored in
ath6kl_htc_tx_from_queue(), but failed tx packet is
is not cleaned up. To fix memory leak in this case, call
completion with error. Also, throw an error debug message
when tx fails in ath6kl_sdio_write_async() due to shortage
in bus request buffer.

kvalo: change the error message to WARN_ON_ONCE()

Signed-off-by: Vasanthakumar Thiagarajan <vthiagar@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl_sdio: Fix the EAPOL out of order issue

Send the EAPOL and management frames in the same AC_VO queue. The issue
happens when the AP supports QOS, the management frames are sent to AC_VO
queue and EAP frame goes to AC_BE queue. Even though the EAP frame is
queued before the DEAUTH management frame, as they are queued on different
h/w queues, order of delivery between these frames cannot be controlled.

This fixes the connection failure seen in P2P case.

Signed-off-by: Vivek Natarajan <nataraja@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Use correct max-scan-SSIDs limit

The currently used firmware images support 16 SSIDs in the scan
request (indexes 0..15), so update the host driver to use the same
limit to allow some more SSIDs to be scanned per request. In addition,
change the max-index to max-SSIDs to make it easier to understand the
implementation and fix couple of off-by-one checks that could limit
the maximum number of entries too strictly.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>

Conflicts:
	drivers/net/wireless/ath/ath6kl/cfg80211.c
ath6kl: Add wow multicast firmware capability support

Infrastructure to enable Multicast WOW support based on
firmware capability added to the driver.This enables
different customers or chips to control this feature based
on firmware capability.

kvalo: Firmware capability infrastructure for multicast wow feature,
indetation fixes.

Signed-off-by: Naveen Gangadharan <ngangadh@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>

Conflicts:
	drivers/net/wireless/ath/ath6kl/core.h
ath6kl: issue wmi disconnect after notifying cfg80211

ath6kl would issue a wmi disconnect command in response to a remote
disconnect and return early without notifying cfg80211, only sending a
cfg80211_disconnected (with reason code always 3) in response to the
second disconnect firmware event.

Pass the right reason code to cfg80211 on the first disconnect instead.

This fixes at least one bug where a p2p client would stop trying to
connect after receiving a stale RSN deauth which was reported to
cfg80211 as GO leaving BSS.

Signed-off-by: Thomas Pedersen <c_tpeder@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath6kl: Fix missing gpio pin 9 configuration

GPIO pin 9 also needs to be configured along with other gpio
pins to avoid sdio crc errors. I've not experienced any issue
with missing this particular gpio pin configuration, found dunring
code review. This can potentially improve rx performance.

Signed-off-by: Vasanthakumar Thiagarajan <vthiagar@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>